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,8 +1,14 @@
1
- <purpose>
1
+ <objective>
2
2
  Extract implementation decisions that downstream agents need. Analyze the phase to identify gray areas, let the user choose what to discuss, then deep-dive each selected area until satisfied.
3
3
 
4
4
  You are a thinking partner, not an interviewer. The user is the visionary — you are the builder. Your job is to capture decisions that will guide research and planning, not to figure out implementation yourself.
5
- </purpose>
5
+ </objective>
6
+
7
+ <required_reading>
8
+ @$HOME/.config/opencode/get-shit-done/references/domain-probes.md
9
+ @$HOME/.config/opencode/get-shit-done/references/gate-prompts.md
10
+ @$HOME/.config/opencode/get-shit-done/references/universal-anti-patterns.md
11
+ </required_reading>
6
12
 
7
13
  <downstream_awareness>
8
14
  **CONTEXT.md feeds into:**
@@ -105,6 +111,25 @@ Phase: "API documentation"
105
111
  - Scope (roadmap defines this)
106
112
  </gray_area_identification>
107
113
 
114
+ <answer_validation>
115
+ **IMPORTANT: Answer validation** — After every question call, check if the response is empty or whitespace-only. If so:
116
+ 1. Retry the question once with the same parameters
117
+ 2. If still empty, present the options as a plain-text numbered list and ask the user to type their choice number
118
+ Never proceed with an empty answer.
119
+
120
+ **Text mode (`workflow.text_mode: true` in config or `--text` flag):**
121
+ When text mode is active, **do not use question at all**. Instead, present every
122
+ question as a plain-text numbered list and ask the user to type their choice number.
123
+ This is required for OpenCode remote sessions (`/rc` mode) where the OpenCode App
124
+ cannot forward TUI menu selections back to the host.
125
+
126
+ Enable text mode:
127
+ - Per-session: pass `--text` flag to any command (e.g., `/gsd-discuss-phase --text`)
128
+ - Per-project: `gsd-tools config-set workflow.text_mode true`
129
+
130
+ Text mode applies to ALL workflows in the session, not just discuss-phase.
131
+ </answer_validation>
132
+
108
133
  <process>
109
134
 
110
135
  **Express path available:** If you already have a PRD or acceptance criteria document, use `/gsd-plan-phase {phase} --prd path/to/prd.md` to skip this discussion and go straight to planning.
@@ -115,30 +140,77 @@ Phase number from argument (required).
115
140
  ```bash
116
141
  INIT=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init phase-op "${PHASE}")
117
142
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
143
+ AGENT_SKILLS_ADVISOR=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-advisor 2>/dev/null)
118
144
  ```
119
145
 
120
- Parse JSON for: `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_plans`, `has_verification`, `plan_count`, `roadmap_exists`, `planning_exists`.
146
+ Parse JSON for: `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_plans`, `has_verification`, `plan_count`, `roadmap_exists`, `planning_exists`, `response_language`.
147
+
148
+ **If `response_language` is set:** All user-facing questions, prompts, and explanations in this workflow MUST be presented in `{response_language}`. This includes question labels, option text, gray area descriptions, and discussion summaries. Technical terms, code, and file paths remain in English. Subagent prompts stay in English — only user-facing output is translated.
121
149
 
122
150
  **If `phase_found` is false:**
123
151
  ```
124
152
  Phase [X] not found in roadmap.
125
153
 
126
- Use /gsd-progress to see available phases.
154
+ Use /gsd-progress ${GSD_WS} to see available phases.
127
155
  ```
128
156
  Exit workflow.
129
157
 
130
158
  **If `phase_found` is true:** Continue to check_existing.
159
+
160
+ **Power mode** — If `--power` is present in ARGUMENTS:
161
+ - Skip interactive questioning entirely
162
+ - read and execute @$HOME/.config/opencode/get-shit-done/workflows/discuss-phase-power.md end-to-end
163
+ - Do not continue with the steps below
164
+
165
+ **Auto mode** — If `--auto` is present in ARGUMENTS:
166
+ - In `check_existing`: auto-select "Skip" (if context exists) or continue without prompting (if no context/plans)
167
+ - In `present_gray_areas`: auto-select ALL gray areas without asking the user
168
+ - In `discuss_areas`: for each discussion question, choose the recommended option (first option, or the one marked "recommended") without using question
169
+ - Log each auto-selected choice inline so the user can review decisions in the context file
170
+ - After discussion completes, auto-advance to plan-phase (existing behavior)
171
+
172
+ **Chain mode** — If `--chain` is present in ARGUMENTS:
173
+ - Discussion is fully interactive (questions, gray area selection — same as default mode)
174
+ - After discussion completes, auto-advance to plan-phase → execute-phase (same as `--auto`)
175
+ - This is the middle ground: user controls the discuss decisions, then plan+execute run autonomously
176
+ </step>
177
+
178
+ <step name="check_blocking_antipatterns" priority="first">
179
+ **MANDATORY — Check for blocking anti-patterns before any other work.**
180
+
181
+ Look for a `.continue-here.md` in the current phase directory:
182
+
183
+ ```bash
184
+ ls ${phase_dir}/.continue-here.md 2>/dev/null || true
185
+ ```
186
+
187
+ If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
188
+
189
+ **If one or more `blocking` anti-patterns are found:**
190
+
191
+ This step cannot be skipped. Before proceeding to `check_existing` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
192
+
193
+ 1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
194
+ 2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
195
+ 3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
196
+
197
+ 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.
198
+
199
+ **If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_existing`.
131
200
  </step>
132
201
 
133
202
  <step name="check_existing">
134
203
  Check if CONTEXT.md already exists using `has_context` from init.
135
204
 
136
205
  ```bash
