@selesai/code 0.5.20 → 0.5.22

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 (302) hide show
  1. package/README.md +1 -1
  2. package/dist/core/agent-session-skill-block.test.d.ts +2 -0
  3. package/dist/core/agent-session-skill-block.test.d.ts.map +1 -0
  4. package/dist/core/agent-session-skill-block.test.js +20 -0
  5. package/dist/core/agent-session-skill-block.test.js.map +1 -0
  6. package/dist/core/agent-session.d.ts +7 -4
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +22 -12
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/skills.d.ts.map +1 -1
  11. package/dist/core/skills.js +1 -1
  12. package/dist/core/skills.js.map +1 -1
  13. package/dist/extensions/handoff-new.test.ts +8 -9
  14. package/dist/extensions/handoff-new.ts +6 -8
  15. package/dist/extensions/inline-skills.test.ts +96 -0
  16. package/dist/extensions/inline-skills.ts +92 -0
  17. package/dist/extensions/package.json +1 -0
  18. package/dist/extensions/pi-powerline-footer/tests/tps.test.ts +39 -0
  19. package/dist/extensions/pi-powerline-footer/tps.ts +172 -113
  20. package/dist/extensions/pi-subagents/CHANGELOG.md +1367 -0
  21. package/dist/extensions/pi-subagents/README.md +602 -220
  22. package/dist/extensions/pi-subagents/banner.png +0 -0
  23. package/dist/extensions/pi-subagents/index.ts +1 -0
  24. package/dist/extensions/pi-subagents/install.mjs +3 -3
  25. package/dist/extensions/pi-subagents/package-lock.json +3405 -0
  26. package/dist/extensions/pi-subagents/package.json +26 -14
  27. package/dist/extensions/pi-subagents/prompts/gather-context-and-clarify.md +1 -1
  28. package/dist/extensions/pi-subagents/prompts/parallel-cleanup.md +9 -9
  29. package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +3 -3
  30. package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +7 -7
  31. package/dist/extensions/pi-subagents/prompts/parallel-research.md +6 -6
  32. package/dist/extensions/pi-subagents/prompts/parallel-review.md +8 -8
  33. package/dist/extensions/pi-subagents/prompts/review-loop.md +13 -11
  34. package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +267 -176
  35. package/dist/extensions/pi-subagents/src/agents/agent-management.ts +89 -16
  36. package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +19 -0
  37. package/dist/extensions/pi-subagents/src/agents/agents.ts +218 -120
  38. package/dist/extensions/pi-subagents/src/agents/frontmatter.ts +67 -13
  39. package/dist/extensions/pi-subagents/src/agents/proactive-skills.ts +2 -2
  40. package/dist/extensions/pi-subagents/src/agents/skills.ts +25 -12
  41. package/dist/extensions/pi-subagents/src/api/background-work.ts +197 -0
  42. package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +17 -0
  43. package/dist/extensions/pi-subagents/src/api/delegation.ts +285 -0
  44. package/dist/extensions/pi-subagents/src/api/preflight.ts +399 -0
  45. package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +165 -0
  46. package/dist/extensions/pi-subagents/src/extension/config.ts +7 -1
  47. package/dist/extensions/pi-subagents/src/extension/doctor.ts +15 -0
  48. package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +3 -1
  49. package/dist/extensions/pi-subagents/src/extension/index.ts +113 -157
  50. package/dist/extensions/pi-subagents/src/extension/rpc.ts +41 -4
  51. package/dist/extensions/pi-subagents/src/extension/schemas.ts +45 -15
  52. package/dist/extensions/pi-subagents/src/extension/steering-notices.ts +35 -0
  53. package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -15
  54. package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +4 -3
  55. package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +225 -29
  56. package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +11 -0
  57. package/dist/extensions/pi-subagents/src/profiles/profiles.ts +8 -10
  58. package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +452 -62
  59. package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +60 -9
  60. package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +198 -52
  61. package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +119 -21
  62. package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +67 -0
  63. package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +2 -0
  64. package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +16 -8
  65. package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +6 -4
  66. package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +2 -11
  67. package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +260 -13
  68. package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +32 -6
  69. package/dist/extensions/pi-subagents/src/runs/background/notify.ts +171 -90
  70. package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +280 -0
  71. package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +149 -88
  72. package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +14 -2
  73. package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +33 -17
  74. package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +9 -1
  75. package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +38 -10
  76. package/dist/extensions/pi-subagents/src/runs/background/steering.ts +237 -0
  77. package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +1297 -307
  78. package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +610 -0
  79. package/dist/extensions/pi-subagents/src/runs/background/top-level-async.ts +2 -1
  80. package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +36 -0
  81. package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +26 -0
  82. package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +230 -0
  83. package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +22 -6
  84. package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +228 -140
  85. package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +452 -138
  86. package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +90 -0
  87. package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1001 -416
  88. package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +443 -132
  89. package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
  90. package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +178 -0
  91. package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +121 -0
  92. package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +41 -93
  93. package/dist/extensions/pi-subagents/src/runs/shared/context-mode.ts +44 -0
  94. package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +11 -9
  95. package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +4 -0
  96. package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +12 -6
  97. package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +36 -0
  98. package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +44 -7
  99. package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +4 -1
  100. package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +154 -0
  101. package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +18 -0
  102. package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +174 -54
  103. package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +38 -31
  104. package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +90 -5
  105. package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +299 -0
  106. package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +61 -6
  107. package/dist/extensions/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
  108. package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +112 -7
  109. package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +14 -6
  110. package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +149 -36
  111. package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +181 -0
  112. package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +83 -0
  113. package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +11 -5
  114. package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +50 -4
  115. package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +63 -14
  116. package/dist/extensions/pi-subagents/src/shared/accessible-dir.ts +25 -0
  117. package/dist/extensions/pi-subagents/src/shared/artifacts.ts +37 -7
  118. package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +18 -43
  119. package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +52 -0
  120. package/dist/extensions/pi-subagents/src/shared/env.ts +16 -0
  121. package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +47 -0
  122. package/dist/extensions/pi-subagents/src/shared/fork-context.ts +28 -3
  123. package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +123 -0
  124. package/dist/extensions/pi-subagents/src/shared/model-info.ts +8 -5
  125. package/dist/extensions/pi-subagents/src/shared/settings.ts +9 -1
  126. package/dist/extensions/pi-subagents/src/shared/status-format.ts +7 -1
  127. package/dist/extensions/pi-subagents/src/shared/types.ts +522 -51
  128. package/dist/extensions/pi-subagents/src/shared/utils.ts +59 -53
  129. package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +604 -0
  130. package/dist/extensions/pi-subagents/src/slash/delegation-json.ts +108 -0
  131. package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +249 -0
  132. package/dist/extensions/pi-subagents/src/slash/prompt-template-bridge.ts +353 -345
  133. package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +2 -2
  134. package/dist/extensions/pi-subagents/src/slash/selector.ts +147 -0
  135. package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +265 -23
  136. package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +2 -2
  137. package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +428 -0
  138. package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +362 -0
  139. package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +472 -0
  140. package/dist/extensions/pi-subagents/src/tui/fleet.ts +664 -0
  141. package/dist/extensions/pi-subagents/src/tui/render.ts +115 -31
  142. package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +220 -0
  143. package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +205 -0
  144. package/dist/extensions/pi-subagents/src/watchdog/emission-guard.ts +123 -0
  145. package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +532 -0
  146. package/dist/extensions/pi-subagents/src/watchdog/model-selection.ts +167 -0
  147. package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +117 -0
  148. package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +433 -0
  149. package/dist/extensions/pi-subagents/src/watchdog/render.ts +54 -0
  150. package/dist/extensions/pi-subagents/src/watchdog/review.ts +298 -0
  151. package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +714 -0
  152. package/dist/extensions/pi-subagents/src/watchdog/settings.ts +528 -0
  153. package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +155 -0
  154. package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +161 -0
  155. package/dist/extensions/pi-subagents/src/watchdog/types.ts +188 -0
  156. package/dist/extensions/pi-subagents/src/watchdog/warning-format.ts +73 -0
  157. package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +130 -2
  158. package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +439 -0
  159. package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1632 -61
  160. package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +54 -1
  161. package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +112 -0
  162. package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +98 -1
  163. package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +179 -9
  164. package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +16 -9
  165. package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +6 -5
  166. package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +589 -9
  167. package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +528 -21
  168. package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +227 -3
  169. package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +235 -7
  170. package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +27 -0
  171. package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +172 -2
  172. package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1502 -18
  173. package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +993 -4
  174. package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +27 -0
  175. package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +7 -1
  176. package/dist/extensions/pi-subagents/test/support/helpers.ts +32 -0
  177. package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +59 -2
  178. package/dist/extensions/pi-subagents/test/support/mock-pi.ts +32 -6
  179. package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +25 -24
  180. package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +59 -35
  181. package/dist/extensions/pi-subagents/test/support/session-lease-child.mjs +42 -0
  182. package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +703 -69
  183. package/dist/extensions/pi-subagents/test/unit/accessible-dir.test.ts +82 -0
  184. package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +15 -15
  185. package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +66 -66
  186. package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +478 -19
  187. package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +228 -7
  188. package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +1 -1
  189. package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +198 -78
  190. package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +15 -1
  191. package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +102 -7
  192. package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +439 -6
  193. package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +41 -1
  194. package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +79 -0
  195. package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +285 -0
  196. package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +84 -0
  197. package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +68 -0
  198. package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +326 -0
  199. package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +82 -0
  200. package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +46 -4
  201. package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +3 -1
  202. package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +9 -17
  203. package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +175 -3
  204. package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +10 -5
  205. package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +126 -6
  206. package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +219 -0
  207. package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +913 -0
  208. package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +13 -2
  209. package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -3
  210. package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +351 -0
  211. package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +280 -0
  212. package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +575 -0
  213. package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +65 -0
  214. package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +94 -1
  215. package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +23 -0
  216. package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +157 -0
  217. package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +367 -5
  218. package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +11 -0
  219. package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +36 -0
  220. package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +25 -3
  221. package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +1 -1
  222. package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +341 -10
  223. package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +16 -0
  224. package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +52 -0
  225. package/dist/extensions/pi-subagents/test/unit/notify.test.ts +168 -7
  226. package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +85 -7
  227. package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +175 -0
  228. package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +1 -1
  229. package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +243 -16
  230. package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +79 -36
  231. package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +174 -56
  232. package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +322 -0
  233. package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +204 -0
  234. package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +20 -12
  235. package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +117 -4
  236. package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +40 -7
  237. package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +48 -1
  238. package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +21 -3
  239. package/dist/extensions/pi-subagents/test/unit/selector.test.ts +57 -0
  240. package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +326 -0
  241. package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +101 -2
  242. package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +111 -1
  243. package/dist/extensions/pi-subagents/test/unit/spawn-budget.test.ts +124 -0
  244. package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +6 -4
  245. package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +7 -0
  246. package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +397 -0
  247. package/dist/extensions/pi-subagents/test/unit/steering-notices.test.ts +58 -0
  248. package/dist/extensions/pi-subagents/test/unit/steering.test.ts +173 -0
  249. package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +25 -4
  250. package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +390 -25
  251. package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +837 -0
  252. package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +86 -0
  253. package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +15 -0
  254. package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +47 -1
  255. package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +56 -10
  256. package/dist/extensions/pi-subagents/test/unit/watchdog-change-signature.test.ts +387 -0
  257. package/dist/extensions/pi-subagents/test/unit/watchdog-child-status.test.ts +110 -0
  258. package/dist/extensions/pi-subagents/test/unit/watchdog-emission-guard.test.ts +62 -0
  259. package/dist/extensions/pi-subagents/test/unit/watchdog-lsp-diagnostics.test.ts +144 -0
  260. package/dist/extensions/pi-subagents/test/unit/watchdog-model-selection.test.ts +121 -0
  261. package/dist/extensions/pi-subagents/test/unit/watchdog-render.test.ts +76 -0
  262. package/dist/extensions/pi-subagents/test/unit/watchdog-review.test.ts +327 -0
  263. package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +863 -0
  264. package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +290 -0
  265. package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +91 -0
  266. package/dist/extensions/pi-subagents/test/unit/watchdog-turn-delta.test.ts +130 -0
  267. package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +32 -4
  268. package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +5 -1
  269. package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +30 -0
  270. package/dist/extensions/question/batch.ts +103 -0
  271. package/dist/extensions/question/constants.ts +1 -1
  272. package/dist/extensions/question/dialog-adapter.ts +23 -1
  273. package/dist/extensions/question/helpers.ts +34 -78
  274. package/dist/extensions/question/index.ts +412 -419
  275. package/dist/extensions/question/package.json +2 -1
  276. package/dist/extensions/question/question-list.ts +21 -14
  277. package/dist/extensions/question/row-layout.ts +2 -2
  278. package/dist/extensions/question/schemas.ts +38 -39
  279. package/dist/extensions/question/selection-mode.ts +5 -7
  280. package/dist/extensions/question/tests/batch.test.ts +75 -0
  281. package/dist/extensions/question/tests/helpers.test.ts +31 -156
  282. package/dist/extensions/question/tests/question-list.test.ts +17 -3
  283. package/dist/extensions/question/tests/row-layout.test.ts +4 -4
  284. package/dist/extensions/question/tests/schemas.test.ts +30 -0
  285. package/dist/extensions/question/tests/ui-protocol.test.ts +23 -3
  286. package/dist/extensions/question/tests/wizard.test.ts +99 -0
  287. package/dist/extensions/question/tui-adapter.ts +2 -3
  288. package/dist/extensions/question/types.ts +75 -39
  289. package/dist/extensions/question/ui-protocol.ts +3 -3
  290. package/dist/extensions/workflow/adapter.ts +4 -76
  291. package/dist/index.d.ts +1 -1
  292. package/dist/index.d.ts.map +1 -1
  293. package/dist/index.js +1 -1
  294. package/dist/index.js.map +1 -1
  295. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  296. package/dist/modes/interactive/interactive-mode.js +10 -10
  297. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  298. package/dist/skills/batch-grill-me/SKILL.md +3 -1
  299. package/dist/skills/workflow-creation/SKILL.md +2 -2
  300. package/docs/skills.md +8 -0
  301. package/docs/workflows.md +4 -4
  302. package/package.json +1 -1
@@ -3,26 +3,31 @@ name: pi-subagents
3
3
  description: |
