gsd-pi 2.80.0-dev.8b3a59f5c → 2.80.0-dev.b2a374d5b

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 (222) hide show
  1. package/dist/resources/.managed-resources-content-hash +1 -1
  2. package/dist/resources/GSD-WORKFLOW.md +2 -2
  3. package/dist/resources/extensions/gsd/auto/loop.js +32 -1
  4. package/dist/resources/extensions/gsd/auto/phases.js +37 -30
  5. package/dist/resources/extensions/gsd/auto-dispatch.js +10 -0
  6. package/dist/resources/extensions/gsd/auto-post-unit.js +10 -10
  7. package/dist/resources/extensions/gsd/auto-prompts.js +111 -1
  8. package/dist/resources/extensions/gsd/auto-start.js +2 -3
  9. package/dist/resources/extensions/gsd/auto.js +16 -3
  10. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +21 -0
  11. package/dist/resources/extensions/gsd/clean-root-preflight.js +42 -4
  12. package/dist/resources/extensions/gsd/commands/dispatcher.js +5 -0
  13. package/dist/resources/extensions/gsd/crash-recovery.js +56 -10
  14. package/dist/resources/extensions/gsd/detection.js +106 -0
  15. package/dist/resources/extensions/gsd/guided-flow.js +63 -12
  16. package/dist/resources/extensions/gsd/migrate/command.js +40 -1
  17. package/dist/resources/extensions/gsd/migration-auto-check.js +87 -0
  18. package/dist/resources/extensions/gsd/planning-path-scope.js +26 -0
  19. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +7 -8
  20. package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
  21. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
  22. package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  23. package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -5
  24. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
  25. package/dist/resources/extensions/gsd/quick.js +34 -2
  26. package/dist/resources/extensions/gsd/safety/evidence-collector.js +10 -2
  27. package/dist/resources/extensions/gsd/tools/plan-slice.js +9 -0
  28. package/dist/resources/extensions/gsd/tools/plan-task.js +9 -0
  29. package/dist/resources/extensions/gsd/unit-runtime.js +11 -0
  30. package/dist/resources/extensions/gsd/worktree-manager.js +16 -14
  31. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  32. package/dist/web/standalone/.next/BUILD_ID +1 -1
  33. package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
  34. package/dist/web/standalone/.next/build-manifest.json +2 -2
  35. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  36. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  37. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  39. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  40. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  41. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  42. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  43. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  44. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  45. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  46. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  47. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  48. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  49. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  50. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  51. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  52. package/dist/web/standalone/.next/server/app/index.html +1 -1
  53. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  54. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  55. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  56. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  57. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  58. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  59. package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
  60. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  61. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  62. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  63. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  64. package/package.json +4 -2
  65. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  66. package/packages/pi-coding-agent/dist/core/agent-session.js +3 -0
  67. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  68. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +32 -0
  69. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  70. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +11 -0
  71. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  72. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +9 -0
  73. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  74. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts +2 -0
  75. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts.map +1 -0
  76. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js +103 -0
  77. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js.map +1 -0
  78. package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts +15 -0
  79. package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts.map +1 -0
  80. package/packages/pi-coding-agent/dist/core/db-snapshot.js +66 -0
  81. package/packages/pi-coding-agent/dist/core/db-snapshot.js.map +1 -0
  82. package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts +2 -0
  83. package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts.map +1 -0
  84. package/packages/pi-coding-agent/dist/core/db-snapshot.test.js +24 -0
  85. package/packages/pi-coding-agent/dist/core/db-snapshot.test.js.map +1 -0
  86. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +3 -0
  87. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  88. package/packages/pi-coding-agent/dist/core/extensions/runner.js +17 -1
  89. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  90. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +99 -0
  91. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
  92. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +7 -0
  93. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  94. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  95. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +20 -0
  96. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  97. package/packages/pi-coding-agent/dist/core/settings-manager.js +25 -0
  98. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  99. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +6 -4
  100. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -1
  101. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +25 -20
  102. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  103. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +2 -2
  104. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -1
  105. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  106. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
  107. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
  108. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +2 -1
  109. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
  110. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +7 -6
  111. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
  112. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +1 -0
  113. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  114. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +26 -13
  115. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  116. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  117. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +15 -5
  118. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  119. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +53 -0
  120. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
  121. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  122. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3 -0
  123. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  124. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  125. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +36 -27
  126. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
  127. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +21 -0
  128. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -1
  129. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts +2 -0
  130. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts.map +1 -0
  131. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js +10 -0
  132. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js.map +1 -0
  133. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts.map +1 -1
  134. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js +3 -2
  135. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js.map +1 -1
  136. package/packages/pi-coding-agent/src/core/agent-session.ts +3 -0
  137. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +38 -0
  138. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +18 -0
  139. package/packages/pi-coding-agent/src/core/compaction-threshold.test.ts +121 -0
  140. package/packages/pi-coding-agent/src/core/db-snapshot.test.ts +32 -0
  141. package/packages/pi-coding-agent/src/core/db-snapshot.ts +66 -0
  142. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +110 -0
  143. package/packages/pi-coding-agent/src/core/extensions/runner.ts +19 -1
  144. package/packages/pi-coding-agent/src/core/extensions/types.ts +7 -0
  145. package/packages/pi-coding-agent/src/core/settings-manager.ts +39 -1
  146. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +7 -5
  147. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +25 -20
  148. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +2 -2
  149. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +1 -0
  150. package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +2 -1
  151. package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +10 -9
  152. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +33 -13
  153. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +56 -0
  154. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +24 -7
  155. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +3 -0
  156. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +36 -27
  157. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +25 -0
  158. package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +14 -0
  159. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +3 -2
  160. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  161. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  162. package/packages/pi-tui/dist/tui.js +17 -7
  163. package/packages/pi-tui/dist/tui.js.map +1 -1
  164. package/packages/pi-tui/src/tui.ts +19 -7
  165. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  166. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  167. package/pkg/dist/modes/interactive/theme/themes.js +36 -27
  168. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
  169. package/src/resources/GSD-WORKFLOW.md +2 -2
  170. package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -0
  171. package/src/resources/extensions/gsd/auto/loop.ts +50 -8
  172. package/src/resources/extensions/gsd/auto/phases.ts +42 -28
  173. package/src/resources/extensions/gsd/auto-dispatch.ts +17 -0
  174. package/src/resources/extensions/gsd/auto-post-unit.ts +10 -10
  175. package/src/resources/extensions/gsd/auto-prompts.ts +116 -1
  176. package/src/resources/extensions/gsd/auto-start.ts +7 -6
  177. package/src/resources/extensions/gsd/auto.ts +23 -3
  178. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +22 -0
  179. package/src/resources/extensions/gsd/clean-root-preflight.ts +41 -3
  180. package/src/resources/extensions/gsd/commands/dispatcher.ts +6 -0
  181. package/src/resources/extensions/gsd/crash-recovery.ts +67 -10
  182. package/src/resources/extensions/gsd/detection.ts +128 -0
  183. package/src/resources/extensions/gsd/guided-flow.ts +66 -12
  184. package/src/resources/extensions/gsd/migrate/command.ts +47 -1
  185. package/src/resources/extensions/gsd/migration-auto-check.ts +129 -0
  186. package/src/resources/extensions/gsd/planning-path-scope.ts +35 -0
  187. package/src/resources/extensions/gsd/prompts/complete-milestone.md +7 -8
  188. package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
  189. package/src/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
  190. package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  191. package/src/resources/extensions/gsd/prompts/quick-task.md +1 -5
  192. package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
  193. package/src/resources/extensions/gsd/quick.ts +37 -2
  194. package/src/resources/extensions/gsd/safety/evidence-collector.ts +11 -2
  195. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +1 -1
  196. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +88 -2
  197. package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +55 -0
  198. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +22 -0
  199. package/src/resources/extensions/gsd/tests/detection.test.ts +140 -0
  200. package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +33 -1
  201. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +48 -0
  202. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +127 -0
  203. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +50 -0
  204. package/src/resources/extensions/gsd/tests/plan-task.test.ts +21 -0
  205. package/src/resources/extensions/gsd/tests/prompt-path-audit.test.ts +40 -0
  206. package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
  207. package/src/resources/extensions/gsd/tests/right-sized-workflow-prompts.test.ts +192 -0
  208. package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +29 -0
  209. package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +38 -0
  210. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +63 -2
  211. package/src/resources/extensions/gsd/tests/status-db-open.test.ts +9 -0
  212. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +7 -0
  213. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
  214. package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +37 -6
  215. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +7 -0
  216. package/src/resources/extensions/gsd/tests/worktree-nested-git-safety.test.ts +9 -2
  217. package/src/resources/extensions/gsd/tools/plan-slice.ts +13 -0
  218. package/src/resources/extensions/gsd/tools/plan-task.ts +10 -0
  219. package/src/resources/extensions/gsd/unit-runtime.ts +14 -0
  220. package/src/resources/extensions/gsd/worktree-manager.ts +15 -4
  221. /package/dist/web/standalone/.next/static/{k-MDjzPMF62Rg1-FR437h → FU0iL9dhdc2IBzEYBDOlY}/_buildManifest.js +0 -0
  222. /package/dist/web/standalone/.next/static/{k-MDjzPMF62Rg1-FR437h → FU0iL9dhdc2IBzEYBDOlY}/_ssgManifest.js +0 -0
