gsd-pi 2.82.0-dev.725028083 → 2.82.0-dev.98ea09b1e

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 (355) hide show
  1. package/README.md +4 -3
  2. package/dist/resources/.managed-resources-content-hash +1 -1
  3. package/dist/resources/GSD-WORKFLOW.md +10 -1
  4. package/dist/resources/extensions/claude-code-cli/partial-builder.js +2 -1
  5. package/dist/resources/extensions/cmux/index.js +5 -0
  6. package/dist/resources/extensions/gsd/auto/infra-errors.js +9 -3
  7. package/dist/resources/extensions/gsd/auto/loop.js +5 -5
  8. package/dist/resources/extensions/gsd/auto/orchestrator.js +124 -6
  9. package/dist/resources/extensions/gsd/auto/phases.js +8 -1
  10. package/dist/resources/extensions/gsd/auto/workflow-memory-pressure.js +12 -0
  11. package/dist/resources/extensions/gsd/auto-dispatch.js +13 -6
  12. package/dist/resources/extensions/gsd/auto-model-selection.js +2 -0
  13. package/dist/resources/extensions/gsd/auto-post-unit.js +233 -127
  14. package/dist/resources/extensions/gsd/auto-prompts.js +2 -2
  15. package/dist/resources/extensions/gsd/auto-recovery.js +31 -1
  16. package/dist/resources/extensions/gsd/auto-start.js +85 -12
  17. package/dist/resources/extensions/gsd/auto-verification.js +28 -22
  18. package/dist/resources/extensions/gsd/auto-worktree.js +111 -1
  19. package/dist/resources/extensions/gsd/auto.js +158 -55
  20. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +4 -1
  21. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +9 -8
  22. package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +21 -9
  23. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +16 -2
  24. package/dist/resources/extensions/gsd/clean-root-preflight.js +170 -8
  25. package/dist/resources/extensions/gsd/commands/catalog.js +4 -1
  26. package/dist/resources/extensions/gsd/commands/handlers/core.js +37 -0
  27. package/dist/resources/extensions/gsd/commands-bootstrap.js +5 -0
  28. package/dist/resources/extensions/gsd/crash-recovery.js +31 -5
  29. package/dist/resources/extensions/gsd/db/unit-dispatches.js +3 -2
  30. package/dist/resources/extensions/gsd/dispatch-guard.js +2 -2
  31. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +28 -11
  32. package/dist/resources/extensions/gsd/doctor.js +2 -28
  33. package/dist/resources/extensions/gsd/export-html.js +27 -425
  34. package/dist/resources/extensions/gsd/git-service.js +39 -1
  35. package/dist/resources/extensions/gsd/gsd-db.js +1 -0
  36. package/dist/resources/extensions/gsd/guided-flow.js +13 -6
  37. package/dist/resources/extensions/gsd/md-importer.js +1 -1
  38. package/dist/resources/extensions/gsd/migrate/command.js +5 -0
  39. package/dist/resources/extensions/gsd/migrate/parsers.js +10 -0
  40. package/dist/resources/extensions/gsd/migrate/preview.js +9 -0
  41. package/dist/resources/extensions/gsd/migrate/transformer.js +51 -4
  42. package/dist/resources/extensions/gsd/migrate/writer.js +11 -1
  43. package/dist/resources/extensions/gsd/migration-auto-check.js +12 -17
  44. package/dist/resources/extensions/gsd/milestone-actions.js +11 -4
  45. package/dist/resources/extensions/gsd/native-git-bridge.js +48 -12
  46. package/dist/resources/extensions/gsd/post-execution-checks.js +73 -2
  47. package/dist/resources/extensions/gsd/pre-execution-checks.js +28 -1
  48. package/dist/resources/extensions/gsd/prompt-loader.js +1 -1
  49. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  50. package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  51. package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
  52. package/dist/resources/extensions/gsd/prompts/discuss.md +9 -9
  53. package/dist/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
  54. package/dist/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
  55. package/dist/resources/extensions/gsd/prompts/plan-slice.md +4 -4
  56. package/dist/resources/extensions/gsd/prompts/queue.md +4 -4
  57. package/dist/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  58. package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  59. package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +6 -1
  60. package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +9 -14
  61. package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +19 -24
  62. package/dist/resources/extensions/gsd/status-guards.js +4 -0
  63. package/dist/resources/extensions/gsd/templates/plan.md +8 -5
  64. package/dist/resources/extensions/gsd/templates/task-plan.md +4 -2
  65. package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -8
  66. package/dist/resources/extensions/gsd/tools/complete-slice.js +6 -8
  67. package/dist/resources/extensions/gsd/tools/plan-milestone.js +7 -1
  68. package/dist/resources/extensions/gsd/tools/plan-slice.js +89 -14
  69. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +119 -0
  70. package/dist/resources/extensions/gsd/unit-context-manifest.js +32 -10
  71. package/dist/resources/extensions/gsd/validation.js +23 -1
  72. package/dist/resources/extensions/gsd/verification-gate.js +68 -7
  73. package/dist/resources/extensions/gsd/verification-verdict.js +26 -0
  74. package/dist/resources/extensions/gsd/workflow-projections.js +6 -8
  75. package/dist/resources/extensions/gsd/worktree-lifecycle.js +54 -10
  76. package/dist/resources/extensions/shared/html-shell.js +388 -0
  77. package/dist/resources/extensions/subagent/index.js +448 -78
  78. package/dist/resources/extensions/subagent/launch.js +77 -0
  79. package/dist/resources/extensions/subagent/run-store.js +148 -0
  80. package/dist/resources/extensions/visual-brief/artifact-policy.js +29 -0
  81. package/dist/resources/extensions/visual-brief/extension-manifest.json +8 -0
  82. package/dist/resources/extensions/visual-brief/index.js +5 -0
  83. package/dist/resources/extensions/visual-brief/page-contract.js +124 -0
  84. package/dist/resources/extensions/visual-brief/prompts.js +140 -0
  85. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  86. package/dist/web/standalone/.next/BUILD_ID +1 -1
  87. package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
  88. package/dist/web/standalone/.next/build-manifest.json +3 -3
  89. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  90. package/dist/web/standalone/.next/react-loadable-manifest.json +3 -3
  91. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  92. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  93. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  94. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  95. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  96. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  98. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  99. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  100. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  101. package/dist/web/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  102. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  103. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  104. package/dist/web/standalone/.next/server/app/_not-found.rsc +4 -7
  105. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -7
  106. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  107. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +4 -5
  108. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  109. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  110. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -5
  111. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  112. package/dist/web/standalone/.next/server/app/index.html +1 -1
  113. package/dist/web/standalone/.next/server/app/index.rsc +4 -7
  114. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  115. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -7
  116. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  117. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +4 -5
  118. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -5
  119. package/dist/web/standalone/.next/server/app/page.js +2 -2
  120. package/dist/web/standalone/.next/server/app/page.js.nft.json +1 -1
  121. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  122. package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
  123. package/dist/web/standalone/.next/server/chunks/4266.js +2 -0
  124. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  125. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  126. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  127. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  128. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  129. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  130. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  131. package/dist/web/standalone/.next/static/chunks/2973.33f26573894b6153.js +2 -0
  132. package/dist/web/standalone/.next/static/chunks/{8359.e059d86b255fce1c.js → 8359.7eb3bb8f8ecf4c01.js} +2 -2
  133. package/dist/web/standalone/.next/static/chunks/app/layout-8c10ec293ae0f1d5.js +1 -0
  134. package/dist/web/standalone/.next/static/chunks/{webpack-de742b64187e13fe.js → webpack-9a4db269f9ed63ad.js} +1 -1
  135. package/dist/web/standalone/.next/static/css/746ee28c929d1880.css +1 -0
  136. package/package.json +4 -4
  137. package/packages/contracts/dist/rpc.test.js +7 -0
  138. package/packages/contracts/dist/rpc.test.js.map +1 -1
  139. package/packages/contracts/dist/workflow.d.ts +21 -0
  140. package/packages/contracts/dist/workflow.d.ts.map +1 -1
  141. package/packages/contracts/dist/workflow.js +24 -0
  142. package/packages/contracts/dist/workflow.js.map +1 -1
  143. package/packages/contracts/src/rpc.test.ts +8 -0
  144. package/packages/contracts/src/workflow.ts +24 -0
  145. package/packages/mcp-server/README.md +13 -4
  146. package/packages/mcp-server/dist/workflow-tools.d.ts +0 -3
  147. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  148. package/packages/mcp-server/dist/workflow-tools.js +80 -0
  149. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  150. package/packages/mcp-server/src/workflow-tools.test.ts +23 -1
  151. package/packages/mcp-server/src/workflow-tools.ts +168 -0
  152. package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
  153. package/packages/native/tsconfig.json +2 -1
  154. package/packages/native/tsconfig.tsbuildinfo +1 -1
  155. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  156. package/packages/pi-ai/dist/providers/openai-codex-responses.js +82 -1
  157. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  158. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts +2 -0
  159. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts.map +1 -0
  160. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +52 -0
  161. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -0
  162. package/packages/pi-ai/dist/providers/simple-options.d.ts +2 -4
  163. package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  164. package/packages/pi-ai/dist/providers/simple-options.js +5 -6
  165. package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
  166. package/packages/pi-ai/dist/providers/simple-options.test.d.ts +2 -0
  167. package/packages/pi-ai/dist/providers/simple-options.test.d.ts.map +1 -0
  168. package/packages/pi-ai/dist/providers/simple-options.test.js +50 -0
  169. package/packages/pi-ai/dist/providers/simple-options.test.js.map +1 -0
  170. package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +63 -0
  171. package/packages/pi-ai/src/providers/openai-codex-responses.ts +91 -1
  172. package/packages/pi-ai/src/providers/simple-options.test.ts +60 -0
  173. package/packages/pi-ai/src/providers/simple-options.ts +5 -6
  174. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  175. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts +2 -0
  176. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts.map +1 -0
  177. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js +66 -0
  178. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js.map +1 -0
  179. package/packages/pi-coding-agent/dist/core/agent-session.js +1 -1
  180. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  181. package/packages/pi-coding-agent/src/core/agent-session-thinking-level.test.ts +79 -0
  182. package/packages/pi-coding-agent/src/core/agent-session.ts +1 -1
  183. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  184. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  185. package/packages/pi-tui/dist/tui.js +5 -0
  186. package/packages/pi-tui/dist/tui.js.map +1 -1
  187. package/packages/pi-tui/src/tui.ts +6 -0
  188. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  189. package/packages/rpc-client/tsconfig.tsbuildinfo +1 -1
  190. package/src/resources/GSD-WORKFLOW.md +10 -1
  191. package/src/resources/extensions/claude-code-cli/partial-builder.ts +2 -1
  192. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +19 -2
  193. package/src/resources/extensions/cmux/index.ts +6 -0
  194. package/src/resources/extensions/gsd/auto/contracts.ts +59 -16
  195. package/src/resources/extensions/gsd/auto/infra-errors.ts +9 -3
  196. package/src/resources/extensions/gsd/auto/loop.ts +8 -5
  197. package/src/resources/extensions/gsd/auto/orchestrator.ts +129 -6
  198. package/src/resources/extensions/gsd/auto/phases.ts +7 -1
  199. package/src/resources/extensions/gsd/auto/workflow-memory-pressure.ts +13 -0
  200. package/src/resources/extensions/gsd/auto-dispatch.ts +14 -6
  201. package/src/resources/extensions/gsd/auto-model-selection.ts +2 -1
  202. package/src/resources/extensions/gsd/auto-post-unit.ts +266 -139
  203. package/src/resources/extensions/gsd/auto-prompts.ts +2 -2
  204. package/src/resources/extensions/gsd/auto-recovery.ts +29 -0
  205. package/src/resources/extensions/gsd/auto-start.ts +92 -9
  206. package/src/resources/extensions/gsd/auto-verification.ts +36 -34
  207. package/src/resources/extensions/gsd/auto-worktree.ts +119 -1
  208. package/src/resources/extensions/gsd/auto.ts +167 -53
  209. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +6 -1
  210. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +9 -8
  211. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +19 -7
  212. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +19 -3
  213. package/src/resources/extensions/gsd/clean-root-preflight.ts +174 -8
  214. package/src/resources/extensions/gsd/commands/catalog.ts +4 -1
  215. package/src/resources/extensions/gsd/commands/handlers/core.ts +40 -0
  216. package/src/resources/extensions/gsd/commands-bootstrap.ts +10 -0
  217. package/src/resources/extensions/gsd/crash-recovery.ts +30 -4
  218. package/src/resources/extensions/gsd/db/unit-dispatches.ts +4 -3
  219. package/src/resources/extensions/gsd/dispatch-guard.ts +2 -2
  220. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +25 -13
  221. package/src/resources/extensions/gsd/doctor.ts +2 -27
  222. package/src/resources/extensions/gsd/export-html.ts +27 -427
  223. package/src/resources/extensions/gsd/git-service.ts +45 -1
  224. package/src/resources/extensions/gsd/gsd-db.ts +3 -0
  225. package/src/resources/extensions/gsd/guided-flow.ts +14 -7
  226. package/src/resources/extensions/gsd/md-importer.ts +1 -1
  227. package/src/resources/extensions/gsd/migrate/command.ts +5 -0
  228. package/src/resources/extensions/gsd/migrate/parsers.ts +11 -0
  229. package/src/resources/extensions/gsd/migrate/preview.ts +10 -0
  230. package/src/resources/extensions/gsd/migrate/transformer.ts +58 -4
  231. package/src/resources/extensions/gsd/migrate/writer.ts +14 -1
  232. package/src/resources/extensions/gsd/migration-auto-check.ts +15 -23
  233. package/src/resources/extensions/gsd/milestone-actions.ts +10 -4
  234. package/src/resources/extensions/gsd/native-git-bridge.ts +54 -12
  235. package/src/resources/extensions/gsd/post-execution-checks.ts +87 -2
  236. package/src/resources/extensions/gsd/pre-execution-checks.ts +32 -1
  237. package/src/resources/extensions/gsd/prompt-loader.ts +1 -1
  238. package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  239. package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  240. package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
  241. package/src/resources/extensions/gsd/prompts/discuss.md +9 -9
  242. package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
  243. package/src/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
  244. package/src/resources/extensions/gsd/prompts/plan-slice.md +4 -4
  245. package/src/resources/extensions/gsd/prompts/queue.md +4 -4
  246. package/src/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  247. package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  248. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +8 -1
  249. package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +12 -15
  250. package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +17 -25
  251. package/src/resources/extensions/gsd/status-guards.ts +5 -0
  252. package/src/resources/extensions/gsd/templates/plan.md +8 -5
  253. package/src/resources/extensions/gsd/templates/task-plan.md +4 -2
  254. package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +116 -0
  255. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +54 -0
  256. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +487 -4
  257. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +12 -11
  258. package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +12 -1
  259. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +15 -1
  260. package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +4 -4
  261. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +1 -0
  262. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +69 -1
  263. package/src/resources/extensions/gsd/tests/brief-command.test.ts +89 -0
  264. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +107 -2
  265. package/src/resources/extensions/gsd/tests/closeout-git-deferral.test.ts +16 -0
  266. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +4 -1
  267. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +5 -9
  268. package/src/resources/extensions/gsd/tests/complete-task.test.ts +3 -1
  269. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +43 -2
  270. package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +208 -0
  271. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +59 -2
  272. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +39 -0
  273. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +27 -0
  274. package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +38 -0
  275. package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +8 -0
  276. package/src/resources/extensions/gsd/tests/guided-discuss-project-prompt-rendering.test.ts +2 -0
  277. package/src/resources/extensions/gsd/tests/guided-flow.test.ts +21 -0
  278. package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +6 -6
  279. package/src/resources/extensions/gsd/tests/hook-model-resolution.test.ts +5 -0
  280. package/src/resources/extensions/gsd/tests/infra-error.test.ts +2 -2
  281. package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +9 -0
  282. package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +20 -0
  283. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +103 -1
  284. package/src/resources/extensions/gsd/tests/integration/migrate-command.test.ts +48 -3
  285. package/src/resources/extensions/gsd/tests/integration/state-machine-runtime-failures.test.ts +6 -1
  286. package/src/resources/extensions/gsd/tests/migrate-transformer.test.ts +5 -1
  287. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +24 -1
  288. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +6 -1
  289. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +26 -18
  290. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +63 -2
  291. package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +121 -1
  292. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +55 -1
  293. package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +26 -0
  294. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +2 -0
  295. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +225 -1
  296. package/src/resources/extensions/gsd/tests/plan-task.test.ts +17 -0
  297. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
  298. package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +86 -0
  299. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +1 -1
  300. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +53 -0
  301. package/src/resources/extensions/gsd/tests/prompt-loader.test.ts +23 -0
  302. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +46 -2
  303. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +10 -0
  304. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +31 -1
  305. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +6 -0
  306. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +119 -23
  307. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +64 -1
  308. package/src/resources/extensions/gsd/tests/summary-render-parity.test.ts +7 -3
  309. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +86 -7
  310. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +110 -1
  311. package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +78 -0
  312. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +1 -1
  313. package/src/resources/extensions/gsd/tests/workflow-memory-pressure.test.ts +21 -1
  314. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +1 -1
  315. package/src/resources/extensions/gsd/tests/worktree-git-pathspec.test.ts +39 -0
  316. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +64 -12
  317. package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +25 -0
  318. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +54 -0
  319. package/src/resources/extensions/gsd/tools/complete-milestone.ts +8 -10
  320. package/src/resources/extensions/gsd/tools/complete-slice.ts +6 -8
  321. package/src/resources/extensions/gsd/tools/plan-milestone.ts +5 -1
  322. package/src/resources/extensions/gsd/tools/plan-slice.ts +98 -12
  323. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +135 -0
  324. package/src/resources/extensions/gsd/types.ts +1 -1
  325. package/src/resources/extensions/gsd/unit-context-manifest.ts +47 -11
  326. package/src/resources/extensions/gsd/validation.ts +23 -1
  327. package/src/resources/extensions/gsd/verification-gate.ts +78 -6
  328. package/src/resources/extensions/gsd/verification-verdict.ts +47 -0
  329. package/src/resources/extensions/gsd/workflow-projections.ts +6 -8
  330. package/src/resources/extensions/gsd/worktree-lifecycle.ts +61 -10
  331. package/src/resources/extensions/shared/html-shell.ts +412 -0
  332. package/src/resources/extensions/subagent/index.ts +567 -103
  333. package/src/resources/extensions/subagent/launch.ts +131 -0
  334. package/src/resources/extensions/subagent/run-store.ts +218 -0
  335. package/src/resources/extensions/subagent/tests/launch.test.ts +115 -0
  336. package/src/resources/extensions/subagent/tests/run-store.test.ts +111 -0
  337. package/src/resources/extensions/visual-brief/artifact-policy.ts +41 -0
  338. package/src/resources/extensions/visual-brief/extension-manifest.json +8 -0
  339. package/src/resources/extensions/visual-brief/index.ts +8 -0
  340. package/src/resources/extensions/visual-brief/page-contract.ts +136 -0
  341. package/src/resources/extensions/visual-brief/prompts.ts +183 -0
  342. package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +212 -0
  343. package/dist/web/standalone/.next/server/chunks/5822.js +0 -2
  344. package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +0 -1
  345. package/dist/web/standalone/.next/static/chunks/app/layout-a16c7a7ecdf0c2cf.js +0 -1
  346. package/dist/web/standalone/.next/static/css/54ec2745c1da488b.css +0 -1
  347. package/dist/web/standalone/.next/static/css/de70bee13400563f.css +0 -1
  348. package/dist/web/standalone/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  349. package/dist/web/standalone/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  350. package/dist/web/standalone/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  351. package/dist/web/standalone/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  352. package/dist/web/standalone/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  353. package/dist/web/standalone/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  354. /package/dist/web/standalone/.next/static/{KDRTXR-22LPCsa80X9dey → euQ0CLP_v8V4e76Tu3odJ}/_buildManifest.js +0 -0
  355. /package/dist/web/standalone/.next/static/{KDRTXR-22LPCsa80X9dey → euQ0CLP_v8V4e76Tu3odJ}/_ssgManifest.js +0 -0