4
4
  Delegate work to builtin or custom subagents with single-agent, chain,
5
5
  parallel, async, forked-context, and intercom-coordinated workflows. Use
6
- for advisory review, implementation handoffs, and multi-step tasks where a
6
+ for commentatory review, implementation handoffs, and multi-step tasks where a
7
7
  single agent should stay in control while other agents contribute context,
8
8
  planning, or execution.
9
9
  ---
10
10
 
11
11
  # Pi Subagents
12
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; child subagents should receive concrete role-specific tasks. 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.
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-builder launches; child subagents should receive concrete role-specific tasks. Ordinary children should not run their own subagent workflows; the explicit exception is a builderd fanout child whose resolved builtin `tools` includes `subagent`, and that child may use `subagent` only for the fanout work the parent assigned.
14
14
 
15
15
  Use this skill when the parent orchestrator needs to launch a specialized subagent, compose multiple agents into a workflow, or create/edit agents and chains on demand.
16
16
 
17
+ ## Capability ceilings
18
+
19
+ Parent extensions may register a session-scoped, out-of-band ceiling through `pi-subagents/capability-ceiling`. Child tools are intersected with every active registration and inherited snapshot; `denyExtensions` removes ambient/provider extension loading while retaining package protocol runtime. Do not add a model-visible ceiling field or rely on role selection for enforcement. Restricted schedules are rejected until their ceiling can be persisted safely.
20
+
17
21
  ## When to Use
18
22
 
19
- - **Advisory review**: use fresh-context `reviewer` agents for adversarial code review, or fork to `oracle` when inherited decisions and drift matter
20
- - **Implementation handoff**: have `oracle` advise, then `worker` implement only after an approved direction
21
- - **Recon and planning**: use `scout` or `context-builder`, then `planner`
23
+ - **Complex work orchestration**: use Fable mode as the default parent-agent loop for complex work. Complex means the task has multiple moving parts, unclear acceptance, cross-cutting code, meaningful user-visible impact, expensive or irreversible validation, broad review surface, or the user asks for orchestration. Lightweight one-off delegation can stay lightweight.
24
+ - **Advisory review**: use fresh-context `commentator` agents for adversarial code review, or fork to `commentator` when inherited decisions and drift matter
25
+ - **Implementation handoff**: have `commentator` advise, then `builder` implement only after an approved direction
26
+ - **Recon and planning**: use `explorer` or `explorer`, then `architect`
22
27
  - **Parallel exploration**: run multiple non-conflicting tasks concurrently
23
28
  - **Regular skill specialists**: when discovery shows proactive skill subagent suggestions and the current work is broad enough, launch a small fresh-context fanout that asks one subagent per relevant regularly used skill to apply that skill's perspective to the task
24
- - **Long-running work**: launch async/background runs and inspect them later; use `timeoutMs` or `maxRuntimeMs` when a foreground or async run needs a hard max runtime, `turnBudget: { maxTurns, graceTurns }` for a soft assistant-turn budget, or `toolBudget: { soft?, hard, block? }` to nudge after a tool-call threshold and then block read/search tools so the child can finalize
25
- - **Subagent control**: watch needs-attention signals and soft-interrupt only when a delegated run is genuinely blocked
29
+ - **Long-running work**: launch async/background runs and inspect them later. For mutation-capable work, bound the delivery slice and elapsed runtime, then request checkpoints after active tool work returns. Reserve hard turn and tool-call caps for explicitly read-only children.
30
+ - **Subagent control**: watch needs-attention signals and soft-interrupt only when a builderd run is genuinely blocked
26
31
  - **Agent authoring**: create, update, or override agents and chains for a project
27
32
 
28
33
  ## Tool vs Slash Commands
@@ -34,19 +39,24 @@ Humans often use the slash-command layer instead:
34
39
  - `/chain` — launch a chain of steps
35
40
  - `/parallel` — launch top-level parallel tasks
36
41
  - `/run-chain` — launch a saved `.chain.md` or `.chain.json` workflow
42
+ - `/subagent-cost` — show parent plus child token usage and cost for the session
43
+ - `/subagents-fleet` — open the live, inspection-only foreground/async fleet; `Ctrl+Alt+F` opens it during an active foreground turn, `↑↓`/`jk` selects children, and `PgUp`/`PgDn` scrolls transcript detail
37
44
  - `/subagents-doctor` — diagnose setup, discovery, async paths, and intercom bridge state
45
+ - `/subagents-models [agent]` — show the live runtime-loaded builtin model mapping
46
+ - `/subagents-profiles`, `/subagents-load-profile`, `/subagents-refresh-provider-models`, `/subagents-generate-profiles`, `/subagents-check-profile` — manage model profiles and provider catalogs
47
+ - `/prompt-workflow` and `/chain-prompts` — run prompt templates through native subagent single/chain workflows
38
48
 
39
49
  Prefer the tool when you are writing agent logic. Prefer the slash commands when
40
50
  you are guiding a human through an interactive flow.
41
51
 
42
52
  Packaged prompt shortcuts are also available for repeatable workflows. Treat them as reusable orchestration recipes, not just human slash commands. When the user asks for one of these shapes, or when the workflow clearly fits, apply the same pattern directly with `subagent(...)` and other tools:
43
- - `/parallel-review` — fresh-context reviewers with distinct review angles, then synthesis
44
- - `/review-loop` — parent-orchestrated worker, fresh-reviewer, and fix-worker cycles until clean or capped
45
- - `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
46
- - `/parallel-context-build` — parallel `context-builder` passes that produce planning handoff context and meta-prompts
47
- - `/parallel-handoff-plan` — external-reference research plus local `context-builder` passes, followed by a synthesis handoff plan and implementation-ready meta-prompt
48
- - `/gather-context-and-clarify` — scout/research first, then ask the user clarifying questions with `interview`
49
- - `/parallel-cleanup` — two fresh-context reviewers (deslop + verbosity passes) for an adversarial cleanup review of the current diff
53
+ - `/parallel-review` — fresh-context commentators with distinct review angles, then synthesis
54
+ - `/review-loop` — parent-orchestrated builder, fresh-commentator, and fix-builder cycles until clean or capped
55
+ - `/parallel-research` — combine `researcher` and `explorer` for external evidence plus local code context
56
+ - `/parallel-context-build` — parallel `explorer` passes that produce planning handoff context and meta-prompts
57
+ - `/parallel-handoff-plan` — external-reference research plus local `explorer` passes, followed by a synthesis handoff plan and implementation-ready meta-prompt
58
+ - `/gather-context-and-clarify` — explorer/research first, then ask the user clarifying questions with `interview`
59
+ - `/parallel-cleanup` — two fresh-context commentators (deslop + verbosity passes) for an adversarial cleanup review of the current diff
50
60
 
51
61
  ## Applying Prompt Techniques Without Slash Commands
52
62
 
@@ -54,7 +64,7 @@ The prompt templates in `prompts/` encode workflows the parent agent can run on
54
64
 
55
65
  ### Parallel review technique
56
66
 
57
- Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. Launch fresh-context `reviewer` agents with distinct angles generated from the actual target. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability; adapt for TypeScript, UI, security, docs, or large structural changes. Reviewers should inspect files and diffs directly, return concise evidence-backed findings with file/line references, and avoid edits unless the user explicitly asks for a writer pass. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
67
+ Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. Launch fresh-context `commentator` agents with distinct angles generated from the actual target. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability; adapt for TypeScript, UI, security, docs, or large structural changes. Reviewers should inspect files and diffs directly, return concise evidence-backed findings with file/line references, and avoid edits unless the user explicitly asks for a writer pass. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
58
68
 
59
69
  ### Proactive skill-specialist technique
60
70
 
@@ -64,7 +74,7 @@ Default guardrails:
64
74
  - Keep the fanout small: usually one or two skill-specialist children, never more than the listed recommendations or configured cap.
65
75
  - Prefer `context: "fresh"` and include only the files, diff, plan, URL, or request details each child needs. Use forked context only when private/session history is essential and appropriate to share.
66
76
  - Use read-only agents for analysis/review unless implementation was explicitly requested; do not create several writers in the same worktree.
67
- - Skip proactive skill subagents for tiny questions, direct commands, highly private requests, or when the user asks not to delegate.
77
+ - Skip proactive skill subagents for tiny questions, direct commands, highly private requests, or when the user asks not to builder.
68
78
  - Make cost and concurrency visible by using an ordinary `subagent(...)` call rather than hidden/background automation.
69
79
 
70
80
  Example shape:
@@ -72,8 +82,8 @@ Example shape:
72
82
  ```typescript
