gsd-opencode 1.30.0 → 1.33.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 (113) 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-set-profile.md +0 -1
  32. package/commands/gsd/gsd-thread.md +1 -1
  33. package/commands/gsd/gsd-workstreams.md +7 -2
  34. package/get-shit-done/bin/gsd-tools.cjs +42 -8
  35. package/get-shit-done/bin/lib/commands.cjs +68 -14
  36. package/get-shit-done/bin/lib/config.cjs +18 -10
  37. package/get-shit-done/bin/lib/core.cjs +383 -80
  38. package/get-shit-done/bin/lib/docs.cjs +267 -0
  39. package/get-shit-done/bin/lib/frontmatter.cjs +47 -2
  40. package/get-shit-done/bin/lib/init.cjs +85 -5
  41. package/get-shit-done/bin/lib/milestone.cjs +21 -0
  42. package/get-shit-done/bin/lib/model-profiles.cjs +2 -0
  43. package/get-shit-done/bin/lib/phase.cjs +232 -189
  44. package/get-shit-done/bin/lib/profile-output.cjs +97 -1
  45. package/get-shit-done/bin/lib/roadmap.cjs +137 -113
  46. package/get-shit-done/bin/lib/schema-detect.cjs +238 -0
  47. package/get-shit-done/bin/lib/security.cjs +5 -3
  48. package/get-shit-done/bin/lib/state.cjs +366 -44
  49. package/get-shit-done/bin/lib/verify.cjs +158 -14
  50. package/get-shit-done/bin/lib/workstream.cjs +6 -2
  51. package/get-shit-done/references/agent-contracts.md +79 -0
  52. package/get-shit-done/references/artifact-types.md +113 -0
  53. package/get-shit-done/references/context-budget.md +49 -0
  54. package/get-shit-done/references/continuation-format.md +15 -15
  55. package/get-shit-done/references/domain-probes.md +125 -0
  56. package/get-shit-done/references/gate-prompts.md +100 -0
  57. package/get-shit-done/references/model-profiles.md +2 -2
  58. package/get-shit-done/references/planner-gap-closure.md +62 -0
  59. package/get-shit-done/references/planner-reviews.md +39 -0
  60. package/get-shit-done/references/planner-revision.md +87 -0
  61. package/get-shit-done/references/planning-config.md +15 -0
  62. package/get-shit-done/references/revision-loop.md +97 -0
  63. package/get-shit-done/references/ui-brand.md +2 -2
  64. package/get-shit-done/references/universal-anti-patterns.md +58 -0
  65. package/get-shit-done/references/workstream-flag.md +56 -3
  66. package/get-shit-done/templates/SECURITY.md +61 -0
  67. package/get-shit-done/templates/VALIDATION.md +3 -3
  68. package/get-shit-done/templates/claude-md.md +27 -4
  69. package/get-shit-done/templates/config.json +4 -0
  70. package/get-shit-done/templates/debug-subagent-prompt.md +2 -6
  71. package/get-shit-done/templates/planner-subagent-prompt.md +2 -10
  72. package/get-shit-done/workflows/add-phase.md +2 -2
  73. package/get-shit-done/workflows/add-todo.md +1 -1
  74. package/get-shit-done/workflows/analyze-dependencies.md +96 -0
  75. package/get-shit-done/workflows/audit-milestone.md +8 -12
  76. package/get-shit-done/workflows/autonomous.md +158 -13
  77. package/get-shit-done/workflows/check-todos.md +2 -2
  78. package/get-shit-done/workflows/complete-milestone.md +13 -4
  79. package/get-shit-done/workflows/diagnose-issues.md +8 -6
  80. package/get-shit-done/workflows/discovery-phase.md +1 -1
  81. package/get-shit-done/workflows/discuss-phase-assumptions.md +24 -6
  82. package/get-shit-done/workflows/discuss-phase-power.md +291 -0
  83. package/get-shit-done/workflows/discuss-phase.md +153 -20
  84. package/get-shit-done/workflows/docs-update.md +1093 -0
  85. package/get-shit-done/workflows/execute-phase.md +362 -66
  86. package/get-shit-done/workflows/execute-plan.md +1 -1
  87. package/get-shit-done/workflows/help.md +9 -6
  88. package/get-shit-done/workflows/insert-phase.md +2 -2
  89. package/get-shit-done/workflows/manager.md +27 -26
  90. package/get-shit-done/workflows/map-codebase.md +10 -32
  91. package/get-shit-done/workflows/new-milestone.md +14 -8
  92. package/get-shit-done/workflows/new-project.md +48 -25
  93. package/get-shit-done/workflows/next.md +1 -1
  94. package/get-shit-done/workflows/note.md +1 -1
  95. package/get-shit-done/workflows/pause-work.md +73 -10
  96. package/get-shit-done/workflows/plan-milestone-gaps.md +2 -2
  97. package/get-shit-done/workflows/plan-phase.md +184 -32
  98. package/get-shit-done/workflows/progress.md +20 -20
  99. package/get-shit-done/workflows/quick.md +102 -84
  100. package/get-shit-done/workflows/research-phase.md +2 -6
  101. package/get-shit-done/workflows/resume-project.md +4 -4
  102. package/get-shit-done/workflows/review.md +56 -3
  103. package/get-shit-done/workflows/secure-phase.md +154 -0
  104. package/get-shit-done/workflows/settings.md +13 -2
  105. package/get-shit-done/workflows/ship.md +13 -4
  106. package/get-shit-done/workflows/transition.md +6 -6
  107. package/get-shit-done/workflows/ui-phase.md +4 -14
  108. package/get-shit-done/workflows/ui-review.md +25 -7
  109. package/get-shit-done/workflows/update.md +165 -16
  110. package/get-shit-done/workflows/validate-phase.md +1 -11
  111. package/get-shit-done/workflows/verify-phase.md +127 -6
  112. package/get-shit-done/workflows/verify-work.md +69 -21
  113. package/package.json +1 -1