@@ -71,6 +71,16 @@ function parsePhaseEntry(line) {
71
71
  raw: line,
72
72
  };
73
73
  }
74
+ // Format 3: - ✅ v1.0 MVP — Phases 1-6
75
+ const fmtVersionPhases = stripped.match(/^-\s+([✅🚧])\s+v\d+(?:\.\d+)*\s+(.+?)\s*[—–]\s*Phases?\s+(\d+(?:\.\d+)?)(?:\s*-\s*\d+(?:\.\d+)?)?(?:\s+\(.*\))?\s*$/iu);
76
+ if (fmtVersionPhases) {
77
+ return {
78
+ number: parseFloat(fmtVersionPhases[3]),
79
+ title: fmtVersionPhases[2].trim(),
80
+ done: fmtVersionPhases[1] === '✅',
81
+ raw: line,
82
+ };
83
+ }
74
84
  return null;
75
85
  }
76
86
  /**
@@ -1,5 +1,11 @@
1
1
  // GSD Migration Preview — Pre-write statistics
2
2
  // Pure function, no I/O. Computes counts from a GSDProject.
3
+ function countCanonicalDecisionRows(content) {
4
+ return content
5
+ .split('\n')
6
+ .filter((line) => /^\|\s*D\d+\s*\|/.test(line.trim()))
7
+ .length;
8
+ }
3
9
  /**
4
10
  * Compute pre-write statistics from a GSDProject without performing I/O.
5
11
  * Used to show the user what a migration will produce before writing anything.
@@ -35,6 +41,9 @@ export function generatePreview(project) {
35
41
  reqCounts.total++;
36
42
  }
37
43
  return {
44
+ decisions: {
45
+ total: countCanonicalDecisionRows(project.decisionsContent),
46
+ },
38
47
  milestoneCount: project.milestones.length,
39
48
  totalSlices,
40
49
  totalTasks,
@@ -187,16 +187,48 @@ function normalizeStatus(status) {
187
187
  return 'validated';
188
188
  return 'active';
189
189
  }
190
+ function normalizeRequirementId(id) {
191
+ const match = id.trim().match(/^R(\d+)$/i);
192
+ if (!match)
193
+ return null;
194
+ return `R${match[1].padStart(3, '0')}`;
195
+ }
190
196
  function mapRequirements(reqs) {
191
197
  let autoId = 0;
198
+ const reservedIds = new Set(reqs
199
+ .map((req) => normalizeRequirementId(req.id))
200
+ .filter((id) => id !== null));
201
+ const usedIds = new Set();
202
+ function nextRequirementId() {
203
+ let id = '';
204
+ do {
205
+ autoId++;
206
+ id = padId('R', autoId, 3);
207
+ } while (usedIds.has(id) || reservedIds.has(id));
208
+ usedIds.add(id);
209
+ return id;
210
+ }
192
211
  return reqs.map((req) => {
193
- autoId++;
212
+ const originalId = req.id.trim();
213
+ const canonicalId = normalizeRequirementId(originalId);
214
+ let id;
215
+ let description = req.description;
216
+ if (canonicalId && !usedIds.has(canonicalId)) {
217
+ id = canonicalId;
218
+ usedIds.add(id);
219
+ }
220
+ else {
221
+ id = nextRequirementId();
222
+ if (originalId) {
223
+ description = `Legacy ID: ${originalId}\n\n${description}`;
224
+ }
225
+ }
194
226
  return {
195
- id: req.id && req.id.trim() !== '' ? req.id : padId('R', autoId, 3),
227
+ id,
196
228
  title: req.title,
197
229
  class: 'core-capability',
198
230
  status: normalizeStatus(req.status),
199
- description: req.description,
231
+ description,
200
232
  source: 'inferred',
201
233
  primarySlice: 'none yet',
202
234
  };
@@ -233,7 +265,22 @@ function deriveDecisions(parsed) {
233
265
  }
234
266
  if (decisions.length === 0)
235
267
  return '';
236
- return decisions.map((d) => `- ${d}`).join('\n');
268
+ const lines = [
269
+ '# Decisions Register',
270
+ '',
271
+ '<!-- Append-only. Never edit or remove existing rows.',
272
+ ' To reverse a decision, add a new row that supersedes it.',
273
+ ' Read this file at the start of any planning or research phase. -->',
274
+ '',
275
+ '| # | When | Scope | Decision | Choice | Rationale | Revisable? | Made By |',
276
+ '|---|------|-------|----------|--------|-----------|------------|---------|',
277
+ ];
278
+ decisions.forEach((decision, index) => {
279
+ const id = padId('D', index + 1, 3);
280
+ const escaped = decision.replace(/\|/g, '\\|');
281
+ lines.push(`| ${id} | migration | migrated-summary | ${escaped} | ${escaped} | Migrated from legacy summary key-decisions | Yes | agent |`);
282
+ });
283
+ return lines.join('\n') + '\n';
237
284
  }
238
285
  // ─── Main Entry Point ──────────────────────────────────────────────────────
239
286
  export function transformToGSD(parsed) {
@@ -296,7 +296,17 @@ export function formatProject(content) {
296
296
  */
