@draht/coding-agent 2026.4.26 → 2026.6.11

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 (621) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/bin/draht-tools.cjs +3809 -1
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js +4 -2
  5. package/dist/bun/cli.js.map +1 -1
  6. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  7. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  8. package/dist/bun/restore-sandbox-env.js +32 -0
  9. package/dist/bun/restore-sandbox-env.js.map +1 -0
  10. package/dist/cli/args.d.ts +9 -4
  11. package/dist/cli/args.d.ts.map +1 -1
  12. package/dist/cli/args.js +88 -35
  13. package/dist/cli/args.js.map +1 -1
  14. package/dist/cli/config-selector.d.ts +2 -2
  15. package/dist/cli/config-selector.d.ts.map +1 -1
  16. package/dist/cli/config-selector.js +1 -1
  17. package/dist/cli/config-selector.js.map +1 -1
  18. package/dist/cli/file-processor.d.ts.map +1 -1
  19. package/dist/cli/file-processor.js +2 -3
  20. package/dist/cli/file-processor.js.map +1 -1
  21. package/dist/cli/initial-message.d.ts +1 -1
  22. package/dist/cli/initial-message.d.ts.map +1 -1
  23. package/dist/cli/initial-message.js.map +1 -1
  24. package/dist/cli/list-models.d.ts +1 -1
  25. package/dist/cli/list-models.d.ts.map +1 -1
  26. package/dist/cli/list-models.js +7 -1
  27. package/dist/cli/list-models.js.map +1 -1
  28. package/dist/cli/project-trust.d.ts +10 -0
  29. package/dist/cli/project-trust.d.ts.map +1 -0
  30. package/dist/cli/project-trust.js +48 -0
  31. package/dist/cli/project-trust.js.map +1 -0
  32. package/dist/cli/session-picker.d.ts +1 -1
  33. package/dist/cli/session-picker.d.ts.map +1 -1
  34. package/dist/cli/session-picker.js.map +1 -1
  35. package/dist/cli/startup-ui.d.ts +16 -0
  36. package/dist/cli/startup-ui.d.ts.map +1 -0
  37. package/dist/cli/startup-ui.js +112 -0
  38. package/dist/cli/startup-ui.js.map +1 -0
  39. package/dist/cli.d.ts.map +1 -1
  40. package/dist/cli.js +7 -4
  41. package/dist/cli.js.map +1 -1
  42. package/dist/config.d.ts +23 -13
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +264 -62
  45. package/dist/config.js.map +1 -1
  46. package/dist/core/agent-session-runtime.d.ts +45 -9
  47. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  48. package/dist/core/agent-session-runtime.js +100 -33
  49. package/dist/core/agent-session-runtime.js.map +1 -1
  50. package/dist/core/agent-session-services.d.ts +6 -4
  51. package/dist/core/agent-session-services.d.ts.map +1 -1
  52. package/dist/core/agent-session-services.js +7 -4
  53. package/dist/core/agent-session-services.js.map +1 -1
  54. package/dist/core/agent-session.d.ts +47 -31
  55. package/dist/core/agent-session.d.ts.map +1 -1
  56. package/dist/core/agent-session.js +470 -443
  57. package/dist/core/agent-session.js.map +1 -1
  58. package/dist/core/auth-guidance.d.ts +5 -0
  59. package/dist/core/auth-guidance.d.ts.map +1 -0
  60. package/dist/core/auth-guidance.js +21 -0
  61. package/dist/core/auth-guidance.js.map +1 -0
  62. package/dist/core/auth-storage.d.ts +10 -1
  63. package/dist/core/auth-storage.d.ts.map +1 -1
  64. package/dist/core/auth-storage.js +27 -6
  65. package/dist/core/auth-storage.js.map +1 -1
  66. package/dist/core/bash-executor.d.ts +1 -15
  67. package/dist/core/bash-executor.d.ts.map +1 -1
  68. package/dist/core/bash-executor.js +10 -24
  69. package/dist/core/bash-executor.js.map +1 -1
  70. package/dist/core/builtins/subagent.d.ts.map +1 -1
  71. package/dist/core/builtins/subagent.js +1 -2
  72. package/dist/core/builtins/subagent.js.map +1 -1
  73. package/dist/core/compaction/branch-summarization.d.ts +6 -4
  74. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  75. package/dist/core/compaction/branch-summarization.js +9 -3
  76. package/dist/core/compaction/branch-summarization.js.map +1 -1
  77. package/dist/core/compaction/compaction.d.ts +5 -5
  78. package/dist/core/compaction/compaction.d.ts.map +1 -1
  79. package/dist/core/compaction/compaction.js +43 -37
  80. package/dist/core/compaction/compaction.js.map +1 -1
  81. package/dist/core/compaction/index.d.ts +3 -3
  82. package/dist/core/compaction/index.d.ts.map +1 -1
  83. package/dist/core/compaction/index.js.map +1 -1
  84. package/dist/core/compaction/utils.d.ts +1 -1
  85. package/dist/core/compaction/utils.d.ts.map +1 -1
  86. package/dist/core/compaction/utils.js +1 -1
  87. package/dist/core/compaction/utils.js.map +1 -1
  88. package/dist/core/exec.d.ts.map +1 -1
  89. package/dist/core/exec.js.map +1 -1
  90. package/dist/core/experimental.d.ts +2 -0
  91. package/dist/core/experimental.d.ts.map +1 -0
  92. package/dist/core/experimental.js +4 -0
  93. package/dist/core/experimental.js.map +1 -0
  94. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  95. package/dist/core/export-html/ansi-to-html.js +1 -1
  96. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  97. package/dist/core/export-html/index.d.ts +1 -1
  98. package/dist/core/export-html/index.d.ts.map +1 -1
  99. package/dist/core/export-html/index.js +13 -11
  100. package/dist/core/export-html/index.js.map +1 -1
  101. package/dist/core/export-html/template.css +69 -4
  102. package/dist/core/export-html/template.js +231 -57
  103. package/dist/core/export-html/tool-renderer.d.ts +0 -6
  104. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  105. package/dist/core/export-html/tool-renderer.js +15 -2
  106. package/dist/core/export-html/tool-renderer.js.map +1 -1
  107. package/dist/core/extensions/index.d.ts +8 -8
  108. package/dist/core/extensions/index.d.ts.map +1 -1
  109. package/dist/core/extensions/index.js.map +1 -1
  110. package/dist/core/extensions/loader.d.ts +3 -3
  111. package/dist/core/extensions/loader.d.ts.map +1 -1
  112. package/dist/core/extensions/loader.js +27 -35
  113. package/dist/core/extensions/loader.js.map +1 -1
  114. package/dist/core/extensions/runner.d.ts +30 -12
  115. package/dist/core/extensions/runner.d.ts.map +1 -1
  116. package/dist/core/extensions/runner.js +215 -32
  117. package/dist/core/extensions/runner.js.map +1 -1
  118. package/dist/core/extensions/types.d.ts +163 -35
  119. package/dist/core/extensions/types.d.ts.map +1 -1
  120. package/dist/core/extensions/types.js.map +1 -1
  121. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  122. package/dist/core/extensions/wrapper.js +2 -2
  123. package/dist/core/extensions/wrapper.js.map +1 -1
  124. package/dist/core/footer-data-provider.d.ts +7 -1
  125. package/dist/core/footer-data-provider.d.ts.map +1 -1
  126. package/dist/core/footer-data-provider.js +78 -54
  127. package/dist/core/footer-data-provider.js.map +1 -1
  128. package/dist/core/http-dispatcher.d.ts +21 -0
  129. package/dist/core/http-dispatcher.d.ts.map +1 -0
  130. package/dist/core/http-dispatcher.js +48 -0
  131. package/dist/core/http-dispatcher.js.map +1 -0
  132. package/dist/core/index.d.ts +9 -8
  133. package/dist/core/index.d.ts.map +1 -1
  134. package/dist/core/index.js +2 -1
  135. package/dist/core/index.js.map +1 -1
  136. package/dist/core/keybindings.d.ts +66 -1
  137. package/dist/core/keybindings.d.ts.map +1 -1
  138. package/dist/core/keybindings.js +56 -1
  139. package/dist/core/keybindings.js.map +1 -1
  140. package/dist/core/model-registry.d.ts +22 -4
  141. package/dist/core/model-registry.d.ts.map +1 -1
  142. package/dist/core/model-registry.js +216 -44
  143. package/dist/core/model-registry.js.map +1 -1
  144. package/dist/core/model-resolver.d.ts +2 -1
  145. package/dist/core/model-resolver.d.ts.map +1 -1
  146. package/dist/core/model-resolver.js +48 -21
  147. package/dist/core/model-resolver.js.map +1 -1
  148. package/dist/core/output-guard.d.ts +1 -0
  149. package/dist/core/output-guard.d.ts.map +1 -1
  150. package/dist/core/output-guard.js +52 -22
  151. package/dist/core/output-guard.js.map +1 -1
  152. package/dist/core/package-manager.d.ts +17 -2
  153. package/dist/core/package-manager.d.ts.map +1 -1
  154. package/dist/core/package-manager.js +363 -121
  155. package/dist/core/package-manager.js.map +1 -1
  156. package/dist/core/project-trust.d.ts +15 -0
  157. package/dist/core/project-trust.d.ts.map +1 -0
  158. package/dist/core/project-trust.js +58 -0
  159. package/dist/core/project-trust.js.map +1 -0
  160. package/dist/core/prompt-templates.d.ts +13 -11
  161. package/dist/core/prompt-templates.d.ts.map +1 -1
  162. package/dist/core/prompt-templates.js +67 -76
  163. package/dist/core/prompt-templates.js.map +1 -1
  164. package/dist/core/provider-attribution.d.ts +4 -0
  165. package/dist/core/provider-attribution.d.ts.map +1 -0
  166. package/dist/core/provider-attribution.js +72 -0
  167. package/dist/core/provider-attribution.js.map +1 -0
  168. package/dist/core/provider-display-names.d.ts +2 -0
  169. package/dist/core/provider-display-names.d.ts.map +1 -0
  170. package/dist/core/provider-display-names.js +36 -0
  171. package/dist/core/provider-display-names.js.map +1 -0
  172. package/dist/core/resolve-config-value.d.ts +9 -1
  173. package/dist/core/resolve-config-value.d.ts.map +1 -1
  174. package/dist/core/resolve-config-value.js +134 -11
  175. package/dist/core/resolve-config-value.js.map +1 -1
  176. package/dist/core/resource-loader.d.ts +34 -14
  177. package/dist/core/resource-loader.d.ts.map +1 -1
  178. package/dist/core/resource-loader.js +165 -76
  179. package/dist/core/resource-loader.js.map +1 -1
  180. package/dist/core/sdk.d.ts +26 -10
  181. package/dist/core/sdk.d.ts.map +1 -1
  182. package/dist/core/sdk.js +45 -16
  183. package/dist/core/sdk.js.map +1 -1
  184. package/dist/core/session-manager.d.ts +11 -12
  185. package/dist/core/session-manager.d.ts.map +1 -1
  186. package/dist/core/session-manager.js +245 -132
  187. package/dist/core/session-manager.js.map +1 -1
  188. package/dist/core/settings-manager.d.ts +52 -5
  189. package/dist/core/settings-manager.d.ts.map +1 -1
  190. package/dist/core/settings-manager.js +202 -38
  191. package/dist/core/settings-manager.js.map +1 -1
  192. package/dist/core/skills.d.ts +10 -10
  193. package/dist/core/skills.d.ts.map +1 -1
  194. package/dist/core/skills.js +13 -35
  195. package/dist/core/skills.js.map +1 -1
  196. package/dist/core/slash-commands.d.ts +1 -1
  197. package/dist/core/slash-commands.d.ts.map +1 -1
  198. package/dist/core/slash-commands.js +7 -4
  199. package/dist/core/slash-commands.js.map +1 -1
  200. package/dist/core/source-info.d.ts +1 -1
  201. package/dist/core/source-info.d.ts.map +1 -1
  202. package/dist/core/source-info.js.map +1 -1
  203. package/dist/core/system-prompt.d.ts +4 -4
  204. package/dist/core/system-prompt.d.ts.map +1 -1
  205. package/dist/core/system-prompt.js +14 -10
  206. package/dist/core/system-prompt.js.map +1 -1
  207. package/dist/core/telemetry.d.ts +3 -0
  208. package/dist/core/telemetry.d.ts.map +1 -0
  209. package/dist/core/telemetry.js +9 -0
  210. package/dist/core/telemetry.js.map +1 -0
  211. package/dist/core/tools/bash.d.ts +11 -16
  212. package/dist/core/tools/bash.d.ts.map +1 -1
  213. package/dist/core/tools/bash.js +162 -177
  214. package/dist/core/tools/bash.js.map +1 -1
  215. package/dist/core/tools/edit-diff.d.ts +3 -1
  216. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  217. package/dist/core/tools/edit-diff.js +11 -3
  218. package/dist/core/tools/edit-diff.js.map +1 -1
  219. package/dist/core/tools/edit.d.ts +22 -24
  220. package/dist/core/tools/edit.d.ts.map +1 -1
  221. package/dist/core/tools/edit.js +199 -111
  222. package/dist/core/tools/edit.js.map +1 -1
  223. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  224. package/dist/core/tools/file-mutation-queue.js +27 -12
  225. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  226. package/dist/core/tools/find.d.ts +7 -18
  227. package/dist/core/tools/find.d.ts.map +1 -1
  228. package/dist/core/tools/find.js +134 -95
  229. package/dist/core/tools/find.js.map +1 -1
  230. package/dist/core/tools/grep.d.ts +11 -30
  231. package/dist/core/tools/grep.d.ts.map +1 -1
  232. package/dist/core/tools/grep.js +23 -12
  233. package/dist/core/tools/grep.js.map +1 -1
  234. package/dist/core/tools/index.d.ts +26 -101
  235. package/dist/core/tools/index.d.ts.map +1 -1
  236. package/dist/core/tools/index.js +78 -52
  237. package/dist/core/tools/index.js.map +1 -1
  238. package/dist/core/tools/ls.d.ts +6 -15
  239. package/dist/core/tools/ls.d.ts.map +1 -1
  240. package/dist/core/tools/ls.js +12 -17
  241. package/dist/core/tools/ls.js.map +1 -1
  242. package/dist/core/tools/output-accumulator.d.ts +52 -0
  243. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  244. package/dist/core/tools/output-accumulator.js +184 -0
  245. package/dist/core/tools/output-accumulator.js.map +1 -0
  246. package/dist/core/tools/path-utils.d.ts +2 -0
  247. package/dist/core/tools/path-utils.d.ts.map +1 -1
  248. package/dist/core/tools/path-utils.js +40 -22
  249. package/dist/core/tools/path-utils.js.map +1 -1
  250. package/dist/core/tools/read.d.ts +7 -18
  251. package/dist/core/tools/read.d.ts.map +1 -1
  252. package/dist/core/tools/read.js +100 -36
  253. package/dist/core/tools/read.js.map +1 -1
  254. package/dist/core/tools/render-utils.d.ts +5 -2
  255. package/dist/core/tools/render-utils.d.ts.map +1 -1
  256. package/dist/core/tools/render-utils.js +18 -2
  257. package/dist/core/tools/render-utils.js.map +1 -1
  258. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  259. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  260. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  261. package/dist/core/tools/truncate.d.ts.map +1 -1
  262. package/dist/core/tools/truncate.js +12 -2
  263. package/dist/core/tools/truncate.js.map +1 -1
  264. package/dist/core/tools/write.d.ts +5 -14
  265. package/dist/core/tools/write.d.ts.map +1 -1
  266. package/dist/core/tools/write.js +27 -46
  267. package/dist/core/tools/write.js.map +1 -1
  268. package/dist/core/trust-manager.d.ts +31 -0
  269. package/dist/core/trust-manager.d.ts.map +1 -0
  270. package/dist/core/trust-manager.js +187 -0
  271. package/dist/core/trust-manager.js.map +1 -0
  272. package/dist/index.d.ts +31 -29
  273. package/dist/index.d.ts.map +1 -1
  274. package/dist/index.js +9 -8
  275. package/dist/index.js.map +1 -1
  276. package/dist/main.d.ts +5 -1
  277. package/dist/main.d.ts.map +1 -1
  278. package/dist/main.js +170 -87
  279. package/dist/main.js.map +1 -1
  280. package/dist/migrations.d.ts +2 -2
  281. package/dist/migrations.d.ts.map +1 -1
  282. package/dist/migrations.js +127 -5
  283. package/dist/migrations.js.map +1 -1
  284. package/dist/modes/index.d.ts +5 -5
  285. package/dist/modes/index.d.ts.map +1 -1
  286. package/dist/modes/index.js.map +1 -1
  287. package/dist/modes/interactive/components/assistant-message.d.ts +2 -0
  288. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  289. package/dist/modes/interactive/components/assistant-message.js +14 -0
  290. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  291. package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
  292. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  293. package/dist/modes/interactive/components/bash-execution.js +3 -3
  294. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  295. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  296. package/dist/modes/interactive/components/bordered-loader.js +3 -0
  297. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  298. package/dist/modes/interactive/components/config-selector.d.ts +4 -4
  299. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  300. package/dist/modes/interactive/components/config-selector.js +38 -11
  301. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  302. package/dist/modes/interactive/components/countdown-timer.d.ts +2 -2
  303. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  304. package/dist/modes/interactive/components/countdown-timer.js +2 -2
  305. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  306. package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
  307. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  308. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  309. package/dist/modes/interactive/components/custom-message.d.ts +2 -2
  310. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  311. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  312. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  313. package/dist/modes/interactive/components/diff.js.map +1 -1
  314. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  315. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  316. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  317. package/dist/modes/interactive/components/extension-editor.js +14 -6
  318. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  319. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  320. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  321. package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
  322. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  323. package/dist/modes/interactive/components/extension-selector.js +8 -3
  324. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  325. package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
  326. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
  327. package/dist/modes/interactive/components/first-time-setup.js +103 -0
  328. package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
  329. package/dist/modes/interactive/components/footer.d.ts +2 -1
  330. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/footer.js +23 -7
  332. package/dist/modes/interactive/components/footer.js.map +1 -1
  333. package/dist/modes/interactive/components/index.d.ts +33 -31
  334. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  335. package/dist/modes/interactive/components/index.js +2 -0
  336. package/dist/modes/interactive/components/index.js.map +1 -1
  337. package/dist/modes/interactive/components/keybinding-hints.d.ts +5 -0
  338. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  339. package/dist/modes/interactive/components/keybinding-hints.js +19 -5
  340. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  341. package/dist/modes/interactive/components/login-dialog.d.ts +12 -2
  342. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  343. package/dist/modes/interactive/components/login-dialog.js +46 -11
  344. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  345. package/dist/modes/interactive/components/model-selector.d.ts +2 -2
  346. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  347. package/dist/modes/interactive/components/model-selector.js +8 -5
  348. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  349. package/dist/modes/interactive/components/oauth-selector.d.ts +18 -6
  350. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  351. package/dist/modes/interactive/components/oauth-selector.js +93 -25
  352. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  353. package/dist/modes/interactive/components/scoped-models-selector.d.ts +5 -12
  354. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  355. package/dist/modes/interactive/components/scoped-models-selector.js +45 -30
  356. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  357. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  358. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  359. package/dist/modes/interactive/components/session-selector.js +20 -7
  360. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  361. package/dist/modes/interactive/components/settings-selector.d.ts +13 -0
  362. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  363. package/dist/modes/interactive/components/settings-selector.js +113 -4
  364. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  365. package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
  366. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  367. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  368. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  369. package/dist/modes/interactive/components/thinking-selector.js +1 -1
  370. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  371. package/dist/modes/interactive/components/tool-execution.d.ts +6 -1
  372. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  373. package/dist/modes/interactive/components/tool-execution.js +57 -14
  374. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  375. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  376. package/dist/modes/interactive/components/tree-selector.js +18 -9
  377. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  378. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  379. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  380. package/dist/modes/interactive/components/trust-selector.js +91 -0
  381. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  382. package/dist/modes/interactive/components/user-message-selector.d.ts +2 -2
  383. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  384. package/dist/modes/interactive/components/user-message-selector.js +8 -7
  385. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  386. package/dist/modes/interactive/components/user-message.d.ts +1 -0
  387. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  388. package/dist/modes/interactive/components/user-message.js +8 -7
  389. package/dist/modes/interactive/components/user-message.js.map +1 -1
  390. package/dist/modes/interactive/interactive-mode.d.ts +68 -13
  391. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  392. package/dist/modes/interactive/interactive-mode.js +1100 -319
  393. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  394. package/dist/modes/interactive/theme/dark.json +5 -4
  395. package/dist/modes/interactive/theme/light.json +5 -4
  396. package/dist/modes/interactive/theme/theme.d.ts +22 -3
  397. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  398. package/dist/modes/interactive/theme/theme.js +160 -105
  399. package/dist/modes/interactive/theme/theme.js.map +1 -1
  400. package/dist/modes/print-mode.d.ts.map +1 -1
  401. package/dist/modes/print-mode.js +40 -20
  402. package/dist/modes/print-mode.js.map +1 -1
  403. package/dist/modes/rpc/rpc-client.d.ts +11 -1
  404. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  405. package/dist/modes/rpc/rpc-client.js +73 -8
  406. package/dist/modes/rpc/rpc-client.js.map +1 -1
  407. package/dist/modes/rpc/rpc-mode.d.ts +2 -2
  408. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  409. package/dist/modes/rpc/rpc-mode.js +96 -30
  410. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  411. package/dist/modes/rpc/rpc-types.d.ts +16 -4
  412. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  413. package/dist/modes/rpc/rpc-types.js.map +1 -1
  414. package/dist/package-manager-cli.d.ts +6 -2
  415. package/dist/package-manager-cli.d.ts.map +1 -1
  416. package/dist/package-manager-cli.js +396 -21
  417. package/dist/package-manager-cli.js.map +1 -1
  418. package/dist/prompts/commands/atomic-commit.md +12 -0
  419. package/dist/prompts/commands/execute-phase.md +48 -17
  420. package/dist/prompts/commands/fix.md +86 -23
  421. package/dist/prompts/commands/map-codebase.md +17 -3
  422. package/dist/prompts/commands/orchestrate.md +31 -6
  423. package/dist/prompts/commands/plan-phase.md +39 -6
  424. package/dist/prompts/commands/quick.md +36 -6
  425. package/dist/prompts/commands/review.md +28 -11
  426. package/dist/prompts/commands/verify-work.md +34 -17
  427. package/dist/utils/ansi.d.ts +2 -0
  428. package/dist/utils/ansi.d.ts.map +1 -0
  429. package/dist/utils/ansi.js +52 -0
  430. package/dist/utils/ansi.js.map +1 -0
  431. package/dist/utils/changelog.d.ts +2 -1
  432. package/dist/utils/changelog.d.ts.map +1 -1
  433. package/dist/utils/changelog.js +78 -0
  434. package/dist/utils/changelog.js.map +1 -1
  435. package/dist/utils/child-process.d.ts +5 -1
  436. package/dist/utils/child-process.d.ts.map +1 -1
  437. package/dist/utils/child-process.js +10 -0
  438. package/dist/utils/child-process.js.map +1 -1
  439. package/dist/utils/clipboard-image.d.ts.map +1 -1
  440. package/dist/utils/clipboard-image.js +2 -2
  441. package/dist/utils/clipboard-image.js.map +1 -1
  442. package/dist/utils/clipboard-native.d.ts +3 -1
  443. package/dist/utils/clipboard-native.d.ts.map +1 -1
  444. package/dist/utils/clipboard-native.js +14 -8
  445. package/dist/utils/clipboard-native.js.map +1 -1
  446. package/dist/utils/clipboard.d.ts.map +1 -1
  447. package/dist/utils/clipboard.js +84 -45
  448. package/dist/utils/clipboard.js.map +1 -1
  449. package/dist/utils/deprecation.d.ts +4 -0
  450. package/dist/utils/deprecation.d.ts.map +1 -0
  451. package/dist/utils/deprecation.js +13 -0
  452. package/dist/utils/deprecation.js.map +1 -0
  453. package/dist/utils/exif-orientation.d.ts +1 -1
  454. package/dist/utils/exif-orientation.d.ts.map +1 -1
  455. package/dist/utils/exif-orientation.js.map +1 -1
  456. package/dist/utils/fs-watch.d.ts +5 -0
  457. package/dist/utils/fs-watch.d.ts.map +1 -0
  458. package/dist/utils/fs-watch.js +25 -0
  459. package/dist/utils/fs-watch.js.map +1 -0
  460. package/dist/utils/git.d.ts.map +1 -1
  461. package/dist/utils/git.js +54 -22
  462. package/dist/utils/git.js.map +1 -1
  463. package/dist/utils/html.d.ts +7 -0
  464. package/dist/utils/html.d.ts.map +1 -0
  465. package/dist/utils/html.js +40 -0
  466. package/dist/utils/html.js.map +1 -0
  467. package/dist/utils/image-convert.d.ts.map +1 -1
  468. package/dist/utils/image-convert.js.map +1 -1
  469. package/dist/utils/image-resize-core.d.ts +30 -0
  470. package/dist/utils/image-resize-core.d.ts.map +1 -0
  471. package/dist/utils/image-resize-core.js +124 -0
  472. package/dist/utils/image-resize-core.js.map +1 -0
  473. package/dist/utils/image-resize-worker.d.ts +2 -0
  474. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  475. package/dist/utils/image-resize-worker.js +31 -0
  476. package/dist/utils/image-resize-worker.js.map +1 -0
  477. package/dist/utils/image-resize.d.ts +7 -27
  478. package/dist/utils/image-resize.d.ts.map +1 -1
  479. package/dist/utils/image-resize.js +75 -115
  480. package/dist/utils/image-resize.js.map +1 -1
  481. package/dist/utils/json.d.ts +3 -0
  482. package/dist/utils/json.d.ts.map +1 -0
  483. package/dist/utils/json.js +7 -0
  484. package/dist/utils/json.js.map +1 -0
  485. package/dist/utils/mime.d.ts +1 -0
  486. package/dist/utils/mime.d.ts.map +1 -1
  487. package/dist/utils/mime.js +59 -16
  488. package/dist/utils/mime.js.map +1 -1
  489. package/dist/utils/open-browser.d.ts +9 -0
  490. package/dist/utils/open-browser.d.ts.map +1 -0
  491. package/dist/utils/open-browser.js +22 -0
  492. package/dist/utils/open-browser.js.map +1 -0
  493. package/dist/utils/paths.d.ts +25 -1
  494. package/dist/utils/paths.d.ts.map +1 -1
  495. package/dist/utils/paths.js +75 -2
  496. package/dist/utils/paths.js.map +1 -1
  497. package/dist/utils/pi-user-agent.d.ts +2 -0
  498. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  499. package/dist/utils/pi-user-agent.js +5 -0
  500. package/dist/utils/pi-user-agent.js.map +1 -0
  501. package/dist/utils/shell.d.ts +10 -6
  502. package/dist/utils/shell.d.ts.map +1 -1
  503. package/dist/utils/shell.js +35 -26
  504. package/dist/utils/shell.js.map +1 -1
  505. package/dist/utils/syntax-highlight.d.ts +12 -0
  506. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  507. package/dist/utils/syntax-highlight.js +118 -0
  508. package/dist/utils/syntax-highlight.js.map +1 -0
  509. package/dist/utils/tools-manager.d.ts.map +1 -1
  510. package/dist/utils/tools-manager.js +86 -10
  511. package/dist/utils/tools-manager.js.map +1 -1
  512. package/dist/utils/version-check.d.ts +15 -0
  513. package/dist/utils/version-check.d.ts.map +1 -0
  514. package/dist/utils/version-check.js +82 -0
  515. package/dist/utils/version-check.js.map +1 -0
  516. package/dist/utils/windows-self-update.d.ts +3 -0
  517. package/dist/utils/windows-self-update.d.ts.map +1 -0
  518. package/dist/utils/windows-self-update.js +77 -0
  519. package/dist/utils/windows-self-update.js.map +1 -0
  520. package/docs/compaction.md +12 -12
  521. package/docs/containerization.md +111 -0
  522. package/docs/custom-provider.md +187 -47
  523. package/docs/development.md +5 -5
  524. package/docs/docs.json +156 -0
  525. package/docs/extensions.md +465 -71
  526. package/docs/index.md +82 -0
  527. package/docs/json.md +4 -4
  528. package/docs/keybindings.md +23 -1
  529. package/docs/models.md +119 -17
  530. package/docs/packages.md +17 -9
  531. package/docs/prompt-templates.md +30 -2
  532. package/docs/providers.md +83 -22
  533. package/docs/quickstart.md +165 -0
  534. package/docs/rpc.md +41 -10
  535. package/docs/sdk.md +68 -50
  536. package/docs/security.md +55 -0
  537. package/docs/{session.md → session-format.md} +11 -11
  538. package/docs/sessions.md +145 -0
  539. package/docs/settings.md +61 -11
  540. package/docs/skills.md +16 -17
  541. package/docs/terminal-setup.md +44 -2
  542. package/docs/termux.md +4 -4
  543. package/docs/themes.md +3 -3
  544. package/docs/tmux.md +4 -2
  545. package/docs/tui.md +44 -4
  546. package/docs/usage.md +305 -0
  547. package/examples/extensions/border-status-editor.ts +145 -0
  548. package/examples/extensions/built-in-tool-renderer.ts +3 -0
  549. package/examples/extensions/custom-header.ts +1 -1
  550. package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
  551. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  552. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  553. package/examples/extensions/custom-provider-gitlab-duo/index.ts +55 -4
  554. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  555. package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
  556. package/examples/extensions/doom-overlay/doom-component.ts +2 -2
  557. package/examples/extensions/doom-overlay/index.ts +1 -1
  558. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  559. package/examples/extensions/dynamic-tools.ts +2 -2
  560. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  561. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  562. package/examples/extensions/gondolin/index.ts +531 -0
  563. package/examples/extensions/gondolin/package-lock.json +185 -0
  564. package/examples/extensions/gondolin/package.json +19 -0
  565. package/examples/extensions/handoff.ts +50 -12
  566. package/examples/extensions/input-transform-streaming.ts +39 -0
  567. package/examples/extensions/interactive-shell.ts +1 -1
  568. package/examples/extensions/notify.ts +2 -9
  569. package/examples/extensions/overlay-qa-tests.ts +240 -138
  570. package/examples/extensions/overlay-test.ts +7 -4
  571. package/examples/extensions/plan-mode/utils.ts +1 -1
  572. package/examples/extensions/preset.ts +36 -3
  573. package/examples/extensions/project-trust.ts +64 -0
  574. package/examples/extensions/prompt-customizer.ts +97 -0
  575. package/examples/extensions/provider-payload.ts +4 -0
  576. package/examples/extensions/qna.ts +1 -1
  577. package/examples/extensions/question.ts +2 -2
  578. package/examples/extensions/questionnaire.ts +2 -2
  579. package/examples/extensions/reload-runtime.ts +1 -1
  580. package/examples/extensions/sandbox/index.ts +4 -4
  581. package/examples/extensions/sandbox/package-lock.json +5 -5
  582. package/examples/extensions/sandbox/package.json +2 -2
  583. package/examples/extensions/shutdown-command.ts +1 -1
  584. package/examples/extensions/snake.ts +1 -1
  585. package/examples/extensions/space-invaders.ts +1 -1
  586. package/examples/extensions/structured-output.ts +65 -0
  587. package/examples/extensions/subagent/index.ts +51 -28
  588. package/examples/extensions/summarize.ts +1 -1
  589. package/examples/extensions/tic-tac-toe.ts +1008 -0
  590. package/examples/extensions/titlebar-spinner.ts +2 -2
  591. package/examples/extensions/todo.ts +2 -2
  592. package/examples/extensions/tool-override.ts +1 -1
  593. package/examples/extensions/tools.ts +5 -0
  594. package/examples/extensions/truncated-tool.ts +1 -1
  595. package/examples/extensions/with-deps/index.ts +1 -1
  596. package/examples/extensions/with-deps/package-lock.json +2 -2
  597. package/examples/extensions/with-deps/package.json +3 -3
  598. package/examples/extensions/working-indicator.ts +123 -0
  599. package/examples/extensions/working-message-test.ts +25 -0
  600. package/examples/sdk/01-minimal.ts +14 -10
  601. package/examples/sdk/02-custom-model.ts +12 -8
  602. package/examples/sdk/03-custom-prompt.ts +32 -17
  603. package/examples/sdk/04-skills.ts +5 -2
  604. package/examples/sdk/05-tools.ts +23 -31
  605. package/examples/sdk/06-extensions.ts +14 -8
  606. package/examples/sdk/07-context-files.ts +5 -3
  607. package/examples/sdk/08-prompt-templates.ts +5 -2
  608. package/examples/sdk/09-api-keys-and-oauth.ts +8 -4
  609. package/examples/sdk/10-settings.ts +8 -6
  610. package/examples/sdk/11-sessions.ts +4 -0
  611. package/examples/sdk/12-full-control.ts +13 -17
  612. package/package.json +15 -7
  613. package/prompts/commands/atomic-commit.md +12 -0
  614. package/prompts/commands/execute-phase.md +48 -17
  615. package/prompts/commands/fix.md +86 -23
  616. package/prompts/commands/map-codebase.md +17 -3
  617. package/prompts/commands/orchestrate.md +31 -6
  618. package/prompts/commands/plan-phase.md +39 -6
  619. package/prompts/commands/quick.md +36 -6
  620. package/prompts/commands/review.md +28 -11
  621. package/prompts/commands/verify-work.md +34 -17
