@xzzpig/pi-subagents 0.7.0 → 0.9.0
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 +456 -4
- package/README.md +3 -3
- package/agents/claude-code-writer.md +15 -0
- package/agents/claude-code.md +15 -0
- package/agents/codex-exec-writer.md +15 -0
- package/agents/codex-exec.md +15 -0
- package/agents/cursor-agent-writer.md +14 -0
- package/agents/cursor-agent.md +14 -0
- package/agents/reviewer.md +13 -3
- package/agents/scout.md +1 -1
- package/docs/agents.md +154 -42
- package/docs/configuration.md +85 -26
- package/docs/extension-api.md +81 -16
- package/docs/missions.md +2 -0
- package/docs/models.md +75 -11
- package/docs/observability.md +34 -21
- package/docs/tool-reference.md +142 -18
- package/docs/watchdog.md +92 -114
- package/docs/workflows.md +148 -4
- package/index.ts +10 -1
- package/install.mjs +1 -1
- package/package.json +7 -6
- package/prompts/council.md +19 -7
- package/prompts/parallel-review.md +5 -1
- package/prompts/review-loop.md +11 -7
- package/skills/council-mode/SKILL.md +44 -215
- package/skills/council-mode/references/pass-contracts.md +150 -0
- package/skills/pi-subagents/SKILL.md +90 -32
- package/skills/pi-subagents/references/constraints-and-recipes.md +34 -223
- package/skills/pi-subagents/references/execution-controls.md +104 -19
- package/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/skills/pi-subagents/references/multi-lane-orchestration.md +16 -4
- package/skills/pi-subagents/references/prompting-and-roles.md +71 -36
- package/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/src/agents/agent-management.ts +471 -114
- package/src/agents/agent-refinements.ts +4 -4
- package/src/agents/agent-serializer.ts +16 -4
- package/src/agents/agents.ts +1076 -351
- package/src/agents/builtin-names.ts +6 -0
- package/src/agents/runtime-agent-events.ts +70 -0
- package/src/agents/runtime-agent-registry.ts +31 -20
- package/src/api/agents.ts +10 -5
- package/src/api/background-work.ts +12 -3
- package/src/api/capability-ceiling.ts +0 -1
- package/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/src/api/delegation.ts +0 -7
- package/src/api/external-job-provider.ts +10 -1
- package/src/api/external-runs.ts +67 -4
- package/src/api/preflight.ts +97 -34
- package/src/api/project-panes.ts +2 -0
- package/src/api/shared-types.ts +6 -0
- package/src/extension/config.ts +90 -0
- package/src/extension/doctor.ts +15 -13
- package/src/extension/fanout-child.ts +17 -16
- package/src/extension/index.ts +139 -41
- package/src/extension/public-execution.ts +113 -22
- package/src/extension/rpc.ts +182 -13
- package/src/extension/schemas.ts +63 -21
- package/src/extension/tool-description.ts +48 -23
- package/src/extension/tool-result.ts +19 -0
- package/src/inspectors/herdr/actions.ts +2 -1
- package/src/inspectors/herdr/client.ts +3 -3
- package/src/inspectors/herdr/focus.ts +55 -0
- package/src/inspectors/herdr/inspector-runner.ts +21 -23
- package/src/inspectors/herdr/project-panes.ts +228 -44
- package/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/src/integrations/herdr-status.ts +75 -5
- package/src/intercom/native-supervisor-channel.ts +138 -60
- package/src/intercom/result-intercom.ts +2 -0
- package/src/intercom/supervisor-ui.ts +243 -0
- package/src/profiles/profiles.ts +5 -6
- package/src/runs/background/active-async-capacity.ts +103 -18
- package/src/runs/background/async-execution.ts +492 -125
- package/src/runs/background/async-job-tracker.ts +127 -28
- package/src/runs/background/async-resume.ts +67 -29
- package/src/runs/background/async-retention.ts +21 -4
- package/src/runs/background/async-status-snapshot.ts +23 -261
- package/src/runs/background/async-status.ts +199 -14
- package/src/runs/background/auto-drain.ts +1 -1
- package/src/runs/background/chain-append.ts +8 -3
- package/src/runs/background/chain-root-attachment.ts +79 -8
- package/src/runs/background/control-channel.ts +101 -214
- package/src/runs/background/fleet-view.ts +38 -22
- package/src/runs/background/inspect-rpc.ts +8 -8
- package/src/runs/background/notify.ts +295 -8
- package/src/runs/background/process-terminal.ts +16 -0
- package/src/runs/background/result-delivery-ownership.ts +45 -0
- package/src/runs/background/result-files.ts +28 -14
- package/src/runs/background/result-watcher.ts +43 -19
- package/src/runs/background/resume-guidance.ts +2 -2
- package/src/runs/background/retained-children.ts +1 -1
- package/src/runs/background/run-child-session.ts +613 -0
- package/src/runs/background/run-status.ts +99 -18
- package/src/runs/background/runner-aliases.ts +125 -0
- package/src/runs/background/runner-child-sessions.ts +31 -0
- package/src/runs/background/scheduled-runs.ts +174 -18
- package/src/runs/background/stale-run-reconciler.ts +13 -4
- package/src/runs/background/steering.ts +8 -15
- package/src/runs/background/subagent-runner.ts +959 -1159
- package/src/runs/background/subagent-wait.ts +86 -31
- package/src/runs/background/terminal-run-index.ts +1 -1
- package/src/runs/background/wait-completions.ts +45 -2
- package/src/runs/background/wait-config.ts +23 -9
- package/src/runs/background/wait-tool.ts +27 -19
- package/src/runs/foreground/async-steering-action.ts +3 -19
- package/src/runs/foreground/async-stop-action.ts +23 -2
- package/src/runs/foreground/execution.ts +585 -481
- package/src/runs/foreground/foreground-control.ts +13 -0
- package/src/runs/foreground/foreground-history.ts +26 -3
- package/src/runs/foreground/subagent-executor.ts +1549 -410
- package/src/runs/foreground/workflow-detach-reconcile.ts +141 -104
- package/src/runs/foreground/workflow-foreground-steering.ts +24 -98
- package/src/runs/shared/abort-recovery.ts +119 -0
- package/src/runs/shared/acceptance.ts +147 -39
- package/src/runs/shared/agent-contract.ts +1 -1
- package/src/runs/shared/async-status-projection.ts +565 -0
- package/src/runs/shared/background-process-options.ts +9 -0
- package/src/runs/shared/capability-ceiling.ts +2 -2
- package/src/runs/shared/child-hooks.ts +25 -0
- package/src/runs/shared/child-identity.ts +62 -0
- package/src/runs/shared/child-launch-plan.ts +151 -0
- package/src/runs/shared/child-launch.ts +314 -0
- package/src/runs/shared/child-lifecycle.ts +25 -0
- package/src/runs/shared/child-runtime-config.ts +126 -0
- package/src/runs/shared/child-session.ts +342 -0
- package/src/runs/shared/child-tool-plan.ts +540 -0
- package/src/runs/shared/claude-code-adapter.ts +133 -0
- package/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/src/runs/shared/completion-evidence.ts +89 -0
- package/src/runs/shared/completion-guard.ts +57 -6
- package/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/src/runs/shared/dynamic-fanout.ts +4 -4
- package/src/runs/shared/extension-bindings.ts +78 -0
- package/src/runs/shared/external-cli-contract.ts +167 -0
- package/src/runs/shared/external-cli-preflight.ts +138 -0
- package/src/runs/shared/external-cli-runner.ts +349 -54
- package/src/runs/shared/external-job-bridge.ts +53 -37
- package/src/runs/shared/external-job-runner.ts +126 -23
- package/src/runs/shared/fast-mode-extension.ts +10 -0
- package/src/runs/shared/host-step-status.ts +231 -0
- package/src/runs/shared/lane-metadata.ts +126 -0
- package/src/runs/shared/launch-cwd.ts +16 -0
- package/src/runs/shared/long-running-guard.ts +2 -1
- package/src/runs/shared/mcp-config-sources.ts +422 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +222 -158
- package/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
- package/src/runs/shared/model-exclusions.ts +141 -10
- package/src/runs/shared/model-fallback.ts +187 -33
- package/src/runs/shared/model-scope.ts +106 -39
- package/src/runs/shared/mutation-evidence.ts +199 -0
- package/src/runs/shared/nested-events.ts +38 -48
- package/src/runs/shared/nested-path.ts +0 -14
- package/src/runs/shared/nested-render.ts +9 -5
- package/src/runs/shared/orca-progress-tabs.ts +83 -16
- package/src/runs/shared/parallel-handoff.ts +423 -7
- package/src/runs/shared/parallel-utils.ts +28 -5
- package/src/runs/shared/permissions.ts +1 -14
- package/src/runs/shared/pi-spawn.ts +69 -35
- package/src/runs/shared/process-signal.ts +16 -0
- package/src/runs/shared/run-fanout-budget.ts +0 -13
- package/src/runs/shared/run-history.ts +21 -1
- package/src/runs/shared/runtime-acknowledged-extensions.ts +0 -27
- package/src/runs/shared/single-output.ts +89 -22
- package/src/runs/shared/structured-output.ts +61 -7
- package/src/runs/shared/subagent-control.ts +6 -2
- package/src/runs/shared/subagent-prompt-runtime.ts +216 -360
- package/src/runs/shared/task-intent.ts +21 -7
- package/src/runs/shared/tool-availability.ts +18 -64
- package/src/runs/shared/tool-budget.ts +0 -14
- package/src/runs/shared/tool-timeout.ts +1 -1
- package/src/runs/shared/workflow-graph.ts +16 -0
- package/src/runs/shared/worktree-cleanup-plan.ts +866 -0
- package/src/runs/shared/worktree.ts +571 -62
- package/src/shared/atomic-json.ts +3 -1
- package/src/shared/child-session-name.ts +46 -0
- package/src/shared/extension-context.ts +24 -0
- package/src/shared/fork-context.ts +21 -12
- package/src/shared/fork-session-cwd.ts +27 -0
- package/src/shared/formatters.ts +18 -3
- package/src/shared/jsonl-writer.ts +11 -0
- package/src/shared/launch-contract.ts +20 -6
- package/src/shared/pruned-fork.ts +450 -0
- package/src/shared/session-file-trust.ts +19 -0
- package/src/shared/session-tokens.ts +14 -3
- package/src/shared/settings.ts +21 -102
- package/src/shared/shortcuts.ts +17 -0
- package/src/shared/thinking-ceiling.ts +46 -0
- package/src/shared/types.ts +644 -75
- package/src/shared/utils.ts +60 -93
- package/src/shared/workflow-child-permit.ts +207 -0
- package/src/slash/delegation-adapters.ts +1 -9
- package/src/slash/delegation-request.ts +0 -4
- package/src/slash/prompt-template-bridge.ts +37 -1
- package/src/slash/slash-bridge.ts +1 -2
- package/src/slash/slash-commands.ts +383 -116
- package/src/slash/slash-live-state.ts +22 -11
- package/src/slash/subagents-admin.ts +29 -12
- package/src/tui/fleet-native-transcript.ts +4 -0
- package/src/tui/fleet-status.ts +278 -90
- package/src/tui/fleet-transcript.ts +11 -5
- package/src/tui/fleet.ts +54 -28
- package/src/tui/render-helpers.ts +31 -0
- package/src/tui/render.ts +1433 -166
- package/src/watchdog/change-signature.ts +40 -1
- package/src/watchdog/child-status.ts +54 -34
- package/src/watchdog/diff-tool.ts +77 -0
- package/src/watchdog/emission-guard.ts +5 -3
- package/src/watchdog/guidance.ts +20 -0
- package/src/watchdog/permission-arbiter.ts +59 -52
- package/src/watchdog/register-child.ts +28 -25
- package/src/watchdog/register-main.ts +10 -9
- package/src/watchdog/render.ts +4 -5
- package/src/watchdog/review.ts +15 -4
- package/src/watchdog/rules.ts +70 -0
- package/src/watchdog/runtime.ts +75 -92
- package/src/watchdog/scope.ts +0 -11
- package/src/watchdog/settings.ts +48 -104
- package/src/watchdog/turn-delta.ts +1 -1
- package/src/watchdog/types.ts +18 -32
- package/src/watchdog/warning-format.ts +0 -1
- package/src/workflows/chat-progress.ts +7 -3
- package/src/workflows/host-command.ts +235 -0
- package/src/workflows/scripted-workflow.ts +1142 -69
- package/src/workflows/workflow-checklist.ts +439 -0
- package/src/workflows/workflow-child-summary.ts +121 -0
- package/src/workflows/workflow-preflight.ts +297 -0
- package/src/workflows/workflow-receipt.ts +232 -6
- package/src/workflows/workflow-resources.ts +150 -0
- package/src/workflows/workflow-settlement.ts +246 -0
- package/src/runs/shared/child-protocol.ts +0 -401
- package/src/runs/shared/pi-args.ts +0 -858
- package/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/src/runs/shared/turn-budget.ts +0 -98
- package/src/shared/post-exit-stdio-guard.ts +0 -85
package/docs/workflows.md
CHANGED
|
@@ -14,7 +14,7 @@ Packaged `worker`, `oracle`, and `advisor` default to forked context when a laun
|
|
|
14
14
|
|
|
15
15
|
Child-safety boundaries are enforced at runtime:
|
|
16
16
|
|
|
17
|
-
-
|
|
17
|
+
- Child sessions do not receive the bundled `pi-subagents` skill.
|
|
18
18
|
- Forked child context filtering removes parent-only subagent artifacts (including old hidden orchestration-instruction messages, slash/status/control messages, and prior parent `subagent` tool-call/tool-result history) while preserving ordinary prose and unrelated tool calls/results.
|
|
19
19
|
- By default, children do not register the `subagent` tool and receive boundary instructions that they are not the parent orchestrator and must not propose or run subagents.
|
|
20
20
|
- The explicit exception is an agent whose resolved builtin `tools` includes `subagent`; that child gets a child-safe `subagent` tool for the fanout work the parent assigned, still bounded by `maxSubagentDepth`.
|
|
@@ -35,10 +35,64 @@ Add `autofix` to `/parallel-review` or `/parallel-cleanup` to apply only the syn
|
|
|
35
35
|
|
|
36
36
|
## Scripted workflows (workflowScript)
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Use direct `{ agent, task }` for one bounded child. Use `workflowScript` when the parent needs a stable keyed child, sequence, fanout, steering, retry, or aggregation. For ordinary parallel fanout, use `await runs.all([{ key, agent, task }, ...])`. It resolves to an ordered array, not a key map, so use indexes, destructuring, or `.map(...)`, not `results.<key>`. Do not read `.output` from unawaited `runs.run` launches. Store a `runs.run` promise only when the script later observes it with `await`, `Promise.race`, or `Promise.all`, such as steering a live child before awaiting its result. Scripts are ordinary JavaScript statement bodies. Use an explicit `return` for a useful result:
|
|
39
39
|
|
|
40
40
|
Child results cross into the script as plain JSON data. Non-JSON host metadata is omitted, so use returned fields such as `runId`, `ok`, `output`, and `structuredOutput` for workflow control.
|
|
41
41
|
|
|
42
|
+
Validate a script without launching children:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
subagent({ action: "validate", workflowScript: `
|
|
46
|
+
const results = await runs.all([{ key: "scan", agent: "scout", task: "Scan" }]);
|
|
47
|
+
return results[0].output;
|
|
48
|
+
` });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For a script stored in a file, use `workflowScriptPath` instead of `workflowScript`:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
subagent({ workflowScriptPath: "workflows/review.js", cwd: "/path/to/project" });
|
|
55
|
+
subagent({ action: "validate", workflowScriptPath: "workflows/review.js" });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The fields are mutually exclusive. Relative paths resolve against the request `cwd`; absolute paths pass through. The host reads the file before validation, schedule creation, or workflow sandbox execution. The sandbox still has no filesystem access. Missing, unreadable, and empty files return file input errors instead of script syntax errors.
|
|
59
|
+
|
|
60
|
+
### Named workflow resources for permission extensions
|
|
61
|
+
|
|
62
|
+
Use a named workflow resource when a permission or policy extension needs to distinguish extension-resolved workflow content from raw model-authored scripts:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
subagent({ workflow: "review", args: { task: "Review the change" } });
|
|
66
|
+
subagent({ workflow: "run-ci", args: { command: "npm test" } });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The host resolves the name and validates bounded plain-JSON `args` before starting the workflow. Resource provenance is recorded in workflow details and receipts for downstream permission/policy checks. Resource authority is not caller-supplied: `runs.host` is available only when the resolved resource explicitly grants the requested host key and command. Inline `workflowScript` and `workflowScriptPath` remain raw, unknown-provenance inputs, so their `runs.host` calls are unavailable through the public execution boundary. Named resources cannot be combined with `agent`, `task`, `workflowScript`, or `workflowScriptPath`; this first slice ships only the package-owned `review` and `run-ci` resources, not a user/project resource registry.
|
|
70
|
+
|
|
71
|
+
### Opt-in bounded workflows
|
|
72
|
+
|
|
73
|
+
Composite workflows have no default parent deadline. Add bounds only when the workflow contract calls for them:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
subagent({
|
|
77
|
+
workflowScript: `
|
|
78
|
+
const scan = await runs.run("scan", { agent: "scout", task: "Inspect the named files." });
|
|
79
|
+
return runs.run("review", { agent: "reviewer", task: "Review:\n" + scan.output });
|
|
80
|
+
`,
|
|
81
|
+
timeoutMs: 900000,
|
|
82
|
+
toolBudget: { soft: 40, hard: 60 },
|
|
83
|
+
usageBudget: { tokens: { soft: 100000, hard: 150000 } }
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- `timeoutMs` sets the workflow deadline and bounds child deadlines to the remaining time.
|
|
88
|
+
- `toolBudget` becomes the default for each child unless that child supplies a narrower value.
|
|
89
|
+
- `usageBudget` accounts for reported usage across completed workflow children. Once exhausted, it rejects later child launches but does not stop children that are already running.
|
|
90
|
+
- Budget and timeout stops return a structured `terminalOutcome` with `state: "partial"` and reason `budget_exhausted` or `timeout`. Workflow receipts keep settled child evidence for recovery.
|
|
91
|
+
|
|
92
|
+
These controls are opt-in. Avoid tight hard budgets for mutation-capable workers unless the workflow has an explicit checkpoint and handoff path.
|
|
93
|
+
|
|
94
|
+
The result is `{ ok, errors }`. Invalid scripts return a tool error and include line and column data when available. Validation checks syntax, portable nested-async rules, literal `runs.run` and `runs.all` keys, duplicate literal keys in one `runs.all` group, direct keyed access to a known `runs.all` result, and statically clear non-JSON boundary values. Dynamic keys and other runtime-only values are accepted without a warning. Validation does not discover agents, launch children, or create run artifacts.
|
|
95
|
+
|
|
42
96
|
```js
|
|
43
97
|
subagent({ workflowScript: `
|
|
44
98
|
const scan = await runs.run("scan", { agent: "scout", task: "Scan the codebase" });
|
|
@@ -72,6 +126,61 @@ subagent({ workflowScript: `
|
|
|
72
126
|
` });
|
|
73
127
|
```
|
|
74
128
|
|
|
129
|
+
### Parallel sequential lanes
|
|
130
|
+
|
|
131
|
+
For a bounded set of independent chains, `runs.lanes(...)` removes the mechanical loop that would otherwise connect each lane's stages. It is a helper inside `workflowScript`, not a new top-level `subagent` execution mode:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
subagent({ workflowScript: `
|
|
135
|
+
const board = await runs.lanes([
|
|
136
|
+
{
|
|
137
|
+
key: "api",
|
|
138
|
+
stages: [
|
|
139
|
+
{ key: "writer", agent: "worker", task: "Implement the API change" },
|
|
140
|
+
{ key: "challenge", resume: "previous", task: "Challenge the API implementation" },
|
|
141
|
+
{ key: "review", agent: "reviewer", task: "Review the API lane" }
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
key: "ui",
|
|
146
|
+
stages: [
|
|
147
|
+
{ key: "writer", agent: "worker", task: "Implement the UI change" },
|
|
148
|
+
{ key: "review", agent: "reviewer", task: "Review the UI lane" }
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
]);
|
|
152
|
+
return board.map((lane) => ({
|
|
153
|
+
key: lane.key,
|
|
154
|
+
state: lane.state,
|
|
155
|
+
failedStage: lane.failedStage,
|
|
156
|
+
stages: lane.stages.map((stage) => ({
|
|
157
|
+
key: stage.key,
|
|
158
|
+
state: stage.state,
|
|
159
|
+
ok: stage.ok,
|
|
160
|
+
runId: stage.runId,
|
|
161
|
+
outputReference: stage.outputReference,
|
|
162
|
+
verdict: stage.verdict
|
|
163
|
+
}))
|
|
164
|
+
}));
|
|
165
|
+
` });
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The first stage from every lane is launched in one existing `runs.all(...)` batch. Later stages in each lane start only after the preceding stage settles. A later stage with `resume: "previous"` requires the preceding child to return a retained `runId`; the helper then uses the existing retained-resume launch checks and does not accept an arbitrary run id. Generated child keys use `<lane>.<stage>`, while the returned board uses the local lane and stage keys.
|
|
169
|
+
|
|
170
|
+
The helper validates the complete plain-JSON lane inventory before launching anything. It bounds the inventory to 32 lanes, 16 stages per lane, 64 total stages, and 64 KiB of canonical JSON; task and path fields retain the existing 1 MiB and 32 KiB limits. Stage keys must be unique within a lane and generated keys must be unique and valid workflow keys. A child failure, stopped/detached result, or explicit `structuredOutput.verdict === "blocked"` blocks only that lane; later stages are marked `skipped` and sibling lanes continue. Reviewer prose is never parsed.
|
|
171
|
+
|
|
172
|
+
The board is bounded and contains only lane/stage keys, state, success, retained run ids, explicit output references, bounded errors, and an optional structured verdict. It does not return child transcripts or create a lane registry or cleanup authority. Use raw `runs.run(...)`/`runs.all(...)` when a workflow needs conditional or rolling orchestration beyond this helper.
|
|
173
|
+
|
|
174
|
+
### Host command steps
|
|
175
|
+
|
|
176
|
+
Use the named `run-ci` resource when a permission/policy extension needs to admit one supported non-interactive command as workflow evidence instead of a child-agent run:
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
subagent({ workflow: "run-ci", args: { command: "npm test", timeoutMs: 120000 } });
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The first named resource version supports only `npm test` and `npm run typecheck`, with bounded timeout values. Its resolved script uses `runs.host("ci", ...)` and the resource authority admits only the selected command. **There is no per-step `cwd` field:** the command and relative output path use the workflow cwd. Set `cwd` on the outer `subagent({...})` request when the workflow should run in another directory. The command has no stdin, receives the workflow cwd, and must be awaited or returned. Stdout, stderr, and the saved log are bounded. A nonzero exit, timeout, abort, or output-write failure fails the workflow. Async status and terminal receipts store the bounded host-step state; renderers do not run commands or read command output.
|
|
183
|
+
|
|
75
184
|
### Steering a workflow child
|
|
76
185
|
|
|
77
186
|
Use `await runs.steer(key, message, options?)` after `runs.run` or `runs.all` has launched that stable key. Scripts do not target raw run ids. The optional fields are `mode: "steer" | "follow_up" | "auto"`, a non-negative child `index`, and a positive `ackTimeoutMs`.
|
|
@@ -226,6 +335,12 @@ fresh: true
|
|
|
226
335
|
Review $@. Return concrete findings with source proof, or state that no issue was found.
|
|
227
336
|
```
|
|
228
337
|
|
|
338
|
+
For first-pass review prompts, filter by evidence rather than by severity. Ask the
|
|
339
|
+
reviewer to label concrete current findings P0/P1/P2 and end with `Merge verdict:
|
|
340
|
+
BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. Reserve
|
|
341
|
+
`blockers only` for final pre-merge re-checks after P1/P2 findings are already
|
|
342
|
+
known, or for explicit emergency hotfix lanes.
|
|
343
|
+
|
|
229
344
|
```text
|
|
230
345
|
/prompt-workflow review-release-candidate v0.51.0
|
|
231
346
|
```
|
|
@@ -254,7 +369,36 @@ Each child uses the existing worktree lifecycle: it branches from clean HEAD, jo
|
|
|
254
369
|
|
|
255
370
|
A top-level `{ workflowScript, worktree: true }` makes isolation the default for every workflow child. An individual child can override that default with `worktree: false`. Keep one writer when parallel writes are not intentionally isolated.
|
|
256
371
|
|
|
257
|
-
|
|
372
|
+
Use `baseRef` to branch managed worktrees from a named commit or branch instead of the default `HEAD`. For example, `{ workflowScript, worktree: true, baseRef: "refs/heads/release" }` applies the release ref to children unless a child supplies its own `baseRef`. The source checkout must still be clean, and the ref must resolve to a commit before any worktree is allocated.
|
|
373
|
+
|
|
374
|
+
Configure the worktree provider, native path layout, base directory, and setup hook in [configuration.md](configuration.md).
|
|
375
|
+
|
|
376
|
+
### Lane metadata lifecycle
|
|
377
|
+
|
|
378
|
+
Workflow children may declare a bounded `lane` object (`version`, `key`, optional
|
|
379
|
+
`mode`, opaque `sourceRef`, advisory `claims`, and advisory `outputPaths`). The
|
|
380
|
+
lane key must match the `runs.run`/`runs.all` workflow key. These fields are
|
|
381
|
+
display and triage hints only: they do not grant tools, authorization, or
|
|
382
|
+
cleanup permission, and `sourceRef` is never resolved over the network while
|
|
383
|
+
rendering status. Worktree paths and branches copied into status are also
|
|
384
|
+
display-only; the handoff manifest remains the deletion authority.
|
|
385
|
+
|
|
386
|
+
| Durable file | Owner | Pending / running / finalized / cleanup states | Release predicate | Rollback predicate | Stale-head behavior | Fail-closed cases |
|
|
387
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
388
|
+
| `status.json` | Async runner and workflow status projector | Child step starts `pending`, becomes `running`, then terminal `complete`/`failed`/`paused`/`stopped`; worktree path and branch are copied at launch | Status is terminal and the existing active-run/process proof can release the run marker; lane metadata alone never releases a worktree | Setup or persistence failure keeps the lane unknown; only the existing verified setup rollback may remove a newly created worktree | Recorded status is retained; a base/head mismatch is not repaired or inferred from render-time Git calls | Missing, malformed, or key-mismatched lane data; only one of `worktreePath`/`branch`; unverified process state |
|
|
389
|
+
| `handoffs/<run-id>.json` | Existing parallel handoff writer and cleanup engine | Group is `partial` with preserved cleanup tasks while pending/running; finalized groups contain child identity, patch, and cleanup evidence; cleanup is `partial` or `complete` | Only the existing cleanup engine's fresh Git checks and recorded task evidence can release a worktree/branch; #1621 adds no deletion path | Missing diff, failed capture, or cleanup error preserves the task and records the reason | `baseCommit` is retained as evidence; stale or changed heads remain unknown/preserved until an explicit later reconciliation | Missing/invalid manifest, mismatched run/key/task identity, duplicate identity, dirty or uncaptured work |
|
|
390
|
+
| `workflow-receipt.json` | Workflow terminal settlement | No receipt while `pending`/`running`; terminal receipt is finalized with one optional lane block per keyed child | Receipt publication is complete only after every included child entry is serialized; it does not authorize cleanup | Receipt write failure leaves status/handoff evidence authoritative and the workflow reports the missing receipt | Existing receipt is not backfilled or rewritten from a newer head | Invalid version/state, mismatched entry key or lane key, stale continuation lineage |
|
|
391
|
+
| `.active-runs` marker | Existing active-run index | `pending`/`running` while the runner is live; terminal marker remains until observed process proof | Marker removal requires the existing exact-run process-terminal proof | Unknown proof keeps the marker and lane retained for inspection | Marker state is not inferred from Git head or timestamps alone | Missing/unknown process proof, active marker, or foreign run identity |
|
|
392
|
+
|
|
393
|
+
Older runs without lane metadata remain readable and retain their existing
|
|
394
|
+
handoff/cleanup behavior. Missing lane, receipt, or handoff metadata is
|
|
395
|
+
unknown—not eligible for destructive cleanup.
|
|
396
|
+
|
|
397
|
+
For managed worktree launches, the runner writes the pending handoff and the
|
|
398
|
+
display-only status path/branch from the deterministic setup plan before the
|
|
399
|
+
first `git worktree add`. If setup then fails or is interrupted, that pending
|
|
400
|
+
ownership record remains preserved evidence; cleanup still rechecks the actual
|
|
401
|
+
worktree state before any removal.
|
|
258
402
|
|
|
259
403
|
## Supervisor coordination (child asks parent)
|
|
260
404
|
|
|
@@ -304,7 +448,7 @@ export PI_SUBAGENT_MAX_DEPTH=1
|
|
|
304
448
|
export PI_SUBAGENT_MAX_DEPTH=0
|
|
305
449
|
```
|
|
306
450
|
|
|
307
|
-
`
|
|
451
|
+
`PI_SUBAGENT_MAX_DEPTH` applies to the top-level parent; children inherit their limit through their runtime config, and their own depth is tracked there too.
|
|
308
452
|
|
|
309
453
|
## Prompt-template integration
|
|
310
454
|
|
package/index.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type {} from "./src/types/pi-runtime-compat.d.ts";
|
|
3
|
+
|
|
4
|
+
const registerParentExtension = process.env.PI_SUBAGENT_CHILD === "1"
|
|
5
|
+
? undefined
|
|
6
|
+
: (await import("./src/extension/index.ts")).default;
|
|
7
|
+
|
|
8
|
+
export default function registerSubagentExtension(pi: ExtensionAPI): void {
|
|
9
|
+
registerParentExtension?.(pi);
|
|
10
|
+
}
|
package/install.mjs
CHANGED
|
@@ -87,7 +87,7 @@ if (fs.existsSync(EXTENSION_DIR)) {
|
|
|
87
87
|
console.log(`
|
|
88
88
|
The extension is now available in pi. Tools added:
|
|
89
89
|
• subagent - Delegate tasks to agents and inspect run status
|
|
90
|
-
•
|
|
90
|
+
• bg_wait - Wait for background/provider/detached work without native completion notifications
|
|
91
91
|
|
|
92
92
|
Documentation: ${EXTENSION_DIR}/README.md
|
|
93
93
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xzzpig/pi-subagents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
|
|
5
5
|
"author": "Nico Bailon",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./agent-management": "./src/api/agent-management.ts",
|
|
18
18
|
"./control-channel": "./src/api/control-channel.ts",
|
|
19
19
|
"./intercom-bridge": "./src/api/intercom-bridge.ts",
|
|
20
|
-
"./
|
|
20
|
+
"./child-tool-plan": "./src/api/child-tool-plan.ts",
|
|
21
21
|
"./shared-types": "./src/api/shared-types.ts",
|
|
22
22
|
"./project-panes": "./src/api/project-panes.ts"
|
|
23
23
|
},
|
|
@@ -94,7 +94,9 @@
|
|
|
94
94
|
"@earendil-works/pi-agent-core": "0.84.2",
|
|
95
95
|
"@earendil-works/pi-ai": "0.84.2",
|
|
96
96
|
"@earendil-works/pi-tui": "0.84.2",
|
|
97
|
+
"@oxlint/plugins": "1.80.0",
|
|
97
98
|
"@types/node": "24.13.3",
|
|
99
|
+
"oxlint": "1.80.0",
|
|
98
100
|
"typescript": "5.9.3",
|
|
99
101
|
"@earendil-works/pi-coding-agent": "file:./test/fixtures/pi-coding-agent-shim"
|
|
100
102
|
},
|
|
@@ -107,9 +109,8 @@
|
|
|
107
109
|
"scripts": {
|
|
108
110
|
"typecheck": "tsc --noEmit",
|
|
109
111
|
"test": "npm run test:unit",
|
|
110
|
-
"test:unit": "node --experimental-strip-types --import ./test/support/isolated-temp-root.mjs --test test/unit/*.test.ts",
|
|
111
|
-
"test:integration": "node --experimental-strip-types --import ./test/support/register-loader.mjs --test test/integration/*.test.ts",
|
|
112
|
-
"test:
|
|
113
|
-
"test:all": "npm run test:unit && npm run test:integration && npm run test:e2e"
|
|
112
|
+
"test:unit": "env -u PI_SUBAGENT_PARENT_SESSION -u PI_SESSION_ID -u PI_SESSION_FILE -u PI_CODING_AGENT -u PI_PROVIDER -u PI_MODEL -u PI_REASONING_LEVEL node --experimental-strip-types --import ./test/support/isolated-temp-root.mjs --test test/unit/*.test.ts",
|
|
113
|
+
"test:integration": "env -u PI_SUBAGENT_PARENT_SESSION -u PI_SESSION_ID -u PI_SESSION_FILE -u PI_CODING_AGENT -u PI_PROVIDER -u PI_MODEL -u PI_REASONING_LEVEL node --experimental-strip-types --import ./test/support/register-loader.mjs --test test/integration/*.test.ts",
|
|
114
|
+
"test:all": "npm run test:unit && npm run test:integration"
|
|
114
115
|
}
|
|
115
116
|
}
|
package/prompts/council.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Run a bounded supervisor-mediated council of advisors and write a decision memo
|
|
3
|
-
argument-hint: "<question> [--advisors name
|
|
3
|
+
argument-hint: "<question> [--advisors name,name] [--max-passes 2|3] [--scope ...] [--non-goals ...]"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Run a bounded, supervisor-mediated council on this question. You, the parent
|
|
@@ -13,13 +13,14 @@ Before you orchestrate, read `skills/council-mode/SKILL.md` and
|
|
|
13
13
|
|
|
14
14
|
Parse the invocation yourself. The flags below are conventions, not runtime
|
|
15
15
|
options. Record a brief with the question, scope, non-goals, evidence targets,
|
|
16
|
-
roster,
|
|
17
|
-
the question is trivial or settled, answer directly instead
|
|
16
|
+
roster, known advisor context modes, and pass cap. Default `--max-passes` to 2.
|
|
17
|
+
Clamp it to 2 or 3. If the question is trivial or settled, answer directly instead
|
|
18
|
+
of convening a council.
|
|
18
19
|
|
|
19
20
|
## Roster
|
|
20
21
|
|
|
21
|
-
- If `--advisors` is given, use exactly those
|
|
22
|
-
unknown agent.
|
|
22
|
+
- If `--advisors` is given, use exactly those agent names. Fail clearly on an
|
|
23
|
+
unknown agent. Do not require or invent per-advisor role labels.
|
|
23
24
|
- Otherwise list agents with `subagent({ action: "list" })`, then prefer 2–3
|
|
24
25
|
executable names that start with `council-`.
|
|
25
26
|
- If fewer than two profiles are available, fill the roster with `oracle`, then
|
|
@@ -30,8 +31,19 @@ the question is trivial or settled, answer directly instead of convening a counc
|
|
|
30
31
|
- Use the normal single-oracle loop only when a requested roster or unavailable
|
|
31
32
|
builtins leaves fewer than two advisors. Label the memo as degraded mode.
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
Profiles provide the model, tools, context, and advisor stance. The council
|
|
35
|
+
question and scope provide the decision frame. If the user wants a specific lens,
|
|
36
|
+
they should put it in the question, scope, or profile definition. Keep the roster
|
|
37
|
+
at 2–3 and never exceed 4.
|
|
38
|
+
|
|
39
|
+
Package advisors such as Surf's `gpt-pro` are valid only when the package Pi
|
|
40
|
+
extension is installed and its external-job provider is registered. For Surf,
|
|
41
|
+
that means the `surf-cli` Pi extension has loaded and `surf-oracle` appears in
|
|
42
|
+
`subagent({ action: "list" })` or the advisor is explicitly requested in
|
|
43
|
+
`--advisors` after that install. Treat them as external-runner advisors: omit
|
|
44
|
+
child `async` for normal attached council results, do not pass `outputSchema`,
|
|
45
|
+
include any needed evidence in the prompt, and use the fresh fallback cross-exam
|
|
46
|
+
path if the run is not resumable.
|
|
35
47
|
|
|
36
48
|
## Run the protocol
|
|
37
49
|
|
|
@@ -28,7 +28,11 @@ Choose or adapt angles when the work calls for it:
|
|
|
28
28
|
|
|
29
29
|
Prefer three strong reviewers over many vague reviewers.
|
|
30
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.
|
|
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. Filter on evidence, not severity: a finding must be concrete, current, caused or made reachable by the target diff, and supported by source proof, a test or repro, or a contract contradiction. Label findings P0/P1/P2. P0 blocks merge. P1 should be fixed before release. P2 is report-only. End each review with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. If nothing qualifies, ask the reviewer to say exactly `No issues found.` 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
|
+
Do not default first-pass reviews to `blockers only`. That phrase is valid only for final pre-merge re-checks after P1/P2 findings are already inventoried, or for explicit emergency hotfix lanes where non-blocking findings are intentionally deferred.
|
|
34
|
+
|
|
35
|
+
For a targeted follow-up review, ask only whether the named finding was resolved, whether the fix introduced a new defect in the fix blast radius, and whether prior P1/P2 notes still stand. For bot or PR-comment triage, classify each comment as VALID, STALE, INVALID, or OUT-OF-POLICY against current HEAD, then assign P0/P1/P2 only to VALID comments.
|
|
32
36
|
|
|
33
37
|
While reviewers run, do your own narrow inspection if useful. After they return, synthesize the feedback into:
|
|
34
38
|
- fixes worth doing now
|
package/prompts/review-loop.md
CHANGED
|
@@ -6,32 +6,36 @@ Run a parent-orchestrated review loop for the requested work.
|
|
|
6
6
|
|
|
7
7
|
Use the `subagent` tool. Keep the parent session as the loop controller and final decision-maker. Child subagents must receive concrete role-specific tasks; they must not run subagents or manage the loop themselves unless the parent intentionally selected an explicit fanout agent whose builtin `tools` includes `subagent` for that assigned fanout.
|
|
8
8
|
|
|
9
|
-
Default to a maximum of 3 review rounds unless I specify a different cap. Count a review round each time fresh-context reviewers inspect the current diff after a worker pass. Stop early when reviewers find no
|
|
9
|
+
Default to a maximum of 3 review rounds unless I specify a different cap. Count a review round each time fresh-context reviewers inspect the current diff after a worker pass. Stop early when reviewers find no P0 findings, no P1 fixes worth doing now, and no approved P2 notes that should be handled in this loop.
|
|
10
10
|
|
|
11
11
|
If the invocation includes an implementation request, first launch one async `worker` to implement the approved scope. If the current diff is already the target, start with review. The sequence can be launched up front with `workflowScript` when it is already clear, or continued as follow-up single-agent runs after each async completion. For an initial workflowScript, pass `async: true` so the main chat is unblocked; do not set `clarify: true` unless I explicitly want the foreground clarify UI. Use only one writer against the active worktree at a time unless I explicitly ask for isolated worktrees.
|
|
12
12
|
|
|
13
|
-
As a conservative orchestration policy, do not set
|
|
13
|
+
As a conservative orchestration policy, do not set a hard `toolBudget` or tight `usageBudget` on implementation or fix workers. A default tool budget blocks read/search tools rather than mutation tools, and reported usage has no reservation model, so count or usage limits still do not measure delivery safety. Give each writer a narrow delivery slice and an outer elapsed deadline with enough margin. Before that deadline, request a checkpoint after the current tool returns with changed files, build/test state, remaining work, and commit or PR state. An elapsed timeout is not a mutation-safe boundary and must not be the checkpoint trigger.
|
|
14
14
|
|
|
15
15
|
For each review round, launch fresh-context `reviewer` agents in parallel. Reviewers must inspect the repository, relevant instructions, and current diff directly from files and commands. They must not rely on the main conversation history and must not edit files.
|
|
16
16
|
|
|
17
|
+
Tell reviewers to filter on evidence, not severity. They should report only concrete current issues caused or made reachable by the target diff, with source proof, a test or repro, or a contract contradiction. Ask them to label findings P0/P1/P2 and end with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. P0 blocks merge. P1 should be fixed before release. P2 is report-only. Use `blockers only` only for final pre-merge re-checks after P1/P2 findings are already captured, or for explicit emergency hotfix lanes.
|
|
18
|
+
|
|
17
19
|
Choose review angles from the actual change. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability. Add security, performance, docs/API contracts, or user-flow validation when the work calls for it. Prefer three strong reviewers over many vague reviewers.
|
|
18
20
|
|
|
19
21
|
After reviewers return, synthesize their feedback into:
|
|
20
|
-
- blockers or scope/product/architecture decisions that need user approval;
|
|
21
|
-
- fixes worth doing now;
|
|
22
|
-
- optional improvements;
|
|
22
|
+
- P0 blockers or scope/product/architecture decisions that need user approval;
|
|
23
|
+
- P1 fixes worth doing now;
|
|
24
|
+
- P2 report-only notes or optional improvements;
|
|
23
25
|
- feedback to ignore or defer, with a short reason.
|
|
24
26
|
|
|
25
27
|
Do not blindly apply every reviewer suggestion. If reviewers surface an unapproved product, scope, or architecture decision, pause and ask me before launching a fix worker.
|
|
26
28
|
|
|
27
29
|
When an async implementation worker completes, treat its handoff as the transition into review, not as final completion, unless I explicitly asked for worker-only work, review-only output, or to stop after implementation.
|
|
28
30
|
|
|
29
|
-
When there are fixes worth doing now and the workflow is implementation-authorized, launch one async forked `worker` without hard
|
|
31
|
+
When there are fixes worth doing now and the workflow is implementation-authorized, launch one async forked `worker` without hard tool-call caps to apply only those synthesized fixes. Ask it to preserve the approved scope, run focused validation, and report changed files, commands run with exit codes, validation evidence, surprises, and anything left undone.
|
|
30
32
|
|
|
31
33
|
After a fix worker returns, run another review round only when it made material changes or addressed non-trivial findings. Do not keep looping for optional polish, speculative improvements, or findings already deferred by the parent.
|
|
32
34
|
|
|
35
|
+
For a targeted follow-up review, ask only three questions: whether the named finding was resolved, whether the fix introduced a new concrete defect in the fix blast radius, and whether prior P1/P2 notes still stand. End with a fix verdict and the merge verdict.
|
|
36
|
+
|
|
33
37
|
Stop and summarize when one of these is true:
|
|
34
|
-
- reviewers find no blockers or fixes worth doing now;
|
|
38
|
+
- reviewers find no P0 blockers or P1 fixes worth doing now;
|
|
35
39
|
- remaining feedback is optional, speculative, or intentionally deferred;
|
|
36
40
|
- reviewers surface an unapproved decision that needs me;
|
|
37
41
|
- the max review-round cap is reached.
|