@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,544 @@
1
+ <purpose>
2
+ Orchestrator workflow that runs structured discussion then research as a single continuous creative session. Discussion flows naturally into research -- the two phases feel like one conversation, not two separate tasks bolted together.
3
+
4
+ Pure orchestrator: no unique artifacts. The idea file (with Discussion Log and Research Log) and research document are the outputs. Discussion commits before research starts so research reads the freshly-updated idea context.
5
+
6
+ When re-running on an idea with prior history, the user is offered granular choice: re-do both, just discuss, or just research.
7
+ </purpose>
8
+
9
+ <context_tier>planning</context_tier>
10
+
11
+ <required_reading>
12
+ Read all files referenced by the invoking prompt's execution_context before starting.
13
+ </required_reading>
14
+
15
+ <process>
16
+
17
+ <step name="initialize" priority="first">
18
+ Load planning context:
19
+
20
+ ```bash
21
+ INIT=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs init milestone-op)
22
+ ```
23
+
24
+ Extract: `project_root` as needed by the workflow.
25
+
26
+ Load planning-tier context files:
27
+
28
+ ```bash
29
+ TIER_FILES=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" context load-tier planning --raw 2>/dev/null)
30
+ ```
31
+ </step>
32
+
33
+ <step name="parse_arguments">
34
+ Parse `$ARGUMENTS` for an idea ID.
35
+
36
+ - First positional argument: treat as idea ID (e.g., `/dgs:develop-idea 5` -> id=5)
37
+ - Named flag: `--id N` (e.g., `/dgs:develop-idea --id 5` -> id=5)
38
+
39
+ If no ID provided, list pending ideas and prompt for selection:
40
+
41
+ ```bash
42
+ PENDING=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs ideas list --state pending --raw)
43
+ ```
44
+
45
+ Parse the JSON `ideas` array.
46
+
47
+ **If empty:**
48
+ ```
49
+ No pending ideas to develop. Run /dgs:add-idea to capture one.
50
+ ```
51
+ Exit workflow.
52
+
53
+ **If ideas exist:** Display them as a numbered list showing ID, title, and tags. Use AskUserQuestion:
54
+ - header: "Select Idea"
55
+ - question: "Which idea would you like to develop?"
56
+ - Provide the numbered idea options
57
+
58
+ Extract the selected idea's ID.
59
+ </step>
60
+
61
+ <step name="load_idea">
62
+ Load the full idea content by ID:
63
+
64
+ ```bash
65
+ LIST=$(node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs ideas list --raw)
66
+ ```
67
+
68
+ Find the idea in the JSON by matching `id`. If not found:
69
+ ```
70
+ Idea #${id} not found.
71
+ ```
72
+ Exit workflow.
73
+
74
+ Read the idea file directly using the `path` from the list result to get the full content including Discussion Log, Research Log, Notes, and body.
75
+
76
+ Set variables from the parsed content:
77
+ - `id` -- idea ID
78
+ - `title` -- idea title
79
+ - `body` -- idea body/problem statement
80
+ - `tags` -- tags array
81
+ - `notes` -- Notes section content (if any)
82
+ - `state` -- current state (pending, done, rejected)
83
+ - `filename` -- file name
84
+ - `path` -- file path
85
+ - `discussionLog` -- Discussion Log section content (if any)
86
+ - `researchLog` -- Research Log section content (if any)
87
+
88
+ Also check for prior research document:
89
+ ```bash
90
+ # Derive slug from filename (strip id prefix and .md suffix)
91
+ SLUG=$(echo "${filename}" | sed 's/^[0-9]*-//' | sed 's/\.md$//')
92
+ RESEARCH_DOC="${project_root}/docs/ideas/pending/${SLUG}-research.md"
93
+ ```
94
+ If the research document file exists, read it for prior research context.
95
+
96
+ Also check for existing spec:
97
+ ```bash
98
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs specs list --raw
99
+ ```
100
+ Search for matching idea_id or title in the specs list.
101
+
102
+ Also check for REPOS.md:
103
+ ```bash
104
+ cat ${project_root}/REPOS.md 2>/dev/null
105
+ ```
106
+ If REPOS.md exists and has entries, this is a multi-repo project -- research should be partitioned by repo where relevant.
107
+ </step>
108
+
109
+ <step name="assess_history">
110
+ Determine the idea's development state by checking what exists:
111
+ - `hasDiscussion` -- whether Discussion Log has content
112
+ - `hasResearch` -- whether Research Log has content
113
+ - `hasSpec` -- whether a matching spec was found
114
+ - `discussionCount` -- number of `### Session` entries in Discussion Log
115
+ - `researchCount` -- number of `### Session` entries in Research Log
116
+
117
+ Set routing variables for later steps:
118
+ - `runDiscussion` -- whether to run the discussion phase (default: true)
119
+ - `runResearch` -- whether to run the research phase (default: true)
120
+
121
+ **For fresh ideas** (no prior discussion or research):
122
+ Skip status display. Proceed directly to discussion_phase. Both `runDiscussion` and `runResearch` remain true.
123
+
124
+ **For ideas with prior history:** Display brief status line:
125
+ ```
126
+ Idea ${id}: ${title}
127
+ Status: Discussed (${N} sessions), ${researched ? 'Researched' : 'Not researched'}
128
+ ```
129
+
130
+ If a spec exists, mention it: "Note: A spec already exists for this idea. Proceeding with development anyway."
131
+
132
+ **For ideas previously discussed AND researched:** Use AskUserQuestion to offer choice:
133
+ - "Re-do both discussion and research"
134
+ - "Just discuss (skip research)"
135
+ - "Just research (skip discussion)"
136
+
137
+ Route based on user choice:
138
+ - "Re-do both": `runDiscussion = true`, `runResearch = true`
139
+ - "Just discuss": `runDiscussion = true`, `runResearch = false`
140
+ - "Just research": `runDiscussion = false`, `runResearch = true`
141
+
142
+ **For ideas discussed but NOT researched:** Use AskUserQuestion to offer choice:
143
+ - "Discuss more, then research"
144
+ - "Go straight to research"
145
+
146
+ Route based on user choice:
147
+ - "Discuss more, then research": `runDiscussion = true`, `runResearch = true`
148
+ - "Go straight to research": `runDiscussion = false`, `runResearch = true`
149
+
150
+ If `runDiscussion` is false, skip to step research_phase.
151
+ If `runResearch` is false, after discussion_commit skip to step completion_summary.
152
+ </step>
153
+
154
+ <step name="discussion_phase">
155
+ **Only runs if `runDiscussion` is true.**
156
+
157
+ Print a visual banner to mark the transition into discussion:
158
+ ```
159
+ --- Discussion Phase ---
160
+ ```
161
+ (Exact format at Claude's discretion -- could be a markdown heading, separator line, or styled banner.)
162
+
163
+ Execute the full discuss-idea workflow inline. This is a single continuous conversation -- do NOT delegate to the discuss-idea command shim.
164
+
165
+ **Sub-step: discussion_context**
166
+ Present the idea to yourself (Claude) as working context.
167
+
168
+ *For a new discussion* (no prior Discussion Log):
169
+ Internalize the idea's title, body, tags, and any notes. This is the raw material for discussion.
170
+
171
+ *For a re-discussion* (prior Discussion Log exists):
172
+ Review the prior discussion entries. Identify:
173
+ - Open Questions from the most recent entry -- these are the starting point
174
+ - Prior Decisions -- context but not necessarily locked; use discretion on whether to revisit
175
+ - Key Insights from prior sessions -- build on these, don't repeat them
176
+
177
+ Each re-discussion produces its own fresh Decision tag regardless of prior status.
178
+
179
+ **Sub-step: understanding_phase**
180
+ *Tone: Thinking partner, collaborative, opinionated -- like a cofounder brainstorming.*
181
+
182
+ *For a new discussion* (no prior log):
183
+ Restate the idea in your own words to confirm understanding. Then ask clarifying questions about the problem:
184
+ - Who has this problem? How often do they hit it?
185
+ - What's the current workaround?
186
+ - What does success look like?
187
+
188
+ Challenge vague problem statements and push for specifics. Adapt depth to idea complexity -- simple ideas get quick understanding (1-2 exchanges), complex ideas get deeper probing (3-4 exchanges).
189
+
190
+ *For a re-discussion* (prior log exists):
191
+ Jump straight to unresolved Open Questions from the last session. Skip restating and re-clarifying unless the prior understanding seems incomplete or wrong.
192
+
193
+ Use AskUserQuestion for each turn of dialogue. Continue until the problem is well-defined.
194
+
195
+ **Mid-exit handling:** If the user indicates they want to exit (says "done", "save", "exit", "stop", or changes topic), go to handle_exit sub-step.
196
+
197
+ **Sub-step: exploration_phase**
198
+ Proactively raise considerations the user may not have thought of:
199
+ - Alternative approaches to the problem
200
+ - Potential conflicts with existing functionality (use Grep/Glob to check the codebase if the idea relates to existing features)
201
+ - Scope concerns -- is this bigger than it seems?
202
+ - Edge cases and failure modes
203
+ - Dependencies or prerequisites
204
+
205
+ When one option is clearly better, recommend it with reasoning. Otherwise present options neutrally and let the user decide.
206
+
207
+ Continue the back-and-forth dialogue with AskUserQuestion. The developer steers the conversation -- follow their lead on what to explore deeper.
208
+
209
+ **Mid-exit handling:** If the user indicates they want to exit, go to handle_exit sub-step.
210
+
211
+ **Sub-step: refinement_phase**
212
+ Propose a refined version of the idea:
213
+
214
+ 1. **Refined problem statement** -- sharper, more specific than the original
215
+ 2. **Updated approach** -- incorporating insights from the discussion
216
+ 3. **Open questions** -- questions that emerged during discussion and remain unresolved
217
+
218
+ Present this as a proposal for user review. Propose a Decision tag -- one of:
219
+ - **"Ready for research"** -- idea is well-defined, needs feasibility/landscape investigation
220
+ - **"Ready for spec"** -- idea is clear enough to write a formal specification
221
+ - **"Needs more thought"** -- idea has merit but unresolved questions remain
222
+
223
+ Use AskUserQuestion to present the proposal and get approval.
224
+
225
+ **If user rejects the proposal:** Revise based on their feedback and present again (one revision attempt). If rejected a second time, save with "Needs more thought" as the Decision tag.
226
+
227
+ **Mid-exit handling:** If the user indicates they want to exit, go to handle_exit sub-step.
228
+
229
+ **Sub-step: handle_exit**
230
+ When the user indicates they want to exit mid-discussion:
231
+
232
+ 1. **Always save on exit** -- inform the user: "Saving your progress." Do NOT ask permission.
233
+ 2. Use **"Needs more thought"** as the Decision tag for partial discussions.
234
+ 3. Do **NOT** update the idea body on partial save -- only write the discussion log entry.
235
+ 4. Format the partial save entry based on how far the discussion progressed:
236
+ - Exited during Understanding: capture what was clarified so far
237
+ - Exited during Exploration: capture clarifications plus alternatives/considerations raised
238
+ - Exited during Refinement: capture the near-complete refinement with a note that it was not finalized
239
+
240
+ Proceed to step save_discussion with `partial = true`.
241
+
242
+ **Sub-step: save_discussion**
243
+ Generate the discussion entry fields:
244
+
245
+ - `date`: current date in YYYY-MM-DD format
246
+ - `keyInsights`: bullet-pointed list of key insights from the discussion (use `\n- ` separator)
247
+ - `refinedProblem`: the refined problem statement (full discussion) or summary of what was discussed (partial)
248
+ - `refinedApproach`: the refined approach (full discussion) or "Not yet refined" (partial)
249
+ - `openQuestions`: bullet-pointed list of open questions (use `\n- ` separator)
250
+ - `decision`: the agreed Decision tag (e.g., "Ready for research", "Ready for spec", "Needs more thought")
251
+
252
+ For re-discussions: reference what changed from prior discussion in the keyInsights.
253
+
254
+ Format as a JSON string and call:
255
+ ```bash
256
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs ideas discuss-save --id "${id}" --entry '${entryJson}'
257
+ ```
258
+
259
+ The `entryJson` should be a JSON object:
260
+ ```json
261
+ {
262
+ "date": "YYYY-MM-DD",
263
+ "keyInsights": "- insight one\n- insight two",
264
+ "refinedProblem": "The refined problem statement",
265
+ "refinedApproach": "The refined approach",
266
+ "openQuestions": "- question one\n- question two",
267
+ "decision": "Ready for research"
268
+ }
269
+ ```
270
+
271
+ Parse the JSON result to confirm success.
272
+
273
+ **For FULL discussions only** (not partial saves): If the idea body or approach changed significantly during refinement, also update the idea body:
274
+ ```bash
275
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs ideas update --id "${id}" --field body --value "${refinedBody}"
276
+ ```
277
+
278
+ Per CONTEXT.md: idea body is NOT updated on partial save.
279
+ </step>
280
+
281
+ <step name="discussion_commit">
282
+ Commit the updated idea file immediately after discussion:
283
+ ```bash
284
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs: discuss idea #${id} — ${title}" --files ${project_root}/ideas/${state}/${filename}
285
+ ```
286
+
287
+ **If `partial = true`** (user exited mid-discussion):
288
+ Print: "Saved progress. Run /dgs:develop-idea ${id} to continue where you left off."
289
+ Exit workflow. Do NOT proceed to research.
290
+
291
+ If `runResearch` is false (user chose "Just discuss" in assess_history), skip to step completion_summary.
292
+ </step>
293
+
294
+ <step name="decision_routing">
295
+ Read the Decision tag from the discussion that just completed.
296
+
297
+ **If Decision is "Not viable" or "Reject":**
298
+ Print: "Discussion concluded the idea is not viable. Skipping research."
299
+ Go to step completion_summary (no research).
300
+
301
+ **If Decision is "Needs more thought":**
302
+ Claude judges whether the open questions are things research can help answer (e.g., feasibility questions, landscape questions, technical unknowns) or things that need more discussion first (e.g., problem definition unclear, user intent ambiguous, scope undefined).
303
+ - If research can help: continue to research_phase.
304
+ - If not: print "Open questions need more discussion before research can help. Run /dgs:discuss-idea ${id} to continue." Go to step completion_summary.
305
+
306
+ **If Decision is "Ready for research" or "Ready for spec":**
307
+ Continue to research_phase.
308
+ </step>
309
+
310
+ <step name="research_phase">
311
+ **Only runs if `runResearch` is true and decision_routing allows it.**
312
+
313
+ Print a visual banner to mark the transition into research:
314
+ ```
315
+ --- Research Phase ---
316
+ ```
317
+ (Exact format at Claude's discretion.)
318
+
319
+ Execute the full research-idea workflow inline. This is part of the same continuous session -- do NOT delegate to the research-idea command shim.
320
+
321
+ **Sub-step: research_context**
322
+ Assess the idea and decide research strategy:
323
+
324
+ 1. **Announce focus**: Print one line explaining which dimensions matter most for this idea and why.
325
+ 2. **Read Discussion Log** -- use discussion insights (refined problem, approach, open questions) to guide research focus areas.
326
+ 3. **Read prior research** if present -- note what was found before. On re-research, the document will be overwritten but note what changed.
327
+ 4. **Determine repo scope**: If REPOS.md exists, identify which repos are relevant. If no REPOS.md, treat as single-repo research.
328
+
329
+ **Sub-step: web_search**
330
+ *Dimension 1: Web Search*
331
+
332
+ Announce: "Searching web for prior art and technical landscape..."
333
+
334
+ Use WebSearch and WebFetch to investigate:
335
+ - How others have solved similar problems
336
+ - Existing libraries, tools, or frameworks relevant to the idea
337
+ - Common patterns and anti-patterns
338
+ - Recent discussions or blog posts
339
+
340
+ Adapt depth to what the idea needs -- a well-understood problem gets a quick scan, a novel idea gets broader exploration. Web search is best-effort -- search what's findable, note gaps, move on.
341
+
342
+ **Sub-step: codebase_analysis**
343
+ *Dimension 2: Codebase Analysis*
344
+
345
+ Announce: "Analyzing codebase for related implementations..."
346
+
347
+ Use Grep and Glob to examine:
348
+ - Existing code that relates to the idea's domain
349
+ - Patterns already established that would apply
350
+ - Potential conflicts or integration points
351
+ - Code that would need to change
352
+
353
+ For multi-repo projects: analyze each relevant repo separately.
354
+
355
+ **Sub-step: landscape_survey**
356
+ *Dimension 3: Landscape Survey*
357
+
358
+ Announce: "Surveying technical landscape..."
359
+
360
+ Build comparison information for relevant tools/libraries/approaches:
361
+ - For obvious choices (one clear winner): brief verdict with reasoning
362
+ - For genuine tradeoffs: table with pros, cons, license, maintenance status, compatibility
363
+ - Per repo stack for multi-repo projects
364
+
365
+ Recommend when clear -- strong recommendation when one option is clearly better, present options neutrally when it's a toss-up.
366
+
367
+ **Sub-step: approaches**
368
+ *Dimension 4: Approaches & Patterns*
369
+
370
+ Announce: "Identifying approaches and patterns..."
371
+
372
+ Identify how similar problems have been solved:
373
+ - Architectural patterns that apply
374
+ - Implementation strategies
375
+ - Sequencing (what to build first)
376
+ - What to avoid and why
377
+
378
+ **Sub-step: feasibility**
379
+ *Dimension 5: Feasibility Assessment*
380
+
381
+ Announce: "Assessing feasibility..."
382
+
383
+ Assess:
384
+ - **Stack fit**: How well does this fit the existing technology stack?
385
+ - **Effort estimate**: T-shirt size (S/M/L/XL) + approximate phase count
386
+ - **Key risks**: What could go wrong? What are the unknowns?
387
+ - **New dependencies**: Any new libraries, services, or external integrations needed?
388
+ - **Recommendation**: Overall go/no-go/conditional assessment
389
+
390
+ **Sub-step: write_document**
391
+ Create (or overwrite) the research document.
392
+
393
+ Ensure directory exists:
394
+ ```bash
395
+ mkdir -p ${project_root}/docs/ideas/pending
396
+ ```
397
+
398
+ Write the research document to `${project_root}/docs/ideas/pending/${SLUG}-research.md` using the Write tool.
399
+
400
+ Document structure:
401
+ ```markdown
402
+ ---
403
+ type: research
404
+ idea_id: {id}
405
+ idea_title: "{title}"
406
+ date: "{YYYY-MM-DD}"
407
+ repos_analysed: ["{repo1}", "{repo2}"]
408
+ ---
409
+
410
+ # Research: {title}
411
+
412
+ {If re-research and meaningful changes exist:}
413
+ ## Changes from Prior Research
414
+
415
+ {Bullet list of what's new, updated, or contradicted vs prior findings.}
416
+
417
+ ## Web Search Findings
418
+
419
+ {Findings from Dimension 1}
420
+
421
+ ## Codebase Analysis
422
+
423
+ {Findings from Dimension 2. For multi-repo: subsections per repo.}
424
+
425
+ ## Landscape Survey
426
+
427
+ {Findings from Dimension 3. Comparison tables where applicable.}
428
+
429
+ ## Approaches & Patterns
430
+
431
+ {Findings from Dimension 4}
432
+
433
+ ## Feasibility Assessment
434
+
435
+ **Stack Fit:** {assessment}
436
+ **Effort:** {T-shirt size} -- {phase count estimate}
437
+ **Key Risks:**
438
+ {bullet list}
439
+ **New Dependencies:**
440
+ {bullet list or "None"}
441
+ **Recommendation:** {go / no-go / conditional with conditions}
442
+
443
+ ---
444
+ *Researched: {YYYY-MM-DD}*
445
+ ```
446
+
447
+ If repos_analysed is empty (no REPOS.md), omit the field from frontmatter or use an empty array.
448
+
449
+ **Sub-step: save_research_log**
450
+ Save the Research Log entry to the idea file via the CLI command.
451
+
452
+ Build the entry JSON:
453
+ ```json
454
+ {
455
+ "date": "YYYY-MM-DD",
456
+ "summary": "{Actionable summary paragraph}",
457
+ "keyFindings": "- {finding 1}\n- {finding 2}\n- {finding 3}",
458
+ "recommendation": "{Strong recommendation or neutral options presentation}",
459
+ "documentLink": "${project_root}/docs/ideas/pending/${SLUG}-research.md",
460
+ "outcome": "{Recommended next step: 'Ready for spec', 'Needs more discussion', 'Not feasible', etc.}"
461
+ }
462
+ ```
463
+
464
+ Call:
465
+ ```bash
466
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs ideas research-save --id "${id}" --entry '${entryJson}'
467
+ ```
468
+
469
+ Parse the JSON result to confirm success.
470
+ </step>
471
+
472
+ <step name="research_commit">
473
+ Commit both the research document and the updated idea file:
474
+ ```bash
475
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "docs: research idea #${id} -- ${title}" --files ${project_root}/docs/ideas/pending/${SLUG}-research.md ${project_root}/ideas/${state}/${filename}
476
+ ```
477
+ </step>
478
+
479
+ <step name="completion_summary">
480
+ Display a unified summary combining both phases.
481
+
482
+ **If both discussion and research ran:**
483
+ ```
484
+ Development Complete: ${title}
485
+
486
+ Discussion: ${decision}
487
+ Research: ${recommendation}
488
+ Key finding: ${keyFinding}
489
+
490
+ Next step: ${contextAwareNextStep}
491
+
492
+ Files:
493
+ - ${project_root}/ideas/${state}/${filename}
494
+ - ${project_root}/docs/ideas/pending/${SLUG}-research.md
495
+ ```
496
+
497
+ **If only discussion ran** (research skipped by decision routing, user choice, or partial exit):
498
+ ```
499
+ Discussion Complete: ${title}
500
+
501
+ Decision: ${decision}
502
+
503
+ Next step: ${contextAwareNextStep}
504
+
505
+ Files:
506
+ - ${project_root}/ideas/${state}/${filename}
507
+ ```
508
+
509
+ **If only research ran** (user chose "Just research" in assess_history):
510
+ ```
511
+ Research Complete: ${title}
512
+
513
+ Research: ${recommendation}
514
+ Key finding: ${keyFinding}
515
+
516
+ Next step: ${contextAwareNextStep}
517
+
518
+ Files:
519
+ - ${project_root}/ideas/${state}/${filename}
520
+ - ${project_root}/docs/ideas/pending/${SLUG}-research.md
521
+ ```
522
+
523
+ **Context-aware next step logic:**
524
+ - Both discussion and research say "ready" -> suggest `/dgs:write-spec`
525
+ - Research says "not feasible" but discussion was positive -> suggest revisiting the idea
526
+ - Research says "needs more discussion" -> suggest `/dgs:discuss-idea ${id}`
527
+ - Idea was rejected in discussion -> suggest `/dgs:reject-idea ${id}` or rethinking
528
+ - Default (both phases completed successfully) -> suggest `/dgs:write-spec`
529
+ </step>
530
+
531
+ </process>
532
+
533
+ <success_criteria>
534
+ - [ ] Idea loaded with full context including prior history
535
+ - [ ] Prior history status displayed (if applicable)
536
+ - [ ] Re-run choice offered (if applicable)
537
+ - [ ] Discussion phase completed (or partial save on exit)
538
+ - [ ] Discussion committed before research starts
539
+ - [ ] Decision routing applied (skip research on negative decisions)
540
+ - [ ] Research phase completed (if applicable)
541
+ - [ ] Research document and idea file committed together
542
+ - [ ] Unified completion summary with context-aware next step
543
+ - [ ] File paths listed in footer
544
+ </success_criteria>