@ktpartners/dgs-platform 2.9.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/CHANGELOG.md +197 -0
  2. package/README.md +34 -2
  3. package/agents/dgs-executor.md +124 -3
  4. package/agents/dgs-idea-researcher.md +447 -0
  5. package/agents/dgs-plan-checker.md +61 -3
  6. package/agents/dgs-planner.md +51 -8
  7. package/bin/install.js +44 -0
  8. package/commands/dgs/abandon-quick.md +28 -0
  9. package/commands/dgs/add-tests.md +2 -2
  10. package/commands/dgs/audit-milestone.md +4 -3
  11. package/commands/dgs/capture-principle.md +11 -11
  12. package/commands/dgs/cleanup.md +2 -2
  13. package/commands/dgs/complete-milestone.md +11 -11
  14. package/commands/dgs/complete-quick.md +28 -0
  15. package/commands/dgs/create-milestone-job.md +2 -2
  16. package/commands/dgs/debug.md +3 -3
  17. package/commands/dgs/develop-idea.md +1 -1
  18. package/commands/dgs/diff-report.md +124 -0
  19. package/commands/dgs/fast.md +3 -1
  20. package/commands/dgs/health.md +1 -1
  21. package/commands/dgs/map-codebase.md +6 -6
  22. package/commands/dgs/new-milestone.md +5 -5
  23. package/commands/dgs/new-project.md +8 -21
  24. package/commands/dgs/package-scan.md +43 -0
  25. package/commands/dgs/plan-milestone-gaps.md +1 -1
  26. package/commands/dgs/progress.md +3 -3
  27. package/commands/dgs/quick-abandon.md +8 -0
  28. package/commands/dgs/quick-complete.md +8 -0
  29. package/commands/dgs/quick.md +10 -3
  30. package/commands/dgs/research-idea.md +3 -2
  31. package/commands/dgs/research-phase.md +3 -3
  32. package/commands/dgs/switch-project.md +14 -1
  33. package/commands/dgs/write-spec.md +3 -3
  34. package/deliver-great-systems/bin/dgs-tools.cjs +401 -32
  35. package/deliver-great-systems/bin/lib/audit-tolerance.cjs +77 -0
  36. package/deliver-great-systems/bin/lib/audit-tolerance.test.cjs +101 -0
  37. package/deliver-great-systems/bin/lib/commands.cjs +626 -46
  38. package/deliver-great-systems/bin/lib/commands.test.cjs +451 -0
  39. package/deliver-great-systems/bin/lib/commit-verify.test.cjs +236 -0
  40. package/deliver-great-systems/bin/lib/config.cjs +80 -6
  41. package/deliver-great-systems/bin/lib/config.test.cjs +309 -0
  42. package/deliver-great-systems/bin/lib/context.cjs +120 -0
  43. package/deliver-great-systems/bin/lib/core.cjs +35 -14
  44. package/deliver-great-systems/bin/lib/core.test.cjs +79 -1
  45. package/deliver-great-systems/bin/lib/execution.cjs +49 -17
  46. package/deliver-great-systems/bin/lib/fast-routing.cjs +199 -0
  47. package/deliver-great-systems/bin/lib/fast-routing.test.cjs +108 -0
  48. package/deliver-great-systems/bin/lib/final-commit-precondition.test.cjs +87 -0
  49. package/deliver-great-systems/bin/lib/fixtures/package-scan/bundler-audit-gemfile.json +21 -0
  50. package/deliver-great-systems/bin/lib/fixtures/package-scan/gate-parity-expected.md +186 -0
  51. package/deliver-great-systems/bin/lib/fixtures/package-scan/gate-parity-runresult.json +235 -0
  52. package/deliver-great-systems/bin/lib/fixtures/package-scan/govulncheck-import.json +3 -0
  53. package/deliver-great-systems/bin/lib/fixtures/package-scan/npm-audit-v10.json +37 -0
  54. package/deliver-great-systems/bin/lib/fixtures/package-scan/osv-clean.json +3 -0
  55. package/deliver-great-systems/bin/lib/fixtures/package-scan/osv-vulns.json +77 -0
  56. package/deliver-great-systems/bin/lib/fixtures/package-scan/pip-audit-requirements.json +28 -0
  57. package/deliver-great-systems/bin/lib/fixtures/package-scan/snyk-lodash.json +30 -0
  58. package/deliver-great-systems/bin/lib/fixtures/package-scan/snyk-workspaces.json +55 -0
  59. package/deliver-great-systems/bin/lib/flat-migration.test.cjs +396 -0
  60. package/deliver-great-systems/bin/lib/frontmatter.cjs +1 -1
  61. package/deliver-great-systems/bin/lib/governance.cjs +211 -0
  62. package/deliver-great-systems/bin/lib/governance.test.cjs +339 -0
  63. package/deliver-great-systems/bin/lib/health-untracked-phase.test.cjs +269 -0
  64. package/deliver-great-systems/bin/lib/ideas.cjs +206 -91
  65. package/deliver-great-systems/bin/lib/ideas.test.cjs +244 -1
  66. package/deliver-great-systems/bin/lib/init.cjs +357 -61
  67. package/deliver-great-systems/bin/lib/init.test.cjs +625 -8
  68. package/deliver-great-systems/bin/lib/jobs.cjs +131 -25
  69. package/deliver-great-systems/bin/lib/jobs.test.cjs +193 -74
  70. package/deliver-great-systems/bin/lib/migration.cjs +409 -1
  71. package/deliver-great-systems/bin/lib/migration.test.cjs +158 -1
  72. package/deliver-great-systems/bin/lib/milestone.cjs +154 -31
  73. package/deliver-great-systems/bin/lib/milestone.test.cjs +203 -0
  74. package/deliver-great-systems/bin/lib/package-adapters.cjs +530 -0
  75. package/deliver-great-systems/bin/lib/package-adapters.test.cjs +618 -0
  76. package/deliver-great-systems/bin/lib/package-ecosystems.cjs +350 -0
  77. package/deliver-great-systems/bin/lib/package-ecosystems.test.cjs +348 -0
  78. package/deliver-great-systems/bin/lib/package-runner.cjs +199 -0
  79. package/deliver-great-systems/bin/lib/package-runner.test.cjs +198 -0
  80. package/deliver-great-systems/bin/lib/package-scan-provenance.cjs +56 -0
  81. package/deliver-great-systems/bin/lib/package-scan-provenance.test.cjs +103 -0
  82. package/deliver-great-systems/bin/lib/package-scan-report.cjs +1140 -0
  83. package/deliver-great-systems/bin/lib/package-scan-report.test.cjs +1963 -0
  84. package/deliver-great-systems/bin/lib/package-scan-skill.cjs +96 -0
  85. package/deliver-great-systems/bin/lib/package-scan-skill.test.cjs +136 -0
  86. package/deliver-great-systems/bin/lib/package-scan.cjs +919 -0
  87. package/deliver-great-systems/bin/lib/package-scan.test.cjs +2147 -0
  88. package/deliver-great-systems/bin/lib/phase.cjs +146 -3
  89. package/deliver-great-systems/bin/lib/phase.test.cjs +420 -0
  90. package/deliver-great-systems/bin/lib/plan-number-validity.test.cjs +48 -0
  91. package/deliver-great-systems/bin/lib/projects.cjs +65 -10
  92. package/deliver-great-systems/bin/lib/projects.test.cjs +198 -2
  93. package/deliver-great-systems/bin/lib/quick.cjs +739 -0
  94. package/deliver-great-systems/bin/lib/quick.test.cjs +730 -0
  95. package/deliver-great-systems/bin/lib/repos.cjs +37 -13
  96. package/deliver-great-systems/bin/lib/review.cjs +1821 -0
  97. package/deliver-great-systems/bin/lib/roadmap.cjs +34 -13
  98. package/deliver-great-systems/bin/lib/specs.cjs +3 -81
  99. package/deliver-great-systems/bin/lib/state-transition-gate.test.cjs +160 -0
  100. package/deliver-great-systems/bin/lib/state.cjs +147 -55
  101. package/deliver-great-systems/bin/lib/summary-frontmatter.cjs +54 -0
  102. package/deliver-great-systems/bin/lib/summary-frontmatter.test.cjs +78 -0
  103. package/deliver-great-systems/bin/lib/sweep-scope.test.cjs +263 -0
  104. package/deliver-great-systems/bin/lib/sync.cjs +75 -0
  105. package/deliver-great-systems/bin/lib/verify.cjs +198 -7
  106. package/deliver-great-systems/bin/lib/verify.test.cjs +82 -0
  107. package/deliver-great-systems/bin/lib/wave-0-template-rename.test.cjs +40 -0
  108. package/deliver-great-systems/bin/lib/worktrees.cjs +790 -0
  109. package/deliver-great-systems/bin/lib/worktrees.test.cjs +963 -0
  110. package/deliver-great-systems/references/agent-step-reliability.md +60 -0
  111. package/deliver-great-systems/references/conflict-resolution.md +4 -0
  112. package/deliver-great-systems/references/context-tiers.md +4 -0
  113. package/deliver-great-systems/references/package-scan-config.md +151 -0
  114. package/deliver-great-systems/references/questioning.md +0 -30
  115. package/deliver-great-systems/references/spec-review-loop.md +1 -2
  116. package/deliver-great-systems/references/workflow-conventions.md +29 -0
  117. package/deliver-great-systems/skills/dgs-tests/package-scan.md +44 -0
  118. package/deliver-great-systems/templates/REVIEW.md +35 -0
  119. package/deliver-great-systems/templates/VALIDATION.md +1 -1
  120. package/deliver-great-systems/templates/claude-md.md +27 -0
  121. package/deliver-great-systems/templates/package-scan-report.md +108 -0
  122. package/deliver-great-systems/templates/project.md +6 -170
  123. package/deliver-great-systems/templates/summary.md +3 -1
  124. package/deliver-great-systems/workflows/abandon-quick.md +89 -0
  125. package/deliver-great-systems/workflows/add-idea.md +3 -3
  126. package/deliver-great-systems/workflows/add-phase.md +5 -0
  127. package/deliver-great-systems/workflows/add-tests.md +14 -0
  128. package/deliver-great-systems/workflows/add-todo.md +1 -0
  129. package/deliver-great-systems/workflows/approve-spec.md +25 -4
  130. package/deliver-great-systems/workflows/audit-milestone.md +66 -10
  131. package/deliver-great-systems/workflows/audit-phase.md +15 -5
  132. package/deliver-great-systems/workflows/cancel-job.md +2 -2
  133. package/deliver-great-systems/workflows/check-todos.md +2 -3
  134. package/deliver-great-systems/workflows/codereview.md +103 -9
  135. package/deliver-great-systems/workflows/complete-milestone.md +218 -24
  136. package/deliver-great-systems/workflows/complete-quick.md +106 -0
  137. package/deliver-great-systems/workflows/consolidate-ideas.md +1 -1
  138. package/deliver-great-systems/workflows/create-milestone-job.md +4 -4
  139. package/deliver-great-systems/workflows/develop-idea.md +11 -11
  140. package/deliver-great-systems/workflows/diagnose-issues.md +14 -0
  141. package/deliver-great-systems/workflows/discuss-idea.md +1 -1
  142. package/deliver-great-systems/workflows/discuss-phase.md +3 -2
  143. package/deliver-great-systems/workflows/execute-phase.md +209 -33
  144. package/deliver-great-systems/workflows/execute-plan.md +22 -22
  145. package/deliver-great-systems/workflows/help.md +53 -20
  146. package/deliver-great-systems/workflows/import-spec.md +65 -7
  147. package/deliver-great-systems/workflows/init-product.md +45 -167
  148. package/deliver-great-systems/workflows/new-milestone.md +140 -33
  149. package/deliver-great-systems/workflows/new-project.md +60 -331
  150. package/deliver-great-systems/workflows/package-scan.md +59 -0
  151. package/deliver-great-systems/workflows/plan-phase.md +79 -1
  152. package/deliver-great-systems/workflows/progress-all.md +133 -0
  153. package/deliver-great-systems/workflows/quick-abandon.md +89 -0
  154. package/deliver-great-systems/workflows/quick-complete.md +106 -0
  155. package/deliver-great-systems/workflows/quick.md +328 -26
  156. package/deliver-great-systems/workflows/refine-spec.md +1 -1
  157. package/deliver-great-systems/workflows/research-idea.md +77 -139
  158. package/deliver-great-systems/workflows/resume-project.md +2 -2
  159. package/deliver-great-systems/workflows/run-job.md +29 -43
  160. package/deliver-great-systems/workflows/settings.md +13 -77
  161. package/deliver-great-systems/workflows/validate-phase.md +39 -1
  162. package/deliver-great-systems/workflows/verify-work.md +14 -0
  163. package/deliver-great-systems/workflows/write-spec.md +11 -13
  164. package/hooks/dist/dgs-enforce-discipline.js +196 -0
  165. package/package.json +1 -1
  166. package/scripts/build-hooks.js +1 -0
