@ktpartners/dgs-platform 2.8.0 → 3.0.4

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 (94) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +41 -13
  3. package/agents/dgs-plan-checker.md +29 -3
  4. package/agents/dgs-planner.md +10 -0
  5. package/commands/dgs/abandon-quick.md +28 -0
  6. package/commands/dgs/add-tests.md +2 -2
  7. package/commands/dgs/audit-milestone.md +2 -2
  8. package/commands/dgs/capture-principle.md +11 -11
  9. package/commands/dgs/cleanup.md +2 -2
  10. package/commands/dgs/complete-milestone.md +11 -11
  11. package/commands/dgs/complete-quick.md +28 -0
  12. package/commands/dgs/create-milestone-job.md +2 -2
  13. package/commands/dgs/debug.md +3 -3
  14. package/commands/dgs/develop-idea.md +1 -1
  15. package/commands/dgs/fast.md +3 -1
  16. package/commands/dgs/health.md +1 -1
  17. package/commands/dgs/map-codebase.md +6 -6
  18. package/commands/dgs/new-milestone.md +5 -5
  19. package/commands/dgs/new-project.md +6 -6
  20. package/commands/dgs/plan-milestone-gaps.md +1 -1
  21. package/commands/dgs/progress.md +3 -3
  22. package/commands/dgs/quick-abandon.md +8 -0
  23. package/commands/dgs/quick-complete.md +8 -0
  24. package/commands/dgs/quick.md +10 -3
  25. package/commands/dgs/research-idea.md +2 -2
  26. package/commands/dgs/research-phase.md +3 -3
  27. package/commands/dgs/switch-project.md +1 -1
  28. package/commands/dgs/write-spec.md +3 -3
  29. package/deliver-great-systems/bin/dgs-tools.cjs +284 -30
  30. package/deliver-great-systems/bin/lib/commands.cjs +316 -31
  31. package/deliver-great-systems/bin/lib/commands.test.cjs +336 -0
  32. package/deliver-great-systems/bin/lib/config.cjs +39 -6
  33. package/deliver-great-systems/bin/lib/context.cjs +120 -0
  34. package/deliver-great-systems/bin/lib/core.cjs +28 -11
  35. package/deliver-great-systems/bin/lib/execution.cjs +49 -17
  36. package/deliver-great-systems/bin/lib/flat-migration.test.cjs +396 -0
  37. package/deliver-great-systems/bin/lib/ideas.cjs +206 -91
  38. package/deliver-great-systems/bin/lib/ideas.test.cjs +244 -1
  39. package/deliver-great-systems/bin/lib/init.cjs +306 -39
  40. package/deliver-great-systems/bin/lib/init.test.cjs +416 -6
  41. package/deliver-great-systems/bin/lib/jobs.cjs +124 -21
  42. package/deliver-great-systems/bin/lib/jobs.test.cjs +193 -74
  43. package/deliver-great-systems/bin/lib/migration.cjs +409 -1
  44. package/deliver-great-systems/bin/lib/migration.test.cjs +158 -1
  45. package/deliver-great-systems/bin/lib/milestone.cjs +54 -29
  46. package/deliver-great-systems/bin/lib/phase.cjs +128 -2
  47. package/deliver-great-systems/bin/lib/phase.test.cjs +420 -0
  48. package/deliver-great-systems/bin/lib/projects.cjs +28 -8
  49. package/deliver-great-systems/bin/lib/projects.test.cjs +86 -0
  50. package/deliver-great-systems/bin/lib/quick.cjs +584 -0
  51. package/deliver-great-systems/bin/lib/quick.test.cjs +596 -0
  52. package/deliver-great-systems/bin/lib/repos.cjs +25 -1
  53. package/deliver-great-systems/bin/lib/roadmap.cjs +34 -13
  54. package/deliver-great-systems/bin/lib/specs.cjs +3 -81
  55. package/deliver-great-systems/bin/lib/state-transition-gate.test.cjs +160 -0
  56. package/deliver-great-systems/bin/lib/state.cjs +142 -54
  57. package/deliver-great-systems/bin/lib/sync.cjs +75 -0
  58. package/deliver-great-systems/bin/lib/verify.cjs +80 -1
  59. package/deliver-great-systems/bin/lib/worktrees.cjs +764 -0
  60. package/deliver-great-systems/bin/lib/worktrees.test.cjs +887 -0
  61. package/deliver-great-systems/templates/claude-md.md +16 -0
  62. package/deliver-great-systems/workflows/abandon-quick.md +89 -0
  63. package/deliver-great-systems/workflows/add-idea.md +3 -3
  64. package/deliver-great-systems/workflows/add-tests.md +14 -0
  65. package/deliver-great-systems/workflows/add-todo.md +1 -0
  66. package/deliver-great-systems/workflows/approve-spec.md +25 -4
  67. package/deliver-great-systems/workflows/audit-phase.md +15 -5
  68. package/deliver-great-systems/workflows/cancel-job.md +1 -1
  69. package/deliver-great-systems/workflows/check-todos.md +2 -3
  70. package/deliver-great-systems/workflows/complete-milestone.md +197 -22
  71. package/deliver-great-systems/workflows/complete-quick.md +68 -0
  72. package/deliver-great-systems/workflows/consolidate-ideas.md +1 -1
  73. package/deliver-great-systems/workflows/create-milestone-job.md +4 -4
  74. package/deliver-great-systems/workflows/develop-idea.md +11 -11
  75. package/deliver-great-systems/workflows/diagnose-issues.md +14 -0
  76. package/deliver-great-systems/workflows/discuss-idea.md +1 -1
  77. package/deliver-great-systems/workflows/execute-phase.md +121 -32
  78. package/deliver-great-systems/workflows/execute-plan.md +12 -21
  79. package/deliver-great-systems/workflows/help.md +33 -29
  80. package/deliver-great-systems/workflows/init-product.md +2 -18
  81. package/deliver-great-systems/workflows/new-milestone.md +40 -24
  82. package/deliver-great-systems/workflows/new-project.md +22 -680
  83. package/deliver-great-systems/workflows/progress-all.md +133 -0
  84. package/deliver-great-systems/workflows/quick-abandon.md +89 -0
  85. package/deliver-great-systems/workflows/quick-complete.md +68 -0
  86. package/deliver-great-systems/workflows/quick.md +152 -23
  87. package/deliver-great-systems/workflows/refine-spec.md +1 -1
  88. package/deliver-great-systems/workflows/research-idea.md +8 -8
  89. package/deliver-great-systems/workflows/resume-project.md +2 -2
  90. package/deliver-great-systems/workflows/run-job.md +8 -8
  91. package/deliver-great-systems/workflows/validate-phase.md +39 -1
  92. package/deliver-great-systems/workflows/verify-work.md +14 -0
  93. package/deliver-great-systems/workflows/write-spec.md +2 -2
  94. package/package.json +1 -1
