gsdd-cli 0.2.0 → 0.16.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 (43) hide show
  1. package/README.md +67 -34
  2. package/agents/DISTILLATION.md +15 -13
  3. package/agents/planner.md +2 -0
  4. package/bin/adapters/agents.mjs +1 -0
  5. package/bin/adapters/claude.mjs +12 -3
  6. package/bin/adapters/codex.mjs +4 -0
  7. package/bin/adapters/opencode.mjs +13 -4
  8. package/bin/gsdd.mjs +64 -39
  9. package/bin/lib/cli-utils.mjs +1 -1
  10. package/bin/lib/file-ops.mjs +161 -0
  11. package/bin/lib/health-truth.mjs +188 -0
  12. package/bin/lib/health.mjs +65 -12
  13. package/bin/lib/init-flow.mjs +267 -0
  14. package/bin/lib/init-prompts.mjs +247 -0
  15. package/bin/lib/init-runtime.mjs +226 -0
  16. package/bin/lib/init.mjs +19 -378
  17. package/bin/lib/models.mjs +19 -4
  18. package/bin/lib/phase.mjs +100 -14
  19. package/bin/lib/plan-constants.mjs +30 -0
  20. package/bin/lib/provenance.mjs +146 -0
  21. package/bin/lib/templates.mjs +17 -0
  22. package/distilled/DESIGN.md +625 -41
  23. package/distilled/EVIDENCE-INDEX.md +297 -0
  24. package/distilled/README.md +49 -21
  25. package/distilled/SKILL.md +89 -85
  26. package/distilled/templates/agents.block.md +13 -82
  27. package/distilled/templates/agents.md +0 -7
  28. package/distilled/templates/delegates/plan-checker.md +11 -4
  29. package/distilled/workflows/audit-milestone.md +7 -5
  30. package/distilled/workflows/complete-milestone.md +297 -0
  31. package/distilled/workflows/execute.md +188 -19
  32. package/distilled/workflows/map-codebase.md +14 -7
  33. package/distilled/workflows/new-milestone.md +249 -0
  34. package/distilled/workflows/new-project.md +28 -24
  35. package/distilled/workflows/pause.md +42 -6
  36. package/distilled/workflows/plan-milestone-gaps.md +183 -0
  37. package/distilled/workflows/plan.md +78 -13
  38. package/distilled/workflows/progress.md +42 -19
  39. package/distilled/workflows/quick.md +171 -8
  40. package/distilled/workflows/resume.md +121 -11
  41. package/distilled/workflows/verify-work.md +260 -0
  42. package/distilled/workflows/verify.md +124 -33
  43. package/package.json +9 -7
@@ -18,7 +18,7 @@ This is a read-only workflow. No files are created, modified, or deleted. If `.p
18
18
  Check for project artifacts in order:
19
19
 
20
20
  1. **No `.planning/` directory** — tell the user to run `gsdd init`. Stop.
21
- 2. **No `.planning/ROADMAP.md` AND no `.planning/SPEC.md`** — project has no artifacts. Suggest running the `/gsdd:new-project` workflow. Stop.
21
+ 2. **No `.planning/ROADMAP.md` AND no `.planning/SPEC.md`** — project has no artifacts. Suggest running the `/gsdd-new-project` workflow. Stop.
22
22
  3. **No `.planning/ROADMAP.md` BUT `.planning/SPEC.md` exists** — this is a between-milestones state (milestone was completed and archived). Go to Branch F.
23
23
  4. **Both exist** — proceed to derive status.
24
24
  </check_existence>
@@ -51,6 +51,14 @@ Scan `.planning/phases/` for:
51
51
 
52
52
  **Quick task log:**
53
53
  If `.planning/quick/LOG.md` exists, check the last entry for a non-terminal status.
54
+
55
+ <unmerged_commits_check>
56
+ Run `git log main..HEAD --oneline` to detect commits on the current branch that have not been merged to `main`.
57
+
58
+ - If the command exits non-zero or `main` does not exist, skip silently — do not surface an error or any output.
59
+ - If the output is empty, record nothing — the silent path; no status line is added.
60
+ - If the output is non-empty, record the commit lines and count them. This will be surfaced in the status block.
61
+ </unmerged_commits_check>
54
62
  </derive_status>
55
63
 
56
64
  <recent_work>
@@ -78,7 +86,7 @@ Recent Work:
78
86
  - Phase [Y]: [one-liner from SUMMARY.md]
79
87
 
80
88
  [If .continue-here.md exists:]
81
- Checkpoint: paused work found — run /gsdd:resume to restore context
89
+ Checkpoint: paused work found — run /gsdd-resume to restore context
82
90
 
83
91
  [If PLAN without SUMMARY found:]
84
92
  Incomplete execution: Phase [N] has PLAN but no SUMMARY
@@ -89,6 +97,11 @@ Unverified: Phase [N] has SUMMARY but no VERIFICATION
89
97
  [If incomplete quick task found:]
90
98
  Incomplete quick task: [description]
91
99
 
100
+ [If unmerged commits found (git log main..HEAD --oneline returned output):]
101
+ Unmerged commits: [N] commit(s) on this branch not yet merged to main
102
+ → Merge or push this branch before closing the milestone, or verify
103
+ these commits are intentional working-branch state.
104
+
92
105
  [If all phases [x]:]
93
106
  All phases complete — ready for milestone audit
94
107
  ```
