@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,231 @@
1
+ <purpose>
2
+ Orchestrate parallel debug agents to investigate UAT gaps and find root causes.
3
+
4
+ After UAT finds gaps, spawn one debug agent per gap. Each agent investigates autonomously with symptoms pre-filled from UAT. Collect root causes, update UAT.md gaps with diagnosis, then hand off to plan-phase --gaps with actual diagnoses.
5
+
6
+ Orchestrator stays lean: parse gaps, spawn agents, collect results, update UAT.
7
+ </purpose>
8
+
9
+ <context_tier>execution</context_tier>
10
+
11
+ <paths>
12
+ DEBUG_DIR=${debug_dir}
13
+
14
+ Debug files use the `${debug_dir}` path from init output.
15
+ </paths>
16
+
17
+ <core_principle>
18
+ **Diagnose before planning fixes.**
19
+
20
+ UAT tells us WHAT is broken (symptoms). Debug agents find WHY (root cause). plan-phase --gaps then creates targeted fixes based on actual causes, not guesses.
21
+
22
+ Without diagnosis: "Comment doesn't refresh" → guess at fix → maybe wrong
23
+ With diagnosis: "Comment doesn't refresh" → "useEffect missing dependency" → precise fix
24
+ </core_principle>
25
+
26
+ <process>
27
+
28
+ <step name="load_tier_context" priority="first">
29
+ Load execution tier context for phase-scoped diagnosis:
30
+
31
+ ```bash
32
+ TIER_FILES=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" context load-tier execution --phase "${PHASE}" --raw 2>/dev/null)
33
+ ```
34
+
35
+ Store the file list for passing to debug sub-agents in `<files_to_read>` blocks.
36
+ </step>
37
+
38
+ <step name="parse_gaps">
39
+ **Extract gaps from UAT.md:**
40
+
41
+ Read the "Gaps" section (YAML format):
42
+ ```yaml
43
+ - truth: "Comment appears immediately after submission"
44
+ status: failed
45
+ reason: "User reported: works but doesn't show until I refresh the page"
46
+ severity: major
47
+ test: 2
48
+ artifacts: []
49
+ missing: []
50
+ ```
51
+
52
+ For each gap, also read the corresponding test from "Tests" section to get full context.
53
+
54
+ Build gap list:
55
+ ```
56
+ gaps = [
57
+ {truth: "Comment appears immediately...", severity: "major", test_num: 2, reason: "..."},
58
+ {truth: "Reply button positioned correctly...", severity: "minor", test_num: 5, reason: "..."},
59
+ ...
60
+ ]
61
+ ```
62
+ </step>
63
+
64
+ <step name="report_plan">
65
+ **Report diagnosis plan to user:**
66
+
67
+ ```
68
+ ## Diagnosing {N} Gaps
69
+
70
+ Spawning parallel debug agents to investigate root causes:
71
+
72
+ | Gap (Truth) | Severity |
73
+ |-------------|----------|
74
+ | Comment appears immediately after submission | major |
75
+ | Reply button positioned correctly | minor |
76
+ | Delete removes comment | blocker |
77
+
78
+ Each agent will:
79
+ 1. Create DEBUG-{slug}.md with symptoms pre-filled
80
+ 2. Investigate autonomously (read code, form hypotheses, test)
81
+ 3. Return root cause
82
+
83
+ This runs in parallel - all gaps investigated simultaneously.
84
+ ```
85
+ </step>
86
+
87
+ <step name="spawn_agents">
88
+ **Spawn debug agents in parallel:**
89
+
90
+ For each gap, fill the debug-subagent-prompt template and spawn:
91
+
92
+ ```
93
+ Task(
94
+ prompt=filled_debug_subagent_prompt + "\n\n<files_to_read>\n- {phase_dir}/{phase_num}-UAT.md\n- ${state_path}\n{For each file in TIER_FILES not already listed:}\n- {tier_file} (Context tier: execution)\n</files_to_read>",
95
+ subagent_type="dgs-debugger",
96
+ description="Debug: {truth_short}"
97
+ )
98
+ ```
99
+
100
+ **All agents spawn in single message** (parallel execution).
101
+
102
+ Template placeholders:
103
+ - `{truth}`: The expected behavior that failed
104
+ - `{expected}`: From UAT test
105
+ - `{actual}`: Verbatim user description from reason field
106
+ - `{errors}`: Any error messages from UAT (or "None reported")
107
+ - `{reproduction}`: "Test {test_num} in UAT"
108
+ - `{timeline}`: "Discovered during UAT"
109
+ - `{goal}`: `find_root_cause_only` (UAT flow - plan-phase --gaps handles fixes)
110
+ - `{slug}`: Generated from truth
111
+ </step>
112
+
113
+ <step name="collect_results">
114
+ **Collect root causes from agents:**
115
+
116
+ Each agent returns with:
117
+ ```
118
+ ## ROOT CAUSE FOUND
119
+
120
+ **Debug Session:** ${DEBUG_DIR}/{slug}.md
121
+
122
+ **Root Cause:** {specific cause with evidence}
123
+
124
+ **Evidence Summary:**
125
+ - {key finding 1}
126
+ - {key finding 2}
127
+ - {key finding 3}
128
+
129
+ **Files Involved:**
130
+ - {file1}: {what's wrong}
131
+ - {file2}: {related issue}
132
+
133
+ **Suggested Fix Direction:** {brief hint for plan-phase --gaps}
134
+ ```
135
+
136
+ Parse each return to extract:
137
+ - root_cause: The diagnosed cause
138
+ - files: Files involved
139
+ - debug_path: Path to debug session file
140
+ - suggested_fix: Hint for gap closure plan
141
+
142
+ If agent returns `## INVESTIGATION INCONCLUSIVE`:
143
+ - root_cause: "Investigation inconclusive - manual review needed"
144
+ - Note which issue needs manual attention
145
+ - Include remaining possibilities from agent return
146
+ </step>
147
+
148
+ <step name="update_uat">
149
+ **Update UAT.md gaps with diagnosis:**
150
+
151
+ For each gap in the Gaps section, add artifacts and missing fields:
152
+
153
+ ```yaml
154
+ - truth: "Comment appears immediately after submission"
155
+ status: failed
156
+ reason: "User reported: works but doesn't show until I refresh the page"
157
+ severity: major
158
+ test: 2
159
+ root_cause: "useEffect in CommentList.tsx missing commentCount dependency"
160
+ artifacts:
161
+ - path: "src/components/CommentList.tsx"
162
+ issue: "useEffect missing dependency"
163
+ missing:
164
+ - "Add commentCount to useEffect dependency array"
165
+ - "Trigger re-render when new comment added"
166
+ debug_session: ${debug_dir}/comment-not-refreshing.md
167
+ ```
168
+
169
+ Update status in frontmatter to "diagnosed".
170
+
171
+ Commit the updated UAT.md:
172
+ ```bash
173
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs({phase_num}): add root causes from diagnosis" --files "${phase_dir}/{phase_num}-UAT.md"
174
+ ```
175
+ </step>
176
+
177
+ <step name="report_results">
178
+ **Report diagnosis results and hand off:**
179
+
180
+ Display:
181
+ ```
182
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
183
+ DGS ► DIAGNOSIS COMPLETE
184
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
185
+
186
+ | Gap (Truth) | Root Cause | Files |
187
+ |-------------|------------|-------|
188
+ | Comment appears immediately | useEffect missing dependency | CommentList.tsx |
189
+ | Reply button positioned correctly | CSS flex order incorrect | ReplyButton.tsx |
190
+ | Delete removes comment | API missing auth header | api/comments.ts |
191
+
192
+ Debug sessions: ${DEBUG_DIR}/
193
+
194
+ Proceeding to plan fixes...
195
+ ```
196
+
197
+ Return to verify-work orchestrator for automatic planning.
198
+ Do NOT offer manual next steps - verify-work handles the rest.
199
+ </step>
200
+
201
+ </process>
202
+
203
+ <context_efficiency>
204
+ Agents start with symptoms pre-filled from UAT (no symptom gathering).
205
+ Agents only diagnose—plan-phase --gaps handles fixes (no fix application).
206
+ </context_efficiency>
207
+
208
+ <failure_handling>
209
+ **Agent fails to find root cause:**
210
+ - Mark gap as "needs manual review"
211
+ - Continue with other gaps
212
+ - Report incomplete diagnosis
213
+
214
+ **Agent times out:**
215
+ - Check DEBUG-{slug}.md for partial progress
216
+ - Can resume with /dgs:debug
217
+
218
+ **All agents fail:**
219
+ - Something systemic (permissions, git, etc.)
220
+ - Report for manual investigation
221
+ - Fall back to plan-phase --gaps without root causes (less precise)
222
+ </failure_handling>
223
+
224
+ <success_criteria>
225
+ - [ ] Gaps parsed from UAT.md
226
+ - [ ] Debug agents spawned in parallel
227
+ - [ ] Root causes collected from all agents
228
+ - [ ] UAT.md gaps updated with artifacts and missing
229
+ - [ ] Debug sessions saved to ${DEBUG_DIR}/
230
+ - [ ] Hand off to verify-work for automatic planning
231
+ </success_criteria>
@@ -0,0 +1,301 @@
1
+ <purpose>
2
+ Execute discovery at the appropriate depth level.
3
+ Produces DISCOVERY.md (for Level 2-3) that informs PLAN.md creation.
4
+
5
+ Called from plan-phase.md's mandatory_discovery step with a depth parameter.
6
+
7
+ NOTE: For comprehensive ecosystem research ("how do experts build this"), use /dgs:research-phase instead, which produces RESEARCH.md.
8
+ </purpose>
9
+
10
+ <context_tier>execution</context_tier>
11
+
12
+ <depth_levels>
13
+ **This workflow supports three depth levels:**
14
+
15
+ | Level | Name | Time | Output | When |
16
+ | ----- | ------------ | --------- | -------------------------------------------- | ----------------------------------------- |
17
+ | 1 | Quick Verify | 2-5 min | No file, proceed with verified knowledge | Single library, confirming current syntax |
18
+ | 2 | Standard | 15-30 min | DISCOVERY.md | Choosing between options, new integration |
19
+ | 3 | Deep Dive | 1+ hour | Detailed DISCOVERY.md with validation gates | Architectural decisions, novel problems |
20
+
21
+ **Depth is determined by plan-phase.md before routing here.**
22
+ </depth_levels>
23
+
24
+ <source_hierarchy>
25
+ **MANDATORY: Context7 BEFORE WebSearch**
26
+
27
+ Claude's training data is 6-18 months stale. Always verify.
28
+
29
+ 1. **Context7 MCP FIRST** - Current docs, no hallucination
30
+ 2. **Official docs** - When Context7 lacks coverage
31
+ 3. **WebSearch LAST** - For comparisons and trends only
32
+
33
+ See ~/.claude/deliver-great-systems/templates/discovery.md `<discovery_protocol>` for full protocol.
34
+ </source_hierarchy>
35
+
36
+ <process>
37
+
38
+ <step name="load_tier_context" priority="first">
39
+ Load execution tier context for phase-scoped discovery:
40
+
41
+ ```bash
42
+ TIER_FILES=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" context load-tier execution --phase "${PHASE}" --raw 2>/dev/null)
43
+ ```
44
+
45
+ This provides planning context (ROADMAP, REQUIREMENTS, codebase docs) plus phase-specific files (CONTEXT.md, RESEARCH.md, PLANs, SUMMARYs) needed for informed discovery decisions.
46
+ </step>
47
+
48
+ <step name="determine_depth">
49
+ Check the depth parameter passed from plan-phase.md:
50
+ - `depth=verify` → Level 1 (Quick Verification)
51
+ - `depth=standard` → Level 2 (Standard Discovery)
52
+ - `depth=deep` → Level 3 (Deep Dive)
53
+
54
+ Route to appropriate level workflow below.
55
+ </step>
56
+
57
+ <step name="level_1_quick_verify">
58
+ **Level 1: Quick Verification (2-5 minutes)**
59
+
60
+ For: Single known library, confirming syntax/version still correct.
61
+
62
+ **Process:**
63
+
64
+ 1. Resolve library in Context7:
65
+
66
+ ```
67
+ mcp__context7__resolve-library-id with libraryName: "[library]"
68
+ ```
69
+
70
+ 2. Fetch relevant docs:
71
+
72
+ ```
73
+ mcp__context7__get-library-docs with:
74
+ - context7CompatibleLibraryID: [from step 1]
75
+ - topic: [specific concern]
76
+ ```
77
+
78
+ 3. Verify:
79
+
80
+ - Current version matches expectations
81
+ - API syntax unchanged
82
+ - No breaking changes in recent versions
83
+
84
+ 4. **If verified:** Return to plan-phase.md with confirmation. No DISCOVERY.md needed.
85
+
86
+ 5. **If concerns found:** Escalate to Level 2.
87
+
88
+ **Output:** Verbal confirmation to proceed, or escalation to Level 2.
89
+ </step>
90
+
91
+ <step name="level_2_standard">
92
+ **Level 2: Standard Discovery (15-30 minutes)**
93
+
94
+ For: Choosing between options, new external integration.
95
+
96
+ **Process:**
97
+
98
+ 1. **Identify what to discover:**
99
+
100
+ - What options exist?
101
+ - What are the key comparison criteria?
102
+ - What's our specific use case?
103
+
104
+ 2. **Context7 for each option:**
105
+
106
+ ```
107
+ For each library/framework:
108
+ - mcp__context7__resolve-library-id
109
+ - mcp__context7__get-library-docs (mode: "code" for API, "info" for concepts)
110
+ ```
111
+
112
+ 3. **Official docs** for anything Context7 lacks.
113
+
114
+ 4. **WebSearch** for comparisons:
115
+
116
+ - "[option A] vs [option B] {current_year}"
117
+ - "[option] known issues"
118
+ - "[option] with [our stack]"
119
+
120
+ 5. **Cross-verify:** Any WebSearch finding → confirm with Context7/official docs.
121
+
122
+ 6. **Create DISCOVERY.md** using ~/.claude/deliver-great-systems/templates/discovery.md structure:
123
+
124
+ - Summary with recommendation
125
+ - Key findings per option
126
+ - Code examples from Context7
127
+ - Confidence level (should be MEDIUM-HIGH for Level 2)
128
+
129
+ 7. Return to plan-phase.md.
130
+
131
+ **Output:** `${phase_dir}/DISCOVERY.md`
132
+ </step>
133
+
134
+ <step name="level_3_deep_dive">
135
+ **Level 3: Deep Dive (1+ hour)**
136
+
137
+ For: Architectural decisions, novel problems, high-risk choices.
138
+
139
+ **Process:**
140
+
141
+ 1. **Scope the discovery** using ~/.claude/deliver-great-systems/templates/discovery.md:
142
+
143
+ - Define clear scope
144
+ - Define include/exclude boundaries
145
+ - List specific questions to answer
146
+
147
+ 2. **Exhaustive Context7 research:**
148
+
149
+ - All relevant libraries
150
+ - Related patterns and concepts
151
+ - Multiple topics per library if needed
152
+
153
+ 3. **Official documentation deep read:**
154
+
155
+ - Architecture guides
156
+ - Best practices sections
157
+ - Migration/upgrade guides
158
+ - Known limitations
159
+
160
+ 4. **WebSearch for ecosystem context:**
161
+
162
+ - How others solved similar problems
163
+ - Production experiences
164
+ - Gotchas and anti-patterns
165
+ - Recent changes/announcements
166
+
167
+ 5. **Cross-verify ALL findings:**
168
+
169
+ - Every WebSearch claim → verify with authoritative source
170
+ - Mark what's verified vs assumed
171
+ - Flag contradictions
172
+
173
+ 6. **Create comprehensive DISCOVERY.md:**
174
+
175
+ - Full structure from ~/.claude/deliver-great-systems/templates/discovery.md
176
+ - Quality report with source attribution
177
+ - Confidence by finding
178
+ - If LOW confidence on any critical finding → add validation checkpoints
179
+
180
+ 7. **Confidence gate:** If overall confidence is LOW, present options before proceeding.
181
+
182
+ 8. Return to plan-phase.md.
183
+
184
+ **Output:** `${phase_dir}/DISCOVERY.md` (comprehensive)
185
+ </step>
186
+
187
+ <step name="identify_unknowns">
188
+ **For Level 2-3:** Define what we need to learn.
189
+
190
+ Ask: What do we need to learn before we can plan this phase?
191
+
192
+ - Technology choices?
193
+ - Best practices?
194
+ - API patterns?
195
+ - Architecture approach?
196
+ </step>
197
+
198
+ <step name="create_discovery_scope">
199
+ Use ~/.claude/deliver-great-systems/templates/discovery.md.
200
+
201
+ Include:
202
+
203
+ - Clear discovery objective
204
+ - Scoped include/exclude lists
205
+ - Source preferences (official docs, Context7, current year)
206
+ - Output structure for DISCOVERY.md
207
+ </step>
208
+
209
+ <step name="execute_discovery">
210
+ Run the discovery:
211
+ - Use web search for current info
212
+ - Use Context7 MCP for library docs
213
+ - Prefer current year sources
214
+ - Structure findings per template
215
+ </step>
216
+
217
+ <step name="create_discovery_output">
218
+ Write `${phase_dir}/DISCOVERY.md`:
219
+ - Summary with recommendation
220
+ - Key findings with sources
221
+ - Code examples if applicable
222
+ - Metadata (confidence, dependencies, open questions, assumptions)
223
+ </step>
224
+
225
+ <step name="confidence_gate">
226
+ After creating DISCOVERY.md, check confidence level.
227
+
228
+ If confidence is LOW:
229
+ Use AskUserQuestion:
230
+
231
+ - header: "Low Conf."
232
+ - question: "Discovery confidence is LOW: [reason]. How would you like to proceed?"
233
+ - options:
234
+ - "Dig deeper" - Do more research before planning
235
+ - "Proceed anyway" - Accept uncertainty, plan with caveats
236
+ - "Pause" - I need to think about this
237
+
238
+ If confidence is MEDIUM:
239
+ Inline: "Discovery complete (medium confidence). [brief reason]. Proceed to planning?"
240
+
241
+ If confidence is HIGH:
242
+ Proceed directly, just note: "Discovery complete (high confidence)."
243
+ </step>
244
+
245
+ <step name="open_questions_gate">
246
+ If DISCOVERY.md has open_questions:
247
+
248
+ Present them inline:
249
+ "Open questions from discovery:
250
+
251
+ - [Question 1]
252
+ - [Question 2]
253
+
254
+ These may affect implementation. Acknowledge and proceed? (yes / address first)"
255
+
256
+ If "address first": Gather user input on questions, update discovery.
257
+ </step>
258
+
259
+ <step name="offer_next">
260
+ ```
261
+ Discovery complete: ${phase_dir}/DISCOVERY.md
262
+ Recommendation: [one-liner]
263
+ Confidence: [level]
264
+
265
+ What's next?
266
+
267
+ 1. Discuss phase context (/dgs:discuss-phase [current-phase])
268
+ 2. Create phase plan (/dgs:plan-phase [current-phase])
269
+ 3. Refine discovery (dig deeper)
270
+ 4. Review discovery
271
+
272
+ ```
273
+
274
+ NOTE: DISCOVERY.md is NOT committed separately. It will be committed with phase completion.
275
+ </step>
276
+
277
+ </process>
278
+
279
+ <success_criteria>
280
+ **Level 1 (Quick Verify):**
281
+ - Context7 consulted for library/topic
282
+ - Current state verified or concerns escalated
283
+ - Verbal confirmation to proceed (no files)
284
+
285
+ **Level 2 (Standard):**
286
+ - Context7 consulted for all options
287
+ - WebSearch findings cross-verified
288
+ - DISCOVERY.md created with recommendation
289
+ - Confidence level MEDIUM or higher
290
+ - Ready to inform PLAN.md creation
291
+
292
+ **Level 3 (Deep Dive):**
293
+ - Discovery scope defined
294
+ - Context7 exhaustively consulted
295
+ - All WebSearch findings verified against authoritative sources
296
+ - DISCOVERY.md created with comprehensive analysis
297
+ - Quality report with source attribution
298
+ - If LOW confidence findings → validation checkpoints defined
299
+ - Confidence gate passed
300
+ - Ready to inform PLAN.md creation
301
+ </success_criteria>