gsdd-cli 0.3.1 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +131 -67
  2. package/agents/DISTILLATION.md +15 -13
  3. package/agents/README.md +1 -1
  4. package/agents/planner.md +2 -0
  5. package/bin/adapters/agents.mjs +1 -0
  6. package/bin/adapters/claude.mjs +20 -4
  7. package/bin/adapters/codex.mjs +9 -1
  8. package/bin/adapters/opencode.mjs +20 -5
  9. package/bin/gsdd.mjs +24 -7
  10. package/bin/lib/cli-utils.mjs +1 -1
  11. package/bin/lib/evidence-contract.mjs +112 -0
  12. package/bin/lib/file-ops.mjs +161 -0
  13. package/bin/lib/health-truth.mjs +186 -0
  14. package/bin/lib/health.mjs +72 -67
  15. package/bin/lib/init-flow.mjs +50 -3
  16. package/bin/lib/init-prompts.mjs +22 -83
  17. package/bin/lib/init-runtime.mjs +47 -25
  18. package/bin/lib/init.mjs +3 -3
  19. package/bin/lib/lifecycle-preflight.mjs +333 -0
  20. package/bin/lib/lifecycle-state.mjs +293 -0
  21. package/bin/lib/models.mjs +19 -4
  22. package/bin/lib/phase.mjs +159 -18
  23. package/bin/lib/plan-constants.mjs +30 -0
  24. package/bin/lib/provenance.mjs +165 -0
  25. package/bin/lib/rendering.mjs +8 -0
  26. package/bin/lib/runtime-freshness.mjs +239 -0
  27. package/bin/lib/session-fingerprint.mjs +106 -0
  28. package/bin/lib/templates.mjs +17 -0
  29. package/distilled/DESIGN.md +733 -49
  30. package/distilled/EVIDENCE-INDEX.md +402 -0
  31. package/distilled/README.md +73 -33
  32. package/distilled/SKILL.md +89 -85
  33. package/distilled/templates/agents.block.md +13 -84
  34. package/distilled/templates/agents.md +0 -7
  35. package/distilled/templates/delegates/plan-checker.md +6 -3
  36. package/distilled/workflows/audit-milestone.md +56 -6
  37. package/distilled/workflows/complete-milestone.md +333 -0
  38. package/distilled/workflows/execute.md +201 -19
  39. package/distilled/workflows/map-codebase.md +17 -4
  40. package/distilled/workflows/new-milestone.md +262 -0
  41. package/distilled/workflows/new-project.md +7 -6
  42. package/distilled/workflows/pause.md +40 -6
  43. package/distilled/workflows/plan-milestone-gaps.md +183 -0
  44. package/distilled/workflows/plan.md +77 -11
  45. package/distilled/workflows/progress.md +107 -29
  46. package/distilled/workflows/quick.md +23 -12
  47. package/distilled/workflows/resume.md +135 -12
  48. package/distilled/workflows/verify-work.md +260 -0
  49. package/distilled/workflows/verify.md +159 -33
  50. package/docs/BROWNFIELD-PROOF.md +95 -0
  51. package/docs/RUNTIME-SUPPORT.md +77 -0
  52. package/docs/USER-GUIDE.md +439 -0
  53. package/docs/VERIFICATION-DISCIPLINE.md +59 -0
  54. package/docs/claude/context-monitor.md +98 -0
  55. package/docs/proof/consumer-node-cli/README.md +37 -0
  56. package/docs/proof/consumer-node-cli/ROADMAP.md +14 -0
  57. package/docs/proof/consumer-node-cli/SPEC.md +17 -0
  58. package/docs/proof/consumer-node-cli/brief.md +9 -0
  59. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-PLAN.md +34 -0
  60. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-SUMMARY.md +10 -0
  61. package/docs/proof/consumer-node-cli/phases/01-foundation/01-VERIFICATION.md +30 -0
  62. package/package.json +38 -29
@@ -1,5 +1,5 @@
1
1
  <role>
2
- You are a Codebase Mapper Orchestrator. You analyze an existing codebase using 4 specialized mapper delegates, each focused on one dimension. The delegates write their documents directly -- you only coordinate, validate, and summarize.
2
+ You are a Codebase Mapper Orchestrator. You analyze an existing codebase using 4 specialized mapper delegates, each focused on one dimension. The delegates write their documents directly -- you only coordinate, validate, and synthesize a bounded brownfield routing summary from their results.
3
3
 
4
4
  Output: `.planning/codebase/` with 4 structured documents about the codebase state.
5
5
  </role>
@@ -9,11 +9,13 @@ Use this workflow when:
9
9
  - Starting work on a brownfield (existing) codebase for the first time
10
10
  - Codebase maps are missing or stale (major refactors, dependency upgrades, new modules)
11
11
  - Explicitly requested as a standalone re-mapping
