@selesai/code 0.5.19 → 0.5.21

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 (265) hide show
  1. package/dist/extensions/handoff-new.test.ts +8 -9
  2. package/dist/extensions/handoff-new.ts +6 -8
  3. package/dist/extensions/pi-intercom/broker/spawn.test.ts +31 -0
  4. package/dist/extensions/pi-intercom/broker/spawn.ts +5 -3
  5. package/dist/extensions/pi-subagents/CHANGELOG.md +1367 -0
  6. package/dist/extensions/pi-subagents/README.md +602 -220
  7. package/dist/extensions/pi-subagents/banner.png +0 -0
  8. package/dist/extensions/pi-subagents/index.ts +1 -0
  9. package/dist/extensions/pi-subagents/install.mjs +3 -3
  10. package/dist/extensions/pi-subagents/package-lock.json +3405 -0
  11. package/dist/extensions/pi-subagents/package.json +26 -14
  12. package/dist/extensions/pi-subagents/prompts/gather-context-and-clarify.md +1 -1
  13. package/dist/extensions/pi-subagents/prompts/parallel-cleanup.md +9 -9
  14. package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +3 -3
  15. package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +7 -7
  16. package/dist/extensions/pi-subagents/prompts/parallel-research.md +6 -6
  17. package/dist/extensions/pi-subagents/prompts/parallel-review.md +8 -8
  18. package/dist/extensions/pi-subagents/prompts/review-loop.md +13 -11
  19. package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +267 -176
  20. package/dist/extensions/pi-subagents/src/agents/agent-management.ts +89 -16
  21. package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +19 -0
  22. package/dist/extensions/pi-subagents/src/agents/agents.ts +218 -120
  23. package/dist/extensions/pi-subagents/src/agents/frontmatter.ts +67 -13
  24. package/dist/extensions/pi-subagents/src/agents/proactive-skills.ts +2 -2
  25. package/dist/extensions/pi-subagents/src/agents/skills.ts +25 -12
  26. package/dist/extensions/pi-subagents/src/api/background-work.ts +197 -0
  27. package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +17 -0
  28. package/dist/extensions/pi-subagents/src/api/delegation.ts +285 -0
  29. package/dist/extensions/pi-subagents/src/api/preflight.ts +399 -0
  30. package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +165 -0
  31. package/dist/extensions/pi-subagents/src/extension/config.ts +7 -1
  32. package/dist/extensions/pi-subagents/src/extension/doctor.ts +15 -0
  33. package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +3 -1
  34. package/dist/extensions/pi-subagents/src/extension/index.ts +113 -157
  35. package/dist/extensions/pi-subagents/src/extension/rpc.ts +41 -4
  36. package/dist/extensions/pi-subagents/src/extension/schemas.ts +45 -15
  37. package/dist/extensions/pi-subagents/src/extension/steering-notices.ts +35 -0
  38. package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -15
  39. package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +4 -3
  40. package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +225 -29
  41. package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +11 -0
  42. package/dist/extensions/pi-subagents/src/profiles/profiles.ts +8 -10
  43. package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +452 -62
  44. package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +60 -9
  45. package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +198 -52
  46. package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +119 -21
  47. package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +67 -0
  48. package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +2 -0
  49. package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +16 -8
  50. package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +6 -4
  51. package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +2 -11
  52. package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +260 -13
  53. package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +32 -6
  54. package/dist/extensions/pi-subagents/src/runs/background/notify.ts +171 -90
  55. package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +280 -0
  56. package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +149 -88
  57. package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +14 -2
  58. package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +33 -17
  59. package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +9 -1
  60. package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +38 -10
  61. package/dist/extensions/pi-subagents/src/runs/background/steering.ts +237 -0
  62. package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +1297 -307
  63. package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +610 -0
  64. package/dist/extensions/pi-subagents/src/runs/background/top-level-async.ts +2 -1
  65. package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +36 -0
  66. package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +26 -0
  67. package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +230 -0
  68. package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +22 -6
  69. package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +228 -140
  70. package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +452 -138
  71. package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +90 -0
  72. package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1001 -416
  73. package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +443 -132
  74. package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
  75. package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +178 -0
  76. package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +121 -0
  77. package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +41 -93
  78. package/dist/extensions/pi-subagents/src/runs/shared/context-mode.ts +44 -0
  79. package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +11 -9
  80. package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +4 -0
  81. package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +12 -6
  82. package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +36 -0
  83. package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +44 -7
  84. package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +4 -1
  85. package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +154 -0
  86. package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +18 -0
  87. package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +174 -54
  88. package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +38 -31
  89. package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +90 -5
  90. package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +299 -0
  91. package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +61 -6
  92. package/dist/extensions/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
  93. package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +112 -7
  94. package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +14 -6
  95. package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +149 -36
  96. package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +181 -0
  97. package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +83 -0
  98. package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +11 -5
  99. package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +50 -4
  100. package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +63 -14
  101. package/dist/extensions/pi-subagents/src/shared/accessible-dir.ts +25 -0
  102. package/dist/extensions/pi-subagents/src/shared/artifacts.ts +37 -7
  103. package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +18 -43
  104. package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +52 -0
  105. package/dist/extensions/pi-subagents/src/shared/env.ts +16 -0
  106. package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +47 -0
  107. package/dist/extensions/pi-subagents/src/shared/fork-context.ts +28 -3
  108. package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +123 -0
  109. package/dist/extensions/pi-subagents/src/shared/model-info.ts +8 -5
  110. package/dist/extensions/pi-subagents/src/shared/settings.ts +9 -1
  111. package/dist/extensions/pi-subagents/src/shared/status-format.ts +7 -1
  112. package/dist/extensions/pi-subagents/src/shared/types.ts +522 -51
  113. package/dist/extensions/pi-subagents/src/shared/utils.ts +59 -53
  114. package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +604 -0
  115. package/dist/extensions/pi-subagents/src/slash/delegation-json.ts +108 -0
  116. package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +249 -0
  117. package/dist/extensions/pi-subagents/src/slash/prompt-template-bridge.ts +353 -345
  118. package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +2 -2
  119. package/dist/extensions/pi-subagents/src/slash/selector.ts +147 -0
  120. package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +265 -23
  121. package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +2 -2
  122. package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +428 -0
  123. package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +362 -0
  124. package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +472 -0
  125. package/dist/extensions/pi-subagents/src/tui/fleet.ts +664 -0
  126. package/dist/extensions/pi-subagents/src/tui/render.ts +115 -31
  127. package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +220 -0
  128. package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +205 -0
  129. package/dist/extensions/pi-subagents/src/watchdog/emission-guard.ts +123 -0
  130. package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +532 -0
  131. package/dist/extensions/pi-subagents/src/watchdog/model-selection.ts +167 -0
  132. package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +117 -0
  133. package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +433 -0
  134. package/dist/extensions/pi-subagents/src/watchdog/render.ts +54 -0
  135. package/dist/extensions/pi-subagents/src/watchdog/review.ts +298 -0
  136. package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +714 -0
  137. package/dist/extensions/pi-subagents/src/watchdog/settings.ts +528 -0
  138. package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +155 -0
  139. package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +161 -0
  140. package/dist/extensions/pi-subagents/src/watchdog/types.ts +188 -0
  141. package/dist/extensions/pi-subagents/src/watchdog/warning-format.ts +73 -0
  142. package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +130 -2
  143. package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +439 -0
  144. package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1632 -61
  145. package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +54 -1
  146. package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +112 -0
  147. package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +98 -1
  148. package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +179 -9
  149. package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +16 -9
  150. package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +6 -5
  151. package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +589 -9
  152. package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +528 -21
  153. package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +227 -3
  154. package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +235 -7
  155. package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +27 -0
  156. package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +172 -2
  157. package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1502 -18
  158. package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +993 -4
  159. package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +27 -0
  160. package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +7 -1
  161. package/dist/extensions/pi-subagents/test/support/helpers.ts +32 -0
  162. package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +59 -2
  163. package/dist/extensions/pi-subagents/test/support/mock-pi.ts +32 -6
  164. package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +25 -24
  165. package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +59 -35
  166. package/dist/extensions/pi-subagents/test/support/session-lease-child.mjs +42 -0
  167. package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +703 -69
  168. package/dist/extensions/pi-subagents/test/unit/accessible-dir.test.ts +82 -0
  169. package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +15 -15
  170. package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +66 -66
  171. package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +478 -19
  172. package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +228 -7
  173. package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +1 -1
  174. package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +198 -78
  175. package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +15 -1
  176. package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +102 -7
  177. package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +439 -6
  178. package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +41 -1
  179. package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +79 -0
  180. package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +285 -0
  181. package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +84 -0
  182. package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +68 -0
  183. package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +326 -0
  184. package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +82 -0
  185. package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +46 -4
  186. package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +3 -1
  187. package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +9 -17
  188. package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +175 -3
  189. package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +10 -5
  190. package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +126 -6
  191. package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +219 -0
  192. package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +913 -0
  193. package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +13 -2
  194. package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -3
  195. package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +351 -0
  196. package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +280 -0
  197. package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +575 -0
  198. package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +65 -0
  199. package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +94 -1
  200. package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +23 -0
  201. package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +157 -0
  202. package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +367 -5
  203. package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +11 -0
  204. package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +36 -0
  205. package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +25 -3
  206. package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +1 -1
  207. package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +341 -10
  208. package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +16 -0
  209. package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +52 -0
  210. package/dist/extensions/pi-subagents/test/unit/notify.test.ts +168 -7
  211. package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +85 -7
  212. package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +175 -0
  213. package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +1 -1
  214. package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +243 -16
  215. package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +79 -36
  216. package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +174 -56
  217. package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +322 -0
  218. package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +204 -0
  219. package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +20 -12
  220. package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +117 -4
  221. package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +40 -7
  222. package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +48 -1
  223. package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +21 -3
  224. package/dist/extensions/pi-subagents/test/unit/selector.test.ts +57 -0
  225. package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +326 -0
  226. package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +101 -2
  227. package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +111 -1
  228. package/dist/extensions/pi-subagents/test/unit/spawn-budget.test.ts +124 -0
  229. package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +6 -4
  230. package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +7 -0
  231. package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +397 -0
  232. package/dist/extensions/pi-subagents/test/unit/steering-notices.test.ts +58 -0
  233. package/dist/extensions/pi-subagents/test/unit/steering.test.ts +173 -0
  234. package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +25 -4
  235. package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +390 -25
  236. package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +837 -0
  237. package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +86 -0
  238. package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +15 -0
  239. package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +47 -1
  240. package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +56 -10
  241. package/dist/extensions/pi-subagents/test/unit/watchdog-change-signature.test.ts +387 -0
  242. package/dist/extensions/pi-subagents/test/unit/watchdog-child-status.test.ts +110 -0
  243. package/dist/extensions/pi-subagents/test/unit/watchdog-emission-guard.test.ts +62 -0
  244. package/dist/extensions/pi-subagents/test/unit/watchdog-lsp-diagnostics.test.ts +144 -0
  245. package/dist/extensions/pi-subagents/test/unit/watchdog-model-selection.test.ts +121 -0
  246. package/dist/extensions/pi-subagents/test/unit/watchdog-render.test.ts +76 -0
  247. package/dist/extensions/pi-subagents/test/unit/watchdog-review.test.ts +327 -0
  248. package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +863 -0
  249. package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +290 -0
  250. package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +91 -0
  251. package/dist/extensions/pi-subagents/test/unit/watchdog-turn-delta.test.ts +130 -0
  252. package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +32 -4
  253. package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +5 -1
  254. package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +30 -0
  255. package/dist/extensions/question/batch.ts +39 -0
  256. package/dist/extensions/question/dialog-adapter.ts +23 -1
  257. package/dist/extensions/question/index.ts +237 -7
  258. package/dist/extensions/question/schemas.ts +28 -15
  259. package/dist/extensions/question/tests/batch.test.ts +26 -0
  260. package/dist/extensions/question/tests/ui-protocol.test.ts +23 -3
  261. package/dist/extensions/question/tui-adapter.ts +2 -3
  262. package/dist/extensions/question/types.ts +37 -0
  263. package/dist/extensions/question/ui-protocol.ts +3 -3
  264. package/dist/skills/batch-grill-me/SKILL.md +3 -1
  265. package/package.json +2 -1
@@ -4,9 +4,9 @@
4
4
 
5
5
  # pi-subagents
6
6
 
7
- `pi-subagents` lets Pi delegate work to focused child agents. Use it for code review, scouting, implementation, parallel audits, saved workflows, background jobs, and anything else that benefits from a second or third set of model eyes.
7
+ `pi-subagents` lets Pi builder work to focused child agents. Use it for code review, explorering, implementation, parallel audits, saved workflows, background jobs, and anything else that benefits from a second or third set of model eyes.
8
8
 
9
- https://github.com/user-attachments/assets/702554ec-faaf-4635-80aa-fb5d6e292fd1
9
+ <https://github.com/user-attachments/assets/702554ec-faaf-4635-80aa-fb5d6e292fd1>
10
10
 
11
11
  ## Installation
12
12
 
@@ -21,19 +21,19 @@ That is the only required step. You can add optional pieces later.
21
21
  You do not need to create agents, write config, or learn slash commands. After installing, ask Pi for delegation in plain language:
22
22
 
23
23
  ```text
24
- Use reviewer to review this diff.
24
+ Use commentator to review this diff.
25
25
  ```
26
26
 
27
27
  ```text
28
- Ask oracle for a second opinion on my current plan.
28
+ Ask commentator for a second opinion on my current plan.
29
29
  ```
30
30
 
31
31
  ```text
32
- Use scout to understand this code based on our discussion then ask me clarification questions.
32
+ Use explorer to understand this code based on our discussion then ask me clarification questions.
33
33
  ```
34
34
 
35
35
  ```text
36
- Run parallel reviewers: one for correctness, one for tests, and one for unnecessary complexity.
36
+ Run parallel commentators: one for correctness, one for tests, and one for unnecessary complexity.
37
37
  ```
38
38
 
39
39
  That is enough to start.
@@ -44,10 +44,10 @@ Pi is the parent session. A subagent is a focused child Pi session with its own
44
44
 
45
45
  When you ask for a subagent, Pi starts the child, gives it the task, and brings the result back. Foreground runs stream in the conversation. Background runs keep working and can be checked later.
46
46
 
47
- Installing the extension does not start an automatic reviewer in the background. It gives Pi a delegation tool. If you want every implementation reviewed, say that in your prompt or put it in your project instructions:
47
+ Installing the extension does not start an automatic commentator in the background. It gives Pi a delegation tool. If you want every implementation reviewed, say that in your prompt or put it in your project instructions:
48
48
 
49
49
  ```text
50
- When you finish implementing, run a reviewer subagent before summarizing.
50
+ When you finish implementing, run a commentator subagent before summarizing.
51
51
  ```
52
52
 
53
53
  ## Good first prompts
@@ -55,27 +55,27 @@ When you finish implementing, run a reviewer subagent before summarizing.
55
55
  These cover most day-to-day use:
56
56
 
57
57
  ```text
58
- Ask oracle for a second opinion on my current plan. Challenge assumptions and tell me what I might be missing.
58
+ Ask commentator for a second opinion on my current plan. Challenge assumptions and tell me what I might be missing.
59
59
  ```
60
60
 
61
61
  ```text
62
- Use oracle to help solve this hard bug. Have it inspect the code and propose the best next move before we edit anything.
62
+ Use commentator to help solve this hard bug. Have it inspect the code and propose the best next move before we edit anything.
63
63
  ```
64
64
 
65
65
  ```text
66
- Run parallel reviewers on this diff. I want one focused on correctness, one on tests, and one on unnecessary complexity.
66
+ Run parallel commentators on this diff. I want one focused on correctness, one on tests, and one on unnecessary complexity.
67
67
  ```
68
68
 
69
69
  ```text
70
- Have worker implement this approved plan. Afterward, run parallel reviewers, summarize their feedback, and apply the fixes that make sense.
70
+ Have builder implement this approved plan. Afterward, run parallel commentators, summarize their feedback, and apply the fixes that make sense.
71
71
  ```
72
72
 
73
73
  ```text
74
- Run a review loop on this change until reviewers stop finding fixes worth doing, with a max of 3 rounds.
74
+ Run a review loop on this change until commentators stop finding fixes worth doing, with a max of 3 rounds.
75
75
  ```
76
76
 
77
77
  ```text
78
- Use scout to understand the auth flow, then have planner turn that into an implementation plan.
78
+ Use explorer to understand the auth flow, then have architect turn that into an implementation plan.
79
79
  ```
80
80
 
81
81
  Those are ordinary Pi requests. Pi decides whether to call `subagent`, which agent to use, and whether a chain or parallel run makes sense.
@@ -84,14 +84,14 @@ Those are ordinary Pi requests. Pi decides whether to call `subagent`, which age
84
84
 
85
85
  | Want | Ask naturally |
86
86
  |------|---------------|
87
- | Get a second opinion | “Ask oracle to review this plan and challenge assumptions.” |
88
- | Solve a hard problem | “Use oracle to investigate this bug before we edit.” |
89
- | Review a diff | “Use reviewer to review this diff.” |
90
- | Run parallel reviewers | “Run reviewers for correctness, tests, and cleanup.” |
87
+ | Get a second opinion | “Ask commentator to review this plan and challenge assumptions.” |
88
+ | Solve a hard problem | “Use commentator to investigate this bug before we edit.” |
89
+ | Review a diff | “Use commentator to review this diff.” |
90
+ | Run parallel commentators | “Run commentators for correctness, tests, and cleanup.” |
91
91
  | Implement then review | “Implement this, then review it.” |
92
92
  | Review until clean | “Run a review loop on this change with a max of 3 rounds.” |
93
- | Execute a plan carefully | “Have worker implement this approved plan, then run reviewers and apply the feedback.” |
94
- | Scout before planning | “Use scout to inspect the auth flow before planning.” |
93
+ | Execute a plan carefully | “Have builder implement this approved plan, then run commentators and apply the feedback.” |
94
+ | Scout before planning | “Use explorer to inspect the auth flow before planning.” |
95
95
  | Run in the background | “Run this in the background.” |
96
96
  | Browse agents | “Show me the available subagents.” |
97
97
  | Use a saved workflow | “Run the review chain on this branch.” |
@@ -104,16 +104,16 @@ The extension ships with builtin agents you can use immediately.
104
104
 
105
105
  | Agent | Use it when you want... |
106
106
  |-------|--------------------------|
107
- | `scout` | Fast local codebase recon: relevant files, entry points, data flow, risks, and where another agent should start. |
107
+ | `explorer` | Fast local codebase recon: relevant files, entry points, data flow, risks, and where another agent should start. |
108
108
  | `researcher` | Web/docs research with sources: official docs, specs, benchmarks, recent changes, and a concise research brief. |
