gswd 1.0.1 → 1.1.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 (85) hide show
  1. package/bin/gswd-tools.cjs +228 -0
  2. package/commands/gswd/imagine.md +7 -1
  3. package/commands/gswd/start.md +507 -32
  4. package/dist/lib/audit.d.ts +205 -0
  5. package/dist/lib/audit.js +805 -0
  6. package/dist/lib/bootstrap.d.ts +103 -0
  7. package/dist/lib/bootstrap.js +563 -0
  8. package/dist/lib/compile.d.ts +239 -0
  9. package/dist/lib/compile.js +1152 -0
  10. package/dist/lib/config.d.ts +49 -0
  11. package/dist/lib/config.js +150 -0
  12. package/dist/lib/imagine-agents.d.ts +54 -0
  13. package/dist/lib/imagine-agents.js +185 -0
  14. package/dist/lib/imagine-gate.d.ts +47 -0
  15. package/dist/lib/imagine-gate.js +131 -0
  16. package/dist/lib/imagine-input.d.ts +46 -0
  17. package/dist/lib/imagine-input.js +233 -0
  18. package/dist/lib/imagine-synthesis.d.ts +90 -0
  19. package/dist/lib/imagine-synthesis.js +453 -0
  20. package/dist/lib/imagine.d.ts +56 -0
  21. package/dist/lib/imagine.js +413 -0
  22. package/dist/lib/intake.d.ts +27 -0
  23. package/dist/lib/intake.js +82 -0
  24. package/dist/lib/parse.d.ts +59 -0
  25. package/dist/lib/parse.js +171 -0
  26. package/dist/lib/render.d.ts +309 -0
  27. package/dist/lib/render.js +624 -0
  28. package/dist/lib/specify-agents.d.ts +120 -0
  29. package/dist/lib/specify-agents.js +269 -0
  30. package/dist/lib/specify-journeys.d.ts +124 -0
  31. package/dist/lib/specify-journeys.js +279 -0
  32. package/dist/lib/specify-nfr.d.ts +45 -0
  33. package/dist/lib/specify-nfr.js +159 -0
  34. package/dist/lib/specify-roles.d.ts +46 -0
  35. package/dist/lib/specify-roles.js +88 -0
  36. package/dist/lib/specify.d.ts +70 -0
  37. package/dist/lib/specify.js +676 -0
  38. package/dist/lib/state.d.ts +140 -0
  39. package/dist/lib/state.js +340 -0
  40. package/dist/tests/audit.test.d.ts +4 -0
  41. package/dist/tests/audit.test.js +1579 -0
  42. package/dist/tests/bootstrap.test.d.ts +5 -0
  43. package/dist/tests/bootstrap.test.js +611 -0
  44. package/dist/tests/compile.test.d.ts +4 -0
  45. package/dist/tests/compile.test.js +862 -0
  46. package/dist/tests/config.test.d.ts +4 -0
  47. package/dist/tests/config.test.js +191 -0
  48. package/dist/tests/imagine-agents.test.d.ts +6 -0
  49. package/dist/tests/imagine-agents.test.js +179 -0
  50. package/dist/tests/imagine-gate.test.d.ts +6 -0
  51. package/dist/tests/imagine-gate.test.js +264 -0
  52. package/dist/tests/imagine-input.test.d.ts +6 -0
  53. package/dist/tests/imagine-input.test.js +283 -0
  54. package/dist/tests/imagine-synthesis.test.d.ts +7 -0
  55. package/dist/tests/imagine-synthesis.test.js +380 -0
  56. package/dist/tests/imagine.test.d.ts +8 -0
  57. package/dist/tests/imagine.test.js +406 -0
  58. package/dist/tests/parse.test.d.ts +4 -0
  59. package/dist/tests/parse.test.js +285 -0
  60. package/dist/tests/render.test.d.ts +4 -0
  61. package/dist/tests/render.test.js +236 -0
  62. package/dist/tests/specify-agents.test.d.ts +4 -0
  63. package/dist/tests/specify-agents.test.js +352 -0
  64. package/dist/tests/specify-journeys.test.d.ts +5 -0
  65. package/dist/tests/specify-journeys.test.js +440 -0
  66. package/dist/tests/specify-nfr.test.d.ts +4 -0
  67. package/dist/tests/specify-nfr.test.js +205 -0
  68. package/dist/tests/specify-roles.test.d.ts +4 -0
  69. package/dist/tests/specify-roles.test.js +136 -0
  70. package/dist/tests/specify.test.d.ts +9 -0
  71. package/dist/tests/specify.test.js +544 -0
  72. package/dist/tests/state.test.d.ts +4 -0
  73. package/dist/tests/state.test.js +316 -0
  74. package/lib/bootstrap.ts +37 -11
  75. package/lib/compile.ts +426 -4
  76. package/lib/imagine-agents.ts +53 -7
  77. package/lib/imagine-synthesis.ts +170 -6
  78. package/lib/imagine.ts +59 -5
  79. package/lib/intake.ts +60 -0
  80. package/lib/parse.ts +2 -1
  81. package/lib/render.ts +566 -5
  82. package/lib/specify-agents.ts +25 -3
  83. package/lib/state.ts +115 -0
  84. package/package.json +3 -2
  85. package/templates/gswd/DECISIONS.template.md +3 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: gswd:start
