From e54dff7efb460e364a39e4a22369991a20c105b9 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 3 Feb 2026 12:27:45 +0100 Subject: [PATCH] fix(coding-agent): rename SlashCommandSource "template" to "prompt" for consistency BREAKING CHANGE: RPC get_commands response and SlashCommandSource type now use "prompt" instead of "template" to match the rest of the codebase. --- packages/coding-agent/CHANGELOG.md | 4 ++++ packages/coding-agent/docs/extensions.md | 2 +- packages/coding-agent/docs/rpc.md | 4 ++-- packages/coding-agent/examples/extensions/commands.ts | 8 ++++---- packages/coding-agent/src/core/agent-session.ts | 2 +- packages/coding-agent/src/core/slash-commands.ts | 2 +- packages/coding-agent/src/modes/rpc/rpc-mode.ts | 2 +- packages/coding-agent/src/modes/rpc/rpc-types.ts | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index c142d038..e2eafdec 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Breaking Changes + +- RPC `get_commands` response and `SlashCommandSource` type: renamed `"template"` to `"prompt"` for consistency with the rest of the codebase + ### Added - Added `ExtensionAPI.getCommands()` to let extensions list available slash commands (extensions, prompt templates, skills) for invocation via `prompt` ([#1210](https://github.com/badlogic/pi-mono/pull/1210) by [@w-winter](https://github.com/w-winter)) diff --git a/packages/coding-agent/docs/extensions.md b/packages/coding-agent/docs/extensions.md index 6b1a54e5..6ee39fb4 100644 --- a/packages/coding-agent/docs/extensions.md +++ b/packages/coding-agent/docs/extensions.md @@ -958,7 +958,7 @@ Each entry has this shape: { name: string; // Command name without the leading slash description?: string; - source: "extension" | "template" | "skill"; + source: "extension" | "prompt" | "skill"; location?: "user" | "project" | "path"; // For templates and skills path?: string; // Files backing templates, skills, and extensions } diff --git a/packages/coding-agent/docs/rpc.md b/packages/coding-agent/docs/rpc.md index 60488fff..880ca29f 100644 --- a/packages/coding-agent/docs/rpc.md +++ b/packages/coding-agent/docs/rpc.md @@ -651,7 +651,7 @@ Response: "data": { "commands": [ {"name": "session-name", "description": "Set or clear session name", "source": "extension", "path": "/home/user/.pi/agent/extensions/session.ts"}, - {"name": "fix-tests", "description": "Fix failing tests", "source": "template", "location": "project", "path": "/home/user/myproject/.pi/agent/prompts/fix-tests.md"}, + {"name": "fix-tests", "description": "Fix failing tests", "source": "prompt", "location": "project", "path": "/home/user/myproject/.pi/agent/prompts/fix-tests.md"}, {"name": "skill:brave-search", "description": "Web search via Brave API", "source": "skill", "location": "user", "path": "/home/user/.pi/agent/skills/brave-search/SKILL.md"} ] } @@ -663,7 +663,7 @@ Each command has: - `description`: Human-readable description (optional for extension commands) - `source`: What kind of command: - `"extension"`: Registered via `pi.registerCommand()` in an extension - - `"template"`: Loaded from a prompt template `.md` file + - `"prompt"`: Loaded from a prompt template `.md` file - `"skill"`: Loaded from a skill directory (name is prefixed with `skill:`) - `location`: Where it was loaded from (optional, not present for extensions): - `"user"`: User-level (`~/.pi/agent/`) diff --git a/packages/coding-agent/examples/extensions/commands.ts b/packages/coding-agent/examples/extensions/commands.ts index 0a2056bc..8f25b65c 100644 --- a/packages/coding-agent/examples/extensions/commands.ts +++ b/packages/coding-agent/examples/extensions/commands.ts @@ -16,13 +16,13 @@ export default function commandsExtension(pi: ExtensionAPI) { pi.registerCommand("commands", { description: "List available slash commands", getArgumentCompletions: (prefix) => { - const sources = ["extension", "template", "skill"]; + const sources = ["extension", "prompt", "skill"]; const filtered = sources.filter((s) => s.startsWith(prefix)); return filtered.length > 0 ? filtered.map((s) => ({ value: s, label: s })) : null; }, handler: async (args, ctx) => { const commands = pi.getCommands(); - const sourceFilter = args.trim() as "extension" | "template" | "skill" | ""; + const sourceFilter = args.trim() as "extension" | "prompt" | "skill" | ""; // Filter by source if specified const filtered = sourceFilter ? commands.filter((c) => c.source === sourceFilter) : commands; @@ -39,9 +39,9 @@ export default function commandsExtension(pi: ExtensionAPI) { }; const items: string[] = []; - const sources: Array<{ key: "extension" | "template" | "skill"; label: string }> = [ + const sources: Array<{ key: "extension" | "prompt" | "skill"; label: string }> = [ { key: "extension", label: "Extensions" }, - { key: "template", label: "Templates" }, + { key: "prompt", label: "Prompts" }, { key: "skill", label: "Skills" }, ]; diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts index 4c69c7f8..b75febf0 100644 --- a/packages/coding-agent/src/core/agent-session.ts +++ b/packages/coding-agent/src/core/agent-session.ts @@ -1799,7 +1799,7 @@ export class AgentSession { const templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({ name: template.name, description: template.description, - source: "template", + source: "prompt", location: normalizeLocation(template.source), path: template.filePath, })); diff --git a/packages/coding-agent/src/core/slash-commands.ts b/packages/coding-agent/src/core/slash-commands.ts index ef77c889..48845cb9 100644 --- a/packages/coding-agent/src/core/slash-commands.ts +++ b/packages/coding-agent/src/core/slash-commands.ts @@ -1,4 +1,4 @@ -export type SlashCommandSource = "extension" | "template" | "skill"; +export type SlashCommandSource = "extension" | "prompt" | "skill"; export type SlashCommandLocation = "user" | "project" | "path"; diff --git a/packages/coding-agent/src/modes/rpc/rpc-mode.ts b/packages/coding-agent/src/modes/rpc/rpc-mode.ts index 770dba1f..0408b2ce 100644 --- a/packages/coding-agent/src/modes/rpc/rpc-mode.ts +++ b/packages/coding-agent/src/modes/rpc/rpc-mode.ts @@ -543,7 +543,7 @@ export async function runRpcMode(session: AgentSession): Promise { commands.push({ name: template.name, description: template.description, - source: "template", + source: "prompt", location: template.source as RpcSlashCommand["location"], path: template.filePath, }); diff --git a/packages/coding-agent/src/modes/rpc/rpc-types.ts b/packages/coding-agent/src/modes/rpc/rpc-types.ts index eace0811..84c8d088 100644 --- a/packages/coding-agent/src/modes/rpc/rpc-types.ts +++ b/packages/coding-agent/src/modes/rpc/rpc-types.ts @@ -77,7 +77,7 @@ export interface RpcSlashCommand { /** Human-readable description */ description?: string; /** What kind of command this is */ - source: "extension" | "template" | "skill"; + source: "extension" | "prompt" | "skill"; /** Where the command was loaded from (undefined for extensions) */ location?: "user" | "project" | "path"; /** File path to the command source */