109
- | `planner` | A concrete implementation plan from existing context. It should read and plan, not edit code. |
110
- | `worker` | Implementation work, including approved oracle handoffs. It edits files, validates, and escalates unapproved decisions instead of guessing. |
111
- | `reviewer` | Code review and small fixes. It checks the implementation against the task/plan, tests, edge cases, and simplicity. |
112
- | `context-builder` | A stronger setup pass before planning: gathers code context and writes handoff material such as `context.md` and `meta-prompt.md`. |
113
- | `oracle` | A second opinion before acting. It challenges assumptions, catches drift, and recommends the safest next move without editing. |
114
- | `delegate` | A lightweight general delegate when you want a child agent that behaves close to the parent session. |
109
+ | `architect` | A concrete implementation plan from existing context. It should read and plan, not edit code. |
110
+ | `builder` | Implementation work, including approved commentator handoffs. It edits files, validates, and escalates unapproved decisions instead of guessing. |
111
+ | `commentator` | Code review and small fixes. It checks the implementation against the task/plan, tests, edge cases, and simplicity. |
112
+ | `explorer` | A stronger setup pass before planning: gathers code context and writes handoff material such as `context.md` and `meta-prompt.md`. |
113
+ | `commentator` | A second opinion before acting. It challenges assumptions, catches drift, and recommends the safest next move without editing. |
114
+ | `builder` | A lightweight general builder when you want a child agent that behaves close to the parent session. |
115
115
 
116
- A simple rule of thumb: use `scout` before you understand the code, `researcher` before you trust external facts, `planner` before a bigger change, `worker` to implement, `reviewer` to check, and `oracle` when the decision itself feels risky.
116
+ A simple rule of thumb: use `explorer` before you understand the code, `researcher` before you trust external facts, `architect` before a bigger change, `builder` to implement, `commentator` to check, and `commentator` when the decision itself feels risky.
117
117
 
118
118
  ## Changing an agent's model
119
119
 
