gsd-opencode 1.10.2 → 1.20.1

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 (164) hide show
  1. package/agents/gsd-codebase-mapper.md +29 -3
  2. package/agents/gsd-debugger.md +19 -21
  3. package/agents/gsd-executor.md +213 -528
  4. package/agents/gsd-integration-checker.md +20 -0
  5. package/agents/gsd-phase-researcher.md +189 -267
  6. package/agents/gsd-plan-checker.md +278 -279
  7. package/agents/gsd-planner.md +299 -490
  8. package/agents/gsd-project-researcher.md +103 -345
  9. package/agents/gsd-research-synthesizer.md +5 -22
  10. package/agents/gsd-roadmapper.md +43 -6
  11. package/agents/gsd-verifier.md +158 -377
  12. package/{lib → bin/dm/lib}/constants.js +10 -3
  13. package/{src → bin/dm/src}/commands/install.js +5 -4
  14. package/{src → bin/dm/src}/commands/uninstall.js +3 -1
  15. package/{src → bin/dm/src}/services/backup-manager.js +1 -1
  16. package/{src → bin/dm/src}/services/config.js +1 -1
  17. package/{src → bin/dm/src}/services/file-ops.js +20 -4
  18. package/{src → bin/dm/src}/services/health-checker.js +3 -1
  19. package/{src → bin/dm/src}/services/repair-service.js +3 -1
  20. package/{src → bin/dm/src}/services/settings.js +1 -1
  21. package/{src → bin/dm/src}/services/update-service.js +2 -2
  22. package/bin/gsd-install.js +0 -0
  23. package/bin/gsd.js +9 -9
  24. package/commands/gsd/gsd-add-phase.md +43 -0
  25. package/commands/gsd/gsd-add-todo.md +47 -0
  26. package/commands/gsd/gsd-audit-milestone.md +36 -0
  27. package/commands/gsd/gsd-check-todos.md +45 -0
  28. package/commands/gsd/gsd-cleanup.md +18 -0
  29. package/commands/gsd/{complete-milestone.md → gsd-complete-milestone.md} +1 -1
  30. package/commands/gsd/{debug.md → gsd-debug.md} +16 -21
  31. package/commands/gsd/{discuss-phase.md → gsd-discuss-phase.md} +6 -9
  32. package/commands/gsd/gsd-execute-phase.md +41 -0
  33. package/commands/gsd/gsd-health.md +22 -0
  34. package/commands/gsd/gsd-help.md +22 -0
  35. package/commands/gsd/gsd-insert-phase.md +32 -0
  36. package/commands/gsd/gsd-join-discord.md +18 -0
  37. package/commands/gsd/{list-phase-assumptions.md → gsd-list-phase-assumptions.md} +3 -7
  38. package/commands/gsd/{map-codebase.md → gsd-map-codebase.md} +3 -3
  39. package/commands/gsd/gsd-new-milestone.md +44 -0
  40. package/commands/gsd/gsd-new-project.md +42 -0
  41. package/commands/gsd/gsd-pause-work.md +38 -0
  42. package/commands/gsd/gsd-plan-milestone-gaps.md +34 -0
  43. package/commands/gsd/gsd-plan-phase.md +44 -0
  44. package/commands/gsd/gsd-progress.md +24 -0
  45. package/commands/gsd/gsd-quick.md +41 -0
  46. package/commands/gsd/gsd-reapply-patches.md +119 -0
  47. package/commands/gsd/gsd-remove-phase.md +31 -0
  48. package/commands/gsd/{research-phase.md → gsd-research-phase.md} +38 -49
  49. package/commands/gsd/{resume-work.md → gsd-resume-work.md} +2 -2
  50. package/commands/gsd/gsd-set-profile.md +34 -0
  51. package/commands/gsd/gsd-settings.md +36 -0
  52. package/commands/gsd/gsd-update.md +37 -0
  53. package/commands/gsd/gsd-verify-work.md +38 -0
  54. package/get-shit-done/bin/gsd-tools.cjs +553 -0
  55. package/get-shit-done/bin/gsd-tools.test.cjs +2346 -0
  56. package/get-shit-done/bin/lib/commands.cjs +556 -0
  57. package/get-shit-done/bin/lib/config.cjs +162 -0
  58. package/get-shit-done/bin/lib/core.cjs +377 -0
  59. package/get-shit-done/bin/lib/frontmatter.cjs +299 -0
  60. package/get-shit-done/bin/lib/init.cjs +694 -0
  61. package/get-shit-done/bin/lib/milestone.cjs +215 -0
  62. package/get-shit-done/bin/lib/phase.cjs +877 -0
  63. package/get-shit-done/bin/lib/roadmap.cjs +298 -0
  64. package/get-shit-done/bin/lib/state.cjs +490 -0
  65. package/get-shit-done/bin/lib/template.cjs +222 -0
  66. package/get-shit-done/bin/lib/verify.cjs +772 -0
  67. package/get-shit-done/references/checkpoints.md +62 -364
  68. package/get-shit-done/references/decimal-phase-calculation.md +65 -0
  69. package/get-shit-done/references/git-integration.md +10 -16
  70. package/get-shit-done/references/git-planning-commit.md +38 -0
  71. package/get-shit-done/references/model-profile-resolution.md +34 -0
  72. package/get-shit-done/references/model-profiles.md +54 -66
  73. package/get-shit-done/references/phase-argument-parsing.md +61 -0
  74. package/get-shit-done/references/planning-config.md +112 -10
  75. package/get-shit-done/references/questioning.md +4 -0
  76. package/get-shit-done/references/ui-brand.md +1 -1
  77. package/get-shit-done/templates/UAT.md +1 -1
  78. package/get-shit-done/templates/VALIDATION.md +104 -0
  79. package/get-shit-done/templates/codebase/structure.md +6 -6
  80. package/get-shit-done/templates/config.json +37 -0
  81. package/get-shit-done/templates/context.md +2 -10
  82. package/get-shit-done/templates/continue-here.md +6 -6
  83. package/get-shit-done/templates/debug-subagent-prompt.md +2 -2
  84. package/get-shit-done/templates/discovery.md +6 -6
  85. package/get-shit-done/templates/milestone-archive.md +3 -3
  86. package/get-shit-done/templates/phase-prompt.md +9 -7
  87. package/get-shit-done/templates/planner-subagent-prompt.md +6 -6
  88. package/get-shit-done/templates/research-project/ARCHITECTURE.md +1 -1
  89. package/get-shit-done/templates/research.md +29 -6
  90. package/get-shit-done/templates/roadmap.md +1 -1
  91. package/get-shit-done/templates/state.md +0 -30
  92. package/get-shit-done/templates/summary-complex.md +59 -0
  93. package/get-shit-done/templates/summary-minimal.md +41 -0
  94. package/get-shit-done/templates/summary-standard.md +48 -0
  95. package/get-shit-done/templates/summary.md +16 -37
  96. package/get-shit-done/templates/user-setup.md +1 -13
  97. package/get-shit-done/templates/verification-report.md +5 -5
  98. package/get-shit-done/workflows/add-phase.md +111 -0
  99. package/{commands/gsd → get-shit-done/workflows}/add-todo.md +24 -60
  100. package/{commands/gsd → get-shit-done/workflows}/audit-milestone.md +83 -63
  101. package/{commands/gsd → get-shit-done/workflows}/check-todos.md +21 -73
  102. package/get-shit-done/workflows/cleanup.md +152 -0
  103. package/get-shit-done/workflows/complete-milestone.md +251 -312
  104. package/get-shit-done/workflows/diagnose-issues.md +6 -31
  105. package/get-shit-done/workflows/discovery-phase.md +11 -11
  106. package/get-shit-done/workflows/discuss-phase.md +156 -49
  107. package/get-shit-done/workflows/execute-phase.md +238 -396
  108. package/get-shit-done/workflows/execute-plan.md +180 -1609
  109. package/get-shit-done/workflows/health.md +156 -0
  110. package/{commands/gsd → get-shit-done/workflows}/help.md +33 -35
  111. package/get-shit-done/workflows/insert-phase.md +129 -0
  112. package/get-shit-done/workflows/list-phase-assumptions.md +3 -3
  113. package/get-shit-done/workflows/map-codebase.md +73 -80
  114. package/get-shit-done/workflows/new-milestone.md +382 -0
  115. package/{commands/gsd → get-shit-done/workflows}/new-project.md +281 -234
  116. package/get-shit-done/workflows/oc-set-profile.md +320 -0
  117. package/{commands/gsd → get-shit-done/workflows}/pause-work.md +31 -43
  118. package/{commands/gsd → get-shit-done/workflows}/plan-milestone-gaps.md +29 -50
  119. package/get-shit-done/workflows/plan-phase.md +478 -0
  120. package/{commands/gsd → get-shit-done/workflows}/progress.md +64 -47
  121. package/get-shit-done/workflows/quick.md +453 -0
  122. package/get-shit-done/workflows/remove-phase.md +154 -0
  123. package/get-shit-done/workflows/research-phase.md +73 -0
  124. package/get-shit-done/workflows/resume-project.md +17 -26
  125. package/get-shit-done/workflows/set-profile.md +80 -0
  126. package/get-shit-done/workflows/settings.md +213 -0
  127. package/get-shit-done/workflows/transition.md +84 -104
  128. package/{commands/gsd → get-shit-done/workflows}/update.md +70 -28
  129. package/get-shit-done/workflows/verify-phase.md +106 -492
  130. package/get-shit-done/workflows/verify-work.md +26 -53
  131. package/package.json +7 -4
  132. package/rules/gsd-oc-work-hard.md +36 -0
  133. package/skills/gsd-oc-select-model/SKILL.md +348 -0
  134. package/skills/gsd-oc-select-model/scripts/select-models.cjs +268 -0
  135. package/agents/gsd-set-model.md +0 -287
  136. package/agents/gsd-set-profile.md +0 -239
  137. package/agents/gsd-settings.md +0 -749
  138. package/bin/install.js +0 -323
  139. package/commands/gsd/add-phase.md +0 -207
  140. package/commands/gsd/execute-phase.md +0 -339
  141. package/commands/gsd/insert-phase.md +0 -227
  142. package/commands/gsd/new-milestone.md +0 -721
  143. package/commands/gsd/plan-phase.md +0 -525
  144. package/commands/gsd/quick.md +0 -309
  145. package/commands/gsd/remove-phase.md +0 -349
  146. package/commands/gsd/set-model.md +0 -77
  147. package/commands/gsd/set-profile.md +0 -46
  148. package/commands/gsd/settings.md +0 -33
  149. package/commands/gsd/verify-work.md +0 -219
  150. package/commands/gsd/whats-new.md +0 -124
  151. /package/{src → bin/dm/src}/commands/check.js +0 -0
  152. /package/{src → bin/dm/src}/commands/config.js +0 -0
  153. /package/{src → bin/dm/src}/commands/list.js +0 -0
  154. /package/{src → bin/dm/src}/commands/repair.js +0 -0
  155. /package/{src → bin/dm/src}/commands/update.js +0 -0
  156. /package/{src → bin/dm/src}/services/manifest-manager.js +0 -0
  157. /package/{src → bin/dm/src}/services/migration-service.js +0 -0
  158. /package/{src → bin/dm/src}/services/scope-manager.js +0 -0
  159. /package/{src → bin/dm/src}/services/structure-detector.js +0 -0
  160. /package/{src → bin/dm/src}/utils/hash.js +0 -0
  161. /package/{src → bin/dm/src}/utils/interactive.js +0 -0
  162. /package/{src → bin/dm/src}/utils/logger.js +0 -0
  163. /package/{src → bin/dm/src}/utils/npm-registry.js +0 -0
  164. /package/{src → bin/dm/src}/utils/path-resolver.js +0 -0
@@ -11,1255 +11,283 @@ read config.json for planning behavior settings.
11
11
 
12
12
  <process>
13
13
 
14
- <step name="resolve_model_profile" priority="first">
15
- read model profile for agent spawning:
14
+ <step name="init_context" priority="first">
15
+ Load execution context (paths only to minimize orchestrator context):
16
16
 
17
17
  ```bash
18
- MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
18
+ INIT=$(node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs init execute-phase "${PHASE}")
19
19
  ```
20
20
 
21
- Default to "balanced" if not set.
21
+ Extract from init JSON: `executor_model`, `commit_docs`, `phase_dir`, `phase_number`, `plans`, `summaries`, `incomplete_plans`, `state_path`, `config_path`.
22
22
 
23
- **Model lookup table:**
24
-
25
- | Agent | quality | balanced | budget |
26
- |-------|---------|----------|--------|
27
- | gsd-executor | opus | sonnet | sonnet |
28
-
29
- Store resolved model for use in Task calls below.
30
- </step>
31
-
32
- <step name="load_project_state">
33
- Before any operation, read project state:
34
-
35
- ```bash
36
- cat .planning/STATE.md 2>/dev/null
37
- ```
38
-
39
- **If file exists:** Parse and internalize:
40
-
41
- - Current position (phase, plan, status)
42
- - Accumulated decisions (constraints on this execution)
43
- - Blockers/concerns (things to watch for)
44
- - Brief alignment status
45
-
46
- **If file missing but .planning/ exists:**
47
-
48
- ```
49
- STATE.md missing but planning artifacts exist.
50
- Options:
51
- 1. Reconstruct from existing artifacts
52
- 2. Continue without project state (may lose accumulated context)
53
- ```
54
-
55
- **If .planning/ doesn't exist:** Error - project not initialized.
56
-
57
- This ensures every execution has full project context.
58
-
59
- **Load planning config:**
60
-
61
- ```bash
62
- # Check if planning docs should be committed (default: true)
63
- COMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
64
- # Auto-detect gitignored (overrides config)
65
- git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=false
66
- ```
67
-
68
- Store `COMMIT_PLANNING_DOCS` for use in git operations.
23
+ If `.planning/` missing: error.
69
24
  </step>
70
25
 
71
26
  <step name="identify_plan">
72
- Find the next plan to execute:
73
- - Check roadmap for "In progress" phase
74
- - Find plans in that phase directory
75
- - Identify first plan without corresponding SUMMARY
76
-
77
27
  ```bash
78
- cat .planning/ROADMAP.md
79
- # Look for phase with "In progress" status
80
- # Then find plans in that phase
28
+ # Use plans/summaries from INIT JSON, or list files
81
29
  ls .planning/phases/XX-name/*-PLAN.md 2>/dev/null | sort
82
30
  ls .planning/phases/XX-name/*-SUMMARY.md 2>/dev/null | sort
83
31
  ```
84
32
 
85
- **Logic:**
86
-
87
- - If `01-01-PLAN.md` exists but `01-01-SUMMARY.md` doesn't → execute 01-01
88
- - If `01-01-SUMMARY.md` exists but `01-02-SUMMARY.md` doesn't → execute 01-02
89
- - Pattern: Find first PLAN file without matching SUMMARY file
90
-
91
- **Decimal phase handling:**
92
-
93
- Phase directories can be integer or decimal format:
94
-
95
- - Integer: `.planning/phases/01-foundation/01-01-PLAN.md`
96
- - Decimal: `.planning/phases/01.1-hotfix/01.1-01-PLAN.md`
97
-
98
- Parse phase number from path (handles both formats):
33
+ Find first PLAN without matching SUMMARY. Decimal phases supported (`01.1-hotfix/`):
99
34
 
100
35
  ```bash
101
- # Extract phase number (handles XX or XX.Y format)
102
36
  PHASE=$(echo "$PLAN_PATH" | grep -oE '[0-9]+(\.[0-9]+)?-[0-9]+')
37
+ # config settings can be fetched via gsd-tools config-get if needed
103
38
  ```
104
39
 
105
- SUMMARY naming follows same pattern:
106
-
107
- - Integer: `01-01-SUMMARY.md`
108
- - Decimal: `01.1-01-SUMMARY.md`
109
-
110
- Confirm with user if ambiguous.
111
-
112
- <config-check>
113
- ```bash
114
- cat .planning/config.json 2>/dev/null
115
- ```
116
- </config-check>
117
-
118
40
  <if mode="yolo">
119
- ```
120
- ⚡ Auto-approved: Execute {phase}-{plan}-PLAN.md
121
- [Plan X of Y for Phase Z]
122
-
123
- Starting execution...
124
- ```
125
-
126
- Proceed directly to parse_segments step.
41
+ Auto-approve: `⚡ Execute {phase}-{plan}-PLAN.md [Plan X of Y for Phase Z]` → parse_segments.
127
42
  </if>
128
43
 
129
44
  <if mode="interactive" OR="custom with gates.execute_next_plan true">
130
- Present:
131
-
132
- ```
133
- Found plan to execute: {phase}-{plan}-PLAN.md
134
- [Plan X of Y for Phase Z]
135
-
136
- Proceed with execution?
137
- ```
138
-
139
- Wait for confirmation before proceeding.
45
+ Present plan identification, wait for confirmation.
140
46
  </if>
141
47
  </step>
142
48
 
143
49
  <step name="record_start_time">
144
- Record execution start time for performance tracking:
145
-
146
50
  ```bash
147
51
  PLAN_START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
148
52
  PLAN_START_EPOCH=$(date +%s)
149
53
  ```
150
-
151
- Store in shell variables for duration calculation at completion.
152
54
  </step>
153
55
 
154
56
  <step name="parse_segments">
155
- **Intelligent segmentation: Parse plan into execution segments.**
156
-
157
- Plans are divided into segments by checkpoints. Each segment is routed to optimal execution context (subagent or main).
158
-
159
- **1. Check for checkpoints:**
160
-
161
57
  ```bash
162
- # Find all checkpoints and their types
163
58
  grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
164
59
  ```
165
60
 
166
- **2. Analyze execution strategy:**
167
-
168
- **If NO checkpoints found:**
169
-
170
- - **Fully autonomous plan** - spawn single subagent for entire plan
171
- - Subagent gets fresh 200k context, executes all tasks, creates SUMMARY, commits
172
- - Main context: Just orchestration (~5% usage)
173
-
174
- **If checkpoints found, parse into segments:**
175
-
176
- Segment = tasks between checkpoints (or start→first checkpoint, or last checkpoint→end)
177
-
178
- **For each segment, determine routing:**
179
-
180
- ```
181
- Segment routing rules:
182
-
183
- IF segment has no prior checkpoint:
184
- → SUBAGENT (first segment, nothing to depend on)
185
-
186
- IF segment follows checkpoint:human-verify:
187
- → SUBAGENT (verification is just confirmation, doesn't affect next work)
188
-
189
- IF segment follows checkpoint:decision OR checkpoint:human-action:
190
- → MAIN CONTEXT (next tasks need the decision/result)
191
- ```
192
-
193
- **3. Execution pattern:**
194
-
195
- **Pattern A: Fully autonomous (no checkpoints)**
196
-
197
- ```
198
- Spawn subagent → execute all tasks → SUMMARY → commit → report back
199
- ```
200
-
201
- **Pattern B: Segmented with verify-only checkpoints**
61
+ **Routing by checkpoint type:**
202
62
 
203
- ```
204
- Segment 1 (tasks 1-3): Spawn subagent → execute → report back
205
- Checkpoint 4 (human-verify): Main context you verify continue
206
- Segment 2 (tasks 5-6): Spawn NEW subagentexecutereport back
207
- Checkpoint 7 (human-verify): Main context you verify continue
208
- Aggregate results → SUMMARY → commit
209
- ```
210
-
211
- **Pattern C: Decision-dependent (must stay in main)**
212
-
213
- ```
214
- Checkpoint 1 (decision): Main context → you decide → continue in main
215
- Tasks 2-5: Main context (need decision from checkpoint 1)
216
- No segmentation benefit - execute entirely in main
217
- ```
218
-
219
- **4. Why this works:**
220
-
221
- **Segmentation benefits:**
222
-
223
- - Fresh context for each autonomous segment (0% start every time)
224
- - Main context only for checkpoints (~10-20% total)
225
- - Can handle 10+ task plans if properly segmented
226
- - Quality impossible to degrade in autonomous segments
227
-
228
- **When segmentation provides no benefit:**
229
-
230
- - Checkpoint is decision/human-action and following tasks depend on outcome
231
- - Better to execute sequentially in main than break flow
232
-
233
- **5. Implementation:**
234
-
235
- **For fully autonomous plans:**
236
-
237
- ```
238
- 1. Run init_agent_tracking step first (see step below)
239
-
240
- 2. Use Task tool with subagent_type="gsd-executor" and model="{executor_model}":
241
-
242
- Prompt: "Execute plan at .planning/phases/{phase}-{plan}-PLAN.md
243
-
244
- This is an autonomous plan (no checkpoints). Execute all tasks, create SUMMARY.md in phase directory, commit with message following plan's commit guidance.
245
-
246
- Follow all deviation rules and authentication gate protocols from the plan.
247
-
248
- When complete, report: plan name, tasks completed, SUMMARY path, commit hash."
249
-
250
- 3. After Task tool returns with agent_id:
251
-
252
- a. write agent_id to current-agent-id.txt:
253
- echo "[agent_id]" > .planning/current-agent-id.txt
254
-
255
- b. Append spawn entry to agent-history.json:
256
- {
257
- "agent_id": "[agent_id from Task response]",
258
- "task_description": "Execute full plan {phase}-{plan} (autonomous)",
259
- "phase": "{phase}",
260
- "plan": "{plan}",
261
- "segment": null,
262
- "timestamp": "[ISO timestamp]",
263
- "status": "spawned",
264
- "completion_timestamp": null
265
- }
266
-
267
- 4. Wait for subagent to complete
268
-
269
- 5. After subagent completes successfully:
270
-
271
- a. Update agent-history.json entry:
272
- - Find entry with matching agent_id
273
- - Set status: "completed"
274
- - Set completion_timestamp: "[ISO timestamp]"
275
-
276
- b. Clear current-agent-id.txt:
277
- rm .planning/current-agent-id.txt
278
-
279
- 6. Report completion to user
280
- ```
281
-
282
- **For segmented plans (has verify-only checkpoints):**
283
-
284
- ```
285
- Execute segment-by-segment:
63
+ | Checkpoints | Pattern | Execution |
64
+ |-------------|---------|-----------|
65
+ | None | A (autonomous) | Single subagent: full plan + SUMMARY + commit |
66
+ | Verify-only | B (segmented) | Segments between checkpoints. After none/human-verify SUBAGENT. After decision/human-action MAIN |
67
+ | Decision | C (main) | Execute entirely in main context |
286
68
 
287
- For each autonomous segment:
288
- Spawn subagent with prompt: "Execute tasks [X-Y] from plan at .planning/phases/{phase}-{plan}-PLAN.md. read the plan for full context and deviation rules. Do NOT create SUMMARY or commit - just execute these tasks and report results."
69
+ **Pattern A:** init_agent_tracking → spawn task(subagent_type="gsd-executor", model=executor_model) with prompt: execute plan at [path], autonomous, all tasks + SUMMARY + commit, follow deviation/auth rules, report: plan name, tasks, SUMMARY path, commit hash → track agent_id → wait → update tracking → report.
289
70
 
290
- Wait for subagent completion
71
+ **Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, create SUMMARY, commit. See segment_execution.
291
72
 
292
- For each checkpoint:
293
- Execute in main context
294
- Wait for user interaction
295
- Continue to next segment
73
+ **Pattern C:** Execute in main using standard flow (step name="execute").
296
74
 
297
- After all segments complete:
298
- Aggregate all results
299
- Create SUMMARY.md
300
- Commit with all changes
301
- ```
302
-
303
- **For decision-dependent plans:**
304
-
305
- ```
306
- Execute in main context (standard flow below)
307
- No subagent routing
308
- Quality maintained through small scope (2-3 tasks per plan)
309
- ```
310
-
311
- See step name="segment_execution" for detailed segment execution loop.
75
+ Fresh context per subagent preserves peak quality. Main context stays lean.
312
76
  </step>
313
77
 
314
78
  <step name="init_agent_tracking">
315
- **Initialize agent tracking for subagent resume capability.**
316
-
317
- Before spawning any subagents, set up tracking infrastructure:
318
-
319
- **1. Create/verify tracking files:**
320
-
321
79
  ```bash
322
- # Create agent history file if doesn't exist
323
80
  if [ ! -f .planning/agent-history.json ]; then
324
81
  echo '{"version":"1.0","max_entries":50,"entries":[]}' > .planning/agent-history.json
325
82
  fi
326
-
327
- # Clear any stale current-agent-id (from interrupted sessions)
328
- # Will be populated when subagent spawns
329
83
  rm -f .planning/current-agent-id.txt
330
- ```
331
-
332
- **2. Check for interrupted agents (resume detection):**
333
-
334
- ```bash
335
- # Check if current-agent-id.txt exists from previous interrupted session
336
84
  if [ -f .planning/current-agent-id.txt ]; then
337
85
  INTERRUPTED_ID=$(cat .planning/current-agent-id.txt)
338
86
  echo "Found interrupted agent: $INTERRUPTED_ID"
339
87
  fi
340
88
  ```
341
89
 
342
- **If interrupted agent found:**
343
- - The agent ID file exists from a previous session that didn't complete
344
- - This agent can potentially be resumed using Task tool's `resume` parameter
345
- - Present to user: "Previous session was interrupted. Resume agent [ID] or start fresh?"
346
- - If resume: Use Task tool with `resume` parameter set to the interrupted ID
347
- - If fresh: Clear the file and proceed normally
90
+ If interrupted: ask user to resume (task `resume` parameter) or start fresh.
348
91
 
349
- **3. Prune old entries (housekeeping):**
92
+ **Tracking protocol:** On spawn: write agent_id to `current-agent-id.txt`, append to agent-history.json: `{"agent_id":"[id]","task_description":"[desc]","phase":"[phase]","plan":"[plan]","segment":[num|null],"timestamp":"[ISO]","status":"spawned","completion_timestamp":null}`. On completion: status → "completed", set completion_timestamp, delete current-agent-id.txt. Prune: if entries > max_entries, remove oldest "completed" (never "spawned").
350
93
 
351
- If agent-history.json has more than `max_entries`:
352
- - Remove oldest entries with status "completed"
353
- - Never remove entries with status "spawned" (may need resume)
354
- - Keep file under size limit for fast reads
355
-
356
- **When to run this step:**
357
- - Pattern A (fully autonomous): Before spawning the single subagent
358
- - Pattern B (segmented): Before the segment execution loop
359
- - Pattern C (main context): Skip - no subagents spawned
94
+ Run for Pattern A/B before spawning. Pattern C: skip.
360
95
  </step>
361
96
 
362
97
  <step name="segment_execution">
363
- **Detailed segment execution loop for segmented plans.**
364
-
365
- **This step applies ONLY to segmented plans (Pattern B: has checkpoints, but they're verify-only).**
366
-
367
- For Pattern A (fully autonomous) and Pattern C (decision-dependent), skip this step.
368
-
369
- **Execution flow:**
370
-
371
- ````
372
- 1. Parse plan to identify segments:
373
- - read plan file
374
- - Find checkpoint locations: grep -n "type=\"checkpoint" PLAN.md
375
- - Identify checkpoint types: grep "type=\"checkpoint" PLAN.md | grep -o 'checkpoint:[^"]*'
376
- - Build segment map:
377
- * Segment 1: Start → first checkpoint (tasks 1-X)
378
- * Checkpoint 1: Type and location
379
- * Segment 2: After checkpoint 1 → next checkpoint (tasks X+1 to Y)
380
- * Checkpoint 2: Type and location
381
- * ... continue for all segments
382
-
383
- 2. For each segment in order:
98
+ Pattern B only (verify-only checkpoints). Skip for A/C.
384
99
 
385
- A. Determine routing (apply rules from parse_segments):
386
- - No prior checkpoint? → Subagent
387
- - Prior checkpoint was human-verify? Subagent
388
- - Prior checkpoint was decision/human-action? Main context
100
+ 1. Parse segment map: checkpoint locations and types
101
+ 2. Per segment:
102
+ - Subagent route: spawn gsd-executor for assigned tasks only. Prompt: task range, plan path, read full plan for context, execute assigned tasks, track deviations, NO SUMMARY/commit. Track via agent protocol.
103
+ - Main route: execute tasks using standard flow (step name="execute")
104
+ 3. After ALL segments: aggregate files/deviations/decisions → create SUMMARY.md → commit → self-check:
105
+ - Verify key-files.created exist on disk with `[ -f ]`
106
+ - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
107
+ - Append `## Self-Check: PASSED` or `## Self-Check: FAILED` to SUMMARY
389
108
 
390
- B. If routing = Subagent:
391
- ```
392
- Spawn Task tool with subagent_type="gsd-executor" and model="{executor_model}":
109
+ **Known OpenCode bug (classifyHandoffIfNeeded):** If any segment agent reports "failed" with `classifyHandoffIfNeeded is not defined`, this is a OpenCode runtime bug — not a real failure. Run spot-checks; if they pass, treat as successful.
393
110
 
394
- Prompt: "Execute tasks [task numbers/names] from plan at [plan path].
395
111
 
396
- **Context:**
397
- - read the full plan for objective, context files, and deviation rules
398
- - You are executing a SEGMENT of this plan (not the full plan)
399
- - Other segments will be executed separately
400
112
 
401
- **Your responsibilities:**
402
- - Execute only the tasks assigned to you
403
- - Follow all deviation rules and authentication gate protocols
404
- - Track deviations for later Summary
405
- - DO NOT create SUMMARY.md (will be created after all segments complete)
406
- - DO NOT commit (will be done after all segments complete)
407
113
 
408
- **Report back:**
409
- - Tasks completed
410
- - Files created/modified
411
- - Deviations encountered
412
- - Any issues or blockers"
413
-
414
- **After Task tool returns with agent_id:**
415
-
416
- 1. write agent_id to current-agent-id.txt:
417
- echo "[agent_id]" > .planning/current-agent-id.txt
418
-
419
- 2. Append spawn entry to agent-history.json:
420
- {
421
- "agent_id": "[agent_id from Task response]",
422
- "task_description": "Execute tasks [X-Y] from plan {phase}-{plan}",
423
- "phase": "{phase}",
424
- "plan": "{plan}",
425
- "segment": [segment_number],
426
- "timestamp": "[ISO timestamp]",
427
- "status": "spawned",
428
- "completion_timestamp": null
429
- }
430
-
431
- Wait for subagent to complete
432
- Capture results (files changed, deviations, etc.)
433
-
434
- **After subagent completes successfully:**
435
-
436
- 1. Update agent-history.json entry:
437
- - Find entry with matching agent_id
438
- - Set status: "completed"
439
- - Set completion_timestamp: "[ISO timestamp]"
440
-
441
- 2. Clear current-agent-id.txt:
442
- rm .planning/current-agent-id.txt
443
-
444
- ```
445
-
446
- C. If routing = Main context:
447
- Execute tasks in main using standard execution flow (step name="execute")
448
- Track results locally
449
-
450
- D. After segment completes (whether subagent or main):
451
- Continue to next checkpoint/segment
452
-
453
- 3. After ALL segments complete:
454
-
455
- A. Aggregate results from all segments:
456
- - Collect files created/modified from all segments
457
- - Collect deviations from all segments
458
- - Collect decisions from all checkpoints
459
- - Merge into complete picture
460
-
461
- B. Create SUMMARY.md:
462
- - Use aggregated results
463
- - Document all work from all segments
464
- - Include deviations from all segments
465
- - Note which segments were subagented
466
-
467
- C. Commit:
468
- - Stage all files from all segments
469
- - Stage SUMMARY.md
470
- - Commit with message following plan guidance
471
- - Include note about segmented execution if relevant
472
-
473
- D. Report completion
474
-
475
- **Example execution trace:**
476
-
477
- ````
478
-
479
- Plan: 01-02-PLAN.md (8 tasks, 2 verify checkpoints)
480
-
481
- Parsing segments...
482
-
483
- - Segment 1: Tasks 1-3 (autonomous)
484
- - Checkpoint 4: human-verify
485
- - Segment 2: Tasks 5-6 (autonomous)
486
- - Checkpoint 7: human-verify
487
- - Segment 3: Task 8 (autonomous)
488
-
489
- Routing analysis:
490
-
491
- - Segment 1: No prior checkpoint → SUBAGENT ✓
492
- - Checkpoint 4: Verify only → MAIN (required)
493
- - Segment 2: After verify → SUBAGENT ✓
494
- - Checkpoint 7: Verify only → MAIN (required)
495
- - Segment 3: After verify → SUBAGENT ✓
496
-
497
- Execution:
498
- [1] Spawning subagent for tasks 1-3...
499
- → Subagent completes: 3 files modified, 0 deviations
500
- [2] Executing checkpoint 4 (human-verify)...
501
- ╔═══════════════════════════════════════════════════════╗
502
- ║ CHECKPOINT: Verification Required ║
503
- ╚═══════════════════════════════════════════════════════╝
504
-
505
- Progress: 3/8 tasks complete
506
- Task: Verify database schema
507
-
508
- Built: User and Session tables with relations
509
-
510
- How to verify:
511
- 1. Check src/db/schema.ts for correct types
512
-
513
- ────────────────────────────────────────────────────────
514
- → YOUR ACTION: Type "approved" or describe issues
515
- ────────────────────────────────────────────────────────
516
- User: "approved"
517
- [3] Spawning subagent for tasks 5-6...
518
- → Subagent completes: 2 files modified, 1 deviation (added error handling)
519
- [4] Executing checkpoint 7 (human-verify)...
520
- User: "approved"
521
- [5] Spawning subagent for task 8...
522
- → Subagent completes: 1 file modified, 0 deviations
523
-
524
- Aggregating results...
525
-
526
- - Total files: 6 modified
527
- - Total deviations: 1
528
- - Segmented execution: 3 subagents, 2 checkpoints
529
-
530
- Creating SUMMARY.md...
531
- Committing...
532
- ✓ Complete
533
-
534
- ````
535
-
536
- **Benefits of this pattern:**
537
- - Main context usage: ~20% (just orchestration + checkpoints)
538
- - Subagent 1: Fresh 0-30% (tasks 1-3)
539
- - Subagent 2: Fresh 0-30% (tasks 5-6)
540
- - Subagent 3: Fresh 0-20% (task 8)
541
- - All autonomous work: Peak quality
542
- - Can handle large plans with many tasks if properly segmented
543
-
544
- **When NOT to use segmentation:**
545
- - Plan has decision/human-action checkpoints that affect following tasks
546
- - Following tasks depend on checkpoint outcome
547
- - Better to execute in main sequentially in those cases
548
114
  </step>
549
115
 
550
116
  <step name="load_prompt">
551
- read the plan prompt:
552
117
  ```bash
553
118
  cat .planning/phases/XX-name/{phase}-{plan}-PLAN.md
554
- ````
555
-
556
- This IS the execution instructions. Follow it exactly.
557
-
558
- **If plan references CONTEXT.md:**
559
- The CONTEXT.md file provides the user's vision for this phase — how they imagine it working, what's essential, and what's out of scope. Honor this context throughout execution.
119
+ ```
120
+ This IS the execution instructions. Follow exactly. If plan references CONTEXT.md: honor user's vision throughout.
560
121
  </step>
561
122
 
562
123
  <step name="previous_phase_check">
563
- Before executing, check if previous phase had issues:
564
-
565
124
  ```bash
566
- # Find previous phase summary
567
- ls .planning/phases/*/SUMMARY.md 2>/dev/null | sort -r | head -2 | tail -1
125
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs phases list --type summaries --raw
126
+ # Extract the second-to-last summary from the JSON result
568
127
  ```
569
-
570
- If previous phase SUMMARY.md has "Issues Encountered" != "None" or "Next Phase Readiness" mentions blockers:
571
-
572
- Use question:
573
-
574
- - header: "Previous Issues"
575
- - question: "Previous phase had unresolved items: [summary]. How to proceed?"
576
- - options:
577
- - "Proceed anyway" - Issues won't block this phase
578
- - "Address first" - Let's resolve before continuing
579
- - "Review previous" - Show me the full summary
580
- </step>
128
+ If previous SUMMARY has unresolved "Issues Encountered" or "Next Phase Readiness" blockers: question(header="Previous Issues", options: "Proceed anyway" | "Address first" | "Review previous").
129
+ </step>
581
130
 
582
131
  <step name="execute">
583
- Execute each task in the prompt. **Deviations are normal** - handle them automatically using embedded rules below.
584
-
585
- 1. read the @context files listed in the prompt
586
-
587
- 2. For each task:
588
-
589
- **If `type="auto"`:**
590
-
591
- **Before executing:** Check if task has `tdd="true"` attribute:
592
- - If yes: Follow TDD execution flow (see `<tdd_execution>`) - RED → GREEN → REFACTOR cycle with atomic commits per stage
593
- - If no: Standard implementation
594
-
595
- - Work toward task completion
596
- - **If CLI/API returns authentication error:** Handle as authentication gate (see below)
597
- - **When you discover additional work not in plan:** Apply deviation rules (see below) automatically
598
- - Continue implementing, applying rules as needed
599
- - Run the verification
600
- - Confirm done criteria met
601
- - **Commit the task** (see `<task_commit>` below)
602
- - Track task completion and commit hash for Summary documentation
603
- - Continue to next task
604
-
605
- **If `type="checkpoint:*"`:**
606
-
607
- - STOP immediately (do not continue to next task)
608
- - Execute checkpoint_protocol (see below)
609
- - Wait for user response
610
- - Verify if possible (check files, env vars, etc.)
611
- - Only after user confirmation: continue to next task
612
-
613
- 3. Run overall verification checks from `<verification>` section
614
- 4. Confirm all success criteria from `<success_criteria>` section met
615
- 5. Document all deviations in Summary (automatic - see deviation_documentation below)
616
- </step>
132
+ Deviations are normal handle via rules below.
133
+
134
+ 1. read @context files from prompt
135
+ 2. Per task:
136
+ - `type="auto"`: if `tdd="true"` → TDD execution. Implement with deviation rules + auth gates. Verify done criteria. Commit (see task_commit). Track hash for Summary.
137
+ - `type="checkpoint:*"`: STOP → checkpoint_protocol → wait for user → continue only after confirmation.
138
+ 3. Run `<verification>` checks
139
+ 4. Confirm `<success_criteria>` met
140
+ 5. Document deviations in Summary
141
+ </step>
617
142
 
618
143
  <authentication_gates>
619
144
 
620
- ## Handling Authentication Errors During Execution
621
-
622
- **When you encounter authentication errors during `type="auto"` task execution:**
623
-
624
- This is NOT a failure. Authentication gates are expected and normal. Handle them dynamically:
625
-
626
- **Authentication error indicators:**
627
-
628
- - CLI returns: "Error: Not authenticated", "Not logged in", "Unauthorized", "401", "403"
629
- - API returns: "Authentication required", "Invalid API key", "Missing credentials"
630
- - Command fails with: "Please run {tool} login" or "Set {ENV_VAR} environment variable"
631
-
632
- **Authentication gate protocol:**
633
-
634
- 1. **Recognize it's an auth gate** - Not a bug, just needs credentials
635
- 2. **STOP current task execution** - Don't retry repeatedly
636
- 3. **Create dynamic checkpoint:human-action** - Present it to user immediately
637
- 4. **Provide exact authentication steps** - CLI commands, where to get keys
638
- 5. **Wait for user to authenticate** - Let them complete auth flow
639
- 6. **Verify authentication works** - Test that credentials are valid
640
- 7. **Retry the original task** - Resume automation where you left off
641
- 8. **Continue normally** - Don't treat this as an error in Summary
642
-
643
- **Example: Vercel deployment hits auth error**
644
-
645
- ```
646
- Task 3: Deploy to Vercel
647
- Running: vercel --yes
648
-
649
- Error: Not authenticated. Please run 'vercel login'
650
-
651
- [Create checkpoint dynamically]
652
-
653
- ╔═══════════════════════════════════════════════════════╗
654
- ║ CHECKPOINT: Action Required ║
655
- ╚═══════════════════════════════════════════════════════╝
656
-
657
- Progress: 2/8 tasks complete
658
- Task: Authenticate Vercel CLI
659
-
660
- Attempted: vercel --yes
661
- Error: Not authenticated
662
-
663
- What you need to do:
664
- 1. Run: vercel login
665
- 2. Complete browser authentication
666
-
667
- I'll verify: vercel whoami returns your account
668
-
669
- ────────────────────────────────────────────────────────
670
- → YOUR ACTION: Type "done" when authenticated
671
- ────────────────────────────────────────────────────────
672
-
673
- [Wait for user response]
674
-
675
- [User types "done"]
676
-
677
- Verifying authentication...
678
- Running: vercel whoami
679
- ✓ Authenticated as: user@example.com
680
-
681
- Retrying deployment...
682
- Running: vercel --yes
683
- ✓ Deployed to: https://myapp-abc123.vercel.app
684
-
685
- Task 3 complete. Continuing to task 4...
686
- ```
687
-
688
- **In Summary documentation:**
689
-
690
- Document authentication gates as normal flow, not deviations:
691
-
692
- ```markdown
693
145
  ## Authentication Gates
694
146
 
695
- During execution, I encountered authentication requirements:
696
-
697
- 1. Task 3: Vercel CLI required authentication
698
- - Paused for `vercel login`
699
- - Resumed after authentication
700
- - Deployed successfully
701
-
702
- These are normal gates, not errors.
703
- ```
704
-
705
- **Key principles:**
706
-
707
- - Authentication gates are NOT failures or bugs
708
- - They're expected interaction points during first-time setup
709
- - Handle them gracefully and continue automation after unblocked
710
- - Don't mark tasks as "failed" or "incomplete" due to auth gates
711
- - Document them as normal flow, separate from deviations
712
- </authentication_gates>
713
-
714
- <deviation_rules>
715
-
716
- ## Automatic Deviation Handling
717
-
718
- **While executing tasks, you WILL discover work not in the plan.** This is normal.
719
-
720
- Apply these rules automatically. Track all deviations for Summary documentation.
721
-
722
- ---
723
-
724
- **RULE 1: Auto-fix bugs**
725
-
726
- **Trigger:** Code doesn't work as intended (broken behavior, incorrect output, errors)
727
-
728
- **Action:** Fix immediately, track for Summary
729
-
730
- **Examples:**
731
-
732
- - Wrong SQL query returning incorrect data
733
- - Logic errors (inverted condition, off-by-one, infinite loop)
734
- - Type errors, null pointer exceptions, undefined references
735
- - Broken validation (accepts invalid input, rejects valid input)
736
- - Security vulnerabilities (SQL injection, XSS, CSRF, insecure auth)
737
- - Race conditions, deadlocks
738
- - Memory leaks, resource leaks
739
-
740
- **Process:**
741
-
742
- 1. Fix the bug inline
743
- 2. Add/update tests to prevent regression
744
- 3. Verify fix works
745
- 4. Continue task
746
- 5. Track in deviations list: `[Rule 1 - Bug] [description]`
747
-
748
- **No user permission needed.** Bugs must be fixed for correct operation.
749
-
750
- ---
751
-
752
- **RULE 2: Auto-add missing critical functionality**
753
-
754
- **Trigger:** Code is missing essential features for correctness, security, or basic operation
755
-
756
- **Action:** Add immediately, track for Summary
757
-
758
- **Examples:**
759
-
760
- - Missing error handling (no try/catch, unhandled promise rejections)
761
- - No input validation (accepts malicious data, type coercion issues)
762
- - Missing null/undefined checks (crashes on edge cases)
763
- - No authentication on protected routes
764
- - Missing authorization checks (users can access others' data)
765
- - No CSRF protection, missing CORS configuration
766
- - No rate limiting on public APIs
767
- - Missing required database indexes (causes timeouts)
768
- - No logging for errors (can't debug production)
769
-
770
- **Process:**
147
+ Auth errors during execution are NOT failures — they're expected interaction points.
771
148
 
772
- 1. Add the missing functionality inline
773
- 2. Add tests for the new functionality
774
- 3. Verify it works
775
- 4. Continue task
776
- 5. Track in deviations list: `[Rule 2 - Missing Critical] [description]`
149
+ **Indicators:** "Not authenticated", "Unauthorized", 401/403, "Please run {tool} login", "Set {ENV_VAR}"
777
150
 
778
- **Critical = required for correct/secure/performant operation**
779
- **No user permission needed.** These are not "features" - they're requirements for basic correctness.
151
+ **Protocol:**
152
+ 1. Recognize auth gate (not a bug)
153
+ 2. STOP task execution
154
+ 3. Create dynamic checkpoint:human-action with exact auth steps
155
+ 4. Wait for user to authenticate
156
+ 5. Verify credentials work
157
+ 6. Retry original task
158
+ 7. Continue normally
780
159
 
781
- ---
160
+ **Example:** `vercel --yes` → "Not authenticated" → checkpoint asking user to `vercel login` → verify with `vercel whoami` → retry deploy → continue
782
161
 
783
- **RULE 3: Auto-fix blocking issues**
162
+ **In Summary:** Document as normal flow under "## Authentication Gates", not as deviations.
784
163
 
785
- **Trigger:** Something prevents you from completing current task
164
+ </authentication_gates>
786
165
 
787
- **Action:** Fix immediately to unblock, track for Summary
788
-
789
- **Examples:**
790
-
791
- - Missing dependency (package not installed, import fails)
792
- - Wrong types blocking compilation
793
- - Broken import paths (file moved, wrong relative path)
794
- - Missing environment variable (app won't start)
795
- - Database connection config error
796
- - Build configuration error (webpack, tsconfig, etc.)
797
- - Missing file referenced in code
798
- - Circular dependency blocking module resolution
799
-
800
- **Process:**
801
-
802
- 1. Fix the blocking issue
803
- 2. Verify task can now proceed
804
- 3. Continue task
805
- 4. Track in deviations list: `[Rule 3 - Blocking] [description]`
806
-
807
- **No user permission needed.** Can't complete task without fixing blocker.
808
-
809
- ---
810
-
811
- **RULE 4: Ask about architectural changes**
812
-
813
- **Trigger:** Fix/addition requires significant structural modification
814
-
815
- **Action:** STOP, present to user, wait for decision
816
-
817
- **Examples:**
166
+ <deviation_rules>
818
167
 
819
- - Adding new database table (not just column)
820
- - Major schema changes (changing primary key, splitting tables)
821
- - Introducing new service layer or architectural pattern
822
- - Switching libraries/frameworks (React → Vue, REST → GraphQL)
823
- - Changing authentication approach (sessions → JWT)
824
- - Adding new infrastructure (message queue, cache layer, CDN)
825
- - Changing API contracts (breaking changes to endpoints)
826
- - Adding new deployment environment
168
+ ## Deviation Rules
827
169
 
828
- **Process:**
170
+ You WILL discover unplanned work. Apply automatically, track all for Summary.
829
171
 
830
- 1. STOP current task
831
- 2. Present clearly:
172
+ | Rule | Trigger | Action | Permission |
173
+ |------|---------|--------|------------|
174
+ | **1: Bug** | Broken behavior, errors, wrong queries, type errors, security vulns, race conditions, leaks | Fix → test → verify → track `[Rule 1 - Bug]` | Auto |
175
+ | **2: Missing Critical** | Missing essentials: error handling, validation, auth, CSRF/CORS, rate limiting, indexes, logging | Add → test → verify → track `[Rule 2 - Missing Critical]` | Auto |
176
+ | **3: Blocking** | Prevents completion: missing deps, wrong types, broken imports, missing env/config/files, circular deps | Fix blocker → verify proceeds → track `[Rule 3 - Blocking]` | Auto |
177
+ | **4: Architectural** | Structural change: new DB table, schema change, new service, switching libs, breaking API, new infra | STOP → present decision (below) → track `[Rule 4 - Architectural]` | Ask user |
832
178
 
179
+ **Rule 4 format:**
833
180
  ```
834
181
  ⚠️ Architectural Decision Needed
835
182
 
836
183
  Current task: [task name]
837
- Discovery: [what you found that prompted this]
838
- Proposed change: [architectural modification]
184
+ Discovery: [what prompted this]
185
+ Proposed change: [modification]
839
186
  Why needed: [rationale]
840
- Impact: [what this affects - APIs, deployment, dependencies, etc.]
841
- Alternatives: [other approaches, or "none apparent"]
187
+ Impact: [what this affects]
188
+ Alternatives: [other approaches]
842
189
 
843
190
  Proceed with proposed change? (yes / different approach / defer)
844
191
  ```
845
192
 
846
- 3. WAIT for user response
847
- 4. If approved: implement, track as `[Rule 4 - Architectural] [description]`
848
- 5. If different approach: discuss and implement
849
- 6. If deferred: note in Summary and continue without change
850
-
851
- **User decision required.** These changes affect system design.
852
-
853
- ---
854
-
855
- **RULE PRIORITY (when multiple could apply):**
856
-
857
- 1. **If Rule 4 applies** → STOP and ask (architectural decision)
858
- 2. **If Rules 1-3 apply** → Fix automatically, track for Summary
859
- 3. **If genuinely unsure which rule** → Apply Rule 4 (ask user)
860
-
861
- **Edge case guidance:**
862
-
863
- - "This validation is missing" → Rule 2 (critical for security)
864
- - "This crashes on null" → Rule 1 (bug)
865
- - "Need to add table" → Rule 4 (architectural)
866
- - "Need to add column" → Rule 1 or 2 (depends: fixing bug or adding critical field)
867
-
868
- **When in doubt:** Ask yourself "Does this affect correctness, security, or ability to complete task?"
869
-
870
- - YES → Rules 1-3 (fix automatically)
871
- - MAYBE → Rule 4 (ask user)
193
+ **Priority:** Rule 4 (STOP) > Rules 1-3 (auto) > unsure → Rule 4
194
+ **Edge cases:** missing validation R2 | null crash R1 | new table → R4 | new column → R1/2
195
+ **Heuristic:** Affects correctness/security/completion? R1-3. Maybe? → R4.
872
196
 
873
197
  </deviation_rules>
874
198
 
875
199
  <deviation_documentation>
876
200
 
877
- ## Documenting Deviations in Summary
878
-
879
- After all tasks complete, Summary MUST include deviations section.
880
-
881
- **If no deviations:**
882
-
883
- ```markdown
884
- ## Deviations from Plan
885
-
886
- None - plan executed exactly as written.
887
- ```
888
-
889
- **If deviations occurred:**
890
-
891
- ```markdown
892
- ## Deviations from Plan
893
-
894
- ### Auto-fixed Issues
895
-
896
- **1. [Rule 1 - Bug] Fixed case-sensitive email uniqueness constraint**
201
+ ## Documenting Deviations
897
202
 
898
- - **Found during:** Task 4 (Follow/unfollow API implementation)
899
- - **Issue:** User.email unique constraint was case-sensitive - Test@example.com and test@example.com were both allowed, causing duplicate accounts
900
- - **Fix:** Changed to `CREATE UNIQUE INDEX users_email_unique ON users (LOWER(email))`
901
- - **Files modified:** src/models/User.ts, migrations/003_fix_email_unique.sql
902
- - **Verification:** Unique constraint test passes - duplicate emails properly rejected
903
- - **Commit:** abc123f
203
+ Summary MUST include deviations section. None? `## Deviations from Plan\n\nNone - plan executed exactly as written.`
904
204
 
905
- **2. [Rule 2 - Missing Critical] Added JWT expiry validation to auth middleware**
906
-
907
- - **Found during:** Task 3 (Protected route implementation)
908
- - **Issue:** Auth middleware wasn't checking token expiry - expired tokens were being accepted
909
- - **Fix:** Added exp claim validation in middleware, reject with 401 if expired
910
- - **Files modified:** src/middleware/auth.ts, src/middleware/auth.test.ts
911
- - **Verification:** Expired token test passes - properly rejects with 401
912
- - **Commit:** def456g
913
-
914
- ---
915
-
916
- **Total deviations:** 4 auto-fixed (1 bug, 1 missing critical, 1 blocking, 1 architectural with approval)
917
- **Impact on plan:** All auto-fixes necessary for correctness/security/performance. No scope creep.
918
- ```
205
+ Per deviation: **[Rule N - Category] Title** Found during: task X | Issue | Fix | Files modified | Verification | Commit hash
919
206
 
920
- **This provides complete transparency:**
921
-
922
- - Every deviation documented
923
- - Why it was needed
924
- - What rule applied
925
- - What was done
926
- - User can see exactly what happened beyond the plan
207
+ End with: **Total deviations:** N auto-fixed (breakdown). **Impact:** assessment.
927
208
 
928
209
  </deviation_documentation>
929
210
 
930
211
  <tdd_plan_execution>
931
- ## TDD Plan Execution
932
-
933
- When executing a plan with `type: tdd` in frontmatter, follow the RED-GREEN-REFACTOR cycle for the single feature defined in the plan.
934
-
935
- **1. Check test infrastructure (if first TDD plan):**
936
- If no test framework configured:
937
- - Detect project type from package.json/requirements.txt/etc.
938
- - Install minimal test framework (Jest, pytest, Go testing, etc.)
939
- - Create test config file
940
- - Verify: run empty test suite
941
- - This is part of the RED phase, not a separate task
942
-
943
- **2. RED - write failing test:**
944
- - read `<behavior>` element for test specification
945
- - Create test file if doesn't exist (follow project conventions)
946
- - write test(s) that describe expected behavior
947
- - Run tests - MUST fail (if passes, test is wrong or feature exists)
948
- - Commit: `test({phase}-{plan}): add failing test for [feature]`
949
-
950
- **3. GREEN - Implement to pass:**
951
- - read `<implementation>` element for guidance
952
- - write minimal code to make test pass
953
- - Run tests - MUST pass
954
- - Commit: `feat({phase}-{plan}): implement [feature]`
955
-
956
- **4. REFACTOR (if needed):**
957
- - Clean up code if obvious improvements
958
- - Run tests - MUST still pass
959
- - Commit only if changes made: `refactor({phase}-{plan}): clean up [feature]`
960
-
961
- **Commit pattern for TDD plans:**
962
- Each TDD plan produces 2-3 atomic commits:
963
- 1. `test({phase}-{plan}): add failing test for X`
964
- 2. `feat({phase}-{plan}): implement X`
965
- 3. `refactor({phase}-{plan}): clean up X` (optional)
966
-
967
- **Error handling:**
968
- - If test doesn't fail in RED phase: Test is wrong or feature already exists. Investigate before proceeding.
969
- - If test doesn't pass in GREEN phase: Debug implementation, keep iterating until green.
970
- - If tests fail in REFACTOR phase: Undo refactor, commit was premature.
971
-
972
- **Verification:**
973
- After TDD plan completion, ensure:
974
- - All tests pass
975
- - Test coverage for the new behavior exists
976
- - No unrelated tests broken
977
-
978
- **Why TDD uses dedicated plans:** TDD requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. This consumes 40-50% of context for a single feature. Dedicated plans ensure full quality throughout the cycle.
979
-
980
- **Comparison:**
981
- - Standard plans: Multiple tasks, 1 commit per task, 2-4 commits total
982
- - TDD plans: Single feature, 2-3 commits for RED/GREEN/REFACTOR cycle
983
-
984
- See `~/.config/opencode/get-shit-done/references/tdd.md` for TDD plan structure.
985
- </tdd_plan_execution>
212
+ ## TDD Execution
986
213
 
987
- <task_commit>
988
- ## Task Commit Protocol
214
+ For `type: tdd` plans — RED-GREEN-REFACTOR:
989
215
 
990
- After each task completes (verification passed, done criteria met), commit immediately:
216
+ 1. **Infrastructure** (first TDD plan only): detect project, install framework, config, verify empty suite
217
+ 2. **RED:** read `<behavior>` → failing test(s) → run (MUST fail) → commit: `test({phase}-{plan}): add failing test for [feature]`
218
+ 3. **GREEN:** read `<implementation>` → minimal code → run (MUST pass) → commit: `feat({phase}-{plan}): implement [feature]`
219
+ 4. **REFACTOR:** Clean up → tests MUST pass → commit: `refactor({phase}-{plan}): clean up [feature]`
991
220
 
992
- **1. Identify modified files:**
221
+ Errors: RED doesn't fail → investigate test/existing feature. GREEN doesn't pass → debug, iterate. REFACTOR breaks → undo.
993
222
 
994
- Track files changed during this specific task (not the entire plan):
223
+ See `~/.config/opencode/get-shit-done/references/tdd.md` for structure.
224
+ </tdd_plan_execution>
995
225
 
996
- ```bash
997
- git status --short
998
- ```
226
+ <task_commit>
227
+ ## task Commit Protocol
999
228
 
1000
- **2. Stage only task-related files:**
229
+ After each task (verification passed, done criteria met), commit immediately.
1001
230
 
1002
- Stage each file individually (NEVER use `git add .` or `git add -A`):
231
+ **1. Check:** `git status --short`
1003
232
 
233
+ **2. Stage individually** (NEVER `git add .` or `git add -A`):
1004
234
  ```bash
1005
- # Example - adjust to actual files modified by this task
1006
235
  git add src/api/auth.ts
1007
236
  git add src/types/user.ts
1008
237
  ```
1009
238
 
1010
- **3. Determine commit type:**
1011
-
1012
- | Type | When to Use | Example |
1013
- |------|-------------|---------|
1014
- | `feat` | New feature, endpoint, component, functionality | feat(08-02): create user registration endpoint |
1015
- | `fix` | Bug fix, error correction | fix(08-02): correct email validation regex |
1016
- | `test` | Test-only changes (TDD RED phase) | test(08-02): add failing test for password hashing |
1017
- | `refactor` | Code cleanup, no behavior change (TDD REFACTOR phase) | refactor(08-02): extract validation to helper |
1018
- | `perf` | Performance improvement | perf(08-02): add database index for user lookups |
1019
- | `docs` | Documentation changes | docs(08-02): add API endpoint documentation |
1020
- | `style` | Formatting, linting fixes | style(08-02): format auth module |
1021
- | `chore` | Config, tooling, dependencies | chore(08-02): add bcrypt dependency |
239
+ **3. Commit type:**
1022
240
 
1023
- **4. Craft commit message:**
241
+ | Type | When | Example |
242
+ |------|------|---------|
243
+ | `feat` | New functionality | feat(08-02): create user registration endpoint |
244
+ | `fix` | Bug fix | fix(08-02): correct email validation regex |
245
+ | `test` | Test-only (TDD RED) | test(08-02): add failing test for password hashing |
246
+ | `refactor` | No behavior change (TDD REFACTOR) | refactor(08-02): extract validation to helper |
247
+ | `perf` | Performance | perf(08-02): add database index |
248
+ | `docs` | Documentation | docs(08-02): add API docs |
249
+ | `style` | Formatting | style(08-02): format auth module |
250
+ | `chore` | Config/deps | chore(08-02): add bcrypt dependency |
1024
251
 
1025
- Format: `{type}({phase}-{plan}): {task-name-or-description}`
1026
-
1027
- ```bash
1028
- git commit -m "{type}({phase}-{plan}): {concise task description}
1029
-
1030
- - {key change 1}
1031
- - {key change 2}
1032
- - {key change 3}
1033
- "
1034
- ```
1035
-
1036
- **Examples:**
1037
-
1038
- ```bash
1039
- # Standard plan task
1040
- git commit -m "feat(08-02): create user registration endpoint
1041
-
1042
- - POST /auth/register validates email and password
1043
- - Checks for duplicate users
1044
- - Returns JWT token on success
1045
- "
1046
-
1047
- # Another standard task
1048
- git commit -m "fix(08-02): correct email validation regex
1049
-
1050
- - Fixed regex to accept plus-addressing
1051
- - Added tests for edge cases
1052
- "
1053
- ```
1054
-
1055
- **Note:** TDD plans have their own commit pattern (test/feat/refactor for RED/GREEN/REFACTOR phases). See `<tdd_plan_execution>` section above.
1056
-
1057
- **5. Record commit hash:**
1058
-
1059
- After committing, capture hash for SUMMARY.md:
252
+ **4. Format:** `{type}({phase}-{plan}): {description}` with bullet points for key changes.
1060
253
 
254
+ **5. Record hash:**
1061
255
  ```bash
1062
256
  TASK_COMMIT=$(git rev-parse --short HEAD)
1063
- echo "Task ${TASK_NUM} committed: ${TASK_COMMIT}"
257
+ TASK_COMMITS+=("task ${TASK_NUM}: ${TASK_COMMIT}")
1064
258
  ```
1065
259
 
1066
- Store in array or list for SUMMARY generation:
1067
- ```bash
1068
- TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
1069
- ```
1070
-
1071
- **Atomic commit benefits:**
1072
- - Each task independently revertable
1073
- - Git bisect finds exact failing task
1074
- - Git blame traces line to specific task context
1075
- - Clear history for OpenCode in future sessions
1076
- - Better observability for AI-automated workflow
1077
-
1078
260
  </task_commit>
1079
261
 
1080
262
  <step name="checkpoint_protocol">
1081
- When encountering `type="checkpoint:*"`:
1082
-
1083
- **Critical: OpenCode automates everything with CLI/API before checkpoints.** Checkpoints are for verification and decisions, not manual work.
1084
-
1085
- **Display checkpoint clearly:**
1086
-
1087
- ```
1088
- ╔═══════════════════════════════════════════════════════╗
1089
- ║ CHECKPOINT: [Type] ║
1090
- ╚═══════════════════════════════════════════════════════╝
1091
-
1092
- Progress: {X}/{Y} tasks complete
1093
- Task: [task name]
263
+ On `type="checkpoint:*"`: automate everything possible first. Checkpoints are for verification/decisions only.
1094
264
 
1095
- [Display task-specific content based on type]
265
+ Display: `CHECKPOINT: [Type]` box → Progress {X}/{Y} → task name → type-specific content `YOUR ACTION: [signal]`
1096
266
 
1097
- ────────────────────────────────────────────────────────
1098
- → YOUR ACTION: [Resume signal instruction]
1099
- ────────────────────────────────────────────────────────
1100
- ```
1101
-
1102
- **For checkpoint:human-verify (90% of checkpoints):**
1103
-
1104
- ```
1105
- Built: [what was automated - deployed, built, configured]
1106
-
1107
- How to verify:
1108
- 1. [Step 1 - exact command/URL]
1109
- 2. [Step 2 - what to check]
1110
- 3. [Step 3 - expected behavior]
1111
-
1112
- ────────────────────────────────────────────────────────
1113
- → YOUR ACTION: Type "approved" or describe issues
1114
- ────────────────────────────────────────────────────────
1115
- ```
1116
-
1117
- **For checkpoint:decision (9% of checkpoints):**
1118
-
1119
- ```
1120
- Decision needed: [decision]
1121
-
1122
- Context: [why this matters]
1123
-
1124
- Options:
1125
- 1. [option-id]: [name]
1126
- Pros: [pros]
1127
- Cons: [cons]
1128
-
1129
- 2. [option-id]: [name]
1130
- Pros: [pros]
1131
- Cons: [cons]
1132
-
1133
- [Resume signal - e.g., "Select: option-id"]
1134
- ```
1135
-
1136
- **For checkpoint:human-action (1% - rare, only for truly unavoidable manual steps):**
267
+ | Type | Content | Resume signal |
268
+ |------|---------|---------------|
269
+ | human-verify (90%) | What was built + verification steps (commands/URLs) | "approved" or describe issues |
270
+ | decision (9%) | Decision needed + context + options with pros/cons | "Select: option-id" |
271
+ | human-action (1%) | What was automated + ONE manual step + verification plan | "done" |
1137
272
 
1138
- ```
1139
- I automated: [what OpenCode already did via CLI/API]
1140
-
1141
- Need your help with: [the ONE thing with no CLI/API - email link, 2FA code]
1142
-
1143
- Instructions:
1144
- [Single unavoidable step]
1145
-
1146
- I'll verify after: [verification]
1147
-
1148
- [Resume signal - e.g., "Type 'done' when complete"]
1149
- ```
1150
-
1151
- **After displaying:** WAIT for user response. Do NOT hallucinate completion. Do NOT continue to next task.
1152
-
1153
- **After user responds:**
273
+ After response: verify if specified. Pass → continue. Fail → inform, wait. WAIT for user — do NOT hallucinate completion.
1154
274
 
1155
- - Run verification if specified (file exists, env var set, tests pass, etc.)
1156
- - If verification passes or N/A: continue to next task
1157
- - If verification fails: inform user, wait for resolution
1158
-
1159
- See ~/.config/opencode/get-shit-done/references/checkpoints.md for complete checkpoint guidance.
275
+ See ~/.config/opencode/get-shit-done/references/checkpoints.md for details.
1160
276
  </step>
1161
277
 
1162
278
  <step name="checkpoint_return_for_orchestrator">
1163
- **When spawned by an orchestrator (execute-phase or execute-plan command):**
1164
-
1165
- If you were spawned via Task tool and hit a checkpoint, you cannot directly interact with the user. Instead, RETURN to the orchestrator with structured checkpoint state so it can present to the user and spawn a fresh continuation agent.
1166
-
1167
- **Return format for checkpoints:**
1168
-
1169
- **Required in your return:**
1170
-
1171
- 1. **Completed Tasks table** - Tasks done so far with commit hashes and files created
1172
- 2. **Current Task** - Which task you're on and what's blocking it
1173
- 3. **Checkpoint Details** - User-facing content (verification steps, decision options, or action instructions)
1174
- 4. **Awaiting** - What you need from the user
1175
-
1176
- **Example return:**
1177
-
1178
- ```
1179
- ## CHECKPOINT REACHED
279
+ When spawned via task and hitting checkpoint: return structured state (cannot interact with user directly).
1180
280
 
1181
- **Type:** human-action
1182
- **Plan:** 01-01
1183
- **Progress:** 1/3 tasks complete
281
+ **Required return:** 1) Completed Tasks table (hashes + files) 2) Current task (what's blocking) 3) Checkpoint Details (user-facing content) 4) Awaiting (what's needed from user)
1184
282
 
1185
- ### Completed Tasks
1186
-
1187
- | Task | Name | Commit | Files |
1188
- |------|------|--------|-------|
1189
- | 1 | Initialize Next.js 15 project | d6fe73f | package.json, tsconfig.json, app/ |
1190
-
1191
- ### Current Task
1192
-
1193
- **Task 2:** Initialize Convex backend
1194
- **Status:** blocked
1195
- **Blocked by:** Convex CLI authentication required
1196
-
1197
- ### Checkpoint Details
1198
-
1199
- **Automation attempted:**
1200
- Ran `npx convex dev` to initialize Convex backend
1201
-
1202
- **Error encountered:**
1203
- "Error: Not authenticated. Run `npx convex login` first."
1204
-
1205
- **What you need to do:**
1206
- 1. Run: `npx convex login`
1207
- 2. Complete browser authentication
1208
- 3. Run: `npx convex dev`
1209
- 4. Create project when prompted
1210
-
1211
- **I'll verify after:**
1212
- `cat .env.local | grep CONVEX` returns the Convex URL
1213
-
1214
- ### Awaiting
1215
-
1216
- Type "done" when Convex is authenticated and project created.
1217
- ```
1218
-
1219
- **After you return:**
1220
-
1221
- The orchestrator will:
1222
- 1. Parse your structured return
1223
- 2. Present checkpoint details to the user
1224
- 3. Collect user's response
1225
- 4. Spawn a FRESH continuation agent with your completed tasks state
1226
-
1227
- You will NOT be resumed. A new agent continues from where you stopped, using your Completed Tasks table to know what's done.
1228
-
1229
- **How to know if you were spawned:**
1230
-
1231
- If you're reading this workflow because an orchestrator spawned you (vs running directly), the orchestrator's prompt will include checkpoint return instructions. Follow those instructions when you hit a checkpoint.
1232
-
1233
- **If running in main context (not spawned):**
1234
-
1235
- Use the standard checkpoint_protocol - display checkpoint and wait for direct user response.
283
+ Orchestrator parses → presents to user → spawns fresh continuation with your completed tasks state. You will NOT be resumed. In main context: use checkpoint_protocol above.
1236
284
  </step>
1237
285
 
1238
286
  <step name="verification_failure_gate">
1239
- If any task verification fails:
1240
-
1241
- STOP. Do not continue to next task.
1242
-
1243
- Present inline:
1244
- "Verification failed for Task [X]: [task name]
1245
-
1246
- Expected: [verification criteria]
1247
- Actual: [what happened]
1248
-
1249
- How to proceed?
1250
-
1251
- 1. Retry - Try the task again
1252
- 2. Skip - Mark as incomplete, continue
1253
- 3. Stop - Pause execution, investigate"
1254
-
1255
- Wait for user decision.
1256
-
1257
- If user chose "Skip", note it in SUMMARY.md under "Issues Encountered".
287
+ If verification fails: STOP. Present: "Verification failed for task [X]: [name]. Expected: [criteria]. Actual: [result]." Options: Retry | Skip (mark incomplete) | Stop (investigate). If skipped → SUMMARY "Issues Encountered".
1258
288
  </step>
1259
289
 
1260
290
  <step name="record_completion_time">
1261
- Record execution end time and calculate duration:
1262
-
1263
291
  ```bash
1264
292
  PLAN_END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
1265
293
  PLAN_END_EPOCH=$(date +%s)
@@ -1275,588 +303,131 @@ else
1275
303
  DURATION="${DURATION_MIN} min"
1276
304
  fi
1277
305
  ```
1278
-
1279
- Pass timing data to SUMMARY.md creation.
1280
306
  </step>
1281
307
 
1282
308
  <step name="generate_user_setup">
1283
- **Generate USER-SETUP.md if plan has user_setup in frontmatter.**
1284
-
1285
- Check PLAN.md frontmatter for `user_setup` field:
1286
-
1287
309
  ```bash
1288
310
  grep -A 50 "^user_setup:" .planning/phases/XX-name/{phase}-{plan}-PLAN.md | head -50
1289
311
  ```
1290
312
 
1291
- **If user_setup exists and is not empty:**
1292
-
1293
- Create `.planning/phases/XX-name/{phase}-USER-SETUP.md` using template from `~/.config/opencode/get-shit-done/templates/user-setup.md`.
1294
-
1295
- **Content generation:**
1296
-
1297
- 1. Parse each service in `user_setup` array
1298
- 2. For each service, generate sections:
1299
- - Environment Variables table (from `env_vars`)
1300
- - Account Setup checklist (from `account_setup`, if present)
1301
- - Dashboard Configuration steps (from `dashboard_config`, if present)
1302
- - Local Development notes (from `local_dev`, if present)
1303
- 3. Add verification section with commands to confirm setup works
1304
- 4. Set status to "Incomplete"
1305
-
1306
- **Example output:**
1307
-
1308
- ```markdown
1309
- # Phase 10: User Setup Required
1310
-
1311
- **Generated:** 2025-01-14
1312
- **Phase:** 10-monetization
1313
- **Status:** Incomplete
1314
-
1315
- ## Environment Variables
1316
-
1317
- | Status | Variable | Source | Add to |
1318
- |--------|----------|--------|--------|
1319
- | [ ] | `STRIPE_SECRET_KEY` | Stripe Dashboard → Developers → API keys → Secret key | `.env.local` |
1320
- | [ ] | `STRIPE_WEBHOOK_SECRET` | Stripe Dashboard → Developers → Webhooks → Signing secret | `.env.local` |
1321
-
1322
- ## Dashboard Configuration
1323
-
1324
- - [ ] **Create webhook endpoint**
1325
- - Location: Stripe Dashboard → Developers → Webhooks → Add endpoint
1326
- - Details: URL: https://[your-domain]/api/webhooks/stripe, Events: checkout.session.completed
1327
-
1328
- ## Local Development
1329
-
1330
- For local testing:
1331
- \`\`\`bash
1332
- stripe listen --forward-to localhost:3000/api/webhooks/stripe
1333
- \`\`\`
1334
-
1335
- ## Verification
1336
-
1337
- [Verification commands based on service]
1338
-
1339
- ---
1340
- **Once all items complete:** Mark status as "Complete"
1341
- ```
1342
-
1343
- **If user_setup is empty or missing:**
1344
-
1345
- Skip this step - no USER-SETUP.md needed.
1346
-
1347
- **Track for offer_next:**
1348
-
1349
- Set `USER_SETUP_CREATED=true` if file was generated, for use in completion messaging.
313
+ If user_setup exists: create `{phase}-USER-SETUP.md` using template `~/.config/opencode/get-shit-done/templates/user-setup.md`. Per service: env vars table, account setup checklist, dashboard config, local dev notes, verification commands. Status "Incomplete". Set `USER_SETUP_CREATED=true`. If empty/missing: skip.
1350
314
  </step>
1351
315
 
1352
316
  <step name="create_summary">
1353
- Create `{phase}-{plan}-SUMMARY.md` as specified in the prompt's `<output>` section.
1354
- Use ~/.config/opencode/get-shit-done/templates/summary.md for structure.
1355
-
1356
- **File location:** `.planning/phases/XX-name/{phase}-{plan}-SUMMARY.md`
1357
-
1358
- **Frontmatter population:**
1359
-
1360
- Before writing summary content, populate frontmatter fields from execution context:
1361
-
1362
- 1. **Basic identification:**
1363
- - phase: From PLAN.md frontmatter
1364
- - plan: From PLAN.md frontmatter
1365
- - subsystem: Categorize based on phase focus (auth, payments, ui, api, database, infra, testing, etc.)
1366
- - tags: Extract tech keywords (libraries, frameworks, tools used)
1367
-
1368
- 2. **Dependency graph:**
1369
- - requires: List prior phases this built upon (check PLAN.md context section for referenced prior summaries)
1370
- - provides: Extract from accomplishments - what was delivered
1371
- - affects: Infer from phase description/goal what future phases might need this
1372
-
1373
- 3. **Tech tracking:**
1374
- - tech-stack.added: New libraries from package.json changes or requirements
1375
- - tech-stack.patterns: Architectural patterns established (from decisions/accomplishments)
317
+ Create `{phase}-{plan}-SUMMARY.md` at `.planning/phases/XX-name/`. Use `~/.config/opencode/get-shit-done/templates/summary.md`.
1376
318
 
1377
- 4. **File tracking:**
1378
- - key-files.created: From "Files Created/Modified" section
1379
- - key-files.modified: From "Files Created/Modified" section
319
+ **Frontmatter:** phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (**MUST** copy `requirements` array from PLAN.md frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date).
1380
320
 
1381
- 5. **Decisions:**
1382
- - key-decisions: Extract from "Decisions Made" section
321
+ Title: `# Phase [X] Plan [Y]: [Name] Summary`
1383
322
 
1384
- 6. **Metrics:**
1385
- - duration: From $DURATION variable
1386
- - completed: From $PLAN_END_TIME (date only, format YYYY-MM-DD)
323
+ One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "Authentication implemented"
1387
324
 
1388
- Note: If subsystem/affects are unclear, use best judgment based on phase name and accomplishments. Can be refined later.
325
+ Include: duration, start/end times, task count, file count.
1389
326
 
1390
- **Title format:** `# Phase [X] Plan [Y]: [Name] Summary`
1391
-
1392
- The one-liner must be SUBSTANTIVE:
1393
-
1394
- - Good: "JWT auth with refresh rotation using jose library"
1395
- - Bad: "Authentication implemented"
1396
-
1397
- **Include performance data:**
1398
-
1399
- - Duration: `$DURATION`
1400
- - Started: `$PLAN_START_TIME`
1401
- - Completed: `$PLAN_END_TIME`
1402
- - Tasks completed: (count from execution)
1403
- - Files modified: (count from execution)
1404
-
1405
- **Next Step section:**
1406
-
1407
- - If more plans exist in this phase: "Ready for {phase}-{next-plan}-PLAN.md"
1408
- - If this is the last plan: "Phase complete, ready for transition"
1409
- </step>
327
+ Next: more plans → "Ready for {next-plan}" | last → "Phase complete, ready for transition".
328
+ </step>
1410
329
 
1411
330
  <step name="update_current_position">
1412
- Update Current Position section in STATE.md to reflect plan completion.
1413
-
1414
- **Format:**
331
+ Update STATE.md using gsd-tools:
1415
332
 
1416
- ```markdown
1417
- Phase: [current] of [total] ([phase name])
1418
- Plan: [just completed] of [total in phase]
1419
- Status: [In progress / Phase complete]
1420
- Last activity: [today] - Completed {phase}-{plan}-PLAN.md
1421
-
1422
- Progress: [progress bar]
1423
- ```
1424
-
1425
- **Calculate progress bar:**
1426
-
1427
- - Count total plans across all phases (from ROADMAP.md or ROADMAP.md)
1428
- - Count completed plans (count SUMMARY.md files that exist)
1429
- - Progress = (completed / total) × 100%
1430
- - Render: ░ for incomplete, █ for complete
1431
-
1432
- **Example - completing 02-01-PLAN.md (plan 5 of 10 total):**
1433
-
1434
- Before:
1435
-
1436
- ```markdown
1437
- ## Current Position
1438
-
1439
- Phase: 2 of 4 (Authentication)
1440
- Plan: Not started
1441
- Status: Ready to execute
1442
- Last activity: 2025-01-18 - Phase 1 complete
1443
-
1444
- Progress: ██████░░░░ 40%
1445
- ```
1446
-
1447
- After:
1448
-
1449
- ```markdown
1450
- ## Current Position
333
+ ```bash
334
+ # Advance plan counter (handles last-plan edge case)
335
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs state advance-plan
1451
336
 
1452
- Phase: 2 of 4 (Authentication)
1453
- Plan: 1 of 2 in current phase
1454
- Status: In progress
1455
- Last activity: 2025-01-19 - Completed 02-01-PLAN.md
337
+ # Recalculate progress bar from disk state
338
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs state update-progress
1456
339
 
1457
- Progress: ███████░░░ 50%
340
+ # Record execution metrics
341
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs state record-metric \
342
+ --phase "${PHASE}" --plan "${PLAN}" --duration "${DURATION}" \
343
+ --tasks "${TASK_COUNT}" --files "${FILE_COUNT}"
1458
344
  ```
1459
-
1460
- **Step complete when:**
1461
-
1462
- - [ ] Phase number shows current phase (X of total)
1463
- - [ ] Plan number shows plans complete in current phase (N of total-in-phase)
1464
- - [ ] Status reflects current state (In progress / Phase complete)
1465
- - [ ] Last activity shows today's date and the plan just completed
1466
- - [ ] Progress bar calculated correctly from total completed plans
1467
- </step>
345
+ </step>
1468
346
 
1469
347
  <step name="extract_decisions_and_issues">
1470
- Extract decisions, issues, and concerns from SUMMARY.md into STATE.md accumulated context.
348
+ From SUMMARY: Extract decisions and add to STATE.md:
1471
349
 
1472
- **Decisions Made:**
1473
-
1474
- - read SUMMARY.md "## Decisions Made" section
1475
- - If content exists (not "None"):
1476
- - Add each decision to STATE.md Decisions table
1477
- - Format: `| [phase number] | [decision summary] | [rationale] |`
1478
-
1479
- **Blockers/Concerns:**
350
+ ```bash
351
+ # Add each decision from SUMMARY key-decisions
352
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs state add-decision \
353
+ --phase "${PHASE}" --summary "${DECISION_TEXT}" --rationale "${RATIONALE}"
1480
354
 
1481
- - read SUMMARY.md "## Next Phase Readiness" section
1482
- - If contains blockers or concerns:
1483
- - Add to STATE.md "Blockers/Concerns Carried Forward"
1484
- </step>
355
+ # Add blockers if any found
356
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs state add-blocker "Blocker description"
357
+ ```
358
+ </step>
1485
359
 
1486
360
  <step name="update_session_continuity">
1487
- Update Session Continuity section in STATE.md to enable resumption in future sessions.
1488
-
1489
- **Format:**
361
+ Update session info using gsd-tools:
1490
362
 
1491
- ```markdown
1492
- Last session: [current date and time]
1493
- Stopped at: Completed {phase}-{plan}-PLAN.md
1494
- Resume file: [path to .continue-here if exists, else "None"]
363
+ ```bash
364
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs state record-session \
365
+ --stopped-at "Completed ${PHASE}-${PLAN}-PLAN.md" \
366
+ --resume-file "None"
1495
367
  ```
1496
368
 
1497
- **Size constraint note:** Keep STATE.md under 150 lines total.
369
+ Keep STATE.md under 150 lines.
1498
370
  </step>
1499
371
 
1500
372
  <step name="issues_review_gate">
1501
- Before proceeding, check SUMMARY.md content.
1502
-
1503
- If "Issues Encountered" is NOT "None":
1504
-
1505
- <if mode="yolo">
1506
- ```
1507
- ⚡ Auto-approved: Issues acknowledgment
1508
- ⚠️ Note: Issues were encountered during execution:
1509
- - [Issue 1]
1510
- - [Issue 2]
1511
- (Logged - continuing in yolo mode)
1512
- ```
1513
-
1514
- Continue without waiting.
1515
- </if>
1516
-
1517
- <if mode="interactive" OR="custom with gates.issues_review true">
1518
- Present issues and wait for acknowledgment before proceeding.
1519
- </if>
373
+ If SUMMARY "Issues Encountered" ≠ "None": yolo → log and continue. Interactive → present issues, wait for acknowledgment.
1520
374
  </step>
1521
375
 
1522
376
  <step name="update_roadmap">
1523
- Update the roadmap file:
1524
-
1525
377
  ```bash
1526
- ROADMAP_FILE=".planning/ROADMAP.md"
378
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs roadmap update-plan-progress "${PHASE}"
1527
379
  ```
1528
-
1529
- **If more plans remain in this phase:**
1530
-
1531
- - Update plan count: "2/3 plans complete"
1532
- - Keep phase status as "In progress"
1533
-
1534
- **If this was the last plan in the phase:**
1535
-
1536
- - Mark phase complete: status → "Complete"
1537
- - Add completion date
380
+ Counts PLAN vs SUMMARY files on disk. Updates progress table row with correct count and status (`In Progress` or `Complete` with date).
1538
381
  </step>
1539
382
 
1540
- <step name="git_commit_metadata">
1541
- Commit execution metadata (SUMMARY + STATE + ROADMAP):
1542
-
1543
- **Note:** All task code has already been committed during execution (one commit per task).
1544
- PLAN.md was already committed during plan-phase. This final commit captures execution results only.
1545
-
1546
- **Check planning config:**
1547
-
1548
- If `COMMIT_PLANNING_DOCS=false` (set in load_project_state):
1549
- - Skip all git operations for .planning/ files
1550
- - Planning docs exist locally but are gitignored
1551
- - Log: "Skipping planning docs commit (commit_docs: false)"
1552
- - Proceed to next step
1553
-
1554
- If `COMMIT_PLANNING_DOCS=true` (default):
1555
- - Continue with git operations below
1556
-
1557
- **1. Stage execution artifacts:**
1558
-
1559
- ```bash
1560
- git add .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md
1561
- git add .planning/STATE.md
1562
- ```
1563
-
1564
- **2. Stage roadmap:**
383
+ <step name="update_requirements">
384
+ Mark completed requirements from the PLAN.md frontmatter `requirements:` field:
1565
385
 
1566
386
  ```bash
1567
- git add .planning/ROADMAP.md
387
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs requirements mark-complete ${REQ_IDS}
1568
388
  ```
1569
389
 
1570
- **3. Verify staging:**
1571
-
1572
- ```bash
1573
- git status
1574
- # Should show only execution artifacts (SUMMARY, STATE, ROADMAP), no code files
1575
- ```
1576
-
1577
- **4. Commit metadata:**
1578
-
1579
- ```bash
1580
- git commit -m "$(cat <<'EOF'
1581
- docs({phase}-{plan}): complete [plan-name] plan
1582
-
1583
- Tasks completed: [N]/[N]
1584
- - [Task 1 name]
1585
- - [Task 2 name]
1586
- - [Task 3 name]
1587
-
1588
- SUMMARY: .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md
1589
- EOF
1590
- )"
1591
- ```
390
+ Extract requirement IDs from the plan's frontmatter (e.g., `requirements: [AUTH-01, AUTH-02]`). If no requirements field, skip.
391
+ </step>
1592
392
 
1593
- **Example:**
393
+ <step name="git_commit_metadata">
394
+ task code already committed per-task. Commit plan metadata:
1594
395
 
1595
396
  ```bash
1596
- git commit -m "$(cat <<'EOF'
1597
- docs(08-02): complete user registration plan
1598
-
1599
- Tasks completed: 3/3
1600
- - User registration endpoint
1601
- - Password hashing with bcrypt
1602
- - Email confirmation flow
1603
-
1604
- SUMMARY: .planning/phases/08-user-auth/08-02-registration-SUMMARY.md
1605
- EOF
1606
- )"
1607
- ```
1608
-
1609
- **Git log after plan execution:**
1610
-
397
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs commit "docs({phase}-{plan}): complete [plan-name] plan" --files .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md .planning/STATE.md .planning/ROADMAP.md .planning/REQUIREMENTS.md
1611
398
  ```
1612
- abc123f docs(08-02): complete user registration plan
1613
- def456g feat(08-02): add email confirmation flow
1614
- hij789k feat(08-02): implement password hashing with bcrypt
1615
- lmn012o feat(08-02): create user registration endpoint
1616
- ```
1617
-
1618
- Each task has its own commit, followed by one metadata commit documenting plan completion.
1619
-
1620
- See `git-integration.md` (loaded via required_reading) for commit message conventions.
1621
399
  </step>
1622
400
 
1623
401
  <step name="update_codebase_map">
1624
- **If .planning/codebase/ exists:**
1625
-
1626
- Check what changed across all task commits in this plan:
402
+ If .planning/codebase/ doesn't exist: skip.
1627
403
 
1628
404
  ```bash
1629
- # Find first task commit (right after previous plan's docs commit)
1630
405
  FIRST_TASK=$(git log --oneline --grep="feat({phase}-{plan}):" --grep="fix({phase}-{plan}):" --grep="test({phase}-{plan}):" --reverse | head -1 | cut -d' ' -f1)
1631
-
1632
- # Get all changes from first task through now
1633
406
  git diff --name-only ${FIRST_TASK}^..HEAD 2>/dev/null
1634
407
  ```
1635
408
 
1636
- **Update only if structural changes occurred:**
1637
-
1638
- | Change Detected | Update Action |
1639
- |-----------------|---------------|
1640
- | New directory in src/ | STRUCTURE.md: Add to directory layout |
1641
- | package.json deps changed | STACK.md: Add/remove from dependencies list |
1642
- | New file pattern (e.g., first .test.ts) | CONVENTIONS.md: Note new pattern |
1643
- | New external API client | INTEGRATIONS.md: Add service entry with file path |
1644
- | Config file added/changed | STACK.md: Update configuration section |
1645
- | File renamed/moved | Update paths in relevant docs |
1646
-
1647
- **Skip update if only:**
1648
- - Code changes within existing files
1649
- - Bug fixes
1650
- - Content changes (no structural impact)
1651
-
1652
- **Update format:**
1653
- Make single targeted edits - add a bullet point, update a path, or remove a stale entry. Don't rewrite sections.
409
+ Update only structural changes: new src/ dir → STRUCTURE.md | deps → STACK.md | file pattern → CONVENTIONS.md | API client → INTEGRATIONS.md | config → STACK.md | renamed → update paths. Skip code-only/bugfix/content changes.
1654
410
 
1655
411
  ```bash
1656
- git add .planning/codebase/*.md
1657
- git commit --amend --no-edit # Include in metadata commit
412
+ node ~/.config/opencode/get-shit-done/bin/gsd-tools.cjs commit "" --files .planning/codebase/*.md --amend
1658
413
  ```
1659
-
1660
- **If .planning/codebase/ doesn't exist:**
1661
- Skip this step.
1662
414
  </step>
1663
415
 
1664
416
  <step name="offer_next">
1665
- **MANDATORY: Verify remaining work before presenting next steps.**
1666
-
1667
- Do NOT skip this verification. Do NOT assume phase or milestone completion without checking.
1668
-
1669
- **Step 0: Check for USER-SETUP.md**
1670
-
1671
- If `USER_SETUP_CREATED=true` (from generate_user_setup step), always include this warning block at the TOP of completion output:
1672
-
1673
- ```
1674
- ⚠️ USER SETUP REQUIRED
1675
-
1676
- This phase introduced external services requiring manual configuration:
1677
-
1678
- 📋 .planning/phases/{phase-dir}/{phase}-USER-SETUP.md
1679
-
1680
- Quick view:
1681
- - [ ] {ENV_VAR_1}
1682
- - [ ] {ENV_VAR_2}
1683
- - [ ] {Dashboard config task}
1684
-
1685
- Complete this setup for the integration to function.
1686
- Run `cat .planning/phases/{phase-dir}/{phase}-USER-SETUP.md` for full details.
1687
-
1688
- ---
1689
- ```
1690
-
1691
- This warning appears BEFORE "Plan complete" messaging. User sees setup requirements prominently.
1692
-
1693
- **Step 1: Count plans and summaries in current phase**
1694
-
1695
- List files in the phase directory:
417
+ If `USER_SETUP_CREATED=true`: display `⚠️ USER SETUP REQUIRED` with path + env/config tasks at TOP.
1696
418
 
1697
419
  ```bash
1698
420
  ls -1 .planning/phases/[current-phase-dir]/*-PLAN.md 2>/dev/null | wc -l
1699
421
  ls -1 .planning/phases/[current-phase-dir]/*-SUMMARY.md 2>/dev/null | wc -l
1700
422
  ```
1701
423
 
1702
- State the counts: "This phase has [X] plans and [Y] summaries."
1703
-
1704
- **Step 2: Route based on plan completion**
1705
-
1706
- Compare the counts from Step 1:
1707
-
1708
- | Condition | Meaning | Action |
1709
- |-----------|---------|--------|
1710
- | summaries < plans | More plans remain | Go to **Route A** |
1711
- | summaries = plans | Phase complete | Go to Step 3 |
1712
-
1713
- ---
1714
-
1715
- **Route A: More plans remain in this phase**
1716
-
1717
- Identify the next unexecuted plan:
1718
- - Find the first PLAN.md file that has no matching SUMMARY.md
1719
- - read its `<objective>` section
1720
-
1721
- <if mode="yolo">
1722
- ```
1723
- Plan {phase}-{plan} complete.
1724
- Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1725
-
1726
- {Y} of {X} plans complete for Phase {Z}.
1727
-
1728
- ⚡ Auto-continuing: Execute next plan ({phase}-{next-plan})
1729
- ```
1730
-
1731
- Loop back to identify_plan step automatically.
1732
- </if>
1733
-
1734
- <if mode="interactive" OR="custom with gates.execute_next_plan true">
1735
- ```
1736
- Plan {phase}-{plan} complete.
1737
- Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1738
-
1739
- {Y} of {X} plans complete for Phase {Z}.
1740
-
1741
- ---
1742
-
1743
- ## ▶ Next Up
1744
-
1745
- **{phase}-{next-plan}: [Plan Name]** — [objective from next PLAN.md]
1746
-
1747
- `/gsd-execute-phase {phase}`
1748
-
1749
- *`/new` first → fresh context window*
1750
-
1751
- ---
1752
-
1753
- **Also available:**
1754
- - `/gsd-verify-work {phase}-{plan}` — manual acceptance testing before continuing
1755
- - Review what was built before continuing
1756
-
1757
- ---
1758
- ```
1759
-
1760
- Wait for user to clear and run next command.
1761
- </if>
1762
-
1763
- **STOP here if Route A applies. Do not continue to Step 3.**
1764
-
1765
- ---
1766
-
1767
- **Step 3: Check milestone status (only when all plans in phase are complete)**
1768
-
1769
- read ROADMAP.md and extract:
1770
- 1. Current phase number (from the plan just completed)
1771
- 2. All phase numbers listed in the current milestone section
1772
-
1773
- To find phases in the current milestone, look for:
1774
- - Phase headers: lines starting with `### Phase` or `#### Phase`
1775
- - Phase list items: lines like `- [ ] **Phase X:` or `- [x] **Phase X:`
1776
-
1777
- Count total phases in the current milestone and identify the highest phase number.
1778
-
1779
- State: "Current phase is {X}. Milestone has {N} phases (highest: {Y})."
1780
-
1781
- **Step 4: Route based on milestone status**
1782
-
1783
- | Condition | Meaning | Action |
1784
- |-----------|---------|--------|
1785
- | current phase < highest phase | More phases remain | Go to **Route B** |
1786
- | current phase = highest phase | Milestone complete | Go to **Route C** |
1787
-
1788
- ---
1789
-
1790
- **Route B: Phase complete, more phases remain in milestone**
1791
-
1792
- read ROADMAP.md to get the next phase's name and goal.
1793
-
1794
- ```
1795
- Plan {phase}-{plan} complete.
1796
- Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1797
-
1798
- ## ✓ Phase {Z}: {Phase Name} Complete
1799
-
1800
- All {Y} plans finished.
1801
-
1802
- ---
1803
-
1804
- ## ▶ Next Up
1805
-
1806
- **Phase {Z+1}: {Next Phase Name}** — {Goal from ROADMAP.md}
1807
-
1808
- `/gsd-plan-phase {Z+1}`
1809
-
1810
- *`/new` first → fresh context window*
1811
-
1812
- ---
1813
-
1814
- **Also available:**
1815
- - `/gsd-verify-work {Z}` — manual acceptance testing before continuing
1816
- - `/gsd-discuss-phase {Z+1}` — gather context first
1817
- - Review phase accomplishments before continuing
1818
-
1819
- ---
1820
- ```
1821
-
1822
- ---
1823
-
1824
- **Route C: Milestone complete (all phases done)**
1825
-
1826
- ```
1827
- 🎉 MILESTONE COMPLETE!
1828
-
1829
- Plan {phase}-{plan} complete.
1830
- Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1831
-
1832
- ## ✓ Phase {Z}: {Phase Name} Complete
1833
-
1834
- All {Y} plans finished.
1835
-
1836
- ╔═══════════════════════════════════════════════════════╗
1837
- ║ All {N} phases complete! Milestone is 100% done. ║
1838
- ╚═══════════════════════════════════════════════════════╝
1839
-
1840
- ---
1841
-
1842
- ## ▶ Next Up
1843
-
1844
- **Complete Milestone** — archive and prepare for next
1845
-
1846
- `/gsd-complete-milestone`
1847
-
1848
- *`/new` first → fresh context window*
1849
-
1850
- ---
1851
-
1852
- **Also available:**
1853
- - `/gsd-verify-work` — manual acceptance testing before completing milestone
1854
- - `/gsd-add-phase <description>` — add another phase before completing
1855
- - Review accomplishments before archiving
1856
-
1857
- ---
1858
- ```
424
+ | Condition | Route | Action |
425
+ |-----------|-------|--------|
426
+ | summaries < plans | **A: More plans** | Find next PLAN without SUMMARY. Yolo: auto-continue. Interactive: show next plan, suggest `/gsd-execute-phase {phase}` + `/gsd-verify-work`. STOP here. |
427
+ | summaries = plans, current < highest phase | **B: Phase done** | Show completion, suggest `/gsd-plan-phase {Z+1}` + `/gsd-verify-work {Z}` + `/gsd-discuss-phase {Z+1}` |
428
+ | summaries = plans, current = highest phase | **C: Milestone done** | Show banner, suggest `/gsd-complete-milestone` + `/gsd-verify-work` + `/gsd-add-phase` |
1859
429
 
430
+ All routes: `/new` first for fresh context.
1860
431
  </step>
1861
432
 
1862
433
  </process>
@@ -1871,4 +442,4 @@ All {Y} plans finished.
1871
442
  - ROADMAP.md updated
1872
443
  - If codebase map exists: map updated with execution changes (or skipped if no significant changes)
1873
444
  - If USER-SETUP.md created: prominently surfaced in completion output
1874
- </success_criteria>
445
+ </success_criteria>