gsd-opencode 1.30.0 → 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 (112) hide show
  1. package/agents/gsd-debugger.md +0 -1
  2. package/agents/gsd-doc-verifier.md +207 -0
  3. package/agents/gsd-doc-writer.md +608 -0
  4. package/agents/gsd-executor.md +22 -1
  5. package/agents/gsd-phase-researcher.md +41 -0
  6. package/agents/gsd-plan-checker.md +82 -0
  7. package/agents/gsd-planner.md +123 -194
  8. package/agents/gsd-security-auditor.md +129 -0
  9. package/agents/gsd-ui-auditor.md +40 -0
  10. package/agents/gsd-user-profiler.md +2 -2
  11. package/agents/gsd-verifier.md +84 -18
  12. package/commands/gsd/gsd-add-backlog.md +1 -1
  13. package/commands/gsd/gsd-analyze-dependencies.md +34 -0
  14. package/commands/gsd/gsd-autonomous.md +6 -2
  15. package/commands/gsd/gsd-cleanup.md +5 -0
  16. package/commands/gsd/gsd-debug.md +24 -21
  17. package/commands/gsd/gsd-discuss-phase.md +7 -2
  18. package/commands/gsd/gsd-docs-update.md +48 -0
  19. package/commands/gsd/gsd-execute-phase.md +4 -0
  20. package/commands/gsd/gsd-help.md +2 -0
  21. package/commands/gsd/gsd-join-discord.md +2 -1
  22. package/commands/gsd/gsd-manager.md +1 -0
  23. package/commands/gsd/gsd-new-project.md +4 -0
  24. package/commands/gsd/gsd-plan-phase.md +5 -0
  25. package/commands/gsd/gsd-quick.md +5 -3
  26. package/commands/gsd/gsd-reapply-patches.md +171 -39
  27. package/commands/gsd/gsd-research-phase.md +2 -12
  28. package/commands/gsd/gsd-review-backlog.md +1 -0
  29. package/commands/gsd/gsd-review.md +3 -2
  30. package/commands/gsd/gsd-secure-phase.md +35 -0
  31. package/commands/gsd/gsd-thread.md +1 -1
  32. package/commands/gsd/gsd-workstreams.md +7 -2
  33. package/get-shit-done/bin/gsd-tools.cjs +42 -8
  34. package/get-shit-done/bin/lib/commands.cjs +68 -14
  35. package/get-shit-done/bin/lib/config.cjs +18 -10
  36. package/get-shit-done/bin/lib/core.cjs +383 -80
  37. package/get-shit-done/bin/lib/docs.cjs +267 -0
  38. package/get-shit-done/bin/lib/frontmatter.cjs +47 -2
  39. package/get-shit-done/bin/lib/init.cjs +85 -5
  40. package/get-shit-done/bin/lib/milestone.cjs +21 -0
  41. package/get-shit-done/bin/lib/model-profiles.cjs +2 -0
  42. package/get-shit-done/bin/lib/phase.cjs +232 -189
  43. package/get-shit-done/bin/lib/profile-output.cjs +97 -1
  44. package/get-shit-done/bin/lib/roadmap.cjs +137 -113
  45. package/get-shit-done/bin/lib/schema-detect.cjs +238 -0
  46. package/get-shit-done/bin/lib/security.cjs +5 -3
  47. package/get-shit-done/bin/lib/state.cjs +366 -44
  48. package/get-shit-done/bin/lib/verify.cjs +158 -14
  49. package/get-shit-done/bin/lib/workstream.cjs +6 -2
  50. package/get-shit-done/references/agent-contracts.md +79 -0
  51. package/get-shit-done/references/artifact-types.md +113 -0
  52. package/get-shit-done/references/context-budget.md +49 -0
  53. package/get-shit-done/references/continuation-format.md +15 -15
  54. package/get-shit-done/references/domain-probes.md +125 -0
  55. package/get-shit-done/references/gate-prompts.md +100 -0
  56. package/get-shit-done/references/model-profiles.md +2 -2
  57. package/get-shit-done/references/planner-gap-closure.md +62 -0
  58. package/get-shit-done/references/planner-reviews.md +39 -0
  59. package/get-shit-done/references/planner-revision.md +87 -0
  60. package/get-shit-done/references/planning-config.md +15 -0
  61. package/get-shit-done/references/revision-loop.md +97 -0
  62. package/get-shit-done/references/ui-brand.md +2 -2
  63. package/get-shit-done/references/universal-anti-patterns.md +58 -0
  64. package/get-shit-done/references/workstream-flag.md +56 -3
  65. package/get-shit-done/templates/SECURITY.md +61 -0
  66. package/get-shit-done/templates/VALIDATION.md +3 -3
  67. package/get-shit-done/templates/claude-md.md +27 -4
  68. package/get-shit-done/templates/config.json +4 -0
  69. package/get-shit-done/templates/debug-subagent-prompt.md +2 -6
  70. package/get-shit-done/templates/planner-subagent-prompt.md +2 -10
  71. package/get-shit-done/workflows/add-phase.md +2 -2
  72. package/get-shit-done/workflows/add-todo.md +1 -1
  73. package/get-shit-done/workflows/analyze-dependencies.md +96 -0
  74. package/get-shit-done/workflows/audit-milestone.md +8 -12
  75. package/get-shit-done/workflows/autonomous.md +158 -13
  76. package/get-shit-done/workflows/check-todos.md +2 -2
  77. package/get-shit-done/workflows/complete-milestone.md +13 -4
  78. package/get-shit-done/workflows/diagnose-issues.md +8 -6
  79. package/get-shit-done/workflows/discovery-phase.md +1 -1
  80. package/get-shit-done/workflows/discuss-phase-assumptions.md +22 -4
  81. package/get-shit-done/workflows/discuss-phase-power.md +291 -0
  82. package/get-shit-done/workflows/discuss-phase.md +149 -11
  83. package/get-shit-done/workflows/docs-update.md +1093 -0
  84. package/get-shit-done/workflows/execute-phase.md +362 -66
  85. package/get-shit-done/workflows/execute-plan.md +1 -1
  86. package/get-shit-done/workflows/help.md +9 -6
  87. package/get-shit-done/workflows/insert-phase.md +2 -2
  88. package/get-shit-done/workflows/manager.md +27 -26
  89. package/get-shit-done/workflows/map-codebase.md +10 -32
  90. package/get-shit-done/workflows/new-milestone.md +14 -8
  91. package/get-shit-done/workflows/new-project.md +48 -25
  92. package/get-shit-done/workflows/next.md +1 -1
  93. package/get-shit-done/workflows/note.md +1 -1
  94. package/get-shit-done/workflows/pause-work.md +73 -10
  95. package/get-shit-done/workflows/plan-milestone-gaps.md +2 -2
  96. package/get-shit-done/workflows/plan-phase.md +184 -32
  97. package/get-shit-done/workflows/progress.md +20 -20
  98. package/get-shit-done/workflows/quick.md +102 -84
  99. package/get-shit-done/workflows/research-phase.md +2 -6
  100. package/get-shit-done/workflows/resume-project.md +4 -4
  101. package/get-shit-done/workflows/review.md +56 -3
  102. package/get-shit-done/workflows/secure-phase.md +154 -0
  103. package/get-shit-done/workflows/settings.md +13 -2
  104. package/get-shit-done/workflows/ship.md +13 -4
  105. package/get-shit-done/workflows/transition.md +6 -6
  106. package/get-shit-done/workflows/ui-phase.md +4 -14
  107. package/get-shit-done/workflows/ui-review.md +25 -7
  108. package/get-shit-done/workflows/update.md +165 -16
  109. package/get-shit-done/workflows/validate-phase.md +1 -11
  110. package/get-shit-done/workflows/verify-phase.md +127 -6
  111. package/get-shit-done/workflows/verify-work.md +69 -21
  112. package/package.json +1 -1
