gsd-pi 2.82.0-dev.c22380fc3 → 2.82.0-dev.dfbc5f58f

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 (287) 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 +11 -0
  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 +30 -3
  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 +6 -0
  37. package/dist/resources/extensions/gsd/migrate/parsers.js +10 -0
  38. package/dist/resources/extensions/gsd/milestone-actions.js +11 -4
  39. package/dist/resources/extensions/gsd/native-git-bridge.js +48 -12
  40. package/dist/resources/extensions/gsd/post-execution-checks.js +73 -2
  41. package/dist/resources/extensions/gsd/pre-execution-checks.js +28 -1
  42. package/dist/resources/extensions/gsd/prompt-loader.js +1 -1
  43. package/dist/resources/extensions/gsd/prompts/plan-slice.md +3 -3
  44. package/dist/resources/extensions/gsd/prompts/refine-slice.md +1 -1
  45. package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +6 -1
  46. package/dist/resources/extensions/gsd/status-guards.js +4 -0
  47. package/dist/resources/extensions/gsd/templates/plan.md +8 -5
  48. package/dist/resources/extensions/gsd/templates/task-plan.md +4 -2
  49. package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -8
  50. package/dist/resources/extensions/gsd/tools/complete-slice.js +6 -8
  51. package/dist/resources/extensions/gsd/tools/plan-milestone.js +7 -1
  52. package/dist/resources/extensions/gsd/tools/plan-slice.js +89 -14
  53. package/dist/resources/extensions/gsd/unit-context-manifest.js +32 -10
  54. package/dist/resources/extensions/gsd/validation.js +23 -1
  55. package/dist/resources/extensions/gsd/verification-gate.js +68 -7
  56. package/dist/resources/extensions/gsd/verification-verdict.js +26 -0
  57. package/dist/resources/extensions/gsd/workflow-projections.js +6 -8
  58. package/dist/resources/extensions/gsd/worktree-lifecycle.js +33 -8
  59. package/dist/resources/extensions/shared/html-shell.js +388 -0
  60. package/dist/resources/extensions/subagent/index.js +448 -78
  61. package/dist/resources/extensions/subagent/launch.js +77 -0
  62. package/dist/resources/extensions/subagent/run-store.js +148 -0
  63. package/dist/resources/extensions/visual-brief/artifact-policy.js +29 -0
  64. package/dist/resources/extensions/visual-brief/extension-manifest.json +8 -0
  65. package/dist/resources/extensions/visual-brief/index.js +5 -0
  66. package/dist/resources/extensions/visual-brief/page-contract.js +124 -0
  67. package/dist/resources/extensions/visual-brief/prompts.js +140 -0
  68. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  69. package/dist/web/standalone/.next/BUILD_ID +1 -1
  70. package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
  71. package/dist/web/standalone/.next/build-manifest.json +3 -3
  72. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  73. package/dist/web/standalone/.next/react-loadable-manifest.json +3 -3
  74. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  75. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  76. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  77. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  78. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  79. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  80. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  81. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  82. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  83. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  84. package/dist/web/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  85. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  86. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  87. package/dist/web/standalone/.next/server/app/_not-found.rsc +4 -7
  88. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -7
  89. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  90. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +4 -5
  91. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  93. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -5
  94. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  95. package/dist/web/standalone/.next/server/app/index.html +1 -1
  96. package/dist/web/standalone/.next/server/app/index.rsc +4 -7
  97. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  98. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -7
  99. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  100. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +4 -5
  101. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -5
  102. package/dist/web/standalone/.next/server/app/page.js +2 -2
  103. package/dist/web/standalone/.next/server/app/page.js.nft.json +1 -1
  104. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  105. package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
  106. package/dist/web/standalone/.next/server/chunks/4266.js +2 -0
  107. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  108. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  109. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  110. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  111. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  112. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  113. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  114. package/dist/web/standalone/.next/static/chunks/2973.33f26573894b6153.js +2 -0
  115. package/dist/web/standalone/.next/static/chunks/{8359.e059d86b255fce1c.js → 8359.7eb3bb8f8ecf4c01.js} +2 -2
  116. package/dist/web/standalone/.next/static/chunks/app/layout-8c10ec293ae0f1d5.js +1 -0
  117. package/dist/web/standalone/.next/static/chunks/{webpack-de742b64187e13fe.js → webpack-9a4db269f9ed63ad.js} +1 -1
  118. package/dist/web/standalone/.next/static/css/746ee28c929d1880.css +1 -0
  119. package/package.json +4 -4
  120. package/packages/mcp-server/src/workflow-tools.test.ts +1 -1
  121. package/packages/native/tsconfig.json +2 -1
  122. package/packages/native/tsconfig.tsbuildinfo +1 -1
  123. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  124. package/packages/pi-ai/dist/providers/openai-codex-responses.js +82 -1
  125. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  126. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts +2 -0
  127. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts.map +1 -0
  128. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +52 -0
  129. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -0
  130. package/packages/pi-ai/dist/providers/simple-options.d.ts +2 -4
  131. package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  132. package/packages/pi-ai/dist/providers/simple-options.js +5 -6
  133. package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
  134. package/packages/pi-ai/dist/providers/simple-options.test.d.ts +2 -0
  135. package/packages/pi-ai/dist/providers/simple-options.test.d.ts.map +1 -0
  136. package/packages/pi-ai/dist/providers/simple-options.test.js +50 -0
  137. package/packages/pi-ai/dist/providers/simple-options.test.js.map +1 -0
  138. package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +63 -0
  139. package/packages/pi-ai/src/providers/openai-codex-responses.ts +91 -1
  140. package/packages/pi-ai/src/providers/simple-options.test.ts +60 -0
  141. package/packages/pi-ai/src/providers/simple-options.ts +5 -6
  142. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  143. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts +2 -0
  144. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts.map +1 -0
  145. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js +66 -0
  146. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js.map +1 -0
  147. package/packages/pi-coding-agent/dist/core/agent-session.js +1 -1
  148. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  149. package/packages/pi-coding-agent/src/core/agent-session-thinking-level.test.ts +79 -0
  150. package/packages/pi-coding-agent/src/core/agent-session.ts +1 -1
  151. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  152. package/src/resources/GSD-WORKFLOW.md +10 -1
  153. package/src/resources/extensions/claude-code-cli/partial-builder.ts +2 -1
  154. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +19 -2
  155. package/src/resources/extensions/cmux/index.ts +6 -0
  156. package/src/resources/extensions/gsd/auto/contracts.ts +14 -6
  157. package/src/resources/extensions/gsd/auto/infra-errors.ts +9 -3
  158. package/src/resources/extensions/gsd/auto/loop.ts +8 -5
  159. package/src/resources/extensions/gsd/auto/orchestrator.ts +11 -0
  160. package/src/resources/extensions/gsd/auto/phases.ts +7 -1
  161. package/src/resources/extensions/gsd/auto/workflow-memory-pressure.ts +13 -0
  162. package/src/resources/extensions/gsd/auto-dispatch.ts +14 -6
  163. package/src/resources/extensions/gsd/auto-model-selection.ts +2 -1
  164. package/src/resources/extensions/gsd/auto-post-unit.ts +266 -139
  165. package/src/resources/extensions/gsd/auto-prompts.ts +2 -2
  166. package/src/resources/extensions/gsd/auto-recovery.ts +29 -0
  167. package/src/resources/extensions/gsd/auto-start.ts +92 -9
  168. package/src/resources/extensions/gsd/auto-verification.ts +36 -34
  169. package/src/resources/extensions/gsd/auto-worktree.ts +119 -1
  170. package/src/resources/extensions/gsd/auto.ts +32 -3
  171. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +6 -1
  172. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +9 -8
  173. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +19 -7
  174. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +19 -3
  175. package/src/resources/extensions/gsd/clean-root-preflight.ts +174 -8
  176. package/src/resources/extensions/gsd/commands/catalog.ts +4 -1
  177. package/src/resources/extensions/gsd/commands/handlers/core.ts +40 -0
  178. package/src/resources/extensions/gsd/commands-bootstrap.ts +10 -0
  179. package/src/resources/extensions/gsd/crash-recovery.ts +30 -4
  180. package/src/resources/extensions/gsd/db/unit-dispatches.ts +4 -3
  181. package/src/resources/extensions/gsd/dispatch-guard.ts +2 -2
  182. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +25 -13
  183. package/src/resources/extensions/gsd/doctor.ts +2 -27
  184. package/src/resources/extensions/gsd/export-html.ts +27 -427
  185. package/src/resources/extensions/gsd/git-service.ts +45 -1
  186. package/src/resources/extensions/gsd/gsd-db.ts +3 -0
  187. package/src/resources/extensions/gsd/guided-flow.ts +6 -0
  188. package/src/resources/extensions/gsd/migrate/parsers.ts +11 -0
  189. package/src/resources/extensions/gsd/milestone-actions.ts +10 -4
  190. package/src/resources/extensions/gsd/native-git-bridge.ts +54 -12
  191. package/src/resources/extensions/gsd/post-execution-checks.ts +87 -2
  192. package/src/resources/extensions/gsd/pre-execution-checks.ts +32 -1
  193. package/src/resources/extensions/gsd/prompt-loader.ts +1 -1
  194. package/src/resources/extensions/gsd/prompts/plan-slice.md +3 -3
  195. package/src/resources/extensions/gsd/prompts/refine-slice.md +1 -1
  196. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +8 -1
  197. package/src/resources/extensions/gsd/status-guards.ts +5 -0
  198. package/src/resources/extensions/gsd/templates/plan.md +8 -5
  199. package/src/resources/extensions/gsd/templates/task-plan.md +4 -2
  200. package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +116 -0
  201. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +54 -0
  202. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +80 -1
  203. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +6 -6
  204. package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +12 -1
  205. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +15 -1
  206. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +1 -0
  207. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +69 -1
  208. package/src/resources/extensions/gsd/tests/brief-command.test.ts +89 -0
  209. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +107 -2
  210. package/src/resources/extensions/gsd/tests/closeout-git-deferral.test.ts +16 -0
  211. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +4 -1
  212. package/src/resources/extensions/gsd/tests/complete-task.test.ts +3 -1
  213. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +43 -2
  214. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +59 -2
  215. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +39 -0
  216. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +27 -0
  217. package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +38 -0
  218. package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +8 -0
  219. package/src/resources/extensions/gsd/tests/guided-flow.test.ts +21 -0
  220. package/src/resources/extensions/gsd/tests/hook-model-resolution.test.ts +5 -0
  221. package/src/resources/extensions/gsd/tests/infra-error.test.ts +2 -2
  222. package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +9 -0
  223. package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +20 -0
  224. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +103 -1
  225. package/src/resources/extensions/gsd/tests/integration/state-machine-runtime-failures.test.ts +6 -1
  226. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +24 -1
  227. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +63 -2
  228. package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +121 -1
  229. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +55 -1
  230. package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +26 -0
  231. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +225 -1
  232. package/src/resources/extensions/gsd/tests/plan-task.test.ts +17 -0
  233. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
  234. package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +86 -0
  235. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +1 -1
  236. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +53 -0
  237. package/src/resources/extensions/gsd/tests/prompt-loader.test.ts +23 -0
  238. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +46 -2
  239. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +10 -0
  240. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +31 -1
  241. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +64 -1
  242. package/src/resources/extensions/gsd/tests/summary-render-parity.test.ts +7 -3
  243. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +86 -7
  244. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +110 -1
  245. package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +78 -0
  246. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +1 -1
  247. package/src/resources/extensions/gsd/tests/workflow-memory-pressure.test.ts +21 -1
  248. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +1 -1
  249. package/src/resources/extensions/gsd/tests/worktree-git-pathspec.test.ts +39 -0
  250. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +64 -12
  251. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +54 -0
  252. package/src/resources/extensions/gsd/tools/complete-milestone.ts +8 -10
  253. package/src/resources/extensions/gsd/tools/complete-slice.ts +6 -8
  254. package/src/resources/extensions/gsd/tools/plan-milestone.ts +5 -1
  255. package/src/resources/extensions/gsd/tools/plan-slice.ts +98 -12
  256. package/src/resources/extensions/gsd/types.ts +1 -1
  257. package/src/resources/extensions/gsd/unit-context-manifest.ts +47 -11
  258. package/src/resources/extensions/gsd/validation.ts +23 -1
  259. package/src/resources/extensions/gsd/verification-gate.ts +78 -6
  260. package/src/resources/extensions/gsd/verification-verdict.ts +47 -0
  261. package/src/resources/extensions/gsd/workflow-projections.ts +6 -8
  262. package/src/resources/extensions/gsd/worktree-lifecycle.ts +41 -8
  263. package/src/resources/extensions/shared/html-shell.ts +412 -0
  264. package/src/resources/extensions/subagent/index.ts +567 -103
  265. package/src/resources/extensions/subagent/launch.ts +131 -0
  266. package/src/resources/extensions/subagent/run-store.ts +218 -0
  267. package/src/resources/extensions/subagent/tests/launch.test.ts +115 -0
  268. package/src/resources/extensions/subagent/tests/run-store.test.ts +111 -0
  269. package/src/resources/extensions/visual-brief/artifact-policy.ts +41 -0
  270. package/src/resources/extensions/visual-brief/extension-manifest.json +8 -0
  271. package/src/resources/extensions/visual-brief/index.ts +8 -0
  272. package/src/resources/extensions/visual-brief/page-contract.ts +136 -0
  273. package/src/resources/extensions/visual-brief/prompts.ts +183 -0
  274. package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +212 -0
  275. package/dist/web/standalone/.next/server/chunks/5822.js +0 -2
  276. package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +0 -1
  277. package/dist/web/standalone/.next/static/chunks/app/layout-a16c7a7ecdf0c2cf.js +0 -1
  278. package/dist/web/standalone/.next/static/css/54ec2745c1da488b.css +0 -1
  279. package/dist/web/standalone/.next/static/css/de70bee13400563f.css +0 -1
  280. package/dist/web/standalone/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  281. package/dist/web/standalone/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  282. package/dist/web/standalone/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  283. package/dist/web/standalone/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  284. package/dist/web/standalone/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  285. package/dist/web/standalone/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  286. /package/dist/web/standalone/.next/static/{Wop3A7KRGyR06H3rla_1- → q0WYuDVbHeFFYbdd-fei2}/_buildManifest.js +0 -0
  287. /package/dist/web/standalone/.next/static/{Wop3A7KRGyR06H3rla_1- → q0WYuDVbHeFFYbdd-fei2}/_ssgManifest.js +0 -0