12
+ - You want a deeper brownfield orientation pass before choosing between bounded `quick` work and full `new-project` setup
12
13
 
13
14
  Do NOT use when:
14
15
  - Greenfield project with no existing code
15
16
  - Maps already exist and are fresh (use Skip)
16
17
  - You are in the middle of a plan/execute/verify cycle (use existing maps)
18
+ - You only need a small bounded brownfield change and the repo is already familiar enough for `quick` to build an inline baseline safely
17
19
  </when_to_use>
18
20
 
19
21
  <load_context>
@@ -142,10 +144,11 @@ These 4 documents are consumed by downstream GSDD workflows:
142
144
 
143
145
  | Workflow | Documents Used |
144
146
  |----------|---------------|
145
- | `/gsdd:new-project` | All 4 -- infers Validated requirements from existing capabilities |
147
+ | `/gsdd-new-project` | All 4 -- infers Validated requirements from existing capabilities |
146
148
  | `plan` (future) | ARCHITECTURE + CONVENTIONS for implementation planning |
147
149
  | `execute` (future) | CONVENTIONS for code style, ARCHITECTURE for file placement |
148
150
  | `verify` (future) | CONCERNS for regression awareness |
151
+ | `/gsdd-quick` | All 4 -- bounded brownfield context for safe feature work |
149
152
 
150
153
  **What this means for mapper output quality:**
151
154
 
@@ -230,10 +233,20 @@ Report to the user what was accomplished, then present the next step:
230
233
  ---
231
234
  **Completed:** Codebase mapping — 4 documents written to `.planning/codebase/` (STACK.md, ARCHITECTURE.md, CONVENTIONS.md, CONCERNS.md).
232
235
 
233
- **Next step:** `/gsdd:new-project` initialize the project with spec and roadmap
236
+ **Brownfield routing summary:** Synthesize this directly from the 4 generated documents before recommending the next workflow.
237
+ - Safest next change lane — which module or surface looks cheapest and safest to modify first
238
+ - Highest-risk zones — areas to avoid or isolate unless the task explicitly needs them
239
+ - Must-know traps — convention, dependency, or architecture constraints likely to cause mistakes
240
+ - Recommended next workflow — choose `/gsdd-quick` for bounded brownfield work or `/gsdd-new-project` for full lifecycle setup, and say why
241
+
242
+ Use only the 4 generated documents for this synthesis. Do NOT create a fifth persistent artifact or write an additional routing-summary file.
243
+
244
+ **Next step:** Choose based on what you need:
245
+ - `/gsdd-new-project` — full project initialization (spec, roadmap, phased delivery), especially if you have not yet defined the bounded change
246
+ - `/gsdd-quick` — bounded brownfield feature work without full ceremony (bug fixes, small features, one-off tasks)
234
247
 
235
248
  Also available:
236
- - `/gsdd:map-codebase` — re-map if results need refinement
249
+ - `/gsdd-map-codebase` — re-map if results need refinement
237
250
  - Review specific file: read `.planning/codebase/STACK.md`
238
251
 
239
252
  Consider clearing context before starting the next workflow for best results.
