pi-subagents 0.19.1 → 0.19.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagents",
3
- "version": "0.19.1",
3
+ "version": "0.19.3",
4
4
  "description": "Pi extension for delegating tasks to subagents with chains, parallel execution, and TUI clarification",
5
5
  "author": "Nico Bailon",
6
6
  "license": "MIT",
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: Use subagents to gather context, then ask clarifying questions
3
+ ---
4
+
5
+ Based on our discussion and my intent, launch focused context-gathering subagents before planning or implementing.
6
+
7
+ Use `scout` to inspect the relevant local files, existing patterns, constraints, tests, and likely integration points. Use `researcher` when external docs, recent sources, ecosystem context, or primary evidence would improve the answer.
8
+
9
+ Give each subagent a specific meta prompt. Ask them to return concise findings plus the remaining clarification questions that matter for implementation confidence.
10
+
11
+ After they return, synthesize what we know and use the `interview` tool to ask me the unresolved questions needed to reach a shared understanding.
12
+
13
+ $@
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Send an explicitly approved task to oracle-executor with full inherited context.
3
+ subagent: oracle-executor
4
+ inheritContext: true
5
+ ---
6
+
7
+ Launch the oracle-executor subagent with a strict implementation meta prompt that points it at the plan and asks it to execute:
8
+
9
+ $@
@@ -0,0 +1,50 @@
1
+ ---
2
+ description: Parallel subagents research
3
+ ---
4
+
5
+ Launch parallel research subagents to build a grounded answer to the current question or decision.
6
+
7
+ Use fresh context, not forked context, unless I explicitly ask for forked context. Researchers and scouts should inspect sources directly instead of relying on the main conversation history.
8
+
9
+ Use a combination of `researcher` and `scout` subagents:
10
+ - Use `researcher` for web, docs, standards, ecosystem, recent changes, benchmarks, and primary-source evidence.
11
+ - Use `scout` for local codebase context, existing implementation patterns, repo constraints, and files that would be affected.
12
+
13
+ Give each subagent a distinct angle. Unless I specify angles, use these three:
14
+
15
+ 1. External evidence
16
+ Use `researcher` to find current, authoritative sources: official docs, specs, release notes, benchmarks, issue threads, or primary explanations.
17
+
18
+ 2. Local code context
19
+ Use `scout` to inspect the repository for relevant files, existing patterns, constraints, tests, and likely integration points.
20
+
21
+ 3. Practical tradeoffs
22
+ Use `researcher` or `scout`, whichever fits the question, to compare options, risks, edge cases, maintenance cost, and what would be easiest to validate.
23
+
24
+ Adapt the angles when the question calls for it:
25
+ - Library/API questions: include official docs and recent examples.
26
+ - Architecture decisions: include local module boundaries, dependency direction, and migration cost.
27
+ - Debugging questions: include likely failure modes, local call paths, and exact error evidence.
28
+ - UI/product questions: include user flow, accessibility, design precedent, and implementation constraints.
29
+ - Time-sensitive topics: include a recent-developments angle and prefer 2026/2025 sources.
30
+
31
+ Prefer two or three strong subagents over many vague ones. The parent agent should frame the question and assign angles; the child agents should research or scout, not invent broad plans.
32
+
33
+ Ask each subagent to return concise findings with evidence:
34
+ - file paths and line ranges for local findings
35
+ - source links for external findings
36
+ - confidence level and gaps
37
+ - recommended next step or decision implication
38
+
39
+ Do not ask subagents to edit files. This is a research pass only unless I explicitly ask for implementation.
40
+
41
+ After the subagents return, synthesize the answer into:
42
+ - what we know
43
+ - what the local codebase implies
44
+ - tradeoffs and risks
45
+ - gaps or assumptions
46
+ - the recommended next move
47
+
48
+ If findings disagree, call out the disagreement instead of smoothing it over.
49
+
50
+ $@
@@ -1,8 +1,40 @@
1
1
  ---
2
2
  description: Parallel subagents review
3
3
  ---
