gsd-opencode 1.22.1 → 1.30.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 (156) 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 +118 -2
  5. package/agents/gsd-executor.md +24 -4
  6. package/agents/gsd-integration-checker.md +0 -2
  7. package/agents/gsd-nyquist-auditor.md +0 -2
  8. package/agents/gsd-phase-researcher.md +150 -5
  9. package/agents/gsd-plan-checker.md +70 -5
  10. package/agents/gsd-planner.md +49 -4
  11. package/agents/gsd-project-researcher.md +28 -3
  12. package/agents/gsd-research-synthesizer.md +0 -2
  13. package/agents/gsd-roadmapper.md +29 -2
  14. package/agents/gsd-ui-auditor.md +445 -0
  15. package/agents/gsd-ui-checker.md +305 -0
  16. package/agents/gsd-ui-researcher.md +368 -0
  17. package/agents/gsd-user-profiler.md +173 -0
  18. package/agents/gsd-verifier.md +123 -4
  19. package/commands/gsd/gsd-add-backlog.md +76 -0
  20. package/commands/gsd/gsd-audit-uat.md +24 -0
  21. package/commands/gsd/gsd-autonomous.md +41 -0
  22. package/commands/gsd/gsd-debug.md +5 -0
  23. package/commands/gsd/gsd-discuss-phase.md +10 -36
  24. package/commands/gsd/gsd-do.md +30 -0
  25. package/commands/gsd/gsd-execute-phase.md +20 -2
  26. package/commands/gsd/gsd-fast.md +30 -0
  27. package/commands/gsd/gsd-forensics.md +56 -0
  28. package/commands/gsd/gsd-list-workspaces.md +19 -0
  29. package/commands/gsd/gsd-manager.md +39 -0
  30. package/commands/gsd/gsd-milestone-summary.md +51 -0
  31. package/commands/gsd/gsd-new-workspace.md +44 -0
  32. package/commands/gsd/gsd-next.md +24 -0
  33. package/commands/gsd/gsd-note.md +34 -0
  34. package/commands/gsd/gsd-plan-phase.md +3 -1
  35. package/commands/gsd/gsd-plant-seed.md +28 -0
  36. package/commands/gsd/gsd-pr-branch.md +25 -0
  37. package/commands/gsd/gsd-profile-user.md +46 -0
  38. package/commands/gsd/gsd-quick.md +4 -2
  39. package/commands/gsd/gsd-reapply-patches.md +9 -8
  40. package/commands/gsd/gsd-remove-workspace.md +26 -0
  41. package/commands/gsd/gsd-research-phase.md +5 -0
  42. package/commands/gsd/gsd-review-backlog.md +61 -0
  43. package/commands/gsd/gsd-review.md +37 -0
  44. package/commands/gsd/gsd-session-report.md +19 -0
  45. package/commands/gsd/gsd-set-profile.md +24 -23
  46. package/commands/gsd/gsd-ship.md +23 -0
  47. package/commands/gsd/gsd-stats.md +18 -0
  48. package/commands/gsd/gsd-thread.md +127 -0
  49. package/commands/gsd/gsd-ui-phase.md +34 -0
  50. package/commands/gsd/gsd-ui-review.md +32 -0
  51. package/commands/gsd/gsd-workstreams.md +66 -0
  52. package/get-shit-done/bin/gsd-tools.cjs +410 -84
  53. package/get-shit-done/bin/lib/commands.cjs +429 -18
  54. package/get-shit-done/bin/lib/config.cjs +318 -45
  55. package/get-shit-done/bin/lib/core.cjs +822 -84
  56. package/get-shit-done/bin/lib/frontmatter.cjs +78 -41
  57. package/get-shit-done/bin/lib/init.cjs +836 -104
  58. package/get-shit-done/bin/lib/milestone.cjs +44 -33
  59. package/get-shit-done/bin/lib/model-profiles.cjs +68 -0
  60. package/get-shit-done/bin/lib/phase.cjs +293 -306
  61. package/get-shit-done/bin/lib/profile-output.cjs +952 -0
  62. package/get-shit-done/bin/lib/profile-pipeline.cjs +539 -0
  63. package/get-shit-done/bin/lib/roadmap.cjs +55 -24
  64. package/get-shit-done/bin/lib/security.cjs +382 -0
  65. package/get-shit-done/bin/lib/state.cjs +363 -53
  66. package/get-shit-done/bin/lib/template.cjs +2 -2
  67. package/get-shit-done/bin/lib/uat.cjs +282 -0
  68. package/get-shit-done/bin/lib/verify.cjs +104 -36
  69. package/get-shit-done/bin/lib/workstream.cjs +491 -0
  70. package/get-shit-done/references/checkpoints.md +12 -10
  71. package/get-shit-done/references/decimal-phase-calculation.md +2 -3
  72. package/get-shit-done/references/git-integration.md +47 -0
  73. package/get-shit-done/references/model-profile-resolution.md +2 -0
  74. package/get-shit-done/references/model-profiles.md +62 -16
  75. package/get-shit-done/references/phase-argument-parsing.md +2 -2
  76. package/get-shit-done/references/planning-config.md +3 -1
  77. package/get-shit-done/references/user-profiling.md +681 -0
  78. package/get-shit-done/references/workstream-flag.md +58 -0
  79. package/get-shit-done/templates/UAT.md +21 -3
  80. package/get-shit-done/templates/UI-SPEC.md +100 -0
  81. package/get-shit-done/templates/claude-md.md +122 -0
  82. package/get-shit-done/templates/config.json +10 -3
  83. package/get-shit-done/templates/context.md +61 -6
  84. package/get-shit-done/templates/dev-preferences.md +21 -0
  85. package/get-shit-done/templates/discussion-log.md +63 -0
  86. package/get-shit-done/templates/phase-prompt.md +46 -5
  87. package/get-shit-done/templates/project.md +2 -0
  88. package/get-shit-done/templates/state.md +2 -2
  89. package/get-shit-done/templates/user-profile.md +146 -0
  90. package/get-shit-done/workflows/add-phase.md +2 -2
  91. package/get-shit-done/workflows/add-tests.md +4 -4
  92. package/get-shit-done/workflows/add-todo.md +3 -3
  93. package/get-shit-done/workflows/audit-milestone.md +13 -5
  94. package/get-shit-done/workflows/audit-uat.md +109 -0
  95. package/get-shit-done/workflows/autonomous.md +891 -0
  96. package/get-shit-done/workflows/check-todos.md +2 -2
  97. package/get-shit-done/workflows/cleanup.md +4 -4
  98. package/get-shit-done/workflows/complete-milestone.md +9 -6
  99. package/get-shit-done/workflows/diagnose-issues.md +15 -3
  100. package/get-shit-done/workflows/discovery-phase.md +3 -3
  101. package/get-shit-done/workflows/discuss-phase-assumptions.md +653 -0
  102. package/get-shit-done/workflows/discuss-phase.md +411 -38
  103. package/get-shit-done/workflows/do.md +104 -0
  104. package/get-shit-done/workflows/execute-phase.md +405 -18
  105. package/get-shit-done/workflows/execute-plan.md +77 -12
  106. package/get-shit-done/workflows/fast.md +105 -0
  107. package/get-shit-done/workflows/forensics.md +265 -0
  108. package/get-shit-done/workflows/health.md +28 -6
  109. package/get-shit-done/workflows/help.md +124 -7
  110. package/get-shit-done/workflows/insert-phase.md +2 -2
  111. package/get-shit-done/workflows/list-phase-assumptions.md +2 -2
  112. package/get-shit-done/workflows/list-workspaces.md +56 -0
  113. package/get-shit-done/workflows/manager.md +362 -0
  114. package/get-shit-done/workflows/map-codebase.md +74 -13
  115. package/get-shit-done/workflows/milestone-summary.md +223 -0
  116. package/get-shit-done/workflows/new-milestone.md +120 -18
  117. package/get-shit-done/workflows/new-project.md +178 -39
  118. package/get-shit-done/workflows/new-workspace.md +237 -0
  119. package/get-shit-done/workflows/next.md +97 -0
  120. package/get-shit-done/workflows/node-repair.md +92 -0
  121. package/get-shit-done/workflows/note.md +156 -0
  122. package/get-shit-done/workflows/pause-work.md +62 -8
  123. package/get-shit-done/workflows/plan-milestone-gaps.md +4 -5
  124. package/get-shit-done/workflows/plan-phase.md +332 -33
  125. package/get-shit-done/workflows/plant-seed.md +169 -0
  126. package/get-shit-done/workflows/pr-branch.md +129 -0
  127. package/get-shit-done/workflows/profile-user.md +450 -0
  128. package/get-shit-done/workflows/progress.md +145 -20
  129. package/get-shit-done/workflows/quick.md +205 -49
  130. package/get-shit-done/workflows/remove-phase.md +2 -2
  131. package/get-shit-done/workflows/remove-workspace.md +90 -0
  132. package/get-shit-done/workflows/research-phase.md +11 -3
  133. package/get-shit-done/workflows/resume-project.md +35 -16
  134. package/get-shit-done/workflows/review.md +228 -0
  135. package/get-shit-done/workflows/session-report.md +146 -0
  136. package/get-shit-done/workflows/set-profile.md +2 -2
  137. package/get-shit-done/workflows/settings.md +79 -10
  138. package/get-shit-done/workflows/ship.md +228 -0
  139. package/get-shit-done/workflows/stats.md +60 -0
  140. package/get-shit-done/workflows/transition.md +147 -20
  141. package/get-shit-done/workflows/ui-phase.md +302 -0
  142. package/get-shit-done/workflows/ui-review.md +165 -0
  143. package/get-shit-done/workflows/update.md +108 -25
  144. package/get-shit-done/workflows/validate-phase.md +15 -8
  145. package/get-shit-done/workflows/verify-phase.md +16 -5
  146. package/get-shit-done/workflows/verify-work.md +72 -18
  147. package/package.json +1 -1
  148. package/skills/gsd-audit-milestone/SKILL.md +29 -0
  149. package/skills/gsd-cleanup/SKILL.md +19 -0
  150. package/skills/gsd-complete-milestone/SKILL.md +131 -0
  151. package/skills/gsd-discuss-phase/SKILL.md +54 -0
  152. package/skills/gsd-execute-phase/SKILL.md +49 -0
  153. package/skills/gsd-plan-phase/SKILL.md +37 -0
  154. package/skills/gsd-ui-phase/SKILL.md +24 -0
  155. package/skills/gsd-ui-review/SKILL.md +24 -0
  156. package/skills/gsd-verify-work/SKILL.md +30 -0