3
3
  description: Imagine, specify, audit, and compile — from idea to GSD contract
4
- argument-hint: "[@idea.md]"
4
+ argument-hint: "[@idea.md] [--auto]"
5
5
  allowed-tools:
6
6
  - Bash
7
7
  - Read
@@ -23,14 +23,18 @@ One command to go from a product idea to a GSD-ready contract.
23
23
  - Full GSWD bundle (IMAGINE.md, DECISIONS.md, SPEC.md, JOURNEYS.md, etc.)
24
24
  - Compiled GSD contract: PROJECT.md, REQUIREMENTS.md, ROADMAP.md, STATE.md
25
25
 
26
+ **Modes:**
27
+ - **Manual (default)** — pauses at each stage boundary with a summary and options (proceed, re-run, other)
28
+ - **Auto (`--auto`)** — runs the full pipeline with no interactive stage-boundary prompts (v1.0 behavior)
29
+
26
30
  **Power-user flags (all optional):**
27
- - `--auto` — apply auto policy for decision-making (minimal interruptions). Requires @idea.md to skip interactive intake.
31
+ - `--auto` — run the full pipeline automatically with no stage-boundary pauses
28
32
  - `--policy=<name>` — select named policy: `strict`, `balanced`, `aggressive`
29
33
  - `--resume` — continue from last checkpoint in `.planning/gswd/STATE.json`
30
34
  - `--skip-research` — disable research agents
31
35
 
32
36
  **Hard gates:**
33
- - Cannot finish if audit is FAIL
37
+ - Cannot finish if audit is FAIL (in auto mode). In manual mode, user chooses.
34
38
  - In auto mode, cannot finish if policy requires manual approvals and they are not present
35
39
  </objective>
36
40
 
@@ -48,19 +52,70 @@ Check if `.planning/gswd/STATE.json` existed before this call. If STATE.json did
48
52
 
49
53
  The init call is idempotent and safe to run regardless of existing state.
50
54
 
51
- ## Step 2 — Check for existing state
55
+ ## Step 2 — First-run experience (one-time)
56
+
57
+ Read `.planning/gswd/STATE.json` using the Read tool. Check the `first_run_complete` field:
58
+
59
+ - If `first_run_complete` is `true`: skip this step entirely — no logo, no guide, nothing.
60
+ - If `first_run_complete` is missing, `false`, or `undefined`: this is the first run. Display the branding:
61
+
62
+ 1. Show the ASCII logo:
63
+ ```bash
64
+ node ./bin/gswd-tools.cjs render logo
65
+ ```
66
+
67
+ 2. Show the command guide:
68
+ ```bash
69
+ node ./bin/gswd-tools.cjs render first-run-guide
70
+ ```
71
+
72
+ 3. Mark first run as complete (write flag AFTER display — prevents flag being set without user seeing branding):
73
+ ```bash
74
+ node ./bin/gswd-tools.cjs first-run-complete
75
+ ```
76
+
77
+ The logo, tagline, and guide display as a single welcome block. After this, proceed directly to Step 3.
78
+
79
+ ## Step 3 — Check for existing state
52
80
 
53
81
  Read `.planning/gswd/STATE.json` using the Read tool. Branch on the `stage` field:
54
82
 
