@draht/coding-agent 2026.7.7 → 2026.7.12-1

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 (532) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +2 -2
  3. package/agents/advisor.md +44 -0
  4. package/bin/draht-tools.cjs +1808 -988
  5. package/dist/agents/advisor.md +44 -0
  6. package/dist/bun/cli.d.ts.map +1 -1
  7. package/dist/bun/cli.js.map +1 -1
  8. package/dist/bun/register-bedrock.d.ts.map +1 -1
  9. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  10. package/dist/bun/restore-sandbox-env.js.map +1 -1
  11. package/dist/cli/args.d.ts.map +1 -1
  12. package/dist/cli/args.js +1 -1
  13. package/dist/cli/args.js.map +1 -1
  14. package/dist/cli/attach-mode.d.ts.map +1 -1
  15. package/dist/cli/attach-mode.js.map +1 -1
  16. package/dist/cli/config-selector.d.ts.map +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.map +1 -1
  20. package/dist/cli/initial-message.d.ts +1 -1
  21. package/dist/cli/initial-message.d.ts.map +1 -1
  22. package/dist/cli/initial-message.js.map +1 -1
  23. package/dist/cli/list-models.d.ts.map +1 -1
  24. package/dist/cli/list-models.js.map +1 -1
  25. package/dist/cli/list-sessions.d.ts.map +1 -1
  26. package/dist/cli/list-sessions.js.map +1 -1
  27. package/dist/cli/project-trust.d.ts.map +1 -1
  28. package/dist/cli/project-trust.js.map +1 -1
  29. package/dist/cli/session-picker.d.ts.map +1 -1
  30. package/dist/cli/session-picker.js.map +1 -1
  31. package/dist/cli/startup-ui.d.ts.map +1 -1
  32. package/dist/cli/startup-ui.js.map +1 -1
  33. package/dist/cli.d.ts.map +1 -1
  34. package/dist/cli.js.map +1 -1
  35. package/dist/config.d.ts.map +1 -1
  36. package/dist/config.js.map +1 -1
  37. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  38. package/dist/core/agent-session-runtime.js +0 -8
  39. package/dist/core/agent-session-runtime.js.map +1 -1
  40. package/dist/core/agent-session-services.d.ts.map +1 -1
  41. package/dist/core/agent-session-services.js +2 -0
  42. package/dist/core/agent-session-services.js.map +1 -1
  43. package/dist/core/agent-session.d.ts +44 -3
  44. package/dist/core/agent-session.d.ts.map +1 -1
  45. package/dist/core/agent-session.js +165 -136
  46. package/dist/core/agent-session.js.map +1 -1
  47. package/dist/core/auth-guidance.d.ts.map +1 -1
  48. package/dist/core/auth-guidance.js.map +1 -1
  49. package/dist/core/auth-storage.d.ts +4 -0
  50. package/dist/core/auth-storage.d.ts.map +1 -1
  51. package/dist/core/auth-storage.js +4 -7
  52. package/dist/core/auth-storage.js.map +1 -1
  53. package/dist/core/bash-executor.d.ts.map +1 -1
  54. package/dist/core/bash-executor.js.map +1 -1
  55. package/dist/core/builtins/index.d.ts +11 -0
  56. package/dist/core/builtins/index.d.ts.map +1 -0
  57. package/dist/core/builtins/index.js +11 -0
  58. package/dist/core/builtins/index.js.map +1 -0
  59. package/dist/core/builtins/subagent.d.ts +88 -1
  60. package/dist/core/builtins/subagent.d.ts.map +1 -1
  61. package/dist/core/builtins/subagent.js +263 -27
  62. package/dist/core/builtins/subagent.js.map +1 -1
  63. package/dist/core/cache-stats.d.ts +49 -0
  64. package/dist/core/cache-stats.d.ts.map +1 -0
  65. package/dist/core/cache-stats.js +101 -0
  66. package/dist/core/cache-stats.js.map +1 -0
  67. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  68. package/dist/core/compaction/branch-summarization.js.map +1 -1
  69. package/dist/core/compaction/compaction.d.ts +1 -2
  70. package/dist/core/compaction/compaction.d.ts.map +1 -1
  71. package/dist/core/compaction/compaction.js +51 -73
  72. package/dist/core/compaction/compaction.js.map +1 -1
  73. package/dist/core/compaction/index.d.ts.map +1 -1
  74. package/dist/core/compaction/utils.d.ts.map +1 -1
  75. package/dist/core/compaction/utils.js.map +1 -1
  76. package/dist/core/defaults.d.ts.map +1 -1
  77. package/dist/core/diagnostics.d.ts.map +1 -1
  78. package/dist/core/event-bus.d.ts.map +1 -1
  79. package/dist/core/event-bus.js.map +1 -1
  80. package/dist/core/exec.d.ts.map +1 -1
  81. package/dist/core/exec.js.map +1 -1
  82. package/dist/core/experimental.d.ts.map +1 -1
  83. package/dist/core/experimental.js.map +1 -1
  84. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  85. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  86. package/dist/core/export-html/index.d.ts.map +1 -1
  87. package/dist/core/export-html/index.js.map +1 -1
  88. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  89. package/dist/core/export-html/tool-renderer.js.map +1 -1
  90. package/dist/core/extensions/index.d.ts +1 -1
  91. package/dist/core/extensions/index.d.ts.map +1 -1
  92. package/dist/core/extensions/index.js.map +1 -1
  93. package/dist/core/extensions/loader.d.ts.map +1 -1
  94. package/dist/core/extensions/loader.js +23 -4
  95. package/dist/core/extensions/loader.js.map +1 -1
  96. package/dist/core/extensions/runner.d.ts.map +1 -1
  97. package/dist/core/extensions/runner.js +22 -52
  98. package/dist/core/extensions/runner.js.map +1 -1
  99. package/dist/core/extensions/types.d.ts +9 -9
  100. package/dist/core/extensions/types.d.ts.map +1 -1
  101. package/dist/core/extensions/types.js.map +1 -1
  102. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  103. package/dist/core/extensions/wrapper.js.map +1 -1
  104. package/dist/core/footer-data-provider.d.ts.map +1 -1
  105. package/dist/core/footer-data-provider.js +17 -18
  106. package/dist/core/footer-data-provider.js.map +1 -1
  107. package/dist/core/http-dispatcher.d.ts.map +1 -1
  108. package/dist/core/http-dispatcher.js.map +1 -1
  109. package/dist/core/index.d.ts +1 -1
  110. package/dist/core/index.d.ts.map +1 -1
  111. package/dist/core/index.js.map +1 -1
  112. package/dist/core/keybindings.d.ts.map +1 -1
  113. package/dist/core/keybindings.js +0 -1
  114. package/dist/core/keybindings.js.map +1 -1
  115. package/dist/core/messages.d.ts.map +1 -1
  116. package/dist/core/messages.js.map +1 -1
  117. package/dist/core/model-registry.d.ts +4 -6
  118. package/dist/core/model-registry.d.ts.map +1 -1
  119. package/dist/core/model-registry.js +39 -15
  120. package/dist/core/model-registry.js.map +1 -1
  121. package/dist/core/model-resolver.d.ts.map +1 -1
  122. package/dist/core/model-resolver.js.map +1 -1
  123. package/dist/core/multi-agent/fsm.d.ts +60 -0
  124. package/dist/core/multi-agent/fsm.d.ts.map +1 -0
  125. package/dist/core/multi-agent/fsm.js +90 -0
  126. package/dist/core/multi-agent/fsm.js.map +1 -0
  127. package/dist/core/multi-agent/index.d.ts +21 -0
  128. package/dist/core/multi-agent/index.d.ts.map +1 -0
  129. package/dist/core/multi-agent/index.js +21 -0
  130. package/dist/core/multi-agent/index.js.map +1 -0
  131. package/dist/core/multi-agent/mailbox.d.ts +56 -0
  132. package/dist/core/multi-agent/mailbox.d.ts.map +1 -0
  133. package/dist/core/multi-agent/mailbox.js +112 -0
  134. package/dist/core/multi-agent/mailbox.js.map +1 -0
  135. package/dist/core/multi-agent/permission-gate.d.ts +140 -0
  136. package/dist/core/multi-agent/permission-gate.d.ts.map +1 -0
  137. package/dist/core/multi-agent/permission-gate.js +669 -0
  138. package/dist/core/multi-agent/permission-gate.js.map +1 -0
  139. package/dist/core/multi-agent/task-board.d.ts +100 -0
  140. package/dist/core/multi-agent/task-board.d.ts.map +1 -0
  141. package/dist/core/multi-agent/task-board.js +141 -0
  142. package/dist/core/multi-agent/task-board.js.map +1 -0
  143. package/dist/core/multi-agent/worktree.d.ts +50 -0
  144. package/dist/core/multi-agent/worktree.d.ts.map +1 -0
  145. package/dist/core/multi-agent/worktree.js +148 -0
  146. package/dist/core/multi-agent/worktree.js.map +1 -0
  147. package/dist/core/output-guard.d.ts.map +1 -1
  148. package/dist/core/output-guard.js.map +1 -1
  149. package/dist/core/package-manager.d.ts.map +1 -1
  150. package/dist/core/package-manager.js +0 -6
  151. package/dist/core/package-manager.js.map +1 -1
  152. package/dist/core/project-trust.d.ts.map +1 -1
  153. package/dist/core/project-trust.js.map +1 -1
  154. package/dist/core/prompt-templates.d.ts.map +1 -1
  155. package/dist/core/prompt-templates.js.map +1 -1
  156. package/dist/core/provider-attribution.d.ts.map +1 -1
  157. package/dist/core/provider-attribution.js.map +1 -1
  158. package/dist/core/provider-display-names.d.ts.map +1 -1
  159. package/dist/core/resolve-config-value.d.ts.map +1 -1
  160. package/dist/core/resolve-config-value.js.map +1 -1
  161. package/dist/core/resource-loader.d.ts.map +1 -1
  162. package/dist/core/resource-loader.js +2 -46
  163. package/dist/core/resource-loader.js.map +1 -1
  164. package/dist/core/sdk.d.ts.map +1 -1
  165. package/dist/core/sdk.js +7 -1
  166. package/dist/core/sdk.js.map +1 -1
  167. package/dist/core/session-cwd.d.ts.map +1 -1
  168. package/dist/core/session-cwd.js +0 -1
  169. package/dist/core/session-cwd.js.map +1 -1
  170. package/dist/core/session-manager.d.ts.map +1 -1
  171. package/dist/core/session-manager.js +7 -11
  172. package/dist/core/session-manager.js.map +1 -1
  173. package/dist/core/settings-manager.d.ts +7 -3
  174. package/dist/core/settings-manager.d.ts.map +1 -1
  175. package/dist/core/settings-manager.js +17 -18
  176. package/dist/core/settings-manager.js.map +1 -1
  177. package/dist/core/skills.d.ts.map +1 -1
  178. package/dist/core/skills.js.map +1 -1
  179. package/dist/core/slash-commands.d.ts +1 -0
  180. package/dist/core/slash-commands.d.ts.map +1 -1
  181. package/dist/core/slash-commands.js +3 -3
  182. package/dist/core/slash-commands.js.map +1 -1
  183. package/dist/core/socket-server/discovery.d.ts.map +1 -1
  184. package/dist/core/socket-server/discovery.js.map +1 -1
  185. package/dist/core/socket-server/index.d.ts.map +1 -1
  186. package/dist/core/socket-server/session-integration.d.ts.map +1 -1
  187. package/dist/core/socket-server/session-integration.js.map +1 -1
  188. package/dist/core/socket-server/socket-client.d.ts.map +1 -1
  189. package/dist/core/socket-server/socket-client.js.map +1 -1
  190. package/dist/core/socket-server/socket-server.d.ts.map +1 -1
  191. package/dist/core/socket-server/socket-server.js.map +1 -1
  192. package/dist/core/socket-server/types.d.ts.map +1 -1
  193. package/dist/core/source-info.d.ts.map +1 -1
  194. package/dist/core/source-info.js.map +1 -1
  195. package/dist/core/system-prompt.d.ts.map +1 -1
  196. package/dist/core/system-prompt.js.map +1 -1
  197. package/dist/core/telemetry.d.ts.map +1 -1
  198. package/dist/core/telemetry.js.map +1 -1
  199. package/dist/core/timings.d.ts.map +1 -1
  200. package/dist/core/timings.js.map +1 -1
  201. package/dist/core/tools/bash.d.ts.map +1 -1
  202. package/dist/core/tools/bash.js +8 -5
  203. package/dist/core/tools/bash.js.map +1 -1
  204. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  205. package/dist/core/tools/edit-diff.js.map +1 -1
  206. package/dist/core/tools/edit.d.ts.map +1 -1
  207. package/dist/core/tools/edit.js.map +1 -1
  208. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  209. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  210. package/dist/core/tools/find.d.ts.map +1 -1
  211. package/dist/core/tools/find.js.map +1 -1
  212. package/dist/core/tools/grep.d.ts.map +1 -1
  213. package/dist/core/tools/grep.js.map +1 -1
  214. package/dist/core/tools/index.d.ts.map +1 -1
  215. package/dist/core/tools/index.js.map +1 -1
  216. package/dist/core/tools/ls.d.ts.map +1 -1
  217. package/dist/core/tools/ls.js.map +1 -1
  218. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  219. package/dist/core/tools/output-accumulator.js +12 -18
  220. package/dist/core/tools/output-accumulator.js.map +1 -1
  221. package/dist/core/tools/path-utils.d.ts.map +1 -1
  222. package/dist/core/tools/path-utils.js.map +1 -1
  223. package/dist/core/tools/read.d.ts.map +1 -1
  224. package/dist/core/tools/read.js.map +1 -1
  225. package/dist/core/tools/render-utils.d.ts.map +1 -1
  226. package/dist/core/tools/render-utils.js.map +1 -1
  227. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  228. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  229. package/dist/core/tools/truncate.d.ts.map +1 -1
  230. package/dist/core/tools/truncate.js.map +1 -1
  231. package/dist/core/tools/write.d.ts.map +1 -1
  232. package/dist/core/tools/write.js +0 -1
  233. package/dist/core/tools/write.js.map +1 -1
  234. package/dist/core/trust-manager.d.ts.map +1 -1
  235. package/dist/core/trust-manager.js +0 -1
  236. package/dist/core/trust-manager.js.map +1 -1
  237. package/dist/gsd/domain-validator.d.ts.map +1 -1
  238. package/dist/gsd/domain-validator.js.map +1 -1
  239. package/dist/gsd/domain.d.ts.map +1 -1
  240. package/dist/gsd/domain.js.map +1 -1
  241. package/dist/gsd/git.d.ts.map +1 -1
  242. package/dist/gsd/git.js.map +1 -1
  243. package/dist/gsd/hook-utils.d.ts.map +1 -1
  244. package/dist/gsd/hook-utils.js +3 -1
  245. package/dist/gsd/hook-utils.js.map +1 -1
  246. package/dist/gsd/index.d.ts.map +1 -1
  247. package/dist/gsd/index.js.map +1 -1
  248. package/dist/gsd/planning.d.ts.map +1 -1
  249. package/dist/gsd/planning.js.map +1 -1
  250. package/dist/hooks/gsd/draht-post-task.js +1 -1
  251. package/dist/hooks/gsd/draht-quality-gate.js +1 -1
  252. package/dist/index.d.ts +1 -1
  253. package/dist/index.d.ts.map +1 -1
  254. package/dist/index.js.map +1 -1
  255. package/dist/main.d.ts.map +1 -1
  256. package/dist/main.js +6 -0
  257. package/dist/main.js.map +1 -1
  258. package/dist/migrations.d.ts.map +1 -1
  259. package/dist/migrations.js.map +1 -1
  260. package/dist/modes/index.d.ts.map +1 -1
  261. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  262. package/dist/modes/interactive/components/armin.js +6 -10
  263. package/dist/modes/interactive/components/armin.js.map +1 -1
  264. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  265. package/dist/modes/interactive/components/assistant-message.js +1 -7
  266. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  267. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/bash-execution.js +4 -9
  269. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  270. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  271. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  272. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  273. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  274. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  275. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  276. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  277. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  278. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  279. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  280. package/dist/modes/interactive/components/config-selector.js +5 -22
  281. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  282. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  283. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  284. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  285. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  286. package/dist/modes/interactive/components/custom-editor.js +1 -8
  287. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  288. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  289. package/dist/modes/interactive/components/custom-entry.js +1 -4
  290. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  291. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  292. package/dist/modes/interactive/components/custom-message.js +1 -6
  293. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  294. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  295. package/dist/modes/interactive/components/daxnuts.js +6 -8
  296. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  297. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  298. package/dist/modes/interactive/components/diff.js.map +1 -1
  299. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  300. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  301. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  302. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  303. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  304. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  305. package/dist/modes/interactive/components/extension-editor.js +1 -7
  306. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  307. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  308. package/dist/modes/interactive/components/extension-input.js +2 -8
  309. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  310. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  311. package/dist/modes/interactive/components/extension-selector.js +1 -9
  312. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  313. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  314. package/dist/modes/interactive/components/first-time-setup.js +2 -4
  315. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  316. package/dist/modes/interactive/components/footer.d.ts +4 -0
  317. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  318. package/dist/modes/interactive/components/footer.js +2 -4
  319. package/dist/modes/interactive/components/footer.js.map +1 -1
  320. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  321. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  322. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  323. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  324. package/dist/modes/interactive/components/login-dialog.js +3 -9
  325. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  326. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  327. package/dist/modes/interactive/components/model-selector.js +8 -20
  328. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  329. package/dist/modes/interactive/components/oauth-selector.d.ts +3 -1
  330. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/oauth-selector.js +19 -18
  332. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  333. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  334. package/dist/modes/interactive/components/scoped-models-selector.js +9 -13
  335. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  336. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  337. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  338. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  339. package/dist/modes/interactive/components/session-selector.js +33 -57
  340. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  341. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  342. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  343. package/dist/modes/interactive/components/settings-selector.js +10 -14
  344. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  345. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  346. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  347. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  348. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  349. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  350. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  351. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  352. package/dist/modes/interactive/components/status-indicator.js +0 -2
  353. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  354. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  355. package/dist/modes/interactive/components/theme-selector.js +0 -2
  356. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  357. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  358. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  359. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  360. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  361. package/dist/modes/interactive/components/tool-execution.js +9 -24
  362. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  363. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  364. package/dist/modes/interactive/components/tree-selector.js +18 -32
  365. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  366. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  367. package/dist/modes/interactive/components/trust-selector.js +0 -6
  368. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  369. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  370. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  371. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  372. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  373. package/dist/modes/interactive/components/user-message.js +0 -3
  374. package/dist/modes/interactive/components/user-message.js.map +1 -1
  375. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  376. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  377. package/dist/modes/interactive/interactive-mode.d.ts +21 -0
  378. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  379. package/dist/modes/interactive/interactive-mode.js +312 -143
  380. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  381. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  382. package/dist/modes/interactive/model-search.js.map +1 -1
  383. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  384. package/dist/modes/interactive/theme/theme-controller.js +2 -7
  385. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  386. package/dist/modes/interactive/theme/theme-schema.json +3 -4
  387. package/dist/modes/interactive/theme/theme.d.ts +4 -3
  388. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  389. package/dist/modes/interactive/theme/theme.js +8 -10
  390. package/dist/modes/interactive/theme/theme.js.map +1 -1
  391. package/dist/modes/print-mode.d.ts.map +1 -1
  392. package/dist/modes/print-mode.js +1 -1
  393. package/dist/modes/print-mode.js.map +1 -1
  394. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  395. package/dist/modes/rpc/jsonl.js.map +1 -1
  396. package/dist/modes/rpc/rpc-client.d.ts +6 -6
  397. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  398. package/dist/modes/rpc/rpc-client.js +10 -11
  399. package/dist/modes/rpc/rpc-client.js.map +1 -1
  400. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  401. package/dist/modes/rpc/rpc-mode.js +4 -1
  402. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  403. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  404. package/dist/package-manager-cli.d.ts.map +1 -1
  405. package/dist/package-manager-cli.js.map +1 -1
  406. package/dist/prompts/agents/build.md +38 -0
  407. package/dist/prompts/agents/plan.md +36 -0
  408. package/dist/prompts/agents/verify.md +36 -4
  409. package/dist/prompts/commands/brainstorm.md +16 -2
  410. package/dist/prompts/commands/discuss-phase.md +1 -1
  411. package/dist/prompts/commands/execute-phase.md +16 -3
  412. package/dist/prompts/commands/fix.md +13 -1
  413. package/dist/prompts/commands/init-project.md +1 -0
  414. package/dist/prompts/commands/map-codebase.md +9 -9
  415. package/dist/prompts/commands/new-project.md +1 -0
  416. package/dist/prompts/commands/next-milestone.md +3 -0
  417. package/dist/prompts/commands/orchestrate-loop.md +99 -0
  418. package/dist/prompts/commands/orchestrate.md +29 -6
  419. package/dist/prompts/commands/pause-work.md +2 -1
  420. package/dist/prompts/commands/plan-phase.md +6 -0
  421. package/dist/prompts/commands/quick.md +6 -2
  422. package/dist/prompts/commands/review.md +4 -1
  423. package/dist/prompts/commands/verify-work.md +10 -8
  424. package/dist/rlm-cli.d.ts +92 -0
  425. package/dist/rlm-cli.d.ts.map +1 -0
  426. package/dist/rlm-cli.js +379 -0
  427. package/dist/rlm-cli.js.map +1 -0
  428. package/dist/rpc-entry.d.ts.map +1 -1
  429. package/dist/rpc-entry.js.map +1 -1
  430. package/dist/utils/ansi.d.ts.map +1 -1
  431. package/dist/utils/ansi.js.map +1 -1
  432. package/dist/utils/changelog.d.ts.map +1 -1
  433. package/dist/utils/changelog.js.map +1 -1
  434. package/dist/utils/child-process.d.ts.map +1 -1
  435. package/dist/utils/child-process.js.map +1 -1
  436. package/dist/utils/clipboard-image.d.ts.map +1 -1
  437. package/dist/utils/clipboard-image.js +1 -1
  438. package/dist/utils/clipboard-image.js.map +1 -1
  439. package/dist/utils/clipboard-native.d.ts.map +1 -1
  440. package/dist/utils/clipboard-native.js.map +1 -1
  441. package/dist/utils/clipboard.d.ts.map +1 -1
  442. package/dist/utils/clipboard.js.map +1 -1
  443. package/dist/utils/deprecation.d.ts.map +1 -1
  444. package/dist/utils/deprecation.js.map +1 -1
  445. package/dist/utils/exif-orientation.d.ts.map +1 -1
  446. package/dist/utils/exif-orientation.js.map +1 -1
  447. package/dist/utils/frontmatter.d.ts.map +1 -1
  448. package/dist/utils/frontmatter.js.map +1 -1
  449. package/dist/utils/fs-watch.d.ts.map +1 -1
  450. package/dist/utils/fs-watch.js.map +1 -1
  451. package/dist/utils/git.d.ts.map +1 -1
  452. package/dist/utils/git.js.map +1 -1
  453. package/dist/utils/html.d.ts.map +1 -1
  454. package/dist/utils/html.js.map +1 -1
  455. package/dist/utils/image-convert.d.ts.map +1 -1
  456. package/dist/utils/image-convert.js.map +1 -1
  457. package/dist/utils/image-process.d.ts.map +1 -1
  458. package/dist/utils/image-process.js.map +1 -1
  459. package/dist/utils/image-resize-core.d.ts.map +1 -1
  460. package/dist/utils/image-resize-core.js.map +1 -1
  461. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  462. package/dist/utils/image-resize-worker.js.map +1 -1
  463. package/dist/utils/image-resize.d.ts.map +1 -1
  464. package/dist/utils/image-resize.js.map +1 -1
  465. package/dist/utils/json.d.ts.map +1 -1
  466. package/dist/utils/json.js.map +1 -1
  467. package/dist/utils/mime.d.ts.map +1 -1
  468. package/dist/utils/mime.js.map +1 -1
  469. package/dist/utils/notify.d.ts +3 -1
  470. package/dist/utils/notify.d.ts.map +1 -1
  471. package/dist/utils/notify.js +11 -4
  472. package/dist/utils/notify.js.map +1 -1
  473. package/dist/utils/open-browser.d.ts.map +1 -1
  474. package/dist/utils/open-browser.js.map +1 -1
  475. package/dist/utils/paths.d.ts.map +1 -1
  476. package/dist/utils/paths.js.map +1 -1
  477. package/dist/utils/photon.d.ts.map +1 -1
  478. package/dist/utils/photon.js.map +1 -1
  479. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  480. package/dist/utils/pi-user-agent.js.map +1 -1
  481. package/dist/utils/shell.d.ts.map +1 -1
  482. package/dist/utils/shell.js.map +1 -1
  483. package/dist/utils/sleep.d.ts.map +1 -1
  484. package/dist/utils/sleep.js.map +1 -1
  485. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  486. package/dist/utils/syntax-highlight.js.map +1 -1
  487. package/dist/utils/tools-manager.d.ts.map +1 -1
  488. package/dist/utils/tools-manager.js.map +1 -1
  489. package/dist/utils/version-check.d.ts.map +1 -1
  490. package/dist/utils/version-check.js.map +1 -1
  491. package/dist/utils/windows-self-update.d.ts.map +1 -1
  492. package/dist/utils/windows-self-update.js.map +1 -1
  493. package/docs/custom-provider.md +4 -3
  494. package/docs/extensions.md +15 -10
  495. package/docs/models.md +49 -8
  496. package/docs/rpc.md +15 -5
  497. package/docs/sdk.md +1 -1
  498. package/docs/settings.md +3 -2
  499. package/docs/themes.md +5 -3
  500. package/docs/tui.md +1 -1
  501. package/docs/usage.md +2 -2
  502. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  503. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  504. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  505. package/examples/extensions/preset.ts +2 -2
  506. package/examples/extensions/reload-runtime.ts +2 -2
  507. package/examples/extensions/sandbox/package-lock.json +2 -2
  508. package/examples/extensions/sandbox/package.json +1 -1
  509. package/examples/extensions/with-deps/package-lock.json +2 -2
  510. package/examples/extensions/with-deps/package.json +1 -1
  511. package/examples/sdk/README.md +1 -1
  512. package/hooks/gsd/draht-post-task.js +1 -1
  513. package/hooks/gsd/draht-quality-gate.js +1 -1
  514. package/package.json +10 -8
  515. package/prompts/agents/build.md +38 -0
  516. package/prompts/agents/plan.md +36 -0
  517. package/prompts/agents/verify.md +36 -4
  518. package/prompts/commands/brainstorm.md +16 -2
  519. package/prompts/commands/discuss-phase.md +1 -1
  520. package/prompts/commands/execute-phase.md +16 -3
  521. package/prompts/commands/fix.md +13 -1
  522. package/prompts/commands/init-project.md +1 -0
  523. package/prompts/commands/map-codebase.md +9 -9
  524. package/prompts/commands/new-project.md +1 -0
  525. package/prompts/commands/next-milestone.md +3 -0
  526. package/prompts/commands/orchestrate-loop.md +99 -0
  527. package/prompts/commands/orchestrate.md +29 -6
  528. package/prompts/commands/pause-work.md +2 -1
  529. package/prompts/commands/plan-phase.md +6 -0
  530. package/prompts/commands/quick.md +6 -2
  531. package/prompts/commands/review.md +4 -1
  532. package/prompts/commands/verify-work.md +10 -8