@@ -16,15 +16,14 @@ Start with what the excerpts give you. Read full files when the section heads si
16
16
 
17
17
  **On-demand Read ordering:** Complete all slice SUMMARY Reads you need for cross-slice synthesis, the Decision Re-evaluation table, and LEARNINGS **before** calling `gsd_complete_milestone` (step 12). Once that tool runs, the milestone is marked complete in the DB, so it must be the final persistent milestone-closeout write.
18
18
 
19
- ### Delegate Review Work
19
+ ### Closeout Review Mode
20
20
 
21
- Use `subagent` for review work needing fresh context, before drafting LEARNINGS:
21
+ The inlined context includes a validation status block.
22
22
 
23
- - Cross-slice integrations or new public APIs -> **reviewer** with milestone diff and roadmap.
24
- - Auth, network, parsing, file IO, shell exec, or crypto -> **security** audit.
25
- - Significant tests added or changed -> **tester** coverage check against success criteria.
23
+ - If it says a passing validation artifact is present, treat that artifact as authoritative for success criteria, requirement coverage, verification classes, and cross-slice integration. Do not delegate fresh reviewer/security/tester audits unless the validation artifact is internally inconsistent with the inlined summaries.
24
+ - If validation is missing, stale, non-pass, or internally inconsistent, use `subagent` for review work needing fresh context before drafting LEARNINGS: cross-slice integrations or new public APIs -> **reviewer**; auth, network, parsing, file IO, shell exec, or crypto -> **security**; significant tests added or changed -> **tester**.
26
25
 
27
- Subagents report only; they do not write user source. Fold findings into Decision Re-evaluation and LEARNINGS before completion.
26
+ Subagents report only; they do not write user source. Fold any findings into Decision Re-evaluation and LEARNINGS before completion.
28
27
 
29
28
  {{inlinedContext}}
30
29
 
@@ -33,8 +32,8 @@ Subagents report only; they do not write user source. Fold findings into Decisio
33
32
  1. Use the **Milestone Summary** output template from the inlined context above
34
33
  2. {{skillActivation}}