@@ -24,6 +24,7 @@ import { deleteMilestone, getMilestone, isDbAvailable, updateMilestoneStatus } f
24
24
  import { removeWorktree } from "./worktree-manager.js";
25
25
  import { logWarning } from "./workflow-logger.js";
26
26
  import { isAutoActive } from "./auto.js";
27
+ import { isClosedStatus } from "./status-guards.js";
27
28
 
28
29
  /**
29
30
  * Writer-side assert for mutations that race with auto-mode's squash merge (#4704).
@@ -44,7 +45,7 @@ function assertNotAutoActive(action: string): void {
44
45
  /**
45
46
  * Park a milestone — creates a PARKED.md marker file with reason and timestamp.
46
47
  * Parked milestones are skipped during active-milestone discovery but stay on disk.
47
- * Returns true if successfully parked, false if milestone not found or already parked.
48
+ * Returns true if successfully parked, false if milestone not found, already parked, or complete.
48
49
  */
49
50
  export function parkMilestone(basePath: string, milestoneId: string, reason: string): boolean {
50
51
  assertNotAutoActive("park milestone");
@@ -52,8 +53,13 @@ export function parkMilestone(basePath: string, milestoneId: string, reason: str
52
53
  if (!mDir || !existsSync(mDir)) return false;
53
54
 
54
55
  // Guard: do not park a completed milestone — it would corrupt depends_on satisfaction
55
- const summaryFile = resolveMilestoneFile(basePath, milestoneId, "SUMMARY");
56
- if (summaryFile) return false;
56
+ const dbAvailable = isDbAvailable();
57
+ const milestone = dbAvailable ? getMilestone(milestoneId) : null;
58
+ if (milestone && isClosedStatus(milestone.status)) return false;
59
+ if (!dbAvailable) {
60
+ const summaryFile = resolveMilestoneFile(basePath, milestoneId, "SUMMARY");
61
+ if (summaryFile) return false;
62
+ }
57
63
 
58
64
  const parkedPath = join(mDir, buildMilestoneFileName(milestoneId, "PARKED"));
59
65
  if (existsSync(parkedPath)) return false; // already parked
@@ -72,7 +78,7 @@ export function parkMilestone(basePath: string, milestoneId: string, reason: str
72
78
 
73
79
  writeFileSync(parkedPath, content, "utf-8");
74
80
  // Sync DB status so deriveStateFromDb also skips this milestone (#2694)
75
- if (isDbAvailable()) {
81
+ if (dbAvailable) {
76
82
  try {
77
83
  updateMilestoneStatus(milestoneId, "parked");
78
84
  } catch (err) {
@@ -6,6 +6,7 @@
6
6
  // execSync calls because git2 credential handling is too complex.
7
7
 
8
8
  import { execSync, execFileSync } from "node:child_process";
9
+ import type { ExecFileSyncOptionsWithStringEncoding } from "node:child_process";
9
10
  import { existsSync, readFileSync, unlinkSync, rmSync, writeFileSync } from "node:fs";
10
11
  import { join } from "node:path";
11
12
  import { GSDError, GSD_GIT_ERROR } from "./errors.js";
@@ -16,6 +17,8 @@ import { isInfrastructureError } from "./auto/infra-errors.js";
16
17
  // Issue #453: keep auto-mode bookkeeping on the stable git CLI path unless a
17
18
  // caller explicitly opts into the native helper.
18
19
  const NATIVE_GSD_GIT_ENABLED = process.env.GSD_ENABLE_NATIVE_GSD_GIT === "1";
20
+ const TRANSIENT_GIT_RETRY_CODES = new Set(["ENOBUFS", "EAGAIN"]);
21
+ const GIT_RETRY_DELAY_MS = 200;
19
22
 
20
23
  // ─── Native Module Types ──────────────────────────────────────────────────
21
24
 
@@ -144,9 +147,46 @@ function gitExec(basePath: string, args: string[], allowFailure = false): string
144
147
  encoding: "utf-8",
145
148
  env: GIT_NO_PROMPT_ENV,
146
149
  }).trim();
147
- } catch {
150
+ } catch (err) {
148
151
  if (allowFailure) return "";
149
- throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}`);
152
+ throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}: ${getErrorMessage(err)}`);
153
+ }
154
+ }
155
+
156
+ /** sleepSync uses Atomics.wait for a blocking pause without busy-waiting; it blocks the current thread and requires Atomics.wait support. */
157
+ function sleepSync(ms: number): void {
158
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
159
+ }
160
+
161
+ function isRetryableGitError(err: unknown): boolean {
162
+ const code = isInfrastructureError(err)
163
+ ?? isInfrastructureError((err as { stderr?: string })?.stderr ?? "");
164
+ return code !== null && TRANSIENT_GIT_RETRY_CODES.has(code);
165
+ }
166
+
167
+ function execGitFileSyncWithRetry(
168
+ basePath: string,
169
+ args: string[],
170
+ options: Partial<ExecFileSyncOptionsWithStringEncoding>,
171
+ ): string {
172
+ try {
173
+ return execFileSync("git", args, {
174
+ cwd: basePath,
175
+ stdio: ["ignore", "pipe", "pipe"],
176
+ encoding: "utf-8",
177
+ env: GIT_NO_PROMPT_ENV,
178
+ ...options,
179
+ }).trim();
180
+ } catch (err) {
181
+ if (!isRetryableGitError(err)) throw err;
182
+ sleepSync(GIT_RETRY_DELAY_MS);
183
+ return execFileSync("git", args, {
184
+ cwd: basePath,
185
+ stdio: ["ignore", "pipe", "pipe"],
186
+ encoding: "utf-8",
187
+ env: GIT_NO_PROMPT_ENV,
188
+ ...options,
189
+ }).trim();
150
190
  }
151
191
  }