@@ -1,8 +1,8 @@
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
6
 
7
7
  <downstream_awareness>
8
8
  **CONTEXT.md feeds into:**
@@ -105,6 +105,25 @@ Phase: "API documentation"
105
105
  - Scope (roadmap defines this)
106
106
  </gray_area_identification>
107
107
 
108
+ <answer_validation>
109
+ **IMPORTANT: Answer validation** — After every question call, check if the response is empty or whitespace-only. If so:
110
+ 1. Retry the question once with the same parameters
111
+ 2. If still empty, present the options as a plain-text numbered list and ask the user to type their choice number
112
+ Never proceed with an empty answer.
113
+
114
+ **Text mode (`workflow.text_mode: true` in config or `--text` flag):**
115
+ When text mode is active, **do not use question at all**. Instead, present every
116
+ question as a plain-text numbered list and ask the user to type their choice number.
117
+ This is required for OpenCode remote sessions (`/rc` mode) where the OpenCode App
118
+ cannot forward TUI menu selections back to the host.
119
+
120
+ Enable text mode:
121
+ - Per-session: pass `--text` flag to any command (e.g., `/gsd-discuss-phase --text`)
122
+ - Per-project: `gsd-tools config-set workflow.text_mode true`
123
+
124
+ Text mode applies to ALL workflows in the session, not just discuss-phase.
125
+ </answer_validation>
126
+
108
127
  <process>
