@selesai/code 0.5.28 → 0.5.29

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 (307) hide show
  1. package/dist/cli/args.d.ts.map +1 -1
  2. package/dist/cli/args.js +9 -1
  3. package/dist/cli/args.js.map +1 -1
  4. package/dist/cli/config-selector.d.ts.map +1 -1
  5. package/dist/cli/config-selector.js +1 -1
  6. package/dist/cli/config-selector.js.map +1 -1
  7. package/dist/cli/credential-print.d.ts +23 -0
  8. package/dist/cli/credential-print.d.ts.map +1 -0
  9. package/dist/cli/credential-print.js +117 -0
  10. package/dist/cli/credential-print.js.map +1 -0
  11. package/dist/cli/startup-ui.d.ts.map +1 -1
  12. package/dist/cli/startup-ui.js +1 -1
  13. package/dist/cli/startup-ui.js.map +1 -1
  14. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  15. package/dist/core/agent-session-runtime.js +3 -0
  16. package/dist/core/agent-session-runtime.js.map +1 -1
  17. package/dist/core/agent-session.d.ts +12 -1
  18. package/dist/core/agent-session.d.ts.map +1 -1
  19. package/dist/core/agent-session.js +20 -14
  20. package/dist/core/agent-session.js.map +1 -1
  21. package/dist/core/compaction/compaction.d.ts.map +1 -1
  22. package/dist/core/compaction/compaction.js +11 -3
  23. package/dist/core/compaction/compaction.js.map +1 -1
  24. package/dist/core/extensions/runner.d.ts +1 -0
  25. package/dist/core/extensions/runner.d.ts.map +1 -1
  26. package/dist/core/extensions/runner.js +11 -0
  27. package/dist/core/extensions/runner.js.map +1 -1
  28. package/dist/core/extensions/types.d.ts +14 -1
  29. package/dist/core/extensions/types.d.ts.map +1 -1
  30. package/dist/core/extensions/types.js.map +1 -1
  31. package/dist/core/footer-data-provider.d.ts +10 -0
  32. package/dist/core/footer-data-provider.d.ts.map +1 -1
  33. package/dist/core/footer-data-provider.js +1 -1
  34. package/dist/core/footer-data-provider.js.map +1 -1
  35. package/dist/core/llama/provider.d.ts.map +1 -1
  36. package/dist/core/llama/provider.js +8 -3
  37. package/dist/core/llama/provider.js.map +1 -1
  38. package/dist/core/model-config.d.ts +30 -0
  39. package/dist/core/model-config.d.ts.map +1 -1
  40. package/dist/core/model-config.js +6 -0
  41. package/dist/core/model-config.js.map +1 -1
  42. package/dist/core/model-registry.d.ts.map +1 -1
  43. package/dist/core/model-registry.js +2 -2
  44. package/dist/core/model-registry.js.map +1 -1
  45. package/dist/core/model-resolver.d.ts +1 -0
  46. package/dist/core/model-resolver.d.ts.map +1 -1
  47. package/dist/core/model-resolver.js +20 -3
  48. package/dist/core/model-resolver.js.map +1 -1
  49. package/dist/core/model-runtime.d.ts +2 -0
  50. package/dist/core/model-runtime.d.ts.map +1 -1
  51. package/dist/core/model-runtime.js +5 -4
  52. package/dist/core/model-runtime.js.map +1 -1
  53. package/dist/core/package-manager.d.ts.map +1 -1
  54. package/dist/core/package-manager.js +13 -6
  55. package/dist/core/package-manager.js.map +1 -1
  56. package/dist/core/remote-catalog-provider.d.ts +1 -1
  57. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  58. package/dist/core/remote-catalog-provider.js +24 -11
  59. package/dist/core/remote-catalog-provider.js.map +1 -1
  60. package/dist/core/resource-loader.d.ts +15 -0
  61. package/dist/core/resource-loader.d.ts.map +1 -1
  62. package/dist/core/resource-loader.js +66 -9
  63. package/dist/core/resource-loader.js.map +1 -1
  64. package/dist/core/settings-manager.d.ts +1 -1
  65. package/dist/core/settings-manager.d.ts.map +1 -1
  66. package/dist/core/settings-manager.js.map +1 -1
  67. package/dist/core/system-prompt.d.ts.map +1 -1
  68. package/dist/core/system-prompt.js +1 -1
  69. package/dist/core/system-prompt.js.map +1 -1
  70. package/dist/core/tools/bash.d.ts +2 -0
  71. package/dist/core/tools/bash.d.ts.map +1 -1
  72. package/dist/core/tools/bash.js +34 -5
  73. package/dist/core/tools/bash.js.map +1 -1
  74. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  75. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  76. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  77. package/dist/extensions/pi-intercom/CHANGELOG.md +249 -0
  78. package/dist/extensions/pi-intercom/README.md +102 -39
  79. package/dist/extensions/pi-intercom/broker/broker.ts +1233 -36
  80. package/dist/extensions/pi-intercom/broker/client.test.ts +83 -0
  81. package/dist/extensions/pi-intercom/broker/client.ts +315 -12
  82. package/dist/extensions/pi-intercom/broker/extension-state.ts +186 -0
  83. package/dist/extensions/pi-intercom/broker/extension.test.ts +387 -0
  84. package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -0
  85. package/dist/extensions/pi-intercom/broker/framing.ts +82 -24
  86. package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -0
  87. package/dist/extensions/pi-intercom/broker/paths.ts +117 -8
  88. package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -0
  89. package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -0
  90. package/dist/extensions/pi-intercom/broker/spawn.test.ts +160 -23
  91. package/dist/extensions/pi-intercom/broker/spawn.ts +113 -27
  92. package/dist/extensions/pi-intercom/config.test.ts +93 -0
  93. package/dist/extensions/pi-intercom/config.ts +55 -6
  94. package/dist/extensions/pi-intercom/cwd.test.ts +40 -0
  95. package/dist/extensions/pi-intercom/cwd.ts +31 -0
  96. package/dist/extensions/pi-intercom/extension-api.ts +44 -0
  97. package/dist/extensions/pi-intercom/format-context.test.ts +31 -0
  98. package/dist/extensions/pi-intercom/format-context.ts +32 -0
  99. package/dist/extensions/pi-intercom/index.ts +742 -145
  100. package/dist/extensions/pi-intercom/intercom.integration.test.ts +2646 -0
  101. package/dist/extensions/pi-intercom/package.json +15 -5
  102. package/dist/extensions/pi-intercom/reply-tracker.test.ts +134 -0
  103. package/dist/extensions/pi-intercom/reply-tracker.ts +31 -13
  104. package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +13 -11
  105. package/dist/extensions/pi-intercom/test/inline-message.test.ts +184 -0
  106. package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -0
  107. package/dist/extensions/pi-intercom/types.ts +94 -4
  108. package/dist/extensions/pi-intercom/ui/compose.ts +8 -4
  109. package/dist/extensions/pi-intercom/ui/inline-message.ts +61 -25
  110. package/dist/extensions/pi-intercom/ui/session-list.ts +7 -3
  111. package/dist/extensions/pi-subagents/CHANGELOG.md +85 -0
  112. package/dist/extensions/pi-subagents/LICENSE +21 -0
  113. package/dist/extensions/pi-subagents/README.md +146 -52
  114. package/dist/extensions/pi-subagents/agents/architect.md +1 -0
  115. package/dist/extensions/pi-subagents/agents/builder.md +1 -0
  116. package/dist/extensions/pi-subagents/package-lock.json +2 -2
  117. package/dist/extensions/pi-subagents/package.json +3 -3
  118. package/dist/extensions/pi-subagents/prompts/review-loop.md +1 -1
  119. package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +21 -989
  120. package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +256 -0
  121. package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +430 -0
  122. package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +144 -0
  123. package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +282 -0
  124. package/dist/extensions/pi-subagents/src/agents/agent-management.ts +71 -30
  125. package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +4 -0
  126. package/dist/extensions/pi-subagents/src/agents/agents.ts +118 -9
  127. package/dist/extensions/pi-subagents/src/agents/skills.ts +14 -12
  128. package/dist/extensions/pi-subagents/src/api/delegation.ts +3 -0
  129. package/dist/extensions/pi-subagents/src/api/preflight.ts +16 -12
  130. package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +17 -1
  131. package/dist/extensions/pi-subagents/src/extension/index.ts +17 -7
  132. package/dist/extensions/pi-subagents/src/extension/rpc.ts +248 -6
  133. package/dist/extensions/pi-subagents/src/extension/schemas.ts +31 -6
  134. package/dist/extensions/pi-subagents/src/extension/tool-description.ts +8 -7
  135. package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +9 -4
  136. package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +33 -4
  137. package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +63 -16
  138. package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +24 -13
  139. package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +7 -5
  140. package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -2
  141. package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +48 -5
  142. package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +68 -1
  143. package/dist/extensions/pi-subagents/src/runs/background/notify.ts +29 -4
  144. package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +29 -6
  145. package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +29 -3
  146. package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +372 -28
  147. package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +65 -0
  148. package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +3 -3
  149. package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +143 -43
  150. package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +527 -247
  151. package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +42 -0
  152. package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +426 -123
  153. package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +15 -7
  154. package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +51 -19
  155. package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +3 -1
  156. package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
  157. package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +44 -11
  158. package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +8 -0
  159. package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +97 -20
  160. package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +43 -12
  161. package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +52 -4
  162. package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +19 -0
  163. package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +45 -9
  164. package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
  165. package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +31 -1
  166. package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +101 -0
  167. package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +1 -1
  168. package/dist/extensions/pi-subagents/src/runs/shared/usage-budget.ts +65 -0
  169. package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +26 -1
  170. package/dist/extensions/pi-subagents/src/shared/settings.ts +17 -1
  171. package/dist/extensions/pi-subagents/src/shared/types.ts +155 -10
  172. package/dist/extensions/pi-subagents/src/shared/utils.ts +73 -4
  173. package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +5 -0
  174. package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +46 -4
  175. package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +5 -3
  176. package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +87 -24
  177. package/dist/extensions/pi-subagents/src/tui/fleet.ts +182 -9
  178. package/dist/extensions/pi-subagents/src/tui/render.ts +27 -28
  179. package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +14 -7
  180. package/dist/extensions/pi-subagents/src/watchdog/review.ts +5 -4
  181. package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +170 -17
  182. package/dist/extensions/pi-subagents/src/watchdog/scope.ts +62 -0
  183. package/dist/extensions/pi-subagents/src/watchdog/settings.ts +41 -1
  184. package/dist/extensions/pi-subagents/src/watchdog/types.ts +10 -0
  185. package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
  186. package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +348 -7
  187. package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +84 -0
  188. package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +4 -2
  189. package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +51 -2
  190. package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +26 -1
  191. package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +48 -0
  192. package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +3 -3
  193. package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +213 -13
  194. package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +34 -0
  195. package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +44 -0
  196. package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +118 -12
  197. package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +850 -7
  198. package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +112 -23
  199. package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +17 -5
  200. package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
  201. package/dist/extensions/pi-subagents/test/support/register-loader.mjs +3 -3
  202. package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +3 -1
  203. package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +128 -0
  204. package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +47 -2
  205. package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +60 -0
  206. package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +8 -0
  207. package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +102 -0
  208. package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +1 -1
  209. package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +6 -0
  210. package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +1 -1
  211. package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +48 -48
  212. package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +23 -0
  213. package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +27 -0
  214. package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +4 -2
  215. package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +1 -0
  216. package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +176 -8
  217. package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +164 -5
  218. package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +41 -1
  219. package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +11 -11
  220. package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +18 -2
  221. package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +20 -1
  222. package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +30 -2
  223. package/dist/extensions/pi-subagents/test/unit/notify.test.ts +10 -2
  224. package/dist/extensions/pi-subagents/test/unit/parallel-utils.test.ts +22 -0
  225. package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +103 -0
  226. package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +18 -0
  227. package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +46 -0
  228. package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +13 -1
  229. package/dist/extensions/pi-subagents/test/unit/result-intercom.test.ts +29 -4
  230. package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +223 -4
  231. package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +30 -0
  232. package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +52 -0
  233. package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +34 -2
  234. package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
  235. package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +1 -1
  236. package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +78 -0
  237. package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +41 -0
  238. package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +77 -0
  239. package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +3 -0
  240. package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +1 -1
  241. package/dist/extensions/pi-subagents/test/unit/total-cost.test.ts +1 -0
  242. package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +210 -1
  243. package/dist/extensions/pi-subagents/test/unit/watchdog-scope.test.ts +33 -0
  244. package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +32 -0
  245. package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +1 -1
  246. package/dist/main.d.ts.map +1 -1
  247. package/dist/main.js +43 -0
  248. package/dist/main.js.map +1 -1
  249. package/dist/modes/interactive/components/custom-message.d.ts +3 -1
  250. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  251. package/dist/modes/interactive/components/custom-message.js +10 -2
  252. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  253. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  254. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  255. package/dist/modes/interactive/components/extension-editor.js +16 -46
  256. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  257. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  258. package/dist/modes/interactive/components/model-selector.js +4 -1
  259. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  260. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  261. package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
  262. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  263. package/dist/modes/interactive/external-editor.d.ts +12 -0
  264. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  265. package/dist/modes/interactive/external-editor.js +37 -0
  266. package/dist/modes/interactive/external-editor.js.map +1 -0
  267. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  268. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  269. package/dist/modes/interactive/interactive-mode.js +72 -64
  270. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  271. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  272. package/dist/modes/rpc/rpc-mode.js +14 -0
  273. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  274. package/dist/utils/clipboard.d.ts.map +1 -1
  275. package/dist/utils/clipboard.js +19 -8
  276. package/dist/utils/clipboard.js.map +1 -1
  277. package/dist/utils/version-check.d.ts.map +1 -1
  278. package/dist/utils/version-check.js +1 -1
  279. package/dist/utils/version-check.js.map +1 -1
  280. package/docs/compaction.md +1 -1
  281. package/docs/custom-provider.md +14 -5
  282. package/docs/environment-variables.md +86 -0
  283. package/docs/extensions.md +15 -5
  284. package/docs/index.md +1 -0
  285. package/docs/models.md +9 -2
  286. package/docs/providers.md +21 -2
  287. package/docs/rpc.md +23 -6
  288. package/docs/session-format.md +2 -0
  289. package/docs/settings.md +1 -1
  290. package/docs/usage.md +0 -13
  291. package/examples/extensions/custom-compaction.ts +5 -2
  292. package/examples/extensions/custom-provider-anthropic/index.ts +9 -3
  293. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  294. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  295. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  296. package/examples/extensions/gondolin/package-lock.json +2 -2
  297. package/examples/extensions/gondolin/package.json +1 -1
  298. package/examples/extensions/handoff.ts +11 -3
  299. package/examples/extensions/message-renderer.ts +3 -3
  300. package/examples/extensions/sandbox/package-lock.json +2 -2
  301. package/examples/extensions/sandbox/package.json +1 -1
  302. package/examples/extensions/summarize.ts +5 -2
  303. package/examples/extensions/with-deps/package-lock.json +2 -2
  304. package/examples/extensions/with-deps/package.json +1 -1
  305. package/examples/sdk/12-full-control.ts +3 -1
  306. package/package.json +15 -6
  307. package/dist/extensions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