152
192
 
@@ -159,9 +199,9 @@ function gitFileExec(basePath: string, args: string[], allowFailure = false): st
159
199
  encoding: "utf-8",
160
200
  env: GIT_NO_PROMPT_ENV,
161
201
  }).trim();
162
- } catch {
202
+ } catch (err) {
163
203
  if (allowFailure) return "";
164
- throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}`);
204
+ throw new GSDError(GSD_GIT_ERROR, `git ${args.join(" ")} failed in ${basePath}: ${getErrorMessage(err)}`);
165
205
  }
166
206
  }
167
207
 
@@ -428,16 +468,21 @@ export function nativeDiffNameStatus(
428
468
 
429
469
  /**
430
470
  * Get numstat diff between two refs.
471
+ * useMergeBase: if true, uses three-dot semantics.
431
472
  * Native: libgit2 patch line stats.
432
473
  * Fallback: `git diff --numstat`.
433
474
  */
434
- export function nativeDiffNumstat(basePath: string, fromRef: string, toRef: string): GitNumstat[] {
475
+ export function nativeDiffNumstat(basePath: string, fromRef: string, toRef: string, useMergeBase?: boolean): GitNumstat[] {
435
476
  const native = loadNative();
436
- if (native) {
477
+ if (native && !useMergeBase) {
437
478
  return native.gitDiffNumstat(basePath, fromRef, toRef);
438
479
  }
439
480
 
440
- const result = gitExec(basePath, ["diff", "--numstat", fromRef, toRef], true);
481
+ const refspec = useMergeBase ? `${fromRef}...${toRef}` : undefined;
482
+ const args = refspec
483
+ ? ["diff", "--numstat", refspec]
484
+ : ["diff", "--numstat", fromRef, toRef];
485
+ const result = gitExec(basePath, args, true);
441
486
  if (!result) return [];
442
487
 
443
488
  return result.split("\n").filter(Boolean).map(line => {
@@ -935,13 +980,10 @@ export function nativeCommit(
935
980
  try {
936
981
  const args = ["commit", "-F", "-"];
937
982
  if (options?.allowEmpty) args.push("--allow-empty");
938
- const result = execFileSync("git", args, {
939
- cwd: basePath,
983
+ const result = execGitFileSyncWithRetry(basePath, args, {
940
984
  stdio: ["pipe", "pipe", "pipe"],
941
- encoding: "utf-8",
942
- env: GIT_NO_PROMPT_ENV,
943
985
  input: message,
944
- }).trim();
986
+ });
945
987
  return result;
946
988
  } catch (err: unknown) {
947
989
  const errObj = err as { stdout?: string; stderr?: string; message?: string };
@@ -46,6 +46,46 @@ export interface PostExecutionResult {
46
46
 
47
47
  // ─── Import Resolution Check ─────────────────────────────────────────────────
48
48
 
49
+ /**
50
+ * Replace the contents of single- and double-quoted string literals on a single
51
+ * source line with spaces so import patterns do not match text inside strings.
52
+ * Template-literal spans are handled separately via the inTemplateLiteral flag.
53
+ */
54
+ function stripStringLiterals(line: string): string {
55
+ let result = "";
56
+ let i = 0;
57
+
58
+ while (i < line.length) {
59
+ const ch = line[i];
60
+
61
+ if (ch === '"' || ch === "'") {
62
+ result += ch;
63
+ i++;
64
+
65
+ while (i < line.length) {
66
+ const c = line[i];
67
+
68
+ if (c === "\\" && i + 1 < line.length) {
69
+ result += " ";
70
+ i += 2;
71
+ } else if (c === ch) {
72
+ result += ch;
73
+ i++;
74
+ break;
75
+ } else {
76
+ result += " ";
77
+ i++;
78
+ }
79
+ }
80
+ } else {
81
+ result += ch;
82
+ i++;
83
+ }
84
+ }
85
+
86
+ return result;
87
+ }
88
+
49
89
  /**
50
90
  * Extract relative import paths from TypeScript/JavaScript source code.
51
91
  * Returns array of { importPath, lineNum } for relative imports.
@@ -62,14 +102,23 @@ export function extractRelativeImports(
62
102
  // import './path'
63
103
  // require('./path')
64
104
  // require("../path")
65
- const importPattern = /(?:import\s+(?:.*?\s+from\s+)?|require\s*\(\s*)(['"])(\.\.?\/[^'"]+)\1/g;
105
+ const importPattern = /(?:^|[;{}]\s*)import\s+(?:.*?\s+from\s+)?(['"])(\.\.?\/[^'"]+)\1/g;
106
+ const requirePattern = /require\s*\(\s*(['"])(\.\.?\/[^'"]+)\1/g;
66
107
 
67
108
  // Track if we're inside a block comment
68
109
  let inBlockComment = false;
110
+ let inTemplateLiteral = false;
69
111
 
70
112
  for (let i = 0; i < lines.length; i++) {
71
113
  const line = lines[i];
72
114
 
115
+ if (inTemplateLiteral) {
116
+ if ((line.match(/(?<!\\)`/g) ?? []).length % 2 === 1) {
117
+ inTemplateLiteral = false;
118
+ }
119
+ continue;
120
+ }
121
+
73
122
  // Handle block comment boundaries
