gsd-pi 2.82.0-dev.2841a1e44 → 2.82.0-dev.3a3c6509d

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 (377) hide show
  1. package/README.md +3 -3
  2. package/dist/resources/.managed-resources-content-hash +1 -1
  3. package/dist/resources/GSD-WORKFLOW.md +7 -0
  4. package/dist/resources/extensions/claude-code-cli/partial-builder.js +2 -1
  5. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +1 -1
  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 +11 -0
  9. package/dist/resources/extensions/gsd/auto/phases.js +81 -31
  10. package/dist/resources/extensions/gsd/auto/workflow-memory-pressure.js +12 -0
  11. package/dist/resources/extensions/gsd/auto-dashboard.js +66 -1
  12. package/dist/resources/extensions/gsd/auto-direct-dispatch.js +1 -0
  13. package/dist/resources/extensions/gsd/auto-dispatch.js +20 -19
  14. package/dist/resources/extensions/gsd/auto-model-selection.js +2 -0
  15. package/dist/resources/extensions/gsd/auto-post-unit.js +71 -10
  16. package/dist/resources/extensions/gsd/auto-recovery.js +71 -14
  17. package/dist/resources/extensions/gsd/auto-start.js +87 -14
  18. package/dist/resources/extensions/gsd/auto-verification.js +17 -4
  19. package/dist/resources/extensions/gsd/auto-worktree.js +176 -10
  20. package/dist/resources/extensions/gsd/auto.js +37 -5
  21. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +31 -7
  22. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +10 -9
  23. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +4 -2
  24. package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +5 -2
  25. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +14 -2
  26. package/dist/resources/extensions/gsd/commands/handlers/core.js +17 -1
  27. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +7 -2
  28. package/dist/resources/extensions/gsd/crash-recovery.js +43 -5
  29. package/dist/resources/extensions/gsd/db/milestone-leases.js +24 -0
  30. package/dist/resources/extensions/gsd/db/unit-dispatches.js +3 -2
  31. package/dist/resources/extensions/gsd/dispatch-guard.js +2 -2
  32. package/dist/resources/extensions/gsd/doctor-git-checks.js +46 -1
  33. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +28 -11
  34. package/dist/resources/extensions/gsd/doctor.js +2 -28
  35. package/dist/resources/extensions/gsd/export-html.js +27 -425
  36. package/dist/resources/extensions/gsd/forensics.js +3 -3
  37. package/dist/resources/extensions/gsd/git-service.js +45 -3
  38. package/dist/resources/extensions/gsd/gsd-db.js +21 -6
  39. package/dist/resources/extensions/gsd/guided-flow-queue.js +4 -3
  40. package/dist/resources/extensions/gsd/guided-flow.js +101 -116
  41. package/dist/resources/extensions/gsd/guided-unit-context.js +23 -0
  42. package/dist/resources/extensions/gsd/migrate/parsers.js +10 -0
  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/pending-auto-start.js +52 -0
  47. package/dist/resources/extensions/gsd/post-execution-checks.js +73 -2
  48. package/dist/resources/extensions/gsd/pre-execution-checks.js +28 -1
  49. package/dist/resources/extensions/gsd/prompt-loader.js +1 -1
  50. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  51. package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  52. package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
  53. package/dist/resources/extensions/gsd/prompts/discuss.md +9 -9
  54. package/dist/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
  55. package/dist/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
  56. package/dist/resources/extensions/gsd/prompts/plan-slice.md +4 -4
  57. package/dist/resources/extensions/gsd/prompts/queue.md +4 -4
  58. package/dist/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  59. package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  60. package/dist/resources/extensions/gsd/queue-reorder-ui.js +30 -13
  61. package/dist/resources/extensions/gsd/smart-entry-routing.js +36 -0
  62. package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +6 -1
  63. package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +9 -14
  64. package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +19 -24
  65. package/dist/resources/extensions/gsd/state.js +1 -1
  66. package/dist/resources/extensions/gsd/status-guards.js +11 -0
  67. package/dist/resources/extensions/gsd/templates/plan.md +8 -5
  68. package/dist/resources/extensions/gsd/templates/task-plan.md +4 -2
  69. package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -8
  70. package/dist/resources/extensions/gsd/tools/complete-slice.js +6 -8
  71. package/dist/resources/extensions/gsd/tools/plan-milestone.js +7 -1
  72. package/dist/resources/extensions/gsd/tools/plan-slice.js +89 -14
  73. package/dist/resources/extensions/gsd/unit-context-manifest.js +7 -8
  74. package/dist/resources/extensions/gsd/validation.js +23 -1
  75. package/dist/resources/extensions/gsd/verification-gate.js +68 -7
  76. package/dist/resources/extensions/gsd/workflow-mcp.js +17 -1
  77. package/dist/resources/extensions/gsd/workflow-projections.js +6 -8
  78. package/dist/resources/extensions/gsd/worktree-lifecycle.js +33 -8
  79. package/dist/resources/extensions/gsd/worktree-manager.js +1 -1
  80. package/dist/resources/extensions/shared/html-shell.js +388 -0
  81. package/dist/resources/extensions/visual-brief/page-contract.js +2 -0
  82. package/dist/resources/extensions/visual-brief/prompts.js +29 -0
  83. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  84. package/dist/web/standalone/.next/BUILD_ID +1 -1
  85. package/dist/web/standalone/.next/app-path-routes-manifest.json +11 -11
  86. package/dist/web/standalone/.next/build-manifest.json +3 -3
  87. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  88. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  89. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  90. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  91. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  93. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  94. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  95. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  96. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  98. package/dist/web/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  99. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  100. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  101. package/dist/web/standalone/.next/server/app/_not-found.rsc +4 -7
  102. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -7
  103. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  104. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +4 -5
  105. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  106. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  107. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -5
  108. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  109. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  110. package/dist/web/standalone/.next/server/app/index.html +1 -1
  111. package/dist/web/standalone/.next/server/app/index.rsc +4 -7
  112. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  113. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -7
  114. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  115. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +4 -5
  116. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -5
  117. package/dist/web/standalone/.next/server/app/page.js +2 -2
  118. package/dist/web/standalone/.next/server/app/page.js.nft.json +1 -1
  119. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  120. package/dist/web/standalone/.next/server/app-paths-manifest.json +11 -11
  121. package/dist/web/standalone/.next/server/chunks/4266.js +2 -0
  122. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  123. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  124. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  125. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  126. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  127. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  128. package/dist/web/standalone/.next/static/chunks/app/layout-8c10ec293ae0f1d5.js +1 -0
  129. package/dist/web/standalone/.next/static/chunks/{webpack-6a95bc41e0f7ec89.js → webpack-9a4db269f9ed63ad.js} +1 -1
  130. package/dist/web/standalone/.next/static/css/746ee28c929d1880.css +1 -0
  131. package/package.json +2 -2
  132. package/packages/mcp-server/src/workflow-tools.test.ts +1 -1
  133. package/packages/native/tsconfig.json +2 -1
  134. package/packages/native/tsconfig.tsbuildinfo +1 -1
  135. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  136. package/packages/pi-ai/dist/providers/google-gemini-cli.js +5 -0
  137. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  138. package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts +2 -0
  139. package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts.map +1 -0
  140. package/packages/pi-ai/dist/providers/google-gemini-cli.test.js +41 -0
  141. package/packages/pi-ai/dist/providers/google-gemini-cli.test.js.map +1 -0
  142. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  143. package/packages/pi-ai/dist/providers/openai-codex-responses.js +82 -1
  144. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  145. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts +2 -0
  146. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts.map +1 -0
  147. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +52 -0
  148. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -0
  149. package/packages/pi-ai/dist/providers/simple-options.d.ts +2 -4
  150. package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  151. package/packages/pi-ai/dist/providers/simple-options.js +5 -6
  152. package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
  153. package/packages/pi-ai/dist/providers/simple-options.test.d.ts +2 -0
  154. package/packages/pi-ai/dist/providers/simple-options.test.d.ts.map +1 -0
  155. package/packages/pi-ai/dist/providers/simple-options.test.js +50 -0
  156. package/packages/pi-ai/dist/providers/simple-options.test.js.map +1 -0
  157. package/packages/pi-ai/src/providers/google-gemini-cli.test.ts +49 -0
  158. package/packages/pi-ai/src/providers/google-gemini-cli.ts +7 -0
  159. package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +63 -0
  160. package/packages/pi-ai/src/providers/openai-codex-responses.ts +91 -1
  161. package/packages/pi-ai/src/providers/simple-options.test.ts +60 -0
  162. package/packages/pi-ai/src/providers/simple-options.ts +5 -6
  163. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  164. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts +2 -0
  165. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts.map +1 -0
  166. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js +66 -0
  167. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js.map +1 -0
  168. package/packages/pi-coding-agent/dist/core/agent-session.js +1 -1
  169. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  170. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +44 -3
  171. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  172. package/packages/pi-coding-agent/dist/core/sdk.js +1 -1
  173. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
  174. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
  175. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +24 -6
  176. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
  177. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  178. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +71 -97
  179. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  180. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js +12 -0
  181. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js.map +1 -1
  182. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  183. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +19 -8
  184. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  185. package/packages/pi-coding-agent/src/core/agent-session-thinking-level.test.ts +79 -0
  186. package/packages/pi-coding-agent/src/core/agent-session.ts +1 -1
  187. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +53 -3
  188. package/packages/pi-coding-agent/src/core/sdk.ts +1 -1
  189. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +23 -7
  190. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +75 -102
  191. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +14 -0
  192. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +23 -8
  193. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  194. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts +2 -0
  195. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts.map +1 -0
  196. package/packages/pi-tui/dist/__tests__/terminal.test.js +103 -0
  197. package/packages/pi-tui/dist/__tests__/terminal.test.js.map +1 -0
  198. package/packages/pi-tui/dist/terminal.d.ts +2 -0
  199. package/packages/pi-tui/dist/terminal.d.ts.map +1 -1
  200. package/packages/pi-tui/dist/terminal.js +12 -0
  201. package/packages/pi-tui/dist/terminal.js.map +1 -1
  202. package/packages/pi-tui/src/__tests__/terminal.test.ts +121 -0
  203. package/packages/pi-tui/src/terminal.ts +11 -0
  204. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  205. package/src/resources/GSD-WORKFLOW.md +7 -0
  206. package/src/resources/extensions/claude-code-cli/partial-builder.ts +2 -1
  207. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +1 -1
  208. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +19 -2
  209. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +9 -0
  210. package/src/resources/extensions/gsd/auto/contracts.ts +14 -6
  211. package/src/resources/extensions/gsd/auto/infra-errors.ts +9 -3
  212. package/src/resources/extensions/gsd/auto/loop.ts +8 -5
  213. package/src/resources/extensions/gsd/auto/orchestrator.ts +11 -0
  214. package/src/resources/extensions/gsd/auto/phases.ts +90 -38
  215. package/src/resources/extensions/gsd/auto/workflow-memory-pressure.ts +13 -0
  216. package/src/resources/extensions/gsd/auto-dashboard.ts +72 -1
  217. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +1 -0
  218. package/src/resources/extensions/gsd/auto-dispatch.ts +21 -19
  219. package/src/resources/extensions/gsd/auto-model-selection.ts +2 -1
  220. package/src/resources/extensions/gsd/auto-post-unit.ts +78 -8
  221. package/src/resources/extensions/gsd/auto-recovery.ts +74 -11
  222. package/src/resources/extensions/gsd/auto-start.ts +94 -12
  223. package/src/resources/extensions/gsd/auto-verification.ts +22 -2
  224. package/src/resources/extensions/gsd/auto-worktree.ts +193 -10
  225. package/src/resources/extensions/gsd/auto.ts +40 -5
  226. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +42 -7
  227. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +10 -9
  228. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +4 -2
  229. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +3 -1
  230. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +17 -2
  231. package/src/resources/extensions/gsd/commands/handlers/core.ts +17 -1
  232. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +8 -3
  233. package/src/resources/extensions/gsd/crash-recovery.ts +44 -4
  234. package/src/resources/extensions/gsd/db/milestone-leases.ts +26 -0
  235. package/src/resources/extensions/gsd/db/unit-dispatches.ts +4 -3
  236. package/src/resources/extensions/gsd/dispatch-guard.ts +2 -2
  237. package/src/resources/extensions/gsd/doctor-git-checks.ts +45 -1
  238. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +25 -13
  239. package/src/resources/extensions/gsd/doctor-types.ts +1 -0
  240. package/src/resources/extensions/gsd/doctor.ts +2 -27
  241. package/src/resources/extensions/gsd/export-html.ts +27 -427
  242. package/src/resources/extensions/gsd/forensics.ts +3 -3
  243. package/src/resources/extensions/gsd/git-service.ts +51 -4
  244. package/src/resources/extensions/gsd/gsd-db.ts +21 -6
  245. package/src/resources/extensions/gsd/guided-flow-queue.ts +4 -3
  246. package/src/resources/extensions/gsd/guided-flow.ts +134 -133
  247. package/src/resources/extensions/gsd/guided-unit-context.ts +30 -0
  248. package/src/resources/extensions/gsd/migrate/parsers.ts +11 -0
  249. package/src/resources/extensions/gsd/migration-auto-check.ts +15 -23
  250. package/src/resources/extensions/gsd/milestone-actions.ts +10 -4
  251. package/src/resources/extensions/gsd/native-git-bridge.ts +54 -12
  252. package/src/resources/extensions/gsd/pending-auto-start.ts +79 -0
  253. package/src/resources/extensions/gsd/post-execution-checks.ts +87 -2
  254. package/src/resources/extensions/gsd/pre-execution-checks.ts +32 -1
  255. package/src/resources/extensions/gsd/prompt-loader.ts +1 -1
  256. package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  257. package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  258. package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
  259. package/src/resources/extensions/gsd/prompts/discuss.md +9 -9
  260. package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
  261. package/src/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
  262. package/src/resources/extensions/gsd/prompts/plan-slice.md +4 -4
  263. package/src/resources/extensions/gsd/prompts/queue.md +4 -4
  264. package/src/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  265. package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  266. package/src/resources/extensions/gsd/queue-reorder-ui.ts +31 -13
  267. package/src/resources/extensions/gsd/smart-entry-routing.ts +77 -0
  268. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +8 -1
  269. package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +12 -15
  270. package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +17 -25
  271. package/src/resources/extensions/gsd/state.ts +1 -1
  272. package/src/resources/extensions/gsd/status-guards.ts +13 -0
  273. package/src/resources/extensions/gsd/templates/plan.md +8 -5
  274. package/src/resources/extensions/gsd/templates/task-plan.md +4 -2
  275. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +71 -0
  276. package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +116 -0
  277. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +56 -0
  278. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +80 -1
  279. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +35 -7
  280. package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +53 -2
  281. package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +12 -1
  282. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +91 -6
  283. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +1 -0
  284. package/src/resources/extensions/gsd/tests/auto-stop-notification.test.ts +20 -0
  285. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +69 -1
  286. package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +87 -0
  287. package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +11 -2
  288. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +4 -1
  289. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +5 -9
  290. package/src/resources/extensions/gsd/tests/complete-task.test.ts +3 -1
  291. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +86 -2
  292. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
  293. package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +208 -0
  294. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +59 -2
  295. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +66 -0
  296. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +27 -0
  297. package/src/resources/extensions/gsd/tests/doctor-empty-worktree.test.ts +65 -0
  298. package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +8 -0
  299. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +11 -0
  300. package/src/resources/extensions/gsd/tests/guided-discuss-project-prompt-rendering.test.ts +2 -0
  301. package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +106 -0
  302. package/src/resources/extensions/gsd/tests/guided-flow-session-isolation.test.ts +59 -11
  303. package/src/resources/extensions/gsd/tests/guided-flow.test.ts +21 -0
  304. package/src/resources/extensions/gsd/tests/guided-tool-contract.test.ts +65 -0
  305. package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +7 -7
  306. package/src/resources/extensions/gsd/tests/hook-model-resolution.test.ts +5 -0
  307. package/src/resources/extensions/gsd/tests/infra-error.test.ts +2 -2
  308. package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +9 -0
  309. package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +20 -0
  310. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +112 -1
  311. package/src/resources/extensions/gsd/tests/integration/state-machine-runtime-failures.test.ts +6 -1
  312. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +46 -0
  313. package/src/resources/extensions/gsd/tests/merge-db-cycle.test.ts +179 -0
  314. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +24 -1
  315. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +26 -18
  316. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +63 -2
  317. package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +121 -1
  318. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +55 -1
  319. package/src/resources/extensions/gsd/tests/pending-autostart-scope.test.ts +29 -5
  320. package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +2 -1
  321. package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +26 -0
  322. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +2 -0
  323. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +225 -1
  324. package/src/resources/extensions/gsd/tests/plan-task.test.ts +17 -0
  325. package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +86 -0
  326. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +1 -1
  327. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +53 -0
  328. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +59 -0
  329. package/src/resources/extensions/gsd/tests/prompt-loader.test.ts +23 -0
  330. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +37 -1
  331. package/src/resources/extensions/gsd/tests/queue-reorder-ui.test.ts +54 -0
  332. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +89 -2
  333. package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +2 -3
  334. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +10 -0
  335. package/src/resources/extensions/gsd/tests/smart-entry-routing.test.ts +113 -0
  336. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +53 -2
  337. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +119 -23
  338. package/src/resources/extensions/gsd/tests/status-guards.test.ts +13 -1
  339. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +64 -1
  340. package/src/resources/extensions/gsd/tests/summary-render-parity.test.ts +7 -3
  341. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +82 -7
  342. package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +29 -2
  343. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +110 -1
  344. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +19 -1
  345. package/src/resources/extensions/gsd/tests/workflow-memory-pressure.test.ts +21 -1
  346. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +1 -1
  347. package/src/resources/extensions/gsd/tests/worktree-git-pathspec.test.ts +39 -0
  348. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +64 -12
  349. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +38 -0
  350. package/src/resources/extensions/gsd/tools/complete-milestone.ts +8 -10
  351. package/src/resources/extensions/gsd/tools/complete-slice.ts +6 -8
  352. package/src/resources/extensions/gsd/tools/plan-milestone.ts +5 -1
  353. package/src/resources/extensions/gsd/tools/plan-slice.ts +98 -12
  354. package/src/resources/extensions/gsd/types.ts +1 -1
  355. package/src/resources/extensions/gsd/unit-context-manifest.ts +12 -9
  356. package/src/resources/extensions/gsd/validation.ts +23 -1
  357. package/src/resources/extensions/gsd/verification-gate.ts +78 -6
  358. package/src/resources/extensions/gsd/workflow-mcp.ts +18 -1
  359. package/src/resources/extensions/gsd/workflow-projections.ts +6 -8
  360. package/src/resources/extensions/gsd/worktree-lifecycle.ts +41 -8
  361. package/src/resources/extensions/gsd/worktree-manager.ts +1 -1
  362. package/src/resources/extensions/shared/html-shell.ts +412 -0
  363. package/src/resources/extensions/visual-brief/page-contract.ts +2 -0
  364. package/src/resources/extensions/visual-brief/prompts.ts +37 -1
  365. package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +40 -0
  366. package/dist/web/standalone/.next/server/chunks/5822.js +0 -2
  367. package/dist/web/standalone/.next/static/chunks/app/layout-a16c7a7ecdf0c2cf.js +0 -1
  368. package/dist/web/standalone/.next/static/css/0262768ec1b89d34.css +0 -1
  369. package/dist/web/standalone/.next/static/css/de70bee13400563f.css +0 -1
  370. package/dist/web/standalone/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  371. package/dist/web/standalone/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  372. package/dist/web/standalone/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  373. package/dist/web/standalone/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  374. package/dist/web/standalone/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  375. package/dist/web/standalone/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  376. /package/dist/web/standalone/.next/static/{Qgr2B_MRhPxC0z8fwv4vT → O6femb9LLl3nlgsDaYwS-}/_buildManifest.js +0 -0
  377. /package/dist/web/standalone/.next/static/{Qgr2B_MRhPxC0z8fwv4vT → O6femb9LLl3nlgsDaYwS-}/_ssgManifest.js +0 -0