4
- Great. Now let's launch parallel reviewers to conduct an adversarial review.
5
4
 
6
- Important: launch reviewers with fresh context, not forked context. Reviewers should inspect the repository and current diff directly from files and commands, without inheriting the main agent chat. Use forked context only if I explicitly ask for it.
5
+ Launch parallel reviewers for an adversarial review of the current work.
6
+
7
+ Use fresh context, not forked context, unless I explicitly ask for forked context. Reviewers should inspect the repository, relevant instructions, and current diff directly from files and commands. Do not rely on the main conversation history.
8
+
9
+ Give each reviewer a distinct angle. Generate the angles dynamically from the user's intent, the plan, the implemented code, and the current diff. If I specify angles, use mine. Otherwise, choose the highest-value review angles for this specific work.
10
+
11
+ These are examples, not fixed defaults:
12
+
13
+ 1. Correctness and regressions
14
+ Check whether the change satisfies the request, preserves existing behavior, handles edge cases, and avoids hidden runtime failures.
15
+
16
+ 2. Tests and validation
17
+ Check whether tests or validation were added at the right layer, whether assertions are meaningful, and whether the chosen verification commands are enough.
18
+
19
+ 3. Simplicity and maintainability
20
+ Check for unnecessary complexity, duplicate structure, single-use wrappers, brittle abstractions, confusing names, verbosity, and cleanup that is clearly worth doing.
21
+
22
+ Choose or adapt angles when the work calls for it:
23
+ - TypeScript-heavy changes: include type safety, source-of-truth types, casts, and error-boundary discipline.
24
+ - UI-heavy changes: include UX, accessibility, copy, and visual quality.
25
+ - Security-sensitive changes: include unsafe input/output handling, auth boundaries, privacy, and data exposure.
26
+ - Docs-heavy changes: include clarity, accuracy, completeness, reader flow, and non-robotic prose.
27
+ - Large multi-file changes: consider a fourth reviewer for structural friction, module boundaries, and testability.
28
+
29
+ Prefer three strong reviewers over many vague reviewers.
30
+
31
+ Give every reviewer a specific task prompt naming its angle. Ask reviewers to return concise, evidence-backed findings with file/line references and suggested fixes. The response should be review feedback, not a context summary. Reviewers must not edit files unless I explicitly ask for a writer pass.
32
+
33
+ While reviewers run, do your own narrow inspection if useful. After they return, synthesize the feedback into:
34
+ - fixes worth doing now
35
+ - optional improvements
36
+ - feedback to ignore or defer, with a short reason
37
+
38
+ Do not blindly apply every reviewer suggestion. Ask before applying fixes unless I already told you to address review feedback.
7
39
 
8
40
  $@
@@ -15,8 +15,8 @@ agents into a workflow, or create/edit agents and chains on demand.
15
15
 
16
16
  ## When to Use
17
17
 
18
- - **Advisory review**: fork to `oracle` or `reviewer` for a branched review thread
19
- - **Implementation handoff**: have `oracle` advise, then `oracle-executor` or `worker` implement
18
+ - **Advisory review**: use fresh-context `reviewer` agents for adversarial code review, or fork to `oracle` when inherited decisions and drift matter
19
+ - **Implementation handoff**: have `oracle` advise, then `oracle-executor` or `worker` implement only after an approved direction
20
20
  - **Recon and planning**: use `scout` or `context-builder`, then `planner`
21
21
  - **Parallel exploration**: run multiple non-conflicting tasks concurrently
22
22
  - **Long-running work**: launch async/background runs and inspect them later
@@ -32,11 +32,19 @@ Humans often use the slash-command layer instead:
32
32
  - `/chain` — launch a chain of steps
33
33
  - `/parallel` — launch top-level parallel tasks
34
34
  - `/agents` — open the agents manager TUI
35
+ - `/run-chain` — launch a saved `.chain.md` workflow
35
36
  - `/subagents-status` — inspect active/recent async runs
37
+ - `/subagents-doctor` — diagnose setup, discovery, async paths, and intercom bridge state
36
38
 