@@ -0,0 +1,262 @@
1
+ <role>
2
+ You are the MILESTONE INITIATOR. Your job is to start a new milestone cycle for an existing project — gather what to build next, define scoped requirements in SPEC.md, and create roadmap phases in ROADMAP.md so the phase lifecycle can begin.
3
+
4
+ Core mindset: this is a brownfield continuation, not a fresh start. You build on what shipped. Do not re-research capabilities that already exist in the Validated section of SPEC.md.
5
+
6
+ Scope boundary: you produce updated SPEC.md requirements and a new set of phases in ROADMAP.md. You do not plan phases — that is `/gsdd-plan` territory.
7
+ </role>
8
+
9
+ <prerequisites>
10
+ `.planning/SPEC.md` must exist (project has been initialized and at least one milestone shipped).
11
+ `.planning/MILESTONES.md` must exist (at least one milestone was completed and archived).
12
+
13
+ If SPEC.md is missing, the project has not been initialized — run `/gsdd-new-project` instead.
14
+ If MILESTONES.md is missing, no milestone has been completed — complete the current milestone first with `/gsdd-complete-milestone`.
15
+ </prerequisites>
16
+
17
+ <load_context>
18
+ Before starting, read these files:
19
+
20
+ 1. `.planning/SPEC.md` — project identity, core value, validated requirements, constraints, decisions
21
+ 2. `.planning/MILESTONES.md` — what shipped previously, last milestone version and date
22
+ 3. `.planning/ROADMAP.md` — collapsed milestone phases, current phase numbering (to determine where to continue)
23
+ 4. `.planning/config.json` — `workflow.research`, `researchDepth`, `gitProtocol`
24
+ </load_context>
25
+
26
+ <lifecycle_preflight>
27
+ Before presenting the last milestone or gathering new milestone goals, run:
28
+
29
+ - `gsdd lifecycle-preflight new-milestone`
30
+
31
+ If the preflight result is `blocked`, STOP and report the blocker instead of inferring milestone-start eligibility from workflow-local prose.
32
+
33
+ Treat the preflight as an authorization seam over shared repo truth only:
34
+ - it may authorize or reject new milestone creation
35
+ - it does not mutate milestone or roadmap state by itself
36
+ - owned writes remain the new milestone requirements, roadmap entries, and phase-directory scaffolding
37
+ </lifecycle_preflight>
38
+
39
+ <integration_surface_check>
40
+ Before mutating milestone truth, inspect the current branch/worktree as a separate provenance surface:
41
+ - current branch
42
+ - divergence from `main`
43
+ - staged / unstaged / untracked local truth
44
+ - whether the branch appears stale/spent or mixed-scope
45
+
46
+ If milestone truth on disk is local-only or AI-generated draft truth, or if the checked-out branch is clearly not the intended integration surface, say so explicitly before continuing. Do not flatten local draft planning truth into committed repo truth.
47
+ </integration_surface_check>
48
+
49
+ <process>
50
+
51
+ ## 1. Present What Shipped Last
52
+
53
+ Read `.planning/MILESTONES.md`. Find the most recent milestone entry. Present it to the user:
54
+
55
+ ```
56
+ Last milestone: v[X.Y] — [Name] (shipped [date])
57
+
58
+ Delivered:
59
+ - [Accomplishment 1]
60
+ - [Accomplishment 2]
61
+ - [Accomplishment 3]
62
+ ```
63
+
64
+ ## 2. Gather What to Build Next
65
+
66
+ Ask the user what the next milestone should focus on. Explore:
67
+ - What problem does this milestone solve?
68
+ - Who benefits?
69
+ - What is explicitly out of scope for this milestone?
70
+ - Any constraints (deadline, team size, dependencies)?
71
+
72
+ If a `.planning/MILESTONE-BRIEF.md` exists, use it as the input instead of asking. Note any assumptions inferred from the brief.
73
+ (MILESTONE-BRIEF.md is an optional pre-written document with goals and scope for the next milestone — useful when the user wants to skip the interactive questioning. Create it manually in `.planning/` before running this workflow.)
74
+
75
+ ## 3. Determine Version
76
+
77
+ Parse the last version from MILESTONES.md (e.g., `v0.5.0`). Suggest the next version:
78
+ - Minor increment for additive work (v0.5.0 → v0.6.0)
79
+ - Major increment for breaking changes or new direction (v0.x.y → v1.0.0)
80
+
81
+ Confirm version with the user.
82
+
83
+ ## 4. Research Decision
84
+
85
+ Check `config.json -> workflow.research`. If `true`, ask the user:
86
+
87
+ > "Research the domain ecosystem for new features before defining requirements?"
88
+ >
89
+ > - "Yes — research first" (recommended for new capability areas)
90
+ > - "No — skip research"
91
+
92
+ If `workflow.research` is `false` in config, skip to Step 5.
93
+
94
+ **If research is selected:**
95
+
96
+ Check `researchDepth` in config (`fast` | `balanced` | `deep`).
97
+
98
+ Use `<delegate>` blocks to spawn researchers. Pass milestone context to each:
99
+ - What existing capabilities are already validated (from SPEC.md Validated section) — do NOT re-research these
100
+ - What NEW capabilities this milestone is adding
101
+ - Focus on: what's needed for the NEW features only
102
+
103
+ ```
104
+ <delegate>
105
+ **Identity:** Researcher — Stack
106
+ **Instruction:** Read `.planning/templates/roles/researcher.md`, then research what stack additions are needed for the new milestone capabilities.
107
+
108
+ **Milestone context:** [existing validated capabilities, new capabilities being added]
109
+ **Question:** What library/framework additions are needed? What should NOT be added?
110
+ **Output:** Write findings to `.planning/research/STACK.md`
111
+ **Return:** 2-3 sentence summary of key findings
112
+ </delegate>
113
+ ```
114
+
115
+ Spawn 2-4 researchers in parallel based on researchDepth:
116
+ - `fast`: 1 researcher (features/pitfalls combined)
117
+ - `balanced`: 2 researchers (features, pitfalls)
118
+ - `deep`: 4 researchers (stack, features, architecture, pitfalls)
119
+
120
+ After researchers complete, synthesize findings inline (no synthesizer delegate needed unless `deep` mode — then spawn the synthesizer delegate).
121
+
122
+ Present key findings before moving to requirements.
123
+
124
+ ## 5. Define Requirements
125
+
126
+ Read SPEC.md Must Have section. Identify the requirement ID pattern in use (e.g., `[FLOW-01]`, `[PLAN-01]`).
127
+
128
+ Based on milestone goals and research findings (if any), define the new Must Have requirements for this milestone:
129
+
130
+ - Each requirement must be user-centric: "User can X"
131
+ - Each must have a `[Done-When:]` completion criterion
132
+ - IDs follow the existing category pattern or introduce a new category for new capability areas
133
+ - Do NOT duplicate or restate requirements already in the Validated section
134
+
135
+ Present the full proposed requirements list:
136
+
137
+ ```
138
+ ## Proposed Requirements for v[X.Y]
139
+
140
+ - [ ] **[CAT-01]**: User can X. [Done-When: ...]
141
+ - [ ] **[CAT-02]**: User can Y. [Done-When: ...]
142
+ ```
143
+
144
+ **STOP. Wait for user confirmation before writing to SPEC.md.**
145
+
146
+ If the user requests changes, revise and re-present.
147
+
148
+ Once confirmed, add the requirements to SPEC.md's Must Have section.
149
+
150
+ ## 6. Create Roadmap Phases
151
+
152
+ Determine the starting phase number:
153
+ - Check ROADMAP.md for the highest existing phase number (in collapsed `<details>` blocks or active entries)
154
+ - Check MILESTONES.md for the last phase range (e.g., "Phases 1–5")
155
+ - New phases start from max + 1
156
+
157
+ Design 2-5 phases that cover all new requirements:
158
+ - Each phase has a goal (one sentence), requirement assignments, and 2-4 success criteria
159
+ - All requirements must be assigned to exactly one phase
160
+ - Verify 100% coverage before writing
161
+
162
+ Present the proposed roadmap:
163
+
164
+ ```
165
+ ## Proposed Phases for v[X.Y]
166
+
167
+ **Phase [N]: [Name]**
168
+ Goal: [one sentence]
169
+ Requirements: [REQ-IDs]
170
+ Success criteria:
171
+ 1. [observable outcome]
172
+ 2. [observable outcome]
173
+
174
+ **Phase [N+1]: [Name]**
175
+ ...
176
+ ```
177
+
178
+ **STOP. Wait for user confirmation before writing to ROADMAP.md.**
179
+
180
+ If the user requests adjustments, revise and re-present.
181
+
182
+ Once confirmed, add the phases to ROADMAP.md below the collapsed milestone `<details>` block(s):
183
+
184
+ ```markdown
185
+ ### [Milestone Name]
186
+
187
+ - [ ] **Phase [N]: [Name]** — [goal]
188
+ - [ ] **Phase [N+1]: [Name]** — [goal]
189
+ ```
190
+
191
+ Also update the Milestones list at the top of ROADMAP.md:
192
+
193
+ ```markdown
194
+ - 🚧 **v[X.Y] [Name]** — Phases [N]–[M] (in progress)
195
+ ```
196
+
197
+ ## 7. Create Phase Directories
198
+
199
+ Create placeholder directories for each new phase:
200
+
201
+ ```
202
+ .planning/phases/[NN]-[phase-name-kebab]/
203
+ ```
204
+
205
+ No files inside — the `/gsdd-plan` workflow populates them.
206
+
207
+ ## 8. Update SPEC.md Current State
208
+
209
+ Update the `## Current State` section in SPEC.md:
210
+
211
+ ```markdown
212
+ ## Current State
213
+
214
+ - **Milestone:** v[X.Y] [Name] — IN PROGRESS
215
+ - **Phases:** [N]–[M] (0 of [total] complete)
216
+ - **Blockers:** None
217
+ - **Next:** `/gsdd-plan [N]` to begin Phase [N]
218
+
219
+ ---
220
+ *Last updated: [today] — v[X.Y] milestone started*
221
+ ```
222
+
223
+ </process>
224
+
225
+ <success_criteria>
226
+ - [ ] MILESTONES.md read and last milestone presented
227
+ - [ ] Milestone goals gathered from user (or MILESTONE-BRIEF.md consumed)
228
+ - [ ] Version confirmed
229
+ - [ ] Research completed if requested (or skipped per config/user)
230
+ - [ ] Requirements defined, user-centric, with Done-When criteria
231
+ - [ ] User confirmed requirements before SPEC.md was updated
232
+ - [ ] All new requirements added to SPEC.md Must Have section
233
+ - [ ] Phase numbering continues from previous milestone
234
+ - [ ] All requirements assigned to phases (100% coverage)
235
+ - [ ] User confirmed roadmap before ROADMAP.md was updated
236
+ - [ ] ROADMAP.md updated with new phases and milestone header
237
+ - [ ] SPEC.md Current State updated
238
+ - [ ] Phase directories created
239
+ </success_criteria>
240
+
241
+ **MANDATORY: `.planning/SPEC.md` and `.planning/ROADMAP.md` must be updated on disk before this workflow is complete. If either write fails, STOP and report the failure. These are the handoff artifacts — without them, the next session cannot proceed.**
242
+
243
+ <completion>
244
+ Report to the user what was created, then present the next step:
245
+
246
+ ---
247
+ **Completed:** Milestone v[X.Y] initialized.
248
+
249
+ Created:
250
+ - [N] new requirements in `SPEC.md` Must Have section
251
+ - [M] new phases in `ROADMAP.md` (Phases [start]–[end])
252
+ - Phase directories in `.planning/phases/`
253
+
254
+ **Next step:** `/gsdd-plan [N]` — plan Phase [N]: [phase name]
255
+
256
+ Also available:
257
+ - `/gsdd-progress` — check overall project status
258
+ - `/gsdd-map-codebase` — refresh codebase maps before planning (recommended for large codebases)
259
+
260
+ Consider clearing context before starting the next workflow for best results.
261
+ ---
262
+ </completion>
@@ -83,6 +83,8 @@ Check whether `.planning/codebase/STACK.md`, `.planning/codebase/ARCHITECTURE.md
83
83
 
84
84
  Inform the user: "No codebase maps found. Running codebase mapping before continuing."
85
85
 
86
+ This is an internal prerequisite of `new-project`, not a user-facing routing requirement. If the user started with `/gsdd-new-project` on a brownfield repo, do not bounce them out and tell them to restart with `/gsdd-map-codebase`. Run the mapping dependency, then continue this workflow.
87
+
86
88
  Read and follow `.agents/skills/gsdd-map-codebase/SKILL.md` now. Execute its full flow (check existing, spawn mappers, validate, secrets scan). When map-codebase completes, return here and continue from Brownfield Validated Requirements Inference below.
87
89
 
88
90
  ### Brownfield Validated Requirements Inference
@@ -296,7 +298,7 @@ After the subagent research completes, synthesize EVERYTHING into `SPEC.md`:
296
298
  6. **Key Decisions are logged** — any choices made during questioning or dictated by the SOTA research.
297
299
  7. **Typed Data Schemas** *(SOTA: GitHub Blog — "Multi-agent workflows often fail")*: explicitly define the core Data Models/Typed Schemas the project will use (e.g., `type UserProfile = { id: number; plan: 'free' | 'pro' }`). Multi-agent systems require typed schemas to pass reliable state; natural language instructions fail across agent handoffs. *SPEC.md defines WHAT, not HOW — do not include implementation tasks.*
298
300
  8. **Done-When Verification Chain** *(SOTA: Cyanluna)*: For EVERY requirement in the "Must Have (v1)" section, define a clear, verifiable `[Done-When: ...]` criterion. "User can log in" must become "User can log in [Done-When: Login form submits, JWT is received, and User is redirected to Dashboard]". No exceptions.
299
- 9. **Capability & Security Gates**: Handle per the `<capability_gates>` section below.
301
+ 9. **Capability & Security Gates**: Handle per the `<capability_gates>` section at the end of this `<spec_creation>` block.
300
302
  10. **Authorization Matrix (optional)**: For projects with multiple user roles or protected resources, create `.planning/AUTH_MATRIX.md` using the template at `.planning/templates/auth-matrix.md`. The integration checker will use this matrix for systematic auth verification during milestone audits.
301
303
  11. **Current State is set** to Phase 1, Status: Not started.
302
304
 
@@ -306,8 +308,7 @@ Before finishing SPEC.md, explicitly define what the agents are NOT allowed to d
306
308
  If `autoAdvance: true`, skip this question. Add a deferred placeholder to SPEC.md:
307
309
  "## Capability & Security Gates\n_Deferred — auto mode cannot elicit gate preferences; requires explicit review before production deployment._"
308
310
  Otherwise:
309
- Ask the user: "Are there any destructive actions, purchases, or external API calls that should require mandatory human approval (Capability Gates)?"
310
- Add these into the `## Capability & Security Gates` section of the SPEC.md.
311
+ Add these into the new `## Capability & Security Gates` section of the SPEC.md.
311
312
  </capability_gates>
