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
@@ -0,0 +1,1036 @@
1
+ <objective>
2
+
3
+ Drive milestone phases autonomously — all remaining phases, a range via `--from N`/`--to N`, or a single phase via `--only N`. For each incomplete phase: discuss → plan → execute using skill() flat invocations. Pauses only for explicit user decisions (grey area acceptance, blockers, validation requests). Re-reads ROADMAP.md after each phase to catch dynamically inserted phases.
4
+
5
+ </objective>
6
+
7
+ <required_reading>
8
+
9
+ read all files referenced by the invoking prompt's execution_context before starting.
10
+
11
+ </required_reading>
12
+
13
+ <process>
14
+
15
+ <step name="initialize" priority="first">
16
+
17
+ ## 1. Initialize
18
+
19
+ Parse `$ARGUMENTS` for `--from N`, `--to N`, `--only N`, and `--interactive` flags:
20
+
21
+ ```bash
22
+ FROM_PHASE=""
23
+ if echo "$ARGUMENTS" | grep -qE '\-\-from\s+[0-9]'; then
24
+ FROM_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-from\s+[0-9]+\.?[0-9]*' | awk '{print $2}')
25
+ fi
26
+
27
+ TO_PHASE=""
28
+ if echo "$ARGUMENTS" | grep -qE '\-\-to\s+[0-9]'; then
29
+ TO_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-to\s+[0-9]+\.?[0-9]*' | awk '{print $2}')
30
+ fi
31
+
32
+ ONLY_PHASE=""
33
+ if echo "$ARGUMENTS" | grep -qE '\-\-only\s+[0-9]'; then
34
+ ONLY_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-only\s+[0-9]+\.?[0-9]*' | awk '{print $2}')
35
+ FROM_PHASE="$ONLY_PHASE"
36
+ fi
37
+
38
+ INTERACTIVE=""
39
+ if echo "$ARGUMENTS" | grep -q '\-\-interactive'; then
40
+ INTERACTIVE="true"
41
+ fi
42
+ ```
43
+
44
+ When `--only` is set, also set `FROM_PHASE` to the same value so existing filter logic applies.
45
+
46
+ When `--interactive` is set, discuss runs inline with questions (not auto-answered), while plan and execute are dispatched as background agents. This keeps the main context lean — only discuss conversations accumulate — while preserving user input on all design decisions.
47
+
48
+ Bootstrap via milestone-level init:
49
+
50
+ ```bash
51
+ INIT=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init milestone-op)
52
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
53
+ ```
54
+
55
+ Parse JSON for: `milestone_version`, `milestone_name`, `phase_count`, `completed_phases`, `roadmap_exists`, `state_exists`, `commit_docs`.
56
+
57
+ **If `roadmap_exists` is false:** Error — "No ROADMAP.md found. Run `/gsd-new-milestone` first."
58
+ **If `state_exists` is false:** Error — "No STATE.md found. Run `/gsd-new-milestone` first."
59
+
60
+ Display startup banner:
61
+
62
+ ```
63
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64
+ GSD ► AUTONOMOUS
65
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
66
+
67
+ Milestone: {milestone_version} — {milestone_name}
68
+ Phases: {phase_count} total, {completed_phases} complete
69
+ ```
70
+
71
+ If `ONLY_PHASE` is set, display: `Single phase mode: Phase ${ONLY_PHASE}`
72
+ Else if `FROM_PHASE` is set, display: `Starting from phase ${FROM_PHASE}`
73
+ If `TO_PHASE` is set, display: `Stopping after phase ${TO_PHASE}`
74
+ If `INTERACTIVE` is set, display: `Mode: Interactive (discuss inline, plan+execute in background)`
75
+
76
+ </step>
77
+
78
+ <step name="discover_phases">
79
+
80
+ ## 2. Discover Phases
81
+
82
+ Run phase discovery:
83
+
84
+ ```bash
85
+ ROADMAP=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap analyze)
86
+ ```
87
+
88
+ Parse the JSON `phases` array.
89
+
90
+ **Filter to incomplete phases:** Keep only phases where `disk_status !== "complete"` OR `roadmap_complete === false`.
91
+
92
+ **Apply `--from N` filter:** If `FROM_PHASE` was provided, additionally filter out phases where `number < FROM_PHASE` (use numeric comparison — handles decimal phases like "5.1").
93
+
94
+ **Apply `--to N` filter:** If `TO_PHASE` was provided, additionally filter out phases where `number > TO_PHASE` (use numeric comparison). This limits execution to phases up through the target phase.
95
+
96
+ **Apply `--only N` filter:** If `ONLY_PHASE` was provided, additionally filter OUT phases where `number != ONLY_PHASE`. This means the phase list will contain exactly one phase (or zero if already complete).
97
+
98
+ **If `TO_PHASE` is set and no phases remain** (all phases up to N are already completed):
99
+
100
+ ```
101
+ All phases through ${TO_PHASE} are already completed. Nothing to do.
102
+ ```
103
+
104
+ Exit cleanly.
105
+
106
+ **If `ONLY_PHASE` is set and no phases remain** (phase already complete):
107
+
108
+ ```
109
+ Phase ${ONLY_PHASE} is already complete. Nothing to do.
110
+ ```
111
+
112
+ Exit cleanly.
113
+
114
+ **Sort by `number`** in numeric ascending order.
115
+
116
+ **If no incomplete phases remain:**
117
+
118
+ ```
119
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
120
+ GSD ► AUTONOMOUS ▸ COMPLETE 🎉
121
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
122
+
123
+ All phases complete! Nothing left to do.
124
+ ```
125
+
126
+ Exit cleanly.
127
+
128
+ **Display phase plan:**
129
+
130
+ ```
131
+ ## Phase Plan
132
+
133
+ | # | Phase | Status |
134
+ |---|-------|--------|
135
+ | 5 | skill Scaffolding & Phase Discovery | In Progress |
136
+ | 6 | Smart Discuss | Not Started |
137
+ | 7 | Auto-Chain Refinements | Not Started |
138
+ | 8 | Lifecycle Orchestration | Not Started |
139
+ ```
140
+
141
+ **Fetch details for each phase:**
142
+
143
+ ```bash
144
+ DETAIL=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap get-phase ${PHASE_NUM})
145
+ ```
146
+
147
+ Extract `phase_name`, `goal`, `success_criteria` from each. Store for use in execute_phase and transition messages.
148
+
149
+ </step>
150
+
151
+ <step name="execute_phase">
152
+
153
+ ## 3. Execute Phase
154
+
155
+ For the current phase, display the progress banner:
156
+
157
+ ```
158
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
159
+ GSD ► AUTONOMOUS ▸ Phase {N}/{T}: {Name} [████░░░░] {P}%
160
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
161
+ ```
162
+
163
+ Where N = current phase number (from the ROADMAP, e.g., 63), T = total milestone phases (from `phase_count` parsed in initialize step, e.g., 67). **Important:** T must be `phase_count` (the total number of phases in this milestone), NOT the count of remaining/incomplete phases. When phases are numbered 61-67, T=7 and the banner should read `Phase 63/7` (phase 63, 7 total in milestone), not `Phase 63/3` (which would confuse 3 remaining with 3 total). P = percentage of all milestone phases completed so far. Calculate P as: (number of phases with `disk_status` "complete" from the latest `roadmap analyze` / T × 100). Use █ for filled and ░ for empty segments in the progress bar (8 characters wide).
164
+
165
+ **Alternative display when phase numbers exceed total** (e.g., multi-milestone projects where phases are numbered globally): If N > T (phase number exceeds milestone phase count), use the format `Phase {N} ({position}/{T})` where `position` is the 1-based index of this phase among incomplete phases being processed. This prevents confusing displays like "Phase 63/5".
166
+
167
+ **3a. Smart Discuss**
168
+
169
+ Check if CONTEXT.md already exists for this phase:
170
+
171
+ ```bash
172
+ PHASE_STATE=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init phase-op ${PHASE_NUM})
173
+ ```
174
+
175
+ Parse `has_context` from JSON.
176
+
177
+ **If has_context is true:** Skip discuss — context already gathered. Display:
178
+
179
+ ```
180
+ Phase ${PHASE_NUM}: Context exists — skipping discuss.
181
+ ```
182
+
183
+ Proceed to 3b.
184
+
185
+ **If has_context is false:** Check if discuss is disabled via settings:
186
+
187
+ ```bash
188
+ SKIP_DISCUSS=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.skip_discuss 2>/dev/null || echo "false")
189
+ ```
190
+
191
+ **If SKIP_DISCUSS is `true`:** Skip discuss entirely — the ROADMAP phase description is the spec. Display:
192
+
193
+ ```
194
+ Phase ${PHASE_NUM}: Discuss skipped (workflow.skip_discuss=true) — using ROADMAP phase goal as spec.
195
+ ```
196
+
197
+ write a minimal CONTEXT.md so downstream plan-phase has valid input. Get phase details:
198
+
199
+ ```bash
200
+ DETAIL=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap get-phase ${PHASE_NUM})
201
+ ```
202
+
203
+ Extract `goal` and `requirements` from JSON. write `${phase_dir}/${padded_phase}-CONTEXT.md` with:
204
+
205
+ ```markdown
206
+ # Phase {PHASE_NUM}: {Phase Name} - Context
207
+
208
+ **Gathered:** {date}
209
+ **Status:** Ready for planning
210
+ **Mode:** Auto-generated (discuss skipped via workflow.skip_discuss)
211
+
212
+ <domain>
213
+ ## Phase Boundary
214
+
215
+ {goal from ROADMAP phase description}
216
+
217
+ </domain>
218
+
219
+ <decisions>
220
+ ## Implementation Decisions
221
+
222
+ ### OpenCode's Discretion
223
+ All implementation choices are at OpenCode's discretion — discuss phase was skipped per user setting. Use ROADMAP phase goal, success criteria, and codebase conventions to guide decisions.
224
+
225
+ </decisions>
226
+
227
+ <code_context>
228
+ ## Existing Code Insights
229
+
230
+ Codebase context will be gathered during plan-phase research.
231
+
232
+ </code_context>
233
+
234
+ <specifics>
235
+ ## Specific Ideas
236
+
237
+ No specific requirements — discuss phase skipped. Refer to ROADMAP phase description and success criteria.
238
+
239
+ </specifics>
240
+
241
+ <deferred>
242
+ ## Deferred Ideas
243
+
244
+ None — discuss phase skipped.
245
+
246
+ </deferred>
247
+ ```
248
+
249
+ Commit the minimal context:
250
+
251
+ ```bash
252
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(${PADDED_PHASE}): auto-generated context (discuss skipped)" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
253
+ ```
254
+
255
+ Proceed to 3b.
256
+
257
+ **If SKIP_DISCUSS is `false` (or unset):**
258
+
259
+ **IMPORTANT — Discuss must be single-pass in autonomous mode.**
260
+ The discuss step in `--auto` mode MUST NOT loop. If CONTEXT.md already exists after discuss completes, do NOT re-invoke discuss for the same phase. The `has_context` check below is authoritative — once true, discuss is done for this phase regardless of perceived "gaps" in the context file.
261
+
262
+ **If `INTERACTIVE` is set:** Run the standard discuss-phase skill inline (asks interactive questions, waits for user answers). This preserves user input on all design decisions while keeping plan+execute out of the main context:
263
+
264
+ ```
265
+ skill(skill="gsd-discuss-phase", args="${PHASE_NUM}")
266
+ ```
267
+
268
+ **If `INTERACTIVE` is NOT set:** Execute the smart_discuss step for this phase (batch table proposals, auto-optimized).
269
+
270
+ After discuss completes (either mode), verify context was written:
271
+
272
+ ```bash
273
+ PHASE_STATE=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init phase-op ${PHASE_NUM})
274
+ ```
275
+
276
+ Check `has_context`. If false → go to handle_blocker: "Discuss for phase ${PHASE_NUM} did not produce CONTEXT.md."
277
+
278
+ **3a.5. UI Design Contract (Frontend Phases)**
279
+
280
+ Check if this phase has frontend indicators and whether a UI-SPEC already exists:
281
+
282
+ ```bash
283
+ PHASE_SECTION=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap get-phase ${PHASE_NUM} 2>/dev/null)
284
+ echo "$PHASE_SECTION" | grep -iE "UI|interface|frontend|component|layout|page|screen|view|form|dashboard|widget" > /dev/null 2>&1
285
+ HAS_UI=$?
286
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
287
+ ```
288
+
289
+ Check if UI phase workflow is enabled:
290
+
291
+ ```bash
292
+ UI_PHASE_CFG=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.ui_phase 2>/dev/null || echo "true")
293
+ ```
294
+
295
+ **If `HAS_UI` is 0 (frontend indicators found) AND `UI_SPEC_FILE` is empty (no UI-SPEC exists) AND `UI_PHASE_CFG` is not `false`:**
296
+
297
+ Display:
298
+
299
+ ```
300
+ Phase ${PHASE_NUM}: Frontend phase detected — generating UI design contract...
301
+ ```
302
+
303
+ ```
304
+ skill(skill="gsd-ui-phase", args="${PHASE_NUM}")
305
+ ```
306
+
307
+ Verify UI-SPEC was created:
308
+
309
+ ```bash
310
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
311
+ ```
312
+
313
+ **If `UI_SPEC_FILE` is still empty after ui-phase:** Display warning `Phase ${PHASE_NUM}: UI-SPEC generation did not produce output — continuing without design contract.` and proceed to 3b.
314
+
315
+ **If `HAS_UI` is 1 (no frontend indicators) OR `UI_SPEC_FILE` is not empty (UI-SPEC already exists) OR `UI_PHASE_CFG` is `false`:** Skip silently to 3b.
316
+
317
+ **3b. Plan**
318
+
319
+ **If `INTERACTIVE` is set:** Dispatch plan as a background agent to keep the main context lean. While plan runs, the workflow can immediately start discussing the next phase (see step 4).
320
+
321
+ ```
322
+ Agent(
323
+ description="Plan phase ${PHASE_NUM}: ${PHASE_NAME}",
324
+ run_in_background=true,
325
+ prompt="Run plan-phase for phase ${PHASE_NUM}: skill(skill=\"gsd:plan-phase\", args=\"${PHASE_NUM}\")"
326
+ )
327
+ ```
328
+
329
+ Store the agent task_id. After discuss for the next phase completes (or if no next phase), wait for the plan agent to finish before proceeding to execute.
330
+
331
+ **If `INTERACTIVE` is NOT set (default):** Run plan inline as before.
332
+
333
+ ```
334
+ skill(skill="gsd-plan-phase", args="${PHASE_NUM}")
335
+ ```
336
+
337
+ Verify plan produced output — re-run `init phase-op` and check `has_plans`. If false → go to handle_blocker: "Plan phase ${PHASE_NUM} did not produce any plans."
338
+
339
+ **3c. Execute**
340
+
341
+ **If `INTERACTIVE` is set:** Wait for the plan agent to complete (if not already), verify plans exist, then dispatch execute as a background agent:
342
+
343
+ ```
344
+ Agent(
345
+ description="Execute phase ${PHASE_NUM}: ${PHASE_NAME}",
346
+ run_in_background=true,
347
+ prompt="Run execute-phase for phase ${PHASE_NUM}: skill(skill=\"gsd:execute-phase\", args=\"${PHASE_NUM} --no-transition\")"
348
+ )
349
+ ```
350
+
351
+ Store the agent task_id. The workflow can now start discussing the next phase while this phase executes in the background. Before starting post-execution routing for this phase, wait for the execute agent to complete.
352
+
353
+ **If `INTERACTIVE` is NOT set (default):** Run execute inline as before.
354
+
355
+ ```
356
+ skill(skill="gsd-execute-phase", args="${PHASE_NUM} --no-transition")
357
+ ```
358
+
359
+ **3d. Post-Execution Routing**
360
+
361
+ **If `INTERACTIVE` is set:** Wait for the execute agent to complete before reading verification results.
362
+
363
+ After execute-phase returns (or the execute agent completes), read the verification result:
364
+
365
+ ```bash
366
+ VERIFY_STATUS=$(grep "^status:" "${PHASE_DIR}"/*-VERIFICATION.md 2>/dev/null | head -1 | cut -d: -f2 | tr -d ' ')
367
+ ```
368
+
369
+ Where `PHASE_DIR` comes from the `init phase-op` call already made in step 3a. If the variable is not in scope, re-fetch:
370
+
371
+ ```bash
372
+ PHASE_STATE=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init phase-op ${PHASE_NUM})
373
+ ```
374
+
375
+ Parse `phase_dir` from the JSON.
376
+
377
+ **If VERIFY_STATUS is empty** (no VERIFICATION.md or no status field):
378
+
379
+ Go to handle_blocker: "Execute phase ${PHASE_NUM} did not produce verification results."
380
+
381
+ **If `passed`:**
382
+
383
+ Display:
384
+ ```
385
+ Phase ${PHASE_NUM} ✅ ${PHASE_NAME} — Verification passed
386
+ ```
387
+
388
+ Proceed to iterate step.
389
+
390
+ **If `human_needed`:**
391
+
392
+ read the human_verification section from VERIFICATION.md to get the count and items requiring manual testing.
393
+
394
+ Display the items, then ask user via question:
395
+ - **question:** "Phase ${PHASE_NUM} has items needing manual verification. Validate now or continue to next phase?"
396
+ - **options:** "Validate now" / "Continue without validation"
397
+
398
+ On **"Validate now"**: Present the specific items from VERIFICATION.md's human_verification section. After user reviews, ask:
399
+ - **question:** "Validation result?"
400
+ - **options:** "All good — continue" / "Found issues"
401
+
402
+ On "All good — continue": Display `Phase ${PHASE_NUM} ✅ Human validation passed` and proceed to iterate step.
403
+
404
+ On "Found issues": Go to handle_blocker with the user's reported issues as the description.
405
+
406
+ On **"Continue without validation"**: Display `Phase ${PHASE_NUM} ⏭ Human validation deferred` and proceed to iterate step.
407
+
408
+ **If `gaps_found`:**
409
+
410
+ read gap summary from VERIFICATION.md (score and missing items). Display:
411
+ ```
412
+ ⚠ Phase ${PHASE_NUM}: ${PHASE_NAME} — Gaps Found
413
+ Score: {N}/{M} must-haves verified
414
+ ```
415
+
416
+ Ask user via question:
417
+ - **question:** "Gaps found in phase ${PHASE_NUM}. How to proceed?"
418
+ - **options:** "Run gap closure" / "Continue without fixing" / "Stop autonomous mode"
419
+
420
+ On **"Run gap closure"**: Execute gap closure cycle (limit: 1 attempt):
421
+
422
+ ```
423
+ skill(skill="gsd-plan-phase", args="${PHASE_NUM} --gaps")
424
+ ```
425
+
426
+ Verify gap plans were created — re-run `init phase-op ${PHASE_NUM}` and check `has_plans`. If no new gap plans → go to handle_blocker: "Gap closure planning for phase ${PHASE_NUM} did not produce plans."
427
+
428
+ Re-execute:
429
+ ```
430
+ skill(skill="gsd-execute-phase", args="${PHASE_NUM} --no-transition")
431
+ ```
432
+
433
+ Re-read verification status:
434
+ ```bash
435
+ VERIFY_STATUS=$(grep "^status:" "${PHASE_DIR}"/*-VERIFICATION.md 2>/dev/null | head -1 | cut -d: -f2 | tr -d ' ')
436
+ ```
437
+
438
+ If `passed` or `human_needed`: Route normally (continue or ask user as above).
439
+
440
+ If still `gaps_found` after this retry: Display "Gaps persist after closure attempt." and ask via question:
441
+ - **question:** "Gap closure did not fully resolve issues. How to proceed?"
442
+ - **options:** "Continue anyway" / "Stop autonomous mode"
443
+
444
+ On "Continue anyway": Proceed to iterate step.
445
+ On "Stop autonomous mode": Go to handle_blocker.
446
+
447
+ This limits gap closure to 1 automatic retry to prevent infinite loops.
448
+
449
+ On **"Continue without fixing"**: Display `Phase ${PHASE_NUM} ⏭ Gaps deferred` and proceed to iterate step.
450
+
451
+ On **"Stop autonomous mode"**: Go to handle_blocker with "User stopped — gaps remain in phase ${PHASE_NUM}".
452
+
453
+ **3d.5. UI Review (Frontend Phases)**
454
+
455
+ > Run after any successful execution routing (passed, human_needed accepted, or gaps deferred/accepted) — before proceeding to the iterate step.
456
+
457
+ Check if this phase had a UI-SPEC (created in step 3a.5 or pre-existing):
458
+
459
+ ```bash
460
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
461
+ ```
462
+
463
+ Check if UI review is enabled:
464
+
465
+ ```bash
466
+ UI_REVIEW_CFG=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.ui_review 2>/dev/null || echo "true")
467
+ ```
468
+
469
+ **If `UI_SPEC_FILE` is not empty AND `UI_REVIEW_CFG` is not `false`:**
470
+
471
+ Display:
472
+
473
+ ```
474
+ Phase ${PHASE_NUM}: Frontend phase with UI-SPEC — running UI review audit...
475
+ ```
476
+
477
+ ```
478
+ skill(skill="gsd-ui-review", args="${PHASE_NUM}")
479
+ ```
480
+
481
+ Display the review result summary (score from UI-REVIEW.md if produced). Continue to iterate step regardless of score — UI review is advisory, not blocking.
482
+
483
+ **If `UI_SPEC_FILE` is empty OR `UI_REVIEW_CFG` is `false`:** Skip silently to iterate step.
484
+
485
+ </step>
486
+
487
+ <step name="smart_discuss">
488
+
489
+ ## Smart Discuss
490
+
491
+ Run smart discuss for the current phase. Proposes grey area answers in batch tables — the user accepts or overrides per area. Produces identical CONTEXT.md output to regular discuss-phase.
492
+
493
+ > **Note:** Smart discuss is an autonomous-optimized variant of the `gsd-discuss-phase` skill. It produces identical CONTEXT.md output but uses batch table proposals instead of sequential questioning. The original `gsd-discuss-phase` skill remains unchanged (per CTRL-03). Future milestones may extract this to a separate skill file.
494
+
495
+ **Inputs:** `PHASE_NUM` from execute_phase. Run init to get phase paths:
496
+
497
+ ```bash
498
+ PHASE_STATE=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init phase-op ${PHASE_NUM})
499
+ ```
500
+
501
+ Parse from JSON: `phase_dir`, `phase_slug`, `padded_phase`, `phase_name`.
502
+
503
+ ---
504
+
505
+ ### Sub-step 1: Load prior context
506
+
507
+ read project-level and prior phase context to avoid re-asking decided questions.
508
+
509
+ **read project files:**
510
+
511
+ ```bash
512
+ cat .planning/PROJECT.md 2>/dev/null || true
513
+ cat .planning/REQUIREMENTS.md 2>/dev/null || true
514
+ cat .planning/STATE.md 2>/dev/null || true
515
+ ```
516
+
517
+ Extract from these:
518
+ - **PROJECT.md** — Vision, principles, non-negotiables, user preferences
519
+ - **REQUIREMENTS.md** — Acceptance criteria, constraints, must-haves vs nice-to-haves
520
+ - **STATE.md** — Current progress, decisions logged so far
521
+
522
+ **read all prior CONTEXT.md files:**
523
+
524
+ ```bash
525
+ (find .planning/phases -name "*-CONTEXT.md" 2>/dev/null || true) | sort
526
+ ```
527
+
528
+ For each CONTEXT.md where phase number < current phase:
529
+ - read the `<decisions>` section — these are locked preferences
530
+ - read `<specifics>` — particular references or "I want it like X" moments
531
+ - Note patterns (e.g., "user consistently prefers minimal UI", "user rejected verbose output")
532
+
533
+ **Build internal prior_decisions context** (do not write to file):
534
+
535
+ ```
536
+ <prior_decisions>
537
+ ## Project-Level
538
+ - [Key principle or constraint from PROJECT.md]
539
+ - [Requirement affecting this phase from REQUIREMENTS.md]
540
+
541
+ ## From Prior Phases
542
+ ### Phase N: [Name]
543
+ - [Decision relevant to current phase]
544
+ - [Preference that establishes a pattern]
545
+ </prior_decisions>
546
+ ```
547
+
548
+ If no prior context exists, continue without — expected for early phases.
549
+
550
+ ---
551
+
552
+ ### Sub-step 2: Scout Codebase
553
+
554
+ Lightweight codebase scan to inform grey area identification and proposals. Keep under ~5% context.
555
+
556
+ **Check for existing codebase maps:**
557
+
558
+ ```bash
559
+ ls .planning/codebase/*.md 2>/dev/null || true
560
+ ```
561
+
562
+ **If codebase maps exist:** read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type). Extract reusable components, established patterns, integration points. Skip to building context below.
563
+
564
+ **If no codebase maps, do targeted grep:**
565
+
566
+ Extract key terms from the phase goal. Search for related files:
567
+
568
+ ```bash
569
+ grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10 || true
570
+ ls src/components/ src/hooks/ src/lib/ src/utils/ 2>/dev/null || true
571
+ ```
572
+
573
+ read the 3-5 most relevant files to understand existing patterns.
574
+
575
+ **Build internal codebase_context** (do not write to file):
576
+ - **Reusable assets** — existing components, hooks, utilities usable in this phase
577
+ - **Established patterns** — how the codebase does state management, styling, data fetching
578
+ - **Integration points** — where new code connects (routes, nav, providers)
579
+
580
+ ---
581
+
582
+ ### Sub-step 3: Analyze Phase and Generate Proposals
583
+
584
+ **Get phase details:**
585
+
586
+ ```bash
587
+ DETAIL=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap get-phase ${PHASE_NUM})
588
+ ```
589
+
590
+ Extract `goal`, `requirements`, `success_criteria` from the JSON response.
591
+
592
+ **Infrastructure detection — check FIRST before generating grey areas:**
593
+
594
+ A phase is pure infrastructure when ALL of these are true:
595
+ 1. Goal keywords match: "scaffolding", "plumbing", "setup", "configuration", "migration", "refactor", "rename", "restructure", "upgrade", "infrastructure"
596
+ 2. AND success criteria are all technical: "file exists", "test passes", "config valid", "command runs"
597
+ 3. AND no user-facing behavior is described (no "users can", "displays", "shows", "presents")
598
+
599
+ **If infrastructure-only:** Skip Sub-step 4. Jump directly to Sub-step 5 with minimal CONTEXT.md. Display:
600
+
601
+ ```
602
+ Phase ${PHASE_NUM}: Infrastructure phase — skipping discuss, writing minimal context.
603
+ ```
604
+
605
+ Use these defaults for the CONTEXT.md:
606
+ - `<domain>`: Phase boundary from ROADMAP goal
607
+ - `<decisions>`: Single "### OpenCode's Discretion" subsection — "All implementation choices are at OpenCode's discretion — pure infrastructure phase"
608
+ - `<code_context>`: Whatever the codebase scout found
609
+ - `<specifics>`: "No specific requirements — infrastructure phase"
610
+ - `<deferred>`: "None"
611
+
612
+ **If NOT infrastructure — generate grey area proposals:**
613
+
614
+ Determine domain type from the phase goal:
615
+ - Something users **SEE** → visual: layout, interactions, states, density
616
+ - Something users **CALL** → interface: contracts, responses, errors, auth
617
+ - Something users **RUN** → execution: invocation, output, behavior modes, flags
618
+ - Something users **READ** → content: structure, tone, depth, flow
619
+ - Something being **ORGANIZED** → organization: criteria, grouping, exceptions, naming
620
+
621
+ Check prior_decisions — skip grey areas already decided in prior phases.
622
+
623
+ Generate **3-4 grey areas** with **~4 questions each**. For each question:
624
+ - **Pre-select a recommended answer** based on: prior decisions (consistency), codebase patterns (reuse), domain conventions (standard approaches), ROADMAP success criteria
625
+ - Generate **1-2 alternatives** per question
626
+ - **Annotate** with prior decision context ("You decided X in Phase N") and code context ("Component Y exists with Z variants") where relevant
627
+
628
+ ---
629
+
630
+ ### Sub-step 4: Present Proposals Per Area
631
+
632
+ Present grey areas **one at a time**. For each area (M of N):
633
+
634
+ Display a table:
635
+
636
+ ```
637
+ ### Grey Area {M}/{N}: {Area Name}
638
+
639
+ | # | question | ✅ Recommended | Alternative(s) |
640
+ |---|----------|---------------|-----------------|
641
+ | 1 | {question} | {answer} — {rationale} | {alt1}; {alt2} |
642
+ | 2 | {question} | {answer} — {rationale} | {alt1} |
643
+ | 3 | {question} | {answer} — {rationale} | {alt1}; {alt2} |
644
+ | 4 | {question} | {answer} — {rationale} | {alt1} |
645
+ ```
646
+
647
+ Then prompt the user via **question**:
648
+ - **header:** "Area {M}/{N}"
649
+ - **question:** "Accept these answers for {Area Name}?"
650
+ - **options:** Build dynamically — always "Accept all" first, then "Change Q1" through "Change QN" for each question (up to 4), then "Discuss deeper" last. Cap at 6 explicit options max (question adds "Other" automatically).
651
+
652
+ **On "Accept all":** Record all recommended answers for this area. Move to next area.
653
+
654
+ **On "Change QN":** Use question with the alternatives for that specific question:
655
+ - **header:** "{Area Name}"
656
+ - **question:** "Q{N}: {question text}"
657
+ - **options:** List the 1-2 alternatives plus "You decide" (maps to OpenCode's Discretion)
658
+
659
+ Record the user's choice. Re-display the updated table with the change reflected. Re-present the full acceptance prompt so the user can make additional changes or accept.
660
+
661
+ **On "Discuss deeper":** Switch to interactive mode for this area only — ask questions one at a time using question with 2-3 concrete options per question plus "You decide". After 4 questions, prompt:
662
+ - **header:** "{Area Name}"
663
+ - **question:** "More questions about {area name}, or move to next?"
664
+ - **options:** "More questions" / "Next area"
665
+
666
+ If "More questions", ask 4 more. If "Next area", display final summary table of captured answers for this area and move on.
667
+
668
+ **On "Other" (free text):** Interpret as either a specific change request or general feedback. Incorporate into the area's decisions, re-display updated table, re-present acceptance prompt.
669
+
670
+ **Scope creep handling:** If user mentions something outside the phase domain:
671
+
672
+ ```
673
+ "{Feature} sounds like a new capability — that belongs in its own phase.
674
+ I'll note it as a deferred idea.
675
+
676
+ Back to {current area}: {return to current question}"
677
+ ```
678
+
679
+ Track deferred ideas internally for inclusion in CONTEXT.md.
680
+
681
+ ---
682
+
683
+ ### Sub-step 5: write CONTEXT.md
684
+
685
+ After all areas are resolved (or infrastructure skip), write the CONTEXT.md file.
686
+
687
+ **File path:** `${phase_dir}/${padded_phase}-CONTEXT.md`
688
+
689
+ Use **exactly** this structure (identical to discuss-phase output):
690
+
691
+ ```markdown
692
+ # Phase {PHASE_NUM}: {Phase Name} - Context
693
+
694
+ **Gathered:** {date}
695
+ **Status:** Ready for planning
696
+
697
+ <domain>
698
+ ## Phase Boundary
699
+
700
+ {Domain boundary statement from analysis — what this phase delivers}
701
+
702
+ </domain>
703
+
704
+ <decisions>
705
+ ## Implementation Decisions
706
+
707
+ ### {Area 1 Name}
708
+ - {Accepted/chosen answer for Q1}
709
+ - {Accepted/chosen answer for Q2}
710
+ - {Accepted/chosen answer for Q3}
711
+ - {Accepted/chosen answer for Q4}
712
+
713
+ ### {Area 2 Name}
714
+ - {Accepted/chosen answer for Q1}
715
+ - {Accepted/chosen answer for Q2}
716
+ ...
717
+
718
+ ### OpenCode's Discretion
719
+ {Any "You decide" answers collected — note OpenCode has flexibility here}
720
+
721
+ </decisions>
722
+
723
+ <code_context>
724
+ ## Existing Code Insights
725
+
726
+ ### Reusable Assets
727
+ - {From codebase scout — components, hooks, utilities}
728
+
729
+ ### Established Patterns
730
+ - {From codebase scout — state management, styling, data fetching}
731
+
732
+ ### Integration Points
733
+ - {From codebase scout — where new code connects}
734
+
735
+ </code_context>
736
+
737
+ <specifics>
738
+ ## Specific Ideas
739
+
740
+ {Any specific references or "I want it like X" from discussion}
741
+ {If none: "No specific requirements — open to standard approaches"}
742
+
743
+ </specifics>
744
+
745
+ <deferred>
746
+ ## Deferred Ideas
747
+
748
+ {Ideas captured but out of scope for this phase}
749
+ {If none: "None — discussion stayed within phase scope"}
750
+
751
+ </deferred>
752
+ ```
753
+
754
+ write the file.
755
+
756
+ **Commit:**
757
+
758
+ ```bash
759
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(${PADDED_PHASE}): smart discuss context" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
760
+ ```
761
+
762
+ Display confirmation:
763
+
764
+ ```
765
+ Created: {path}
766
+ Decisions captured: {count} across {area_count} areas
767
+ ```
768
+
769
+ </step>
770
+
771
+ <step name="iterate">
772
+
773
+ ## 4. Iterate
774
+
775
+ **If `ONLY_PHASE` is set:** Do not iterate. Proceed directly to lifecycle step (which exits cleanly per single-phase mode).
776
+
777
+ **If `TO_PHASE` is set and current phase number >= `TO_PHASE`:** The target phase has been reached. Do not iterate further. Display:
778
+
779
+ ```
780
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
781
+ GSD ► AUTONOMOUS ▸ --to ${TO_PHASE} REACHED
782
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
783
+
784
+ Completed through phase ${TO_PHASE} as requested.
785
+ Remaining phases were not executed.
786
+
787
+ Resume with: /gsd-autonomous --from ${next_incomplete_phase}
788
+ ```
789
+
790
+ Proceed directly to lifecycle step (which handles partial completion — skips audit/complete/cleanup since not all phases are done). Exit cleanly.
791
+
792
+ **Otherwise:** After each phase completes, re-read ROADMAP.md to catch phases inserted mid-execution (decimal phases like 5.1):
793
+
794
+ ```bash
795
+ ROADMAP=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap analyze)
796
+ ```
797
+
798
+ Re-filter incomplete phases using the same logic as discover_phases:
799
+ - Keep phases where `disk_status !== "complete"` OR `roadmap_complete === false`
800
+ - Apply `--from N` filter if originally provided
801
+ - Apply `--to N` filter if originally provided
802
+ - Sort by number ascending
803
+
804
+ read STATE.md fresh:
805
+
806
+ ```bash
807
+ cat .planning/STATE.md
808
+ ```
809
+
810
+ Check for blockers in the Blockers/Concerns section. If blockers are found, go to handle_blocker with the blocker description.
811
+
812
+ If incomplete phases remain: proceed to next phase, loop back to execute_phase.
813
+
814
+ **Interactive mode overlap:** When `INTERACTIVE` is set, the iterate step enables pipeline parallelism:
815
+ 1. After discuss completes for Phase N, dispatch plan+execute as background agents
816
+ 2. Immediately start discuss for Phase N+1 (the next incomplete phase) while Phase N builds
817
+ 3. Before starting plan for Phase N+1, wait for Phase N's execute agent to complete and handle its post-execution routing (verification, gap closure, etc.)
818
+
819
+ This means the user is always answering discuss questions (lightweight, interactive) while the heavy work (planning, code generation) runs in the background. The main context only accumulates discuss conversations — plan and execute contexts are isolated in their agents.
820
+
821
+ If all phases complete, proceed to lifecycle step.
822
+
823
+ </step>
824
+
825
+ <step name="lifecycle">
826
+
827
+ ## 5. Lifecycle
828
+
829
+ **If `ONLY_PHASE` is set:** Skip lifecycle. A single phase does not trigger audit/complete/cleanup. Display:
830
+
831
+ ```
832
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
833
+ GSD ► AUTONOMOUS ▸ PHASE ${ONLY_PHASE} COMPLETE ✓
834
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
835
+
836
+ Phase ${ONLY_PHASE}: ${PHASE_NAME} — Done
837
+ Mode: Single phase (--only)
838
+
839
+ Lifecycle skipped — run /gsd-autonomous without --only
840
+ after all phases complete to trigger audit/complete/cleanup.
841
+ ```
842
+
843
+ Exit cleanly.
844
+
845
+ **Otherwise:** After all phases complete, run the milestone lifecycle sequence: audit → complete → cleanup.
846
+
847
+ Display lifecycle transition banner:
848
+
849
+ ```
850
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
851
+ GSD ► AUTONOMOUS ▸ LIFECYCLE
852
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
853
+
854
+ All phases complete → Starting lifecycle: audit → complete → cleanup
855
+ Milestone: {milestone_version} — {milestone_name}
856
+ ```
857
+
858
+ **5a. Audit**
859
+
860
+ ```
861
+ skill(skill="gsd-audit-milestone")
862
+ ```
863
+
864
+ After audit completes, detect the result:
865
+
866
+ ```bash
867
+ AUDIT_FILE=".planning/v${milestone_version}-MILESTONE-AUDIT.md"
868
+ AUDIT_STATUS=$(grep "^status:" "${AUDIT_FILE}" 2>/dev/null | head -1 | cut -d: -f2 | tr -d ' ')
869
+ ```
870
+
871
+ **If AUDIT_STATUS is empty** (no audit file or no status field):
872
+
873
+ Go to handle_blocker: "Audit did not produce results — audit file missing or malformed."
874
+
875
+ **If `passed`:**
876
+
877
+ Display:
878
+ ```
879
+ Audit ✅ passed — proceeding to complete milestone
880
+ ```
881
+
882
+ Proceed to 5b (no user pause — per CTRL-01).
883
+
884
+ **If `gaps_found`:**
885
+
886
+ read the gaps summary from the audit file. Display:
887
+ ```
888
+ ⚠ Audit: Gaps Found
889
+ ```
890
+
891
+ Ask user via question:
892
+ - **question:** "Milestone audit found gaps. How to proceed?"
893
+ - **options:** "Continue anyway — accept gaps" / "Stop — fix gaps manually"
894
+
895
+ On **"Continue anyway"**: Display `Audit ⏭ Gaps accepted — proceeding to complete milestone` and proceed to 5b.
896
+
897
+ On **"Stop"**: Go to handle_blocker with "User stopped — audit gaps remain. Run /gsd-audit-milestone to review, then /gsd-complete-milestone when ready."
898
+
899
+ **If `tech_debt`:**
900
+
901
+ read the tech debt summary from the audit file. Display:
902
+ ```
903
+ ⚠ Audit: Tech Debt Identified
904
+ ```
905
+
906
+ Show the summary, then ask user via question:
907
+ - **question:** "Milestone audit found tech debt. How to proceed?"
908
+ - **options:** "Continue with tech debt" / "Stop — address debt first"
909
+
910
+ On **"Continue with tech debt"**: Display `Audit ⏭ Tech debt acknowledged — proceeding to complete milestone` and proceed to 5b.
911
+
912
+ On **"Stop"**: Go to handle_blocker with "User stopped — tech debt to address. Run /gsd-audit-milestone to review details."
913
+
914
+ **5b. Complete Milestone**
915
+
916
+ ```
917
+ skill(skill="gsd-complete-milestone", args="${milestone_version}")
918
+ ```
919
+
920
+ After complete-milestone returns, verify it produced output:
921
+
922
+ ```bash
923
+ ls .planning/milestones/v${milestone_version}-ROADMAP.md 2>/dev/null || true
924
+ ```
925
+
926
+ If the archive file does not exist, go to handle_blocker: "Complete milestone did not produce expected archive files."
927
+
928
+ **5c. Cleanup**
929
+
930
+ ```
931
+ skill(skill="gsd-cleanup")
932
+ ```
933
+
934
+ Cleanup shows its own dry-run and asks user for approval internally — this is an acceptable pause per CTRL-01 since it's an explicit decision about file deletion.
935
+
936
+ **5d. Final Completion**
937
+
938
+ Display final completion banner:
939
+
940
+ ```
941
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
942
+ GSD ► AUTONOMOUS ▸ COMPLETE 🎉
943
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
944
+
945
+ Milestone: {milestone_version} — {milestone_name}
946
+ Status: Complete ✅
947
+ Lifecycle: audit ✅ → complete ✅ → cleanup ✅
948
+
949
+ Ship it! 🚀
950
+ ```
951
+
952
+ </step>
953
+
954
+ <step name="handle_blocker">
955
+
956
+ ## 6. Handle Blocker
957
+
958
+ When any phase operation fails or a blocker is detected, present 3 options via question:
959
+
960
+ **Prompt:** "Phase {N} ({Name}) encountered an issue: {description}"
961
+
962
+ **Options:**
963
+ 1. **"Fix and retry"** — Re-run the failed step (discuss, plan, or execute) for this phase
964
+ 2. **"Skip this phase"** — Mark phase as skipped, continue to the next incomplete phase
965
+ 3. **"Stop autonomous mode"** — Display summary of progress so far and exit cleanly
966
+
967
+ **On "Fix and retry":** Loop back to the failed step within execute_phase. If the same step fails again after retry, re-present these options.
968
+
969
+ **On "Skip this phase":** Log `Phase {N} ⏭ {Name} — Skipped by user` and proceed to iterate.
970
+
971
+ **On "Stop autonomous mode":** Display progress summary:
972
+
973
+ ```
974
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
975
+ GSD ► AUTONOMOUS ▸ STOPPED
976
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
977
+
978
+ Completed: {list of completed phases}
979
+ Skipped: {list of skipped phases}
980
+ Remaining: {list of remaining phases}
981
+
982
+ Resume with: /gsd-autonomous ${ONLY_PHASE ? "--only " + ONLY_PHASE : "--from " + next_phase}${TO_PHASE ? " --to " + TO_PHASE : ""}
983
+ ```
984
+
985
+ </step>
986
+
987
+ </process>
988
+
989
+ <success_criteria>
990
+ - [ ] All incomplete phases executed in order (smart discuss → ui-phase → plan → execute → ui-review each)
991
+ - [ ] Smart discuss proposes grey area answers in tables, user accepts or overrides per area
992
+ - [ ] Progress banners displayed between phases
993
+ - [ ] Execute-phase invoked with --no-transition (autonomous manages transitions)
994
+ - [ ] Post-execution verification reads VERIFICATION.md and routes on status
995
+ - [ ] Passed verification → automatic continue to next phase
996
+ - [ ] Human-needed verification → user prompted to validate or skip
997
+ - [ ] Gaps-found → user offered gap closure, continue, or stop
998
+ - [ ] Gap closure limited to 1 retry (prevents infinite loops)
999
+ - [ ] Plan-phase and execute-phase failures route to handle_blocker
1000
+ - [ ] ROADMAP.md re-read after each phase (catches inserted phases)
1001
+ - [ ] STATE.md checked for blockers before each phase
1002
+ - [ ] Blockers handled via user choice (retry / skip / stop)
1003
+ - [ ] Final completion or stop summary displayed
1004
+ - [ ] After all phases complete, lifecycle step is invoked (not manual suggestion)
1005
+ - [ ] Lifecycle transition banner displayed before audit
1006
+ - [ ] Audit invoked via skill(skill="gsd-audit-milestone")
1007
+ - [ ] Audit result routing: passed → auto-continue, gaps_found → user decides, tech_debt → user decides
1008
+ - [ ] Audit technical failure (no file/no status) routes to handle_blocker
1009
+ - [ ] Complete-milestone invoked via skill() with ${milestone_version} arg
1010
+ - [ ] Cleanup invoked via skill() — internal confirmation is acceptable (CTRL-01)
1011
+ - [ ] Final completion banner displayed after lifecycle
1012
+ - [ ] Progress bar uses phase number / total milestone phases (not position among incomplete), with fallback display when phase numbers exceed total
1013
+ - [ ] Smart discuss documents relationship to discuss-phase with CTRL-03 note
1014
+ - [ ] Frontend phases get UI-SPEC generated before planning (step 3a.5) if not already present
1015
+ - [ ] Frontend phases get UI review audit after successful execution (step 3d.5) if UI-SPEC exists
1016
+ - [ ] UI phase and UI review respect workflow.ui_phase and workflow.ui_review config toggles
1017
+ - [ ] UI review is advisory (non-blocking) — phase proceeds to iterate regardless of score
1018
+ - [ ] `--only N` restricts execution to exactly one phase
1019
+ - [ ] `--only N` skips lifecycle step (audit/complete/cleanup)
1020
+ - [ ] `--only N` exits cleanly after single phase completes
1021
+ - [ ] `--only N` on already-complete phase exits with message
1022
+ - [ ] `--only N` handle_blocker resume message uses --only flag
1023
+ - [ ] `--to N` stops execution after phase N completes (halts at iterate step)
1024
+ - [ ] `--to N` filters out phases with number > N during discovery
1025
+ - [ ] `--to N` displays "Stopping after phase N" in startup banner
1026
+ - [ ] `--to N` on already completed target exits with "already completed" message
1027
+ - [ ] `--to N` compatible with `--from N` (run phases from M to N)
1028
+ - [ ] `--to N` handle_blocker resume message preserves --to flag
1029
+ - [ ] `--to N` skips lifecycle when not all milestone phases complete
1030
+ - [ ] `--interactive` runs discuss inline via gsd:discuss-phase (asks questions, waits for user)
1031
+ - [ ] `--interactive` dispatches plan and execute as background agents (context isolation)
1032
+ - [ ] `--interactive` enables pipeline parallelism: discuss Phase N+1 while Phase N builds
1033
+ - [ ] `--interactive` main context only accumulates discuss conversations (lean)
1034
+ - [ ] `--interactive` waits for background agents before post-execution routing
1035
+ - [ ] `--interactive` compatible with `--only`, `--from`, and `--to` flags
1036
+ </success_criteria>