pi-subagents 0.21.1 → 0.21.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/CHANGELOG.md +24 -0
- package/README.md +35 -16
- package/agents/context-builder.md +6 -3
- package/package.json +3 -4
- package/prompts/parallel-context-build.md +53 -0
- package/prompts/parallel-handoff-plan.md +59 -0
- package/prompts/parallel-review.md +4 -0
- package/skills/pi-subagents/SKILL.md +84 -4
- package/{agent-management.ts → src/agents/agent-management.ts} +1 -1
- package/{agents.ts → src/agents/agents.ts} +1 -1
- package/src/extension/control-notices.ts +92 -0
- package/{doctor.ts → src/extension/doctor.ts} +5 -5
- package/{index.ts → src/extension/index.ts} +34 -52
- package/{schemas.ts → src/extension/schemas.ts} +25 -39
- package/{intercom-bridge.ts → src/intercom/intercom-bridge.ts} +2 -2
- package/{result-intercom.ts → src/intercom/result-intercom.ts} +33 -5
- package/{agent-manager-chain-detail.ts → src/manager-ui/agent-manager-chain-detail.ts} +3 -3
- package/{agent-manager-detail.ts → src/manager-ui/agent-manager-detail.ts} +7 -7
- package/{agent-manager-edit.ts → src/manager-ui/agent-manager-edit.ts} +4 -4
- package/{agent-manager-list.ts → src/manager-ui/agent-manager-list.ts} +2 -2
- package/{agent-manager-parallel.ts → src/manager-ui/agent-manager-parallel.ts} +3 -3
- package/{agent-manager.ts → src/manager-ui/agent-manager.ts} +9 -9
- package/{async-execution.ts → src/runs/background/async-execution.ts} +11 -11
- package/{async-job-tracker.ts → src/runs/background/async-job-tracker.ts} +29 -6
- package/src/runs/background/async-resume.ts +305 -0
- package/{async-status.ts → src/runs/background/async-status.ts} +14 -12
- package/{notify.ts → src/runs/background/notify.ts} +1 -1
- package/{result-watcher.ts → src/runs/background/result-watcher.ts} +3 -3
- package/{run-status.ts → src/runs/background/run-status.ts} +63 -28
- package/src/runs/background/stale-run-reconciler.ts +275 -0
- package/{subagent-runner.ts → src/runs/background/subagent-runner.ts} +38 -58
- package/{chain-clarify.ts → src/runs/foreground/chain-clarify.ts} +7 -7
- package/{chain-execution.ts → src/runs/foreground/chain-execution.ts} +10 -10
- package/{execution.ts → src/runs/foreground/execution.ts} +24 -28
- package/{subagent-executor.ts → src/runs/foreground/subagent-executor.ts} +157 -24
- package/{long-running-guard.ts → src/runs/shared/long-running-guard.ts} +3 -3
- package/{model-fallback.ts → src/runs/shared/model-fallback.ts} +1 -1
- package/{subagent-control.ts → src/runs/shared/subagent-control.ts} +4 -8
- package/src/shared/atomic-json.ts +16 -0
- package/{settings.ts → src/shared/settings.ts} +21 -14
- package/{types.ts → src/shared/types.ts} +6 -2
- package/{utils.ts → src/shared/utils.ts} +1 -15
- package/{slash-bridge.ts → src/slash/slash-bridge.ts} +2 -2
- package/{slash-commands.ts → src/slash/slash-commands.ts} +7 -7
- package/{slash-live-state.ts → src/slash/slash-live-state.ts} +2 -2
- package/{render.ts → src/tui/render.ts} +3 -3
- package/{subagents-status.ts → src/tui/subagents-status.ts} +34 -14
- /package/{agent-scope.ts → src/agents/agent-scope.ts} +0 -0
- /package/{agent-selection.ts → src/agents/agent-selection.ts} +0 -0
- /package/{agent-serializer.ts → src/agents/agent-serializer.ts} +0 -0
- /package/{agent-templates.ts → src/agents/agent-templates.ts} +0 -0
- /package/{chain-serializer.ts → src/agents/chain-serializer.ts} +0 -0
- /package/{frontmatter.ts → src/agents/frontmatter.ts} +0 -0
- /package/{skills.ts → src/agents/skills.ts} +0 -0
- /package/{completion-dedupe.ts → src/runs/background/completion-dedupe.ts} +0 -0
- /package/{top-level-async.ts → src/runs/background/top-level-async.ts} +0 -0
- /package/{completion-guard.ts → src/runs/shared/completion-guard.ts} +0 -0
- /package/{parallel-utils.ts → src/runs/shared/parallel-utils.ts} +0 -0
- /package/{pi-args.ts → src/runs/shared/pi-args.ts} +0 -0
- /package/{pi-spawn.ts → src/runs/shared/pi-spawn.ts} +0 -0
- /package/{run-history.ts → src/runs/shared/run-history.ts} +0 -0
- /package/{single-output.ts → src/runs/shared/single-output.ts} +0 -0
- /package/{subagent-prompt-runtime.ts → src/runs/shared/subagent-prompt-runtime.ts} +0 -0
- /package/{worktree.ts → src/runs/shared/worktree.ts} +0 -0
- /package/{artifacts.ts → src/shared/artifacts.ts} +0 -0
- /package/{file-coalescer.ts → src/shared/file-coalescer.ts} +0 -0
- /package/{fork-context.ts → src/shared/fork-context.ts} +0 -0
- /package/{formatters.ts → src/shared/formatters.ts} +0 -0
- /package/{jsonl-writer.ts → src/shared/jsonl-writer.ts} +0 -0
- /package/{post-exit-stdio-guard.ts → src/shared/post-exit-stdio-guard.ts} +0 -0
- /package/{session-tokens.ts → src/shared/session-tokens.ts} +0 -0
- /package/{prompt-template-bridge.ts → src/slash/prompt-template-bridge.ts} +0 -0
- /package/{render-helpers.ts → src/tui/render-helpers.ts} +0 -0
- /package/{text-editor.ts → src/tui/text-editor.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.21.3] - 2026-04-30
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Debounce foreground `needs_attention` notices, make them non-triggering, and cancel them when the run finishes so stale chain-step alerts do not launch parent turns after completion.
|
|
9
|
+
|
|
10
|
+
## [0.21.2] - 2026-04-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Added a packaged `/parallel-context-build` prompt for parallel `context-builder` handoff passes.
|
|
14
|
+
- Added a packaged `/parallel-handoff-plan` prompt for external-reference research plus local `context-builder` passes that produce an implementation handoff meta-prompt.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Strengthened `context-builder` guidance so handoffs require reading all relevant files and doing needed tool-available research before summarizing.
|
|
18
|
+
- Expanded the bundled `pi-subagents` skill with tool-level recipes for the packaged prompt workflows, including context-build and handoff-plan patterns that parent agents can apply without slash commands.
|
|
19
|
+
- Updated `README.md` to explain the bundled `pi-subagents` skill, what it covers, and how it helps the orchestrating agent.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- Make active-long-running notices time-based by default, with turn and token thresholds available only as explicit opt-in budget guards.
|
|
23
|
+
- Stop async status listing from inventing `needs_attention` with default thresholds when the runner has not persisted a control state.
|
|
24
|
+
- Treat string `"false"` output settings as disabled output so parallel reviewers do not collide on a `/false` output path, including chain-parallel agent defaults.
|
|
25
|
+
- Wrap long `/subagents-status` detail output/event lines instead of truncating them with ellipses.
|
|
26
|
+
- Treat cleanup after a clean terminal assistant stop as success even when the final assistant text is empty, using a short grace period before terminating lingering child processes without surfacing scary final-drain warnings.
|
|
27
|
+
- Express flexible tool schema fields as `anyOf` unions without parent-level `type` arrays, avoiding schema shapes rejected by strict providers such as Moonshot/opencode-go.
|
|
28
|
+
|
|
5
29
|
## [0.21.1] - 2026-04-30
|
|
6
30
|
|
|
7
31
|
### Changed
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
<img src="banner.png" alt="pi-subagents" width="1100">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/nicobailon/pi-subagents/main/banner.png" alt="pi-subagents" width="1100">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# pi-subagents
|
|
@@ -196,6 +196,8 @@ The package includes reusable prompt templates for common workflows. You do not
|
|
|
196
196
|
|--------|------------|
|
|
197
197
|
| `/parallel-review` | Launch fresh-context reviewers with distinct angles, then synthesize what to fix. |
|
|
198
198
|
| `/parallel-research` | Combine `researcher` and `scout` for external evidence, local code context, and practical tradeoffs. |
|
|
199
|
+
| `/parallel-context-build` | Run `context-builder` agents in parallel to produce planning handoff context and meta-prompts. |
|
|
200
|
+
| `/parallel-handoff-plan` | Combine external research and `context-builder` passes into an implementation handoff plan and meta-prompt. |
|
|
199
201
|
| `/gather-context-and-clarify` | Scout/research first, then ask the user the clarification questions that matter. |
|
|
200
202
|
| `/parallel-cleanup` | Run review-only cleanup passes after implementation. |
|
|
201
203
|
|
|
@@ -618,6 +620,20 @@ Injected skills use this shape:
|
|
|
618
620
|
|
|
619
621
|
Missing skills do not fail execution. The result summary shows a warning.
|
|
620
622
|
|
|
623
|
+
### Bundled skill
|
|
624
|
+
|
|
625
|
+
The package bundles a `pi-subagents` skill that is automatically available to the parent agent when the extension is installed. It is for the orchestrating parent only: child subagents never receive it, and their context is explicitly filtered to strip parent-only orchestration instructions.
|
|
626
|
+
|
|
627
|
+
What the bundled skill covers:
|
|
628
|
+
- **Delegation patterns**: when to launch which agent, whether to use single, parallel, chain, or async mode, and whether to use fresh or forked context
|
|
629
|
+
- **Prompt workflow recipes**: how to apply the packaged techniques directly with `subagent(...)` when the user describes the workflow in natural language instead of invoking a slash command. This includes parallel review, parallel research, parallel context-build, parallel handoff-plan, gather-context-and-clarify, and parallel cleanup
|
|
630
|
+
- **GPT-5.5 prompting guidance**: compact contract prompts instead of long scripts, what to include in role-specific meta prompts, and retrieval budgets for researchers
|
|
631
|
+
- **Safety boundaries**: child agents must not run subagents, must not invent intercom targets, and must escalate unapproved decisions
|
|
632
|
+
- **Intercom conventions**: when to ask vs send, and how parent-side result delivery works with `pi-intercom`
|
|
633
|
+
- **Control and diagnostics**: attention signals, soft interrupts, status, and the `doctor` action
|
|
634
|
+
|
|
635
|
+
If you are writing an agent that orchestrates subagents, the bundled skill helps it behave correctly without guessing the patterns. If you are a human user, you do not need to read it directly; the README and prompt shortcuts encode the same workflows in user-facing form.
|
|
636
|
+
|
|
621
637
|
## Programmatic tool usage
|
|
622
638
|
|
|
623
639
|
These are the parameters the LLM passes when it calls the `subagent` tool. Most users ask naturally or use slash commands instead.
|
|
@@ -719,7 +735,7 @@ Agent definitions are not loaded into context by default. Management actions let
|
|
|
719
735
|
|-------|------|---------|-------------|
|
|
720
736
|
| `agent` | string | - | Agent name for single mode, or target for management actions. |
|
|
721
737
|
| `task` | string | - | Task string for single mode. |
|
|
722
|
-
| `action` | string | - | `list`, `get`, `create`, `update`, `delete`, `status`, `interrupt`, or `doctor`. |
|
|
738
|
+
| `action` | string | - | `list`, `get`, `create`, `update`, `delete`, `status`, `interrupt`, `resume`, or `doctor`. |
|
|
723
739
|
| `chainName` | string | - | Chain name for management actions. |
|
|
724
740
|
| `config` | object/string | - | Agent or chain config for create/update. |
|
|
725
741
|
| `output` | `string \| false` | agent default | Override single-agent output file. |
|
|
@@ -751,9 +767,12 @@ Status and control actions:
|
|
|
751
767
|
subagent({ action: "status" })
|
|
752
768
|
subagent({ action: "status", id: "<run-id>" })
|
|
753
769
|
subagent({ action: "interrupt", id: "<run-id>" })
|
|
770
|
+
subagent({ action: "resume", id: "<async-run-id>", message: "follow-up question" })
|
|
754
771
|
subagent({ action: "doctor" })
|
|
755
772
|
```
|
|
756
773
|
|
|
774
|
+
`resume` sends the follow-up directly when the async child is still reachable over intercom. After completion, it starts a new async child from the stored single-child session file.
|
|
775
|
+
|
|
757
776
|
## Worktree isolation
|
|
758
777
|
|
|
759
778
|
Parallel agents can clobber each other if they edit the same checkout. `worktree: true` gives each parallel child its own git worktree branched from `HEAD`.
|
|
@@ -971,7 +990,7 @@ Intercom delivery events:
|
|
|
971
990
|
- `subagent:control-intercom`
|
|
972
991
|
- `subagent:result-intercom`
|
|
973
992
|
|
|
974
|
-
The result watcher emits `subagent:async-complete`; `index.ts` registers the notification handler that consumes it. Control/attention events are surfaced as visible parent notices and persisted for async runs. With `pi-intercom`, needs-attention notices and grouped parent-side subagent result deliveries can reach the orchestrator over intercom.
|
|
993
|
+
The result watcher emits `subagent:async-complete`; `src/extension/index.ts` registers the notification handler that consumes it. Control/attention events are surfaced as visible parent notices and persisted for async runs. With `pi-intercom`, needs-attention notices and grouped parent-side subagent result deliveries can reach the orchestrator over intercom.
|
|
975
994
|
|
|
976
995
|
## Prompt-template integration
|
|
977
996
|
|
|
@@ -999,17 +1018,17 @@ The main runtime files are:
|
|
|
999
1018
|
|
|
1000
1019
|
| File | Purpose |
|
|
1001
1020
|
|------|---------|
|
|
1002
|
-
| `index.ts` | Extension registration, tool registration, message/render wiring. |
|
|
1003
|
-
| `agents.ts` | Agent and chain discovery, frontmatter parsing. |
|
|
1004
|
-
| `subagent-executor.ts` | Main execution routing for single, parallel, chain, management, status, interrupt, and doctor actions. |
|
|
1005
|
-
| `execution.ts` | Core foreground `runSync` handling. |
|
|
1006
|
-
| `subagent-runner.ts` | Detached async runner. |
|
|
1007
|
-
| `async-execution.ts` | Background launch support. |
|
|
1008
|
-
| `async-status.ts` / `subagents-status.ts` | Status discovery and overlay UI. |
|
|
1009
|
-
| `chain-execution.ts` / `chain-serializer.ts` | Chain orchestration and `.chain.md` parsing. |
|
|
1010
|
-
| `agent-manager*.ts` | Agents Manager screens and editing flows. |
|
|
1011
|
-
| `settings.ts` | Chain behavior, instructions, and config helpers. |
|
|
1012
|
-
| `worktree.ts` | Git worktree isolation. |
|
|
1013
|
-
| `intercom-bridge.ts` | Runtime intercom bridge instructions and diagnostics. |
|
|
1014
|
-
| `schemas.ts` / `types.ts` | Tool schemas, shared types, and event constants. |
|
|
1021
|
+
| `src/extension/index.ts` | Extension registration, tool registration, message/render wiring. |
|
|
1022
|
+
| `src/agents/agents.ts` | Agent and chain discovery, frontmatter parsing. |
|
|
1023
|
+
| `src/runs/foreground/subagent-executor.ts` | Main execution routing for single, parallel, chain, management, status, interrupt, and doctor actions. |
|
|
1024
|
+
| `src/runs/foreground/execution.ts` | Core foreground `runSync` handling. |
|
|
1025
|
+
| `src/runs/background/subagent-runner.ts` | Detached async runner. |
|
|
1026
|
+
| `src/runs/background/async-execution.ts` | Background launch support. |
|
|
1027
|
+
| `src/runs/background/async-status.ts` / `src/tui/subagents-status.ts` | Status discovery and overlay UI. |
|
|
1028
|
+
| `src/runs/foreground/chain-execution.ts` / `src/agents/chain-serializer.ts` | Chain orchestration and `.chain.md` parsing. |
|
|
1029
|
+
| `src/manager-ui/agent-manager*.ts` | Agents Manager screens and editing flows. |
|
|
1030
|
+
| `src/shared/settings.ts` | Chain behavior, instructions, and config helpers. |
|
|
1031
|
+
| `src/runs/shared/worktree.ts` | Git worktree isolation. |
|
|
1032
|
+
| `src/intercom/intercom-bridge.ts` | Runtime intercom bridge instructions and diagnostics. |
|
|
1033
|
+
| `src/extension/schemas.ts` / `src/shared/types.ts` | Tool schemas, shared types, and event constants. |
|
|
1015
1034
|
| `test/unit/` / `test/integration/` | Unit and loader-based integration tests. |
|
|
@@ -12,14 +12,17 @@ output: context.md
|
|
|
12
12
|
|
|
13
13
|
You are a requirements-to-context subagent.
|
|
14
14
|
|
|
15
|
-
Analyze the user request against the codebase, gather the
|
|
15
|
+
Analyze the user request against the codebase, gather the relevant high-value context, and produce structured handoff material for planning and GPT-5.5 subagent prompts. The handoff must be complete enough that the next agent does not have to rediscover the same issue from scratch.
|
|
16
16
|
|
|
17
17
|
Working rules:
|
|
18
18
|
- Read the request carefully before touching the codebase.
|
|
19
19
|
- Search the codebase for relevant files, patterns, dependencies, and constraints.
|
|
20
|
-
-
|
|
20
|
+
- Read every file needed to fully understand the issue, not just the first matching symbol. Follow imports, callers, tests, fixtures, configuration, docs, and adjacent patterns until the problem, likely solution space, and validation path are clear.
|
|
21
|
+
- If a referenced URL, issue, PR, plan, design doc, or local file is part of the request, read or fetch it before writing the handoff.
|
|
22
|
+
- Conduct web research when the task depends on external APIs, libraries, current best practices, recently changed behavior, or when local evidence is not enough to know how to solve the problem correctly. Use `web_search` if it is available; otherwise use whatever equivalent research capability is available.
|
|
23
|
+
- Keep searching or researching until you can state the likely implementation approach, risks, and validation with evidence. If a gap remains, call it out explicitly instead of implying certainty.
|
|
21
24
|
- Write the requested output files clearly and concretely.
|
|
22
|
-
- Prefer distilled, high-signal context over exhaustive dumps.
|
|
25
|
+
- Prefer distilled, high-signal context over exhaustive dumps, but do not omit a relevant file or source just to keep the handoff short.
|
|
23
26
|
|
|
24
27
|
When running in a chain, expect to generate two files in the chain directory:
|
|
25
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-subagents",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.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",
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
"pi-subagents": "install.mjs"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
|
-
"
|
|
30
|
-
"!*.test.ts",
|
|
29
|
+
"src/**/*.ts",
|
|
31
30
|
"*.mjs",
|
|
32
31
|
"agents/",
|
|
33
32
|
"skills/**/*",
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
},
|
|
44
43
|
"pi": {
|
|
45
44
|
"extensions": [
|
|
46
|
-
"./index.ts"
|
|
45
|
+
"./src/extension/index.ts"
|
|
47
46
|
],
|
|
48
47
|
"skills": [
|
|
49
48
|
"./skills"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Parallel context builders for planning handoff
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Launch fresh-context `context-builder` subagents in parallel to build grounded handoff context for planning or implementation.
|
|
6
|
+
|
|
7
|
+
Use the `subagent` tool in chain mode with a single parallel step, not top-level parallel tasks, so relative output files live under the temporary chain directory. Use `context: "fresh"` unless I explicitly ask for forked context. Give every parallel task a distinct `output` path, for example:
|
|
8
|
+
|
|
9
|
+
- `context-build/request-and-scope.md`
|
|
10
|
+
- `context-build/codebase-and-patterns.md`
|
|
11
|
+
- `context-build/validation-and-risks.md`
|
|
12
|
+
|
|
13
|
+
Do not write these context artifacts into the repository unless I explicitly ask for persistent files.
|
|
14
|
+
|
|
15
|
+
Treat the slash command arguments as the primary request, target, or focus:
|
|
16
|
+
|
|
17
|
+
$@
|
|
18
|
+
|
|
19
|
+
If the invocation provides a URL, issue link, file path, plan path, or freeform request, read or fetch that target before assigning builder angles, then pass the target explicitly into every `context-builder` task.
|
|
20
|
+
|
|
21
|
+
Choose two or three strong builders based on the request. Prefer three only when the scope benefits from independent context slices. These are examples, not fixed defaults:
|
|
22
|
+
|
|
23
|
+
1. Request and scope
|
|
24
|
+
Clarify the actual goal, user intent, constraints, non-goals, open questions, and decisions that affect the handoff.
|
|
25
|
+
|
|
26
|
+
2. Codebase and patterns
|
|
27
|
+
Inspect relevant files, call paths, existing abstractions, tests, package constraints, and local conventions that the next agent must follow.
|
|
28
|
+
|
|
29
|
+
3. Validation and risks
|
|
30
|
+
Identify likely failure modes, edge cases, test strategy, commands to run, dependency/API concerns, and escalation rules.
|
|
31
|
+
|
|
32
|
+
Adapt the angles when the request calls for it:
|
|
33
|
+
- Issue or PR URL: include issue requirements, acceptance criteria, linked discussion, and likely affected files.
|
|
34
|
+
- Plan file: include plan consistency, missing context, implementation sequence, and validation readiness.
|
|
35
|
+
- External API/library work: include current docs or primary sources through `web_search` when needed.
|
|
36
|
+
- Large refactor: include module boundaries, dependency direction, migration/cutover risks, and testability.
|
|
37
|
+
- UI/product work: include user flow, accessibility, copy, visual constraints, and implementation touchpoints.
|
|
38
|
+
|
|
39
|
+
Ask each builder to produce a compact handoff file with:
|
|
40
|
+
- relevant files and line ranges;
|
|
41
|
+
- key snippets or patterns, not full dumps;
|
|
42
|
+
- constraints and invariants;
|
|
43
|
+
- risks and unknowns;
|
|
44
|
+
- validation commands or next-best checks;
|
|
45
|
+
- a `meta-prompt` section for the next planner or GPT-5.5 subagent.
|
|
46
|
+
|
|
47
|
+
After the builders return, synthesize their outputs into:
|
|
48
|
+
- the most important context the next agent needs;
|
|
49
|
+
- the recommended meta-prompt to use next;
|
|
50
|
+
- open questions or assumptions;
|
|
51
|
+
- the output artifact paths.
|
|
52
|
+
|
|
53
|
+
Do not start implementation from this command unless I explicitly ask for it.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Parallel research/context builders into an implementation handoff plan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Use parallel subagents to understand the request, compare any external references, inspect the local codebase, and produce a grounded implementation handoff plan with a final GPT-5.5-ready meta-prompt.
|
|
6
|
+
|
|
7
|
+
Primary request, target, or focus:
|
|
8
|
+
|
|
9
|
+
$@
|
|
10
|
+
|
|
11
|
+
Use `context: "fresh"` unless I explicitly ask for forked context. First read or fetch any URLs, issue links, PRs, screenshots, plans, docs, or local files mentioned in the request. Treat them as primary scope, not optional context.
|
|
12
|
+
|
|
13
|
+
Use the `subagent` tool in chain mode:
|
|
14
|
+
|
|
15
|
+
1. First step: a parallel group.
|
|
16
|
+
- `researcher`, when the request includes external references, APIs, libraries, docs, current best practices, or prompt-guidance research.
|
|
17
|
+
- `context-builder` for local codebase context.
|
|
18
|
+
- Add a second `context-builder` only when the scope is large enough to benefit from a separate implementation-strategy pass.
|
|
19
|
+
|
|
20
|
+
2. Second step: a synthesis `context-builder` that reads the parallel findings and writes the final handoff plan and meta-prompt.
|
|
21
|
+
|
|
22
|
+
Use distinct output paths under the chain directory. Example outputs:
|
|
23
|
+
- `handoff/external-reference.md`
|
|
24
|
+
- `handoff/local-context.md`
|
|
25
|
+
- `handoff/implementation-strategy.md`
|
|
26
|
+
- `handoff/final-handoff-plan.md`
|
|
27
|
+
|
|
28
|
+
Do not write these artifacts into the repository unless I explicitly ask for persistent files.
|
|
29
|
+
|
|
30
|
+
Role guidance:
|
|
31
|
+
|
|
32
|
+
External reference researcher:
|
|
33
|
+
- Study linked projects, docs, issues, examples, source code, or prompt guidance.
|
|
34
|
+
- Identify the behavior, API, implementation files, constraints, and transferable ideas.
|
|
35
|
+
- Conduct web research if needed. Use `web_search` if it is available; otherwise use whatever equivalent research capability is available.
|
|
36
|
+
- Return source links, repo paths, key evidence, risks, and what matters for this implementation.
|
|
37
|
+
|
|
38
|
+
Local context-builder:
|
|
39
|
+
- Read all files needed to fully understand the local issue, not just the first match.
|
|
40
|
+
- Follow imports, callers, tests, fixtures, configuration, docs, and adjacent patterns until the local problem, solution space, and validation path are clear.
|
|
41
|
+
- Return relevant file paths and line ranges, current architecture, constraints, tests, risks, and open questions.
|
|
42
|
+
|
|
43
|
+
Implementation-strategy context-builder, when used:
|
|
44
|
+
- Compare the external evidence against the local architecture.
|
|
45
|
+
- Propose the safest implementation shape, files likely to change, edge cases, validation commands, and decisions that need approval.
|
|
46
|
+
- Stay review/planning-only unless I explicitly ask for implementation.
|
|
47
|
+
|
|
48
|
+
Final synthesis context-builder:
|
|
49
|
+
- Read the parallel outputs and produce one concise handoff plan.
|
|
50
|
+
- Include what the feature/change should do, what the external reference teaches, what the local codebase implies, the recommended approach, likely files to change, constraints, non-goals, validation, risks, and unresolved questions.
|
|
51
|
+
- End with a compact GPT-5.5-ready meta-prompt for the next worker/planner.
|
|
52
|
+
|
|
53
|
+
After the chain returns, synthesize the result for me with:
|
|
54
|
+
- the recommended approach;
|
|
55
|
+
- artifact paths;
|
|
56
|
+
- the final meta-prompt;
|
|
57
|
+
- any questions or assumptions that remain.
|
|
58
|
+
|
|
59
|
+
Do not start implementation from this command unless I explicitly ask for it.
|
|
@@ -37,4 +37,8 @@ While reviewers run, do your own narrow inspection if useful. After they return,
|
|
|
37
37
|
|
|
38
38
|
Do not blindly apply every reviewer suggestion. Ask before applying fixes unless I already told you to address review feedback.
|
|
39
39
|
|
|
40
|
+
Additional review target or focus from the slash command invocation:
|
|
41
|
+
|
|
40
42
|
$@
|
|
43
|
+
|
|
44
|
+
If the invocation provides a URL, issue link, file path, plan path, or freeform focus, treat it as the primary review scope. Read or fetch that target before assigning reviewer angles, and pass the target explicitly into each reviewer task.
|
|
@@ -40,12 +40,73 @@ Humans often use the slash-command layer instead:
|
|
|
40
40
|
Prefer the tool when you are writing agent logic. Prefer the slash commands when
|
|
41
41
|
you are guiding a human through an interactive flow.
|
|
42
42
|
|
|
43
|
-
Packaged prompt shortcuts are also available for repeatable workflows:
|
|
43
|
+
Packaged prompt shortcuts are also available for repeatable workflows. Treat them as reusable orchestration recipes, not just human slash commands. When the user asks for one of these shapes, or when the workflow clearly fits, apply the same pattern directly with `subagent(...)` and other tools:
|
|
44
44
|
- `/parallel-review` — fresh-context reviewers with distinct review angles, then synthesis
|
|
45
45
|
- `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
|
|
46
|
+
- `/parallel-context-build` — parallel `context-builder` passes that produce planning handoff context and meta-prompts
|
|
47
|
+
- `/parallel-handoff-plan` — external-reference research plus local `context-builder` passes, followed by a synthesis handoff plan and GPT-5.5-ready meta-prompt
|
|
46
48
|
- `/gather-context-and-clarify` — scout/research first, then ask the user clarifying questions with `interview`
|
|
47
49
|
- `/parallel-cleanup` — two fresh-context reviewers (deslop + verbosity passes) for an adversarial cleanup review of the current diff
|
|
48
50
|
|
|
51
|
+
## Applying Prompt Techniques Without Slash Commands
|
|
52
|
+
|
|
53
|
+
The prompt templates in `prompts/` encode workflows the parent agent can run on demand. If the user provides a URL, issue, PR, plan, local file, screenshot, or freeform target, treat that target as the primary scope: read or fetch it before launching children, then include it explicitly in every child task. Do not depend on the parent conversation history when the recipe calls for fresh context.
|
|
54
|
+
|
|
55
|
+
### Parallel review technique
|
|
56
|
+
|
|
57
|
+
Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. Launch fresh-context `reviewer` agents with distinct angles generated from the actual target. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability; adapt for TypeScript, UI, security, docs, or large structural changes. Reviewers should inspect files and diffs directly, return concise evidence-backed findings with file/line references, and avoid edits unless the user explicitly asks for a writer pass. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
|
|
58
|
+
|
|
59
|
+
### Parallel research technique
|
|
60
|
+
|
|
61
|
+
Use this when the question needs both external evidence and local implications. Combine `researcher` for official docs, specs, ecosystem behavior, recent changes, benchmarks, and primary sources with `scout` for repository files, patterns, constraints, tests, and likely integration points. Give each child a distinct angle: external evidence, local code context, and practical tradeoffs. Ask for source links or file ranges, confidence level, gaps, and decision implications. Do not ask these children to edit unless implementation was explicitly requested.
|
|
62
|
+
|
|
63
|
+
### Parallel context-build technique
|
|
64
|
+
|
|
65
|
+
Use this before planning or implementation when a stronger handoff is needed. Run a chain with one parallel step of `context-builder` agents rather than top-level parallel tasks, so relative output files live under the temporary chain directory. Give every task a distinct output path such as `context-build/request-and-scope.md`, `context-build/codebase-and-patterns.md`, and `context-build/validation-and-risks.md`. Choose two or three builders: request/scope, codebase/patterns, and validation/risks. Each builder must read every relevant file needed to understand its slice, follow imports/callers/tests/docs/config, conduct tool-available web research when needed, and include a compact `meta-prompt` section. The parent synthesizes the outputs into important context, recommended next meta-prompt, open questions, assumptions, and artifact paths.
|
|
66
|
+
|
|
67
|
+
Example shape:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
subagent({
|
|
71
|
+
chain: [{
|
|
72
|
+
parallel: [
|
|
73
|
+
{ agent: "context-builder", task: "Build request/scope context for: ...", output: "context-build/request-and-scope.md" },
|
|
74
|
+
{ agent: "context-builder", task: "Build codebase/pattern context for: ...", output: "context-build/codebase-and-patterns.md" },
|
|
75
|
+
{ agent: "context-builder", task: "Build validation/risk context for: ...", output: "context-build/validation-and-risks.md" }
|
|
76
|
+
]
|
|
77
|
+
}],
|
|
78
|
+
context: "fresh"
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Parallel handoff-plan technique
|
|
83
|
+
|
|
84
|
+
Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context, such as “study this library behavior, inspect our codebase, then produce a GPT-5.5 worker prompt.” Run a chain with a first parallel group and a second synthesis `context-builder` step. The first group usually includes `researcher` for external projects/docs/prompt guidance and `context-builder` for local code context; add a second `context-builder` for implementation strategy only when the scope is large enough to benefit. Use distinct output paths under `handoff/`, then have the synthesis `context-builder` read those outputs and write `handoff/final-handoff-plan.md` with the recommended approach, likely files, constraints, non-goals, validation, risks, unresolved questions, and final compact GPT-5.5-ready meta-prompt.
|
|
85
|
+
|
|
86
|
+
Example shape:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
subagent({
|
|
90
|
+
chain: [
|
|
91
|
+
{ parallel: [
|
|
92
|
+
{ agent: "researcher", task: "Research the external reference and transferable implementation ideas for: ...", output: "handoff/external-reference.md" },
|
|
93
|
+
{ agent: "context-builder", task: "Build local codebase context for: ...", output: "handoff/local-context.md" },
|
|
94
|
+
{ agent: "context-builder", task: "Compare evidence and propose implementation strategy for: ...", output: "handoff/implementation-strategy.md" }
|
|
95
|
+
] },
|
|
96
|
+
{ agent: "context-builder", task: "Read {previous} and synthesize the final handoff plan and GPT-5.5-ready meta-prompt.", output: "handoff/final-handoff-plan.md" }
|
|
97
|
+
],
|
|
98
|
+
context: "fresh"
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Gather-context-and-clarify technique
|
|
103
|
+
|
|
104
|
+
Use this at the start of non-trivial work. Launch `scout` for local context and `researcher` only when external docs, recent sources, ecosystem context, or primary evidence would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
|
|
105
|
+
|
|
106
|
+
### Parallel cleanup technique
|
|
107
|
+
|
|
108
|
+
Use this after implementation when the user wants cleanup review or when a final pass would reduce AI-slop. Launch two fresh-context `reviewer` tasks with `output: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that reviewer; otherwise inline the criteria. Both reviewers are review-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. The parent decides what to apply and asks before making changes unless cleanup was already authorized.
|
|
109
|
+
|
|
49
110
|
## Builtin Agents
|
|
50
111
|
|
|
51
112
|
Builtin agents load at the lowest priority. Project agents override user agents,
|
|
@@ -200,6 +261,8 @@ without forcing each step to rediscover everything.
|
|
|
200
261
|
|
|
201
262
|
### Async/background
|
|
202
263
|
|
|
264
|
+
Use async mode whenever the parent agent should keep working while a child runs. A normal foreground `subagent(...)` call blocks the parent until the child completes; it is appropriate when the next parent step depends on the child result. If you say you will "ask a reviewer while I continue auditing" or otherwise run local work in parallel with a child, launch with `async: true`. Do not end your turn immediately after launching that async child if you promised to keep working; continue the local inspection or other independent work, then check the async run when its result is needed.
|
|
265
|
+
|
|
203
266
|
```typescript
|
|
204
267
|
subagent({
|
|
205
268
|
agent: "worker",
|
|
@@ -208,6 +271,18 @@ subagent({
|
|
|
208
271
|
})
|
|
209
272
|
```
|
|
210
273
|
|
|
274
|
+
For review fanout where the parent continues a local audit:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
const run = subagent({
|
|
278
|
+
agent: "reviewer",
|
|
279
|
+
task: "Review the current diff for correctness issues. Do not edit files.",
|
|
280
|
+
async: true,
|
|
281
|
+
context: "fresh"
|
|
282
|
+
})
|
|
283
|
+
// Continue local inspection, then later call status with the returned id.
|
|
284
|
+
```
|
|
285
|
+
|
|
211
286
|
Inspect async runs with `subagent({ action: "status", id: "..." })`, `subagent({ action: "status" })` for active runs, or the `/subagents-status` slash command.
|
|
212
287
|
|
|
213
288
|
Use diagnostics when setup or child startup looks wrong:
|
|
@@ -440,9 +515,12 @@ copying a full builtin file.
|
|
|
440
515
|
## Prompt Template Integration
|
|
441
516
|
|
|
442
517
|
The package includes prompt shortcuts for common workflows: `/parallel-review`,
|
|
443
|
-
`/parallel-research`, `/
|
|
444
|
-
Use them when the user
|
|
445
|
-
|
|
518
|
+
`/parallel-research`, `/parallel-context-build`, `/parallel-handoff-plan`,
|
|
519
|
+
`/gather-context-and-clarify`, and `/parallel-cleanup`. Use them when the user
|
|
520
|
+
wants repeatable review, research, context handoff, implementation handoff,
|
|
521
|
+
clarification, or cleanup-review patterns. Parent agents can also apply the same
|
|
522
|
+
recipes directly with `subagent(...)` when the user describes the workflow in
|
|
523
|
+
natural language instead of invoking a slash command.
|
|
446
524
|
|
|
447
525
|
If `pi-prompt-template-model` is installed, additional user prompt templates can delegate into
|
|
448
526
|
`pi-subagents`. This is useful when a slash command should always run through a
|
|
@@ -522,6 +600,8 @@ When the user approves launching a subagent to carry out a plan or workflow, tre
|
|
|
522
600
|
- `/gather-context-and-clarify` maps to: launch `scout` and, when needed, `researcher`; synthesize findings; then use `interview` to ask every clarification question needed for shared understanding.
|
|
523
601
|
- `/parallel-review` maps to: launch fresh-context `reviewer` agents with distinct review angles; synthesize the feedback before applying anything.
|
|
524
602
|
- `/parallel-research` maps to: combine local `scout` context with external `researcher` evidence when current docs, ecosystem behavior, or API details matter.
|
|
603
|
+
- `/parallel-context-build` maps to: run a chain-mode parallel group of `context-builder` agents with distinct temp output paths, then synthesize their context and meta-prompt sections.
|
|
604
|
+
- `/parallel-handoff-plan` maps to: run external `researcher` plus local/strategy `context-builder` passes, then a synthesis `context-builder` that writes an implementation handoff plan and GPT-5.5-ready meta-prompt.
|
|
525
605
|
- `/parallel-cleanup` maps to: use review-only cleanup passes after implementation, especially for simplicity, verbosity, and redundant tests.
|
|
526
606
|
|
|
527
607
|
For feature work, use this sequence as scaffolding for parent-agent behavior:
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { serializeAgent } from "./agent-serializer.ts";
|
|
17
17
|
import { serializeChain } from "./chain-serializer.ts";
|
|
18
18
|
import { discoverAvailableSkills } from "./skills.ts";
|
|
19
|
-
import type { Details } from "
|
|
19
|
+
import type { Details } from "../shared/types.ts";
|
|
20
20
|
|
|
21
21
|
type ManagementAction = "list" | "get" | "create" | "update" | "delete";
|
|
22
22
|
type ManagementScope = "user" | "project";
|
|
@@ -696,7 +696,7 @@ function resolveNearestProjectAgentDirs(cwd: string): { readDirs: string[]; pref
|
|
|
696
696
|
preferredDir,
|
|
697
697
|
};
|
|
698
698
|
}
|
|
699
|
-
const BUILTIN_AGENTS_DIR = path.
|
|
699
|
+
const BUILTIN_AGENTS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "agents");
|
|
700
700
|
|
|
701
701
|
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
|
702
702
|
const userDirOld = path.join(os.homedir(), ".pi", "agent", "agents");
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { controlNotificationKey, formatControlNoticeMessage } from "../runs/shared/subagent-control.ts";
|
|
3
|
+
import type { ControlEvent, SubagentState } from "../shared/types.ts";
|
|
4
|
+
|
|
5
|
+
export const SUBAGENT_CONTROL_MESSAGE_TYPE = "subagent_control_notice";
|
|
6
|
+
|
|
7
|
+
export interface SubagentControlMessageDetails {
|
|
8
|
+
event: ControlEvent;
|
|
9
|
+
source?: "foreground" | "async";
|
|
10
|
+
asyncDir?: string;
|
|
11
|
+
childIntercomTarget?: string;
|
|
12
|
+
noticeText?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function controlNoticeTarget(details: SubagentControlMessageDetails): string | undefined {
|
|
16
|
+
return details.childIntercomTarget;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function formatSubagentControlNotice(details: SubagentControlMessageDetails, content?: string): string {
|
|
20
|
+
return details.noticeText ?? content ?? formatControlNoticeMessage(details.event, controlNoticeTarget(details));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function noticeTimerKey(details: SubagentControlMessageDetails): string {
|
|
24
|
+
const childIntercomTarget = controlNoticeTarget(details);
|
|
25
|
+
return `${details.event.runId}:${controlNotificationKey(details.event, childIntercomTarget)}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function clearPendingForegroundControlNotices(state: SubagentState, runId?: string): void {
|
|
29
|
+
const pending = state.pendingForegroundControlNotices;
|
|
30
|
+
if (!pending) return;
|
|
31
|
+
for (const [key, timer] of pending) {
|
|
32
|
+
if (runId !== undefined && !key.startsWith(`${runId}:`)) continue;
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
pending.delete(key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function deliverControlNotice(input: {
|
|
39
|
+
pi: Pick<ExtensionAPI, "sendMessage">;
|
|
40
|
+
visibleControlNotices: Set<string>;
|
|
41
|
+
details: SubagentControlMessageDetails;
|
|
42
|
+
}): void {
|
|
43
|
+
const childIntercomTarget = controlNoticeTarget(input.details);
|
|
44
|
+
const key = controlNotificationKey(input.details.event, childIntercomTarget);
|
|
45
|
+
if (input.visibleControlNotices.has(key)) return;
|
|
46
|
+
input.visibleControlNotices.add(key);
|
|
47
|
+
const noticeText = input.details.noticeText ?? formatControlNoticeMessage(input.details.event, childIntercomTarget);
|
|
48
|
+
input.pi.sendMessage(
|
|
49
|
+
{
|
|
50
|
+
customType: SUBAGENT_CONTROL_MESSAGE_TYPE,
|
|
51
|
+
content: noticeText,
|
|
52
|
+
display: true,
|
|
53
|
+
details: { ...input.details, childIntercomTarget, noticeText },
|
|
54
|
+
},
|
|
55
|
+
{ triggerTurn: input.details.source !== "foreground" },
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isForegroundNoticeStillActionable(state: SubagentState, details: SubagentControlMessageDetails): boolean {
|
|
60
|
+
const control = state.foregroundControls.get(details.event.runId);
|
|
61
|
+
if (!control) return false;
|
|
62
|
+
if (control.currentAgent && control.currentAgent !== details.event.agent) return false;
|
|
63
|
+
if (details.event.index !== undefined && control.currentIndex !== details.event.index) return false;
|
|
64
|
+
return control.currentActivityState === "needs_attention";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function handleSubagentControlNotice(input: {
|
|
68
|
+
pi: Pick<ExtensionAPI, "sendMessage">;
|
|
69
|
+
state: SubagentState;
|
|
70
|
+
visibleControlNotices: Set<string>;
|
|
71
|
+
details: SubagentControlMessageDetails;
|
|
72
|
+
foregroundDelayMs?: number;
|
|
73
|
+
}): void {
|
|
74
|
+
if (!input.details?.event || input.details.event.type === "active_long_running") return;
|
|
75
|
+
if (input.details.source !== "foreground") {
|
|
76
|
+
deliverControlNotice(input);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const pending = input.state.pendingForegroundControlNotices ?? new Map<string, ReturnType<typeof setTimeout>>();
|
|
81
|
+
input.state.pendingForegroundControlNotices = pending;
|
|
82
|
+
const timerKey = noticeTimerKey(input.details);
|
|
83
|
+
const existing = pending.get(timerKey);
|
|
84
|
+
if (existing) clearTimeout(existing);
|
|
85
|
+
const timer = setTimeout(() => {
|
|
86
|
+
pending.delete(timerKey);
|
|
87
|
+
if (!isForegroundNoticeStillActionable(input.state, input.details)) return;
|
|
88
|
+
deliverControlNotice(input);
|
|
89
|
+
}, input.foregroundDelayMs ?? 1000);
|
|
90
|
+
timer.unref?.();
|
|
91
|
+
pending.set(timerKey, timer);
|
|
92
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { discoverAgentsAll, type AgentSource } from "
|
|
4
|
-
import { isAsyncAvailable } from "
|
|
5
|
-
import { diagnoseIntercomBridge, type IntercomBridgeDiagnostic } from "
|
|
6
|
-
import { discoverAvailableSkills, type SkillSource } from "
|
|
3
|
+
import { discoverAgentsAll, type AgentSource } from "../agents/agents.ts";
|
|
4
|
+
import { isAsyncAvailable } from "../runs/background/async-execution.ts";
|
|
5
|
+
import { diagnoseIntercomBridge, type IntercomBridgeDiagnostic } from "../intercom/intercom-bridge.ts";
|
|
6
|
+
import { discoverAvailableSkills, type SkillSource } from "../agents/skills.ts";
|
|
7
7
|
import {
|
|
8
8
|
ASYNC_DIR,
|
|
9
9
|
CHAIN_RUNS_DIR,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
TEMP_ROOT_DIR,
|
|
12
12
|
type ExtensionConfig,
|
|
13
13
|
type SubagentState,
|
|
14
|
-
} from "
|
|
14
|
+
} from "../shared/types.ts";
|
|
15
15
|
|
|
16
16
|
interface DoctorPaths {
|
|
17
17
|
tempRootDir: string;
|