297
297
  export function formatDecisions(content) {
298
298
  if (!content || !content.trim()) {
299
- return '# Decisions\n\n<!-- Append-only register of architectural and pattern decisions -->\n\n| ID | Decision | Rationale | Date |\n|----|----------|-----------|------|\n';
299
+ return [
300
+ '# Decisions Register',
301
+ '',
302
+ '<!-- Append-only. Never edit or remove existing rows.',
303
+ ' To reverse a decision, add a new row that supersedes it.',
304
+ ' Read this file at the start of any planning or research phase. -->',
305
+ '',
306
+ '| # | When | Scope | Decision | Choice | Rationale | Revisable? | Made By |',
307
+ '|---|------|-------|----------|--------|-----------|------------|---------|',
308
+ '',
309
+ ].join('\n');
300
310
  }
301
311
  return content.endsWith('\n') ? content : content + '\n';
302
312
  }
@@ -1,10 +1,8 @@
1
1
  import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { ensureDbOpen } from "./bootstrap/dynamic-tools.js";
3
- import { clearEngineHierarchy, getAllMilestones, getMilestoneSlices, getSliceTasks, isDbAvailable, transaction, } from "./gsd-db.js";
4
- import { migrateHierarchyToDb } from "./md-importer.js";
3
+ import { getAllMilestones, getMilestoneSlices, getSliceTasks, isDbAvailable, } from "./gsd-db.js";
5
4
  import { parsePlan, parseRoadmap } from "./parsers-legacy.js";