@@ -24,7 +24,7 @@ Use `TIER_FILES` JSON `files` array for project context (PROJECT.md, STATE.md, c
24
24
  Parse `$ARGUMENTS` to extract version and flags.
25
25
 
26
26
  - **Version:** First non-flag argument (e.g., `v6`, `v6.0`). If omitted, auto-detection happens in the preview step.
27
- - **--no-check flag:** If present, omit audit-milestone and complete-milestone steps from the generated job.
27
+ - **--no-check flag:** If present, omit the audit-milestone step from the generated job.
28
28
 
29
29
  ```bash
30
30
  # Pseudocode for argument parsing:
@@ -97,7 +97,7 @@ Present in this format:
97
97
  5. execute-phase 52
98
98
  6. verify-work 52
99
99
  ...
100
- N. complete-milestone v6.0
100
+ N. audit-milestone v6.0
101
101
 
102
102
  Create this job? (yes/no)
103
103
  ```
@@ -123,13 +123,13 @@ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs create-milestone VER
123
123
  2. Commit the job file:
124
124
 
125
125
  ```bash
126
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs(50): create milestone job {version}" --files jobs/pending/milestone-{version}.md
126
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs(50): create milestone job {version}" --files jobs/milestone-{version}.md
127
127
  ```
128
128
 
129
129
  3. Display success and next steps:
130
130
 
131
131
  ```
132
- Job created: jobs/pending/milestone-{version}.md
132
+ Job created: jobs/milestone-{version}.md
133
133
 
134
134
  ---
135
135
 
@@ -89,7 +89,7 @@ Also check for prior research document:
89
89
  ```bash
90
90
  # Derive slug from filename (strip id prefix and .md suffix)
91
91
  SLUG=$(echo "${filename}" | sed 's/^[0-9]*-//' | sed 's/\.md$//')
92
- RESEARCH_DOC="${project_root}/docs/ideas/pending/${SLUG}-research.md"
92
+ RESEARCH_DOC="${project_root}/docs/ideas/${SLUG}-research.md"
93
93
  ```
94
94
  If the research document file exists, read it for prior research context.
95
95
 
@@ -281,7 +281,7 @@ Per CONTEXT.md: idea body is NOT updated on partial save.
281
281
  <step name="discussion_commit">
282
282
  Commit the updated idea file immediately after discussion:
283
283
  ```bash
284
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs: discuss idea #${id} — ${title}" --files ${project_root}/ideas/${state}/${filename}
284
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs: discuss idea #${id} — ${title}" --files ${project_root}/ideas/${filename}
285
285
  ```
286
286
 
287
287
  **If `partial = true`** (user exited mid-discussion):
@@ -392,10 +392,10 @@ Create (or overwrite) the research document.
392
392
 
393
393
  Ensure directory exists:
394
394
  ```bash
395
- mkdir -p ${project_root}/docs/ideas/pending
395
+ mkdir -p ${project_root}/docs/ideas
396
396
  ```
397
397
 
398
- Write the research document to `${project_root}/docs/ideas/pending/${SLUG}-research.md` using the Write tool.
398
+ Write the research document to `${project_root}/docs/ideas/${SLUG}-research.md` using the Write tool.
399
399
 
400
400
  Document structure:
401
401
  ```markdown
@@ -456,7 +456,7 @@ Build the entry JSON:
456
456
  "summary": "{Actionable summary paragraph}",
457
457
  "keyFindings": "- {finding 1}\n- {finding 2}\n- {finding 3}",
458
458
  "recommendation": "{Strong recommendation or neutral options presentation}",
459
- "documentLink": "${project_root}/docs/ideas/pending/${SLUG}-research.md",
459
+ "documentLink": "${project_root}/docs/ideas/${SLUG}-research.md",
460
460
  "outcome": "{Recommended next step: 'Ready for spec', 'Needs more discussion', 'Not feasible', etc.}"
461
461
  }