@@ -1,9 +1,9 @@
1
1
  <purpose>
2
- Subagent-driven research workflow that investigates an idea's feasibility and technical landscape across five adaptive dimensions. Claude acts as an analyst -- purposeful and efficient, adapting depth to what the idea actually needs rather than running a checklist.
2
+ Subagent-driven research workflow that investigates an idea's feasibility and technical landscape. The orchestrator parses arguments, loads idea context (body, discussion log, prior research, supporting docs, REPOS.md), spawns a dedicated `dgs-idea-researcher` subagent for the five adaptive research dimensions, then handles the Research Log entry, git commit, and next-step suggestion. The orchestrator keeps its own context clean dimension prose and retrieved web/codebase content stay inside the subagent.
3
3
 
4
4
  Produces a structured research document at `${project_root}/docs/ideas/pending/{slug}-research.md` and appends a Research Log entry to the idea file. Commits both files together and suggests the next step based on findings.
5
5
 
6
- When re-researching a previously-researched idea, the document is overwritten with a "Changes from Prior Research" section highlighting what shifted. Each re-research appends a fresh Research Log entry.
6
+ When re-researching a previously-researched idea, the subagent overwrites the document and emits a "Changes from Prior Research" section only when meaningful differences exist. Each re-research appends a fresh Research Log entry.
7
7
  </purpose>