@@ -0,0 +1,291 @@
1
+ <objective>
2
+ Power user mode for discuss-phase. Generates ALL questions upfront into a JSON state file and an HTML companion UI, then waits for the user to answer at their own pace. When the user signals readiness, processes all answers in one pass and generates CONTEXT.md.
3
+
4
+ **When to use:** Large phases with many gray areas, or when users prefer to answer questions offline / asynchronously rather than interactively in the chat session.
5
+ </objective>
6
+
7
+ <trigger>
8
+ This workflow executes when `--power` flag is present in ARGUMENTS to `/gsd-discuss-phase`.
9
+
10
+ The caller (discuss-phase.md) has already:
11
+ - Validated the phase exists
12
+ - Provided init context: `phase_dir`, `padded_phase`, `phase_number`, `phase_name`, `phase_slug`
13
+
14
+ Begin at **Step 1** immediately.
15
+ </trigger>
16
+
17
+ <step name="analyze">
18
+ Run the same gray area identification as standard discuss-phase mode.
19
+
20
+ 1. Load prior context (PROJECT.md, REQUIREMENTS.md, STATE.md, prior CONTEXT.md files)
21
+ 2. Scout codebase for reusable assets and patterns relevant to this phase
22
+ 3. read the phase goal from ROADMAP.md
23
+ 4. Identify ALL gray areas — specific implementation decisions the user should weigh in on
24
+ 5. For each gray area, generate 2–4 concrete options with tradeoff descriptions
25
+
26
+ Group questions by topic into sections (e.g., "Visual Style", "Data Model", "Interactions", "Error Handling"). Each section should have 2–6 questions.
27
+
28
+ Do NOT ask the user anything at this stage. Capture everything internally, then proceed to generate.
29
+ </step>
30
+
31
+ <step name="generate_json">
32
+ write all questions to:
33
+
34
+ ```
35
+ {phase_dir}/{padded_phase}-QUESTIONS.json
36
+ ```
37
+
38
+ **JSON structure:**
39
+
40
+ ```json
41
+ {
42
+ "phase": "{padded_phase}-{phase_slug}",
43
+ "generated_at": "ISO-8601 timestamp",
44
+ "stats": {
45
+ "total": 0,
46
+ "answered": 0,
47
+ "chat_more": 0,
48
+ "remaining": 0
49
+ },
50
+ "sections": [
51
+ {
52
+ "id": "section-slug",
53
+ "title": "Section Title",
54
+ "questions": [
55
+ {
56
+ "id": "Q-01",
57
+ "title": "Short question title",
58
+ "context": "Codebase info, prior decisions, or constraints relevant to this question",
59
+ "options": [
60
+ {
61
+ "id": "a",
62
+ "label": "Option label",
63
+ "description": "Tradeoff or elaboration for this option"
64
+ },
65
+ {
66
+ "id": "b",
67
+ "label": "Another option",
68
+ "description": "Tradeoff or elaboration"
69
+ },
70
+ {
71
+ "id": "c",
72
+ "label": "Custom",
73
+ "description": ""
74
+ }
75
+ ],
76
+ "answer": null,
77
+ "chat_more": "",
78
+ "status": "unanswered"
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ }
84
+ ```
85
+
86
+ **Field rules:**
87
+ - `stats.total`: count of all questions across all sections
88
+ - `stats.answered`: count where `answer` is not null and not empty string
89
+ - `stats.chat_more`: count where `chat_more` has content
90
+ - `stats.remaining`: `total - answered`
91
+ - `question.id`: sequential across all sections — Q-01, Q-02, Q-03, ...
92
+ - `question.context`: concrete codebase or prior-decision annotation (not generic)
93
+ - `question.answer`: null until user sets it; once answered, the selected option id or free-text
94
+ - `question.status`: "unanswered" | "answered" | "chat-more" (has chat_more but no answer yet)
95
+ </step>
96
+
97
+ <step name="generate_html">
98
+ write a self-contained HTML companion file to:
99
+
100
+ ```
101
+ {phase_dir}/{padded_phase}-QUESTIONS.html
102
+ ```
103
+
104
+ The file must be a single self-contained HTML file with inline CSS and JavaScript. No external dependencies.
105
+
106
+ **Layout:**
107
+
108
+ ```
109
+ ┌─────────────────────────────────────────────────────┐
110
+ │ Phase {N}: {phase_name} — Discussion Questions │
111
+ │ ┌──────────────────────────────────────────────┐ │
112
+ │ │ 12 total | 3 answered | 9 remaining │ │
113
+ │ └──────────────────────────────────────────────┘ │
114
+ ├─────────────────────────────────────────────────────┤
115
+ │ ▼ Visual Style (3 questions) │
116
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
117
+ │ │ Q-01 │ │ Q-02 │ │ Q-03 │ │
118
+ │ │ Layout │ │ Density │ │ Colors │ │
119
+ │ │ ... │ │ ... │ │ ... │ │
120
+ │ └──────────┘ └──────────┘ └──────────┘ │
121
+ │ ▼ Data Model (2 questions) │
122
+ │ ... │
123
+ └─────────────────────────────────────────────────────┘
124
+ ```
125
+
126
+ **Stats bar:**
127
+ - Total questions, answered count, remaining count
128
+ - A simple CSS progress bar (green fill = answered / total)
129
+
130
+ **Section headers:**
131
+ - Collapsible via click — show/hide questions in the section
132
+ - Show answered count for the section (e.g., "2/4 answered")
133
+
134
+ **question cards (3-column grid):**
135
+ Each card contains:
136
+ - question ID badge (e.g., "Q-01") and title
137
+ - Context annotation (gray italic text)
138
+ - Option list: radio buttons with bold label + description text
139
+ - Chat more textarea (orange border when content present)
140
+ - Card highlighted green when answered
141
+
142
+ **JavaScript behavior:**
143
+ - On radio button select: mark question as answered in page state; update stats bar
144
+ - On textarea input: update chat_more content in page state; show orange border if content present
145
+ - "Save answers" button at top and bottom: serializes page state back to the JSON file path
146
+
147
+ **Save mechanism:**
148
+ The Save button writes the updated JSON back using the File System Access API if available, otherwise generates a downloadable JSON file the user can save over the original. Include clear instructions in the UI:
149
+
150
+ ```
151
+ After answering, click "Save answers" — or download the JSON and replace the original file.
152
+ Then return to OpenCode and say "refresh" to process your answers.
153
+ ```
154
+
155
+ **Answered question styling:**
156
+ - Card border: `2px solid #22c55e` (green)
157
+ - Card background: `#f0fdf4` (light green tint)
158
+
159
+ **Unanswered question styling:**
160
+ - Card border: `1px solid #e2e8f0` (gray)
161
+ - Card background: `white`
162
+
163
+ **Chat more textarea:**
164
+ - Placeholder: "Add context, nuance, or clarification for this question..."
165
+ - Normal border: `1px solid #e2e8f0`
166
+ - Active (has content) border: `2px solid #f97316` (orange)
167
+ </step>
168
+
169
+ <step name="notify_user">
170
+ After writing both files, print this message to the user:
171
+
172
+ ```
173
+ Questions ready for Phase {N}: {phase_name}
174
+
175
+ HTML (open in browser/IDE): {phase_dir}/{padded_phase}-QUESTIONS.html
176
+ JSON (state file): {phase_dir}/{padded_phase}-QUESTIONS.json
177
+
178
+ {total} questions across {section_count} topics.
179
+
180
+ Open the HTML file, answer the questions at your own pace, then save.
181
+
182
+ When ready, tell me:
183
+ "refresh" — process your answers and update the file
184
+ "finalize" — generate CONTEXT.md from all answered questions
185
+ "explain Q-05" — elaborate on a specific question
186
+ "exit power mode" — return to standard one-by-one discussion (answers carry over)
187
+ ```
188
+ </step>
189
+
190
+ <step name="wait_loop">
191
+ Enter wait mode. OpenCode listens for user commands and handles each:
192
+
193
+ ---
194
+
195
+ **"refresh"** (or "process answers", "update", "re-read"):
196
+
197
+ 1. read `{phase_dir}/{padded_phase}-QUESTIONS.json`
198
+ 2. Recalculate stats: count answered, chat_more, remaining
199
+ 3. write updated stats back to the JSON
200
+ 4. Re-generate the HTML file with the updated state (answered cards highlighted green, progress bar updated)
201
+ 5. Report to user:
202
+
203
+ ```
204
+ Refreshed. Updated state:
205
+ Answered: {answered} / {total}
206
+ Remaining: {remaining}
207
+ Chat-more: {chat_more}
208
+
209
+ {phase_dir}/{padded_phase}-QUESTIONS.html updated.
210
+
211
+ Answer more questions, then say "refresh" again, or say "finalize" when done.
212
+ ```
213
+
214
+ ---
215
+
216
+ **"finalize"** (or "done", "generate context", "write context"):
217
+
218
+ Proceed to the **finalize** step.
219
+
220
+ ---
221
+
222
+ **"explain Q-{N}"** (or "more info on Q-{N}", "elaborate Q-{N}"):
223
+
224
+ 1. Find the question by ID in the JSON
225
+ 2. Provide a detailed explanation: why this decision matters, how it affects the downstream plan, what additional context from the codebase is relevant
226
+ 3. Return to wait mode
227
+
228
+ ---
229
+
230
+ **"exit power mode"** (or "switch to interactive"):
231
+
232
+ 1. read all currently answered questions from JSON
233
+ 2. Load answers into the internal accumulator as if they were answered interactively
234
+ 3. Continue with standard `discuss_areas` step from discuss-phase.md for any unanswered questions
235
+ 4. Generate CONTEXT.md as normal
236
+
237
+ ---
238
+
239
+ **Any other message:**
240
+ Respond helpfully, then remind the user of available commands:
241
+ ```
242
+ (Power mode active — say "refresh", "finalize", "explain Q-N", or "exit power mode")
243
+ ```
244
+ </step>
245
+
246
+ <step name="finalize">
247
+ Process all answered questions from the JSON file and generate CONTEXT.md.
248
+
249
+ 1. read `{phase_dir}/{padded_phase}-QUESTIONS.json`
250
+ 2. Filter to questions where `answer` is not null/empty
251
+ 3. Group decisions by section
252
+ 4. For each answered question, format as a decision entry:
253
+ - Decision: the selected option label (or custom text if free-form answer)
254
+ - Rationale: the option description, plus `chat_more` content if present
255
+ - Status: "Decided" if fully answered, "Needs clarification" if only chat_more with no option selected
256
+
257
+ 5. write CONTEXT.md using the standard context template format:
258
+ - `<decisions>` section with all answered questions grouped by section
259
+ - `<deferred_ideas>` section for unanswered questions (carry forward for future discussion)
260
+ - `<specifics>` section for any chat_more content that adds nuance
261
+ - `<code_context>` section with reusable assets found during analysis
262
+ - `<canonical_refs>` section (MANDATORY — paths to relevant specs/docs)
263
+
264
+ 6. If fewer than 50% of questions were answered, warn the user:
265
+ ```
266
+ Warning: Only {answered}/{total} questions answered ({pct}%).
267
+ CONTEXT.md generated with available decisions. Unanswered questions listed as deferred.
268
+ Consider running /gsd-discuss-phase {N} again to refine before planning.
269
+ ```
270
+
271
+ 7. Print completion message:
272
+ ```
273
+ CONTEXT.md written: {phase_dir}/{padded_phase}-CONTEXT.md
274
+
275
+ Decisions captured: {answered}
276
+ Deferred: {remaining}
277
+
278
+ Next step: /gsd-plan-phase {N}
279
+ ```
280
+ </step>
281
+
282
+ <success_criteria>
283
+ - Questions generated into well-structured JSON covering all identified gray areas
284
+ - HTML companion file is self-contained and usable without a server
285
+ - Stats bar accurately reflects answered/remaining counts after each refresh
286
+ - Answered questions highlighted green in HTML
287
+ - CONTEXT.md generated in the same format as standard discuss-phase output
288
+ - Unanswered questions preserved as deferred items (not silently dropped)
289
+ - `canonical_refs` section always present in CONTEXT.md (MANDATORY)
290
+ - User knows how to refresh, finalize, explain, or exit power mode
291
+ </success_criteria>
@@ -4,6 +4,12 @@ Extract implementation decisions that downstream agents need. Analyze the phase
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
5
  </objective>
6
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>
12
+
7
13
  <downstream_awareness>
8
14
  **CONTEXT.md feeds into:**
9
15
 
@@ -137,7 +143,9 @@ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
137
143
  AGENT_SKILLS_ADVISOR=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-advisor 2>/dev/null)
138
144
  ```
139
145
 
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`.
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.
141
149
 
142
150
  **If `phase_found` is false:**
143
151
  ```
@@ -149,12 +157,46 @@ Exit workflow.
149
157
 
150
158
  **If `phase_found` is true:** Continue to check_existing.
151
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
+
152
165
  **Auto mode** — If `--auto` is present in ARGUMENTS:
153
166
  - In `check_existing`: auto-select "Skip" (if context exists) or continue without prompting (if no context/plans)
154
167
  - In `present_gray_areas`: auto-select ALL gray areas without asking the user
155
168
  - In `discuss_areas`: for each discussion question, choose the recommended option (first option, or the one marked "recommended") without using question
156
169
  - Log each auto-selected choice inline so the user can review decisions in the context file
157
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`.
158
200
  </step>
159
201
 
160
202
  <step name="check_existing">
@@ -182,6 +224,26 @@ If "Skip": Exit workflow
182
224
 
183
225
  **If doesn't exist:**
184
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
+
185
247
  Check `has_plans` and `plan_count` from init. **If `has_plans` is true:**
186
248
 
187
249
  **If `--auto`:** Auto-select "Continue and replan after". Log: `[auto] Plans exist — continuing with context capture, will replan after.`
@@ -640,6 +702,16 @@ Each answer (or answer set, in batch mode) should reveal the next question or ne
640
702
  ```
641
703
  After all areas are auto-resolved, skip the "Explore more gray areas" prompt and proceed directly to write_context.
642
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
+
643
715
  **Interactive mode (no `--auto`):**
644
716
 
645
717
  **For each area:**
@@ -719,6 +791,44 @@ Back to [current area]: [return to current question]"
719
791
 
720
792
  Track deferred ideas internally.
721
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
+
722
832
  **Track discussion log data internally:**
723
833
  For each question asked, accumulate:
724
834
  - Area name
@@ -873,13 +983,14 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
873
983
 
874
984
  **Phase ${PHASE}: [Name]** — [Goal from ROADMAP.md]
875
985
 
876
- `/gsd-plan-phase ${PHASE} ${GSD_WS}`
986
+ `/new` then:
877
987
 
878
- *`/new` first → fresh context window*
988
+ `/gsd-plan-phase ${PHASE} ${GSD_WS}`
879
989
 
880
990
  ---
881
991
 
882
992
  **Also available:**
993
+ - `/gsd-discuss-phase ${PHASE} --chain ${GSD_WS}` — re-run with auto plan+execute after
883
994
  - `/gsd-plan-phase ${PHASE} --skip-research ${GSD_WS}` — plan without research
884
995
  - `/gsd-ui-phase ${PHASE} ${GSD_WS}` — generate UI design contract before planning (if phase has frontend work)
885
996
  - Review/edit CONTEXT.md before continuing
@@ -933,6 +1044,12 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
933
1044
 
934
1045
  write file.
935
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
+
936
1053
  Commit phase context and discussion log:
937
1054
 
938
1055
  ```bash
@@ -961,10 +1078,10 @@ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" commit "docs(state
961
1078
  <step name="auto_advance">
962
1079
  Check for auto-advance trigger:
963
1080
 
964
- 1. Parse `--auto` flag from $ARGUMENTS
965
- 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):
966
1083
  ```bash
967
- if [[ ! "$ARGUMENTS" =~ --auto ]]; then
1084
+ if [[ ! "$ARGUMENTS" =~ --auto ]] && [[ ! "$ARGUMENTS" =~ --chain ]]; then
968
1085
  node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
969
1086
  fi
970
1087
  ```
@@ -974,12 +1091,12 @@ Check for auto-advance trigger:
974
1091
  AUTO_CFG=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
975
1092
  ```
976
1093
 
977
- **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):
978
1095
  ```bash
979
1096
  node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true
980
1097
  ```
981
1098
 
982
- **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:**
983
1100
 
984
1101
  Display banner:
985
1102
  ```
@@ -1006,8 +1123,9 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
1006
1123
 
1007
1124
  Auto-advance pipeline finished: discuss → plan → execute
1008
1125
 
1009
- Next: /gsd-discuss-phase ${NEXT_PHASE} --auto ${GSD_WS}
1010
- */new first → fresh context window*
1126
+ /new then:
1127
+
1128
+ Next: /gsd-discuss-phase ${NEXT_PHASE} ${WAS_CHAIN ? "--chain" : "--auto"} ${GSD_WS}
1011
1129
  ```
1012
1130
  - **PLANNING COMPLETE** → Planning done, execution didn't complete:
1013
1131
  ```
@@ -1025,12 +1143,27 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
1025
1143
  Continue: /gsd-plan-phase ${PHASE} --gaps ${GSD_WS}
1026
1144
  ```
1027
1145
 
1028
- **If neither `--auto` nor config enabled:**
1146
+ **If none of `--auto`, `--chain`, nor config enabled:**
1029
1147
  Route to `confirm_creation` step (existing behavior — show manual next steps).
1030
1148
  </step>
1031
1149
 
1032
1150
  </process>
1033
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
+
1034
1167
  <success_criteria>
1035
1168
  - Phase validated against roadmap
1036
1169
  - Prior context loaded (PROJECT.md, REQUIREMENTS.md, STATE.md, prior CONTEXT.md files)
@@ -1046,4 +1179,9 @@ Route to `confirm_creation` step (existing behavior — show manual next steps).
1046
1179
  - Deferred ideas preserved for future phases
1047
1180
  - STATE.md updated with session info
1048
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
1049
1187
  </success_criteria>