55
- - If `stage` is not `done` and not `init` (work is in progress): ask the user "Resume from [stage]? [yes / start fresh]"
56
- - If yes: add `--resume` to the bootstrap call arguments assembled in Step 4
57
- - If start fresh: proceed without `--resume`
58
- - If `stage` is `done` (pipeline already completed): ask the user "You already have a completed spec. Start fresh or resume?"
59
- - If resume: add `--resume` to the bootstrap arguments
60
- - If fresh: proceed without `--resume`
61
- - If `stage` is `init` or STATE.json was just created by Step 1: proceed directly to Step 3 (no resume prompt)
83
+ - If `stage` is `init` or STATE.json was just created by Step 1: skip this step proceed directly to Step 4 (no resume prompt needed for a fresh project)
84
+
85
+ - If `stage` is not `init` and not `done` (work is in progress): present a choice using AskUserQuestion:
86
+
87
+ **Question:** "You have an in-progress session."
88
+ **Options:**
89
+ 1. Resume previous session continue from the current stage
90
+ 2. Start new product — discard current state and begin fresh
91
+
92
+ If the user selects (1):
93
+ - Check `manual_mode` in STATE.json:
94
+ - If `manual_mode.enabled` is `true`: this is a manual mode resume. Read `manual_mode.last_checkpoint_stage` and `manual_mode.interrupt_type`.
95
+ - If `interrupt_type` is `mid_stage`: the interrupted stage will be re-run from scratch.
96
+ - If `interrupt_type` is `between_stages`: the next stage after `last_checkpoint_stage` will begin.
97
+ - Skip intake summary on resume (per CONTEXT.md decision). Just show stage progress:
98
+ ```bash
99
+ node ./bin/gswd-tools.cjs status
100
+ ```
101
+ - Display a brief recap: which stages are complete and where we are picking up.
102
+ - If `manual_mode.enabled` is `false` or not present (auto mode resume):
103
+ - Show status and read DECISIONS.md if it exists for a 2-3 sentence recap
104
+ - Add `--resume` to the pipeline call arguments assembled in Step 5
105
+
106
+ If the user selects (2): proceed without `--resume` (fresh start)
107
+
108
+ - If `stage` is `done` (pipeline already completed): present a choice using AskUserQuestion:
62
109
 
63
- ## Step 3 Collect idea
110
+ **Question:** "You already have a completed spec."
111
+ **Options:**
112
+ 1. Start new product — create a fresh spec from scratch
113
+ 2. Resume from compile — re-run compile with existing spec
114
+
115
+ If the user selects (2): add `--resume` to the pipeline arguments
116
+ If the user selects (1): proceed without `--resume`
117
+
118
+ ## Step 4 — Collect idea
64
119
 
65
120
  **Path A — Idea file provided in $ARGUMENTS**
66
121
 
@@ -70,7 +125,11 @@ Detect Path A if $ARGUMENTS contains any word starting with `@` OR a path ending
70
125
  2. Summarize the idea in 2-3 sentences
71
126
  3. Ask: "Did I get that right? [yes / edit]"
72
127
  4. If the user chooses edit: let them revise, then re-summarize and re-confirm
73
- 5. Once confirmed, proceed to Step 4
128
+ 5. Once confirmed, write INTAKE.json for resume support:
129
+ ```bash
130
+ node ./bin/gswd-tools.cjs intake write --description "<confirmed summary>" --source file --idea-file "<original file path>"
131
+ ```
132
+ 6. Proceed to Step 5
74
133
 
75
134
  **Path B — No file provided in $ARGUMENTS**
76
135
 
@@ -80,44 +139,460 @@ Detect Path A if $ARGUMENTS contains any word starting with `@` OR a path ending
80
139
  2. After the user responds, summarize their response in 2-3 sentences
81
140
  3. Ask: "Did I get that right? [yes / edit]"
82
141
  4. If the user chooses edit: let them revise, then re-summarize and re-confirm
83
- 5. Once confirmed, write the confirmed summary to `.planning/gswd/intake.md` using the Write tool so it can be passed to the bootstrap CLI:
84
-
85
- ```
86
- # Idea
142
+ 5. Once confirmed:
143
+ a. Write INTAKE.json for resume support:
144
+ ```bash
145
+ node ./bin/gswd-tools.cjs intake write --description "<confirmed summary>" --source interactive
146
+ ```
147
+ b. Write intake.md for the pipeline CLI (same as before):
148
+ ```
149
+ # Idea
87
150
 
88
- <confirmed summary here>
89
- ```
151
+ <confirmed summary here>
152
+ ```
153
+ 6. Proceed to Step 5
90
154
 
91
- 6. Proceed to Step 4
155
+ Note: "Did I get that right?" is the key moment — it is the last manual touchpoint before stages run. INTAKE.json is written AFTER confirmation, BEFORE any stage execution.
92
156
 
93
- Note: "Did I get that right?" is the key moment it is the last manual touchpoint before automated stages run.
157
+ ## Step 5Route by mode
94
158
 
95
- ## Step 4 — Run the bootstrap pipeline
159
+ Determine mode from $ARGUMENTS:
160
+ - If `--auto` is present: set `mode = auto`
161
+ - Otherwise: set `mode = manual` (the default)
96
162
 
97
- Assemble the CLI command:
163
+ **If mode is auto:**
98
164
 
165
+ Assemble and run the bootstrap command exactly as before:
99
166
  - Base: `node ./bin/gswd-tools.cjs bootstrap`