8
8
 
9
9
  <context_tier>planning</context_tier>
@@ -86,7 +86,7 @@ Also check for prior research document:
86
86
  SLUG=$(echo "${filename}" | sed 's/^[0-9]*-//' | sed 's/\.md$//')
87
87
  RESEARCH_DOC="${project_root}/docs/ideas/pending/${SLUG}-research.md"
88
88
  ```
89
- If the research document file exists, read it for prior research context.
89
+ If the research document file exists, note its path so the subagent can read it for re-research diffing.
90
90
 
91
91
  **Load idea supporting documents:**
92
92
 
@@ -98,7 +98,7 @@ IDEA_DOCS_DIR="${IDEA_DIR}/docs"
98
98
 
99
99
  If a flat structure is used (ideas stored as files, not directories), derive from the filename:
100
100
  ```bash
101
- IDEA_DOCS_DIR="${project_root}/docs/ideas/pending/${SLUG}"
101
+ IDEA_DOCS_DIR="${project_root}/docs/ideas/${SLUG}"
102
102
  ```
103
103
 
104
104
  Check both paths. Use whichever exists.
@@ -126,154 +126,92 @@ cat ${project_root}/REPOS.md 2>/dev/null
126
126
  If REPOS.md exists and has entries, this is a multi-repo project -- research should be partitioned by repo where relevant.
127
127
  </step>
128
128
 
129
- <step name="research_context">
130
- Assess the idea and decide research strategy:
129
+ <step name="spawn_researcher">
130
+ Resolve the model for the idea-researcher subagent. The `resolve-model` CLI subcommand on `dgs-tools.cjs` emits JSON (`{"model": "...", "profile": "..."}`) — pipe through `jq -r .model` to extract the bare model string:
131
131
 
132
- 1. **Announce focus**: Print one line explaining which dimensions matter most for this idea and why. E.g.: "Focusing on landscape survey and codebase analysis -- this idea involves integrating with existing patterns."
133
-
134
- 2. **Read Discussion Log** if present -- use discussion insights (refined problem, approach, open questions) to guide research focus areas.
135
-
136
- 3. **Read prior research** if present -- note what was found before. On re-research, Claude will overwrite the document but should note what changed.
137
-
138
- 4. **Read supporting documents** if `ideaDocs` is not empty -- review loaded text files, diagrams, and other supporting materials. These may reveal additional context about the idea's scope, architecture requirements, or prior art that inform the research focus areas.
139
-
140
- 5. **Determine repo scope**: If REPOS.md exists, identify which repos are relevant to this idea. If no REPOS.md, treat as single-repo research.
141
- </step>
142
-
143
- <step name="web_search">
144
- **Dimension 1: Web Search**
145
-
146
- Announce: "Searching web for prior art and technical landscape..."
147
-
148
- Use WebSearch and WebFetch to investigate:
149
- - How others have solved similar problems
150
- - Existing libraries, tools, or frameworks relevant to the idea
151
- - Common patterns and anti-patterns
152
- - Recent discussions or blog posts
153
-
154
- Adapt depth to what the idea needs -- a well-understood problem gets a quick scan, a novel idea gets broader exploration. If web search yields little, note the gap and move on.
155
-
156
- Web search is best-effort -- search what's findable, note gaps, move on. Don't burn time on thin topics.
157
- </step>
158
-
159
- <step name="codebase_analysis">
160
- **Dimension 2: Codebase Analysis**
161
-
162
- Announce: "Analyzing codebase for related implementations..."
163
-
164
- Use Grep and Glob to examine:
165
- - Existing code that relates to the idea's domain
166
- - Patterns already established that would apply
167
- - Potential conflicts or integration points
168
- - Code that would need to change
169
-
170
- For multi-repo projects: analyze each relevant repo separately, noting repo-specific patterns and concerns.
171
- </step>
172
-
173
- <step name="landscape_survey">
174
- **Dimension 3: Landscape Survey**
175
-
176
- Announce: "Surveying technical landscape..."
177
-
178
- Build comparison information for relevant tools/libraries/approaches:
179
- - For obvious choices (one clear winner): brief verdict with reasoning
180
- - For genuine tradeoffs: table with pros, cons, license, maintenance status, compatibility
181
- - Per repo stack for multi-repo projects
182
-
183
- Recommend when clear -- strong recommendation when one option is clearly better, present options neutrally when it's genuinely a toss-up.
184
- </step>
185
-
186
- <step name="approaches">
187
- **Dimension 4: Approaches & Patterns**
188
-
189
- Announce: "Identifying approaches and patterns..."
190
-
191
- Identify how similar problems have been solved:
192
- - Architectural patterns that apply
193
- - Implementation strategies
194
- - Sequencing (what to build first)
195
- - What to avoid and why
196
- </step>
197
-
198
- <step name="feasibility">
199
- **Dimension 5: Feasibility Assessment**
200
-
201
- Announce: "Assessing feasibility..."
202
-
203
- Assess:
204
- - **Stack fit**: How well does this fit the existing technology stack?
205
- - **Effort estimate**: T-shirt size (S/M/L/XL) + approximate phase count
206
- - **Key risks**: What could go wrong? What are the unknowns?
207
- - **New dependencies**: Any new libraries, services, or external integrations needed?
208
- - **Recommendation**: Overall go/no-go/conditional assessment
209
- </step>
210
-
211
- <step name="write_document">
212
- Create (or overwrite) the research document.
213
-
214
- Ensure directory exists:
215
132
  ```bash
