@bacnh85/pi-subagent 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: general-purpose
3
+ description: General-purpose sub-agent for any delegated task. Use when no specialized agent fits. Good for complex research, multi-step operations, and code modifications.
4
+ tools: read, bash, edit, write, grep, find, ls
5
+ ---
6
+
7
+ You are a capable coding assistant running as a sub-agent. Complete the delegated task efficiently and return a concise summary of your findings or changes.
8
+
9
+ Guidelines:
10
+ - Use available tools to investigate and act on the task.
11
+ - If the task involves searching, use grep and find to locate relevant code.
12
+ - If the task involves implementation, make focused changes following existing patterns.
13
+ - Return a structured summary: what you found, what you changed, and any recommendations.
package/index.ts CHANGED
@@ -164,6 +164,31 @@ export default function (pi: ExtensionAPI) {
164
164
  if (event.reason === "reload") invalidateAgentCache();
165
165
  });
166
166
 
167
+ // Proactively steer agents toward sub-agent delegation when users mention it
168
+ pi.on("before_agent_start", async (event) => {
169
+ const prompt = event.prompt.toLowerCase();
170
+ if (/\b(delegate to|use a subagent|run in parallel|spawn an agent|scout|review this|chain|worker agent)\b/.test(prompt)) {
171
+ return {
172
+ systemPrompt:
173
+ event.systemPrompt +
174
+ "\n\nThe subagent tool is available for delegating tasks to specialized agents with isolated context. Use /subagent to list available agents. Bundled: scout (fast recon), reviewer (code review), worker (implementation), general-purpose (fallback). Modes: single, parallel (max 8), chain.",
175
+ };
176
+ }
177
+ });
178
+
179
+ // Inject available agent list into system prompt on every session
180
+ pi.on("before_agent_start", async (event, ctx) => {
181
+ const discovery = discoverAgents(ctx.cwd, "both", bundledAgentsDir);
182
+ if (discovery.agents.length > 0) {
183
+ const names = discovery.agents.map(a => a.name).join(", ");
184
+ return {
185
+ systemPrompt:
186
+ event.systemPrompt +
187
+ `\n\nAvailable sub-agents: ${names}. Use /subagent for details.`,
188
+ };
189
+ }
190
+ });
191
+
167
192
  // Resolve bundled agents directory relative to this extension file
168
193
  const bundledAgentsDir = path.resolve(__dirname, "agents");
169
194
 
@@ -250,7 +275,13 @@ export default function (pi: ExtensionAPI) {
250
275
  `To enable project-local agents in ${CONFIG_DIR_NAME}/agents, set agentScope: "both" or "project".`,
251
276
  ].join(" "),
252
277
  parameters: SubagentParams,
253
-
278
+ promptSnippet: "Delegate tasks to specialized sub-agents (scout, reviewer, worker, general-purpose)",
279
+ promptGuidelines: [
280
+ "Use subagent to delegate work that would flood the main context with search results or file contents.",
281
+ "Modes: single {agent, task}, parallel {tasks: [...]} (max 8, 4 concurrent), chain {chain: [...]} (sequential with {previous}).",
282
+ "Bundled agents: scout (fast recon), reviewer (code review), worker (implementation), general-purpose (fallback).",
283
+ "Use /subagent to list all available agents or /subagent <name> for agent details.",
284
+ ],
254
285
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
255
286
  const agentScope: AgentScope = params.agentScope ?? "user";
256
287
  const discovery = discoverAgents(ctx.cwd, agentScope, bundledAgentsDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacnh85/pi-subagent",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Minimal-overhead sub-agent extension for pi. Delegate tasks to specialized agents with isolated context using the pi SDK in-process.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/runner.ts CHANGED
@@ -66,6 +66,7 @@ export async function runSubAgent(options: {
66
66
  modelRegistry: ModelRegistry;
67
67
  signal?: AbortSignal;
68
68
  agentName?: string;
69
+ onUpdate?: (text: string) => void;
69
70
  }): Promise<SubAgentResult> {
70
71
  const {
71
72
  cwd,
@@ -77,6 +78,7 @@ export async function runSubAgent(options: {
77
78
  modelRegistry,
78
79
  signal,
79
80
  agentName = "subagent",
81
+ onUpdate,
80
82
  } = options;
81
83
 
82
84
  const result: SubAgentResult = {
@@ -121,9 +123,9 @@ export async function runSubAgent(options: {
121
123
  settingsManager,
122
124
  });
123
125
 
126
+ let cleanupAbort: (() => void) | undefined;
124
127
  try {
125
128
  // Wire abort signal
126
- let cleanupAbort: (() => void) | undefined;
127
129
  if (signal) {
128
130
  const onAbort = () => session.abort();
129
131
  if (signal.aborted) {