6
5
  import { milestonesDir, resolveMilestoneFile, resolveSliceFile, } from "./paths.js";
7
- import { invalidateStateCache } from "./state.js";
8
6
  function zeroCounts() {
9
7
  return { milestones: 0, slices: 0, tasks: 0 };
10
8
  }
@@ -50,7 +48,7 @@ export function countDbHierarchy() {
50
48
  }
51
49
  return counts;
52
50
  }
53
- export async function autoImportMarkdownHierarchyIfDbMismatch(basePath) {
51
+ export async function checkMarkdownHierarchyAgainstDb(basePath) {
54
52
  const markdown = countMarkdownHierarchy(basePath);
55
53
  if (sameCounts(markdown, zeroCounts())) {
56
54
  return {
@@ -70,18 +68,15 @@ export async function autoImportMarkdownHierarchyIfDbMismatch(basePath) {
70
68
  return { action: "none", reason: "in-sync", markdown, beforeDb, afterDb: beforeDb };
71
69
  }
72
70
  const reason = sameCounts(beforeDb, zeroCounts()) ? "db-empty" : "count-mismatch";
73
- const imported = transaction(() => {
74
- clearEngineHierarchy();
75
- return migrateHierarchyToDb(basePath);
76
- });
77
- invalidateStateCache();
78
- const afterDb = {
79
- milestones: imported.milestones,
80
- slices: imported.slices,
81
- tasks: imported.tasks,
71
+ return {
72
+ action: "recovery-required",
73
+ reason,
74
+ markdown,
75
+ beforeDb,
76
+ afterDb: beforeDb,
77
+ recoveryCommand: "gsd recover",
78
+ message: `Markdown planning artifacts (${markdown.milestones}M/${markdown.slices}S/${markdown.tasks}T) ` +
79
+ `do not match the authoritative DB (${beforeDb.milestones}M/${beforeDb.slices}S/${beforeDb.tasks}T). ` +
80
+ "Runtime startup will not import markdown automatically; run explicit GSD recovery if markdown should repopulate the database.",
82
81
  };
83
- if (!sameCounts(markdown, afterDb)) {
84
- throw new Error(`migration auto-import verification failed: markdown ${markdown.milestones}M/${markdown.slices}S/${markdown.tasks}T, db ${afterDb.milestones}M/${afterDb.slices}S/${afterDb.tasks}T`);
85
- }
86
- return { action: "imported", reason, markdown, beforeDb, afterDb };
87
82
  }
@@ -19,6 +19,7 @@ import { deleteMilestone, getMilestone, isDbAvailable, updateMilestoneStatus } f
19
19
  import { removeWorktree } from "./worktree-manager.js";
20
20
  import { logWarning } from "./workflow-logger.js";
21
21
  import { isAutoActive } from "./auto.js";
22
+ import { isClosedStatus } from "./status-guards.js";
22
23
  /**
23
24
  * Writer-side assert for mutations that race with auto-mode's squash merge (#4704).
24
25
  * Auto-mode is confirmed not to call parkMilestone/discardMilestone/unparkMilestone
@@ -34,7 +35,7 @@ function assertNotAutoActive(action) {
34
35
  /**
35
36
  * Park a milestone — creates a PARKED.md marker file with reason and timestamp.
36
37
  * Parked milestones are skipped during active-milestone discovery but stay on disk.
37
- * Returns true if successfully parked, false if milestone not found or already parked.
38
+ * Returns true if successfully parked, false if milestone not found, already parked, or complete.
38
39
  */
39
40
  export function parkMilestone(basePath, milestoneId, reason) {
40
41
  assertNotAutoActive("park milestone");
@@ -42,9 +43,15 @@ export function parkMilestone(basePath, milestoneId, reason) {
42
43
  if (!mDir || !existsSync(mDir))
43
44
  return false;
44
45
  // Guard: do not park a completed milestone — it would corrupt depends_on satisfaction
45
- const summaryFile = resolveMilestoneFile(basePath, milestoneId, "SUMMARY");
46
- if (summaryFile)
46
+ const dbAvailable = isDbAvailable();
47
+ const milestone = dbAvailable ? getMilestone(milestoneId) : null;
48
+ if (milestone && isClosedStatus(milestone.status))
47
49
  return false;
50
+ if (!dbAvailable) {
51
+ const summaryFile = resolveMilestoneFile(basePath, milestoneId, "SUMMARY");
52
+ if (summaryFile)
53
+ return false;
54
+ }
48
55
  const parkedPath = join(mDir, buildMilestoneFileName(milestoneId, "PARKED"));
49
56
  if (existsSync(parkedPath))
50
57
  return false; // already parked
@@ -61,7 +68,7 @@ export function parkMilestone(basePath, milestoneId, reason) {
61
68
  ].join("\n");
62
69
  writeFileSync(parkedPath, content, "utf-8");
63
70
  // Sync DB status so deriveStateFromDb also skips this milestone (#2694)
64
- if (isDbAvailable()) {
71
+ if (dbAvailable) {
65
72
  try {
66
73
  updateMilestoneStatus(milestoneId, "parked");
67
74
  }
@@ -14,6 +14,8 @@ import { isInfrastructureError } from "./auto/infra-errors.js";
14
14
  // Issue #453: keep auto-mode bookkeeping on the stable git CLI path unless a
15
15
  // caller explicitly opts into the native helper.
16
16
  const NATIVE_GSD_GIT_ENABLED = process.env.GSD_ENABLE_NATIVE_GSD_GIT === "1";
17
+ const TRANSIENT_GIT_RETRY_CODES = new Set(["ENOBUFS", "EAGAIN"]);
18
+ const GIT_RETRY_DELAY_MS = 200;
17
19
  // ─── Native Module Loading ──────────────────────────────────────────────────
18
20
  let nativeModule = null;
19
21
  let loadAttempted = false;
@@ -46,10 +48,42 @@ function gitExec(basePath, args, allowFailure = false) {
46
48
  env: GIT_NO_PROMPT_ENV,
47
49
  }).trim();
48
50
  }
49
- catch {
51
+ catch (err) {
50
52
  if (allowFailure)
51
53
  return "";
52
- throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}`);
54
+ throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}: ${getErrorMessage(err)}`);
55
+ }
56
+ }
57
+ /** sleepSync uses Atomics.wait for a blocking pause without busy-waiting; it blocks the current thread and requires Atomics.wait support. */
58
+ function sleepSync(ms) {
59
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
60
+ }
61
+ function isRetryableGitError(err) {
62
+ const code = isInfrastructureError(err)
63
+ ?? isInfrastructureError(err?.stderr ?? "");
64
+ return code !== null && TRANSIENT_GIT_RETRY_CODES.has(code);
65
+ }
66
+ function execGitFileSyncWithRetry(basePath, args, options) {
67
+ try {
68
+ return execFileSync("git", args, {
69
+ cwd: basePath,
70
+ stdio: ["ignore", "pipe", "pipe"],
71
+ encoding: "utf-8",
72
+ env: GIT_NO_PROMPT_ENV,
73
+ ...options,
74
+ }).trim();
75
+ }
76
+ catch (err) {
77
+ if (!isRetryableGitError(err))
78
+ throw err;
79
+ sleepSync(GIT_RETRY_DELAY_MS);
80
+ return execFileSync("git", args, {
81
+ cwd: basePath,
82
+ stdio: ["ignore", "pipe", "pipe"],
83
+ encoding: "utf-8",
84
+ env: GIT_NO_PROMPT_ENV,
85
+ ...options,
86
+ }).trim();
53
87
  }
54
88
  }
55
89
  /** Run a git command via execFileSync. Returns trimmed stdout. */
@@ -62,10 +96,10 @@ function gitFileExec(basePath, args, allowFailure = false) {
62
96
  env: GIT_NO_PROMPT_ENV,
63
97
  }).trim();
64
98
  }
65
- catch {
99
+ catch (err) {
66
100
  if (allowFailure)
67
101
  return "";
68
- throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}`);
102
+ throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}: ${getErrorMessage(err)}`);
69
103
  }
70
104
  }