216
- mkdir -p ${project_root}/docs/ideas/pending
133
+ IDEA_RESEARCHER_MODEL=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs resolve-model dgs-idea-researcher | jq -r .model)
217
134
  ```
218
135
 
219
- Write the research document to `${project_root}/docs/ideas/pending/${SLUG}-research.md` using the Write tool.
220
-
221
- **Document structure:**
222
- ```markdown
223
- ---
224
- type: research
225
- idea_id: {id}
226
- idea_title: "{title}"
227
- date: "{YYYY-MM-DD}"
228
- repos_analysed: ["{repo1}", "{repo2}"]
229
- ---
230
-
231
- # Research: {title}
232
-
233
- {If re-research and meaningful changes exist:}
234
- ## Changes from Prior Research
235
-
236
- {Bullet list of what's new, updated, or contradicted vs prior findings. Include when there are meaningful differences from prior research, skip when findings are similar.}
136
+ The MODEL_PROFILES entry resolves to `inherit` (quality profile), `sonnet` (balanced), or `haiku` (budget) based on the project's `model_profile` config. (Note: wiring `idea_researcher_model` directly into init.cjs — so the orchestrator could read it from init JSON, mirroring `researcher_model` in plan-phase — is a follow-up. The CLI invocation above is the canonical resolution path here.)
237
137
 
238
- ## Web Search Findings
138
+ Build the research prompt with all loaded context. Inline the idea content; pass paths for files the subagent should Read itself:
239
139
 
240
- {Findings from Dimension 1}
241
-
242
- ## Codebase Analysis
243
-
244
- {Findings from Dimension 2. For multi-repo: subsections per repo.}
245
-
246
- ## Landscape Survey
247
-
248
- {Findings from Dimension 3. Comparison tables where applicable.}
249
-
250
- ## Approaches & Patterns
251
-
252
- {Findings from Dimension 4}
253
-
254
- ## Feasibility Assessment
140
+ ```markdown
141
+ <objective>
142
+ Research idea #${id}: ${title}
143
+ Answer: "Is this idea feasible? What's the technical landscape and recommended approach?"
144
+ </objective>
145
+
146
+ <files_to_read>
147
+ {If prior research exists:} ${RESEARCH_DOC}
148
+ {If discussion log file exists separately, pass its path; otherwise the discussion log is inlined in <idea_content> below.}
149
+ {For each ideaDoc loaded: pass its path}
150
+ {If REPOS.md exists:} ${project_root}/REPOS.md
151
+ </files_to_read>
152
+
153
+ <idea_content>
154
+ **Title:** ${title}
155
+ **Tags:** ${tags}
156
+ **Body:**
157
+ ${body}
158
+
159
+ {If notes:} **Notes:** ${notes}
160
+
161
+ {If discussionLog:} **Discussion Log:**
162
+ ${discussionLog}
163
+ </idea_content>
164
+
165
+ <prior_research>
166
+ {If prior research doc exists:}
167
+ Prior research at `${RESEARCH_DOC}` — read it before researching, then include a `## Changes from Prior Research` section in the new doc ONLY when meaningful differences exist. Omit the section when findings are substantially the same.
168
+ {Otherwise:}
169
+ No prior research.
170
+ </prior_research>
171
+
172
+ <supporting_docs>
173
+ {If ideaDocs non-empty:}
174
+ The following per-idea supporting documents were loaded by the orchestrator; their paths are listed in <files_to_read>. Brief summaries: {list path + 1-line summary per doc}.
175
+ {Otherwise:}
176
+ None
177
+ </supporting_docs>
178
+
179
+ <repos>
180
+ {If REPOS.md exists:}
181
+ Multi-repo project. Repos: {list repo names from REPOS.md}. Partition Codebase Analysis (Dimension 2) by repo, and provide per-repo stack recommendations in the Landscape Survey (Dimension 3) where relevant.
182
+ {Otherwise:}
183
+ Single-repo project — no partitioning needed.
184
+ </repos>
185
+
186
+ <output>
187
+ Write the research document to: ${project_root}/docs/ideas/pending/${SLUG}-research.md
188
+
189
+ `mkdir -p ${project_root}/docs/ideas/pending` first if the directory doesn't exist.
190
+
191
+ Return a `## RESEARCH COMPLETE` block with: key findings (3-5 bullets), recommendation, document path, outcome (one of: "Ready for spec" / "Needs more discussion" / "Not feasible" / "Other: {short label}").
192
+ </output>
193
+ ```
255
194
 
256
- **Stack Fit:** {assessment}
257
- **Effort:** {T-shirt size} -- {phase count estimate}
258
- **Key Risks:**
259
- {bullet list}
260
- **New Dependencies:**
261
- {bullet list or "None"}
262
- **Recommendation:** {go / no-go / conditional with conditions}
195
+ Spawn the subagent:
263
196
 
264
- ---
265
- *Researched: {YYYY-MM-DD}*
197
+ ```
198
+ Task(
199
+ prompt=research_prompt,
200
+ subagent_type="dgs-idea-researcher",
201
+ model="${IDEA_RESEARCHER_MODEL}",
202
+ description="Research idea #${id}"
203
+ )
266
204
  ```
267
205
 
268
- For multi-repo projects, the Codebase Analysis and Landscape Survey sections should have `### {repo-name}` subsections.
269
-
270
- If repos_analysed is empty (no REPOS.md), omit the field from frontmatter or use an empty array.
206
+ Handle the return:
207
+ - **`## RESEARCH COMPLETE`**: extract `keyFindings`, `recommendation`, `outcome`, and the document path from the structured return. These flow into `save_research_log` as the entry JSON fields.
208
+ - **`## RESEARCH BLOCKED`**: display the blocker to the user, offer the options the subagent surfaced (provide context / abort). Do NOT proceed to `save_research_log` or `git_commit` until the blocker is resolved.
271
209
  </step>
272
210
 
273
211
  <step name="save_research_log">
274
212
  Save the Research Log entry to the idea file via the CLI command.
275
213
 
276
- Build the entry JSON:
214
+ Build the entry JSON from the subagent's structured return:
277
215
  ```json
278
216
  {
279
217
  "date": "YYYY-MM-DD",
@@ -296,7 +234,7 @@ Parse the JSON result to confirm success.
296
234
  <step name="git_commit">
297
235
  Commit both the research document and the updated idea file:
298
236
  ```bash
299
- 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}
237
+ 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/${filename}
300
238
  ```
301
239
  </step>
302
240
 
@@ -317,7 +255,7 @@ Suggest next step based on outcome:
317
255
 
318
256
  <success_criteria>
319
257
  - [ ] Idea loaded with full context (body, tags, notes, discussion log, research log)
320
- - [ ] Research dimensions executed with progress announcements
258
+ - [ ] `dgs-idea-researcher` subagent spawned with resolved model and a complete research prompt
321
259
  - [ ] Research document created at `${project_root}/docs/ideas/pending/{slug}-research.md` with frontmatter
322
260
  - [ ] Research Log entry saved to idea file via research-save CLI
323
261
  - [ ] Both files committed together
@@ -247,7 +247,7 @@ Based on user selection, route to appropriate workflow:
247
247
  ---
248
248
  ```
