Commit 5d5ee224a825
Changed files (1)
dots
pi
agent
extensions
dots/pi/agent/extensions/subagent-commands.ts
@@ -0,0 +1,138 @@
+/**
+ * Subagent Commands - Slash commands for common subagent workflows
+ *
+ * Provides easy-to-use slash commands that invoke the subagent tool:
+ * - /scout <query> - Fast reconnaissance with scout agent
+ * - /implement <query> - Full workflow: scout → planner → worker
+ * - /scout-and-plan <query> - Planning workflow: scout → planner
+ * - /review-code <query> - Review workflow: scout → reviewer
+ */
+
+import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
+
+export default function (pi: ExtensionAPI) {
+ // /scout - Quick reconnaissance
+ pi.registerCommand("scout", {
+ description: "Quick codebase reconnaissance with scout agent",
+ handler: async (args, ctx) => {
+ if (!args.trim()) {
+ ctx.ui.notify("Usage: /scout <query>", "error");
+ return;
+ }
+
+ // Send a message that will cause the AI to use the subagent tool
+ ctx.ui.notify("Dispatching scout agent...", "info");
+ pi.sendUserMessage(`Use the subagent tool to run the scout agent with this task: ${args}`);
+ },
+ });
+
+ // /implement - Full workflow
+ pi.registerCommand("implement", {
+ description: "Full implementation workflow: scout → planner → worker",
+ handler: async (args, ctx) => {
+ if (!args.trim()) {
+ ctx.ui.notify("Usage: /implement <query>", "error");
+ return;
+ }
+
+ ctx.ui.notify("Starting implementation workflow...", "info");
+ pi.sendUserMessage(
+ `Use the subagent tool with chain mode to implement: ${args}\n\n` +
+ `Chain:\n` +
+ `1. scout agent: find all code relevant to: ${args}\n` +
+ `2. planner agent: create implementation plan using {previous}\n` +
+ `3. worker agent: implement the plan from {previous}`
+ );
+ },
+ });
+
+ // /scout-and-plan - Planning workflow
+ pi.registerCommand("scout-and-plan", {
+ description: "Planning workflow: scout → planner (no implementation)",
+ handler: async (args, ctx) => {
+ if (!args.trim()) {
+ ctx.ui.notify("Usage: /scout-and-plan <query>", "error");
+ return;
+ }
+
+ ctx.ui.notify("Starting planning workflow...", "info");
+ pi.sendUserMessage(
+ `Use the subagent tool with chain mode for planning: ${args}\n\n` +
+ `Chain:\n` +
+ `1. scout agent: find all code relevant to: ${args}\n` +
+ `2. planner agent: create implementation plan using {previous}`
+ );
+ },
+ });
+
+ // /review-code - Review workflow
+ pi.registerCommand("review-code", {
+ description: "Code review workflow: scout → reviewer",
+ handler: async (args, ctx) => {
+ if (!args.trim()) {
+ ctx.ui.notify("Usage: /review-code <query>", "error");
+ return;
+ }
+
+ ctx.ui.notify("Starting code review...", "info");
+ pi.sendUserMessage(
+ `Use the subagent tool with chain mode to review: ${args}\n\n` +
+ `Chain:\n` +
+ `1. scout agent: find all code relevant to: ${args}\n` +
+ `2. reviewer agent: review the code from {previous}`
+ );
+ },
+ });
+
+ // /subagent-help - Show available agents
+ pi.registerCommand("subagent-help", {
+ description: "Show available subagents and usage",
+ handler: async (_args, ctx) => {
+ const help = `
+# Subagent Extension Help
+
+## Available Slash Commands
+
+- \`/scout <query>\` - Quick reconnaissance (uses Haiku, fast & cheap)
+- \`/implement <query>\` - Full workflow: scout → planner → worker
+- \`/scout-and-plan <query>\` - Planning only: scout → planner
+- \`/review-code <query>\` - Code review: scout → reviewer
+
+## Available Agents
+
+- **scout** (Haiku) - Fast recon, returns compressed context
+- **planner** (Sonnet) - Creates implementation plans
+- **reviewer** (Sonnet) - Code review
+- **worker** (Sonnet) - General purpose, full capabilities
+
+## Direct Tool Usage
+
+You can also ask the AI to use the subagent tool directly:
+
+**Single agent:**
+> Use scout to find all authentication code
+
+**Parallel:**
+> Run scouts in parallel: find DB schemas, find API endpoints
+
+**Chain:**
+> Chain: scout finds auth code, then planner suggests improvements
+
+## Examples
+
+\`\`\`
+/scout find all Tekton Task definitions
+/implement add Redis caching to session store
+/scout-and-plan refactor authentication module
+/review-code check security in auth handlers
+\`\`\`
+
+## Agent Details
+
+Location: ~/.pi/agent/agents/*.md
+`;
+ ctx.ui.notify("Subagent help displayed", "info");
+ console.log(help);
+ },
+ });
+}