462
462
  ```
@@ -472,7 +472,7 @@ Parse the JSON result to confirm success.
472
472
  <step name="research_commit">
473
473
  Commit both the research document and the updated idea file:
474
474
  ```bash
475
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs: research idea #${id} -- ${title}" --files ${project_root}/docs/ideas/pending/${SLUG}-research.md ${project_root}/ideas/${state}/${filename}
475
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs: research idea #${id} -- ${title}" --files ${project_root}/docs/ideas/${SLUG}-research.md ${project_root}/ideas/${filename}
476
476
  ```
477
477
  </step>
478
478
 
@@ -490,8 +490,8 @@ Research: ${recommendation}
490
490
  Next step: ${contextAwareNextStep}
491
491
 
492
492
  Files:
493
- - ${project_root}/ideas/${state}/${filename}
494
- - ${project_root}/docs/ideas/pending/${SLUG}-research.md
493
+ - ${project_root}/ideas/${filename}
494
+ - ${project_root}/docs/ideas/${SLUG}-research.md
495
495
  ```
496
496
 
497
497
  **If only discussion ran** (research skipped by decision routing, user choice, or partial exit):
@@ -503,7 +503,7 @@ Decision: ${decision}
503
503
  Next step: ${contextAwareNextStep}
504
504
 
505
505
  Files:
506
- - ${project_root}/ideas/${state}/${filename}
506
+ - ${project_root}/ideas/${filename}
507
507
  ```
508
508
 
509
509
  **If only research ran** (user chose "Just research" in assess_history):
@@ -516,8 +516,8 @@ Research: ${recommendation}
516
516
  Next step: ${contextAwareNextStep}
517
517
 
518
518
  Files:
519
- - ${project_root}/ideas/${state}/${filename}
520
- - ${project_root}/docs/ideas/pending/${SLUG}-research.md
519
+ - ${project_root}/ideas/${filename}
520
+ - ${project_root}/docs/ideas/${SLUG}-research.md
521
521
  ```
522
522
 
523
523
  **Context-aware next step logic:**
@@ -33,6 +33,20 @@ TIER_FILES=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" contex
33
33
  ```
34
34
 
35
35
  Store the file list for passing to debug sub-agents in `<files_to_read>` blocks.
36
+
37
+ **Worktree-aware code directory resolution (resolveCodeContext):**
38
+
39
+ For each registered code repo, resolve the correct working directory. When a milestone or quick worktree is active, debug investigation must target the worktree directory, not the main checkout, so the debugger examines the correct code and can reproduce issues in the right context.
40
+
41
+ ```javascript
42
+ // In the agent's execution context, use resolveCodeContext to determine the code directory:
43
+ const { resolveCodeContext } = require('./bin/lib/context.cjs');
44
+ const ctx = resolveCodeContext(planningRoot, repoName);
45
+ // ctx.type: 'main' | 'milestone' | 'quick'
46
+ // ctx.directory: absolute path to the correct working directory
47
+ ```
48
+
49
+ Pass `ctx.directory` to debug sub-agents so they investigate code in the correct location.
36
50
  </step>
37
51
 
38
52
  <step name="parse_gaps">
@@ -86,7 +86,7 @@ IDEA_DOCS_DIR="${IDEA_DIR}/docs"
86
86
  If a flat structure is used (ideas stored as files, not directories), derive from the filename:
87
87
  ```bash
88
88
  IDEA_SLUG=$(echo "${filename}" | sed 's/^[0-9]*-//' | sed 's/\.md$//')
89
- IDEA_DOCS_DIR="$(dirname "$(dirname "${path}")")/docs/ideas/pending/${IDEA_SLUG}"
89
+ IDEA_DOCS_DIR="$(dirname "$(dirname "${path}")")/docs/ideas/${IDEA_SLUG}"
90
90
  ```
91
91
 
92
92
  Check both paths. Use whichever exists.
@@ -9,7 +9,7 @@ Orchestrator coordinates, not executes. Each subagent loads the full execute-pla
9
9
  </core_principle>
10
10
 
11
11
  <hard_boundary>
12
- **CRITICAL SCOPE CONSTRAINT:** You execute ONLY the single phase specified in $ARGUMENTS. After that phase completes (plans executed, verification done, roadmap updated), you MUST STOP. Do NOT read the roadmap to discover subsequent phases. Do NOT execute transition.md unless `--auto` flag is present. Do NOT advance to phase N+1. Violating this boundary causes duplicate work and corrupts job state.
12
+ **CRITICAL SCOPE CONSTRAINT:** You execute ONLY the single phase specified in $ARGUMENTS. After that phase finishes (plans executed, verification done, roadmap updated), you MUST STOP. Do NOT read the roadmap to discover subsequent phases. Do NOT execute transition.md unless `--auto` flag is present. Do NOT advance to phase N+1. Violating this boundary causes duplicate work and corrupts job state.
13
13
  </hard_boundary>
14
14
 
15
15
  <required_reading>
@@ -27,7 +27,7 @@ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" init execute
27
27
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
28
28
  ```
