gsd-opencode 1.22.1 → 1.33.0

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 (188) hide show
  1. package/agents/gsd-advisor-researcher.md +112 -0
  2. package/agents/gsd-assumptions-analyzer.md +110 -0
  3. package/agents/gsd-codebase-mapper.md +0 -2
  4. package/agents/gsd-debugger.md +117 -2
  5. package/agents/gsd-doc-verifier.md +207 -0
  6. package/agents/gsd-doc-writer.md +608 -0
  7. package/agents/gsd-executor.md +45 -4
  8. package/agents/gsd-integration-checker.md +0 -2
  9. package/agents/gsd-nyquist-auditor.md +0 -2
  10. package/agents/gsd-phase-researcher.md +191 -5
  11. package/agents/gsd-plan-checker.md +152 -5
  12. package/agents/gsd-planner.md +131 -157
  13. package/agents/gsd-project-researcher.md +28 -3
  14. package/agents/gsd-research-synthesizer.md +0 -2
  15. package/agents/gsd-roadmapper.md +29 -2
  16. package/agents/gsd-security-auditor.md +129 -0
  17. package/agents/gsd-ui-auditor.md +485 -0
  18. package/agents/gsd-ui-checker.md +305 -0
  19. package/agents/gsd-ui-researcher.md +368 -0
  20. package/agents/gsd-user-profiler.md +173 -0
  21. package/agents/gsd-verifier.md +207 -22
  22. package/commands/gsd/gsd-add-backlog.md +76 -0
  23. package/commands/gsd/gsd-analyze-dependencies.md +34 -0
  24. package/commands/gsd/gsd-audit-uat.md +24 -0
  25. package/commands/gsd/gsd-autonomous.md +45 -0
  26. package/commands/gsd/gsd-cleanup.md +5 -0
  27. package/commands/gsd/gsd-debug.md +29 -21
  28. package/commands/gsd/gsd-discuss-phase.md +15 -36
  29. package/commands/gsd/gsd-do.md +30 -0
  30. package/commands/gsd/gsd-docs-update.md +48 -0
  31. package/commands/gsd/gsd-execute-phase.md +24 -2
  32. package/commands/gsd/gsd-fast.md +30 -0
  33. package/commands/gsd/gsd-forensics.md +56 -0
  34. package/commands/gsd/gsd-help.md +2 -0
  35. package/commands/gsd/gsd-join-discord.md +2 -1
  36. package/commands/gsd/gsd-list-workspaces.md +19 -0
  37. package/commands/gsd/gsd-manager.md +40 -0
  38. package/commands/gsd/gsd-milestone-summary.md +51 -0
  39. package/commands/gsd/gsd-new-project.md +4 -0
  40. package/commands/gsd/gsd-new-workspace.md +44 -0
  41. package/commands/gsd/gsd-next.md +24 -0
  42. package/commands/gsd/gsd-note.md +34 -0
  43. package/commands/gsd/gsd-plan-phase.md +8 -1
  44. package/commands/gsd/gsd-plant-seed.md +28 -0
  45. package/commands/gsd/gsd-pr-branch.md +25 -0
  46. package/commands/gsd/gsd-profile-user.md +46 -0
  47. package/commands/gsd/gsd-quick.md +7 -3
  48. package/commands/gsd/gsd-reapply-patches.md +178 -45
  49. package/commands/gsd/gsd-remove-workspace.md +26 -0
  50. package/commands/gsd/gsd-research-phase.md +7 -12
  51. package/commands/gsd/gsd-review-backlog.md +62 -0
  52. package/commands/gsd/gsd-review.md +38 -0
  53. package/commands/gsd/gsd-secure-phase.md +35 -0
  54. package/commands/gsd/gsd-session-report.md +19 -0
  55. package/commands/gsd/gsd-set-profile.md +24 -23
  56. package/commands/gsd/gsd-ship.md +23 -0
  57. package/commands/gsd/gsd-stats.md +18 -0
  58. package/commands/gsd/gsd-thread.md +127 -0
  59. package/commands/gsd/gsd-ui-phase.md +34 -0
  60. package/commands/gsd/gsd-ui-review.md +32 -0
  61. package/commands/gsd/gsd-workstreams.md +71 -0
  62. package/get-shit-done/bin/gsd-tools.cjs +450 -90
  63. package/get-shit-done/bin/lib/commands.cjs +489 -24
  64. package/get-shit-done/bin/lib/config.cjs +329 -48
  65. package/get-shit-done/bin/lib/core.cjs +1143 -102
  66. package/get-shit-done/bin/lib/docs.cjs +267 -0
  67. package/get-shit-done/bin/lib/frontmatter.cjs +125 -43
  68. package/get-shit-done/bin/lib/init.cjs +918 -106
  69. package/get-shit-done/bin/lib/milestone.cjs +65 -33
  70. package/get-shit-done/bin/lib/model-profiles.cjs +70 -0
  71. package/get-shit-done/bin/lib/phase.cjs +434 -404
  72. package/get-shit-done/bin/lib/profile-output.cjs +1048 -0
  73. package/get-shit-done/bin/lib/profile-pipeline.cjs +539 -0
  74. package/get-shit-done/bin/lib/roadmap.cjs +156 -101
  75. package/get-shit-done/bin/lib/schema-detect.cjs +238 -0
  76. package/get-shit-done/bin/lib/security.cjs +384 -0
  77. package/get-shit-done/bin/lib/state.cjs +711 -79
  78. package/get-shit-done/bin/lib/template.cjs +2 -2
  79. package/get-shit-done/bin/lib/uat.cjs +282 -0
  80. package/get-shit-done/bin/lib/verify.cjs +254 -42
  81. package/get-shit-done/bin/lib/workstream.cjs +495 -0
  82. package/get-shit-done/references/agent-contracts.md +79 -0
  83. package/get-shit-done/references/artifact-types.md +113 -0
  84. package/get-shit-done/references/checkpoints.md +12 -10
  85. package/get-shit-done/references/context-budget.md +49 -0
  86. package/get-shit-done/references/continuation-format.md +15 -15
  87. package/get-shit-done/references/decimal-phase-calculation.md +2 -3
  88. package/get-shit-done/references/domain-probes.md +125 -0
  89. package/get-shit-done/references/gate-prompts.md +100 -0
  90. package/get-shit-done/references/git-integration.md +47 -0
  91. package/get-shit-done/references/model-profile-resolution.md +2 -0
  92. package/get-shit-done/references/model-profiles.md +62 -16
  93. package/get-shit-done/references/phase-argument-parsing.md +2 -2
  94. package/get-shit-done/references/planner-gap-closure.md +62 -0
  95. package/get-shit-done/references/planner-reviews.md +39 -0
  96. package/get-shit-done/references/planner-revision.md +87 -0
  97. package/get-shit-done/references/planning-config.md +18 -1
  98. package/get-shit-done/references/revision-loop.md +97 -0
  99. package/get-shit-done/references/ui-brand.md +2 -2
  100. package/get-shit-done/references/universal-anti-patterns.md +58 -0
  101. package/get-shit-done/references/user-profiling.md +681 -0
  102. package/get-shit-done/references/workstream-flag.md +111 -0
  103. package/get-shit-done/templates/SECURITY.md +61 -0
  104. package/get-shit-done/templates/UAT.md +21 -3
  105. package/get-shit-done/templates/UI-SPEC.md +100 -0
  106. package/get-shit-done/templates/VALIDATION.md +3 -3
  107. package/get-shit-done/templates/claude-md.md +145 -0
  108. package/get-shit-done/templates/config.json +14 -3
  109. package/get-shit-done/templates/context.md +61 -6
  110. package/get-shit-done/templates/debug-subagent-prompt.md +2 -6
  111. package/get-shit-done/templates/dev-preferences.md +21 -0
  112. package/get-shit-done/templates/discussion-log.md +63 -0
  113. package/get-shit-done/templates/phase-prompt.md +46 -5
  114. package/get-shit-done/templates/planner-subagent-prompt.md +2 -10
  115. package/get-shit-done/templates/project.md +2 -0
  116. package/get-shit-done/templates/state.md +2 -2
  117. package/get-shit-done/templates/user-profile.md +146 -0
  118. package/get-shit-done/workflows/add-phase.md +4 -4
  119. package/get-shit-done/workflows/add-tests.md +4 -4
  120. package/get-shit-done/workflows/add-todo.md +4 -4
  121. package/get-shit-done/workflows/analyze-dependencies.md +96 -0
  122. package/get-shit-done/workflows/audit-milestone.md +20 -16
  123. package/get-shit-done/workflows/audit-uat.md +109 -0
  124. package/get-shit-done/workflows/autonomous.md +1036 -0
  125. package/get-shit-done/workflows/check-todos.md +4 -4
  126. package/get-shit-done/workflows/cleanup.md +4 -4
  127. package/get-shit-done/workflows/complete-milestone.md +22 -10
  128. package/get-shit-done/workflows/diagnose-issues.md +21 -7
  129. package/get-shit-done/workflows/discovery-phase.md +2 -2
  130. package/get-shit-done/workflows/discuss-phase-assumptions.md +671 -0
  131. package/get-shit-done/workflows/discuss-phase-power.md +291 -0
  132. package/get-shit-done/workflows/discuss-phase.md +558 -47
  133. package/get-shit-done/workflows/do.md +104 -0
  134. package/get-shit-done/workflows/docs-update.md +1093 -0
  135. package/get-shit-done/workflows/execute-phase.md +741 -58
  136. package/get-shit-done/workflows/execute-plan.md +77 -12
  137. package/get-shit-done/workflows/fast.md +105 -0
  138. package/get-shit-done/workflows/forensics.md +265 -0
  139. package/get-shit-done/workflows/health.md +28 -6
  140. package/get-shit-done/workflows/help.md +127 -7
  141. package/get-shit-done/workflows/insert-phase.md +4 -4
  142. package/get-shit-done/workflows/list-phase-assumptions.md +2 -2
  143. package/get-shit-done/workflows/list-workspaces.md +56 -0
  144. package/get-shit-done/workflows/manager.md +363 -0
  145. package/get-shit-done/workflows/map-codebase.md +83 -44
  146. package/get-shit-done/workflows/milestone-summary.md +223 -0
  147. package/get-shit-done/workflows/new-milestone.md +133 -25
  148. package/get-shit-done/workflows/new-project.md +216 -54
  149. package/get-shit-done/workflows/new-workspace.md +237 -0
  150. package/get-shit-done/workflows/next.md +97 -0
  151. package/get-shit-done/workflows/node-repair.md +92 -0
  152. package/get-shit-done/workflows/note.md +156 -0
  153. package/get-shit-done/workflows/pause-work.md +132 -15
  154. package/get-shit-done/workflows/plan-milestone-gaps.md +6 -7
  155. package/get-shit-done/workflows/plan-phase.md +513 -62
  156. package/get-shit-done/workflows/plant-seed.md +169 -0
  157. package/get-shit-done/workflows/pr-branch.md +129 -0
  158. package/get-shit-done/workflows/profile-user.md +450 -0
  159. package/get-shit-done/workflows/progress.md +154 -29
  160. package/get-shit-done/workflows/quick.md +285 -111
  161. package/get-shit-done/workflows/remove-phase.md +2 -2
  162. package/get-shit-done/workflows/remove-workspace.md +90 -0
  163. package/get-shit-done/workflows/research-phase.md +13 -9
  164. package/get-shit-done/workflows/resume-project.md +37 -18
  165. package/get-shit-done/workflows/review.md +281 -0
  166. package/get-shit-done/workflows/secure-phase.md +154 -0
  167. package/get-shit-done/workflows/session-report.md +146 -0
  168. package/get-shit-done/workflows/set-profile.md +2 -2
  169. package/get-shit-done/workflows/settings.md +91 -11
  170. package/get-shit-done/workflows/ship.md +237 -0
  171. package/get-shit-done/workflows/stats.md +60 -0
  172. package/get-shit-done/workflows/transition.md +150 -23
  173. package/get-shit-done/workflows/ui-phase.md +292 -0
  174. package/get-shit-done/workflows/ui-review.md +183 -0
  175. package/get-shit-done/workflows/update.md +262 -30
  176. package/get-shit-done/workflows/validate-phase.md +14 -17
  177. package/get-shit-done/workflows/verify-phase.md +143 -11
  178. package/get-shit-done/workflows/verify-work.md +141 -39
  179. package/package.json +1 -1
  180. package/skills/gsd-audit-milestone/SKILL.md +29 -0
  181. package/skills/gsd-cleanup/SKILL.md +19 -0
  182. package/skills/gsd-complete-milestone/SKILL.md +131 -0
  183. package/skills/gsd-discuss-phase/SKILL.md +54 -0
  184. package/skills/gsd-execute-phase/SKILL.md +49 -0
  185. package/skills/gsd-plan-phase/SKILL.md +37 -0
  186. package/skills/gsd-ui-phase/SKILL.md +24 -0
  187. package/skills/gsd-ui-review/SKILL.md +24 -0
  188. package/skills/gsd-verify-work/SKILL.md +30 -0