@@ -173,7 +173,18 @@ function gitPathspecForWorktreePath(basePath, targetPath) {
173
173
  let base = basePath;
174
174
  let target = targetPath;
175
175
  try {
176
- base = realpathSync.native(basePath);
176
+ base = execFileSync("git", ["rev-parse", "--show-toplevel"], {
177
+ cwd: basePath,
178
+ stdio: ["ignore", "pipe", "ignore"],
179
+ encoding: "utf-8",
180
+ }).trim() || basePath;
181
+ }
182
+ catch {
183
+ /* keep original */
184
+ void base;
185
+ }
186
+ try {
187
+ base = realpathSync.native(base);
177
188
  }
178
189
  catch {
179
190
  /* keep original */
@@ -191,6 +202,9 @@ function gitPathspecForWorktreePath(basePath, targetPath) {
191
202
  return null;
192
203
  return rel.replaceAll("\\", "/");
193
204
  }
205
+ export function _gitPathspecForWorktreePath(basePath, targetPath) {
206
+ return gitPathspecForWorktreePath(basePath, targetPath);
207
+ }
194
208
  function gitRemoteExists(basePath, remote) {
195
209
  try {
196
210
  execFileSync("git", ["remote", "get-url", remote], {
@@ -204,6 +218,52 @@ function gitRemoteExists(basePath, remote) {
204
218
  return false;
205
219
  }
206
220
  }
221
+ function findRegularMergeChangedPaths(basePath, milestoneBranch, mainBranch) {
222
+ const changedPaths = new Set();
223
+ let mergeLog = "";
224
+ try {
225
+ mergeLog = execFileSync("git", ["rev-list", "--merges", "--parents", mainBranch], {
226
+ cwd: basePath,
227
+ stdio: ["ignore", "pipe", "pipe"],
228
+ encoding: "utf-8",
229
+ }).trim();
230
+ }
231
+ catch (err) {
232
+ logWarning("worktree", `regular merge lookup failed: ${err instanceof Error ? err.message : String(err)}`);
233
+ return changedPaths;
234
+ }
235
+ for (const line of mergeLog.split("\n").filter(Boolean)) {
236
+ const [mergeCommit, firstParent, ...otherParents] = line.split(" ");
237
+ if (!mergeCommit || !firstParent || otherParents.length === 0)
238
+ continue;
239
+ const mergedMilestone = otherParents.some((parent) => {
240
+ try {
241
+ return nativeIsAncestor(basePath, milestoneBranch, parent);
242
+ }
243
+ catch {
244
+ return false;
245
+ }
246
+ });
247
+ if (!mergedMilestone)
248
+ continue;
249
+ try {
250
+ const output = execFileSync("git", ["diff", "--name-only", firstParent, mergeCommit], {
251
+ cwd: basePath,
252
+ stdio: ["ignore", "pipe", "pipe"],
253
+ encoding: "utf-8",
254
+ }).trim();
255
+ for (const path of output.split("\n").filter(Boolean)) {
256
+ if (!path.startsWith(".gsd/"))
257
+ changedPaths.add(path);
258
+ }
259
+ }
260
+ catch (err) {
261
+ logWarning("worktree", `regular merge diff lookup failed: ${err instanceof Error ? err.message : String(err)}`);
262
+ }
263
+ return changedPaths;
264
+ }
265
+ return changedPaths;
266
+ }
207
267
  function clearProjectRootStateFiles(basePath, milestoneId) {
208
268
  const gsdDir = gsdRoot(basePath);
209
269
  // Phase C pt 2: auto.lock removed from this list — the file is gone
@@ -810,7 +870,63 @@ export function enterBranchModeForMilestone(basePath, milestoneId) {
810
870
  reused: true,
811
871
  });
812
872
  }
813
- nativeCheckoutBranch(basePath, branch);
873
+ checkoutBranchWithStashGuard(basePath, branch, `enter-branch-mode:${milestoneId}`);
874
+ }
875
+ export function checkoutBranchWithStashGuard(basePath, branch, reason) {
876
+ let stashMarker = null;
877
+ let stashed = false;
878
+ const status = nativeWorkingTreeStatus(basePath).trim();
879
+ if (status.length > 0) {
880
+ stashMarker = `gsd-checkout-stash:${reason}:${process.pid}:${Date.now()}:${process.hrtime.bigint().toString(36)}`;
881
+ const stashListBefore = execFileSync("git", ["stash", "list"], {
882
+ cwd: basePath,
883
+ stdio: ["ignore", "pipe", "pipe"],
884
+ encoding: "utf-8",
885
+ });
886
+ execFileSync("git", ["stash", "push", "--include-untracked", "-m", `gsd: checkout stash [${stashMarker}]`], {
887
+ cwd: basePath,
888
+ stdio: ["ignore", "pipe", "pipe"],
889
+ encoding: "utf-8",
890
+ });
891
+ const stashListAfter = execFileSync("git", ["stash", "list"], {
892
+ cwd: basePath,
893
+ stdio: ["ignore", "pipe", "pipe"],
894
+ encoding: "utf-8",
895
+ });
896
+ stashed = stashListAfter !== stashListBefore;
897
+ }
898
+ // Checkout and stash-restore are split so we can distinguish two failure
899
+ // modes: (a) checkout failed → HEAD did not move, restore stash and rethrow;
900
+ // (b) checkout succeeded but stash pop failed → HEAD moved to `branch` but
901
+ // the working-tree changes remain in the stash list. We surface a distinct
902
+ // error in case (b) so callers don't assume the branch switch was rolled back.
903
+ try {
904
+ nativeCheckoutBranch(basePath, branch);
905
+ }
906
+ catch (checkoutErr) {
907
+ if (stashed) {
908
+ try {
909
+ popStashByRef(basePath, stashMarker);
910
+ }
911
+ catch (restoreErr) {
912
+ logWarning("worktree", `git stash pop failed during checkout restore: ${restoreErr instanceof Error ? restoreErr.message : String(restoreErr)}`);
913
+ }
914
+ }
915
+ throw checkoutErr;
916
+ }
917
+ if (stashed) {
918
+ try {
919
+ popStashByRef(basePath, stashMarker);
920
+ }
921
+ catch (popErr) {
922
+ const msg = popErr instanceof Error ? popErr.message : String(popErr);
923
+ const wrapped = new Error(`checkout to '${branch}' succeeded but stash restore failed; working tree changes remain in the stash list. Original error: ${msg}`);
924
+ const ref = popErr?.stashRef;
925
+ if (ref)
926
+ wrapped.stashRef = ref;
927
+ throw wrapped;
928
+ }
929
+ }
814
930
  }
815
931
  // ─── Public API ────────────────────────────────────────────────────────────
816
932
  /**
@@ -1482,6 +1598,56 @@ export function mergeMilestoneToMain(originalBasePath_, milestoneId, roadmapCont
1482
1598
  });
1483
1599
  }
1484
1600
  }
1601
+ // Already regular-merged milestones can skip the squash path and proceed to cleanup (#5831).
1602
+ if (nativeIsAncestor(originalBasePath_, milestoneBranch, mainBranch)) {
1603
+ const codeChanges = nativeDiffNumstat(originalBasePath_, mainBranch, milestoneBranch).filter((entry) => !entry.path.startsWith(".gsd/"));
1604
+ if (codeChanges.length > 0) {
1605
+ const regularMergeChangedPaths = findRegularMergeChangedPaths(originalBasePath_, milestoneBranch, mainBranch);
1606
+ const unanchoredCodeChanges = codeChanges.filter((entry) => regularMergeChangedPaths.has(entry.path));
1607
+ if (unanchoredCodeChanges.length > 0) {
1608
+ process.chdir(previousCwd);
1609
+ throw new GSDError(GSD_GIT_ERROR, `Milestone branch "${milestoneBranch}" is reachable from "${mainBranch}" ` +
1610
+ `but has ${unanchoredCodeChanges.length} milestone-touched code file(s) not on current "${mainBranch}". ` +
1611
+ `Aborting worktree teardown to prevent data loss.`);
1612
+ }
1613
+ }
1614
+ debugLog("mergeMilestoneToMain", {
1615
+ action: "skip-squash-already-merged",
1616
+ milestoneId,
1617
+ milestoneBranch,
1618
+ mainBranch,
1619
+ });
1620
+ try {
1621
+ clearProjectRootStateFiles(originalBasePath_, milestoneId);
1622
+ }
1623
+ catch (err) {
1624
+ logWarning("worktree", `clearProjectRootStateFiles failed during already-merged cleanup: ${err instanceof Error ? err.message : String(err)}`);
1625
+ }
1626
+ try {
1627
+ removeWorktree(originalBasePath_, milestoneId, {
1628
+ branch: milestoneBranch,
1629
+ deleteBranch: false,
1630
+ });
1631
+ }
1632
+ catch (err) {
1633
+ logWarning("worktree", `worktree removal failed: ${err instanceof Error ? err.message : String(err)}`);
1634
+ }
1635
+ try {
1636
+ nativeBranchDelete(originalBasePath_, milestoneBranch);
1637
+ }
1638
+ catch (err) {
1639
+ logWarning("worktree", `git branch-delete failed: ${err instanceof Error ? err.message : String(err)}`);
1640
+ }
1641
+ setActiveWorkspace(null);
1642
+ nudgeGitBranchCache(previousCwd);
1643
+ try {
1644
+ process.chdir(originalBasePath_);
1645
+ }
1646
+ catch (err) {
1647
+ logWarning("worktree", `chdir to project root after already-merged cleanup failed: ${err instanceof Error ? err.message : String(err)}`);
1648
+ }
1649
+ return { commitMessage, pushed: false, prCreated: false, codeFilesChanged: true };
1650
+ }
1485
1651
  // 7. Shelter queued milestone directories before the squash merge (#2505).
1486
1652
  // The milestone branch may contain copies of queued milestone dirs (via
1487
1653
  // copyPlanningArtifacts), so `git merge --squash` rejects when those same
@@ -1617,14 +1783,6 @@ export function mergeMilestoneToMain(originalBasePath_, milestoneId, roadmapCont
1617
1783
  // report the dirty tree if it fails.
1618
1784
  logWarning("worktree", `git stash failed: ${err instanceof Error ? err.message : String(err)}`);
1619
1785
  }
1620
- if (needsDbCycle && dbPathToReopen) {
1621
- try {
1622
- openDatabase(dbPathToReopen);
1623
- }
1624
- catch (err) {
1625
- logWarning("worktree", `post-stash db reopen failed: ${err instanceof Error ? err.message : String(err)}`);
1626
- }
1627
- }
1628
1786
  // 7b. Clean up stale merge state before attempting squash merge (#2912).
1629
1787
  // A leftover MERGE_HEAD (from a previous failed merge, libgit2 native path,
1630
1788
  // or interrupted operation) causes `git merge --squash` to refuse with
@@ -1633,6 +1791,14 @@ export function mergeMilestoneToMain(originalBasePath_, milestoneId, roadmapCont
1633
1791
  removeMergeStateFiles(originalBasePath_, "pre-merge");
1634
1792
  // 8. Squash merge — auto-resolve .gsd/ state file conflicts (#530)
1635
1793
  const mergeResult = nativeMergeSquash(originalBasePath_, milestoneBranch);
1794
+ if (needsDbCycle && dbPathToReopen) {
1795
+ try {
1796
+ openDatabase(dbPathToReopen);
1797
+ }
1798
+ catch (err) {
1799
+ logWarning("worktree", `post-merge db reopen failed: ${err instanceof Error ? err.message : String(err)}`);
1800
+ }
1801
+ }
1636
1802
  if (!mergeResult.success) {
1637
1803
  // Dirty working tree — the merge was rejected before it started (e.g.
1638
1804
  // untracked .gsd/ files left by syncStateToProjectRoot). Preserve the
@@ -22,7 +22,7 @@ import { gsdRoot, resolveMilestoneFile, resolveMilestonePath, resolveDir, milest
22
22
  import { invalidateAllCaches } from "./cache.js";
23
23
  import { clearActivityLogState } from "./activity-log.js";
24
24
  import { synthesizeCrashRecovery, getDeepDiagnostic, readActiveMilestoneId, } from "./session-forensics.js";
25
- import { writeLock, clearLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, emitOpenUnitEndForUnit, } from "./crash-recovery.js";
25
+ import { writeLock, clearLock, clearStaleWorkerLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, emitOpenUnitEndForUnit, } from "./crash-recovery.js";
26
26
  import { acquireSessionLock, getSessionLockStatus, releaseSessionLock, updateSessionLock, } from "./session-lock.js";
27
27
  import { resolveAutoSupervisorConfig, loadEffectiveGSDPreferences, getIsolationMode, } from "./preferences.js";
28
28
  import { sendDesktopNotification } from "./notifications.js";
@@ -127,6 +127,12 @@ import { normalizeRealPath } from "./paths.js";
127
127
  // ─────────────────────────────────────────────────────────────────────────────
128
128
  /** Throttle STATE.md rebuilds — at most once per 30 seconds */
129
129
  const STATE_REBUILD_MIN_INTERVAL_MS = 30_000;
130
+ export function formatAutoStopNotification(prefix, totals, unitCount) {
131
+ return [
132
+ `${prefix}.`,
133
+ `Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${unitCount} units`,
134
+ ].join("\n");
135
+ }
130
136
  /**
131
137
  * Phase B — register this auto-mode process in the workers table so other
132
138
  * workers and janitors can detect liveness via heartbeat. Best-effort: if
@@ -707,6 +713,7 @@ export async function cleanupAfterLoopExit(ctx) {
707
713
  // visible so the user still has a resumable auto-mode signal on screen.
708
714
  if (!s.paused) {
709
715
  ctx.ui.setStatus("gsd-auto", undefined);
716
+ ctx.ui.setWidget("gsd-progress", undefined);
710
717
  if (s.completionStopInProgress) {
711
718
  s.completionStopInProgress = false;
712
719
  }
@@ -1029,7 +1036,7 @@ export async function stopAuto(ctx, pi, reason, options = {}) {
1029
1036
  : `Auto-mode stopped${reasonSuffix}`;
1030
1037
  if (ledger && ledger.units.length > 0) {
1031
1038
  const totals = getProjectTotals(ledger.units);
1032
- ctx?.ui.notify(`${notificationPrefix}. Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${ledger.units.length} units`, "info");
1039
+ ctx?.ui.notify(formatAutoStopNotification(notificationPrefix, totals, ledger.units.length), "info");
1033
1040
  }
1034
1041
  else {
1035
1042
  ctx?.ui.notify(`${notificationPrefix}.`, "info");
@@ -1318,7 +1325,6 @@ export async function pauseAuto(ctx, _pi, _errorContext) {
1318
1325
  restoreProjectRootEnv();
1319
1326
  restoreMilestoneLockEnv();
1320
1327
  s.pendingVerificationRetry = null;
1321
- s.verificationRetryCount.clear();
1322
1328
  ctx?.ui.setStatus("gsd-auto", "paused");
1323
1329
  ctx?.ui.setWidget("gsd-progress", undefined);
1324
1330
  const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
@@ -1420,6 +1426,13 @@ export function createWiredDispatchAdapter(ctx, pi, dispatchBasePath) {
1420
1426
  sessionProvider,
1421
1427
  modelRegistry,
1422
1428
  });
1429
+ if (action.action === "stop") {
1430
+ return {
1431
+ kind: "blocked",
1432
+ reason: action.reason,
1433
+ action: action.level === "warning" ? "pause" : "stop",
1434
+ };
1435
+ }
1423
1436
  if (action.action !== "dispatch")
1424
1437
  return null;
1425
1438
  return {
@@ -1640,6 +1653,17 @@ export function createWiredAutoOrchestrationModule(ctx, pi, dispatchBasePath, ru
1640
1653
  };
1641
1654
  return createAutoOrchestrator(deps);
1642
1655
  }
1656
+ function notifyResumeBlocked(ctx, result) {
1657
+ const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
1658
+ ctx.ui.notify(`Auto-mode blocked: ${result.reason}. Fix and run ${resumeCmd} to resume.`, "warning");
1659
+ setLifecycleOutcome(ctx, {
1660
+ status: "blocked",
1661
+ title: "Auto-mode blocked",
1662
+ detail: result.reason,
1663
+ nextAction: `Fix the blocker, then run ${resumeCmd} to resume.`,
1664
+ commands: ["/gsd status for overview", `${resumeCmd} to resume`, "/gsd doctor to diagnose"],
1665
+ });
1666
+ }
1643
1667
  function ensureOrchestrationModule(ctx, pi, basePath) {
1644
1668
  s.orchestration = createWiredAutoOrchestrationModule(ctx, pi, basePath, lockBase());
1645
1669
  }
@@ -1924,7 +1948,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
1924
1948
  // This closes the journal gap reported in #3348 where the worker wrote side
1925
1949
  // effects (SUMMARY.md, DB updates) but died before emitting unit-end.
1926
1950
  emitCrashRecoveredUnitEnd(base, freshStartAssessment.lock);
1927
- clearLock(base);
1951
+ clearStaleWorkerLock(base);
1928
1952
  }
1929
1953
  if (!s.paused) {
1930
1954
  s.pendingCrashRecovery =
@@ -1987,6 +2011,8 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
1987
2011
  initMetrics(base);
1988
2012
  if (s.currentMilestoneId)
1989
2013
  setActiveMilestoneId(base, s.currentMilestoneId);
2014
+ await openProjectDbIfPresent(base);
2015
+ registerAutoWorkerForSession(s, base);
1990
2016
  // Re-register health level notification callback lost across process restart
1991
2017
  setLevelChangeCallback((_from, to, summary) => {
1992
2018
  const level = to === "red" ? "error" : to === "yellow" ? "warning" : "info";
@@ -2062,7 +2088,12 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
2062
2088
  }
2063
2089
  pi.events.emit(CMUX_CHANNELS.LOG, { preferences: loadEffectiveGSDPreferences(s.basePath || undefined)?.preferences, message: s.stepMode ? "Step-mode resumed." : "Auto-mode resumed.", level: "progress" });
2064
2090
  try {
2065
- await s.orchestration?.resume();
2091
+ const resumeResult = await s.orchestration?.resume();
2092
+ if (resumeResult?.kind === "blocked") {
2093
+ notifyResumeBlocked(ctx, resumeResult);
2094
+ await cleanupAfterLoopExit(ctx);
2095
+ return;
2096
+ }
2066
2097
  }
2067
2098
  catch (err) {
2068
2099
  debugLog("resume-orchestration-resume", { error: err instanceof Error ? err.message : String(err) });
@@ -2083,6 +2114,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
2083
2114
  const bootstrapDeps = {
2084
2115
  shouldUseWorktreeIsolation,
2085
2116
  registerSigtermHandler,
2117
+ registerAutoWorkerForSession: (projectRoot) => registerAutoWorkerForSession(s, projectRoot),
2086
2118
  lockBase,
2087
2119
  buildLifecycle,
2088
2120
  };
@@ -10,6 +10,7 @@ import { shouldIgnoreAgentEndForActiveUnit } from "../auto/unit-runner-events.js
10
10
  import { resolveModelId } from "../auto-model-selection.js";
11
11
  import { resolveProjectRoot } from "../worktree.js";
12
12
  import { clearDiscussionFlowState } from "./write-gate.js";
13
+ import { clearGuidedUnitContext } from "../guided-unit-context.js";
13
14
  import { resumeAutoAfterProviderDelay } from "./provider-error-resume.js";
14
15
  import { classifyError, createRetryState, resetRetryState, isTransient, } from "../error-classifier.js";
15
16
  import { blockModel, isModelBlocked } from "../blocked-models.js";
@@ -18,6 +19,9 @@ const MAX_NETWORK_RETRIES = 2;
18
19
  function isObjectRecord(value) {
19
20
  return !!value && typeof value === "object";
20
21
  }
22
+ export function _hasEmptyAgentEndContent(content) {
23
+ return content == null || (Array.isArray(content) && content.length === 0);
24
+ }
21
25
  /**
22
26
  * Cap on auto-resume attempts for sustained transient-provider errors.
23
27
  *
@@ -57,6 +61,11 @@ export function isUserInitiatedAbortMessage(message) {
57
61
  return false;
58
62
  return /\b(?:claude code process aborted by user|request aborted by user|process aborted by user)\b/i.test(message);
59
63
  }
64
+ export function shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg) {
65
+ if (!isTransient(cls) || cls.kind === "rate-limit")
66
+ return false;
67
+ return !/retry failed after \d+ attempts:/i.test(rawErrorMsg);
68
+ }
60
69
  function isBareClaudeCodeSessionSwitchAbortMarker(message) {
61
70
  if (!message)
62
71
  return false;
@@ -150,6 +159,13 @@ export function resolveAgentEndErrorDisplay(rawErrorMsg, content) {
150
159
  }
151
160
  return rawErrorMsg;
152
161
  }
162
+ export function isTerminalDeletedWorktreeProviderError(message) {
163
+ if (!message)
164
+ return false;
165
+ if (!/\bdoes not exist\b/i.test(message))
166
+ return false;
167
+ return /[/\\]\.gsd[/\\](?:projects[/\\][^/\\]+[/\\])?worktrees[/\\][^/\\\s"']+/i.test(message);
168
+ }
153
169
  async function pauseTransientWithBackoff(cls, pi, ctx, errorDetail, isRateLimit) {
154
170
  retryState.consecutiveTransientCount += 1;
155
171
  const baseRetryAfterMs = "retryAfterMs" in cls ? cls.retryAfterMs : 15_000;
@@ -187,8 +203,10 @@ export async function handleAgentEnd(pi, event, ctx) {
187
203
  // falsely report files as missing — producing a spurious "ready signal
188
204
  // rejected" loop even though the files are on disk.
189
205
  clearPathCache();
206
+ const basePath = resolveAgentEndBasePath();
207
+ clearGuidedUnitContext(basePath);
190
208
  try {
191
- if (await checkDeepProjectSetupAfterTurn(event, ctx, resolveAgentEndBasePath())) {
209
+ if (await checkDeepProjectSetupAfterTurn(event, ctx, basePath)) {
192
210
  return;
193
211
  }
194
212
  }
@@ -196,22 +214,22 @@ export async function handleAgentEnd(pi, event, ctx) {
196
214
  const message = err instanceof Error ? err.message : String(err);
197
215
  logWarning("bootstrap", `checkDeepProjectSetupAfterTurn failed: ${message}`);
198
216
  }
199
- if (checkAutoStartAfterDiscuss()) {
200
- clearDiscussionFlowState(resolveAgentEndBasePath() ?? process.cwd());
217
+ if (checkAutoStartAfterDiscuss(basePath)) {
218
+ clearDiscussionFlowState(basePath ?? process.cwd());
201
219
  return;
202
220
  }
203
221
  // #4573 — When the LLM emits "Milestone X ready." but the required files
204
222
  // are missing, `checkAutoStartAfterDiscuss` returns false silently. Surface
205
223
  // that and nudge the LLM to complete the writes before the user hits the
206
224
  // downstream "All milestones complete" warning loop.
207
- if (maybeHandleReadyPhraseWithoutFiles(event))
225
+ if (maybeHandleReadyPhraseWithoutFiles(event, basePath))
208
226
  return;
209
227
  // #4573 — Empty-turn recovery: if the LLM announced intent in prose but
210
228
  // emitted no tool calls, nudge it to execute. Fires only when auto-mode is
211
229
  // active or a discussion autostart is pending (non-auto interactive discuss
212
230
  // is user-driven). Runs before `isAutoActive` early return so pending
213
231
  // discussions (where isAutoActive may be false) still get recovered.
214
- if (maybeHandleEmptyIntentTurn(event, isAutoActive()))
232
+ if (maybeHandleEmptyIntentTurn(event, isAutoActive(), basePath))
215
233
  return;
216
234
  if (!isAutoActive())
217
235
  return;
@@ -246,7 +264,7 @@ export async function handleAgentEnd(pi, event, ctx) {
246
264
  // that carry error context — e.g. errorMessage field or non-empty content
247
265
  // indicating a mid-stream failure. (#2695)
248
266
  const content = "content" in lastMsg ? lastMsg.content : undefined;
249
- const hasEmptyContent = Array.isArray(content) && content.length === 0;
267
+ const hasEmptyContent = _hasEmptyAgentEndContent(content);
250
268
  const hasErrorMessage = "errorMessage" in lastMsg && !!lastMsg.errorMessage;
251
269
  if (hasEmptyContent && !hasErrorMessage) {
252
270
  // Non-fatal: treat as a normal agent end so the loop can continue
@@ -292,6 +310,12 @@ export async function handleAgentEnd(pi, event, ctx) {
292
310
  // the assistant message text content for display purposes only.
293
311
  // Classification still uses rawErrorMsg to avoid false positives from prose.
294
312
  const displayMsg = resolveAgentEndErrorDisplay(rawErrorMsg, "content" in lastMsg ? lastMsg.content : undefined);
313
+ if (isAutoCompletionStopInProgress() &&
314
+ isTerminalDeletedWorktreeProviderError(`${rawErrorMsg}\n${displayMsg}`)) {
315
+ resetRetryState(retryState);
316
+ logWarning("bootstrap", `Ignoring stale deleted-worktree provider error during terminal completion reroot: ${displayMsg || rawErrorMsg}`);
317
+ return;
318
+ }
295
319
  const errorDetail = displayMsg ? `: ${displayMsg}` : "";
296
320
  const explicitRetryAfterMs = ("retryAfterMs" in lastMsg && typeof lastMsg.retryAfterMs === "number") ? lastMsg.retryAfterMs : undefined;
297
321
  // ── 1. Classify using rawErrorMsg to avoid prose false-positives ────
@@ -375,7 +399,7 @@ export async function handleAgentEnd(pi, event, ctx) {
375
399
  // Core retries transient failures in-session after this handler.
376
400
  // Keep that behavior for non-rate-limit classes to avoid pause/retry races,
377
401
  // but let rate-limit continue into model fallback logic below (#4373).
378
- if (isTransient(cls) && cls.kind !== "rate-limit") {
402
+ if (shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg)) {
379
403
  return;
380
404
  }
381
405
  // Cap rate-limit backoff for CLI-style providers (openai-codex, google-gemini-cli)
@@ -468,17 +468,18 @@ export function registerDbTools(pi) {
468
468
  promptGuidelines: [
469
469
  "Use gsd_plan_milestone for milestone planning instead of writing ROADMAP.md directly.",
470
470
  "Keep parameters flat and provide the full milestone planning payload, including slices.",
471
+ "Milestone and slice titles must not contain forward slash (/), en dash, or em dash characters.",
471
472
  "The tool validates input, writes milestone and slice planning data transactionally, renders ROADMAP.md from DB, and clears both state and parse caches after success.",
472
473
  "Use the canonical name gsd_plan_milestone; gsd_milestone_plan is only an alias.",
473
474
  ],
474
475
  parameters: Type.Object({
475
476
  // ── Core identification + content (required) ──────────────────────
476
477
  milestoneId: Type.String({ description: "Milestone ID (e.g. M001)" }),
477
- title: Type.String({ description: "Milestone title" }),
478
+ title: Type.String({ description: "Milestone title; must not contain forward slash (/), en dash, or em dash characters" }),
478
479
  vision: Type.String({ description: "Milestone vision" }),
479
480
  slices: Type.Array(Type.Object({
480
481
  sliceId: Type.String({ description: "Slice ID (e.g. S01)" }),
481
- title: Type.String({ description: "Slice title" }),
482
+ title: Type.String({ description: "Slice title; must not contain forward slash (/), en dash, or em dash characters" }),
482
483
  risk: Type.String({ description: "Slice risk" }),
483
484
  depends: Type.Array(Type.String(), { description: "Slice dependency IDs" }),
484
485
  demo: Type.String({ description: "Roadmap demo text / After this" }),
@@ -546,10 +547,10 @@ export function registerDbTools(pi) {
546
547
  title: Type.String({ description: "Task title" }),
547
548
  description: Type.String({ description: "Task description / steps block" }),
548
549
  estimate: Type.String({ description: "Task estimate string" }),
549
- files: Type.Array(Type.String(), { description: "Files likely touched" }),
550
+ files: Type.Array(Type.String(), { description: "Array<string> of files likely touched; pass [\"path\"] or [], never a single string" }),
550
551
  verify: Type.String({ description: "Verification command or block" }),
551
- inputs: Type.Array(Type.String(), { description: "Input files or references" }),
552
- expectedOutput: Type.Array(Type.String(), { description: "Expected output files or artifacts" }),
552
+ inputs: Type.Array(Type.String(), { description: "Array<string> of input files or references; pass [\"path\"] or [], never a single string" }),
553
+ expectedOutput: Type.Array(Type.String(), { description: "Array<string> of expected output files or artifacts; pass [\"path\"] or [], never a single string" }),
553
554
  observabilityImpact: Type.Optional(Type.String({ description: "Task observability impact" })),
554
555
  }), { description: "Planned tasks for the slice" }),
555
556
  // ── Enrichment metadata (optional — defaults to empty) ────────────
@@ -622,10 +623,10 @@ export function registerDbTools(pi) {
622
623
  title: Type.String({ description: "Task title" }),
623
624
  description: Type.String({ description: "Task description / steps block" }),
624
625
  estimate: Type.String({ description: "Task estimate string" }),
625
- files: Type.Array(Type.String(), { description: "Files likely touched" }),
626
+ files: Type.Array(Type.String(), { description: "Array<string> of files likely touched; pass [\"path\"] or [], never a single string" }),
626
627
  verify: Type.String({ description: "Verification command or block" }),
627
- inputs: Type.Array(Type.String(), { description: "Input files or references" }),
628
- expectedOutput: Type.Array(Type.String(), { description: "Expected output files or artifacts" }),
628
+ inputs: Type.Array(Type.String(), { description: "Array<string> of input files or references; pass [\"path\"] or [], never a single string" }),
629
+ expectedOutput: Type.Array(Type.String(), { description: "Array<string> of expected output files or artifacts; pass [\"path\"] or [], never a single string" }),
629
630
  observabilityImpact: Type.Optional(Type.String({ description: "Task observability impact" })),
630
631
  // Single-writer v3 audit trail (Stream 2): caller-provided actor identity + causation.
631
632
  actorName: Type.Optional(Type.String({ description: "Caller-provided actor identity for the audit trail (e.g. 'executor-01', 'gsd-orchestrator')" })),
@@ -847,7 +848,7 @@ export function registerDbTools(pi) {
847
848
  name: "gsd_skip_slice",
848
849
  label: "Skip Slice",
849
850
  description: "Mark a slice as skipped so auto-mode advances past it without executing. " +
850
- "Non-closed tasks within the slice are cascaded to skipped so milestone completion is not blocked by leftover pending tasks (#4375). " +
851
+ "Non-closed tasks within the slice are cascaded to skipped so milestone completion is not blocked by leftover pending tasks. " +
851
852
  "The slice data is preserved for reference. The state machine treats skipped slices like completed ones for dependency satisfaction.",
852
853
  promptSnippet: "Skip a GSD slice (mark as skipped, auto-mode will advance past it)",
853
854
  promptGuidelines: [
@@ -24,6 +24,7 @@ import { resolveWorktreeProjectRoot } from "../worktree-root.js";
24
24
  import { extractSubagentAgentClasses } from "./subagent-input.js";
25
25
  import { approvalGateIdForUnit, isExplicitApprovalResponse, shouldPauseForUserApprovalQuestion } from "../user-input-boundary.js";
26
26
  import { resolveSkillManifest } from "../skill-manifest.js";
27
+ import { getGuidedUnitContext } from "../guided-unit-context.js";
27
28
  let approvalQuestionAbortInFlight = false;
28
29
  async function loadWelcomeScreenModule() {
29
30
  const candidates = [];
@@ -675,7 +676,8 @@ export function registerHooks(pi, ecosystemHandlers) {
675
676
  // subagent dispatch. Closes the b23 bug class where a discuss-milestone
676
677
  // turn used the host Edit tool to modify user source files.
677
678
  const dash = getAutoRuntimeSnapshot();
678
- const activeUnitType = dash.currentUnit?.type;
679
+ const guidedUnit = getGuidedUnitContext(discussionBasePath);
680
+ const activeUnitType = dash.currentUnit?.type ?? guidedUnit?.unitType;
679
681
  if (activeUnitType) {
680
682
  const manifest = resolveManifest(activeUnitType);
681
683
  if (manifest) {
@@ -694,7 +696,7 @@ export function registerHooks(pi, ecosystemHandlers) {
694
696
  // Subagent inputs use { agent }, { tasks: [{ agent }] }, or { chain: [{ agent }] }.
695
697
  agentClasses = extractSubagentAgentClasses(event.input);
696
698
  }
697
- const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || discussionBasePath, activeUnitType, manifest.tools, agentClasses);
699
+ const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || guidedUnit?.basePath || discussionBasePath, activeUnitType, manifest.tools, agentClasses);
698
700
  if (planningGuard.block)
699
701
  return planningGuard;
700
702
  }
@@ -4,8 +4,11 @@ export function extractSubagentAgentClasses(input) {
4
4
  const agentClasses = [];
5
5
  const visited = new WeakSet();
6
6
  const addAgentClass = (value) => {
7
- if (typeof value === "string" && value.trim().length > 0)
8
- agentClasses.push(value.trim());
7
+ if (typeof value !== "string")
8
+ return;
9
+ const normalized = value.trim().replace(/\.md$/i, "");
10
+ if (normalized.length > 0)
11
+ agentClasses.push(normalized);
9
12
  };
10
13
  const visitItems = (value) => {
11
14
  if (!Array.isArray(value))
@@ -59,6 +59,7 @@ const QUEUE_SAFE_TOOLS = new Set([
59
59
  * true / false — shell no-ops / test exit codes
60
60
  */
61
61
  const BASH_READ_ONLY_RE = /^\s*(cat|head|tail|less|more|wc|file|stat|du|df|which|type|echo|printf|ls|find|grep|rg|awk|sed\b(?!.*-i)|sort|uniq|diff|comm|tr|cut|tee\s+-a\s+\/dev\/null|git\s+(log|show|diff|status|branch|tag|remote|rev-parse|ls-files|blame|shortlog|describe|stash\s+list|config\s+--get|cat-file)|gh\s+(issue|pr|api|repo|release)\s+(view|list|diff|status|checks)|mkdir\s+-p\s+\.gsd|rtk\s|npm\s+run\s+(test|test:\w+|lint|lint:\w+|typecheck|type-check|type-check:\w+|check|verify|audit|outdated|format:check|ci|validate)\b|npm\s+(ls|list|info|view|show|outdated|audit|explain|doctor|ping|--version|-v)\b|npx\s|tsx\s|node\s+(--print|--version|-v\b)|python[23]?\s+(-c\s+'[^']*'|--version|-V\b|-m\s+(pip\s+show|pip\s+list|site))|pip[23]?\s+(show|list|freeze|check|index\s+versions)\b|jq\s|yq\s|curl\s+(-s\b|--silent\b)(?!\s+[^|>]*\s-[oO]\b)(?!\s+[^|>]*\s--output\b)[^|>]*$|openssl\s+(version|x509|s_client)|env\b|printenv\b|true\b|false\b)/;
62
+ const BASH_VERIFICATION_RE = /^\s*(npm\s+(run\s+(build|test|test:\w+|lint|lint:\w+|typecheck|type-check|verify|ci|validate)\b|test\b)|pnpm\s+(build|test|lint|typecheck|verify)\b|yarn\s+(build|test|lint|typecheck|verify)\b|vitest\b|jest\b|go\s+test\b)/;
62
63
  function createEmptyWriteGateState() {
63
64
  return {
64
65
  verifiedDepthMilestones: new Set(),
@@ -624,7 +625,7 @@ function matchesAllowedGlob(absPath, basePath, globs) {
624
625
  function blockReason(unitType, mode, what) {
625
626
  return [
626
627
  `HARD BLOCK: unit "${unitType}" runs under tools-policy "${mode}" — ${what}.`,
627
- `This is a mechanical gate enforced by manifest.tools (#4934). You MUST NOT proceed,`,
628
+ `This is a mechanical gate enforced by manifest.tools. You MUST NOT proceed,`,
628
629
  `retry the same call, or rationalize past this block. If you need to write user source,`,
629
630
  `the work belongs in execute-task, not in a planning unit.`,
630
631
  ].join(" ");
@@ -643,6 +644,9 @@ function blockReason(unitType, mode, what) {
643
644
  * and listed in the policy's allowedSubagents.
644
645
  * - "docs" → like "planning" but also allows writes to paths
645
646
  * matching `allowedPathGlobs` relative to basePath.
647
+ * - "verification"
648
+ * → allows Bash for project verification commands, but keeps
649
+ * writes restricted to .gsd/ and blocks subagent dispatch.
646
650
  *
647
651
  * `pathOrCommand` is the file path for write/edit-shaped tools and the
648
652
  * shell command for bash. Other tools ignore this argument.
@@ -674,7 +678,7 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
674
678
  // Unknown tool in read-only mode — block by default.
675
679
  return { block: true, reason: blockReason(unitType, policy.mode, `tool "${tool}" is not on the read-only allowlist`) };
676
680
  }
677
- // planning / planning-dispatch / docs modes share the same surface for safe tools, bash, and subagent.
681
+ // planning / planning-dispatch / docs / verification modes share the same surface for safe tools, bash, and subagent.
678
682
  if (PLANNING_SAFE_TOOLS.has(tool))
679
683
  return { block: false };
680
684
  if (tool.startsWith("gsd_"))
@@ -720,6 +724,14 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
720
724
  return { block: true, reason: blockReason(unitType, policy.mode, `subagent dispatch is not permitted in planning units`) };
721
725
  }
722
726
  if (tool === "bash") {
727
+ if (policy.mode === "verification") {
728
+ if (BASH_VERIFICATION_RE.test(pathOrCommand) || BASH_READ_ONLY_RE.test(pathOrCommand))
729
+ return { block: false };
730
+ return {
731
+ block: true,
732
+ reason: blockReason(unitType, policy.mode, `bash is restricted to build/test verification commands (npm run build, npm test, etc.); cannot run "${pathOrCommand.slice(0, 80)}${pathOrCommand.length > 80 ? "…" : ""}"`),
733
+ };
734
+ }
723
735
  if (BASH_READ_ONLY_RE.test(pathOrCommand))
724
736
  return { block: false };
725
737
  return {
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { computeProgressScore, formatProgressLine } from "../../progress-score.js";
2
3
  import { getGlobalGSDPreferencesPath, getProjectGSDPreferencesPath } from "../../preferences.js";
3
4
  import { ensurePreferencesFile, handlePrefs, handlePrefsMode, handlePrefsWizard, handleLanguage } from "../../commands-prefs-wizard.js";
@@ -197,7 +198,22 @@ export async function handleBrief(args, ctx, pi) {
197
198
  return;
198
199
  }
199
200
  const outputDir = getVisualBriefOutputDir();
200
- pi.sendUserMessage(buildVisualBriefPrompt(request, { outputDir }));
201
+ const version = resolveGsdVersion();
202
+ pi.sendUserMessage(buildVisualBriefPrompt(request, { outputDir, version }));
203
+ }
204
+ const briefRequire = createRequire(import.meta.url);
205
+ function resolveGsdVersion() {
206
+ const envVersion = process.env.GSD_VERSION?.trim();
207
+ if (envVersion)
208
+ return envVersion;
209
+ try {
210
+ const pkg = briefRequire("../../../../../../package.json");
211
+ const fromPkg = typeof pkg.version === "string" ? pkg.version.trim() : "";
212
+ return fromPkg || undefined;
213
+ }
214
+ catch {
215
+ return undefined;
216
+ }
201
217
  }
202
218
  export async function handleSetup(args, ctx, pi) {
203
219
  const { detectProjectState, hasGlobalSetup } = await import("../../detection.js");