@@ -107,8 +120,8 @@ Recent Work:
107
120
  Incomplete execution: Phase 3 has PLAN but no SUMMARY
108
121
 
109
122
  Suggested next action:
110
- Run /gsdd:execute to continue Phase 3 execution
111
- Also available: /gsdd:plan (re-plan), /gsdd:progress (refresh status)
123
+ Run /gsdd-execute to continue Phase 3 execution
124
+ Also available: /gsdd-plan (re-plan), /gsdd-progress (refresh status)
112
125
  ```
113
126
 
114
127
  No ASCII art, no progress bars. Keep it scannable.
@@ -122,8 +135,8 @@ Condition: `.continue-here.md` exists.
122
135
 
123
136
  ```
124
137
  Suggested next action:
125
- Run /gsdd:resume to restore paused session context
126
- Also available: /gsdd:execute (ignore checkpoint, continue current phase), /gsdd:progress (refresh)
138
+ Run /gsdd-resume to restore paused session context
139
+ Also available: /gsdd-execute (ignore checkpoint, continue current phase), /gsdd-progress (refresh)
127
140
  ```
128
141
 
129
142
  **Branch B: Execute (PLAN without SUMMARY in current phase)**
@@ -131,8 +144,8 @@ Condition: Current phase has a PLAN file but no matching SUMMARY.
131
144
 
132
145
  ```
133
146
  Suggested next action:
134
- Run /gsdd:execute to continue Phase [N] execution
135
- Also available: /gsdd:plan (re-plan current phase), /gsdd:verify (if prior phase needs verification)
147
+ Run /gsdd-execute to continue Phase [N] execution
148
+ Also available: /gsdd-plan (re-plan current phase), /gsdd-verify (if prior phase needs verification)
136
149
  ```
137
150
 
138
151
  **Branch C: Plan (no PLAN for current phase)**
@@ -140,8 +153,8 @@ Condition: Current phase has no PLAN files.
140
153
 
141
154
  ```
142
155
  Suggested next action:
143
- Run /gsdd:plan to create a plan for Phase [N]: [phase name]
144
- Also available: /gsdd:quick (sub-hour task outside phases), /gsdd:map-codebase (refresh codebase maps)
156
+ Run /gsdd-plan to create a plan for Phase [N]: [phase name]
157
+ Also available: /gsdd-quick (sub-hour task outside phases), /gsdd-map-codebase (refresh codebase maps)
145
158
  ```
146
159
 
147
160
  **Branch D: Verify (SUMMARY without VERIFICATION)**
@@ -149,8 +162,8 @@ Condition: Current phase has SUMMARY but no VERIFICATION file (verifier enabled)
149
162
 
150
163
  ```
151
164
  Suggested next action:
152
- Run /gsdd:verify to validate Phase [N]
153
- Also available: /gsdd:execute (continue to next phase), /gsdd:plan (plan next phase)
165
+ Run /gsdd-verify to validate Phase [N]
166
+ Also available: /gsdd-execute (continue to next phase), /gsdd-plan (plan next phase)
154
167
  ```
155
168
 
156
169
  **Branch E: Audit milestone (all phases [x])**
@@ -158,17 +171,26 @@ Condition: All phases in ROADMAP.md are marked `[x]`.
158
171
 
159
172
  ```
160
173
  Suggested next action:
161
- Run /gsdd:audit-milestone to audit the completed milestone
162
- Also available: /gsdd:verify (re-verify a specific phase), /gsdd:quick (sub-hour task)
174
+ Run /gsdd-audit-milestone to audit the completed milestone
175
+ Also available: /gsdd-verify (re-verify a specific phase), /gsdd-quick (sub-hour task)
163
176
  ```
164
177
 
165
178
  **Branch F: Between milestones (SPEC.md exists, ROADMAP.md absent)**
166
179
  Condition: `.planning/SPEC.md` exists but `.planning/ROADMAP.md` does not — a milestone was completed and archived.
167
180
 
181
+ Check `.planning/MILESTONES.md`:
182
+ - If MILESTONES.md exists and has at least one milestone entry → this is a subsequent milestone
183
+ - If MILESTONES.md does not exist or is empty → this is the first milestone setup
184
+
168
185
  ```