249
249
  - **Transition** → ./transition.md
250
- - **Check todos** → Read ${project_root}/todos/pending/, present summary
250
+ - **Check todos** → Run `node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" todos list --status pending`, present summary
251
251
  - **Review alignment** → Read PROJECT.md, compare to current state
252
252
  - **Something else** → Ask what they need
253
253
  </step>
@@ -278,7 +278,7 @@ If STATE.md is missing but other artifacts exist:
278
278
  1. Read PROJECT.md → Extract "What This Is" and Core Value
279
279
  2. Read ROADMAP.md → Determine phases, find current position
280
280
  3. Scan \*-SUMMARY.md files → Extract decisions, concerns
281
- 4. Count pending todos in ${project_root}/todos/pending/
281
+ 4. Count pending todos via `node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" todos list --status pending --count`
282
282
  5. Check for .continue-here files → Session continuity
283
283
 
284
284
  Reconstruct and write STATE.md, then proceed normally.
@@ -1,5 +1,5 @@
1
1
  <purpose>
2
- Execute a milestone build job end-to-end. Reads the job file, loops through pending steps, spawns an isolated subagent per step, updates the job file in real-time, handles failures with immediate halt, manages dynamic gap-fix cycles at both milestone level (GapFixCycle, max 3) and phase level (PhaseFixCycle, max 2), and moves completed jobs to the completed/ directory. Supports --dry-run mode for step preview without execution. Auto-generates job summaries on completion and failure.
2
+ Execute a milestone build job end-to-end. Reads the job file, loops through pending steps, spawns an isolated subagent per step, updates the job file in real-time, handles failures with immediate halt, manages dynamic gap-fix cycles at both milestone level (GapFixCycle, max 3) and phase level (PhaseFixCycle, max 2), and marks completed jobs with status: completed. Supports --dry-run mode for step preview without execution. Auto-generates job summaries on completion and failure.
3
3
 