109
128
 
110
129
  **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,6 +134,7 @@ Phase number from argument (required).
115
134
  ```bash
116
135
  INIT=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" init phase-op "${PHASE}")
117
136
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
137
+ AGENT_SKILLS_ADVISOR=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-advisor 2>/dev/null)
118
138
  ```
119
139
 
120
140
  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`.
@@ -123,22 +143,32 @@ Parse JSON for: `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phas
123
143
  ```
124
144
  Phase [X] not found in roadmap.
125
145
 
126
- Use /gsd-progress to see available phases.
146
+ Use /gsd-progress ${GSD_WS} to see available phases.
127
147
  ```
128
148
  Exit workflow.
129
149
 
130
150
  **If `phase_found` is true:** Continue to check_existing.
151
+
152
+ **Auto mode** — If `--auto` is present in ARGUMENTS:
153
+ - In `check_existing`: auto-select "Skip" (if context exists) or continue without prompting (if no context/plans)
154
+ - In `present_gray_areas`: auto-select ALL gray areas without asking the user
155
+ - In `discuss_areas`: for each discussion question, choose the recommended option (first option, or the one marked "recommended") without using question
156
+ - Log each auto-selected choice inline so the user can review decisions in the context file
157
+ - After discussion completes, auto-advance to plan-phase (existing behavior)
131
158
  </step>
132
159
 
133
160
  <step name="check_existing">
134
161
  Check if CONTEXT.md already exists using `has_context` from init.
135
162
 
136
163
  ```bash
137
- ls ${phase_dir}/*-CONTEXT.md 2>/dev/null
164
+ ls ${phase_dir}/*-CONTEXT.md 2>/dev/null || true
138
165
  ```
139
166
 
140
167
  **If exists:**
141
- Use question:
168
+
169
+ **If `--auto`:** Auto-select "Update it" — load existing context and continue to analyze_phase. Log: `[auto] Context exists — updating with auto-selected decisions.`
170
+
171
+ **Otherwise:** Use question:
142
172
  - header: "Context"
143
173
  - question: "Phase [X] already has context. What do you want to do?"
144
174
  - options:
@@ -154,11 +184,13 @@ If "Skip": Exit workflow
154
184
 
155
185
  Check `has_plans` and `plan_count` from init. **If `has_plans` is true:**
156
186
 
157
- Use question:
187
+ **If `--auto`:** Auto-select "Continue and replan after". Log: `[auto] Plans exist — continuing with context capture, will replan after.`
188
+
189
+ **Otherwise:** Use question:
158
190
  - header: "Plans exist"
159
191
  - 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
192
  - options:
161
- - "Continue and replan after" — Capture context, then run /gsd-plan-phase {X} to replan
193
+ - "Continue and replan after" — Capture context, then run /gsd-plan-phase {X} ${GSD_WS} to replan
162
194
  - "View existing plans" — Show plans before deciding
163
195
  - "Cancel" — Skip discuss-phase
164
196
 
@@ -175,9 +207,9 @@ read project-level and prior phase context to avoid re-asking decided questions
175
207
  **Step 1: read project-level files**
176
208
  ```bash
177
209
  # 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
210
+ cat .planning/PROJECT.md 2>/dev/null || true
211
+ cat .planning/REQUIREMENTS.md 2>/dev/null || true
212
+ cat .planning/STATE.md 2>/dev/null || true
181
213
  ```
182
214
 
183
215
  Extract from these:
@@ -188,7 +220,7 @@ Extract from these:
188
220
  **Step 2: read all prior CONTEXT.md files**
189
221
  ```bash
190
222
  # Find all CONTEXT.md files from phases before current
191
- find .planning/phases -name "*-CONTEXT.md" 2>/dev/null | sort
223
+ (find .planning/phases -name "*-CONTEXT.md" 2>/dev/null || true) | sort
192
224
  ```