29
29
 
30
- Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `base_branch`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `author`, `phase_req_ids`, `sync_push`, `sync_pull`, `cadence_push`, `cadence_pull`.
30
+ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `base_branch`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `author`, `phase_req_ids`, `sync_push`, `sync_pull`, `cadence_push`, `cadence_pull`, `milestone_slug`, `milestone_version`, `milestone_name`.
31
31
 
32
32
  **Load execution tier context:**
33
33
 
@@ -119,34 +119,122 @@ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" sync workflow-pull
119
119
  - If No: skip pull, continue
120
120
  </step>
121
121
 
122
- <step name="handle_branching">
123
- Check `branching_strategy` from init:
122
+ <step name="handle_worktree">
123
+ Check if this phase is part of a milestone with code repos registered in REPOS.md.
124
124
 
125
- **"none":** Skip, continue on current branch.
125
+ **If no REPOS.md or no code repos:** Skip worktree creation entirely. Log: `No code repos registered — skipping worktree setup.` Continue to validate_phase.
126
+
127
+ **If REPOS.md has code repos and `milestone_slug` is present:**
128
+
129
+ Use `milestone_slug` from init JSON (already sanitized).
130
+
131
+ **1. Check for existing worktree:**
126
132
 
127
- **"phase" or "milestone":** Use pre-computed `branch_name` from init for the product folder:
128
133
  ```bash
129
- git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
134
+ WORKTREE_LIST=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" worktrees list 2>/dev/null)
130
135
  ```
131
136
 
132
- All subsequent commits go to this branch. User handles merging.
137
+ Parse the JSON array. Look for an entry matching `milestone_slug`.
133
138
 
134
- **Code repo branching (base_branch):**
139
+ **If worktree exists with `setup_complete: true` for all repos:**
140
+ ```
141
+ Using existing milestone worktree for ${MILESTONE_SLUG}
142
+ ```
143
+ Skip to step 3 (set active_context).
135
144
 
136
- The product folder's own branch is always created from the current HEAD (typically `main`). The `base_branch` from init JSON applies only to code repos registered in REPOS.md.
145
+ **If worktree exists but `setup_complete: false` for any repo:**
146
+ ```
147
+ ╔══════════════════════════════════════════════════════════════╗
148
+ ║ ERROR ║
149
+ ╚══════════════════════════════════════════════════════════════╝
137
150
 
138
- When branching is enabled and REPOS.md lists code repos, `createRepoBranches` (via `dgs-tools.cjs`) uses `base_branch` to:
139
- 1. Pre-check all code repos upfront — verify the base branch exists in every registered repo before creating any branches
140
- 2. Fetch the base branch from remote in each repo (`git fetch origin "$BASE_BRANCH"`)
141
- 3. Create feature branches from the base branch (`git checkout "$BASE_BRANCH" && git checkout -b "$BRANCH_NAME"`)
151
+ Worktree setup incomplete for milestone '${MILESTONE_SLUG}'.
152
+ Repo(s) with failed setup need manual intervention.
142
153
 
143
- If the base branch does not exist in any code repo, the operation fails with a clear error before any branches are created:
154
+ **To fix:** dgs-tools worktrees setup ${MILESTONE_SLUG}
155
+ Then re-run: /dgs:execute-phase ${PHASE}
144
156
  ```
145
- Error: Base branch '{base_branch}' does not exist in repo '{repo_name}'.
146
- Create the branch or update git.base_branch in config.
157
+ **STOP.** Do not proceed with phase execution.
158
+
159
+ **If no worktree exists:**
160
+
161
+ **2. Create milestone worktree:**
162
+
163
+ ```bash
164
+ CREATE_RESULT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" worktrees create "${MILESTONE_SLUG}" --type milestone)
147
165
  ```
148
166
 