@@ -1,26 +1,96 @@
1
- <purpose>
1
+ <objective>
2
2
  Execute all plans in a phase using wave-based parallel execution. Orchestrator stays lean — delegates plan execution to subagents.
3
- </purpose>
3
+ </objective>
4
4
 
5
5
  <core_principle>
6
6
  Orchestrator coordinates, not executes. Each subagent loads the full execute-plan context. Orchestrator: discover plans → analyze deps → group waves → spawn agents → handle checkpoints → collect results.
7
7
  </core_principle>
8
8
 
9
+ <runtime_compatibility>
10
+ **Subagent spawning is runtime-specific:**
11
+ - **OpenCode:** Uses `task(subagent_type="gsd-executor", ...)` — blocks until complete, returns result
12
+ - **Copilot:** Subagent spawning does not reliably return completion signals. **Default to
13
+ sequential inline execution**: read and follow execute-plan.md directly for each plan
14
+ instead of spawning parallel agents. Only attempt parallel spawning if the user
15
+ explicitly requests it — and in that case, rely on the spot-check fallback in step 3
16
+ to detect completion.
17
+ - **Other runtimes:** If `task`/`task` tool is unavailable, use sequential inline execution as the
18
+ fallback. Check for tool availability at runtime rather than assuming based on runtime name.
19
+
20
+ **Fallback rule:** If a spawned agent completes its work (commits visible, SUMMARY.md exists) but
21
+ the orchestrator never receives the completion signal, treat it as successful based on spot-checks
22
+ and continue to the next wave/plan. Never block indefinitely waiting for a signal — always verify
23
+ via filesystem and git state.
24
+ </runtime_compatibility>
25
+
9
26
  <required_reading>