71
105
  // ─── Existing Read Functions ──────────────────────────────────────────────
@@ -303,15 +337,20 @@ export function nativeDiffNameStatus(basePath, fromRef, toRef, pathspec, useMerg
303
337
  }
304
338
  /**
305
339
  * Get numstat diff between two refs.
340
+ * useMergeBase: if true, uses three-dot semantics.
306
341
  * Native: libgit2 patch line stats.
307
342
  * Fallback: `git diff --numstat`.
308
343
  */
309
- export function nativeDiffNumstat(basePath, fromRef, toRef) {
344
+ export function nativeDiffNumstat(basePath, fromRef, toRef, useMergeBase) {
310
345
  const native = loadNative();
311
- if (native) {
346
+ if (native && !useMergeBase) {
312
347
  return native.gitDiffNumstat(basePath, fromRef, toRef);
313
348
  }
314
- const result = gitExec(basePath, ["diff", "--numstat", fromRef, toRef], true);
349
+ const refspec = useMergeBase ? `${fromRef}...${toRef}` : undefined;
350
+ const args = refspec
351
+ ? ["diff", "--numstat", refspec]
352
+ : ["diff", "--numstat", fromRef, toRef];
353
+ const result = gitExec(basePath, args, true);
315
354
  if (!result)
316
355
  return [];
317
356
  return result.split("\n").filter(Boolean).map(line => {
@@ -777,13 +816,10 @@ export function nativeCommit(basePath, message, options) {
777
816
  const args = ["commit", "-F", "-"];
778
817
  if (options?.allowEmpty)
779
818
  args.push("--allow-empty");
780
- const result = execFileSync("git", args, {
781
- cwd: basePath,
819
+ const result = execGitFileSyncWithRetry(basePath, args, {
782
820
  stdio: ["pipe", "pipe", "pipe"],
783
- encoding: "utf-8",
784
- env: GIT_NO_PROMPT_ENV,
785
821
  input: message,
786
- }).trim();
822
+ });
787
823
  return result;
788
824
  }
789
825
  catch (err) {
@@ -17,6 +17,43 @@
17
17
  import { existsSync, readFileSync } from "node:fs";
18
18
  import { resolve, dirname, extname } from "node:path";
19
19
  // ─── Import Resolution Check ─────────────────────────────────────────────────
20
+ /**
21
+ * Replace the contents of single- and double-quoted string literals on a single
22
+ * source line with spaces so import patterns do not match text inside strings.
23
+ * Template-literal spans are handled separately via the inTemplateLiteral flag.
24
+ */
25
+ function stripStringLiterals(line) {
26
+ let result = "";
27
+ let i = 0;
28
+ while (i < line.length) {
29
+ const ch = line[i];
30
+ if (ch === '"' || ch === "'") {
31
+ result += ch;
32
+ i++;
33
+ while (i < line.length) {
34
+ const c = line[i];
35
+ if (c === "\\" && i + 1 < line.length) {
36
+ result += " ";
37
+ i += 2;
38
+ }
39
+ else if (c === ch) {
40
+ result += ch;
41
+ i++;
42
+ break;
43
+ }
44
+ else {
45
+ result += " ";
46
+ i++;
47
+ }
48
+ }
49
+ }
50
+ else {
51
+ result += ch;
52
+ i++;
53
+ }
54
+ }
55
+ return result;
56
+ }
20
57
  /**
21
58
  * Extract relative import paths from TypeScript/JavaScript source code.
22
59
  * Returns array of { importPath, lineNum } for relative imports.
@@ -30,11 +67,19 @@ export function extractRelativeImports(source) {
30
67
  // import './path'
31
68
  // require('./path')
32
69
  // require("../path")
33
- const importPattern = /(?:import\s+(?:.*?\s+from\s+)?|require\s*\(\s*)(['"])(\.\.?\/[^'"]+)\1/g;
70
+ const importPattern = /(?:^|[;{}]\s*)import\s+(?:.*?\s+from\s+)?(['"])(\.\.?\/[^'"]+)\1/g;
71
+ const requirePattern = /require\s*\(\s*(['"])(\.\.?\/[^'"]+)\1/g;
34
72
  // Track if we're inside a block comment
35
73
  let inBlockComment = false;
74
+ let inTemplateLiteral = false;
36
75
  for (let i = 0; i < lines.length; i++) {
37
76
  const line = lines[i];
77
+ if (inTemplateLiteral) {
78
+ if ((line.match(/(?<!\\)`/g) ?? []).length % 2 === 1) {
79
+ inTemplateLiteral = false;
80
+ }
81
+ continue;
82
+ }
38
83
  // Handle block comment boundaries
39
84
  if (inBlockComment) {
40
85
  if (line.includes("*/")) {
@@ -61,9 +106,17 @@ export function extractRelativeImports(source) {
61
106
  let match;
62
107
  // Reset lastIndex for each line
63
108
  importPattern.lastIndex = 0;
109
+ requirePattern.lastIndex = 0;
110
+ const strippedLine = stripStringLiterals(line);
64
111
  while ((match = importPattern.exec(line)) !== null) {
112
+ const importOffset = match[0].indexOf("import");
113
+ const importStart = match.index + importOffset;
114
+ if (strippedLine.slice(importStart, importStart + "import".length) !==
115
+ "import") {
116
+ continue;
117
+ }
65
118
  // Check if this match is after a // comment marker on the same line
66
- const beforeMatch = line.substring(0, match.index);
119
+ const beforeMatch = strippedLine.substring(0, match.index);
67
120
  if (beforeMatch.includes("//")) {
68
121
  continue;
69
122
  }
@@ -72,6 +125,24 @@ export function extractRelativeImports(source) {
72
125
  lineNum: i + 1,
73
126
  });
74
127
  }
128
+ while ((match = requirePattern.exec(line)) !== null) {
129
+ if (strippedLine.slice(match.index, match.index + "require".length) !==
130
+ "require") {
131
+ continue;
132
+ }
133
+ // Check if this match is after a // comment marker on the same line
134
+ const beforeMatch = strippedLine.substring(0, match.index);
135
+ if (beforeMatch.includes("//")) {
136
+ continue;
137
+ }
138
+ imports.push({
139
+ importPath: match[2],
140
+ lineNum: i + 1,
141
+ });
142
+ }
143
+ if ((strippedLine.match(/(?<!\\)`/g) ?? []).length % 2 === 1) {
144
+ inTemplateLiteral = true;
145
+ }
75
146
  }
76
147
  return imports;
77
148
  }
@@ -19,7 +19,33 @@ import { existsSync } from "node:fs";
19
19
  import { spawn } from "node:child_process";
20
20
  import { homedir } from "node:os";
21
21
  import { resolve } from "node:path";
22
+ import { validateVerificationCommand } from "./verification-gate.js";
22
23
  const NPM_COMMAND = process.platform === "win32" ? "npm.cmd" : "npm";
24
+ export function checkVerificationCommands(tasks) {
25
+ const results = [];
26
+ for (const task of tasks) {
27
+ const verify = task.verify.trim();
28
+ if (!verify)
29
+ continue;
30
+ const commands = verify
31
+ .split("&&")
32
+ .map((command) => command.trim())
33
+ .filter(Boolean);
34
+ for (const command of commands) {
35
+ const validation = validateVerificationCommand(command);
36
+ if (!validation.ok) {
37
+ results.push({
38
+ category: "tool",
39
+ target: `${task.id} Verify`,
40
+ passed: false,
41
+ message: `Unsafe or non-runnable Verify command: ${command} (${validation.reason})`,
42
+ blocking: true,
43
+ });
44
+ }
45
+ }
46
+ }
47
+ return results;
48
+ }
23
49
  // ─── Package Existence Check ─────────────────────────────────────────────────
24
50
  /**
25
51
  * Extract npm package names from task descriptions.
@@ -647,7 +673,8 @@ export async function runPreExecutionChecks(tasks, basePath) {
647
673
  const fileChecks = checkFilePathConsistency(tasks, basePath);
648
674
  const orderingChecks = checkTaskOrdering(tasks, basePath);
649
675
  const contractChecks = checkInterfaceContracts(tasks, basePath);
650
- allChecks.push(...fileChecks, ...orderingChecks, ...contractChecks);
676
+ const verificationChecks = checkVerificationCommands(tasks);
677
+ allChecks.push(...fileChecks, ...orderingChecks, ...contractChecks, ...verificationChecks);
651
678
  // Run async package checks
652
679
  const packageChecks = await checkPackageExistence(tasks, basePath);
653
680
  allChecks.push(...packageChecks);
@@ -181,7 +181,7 @@ export function loadPrompt(name, vars = {}) {
181
181
  .map(m => m.slice(2, -2))
182
182
  .filter(key => !(key in effectiveVars));
183
183
  if (missing.length > 0) {
184
- throw new GSDError(GSD_PARSE_ERROR, `loadPrompt("${name}"): template declares {{${missing.join("}}, {{")}}}} but no value was provided. ` +
184
+ throw new GSDError(GSD_PARSE_ERROR, `loadPrompt("${name}"): template declares {{${missing.join("}}, {{")}}} but no value was provided. ` +
185
185
  `This usually means the extension code in memory is older than the template on disk. ` +
186
186
  `Restart pi to reload the extension.`);
187
187
  }
@@ -57,7 +57,7 @@ Subagents report only; they do not write user source. Fold any findings into Dec
57
57
  **Success path** (all verifications passed):
58
58
 
59
59
  10. For each requirement whose status changed in step 9, call `gsd_requirement_update` with the requirement ID and updated `status` and `validation` fields — the tool regenerates `.gsd/REQUIREMENTS.md` automatically. Do this BEFORE completing the milestone so requirement updates are persisted.
60
- 11. Update `.gsd/PROJECT.md`: use the `write` tool with `path: ".gsd/PROJECT.md"` and `content` containing the full updated document reflecting milestone completion and current project state. Do NOT use the `edit` tool for this PROJECT.md is a full-document refresh.
60
+ 11. Refresh the project state through `gsd_summary_save` with `artifact_type: "PROJECT"` and the full updated project markdown as `content`; omit `milestone_id`. The tool persists the DB-backed PROJECT artifact and renders `.gsd/PROJECT.md`. Do not write or edit `.gsd/PROJECT.md` directly.
61
61
  12. Extract structured learnings from this milestone and persist them to the GSD memory store. Follow the procedure block immediately below — it writes `{{milestoneId}}-LEARNINGS.md` as the audit trail and persists Patterns, Lessons, and Decisions via `capture_thought` (categories: pattern, gotcha/convention, architecture). The memory store is the single source of truth for cross-session durable knowledge (ADR-013).
62
62
 
63
63
  {{extractLearningsSteps}}
@@ -34,7 +34,7 @@ Use `subagent` only for fresh-context review when useful: reviewer for cross-cut
34
34
  12. Review the inlined task-summary excerpts for DECISIONS.md and KNOWLEDGE.md-worthy decisions, patterns, and gotchas. Read full `*-SUMMARY.md` files only when an excerpt is absent, truncated, or lacks the specific evidence needed for the slice narrative. Capture significant items with `capture_thought`; do not append knowledge files directly.
35
35
  13. When verification passes, call `gsd_slice_complete`. The DB-backed tool is the canonical write path. Do **not** manually write `{{sliceSummaryPath}}`. Do **not** manually write `{{sliceUatPath}}`. Do not edit roadmap checkboxes; the tool renders files and updates projections.
36
36
  14. Do not run git commands.
37
- 15. Update `.gsd/PROJECT.md` with a full `write` only if the current project state needs refresh.
37
+ 15. If the current project state needs refresh, call `gsd_summary_save` with `artifact_type: "PROJECT"` and the full updated project markdown as `content`; omit `milestone_id`. Do not write or edit `.gsd/PROJECT.md` directly.
38
38
 
39
39
  **Autonomous execution:** no human is available. Do not call `ask_user_questions` or `secure_env_collect`; make reasonable assumptions and document them.
40
40
 
@@ -106,8 +106,8 @@ Directories use bare IDs. Files use ID-SUFFIX format. Titles live inside content
106
106
 
107
107
  In a single pass:
108
108
  1. `mkdir -p .gsd/milestones/{{milestoneId}}/slices`
109
- 2. Write or update `.gsd/PROJECT.md` use the **Project** output template below. Describe what the project is, its current state, and list the milestone sequence.
110
- 3. Write or update `.gsd/REQUIREMENTS.md` use the **Requirements** output template below. Confirm states, ownership, and traceability before roadmap creation.
109
+ 2. Call `gsd_summary_save` with `artifact_type: "PROJECT"` and full Project template content. The tool persists the DB-backed PROJECT artifact and renders `.gsd/PROJECT.md`. Describe what the project is, its current state, and list the milestone sequence.
110
+ 3. Persist requirements with `gsd_requirement_save` or `gsd_requirement_update`, then call `gsd_summary_save` with `artifact_type: "REQUIREMENTS"` so the tool renders `.gsd/REQUIREMENTS.md` from DB rows. Confirm states, ownership, and traceability before roadmap creation.
111
111
 
112
112
  **Depth-Preservation Guidance for context.md:** Preserve the specification's exact terminology, emphasis, and framing. Do not flatten domain-specific language into generics. CONTEXT.md is downstream agents' only window into this spec.
113
113
 
@@ -120,8 +120,8 @@ In a single pass:
120
120
 
121
121
  Before emitting the ready phrase, verify in the CURRENT turn that you have:
122
122
 
123
- - [ ] Written `.gsd/PROJECT.md` (step 2)
124
- - [ ] Written `.gsd/REQUIREMENTS.md` (step 3)
123
+ - [ ] Called `gsd_summary_save` for the PROJECT artifact (step 2)
124
+ - [ ] Persisted requirements and called `gsd_summary_save` for the REQUIREMENTS artifact (step 3)
125
125
  - [ ] Written `{{contextPath}}` (step 4)
126
126
  - [ ] Called `gsd_plan_milestone` (step 5)
127
127
 
@@ -145,8 +145,8 @@ Next steps:
145
145
  #### Phase 1: Shared artifacts
146
146
 
147
147
  1. For each milestone, call `gsd_milestone_generate_id`; never invent IDs. Then `mkdir -p .gsd/milestones/<ID>/slices`.
148
- 2. Write `.gsd/PROJECT.md` use the **Project** output template below.
149
- 3. Write `.gsd/REQUIREMENTS.md` use the **Requirements** output template below. Capture Active, Deferred, Out of Scope, and any already Validated requirements. Later milestones may have provisional ownership where slice plans do not exist yet.
148
+ 2. Call `gsd_summary_save` with `artifact_type: "PROJECT"` and full Project template content so the tool persists the DB-backed PROJECT artifact and renders `.gsd/PROJECT.md`.
149
+ 3. Persist requirements with `gsd_requirement_save` or `gsd_requirement_update`, then call `gsd_summary_save` with `artifact_type: "REQUIREMENTS"` so the tool renders `.gsd/REQUIREMENTS.md` from DB rows. Capture Active, Deferred, Out of Scope, and any already Validated requirements. Later milestones may have provisional ownership where slice plans do not exist yet.
150
150
  4. For any architectural or pattern decisions, call `gsd_decision_save` — the tool auto-assigns IDs and regenerates `.gsd/DECISIONS.md` automatically.
151
151
 
152
152
  #### Phase 2: Primary milestone
@@ -214,8 +214,8 @@ For single-milestone projects, do NOT write this file.
214
214
 
215
215
  Before emitting the ready phrase, verify in the CURRENT turn that you have:
216
216
 
217
- - [ ] Written `.gsd/PROJECT.md`
218
- - [ ] Written `.gsd/REQUIREMENTS.md`
217
+ - [ ] Called `gsd_summary_save` for the PROJECT artifact
218
+ - [ ] Persisted requirements and called `gsd_summary_save` for the REQUIREMENTS artifact
219
219
  - [ ] Written the primary milestone `CONTEXT.md`
220
220
  - [ ] Called `gsd_plan_milestone` for the primary milestone
221
221
  - [ ] Written `.gsd/DISCUSSION-MANIFEST.json` with `gates_completed === total`
@@ -186,7 +186,7 @@ Research is advisory, not auto-binding. Use discussion output to identify table
186
186
 
187
187
  ## Capability Contract
188
188
 
189
- Before writing a roadmap, produce or update `.gsd/REQUIREMENTS.md`.
189
+ Before writing a roadmap, persist requirements with `gsd_requirement_save` or `gsd_requirement_update`, then render `.gsd/REQUIREMENTS.md` through `gsd_summary_save` with `artifact_type: "REQUIREMENTS"`.
190
190
 
191
191
  Use it as the project's explicit capability contract.
192
192
 
@@ -226,8 +226,8 @@ Directories use bare IDs. Files use ID-SUFFIX format. Titles live inside file co
226
226
 
227
227
  Once the user is satisfied, in a single pass:
228
228
  1. `mkdir -p .gsd/milestones/{{milestoneId}}/slices`
229
- 2. Write or update `.gsd/PROJECT.md` use the **Project** output template below. Describe what the project is, its current state, and list the milestone sequence.
230
- 3. Write or update `.gsd/REQUIREMENTS.md` use the **Requirements** output template below. Confirm requirement states, ownership, and traceability before roadmap creation.
229
+ 2. Call `gsd_summary_save` with `artifact_type: "PROJECT"` and full Project template content. The tool persists the DB-backed PROJECT artifact and renders `.gsd/PROJECT.md`. Describe what the project is, its current state, and list the milestone sequence.
230
+ 3. Persist requirements with `gsd_requirement_save` or `gsd_requirement_update`, then call `gsd_summary_save` with `artifact_type: "REQUIREMENTS"` so the tool renders `.gsd/REQUIREMENTS.md` from DB rows. Confirm requirement states, ownership, and traceability before roadmap creation.
231
231
  **Depth-Preservation Guidance for context.md:**
232
232
  When writing context.md, preserve the user's exact terminology, emphasis, and framing. Do not flatten nuance into generic summaries. If the user said "craft feel," write "craft feel," not "high-quality user experience." CONTEXT.md is downstream agents' only window into this conversation.
233
233
 
@@ -243,8 +243,8 @@ When writing CONTEXT.md, include discussion-layer sections: **Scope**, **Archite
243
243
 
244
244
  Before emitting the ready phrase, verify in the CURRENT turn that you have:
245
245
 
246
- - [ ] Written `.gsd/PROJECT.md` (step 2)
247
- - [ ] Written `.gsd/REQUIREMENTS.md` (step 3)
246
+ - [ ] Called `gsd_summary_save` for the PROJECT artifact (step 2)
247
+ - [ ] Persisted requirements and called `gsd_summary_save` for the REQUIREMENTS artifact (step 3)
248
248
  - [ ] Written `{{contextPath}}` (step 4)
249
249
  - [ ] Called `gsd_plan_milestone` (step 5)
250
250
 
@@ -270,8 +270,8 @@ Once the user confirms the milestone split:
270
270
  #### Phase 1: Shared artifacts
271
271
 
272
272
  1. For each milestone, call `gsd_milestone_generate_id`; never invent IDs. Then `mkdir -p .gsd/milestones/<ID>/slices`.
273
- 2. Write `.gsd/PROJECT.md` use the **Project** output template below.
274
- 3. Write `.gsd/REQUIREMENTS.md` use the **Requirements** output template below. Capture Active, Deferred, Out of Scope, and any already Validated requirements. Later milestones may have provisional ownership where slice plans do not exist yet.
273
+ 2. Call `gsd_summary_save` with `artifact_type: "PROJECT"` and full Project template content so the tool persists the DB-backed PROJECT artifact and renders `.gsd/PROJECT.md`.
274
+ 3. Persist requirements with `gsd_requirement_save` or `gsd_requirement_update`, then call `gsd_summary_save` with `artifact_type: "REQUIREMENTS"` so the tool renders `.gsd/REQUIREMENTS.md` from DB rows. Capture Active, Deferred, Out of Scope, and any already Validated requirements. Later milestones may have provisional ownership where slice plans do not exist yet.
275
275
  4. For any architectural or pattern decisions made during discussion, call `gsd_decision_save` — the tool auto-assigns IDs and regenerates `.gsd/DECISIONS.md` automatically.
276
276
 
277
277
  #### Phase 2: Primary milestone
@@ -344,8 +344,8 @@ For single-milestone projects, do NOT write this file.
344
344
 
345
345
  Before emitting the ready phrase, verify in the CURRENT turn that you have:
346
346
 
347
- - [ ] Written `.gsd/PROJECT.md` (Phase 1)
348
- - [ ] Written `.gsd/REQUIREMENTS.md` (Phase 1)
347
+ - [ ] Called `gsd_summary_save` for the PROJECT artifact (Phase 1)
348
+ - [ ] Persisted requirements and called `gsd_summary_save` for the REQUIREMENTS artifact (Phase 1)
349
349
  - [ ] Written primary-milestone `CONTEXT.md` (Phase 2)
350
350
  - [ ] Called `gsd_plan_milestone` for the primary milestone (Phase 2)
351
351
  - [ ] Written `.gsd/DISCUSSION-MANIFEST.json` with `gates_completed === total` (Phase 3)