149
- The `base_branch` value is passed from init JSON to `createRepoBranches` automatically — the two-pass validation (verify all repos, then create all branches) is handled by the library function (see Plan 01, Task 3).
167
+ Parse JSON output. Check each repo:
168
+ - If all repos have `setup_complete: true` (or no setup command): continue.
169
+ - If any repo has `setup_complete: false`:
170
+
171
+ ```
172
+ ╔══════════════════════════════════════════════════════════════╗
173
+ ║ ERROR ║
174
+ ╚══════════════════════════════════════════════════════════════╝
175
+
176
+ Setup failed for one or more repos during worktree creation.
177
+ Phase cannot start until setup succeeds.
178
+
179
+ **To fix:** dgs-tools worktrees setup ${MILESTONE_SLUG}
180
+ Then re-run: /dgs:execute-phase ${PHASE}
181
+ ```
182
+ **STOP.** Do not proceed.
183
+
184
+ Note: The worktree directory and branch are kept (not removed) so the user can fix and re-run setup.
185
+
186
+ **3. Set active_context and capture worktree repos:**
187
+
188
+ ```bash
189
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-local-set execution.active_context "${MILESTONE_SLUG}"
190
+ ```
191
+
192
+ Read the worktree repos map from config.local.json so it can be passed to executor agents:
193
+
194
+ ```bash
195
+ WORKTREE_REPOS=$(node -e "
196
+ const fs = require('fs');
197
+ const cfg = JSON.parse(fs.readFileSync('config.local.json', 'utf-8'));
198
+ const project = cfg.current_project;
199
+ const repos = (cfg.projects && cfg.projects[project] && cfg.projects[project].worktrees && cfg.projects[project].worktrees['${MILESTONE_SLUG}'] && cfg.projects[project].worktrees['${MILESTONE_SLUG}'].repos) || {};
200
+ process.stdout.write(JSON.stringify(repos));
201
+ ")
202
+ ```
203
+
204
+ Store `$WORKTREE_REPOS` (JSON object mapping repoName -> worktreePath) for use in executor prompts.
205
+
206
+ **4. Verify worktree health:**
207
+
208
+ For each code repo registered in REPOS.md, verify the worktree is healthy:
209
+
210
+ ```bash
211
+ HEALTH=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" worktrees health "${MILESTONE_SLUG}" 2>/dev/null || echo '{"healthy":true,"issues":[]}')
212
+ ```
213
+
214
+ If the `worktrees health` subcommand is not available, perform inline checks:
215
+
216
+ For each repo in the worktree:
217
+ ```bash
218
+ # Check branch
219
+ BRANCH=$(git -C "${WORKTREE_PATH}" rev-parse --abbrev-ref HEAD 2>/dev/null)
220
+ # Check clean state
221
+ STATUS=$(git -C "${WORKTREE_PATH}" status --porcelain 2>/dev/null)
222
+ ```
223
+
224
+ If branch is wrong or uncommitted changes exist, **warn** but continue (quick sanity check, not a full health audit):
225
+ ```
226
+ ⚠ Worktree health warning for ${REPO_NAME}:
227
+ - Expected branch: milestone/${MILESTONE_SLUG}, actual: ${BRANCH}
228
+ - Has uncommitted changes
229
+ Continuing anyway — review worktree state after execution.
230
+ ```
231
+
232
+ **5. Do NOT clear active_context after phase completion.**
233
+
234
+ The milestone worktree persists across all phases within the milestone until `complete-milestone` is run. active_context is NOT cleared in the post-execution steps of this workflow.
235
+
236
+ **Note on backward compatibility:**
237
+ The old `branching_strategy` check and `createRepoBranches` code path is removed. If `branching_strategy` is set to "phase" or "milestone" in an older config, the worktree path runs instead.
150
238
  </step>
151
239
 
152
240
  <step name="validate_phase">
@@ -217,6 +305,13 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
217
305
  Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
218
306
  </objective>
219
307
 
308
+ ${WORKTREE_REPOS && WORKTREE_REPOS !== '{}' ? `
309
+ <worktree_context>
310
+ This phase is executing in a git worktree. Work in these directories — do NOT use the main checkout paths:
311
+ ${Object.entries(JSON.parse(WORKTREE_REPOS)).map(([name, dir]) => '- ' + name + ': ' + dir).join('\n ')}
312
+ </worktree_context>
313
+ ` : ''}
314
+
220
315
  <execution_context>
221
316
  @~/.claude/deliver-great-systems/workflows/execute-plan.md
222
317
  @~/.claude/deliver-great-systems/templates/summary.md
@@ -292,11 +387,7 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
292
387
 
293
388
  If `CODEREVIEW` is not `true`: skip silently, proceed to next step.
294
389
 
295
- **If `NON_INTERACTIVE` is true:**
296
- Log: `[AUTO-RESOLVE] Code review enabled but skipping in non-interactive mode (codereview requires interactive Task spawning)`
297
- Skip codereview, proceed to next step.
298
-
299
- **If `NON_INTERACTIVE` is false (interactive mode) AND `CODEREVIEW` is `true`:**
390
+ The codereview workflow is non-interactive by design — it auto-fixes low-risk issues and logs CRITICAL/HIGH findings as deviations to SUMMARY.md rather than prompting. It runs in both interactive and job modes.
300
391
 
301
392
  For each plan that completed successfully in this wave:
302
393
 
@@ -570,10 +661,10 @@ Gap closure cycle: `/dgs:plan-phase {X} --gaps` reads VERIFICATION.md → create
570
661
  </step>
571
662
 
572
663
  <step name="update_roadmap">
573
- **Mark phase complete and update all tracking files:**
664
+ **Mark phase done, commit tracking files, and push all atomically:**
574
665
 
575
666
  ```bash
576
- COMPLETION=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" phase complete "${PHASE_NUMBER}")
667
+ FINALIZE=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" phase finalize "${PHASE_NUMBER}" --push)
577
668
  ```
578
669
 
579
670
  The CLI handles:
@@ -582,14 +673,12 @@ The CLI handles:
582
673
  - Updating plan count to final
583
674
  - Advancing STATE.md to next phase
584
675
  - Updating REQUIREMENTS.md traceability