35
34
  3. **Verify code changes exist.** Compare milestone work against the integration branch (`main`, `master`, or recorded branch), using merge-base as older revision and `HEAD` as newer. If the diff lists non-`.gsd/` files, pass. If `HEAD` equals the integration branch/merge-base, treat it as a self-diff retry: inspect milestone-scoped commit evidence (`GSD-Unit: {{milestoneId}}` or production `GSD-Task: Sxx/Tyy` trailers touching `.gsd/milestones/{{milestoneId}}/`) and verify those commits touched non-`.gsd/` files. Record **verification failure** only when neither source shows implementation files.
36
- 4. Verify every **success criterion** from `{{roadmapPath}}` with evidence from summaries, tests, or observable behavior. Record unmet criteria as **verification failure**.
37
- 5. Verify **definition of done**: all slices `[x]`, summaries exist, and integrations work. Record unmet items as **verification failure**.
35
+ 4. Verify every **success criterion** from `{{roadmapPath}}`. If passing validation is present, summarize the validation evidence instead of re-auditing it; otherwise verify with evidence from summaries, tests, or observable behavior. Record unmet criteria as **verification failure**.
36
+ 5. Verify **definition of done**: all slices `[x]`, summaries exist, and integrations work. If passing validation is present, trust its integration/verification verdict unless inconsistent with current artifacts. Record unmet items as **verification failure**.
38
37
  6. If the roadmap includes a **Horizontal Checklist**, verify each item and note unchecked items in the summary.
39
38
  7. Fill the **Decision Re-evaluation** table: compare each key `.gsd/DECISIONS.md` decision from this milestone with what shipped, and flag decisions to revisit.
40
39
  8. Validate **requirement status transitions**. For each changed requirement, confirm evidence supports the new status. Requirements may move between Active, Validated, Deferred, Blocked, or Out of Scope only with proof.
@@ -16,7 +16,7 @@ Dispatch ALL slices simultaneously using the `subagent` tool in **parallel mode*
16
16
 
17
17
  1. Call `subagent` with `tasks: [...]` containing one entry per slice below
18
18
  2. Wait for ALL subagents to complete
19
- 3. Verify each slice's RESEARCH file was written (check the `.gsd/{{mid}}/` directory)
19
+ 3. Verify each slice's RESEARCH file was written (check `.gsd/milestones/{{mid}}/slices/<slice-id>/`)
20
20
  4. If a subagent failed to write its RESEARCH file, retry it **once** individually
21
21
  5. If it fails a second time, write a partial RESEARCH file for that slice with a `## BLOCKER` section explaining the failure — do NOT retry again
22
22
  6. Report which slices completed research and which (if any) needed a blocker note
@@ -48,7 +48,7 @@ Narrate decomposition reasoning in complete sentences: grouping, risk order, ver
48
48
  Then:
49
49
  1. Use the **Roadmap** output template from the inlined context above
50
50
  2. {{skillActivation}}
51
- 3. Create only as many demoable vertical slices as the work genuinely needs.
51
+ 3. Create only as many demoable vertical slices as the work genuinely needs. Use 1-10 slices, sized to the work; tiny/single-file/static work should usually be one slice.
52
52
  4. Order by risk, high-risk first.
53
53
  5. Call `gsd_plan_milestone` to persist milestone fields, slice rows, and **Horizontal Checklist** through the DB-backed path. Fill checklist concerns considered during planning: requirements, decisions, shutdown, revenue, auth, shared resources, reconnection. Omit for trivial milestones. Do **not** write `{{outputPath}}`, `ROADMAP.md`, or other planning artifacts manually; the tool owns rendering and persistence.
54
54
  6. If planning produced structural decisions (slice ordering, technology choices, scope exclusions), call `gsd_decision_save` for each; the tool assigns IDs and regenerates `.gsd/DECISIONS.md`.
@@ -78,6 +78,8 @@ Apply these when decomposing and ordering slices:
78
78
  - Ship features, not proofs; use clearly marked realistic stubs only when necessary.
79
79
  - **Dependency format is comma-separated, never range syntax.** Write `depends:[S01,S02,S03]`, not `depends:[S01-S03]`.
80
80
  - Roadmap ambition must match the milestone; right-size decomposition.
81
+ - Missing ecosystem markers are not a reason to over-plan. If Project Classification says `untyped-existing`, treat the listed content files as the project surface and use generic file-level workflow guidance.
82
+ - For `untyped-existing` projects with 1-2 content files, prefer exactly one slice unless the request clearly spans multiple independent user-visible capabilities. For 3-5 content files, prefer 1-2 slices.
81
83
 
82
84
  ## Progressive Planning (ADR-011)
83
85
 