4
4
  The orchestrator stays lean: it reads only the job file and MILESTONE-AUDIT.md (plus phase UAT status via CLI for phase-level audits). All actual work is delegated to subagents via Task tool. Each subagent gets a fresh context window with no shared state beyond what is on disk.
5
5
  </purpose>
@@ -106,7 +106,7 @@ Parse the JSON result.
106
106
  Error: No job found for version {VERSION}. Create one with /dgs:create-milestone-job {VERSION}
107
107
  ```
108
108
 
109
- **If found in `completed/` directory:**
109
+ **If found.status is 'completed':**
110
110
  ```
111
111
  Error: Job {VERSION} is already completed.
112
112
  ```
@@ -117,21 +117,14 @@ Store `JOB_PATH` from the result for all subsequent operations.
117
117
  <step name="move_to_in_progress">
118
118
  Transition the job to in-progress state if needed.
119
119
 
120
- **If job is in `pending/`:**
120
+ **If found.status is 'pending':**
121
121
 
122
- 1. Move the file to `in-progress/`:
122
+ 1. Set the job status to in-progress (updates both frontmatter and header):
123
123
  ```bash
124
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs move "$JOB_PATH" "${jobs_root}/in-progress"
124
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs set-status "$VERSION" --status in-progress
125
125
  ```
126
126
 
127
- 2. Update `JOB_PATH` to reflect the new location under `in-progress/`.
128
-
129
- 3. Update the header Status field (using the updated `$JOB_PATH`):
130
- ```bash
131
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs update-header "$JOB_PATH" Status in-progress
132
- ```
133
-
134
- **If already in `in-progress/`:** Skip the move. The job is being resumed.
127
+ **If found.status is already 'in-progress':** Skip. The job is being resumed.
135
128
 
136
129
  **Record starting commit SHAs:**
137
130
 
@@ -293,7 +286,7 @@ Loop through steps starting from `nextStepIndex`.
293
286
 
294
287
  **Mid-workflow push (after phase-completing steps):**
295
288
 
296
- After a step completes successfully, check if the step's command is a phase-completing workflow: `execute-phase`, `verify-work`, `audit-phase`, `audit-milestone`, `plan-phase`, `plan-milestone-gaps`, or `complete-milestone`.
289
+ After a step completes successfully, check if the step's command is a phase-completing workflow: `execute-phase`, `verify-work`, `audit-phase`, `audit-milestone`, `plan-phase`, `plan-milestone-gaps`, `validate-phase`, or `complete-milestone`.
297
290
 
298
291
  If so, and `sync_push` is not `"off"` and `cadence_push` is true:
299
292
  ```bash
@@ -332,13 +325,13 @@ Loop through steps starting from `nextStepIndex`.
332
325
  ```bash
333
326
  SUMMARY=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs generate-summary "$VERSION")
334
327
  ```
335
- Parse the result. If `found: true`, write the `content` field to `${jobs_root}/in-progress/job-{version}-SUMMARY.md` using the Write tool (job stays in in-progress/ on failure).
336
- Display: `Job summary written to ${jobs_root}/in-progress/job-{version}-SUMMARY.md`
328
+ Parse the result. If `found: true`, write the `content` field to `${jobs_root}/job-{version}-SUMMARY.md` using the Write tool (job stays in place on failure -- status is tracked in frontmatter).
329
+ Display: `Job summary written to ${jobs_root}/job-{version}-SUMMARY.md`
337
330
 
338
331
  **Commit and push failure summary:**
339
332
 
340
333
  ```bash
341
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(job): ${VERSION} failure summary" --files "${jobs_root}/in-progress/job-${VERSION}-SUMMARY.md" --push
334
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(job): ${VERSION} failure summary" --files "${jobs_root}/job-${VERSION}-SUMMARY.md" --push
342
335
  ```
343
336
 
344
337
  **HALT immediately.** Do not proceed to the next step.
@@ -359,11 +352,11 @@ After an `audit-milestone` step completes successfully, check the audit outcome.
359
352
 
360
353
  Note: --no-check jobs never trigger this code path because they have no audit-milestone step. The `check: false` header means no `audit-milestone` step is generated by `generateMilestoneSteps`, so handle_audit_result is never reached.
361
354
 
362
- Note: The original complete-milestone step (if present) remains at its position after the original
363
- audit step. Gap-fix steps (including re-audit) are inserted between the original audit step and
364
- complete-milestone. When the re-audit passes, the loop naturally reaches complete-milestone.
365
- If the re-audit finds MORE gaps, another cycle inserts steps after THAT re-audit, further
366
- deferring complete-milestone. This is correct -- complete-milestone only runs after a clean audit.
355
+ Note: audit-milestone is the last step of milestone jobs. complete-milestone is never
356
+ auto-run because it requires manual intervention (branch review, tag push, merge conflict
357
+ resolution). After audit passes, the job ends and the user runs /dgs:complete-milestone
358
+ manually. Gap-fix steps are inserted after the original audit step; when a re-audit passes,
359
+ the job completes and the user still runs complete-milestone manually.
367
360
 
368
361
  1. **Read audit status:**
369
362
  ```bash
@@ -378,9 +371,9 @@ deferring complete-milestone. This is correct -- complete-milestone only runs af
378
371
  ```
379
372
  - If `GAP_FIX_CYCLE == 0` (audit passed first time): Display clean banner:
380
373
  ```
381
- Audit passed -- no gaps found. Proceeding to complete milestone.
374
+ Audit passed -- no gaps found. Run /dgs:complete-milestone manually to archive.
382
375
  ```