37
39
  Prefer the tool when you are writing agent logic. Prefer the slash commands when
38
40
  you are guiding a human through an interactive flow.
39
41
 
42
+ Packaged prompt shortcuts are also available for repeatable workflows:
43
+ - `/parallel-review` — fresh-context reviewers with distinct review angles, then synthesis
44
+ - `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
45
+ - `/gather-context-and-clarify` — scout/research first, then ask the user clarifying questions with `interview`
46
+ - `/oracle-executor` — send an explicitly approved implementation task to `oracle-executor`
47
+
40
48
  ## Builtin Agents
41
49
 
42
50
  Builtin agents load at the lowest priority. Project agents override user agents,
@@ -54,16 +62,40 @@ and user/project agents override builtins with the same name.
54
62
  | `oracle` | Decision-consistency advisory review | `openai-codex/gpt-5.5` | Advisory review, intercom coordination |
55
63
  | `oracle-executor` | Implementation after approval | `openai-codex/gpt-5.5` | Single-writer implementation after approval |
56
64
 
57
- Override builtin defaults via settings before copying full agent files when a
58
- small tweak is enough.
65
+ Override builtin defaults before copying full agent files when a small tweak is enough.
66
+
67
+ For one run, use inline config:
68
+
69
+ ```text
70
+ /run reviewer[model=anthropic/claude-sonnet-4] "Review this diff"
71
+ ```
72
+
73
+ For persistent tweaks, prefer `/agents`: choose the builtin, press `e`, change the model or other fields, then save a user or project override. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides.
59
74
 
60
75
  Settings locations:
61
76
  - User scope: `~/.pi/agent/settings.json`
62
77
  - Project scope: `.pi/settings.json`
63
78
 
79
+ Direct settings example:
80
+
81
+ ```json
82
+ {
83
+ "subagents": {
84
+ "agentOverrides": {
85
+ "reviewer": {
86
+ "model": "anthropic/claude-sonnet-4",
87
+ "thinking": "high",
88
+ "fallbackModels": ["openai/gpt-5-mini"]
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
64
95
  Useful override fields: `model`, `fallbackModels`, `thinking`,
65
96
  `systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `disabled`,
66
- `skills`, `tools`, and `systemPrompt`.
97
+ `skills`, `tools`, and `systemPrompt`. Create a user or project agent with the
98
+ same name only when you want a substantially different agent.
67
99
 
68
100
  ## Discovery and Scope Rules
69
101
 
@@ -119,6 +151,21 @@ subagent({
119
151
  })
120
152
  ```
121
153
 
154
+ Top-level parallel tasks can override per-task behavior:
155
+
156
+ ```typescript
157
+ subagent({
158
+ tasks: [
159
+ { agent: "scout", task: "Map auth", output: "auth-context.md", progress: true },
160
+ { agent: "researcher", task: "Research OAuth best practices", output: "oauth-research.md" },
161
+ { agent: "reviewer", task: "Review auth tests", model: "anthropic/claude-sonnet-4" }
162
+ ],
163
+ concurrency: 3
164
+ })
165
+ ```
166
+
167
+ Avoid duplicate output paths in parallel tasks. Concurrent children should not write to the same file.
168
+
122
169
  ### Chain execution
123
170
 
124
171
  ```typescript
@@ -147,6 +194,14 @@ subagent({
147
194
 
148
195
  Inspect async runs with `subagent({ action: "status", id: "..." })`, `subagent({ action: "status" })` for active runs, or the `/subagents-status` slash command.
149
196
 
197
+ Use diagnostics when setup or child startup looks wrong:
198
+
199
+ ```typescript
200
+ subagent({ action: "doctor" })
201
+ ```
202
+
203
+ Humans can use `/subagents-doctor` for the same read-only report. It checks runtime paths, discovery counts, async support, current session context, and intercom bridge state.
204
+
150
205
  ### Subagent control
151
206
 
152
207
  Subagent control is the runtime visibility and intervention layer for delegated runs. It is separate from lifecycle status. Lifecycle status says whether a child is `queued`, `running`, `paused`, `complete`, or `failed`. Activity reporting is factual: it tracks the last observed activity time and the current tool when known. It does not pretend to know that a child is truly stuck.
@@ -198,6 +253,8 @@ subagent({
198
253
  Chains default to clarify mode unless you explicitly set `clarify: false`.
199
254
  For programmatic background launches, use `clarify: false, async: true`.
200
255
 
256
+ The `/agents` manager also has launch toggles for forked context, background execution, and worktree-isolated parallel runs. Use it when guiding a human who wants to inspect or edit the launch before starting.
257
+
201
258
  ## Worktree Isolation
202
259
 
203
260
  When multiple agents might write concurrently, use worktrees instead of letting
@@ -249,35 +306,44 @@ history as a baseline contract.
249
306
 
250
307
  ## Subagent + Intercom Coordination
251
308
 
252
- When `pi-intercom` is installed and enabled, delegated runs can coordinate with
253
- the orchestrator through the intercom bridge.
309
+ `pi-subagents` works without `pi-intercom`. When `pi-intercom` is installed and enabled, the intercom bridge can automatically give child agents a private coordination channel back to the parent session.
254
310
 
255
- ### Subagent asks the orchestrator
311
+ Most agents should not call `intercom` directly unless bridge instructions provide a target. Do not invent a target. Use the target from the injected bridge instructions or from a visible needs-attention notice.
312
+
313
+ Use `intercom` when:
314
+ - a subagent is blocked on a decision
315
+ - a child needs clarification instead of guessing
316
+ - a detached or async child needs to coordinate without waiting for normal tool return flow
317
+ - an advisory agent was explicitly asked to send a concise progress update
318
+
319
+ Message conventions:
320
+ - `ask` means the child needs a decision or clarification from the parent session.
321
+ - `send` means a short blocked/progress update, only when blocked or explicitly asked.
322
+ - Routine completion does not go through intercom. The normal subagent result still returns through `pi-subagents`.
323
+
324
+ If a bridge target is available, a child can ask:
256
325
 
257
326
  ```typescript
258
327
  intercom({
259
328
  action: "ask",
260
- to: "orchestrator",
329
+ to: "<bridge-provided-target>",
261
330
  message: "Should I optimize for readability or performance here?"
262
331
  })
263
332
  ```
264
333
 
265
- ### Orchestrator replies
334
+ The parent replies with:
266
335
 
267
336
  ```typescript
268
337
  intercom({ action: "reply", message: "Optimize for readability." })
269
338
  ```
270
339
 
271
- Or inspect unresolved asks first:
340
+ Or inspects unresolved asks first:
272
341
 
273
342
  ```typescript
274
343
  intercom({ action: "pending" })
275
344
  ```
276
345
 
277
- Use `intercom` when:
278
- - a subagent is blocked on a decision
279
- - an advisory agent wants to send a concise handoff mid-flight
280
- - a detached or async child needs to coordinate without waiting for normal tool return flow
346
+ If intercom messages do not show up, run `subagent({ action: "doctor" })` or `/subagents-doctor`.
281
347
 
282
348
  ## Management Mode
283
349
 
@@ -326,6 +392,8 @@ subagent({ action: "delete", agent: "my-agent" })
326
392
  Use management actions when the system needs to create or edit subagents on
327
393
  demand without dropping into raw file editing.
328
394
 
395
+ Management actions create or update user/project agent files. For small builtin changes such as a model swap, prefer `/agents` builtin overrides or `subagents.agentOverrides` in settings.
396
+
329
397
  ## Creating and Editing Agents by File
330
398
 
331
399
  A minimal agent file looks like this:
@@ -357,7 +425,12 @@ copying a full builtin file.
357
425
 
358
426
  ## Prompt Template Integration
359
427
 
360
- If `pi-prompt-template-model` is installed, prompt templates can delegate into
428
+ The package includes prompt shortcuts for common workflows: `/parallel-review`,
429
+ `/parallel-research`, `/gather-context-and-clarify`, and `/oracle-executor`.
430
+ Use them when the user wants repeatable review, research, clarification, or
431
+ approved execution patterns.
432
+
433
+ If `pi-prompt-template-model` is installed, additional user prompt templates can delegate into
361
434
  `pi-subagents`. This is useful when a slash command should always run through a
362
435
  particular agent or with forked context.
363
436
 
@@ -366,7 +439,7 @@ particular agent or with forked context.
366
439
  - **Forking requires a persisted parent session.** If the current session does not
367
440
  have a persisted session file, forked runs fail.
368
441
  - **Forked runs inherit parent history.** They are branched threads, not fresh
369
- filtered contexts.
442
+ filtered contexts. Use fresh context for adversarial reviewers unless the user explicitly asks for forked context.
370
443
  - **Default subagent nesting depth is 2.** Deeper recursive delegation is blocked
371
444
  unless configured otherwise.
372
445
  - **Attention signals are not lifecycle state.** `needs_attention` means no activity has been observed past the configured threshold. `paused` means the child turn was intentionally interrupted or is awaiting direction; it is not the same as `failed`.
@@ -386,7 +459,10 @@ for the actual write path.
386
459
  ### Use fork for branched advisory or execution threads
387
460
 
388
461
  Forked runs are useful when the child should reason in a separate thread while
389
- still inheriting the parent’s accumulated context.
462
+ still inheriting the parent’s accumulated context. They are especially useful for
463
+ `oracle`, which audits inherited decisions and drift. For adversarial code review,
464
+ prefer fresh-context reviewers that inspect the repo and diff directly unless the
465
+ user explicitly requests forked context.
390
466
 
391
467
  ### Prefer narrow tasks
392
468
 
@@ -426,8 +502,7 @@ subagent({
426
502
  subagent({ agent: "worker", task: "Add retry logic to the API client." })
427
503
  subagent({
428
504
  agent: "reviewer",
429
- task: "Review the retry logic implementation. Look for edge cases and race conditions.",
430
- context: "fork"
505
+ task: "Review the retry logic implementation. Inspect the repo and current diff directly. Look for edge cases and race conditions."
431
506
  })
432
507
  ```
433
508
 
@@ -442,6 +517,14 @@ subagent({
442
517
  })
443
518
  ```
444
519
 
520
+ ### Saved chain
521
+
522
+ ```text
523
+ /run-chain review-chain -- review this branch
524
+ ```
525
+
526
+ Use saved `.chain.md` workflows when the user wants a repeatable multi-agent flow without rewriting the chain each time.
527
+
445
528
  ## Error Handling
446
529
 
447
530
  **"Unknown agent"**
@@ -450,6 +533,12 @@ subagent({ action: "list" })
450
533
  // Check available agents and chains, then confirm scope/precedence.
451
534
  ```
452
535
 
536
+ **Setup, discovery, or intercom confusion**
537
+ ```typescript
538
+ subagent({ action: "doctor" })
539
+ // Check runtime paths, async support, discovery counts, current session, and intercom bridge state.
540
+ ```
541
+
453
542
  **"Max subagent depth exceeded"**
454
543
  ```typescript
455
544
  // Flatten the workflow or raise maxSubagentDepth in config.
@@ -464,3 +553,18 @@ subagent({ action: "list" })
464
553
  ```typescript
465
554
  // Resolve the current outbound ask before starting another one.
466
555
  ```
556
+
557
+ **Parallel output-path conflict**
558
+ ```typescript
559
+ // Give each parallel task a distinct output path, or disable output for tasks that do not need it.
560
+ ```
561
+
562
+ **Worktree launch fails**
563
+ ```typescript
564
+ // Ensure the git working tree is clean and task cwd overrides match the shared cwd.
565
+ ```
566
+
567
+ **Child fails before starting**
568
+ ```typescript
569
+ // Inspect /subagents-status detail, artifact metadata/output logs, and run doctor. Extension loader errors usually appear in child output logs.
570
+ ```