169
- Suggested next action:
170
- Run /gsdd:new-project to start the next milestone cycle (create a new ROADMAP.md)
171
- Also available: /gsdd:progress (refresh after milestone setup)
186
+ Suggested next action (subsequent milestone):
187
+ Run /gsdd-new-milestone to start the next milestone cycle (gather goals, define requirements, create ROADMAP.md)
188
+ Also available: /gsdd-progress (refresh after milestone setup)
189
+
190
+ Suggested next action (incomplete milestone state — SPEC.md exists but no milestone archived yet):
191
+ Inspect .planning/ manually — a milestone is likely still in progress.
192
+ If a ROADMAP.md was deleted prematurely, re-run /gsdd-new-milestone to restore it.
193
+ Do NOT run /gsdd-new-project — SPEC.md already exists and re-running would overwrite it.
172
194
  ```
173
195
 
174
196
  If none of the above conditions match, report that the project is in a clean state with no obvious next action.
@@ -178,7 +200,7 @@ If none of the above conditions match, report that the project is in a clean sta
178
200
  Handle compound states:
179
201
 
180
202
  - **Checkpoint + unexecuted plan:** Both `.continue-here.md` exists and a PLAN lacks a SUMMARY. Prioritize checkpoint (Branch A) but mention the unexecuted plan in the status block.
181
- - **All phases complete + checkpoint:** All phases `[x]` but a checkpoint exists. Mention both — suggest clearing the stale checkpoint via `/gsdd:resume`, then routing to milestone audit.
203
+ - **All phases complete + checkpoint:** All phases `[x]` but a checkpoint exists. Mention both — suggest clearing the stale checkpoint via `/gsdd-resume`, then routing to milestone audit.
182
204
  - **Phase done but next unplanned:** Current phase has both PLAN and SUMMARY, but the next phase has no PLAN. Show the current phase as complete and suggest planning the next phase (Branch C targeting the next phase).
183
205
  - **No matching condition:** If the project state does not match any branch, report it clearly and suggest the user inspect `.planning/` manually.
184
206
  </edge_cases>
@@ -193,7 +215,8 @@ Handle compound states:
193
215
  - [ ] Routing suggestion is specific (includes phase number and branch-specific output block)
194
216
  - [ ] Named branch output format used with "Also available" alternatives
195
217
  - [ ] No files created, modified, or deleted (read-only workflow)
196
- - [ ] All workflow references use portable `/gsdd:*` command format
218
+ - [ ] All workflow references use portable `/gsdd-*` command format
197
219
  - [ ] No interactive menus, no numbered option lists, no waiting for user selection
198
220
  - [ ] Edge cases handled for compound states
221
+ - [ ] Unmerged-commit warning only appears when `git log main..HEAD --oneline` returns output; silent when empty
199
222
  </success_criteria>
@@ -5,6 +5,16 @@ Quick tasks are for sub-hour work: bug fixes, small features, config changes, on
5
5
  They reuse the same planner, executor, and verifier roles but skip research and synthesizer.
6
6
  </role>
7
7
 
8
+ <anti_patterns>
9
+ - Do not execute before the user sees the plan preview (Step 3.7 must complete before Step 4)
10
+ - Do not proceed past file verification gates if the expected file does not exist on disk — a plan that exists only in conversation context will be lost on compaction
11
+ - Do not ask more than 2 approach clarification questions — if 3+ grey areas exist, recommend /gsdd-plan instead
12
+ - Do not create APPROACH.md for quick tasks — use inline $APPROACH_CONTEXT only
13
+ - Do not update ROADMAP.md or SPEC.md from quick tasks — these are phase-level artifacts
14
+ - Do not skip config.json reads — workflow toggles (discuss, planCheck, verifier) control flow
15
+ - Do not expand scope mid-execution — if the plan reveals architectural work, surface the scope signal (Step 3.6) and let the user decide
16
+ </anti_patterns>
17
+
8
18
  <prerequisites>
9
19
  `.planning/` must exist (from `gsdd init`). ROADMAP.md is NOT required -- quick tasks work during any project phase.
10
20
 
@@ -27,6 +37,9 @@ Store the response as `$DESCRIPTION`. If empty, re-prompt.
27
37
  2. Scan `.planning/quick/` for existing task directories. Calculate `$NEXT_NUM` as the next 3-digit number (001, 002, ...).
28
38
  3. Generate `$SLUG` from `$DESCRIPTION` (lowercase, hyphens, max 40 chars).
29
39
  4. Create `.planning/quick/$NEXT_NUM-$SLUG/`.
40
+ 5. If `.planning/codebase/` exists, read `.planning/codebase/ARCHITECTURE.md` and `.planning/codebase/STACK.md`. Summarize key findings in <=500 words as `$CODEBASE_CONTEXT`. If `.planning/codebase/` does not exist, set `$CODEBASE_CONTEXT` to empty.
41
+ 6. **Session-boundary fallback:** If `.planning/.continue-here.bak` exists, read its `<judgment>` section. Use `<active_constraints>` and `<anti_regression>` rules as task-scoping context (do not violate active constraints; do not regress on listed invariants). After reading, run `gsdd file-op delete .planning/.continue-here.bak --missing ok` (auto-clean).
42
+ 7. Inspect the live branch/worktree surface separately from checkpoint or planning artifacts. If the current branch appears stale/spent, PR-less with overlapping write scope, or otherwise like the wrong execution surface, warn before proceeding. This is advisory for quick tasks unless the mismatch makes the task description materially misleading.
30
43
 
31
44
  If `.planning/quick/` does not exist, create it along with an empty `LOG.md`:
32
45
 
@@ -39,6 +52,44 @@ If `.planning/quick/` does not exist, create it along with an empty `LOG.md`:
39
52
 
40
53
  ---
41
54
 
55
+ ## Step 2.5: Approach clarification (conditional)
56
+
57
+ Read `.planning/config.json`.
58
+ - If `workflow.discuss` is `false` (or key missing): set `$APPROACH_CONTEXT` to empty, skip to Step 3.
59
+ - If `workflow.discuss` is `true`: evaluate `$DESCRIPTION` for ambiguity signals.
60
+
61
+ ### Ambiguity signals
62
+
63
+ | Signal | Detection | Example |
64
+ |--------|-----------|---------|
65
+ | Multiple valid approaches | Description could be solved via distinct patterns | "add caching" (Redis? in-memory? HTTP headers?) |
66
+ | Destructive operations | Contains: `delete`, `remove`, `migrate`, `rename`, `replace`, `rewrite`, `drop` | "remove the old auth middleware" |
67
+ | Vague scope | Contains: `improve`, `fix`, `update`, `refactor`, `clean up`, `optimize` without specifying target | "improve error handling" |
68
+ | Trade-off present | Description implies competing goals (performance vs simplicity, DRY vs explicit) | "make it faster" |
69
+
70
+ If **no signals fire**: set `$APPROACH_CONTEXT` to empty, skip to Step 3 silently.
71
+
72
+ If **any signal fires**: identify 1-2 grey areas and ask targeted questions.
73
+
74
+ ### Question format
75
+
76
+ For each grey area, present 2-3 concrete options with a recommended default:
77
+
78
+ "I'd approach this with **{recommendation}** because {reason}. Want me to proceed, or do you prefer {alternative}?"
79
+
80
+ - If user says "go ahead" / "your call" / presses Enter → use the recommendation.
81
+ - If user specifies a preference → record it.
82
+ - Maximum 2 questions. If the task has 3+ grey areas, it's not a quick task.
83
+
84
+ ### Output
85
+
86
+ Store confirmed decisions as `$APPROACH_CONTEXT` — a short string of user-validated choices.
87
+ Example: "User confirmed: use in-memory LRU cache, not Redis. Keep existing error format."
88
+
89
+ No APPROACH.md file is created. This is inline context only.
90
+
91
+ ---
92
+
42
93
  ## Step 3: Plan
43
94
 
44
95
  Delegate to the planner role in quick mode.
@@ -49,10 +100,13 @@ Delegate to the planner role in quick mode.
49
100
 
50
101
  **Context to provide:**
51
102
  - Task description: `$DESCRIPTION`
103
+ - Approach context: `$APPROACH_CONTEXT` (user-confirmed decisions from Step 2.5 — treat as locked constraints, do not revisit)
104
+ - Codebase context: `$CODEBASE_CONTEXT` (existing architecture and stack — use for orientation, not as constraints; empty if no codebase map exists)
52
105
  - Mode: quick (single plan, 1-3 tasks, no research phase)
53
106
  - Output path: `.planning/quick/$NEXT_NUM-$SLUG/$NEXT_NUM-PLAN.md`
54
107
 
55
108
  **Constraints:**
109
+ - If `$APPROACH_CONTEXT` is non-empty, implement the user's confirmed choices — do not substitute alternatives
56
110
  - Create a SINGLE plan with 1-3 focused tasks
57
111
  - Quick tasks are atomic and self-contained
58
112
  - No research phase, no ROADMAP requirements
@@ -66,13 +120,116 @@ Delegate to the planner role in quick mode.
66
120
  </delegate>
67
121
 
68
122
  After the planner returns:
69
- 1. Verify the plan file exists.
70
- 2. If not found, report the error and stop.
123
+
124
+ **STOP. Verify that `.planning/quick/$NEXT_NUM-$SLUG/$NEXT_NUM-PLAN.md` exists on disk before proceeding to execution. If the file does not exist, report the error to the user and do NOT proceed. A plan that exists only in conversation context will be lost.**
125
+
126
+ ### Quick Plan Self-Check
127
+
128
+ Before proceeding to execution, verify the plan meets minimum quality:
129
+ - [ ] Plan has at least 1 task with `<action>` and `<verify>` sections
130
+ - [ ] Each task's `<verify>` has at least one runnable command
131
+ - [ ] Plan tasks do not exceed 3 (quick scope constraint)
132
+
133
+ This is a self-check, not an independent plan-check. Failures are noted but do NOT block execution — report `reduced_assurance` in the completion summary.
134
+
135
+ ---
136
+
137
+ ## Step 3.5: Independent plan check (conditional)
138
+
139
+ Read `.planning/config.json`.
140
+ - If `workflow.planCheck` is `false` (or key missing): skip to Step 3.6.
141
+ - If `workflow.planCheck` is `true`: delegate to the plan-checker with quick-scoped dimensions.
142
+
143
+ <delegate>
144
+ **Identity:** Plan Checker (quick mode)
145
+ **Instruction:** Read `.planning/templates/delegates/plan-checker.md` for your role contract, then check this quick task plan.
146
+
147
+ **Context to provide:**
148
+ - Task description: `$DESCRIPTION` (treat as the phase goal equivalent)
149
+ - Plan: `.planning/quick/$NEXT_NUM-$SLUG/$NEXT_NUM-PLAN.md`
150
+ - Mode: quick
151
+
152
+ **Constraints:**
153
+ - Check 5 dimensions only: `requirement_coverage`, `task_completeness`, `dependency_correctness`, `scope_sanity`, `must_have_quality`
154
+ - Skip: `key_link_completeness`, `context_compliance`, `goal_achievement`, `approach_alignment`
155
+ - Maximum 1 revision cycle (if blockers found, send back to planner once, then accept result)
156
+ - Blocker threshold: only block on `task_completeness` or `scope_sanity` violations
157
+ - Warnings for other dimensions are noted but do not block
158
+
159
+ **Output:** Checker response (passed | issues_found) with issue details.
160
+ **Return:** Status and issue summary.
161
+ </delegate>
162
+
163
+ If the checker returns `issues_found` with blockers and this is the first cycle:
164
+ 1. Send the issue list back to the planner for targeted revision of the plan file.
165
+ 2. Re-run the checker once more.
166
+ 3. If blockers remain after 1 revision cycle, store `$CHECKER_ISSUES` for display in the plan preview. Do NOT block — the user decides in Step 3.7.
167
+
168
+ If the checker returns `passed`, or `workflow.planCheck` is false, `$CHECKER_ISSUES` is empty.
169
+
170
+ ---
171
+
172
+ ## Step 3.6: Scope signal evaluation
173
+
174
+ Evaluate the plan against quick-scope boundaries. Read the plan file and check:
175
+
176
+ | Signal | Threshold | `$SCOPE_WARNING` text |
177
+ |--------|-----------|----------------------|
178
+ | Files modified | >8 distinct files in plan | "This task touches {N} files — consider `/gsdd-plan` for full ceremony." |
179
+ | Architecture keywords in `$DESCRIPTION` | contains: `refactor`, `migration`, `security`, `auth`, `API design`, `schema`, `database` | "This looks like architectural work — consider `/gsdd-plan` for approach exploration." |
180
+ | New public APIs | Plan tasks create new route files, API endpoints, or exported interfaces | "New public surface area detected — consider `/gsdd-plan` for approach exploration." |
181
+
182
+ If any signal fires, set `$SCOPE_WARNING` to the first matching advisory text. Multiple signals concatenate.
183
+ If no signals fire, `$SCOPE_WARNING` is empty.
184
+
185
+ This is advisory only — it does NOT block execution.
186
+
187
+ ---
188
+
189
+ ## Step 3.7: Plan preview
190
+
191
+ Present the plan summary to the user before execution begins.
192
+
193
+ Read the plan file and extract:
194
+ - Task count and task names
195
+ - List of files to be modified/created (from plan task `<files>` sections)
196
+ - A 1-sentence approach summary (first sentence of the plan's objective or goal)
197
+
198
+ Display:
199
+
200
+ ```
201
+ Quick Task Plan Preview:
202
+ - Tasks: {count} ({task_names})
203
+ - Files: {file_list}
204
+ - Approach: {1-sentence summary}
205
+ ```
206
+
207
+ If `$SCOPE_WARNING` is non-empty, append:
208
+ ```
209
+ Scope signal: {$SCOPE_WARNING}
210
+ ```
211
+
212
+ If `$CHECKER_ISSUES` is non-empty, append:
213
+ ```
214
+ Plan check issues: {$CHECKER_ISSUES}
215
+ ```
216
+
217
+ Present options (default-yes — pressing Enter proceeds):
218
+ - If `$SCOPE_WARNING` is empty: `[Enter to proceed / edit description / abort]`
219
+ - If `$SCOPE_WARNING` is non-empty: `[Enter to proceed / switch to /gsdd-plan / edit description / abort]`
220
+
221
+ Handle response:
222
+ - **Enter (or "yes"):** proceed to Step 4.
223
+ - **"edit description":** clean up the task directory, then return to Step 1 with `$DESCRIPTION` pre-filled as the starting point.
224
+ - **"switch to /gsdd-plan":** clean up the task directory, then stop quick workflow and report: "Use `/gsdd-plan` for full ceremony with approach exploration. Task description: {$DESCRIPTION}"
225
+ - **"abort":** clean up the task directory, report cancellation, stop.
71
226
 
72
227
  ---
73
228
 
74
229
  ## Step 4: Execute
75
230
 
231
+ **Only reached after the user has seen the plan preview in Step 3.7.**
232
+
76
233
  Delegate to the executor role.
77
234
 
78
235
  <delegate>
@@ -96,8 +253,8 @@ Delegate to the executor role.
96
253
  </delegate>
97
254
 
98
255
  After the executor returns:
99
- 1. Verify the summary file exists.
100
- 2. If not found, report the error and stop.
256
+
257
+ **STOP. Verify the SUMMARY file exists at `.planning/quick/$NEXT_NUM-$SLUG/$NEXT_NUM-SUMMARY.md` on disk. If it does not exist, report the write failure. Do NOT proceed to verification or LOG.md update without a persisted summary.**
101
258
 
102
259
  ---
103
260
 
@@ -125,6 +282,8 @@ Read `.planning/config.json`.
125
282
  **Return:** Verification status (passed | gaps_found | human_needed).
126
283
  </delegate>
127
284
 
285
+ **STOP. Verify the VERIFICATION file exists at `.planning/quick/$NEXT_NUM-$SLUG/$NEXT_NUM-VERIFICATION.md` on disk (when verifier ran). If it does not exist, report the write failure. Do NOT proceed to LOG.md update without a persisted verification report.**
286
+
128
287
  ---
129
288
 
130
289
  ## Step 6: Update LOG.md
@@ -154,9 +313,13 @@ Report to the user:
154
313
 
155
314
  <success_criteria>
156
315
  - [ ] User provided a task description
316
+ - [ ] Approach clarification ran (only if workflow.discuss is true AND ambiguity detected)
157
317
  - [ ] `.planning/quick/` directory exists (created if needed)
158
318
  - [ ] Task directory created at `.planning/quick/NNN-slug/`
159
319
  - [ ] `NNN-PLAN.md` created by planner (1-3 tasks)
320
+ - [ ] Independent plan check ran (only if workflow.planCheck is true)
321
+ - [ ] Plan preview presented to user before execution
322
+ - [ ] User confirmed (or pressed Enter) before execution proceeded
160
323
  - [ ] `NNN-SUMMARY.md` created by executor
161
324
  - [ ] `NNN-VERIFICATION.md` created by verifier (only if workflow.verifier is true)
162
325
  - [ ] `LOG.md` updated with task row
@@ -175,12 +338,12 @@ Created:
175
338
  - `.planning/quick/{next_num}-{slug}/{next_num}-VERIFICATION.md` (if verifier enabled)
176
339
  - Updated `.planning/quick/LOG.md`
177
340
 
178
- **Next step:** `/gsdd:progress` — check project status and continue phase work
341
+ **Next step:** `/gsdd-progress` — check project status and continue phase work
179
342
 
180
343
  Also available:
181
- - `/gsdd:quick` — run another quick task
182
- - `/gsdd:plan` — plan the next phase
183
- - `/gsdd:pause` — save context for later if stopping work
344
+ - `/gsdd-quick` — run another quick task
345
+ - `/gsdd-plan` — plan the next phase
346
+ - `/gsdd-pause` — save context for later if stopping work
184
347
 
185
348
  Consider clearing context before starting the next workflow for best results.
186
349
  ---
@@ -10,13 +10,19 @@ Scope boundary: unlike progress.md, you have side effects — checkpoint cleanup
10
10
  `.planning/` should exist. If it does not, route the user to `gsdd init`.
11
11
  </prerequisites>
12
12
 
13
+ <runtime_contract>
14
+ Use the `Runtime` type from `.planning/SPEC.md`.
15
+ Infer runtime from the launching surface when obvious: `.claude/` -> `claude-code`, `.codex/` or Codex portable skill -> `codex-cli`, `.opencode/` -> `opencode`, otherwise `other`.
16
+ When a checkpoint's `runtime` differs from the inferred current runtime, surface it as an informational note in `<present_status>` — it is context, not a gate.
17
+ </runtime_contract>
18
+
13
19
  <process>
14
20
 
15
21
  <detect_state>
16
22
  Check for project artifacts in order:
17
23
 
18
24
  1. **No `.planning/` directory** — route user to run `gsdd init`. Stop.
19
- 2. **No `.planning/SPEC.md` or no `.planning/ROADMAP.md`** — `.planning/` exists but the project is not fully initialized (partial init). Route user to run the `/gsdd:new-project` workflow. Stop.
25
+ 2. **No `.planning/SPEC.md` or no `.planning/ROADMAP.md`** — `.planning/` exists but the project is not fully initialized (partial init). Route user to run the `/gsdd-new-project` workflow. Stop.
20
26
  3. **Both exist** — proceed to load state.
21
27
  </detect_state>
22
28
 
@@ -44,7 +50,9 @@ Read `.planning/SPEC.md`. Extract:
44
50
  Check if `.planning/.continue-here.md` exists. If yes, read it and extract:
45
51
  - `workflow` frontmatter (phase/quick/generic)
46
52
  - `phase` frontmatter
53
+ - `runtime` frontmatter (the runtime that wrote the checkpoint; use `unknown` if field absent)
47
54
  - All 6 sections: current_state, completed_work, remaining_work, decisions, blockers, next_action
55
+ - `<judgment>` if present, including `<active_constraints>`, `<unresolved_uncertainty>`, `<decision_posture>`, and `<anti_regression>`
48
56
 
49
57
  **Phase directories:**
50
58
  Scan `.planning/phases/` for:
@@ -53,8 +61,67 @@ Scan `.planning/phases/` for:
53
61
 
54
62
  **Quick task log:**
55
63
  If `.planning/quick/LOG.md` exists, read the last entry. Check if it has a non-terminal status (not `done`/`passed`).
64
+
65
+ **Git/worktree truth:**
66
+ Collect the live integration-surface facts separately from checkpoint narrative truth:
67
+ - current branch name
68
+ - branch divergence from `main` (and tracked remote when available)
69
+ - staged pending truth
70
+ - unstaged local edits
71
+ - untracked local files
72
+ - PR presence/state when available
73
+ - whether the current branch appears stale/spent or the dirty tree appears mixed-scope
56
74
  </load_artifacts>
57
75
 
76
+ <provenance_reconciliation>
77
+ Before routing, reconstruct and compare these truth buckets explicitly:
78
+
79
+ 1. **Checkpoint narrative truth** — what `.planning/.continue-here.md` claims was happening
80
+ 2. **Planning/artifact truth** — what ROADMAP, SPEC, phase files, and quick-task logs say
81
+ 3. **Git/worktree truth** — what the live branch and working tree say now
82
+
83
+ Treat them as separate inputs. Do not flatten them into one continuity story.
84
+
85
+ Material mismatch signals include:
86
+ - checkpoint narrative describes only a narrow slice of a broader dirty tree
87
+ - current branch is stale/spent relative to the next intended integration surface
88
+ - dirty files suggest overlapping write sets or mixed phase scope
89
+
90
+ If git/worktree truth materially disagrees with checkpoint narrative truth:
91
+ - record a mismatch flag
92
+ - keep ordinary git risk warning-level by default
93
+ - require explicit user acknowledgement before routing onward
94
+ - do not allow a quick "continue" shortcut to skip that acknowledgement
95
+ </provenance_reconciliation>
96
+
97
+ <validate_checkpoint>
98
+ Only run this step when `.planning/.continue-here.md` was found in `<load_artifacts>`. If no checkpoint exists, skip this step entirely.
99
+
100
+ Cross-validate checkpoint fields against current roadmap state in this order:
101
+
102
+ 1. Extract the checkpoint `workflow` and `phase` frontmatter fields.
103
+ 2. If `phase` is non-null, look up that exact phase name in `.planning/ROADMAP.md`.
104
+ - If the matching roadmap entry is `[x]`, mark the checkpoint as stale.
105
+ - Record the specific reason in this form: `checkpoint references phase "[phase]" which is already complete [x] in ROADMAP.md`.
106
+ - Stop further staleness checks after recording this reason.
107
+ 3. If `workflow` is `phase` and `phase` is null, mark the checkpoint as potentially stale.
108
+ - Record the reason in this form: `checkpoint workflow is "phase" but checkpoint phase is missing`.
109
+ 4. If `workflow` is `phase` and `phase` is non-null but no matching roadmap entry exists, mark the checkpoint as potentially stale.
110
+ - Record the reason in this form: `checkpoint workflow is "phase" but phase "[phase]" was not found in ROADMAP.md`.
111
+ 5. If `workflow` is `phase` and `phase` matches a roadmap entry with status `[ ]` or `[-]`, do not mark it stale based only on missing execution artifacts. Continue normally.
112
+ 6. If no structural staleness rule applied, skip validation cleanly. This includes `generic` or `quick` checkpoints with null `phase`.
113
+
114
+ When staleness is detected:
115
+ - Record a staleness flag and keep the full reason text.
116
+ - Record only one staleness reason string. Do not append additional reasons after the first matching rule.
117
+ - Do NOT delete the checkpoint.
118
+ - Do NOT suppress the checkpoint contents.
119
+
120
+ The output of this step is either:
121
+ - no staleness flag, or
122
+ - a staleness flag with a specific reason string that flows into `<present_status>` and `<determine_action>`.
123
+ </validate_checkpoint>
124
+
58
125
  <present_status>
59
126
  Present a compact status to the user:
60
127
 
@@ -64,10 +131,43 @@ Phase: [current] of [total] — [phase name]
64
131
  Completed: [N] phases done
65
132
 
66
133
  [If .continue-here.md exists:]
134
+ [If stale checkpoint flag set:]
135
+ ⚠ Stale checkpoint detected
136
+ Reason: [specific staleness reason]
137
+ Review the checkpoint contents below and decide whether to resume from it or continue without it.
138
+
67
139
  Checkpoint found: [workflow type] — [phase name or task description]
68
140
  Last paused: [timestamp from frontmatter]
141
+ Paused by: [runtime from checkpoint, or unknown if field absent]
142
+ Resuming in: [inferred current runtime]
69
143
  Next action: [next_action section content]
70
144
 
145
+ [If <judgment> was present in checkpoint:]
146
+ Judgment context:
147
+ Constraints:
148
+ [Full content of <active_constraints>]
149
+ Uncertainty:
150
+ [Full content of <unresolved_uncertainty>]
151
+ Posture:
152
+ [Full content of <decision_posture>]
153
+ Anti-regression:
154
+ [Full content of <anti_regression>]
155
+
156
+ [If git/worktree truth was collected:]
157
+ Git/worktree truth:
158
+ Branch: [current branch]
159
+ Divergence: [ahead/behind or unknown]
160
+ Staged: [count]
161
+ Unstaged: [count]
162
+ Untracked: [count]
163
+ PR: [open|closed|merged|none|unknown]
164
+ Integration surface: [clean | warning | stale/spent | mixed-scope]
165
+
166
+ [If material checkpoint/worktree mismatch flag set:]
167
+ ⚠ Checkpoint/worktree mismatch
168
+ The checkpoint narrative no longer matches the live branch/worktree scope.
169
+ Review both truth surfaces before choosing the next action.
170
+
71
171
  [If incomplete phase execution found:]
72
172
  Incomplete execution: Phase [N] has a PLAN but no SUMMARY
73
173
 
@@ -76,6 +176,8 @@ Incomplete quick task: [description from LOG.md]
76
176
  ```
