@pi-unipi/subagents 2.6.1 → 2.6.2

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.
Files changed (107) hide show
  1. package/README.md +89 -78
  2. package/agents/delegate.md +14 -0
  3. package/agents/oracle.md +78 -0
  4. package/agents/researcher.md +52 -0
  5. package/agents/reviewer.md +79 -0
  6. package/agents/scout.md +50 -0
  7. package/agents/worker.md +59 -0
  8. package/package.json +19 -17
  9. package/prompts/council.md +48 -0
  10. package/prompts/gather-context-and-clarify.md +13 -0
  11. package/prompts/parallel-cleanup.md +59 -0
  12. package/prompts/parallel-research.md +50 -0
  13. package/prompts/parallel-review.md +54 -0
  14. package/prompts/review-loop.md +43 -0
  15. package/skills/council-mode/SKILL.md +230 -0
  16. package/skills/subagents/SKILL.md +49 -0
  17. package/skills/subagents/references/constraints-and-recipes.md +259 -0
  18. package/skills/subagents/references/execution-controls.md +454 -0
  19. package/skills/subagents/references/management-authoring-rpc.md +161 -0
  20. package/skills/subagents/references/multi-lane-orchestration.md +39 -0
  21. package/skills/subagents/references/prompting-and-roles.md +267 -0
  22. package/src/acceptance.ts +331 -0
  23. package/src/agent-manager.ts +405 -0
  24. package/src/agent-memory.ts +300 -0
  25. package/src/agent-overrides.ts +183 -0
  26. package/src/agent-runner.ts +265 -0
  27. package/src/async-runner.ts +417 -0
  28. package/src/authority-policy.ts +47 -0
  29. package/src/budgets.ts +285 -0
  30. package/src/child-safety.ts +140 -0
  31. package/src/config.ts +226 -0
  32. package/src/conversation-viewer.ts +281 -0
  33. package/src/core-compat.ts +94 -0
  34. package/src/custom-agents.ts +323 -0
  35. package/src/file-system-retry.ts +50 -0
  36. package/src/fleet-data.ts +61 -0
  37. package/src/fleet-view.ts +316 -0
  38. package/src/foreground-detach.ts +59 -0
  39. package/src/fork-context.ts +285 -0
  40. package/src/global.d.ts +7 -0
  41. package/src/guide.ts +129 -0
  42. package/src/index.ts +1149 -0
  43. package/src/mission-state.ts +133 -0
  44. package/src/mission-store.ts +434 -0
  45. package/src/model-resolver.ts +79 -0
  46. package/src/output-limits.ts +142 -0
  47. package/src/parity-types.ts +315 -0
  48. package/src/pi-args.ts +161 -0
  49. package/src/pi-spawn.ts +147 -0
  50. package/src/result-files.ts +232 -0
  51. package/src/result-watcher.ts +221 -0
  52. package/src/retained-children.ts +176 -0
  53. package/src/run-fanout-budget.ts +356 -0
  54. package/src/scheduled-runs.ts +351 -0
  55. package/src/schemas.ts +263 -0
  56. package/src/slash-commands.ts +77 -0
  57. package/src/supervisor-channel.ts +249 -0
  58. package/src/tool-handler.ts +1144 -0
  59. package/src/types.ts +238 -0
  60. package/src/widget.ts +447 -0
  61. package/src/workflow-script.ts +737 -0
  62. package/src/workflow-worker.ts +384 -0
  63. package/src/worktree.ts +614 -0
  64. package/dist/agent-manager.d.ts +0 -81
  65. package/dist/agent-manager.d.ts.map +0 -1
  66. package/dist/agent-manager.js +0 -295
  67. package/dist/agent-manager.js.map +0 -1
  68. package/dist/agent-runner.d.ts +0 -51
  69. package/dist/agent-runner.d.ts.map +0 -1
  70. package/dist/agent-runner.js +0 -262
  71. package/dist/agent-runner.js.map +0 -1
  72. package/dist/config.d.ts +0 -24
  73. package/dist/config.d.ts.map +0 -1
  74. package/dist/config.js +0 -132
  75. package/dist/config.js.map +0 -1
  76. package/dist/conversation-viewer.d.ts +0 -40
  77. package/dist/conversation-viewer.d.ts.map +0 -1
  78. package/dist/conversation-viewer.js +0 -276
  79. package/dist/conversation-viewer.js.map +0 -1
  80. package/dist/core-compat.d.ts +0 -21
  81. package/dist/core-compat.d.ts.map +0 -1
  82. package/dist/core-compat.js +0 -86
  83. package/dist/core-compat.js.map +0 -1
  84. package/dist/custom-agents.d.ts +0 -14
  85. package/dist/custom-agents.d.ts.map +0 -1
  86. package/dist/custom-agents.js +0 -113
  87. package/dist/custom-agents.js.map +0 -1
  88. package/dist/file-lock.d.ts +0 -42
  89. package/dist/file-lock.d.ts.map +0 -1
  90. package/dist/file-lock.js +0 -91
  91. package/dist/file-lock.js.map +0 -1
  92. package/dist/index.d.ts +0 -10
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/index.js +0 -758
  95. package/dist/index.js.map +0 -1
  96. package/dist/model-resolver.d.ts +0 -19
  97. package/dist/model-resolver.d.ts.map +0 -1
  98. package/dist/model-resolver.js +0 -61
  99. package/dist/model-resolver.js.map +0 -1
  100. package/dist/types.d.ts +0 -98
  101. package/dist/types.d.ts.map +0 -1
  102. package/dist/types.js +0 -47
  103. package/dist/types.js.map +0 -1
  104. package/dist/widget.d.ts +0 -56
  105. package/dist/widget.d.ts.map +0 -1
  106. package/dist/widget.js +0 -396
  107. package/dist/widget.js.map +0 -1