74
123
  if (inBlockComment) {
75
124
  if (line.includes("*/")) {
@@ -101,10 +150,22 @@ export function extractRelativeImports(
101
150
 
102
151
  // Reset lastIndex for each line
103
152
  importPattern.lastIndex = 0;
153
+ requirePattern.lastIndex = 0;
154
+
155
+ const strippedLine = stripStringLiterals(line);
104
156
 
105
157
  while ((match = importPattern.exec(line)) !== null) {
158
+ const importOffset = match[0].indexOf("import");
159
+ const importStart = match.index + importOffset;
160
+ if (
161
+ strippedLine.slice(importStart, importStart + "import".length) !==
162
+ "import"
163
+ ) {
164
+ continue;
165
+ }
166
+
106
167
  // Check if this match is after a // comment marker on the same line
107
- const beforeMatch = line.substring(0, match.index);
168
+ const beforeMatch = strippedLine.substring(0, match.index);
108
169
  if (beforeMatch.includes("//")) {
109
170
  continue;
110
171
  }
@@ -114,6 +175,30 @@ export function extractRelativeImports(
114
175
  lineNum: i + 1,
115
176
  });
116
177
  }
178
+
179
+ while ((match = requirePattern.exec(line)) !== null) {
180
+ if (
181
+ strippedLine.slice(match.index, match.index + "require".length) !==
182
+ "require"
183
+ ) {
184
+ continue;
185
+ }
186
+
187
+ // Check if this match is after a // comment marker on the same line
188
+ const beforeMatch = strippedLine.substring(0, match.index);
189
+ if (beforeMatch.includes("//")) {
190
+ continue;
191
+ }
192
+
193
+ imports.push({
194
+ importPath: match[2],
195
+ lineNum: i + 1,
196
+ });
197
+ }
198
+
199
+ if ((strippedLine.match(/(?<!\\)`/g) ?? []).length % 2 === 1) {
200
+ inTemplateLiteral = true;
201
+ }
117
202
  }
118
203
 
119
204
  return imports;
@@ -23,6 +23,7 @@ import { homedir } from "node:os";
23
23
  import { resolve } from "node:path";
24
24
  import type { TaskRow } from "./db-task-slice-rows.js";
25
25
  import type { PreExecutionCheckJSON } from "./verification-evidence.ts";
26
+ import { validateVerificationCommand } from "./verification-gate.js";
26
27
 
27
28
  const NPM_COMMAND = process.platform === "win32" ? "npm.cmd" : "npm";
28
29
 
@@ -37,6 +38,35 @@ export interface PreExecutionResult {
37
38
  durationMs: number;
38
39
  }
39
40
 
41
+ export function checkVerificationCommands(tasks: TaskRow[]): PreExecutionCheckJSON[] {
42
+ const results: PreExecutionCheckJSON[] = [];
43
+
44
+ for (const task of tasks) {
45
+ const verify = task.verify.trim();
46
+ if (!verify) continue;
47
+
48
+ const commands = verify
49
+ .split("&&")
50
+ .map((command) => command.trim())
51
+ .filter(Boolean);
52
+
53
+ for (const command of commands) {
54
+ const validation = validateVerificationCommand(command);
55
+ if (!validation.ok) {
56
+ results.push({
57
+ category: "tool",
58
+ target: `${task.id} Verify`,
59
+ passed: false,
60
+ message: `Unsafe or non-runnable Verify command: ${command} (${validation.reason})`,
61
+ blocking: true,
62
+ });
63
+ }
64
+ }
65
+ }
66
+
67
+ return results;
68
+ }
69
+
40
70
  // ─── Package Existence Check ─────────────────────────────────────────────────
41
71
 
42
72
  /**
@@ -757,8 +787,9 @@ export async function runPreExecutionChecks(
757
787
  const fileChecks = checkFilePathConsistency(tasks, basePath);
758
788
  const orderingChecks = checkTaskOrdering(tasks, basePath);
759
789
  const contractChecks = checkInterfaceContracts(tasks, basePath);
790
+ const verificationChecks = checkVerificationCommands(tasks);
760
791
 
761
- allChecks.push(...fileChecks, ...orderingChecks, ...contractChecks);
792
+ allChecks.push(...fileChecks, ...orderingChecks, ...contractChecks, ...verificationChecks);
762
793
 
763
794
  // Run async package checks
764
795
  const packageChecks = await checkPackageExistence(tasks, basePath);
@@ -200,7 +200,7 @@ export function loadPrompt(name: string, vars: Record<string, string> = {}): str
200
200
  if (missing.length > 0) {
201
201
  throw new GSDError(
202
202
  GSD_PARSE_ERROR,
203
- `loadPrompt("${name}"): template declares {{${missing.join("}}, {{")}}}} but no value was provided. ` +
203
+ `loadPrompt("${name}"): template declares {{${missing.join("}}, {{")}}} but no value was provided. ` +
204
204
  `This usually means the extension code in memory is older than the template on disk. ` +
205
205
  `Restart pi to reload the extension.`,
206
206
  );
@@ -26,7 +26,7 @@ Before planning, validate roadmap assumptions against code and dependency summar
26
26
 
27
27
  {{sourceFilePaths}}
28
28
 
29
- If slice research is inlined, trust it. Explore enough code to confirm paths, boundaries, and verification. Executors later get only task plans, slice excerpt, and prior summaries, so put required paths, steps, inputs, and outputs in task plans.
29
+ If slice research is inlined, trust its architectural findings, but verify every concrete file path you place in task `inputs` or `expectedOutput` against the current tree or prior/same-task outputs. Explore enough code to confirm paths, boundaries, and verification. Executors later get only task plans, slice excerpt, and prior summaries, so put required paths, steps, inputs, and outputs in task plans.
30
30
 
31
31
  {{executorContextConstraints}}
32
32
 
@@ -39,8 +39,8 @@ If slice research is inlined, trust it. Explore enough code to confirm paths, bo
39
39
  5. Define slice verification before tasks. Non-trivial slices need real tests or executable assertions; boundary contracts need contract-exercising checks. Tests must not read .gitignore/gitignored paths such as `.gsd/`, `.planning/`, or `.audits/`.
40
40
  6. Include Threat Surface (Q3), Requirement Impact (Q4), proof level, observability, integration closure, Failure Modes (Q5), Load Profile (Q6), and Negative Tests (Q7) only where applicable.
41
41
  7. Right-size tasks. Simple slices can be one task; split only when context, ownership, or verification boundaries justify it.
42
- 8. Each task needs a concrete title, Why / Files / Do / Verify / Done when, plus task-plan description, steps, must-haves, verification, inputs, and expected output. Inputs and Expected Output must include concrete backtick-wrapped paths. Use paths relative to `{{workingDirectory}}`; do not put absolute paths to the original checkout or any directory outside `{{workingDirectory}}` in `files`, `inputs`, `expectedOutput`, or verification commands. **`expected_output` must only list files the task actually creates or overwrites on disk.** Do NOT include files the task merely reads, verifies, or tests — those belong only in `inputs`. If a task is a pure verification or test task that produces no new files, its `expected_output` may be empty or limited to test-result artifacts (e.g. a log or assertion output). A file that does not yet exist on disk and is needed as an `input` must be produced by an earlier task's `expected_output` — if no prior task creates it, add a task before this one that does.
43
- 9. Persist with `gsd_plan_slice` using goal, successCriteria, optional proofLevel/integrationClosure/observabilityImpact, and tasks. `gsd_plan_slice` handles task persistence transactionally and renders `{{outputPath}}` plus task plans; do not call `gsd_plan_task`. The DB-backed tool is the canonical write path. Do **not** rely on direct `PLAN.md` writes as the source of truth.
42
+ 8. Each task needs the exact `gsd_plan_slice.tasks[]` shape: `taskId`, `title`, `description`, `estimate`, `files`, `verify`, `inputs`, `expectedOutput`, and optional `observabilityImpact`. `description` should contain the Why / Do / Done-when narrative. `files`, `inputs`, and `expectedOutput` must be JSON arrays of strings, even when there is only one path (for example, `"inputs": ["src/index.ts"]`, never `"inputs": "src/index.ts"`). Use paths relative to `{{workingDirectory}}`; do not put absolute paths to the original checkout or any directory outside `{{workingDirectory}}` in `files`, `inputs`, `expectedOutput`, or verification commands. **`expectedOutput` must only list files the task actually creates or overwrites on disk.** Do NOT include files the task merely reads, verifies, or tests — those belong only in `inputs`. If a task is a pure verification or test task that produces no new files, `expectedOutput` may be `[]` or limited to test-result artifacts (e.g. a log or assertion output). A file that does not yet exist on disk and is needed as an `input` must be produced by an earlier task's `expectedOutput` — if no prior task creates it, add a task before this one that does.
43
+ 9. Persist with `gsd_plan_slice` using `milestoneId`, `sliceId`, `goal`, optional `successCriteria`/`proofLevel`/`integrationClosure`/`observabilityImpact`, and `tasks`. `gsd_plan_slice` handles task persistence transactionally and renders `{{outputPath}}` plus task plans; do not call `gsd_plan_task`. The DB-backed tool is the canonical write path. Do **not** rely on direct `PLAN.md` writes as the source of truth.
44
44
  10. Self-audit before finishing: goal/demo closure, requirement coverage, locked decisions, concrete paths, dependency order, wiring, scope size, proof truthfulness, feature completeness, and quality gates. Quality gates: non-trivial slices/tasks include specific Q3-Q7 coverage where applicable.
45
45
  11. If planning creates structural decisions, append them to `.gsd/DECISIONS.md`.
46
46
  12. {{commitInstruction}}
@@ -64,7 +64,7 @@ Then:
64
64
  2. {{skillActivation}} Record the installed skills you expect executors to use in each task plan's `skills_used` frontmatter.
65
65
  3. Define slice-level verification: the objective stopping condition. Plan real test files with real assertions; for simple slices, executable commands are fine.
66
66
  4. For non-trivial slices, plan observability / proof level / integration closure, threat surface, and requirement impact. Omit entirely for simple slices.
67
- 5. Decompose the slice into tasks that fit one context window each. Every task must have Why / Files / Do / Verify / Done-when, plus a task plan with description, steps, must-haves, verification, inputs (backtick-wrapped paths), and expected output (backtick-wrapped paths).
67
+ 5. Decompose the slice into tasks that fit one context window each. Every task passed to `gsd_plan_slice` must use the exact keys `taskId`, `title`, `description`, `estimate`, `files`, `verify`, `inputs`, `expectedOutput`, and optional `observabilityImpact`. Put Why / Do / Done-when detail in `description`. `files`, `inputs`, and `expectedOutput` must be JSON arrays of strings, even for one path (for example, `"expectedOutput": ["src/index.ts"]`, never `"expectedOutput": "src/index.ts"`).
68
68
  6. **Persist planning state through `gsd_plan_slice`.** Call it with the full payload. The tool writes to the DB and renders `{{outputPath}}` and `{{slicePath}}/tasks/T##-PLAN.md` automatically. Do NOT rely on direct `PLAN.md` writes.
69
69
  7. **Self-audit the plan.** If every task were completed exactly as written, the slice goal/demo should be true. Every must-have maps to a task. Inputs and Expected Output are backtick-wrapped file paths.
70
70
  8. If refinement produced structural decisions that diverge from the sketch, append them to `.gsd/DECISIONS.md`.
@@ -23,6 +23,7 @@ import {
23
23
  } from "../../native-git-bridge.js";
24
24
  import type { GSDState } from "../../types.js";
25
25
  import { logError, logWarning } from "../../workflow-logger.js";
26
+ import { isGsdWorktreePath } from "../../worktree-root.js";
26
27
  import type { DriftContext, DriftHandler, DriftRecord } from "../types.js";
27
28
 
28
29
  export type MergeReconcileResult = "clean" | "reconciled" | "blocked";
@@ -46,7 +47,13 @@ function resolveGitDir(basePath: string): string {
46
47
  return isAbsolute(gitDir) ? gitDir : resolve(basePath, gitDir);
47
48
  }
48
49
  } catch (err) {
49
- logWarning("recovery", `gitdir resolution failed: ${getErrorMessage(err)}`);
50
+ const message = getErrorMessage(err);
51
+ logWarning("recovery", `gitdir resolution failed: ${message}`);
52
+ if (isGsdWorktreePath(basePath)) {
53
+ throw new Error(
54
+ `Worktree integrity failure: ${basePath} is not a valid git worktree (git rev-parse failed: ${message.split("\n")[0]}). Repair or recreate the worktree before retrying.`,
55
+ );
56
+ }
50
57
  }
51
58
 
52
59
  return join(basePath, ".git");
@@ -25,3 +25,8 @@ export function isDeferredStatus(status: string): boolean {
25
25
  export function isInactiveStatus(status: string): boolean {
26
26
  return isClosedStatus(status) || isDeferredStatus(status);
27
27
  }
28
+
29
+ /** Returns true when a prior milestone should not block dispatch ordering. */
30
+ export function isSkippedForDispatch(status: string): boolean {
31
+ return isClosedStatus(status) || status === "parked" || isDeferredStatus(status);
32
+ }
@@ -99,11 +99,11 @@
99
99
  - "Improve UI"
100
100
 
101
101
  Each task should usually include:
102
- - Why: why this task exists / what part of the slice it closes
103
- - Files: the main files likely touched
104
- - Do: concrete implementation steps and important constraints
105
- - Verify: the command, test, or runtime check that proves it worked
106
- - Done when: a measurable acceptance condition
102
+ - description: why this task exists, concrete steps, and done-when acceptance
103
+ - files: JSON array of likely touched paths
104
+ - verify: the command, test, or runtime check that proves it worked
105
+ - inputs: JSON array of existing paths or prior task outputs this task consumes
106
+ - expectedOutput: JSON array of paths this task creates or overwrites
107
107
 
108
108
  Keep the checkbox line format exactly:
109
109
  - [ ] **T01: Title** `est:30m`
@@ -131,10 +131,13 @@
131
131
 
132
132
  Verify field rules:
133
133
  - MUST be a mechanically executable command: `npm test`, `grep -q "pattern" file`, `test -f path`
134
+ - MUST NOT use shell pipes, redirects, semicolons, backticks, command substitution, or output trimming
134
135
  - For content/document tasks: verify file existence, section count, YAML validity, or word count
135
136
  NOT exact phrasing, specific formulas, or "zero TBD" aspirational criteria
136
137
  - If no command can verify the output, write: "Manual review — file exists and is non-empty"
138
+ - BAD: `python3 -m pytest tests/ -q --tb=short 2>&1 | tail -5`
137
139
  - BAD: "Sections 3.1 and 3.2 exist with exact formulas. Zero TBD/TODO."
140
+ - GOOD: `python3 -m pytest tests/ -q --tb=short`
138
141
  - GOOD: `grep -c "^## " doc.md` returns >= 4 (4+ sections), `! grep -q "TBD\|TODO" doc.md`
139
142
 
140
143
  Integration closure rule:
@@ -72,7 +72,8 @@ skills_used:
72
72
  <!-- Every input MUST be a backtick-wrapped file path. These paths are machine-parsed to
73
73
  derive task dependencies — vague descriptions without paths break dependency detection.
74
74
  For the first task in a slice with no prior task outputs, list the existing source files
75
- this task reads or modifies. -->
75
+ this task reads or modifies.
76
+ Tool field: inputs must be an array of strings, e.g. ["src/index.ts"], never a single string. -->
76
77
 
77
78
  - `{{filePath}}` — {{whatThisTaskNeedsFromPriorWork}}
78
79
 
@@ -82,6 +83,7 @@ skills_used:
82
83
  or modifies. These paths are machine-parsed to derive task dependencies.
83
84
  This task should produce a real increment toward making the slice goal/demo true. A full
84
85
  slice plan should not be able to mark every task complete while the claimed slice behavior
85
- still does not work at the stated proof level. -->
86
+ still does not work at the stated proof level.
87
+ Tool field: expectedOutput must be an array of strings, e.g. ["src/index.ts"], never a single string. -->
86
88
 
87
89
  - `{{filePath}}` — {{whatThisTaskCreatesOrModifies}}
@@ -42,6 +42,20 @@ function makeTmpBase(): string {
42
42
  return base;
43
43
  }
44
44
 
45
+ function makeBrokenIsolatedWorktree(): string {
46
+ const root = mkdtempSync(join(tmpdir(), `gsd-test-5848-${randomUUID().slice(0, 8)}-`));
47
+ tmpDirs.push(root);
48
+ const base = join(root, ".gsd", "projects", "project-id", "worktrees", "M003");
49
+ mkdirSync(join(base, ".gsd", "milestones", "M003", "slices", "S03"), { recursive: true });
50
+ return base;
51
+ }
52
+
53
+ function makeBrokenIsolatedWorktreeRevParse(): string {
54
+ const base = makeBrokenIsolatedWorktree();
55
+ mkdirSync(join(base, ".git"));
56
+ return base;
57
+ }
58
+
45
59
  function resetAutoState(): void {
46
60
  _setAutoActiveForTest(false);
47
61
  }
@@ -231,6 +245,108 @@ describe("Test 5 — postUnitPreVerification short-circuits on deterministic err
231
245
  });
232
246
  });
233
247
 
248
+ describe("Test 5b — broken isolated worktree short-circuits artifact retry (#5848)", () => {
249
+ test("pauses with worktree integrity failure instead of setting pendingVerificationRetry", async () => {
250
+ const { postUnitPreVerification } = await import("../auto-post-unit.ts");
251
+
252
+ const base = makeBrokenIsolatedWorktree();
253
+ const s = new AutoSession();
254
+ s.active = true;
255
+ s.basePath = base;
256
+ s.currentUnit = { type: "research-slice", id: "M003/S03", startedAt: Date.now() };
257
+ s.verificationRetryCount.set("research-slice:M003/S03", 2);
258
+
259
+ const notifications: string[] = [];
260
+ let pauseCalled = false;
261
+ const pctx = {
262
+ s,
263
+ ctx: {
264
+ ui: {
265
+ notify: (message: string) => {
266
+ notifications.push(message);
267
+ },
268
+ },
269
+ },
270
+ pi: {},
271
+ buildSnapshotOpts: () => ({}) as any,
272
+ lockBase: () => base,
273
+ stopAuto: async () => {},
274
+ pauseAuto: async () => {
275
+ pauseCalled = true;
276
+ },
277
+ updateProgressWidget: () => {},
278
+ } as any;
279
+
280
+ const result = await postUnitPreVerification(pctx, {
281
+ skipSettleDelay: true,
282
+ skipWorktreeSync: true,
283
+ });
284
+
285
+ assert.strictEqual(result, "dispatched", "worktree integrity failure must pause instead of retrying");
286
+ assert.strictEqual(pauseCalled, true, "pauseAuto must be called for a broken isolated worktree");
287
+ assert.strictEqual(s.pendingVerificationRetry, null, "pendingVerificationRetry must NOT be set");
288
+ assert.strictEqual(s.verificationRetryCount.has("research-slice:M003/S03"), false, "stale retry count must be cleared");
289
+ assert.ok(
290
+ notifications.some((message) => message.includes("Worktree integrity failure") && message.includes(".git missing")),
291
+ `expected worktree integrity notification, got: ${notifications.join("\n")}`,
292
+ );
293
+ assert.ok(
294
+ notifications.every((message) => !message.includes("Artifact verification failed")),
295
+ `must not surface artifact retry messaging, got: ${notifications.join("\n")}`,
296
+ );
297
+ });
298
+
299
+ test("pauses when git rev-parse cannot validate an isolated worktree", async () => {
300
+ const { postUnitPreVerification } = await import("../auto-post-unit.ts");
301
+
302
+ const base = makeBrokenIsolatedWorktreeRevParse();
303
+ const s = new AutoSession();
304
+ s.active = true;
305
+ s.basePath = base;
306
+ s.currentUnit = { type: "research-slice", id: "M003/S03", startedAt: Date.now() };
307
+ s.verificationRetryCount.set("research-slice:M003/S03", 2);
308
+
309
+ const notifications: string[] = [];
310
+ let pauseCalled = false;
311
+ const pctx = {
312
+ s,
313
+ ctx: {
314
+ ui: {
315
+ notify: (message: string) => {
316
+ notifications.push(message);
317
+ },
318
+ },
319
+ },
320
+ pi: {},
321
+ buildSnapshotOpts: () => ({}) as any,
322
+ lockBase: () => base,
323
+ stopAuto: async () => {},
324
+ pauseAuto: async () => {
325
+ pauseCalled = true;
326
+ },
327
+ updateProgressWidget: () => {},
328
+ } as any;
329
+
330
+ const result = await postUnitPreVerification(pctx, {
331
+ skipSettleDelay: true,
332
+ skipWorktreeSync: true,
333
+ });
334
+
335
+ assert.strictEqual(result, "dispatched", "worktree integrity failure must pause instead of retrying");
336
+ assert.strictEqual(pauseCalled, true, "pauseAuto must be called for a broken isolated worktree");
337
+ assert.strictEqual(s.pendingVerificationRetry, null, "pendingVerificationRetry must NOT be set");
338
+ assert.strictEqual(s.verificationRetryCount.has("research-slice:M003/S03"), false, "stale retry count must be cleared");
339
+ assert.ok(
340
+ notifications.some((message) => message.includes("Worktree integrity failure") && message.includes("git rev-parse")),
341
+ `expected git rev-parse worktree integrity notification, got: ${notifications.join("\n")}`,
342
+ );
343
+ assert.ok(
344
+ notifications.every((message) => !message.includes("Artifact verification failed")),
345
+ `must not surface artifact retry messaging, got: ${notifications.join("\n")}`,
346
+ );
347
+ });
348
+ });
349
+
234
350
  // ─── Test 6: Model-quality failures use standard retry path ──────────────────
235
351
 
236
352
  describe("Test 6 — non-deterministic failures use standard retry; tier escalates once (#4973)", () => {
@@ -3353,6 +3353,60 @@ test("runDispatch runs stuck detection while artifact verification retry is pend
3353
3353
  );
3354
3354
  });
3355
3355
 
3356
+ test("runDispatch falls back to main when dispatch guard cannot read main branch (#5530)", async (t) => {
3357
+ _resetPendingResolve();
3358
+
3359
+ const ctx = makeMockCtx();
3360
+ const pi = makeMockPi();
3361
+ const basePath = mkdtempSync(join(tmpdir(), "gsd-5530-main-branch-fallback-"));
3362
+ t.after(() => rmSync(basePath, { recursive: true, force: true }));
3363
+
3364
+ let guardBranch: string | null = null;
3365
+ const s = makeLoopSession({ basePath });
3366
+ const deps = makeMockDeps({
3367
+ getMainBranch: () => {
3368
+ throw new Error("fatal: detected dubious ownership");
3369
+ },
3370
+ getPriorSliceCompletionBlocker: (_basePath, mainBranch) => {
3371
+ guardBranch = mainBranch;
3372
+ return null;
3373
+ },
3374
+ });
3375
+
3376
+ const result = await runDispatch(
3377
+ {
3378
+ ctx,
3379
+ pi,
3380
+ s,
3381
+ deps,
3382
+ prefs: undefined,
3383
+ iteration: 1,
3384
+ flowId: "test-flow",
3385
+ nextSeq: () => 1,
3386
+ },
3387
+ {
3388
+ state: {
3389
+ phase: "executing",
3390
+ activeMilestone: { id: "M001", title: "Test", status: "active" },
3391
+ activeSlice: { id: "S01", title: "Slice 1" },
3392
+ activeTask: { id: "T01" },
3393
+ registry: [{ id: "M001", status: "active" }],
3394
+ blockers: [],
3395
+ } as any,
3396
+ mid: "M001",
3397
+ midTitle: "Test",
3398
+ },
3399
+ {
3400
+ recentUnits: [],
3401
+ stuckRecoveryAttempts: 0,
3402
+ consecutiveFinalizeTimeouts: 0,
3403
+ },
3404
+ );
3405
+
3406
+ assert.equal(guardBranch, "main");
3407
+ assert.equal(result.action, "next");
3408
+ });
3409
+
3356
3410
  test("dispatch Worktree Safety stops unknown unit types with missing Tool Contract", async (t) => {
3357
3411
  _resetPendingResolve();
3358
3412