@@ -30,22 +30,22 @@ Before analyzing, decompose codebase understanding into atomic reasoning units:
30
30
  - Note architectural concerns and patterns
31
31
 
32
32
  ## Steps
33
- 1. Run `draht-tools map-codebase $1`
33
+ 1. Run `draht-tools map-codebase $1` (graph artifacts are always whole-repo — see below)
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**:
35
+ 2a. Run `draht-tools map-graph` to produce the **living architecture map**. The graph always maps the whole repository from the git root, regardless of any directory argument — the tool enforces this deterministically; a directory argument only scopes the narrative analysis in step 3, not the graph itself.
36
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.
37
+ - `.planning/codebase/MAP.html` — interactive visualization with three tabs:
38
+ - **Graph** — the primary interactive force-directed knowledge graph: nodes colored by cluster and sized by degree; click a node for an inspector (file, symbols, importers, callers); search plus filters for layer / cluster / edge-confidence (EXTRACTED/INFERRED/AMBIGUOUS); legend; PNG/SVG export; double-click a cluster to expand/collapse it.
39
+ - **Architecture** — package containers in layer bands with cross-package dataflow arrows.
40
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).
41
+ Open `MAP.html` directly via `file://` — the data is embedded inline so it works fully offline — or run `draht-tools map-serve` for a live-reloading dev view (regenerates on every code-file save (docs/asset saves are ignored by design), via SSE).
42
42
  3. **Run parallel deep analysis via subagents:**