137
- ls ${phase_dir}/*-CONTEXT.md 2>/dev/null
206
+ ls ${phase_dir}/*-CONTEXT.md 2>/dev/null || true
138
207
  ```
139
208
 
140
209
  **If exists:**
141
- Use question:
210
+
211
+ **If `--auto`:** Auto-select "Update it" — load existing context and continue to analyze_phase. Log: `[auto] Context exists — updating with auto-selected decisions.`
212
+
213
+ **Otherwise:** Use question:
142
214
  - header: "Context"
143
215
  - question: "Phase [X] already has context. What do you want to do?"
144
216
  - options:
@@ -152,13 +224,35 @@ If "Skip": Exit workflow
152
224
 
153
225
  **If doesn't exist:**
154
226
 
227
+ **Check for interrupted discussion checkpoint:**
228
+
229
+ ```bash
230
+ ls ${phase_dir}/*-DISCUSS-CHECKPOINT.json 2>/dev/null || true
231
+ ```
232
+
233
+ If a checkpoint file exists (previous session was interrupted before CONTEXT.md was written):
234
+
235
+ **If `--auto`:** Auto-select "Resume" — load checkpoint and continue from last completed area.
236
+
237
+ **Otherwise:** Use question:
238
+ - header: "Resume"
239
+ - question: "Found interrupted discussion checkpoint ({N} areas completed out of {M}). Resume from where you left off?"
240
+ - options:
241
+ - "Resume" — Load checkpoint, skip completed areas, continue discussion
242
+ - "Start fresh" — Delete checkpoint, start discussion from scratch
243
+
244
+ If "Resume": Parse the checkpoint JSON. Load `decisions` into the internal accumulator. Set `areas_completed` to skip those areas. Continue to `present_gray_areas` with only the remaining areas.
245
+ If "Start fresh": Delete the checkpoint file. Continue as if no checkpoint existed.
246
+
155
247
  Check `has_plans` and `plan_count` from init. **If `has_plans` is true:**
156
248
 
157
- Use question:
249
+ **If `--auto`:** Auto-select "Continue and replan after". Log: `[auto] Plans exist — continuing with context capture, will replan after.`
250
+
251
+ **Otherwise:** Use question:
158
252
  - header: "Plans exist"
159
253
  - question: "Phase [X] already has {plan_count} plan(s) created without user context. Your decisions here won't affect existing plans unless you replan."
160
254
  - options:
161
- - "Continue and replan after" — Capture context, then run /gsd-plan-phase {X} to replan
255
+ - "Continue and replan after" — Capture context, then run /gsd-plan-phase {X} ${GSD_WS} to replan
162
256
  - "View existing plans" — Show plans before deciding
163
257
  - "Cancel" — Skip discuss-phase
164
258
 
@@ -175,9 +269,9 @@ read project-level and prior phase context to avoid re-asking decided questions
175
269
  **Step 1: read project-level files**
176
270
  ```bash
177
271
  # Core project files
178
- cat .planning/PROJECT.md 2>/dev/null
179
- cat .planning/REQUIREMENTS.md 2>/dev/null
180
- cat .planning/STATE.md 2>/dev/null
272
+ cat .planning/PROJECT.md 2>/dev/null || true
273
+ cat .planning/REQUIREMENTS.md 2>/dev/null || true
274
+ cat .planning/STATE.md 2>/dev/null || true
181
275
  ```
182
276
 
183
277
  Extract from these:
@@ -188,7 +282,7 @@ Extract from these:
188
282
  **Step 2: read all prior CONTEXT.md files**
189
283
  ```bash
190
284
  # Find all CONTEXT.md files from phases before current
191
- find .planning/phases -name "*-CONTEXT.md" 2>/dev/null | sort
285
+ (find .planning/phases -name "*-CONTEXT.md" 2>/dev/null || true) | sort
192
286
  ```
193
287
 
194
288
  For each CONTEXT.md where phase number < current phase:
@@ -223,12 +317,53 @@ Structure the extracted information:
223
317
  **If no prior context exists:** Continue without — this is expected for early phases.
224
318
  </step>
225
319
 
320
+ <step name="cross_reference_todos">
321
+ Check if any pending todos are relevant to this phase's scope. Surfaces backlog items that might otherwise be missed.
322
+
323
+ **Load and match todos:**
324
+ ```bash
325
+ TODO_MATCHES=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" todo match-phase "${PHASE_NUMBER}")
326
+ ```
327
+
328
+ Parse JSON for: `todo_count`, `matches[]` (each with `file`, `title`, `area`, `score`, `reasons`).
329
+
330
+ **If `todo_count` is 0 or `matches` is empty:** Skip silently — no workflow slowdown.
331
+
332
+ **If matches found:**
333
+
334
+ Present matched todos to the user. Show each match with its title, area, and why it matched:
335
+
336
+ ```
337
+ 📋 Found {N} pending todo(s) that may be relevant to Phase {X}:
338
+
339
+ {For each match:}
340
+ - **{title}** (area: {area}, relevance: {score}) — matched on {reasons}
341
+ ```
342
+
343
+ Use question (multiSelect) asking which todos to fold into this phase's scope:
344
+
345
+ ```
346
+ Which of these todos should be folded into Phase {X} scope?
347
+ (Select any that apply, or none to skip)
348
+ ```
349
+
350
+ **For selected (folded) todos:**
351
+ - Store internally as `<folded_todos>` for inclusion in CONTEXT.md `<decisions>` section
352
+ - These become additional scope items that downstream agents (researcher, planner) will see
353
+
354
+ **For unselected (reviewed but not folded) todos:**
355
+ - Store internally as `<reviewed_todos>` for inclusion in CONTEXT.md `<deferred>` section
356
+ - This prevents future phases from re-surfacing the same todos as "missed"
357
+
358
+ **Auto mode (`--auto`):** Fold all todos with score >= 0.4 automatically. Log the selection.
359
+ </step>
360
+
226
361
  <step name="scout_codebase">
227
362
  Lightweight scan of existing code to inform gray area identification and discussion. Uses ~10% context — acceptable for an interactive session.
228
363
 
229
364
  **Step 1: Check for existing codebase maps**
230
365
  ```bash
231
- ls .planning/codebase/*.md 2>/dev/null
366
+ ls .planning/codebase/*.md 2>/dev/null || true
232
367
  ```
233
368
 
234
369
  **If codebase maps exist:** read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type). Extract:
@@ -244,12 +379,12 @@ Extract key terms from the phase goal (e.g., "feed" → "post", "card", "list";
244
379
 
245
380
  ```bash
246
381
  # Find files related to phase goal terms
247
- grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10
382
+ grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10 || true
248
383
 
249
384
  # Find existing components/hooks
250
- ls src/components/ 2>/dev/null
251
- ls src/hooks/ 2>/dev/null
252
- ls src/lib/ src/utils/ 2>/dev/null
385
+ ls src/components/ 2>/dev/null || true
386
+ ls src/hooks/ 2>/dev/null || true
387
+ ls src/lib/ src/utils/ 2>/dev/null || true
253
388
  ```
254
389
 
255
390
  read the 3-5 most relevant files to understand existing patterns.
@@ -272,6 +407,15 @@ Analyze the phase to identify gray areas worth discussing. **Use both `prior_dec
272
407
 
273
408
  1. **Domain boundary** — What capability is this phase delivering? State it clearly.
274
409
 
410
+ 1b. **Initialize canonical refs accumulator** — Start building the `<canonical_refs>` list for CONTEXT.md. This accumulates throughout the entire discussion, not just this step.
411
+
412
+ **Source 1 (now):** Copy `Canonical refs:` from ROADMAP.md for this phase. Expand each to a full relative path.
413
+ **Source 2 (now):** Check REQUIREMENTS.md and PROJECT.md for any specs/ADRs referenced for this phase.
414
+ **Source 3 (scout_codebase):** If existing code references docs (e.g., comments citing ADRs), add those.
415
+ **Source 4 (discuss_areas):** When the user says "read X", "check Y", or references any doc/spec/ADR during discussion — add it immediately. These are often the MOST important refs because they represent docs the user specifically wants followed.
416
+
417
+ This list is MANDATORY in CONTEXT.md. Every ref must have a full relative path so downstream agents can read it directly. If no external docs exist, note that explicitly.
418
+
275
419
  2. **Check prior decisions** — Before generating gray areas, check if any were already decided:
276
420
  - Scan `<prior_decisions>` for relevant choices (e.g., "Ctrl+C only, no single-key shortcuts")
277
421
  - These are **pre-answered** — don't re-ask unless this phase has conflicting needs
@@ -281,6 +425,33 @@ Analyze the phase to identify gray areas worth discussing. **Use both `prior_dec
281
425
 
282
426
  4. **Skip assessment** — If no meaningful gray areas exist (pure infrastructure, clear-cut implementation, or all already decided in prior phases), the phase may not need discussion.
283
427
 
428
+ **Advisor Mode Detection:**
429
+
430
+ Check if advisor mode should activate:
431
+
432
+ 1. Check for USER-PROFILE.md:
433
+ ```bash
434
+ PROFILE_PATH="$HOME/.config/opencode/get-shit-done/USER-PROFILE.md"
435
+ ```
436
+ ADVISOR_MODE = file exists at PROFILE_PATH → true, otherwise → false
437
+
438
+ 2. If ADVISOR_MODE is true, resolve vendor_philosophy calibration tier:
439
+ - Priority 1: read config.json > preferences.vendor_philosophy (project-level override)
440
+ - Priority 2: read USER-PROFILE.md Vendor Choices/Philosophy rating (global)
441
+ - Priority 3: Default to "standard" if neither has a value or value is UNSCORED
442
+
443
+ Map to calibration tier:
444
+ - conservative OR thorough-evaluator → full_maturity
445
+ - opinionated → minimal_decisive
446
+ - pragmatic-fast OR any other value OR empty → standard
447
+
448
+ 3. Resolve model for advisor agents:
449
+ ```bash
450
+ ADVISOR_MODEL=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" resolve-model gsd-advisor-researcher --raw)
451
+ ```
452
+
453
+ If ADVISOR_MODE is false, skip all advisor-specific steps — workflow proceeds with existing conversational flow unchanged.
454
+
284
455
  **Output your analysis internally, then present to user.**
285
456
 
286
457
  Example analysis for "Post Feed" phase (with code and prior context):
@@ -314,7 +485,9 @@ We'll clarify HOW to implement this.
314
485
  - [Decision from Phase M that applies here]
315
486
  ```
316
487
 
317
- **Then use question (multiSelect: true):**
488
+ **If `--auto`:** Auto-select ALL gray areas. Log: `[auto] Selected all gray areas: [list area names].` Skip the question below and continue directly to discuss_areas with all areas selected.
489
+
490
+ **Otherwise, use question (multiSelect: true):**
318
491
  - header: "Discuss"
319
492
  - question: "Which areas do you want to discuss for [phase name]?"
320
493
  - options: Generate 3-4 phase-specific gray areas, each with:
@@ -368,15 +541,178 @@ For "Organize photo library" (organization task):
368
541
  ☐ Folder structure — Flat, nested by year, or by category?
369
542
  ```
370
543
 
371
- Continue to discuss_areas with selected areas.
544
+ Continue to discuss_areas with selected areas (or advisor_research if ADVISOR_MODE is true).
545
+ </step>
546
+
547
+ <step name="advisor_research">
548
+ **Advisor Research** (only when ADVISOR_MODE is true)
549
+
550
+ After user selects gray areas in present_gray_areas, spawn parallel research agents.
551
+
552
+ 1. Display brief status: "Researching {N} areas..."
553
+
554
+ 2. For EACH user-selected gray area, spawn a task() in parallel:
555
+
556
+ task(
557
+ prompt="First, read @$HOME/.config/opencode/agents/gsd-advisor-researcher.md for your role and instructions.
558
+
559
+ <gray_area>{area_name}: {area_description from gray area identification}</gray_area>
560
+ <phase_context>{phase_goal and description from ROADMAP.md}</phase_context>
561
+ <project_context>{project name and brief description from PROJECT.md}</project_context>
562
+ <calibration_tier>{resolved calibration tier: full_maturity | standard | minimal_decisive}</calibration_tier>
563
+
564
+ Research this gray area and return a structured comparison table with rationale.
565
+ ${AGENT_SKILLS_ADVISOR}",
566
+ subagent_type="general",
567
+ model="{ADVISOR_MODEL}",
568
+ description="Research: {area_name}"
569
+ )
570
+
571
+ All task() calls spawn simultaneously — do NOT wait for one before starting the next.
572
+
573
+ 3. After ALL agents return, SYNTHESIZE results before presenting:
574
+ For each agent's return:
575
+ a. Parse the markdown comparison table and rationale paragraph
576
+ b. Verify all 5 columns present (Option | Pros | Cons | Complexity | Recommendation) — fill any missing columns rather than showing broken table
577
+ c. Verify option count matches calibration tier:
578
+ - full_maturity: 3-5 options acceptable
579
+ - standard: 2-4 options acceptable
580
+ - minimal_decisive: 1-2 options acceptable
581
+ If agent returned too many, trim least viable. If too few, accept as-is.
582
+ d. Rewrite rationale paragraph to weave in project context and ongoing discussion context that the agent did not have access to
583
+ e. If agent returned only 1 option, convert from table format to direct recommendation: "Standard approach for {area}: {option}. {rationale}"
584
+
585
+ 4. Store synthesized tables for use in discuss_areas.
586
+
587
+ **If ADVISOR_MODE is false:** Skip this step entirely — proceed directly from present_gray_areas to discuss_areas.
372
588
  </step>
373
589
 
374
590
  <step name="discuss_areas">
591
+ Discuss each selected area with the user. Flow depends on advisor mode.
592
+
593
+ **If ADVISOR_MODE is true:**
594
+
595
+ Table-first discussion flow — present research-backed comparison tables, then capture user picks.
596
+
597
+ **For each selected area:**
598
+
599
+ 1. **Present the synthesized comparison table + rationale paragraph** (from advisor_research step)
600
+
601
+ 2. **Use question:**
602
+ - header: "{area_name}"
603
+ - question: "Which approach for {area_name}?"
604
+ - options: Extract from the table's Option column (question adds "Other" automatically)
605
+
606
+ 3. **Record the user's selection:**
607
+ - If user picks from table options → record as locked decision for that area
608
+ - If user picks "Other" → receive their input, reflect it back for confirmation, record
609
+
610
+ 4. **After recording pick, OpenCode decides whether follow-up questions are needed:**
611
+ - If the pick has ambiguity that would affect downstream planning → ask 1-2 targeted follow-up questions using question
612
+ - If the pick is clear and self-contained → move to next area
613
+ - Do NOT ask the standard 4 questions — the table already provided the context
614
+
615
+ 5. **After all areas processed:**
616
+ - header: "Done"
617
+ - question: "That covers [list areas]. Ready to create context?"
618
+ - options: "Create context" / "Revisit an area"
619
+
620
+ **Scope creep handling (advisor mode):**
621
+ If user mentions something outside the phase domain:
622
+ ```
623
+ "[Feature] sounds like a new capability — that belongs in its own phase.
624
+ I'll note it as a deferred idea.
625
+
626
+ Back to [current area]: [return to current question]"
627
+ ```
628
+
629
+ Track deferred ideas internally.
630
+
631
+ ---
632
+
633
+ **If ADVISOR_MODE is false:**
634
+
375
635
  For each selected area, conduct a focused discussion loop.
376
636
 
377
- **Philosophy: 4 questions, then check.**
637
+ **Research-before-questions mode:** Check if `workflow.research_before_questions` is enabled in config (from init context or `.planning/config.json`). When enabled, before presenting questions for each area:
638
+ 1. Do a brief web search for best practices related to the area topic
639
+ 2. Summarize the top findings in 2-3 bullet points
640
+ 3. Present the research alongside the question so the user can make a more informed decision
641
+
642
+ Example with research enabled:
643
+ ```
644
+ Let's talk about [Authentication Strategy].
378
645
 
379
- Ask 4 questions per area before offering to continue or move on. Each answer often reveals the next question.
646
+ 📊 Best practices research:
647
+ • OAuth 2.0 + PKCE is the current standard for SPAs (replaces implicit flow)
648
+ • Session tokens with httpOnly cookies preferred over localStorage for XSS protection
649
+ • Consider passkey/WebAuthn support — adoption is accelerating in 2025-2026
650
+
651
+ With that context: How should users authenticate?
652
+ ```
653
+
654
+ When disabled (default), skip the research and present questions directly as before.
655
+
656
+ **Text mode support:** Parse optional `--text` from `$ARGUMENTS`.
657
+ - Accept `--text` flag OR read `workflow.text_mode` from config (from init context)
658
+ - When active, replace ALL `question` calls with plain-text numbered lists
659
+ - User types a number to select, or types free text for "Other"
660
+ - This is required for OpenCode remote sessions (`/rc` mode) where TUI menus
661
+ don't work through the OpenCode App
662
+
663
+ **Batch mode support:** Parse optional `--batch` from `$ARGUMENTS`.
664
+ - Accept `--batch`, `--batch=N`, or `--batch N`
665
+
666
+ **Analyze mode support:** Parse optional `--analyze` from `$ARGUMENTS`.
667
+ When `--analyze` is active, before presenting each question (or question group in batch mode), provide a brief **trade-off analysis** for the decision:
668
+ - 2-3 options with pros/cons based on codebase context and common patterns
669
+ - A recommended approach with reasoning
670
+ - Known pitfalls or constraints from prior phases
671
+
672
+ Example with `--analyze`:
673
+ ```
674
+ **Trade-off analysis: Authentication strategy**
675
+
676
+ | Approach | Pros | Cons |
677
+ |----------|------|------|
678
+ | Session cookies | Simple, httpOnly prevents XSS | Requires CSRF protection, sticky sessions |
679
+ | JWT (stateless) | Scalable, no server state | Token size, revocation complexity |
680
+ | OAuth 2.0 + PKCE | Industry standard for SPAs | More setup, redirect flow UX |
681
+
682
+ 💡 Recommended: OAuth 2.0 + PKCE — your app has social login in requirements (REQ-04) and this aligns with the existing NextAuth setup in `src/lib/auth.ts`.
683
+
684
+ How should users authenticate?
685
+ ```
686
+
687
+ This gives the user context to make informed decisions without extra prompting. When `--analyze` is absent, present questions directly as before.
688
+ - Accept `--batch`, `--batch=N`, or `--batch N`
689
+ - Default to 4 questions per batch when no number is provided
690
+ - Clamp explicit sizes to 2-5 so a batch stays answerable
691
+ - If `--batch` is absent, keep the existing one-question-at-a-time flow
692
+
693
+ **Philosophy:** stay adaptive, but let the user choose the pacing.
694
+ - Default mode: 4 single-question turns, then check whether to continue
695
+ - `--batch` mode: 1 grouped turn with 2-5 numbered questions, then check whether to continue
696
+
697
+ Each answer (or answer set, in batch mode) should reveal the next question or next batch.
698
+
699
+ **Auto mode (`--auto`):** For each area, OpenCode selects the recommended option (first option, or the one explicitly marked "recommended") for every question without using question. Log each auto-selected choice:
700
+ ```
701
+ [auto] [Area] — Q: "[question text]" → Selected: "[chosen option]" (recommended default)
702
+ ```
703
+ After all areas are auto-resolved, skip the "Explore more gray areas" prompt and proceed directly to write_context.
704
+
705
+ **CRITICAL — Auto-mode pass cap:**
706
+ In `--auto` mode, the discuss step MUST complete in a **single pass**. After writing CONTEXT.md once, you are DONE — proceed immediately to write_context and then auto_advance. Do NOT re-read your own CONTEXT.md to find "gaps", "undefined types", or "missing decisions" and run additional passes. This creates a self-feeding loop where each pass generates references that the next pass treats as gaps, consuming unbounded time and resources.
707
+
708
+ Check the pass cap from config:
709
+ ```bash
710
+ MAX_PASSES=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.max_discuss_passes 2>/dev/null || echo "3")
711
+ ```
712
+
713
+ If you have already written and committed CONTEXT.md, the discuss step is complete. Move on.
714
+
715
+ **Interactive mode (no `--auto`):**
380
716
 
381
717
  **For each area:**
382
718
 
@@ -385,7 +721,9 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
385
721
  Let's talk about [Area].
386
722
  ```
387
723
 
388
- 2. **Ask 4 questions using question:**
724
+ 2. **Ask questions using the selected pacing:**
725
+
726
+ **Default (no `--batch`): Ask 4 questions using question**
389
727
  - header: "[Area]" (max 12 chars — abbreviate if needed)
390
728
  - question: Specific decision for this area
391
729
  - options: 2-3 concrete choices (question adds "Other" automatically), with the recommended choice highlighted and brief explanation why
@@ -399,12 +737,21 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
399
737
  - Include "You decide" as an option when reasonable — captures OpenCode discretion
400
738
  - **Context7 for library choices:** When a gray area involves library selection (e.g., "magic links" → query next-auth docs) or API approach decisions, use `mcp__context7__*` tools to fetch current documentation and inform the options. Don't use Context7 for every question — only when library-specific knowledge improves the options.
401
739
 
402
- 3. **After 4 questions, check:**
740
+ **Batch mode (`--batch`): Ask 2-5 numbered questions in one plain-text turn**
741
+ - Group closely related questions for the current area into a single message
742
+ - Keep each question concrete and answerable in one reply
743
+ - When options are helpful, include short inline choices per question rather than a separate question for every item
744
+ - After the user replies, reflect back the captured decisions, note any unanswered items, and ask only the minimum follow-up needed before moving on
745
+ - Preserve adaptiveness between batches: use the full set of answers to decide the next batch or whether the area is sufficiently clear
746
+
747
+ 3. **After the current set of questions, check:**
403
748
  - header: "[Area]" (max 12 chars)
404
- - question: "More questions about [area], or move to next?"
749
+ - question: "More questions about [area], or move to next? (Remaining: [list other unvisited areas])"
405
750
  - options: "More questions" / "Next area"
406
751
 
407
- If "More questions" ask 4 more, then check again
752
+ When building the question text, list the remaining unvisited areas so the user knows what's ahead. For example: "More questions about Layout, or move to next? (Remaining: Loading behavior, Content ordering)"
753
+
754
+ If "More questions" → ask another 4 single questions, or another 2-5 question batch when `--batch` is active, then check again
408
755
  If "Next area" → proceed to next selected area
409
756
  If "Other" (free text) → interpret intent: continuation phrases ("chat more", "keep going", "yes", "more") map to "More questions"; advancement phrases ("done", "move on", "next", "skip") map to "Next area". If ambiguous, ask: "Continue with more questions about [area], or move to the next area?"
410
757
 
@@ -420,10 +767,18 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
420
767
  - Loop: discuss new areas, then prompt again
421
768
  - If "I'm ready for context": Proceed to write_context
422
769
 
770
+ **Canonical ref accumulation during discussion:**
771
+ When the user references a doc, spec, or ADR during any answer — e.g., "read adr-014", "check the MCP spec", "per browse-spec.md" — immediately:
772
+ 1. read the referenced doc (or confirm it exists)
773
+ 2. Add it to the canonical refs accumulator with full relative path
774
+ 3. Use what you learned from the doc to inform subsequent questions
775
+
776
+ These user-referenced docs are often MORE important than ROADMAP.md refs because they represent docs the user specifically wants downstream agents to follow. Never drop them.
777
+
423
778
  **question design:**
424
779
  - Options should be concrete, not abstract ("Cards" not "Option A")
425
- - Each answer should inform the next question
426
- - If user picks "Other" to provide freeform input (e.g., "let me describe it", "something else", or an open-ended reply), ask your follow-up as plain text — NOT another question. Wait for them to type at the normal prompt, then reflect their input back and confirm before resuming question for the next question.
780
+ - Each answer should inform the next question or next batch
781
+ - If user picks "Other" to provide freeform input (e.g., "let me describe it", "something else", or an open-ended reply), ask your follow-up as plain text — NOT another question. Wait for them to type at the normal prompt, then reflect their input back and confirm before resuming question or the next numbered batch.
427
782
 
428
783
  **Scope creep handling:**
429
784
  If user mentions something outside the phase domain:
@@ -435,11 +790,61 @@ Back to [current area]: [return to current question]"
435
790
  ```
436
791
 
437
792
  Track deferred ideas internally.
793
+
794
+ **Incremental checkpoint — save after each area completes:**
795
+
796
+ After each area is resolved (user says "Next area" or area auto-resolves in `--auto` mode), immediately write a checkpoint file with all decisions captured so far. This prevents data loss if the session is interrupted mid-discussion.
797
+
798
+ **Checkpoint file:** `${phase_dir}/${padded_phase}-DISCUSS-CHECKPOINT.json`
799
+
800
+ write after each area:
801
+ ```json
802
+ {
803
+ "phase": "{PHASE_NUM}",
804
+ "phase_name": "{phase_name}",
805
+ "timestamp": "{ISO timestamp}",
806
+ "areas_completed": ["Area 1", "Area 2"],
807
+ "areas_remaining": ["Area 3", "Area 4"],
808
+ "decisions": {
809
+ "Area 1": [
810
+ {"question": "...", "answer": "...", "options_presented": ["..."]},
811
+ {"question": "...", "answer": "...", "options_presented": ["..."]}
812
+ ],
813
+ "Area 2": [
814
+ {"question": "...", "answer": "...", "options_presented": ["..."]}
815
+ ]
816
+ },
817
+ "deferred_ideas": ["..."],
818
+ "canonical_refs": ["..."]
819
+ }
820
+ ```
821
+
822
+ This is a structured checkpoint, not the final CONTEXT.md — the `write_context` step still produces the canonical output. But if the session dies, the next `/gsd-discuss-phase` invocation can detect this checkpoint and offer to resume from it instead of starting from scratch.
823
+
824
+ **On session resume:** In the `check_existing` step, also check for `*-DISCUSS-CHECKPOINT.json`. If found and no CONTEXT.md exists:
825
+ - Display: "Found interrupted discussion checkpoint ({N} areas completed). Resume from checkpoint?"
826
+ - Options: "Resume" / "Start fresh"
827
+ - On "Resume": Load the checkpoint, skip completed areas, continue from where it left off
828
+ - On "Start fresh": Delete the checkpoint, proceed as normal
829
+
830
+ **After write_context completes successfully:** Delete the checkpoint file — the canonical CONTEXT.md now has all decisions.
831
+
832
+ **Track discussion log data internally:**
833
+ For each question asked, accumulate:
834
+ - Area name
835
+ - All options presented (label + description)
836
+ - Which option the user selected (or their free-text response)
837
+ - Any follow-up notes or clarifications the user provided
838
+ This data is used to generate DISCUSSION-LOG.md in the `write_context` step.
438
839
  </step>
439
840
 
440
841
  <step name="write_context">
441
842
  Create CONTEXT.md capturing decisions made.
442
843
 
844
+ **Also generate DISCUSSION-LOG.md** — a full audit trail of the discuss-phase Q&A.
845
+ This file is for human reference only (software audits, compliance reviews). It is NOT
846
+ consumed by downstream agents (researcher, planner, executor).
847
+
443
848
  **Find or create phase directory:**
444
849
 
445
850
  Use values from init: `phase_dir`, `phase_slug`, `padded_phase`.
@@ -470,17 +875,43 @@ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
470
875
  ## Implementation Decisions
471
876
 
472
877
  ### [Category 1 that was discussed]
473
- - [Decision or preference captured]
474
- - [Another decision if applicable]
878
+ - **D-01:** [Decision or preference captured]
879
+ - **D-02:** [Another decision if applicable]
475
880
 
476
881
  ### [Category 2 that was discussed]
477
- - [Decision or preference captured]
882
+ - **D-03:** [Decision or preference captured]
478
883
 
479
884
  ### OpenCode's Discretion
480
885
  [Areas where user said "you decide" — note that OpenCode has flexibility here]
481
886
 
887
+ ### Folded Todos
888
+ [If any todos were folded into scope from the cross_reference_todos step, list them here.
889
+ Each entry should include the todo title, original problem, and how it fits this phase's scope.
890
+ If no todos were folded: omit this subsection entirely.]
891
+
482
892
  </decisions>
483
893
 
894
+ <canonical_refs>
895
+ ## Canonical References
896
+
897
+ **Downstream agents MUST read these before planning or implementing.**
898
+
899
+ [MANDATORY section. write the FULL accumulated canonical refs list here.
900
+ Sources: ROADMAP.md refs + REQUIREMENTS.md refs + user-referenced docs during
901
+ discussion + any docs discovered during codebase scout. Group by topic area.
902
+ Every entry needs a full relative path — not just a name.]
903
+
904
+ ### [Topic area 1]
905
+ - `path/to/adr-or-spec.md` — [What it decides/defines that's relevant]
906
+ - `path/to/doc.md` §N — [Specific section reference]
907
+
908
+ ### [Topic area 2]
909
+ - `path/to/feature-doc.md` — [What this doc defines]
910
+
911
+ [If no external specs: "No external specs — requirements fully captured in decisions above"]
912
+
913
+ </canonical_refs>
914
+
484
915
  <code_context>
485
916
  ## Existing Code Insights
486
917
 
@@ -509,6 +940,12 @@ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
509
940
 
510
941
  [Ideas that came up but belong in other phases. Don't lose them.]
511
942
 
943
+ ### Reviewed Todos (not folded)
944
+ [If any todos were reviewed in cross_reference_todos but not folded into scope,
945
+ list them here so future phases know they were considered.
946
+ Each entry: todo title + reason it was deferred (out of scope, belongs in Phase Y, etc.)
947
+ If no reviewed-but-deferred todos: omit this subsection entirely.]
948
+
512
949
  [If none: "None — discussion stayed within phase scope"]
513
950
 
514
951
  </deferred>
@@ -546,14 +983,16 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
546
983
 
547
984
  **Phase ${PHASE}: [Name]** — [Goal from ROADMAP.md]
548
985
 
549
- `/gsd-plan-phase ${PHASE}`
986
+ `/new` then:
550
987
 
551
- *`/new` first → fresh context window*
988
+ `/gsd-plan-phase ${PHASE} ${GSD_WS}`
552
989
 
553
990
  ---
554
991
 
555
992
  **Also available:**
556
- - `/gsd-plan-phase ${PHASE} --skip-research` — plan without research
993
+ - `/gsd-discuss-phase ${PHASE} --chain ${GSD_WS}` — re-run with auto plan+execute after
994
+ - `/gsd-plan-phase ${PHASE} --skip-research ${GSD_WS}` — plan without research
995
+ - `/gsd-ui-phase ${PHASE} ${GSD_WS}` — generate UI design contract before planning (if phase has frontend work)
557
996
  - Review/edit CONTEXT.md before continuing
558
997
 
559
998
  ---
@@ -561,10 +1000,60 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
561
1000
  </step>
562
1001
 
563
1002
  <step name="git_commit">
564
- Commit phase context (uses `commit_docs` from init internally):
1003
+ **write DISCUSSION-LOG.md before committing:**
1004
+
1005
+ **File location:** `${phase_dir}/${padded_phase}-DISCUSSION-LOG.md`
1006
+
1007
+ ```markdown
1008
+ # Phase [X]: [Name] - Discussion Log
1009
+
1010
+ > **Audit trail only.** Do not use as input to planning, research, or execution agents.
1011
+ > Decisions are captured in CONTEXT.md — this log preserves the alternatives considered.
1012
+
1013
+ **Date:** [ISO date]
1014
+ **Phase:** [phase number]-[phase name]
1015
+ **Areas discussed:** [comma-separated list]
1016
+
1017
+ ---
1018
+
1019
+ [For each gray area discussed:]
1020
+
1021
+ ## [Area Name]
1022
+
1023
+ | Option | Description | Selected |
1024
+ |--------|-------------|----------|
1025
+ | [Option 1] | [Description from question] | |
1026
+ | [Option 2] | [Description] | ✓ |
1027
+ | [Option 3] | [Description] | |
1028
+
1029
+ **User's choice:** [Selected option or free-text response]
1030
+ **Notes:** [Any clarifications, follow-up context, or rationale the user provided]
1031
+
1032
+ ---
1033
+
1034
+ [Repeat for each area]
1035
+
1036
+ ## OpenCode's Discretion
1037
+
1038
+ [List areas where user said "you decide" or deferred to OpenCode]
1039
+
1040
+ ## Deferred Ideas
1041
+
1042
+ [Ideas mentioned during discussion that were noted for future phases]
1043
+ ```
1044
+
1045
+ write file.
1046
+
1047
+ **Clean up checkpoint file** — CONTEXT.md is now the canonical record:
1048
+
1049
+ ```bash
1050
+ rm -f "${phase_dir}/${padded_phase}-DISCUSS-CHECKPOINT.json"
1051
+ ```
1052
+
1053
+ Commit phase context and discussion log:
565
1054
 
566
1055
  ```bash
567
- node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(${padded_phase}): capture phase context" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
1056
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(${padded_phase}): capture phase context" --files "${phase_dir}/${padded_phase}-CONTEXT.md" "${phase_dir}/${padded_phase}-DISCUSSION-LOG.md"
568
1057
  ```
569
1058
 
570
1059
  Confirm: "Committed: docs(${padded_phase}): capture phase context"
@@ -589,10 +1078,10 @@ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(state
589
1078
  <step name="auto_advance">
590
1079
  Check for auto-advance trigger:
591
1080
 
592
- 1. Parse `--auto` flag from $ARGUMENTS
593
- 2. **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):
1081
+ 1. Parse `--auto` and `--chain` flags from $ARGUMENTS
1082
+ 2. **Sync chain flag with intent** — if user invoked manually (no `--auto` and no `--chain`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
594
1083
  ```bash
595
- if [[ ! "$ARGUMENTS" =~ --auto ]]; then
1084
+ if [[ ! "$ARGUMENTS" =~ --auto ]] && [[ ! "$ARGUMENTS" =~ --chain ]]; then
596
1085
  node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
597
1086
  fi
598
1087
  ```
@@ -602,12 +1091,12 @@ Check for auto-advance trigger:
602
1091
  AUTO_CFG=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
603
1092
  ```
604
1093
 
605
- **If `--auto` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct `--auto` usage without new-project):
1094
+ **If `--auto` or `--chain` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct usage without new-project):
606
1095
  ```bash
607
1096
  node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true
608
1097
  ```
609
1098
 
610
- **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
1099
+ **If `--auto` flag present OR `--chain` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
611
1100
 
612
1101
  Display banner:
613
1102
  ```
@@ -620,7 +1109,7 @@ Context captured. Launching plan-phase...
620
1109
 
621
1110
  Launch plan-phase using the skill tool to avoid nested task sessions (which cause runtime freezes due to deep agent nesting — see #686):
622
1111
  ```
623
- skill(skill="gsd-plan-phase", args="${PHASE} --auto")
1112
+ skill(skill="gsd-plan-phase", args="${PHASE} --auto ${GSD_WS}")
624
1113
  ```
625
1114
 
626
1115
  This keeps the auto-advance chain flat — discuss, plan, and execute all run at the same nesting level rather than spawning increasingly deep task agents.
@@ -634,31 +1123,47 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
634
1123
 
635
1124
  Auto-advance pipeline finished: discuss → plan → execute
636
1125
 
637
- Next: /gsd-discuss-phase ${NEXT_PHASE} --auto
638
- */new first → fresh context window*
1126
+ /new then:
1127
+
1128
+ Next: /gsd-discuss-phase ${NEXT_PHASE} ${WAS_CHAIN ? "--chain" : "--auto"} ${GSD_WS}
639
1129
  ```
640
1130
  - **PLANNING COMPLETE** → Planning done, execution didn't complete:
641
1131
  ```
