@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
@@ -1 +1 @@
1
- {"version":3,"file":"trust-manager.js","sourceRoot":"","sources":["../../src/core/trust-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuBlE,MAAM,wCAAwC,GAAG;IAChD,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW;IACX,kBAAkB;CACT,CAAC;AAEX,SAAS,Y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oBACvB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACP,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACtB,CAAC;YACF,CAAC;YACD,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAAA,CACrC,CAAC,CAAC;IAAA,CACH;CACD","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\n\nexport type ProjectTrustDecision = boolean | null;\n\nexport interface ProjectTrustStoreEntry {\n\tpath: string;\n\tdecision: boolean;\n}\n\nexport interface ProjectTrustUpdate {\n\tpath: string;\n\tdecision: ProjectTrustDecision;\n}\n\nexport interface ProjectTrustOption {\n\tlabel: string;\n\ttrusted: boolean;\n\tupdates: ProjectTrustUpdate[];\n\tsavedPath?: string;\n}\n\ntype TrustFile = Record<string, boolean | null | undefined>;\n\nconst TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [\n\t\"settings.json\",\n\t\"extensions\",\n\t\"skills\",\n\t\"prompts\",\n\t\"themes\",\n\t\"SYSTEM.md\",\n\t\"APPEND_SYSTEM.md\",\n] as const;\n\nfunction normalizeCwd(cwd: string): string {\n\treturn canonicalizePath(resolvePath(cwd));\n}\n\nfunction findNearestTrustEntry(data: TrustFile, cwd: string): ProjectTrustStoreEntry | null {\n\tlet currentDir = normalizeCwd(cwd);\n\twhile (true) {\n\t\tconst value = data[currentDir];\n\t\tif (value === true || value === false) {\n\t\t\treturn { path: currentDir, decision: value };\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport function getProjectTrustParentPath(cwd: string): string | undefined {\n\tconst trustPath = normalizeCwd(cwd);\n\tconst parentDir = dirname(trustPath);\n\treturn parentDir === trustPath ? undefined : parentDir;\n}\n\nexport function getProjectTrustOptions(cwd: string, options?: { includeSessionOnly?: boolean }): ProjectTrustOption[] {\n\tconst trustPath = normalizeCwd(cwd);\n\tconst trustOptions: ProjectTrustOption[] = [\n\t\t{ label: \"Trust\", trusted: true, updates: [{ path: trustPath, decision: true }], savedPath: trustPath },\n\t];\n\tconst parentPath = getProjectTrustParentPath(cwd);\n\tif (parentPath !== undefined) {\n\t\ttrustOptions.push({\n\t\t\tlabel: `Trust parent folder (${parentPath})`,\n\t\t\ttrusted: true,\n\t\t\tupdates: [\n\t\t\t\t{ path: parentPath, decision: true },\n\t\t\t\t{ path: trustPath, decision: null },\n\t\t\t],\n\t\t\tsavedPath: parentPath,\n\t\t});\n\t}\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Trust (this session only)\", trusted: true, updates: [] });\n\t}\n\ttrustOptions.push({\n\t\tlabel: \"Do not trust\",\n\t\ttrusted: false,\n\t\tupdates: [{ path: trustPath, decision: false }],\n\t\tsavedPath: trustPath,\n\t});\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Do not trust (this session only)\", trusted: false, updates: [] });\n\t}\n\treturn trustOptions;\n}\n\nfunction readTrustFile(path: string): TrustFile {\n\tif (!existsSync(path)) {\n\t\treturn {};\n\t}\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(readFileSync(path, \"utf-8\"));\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to read trust store ${path}: ${message}`);\n\t}\n\n\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(`Invalid trust store ${path}: expected an object`);\n\t}\n\n\tconst data: TrustFile = {};\n\tfor (const [key, value] of Object.entries(parsed)) {\n\t\tif (value !== true && value !== false && value !== null) {\n\t\t\tthrow new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);\n\t\t}\n\t\tdata[key] = value;\n\t}\n\treturn data;\n}\n\nfunction writeTrustFile(path: string, data: TrustFile): void {\n\tconst sorted: TrustFile = {};\n\tfor (const key of Object.keys(data).sort()) {\n\t\tconst value = data[key];\n\t\tif (value === true || value === false || value === null) {\n\t\t\tsorted[key] = value;\n\t\t}\n\t}\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(sorted, null, 2)}\\n`, \"utf-8\");\n}\n\nfunction acquireTrustLockSync(path: string): () => void {\n\tconst trustDir = dirname(path);\n\tmkdirSync(trustDir, { recursive: true });\n\tconst maxAttempts = 10;\n\tconst delayMs = 20;\n\tlet lastError: unknown;\n\n\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\ttry {\n\t\t\treturn lockfile.lockSync(trustDir, { realpath: false, lockfilePath: `${path}.lock` });\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t: undefined;\n\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tlastError = error;\n\t\t\tconst start = Date.now();\n\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t// Sleep synchronously to avoid changing trust store callers to async.\n\t\t\t}\n\t\t}\n\t}\n\n\tif (lastError instanceof Error) {\n\t\tthrow lastError;\n\t}\n\tthrow new Error(\"Failed to acquire trust store lock\");\n}\n\nfunction withTrustFileLock<T>(path: string, fn: () => T): T {\n\tconst release = acquireTrustLockSync(path);\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\trelease();\n\t}\n}\n\n/**\n * Returns true when cwd has project-local resources that must be gated by\n * project trust: trust-requiring entries under cwd/.pi, or .agents/skills in\n * cwd or one of its ancestors. Returns false when no such project resources\n * exist. The user/global ~/.agents/skills directory is always treated as a\n * trusted user resource and is ignored here, even when cwd is $HOME.\n */\nexport function hasTrustRequiringProjectResources(cwd: string): boolean {\n\tconst homeDir = canonicalizePath(resolvePath(process.env.HOME || homedir()));\n\tconst userAgentsSkillsDir = join(homeDir, \".agents\", \"skills\");\n\tlet currentDir = canonicalizePath(resolvePath(cwd));\n\n\tconst configDir = join(currentDir, CONFIG_DIR_NAME);\n\tif (TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync(join(configDir, entry)))) {\n\t\treturn true;\n\t}\n\n\twhile (true) {\n\t\tconst agentsSkillsDir = join(currentDir, \".agents\", \"skills\");\n\t\tif (agentsSkillsDir !== userAgentsSkillsDir && existsSync(agentsSkillsDir)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport class ProjectTrustStore {\n\tprivate trustPath: string;\n\n\tconstructor(agentDir: string) {\n\t\tthis.trustPath = join(resolvePath(agentDir), \"trust.json\");\n\t}\n\n\tget(cwd: string): ProjectTrustDecision {\n\t\treturn this.getEntry(cwd)?.decision ?? null;\n\t}\n\n\tgetEntry(cwd: string): ProjectTrustStoreEntry | null {\n\t\treturn withTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\treturn findNearestTrustEntry(data, cwd);\n\t\t});\n\t}\n\n\tset(cwd: string, decision: ProjectTrustDecision): void {\n\t\tthis.setMany([{ path: cwd, decision }]);\n\t}\n\n\tsetMany(decisions: ProjectTrustUpdate[]): void {\n\t\twithTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\tfor (const { path, decision } of decisions) {\n\t\t\t\tconst key = normalizeCwd(path);\n\t\t\t\tif (decision === null) {\n\t\t\t\t\tdelete data[key];\n\t\t\t\t} else {\n\t\t\t\t\tdata[key] = decision;\n\t\t\t\t}\n\t\t\t}\n\t\t\twriteTrustFile(this.trustPath, data);\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"trust-manager.js","sourceRoot":"","sources":["../../src/core/trust-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuBlE,MAAM,wCAAwC,GAAG;IAChD,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW;IACX,kBAAkB;CACT,CAAC;AAEX,SAAS,YAAY,CAAC,GAAW;IAChC,OAAO,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAe,EAAE,GAAW;IAC1D,IAAI,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,IAAI,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC9C,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;QACD,UAAU,GAA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AAE,GAAG,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,QAA8B;QAC9C,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,SAA+B;QACtC,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YACtC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3C,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC5C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;oBACvB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACP,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACtB,CAAC;YACF,CAAC;YACD,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\n\nexport type ProjectTrustDecision = boolean | null;\n\nexport interface ProjectTrustStoreEntry {\n\tpath: string;\n\tdecision: boolean;\n}\n\nexport interface ProjectTrustUpdate {\n\tpath: string;\n\tdecision: ProjectTrustDecision;\n}\n\nexport interface ProjectTrustOption {\n\tlabel: string;\n\ttrusted: boolean;\n\tupdates: ProjectTrustUpdate[];\n\tsavedPath?: string;\n}\n\ntype TrustFile = Record<string, boolean | null | undefined>;\n\nconst TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [\n\t\"settings.json\",\n\t\"extensions\",\n\t\"skills\",\n\t\"prompts\",\n\t\"themes\",\n\t\"SYSTEM.md\",\n\t\"APPEND_SYSTEM.md\",\n] as const;\n\nfunction normalizeCwd(cwd: string): string {\n\treturn canonicalizePath(resolvePath(cwd));\n}\n\nfunction findNearestTrustEntry(data: TrustFile, cwd: string): ProjectTrustStoreEntry | null {\n\tlet currentDir = normalizeCwd(cwd);\n\twhile (true) {\n\t\tconst value = data[currentDir];\n\t\tif (value === true || value === false) {\n\t\t\treturn { path: currentDir, decision: value };\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport function getProjectTrustParentPath(cwd: string): string | undefined {\n\tconst trustPath = normalizeCwd(cwd);\n\tconst parentDir = dirname(trustPath);\n\treturn parentDir === trustPath ? undefined : parentDir;\n}\n\nexport function getProjectTrustOptions(cwd: string, options?: { includeSessionOnly?: boolean }): ProjectTrustOption[] {\n\tconst trustPath = normalizeCwd(cwd);\n\tconst trustOptions: ProjectTrustOption[] = [\n\t\t{ label: \"Trust\", trusted: true, updates: [{ path: trustPath, decision: true }], savedPath: trustPath },\n\t];\n\tconst parentPath = getProjectTrustParentPath(cwd);\n\tif (parentPath !== undefined) {\n\t\ttrustOptions.push({\n\t\t\tlabel: `Trust parent folder (${parentPath})`,\n\t\t\ttrusted: true,\n\t\t\tupdates: [\n\t\t\t\t{ path: parentPath, decision: true },\n\t\t\t\t{ path: trustPath, decision: null },\n\t\t\t],\n\t\t\tsavedPath: parentPath,\n\t\t});\n\t}\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Trust (this session only)\", trusted: true, updates: [] });\n\t}\n\ttrustOptions.push({\n\t\tlabel: \"Do not trust\",\n\t\ttrusted: false,\n\t\tupdates: [{ path: trustPath, decision: false }],\n\t\tsavedPath: trustPath,\n\t});\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Do not trust (this session only)\", trusted: false, updates: [] });\n\t}\n\treturn trustOptions;\n}\n\nfunction readTrustFile(path: string): TrustFile {\n\tif (!existsSync(path)) {\n\t\treturn {};\n\t}\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(readFileSync(path, \"utf-8\"));\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to read trust store ${path}: ${message}`);\n\t}\n\n\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(`Invalid trust store ${path}: expected an object`);\n\t}\n\n\tconst data: TrustFile = {};\n\tfor (const [key, value] of Object.entries(parsed)) {\n\t\tif (value !== true && value !== false && value !== null) {\n\t\t\tthrow new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);\n\t\t}\n\t\tdata[key] = value;\n\t}\n\treturn data;\n}\n\nfunction writeTrustFile(path: string, data: TrustFile): void {\n\tconst sorted: TrustFile = {};\n\tfor (const key of Object.keys(data).sort()) {\n\t\tconst value = data[key];\n\t\tif (value === true || value === false || value === null) {\n\t\t\tsorted[key] = value;\n\t\t}\n\t}\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(sorted, null, 2)}\\n`, \"utf-8\");\n}\n\nfunction acquireTrustLockSync(path: string): () => void {\n\tconst trustDir = dirname(path);\n\tmkdirSync(trustDir, { recursive: true });\n\tconst maxAttempts = 10;\n\tconst delayMs = 20;\n\tlet lastError: unknown;\n\n\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\ttry {\n\t\t\treturn lockfile.lockSync(trustDir, { realpath: false, lockfilePath: `${path}.lock` });\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t: undefined;\n\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tlastError = error;\n\t\t\tconst start = Date.now();\n\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t// Sleep synchronously to avoid changing trust store callers to async.\n\t\t\t}\n\t\t}\n\t}\n\n\tif (lastError instanceof Error) {\n\t\tthrow lastError;\n\t}\n\tthrow new Error(\"Failed to acquire trust store lock\");\n}\n\nfunction withTrustFileLock<T>(path: string, fn: () => T): T {\n\tconst release = acquireTrustLockSync(path);\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\trelease();\n\t}\n}\n\n/**\n * Returns true when cwd has project-local resources that must be gated by\n * project trust: trust-requiring entries under cwd/.pi, or .agents/skills in\n * cwd or one of its ancestors. Returns false when no such project resources\n * exist. The user/global ~/.agents/skills directory is always treated as a\n * trusted user resource and is ignored here, even when cwd is $HOME.\n */\nexport function hasTrustRequiringProjectResources(cwd: string): boolean {\n\tconst homeDir = canonicalizePath(resolvePath(process.env.HOME || homedir()));\n\tconst userAgentsSkillsDir = join(homeDir, \".agents\", \"skills\");\n\tlet currentDir = canonicalizePath(resolvePath(cwd));\n\n\tconst configDir = join(currentDir, CONFIG_DIR_NAME);\n\tif (TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync(join(configDir, entry)))) {\n\t\treturn true;\n\t}\n\n\twhile (true) {\n\t\tconst agentsSkillsDir = join(currentDir, \".agents\", \"skills\");\n\t\tif (agentsSkillsDir !== userAgentsSkillsDir && existsSync(agentsSkillsDir)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport class ProjectTrustStore {\n\tprivate trustPath: string;\n\n\tconstructor(agentDir: string) {\n\t\tthis.trustPath = join(resolvePath(agentDir), \"trust.json\");\n\t}\n\n\tget(cwd: string): ProjectTrustDecision {\n\t\treturn this.getEntry(cwd)?.decision ?? null;\n\t}\n\n\tgetEntry(cwd: string): ProjectTrustStoreEntry | null {\n\t\treturn withTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\treturn findNearestTrustEntry(data, cwd);\n\t\t});\n\t}\n\n\tset(cwd: string, decision: ProjectTrustDecision): void {\n\t\tthis.setMany([{ path: cwd, decision }]);\n\t}\n\n\tsetMany(decisions: ProjectTrustUpdate[]): void {\n\t\twithTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\tfor (const { path, decision } of decisions) {\n\t\t\t\tconst key = normalizeCwd(path);\n\t\t\t\tif (decision === null) {\n\t\t\t\t\tdelete data[key];\n\t\t\t\t} else {\n\t\t\t\t\tdata[key] = decision;\n\t\t\t\t}\n\t\t\t}\n\t\t\twriteTrustFile(this.trustPath, data);\n\t\t});\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"domain-validator.d.ts","sourceRoot":"","sources":["../../src/gsd/domain-validator.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAuBjE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAIlG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWrD","sourcesContent":["// GSD Domain Validator — glossary extraction and domain naming validation.\n// Reads DOMAIN-MODEL.md (preferred) or DOMAIN.md as the glossary source of truth.\n// Used by draht-quality-gate.js and exported via @draht/coding-agent.\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n/**\n * Extract PascalCase glossary terms from an \"## Ubiquitous Language\" section.\n * Handles three formats:\n * - **Term** bold format\n * - - Term: list format\n * - | Term | table format\n */\nexport function extractGlossaryTerms(content: string): Set<string> {\n\tconst terms = new Set<string>();\n\tif (!content) return terms;\n\n\t// Extract only the Ubiquitous Language section (stop at next ## heading)\n\tconst sectionMatch = content.match(/## Ubiquitous Language([\\s\\S]*?)(?:\\n## |\\s*$)/);\n\tconst section = sectionMatch ? sectionMatch[1] : \"\";\n\tif (!section) return terms;\n\n\t// **PascalCase** bold format\n\tfor (const m of section.matchAll(/\\*\\*([A-Z][a-zA-Z0-9]+)\\*\\*/g)) {\n\t\tterms.add(m[1]);\n\t}\n\t// - PascalCase: list format\n\tfor (const m of section.matchAll(/^[-*]\\s+([A-Z][a-zA-Z0-9]+)\\s*:/gm)) {\n\t\tterms.add(m[1]);\n\t}\n\t// | PascalCase | table format\n\tfor (const m of section.matchAll(/\\|\\s*([A-Z][a-zA-Z0-9]+)\\s*\\|/g)) {\n\t\tterms.add(m[1]);\n\t}\n\n\treturn terms;\n}\n\n/**\n * Returns terms from candidateTerms that are not present in the glossary.\n */\nexport function validateDomainGlossary(glossaryContent: string, candidateTerms: string[]): string[] {\n\tif (candidateTerms.length === 0) return [];\n\tconst known = extractGlossaryTerms(glossaryContent);\n\treturn candidateTerms.filter((t) => !known.has(t));\n}\n\n/**\n * Load domain content from .planning/DOMAIN-MODEL.md (preferred) or DOMAIN.md.\n * Returns empty string if neither exists.\n */\nexport function loadDomainContent(cwd: string): string {\n\tconst planningDir = path.join(cwd, \".planning\");\n\tconst modelPath = path.join(planningDir, \"DOMAIN-MODEL.md\");\n\tif (fs.existsSync(modelPath)) {\n\t\treturn fs.readFileSync(modelPath, \"utf-8\");\n\t}\n\tconst domainPath = path.join(planningDir, \"DOMAIN.md\");\n\tif (fs.existsSync(domainPath)) {\n\t\treturn fs.readFileSync(domainPath, \"utf-8\");\n\t}\n\treturn \"\";\n}\n"]}
1
+ {"version":3,"file":"domain-validator.d.ts","sourceRoot":"","sources":["../../src/gsd/domain-validator.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAuBjE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAIlG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"domain-validator.js","sourceRoot":"","sources":["../../src/gsd/domain-validator.ts"],"names":[],"mappings":"AAAA,6EAA2E;AAC3E,kFAAkF;AAClF,sEAAsE;AAEtE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAe;IAClE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,yEAAyE;IACzE,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,6BAA6B;IAC7B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE,CAAC;QAClE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,4BAA4B;IAC5B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EAAE,CAAC;QACvE,KAAK,CAAC,GAAG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naming validation.\n// Reads DOMAIN-MODEL.md (preferred) or DOMAIN.md as the glossary source of truth.\n// Used by draht-quality-gate.js and exported via @draht/coding-agent.\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n/**\n * Extract PascalCase glossary terms from an \"## Ubiquitous Language\" section.\n * Handles three formats:\n * - **Term** bold format\n * - - Term: list format\n * - | Term | table format\n */\nexport function extractGlossaryTerms(content: string): Set<string> {\n\tconst terms = new Set<string>();\n\tif (!content) return terms;\n\n\t// Extract only the Ubiquitous Language section (stop at next ## heading)\n\tconst sectionMatch = content.match(/## Ubiquitous Language([\\s\\S]*?)(?:\\n## |\\s*$)/);\n\tconst section = sectionMatch ? sectionMatch[1] : \"\";\n\tif (!section) return terms;\n\n\t// **PascalCase** bold format\n\tfor (const m of section.matchAll(/\\*\\*([A-Z][a-zA-Z0-9]+)\\*\\*/g)) {\n\t\tterms.add(m[1]);\n\t}\n\t// - PascalCase: list format\n\tfor (const m of section.matchAll(/^[-*]\\s+([A-Z][a-zA-Z0-9]+)\\s*:/gm)) {\n\t\tterms.add(m[1]);\n\t}\n\t// | PascalCase | table format\n\tfor (const m of section.matchAll(/\\|\\s*([A-Z][a-zA-Z0-9]+)\\s*\\|/g)) {\n\t\tterms.add(m[1]);\n\t}\n\n\treturn terms;\n}\n\n/**\n * Returns terms from candidateTerms that are not present in the glossary.\n */\nexport function validateDomainGlossary(glossaryContent: string, candidateTerms: string[]): string[] {\n\tif (candidateTerms.length === 0) return [];\n\tconst known = extractGlossaryTerms(glossaryContent);\n\treturn candidateTerms.filter((t) => !known.has(t));\n}\n\n/**\n * Load domain content from .planning/DOMAIN-MODEL.md (preferred) or DOMAIN.md.\n * Returns empty string if neither exists.\n */\nexport function loadDomainContent(cwd: string): string {\n\tconst planningDir = path.join(cwd, \".planning\");\n\tconst modelPath = path.join(planningDir, \"DOMAIN-MODEL.md\");\n\tif (fs.existsSync(modelPath)) {\n\t\treturn fs.readFileSync(modelPath, \"utf-8\");\n\t}\n\tconst domainPath = path.join(planningDir, \"DOMAIN.md\");\n\tif (fs.existsSync(domainPath)) {\n\t\treturn fs.readFileSync(domainPath, \"utf-8\");\n\t}\n\treturn \"\";\n}\n"]}
1
+ {"version":3,"file":"domain-validator.js","sourceRoot":"","sources":["../../src/gsd/domain-validator.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,kFAAkF;AAClF,sEAAsE;AAEtE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IACnD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,yEAAyE;IACzE,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,6BAA6B;IAC7B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE,CAAC;QAClE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,4BAA4B;IAC5B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EAAE,CAAC;QACvE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,8BAA8B;IAC9B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,gCAAgC,CAAC,EAAE,CAAC;QACpE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,eAAuB,EAAE,cAAwB;IACvF,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;IACpD,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC5D,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACvD,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC","sourcesContent":["// GSD Domain Validator — glossary extraction and domain naming validation.\n// Reads DOMAIN-MODEL.md (preferred) or DOMAIN.md as the glossary source of truth.\n// Used by draht-quality-gate.js and exported via @draht/coding-agent.\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n/**\n * Extract PascalCase glossary terms from an \"## Ubiquitous Language\" section.\n * Handles three formats:\n * - **Term** bold format\n * - - Term: list format\n * - | Term | table format\n */\nexport function extractGlossaryTerms(content: string): Set<string> {\n\tconst terms = new Set<string>();\n\tif (!content) return terms;\n\n\t// Extract only the Ubiquitous Language section (stop at next ## heading)\n\tconst sectionMatch = content.match(/## Ubiquitous Language([\\s\\S]*?)(?:\\n## |\\s*$)/);\n\tconst section = sectionMatch ? sectionMatch[1] : \"\";\n\tif (!section) return terms;\n\n\t// **PascalCase** bold format\n\tfor (const m of section.matchAll(/\\*\\*([A-Z][a-zA-Z0-9]+)\\*\\*/g)) {\n\t\tterms.add(m[1]);\n\t}\n\t// - PascalCase: list format\n\tfor (const m of section.matchAll(/^[-*]\\s+([A-Z][a-zA-Z0-9]+)\\s*:/gm)) {\n\t\tterms.add(m[1]);\n\t}\n\t// | PascalCase | table format\n\tfor (const m of section.matchAll(/\\|\\s*([A-Z][a-zA-Z0-9]+)\\s*\\|/g)) {\n\t\tterms.add(m[1]);\n\t}\n\n\treturn terms;\n}\n\n/**\n * Returns terms from candidateTerms that are not present in the glossary.\n */\nexport function validateDomainGlossary(glossaryContent: string, candidateTerms: string[]): string[] {\n\tif (candidateTerms.length === 0) return [];\n\tconst known = extractGlossaryTerms(glossaryContent);\n\treturn candidateTerms.filter((t) => !known.has(t));\n}\n\n/**\n * Load domain content from .planning/DOMAIN-MODEL.md (preferred) or DOMAIN.md.\n * Returns empty string if neither exists.\n */\nexport function loadDomainContent(cwd: string): string {\n\tconst planningDir = path.join(cwd, \".planning\");\n\tconst modelPath = path.join(planningDir, \"DOMAIN-MODEL.md\");\n\tif (fs.existsSync(modelPath)) {\n\t\treturn fs.readFileSync(modelPath, \"utf-8\");\n\t}\n\tconst domainPath = path.join(planningDir, \"DOMAIN.md\");\n\tif (fs.existsSync(domainPath)) {\n\t\treturn fs.readFileSync(domainPath, \"utf-8\");\n\t}\n\treturn \"\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../src/gsd/domain.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,iBAAiB,GAAG,MAAM,EAAE,GAAG;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAsGF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAqCrD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAuF1D","sourcesContent":["// GSD Domain module — domain model and codebase mapping operations.\n// Part of the draht GSD (Get Shit Done) methodology.\n// Exported via src/gsd/index.ts and @draht/coding-agent.\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst PLANNING = \".planning\";\nconst VALUE_OBJECT_NAME = /(Address|Amount|Code|Email|Id|Identifier|Key|Money|Price|Value)$/;\n\nexport type MapCodebaseResult = string[] & {\n\tentities: string[];\n\tvalueObjects: string[];\n};\n\nfunction planningPath(cwd: string, ...segments: string[]): string {\n\treturn path.join(cwd, PLANNING, ...segments);\n}\n\nfunction ensureDir(dir: string): void {\n\tif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\nfunction ensureCodebaseExists(cwd: string): void {\n\tif (!fs.existsSync(cwd)) {\n\t\tthrow new Error(`Codebase path does not exist: ${cwd}`);\n\t}\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n}\n\nfunction toRelativeCodePath(cwd: string, filePath: string): string {\n\treturn path.relative(cwd, filePath).split(path.sep).join(\"/\");\n}\n\nfunction listCodeFiles(cwd: string): string[] {\n\tconst codeFiles: string[] = [];\n\tconst ignoredDirs = new Set([\".git\", \".planning\", \"dist\", \"node_modules\"]);\n\tconst pendingDirs = [cwd];\n\n\twhile (pendingDirs.length > 0) {\n\t\tconst currentDir = pendingDirs.pop();\n\t\tif (!currentDir) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst entryPath = path.join(currentDir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (!ignoredDirs.has(entry.name)) {\n\t\t\t\t\tpendingDirs.push(entryPath);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && /\\.(go|ts)$/.test(entry.name)) {\n\t\t\t\tcodeFiles.push(entryPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn codeFiles.sort((left, right) => toRelativeCodePath(cwd, left).localeCompare(toRelativeCodePath(cwd, right)));\n}\n\nfunction extractExportedTerms(fileContent: string): string[] {\n\tconst terms = new Set<string>();\n\tconst exportPattern = /export\\s+(?:interface|type|class)\\s+([A-Z][A-Za-z0-9_]*)/g;\n\n\tfor (const match of fileContent.matchAll(exportPattern)) {\n\t\tterms.add(match[1]);\n\t}\n\n\treturn [...terms].sort((left, right) => left.localeCompare(right));\n}\n\nfunction classifyTerms(terms: string[]): { entities: string[]; valueObjects: string[] } {\n\tconst entities: string[] = [];\n\tconst valueObjects: string[] = [];\n\n\tfor (const term of terms) {\n\t\tif (VALUE_OBJECT_NAME.test(term)) {\n\t\t\tvalueObjects.push(term);\n\t\t\tcontinue;\n\t\t}\n\n\t\tentities.push(term);\n\t}\n\n\treturn { entities, valueObjects };\n}\n\nfunction scanStructuredDomainTerms(cwd: string): { entities: string[]; valueObjects: string[] } {\n\tconst uniqueTerms = new Set<string>();\n\n\tfor (const filePath of listCodeFiles(cwd)) {\n\t\tconst fileContent = fs.readFileSync(filePath, \"utf-8\");\n\t\tfor (const term of extractExportedTerms(fileContent)) {\n\t\t\tuniqueTerms.add(term);\n\t\t}\n\t}\n\n\tconst sortedTerms = [...uniqueTerms].sort((left, right) => left.localeCompare(right));\n\treturn classifyTerms(sortedTerms);\n}\n\nfunction attachStructuredDomainTerms(\n\tfiles: string[],\n\tstructuredTerms: { entities: string[]; valueObjects: string[] },\n): MapCodebaseResult {\n\treturn Object.assign(files, structuredTerms);\n}\n\n/**\n * Generate a DOMAIN-MODEL.md scaffold from PROJECT.md.\n * Requires .planning/PROJECT.md to exist.\n * Returns the path to the created file.\n */\nexport function createDomainModel(cwd: string): string {\n\tconst projectPath = planningPath(cwd, \"PROJECT.md\");\n\tif (!fs.existsSync(projectPath)) {\n\t\tthrow new Error(\"No PROJECT.md found — run create-project first\");\n\t}\n\n\tconst outPath = planningPath(cwd, \"DOMAIN-MODEL.md\");\n\tconst tmpl = `# Domain Model\n\n## Bounded Contexts\n[Extract from PROJECT.md — identify distinct areas of responsibility]\n\n## Context Map\n[How bounded contexts interact — upstream/downstream, shared kernel, etc.]\n\n## Entities\n[Core domain objects with identity]\n\n## Value Objects\n[Immutable objects defined by attributes]\n\n## Aggregates\n[Cluster of entities with a root — transactional boundary]\n\n## Domain Events\n[Things that happen in the domain]\n\n## Ubiquitous Language Glossary\n| Term | Context | Definition |\n|------|---------|------------|\n| [term] | [context] | [definition] |\n\n---\nGenerated from PROJECT.md: ${timestamp()}\n`;\n\tfs.writeFileSync(outPath, tmpl, \"utf-8\");\n\treturn outPath;\n}\n\n/**\n * Scan the codebase and write .planning/codebase/ analysis files.\n * Returns array of created file paths.\n */\nexport function mapCodebase(cwd: string): MapCodebaseResult {\n\tensureCodebaseExists(cwd);\n\n\tconst outDir = planningPath(cwd, \"codebase\");\n\tensureDir(outDir);\n\tconst structuredTerms = scanStructuredDomainTerms(cwd);\n\n\t// Gather file tree\n\tlet tree = \"\";\n\ttry {\n\t\ttree = execSync(\n\t\t\t`find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/.planning/*' | head -200`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t);\n\t} catch {\n\t\ttree = \"(unable to list files)\";\n\t}\n\n\t// Gather package info\n\tlet pkgJson: {\n\t\tname?: string;\n\t\tdependencies?: Record<string, string>;\n\t\tdevDependencies?: Record<string, string>;\n\t} | null = null;\n\ttry {\n\t\tpkgJson = JSON.parse(fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"));\n\t} catch {\n\t\t// not a Node.js project\n\t}\n\n\tconst stackPath = path.join(outDir, \"STACK.md\");\n\tfs.writeFileSync(\n\t\tstackPath,\n\t\t`# Technology Stack\\n\\nGenerated: ${timestamp()}\\n\\n## File Tree (first 200 files)\\n\\`\\`\\`\\n${tree}\\`\\`\\`\\n\\n## Package Info\\n\\`\\`\\`json\\n${pkgJson ? JSON.stringify({ name: pkgJson.name, dependencies: pkgJson.dependencies, devDependencies: pkgJson.devDependencies }, null, 2) : \"No package.json found\"}\\n\\`\\`\\`\\n\\n## TODO\\n- [ ] Fill in languages, versions, frameworks\\n- [ ] Document build tools and runtime\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst archPath = path.join(outDir, \"ARCHITECTURE.md\");\n\tfs.writeFileSync(\n\t\tarchPath,\n\t\t`# Architecture\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Document file/directory patterns\\n- [ ] Map module boundaries\\n- [ ] Describe data flow\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst convPath = path.join(outDir, \"CONVENTIONS.md\");\n\tfs.writeFileSync(\n\t\tconvPath,\n\t\t`# Conventions\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Document code style patterns\\n- [ ] Document testing patterns\\n- [ ] Document error handling approach\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst concernsPath = path.join(outDir, \"CONCERNS.md\");\n\tfs.writeFileSync(\n\t\tconcernsPath,\n\t\t`# Concerns\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Identify technical debt\\n- [ ] Flag security concerns\\n- [ ] Note missing tests\\n`,\n\t\t\"utf-8\",\n\t);\n\n\t// Domain model extraction\n\tlet domainHints = \"\";\n\ttry {\n\t\tconst types = execSync(\n\t\t\t`grep -rn 'export\\\\s\\\\+\\\\(interface\\\\|type\\\\|class\\\\)' --include='*.ts' --include='*.go' . 2>/dev/null | grep -v node_modules | grep -v dist | head -50`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t).trim();\n\t\tif (types) domainHints += `## Types/Interfaces (potential entities)\\n\\`\\`\\`\\n${types}\\n\\`\\`\\`\\n\\n`;\n\t} catch {\n\t\t// no ts/go files\n\t}\n\ttry {\n\t\tconst dirs = execSync(\n\t\t\t`find . -type d -maxdepth 3 -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' | sort`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t).trim();\n\t\tif (dirs) domainHints += `## Directory Structure (potential bounded contexts)\\n\\`\\`\\`\\n${dirs}\\n\\`\\`\\`\\n`;\n\t} catch {\n\t\t// ignore\n\t}\n\n\tconst hintsPath = path.join(outDir, \"DOMAIN-HINTS.md\");\n\tfs.writeFileSync(\n\t\thintsPath,\n\t\t`# Domain Model Hints\\n\\nGenerated: ${timestamp()}\\n\\nExtracted from codebase to help identify domain model.\\n\\n${domainHints}\\n## TODO\\n- [ ] Identify entities vs value objects\\n- [ ] Map bounded contexts from directory structure\\n- [ ] Define ubiquitous language glossary\\n`,\n\t\t\"utf-8\",\n\t);\n\n\treturn attachStructuredDomainTerms([stackPath, archPath, convPath, concernsPath, hintsPath], structuredTerms);\n}\n"]}
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../src/gsd/domain.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,iBAAiB,GAAG,MAAM,EAAE,GAAG;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAsGF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAqCrD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAuF1D"}
@@ -1 +1 @@
1
- {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AC,CAAC;IACtD,EAAE,CAAC,aAAa,CACf,YAAY,EACZ,4BAA4B,SAAS,EAAE,sGAAsG,EAC7I,OAAO,CACP,CAAC;IAEF,0BAA0B;IAC1B,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,QAAQ,CACrB,wJAAwJ,EACxJ,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,CAC1B,CAAC,IAAI,EAAE,CAAC;QACT,IAAI,KAAK;YAAE,WAAW,IAAI,qDAAqD,KAAK,cAAc,CAAC;IACpG,CAAC;IAAC,MAAM,CAAC;QACR,iBAAiB;IAClB,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,QAAQ,CACpB,6GAA6G,EAC7G,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,CAC1B,CAAC,IAAI,EAAE,CAAC;QACT,IAAI,IAAI;YAAE,WAAW,IAAI,gEAAgE,IAAI,YAAY,CAAC;IAC3G,CAAC;IAAC,MAAM,CAAC;QACR,SAAS;IACV,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACvD,EAAE,CAAC,aAAa,CACf,SAAS,EACT,sCAAsC,SAAS,EAAE,iEAAiE,WAAW,uJAAuJ,EACpR,OAAO,CACP,CAAC;IAEF,OAAO,2BAA2B,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC;AAAA,CAC9G","sourcesContent":["// GSD Domain module — domain model and codebase mapping operations.\n// Part of the draht GSD (Get Shit Done) methodology.\n// Exported via src/gsd/index.ts and @draht/coding-agent.\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst PLANNING = \".planning\";\nconst VALUE_OBJECT_NAME = /(Address|Amount|Code|Email|Id|Identifier|Key|Money|Price|Value)$/;\n\nexport type MapCodebaseResult = string[] & {\n\tentities: string[];\n\tvalueObjects: string[];\n};\n\nfunction planningPath(cwd: string, ...segments: string[]): string {\n\treturn path.join(cwd, PLANNING, ...segments);\n}\n\nfunction ensureDir(dir: string): void {\n\tif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\nfunction ensureCodebaseExists(cwd: string): void {\n\tif (!fs.existsSync(cwd)) {\n\t\tthrow new Error(`Codebase path does not exist: ${cwd}`);\n\t}\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n}\n\nfunction toRelativeCodePath(cwd: string, filePath: string): string {\n\treturn path.relative(cwd, filePath).split(path.sep).join(\"/\");\n}\n\nfunction listCodeFiles(cwd: string): string[] {\n\tconst codeFiles: string[] = [];\n\tconst ignoredDirs = new Set([\".git\", \".planning\", \"dist\", \"node_modules\"]);\n\tconst pendingDirs = [cwd];\n\n\twhile (pendingDirs.length > 0) {\n\t\tconst currentDir = pendingDirs.pop();\n\t\tif (!currentDir) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst entryPath = path.join(currentDir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (!ignoredDirs.has(entry.name)) {\n\t\t\t\t\tpendingDirs.push(entryPath);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && /\\.(go|ts)$/.test(entry.name)) {\n\t\t\t\tcodeFiles.push(entryPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn codeFiles.sort((left, right) => toRelativeCodePath(cwd, left).localeCompare(toRelativeCodePath(cwd, right)));\n}\n\nfunction extractExportedTerms(fileContent: string): string[] {\n\tconst terms = new Set<string>();\n\tconst exportPattern = /export\\s+(?:interface|type|class)\\s+([A-Z][A-Za-z0-9_]*)/g;\n\n\tfor (const match of fileContent.matchAll(exportPattern)) {\n\t\tterms.add(match[1]);\n\t}\n\n\treturn [...terms].sort((left, right) => left.localeCompare(right));\n}\n\nfunction classifyTerms(terms: string[]): { entities: string[]; valueObjects: string[] } {\n\tconst entities: string[] = [];\n\tconst valueObjects: string[] = [];\n\n\tfor (const term of terms) {\n\t\tif (VALUE_OBJECT_NAME.test(term)) {\n\t\t\tvalueObjects.push(term);\n\t\t\tcontinue;\n\t\t}\n\n\t\tentities.push(term);\n\t}\n\n\treturn { entities, valueObjects };\n}\n\nfunction scanStructuredDomainTerms(cwd: string): { entities: string[]; valueObjects: string[] } {\n\tconst uniqueTerms = new Set<string>();\n\n\tfor (const filePath of listCodeFiles(cwd)) {\n\t\tconst fileContent = fs.readFileSync(filePath, \"utf-8\");\n\t\tfor (const term of extractExportedTerms(fileContent)) {\n\t\t\tuniqueTerms.add(term);\n\t\t}\n\t}\n\n\tconst sortedTerms = [...uniqueTerms].sort((left, right) => left.localeCompare(right));\n\treturn classifyTerms(sortedTerms);\n}\n\nfunction attachStructuredDomainTerms(\n\tfiles: string[],\n\tstructuredTerms: { entities: string[]; valueObjects: string[] },\n): MapCodebaseResult {\n\treturn Object.assign(files, structuredTerms);\n}\n\n/**\n * Generate a DOMAIN-MODEL.md scaffold from PROJECT.md.\n * Requires .planning/PROJECT.md to exist.\n * Returns the path to the created file.\n */\nexport function createDomainModel(cwd: string): string {\n\tconst projectPath = planningPath(cwd, \"PROJECT.md\");\n\tif (!fs.existsSync(projectPath)) {\n\t\tthrow new Error(\"No PROJECT.md found — run create-project first\");\n\t}\n\n\tconst outPath = planningPath(cwd, \"DOMAIN-MODEL.md\");\n\tconst tmpl = `# Domain Model\n\n## Bounded Contexts\n[Extract from PROJECT.md — identify distinct areas of responsibility]\n\n## Context Map\n[How bounded contexts interact — upstream/downstream, shared kernel, etc.]\n\n## Entities\n[Core domain objects with identity]\n\n## Value Objects\n[Immutable objects defined by attributes]\n\n## Aggregates\n[Cluster of entities with a root — transactional boundary]\n\n## Domain Events\n[Things that happen in the domain]\n\n## Ubiquitous Language Glossary\n| Term | Context | Definition |\n|------|---------|------------|\n| [term] | [context] | [definition] |\n\n---\nGenerated from PROJECT.md: ${timestamp()}\n`;\n\tfs.writeFileSync(outPath, tmpl, \"utf-8\");\n\treturn outPath;\n}\n\n/**\n * Scan the codebase and write .planning/codebase/ analysis files.\n * Returns array of created file paths.\n */\nexport function mapCodebase(cwd: string): MapCodebaseResult {\n\tensureCodebaseExists(cwd);\n\n\tconst outDir = planningPath(cwd, \"codebase\");\n\tensureDir(outDir);\n\tconst structuredTerms = scanStructuredDomainTerms(cwd);\n\n\t// Gather file tree\n\tlet tree = \"\";\n\ttry {\n\t\ttree = execSync(\n\t\t\t`find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/.planning/*' | head -200`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t);\n\t} catch {\n\t\ttree = \"(unable to list files)\";\n\t}\n\n\t// Gather package info\n\tlet pkgJson: {\n\t\tname?: string;\n\t\tdependencies?: Record<string, string>;\n\t\tdevDependencies?: Record<string, string>;\n\t} | null = null;\n\ttry {\n\t\tpkgJson = JSON.parse(fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"));\n\t} catch {\n\t\t// not a Node.js project\n\t}\n\n\tconst stackPath = path.join(outDir, \"STACK.md\");\n\tfs.writeFileSync(\n\t\tstackPath,\n\t\t`# Technology Stack\\n\\nGenerated: ${timestamp()}\\n\\n## File Tree (first 200 files)\\n\\`\\`\\`\\n${tree}\\`\\`\\`\\n\\n## Package Info\\n\\`\\`\\`json\\n${pkgJson ? JSON.stringify({ name: pkgJson.name, dependencies: pkgJson.dependencies, devDependencies: pkgJson.devDependencies }, null, 2) : \"No package.json found\"}\\n\\`\\`\\`\\n\\n## TODO\\n- [ ] Fill in languages, versions, frameworks\\n- [ ] Document build tools and runtime\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst archPath = path.join(outDir, \"ARCHITECTURE.md\");\n\tfs.writeFileSync(\n\t\tarchPath,\n\t\t`# Architecture\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Document file/directory patterns\\n- [ ] Map module boundaries\\n- [ ] Describe data flow\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst convPath = path.join(outDir, \"CONVENTIONS.md\");\n\tfs.writeFileSync(\n\t\tconvPath,\n\t\t`# Conventions\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Document code style patterns\\n- [ ] Document testing patterns\\n- [ ] Document error handling approach\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst concernsPath = path.join(outDir, \"CONCERNS.md\");\n\tfs.writeFileSync(\n\t\tconcernsPath,\n\t\t`# Concerns\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Identify technical debt\\n- [ ] Flag security concerns\\n- [ ] Note missing tests\\n`,\n\t\t\"utf-8\",\n\t);\n\n\t// Domain model extraction\n\tlet domainHints = \"\";\n\ttry {\n\t\tconst types = execSync(\n\t\t\t`grep -rn 'export\\\\s\\\\+\\\\(interface\\\\|type\\\\|class\\\\)' --include='*.ts' --include='*.go' . 2>/dev/null | grep -v node_modules | grep -v dist | head -50`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t).trim();\n\t\tif (types) domainHints += `## Types/Interfaces (potential entities)\\n\\`\\`\\`\\n${types}\\n\\`\\`\\`\\n\\n`;\n\t} catch {\n\t\t// no ts/go files\n\t}\n\ttry {\n\t\tconst dirs = execSync(\n\t\t\t`find . -type d -maxdepth 3 -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' | sort`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t).trim();\n\t\tif (dirs) domainHints += `## Directory Structure (potential bounded contexts)\\n\\`\\`\\`\\n${dirs}\\n\\`\\`\\`\\n`;\n\t} catch {\n\t\t// ignore\n\t}\n\n\tconst hintsPath = path.join(outDir, \"DOMAIN-HINTS.md\");\n\tfs.writeFileSync(\n\t\thintsPath,\n\t\t`# Domain Model Hints\\n\\nGenerated: ${timestamp()}\\n\\nExtracted from codebase to help identify domain model.\\n\\n${domainHints}\\n## TODO\\n- [ ] Identify entities vs value objects\\n- [ ] Map bounded contexts from directory structure\\n- [ ] Define ubiquitous language glossary\\n`,\n\t\t\"utf-8\",\n\t);\n\n\treturn attachStructuredDomainTerms([stackPath, archPath, convPath, concernsPath, hintsPath], structuredTerms);\n}\n"]}
1
+ {"version":3,"file":"domain.js","sourceRoot":"","sources":["../../src/gsd/domain.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qDAAqD;AACrD,yDAAyD;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAC7B,MAAM,iBAAiB,GAAG,kEAAkE,CAAC;AAO7F,SAAS,YAAY,CAAC,GAAW,EAAE,GAAG,QAAkB;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC7B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAW;IACxC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC;AACF,CAAC;AAED,SAAS,SAAS;IACjB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OA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C","sourcesContent":["// GSD Domain module — domain model and codebase mapping operations.\n// Part of the draht GSD (Get Shit Done) methodology.\n// Exported via src/gsd/index.ts and @draht/coding-agent.\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst PLANNING = \".planning\";\nconst VALUE_OBJECT_NAME = /(Address|Amount|Code|Email|Id|Identifier|Key|Money|Price|Value)$/;\n\nexport type MapCodebaseResult = string[] & {\n\tentities: string[];\n\tvalueObjects: string[];\n};\n\nfunction planningPath(cwd: string, ...segments: string[]): string {\n\treturn path.join(cwd, PLANNING, ...segments);\n}\n\nfunction ensureDir(dir: string): void {\n\tif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\nfunction ensureCodebaseExists(cwd: string): void {\n\tif (!fs.existsSync(cwd)) {\n\t\tthrow new Error(`Codebase path does not exist: ${cwd}`);\n\t}\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n}\n\nfunction toRelativeCodePath(cwd: string, filePath: string): string {\n\treturn path.relative(cwd, filePath).split(path.sep).join(\"/\");\n}\n\nfunction listCodeFiles(cwd: string): string[] {\n\tconst codeFiles: string[] = [];\n\tconst ignoredDirs = new Set([\".git\", \".planning\", \"dist\", \"node_modules\"]);\n\tconst pendingDirs = [cwd];\n\n\twhile (pendingDirs.length > 0) {\n\t\tconst currentDir = pendingDirs.pop();\n\t\tif (!currentDir) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst entryPath = path.join(currentDir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (!ignoredDirs.has(entry.name)) {\n\t\t\t\t\tpendingDirs.push(entryPath);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && /\\.(go|ts)$/.test(entry.name)) {\n\t\t\t\tcodeFiles.push(entryPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn codeFiles.sort((left, right) => toRelativeCodePath(cwd, left).localeCompare(toRelativeCodePath(cwd, right)));\n}\n\nfunction extractExportedTerms(fileContent: string): string[] {\n\tconst terms = new Set<string>();\n\tconst exportPattern = /export\\s+(?:interface|type|class)\\s+([A-Z][A-Za-z0-9_]*)/g;\n\n\tfor (const match of fileContent.matchAll(exportPattern)) {\n\t\tterms.add(match[1]);\n\t}\n\n\treturn [...terms].sort((left, right) => left.localeCompare(right));\n}\n\nfunction classifyTerms(terms: string[]): { entities: string[]; valueObjects: string[] } {\n\tconst entities: string[] = [];\n\tconst valueObjects: string[] = [];\n\n\tfor (const term of terms) {\n\t\tif (VALUE_OBJECT_NAME.test(term)) {\n\t\t\tvalueObjects.push(term);\n\t\t\tcontinue;\n\t\t}\n\n\t\tentities.push(term);\n\t}\n\n\treturn { entities, valueObjects };\n}\n\nfunction scanStructuredDomainTerms(cwd: string): { entities: string[]; valueObjects: string[] } {\n\tconst uniqueTerms = new Set<string>();\n\n\tfor (const filePath of listCodeFiles(cwd)) {\n\t\tconst fileContent = fs.readFileSync(filePath, \"utf-8\");\n\t\tfor (const term of extractExportedTerms(fileContent)) {\n\t\t\tuniqueTerms.add(term);\n\t\t}\n\t}\n\n\tconst sortedTerms = [...uniqueTerms].sort((left, right) => left.localeCompare(right));\n\treturn classifyTerms(sortedTerms);\n}\n\nfunction attachStructuredDomainTerms(\n\tfiles: string[],\n\tstructuredTerms: { entities: string[]; valueObjects: string[] },\n): MapCodebaseResult {\n\treturn Object.assign(files, structuredTerms);\n}\n\n/**\n * Generate a DOMAIN-MODEL.md scaffold from PROJECT.md.\n * Requires .planning/PROJECT.md to exist.\n * Returns the path to the created file.\n */\nexport function createDomainModel(cwd: string): string {\n\tconst projectPath = planningPath(cwd, \"PROJECT.md\");\n\tif (!fs.existsSync(projectPath)) {\n\t\tthrow new Error(\"No PROJECT.md found — run create-project first\");\n\t}\n\n\tconst outPath = planningPath(cwd, \"DOMAIN-MODEL.md\");\n\tconst tmpl = `# Domain Model\n\n## Bounded Contexts\n[Extract from PROJECT.md — identify distinct areas of responsibility]\n\n## Context Map\n[How bounded contexts interact — upstream/downstream, shared kernel, etc.]\n\n## Entities\n[Core domain objects with identity]\n\n## Value Objects\n[Immutable objects defined by attributes]\n\n## Aggregates\n[Cluster of entities with a root — transactional boundary]\n\n## Domain Events\n[Things that happen in the domain]\n\n## Ubiquitous Language Glossary\n| Term | Context | Definition |\n|------|---------|------------|\n| [term] | [context] | [definition] |\n\n---\nGenerated from PROJECT.md: ${timestamp()}\n`;\n\tfs.writeFileSync(outPath, tmpl, \"utf-8\");\n\treturn outPath;\n}\n\n/**\n * Scan the codebase and write .planning/codebase/ analysis files.\n * Returns array of created file paths.\n */\nexport function mapCodebase(cwd: string): MapCodebaseResult {\n\tensureCodebaseExists(cwd);\n\n\tconst outDir = planningPath(cwd, \"codebase\");\n\tensureDir(outDir);\n\tconst structuredTerms = scanStructuredDomainTerms(cwd);\n\n\t// Gather file tree\n\tlet tree = \"\";\n\ttry {\n\t\ttree = execSync(\n\t\t\t`find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/.planning/*' | head -200`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t);\n\t} catch {\n\t\ttree = \"(unable to list files)\";\n\t}\n\n\t// Gather package info\n\tlet pkgJson: {\n\t\tname?: string;\n\t\tdependencies?: Record<string, string>;\n\t\tdevDependencies?: Record<string, string>;\n\t} | null = null;\n\ttry {\n\t\tpkgJson = JSON.parse(fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"));\n\t} catch {\n\t\t// not a Node.js project\n\t}\n\n\tconst stackPath = path.join(outDir, \"STACK.md\");\n\tfs.writeFileSync(\n\t\tstackPath,\n\t\t`# Technology Stack\\n\\nGenerated: ${timestamp()}\\n\\n## File Tree (first 200 files)\\n\\`\\`\\`\\n${tree}\\`\\`\\`\\n\\n## Package Info\\n\\`\\`\\`json\\n${pkgJson ? JSON.stringify({ name: pkgJson.name, dependencies: pkgJson.dependencies, devDependencies: pkgJson.devDependencies }, null, 2) : \"No package.json found\"}\\n\\`\\`\\`\\n\\n## TODO\\n- [ ] Fill in languages, versions, frameworks\\n- [ ] Document build tools and runtime\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst archPath = path.join(outDir, \"ARCHITECTURE.md\");\n\tfs.writeFileSync(\n\t\tarchPath,\n\t\t`# Architecture\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Document file/directory patterns\\n- [ ] Map module boundaries\\n- [ ] Describe data flow\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst convPath = path.join(outDir, \"CONVENTIONS.md\");\n\tfs.writeFileSync(\n\t\tconvPath,\n\t\t`# Conventions\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Document code style patterns\\n- [ ] Document testing patterns\\n- [ ] Document error handling approach\\n`,\n\t\t\"utf-8\",\n\t);\n\n\tconst concernsPath = path.join(outDir, \"CONCERNS.md\");\n\tfs.writeFileSync(\n\t\tconcernsPath,\n\t\t`# Concerns\\n\\nGenerated: ${timestamp()}\\n\\n## TODO\\n- [ ] Identify technical debt\\n- [ ] Flag security concerns\\n- [ ] Note missing tests\\n`,\n\t\t\"utf-8\",\n\t);\n\n\t// Domain model extraction\n\tlet domainHints = \"\";\n\ttry {\n\t\tconst types = execSync(\n\t\t\t`grep -rn 'export\\\\s\\\\+\\\\(interface\\\\|type\\\\|class\\\\)' --include='*.ts' --include='*.go' . 2>/dev/null | grep -v node_modules | grep -v dist | head -50`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t).trim();\n\t\tif (types) domainHints += `## Types/Interfaces (potential entities)\\n\\`\\`\\`\\n${types}\\n\\`\\`\\`\\n\\n`;\n\t} catch {\n\t\t// no ts/go files\n\t}\n\ttry {\n\t\tconst dirs = execSync(\n\t\t\t`find . -type d -maxdepth 3 -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' | sort`,\n\t\t\t{ cwd, encoding: \"utf-8\" },\n\t\t).trim();\n\t\tif (dirs) domainHints += `## Directory Structure (potential bounded contexts)\\n\\`\\`\\`\\n${dirs}\\n\\`\\`\\`\\n`;\n\t} catch {\n\t\t// ignore\n\t}\n\n\tconst hintsPath = path.join(outDir, \"DOMAIN-HINTS.md\");\n\tfs.writeFileSync(\n\t\thintsPath,\n\t\t`# Domain Model Hints\\n\\nGenerated: ${timestamp()}\\n\\nExtracted from codebase to help identify domain model.\\n\\n${domainHints}\\n## TODO\\n- [ ] Identify entities vs value objects\\n- [ ] Map bounded contexts from directory structure\\n- [ ] Define ubiquitous language glossary\\n`,\n\t\t\"utf-8\",\n\t);\n\n\treturn attachStructuredDomainTerms([stackPath, archPath, convPath, concernsPath, hintsPath], structuredTerms);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/gsd/git.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAoBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAgC5G;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAUrE","sourcesContent":["// GSD Git module — git commit operations for the GSD lifecycle.\n// Part of the draht GSD (Get Shit Done) methodology.\n// Exported via src/gsd/index.ts and @draht/coding-agent.\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface CommitResult {\n\thash: string | null;\n\ttddWarning: boolean;\n}\n\ninterface ExecutionLogEntry {\n\tcommit: string;\n\tphase: number;\n\tplan: number;\n\tstatus: \"pass\" | \"tdd-violation\";\n\ttask: number;\n\ttimestamp: string;\n}\n\nfunction appendExecutionLog(cwd: string, entry: ExecutionLogEntry): void {\n\tconst planningDir = path.join(cwd, \".planning\");\n\tif (!fs.existsSync(planningDir)) {\n\t\treturn;\n\t}\n\tconst logPath = path.join(planningDir, \"execution-log.jsonl\");\n\tfs.appendFileSync(logPath, `${JSON.stringify(entry)}\\n`, \"utf-8\");\n}\n\n/**\n * Returns true if any file in the list matches known test file patterns.\n */\nexport function hasTestFiles(files: string[]): boolean {\n\treturn files.some((f) => /\\.(test|spec)\\.(ts|tsx|js|jsx)$|_test\\.(go|ts)$/.test(f));\n}\n\n/**\n * Stage all changes and commit as a task in the GSD methodology.\n * Message format: feat(NN-NN): description\n * Sets tddWarning=true when no test files are in the commit.\n */\nexport function commitTask(cwd: string, phaseNum: number, planNum: number, description: string): CommitResult {\n\tconst scope = `${String(phaseNum).padStart(2, \"0\")}-${String(planNum).padStart(2, \"0\")}`;\n\tconst message = `feat(${scope}): ${description}`;\n\ttry {\n\t\texecSync(\"git add -A\", { cwd, stdio: \"pipe\" });\n\t\texecSync(`git commit -m ${JSON.stringify(message)}`, { cwd, stdio: \"pipe\" });\n\t\tconst hash = execSync(\"git rev-parse HEAD\", { cwd, encoding: \"utf-8\" }).trim();\n\t\tlet tddWarning = false;\n\t\ttry {\n\t\t\tconst files = execSync(`git diff-tree --no-commit-id --name-only -r ${hash}`, {\n\t\t\t\tcwd,\n\t\t\t\tencoding: \"utf-8\",\n\t\t\t})\n\t\t\t\t.trim()\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.filter(Boolean);\n\t\t\ttddWarning = !hasTestFiles(files);\n\t\t} catch {\n\t\t\t// not a git repo or commit not found\n\t\t}\n\t\tappendExecutionLog(cwd, {\n\t\t\tcommit: hash,\n\t\t\tphase: phaseNum,\n\t\t\tplan: planNum,\n\t\t\tstatus: tddWarning ? \"tdd-violation\" : \"pass\",\n\t\t\ttask: 1,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t});\n\t\treturn { hash, tddWarning };\n\t} catch {\n\t\treturn { hash: null, tddWarning: false };\n\t}\n}\n\n/**\n * Stage all changes and commit as a docs update.\n * Message format: docs: message\n */\nexport function commitDocs(cwd: string, message: string): CommitResult {\n\tconst msg = `docs: ${message}`;\n\ttry {\n\t\texecSync(\"git add -A\", { cwd, stdio: \"pipe\" });\n\t\texecSync(`git commit -m ${JSON.stringify(msg)}`, { cwd, stdio: \"pipe\" });\n\t\tconst hash = execSync(\"git rev-parse HEAD\", { cwd, encoding: \"utf-8\" }).trim();\n\t\treturn { hash, tddWarning: false };\n\t} catch {\n\t\treturn { hash: null, tddWarning: false };\n\t}\n}\n"]}
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/gsd/git.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAoBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAgC5G;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAUrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/gsd/git.ts"],"names":[],"mappings":"AAAA,kEAAgE;AAChE,qDAAqD;AACrD,yDAAyD;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,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iBAAiB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACzE,MAAM,IAAI,GAAG,QAAQ,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;AAAA,CACD","sourcesContent":["// GSD Git module — git commit operations for the GSD lifecycle.\n// Part of the draht GSD (Get Shit Done) methodology.\n// Exported via src/gsd/index.ts and @draht/coding-agent.\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface CommitResult {\n\thash: string | null;\n\ttddWarning: boolean;\n}\n\ninterface ExecutionLogEntry {\n\tcommit: string;\n\tphase: number;\n\tplan: number;\n\tstatus: \"pass\" | \"tdd-violation\";\n\ttask: number;\n\ttimestamp: string;\n}\n\nfunction appendExecutionLog(cwd: string, entry: ExecutionLogEntry): void {\n\tconst planningDir = path.join(cwd, \".planning\");\n\tif (!fs.existsSync(planningDir)) {\n\t\treturn;\n\t}\n\tconst logPath = path.join(planningDir, \"execution-log.jsonl\");\n\tfs.appendFileSync(logPath, `${JSON.stringify(entry)}\\n`, \"utf-8\");\n}\n\n/**\n * Returns true if any file in the list matches known test file patterns.\n */\nexport function hasTestFiles(files: string[]): boolean {\n\treturn files.some((f) => /\\.(test|spec)\\.(ts|tsx|js|jsx)$|_test\\.(go|ts)$/.test(f));\n}\n\n/**\n * Stage all changes and commit as a task in the GSD methodology.\n * Message format: feat(NN-NN): description\n * Sets tddWarning=true when no test files are in the commit.\n */\nexport function commitTask(cwd: string, phaseNum: number, planNum: number, description: string): CommitResult {\n\tconst scope = `${String(phaseNum).padStart(2, \"0\")}-${String(planNum).padStart(2, \"0\")}`;\n\tconst message = `feat(${scope}): ${description}`;\n\ttry {\n\t\texecSync(\"git add -A\", { cwd, stdio: \"pipe\" });\n\t\texecSync(`git commit -m ${JSON.stringify(message)}`, { cwd, stdio: \"pipe\" });\n\t\tconst hash = execSync(\"git rev-parse HEAD\", { cwd, encoding: \"utf-8\" }).trim();\n\t\tlet tddWarning = false;\n\t\ttry {\n\t\t\tconst files = execSync(`git diff-tree --no-commit-id --name-only -r ${hash}`, {\n\t\t\t\tcwd,\n\t\t\t\tencoding: \"utf-8\",\n\t\t\t})\n\t\t\t\t.trim()\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.filter(Boolean);\n\t\t\ttddWarning = !hasTestFiles(files);\n\t\t} catch {\n\t\t\t// not a git repo or commit not found\n\t\t}\n\t\tappendExecutionLog(cwd, {\n\t\t\tcommit: hash,\n\t\t\tphase: phaseNum,\n\t\t\tplan: planNum,\n\t\t\tstatus: tddWarning ? \"tdd-violation\" : \"pass\",\n\t\t\ttask: 1,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t});\n\t\treturn { hash, tddWarning };\n\t} catch {\n\t\treturn { hash: null, tddWarning: false };\n\t}\n}\n\n/**\n * Stage all changes and commit as a docs update.\n * Message format: docs: message\n */\nexport function commitDocs(cwd: string, message: string): CommitResult {\n\tconst msg = `docs: ${message}`;\n\ttry {\n\t\texecSync(\"git add -A\", { cwd, stdio: \"pipe\" });\n\t\texecSync(`git commit -m ${JSON.stringify(msg)}`, { cwd, stdio: \"pipe\" });\n\t\tconst hash = execSync(\"git rev-parse HEAD\", { cwd, encoding: \"utf-8\" }).trim();\n\t\treturn { hash, tddWarning: false };\n\t} catch {\n\t\treturn { hash: null, tddWarning: false };\n\t}\n}\n"]}
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/gsd/git.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qD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CAAC,CAAC;QAC/C,QAAQ,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACzE,MAAM,IAAI,GAAG,QAAQ,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;AACF,CAAC","sourcesContent":["// GSD Git module — git commit operations for the GSD lifecycle.\n// Part of the draht GSD (Get Shit Done) methodology.\n// Exported via src/gsd/index.ts and @draht/coding-agent.\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface CommitResult {\n\thash: string | null;\n\ttddWarning: boolean;\n}\n\ninterface ExecutionLogEntry {\n\tcommit: string;\n\tphase: number;\n\tplan: number;\n\tstatus: \"pass\" | \"tdd-violation\";\n\ttask: number;\n\ttimestamp: string;\n}\n\nfunction appendExecutionLog(cwd: string, entry: ExecutionLogEntry): void {\n\tconst planningDir = path.join(cwd, \".planning\");\n\tif (!fs.existsSync(planningDir)) {\n\t\treturn;\n\t}\n\tconst logPath = path.join(planningDir, \"execution-log.jsonl\");\n\tfs.appendFileSync(logPath, `${JSON.stringify(entry)}\\n`, \"utf-8\");\n}\n\n/**\n * Returns true if any file in the list matches known test file patterns.\n */\nexport function hasTestFiles(files: string[]): boolean {\n\treturn files.some((f) => /\\.(test|spec)\\.(ts|tsx|js|jsx)$|_test\\.(go|ts)$/.test(f));\n}\n\n/**\n * Stage all changes and commit as a task in the GSD methodology.\n * Message format: feat(NN-NN): description\n * Sets tddWarning=true when no test files are in the commit.\n */\nexport function commitTask(cwd: string, phaseNum: number, planNum: number, description: string): CommitResult {\n\tconst scope = `${String(phaseNum).padStart(2, \"0\")}-${String(planNum).padStart(2, \"0\")}`;\n\tconst message = `feat(${scope}): ${description}`;\n\ttry {\n\t\texecSync(\"git add -A\", { cwd, stdio: \"pipe\" });\n\t\texecSync(`git commit -m ${JSON.stringify(message)}`, { cwd, stdio: \"pipe\" });\n\t\tconst hash = execSync(\"git rev-parse HEAD\", { cwd, encoding: \"utf-8\" }).trim();\n\t\tlet tddWarning = false;\n\t\ttry {\n\t\t\tconst files = execSync(`git diff-tree --no-commit-id --name-only -r ${hash}`, {\n\t\t\t\tcwd,\n\t\t\t\tencoding: \"utf-8\",\n\t\t\t})\n\t\t\t\t.trim()\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.filter(Boolean);\n\t\t\ttddWarning = !hasTestFiles(files);\n\t\t} catch {\n\t\t\t// not a git repo or commit not found\n\t\t}\n\t\tappendExecutionLog(cwd, {\n\t\t\tcommit: hash,\n\t\t\tphase: phaseNum,\n\t\t\tplan: planNum,\n\t\t\tstatus: tddWarning ? \"tdd-violation\" : \"pass\",\n\t\t\ttask: 1,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t});\n\t\treturn { hash, tddWarning };\n\t} catch {\n\t\treturn { hash: null, tddWarning: false };\n\t}\n}\n\n/**\n * Stage all changes and commit as a docs update.\n * Message format: docs: message\n */\nexport function commitDocs(cwd: string, message: string): CommitResult {\n\tconst msg = `docs: ${message}`;\n\ttry {\n\t\texecSync(\"git add -A\", { cwd, stdio: \"pipe\" });\n\t\texecSync(`git commit -m ${JSON.stringify(msg)}`, { cwd, stdio: \"pipe\" });\n\t\tconst hash = execSync(\"git rev-parse HEAD\", { cwd, encoding: \"utf-8\" }).trim();\n\t\treturn { hash, tddWarning: false };\n\t} catch {\n\t\treturn { hash: null, tddWarning: false };\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hook-utils.d.ts","sourceRoot":"","sources":["../../src/gsd/hook-utils.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC/B,iBAAiB,EAAE,OAAO,CAAC;CAC3B;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAgE1D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAyBtD","sourcesContent":["// GSD Hook Utilities — toolchain auto-detection and hook configuration.\n// Mirrors the inline logic in hooks/gsd/*.js so it can be tested via vitest.\n// The hook .js files embed the same logic inline (with require() fallback to this dist).\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface ToolchainInfo {\n\tpm: \"npm\" | \"bun\" | \"pnpm\" | \"yarn\";\n\ttestCmd: string;\n\tcoverageCmd: string;\n\tlintCmd: string;\n}\n\nexport interface HookConfig {\n\tcoverageThreshold: number;\n\ttddMode: \"strict\" | \"advisory\";\n\tqualityGateStrict: boolean;\n}\n\nconst DEFAULT_HOOK_CONFIG: HookConfig = {\n\tcoverageThreshold: 80,\n\ttddMode: \"advisory\",\n\tqualityGateStrict: false,\n};\n\n/**\n * Detect package manager from lockfiles and package.json scripts.\n * Priority: bun.lockb/bun.lock > pnpm-lock.yaml > yarn.lock > package-lock.json > fallback npm\n */\nexport function detectToolchain(cwd: string): ToolchainInfo {\n\tif (fs.existsSync(path.join(cwd, \"bun.lockb\")) || fs.existsSync(path.join(cwd, \"bun.lock\"))) {\n\t\treturn {\n\t\t\tpm: \"bun\",\n\t\t\ttestCmd: \"bun test\",\n\t\t\tcoverageCmd: \"bun test --coverage\",\n\t\t\tlintCmd: \"bunx biome check .\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"pnpm-lock.yaml\"))) {\n\t\treturn {\n\t\t\tpm: \"pnpm\",\n\t\t\ttestCmd: \"pnpm test\",\n\t\t\tcoverageCmd: \"pnpm run test:coverage\",\n\t\t\tlintCmd: \"pnpm run lint\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"yarn.lock\"))) {\n\t\treturn {\n\t\t\tpm: \"yarn\",\n\t\t\ttestCmd: \"yarn test\",\n\t\t\tcoverageCmd: \"yarn run test:coverage\",\n\t\t\tlintCmd: \"yarn run lint\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"package-lock.json\"))) {\n\t\treturn {\n\t\t\tpm: \"npm\",\n\t\t\ttestCmd: \"npm test\",\n\t\t\tcoverageCmd: \"npm run test:coverage\",\n\t\t\tlintCmd: \"npm run lint\",\n\t\t};\n\t}\n\n\t// No lockfile — check package.json scripts for test runner hints\n\tconst pkgPath = path.join(cwd, \"package.json\");\n\tif (fs.existsSync(pkgPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\")) as {\n\t\t\t\tscripts?: Record<string, string>;\n\t\t\t};\n\t\t\tif (pkg.scripts?.test) {\n\t\t\t\treturn {\n\t\t\t\t\tpm: \"npm\",\n\t\t\t\t\ttestCmd: \"npm test\",\n\t\t\t\t\tcoverageCmd: \"npm run test:coverage\",\n\t\t\t\t\tlintCmd: \"npm run lint\",\n\t\t\t\t};\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore parse errors */\n\t\t}\n\t}\n\n\t// Fallback\n\treturn {\n\t\tpm: \"npm\",\n\t\ttestCmd: \"npm test\",\n\t\tcoverageCmd: \"npm run test:coverage\",\n\t\tlintCmd: \"npm run lint\",\n\t};\n}\n\n/**\n * Read hook configuration from .planning/config.json hooks section.\n * Falls back to defaults on missing file or parse errors.\n */\nexport function readHookConfig(cwd: string): HookConfig {\n\tconst configPath = path.join(cwd, \".planning\", \"config.json\");\n\tif (!fs.existsSync(configPath)) {\n\t\treturn { ...DEFAULT_HOOK_CONFIG };\n\t}\n\ttry {\n\t\tconst raw = JSON.parse(fs.readFileSync(configPath, \"utf-8\")) as {\n\t\t\thooks?: Partial<HookConfig>;\n\t\t};\n\t\tconst hooks = raw.hooks ?? {};\n\t\treturn {\n\t\t\tcoverageThreshold:\n\t\t\t\ttypeof hooks.coverageThreshold === \"number\"\n\t\t\t\t\t? hooks.coverageThreshold\n\t\t\t\t\t: DEFAULT_HOOK_CONFIG.coverageThreshold,\n\t\t\ttddMode:\n\t\t\t\thooks.tddMode === \"strict\" || hooks.tddMode === \"advisory\" ? hooks.tddMode : DEFAULT_HOOK_CONFIG.tddMode,\n\t\t\tqualityGateStrict:\n\t\t\t\ttypeof hooks.qualityGateStrict === \"boolean\"\n\t\t\t\t\t? hooks.qualityGateStrict\n\t\t\t\t\t: DEFAULT_HOOK_CONFIG.qualityGateStrict,\n\t\t};\n\t} catch {\n\t\treturn { ...DEFAULT_HOOK_CONFIG };\n\t}\n}\n"]}
1
+ {"version":3,"file":"hook-utils.d.ts","sourceRoot":"","sources":["../../src/gsd/hook-utils.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC/B,iBAAiB,EAAE,OAAO,CAAC;CAC3B;AAUD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAgE1D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAyBtD"}
@@ -3,10 +3,12 @@
3
3
  // The hook .js files embed the same logic inline (with require() fallback to this dist).
4
4
  import * as fs from "node:fs";
5
5
  import * as path from "node:path";
6
+ // Strict by default: failing tests/types/lint fail the gate (exit 1).
7
+ // Opt out per-project with hooks.qualityGateStrict: false in .planning/config.json.
6
8
  const DEFAULT_HOOK_CONFIG = {
7
9
  coverageThreshold: 80,
8
10
  tddMode: "advisory",
9
- qualityGateStrict: false,
11
+ qualityGateStrict: true,
10
12
  };
11
13
  /**
12
14
  * Detect package manager from lockfiles and package.json scripts.
@@ -1 +1 @@
1
- {"version":3,"file":"hook-utils.js","sourceRoot":"","sources":["../../src/gsd/hook-utils.ts"],"names":[],"mappings":"AAAA,0EAAwE;AACxE,6EAA6E;AAC7E,yFAAyF;AAEzF,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAelC,MAAM,mBAAmB,GAAe;IACvC,iBAAiB,EAAE,EAAE;IACrB,OAAO,EAAE,UAAU;IACnB,iBAAiB,EAAE,KAAK;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAiB;IAC3D,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAC7F,OAAO;YACN,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,UAAU;YACnB,WAAW,EAAE,qBAAqB;YAClC,OAAO,EAAE,oBAAoB;SAC7B,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC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AW,EAAE,uBAAuB;QACpC,OAAO,EAAE,cAAc;KACvB,CAAC;AAAA,CACF;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAc;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAE1D,CAAC;QACF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,OAAO;YACN,iBAAiB,EAChB,OAAO,KAAK,CAAC,iBAAiB,KAAK,QAAQ;gBAC1C,CAAC,CAAC,KAAK,CAAC,iBAAiB;gBACzB,CAAC,CAAC,mBAAmB,CAAC,iBAAiB;YACzC,OAAO,EACN,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO;YACzG,iBAAiB,EAChB,OAAO,KAAK,CAAC,iBAAiB,KAAK,SAAS;gBAC3C,CAAC,CAAC,KAAK,CAAC,iBAAiB;gBACzB,CAAC,CAAC,mBAAmB,CAAC,iBAAiB;SACzC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACnC,CAAC;AAAA,CACD","sourcesContent":["// GSD Hook Utilities — toolchain auto-detection and hook configuration.\n// Mirrors the inline logic in hooks/gsd/*.js so it can be tested via vitest.\n// The hook .js files embed the same logic inline (with require() fallback to this dist).\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface ToolchainInfo {\n\tpm: \"npm\" | \"bun\" | \"pnpm\" | \"yarn\";\n\ttestCmd: string;\n\tcoverageCmd: string;\n\tlintCmd: string;\n}\n\nexport interface HookConfig {\n\tcoverageThreshold: number;\n\ttddMode: \"strict\" | \"advisory\";\n\tqualityGateStrict: boolean;\n}\n\nconst DEFAULT_HOOK_CONFIG: HookConfig = {\n\tcoverageThreshold: 80,\n\ttddMode: \"advisory\",\n\tqualityGateStrict: false,\n};\n\n/**\n * Detect package manager from lockfiles and package.json scripts.\n * Priority: bun.lockb/bun.lock > pnpm-lock.yaml > yarn.lock > package-lock.json > fallback npm\n */\nexport function detectToolchain(cwd: string): ToolchainInfo {\n\tif (fs.existsSync(path.join(cwd, \"bun.lockb\")) || fs.existsSync(path.join(cwd, \"bun.lock\"))) {\n\t\treturn {\n\t\t\tpm: \"bun\",\n\t\t\ttestCmd: \"bun test\",\n\t\t\tcoverageCmd: \"bun test --coverage\",\n\t\t\tlintCmd: \"bunx biome check .\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"pnpm-lock.yaml\"))) {\n\t\treturn {\n\t\t\tpm: \"pnpm\",\n\t\t\ttestCmd: \"pnpm test\",\n\t\t\tcoverageCmd: \"pnpm run test:coverage\",\n\t\t\tlintCmd: \"pnpm run lint\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"yarn.lock\"))) {\n\t\treturn {\n\t\t\tpm: \"yarn\",\n\t\t\ttestCmd: \"yarn test\",\n\t\t\tcoverageCmd: \"yarn run test:coverage\",\n\t\t\tlintCmd: \"yarn run lint\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"package-lock.json\"))) {\n\t\treturn {\n\t\t\tpm: \"npm\",\n\t\t\ttestCmd: \"npm test\",\n\t\t\tcoverageCmd: \"npm run test:coverage\",\n\t\t\tlintCmd: \"npm run lint\",\n\t\t};\n\t}\n\n\t// No lockfile — check package.json scripts for test runner hints\n\tconst pkgPath = path.join(cwd, \"package.json\");\n\tif (fs.existsSync(pkgPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\")) as {\n\t\t\t\tscripts?: Record<string, string>;\n\t\t\t};\n\t\t\tif (pkg.scripts?.test) {\n\t\t\t\treturn {\n\t\t\t\t\tpm: \"npm\",\n\t\t\t\t\ttestCmd: \"npm test\",\n\t\t\t\t\tcoverageCmd: \"npm run test:coverage\",\n\t\t\t\t\tlintCmd: \"npm run lint\",\n\t\t\t\t};\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore parse errors */\n\t\t}\n\t}\n\n\t// Fallback\n\treturn {\n\t\tpm: \"npm\",\n\t\ttestCmd: \"npm test\",\n\t\tcoverageCmd: \"npm run test:coverage\",\n\t\tlintCmd: \"npm run lint\",\n\t};\n}\n\n/**\n * Read hook configuration from .planning/config.json hooks section.\n * Falls back to defaults on missing file or parse errors.\n */\nexport function readHookConfig(cwd: string): HookConfig {\n\tconst configPath = path.join(cwd, \".planning\", \"config.json\");\n\tif (!fs.existsSync(configPath)) {\n\t\treturn { ...DEFAULT_HOOK_CONFIG };\n\t}\n\ttry {\n\t\tconst raw = JSON.parse(fs.readFileSync(configPath, \"utf-8\")) as {\n\t\t\thooks?: Partial<HookConfig>;\n\t\t};\n\t\tconst hooks = raw.hooks ?? {};\n\t\treturn {\n\t\t\tcoverageThreshold:\n\t\t\t\ttypeof hooks.coverageThreshold === \"number\"\n\t\t\t\t\t? hooks.coverageThreshold\n\t\t\t\t\t: DEFAULT_HOOK_CONFIG.coverageThreshold,\n\t\t\ttddMode:\n\t\t\t\thooks.tddMode === \"strict\" || hooks.tddMode === \"advisory\" ? hooks.tddMode : DEFAULT_HOOK_CONFIG.tddMode,\n\t\t\tqualityGateStrict:\n\t\t\t\ttypeof hooks.qualityGateStrict === \"boolean\"\n\t\t\t\t\t? hooks.qualityGateStrict\n\t\t\t\t\t: DEFAULT_HOOK_CONFIG.qualityGateStrict,\n\t\t};\n\t} catch {\n\t\treturn { ...DEFAULT_HOOK_CONFIG };\n\t}\n}\n"]}
1
+ {"version":3,"file":"hook-utils.js","sourceRoot":"","sources":["../../src/gsd/hook-utils.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,6EAA6E;AAC7E,yFAAyF;AAEzF,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAelC,sEAAsE;AACtE,oFAAoF;AACpF,MAAM,mBAAmB,GAAe;IACvC,iBAAiB,EAAE,EAAE;IACrB,OAAO,EAAE,UAAU;IACnB,iBAAiB,EAAE,IAAI;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAC7F,OAAO;YACN,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,UAAU;YACnB,WAAW,EAAE,qBAAqB;YAClC,OAAO,EAAE,oBAAoB;SAC7B,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO;YACN,EAAE,EAAE,MAAM;YACV,OAAO,EAAE,WAAW;YACpB,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE,eAAe;SACxB,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;QAChD,OAAO;YACN,EAAE,EAAE,MAAM;YACV,OAAO,EAAE,WAAW;YACpB,WAAW,EAAE,wBAAwB;YACrC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AC;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAE1D,CAAC;QACF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,OAAO;YACN,iBAAiB,EAChB,OAAO,KAAK,CAAC,iBAAiB,KAAK,QAAQ;gBAC1C,CAAC,CAAC,KAAK,CAAC,iBAAiB;gBACzB,CAAC,CAAC,mBAAmB,CAAC,iBAAiB;YACzC,OAAO,EACN,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO;YACzG,iBAAiB,EAChB,OAAO,KAAK,CAAC,iBAAiB,KAAK,SAAS;gBAC3C,CAAC,CAAC,KAAK,CAAC,iBAAiB;gBACzB,CAAC,CAAC,mBAAmB,CAAC,iBAAiB;SACzC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACnC,CAAC;AACF,CAAC","sourcesContent":["// GSD Hook Utilities — toolchain auto-detection and hook configuration.\n// Mirrors the inline logic in hooks/gsd/*.js so it can be tested via vitest.\n// The hook .js files embed the same logic inline (with require() fallback to this dist).\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface ToolchainInfo {\n\tpm: \"npm\" | \"bun\" | \"pnpm\" | \"yarn\";\n\ttestCmd: string;\n\tcoverageCmd: string;\n\tlintCmd: string;\n}\n\nexport interface HookConfig {\n\tcoverageThreshold: number;\n\ttddMode: \"strict\" | \"advisory\";\n\tqualityGateStrict: boolean;\n}\n\n// Strict by default: failing tests/types/lint fail the gate (exit 1).\n// Opt out per-project with hooks.qualityGateStrict: false in .planning/config.json.\nconst DEFAULT_HOOK_CONFIG: HookConfig = {\n\tcoverageThreshold: 80,\n\ttddMode: \"advisory\",\n\tqualityGateStrict: true,\n};\n\n/**\n * Detect package manager from lockfiles and package.json scripts.\n * Priority: bun.lockb/bun.lock > pnpm-lock.yaml > yarn.lock > package-lock.json > fallback npm\n */\nexport function detectToolchain(cwd: string): ToolchainInfo {\n\tif (fs.existsSync(path.join(cwd, \"bun.lockb\")) || fs.existsSync(path.join(cwd, \"bun.lock\"))) {\n\t\treturn {\n\t\t\tpm: \"bun\",\n\t\t\ttestCmd: \"bun test\",\n\t\t\tcoverageCmd: \"bun test --coverage\",\n\t\t\tlintCmd: \"bunx biome check .\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"pnpm-lock.yaml\"))) {\n\t\treturn {\n\t\t\tpm: \"pnpm\",\n\t\t\ttestCmd: \"pnpm test\",\n\t\t\tcoverageCmd: \"pnpm run test:coverage\",\n\t\t\tlintCmd: \"pnpm run lint\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"yarn.lock\"))) {\n\t\treturn {\n\t\t\tpm: \"yarn\",\n\t\t\ttestCmd: \"yarn test\",\n\t\t\tcoverageCmd: \"yarn run test:coverage\",\n\t\t\tlintCmd: \"yarn run lint\",\n\t\t};\n\t}\n\n\tif (fs.existsSync(path.join(cwd, \"package-lock.json\"))) {\n\t\treturn {\n\t\t\tpm: \"npm\",\n\t\t\ttestCmd: \"npm test\",\n\t\t\tcoverageCmd: \"npm run test:coverage\",\n\t\t\tlintCmd: \"npm run lint\",\n\t\t};\n\t}\n\n\t// No lockfile — check package.json scripts for test runner hints\n\tconst pkgPath = path.join(cwd, \"package.json\");\n\tif (fs.existsSync(pkgPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\")) as {\n\t\t\t\tscripts?: Record<string, string>;\n\t\t\t};\n\t\t\tif (pkg.scripts?.test) {\n\t\t\t\treturn {\n\t\t\t\t\tpm: \"npm\",\n\t\t\t\t\ttestCmd: \"npm test\",\n\t\t\t\t\tcoverageCmd: \"npm run test:coverage\",\n\t\t\t\t\tlintCmd: \"npm run lint\",\n\t\t\t\t};\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore parse errors */\n\t\t}\n\t}\n\n\t// Fallback\n\treturn {\n\t\tpm: \"npm\",\n\t\ttestCmd: \"npm test\",\n\t\tcoverageCmd: \"npm run test:coverage\",\n\t\tlintCmd: \"npm run lint\",\n\t};\n}\n\n/**\n * Read hook configuration from .planning/config.json hooks section.\n * Falls back to defaults on missing file or parse errors.\n */\nexport function readHookConfig(cwd: string): HookConfig {\n\tconst configPath = path.join(cwd, \".planning\", \"config.json\");\n\tif (!fs.existsSync(configPath)) {\n\t\treturn { ...DEFAULT_HOOK_CONFIG };\n\t}\n\ttry {\n\t\tconst raw = JSON.parse(fs.readFileSync(configPath, \"utf-8\")) as {\n\t\t\thooks?: Partial<HookConfig>;\n\t\t};\n\t\tconst hooks = raw.hooks ?? {};\n\t\treturn {\n\t\t\tcoverageThreshold:\n\t\t\t\ttypeof hooks.coverageThreshold === \"number\"\n\t\t\t\t\t? hooks.coverageThreshold\n\t\t\t\t\t: DEFAULT_HOOK_CONFIG.coverageThreshold,\n\t\t\ttddMode:\n\t\t\t\thooks.tddMode === \"strict\" || hooks.tddMode === \"advisory\" ? hooks.tddMode : DEFAULT_HOOK_CONFIG.tddMode,\n\t\t\tqualityGateStrict:\n\t\t\t\ttypeof hooks.qualityGateStrict === \"boolean\"\n\t\t\t\t\t? hooks.qualityGateStrict\n\t\t\t\t\t: DEFAULT_HOOK_CONFIG.qualityGateStrict,\n\t\t};\n\t} catch {\n\t\treturn { ...DEFAULT_HOOK_CONFIG };\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gsd/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACN,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACN,UAAU,EACV,aAAa,EACb,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,GACZ,MAAM,eAAe,CAAC","sourcesContent":["// GSD index — re-exports all GSD module functions.\n// Import from @draht/coding-agent for use in extensions.\n\nexport type { MapCodebaseResult } from \"./domain.js\";\nexport { createDomainModel, mapCodebase } from \"./domain.js\";\nexport {\n\textractGlossaryTerms,\n\tloadDomainContent,\n\tvalidateDomainGlossary,\n} from \"./domain-validator.js\";\nexport type { CommitResult } from \"./git.js\";\nexport { commitDocs, commitTask, hasTestFiles } from \"./git.js\";\nexport type { HookConfig, ToolchainInfo } from \"./hook-utils.js\";\nexport { detectToolchain, readHookConfig } from \"./hook-utils.js\";\nexport type { PhaseVerification, PlanDiscovery } from \"./planning.js\";\nexport {\n\tcreatePlan,\n\tdiscoverPlans,\n\treadPlan,\n\tupdateState,\n\tverifyPhase,\n\twriteSummary,\n} from \"./planning.js\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gsd/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACN,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACN,UAAU,EACV,aAAa,EACb,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,GACZ,MAAM,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gsd/index.ts"],"names":[],"mappings":"AAAA,qDAAmD;AACnD,yDAAyD;AAGzD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACN,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EACN,UAAU,EACV,aAAa,EACb,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,GACZ,MAAM,eAAe,CAAC","sourcesContent":["// GSD index — re-exports all GSD module functions.\n// Import from @draht/coding-agent for use in extensions.\n\nexport type { MapCodebaseResult } from \"./domain.js\";\nexport { createDomainModel, mapCodebase } from \"./domain.js\";\nexport {\n\textractGlossaryTerms,\n\tloadDomainContent,\n\tvalidateDomainGlossary,\n} from \"./domain-validator.js\";\nexport type { CommitResult } from \"./git.js\";\nexport { commitDocs, commitTask, hasTestFiles } from \"./git.js\";\nexport type { HookConfig, ToolchainInfo } from \"./hook-utils.js\";\nexport { detectToolchain, readHookConfig } from \"./hook-utils.js\";\nexport type { PhaseVerification, PlanDiscovery } from \"./planning.js\";\nexport {\n\tcreatePlan,\n\tdiscoverPlans,\n\treadPlan,\n\tupdateState,\n\tverifyPhase,\n\twriteSummary,\n} from \"./planning.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gsd/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,yDAAyD;AAGzD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACN,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EACN,UAAU,EACV,aAAa,EACb,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,GACZ,MAAM,eAAe,CAAC","sourcesContent":["// GSD index — re-exports all GSD module functions.\n// Import from @draht/coding-agent for use in extensions.\n\nexport type { MapCodebaseResult } from \"./domain.js\";\nexport { createDomainModel, mapCodebase } from \"./domain.js\";\nexport {\n\textractGlossaryTerms,\n\tloadDomainContent,\n\tvalidateDomainGlossary,\n} from \"./domain-validator.js\";\nexport type { CommitResult } from \"./git.js\";\nexport { commitDocs, commitTask, hasTestFiles } from \"./git.js\";\nexport type { HookConfig, ToolchainInfo } from \"./hook-utils.js\";\nexport { detectToolchain, readHookConfig } from \"./hook-utils.js\";\nexport type { PhaseVerification, PlanDiscovery } from \"./planning.js\";\nexport {\n\tcreatePlan,\n\tdiscoverPlans,\n\treadPlan,\n\tupdateState,\n\tverifyPhase,\n\twriteSummary,\n} from \"./planning.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../../src/gsd/planning.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC/C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAyCjG;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CA+B1E;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM/E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAyBnF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAe5E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAM7C","sourcesContent":["// GSD Planning module — phase/plan/task file system operations.\n// Part of the draht GSD (Get Shit Done) methodology.\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst PLANNING = \".planning\";\n\nfunction planningPath(cwd: string, ...segments: string[]): string {\n\treturn path.join(cwd, PLANNING, ...segments);\n}\n\nfunction ensureDir(dir: string): void {\n\tif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\nfunction padNum(n: number, digits = 2): string {\n\treturn String(n).padStart(digits, \"0\");\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n}\n\nfunction getPhaseSlug(cwd: string, phaseNum: number): string {\n\tconst roadmapPath = planningPath(cwd, \"ROADMAP.md\");\n\tif (!fs.existsSync(roadmapPath)) return `phase-${phaseNum}`;\n\tconst content = fs.readFileSync(roadmapPath, \"utf-8\");\n\tconst re = new RegExp(`## Phase ${phaseNum}: (.+?) —`);\n\tconst m = re.exec(content);\n\tif (!m) return `phase-${phaseNum}`;\n\treturn m[1]\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.slice(0, 40);\n}\n\nfunction getPhaseDir(cwd: string, phaseNum: number): string | null {\n\tconst phasesDir = planningPath(cwd, \"phases\");\n\tif (!fs.existsSync(phasesDir)) return null;\n\tconst prefix = `${padNum(phaseNum)}-`;\n\tconst entry = fs.readdirSync(phasesDir).find((e) => e.startsWith(prefix));\n\treturn entry ? path.join(phasesDir, entry) : null;\n}\n\nexport interface PlanDiscovery {\n\tplans: Array<{ file: string; deps: string[] }>;\n\tincomplete: string[];\n\tfixPlans: string[];\n}\n\nexport interface PhaseVerification {\n\tplans: number;\n\tsummaries: number;\n\tcomplete: boolean;\n}\n\nexport function createPlan(cwd: string, phaseNum: number, planNum: number, title?: string): string {\n\tconst slug = getPhaseSlug(cwd, phaseNum);\n\tconst dir = planningPath(cwd, \"phases\", `${padNum(phaseNum)}-${slug}`);\n\tensureDir(dir);\n\tconst planTitle = title || `Plan ${planNum}`;\n\tconst planFile = path.join(dir, `${padNum(phaseNum)}-${padNum(planNum)}-PLAN.md`);\n\tconst tmpl = `---\nphase: ${phaseNum}\nplan: ${planNum}\ndepends_on: []\nmust_haves:\n - \"[Observable truth this plan delivers]\"\n---\n\n# Phase ${phaseNum}, Plan ${planNum}: ${planTitle}\n\n## Goal\n[What this plan achieves from user perspective]\n\n## Context\n[Key decisions that affect this plan]\n\n## Tasks\n\n<task type=\"auto\">\n <n>[Task name]</n>\n <files>[affected files]</files>\n <test>[Write tests first — what should pass when done]</test>\n <action>\n [Implementation to make tests pass]\n </action>\n <refactor>[Optional cleanup after green]</refactor>\n <verify>[How to verify]</verify>\n <done>[What \"done\" looks like]</done>\n</task>\n\n---\nCreated: ${timestamp()}\n`;\n\tfs.writeFileSync(planFile, tmpl, \"utf-8\");\n\treturn planFile;\n}\n\nexport function discoverPlans(cwd: string, phaseNum: number): PlanDiscovery {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} directory not found`);\n\n\tconst files = fs.readdirSync(phaseDir).sort();\n\tconst plans = files.filter((f) => f.endsWith(\"-PLAN.md\") && !f.includes(\"FIX\"));\n\tconst summaries = files.filter((f) => f.endsWith(\"-SUMMARY.md\"));\n\tconst fixPlans = files.filter((f) => f.includes(\"FIX-PLAN.md\"));\n\n\tconst completedPlanNums = new Set(\n\t\tsummaries.map((s) => s.match(/\\d+-(\\d+)-SUMMARY/)?.[1]).filter((x): x is string => Boolean(x)),\n\t);\n\n\tconst incomplete = plans.filter((p) => {\n\t\tconst m = p.match(/\\d+-(\\d+)-PLAN/);\n\t\treturn m ? !completedPlanNums.has(m[1]) : true;\n\t});\n\n\tconst planData = plans.map((p) => {\n\t\tconst content = fs.readFileSync(path.join(phaseDir, p), \"utf-8\");\n\t\tconst depsMatch = content.match(/depends_on:\\s*\\[(.*?)\\]/);\n\t\tconst deps = depsMatch\n\t\t\t? depsMatch[1]\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((d) => d.trim())\n\t\t\t\t\t.filter(Boolean)\n\t\t\t: [];\n\t\treturn { file: p, deps };\n\t});\n\n\treturn { plans: planData, incomplete, fixPlans };\n}\n\nexport function readPlan(cwd: string, phaseNum: number, planNum: number): string {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst planFile = path.join(phaseDir, `${padNum(phaseNum)}-${padNum(planNum)}-PLAN.md`);\n\tif (!fs.existsSync(planFile)) throw new Error(`Plan file not found: ${planFile}`);\n\treturn fs.readFileSync(planFile, \"utf-8\");\n}\n\nexport function writeSummary(cwd: string, phaseNum: number, planNum: number): string {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst summaryPath = path.join(phaseDir, `${padNum(phaseNum)}-${padNum(planNum)}-SUMMARY.md`);\n\tconst tmpl = `# Phase ${phaseNum}, Plan ${planNum} Summary\n\n## Completed Tasks\n| # | Task | Status | Commit |\n|---|------|--------|--------|\n| 1 | [task] | ✅ Done | [hash] |\n\n## Files Changed\n- [files]\n\n## Verification Results\n- [results]\n\n## Notes\n[deviations, decisions]\n\n---\nCompleted: ${timestamp()}\n`;\n\tfs.writeFileSync(summaryPath, tmpl, \"utf-8\");\n\treturn summaryPath;\n}\n\nexport function verifyPhase(cwd: string, phaseNum: number): PhaseVerification {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst plans = fs.readdirSync(phaseDir).filter((f) => f.endsWith(\"-PLAN.md\") && !f.includes(\"FIX\"));\n\tconst summaries = fs.readdirSync(phaseDir).filter((f) => f.endsWith(\"-SUMMARY.md\"));\n\tconst complete = summaries.length >= plans.length && plans.length > 0;\n\tif (complete) {\n\t\tconst verPath = path.join(phaseDir, `${padNum(phaseNum)}-VERIFICATION.md`);\n\t\tfs.writeFileSync(\n\t\t\tverPath,\n\t\t\t`# Phase ${phaseNum} Verification\\n\\nAll ${plans.length} plans executed.\\nVerified: ${timestamp()}\\n`,\n\t\t\t\"utf-8\",\n\t\t);\n\t}\n\treturn { plans: plans.length, summaries: summaries.length, complete };\n}\n\nexport function updateState(cwd: string): void {\n\tconst statePath = planningPath(cwd, \"STATE.md\");\n\tif (!fs.existsSync(statePath)) throw new Error(\"No STATE.md found\");\n\tlet state = fs.readFileSync(statePath, \"utf-8\");\n\tstate = state.replace(/## Last Activity:.*/, `## Last Activity: ${timestamp()}`);\n\tfs.writeFileSync(statePath, state, \"utf-8\");\n}\n"]}
1
+ {"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../../src/gsd/planning.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC/C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAyCjG;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CA+B1E;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM/E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAyBnF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAe5E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CA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AC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,qBAAqB,SAAS,EAAE,EAAE,CAAC,CAAC;IACjF,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAAA,CAC5C","sourcesContent":["// GSD Planning module — phase/plan/task file system operations.\n// Part of the draht GSD (Get Shit Done) methodology.\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst PLANNING = \".planning\";\n\nfunction planningPath(cwd: string, ...segments: string[]): string {\n\treturn path.join(cwd, PLANNING, ...segments);\n}\n\nfunction ensureDir(dir: string): void {\n\tif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\nfunction padNum(n: number, digits = 2): string {\n\treturn String(n).padStart(digits, \"0\");\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n}\n\nfunction getPhaseSlug(cwd: string, phaseNum: number): string {\n\tconst roadmapPath = planningPath(cwd, \"ROADMAP.md\");\n\tif (!fs.existsSync(roadmapPath)) return `phase-${phaseNum}`;\n\tconst content = fs.readFileSync(roadmapPath, \"utf-8\");\n\tconst re = new RegExp(`## Phase ${phaseNum}: (.+?) —`);\n\tconst m = re.exec(content);\n\tif (!m) return `phase-${phaseNum}`;\n\treturn m[1]\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.slice(0, 40);\n}\n\nfunction getPhaseDir(cwd: string, phaseNum: number): string | null {\n\tconst phasesDir = planningPath(cwd, \"phases\");\n\tif (!fs.existsSync(phasesDir)) return null;\n\tconst prefix = `${padNum(phaseNum)}-`;\n\tconst entry = fs.readdirSync(phasesDir).find((e) => e.startsWith(prefix));\n\treturn entry ? path.join(phasesDir, entry) : null;\n}\n\nexport interface PlanDiscovery {\n\tplans: Array<{ file: string; deps: string[] }>;\n\tincomplete: string[];\n\tfixPlans: string[];\n}\n\nexport interface PhaseVerification {\n\tplans: number;\n\tsummaries: number;\n\tcomplete: boolean;\n}\n\nexport function createPlan(cwd: string, phaseNum: number, planNum: number, title?: string): string {\n\tconst slug = getPhaseSlug(cwd, phaseNum);\n\tconst dir = planningPath(cwd, \"phases\", `${padNum(phaseNum)}-${slug}`);\n\tensureDir(dir);\n\tconst planTitle = title || `Plan ${planNum}`;\n\tconst planFile = path.join(dir, `${padNum(phaseNum)}-${padNum(planNum)}-PLAN.md`);\n\tconst tmpl = `---\nphase: ${phaseNum}\nplan: ${planNum}\ndepends_on: []\nmust_haves:\n - \"[Observable truth this plan delivers]\"\n---\n\n# Phase ${phaseNum}, Plan ${planNum}: ${planTitle}\n\n## Goal\n[What this plan achieves from user perspective]\n\n## Context\n[Key decisions that affect this plan]\n\n## Tasks\n\n<task type=\"auto\">\n <n>[Task name]</n>\n <files>[affected files]</files>\n <test>[Write tests first — what should pass when done]</test>\n <action>\n [Implementation to make tests pass]\n </action>\n <refactor>[Optional cleanup after green]</refactor>\n <verify>[How to verify]</verify>\n <done>[What \"done\" looks like]</done>\n</task>\n\n---\nCreated: ${timestamp()}\n`;\n\tfs.writeFileSync(planFile, tmpl, \"utf-8\");\n\treturn planFile;\n}\n\nexport function discoverPlans(cwd: string, phaseNum: number): PlanDiscovery {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} directory not found`);\n\n\tconst files = fs.readdirSync(phaseDir).sort();\n\tconst plans = files.filter((f) => f.endsWith(\"-PLAN.md\") && !f.includes(\"FIX\"));\n\tconst summaries = files.filter((f) => f.endsWith(\"-SUMMARY.md\"));\n\tconst fixPlans = files.filter((f) => f.includes(\"FIX-PLAN.md\"));\n\n\tconst completedPlanNums = new Set(\n\t\tsummaries.map((s) => s.match(/\\d+-(\\d+)-SUMMARY/)?.[1]).filter((x): x is string => Boolean(x)),\n\t);\n\n\tconst incomplete = plans.filter((p) => {\n\t\tconst m = p.match(/\\d+-(\\d+)-PLAN/);\n\t\treturn m ? !completedPlanNums.has(m[1]) : true;\n\t});\n\n\tconst planData = plans.map((p) => {\n\t\tconst content = fs.readFileSync(path.join(phaseDir, p), \"utf-8\");\n\t\tconst depsMatch = content.match(/depends_on:\\s*\\[(.*?)\\]/);\n\t\tconst deps = depsMatch\n\t\t\t? depsMatch[1]\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((d) => d.trim())\n\t\t\t\t\t.filter(Boolean)\n\t\t\t: [];\n\t\treturn { file: p, deps };\n\t});\n\n\treturn { plans: planData, incomplete, fixPlans };\n}\n\nexport function readPlan(cwd: string, phaseNum: number, planNum: number): string {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst planFile = path.join(phaseDir, `${padNum(phaseNum)}-${padNum(planNum)}-PLAN.md`);\n\tif (!fs.existsSync(planFile)) throw new Error(`Plan file not found: ${planFile}`);\n\treturn fs.readFileSync(planFile, \"utf-8\");\n}\n\nexport function writeSummary(cwd: string, phaseNum: number, planNum: number): string {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst summaryPath = path.join(phaseDir, `${padNum(phaseNum)}-${padNum(planNum)}-SUMMARY.md`);\n\tconst tmpl = `# Phase ${phaseNum}, Plan ${planNum} Summary\n\n## Completed Tasks\n| # | Task | Status | Commit |\n|---|------|--------|--------|\n| 1 | [task] | ✅ Done | [hash] |\n\n## Files Changed\n- [files]\n\n## Verification Results\n- [results]\n\n## Notes\n[deviations, decisions]\n\n---\nCompleted: ${timestamp()}\n`;\n\tfs.writeFileSync(summaryPath, tmpl, \"utf-8\");\n\treturn summaryPath;\n}\n\nexport function verifyPhase(cwd: string, phaseNum: number): PhaseVerification {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst plans = fs.readdirSync(phaseDir).filter((f) => f.endsWith(\"-PLAN.md\") && !f.includes(\"FIX\"));\n\tconst summaries = fs.readdirSync(phaseDir).filter((f) => f.endsWith(\"-SUMMARY.md\"));\n\tconst complete = summaries.length >= plans.length && plans.length > 0;\n\tif (complete) {\n\t\tconst verPath = path.join(phaseDir, `${padNum(phaseNum)}-VERIFICATION.md`);\n\t\tfs.writeFileSync(\n\t\t\tverPath,\n\t\t\t`# Phase ${phaseNum} Verification\\n\\nAll ${plans.length} plans executed.\\nVerified: ${timestamp()}\\n`,\n\t\t\t\"utf-8\",\n\t\t);\n\t}\n\treturn { plans: plans.length, summaries: summaries.length, complete };\n}\n\nexport function updateState(cwd: string): void {\n\tconst statePath = planningPath(cwd, \"STATE.md\");\n\tif (!fs.existsSync(statePath)) throw new Error(\"No STATE.md found\");\n\tlet state = fs.readFileSync(statePath, \"utf-8\");\n\tstate = state.replace(/## Last Activity:.*/, `## Last Activity: ${timestamp()}`);\n\tfs.writeFileSync(statePath, state, \"utf-8\");\n}\n"]}
1
+ {"version":3,"file":"planning.js","sourceRoot":"","sources":["../../src/gsd/planning.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qDAAqD;AAErD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,SAAS,YAAY,CAAC,GAAW,EAAE,GAAG,QAAkB;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC7B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACjE,CAAC;A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,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAC3E,EAAE,CAAC,aAAa,CACf,OAAO,EACP,WAAW,QAAQ,wBAAwB,KAAK,CAAC,MAAM,+BAA+B,SAAS,EAAE,IAAI,EACrG,OAAO,CACP,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACtC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACpE,IAAI,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,qBAAqB,SAAS,EAAE,EAAE,CAAC,CAAC;IACjF,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["// GSD Planning module — phase/plan/task file system operations.\n// Part of the draht GSD (Get Shit Done) methodology.\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst PLANNING = \".planning\";\n\nfunction planningPath(cwd: string, ...segments: string[]): string {\n\treturn path.join(cwd, PLANNING, ...segments);\n}\n\nfunction ensureDir(dir: string): void {\n\tif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\nfunction padNum(n: number, digits = 2): string {\n\treturn String(n).padStart(digits, \"0\");\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n}\n\nfunction getPhaseSlug(cwd: string, phaseNum: number): string {\n\tconst roadmapPath = planningPath(cwd, \"ROADMAP.md\");\n\tif (!fs.existsSync(roadmapPath)) return `phase-${phaseNum}`;\n\tconst content = fs.readFileSync(roadmapPath, \"utf-8\");\n\tconst re = new RegExp(`## Phase ${phaseNum}: (.+?) —`);\n\tconst m = re.exec(content);\n\tif (!m) return `phase-${phaseNum}`;\n\treturn m[1]\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.slice(0, 40);\n}\n\nfunction getPhaseDir(cwd: string, phaseNum: number): string | null {\n\tconst phasesDir = planningPath(cwd, \"phases\");\n\tif (!fs.existsSync(phasesDir)) return null;\n\tconst prefix = `${padNum(phaseNum)}-`;\n\tconst entry = fs.readdirSync(phasesDir).find((e) => e.startsWith(prefix));\n\treturn entry ? path.join(phasesDir, entry) : null;\n}\n\nexport interface PlanDiscovery {\n\tplans: Array<{ file: string; deps: string[] }>;\n\tincomplete: string[];\n\tfixPlans: string[];\n}\n\nexport interface PhaseVerification {\n\tplans: number;\n\tsummaries: number;\n\tcomplete: boolean;\n}\n\nexport function createPlan(cwd: string, phaseNum: number, planNum: number, title?: string): string {\n\tconst slug = getPhaseSlug(cwd, phaseNum);\n\tconst dir = planningPath(cwd, \"phases\", `${padNum(phaseNum)}-${slug}`);\n\tensureDir(dir);\n\tconst planTitle = title || `Plan ${planNum}`;\n\tconst planFile = path.join(dir, `${padNum(phaseNum)}-${padNum(planNum)}-PLAN.md`);\n\tconst tmpl = `---\nphase: ${phaseNum}\nplan: ${planNum}\ndepends_on: []\nmust_haves:\n - \"[Observable truth this plan delivers]\"\n---\n\n# Phase ${phaseNum}, Plan ${planNum}: ${planTitle}\n\n## Goal\n[What this plan achieves from user perspective]\n\n## Context\n[Key decisions that affect this plan]\n\n## Tasks\n\n<task type=\"auto\">\n <n>[Task name]</n>\n <files>[affected files]</files>\n <test>[Write tests first — what should pass when done]</test>\n <action>\n [Implementation to make tests pass]\n </action>\n <refactor>[Optional cleanup after green]</refactor>\n <verify>[How to verify]</verify>\n <done>[What \"done\" looks like]</done>\n</task>\n\n---\nCreated: ${timestamp()}\n`;\n\tfs.writeFileSync(planFile, tmpl, \"utf-8\");\n\treturn planFile;\n}\n\nexport function discoverPlans(cwd: string, phaseNum: number): PlanDiscovery {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} directory not found`);\n\n\tconst files = fs.readdirSync(phaseDir).sort();\n\tconst plans = files.filter((f) => f.endsWith(\"-PLAN.md\") && !f.includes(\"FIX\"));\n\tconst summaries = files.filter((f) => f.endsWith(\"-SUMMARY.md\"));\n\tconst fixPlans = files.filter((f) => f.includes(\"FIX-PLAN.md\"));\n\n\tconst completedPlanNums = new Set(\n\t\tsummaries.map((s) => s.match(/\\d+-(\\d+)-SUMMARY/)?.[1]).filter((x): x is string => Boolean(x)),\n\t);\n\n\tconst incomplete = plans.filter((p) => {\n\t\tconst m = p.match(/\\d+-(\\d+)-PLAN/);\n\t\treturn m ? !completedPlanNums.has(m[1]) : true;\n\t});\n\n\tconst planData = plans.map((p) => {\n\t\tconst content = fs.readFileSync(path.join(phaseDir, p), \"utf-8\");\n\t\tconst depsMatch = content.match(/depends_on:\\s*\\[(.*?)\\]/);\n\t\tconst deps = depsMatch\n\t\t\t? depsMatch[1]\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((d) => d.trim())\n\t\t\t\t\t.filter(Boolean)\n\t\t\t: [];\n\t\treturn { file: p, deps };\n\t});\n\n\treturn { plans: planData, incomplete, fixPlans };\n}\n\nexport function readPlan(cwd: string, phaseNum: number, planNum: number): string {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst planFile = path.join(phaseDir, `${padNum(phaseNum)}-${padNum(planNum)}-PLAN.md`);\n\tif (!fs.existsSync(planFile)) throw new Error(`Plan file not found: ${planFile}`);\n\treturn fs.readFileSync(planFile, \"utf-8\");\n}\n\nexport function writeSummary(cwd: string, phaseNum: number, planNum: number): string {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst summaryPath = path.join(phaseDir, `${padNum(phaseNum)}-${padNum(planNum)}-SUMMARY.md`);\n\tconst tmpl = `# Phase ${phaseNum}, Plan ${planNum} Summary\n\n## Completed Tasks\n| # | Task | Status | Commit |\n|---|------|--------|--------|\n| 1 | [task] | ✅ Done | [hash] |\n\n## Files Changed\n- [files]\n\n## Verification Results\n- [results]\n\n## Notes\n[deviations, decisions]\n\n---\nCompleted: ${timestamp()}\n`;\n\tfs.writeFileSync(summaryPath, tmpl, \"utf-8\");\n\treturn summaryPath;\n}\n\nexport function verifyPhase(cwd: string, phaseNum: number): PhaseVerification {\n\tconst phaseDir = getPhaseDir(cwd, phaseNum);\n\tif (!phaseDir) throw new Error(`Phase ${phaseNum} not found`);\n\tconst plans = fs.readdirSync(phaseDir).filter((f) => f.endsWith(\"-PLAN.md\") && !f.includes(\"FIX\"));\n\tconst summaries = fs.readdirSync(phaseDir).filter((f) => f.endsWith(\"-SUMMARY.md\"));\n\tconst complete = summaries.length >= plans.length && plans.length > 0;\n\tif (complete) {\n\t\tconst verPath = path.join(phaseDir, `${padNum(phaseNum)}-VERIFICATION.md`);\n\t\tfs.writeFileSync(\n\t\t\tverPath,\n\t\t\t`# Phase ${phaseNum} Verification\\n\\nAll ${plans.length} plans executed.\\nVerified: ${timestamp()}\\n`,\n\t\t\t\"utf-8\",\n\t\t);\n\t}\n\treturn { plans: plans.length, summaries: summaries.length, complete };\n}\n\nexport function updateState(cwd: string): void {\n\tconst statePath = planningPath(cwd, \"STATE.md\");\n\tif (!fs.existsSync(statePath)) throw new Error(\"No STATE.md found\");\n\tlet state = fs.readFileSync(statePath, \"utf-8\");\n\tstate = state.replace(/## Last Activity:.*/, `## Last Activity: ${timestamp()}`);\n\tfs.writeFileSync(statePath, state, \"utf-8\");\n}\n"]}
@@ -105,7 +105,7 @@ fs.appendFileSync(LOG_FILE, JSON.stringify(entry) + "\n");
105
105
  if (status === "pass") {
106
106
  // Type check
107
107
  try {
108
- const tsCmd = toolchain.pm === "bun" ? "bun run tsgo --noEmit 2>&1" : "npx tsc --noEmit 2>&1";
108
+ const tsCmd = toolchain.pm === "bun" ? "bun run tsc --noEmit 2>&1" : "npx tsc --noEmit 2>&1";
109
109
  execSync(tsCmd, { timeout: 30000, encoding: "utf-8", cwd });
110
110
  // Run tests
111
111
  try {
@@ -71,7 +71,7 @@ const issues = [];
71
71
 
72
72
  // 1. TypeScript check
73
73
  try {
74
- const tsCmd = toolchain.pm === "bun" ? "bun run tsgo --noEmit 2>&1" : "npx tsc --noEmit 2>&1";
74
+ const tsCmd = toolchain.pm === "bun" ? "bun run tsc --noEmit 2>&1" : "npx tsc --noEmit 2>&1";
75
75
  execSync(tsCmd, { timeout: 60000, encoding: "utf-8", cwd });
76
76
  } catch (error) {
77
77
  const output = error.stdout || error.stderr || "";
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { AgentSession, type AgentSessionConfig, type AgentSessionEvent, type Age
4
4
  export { type ApiKeyCredential, type AuthCredential, type AuthStatus, AuthStorage, type AuthStorageBackend, FileAuthStorageBackend, InMemoryAuthStorageBackend, type OAuthCredential, } from "./core/auth-storage.ts";
5
5
  export { type BranchPreparation, type BranchSummaryResult, type CollectEntriesResult, type CompactionResult, type CutPointResult, calculateContextTokens, collectEntriesForBranchSummary, compact, DEFAULT_COMPACTION_SETTINGS, estimateTokens, type FileOperations, findCutPoint, findTurnStartIndex, type GenerateBranchSummaryOptions, generateBranchSummary, generateSummary, getLastAssistantUsage, prepareBranchEntries, serializeConversation, shouldCompact, } from "./core/compaction/index.ts";
6
6
  export { createEventBus, type EventBus, type EventBusController } from "./core/event-bus.ts";
7
- export type { AgentEndEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactOptions, ContextEvent, ContextUsage, CustomToolCallEvent, EditToolCallEvent, EntryRenderer, EntryRenderOptions, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetOptions, FindToolCallEvent, GrepToolCallEvent, InlineExtension, InputEvent, InputEventResult, InputSource, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, MessageRenderer, MessageRenderOptions, ProjectTrustContext, ProjectTrustEvent, ProjectTrustEventDecision, ProjectTrustEventResult, ProjectTrustHandler, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, RegisteredCommand, RegisteredTool, ResolvedCommand, SessionBeforeCompactEvent, SessionBeforeForkEvent, SessionBeforeSwitchEvent, SessionBeforeTreeEvent, SessionCompactEvent, SessionInfoChangedEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SlashCommandInfo, SlashCommandSource, SourceInfo, TerminalInputHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionMode, ToolInfo, ToolRenderResultOptions, ToolResultEvent, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, } from "./core/extensions/index.ts";
7
+ export type { AgentEndEvent, AgentSettledEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactOptions, ContextEvent, ContextUsage, CustomToolCallEvent, EditToolCallEvent, EntryRenderer, EntryRenderOptions, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetOptions, FindToolCallEvent, GrepToolCallEvent, InlineExtension, InputEvent, InputEventResult, InputSource, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, MessageRenderer, MessageRenderOptions, ProjectTrustContext, ProjectTrustEvent, ProjectTrustEventDecision, ProjectTrustEventResult, ProjectTrustHandler, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, RegisteredCommand, RegisteredTool, ResolvedCommand, SessionBeforeCompactEvent, SessionBeforeForkEvent, SessionBeforeSwitchEvent, SessionBeforeTreeEvent, SessionCompactEvent, SessionInfoChangedEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SlashCommandInfo, SlashCommandSource, SourceInfo, TerminalInputHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionMode, ToolInfo, ToolRenderResultOptions, ToolResultEvent, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, } from "./core/extensions/index.ts";
8
8
  export { createExtensionRuntime, defineTool, discoverAndLoadExtensions, ExtensionRunner, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, wrapRegisteredTool, wrapRegisteredTools, } from "./core/extensions/index.ts";
9
9
  export type { ReadonlyFooterDataProvider } from "./core/footer-data-provider.ts";
10
10
  export { convertToLlm } from "./core/messages.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,E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nB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,KAAK,EACL,KAAK,UAAU,GACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport {\n\tCONFIG_DIR_NAME,\n\tgetAgentDir,\n\tgetDocsPath,\n\tgetExamplesPath,\n\tgetPackageDir,\n\tgetReadmePath,\n\tVERSION,\n} from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInlineExtension,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProjectTrustContext,\n\tProjectTrustEvent,\n\tProjectTrustEventDecision,\n\tProjectTrustEventResult,\n\tProjectTrustHandler,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionInfoChangedEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport {\n\ttype ModelScopeDiagnostic,\n\ttype ResolveCliModelResult,\n\ttype ResolveModelScopeResult,\n\tresolveCliModel,\n\tresolveModelScopeWithDiagnostics,\n\ttype ScopedModel,\n} from \"./core/model-resolver.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildContextEntries,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype SessionTreeNode,\n\tsessionEntryToContextMessages,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DefaultProjectTrust,\n\ttype ImageSettings,\n\ttype PackageSource,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\nexport { type EditDiffResult, generateDiffString, generateUnifiedPatch } from \"./core/tools/edit-diff.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport {\n\thasTrustRequiringProjectResources,\n\ttype ProjectTrustDecision,\n\tProjectTrustStore,\n\ttype ProjectTrustStoreEntry,\n\ttype ProjectTrustUpdate,\n} from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcExtensionUIRequest,\n\ttype RpcExtensionUIResponse,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tTreeSelectorComponent,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EACN,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,OAAO,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,YAAY,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,WAAW,EACX,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,eAAe,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EACd,KAAK,cAAc,EACnB,YAAY,EACZ,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE7F,YAAY,EACX,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,2BAA2B,EAC3B,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EA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