43
43
  Use the `subagent` tool in **parallel mode** with these tasks:
44
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
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."
46
46
 
47
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.
48
- 5. Create `.planning/DOMAIN.md` (if it doesn't exist) with:
48
+ 5. Create `.planning/DOMAIN.md` (if it doesn't exist). Everything in it is **inferred from code, not confirmed by the user** — mark uncertain context boundaries and ambiguous terms as `(inferred)` so later commands know to confirm rather than build on them. With:
49
49
  - `## Bounded Contexts` — one entry per discovered context with a brief description
50
50
  - `## Ubiquitous Language` — glossary of extracted domain terms
51
51
  - `## Context Map` — how bounded contexts relate (upstream/downstream, shared kernel, ACL)
@@ -61,7 +61,7 @@ Before analyzing, decompose codebase understanding into atomic reasoning units:
61
61
 
62
62
  ## Living map for agents
63
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.
64
+ The `MAP.json` produced in step 2a is the single source of truth for "what's in this codebase". It is always the **whole-repo** map — `map-graph` maps from the git root regardless of where it's invoked or what directory argument is passed:
65
+ - Subagents that need orientation should read `.planning/codebase/MAP.json` before walking the file tree, even when working from a subdirectory — they get the full map via the `graph-*` commands, not a scoped one.
66
66
  - It is regenerated every time `map-codebase`, `map-graph`, or `map-serve` runs, so it stays current with the code.
67
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.
@@ -70,5 +70,6 @@ Each step runs in its own session (`/new` between steps). Do NOT suggest `/next-
70
70
  - Follow threads based on answers
71
71
  - Use examples ("Like Stripe Checkout, or custom?")
72
72
  - Confirm, don't assume
73
+ - When the description names a solution ("an app with X"), ask what problem it solves — requirements record problems and outcomes; mechanisms stay candidates
73
74
  - 3-7 follow-up rounds typical
74
75
  - Stop when you have: problem, audience, MVP scope, constraints, success criteria
@@ -42,6 +42,7 @@ Before planning the next milestone, decompose progress into atomic reasoning uni
42
42
  2. Review completed work:
43
43
  - Scan `.planning/phases/` for all UAT reports (`*-UAT.md`) and summaries (`*-SUMMARY.md`)
44
44
  - Note what was built, what worked well, what had issues
45
+ - **Write the distilled lessons back**: append each durable lesson as a dated bullet to `.planning/STATE.md` under `## Lessons` (create the section before `## Blockers` if missing) — extraction that only informs this session evaporates; the `## Lessons` section is what future sessions reread
45
46
  3. Assess requirements:
46
47
  - Which v1 requirements are now satisfied?
47
48
  - Which v1 requirements remain?
@@ -62,5 +63,7 @@ Before planning the next milestone, decompose progress into atomic reasoning uni
62
63
 
63
64
  ## Rules
64
65
  - Always review what was actually built, not just what was planned
66
+ - Distinguish **verified-complete** (a UAT report shows observed passes) from **believed-complete** (someone said so) — only the former counts toward requirement satisfaction; the latter goes back on the list
65
67
  - Be honest about requirements that slipped or changed scope
66
68
  - Each phase goal must be testable — "user can X" not "implement Y"
69
+ - Order the new phases risk-first: the phase carrying the highest uncertainty × blast radius comes earliest, so a wrong bet invalidates the least downstream work
@@ -0,0 +1,99 @@
1
+ ---
2
+ description: "Run a verification-gated loop of fresh subagent iterations until a deterministic check passes"
3
+ argument-hint: "<goal with a measurable success criterion> [--max-iterations N]"
4
+ ---
5
+
6
+ # /orchestrate-loop
7
+
8
+ Run fresh-context worker iterations against a fixed goal until an independent check passes — or a hard stop fires. The loop closes on a deterministic check, never on an agent's claim of completion.
9
+
10
+ Goal: $ARGUMENTS
11
+
12
+ > **Tool note**: Use the `subagent` tool. Workers are `implementer` (or `debugger` for pure-diagnosis goals); the final gate is `spec-reviewer`. One worker per iteration — never parallel workers inside the loop.
13
+
14
+ ## When to Loop vs Orchestrate
15
+
16
+ | Situation | Command |
17
+ |---|---|
18
+ | Decomposition is known, sub-tasks dispatch once | `/orchestrate` |
19
+ | Phase plans exist in `.planning/phases/` | `/execute-phase` |
20
+ | Goal needs iteration until a measurable criterion holds | `/orchestrate-loop` |
21
+
22
+ Loops trade tokens for persistence: use one when the work is too large or too uncertain for a single pass AND success is checkable without human judgment.
23
+
24
+ ## The Loop Contract — no check, no loop
25
+
26
+ A loop is only as good as its check. Before iterating, establish all four:
27
+
28
+ 1. **GOAL** — one measurable end state, stated in one sentence.
29
+ 2. **CHECK** — a command that proves the goal, pass/fail by exit code (test suite, typecheck + lint, a script comparing against a known-good oracle). Prefer terse output: failures only.
30
+ 3. **STOP CONDITIONS** — check passes (verified independently), max iterations reached (default 10; `--max-iterations N` overrides), stall detected, or `STATUS: BLOCKED`.
31
+ 4. **CONSTRAINTS** — what no iteration may touch: existing tests and the check itself are immutable (weakening either to "make it pass" is a hard-stop violation), plus anything out of scope.
32
+
33
+ If no deterministic check can be derived from the goal, STOP and ask the user to define one (or fall back to `/orchestrate`). Never start a loop whose only stop signal is "looks done" — without a check, you become the verification loop and it never closes.
34
+
35
+ Write the contract to `.planning/loop/LOOP.md`:
36
+
37
+ ```markdown
38
+ # Loop: <slug>
39
+ Started: <date> | Max iterations: <N>
40
+
41
+ ## Goal
42
+ <one sentence>
43
+
44
+ ## Check
45
+ `<command>` — passes when <what the output proves>
46
+
47
+ ## Constraints
48
+ - <immutables and out-of-scope items>
49
+ ```
50
+
51
+ Create `.planning/loop/PROGRESS.md` alongside it (append-only iteration log).
52
+
53
+ ## Iteration Protocol
54
+
55
+ Each iteration dispatches ONE fresh worker whose prompt contains, in full (workers cannot see this conversation):
56
+
57
+ 1. The loop contract verbatim
58
+ 2. The last 3 entries of `PROGRESS.md` and the last 5 `git log --oneline` lines — the recoverable state
59
+ 3. The previous iteration's failure evidence, terse: the failing assertions or error lines, not full output
60
+ 4. Standing orders:
61
+ - **Startup ritual** — read the progress log, run the CHECK first, observe the current failure before changing anything
62
+ - **One increment** — the smallest change that moves the check toward passing; do not batch
63
+ - **Commit the increment** even if the check still fails — state must survive context death
64
+ - **Append one `PROGRESS.md` entry** — what changed / check result observed / suggested next step
65
+ - Never edit or delete tests or the check to make it pass; never claim completion without quoting check output
66
+
67
+ ## Independent Verification — the gate
68
+
69
+ After EVERY iteration, re-run the CHECK yourself and read exit code and output. Completion is decided by this re-run, never by the worker's report — worker claims are inputs, not verdicts.
70
+
71
+ - **Check passes** → dispatch `spec-reviewer` once over the full loop diff (contract vs everything changed since the loop started). Only a clean spec review ends the loop as DONE; concerns trigger one more targeted iteration.
72
+ - **Check fails** → extract the terse failure evidence and feed it into the next iteration's prompt as guidance.
73
+
74
+ ## Stall Detection
75
+
76
+ Stop early when the loop is running but not progressing:
77
+
78
+ - Two consecutive iterations with the identical failure signature, or
79
+ - An iteration that produced no commit
80
+
81
+ On stall, do not dispatch the same input again — change something: decompose the goal, add context the workers were missing, switch worker (`implementer` → `debugger`), consult `advisor` for a course correction, or surface to the user with the evidence so far.
82
+
83
+ ## Steps
84
+
85
+ 1. Parse `$ARGUMENTS` into GOAL and flags; derive the CHECK; refuse to loop without one
86
+ 2. Write `.planning/loop/LOOP.md` and `.planning/loop/PROGRESS.md`
87
+ 3. Iterate: dispatch worker → re-run CHECK yourself → branch (pass → gate, fail → next iteration, stall / max / BLOCKED → hard stop)
88
+ 4. On success: spec-review the full diff, then report — outcome first, check output quoted, iterations used
89
+ 5. On any hard stop: append a handoff entry to `PROGRESS.md` (state observed, failure evidence, recommended next step) and report with observed / derived / assumed labels
90
+ 6. Leave `.planning/loop/` in place as the loop's record
91
+
92
+ ## Rules
93
+
94
+ - One worker, one increment, at least one commit per iteration
95
+ - Loops are volume work — run workers on the executor tier and keep steering (this context, `advisor`, `spec-reviewer`) on the strongest tier
96
+ - The worker never grades its own work — your re-run of the check plus a fresh-context spec review decide completion
97
+ - Never raise max iterations mid-loop without asking the user
98
+ - Tests and the check are immutable inside the loop; tampering means revert and hard stop
99
+ - Evidence discipline applies to the loop verdict: label results observed / derived / assumed
@@ -9,15 +9,15 @@ 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`, `spec-reviewer`, `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`, `advisor`. Use `tasks: [...]` for parallel dispatch and `chain: [...]` for sequential pipelines.
13
13
 
14
14
  ## Atomic Reasoning
15
15
 
16
16
  Before delegating, decompose the task into atomic work units:
17
17
 
18
- 1. **State the logical components** — What sub-tasks make up this work? Which are independent?
18
+ 1. **State the logical components** — What sub-tasks make up this work? Which are independent? A sub-task is well-cut only if its success can be checked without reference to the others.
19
19
  2. **Match agents to work** — Which specialist is right for each sub-task?
20
- 3. **Determine order** — What can run in parallel vs what must be sequential?
20
+ 3. **Determine order** — What can run in parallel vs what must be sequential? Among independent sub-tasks, dispatch the riskiest first (highest uncertainty × blast radius): its failure invalidates the rest of the graph most cheaply, before effort is sunk into work it would obsolete.
21
21
  4. **Define success** — What does "done" look like for each sub-task, and for the whole?
22
22
 
23
23
  ## Agent Selection Guide
@@ -32,9 +32,28 @@ Before delegating, decompose the task into atomic work units:
32
32
  | Audit for security issues | `security-auditor` |
33
33
  | Run lint / typecheck / tests | `verifier` |
34
34
  | Create atomic commits | `git-committer` |
35
+ | Strategic steer at a decision point — rare, high-leverage | `advisor` |
35
36
 
36
37
  `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
38
 
39
+ ## Effort Scaling
40
+
41
+ Match orchestration weight to the task — over-orchestration burns tokens without adding verification value:
42
+
43
+ | Task shape | Dispatch |
44
+ |---|---|
45
+ | Single question or trivial fix | One agent, or handle it directly — no orchestration |
46
+ | One change set to evaluate | 2–4 parallel evaluators (reviewer, security-auditor, verifier) |
47
+ | Multi-part feature with known decomposition | Fan-out / fan-in |
48
+ | Goal needing iteration until a measurable criterion holds | `/orchestrate-loop` |
49
+
50
+ ## Model Tiering
51
+
52
+ Bill volume tokens at the cheaper rate:
53
+
54
+ - **Orchestrator pattern** — run this command on the strongest tier (e.g. Claude Fable 5) and let workers execute on the executor tier (e.g. Claude Sonnet 5): planning quality where it matters, volume tokens at worker rates.
55
+ - **Advisor pattern** — when the session runs on the executor tier, dispatch `advisor` sparingly: once after orientation before committing to an approach, again when stuck or before declaring a hard task done. ~1–3 consults per task; treat its guidance with serious weight.
56
+
38
57
  ## Orchestration Modes
39
58
 
40
59
  ### Parallel
@@ -57,11 +76,14 @@ implementer → spec-reviewer → reviewer
57
76
 
58
77
  Never run quality review on a spec-non-compliant diff. This is the per-task loop inside `/execute-phase`.
59
78
 
79
+ ### Loop (iterate until a check passes)
80
+ When the work cannot land in one dispatch but success is provable by a deterministic check, do not improvise retries here — hand off to `/orchestrate-loop`. It runs fresh worker iterations gated by an independent re-run of the check, with max-iteration and stall bounds.
81
+
60
82
  ## Reading Subagent Status
61
83
 
62
84
  Every draht agent ends its response with one of four status lines. Branch on it:
63
85
 
64
- - `STATUS: DONE` — proceed to the next step in the chain.
86
+ - `STATUS: DONE` — check the evidence before proceeding: a `DONE` that quotes no verification output (test counts, command results) is treated as `DONE_WITH_CONCERNS` — re-run the decisive check yourself. Subagent claims are inputs, not verdicts.
65
87
  - `STATUS: DONE_WITH_CONCERNS` — note the concerns. If correctness-related, address before moving on; otherwise log and continue.
66
88
  - `STATUS: NEEDS_CONTEXT` — provide the missing info and re-dispatch the same agent. Do NOT skip ahead with a guess.
67
89
  - `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.
@@ -72,11 +94,12 @@ Every draht agent ends its response with one of four status lines. Branch on it:
72
94
  3. Decide parallel vs chain vs fan-out vs two-stage based on dependencies
73
95
  4. Dispatch via the `subagent` tool accordingly
74
96
  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
97
+ 6. Collect results, handle failures, report to the user — outcome first (what happened, in one line), evidence second (what each agent verified, quoted), risk last (what remains unverified or assumed)
76
98
 
77
99
  ## Rules
78
100
  - Prefer parallel dispatch when possible — it's faster and each subagent has its own context
79
- - Pass complete context to subagents — they cannot see the main conversation
101
+ - Every dispatch is a complete brief: objective, expected output format, tool guidance, and task boundaries — subagents cannot see the main conversation
80
102
  - Do not nest delegations deeply — one level is usually enough
81
103
  - Never retry the same agent on the same input after `BLOCKED` — change something
82
104
  - For any spec-driven work, spec-reviewer runs before quality reviewer
105
+ - The agent that produced work never evaluates it — completion verdicts come from a fresh-context evaluator plus your own re-run of the decisive check
@@ -26,4 +26,5 @@ Before pausing, decompose session state into atomic reasoning units:
26
26
 
27
27
  ## Steps
28
28
  1. Run `draht-tools pause` — creates CONTINUE-HERE.md
29
- 2. Commit: `draht-tools commit-docs "pause work"`
29
+ 2. **Distill lessons before the context is lost**: for anything this session tried that failed, or an approach that worked against expectations, append one dated bullet to `.planning/STATE.md` under `## Lessons` (create the section before `## Blockers` if missing). Lessons name what to do differently — "runner hits TLS issue in PowerShell, use bash", not "had problems with tests".
30
+ 3. Commit: `draht-tools commit-docs "pause work"`
@@ -23,6 +23,7 @@ A plan is only as good as the tasks inside it. STOP and revise instead of saving
23
23
  - A task takes more than ~5 minutes — break it down further
24
24
  - The plan introduces new domain terms that are NOT in `.planning/DOMAIN.md` — update DOMAIN.md first
25
25
  - A plan touches more than one bounded context without explicit ACL — split per context
26
+ - The first plan is scaffolding/boilerplate while an unproven risk (new integration, unfamiliar API, untested pattern) sits in a later plan — reorder so the risk is proven first
26
27
 
27
28
  Run `draht-tools validate-plans $1` after saving. Fix any issues it reports before commit.
28
29
 
@@ -35,14 +36,19 @@ Before creating plans, decompose this phase goal into atomic reasoning units:
35
36
  2. **Validate independence** — Which artifacts (files, endpoints, schemas) prove this truth exists? Can it be built independently?
36
37
  3. **Verify correctness** — What test scenarios would prove this observable truth? What are the specific inputs → expected outputs?
37
38
 
39
+ **Atomicity test:** a task is atomic only if its `<verify>` can fail while every other task passes. If two tasks can only be checked together, they are one task.
40
+
38
41
  **Synthesize planning strategy:**
39
42
  - Group related observable truths into cohesive plans (2-5 tasks each)
40
43
  - Identify which plans can be created in parallel vs sequentially
41
44
  - Map each plan to specific bounded contexts and domain concepts
42
45
  - Ensure each plan produces testable, verifiable outcomes
46
+ - **Order risk-first**: score each truth by uncertainty (has this codebase done it before?) × blast radius (how much becomes invalid if it's wrong?). The plan proving the highest-scoring truth executes first; boilerplate goes last. Boilerplate never invalidates a phase — the risky part regularly does.
47
+ - Write every assumption a plan rests on as an explicit `Assumes:` line (with how to confirm it) in the plan header. Unwritten assumptions become the executor's bugs.
43
48
 
44
49
  ## Steps
45
50
  1. Run `draht-tools load-phase-context $1` to gather all context
51
+ 1b. Read `.planning/STATE.md` `## Lessons` — every plan must respect the recorded lessons; a plan that repeats a documented failure is invalid. Feed relevant lessons into each architect prompt.
46
52
  2. Optional: `draht-tools research-phase $1` for domain research
47
53
  3. Goal-backward planning:
48
54
  a. State the goal (outcome, not activity)
@@ -13,6 +13,10 @@ Execute a small ad-hoc task with tracking.
13
13
 
14
14
  Task: $ARGUMENTS
15
15
 
16
+ ## "Small" Is a Claim, Not a Fact
17
+
18
+ Before planning, verify the task is actually quick: grep the blast radius (callers, imports, tests touching the target). If the change reaches further than the description implies, say so and recommend `/plan-phase`-level treatment instead of forcing it through. And if the description names a solution ("add a flag"), confirm the problem it solves — a smaller fix may exist. A "quick task" that silently grows is how untracked complexity enters a codebase.
19
+
16
20
  ## Atomic Reasoning
17
21
 
18
22
  Before executing, decompose this task into atomic reasoning units:
@@ -65,11 +69,11 @@ Before executing, decompose this task into atomic reasoning units:
65
69
  End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
66
70
  ```
67
71
  - `DONE` → go to Stage 3.
68
- - `BLOCKED` → re-dispatch implementer with Required Fixes. Repeat until `DONE`.
72
+ - `BLOCKED` → re-dispatch implementer with Required Fixes. Repeat until `DONE`. **Hard cap: 3 re-dispatches total** — at the cap, STOP and report the disagreement to the user.
69
73
 
70
74
  5. **Stage 3 — Reviewer (optional code-quality pass).** For non-trivial quick tasks (more than one file, or domain code), use the `subagent` tool with the `reviewer` agent. Otherwise skip.
71
75
  - `DONE` → task complete.
72
- - `BLOCKED` → re-dispatch implementer with Must-fix list.
76
+ - `BLOCKED` → re-dispatch implementer with Must-fix list — same **hard cap of 3 re-dispatches**; at the cap, STOP and report.
73
77
 
74
78
  6. Write summary: `draht-tools write-quick-summary NNN`
75
79
  7. Update state: `draht-tools update-state`
@@ -47,11 +47,14 @@ Before reviewing, decompose code changes into atomic reasoning units:
47
47
 
48
48
  5. Read each subagent's final `STATUS:` line.
49
49
  6. Collect and merge results.
50
- 7. Produce a unified, prioritized findings report:
50
+ 7. **Refute before reporting.** For each Critical or Important finding, attempt to kill it yourself before it reaches the report: read the code path that would make it a false positive — an upstream guard clause, a type constraint, an existing test that covers the case. A finding that survives an honest refutation attempt is **confirmed** (you traced the failing path); one you couldn't confirm is downgraded and labeled **suspected**. Reporting unattacked findings trains readers to ignore the report.
51
+ 8. Produce a unified, prioritized findings report. Verdict first: one line — mergeable or not, and why. Then findings:
51
52
  - **Critical** — must fix before merge (security `BLOCKED`, spec gaps for required deliverables, correctness issues that cause data loss / crashes)
52
53
  - **Important** — should fix (bugs, type issues, spec over-builds, missing error handling)
53
54
  - **Minor** — style, naming, optional improvements
54
55
 
56
+ Each finding carries its label (confirmed/suspected). End with residual risk: what the review did NOT cover (files skipped, paths not traced) — a review that claims total coverage it doesn't have is worse than a scoped one.
57
+
55
58
  ## Reading STATUS
56
59
  - Any `STATUS: BLOCKED` → its findings escalate to Critical in the merged report
57
60
  - `STATUS: NEEDS_CONTEXT` → provide missing info and re-dispatch that one agent
@@ -38,23 +38,25 @@ Before verifying, decompose phase acceptance into atomic reasoning units:
38
38
  - `reviewer` agent: "Review the recent code changes for this phase. Check domain language compliance against `.planning/DOMAIN.md` if it exists — scan for identifiers not in the glossary and cross-context boundary violations. Report Must fix / Should fix / Consider. End with `STATUS: ...`. Do NOT run draht, draht-tools, or pi commands."
39
39
  - `spec-reviewer` agent: "Phase-level spec compliance check for phase $1. The phase has these plan files (each is a spec): <list of .planning/phases/<N>-*/<N>-NN-PLAN.md paths>. For each plan, evaluate whether the phase's commits implement exactly what the plan's <task> elements asked — no missing tasks, no over-builds. Use git log and git diff against the phase commit range. Output a per-plan compliance verdict with omissions and over-builds. End with `STATUS: ...`."
40
40
 
41
- 4. **Read each subagent's `STATUS:` line.** Treat the phase as failed if any of these is `BLOCKED`:
41
+ 4. **Spot-check before aggregating.** Subagent claims are inputs, not verdicts. Before accepting the verifier's `DONE`, re-run the test suite headline yourself and read the counts. Before accepting the spec-reviewer's compliance verdict, read one plan's diff yourself. A pass you only heard about is an "assumed pass" — and an assumed pass is not a pass. This costs two commands and catches the most expensive failure mode this command has: trust laundered into evidence.
42
+
43
+ 5. **Read each subagent's `STATUS:` line.** Treat the phase as failed if any of these is `BLOCKED`:
42
44
  - `verifier` (tests / lint / typecheck failed)
43
45
  - `security-auditor` (Critical or High findings)
44
46
  - `spec-reviewer` (any plan non-compliant)
45
47
  - `reviewer` (Must-fix correctness issues)
46
48
 
47
- 5. Collect results and walk user through each deliverable, incorporating findings.
48
- 6. Record results (pass/fail/partially/skip).
49
- 7. For failures: diagnose and create fix plans via `draht-tools create-fix-plan $1 P`
49
+ 6. Collect results and walk user through each deliverable, incorporating findings.
50
+ 7. Record results (pass/fail/partially/skip). Label each: **observed** (you or a subagent ran it and quoted output), **derived** (follows necessarily from something observed), or **assumed** (unchecked). Verdicts inherit the weakest label they rest on.
51
+ 8. For failures: diagnose and create fix plans via `draht-tools create-fix-plan $1 P`
50
52
  - Fix plans MUST include a reproducing test that demonstrates the failure before any implementation
51
53
  - Spec-reviewer omissions become explicit fix-plan tasks (one task per omission)
52
- 8. Write UAT report: `draht-tools write-uat $1`
53
- - Report must include: test health summary (pass/fail/coverage), security audit results, **spec compliance summary per plan**, domain model status (any glossary violations), deliverable results
54
- 9. If all passed: mark phase complete.
54
+ 9. Write UAT report: `draht-tools write-uat $1`
55
+ - Order: **verdict first** (phase pass/fail, X/Y deliverables, in the first line), **evidence second** (test health summary with pass/fail/coverage, security audit results, spec compliance summary per plan, domain model status, deliverable results with labels), **risk last** (what was NOT tested and how it could bite). Never bury a failure under passes.
56
+ 10. If all passed: mark phase complete.
55
57
  - If more phases remain in the milestone: tell the user to start a new session and run `/discuss-phase N+1`.
56
58
  - If ALL phases in the milestone are complete: tell the user to start a new session and run `/next-milestone`.
57
- 10. If failures: route to `execute-phase $1 --gaps-only`
59
+ 11. If failures: route to `execute-phase $1 --gaps-only`
58
60
 
59
61
  ## Why a phase-level spec-reviewer
60
62
 
@@ -0,0 +1,92 @@
1
+ /**
2
+ * `draht rlm --input <path|glob|url> --query "..." [--max-cost <n>]` and
3
+ * `draht rlm replay <trajectory-id> [--verbose]` CLI subcommand.
4
+ *
5
+ * Follows the same "check args, return true/false" dispatch convention as
6
+ * `handlePackageCommand`/`handleConfigCommand` in `package-manager-cli.ts`:
7
+ * `handleRlmCommand` returns `false` (no output, no side effects) unless
8
+ * `args[0] === "rlm"`, letting `main()` fall through to the normal
9
+ * interactive/print-mode session for everything else.
10
+ *
11
+ * Loads `--input` via `@draht/rlm`'s `parseInputArg`/`loadInput` (a file
12
+ * path, glob pattern, `http(s)://` URL, or `knowledge:<client-slug>`
13
+ * reference -- see `packages/rlm/src/loaders.ts`), then runs a
14
+ * `createRouterBackedSession`-backed `RlmSession` to completion and prints
15
+ * the final answer. See
16
+ * .planning/phases/29-agent-cli-integration/29-01-PLAN.md, Architecture
17
+ * section 3.
18
+ *
19
+ * Note on `--query`: `CreateRouterBackedSessionOptions`/`RlmSessionOptions`
20
+ * have no dedicated "question" field -- the whole `prompt` string becomes
21
+ * the REPL's `context` variable (see `router-session.ts`). This phase's
22
+ * scope is input loaders + integration surfaces, not changes to the
23
+ * session/prompt internals (26-28), so `buildRlmPrompt` embeds `--query` as
24
+ * a clearly delimited header ahead of the loaded content instead of adding
25
+ * a new session-level parameter.
26
+ *
27
+ * Note on `--max-cost`: parsed and validated here, but
28
+ * `createRouterBackedSession` currently has no `maxTotalCostUsd`/
29
+ * `getAccumulatedCostUsd` passthrough (those are `RlmSessionOptions` fields
30
+ * that the router-backed factory doesn't yet wire up), so it isn't enforced
31
+ * against the run yet -- flagged as a follow-up rather than widening this
32
+ * plan's scope into `router-session.ts`.
33
+ *
34
+ * `draht rlm replay <trajectory-id>` (Phase 30, see
35
+ * .planning/phases/30-eval-observability-docs/30-01-PLAN.md, Architecture
36
+ * section 4) is a second mode of this same subcommand, dispatched on
37
+ * `args[0] === "replay"` before any of the `--input`/`--query` parsing
38
+ * above. It reads `.draht/rlm/<trajectory-id>.jsonl` via `@draht/rlm`'s
39
+ * `readTrajectory` and prints the recorded final answer straight from that
40
+ * log -- it never imports/constructs a `ModelRouter`, never calls
41
+ * `createRouterBackedSession`, and is not reachable through any code path
42
+ * that touches `RlmCliRuntimeOptions.router`. That's deliberate: replay
43
+ * must make zero network/LLM calls, and the strongest proof of that is
44
+ * that the router dependency simply isn't in this branch at all.
45
+ */
46
+ import { ModelRouter } from "@draht/router";
47
+ export interface RlmCliRuntimeOptions {
48
+ /**
49
+ * Injectable for tests: a fake object shaped like `ModelRouter`'s public
50
+ * API (`resolve`/`resolveModel`/`streamSimple`), cast to `ModelRouter` at
51
+ * the call site -- see `packages/rlm/test/router-session.test.ts`'s
52
+ * `FakeModelRouter` for the established pattern. No real network/API call
53
+ * happens when this is supplied. Defaults to a real `new ModelRouter()`.
54
+ */
55
+ router?: ModelRouter;
56
+ }
57
+ export interface ParsedRlmArgs {
58
+ /** Which of the subcommand's two modes these args parsed into. */
59
+ mode: "query" | "replay";
60
+ input?: string;
61
+ query?: string;
62
+ maxCost?: number;
63
+ /** Replay mode only: the `<trajectory-id>` positional argument. */
64
+ trajectoryId?: string;
65
+ /** Replay mode only: print each step's code/stdout/cost, not just the final answer. */
66
+ verbose?: boolean;
67
+ help: boolean;
68
+ invalidOption?: string;
69
+ invalidArgument?: string;
70
+ missingOptionValue?: string;
71
+ invalidMaxCost?: string;
72
+ }
73
+ /**
74
+ * Parses the `rlm` subcommand's arguments (everything after the leading
75
+ * `"rlm"` token). Mirrors `parsePackageCommand`'s style in
76
+ * `package-manager-cli.ts`: collects the first problem of each kind rather
77
+ * than throwing, so `handleRlmCommand` can report one clear error.
78
+ *
79
+ * Dispatches to `parseRlmReplayArgs` when the first token is literally
80
+ * `"replay"`, before any of the `--input`/`--query` parsing below runs --
81
+ * see the module docstring's note on why replay's zero-LLM-calls guarantee
82
+ * depends on this branch happening first.
83
+ */
84
+ export declare function parseRlmArgs(args: string[]): ParsedRlmArgs;
85
+ /**
86
+ * Handles the `draht rlm ...` subcommand. Returns `false` immediately (no
87
+ * side effects) if `args[0]` isn't `"rlm"`; otherwise always returns `true`
88
+ * after setting `process.exitCode` to reflect success/failure, matching
89
+ * `handlePackageCommand`'s contract so `main.ts` can dispatch identically.
90
+ */
91
+ export declare function handleRlmCommand(args: string[], runtimeOptions?: RlmCliRuntimeOptions): Promise<boolean>;
92
+ //# sourceMappingURL=rlm-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rlm-cli.d.ts","sourceRoot":"","sources":["../src/rlm-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,WAAW,oBAAoB;IACpC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC7B,kEAAkE;IAClE,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAwFD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,aAAa,CA+E1D;AAwFD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,cAAc,GAAE,oBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC,CA+FlH"}