676
+ - **Committing** ROADMAP.md, STATE.md, REQUIREMENTS.md, and `${phase_dir}/*-VERIFICATION.md` in a single atomic commit
677
+ - Pushing (if sync_push=auto) in the same call
585
678
 
586
- Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`.
587
-
588
- ```bash
589
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(phase-{X}): complete phase execution" --push --files ${roadmap_path} ${state_path} ${requirements_path} ${phase_dir}/*-VERIFICATION.md
590
- ```
679
+ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`, `committed`, `hash`, `pushed`.
591
680
 
592
- Parse the commit result JSON. If `needs_push` is true (sync_push is "prompt" mode), handle push prompting via the existing sync_after step. If `pushed` is true, the push already happened atomically with the commit -- skip the sync_after push for this commit (avoid double-push). If `pushed` is false and `push_result` exists, log the push warning but do not halt.
681
+ Parse the result JSON. If `needs_push` is true (sync_push is "prompt" mode), handle push prompting via the existing sync_after step. If `pushed` is true, the push already happened atomically with the commit skip the sync_after push for this commit (avoid double-push). If `pushed` is false and `push_result` exists, log the push warning but do not halt.
593
682
  </step>
594
683
 
595
684
  <step name="sync_after">
@@ -683,7 +772,7 @@ Read and follow `~/.claude/deliver-great-systems/workflows/transition.md`, passi
683
772
 
684
773
  **HARD STOP.** The workflow ends here. Do NOT read transition.md. Do NOT read ROADMAP.md. Do NOT execute any additional phases.
685
774
 
686
- **Use ONLY the `is_last_phase`, `next_phase`, and `next_phase_name` values from the `phase complete` result in the update_roadmap step.** Do NOT read the roadmap or any other file to determine remaining phases — the CLI already computed this.
775
+ **Use ONLY the `is_last_phase`, `next_phase`, and `next_phase_name` values from the `phase finalize` result in the update_roadmap step.** Do NOT read the roadmap or any other file to determine remaining phases — the CLI already computed this.
687
776
 
688
777
  If `is_last_phase` is `false`:
689
778
  ```
@@ -452,25 +452,10 @@ Keep STATE.md under 150 lines.
452
452
  If SUMMARY "Issues Encountered" ≠ "None": yolo → log and continue. Interactive → present issues, wait for acknowledgment.
453
453
  </step>
454
454
 
455
- <step name="update_roadmap">
456
- ```bash
457
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" roadmap update-plan-progress "${PHASE}"
458
- ```
459
- Counts PLAN vs SUMMARY files on disk. Updates progress table row with correct count and status (`In Progress` or `Complete` with date).
460
- </step>
461
-
462
- <step name="update_requirements">
463
- Mark completed requirements from the PLAN.md frontmatter `requirements:` field:
464
-
465
- ```bash
466
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" requirements mark-complete ${REQ_IDS}
467
- ```
468
-
469
- Extract requirement IDs from the plan's frontmatter (e.g., `requirements: [AUTH-01, AUTH-02]`). If no requirements field, skip.
470
- </step>
455
+ <step name="finalize_plan">
456
+ **Update state/roadmap/requirements and commit plan metadata atomically.**
471
457
 
472
- <step name="git_commit_metadata">
473
- **Multi-repo guard:** If any task used `commit --multi-repo` and returned `success: false`, display a warning before committing planning metadata:
458
+ **Multi-repo guard:** If any task used `commit --multi-repo` and returned `success: false`, display a warning before finalizing:
474
459
 
475
460
  ```
476
461
  Warning: Some repo commits failed. Planning metadata will still be committed to track partial progress.
@@ -479,11 +464,17 @@ Check SUMMARY.md status field for per-repo details.
479
464
 
480
465
  The planning metadata commit proceeds regardless (to track partial progress), but the warning ensures visibility. The SUMMARY.md `status: partial` field records which repos failed.
481
466
 
482
- Task code already committed per-task. Commit plan metadata:
483
-
484
467
  ```bash
485
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs({phase}-{plan}): complete [plan-name] plan" --files ${phase_dir}/{phase}-{plan}-SUMMARY.md ${state_path} ${roadmap_path} ${requirements_path}
468
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" plan finalize "${PHASE}" "${PLAN}"
486
469
  ```
470
+
471
+ The CLI handles (in one atomic call):
472
+ - `roadmap update-plan-progress` (progress table, status, date, checkbox)
473
+ - `requirements mark-complete` (from PLAN.md `requirements:` frontmatter — auto-extracted)
474
+ - `state update-progress` (global progress bar, idempotent with `record_metrics`)
475
+ - Commits `{phase}-{plan}-PLAN.md`, `{phase}-{plan}-SUMMARY.md`, `STATE.md`, `ROADMAP.md`, `REQUIREMENTS.md` with message `docs({phase}-{plan}): complete {plan-name} plan`
476
+
477
+ The plan name is auto-extracted from the PLAN.md `plan_name` frontmatter field (fallback: "execution"). To override, add `--plan-name "<name>"` to the call.
487
478
  </step>
488
479
 
489
480
  <step name="update_codebase_map">
@@ -12,15 +12,17 @@ Display the complete DGS command reference. Output ONLY the reference content. D
12
12
  ## Quick Start
13
13
 