383
- - Continue to the next step (should be `complete-milestone`).
376
+ - Job completes after this step. User runs /dgs:complete-milestone manually when ready.
384
377
 
385
378
  3. **If `gaps_found`:**
386
379
 
@@ -536,39 +529,32 @@ After an `audit-phase` step completes successfully, check the phase audit outcom
536
529
  <step name="complete_job">
537
530
  When all steps are completed (`nextStepIndex` is null after the loop):
538
531
 
539
- 1. **Update header Status to `completed`:**
532
+ 1. **Set job status to `completed`** (updates both frontmatter and header):
540
533
  ```bash
541
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs update-header "$JOB_PATH" Status completed
534
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs set-status "$VERSION" --status completed
542
535
  ```
543
536
 
544
- 2. **Move job to `completed/`:**
545
- ```bash
546
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs move "$JOB_PATH" "${jobs_root}/completed"
547
- ```
548
-
549
- Update `JOB_PATH` to reflect the new location under `completed/`.
550
-
551
537
  **Commit and push job status:**
552
538
 
553
539
  ```bash
554
- git add -A "$(dirname "$JOB_PATH")/../"
540
+ git add -A "$(dirname "$JOB_PATH")/"
555
541
  node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(job): ${VERSION} completed" --push
556
542
  ```
557
543
 
558
- 3. **Generate job summary:**
544
+ 2. **Generate job summary:**
559
545
  ```bash
560
546
  SUMMARY=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs jobs generate-summary "$VERSION")
561
547
  ```
562
- Parse the result. If `found: true`, write the `content` field to `${jobs_root}/completed/job-{version}-SUMMARY.md` using the Write tool.
563
- Display: `Job summary written to ${jobs_root}/completed/job-{version}-SUMMARY.md`
548
+ Parse the result. If `found: true`, write the `content` field to `${jobs_root}/job-{version}-SUMMARY.md` using the Write tool.
549
+ Display: `Job summary written to ${jobs_root}/job-{version}-SUMMARY.md`
564
550
 
565
551
  **Commit and push completion summary:**
566
552
 
567
553
  ```bash
568
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(job): ${VERSION} completion summary" --files "${jobs_root}/completed/job-${VERSION}-SUMMARY.md" --push
554
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(job): ${VERSION} completion summary" --files "${jobs_root}/job-${VERSION}-SUMMARY.md" --push
569
555
  ```
570
556
 
571
- 4. **Post-workflow push (sync_after):**
557
+ 3. **Post-workflow push (sync_after):**
572
558
 
573
559
  Follow the sync-hooks post-workflow push pattern with `WORKFLOW_NAME = "run-job"`:
574
560
 
@@ -582,7 +568,7 @@ When all steps are completed (`nextStepIndex` is null after the loop):
582
568
 
583
569
  Display aggregated push summary including any accumulated `SYNC_WARNINGS` from mid-workflow pushes.
584
570
 
585
- 5. **Display completion banner:**
571
+ 4. **Display completion banner:**
586
572
 
587
573
  If `AUTO_RESOLVE_COUNT` is 0:
588
574
  ```
@@ -617,11 +603,11 @@ The orchestrator MUST stay lean per EXEC-07:
617
603
  - [ ] Milestone audit gap-fix cycle auto-approved with 3-cycle safety limit
618
604
  - [ ] Phase audit gap-fix cycle auto-approved with 2-cycle safety limit
619
605
  - [ ] PhaseFixCycle counter resets on plan-phase/map-codebase steps
620
- - [ ] Completed jobs moved to completed/ directory with banner
606
+ - [ ] Completed jobs marked with status: completed with banner
621
607
  - [ ] Orchestrator reads only job file and MILESTONE-AUDIT.md (phase UAT via CLI)
622
608
  - [ ] --dry-run flag displays step preview without executing
623
- - [ ] Job summary auto-generated on completion (written to completed/)
624
- - [ ] Job summary auto-generated on failure (written to in-progress/)
609
+ - [ ] Job summary auto-generated on completion (written to ${jobs_root}/)
610
+ - [ ] Job summary auto-generated on failure (written to ${jobs_root}/)
625
611
  - [ ] Pre-workflow pull executed before job steps start (sync_before)
626
612
  - [ ] Mid-workflow push after phase-completing steps (silent, no prompt)
627
613
  - [ ] Post-workflow push after job completion (sync_after)
@@ -45,8 +45,8 @@ Parse current values (default to `true` if not present):
45
45
  - `workflow.verifier` — spawn verifier during execute-phase
46
46
  - `workflow.nyquist_validation` — validation architecture research during plan-phase (default: true if absent)
47
47
  - `workflow.codereview` — spawn code reviewer after plan execution (default: false if absent)
48
+ - `workflow.four_eyes` — four-eyes completion governance mode (default: "off" if absent)
48
49
  - `model_profile` — which model each agent uses (default: `balanced`)
49
- - `git.branching_strategy` — branching approach (default: `"none"`)
50
50
  - `git.base_branch` — integration target branch for code repos (default: `"main"`)
51
51
  - `git.sync_push` — remote sync push mode (default: "off" if absent for existing installs)
52
52
  - `git.sync_pull` — remote sync pull mode (default: "off" if absent for existing installs)
@@ -59,62 +59,6 @@ CLAUDE_MD_HAS_DGS=$(grep -l 'DGS:BEGIN' ./CLAUDE.md 2>/dev/null && echo "true" |
59
59
  ```
60
60
  </step>
61
61
 