@@ -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,59 @@
1
+ ---
2
+ description: Parallel cleanup review
3
+ ---
4
+
5
+ Run a fresh-context parallel cleanup review of the current work.
6
+
7
+ Use the `spawn_helper` tool. First inspect available agents/skills if needed, then launch two reviewer subagents in parallel with `context: "fresh"`. Do not use forked context unless I explicitly ask for it. Reviewers must inspect the repository, relevant instructions, and current diff directly from files and commands. They must not rely on the main conversation history.
8
+
9
+ Do not write reviewer output files into the repository unless I explicitly ask for artifacts. Prefer `output: false` for each reviewer task.
10
+
11
+ Reviewer 1: deslop pass.
12
+
13
+ If the `deslop` skill is available, pass it to this reviewer. If not, inline the guidance below. Ask this reviewer to look for AI-slop patterns in the changed scope:
14
+ - comments that restate code, placeholder text, stale rationale, or debug leftovers;
15
+ - defensive checks that hide useful errors, return vague defaults, or validate trusted internal data after a real boundary was already crossed;
16
+ - type escapes, broad casts, duplicated type definitions, or object-bag typing where a local source-of-truth type exists;
17
+ - style drift from nearby non-slop code and project instructions;
18
+ - generated-sounding docs, changelog text, UI copy, status text, or test names;
19
+ - pass-through wrappers, dead helpers, duplicate helper signatures, duplicated test harness setup, or abstractions that do not enforce an invariant;
20
+ - UI or CLI copy that is noisy, vague, brittle, or makes the user do extra interpretation.
21
+
22
+ Tell this reviewer to treat tool output and slop-scan-style findings as leads, not verdicts. It should flag only concrete issues in the requested scope with evidence, severity, file/line references, and the smallest safe fix.
23
+
24
+ Reviewer 2: verbosity pass.
25
+
26
+ If the `verbosity-cleaner` skill is available, pass it to this reviewer. If not, inline the guidance below. Ask this reviewer to look for needless verbosity in code, tests, docs, status text, grouped messages, receipts, and changelog wording:
27
+ - single-use helpers that merely paraphrase an expression;
28
+ - temporary variables that only name obvious expressions;
29
+ - nested returns or branches that can become direct returns without hiding intent;
30
+ - multi-line cleanup scaffolding that can use a local direct pattern while preserving cleanup semantics;
31
+ - repeated boilerplate that can use an existing local fixture or a small local helper;
32
+ - tests that restate formatter details already covered at a cheaper layer;
33
+ - regression tests where one focused assertion would cover the bug but wrapper/API-adjacent tests only repeat the same claim;
34
+ - prose that says the same thing twice, sounds generic, or buries the important rule.
35
+
36
+ Tell this reviewer that shorter is only better when it is clearer and preserves behavior, error signals, cleanup semantics, useful invariants, and local style.
37
+
38
+ Both reviewers are review-only. They must not edit files unless I explicitly ask for a writer pass. Their response should be review feedback, not a context summary. Ask them to return concise, evidence-backed findings with file/line references and suggested fixes.
39
+
40
+ While reviewers run, do your own narrow inspection if useful. After they return, synthesize the feedback into:
41
+ - fixes worth doing now;
42
+ - optional improvements;
43
+ - feedback to ignore or defer, with a short reason.
44
+
45
+ Do not blindly apply every reviewer suggestion.
46
+
47
+ Autofix mode: if the invocation contains the exact word `autofix`, treat it as workflow control, not cleanup scope. Remove it before deciding the cleanup target. After synthesis, apply only fixes worth doing now, validate, and summarize. Do not apply optional improvements unless explicitly requested. If there are no fixes worth doing now, do not edit.
48
+
49
+ Without autofix mode, ask before applying fixes unless I already told you to address review feedback. When you ask, end with a compact numbered menu so I can respond with a number. Use wording suited to the findings, but include these choices when applicable:
50
+
51
+ ```text
52
+ Reply with [1], [2], or further instructions:
53
+ [1] Apply only the fixes worth doing now.
54
+ [2] Apply the fixes worth doing now plus optional improvements.
55
+ ```
56
+
57
+ Additional scope or focus from the slash command invocation:
58
+
59
+ $@
@@ -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
+ $@
@@ -0,0 +1,54 @@
1
+ ---
2
+ description: Parallel subagents review
3
+ ---
4
+
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.
39
+
40
+ Autofix mode: if the invocation contains the exact word `autofix`, treat it as workflow control, not review scope. Remove it before deciding the review target. After synthesis, apply only fixes worth doing now, validate, and summarize. Do not apply optional improvements unless explicitly requested. If there are no fixes worth doing now, do not edit.
41
+
42
+ Without autofix mode, ask before applying fixes unless I already told you to address review feedback. When you ask, end with a compact numbered menu so I can respond with a number. Use wording suited to the findings, but include these choices when applicable:
43
+
44
+ ```text
45
+ Reply with [1], [2], or further instructions:
46
+ [1] Apply only the fixes worth doing now.
47
+ [2] Apply the fixes worth doing now plus optional improvements.
48
+ ```
49
+
50
+ Additional review target or focus from the slash command invocation:
51
+
52
+ $@
53
+
54
+ 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.
@@ -0,0 +1,43 @@
1
+ ---
2
+ description: Review/fix loop until clean
3
+ ---
4
+
5
+ Run a parent-orchestrated review loop for the requested work.
6
+
7
+ Use the `spawn_helper` 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
+
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 blockers or fixes worth doing now.
10
+
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
+
13
+ As a conservative orchestration policy, do not set `turnBudget`, a hard `toolBudget`, or a 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
+
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
+
17
+ 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
+
19
+ 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;
23
+ - feedback to ignore or defer, with a short reason.
24
+
25
+ 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
+
27
+ 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
+
29
+ When there are fixes worth doing now and the workflow is implementation-authorized, launch one async forked `worker` without hard turn or 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
+
31
+ 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
+
33
+ Stop and summarize when one of these is true:
34
+ - reviewers find no blockers or fixes worth doing now;
35
+ - remaining feedback is optional, speculative, or intentionally deferred;
36
+ - reviewers surface an unapproved decision that needs me;
37
+ - the max review-round cap is reached.
38
+
39
+ On completion, inspect the final diff yourself, run or confirm focused validation where appropriate, and summarize the loop: rounds run, fixes applied, validation, remaining deferred items, and why the loop stopped.
40
+
41
+ Additional target, implementation request, max-iteration cap, or review focus from the slash command invocation:
42
+
43
+ $@
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: council-mode
3
+ description: Run a bounded supervisor-mediated advisor council. Use when the user asks for council mode, asks to convene advisors, debate a decision, cross-examine recommendations, or run /council.
4
+ ---
5
+
6
+ # Council Mode
7
+
8
+ This skill is for the parent supervisor only. Do not inject it into advisors. The
9
+ parent selects the roster, curates all cross-advisor communication, decides which
10
+ feedback is valid, and writes the decision memo. Advisors do not talk directly or
11
+ see peer transcripts by default. This is not free-form agent chat.
12
+
13
+ Use council mode for a material decision with real tradeoffs. Do not use it for a
14
+ trivial or settled question, or for implementation work. Read
15
+ `skills/pi-subagents/references/execution-controls.md` before you launch advisors.
16
+
17
+ ## Roster and limits
18
+
19
+ Roles such as architect, skeptic, operator, and performance reviewer belong to the
20
+ `/council` request. A `council-*` profile defines only model, tools, context, and
21
+ output defaults. Its profile configuration or explicit invocation owns its context
22
+ choice.
23
+
24
+ Create model-based profiles in your user or project agent directory. Do not add
25
+ them to this package. This is a valid example; roles still come from `/council`:
26
+
27
+ ```markdown
28
+ ---
29
+ name: council-sol
30
+ description: Read-only fresh-context advisor for bounded council decisions
31
+ tools: read, grep, find, ls
32
+ model: openai-codex/gpt-5.6-sol
33
+ thinking: high
34
+ systemPromptMode: replace
35
+ inheritProjectContext: true
36
+ inheritSkills: false
37
+ defaultContext: fresh
38
+ acceptanceRole: read-only
39
+ ---
40
+
41
+ Analyze only the assigned council role. Inspect evidence directly. Do not edit,
42
+ run mutating commands, commit, push, contact peers, or spawn subagents. Return
43
+ concise, cited advice using the report contract in the council task.
44
+ ```
45
+
46
+ After `spawn_helper({ action: "list" })`, prefer 2–3 executable names that start with
47
+ `council-`. The prefix is a naming convention, not runtime selection. If fewer
48
+ than two profiles are available, fill the roster with `oracle`, then `reviewer`,
49
+ until it has two advisors. Launch fallback `oracle` with `context: "fork"` so
50
+ global defaults cannot remove its parent-chat context. Let fallback `reviewer`
51
+ use its normal profile context. Note the fallback and known context modes in the
52
+ memo. Use the normal single-oracle consultation loop only when a requested roster
53
+ or unavailable builtins leaves fewer than two advisors.
54
+ Label that result as degraded mode. Never use more than four advisors.
55
+
56
+ Pass 1 is independent reports. Pass 2 is one cross-exam. The default pass cap is
57
+ 2. Run pass 3 only when `--max-passes 3` was requested and a material dispute can
58
+ be settled by evidence an advisor can produce. Never run an unbounded loop.
59
+
60
+ ## Protocol
61
+
62
+ 1. The parent writes a brief with the question, scope, non-goals, evidence targets,
63
+ roster, roles, and pass cap.
64
+ 2. Before Pass 1, tell the user the roster, roles, requested or known context
65
+ modes, and pass cap. Use a stable key, `phase`, and concise `label` for every
66
+ workflow child. For example, use `advisor-oracle`, `phase: "Council pass 1"`,
67
+ and `label: "Oracle — intent and consistency"`.
68
+ 3. Launch one async `workflowScript` with `runs.all` for independent advisor
69
+ reports. Set `context` when the selected advisor has a known profile context or
70
+ a fallback rule requests one, because a global default can otherwise override
71
+ that profile. Set `context: "fork"` for fallback `oracle`. If no advisor context
72
+ is known, omit `context` and disclose the unknown runtime default in the memo.
73
+ Each advisor is read-only and must not spawn children, edit files, run mutating
74
+ commands, commit, or push. Set `output: false` unless separate advisor artifacts
75
+ are explicitly requested or useful for the decision.
76
+ 4. Return one aggregate Pass 1 receipt. After it completes, tell the user the
77
+ completion count, agreement count, dispute count, and whether Pass 2 is needed.
78
+ 5. The parent synthesizes a claim matrix in session. It contains agreements,
79
+ disputed claims, missing proof, owner decisions, and a relay set of at most five
80
+ high-impact claims per advisor. Do not delegate this synthesis.
81
+ 6. Before Pass 2, tell the user how many claims are relayed and why each is
82
+ material. Launch a second async `workflowScript` with `runs.all` resume calls.
83
+ Each task is a curated challenge packet, not a peer transcript. A resume requires
84
+ a retained run id and a non-empty task. It excludes `agent` and rejects `gate`.
85
+ Record the new run id from every resume. Pass 3 resumes those latest ids. Return
86
+ one aggregate Pass 2 receipt.
87
+ 7. After Pass 2, tell the user whether the council converged or which owner
88
+ decisions remain. The parent writes the final memo. Do not delegate it.
89
+
90
+ If an advisor is not resumable, run the same profile in fresh context with its own
91
+ pass-1 report and the challenge packet. Label that response as a fresh-context
92
+ fallback, not a true cross-exam.
93
+
94
+ Do not set `clarify`, `worktree`, `gate`, turn budgets, tool budgets, or tight usage
95
+ budgets on advisors. Bound work through the roster, pass cap, and report length.
96
+
97
+ ## Advisor contracts and pass receipts
98
+
99
+ Pass-1 reports are at most about 600 words. Give each advisor the same
100
+ `outputSchema`, so reports are comparable without heading cleanup. The following
101
+ shape is a contract template. Use the runtime schema syntax supported by the
102
+ workflow and keep narrative fields as strings:
103
+
104
+ ```js
105
+ const pass1OutputSchema = {
106
+ type: "object",
107
+ required: [
108
+ "recommendation", "evidence", "assumptions", "risks", "confidence",
109
+ "challengeClaims", "ownerDecisions", "changeMyMind"
110
+ ],
111
+ properties: {
112
+ recommendation: { type: "string" },
113
+ evidence: {
114
+ type: "array",
115
+ items: {
116
+ type: "object",
117
+ required: ["claim", "sources"],
118
+ properties: {
119
+ claim: { type: "string" },
120
+ sources: { type: "array", items: { type: "string" } }
121
+ }
122
+ }
123
+ },
124
+ assumptions: {
125
+ type: "array",
126
+ items: {
127
+ type: "object",
128
+ required: ["assumption", "status"],
129
+ properties: {
130
+ assumption: { type: "string" },
131
+ status: { enum: ["verified", "unverified"] }
132
+ }
133
+ }
134
+ },
135
+ risks: { type: "array", items: { type: "string" } },
136
+ confidence: {
137
+ type: "object",
138
+ required: ["level", "reason"],
139
+ properties: {
140
+ level: { enum: ["high", "medium", "low"] },
141
+ reason: { type: "string" }
142
+ }
143
+ },
144
+ challengeClaims: { type: "array", items: { type: "string" }, maxItems: 3 },
145
+ ownerDecisions: { type: "array", items: { type: "string" } },
146
+ changeMyMind: { type: "array", items: { type: "string" } }
147
+ }
148
+ };
149
+ ```
150
+
151
+ Include this contract in each Pass 1 task: inspect supplied evidence directly; do
152
+ not see or ask about other advisors; stay read-only; do not spawn children; return
153
+ only the structured report.
154
+
155
+ After `runs.all`, return one aggregate receipt rather than making the parent find
156
+ separate artifacts. Preserve the result order or map it by stable key so each row
157
+ contains the advisor identity and report:
158
+
159
+ ```js
160
+ return {
161
+ pass: 1,
162
+ advisors: results.map((result, index) => ({
163
+ key: result.key,
164
+ agent: result.agent,
165
+ role: roster[index].role,
166
+ requestedContext: roster[index].context ?? "runtime-default-unknown",
167
+ runId: result.runId,
168
+ report: result.structuredOutput
169
+ }))
170
+ };
171
+ ```
172
+
173
+ Do not replace `runtime-default-unknown` with a guessed context. It records that
174
+ the launch intentionally omitted context.
175
+
176
+ A challenge packet contains only disputed claims, strong conflicting evidence,
177
+ missing proof, owner decisions, and high-impact risks. Attribute peer content as
178
+ "another advisor". Do not include full peer reports. Use a common Pass 2 contract:
179
+
180
+ ```js
181
+ const pass2OutputSchema = {
182
+ type: "object",
183
+ required: ["responses", "recommendationChanged", "outOfScopeFindings"],
184
+ properties: {
185
+ responses: {
186
+ type: "array",
187
+ items: {
188
+ type: "object",
189
+ required: ["claimId", "disposition", "reason", "sources"],
190
+ properties: {
191
+ claimId: { type: "string" },
192
+ disposition: {
193
+ enum: ["accept", "reject", "refine", "owner-decision"]
194
+ },
195
+ reason: { type: "string" },
196
+ sources: { type: "array", items: { type: "string" } }
197
+ }
198
+ }
199
+ },
200
+ recommendationChanged: {
201
+ type: "object",
202
+ required: ["changed", "reason"],
203
+ properties: { changed: { type: "boolean" }, reason: { type: "string" } }
204
+ },
205
+ outOfScopeFindings: { type: "array", items: { type: "string" } }
206
+ }
207
+ };
208
+ ```
209
+
210
+ Use stable resume keys such as `cross-oracle`, `phase: "Council pass 2"`, concise
211
+ labels, and `output: false` unless separate artifacts are requested or useful. The
212
+ aggregate Pass 2 receipt uses the same row shape as Pass 1, with the new `runId`
213
+ and `structuredOutput`.
214
+
215
+ ## Stop and memo
216
+
217
+ Converged means no disputed claim remains that both materially affects the
218
+ recommendation and can plausibly be settled by evidence. Stop at convergence, the
219
+ pass cap, failed fallback, or user interruption. Put unresolved disputes in owner
220
+ decisions. Never add a round for polish or symmetry.
221
+
222
+ The parent memo states the question and scope, recommendation, rationale, accepted
223
+ and rejected feedback with reasons, owner decisions, evidence and run ids,
224
+ confidence, what would change the decision, and the roster, roles, passes,
225
+ fallbacks, and known advisor context modes. State that fallback `oracle` is
226
+ context-aware and forked.
227
+
228
+ Council mode is not agent-to-agent chat, a transcript dump, mutation authority,
229
+ auto-escalation to writer lanes, or a council UI. Escalate to a writer only after
230
+ the parent memo and only when the user explicitly requests it.
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: unipi-subagents
3
+ description: |
4
+ Delegate work to builtin or custom subagents with single-agent, parallel,
5
+ scripted-chaining, async, forked-context, and coordinated workflows. Use
6
+ for advisory review, implementation handoffs, and multi-step tasks where a
7
+ single agent should stay in control while other agents contribute context,
8
+ planning, or execution.
9
+ ---
10
+
11
+ # Pi Subagents
12
+
13
+ This skill is for the main parent orchestrator only. Do not inject or follow it inside spawned child subagents. The parent session owns delegation, orchestration, review fanout, and final fix-worker launches. Ordinary children should not run their own subagent workflows; the explicit exception is a delegated fanout child whose resolved builtin `tools` includes `subagent`, and that child may use `subagent` only for the fanout work the parent assigned.
14
+
15
+ Use this skill when the parent orchestrator needs one specialized child or composed orchestration. Use `workflowScript` for all execution, including one isolated child. Chaining is still supported, but it is code-driven: use `await runs.run(...)` for sequential steps, `runs.all([...])` for parallel fanout, and ordinary JavaScript for branching, retries, gate monitors, and aggregation. Keep workflow helpers portable: use plain helper functions or explicit Promise chains, not nested `async function` helpers, async arrows, or async methods. Do not use legacy top-level `chain` / `tasks` inputs or durable `.chain.md` execution. Scripted workflows normally start asynchronously unless config sets `asyncByDefault:false`; set `async:true` explicitly when async behavior matters. Pass `async:false` only when the parent must block until completion. Async mode still shows progress. Do not use `async:false` for final reviews, backlog gates, run-to-completion convenience, or because no other work is available.
16
+
17
+ Package-installed agents appear in `spawn_helper({ action: "list" })` with builtin, user, and project agents. If `surf-cli` is installed as a Pi package, the Surf browser extension is loaded, and Chrome is logged into a ChatGPT Pro account, Surf can expose `gpt-pro`: a read-only async advisor that reaches ChatGPT web through Surf Oracle. Check it with `spawn_helper({ action: "get", agent: "gpt-pro" })` and run it with `subagent({ agent: "gpt-pro", task: "Review this plan and identify release risks." })`.
18
+
19
+ ## How to use this router
20
+
21
+ Read the matching reference file before acting. Paths are relative to this `SKILL.md`; resolve them against `skills/subagents/` and load them with the read tool.
22
+
23
+ | Task | Read |
24
+ | --- | --- |
25
+ | Decide whether to delegate, choose agents, compare tool versus slash commands, apply prompt techniques, or understand builtin roles | `references/prompting-and-roles.md` |
26
+ | Use council mode, convene several advisors, debate a decision, cross-examine recommendations, critique or improve a plan with multiple model perspectives, or run `/council` | `../council-mode/SKILL.md` |
27
+ | Run one-child, scripted, async, scheduled, mission-backed, forked, watchdog, oracle, or intercom-coordinated workflows | `references/execution-controls.md` |
28
+ | Coordinate several independent tasks, worktrees, repositories, or writer lanes | `references/multi-lane-orchestration.md` |
29
+ | List/create/update/delete/eject/disable agents, inspect legacy chain records, edit agent files, use prompt-template integration, or expose extension RPC | `references/management-authoring-rpc.md` |
30
+ | Check safety constraints, best practices, standard workflows, or error handling | `references/constraints-and-recipes.md` |
31
+
32
+ For broad or uncertain requests, read more than one reference. For complex work, start with `references/prompting-and-roles.md` and `references/execution-controls.md`, then consult `references/constraints-and-recipes.md` before launching or reviewing child work.
33
+
34
+ ## Always-on constraints
35
+
36
+ - Keep the parent as orchestrator and final decision-maker.
37
+ - Before multiple mutation-capable lanes, record a lane board and each lane's isolation path.
38
+ - For plan, design, or architecture advice that asks for council mode, asks to convene several advisors, compare model perspectives, debate a decision, cross-examine recommendations, or critique and improve a plan, read `../council-mode/SKILL.md` and use Council Mode instead of ad hoc parallel oracle calls.
39
+ - For plan, design, or architecture advice that asks to consult, discuss with, or come to agreement with one `oracle`, use a short same-session consultation loop: read the first result, resume once with a targeted challenge when material tradeoffs remain, then synthesize the parent decision. Keep explicit one-shot, trivial, and fully settled consultations one-shot.
40
+ - Use one writer per cwd/worktree unless isolated worktrees are intentional.
41
+ - For cross-codebase work, record the target repo, explicit `cwd`, authority boundary, and expected output before launch. Do not assume the parent session cwd is the child repo.
42
+ - For parallel fanout, compare child prompts before launch. Do not send clone prompts with only issue numbers, titles, or broad file globs swapped; each child needs a lane-specific task, source seam, prior evidence, and decision that remains distinct without the item number. Launch that fanout as one async `workflowScript` with stable keys and aggregate output unless there is truly only one child.
43
+ - Prefer fresh-context review/validation fanout, then synthesize and apply fixes in the parent.
44
+ - Use async/background by default. Final reviews, gate checks, oracle checks, and backlog lanes stay async. Use `async:false` only when the parent must block until completion. Do not poll just to wait. For adaptive gates, branch in `workflowScript`.
45
+ - For Pi extension repos whose canonical checkout is under `~/.pi/agent/extensions`, never create lane worktrees as sibling directories there. Pi auto-loads `~/.pi/agent/extensions/*/index.ts`, so sibling worktrees can register duplicate tools. Put lanes under `~/.pi/agent/worktrees`, another worktree base outside auto-discovery, or a temporary clone. If a lane must run the modified extension itself, use an isolated Pi config home with `PI_CODING_AGENT_DIR=<lane-config> pi --no-extensions -e <lane>/index.ts`. Use full containers only when path and config isolation are insufficient.
46
+ - Preserve capability ceilings, including child tool restrictions and session-scoped allowed-agent restrictions.
47
+ - Escalate unresolved product, architecture, authority, release, merge, or safety decisions upward instead of letting a child decide silently.
48
+ - Treat receipts, CI, review bots, and external-run records as evidence, not authority to merge, close, comment, publish, or release.
49
+ - As a conservative orchestration policy, do not pass `turnBudget`, a hard `toolBudget`, or a tight `usageBudget` to mutation-capable workers. The default tool budget blocks read/search tools rather than mutation tools, and reported usage has no reservation model. If a worker is interrupted after a tool call starts, checkpoint after the current tool returns with changed files, build/test state, and commit or PR state.