14
14
  **Single-project (v1):**
15
- 1. `/dgs:new-project` - Initialize project (includes research, requirements, roadmap)
16
- 2. `/dgs:plan-phase 1` - Create detailed plan for first phase
17
- 3. `/dgs:execute-phase 1` - Execute the phase
15
+ 1. `/dgs:new-project` - Create project (questioning + PROJECT.md)
16
+ 2. `/dgs:new-milestone` - First milestone (research, requirements, roadmap)
17
+ 3. `/dgs:plan-phase 1` - Create detailed plan for first phase
18
+ 4. `/dgs:execute-phase 1` - Execute the phase
18
19
 
19
20
  **Multi-project / multi-repo (v2):**
20
21
  1. `/dgs:init-product` - Set up product folder and register repos
21
- 2. `/dgs:new-project` - Create a project (prompts for name and repos)
22
- 3. `/dgs:plan-phase 1` - Plan first phase (repos tracked per task)
23
- 4. `/dgs:execute-phase 1` - Execute (commits per-repo automatically)
22
+ 2. `/dgs:new-project` - Create a project (questioning + PROJECT.md)
23
+ 3. `/dgs:new-milestone` - First milestone (research, requirements, roadmap)
24
+ 4. `/dgs:plan-phase 1` - Plan first phase (repos tracked per task)
25
+ 5. `/dgs:execute-phase 1` - Execute (commits per-repo automatically)
24
26
 
25
27
  ## Project Structure
26
28
 
@@ -54,7 +56,7 @@ Each command loads a specific tier of project context. Higher tiers include all
54
56
  ## Core Workflow
55
57
 
56
58
  ```
57
- /dgs:new-project → /dgs:plan-phase → /dgs:execute-phase → repeat
59
+ /dgs:new-project → /dgs:new-milestone → /dgs:plan-phase → /dgs:execute-phase → repeat
58
60
  ```
59
61
 
60
62
  ### Product Setup (v2)
@@ -72,23 +74,19 @@ Usage: `/dgs:init-product`
72
74
  ### Project Initialization
73
75
 
74
76
  **`/dgs:new-project`**
75
- Initialize new project through unified flow. *(Tier 2: planning)*
77
+ Initialize new project through deep questioning. *(Tier 2: planning)*
76
78
 
77
- One command takes you from idea to ready-for-planning:
79
+ One command takes you from idea to project identity:
78
80
  - Deep questioning to understand what you're building
79
- - Optional domain research (spawns 4 parallel researcher agents)
80
- - Requirements definition with v1/v2/out-of-scope scoping
81
- - Roadmap creation with phase breakdown and success criteria
81
+ - Optional brownfield mapping for existing codebases
82
+ - PROJECT.md creation with vision, requirements hypotheses, and key decisions
82
83
 
83
84
  Creates project artifacts:
84
85
  - `PROJECT.md` — vision and requirements
85
- - `config.json` — workflow mode (interactive/yolo)
86
- - `research/` — domain research (if selected)
87
- - `REQUIREMENTS.md` — scoped requirements with REQ-IDs
88
- - `ROADMAP.md` — phases mapped to requirements
89
- - `STATE.md` — project memory
90
86
 
91
- **v2 additions:** Prompts for project name (used as folder slug), prompts for which repos this project touches (from REPOS.md), checks for overlap with other active projects. Artifacts are created under `projects/<project-slug>/`.
87
+ **v2 additions:** Prompts for project name (used as folder slug), prompts for which repos this project touches (from REPOS.md). Artifacts are created under `projects/<project-slug>/`.
88
+
89
+ After completion, run `/dgs:new-milestone` to start your first milestone.
92
90
 
93
91
  Usage: `/dgs:new-project`
94
92
 
@@ -186,7 +184,7 @@ Show which repos are touched by multiple active projects. *(Tier 1: lite)*
186
184
 
187
185
  - Scans plan files across all active projects for repo references
188
186
  - Highlights specific file-level overlaps
189
- - Runs automatically during `/dgs:new-project` and `/dgs:new-milestone`
187
+ - Runs automatically during `/dgs:new-milestone`
190
188
 
191
189
  Usage: `/dgs:overlap-check`
192
190
 
@@ -307,14 +305,14 @@ Result: Phase 17 deleted, phases 18-20 become 17-19
307
305
  ### Milestone Management
308
306
 
309
307
  **`/dgs:new-milestone <name>`**
310
- Start a new milestone through unified flow. *(Tier 2: planning)*
308
+ Start a new milestone (or the first milestone after `/dgs:new-project`). *(Tier 2: planning)*
311
309
 
312
- - Deep questioning to understand what you're building next
310
+ - Gathers milestone goals (interactive or from spec via --auto)
313
311
  - Optional domain research (spawns 4 parallel researcher agents)
314
312
  - Requirements definition with scoping
315
313
  - Roadmap creation with phase breakdown
316
314
 
317
- Mirrors `/dgs:new-project` flow for brownfield projects (existing PROJECT.md).
315
+ Handles both first milestones (creates STATE.md, defaults to v1.0) and subsequent milestones (continues from MILESTONES.md).
318
316
 
319
317
  Usage: `/dgs:new-milestone "v2.0 Features"`