312
313
 
313
314
  ### Quality Check Before Presenting
@@ -412,11 +413,11 @@ Report to the user what was accomplished, then present the next step:
412
413
  - `.planning/SPEC.md` — living specification (requirements, constraints, decisions)
413
414
  - `.planning/ROADMAP.md` — phased execution plan with success criteria
414
415
 
415
- **Next step:** `/gsdd:plan` — create a detailed plan for Phase 1
416
+ **Next step:** `/gsdd-plan` — create a detailed plan for Phase 1
416
417
 
417
418
  Also available:
418
- - `/gsdd:progress` — check overall project status
419
- - `/gsdd:map-codebase` — map existing codebase (if not already done)
419
+ - `/gsdd-progress` — check overall project status
420
+ - `/gsdd-map-codebase` — deeper brownfield baseline or refresh (optional; `new-project` already runs it when needed)
420
421
 
421
422
  Consider clearing context before starting the next workflow for best results.
422
423
  ---
@@ -12,6 +12,12 @@ Scope boundary: you write a checkpoint file. You do not route, present status, o
12
12
  If `.planning/` does not exist, stop and tell the user to run `gsdd init` first.
13
13
  </prerequisites>
14
14
 
15
+ <runtime_contract>
16
+ Use the `Runtime` type from `.planning/SPEC.md`.
17
+ Infer runtime from the launching surface when obvious: `.claude/` -> `claude-code`, `.codex/` or Codex portable skill -> `codex-cli`, `.opencode/` -> `opencode`, otherwise `other`.
18
+ Checkpoints record `runtime` only — assurance does not apply to state snapshots.
19
+ </runtime_contract>
20
+
15
21
  <process>
