@xzzpig/pi-subagents 0.1.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.
Files changed (196) hide show
  1. package/CHANGELOG.md +1621 -0
  2. package/LICENSE +21 -0
  3. package/README.md +118 -0
  4. package/agents/delegate.md +14 -0
  5. package/agents/oracle.md +74 -0
  6. package/agents/researcher.md +52 -0
  7. package/agents/reviewer.md +79 -0
  8. package/agents/scout.md +50 -0
  9. package/agents/worker.md +58 -0
  10. package/index.ts +1 -0
  11. package/inspector-runner.mjs +11 -0
  12. package/install.mjs +93 -0
  13. package/package.json +105 -0
  14. package/prompts/gather-context-and-clarify.md +13 -0
  15. package/prompts/parallel-cleanup.md +59 -0
  16. package/prompts/parallel-research.md +50 -0
  17. package/prompts/parallel-review.md +54 -0
  18. package/prompts/review-loop.md +43 -0
  19. package/skills/pi-subagents/SKILL.md +41 -0
  20. package/skills/pi-subagents/references/constraints-and-recipes.md +251 -0
  21. package/skills/pi-subagents/references/execution-controls.md +428 -0
  22. package/skills/pi-subagents/references/management-authoring-rpc.md +161 -0
  23. package/skills/pi-subagents/references/prompting-and-roles.md +242 -0
  24. package/src/agents/agent-management.ts +1256 -0
  25. package/src/agents/agent-memory.ts +254 -0
  26. package/src/agents/agent-refinements.ts +624 -0
  27. package/src/agents/agent-scope.ts +6 -0
  28. package/src/agents/agent-selection.ts +25 -0
  29. package/src/agents/agent-serializer.ts +163 -0
  30. package/src/agents/agents.ts +1889 -0
  31. package/src/agents/chain-serializer.ts +280 -0
  32. package/src/agents/frontmatter.ts +149 -0
  33. package/src/agents/identity.ts +30 -0
  34. package/src/agents/proactive-skills.ts +194 -0
  35. package/src/agents/skills.ts +761 -0
  36. package/src/api/background-work.ts +197 -0
  37. package/src/api/capability-ceiling.ts +17 -0
  38. package/src/api/control-channel.ts +4 -0
  39. package/src/api/delegation.ts +119 -0
  40. package/src/api/external-runs.ts +129 -0
  41. package/src/api/intercom-bridge.ts +3 -0
  42. package/src/api/pi-args.ts +5 -0
  43. package/src/api/preflight.ts +403 -0
  44. package/src/api/shared-types.ts +19 -0
  45. package/src/extension/config.ts +76 -0
  46. package/src/extension/control-notices.ts +58 -0
  47. package/src/extension/doctor.ts +230 -0
  48. package/src/extension/fanout-child.ts +201 -0
  49. package/src/extension/index.ts +805 -0
  50. package/src/extension/public-execution.ts +71 -0
  51. package/src/extension/rpc.ts +653 -0
  52. package/src/extension/schemas.ts +375 -0
  53. package/src/extension/steering-notices.ts +35 -0
  54. package/src/extension/tool-description.ts +164 -0
  55. package/src/inspectors/herdr/actions.ts +229 -0
  56. package/src/inspectors/herdr/client.ts +130 -0
  57. package/src/inspectors/herdr/inspector-runner.ts +141 -0
  58. package/src/inspectors/herdr/project-panes.ts +154 -0
  59. package/src/integrations/herdr-status.ts +330 -0
  60. package/src/intercom/intercom-bridge.ts +187 -0
  61. package/src/intercom/native-supervisor-channel.ts +715 -0
  62. package/src/intercom/result-intercom.ts +421 -0
  63. package/src/missions/actions.ts +410 -0
  64. package/src/missions/goal-driver.ts +162 -0
  65. package/src/missions/lifecycle.ts +346 -0
  66. package/src/missions/store.ts +507 -0
  67. package/src/missions/types.ts +157 -0
  68. package/src/missions/workflow-state.ts +250 -0
  69. package/src/policy/authority.ts +46 -0
  70. package/src/profiles/profiles.ts +661 -0
  71. package/src/runs/background/async-execution.ts +1574 -0
  72. package/src/runs/background/async-job-tracker.ts +511 -0
  73. package/src/runs/background/async-resume.ts +539 -0
  74. package/src/runs/background/async-status.ts +542 -0
  75. package/src/runs/background/auto-drain.ts +67 -0
  76. package/src/runs/background/chain-append.ts +328 -0
  77. package/src/runs/background/chain-root-attachment.ts +199 -0
  78. package/src/runs/background/completion-batcher.ts +168 -0
  79. package/src/runs/background/completion-dedupe.ts +54 -0
  80. package/src/runs/background/control-channel.ts +692 -0
  81. package/src/runs/background/fleet-view.ts +540 -0
  82. package/src/runs/background/notify.ts +332 -0
  83. package/src/runs/background/parallel-groups.ts +45 -0
  84. package/src/runs/background/process-terminal.ts +280 -0
  85. package/src/runs/background/result-watcher.ts +414 -0
  86. package/src/runs/background/retained-children.ts +68 -0
  87. package/src/runs/background/run-id-resolver.ts +167 -0
  88. package/src/runs/background/run-status.ts +504 -0
  89. package/src/runs/background/scheduled-runs.ts +753 -0
  90. package/src/runs/background/stale-run-reconciler.ts +396 -0
  91. package/src/runs/background/steering.ts +239 -0
  92. package/src/runs/background/subagent-runner.ts +4718 -0
  93. package/src/runs/background/subagent-wait.ts +661 -0
  94. package/src/runs/background/top-level-async.ts +14 -0
  95. package/src/runs/background/wait-completions.ts +112 -0
  96. package/src/runs/background/wait-config.ts +36 -0
  97. package/src/runs/background/wait-subscriptions.ts +253 -0
  98. package/src/runs/background/wait-tool.ts +34 -0
  99. package/src/runs/foreground/async-steering-action.ts +256 -0
  100. package/src/runs/foreground/async-stop-action.ts +65 -0
  101. package/src/runs/foreground/chain-clarify.ts +1354 -0
  102. package/src/runs/foreground/chain-execution.ts +1527 -0
  103. package/src/runs/foreground/execution.ts +1868 -0
  104. package/src/runs/foreground/foreground-control.ts +132 -0
  105. package/src/runs/foreground/subagent-executor.ts +5532 -0
  106. package/src/runs/shared/acceptance.ts +1365 -0
  107. package/src/runs/shared/agent-contract.ts +38 -0
  108. package/src/runs/shared/capability-ceiling.ts +209 -0
  109. package/src/runs/shared/chain-outputs.ts +118 -0
  110. package/src/runs/shared/child-protocol.ts +401 -0
  111. package/src/runs/shared/completion-guard.ts +95 -0
  112. package/src/runs/shared/context-mode.ts +44 -0
  113. package/src/runs/shared/dynamic-fanout.ts +297 -0
  114. package/src/runs/shared/external-cli-runner.ts +130 -0
  115. package/src/runs/shared/long-running-guard.ts +220 -0
  116. package/src/runs/shared/mcp-direct-tool-allowlist.ts +406 -0
  117. package/src/runs/shared/model-fallback.ts +336 -0
  118. package/src/runs/shared/model-scope.ts +128 -0
  119. package/src/runs/shared/nested-events.ts +1076 -0
  120. package/src/runs/shared/nested-path.ts +52 -0
  121. package/src/runs/shared/nested-render.ts +123 -0
  122. package/src/runs/shared/parallel-handoff.ts +238 -0
  123. package/src/runs/shared/parallel-utils.ts +256 -0
  124. package/src/runs/shared/permissions.ts +95 -0
  125. package/src/runs/shared/pi-args.ts +808 -0
  126. package/src/runs/shared/pi-spawn.ts +163 -0
  127. package/src/runs/shared/process-signal.ts +19 -0
  128. package/src/runs/shared/run-history.ts +181 -0
  129. package/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
  130. package/src/runs/shared/session-lease.ts +299 -0
  131. package/src/runs/shared/single-output.ts +235 -0
  132. package/src/runs/shared/spawn-budget.ts +128 -0
  133. package/src/runs/shared/structured-output.ts +182 -0
  134. package/src/runs/shared/subagent-control.ts +231 -0
  135. package/src/runs/shared/subagent-prompt-runtime.ts +588 -0
  136. package/src/runs/shared/subagent-startup-retry.ts +104 -0
  137. package/src/runs/shared/task-intent.ts +181 -0
  138. package/src/runs/shared/tool-availability.ts +83 -0
  139. package/src/runs/shared/tool-budget.ts +80 -0
  140. package/src/runs/shared/turn-budget.ts +98 -0
  141. package/src/runs/shared/usage-budget.ts +65 -0
  142. package/src/runs/shared/workflow-graph.ts +231 -0
  143. package/src/runs/shared/worktree.ts +759 -0
  144. package/src/shared/accessible-dir.ts +47 -0
  145. package/src/shared/artifacts.ts +285 -0
  146. package/src/shared/atomic-json.ts +61 -0
  147. package/src/shared/child-transcript.ts +264 -0
  148. package/src/shared/file-coalescer.ts +40 -0
  149. package/src/shared/file-system-retry.ts +47 -0
  150. package/src/shared/fork-context.ts +213 -0
  151. package/src/shared/formatters.ts +133 -0
  152. package/src/shared/jsonl-writer.ts +81 -0
  153. package/src/shared/launch-contract.ts +124 -0
  154. package/src/shared/model-info.ts +81 -0
  155. package/src/shared/post-exit-stdio-guard.ts +85 -0
  156. package/src/shared/session-identity.ts +10 -0
  157. package/src/shared/session-tokens.ts +44 -0
  158. package/src/shared/settings.ts +501 -0
  159. package/src/shared/status-format.ts +55 -0
  160. package/src/shared/types.ts +2069 -0
  161. package/src/shared/utils.ts +613 -0
  162. package/src/slash/delegation-adapters.ts +434 -0
  163. package/src/slash/delegation-json.ts +108 -0
  164. package/src/slash/delegation-request.ts +166 -0
  165. package/src/slash/prompt-template-bridge.ts +383 -0
  166. package/src/slash/prompt-workflows.ts +300 -0
  167. package/src/slash/selector.ts +147 -0
  168. package/src/slash/slash-bridge.ts +192 -0
  169. package/src/slash/slash-commands.ts +994 -0
  170. package/src/slash/slash-live-state.ts +296 -0
  171. package/src/slash/subagents-admin.ts +432 -0
  172. package/src/tui/fleet-status.ts +564 -0
  173. package/src/tui/fleet-transcript.ts +577 -0
  174. package/src/tui/fleet.ts +879 -0
  175. package/src/tui/render-helpers.ts +80 -0
  176. package/src/tui/render.ts +2029 -0
  177. package/src/types/pi-runtime-compat.d.ts +8 -0
  178. package/src/watchdog/change-signature.ts +220 -0
  179. package/src/watchdog/child-status.ts +205 -0
  180. package/src/watchdog/emission-guard.ts +123 -0
  181. package/src/watchdog/lsp-diagnostics.ts +537 -0
  182. package/src/watchdog/model-selection.ts +167 -0
  183. package/src/watchdog/permission-arbiter.ts +145 -0
  184. package/src/watchdog/register-child.ts +117 -0
  185. package/src/watchdog/register-main.ts +440 -0
  186. package/src/watchdog/render.ts +54 -0
  187. package/src/watchdog/review.ts +302 -0
  188. package/src/watchdog/runtime.ts +868 -0
  189. package/src/watchdog/scope.ts +62 -0
  190. package/src/watchdog/settings.ts +568 -0
  191. package/src/watchdog/tool-actions.ts +155 -0
  192. package/src/watchdog/turn-delta.ts +161 -0
  193. package/src/watchdog/types.ts +198 -0
  194. package/src/watchdog/warning-format.ts +73 -0
  195. package/src/workflows/chat-progress.ts +140 -0
  196. package/src/workflows/scripted-workflow.ts +506 -0
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "@xzzpig/pi-subagents",
3
+ "version": "0.1.0",
4
+ "description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
5
+ "author": "Nico Bailon",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": "./index.ts",
10
+ "./background-work": "./src/api/background-work.ts",
11
+ "./external-runs": "./src/api/external-runs.ts",
12
+ "./delegation": "./src/api/delegation.ts",
13
+ "./capability-ceiling": "./src/api/capability-ceiling.ts",
14
+ "./preflight": "./src/api/preflight.ts",
15
+ "./control-channel": "./src/api/control-channel.ts",
16
+ "./intercom-bridge": "./src/api/intercom-bridge.ts",
17
+ "./pi-args": "./src/api/pi-args.ts",
18
+ "./shared-types": "./src/api/shared-types.ts"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/nicobailon/pi-subagents.git"
23
+ },
24
+ "homepage": "https://github.com/nicobailon/pi-subagents#readme",
25
+ "bugs": {
26
+ "url": "https://github.com/nicobailon/pi-subagents/issues"
27
+ },
28
+ "keywords": [
29
+ "pi-package",
30
+ "pi",
31
+ "pi-coding-agent",
32
+ "subagents",
33
+ "ai",
34
+ "agents",
35
+ "cli"
36
+ ],
37
+ "bin": {
38
+ "pi-subagents": "install.mjs"
39
+ },
40
+ "files": [
41
+ "index.ts",
42
+ "src/**/*.ts",
43
+ "*.mjs",
44
+ "agents/",
45
+ "skills/**/*",
46
+ "prompts/**/*",
47
+ "README.md",
48
+ "CHANGELOG.md"
49
+ ],
50
+ "pi": {
51
+ "extensions": [
52
+ "./index.ts"
53
+ ],
54
+ "skills": [
55
+ "./skills"
56
+ ],
57
+ "prompts": [
58
+ "./prompts"
59
+ ]
60
+ },
61
+ "peerDependencies": {
62
+ "@earendil-works/pi-agent-core": "*",
63
+ "@earendil-works/pi-ai": ">=0.80.0",
64
+ "@earendil-works/pi-coding-agent": "*",
65
+ "@earendil-works/pi-tui": "*"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@earendil-works/pi-agent-core": {
69
+ "optional": true
70
+ },
71
+ "@earendil-works/pi-ai": {
72
+ "optional": true
73
+ },
74
+ "@earendil-works/pi-coding-agent": {
75
+ "optional": true
76
+ },
77
+ "@earendil-works/pi-tui": {
78
+ "optional": true
79
+ }
80
+ },
81
+ "dependencies": {
82
+ "jiti": "2.7.0",
83
+ "typebox": "1.1.38",
84
+ "yaml": "2.8.3"
85
+ },
86
+ "devDependencies": {
87
+ "@earendil-works/pi-agent-core": "0.83.0",
88
+ "@earendil-works/pi-ai": "0.83.0",
89
+ "@earendil-works/pi-tui": "0.83.0",
90
+ "@types/node": "24.13.3",
91
+ "typescript": "5.9.3",
92
+ "@earendil-works/pi-coding-agent": "file:./test/fixtures/pi-coding-agent-shim"
93
+ },
94
+ "publishConfig": {
95
+ "access": "public"
96
+ },
97
+ "scripts": {
98
+ "typecheck": "tsc --noEmit",
99
+ "test": "npm run test:unit",
100
+ "test:unit": "node --experimental-strip-types --test test/unit/*.test.ts",
101
+ "test:integration": "node --experimental-strip-types --import ./test/support/register-loader.mjs --test test/integration/*.test.ts",
102
+ "test:e2e": "node --experimental-strip-types --import ./test/support/register-loader.mjs --test test/e2e/*.test.ts",
103
+ "test:all": "npm run test:unit && npm run test:integration && npm run test:e2e"
104
+ }
105
+ }
@@ -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 `subagent` 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 `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
+
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,41 @@
1
+ ---
2
+ name: pi-subagents
3
+ description: |
4
+ Delegate work to builtin or custom subagents with single-agent, parallel,
5
+ scripted, compatibility-chain, 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. Use `return runs.run("main", { agent, task })` for one child and `runs.all([...])` for coordinated waves: sequence, parallelism, branching, retries, gate monitors, and aggregation. Scripted workflows start asynchronously by default; pass `async:false` only for a small foreground run.
16
+
17
+ ## How to use this router
18
+
19
+ Read the matching reference file before acting. Paths are relative to this `SKILL.md`; resolve them against `skills/pi-subagents/` and load them with the read tool.
20
+
21
+ | Task | Read |
22
+ | --- | --- |
23
+ | Decide whether to delegate, choose agents, compare tool versus slash commands, apply prompt techniques, or understand builtin roles | `references/prompting-and-roles.md` |
24
+ | Run one-child, scripted, async, scheduled, mission-backed, forked, watchdog, oracle, or intercom-coordinated workflows | `references/execution-controls.md` |
25
+ | List/create/update/delete/eject/disable agents or chains, edit agent files, use prompt-template integration, or expose extension RPC | `references/management-authoring-rpc.md` |
26
+ | Check safety constraints, best practices, standard workflows, or error handling | `references/constraints-and-recipes.md` |
27
+
28
+ 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.
29
+
30
+ ## Always-on constraints
31
+
32
+ - Keep the parent as orchestrator and final decision-maker.
33
+ - Use one writer per cwd/worktree unless isolated worktrees are intentional.
34
+ - 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.
35
+ - 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.
36
+ - Prefer fresh-context review/validation fanout, then synthesize and apply fixes in the parent.
37
+ - Use async/background by default when work can proceed independently; do not poll just to wait. For adaptive gates, branch in `workflowScript`. Approval controls remain available only for already-running durable legacy chains.
38
+ - Preserve capability ceilings, including child tool restrictions and session-scoped allowed-agent restrictions.
39
+ - Escalate unresolved product, architecture, authority, release, merge, or safety decisions upward instead of letting a child decide silently.
40
+ - Treat receipts, CI, review bots, and external-run records as evidence, not authority to merge, close, comment, publish, or release.
41
+ - 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.