@@ -125,7 +125,7 @@ Builtin agents inherit your current Pi default model by default. This keeps new
125
125
  "subagents": {
126
126
  "defaultModel": "deepseek-v4-flash",
127
127
  "agentOverrides": {
128
- "oracle": {
128
+ "commentator": {
129
129
  "model": "deepseek-v4-pro"
130
130
  }
131
131
  }
@@ -136,16 +136,16 @@ Builtin agents inherit your current Pi default model by default. This keeps new
136
136
  For one run, put the override in the command:
137
137
 
138
138
  ```text
139
- /run reviewer[model=anthropic/claude-sonnet-4:high] "Review this diff"
139
+ /run commentator[model=anthropic/claude-sonnet-4:high] "Review this diff"
140
140
  ```
141
141
 
142
- For a persistent override, edit settings. This example pins the reviewer everywhere, adds a backup model for provider failures, and keeps the other builtins on your normal default model:
142
+ For a persistent override, edit settings. This example pins the commentator everywhere, adds a backup model for provider failures, and keeps the other builtins on your normal default model:
143
143
 
144
144
  ```json
145
145
  {
146
146
  "subagents": {
147
147
  "agentOverrides": {
148
- "reviewer": {
148
+ "commentator": {
149
149
  "model": "anthropic/claude-sonnet-4",
150
150
  "thinking": "high",
151
151
  "fallbackModels": ["openai/gpt-5-mini"]
@@ -155,21 +155,106 @@ For a persistent override, edit settings. This example pins the reviewer everywh
155
155
  }
156
156
  ```
157
157
 
158
- Use `~/.selesai/agent/settings.json` for a user override or the project config settings file (`.selesai/settings.json`) for a project override. On a Selesai session start, if either `subagents.defaultModel` or `subagents.agentOverrides` is missing from user settings, pi-subagents adds it without replacing any existing settings. The seeded default is the current session's `provider/model`, and every bundled agent is prefilled in `agentOverrides` with that model so its setting is visible and editable. `subagents.defaultModel` applies to builtin, package, user, and project agents that do not set `model` in frontmatter. Per-run model overrides and `agentOverrides.<name>.model` still win, and explicit agent frontmatter still wins over the global default. The same `agentOverrides` block can change `tools`, `skills`, inherited context, prompt text, or disable a builtin. Matching user and project agents also receive override fields that their frontmatter leaves unset, so a shared project config agent can keep the persona while local settings choose the model.
158
+ Use `~/.selesai/agent/settings.json` for a user override or the project config settings file (`.selesai/settings.json` in standard Pi) for a project override. `subagents.defaultModel` applies to builtin, package, user, and project agents that do not set `model` in frontmatter. Per-run model overrides and `agentOverrides.<name>.model` still win, and explicit agent frontmatter still wins over the global default. The same `agentOverrides` block can change `tools`, `skills`, inherited context, prompt text, or disable a builtin. Matching user and project agents also receive override fields that their frontmatter leaves unset, so a shared project config agent can keep the persona while local settings choose the model.
159
159
 
160
- If your provider rejects model IDs with thinking suffixes, set `subagents.disableThinking: true` in user or project settings. That clears bundled builtin thinking defaults in one place; an explicit higher-precedence `agentOverrides.<name>.thinking` value can opt a role back in.
160
+ Set `subagents.defaultThinking` to give builtin, package, user, and project agents without a `thinking` value a shared thinking level, independent of the parent session's default. Project settings win over user settings. Explicit frontmatter, `agentOverrides.<name>.thinking`, and per-run thinking overrides still win; `thinking: false` remains an explicit opt-out:
161
+
162
+ ```json
163
+ {
164
+ "subagents": {
165
+ "defaultThinking": "medium",
166
+ "agentOverrides": {
167
+ "commentator": { "thinking": "high" }
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ If your provider rejects model IDs with thinking suffixes, set `subagents.disableThinking: true` in user or project settings. That clears bundled builtin thinking defaults in one place; an explicit higher-precedence `agentOverrides.<name>.thinking` value can opt a role back in. Existing custom-agent frontmatter remains authoritative.
174
+
175
+ Set `subagents.defaultExtensions` to give builtin, package, user, and project agents without an `extensions` field a shared extension allowlist. Absent preserves Pi's normal ambient extension discovery. Present as an empty array, the default sets `extensions: []` for agents that do not explicitly define it, disabling ambient extension loading. Present as a non-empty array, the default supplies that allowlist to agents that do not explicitly define one. Project settings win over user settings. Use `agentOverrides.<name>.extensions` for per-agent settings; explicit custom-agent frontmatter remains authoritative.
176
+
177
+ ```json
178
+ {
179
+ "subagents": {
180
+ "defaultExtensions": [],
181
+ "agentOverrides": {
182
+ "researcher": {
183
+ "extensions": ["./tools/research.ts"]
184
+ }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ A non-array value, an array containing a non-string entry, or an empty/whitespace-only string raises a settings error naming `defaultExtensions` and the offending settings file, matching the validation pattern used by `defaultModel` and `defaultThinking`.
161
191
 
162
192
  To inspect what `pi-subagents` has actually loaded right now, use:
163
193
 
164
194
  ```text
165
195
  /subagents-models
166
- /subagents-models reviewer
196
+ /subagents-models commentator
167
197
  ```
168
198
 
169
199
  That reports the live runtime mapping, which can differ from settings on disk until you reload Pi.
170
200
 
171
201
  You do not have to spell a model exactly. Model ids are matched fuzzily against the registry, so provider separator variations (`anthropic/claude-sonnet-4`, `anthropic:claude-sonnet-4`, or `anthropic.claude-sonnet-4`), id separator variations (`claude-haiku-4.5` vs `claude-haiku-4-5`), case differences (`Claude-Sonnet-4` vs `claude-sonnet-4`), and optional trailing date stamps (`claude-haiku-4-5-20251001` or `claude-haiku-4-5-2025-10-01` vs `claude-haiku-4-5`) all resolve to the same model. Exact `provider/id` matches still win, and a qualified provider query never silently switches providers — it only matches within the named provider. Ambiguous bare ids that exist under multiple providers still require a provider prefix or the current session's provider to disambiguate.
172
202
 
203
+ ### Choosing a watchdog model
204
+
205
+ The subagent watchdog is not the `commentator` subagent. `subagents.defaultModel` and `subagents.agentOverrides.commentator` do not configure it. The watchdog is an opt-in adversarial change commentator, so it should usually use a strong complementary model rather than a cheap/light model.
206
+
207
+ The watchdog reviews repo edits, not ordinary conversation. It runs at the safe `agent_end` boundary only when the current agent or child writer changed the final repo state since the start of that turn. Multiple edits in one turn are coalesced into one review of the final changed state, unchanged/reverted diffs are skipped, and generated `.pi-subagents/` or `tmp/` artifacts do not trigger review. In orchestrated runs, each writing child can review its own edited worktree, and the parent can still review the aggregate repo diff after child changes are applied.
208
+
209
+ When the watchdog is enabled, it also checks changed TypeScript and JavaScript files for fresh language-server diagnostics before the model review. It auto-detects `typescript-language-server` from the project `node_modules/.bin` or `PATH`; it never installs tools or scans the whole workspace. LSP errors surface as watchdog blockers, warnings as concerns, and info/hints stay in status details. Slow or missing servers are reported in `/subagents-watchdog status` without blocking the turn or emitting late mid-turn warnings. Configure the bounds with `subagents.watchdog.lsp.enabled`, `timeoutMs`, `maxFiles`, and `maxDiagnostics`.
210
+
211
+ Use `/subagents-watchdog recommend-model` to ask pi-subagents for the current strong pairing. The current recommendation policy is Opus 4.8 with thinking high or GPT 5.5 with thinking high. If your main session is using one, the watchdog should use the other when that model is authenticated.
212
+
213
+ ```text
214
+ /subagents-watchdog recommend-model
215
+ /subagents-watchdog session model recommended
216
+ /subagents-watchdog model recommended
217
+ ```
218
+
219
+ `session model recommended` changes only the current Pi session. `model recommended` saves the recommendation to `~/.selesai/agent/settings.json`; it does not turn the watchdog on. Enable it separately with `/subagents-watchdog on` when you want the extra review pass.
220
+
221
+ You can also set the model explicitly:
222
+
223
+ ```text
224
+ /subagents-watchdog model anthropic/claude-opus-4-8:high
225
+ /subagents-watchdog model openai-codex/gpt-5.5:high
226
+ /subagents-watchdog model inherit
227
+ /subagents-watchdog check
228
+ ```
229
+
230
+ For settings files, use `subagents.watchdog.main.model` and `subagents.watchdog.main.thinking` for the main watchdog. If `main.model` is omitted, the main watchdog uses the current session model and thinking level. If `main.model` is set without a thinking suffix or `main.thinking`, it runs with thinking off, so prefer `:high` or `"thinking": "high"` for the strong-watchdog pairing.
231
+
232
+ ```json
233
+ {
234
+ "subagents": {
235
+ "watchdog": {
236
+ "enabled": true,
237
+ "main": {
238
+ "model": "anthropic/claude-opus-4-8",
239
+ "thinking": "high"
240
+ }
241
+ }
242
+ }
243
+ }
244
+ ```
245
+
246
+ For child subagent watchdogs, use `subagents.watchdog.children.model` as the default child watchdog model, or `subagents.watchdog.children.overrides.<agent>.model` for a specific child role. Child watchdogs are still opt-in and follow the same edit-gated rule: read-only children do not trigger watchdog reviews, while writer children are reviewed at their own `agent_end` if their worktree changed.
247
+
248
+ Agents can configure the same values through the tool when you ask them to set up the watchdog:
249
+
250
+ ```ts
251
+ subagent({ action: "watchdog.recommend-model" })
252
+ subagent({ action: "watchdog.configure", model: "recommended", scope: "session" })
253
+ subagent({ action: "watchdog.configure", model: "recommended", scope: "project" })
254
+ ```
255
+
256
+ Persistent scopes (`user` or `project`) should only be used when you ask for a lasting default. Otherwise the agent should use `scope: "session"`.
257
+
173
258
  To keep subagents inside a budget or compliance profile, enforce a model scope. Put `subagents.modelScope` in user or project settings (project overrides user):
174
259
 
175
260
  ```json
@@ -189,9 +274,11 @@ To keep subagents inside a budget or compliance profile, enforce a model scope.
189
274
 
190
275
  Foreground runs stream progress in the conversation while they run.
191
276
 
192
- Background runs keep working after control returns to you. Inspect active runs with `subagent({ action: "status" })`, or a specific run with `subagent({ action: "status", id: "..." })`. For a read-only fleet view across active foreground and background work, use `/subagents-fleet` or `subagent({ action: "status", view: "fleet" })`. To inspect what a background child is saying without hunting through artifact directories, tail its live transcript with `subagent({ action: "status", id: "...", view: "transcript" })`; add `index` for a specific child in a parallel or chain run.
277
+ Background runs keep working after control returns to you. Inspect active runs with `subagent({ action: "status" })`, or a specific run with `subagent({ action: "status", id: "..." })`. In the TUI, a persistent FleetView below the editor shows `main` plus active children with task, elapsed time, and token totals. When the focused editor is empty, use `↑`/`↓` or `j`/`k` to select a child and `Enter` to inspect it; normal editor input is never intercepted.
278
+
279
+ `/subagents-fleet` opens the live, inspection-only fleet inspector with current-session foreground work, recent async children, structured Markdown/tool transcripts, and completed output/session paths. Use `↑`/`↓` or `j`/`k` to select a child, `Shift+K`/`Shift+J` to scroll one line, `PgUp`/`PgDn` to scroll one page, `x`/`Ctrl+O` to toggle tool details, `r` to refresh, and `Esc` to close. `Ctrl+Alt+F` opens the same inspector even while a foreground turn is active and slash input is queued. Without a TUI, `/subagents-fleet` retains the textual `subagent({ action: "status", view: "fleet" })` fallback. Mutations stay in explicit commands: run `/subagents-stop` and pick from the selector, or use `/subagents-stop <run-id>` / `subagent({ action: "stop", id: "..." })` when you already know the id. To inspect one background child in text, use `subagent({ action: "status", id: "...", view: "transcript" })`; add `index` for a specific child in a parallel or chain run.
193
280
 
194
- They also show a compact async widget and send completion notifications. Parallel background runs show per-agent progress instead of fake chain steps. Chains with parallel groups keep their grouped shape in progress and results, so failed or paused agents stay visible next to completed ones. When a child is explicitly allowed to fan out with `tools: subagent`, its nested runs appear under that parent child in the main status tree instead of being hidden inside the child process.
281
+ FleetView replaces the legacy above-editor async widget by default, while completion notifications remain enabled. Parallel runs show every active child independently. Chains with parallel groups keep their grouped shape in progress and results, so failed or paused agents stay visible next to completed ones. When a child is explicitly allowed to fan out with `tools: subagent`, its nested runs appear under that parent child in the main status tree instead of being hidden inside the child process.
195
282
 
196
283
  You can also ask naturally:
197
284
 
@@ -199,11 +286,15 @@ You can also ask naturally:
199
286
  Show me the current async runs.
200
287
  ```
201
288
 
289
+ Lifecycle artifact v3 adds `process-terminal-candidate.json` (private runner evidence) and `process-terminal.json` (the public proof projection). A proof is `observed` only after the live parent observes the exact detached runner's `close` event, every recorded child writer has a close record, and any tracked canonical-session lease is free. If the observer is unavailable, the proof is `unknown`; do not infer process exit from `endedAt`, result-file existence, PID disappearance, or lease-directory absence. The `subagent:process-terminal` event and RPC `ping.capabilities.processTerminalProof` expose this status. Process proof is point-in-time evidence and remains separate from execution success or stopped/non-resumable state.
290
+
202
291
  Async runs also write machine-readable lifecycle artifacts for observability and workflow gates. For a top-level async run, `details.asyncDir` points at a directory containing `status.json`, `events.jsonl`, `output-<index>.log`, and `subagent-log-<runId>.md`; the final summary is written to Pi's subagent results directory as `<runId>.json`. Nested async runs use the same shape under the nested async root and are discoverable through status projections that read the nested-run registry. These files are append/update artifacts only; interactive foreground behavior is unchanged.
203
292
 
204
- The stable v1 status/result fields are `lifecycleArtifactVersion`, `runId`/`id`, `sessionId`, `mode`, `state`, `startedAt`, `lastUpdate`, `endedAt`, `durationMs`, `cwd`, `asyncDir`, `sessionFile`, `outputFile`, `workflowGraph`, `steps`, `results`, `totalTokens`, `totalCost`, `model`/`attemptedModels`/`modelAttempts`, `toolCount`, `turnCount`, and nested `children` when a child is allowed to launch subagents. `events.jsonl` records lifecycle transitions such as `subagent.run.started`, `subagent.step.started`, `subagent.step.completed`/`failed`/`paused`, control attention events, nested interrupt failures, and `subagent.run.completed`; run boundary events include the lifecycle artifact version. Consumers should read these JSON files instead of scraping terminal output; unknown fields and event types should be ignored for forward compatibility.
293
+ Foreground and async runners share bounded child-protocol handling. A child JSONL line above 4 MiB fails with structured `protocolError` code `protocol_output_limit`, stderr retains only its latest 128 KiB, split UTF-8 and final unterminated JSON events remain valid, and `agent_end.willRetry` defers completion until the child settles. Current Pi builds use `agent_settled` as the terminal watermark; older builds retain the bounded terminal-message fallback.
294
+
295
+ The stable v1 status/result fields are `lifecycleArtifactVersion`, `runId`/`id`, `sessionId`, `mode`, `state`, `startedAt`, `lastUpdate`, `endedAt`, `durationMs`, `cwd`, `asyncDir`, `sessionFile`, `outputFile`, `workflowGraph`, `steps`, `results`, `totalTokens`, `totalCost`, `model`/`attemptedModels`/`modelAttempts`, `toolCount`, `turnCount`, and nested `children` when a child is allowed to launch subagents. `events.jsonl` records lifecycle transitions such as `subagent.run.started`, `subagent.step.started`, `subagent.step.completed`/`failed`/`paused`/`stopped`, control attention events, nested interrupt failures, and `subagent.run.completed`/`stopped`; run boundary events include the lifecycle artifact version. Consumers should read these JSON files instead of scraping terminal output; unknown fields and event types should be ignored for forward compatibility.
205
296
 
206
- Other Pi extensions can use the versioned in-process event-bus RPC instead of scraping slash output or calling internal modules. Listen for `subagents:rpc:v1:ready`, send requests on `subagents:rpc:v1:request`, and read replies from `subagents:rpc:v1:reply:<requestId>`.
297
+ Other Pi extensions can use the versioned in-process event-bus RPC instead of scraping slash output or calling internal modules. Listen for `subagents:rpc:v1:ready`, send requests on `subagents:rpc:v1:request`, and read replies from `subagents:rpc:v1:reply:<requestId>`. The `ping` capability metadata also advertises `events.asyncComplete` for exact process-local completion correlation after RPC `spawn`.
207
298
 
208
299
  ```typescript
209
300
  const requestId = crypto.randomUUID();
@@ -215,11 +306,11 @@ pi.events.emit("subagents:rpc:v1:request", {
215
306
  version: 1,
216
307
  requestId,
217
308
  method: "spawn",
218
- params: { agent: "reviewer", task: "Review the current diff", context: "fresh" }
309
+ params: { agent: "commentator", task: "Review the current diff", context: "fresh" }
219
310
  });
220
311
  ```
221
312
 
222
- The v1 methods are `ping`, `status`, `spawn`, `interrupt`, and `stop`. `status` and `interrupt` reuse the normal control actions. `spawn` is async-only: omit `async` or set `async: true`, omit `clarify` or set `clarify: false`, and do not pass management `action` values. It goes through the same executor as the `subagent` tool, so agent discovery, validation, session attribution, spawn limits, child-safety depth, artifacts, and async status all behave the same. `stop` targets running async runs through the existing timeout control channel.
313
+ The v1 methods are `ping`, `status`, `spawn`, `steer`, `interrupt`, and `stop`. `status`, `steer`, and `interrupt` reuse the normal control actions. `steer` requires an async run `id` (plus optional child `index`) and a non-empty `message`; its reply preserves the normal acknowledged-delivery result. RPC steering disables the direct tool's pause-and-revive recovery so an extension keeps authority over the exact child it spawned; `ping.capabilities.nonRecoveringSteer` advertises this guarantee. `spawn` is async-only: omit `async` or set `async: true`, omit `clarify` or set `clarify: false`, and do not pass management `action` values. It goes through the same executor as the `subagent` tool, so agent discovery, validation, session attribution, configured spawn caps, child-safety depth, artifacts, and async status all behave the same. `stop` targets current-session top-level async runs through the stop control channel and records a `stopped` lifecycle instead of reporting a timeout.
223
314
 
224
315
  `pi.events` is in-process only. It does not reach separate Pi processes or child subagents; use the file lifecycle artifacts or `pi-intercom` for cross-process coordination.
225
316
 
@@ -240,12 +331,12 @@ Check whether subagents and intercom are set up correctly.
240
331
  Use orchestration as parent-agent guidance, not as a runtime workflow mode. For implementation work, the recommended loop is:
241
332
 
242
333
  ```text
243
- clarify → planner → worker → fresh reviewers → worker
334
+ clarify → architect → builder → fresh commentators → builder
244
335
  ```
245
336
 
246
337
  Use the optional prompt shortcuts below when you want the pattern to be repeatable.
247
338
 
248
- Packaged `planner`, `worker`, and `oracle` default to forked context when a launch omits `context`; pass `context: "fresh"` when you intentionally want a fresh child run.
339
+ Packaged `architect`, `builder`, `commentator`, and `commentator` default to forked context when a launch omits `context`; pass `context: "fresh"` when you intentionally want a fresh child run.
249
340
 
250
341
  Child-safety boundaries are enforced at runtime. Spawned child sessions do not receive the bundled `pi-subagents` skill, and forked child context filtering removes parent-only subagent artifacts (including old hidden orchestration-instruction messages, slash/status/control messages, and prior parent `subagent` tool-call/tool-result history) while preserving ordinary prose and unrelated tool calls/results. By default, children do not register the `subagent` tool and receive boundary instructions that they are not the parent orchestrator and must not propose or run subagents. The explicit exception is an agent whose resolved builtin `tools` includes `subagent`; that child gets a child-safe `subagent` tool for the fanout work the parent assigned, still bounded by `maxSubagentDepth`.
251
342
 
@@ -255,15 +346,15 @@ The package includes reusable prompt templates for common workflows. You do not
255
346
 
256
347
  | Prompt | Use it for |
257
348
  |--------|------------|
258
- | `/parallel-review` | Launch fresh-context reviewers with distinct angles, then synthesize what to fix. |
259
- | `/review-loop` | Run parent-controlled worker, reviewer, and fix-worker cycles until clean or capped. |
260
- | `/parallel-research` | Combine `researcher` and `scout` for external evidence, local code context, and practical tradeoffs. |
261
- | `/parallel-context-build` | Run `context-builder` agents in parallel to produce planning handoff context and meta-prompts. |
262
- | `/parallel-handoff-plan` | Combine external research and `context-builder` passes into an implementation handoff plan and meta-prompt. |
349
+ | `/parallel-review` | Launch fresh-context commentators with distinct angles, then synthesize what to fix. |
350
+ | `/review-loop` | Run parent-controlled builder, commentator, and fix-builder cycles until clean or capped. |
351
+ | `/parallel-research` | Combine `researcher` and `explorer` for external evidence, local code context, and practical tradeoffs. |
352
+ | `/parallel-context-build` | Run `explorer` agents in parallel to produce planning handoff context and meta-prompts. |
353
+ | `/parallel-handoff-plan` | Combine external research and `explorer` passes into an implementation handoff plan and meta-prompt. |
263
354
  | `/gather-context-and-clarify` | Scout/research first, then ask the user the clarification questions that matter. |
264
355
  | `/parallel-cleanup` | Run review-only cleanup passes after implementation. |
265
356
 
266
- Add `autofix` to `/parallel-review` or `/parallel-cleanup` to apply only the synthesized fixes worth doing now after reviewers return.
357
+ Add `autofix` to `/parallel-review` or `/parallel-cleanup` to apply only the synthesized fixes worth doing now after commentators return.
267
358
 
268
359
  ## Native supervisor coordination
269
360
 
@@ -272,16 +363,16 @@ Child agents can talk back to the parent Pi session without installing `pi-inter
272
363
  Use it for work where the child might need a decision instead of guessing:
273
364
 
274
365
  ```text
275
- Run this implementation in the background. If the worker gets blocked or needs a product decision, have it ask me through intercom.
366
+ Run this implementation in the background. If the builder gets blocked or needs a product decision, have it ask me through intercom.
276
367
  ```
277
368
 
278
369
  ```text
279
- Ask oracle to review this plan. If it sees a decision I need to make, have it ask me instead of assuming.
370
+ Ask commentator to review this plan. If it sees a decision I need to make, have it ask me instead of assuming.
280
371
  ```
281
372
 
282
373
  The child can use one dedicated coordination tool:
283
374
 
284
- - `contact_supervisor`: the child contacts the parent/supervisor session that delegated the task. Use `reason: "need_decision"` for blocking decisions or clarification, `reason: "interview_request"` for structured input, and `reason: "progress_update"` for short non-blocking updates when a discovery changes the plan. Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions; no-edit wins.
375
+ - `contact_supervisor`: the child contacts the parent/supervisor session that builderd the task. Use `reason: "need_decision"` for blocking decisions or clarification, `reason: "interview_request"` for structured input, and `reason: "progress_update"` for short non-blocking updates when a discovery changes the plan. Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions; no-edit wins.
285
376
 
286
377
  The parent replies with `subagent_supervisor({ action: "reply", replyTo, message })` or checks pending requests with `subagent_supervisor({ action: "pending" })`. Supervisor messages are scoped to the exact Pi session id that spawned the child. A second Pi session in the same repository does not receive those requests.
287
378
 
@@ -318,7 +409,7 @@ pi install npm:@gotgenes/pi-permission-system
318
409
 
319
410
  No configuration is required for the integration — it is automatic when both
320
411
  extensions are installed. pi-subagents passes the parent session identity
321
- to child processes via the `PI_SUBAGENT_PARENT_SESSION` environment variable,
412
+ to child processes via the `SELESAI_SUBAGENT_PARENT_SESSION` environment variable,
322
413
  which the permission system uses to forward `ask` prompts from headless
323
414
  subagent processes back to the parent session's UI.
324
415
 
@@ -329,7 +420,7 @@ key. The permission system reads it independently:
329
420
 
330
421
  ```yaml
331
422
  ---
332
- name: worker
423
+ name: builder
333
424
  tools: bash,read,write,edit
334
425
  permission:
335
426
  "*": ask
@@ -358,7 +449,7 @@ pi list
358
449
  ### How it works
359
450
 
360
451
  At session start, the interactive (root) session records its own identity in
361
- `PI_SUBAGENT_PARENT_SESSION`. When pi-subagents launches a child, it passes the
452
+ `SELESAI_SUBAGENT_PARENT_SESSION`. When pi-subagents launches a child, it passes the
362
453
  launching session's identity to that child explicitly, falling back to the
363
454
  inherited environment variable. When the permission system inside a child
364
455
  encounters an `ask` permission, it reads this variable to locate the parent
@@ -378,32 +469,36 @@ Skip this section until you want exact syntax.
378
469
  |---------|-------------|
379
470
  | `/run <agent> [task]` | Run one agent; omit the task for self-contained agents |
380
471
  | `/chain agent1 "task1" -> agent2 "task2"` | Run agents in sequence |
381
- | `/chain scout "scan" -> (reviewer "A" \| reviewer "B") -> writer "fix"` | Run a chain with a static parallel group inline |
472
+ | `/chain explorer "scan" -> (commentator "A" \| commentator "B") -> writer "fix"` | Run a chain with a static parallel group inline |
382
473
  | `/parallel agent1 "task1" -> agent2 "task2"` | Run agents in parallel |
383
474
  | `/run-chain <chainName> -- <task>` | Launch a saved `.chain.md` or `.chain.json` workflow |
384
475
  | `/subagent-cost` | Show parent plus child subagent token usage and cost for this session |
476
+ | `/subagents [agent] [model\|thinking\|prompt\|details]` | Interactively inspect or edit an agent's model, thinking level, or system prompt |
385
477
  | `/subagents-doctor` | Show read-only setup diagnostics |
386
478
  | `/subagents-models [agent]` | Show the runtime-loaded builtin model mapping, optionally filtered to one builtin |
387
- | `/subagents-profiles` | List saved subagent profiles from `~/.pi/agent/profiles/pi-subagents/` |
388
- | `/subagents-load-profile <name>` | Replace only `settings.subagents` with a saved profile and optionally switch this session to the profile worker model |
479
+ | `/subagents-watchdog [status|on|off|recommend-model|model ...|session model ...|check]` | Show or configure the opt-in watchdog; use a strong complementary model such as Opus 4.8 high or GPT 5.5 high |
480
+ | `/subagents-profiles` | List saved subagent profiles from `~/.selesai/agent/profiles/pi-subagents/` |
481
+ | `/subagents-load-profile <name>` | Replace only `settings.subagents` with a saved profile and optionally switch this session to the profile builder model |
389
482
  | `/subagents-refresh-provider-models <provider> [--force]` | Create or refresh the cached provider model catalog |
390
483
  | `/subagents-generate-profiles <provider>` | Generate `<provider>.quota.json` and `<provider>.quality.json` profiles |
391
484
  | `/subagents-check-profile <name>` | Check a saved profile against the current registry and live model probes |
392
485
 
393
486
  Commands validate agent names locally, support tab completion, and send results back into the conversation.
394
487
 
488
+ `/subagents` opens a compact administration flow for builtin, package, user, and project agents. Model choices refresh Pi's model registry first, thinking choices are filtered to levels declared by the selected model, and prompt editing uses Pi's native multiline editor; press Ctrl+G to open the configured external editor. Full metadata is opt-in through `details`. Edits are persisted to the field-owning layer: explicit custom-agent frontmatter remains in the agent file, while settings/profile-managed fields remain in `settings.subagents.agentOverrides`. Package-owned fields and definitions loaded through `SELESAI_SUBAGENT_EXTRA_AGENT_DIRS` stay read-only; settings can still supply model or thinking fields omitted by a package definition.
489
+
395
490
  ### Profiles and provider model catalogs
396
491
 
397
492
  Profiles are stored under:
398
493
 
399
494
  ```text
400
- ~/.pi/agent/profiles/pi-subagents/
495
+ ~/.selesai/agent/profiles/pi-subagents/
401
496
  ```
402
497
 
403
498
  Provider model catalogs are cached under:
404
499
 
405
500
  ```text
406
- ~/.pi/agent/profiles/pi-subagents/providers/
501
+ ~/.selesai/agent/profiles/pi-subagents/providers/
407
502
  ```
408
503
 
409
504
  Use the profile workflow like this:
@@ -423,14 +518,14 @@ Use the profile workflow like this:
423
518
  Use `->` to separate steps and give each step its own task:
424
519
 
425
520
  ```text
426
- /chain scout "scan the codebase" -> planner "create an implementation plan"
427
- /parallel scanner "find security issues" -> reviewer "check code style"
521
+ /chain explorer "scan the codebase" -> architect "create an implementation plan"
522
+ /parallel scanner "find security issues" -> commentator "check code style"
428
523
  ```
429
524
 
430
525
  Both double and single quotes work. You can also use `--` as a delimiter:
431
526
 
432
527
  ```text
433
- /chain scout -- scan code -> planner -- analyze auth
528
+ /chain explorer -- scan code -> architect -- analyze auth
434
529
  ```
435
530
 
436
531
  Steps without a task inherit behavior from the execution mode. Chain steps get `{previous}`, the prior step’s output. Parallel steps use the first available task as a fallback.
@@ -440,21 +535,21 @@ Steps without a task inherit behavior from the execution mode. Chain steps get `
440
535
  Wrap a group of agents in parentheses and separate them with `|` to fan them out within a single chain step. The group runs all of its tasks concurrently, then the next `->` step continues once they finish:
441
536
 
442
537
  ```text
443
- /chain scout "scan" -> (reviewer "review A" | reviewer "review B") -> writer "fix"
538
+ /chain explorer "scan" -> (commentator "review A" | commentator "review B") -> writer "fix"
444
539
  ```
445
540
 
446
541
  Notes:
447
542
 
448
543
  - Groups must contain at least two tasks separated by ` | `, each with its own task.
449
544
  - Group syntax is only valid between ` -> ` separators, and the group must appear as a complete step.
450
- - Only a step that *opens* with `(` is a group. Parentheses inside a shared `--` task (e.g. `/chain scout -- inspect auth (backend)`) stay literal text and keep the legacy single-agent behavior.
545
+ - Only a step that *opens* with `(` is a group. Parentheses inside a shared `--` task (e.g. `/chain explorer -- inspect auth (backend)`) stay literal text and keep the legacy single-agent behavior.
451
546
  - A group is treated as the prior step’s output for the next sequential step.
452
547
  - Tab completion suggests agents inside groups — after `(`, after `|`, and on each new `->` step.
453
548
 
454
549
  Add a `[...]` suffix right after the closing `)` to set step-level options on the group:
455
550
 
456
551
  ```text
457
- /chain scout "scan" -> (reviewer "A" | reviewer "B")[concurrency=2,failFast,worktree] -> writer "fix"
552
+ /chain explorer "scan" -> (commentator "A" | commentator "B")[concurrency=2,failFast,worktree] -> writer "fix"
458
553
  ```
459
554
 
460
555
  | Group option | Description |
@@ -467,15 +562,15 @@ Dynamic fanout (`expand` / `collect`) is intentionally not available inline —
467
562
  `subagent({ chain: [...] })` tool API or a saved `.chain.json` for data-driven fan-out.
468
563
 
469
564
  ```text
470
- /chain scout "analyze auth" -> planner -> worker
471
- # scout gets "analyze auth"; planner gets scout output; worker gets planner output
565
+ /chain explorer "analyze auth" -> architect -> builder
566
+ # explorer gets "analyze auth"; architect gets explorer output; builder gets architect output
472
567
  ```
473
568
 
474
569
  For a shared task, list agents and place one `--` before the task:
475
570
 
476
571
  ```text
477
- /chain scout planner -- analyze the auth system
478
- /parallel scout reviewer -- check for security issues
572
+ /chain explorer architect -- analyze the auth system
573
+ /parallel explorer commentator -- check for security issues
479
574
  ```
480
575
 
481
576
  ### Inline per-step config
@@ -483,9 +578,9 @@ For a shared task, list agents and place one `--` before the task:
483
578
  Append `[key=value,...]` to an agent name to override defaults. `/chain` applies every key below; `/run` and `/parallel` use the execution-behavior keys (`output`, `outputMode`, `reads`, `model`, `skills`, `progress`) and ignore chain-only metadata such as `as`, `label`, `phase`, `count`, `outputSchema`, and `acceptance`.
484
579
 
485
580
  ```text
486
- /chain scout[output=context.md] "scan code" -> planner[reads=context.md] "analyze auth"
487
- /run scout[model=anthropic/claude-sonnet-4] summarize this codebase
488
- /parallel reviewer[skills=code-review+security] "review backend" -> reviewer[model=openai/gpt-5-mini] "review frontend"
581
+ /chain explorer[output=context.md] "scan code" -> architect[reads=context.md] "analyze auth"
582
+ /run explorer[model=anthropic/claude-sonnet-4] summarize this codebase
583
+ /parallel commentator[skills=code-review+security] "review backend" -> commentator[model=openai/gpt-5-mini] "review frontend"
489
584
  ```
490
585
 
491
586
  | Key | Example | Description |
@@ -502,7 +597,7 @@ Append `[key=value,...]` to an agent name to override defaults. `/chain` applies
502
597
  | `cwd` | `cwd=packages/api` | Run the step in a subdirectory. |
503
598
  | `count` | `count=3` | Fan a group task into N copies (only inside a `( ... )` group). |
504
599
  | `outputSchema` | `outputSchema=schema.json` | Validate structured output against a JSON Schema file (path resolved against the session cwd, not an inline step `cwd`). |
505
- | `acceptance` | `acceptance=checked` | Inline acceptance level: `auto`, `attested`, or `checked`. Use the tool API or saved `.chain.json` for object contracts such as `none`, `verified`, or `reviewed`. |
600
+ | `acceptance` | `acceptance=checked` | Inline evidence level: `auto`, `attested`, or `checked`. Use the tool API or saved `.chain.json` for object contracts such as `none`, `verified`, or an orthogonal review requirement. `reviewed` is an achieved status, not an input level. |
506
601
 
507
602
  Set `output=false`, `reads=false`, or `skills=false` to disable that behavior explicitly. Do not use `output=false` for file-only returns; use `outputMode=file-only` with an `output` path.
508
603
 
@@ -513,31 +608,33 @@ Inline `[...]` values must not contain spaces or commas — keep `label`/`phase`
513
608
  Add `--bg` to run in the background:
514
609
 
515
610
  ```text
516
- /run scout "audit the codebase" --bg
517
- /chain scout "analyze auth" -> planner "design refactor" -> worker --bg
518
- /parallel scout "scan frontend" -> scout "scan backend" --bg
611
+ /run explorer "audit the codebase" --bg
612
+ /chain explorer "analyze auth" -> architect "design refactor" -> builder --bg
613
+ /parallel explorer "scan frontend" -> explorer "scan backend" --bg
519
614
  ```
520
615
 
521
616
  Add `--fork` to start each child from a real branched session created from the parent’s current leaf:
522
617
 
523
618
  ```text
524
- /run reviewer "review this diff" --fork
525
- /chain scout "analyze this branch" -> planner "plan next steps" --fork
526
- /parallel scout "audit frontend" -> reviewer "audit backend" --fork
619
+ /run commentator "review this diff" --fork
620
+ /chain explorer "analyze this branch" -> architect "plan next steps" --fork
621
+ /parallel explorer "audit frontend" -> commentator "audit backend" --fork
527
622
  ```
528
623
 
529
624
  You can combine them in either order:
530
625
 
531
626
  ```text
532
- /run reviewer "review this diff" --fork --bg
533
- /run reviewer "review this diff" --bg --fork
627
+ /run commentator "review this diff" --fork --bg
628
+ /run commentator "review this diff" --bg --fork
534
629
  ```
535
630
 
536
- Background runs are detached. If the parent agent has other independent work, it should keep working. When it has nothing useful to do until a background result arrives, it should call the `wait` tool instead of running sleep or 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 })` for one run, and `wait({ timeoutMs })` to cap the block.
631
+ Background runs are detached. If the parent agent has other independent work, it should keep working. In an interactive chat, it should normally return control when ready to yield and let Pi deliver the completion notification instead of blocking merely to wait. Override that default and use `subagent_wait` 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 work finishes. In a non-interactive run, Pi auto-drains current-session work at `agent_end`; use `subagent_wait` when this turn must receive results before it ends. It returns when the next initially active 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.
632
+
633
+ A foreground child can detach while it waits for a supervisor reply. Reply first, then call `subagent_wait({ id: runId })`. While that wait blocks, it streams the detached child's current tool and recent transcript activity into the pending tool row when transcript artifacts are available. The remembered run stays pending until the child exits, then emits a session-scoped completion notification with recovered output and remains inspectable through `subagent({ action: "status", id: runId })`. Do not call `resume` or launch a replacement while the child remains detached.
537
634
 
538
- `wait` is what lets a background-launching skill keep moving in a single turn, including non-interactive `pi -p` invocations where there is no subsequent turn to receive a completion notification. Ending the turn to wait for a completion only works in an interactive session where the user will prompt the agent again; in a run-to-completion skill or a non-interactive run, use `wait` so the still-running children are not abandoned.
635
+ Headless sessions also auto-drain current-session subagent and registered provider work at `agent_end`, using one absolute timeout and continuing through attention states. This is a final lifecycle safeguard rather than a replacement for explicit orchestration: `subagent_wait` still lets a model react to each result during the turn. Provider, reconciliation, timeout, and malformed-state failures remain visible errors instead of being treated as successful drains.
539
636
 
540
- The `oracle` and `worker` builtins are designed for an explicit decision loop. A typical pattern is to ask `oracle` for diagnosis and a recommended execution prompt, then only run `worker` after the main agent approves that direction.
637
+ The `commentator`/`commentator` and `builder` builtins are designed for an explicit decision loop. A typical pattern is to ask `commentator` or its `commentator` alias for diagnosis and a recommended execution prompt, then only run `builder` after the main agent approves that direction.
541
638
 
542
639
  ## Clarify and launch UI
543
640
 
@@ -566,14 +663,14 @@ Agent locations, lowest to highest priority:
566
663
 
567
664
  | Scope | Path |
568
665
  |-------|------|
569
- | Builtin | `~/.pi/agent/extensions/subagent/agents/` |
666
+ | Builtin | `~/.selesai/agent/extensions/subagent/agents/` |
570
667
  | Installed package | `package.json` `pi-subagents.agents` or `pi.subagents.agents` |
571
- | User | `~/.pi/agent/agents/**/*.md` |
572
- | Project | Project config `agents/**/*.md` (`.pi/agents/**/*.md` in standard Pi) |
668
+ | User | `~/.selesai/agent/agents/**/*.md` |
669
+ | Project | Project config `agents/**/*.md` (`.selesai/agents/**/*.md` in standard Pi) |
573
670
 
574
671
  Project discovery also reads legacy `.agents/**/*.md` files. Nested subdirectories are discovered recursively. `.chain.md` files do not define agents. Installed Pi packages can expose agent directories from either `{"pi-subagents":{"agents":["./agents"]}}` or `{"pi":{"subagents":{"agents":["./agents"]}}}` in their package manifest. Package agents load above builtins and below user/project agents. If both `.agents/` and the project config agents directory define the same parsed runtime agent name, the project config directory wins. Use `agentScope: "user" | "project" | "both"` to control discovery; `both` is the default and project definitions win runtime-name collisions.
575
672
 
576
- Builtin agents load at the lowest priority, so a user or project agent with the same name overrides them. They do not pin a provider model; they inherit your current Pi default model unless you set `subagents.defaultModel` or `subagents.agentOverrides.<name>.model`. `oracle` is an advisory reviewer that critiques direction and proposes an execution prompt without editing files. `worker` is the implementation agent for normal tasks and approved oracle handoffs.
673
+ Builtin agents load at the lowest priority, so a user or project agent with the same name overrides them. They do not pin a provider model; they inherit your current Pi default model unless you set `subagents.defaultModel` or `subagents.agentOverrides.<name>.model`. `commentator` is an commentatory commentator that critiques direction and proposes an execution prompt without editing files; `commentator` is the same bundled role under the Claude Code-compatible name. `builder` is the implementation agent for normal tasks and approved commentator handoffs.
577
674
 
578
675
  The `researcher` builtin uses `web_search`, `fetch_content`, and `get_search_content`; those require [pi-web-access](https://github.com/nicobailon/pi-web-access):
579
676
 
@@ -585,8 +682,8 @@ pi install npm:pi-web-access
585
682
 
586
683
  You can override selected builtin fields without copying the whole agent. Overrides live in settings:
587
684
 
588
- - User: `~/.pi/agent/settings.json`
589
- - Project: project config settings file (`.pi/settings.json` in standard Pi)
685
+ - User: `~/.selesai/agent/settings.json`
686
+ - Project: project config settings file (`.selesai/settings.json` in standard Pi)
590
687
 
591
688
  Example:
592
689
 
@@ -594,7 +691,7 @@ Example:
594
691
  {
595
692
  "subagents": {
596
693
  "agentOverrides": {
597
- "reviewer": {
694
+ "commentator": {
598
695
  "inheritProjectContext": false
599
696
  }
600
697
  }
@@ -602,11 +699,11 @@ Example:
602
699
  }
603
700
  ```
604
701
 
605
- Supported override fields are `model`, `fallbackModels`, `thinking`, `systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `defaultContext`, `disabled`, `skills`, `tools`, and `systemPrompt`. Use `defaultContext: false` in builtin overrides to clear an inherited context default. Project overrides beat user overrides.
702
+ Supported override fields are `model`, `fallbackModels`, `thinking`, `systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `defaultContext`, `acceptanceRole`, `disabled`, `skills`, `tools`, and `systemPrompt`. Use `defaultContext: false` or `acceptanceRole: false` to clear an inherited override. Project overrides beat user overrides.
606
703
 
607
704
  Set `subagents.defaultModel` to give all subagents without an explicit model their own default model, separate from the parent session model. Per-agent model overrides and agent frontmatter still win.
608
705
 
609
- Set `disabled: true` to hide a builtin from runtime discovery and agent-facing `subagent({ action: "list" })` output. For bulk control, set `subagents.disableBuiltins: true` in settings. You can also toggle a single agent without editing settings by hand: `subagent({ action: "disable", agent: "reviewer" })` writes that override, and `subagent({ action: "enable", agent: "reviewer" })` removes it.
706
+ Set `disabled: true` to hide a builtin from runtime discovery and agent-facing `subagent({ action: "list" })` output. For bulk control, set `subagents.disableBuiltins: true` in settings. You can also toggle a single agent without editing settings by hand: `subagent({ action: "disable", agent: "commentator" })` writes that override, and `subagent({ action: "enable", agent: "commentator" })` removes it.
610
707
 
611
708
  Set `subagents.disableThinking: true` to clear bundled builtin thinking defaults globally for providers that do not support `:low`, `:medium`, `:high`, or similar model suffixes. A higher-precedence per-agent `thinking` override can opt one builtin back in.
612
709
 
@@ -623,7 +720,7 @@ Use these fields when an agent should see more:
623
720
  | `inheritSkills: true` | Let the child see Pi’s discovered skills catalog. |
624
721
  | `defaultContext: fork` | Use forked session context when a launch omits `context`; explicit `context: "fresh"` still wins. |
625
722
 
626
- Builtin agents opt into project instruction inheritance by default so they follow repo-specific rules out of the box. `delegate` also uses append mode because its job is orchestration inside the parent workflow.
723
+ Builtin agents opt into project instruction inheritance by default so they follow repo-specific rules out of the box. `builder` also uses append mode because its job is orchestration inside the parent workflow.
627
724
 
628
725
  ### Agent frontmatter
629
726
 
@@ -631,8 +728,8 @@ A typical agent looks like this:
631
728
 
632
729
  ```yaml
633
730
  ---
634
- name: scout
635
- # Optional: registers this as code-analysis.scout while preserving name: scout
731
+ name: explorer
732
+ # Optional: registers this as code-analysis.explorer while preserving name: explorer
636
733
  package: code-analysis
637
734
  description: Fast codebase recon
638
735
  tools: read, grep, find, ls, bash, mcp:chrome-devtools
@@ -644,10 +741,16 @@ thinking: high
644
741
  systemPromptMode: replace
645
742
  inheritProjectContext: false
646
743
  inheritSkills: false
647
- skills: safe-bash, chrome-devtools
744
+ skills: safe-bash, review-checklist
745
+ skillPath: ./skills, ../shared-skills
648
746
  output: context.md
649
747
  defaultReads: context.md
650
748
  defaultProgress: true
749
+ async: true
750
+ timeoutMs: 900000
751
+ turnBudget: {"maxTurns":20,"graceTurns":2}
752
+ acceptance: {"level":"none","reason":"lightweight lookup"}
753
+ acceptanceRole: read-only
651
754
  completionGuard: false
652
755
  interactive: true
653
756
  maxSubagentDepth: 1
@@ -656,14 +759,25 @@ maxSubagentDepth: 1
656
759
  Your system prompt goes here.
657
760
  ```
658
761
 
762
+ Simple-scalar list fields accept either the existing comma-separated form or a newline block list with one `- item` per line. This applies to `tools`, `defaultReads`, `skill`/`skills`, `skillPath`, `fallbackModels`, `extensions`, and `subagentOnlyExtensions`; for example:
763
+
764
+ ```yaml
765
+ tools:
766
+ - read
767
+ - mcp:github/search_repositories
768
+ fallbackModels:
769
+ - openai/gpt-5-mini
770
+ - anthropic/claude-sonnet-4
771
+ ```
772
+
659
773
  Important fields:
660
774
 
661
775
  | Field | Notes |
662
776
  |-------|-------|
663
- | `package` | Optional package identifier. A file with `name: scout` and `package: code-analysis` registers as `code-analysis.scout`; serialization keeps `name` and `package` separate. |
664
- | `tools` | Builtin tool allowlist. `mcp:` entries select direct MCP tools when `pi-mcp-adapter` is installed. |
665
- | `extensions` | Omitted means normal extensions; empty means no extensions; comma-separated values allowlist specific extensions. |
666
- | `subagentOnlyExtensions` | Comma-separated extension paths loaded only in spawned child sessions for this agent. Tools registered there are unavailable to the main agent unless also installed through normal Pi extension configuration. |
777
+ | `package` | Optional package identifier. A file with `name: explorer` and `package: code-analysis` registers as `code-analysis.explorer`; serialization keeps `name` and `package` separate. |
778
+ | `tools` | Strict child tool allowlist. Named extension tools must also have their provider loaded. `mcp:` entries select direct MCP tools when `pi-mcp-adapter` is installed. |
779
+ | `extensions` | Omitted means normal extensions; empty means no extensions; list values allowlist specific extensions. |
780
+ | `subagentOnlyExtensions` | Extension paths loaded only in spawned child sessions for this agent. Tools registered there are unavailable to the main agent unless also installed through normal Pi extension configuration. |
667
781
  | `model` | Default model. Bare ids prefer the current provider when possible, then unique registry matches. |
668
782
  | `fallbackModels` | Ordered backup models for provider/model failures such as quota, auth, timeout, or unavailable model. Ordinary task failures do not trigger fallback. |
669
783
  | `thinking` | Appended as a `:level` suffix at runtime unless a suffix is already present. |
@@ -671,14 +785,22 @@ Important fields:
671
785
  | `inheritProjectContext` | Keeps or strips inherited project instruction blocks. |
672
786
  | `inheritSkills` | Keeps or strips Pi’s discovered skills catalog. |
673
787
  | `defaultContext` | Optional `fresh` or `fork` launch context default for this agent. |
674
- | `skills` | Adds specific skills to the child’s available skill list, regardless of `inheritSkills`. |
788
+ | `skills` | Selects specific skills for the child, regardless of `inheritSkills`. |
789
+ | `skillPath` | Invocation-private skill files or discovery directories. Relative paths resolve from the agent definition file. Local matches take precedence, while unresolved or unreadable matches fall back to normal skill discovery. This field discovers candidates only; `skills` still selects what the child receives. |
675
790
  | `output` | Default single-agent output file. |
676
791
  | `defaultReads` | Files to read before running in chain/parallel behavior. |
677
792
  | `defaultProgress` | Maintain `progress.md`. |
793
+ | `async` | Default a single-agent launch to background (`true`) or foreground (`false`) when the call omits `async`. Explicit call values and `forceTopLevelAsync` win. |
794
+ | `timeoutMs` | Positive integer default runtime deadline in milliseconds for single-agent launches. An explicit `timeoutMs` or `maxRuntimeMs` wins. |
795
+ | `turnBudget` | JSON object default such as `{"maxTurns":20,"graceTurns":2}` for single-agent launches. An explicit call value wins, followed by this agent default, then global `turnBudget` config. |
796
+ | `acceptance` | Acceptance default for single-agent launches. Use a scalar level such as `checked` or an inline/block YAML map such as `{ level: "none", reason: "lightweight lookup" }`. Explicit call values win; chain and parallel acceptance remains task/step configuration. |
797
+ | `acceptanceRole` | Optional `read-only` or `writer` role for automatic acceptance inference. Explicit task mutation or no-edit intent wins; otherwise the declared role replaces agent-name guessing. This does not grant or revoke tools. |
678
798
  | `completionGuard` | Set `false` only for non-implementation agents that may mention implementation words while using mutation-capable tools such as `bash`. |
679
799
  | `interactive` | Parsed for compatibility but not enforced in v1. |
680
800
  | `maxSubagentDepth` | Tightens nested delegation for this agent's children. |
681
- | `memory` | Opt-in role-specific persistent memory. `memory: { scope: "project" \| "user", path: "<name>" }` injects the first lines of a `MEMORY.md` from a dedicated `agent-memory/` directory into the child system prompt. Agents with write tools (`edit`/`write`/`bash`) get a read-write block; read-only agents get a read-only fallback. Project scope resolves under `<project>/.pi/agent-memory/`, user scope under `~/.pi/agent/agent-memory/`. Paths are validated against traversal and symlink escape. |
801
+ | `memory` | Opt-in role-specific persistent memory. `memory: { scope: "project" \| "user", path: "<name>" }` injects the first lines of a `MEMORY.md` from a dedicated `agent-memory/` directory into the child system prompt. Agents with write tools (`edit`/`write`/`bash`) get a read-write block; read-only agents get a read-only fallback. Project scope resolves under `<project>/.selesai/agent-memory/`, user scope under `~/.selesai/agent/agent-memory/`. Paths are validated against traversal and symlink escape. |
802
+
803
+ Agent-local `skillPath` candidates never enter Pi's parent/global skills catalog. Pair `inheritSkills: false` with explicit `skills` and `skillPath` when a child should receive only its selected private skills.
682
804
 
683
805
  ### Per-agent persistent memory
684
806
 
@@ -687,25 +809,26 @@ A recurring custom agent can opt into a durable, role-specific memory scope with
687
809
  ```yaml
688
810
  memory:
689
811
  scope: project
690
- path: security-reviewer
812
+ path: security-commentator
691
813
  ```
692
814
 
693
- On each run, the first 200 lines of `MEMORY.md` in the resolved memory directory are injected into the child system prompt so the agent can recall accumulated role notes such as threat-model entries, release gotchas, or verified commands. Agents that have write tools (`edit`, `write`, or `bash`, or no `tools` allowlist at all) are told they may append concise dated entries to the file. Agents without write tools receive a read-only memory block and are not instructed to edit it, so a read-only reviewer can still recall prior notes without being granted write capability. The memory directory is never created eagerly; the agent's own `write` tool creates it (and `MEMORY.md`) on the first persist. Memory paths are validated against `.`/`..` traversal and symlink escape, and an unsafe or unresolvable scope is silently skipped rather than breaking the run.
815
+ On each run, the first 200 lines of `MEMORY.md` in the resolved memory directory are injected into the child system prompt so the agent can recall accumulated role notes such as threat-model entries, release gotchas, or verified commands. Agents that have write tools (`edit`, `write`, or `bash`, or no `tools` allowlist at all) are told they may append concise dated entries to the file. Agents without write tools receive a read-only memory block and are not instructed to edit it, so a read-only commentator can still recall prior notes without being granted write capability. The memory directory is never created eagerly; the agent's own `write` tool creates it (and `MEMORY.md`) on the first persist. Memory paths are validated against `.`/`..` traversal and symlink escape, and an unsafe or unresolvable scope is silently skipped rather than breaking the run.
694
816
 
695
- Project-scoped memory resolves under `<project>/.pi/agent-memory/<path>` and travels with the repo. User-scoped memory resolves under `~/.pi/agent/agent-memory/<path>` and is shared across projects for that agent.
817
+ Project-scoped memory resolves under `<project>/.selesai/agent-memory/<path>` and travels with the repo. User-scoped memory resolves under `~/.selesai/agent/agent-memory/<path>` and is shared across projects for that agent.
696
818
 
697
819
  ### Tool and extension selection
698
820
 
699
- If `tools` is omitted, `pi-subagents` does not pass `--tools`, so the child gets Pi’s normal builtin tools. If `tools` is present, regular tool names become an explicit allowlist. `mcp:` entries are split out and forwarded as direct MCP selections. Path-like `tools` entries, such as extension paths or `.ts`/`.js` files, are treated as tool-extension paths rather than builtin tool names. Agents that declare only known read-only builtin tools skip the implementation completion guard, but `bash`, unknown tools, and MCP tools stay mutation-capable. Use `completionGuard: false` for bash-enabled validators or advisors that should never be judged as implementation agents.
821
+ If `tools` is omitted, `pi-subagents` does not pass `--tools`, so the child gets Pi’s normal builtin tools. If `tools` is present, regular tool names become an explicit allowlist; an empty `tools:` field emits `--no-tools`. An allowlisted name does not load the extension that registers it: load that provider through normal Pi extension discovery, `extensions`, `subagentOnlyExtensions`, or a path-like `tools` entry. `mcp:` entries are split out and forwarded as direct MCP selections without granting normal builtins unless those builtins are also listed. Path-like `tools` entries, such as extension paths or `.ts`/`.js` files, are treated as tool-extension paths rather than tool names. Internal runtime tools such as `structured_output` are added to an explicit allowlist only when their contract is active. Agents that declare only known read-only builtin tools skip the implementation completion guard, but `bash`, unknown tools, and MCP tools stay mutation-capable. Use `completionGuard: false` for bash-enabled validators or commentators that should never be judged as implementation agents.
700
822
 
701
823
  Examples:
702
824
 
703
825
  - `tools` omitted and `extensions` omitted: normal builtins and normal extensions.
704
- - `tools: mcp:chrome-devtools`: normal builtins plus direct Chrome DevTools MCP tools.
826
+ - `tools: mcp:chrome-devtools`: only the resolved direct Chrome DevTools MCP tools.
705
827
  - `tools: read, bash, mcp:chrome-devtools`: only `read` and `bash` as builtins, plus direct Chrome DevTools MCP tools.
706
828
  - `tools: subagent, read`: a child-safe `subagent` tool is available inside that child so it can run explicitly assigned nested fanout.
829
+ - `tools: read, fixture_search` plus `subagentOnlyExtensions: ./tools/fixture-search.ts`: the provider loads only in this agent's child process, and the registered `fixture_search` name survives the strict allowlist.
707
830
 
708
- Direct MCP tools require [pi-mcp-adapter](https://github.com/nicobailon/pi-mcp-adapter). Subagents only receive direct MCP tools when `mcp:` entries are listed in their frontmatter; global `directTools: true` in `mcp.json` is not enough by itself. The generic `mcp` proxy tool can still be used for discovery when available. The adapter caches tool metadata at startup, so after connecting a new MCP server for the first time, restart Pi before relying on direct tools. An `mcp:` entry named `subagent` does not authorize nested fanout; only the builtin `subagent` tool name does.
831
+ Direct MCP tools require [pi-mcp-adapter](https://github.com/nicobailon/pi-mcp-adapter). Subagents only receive direct MCP tools when `mcp:` entries are listed in their frontmatter; global `directTools: true` in `mcp.json` is not enough by itself. The generic `mcp` proxy tool can still be used for discovery when available. The adapter caches tool metadata at startup, so after connecting a new MCP server for the first time, restart Pi before relying on direct tools. An `mcp:` entry named `subagent` does not authorize nested fanout; only the builtin `subagent` tool name does. If a resolved direct MCP name is missing from the child registry, pi-subagents keeps the launch failed under the strict allowlist and identifies the condition as a host/pi-mcp-adapter registration problem; verify that the adapter registers the selected tools before child startup.
709
832
 
710
833
  `extensions` controls child extension loading:
711
834
 
@@ -719,10 +842,14 @@ extensions:
719
842
  extensions: /abs/path/to/ext-a.ts, /abs/path/to/ext-b.ts
720
843
  ```
721
844
 
722
- When `extensions` is present, it takes precedence over extension paths implied by `tools` entries.
845
+ When `extensions` is present, normal discovered extensions are disabled; the listed extensions, path-like `tools` entries, required pi-subagents runtime extensions, and `subagentOnlyExtensions` still load.
723
846
 
724
847
  Use `subagentOnlyExtensions` when a custom extension tool should exist only inside child sessions. It is scoped by agent config: every run of that agent receives those extension paths, while other agents do not unless they declare the same field. The current model does not have a separate named-subagent audience inside one agent definition.
725
848
 
849
+ To apply the same `extensions` allowlist to every agent that does not declare its own, set `subagents.defaultExtensions` in user or project settings. Omit it to preserve ambient extension discovery or set it to `[]` to disable ambient extensions by default; project settings win over user settings. Agents that explicitly define `extensions` keep their own value, including an empty `extensions:` field.
850
+
851
+ Before the first model turn, the child runtime compares every explicit tool name with Pi's final filtered registry. A missing provider now fails the run with the unavailable names and concrete `subagentOnlyExtensions`/`extensions` guidance instead of letting a direct or chained child silently continue without its requested tools.
852
+
726
853
  ## Chain files
727
854
 
728
855
  Chains are reusable workflows stored separately from agent files. Use `.chain.md` for simple sequential saved chains. Use `.chain.json` when a chain needs dynamic fanout.
@@ -730,8 +857,8 @@ Chains are reusable workflows stored separately from agent files. Use `.chain.md
730
857
  | Scope | Path |
731
858
  |-------|------|
732
859
  | Installed package | `package.json` `pi-subagents.chains` or `pi.subagents.chains` |
733
- | User | `~/.pi/agent/chains/**/*.chain.md`, `~/.pi/agent/chains/**/*.chain.json` |
734
- | Project | Project config `chains/**/*.chain.md`, `chains/**/*.chain.json` (`.pi/chains/...` in standard Pi) |
860
+ | User | `~/.selesai/agent/chains/**/*.chain.md`, `~/.selesai/agent/chains/**/*.chain.json` |
861
+ | Project | Project config `chains/**/*.chain.md`, `chains/**/*.chain.json` (`.selesai/chains/...` in standard Pi) |
735
862
 
736
863
  Nested subdirectories are discovered recursively. Installed Pi packages can expose chain directories from either `{"pi-subagents":{"chains":["./chains"]}}` or `{"pi":{"subagents":{"chains":["./chains"]}}}` in their package manifest. Package chains load below user/project chains. If both `.chain.md` and `.chain.json` define the same parsed runtime chain name in the same scope, `.chain.json` wins. If user and project scopes define the same parsed runtime chain name, the project chain wins. Chains support the same optional `package` frontmatter as agents; `name: review-flow` plus `package: code-analysis` runs as `code-analysis.review-flow`.
737
864
 
@@ -739,11 +866,11 @@ Example:
739
866
 
740
867
  ```md
741
868
  ---
742
- name: scout-planner
869
+ name: explorer-architect
743
870
  description: Gather context then plan implementation
744
871
  ---
745
872
 
746
- ## scout
873
+ ## explorer
747
874
  phase: Context
748
875
  label: Map auth flow
749
876
  as: context
@@ -751,7 +878,7 @@ output: context.md
751
878
 
752
879
  Analyze the codebase for {task}
753
880
 
754
- ## planner
881
+ ## architect
755
882
  phase: Planning
756
883
  label: Implementation plan
757
884
  reads: context.md
@@ -772,10 +899,10 @@ Dynamic fanout is available only through direct `subagent({ chain: [...] })` JSO
772
899
  ```json
773
900
  {
774
901
  "name": "dynamic-review",
775
- "description": "Find review targets, fan out reviewers, then synthesize.",
902
+ "description": "Find review targets, fan out commentators, then synthesize.",
776
903
  "chain": [
777
904
  {
778
- "agent": "scout",
905
+ "agent": "explorer",
779
906
  "task": "Return {\"items\":[{\"path\":\"...\",\"reason\":\"...\"}]} via structured_output.",
780
907
  "as": "targets",
781
908
  "outputSchema": { "type": "object" }
@@ -788,7 +915,7 @@ Dynamic fanout is available only through direct `subagent({ chain: [...] })` JSO
788
915
  "maxItems": 12
789
916
  },
790
917
  "parallel": {
791
- "agent": "reviewer",
918
+ "agent": "commentator",
792
919
  "label": "Review {target.path}",
793
920
  "task": "Review {target.path}. Reason: {target.reason}",
794
921
  "outputSchema": { "type": "object" }
@@ -797,7 +924,7 @@ Dynamic fanout is available only through direct `subagent({ chain: [...] })` JSO
797
924
  "concurrency": 4
798
925
  },
799
926
  {
800
- "agent": "worker",
927
+ "agent": "builder",
801
928
  "task": "Synthesize fixes from {outputs.reviews}"
802
929
  }
803
930
  ]
@@ -807,7 +934,7 @@ Dynamic fanout is available only through direct `subagent({ chain: [...] })` JSO
807
934
  Create simple `.chain.md` chains by writing files directly or with the `subagent({ action: "create", config: ... })` management action. Create dynamic `.chain.json` chains by writing the JSON file directly. Run saved chains with natural language or:
808
935
 
809
936
  ```text
810
- /run-chain scout-planner -- refactor authentication
937
+ /run-chain explorer-architect -- refactor authentication
811
938
  ```
812
939
 
813
940
  ## Chain variables
@@ -824,10 +951,10 @@ Task templates support:
824
951
  Parallel outputs are aggregated with clear separators before being passed to the next step:
825
952
 
826
953
  ```text
827
- === Parallel Task 1 (worker) ===
954
+ === Parallel Task 1 (builder) ===
828
955
  ...
829
956
 
830
- === Parallel Task 2 (worker) ===
957
+ === Parallel Task 2 (builder) ===
831
958
  ...
832
959
  ```
833
960
 
@@ -837,20 +964,20 @@ Skills are `SKILL.md` files made available to an agent. The prompt includes skil
837
964
 
838
965
  Discovery uses project-first precedence:
839
966
 
840
- 1. Project config `skills/{name}/SKILL.md` (`.pi/skills/{name}/SKILL.md` in standard Pi)
967
+ 1. Project config `skills/{name}/SKILL.md` (`.selesai/skills/{name}/SKILL.md` in standard Pi)
841
968
  2. Project packages and project settings packages via `package.json -> pi.skills`
842
969
  3. Current task cwd package via `package.json -> pi.skills`
843
970
  4. Project config `settings.json -> skills`
844
- 5. `~/.pi/agent/skills/{name}/SKILL.md`
971
+ 5. `~/.selesai/agent/skills/{name}/SKILL.md`
845
972
  6. User packages and user settings packages via `package.json -> pi.skills`
846
- 7. `~/.pi/agent/settings.json -> skills`
973
+ 7. `~/.selesai/agent/settings.json -> skills`
847
974
 
848
975
  Use agent defaults, override them at runtime, or disable them:
849
976
 
850
977
  ```ts
851
- { agent: "scout", task: "..." }
852
- { agent: "scout", task: "...", skill: "tmux, safe-bash" }
853
- { agent: "scout", task: "...", skill: false }
978
+ { agent: "explorer", task: "..." }
979
+ { agent: "explorer", task: "...", skill: "tmux, safe-bash" }
980
+ { agent: "explorer", task: "...", skill: false }
854
981
  ```
855
982
 
856
983
  For chains, `skill` at the top level is additive. A step-level `skill` overrides that step; `false` disables skills for that step.
@@ -880,6 +1007,7 @@ Missing skills do not fail execution. The result summary shows a warning.
880
1007
  The package bundles a `pi-subagents` skill that is automatically available to the parent agent when the extension is installed. It is for the orchestrating parent only: child subagents never receive it, and their context is explicitly filtered to strip parent-only orchestration instructions.
881
1008
 
882
1009
  What the bundled skill covers:
1010
+
883
1011
  - **Delegation patterns**: when to launch which agent, whether to use single, parallel, chain, or async mode, and whether to use fresh or forked context
884
1012
  - **Prompt workflow recipes**: how to apply the packaged techniques directly with `subagent(...)` when the user describes the workflow in natural language instead of invoking a slash command. This includes parallel review, review-loop, parallel research, parallel context-build, parallel handoff-plan, gather-context-and-clarify, and parallel cleanup
885
1013
  - **Role-agent prompting guidance**: compact contract prompts instead of long scripts, what to include in role-specific meta prompts, and retrieval budgets for researchers
@@ -889,6 +1017,198 @@ What the bundled skill covers:
889
1017
 
890
1018
  If you are writing an agent that orchestrates subagents, the bundled skill helps it behave correctly without guessing the patterns. If you are a human user, you do not need to read it directly; the README and prompt shortcuts encode the same workflows in user-facing form.
891
1019
 
1020
+ ## Extension delegation API
1021
+
1022
+ Pi extensions can request configured foreground agents through the public event
1023
+ contract exported by `pi-subagents/delegation`.
1024
+
1025
+ ### Launch contract preflight
1026
+
1027
+ Use `pi-subagents/preflight` when an extension needs to inspect the resolved child launch contract before deciding whether to run anything:
1028
+
1029
+ ```ts
1030
+ import { resolveSubagentLaunchContract } from "pi-subagents/preflight";
1031
+
1032
+ const result = await resolveSubagentLaunchContract({
1033
+ agent: "commentator",
1034
+ task: "Review the current diff.",
1035
+ context: "fresh",
1036
+ cwd: ctx.cwd,
1037
+ sessionRoot: "/tmp/my-extension-preflight-session-root",
1038
+ availableModels: ctx.modelRegistry.getAvailable(),
1039
+ });
1040
+
1041
+ if (!result.ok) {
1042
+ // missing_agent, ambiguous_agent, missing_skill, denied_required_tool,
1043
+ // invalid_artifact_dir, invalid_cwd, or unsupported_mode
1044
+ throw new Error(result.message);
1045
+ }
1046
+
1047
+ console.log(result.contract.digest, result.contract.tools.effectiveAllowlist);
1048
+ ```
1049
+
1050
+ Preflight covers ordinary single-agent launch resolution under public contract version 2: selected agent identity and shadowed candidates, a versioned parsed-definition digest (including system prompt and launch-affecting model, tool, skill, extension, output, and memory fields), fresh/fork context, effective model and thinking, skill and tool resolution, direct MCP selections, runtime/configured extensions, artifact/session paths, async lifecycle/status/result/event/process-terminal paths, package/lifecycle versions, capability-ceiling audit data, and stable digests. `launchContractDigest` is the canonical digest of the caller task, effective system prompt (including the resolved `turnBudget` prompt augmentation when supplied), model candidates, effective tools/extensions/MCP (including inherited capability ceilings), output binding, and structured-output schema that ordinary foreground and async execution report in results/status/events and metadata. Runtime acceptance prose and output-task annotations are intentionally excluded because side-effect-free preflight does not resolve those host/runtime augmentations; the contract version and task digest make that boundary explicit. Raw prompts are not exposed in public contract output. It is side-effect-free for launch state: it does not create child sessions, temp prompt files, structured-output runtimes, tool-diagnostic files, or run artifacts. Some host-owned facts, such as exact fork snapshots, nested async roots, and live model registries, can only be proven by the Pi host; those appear as `host_required` diagnostics instead of silently pretending to be exact.
1051
+
1052
+ ### Delegation v1
1053
+
1054
+ The compatibility v1 contract runs one configured foreground agent per request:
1055
+
1056
+ ```ts
1057
+ import {
1058
+ SUBAGENT_DELEGATION_REQUEST_EVENT,
1059
+ SUBAGENT_DELEGATION_RESPONSE_EVENT,
1060
+ type SubagentDelegationRequest,
1061
+ type SubagentDelegationResponse,
1062
+ } from "pi-subagents/delegation";
1063
+
1064
+ const request: SubagentDelegationRequest = {
1065
+ version: 1,
1066
+ requestId: crypto.randomUUID(),
1067
+ agent: "commentator",
1068
+ task: "Review the supplied evidence.",
1069
+ context: "fresh",
1070
+ cwd: ctx.cwd,
1071
+ timeoutMs: 120_000,
1072
+ toolBudget: { soft: 10, hard: 16, block: "*" },
1073
+ };
1074
+
1075
+ const unsubscribe = pi.events.on(SUBAGENT_DELEGATION_RESPONSE_EVENT, (payload) => {
1076
+ const response = payload as SubagentDelegationResponse;
1077
+ if (response.requestId !== request.requestId) return;
1078
+ unsubscribe();
1079
+ // Inspect response.status and the metadata present for this run.
1080
+ });
1081
+ pi.events.emit(SUBAGENT_DELEGATION_REQUEST_EVENT, request);
1082
+ ```
1083
+
1084
+ The contract uses the established `prompt-template:subagent:*` event transport and the same executor as the `subagent` tool; it does not add another launcher. New integrations must send `version: 1`. Requests are strict and single-agent only. They can set fresh or fork context, model, cwd, timeout, turn and tool-call budgets, skills, output behavior, acceptance, and artifact capture. Unknown or malformed fields return `invalid_request` before execution.
1085
+
1086
+ Responses distinguish completion, failure, timeout, cancellation, interruption,
1087
+ turn or tool-budget exhaustion, explicit acceptance failure, invalid requests,
1088
+ and unavailable active context. Optional metadata is omitted when unavailable.
1089
+ Request IDs must be unique while active; duplicate active IDs are ignored so the
1090
+ original request keeps ownership of its terminal response. Emit
1091
+ `SUBAGENT_DELEGATION_CANCEL_EVENT` with the same version and request ID to cancel
1092
+ queued or active work.
1093
+
1094
+ ### Delegation v2
1095
+
1096
+ V2 is the owned-leaf contract for workflow supervisors. Independent requests
1097
+ can overlap through the builderd executor without weakening the ordinary
1098
+ model-facing tool's one-foreground-call-per-turn guard.
1099
+
1100
+ ```ts
1101
+ import {
1102
+ SUBAGENT_DELEGATION_REQUEST_EVENT,
1103
+ SUBAGENT_DELEGATION_RESPONSE_EVENT,
1104
+ type SubagentDelegationV2Request,
1105
+ type SubagentDelegationV2Response,
1106
+ } from "pi-subagents/delegation";
1107
+
1108
+ const request: SubagentDelegationV2Request = {
1109
+ version: 2,
1110
+ requestId: crypto.randomUUID(),
1111
+ ownerRunId: workflowRunId,
1112
+ nodeId: "review-accuracy",
1113
+ agent: "commentator",
1114
+ task: "Review the supplied evidence.",
1115
+ context: "fresh",
1116
+ cwd: ctx.cwd,
1117
+ thinking: "high",
1118
+ result: {
1119
+ kind: "structured",
1120
+ schema: {
1121
+ type: "object",
1122
+ properties: { verdict: { type: "string" } },
1123
+ required: ["verdict"],
1124
+ additionalProperties: false,
1125
+ },
1126
+ },
1127
+ };
1128
+
1129
+ const unsubscribe = pi.events.on(SUBAGENT_DELEGATION_RESPONSE_EVENT, (payload) => {
1130
+ const response = payload as SubagentDelegationV2Response;
1131
+ if (response.version !== 2 || response.requestId !== request.requestId) return;
1132
+ if (response.ownerRunId !== request.ownerRunId || response.nodeId !== request.nodeId) return;
1133
+ unsubscribe();
1134
+ // Inspect response.status, response.result, response.usage, model, and thinking.
1135
+ });
1136
+ pi.events.emit(SUBAGENT_DELEGATION_REQUEST_EVENT, request);
1137
+ ```
1138
+
1139
+ `ownerRunId` plus `nodeId` is the active logical identity; `requestId` identifies
1140
+ one attempt. A second active attempt for the same logical node receives
1141
+ `duplicate_node` without disturbing the original. Started, update, response,
1142
+ and cancellation payloads carry the full tuple. Cancellation affects only an
1143
+ exact tuple, including cancel-before-start races. Each attempt emits at most one
1144
+ terminal response.
1145
+
1146
+ Result mode is explicit. Text remains literal even when it looks like JSON.
1147
+ Structured mode returns the separately captured, schema-validated JSON value.
1148
+ Terminal usage reports input, output, cache-read, cache-write, cost, turns, tool
1149
+ calls, and duration alongside the effective model and thinking level when
1150
+ known. Schemas are capped at 64 KiB; tasks and returned text/structured values
1151
+ are capped at 1 MiB, with smaller bounds on identity/configuration strings and
1152
+ a maximum v2 `timeoutMs` of 2,147,483,647. V2 alone accepts
1153
+ `toolBudget: { hard: 0, block: "*" }` to block the first tool call and run a
1154
+ zero-tool leaf; delegation v1 and ordinary model-facing/configured budgets keep
1155
+ their existing minimum of one. The foreground bridge retains up to 8,192 exact
1156
+ pending-cancellation and settled-attempt identities per extension
1157
+ context. If either history fills, it fails closed with `unavailable_context`
1158
+ for later v2 starts rather than evicting identity facts; lifecycle reset clears
1159
+ the bounded history.
1160
+
1161
+ Delegation requires an active extension context. Emit requests from a supported event callback or queued application step, not by recursively invoking the `subagent` tool inside another tool's `tool_call` hook. The caller selects a configured agent, but agent discovery and effective tools remain package-owned. A request cannot grant arbitrary tools, and tool restrictions are not an operating-system sandbox. The detached RPC remains async-only; this API is foreground-only.
1162
+
1163
+ Existing prompt-template payloads and delegation v1 continue over the same event
1164
+ family. V2 remains foreground-only and inherits the configured agent's current
1165
+ tools, skills, context, model policy, and workspace authority; it is not a
1166
+ sandbox or a durable task broker. `pi-subagents/delegation` is the canonical
1167
+ contract for extension integrations.
1168
+
1169
+ ## Capability ceilings
1170
+
1171
+ Parent extensions can enforce an out-of-band, session-scoped capability ceiling without adding a model-visible field to `subagent`:
1172
+
1173
+ ```ts
1174
+ import { registerSubagentCapabilityCeiling } from "pi-subagents/capability-ceiling";
1175
+
1176
+ const restriction = registerSubagentCapabilityCeiling({
1177
+ sessionId: ctx.sessionManager.getSessionId(),
1178
+ source: "plan-mode",
1179
+ ceiling: { allowedTools: ["read", "grep", "find", "ls"], denyExtensions: true },
1180
+ });
1181
+ // restriction.update(...) replaces this provider's policy atomically.
1182
+ // restriction.dispose() removes only this provider's registration.
1183
+ ```
1184
+
1185
+ Active registrations intersect their `allowedTools` sets and OR `denyExtensions`; an explicit empty list means no caller-facing tools, while an omitted list does not restrict names. The resolved snapshot is propagated monotonically to nested and async children and is retained for recovery. `structured_output` may remain as a package-owned internal protocol tool when an output schema requires it; it is not a caller capability. A denied lazy-skill `read` requirement fails before spawn rather than widening the ceiling.
1186
+
1187
+ `denyExtensions` suppresses ambient, configured, and MCP provider extensions while retaining the package runtime needed for child protocol enforcement. This is a same-process policy boundary, not a sandbox against malicious code already running in the parent process. Schedules created while a ceiling is active are rejected until durable schedule persistence is available; unrestricted schedules remain subject to any policy active when they fire. Public status exposes bounded audit counts and sources, never full extension paths.
1188
+
1189
+ ## Background-work provider API
1190
+
1191
+ Other Pi extensions can make their current-session jobs visible to `subagent_wait` through the versioned process-local provider contract:
1192
+
1193
+ ```ts
1194
+ import { registerBackgroundWorkProvider } from "pi-subagents/background-work";
1195
+
1196
+ const dispose = registerBackgroundWorkProvider({
1197
+ name: "my-background-extension",
1198
+ wakeChannels: ["my-extension:job-finished"],
1199
+ listActiveWork: () => jobs
1200
+ .filter((job) => job.status === "running")
1201
+ .map((job) => ({ id: job.id, sessionId: job.ownerSessionId })),
1202
+ reconcile: ({ sessionId, nowMs }) => reconcileJobs(sessionId, nowMs),
1203
+ });
1204
+ ```
1205
+
1206
+ Each item needs a stable provider-local ID and the exact Pi session ID that owns it. `subagent_wait` captures those identities rather than a count, so one job finishing while another starts still satisfies first-completion waits without losing the replacement. It filters snapshots to the active session, fails closed if a provider disappears while its work is tracked, and surfaces malformed snapshots or provider errors with provider context. Wake channels only shorten polling; validated snapshots remain authoritative.
1207
+
1208
+ Providers share a registry through `Symbol.for("pi-subagents.background-work.v1")`, allowing independently loaded extension modules to meet in one Pi process. Registration is reload-safe: a new provider with the same name replaces the old callback, and the old disposer cannot remove the replacement. Call the disposer during extension shutdown when possible.
1209
+
1210
+ Child processes do not gain provider tools or extensions automatically. Add `subagent_wait` to the child agent's `tools` allowlist and load each provider through `extensions` or `subagentOnlyExtensions`. The parent's effective `waitTool` setting is serialized through foreground, async, resume, chain, parallel, and fanout launch paths; `SELESAI_SUBAGENT_WAIT_TOOL_ENABLED` keeps precedence.
1211
+
892
1212
  ## Programmatic tool usage
893
1213
 
894
1214
  These are the parameters the LLM passes when it calls the `subagent` tool. Most users ask naturally or use slash commands instead.
@@ -897,25 +1217,25 @@ These are the parameters the LLM passes when it calls the `subagent` tool. Most
897
1217
 
898
1218
  ```ts
899
1219
  // Single agent
900
- { agent: "worker", task: "refactor auth" }
901
- { agent: "scout", task: "find todos", maxOutput: { lines: 1000 } }
902
- { agent: "scout", task: "investigate", output: false }
903
- { agent: "scout", task: "write a large report", output: "reports/scout.md", outputMode: "file-only" }
1220
+ { agent: "builder", task: "refactor auth" }
1221
+ { agent: "explorer", task: "find todos", maxOutput: { lines: 1000 } }
1222
+ { agent: "explorer", task: "investigate", output: false }
1223
+ { agent: "explorer", task: "write a large report", output: "reports/explorer.md", outputMode: "file-only" }
904
1224
 
905
1225
  // Forked context
906
- { agent: "worker", task: "continue this thread", context: "fork" }
1226
+ { agent: "builder", task: "continue this thread", context: "fork" }
907
1227
 
908
1228
  // Parallel
909
- { tasks: [{ agent: "scout", task: "a" }, { agent: "reviewer", task: "b" }] }
910
- { tasks: [{ agent: "scout", task: "audit auth", count: 3 }] }
911
- { tasks: [{ agent: "scout", task: "audit frontend" }, { agent: "reviewer", task: "audit backend" }], context: "fork" }
1229
+ { tasks: [{ agent: "explorer", task: "a" }, { agent: "commentator", task: "b" }] }
1230
+ { tasks: [{ agent: "explorer", task: "audit auth", count: 3 }] }
1231
+ { tasks: [{ agent: "explorer", task: "audit frontend" }, { agent: "commentator", task: "audit backend" }], context: "fork" }
912
1232
 
913
1233
  // Chain
914
1234
  { chain: [
915
- { agent: "scout", task: "Gather context for auth refactor" },
916
- { agent: "planner" },
917
- { agent: "worker" },
918
- { agent: "reviewer" }
1235
+ { agent: "explorer", task: "Gather context for auth refactor" },
1236
+ { agent: "architect" },
1237
+ { agent: "builder" },
1238
+ { agent: "commentator" }
919
1239
  ]}
920
1240
 
921
1241
  // Chain in the background, suitable for unblocking the main chat
@@ -923,35 +1243,35 @@ These are the parameters the LLM passes when it calls the `subagent` tool. Most
923
1243
 
924
1244
  // Chain with fan-out/fan-in
925
1245
  { chain: [
926
- { agent: "scout", task: "Gather context", phase: "Context", label: "Map code", as: "context" },
1246
+ { agent: "explorer", task: "Gather context", phase: "Context", label: "Map code", as: "context" },
927
1247
  { parallel: [
928
- { agent: "worker", task: "Implement feature A from {outputs.context}", label: "Feature A", as: "featureA" },
929
- { agent: "worker", task: "Implement feature B from {outputs.context}", label: "Feature B", as: "featureB" }
1248
+ { agent: "builder", task: "Implement feature A from {outputs.context}", label: "Feature A", as: "featureA" },
1249
+ { agent: "builder", task: "Implement feature B from {outputs.context}", label: "Feature B", as: "featureB" }
930
1250
  ], concurrency: 2, failFast: true },
931
- { agent: "reviewer", task: "Review {outputs.featureA} and {outputs.featureB}" }
1251
+ { agent: "commentator", task: "Review {outputs.featureA} and {outputs.featureB}" }
932
1252
  ]}
933
1253
 
934
1254
  // Dynamic fanout from structured output
935
1255
  { chain: [
936
1256
  {
937
- agent: "scout",
1257
+ agent: "explorer",
938
1258
  task: "Return review targets as structured_output: { items: [{ path, reason }] }",
939
1259
  as: "targets",
940
1260
  outputSchema: { type: "object" }
941
1261
  },
942
1262
  {
943
1263
  expand: { from: { output: "targets", path: "/items" }, item: "target", key: "/path", maxItems: 12 },
944
- parallel: { agent: "reviewer", task: "Review {target.path}. Reason: {target.reason}", outputSchema: { type: "object" } },
1264
+ parallel: { agent: "commentator", task: "Review {target.path}. Reason: {target.reason}", outputSchema: { type: "object" } },
945
1265
  collect: { as: "reviews" },
946
1266
  concurrency: 4
947
1267
  },
948
- { agent: "worker", task: "Synthesize fixes from {outputs.reviews}" }
1268
+ { agent: "builder", task: "Synthesize fixes from {outputs.reviews}" }
949
1269
  ] }
950
1270
 
951
1271
  // Strict structured output for reliable handoff data
952
1272
  { chain: [
953
1273
  {
954
- agent: "scout",
1274
+ agent: "explorer",
955
1275
  task: "Return the key files and risks for {task}",
956
1276
  as: "scan",
957
1277
  outputSchema: {
@@ -963,13 +1283,13 @@ These are the parameters the LLM passes when it calls the `subagent` tool. Most
963
1283
  }
964
1284
  }
965
1285
  },
966
- { agent: "planner", task: "Plan from this scan: {outputs.scan}" }
1286
+ { agent: "architect", task: "Plan from this scan: {outputs.scan}" }
967
1287
  ] }
968
1288
 
969
1289
  // Worktree isolation
970
1290
  { tasks: [
971
- { agent: "worker", task: "Implement auth" },
972
- { agent: "worker", task: "Implement API" }
1291
+ { agent: "builder", task: "Implement auth" },
1292
+ { agent: "builder", task: "Implement API" }
973
1293
  ], worktree: true }
974
1294
  ```
975
1295
 
@@ -980,10 +1300,10 @@ Agent definitions are not loaded into context by default. Management actions let
980
1300
  ```ts
981
1301
  { action: "list" }
982
1302
  { action: "list", agentScope: "project" }
983
- { action: "get", agent: "scout" }
1303
+ { action: "get", agent: "explorer" }
984
1304
  { action: "models" }
985
- { action: "models", agent: "reviewer" }
986
- { action: "get", agent: "code-analysis.scout" }
1305
+ { action: "models", agent: "commentator" }
1306
+ { action: "get", agent: "code-analysis.explorer" }
987
1307
  { action: "get", chainName: "review-pipeline" }
988
1308
 
989
1309
  { action: "create", config: {
@@ -991,7 +1311,7 @@ Agent definitions are not loaded into context by default. Management actions let
991
1311
  package: "code-analysis",
992
1312
  description: "Scans codebases for patterns and issues",
993
1313
  scope: "user",
994
- systemPrompt: "You are a code scout...",
1314
+ systemPrompt: "You are a code explorer...",
995
1315
  systemPromptMode: "replace",
996
1316
  inheritProjectContext: false,
997
1317
  inheritSkills: false,
@@ -999,8 +1319,10 @@ Agent definitions are not loaded into context by default. Management actions let
999
1319
  fallbackModels: ["openai/gpt-5-mini", "anthropic/claude-haiku-4-5"],
1000
1320
  tools: "read, bash, mcp:github/search_repositories",
1001
1321
  extensions: "",
1002
- skills: "parallel-scout",
1322
+ skills: "parallel-explorer",
1003
1323
  thinking: "high",
1324
+ acceptance: { level: "none", reason: "lightweight lookup" },
1325
+ acceptanceRole: "read-only",
1004
1326
  output: "context.md",
1005
1327
  reads: "shared-context.md",
1006
1328
  progress: true
@@ -1011,21 +1333,23 @@ Agent definitions are not loaded into context by default. Management actions let
1011
1333
  description: "Scout then review",
1012
1334
  scope: "project",
1013
1335
  steps: [
1014
- { agent: "scout", task: "Scan {task}", output: "context.md" },
1015
- { agent: "reviewer", task: "Review {previous}", reads: ["context.md"] }
1336
+ { agent: "explorer", task: "Scan {task}", output: "context.md" },
1337
+ { agent: "commentator", task: "Review {previous}", reads: ["context.md"] }
1016
1338
  ]
1017
1339
  }}
1018
1340
 
1019
- { action: "update", agent: "code-analysis.scout", config: { model: "openai/gpt-4o" } }
1341
+ { action: "update", agent: "code-analysis.explorer", config: { model: "openai/gpt-4o" } }
1342
+ { action: "update", agent: "code-analysis.explorer", config: { acceptance: "" } } // clear the frontmatter default
1343
+ { action: "update", agent: "code-analysis.explorer", config: { acceptanceRole: false } } // restore inferred name fallback
1020
1344
  { action: "update", chainName: "review-pipeline", config: { steps: [...] } }
1021
- { action: "delete", agent: "scout" }
1345
+ { action: "delete", agent: "explorer" }
1022
1346
  { action: "delete", chainName: "review-pipeline" }
1023
1347
 
1024
- { action: "eject", agent: "reviewer" }
1025
- { action: "eject", agent: "reviewer", agentScope: "project" }
1026
- { action: "disable", agent: "reviewer" }
1027
- { action: "enable", agent: "reviewer", agentScope: "project" }
1028
- { action: "reset", agent: "reviewer" }
1348
+ { action: "eject", agent: "commentator" }
1349
+ { action: "eject", agent: "commentator", agentScope: "project" }
1350
+ { action: "disable", agent: "commentator" }
1351
+ { action: "enable", agent: "commentator", agentScope: "project" }
1352
+ { action: "reset", agent: "commentator" }
1029
1353
  ```
1030
1354
 
1031
1355
  `create` uses `config.scope`, not `agentScope`. `config.name` is the local frontmatter name; optional `config.package` registers the runtime name as `{package}.{name}` and is saved as separate `name` and `package` frontmatter. `update` and `delete` use the runtime name and `agentScope` only when the same runtime name exists in multiple scopes. To clear optional string fields, including `package`, set them to `false` or `""`.
@@ -1038,40 +1362,48 @@ Agent definitions are not loaded into context by default. Management actions let
1038
1362
  |-------|------|---------|-------------|
1039
1363
  | `agent` | string | - | Agent name for single mode, or target for management actions. |
1040
1364
  | `task` | string | - | Task string for single mode. |
1041
- | `action` | string | - | `list`, `get`, `create`, `update`, `delete`, `status`, `interrupt`, `resume`, `steer`, `append-step`, or `doctor`. |
1365
+ | `action` | string | - | `list`, `get`, `create`, `update`, `delete`, `status`, `interrupt`, `stop`, `resume`, `steer`, `append-step`, or `doctor`. |
1042
1366
  | `chainName` | string | - | Chain name for management actions. |
1043
1367
  | `config` | object/string | - | Agent or chain config for create/update. |
1044
1368
  | `output` | `string \| false` | agent default | Override single-agent output file. |
1045
1369
  | `outputMode` | `"inline" \| "file-only"` | `inline` | Return saved output inline or as a concise saved-file reference. `file-only` requires an `output` path. |
1046
1370
  | `skill` | `string \| string[] \| false` | agent default | Override skills or disable all. |
1047
1371
  | `model` | string | agent default | Override model. |
1048
- | `tasks` | array | - | Top-level parallel tasks. Supports `agent`, `task`, `cwd`, `count`, `output`, `outputMode`, `reads`, `progress`, `skill`, `model`, `toolBudget`, and `acceptance`. |
1372
+ | `outputSchema` | object | - | Require schema-valid structured output for a direct single-agent run. |
1373
+ | `agentContract` | `{ version: 1 }` | - | Opt into generic agent contract v1. Omit to keep the current/default contract. |
1374
+ | `tasks` | array | - | Top-level parallel tasks. Supports `agent`, `task`, `cwd`, `count`, `output`, `outputMode`, `outputSchema`, `reads`, `progress`, `skill`, `model`, `toolBudget`, `acceptance`, and `agentContract`. |
1049
1375
  | `concurrency` | number | config or `4` | Top-level parallel concurrency. |
1050
1376
  | `worktree` | boolean | false | Create isolated git worktrees for parallel tasks. |
1051
- | `chain` | array | - | Sequential, static parallel, and dynamic fanout chain steps. Steps and chain parallel tasks support `phase`, `label`, `as`, `outputSchema`, and `acceptance` in addition to the usual execution fields. Dynamic fanout uses `expand`, one child `parallel` template, and `collect`. With `action: "append-step"`, pass exactly one step to append to a running async chain. |
1052
- | `context` | `fresh \| fork` | per-agent default or `fresh` | Explicit `fresh` or `fork` overrides every child. When omitted, each agent uses its own `defaultContext`; `fork` creates real branched sessions from the parent leaf. Packaged `planner`, `worker`, and `oracle` default to `fork`. |
1053
- | `chainDir` | string | temp chain dir | Persistent directory for chain artifacts. |
1377
+ | `chain` | array | - | Sequential, static parallel, and dynamic fanout chain steps. Steps and chain parallel tasks support `phase`, `label`, `as`, `outputSchema`, `acceptance`, `agentContract`, and v1-only `gateOn` in addition to the usual execution fields. Dynamic fanout uses `expand`, one child `parallel` template, and `collect`. With `action: "append-step"`, pass exactly one step to append to a running async chain. |
1378
+ | `context` | `fresh \| fork` | per-agent default or `fresh` | Explicit `fresh` or `fork` overrides every child. When omitted, each agent uses its own `defaultContext`; `fork` creates real branched sessions from the parent leaf. Packaged `architect`, `builder`, `commentator`, and `commentator` default to `fork`. |
1379
+ | `chainDir` | string | temp chain dir | Persistent directory for chain artifacts. Relative chain `output`, `reads`, and `progress` paths live under this directory. |
1054
1380
  | `view` | `fleet \| transcript` | - | Optional `status` view for the active fleet surface or transcript tail inspection. |
1055
1381
  | `lines` | number | `80` | Maximum transcript lines for `action: "status", view: "transcript"`; capped at 500. |
1056
1382
  | `clarify` | boolean | false | Show TUI preview/edit flow. Explicit `clarify: true` keeps the run foreground for the clarify UI. |
1057
1383
  | `agentScope` | `user \| project \| both` | `both` | Agent discovery scope. Project wins on collisions. |
1058
1384
  | `async` | boolean | false | Background execution. For chains, `clarify: true` explicitly keeps the run foreground for the clarify UI. |
1059
1385
  | `timeoutMs` / `maxRuntimeMs` | number | none | Optional run-level max runtime in milliseconds for foreground and async/background runs. |
1060
- | `turnBudget` | object | none | Optional assistant-turn budget `{ maxTurns, graceTurns }`. At `maxTurns` the child is warned to wrap up; after `graceTurns` (default 1) more assistant turns the run is aborted and partial output is returned. |
1061
- | `toolBudget` | object | none | Optional child tool-call budget `{ soft?, hard, block? }`. At `soft` the child is nudged to finalize. After `hard`, configured tools are blocked; `block` defaults to `read`, `grep`, `find`, and `ls`, or use `"*"` to block every tool call. Final assistant text is never blocked. |
1386
+ | `turnBudget` | object | none | Optional assistant-turn budget `{ maxTurns, graceTurns }`. At `maxTurns` the child is warned to wrap up. After the grace window (default 1), termination occurs at the next assistant boundary; a response that starts tool work records `termination-deferred` until a later boundary. Partial output is returned on abort. |
1387
+ | `toolBudget` | object | none | Optional child tool-call budget `{ soft?, hard, block? }`. At `soft` the child is nudged to finalize. After `hard`, configured tools are blocked; `block` defaults to `read`, `grep`, `find`, and `ls`, while `"*"` blocks every tool call. Final assistant text is never blocked. |
1062
1388
  | `cwd` | string | runtime cwd | Override working directory. |
1063
1389
  | `maxOutput` | object | 200KB, 5000 lines | Final output truncation limits. |
1064
1390
  | `artifacts` | boolean | true | Write debug artifacts. |
1065
1391
  | `includeProgress` | boolean | false | Include full progress in result. |
1066
1392
  | `share` | boolean | false | Upload session export to GitHub Gist. |
1067
1393
  | `sessionDir` | string | derived | Override session log directory. |
1068
- | `acceptance` | string/object/false | inferred | Override the run's inferred acceptance gates. Use `"auto"`, `"attested"`, `"checked"`, `"verified"`, `"reviewed"`, or `{ level: "none", reason: "..." }`. |
1394
+ | `acceptance` | string/object/false | inferred | Configure evidence gates with `"auto"`, `"attested"`, `"checked"`, `"verified"`, or `{ level: "none", reason: "..." }`. Independent review is orthogonal: use `review: { required: true, agent?: "commentator", focus?: "..." }`. `review-required` means evidence passed but review is pending; `reviewed` is achieved only after a real independent result. Explicit `"reviewed"` remains schema-recognized solely for actionable preflight recovery. For commentator/read-only calls, omit acceptance. `false` disables gates. With `agentContract: { version: 1 }`, omitted, `"auto"`, and `false` mean no acceptance request for that run; explicit acceptance is reported separately from execution. |
1395
+
1396
+ `agentContract: { version: 1 }` keeps existing fields and artifacts but adds derived `execution`, `acceptance`, `review`, and `effects` projections. In v1, acceptance failures do not rewrite execution success, and an explicit completion guard reports `effects.fileMutation` instead of failing the run by itself. Chain steps default to advancing on execution under v1; set `gateOn: "acceptance"` on a v1 step or parallel task when rejected acceptance should stop the chain.
1397
+
1398
+ As a conservative orchestration policy, do not set `turnBudget` or a hard `toolBudget` on implementation builders, fix builders, commentators with edit authority, or other mutation-capable children. A default tool budget blocks read/search tools rather than mutation tools, but neither assistant turns nor tool-call counts measure whether a delivery slice is buildable or safe to hand off. Hard count caps remain appropriate for explicitly read-only explorers, commentators, and validators.
1069
1399
 
1070
- `context: "fork"` fails fast when the parent session is not persisted, the current leaf is missing, or the branched child session cannot be created. When the inherited transcript contains signed Anthropic `thinking` / `redacted_thinking` blocks, `pi-subagents` strips those provider-private blocks from the forked child session and forces the child run's thinking level to `off` so Anthropic does not reject modified signatures after branching or compaction. Forking never silently downgrades to `fresh`. In multi-agent runs that omit `context`, each agent/task/step follows its own `defaultContext`, so a fresh-default scout can run fresh beside a fork-default worker. Pass explicit `context: "fork"` or `context: "fresh"` when you intentionally want one context for every child.
1400
+ Bound writer work with a narrow task and an outer `timeoutMs` or `maxRuntimeMs` that leaves enough margin for the slice. An elapsed timeout is not a mutation-safe boundary and may still signal a child during tool work. Before the deadline, use `steer` or an attention notice to request a checkpoint after the current tool returns, including changed files, build/test state, remaining work, and commit or PR state.
1071
1401
 
1072
- Use `outputMode: "file-only"` when a saved output may be large and the parent only needs a pointer. The returned text is a compact reference like `Output saved to: /abs/report.md (48.2 KB, 2847 lines). Read this file if needed.` Failed runs and save errors still return normal inline output for debugging. In chains, later `{previous}` steps receive the same compact reference when the prior step used file-only mode.
1402
+ `context: "fork"` fails fast when the parent session is not persisted, the current leaf is missing, or the branched child session cannot be created. When the inherited transcript contains signed Anthropic `thinking` / `redacted_thinking` blocks, `pi-subagents` strips those provider-private blocks from the forked child session. It forces thinking `off` only when the child’s effective primary or fallback model resolves through the model registry to the Anthropic provider or `anthropic-messages` API; unresolved models are treated conservatively. The result reports every affected child, including on failed runs. Use `context: "fresh"` when an Anthropic child needs thinking. Forking never silently downgrades to `fresh`. In multi-agent runs that omit `context`, each agent/task/step follows its own `defaultContext`, so a fresh-default explorer can run fresh beside a fork-default builder. Pass explicit `context: "fork"` or `context: "fresh"` when you intentionally want one context for every child.
1073
1403
 
1074
- Sequential and parallel chain tasks accept `agent`, `task`, `phase`, `label`, `as`, `outputSchema`, `cwd`, `output`, `outputMode`, `reads`, `progress`, `skill`, `model`, and `toolBudget`. Parallel tasks also accept `count`. Parallel step groups accept `parallel`, `concurrency`, `failFast`, and `worktree`. If `outputSchema` is present, the child must call `structured_output` with schema-valid JSON; prose-only completion or invalid JSON fails the step. Validated structured values are preserved on the step result, and `as` also exposes a compact text representation through `{outputs.name}`.
1404
+ Use `outputMode: "file-only"` when a saved output may be large and the parent only needs a pointer. The returned text is a compact reference like `Output saved to: /abs/report.md (48.2 KB, 2847 lines). Read this file if needed.` Failed runs and save errors still return normal inline output for debugging. In chains, relative `output` paths are resolved inside the chain artifact directory, not the caller's CWD; later `{previous}` steps receive the same compact reference when the prior step used file-only mode. To persist chain outputs outside the temp artifact area, pass a persistent `chainDir` or use an absolute `output` path. A child with only read-only tools does not need direct filesystem access for `output`: it returns the complete artifact in its final response and the runtime persists it. Children with mutation-capable tools retain the direct-write instruction.
1405
+
1406
+ Sequential and parallel chain tasks accept `agent`, `task`, `phase`, `label`, `as`, `outputSchema`, `cwd`, `output`, `outputMode`, `reads`, `progress`, `skill`, `model`, `toolBudget`, `acceptance`, `agentContract`, and v1-only `gateOn`. Parallel tasks also accept `count`. Parallel step groups accept `parallel`, `concurrency`, `failFast`, and `worktree`. If `outputSchema` is present, the child must call `structured_output` with schema-valid JSON; prose-only completion or invalid JSON fails the step. Validated structured values are preserved on the step result, and `as` also exposes a compact text representation through `{outputs.name}`.
1075
1407
 
1076
1408
  Status and control actions:
1077
1409
 
@@ -1083,20 +1415,23 @@ subagent({ action: "status", id: "<run-id>", view: "transcript", index: 0, lines
1083
1415
  subagent({ action: "status", id: "<nested-run-id>" })
1084
1416
  subagent({ action: "interrupt", id: "<run-id>" })
1085
1417
  subagent({ action: "interrupt", id: "<nested-run-id>" })
1086
- subagent({ action: "resume", id: "<run-id>", message: "follow-up question" })
1418
+ subagent({ action: "stop", id: "<run-id>" })
1419
+ subagent({ action: "resume", id: "<run-id>", message: "follow-up question after it pauses or finishes" })
1087
1420
  subagent({ action: "resume", id: "<run-id>", index: 1, message: "follow-up for child 2" })
1088
1421
  subagent({ action: "resume", id: "<nested-run-id>", message: "follow-up for a nested child" })
1089
1422
  subagent({ action: "steer", id: "<run-id>", message: "guidance for the running child" })
1090
1423
  subagent({ action: "steer", id: "<run-id>", index: 1, message: "guidance for child 2" })
1091
- subagent({ action: "append-step", id: "<run-id>", chain: [{ agent: "worker", task: "Continue from {previous}" }] })
1424
+ subagent({ action: "append-step", id: "<run-id>", chain: [{ agent: "builder", task: "Continue from {previous}" }] })
1092
1425
  subagent({ action: "doctor" })
1093
1426
  ```
1094
1427
 
1095
1428
  `status` resolves exact foreground ids, top-level async ids, and nested run ids before falling back to prefix matching. `view: "fleet"` is an optional read-only active-run surface with transcript commands; it does not add steering or stop controls. `view: "transcript"` tails the selected run's live `output-<index>.log` or persisted session transcript, with `lines` capped at 500. Nested status shows the root/parent path, nested children, session/artifact paths when known, and nested control commands. Inside child-safe fanout mode, bare `status` requires an id when no local foreground run is active, so children cannot enumerate unrelated top-level async runs. Bare `interrupt` still targets only the visible top-level run; interrupting a nested run requires its explicit nested id.
1096
1429
 
1097
- `resume` sends the follow-up directly when an async child is still reachable over intercom. After completion, it revives the child by starting a new async child from the stored child session file. Multi-child async runs and remembered foreground single, parallel, or chain runs can be revived by passing `index` to choose the child. Nested runs can be resumed by nested id when their live route or persisted session metadata is available. Revive starts a new child process from the old session context; it does not restart the same OS process, and it requires the chosen child to have a persisted `.jsonl` session file.
1430
+ `resume` revives a paused, completed, or failed async/foreground child by starting a new child from its stored session file; stopped runs remain non-resumable, and it does not interrupt a live top-level async child. Use `steer` for acknowledged live async guidance. Multi-child async runs and remembered foreground single, parallel, or chain runs can be revived by passing `index` to choose the child. Nested runs can be resumed by nested id when their live route or persisted nested session metadata is available. Revive starts a new child process from the old session context; it does not restart the same OS process, and it requires the chosen child to have a persisted `.jsonl` session file. Direct revival takes an exclusive cross-process lease on the canonical session file until the new child finishes. A concurrent attempt fails before Pi is spawned and identifies the owning revived run; dead-owner leases are reclaimed only when staleness can be proved.
1431
+
1432
+ `stop` ends a current-session top-level async run. It is deliberately stronger than `interrupt`: it is not a resumable pause, stopped runs should be restarted as new runs, foreground and nested targets are rejected, direct id calls execute immediately, and `/subagents-stop` without an id opens a selector with confirmation when a TUI is available. In non-TUI contexts the slash command prints exact `subagent({ action: "stop", id })` and `/subagents-stop <id>` commands. Scheduled jobs can appear in the selector, but they are labeled as scheduled cancellations and route through `schedule-cancel`, not `stop`.
1098
1433
 
1099
- `steer` queues non-terminal guidance for a running async Pi child, or for a pending indexed child that will start later in the same async run. It does not interrupt, pause, or revive a child. Delivery requires the spawned Pi session to support mid-run `sendUserMessage(..., { deliverAs: "steer" })`; unsupported runtimes keep the request visible in control artifacts but cannot receive it live. Use `index` for multi-child runs when you want to steer one child; without `index`, steering targets the currently running child or children.
1434
+ `steer` waits up to three seconds for a correlated child-Pi input acceptance and returns a request id with `delivered`, `scheduled`, `pending`, `partial`, `recovered`, or `failed` plus per-child states. Delivery means Pi accepted the user message, not model compliance. A pending indexed child returns `scheduled`. Only a top-level single run may interrupt after the acknowledgment deadline and recover after a further 15-second pause/revival bound; chain, parallel, and nested runs never auto-interrupt. Recovery launches a replacement only after the source is confirmed paused, a valid persisted session exists, and deadline, turn, and tool budgets remain. It preserves the original child contract and remaining limits; otherwise the source stays paused with an explicit failure. Late acceptance is recorded but cannot cancel committed recovery. The persisted `steering` ledger retains 20 requests and replaces the old `steerCount`/`lastSteerAt` fields.
1100
1435
 
1101
1436
  `append-step` accepts exactly one sequential, static parallel, or dynamic fanout chain step for a top-level async chain whose status is still `running`. The step is persisted in the run directory and becomes eligible only after the chain's already-queued steps finish; completed, failed, paused, foreground, single, and top-level parallel runs reject appends.
1102
1437
 
@@ -1106,17 +1441,17 @@ Parallel agents can clobber each other if they edit the same checkout. `worktree
1106
1441
 
1107
1442
  ```ts
1108
1443
  { tasks: [
1109
- { agent: "worker", task: "Implement auth", count: 2 },
1110
- { agent: "worker", task: "Implement API" }
1444
+ { agent: "builder", task: "Implement auth", count: 2 },
1445
+ { agent: "builder", task: "Implement API" }
1111
1446
  ], worktree: true }
1112
1447
 
1113
1448
  { chain: [
1114
- { agent: "scout", task: "Gather context" },
1449
+ { agent: "explorer", task: "Gather context" },
1115
1450
  { parallel: [
1116
- { agent: "worker", task: "Implement feature A from {previous}" },
1117
- { agent: "worker", task: "Implement feature B from {previous}" }
1451
+ { agent: "builder", task: "Implement feature A from {previous}" },
1452
+ { agent: "builder", task: "Implement feature B from {previous}" }
1118
1453
  ], worktree: true },
1119
- { agent: "reviewer", task: "Review all changes from {previous}" }
1454
+ { agent: "commentator", task: "Review all changes from {previous}" }
1120
1455
  ]}
1121
1456
  ```
1122
1457
 
@@ -1128,13 +1463,13 @@ Requirements:
1128
1463
  - task-level `cwd` overrides must be omitted or match the shared cwd
1129
1464
  - configured `worktreeSetupHook` must return valid JSON before timeout
1130
1465
 
1131
- By default, worktrees are created under the system temp directory. Set `worktreeBaseDir` in config, or `PI_SUBAGENTS_WORKTREE_DIR` when config is unset, to put them under a stable trusted directory. Missing base directories are created automatically.
1466
+ By default, worktrees are created under the system temp directory. Set `worktreeBaseDir` in config, or `SELESAI_SUBAGENTS_WORKTREE_DIR` when config is unset, to put them under a stable trusted directory. Missing base directories are created automatically.
1132
1467
 
1133
- After a worktree parallel step completes, per-agent diff stats are appended to the output and full patch files are written to artifacts. Worktrees and temp branches are cleaned up in `finally` blocks.
1468
+ After a worktree parallel step completes, per-agent diff stats are appended to the output and full patch files are written to artifacts. The runtime also writes a versioned aggregate handoff manifest: foreground runs use the artifact directory's `handoffs/<run-id>.json`, while async runs use `<async-dir>/handoff.json`. The manifest records each child's terminal status, summary, output/session/structured-output references, patch stats and path, and whether its worktree and temporary branch were actually removed. Foreground `details`, async `status.json` and result files, status output, intercom delivery, and completion notifications expose the manifest path. Worktrees and temp branches still receive best-effort fallback cleanup if handoff finalization cannot run.
1134
1469
 
1135
1470
  ## Configuration
1136
1471
 
1137
- `pi-subagents` reads optional JSON config from `~/.pi/agent/extensions/subagent/config.json`.
1472
+ `pi-subagents` reads optional JSON config from `~/.selesai/agent/extensions/subagent/config.json`.
1138
1473
 
1139
1474
  ### `toolDescriptionMode`
1140
1475
 
@@ -1142,9 +1477,9 @@ After a worktree parallel step completes, per-agent diff stats are appended to t
1142
1477
  { "toolDescriptionMode": "compact" }
1143
1478
  ```
1144
1479
 
1145
- Controls the parent-facing `subagent` tool description registered at startup. `full` is the default. `compact` keeps the execution modes, async/wait guidance, child-safety boundary, management/action split, one-writer review guidance, and artifact/status essentials with less prompt bloat.
1480
+ Controls the parent-facing `subagent` tool description registered at startup. `full` is the default. `compact` keeps the execution modes, async/`subagent_wait` guidance, child-safety boundary, management/action split, one-writer review guidance, and artifact/status essentials with less prompt bloat.
1146
1481
 
1147
- `custom` reads `subagent-tool-description.md` from the project config directory, then from `~/.pi/agent/subagent-tool-description.md`. Missing, empty, unreadable, or oversized custom files fall back to the full description. Custom templates may use `{{fullDescription}}`, `{{compactDescription}}`, `{{safetyGuidance}}`, `{{agentDir}}`, and `{{projectConfigDir}}`; the safety guidance is always present so custom prose cannot remove the runtime guardrails. Restart Pi after changing the mode or custom file.
1482
+ `custom` reads `subagent-tool-description.md` from the project config directory, then from `~/.selesai/agent/subagent-tool-description.md`. Missing, empty, unreadable, or oversized custom files fall back to the full description. Custom templates may use `{{fullDescription}}`, `{{compactDescription}}`, `{{safetyGuidance}}`, `{{agentDir}}`, and `{{projectConfigDir}}`; the safety guidance is always present so custom prose cannot remove the runtime guardrails. Restart Pi after changing the mode or custom file.
1148
1483
 
1149
1484
  ### `asyncByDefault`
1150
1485
 
@@ -1154,6 +1489,30 @@ Controls the parent-facing `subagent` tool description registered at startup. `f
1154
1489
 
1155
1490
  Makes top-level calls use background execution when the request does not explicitly set `async`. Callers can still force foreground with `async: false` unless `forceTopLevelAsync` is enabled.
1156
1491
 
1492
+ ### `fleetView`
1493
+
1494
+ ```json
1495
+ { "fleetView": false }
1496
+ ```
1497
+
1498
+ Controls the persistent, navigable FleetView below the editor. The default is `true`. Set it to `false` to hide FleetView without disabling status tracking, completion notifications, `/subagents-fleet`, or lifecycle events.
1499
+
1500
+ ### `asyncWidget`
1501
+
1502
+ ```json
1503
+ { "asyncWidget": true }
1504
+ ```
1505
+
1506
+ Controls the legacy above-editor widget for background runs. It defaults to `false` while FleetView is enabled and `true` when FleetView is disabled. Set it explicitly to show both surfaces or hide the legacy widget entirely.
1507
+
1508
+ ### `waitTool`
1509
+
1510
+ ```json
1511
+ { "waitTool": { "enabled": false } }
1512
+ ```
1513
+
1514
+ Keeps the `subagent_wait` tool registered but makes direct calls return immediately instead of blocking on active subagent or provider work. The default is enabled. You can also set `"waitTool": false`; set `SELESAI_SUBAGENT_WAIT_TOOL_ENABLED=false` (or `0`, `off`, `disabled`) to override config for one process. The effective value is passed explicitly to child runtimes. Headless `agent_end` auto-drain remains a lifecycle safeguard even when direct wait calls are disabled. Invalid config or environment values fail instead of being coerced.
1515
+
1157
1516
  ### `forceTopLevelAsync`
1158
1517
 
1159
1518
  ```json
@@ -1173,10 +1532,14 @@ Caps simultaneously running subagent tasks within a single run across top-level
1173
1532
  ### `maxSubagentSpawnsPerSession`
1174
1533
 
1175
1534
  ```json
1176
- { "maxSubagentSpawnsPerSession": 40 }
1535
+ { "maxSubagentSpawnsPerSession": 100 }
1177
1536
  ```
1178
1537
 
1179
- Caps the total number of child subagent launches allowed during one parent session, including single runs, parallel task counts, static chain steps, and bounded dynamic fanout children. Set `PI_SUBAGENT_MAX_SPAWNS_PER_SESSION` to override the config for a process. The default is `40`; `0` blocks new subagent launches for that session.
1538
+ Optionally caps the total number of child subagent launches during one parent session, including completed and failed children, parallel task counts, static chain steps, and bounded dynamic fanout children. Sessions are unlimited by default. Set this value to `0` to disable a configured cap. `SELESAI_SUBAGENT_MAX_SPAWNS_PER_SESSION` overrides the config for a process and follows the same positive-cap/zero-unlimited semantics.
1539
+
1540
+ `subagent({ action: "status" })`, fleet status, and `subagent({ action: "doctor" })` expose used, effective limit, remaining capacity, grants, and the remaining grant allowance. Static chains and parallel calls fail before creating run artifacts or starting partial work when their declared capacity cannot fit. Later retries or unbounded dynamic work are not guaranteed by that preflight.
1541
+
1542
+ A user may explicitly call `subagent({ action: "grant-spawn-budget", additional: 10 })` from the root interactive parent after all children settle and confirm the native prompt. Grants are additive: they never erase cumulative usage, are rejected for unlimited sessions and child/headless callers, and total granted capacity cannot exceed the original configured cap. Compaction remains part of the same logical parent session and does not reset usage or grants; starting a new parent session does.
1180
1543
 
1181
1544
  ### `scheduledRuns`
1182
1545
 
@@ -1184,7 +1547,7 @@ Caps the total number of child subagent launches allowed during one parent sessi
1184
1547
  { "scheduledRuns": { "enabled": true, "maxPending": 20, "maxLatenessMs": 300000 } }
1185
1548
  ```
1186
1549
 
1187
- Enables optional one-shot scheduled subagent runs. When enabled, `subagent({ action: "schedule", agent, task?, schedule: "+10m" | "2030-01-01T09:00:00Z", scheduleName? })` defers a subagent launch until a future time. Absolute ISO timestamps must include a timezone (`Z` or an offset such as `+05:30`). The scheduled run launches as a normal tracked async run with fresh context once it fires, and joins the existing async widget, status, `wait`, and completion-notification paths. `schedule-list`, `schedule-status`, and `schedule-cancel` manage pending jobs. Schedules are persisted per session and restored after a Pi restart; a job missed by more than `maxLatenessMs` while Pi is unavailable is marked `missed` instead of firing late. `maxPending` caps the number of pending or running scheduled jobs per session (default `20`). The feature is opt-in: leave `enabled` unset to keep scheduling out of the tool surface and prompt. Only schedule explicit delayed runs the user asked for.
1550
+ Enables optional one-shot scheduled subagent runs. When enabled, `subagent({ action: "schedule", agent, task?, schedule: "+10m" | "2030-01-01T09:00:00Z", scheduleName? })` defers a subagent launch until a future time. Absolute ISO timestamps must include a timezone (`Z` or an offset such as `+05:30`). The scheduled run launches as a normal tracked async run with fresh context once it fires, and joins the existing async widget, status, `subagent_wait`, and completion-notification paths. `schedule-list`, `schedule-status`, and `schedule-cancel` manage pending jobs. Schedules are persisted per session and restored after a Pi restart; a job missed by more than `maxLatenessMs` while Pi is unavailable is marked `missed` instead of firing late. `maxPending` caps the number of pending or running scheduled jobs per session (default `20`). The feature is opt-in: leave `enabled` unset to keep scheduling out of the tool surface and prompt. Only schedule explicit delayed runs the user asked for.
1188
1551
 
1189
1552
  ### `parallel`
1190
1553
 
@@ -1202,7 +1565,7 @@ Enables optional one-shot scheduled subagent runs. When enabled, `subagent({ act
1202
1565
  ### `defaultSessionDir`
1203
1566
 
1204
1567
  ```json
1205
- { "defaultSessionDir": "~/.pi/agent/sessions/subagent/" }
1568
+ { "defaultSessionDir": "~/.selesai/agent/sessions/subagent/" }
1206
1569
  ```
1207
1570
 
1208
1571
  Session directory precedence is: `params.sessionDir`, then `config.defaultSessionDir`, then a directory derived from the parent session. Sessions are always enabled.
@@ -1210,7 +1573,7 @@ Session directory precedence is: `params.sessionDir`, then `config.defaultSessio
1210
1573
  ### `singleRunOutputBaseDir`
1211
1574
 
1212
1575
  ```json
1213
- { "singleRunOutputBaseDir": "~/.pi/subagent-outputs" }
1576
+ { "singleRunOutputBaseDir": "~/.selesai/subagent-outputs" }
1214
1577
  ```
1215
1578
 
1216
1579
  Routes relative `output` paths for single-agent `/run` calls under this directory. Absolute per-call or agent output paths are still used as-is. When unset, relative single-run outputs go under the run's output artifact directory instead of the project root.
@@ -1221,15 +1584,15 @@ Routes relative `output` paths for single-agent `/run` calls under this director
1221
1584
  { "maxSubagentDepth": 1 }
1222
1585
  ```
1223
1586
 
1224
- Controls nested delegation when no inherited `PI_SUBAGENT_MAX_DEPTH` is already in effect. Per-agent `maxSubagentDepth` can tighten the limit for that agent’s child runs, but cannot relax an inherited stricter limit. This applies even to children that explicitly declare `tools: subagent`; at the cap, execution fanout is blocked instead of silently hiding nested work.
1587
+ Controls nested delegation when no inherited `SELESAI_SUBAGENT_MAX_DEPTH` is already in effect. Per-agent `maxSubagentDepth` can tighten the limit for that agent’s child runs, but cannot relax an inherited stricter limit. This applies even to children that explicitly declare `tools: subagent`; at the cap, execution fanout is blocked instead of silently hiding nested work.
1225
1588
 
1226
- ### `PI_SUBAGENT_PI_BINARY`
1589
+ ### `SELESAI_SUBAGENT_PI_BINARY`
1227
1590
 
1228
1591
  ```bash
1229
- export PI_SUBAGENT_PI_BINARY=/path/to/pi-or-wrapper
1592
+ export SELESAI_SUBAGENT_PI_BINARY=/path/to/pi-or-wrapper
1230
1593
  ```
1231
1594
 
1232
- Overrides the command used to launch child Pi processes. Package wrappers can set this to their own `pi`/agent binary so subagents inherit wrapper flags, environment setup, and bundled resources without relying on `PATH` ordering. Empty or whitespace-only values are ignored.
1595
+ Overrides the command used to launch child Selesai processes. Package wrappers can set this to their own `selesai`/agent binary so subagents inherit wrapper flags, environment setup, and bundled resources without relying on `PATH` ordering. Empty or whitespace-only values are ignored. Legacy `PI_SUBAGENT_*` and `PI_SUBAGENTS_*` variables remain supported when no corresponding `SELESAI_*` variable is set.
1233
1596
 
1234
1597
  ### `intercomBridge`
1235
1598
 
@@ -1247,7 +1610,7 @@ Controls whether subagents receive runtime intercom coordination instructions an
1247
1610
  Fields:
1248
1611
 
1249
1612
  - `mode`: default `always`; use `fork-only` to inject only for forked runs, or `off` to disable the bridge.
1250
- - `instructionFile`: optional Markdown template replacing the default bridge instructions. `{orchestratorTarget}` is interpolated. Relative paths resolve from `~/.pi/agent/extensions/subagent/`.
1613
+ - `instructionFile`: optional Markdown template replacing the default bridge instructions. `{orchestratorTarget}` is interpolated. Relative paths resolve from `~/.selesai/agent/extensions/subagent/`.
1251
1614
 
1252
1615
  Bridge activation requires a targetable current parent session id, which `pi-subagents` passes to children automatically. It no longer depends on an external `pi-intercom` installation or per-agent extension allowlists.
1253
1616
 
@@ -1259,7 +1622,7 @@ The default injected guidance tells children to use `contact_supervisor` with `r
1259
1622
  { "worktreeBaseDir": "/Users/matt/code/.worktrees/pi-subagents" }
1260
1623
  ```
1261
1624
 
1262
- Sets the base directory for `worktree: true` runs. Relative paths resolve from the repository root, `~/...` expands to your home directory, and `PI_SUBAGENTS_WORKTREE_DIR` is used when config is unset. The default remains the system temp directory.
1625
+ Sets the base directory for `worktree: true` runs. Relative paths resolve from the repository root, `~/...` expands to your home directory, and `SELESAI_SUBAGENTS_WORKTREE_DIR` is used when config is unset. The default remains the system temp directory.
1263
1626
 
1264
1627
  ### `worktreeSetupHook`
1265
1628
 
@@ -1280,6 +1643,18 @@ stdin is a JSON object with `repoRoot`, `worktreePath`, `agentCwd`, `branch`, `i
1280
1643
 
1281
1644
  `syntheticPaths` must be relative to the worktree root. They are removed before diff capture so helper files do not pollute patches. Tracked files are never excluded; marking a tracked path as synthetic fails setup. Default timeout is `30000` ms.
1282
1645
 
1646
+ ### `artifactDir`
1647
+
1648
+ ```json
1649
+ {
1650
+ "artifactDir": "session"
1651
+ }
1652
+ ```
1653
+
1654
+ Controls where subagent artifact files (inputs, outputs, transcripts, metadata) are stored. Defaults to `"project"`, which writes to `<cwd>/.pi-subagents/artifacts/`. Set to `"session"` to store artifacts under pi's session directory (`~/.selesai/agent/sessions/<session>/subagent-artifacts/`), keeping the working directory clean. Set to `"temp"` to use the OS temp directory.
1655
+
1656
+ The `"session"` option uses the same directory that `cleanupAllArtifactDirs` already scans for age-based cleanup, so artifacts are still cleaned up automatically.
1657
+
1283
1658
  ### `completionBatch`
1284
1659
 
1285
1660
  ```json
@@ -1316,7 +1691,7 @@ Debug artifacts live under `{sessionDir}/subagent-artifacts/`, `.pi-subagents/ar
1316
1691
  - `{runId}_{agent}.jsonl`
1317
1692
  - `{runId}_{agent}_meta.json`
1318
1693
 
1319
- Metadata records timing, usage, exit code, final model, attempted models, and fallback attempt outcomes.
1694
+ Metadata records timing, usage, exit code, final model, attempted models, fallback attempt outcomes, and the resolved acceptance ledger with its parsed child report.
1320
1695
 
1321
1696
  Session files are stored under a per-run session directory. With `context: "fork"`, each child starts with `--session <branched-session-file>` produced from the parent’s current leaf. That is a real session fork, not an injected summary.
1322
1697
 
@@ -1332,7 +1707,7 @@ Async runs write:
1332
1707
  subagent-log-<id>.md
1333
1708
  ```
1334
1709
 
1335
- `status.json` powers the widget and `subagent({ action: "status" })` output. `events.jsonl` contains wrapper events plus child Pi JSON events annotated with run and step metadata, including `subagent.steer.requested` when live async steering is queued. Nested fanout status is stored as compact sidecar event/registry metadata and merged into parent status views and result/intercom payloads; full recursive status snapshots are not embedded in parent result files. `output-<n>.log` is a live human-readable tail. Fallback information is persisted so background runs are debuggable after completion.
1710
+ `status.json` powers the widget and `subagent({ action: "status" })` output. `events.jsonl` contains wrapper events plus child Pi JSON events annotated with run and step metadata, including correlated `subagent.steer.requested`, `scheduled`, `routed`, `delivered`, `failed`, and `recovered` events plus failure/partial/recovery notices. Nested fanout status is stored as compact sidecar event/registry metadata and merged into parent status views and result/intercom payloads; full recursive status snapshots are not embedded in parent result files. `output-<n>.log` is a live human-readable tail. Fallback information is persisted so background runs are debuggable after completion.
1336
1711
 
1337
1712
  ## Acceptance Gates
1338
1713
 
@@ -1340,7 +1715,7 @@ Every run resolves an effective acceptance policy. Callers may omit `acceptance`
1340
1715
 
1341
1716
  ```ts
1342
1717
  {
1343
- agent: "worker",
1718
+ agent: "builder",
1344
1719
  task: "Implement the fix",
1345
1720
  acceptance: {
1346
1721
  level: "verified",
@@ -1351,18 +1726,23 @@ Every run resolves an effective acceptance policy. Callers may omit `acceptance`
1351
1726
  }
1352
1727
  ```
1353
1728
 
1354
- Accepted levels are `auto`, `none`, `attested`, `checked`, `verified`, and `reviewed`. `acceptance: "auto"` is the default. Read-only reviewer/scout tasks infer lightweight attestation, normal writer tasks infer checked evidence, and async/risky/dynamic writer contexts infer a reviewed gate. To disable gates, prefer `{ level: "none", reason: "..." }`.
1729
+ Acceptance evidence levels are `auto`, `none`, `attested`, `checked`, and `verified`. `acceptance: "auto"` is the default. Review is a separate gate configured with `acceptance.review`; async, risky, and dynamic writer contexts infer checked evidence plus `review: { agent: "commentator", required: true }`. Read-only tasks infer lightweight attestation, while normal writer tasks infer checked evidence without review. Agent frontmatter or `subagents.agentOverrides` may set `acceptanceRole: "read-only" | "writer"` for ambiguous tasks; explicit task mutation or no-edit intent wins over that role, while omitted metadata preserves the existing commentator/explorer/builder name heuristics. The role affects acceptance inference only and does not change tool access. The bare string `"none"` is rejected; use `{ level: "none", reason: "..." }` instead. `acceptance: false` is accepted only as a deprecated shorthand for disabling gates.
1730
+
1731
+ For commentator/read-only calls, omit `acceptance`. The explicit value `"reviewed"` is not a policy level: it remains schema-recognized only so semantic preflight can explain the mistake without spawning a child. To require review of a writer result, use `acceptance: { level: "checked", review: { required: true, agent: "commentator" } }` and orchestrate the commentator separately.
1355
1732
 
1356
- Acceptance provenance is stored separately from child prose:
1733
+ Acceptance provenance is stored separately from child prose. `evidenceStatus` preserves evidence progress when the overall status is waiting on or has completed review:
1357
1734
 
1358
1735
  - `claimed`: child finished but did not provide structured evidence.
1359
1736
  - `attested`: child returned a structured acceptance report.
1360
1737
  - `checked`: runtime structural checks passed, such as required evidence and no staged files.
1361
1738
  - `verified`: configured runtime verification commands passed. Child-reported command success does not count.
1362
- - `reviewed`: an independent reviewer result is present.
1739
+ - `review-required`: required evidence passed, but no independent commentator result has been supplied.
1740
+ - `reviewed`: an independent commentator result is present and has no blockers.
1363
1741
  - `rejected`: attestation, structural checks, verification, or review failed.
1364
1742
 
1365
- For `attested` or stricter levels, the child prompt includes a standardized acceptance section and asks for a fenced `acceptance-report` JSON block. Explicit failed gates fail the run. Inferred gates are persisted for observability without breaking older calls that omit `acceptance`.
1743
+ For `attested` or stricter levels, the child prompt includes a standardized acceptance section and asks for a fenced `acceptance-report` JSON block. The parser canonicalizes known enum synonyms, snake_case report keys and wrappers, underscore fence tags, unambiguous scalar arrays, string booleans, and criterion-id separators. Unknown or ambiguous keys and enum values fail with field-level diagnostics. Explicit empty `changedFiles` and `testsAddedOrUpdated` arrays are recorded as not applicable; missing fields and empty required command or validation evidence still fail.
1744
+
1745
+ Acceptance fences are removed from normal output artifacts, while the raw child transcript remains intact and per-child metadata stores the complete acceptance ledger and parsed report. Explicit failed gates fail the run. Inferred gates remain observable without failing the run.
1366
1746
 
1367
1747
  ## Live progress
1368
1748
 
@@ -1370,37 +1750,37 @@ Foreground runs show compact live progress for single, chain, and parallel modes
1370
1750
 
1371
1751
  Press Pi's configured expand key (`Ctrl+O` by default) to expand the full streaming view with complete output per step.
1372
1752
 
1373
- Sequential chains show a flow line like `done scout → running planner`. Chains with parallel steps show per-step cards instead. Chain status uses `label` and `phase` metadata when present, while falling back to agent names for older chains.
1753
+ Sequential chains show a flow line like `done explorer → running architect`. Chains with parallel steps show per-step cards instead. Chain status uses `label` and `phase` metadata when present, while falling back to agent names for older chains.
1374
1754
 
1375
1755
  ## Session sharing
1376
1756
 
1377
1757
  Pass `share: true` to export a full session to HTML, upload it to a secret GitHub Gist through your `gh` credentials, and return a `https://shittycodingagent.ai/session/?<gistId>` URL.
1378
1758
 
1379
1759
  ```ts
1380
- { agent: "scout", task: "...", share: true }
1760
+ { agent: "explorer", task: "...", share: true }
1381
1761
  ```
1382
1762
 
1383
1763
  This is disabled by default. Session data may contain source code, paths, environment variables, credentials, or other sensitive output. You need `gh` installed and authenticated.
1384
1764
 
1385
1765
  ## Recursion guard
1386
1766
 
1387
- Subagents can call `subagent` only when their resolved builtin tools explicitly include `subagent`. That is meant for delegated fanout agents, not ordinary worker/reviewer children. A depth guard prevents unbounded nesting.
1767
+ Subagents can call `subagent` only when their resolved builtin tools explicitly include `subagent`. That is meant for builderd fanout agents, not ordinary builder/commentator children. A depth guard prevents unbounded nesting.
1388
1768
 
1389
1769
  By default, nesting is limited to two levels: main session → subagent → sub-subagent. Deeper calls are blocked with guidance to complete the current task directly. Nested runs appear in the parent status widget and `status` output as a tree, and `status`, `interrupt`, and `resume` can target a nested run by its id.
1390
1770
 
1391
1771
  Configure the limit with:
1392
1772
 
1393
- 1. `PI_SUBAGENT_MAX_DEPTH` before starting Pi
1773
+ 1. `SELESAI_SUBAGENT_MAX_DEPTH` before starting Pi
1394
1774
  2. `config.maxSubagentDepth`
1395
1775
  3. `maxSubagentDepth` in agent frontmatter, which can only tighten the inherited limit
1396
1776
 
1397
1777
  ```bash
1398
- export PI_SUBAGENT_MAX_DEPTH=3
1399
- export PI_SUBAGENT_MAX_DEPTH=1
1400
- export PI_SUBAGENT_MAX_DEPTH=0
1778
+ export SELESAI_SUBAGENT_MAX_DEPTH=3
1779
+ export SELESAI_SUBAGENT_MAX_DEPTH=1
1780
+ export SELESAI_SUBAGENT_MAX_DEPTH=0
1401
1781
  ```
1402
1782
 
1403
- `PI_SUBAGENT_DEPTH` is internal and propagated automatically. Do not set it manually.
1783
+ `SELESAI_SUBAGENT_DEPTH` is internal and propagated automatically. Do not set it manually.
1404
1784
 
1405
1785
  ## Events
1406
1786
 
@@ -1409,6 +1789,8 @@ Async events:
1409
1789
  - `subagent:async-started`
1410
1790
  - `subagent:async-complete`
1411
1791
 
1792
+ The `subagent:async-started` payload includes `task`, the backwards-compatible first child task truncated to 50 characters, and `goal`, the workflow-level caller task truncated to 120 characters (falling back to the first child task). Companion UI extensions can combine `goal`, `workflowGraph`, and the live lifecycle artifacts under `asyncDir` without scraping terminal output.
1793
+
1412
1794
  Intercom delivery events:
1413
1795
 
1414
1796
  - `subagent:control-intercom`
@@ -1420,7 +1802,7 @@ The result watcher emits `subagent:async-complete`; `src/extension/index.ts` reg
1420
1802
 
1421
1803
  `pi-subagents` works standalone through natural language, the `subagent` tool, slash commands, and the packaged prompt shortcuts listed near the top of this README. It also includes a native prompt-workflow adapter for reusable subagent prompt templates, so you do not need `pi-prompt-template-model` for the common subagent workflow path.
1422
1804
 
1423
- Create a prompt in `.pi/prompts/` or `~/.pi/agent/prompts/`:
1805
+ Create a prompt in `.selesai/prompts/` or `~/.selesai/agent/prompts/`:
1424
1806
 
1425
1807
  ```md
1426
1808
  ---
@@ -1438,7 +1820,7 @@ Then run it through the native adapter:
1438
1820
  /prompt-workflow take-screenshot https://example.com
1439
1821
  ```
1440
1822
 
1441
- The adapter delegates to the named subagent, applies `model`, `skill`, `cwd`, `worktree`, and fork/fresh context metadata, and supports runtime overrides such as `--subagent reviewer`, `--fork`, `--fresh`, `--worktree`, and `--bg`.
1823
+ The adapter builders to the named subagent, applies `model`, `skill`, `cwd`, `worktree`, and fork/fresh context metadata, and supports runtime overrides such as `--subagent commentator`, `--fork`, `--fresh`, `--worktree`, and `--bg`.
1442
1824
 
1443
1825
  For prompt-template chains, use:
1444
1826