62
- <step name="detect_old_templates">
63
- After loading current config, check if the branch templates use old defaults without `{project}`:
64
-
65
- ```bash
66
- CURRENT_PHASE_TPL=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get git.phase_branch_template --raw 2>/dev/null)
67
- CURRENT_MILESTONE_TPL=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get git.milestone_branch_template --raw 2>/dev/null)
68
- ```
69
-
70
- If either template is set AND does not contain `{project}`, and `branching_strategy` is not `"none"`, show migration hint before the settings questions:
71
-
72
- ```
73
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
74
- DGS ► BRANCH TEMPLATE UPDATE AVAILABLE
75
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
76
-
77
- Your branch templates don't include the project name, which can cause
78
- collisions in multi-project setups.
79
-
80
- Current: {current_phase_tpl}
81
- Suggested: dgs/{project}/phase-{phase}-{slug}
82
-
83
- Current: {current_milestone_tpl}
84
- Suggested: dgs/{project}/{milestone}-{slug}
85
- ```
86
-
87
- Use AskUserQuestion:
88
- ```
89
- AskUserQuestion([{
90
- question: "Update branch templates to include project name?",
91
- header: "Templates",
92
- multiSelect: false,
93
- options: [
94
- { label: "Yes (Recommended)", description: "Updates templates to include {project} for multi-project safety" },
95
- { label: "No", description: "Keep current templates" }
96
- ]
97
- }])
98
- ```
99
-
100
- If "Yes": write updated templates to config.json using config-set:
101
- ```bash
102
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-set git.phase_branch_template "dgs/{project}/phase-{phase}-{slug}"
103
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-set git.milestone_branch_template "dgs/{project}/{milestone}-{slug}"
104
- ```
105
-
106
- Show confirmation:
107
- ```
108
- Updated branch templates to include {project}.
109
- Branch names will now look like: dgs/your-project/phase-03-auth
110
-
111
- Note: Existing branches using the old format will NOT be renamed.
112
- Only new branches will use the updated format.
113
- ```
114
-
115
- If templates already contain `{project}` or branching_strategy is "none": skip this step silently.
116
- </step>
117
-
118
62
  <step name="present_settings">
119
63
  Use AskUserQuestion with current values pre-selected:
120
64
 
@@ -185,21 +129,14 @@ AskUserQuestion([
185
129
  ]
186
130
  },
187
131
  {
188
- question: "Git branching strategy?",
189
- header: "Branching",
132
+ question: "Four-eyes completion governance? (requires a second contributor for milestone/quick completion)",
133
+ header: "Four-Eyes",
190
134
  multiSelect: false,
191
135
  options: [
192
- { label: "None (Recommended)", description: "Commit to current branch (fine for single projects)" },
193
- { label: "Per Phase", description: "Branch per phase, review before merging" },
194
- { label: "Per Milestone", description: "Branch per project, merge all at end (for parallel projects)" }
136
+ { label: "Off", description: "No contributor check at completion gates" },
137
+ { label: "Warn", description: "Warn if only one contributor, but allow completion" },
138
+ { label: "Enforce", description: "Block completion unless a second contributor is detected (bypass with --force)" }
195
139
  ]
196
- },
197
- {
198
- question: "Base branch for code repos? (integration target for branching operations)",
199
- header: "Git",
200
- multiSelect: false,
201
- freeform: true,
202
- placeholder: currentConfig.base_branch || "main"
203
140
  }
204
141
  ])
205
142
  ```
@@ -450,11 +387,11 @@ Merge new settings into existing config:
450
387
  "auto_advance": true/false,
451
388
  "nyquist_validation": true/false,
452
389
  "codereview": true/false,
453
- "discipline": true/false
390
+ "discipline": true/false,
391
+ "four_eyes": "off" | "warn" | "enforce"
454
392
  },
455
393
  "git": {
456
- "branching_strategy": "none" | "phase" | "milestone",
457
- "base_branch": "main" | user_answer,
394
+ "base_branch": "main",
458
395
  "sync_push": "off" | "prompt" | "auto",
459
396
  "sync_pull": "off" | "prompt" | "auto"
460
397
  }
@@ -495,7 +432,6 @@ Write `~/.dgs/defaults.json` with:
495
432
  "model_profile": <current>,
496
433
  "commit_docs": <current>,
497
434
  "parallelization": <current>,
498
- "branching_strategy": <current>,
499
435
  "workflow": {
500
436
  "research": <current>,
501
437
  "plan_check": <current>,
@@ -503,7 +439,8 @@ Write `~/.dgs/defaults.json` with:
503
439
  "auto_advance": <current>,
504
440
  "nyquist_validation": <current>,
505
441
  "codereview": <current>,
506
- "discipline": <current>
442
+ "discipline": <current>,
443
+ "four_eyes": <current>
507
444
  },
508
445
  "git": {
509
446
  "sync_push": <current>,
@@ -544,8 +481,7 @@ Display:
544
481
  | Auto-Advance | {On/Off} |
545
482
  | Nyquist Validation | {On/Off} |
546
483
  | Code Reviewer | {On/Off} |
547
- | Git Branching | {None/Per Phase/Per Milestone} |
548
- | Base Branch | {main/develop/etc.} |
484
+ | Four-Eyes Governance | {Off/Warn/Enforce} |
549
485
  | Workflow Discipline | {On/Off} |
550
486
  | Git Sync Push | {Off/Prompt/Auto} |
551
487
  | Git Sync Pull | {Off/Prompt/Auto} |
@@ -567,7 +503,7 @@ Quick commands:
567
503
 
568
504
  <success_criteria>
569
505
  - [ ] Current config read
570
- - [ ] User presented with 9 workflow settings (profile + 6 workflow toggles + git branching + base branch)
506
+ - [ ] User presented with 8 workflow settings (profile + 6 workflow toggles + four-eyes governance)
571
507
  - [ ] User shown review key status (read-only)
572
508
  - [ ] Config updated with model_profile, workflow, and git sections
573
509
  - [ ] User offered to save as global defaults (~/.dgs/defaults.json)