@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,224 @@
1
+ <planning_config>
2
+
3
+ Configuration options for planning directory behavior.
4
+
5
+ > **v2 Multi-Project:** Config file (`dgs.config.json`) is always product-level — not project-scoped. In v2 setups, project-specific paths (STATE.md, ROADMAP.md, phases/) resolve to `<project-slug>/` within the planning root via init commands, but config stays at the product root.
6
+
7
+ <config_schema>
8
+ ```json
9
+ "workflow": {
10
+ "research": true,
11
+ "plan_check": true,
12
+ "verifier": true,
13
+ "auto_advance": false,
14
+ "nyquist_validation": true,
15
+ "codereview": false
16
+ },
17
+ "planning": {
18
+ "commit_docs": true,
19
+ "search_gitignored": false
20
+ },
21
+ "git": {
22
+ "base_branch": "main",
23
+ "branching_strategy": "none",
24
+ "phase_branch_template": "dgs/{project}/phase-{phase}-{slug}",
25
+ "milestone_branch_template": "dgs/{project}/{milestone}-{slug}"
26
+ }
27
+ ```
28
+
29
+ | Option | Default | Description |
30
+ |--------|---------|-------------|
31
+ | `workflow.codereview` | `false` | Spawn 3-pass multi-agent code reviewer after plan execution. Auto-fixes low-risk issues in separate commit. |
32
+ | `commit_docs` | `true` | Whether to commit planning artifacts to git |
33
+ | `search_gitignored` | `false` | Add `--no-ignore` to broad rg searches |
34
+ | `git.base_branch` | `"main"` | Integration target branch for code repo branching operations (branch creation and merge) |
35
+ | `git.branching_strategy` | `"none"` | Git branching approach: `"none"`, `"phase"`, or `"milestone"` |
36
+ | `git.phase_branch_template` | `"dgs/{project}/phase-{phase}-{slug}"` | Branch template for phase strategy |
37
+ | `git.milestone_branch_template` | `"dgs/{project}/{milestone}-{slug}"` | Branch template for milestone strategy |
38
+ </config_schema>
39
+
40
+ <commit_docs_behavior>
41
+
42
+ **When `commit_docs: true` (default):**
43
+ - Planning files committed normally
44
+ - SUMMARY.md, STATE.md, ROADMAP.md tracked in git
45
+ - Full history of planning decisions preserved
46
+
47
+ **When `commit_docs: false`:**
48
+ - Skip all `git add`/`git commit` for planning files
49
+ - User must add planning directory to `.gitignore`
50
+ - Useful for: OSS contributions, client projects, keeping planning private
51
+
52
+ **Using dgs-tools.cjs (preferred):**
53
+
54
+ ```bash
55
+ # Commit with automatic commit_docs + gitignore checks:
56
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs: update state" --files ${state_path}
57
+
58
+ # Load config via state load (returns JSON):
59
+ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" state load)
60
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
61
+ # commit_docs is available in the JSON output
62
+
63
+ # Or use init commands which include commit_docs:
64
+ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" init execute-phase "1")
65
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
66
+ # commit_docs is included in all init command outputs
67
+ ```
68
+
69
+ **Auto-detection:** If the planning directory is gitignored, `commit_docs` is automatically `false` regardless of config. This prevents git errors when users have the planning directory in `.gitignore`.
70
+
71
+ **Commit via CLI (handles checks automatically):**
72
+
73
+ ```bash
74
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs: update state" --files ${state_path}
75
+ ```
76
+
77
+ The CLI checks `commit_docs` config and gitignore status internally — no manual conditionals needed.
78
+
79
+ </commit_docs_behavior>
80
+
81
+ <search_behavior>
82
+
83
+ **When `search_gitignored: false` (default):**
84
+ - Standard rg behavior (respects .gitignore)
85
+ - Direct path searches work: `rg "pattern" ${project_root}/` finds files
86
+ - Broad searches skip gitignored: `rg "pattern"` skips planning directory
87
+
88
+ **When `search_gitignored: true`:**
89
+ - Add `--no-ignore` to broad rg searches that should include the planning directory
90
+ - Only needed when searching entire repo and expecting planning directory matches
91
+
92
+ **Note:** Most DGS operations use direct file reads or explicit paths, which work regardless of gitignore status.
93
+
94
+ </search_behavior>
95
+
96
+ <setup_uncommitted_mode>
97
+
98
+ To use uncommitted mode:
99
+
100
+ 1. **Set config:**
101
+ ```json
102
+ "planning": {
103
+ "commit_docs": false,
104
+ "search_gitignored": true
105
+ }
106
+ ```
107
+
108
+ 2. **Add to .gitignore:**
109
+ ```
110
+ .planning/
111
+ ```
112
+
113
+ 3. **Existing tracked files:** If the planning directory was previously tracked:
114
+ ```bash
115
+ git rm -r --cached ${project_root}
116
+ git commit -m "chore: stop tracking planning docs"
117
+ ```
118
+
119
+ 4. **Branch merges:** When using `branching_strategy: phase` or `milestone`, the `complete-milestone` workflow automatically strips planning files from staging before merge commits when `commit_docs: false`.
120
+
121
+ </setup_uncommitted_mode>
122
+
123
+ <branching_strategy_behavior>
124
+
125
+ **Branching Strategies:**
126
+
127
+ | Strategy | When branch created | Branch scope | Merge point |
128
+ |----------|---------------------|--------------|-------------|
129
+ | `none` | Never | N/A | N/A |
130
+ | `phase` | At `execute-phase` start | Single phase | User merges after phase |
131
+ | `milestone` | At first `execute-phase` of milestone | Entire milestone | At `complete-milestone` |
132
+
133
+ **Base Branch:**
134
+
135
+ All branching operations on code repos (branch creation in `execute-phase`, merge in `complete-milestone`) use `git.base_branch` as the starting point instead of hardcoded `main`. Default is `main`. Set during `/dgs:init-product` or change via `/dgs:settings`. The product folder repo always uses `main` — only sibling code repos registered in REPOS.md use the configured base branch.
136
+
137
+ **When `git.branching_strategy: "none"` (default):**
138
+ - All work commits to current branch
139
+ - Standard DGS behavior
140
+
141
+ **When `git.branching_strategy: "phase"`:**
142
+ - `execute-phase` creates/switches to a branch before execution
143
+ - Branch name from `phase_branch_template` (e.g., `dgs/checkout/phase-03-authentication`)
144
+ - All plan commits go to that branch
145
+ - User merges branches manually after phase completion
146
+ - `complete-milestone` offers to merge all phase branches
147
+
148
+ **When `git.branching_strategy: "milestone"`:**
149
+ - First `execute-phase` of milestone creates the milestone branch
150
+ - Branch name from `milestone_branch_template` (e.g., `dgs/checkout/v1.0-mvp`)
151
+ - All phases in milestone commit to same branch
152
+ - `complete-milestone` offers to merge milestone branch to main
153
+
154
+ **Template variables:**
155
+
156
+ | Variable | Available in | Description |
157
+ |----------|--------------|-------------|
158
+ | `{project}` | Both | Project slug from current_project (e.g., "checkout") |
159
+ | `{phase}` | phase_branch_template | Zero-padded phase number (e.g., "03") |
160
+ | `{slug}` | Both | Lowercase, hyphenated name |
161
+ | `{milestone}` | milestone_branch_template | Milestone version (e.g., "v1.0") |
162
+
163
+ **Checking the config:**
164
+
165
+ Use `init execute-phase` which returns all config as JSON:
166
+ ```bash
167
+ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" init execute-phase "1")
168
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
169
+ # JSON output includes: branching_strategy, phase_branch_template, milestone_branch_template
170
+ ```
171
+
172
+ Or use `state load` for the config values:
173
+ ```bash
174
+ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" state load)
175
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
176
+ # Parse branching_strategy, phase_branch_template, milestone_branch_template from JSON
177
+ ```
178
+
179
+ **Branch creation:**
180
+
181
+ ```bash
182
+ # For phase strategy (code repos — product folder always uses main)
183
+ if [ "$BRANCHING_STRATEGY" = "phase" ]; then
184
+ PHASE_SLUG=$(echo "$PHASE_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
185
+ BRANCH_NAME=$(echo "$PHASE_BRANCH_TEMPLATE" | sed "s/{project}/$PROJECT_SLUG/g" | sed "s/{phase}/$PADDED_PHASE/g" | sed "s/{slug}/$PHASE_SLUG/g")
186
+ # In code repos: fetch and checkout base branch first
187
+ git fetch origin "$BASE_BRANCH" 2>/dev/null || true
188
+ git checkout "$BASE_BRANCH"
189
+ git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
190
+ fi
191
+
192
+ # For milestone strategy (code repos — product folder always uses main)
193
+ if [ "$BRANCHING_STRATEGY" = "milestone" ]; then
194
+ MILESTONE_SLUG=$(echo "$MILESTONE_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
195
+ BRANCH_NAME=$(echo "$MILESTONE_BRANCH_TEMPLATE" | sed "s/{project}/$PROJECT_SLUG/g" | sed "s/{milestone}/$MILESTONE_VERSION/g" | sed "s/{slug}/$MILESTONE_SLUG/g")
196
+ # In code repos: fetch and checkout base branch first
197
+ git fetch origin "$BASE_BRANCH" 2>/dev/null || true
198
+ git checkout "$BASE_BRANCH"
199
+ git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
200
+ fi
201
+ ```
202
+
203
+ **Merge options at complete-milestone:**
204
+
205
+ | Option | Git command | Result |
206
+ |--------|-------------|--------|
207
+ | Squash merge (recommended) | `git merge --squash` | Single clean commit per branch |
208
+ | Merge with history | `git merge --no-ff` | Preserves all individual commits |
209
+ | Delete without merging | `git branch -D` | Discard branch work |
210
+ | Keep branches | (none) | Manual handling later |
211
+
212
+ Squash merge is recommended — keeps main branch history clean while preserving the full development history in the branch (until deleted).
213
+
214
+ **Use cases:**
215
+
216
+ | Strategy | Best for |
217
+ |----------|----------|
218
+ | `none` | Solo development, simple projects |
219
+ | `phase` | Code review per phase, granular rollback, team collaboration |
220
+ | `milestone` | Release branches, staging environments, PR per version |
221
+
222
+ </branching_strategy_behavior>
223
+
224
+ </planning_config>
@@ -0,0 +1,162 @@
1
+ <questioning_guide>
2
+
3
+ Project initialization is dream extraction, not requirements gathering. You're helping the user discover and articulate what they want to build. This isn't a contract negotiation — it's collaborative thinking.
4
+
5
+ <philosophy>
6
+
7
+ **You are a thinking partner, not an interviewer.**
8
+
9
+ The user often has a fuzzy idea. Your job is to help them sharpen it. Ask questions that make them think "oh, I hadn't considered that" or "yes, that's exactly what I mean."
10
+
11
+ Don't interrogate. Collaborate. Don't follow a script. Follow the thread.
12
+
13
+ </philosophy>
14
+
15
+ <the_goal>
16
+
17
+ By the end of questioning, you need enough clarity to write a PROJECT.md that downstream phases can act on:
18
+
19
+ - **Research** needs: what domain to research, what the user already knows, what unknowns exist
20
+ - **Requirements** needs: clear enough vision to scope v1 features
21
+ - **Roadmap** needs: clear enough vision to decompose into phases, what "done" looks like
22
+ - **plan-phase** needs: specific requirements to break into tasks, context for implementation choices
23
+ - **execute-phase** needs: success criteria to verify against, the "why" behind requirements
24
+
25
+ A vague PROJECT.md forces every downstream phase to guess. The cost compounds.
26
+
27
+ </the_goal>
28
+
29
+ <how_to_question>
30
+
31
+ **Start open.** Let them dump their mental model. Don't interrupt with structure.
32
+
33
+ **Follow energy.** Whatever they emphasized, dig into that. What excited them? What problem sparked this?
34
+
35
+ **Challenge vagueness.** Never accept fuzzy answers. "Good" means what? "Users" means who? "Simple" means how?
36
+
37
+ **Make the abstract concrete.** "Walk me through using this." "What does that actually look like?"
38
+
39
+ **Clarify ambiguity.** "When you say Z, do you mean A or B?" "You mentioned X — tell me more."
40
+
41
+ **Know when to stop.** When you understand what they want, why they want it, who it's for, and what done looks like — offer to proceed.
42
+
43
+ </how_to_question>
44
+
45
+ <question_types>
46
+
47
+ Use these as inspiration, not a checklist. Pick what's relevant to the thread.
48
+
49
+ **Motivation — why this exists:**
50
+ - "What prompted this?"
51
+ - "What are you doing today that this replaces?"
52
+ - "What would you do if this existed?"
53
+
54
+ **Concreteness — what it actually is:**
55
+ - "Walk me through using this"
56
+ - "You said X — what does that actually look like?"
57
+ - "Give me an example"
58
+
59
+ **Clarification — what they mean:**
60
+ - "When you say Z, do you mean A or B?"
61
+ - "You mentioned X — tell me more about that"
62
+
63
+ **Success — how you'll know it's working:**
64
+ - "How will you know this is working?"
65
+ - "What does done look like?"
66
+
67
+ </question_types>
68
+
69
+ <using_askuserquestion>
70
+
71
+ Use AskUserQuestion to help users think by presenting concrete options to react to.
72
+
73
+ **Good options:**
74
+ - Interpretations of what they might mean
75
+ - Specific examples to confirm or deny
76
+ - Concrete choices that reveal priorities
77
+
78
+ **Bad options:**
79
+ - Generic categories ("Technical", "Business", "Other")
80
+ - Leading options that presume an answer
81
+ - Too many options (2-4 is ideal)
82
+ - Headers longer than 12 characters (hard limit — validation will reject them)
83
+
84
+ **Example — vague answer:**
85
+ User says "it should be fast"
86
+
87
+ - header: "Fast"
88
+ - question: "Fast how?"
89
+ - options: ["Sub-second response", "Handles large datasets", "Quick to build", "Let me explain"]
90
+
91
+ **Example — following a thread:**
92
+ User mentions "frustrated with current tools"
93
+
94
+ - header: "Frustration"
95
+ - question: "What specifically frustrates you?"
96
+ - options: ["Too many clicks", "Missing features", "Unreliable", "Let me explain"]
97
+
98
+ **Tip for users — modifying an option:**
99
+ Users who want a slightly modified version of an option can select "Other" and reference the option by number: `#1 but for finger joints only` or `#2 with pagination disabled`. This avoids retyping the full option text.
100
+
101
+ </using_askuserquestion>
102
+
103
+ <freeform_rule>
104
+
105
+ **When the user wants to explain freely, STOP using AskUserQuestion.**
106
+
107
+ If a user selects "Other" and their response signals they want to describe something in their own words (e.g., "let me describe it", "I'll explain", "something else", or any open-ended reply that isn't choosing/modifying an existing option), you MUST:
108
+
109
+ 1. **Ask your follow-up as plain text** — NOT via AskUserQuestion
110
+ 2. **Wait for them to type at the normal prompt**
111
+ 3. **Resume AskUserQuestion** only after processing their freeform response
112
+
113
+ The same applies if YOU include a freeform-indicating option (like "Let me explain" or "Describe in detail") and the user selects it.
114
+
115
+ **Wrong:** User says "let me describe it" → AskUserQuestion("What feature?", ["Feature A", "Feature B", "Describe in detail"])
116
+ **Right:** User says "let me describe it" → "Go ahead — what are you thinking?"
117
+
118
+ </freeform_rule>
119
+
120
+ <context_checklist>
121
+
122
+ Use this as a **background checklist**, not a conversation structure. Check these mentally as you go. If gaps remain, weave questions naturally.
123
+
124
+ - [ ] What they're building (concrete enough to explain to a stranger)
125
+ - [ ] Why it needs to exist (the problem or desire driving it)
126
+ - [ ] Who it's for (even if just themselves)
127
+ - [ ] What "done" looks like (observable outcomes)
128
+
129
+ Four things. If they volunteer more, capture it.
130
+
131
+ </context_checklist>
132
+
133
+ <decision_gate>
134
+
135
+ When you could write a clear PROJECT.md, offer to proceed:
136
+
137
+ - header: "Ready?"
138
+ - question: "I think I understand what you're after. Ready to create PROJECT.md?"
139
+ - options:
140
+ - "Create PROJECT.md" — Let's move forward
141
+ - "Keep exploring" — I want to share more / ask me more
142
+
143
+ If "Keep exploring" — ask what they want to add or identify gaps and probe naturally.
144
+
145
+ Loop until "Create PROJECT.md" selected.
146
+
147
+ </decision_gate>
148
+
149
+ <anti_patterns>
150
+
151
+ - **Checklist walking** — Going through domains regardless of what they said
152
+ - **Canned questions** — "What's your core value?" "What's out of scope?" regardless of context
153
+ - **Corporate speak** — "What are your success criteria?" "Who are your stakeholders?"
154
+ - **Interrogation** — Firing questions without building on answers
155
+ - **Rushing** — Minimizing questions to get to "the work"
156
+ - **Shallow acceptance** — Taking vague answers without probing
157
+ - **Premature constraints** — Asking about tech stack before understanding the idea
158
+ - **User skills** — NEVER ask about user's technical experience. Claude builds.
159
+
160
+ </anti_patterns>
161
+
162
+ </questioning_guide>
@@ -0,0 +1,177 @@
1
+ # Spec Review Loop Reference
2
+
3
+ ## Overview
4
+ The review loop sends the spec to external LLM reviewers (OpenAI, Gemini) and processes their feedback autonomously until convergence. This reference is loaded by the write-spec workflow and provides all the details Claude needs to execute the review loop.
5
+
6
+ ## Loading Review Configuration
7
+
8
+ ```bash
9
+ REVIEW_CONFIG=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs review-config)
10
+ ```
11
+
12
+ Parse JSON: `{ reviewers: { openai: { api_key, model }, gemini: { api_key, model } }, max_rounds, has_any_key }`.
13
+
14
+ If `has_any_key = false`: warn "No review API keys configured. Edit review-keys.json in your planning root to add OpenAI or Gemini keys. Skipping review." and exit the review loop.
15
+
16
+ ## API Call Patterns
17
+
18
+ ### OpenAI Chat Completions
19
+
20
+ Write the JSON payload to a temp file to avoid shell quoting issues with markdown content, then use `curl -d @file`:
21
+
22
+ ```bash
23
+ python3 -c "
24
+ import sys, json
25
+ spec = sys.stdin.read()
26
+ payload = {
27
+ 'model': '$MODEL',
28
+ 'messages': [
29
+ {'role': 'system', 'content': 'You are a senior product manager reviewing a PRD spec. Provide specific, actionable feedback organized by section. For each item, indicate severity: [critical], [important], or [suggestion]. If the spec is solid, respond with only: LGTM - no changes needed.'},
30
+ {'role': 'user', 'content': 'Review this PRD spec:\n\n' + spec}
31
+ ],
32
+ 'temperature': 0.3
33
+ }
34
+ json.dump(payload, open('/tmp/dgs-review-openai.json', 'w'))
35
+ " < "$SPEC_FILE"
36
+
37
+ curl -s https://api.openai.com/v1/chat/completions \
38
+ -H "Authorization: Bearer $OPENAI_API_KEY" \
39
+ -H "Content-Type: application/json" \
40
+ -d @/tmp/dgs-review-openai.json
41
+
42
+ rm -f /tmp/dgs-review-openai.json
43
+ ```
44
+
45
+ Parse response: extract `choices[0].message.content` for feedback, `usage.prompt_tokens` and `usage.completion_tokens` for token tracking.
46
+
47
+ ### Google Gemini
48
+
49
+ Write the JSON payload to a temp file to avoid shell quoting issues with markdown content, then use `curl -d @file`:
50
+
51
+ ```bash
52
+ python3 -c "
53
+ import sys, json
54
+ spec = sys.stdin.read()
55
+ payload = {
56
+ 'contents': [{'parts': [{'text': 'You are a senior product manager reviewing a PRD spec. Provide specific, actionable feedback organized by section. For each item, indicate severity: [critical], [important], or [suggestion]. If the spec is solid, respond with only: LGTM - no changes needed.\n\nReview this PRD spec:\n\n' + spec}]}],
57
+ 'generationConfig': {'temperature': 0.3}
58
+ }
59
+ json.dump(payload, open('/tmp/dgs-review-gemini.json', 'w'))
60
+ " < "$SPEC_FILE"
61
+
62
+ curl -s "https://generativelanguage.googleapis.com/v1beta/models/$MODEL:generateContent?key=$GEMINI_API_KEY" \
63
+ -H "Content-Type: application/json" \
64
+ -d @/tmp/dgs-review-gemini.json
65
+
66
+ rm -f /tmp/dgs-review-gemini.json
67
+ ```
68
+
69
+ Parse response: extract `candidates[0].content.parts[0].text` for feedback, `usageMetadata.promptTokenCount` and `usageMetadata.candidatesTokenCount` for token tracking.
70
+
71
+ ## Sending Reviews in Parallel
72
+
73
+ Both API calls should be made concurrently. Use two Bash tool calls issued in parallel. If one fails, the other's result is still usable.
74
+
75
+ ## Error Handling & Retry
76
+
77
+ For each reviewer:
78
+
79
+ 1. First attempt: make API call.
80
+ 2. If HTTP error or malformed response: retry once after 2 seconds.
81
+ 3. If retry also fails: mark reviewer as `failed` for this round.
82
+ 4. If both reviewers fail in a round: exit loop, warn user "Both reviewers unavailable. Review skipped."
83
+ 5. If one reviewer fails: continue with the other reviewer's feedback only.
84
+
85
+ ## Feedback Processing
86
+
87
+ ### Parse Feedback Items
88
+
89
+ Extract individual feedback items from each reviewer's response. Each item has:
90
+
91
+ - `section`: which PRD section it targets
92
+ - `severity`: critical, important, or suggestion
93
+ - `feedback`: the actual feedback text
94
+ - `reviewer`: openai or gemini
95
+
96
+ ### Auto-Reject Non-Goal Contradictions (SPEC-04)
97
+
98
+ For each feedback item, check if it contradicts a stated Non-Goal:
99
+
100
+ 1. Read the `## Non-Goals` section from the spec.
101
+ 2. If a feedback item suggests adding something explicitly listed as a Non-Goal, reject it.
102
+ 3. Disposition: `rejected-non-goal` with reason "Contradicts Non-Goal: [quoted non-goal]".
103
+
104
+ ### Apply Accepted Feedback
105
+
106
+ For accepted feedback items:
107
+
108
+ 1. Claude reads each item and decides whether to apply it by modifying the spec.
109
+ 2. If the change is warranted: update the relevant section in the spec body.
110
+ 3. Disposition: `accepted` with brief description of change made.
111
+ 4. If the feedback is already addressed or too vague: disposition `no-action` with reason.
112
+
113
+ ### Convergence Detection (SPEC-06)
114
+
115
+ Track rejected items across rounds. If an item (or substantially similar item) is rejected in 2+ consecutive rounds:
116
+
117
+ 1. Move the item's core concern to the `## Open Questions` section.
118
+ 2. Tag it: "From review: [summarized concern]"
119
+ 3. Disposition: `moved-to-open-questions`.
120
+
121
+ This prevents infinite loops where reviewers keep suggesting the same rejected change.
122
+
123
+ ## Exit Conditions (SPEC-05)
124
+
125
+ After each round, check:
126
+
127
+ 1. **No changes applied**: all feedback items were either rejected, already addressed, or too vague. EXIT.
128
+ 2. **Green-only**: all reviewers responded with "LGTM" or equivalent (no actionable feedback). EXIT.
129
+ 3. **Max rounds reached**: round number >= max_rounds from config. EXIT.
130
+
131
+ If none met: start next round with the updated spec.
132
+
133
+ ## Review History Format (SPEC-07)
134
+
135
+ After the loop completes, append Review History to the spec:
136
+
137
+ ```markdown
138
+ ### Round 1
139
+ **Reviewers:** OpenAI (gpt-5-mini), Gemini (gemini-2.5-flash)
140
+ **Changes applied:** 3 | **Rejected:** 1 (non-goal) | **No action:** 2
141
+
142
+ | # | Section | Severity | Disposition | Detail |
143
+ |---|---------|----------|-------------|--------|
144
+ | 1 | Requirements | critical | accepted | Added error handling requirement to P0 |
145
+ | 2 | Non-Goals | important | rejected-non-goal | Contradicts "No dark mode" |
146
+ | 3 | User Stories | suggestion | accepted | Added admin user story |
147
+
148
+ ### Round 2
149
+ ...
150
+ ```
151
+
152
+ Append via:
153
+
154
+ ```bash
155
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs specs append-review --id "$SPEC_ID" --entry "$HISTORY_MD"
156
+ ```
157
+
158
+ ## Token & Cost Tracking (SPEC-14)
159
+
160
+ Track cumulative tokens across all rounds:
161
+
162
+ - `total_prompt_tokens`: sum of all prompt tokens
163
+ - `total_completion_tokens`: sum of all completion tokens
164
+ - Per reviewer: `openai_tokens`, `gemini_tokens`
165
+
166
+ Approximate cost calculation (use current API pricing as estimates):
167
+
168
+ - OpenAI gpt-5-mini: ~$2.50/1M input, ~$10.00/1M output
169
+ - Gemini gemini-2.5-flash: ~$0.075/1M input, ~$0.30/1M output
170
+
171
+ Display at end of review loop:
172
+
173
+ ```
174
+ Review complete (N rounds).
175
+ Tokens: OpenAI [X prompt + Y completion] | Gemini [X prompt + Y completion]
176
+ Estimated cost: ~$X.XX
177
+ ```