193
225
 
194
226
  For each CONTEXT.md where phase number < current phase:
@@ -223,12 +255,53 @@ Structure the extracted information:
223
255
  **If no prior context exists:** Continue without — this is expected for early phases.
224
256
  </step>
225
257
 
258
+ <step name="cross_reference_todos">
259
+ Check if any pending todos are relevant to this phase's scope. Surfaces backlog items that might otherwise be missed.
260
+
261
+ **Load and match todos:**
262
+ ```bash
263
+ TODO_MATCHES=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" todo match-phase "${PHASE_NUMBER}")
264
+ ```
265
+
266
+ Parse JSON for: `todo_count`, `matches[]` (each with `file`, `title`, `area`, `score`, `reasons`).
267
+
268
+ **If `todo_count` is 0 or `matches` is empty:** Skip silently — no workflow slowdown.
269
+
270
+ **If matches found:**
271
+
272
+ Present matched todos to the user. Show each match with its title, area, and why it matched:
273
+
274
+ ```
275
+ 📋 Found {N} pending todo(s) that may be relevant to Phase {X}:
276
+
277
+ {For each match:}
278
+ - **{title}** (area: {area}, relevance: {score}) — matched on {reasons}
279
+ ```
280
+
281
+ Use question (multiSelect) asking which todos to fold into this phase's scope:
282
+
283
+ ```
284
+ Which of these todos should be folded into Phase {X} scope?
285
+ (Select any that apply, or none to skip)
286
+ ```
287
+
288
+ **For selected (folded) todos:**
289
+ - Store internally as `<folded_todos>` for inclusion in CONTEXT.md `<decisions>` section
290
+ - These become additional scope items that downstream agents (researcher, planner) will see
291
+
292
+ **For unselected (reviewed but not folded) todos:**
293
+ - Store internally as `<reviewed_todos>` for inclusion in CONTEXT.md `<deferred>` section
294
+ - This prevents future phases from re-surfacing the same todos as "missed"
295
+
296
+ **Auto mode (`--auto`):** Fold all todos with score >= 0.4 automatically. Log the selection.
297
+ </step>
298
+
226
299
  <step name="scout_codebase">
227
300
  Lightweight scan of existing code to inform gray area identification and discussion. Uses ~10% context — acceptable for an interactive session.
228
301
 
229
302
  **Step 1: Check for existing codebase maps**
230
303
  ```bash
231
- ls .planning/codebase/*.md 2>/dev/null
304
+ ls .planning/codebase/*.md 2>/dev/null || true
232
305
  ```
233
306
 
234
307
  **If codebase maps exist:** read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type). Extract:
@@ -244,12 +317,12 @@ Extract key terms from the phase goal (e.g., "feed" → "post", "card", "list";
244
317
 
245
318
  ```bash
246
319
  # 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
320
+ grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10 || true
248
321
 
249
322
  # 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
323
+ ls src/components/ 2>/dev/null || true
324
+ ls src/hooks/ 2>/dev/null || true
325
+ ls src/lib/ src/utils/ 2>/dev/null || true
253
326
  ```
254
327
 
255
328
  read the 3-5 most relevant files to understand existing patterns.
@@ -272,6 +345,15 @@ Analyze the phase to identify gray areas worth discussing. **Use both `prior_dec
272
345
 
273
346
  1. **Domain boundary** — What capability is this phase delivering? State it clearly.
274
347
 
348
+ 1b. **Initialize canonical refs accumulator** — Start building the `<canonical_refs>` list for CONTEXT.md. This accumulates throughout the entire discussion, not just this step.
349
+
350
+ **Source 1 (now):** Copy `Canonical refs:` from ROADMAP.md for this phase. Expand each to a full relative path.
351
+ **Source 2 (now):** Check REQUIREMENTS.md and PROJECT.md for any specs/ADRs referenced for this phase.
352
+ **Source 3 (scout_codebase):** If existing code references docs (e.g., comments citing ADRs), add those.
353
+ **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.
354
+
355
+ 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.
356
+
275
357
  2. **Check prior decisions** — Before generating gray areas, check if any were already decided:
276
358
  - Scan `<prior_decisions>` for relevant choices (e.g., "Ctrl+C only, no single-key shortcuts")
277
359
  - These are **pre-answered** — don't re-ask unless this phase has conflicting needs
@@ -281,6 +363,33 @@ Analyze the phase to identify gray areas worth discussing. **Use both `prior_dec
281
363
 
282
364
  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
365
 
366
+ **Advisor Mode Detection:**
367
+
368
+ Check if advisor mode should activate:
369
+
370
+ 1. Check for USER-PROFILE.md:
371
+ ```bash
372
+ PROFILE_PATH="$HOME/.config/opencode/get-shit-done/USER-PROFILE.md"
373
+ ```
374
+ ADVISOR_MODE = file exists at PROFILE_PATH → true, otherwise → false
375
+
376
+ 2. If ADVISOR_MODE is true, resolve vendor_philosophy calibration tier:
377
+ - Priority 1: read config.json > preferences.vendor_philosophy (project-level override)
378
+ - Priority 2: read USER-PROFILE.md Vendor Choices/Philosophy rating (global)
379
+ - Priority 3: Default to "standard" if neither has a value or value is UNSCORED
380
+
381
+ Map to calibration tier:
382
+ - conservative OR thorough-evaluator → full_maturity
383
+ - opinionated → minimal_decisive
384
+ - pragmatic-fast OR any other value OR empty → standard
385
+
386
+ 3. Resolve model for advisor agents:
387
+ ```bash
388
+ ADVISOR_MODEL=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" resolve-model gsd-advisor-researcher --raw)
389
+ ```
390
+
391
+ If ADVISOR_MODE is false, skip all advisor-specific steps — workflow proceeds with existing conversational flow unchanged.
392
+
284
393
  **Output your analysis internally, then present to user.**
285
394
 
286
395
  Example analysis for "Post Feed" phase (with code and prior context):
@@ -314,7 +423,9 @@ We'll clarify HOW to implement this.
314
423
  - [Decision from Phase M that applies here]
315
424
  ```
316
425
 
317
- **Then use question (multiSelect: true):**
426
+ **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.
427
+
428
+ **Otherwise, use question (multiSelect: true):**
318
429
  - header: "Discuss"
319
430
  - question: "Which areas do you want to discuss for [phase name]?"
320
431
  - options: Generate 3-4 phase-specific gray areas, each with:
@@ -368,15 +479,168 @@ For "Organize photo library" (organization task):
368
479
  ☐ Folder structure — Flat, nested by year, or by category?
369
480
  ```
370
481
 
371
- Continue to discuss_areas with selected areas.
482
+ Continue to discuss_areas with selected areas (or advisor_research if ADVISOR_MODE is true).
483
+ </step>
484
+
485
+ <step name="advisor_research">
486
+ **Advisor Research** (only when ADVISOR_MODE is true)
487
+
488
+ After user selects gray areas in present_gray_areas, spawn parallel research agents.
489
+
490
+ 1. Display brief status: "Researching {N} areas..."
491
+
492
+ 2. For EACH user-selected gray area, spawn a task() in parallel:
493
+
494
+ task(
495
+ prompt="First, read @$HOME/.config/opencode/agents/gsd-advisor-researcher.md for your role and instructions.
496
+
497
+ <gray_area>{area_name}: {area_description from gray area identification}</gray_area>
498
+ <phase_context>{phase_goal and description from ROADMAP.md}</phase_context>
499
+ <project_context>{project name and brief description from PROJECT.md}</project_context>
500
+ <calibration_tier>{resolved calibration tier: full_maturity | standard | minimal_decisive}</calibration_tier>
501
+
502
+ Research this gray area and return a structured comparison table with rationale.
503
+ ${AGENT_SKILLS_ADVISOR}",
504
+ subagent_type="general",
505
+ model="{ADVISOR_MODEL}",
506
+ description="Research: {area_name}"
507
+ )
508
+
509
+ All task() calls spawn simultaneously — do NOT wait for one before starting the next.
510
+
511
+ 3. After ALL agents return, SYNTHESIZE results before presenting:
512
+ For each agent's return:
513
+ a. Parse the markdown comparison table and rationale paragraph
514
+ b. Verify all 5 columns present (Option | Pros | Cons | Complexity | Recommendation) — fill any missing columns rather than showing broken table
515
+ c. Verify option count matches calibration tier:
516
+ - full_maturity: 3-5 options acceptable
517
+ - standard: 2-4 options acceptable
518
+ - minimal_decisive: 1-2 options acceptable
519
+ If agent returned too many, trim least viable. If too few, accept as-is.
520
+ d. Rewrite rationale paragraph to weave in project context and ongoing discussion context that the agent did not have access to
521
+ e. If agent returned only 1 option, convert from table format to direct recommendation: "Standard approach for {area}: {option}. {rationale}"
522
+
523
+ 4. Store synthesized tables for use in discuss_areas.
524
+
525
+ **If ADVISOR_MODE is false:** Skip this step entirely — proceed directly from present_gray_areas to discuss_areas.
372
526
  </step>
373
527
 
374
528
  <step name="discuss_areas">
529
+ Discuss each selected area with the user. Flow depends on advisor mode.
530
+
531
+ **If ADVISOR_MODE is true:**
532
+
533
+ Table-first discussion flow — present research-backed comparison tables, then capture user picks.
534
+
535
+ **For each selected area:**
536
+
537
+ 1. **Present the synthesized comparison table + rationale paragraph** (from advisor_research step)
538
+
539
+ 2. **Use question:**
540
+ - header: "{area_name}"
541
+ - question: "Which approach for {area_name}?"
542
+ - options: Extract from the table's Option column (question adds "Other" automatically)
543
+
544
+ 3. **Record the user's selection:**
545
+ - If user picks from table options → record as locked decision for that area
546
+ - If user picks "Other" → receive their input, reflect it back for confirmation, record
547
+
548
+ 4. **After recording pick, OpenCode decides whether follow-up questions are needed:**
549
+ - If the pick has ambiguity that would affect downstream planning → ask 1-2 targeted follow-up questions using question
550
+ - If the pick is clear and self-contained → move to next area
551
+ - Do NOT ask the standard 4 questions — the table already provided the context
552
+
553
+ 5. **After all areas processed:**
554
+ - header: "Done"
555
+ - question: "That covers [list areas]. Ready to create context?"
556
+ - options: "Create context" / "Revisit an area"
557
+
558
+ **Scope creep handling (advisor mode):**
559
+ If user mentions something outside the phase domain:
560
+ ```
561
+ "[Feature] sounds like a new capability — that belongs in its own phase.
562
+ I'll note it as a deferred idea.
563
+
564
+ Back to [current area]: [return to current question]"
565
+ ```
566
+
567
+ Track deferred ideas internally.
568
+
569
+ ---
570
+
571
+ **If ADVISOR_MODE is false:**
572
+
375
573
  For each selected area, conduct a focused discussion loop.
376
574
 
377
- **Philosophy: 4 questions, then check.**
575
+ **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:
576
+ 1. Do a brief web search for best practices related to the area topic
577
+ 2. Summarize the top findings in 2-3 bullet points
578
+ 3. Present the research alongside the question so the user can make a more informed decision
579
+
580
+ Example with research enabled:
581
+ ```
582
+ Let's talk about [Authentication Strategy].
583
+
584
+ 📊 Best practices research:
585
+ • OAuth 2.0 + PKCE is the current standard for SPAs (replaces implicit flow)
586
+ • Session tokens with httpOnly cookies preferred over localStorage for XSS protection
587
+ • Consider passkey/WebAuthn support — adoption is accelerating in 2025-2026
588
+
589
+ With that context: How should users authenticate?
590
+ ```
591
+
592
+ When disabled (default), skip the research and present questions directly as before.
593
+
594
+ **Text mode support:** Parse optional `--text` from `$ARGUMENTS`.
595
+ - Accept `--text` flag OR read `workflow.text_mode` from config (from init context)
596
+ - When active, replace ALL `question` calls with plain-text numbered lists
597
+ - User types a number to select, or types free text for "Other"
598
+ - This is required for OpenCode remote sessions (`/rc` mode) where TUI menus
599
+ don't work through the OpenCode App
600
+
601
+ **Batch mode support:** Parse optional `--batch` from `$ARGUMENTS`.
602
+ - Accept `--batch`, `--batch=N`, or `--batch N`
603
+
604
+ **Analyze mode support:** Parse optional `--analyze` from `$ARGUMENTS`.
605
+ When `--analyze` is active, before presenting each question (or question group in batch mode), provide a brief **trade-off analysis** for the decision:
606
+ - 2-3 options with pros/cons based on codebase context and common patterns
607
+ - A recommended approach with reasoning
608
+ - Known pitfalls or constraints from prior phases
378
609
 
379
- Ask 4 questions per area before offering to continue or move on. Each answer often reveals the next question.
610
+ Example with `--analyze`:
611
+ ```
612
+ **Trade-off analysis: Authentication strategy**
613
+
614
+ | Approach | Pros | Cons |
615
+ |----------|------|------|
616
+ | Session cookies | Simple, httpOnly prevents XSS | Requires CSRF protection, sticky sessions |
617
+ | JWT (stateless) | Scalable, no server state | Token size, revocation complexity |
618
+ | OAuth 2.0 + PKCE | Industry standard for SPAs | More setup, redirect flow UX |
619
+
620
+ 💡 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`.
621
+
622
+ How should users authenticate?
623
+ ```
624
+
625
+ This gives the user context to make informed decisions without extra prompting. When `--analyze` is absent, present questions directly as before.
626
+ - Accept `--batch`, `--batch=N`, or `--batch N`
627
+ - Default to 4 questions per batch when no number is provided
628
+ - Clamp explicit sizes to 2-5 so a batch stays answerable
629
+ - If `--batch` is absent, keep the existing one-question-at-a-time flow
630
+
631
+ **Philosophy:** stay adaptive, but let the user choose the pacing.
632
+ - Default mode: 4 single-question turns, then check whether to continue
633
+ - `--batch` mode: 1 grouped turn with 2-5 numbered questions, then check whether to continue
634
+
635
+ Each answer (or answer set, in batch mode) should reveal the next question or next batch.
636
+
637
+ **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:
638
+ ```
639
+ [auto] [Area] — Q: "[question text]" → Selected: "[chosen option]" (recommended default)
640
+ ```
641
+ After all areas are auto-resolved, skip the "Explore more gray areas" prompt and proceed directly to write_context.
642
+
643
+ **Interactive mode (no `--auto`):**
380
644
 
381
645
  **For each area:**
382
646
 
@@ -385,7 +649,9 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
385
649
  Let's talk about [Area].
386
650
  ```
387
651
 
388
- 2. **Ask 4 questions using question:**
652
+ 2. **Ask questions using the selected pacing:**
653
+
654
+ **Default (no `--batch`): Ask 4 questions using question**
389
655
  - header: "[Area]" (max 12 chars — abbreviate if needed)
390
656
  - question: Specific decision for this area
391
657
  - options: 2-3 concrete choices (question adds "Other" automatically), with the recommended choice highlighted and brief explanation why
@@ -399,12 +665,21 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
399
665
  - Include "You decide" as an option when reasonable — captures OpenCode discretion
400
666
  - **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
667
 
402
- 3. **After 4 questions, check:**
668
+ **Batch mode (`--batch`): Ask 2-5 numbered questions in one plain-text turn**
669
+ - Group closely related questions for the current area into a single message
670
+ - Keep each question concrete and answerable in one reply
671
+ - When options are helpful, include short inline choices per question rather than a separate question for every item
672
+ - After the user replies, reflect back the captured decisions, note any unanswered items, and ask only the minimum follow-up needed before moving on
673
+ - Preserve adaptiveness between batches: use the full set of answers to decide the next batch or whether the area is sufficiently clear
674
+
675
+ 3. **After the current set of questions, check:**
403
676
  - header: "[Area]" (max 12 chars)
404
- - question: "More questions about [area], or move to next?"
677
+ - question: "More questions about [area], or move to next? (Remaining: [list other unvisited areas])"
405
678
  - options: "More questions" / "Next area"
406
679
 
407
- If "More questions" ask 4 more, then check again
680
+ 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)"
681
+
682
+ If "More questions" → ask another 4 single questions, or another 2-5 question batch when `--batch` is active, then check again
408
683
  If "Next area" → proceed to next selected area
409
684
  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
685
 
@@ -420,10 +695,18 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
420
695
  - Loop: discuss new areas, then prompt again
421
696
  - If "I'm ready for context": Proceed to write_context
422
697
 
698
+ **Canonical ref accumulation during discussion:**
699
+ 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:
700
+ 1. read the referenced doc (or confirm it exists)
701
+ 2. Add it to the canonical refs accumulator with full relative path
702
+ 3. Use what you learned from the doc to inform subsequent questions
703
+
704
+ 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.
705
+
423
706
  **question design:**
424
707
  - 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.
708
+ - Each answer should inform the next question or next batch
709
+ - 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
710
 
428
711
  **Scope creep handling:**
429
712
  If user mentions something outside the phase domain:
@@ -435,11 +718,23 @@ Back to [current area]: [return to current question]"
435
718
  ```
436
719
 
437
720
  Track deferred ideas internally.
721
+
722
+ **Track discussion log data internally:**
723
+ For each question asked, accumulate:
724
+ - Area name
725
+ - All options presented (label + description)
726
+ - Which option the user selected (or their free-text response)
727
+ - Any follow-up notes or clarifications the user provided
728
+ This data is used to generate DISCUSSION-LOG.md in the `write_context` step.
438
729
  </step>
439
730
 
440
731
  <step name="write_context">
441
732
  Create CONTEXT.md capturing decisions made.
442
733
 
734
+ **Also generate DISCUSSION-LOG.md** — a full audit trail of the discuss-phase Q&A.
735
+ This file is for human reference only (software audits, compliance reviews). It is NOT
736
+ consumed by downstream agents (researcher, planner, executor).
737
+
443
738
  **Find or create phase directory:**
444
739
 
445
740
  Use values from init: `phase_dir`, `phase_slug`, `padded_phase`.
@@ -470,17 +765,43 @@ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
470
765
  ## Implementation Decisions
471
766
 
472
767
  ### [Category 1 that was discussed]
473
- - [Decision or preference captured]
474
- - [Another decision if applicable]
768
+ - **D-01:** [Decision or preference captured]
769
+ - **D-02:** [Another decision if applicable]
475
770
 
476
771
  ### [Category 2 that was discussed]
477
- - [Decision or preference captured]
772
+ - **D-03:** [Decision or preference captured]
478
773
 
479
774
  ### OpenCode's Discretion
480
775
  [Areas where user said "you decide" — note that OpenCode has flexibility here]
481
776
 
777
+ ### Folded Todos
778
+ [If any todos were folded into scope from the cross_reference_todos step, list them here.
779
+ Each entry should include the todo title, original problem, and how it fits this phase's scope.
780
+ If no todos were folded: omit this subsection entirely.]
781
+
482
782
  </decisions>
483
783
 
784
+ <canonical_refs>
785
+ ## Canonical References
786
+
787
+ **Downstream agents MUST read these before planning or implementing.**
788
+
789
+ [MANDATORY section. write the FULL accumulated canonical refs list here.
790
+ Sources: ROADMAP.md refs + REQUIREMENTS.md refs + user-referenced docs during
791
+ discussion + any docs discovered during codebase scout. Group by topic area.
792
+ Every entry needs a full relative path — not just a name.]
793
+
794
+ ### [Topic area 1]
795
+ - `path/to/adr-or-spec.md` — [What it decides/defines that's relevant]
796
+ - `path/to/doc.md` §N — [Specific section reference]
797
+
798
+ ### [Topic area 2]
799
+ - `path/to/feature-doc.md` — [What this doc defines]
800
+
801
+ [If no external specs: "No external specs — requirements fully captured in decisions above"]
802
+
803
+ </canonical_refs>
804
+
484
805
  <code_context>
485
806
  ## Existing Code Insights
486
807
 
@@ -509,6 +830,12 @@ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
509
830
 
510
831
  [Ideas that came up but belong in other phases. Don't lose them.]
511
832
 
833
+ ### Reviewed Todos (not folded)
834
+ [If any todos were reviewed in cross_reference_todos but not folded into scope,
835
+ list them here so future phases know they were considered.
836
+ Each entry: todo title + reason it was deferred (out of scope, belongs in Phase Y, etc.)
837
+ If no reviewed-but-deferred todos: omit this subsection entirely.]
838
+
512
839
  [If none: "None — discussion stayed within phase scope"]
513
840
 
514
841
  </deferred>
@@ -546,14 +873,15 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
546
873
 
547
874
  **Phase ${PHASE}: [Name]** — [Goal from ROADMAP.md]
548
875
 
549
- `/gsd-plan-phase ${PHASE}`
876
+ `/gsd-plan-phase ${PHASE} ${GSD_WS}`
550
877
 
551
878
  *`/new` first → fresh context window*
552
879
 
553
880
  ---
554
881
 
555
882
  **Also available:**
556
- - `/gsd-plan-phase ${PHASE} --skip-research` — plan without research
883
+ - `/gsd-plan-phase ${PHASE} --skip-research ${GSD_WS}` — plan without research
884
+ - `/gsd-ui-phase ${PHASE} ${GSD_WS}` — generate UI design contract before planning (if phase has frontend work)
557
885
  - Review/edit CONTEXT.md before continuing
558
886
 
559
887
  ---
@@ -561,10 +889,54 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
561
889
  </step>
562
890
 
563
891
  <step name="git_commit">
564
- Commit phase context (uses `commit_docs` from init internally):
892
+ **write DISCUSSION-LOG.md before committing:**
893
+
894
+ **File location:** `${phase_dir}/${padded_phase}-DISCUSSION-LOG.md`
895
+
896
+ ```markdown
897
+ # Phase [X]: [Name] - Discussion Log
898
+
899
+ > **Audit trail only.** Do not use as input to planning, research, or execution agents.
900
+ > Decisions are captured in CONTEXT.md — this log preserves the alternatives considered.
901
+
902
+ **Date:** [ISO date]
903
+ **Phase:** [phase number]-[phase name]
904
+ **Areas discussed:** [comma-separated list]
905
+
906
+ ---
907
+
908
+ [For each gray area discussed:]
909
+
910
+ ## [Area Name]
911
+
912
+ | Option | Description | Selected |
913
+ |--------|-------------|----------|
914
+ | [Option 1] | [Description from question] | |
915
+ | [Option 2] | [Description] | ✓ |
916
+ | [Option 3] | [Description] | |
917
+
918
+ **User's choice:** [Selected option or free-text response]
919
+ **Notes:** [Any clarifications, follow-up context, or rationale the user provided]
920
+
921
+ ---
922
+
923
+ [Repeat for each area]
924
+
925
+ ## OpenCode's Discretion
926
+
927
+ [List areas where user said "you decide" or deferred to OpenCode]
928
+
929
+ ## Deferred Ideas
930
+
931
+ [Ideas mentioned during discussion that were noted for future phases]
932
+ ```
933
+
934
+ write file.
935
+
936
+ Commit phase context and discussion log:
565
937
 
566
938
  ```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"
939
+ 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
940
  ```
569
941
 
570
942
  Confirm: "Committed: docs(${padded_phase}): capture phase context"
@@ -620,7 +992,7 @@ Context captured. Launching plan-phase...
620
992
 
621
993
  Launch plan-phase using the skill tool to avoid nested task sessions (which cause runtime freezes due to deep agent nesting — see #686):
622
994
  ```
623
- skill(skill="gsd-plan-phase", args="${PHASE} --auto")
995
+ skill(skill="gsd-plan-phase", args="${PHASE} --auto ${GSD_WS}")
624
996
  ```
625
997
 
626
998
  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,23 +1006,23 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
634
1006
 
635
1007
  Auto-advance pipeline finished: discuss → plan → execute
636
1008
 
637
- Next: /gsd-discuss-phase ${NEXT_PHASE} --auto
1009
+ Next: /gsd-discuss-phase ${NEXT_PHASE} --auto ${GSD_WS}
638
1010
  */new first → fresh context window*
639
1011
  ```
640
1012
  - **PLANNING COMPLETE** → Planning done, execution didn't complete:
641
1013
  ```
642
1014
  Auto-advance partial: Planning complete, execution did not finish.
643
- Continue: /gsd-execute-phase ${PHASE}
1015
+ Continue: /gsd-execute-phase ${PHASE} ${GSD_WS}
644
1016
  ```