@@ -39,7 +39,7 @@ 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; each task needs at least one output path.
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; each task needs at least one output path. 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.
43
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.
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`.
@@ -17,11 +17,7 @@ You are executing a GSD quick task — a lightweight, focused unit of work outsi
17
17
  5. Verify your work:
18
18
  - Run tests if applicable.
19
19
  - Verify both happy path and failure modes for non-trivial changes.
20
- 6. Commit your changes atomically:
21
- - Use conventional commit messages (feat:, fix:, refactor:, etc.)
22
- - Stage only relevant files — never commit secrets or runtime files.
23
- - Commit logical units separately if the task involves distinct changes.
24
- - Quick tasks run outside the auto-mode lifecycle — there is no system auto-commit, so commit directly here.
20
+ 6. {{commitInstruction}}
25
21
  7. Write a brief summary to `{{summaryPath}}`:
26
22
  - Quick tasks operate outside the milestone/slice/task DB structure, so `gsd_summary_save` (which requires a `milestone_id`) cannot be used here. Write the file directly.
27
23
 
@@ -27,13 +27,13 @@ Roadmap, slice summaries, assessments, requirements, decisions, and project cont
27
27
  Call `subagent` with `tasks: [...]` containing ALL THREE reviewers simultaneously:
28
28
 
29
29
  **Reviewer A - Requirements Coverage**
30
- Prompt: "Review milestone {{milestoneId}} requirements coverage. Working directory: {{workingDirectory}}. Read `.gsd/{{milestoneId}}/REQUIREMENTS.md` or equivalent. For each requirement, check slice SUMMARY files in `.gsd/{{milestoneId}}/` and mark COVERED, PARTIAL, or MISSING. Output table: Requirement | Status | Evidence. End with one-line verdict: PASS if all covered, NEEDS-ATTENTION if partials exist, FAIL if any missing."
30
+ Prompt: "Review milestone {{milestoneId}} requirements coverage. Working directory: {{workingDirectory}}. Read `.gsd/REQUIREMENTS.md` or use the inlined requirements context. For each requirement, check slice SUMMARY files under `.gsd/milestones/{{milestoneId}}/slices/` and mark COVERED, PARTIAL, or MISSING. Output table: Requirement | Status | Evidence. End with one-line verdict: PASS if all covered, NEEDS-ATTENTION if partials exist, FAIL if any missing."
31
31
 
32
32
  **Reviewer B - Cross-Slice Integration**
33
33
  Prompt: "Review milestone {{milestoneId}} cross-slice integration. Working directory: {{workingDirectory}}. Read `{{roadmapPath}}` and find the boundary map (produces/consumes contracts). For each boundary, confirm producer SUMMARY produced the artifact and consumer SUMMARY consumed it. Output table: Boundary | Producer Summary | Consumer Summary | Status. End with one-line verdict: PASS if all boundaries honored, NEEDS-ATTENTION if any gaps."
34
34
 
35
35
  **Reviewer C - Assessment & Acceptance Criteria**
36
- Prompt: "Review milestone {{milestoneId}} assessment evidence and acceptance criteria. Working directory: {{workingDirectory}}. Read `.gsd/{{milestoneId}}/CONTEXT.md` for criteria. Check slice ASSESSMENT files. Verify each criterion maps to a passing assessment or clear SUMMARY evidence. Then review inlined milestone verification classes. For each non-empty planned class, output table: Class | Planned Check | Evidence | Verdict. Use the exact class names `Contract`, `Integration`, `Operational`, and `UAT` whenever those classes are present. If no verification classes were planned, say that explicitly. Output sections `Acceptance Criteria` with checklist `[ ] Criterion | Evidence`, and `Verification Classes` with the table. End with one-line verdict: PASS if all criteria and classes are covered, NEEDS-ATTENTION if gaps exist."
36
+ Prompt: "Review milestone {{milestoneId}} assessment evidence and acceptance criteria. Working directory: {{workingDirectory}}. Read `.gsd/milestones/{{milestoneId}}/{{milestoneId}}-CONTEXT.md` for criteria. Check slice SUMMARY/UAT files under `.gsd/milestones/{{milestoneId}}/slices/`. Verify each criterion maps to passing evidence. Then review inlined milestone verification classes. For each non-empty planned class, output table: Class | Planned Check | Evidence | Verdict. Use the exact class names `Contract`, `Integration`, `Operational`, and `UAT` whenever those classes are present. If no verification classes were planned, say that explicitly. Output sections `Acceptance Criteria` with checklist `[ ] Criterion | Evidence`, and `Verification Classes` with the table. End with one-line verdict: PASS if all criteria and classes are covered, NEEDS-ATTENTION if gaps exist."
37
37
 
38
38
  ### Step 2 - Synthesize Findings
39
39
 
@@ -10,8 +10,8 @@
10
10
  */
11
11
 
12
12
  import type { ExtensionAPI, ExtensionCommandContext } from "@gsd/pi-coding-agent";
13
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
14
- import { join } from "node:path";
13
+ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
14
+ import { isAbsolute, join, relative } from "node:path";
15
15
  import { loadPrompt } from "./prompt-loader.js";
16
16
  import { gsdRoot } from "./paths.js";
17
17
  import { GitServiceImpl, runGit } from "./git-service.js";
@@ -77,6 +77,40 @@ function ensureQuickDir(basePath: string, taskNum: number, slug: string): string
77
77
  return taskDir;
78
78
  }
79
79
 
80
+ function isPathInside(parent: string, child: string): boolean {
81
+ const rel = relative(parent, child);
82
+ return rel === "" || (!!rel && !rel.startsWith("..") && !isAbsolute(rel));
83
+ }
84
+
85
+ function isExternalGsdRoot(basePath: string, root: string): boolean {
86
+ try {
87
+ return !isPathInside(realpathSync(basePath), realpathSync(root));
88
+ } catch {
89
+ return !isPathInside(basePath, root);
90
+ }
91
+ }
92
+
93
+ export function buildQuickCommitInstruction(basePath: string, root: string): string {
94
+ const externalState = isExternalGsdRoot(basePath, root);
95
+ if (externalState) {
96
+ return [
97
+ "Commit repo changes atomically, but do not stage or commit `.gsd/quick/...`:",
98
+ " - `.gsd/` resolves outside this git repository, so Git cannot stage quick-task summary files from the project repo.",
99
+ " - Write the quick summary file directly at the requested path; that file is persisted by GSD external state.",
100
+ " - Stage and commit only implementation/test/docs files that live inside the repository.",
101
+ " - If the task only writes quick-task research/summary files and no repository files changed, do not run `git commit`; report that there was nothing in the project repo to commit.",
102
+ ].join("\n");
103
+ }
104
+
105
+ return [
106
+ "Commit your changes atomically:",
107
+ " - Use conventional commit messages (feat:, fix:, refactor:, etc.)",
108
+ " - Stage only relevant files — never commit secrets or runtime files.",
109
+ " - Commit logical units separately if the task involves distinct changes.",
110
+ " - Quick tasks run outside the auto-mode lifecycle — there is no system auto-commit, so commit directly here.",
111
+ ].join("\n");
112
+ }
113
+
80
114
  function quickReturnStatePath(basePath: string): string {
81
115
  return join(gsdRoot(basePath), "runtime", "quick-return.json");
82
116
  }
@@ -246,6 +280,7 @@ export async function handleQuick(
246
280
  taskDir: taskDirRel,
247
281
  branch: actualBranch,
248
282
  summaryPath,
283
+ commitInstruction: buildQuickCommitInstruction(basePath, root),
249
284
  date,
250
285
  taskNum: String(taskNum),
251
286
  slug,
@@ -50,6 +50,15 @@ export interface FileEditEvidence {
50
50
 
51
51
  export type EvidenceEntry = BashEvidence | FileWriteEvidence | FileEditEvidence;
52
52
 
53
+ const EXECUTION_TOOL_NAMES = new Set([
54
+ "bash",
55
+ "Bash",
56
+ "gsd_exec",
57
+ "gsd_exec_search",
58
+ "mcp__gsd-workflow__gsd_exec",
59
+ "mcp__gsd-workflow__gsd_exec_search",
60
+ ]);
61
+
53
62
  // ─── Module State ───────────────────────────────────────────────────────────
54
63
 
55
64
  let unitEvidence: EvidenceEntry[] = [];
@@ -188,11 +197,11 @@ export function clearEvidenceFromDisk(
188
197
  * Exit codes and output are filled in by recordToolResult after execution.
189
198
  */
190
199
  export function recordToolCall(toolCallId: string, toolName: string, input: Record<string, unknown>): void {
191
- if (toolName === "bash" || toolName === "Bash") {
200
+ if (EXECUTION_TOOL_NAMES.has(toolName)) {
192
201
  unitEvidence.push({
193
202
  kind: "bash",
194
203
  toolCallId,
195
- command: String(input.command ?? ""),
204
+ command: String(input.command ?? input.cmd ?? input.query ?? ""),
196
205
  exitCode: -1,
197
206
  outputSnippet: "",
198
207
  timestamp: Date.now(),
@@ -2556,7 +2556,7 @@ test("autoLoop warns but proceeds for greenfield project (no project files) (#18
2556
2556
  "should not stop with health check failure for greenfield project",
2557
2557
  );
2558
2558
  const greenfieldWarning = notifications.find(
2559
- (n) => n.includes("no recognized project files") && n.includes("greenfield"),
2559
+ (n) => n.includes("no project content yet") && n.includes("greenfield"),
2560
2560
  );
2561
2561
  assert.ok(
2562
2562
  greenfieldWarning,
@@ -131,7 +131,7 @@ test("postflightPopStash — restores stashed changes and emits info notificatio
131
131
  run('git commit -m "simulate merge"', repo);
132
132
 
133
133
  const postNotifications: Array<{ msg: string; level: string }> = [];
134
- postflightPopStash(repo, "M004", (msg, level) => {
134
+ postflightPopStash(repo, "M004", preflight.stashMarker, (msg, level) => {
135
135
  postNotifications.push({ msg, level });
136
136
  });
137
137
 
@@ -171,7 +171,7 @@ test("preflight + merge + postflight round-trip preserves uncommitted changes",
171
171
  run('git commit -m "feat: add feature"', repo);
172
172
 
173
173
  // Postflight: pop stash
174
- postflightPopStash(repo, "M005", () => {});
174
+ postflightPopStash(repo, "M005", preflight.stashMarker, () => {});
175
175
 
176
176
  // README.md must still have our local content
177
177
  const restored = readFileSync(join(repo, "README.md"), "utf-8");
@@ -184,3 +184,89 @@ test("preflight + merge + postflight round-trip preserves uncommitted changes",
184
184
  try { rmSync(repo, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* ignore */ }
185
185
  }
186
186
  });
187
+
188
+ test("postflightPopStash conflict warning names the exact stash ref", () => {
189
+ const repo = createTempRepo();
190
+ try {
191
+ writeFileSync(join(repo, "README.md"), "# local work\n");
192
+ const preflight = preflightCleanRoot(repo, "M005C", () => {});
193
+ assert.equal(preflight.stashPushed, true, "must have stashed");
194
+
195
+ writeFileSync(join(repo, "README.md"), "# merged work\n");
196
+ run("git add README.md", repo);
197
+ run('git commit -m "simulate conflicting merge"', repo);
198
+
199
+ const notifications: Array<{ msg: string; level: string }> = [];
200
+ postflightPopStash(repo, "M005C", preflight.stashMarker, (msg, level) => {
201
+ notifications.push({ msg, level });
202
+ });
203
+
204
+ const warning = notifications.find((n) => n.level === "warning")?.msg ?? "";
205
+ assert.match(warning, /git stash pop stash@\{\d+\}/);
206
+ assert.match(warning, /git stash apply stash@\{\d+\}/);
207
+ } finally {
208
+ try { rmSync(repo, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* ignore */ }
209
+ }
210
+ });
211
+
212
+ test("postflightPopStash restores the matching GSD stash, not stash@{0}", () => {
213
+ const repo = createTempRepo();
214
+ try {
215
+ writeFileSync(join(repo, "README.md"), "# target stash\n");
216
+ const preflight = preflightCleanRoot(repo, "M006", () => {});
217
+ assert.equal(preflight.stashPushed, true, "must have stashed target change");
218
+
219
+ writeFileSync(join(repo, "other.txt"), "other stash\n");
220
+ run('git stash push --include-untracked -m "unrelated newer stash"', repo);
221
+
222
+ postflightPopStash(repo, "M006", preflight.stashMarker, () => {});
223
+
224
+ const content = readFileSync(join(repo, "README.md"), "utf-8");
225
+ assert.equal(content.replace(/\r\n/g, "\n"), "# target stash\n");
226
+ const stashList = run("git stash list", repo);
227
+ assert.ok(stashList.includes("unrelated newer stash"), "unrelated newer stash must remain");
228
+ assert.ok(!stashList.includes("gsd-preflight-stash [gsd-preflight-stash:M006"), "target stash should be consumed");
229
+ } finally {
230
+ try { rmSync(repo, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* ignore */ }
231
+ }
232
+ });
233
+
234
+ test("postflightPopStash restores the exact preflight marker when another same-milestone stash exists", () => {
235
+ const repo = createTempRepo();
236
+ try {
237
+ writeFileSync(join(repo, "README.md"), "# target stash\n");
238
+ const preflight = preflightCleanRoot(repo, "M007", () => {});
239
+ assert.equal(preflight.stashPushed, true, "must have stashed target change");
240
+ assert.ok(preflight.stashMarker, "preflight must expose exact stash marker");
241
+
242
+ writeFileSync(join(repo, "same-milestone.txt"), "newer same milestone stash\n");
243
+ run('git stash push --include-untracked -m "gsd-preflight-stash [gsd-preflight-stash:M007:other]"', repo);
244
+
245
+ postflightPopStash(repo, "M007", preflight.stashMarker, () => {});
246
+
247
+ const content = readFileSync(join(repo, "README.md"), "utf-8");
248
+ assert.equal(content.replace(/\r\n/g, "\n"), "# target stash\n");
249
+ const stashList = run("git stash list", repo);
250
+ assert.ok(stashList.includes("gsd-preflight-stash:M007:other"), "newer same-milestone stash must remain");
251
+ assert.ok(!stashList.includes(preflight.stashMarker), "exact target stash should be consumed");
252
+ } finally {
253
+ try { rmSync(repo, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* ignore */ }
254
+ }
255
+ });
256
+
257
+ test("postflightPopStash falls back to milestone marker prefix when exact marker is unavailable", () => {
258
+ const repo = createTempRepo();
259
+ try {
260
+ writeFileSync(join(repo, "README.md"), "# fallback stash\n");
261
+ run('git stash push --include-untracked -m "gsd-preflight-stash [gsd-preflight-stash:M008:fallback]"', repo);
262
+
263
+ postflightPopStash(repo, "M008", undefined, () => {});
264
+
265
+ const content = readFileSync(join(repo, "README.md"), "utf-8");
266
+ assert.equal(content.replace(/\r\n/g, "\n"), "# fallback stash\n");
267
+ const stashList = run("git stash list", repo);
268
+ assert.ok(!stashList.includes("gsd-preflight-stash:M008:fallback"), "fallback stash should be consumed");
269
+ } finally {
270
+ try { rmSync(repo, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* ignore */ }
271
+ }
272
+ });
@@ -232,4 +232,59 @@ describe('emitCrashRecoveredUnitEnd (#3348)', () => {
232
232
  rmSync(base, { recursive: true, force: true });
233
233
  }
234
234
  });
235
+
236
+ test('emitOpenUnitEndForUnit closes the latest open start with error context', async () => {
237
+ const base = makeTmpBase();
238
+ try {
239
+ const { emitJournalEvent, queryJournal } = await import('../journal.ts');
240
+ const { emitOpenUnitEndForUnit } = await import('../crash-recovery.ts');
241
+
242
+ const firstFlowId = randomUUID();
243
+ const secondFlowId = randomUUID();
244
+ emitJournalEvent(base, {
245
+ ts: new Date().toISOString(),
246
+ flowId: firstFlowId,
247
+ seq: 1,
248
+ eventType: 'unit-start',
249
+ data: { unitType: 'execute-task', unitId: 'M008/S04/T02' },
250
+ });
251
+ emitJournalEvent(base, {
252
+ ts: new Date().toISOString(),
253
+ flowId: firstFlowId,
254
+ seq: 2,
255
+ eventType: 'unit-end',
256
+ data: { unitType: 'execute-task', unitId: 'M008/S04/T02', status: 'completed' },
257
+ causedBy: { flowId: firstFlowId, seq: 1 },
258
+ });
259
+ emitJournalEvent(base, {
260
+ ts: new Date().toISOString(),
261
+ flowId: secondFlowId,
262
+ seq: 3,
263
+ eventType: 'unit-start',
264
+ data: { unitType: 'execute-task', unitId: 'M008/S04/T02' },
265
+ });
266
+
267
+ const emitted = emitOpenUnitEndForUnit(
268
+ base,
269
+ 'execute-task',
270
+ 'M008/S04/T02',
271
+ 'cancelled',
272
+ { message: 'runUnitPhase exploded', category: 'unit-exception', isTransient: false },
273
+ );
274
+
275
+ assert.equal(emitted, true, 'open unit should be closed');
276
+ const ends = queryJournal(base).filter((e) => e.eventType === 'unit-end');
277
+ assert.equal(ends.length, 2, 'should preserve existing end and add one new end');
278
+ const newEnd = ends.find((e) => e.causedBy?.flowId === secondFlowId);
279
+ assert.ok(newEnd, 'new end should close the latest open start');
280
+ assert.equal(newEnd!.data?.status, 'cancelled');
281
+ assert.deepEqual(newEnd!.data?.errorContext, {
282
+ message: 'runUnitPhase exploded',
283
+ category: 'unit-exception',
284
+ isTransient: false,
285
+ });
286
+ } finally {
287
+ rmSync(base, { recursive: true, force: true });
288
+ }
289
+ });
235
290
  });
@@ -30,6 +30,7 @@ import {
30
30
  isLockProcessAlive,
31
31
  } from "../crash-recovery.ts";
32
32
  import { normalizeRealPath } from "../paths.ts";
33
+ import { writeUnitRuntimeRecord } from "../unit-runtime.ts";
33
34
 
34
35
  function makeBase(): string {
35
36
  const base = mkdtempSync(join(tmpdir(), "gsd-crash-recovery-"));
@@ -102,6 +103,27 @@ test("readCrashLock synthesizes LockData from a stale dead worker (no dispatches
102
103
  assert.ok(lock!.startedAt, "startedAt populated from workers.started_at");
103
104
  });
104
105
 
106
+ test("readCrashLock falls back to latest in-flight runtime record when dispatch claim is missing", (t) => {
107
+ const base = makeBase();
108
+ t.after(() => cleanup(base));
109
+ openDatabase(join(base, ".gsd", "gsd.db"));
110
+ const projectRoot = normalizeRealPath(base);
111
+ const workerId = registerAutoWorker({ projectRootRealpath: projectRoot });
112
+ writeUnitRuntimeRecord(base, "execute-task", "M008/S04/T02", 1778069087937, {
113
+ phase: "dispatched",
114
+ lastProgressAt: 1778069087937,
115
+ lastProgressKind: "dispatch",
116
+ });
117
+ setWorkerPid(workerId, 99999);
118
+ expireWorker(workerId);
119
+
120
+ const lock = readCrashLock(base);
121
+ assert.ok(lock, "stale worker surfaced as a crash lock");
122
+ assert.equal(lock!.unitType, "execute-task");
123
+ assert.equal(lock!.unitId, "M008/S04/T02");
124
+ assert.equal(lock!.unitStartedAt, new Date(1778069087937).toISOString());
125
+ });
126
+
105
127
  test("readCrashLock includes the most recent dispatch as unitType/unitId", (t) => {
106
128
  const base = makeBase();
107
129
  t.after(() => cleanup(base));
@@ -11,12 +11,14 @@
11
11
  import test from "node:test";
12
12
  import assert from "node:assert/strict";
13
13
  import { mkdirSync, writeFileSync, rmSync, existsSync } from "node:fs";
14
+ import { execFileSync } from "node:child_process";
14
15
  import { join } from "node:path";
15
16
  import { tmpdir } from "node:os";
16
17
  import {
17
18
  detectProjectState,
18
19
  detectV1Planning,
19
20
  detectProjectSignals,
21
+ classifyProject,
20
22
  scanProjectFiles,
21
23
  } from "../detection.ts";
22
24
 
@@ -37,6 +39,18 @@ function cleanup(dir: string): void {
37
39
  }
38
40
  }
39
41
 
42
+ function git(dir: string, args: string[]): void {
43
+ execFileSync("git", args, { cwd: dir, stdio: "ignore" });
44
+ }
45
+
46
+ function makeGitRepo(prefix: string): string {
47
+ const dir = makeTempDir(prefix);
48
+ git(dir, ["init"]);
49
+ git(dir, ["config", "user.email", "test@example.com"]);
50
+ git(dir, ["config", "user.name", "Test User"]);
51
+ return dir;
52
+ }
53
+
40
54
  // ─── detectProjectState ─────────────────────────────────────────────────────────
41
55
 
42
56
  test("detectProjectState: empty directory returns state=none", (t) => {
@@ -49,6 +63,132 @@ test("detectProjectState: empty directory returns state=none", (t) => {
49
63
  assert.equal(result.v2, undefined);
50
64
  });
51
65
 
66
+ test("classifyProject: no git repo is invalid", (t) => {
67
+ const dir = makeTempDir("classify-invalid");
68
+ t.after(() => cleanup(dir));
69
+
70
+ const classification = classifyProject(dir);
71
+ assert.equal(classification.kind, "invalid-repo");
72
+ });
73
+
74
+ test("classifyProject: empty git repo is greenfield", (t) => {
75
+ const dir = makeGitRepo("classify-greenfield");
76
+ t.after(() => cleanup(dir));
77
+
78
+ const classification = classifyProject(dir);
79
+ assert.equal(classification.kind, "greenfield");
80
+ });
81
+
82
+ test("classifyProject: nested empty git repo does not inherit ancestor markers", (t) => {
83
+ const parent = makeGitRepo("classify-parent-marker");
84
+ t.after(() => cleanup(parent));
85
+
86
+ writeFileSync(join(parent, "package.json"), JSON.stringify({ name: "parent" }), "utf-8");
87
+ git(parent, ["add", "package.json"]);
88
+ git(parent, ["commit", "-m", "add parent marker"]);
89
+ const child = join(parent, "nested");
90
+ mkdirSync(child, { recursive: true });
91
+ git(child, ["init"]);
92
+ git(child, ["config", "user.email", "test@example.com"]);
93
+ git(child, ["config", "user.name", "Test User"]);
94
+
95
+ const classification = classifyProject(child);
96
+ assert.equal(classification.kind, "greenfield");
97
+ });
98
+
99
+ test("classifyProject: tracked static HTML is existing untyped content", (t) => {
100
+ const dir = makeGitRepo("classify-index");
101
+ t.after(() => cleanup(dir));
102
+
103
+ writeFileSync(join(dir, "index.html"), "<main></main>\n", "utf-8");
104
+ git(dir, ["add", "index.html"]);
105
+ git(dir, ["commit", "-m", "add static page"]);
106
+
107
+ const classification = classifyProject(dir);
108
+ assert.equal(classification.kind, "untyped-existing");
109
+ assert.deepEqual(classification.contentFiles, ["index.html"]);
110
+ });
111
+
112
+ test("classifyProject: README-only repo is existing untyped content", (t) => {
113
+ const dir = makeGitRepo("classify-readme");
114
+ t.after(() => cleanup(dir));
115
+
116
+ writeFileSync(join(dir, "README.md"), "# docs\n", "utf-8");
117
+ git(dir, ["add", "README.md"]);
118
+ git(dir, ["commit", "-m", "add docs"]);
119
+
120
+ const classification = classifyProject(dir);
121
+ assert.equal(classification.kind, "untyped-existing");
122
+ });
123
+
124
+ test("classifyProject: src-only content is untyped existing, not typed marker", (t) => {
125
+ const dir = makeGitRepo("classify-src-only");
126
+ t.after(() => cleanup(dir));
127
+
128
+ mkdirSync(join(dir, "src"), { recursive: true });
129
+ writeFileSync(join(dir, "src", "index.txt"), "content\n", "utf-8");
130
+ git(dir, ["add", "src/index.txt"]);
131
+ git(dir, ["commit", "-m", "add source content"]);
132
+
133
+ const classification = classifyProject(dir);
134
+ assert.equal(classification.kind, "untyped-existing");
135
+ assert.deepEqual(classification.contentFiles, ["src/index.txt"]);
136
+ });
137
+
138
+ test("classifyProject: nested untracked files count as project content", (t) => {
139
+ const dir = makeGitRepo("classify-untracked-nested");
140
+ t.after(() => cleanup(dir));
141
+
142
+ mkdirSync(join(dir, "docs"), { recursive: true });
143
+ writeFileSync(join(dir, "docs", "index.html"), "<main></main>\n", "utf-8");
144
+
145
+ const classification = classifyProject(dir);
146
+ assert.equal(classification.kind, "untyped-existing");
147
+ assert.deepEqual(classification.untrackedFiles, ["docs/index.html"]);
148
+ });
149
+
150
+ test("classifyProject: known markers produce typed existing project", (t) => {
151
+ const dir = makeGitRepo("classify-typed");
152
+ t.after(() => cleanup(dir));
153
+
154
+ writeFileSync(join(dir, "package.json"), JSON.stringify({ name: "typed" }), "utf-8");
155
+ git(dir, ["add", "package.json"]);
156
+ git(dir, ["commit", "-m", "add package"]);
157
+
158
+ const classification = classifyProject(dir);
159
+ assert.equal(classification.kind, "typed-existing");
160
+ assert.ok(classification.markers.includes("package.json"));
161
+ });
162
+
163
+ test("classifyProject: ignored build/cache-only files do not count as content", (t) => {
164
+ const dir = makeGitRepo("classify-ignored");
165
+ t.after(() => cleanup(dir));
166
+
167
+ writeFileSync(join(dir, ".gitignore"), "dist/\n.cache/\n", "utf-8");
168
+ git(dir, ["add", ".gitignore"]);
169
+ git(dir, ["commit", "-m", "ignore generated files"]);
170
+ mkdirSync(join(dir, "dist"), { recursive: true });
171
+ writeFileSync(join(dir, "dist", "bundle.js"), "generated\n", "utf-8");
172
+ mkdirSync(join(dir, ".cache"), { recursive: true });
173
+ writeFileSync(join(dir, ".cache", "x"), "cache\n", "utf-8");
174
+
175
+ const classification = classifyProject(dir);
176
+ assert.equal(classification.kind, "greenfield");
177
+ });
178
+
179
+ test("classifyProject: generated framework/cache dirs do not count as content", (t) => {
180
+ const dir = makeGitRepo("classify-generated-dirs");
181
+ t.after(() => cleanup(dir));
182
+
183
+ mkdirSync(join(dir, ".next", "server"), { recursive: true });
184
+ writeFileSync(join(dir, ".next", "server", "page.js"), "generated\n", "utf-8");
185
+ mkdirSync(join(dir, ".venv", "lib"), { recursive: true });
186
+ writeFileSync(join(dir, ".venv", "lib", "site.py"), "generated\n", "utf-8");
187
+
188
+ const classification = classifyProject(dir);
189
+ assert.equal(classification.kind, "greenfield");
190
+ });
191
+
52
192
  test("detectProjectState: directory with .gsd/milestones/M001 returns v2-gsd", (t) => {
53
193
  const dir = makeTempDir("v2-gsd");
54
194
  t.after(() => cleanup(dir));
@@ -15,7 +15,7 @@ import { tmpdir } from "node:os";
15
15
  import { join } from "node:path";
16
16
  import { randomUUID } from "node:crypto";
17
17
 
18
- import { hasPendingDeepStage } from "../auto-dispatch.ts";
18
+ import { hasPendingDeepStage, shouldRunDeepProjectSetup } from "../auto-dispatch.ts";
19
19
  import type { GSDPreferences } from "../preferences.ts";
20
20
  import { loadEffectiveGSDPreferences } from "../preferences.ts";
21
21
 
@@ -57,6 +57,38 @@ test("hasPendingDeepStage: returns true in deep mode when nothing has been captu
57
57
  }
58
58
  });
59
59
 
60
+ test("shouldRunDeepProjectSetup: complete state wins over pending deep setup", async () => {
61
+ const base = makeBase();
62
+ try {
63
+ assert.equal(hasPendingDeepStage(deepPrefs, base), true);
64
+ assert.equal(
65
+ shouldRunDeepProjectSetup({ phase: "complete" }, deepPrefs, base),
66
+ false,
67
+ "completed projects must not restart deep setup and loop through auto-mode",
68
+ );
69
+ } finally {
70
+ rmSync(base, { recursive: true, force: true });
71
+ }
72
+ });
73
+
74
+ test("shouldRunDeepProjectSetup: only setup phases can trigger pending deep setup", () => {
75
+ const base = makeBase();
76
+ try {
77
+ assert.equal(hasPendingDeepStage(deepPrefs, base), true);
78
+ assert.equal(shouldRunDeepProjectSetup({ phase: "pre-planning" }, deepPrefs, base), true);
79
+ assert.equal(shouldRunDeepProjectSetup({ phase: "needs-discussion" }, deepPrefs, base), true);
80
+ assert.equal(shouldRunDeepProjectSetup({ phase: "planning" }, deepPrefs, base), true);
81
+ assert.equal(shouldRunDeepProjectSetup({ phase: "executing" }, deepPrefs, base), false);
82
+ assert.equal(shouldRunDeepProjectSetup({ phase: "blocked" }, deepPrefs, base), false);
83
+ assert.equal(
84
+ shouldRunDeepProjectSetup({ phase: "pre-planning" }, deepPrefs, base, { hasSurvivorBranch: true }),
85
+ false,
86
+ );
87
+ } finally {
88
+ rmSync(base, { recursive: true, force: true });
89
+ }
90
+ });
91
+
60
92
  test("hasPendingDeepStage: returns true in deep mode when only some gates pass", () => {
61
93
  // workflow-preferences captured but PROJECT.md still missing.
62
94
  const base = makeBase();