Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(composer): render selected skills as inline nodes
Tioit-Wang70c91e0ef6f1
diff --git a/apps/desktop/src/features/chat/composer/editor.ts b/apps/desktop/src/features/chat/composer/editor.tsindex 7c56694db..a8971ba67 100644--- a/apps/desktop/src/features/chat/composer/editor.ts+++ b/apps/desktop/src/features/chat/composer/editor.ts@@ -1,4 +1,5 @@import {+ composerMentionText,fileReferenceLabel,formatFileInsert,} from "@pi-desktop/shared";@@ -42,7 +43,7 @@ export function createFileReference(metadata?: {size?: number;localReference?: string;- kind?: "image" | "file" | "session" | "directory" | "agent";+ kind?: ComposerFileReference["kind"];mimeType?: string;token?: string;lineRange?: FileLineRange;@@ -54,11 +55,9 @@ export function createFileReference(id: `composer-file-${composerFileReferenceSequence}`,sessionId,path,- // A plugin mark's label is shown as given; it is no path.- // A plugin mark's label is shown as given, and a session reference is- // named by its conversation; neither is a path.+ // Catalog and plugin labels are not filenames.name:- isPluginMark(metadata) || metadata?.kind === "session" || metadata?.kind === "agent"+ isPluginMark(metadata) || metadata?.kind === "session" || metadata?.kind === "agent" || metadata?.kind === "skill"? (preferredName ?? ""): fileReferenceLabel(path, preferredName),kind: metadata?.kind ?? (isImageFilePath(path) ? "image" : "file"),@@ -337,6 +336,7 @@ const CHIP_ICON_SVG: Record<string, string> = {'<path d="M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z"/>',agent:'<path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>',+ skill: '<path d="M12 7c-2-2-6-3-10-2v14c4-1 8 0 10 2 2-2 6-3 10-2V5c-4-1-8 0-10 2Zm0 0v14"/>',fold: '<rect width="14" height="14" x="8" y="8" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',};@@ -344,7 +344,7 @@ function chipIconKey(reference: ComposerFileReference): string {if (reference.plugin?.kind === "mark") return "plugin";if (reference.plugin?.kind === "fold") return "fold";if (reference.kind === "session") return "session";- if (reference.kind === "agent") return "agent";+ if (reference.kind === "agent" || reference.kind === "skill") return reference.kind;if (reference.kind === "directory") return "dir";if (reference.lineRange) return "file";const mime = reference.mimeType ?? "";@@ -366,7 +366,7 @@ function chipSvg(key: string, size = 13): string {export function isEditableTextReference(reference: ComposerFileReference): boolean {if (reference.localReference || reference.lineRange) return false;- if (isPluginMark(reference) || reference.kind === "directory" || reference.kind === "agent") return false;+ if (isPluginMark(reference) || reference.kind === "directory" || reference.kind === "agent" || reference.kind === "skill") return false;return reference.mimeType?.toLowerCase() === "text/plain" || /\.txt$/i.test(reference.name);}@@ -387,11 +387,10 @@ function buildChipElement(// A mark names the plugin that put it there where a file names its path.const origin = isPluginMark(reference)? (reference.plugin?.pluginId ?? "")- : reference.kind === "agent"- ? `@${reference.path}`- : reference.path;+ : composerMentionText(reference) ?? reference.path;if (isPluginMark(reference)) chip.dataset.pluginMark = reference.plugin?.kind;if (reference.kind === "agent") chip.dataset.agent = reference.path;+ if (reference.kind === "skill") chip.dataset.skill = reference.path;chip.title = origin;// An image keeps the compact chip and opens its preview, a session chip opens// that conversation, and only plain text expands into editable draft text.diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerCompletions.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerCompletions.tsindex 05521b996..c73ebb90a 100644--- a/apps/desktop/src/features/chat/composer/hooks/useComposerCompletions.ts+++ b/apps/desktop/src/features/chat/composer/hooks/useComposerCompletions.ts@@ -200,21 +200,18 @@ export function useComposerCompletions({const result = host.accept(index);if (!result) return;invalidateComposerTransforms();- const acceptedAgent = result.agentReference;- if (acceptedAgent) {- // The same atomic chip a file gets: it displays and deletes as one- // thing, and serializes to `@name` only at send time.+ const mention = result.mention;+ if (mention) {const token = nextChipToken();+ // Slash completion leaves the caret after an editable argument separator.+ const insert = mention.kind === "skill" ? `${token} ` : token;applyEditorDraft(- result.value.slice(0, result.cursor) + token + result.value.slice(result.cursor),+ result.value.slice(0, result.cursor) + insert + result.value.slice(result.cursor),[...fileReferencesRef.current,- createFileReference(acceptedAgent.name, acceptedAgent.name, referenceSessionId, {- kind: "agent",- token,- }),+ createFileReference(mention.id, mention.label, referenceSessionId, { kind: mention.kind, token }),],- result.cursor + token.length,+ result.cursor + insert.length,);return;}diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerDraft.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerDraft.tsindex 2fea1932c..2dd8fb5c9 100644--- a/apps/desktop/src/features/chat/composer/hooks/useComposerDraft.ts+++ b/apps/desktop/src/features/chat/composer/hooks/useComposerDraft.ts@@ -295,7 +295,7 @@ export function useComposerDraft({nextValue,referenceByTokenRef.current,(reference) =>- t(isPluginMark(reference) ? "chat.removePluginMark" : "chat.removeFileReference", {+ t(isPluginMark(reference) || reference.kind === "skill" ? "chat.removePluginMark" : "chat.removeFileReference", {name: reference.name,}),(token) => removeChipByTokenRef.current(token),@@ -505,13 +505,12 @@ export function useComposerDraft({compositionRef.current = null;previousWorkspacePathRef.current = workspacePath;const current = fileReferencesRef.current;- // Plugin marks carry their text, not a workspace path, a session- // reference names a conversation and an agent chip names a subagent- // rather than a file in this project.+ // Only workspace-relative file references belong to the previous project.const survives = (fileReference: ComposerFileReference) =>Boolean(fileReference.plugin) ||fileReference.kind === "session" ||fileReference.kind === "agent" ||+ fileReference.kind === "skill" ||isPersistedScratchReference(fileReference.path);const kept = current.filter(survives);if (kept.length === current.length) return;diff --git a/apps/desktop/src/features/chat/composer/model.ts b/apps/desktop/src/features/chat/composer/model.tsindex ddc7bb51e..908b511a6 100644--- a/apps/desktop/src/features/chat/composer/model.ts+++ b/apps/desktop/src/features/chat/composer/model.ts@@ -13,7 +13,7 @@ import {sessionThinkingMenuLevels,} from "@pi-desktop/shared";import { sameComposerModelId } from "../../../lib/composer-models.ts";-import type { ComposerPluginPart } from "../../../lib/composer-smart-stop";+import type { ComposerDraftFileReference, ComposerPluginPart } from "../../../lib/composer-smart-stop";import { providerThinkingLevels } from "../../../lib/session-thinking.ts";export const COMPOSER_MIN_HEIGHT_PX = 28;@@ -66,7 +66,7 @@ export type ComposerFileReference = {sessionId: string;path: string;name: string;- kind: "image" | "file" | "session" | "directory" | "agent";+ kind: NonNullable<ComposerDraftFileReference["kind"]>;mimeType?: string;token?: string;plugin?: ComposerPluginPart;diff --git a/apps/desktop/src/hooks/use-composer-autocomplete.ts b/apps/desktop/src/hooks/use-composer-autocomplete.tsindex 4ea391f18..9c4e7ac21 100644--- a/apps/desktop/src/hooks/use-composer-autocomplete.ts+++ b/apps/desktop/src/hooks/use-composer-autocomplete.ts@@ -443,7 +443,7 @@ export function useComposerAutocomplete({value: string;cursor: number;fileReference?: { path: string; name: string };- agentReference?: { name: string };+ mention?: { kind: "agent" | "skill"; id: string; label: string };}| null => {if (!trigger) return null;@@ -452,7 +452,13 @@ export function useComposerAutocomplete({if (item.kind === "agent") {return {...applyCompletion(value, trigger, ""),- agentReference: { name: item.agent.name },+ mention: { kind: "agent", id: item.agent.name, label: item.agent.name },+ };+ }+ if (item.kind === "command" && item.command.kind === "skill" && item.command.skillId) {+ return {+ ...applyCompletion(value, trigger, ""),+ mention: { kind: "skill", id: item.command.skillId, label: item.command.title || item.command.skillId },};}if (item.kind === "path" && item.entry.kind === "file") {diff --git a/apps/desktop/src/lib/composer-draft-cache.ts b/apps/desktop/src/lib/composer-draft-cache.tsindex ea9c417bb..eda048d5b 100644--- a/apps/desktop/src/lib/composer-draft-cache.ts+++ b/apps/desktop/src/lib/composer-draft-cache.ts@@ -27,7 +27,7 @@ export type ComposerDraftFileInput = {sessionId?: string;path: string;name: string;- kind?: "image" | "file" | "session" | "directory" | "agent";+ kind?: ComposerDraftFileReference["kind"];mimeType?: string;token?: string;plugin?: ComposerPluginPart;diff --git a/apps/desktop/src/lib/composer-input-history.ts b/apps/desktop/src/lib/composer-input-history.tsindex e7ba63602..a3da7c35e 100644--- a/apps/desktop/src/lib/composer-input-history.ts+++ b/apps/desktop/src/lib/composer-input-history.ts@@ -40,7 +40,8 @@ function readReference(value: unknown): HistoryReference | null {if (!value || typeof value !== "object") return null;const row = value as Record<string, unknown>;if (typeof row.path !== "string" || !row.path || typeof row.name !== "string") return null;- const kind = row.kind === "image" || row.kind === "file" || row.kind === "directory" ? row.kind : undefined;+ const kind = row.kind === "image" || row.kind === "file" || row.kind === "directory" || row.kind === "skill"+ ? row.kind : undefined;const lineRange = parseFileLineRange(row.lineRange);return {path: row.path,diff --git a/apps/desktop/src/lib/composer-smart-stop.ts b/apps/desktop/src/lib/composer-smart-stop.tsindex 9b0cb23ce..ce9495789 100644--- a/apps/desktop/src/lib/composer-smart-stop.ts+++ b/apps/desktop/src/lib/composer-smart-stop.ts@@ -28,7 +28,7 @@ export type ComposerDraftFileReference = {lineRange?: import("@pi-desktop/shared").FileLineRange;path: string;name: string;- kind?: "image" | "file" | "session" | "directory" | "agent";+ kind?: "image" | "file" | "session" | "directory" | "agent" | "skill";mimeType?: string;/** Visible inline token for a generated large-text paste reference. */token?: string;diff --git a/apps/desktop/src/lib/session-transcript.ts b/apps/desktop/src/lib/session-transcript.tsindex 72a6b70aa..7e7834226 100644--- a/apps/desktop/src/lib/session-transcript.ts+++ b/apps/desktop/src/lib/session-transcript.ts@@ -8,16 +8,7 @@ import {registerSessionMessageRewrite,} from "./session-transcript-updates";-type OptimisticFileReference = {- size?: number;- localReference?: string;- path: string;- name: string;- kind?: "image" | "file" | "session" | "directory" | "agent";- mimeType?: string;- /** Large-text paste tokens travel inline in the text, not as attachments. */- token?: string;-};+import type { ComposerDraftFileReference } from "./composer-smart-stop";const OPTIMISTIC_USER_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;const MAX_OPTIMISTIC_ECHO_DELAY_MS = 30_000;@@ -32,14 +23,14 @@ const IMAGE_PATH_PATTERN = /\.(avif|bmp|gif|heic|jpe?g|png|tiff?|webp)$/i;export function optimisticUserMessage(id: string,content: string,- fileReferences: readonly OptimisticFileReference[] = [],+ fileReferences: readonly ComposerDraftFileReference[] = [],createdAt: string = new Date().toISOString(),): UiMessage {// A plain file chip travels as `@path` text and needs no attachment row, but// an image chip is one: it also records where its path sits, so the row shows// the image in place before the durable echo arrives (D288).const rendered = fileReferences.flatMap((reference) => {- if (reference.kind === "directory" || reference.kind === "agent") return [];+ if (reference.kind === "directory" || reference.kind === "agent" || reference.kind === "skill") return [];const kind =reference.kind ??(IMAGE_PATH_PATTERN.test(reference.path) ? ("image" as const) : ("file" as const));diff --git a/apps/desktop/src/stores/helpers/store-helpers.ts b/apps/desktop/src/stores/helpers/store-helpers.tsindex ee2043b17..43b267078 100644--- a/apps/desktop/src/stores/helpers/store-helpers.ts+++ b/apps/desktop/src/stores/helpers/store-helpers.ts@@ -27,8 +27,8 @@ export function promptAttachmentsFromDraft(return references.flatMap((reference) => {// A session link is prompt text: main resolves it into a conversation// reference, and it never travels as a structured attachment.- // An `@agent` chip is prompt text too (ADR 0346).- if (reference.kind === "session" || reference.kind === "directory" || reference.kind === "agent") return [];+ // Agent and Skill mentions are resolved from prompt text at send time.+ if (reference.kind === "session" || reference.kind === "directory" || reference.kind === "agent" || reference.kind === "skill") return [];const kind =reference.kind ??(/\.(avif|bmp|gif|heic|jpe?g|png|tiff?|webp)$/i.test(reference.path)diff --git a/apps/desktop/test/composer-agent-mention-user-path.test.mjs b/apps/desktop/test/composer-agent-mention-user-path.test.mjsindex 29077cad5..c96720e9c 100644--- a/apps/desktop/test/composer-agent-mention-user-path.test.mjs+++ b/apps/desktop/test/composer-agent-mention-user-path.test.mjs@@ -24,12 +24,19 @@ import { catalogs, flattenCatalog } from "@pi-desktop/i18n";import { findAgentMentions, serializeComposerFileReferences } from "@pi-desktop/shared";import { useComposerDraft } from "../../apps/desktop/src/features/chat/composer/hooks/useComposerDraft";import { useComposerCompletions } from "../../apps/desktop/src/features/chat/composer/hooks/useComposerCompletions";+import { useComposerSubmit } from "../../apps/desktop/src/features/chat/composer/hooks/useComposerSubmit";+import { loadComposerInputHistory, rememberComposerInput } from "../../apps/desktop/src/lib/composer-input-history";+import { promptAttachmentsFromDraft } from "../../apps/desktop/src/stores/helpers/store-helpers";import { ComposerInput } from "../../apps/desktop/src/features/chat/composer/ComposerInput";import { ComposerAutocomplete } from "../../apps/desktop/src/components/ComposerAutocomplete";import { setEditorCaret } from "../../apps/desktop/src/features/chat/composer/editor";import { api } from "../../apps/desktop/src/lib/api";import { useAppStore } from "../../apps/desktop/src/stores/app-store";+api.composerCommands = async () => ({ commands: [+ { name: "skill:plugin/review", title: "Review", skillId: "plugin/review", kind: "skill" },+ { name: "compact", title: "Compact", kind: "builtin" },+] });let catalogReads = 0;api.fsIndex = async () => ({ entries: [{ path: "README.md", kind: "file" }, { path: "fixer", kind: "file" }], truncated: false });api.subagentCatalog = async () => {@@ -50,6 +57,7 @@ useAppStore.setState({ activeSessionId: "s1", workspace: { path: "/repo", name:const noop = () => {};let draft;+let sent;function Fixture({ agentsEnabled }) {draft = useComposerDraft({variant: "docked", activeSessionId: "s1", workspacePath: "/repo",@@ -63,11 +71,18 @@ function Fixture({ agentsEnabled }) {applyEditorDraft: draft.applyEditorDraft, handleInput: draft.handleInput,invalidateComposerTransforms: noop,});+ const submission = useComposerSubmit({+ draft, value: draft.value, draftKey: draft.draftKey, activeSessionId: "s1",+ modelReady: true, sendBlocked: false, pasting: false, activeFileReferences: draft.activeFileReferences,+ t: key => key, invalidateComposerTransforms: noop, queuedPrompts: [], showToast: noop,+ sendPrompt: async (content, snapshot) => { sent = { content, snapshot }; return true; },+ recordHistory: (snapshot, id) => rememberComposerInput(id, snapshot),+ });return <><ComposerInput inputRef={draft.ref} value={draft.value} placeholderText="" placeholderKey="fixture"inputBlocked={false} pasting={false} enterToSend={false} runActive={false}composerAc={completions.ac} onPaste={noop} onAcceptCompletion={completions.acceptCompletion}- onSubmit={noop} onInsertNewline={noop} onHistoryNavigate={() => false}+ onSubmit={submission.submit} onInsertNewline={noop} onHistoryNavigate={() => false}onInput={(source, caret, composing) => completions.handleInput(source, caret, composing)}onCompositionStart={() => draft.setComposing(true)}onCompositionEnd={() => draft.setComposing(false)}@@ -138,12 +153,48 @@ window.agentMentionProbe = async () => {const serialized = serializeComposerFileReferences(text, references);check(findAgentMentions(serialized, new Set(["explorer"])).length === 1, "the serialized prompt lost the mention");+ // Only a selected Skill gets a node. Ordinary slash commands stay editable.+ const acceptSlash = async (query, name) => {+ await type(query);+ await until(() => document.querySelector('.composer-ac-name')?.textContent === name, "missing " + name);+ editor().dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));+ await settle();+ };+ await acceptSlash("/compact", "/compact");+ check(draft.value === "/compact " && !editor().querySelector(".composer-chip"), "ordinary command became a chip");+ await acceptSlash("please /review", "/skill:plugin/review");+ const skill = () => editor().querySelector('[data-skill="plugin/review"]');+ check(skill()?.contentEditable === "false", "selected Skill is not an atomic node");+ check(skill().textContent.includes("Review"), "missing Skill label");+ document.execCommand("insertText", false, "changes");+ await settle();+ const prompt = () => serializeComposerFileReferences(draft.value, draft.fileReferencesRef.current);+ check(prompt() === "please /skill:plugin/review changes", "arguments or canonical Skill token lost");+ const range = document.createRange();+ range.selectNode(skill());+ getSelection().removeAllRanges();+ getSelection().addRange(range);+ document.execCommand("delete");+ await settle();+ check(!skill() && !prompt().includes("/skill:"), "native delete left part of the Skill");+ document.execCommand("undo");+ await settle();+ check(skill() && prompt() === "please /skill:plugin/review changes", "undo lost the Skill identity");+ editor().dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", ctrlKey: true, bubbles: true }));+ await until(() => sent && !draft.value, "submission did not leave the editor");+ check(sent.content === "please /skill:plugin/review changes", "incorrect send payload");+ check(!promptAttachmentsFromDraft(sent.snapshot.fileReferences).length, "Skill traveled as an attachment");+ const [entry] = loadComposerInputHistory("s1");+ draft.restoreDraftForKey("s1", entry);+ await settle();+ check(skill()?.title === "/skill:plugin/review" && prompt() === sent.content, "history lost the Skill node");+flushSync(() => rootNode.unmount());return { passed: true, serialized };};`;-test("the @ menu offers subagents in Agent mode and accepts one as an atomic chip", {+test("the composer accepts agent and Skill mentions as atomic chips and sends the canonical prompt", {skip: process.platform === "linux" && !process.env.DISPLAY ? "Electron requires a display" : false,}, async () => {const temp = await mkdtemp(join(tmpdir(), "pi-agent-mention-ui-"));diff --git a/apps/desktop/test/composer-file-reference-display.test.mjs b/apps/desktop/test/composer-file-reference-display.test.mjsindex 927e48c70..42c841ff7 100644--- a/apps/desktop/test/composer-file-reference-display.test.mjs+++ b/apps/desktop/test/composer-file-reference-display.test.mjs@@ -80,7 +80,7 @@ test("composer renders atomic inline chips and serializes paths on send", () =>// A file chip's title is its path; a plugin mark's is its plugin.assert.match(composer,- /isPluginMark\(reference\)\s*\? \(reference\.plugin\?\.pluginId \?\? ""\)\s*: reference\.kind === "agent"\s*\? `@\$\{reference\.path\}`\s*: reference\.path/,+ /isPluginMark\(reference\)\s*\? \(reference\.plugin\?\.pluginId \?\? ""\)\s*: composerMentionText\(reference\) \?\? reference\.path/,);assert.match(composer, /chip\.title = origin/);assert.match(diff --git a/apps/desktop/test/composer-file-reference-draft.test.mjs b/apps/desktop/test/composer-file-reference-draft.test.mjsindex 432994097..80bdd070e 100644--- a/apps/desktop/test/composer-file-reference-draft.test.mjs+++ b/apps/desktop/test/composer-file-reference-draft.test.mjs@@ -3,7 +3,7 @@ import { readFileSync } from "node:fs";import vm from "node:vm";import test from "node:test";import ts from "typescript";-import { fileLineLabel, isRenderableAttachment } from "@pi-desktop/shared";+import { composerMentionText, fileLineLabel, isRenderableAttachment } from "@pi-desktop/shared";import { snapshotComposerDraft } from "../src/lib/composer-draft-cache.ts";function loadFunction(path, name, globals = {}) {@@ -58,7 +58,7 @@ test("file card shows size, remains removable, and does not expand or preview coappend(...items) { this.children.push(...items); },};}- const globals = { document: { createElement: element }, chipIconKey: () => "file", chipSvg: () => "", isPluginMark: () => false, fileLineLabel };+ const globals = { document: { createElement: element }, chipIconKey: () => "file", chipSvg: () => "", isPluginMark: () => false, fileLineLabel, composerMentionText };globals.isEditableTextReference = loadFunction("../src/features/chat/composer/editor.ts", "isEditableTextReference", globals);const build = loadFunction("../src/features/chat/composer/editor.ts", "buildChipElement", globals);let removed;diff --git a/docs/adr/0219-user-invoked-skills-in-composer.md b/docs/adr/0219-user-invoked-skills-in-composer.mdindex 75cd7e6f2..a1a0264ca 100644--- a/docs/adr/0219-user-invoked-skills-in-composer.md+++ b/docs/adr/0219-user-invoked-skills-in-composer.md@@ -15,8 +15,8 @@ user who knows a workflow should apply.Active built-in, plugin, and user Skills contribute entries to the composer slash menuin a trailing `Skills` group, named with the explicit `skill:<id>` prefix while-`skillId` keeps the original id. Selecting one inserts `/skill:<skill-id> `, and-sending uses the ordinary prompt path: Electron main resolves the command against the+`skillId` keeps the original id. Selecting one places an atomic editor chip and+an argument separator; it serializes to `/skill:<skill-id> `. Sending uses the ordinary prompt path: Electron main resolves the command against thesession project, revalidates active scope and permissions at send time, and keeps thetyped slash form for the transcript chip. Main then persists a model-facinginstruction to call the local `Skill` tool with each validated id before the remainingdiff --git a/docs/spec/04-ux/04-builtin-commands.md b/docs/spec/04-ux/04-builtin-commands.mdindex b30d6369d..2d1c7e2d4 100644--- a/docs/spec/04-ux/04-builtin-commands.md+++ b/docs/spec/04-ux/04-builtin-commands.md@@ -133,7 +133,9 @@ display name and description in a separate **Skills** group after extensioncommands. This group is always last; a Skill with the same unprefixed name as acommand or template remains independently addressable.-Selecting a Skill inserts `/skill:<skill-id> `. After the first token, typing `/`+Selecting a Skill inserts a non-editable inline chip followed by an editable space.+The chip shows the catalog title, deletes as a unit, and sends `/skill:<skill-id>`.+Typing the slash form by hand still works as plain text. After the first token, typing `/`offers Skills only; app commands and templates remain first-token actions.Multiple Skills may be selected in one message. Sending keeps each validatedSkill as its own transcript chip, with ordinary prompt text between chips, anddiff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 1422e22a8..5228ac534 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -3777,8 +3777,8 @@ Anatomy:not support Desktop-managed MCP selections. Existing command aliases wincollisions. See `docs/adr/composer-mcp-invocations.md`.- Active Skill commands use `/skill:<id>` for builtin, plugin, and user Skills.- Completion inserts this explicit prefix; sending resolves it to the unchanged- Skill ID. Unprefixed names are not Skill aliases; existing app commands and+ Completion displays the Skill as a chip; sending resolves its explicit slash+ token to the unchanged Skill ID. Unprefixed names are not Skill aliases; existing app commands andprompt templates keep their names. Saved Skill mentions remain unchanged.- A whitespace-delimited `/` later in the draft offers active Skills only.Completion replaces only the token under the cursor, so several Skills and@@ -3821,7 +3821,9 @@ Anatomy:each mention. Skill and agent mentions combine; a leading template or appcommand is not rewritten. Stop restores the typed `command`, never therewritten `content`.-- Accepting commands and directories inserts text (`/name ` / `@dir/`);+- Accepting a Skill inserts an atomic inline chip with its catalog title and an+ editable space for arguments; it serializes to `/skill:<id>`, not a file.+ Accepting other commands and directories inserts text (`/name ` / `@dir/`);accepting a completed file inserts the inline chip rather than deleting thetrigger. Immediatelybefore dispatch, ordinary references serialize in stable order after thediff --git a/docs/spec/06-delivery/e2e/conversation.md b/docs/spec/06-delivery/e2e/conversation.mdindex dbfdbc779..1f65c87a6 100644--- a/docs/spec/06-delivery/e2e/conversation.md+++ b/docs/spec/06-delivery/e2e/conversation.md@@ -1492,7 +1492,9 @@ folder/mixed-selection behavior. No system clipboard contents are changed.changes occur. The keyboard hint includes Shift+Enter and a submit hint, while thecommand/file hint includes `/` and `@`. The slash menu still contains `/new`,`/compact`, `/agent-mode`, `/plan-mode`, and `/goal-mode`, followed by a- Skills group at the bottom. Selecting a Skill inserts `/skill:<id>`; sending+ Skills group at the bottom. Select a Skill mid-sentence and type its arguments;+ verify the editor has one atomic Skill node, deletion removes the whole node,+ and native undo restores it. The node serializes to `/skill:<id>` without an attachment; sendingit keeps the typed command chip visible and the model calls `Skill` with theoriginal ID before answering. Verify builtin, plugin, and user Skill prefixes,multiple inline references, and a prompt template sharing the unprefixeddiff --git a/packages/shared/src/changelog-de.ts b/packages/shared/src/changelog-de.tsindex 6ba93710f..cafbaabfa 100644--- a/packages/shared/src/changelog-de.ts+++ b/packages/shared/src/changelog-de.ts@@ -5,6 +5,7 @@ export const deEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "Im /-Menü ausgewählte Skills erscheinen als einzelne Chips im Eingabefeld.","Bearbeite integrierte Rollen und Skills in den Moduseinstellungen, organisiere private Agent-Rollen und begrenze delegierte Aufgaben auf benötigte Werkzeuge und Dateien.","Verfolge aktive Subagenten optional über dem Composer und stoppe einzelne oder alle, ohne den koordinierenden Agenten anzuhalten.","Lang laufende Bash-Befehle geben nach einer ersten Wartezeit die Kontrolle zurück und laufen im Hintergrund weiter; optional melden sie Ergebnisse und setzen eine untätige Unterhaltung fort.",diff --git a/packages/shared/src/changelog-en.ts b/packages/shared/src/changelog-en.tsindex 21e84ef55..17ffaf676 100644--- a/packages/shared/src/changelog-en.ts+++ b/packages/shared/src/changelog-en.ts@@ -5,6 +5,7 @@ export const enEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "Skills selected from the / menu appear as individual chips in the composer.","Edit bundled role and skill definitions in Modes, organize private agent roles, and scope delegated work to the tools and files each role needs.","Optionally follow active subagents above the Composer and stop one or all without stopping the coordinator.","Long-running Bash commands return control after an initial wait and can continue in the background; optionally report results and resume an idle conversation when finished.",diff --git a/packages/shared/src/changelog-es.ts b/packages/shared/src/changelog-es.tsindex 0738348cb..10593d952 100644--- a/packages/shared/src/changelog-es.ts+++ b/packages/shared/src/changelog-es.ts@@ -5,6 +5,7 @@ export const esEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "Las habilidades seleccionadas en el menú / aparecen como etiquetas individuales en el editor.","Edita los roles y las habilidades incluidos en los ajustes de Modos, organiza roles privados de agente y limita las tareas delegadas a las herramientas y archivos necesarios.","Sigue opcionalmente a los subagentes activos sobre el Composer y detén uno o todos sin detener al agente coordinador.","Los comandos Bash de larga duración devuelven el control tras una espera inicial y siguen en segundo plano; opcionalmente informan del resultado y reanudan una conversación inactiva.",diff --git a/packages/shared/src/changelog-fr.ts b/packages/shared/src/changelog-fr.tsindex de71e7fd9..269126d2d 100644--- a/packages/shared/src/changelog-fr.ts+++ b/packages/shared/src/changelog-fr.ts@@ -5,6 +5,7 @@ export const frEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "Les compétences choisies dans le menu / apparaissent sous forme de pastilles dans le champ de saisie.","Modifiez les rôles et compétences intégrés dans les réglages des Modes, organisez les rôles d'agent privés et limitez les tâches déléguées aux outils et fichiers nécessaires.","Suivez en option les sous-agents actifs au-dessus du Composer et arrêtez-en un ou tous sans interrompre l'agent coordinateur.","Les commandes Bash longues rendent la main après une première attente et continuent en arrière-plan ; elles peuvent aussi signaler leur résultat et reprendre une conversation inactive.",diff --git a/packages/shared/src/changelog-ko.ts b/packages/shared/src/changelog-ko.tsindex 6074beb68..a767f7b47 100644--- a/packages/shared/src/changelog-ko.ts+++ b/packages/shared/src/changelog-ko.ts@@ -5,6 +5,7 @@ export const koEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "/ 메뉴에서 선택한 스킬이 입력창에 개별 태그로 표시됩니다.","모드 설정에서 기본 역할과 스킬을 편집하고, 비공개 에이전트 역할을 정리하며, 역할에 필요한 도구와 파일로 위임 작업 범위를 제한할 수 있습니다.","입력창 위에서 실행 중인 하위 에이전트를 선택적으로 확인하고, 조정 에이전트를 멈추지 않은 채 하나 또는 모두를 중지할 수 있습니다.","장시간 실행되는 Bash 명령은 초기 대기 후 제어를 돌려주고 백그라운드에서 계속 실행됩니다. 선택하면 결과를 알리고 유휴 대화를 이어갈 수도 있습니다.",diff --git a/packages/shared/src/changelog-pt-BR.ts b/packages/shared/src/changelog-pt-BR.tsindex c4a6798f3..3af8371c4 100644--- a/packages/shared/src/changelog-pt-BR.ts+++ b/packages/shared/src/changelog-pt-BR.ts@@ -5,6 +5,7 @@ export const ptBREntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "As habilidades selecionadas no menu / aparecem como etiquetas individuais no campo de mensagem.","Edite funções e habilidades incluídas nas configurações de Modos, organize funções privadas de agentes e limite tarefas delegadas às ferramentas e arquivos necessários.","Opcionalmente acompanhe subagentes ativos acima do Composer e pare um ou todos sem interromper o agente coordenador.","Comandos Bash longos devolvem o controle após a espera inicial e continuam em segundo plano; opcionalmente informam o resultado e retomam uma conversa ociosa.",diff --git a/packages/shared/src/changelog-tr.ts b/packages/shared/src/changelog-tr.tsindex eea574b92..1d09f07d6 100644--- a/packages/shared/src/changelog-tr.ts+++ b/packages/shared/src/changelog-tr.ts@@ -5,6 +5,7 @@ export const trEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "/ menüsünden seçilen beceriler ileti alanında ayrı etiketler olarak görünür.","Modlar ayarlarında yerleşik rolleri ve becerileri düzenleyin, özel ajan rollerini düzenleyin ve devredilen işleri rolün ihtiyaç duyduğu araç ve dosyalarla sınırlayın.","Etkin alt ajanları isteğe bağlı olarak Composer'ın üzerinde izleyin; koordinatör ajanı durdurmadan birini veya tümünü durdurun.","Uzun süren Bash komutları ilk beklemeden sonra kontrolü geri verir ve arka planda çalışmayı sürdürür; isteğe bağlı olarak sonucu bildirip boşta olan bir sohbeti devam ettirebilir.",diff --git a/packages/shared/src/changelog-zh-CN.ts b/packages/shared/src/changelog-zh-CN.tsindex 17fbac5cf..502e5052b 100644--- a/packages/shared/src/changelog-zh-CN.ts+++ b/packages/shared/src/changelog-zh-CN.ts@@ -5,6 +5,7 @@ export const zhCNEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "从 / 菜单选择的技能会在输入框中显示为独立标签。","可在「模式」设置中编辑内置角色与技能,整理私有 Agent 角色,并按角色所需工具和文件范围委派任务。","可选择在输入框上方查看运行中的子代理,并单独停止一个或全部子代理,而不停止主 Agent。","长时间运行的 Bash 命令会在初次等待后返回,可继续在后台执行;也可选择在命令结束后回报结果并继续空闲会话。",diff --git a/packages/shared/src/changelog-zh-TW.ts b/packages/shared/src/changelog-zh-TW.tsindex d8e23e59f..6e5c2ec61 100644--- a/packages/shared/src/changelog-zh-TW.ts+++ b/packages/shared/src/changelog-zh-TW.ts@@ -5,6 +5,7 @@ export const zhTWEntries: ChangelogEntry[] = [version: "0.24.0",date: "2026-11-24",highlights: [+ "從 / 選單選取的技能會在輸入框中顯示為獨立標籤。","可在「模式」設定中編輯內建角色與技能、整理私有 Agent 角色,並依角色所需工具和檔案範圍委派工作。","可選擇在輸入框上方查看執行中的子代理,並個別停止一個或全部子代理,而不停止主 Agent。","長時間執行的 Bash 命令會在初次等待後返回,並可繼續於背景執行;也可選擇在命令完成後回報結果並繼續閒置對話。",diff --git a/packages/shared/src/composer-trigger.test.ts b/packages/shared/src/composer-trigger.test.tsindex ab9abd32d..c90de81fb 100644--- a/packages/shared/src/composer-trigger.test.ts+++ b/packages/shared/src/composer-trigger.test.ts@@ -363,6 +363,17 @@ describe("agent mentions (ADR 0346)", () => {expect(serializeComposerFileReferences("hi", [{ path: "explorer", kind: "agent" }])).toBe("hi");});+ it("serializes adjacent Skill chips as separate canonical mentions, never trailing paths", () => {+ const refs = [+ { kind: "skill", path: "plugin/review", token: "\ue001" },+ { kind: "skill", path: "review", token: "\ue002" },+ { kind: "skill", path: "removed" },+ ];+ const text = serializeComposerFileReferences("go\ue002\ue001now", refs);+ expect(text).toBe("go /skill:review /skill:plugin/review now");+ expect(findSkillMentions(text, new Map([["skill:review", "review"]])).map(m => m.id)).toEqual(["review"]);+ });+it("keeps the file serialization byte-for-byte unchanged", () => {const file = { path: "src/a.ts", kind: "file", token: "\ue011" };expect(serializeInlineComposerFileReferences("see\ue011now", [file])).toBe("see@src/a.ts now");diff --git a/packages/shared/src/composer-trigger.ts b/packages/shared/src/composer-trigger.tsindex d30a7b1a3..e7c28ea9d 100644--- a/packages/shared/src/composer-trigger.ts+++ b/packages/shared/src/composer-trigger.ts@@ -243,7 +243,7 @@ export function serializeComposerFileReferences(): string {const content = serializeInlineComposerFileReferences(draft, references);const paths = references- .filter((reference) => !reference.token && reference.kind !== "session" && reference.kind !== "directory" && reference.kind !== "agent")+ .filter((reference) => !reference.token && reference.kind !== "session" && reference.kind !== "directory" && !composerMentionText(reference)).map((reference) => formatFileInsert(reference.path, "file")).join("").trim();@@ -289,14 +289,21 @@ function directoryPromptReference(path: string): string {return `<dir>${escaped}</dir>`;}+/** Canonical slash/at token for a catalog mention, never a filesystem path. */+export function composerMentionText(reference: { kind?: string; path: string }): string | null {+ if (reference.kind === "skill") return `/skill:${reference.path}`;+ if (reference.kind === "agent") return `@${reference.path}`;+ return null;+}+/*** Resolve only inline generated tokens (legacy @name strings or single* sentinel characters backing atomic chips). Each resolved token keeps one* separating space so adjacent chips never fuse their @paths together. A* plugin mark's token resolves to the text it sends (`plugin.send`) instead* of a path, and a session reference resolves to its `pi-desktop://` link.- * An agent chip resolves to `@name` and also keeps a space before it, because- * the send-time resolver reads an `@token` only after whitespace (ADR 0346).+ * Agent and Skill chips keep whitespace boundaries so the send-time catalog+ * resolver can match the complete mention (ADR 0219 and ADR 0346).*/export function serializeInlineComposerFileReferences(draft: string,@@ -307,24 +314,22 @@ export function serializeInlineComposerFileReferences(const token = reference.token?.trim();if (!token || !content.includes(token)) continue;const send = reference.plugin?.send;- const agent = reference.kind === "agent";+ const mention = composerMentionText(reference);const insert = reference.lineRange? fileLineLabel(reference.path, reference.lineRange): typeof send === "string"? send- : agent- ? `@${reference.path}`- : reference.kind === "session"- ? formatSessionLink(reference.path)- : reference.kind === "directory"- ? directoryPromptReference(reference.path)- : formatFileInsert(reference.path, "file").trim();+ : mention ?? (reference.kind === "session"+ ? formatSessionLink(reference.path)+ : reference.kind === "directory"+ ? directoryPromptReference(reference.path)+ : formatFileInsert(reference.path, "file").trim());let index = content.indexOf(token);while (index !== -1) {const nextChar = content[index + token.length];const separator = nextChar && !/\s/.test(nextChar) ? " " : "";const previousChar = content[index - 1];- const lead = agent && previousChar && !/\s/.test(previousChar) ? " " : "";+ const lead = mention && previousChar && !/\s/.test(previousChar) ? " " : "";content =content.slice(0, index) +lead +