@@ -6,23 +6,25 @@
6
6
 
7
7
  import { createAgentSession, SessionManager, SettingsManager } from "@draht/coding-agent";
8
8
 
9
+ const cwd = process.cwd();
10
+
9
11
  // Load current settings (merged global + project)
10
- const settingsManagerFromDisk = SettingsManager.create();
12
+ const settingsManagerFromDisk = SettingsManager.create(cwd);
11
13
  console.log("Current settings:", JSON.stringify(settingsManagerFromDisk.getGlobalSettings(), null, 2));
12
14
 
13
15
  // Override specific settings
14
- const settingsManager = SettingsManager.create();
16
+ const settingsManager = SettingsManager.create(cwd);
15
17
  settingsManager.applyOverrides({
16
18
  compaction: { enabled: false },
17
19
  retry: { enabled: true, maxRetries: 5, baseDelayMs: 1000 },
18
20
  });
19
21
 
20
- await createAgentSession({
22
+ const { session: customSettingsSession } = await createAgentSession({
21
23
  settingsManager,
22
24
  sessionManager: SessionManager.inMemory(),
23
25
  });
24
-
25
26
  console.log("Session created with custom settings");
27
+ customSettingsSession.dispose();
26
28
 
27
29
  // Setters update memory immediately and queue persistence writes.
28
30
  // Call flush() when you need a durability boundary.
@@ -43,9 +45,9 @@ const inMemorySettings = SettingsManager.inMemory({
43
45
  retry: { enabled: false },
44
46
  });
45
47
 
46
- await createAgentSession({
48
+ const { session: testSession } = await createAgentSession({
47
49
  settingsManager: inMemorySettings,
48
50
  sessionManager: SessionManager.inMemory(),
49
51
  });
50
-
51
52
  console.log("Test session created with in-memory settings");
53
+ testSession.dispose();
@@ -11,12 +11,14 @@ const { session: inMemory } = await createAgentSession({
11
11
  sessionManager: SessionManager.inMemory(),
12
12
  });
13
13
  console.log("In-memory session:", inMemory.sessionFile ?? "(none)");
14
+ inMemory.dispose();
14
15
 
15
16
  // New persistent session
16
17
  const { session: newSession } = await createAgentSession({
17
18
  sessionManager: SessionManager.create(process.cwd()),
18
19
  });
19
20
  console.log("New session file:", newSession.sessionFile);
21
+ newSession.dispose();
20
22
 
21
23
  // Continue most recent session (or create new if none)
22
24
  const { session: continued, modelFallbackMessage } = await createAgentSession({
@@ -24,6 +26,7 @@ const { session: continued, modelFallbackMessage } = await createAgentSession({
24
26
  });
25
27
  if (modelFallbackMessage) console.log("Note:", modelFallbackMessage);
26
28
  console.log("Continued session:", continued.sessionFile);
29
+ continued.dispose();
27
30
 
28
31
  // List and open specific session
29
32
  const sessions = await SessionManager.list(process.cwd());
@@ -37,6 +40,7 @@ if (sessions.length > 0) {
37
40
  sessionManager: SessionManager.open(sessions[0].path),
38
41
  });
39
42
  console.log(`\nOpened: ${opened.sessionId}`);
43
+ opened.dispose();
40
44
  }
41
45
 
42
46
  // Custom session directory (no cwd encoding)
@@ -2,19 +2,13 @@
2
2
  * Full Control
3
3
  *
4
4
  * Replace everything - no discovery, explicit configuration.
5
- *
6
- * IMPORTANT: When providing `tools` with a custom `cwd`, use the tool factory
7
- * functions (createReadTool, createBashTool, etc.) to ensure tools resolve
8
- * paths relative to your cwd.
9
5
  */
10
6
 
11
7
  import { getModel } from "@draht/ai";
12
8
  import {
13
9
  AuthStorage,
14
10
  createAgentSession,
15
- createBashTool,
16
11
  createExtensionRuntime,
17
- createReadTool,
18
12
  ModelRegistry,
19
13
  type ResourceLoader,
20
14
  SessionManager,
@@ -41,7 +35,6 @@ const settingsManager = SettingsManager.inMemory({
41
35
  retry: { enabled: true, maxRetries: 2 },
42
36
  });
43
37
 
44
- // When using a custom cwd with explicit tools, use the factory functions
45
38
  const cwd = process.cwd();
46
39
 
47
40
  const resourceLoader: ResourceLoader = {
@@ -65,17 +58,20 @@ const { session } = await createAgentSession({
65
58
  authStorage,
66
59
  modelRegistry,
67
60
  resourceLoader,
68
- // Use factory functions with the same cwd to ensure path resolution works correctly
69
- tools: [createReadTool(cwd), createBashTool(cwd)],
70
- sessionManager: SessionManager.inMemory(),
61
+ tools: ["read", "bash"],
62
+ sessionManager: SessionManager.inMemory(cwd),
71
63
  settingsManager,
72
64
  });
73
65
 
74
- session.subscribe((event) => {
75
- if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
76
- process.stdout.write(event.assistantMessageEvent.delta);
77
- }
78
- });
66
+ try {
67
+ session.subscribe((event) => {
68
+ if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
69
+ process.stdout.write(event.assistantMessageEvent.delta);
70
+ }
71
+ });
79
72
 
80
- await session.prompt("List files in the current directory.");
81
- console.log();
73
+ await session.prompt("List files in the current directory.");
74
+ console.log();
75
+ } finally {
76
+ session.dispose();
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draht/coding-agent",
3
- "version": "2026.4.26",
3
+ "version": "2026.6.11",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "drahtConfig": {
@@ -41,30 +41,37 @@
41
41
  "build:binary": "bun run build && bun build --compile ./dist/cli.js --outfile dist/draht && bun run copy-binary-assets",
42
42
  "copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/ && shx rm -rf dist/prompts dist/hooks dist/agents && shx cp -r prompts dist/prompts && shx cp -r hooks dist/hooks && shx cp -r agents dist/agents",
43
43
  "copy-binary-assets": "shx cp package.json dist/ && shx cp README.md dist/ && shx cp CHANGELOG.md dist/ && shx mkdir -p dist/theme && shx cp src/modes/interactive/theme/*.json dist/theme/ && shx mkdir -p dist/export-html/vendor && shx cp src/core/export-html/template.html dist/export-html/ && shx cp src/core/export-html/vendor/*.js dist/export-html/vendor/ && shx cp -r docs dist/ && shx cp -r examples dist/ && shx cp -r prompts dist/ && shx cp -r hooks dist/ && shx cp -r agents dist/ && shx cp ../../node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm dist/",
44
+ "sync-tools": "node ../../scripts/sync-draht-tools.mjs",
44
45
  "test": "vitest --run",
45
- "prepublishOnly": "bun run clean && bun run build"
46
+ "prepublishOnly": "node ../../scripts/sync-draht-tools.mjs && bun run clean && bun run build"
46
47
  },
47
48
  "dependencies": {
48
49
  "@mariozechner/jiti": "^2.6.2",
49
- "@draht/agent-core": "2026.4.26",
50
- "@draht/ai": "2026.4.26",
51
- "@draht/tui": "2026.4.26",
50
+ "@draht/agent-core": "2026.6.11",
51
+ "@draht/ai": "2026.6.11",
52
+ "@draht/tools": "2026.6.11",
53
+ "@draht/tui": "2026.6.11",
52
54
  "@silvia-odwyer/photon-node": "^0.3.4",
55
+ "@sinclair/typebox": "^0.34.41",
53
56
  "ajv": "^8.17.1",
54
57
  "chalk": "^5.5.0",
55
58
  "cli-highlight": "^2.1.11",
59
+ "cross-spawn": "7.0.6",
56
60
  "diff": "^8.0.2",
57
61
  "extract-zip": "^2.0.1",
58
62
  "file-type": "^21.1.1",
59
63
  "glob": "^13.0.1",
64
+ "highlight.js": "10.7.3",
60
65
  "hosted-git-info": "^9.0.2",
61
66
  "ignore": "^7.0.5",
62
67
  "marked": "^15.0.12",
63
68
  "minimatch": "^10.2.3",
64
69
  "proper-lockfile": "^4.1.2",
65
70
  "strip-ansi": "^7.1.0",
71
+ "typebox": "^1.1.24",
66
72
  "undici": "^7.19.1",
67
- "yaml": "^2.8.2"
73
+ "yaml": "^2.8.2",
74
+ "uuid": "^14.0.0"
68
75
  },
69
76
  "overrides": {
70
77
  "rimraf": "6.1.2",
@@ -76,6 +83,7 @@
76
83
  "@mariozechner/clipboard": "^0.3.2"
77
84
  },
78
85
  "devDependencies": {
86
+ "@types/cross-spawn": "6.0.6",
79
87
  "@types/diff": "^7.0.2",
80
88
  "@types/hosted-git-info": "^3.0.5",
81
89
  "@types/ms": "^2.1.0",
@@ -93,7 +101,7 @@
93
101
  "tui",
94
102
  "agent"
95
103
  ],
96
- "author": "Mario Zechner",
104
+ "author": "Oskar Freye",
97
105
  "license": "MIT",
98
106
  "publishConfig": {
99
107
  "access": "public"
@@ -4,6 +4,18 @@ description: "Analyze changes and create atomic commits"
4
4
 
5
5
  # Git Atomic Commit Analysis
6
6
 
7
+ ## Red Flags — STOP
8
+
9
+ Do NOT proceed with a commit if **any** of these is true:
10
+
11
+ - A single proposed commit mixes unrelated concerns (feature + unrelated refactor + config tweak)
12
+ - The change set contains potential secrets (`.env`, credentials, API keys in source)
13
+ - Staged content includes files unrelated to the user's stated intent
14
+ - Pre-commit hooks fail — fix the cause, never use `--no-verify`
15
+ - You cannot articulate the "why" of a commit in one sentence — split it
16
+
17
+ Surface any of these to the user and split the change set before continuing.
18
+
7
19
  ## Atomic Reasoning
8
20
 
9
21
  Before creating commits, decompose changes into atomic reasoning units:
@@ -1,10 +1,10 @@
1
1
  ---
2
- description: "Execute all plans in a phase with atomic commits"
2
+ description: "Execute all plans in a phase with atomic commits + per-task two-stage review"
3
3
  ---
4
4
 
5
5
  # /execute-phase
6
6
 
7
- Execute all plans in a phase with atomic commits, parallelizing independent plans via subagents.
7
+ Execute all plans in a phase with atomic commits, parallelizing independent plans via subagents. Each task is implemented, then **spec-reviewed**, then **quality-reviewed** before the next task begins.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -14,6 +14,16 @@ Execute all plans in a phase with atomic commits, parallelizing independent plan
14
14
  Phase: $1
15
15
  Arguments: $ARGUMENTS
16
16
 
17
+ ## Red Flags — STOP
18
+
19
+ STOP and report to the user instead of proceeding if **any** of these is true:
20
+
21
+ - Any plan file contains placeholder text: `[TBD]`, `[files]`, `[description]`, "appropriate error handling", "similar to Task N", or empty `<test>` / `<action>` / `<verify>` / `<done>` sections
22
+ - A plan has zero `<task>` elements
23
+ - `.planning/DOMAIN.md` is absent on a non-greenfield project
24
+ - The working tree is dirty with changes unrelated to this phase
25
+ - A subagent returns `STATUS: BLOCKED` — never retry blindly; report and ask the user
26
+
17
27
  ## Atomic Reasoning
18
28
 
19
29
  Before executing, decompose this phase execution into atomic reasoning units:
@@ -30,22 +40,35 @@ Before executing, decompose this phase execution into atomic reasoning units:
30
40
 
31
41
  ## Steps
32
42
  1. Run `draht-tools discover-plans $1` to find and order plans
33
- 2. Read each plan file yourself (from `.planning/phases/`) and analyze dependencies to identify which plans can run in parallel vs sequential
34
- 3. **Delegate execution to subagents:**
35
- - For independent plans (no shared files, no dependency chain): use the `subagent` tool in **parallel mode** with `implementer` agents, one per plan.
36
- - For dependent plans: execute them sequentially, each via a **single** `subagent` call to `implementer`, waiting for the previous to complete before starting the next.
37
- - Each subagent task must include:
38
- - The full plan content (paste it into the task — the subagent cannot run draht-tools)
39
- - The TDD cycle instructions (see template below)
40
- - Instructions to commit with `git add <files> && git commit -m "description"`
41
-
42
- 4. After all subagents complete, collect results and check for failures
43
- 5. Run `draht-tools verify-phase $1` yourself (not the subagent)
43
+ 2. Run `draht-tools validate-plans $1` — if any plan has placeholders or missing sections, STOP and fix the plan first
44
+ 3. Read each plan file yourself (from `.planning/phases/`) and analyze dependencies to identify which plans can run in parallel vs sequential
45
+ 4. **Per-plan execution loop.** For each plan (parallel where independent, sequential where dependent), iterate over its `<task>` elements with a **three-stage** dispatch:
46
+
47
+ ### Stage 1 — Implementer
48
+ Use the `subagent` tool in **single mode** with the `implementer` agent. Prompt includes the full plan content + the TDD cycle instructions (template below). Read the final `STATUS:` line:
49
+ - `DONE` → go to Stage 2.
50
+ - `DONE_WITH_CONCERNS` → if concerns are correctness-related, re-dispatch with a fix instruction; otherwise note and proceed.
51
+ - `NEEDS_CONTEXT` → provide the missing info and re-dispatch.
52
+ - `BLOCKED` → STOP, report to the user.
53
+
54
+ ### Stage 2 — Spec-reviewer
55
+ Use the `subagent` tool with the `spec-reviewer` agent. ONLY checks "does the diff cover exactly what the spec asked for". Prompt includes the task XML and the diff range.
56
+ - `DONE` → go to Stage 3.
57
+ - `DONE_WITH_CONCERNS` → note and proceed.
58
+ - `BLOCKED` → re-dispatch implementer with the "Required Fixes" list; repeat Stage 1+2 until `DONE`. Never proceed to Stage 3 with a non-compliant diff.
59
+
60
+ ### Stage 3 — Reviewer (code quality)
61
+ Use the `subagent` tool with the `reviewer` agent for code-quality review. Spec compliance is already ✅.
62
+ - `DONE` → task complete; move to next task.
63
+ - `DONE_WITH_CONCERNS` → log `Should fix` items; if any are correctness-critical, re-dispatch implementer.
64
+ - `BLOCKED` → `Must fix` issues exist; re-dispatch implementer with the issue list. Repeat until `DONE`.
65
+
66
+ 5. After all plans complete, run `draht-tools verify-phase $1` yourself (not the subagent)
44
67
  6. Run `draht-tools update-state` yourself
45
68
  7. Final commit: `draht-tools commit-docs "complete phase $1 execution"`
46
69
  8. After execution, tell the user to start a new session and run `/verify-work $1`.
47
70
 
48
- ## Subagent Task Template
71
+ ## Subagent Task Template (Stage 1: implementer)
49
72
 
50
73
  Each implementer subagent receives a task like:
51
74
 
@@ -55,20 +78,28 @@ Execute this plan. Here is the full plan content:
55
78
  <paste full plan XML here>
56
79
 
57
80
  For each <task> in the plan, follow this TDD cycle:
58
- 1. RED — Write failing tests from <test>. Run the test runner, confirm they FAIL. Commit with: git add <test-files> && git commit -m "test: <description>"
59
- 2. GREEN — Write minimal implementation from <action> to make tests pass. Run tests, confirm PASS. Commit with: git add <files> && git commit -m "feat: <task name>"
81
+ 1. RED — Write failing tests from <test>. Run the test runner, confirm they FAIL. Commit with: git add <test-files> && git commit -m "red: <description>"
82
+ 2. GREEN — Write minimal implementation from <action> to make tests pass. Run tests, confirm PASS. Commit with: git add <files> && git commit -m "green: <task name>"
60
83
  3. REFACTOR — Apply <refactor> improvements if any. Tests must stay green after each change. Commit with: git add <files> && git commit -m "refactor: <description>"
61
84
  4. VERIFY — Run the <verify> step, confirm <done> criteria are met.
62
85
 
63
86
  Domain rules: Use ubiquitous language from .planning/DOMAIN.md (read it). Do not import across bounded context boundaries.
64
87
  Checkpoint handling: type="auto" → execute silently. type="checkpoint:human-verify" → stop and report back what was built. type="checkpoint:decision" → stop and report the options.
65
88
 
89
+ End your response with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED` per the agent contract.
90
+
66
91
  Important: Do NOT run draht, draht-tools, draht help, or pi commands. Use only standard tools (read, bash, edit, write, grep, find, ls).
67
92
  ```
68
93
 
94
+ ## Two-Stage Review Rationale
95
+
96
+ - **Spec compliance prevents over/under-building.** The spec-reviewer catches drift before quality review masks it.
97
+ - **Code quality runs only after spec ✅.** Never accept "close enough" on spec compliance.
98
+ - **Tasks within a plan are sequential** — review loop completes before next task starts.
99
+
69
100
  ## Parallelization Rules
70
101
  - Plans sharing no files and having no dependency edges can run in parallel
71
- - If plan B depends on output of plan A, plan B must wait for A to complete
102
+ - Inside a plan, tasks run sequentially with the three-stage loop
72
103
  - Maximum parallel subagents: follow the subagent tool limits (max 8 tasks, 4 concurrent)
73
104
  - If a parallel subagent fails, report which plan failed and continue with independent plans
74
105
 
@@ -1,10 +1,10 @@
1
1
  ---
2
- description: "Diagnose and fix a bug with TDD discipline"
2
+ description: "Diagnose and fix a bug with a 4-phase systematic debugging protocol + TDD discipline"
3
3
  ---
4
4
 
5
5
  # /fix
6
6
 
7
- Diagnose and fix a specific bug or failing task with TDD discipline, using a subagent for diagnosis.
7
+ Diagnose and fix a bug using the **four-phase systematic debugging protocol**: root cause investigation → pattern analysis → hypothesis & testing → implementation with a reproducing test.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -13,39 +13,102 @@ Diagnose and fix a specific bug or failing task with TDD discipline, using a sub
13
13
 
14
14
  Issue: $ARGUMENTS
15
15
 
16
- ## Atomic Reasoning
16
+ ## The Iron Law
17
+
18
+ > **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.**
19
+
20
+ Symptom fixes are failure. If you find yourself proposing a "quick fix for now, investigate later", STOP and return to Phase 1.
21
+
22
+ ## Red Flags — STOP
17
23
 
18
- Before diagnosing, decompose this bug into atomic reasoning units:
24
+ Stop immediately if you catch yourself:
25
+ - Proposing "quick fixes for now, investigate later"
26
+ - Attempting multiple changes simultaneously
27
+ - Skipping a reproducing test before fixing
28
+ - Proposing solutions before understanding data flow
29
+ - Making "one more fix attempt" after already trying 2+
30
+ - Watching each fix reveal new problems elsewhere
31
+
32
+ After **3 failed fix attempts**, STOP. This is an architectural problem, not a hypothesis problem. Report back to the user — do not try a 4th fix.
33
+
34
+ ## Atomic Reasoning
19
35
 
20
36
  1. **State the logical component** — What is the observed failure? What should happen vs what actually happens?
21
37
  2. **Validate independence** — Which components/files are involved? Can we isolate the failure? Are there related bugs that should be fixed separately?
22
38
  3. **Verify correctness** — What test will reproduce this bug reliably? What would prove it's fixed? What regressions could the fix introduce?
23
39
 
24
- **Synthesize fix strategy:**
25
- - Trace the failure to root cause
26
- - Write a minimal reproducing test
27
- - Identify the smallest change that makes the test pass
28
- - Plan regression checks
40
+ ## The Four Phases
29
41
 
30
- ## Steps
31
- 1. **Diagnose via subagent**: Use the `subagent` tool in **single mode** with the `debugger` agent:
32
- "Diagnose this issue: $ARGUMENTS. Reproduce the bug by running the relevant test or command. Trace the root cause by reading the code. Identify the exact files and lines involved. Do NOT fix it yet — only report the diagnosis with: root cause, affected files, and a recommended fix approach. Do NOT run draht, draht-tools, or pi commands."
42
+ ### Phase 1 — Root Cause Investigation (before ANY fix)
33
43
 
34
- 2. **Write a reproducing test**: Based on the diagnosis, write a test that demonstrates the bug (it must fail)
35
- - Commit: `draht-tools commit-docs "test: reproduce bug"`
44
+ Use the `subagent` tool in **single mode** with the `debugger` agent. Prompt:
36
45
 
37
- 3. **Minimal fix**: Write the smallest change that makes the test pass
38
- - Do not refactor or add features — just fix the bug
39
- - Run the full test suite to check for regressions
40
- - Commit: `draht-tools commit-docs "fix: fix description"`
46
+ ```
47
+ Investigate this issue using Phase 1 root-cause discipline. Do NOT fix anything — only diagnose.
48
+
49
+ Issue: $ARGUMENTS
50
+
51
+ Walk through these steps and report on each:
52
+ 1. Read the error message / stack trace carefully — exact line numbers, exact file paths.
53
+ 2. Reproduce consistently — exact steps. If you cannot reproduce, gather more data instead of guessing.
54
+ 3. Check recent changes — `git log --oneline -20` and `git diff HEAD~5` against affected files.
55
+ 4. Trace data flow upward until you find the source. Fix at source, not at symptom.
56
+ 5. State the root cause as one sentence: "X happens because Y at <file:line>."
57
+
58
+ End your response with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
59
+ Do NOT run draht, draht-tools, or pi commands.
60
+ ```
41
61
 
42
- 4. **Refactor** (if needed): Clean up without changing behavior
43
- - Tests must stay green after every change
44
- - Commit: `draht-tools commit-docs "refactor: description"`
62
+ If `BLOCKED` or `NEEDS_CONTEXT`: provide the missing info and re-dispatch.
63
+
64
+ ### Phase 2 — Pattern Analysis
65
+
66
+ 1. Find working examples in the codebase that do the same kind of thing correctly
67
+ 2. Read those references completely — not skimmed
68
+ 3. List every difference between the working code and the broken code
69
+ 4. Note dependencies the working version assumes
70
+
71
+ If Phase 2 reveals a different root cause, go back to Phase 1.
72
+
73
+ ### Phase 3 — Single Hypothesis Test
74
+
75
+ 1. State ONE hypothesis: "I think the root cause is X because Y."
76
+ 2. Apply the smallest possible change to test it — one variable.
77
+ 3. Did it fix the issue?
78
+ - Yes → proceed to Phase 4.
79
+ - No → form a NEW hypothesis. Revert the test change. Do not pile changes.
80
+ 4. After 3 hypotheses still failing: STOP. Question architecture, not hypothesis. Report to user.
81
+
82
+ ### Phase 4 — Implementation
83
+
84
+ 1. **Write the reproducing test FIRST.** Confirm it FAILS for the right reason.
85
+ - Commit: `draht-tools commit-docs "red: reproduce <bug>"`
86
+
87
+ 2. **Apply the single fix** from Phase 3. No other changes.
88
+ - Failing test now PASSES.
89
+ - Full test suite — no regressions.
90
+ - Commit: `draht-tools commit-docs "green: fix <bug>"`
91
+
92
+ 3. **Refactor (optional)** — only if clear improvement, no behaviour change. Tests stay green.
93
+ - Commit: `draht-tools commit-docs "refactor: <description>"`
94
+
95
+ 4. **Verify the original symptom is gone** — run the user-level reproduction.
45
96
 
46
97
  5. **Update state**: `draht-tools update-state`
47
98
 
99
+ ## Rationalization Table
100
+
101
+ | Excuse | Reality |
102
+ |--------|---------|
103
+ | "Simple bug, skip the process" | Simple bugs have root causes too. The process is fast. |
104
+ | "It's an emergency, no time" | Systematic debugging is *faster* than thrashing. |
105
+ | "I'll write the test after I confirm the fix" | Untested fixes don't stick. |
106
+ | "I'll just try things and see what works" | Can't isolate what worked. Creates new bugs. |
107
+ | "I already manually tested it" | A reproducing test is the only durable proof. |
108
+
48
109
  ## Rules
49
- - Always reproduce before fixing — a fix without a test is a guess
50
- - One bug, one fix, one commit. Do not bundle unrelated changes.
110
+ - Always reproduce before fixing
111
+ - One bug, one fix, one commit series
112
+ - Fix at source, not symptom
113
+ - 3 failed attempts ⇒ architecture problem, stop and discuss
51
114
  - If the root cause spans multiple files, explain the chain in the commit message
@@ -32,12 +32,19 @@ Before analyzing, decompose codebase understanding into atomic reasoning units:
32
32
  ## Steps
33
33
  1. Run `draht-tools map-codebase $1`
34
34
  2. Tool generates: STACK.md, ARCHITECTURE.md, CONVENTIONS.md, CONCERNS.md
35
+ 2a. Run `draht-tools map-graph $1` to produce the **living architecture map**:
36
+ - `.planning/codebase/MAP.json` — machine-readable map with **entry points** (CLI bins, HTTP routes, library main exports), **sinks** (FS / net / DB / stdout / exec calls), **bounded contexts** (packages), **cross-package dataflow edges**, **symbol-resolved call edges**, **flows** (which sinks each entry point reaches and through which intermediate module), per-module **layer** (presentation / application / domain / infrastructure / support), and exports/imports per file. Agents starting a new task should read MAP.json first instead of re-scanning the tree.
37
+ - `.planning/codebase/MAP.html` — interactive layered visualization with three views:
38
+ - **System** — packages drawn as containers in architectural layers, with cross-package dataflow arrows. Thickness encodes import count.
39
+ - **Modules** — every file inside its package container, import edges between them; click a package or sink to highlight.
40
+ - **Flows** — entry points on top, sinks on bottom, intermediate modules ranked by depth from entry. Click an entry point to trace which sinks it reaches.
41
+ Open directly, or run `draht-tools map-serve` for a live-reloading dev view (regenerates on every file save).
35
42
  3. **Run parallel deep analysis via subagents:**
36
43
  Use the `subagent` tool in **parallel mode** with these tasks:
37
- - `architect` agent: "Analyze the codebase at $1. Identify bounded contexts from directory structure — look for top-level src/ subdirectories, packages, or modules that encapsulate coherent domain concepts. Note any cross-directory coupling suggesting blurred context boundaries. Extract domain language: collect PascalCase class/interface/type names, key function names, database table/collection names. Look for repeated nouns representing core domain concepts. Output a structured list of: bounded contexts (name + description), domain terms (glossary), aggregates per context, and context relationships (upstream/downstream, shared kernel, ACL). Do NOT run draht, draht-tools, or pi commands."
38
- - `verifier` agent: "Analyze the test infrastructure at $1. Discover: test framework(s) in use (check package.json, config files), test directory conventions (co-located, __tests__/, test/), existing coverage configuration and goals, which layers have tests (unit, integration, e2e), gaps and recommendations. Output a structured test strategy report. Do NOT run draht, draht-tools, or pi commands."
44
+ - `architect` agent: "Analyze the codebase at $1. Identify bounded contexts from directory structure — look for top-level src/ subdirectories, packages, or modules that encapsulate coherent domain concepts. Note any cross-directory coupling suggesting blurred context boundaries. Extract domain language: collect PascalCase class/interface/type names, key function names, database table/collection names. Look for repeated nouns representing core domain concepts. Output a structured list of: bounded contexts (name + description), domain terms (glossary), aggregates per context, and context relationships (upstream/downstream, shared kernel, ACL). End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`. Do NOT run draht, draht-tools, or pi commands."
45
+ - `verifier` agent: "Analyze the test infrastructure at $1. Discover: test framework(s) in use, test directory conventions, existing coverage configuration and goals, which layers have tests (unit, integration, e2e), gaps and recommendations. Output a structured test strategy report. End with `STATUS: ...`. Do NOT run draht, draht-tools, or pi commands."
39
46
 
40
- 4. Collect subagent results and merge with the draht-tools output
47
+ 4. Read each subagent's `STATUS:` line. `BLOCKED` or `NEEDS_CONTEXT` from either means STOP — partial output here corrupts downstream phases. Collect subagent results and merge with the draht-tools output.
41
48
  5. Create `.planning/DOMAIN.md` (if it doesn't exist) with:
42
49
  - `## Bounded Contexts` — one entry per discovered context with a brief description
43
50
  - `## Ubiquitous Language` — glossary of extracted domain terms
@@ -51,3 +58,10 @@ Before analyzing, decompose codebase understanding into atomic reasoning units:
51
58
  - `## Testing Levels` — what is tested at unit level vs integration vs e2e, with examples
52
59
  - `## Excluded` — what is explicitly not tested and why
53
60
  7. Commit: `draht-tools commit-docs "map existing codebase"`
61
+
62
+ ## Living map for agents
63
+
64
+ The `MAP.json` produced in step 2a is the single source of truth for "what's in this codebase":
65
+ - Subagents that need orientation should read `.planning/codebase/MAP.json` before walking the file tree.
66
+ - It is regenerated every time `map-codebase`, `map-graph`, or `map-serve` runs, so it stays current with the code.
67
+ - Developers can keep `draht-tools map-serve` running in a terminal — the HTML visualization updates live as files change, so architecture documentation is never stale.
@@ -9,7 +9,7 @@ Decompose a task and dispatch the right mix of specialist subagents.
9
9
 
10
10
  Task: $ARGUMENTS
11
11
 
12
- > **Tool note**: Use the `subagent` tool. Set `agent` to one of: `architect`, `implementer`, `reviewer`, `debugger`, `verifier`, `git-committer`, `security-auditor`. Use `tasks: [...]` for parallel dispatch and `chain: [...]` for sequential pipelines.
12
+ > **Tool note**: Use the `subagent` tool. Set `agent` to one of: `architect`, `implementer`, `spec-reviewer`, `reviewer`, `debugger`, `verifier`, `git-committer`, `security-auditor`. Use `tasks: [...]` for parallel dispatch and `chain: [...]` for sequential pipelines.
13
13
 
14
14
  ## Atomic Reasoning
15
15
 
@@ -26,12 +26,15 @@ Before delegating, decompose the task into atomic work units:
26
26
  |---|---|
27
27
  | Plan structure before coding | `architect` |
28
28
  | Write or change code | `implementer` |
29
- | Find what's broken | `debugger` |
30
- | Review for correctness / conventions / domain | `reviewer` |
29
+ | Check that a diff covers exactly the spec — no more, no less | `spec-reviewer` |
30
+ | Review code quality (correctness, conventions, domain language) | `reviewer` |
31
+ | Find what's broken (root-cause diagnosis) | `debugger` |
31
32
  | Audit for security issues | `security-auditor` |
32
33
  | Run lint / typecheck / tests | `verifier` |
33
34
  | Create atomic commits | `git-committer` |
34
35
 
36
+ `spec-reviewer` and `reviewer` are distinct on purpose. Spec-reviewer ONLY checks "did the diff implement what the spec asked, no more no less". Reviewer evaluates quality. For any task with a written spec, run spec-reviewer **before** reviewer.
37
+
35
38
  ## Orchestration Modes
36
39
 
37
40
  ### Parallel
@@ -43,15 +46,37 @@ Use the `subagent` tool with `chain: [...]` when later work depends on earlier o
43
46
  ### Fan-out / Fan-in
44
47
  Architect decomposes into N independent plans → dispatch N implementers in parallel → collect all outputs → single verifier run → single reviewer audit. This is the standard pattern for `/execute-phase` work.
45
48
 
49
+ ### Two-Stage Review (spec → quality)
50
+ For any task that has a written spec, follow implementer with **spec-reviewer first, then reviewer**:
51
+
52
+ ```
53
+ implementer → spec-reviewer → reviewer
54
+ ↓ BLOCKED
55
+ re-dispatch implementer with required fixes
56
+ ```
57
+
58
+ Never run quality review on a spec-non-compliant diff. This is the per-task loop inside `/execute-phase`.
59
+
60
+ ## Reading Subagent Status
61
+
62
+ Every draht agent ends its response with one of four status lines. Branch on it:
63
+
64
+ - `STATUS: DONE` — proceed to the next step in the chain.
65
+ - `STATUS: DONE_WITH_CONCERNS` — note the concerns. If correctness-related, address before moving on; otherwise log and continue.
66
+ - `STATUS: NEEDS_CONTEXT` — provide the missing info and re-dispatch the same agent. Do NOT skip ahead with a guess.
67
+ - `STATUS: BLOCKED` — STOP. Report the blocker. Do not retry the same agent on the same input — adjust inputs (more context, decompose further, different agent) or surface to the user.
68
+
46
69
  ## Steps
47
70
  1. Read the task description and identify sub-tasks
48
71
  2. Map each sub-task to the right agent from the table above
49
- 3. Decide parallel vs chain vs fan-out based on dependencies
72
+ 3. Decide parallel vs chain vs fan-out vs two-stage based on dependencies
50
73
  4. Dispatch via the `subagent` tool accordingly
51
- 5. Collect results, handle failures, report the final outcome to the user
74
+ 5. Read each subagent's final `STATUS:` line and branch per the protocol above
75
+ 6. Collect results, handle failures, report the final outcome to the user
52
76
 
53
77
  ## Rules
54
78
  - Prefer parallel dispatch when possible — it's faster and each subagent has its own context
55
79
  - Pass complete context to subagents — they cannot see the main conversation
56
80
  - Do not nest delegations deeply — one level is usually enough
57
- - If a subagent fails, report the failure and suggest next steps rather than retrying blindly
81
+ - Never retry the same agent on the same input after `BLOCKED` — change something
82
+ - For any spec-driven work, spec-reviewer runs before quality reviewer