100
167
  - If Path A: append the original `$ARGUMENTS` (contains the file path and any flags as-is)
101
168
  - If Path B: append `@.planning/gswd/intake.md` as the idea file argument, then append any flags from `$ARGUMENTS` that are NOT file paths (e.g., `--skip-research`, `--policy=balanced`)
102
- - If `--auto` is in `$ARGUMENTS` but no file was provided (Path B): note that `--auto` applies to pipeline stages after intake; proceed with interactive intake first, then pass `--auto` to the bootstrap call along with the intake.md path
103
- - If `--resume` was added in Step 2: include it in the arguments
169
+ - If `--resume` was added in Step 3: include it in the arguments
104
170
 
105
171
  Run the assembled command via Bash:
106
-
107
172
  ```bash
108
173
  node ./bin/gswd-tools.cjs bootstrap <assembled arguments>
109
174
  ```
110
175
 
111
- ## Step 5 Show pipeline progress
176
+ Skip to Step 7 (completion handler).
177
+
178
+ **If mode is manual:**
179
+
180
+ Write manual mode to STATE.json:
181
+ ```bash
182
+ node ./bin/gswd-tools.cjs state set-manual-mode true
183
+ ```
184
+
185
+ Proceed to Step 6 (manual stage loop).
186
+
187
+ ## Step 6 — Manual stage loop
188
+
189
+ Run stages in order: Imagine, Specify, Audit, Compile. For each stage, follow the pattern below.
190
+
191
+ If resuming (`--resume` was added in Step 3), determine the resume point:
192
+ - Read STATE.json `stage_status` and `manual_mode.last_checkpoint_stage`
193
+ - Skip any stage whose status is `done` (or `pass` for audit) AND whose artifacts are valid
194
+ - If `manual_mode.interrupt_type` is `mid_stage`, re-run the stage at `last_checkpoint_stage`
195
+ - If `manual_mode.interrupt_type` is `between_stages`, start the next stage after `last_checkpoint_stage`
196
+
197
+ ### 6.1 — Imagine
198
+
199
+ If resuming and imagine is already `done` in STATE.json with valid artifacts (IMAGINE.md, ICP.md, GTM.md, COMPETITION.md, DECISIONS.md all exist and non-empty), skip to 6.2.
200
+
201
+ #### 6.1.1 — Run Imagine
202
+
203
+ **Extract product context.** Read `.planning/gswd/INTAKE.json` using the Read tool. Extract:
204
+ - `domain`: the first sentence of the `description` field (up to the first period)
205
+ - `targetUser`: the `target_user` field
206
+ - Fallback to "your product" / "your users" if fields are missing
207
+
208
+ **Display contextual banner.** Render a contextualized stage banner:
209
+
210
+ For a first run (STATE.json `manual_mode.reruns.imagine` is 0 or missing):
211
+ ```
212
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
213
+ GSWD ► IMAGINE
214
+ Validating product direction for {domain} targeting {targetUser}
215
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
216
+ ```
217
+
218
+ For re-runs (STATE.json `manual_mode.reruns.imagine` > 0):
219
+ ```
220
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
221
+ GSWD ► IMAGINE
222
+ Refining directions based on your feedback about {key concern from revision-notes.md}
223
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
224
+ ```
225
+
226
+ **Display agent pre-briefing** BEFORE the imagine CLI call. Show all 5 Imagine agents with product-contextualized purposes:
227
+ ```
228
+ ◆ Spawning 5 research agents:
229
+ → market-researcher: mapping the {domain} landscape to find gaps
230
+ → icp-persona: profiling {targetUser} who need {domain}
231
+ → positioning: finding the angle that makes {domain} obviously necessary
232
+ → brainstorm-alternatives: exploring 3 distinct product directions for {domain}
233
+ → devils-advocate: stress-testing assumptions before you commit to a direction
234
+ ```
235
+
236
+ The pre-briefing uses the user's product context, not generic text. Each agent is named explicitly for technical transparency.
237
+
238
+ **Run imagine** via Bash:
239
+ ```bash
240
+ node ./bin/gswd-tools.cjs imagine @.planning/gswd/intake.md {--skip-research if flag present}
241
+ ```
242
+
243
+ If this is a re-run with augmented context:
244
+ ```bash
245
+ node ./bin/gswd-tools.cjs imagine @.planning/gswd/intake.md --rerun-context .planning/gswd/revision-notes.md
246
+ ```
247
+
248
+ After imagine completes successfully, read the ImagineResult output. Extract `research_summary`, `selected_direction`, `vision_statement`, `agent_headlines`, and artifact paths.
249
+
250
+ #### 6.1.2 — Display Agent Completion Headlines and Research Summary
251
+
252
+ **Display individual agent completion headlines.** After the imagine command returns, display each agent's key finding on its own line. If `agent_headlines` are available in the ImagineResult, use them directly. Otherwise, extract headlines from the raw artifact files (COMPETITION.md, ICP.md, GTM.md) by reading the first sentence after `## Summary` or `## Overview` or the first non-heading line.
253
+
254
+ ```
255
+ ✓ market-researcher: {headline from agent output}
256
+ ✓ icp-persona: {headline from agent output}
257
+ ✓ positioning: {headline from agent output}
258
+ ✓ brainstorm-alternatives: {headline from agent output}
259
+ ✓ devils-advocate: {headline from agent output}
260
+ ```
261
+
262
+ Show each agent individually — even if multiple agents finished within seconds, each gets its own line. Use ✓ for completed agents and ✗ for any that failed.
263
+
264
+ Note: Since CLI execution is synchronous (agents run inside `node ./bin/gswd-tools.cjs imagine`), headlines are displayed AFTER the command returns. Each agent still gets its own line with its key finding to meet COMM-03.
265
+
266
+ Read the output artifacts using the Read tool: `.planning/IMAGINE.md`, `.planning/ICP.md`, `.planning/GTM.md`, `.planning/COMPETITION.md`, `.planning/DECISIONS.md`
267
+
268
+ **Display the structured research summary.** For each agent section from the ImagineResult `research_summary`:
269
+
270
+ 1. Show the section display name as a ### heading
271
+ 2. Show a product-contextualized intro: "*For a product helping {target_user}:*"
272
+ 3. Show 3-5 takeaway bullets (highlights only, not full agent output)
273
+ 4. Show the bridging paragraph: how these findings shaped the proposed directions
274
+
275
+ The summary should read like a consultant brief written for the user's specific product, not a generic market report. Reference the user's actual product/problem in section intros.
276
+
277
+ Mention that full agent outputs are available in their raw artifact files.
278
+
279
+ #### 6.1.3 — Present Direction Cards
280
+
281
+ Display each of the 3 directions using direction cards:
282
+
283
+ For each direction (proposed + 2 alternatives):
284
+ 1. Show direction label with **(Recommended)** marker on the proposed direction
285
+ 2. Show **"Why this makes sense:"** rationale section FIRST with evidence-based bullets
286
+ 3. Show existing fields: ICP, Problem, Wedge, Differentiator, Risks
287
+
288
+ #### 6.1.4 — Direction Selection
289
+
290
+ Present direction selection using AskUserQuestion:
291
+ - **header:** "Choose your product direction"
292
+ - **question:** "Review the directions above. Which path fits your vision?"
293
+ - **options:**
294
+ - "{Direction 1 label}" (the proposed/recommended direction)
295
+ - "{Direction 2 label}"
296
+ - "{Direction 3 label}"
297
+ - "Not satisfied — tell me more"
298
+
299
+ **Handle response:**
300
+
301
+ **If user selects a direction (option 1, 2, or 3):** Record the selection. Proceed to 6.1.5 (Vision Statement).
302
+
303
+ **If user selects "Not satisfied — tell me more":**
304
+
305
+ 1. Ask the user conversationally: "What's missing or wrong? Tell me what you didn't like or what you'd like to explore differently."
306
+ 2. Collect their free-text feedback.
307
+ 3. **CASCADE-INVALIDATE FIRST** (IMAGINE-08 — this MUST happen before any new artifact writes):
308
+ ```bash
309
+ node ./bin/gswd-tools.cjs state cascade-invalidate imagine
310
+ ```
311
+ 4. Write the user's feedback to `.planning/gswd/revision-notes.md`:
312
+ ```
313
+ # Imagine Re-run Feedback
314
+
315
+ **Re-run #{N}** (from STATE.json manual_mode.reruns.imagine)
316
+ **Date:** {current date}
317
+
318
+ ## User Feedback
319
+ {user's free-text feedback}
320
+
321
+ ## Previous Direction Labels
322
+ {list the 3 directions from this run}
323
+ ```
324
+ 5. Re-run imagine with augmented context:
325
+ ```bash
326
+ node ./bin/gswd-tools.cjs imagine @.planning/gswd/intake.md --rerun-context .planning/gswd/revision-notes.md
327
+ ```
328
+ The `--rerun-context` flag causes imagine to pass previous agent outputs + user feedback into agent prompts, so agents build on or pivot from prior findings.
329
+ 6. **Loop back to 6.1.2** (display new research summary, present new direction cards, offer selection again).
330
+
331
+ Re-runs are unlimited — no hard cap (IMAGINE-04). The re-run counter in STATE.json tracks count for visibility/debugging only.
332
+
333
+ #### 6.1.5 — Vision Statement
334
+
335
+ After a direction is selected, synthesize a vision statement:
336
+
337
+ 1. Using the research findings and selected direction, generate an aspirational vision statement.
338
+ - Vision = aspirational future state the product enables ("A world where X is possible")
339
+ - NOT a product description (what the product does)
340
+ - Different scope: vision describes the world the product creates, not the product itself
341
+ - Example: "A world where solo founders never build the wrong thing because their specification process is as rigorous as their code."
342
+
343
+ 2. Present the vision statement to the user using AskUserQuestion:
344
+ - **header:** "Vision Statement"
345
+ - **question:** Show the generated vision statement, then ask: "This vision captures the aspirational future your product enables. Accept or edit?"
346
+ - **options:**
347
+ - "Accept this vision"
348
+ - "Edit — I want to adjust it"
349
+
350
+ 3. **Handle response:**
351
+ - **"Accept this vision":** Proceed with this vision statement.
352
+ - **"Edit — I want to adjust it":** Ask: "What would you like to change or add?" Collect feedback. Regenerate the vision incorporating the user's additional inputs. Present again with Accept / Edit. Loop until accepted.
353
+
354
+ 4. The accepted vision statement is already written to DECISIONS.md (## Vision section) and IMAGINE.md (## Vision section) by the imagine workflow. If the user edited and regenerated, update both files atomically via CLI:
355
+ ```bash
356
+ node ./bin/gswd-tools.cjs imagine update-vision "<accepted vision statement>"
357
+ ```
358
+ This replaces the ## Vision section in both DECISIONS.md and IMAGINE.md atomically via safeWriteFile(). Do NOT use the Write tool directly on these files for vision updates — route all vision writes through this command.
359
+
360
+ #### 6.1.6 — Post-Imagine Summary and Checkpoint
361
+
362
+ 1. Generate a structured summary (same pattern as before):
363
+ - **Headline:** Count of product directions proposed, mention ICP/GTM/competition coverage, note vision statement frozen
364
+ - **Section summaries:** One paragraph each for product directions, ICP analysis, GTM strategy, competition landscape, key decisions, and vision statement
365
+ - **File list:** All files created/updated
366
+
367
+ 2. Display the summary to the user.
368
+
369
+ 3. Record checkpoint in STATE.json:
370
+ ```bash
371
+ node ./bin/gswd-tools.cjs state update-manual-checkpoint imagine between_stages
372
+ ```
373
+
374
+ 4. Present the checkpoint using AskUserQuestion:
375
+ - **header:** "Imagine complete"
376
+ - **question:** Consultant-style summary referencing actual findings: "The research mapped {domain}'s competitive landscape, identified {targetUser} as your primary persona, and produced {N} distinct product directions. You selected '{direction label}' and froze a vision statement. The groundwork for a strong spec is in place. Proceed to Specify?\n\n> **Tip:** Run `/clear` before continuing — the imagine stage consumed significant context."
377
+ - **options:**
378
+ - "Proceed to Specify"
379
+ - "Edit & re-run Imagine"
380
+ - "Other"
381
+
382
+ 5. Handle response:
383
+ - **"Proceed to Specify":** Continue to 6.2.
384
+ - **"Edit & re-run Imagine":** Ask the user: "What would you like to change?" Collect feedback. Run cascade invalidation:
385
+ ```bash
386
+ node ./bin/gswd-tools.cjs state cascade-invalidate imagine
387
+ ```
388
+ Write feedback to revision-notes.md. Re-run imagine with augmented context. Loop back to 6.1.2. Re-runs are unlimited.
389
+ - **"Other":** Accept free-text input. Interpret and act accordingly.
390
+
391
+ ### 6.2 — Specify
392
+
393
+ If resuming and specify is already `done` in STATE.json with valid artifacts (SPEC.md, JOURNEYS.md, NFR.md, ARCHITECTURE.md, INTEGRATIONS.md all exist and non-empty), skip to 6.3.
394
+
395
+ **Extract enriched product context.** DECISIONS.md now exists after Imagine. Read it to get precise context:
396
+ - Read `**Product Direction:**` from DECISIONS.md for the domain
397
+ - Read `**Target User:**` from DECISIONS.md for the target user
398
+ - These are more precise than INTAKE.json since they reflect the user's chosen direction
399
+
400
+ **Display contextual banner:**
401
+ ```
402
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
403
+ GSWD ► SPECIFY
404
+ Building the execution-grade spec: journeys, requirements, and architecture for {domain}
405
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
406
+ ```
407
+
408
+ **Display agent pre-briefing** for Specify agents:
409
+ ```
410
+ ◆ Spawning specification agents:
411
+ → journey-mapper: mapping user journeys for {targetUser} through {domain}
412
+ → architecture-drafter: designing the system architecture for {domain}
413
+ → integrations-checker: evaluating external services {domain} needs to connect with
414
+ ```
415
+
416
+ Run specify via Bash:
417
+ ```bash
418
+ node ./bin/gswd-tools.cjs specify
419
+ ```
420
+
421
+ After specify completes successfully:
422
+
423
+ 1. Read the output artifacts using the Read tool: `.planning/SPEC.md`, `.planning/JOURNEYS.md`, `.planning/NFR.md`, `.planning/ARCHITECTURE.md`, `.planning/INTEGRATIONS.md`
424
+ 2. Generate a structured summary:
425
+ - **Headline:** Count of journeys, NFR categories, architecture decisions, integrations
426
+ - **Section summaries:** One paragraph each for:
427
+ - Spec overview (scope, key features)
428
+ - User journeys (count, primary flows)
429
+ - NFRs (categories, key constraints)
430
+ - Architecture (stack decisions, patterns)
431
+ - Integrations (count, key services)
432
+ - **File list:** All files created/updated
433
+ 3. Display the summary
434
+
435
+ 4. Record checkpoint:
436
+ ```bash
437
+ node ./bin/gswd-tools.cjs state update-manual-checkpoint specify between_stages
438
+ ```
439
+
440
+ 5. Present checkpoint using AskUserQuestion:
441
+ - **header:** "Specify complete"
442
+ - **question:** Consultant-style summary referencing actual findings: "Specify mapped {N} user journeys with {M} functional requirements and {K} NFR categories for {domain}. The architecture defines {C} components. Every journey traces to requirements — the spec is execution-ready. Proceed to Audit?\n\n> **Tip:** Run `/clear` before continuing — the specify stage consumed significant context."
443
+ - **options:**
444
+ - "Proceed to Audit"
445
+ - "Edit & re-run Specify"
446
+ - "Other"
447
+
448
+ 6. Handle response (same pattern as 6.1):
449
+ - **"Proceed to Audit":** Continue to 6.3
450
+ - **"Edit & re-run Specify":** Cascade-invalidate specify, collect feedback, re-run with feedback, loop
451
+ ```bash
452
+ node ./bin/gswd-tools.cjs state cascade-invalidate specify
453
+ ```
454
+ - **"Other":** Interpret free-text
455
+
456
+ ### 6.3 — Audit
457
+
458
+ If resuming and audit is already `pass` in STATE.json with valid artifacts (AUDIT.md exists and non-empty), skip to 6.4.
459
+
460
+ **Display contextual banner:**
461
+ ```
462
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
463
+ GSWD ► AUDIT
464
+ Verifying spec completeness — every journey, requirement, and edge case for {domain} must trace
465
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
466
+ ```
467
+
468
+ **Display pre-run explanation.** Audit has no agents, so no pre-briefing. Instead, show a one-line explanation of what the deterministic checks will do:
469
+
470
+ "Running deterministic coverage checks: journey-FR tracing, orphan detection, integration validation, and heading compliance."
471
+
472
+ Run audit via Bash:
473
+ ```bash
474
+ node ./bin/gswd-tools.cjs audit
475
+ ```
476
+
477
+ After audit completes:
478
+
479
+ **If audit PASSED:**
480
+
481
+ 1. Read `.planning/AUDIT.md` and generate summary: total checks, pass count, coverage
482
+ 2. Display summary
483
+
484
+ 3. Record checkpoint:
485
+ ```bash
486
+ node ./bin/gswd-tools.cjs state update-manual-checkpoint audit between_stages
487
+ ```
488
+
489
+ 4. Present checkpoint using AskUserQuestion:
490
+ - **header:** "Audit passed"
491
+ - **question:** Consultant-style summary: "Audit passed all {N} checks with full coverage for {domain}. Every journey links to requirements, no orphan specs, and all integration statuses are resolved. The specification is verified and ready for compilation. Proceed to Compile?"
492
+ - **options:**
493
+ - "Proceed to Compile"
494
+ - "Re-run Audit"
495
+ - "Other"
496
+
497
+ 5. Handle response:
498
+ - **"Proceed to Compile":** Continue to 6.4
499
+ - **"Re-run Audit":** Re-run audit, loop
500
+ - **"Other":** Interpret free-text
501
+
502
+ **If audit FAILED (manual mode specific handling):**
503
+
504
+ 1. Read `.planning/AUDIT.md` for failure details
505
+ 2. Display the audit failures with details — show what failed and why
506
+
507
+ 3. Present checkpoint using AskUserQuestion:
508
+ - **header:** "Audit failed"
509
+ - **question:** Consultant-style summary: "Audit found {N} issues in the {domain} specification. {top issue summary}. These gaps need attention before the spec can be trusted as a build contract."
510
+ - **options:**
511
+ - "Fix issues & re-run Audit"
512
+ - "Proceed to Compile anyway"
513
+ - "Stop here"
514
+
515
+ 4. Handle response:
516
+ - **"Fix issues & re-run Audit":** Ask user for guidance on what to fix, or attempt automatic fixes. Run cascade-invalidate on audit:
517
+ ```bash
518
+ node ./bin/gswd-tools.cjs state cascade-invalidate audit
519
+ ```
520
+ Re-run audit. Loop back to check result.
521
+ - **"Proceed to Compile anyway":** Log the override decision in STATE.json (record that user chose to proceed despite audit failures). Continue to 6.4.
522
+ - **"Stop here":** Display current status and inform user they can resume later with `/gswd:start --resume`. Exit the pipeline gracefully.
523
+
524
+ ### 6.4 — Compile
525
+
526
+ **No contextual banner for Compile.** Per CONTEXT.md locked decision: "Skip Compile (deterministic, quick, banner unnecessary)." Keep any existing minimal banner as `renderBanner('COMPILE')` without a context line. Do NOT add a product-contextualized line.
527
+
528
+ Run compile via Bash:
529
+ ```bash
530
+ node ./bin/gswd-tools.cjs compile
531
+ ```
532
+
533
+ After compile completes successfully:
534
+
535
+ Display a brief informational one-liner (not a banner, just context):
536
+ "Compile is deterministic — same spec inputs always produce the same GSD contract. No advisor commentary needed."
537
+
538
+ 1. Read the output artifacts: `.planning/PROJECT.md`, `.planning/REQUIREMENTS.md`, `.planning/ROADMAP.md`, `.planning/STATE.md`
539
+ 2. Generate a brief completion summary: files compiled, contract completeness
540
+ 3. Display the summary
541
+
542
+ 4. Set stage to done in STATE.json:
543
+ ```bash
544
+ node ./bin/gswd-tools.cjs state update-stage compile done
545
+ ```
546
+
547
+ 5. Clear manual mode checkpoint (pipeline complete):
548
+ ```bash
549
+ node ./bin/gswd-tools.cjs state update-manual-checkpoint null null
550
+ ```
551
+
552
+ Proceed to Step 7.
553
+
554
+ Note: Compile is deterministic given the same inputs. No re-run prompt is needed since compile output cannot diverge from spec input.
555
+
556
+ ## Step 7 — On completion
557
+
558
+ Display the final completion summary in a consultant-toned format. Frame it as a deliverable, not a log dump.
559
+
560
+ **For both manual and auto modes, show:**
561
+
562
+ "Your GSD contract is ready. Here's what was produced for {domain}:"
563
+
564
+ **Generated Files:**
565
+
566
+ ```bash
567
+ node ./bin/gswd-tools.cjs render file-inventory
568
+ ```
569
+
570
+ Display the file inventory table produced by the command above. Only existing files are shown, so the output reflects what was actually generated.
571
+
572
+ Follow with:
573
+ - A clear "Pipeline complete" confirmation
574
+ - Suggest running `/gsd:plan-phase 01` to begin the build phase
575
+ - Suggest `/clear` for fresh context
576
+
577
+ **Next up:** `/gsd:plan-phase 01`
112
578
 
113
- Display stage banners, checkpoint boxes, and output as the CLI emits them.
579
+ **For manual mode additionally show:**
580
+ - Re-run counts per stage if any re-runs occurred (read from STATE.json `manual_mode.reruns`)
581
+ - A note that all artifacts are in `.planning/`
114
582
 
115
- ## Step 6 — On completion
583
+ ## Step 8 — On failure
116
584
 
117
- Show the Next Up block with generated artifacts and suggest running `/gsd:plan-phase 01`.
585
+ If any stage fails (not an audit FAIL in manual mode — that is handled in 6.3):
118
586
 
119
- ## Step 7 — On failure
587
+ **In manual mode:**
588
+ - Display the failure reason clearly
589
+ - Use AskUserQuestion to offer options:
590
+ - "Re-run the failed stage"
591
+ - "Stop here"
592
+ - If user chooses to re-run: loop back to the appropriate stage step
593
+ - If user chooses to stop: save state and exit gracefully
120
594
 
121
- If any stage fails (especially audit), display the failure reason and suggest remediation before retrying.
595
+ **In auto mode:**
596
+ - Display the error and exit (existing behavior, no change from v1.0)
122
597
 
123
598
  </process>