320
318
 
@@ -386,7 +384,7 @@ Usage: `/dgs:debug` (resume active session)
386
384
  Capture idea or task as todo from current conversation. *(Tier 1: lite)*
387
385
 
388
386
  - Extracts context from conversation (or uses provided description)
389
- - Creates structured todo file in the project's todos/pending/ directory
387
+ - Creates structured todo file in the project's todos/ directory
390
388
  - Infers area from file paths for grouping
391
389
  - Checks for duplicates before creating
392
390
  - Updates STATE.md todo count
@@ -408,7 +406,7 @@ Usage: `/dgs:check-todos api`
408
406
 
409
407
  ### Ideas & Specs
410
408
 
411
- `capture ideas → develop idea → write spec → new-project --auto`
409
+ `capture ideas → develop idea → write spec → new-project --auto → new-milestone --auto`
412
410
 
413
411
  #### Ideas
414
412
 
@@ -470,7 +468,7 @@ Usage: `/dgs:discuss-idea` (shows picker)
470
468
  Research an idea's feasibility and technical landscape. *(Tier 2: planning)*
471
469
 
472
470
  - Five dimensions: web search, codebase analysis, landscape survey, approaches, feasibility
473
- - Creates research document at `docs/ideas/pending/{slug}-research.md` (relative to planning root)
471
+ - Creates research document at `docs/ideas/{slug}-research.md` (relative to planning root)
474
472
  - Appends Research Log to idea file (Summary, Document link, Key Finding, Recommendation)
475
473
  - Can run multiple times; each run appends a new entry
476
474
 
@@ -812,7 +810,7 @@ my-product/ # Product folder (git repo)
812
810
 
813
811
  ## Workflow Modes
814
812
 
815
- Set during `/dgs:new-project`:
813
+ Set during `/dgs:init-product`:
816
814
 
817
815
  **Interactive Mode**
818
816
 
@@ -868,7 +866,9 @@ Example config:
868
866
  **Starting a new project (v1):**
869
867
 
870
868
  ```
871
- /dgs:new-project # Unified flow: questioning -> research -> requirements -> roadmap
869
+ /dgs:new-project # Questioning -> PROJECT.md
870
+ /clear
871
+ /dgs:new-milestone # Research -> requirements -> roadmap
872
872
  /clear
873
873
  /dgs:plan-phase 1 # Create plans for first phase
874
874
  /clear
@@ -879,7 +879,9 @@ Example config:
879
879
 
880
880
  ```
881
881
  /dgs:init-product # One-time: register repos, create product structure
882
- /dgs:new-project # Create project (picks name, selects repos)
882
+ /dgs:new-project # Questioning -> PROJECT.md
883
+ /clear
884
+ /dgs:new-milestone # Research -> requirements -> roadmap
883
885
  /clear
884
886
  /dgs:plan-phase 1 # Plan with per-repo task tracking
885
887
  /clear
@@ -942,7 +944,9 @@ Example config:
942
944
  # /dgs:research-idea # Investigate feasibility
943
945
  /dgs:write-spec # Turn ideas into structured spec
944
946
  /clear
945
- /dgs:new-project --auto @spec.md # Create project directly from spec
947
+ /dgs:new-project --auto @spec.md # Create project from spec
948
+ /clear
949
+ /dgs:new-milestone --auto <spec-id> # First milestone from spec
946
950
  ```
947
951
 
948
952
  **Debugging an issue:**
@@ -206,16 +206,6 @@ AskUserQuestion([
206
206
  { label: "Yes (Recommended)", description: "Planning docs tracked in version control" },
207
207
  { label: "No", description: "Keep planning docs local-only (add to .gitignore)" }
208
208
  ]
209
- },
210
- {
211
- header: "Branching",
212
- question: "Git branching strategy?",
213
- multiSelect: false,
214
- options: [
215
- { label: "None (Recommended)", description: "Commit to current branch (fine for single projects)" },
216
- { label: "Per Phase", description: "Branch per phase, review before merging" },
217
- { label: "Per Milestone", description: "Branch per project, merge all at end (for parallel projects)" }
218
- ]
219
209
  }
220
210
  ])
221
211
  ```
@@ -282,10 +272,9 @@ AskUserQuestion([
282
272
  "discipline": true|false
283
273
  },
284
274
  "git": {
285
- "branching_strategy": "none|phase|milestone",
286
275
  "base_branch": "[from earlier question]",
287
- "sync_push": "prompt",
288
- "sync_pull": "prompt"
276
+ "sync_push": "auto",
277
+ "sync_pull": "auto"
289
278
  }
290
279
  }
291
280
  ```
@@ -300,11 +289,6 @@ Smart defaults (not asked): `parallelization: true`, `auto_advance: false`, `nyq
300
289
  node /Users/adrian/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "chore: add product config" --files ${config_path}
301
290
  ```
302
291
 
303
- **Branch name preview:** If `branching_strategy` is not `"none"`, show:
304
- ```
305
- Branch names will look like: dgs/{project-slug}/phase-03-auth
306
- ```
307
-
308
292
  **b7. Commit initialized files:**
309
293
 
310
294
  Use the `files_created` array from the init response to build the commit file list: