@ktpartners/dgs-platform 2.6.2

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 (256) hide show
  1. package/LICENSE +38 -0
  2. package/README.md +851 -0
  3. package/agents/dgs-codebase-cross-analyzer.md +183 -0
  4. package/agents/dgs-codebase-mapper.md +782 -0
  5. package/agents/dgs-codebase-synthesizer.md +156 -0
  6. package/agents/dgs-debugger.md +1256 -0
  7. package/agents/dgs-executor.md +550 -0
  8. package/agents/dgs-integration-checker.md +481 -0
  9. package/agents/dgs-nyquist-auditor.md +178 -0
  10. package/agents/dgs-phase-researcher.md +563 -0
  11. package/agents/dgs-phase-verifier.md +450 -0
  12. package/agents/dgs-plan-checker.md +708 -0
  13. package/agents/dgs-planner.md +1324 -0
  14. package/agents/dgs-project-researcher.md +631 -0
  15. package/agents/dgs-research-synthesizer.md +249 -0
  16. package/agents/dgs-roadmapper.md +652 -0
  17. package/agents/dgs-verifier.md +607 -0
  18. package/bin/install.js +2073 -0
  19. package/commands/dgs/add-doc.md +45 -0
  20. package/commands/dgs/add-idea.md +38 -0
  21. package/commands/dgs/add-phase.md +43 -0
  22. package/commands/dgs/add-repo.md +54 -0
  23. package/commands/dgs/add-tests.md +41 -0
  24. package/commands/dgs/add-todo.md +47 -0
  25. package/commands/dgs/approve-spec.md +38 -0
  26. package/commands/dgs/audit-milestone.md +36 -0
  27. package/commands/dgs/audit-phase.md +37 -0
  28. package/commands/dgs/cancel-job.md +23 -0
  29. package/commands/dgs/capture-principle.md +143 -0
  30. package/commands/dgs/check-todos.md +45 -0
  31. package/commands/dgs/cleanup.md +18 -0
  32. package/commands/dgs/complete-milestone.md +136 -0
  33. package/commands/dgs/complete-project.md +70 -0
  34. package/commands/dgs/consolidate-ideas.md +50 -0
  35. package/commands/dgs/create-milestone-job.md +37 -0
  36. package/commands/dgs/debug.md +164 -0
  37. package/commands/dgs/develop-idea.md +53 -0
  38. package/commands/dgs/discuss-idea.md +41 -0
  39. package/commands/dgs/discuss-phase.md +83 -0
  40. package/commands/dgs/execute-phase.md +41 -0
  41. package/commands/dgs/fast.md +38 -0
  42. package/commands/dgs/find-related-ideas.md +43 -0
  43. package/commands/dgs/health.md +28 -0
  44. package/commands/dgs/help.md +22 -0
  45. package/commands/dgs/import-spec.md +36 -0
  46. package/commands/dgs/init-product.md +28 -0
  47. package/commands/dgs/insert-phase.md +32 -0
  48. package/commands/dgs/join-discord.md +18 -0
  49. package/commands/dgs/list-docs.md +40 -0
  50. package/commands/dgs/list-ideas.md +42 -0
  51. package/commands/dgs/list-jobs.md +22 -0
  52. package/commands/dgs/list-phase-assumptions.md +46 -0
  53. package/commands/dgs/list-projects.md +57 -0
  54. package/commands/dgs/list-specs.md +40 -0
  55. package/commands/dgs/map-codebase.md +92 -0
  56. package/commands/dgs/new-milestone.md +44 -0
  57. package/commands/dgs/new-project.md +42 -0
  58. package/commands/dgs/node-repair.md +26 -0
  59. package/commands/dgs/overlap-check.md +20 -0
  60. package/commands/dgs/pause-work.md +38 -0
  61. package/commands/dgs/plan-milestone-gaps.md +34 -0
  62. package/commands/dgs/plan-phase.md +44 -0
  63. package/commands/dgs/progress.md +24 -0
  64. package/commands/dgs/quick.md +41 -0
  65. package/commands/dgs/reactivate-project.md +70 -0
  66. package/commands/dgs/reapply-patches.md +110 -0
  67. package/commands/dgs/refine-spec.md +38 -0
  68. package/commands/dgs/reject-idea.md +43 -0
  69. package/commands/dgs/remove-doc.md +44 -0
  70. package/commands/dgs/remove-phase.md +31 -0
  71. package/commands/dgs/remove-repo.md +69 -0
  72. package/commands/dgs/research-idea.md +43 -0
  73. package/commands/dgs/research-phase.md +189 -0
  74. package/commands/dgs/restore-idea.md +45 -0
  75. package/commands/dgs/resume-work.md +40 -0
  76. package/commands/dgs/rollback-job.md +24 -0
  77. package/commands/dgs/run-job.md +35 -0
  78. package/commands/dgs/search.md +40 -0
  79. package/commands/dgs/set-profile.md +34 -0
  80. package/commands/dgs/settings.md +38 -0
  81. package/commands/dgs/switch-project.md +58 -0
  82. package/commands/dgs/undo-consolidation.md +42 -0
  83. package/commands/dgs/update-idea.md +44 -0
  84. package/commands/dgs/update.md +37 -0
  85. package/commands/dgs/validate-phase.md +35 -0
  86. package/commands/dgs/verify-work.md +39 -0
  87. package/commands/dgs/write-spec.md +49 -0
  88. package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-01-SUMMARY.md +84 -0
  89. package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-02-SUMMARY.md +86 -0
  90. package/deliver-great-systems/.planning/phases/10-v1-to-v2-migration-flow/10-01-SUMMARY.md +85 -0
  91. package/deliver-great-systems/bin/dgs-tools.cjs +1444 -0
  92. package/deliver-great-systems/bin/lib/auto-test.cjs +1365 -0
  93. package/deliver-great-systems/bin/lib/commands.cjs +570 -0
  94. package/deliver-great-systems/bin/lib/config.cjs +417 -0
  95. package/deliver-great-systems/bin/lib/conflict-agent.cjs +1063 -0
  96. package/deliver-great-systems/bin/lib/conflict-agent.test.cjs +554 -0
  97. package/deliver-great-systems/bin/lib/context.cjs +929 -0
  98. package/deliver-great-systems/bin/lib/context.test.cjs +693 -0
  99. package/deliver-great-systems/bin/lib/core.cjs +744 -0
  100. package/deliver-great-systems/bin/lib/core.test.cjs +822 -0
  101. package/deliver-great-systems/bin/lib/docs.cjs +919 -0
  102. package/deliver-great-systems/bin/lib/docs.test.cjs +211 -0
  103. package/deliver-great-systems/bin/lib/execution.cjs +705 -0
  104. package/deliver-great-systems/bin/lib/execution.test.cjs +1472 -0
  105. package/deliver-great-systems/bin/lib/frontmatter.cjs +324 -0
  106. package/deliver-great-systems/bin/lib/ideas.cjs +1406 -0
  107. package/deliver-great-systems/bin/lib/ideas.test.cjs +1417 -0
  108. package/deliver-great-systems/bin/lib/identity.cjs +125 -0
  109. package/deliver-great-systems/bin/lib/init.cjs +1114 -0
  110. package/deliver-great-systems/bin/lib/init.test.cjs +1271 -0
  111. package/deliver-great-systems/bin/lib/jobs.cjs +2015 -0
  112. package/deliver-great-systems/bin/lib/jobs.test.cjs +2619 -0
  113. package/deliver-great-systems/bin/lib/merge-conflicts.cjs +654 -0
  114. package/deliver-great-systems/bin/lib/merge-conflicts.test.cjs +370 -0
  115. package/deliver-great-systems/bin/lib/migration.cjs +352 -0
  116. package/deliver-great-systems/bin/lib/migration.test.cjs +582 -0
  117. package/deliver-great-systems/bin/lib/milestone.cjs +243 -0
  118. package/deliver-great-systems/bin/lib/overlap.cjs +437 -0
  119. package/deliver-great-systems/bin/lib/overlap.test.cjs +747 -0
  120. package/deliver-great-systems/bin/lib/path-audit.test.cjs +384 -0
  121. package/deliver-great-systems/bin/lib/paths.cjs +144 -0
  122. package/deliver-great-systems/bin/lib/paths.test.cjs +486 -0
  123. package/deliver-great-systems/bin/lib/phase.cjs +910 -0
  124. package/deliver-great-systems/bin/lib/projects.cjs +691 -0
  125. package/deliver-great-systems/bin/lib/projects.test.cjs +871 -0
  126. package/deliver-great-systems/bin/lib/repos.cjs +1432 -0
  127. package/deliver-great-systems/bin/lib/repos.test.cjs +1882 -0
  128. package/deliver-great-systems/bin/lib/roadmap.cjs +305 -0
  129. package/deliver-great-systems/bin/lib/search.cjs +570 -0
  130. package/deliver-great-systems/bin/lib/specs.cjs +1303 -0
  131. package/deliver-great-systems/bin/lib/state.cjs +893 -0
  132. package/deliver-great-systems/bin/lib/template.cjs +228 -0
  133. package/deliver-great-systems/bin/lib/test-helpers.cjs +291 -0
  134. package/deliver-great-systems/bin/lib/verify.cjs +796 -0
  135. package/deliver-great-systems/references/checkpoints.md +776 -0
  136. package/deliver-great-systems/references/conflict-resolution.md +66 -0
  137. package/deliver-great-systems/references/context-tiers.md +166 -0
  138. package/deliver-great-systems/references/continuation-format.md +249 -0
  139. package/deliver-great-systems/references/decimal-phase-calculation.md +67 -0
  140. package/deliver-great-systems/references/git-integration.md +250 -0
  141. package/deliver-great-systems/references/git-planning-commit.md +40 -0
  142. package/deliver-great-systems/references/model-profile-resolution.md +36 -0
  143. package/deliver-great-systems/references/model-profiles.md +95 -0
  144. package/deliver-great-systems/references/phase-argument-parsing.md +61 -0
  145. package/deliver-great-systems/references/planning-config.md +224 -0
  146. package/deliver-great-systems/references/questioning.md +162 -0
  147. package/deliver-great-systems/references/spec-review-loop.md +177 -0
  148. package/deliver-great-systems/references/tdd.md +265 -0
  149. package/deliver-great-systems/references/ui-brand.md +160 -0
  150. package/deliver-great-systems/references/verification-patterns.md +612 -0
  151. package/deliver-great-systems/templates/DEBUG.md +166 -0
  152. package/deliver-great-systems/templates/UAT.md +251 -0
  153. package/deliver-great-systems/templates/VALIDATION.md +95 -0
  154. package/deliver-great-systems/templates/claude-md.md +74 -0
  155. package/deliver-great-systems/templates/codebase/architecture.md +257 -0
  156. package/deliver-great-systems/templates/codebase/concerns.md +312 -0
  157. package/deliver-great-systems/templates/codebase/conventions.md +309 -0
  158. package/deliver-great-systems/templates/codebase/integrations.md +282 -0
  159. package/deliver-great-systems/templates/codebase/stack.md +188 -0
  160. package/deliver-great-systems/templates/codebase/structure.md +287 -0
  161. package/deliver-great-systems/templates/codebase/testing.md +482 -0
  162. package/deliver-great-systems/templates/config.json +38 -0
  163. package/deliver-great-systems/templates/context.md +354 -0
  164. package/deliver-great-systems/templates/continue-here.md +80 -0
  165. package/deliver-great-systems/templates/debug-subagent-prompt.md +93 -0
  166. package/deliver-great-systems/templates/discovery.md +148 -0
  167. package/deliver-great-systems/templates/milestone-archive.md +125 -0
  168. package/deliver-great-systems/templates/milestone.md +117 -0
  169. package/deliver-great-systems/templates/phase-prompt.md +615 -0
  170. package/deliver-great-systems/templates/planner-subagent-prompt.md +119 -0
  171. package/deliver-great-systems/templates/project.md +186 -0
  172. package/deliver-great-systems/templates/requirements.md +233 -0
  173. package/deliver-great-systems/templates/research-project/ARCHITECTURE.md +206 -0
  174. package/deliver-great-systems/templates/research-project/FEATURES.md +149 -0
  175. package/deliver-great-systems/templates/research-project/PITFALLS.md +202 -0
  176. package/deliver-great-systems/templates/research-project/STACK.md +122 -0
  177. package/deliver-great-systems/templates/research-project/SUMMARY.md +172 -0
  178. package/deliver-great-systems/templates/research.md +554 -0
  179. package/deliver-great-systems/templates/retrospective.md +54 -0
  180. package/deliver-great-systems/templates/roadmap.md +204 -0
  181. package/deliver-great-systems/templates/state.md +178 -0
  182. package/deliver-great-systems/templates/summary-complex.md +59 -0
  183. package/deliver-great-systems/templates/summary-minimal.md +41 -0
  184. package/deliver-great-systems/templates/summary-standard.md +48 -0
  185. package/deliver-great-systems/templates/summary.md +253 -0
  186. package/deliver-great-systems/templates/user-setup.md +313 -0
  187. package/deliver-great-systems/templates/verification-report.md +324 -0
  188. package/deliver-great-systems/workflows/add-doc.md +151 -0
  189. package/deliver-great-systems/workflows/add-idea.md +96 -0
  190. package/deliver-great-systems/workflows/add-phase.md +120 -0
  191. package/deliver-great-systems/workflows/add-tests.md +359 -0
  192. package/deliver-great-systems/workflows/add-todo.md +162 -0
  193. package/deliver-great-systems/workflows/approve-spec.md +194 -0
  194. package/deliver-great-systems/workflows/audit-milestone.md +364 -0
  195. package/deliver-great-systems/workflows/audit-phase.md +462 -0
  196. package/deliver-great-systems/workflows/cancel-job.md +108 -0
  197. package/deliver-great-systems/workflows/check-todos.md +181 -0
  198. package/deliver-great-systems/workflows/cleanup.md +247 -0
  199. package/deliver-great-systems/workflows/codereview.md +526 -0
  200. package/deliver-great-systems/workflows/complete-milestone.md +1298 -0
  201. package/deliver-great-systems/workflows/consolidate-ideas.md +365 -0
  202. package/deliver-great-systems/workflows/create-milestone-job.md +177 -0
  203. package/deliver-great-systems/workflows/develop-idea.md +544 -0
  204. package/deliver-great-systems/workflows/diagnose-issues.md +231 -0
  205. package/deliver-great-systems/workflows/discovery-phase.md +301 -0
  206. package/deliver-great-systems/workflows/discuss-idea.md +263 -0
  207. package/deliver-great-systems/workflows/discuss-phase.md +733 -0
  208. package/deliver-great-systems/workflows/execute-phase.md +571 -0
  209. package/deliver-great-systems/workflows/execute-plan.md +592 -0
  210. package/deliver-great-systems/workflows/find-related-ideas.md +271 -0
  211. package/deliver-great-systems/workflows/health.md +173 -0
  212. package/deliver-great-systems/workflows/help.md +997 -0
  213. package/deliver-great-systems/workflows/import-spec.md +381 -0
  214. package/deliver-great-systems/workflows/init-product.md +767 -0
  215. package/deliver-great-systems/workflows/insert-phase.md +138 -0
  216. package/deliver-great-systems/workflows/list-docs.md +119 -0
  217. package/deliver-great-systems/workflows/list-ideas.md +154 -0
  218. package/deliver-great-systems/workflows/list-jobs.md +89 -0
  219. package/deliver-great-systems/workflows/list-phase-assumptions.md +192 -0
  220. package/deliver-great-systems/workflows/list-specs.md +101 -0
  221. package/deliver-great-systems/workflows/map-codebase.md +621 -0
  222. package/deliver-great-systems/workflows/new-milestone.md +591 -0
  223. package/deliver-great-systems/workflows/new-project.md +1113 -0
  224. package/deliver-great-systems/workflows/node-repair.md +94 -0
  225. package/deliver-great-systems/workflows/overlap-check.md +86 -0
  226. package/deliver-great-systems/workflows/pause-work.md +134 -0
  227. package/deliver-great-systems/workflows/plan-milestone-gaps.md +306 -0
  228. package/deliver-great-systems/workflows/plan-phase.md +698 -0
  229. package/deliver-great-systems/workflows/progress.md +386 -0
  230. package/deliver-great-systems/workflows/quick.md +845 -0
  231. package/deliver-great-systems/workflows/refine-spec.md +275 -0
  232. package/deliver-great-systems/workflows/reject-idea.md +109 -0
  233. package/deliver-great-systems/workflows/remove-doc.md +117 -0
  234. package/deliver-great-systems/workflows/remove-phase.md +163 -0
  235. package/deliver-great-systems/workflows/research-idea.md +325 -0
  236. package/deliver-great-systems/workflows/research-phase.md +81 -0
  237. package/deliver-great-systems/workflows/restore-idea.md +101 -0
  238. package/deliver-great-systems/workflows/resume-project.md +311 -0
  239. package/deliver-great-systems/workflows/rollback-job.md +130 -0
  240. package/deliver-great-systems/workflows/run-job.md +498 -0
  241. package/deliver-great-systems/workflows/search.md +130 -0
  242. package/deliver-great-systems/workflows/set-profile.md +83 -0
  243. package/deliver-great-systems/workflows/settings.md +470 -0
  244. package/deliver-great-systems/workflows/transition.md +563 -0
  245. package/deliver-great-systems/workflows/undo-consolidation.md +155 -0
  246. package/deliver-great-systems/workflows/update-idea.md +157 -0
  247. package/deliver-great-systems/workflows/update.md +242 -0
  248. package/deliver-great-systems/workflows/validate-phase.md +177 -0
  249. package/deliver-great-systems/workflows/verify-phase.md +253 -0
  250. package/deliver-great-systems/workflows/verify-work.md +671 -0
  251. package/deliver-great-systems/workflows/write-spec.md +450 -0
  252. package/hooks/dist/dgs-check-update.js +62 -0
  253. package/hooks/dist/dgs-context-monitor.js +141 -0
  254. package/hooks/dist/dgs-statusline.js +115 -0
  255. package/package.json +60 -0
  256. package/scripts/build-hooks.js +43 -0
@@ -0,0 +1,571 @@
1
+ <purpose>
2
+ Execute all plans in a phase using wave-based parallel execution. Orchestrator stays lean — delegates plan execution to subagents.
3
+ </purpose>
4
+
5
+ <context_tier>execution</context_tier>
6
+
7
+ <core_principle>
8
+ Orchestrator coordinates, not executes. Each subagent loads the full execute-plan context. Orchestrator: discover plans → analyze deps → group waves → spawn agents → handle checkpoints → collect results.
9
+ </core_principle>
10
+
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.
13
+ </hard_boundary>
14
+
15
+ <required_reading>
16
+ Read STATE.md before any operation to load project context.
17
+ </required_reading>
18
+
19
+ <process>
20
+
21
+ <step name="initialize" priority="first">
22
+ Load all context in one call:
23
+
24
+ ```bash
25
+ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" init execute-phase "${PHASE_ARG}")
26
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
27
+ ```
28
+
29
+ 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`.
30
+
31
+ **Load execution tier context:**
32
+
33
+ ```bash
34
+ TIER_FILES=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" context load-tier execution --phase "${PHASE_NUMBER}" --raw 2>/dev/null)
35
+ ```
36
+
37
+ Store the file list for passing to sub-agents in `<files_to_read>` blocks.
38
+
39
+ **If `phase_found` is false:** Error — phase directory not found.
40
+ **If `plan_count` is 0:** Error — no plans found in phase.
41
+ **If `state_exists` is false but planning directory exists:** Offer reconstruct or continue.
42
+
43
+ When `parallelization` is false, plans within a wave execute sequentially.
44
+
45
+ **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). Must happen before any config reads (checkpoint handling also reads auto-advance flags):
46
+ ```bash
47
+ if [[ ! "$ARGUMENTS" =~ --auto ]]; then
48
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
49
+ fi
50
+ ```
51
+
52
+ **Auto-mode and non-interactive detection:**
53
+
54
+ Parse `--auto` and `--non-interactive` flags from $ARGUMENTS.
55
+ Read auto-advance config:
56
+ ```bash
57
+ AUTO_CHAIN=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
58
+ AUTO_CFG=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
59
+ ```
60
+ Set `AUTO_MODE = true` if `--auto` flag present OR `AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`.
61
+ Set `NON_INTERACTIVE = true` if `--non-interactive` flag present OR `--auto` flag present OR `AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`.
62
+
63
+ `NON_INTERACTIVE` controls checkpoint auto-approval and verification auto-resolve.
64
+ `AUTO_MODE` controls auto-advance via transition.md only (offer_next step).
65
+ </step>
66
+
67
+ <step name="handle_branching">
68
+ Check `branching_strategy` from init:
69
+
70
+ **"none":** Skip, continue on current branch.
71
+
72
+ **"phase" or "milestone":** Use pre-computed `branch_name` from init for the product folder:
73
+ ```bash
74
+ git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
75
+ ```
76
+
77
+ All subsequent commits go to this branch. User handles merging.
78
+
79
+ **Code repo branching (base_branch):**
80
+
81
+ 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.
82
+
83
+ When branching is enabled and REPOS.md lists code repos, `createRepoBranches` (via `dgs-tools.cjs`) uses `base_branch` to:
84
+ 1. Pre-check all code repos upfront — verify the base branch exists in every registered repo before creating any branches
85
+ 2. Fetch the base branch from remote in each repo (`git fetch origin "$BASE_BRANCH"`)
86
+ 3. Create feature branches from the base branch (`git checkout "$BASE_BRANCH" && git checkout -b "$BRANCH_NAME"`)
87
+
88
+ If the base branch does not exist in any code repo, the operation fails with a clear error before any branches are created:
89
+ ```
90
+ Error: Base branch '{base_branch}' does not exist in repo '{repo_name}'.
91
+ Create the branch or update git.base_branch in config.
92
+ ```
93
+
94
+ 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).
95
+ </step>
96
+
97
+ <step name="validate_phase">
98
+ From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
99
+
100
+ Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
101
+ </step>
102
+
103
+ <step name="discover_and_group_plans">
104
+ Load plan inventory with wave grouping in one call:
105
+
106
+ ```bash
107
+ PLAN_INDEX=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
108
+ ```
109
+
110
+ Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
111
+
112
+ **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If all filtered: "No matching incomplete plans" → exit.
113
+
114
+ Report:
115
+ ```
116
+ ## Execution Plan
117
+
118
+ **Phase {X}: {Name}** — {total_plans} plans across {wave_count} waves
119
+
120
+ | Wave | Plans | What it builds |
121
+ |------|-------|----------------|
122
+ | 1 | 01-01, 01-02 | {from plan objectives, 3-8 words} |
123
+ | 2 | 01-03 | ... |
124
+ ```
125
+ </step>
126
+
127
+ <step name="execute_waves">
128
+ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
129
+
130
+ **For each wave:**
131
+
132
+ 1. **Describe what's being built (BEFORE spawning):**
133
+
134
+ Read each plan's `<objective>`. Extract what's being built and why.
135
+
136
+ ```
137
+ ---
138
+ ## Wave {N}
139
+
140
+ **{Plan ID}: {Plan Name}**
141
+ {2-3 sentences: what this builds, technical approach, why it matters}
142
+
143
+ Spawning {count} agent(s)...
144
+ ---
145
+ ```
146
+
147
+ - Bad: "Executing terrain generation plan"
148
+ - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
149
+
150
+ 2. **Spawn executor agents:**
151
+
152
+ Pass paths only — executors read files themselves with their fresh 200k context.
153
+ This keeps orchestrator context lean (~10-15%).
154
+
155
+ ```
156
+ Task(
157
+ subagent_type="dgs-executor",
158
+ model="{executor_model}",
159
+ prompt="
160
+ <objective>
161
+ Execute plan {plan_number} of phase {phase_number}-{phase_name}.
162
+ Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
163
+ </objective>
164
+
165
+ <execution_context>
166
+ @~/.claude/deliver-great-systems/workflows/execute-plan.md
167
+ @~/.claude/deliver-great-systems/templates/summary.md
168
+ @~/.claude/deliver-great-systems/references/checkpoints.md
169
+ @~/.claude/deliver-great-systems/references/tdd.md
170
+ </execution_context>
171
+
172
+ <files_to_read>
173
+ Read these files at execution start using the Read tool:
174
+ - {phase_dir}/{plan_file} (Plan)
175
+ - ${state_path} (State — resolved by init)
176
+ - {phase_dir}/{padded_phase}-CONTEXT.md (Phase context — user design decisions. Warn if missing, continue.)
177
+ - ${config_path} (Config, if exists)
178
+ - ./CLAUDE.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
179
+ - .claude/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
180
+ {For each file in TIER_FILES not already listed above:}
181
+ - {tier_file} (Context tier: execution)
182
+ </files_to_read>
183
+
184
+ <author>${author}</author>
185
+
186
+ <success_criteria>
187
+ - [ ] All tasks executed
188
+ - [ ] Each task committed individually
189
+ - [ ] SUMMARY.md created in plan directory
190
+ - [ ] STATE.md updated with position and decisions
191
+ - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
192
+ </success_criteria>
193
+ "
194
+ )
195
+ ```
196
+
197
+ 3. **Wait for all agents in wave to complete.**
198
+
199
+ 4. **Report completion — spot-check claims first:**
200
+
201
+ For each SUMMARY.md:
202
+ - Verify first 2 files from `key-files.created` exist on disk
203
+ - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
204
+ - Check for `## Self-Check: FAILED` marker
205
+
206
+ If ANY spot-check fails: report which plan failed, route to failure handler.
207
+
208
+ **If `NON_INTERACTIVE` is true AND spot-check fails:**
209
+ Log: `[AUTO-RESOLVE] Spot-check failed for plan {plan_id} -- continuing to next wave`
210
+ Skip the "Retry plan?" / "Continue with remaining waves?" interactive prompt. Continue to the next wave.
211
+
212
+ **If `NON_INTERACTIVE` is false (interactive mode):**
213
+ Ask "Retry plan?" or "Continue with remaining waves?"
214
+
215
+ If pass:
216
+ ```
217
+ ---
218
+ ## Wave {N} Complete
219
+
220
+ **{Plan ID}: {Plan Name}**
221
+ {What was built — from SUMMARY.md}
222
+ {Notable deviations, if any}
223
+
224
+ {If more waves: what this enables for next wave}
225
+ ---
226
+ ```
227
+
228
+ - Bad: "Wave 2 complete. Proceeding to Wave 3."
229
+ - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
230
+
231
+ 5. **Handle failures:**
232
+
233
+ **Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a DGS or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 4 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
234
+
235
+ **If `NON_INTERACTIVE` is true AND a real failure occurs:**
236
+ Log: `[AUTO-RESOLVE] Plan {plan_id} failed -- halting execution (step failures are not auto-resolvable)`
237
+ Halt immediately with no interactive "Continue?" / "Stop?" prompt. The step just halts.
238
+
239
+ **If `NON_INTERACTIVE` is false (interactive mode):**
240
+ For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
241
+
242
+ 6. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
243
+
244
+ 7. **Proceed to next wave.**
245
+ </step>
246
+
247
+ <step name="checkpoint_handling">
248
+ Plans with `autonomous: false` require user interaction.
249
+
250
+ **Auto-mode checkpoint handling:**
251
+
252
+ When executor returns a checkpoint AND `NON_INTERACTIVE` is true (set in initialize step from `--non-interactive` flag, `--auto` flag, `workflow._auto_chain_active`, or `workflow.auto_advance` config):
253
+
254
+ - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`. Log: `[AUTO-RESOLVE] Auto-approved checkpoint: {task_name}`
255
+ - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`. Log: `[AUTO-RESOLVE] Auto-selected option: {selected_option_name}`
256
+ - **human-action** → Do NOT present the checkpoint to the user. Do NOT auto-resolve. Log: `[AUTO-RESOLVE] human-action checkpoint encountered -- FAILING step (requires human intervention)`. Return a FAILED result so the job orchestrator halts the job. The user can then fix the issue and resume the job with `/dgs:run-job`.
257
+
258
+ **Standard flow (not non-interactive, or human-action type in interactive mode):**
259
+
260
+ 1. Spawn agent for checkpoint plan
261
+ 2. Agent runs until checkpoint task or auth gate → returns structured state
262
+ 3. Agent return includes: completed tasks table, current task + blocker, checkpoint type/details, what's awaited
263
+ 4. **Present to user:**
264
+ ```
265
+ ## Checkpoint: [Type]
266
+
267
+ **Plan:** 03-03 Dashboard Layout
268
+ **Progress:** 2/3 tasks complete
269
+
270
+ [Checkpoint Details from agent return]
271
+ [Awaiting section from agent return]
272
+ ```
273
+ 5. User responds: "approved"/"done" | issue description | decision selection
274
+ 6. **Spawn continuation agent (NOT resume)** using continuation-prompt.md template:
275
+ - `{completed_tasks_table}`: From checkpoint return
276
+ - `{resume_task_number}` + `{resume_task_name}`: Current task
277
+ - `{user_response}`: What user provided
278
+ - `{resume_instructions}`: Based on checkpoint type
279
+ 7. Continuation agent verifies previous commits, continues from resume point
280
+ 8. Repeat until plan completes or user stops
281
+
282
+ **Why fresh agent, not resume:** Resume relies on internal serialization that breaks with parallel tool calls. Fresh agents with explicit state are more reliable.
283
+
284
+ **Checkpoints in parallel waves:** Agent pauses and returns while other parallel agents may complete. Present checkpoint, spawn continuation, wait for all before next wave.
285
+ </step>
286
+
287
+ <step name="aggregate_results">
288
+ After all waves:
289
+
290
+ ```markdown
291
+ ## Phase {X}: {Name} Execution Complete
292
+
293
+ **Waves:** {N} | **Plans:** {M}/{total} complete
294
+
295
+ | Wave | Plans | Status |
296
+ |------|-------|--------|
297
+ | 1 | plan-01, plan-02 | ✓ Complete |
298
+ | CP | plan-03 | ✓ Verified |
299
+ | 2 | plan-04 | ✓ Complete |
300
+
301
+ ### Plan Details
302
+ 1. **03-01**: [one-liner from SUMMARY.md]
303
+ 2. **03-02**: [one-liner from SUMMARY.md]
304
+
305
+ ### Issues Encountered
306
+ [Aggregate from SUMMARYs, or "None"]
307
+ ```
308
+ </step>
309
+
310
+ <step name="close_parent_artifacts">
311
+ **For decimal/polish phases only (X.Y pattern):** Close the feedback loop by resolving parent UAT and debug artifacts.
312
+
313
+ **Skip if** phase number has no decimal (e.g., `3`, `04`) — only applies to gap-closure phases like `4.1`, `03.1`.
314
+
315
+ **1. Detect decimal phase and derive parent:**
316
+ ```bash
317
+ # Check if phase_number contains a decimal
318
+ if [[ "$PHASE_NUMBER" == *.* ]]; then
319
+ PARENT_PHASE="${PHASE_NUMBER%%.*}"
320
+ fi
321
+ ```
322
+
323
+ **2. Find parent UAT file:**
324
+ ```bash
325
+ PARENT_INFO=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" find-phase "${PARENT_PHASE}" --raw)
326
+ # Extract directory from PARENT_INFO JSON, then find UAT file in that directory
327
+ ```
328
+
329
+ **If no parent UAT found:** Skip this step (gap-closure may have been triggered by VERIFICATION.md instead).
330
+
331
+ **3. Update UAT gap statuses:**
332
+
333
+ Read the parent UAT file's `## Gaps` section. For each gap entry with `status: failed`:
334
+ - Update to `status: resolved`
335
+
336
+ **4. Update UAT frontmatter:**
337
+
338
+ If all gaps now have `status: resolved`:
339
+ - Update frontmatter `status: diagnosed` → `status: resolved`
340
+ - Update frontmatter `updated:` timestamp
341
+
342
+ **5. Resolve referenced debug sessions:**
343
+
344
+ For each gap that has a `debug_session:` field:
345
+ - Read the debug session file
346
+ - Update frontmatter `status:` → `resolved`
347
+ - Update frontmatter `updated:` timestamp
348
+ - Move to resolved directory:
349
+ ```bash
350
+ mkdir -p ${debug_dir}/resolved
351
+ mv ${debug_dir}/{slug}.md ${debug_dir}/resolved/
352
+ ```
353
+
354
+ **6. Commit updated artifacts:**
355
+ ```bash
356
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files ${phase_dir}/*-UAT.md ${debug_dir}/resolved/*.md
357
+ ```
358
+ </step>
359
+
360
+ <step name="verify_phase_goal">
361
+ Verify phase achieved its GOAL, not just completed tasks.
362
+
363
+ ```
364
+ Task(
365
+ prompt="Verify phase {phase_number} goal achievement.
366
+ Phase directory: {phase_dir}
367
+ Phase goal: {goal from ROADMAP.md}
368
+ Phase requirement IDs: {phase_req_ids}
369
+ Author: ${author}
370
+ Check must_haves against actual codebase.
371
+ Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
372
+ Create VERIFICATION.md.",
373
+ subagent_type="dgs-verifier",
374
+ model="{verifier_model}"
375
+ )
376
+ ```
377
+
378
+ Read status:
379
+ ```bash
380
+ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
381
+ ```
382
+
383
+ | Status | Action |
384
+ |--------|--------|
385
+ | `passed` | → update_roadmap |
386
+ | `human_needed` | Present items for human testing, get approval or feedback |
387
+ | `gaps_found` | Present gap summary, offer `/dgs:plan-phase {phase} --gaps` |
388
+
389
+ **If human_needed:**
390
+
391
+ **If `NON_INTERACTIVE` is true AND status is `human_needed`:**
392
+ Log: `[AUTO-RESOLVE] Verification status is human_needed -- auto-approving. AI-verified only -- no human UAT performed.`
393
+
394
+ Update the VERIFICATION.md file to add an annotation noting auto-approval:
395
+ - Find the `status: human_needed` line and change to `status: passed`
396
+ - Add a line after status: `auto_approved: true`
397
+ - Add a line: `auto_approved_note: "AI-verified only -- no human UAT performed"`
398
+
399
+ Then proceed to update_roadmap step (same as if user approved).
400
+
401
+ **If `NON_INTERACTIVE` is false (interactive mode):**
402
+ ```
403
+ ## ✓ Phase {X}: {Name} — Human Verification Required
404
+
405
+ All automated checks passed. {N} items need human testing:
406
+
407
+ {From VERIFICATION.md human_verification section}
408
+
409
+ "approved" → continue | Report issues → gap closure
410
+ ```
411
+
412
+ **If gaps_found:**
413
+
414
+ **If `NON_INTERACTIVE` is true AND status is `gaps_found`:**
415
+ Log: `[AUTO-RESOLVE] Verification found gaps -- logging and continuing (Phase 53 audit will catch real issues)`
416
+ Log: `[DEVIATION] Phase verification gaps found but not blocking: {gap_summary}`
417
+
418
+ Proceed to update_roadmap step. Mark phase as complete despite gaps -- the audit step in the job (Phase 53) serves as the safety net.
419
+
420
+ **If `NON_INTERACTIVE` is false (interactive mode):**
421
+ ```
422
+ ## ⚠ Phase {X}: {Name} — Gaps Found
423
+
424
+ **Score:** {N}/{M} must-haves verified
425
+ **Report:** {phase_dir}/{phase_num}-VERIFICATION.md
426
+
427
+ ### What's Missing
428
+ {Gap summaries from VERIFICATION.md}
429
+
430
+ ---
431
+ ## ▶ Next Up
432
+
433
+ `/dgs:plan-phase {X} --gaps`
434
+
435
+ <sub>`/clear` first → fresh context window</sub>
436
+
437
+ Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
438
+ Also: `/dgs:verify-work {X}` — manual testing first
439
+ ```
440
+
441
+ Gap closure cycle: `/dgs:plan-phase {X} --gaps` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/dgs:execute-phase {X} --gaps-only` → verifier re-runs.
442
+ </step>
443
+
444
+ <step name="update_roadmap">
445
+ **Mark phase complete and update all tracking files:**
446
+
447
+ ```bash
448
+ COMPLETION=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" phase complete "${PHASE_NUMBER}")
449
+ ```
450
+
451
+ The CLI handles:
452
+ - Marking phase checkbox `[x]` with completion date
453
+ - Updating Progress table (Status → Complete, date)
454
+ - Updating plan count to final
455
+ - Advancing STATE.md to next phase
456
+ - Updating REQUIREMENTS.md traceability
457
+
458
+ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`.
459
+
460
+ ```bash
461
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(phase-{X}): complete phase execution" --files ${roadmap_path} ${state_path} ${requirements_path} ${phase_dir}/*-VERIFICATION.md
462
+ ```
463
+ </step>
464
+
465
+ <step name="offer_next">
466
+
467
+ **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/dgs:plan-phase {X} --gaps`). No additional routing needed — skip auto-advance.
468
+
469
+ **No-transition check (spawned by auto-advance chain):**
470
+
471
+ Parse `--no-transition` flag from $ARGUMENTS.
472
+
473
+ **If `--no-transition` flag present:**
474
+
475
+ Execute-phase was spawned by plan-phase's auto-advance. Do NOT run transition.md.
476
+ After verification passes and roadmap is updated, return completion status to parent:
477
+
478
+ ```
479
+ ## PHASE COMPLETE
480
+
481
+ Phase: ${PHASE_NUMBER} - ${PHASE_NAME}
482
+ Plans: ${completed_count}/${total_count}
483
+ Verification: {Passed | Gaps Found}
484
+
485
+ [Include aggregate_results output]
486
+ ```
487
+
488
+ STOP. Do not proceed to auto-advance or transition.
489
+
490
+ **If `--no-transition` flag is NOT present:**
491
+
492
+ **Auto-advance detection:**
493
+
494
+ 1. Parse `--auto` flag from $ARGUMENTS
495
+ 2. Read both the chain flag and user preference (chain flag already synced in init step):
496
+ ```bash
497
+ AUTO_CHAIN=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
498
+ AUTO_CFG=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
499
+ ```
500
+
501
+ **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true (AND verification passed with no gaps):**
502
+
503
+ ```
504
+ ╔══════════════════════════════════════════╗
505
+ ║ AUTO-ADVANCING → TRANSITION ║
506
+ ║ Phase {X} verified, continuing chain ║
507
+ ╚══════════════════════════════════════════╝
508
+ ```
509
+
510
+ Execute the transition workflow inline (do NOT use Task — orchestrator context is ~10-15%, transition needs phase completion data already in context):
511
+
512
+ Read and follow `~/.claude/deliver-great-systems/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
513
+
514
+ **If neither `--auto` nor `AUTO_CFG` is true:**
515
+
516
+ **HARD STOP.** The workflow ends here. Do NOT read transition.md. Do NOT read ROADMAP.md. Do NOT execute any additional phases.
517
+
518
+ **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.
519
+
520
+ If `is_last_phase` is `false`:
521
+ ```
522
+ ## Phase {X}: {Name} Complete
523
+
524
+ Plans: {M}/{total} | Verification: {status}
525
+
526
+ ---
527
+
528
+ ## Next Up
529
+
530
+ **Phase {next_phase}: {next_phase_name}**
531
+
532
+ `/dgs:plan-phase {next_phase}`
533
+
534
+ <sub>`/clear` first → fresh context window</sub>
535
+ ```
536
+
537
+ If `is_last_phase` is `true`:
538
+ ```
539
+ ## Phase {X}: {Name} Complete
540
+
541
+ Plans: {M}/{total} | Verification: {status}
542
+
543
+ All phases in this milestone are complete!
544
+
545
+ `/dgs:complete-milestone`
546
+
547
+ <sub>`/clear` first → fresh context window</sub>
548
+ ```
549
+
550
+ STOP. Do not proceed further. The job orchestrator handles sequencing — advancing beyond this point corrupts job state and causes duplicate execution.
551
+ </step>
552
+
553
+ </process>
554
+
555
+ <context_efficiency>
556
+ Orchestrator: ~10-15% context. Subagents: fresh 200k each. No polling (Task blocks). No context bleed.
557
+ </context_efficiency>
558
+
559
+ <failure_handling>
560
+ - **classifyHandoffIfNeeded false failure:** Agent reports "failed" but error is `classifyHandoffIfNeeded is not defined` → Claude Code bug, not DGS. Spot-check (SUMMARY exists, commits present) → if pass, treat as success
561
+ - **Agent fails mid-plan:** Missing SUMMARY.md → report, ask user how to proceed
562
+ - **Dependency chain breaks:** Wave 1 fails → Wave 2 dependents likely fail → user chooses attempt or skip
563
+ - **All agents in wave fail:** Systemic issue → stop, report for investigation
564
+ - **Checkpoint unresolvable:** "Skip this plan?" or "Abort phase execution?" → record partial progress in STATE.md
565
+ </failure_handling>
566
+
567
+ <resumption>
568
+ Re-run `/dgs:execute-phase {phase}` → discover_plans finds completed SUMMARYs → skips them → resumes from first incomplete plan → continues wave execution.
569
+
570
+ STATE.md tracks: last completed plan, current wave, pending checkpoints.
571
+ </resumption>