77
177
 
78
178
  No ASCII art, no progress bars. Keep it scannable.
179
+
180
+ Only show the staleness banner when `<validate_checkpoint>` produced a staleness flag. Even when flagged, still show the checkpoint details immediately below the banner.
79
181
  </present_status>
80
182
 
81
183
  <determine_action>
@@ -83,21 +185,25 @@ Evaluate in priority order and present the primary recommendation:
83
185
 
84
186
  **Checkpoint exists (`.continue-here.md`):**
85
187
  Route based on the `workflow` frontmatter:
86
- - `phase` — route to `/gsdd:execute` (or `/gsdd:plan`/`/gsdd:verify` based on checkpoint context)
87
- - `quick` — route to `/gsdd:quick` to complete the task
188
+ - `phase` — route to `/gsdd-execute` (or `/gsdd-plan`/`/gsdd-verify` based on checkpoint context)
189
+ - `quick` — route to `/gsdd-quick` to complete the task
88
190
  - `generic` — present the next_action and let the user decide
89
191
 
192
+ If `<validate_checkpoint>` marked the checkpoint as stale, keep the same routing logic. The user may still choose to resume from the checkpoint after reviewing the warning. If the user chooses a different path, leave the checkpoint in place and continue without it.
193
+
194
+ If `<provenance_reconciliation>` marked a material checkpoint/worktree mismatch, keep the same routing logic but require explicit acknowledgement before continuing. The workflow should not silently route onward from a materially misleading checkpoint narrative.
195
+
90
196
  **Incomplete plan execution (PLAN without SUMMARY):**