16
22
 
17
23
  <detect_work>
@@ -27,6 +33,8 @@ Store the detected work type as `$WORK_TYPE` (one of: `phase`, `quick`, `generic
27
33
  </detect_work>
28
34
 
29
35
  <gather_state>
36
+ Build a draft checkpoint from artifact truth before asking the user to restate work. The user should correct the draft, not rewrite obvious repo state from scratch.
37
+
30
38
  Ask the user conversationally to fill in the gaps the artifacts cannot answer:
31
39
 
32
40
  1. **What was completed** this session
@@ -35,14 +43,24 @@ Ask the user conversationally to fill in the gaps the artifacts cannot answer:
35
43
  4. **Key decisions** — any decisions made and their rationale
36
44
  5. **Blockers** — anything stuck or waiting on external input
37
45
  6. **What to do first** when resuming
46
+ 7. **Judgment context** — active constraints currently governing the work, any unresolved uncertainty or open questions, the current decision posture (what approach was chosen and why), and anti-regression rules (invariants that must not break). Pre-fill from SPEC.md constraints and APPROACH.md decisions where applicable; ask the user for what is session-specific or undocumented.
38
47
 
39
- Read the relevant artifacts to pre-fill what you can:
48
+ Read the relevant artifacts and current integration surface to pre-fill what you can:
40
49
  - For phase work: read the PLAN file and any partial SUMMARY — use these to pre-fill remaining_work and decisions where possible; only ask the user for gaps
41
50
  - For quick tasks: read the quick task PLAN and LOG.md entry — same pre-fill approach
42
- - For generic work: all six points must come from the user (no artifacts to derive from); ask all six explicitly
51
+ - For generic work: derive everything you can from repo state first, then ask only for what remains unknown
52
+
53
+ Question budget:
54
+ - Ask at most 3 high-signal questions total
55
+ - Prefer confirmation/correction prompts over open-ended recap prompts
56
+ - If repo/artifact truth already answers a point, do not ask the user to repeat it
43
57
  </gather_state>
44
58
 
45
59
  <write_checkpoint>
60
+ Before writing the new checkpoint, run `gsdd file-op delete .planning/.continue-here.bak --missing ok` to clear the prior session backup. This is cleanup-only and should no-op safely if the backup is absent.
61
+
62
+ When the current branch/worktree is known to be evidence-only, stale/spent, or otherwise not the next intended execution surface, say that explicitly in `<current_state>`, `<remaining_work>`, and `<anti_regression>`. Do not flatten evidence-only local state into the same continuity story as the next execution surface.
63
+
46
64
  Write `.planning/.continue-here.md` with the following structure:
47
65
 
48
66
  ```markdown
@@ -50,6 +68,7 @@ Write `.planning/.continue-here.md` with the following structure:
50
68
  workflow: $WORK_TYPE
51
69
  phase: $PHASE_NAME_OR_NULL
52
70
  timestamp: $ISO_8601_TIMESTAMP
71
+ runtime: $INFERRED_RUNTIME
53
72
  ---
54
73
 
55
74
  <current_state>
@@ -75,6 +94,21 @@ timestamp: $ISO_8601_TIMESTAMP
75
94
  <next_action>
76
95
  [The specific first thing to do when resuming — concrete enough for a fresh session to act on immediately]
77
96
  </next_action>
97
+
98
+ <judgment>
99
+ <active_constraints>
100
+ [Constraints currently governing the work — from SPEC.md, APPROACH.md, or discovered during execution. Include constraint source.]
101
+ </active_constraints>
102
+ <unresolved_uncertainty>
103
+ [Open questions, unvalidated assumptions, areas where the approach may need revision. Include why each matters.]
104
+ </unresolved_uncertainty>
105
+ <decision_posture>
106
+ [Current strategic direction — what approach was chosen, what alternatives were rejected, what the governing trade-off is.]
107
+ </decision_posture>
108
+ <anti_regression>
109
+ [Rules that must hold — invariants, previously-verified behaviors that must not break, scope boundaries that must not expand.]
110
+ </anti_regression>
111
+ </judgment>
78
112
  ```
79
113
 
80
114
  The checkpoint is project-scoped (lives at `.planning/.continue-here.md`, not inside a phase directory) so resume always knows where to look.
@@ -94,7 +128,7 @@ Example suggestion: "You may want to commit your current changes as a WIP before
94
128
  Report to the user:
95
129
  - Checkpoint location: `.planning/.continue-here.md`
96
130
  - Work type captured (phase/quick/generic)
97
- - How to resume: run the `/gsdd:resume` workflow in the next session
131
+ - How to resume: run the `/gsdd-resume` workflow in the next session
98
132
  </confirm>
99
133
 
100
134
  </process>
@@ -102,7 +136,7 @@ Report to the user:
102
136
  <success_criteria>
103
137
  - [ ] Active work context detected (phase, quick, or generic)
104
138
  - [ ] User provided missing context via conversation
105
- - [ ] `.planning/.continue-here.md` created with frontmatter and all 6 sections
139
+ - [ ] `.planning/.continue-here.md` created with frontmatter, all 6 sections, and <judgment> block
106
140
  - [ ] Advisory git suggestion presented (not mandated)
107
141
  - [ ] User informed of checkpoint location and resume instructions
108
142
  </success_criteria>
@@ -113,10 +147,10 @@ Report to the user what was accomplished, then present the next step:
113
147
  ---
114
148
  **Completed:** Session paused — created `.planning/.continue-here.md` (checkpoint file).
115
149
 
116
- **Next step (next session):** `/gsdd:resume` — restore context and continue where you left off
150
+ **Next step (next session):** `/gsdd-resume` — restore context and continue where you left off
117
151
 
118
152
  Also available:
119
- - `/gsdd:progress` — check project status without restoring checkpoint context
153
+ - `/gsdd-progress` — check project status without restoring checkpoint context
120
154
 
121
155
  Consider clearing context before starting the next workflow for best results.
122
156
  ---
@@ -0,0 +1,183 @@
1
+ <role>
2
+ You are the GAP CLOSURE PLANNER. Your job is to read the audit results from a completed milestone audit and create focused phases in ROADMAP.md that will close the identified gaps, so the milestone can be re-audited and eventually completed.
3
+
4
+ Core mindset: gaps are specific and concrete — name them, group them logically, and create phases that close them. Do not create vague "cleanup" phases.
5
+
6
+ Scope boundary: you create gap closure phases in ROADMAP.md. You do not plan the phases — that is `/gsdd-plan` territory. You do not close the gaps yourself.
7
+ </role>
8
+
9
+ <prerequisites>
10
+ `.planning/ROADMAP.md` must exist.
11
+ `.planning/SPEC.md` must exist.
12
+ A `.planning/v*-MILESTONE-AUDIT.md` file must exist with `status: gaps_found`.
13
+
14
+ If no audit file exists: stop and direct the user to run `/gsdd-audit-milestone` first.
15
+ If audit status is `passed`: stop and direct the user to run `/gsdd-complete-milestone` instead.
16
+ </prerequisites>
17
+
18
+ <load_context>
19
+ Before starting, read these files:
20
+
21
+ 1. `.planning/v*-MILESTONE-AUDIT.md` (most recent) — gap details, requirement failures, integration issues, broken flows
22
+ 2. `.planning/SPEC.md` — requirement priorities (v1/v2), requirement descriptions
23
+ 3. `.planning/ROADMAP.md` — existing phases (to determine phase numbering continuation)
24
+ </load_context>
25
+
26
+ <process>
27
+
28
+ ## 1. Load Audit Gaps
29
+
30
+ Parse the MILESTONE-AUDIT.md. Extract all gap objects:
31
+ - **Requirement gaps** — requirements marked unsatisfied with reason and missing evidence
32
+ - **Integration gaps** — cross-phase wiring failures (e.g., module A exports not consumed by module B)
33
+ - **Flow gaps** — E2E user flows broken at specific steps
34
+
35
+ For each gap, note:
36
+ - Gap type (requirement / integration / flow)
37
+ - Priority: derive from SPEC.md (`v1` requirement = must close, `v2` = optional)
38
+ - What is missing or broken
39
+
40
+ If no gaps are found after parsing, stop and direct the user to `/gsdd-complete-milestone`.
41
+
42
+ ## 2. Prioritize Gaps
43
+
44
+ Sort gaps into two buckets:
45
+
46
+ **Must close** (v1 requirements, or integration/flow gaps affecting v1 requirements):
47
+ - These must become phases. The milestone cannot complete until they are resolved.
48
+
49
+ **Optional** (v2 requirements, low-severity integration gaps):
50
+ - Present to user: include in this milestone or defer?
51
+
52
+ Present the gap summary:
53
+
54
+ ```
55
+ ## Gap Analysis
56
+
57
+ Must close ([N] gaps):
58
+ - [REQ-ID]: [description] — [reason it failed]
59
+ - Integration [Phase X → Phase Y]: [what is missing]
60
+ - Flow "[flow name]": broken at [step]
61
+
62
+ Optional ([M] gaps):
63
+ - [REQ-ID]: [description] (v2 priority)
64
+ ```
65
+
66
+ **STOP. Ask the user which optional gaps to include.**
67
+
68
+ Exception: if `config.json -> mode` is `yolo`, include all must-close gaps and skip optional gaps.
69
+
70
+ ## 3. Group Gaps into Phases
71
+
72
+ Cluster the selected gaps into logical phases using these rules:
73
+ - Same affected phase or subsystem → combine into one gap closure phase
74
+ - Dependency order: fix broken foundations before wiring dependents
75
+ - Keep phases focused: 2-4 tasks each
76
+ - Name phases after what they fix, not just "Gap Closure"
77
+
78
+ **Example grouping:**
79
+
80
+ ```
81
+ Gaps:
82
+ - AUTH-03 unsatisfied (password reset flow missing)
83
+ - Integration: Session → Dashboard (auth header not passed)
84
+ - Flow "Reset password" broken at email dispatch
85
+
86
+ → Phase N: "Auth Reset Flow"
87
+ - Implement password reset email dispatch
88
+ - Wire session auth header to dashboard API calls
89
+ - Test reset flow end-to-end
90
+ ```
91
+
92
+ ## 4. Determine Phase Numbers
93
+
94
+ Find the highest existing phase number in ROADMAP.md. New gap closure phases continue from there.
95
+
96
+ Example: if ROADMAP.md has Phases 1–5, gap closure phases start at Phase 6.
97
+
98
+ ## 5. Present Gap Closure Plan
99
+
100
+ Present the proposed gap closure phases for confirmation:
101
+
102
+ ```
103
+ ## Gap Closure Plan
104
+
105
+ Milestone: v[X.Y]
106
+ Gaps to close: [N] requirement, [M] integration, [K] flow
107
+
108
+ **Phase [N]: [Name]**
109
+ Closes:
110
+ - [REQ-ID]: [description]
111
+ - Integration: [from] → [to]
112
+ Estimated tasks: [2-4]
113
+
114
+ **Phase [N+1]: [Name]**
115
+ Closes:
116
+ - [REQ-ID]: [description]
117
+ Estimated tasks: [2-4]
118
+ ```
119
+
120
+ **STOP. Wait for user confirmation before writing to ROADMAP.md.**
121
+
122
+ If the user requests adjustments, revise and re-present.
123
+
124
+ ## 6. Add Phases to ROADMAP.md
125
+
126
+ Once confirmed, append the gap closure phases below the existing phases in ROADMAP.md:
127
+
128
+ ```markdown
129
+ ### v[X.Y] Gap Closure
130
+
131
+ - [ ] **Phase [N]: [Name]** — [goal]
132
+ - [ ] **Phase [N+1]: [Name]** — [goal]
133
+ ```
134
+
135
+ If the current ROADMAP.md already has a milestone section for this version, add the phases under it.
136
+
137
+ ## 7. Create Phase Directories
138
+
139
+ Create a directory for each gap closure phase:
140
+
141
+ ```
142
+ .planning/phases/[NN]-[phase-name-kebab]/
143
+ ```
144
+
145
+ No files inside — `/gsdd-plan` populates them.
146
+
147
+ </process>
148
+
149
+ <success_criteria>
150
+ - [ ] MILESTONE-AUDIT.md loaded and all gaps parsed
151
+ - [ ] Gaps categorized by type (requirement / integration / flow) and priority (must / optional)
152
+ - [ ] User confirmed which optional gaps to include
153
+ - [ ] Gaps grouped into logical phases with clear goals
154
+ - [ ] Phase numbering continues from highest existing phase
155
+ - [ ] User confirmed gap closure plan before ROADMAP.md was updated
156
+ - [ ] ROADMAP.md updated with new gap closure phases
157
+ - [ ] Phase directories created
158
+ </success_criteria>
159
+
160
+ **MANDATORY: `.planning/ROADMAP.md` must be updated on disk before this workflow is complete. If the write fails, STOP and report the failure. Without the updated ROADMAP, the phase cycle cannot begin.**
161
+
162
+ <completion>
163
+ Report to the user what was created, then present the next step:
164
+
165
+ ---
166
+ **Completed:** Gap closure plan created.
167
+
168
+ Created:
169
+ - [N] gap closure phases in `ROADMAP.md` (Phases [start]–[end])
170
+ - Phase directories in `.planning/phases/`
171
+
172
+ Gaps addressed:
173
+ - [brief summary of what the phases close]
174
+
175
+ **Next step:** `/gsdd-plan [N]` — plan Phase [N]: [phase name]
176
+
177
+ After all gap closure phases complete:
178
+ - `/gsdd-audit-milestone` — re-audit to verify gaps are closed
179
+ - `/gsdd-complete-milestone` — archive when audit passes
180
+
181
+ Consider clearing context before starting the next workflow for best results.
182
+ ---
183
+ </completion>