@@ -25,6 +25,9 @@ via filesystem and git state.
25
25
 
26
26
  <required_reading>
27
27
  read STATE.md before any operation to load project context.
28
+
29
+ @$HOME/.config/opencode/get-shit-done/references/agent-contracts.md
30
+ @$HOME/.config/opencode/get-shit-done/references/context-budget.md
28
31
  </required_reading>
29
32
 
30
33
  <available_agent_types>
@@ -66,7 +69,28 @@ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
66
69
  AGENT_SKILLS=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-executor 2>/dev/null)
67
70
  ```
68
71
 
69
- Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`.
72
+ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
73
+
74
+ **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
75
+
76
+ read worktree config:
77
+
78
+ ```bash
79
+ USE_WORKTREES=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
80
+ ```
81
+
82
+ When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees.
83
+
84
+ read context window size for adaptive prompt enrichment:
85
+
86
+ ```bash
87
+ CONTEXT_WINDOW=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get context_window 2>/dev/null || echo "200000")
88
+ ```
89
+
90
+ When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
91
+ - Executor agents receive prior wave SUMMARY.md files and the phase CONTEXT.md/RESEARCH.md
92
+ - Verifier agents receive all PLAN.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
93
+ - This enables cross-phase awareness and history-aware verification
70
94
 
71
95
  **If `phase_found` is false:** Error — phase directory not found.
72
96
  **If `plan_count` is 0:** Error — no plans found in phase.
@@ -91,6 +115,30 @@ fi
91
115
  ```
92
116
  </step>
93
117
 
118
+ <step name="check_blocking_antipatterns" priority="first">
119
+ **MANDATORY — Check for blocking anti-patterns before any other work.**
120
+
121
+ Look for a `.continue-here.md` in the current phase directory:
122
+
123
+ ```bash
124
+ ls ${phase_dir}/.continue-here.md 2>/dev/null || true
125
+ ```
126
+
127
+ If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
128
+
129
+ **If one or more `blocking` anti-patterns are found:**
130
+
131
+ This step cannot be skipped. Before proceeding to `check_interactive_mode` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
132
+
133
+ 1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
134
+ 2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
135
+ 3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
136
+
137
+ 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.
138
+
139
+ **If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_interactive_mode`.
140
+ </step>
141
+
94
142
  <step name="check_interactive_mode">
95
143
  **Parse `--interactive` flag from $ARGUMENTS.**
96
144
 
@@ -199,7 +247,41 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
199
247
 
200
248
  **For each wave:**
201
249
 
202
- 1. **Describe what's being built (BEFORE spawning):**
250
+ 1. **Intra-wave files_modified overlap check (BEFORE spawning):**
251
+
252
+ Before spawning any agents for this wave, inspect the `files_modified` list of all plans
253
+ in the wave. Check every pair of plans in the wave — if any two plans share even one file
254
+ in their `files_modified` lists, those plans have an implicit dependency and MUST NOT run
255
+ in parallel.
256
+
257
+ **Detection algorithm (pseudocode):**
258
+ ```
259
+ seen_files = {}
260
+ overlapping_plans = []
261
+ for each plan in wave_plans:
262
+ for each file in plan.files_modified:
263
+ if file in seen_files:
264
+ overlapping_plans.add(plan, seen_files[file]) # both plans overlap on this file
265
+ else:
266
+ seen_files[file] = plan
267
+ ```
268
+
269
+ **If overlap is detected:**
270
+ - Warn the user:
271
+ ```
272
+ ⚠ Intra-wave files_modified overlap detected in Wave {N}:
273
+ Plan {A} and Plan {B} both modify {file}
274
+ Running these plans sequentially to avoid parallel worktree conflicts.
275
+ ```
276
+ - Override `PARALLELIZATION` to `false` for this wave only — run all plans in the wave
277
+ sequentially regardless of the global parallelization setting.
278
+ - This is a safety net for plans that were incorrectly assigned to the same wave.
279
+ The planner should have caught this; flag it as a planning defect so the user can
280
+ replan the phase if desired.
281
+
282
+ **If no overlap:** proceed normally (parallel if `PARALLELIZATION=true`).
283
+
284
+ 2. **Describe what's being built (BEFORE spawning):**
203
285
 
204
286
  read each plan's `<objective>`. Extract what's being built and why.
205
287
 
@@ -217,57 +299,127 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
217
299
  - Bad: "Executing terrain generation plan"
218
300
  - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
219
301
 
220
- 2. **Spawn executor agents:**
302
+ 3. **Spawn executor agents:**
221
303
 
222
304
  Pass paths only — executors read files themselves with their fresh context window.
223
305
  For 200k models, this keeps orchestrator context lean (~10-15%).
224
306
  For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
225
307
 