@@ -0,0 +1,282 @@
1
+ # Pi Subagents: Prompting And Roles
2
+
3
+ This file is a detailed reference loaded from `skills/pi-subagents/SKILL.md`.
4
+
5
+ ## Capability ceilings
6
+
7
+ Parent extensions may register a session-scoped, out-of-band ceiling through `pi-subagents/capability-ceiling`. Child tools and eligible canonical agent names are intersected with every active registration and inherited snapshot; `denyExtensions` removes ambient/provider extension loading while retaining package protocol runtime. `{ action: "list" }` marks non-allowlisted agents as restricted, and launch rejects them before spawn. Do not add a model-visible ceiling field or rely on unrestricted role selection for enforcement. Restricted schedules are rejected until their ceiling can be persisted safely.
8
+
9
+ ## When to Use
10
+
11
+ - **Complex work orchestration**: use Fable mode as the default parent-agent loop for complex work. Complex means the task has multiple moving parts, unclear acceptance, cross-cutting code, meaningful user-visible impact, expensive or irreversible validation, broad review surface, or the user asks for orchestration. Lightweight one-off delegation can stay lightweight.
12
+ - **Advisory review**: use fresh-context `commentator` agents for adversarial code review, or fork to `commentator` when inherited decisions and drift matter
13
+ - **Implementation handoff**: have `commentator` advise, then `builder` implement only after an approved direction
14
+ - **Recon and planning**: use `explorer` or `explorer`, then `architect`
15
+ - **Parallel exploration**: run multiple non-conflicting tasks concurrently
16
+ - **Regular skill specialists**: when discovery shows proactive skill subagent suggestions and the current work is broad enough, launch a small fresh-context fanout that asks one subagent per relevant regularly used skill to apply that skill's perspective to the task
17
+ - **Long-running work**: launch async/background runs and inspect them later. For mutation-capable work, bound the delivery slice and elapsed runtime, then request checkpoints after active tool work returns. Reserve hard turn and tool-call caps for explicitly read-only children.
18
+ - **Subagent control**: watch needs-attention signals and soft-interrupt only when a delegated run is genuinely blocked
19
+ - **Agent authoring**: create, update, or override agents and chains for a project
20
+
21
+ ## Tool vs Slash Commands
22
+
23
+ Agents can use the `subagent(...)` tool directly for execution, management, status, and control.
24
+ Humans often use the slash-command layer instead:
25
+
26
+ - `/run` — launch a single agent
27
+ - `/chain` — launch a chain of steps
28
+ - `/parallel` — launch top-level parallel tasks
29
+ - `/run-chain` — launch a saved `.chain.md` or `.chain.json` workflow
30
+ - `/subagents` — interactive admin for inspecting agents and editing model, thinking, or system prompt
31
+ - `/subagents-stop [run-id]` — stop a current-session top-level async run; opens a selector when no id is given
32
+ - `/subagents-detach [run-id]` — detach an active foreground single-subagent run without terminating its child
33
+ - `/subagent-cost` — show parent plus child token usage and cost for the session
34
+ - `/subagents-fleet` — open the live fleet inspector with per-child controls; `Ctrl+Alt+F` opens it during an active foreground turn, `↑↓`/`jk` selects children, `PgUp`/`PgDn` scrolls transcript detail, `s` steers the selected live async child, and `D` stops its top-level async run after confirmation
35
+ - `/subagents-watchdog` — inspect or configure the opt-in adversarial change watchdog (model, on/off, recommend-model, check)
36
+ - `/subagents-doctor` — diagnose setup, discovery, async paths, and intercom bridge state
37
+ - `/subagents-models [agent]` — show the live runtime-loaded builtin model mapping
38
+ - `/subagents-profiles`, `/subagents-load-profile`, `/subagents-refresh-provider-models`, `/subagents-generate-profiles`, `/subagents-check-profile` — manage model profiles and provider catalogs
39
+ - `/prompt-workflow` and `/chain-prompts` — run prompt templates through native subagent single/chain workflows
40
+
41
+ Prefer the tool when you are writing agent logic. Prefer the slash commands when
42
+ you are guiding a human through an interactive flow.
43
+
44
+ Packaged prompt shortcuts are also available for repeatable workflows. Treat them as reusable orchestration recipes, not just human slash commands. When the user asks for one of these shapes, or when the workflow clearly fits, apply the same pattern directly with `subagent(...)` and other tools:
45
+ - `/parallel-review` — fresh-context commentators with distinct review angles, then synthesis
46
+ - `/review-loop` — parent-orchestrated builder, fresh-commentator, and fix-builder cycles until clean or capped
47
+ - `/parallel-research` — combine `researcher` and `explorer` for external evidence plus local code context
48
+ - `/parallel-context-build` — parallel `explorer` passes that produce planning handoff context and meta-prompts
49
+ - `/parallel-handoff-plan` — external-reference research plus local `explorer` passes, followed by a synthesis handoff plan and implementation-ready meta-prompt
50
+ - `/gather-context-and-clarify` — explorer/research first, then ask the user clarifying questions with `interview`
51
+ - `/parallel-cleanup` — two fresh-context commentators (deslop + verbosity passes) for an adversarial cleanup review of the current diff
52
+
53
+ ## Applying Prompt Techniques Without Slash Commands
54
+
55
+ The prompt templates in `prompts/` encode workflows the parent agent can run on demand. If the user provides a URL, issue, PR, plan, local file, screenshot, or freeform target, treat that target as the primary scope: read or fetch it before launching children, then include it explicitly in every child task. Do not depend on the parent conversation history when the recipe calls for fresh context.
56
+
57
+ ### Parallel review technique
58
+
59
+ Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. Launch fresh-context `commentator` agents with distinct angles generated from the actual target. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability; adapt for TypeScript, UI, security, docs, or large structural changes. commentators should inspect files and diffs directly, return concise evidence-backed findings with file/line references, and avoid edits unless the user explicitly asks for a writer pass. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
60
+
61
+ ### Proactive skill-specialist technique
62
+
63
+ Use this when `{ action: "list" }` reports proactive skill subagent suggestions and the user's task would benefit from perspectives the parent regularly uses. These suggestions are conservative: a skill is recommended only when it is available and referenced repeatedly by configured agents or saved chains. Treat the list as an opt-in hint for the current task, not a command to always fan out.
64
+
65
+ Default guardrails:
66
+ - Keep the fanout small: usually one or two skill-specialist children, never more than the listed recommendations or configured cap.
67
+ - Prefer `context: "fresh"` and include only the files, diff, plan, URL, or request details each child needs. Use forked context only when private/session history is essential and appropriate to share.
68
+ - Use read-only agents for analysis/review unless implementation was explicitly requested; do not create several writers in the same worktree.
69
+ - Skip proactive skill subagents for tiny questions, direct commands, highly private requests, or when the user asks not to delegate.
70
+ - Make cost and concurrency visible by using an ordinary `subagent(...)` call rather than hidden/background automation.
71
+
72
+ Example shape:
73
+
74
+ ```typescript
75
+ subagent({
76
+ tasks: [
77
+ { agent: "commentator", task: "Apply the available 'deslop' skill to review the current diff for concrete cleanup findings only. Do not modify files.", skill: "deslop" },
78
+ { agent: "commentator", task: "Apply the available 'accessibility' skill to review the UI changes for concrete issues only. Do not modify files.", skill: "accessibility" }
79
+ ],
80
+ context: "fresh",
81
+ concurrency: 2
82
+ })
83
+ ```
84
+
85
+ ### Review-loop technique
86
+
87
+ Use this when the user wants implementation or current diff review to continue until commentators stop finding fixes worth doing now. Keep the loop in the parent session: one async `builder` implements or fixes, fresh-context `commentator` agents inspect the actual repo and diff, the parent synthesizes accepted fixes, and one async forked `builder` applies them. The parent can express the sequence up front as an async/background chain when the workflow is known, or continue with explicit follow-up subagent runs after each async completion. For an initial chain, pass `async: true` so the main chat is unblocked; do not set `clarify: true` unless the user explicitly wants the foreground clarify UI. Treat an async implementation builder handoff as an intermediate state, not final completion, unless the user explicitly asked for builder-only work, review-only output, or to stop after implementation. Stop when commentators find no blockers or fixes worth doing now, remaining feedback is optional or deferred, an unapproved product/scope/architecture decision appears, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. Do not loop for optional polish, and do not let children launch subagents or decide the loop outcome.
88
+
89
+ As a conservative orchestration policy, do not pass `turnBudget` or a hard `toolBudget` to an implementation builder, fix builder, commentator with edit authority, or other mutation-capable child. The default tool budget blocks read/search tools rather than mutation tools, but count limits still do not measure delivery safety. Use a narrow task plus an outer elapsed deadline with enough margin, then request a checkpoint after the current tool returns. The checkpoint should report changed files, build/test state, remaining work, and commit or PR state. An elapsed timeout is not a mutation-safe boundary and must not be used as the checkpoint trigger.
90
+
91
+ ### Parallel research technique
92
+
93
+ Use this when the question needs both external evidence and local implications. Combine `researcher` for official docs, specs, ecosystem behavior, recent changes, benchmarks, and primary sources with `explorer` for repository files, patterns, constraints, tests, and likely integration points. Give each child a distinct angle: external evidence, local code context, and practical tradeoffs. Ask for source links or file ranges, confidence level, gaps, and decision implications. Do not ask these children to edit unless implementation was explicitly requested.
94
+
95
+ ### Parallel context-build technique
96
+
97
+ Use this before planning or implementation when a stronger handoff is needed. Run a chain with one parallel step of `explorer` agents rather than top-level parallel tasks, so relative output files live under the temporary chain directory. Give every task a distinct output path such as `context-build/request-and-scope.md`, `context-build/codebase-and-patterns.md`, and `context-build/validation-and-risks.md`. Choose two or three builders: request/scope, codebase/patterns, and validation/risks. Each builder must read every relevant file needed to understand its slice, follow imports/callers/tests/docs/config, conduct tool-available web research when needed, and include a compact `meta-prompt` section. The parent synthesizes the outputs into important context, recommended next meta-prompt, open questions, assumptions, and artifact paths.
98
+
99
+ Example shape:
100
+
101
+ ```typescript
102
+ subagent({
103
+ chain: [{
104
+ parallel: [
105
+ { agent: "explorer", task: "Build request/scope context for: ...", output: "context-build/request-and-scope.md" },
106
+ { agent: "explorer", task: "Build codebase/pattern context for: ...", output: "context-build/codebase-and-patterns.md" },
107
+ { agent: "explorer", task: "Build validation/risk context for: ...", output: "context-build/validation-and-risks.md" }
108
+ ]
109
+ }],
110
+ context: "fresh"
111
+ })
112
+ ```
113
+
114
+ ### Parallel handoff-plan technique
115
+
116
+ Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context, such as “study this library behavior, inspect our codebase, then produce a builder prompt.” Run a chain with a first parallel group and a second synthesis `explorer` step. The first group usually includes `researcher` for external projects/docs/prompt guidance and `explorer` for local code context; add a second `explorer` for implementation strategy only when the scope is large enough to benefit. Use distinct output paths under `handoff/`, then have the synthesis `explorer` read those outputs and write `handoff/final-handoff-plan.md` with the recommended approach, likely files, constraints, non-goals, validation, risks, unresolved questions, and final compact implementation-ready meta-prompt.
117
+
118
+ Example shape:
119
+
120
+ ```typescript
121
+ subagent({
122
+ chain: [
123
+ { parallel: [
124
+ { agent: "researcher", task: "Research the external reference and transferable implementation ideas for: ...", output: "handoff/external-reference.md" },
125
+ { agent: "explorer", task: "Build local codebase context for: ...", output: "handoff/local-context.md" },
126
+ { agent: "explorer", task: "Compare evidence and propose implementation strategy for: ...", output: "handoff/implementation-strategy.md" }
127
+ ] },
128
+ { agent: "explorer", task: "Read {previous} and synthesize the final handoff plan and implementation-ready meta-prompt.", output: "handoff/final-handoff-plan.md" }
129
+ ],
130
+ context: "fresh"
131
+ })
132
+ ```
133
+
134
+ ### Gather-context-and-clarify technique
135
+
136
+ Use this at the start of non-trivial work. Launch `explorer` for local context and `researcher` only when external docs, recent sources, ecosystem context, or primary evidence would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
137
+
138
+ ### Parallel cleanup technique
139
+
140
+ Use this after implementation when the user wants cleanup review or when a final pass would reduce AI-slop. Launch two fresh-context `commentator` tasks with `output: false` and `progress: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that commentator; otherwise inline the criteria. Both commentators are review-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. Phrase the constraint as “Do not modify project/source files; returning findings through the configured output artifact is allowed” when you use `output` or `outputMode: "file-only"`. The parent decides what to apply and asks before making changes unless cleanup was already authorized.
141
+
142
+ ### Staged fix orchestration technique
143
+
144
+ Use this when a broad diff has known commentator findings across several items and the user wants the parent to “orchestrate subagents like a boss.” Keep the active worktree safe with a three-stage chain:
145
+
146
+ 1. A parallel read-only planning fanout, one architect/commentator per issue cluster. Each child inspects the real diff and returns exact files, line refs, proposed fixes, and focused validation. They must not edit.
147
+ 2. One writer builder. It receives the architect summaries through `{previous}`, the parent’s accepted scope, stop rules, and verification contract. It is the only child allowed to edit the active worktree.
148
+ 3. A parallel read-only validation fanout. Validators inspect the builder diff from fresh context with distinct angles, report pass/fail, remaining blockers, and missing verification.
149
+
150
+ Prefer `async: true`, `context: "fresh"` for architects/validators, `outputMode: "file-only"` for large summaries, and per-stage output names that will not collide. Add `phase` and `label` to make async status readable, and use `as` plus `{outputs.name}` when a later step needs a specific earlier result instead of the whole `{previous}` blob. Use this pattern instead of launching several writer builders into a dirty worktree. Include non-blocking suggestions in the writer prompt only when they are small, safe, and do not expand product scope; otherwise record them as deferred.
151
+
152
+ When the first step can return a structured target list, prefer dynamic fanout instead of hand-authoring a static parallel group. Use `outputSchema` and `as` on the producer, then an `expand` step with `from: { output, path }`, an explicit `maxItems`, one `parallel` child template, and `collect.as`. Item templates may use `{item}` or a named item such as `{target.path}`. Do not use dynamic fanout for prose outputs, nested fanout, dynamic agent selection, reducers, `when` conditions, or arbitrary expressions; `.chain.md` does not support this syntax, so use direct JSON or a saved `.chain.json`.
153
+
154
+ Example shape:
155
+
156
+ ```typescript
157
+ subagent({
158
+ async: true,
159
+ context: "fresh",
160
+ chain: [
161
+ { parallel: [
162
+ { agent: "commentator", phase: "Planning", label: "Deploy docs", as: "deployPlan", task: "Plan fixes for deploy docs/workflow. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/deploy.md", outputMode: "file-only" },
163
+ { agent: "commentator", phase: "Planning", label: "Scheduler contract", as: "schedulerPlan", task: "Plan fixes for scheduler contract. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/scheduler.md", outputMode: "file-only" },
164
+ { agent: "commentator", phase: "Planning", label: "Sandbox/security", as: "sandboxPlan", task: "Plan fixes for sandbox/security. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/sandbox.md", outputMode: "file-only" }
165
+ ], concurrency: 3 },
166
+ { agent: "builder", phase: "Implementation", label: "Apply accepted fixes", as: "workerResult", task: "Apply only the accepted fixes from these planning summaries. You are the sole writer for the active worktree. Run focused validation and report changed files, commands, failures, and remaining issues.\n\nDeploy plan:\n{outputs.deployPlan}\n\nScheduler plan:\n{outputs.schedulerPlan}\n\nSandbox plan:\n{outputs.sandboxPlan}", output: "builder/fixes.md", outputMode: "file-only", progress: true },
167
+ { parallel: [
168
+ { agent: "commentator", phase: "Validation", label: "Deploy/scheduler validation", task: "Validate the post-builder diff for deploy and scheduler fixes. Start from the builder result: {outputs.workerResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/deploy-scheduler.md", outputMode: "file-only" },
169
+ { agent: "commentator", phase: "Validation", label: "Sandbox validation", task: "Validate the post-builder diff for sandbox/security fixes. Start from the builder result: {outputs.workerResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/sandbox.md", outputMode: "file-only" }
170
+ ], concurrency: 2 }
171
+ ]
172
+ })
173
+ ```
174
+
175
+ ## Builtin Agents
176
+
177
+ Builtin agents load at the lowest priority. Project agents override user agents,
178
+ and user/project agents override builtins with the same name.
179
+
180
+ | Agent | Purpose | Model | Typical output / role |
181
+ |-------|---------|-------|------------------------|
182
+ | `explorer` | Fast codebase recon | inherits default | Writes `context.md` handoff material |
183
+ | `architect` | Creates implementation plans | inherits default | Writes `plan.md` |
184
+ | `builder` | Implementation and approved commentator handoffs | inherits default | Single-writer implementation with decision escalation |
185
+ | `commentator` | Review specialist | inherits default | Default recipes are review-only; tools include edit/write when a fix pass is explicit |
186
+ | `explorer` | Requirements/codebase handoff builder | inherits default | Writes structured context files |
187
+ | `researcher` | Web research brief generator | inherits default | Writes `research.md` |
188
+ | `builder` | Lightweight generic builder | inherits default | No fixed output; generic delegated work |
189
+ | `commentator` | Decision-consistency advisory review | inherits default | Advisory review, intercom coordination |
190
+ | `commentator` | Claude Code-compatible alias for `commentator` | inherits default | Same advisory role as `commentator` |
191
+
192
+ Builtin `builder` and `builder` use strict tool allowlists and do not inherit ambient parent extension tools. To give a child an extension tool, name it in `tools` and load its provider via `extensions`, a path-like `tools` entry, or `subagentOnlyExtensions`. Custom agents without an `extensions` field follow `subagents.defaultExtensions` when set.
193
+
194
+ Builtin agents inherit the current Pi default model unless a run, user setting, project setting, or `subagents.defaultModel` overrides `model`. Set `subagents.defaultModel` when subagents should use a different default model than the parent session. Override builtin defaults before copying full agent files when a small tweak is enough.
195
+
196
+ Set `subagents.defaultThinking` to apply a shared thinking level to builtin, package, user, and project agents whose frontmatter leaves `thinking` unset. Project settings win over user settings; explicit frontmatter (including `thinking: false`), `agentOverrides.<name>.thinking`, and per-run overrides remain more specific. This setting affects child agents only and does not change the parent session's default thinking level.
197
+
198
+ ```json
199
+ {
200
+ "subagents": {
201
+ "defaultThinking": "medium"
202
+ }
203
+ }
204
+ ```
205
+
206
+ For one run, use inline config:
207
+
208
+ ```text
209
+ /run commentator[model=anthropic/claude-sonnet-4] "Review this diff"
210
+ ```
211
+
212
+ For persistent tweaks, edit `subagents.agentOverrides` in user or project settings. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides. Use `/subagents-models` or `subagent({ action: "models" })` to inspect the live mapping after settings and overrides load.
213
+
214
+ Model ids do not have to be exact. Separator variations (`claude-haiku-4.5` vs `claude-haiku-4-5`), case (`Claude-Sonnet-4`), and optional trailing date stamps (`claude-haiku-4-5-20251001`) all resolve to the same registry model. Exact `provider/id` wins; a qualified `provider/model` never switches providers. To constrain subagents to a budget or compliance profile, set `subagents.modelScope: { enforce: true, allow: ["anthropic/*", "openai/gpt-5-*"] }` in user or project settings. Out-of-scope models you pass explicitly error and abort; models inherited from frontmatter, `subagents.defaultModel`, agent frontmatter, or the parent session only warn.
215
+
216
+ For model fleets, use the profile commands instead of hand-editing repeated overrides: `/subagents-refresh-provider-models <provider>`, `/subagents-generate-profiles <provider>`, `/subagents-load-profile <name>`, and `/subagents-check-profile <name>`. Profiles live under `~/.selesai/agent/profiles/pi-subagents/` and replace only `settings.subagents` when loaded.
217
+
218
+ ## Prompting role subagents
219
+
220
+ Builtin role agents inherit the current Pi default model unless you override them. When launching them, write the task prompt as a compact contract, not a long procedural script. Define the destination and let the role choose the efficient path.
221
+
222
+ A strong subagent prompt usually includes:
223
+ - **Goal**: the concrete outcome the child should produce.
224
+ - **Context/evidence**: relevant plan paths, files, diffs, decisions, or user constraints already approved.
225
+ - **Success criteria**: what must be true before the child can finish.
226
+ - **Hard constraints**: true invariants only, such as no edits for review-only tasks, one writer thread, child must not run subagents unless it is an explicitly assigned `tools: subagent` fanout child, or escalation for unapproved decisions.
227
+ - **Validation**: targeted checks to run, or the next-best check when validation is impossible.
228
+ - **Output**: the expected summary shape, artifact path, or finding format.
229
+ - **Stop rules**: when to ask via `intercom`, when to stop after enough evidence, and when not to keep searching.
230
+
231
+ Avoid carrying over old prompt habits that over-specify every step. Use `must`, `always`, and `never` for real invariants; for judgment calls, give decision rules. For example, tell a commentator to inspect the staged diff directly and report only evidence-backed findings, rather than prescribing every file or command. Tell a researcher the retrieval budget: start with broad targeted searches, fetch only the strongest sources, search again only when a required fact is missing, then stop.
232
+
233
+ For implementation handoffs, name the approved scope and success criteria more clearly than the process. Good prompts say what to change, what not to change, where the evidence lives, how to validate, and when to escalate. They should not ask the child to create another subagent plan or continue the parent conversation.
234
+
235
+ Settings locations:
236
+ - User scope: `~/.selesai/agent/settings.json`
237
+ - Project scope: `.selesai/settings.json`
238
+
239
+ Direct settings example:
240
+
241
+ ```json
242
+ {
243
+ "subagents": {
244
+ "agentOverrides": {
245
+ "commentator": {
246
+ "model": "anthropic/claude-sonnet-4",
247
+ "thinking": "high",
248
+ "fallbackModels": ["openai/gpt-5-mini"],
249
+ "acceptanceRole": "read-only"
250
+ }
251
+ }
252
+ }
253
+ }
254
+ ```
255
+
256
+ Useful override fields: `description`, `model`, `fallbackModels`, `thinking`,
257
+ `systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `defaultContext`,
258
+ `acceptanceRole`, `disabled`, `skills`, `tools`, `extensions`, and `systemPrompt`.
259
+ `description` replaces the discovered description for builtin and custom agents
260
+ in `list` output, which is useful for deployment-specific routing notes.
261
+ Use `acceptanceRole: false` to clear an override. Create a user or project
262
+ agent with the same name only when you want a substantially different agent.
263
+
264
+ ### Recommended model tiering (optional)
265
+
266
+ When several providers are available, route agents by task shape instead of one model for everything:
267
+
268
+ 1. **Fast workhorse** — cheapest capable model at low thinking for recon, lookups, and mechanical edits (for example on `explorer`).
269
+ 2. **Standard well-scoped** — mid-tier model at medium thinking for most delegations: routine multi-file edits, focused reviews, straightforward implementation (for example on `builder`, `commentator`, `builder`).
270
+ 3. **Deep but bounded** — top reasoning model at high thinking only for hard tasks that arrive with explicit goals and completion criteria; these models loop on vague goals (for example on `architect` and commentator-style agents).
271
+ 4. **Taste and intent** — a model that reads human intent well for ambiguous work: UX/design judgment, product tradeoffs, planning from vague requirements, writing quality.
272
+
273
+ Routing rule: use tiers 1–3 when the task is well-scoped; use tier 4 when scoping or judging is the task itself. Give tier-4 agents cross-provider `fallbackModels` so subscription usage limits degrade gracefully; fallback triggers automatically on rate-limit and overload errors. Note that forked context over an Anthropic parent transcript with signed thinking blocks forces the child's thinking off, so intent-tier agents work best with fresh context.
274
+
275
+ If a provider rejects model IDs with thinking suffixes, use
276
+ `subagents.disableThinking: true` in user or project settings to clear bundled
277
+ builtin thinking defaults globally. A higher-precedence per-agent `thinking`
278
+ override can opt one builtin back in. Existing custom-agent frontmatter remains authoritative.
279
+
280
+ Set `subagents.defaultExtensions` to give agents without an `extensions` field a shared child extension allowlist. Omit it to preserve ambient extension discovery, set it to `[]` to disable ambient extensions by default, or use `agentOverrides.<name>.extensions` for one agent. Explicit custom-agent frontmatter still wins.
281
+
282
+ Tool description modes live in `~/.selesai/agent/extensions/subagent/config.json`, not `subagents` settings. Set `toolDescriptionMode` to `compact` to reduce tool-description prompt cost while keeping the execution, async/`subagent_wait`, child-safety, one-writer, management/action, and artifact/status guardrails. Set it to `custom` to read `subagent-tool-description.md` from the project config dir or agent dir; invalid custom files fall back to full mode and the safety guidance is still appended.
@@ -19,6 +19,7 @@ import {
19
19
  mergeBuiltinAgentOverride,
20
20
  removeBuiltinAgentOverride,
21
21
  removeBuiltinAgentOverrideFields,
22
+ resolveAgentName,
22
23
  } from "./agents.ts";
23
24
  import { serializeAgent } from "./agent-serializer.ts";
24
25
  import { mergeAgentsForScope } from "./agent-selection.ts";
@@ -35,10 +36,11 @@ import { resolveTurnBudgetConfig } from "../runs/shared/turn-budget.ts";
35
36
  import { validateAcceptanceInput } from "../runs/shared/acceptance.ts";
36
37
  import type { AcceptanceInput, Details, ExtensionConfig, ToolBudgetConfig } from "../shared/types.ts";
37
38
  import { getProjectConfigDir } from "../shared/utils.ts";
39
+ import { capabilityCeilingAgentRestrictionSources, isAgentAllowedByCapabilityCeiling, resolveCurrentSubagentCapabilityCeiling } from "../runs/shared/capability-ceiling.ts";
38
40
 
39
41
  type ManagementAction = "list" | "get" | "models" | "create" | "update" | "delete" | "eject" | "disable" | "enable" | "reset";
40
42
  type ManagementScope = "user" | "project";
41
- type ManagementContext = Pick<ExtensionContext, "cwd" | "modelRegistry"> & { model?: ExtensionContext["model"]; config?: ExtensionConfig };
43
+ type ManagementContext = Pick<ExtensionContext, "cwd" | "modelRegistry"> & { model?: ExtensionContext["model"]; config?: ExtensionConfig; currentSessionId?: string };
42
44
 
43
45
  interface ManagementParams {
44
46
  action?: string;
@@ -113,8 +115,13 @@ function findAgents(name: string, cwd: string, scope: AgentScope = "both"): Agen
113
115
  const d = discoverAgentsAll(cwd);
114
116
  const raw = name.trim();
115
117
  const sanitized = sanitizeName(raw);
116
- return allAgents(d)
117
- .filter((a) => (scope === "both" || a.source === scope) && (a.name === raw || a.name === sanitized))
118
+ const scoped = mergeAgentsForScope(scope, d.user, d.project, d.builtin, d.package);
119
+ let resolved = resolveAgentName(raw, scoped);
120
+ if (!resolved.agent && !resolved.error && sanitized !== raw) resolved = resolveAgentName(sanitized, scoped);
121
+ if (resolved.agent) return scoped.filter((agent) => agent.name === resolved.agent!.name).sort((a, b) => a.source.localeCompare(b.source));
122
+ return scoped
123
+ .filter((agent) => Boolean(resolveAgentName(raw, [agent]).agent)
124
+ || (sanitized !== raw && Boolean(resolveAgentName(sanitized, [agent]).agent)))
118
125
  .sort((a, b) => a.source.localeCompare(b.source));
119
126
  }
120
127
 
@@ -128,15 +135,20 @@ function findChains(name: string, cwd: string, scope: AgentScope = "both"): Chai
128
135
 
129
136
  const AGENT_SOURCE_PRECEDENCE: Record<AgentSource, number> = { builtin: 0, package: 1, user: 2, project: 3 };
130
137
 
131
- // Returns the highest-precedence agent for a name (project > user > package > builtin,
132
- // matching mergeAgentsForScope for "both"), including disabled agents so disable/enable/reset
133
- // can locate agents that runtime discovery filters out.
134
- function pickEffectiveAgent(d: ReturnType<typeof discoverAgentsAll>, name: string): AgentConfig | undefined {
138
+ // Returns the highest-precedence definition for a resolved canonical name (project > user > package > builtin),
139
+ // matching mergeAgentsForScope for "both", including disabled agents so disable/enable can locate hidden targets.
140
+ function resolveEffectiveAgent(d: ReturnType<typeof discoverAgentsAll>, name: string): { agent?: AgentConfig; error?: string } {
135
141
  const raw = name.trim();
136
- const sanitized = sanitizeName(raw);
137
- const matches = allAgents(d).filter((a) => a.name === raw || a.name === sanitized);
138
- if (matches.length === 0) return undefined;
139
- return matches.reduce((best, agent) => (AGENT_SOURCE_PRECEDENCE[agent.source] > AGENT_SOURCE_PRECEDENCE[best.source] ? agent : best));
142
+ const candidates = allAgents(d);
143
+ let resolved = resolveAgentName(raw, candidates);
144
+ if (!resolved.agent && !resolved.error) {
145
+ const sanitized = sanitizeName(raw);
146
+ if (sanitized !== raw) resolved = resolveAgentName(sanitized, candidates);
147
+ }
148
+ if (resolved.error) return { error: resolved.error };
149
+ if (!resolved.agent) return {};
150
+ const matches = candidates.filter((agent) => agent.name === resolved.agent!.name);
151
+ return { agent: matches.reduce((best, agent) => (AGENT_SOURCE_PRECEDENCE[agent.source] > AGENT_SOURCE_PRECEDENCE[best.source] ? agent : best)) };
140
152
  }
141
153
 
142
154
  function nameExistsInScope(cwd: string, scope: ManagementScope, name: string, excludePath?: string): boolean {
@@ -156,8 +168,9 @@ function isMutableSource(source: AgentSource): source is ManagementScope {
156
168
 
157
169
  function unknownChainAgents(cwd: string, steps: ChainStepConfig[]): string[] {
158
170
  const d = discoverAgentsAll(cwd);
159
- const known = new Set(allAgents(d).map((a) => a.name));
160
- return [...new Set(steps.map((s) => s.agent).filter((a) => !known.has(a)))].sort((a, b) => a.localeCompare(b));
171
+ const agents = allAgents(d);
172
+ return [...new Set(steps.map((s) => s.agent).filter((agentName): agentName is string => typeof agentName === "string" && !resolveAgentName(agentName, agents).agent))]
173
+ .sort((a, b) => a.localeCompare(b));
161
174
  }
162
175
 
163
176
  function chainStepWarnings(ctx: ManagementContext, steps: ChainStepConfig[]): string[] {
@@ -251,6 +264,7 @@ export function preservedAgentFrontmatterFields(agent: AgentConfig, cfg: Record<
251
264
  if (hasKey(cfg, "name")) changed("name");
252
265
  if (hasKey(cfg, "package")) changed("package");
253
266
  if (hasKey(cfg, "description")) changed("description");
267
+ if (hasKey(cfg, "aliases")) changed("alias", "aliases");
254
268
  if (hasKey(cfg, "systemPrompt")) changed("systemPrompt");
255
269
  if (hasKey(cfg, "model")) changed("model");
256
270
  if (hasKey(cfg, "fallbackModels")) changed("fallbackModels");
@@ -370,6 +384,16 @@ function parseTools(raw: string): { tools?: string[]; mcpDirectTools?: string[]
370
384
  }
371
385
 
372
386
  function applyAgentConfig(target: AgentConfig, cfg: Record<string, unknown>): string | undefined {
387
+ if (hasKey(cfg, "aliases")) {
388
+ if (cfg.aliases === false || cfg.aliases === "") target.aliases = undefined;
389
+ else if (typeof cfg.aliases === "string") {
390
+ const aliases = parseCsv(cfg.aliases).filter((alias) => alias !== target.name);
391
+ target.aliases = aliases.length ? aliases : undefined;
392
+ } else if (Array.isArray(cfg.aliases) && cfg.aliases.every((entry) => typeof entry === "string")) {
393
+ const aliases = [...new Set(cfg.aliases.map((entry) => entry.trim()).filter(Boolean).filter((alias) => alias !== target.name))];
394
+ target.aliases = aliases.length ? aliases : undefined;
395
+ } else return "config.aliases must be a comma-separated string, string array, or false when provided.";
396
+ }
373
397
  if (hasKey(cfg, "systemPrompt")) {
374
398
  if (cfg.systemPrompt === false || cfg.systemPrompt === "") target.systemPrompt = "";
375
399
  else if (typeof cfg.systemPrompt === "string") target.systemPrompt = cfg.systemPrompt;
@@ -513,13 +537,17 @@ function applyAgentConfig(target: AgentConfig, cfg: Record<string, unknown>): st
513
537
  return undefined;
514
538
  }
515
539
 
516
- function resolveTarget<T extends { source: AgentSource; filePath: string }>(
540
+ function resolveTarget<T extends { name: string; source: AgentSource; filePath: string }>(
517
541
  kind: "agent" | "chain",
518
542
  name: string,
519
543
  matches: T[],
520
544
  cwd: string,
521
545
  scopeHint?: string,
522
546
  ): T | AgentToolResult<Details> {
547
+ const distinctNames = [...new Set(matches.map((m) => m.name))];
548
+ if (distinctNames.length > 1) {
549
+ return result(`Ambiguous ${kind} alias or name '${name}': ${distinctNames.sort((a, b) => a.localeCompare(b)).join(", ")}`, true);
550
+ }
523
551
  const mutable = matches.filter((m): m is T & { source: ManagementScope } => isMutableSource(m.source));
524
552
  if (mutable.length === 0) {
525
553
  if (matches.length > 0) {
@@ -564,6 +592,7 @@ function formatAgentDetail(agent: AgentConfig): string {
564
592
  lines.push(`Local name: ${frontmatterNameForConfig(agent)}`);
565
593
  lines.push(`Package: ${agent.packageName}`);
566
594
  }
595
+ if (agent.aliases?.length) lines.push(`Aliases: ${agent.aliases.join(", ")}`);
567
596
  if (agent.model) lines.push(`Model: ${agent.model}`);
568
597
  if (agent.fallbackModels?.length) lines.push(`Fallback models: ${agent.fallbackModels.join(", ")}`);
569
598
  if (tools.length) lines.push(`Tools: ${tools.join(", ")}`);
@@ -648,7 +677,11 @@ export function handleList(params: ManagementParams, ctx: ManagementContext): Ag
648
677
  const d = discoverAgentsAll(ctx.cwd);
649
678
  const scopedAgents = mergeAgentsForScope(scope, d.user, d.project, d.builtin, d.package)
650
679
  .sort((a, b) => a.name.localeCompare(b.name));
651
- const agents = scopedAgents.filter((a) => !a.disabled);
680
+ const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.currentSessionId);
681
+ const visibleAgents = scopedAgents.filter((a) => !a.disabled);
682
+ const agents = visibleAgents.filter((a) => isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
683
+ const restrictedAgents = visibleAgents.filter((a) => !isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
684
+ const restrictedSources = capabilityCeilingAgentRestrictionSources(capabilityCeiling);
652
685
  const chains = d.chains.filter((c) => scope === "both" || c.source === "package" || c.source === scope).sort((a, b) => a.name.localeCompare(b.name));
653
686
  const diagnostics = d.chainDiagnostics.filter((entry) => scope === "both" || entry.source === scope);
654
687
  const proactiveSuggestions = buildProactiveSkillSubagentRecommendationLines({
@@ -660,8 +693,13 @@ export function handleList(params: ManagementParams, ctx: ManagementContext): Ag
660
693
  const lines = [
661
694
  "Executable agents:",
662
695
  ...(agents.length
663
- ? agents.map((a) => `- ${a.name} (${a.source}${a.defaultContext ? `, context: ${a.defaultContext}` : ""}): ${a.description}`)
696
+ ? agents.map((a) => `- ${a.name} (${a.source}${a.defaultContext ? `, context: ${a.defaultContext}` : ""}${a.aliases?.length ? `, aliases: ${a.aliases.join(", ")}` : ""}): ${a.description}`)
664
697
  : ["- (none)"]),
698
+ ...(restrictedAgents.length ? [
699
+ "",
700
+ `Restricted agents (not executable in this session${restrictedSources?.length ? `; capability ceiling: ${restrictedSources.join(", ")}` : ""}):`,
701
+ ...restrictedAgents.map((a) => `- ${a.name} (${a.source}${a.aliases?.length ? `, aliases: ${a.aliases.join(", ")}` : ""}): ${a.description}`),
702
+ ] : []),
665
703
  "",
666
704
  "Chains:",
667
705
  ...(chains.length ? chains.map((c) => `- ${c.name} (${c.source}): ${c.description}`) : ["- (none)"]),
@@ -760,12 +798,13 @@ function handleGet(params: ManagementParams, ctx: ManagementContext): AgentToolR
760
798
  const blocks: string[] = [];
761
799
  let anyFound = false;
762
800
  if (params.agent) {
763
- const raw = params.agent.trim();
764
- const sanitized = sanitizeName(raw);
765
- const d = discoverAgentsAll(ctx.cwd);
766
- const matches = mergeAgentsForScope(scope, d.user, d.project, d.builtin, d.package)
767
- .filter((agent) => agent.name === raw || agent.name === sanitized);
768
- if (!matches.length) {
801
+ const matches = findAgents(params.agent, ctx.cwd, scope);
802
+ const distinctNames = [...new Set(matches.map((agent) => agent.name))];
803
+ if (distinctNames.length > 1) {
804
+ const msg = `Ambiguous agent alias or name '${params.agent}': ${distinctNames.sort((a, b) => a.localeCompare(b)).join(", ")}`;
805
+ if (!hasBoth) return result(msg, true);
806
+ blocks.push(msg);
807
+ } else if (!matches.length) {
769
808
  const msg = `Agent '${params.agent}' not found. Available: ${availableNames(ctx.cwd, "agent").join(", ") || "none"}.`;
770
809
  if (!hasBoth) return result(msg, true);
771
810
  blocks.push(msg);
@@ -1027,13 +1066,14 @@ function handleDisable(params: ManagementParams, ctx: ManagementContext): AgentT
1027
1066
  if (scope === "project" && d.projectSettingsPath === null) {
1028
1067
  return result("Project override is not available here: no project config root (.pi or .agents) was found above the cwd. Use agentScope: 'user' or run from inside a project.", true);
1029
1068
  }
1030
- const effective = pickEffectiveAgent(d, raw);
1031
- if (!effective) {
1069
+ const effective = resolveEffectiveAgent(d, raw);
1070
+ if (effective.error) return result(effective.error, true);
1071
+ if (!effective.agent) {
1032
1072
  return result(`Agent '${raw}' not found. Available: ${availableNames(ctx.cwd, "agent").join(", ") || "none"}.`, true);
1033
1073
  }
1034
- const runtimeName = effective.name;
1074
+ const runtimeName = effective.agent.name;
1035
1075
  const settingsPath = mergeBuiltinAgentOverride(ctx.cwd, runtimeName, scope, { disabled: true });
1036
- const after = pickEffectiveAgent(discoverAgentsAll(ctx.cwd), raw);
1076
+ const after = resolveEffectiveAgent(discoverAgentsAll(ctx.cwd), raw).agent;
1037
1077
  if (after?.disabled === true) {
1038
1078
  return result(`Disabled agent '${runtimeName}' via ${scope} settings override at ${settingsPath}. It is now hidden from runtime discovery and { action: "list" }.`);
1039
1079
  }
@@ -1050,13 +1090,14 @@ function handleEnable(params: ManagementParams, ctx: ManagementContext): AgentTo
1050
1090
  if (scope === "project" && d.projectSettingsPath === null) {
1051
1091
  return result("Project override is not available here: no project config root (.pi or .agents) was found above the cwd. Use agentScope: 'user' or run from inside a project.", true);
1052
1092
  }
1053
- const effective = pickEffectiveAgent(d, raw);
1054
- if (!effective) {
1093
+ const effective = resolveEffectiveAgent(d, raw);
1094
+ if (effective.error) return result(effective.error, true);
1095
+ if (!effective.agent) {
1055
1096
  return result(`Agent '${raw}' not found. Available: ${availableNames(ctx.cwd, "agent").join(", ") || "none"}.`, true);
1056
1097
  }
1057
- const runtimeName = effective.name;
1098
+ const runtimeName = effective.agent.name;
1058
1099
  const { path: settingsPath, removed } = removeBuiltinAgentOverrideFields(ctx.cwd, runtimeName, scope, ["disabled"]);
1059
- const after = pickEffectiveAgent(discoverAgentsAll(ctx.cwd), raw);
1100
+ const after = resolveEffectiveAgent(discoverAgentsAll(ctx.cwd), raw).agent;
1060
1101
  if (after && after.disabled !== true) {
1061
1102
  if (removed) return result(`Enabled agent '${runtimeName}' (removed disabled override at ${settingsPath}).`);
1062
1103
  return result(`Agent '${runtimeName}' is already enabled.`);
@@ -5,6 +5,8 @@ export const KNOWN_FIELDS = new Set([
5
5
  "name",
6
6
  "package",
7
7
  "description",
8
+ "alias",
9
+ "aliases",
8
10
  "tools",
9
11
  "model",
10
12
  "fallbackModels",
@@ -50,6 +52,8 @@ export function serializeAgent(config: AgentConfig, options: SerializeAgentOptio
50
52
  lines.push(`name: ${frontmatterNameForConfig(config)}`);
51
53
  if (config.packageName) lines.push(`package: ${config.packageName}`);
52
54
  lines.push(`description: ${config.description}`);
55
+ const aliasesValue = joinComma(config.aliases);
56
+ if (aliasesValue || preserve("alias", "aliases")) lines.push(`aliases: ${aliasesValue ?? ""}`);
53
57
 
54
58
  const tools = [
55
59
  ...(config.tools ?? []),