73
83
  subagent({
74
84
  tasks: [
75
- { agent: "reviewer", task: "Apply the available 'deslop' skill to review the current diff for concrete cleanup findings only. Do not modify files.", skill: "deslop" },
76
- { agent: "reviewer", task: "Apply the available 'accessibility' skill to review the UI changes for concrete issues only. Do not modify files.", skill: "accessibility" }
85
+ { agent: "commentator", task: "Apply the available 'deslop' skill to review the current diff for concrete cleanup findings only. Do not modify files.", skill: "deslop" },
86
+ { agent: "commentator", task: "Apply the available 'accessibility' skill to review the UI changes for concrete issues only. Do not modify files.", skill: "accessibility" }
77
87
  ],
78
88
  context: "fresh",
79
89
  concurrency: 2
@@ -82,15 +92,17 @@ subagent({
82
92
 
83
93
  ### Review-loop technique
84
94
 
85
- Use this when the user wants implementation or current diff review to continue until reviewers stop finding fixes worth doing now. Keep the loop in the parent session: one async `worker` implements or fixes, fresh-context `reviewer` agents inspect the actual repo and diff, the parent synthesizes accepted fixes, and one async forked `worker` applies them. The parent can express the sequence up front as an async/background chain when the workflow is known, or continue with explicit follow-up subagent runs after each async completion. For an initial chain, pass `async: true` so the main chat is unblocked; do not set `clarify: true` unless the user explicitly wants the foreground clarify UI. Treat an async implementation worker handoff as an intermediate state, not final completion, unless the user explicitly asked for worker-only work, review-only output, or to stop after implementation. Stop when reviewers find no blockers or fixes worth doing now, remaining feedback is optional or deferred, an unapproved product/scope/architecture decision appears, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. Do not loop for optional polish, and do not let children launch subagents or decide the loop outcome.
95
+ Use this when the user wants implementation or current diff review to continue until commentators stop finding fixes worth doing now. Keep the loop in the parent session: one async `builder` implements or fixes, fresh-context `commentator` agents inspect the actual repo and diff, the parent synthesizes accepted fixes, and one async forked `builder` applies them. The parent can express the sequence up front as an async/background chain when the workflow is known, or continue with explicit follow-up subagent runs after each async completion. For an initial chain, pass `async: true` so the main chat is unblocked; do not set `clarify: true` unless the user explicitly wants the foreground clarify UI. Treat an async implementation builder handoff as an intermediate state, not final completion, unless the user explicitly asked for builder-only work, review-only output, or to stop after implementation. Stop when commentators find no blockers or fixes worth doing now, remaining feedback is optional or deferred, an unapproved product/scope/architecture decision appears, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. Do not loop for optional polish, and do not let children launch subagents or decide the loop outcome.
96
+
97
+ As a conservative orchestration policy, do not pass `turnBudget` or a hard `toolBudget` to an implementation builder, fix builder, commentator with edit authority, or other mutation-capable child. The default tool budget blocks read/search tools rather than mutation tools, but count limits still do not measure delivery safety. Use a narrow task plus an outer elapsed deadline with enough margin, then request a checkpoint after the current tool returns. The checkpoint should report 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 used as the checkpoint trigger.
86
98
 
87
99
  ### Parallel research technique
88
100
 
89
- Use this when the question needs both external evidence and local implications. Combine `researcher` for official docs, specs, ecosystem behavior, recent changes, benchmarks, and primary sources with `scout` for repository files, patterns, constraints, tests, and likely integration points. Give each child a distinct angle: external evidence, local code context, and practical tradeoffs. Ask for source links or file ranges, confidence level, gaps, and decision implications. Do not ask these children to edit unless implementation was explicitly requested.
101
+ Use this when the question needs both external evidence and local implications. Combine `researcher` for official docs, specs, ecosystem behavior, recent changes, benchmarks, and primary sources with `explorer` for repository files, patterns, constraints, tests, and likely integration points. Give each child a distinct angle: external evidence, local code context, and practical tradeoffs. Ask for source links or file ranges, confidence level, gaps, and decision implications. Do not ask these children to edit unless implementation was explicitly requested.
90
102
 
91
103
  ### Parallel context-build technique
92
104
 
93
- Use this before planning or implementation when a stronger handoff is needed. Run a chain with one parallel step of `context-builder` agents rather than top-level parallel tasks, so relative output files live under the temporary chain directory. Give every task a distinct output path such as `context-build/request-and-scope.md`, `context-build/codebase-and-patterns.md`, and `context-build/validation-and-risks.md`. Choose two or three builders: request/scope, codebase/patterns, and validation/risks. Each builder must read every relevant file needed to understand its slice, follow imports/callers/tests/docs/config, conduct tool-available web research when needed, and include a compact `meta-prompt` section. The parent synthesizes the outputs into important context, recommended next meta-prompt, open questions, assumptions, and artifact paths.
105
+ Use this before planning or implementation when a stronger handoff is needed. Run a chain with one parallel step of `explorer` agents rather than top-level parallel tasks, so relative output files live under the temporary chain directory. Give every task a distinct output path such as `context-build/request-and-scope.md`, `context-build/codebase-and-patterns.md`, and `context-build/validation-and-risks.md`. Choose two or three builders: request/scope, codebase/patterns, and validation/risks. Each builder must read every relevant file needed to understand its slice, follow imports/callers/tests/docs/config, conduct tool-available web research when needed, and include a compact `meta-prompt` section. The parent synthesizes the outputs into important context, recommended next meta-prompt, open questions, assumptions, and artifact paths.
94
106
 
95
107
  Example shape:
96
108
 
@@ -98,9 +110,9 @@ Example shape:
98
110
  subagent({
99
111
  chain: [{
100
112
  parallel: [
101
- { agent: "context-builder", task: "Build request/scope context for: ...", output: "context-build/request-and-scope.md" },
102
- { agent: "context-builder", task: "Build codebase/pattern context for: ...", output: "context-build/codebase-and-patterns.md" },
103
- { agent: "context-builder", task: "Build validation/risk context for: ...", output: "context-build/validation-and-risks.md" }
113
+ { agent: "explorer", task: "Build request/scope context for: ...", output: "context-build/request-and-scope.md" },
114
+ { agent: "explorer", task: "Build codebase/pattern context for: ...", output: "context-build/codebase-and-patterns.md" },
115
+ { agent: "explorer", task: "Build validation/risk context for: ...", output: "context-build/validation-and-risks.md" }
104
116
  ]
105
117
  }],
106
118
  context: "fresh"
@@ -109,7 +121,7 @@ subagent({
109
121
 
110
122
  ### Parallel handoff-plan technique
111
123
 
112
- Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context, such as “study this library behavior, inspect our codebase, then produce a worker prompt.” Run a chain with a first parallel group and a second synthesis `context-builder` step. The first group usually includes `researcher` for external projects/docs/prompt guidance and `context-builder` for local code context; add a second `context-builder` for implementation strategy only when the scope is large enough to benefit. Use distinct output paths under `handoff/`, then have the synthesis `context-builder` read those outputs and write `handoff/final-handoff-plan.md` with the recommended approach, likely files, constraints, non-goals, validation, risks, unresolved questions, and final compact implementation-ready meta-prompt.
124
+ Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context, such as “study this library behavior, inspect our codebase, then produce a builder prompt.” Run a chain with a first parallel group and a second synthesis `explorer` step. The first group usually includes `researcher` for external projects/docs/prompt guidance and `explorer` for local code context; add a second `explorer` for implementation strategy only when the scope is large enough to benefit. Use distinct output paths under `handoff/`, then have the synthesis `explorer` read those outputs and write `handoff/final-handoff-plan.md` with the recommended approach, likely files, constraints, non-goals, validation, risks, unresolved questions, and final compact implementation-ready meta-prompt.
113
125
 
114
126
  Example shape:
115
127
 
@@ -118,10 +130,10 @@ subagent({
118
130
  chain: [
119
131
  { parallel: [
120
132
  { agent: "researcher", task: "Research the external reference and transferable implementation ideas for: ...", output: "handoff/external-reference.md" },
121
- { agent: "context-builder", task: "Build local codebase context for: ...", output: "handoff/local-context.md" },
122
- { agent: "context-builder", task: "Compare evidence and propose implementation strategy for: ...", output: "handoff/implementation-strategy.md" }
133
+ { agent: "explorer", task: "Build local codebase context for: ...", output: "handoff/local-context.md" },
134
+ { agent: "explorer", task: "Compare evidence and propose implementation strategy for: ...", output: "handoff/implementation-strategy.md" }
123
135
  ] },
124
- { agent: "context-builder", task: "Read {previous} and synthesize the final handoff plan and implementation-ready meta-prompt.", output: "handoff/final-handoff-plan.md" }
136
+ { agent: "explorer", task: "Read {previous} and synthesize the final handoff plan and implementation-ready meta-prompt.", output: "handoff/final-handoff-plan.md" }
125
137
  ],
126
138
  context: "fresh"
127
139
  })
@@ -129,21 +141,21 @@ subagent({
129
141
 
130
142
  ### Gather-context-and-clarify technique
131
143
 
132
- Use this at the start of non-trivial work. Launch `scout` for local context and `researcher` only when external docs, recent sources, ecosystem context, or primary evidence would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
144
+ Use this at the start of non-trivial work. Launch `explorer` for local context and `researcher` only when external docs, recent sources, ecosystem context, or primary evidence would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
133
145
 
134
146
  ### Parallel cleanup technique
135
147
 
136
- Use this after implementation when the user wants cleanup review or when a final pass would reduce AI-slop. Launch two fresh-context `reviewer` tasks with `output: false` and `progress: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that reviewer; otherwise inline the criteria. Both reviewers are review-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. Phrase the constraint as “Do not modify project/source files; returning findings through the configured output artifact is allowed” when you use `output` or `outputMode: "file-only"`. The parent decides what to apply and asks before making changes unless cleanup was already authorized.
148
+ Use this after implementation when the user wants cleanup review or when a final pass would reduce AI-slop. Launch two fresh-context `commentator` tasks with `output: false` and `progress: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that commentator; otherwise inline the criteria. Both commentators are review-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. Phrase the constraint as “Do not modify project/source files; returning findings through the configured output artifact is allowed” when you use `output` or `outputMode: "file-only"`. The parent decides what to apply and asks before making changes unless cleanup was already authorized.
137
149
 
138
150
  ### Staged fix orchestration technique
139
151
 
140
- Use this when a broad diff has known reviewer findings across several items and the user wants the parent to “orchestrate subagents like a boss.” Keep the active worktree safe with a three-stage chain:
152
+ Use this when a broad diff has known commentator findings across several items and the user wants the parent to “orchestrate subagents like a boss.” Keep the active worktree safe with a three-stage chain:
141
153
 
142
- 1. A parallel read-only planning fanout, one planner/reviewer per issue cluster. Each child inspects the real diff and returns exact files, line refs, proposed fixes, and focused validation. They must not edit.
143
- 2. One writer worker. It receives the planner summaries through `{previous}`, the parent’s accepted scope, stop rules, and verification contract. It is the only child allowed to edit the active worktree.
144
- 3. A parallel read-only validation fanout. Validators inspect the worker diff from fresh context with distinct angles, report pass/fail, remaining blockers, and missing verification.
154
+ 1. A parallel read-only planning fanout, one architect/commentator per issue cluster. Each child inspects the real diff and returns exact files, line refs, proposed fixes, and focused validation. They must not edit.
155
+ 2. One writer builder. It receives the architect summaries through `{previous}`, the parent’s accepted scope, stop rules, and verification contract. It is the only child allowed to edit the active worktree.
156
+ 3. A parallel read-only validation fanout. Validators inspect the builder diff from fresh context with distinct angles, report pass/fail, remaining blockers, and missing verification.
145
157
 
146
- Prefer `async: true`, `context: "fresh"` for planners/validators, `outputMode: "file-only"` for large summaries, and per-stage output names that will not collide. Add `phase` and `label` to make async status readable, and use `as` plus `{outputs.name}` when a later step needs a specific earlier result instead of the whole `{previous}` blob. Use this pattern instead of launching several writer workers into a dirty worktree. Include non-blocking suggestions in the writer prompt only when they are small, safe, and do not expand product scope; otherwise record them as deferred.
158
+ Prefer `async: true`, `context: "fresh"` for architects/validators, `outputMode: "file-only"` for large summaries, and per-stage output names that will not collide. Add `phase` and `label` to make async status readable, and use `as` plus `{outputs.name}` when a later step needs a specific earlier result instead of the whole `{previous}` blob. Use this pattern instead of launching several writer builders into a dirty worktree. Include non-blocking suggestions in the writer prompt only when they are small, safe, and do not expand product scope; otherwise record them as deferred.
147
159
 
148
160
  When the first step can return a structured target list, prefer dynamic fanout instead of hand-authoring a static parallel group. Use `outputSchema` and `as` on the producer, then an `expand` step with `from: { output, path }`, an explicit `maxItems`, one `parallel` child template, and `collect.as`. Item templates may use `{item}` or a named item such as `{target.path}`. Do not use dynamic fanout for prose outputs, nested fanout, dynamic agent selection, reducers, `when` conditions, or arbitrary expressions; `.chain.md` does not support this syntax, so use direct JSON or a saved `.chain.json`.
149
161
 
@@ -155,14 +167,14 @@ subagent({
155
167
  context: "fresh",
156
168
  chain: [
157
169
  { parallel: [
158
- { agent: "reviewer", phase: "Planning", label: "Deploy docs", as: "deployPlan", task: "Plan fixes for deploy docs/workflow. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/deploy.md", outputMode: "file-only" },
159
- { agent: "reviewer", phase: "Planning", label: "Scheduler contract", as: "schedulerPlan", task: "Plan fixes for scheduler contract. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/scheduler.md", outputMode: "file-only" },
160
- { agent: "reviewer", phase: "Planning", label: "Sandbox/security", as: "sandboxPlan", task: "Plan fixes for sandbox/security. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/sandbox.md", outputMode: "file-only" }
170
+ { agent: "commentator", phase: "Planning", label: "Deploy docs", as: "deployPlan", task: "Plan fixes for deploy docs/workflow. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/deploy.md", outputMode: "file-only" },
171
+ { agent: "commentator", phase: "Planning", label: "Scheduler contract", as: "schedulerPlan", task: "Plan fixes for scheduler contract. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/scheduler.md", outputMode: "file-only" },
172
+ { agent: "commentator", phase: "Planning", label: "Sandbox/security", as: "sandboxPlan", task: "Plan fixes for sandbox/security. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/sandbox.md", outputMode: "file-only" }
161
173
  ], concurrency: 3 },
162
- { agent: "worker", phase: "Implementation", label: "Apply accepted fixes", as: "workerResult", task: "Apply only the accepted fixes from these planning summaries. You are the sole writer for the active worktree. Run focused validation and report changed files, commands, failures, and remaining issues.\n\nDeploy plan:\n{outputs.deployPlan}\n\nScheduler plan:\n{outputs.schedulerPlan}\n\nSandbox plan:\n{outputs.sandboxPlan}", output: "worker/fixes.md", outputMode: "file-only", progress: true },
174
+ { agent: "builder", phase: "Implementation", label: "Apply accepted fixes", as: "builderResult", task: "Apply only the accepted fixes from these planning summaries. You are the sole writer for the active worktree. Run focused validation and report changed files, commands, failures, and remaining issues.\n\nDeploy plan:\n{outputs.deployPlan}\n\nScheduler plan:\n{outputs.schedulerPlan}\n\nSandbox plan:\n{outputs.sandboxPlan}", output: "builder/fixes.md", outputMode: "file-only", progress: true },
163
175
  { parallel: [
164
- { agent: "reviewer", phase: "Validation", label: "Deploy/scheduler validation", task: "Validate the post-worker diff for deploy and scheduler fixes. Start from the worker result: {outputs.workerResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/deploy-scheduler.md", outputMode: "file-only" },
165
- { agent: "reviewer", phase: "Validation", label: "Sandbox validation", task: "Validate the post-worker diff for sandbox/security fixes. Start from the worker result: {outputs.workerResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/sandbox.md", outputMode: "file-only" }
176
+ { agent: "commentator", phase: "Validation", label: "Deploy/scheduler validation", task: "Validate the post-builder diff for deploy and scheduler fixes. Start from the builder result: {outputs.builderResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/deploy-scheduler.md", outputMode: "file-only" },
177
+ { agent: "commentator", phase: "Validation", label: "Sandbox validation", task: "Validate the post-builder diff for sandbox/security fixes. Start from the builder result: {outputs.builderResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/sandbox.md", outputMode: "file-only" }
166
178
  ], concurrency: 2 }
167
179
  ]
168
180
  })
@@ -175,26 +187,39 @@ and user/project agents override builtins with the same name.
175
187
 
176
188
  | Agent | Purpose | Model | Typical output / role |
177
189
  |-------|---------|-------|------------------------|
178
- | `scout` | Fast codebase recon | inherits default | Writes `context.md` handoff material |
179
- | `planner` | Creates implementation plans | inherits default | Writes `plan.md` |
180
- | `worker` | Implementation and approved oracle handoffs | inherits default | Single-writer implementation with decision escalation |
181
- | `reviewer` | Review-and-fix specialist | inherits default | Can edit/fix reviewed code |
182
- | `context-builder` | Requirements/codebase handoff builder | inherits default | Writes structured context files |
190
+ | `explorer` | Fast codebase recon | inherits default | Writes `context.md` handoff material |
191
+ | `architect` | Creates implementation plans | inherits default | Writes `plan.md` |
192
+ | `builder` | Implementation and approved commentator handoffs | inherits default | Single-writer implementation with decision escalation |
193
+ | `commentator` | Review-and-fix specialist | inherits default | Can edit/fix reviewed code |
194
+ | `explorer` | Requirements/codebase handoff builder | inherits default | Writes structured context files |
183
195
  | `researcher` | Web research brief generator | inherits default | Writes `research.md` |
184
- | `delegate` | Lightweight generic delegate | inherits default | No fixed output; generic delegated work |
185
- | `oracle` | Decision-consistency advisory review | inherits default | Advisory review, intercom coordination |
196
+ | `builder` | Lightweight generic builder | inherits default | No fixed output; generic builderd work |
197
+ | `commentator` | Decision-consistency commentatory review | inherits default | Advisory review, intercom coordination |
198
+ | `commentator` | Claude Code-compatible alias for `commentator` | inherits default | Same commentatory role as `commentator` |
199
+
200
+ Builtin agents inherit the current Pi default model unless a run, user setting, project setting, or `subagents.defaultModel` overrides `model`. Set `subagents.defaultModel` when subagents should use a different default model than the parent session. Override builtin defaults before copying full agent files when a small tweak is enough.
186
201
 
187
- Builtin agents inherit the current Pi default model unless a run, user setting, or project setting overrides `model`. Override builtin defaults before copying full agent files when a small tweak is enough.
202
+ Set `subagents.defaultThinking` to apply a shared thinking level to builtin, package, user, and project agents whose frontmatter leaves `thinking` unset. Project settings win over user settings; explicit frontmatter (including `thinking: false`), `agentOverrides.<name>.thinking`, and per-run overrides remain more specific. This setting affects child agents only and does not change the parent session's default thinking level.
203
+
204
+ ```json
205
+ {
206
+ "subagents": {
207
+ "defaultThinking": "medium"
208
+ }
209
+ }
210
+ ```
188
211
 
189
212
  For one run, use inline config:
190
213
 
191
214
  ```text
192
- /run reviewer[model=anthropic/claude-sonnet-4] "Review this diff"
215
+ /run commentator[model=anthropic/claude-sonnet-4] "Review this diff"
193
216
  ```
194
217
 
195
- For persistent tweaks, edit `subagents.agentOverrides` in user or project settings. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides.
218
+ For persistent tweaks, edit `subagents.agentOverrides` in user or project settings. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides. Use `/subagents-models` or `subagent({ action: "models" })` to inspect the live mapping after settings and overrides load.
219
+
220
+ Model ids do not have to be exact. Separator variations (`claude-haiku-4.5` vs `claude-haiku-4-5`), case (`Claude-Sonnet-4`), and optional trailing date stamps (`claude-haiku-4-5-20251001`) all resolve to the same registry model. Exact `provider/id` wins; a qualified `provider/model` never switches providers. To constrain subagents to a budget or compliance profile, set `subagents.modelScope: { enforce: true, allow: ["anthropic/*", "openai/gpt-5-*"] }` in user or project settings. Out-of-scope models you pass explicitly error and abort; models inherited from frontmatter, `subagents.defaultModel`, agent frontmatter, or the parent session only warn.
196
221
 
197
- Model ids do not have to be exact. Separator variations (`claude-haiku-4.5` vs `claude-haiku-4-5`), case (`Claude-Sonnet-4`), and optional trailing date stamps (`claude-haiku-4-5-20251001`) all resolve to the same registry model. Exact `provider/id` wins; a qualified `provider/model` never switches providers. To constrain subagents to a budget or compliance profile, set `subagents.modelScope: { enforce: true, allow: ["anthropic/*", "openai/gpt-5-*"] }` in user or project settings. Out-of-scope models you pass explicitly error and abort; models inherited from frontmatter, `defaultModel`, or the parent session only warn.
222
+ For model fleets, use the profile commands instead of hand-editing repeated overrides: `/subagents-refresh-provider-models <provider>`, `/subagents-generate-profiles <provider>`, `/subagents-load-profile <name>`, and `/subagents-check-profile <name>`. Profiles live under `~/.selesai/agent/profiles/pi-subagents/` and replace only `settings.subagents` when loaded.
198
223
 
199
224
  ## Prompting role subagents
200
225
 
@@ -209,13 +234,13 @@ A strong subagent prompt usually includes:
209
234
  - **Output**: the expected summary shape, artifact path, or finding format.
210
235
  - **Stop rules**: when to ask via `intercom`, when to stop after enough evidence, and when not to keep searching.
211
236
 
212
- Avoid carrying over old prompt habits that over-specify every step. Use `must`, `always`, and `never` for real invariants; for judgment calls, give decision rules. For example, tell a reviewer to inspect the staged diff directly and report only evidence-backed findings, rather than prescribing every file or command. Tell a researcher the retrieval budget: start with broad targeted searches, fetch only the strongest sources, search again only when a required fact is missing, then stop.
237
+ Avoid carrying over old prompt habits that over-specify every step. Use `must`, `always`, and `never` for real invariants; for judgment calls, give decision rules. For example, tell a commentator to inspect the staged diff directly and report only evidence-backed findings, rather than prescribing every file or command. Tell a researcher the retrieval budget: start with broad targeted searches, fetch only the strongest sources, search again only when a required fact is missing, then stop.
213
238
 
214
239
  For implementation handoffs, name the approved scope and success criteria more clearly than the process. Good prompts say what to change, what not to change, where the evidence lives, how to validate, and when to escalate. They should not ask the child to create another subagent plan or continue the parent conversation.
215
240
 
216
241
  Settings locations:
217
- - User scope: `~/.pi/agent/settings.json`
218
- - Project scope: `.pi/settings.json`
242
+ - User scope: `~/.selesai/agent/settings.json`
243
+ - Project scope: `.selesai/settings.json`
219
244
 
220
245
  Direct settings example:
221
246
 
@@ -223,10 +248,11 @@ Direct settings example:
223
248
  {
224
249
  "subagents": {
225
250
  "agentOverrides": {
226
- "reviewer": {
251
+ "commentator": {
227
252
  "model": "anthropic/claude-sonnet-4",
228
253
  "thinking": "high",
229
- "fallbackModels": ["openai/gpt-5-mini"]
254
+ "fallbackModels": ["openai/gpt-5-mini"],
255
+ "acceptanceRole": "read-only"
230
256
  }
231
257
  }
232
258
  }
@@ -235,28 +261,31 @@ Direct settings example:
235
261
 
236
262
  Useful override fields: `model`, `fallbackModels`, `thinking`,
237
263
  `systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `defaultContext`,
238
- `disabled`, `skills`, `tools`, and `systemPrompt`. Create a user or project
264
+ `acceptanceRole`, `disabled`, `skills`, `tools`, `extensions`, and `systemPrompt`.
265
+ Use `acceptanceRole: false` to clear an override. Create a user or project
239
266
  agent with the same name only when you want a substantially different agent.
240
267
 
241
268
  If a provider rejects model IDs with thinking suffixes, use
242
269
  `subagents.disableThinking: true` in user or project settings to clear bundled
243
270
  builtin thinking defaults globally. A higher-precedence per-agent `thinking`
244
- override can opt one builtin back in.
271
+ override can opt one builtin back in. Existing custom-agent frontmatter remains authoritative.
245
272
 
246
- Tool description modes live in `~/.pi/agent/extensions/subagent/config.json`, not `subagents` settings. Set `toolDescriptionMode` to `compact` to reduce tool-description prompt cost while keeping the execution, async/wait, child-safety, one-writer, management/action, and artifact/status guardrails. Set it to `custom` to read `subagent-tool-description.md` from the project config dir or agent dir; invalid custom files fall back to full mode and the safety guidance is still appended.
273
+ Set `subagents.defaultExtensions` to give agents without an `extensions` field a shared child extension allowlist. Omit it to preserve ambient extension discovery, set it to `[]` to disable ambient extensions by default, or use `agentOverrides.<name>.extensions` for one agent. Explicit custom-agent frontmatter still wins.
274
+
275
+ Tool description modes live in `~/.selesai/agent/extensions/subagent/config.json`, not `subagents` settings. Set `toolDescriptionMode` to `compact` to reduce tool-description prompt cost while keeping the execution, async/`subagent_wait`, child-safety, one-writer, management/action, and artifact/status guardrails. Set it to `custom` to read `subagent-tool-description.md` from the project config dir or agent dir; invalid custom files fall back to full mode and the safety guidance is still appended.
247
276
 
248
277
  ## Discovery and Scope Rules
249
278
 
250
279
  Agent files can live in:
251
- - `~/.pi/agent/agents/**/*.md` — user scope
252
- - `.pi/agents/**/*.md` — canonical project scope
253
- - legacy `.agents/**/*.md` — still read for compatibility, but `.pi/agents/` wins on conflicts
280
+ - `~/.selesai/agent/agents/**/*.md` — user scope
281
+ - `.selesai/agents/**/*.md` — canonical project scope
282
+ - legacy `.agents/**/*.md` — still read for compatibility, but `.selesai/agents/` wins on conflicts
254
283
 
255
284
  Chains live in:
256
- - `~/.pi/agent/chains/**/*.chain.md` and `~/.pi/agent/chains/**/*.chain.json` — user scope
257
- - `.pi/chains/**/*.chain.md` and `.pi/chains/**/*.chain.json` — project scope
285
+ - `~/.selesai/agent/chains/**/*.chain.md` and `~/.selesai/agent/chains/**/*.chain.json` — user scope
286
+ - `.selesai/chains/**/*.chain.md` and `.selesai/chains/**/*.chain.json` — project scope
258
287
 
259
- Discovery is recursive. `.chain.md` files do not define agents. Use `.chain.md` for simple saved chains and `.chain.json` for dynamic fanout or inline schema objects. Agents and chains can set optional frontmatter/package metadata; `name: scout` plus `package: code-analysis` registers as runtime name `code-analysis.scout` while serialization keeps `name` and `package` separate.
288
+ Discovery is recursive. `.chain.md` files do not define agents. Use `.chain.md` for simple saved chains and `.chain.json` for dynamic fanout or inline schema objects. Agents and chains can set optional frontmatter/package metadata; `name: explorer` plus `package: code-analysis` registers as runtime name `code-analysis.explorer` while serialization keeps `name` and `package` separate.
260
289
 
261
290
  Precedence is by parsed runtime name:
262
291
  1. project scope
@@ -269,7 +298,7 @@ Precedence is by parsed runtime name:
269
298
 
270
299
  ```typescript
271
300
  subagent({
272
- agent: "oracle",
301
+ agent: "commentator",
273
302
  task: "Review my current direction and challenge assumptions."
274
303
  })
275
304
  ```
@@ -278,8 +307,9 @@ subagent({
278
307
 
279
308
  ```typescript
280
309
  subagent({
281
- agent: "oracle",
282
- task: "Review my current direction and challenge assumptions."
310
+ agent: "commentator",
311
+ task: "Review my current direction and challenge assumptions.",
312
+ context: "fork"
283
313
  })
284
314
  ```
285
315
 
@@ -293,8 +323,8 @@ or execution thread that can still reference the parent session history.
293
323
  ```typescript
294
324
  subagent({
295
325
  tasks: [
296
- { agent: "scout", task: "Explore the auth module" },
297
- { agent: "reviewer", task: "Review the API client" }
326
+ { agent: "explorer", task: "Explore the auth module" },
327
+ { agent: "commentator", task: "Review the API client" }
298
328
  ]
299
329
  })
300
330
  ```
@@ -304,24 +334,24 @@ Top-level parallel tasks can override per-task behavior:
304
334
  ```typescript
305
335
  subagent({
306
336
  tasks: [
307
- { agent: "scout", task: "Map auth", output: "auth-context.md", progress: true },
337
+ { agent: "explorer", task: "Map auth", output: "auth-context.md", progress: true },
308
338
  { agent: "researcher", task: "Research OAuth best practices", output: "oauth-research.md" },
309
- { agent: "reviewer", task: "Review auth tests", model: "anthropic/claude-sonnet-4" }
339
+ { agent: "commentator", task: "Review auth tests", model: "anthropic/claude-sonnet-4" }
310
340
  ],
311
341
  concurrency: 3
312
342
  })
313
343
  ```
314
344
 
315
- Avoid duplicate output paths in parallel tasks. Concurrent children should not write to the same file. For large saved outputs, set `outputMode: "file-only"` together with an `output` path. The parent result then contains only a compact reference like `Output saved to: /abs/report.md (48.2 KB, 2847 lines). Read this file if needed.` instead of the full saved content. Do not use `output: false` for this; `output: false` means no file output. When a task is review-only, say “do not modify project/source files” rather than “do not write files” if you also configured `output`; otherwise the child may treat the output artifact as forbidden. Failed runs and save errors still return inline details for debugging.
345
+ Avoid duplicate output paths in parallel tasks. Concurrent children should not write to the same file. For large saved outputs, set `outputMode: "file-only"` together with an `output` path. The parent result then contains only a compact reference like `Output saved to: /abs/report.md (48.2 KB, 2847 lines). Read this file if needed.` instead of the full saved content. Do not use `output: false` for this; `output: false` means no file output. In chains, relative `output` paths are chain-artifact paths under `{chain_dir}`, not project CWD paths; use an absolute `output` path or a persistent `chainDir` when a saved artifact must outlive the temp chain directory. Read-only children return the complete artifact in their final response and the runtime persists it, so missing write tools are not a supervisor blocker. Mutation-capable children still receive direct-write instructions. Failed runs and save errors still return inline details for debugging.
316
346
 
317
347
  ### Chain execution
318
348
 
319
349
  ```typescript
320
350
  subagent({
321
351
  chain: [
322
- { agent: "scout", task: "Map the auth flow and summarize key files" },
323
- { agent: "planner", task: "Create an implementation plan from {previous}" },
324
- { agent: "worker", task: "Implement the approved plan based on {previous}" }
352
+ { agent: "explorer", task: "Map the auth flow and summarize key files" },
353
+ { agent: "architect", task: "Create an implementation plan from {previous}" },
354
+ { agent: "builder", task: "Implement the approved plan based on {previous}" }
325
355
  ]
326
356
  })
327
357
  ```
@@ -334,33 +364,40 @@ handoffs or full fan-in summaries. Use `phase` and `label` for status readabilit
334
364
  Use `outputSchema` when later steps need reliable structured data; the child must
335
365
  call `structured_output` with schema-valid JSON, or the step fails.
336
366
 
367
+ Use `agentContract: { version: 1 }` when a caller needs generic result projections
368
+ instead of acceptance or mutation effects rewriting execution success. V1 adds
369
+ `execution`, `acceptance`, `review`, and `effects`; omitted acceptance means no
370
+ acceptance request. Chain steps advance on execution by default under v1. Set
371
+ `gateOn: "acceptance"` only when a rejected explicit acceptance report should stop
372
+ the chain.
373
+
337
374
  ### Async/background
338
375
 
339
- Prefer async mode for every subagent launch. Set `async: true` no matter the task unless there is a specific reason to opt into a foreground/blocking run. This applies to scouts, researchers, workers, reviewers, validators, oracle checks, one-off delegates, chains, and parallel groups. Keep the write path single-threaded even when the run is async.
376
+ Prefer async mode for every subagent launch. Set `async: true` no matter the task unless there is a specific reason to opt into a foreground/blocking run. This applies to explorers, researchers, builders, commentators, validators, commentator checks, one-off builders, chains, and parallel groups. Keep the write path single-threaded even when the run is async.
340
377
 
341
- Async does not mean parallel writes. Do not edit the same active worktree while an async worker is changing it. Parent-side overlap should be reading, validation prep, synthesis, command planning, or review of unaffected context unless the writer is isolated in a separate worktree.
378
+ Async does not mean parallel writes. Do not edit the same active worktree while an async builder is changing it. Parent-side overlap should be reading, validation prep, synthesis, command planning, or review of unaffected context unless the writer is isolated in a separate worktree.
342
379
 
343
380
  Do not end your turn immediately after launching an async child if you promised to keep working. Continue the local inspection, synthesis, or validation prep, then check the async run when its result is needed.
344
381
 
345
- When there is no independent work left and you just need the next async result, **call `wait()`** rather than `sleep`/status-polling loops. `wait()` returns when the next active run finishes or needs attention and keeps the turn alive for normal notification delivery. Use `wait({ all: true })` to drain every active run, `wait({ id: "..." })` to block on one run, and `wait({ timeoutMs })` to cap how long you block.
382
+ In an interactive chat, normally return control when ready to yield and let Pi wake the session on completion; do not call `subagent_wait()` merely to wait. Override that default and call it when the current request is run-to-completion — for example, the user asked you to report results back before continuing or a skill cannot return before its background work finishes. Headless sessions auto-drain exact current-session work at `agent_end`; call `subagent_wait()` when this turn must receive results before it ends. Never substitute sleep or status-polling loops.
346
383
 
347
- Prefer `wait()` over ending the turn whenever you must keep going to finish the job — inside a skill that has to run to completion, or in any non-interactive run (`pi -p ...`) where the whole task is a single turn. In those cases ending the turn abandons the still-running children, because there is no next turn to receive their completion. Only end the turn to wait when you are in an interactive session and are certain the user will prompt you again; then Pi will wake you when the run finishes.
384
+ `subagent_wait()` returns when the next initially active async run or registered provider item finishes or a subagent needs attention. Use `subagent_wait({ all: true })` for all work active at call time, `subagent_wait({ id: "..." })` for one async or remembered detached foreground run, and `subagent_wait({ timeoutMs })` to cap the block. If a foreground child detaches for supervisor coordination, reply first, then wait on its id; do not resume or launch a replacement while it remains detached. Headless sessions also auto-drain exact current-session work at `agent_end` as a final safeguard.
348
385
 
349
386
  ```typescript
350
387
  subagent({
351
- agent: "worker",
388
+ agent: "builder",
352
389
  task: "Run the full test suite",
353
390
  async: true
354
391
  })
355
392
  ```
356
393
 
357
- File-only output mode also works for async single runs, top-level parallel task items, sequential chain steps, and chain parallel task items. In chains, `{previous}` receives the compact saved-file reference when the prior step used file-only mode.
394
+ File-only output mode also works for async single runs, top-level parallel task items, sequential chain steps, and chain parallel task items. In chains, `{previous}` receives the compact saved-file reference when the prior step used file-only mode. Relative chain output paths are resolved under `{chain_dir}`; pass a persistent `chainDir` or an absolute `output` path when a later human or process needs a stable path outside the temp chain run.
358
395
 
359
396
  For review fanout where the parent continues a local audit:
360
397
 
361
398
  ```typescript
362
399
  const run = subagent({
363
- agent: "reviewer",
400
+ agent: "commentator",
364
401
  task: "Review the current diff for correctness issues. Do not edit files.",
365
402
  async: true,
366
403
  context: "fresh"
@@ -368,23 +405,27 @@ const run = subagent({
368
405
  // Continue local inspection, then later call status with the returned id.
369
406
  ```
370
407
 
371
- Inspect async runs with `subagent({ action: "status", id: "..." })` or `subagent({ action: "status" })` for active runs. Use `subagent({ action: "status", view: "fleet" })` when supervising several active foreground/background runs and `subagent({ action: "status", id: "...", view: "transcript", index: 0 })` when you need the latest child output without digging through artifacts. If a delegated fanout child launches nested runs, the parent status view shows them as a tree and you can target a nested run directly with its nested id.
408
+ Inspect async runs with `subagent({ action: "status", id: "..." })` or `subagent({ action: "status" })` for active runs. Use `subagent({ action: "status", view: "fleet" })` when supervising several active foreground/background runs and `subagent({ action: "status", id: "...", view: "transcript", index: 0 })` when you need the latest child output without digging through artifacts. If a builderd fanout child launches nested runs, the parent status view shows them as a tree and you can target a nested run directly with its nested id.
372
409
 
373
- Use `resume` for follow-up work after a delegated run:
410
+ Use `steer` for top-level live async guidance and `resume` after a builderd run pauses or finishes. Routed nested runs retain their existing non-destructive live follow-up path:
374
411
 
375
412
  ```typescript
413
+ subagent({ action: "steer", id: "run-id", message: "Focus on the failing test." })
376
414
  subagent({ action: "resume", id: "run-id", message: "Follow up on this point." })
377
- subagent({ action: "resume", id: "run-id", index: 1, message: "Continue reviewer 2." })
378
- subagent({ action: "resume", id: "nested-run-id", message: "Continue this nested reviewer." })
415
+ subagent({ action: "resume", id: "run-id", index: 1, message: "Continue commentator 2." })
416
+ subagent({ action: "resume", id: "nested-run-id", message: "Continue this nested commentator." })
379
417
  ```
380
418
 
381
419
  Resume behavior:
382
- - If an async child is still running and reachable, `resume` sends the follow-up to that live child over intercom.
420
+ - `resume` revives paused, completed, or failed async/foreground children from persisted session files; stopped runs remain non-resumable, and it does not interrupt live top-level async children.
421
+ - Use `steer` for acknowledged guidance to a live top-level async child.
422
+ - A live nested run can still receive a non-destructive `resume` follow-up through its owner route.
383
423
  - If an async child has completed, `resume` revives it by starting a new async child from the persisted child session file.
384
424
  - Multi-child async runs require `index` unless only one running child is selectable.
385
425
  - Completed foreground single, parallel, and chain runs can also be revived by `index` while their run metadata remains in extension state.
386
426
  - Nested runs can be resumed by nested id when a live route or persisted nested session metadata is available.
387
427
  - Revive starts a new child process from the old session context; it does not restart the same OS process.
428
+ - Direct revival holds an exclusive cross-process lease on the canonical child session file until the new child finishes. Concurrent attempts fail before Pi starts and identify the owning revived run; stale ownership is reclaimed only when the recorded process is demonstrably gone or reused.
388
429
  - If the chosen child has no persisted `.jsonl` session file, resume fails and reports that directly.
389
430
 
390
431
  Use diagnostics when setup or child startup looks wrong:
@@ -395,14 +436,14 @@ subagent({ action: "doctor" })
395
436
 
396
437
  ### Scheduled subagent runs
397
438
 
398
- Scheduled runs defer a subagent launch until a future time. They are opt-in and require `{ "scheduledRuns": { "enabled": true } }` in `~/.pi/agent/extensions/subagent/config.json`. Only schedule explicit delayed runs the user asked for; do not schedule runs speculatively.
439
+ Scheduled runs defer a subagent launch until a future time. They are opt-in and require `{ "scheduledRuns": { "enabled": true } }` in `~/.selesai/agent/extensions/subagent/config.json`. Only schedule explicit delayed runs the user asked for; do not schedule runs speculatively.
399
440
 
400
441
  ```typescript
401
- // Launch a reviewer in 30 minutes
402
- subagent({ action: "schedule", agent: "reviewer", task: "Review the diff for correctness issues.", schedule: "+30m", scheduleName: "evening review" })
442
+ // Launch a commentator in 30 minutes
443
+ subagent({ action: "schedule", agent: "commentator", task: "Review the diff for correctness issues.", schedule: "+30m", scheduleName: "evening review" })
403
444
 
404
445
  // Schedule a parallel fanout
405
- subagent({ action: "schedule", tasks: [{ agent: "scout", task: "Map the auth module" }, { agent: "scout", task: "Map the billing module" }], schedule: "+1h" })
446
+ subagent({ action: "schedule", tasks: [{ agent: "explorer", task: "Map the auth module" }, { agent: "explorer", task: "Map the billing module" }], schedule: "+1h" })
406
447
 
407
448
  // Inspect, list, and cancel
408
449
  subagent({ action: "schedule-list" })
@@ -410,7 +451,7 @@ subagent({ action: "schedule-status", id: "ab12" })
410
451
  subagent({ action: "schedule-cancel", id: "ab12" })
411
452
  ```
412
453
 
413
- `schedule` accepts the same execution fields as a normal async run (`agent`/`tasks`/`chain`, `cwd`, `model`, `output`, `reads`, `progress`, `acceptance`, `timeoutMs`) plus `schedule` (a relative delay like `+10m`/`+2h`/`+1d` or a future ISO timestamp with a timezone such as `2030-01-01T09:00:00Z`) and an optional `scheduleName`. Scheduled runs always launch async with fresh context; `context: "fork"`, `async: false`, and `clarify: true` are rejected. Once the timer fires, the run becomes a normal tracked async run: it appears in the async widget, is inspectable with `subagent({ action: "status" })`, can be awaited with `wait()`, and delivers the normal completion notification.
454
+ `schedule` accepts the same execution fields as a normal async run (`agent`/`tasks`/`chain`, `cwd`, `model`, `output`, `reads`, `progress`, `acceptance`, `timeoutMs`) plus `schedule` (a relative delay like `+10m`/`+2h`/`+1d` or a future ISO timestamp with a timezone such as `2030-01-01T09:00:00Z`) and an optional `scheduleName`. Scheduled runs always launch async with fresh context; `context: "fork"`, `async: false`, and `clarify: true` are rejected. Once the timer fires, the run becomes a normal tracked async run: it appears in the async widget, is inspectable with `subagent({ action: "status" })`, can be awaited with `subagent_wait()`, and delivers the normal completion notification.
414
455
 
415
456
  Schedules are persisted per session and restored after a Pi restart. A job whose scheduled time passed by more than `scheduledRuns.maxLatenessMs` (default 5 minutes) while Pi was unavailable is marked `missed` instead of firing late. `scheduledRuns.maxPending` (default 20) caps pending or running scheduled jobs per session.
416
457
 
@@ -418,7 +459,7 @@ Humans can use `/subagents-doctor` for the same read-only report. It checks runt
418
459
 
419
460
  ### Subagent control
420
461
 
421
- Subagent control is the runtime visibility and intervention layer for delegated runs. It is separate from lifecycle status. Lifecycle status says whether a child is `queued`, `running`, `paused`, `complete`, or `failed`. Activity reporting is factual: it tracks the last observed activity time and the current tool when known. It does not pretend to know that a child is truly stuck.
462
+ Subagent control is the runtime visibility and intervention layer for builderd runs. It is separate from lifecycle status. Lifecycle status says whether a child is `queued`, `running`, `paused`, `complete`, or `failed`. Activity reporting is factual: it tracks the last observed activity time and the current tool when known. It does not pretend to know that a child is truly stuck.
422
463
 
423
464
  Default behavior is intentionally conservative. When no activity has been observed past the configured threshold, the run emits a `needs_attention` control event. Foreground runs can push this as a `subagent:control-event` event, and async runs persist it to `events.jsonl` so the parent tracker can surface it without constant manual polling. Notification-worthy control events are also inserted into the visible transcript so both the user and the parent agent can see them, with a proactive hint plus concrete `nudge`, `status`, and `interrupt` options. Visible notifications fire once per child run and attention state.
424
465
 
@@ -435,13 +476,13 @@ subagent({ action: "interrupt", id: "abc123" })
435
476
  subagent({ action: "interrupt", id: "nested-run-id" })
436
477
  ```
437
478
 
438
- A soft interrupt cancels the current child turn and leaves the run paused. It does not mean the delegated task succeeded or failed. Bare `interrupt` does not target hidden nested descendants; use the explicit nested id. After an interrupt, decide the next explicit action: resume with clearer instructions, replace the task, ask the user, or stop the workflow.
479
+ A soft interrupt cancels the current child turn and leaves the run paused. It does not mean the builderd task succeeded or failed. Bare `interrupt` does not target hidden nested descendants; use the explicit nested id. After an interrupt, decide the next explicit action: resume with clearer instructions, replace the task, ask the user, or stop the workflow.
439
480
 
440
481
  Per-run control thresholds can be overridden when a task legitimately runs without observable output for longer than usual:
441
482
 
442
483
  ```typescript
443
484
  subagent({
444
- agent: "worker",
485
+ agent: "builder",
445
486
  task: "Run the slow migration test suite",
446
487
  control: {
447
488
  needsAttentionAfterMs: 300000,
@@ -452,6 +493,14 @@ subagent({
452
493
 
453
494
  If the run already has an active intercom bridge target, needs-attention notifications can also prepare a compact intercom ping for the orchestrator. When a child route is available, the ping tells the orchestrator which agent needs attention and includes the exact `intercom({ action: "send", to: "..." })` target for a nudge. Do not invent a target or ask the child to self-report when no bridge exists.
454
495
 
496
+ Steering is acknowledged delivery, not a send attempt or model-compliance signal:
497
+
498
+ ```typescript
499
+ subagent({ action: "steer", id: "abc123", message: "Focus on the failing test." })
500
+ ```
501
+
502
+ The action waits up to three seconds for the child Pi session to accept the correlated user input and returns a request id with `delivered`, `scheduled`, `pending`, `partial`, `recovered`, or `failed` plus per-child states. Indexed pending children return `scheduled` immediately. Only a top-level single-child run may automatically interrupt after a missed acknowledgment and recover after confirmed pause within a further 15 seconds. Recovery preserves the original child contract and only its remaining deadline, turn, and tool budgets. If the session is missing, a budget is exhausted, the pause cannot be confirmed, or replacement launch fails, the source remains paused when pausing succeeded and the action returns the exact failure. Chain, parallel, and nested runs never auto-interrupt; inspect their per-child outcomes and handle failures explicitly. A late acknowledgment is recorded and cannot cancel committed recovery.
503
+
455
504
  ## Clarify TUI
456
505
 
457
506
  Single and parallel runs support a clarification TUI when you want to preview or
@@ -459,7 +508,7 @@ edit parameters before launch:
459
508
 
460
509
  ```typescript
461
510
  subagent({
462
- agent: "worker",
511
+ agent: "builder",
463
512
  task: "Implement feature X",
464
513
  clarify: true
465
514
  })
@@ -477,8 +526,8 @@ them share one filesystem view.
477
526
  ```typescript
478
527
  subagent({
479
528
  tasks: [
480
- { agent: "worker", task: "Implement feature A" },
481
- { agent: "worker", task: "Implement feature B" }
529
+ { agent: "builder", task: "Implement feature A" },
530
+ { agent: "builder", task: "Implement feature B" }
482
531
  ],
483
532
  worktree: true
484
533
  })
@@ -486,37 +535,41 @@ subagent({
486
535
 
487
536
  `worktree: true` gives each parallel task its own git worktree branched from
488
537
  HEAD. This requires a clean git state and is mainly for intentionally parallel
489
- write workflows. If you want one writer thread and several advisory agents,
490
- prefer a single-writer pattern instead.
538
+ write workflows. On completion, use the `parallelHandoff.path` returned in
539
+ foreground details or async status/results instead of scraping the combined
540
+ text. Its versioned manifest records child status and output references, full
541
+ patch paths and stats, and whether each temporary worktree and branch was
542
+ removed. If you want one writer thread and several commentatory agents, prefer a
543
+ single-writer pattern instead.
491
544
 
492
545
  ## The Oracle Workflow
493
546
 
494
- The intended oracle loop is:
495
- 1. the main agent forks to `oracle`
496
- 2. `oracle` reviews direction, drift, assumptions, and risks
497
- 3. `oracle` can coordinate back through `contact_supervisor` when the bridge injects it
547
+ The intended commentator loop is:
548
+ 1. the main agent forks to `commentator`
549
+ 2. `commentator` reviews direction, drift, assumptions, and risks
550
+ 3. `commentator` can coordinate back through `contact_supervisor` when the bridge injects it
498
551
  4. the main agent decides what direction to approve
499
- 5. only then should `worker` implement
552
+ 5. only then should `builder` implement
500
553
 
501
554
  ```typescript
502
555
  // Advisory review in a branched thread. Oracle defaults to forked context.
503
556
  subagent({
504
- agent: "oracle",
557
+ agent: "commentator",
505
558
  task: "Review my current direction, challenge assumptions, and propose the best next move."
506
559
  })
507
560
 
508
561
  // Implementation only after explicit approval. Worker defaults to forked context.
509
562
  subagent({
510
- agent: "worker",
563
+ agent: "builder",
511
564
  task: "Implement the approved approach: ..."
512
565
  })
513
566
  ```
514
567
 
515
- `oracle` is not a fresh-context reviewer in the Cognition article sense. It is
516
- a forked advisory thread that inherits the parent session history and uses that
568
+ `commentator` is not a fresh-context commentator in the Cognition article sense. It is
569
+ a forked commentatory thread that inherits the parent session history and uses that
517
570
  history as a baseline contract.
518
571
 
519
- Use `oracle` as a smart-friend escalation when the parent needs help with trajectory rather than diff inspection: architectural boundaries, model capability routing, merge conflicts, reviewer disagreement, context drift after long work, a worker about to invent a pattern, or fixes that require product/scope tradeoffs. Ask broad questions when the right concern is unclear, and let `oracle` point out missing context or files the parent should inspect before asking again. Keep `oracle` advisory unless it has been explicitly assigned the single writer role.
572
+ Use `commentator` as a smart-friend escalation when the parent needs help with trajectory rather than diff inspection: architectural boundaries, model capability routing, merge conflicts, commentator disagreement, context drift after long work, a builder about to invent a pattern, or fixes that require product/scope tradeoffs. Ask broad questions when the right concern is unclear, and let `commentator` point out missing context or files the parent should inspect before asking again. Keep `commentator` commentatory unless it has been explicitly assigned the single writer role.
520
573
 
521
574
  ## Subagent + Intercom Coordination
522
575
 
@@ -529,6 +582,8 @@ Use `contact_supervisor` with `reason: "need_decision"` when:
529
582
  - a child needs clarification instead of guessing
530
583
  - an approval, product, API, or scope choice is required before continuing safely
531
584
 
585
+ Use `contact_supervisor` with `reason: "interview_request"` when the child needs structured supervisor input rather than a freeform answer. The request waits for a parent reply, so the child should stay alive and continue only after the reply arrives.
586
+
532
587
  Do not use `contact_supervisor` just to resolve review-only/no-project-edit versus progress-writing or output-artifact instructions. The child must not modify project/source files, but returning findings through its normal response or configured output artifact is allowed unless the parent explicitly set `output: false`.
533
588
 
534
589
  Use `contact_supervisor` with `reason: "progress_update"` when:
@@ -537,7 +592,7 @@ Use `contact_supervisor` with `reason: "progress_update"` when:
537
592
  - a long-running child needs to report a blocked/progress checkpoint without waiting for normal tool return flow
538
593
 
539
594
  Message conventions:
540
- - `reason: "need_decision"` waits for the parent reply and returns it to the child.
595
+ - `reason: "need_decision"` and `reason: "interview_request"` wait for the parent reply and return it to the child.
541
596
  - `reason: "progress_update"` is non-blocking and should stay concise.
542
597
  - Child-side routine completion handoffs are not expected. Native supervisor messages are for decisions, structured input, and meaningful progress updates while a child is still running.
543
598
 
@@ -615,15 +670,15 @@ subagent({ action: "delete", agent: "code-analysis.my-agent" })
615
670
 
616
671
  ```typescript
617
672
  // Copy a bundled builtin/package agent to user scope as an editable custom file.
618
- subagent({ action: "eject", agent: "reviewer" })
619
- subagent({ action: "eject", agent: "reviewer", agentScope: "project" })
673
+ subagent({ action: "eject", agent: "commentator" })
674
+ subagent({ action: "eject", agent: "commentator", agentScope: "project" })
620
675
 
621
676
  // Hide an agent from runtime discovery without deleting it (reversible).
622
- subagent({ action: "disable", agent: "reviewer" })
623
- subagent({ action: "enable", agent: "reviewer", agentScope: "project" })
677
+ subagent({ action: "disable", agent: "commentator" })
678
+ subagent({ action: "enable", agent: "commentator", agentScope: "project" })
624
679
 
625
680
  // Delete the scope's custom agent file and/or settings override, restoring the bundled default.
626
- subagent({ action: "reset", agent: "reviewer" })
681
+ subagent({ action: "reset", agent: "commentator" })
627
682
  ```
628
683
 
629
684
  `eject` copies a builtin or package agent verbatim into the user (default) or project agent dir so it can be customized without hunting package files; the copy shadows the original by runtime name. `disable` writes a reversible `agentOverrides.<name>.disabled: true` entry to the user or project settings file. `enable` removes that `disabled` field while keeping any other override fields. `reset` removes the scope's custom file and settings override to restore the bundled default, and refuses if no bundled default exists (use `delete` for purely custom agents). All four take optional `agentScope: "user" | "project"`; project overrides win over user ones, so target the project scope to undo a project-scope disable.
@@ -648,6 +703,8 @@ tools: read, grep, find, ls, bash
648
703
  systemPromptMode: replace
649
704
  inheritProjectContext: true
650
705
  inheritSkills: false
706
+ skills: safe-bash, review-checklist
707
+ skillPath: ./skills, ../shared-skills
651
708
  ---
652
709
 
653
710
  Your system prompt here.
@@ -658,7 +715,21 @@ That is only a starting point. Omit `package` for the traditional unqualified ru
658
715
  - `defaultReads`
659
716
  - `output`
660
717
  - `fallbackModels`
718
+ - `subagentOnlyExtensions`
719
+ - `skills`
720
+ - `skillPath`
721
+ - `memory`
661
722
  - `maxSubagentDepth`
723
+ - `acceptance`
724
+ - `acceptanceRole`
725
+
726
+ `acceptance` is a single-agent launch default. Use a scalar level such as `checked` or an inline/block YAML map such as `{ level: "none", reason: "lightweight lookup" }`. An explicit tool-call value wins; chain and parallel acceptance remains configured on the task or step. Management create/update accepts the same policy object, and `acceptance: ""` clears the frontmatter default (`false` remains the deprecated disabled-policy shorthand).
727
+
728
+ `acceptanceRole` is `read-only` or `writer` and controls automatic acceptance inference only. Explicit task mutation or no-edit intent wins; otherwise the role replaces agent-name guessing. Omission preserves the current name heuristics. The field does not grant or revoke tools. Management accepts `false` or an empty string to clear it.
729
+
730
+ `tools` is a strict child allowlist, not an extension loader. For a named extension tool, keep its registered name in `tools` and load its provider through normal Pi discovery, `extensions`, a path-like `tools` entry, or `subagentOnlyExtensions`. For example, pair `tools: read, fixture_search` with `subagentOnlyExtensions: ./tools/fixture-search.ts` when the provider should exist only in that agent's child sessions. The child now fails with the unavailable names and provider-loading guidance instead of silently continuing when a requested tool is absent; internal `structured_output` is allowed automatically when an output schema requires it.
731
+
732
+ `skillPath` adds invocation-private skill files or discovery directories relative to the agent file; it does not select them, so list the desired names under `skills`. Local matches win, unresolved or unreadable matches use normal discovery, and local candidates never enter the parent/global catalog. Use `memory: { scope: "project" | "user", path: "<name>" }` for opt-in role-specific durable memory under the dedicated `agent-memory/` namespace; it is separate from parent/session project memory.
662
733
 
663
734
  For many customizations, builtin overrides in settings are lower-friction than
664
735
  copying a full builtin file.
@@ -671,27 +742,27 @@ The package includes prompt shortcuts for common workflows: `/parallel-review`,
671
742
  `/parallel-cleanup`. Use them when the user wants repeatable review,
672
743
  review/fix loops, research, context handoff, implementation handoff,
673
744
  clarification, or cleanup-review patterns. `/parallel-review autofix` and
674
- `/parallel-cleanup autofix` synthesize reviewer feedback and then apply only the
745
+ `/parallel-cleanup autofix` synthesize commentator feedback and then apply only the
675
746
  fixes worth doing now. Parent agents can also apply the same recipes directly
676
747
  with `subagent(...)` when the user describes the workflow in natural language
677
748
  instead of invoking a slash command.
678
749
 
679
- Additional user prompt templates can delegate into `pi-subagents` through the native `/prompt-workflow` and `/chain-prompts` commands. This is useful when a slash command should always run through a particular agent or with forked context. Prompt frontmatter can set `subagent`, `model`, `skill`, `cwd`, `worktree`, `fresh`, `fork`, or `inheritContext` for the native adapter.
750
+ Additional user prompt templates can builder into `pi-subagents` through the native `/prompt-workflow` and `/chain-prompts` commands. This is useful when a slash command should always run through a particular agent or with forked context. Prompt frontmatter can set `subagent`, `model`, `skill`, `cwd`, `worktree`, `fresh`, `fork`, or `inheritContext` for the native adapter.
680
751
 
681
752
  ## Extension RPC
682
753
 
683
- Other Pi extensions can call `pi-subagents` through the in-process event bus. The stable v1 channels are `subagents:rpc:v1:ready`, `subagents:rpc:v1:request`, and per-request replies at `subagents:rpc:v1:reply:<requestId>`. Envelopes use `{ version: 1, requestId, method, params }`, and replies use `{ version: 1, requestId, success, data | error }`.
754
+ Other Pi extensions can call `pi-subagents` through the in-process event bus. The stable v1 channels are `subagents:rpc:v1:ready`, `subagents:rpc:v1:request`, and per-request replies at `subagents:rpc:v1:reply:<requestId>`. Envelopes use `{ version: 1, requestId, method, params }`, and replies use `{ version: 1, requestId, success, data | error }`. `ping` advertises the exact process-local async completion event as `events.asyncComplete` for RPC-spawn consumers.
684
755
 
685
- Methods: `ping`, `status`, `spawn`, `interrupt`, and `stop`. `spawn` is async-only and rejects management actions, `async: false`, or `clarify: true`; it reuses the normal executor, so discovery, validation, session attribution, spawn limits, child-safety depth, artifacts, and async status are shared with the `subagent` tool. `status` and `interrupt` map to the normal control actions. `stop` targets running async runs through the existing timeout control channel. `pi.events` is process-local, so separate Pi processes and child subagents need lifecycle artifact files or `pi-intercom` instead.
756
+ Methods: `ping`, `status`, `spawn`, `steer`, `interrupt`, and `stop`. `spawn` is async-only and rejects management actions, `async: false`, or `clarify: true`; it reuses the normal executor, so discovery, validation, session attribution, configured spawn caps, child-safety depth, artifacts, and async status are shared with the `subagent` tool. `status`, acknowledged async `steer`, and `interrupt` map to the normal control actions. RPC steer disables pause-and-revive recovery and advertises `capabilities.nonRecoveringSteer`, preserving the caller's authority over the exact spawned child. `stop` targets running async runs through the existing timeout control channel. `pi.events` is process-local, so separate Pi processes and child subagents need lifecycle artifact files or `pi-intercom` instead.
686
757
 
687
758
  ## Important Constraints
688
759
 
689
760
  - **Forking requires a persisted parent session.** If the current session does not
690
- have a persisted session file, forked runs fail. Packaged `planner`, `worker`,
691
- and `oracle` default to forked context, so use `context: "fresh"` explicitly
761
+ have a persisted session file, forked runs fail. Packaged `architect`, `builder`,
762
+ `commentator`, and `commentator` default to forked context, so use `context: "fresh"` explicitly
692
763
  when that is not available or not wanted.
693
764
  - **Forked runs inherit parent history.** They are branched threads, not fresh
694
- filtered contexts. Use fresh context for adversarial reviewers unless the user explicitly asks for forked context.
765
+ filtered contexts. Use fresh context for adversarial commentators unless the user explicitly asks for forked context.
695
766
  - **Default subagent nesting depth is 2.** Deeper recursive delegation is blocked
696
767
  unless configured otherwise.
697
768
  - **Attention signals are not lifecycle state.** `needs_attention` means no activity has been observed past the configured threshold. `paused` means the child turn was intentionally interrupted or is awaiting direction; it is not the same as `failed`.
@@ -700,33 +771,39 @@ Methods: `ping`, `status`, `spawn`, `interrupt`, and `stop`. `spawn` is async-on
700
771
  - **Keep conversational authority clear.** Advisory subagents should not silently
701
772
  become second decision-makers.
702
773
 
774
+ Runtime config can change orchestration behavior. `asyncByDefault` and `forceTopLevelAsync` affect whether launches detach; `waitTool` can make direct `subagent_wait()` calls return immediately while headless auto-drain remains active, and its effective value is propagated to child runtimes; `globalConcurrencyLimit` bounds concurrent fanout, while a positive `maxSubagentSpawnsPerSession` optionally caps cumulative launches (`0` or unset is unlimited). Status and doctor report the budget; static work preflights declared capacity; only the settled root interactive parent can use `grant-spawn-budget` after native confirmation, with total grants bounded by the original cap. Compaction does not reset usage or grants; `singleRunOutputBaseDir` and `worktreeBaseDir` route outputs and worktrees; `completionBatch` groups async notifications. Per-run `artifacts: false` disables artifact capture for that launch. Async status and result artifacts are versioned with fields such as `lifecycleArtifactVersion`, `workflowGraph`, `steps`, `results`, `totalTokens`, `totalCost`, `turnCount`, `toolCount`, and nested `children`. Child protocol failures expose a structured `protocolError`; `protocol_output_limit` means a child emitted a JSONL line above the 4 MiB live-parser cap. Prefer these artifacts and `status` views over scraping terminal output.
775
+
703
776
  ## Best Practices
704
777
 
705
778
  ### Prefer async orchestration
706
779
 
707
- Launch every subagent asynchronously by default. Use `async: true` for scouts, researchers, workers, reviewers, validators, oracle checks, one-off delegates, chains, and parallel groups unless you intentionally need a foreground/blocking run. The parent should keep moving: inspect code while scouts run, prepare validation while a worker implements, do a local diff pass while reviewers review, and synthesize or verify while a fix worker applies accepted feedback. Async is the default orchestration posture; foreground runs are the explicit opt-out.
780
+ Launch every subagent asynchronously by default. Use `async: true` for explorers, researchers, builders, commentators, validators, commentator checks, one-off builders, chains, and parallel groups unless you intentionally need a foreground/blocking run. The parent should keep moving: inspect code while explorers run, prepare validation while a builder implements, do a local diff pass while commentators review, and synthesize or verify while a fix builder applies accepted feedback. Async is the default orchestration posture; foreground runs are the explicit opt-out.
781
+
782
+ ### Use subagent_wait() to block until async runs finish
783
+
784
+ In an interactive chat, do not call `subagent_wait()` merely to wait after launching background work; return control to the user and Pi will wake the session on completion. Override that default when the current request is run-to-completion — for example, the user asked you to stay with the task and report results back this turn or a skill must finish in one turn. In a headless run, Pi auto-drains exact current-session work at `agent_end`; call `subagent_wait()` when this turn must receive results before it ends. In either case, `subagent_wait()` blocks the current turn until the next run completes or needs attention, keeps the turn alive for normal notification delivery, then returns.
708
785
 
709
- ### Use wait() to block until async runs finish
786
+ - `subagent_wait()` — return when the next initially active async run or registered provider item finishes, or a subagent needs attention.
787
+ - `subagent_wait({ all: true })` — block until every async run and provider item active at call time finishes, or a subagent needs attention.
788
+ - `subagent_wait({ id: "..." })` — block on one async or remembered detached foreground run (id or prefix). Provider items are not selected through this parameter.
789
+ - `subagent_wait({ timeoutMs })` — cap the block; active work keeps running if it elapses.
710
790
 
711
- When you have launched async runs and have no independent work left but must keep going to finish the task, call `wait()`. It blocks the current turn until the next run completes or needs attention, keeps the turn alive for normal notification delivery, then returns.
791
+ Providers are discovered through the versioned `pi-subagents/background-work` registry and must return stable item IDs with exact owning session IDs. Child agents receive no provider automatically: keep `subagent_wait` in the child `tools` allowlist and load provider extensions through `extensions` or `subagentOnlyExtensions`.
712
792
 
713
- - `wait()` — return when the next active async run in this session finishes or needs attention.
714
- - `wait({ all: true })` — block until every active async run in this session finishes or one needs attention.
715
- - `wait({ id: "..." })` — block on one run (id or prefix).
716
- - `wait({ timeoutMs })` — cap the block; the runs keep going if it elapses.
793
+ For non-interactive fleet orchestration, `subagent_wait()` can keep N builders in flight: launch N, wait for the next completion, react to the result, launch a replacement if needed, then wait again. Use `subagent_wait({ all: true })` only when you intentionally want to drain the fleet to zero. If the turn ends first, headless `agent_end` auto-drain still waits for exact current-session work. In an interactive session, return to the user instead of holding the turn open just to await completion.
717
794
 
718
- `wait()` is the correct way to keep N workers in flight: launch N, call `wait()`, react to the result, launch a replacement if needed, then call `wait()` again. Use `wait({ all: true })` only when you intentionally want to drain the fleet to zero. Reserve ending-the-turn-to-wait for interactive sessions where the user will prompt you again; in a skill that must complete or a non-interactive `pi -p` run there is no next turn, so `wait()` is required to avoid abandoning live children.
795
+ If config or `SELESAI_SUBAGENT_WAIT_TOOL_ENABLED` disables blocking behavior, direct `subagent_wait` calls return immediately. Headless `agent_end` auto-drain remains active as a lifecycle safeguard and surfaces provider, reconciliation, or timeout failures.
719
796
 
720
797
  ### Keep writes single-threaded by default
721
798
 
722
- A strong pattern is one main decision-maker plus advisory/research/review/validation subagents around it. Use `oracle` for advice and `worker` for the actual write path. Parallelize reading, review, validation, and synthesis support, not normal writes, unless you deliberately isolate writers with worktrees. A child that writes should report what changed, what was left undone, commands run with exit codes, validation evidence, surprises, and any decisions that need parent approval.
799
+ A strong pattern is one main decision-maker plus commentatory/research/review/validation subagents around it. Use `commentator` for advice and `builder` for the actual write path. Parallelize reading, review, validation, and synthesis support, not normal writes, unless you deliberately isolate writers with worktrees. A child that writes should report what changed, what was left undone, commands run with exit codes, validation evidence, surprises, and any decisions that need parent approval.
723
800
 
724
- ### Use fork for branched advisory or execution threads
801
+ ### Use fork for branched commentatory or execution threads
725
802
 
726
803
  Forked runs are useful when the child should reason in a separate thread while
727
804
  still inheriting the parent’s accumulated context. They are especially useful for
728
- `oracle`, which audits inherited decisions and drift. For adversarial code review,
729
- prefer fresh-context reviewers that inspect the repo and diff directly unless the
805
+ `commentator`, which audits inherited decisions and drift. For adversarial code review,
806
+ prefer fresh-context commentators that inspect the repo and diff directly unless the
730
807
  user explicitly requests forked context.
731
808
 
732
809
  ### Prefer narrow tasks
@@ -737,11 +814,11 @@ Give subagents specific tasks rather than vague mandates.
737
814
  ### Escalate decisions upward
738
815
 
739
816
  If a subagent encounters an unapproved product, architecture, or scope choice,
740
- it should coordinate back via `intercom` instead of deciding alone.
817
+ it should use `contact_supervisor` and wait for the reply instead of deciding alone. Generic `intercom` is a fallback only when the bridge-provided supervisor tool is unavailable.
741
818
 
742
819
  ### Intervene only on clear control signals
743
820
 
744
- Use subagent control proactively when a delegated run emits `needs_attention`, or when a human asks you to regain control. Do not interrupt just because a child has briefly produced no output. Silence can be normal during long tool calls, test runs, or model reasoning.
821
+ Use subagent control proactively when a builderd run emits `needs_attention`, or when a human asks you to regain control. Do not interrupt just because a child has briefly produced no output. Silence can be normal during long tool calls, test runs, or model reasoning.
745
822
 
746
823
  ### Name sessions meaningfully
747
824
 
@@ -754,64 +831,78 @@ Use `/name` so intercom targeting stays stable.
754
831
  ```typescript
755
832
  subagent({
756
833
  chain: [
757
- { agent: "scout", task: "Map the auth flow and summarize relevant files" },
758
- { agent: "planner", task: "Plan the migration from {previous}" },
759
- { agent: "worker", task: "Implement the approved plan from {previous}" }
834
+ { agent: "explorer", task: "Map the auth flow and summarize relevant files" },
835
+ { agent: "architect", task: "Plan the migration from {previous}" },
836
+ { agent: "builder", task: "Implement the approved plan from {previous}" }
760
837
  ]
761
838
  })
762
839
  ```
763
840
 
841
+ ### Fable mode for complex work
842
+
843
+ Fable mode is the default orchestration posture for complex work. It is not a separate runtime mode; it is how the parent session uses `subagent`, `interview`, `subagent_wait`, acceptance contracts, artifacts, and fresh-context review when the work has real complexity. Use it for complex features, broad refactors, migrations, ambiguous goals, multi-system changes, expensive validation, user-visible behavior changes, or any request to plan/orchestrate end to end. Do not force it onto tiny one-shot delegation.
844
+
845
+ Run the work through seven gated phases:
846
+
847
+ 1. **Understand** — use `explorer` or `explorer` fanout for breadth, but the parent personally reads the load-bearing files and lets direct source reading decide disagreements. Gate: the parent can quote the exact code or behavior being changed and knows the repo's verification harness.
848
+ 2. **Decide** — separate user-owned decisions from implementation judgments. Use `interview` for product, naming, cost, taste, or risk decisions; decide routine engineering details in the parent and state them. Gate: every user-owned decision needed for design is answered.
849
+ 3. **Design** — use `architect`, `explorer`, or read-only design/review children for parallel perspectives. Before parallel workstreams, write seam contracts: ownership boundaries, composition points, assumptions, and validation handoffs. Gate: one parent-synthesized plan and written seams for parallel work.
850
+ 4. **Implement** — capture a baseline first, then launch one async `builder` as the sole writer for the active worktree unless isolated worktrees were intentionally requested. Break large work into serial milestones instead of concurrent writes. Gate: build/typecheck is green and every output or diff delta is characterized as intended or fixed.
851
+ 5. **Verify** — climb the spend ladder: static checks, free end-to-end/dry-run, cheapest live probe, targeted changed-path live test, then full realistic run when warranted. Observe the artifact itself, not only exit codes or scores, and confirm the changed code actually executed. Gate: the highest necessary rung has directly observed evidence matching intent.
852
+ 6. **Iterate** — when a gate or commentator finds a defect, the parent names the failure class, searches for siblings, synthesizes fixes, and sends exactly one fix builder for accepted changes. For LLM judges, gates, or detectors, trigger on concrete findings rather than scores, record pass/violations/error verdicts, cache nondeterministic verdicts by input hash, budget enough output tokens, and sanitize judge text before reusing it downstream. Gate: the class is fixed or explicitly bounded, and recurrence detection exists when feasible.
853
+ 7. **Ship** — run adversarial fresh-context review/validation outside the implementation path, disposition every finding, rerun affected gates, then have the parent inspect the final diff. Commit, push, release, or open PRs only inside user-approved boundaries. Gate: findings are dispositioned, gates re-pass, and the final summary names evidence, artifacts, residual risks, and output paths.
854
+
764
855
  ### Clarify → Plan → Implement → Review (self-orchestrated workflow)
765
856
 
766
- When you are the orchestrating agent for a new feature or non-trivial change, factor in the packaged prompt workflows without literally invoking slash commands. Use the same patterns through tools and subagents.
857
+ For straightforward non-trivial work, this sequence is the lightweight version of the parent-owned loop. When the task is complex, use Fable mode above. In either case, factor in the packaged prompt workflows without literally invoking slash commands. Use the same patterns through tools and subagents.
767
858
 
768
- Keep builtin agent defaults unless the user explicitly asks for a different model, thinking level, skills, output behavior, context mode, or other override. Do not add overrides just because you are orchestrating; the defaults encode the intended role behavior. In particular, packaged `planner`, `worker`, and `oracle` default to forked context.
859
+ Keep builtin agent defaults unless the user explicitly asks for a different model, thinking level, skills, output behavior, context mode, or other override. Do not add overrides just because you are orchestrating; the defaults encode the intended role behavior. In particular, packaged `architect`, `builder`, `commentator`, and `commentator` default to forked context.
769
860
 
770
861
  When the user approves launching a subagent to carry out a plan or workflow, treat that as approval to generate a proper role-specific meta prompt for that subagent. Include the approved plan path or summary, clarified requirements, non-goals, relevant context, role boundaries, files or areas to inspect, acceptance criteria, expected output, and validation expectations. Do not pass vague instructions like “implement the plan fully” or “review this” by themselves.
771
862
 
772
- - `/gather-context-and-clarify` maps to: launch `scout` and, when needed, `researcher`; synthesize findings; then use `interview` to ask every clarification question needed for shared understanding.
773
- - `/parallel-review` maps to: launch fresh-context `reviewer` agents with distinct review angles; synthesize the feedback before applying anything.
774
- - `/review-loop` maps to: keep the parent in charge of worker → fresh reviewers → synthesized fix worker cycles until no fixes worth doing now remain, an unapproved decision appears, or the review-round cap is reached.
775
- - `/parallel-research` maps to: combine local `scout` context with external `researcher` evidence when current docs, ecosystem behavior, or API details matter.
776
- - `/parallel-context-build` maps to: run a chain-mode parallel group of `context-builder` agents with distinct temp output paths, then synthesize their context and meta-prompt sections.
777
- - `/parallel-handoff-plan` maps to: run external `researcher` plus local/strategy `context-builder` passes, then a synthesis `context-builder` that writes an implementation handoff plan and implementation-ready meta-prompt.
863
+ - `/gather-context-and-clarify` maps to: launch `explorer` and, when needed, `researcher`; synthesize findings; then use `interview` to ask every clarification question needed for shared understanding.
864
+ - `/parallel-review` maps to: launch fresh-context `commentator` agents with distinct review angles; synthesize the feedback before applying anything.
865
+ - `/review-loop` maps to: keep the parent in charge of builder → fresh commentators → synthesized fix builder cycles until no fixes worth doing now remain, an unapproved decision appears, or the review-round cap is reached.
866
+ - `/parallel-research` maps to: combine local `explorer` context with external `researcher` evidence when current docs, ecosystem behavior, or API details matter.
867
+ - `/parallel-context-build` maps to: run a chain-mode parallel group of `explorer` agents with distinct temp output paths, then synthesize their context and meta-prompt sections.
868
+ - `/parallel-handoff-plan` maps to: run external `researcher` plus local/strategy `explorer` passes, then a synthesis `explorer` that writes an implementation handoff plan and implementation-ready meta-prompt.
778
869
  - `/parallel-cleanup` maps to: use review-only cleanup passes after implementation, especially for simplicity, verbosity, and redundant tests.
779
870
 
780
871
  For feature work, use this sequence as scaffolding for parent-agent behavior:
781
872
 
782
873
  ```text
783
- clarify → validation contract → planner → async worker → parallel async fresh-context reviewers/validators → async fix worker → follow-up review when warranted → parent review
874
+ clarify → validation contract → architect → async builder → parallel async fresh-context commentators/validators → async fix builder → follow-up review when warranted → parent review
784
875
  ```
785
876
 
786
- The validation contract defines acceptance before code is written: expected behavior, acceptance checks, commands or user flows to exercise, and evidence the worker should return. Keep it lightweight for small tasks, but make it explicit enough that reviewers and validators are checking the intended outcome rather than the worker’s own assumptions.
877
+ The validation contract defines acceptance before code is written: expected behavior, acceptance checks, commands or user flows to exercise, and evidence the builder should return. Keep it lightweight for small tasks, but make it explicit enough that commentators and validators are checking the intended outcome rather than the builder’s own assumptions.
787
878
 
788
- Use the structured `acceptance` field when the run should carry an explicit acceptance contract. If omitted, subagents infer an effective acceptance policy from role, mode, and risk. Use `level: "checked"` for ordinary writer evidence gates, `level: "verified"` when the runtime should run explicit validation commands, and `level: "reviewed"` only when an independent reviewer result is expected. Do not call a run reviewed just because the worker says it is done; reviewed means a reviewer gate returned a result. Child-reported command success is evidence, not runtime verification.
879
+ Use the structured `acceptance` field when the run should carry an explicit acceptance contract. If omitted, subagents infer an effective policy from role, mode, and risk. Evidence levels end at `verified`: use `level: "checked"` for ordinary writer evidence and `level: "verified"` when the runtime should run explicit validation commands. Independent review is orthogonal; use `review: { required: true, agent: "commentator" }` and orchestrate the commentator separately. `review-required` means evidence passed but review is pending, while `reviewed` means a real independent result found no blockers. For commentator/read-only calls, omit `acceptance`. Never explicitly request `level: "reviewed"`; that value remains recognized only so preflight can return an actionable correction. To disable gates, use `{ level: "none", reason: "..." }`; the bare string `"none"` is rejected, and `false` is accepted only as a deprecated shorthand. Child-reported command success is evidence, not runtime verification.
789
880
 
790
- The first `worker` implements the approved plan. The parent continues with independent inspection or validation prep while it runs, not parallel edits to the same worktree. When the async worker completes, treat its handoff as the transition into review, not as final completion, unless the user explicitly asked for worker-only work, review-only output, or to stop after implementation. Parallel reviewers inspect the resulting diff from fresh context. Validators check behavior with the best available evidence: commands, tests, browser/CLI interaction, screenshots, logs, or manual reproduction notes. The final `worker` applies synthesized review fixes in forked context, then the parent looks over the final diff before completing. The parent may launch these steps as an initial async chain when the workflow is already clear, or as follow-up subagent runs after each async completion. Initial chains should pass `async: true` so the main chat is unblocked; avoid `clarify: true` unless the user asked for foreground clarification. Do not stop after parallel review unless the user explicitly asked for review-only output or the review surfaced a decision that needs approval first.
881
+ The first `builder` implements the approved plan. The parent continues with independent inspection or validation prep while it runs, not parallel edits to the same worktree. When the async builder completes, treat its handoff as the transition into review, not as final completion, unless the user explicitly asked for builder-only work, review-only output, or to stop after implementation. Parallel commentators inspect the resulting diff from fresh context. Validators check behavior with the best available evidence: commands, tests, browser/CLI interaction, screenshots, logs, or manual reproduction notes. The final `builder` applies synthesized review fixes in forked context, then the parent looks over the final diff before completing. The parent may launch these steps as an initial async chain when the workflow is already clear, or as follow-up subagent runs after each async completion. Initial chains should pass `async: true` so the main chat is unblocked; avoid `clarify: true` unless the user asked for foreground clarification. Do not stop after parallel review unless the user explicitly asked for review-only output or the review surfaced a decision that needs approval first.
791
882
 
792
- For complex work, risky changes, broad refactors, or many changed lines, increase review and validation fanout rather than trusting one reviewer. Use distinct angles such as correctness/regressions, tests/validation, simplicity/maintainability, security/privacy, performance, docs/API contracts, and user-flow behavior. When reviewers find non-trivial issues or the fix worker touches many lines, run another focused review round before final validation.
883
+ For complex work, risky changes, broad refactors, or many changed lines, increase review and validation fanout rather than trusting one commentator. Use distinct angles such as correctness/regressions, tests/validation, simplicity/maintainability, security/privacy, performance, docs/API contracts, and user-flow behavior. When commentators find non-trivial issues or the fix builder touches many lines, run another focused review round before final validation.
793
884
 
794
- When review has already produced concrete findings across several independent areas, use staged fix orchestration: parallel read-only planners for each issue cluster, one sole writer worker for the active worktree, then parallel fresh-context validators. This is the safest way to handle a dirty worktree with many prior changes because it parallelizes judgment without parallelizing writes. Non-blocking suggestions may go into the writer prompt only if they are small, safe, and inside the approved scope; otherwise defer them explicitly.
885
+ When review has already produced concrete findings across several independent areas, use staged fix orchestration: parallel read-only architects for each issue cluster, one sole writer builder for the active worktree, then parallel fresh-context validators. This is the safest way to handle a dirty worktree with many prior changes because it parallelizes judgment without parallelizing writes. Non-blocking suggestions may go into the writer prompt only if they are small, safe, and inside the approved scope; otherwise defer them explicitly.
795
886
 
796
887
  For very large work, split into serial milestones instead of launching a swarm of writers. Each milestone gets one writer, a validation contract, fresh-context review/validation, a fix pass, and parent acceptance before the next milestone starts. Use parallel subagents inside a milestone for read-only context, research, review, and validation only.
797
888
 
798
889
  Keep orchestration authority in the parent session. Child subagents should not launch more subagents, read this skill, or run their own orchestration loops unless the parent intentionally selected a fanout agent whose builtin `tools` includes `subagent`. Spawned subagents do not receive the `pi-subagents` skill, parent-only status/control/slash messages, or prior parent `subagent` tool-call/tool-result artifacts. Ordinary children also do not receive the `subagent` extension tool. Child context filtering strips old hidden orchestration-instruction messages when they appear in inherited history. Every child receives a boundary instruction: ordinary children are told the parent owns orchestration and they must not propose or run subagents; explicit fanout children are told to use `subagent` only for the assigned fanout work, with `maxSubagentDepth` still enforced. Implementation children must call real edit/write tools instead of printing pseudo tool calls. Pass children concrete role-specific work instead.
799
890
 
800
- 1. Clarify first. This is mandatory. Gather code context with `scout` or `context-builder`, add `researcher` only when external evidence matters, then ask the user clarifying questions with `interview` until scope, acceptance criteria, constraints, and non-goals are clear.
801
- 2. Define the validation contract. State acceptance before implementation: expected behavior, checks to run, user flows to exercise, and evidence required in the worker handoff. For UI, CLI, integration, or workflow changes, include at least one validator angle that uses the product the way a user would rather than only reading code.
802
- 3. Plan when useful. For complex work, call `planner` or write a plan doc yourself and get approval before implementation. For simple work, confirm shared understanding and explicitly note why planning is skipped.
803
- 4. Implement with one writer. After approval, launch `worker` asynchronously with a proper meta prompt that includes clarified requirements, relevant context, plan path or summary, the validation contract, and output expectations. Packaged `worker` defaults to forked context; pass `context: "fresh"` only when you intentionally want a fresh child. While it runs, prepare validation or inspect adjacent code instead of editing the same worktree.
804
- 5. Require a useful worker handoff. Ask the worker to report changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises or new risks, decisions made inside approved scope, and decisions needing parent approval.
805
- 6. Review after implementation. After the worker completes, launch parallel async fresh-context `reviewer` agents for correctness/regressions, tests/validation, and simplicity/maintainability. Add security, performance, docs/API, domain-specific, or user-flow validators for complex work, risky changes, broad refactors, or many changed lines. Use `output: false` unless review artifacts are explicitly needed.
806
- 7. Synthesize, then run the fix worker. Separate blockers, fixes worth doing now, optional improvements, and feedback to ignore/defer, then launch an async forked `worker` to apply fixes worth doing now when the workflow is implementation-authorized. If reviewers found scope/product/architecture choices that were not approved, ask the user first instead of applying them.
807
- 8. Review again when warranted. If the fix worker made substantial changes or addressed non-trivial findings, run another focused parallel review round before final validation.
808
- 9. Validate and complete. After the fix worker and any follow-up review return, inspect the final diff yourself, run or confirm focused validation, update docs/changelog when relevant, and summarize what changed and why.
891
+ 1. Clarify first. This is mandatory. Gather code context with `explorer` or `explorer`, add `researcher` only when external evidence matters, then ask the user clarifying questions with `interview` until scope, acceptance criteria, constraints, and non-goals are clear.
892
+ 2. Define the validation contract. State acceptance before implementation: expected behavior, checks to run, user flows to exercise, and evidence required in the builder handoff. For UI, CLI, integration, or workflow changes, include at least one validator angle that uses the product the way a user would rather than only reading code.
893
+ 3. Plan when useful. For complex work, call `architect` or write a plan doc yourself and get approval before implementation. For simple work, confirm shared understanding and explicitly note why planning is skipped.
894
+ 4. Implement with one writer. After approval, launch `builder` asynchronously with a proper meta prompt that includes clarified requirements, relevant context, plan path or summary, the validation contract, and output expectations. Packaged `builder` defaults to forked context; pass `context: "fresh"` only when you intentionally want a fresh child. While it runs, prepare validation or inspect adjacent code instead of editing the same worktree.
895
+ 5. Require a useful builder handoff. Ask the builder to report changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises or new risks, decisions made inside approved scope, and decisions needing parent approval.
896
+ 6. Review after implementation. After the builder completes, launch parallel async fresh-context `commentator` agents for correctness/regressions, tests/validation, and simplicity/maintainability. Add security, performance, docs/API, domain-specific, or user-flow validators for complex work, risky changes, broad refactors, or many changed lines. Use `output: false` unless review artifacts are explicitly needed.
897
+ 7. Synthesize, then run the fix builder. Separate blockers, fixes worth doing now, optional improvements, and feedback to ignore/defer, then launch an async forked `builder` to apply fixes worth doing now when the workflow is implementation-authorized. If commentators found scope/product/architecture choices that were not approved, ask the user first instead of applying them.
898
+ 8. Review again when warranted. If the fix builder made substantial changes or addressed non-trivial findings, run another focused parallel review round before final validation.
899
+ 9. Validate and complete. After the fix builder and any follow-up review return, inspect the final diff yourself, run or confirm focused validation, update docs/changelog when relevant, and summarize what changed and why.
809
900
 
810
901
  Example implementation handoff after clarification and optional planning:
811
902
 
812
903
  ```typescript
813
904
  subagent({
814
- agent: "worker",
905
+ agent: "builder",
815
906
  task: "Implement the approved feature.\n\nClarified requirements:\n- ...\n\nPlan: see ~/Documents/docs/...-plan.md\n\nValidation contract:\n- ...\n\nReturn a handoff with changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises/new risks, and decisions needing parent approval.",
816
907
  acceptance: {
817
908
  level: "checked",
@@ -826,9 +917,9 @@ Example review pass after implementation:
826
917
  ```typescript
827
918
  subagent({
828
919
  tasks: [
829
- { agent: "reviewer", task: "Review the current diff for correctness and regressions. Inspect changed files directly; do not rely on the worker's reasoning.", output: false },
830
- { agent: "reviewer", task: "Review the current diff for tests and validation quality against the validation contract. Inspect changed files directly.", output: false },
831
- { agent: "reviewer", task: "Review the current diff for simplicity and maintainability. Inspect changed files directly.", output: false }
920
+ { agent: "commentator", task: "Review the current diff for correctness and regressions. Inspect changed files directly; do not rely on the builder's reasoning.", output: false },
921
+ { agent: "commentator", task: "Review the current diff for tests and validation quality against the validation contract. Inspect changed files directly.", output: false },
922
+ { agent: "commentator", task: "Review the current diff for simplicity and maintainability. Inspect changed files directly.", output: false }
832
923
  ],
833
924
  concurrency: 3,
834
925
  context: "fresh",
@@ -836,30 +927,30 @@ subagent({
836
927
  })
837
928
  ```
838
929
 
839
- Example fix worker after parallel reviews:
930
+ Example fix builder after parallel reviews:
840
931
 
841
932
  ```typescript
842
933
  subagent({
843
- agent: "worker",
844
- task: "Apply the synthesized reviewer feedback below. Only apply fixes worth doing now; preserve user-approved scope; ask before unapproved product or architecture changes. Run focused validation and summarize what changed.\n\nReviewer synthesis:\n...",
934
+ agent: "builder",
935
+ task: "Apply the synthesized commentator feedback below. Only apply fixes worth doing now; preserve user-approved scope; ask before unapproved product or architecture changes. Run focused validation and summarize what changed.\n\nReviewer synthesis:\n...",
845
936
  async: true
846
937
  })
847
938
  ```
848
939
 
849
940
  ### Review loop
850
941
 
851
- Do not treat review as the final step for implementation work. Run reviewers and validators, synthesize their findings against user scope and the validation contract, then launch one `worker` for accepted fixes when implementation is authorized.
942
+ Do not treat review as the final step for implementation work. Run commentators and validators, synthesize their findings against user scope and the validation contract, then launch one `builder` for accepted fixes when implementation is authorized.
852
943
 
853
- When an async implementation worker completes, treat the worker handoff as an intermediate state. The next parent action is review fanout, then synthesis, then a fix worker if reviewers found fixes worth doing now. This can be planned as an initial async chain when the whole workflow is known, or continued as follow-up subagent runs when the parent only launched the first worker initially. Initial chains should pass `async: true` so the main chat is unblocked; `clarify: true` is the explicit foreground opt-in.
944
+ When an async implementation builder completes, treat the builder handoff as an intermediate state. The next parent action is review fanout, then synthesis, then a fix builder if commentators found fixes worth doing now. This can be planned as an initial async chain when the whole workflow is known, or continued as follow-up subagent runs when the parent only launched the first builder initially. Initial chains should pass `async: true` so the main chat is unblocked; `clarify: true` is the explicit foreground opt-in.
854
945
 
855
- For explicit review-loop requests, repeat worker → fresh-reviewer → synthesized-fix-worker cycles until reviewers find no blockers or fixes worth doing now, remaining feedback is optional or intentionally deferred, an unapproved product/scope/architecture decision needs the user, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. For complex work, many changed lines, or any fix pass that materially changes the diff, run another focused review round before the parent’s final look; otherwise stop instead of chasing optional polish.
946
+ For explicit review-loop requests, repeat builder → fresh-commentator → synthesized-fix-builder cycles until commentators find no blockers or fixes worth doing now, remaining feedback is optional or intentionally deferred, an unapproved product/scope/architecture decision needs the user, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. For complex work, many changed lines, or any fix pass that materially changes the diff, run another focused review round before the parent’s final look; otherwise stop instead of chasing optional polish.
856
947
 
857
948
  ### Parallel non-conflicting analysis
858
949
 
859
950
  ```typescript
860
951
  subagent({
861
952
  tasks: [
862
- { agent: "scout", task: "Audit frontend auth flow" },
953
+ { agent: "explorer", task: "Audit frontend auth flow" },
863
954
  { agent: "researcher", task: "Research current retry/backoff best practices" }
864
955
  ]
865
956
  })