308
+ **Worktree mode** (`USE_WORKTREES` is not `false`):
309
+
310
+ Before spawning, capture the current HEAD:
311
+ ```bash
312
+ EXPECTED_BASE=$(git rev-parse HEAD)
313
+ ```
314
+
315
+ **Sequential dispatch for parallel execution (waves with 2+ agents):**
316
+ When spawning multiple agents in a wave, dispatch each `task()` call **one at a time
317
+ with `run_in_background: true`** — do NOT send all task calls in a single message.
318
+ `git worktree add` acquires an exclusive lock on `.git/config.lock`, so simultaneous
319
+ calls race for this lock and fail. Sequential dispatch ensures each worktree finishes
320
+ creation before the next begins (the round-trip latency of each tool call provides
321
+ natural spacing), while all agents still **run in parallel** once created.
322
+
226
323
  ```
227
- task(
228
- subagent_type="gsd-executor",
229
- model="{executor_model}",
230
- isolation="worktree",
231
- prompt="
232
- <objective>
233
- Execute plan {plan_number} of phase {phase_number}-{phase_name}.
234
- Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
235
- </objective>
236
-
237
- <parallel_execution>
238
- You are running as a PARALLEL executor agent. Use --no-verify on all git
239
- commits to avoid pre-commit hook contention with other agents. The
240
- orchestrator validates hooks once after all agents complete.
241
- For gsd-tools commits: add --no-verify flag.
242
- For direct git commits: use git commit --no-verify -m "..."
243
- </parallel_execution>
244
-
245
- <execution_context>
246
- @$HOME/.config/opencode/get-shit-done/workflows/execute-plan.md
247
- @$HOME/.config/opencode/get-shit-done/templates/summary.md
248
- @$HOME/.config/opencode/get-shit-done/references/checkpoints.md
249
- @$HOME/.config/opencode/get-shit-done/references/tdd.md
250
- </execution_context>
251
-
252
- <files_to_read>
253
- read these files at execution start using the read tool:
254
- - {phase_dir}/{plan_file} (Plan)
255
- - .planning/PROJECT.md (Project context core value, requirements, evolution rules)
256
- - .planning/STATE.md (State)
257
- - .planning/config.json (Config, if exists)
258
- - ./AGENTS.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
259
- - .OpenCode/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
260
- </files_to_read>
261
-
262
- ${AGENT_SKILLS}
263
-
264
- <mcp_tools>
265
- If AGENTS.md or project instructions reference MCP tools (e.g. jCodeMunch, context7,
266
- or other MCP servers), prefer those tools over grep/glob for code navigation when available.
267
- MCP tools often save significant tokens by providing structured code indexes.
268
- Check tool availability first if MCP tools are not accessible, fall back to grep/glob.
269
- </mcp_tools>
324
+ # CORRECT: dispatch one task() per message, each with run_in_background: true
325
+ # → worktrees created sequentially, agents execute in parallel
326
+ #
327
+ # WRONG: multiple task() calls in a single message
328
+ # → simultaneous git worktree add → .git/config.lock contention → failures
329
+ ```
330
+
331
+ ```
332
+ @gsd-executor "
333
+ <objective>
334
+ Execute plan {plan_number} of phase {phase_number}-{phase_name}.
335
+ Commit each task atomically. Create SUMMARY.md.
336
+ Do NOT update STATE.md or ROADMAP.md the orchestrator owns those writes after all worktree agents in the wave complete.
337
+ </objective>
338
+
339
+ <worktree_branch_check>
340
+ FIRST ACTION before any other work: verify this worktree's branch is based on the correct commit.
341
+
342
+ Run:
343
+ ```bash
344
+ ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
345
+ CURRENT_HEAD=$(git rev-parse HEAD)
346
+ ```
347
+
348
+ If `ACTUAL_BASE` != `{EXPECTED_BASE}` (i.e. the worktree branch was created from an older
349
+ base such as `main` instead of the feature branch HEAD), rebase onto the correct base:
350
+ ```bash
351
+ git rebase --onto {EXPECTED_BASE} $(git rev-parse --abbrev-ref HEAD~1 2>/dev/null || git rev-parse HEAD^) HEAD 2>/dev/null || true
352
+ # If rebase fails or is a no-op, reset the branch to start from the correct base:
353
+ git reset --soft {EXPECTED_BASE}
354
+ ```
355
+
356
+ If `ACTUAL_BASE` == `{EXPECTED_BASE}`: the branch base is correct, proceed immediately.
357
+
358
+ This check fixes a known issue on Windows where `EnterWorktree` creates branches from
359
+ `main` instead of the current feature branch HEAD.
360
+ </worktree_branch_check>
361
+
362
+ <parallel_execution>
363
+ You are running as a PARALLEL executor agent. Use --no-verify on all git
364
+ commits to avoid pre-commit hook contention with other agents. The
365
+ orchestrator validates hooks once after all agents complete.
366
+ For gsd-tools commits: add --no-verify flag.
367
+ For direct git commits: use git commit --no-verify -m "..."
368
+ </parallel_execution>
369
+
370
+ <execution_context>
371
+ @$HOME/.config/opencode/get-shit-done/workflows/execute-plan.md
372
+ @$HOME/.config/opencode/get-shit-done/templates/summary.md
373
+ @$HOME/.config/opencode/get-shit-done/references/checkpoints.md
374
+ @$HOME/.config/opencode/get-shit-done/references/tdd.md
375
+ </execution_context>
376
+
377
+ <files_to_read>
378
+ read these files at execution start using the read tool:
379
+ - {phase_dir}/{plan_file} (Plan)
380
+ - .planning/PROJECT.md (Project context — core value, requirements, evolution rules)
381
+ - .planning/STATE.md (State)
382
+ - .planning/config.json (Config, if exists)
383
+ ${CONTEXT_WINDOW >= 500000 ? `
384
+ - ${phase_dir}/*-CONTEXT.md (User decisions from discuss-phase — honors locked choices)
385
+ - ${phase_dir}/*-RESEARCH.md (Technical research — pitfalls and patterns to follow)
386
+ - ${prior_wave_summaries} (SUMMARY.md files from earlier waves in this phase — what was already built)
387
+ ` : ''}
388
+ - ./AGENTS.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
389
+ - .OpenCode/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
390
+ </files_to_read>
391
+
392
+ ${AGENT_SKILLS}
393
+
394
+ <mcp_tools>
395
+ If AGENTS.md or project instructions reference MCP tools (e.g. jCodeMunch, context7,
396
+ or other MCP servers), prefer those tools over grep/glob for code navigation when available.
397
+ MCP tools often save significant tokens by providing structured code indexes.
398
+ Check tool availability first — if MCP tools are not accessible, fall back to grep/glob.
399
+ </mcp_tools>
400
+
401
+ <success_criteria>
402
+ - [ ] All tasks executed
403
+ - [ ] Each task committed individually
404
+ - [ ] SUMMARY.md created in plan directory
405
+ </success_criteria>
406
+ "
407
+ ```
408
+
409
+ **Sequential mode** (`USE_WORKTREES` is `false`):
270
410
 
411
+ Omit `isolation="worktree"` from the task call. Replace the `<parallel_execution>` block with:
412
+
413
+ ```
414
+ <sequential_execution>
415
+ You are running as a SEQUENTIAL executor agent on the main working tree.
416
+ Use normal git commits (with hooks). Do NOT use --no-verify.
417
+ </sequential_execution>
418
+ ```
419
+
420
+ The sequential mode task prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
421
+
422
+ ```
271
423
  <success_criteria>
272
424
  - [ ] All tasks executed
273
425
  - [ ] Each task committed individually
@@ -275,11 +427,11 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
275
427
  - [ ] STATE.md updated with position and decisions
276
428
  - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
277
429
  </success_criteria>
278
- "
279
- )
280
430
  ```
281
431
 
282
- 3. **Wait for all agents in wave to complete.**
432
+ When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting — multiple agents writing to the same working tree concurrently would cause conflicts.
433
+
434
+ 4. **Wait for all agents in wave to complete.**
283
435
 
284
436
  **Completion signal fallback (Copilot and runtimes where task() may not return):**
285
437
 
@@ -293,17 +445,17 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
293
445
  ```
294
446
 
295
447
  **If SUMMARY.md exists AND commits are found:** The agent completed successfully —
296
- treat as done and proceed to step 4. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
448
+ treat as done and proceed to step 5. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
297
449
 
298
450
  **If SUMMARY.md does NOT exist after a reasonable wait:** The agent may still be
299
451
  running or may have failed silently. Check `git log --oneline -5` for recent
300
452
  activity. If commits are still appearing, wait longer. If no activity, report
301
- the plan as failed and route to the failure handler in step 5.
453
+ the plan as failed and route to the failure handler in step 6.
302
454
 
303
455
  **This fallback applies automatically to all runtimes.** OpenCode's task() normally
304
456
  returns synchronously, but the fallback ensures resilience if it doesn't.
305
457
 
306
- 4. **Post-wave hook validation (parallel mode only):**
458
+ 5. **Post-wave hook validation (parallel mode only):**
307
459
 
308
460
  When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
309
461
  ```bash
@@ -313,7 +465,56 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
313
465
  ```
314
466
  If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
315
467
 
316
- 5. **Report completion spot-check claims first:**
468
+ 5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
469
+
470
+ When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
471
+
472
+ ```bash
473
+ # List worktrees created by this wave's agents
474
+ WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
475
+
476
+ for WT in $WORKTREES; do
477
+ # Get the branch name for this worktree
478
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
479
+ if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
480
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
481
+
482
+ # Merge the worktree branch into the current branch
483
+ git merge "$WT_BRANCH" --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
484
+ echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
485
+ continue
486
+ }
487
+
488
+ # Remove the worktree
489
+ git worktree remove "$WT" --force 2>/dev/null || true
490
+
491
+ # Delete the temporary branch
492
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
493
+ fi
494
+ done
495
+ ```
496
+
497
+ **If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
498
+
499
+ **If no worktrees found:** Skip silently — agents may have been spawned without worktree isolation.
500
+
501
+ 5.6. **Post-wave shared artifact update (worktree mode only):**
502
+
503
+ When executor agents ran with `isolation="worktree"`, they skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once:
504
+
505
+ ```bash
506
+ # Update ROADMAP.md for each completed plan in this wave
507
+ for PLAN_ID in ${WAVE_PLAN_IDS}; do
508
+ node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" roadmap update-plan-progress "${PHASE_NUMBER}" "${PLAN_ID}" completed
509
+ done
510
+
511
+ ```
512
+
513
+ Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
514
+
515
+ **If `workflow.use_worktrees` is `false`:** Sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
516
+
517
+ 6. **Report completion — spot-check claims first:**
317
518
 
318
519
  For each SUMMARY.md:
319
520
  - Verify first 2 files from `key-files.created` exist on disk
@@ -338,13 +539,13 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
338
539
  - Bad: "Wave 2 complete. Proceeding to Wave 3."
339
540
  - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
340
541
 
341
- 5. **Handle failures:**
542
+ 7. **Handle failures:**
342
543
 
343
- **Known OpenCode bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a OpenCode runtime bug — not a GSD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 4 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
544
+ **Known OpenCode bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a OpenCode runtime bug — not a GSD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 5 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
344
545
 
345
546
  For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
346
547
 
347
- 5b. **Pre-wave dependency check (waves 2+ only):**
548
+ 7b. **Pre-wave dependency check (waves 2+ only):**
348
549
 
349
550
  Before spawning wave N+1, for each plan in the upcoming wave:
350
551
  ```bash
@@ -365,9 +566,9 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
365
566
 
366
567
  Key-links referencing files in the CURRENT (upcoming) wave are skipped.
367
568
 
368
- 6. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
569
+ 8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
369
570
 
370
- 7. **Proceed to next wave.**
571
+ 9. **Proceed to next wave.**
371
572
  </step>
372
573
 
373
574
  <step name="checkpoint_handling">
@@ -436,6 +637,27 @@ After all waves:
436
637
  ### Issues Encountered
437
638
  [Aggregate from SUMMARYs, or "None"]
438
639
  ```
640
+
641
+ **Security gate check:**
642
+ ```bash
643
+ SECURITY_CFG=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
644
+ SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
645
+ ```
646
+
647
+ If `SECURITY_CFG` is `false`: skip.
648
+
649
+ If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
650
+ Include in the next-steps routing output:
651
+ ```
652
+ ⚠ Security enforcement enabled — run before advancing:
653
+ /gsd-secure-phase {PHASE} ${GSD_WS}
654
+ ```
655
+
656
+ If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
657
+ ```
658
+ ⚠ Security gate: {threats_open} threats open
659
+ /gsd-secure-phase {PHASE} — resolve before advancing
660
+ ```
439
661
  </step>
440
662
 
441
663
  <step name="handle_partial_wave_execution">
@@ -580,6 +802,72 @@ Options:
580
802
  Use question to present the options.
581
803
  </step>
582
804
 
805
+ <step name="schema_drift_gate">
806
+ Post-execution schema drift detection. Catches false-positive verification where
807
+ build/types pass because TypeScript types come from config, not the live database.
808
+
809
+ **Run after execution completes but BEFORE verification marks success.**
810
+
811
+ ```bash
812
+ SCHEMA_DRIFT=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
813
+ ```
814
+
815
+ Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
816
+
817
+ **If `drift_detected` is false:** Skip to verify_phase_goal.
818
+
819
+ **If `drift_detected` is true AND `blocking` is true:**
820
+
821
+ Check for override:
822
+ ```bash
823
+ SKIP_SCHEMA=$(echo "${GSD_SKIP_SCHEMA_CHECK:-false}")
824
+ ```
825
+
826
+ **If `SKIP_SCHEMA` is `true`:**
827
+
828
+ Display:
829
+ ```
830
+ ⚠ Schema drift detected but GSD_SKIP_SCHEMA_CHECK=true — bypassing gate.
831
+
832
+ Schema files changed: {schema_files}
833
+ ORMs requiring push: {unpushed_orms}
834
+
835
+ Proceeding to verification (database may be out of sync).
836
+ ```
837
+ → Continue to verify_phase_goal.
838
+
839
+ **If `SKIP_SCHEMA` is not `true`:**
840
+
841
+ BLOCK verification. Display:
842
+
843
+ ```
844
+ ## BLOCKED: Schema Drift Detected
845
+
846
+ Schema-relevant files changed during this phase but no database push command
847
+ was executed. Build and type checks pass because TypeScript types come from
848
+ config, not the live database — verification would produce a false positive.
849
+
850
+ Schema files changed: {schema_files}
851
+ ORMs requiring push: {unpushed_orms}
852
+
853
+ Required push commands:
854
+ {For each unpushed ORM, show the push command from the message}
855
+
856
+ Options:
857
+ 1. Run push command now (recommended) — execute the push, then re-verify
858
+ 2. Skip schema check (GSD_SKIP_SCHEMA_CHECK=true) — bypass this gate
859
+ 3. Abort — stop execution and investigate
860
+ ```
861
+
862
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use question.
863
+
864
+ **If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
865
+
866
+ **If user selects option 2:** Set override and continue to verify_phase_goal.
867
+
868
+ **If user selects option 3:** Stop execution. Report partial completion.
869
+ </step>
870
+
583
871
  <step name="verify_phase_goal">
584
872
  Verify phase achieved its GOAL, not just completed tasks.
585
873
 
@@ -588,18 +876,26 @@ VERIFIER_SKILLS=$(node "$HOME/.config/opencode/get-shit-done/bin/gsd-tools.cjs"
588
876
  ```
589
877
 
590
878
  ```
591
- task(
592
- prompt="Verify phase {phase_number} goal achievement.
879
+ @gsd-verifier "Verify phase {phase_number} goal achievement.
593
880
  Phase directory: {phase_dir}
594
881
  Phase goal: {goal from ROADMAP.md}
595
882
  Phase requirement IDs: {phase_req_ids}
596
883
  Check must_haves against actual codebase.
597
884
  Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
598
885
  Create VERIFICATION.md.
599
- ${VERIFIER_SKILLS}",
600
- subagent_type="gsd-verifier",
601
- model="{verifier_model}"
602
- )
886
+
887
+ <files_to_read>
888
+ read these files before verification:
889
+ - {phase_dir}/*-PLAN.md (All plans — understand intent, check must_haves)
890
+ - {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
891
+ - .planning/REQUIREMENTS.md (Requirement traceability)
892
+ ${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
893
+ - {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
894
+ - Prior VERIFICATION.md files from earlier phases (regression check)
895
+ ` : ''}
896
+ </files_to_read>
897
+
898
+ ${VERIFIER_SKILLS}"
603
899
  ```
604
900
 
605
901
  read status:
@@ -688,9 +984,9 @@ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/gsd-progress
688
984
  ---
689
985
  ## ▶ Next Up
690
986
 
691
- `/gsd-plan-phase {X} --gaps ${GSD_WS}`
987
+ `/new` then:
692
988
 
693
- *`/new` first fresh context window*
989
+ `/gsd-plan-phase {X} --gaps ${GSD_WS}`
694
990
 
695
991
  Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
696
992
  Also: `/gsd-verify-work {X} ${GSD_WS}` — manual testing first
@@ -72,7 +72,7 @@ grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
72
72
  | Verify-only | B (segmented) | Segments between checkpoints. After none/human-verify → SUBAGENT. After decision/human-action → MAIN |
73
73
  | Decision | C (main) | Execute entirely in main context |
74
74
 
75
- **Pattern A:** init_agent_tracking → spawn task(subagent_type="gsd-executor", model=executor_model, isolation="worktree") 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.
75
+ **Pattern A:** init_agent_tracking → capture `EXPECTED_BASE=$(git rev-parse HEAD)` → 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. **Include `isolation="worktree"` only if `workflow.use_worktrees` is not `false`** (read via `config-get workflow.use_worktrees`). **When using `isolation="worktree"`, include a `<worktree_branch_check>` block in the prompt** instructing the executor to run `git merge-base HEAD {EXPECTED_BASE}` and, if the result differs from `{EXPECTED_BASE}`, reset the branch base with `git reset --soft {EXPECTED_BASE}` before starting work. This corrects a known issue on Windows where `EnterWorktree` creates branches from `main` instead of the feature branch HEAD.
76
76
 
77
77
  **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.
78
78
 
@@ -134,7 +134,7 @@ Usage: `/gsd-do I want to start a new milestone`
134
134
 
135
135
  ### Quick Mode
136
136
 
137
- **`/gsd-quick [--full] [--discuss] [--research]`**
137
+ **`/gsd-quick [--full] [--validate] [--discuss] [--research]`**
138
138
  Execute small, ad-hoc tasks with GSD guarantees but skip optional agents.
139
139
 
140
140
  Quick mode uses the same system with a shorter path:
@@ -143,14 +143,16 @@ Quick mode uses the same system with a shorter path:
143
143
  - Updates STATE.md tracking (not ROADMAP.md)
144
144
 
145
145
  Flags enable additional quality steps:
146
+ - `--full` — Complete quality pipeline: discussion + research + plan-checking + verification
147
+ - `--validate` — Plan-checking (max 2 iterations) and post-execution verification only
146
148
  - `--discuss` — Lightweight discussion to surface gray areas before planning
147
149
  - `--research` — Focused research agent investigates approaches before planning
148
- - `--full` — Adds plan-checking (max 2 iterations) and post-execution verification
149
150
 
150
- Flags are composable: `--discuss --research --full` gives the complete quality pipeline for a single task.
151
+ Granular flags are composable: `--discuss --research --validate` gives the same as `--full`.
151
152
 
152
153
  Usage: `/gsd-quick`
153
- Usage: `/gsd-quick --research --full`
154
+ Usage: `/gsd-quick --full`
155
+ Usage: `/gsd-quick --research --validate`
154
156
  Result: Creates `.planning/quick/NNN-slug/PLAN.md`, `.planning/quick/NNN-slug/SUMMARY.md`
155
157
 
156
158
  ---
@@ -343,11 +345,12 @@ Usage: `/gsd-ship 4` or `/gsd-ship 4 --draft`
343
345
 
344
346
  ---
345
347
 
346
- **`/gsd-review --phase N [--gemini] [--OpenCode] [--codex] [--all]`**
348
+ **`/gsd-review --phase N [--gemini] [--OpenCode] [--codex] [--coderabbit] [--all]`**
347
349
  Cross-AI peer review — invoke external AI CLIs to independently review phase plans.
348
350
 
349
- - Detects available CLIs (gemini, OpenCode, codex)
351
+ - Detects available CLIs (gemini, OpenCode, codex, coderabbit)
350
352
  - Each CLI reviews plans independently with the same structured prompt
353
+ - CodeRabbit reviews the current git diff (not a prompt) — may take up to 5 minutes
351
354
  - Produces REVIEWS.md with per-reviewer feedback and consensus summary
352
355
  - Feed reviews back into planning: `/gsd-plan-phase N --reviews`
353
356
 
@@ -93,9 +93,9 @@ Project state updated: .planning/STATE.md
93
93
 
94
94
  **Phase {decimal_phase}: {description}** -- urgent insertion
95
95
 
96
- `/gsd-plan-phase {decimal_phase}`
96
+ `/new` then:
97
97
 
98
- *`/new` first -> fresh context window*
98
+ `/gsd-plan-phase {decimal_phase}`
99
99
 
100
100
  ---
101
101