642
1132
  Auto-advance partial: Planning complete, execution did not finish.
643
- Continue: /gsd-execute-phase ${PHASE}
1133
+ Continue: /gsd-execute-phase ${PHASE} ${GSD_WS}
644
1134
  ```
645
1135
  - **PLANNING INCONCLUSIVE / CHECKPOINT** → Stop chain:
646
1136
  ```
647
1137
  Auto-advance stopped: Planning needs input.
648
- Continue: /gsd-plan-phase ${PHASE}
1138
+ Continue: /gsd-plan-phase ${PHASE} ${GSD_WS}
649
1139
  ```
650
1140
  - **GAPS FOUND** → Stop chain:
651
1141
  ```
652
1142
  Auto-advance stopped: Gaps found during execution.
653
- Continue: /gsd-plan-phase ${PHASE} --gaps
1143
+ Continue: /gsd-plan-phase ${PHASE} --gaps ${GSD_WS}
654
1144
  ```
655
1145
 
656
- **If neither `--auto` nor config enabled:**
1146
+ **If none of `--auto`, `--chain`, nor config enabled:**
657
1147
  Route to `confirm_creation` step (existing behavior — show manual next steps).
658
1148
  </step>
659
1149
 
660
1150
  </process>
661
1151
 
1152
+ <power_user_mode>
1153
+ When `--power` flag is present in ARGUMENTS, skip interactive questioning and execute the power user workflow.
1154
+
1155
+ The power user mode generates ALL questions upfront into machine-readable and human-friendly files, then waits for the user to answer at their own pace before processing all answers in a single pass.
1156
+
1157
+ **Full step-by-step instructions:** @$HOME/.config/opencode/get-shit-done/workflows/discuss-phase-power.md
1158
+
1159
+ **Summary of flow:**
1160
+ 1. Run the same phase analysis (gray area identification) as standard mode
1161
+ 2. write all questions to `{phase_dir}/{padded_phase}-QUESTIONS.json` and `{phase_dir}/{padded_phase}-QUESTIONS.html`
1162
+ 3. Notify user with file paths and wait for a "refresh" or "finalize" command
1163
+ 4. On "refresh": read the JSON, process answered questions, update stats and HTML
1164
+ 5. On "finalize": read all answers from JSON, generate CONTEXT.md in the standard format
1165
+ </power_user_mode>
1166
+
662
1167
  <success_criteria>
663
1168
  - Phase validated against roadmap
664
1169
  - Prior context loaded (PROJECT.md, REQUIREMENTS.md, STATE.md, prior CONTEXT.md files)
@@ -669,8 +1174,14 @@ Route to `confirm_creation` step (existing behavior — show manual next steps).
669
1174
  - Each selected area explored until user satisfied (with code-informed and prior-decision-informed options)
670
1175
  - Scope creep redirected to deferred ideas
671
1176
  - CONTEXT.md captures actual decisions, not vague vision
1177
+ - CONTEXT.md includes canonical_refs section with full file paths to every spec/ADR/doc downstream agents need (MANDATORY — never omit)
672
1178
  - CONTEXT.md includes code_context section with reusable assets and patterns
673
1179
  - Deferred ideas preserved for future phases
674
1180
  - STATE.md updated with session info
675
1181
  - User knows next steps
1182
+ - Checkpoint file written after each area completes (incremental save)
1183
+ - Interrupted sessions can be resumed from checkpoint (no re-answering completed areas)
1184
+ - Checkpoint file cleaned up after successful CONTEXT.md write
1185
+ - `--chain` triggers interactive discuss followed by auto plan+execute (no auto-answering)
1186
+ - `--chain` and `--auto` both persist chain flag and auto-advance to plan-phase
676
1187
  </success_criteria>