645
1017
  - **PLANNING INCONCLUSIVE / CHECKPOINT** → Stop chain:
646
1018
  ```
647
1019
  Auto-advance stopped: Planning needs input.
648
- Continue: /gsd-plan-phase ${PHASE}
1020
+ Continue: /gsd-plan-phase ${PHASE} ${GSD_WS}
649
1021
  ```
650
1022
  - **GAPS FOUND** → Stop chain:
651
1023
  ```
652
1024
  Auto-advance stopped: Gaps found during execution.
653
- Continue: /gsd-plan-phase ${PHASE} --gaps
1025
+ Continue: /gsd-plan-phase ${PHASE} --gaps ${GSD_WS}
654
1026
  ```
655
1027
 
656
1028
  **If neither `--auto` nor config enabled:**
@@ -669,6 +1041,7 @@ Route to `confirm_creation` step (existing behavior — show manual next steps).
669
1041
  - Each selected area explored until user satisfied (with code-informed and prior-decision-informed options)
670
1042
  - Scope creep redirected to deferred ideas
671
1043
  - CONTEXT.md captures actual decisions, not vague vision
1044
+ - CONTEXT.md includes canonical_refs section with full file paths to every spec/ADR/doc downstream agents need (MANDATORY — never omit)
672
1045
  - CONTEXT.md includes code_context section with reusable assets and patterns
673
1046
  - Deferred ideas preserved for future phases
674
1047
  - STATE.md updated with session info