@draht/coding-agent 2026.3.2-2

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 (639) hide show
  1. package/CHANGELOG.md +2866 -0
  2. package/README.md +566 -0
  3. package/bin/draht-tools.cjs +912 -0
  4. package/dist/cli/args.d.ts +48 -0
  5. package/dist/cli/args.d.ts.map +1 -0
  6. package/dist/cli/args.js +298 -0
  7. package/dist/cli/args.js.map +1 -0
  8. package/dist/cli/config-selector.d.ts +14 -0
  9. package/dist/cli/config-selector.d.ts.map +1 -0
  10. package/dist/cli/config-selector.js +31 -0
  11. package/dist/cli/config-selector.js.map +1 -0
  12. package/dist/cli/file-processor.d.ts +15 -0
  13. package/dist/cli/file-processor.d.ts.map +1 -0
  14. package/dist/cli/file-processor.js +79 -0
  15. package/dist/cli/file-processor.js.map +1 -0
  16. package/dist/cli/list-models.d.ts +9 -0
  17. package/dist/cli/list-models.d.ts.map +1 -0
  18. package/dist/cli/list-models.js +92 -0
  19. package/dist/cli/list-models.js.map +1 -0
  20. package/dist/cli/session-picker.d.ts +9 -0
  21. package/dist/cli/session-picker.d.ts.map +1 -0
  22. package/dist/cli/session-picker.js +34 -0
  23. package/dist/cli/session-picker.js.map +1 -0
  24. package/dist/cli.d.ts +3 -0
  25. package/dist/cli.d.ts.map +1 -0
  26. package/dist/cli.js +11 -0
  27. package/dist/cli.js.map +1 -0
  28. package/dist/config.d.ts +85 -0
  29. package/dist/config.d.ts.map +1 -0
  30. package/dist/config.js +235 -0
  31. package/dist/config.js.map +1 -0
  32. package/dist/core/agent-session.d.ts +571 -0
  33. package/dist/core/agent-session.d.ts.map +1 -0
  34. package/dist/core/agent-session.js +2343 -0
  35. package/dist/core/agent-session.js.map +1 -0
  36. package/dist/core/auth-storage.d.ts +129 -0
  37. package/dist/core/auth-storage.d.ts.map +1 -0
  38. package/dist/core/auth-storage.js +394 -0
  39. package/dist/core/auth-storage.js.map +1 -0
  40. package/dist/core/bash-executor.d.ts +47 -0
  41. package/dist/core/bash-executor.d.ts.map +1 -0
  42. package/dist/core/bash-executor.js +212 -0
  43. package/dist/core/bash-executor.js.map +1 -0
  44. package/dist/core/compaction/branch-summarization.d.ts +86 -0
  45. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  46. package/dist/core/compaction/branch-summarization.js +242 -0
  47. package/dist/core/compaction/branch-summarization.js.map +1 -0
  48. package/dist/core/compaction/compaction.d.ts +121 -0
  49. package/dist/core/compaction/compaction.d.ts.map +1 -0
  50. package/dist/core/compaction/compaction.js +607 -0
  51. package/dist/core/compaction/compaction.js.map +1 -0
  52. package/dist/core/compaction/index.d.ts +7 -0
  53. package/dist/core/compaction/index.d.ts.map +1 -0
  54. package/dist/core/compaction/index.js +7 -0
  55. package/dist/core/compaction/index.js.map +1 -0
  56. package/dist/core/compaction/utils.d.ts +35 -0
  57. package/dist/core/compaction/utils.d.ts.map +1 -0
  58. package/dist/core/compaction/utils.js +138 -0
  59. package/dist/core/compaction/utils.js.map +1 -0
  60. package/dist/core/defaults.d.ts +3 -0
  61. package/dist/core/defaults.d.ts.map +1 -0
  62. package/dist/core/defaults.js +2 -0
  63. package/dist/core/defaults.js.map +1 -0
  64. package/dist/core/diagnostics.d.ts +15 -0
  65. package/dist/core/diagnostics.d.ts.map +1 -0
  66. package/dist/core/diagnostics.js +2 -0
  67. package/dist/core/diagnostics.js.map +1 -0
  68. package/dist/core/event-bus.d.ts +9 -0
  69. package/dist/core/event-bus.d.ts.map +1 -0
  70. package/dist/core/event-bus.js +25 -0
  71. package/dist/core/event-bus.js.map +1 -0
  72. package/dist/core/exec.d.ts +29 -0
  73. package/dist/core/exec.d.ts.map +1 -0
  74. package/dist/core/exec.js +71 -0
  75. package/dist/core/exec.js.map +1 -0
  76. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  77. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  78. package/dist/core/export-html/ansi-to-html.js +249 -0
  79. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  80. package/dist/core/export-html/index.d.ts +34 -0
  81. package/dist/core/export-html/index.d.ts.map +1 -0
  82. package/dist/core/export-html/index.js +222 -0
  83. package/dist/core/export-html/index.js.map +1 -0
  84. package/dist/core/export-html/template.css +971 -0
  85. package/dist/core/export-html/template.html +54 -0
  86. package/dist/core/export-html/template.js +1586 -0
  87. package/dist/core/export-html/tool-renderer.d.ts +35 -0
  88. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  89. package/dist/core/export-html/tool-renderer.js +57 -0
  90. package/dist/core/export-html/tool-renderer.js.map +1 -0
  91. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  92. package/dist/core/export-html/vendor/marked.min.js +6 -0
  93. package/dist/core/extensions/index.d.ts +11 -0
  94. package/dist/core/extensions/index.d.ts.map +1 -0
  95. package/dist/core/extensions/index.js +9 -0
  96. package/dist/core/extensions/index.js.map +1 -0
  97. package/dist/core/extensions/loader.d.ts +25 -0
  98. package/dist/core/extensions/loader.d.ts.map +1 -0
  99. package/dist/core/extensions/loader.js +415 -0
  100. package/dist/core/extensions/loader.js.map +1 -0
  101. package/dist/core/extensions/runner.d.ts +146 -0
  102. package/dist/core/extensions/runner.d.ts.map +1 -0
  103. package/dist/core/extensions/runner.js +645 -0
  104. package/dist/core/extensions/runner.js.map +1 -0
  105. package/dist/core/extensions/types.d.ts +1011 -0
  106. package/dist/core/extensions/types.d.ts.map +1 -0
  107. package/dist/core/extensions/types.js +35 -0
  108. package/dist/core/extensions/types.js.map +1 -0
  109. package/dist/core/extensions/wrapper.d.ts +27 -0
  110. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  111. package/dist/core/extensions/wrapper.js +102 -0
  112. package/dist/core/extensions/wrapper.js.map +1 -0
  113. package/dist/core/footer-data-provider.d.ts +32 -0
  114. package/dist/core/footer-data-provider.d.ts.map +1 -0
  115. package/dist/core/footer-data-provider.js +134 -0
  116. package/dist/core/footer-data-provider.js.map +1 -0
  117. package/dist/core/index.d.ts +9 -0
  118. package/dist/core/index.d.ts.map +1 -0
  119. package/dist/core/index.js +9 -0
  120. package/dist/core/index.js.map +1 -0
  121. package/dist/core/keybindings.d.ts +55 -0
  122. package/dist/core/keybindings.d.ts.map +1 -0
  123. package/dist/core/keybindings.js +153 -0
  124. package/dist/core/keybindings.js.map +1 -0
  125. package/dist/core/messages.d.ts +77 -0
  126. package/dist/core/messages.d.ts.map +1 -0
  127. package/dist/core/messages.js +123 -0
  128. package/dist/core/messages.js.map +1 -0
  129. package/dist/core/model-registry.d.ts +112 -0
  130. package/dist/core/model-registry.d.ts.map +1 -0
  131. package/dist/core/model-registry.js +534 -0
  132. package/dist/core/model-registry.js.map +1 -0
  133. package/dist/core/model-resolver.d.ts +104 -0
  134. package/dist/core/model-resolver.d.ts.map +1 -0
  135. package/dist/core/model-resolver.js +432 -0
  136. package/dist/core/model-resolver.js.map +1 -0
  137. package/dist/core/package-manager.d.ts +151 -0
  138. package/dist/core/package-manager.d.ts.map +1 -0
  139. package/dist/core/package-manager.js +1447 -0
  140. package/dist/core/package-manager.js.map +1 -0
  141. package/dist/core/prompt-templates.d.ts +50 -0
  142. package/dist/core/prompt-templates.d.ts.map +1 -0
  143. package/dist/core/prompt-templates.js +268 -0
  144. package/dist/core/prompt-templates.js.map +1 -0
  145. package/dist/core/resolve-config-value.d.ts +17 -0
  146. package/dist/core/resolve-config-value.d.ts.map +1 -0
  147. package/dist/core/resolve-config-value.js +59 -0
  148. package/dist/core/resolve-config-value.js.map +1 -0
  149. package/dist/core/resource-loader.d.ts +184 -0
  150. package/dist/core/resource-loader.d.ts.map +1 -0
  151. package/dist/core/resource-loader.js +670 -0
  152. package/dist/core/resource-loader.js.map +1 -0
  153. package/dist/core/sdk.d.ts +90 -0
  154. package/dist/core/sdk.d.ts.map +1 -0
  155. package/dist/core/sdk.js +235 -0
  156. package/dist/core/sdk.js.map +1 -0
  157. package/dist/core/session-manager.d.ts +323 -0
  158. package/dist/core/session-manager.d.ts.map +1 -0
  159. package/dist/core/session-manager.js +1098 -0
  160. package/dist/core/session-manager.js.map +1 -0
  161. package/dist/core/settings-manager.d.ts +225 -0
  162. package/dist/core/settings-manager.d.ts.map +1 -0
  163. package/dist/core/settings-manager.js +653 -0
  164. package/dist/core/settings-manager.js.map +1 -0
  165. package/dist/core/skills.d.ts +58 -0
  166. package/dist/core/skills.d.ts.map +1 -0
  167. package/dist/core/skills.js +364 -0
  168. package/dist/core/skills.js.map +1 -0
  169. package/dist/core/slash-commands.d.ts +15 -0
  170. package/dist/core/slash-commands.d.ts.map +1 -0
  171. package/dist/core/slash-commands.js +22 -0
  172. package/dist/core/slash-commands.js.map +1 -0
  173. package/dist/core/system-prompt.d.ts +24 -0
  174. package/dist/core/system-prompt.d.ts.map +1 -0
  175. package/dist/core/system-prompt.js +137 -0
  176. package/dist/core/system-prompt.js.map +1 -0
  177. package/dist/core/timings.d.ts +7 -0
  178. package/dist/core/timings.d.ts.map +1 -0
  179. package/dist/core/timings.js +25 -0
  180. package/dist/core/timings.js.map +1 -0
  181. package/dist/core/tools/bash.d.ts +55 -0
  182. package/dist/core/tools/bash.d.ts.map +1 -0
  183. package/dist/core/tools/bash.js +242 -0
  184. package/dist/core/tools/bash.js.map +1 -0
  185. package/dist/core/tools/edit-diff.d.ts +63 -0
  186. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  187. package/dist/core/tools/edit-diff.js +243 -0
  188. package/dist/core/tools/edit-diff.js.map +1 -0
  189. package/dist/core/tools/edit.d.ts +39 -0
  190. package/dist/core/tools/edit.d.ts.map +1 -0
  191. package/dist/core/tools/edit.js +146 -0
  192. package/dist/core/tools/edit.js.map +1 -0
  193. package/dist/core/tools/find.d.ts +39 -0
  194. package/dist/core/tools/find.d.ts.map +1 -0
  195. package/dist/core/tools/find.js +206 -0
  196. package/dist/core/tools/find.js.map +1 -0
  197. package/dist/core/tools/grep.d.ts +45 -0
  198. package/dist/core/tools/grep.d.ts.map +1 -0
  199. package/dist/core/tools/grep.js +239 -0
  200. package/dist/core/tools/grep.js.map +1 -0
  201. package/dist/core/tools/index.d.ts +73 -0
  202. package/dist/core/tools/index.d.ts.map +1 -0
  203. package/dist/core/tools/index.js +61 -0
  204. package/dist/core/tools/index.js.map +1 -0
  205. package/dist/core/tools/ls.d.ts +40 -0
  206. package/dist/core/tools/ls.d.ts.map +1 -0
  207. package/dist/core/tools/ls.js +118 -0
  208. package/dist/core/tools/ls.js.map +1 -0
  209. package/dist/core/tools/path-utils.d.ts +8 -0
  210. package/dist/core/tools/path-utils.d.ts.map +1 -0
  211. package/dist/core/tools/path-utils.js +81 -0
  212. package/dist/core/tools/path-utils.js.map +1 -0
  213. package/dist/core/tools/read.d.ts +39 -0
  214. package/dist/core/tools/read.d.ts.map +1 -0
  215. package/dist/core/tools/read.js +166 -0
  216. package/dist/core/tools/read.js.map +1 -0
  217. package/dist/core/tools/truncate.d.ts +70 -0
  218. package/dist/core/tools/truncate.d.ts.map +1 -0
  219. package/dist/core/tools/truncate.js +205 -0
  220. package/dist/core/tools/truncate.js.map +1 -0
  221. package/dist/core/tools/write.d.ts +29 -0
  222. package/dist/core/tools/write.d.ts.map +1 -0
  223. package/dist/core/tools/write.js +78 -0
  224. package/dist/core/tools/write.js.map +1 -0
  225. package/dist/extensions/gsd-commands.ts +338 -0
  226. package/dist/extensions/subagent.ts +312 -0
  227. package/dist/hooks/gsd/draht-post-phase.js +133 -0
  228. package/dist/hooks/gsd/draht-post-task.js +132 -0
  229. package/dist/hooks/gsd/draht-pre-execute.js +146 -0
  230. package/dist/hooks/gsd/draht-quality-gate.js +210 -0
  231. package/dist/index.d.ts +27 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +42 -0
  234. package/dist/index.js.map +1 -0
  235. package/dist/main.d.ts +8 -0
  236. package/dist/main.d.ts.map +1 -0
  237. package/dist/main.js +812 -0
  238. package/dist/main.js.map +1 -0
  239. package/dist/migrations.d.ts +33 -0
  240. package/dist/migrations.d.ts.map +1 -0
  241. package/dist/migrations.js +261 -0
  242. package/dist/migrations.js.map +1 -0
  243. package/dist/modes/index.d.ts +9 -0
  244. package/dist/modes/index.d.ts.map +1 -0
  245. package/dist/modes/index.js +8 -0
  246. package/dist/modes/index.js.map +1 -0
  247. package/dist/modes/interactive/components/armin.d.ts +34 -0
  248. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  249. package/dist/modes/interactive/components/armin.js +333 -0
  250. package/dist/modes/interactive/components/armin.js.map +1 -0
  251. package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
  252. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  253. package/dist/modes/interactive/components/assistant-message.js +96 -0
  254. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  255. package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
  256. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  257. package/dist/modes/interactive/components/bash-execution.js +162 -0
  258. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  259. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  260. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  261. package/dist/modes/interactive/components/bordered-loader.js +51 -0
  262. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  263. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  264. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  265. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  266. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  267. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  268. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  269. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  270. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  271. package/dist/modes/interactive/components/config-selector.d.ts +71 -0
  272. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  273. package/dist/modes/interactive/components/config-selector.js +479 -0
  274. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  275. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  276. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  277. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  278. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  279. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  280. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  281. package/dist/modes/interactive/components/custom-editor.js +70 -0
  282. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  283. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  284. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  285. package/dist/modes/interactive/components/custom-message.js +79 -0
  286. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  287. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  288. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  289. package/dist/modes/interactive/components/daxnuts.js +140 -0
  290. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  291. package/dist/modes/interactive/components/diff.d.ts +12 -0
  292. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  293. package/dist/modes/interactive/components/diff.js +133 -0
  294. package/dist/modes/interactive/components/diff.js.map +1 -0
  295. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  296. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  297. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  298. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  299. package/dist/modes/interactive/components/extension-editor.d.ts +17 -0
  300. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  301. package/dist/modes/interactive/components/extension-editor.js +102 -0
  302. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  303. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  304. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  305. package/dist/modes/interactive/components/extension-input.js +61 -0
  306. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  307. package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
  308. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  309. package/dist/modes/interactive/components/extension-selector.js +78 -0
  310. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  311. package/dist/modes/interactive/components/footer.d.ts +26 -0
  312. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  313. package/dist/modes/interactive/components/footer.js +213 -0
  314. package/dist/modes/interactive/components/footer.js.map +1 -0
  315. package/dist/modes/interactive/components/index.d.ts +32 -0
  316. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  317. package/dist/modes/interactive/components/index.js +33 -0
  318. package/dist/modes/interactive/components/index.js.map +1 -0
  319. package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
  320. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  321. package/dist/modes/interactive/components/keybinding-hints.js +61 -0
  322. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  323. package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
  324. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  325. package/dist/modes/interactive/components/login-dialog.js +145 -0
  326. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  327. package/dist/modes/interactive/components/model-selector.d.ts +47 -0
  328. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  329. package/dist/modes/interactive/components/model-selector.js +271 -0
  330. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  331. package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
  332. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  333. package/dist/modes/interactive/components/oauth-selector.js +97 -0
  334. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  335. package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
  336. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  337. package/dist/modes/interactive/components/scoped-models-selector.js +275 -0
  338. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  339. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  340. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  341. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  342. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  343. package/dist/modes/interactive/components/session-selector.d.ts +95 -0
  344. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  345. package/dist/modes/interactive/components/session-selector.js +851 -0
  346. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  347. package/dist/modes/interactive/components/settings-selector.d.ts +56 -0
  348. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  349. package/dist/modes/interactive/components/settings-selector.js +287 -0
  350. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  351. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  352. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  353. package/dist/modes/interactive/components/show-images-selector.js +35 -0
  354. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  355. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  356. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  357. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  358. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  359. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  360. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  361. package/dist/modes/interactive/components/theme-selector.js +46 -0
  362. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  363. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  364. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  365. package/dist/modes/interactive/components/thinking-selector.js +47 -0
  366. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  367. package/dist/modes/interactive/components/tool-execution.d.ts +75 -0
  368. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  369. package/dist/modes/interactive/components/tool-execution.js +752 -0
  370. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  371. package/dist/modes/interactive/components/tree-selector.d.ts +68 -0
  372. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  373. package/dist/modes/interactive/components/tree-selector.js +934 -0
  374. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  375. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  376. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  377. package/dist/modes/interactive/components/user-message-selector.js +113 -0
  378. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  379. package/dist/modes/interactive/components/user-message.d.ts +8 -0
  380. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  381. package/dist/modes/interactive/components/user-message.js +16 -0
  382. package/dist/modes/interactive/components/user-message.js.map +1 -0
  383. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  384. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  385. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  386. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  387. package/dist/modes/interactive/interactive-mode.d.ts +315 -0
  388. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  389. package/dist/modes/interactive/interactive-mode.js +3719 -0
  390. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  391. package/dist/modes/interactive/theme/dark.json +85 -0
  392. package/dist/modes/interactive/theme/light.json +84 -0
  393. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  394. package/dist/modes/interactive/theme/theme.d.ts +78 -0
  395. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  396. package/dist/modes/interactive/theme/theme.js +944 -0
  397. package/dist/modes/interactive/theme/theme.js.map +1 -0
  398. package/dist/modes/print-mode.d.ts +28 -0
  399. package/dist/modes/print-mode.d.ts.map +1 -0
  400. package/dist/modes/print-mode.js +101 -0
  401. package/dist/modes/print-mode.js.map +1 -0
  402. package/dist/modes/rpc/rpc-client.d.ts +217 -0
  403. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  404. package/dist/modes/rpc/rpc-client.js +405 -0
  405. package/dist/modes/rpc/rpc-client.js.map +1 -0
  406. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  407. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  408. package/dist/modes/rpc/rpc-mode.js +511 -0
  409. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  410. package/dist/modes/rpc/rpc-types.d.ts +409 -0
  411. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  412. package/dist/modes/rpc/rpc-types.js +8 -0
  413. package/dist/modes/rpc/rpc-types.js.map +1 -0
  414. package/dist/prompts/agents/build.md +44 -0
  415. package/dist/prompts/agents/plan.md +39 -0
  416. package/dist/prompts/agents/verify.md +33 -0
  417. package/dist/prompts/commands/atomic-commit.md +39 -0
  418. package/dist/prompts/commands/discuss-phase.md +25 -0
  419. package/dist/prompts/commands/execute-phase.md +59 -0
  420. package/dist/prompts/commands/map-codebase.md +32 -0
  421. package/dist/prompts/commands/new-project.md +40 -0
  422. package/dist/prompts/commands/pause-work.md +12 -0
  423. package/dist/prompts/commands/plan-phase.md +61 -0
  424. package/dist/prompts/commands/progress.md +12 -0
  425. package/dist/prompts/commands/quick.md +19 -0
  426. package/dist/prompts/commands/resume-work.md +13 -0
  427. package/dist/prompts/commands/verify-work.md +27 -0
  428. package/dist/utils/changelog.d.ts +21 -0
  429. package/dist/utils/changelog.d.ts.map +1 -0
  430. package/dist/utils/changelog.js +87 -0
  431. package/dist/utils/changelog.js.map +1 -0
  432. package/dist/utils/clipboard-image.d.ts +11 -0
  433. package/dist/utils/clipboard-image.d.ts.map +1 -0
  434. package/dist/utils/clipboard-image.js +162 -0
  435. package/dist/utils/clipboard-image.js.map +1 -0
  436. package/dist/utils/clipboard-native.d.ts +7 -0
  437. package/dist/utils/clipboard-native.d.ts.map +1 -0
  438. package/dist/utils/clipboard-native.js +14 -0
  439. package/dist/utils/clipboard-native.js.map +1 -0
  440. package/dist/utils/clipboard.d.ts +2 -0
  441. package/dist/utils/clipboard.d.ts.map +1 -0
  442. package/dist/utils/clipboard.js +67 -0
  443. package/dist/utils/clipboard.js.map +1 -0
  444. package/dist/utils/frontmatter.d.ts +8 -0
  445. package/dist/utils/frontmatter.d.ts.map +1 -0
  446. package/dist/utils/frontmatter.js +26 -0
  447. package/dist/utils/frontmatter.js.map +1 -0
  448. package/dist/utils/git.d.ts +26 -0
  449. package/dist/utils/git.d.ts.map +1 -0
  450. package/dist/utils/git.js +163 -0
  451. package/dist/utils/git.js.map +1 -0
  452. package/dist/utils/image-convert.d.ts +9 -0
  453. package/dist/utils/image-convert.d.ts.map +1 -0
  454. package/dist/utils/image-convert.js +35 -0
  455. package/dist/utils/image-convert.js.map +1 -0
  456. package/dist/utils/image-resize.d.ts +36 -0
  457. package/dist/utils/image-resize.d.ts.map +1 -0
  458. package/dist/utils/image-resize.js +181 -0
  459. package/dist/utils/image-resize.js.map +1 -0
  460. package/dist/utils/mime.d.ts +2 -0
  461. package/dist/utils/mime.d.ts.map +1 -0
  462. package/dist/utils/mime.js +26 -0
  463. package/dist/utils/mime.js.map +1 -0
  464. package/dist/utils/photon.d.ts +21 -0
  465. package/dist/utils/photon.d.ts.map +1 -0
  466. package/dist/utils/photon.js +121 -0
  467. package/dist/utils/photon.js.map +1 -0
  468. package/dist/utils/shell.d.ts +26 -0
  469. package/dist/utils/shell.d.ts.map +1 -0
  470. package/dist/utils/shell.js +186 -0
  471. package/dist/utils/shell.js.map +1 -0
  472. package/dist/utils/sleep.d.ts +5 -0
  473. package/dist/utils/sleep.d.ts.map +1 -0
  474. package/dist/utils/sleep.js +17 -0
  475. package/dist/utils/sleep.js.map +1 -0
  476. package/dist/utils/tools-manager.d.ts +3 -0
  477. package/dist/utils/tools-manager.d.ts.map +1 -0
  478. package/dist/utils/tools-manager.js +251 -0
  479. package/dist/utils/tools-manager.js.map +1 -0
  480. package/docs/compaction.md +390 -0
  481. package/docs/custom-provider.md +580 -0
  482. package/docs/development.md +69 -0
  483. package/docs/extensions.md +1952 -0
  484. package/docs/images/doom-extension.png +0 -0
  485. package/docs/images/exy.png +0 -0
  486. package/docs/images/interactive-mode.png +0 -0
  487. package/docs/images/tree-view.png +0 -0
  488. package/docs/json.md +79 -0
  489. package/docs/keybindings.md +174 -0
  490. package/docs/models.md +293 -0
  491. package/docs/packages.md +209 -0
  492. package/docs/prompt-templates.md +67 -0
  493. package/docs/providers.md +186 -0
  494. package/docs/rpc.md +1317 -0
  495. package/docs/sdk.md +968 -0
  496. package/docs/session.md +412 -0
  497. package/docs/settings.md +223 -0
  498. package/docs/shell-aliases.md +13 -0
  499. package/docs/skills.md +231 -0
  500. package/docs/terminal-setup.md +70 -0
  501. package/docs/termux.md +127 -0
  502. package/docs/themes.md +295 -0
  503. package/docs/tree.md +219 -0
  504. package/docs/tui.md +887 -0
  505. package/docs/windows.md +17 -0
  506. package/examples/README.md +25 -0
  507. package/examples/extensions/README.md +204 -0
  508. package/examples/extensions/antigravity-image-gen.ts +413 -0
  509. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  510. package/examples/extensions/bash-spawn-hook.ts +30 -0
  511. package/examples/extensions/bookmark.ts +50 -0
  512. package/examples/extensions/built-in-tool-renderer.ts +246 -0
  513. package/examples/extensions/claude-rules.ts +86 -0
  514. package/examples/extensions/commands.ts +72 -0
  515. package/examples/extensions/confirm-destructive.ts +59 -0
  516. package/examples/extensions/custom-compaction.ts +114 -0
  517. package/examples/extensions/custom-footer.ts +64 -0
  518. package/examples/extensions/custom-header.ts +73 -0
  519. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  520. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  521. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  522. package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
  523. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  524. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  525. package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
  526. package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
  527. package/examples/extensions/dirty-repo-guard.ts +56 -0
  528. package/examples/extensions/doom-overlay/README.md +46 -0
  529. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  530. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  531. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  532. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  533. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  534. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  535. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  536. package/examples/extensions/doom-overlay/index.ts +74 -0
  537. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  538. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  539. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  540. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  541. package/examples/extensions/dynamic-resources/index.ts +15 -0
  542. package/examples/extensions/event-bus.ts +43 -0
  543. package/examples/extensions/file-trigger.ts +41 -0
  544. package/examples/extensions/git-checkpoint.ts +53 -0
  545. package/examples/extensions/handoff.ts +150 -0
  546. package/examples/extensions/hello.ts +25 -0
  547. package/examples/extensions/inline-bash.ts +94 -0
  548. package/examples/extensions/input-transform.ts +43 -0
  549. package/examples/extensions/interactive-shell.ts +196 -0
  550. package/examples/extensions/mac-system-theme.ts +47 -0
  551. package/examples/extensions/message-renderer.ts +59 -0
  552. package/examples/extensions/minimal-mode.ts +426 -0
  553. package/examples/extensions/modal-editor.ts +85 -0
  554. package/examples/extensions/model-status.ts +31 -0
  555. package/examples/extensions/notify.ts +55 -0
  556. package/examples/extensions/overlay-qa-tests.ts +881 -0
  557. package/examples/extensions/overlay-test.ts +150 -0
  558. package/examples/extensions/permission-gate.ts +34 -0
  559. package/examples/extensions/pirate.ts +47 -0
  560. package/examples/extensions/plan-mode/README.md +65 -0
  561. package/examples/extensions/plan-mode/index.ts +340 -0
  562. package/examples/extensions/plan-mode/utils.ts +168 -0
  563. package/examples/extensions/preset.ts +398 -0
  564. package/examples/extensions/protected-paths.ts +30 -0
  565. package/examples/extensions/qna.ts +119 -0
  566. package/examples/extensions/question.ts +264 -0
  567. package/examples/extensions/questionnaire.ts +427 -0
  568. package/examples/extensions/rainbow-editor.ts +88 -0
  569. package/examples/extensions/reload-runtime.ts +37 -0
  570. package/examples/extensions/rpc-demo.ts +124 -0
  571. package/examples/extensions/sandbox/index.ts +318 -0
  572. package/examples/extensions/sandbox/package-lock.json +92 -0
  573. package/examples/extensions/sandbox/package.json +19 -0
  574. package/examples/extensions/send-user-message.ts +97 -0
  575. package/examples/extensions/session-name.ts +27 -0
  576. package/examples/extensions/shutdown-command.ts +63 -0
  577. package/examples/extensions/snake.ts +343 -0
  578. package/examples/extensions/space-invaders.ts +560 -0
  579. package/examples/extensions/ssh.ts +220 -0
  580. package/examples/extensions/sst-resource-manager.ts +203 -0
  581. package/examples/extensions/status-line.ts +40 -0
  582. package/examples/extensions/subagent/README.md +172 -0
  583. package/examples/extensions/subagent/agents/planner.md +37 -0
  584. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  585. package/examples/extensions/subagent/agents/scout.md +50 -0
  586. package/examples/extensions/subagent/agents/worker.md +24 -0
  587. package/examples/extensions/subagent/agents.ts +126 -0
  588. package/examples/extensions/subagent/index.ts +964 -0
  589. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  590. package/examples/extensions/subagent/prompts/implement.md +10 -0
  591. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  592. package/examples/extensions/summarize.ts +195 -0
  593. package/examples/extensions/system-prompt-header.ts +17 -0
  594. package/examples/extensions/timed-confirm.ts +70 -0
  595. package/examples/extensions/titlebar-spinner.ts +58 -0
  596. package/examples/extensions/todo.ts +299 -0
  597. package/examples/extensions/tool-override.ts +143 -0
  598. package/examples/extensions/tools.ts +146 -0
  599. package/examples/extensions/trigger-compact.ts +40 -0
  600. package/examples/extensions/truncated-tool.ts +192 -0
  601. package/examples/extensions/widget-placement.ts +17 -0
  602. package/examples/extensions/with-deps/index.ts +36 -0
  603. package/examples/extensions/with-deps/package-lock.json +31 -0
  604. package/examples/extensions/with-deps/package.json +22 -0
  605. package/examples/rpc-extension-ui.ts +632 -0
  606. package/examples/sdk/01-minimal.ts +22 -0
  607. package/examples/sdk/02-custom-model.ts +49 -0
  608. package/examples/sdk/03-custom-prompt.ts +55 -0
  609. package/examples/sdk/04-skills.ts +46 -0
  610. package/examples/sdk/05-tools.ts +56 -0
  611. package/examples/sdk/06-extensions.ts +88 -0
  612. package/examples/sdk/07-context-files.ts +40 -0
  613. package/examples/sdk/08-prompt-templates.ts +42 -0
  614. package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
  615. package/examples/sdk/10-settings.ts +51 -0
  616. package/examples/sdk/11-sessions.ts +48 -0
  617. package/examples/sdk/12-full-control.ts +82 -0
  618. package/examples/sdk/README.md +144 -0
  619. package/extensions/gsd-commands.ts +338 -0
  620. package/extensions/subagent.ts +312 -0
  621. package/hooks/gsd/draht-post-phase.js +133 -0
  622. package/hooks/gsd/draht-post-task.js +132 -0
  623. package/hooks/gsd/draht-pre-execute.js +146 -0
  624. package/hooks/gsd/draht-quality-gate.js +210 -0
  625. package/package.json +105 -0
  626. package/prompts/agents/build.md +44 -0
  627. package/prompts/agents/plan.md +39 -0
  628. package/prompts/agents/verify.md +33 -0
  629. package/prompts/commands/atomic-commit.md +39 -0
  630. package/prompts/commands/discuss-phase.md +25 -0
  631. package/prompts/commands/execute-phase.md +59 -0
  632. package/prompts/commands/map-codebase.md +32 -0
  633. package/prompts/commands/new-project.md +40 -0
  634. package/prompts/commands/pause-work.md +12 -0
  635. package/prompts/commands/plan-phase.md +61 -0
  636. package/prompts/commands/progress.md +12 -0
  637. package/prompts/commands/quick.md +19 -0
  638. package/prompts/commands/resume-work.md +13 -0
  639. package/prompts/commands/verify-work.md +27 -0
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * Draht Pre-Execute Hook
6
+ * Runs before gsd-execute-phase to validate preconditions.
7
+ *
8
+ * Usage: node gsd-pre-execute.js <phase-number>
9
+ * Exit 0 = proceed, Exit 1 = abort
10
+ */
11
+
12
+ const fs = require("node:fs");
13
+ const path = require("node:path");
14
+ const { execSync } = require("node:child_process");
15
+
16
+ const phaseNum = process.argv[2];
17
+ if (!phaseNum) {
18
+ console.error("Usage: gsd-pre-execute.js <phase-number>");
19
+ process.exit(1);
20
+ }
21
+
22
+ const PLANNING = ".planning";
23
+ const errors = [];
24
+ const warnings = [];
25
+
26
+ // 1. Check .planning/ exists
27
+ if (!fs.existsSync(PLANNING)) {
28
+ errors.push("No .planning/ directory found. Run gsd-new-project first.");
29
+ }
30
+
31
+ // 2. Check STATE.md exists
32
+ if (!fs.existsSync(path.join(PLANNING, "STATE.md"))) {
33
+ errors.push("No STATE.md found. Project not initialized.");
34
+ }
35
+
36
+ // 3. Check ROADMAP.md exists and phase is defined
37
+ const roadmapPath = path.join(PLANNING, "ROADMAP.md");
38
+ if (fs.existsSync(roadmapPath)) {
39
+ const roadmap = fs.readFileSync(roadmapPath, "utf-8");
40
+ if (!roadmap.includes(`Phase ${phaseNum}`)) {
41
+ errors.push(`Phase ${phaseNum} not found in ROADMAP.md`);
42
+ }
43
+ } else {
44
+ errors.push("No ROADMAP.md found.");
45
+ }
46
+
47
+ // 4. Check phase directory exists with plans
48
+ const phasesDir = path.join(PLANNING, "phases");
49
+ if (fs.existsSync(phasesDir)) {
50
+ const entries = fs.readdirSync(phasesDir);
51
+ const phaseDir = entries.find((e) => e.startsWith(String(phaseNum).padStart(2, "0") + "-"));
52
+ if (!phaseDir) {
53
+ errors.push(`No phase directory found for phase ${phaseNum}. Run gsd-plan-phase first.`);
54
+ } else {
55
+ const phaseFiles = fs.readdirSync(path.join(phasesDir, phaseDir));
56
+ const plans = phaseFiles.filter((f) => f.endsWith("-PLAN.md") && !f.includes("FIX"));
57
+ if (plans.length === 0) {
58
+ errors.push(`No plans found in phase ${phaseNum}. Run gsd-plan-phase first.`);
59
+ }
60
+
61
+ // Check plans have required elements
62
+ for (const planFile of plans) {
63
+ const content = fs.readFileSync(path.join(phasesDir, phaseDir, planFile), "utf-8");
64
+ if (!content.includes("<task")) {
65
+ warnings.push(`${planFile}: No <task> elements — plan may be incomplete`);
66
+ }
67
+ if (!content.includes("<verify>")) {
68
+ warnings.push(`${planFile}: Missing <verify> steps — tasks won't be verifiable`);
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ // 5. Check git status
75
+ try {
76
+ const status = execSync("git status --porcelain", { encoding: "utf-8" }).trim();
77
+ if (status) {
78
+ const lines = status.split("\n").length;
79
+ warnings.push(`${lines} uncommitted file(s) — consider committing first`);
80
+ }
81
+ } catch {
82
+ warnings.push("Not a git repository — no commit tracking");
83
+ }
84
+
85
+ // 6. Check for CONTINUE-HERE.md (unfinished session)
86
+ if (fs.existsSync(path.join(PLANNING, "CONTINUE-HERE.md"))) {
87
+ warnings.push("CONTINUE-HERE.md exists — previous session may be unfinished. Consider gsd-resume-work.");
88
+ }
89
+
90
+ // 7. Check DOMAIN.md exists and has required sections
91
+ const domainPath = path.join(PLANNING, "DOMAIN.md");
92
+ if (!fs.existsSync(domainPath)) {
93
+ warnings.push("No .planning/DOMAIN.md found — domain model not documented. Run /new-project or /map-codebase to create it.");
94
+ } else {
95
+ const domainContent = fs.readFileSync(domainPath, "utf-8");
96
+ if (!domainContent.includes("## Bounded Contexts")) {
97
+ errors.push("DOMAIN.md is missing '## Bounded Contexts' section.");
98
+ }
99
+ if (!domainContent.includes("## Ubiquitous Language")) {
100
+ errors.push("DOMAIN.md is missing '## Ubiquitous Language' section.");
101
+ }
102
+ }
103
+
104
+ // 8. Check TEST-STRATEGY.md exists
105
+ if (!fs.existsSync(path.join(PLANNING, "TEST-STRATEGY.md"))) {
106
+ warnings.push("No .planning/TEST-STRATEGY.md found — test strategy not documented. Run /new-project or /map-codebase to create it.");
107
+ }
108
+
109
+ // 9. Check all plans have non-empty <test> sections
110
+ if (fs.existsSync(phasesDir)) {
111
+ const entries2 = fs.readdirSync(phasesDir);
112
+ const phaseDir2 = entries2.find((e) => e.startsWith(String(phaseNum).padStart(2, "0") + "-"));
113
+ if (phaseDir2) {
114
+ const phaseFiles2 = fs.readdirSync(path.join(phasesDir, phaseDir2));
115
+ const plans2 = phaseFiles2.filter((f) => f.endsWith("-PLAN.md") && !f.includes("FIX"));
116
+ for (const planFile of plans2) {
117
+ const content = fs.readFileSync(path.join(phasesDir, phaseDir2, planFile), "utf-8");
118
+ // Extract all <test>...</test> blocks and check they are non-empty
119
+ const testMatches = [...content.matchAll(/<test>([\s\S]*?)<\/test>/g)];
120
+ if (testMatches.length === 0) {
121
+ errors.push(`${planFile}: Missing <test> sections — TDD requires tests for every task`);
122
+ } else {
123
+ for (const m of testMatches) {
124
+ if (!m[1].trim()) {
125
+ errors.push(`${planFile}: Empty <test> section found — fill in test cases before executing`);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+
133
+ // Output
134
+ if (warnings.length > 0) {
135
+ console.log(`⚠️ ${warnings.length} warning(s):`);
136
+ for (const w of warnings) console.log(` - ${w}`);
137
+ }
138
+
139
+ if (errors.length > 0) {
140
+ console.log(`\n❌ ${errors.length} error(s) — cannot proceed:`);
141
+ for (const e of errors) console.log(` - ${e}`);
142
+ process.exit(1);
143
+ }
144
+
145
+ console.log(`✅ Pre-execute checks passed for phase ${phaseNum}`);
146
+ process.exit(0);
@@ -0,0 +1,210 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * Draht Quality Gate Hook
6
+ * Runs after task completion to enforce quality standards.
7
+ * Called by the build agent after each verify step.
8
+ *
9
+ * Usage: node gsd-quality-gate.js [--strict]
10
+ * Exit 0 = quality OK, Exit 1 = quality issues
11
+ */
12
+
13
+ const { execSync } = require("node:child_process");
14
+ const fs = require("node:fs");
15
+
16
+ const strict = process.argv.includes("--strict");
17
+ const issues = [];
18
+
19
+ // 1. TypeScript check
20
+ try {
21
+ execSync("bun run tsgo --noEmit 2>&1", { timeout: 60000, encoding: "utf-8" });
22
+ } catch (error) {
23
+ const output = error.stdout || error.stderr || "";
24
+ const errorCount = (output.match(/error TS/g) || []).length;
25
+ if (errorCount > 0) {
26
+ issues.push({ severity: strict ? "error" : "warning", message: `${errorCount} TypeScript error(s)`, details: output.slice(0, 500) });
27
+ }
28
+ }
29
+
30
+ // 2. Biome lint check (if biome.json exists)
31
+ if (fs.existsSync("biome.json")) {
32
+ try {
33
+ execSync("bunx biome check --error-on-warnings . 2>&1", { timeout: 30000, encoding: "utf-8" });
34
+ } catch (error) {
35
+ const output = error.stdout || error.stderr || "";
36
+ issues.push({ severity: strict ? "error" : "warning", message: "Biome lint issues", details: output.slice(0, 500) });
37
+ }
38
+ }
39
+
40
+ // 3. Run tests
41
+ try {
42
+ const testOutput = execSync("bun test 2>&1", { timeout: 120000, encoding: "utf-8" });
43
+ const failMatch = testOutput.match(/(\d+) fail/);
44
+ if (failMatch && parseInt(failMatch[1], 10) > 0) {
45
+ issues.push({ severity: strict ? "error" : "warning", message: `${failMatch[1]} test(s) failing` });
46
+ }
47
+ } catch (error) {
48
+ const output = error.stdout || error.stderr || "";
49
+ const failMatch = output.match(/(\d+) fail/);
50
+ if (failMatch && parseInt(failMatch[1], 10) > 0) {
51
+ issues.push({ severity: strict ? "error" : "warning", message: `${failMatch[1]} test(s) failing` });
52
+ }
53
+ }
54
+
55
+ // 4. Check for console.log in source files (not tests)
56
+ try {
57
+ const result = execSync(
58
+ "grep -rn 'console\\.log' src/ --include='*.ts' --include='*.tsx' 2>/dev/null | grep -v '// debug' | head -5",
59
+ { encoding: "utf-8" }
60
+ ).trim();
61
+ if (result) {
62
+ issues.push({ severity: "warning", message: `console.log found in source`, details: result });
63
+ }
64
+ } catch { /* grep returns 1 when no match — that's good */ }
65
+
66
+ // 5. Domain glossary compliance
67
+ // Extract terms from DOMAIN.md and flag new PascalCase classes not in the glossary
68
+ const domainMdPath = ".planning/DOMAIN.md";
69
+ if (fs.existsSync(domainMdPath)) {
70
+ try {
71
+ const domainContent = fs.readFileSync(domainMdPath, "utf-8");
72
+ // Collect all PascalCase tokens that appear in the glossary section
73
+ const glossarySection = domainContent.match(/## Ubiquitous Language([\s\S]*?)(?:^##|\Z)/m)?.[1] || "";
74
+ // Each glossary entry is assumed to start the line with a PascalCase term (e.g. "**Order**" or "- Order:")
75
+ const glossaryTerms = new Set(
76
+ [...glossarySection.matchAll(/\b([A-Z][a-zA-Z0-9]+)\b/g)].map((m) => m[1])
77
+ );
78
+
79
+ // Scan changed source files for PascalCase class/interface/type declarations
80
+ try {
81
+ const changedFiles = execSync(
82
+ "git diff --cached --name-only 2>/dev/null || git diff --name-only HEAD~1",
83
+ { encoding: "utf-8" }
84
+ ).trim().split("\n").filter((f) => f.endsWith(".ts") || f.endsWith(".tsx"));
85
+
86
+ const unknownTerms = [];
87
+ for (const file of changedFiles) {
88
+ if (!fs.existsSync(file)) continue;
89
+ const src = fs.readFileSync(file, "utf-8");
90
+ const declarations = [...src.matchAll(/(?:class|interface|type|enum)\s+([A-Z][a-zA-Z0-9]+)/g)].map((m) => m[1]);
91
+ for (const term of declarations) {
92
+ if (!glossaryTerms.has(term)) {
93
+ unknownTerms.push(`${file}: ${term}`);
94
+ }
95
+ }
96
+ }
97
+ if (unknownTerms.length > 0) {
98
+ issues.push({
99
+ severity: "warning",
100
+ message: `${unknownTerms.length} PascalCase type(s) not in DOMAIN.md glossary`,
101
+ details: unknownTerms.slice(0, 5).join(", "),
102
+ });
103
+ }
104
+ } catch { /* ignore git errors */ }
105
+ } catch { /* ignore read errors */ }
106
+ }
107
+
108
+ // 6. Bounded context boundary check — flag suspicious cross-directory imports
109
+ try {
110
+ const changedSrcFiles = execSync(
111
+ "git diff --cached --name-only 2>/dev/null || git diff --name-only HEAD~1",
112
+ { encoding: "utf-8" }
113
+ ).trim().split("\n").filter((f) => /^src\/[^/]+\//.test(f) && (f.endsWith(".ts") || f.endsWith(".tsx")));
114
+
115
+ const crossContextImports = [];
116
+ for (const file of changedSrcFiles) {
117
+ if (!fs.existsSync(file)) continue;
118
+ // Determine this file's context (first path segment under src/)
119
+ const ownContext = file.split("/")[1];
120
+ const src = fs.readFileSync(file, "utf-8");
121
+ const imports = [...src.matchAll(/from\s+['"](\.\.\/.+?)['"]/g)].map((m) => m[1]);
122
+ for (const imp of imports) {
123
+ // Resolve relative import against the file's directory
124
+ const resolved = path.normalize(path.join(path.dirname(file), imp));
125
+ const parts = resolved.split(path.sep);
126
+ const srcIdx = parts.indexOf("src");
127
+ if (srcIdx !== -1 && parts[srcIdx + 1] && parts[srcIdx + 1] !== ownContext) {
128
+ crossContextImports.push(`${file} → ${parts.slice(srcIdx).join("/")}`);
129
+ }
130
+ }
131
+ }
132
+ if (crossContextImports.length > 0) {
133
+ issues.push({
134
+ severity: "warning",
135
+ message: `${crossContextImports.length} suspicious cross-context import(s) detected`,
136
+ details: crossContextImports.slice(0, 3).join("; "),
137
+ });
138
+ }
139
+ } catch { /* ignore */ }
140
+
141
+ // 7. TDD health — check test-to-source file ratio
142
+ try {
143
+ const allSrc = execSync(
144
+ "find src -name '*.ts' -not -name '*.test.ts' -not -name '*.spec.ts' 2>/dev/null | wc -l",
145
+ { encoding: "utf-8" }
146
+ ).trim();
147
+ const allTests = execSync(
148
+ "find src -name '*.test.ts' -o -name '*.spec.ts' 2>/dev/null | wc -l",
149
+ { encoding: "utf-8" }
150
+ ).trim();
151
+ const srcCount = parseInt(allSrc, 10) || 0;
152
+ const testCount = parseInt(allTests, 10) || 0;
153
+ if (srcCount > 0) {
154
+ const ratio = testCount / srcCount;
155
+ if (ratio < 0.3) {
156
+ issues.push({
157
+ severity: "warning",
158
+ message: `TDD health: test-to-source ratio is ${(ratio * 100).toFixed(0)}% (${testCount} tests / ${srcCount} sources) — target ≥ 30%`,
159
+ });
160
+ }
161
+ }
162
+ } catch { /* ignore — src/ may not exist */ }
163
+
164
+ // 8. Check for TODO/FIXME/HACK comments in changed files
165
+ try {
166
+ const diff = execSync("git diff --cached --name-only 2>/dev/null || git diff --name-only HEAD~1", { encoding: "utf-8" }).trim();
167
+ if (diff) {
168
+ const files = diff.split("\n").filter((f) => f.endsWith(".ts") || f.endsWith(".tsx"));
169
+ for (const file of files) {
170
+ try {
171
+ const content = fs.readFileSync(file, "utf-8");
172
+ const todos = content.match(/\/\/\s*(TODO|FIXME|HACK|XXX):/gi) || [];
173
+ if (todos.length > 0) {
174
+ issues.push({ severity: "info", message: `${file}: ${todos.length} TODO/FIXME comment(s)` });
175
+ }
176
+ } catch { /* file may not exist */ }
177
+ }
178
+ }
179
+ } catch { /* ignore */ }
180
+
181
+ // Output
182
+ const errors = issues.filter((i) => i.severity === "error");
183
+ const warnings = issues.filter((i) => i.severity === "warning");
184
+ const infos = issues.filter((i) => i.severity === "info");
185
+
186
+ if (errors.length > 0) {
187
+ console.log(`\n❌ Quality Gate FAILED (${errors.length} error(s)):`);
188
+ for (const e of errors) {
189
+ console.log(` ❌ ${e.message}`);
190
+ if (e.details) console.log(` ${e.details.split("\n")[0]}`);
191
+ }
192
+ }
193
+
194
+ if (warnings.length > 0) {
195
+ console.log(`\n⚠️ ${warnings.length} warning(s):`);
196
+ for (const w of warnings) {
197
+ console.log(` ⚠️ ${w.message}`);
198
+ }
199
+ }
200
+
201
+ if (infos.length > 0) {
202
+ console.log(`\nℹ️ ${infos.length} note(s):`);
203
+ for (const i of infos) console.log(` ℹ️ ${i.message}`);
204
+ }
205
+
206
+ if (errors.length === 0 && warnings.length === 0) {
207
+ console.log("✅ Quality gate passed");
208
+ }
209
+
210
+ process.exit(errors.length > 0 ? 1 : 0);
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "@draht/coding-agent",
3
+ "version": "2026.3.2-2",
4
+ "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
+ "type": "module",
6
+ "drahtConfig": {
7
+ "name": "draht",
8
+ "configDir": ".draht"
9
+ },
10
+ "bin": {
11
+ "draht": "dist/cli.js",
12
+ "draht-tools": "bin/draht-tools.cjs"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ },
21
+ "./hooks": {
22
+ "types": "./dist/core/hooks/index.d.ts",
23
+ "import": "./dist/core/hooks/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "docs",
29
+ "examples",
30
+ "prompts",
31
+ "hooks",
32
+ "extensions",
33
+ "bin",
34
+ "CHANGELOG.md"
35
+ ],
36
+ "scripts": {
37
+ "clean": "shx rm -rf dist",
38
+ "dev": "tsgo -p tsconfig.build.json --watch --preserveWatchOutput",
39
+ "build": "tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js && bun run copy-assets",
40
+ "build:binary": "bun run build && bun build --compile ./dist/cli.js --outfile dist/pi && bun run copy-binary-assets",
41
+ "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/extensions && shx cp -r prompts dist/prompts && shx cp -r hooks dist/hooks && shx cp -r extensions dist/extensions",
42
+ "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 extensions dist/ && shx cp ../../node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm dist/",
43
+ "test": "vitest --run",
44
+ "prepublishOnly": "bun run clean && bun run build"
45
+ },
46
+ "dependencies": {
47
+ "@mariozechner/jiti": "^2.6.2",
48
+ "@draht/agent-core": "2026.3.1-7",
49
+ "@draht/ai": "2026.3.1-7",
50
+ "@draht/tui": "2026.3.1-7",
51
+ "@silvia-odwyer/photon-node": "^0.3.4",
52
+ "chalk": "^5.5.0",
53
+ "cli-highlight": "^2.1.11",
54
+ "diff": "^8.0.2",
55
+ "extract-zip": "^2.0.1",
56
+ "file-type": "^21.1.1",
57
+ "glob": "^13.0.1",
58
+ "hosted-git-info": "^9.0.2",
59
+ "ignore": "^7.0.5",
60
+ "marked": "^15.0.12",
61
+ "minimatch": "^10.2.3",
62
+ "proper-lockfile": "^4.1.2",
63
+ "yaml": "^2.8.2"
64
+ },
65
+ "overrides": {
66
+ "rimraf": "6.1.2",
67
+ "gaxios": {
68
+ "rimraf": "6.1.2"
69
+ }
70
+ },
71
+ "optionalDependencies": {
72
+ "@mariozechner/clipboard": "^0.3.2"
73
+ },
74
+ "devDependencies": {
75
+ "@types/diff": "^7.0.2",
76
+ "@types/hosted-git-info": "^3.0.5",
77
+ "@types/ms": "^2.1.0",
78
+ "@types/node": "^24.3.0",
79
+ "@types/proper-lockfile": "^4.1.4",
80
+ "shx": "^0.4.0",
81
+ "typescript": "^6.0.0-beta",
82
+ "vitest": "^3.2.4"
83
+ },
84
+ "keywords": [
85
+ "coding-agent",
86
+ "ai",
87
+ "llm",
88
+ "cli",
89
+ "tui",
90
+ "agent"
91
+ ],
92
+ "author": "Mario Zechner",
93
+ "license": "MIT",
94
+ "publishConfig": {
95
+ "access": "public"
96
+ },
97
+ "repository": {
98
+ "type": "git",
99
+ "url": "git+https://github.com/badlogic/pi-mono.git",
100
+ "directory": "packages/coding-agent"
101
+ },
102
+ "engines": {
103
+ "node": ">=20.0.0"
104
+ }
105
+ }
@@ -0,0 +1,44 @@
1
+ # Draht Build Agent
2
+
3
+ You are an execution agent for the Get Shit Done methodology. Your job is to implement plans precisely.
4
+
5
+ ## Core Rules
6
+ 1. Read the plan FIRST — it is your instruction set
7
+ 2. Execute tasks in order, one at a time
8
+ 3. VERIFY each task before moving to the next
9
+ 4. Commit after each task: `draht commit-task N P T "description"`
10
+ 5. If verification fails, fix it before continuing
11
+ 6. Never skip a verify step — that's how quality dies
12
+
13
+ ## Tools Available
14
+ - `draht read-plan N P` — read the plan to execute
15
+ - `draht commit-task N P T "desc"` — atomic commit per task
16
+ - `draht write-summary N P` — write completion summary
17
+ - `draht verify-phase N` — check phase completion
18
+ - `draht update-state` — update STATE.md
19
+
20
+ ## Process (TDD-First)
21
+ 1. Read plan: `draht read-plan N P`
22
+ 2. For each <task>:
23
+ a. Read the <test> block — write the test code FIRST (expect RED — tests should fail)
24
+ b. Read the <action> — implement to make tests GREEN
25
+ c. Read the <refactor> — clean up while keeping tests green
26
+ d. Run the <verify> step
27
+ e. If verify passes: `draht commit-task N P T "task name"`
28
+ f. If verify fails: fix and retry (max 3 attempts)
29
+ g. If a task has no <test> block, write a test anyway before implementing
30
+ 3. After all tasks: `draht write-summary N P`
31
+ 4. Fill in the summary with actual commits, files changed, notes
32
+ 5. After all plans in phase: `draht verify-phase N`
33
+
34
+ ## Checkpoint Handling
35
+ - `type="auto"` → execute silently
36
+ - `type="checkpoint:human-verify"` → STOP, show what was built, ask for confirmation
37
+ - `type="checkpoint:decision"` → STOP, present options, wait for choice
38
+
39
+ ## On Failure
40
+ If a task fails 3 times:
41
+ 1. Document what went wrong in the summary
42
+ 2. Mark task as failed
43
+ 3. Continue to next task (unless it depends on the failed one)
44
+ 4. Note the failure for fix planning
@@ -0,0 +1,39 @@
1
+ # Draht Plan Agent
2
+
3
+ You are a planning agent for the Get Shit Done methodology. Your job is to create atomic, executable plans.
4
+
5
+ ## Core Rules
6
+ 1. Plans are prompts — they tell the executor EXACTLY what to build
7
+ 2. Each task must be atomic (one clear action, one verify step)
8
+ 3. Maximum 5 tasks per plan
9
+ 4. Goal-backward: start from "what must be TRUE" not "what should we build"
10
+ 5. Every task needs <verify> and <done> — no ambiguity
11
+
12
+ ## Tools Available
13
+ - `draht load-phase-context N` — gather all context for a phase
14
+ - `draht create-plan N P "title"` — create plan template
15
+ - `draht validate-plans N` — check plans for completeness
16
+ - `draht research-phase N` — create research template
17
+ - `draht commit-docs "message"` — commit planning docs
18
+
19
+ ## Process
20
+ 1. Load all context: `draht load-phase-context N`
21
+ 2. State the goal as an outcome
22
+ 3. List 3-7 observable truths that must be TRUE
23
+ 4. Map truths to files/endpoints/artifacts
24
+ 5. Group into plans of 2-5 tasks each
25
+ 6. Write plans using XML task format
26
+ 7. Validate: `draht validate-plans N`
27
+
28
+ ## XML Task Format
29
+ ```xml
30
+ <task type="auto">
31
+ <n>Short task name</n>
32
+ <files>path/to/files</files>
33
+ <action>Precise instructions. No ambiguity.</action>
34
+ <verify>Command or check to verify</verify>
35
+ <done>What "done" looks like from user perspective</done>
36
+ </task>
37
+ ```
38
+
39
+ Task types: auto, checkpoint:human-verify, checkpoint:decision
@@ -0,0 +1,33 @@
1
+ # Draht Verify Agent
2
+
3
+ You are a verification agent for the Get Shit Done methodology. Your job is to test completed work against acceptance criteria.
4
+
5
+ ## Core Rules
6
+ 1. Test from the USER's perspective, not the developer's
7
+ 2. Every must_have and <done> must be verified
8
+ 3. Be honest — if something doesn't work, say so
9
+ 4. Create fix plans for failures, don't just report them
10
+
11
+ ## Tools Available
12
+ - `draht extract-deliverables N` — list testable items
13
+ - `draht create-fix-plan N P "issue"` — create fix plan for failures
14
+ - `draht write-uat N` — create UAT report
15
+ - `draht update-state` — update STATE.md
16
+
17
+ ## Process
18
+ 1. Extract deliverables: `draht extract-deliverables N`
19
+ 2. For each deliverable:
20
+ a. Explain what should be true
21
+ b. Test it (run commands, check files, verify behavior)
22
+ c. Record: pass / fail / partial
23
+ 3. For failures:
24
+ a. Diagnose root cause
25
+ b. Create fix plan: `draht create-fix-plan N P "issue"`
26
+ 4. Write UAT report: `draht write-uat N`
27
+ 5. Update state: `draht update-state`
28
+
29
+ ## Output
30
+ Always end with a clear summary:
31
+ - X/Y passed
32
+ - Fix plans created (if any)
33
+ - Recommended next action
@@ -0,0 +1,39 @@
1
+ ---
2
+ description: "Analyze changes and create atomic commits"
3
+ ---
4
+
5
+ # Git Atomic Commit Analysis
6
+
7
+ First, check the current status:
8
+
9
+ *! git status*
10
+
11
+ Now get the full diff of all changes:
12
+
13
+ *! git diff*
14
+
15
+ And staged changes:
16
+
17
+ *! git diff --cached*
18
+
19
+ Based on the changes shown above, analyze and group them into logical, ATOMIC commits. Each commit should:
20
+
21
+ 1. Contain ONE logical change only
22
+ 2. Be self-contained and complete
23
+ 3. Not break the build if applied independently
24
+
25
+ For each group of changes you identify:
26
+ - List the specific files that belong together
27
+ - Generate a clear, descriptive commit message following conventional commits format
28
+ - Explain WHY these changes belong in one commit
29
+
30
+ Then provide the exact `git add` and `git commit` commands to execute for each atomic commit in the order they should be applied.
31
+
32
+ Format each commit message as:
33
+ type(scope): brief description
34
+ - Detailed explanation of what changed
35
+ - Why the change was necessary
36
+
37
+
38
+ Common types: feat, fix, refactor, docs, test, chore, style, perf
39
+
@@ -0,0 +1,25 @@
1
+ # /discuss-phase
2
+
3
+ Capture implementation decisions before planning a phase.
4
+
5
+ ## Usage
6
+ ```
7
+ /discuss-phase [N]
8
+ ```
9
+
10
+ ## Steps
11
+ 1. Run `draht phase-info N` to load phase context
12
+ 2. Identify gray areas based on what's being built
13
+ 3. Present 1-2 questions at a time about preferences
14
+ 4. If `.planning/DOMAIN.md` exists, load it and validate discovered terms against the glossary. Add any new domain terms found during discussion.
15
+ 5. Record decisions with `draht save-context N`
16
+ 6. Commit: `draht commit-docs "capture phase N context"`
17
+
18
+ ## Gray Area Categories
19
+ - **Visual features** → Layout, density, interactions, empty states
20
+ - **APIs/CLIs** → Response format, error handling, auth
21
+ - **Data models** → Schema, relationships, validation
22
+ - **Content** → Structure, tone, depth, flow
23
+ - **Refactoring** → Grouping, naming, migration strategy
24
+ - **Testability** → What needs testing, test framework preference, coverage goals, integration vs unit boundaries
25
+ - **Domain boundaries** → What are the bounded contexts in play? Are there existing domain terms to respect? What aggregates/entities are involved?