91
- Route to `/gsdd:execute` for that phase.
197
+ Route to `/gsdd-execute` for that phase.
92
198
 
93
199
  **Phase needs planning (next `[ ]` phase, no PLAN file exists):**
94
- Route to `/gsdd:plan` for that phase.
200
+ Route to `/gsdd-plan` for that phase.
95
201
 
96
202
  **Phase needs verification (SUMMARY exists but no VERIFICATION):**
97
- Route to `/gsdd:verify` for that phase (only if `workflow.verifier` is enabled in config.json; if config.json cannot be read, assume verifier is disabled).
203
+ Route to `/gsdd-verify` for that phase (only if `workflow.verifier` is enabled in config.json; if config.json cannot be read, assume verifier is disabled).
98
204
 
99
205
  **All phases complete (all `[x]`):**
100
- Route to `/gsdd:audit-milestone`.
206
+ Route to `/gsdd-audit-milestone`.
101
207
  </determine_action>
102
208
 
103
209
  <present_options>
@@ -112,17 +218,21 @@ What would you like to do?
112
218
  4. Something else
113
219
  ```
114
220
 
115
- **Quick-resume shortcut:** If the user says "continue", "go", or "resume" without further input, skip the options and execute the primary action directly.
221
+ **Quick-resume shortcut:** If there is no stale-checkpoint banner and no material checkpoint/worktree mismatch, the user may say "continue", "go", or "resume" without further input to execute the primary action directly.
222
+
223
+ **Mismatch acknowledgement:** If material checkpoint/worktree mismatch was detected, require an explicit acknowledgement such as "continue despite mismatch" or a different selected path. Do not let a bare "continue" skip the warning.
116
224
 
117
225
  Wait for user selection.
118
226
  </present_options>
119
227
 
120
228
  <cleanup_checkpoint>
121
229
  Immediately after the user confirms their action selection (before routing to the target workflow):
122
- - If the user chose to resume from `.continue-here.md`, delete it now — before dispatching to the target workflow.
230
+ - If the user chose to resume from `.continue-here.md`:
231
+ 1. Run `gsdd file-op copy .planning/.continue-here.md .planning/.continue-here.bak`.
232
+ 2. After the copy succeeds, run `gsdd file-op delete .planning/.continue-here.md`.
123
233
  - If the user chose a different action (not based on the checkpoint), leave `.continue-here.md` in place for a future resume.
124
234
 
125
- Deleting before routing ensures a failed or interrupted workflow does not leave a stale checkpoint that would mislead the next resume invocation.
235
+ Copying before deleting ensures the checkpoint survives a session crash between deletion and dispatch. `.continue-here.bak` is cleaned up by the downstream workflow after absorbing the judgment, or by the next `pause.md` run.
126
236
  </cleanup_checkpoint>
127
237
 
128
238
  </process>
@@ -148,5 +258,5 @@ Present to the user before dispatching:
148
258
  Consider clearing context before starting the next workflow for best results.
149
259
  ---
150
260
 
151
- Then dispatch to the selected `/gsdd:*` workflow.
261
+ Then dispatch to the selected `/gsdd-*` workflow.
152
262
  </completion>