10
27
  read STATE.md before any operation to load project context.
28
+
29
+ @$HOME/.config/opencode/get-shit-done/references/agent-contracts.md
30
+ @$HOME/.config/opencode/get-shit-done/references/context-budget.md
11
31
  </required_reading>
12
32
 
33
+ <available_agent_types>
34
+ These are the valid GSD subagent types registered in .OpenCode/agents/ (or equivalent for your runtime).
35
+ Always use the exact name from this list — do not fall back to 'general' or other built-in types:
36
+
37
+ - gsd-executor — Executes plan tasks, commits, creates SUMMARY.md
38
+ - gsd-verifier — Verifies phase completion, checks quality gates
39
+ - gsd-planner — Creates detailed plans from phase scope
40
+ - gsd-phase-researcher — Researches technical approaches for a phase
41
+ - gsd-plan-checker — Reviews plan quality before execution
42
+ - gsd-debugger — Diagnoses and fixes issues
43
+ - gsd-codebase-mapper — Maps project structure and dependencies
44
+ - gsd-integration-checker — Checks cross-phase integration
45
+ - gsd-nyquist-auditor — Validates verification coverage
46
+ - gsd-ui-researcher — Researches UI/UX approaches
47
+ - gsd-ui-checker — Reviews UI implementation quality
48
+ - gsd-ui-auditor — Audits UI against design requirements
49
+ </available_agent_types>
50
+
13
51
  <process>
14
52
 
53
+ <step name="parse_args" priority="first">
54
+ Parse `$ARGUMENTS` before loading any context:
55
+
56
+ - First positional token → `PHASE_ARG`
57
+ - Optional `--wave N` → `WAVE_FILTER`
58
+ - Optional `--gaps-only` keeps its current meaning
59
+
60
+ If `--wave` is absent, preserve the current behavior of executing all incomplete waves in the phase.
61
+ </step>
62
+
15
63
  <step name="initialize" priority="first">
16
64
  Load all context in one call:
17
65
 
18
66
  ```bash
19
67
  INIT=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init execute-phase "${PHASE_ARG}")
20
68
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
69
+ AGENT_SKILLS=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-executor 2>/dev/null)
21
70
  ```
22
71
 
23
- Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`.
72
+ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
73
+
74
+ **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
75
+
76
+ read worktree config:
77
+
78
+ ```bash
79
+ USE_WORKTREES=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
80
+ ```
81
+
82
+ When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees.
83
+
84
+ read context window size for adaptive prompt enrichment:
85
+
86
+ ```bash
87
+ CONTEXT_WINDOW=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get context_window 2>/dev/null || echo "200000")
88
+ ```
89
+
90
+ When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
91
+ - Executor agents receive prior wave SUMMARY.md files and the phase CONTEXT.md/RESEARCH.md
92
+ - Verifier agents receive all PLAN.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
93
+ - This enables cross-phase awareness and history-aware verification
24
94
 
25
95
  **If `phase_found` is false:** Error — phase directory not found.
26
96
  **If `plan_count` is 0:** Error — no plans found in phase.
@@ -28,14 +98,95 @@ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelizat
28
98
 
29
99
  When `parallelization` is false, plans within a wave execute sequentially.
30
100
 
31
- **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). Must happen before any config reads (checkpoint handling also reads auto-advance flags):
101
+ **Runtime detection for Copilot:**
102
+ Check if the current runtime is Copilot by testing for the `@gsd-executor` agent pattern
103
+ or absence of the `task()` subagent API. If running under Copilot, force sequential inline
104
+ execution regardless of the `parallelization` setting — Copilot's subagent completion
105
+ signals are unreliable (see `<runtime_compatibility>`). Set `COPILOT_SEQUENTIAL=true`
106
+ internally and skip the `execute_waves` step in favor of `check_interactive_mode`'s
107
+ inline path for each plan.
108
+
109
+ **REQUIRED — Sync chain flag with intent.** If user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This prevents stale `_auto_chain_active: true` from causing unwanted auto-advance. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). You MUST execute this bash block before any config reads:
32
110
  ```bash
111
+ # REQUIRED: prevents stale auto-chain from previous --auto runs
33
112
  if [[ ! "$ARGUMENTS" =~ --auto ]]; then
34
113
  node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
35
114
  fi
36
115
  ```
37
116
  </step>
38
117
 
118
+ <step name="check_blocking_antipatterns" priority="first">
119
+ **MANDATORY — Check for blocking anti-patterns before any other work.**
120
+
121
+ Look for a `.continue-here.md` in the current phase directory:
122
+
123
+ ```bash
124
+ ls ${phase_dir}/.continue-here.md 2>/dev/null || true
125
+ ```
126
+
127
+ If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
128
+
129
+ **If one or more `blocking` anti-patterns are found:**
130
+
131
+ This step cannot be skipped. Before proceeding to `check_interactive_mode` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
132
+
133
+ 1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
134
+ 2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
135
+ 3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
136
+
137
+ write these answers inline before continuing. If a blocking anti-pattern cannot be answered from the context in `.continue-here.md`, stop and ask the user for clarification.
138
+
139
+ **If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_interactive_mode`.
140
+ </step>
141
+
142
+ <step name="check_interactive_mode">
143
+ **Parse `--interactive` flag from $ARGUMENTS.**
144
+
145
+ **If `--interactive` flag present:** Switch to interactive execution mode.
146
+
147
+ Interactive mode executes plans sequentially **inline** (no subagent spawning) with user
148
+ checkpoints between tasks. The user can review, modify, or redirect work at any point.
149
+
150
+ **Interactive execution flow:**
151
+
152
+ 1. Load plan inventory as normal (discover_and_group_plans)
153
+ 2. For each plan (sequentially, ignoring wave grouping):
154
+
155
+ a. **Present the plan to the user:**
156
+ ```
157
+ ## Plan {plan_id}: {plan_name}
158
+
159
+ Objective: {from plan file}
160
+ Tasks: {task_count}
161
+
162
+ Options:
163
+ - Execute (proceed with all tasks)
164
+ - Review first (show task breakdown before starting)
165
+ - Skip (move to next plan)
166
+ - Stop (end execution, save progress)
167
+ ```
168
+
169
+ b. **If "Review first":** read and display the full plan file. Ask again: Execute, Modify, Skip.
170
+
171
+ c. **If "Execute":** read and follow `$HOME/.config/opencode/get-shit-done/workflows/execute-plan.md` **inline**
172
+ (do NOT spawn a subagent). Execute tasks one at a time.
173
+
174
+ d. **After each task:** Pause briefly. If the user intervenes (types anything), stop and address
175
+ their feedback before continuing. Otherwise proceed to next task.
176
+
177
+ e. **After plan complete:** Show results, commit, create SUMMARY.md, then present next plan.
178
+
179
+ 3. After all plans: proceed to verification (same as normal mode).
180
+
181
+ **Benefits of interactive mode:**
182
+ - No subagent overhead — dramatically lower token usage
183
+ - User catches mistakes early — saves costly verification cycles
184
+ - Maintains GSD's planning/tracking structure
185
+ - Best for: small phases, bug fixes, verification gaps, learning GSD
186
+
187
+ **Skip to handle_branching step** (interactive plans execute inline after grouping).
188
+ </step>
189
+
39
190
  <step name="handle_branching">
40
191
  Check `branching_strategy` from init:
41
192
 
@@ -53,6 +204,12 @@ All subsequent commits go to this branch. User handles merging.
53
204
  From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
54
205
 
55
206
  Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
207
+
208
+ **Update STATE.md for phase start:**
209
+ ```bash
210
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" state begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
211
+ ```
212
+ This updates Status, Last Activity, Current focus, Current Position, and plan counts in STATE.md so frontmatter and body text reflect the active phase immediately.
56
213
  </step>
57
214
 
58
215
  <step name="discover_and_group_plans">
@@ -64,13 +221,19 @@ PLAN_INDEX=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" phase
64
221
 
65
222
  Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
66
223
 
67
- **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If all filtered: "No matching incomplete plans" exit.
224
+ **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If `WAVE_FILTER` is set: also skip plans whose `wave` does not equal `WAVE_FILTER`.
225
+
226
+ **Wave safety check:** If `WAVE_FILTER` is set and there are still incomplete plans in any lower wave that match the current execution mode, STOP and tell the user to finish earlier waves first. Do not let Wave 2+ execute while prerequisite earlier-wave plans remain incomplete.
227
+
228
+ If all filtered: "No matching incomplete plans" → exit.
68
229
 
69
230
  Report:
70
231
  ```
71
232
  ## Execution Plan
72
233
 
73
- **Phase {X}: {Name}** — {total_plans} plans across {wave_count} waves
234
+ **Phase {X}: {Name}** — {total_plans} matching plans across {wave_count} wave(s)
235
+
236
+ {If WAVE_FILTER is set: `Wave filter active: executing only Wave {WAVE_FILTER}`.}
74
237
 
75
238
  | Wave | Plans | What it builds |
76
239
  |------|-------|----------------|
@@ -80,11 +243,45 @@ Report:
80
243
  </step>
81
244
 
82
245
  <step name="execute_waves">
83
- Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
246
+ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
84
247
 
85
248
  **For each wave:**
86
249
 
87
- 1. **Describe what's being built (BEFORE spawning):**
250
+ 1. **Intra-wave files_modified overlap check (BEFORE spawning):**
251
+
252
+ Before spawning any agents for this wave, inspect the `files_modified` list of all plans
253
+ in the wave. Check every pair of plans in the wave — if any two plans share even one file
254
+ in their `files_modified` lists, those plans have an implicit dependency and MUST NOT run
255
+ in parallel.
256
+
257
+ **Detection algorithm (pseudocode):**
258
+ ```
259
+ seen_files = {}
260
+ overlapping_plans = []
261
+ for each plan in wave_plans:
262
+ for each file in plan.files_modified:
263
+ if file in seen_files:
264
+ overlapping_plans.add(plan, seen_files[file]) # both plans overlap on this file
265
+ else:
266
+ seen_files[file] = plan
267
+ ```
268
+
269
+ **If overlap is detected:**
270
+ - Warn the user:
271
+ ```
272
+ ⚠ Intra-wave files_modified overlap detected in Wave {N}:
273
+ Plan {A} and Plan {B} both modify {file}
274
+ Running these plans sequentially to avoid parallel worktree conflicts.
275
+ ```
276
+ - Override `PARALLELIZATION` to `false` for this wave only — run all plans in the wave
277
+ sequentially regardless of the global parallelization setting.
278
+ - This is a safety net for plans that were incorrectly assigned to the same wave.
279
+ The planner should have caught this; flag it as a planning defect so the user can
280
+ replan the phase if desired.
281
+
282
+ **If no overlap:** proceed normally (parallel if `PARALLELIZATION=true`).
283
+
284
+ 2. **Describe what's being built (BEFORE spawning):**
88
285
 
89
286
  read each plan's `<objective>`. Extract what's being built and why.
90
287
 
@@ -102,37 +299,127 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
102
299
  - Bad: "Executing terrain generation plan"
103
300
  - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
104
301
 
105
- 2. **Spawn executor agents:**
302
+ 3. **Spawn executor agents:**
303
+
304
+ Pass paths only — executors read files themselves with their fresh context window.
305
+ For 200k models, this keeps orchestrator context lean (~10-15%).
306
+ For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
307
+
308
+ **Worktree mode** (`USE_WORKTREES` is not `false`):
106
309
 
107
- Pass paths only executors read files themselves with their fresh 200k context.
108
- This keeps orchestrator context lean (~10-15%).
310
+ Before spawning, capture the current HEAD:
311
+ ```bash
312
+ EXPECTED_BASE=$(git rev-parse HEAD)
313
+ ```
109
314
 
315
+ **Sequential dispatch for parallel execution (waves with 2+ agents):**
316
+ When spawning multiple agents in a wave, dispatch each `task()` call **one at a time
317
+ with `run_in_background: true`** — do NOT send all task calls in a single message.
318
+ `git worktree add` acquires an exclusive lock on `.git/config.lock`, so simultaneous
319
+ calls race for this lock and fail. Sequential dispatch ensures each worktree finishes
320
+ creation before the next begins (the round-trip latency of each tool call provides
321
+ natural spacing), while all agents still **run in parallel** once created.
322
+
323
+ ```
324
+ # CORRECT: dispatch one task() per message, each with run_in_background: true
325
+ # → worktrees created sequentially, agents execute in parallel
326
+ #
327
+ # WRONG: multiple task() calls in a single message
328
+ # → simultaneous git worktree add → .git/config.lock contention → failures
110
329
  ```
111
- task(
112
- subagent_type="gsd-executor",
113
- model="{executor_model}",
114
- prompt="
115
- <objective>
116
- Execute plan {plan_number} of phase {phase_number}-{phase_name}.
117
- Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
118
- </objective>
119
-
120
- <execution_context>
121
- @$HOME/.config/opencode/get-shit-done/workflows/execute-plan.md
122
- @$HOME/.config/opencode/get-shit-done/templates/summary.md
123
- @$HOME/.config/opencode/get-shit-done/references/checkpoints.md
124
- @$HOME/.config/opencode/get-shit-done/references/tdd.md
125
- </execution_context>
126
-
127
- <files_to_read>
128
- read these files at execution start using the read tool:
129
- - {phase_dir}/{plan_file} (Plan)
130
- - .planning/STATE.md (State)
131
- - .planning/config.json (Config, if exists)
132
- - ./AGENTS.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
133
- - .OpenCode/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
134
- </files_to_read>
135
330
 
331
+ ```
332
+ @gsd-executor "
333
+ <objective>
334
+ Execute plan {plan_number} of phase {phase_number}-{phase_name}.
335
+ Commit each task atomically. Create SUMMARY.md.
336
+ Do NOT update STATE.md or ROADMAP.md — the orchestrator owns those writes after all worktree agents in the wave complete.
337
+ </objective>
338
+
339
+ <worktree_branch_check>
340
+ FIRST ACTION before any other work: verify this worktree's branch is based on the correct commit.
341
+
342
+ Run:
343
+ ```bash
344
+ ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
345
+ CURRENT_HEAD=$(git rev-parse HEAD)
346
+ ```
347
+
348
+ If `ACTUAL_BASE` != `{EXPECTED_BASE}` (i.e. the worktree branch was created from an older
349
+ base such as `main` instead of the feature branch HEAD), rebase onto the correct base:
350
+ ```bash
351
+ git rebase --onto {EXPECTED_BASE} $(git rev-parse --abbrev-ref HEAD~1 2>/dev/null || git rev-parse HEAD^) HEAD 2>/dev/null || true
352
+ # If rebase fails or is a no-op, reset the branch to start from the correct base:
353
+ git reset --soft {EXPECTED_BASE}
354
+ ```
355
+
356
+ If `ACTUAL_BASE` == `{EXPECTED_BASE}`: the branch base is correct, proceed immediately.
357
+
358
+ This check fixes a known issue on Windows where `EnterWorktree` creates branches from
359
+ `main` instead of the current feature branch HEAD.
360
+ </worktree_branch_check>
361
+
362
+ <parallel_execution>
363
+ You are running as a PARALLEL executor agent. Use --no-verify on all git
364
+ commits to avoid pre-commit hook contention with other agents. The
365
+ orchestrator validates hooks once after all agents complete.
366
+ For gsd-tools commits: add --no-verify flag.
367
+ For direct git commits: use git commit --no-verify -m "..."
368
+ </parallel_execution>
369
+
370
+ <execution_context>
371
+ @$HOME/.config/opencode/get-shit-done/workflows/execute-plan.md
372
+ @$HOME/.config/opencode/get-shit-done/templates/summary.md
373
+ @$HOME/.config/opencode/get-shit-done/references/checkpoints.md
374
+ @$HOME/.config/opencode/get-shit-done/references/tdd.md
375
+ </execution_context>
376
+
377
+ <files_to_read>
378
+ read these files at execution start using the read tool:
379
+ - {phase_dir}/{plan_file} (Plan)
380
+ - .planning/PROJECT.md (Project context — core value, requirements, evolution rules)
381
+ - .planning/STATE.md (State)
382
+ - .planning/config.json (Config, if exists)
383
+ ${CONTEXT_WINDOW >= 500000 ? `
384
+ - ${phase_dir}/*-CONTEXT.md (User decisions from discuss-phase — honors locked choices)
385
+ - ${phase_dir}/*-RESEARCH.md (Technical research — pitfalls and patterns to follow)
386
+ - ${prior_wave_summaries} (SUMMARY.md files from earlier waves in this phase — what was already built)
387
+ ` : ''}
388
+ - ./AGENTS.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
389
+ - .OpenCode/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
390
+ </files_to_read>
391
+
392
+ ${AGENT_SKILLS}
393
+
394
+ <mcp_tools>
395
+ If AGENTS.md or project instructions reference MCP tools (e.g. jCodeMunch, context7,
396
+ or other MCP servers), prefer those tools over grep/glob for code navigation when available.
397
+ MCP tools often save significant tokens by providing structured code indexes.
398
+ Check tool availability first — if MCP tools are not accessible, fall back to grep/glob.
399
+ </mcp_tools>
400
+
401
+ <success_criteria>
402
+ - [ ] All tasks executed
403
+ - [ ] Each task committed individually
404
+ - [ ] SUMMARY.md created in plan directory
405
+ </success_criteria>
406
+ "
407
+ ```
408
+
409
+ **Sequential mode** (`USE_WORKTREES` is `false`):
410
+
411
+ Omit `isolation="worktree"` from the task call. Replace the `<parallel_execution>` block with:
412
+
413
+ ```
414
+ <sequential_execution>
415
+ You are running as a SEQUENTIAL executor agent on the main working tree.
416
+ Use normal git commits (with hooks). Do NOT use --no-verify.
417
+ </sequential_execution>
418
+ ```
419
+
420
+ The sequential mode task prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
421
+
422
+ ```
136
423
  <success_criteria>
137
424
  - [ ] All tasks executed
138
425
  - [ ] Each task committed individually
@@ -140,13 +427,94 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
140
427
  - [ ] STATE.md updated with position and decisions
141
428
  - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
142
429
  </success_criteria>
143
- "
144
- )
145
430
  ```
146
431
 
147
- 3. **Wait for all agents in wave to complete.**
432
+ When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting — multiple agents writing to the same working tree concurrently would cause conflicts.
433
+
434
+ 4. **Wait for all agents in wave to complete.**
435
+
436
+ **Completion signal fallback (Copilot and runtimes where task() may not return):**
437
+
438
+ If a spawned agent does not return a completion signal but appears to have finished
439
+ its work, do NOT block indefinitely. Instead, verify completion via spot-checks:
440
+
441
+ ```bash
442
+ # For each plan in this wave, check if the executor finished:
443
+ SUMMARY_EXISTS=$(test -f "{phase_dir}/{plan_number}-{plan_padded}-SUMMARY.md" && echo "true" || echo "false")
444
+ COMMITS_FOUND=$(git log --oneline --all --grep="{phase_number}-{plan_padded}" --since="1 hour ago" | head -1)
445
+ ```
446
+
447
+ **If SUMMARY.md exists AND commits are found:** The agent completed successfully —
448
+ treat as done and proceed to step 5. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
449
+
450
+ **If SUMMARY.md does NOT exist after a reasonable wait:** The agent may still be
451
+ running or may have failed silently. Check `git log --oneline -5` for recent
452
+ activity. If commits are still appearing, wait longer. If no activity, report
453
+ the plan as failed and route to the failure handler in step 6.
454
+
455
+ **This fallback applies automatically to all runtimes.** OpenCode's task() normally
456
+ returns synchronously, but the fallback ensures resilience if it doesn't.
457
+
458
+ 5. **Post-wave hook validation (parallel mode only):**
459
+
460
+ When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
461
+ ```bash
462
+ # Run project's pre-commit hooks on the current state
463
+ git diff --cached --quiet || git stash # stash any unstaged changes
464
+ git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed — review before continuing"
465
+ ```
466
+ If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
467
+
468
+ 5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
469
+
470
+ When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
471
+
472
+ ```bash
473
+ # List worktrees created by this wave's agents
474
+ WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
475
+
476
+ for WT in $WORKTREES; do
477
+ # Get the branch name for this worktree
478
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
479
+ if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
480
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
481
+
482
+ # Merge the worktree branch into the current branch
483
+ git merge "$WT_BRANCH" --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
484
+ echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
485
+ continue
486
+ }
487
+
488
+ # Remove the worktree
489
+ git worktree remove "$WT" --force 2>/dev/null || true
490
+
491
+ # Delete the temporary branch
492
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
493
+ fi
494
+ done
495
+ ```
496
+
497
+ **If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
148
498
 
149
- 4. **Report completionspot-check claims first:**
499
+ **If no worktrees found:** Skip silently agents may have been spawned without worktree isolation.
500
+
501
+ 5.6. **Post-wave shared artifact update (worktree mode only):**
502
+
503
+ When executor agents ran with `isolation="worktree"`, they skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once:
504
+
505
+ ```bash
506
+ # Update ROADMAP.md for each completed plan in this wave
507
+ for PLAN_ID in ${WAVE_PLAN_IDS}; do
508
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap update-plan-progress "${PHASE_NUMBER}" "${PLAN_ID}" completed
509
+ done
510
+
511
+ ```
512
+
513
+ Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
514
+
515
+ **If `workflow.use_worktrees` is `false`:** Sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
516
+
517
+ 6. **Report completion — spot-check claims first:**
150
518
 
151
519
  For each SUMMARY.md:
152
520
  - Verify first 2 files from `key-files.created` exist on disk
@@ -171,15 +539,36 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
171
539
  - Bad: "Wave 2 complete. Proceeding to Wave 3."
172
540
  - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
173
541
 
174
- 5. **Handle failures:**
542
+ 7. **Handle failures:**
175
543
 
176
- **Known OpenCode bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a OpenCode runtime bug — not a GSD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 4 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
544
+ **Known OpenCode bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a OpenCode runtime bug — not a GSD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 5 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
177
545
 
178
546
  For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
179
547
 
180
- 6. **Execute checkpoint plans between waves** see `<checkpoint_handling>`.
548
+ 7b. **Pre-wave dependency check (waves 2+ only):**
549
+
550
+ Before spawning wave N+1, for each plan in the upcoming wave:
551
+ ```bash
552
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" verify key-links {phase_dir}/{plan}-PLAN.md
553
+ ```
554
+
555
+ If any key-link from a PRIOR wave's artifact fails verification:
181
556
 
182
- 7. **Proceed to next wave.**
557
+ ## Cross-Plan Wiring Gap
558
+
559
+ | Plan | Link | From | Expected Pattern | Status |
560
+ |------|------|------|-----------------|--------|
561
+ | {plan} | {via} | {from} | {pattern} | NOT FOUND |
562
+
563
+ Wave {N} artifacts may not be properly wired. Options:
564
+ 1. Investigate and fix before continuing
565
+ 2. Continue (may cause cascading failures in wave {N+1})
566
+
567
+ Key-links referencing files in the CURRENT (upcoming) wave are skipped.
568
+
569
+ 8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
570
+
571
+ 9. **Proceed to next wave.**
183
572
  </step>
184
573
 
185
574
  <step name="checkpoint_handling">
@@ -248,6 +637,58 @@ After all waves:
248
637
  ### Issues Encountered
249
638
  [Aggregate from SUMMARYs, or "None"]
250
639
  ```
640
+
641
+ **Security gate check:**
642
+ ```bash
643
+ SECURITY_CFG=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
644
+ SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
645
+ ```
646
+
647
+ If `SECURITY_CFG` is `false`: skip.
648
+
649
+ If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
650
+ Include in the next-steps routing output:
651
+ ```
652
+ ⚠ Security enforcement enabled — run before advancing:
653
+ /gsd-secure-phase {PHASE} ${GSD_WS}
654
+ ```
655
+
656
+ If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
657
+ ```
658
+ ⚠ Security gate: {threats_open} threats open
659
+ /gsd-secure-phase {PHASE} — resolve before advancing
660
+ ```
661
+ </step>
662
+
663
+ <step name="handle_partial_wave_execution">
664
+ If `WAVE_FILTER` was used, re-run plan discovery after execution:
665
+
666
+ ```bash
667
+ POST_PLAN_INDEX=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
668
+ ```
669
+
670
+ Apply the same "incomplete" filtering rules as earlier:
671
+ - ignore plans with `has_summary: true`
672
+ - if `--gaps-only`, only consider `gap_closure: true` plans
673
+
674
+ **If incomplete plans still remain anywhere in the phase:**
675
+ - STOP here
676
+ - Do NOT run phase verification
677
+ - Do NOT mark the phase complete in ROADMAP/STATE
678
+ - Present:
679
+
680
+ ```markdown
681
+ ## Wave {WAVE_FILTER} Complete
682
+
683
+ Selected wave finished successfully. This phase still has incomplete plans, so phase-level verification and completion were intentionally skipped.
684
+
685
+ /gsd-execute-phase {phase} ${GSD_WS} # Continue remaining waves
686
+ /gsd-execute-phase {phase} --wave {next} ${GSD_WS} # Run the next wave explicitly
687
+ ```
688
+
689
+ **If no incomplete plans remain after the selected wave finishes:**
690
+ - continue with the normal phase-level verification and completion flow below
691
+ - this means the selected wave happened to be the last remaining work in the phase
251
692
  </step>
252
693
 
253
694
  <step name="close_parent_artifacts">
@@ -300,21 +741,161 @@ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(phase
300
741
  ```
301
742
  </step>
302
743
 
744
+ <step name="regression_gate">
745
+ Run prior phases' test suites to catch cross-phase regressions BEFORE verification.
746
+
747
+ **Skip if:** This is the first phase (no prior phases), or no prior VERIFICATION.md files exist.
748
+
749
+ **Step 1: Discover prior phases' test files**
750
+ ```bash
751
+ # Find all VERIFICATION.md files from prior phases in current milestone
752
+ PRIOR_VERIFICATIONS=$(find .planning/phases/ -name "*-VERIFICATION.md" ! -path "*${PHASE_NUMBER}*" 2>/dev/null)
753
+ ```
754
+
755
+ **Step 2: Extract test file lists from prior verifications**
756
+
757
+ For each VERIFICATION.md found, look for test file references:
758
+ - Lines containing `test`, `spec`, or `__tests__` paths
759
+ - The "Test Suite" or "Automated Checks" section
760
+ - File patterns from `key-files.created` in corresponding SUMMARY.md files that match `*.test.*` or `*.spec.*`
761
+
762
+ Collect all unique test file paths into `REGRESSION_FILES`.
763
+
764
+ **Step 3: Run regression tests (if any found)**
765
+
766
+ ```bash
767
+ # Detect test runner and run prior phase tests
768
+ if [ -f "package.json" ]; then
769
+ # Node.js — use project's test runner
770
+ npx jest ${REGRESSION_FILES} --passWithNoTests --no-coverage -q 2>&1 || npx vitest run ${REGRESSION_FILES} 2>&1
771
+ elif [ -f "Cargo.toml" ]; then
772
+ cargo test 2>&1
773
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
774
+ python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
775
+ fi
776
+ ```
777
+
778
+ **Step 4: Report results**
779
+
780
+ If all tests pass:
781
+ ```
782
+ ✓ Regression gate: {N} prior-phase test files passed — no regressions detected
783
+ ```
784
+ → Proceed to verify_phase_goal
785
+
786
+ If any tests fail:
787
+ ```
788
+ ## ⚠ Cross-Phase Regression Detected
789
+
790
+ Phase {X} execution may have broken functionality from prior phases.
791
+
792
+ | Test File | Phase | Status | Detail |
793
+ |-----------|-------|--------|--------|
794
+ | {file} | {origin_phase} | FAILED | {first_failure_line} |
795
+
796
+ Options:
797
+ 1. Fix regressions before verification (recommended)
798
+ 2. Continue to verification anyway (regressions will compound)
799
+ 3. Abort phase — roll back and re-plan
800
+ ```
801
+
802
+ Use question to present the options.
803
+ </step>
804
+
805
+ <step name="schema_drift_gate">
806
+ Post-execution schema drift detection. Catches false-positive verification where
807
+ build/types pass because TypeScript types come from config, not the live database.
808
+
809
+ **Run after execution completes but BEFORE verification marks success.**
810
+
811
+ ```bash
812
+ SCHEMA_DRIFT=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
813
+ ```
814
+
815
+ Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
816
+
817
+ **If `drift_detected` is false:** Skip to verify_phase_goal.
818
+
819
+ **If `drift_detected` is true AND `blocking` is true:**
820
+
821
+ Check for override:
822
+ ```bash
823
+ SKIP_SCHEMA=$(echo "${GSD_SKIP_SCHEMA_CHECK:-false}")
824
+ ```
825
+
826
+ **If `SKIP_SCHEMA` is `true`:**
827
+
828
+ Display:
829
+ ```
830
+ ⚠ Schema drift detected but GSD_SKIP_SCHEMA_CHECK=true — bypassing gate.
831
+
832
+ Schema files changed: {schema_files}
833
+ ORMs requiring push: {unpushed_orms}
834
+
835
+ Proceeding to verification (database may be out of sync).
836
+ ```
837
+ → Continue to verify_phase_goal.
838
+
839
+ **If `SKIP_SCHEMA` is not `true`:**
840
+
841
+ BLOCK verification. Display:
842
+
843
+ ```
844
+ ## BLOCKED: Schema Drift Detected
845
+
846
+ Schema-relevant files changed during this phase but no database push command
847
+ was executed. Build and type checks pass because TypeScript types come from
848
+ config, not the live database — verification would produce a false positive.
849
+
850
+ Schema files changed: {schema_files}
851
+ ORMs requiring push: {unpushed_orms}
852
+
853
+ Required push commands:
854
+ {For each unpushed ORM, show the push command from the message}
855
+
856
+ Options:
857
+ 1. Run push command now (recommended) — execute the push, then re-verify
858
+ 2. Skip schema check (GSD_SKIP_SCHEMA_CHECK=true) — bypass this gate
859
+ 3. Abort — stop execution and investigate
860
+ ```
861
+
862
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use question.
863
+
864
+ **If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
865
+
866
+ **If user selects option 2:** Set override and continue to verify_phase_goal.
867
+
868
+ **If user selects option 3:** Stop execution. Report partial completion.
869
+ </step>
870
+
303
871
  <step name="verify_phase_goal">
304
872
  Verify phase achieved its GOAL, not just completed tasks.
305
873
 
874
+ ```bash
875
+ VERIFIER_SKILLS=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-verifier 2>/dev/null)
876
+ ```
877
+
306
878
  ```
307
- task(
308
- prompt="Verify phase {phase_number} goal achievement.
879
+ @gsd-verifier "Verify phase {phase_number} goal achievement.
309
880
  Phase directory: {phase_dir}
310
881
  Phase goal: {goal from ROADMAP.md}
311
882
  Phase requirement IDs: {phase_req_ids}
312
883
  Check must_haves against actual codebase.
313
884
  Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
314
- Create VERIFICATION.md.",
315
- subagent_type="gsd-verifier",
316
- model="{verifier_model}"
317
- )
885
+ Create VERIFICATION.md.
886
+
887
+ <files_to_read>
888
+ read these files before verification:
889
+ - {phase_dir}/*-PLAN.md (All plans — understand intent, check must_haves)
890
+ - {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
891
+ - .planning/REQUIREMENTS.md (Requirement traceability)
892
+ ${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
893
+ - {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
894
+ - Prior VERIFICATION.md files from earlier phases (regression check)
895
+ ` : ''}
896
+ </files_to_read>
897
+
898
+ ${VERIFIER_SKILLS}"
318
899
  ```
319
900
 
320
901
  read status:
@@ -326,9 +907,54 @@ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
326
907
  |--------|--------|
327
908
  | `passed` | → update_roadmap |
328
909
  | `human_needed` | Present items for human testing, get approval or feedback |
329
- | `gaps_found` | Present gap summary, offer `/gsd-plan-phase {phase} --gaps` |
910
+ | `gaps_found` | Present gap summary, offer `/gsd-plan-phase {phase} --gaps ${GSD_WS}` |
330
911
 
331
912
  **If human_needed:**
913
+
914
+ **Step A: Persist human verification items as UAT file.**
915
+
916
+ Create `{phase_dir}/{phase_num}-HUMAN-UAT.md` using UAT template format:
917
+
918
+ ```markdown
919
+ ---
920
+ status: partial
921
+ phase: {phase_num}-{phase_name}
922
+ source: [{phase_num}-VERIFICATION.md]
923
+ started: [now ISO]
924
+ updated: [now ISO]
925
+ ---
926
+
927
+ ## Current Test
928
+
929
+ [awaiting human testing]
930
+
931
+ ## Tests
932
+
933
+ {For each human_verification item from VERIFICATION.md:}
934
+
935
+ ### {N}. {item description}
936
+ expected: {expected behavior from VERIFICATION.md}
937
+ result: [pending]
938
+
939
+ ## Summary
940
+
941
+ total: {count}
942
+ passed: 0
943
+ issues: 0
944
+ pending: {count}
945
+ skipped: 0
946
+ blocked: 0
947
+
948
+ ## Gaps
949
+ ```
950
+
951
+ Commit the file:
952
+ ```bash
953
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
954
+ ```
955
+
956
+ **Step B: Present to user:**
957
+
332
958
  ```
333
959
  ## ✓ Phase {X}: {Name} — Human Verification Required
334
960
 
@@ -336,9 +962,15 @@ All automated checks passed. {N} items need human testing:
336
962
 
337
963
  {From VERIFICATION.md human_verification section}
338
964
 
965
+ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/gsd-progress` and `/gsd-audit-uat`.
966
+
339
967
  "approved" → continue | Report issues → gap closure
340
968
  ```
341
969
 
970
+ **If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/gsd-verify-work` on it.
971
+
972
+ **If user reports issues:** Proceed to gap closure as currently implemented.
973
+
342
974
  **If gaps_found:**
343
975
  ```
344
976
  ## ⚠ Phase {X}: {Name} — Gaps Found
@@ -352,15 +984,15 @@ All automated checks passed. {N} items need human testing:
352
984
  ---
353
985
  ## ▶ Next Up
354
986
 
355
- `/gsd-plan-phase {X} --gaps`
987
+ `/new` then:
356
988
 
357
- *`/new` first fresh context window*
989
+ `/gsd-plan-phase {X} --gaps ${GSD_WS}`
358
990
 
359
991
  Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
360
- Also: `/gsd-verify-work {X}` — manual testing first
992
+ Also: `/gsd-verify-work {X} ${GSD_WS}` — manual testing first
361
993
  ```
362
994
 
363
- Gap closure cycle: `/gsd-plan-phase {X} --gaps` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/gsd-execute-phase {X} --gaps-only` → verifier re-runs.
995
+ Gap closure cycle: `/gsd-plan-phase {X} --gaps ${GSD_WS}` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/gsd-execute-phase {X} --gaps-only ${GSD_WS}` → verifier re-runs.
364
996
  </step>
365
997
 
366
998
  <step name="update_roadmap">
@@ -376,14 +1008,46 @@ The CLI handles:
376
1008
  - Updating plan count to final
377
1009
  - Advancing STATE.md to next phase
378
1010
  - Updating REQUIREMENTS.md traceability
1011
+ - Scanning for verification debt (returns `warnings` array)
1012
+
1013
+ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`, `warnings`, `has_warnings`.
1014
+
1015
+ **If has_warnings is true:**
1016
+ ```
1017
+ ## Phase {X} marked complete with {N} warnings:
379
1018
 
380
- Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`.
1019
+ {list each warning}
1020
+
1021
+ These items are tracked and will appear in `/gsd-progress` and `/gsd-audit-uat`.
1022
+ ```
381
1023
 
382
1024
  ```bash
383
1025
  node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
384
1026
  ```
385
1027
  </step>
386
1028
 
1029
+ <step name="update_project_md">
1030
+ **Evolve PROJECT.md to reflect phase completion (prevents planning document drift — #956):**
1031
+
1032
+ PROJECT.md tracks validated requirements, decisions, and current state. Without this step,
1033
+ PROJECT.md falls behind silently over multiple phases.
1034
+
1035
+ 1. read `.planning/PROJECT.md`
1036
+ 2. If the file exists and has a `## Validated Requirements` or `## Requirements` section:
1037
+ - Move any requirements validated by this phase from Active → Validated
1038
+ - Add a brief note: `Validated in Phase {X}: {Name}`
1039
+ 3. If the file has a `## Current State` or similar section:
1040
+ - Update it to reflect this phase's completion (e.g., "Phase {X} complete — {one-liner}")
1041
+ 4. Update the `Last updated:` footer to today's date
1042
+ 5. Commit the change:
1043
+
1044
+ ```bash
1045
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(phase-{X}): evolve PROJECT.md after phase completion" --files .planning/PROJECT.md
1046
+ ```
1047
+
1048
+ **Skip this step if** `.planning/PROJECT.md` does not exist.
1049
+ </step>
1050
+
387
1051
  <step name="offer_next">
388
1052
 
389
1053
  **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/gsd-plan-phase {X} --gaps`). No additional routing needed — skip auto-advance.
@@ -433,15 +1097,34 @@ Execute the transition workflow inline (do NOT use task — orchestrator context
433
1097
 
434
1098
  read and follow `$HOME/.config/opencode/get-shit-done/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
435
1099
 
436
- **If neither `--auto` nor `AUTO_CFG` is true:**
1100
+ **If none of `--auto`, `AUTO_CHAIN`, or `AUTO_CFG` is true:**
437
1101
 
438
- The workflow ends. The user runs `/gsd-progress` or invokes the transition workflow manually.
1102
+ **STOP. Do not auto-advance. Do not execute transition. Do not plan next phase. Present options to the user and wait.**
1103
+
1104
+ **IMPORTANT: There is NO `/gsd-transition` command. Never suggest it. The transition workflow is internal only.**
1105
+
1106
+ ```
1107
+ ## ✓ Phase {X}: {Name} Complete
1108
+
1109
+ /gsd-progress ${GSD_WS} — see updated roadmap
1110
+ /gsd-discuss-phase {next} ${GSD_WS} — discuss next phase before planning
1111
+ /gsd-plan-phase {next} ${GSD_WS} — plan next phase
1112
+ /gsd-execute-phase {next} ${GSD_WS} — execute next phase
1113
+ ```
1114
+
1115
+ Only suggest the commands listed above. Do not invent or hallucinate command names.
439
1116
  </step>
440
1117
 
441
1118
  </process>
442
1119
 
443
1120
  <context_efficiency>
444
- Orchestrator: ~10-15% context. Subagents: fresh 200k each. No polling (task blocks). No context bleed.
1121
+ Orchestrator: ~10-15% context for 200k windows, can use more for 1M+ windows.
1122
+ Subagents: fresh context each (200k-1M depending on model). No polling (task blocks). No context bleed.
1123
+
1124
+ For 1M+ context models, consider:
1125
+ - Passing richer context (code snippets, dependency outputs) directly to executors instead of just file paths
1126
+ - Running small phases (≤3 plans, no dependencies) inline without subagent spawning overhead
1127
+ - Relaxing /new recommendations — context rot onset is much further out with 5x window
445
1128
  </context_efficiency>
446
1129
 
447
1130
  <failure_handling>