@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,257 @@
1
+ # Architecture Template
2
+
3
+ Template for `codebase/ARCHITECTURE.md` (in planning root) - captures conceptual code organization.
4
+
5
+ > **Layout-agnostic:** Workflows access the codebase directory via `${codebase_dir}` from init output. Works in both standard and root layouts.
6
+
7
+ **Purpose:** Document how the code is organized at a conceptual level. Complements STRUCTURE.md (which shows physical file locations).
8
+
9
+ ---
10
+
11
+ ## File Template
12
+
13
+ ```markdown
14
+ # Architecture
15
+
16
+ **Analysis Date:** [YYYY-MM-DD]
17
+
18
+ ## Pattern Overview
19
+
20
+ **Overall:** [Pattern name: e.g., "Monolithic CLI", "Serverless API", "Full-stack MVC"]
21
+
22
+ **Key Characteristics:**
23
+ - [Characteristic 1: e.g., "Single executable"]
24
+ - [Characteristic 2: e.g., "Stateless request handling"]
25
+ - [Characteristic 3: e.g., "Event-driven"]
26
+
27
+ ## Layers
28
+
29
+ [Describe the conceptual layers and their responsibilities]
30
+
31
+ **[Layer Name]:**
32
+ - Purpose: [What this layer does]
33
+ - Contains: [Types of code: e.g., "route handlers", "business logic"]
34
+ - Depends on: [What it uses: e.g., "data layer only"]
35
+ - Used by: [What uses it: e.g., "API routes"]
36
+
37
+ **[Layer Name]:**
38
+ - Purpose: [What this layer does]
39
+ - Contains: [Types of code]
40
+ - Depends on: [What it uses]
41
+ - Used by: [What uses it]
42
+
43
+ ## Data Flow
44
+
45
+ [Describe the typical request/execution lifecycle]
46
+
47
+ **[Flow Name] (e.g., "HTTP Request", "CLI Command", "Event Processing"):**
48
+
49
+ 1. [Entry point: e.g., "User runs command"]
50
+ 2. [Processing step: e.g., "Router matches path"]
51
+ 3. [Processing step: e.g., "Controller validates input"]
52
+ 4. [Processing step: e.g., "Service executes logic"]
53
+ 5. [Output: e.g., "Response returned"]
54
+
55
+ **State Management:**
56
+ - [How state is handled: e.g., "Stateless - no persistent state", "Database per request", "In-memory cache"]
57
+
58
+ ## Key Abstractions
59
+
60
+ [Core concepts/patterns used throughout the codebase]
61
+
62
+ **[Abstraction Name]:**
63
+ - Purpose: [What it represents]
64
+ - Examples: [e.g., "UserService, ProjectService"]
65
+ - Pattern: [e.g., "Singleton", "Factory", "Repository"]
66
+
67
+ **[Abstraction Name]:**
68
+ - Purpose: [What it represents]
69
+ - Examples: [Concrete examples]
70
+ - Pattern: [Pattern used]
71
+
72
+ ## Entry Points
73
+
74
+ [Where execution begins]
75
+
76
+ **[Entry Point]:**
77
+ - Location: [Brief: e.g., "src/index.ts", "API Gateway triggers"]
78
+ - Triggers: [What invokes it: e.g., "CLI invocation", "HTTP request"]
79
+ - Responsibilities: [What it does: e.g., "Parse args, route to command"]
80
+
81
+ ## Error Handling
82
+
83
+ **Strategy:** [How errors are handled: e.g., "Exception bubbling to top-level handler", "Per-route error middleware"]
84
+
85
+ **Patterns:**
86
+ - [Pattern: e.g., "try/catch at controller level"]
87
+ - [Pattern: e.g., "Error codes returned to user"]
88
+
89
+ ## Cross-Cutting Concerns
90
+
91
+ [Aspects that affect multiple layers]
92
+
93
+ **Logging:**
94
+ - [Approach: e.g., "Winston logger, injected per-request"]
95
+
96
+ **Validation:**
97
+ - [Approach: e.g., "Zod schemas at API boundary"]
98
+
99
+ **Authentication:**
100
+ - [Approach: e.g., "JWT middleware on protected routes"]
101
+
102
+ ---
103
+
104
+ *Architecture analysis: [date]*
105
+ *Update when major patterns change*
106
+ ```
107
+
108
+ <good_examples>
109
+ ```markdown
110
+ # Architecture
111
+
112
+ **Analysis Date:** 2025-01-20
113
+
114
+ ## Pattern Overview
115
+
116
+ **Overall:** CLI Application with Plugin System
117
+
118
+ **Key Characteristics:**
119
+ - Single executable with subcommands
120
+ - Plugin-based extensibility
121
+ - File-based state (no database)
122
+ - Synchronous execution model
123
+
124
+ ## Layers
125
+
126
+ **Command Layer:**
127
+ - Purpose: Parse user input and route to appropriate handler
128
+ - Contains: Command definitions, argument parsing, help text
129
+ - Location: `src/commands/*.ts`
130
+ - Depends on: Service layer for business logic
131
+ - Used by: CLI entry point (`src/index.ts`)
132
+
133
+ **Service Layer:**
134
+ - Purpose: Core business logic
135
+ - Contains: FileService, TemplateService, InstallService
136
+ - Location: `src/services/*.ts`
137
+ - Depends on: File system utilities, external tools
138
+ - Used by: Command handlers
139
+
140
+ **Utility Layer:**
141
+ - Purpose: Shared helpers and abstractions
142
+ - Contains: File I/O wrappers, path resolution, string formatting
143
+ - Location: `src/utils/*.ts`
144
+ - Depends on: Node.js built-ins only
145
+ - Used by: Service layer
146
+
147
+ ## Data Flow
148
+
149
+ **CLI Command Execution:**
150
+
151
+ 1. User runs: `dgs new-project`
152
+ 2. Commander parses args and flags
153
+ 3. Command handler invoked (`src/commands/new-project.ts`)
154
+ 4. Handler calls service methods (`src/services/project.ts` → `create()`)
155
+ 5. Service reads templates, processes files, writes output
156
+ 6. Results logged to console
157
+ 7. Process exits with status code
158
+
159
+ **State Management:**
160
+ - File-based: All state lives in the planning directory
161
+ - No persistent in-memory state
162
+ - Each command execution is independent
163
+
164
+ ## Key Abstractions
165
+
166
+ **Service:**
167
+ - Purpose: Encapsulate business logic for a domain
168
+ - Examples: `src/services/file.ts`, `src/services/template.ts`, `src/services/project.ts`
169
+ - Pattern: Singleton-like (imported as modules, not instantiated)
170
+
171
+ **Command:**
172
+ - Purpose: CLI command definition
173
+ - Examples: `src/commands/new-project.ts`, `src/commands/plan-phase.ts`
174
+ - Pattern: Commander.js command registration
175
+
176
+ **Template:**
177
+ - Purpose: Reusable document structures
178
+ - Examples: PROJECT.md, PLAN.md templates
179
+ - Pattern: Markdown files with substitution variables
180
+
181
+ ## Entry Points
182
+
183
+ **CLI Entry:**
184
+ - Location: `src/index.ts`
185
+ - Triggers: User runs `dgs <command>`
186
+ - Responsibilities: Register commands, parse args, display help
187
+
188
+ **Commands:**
189
+ - Location: `src/commands/*.ts`
190
+ - Triggers: Matched command from CLI
191
+ - Responsibilities: Validate input, call services, format output
192
+
193
+ ## Error Handling
194
+
195
+ **Strategy:** Throw exceptions, catch at command level, log and exit
196
+
197
+ **Patterns:**
198
+ - Services throw Error with descriptive messages
199
+ - Command handlers catch, log error to stderr, exit(1)
200
+ - Validation errors shown before execution (fail fast)
201
+
202
+ ## Cross-Cutting Concerns
203
+
204
+ **Logging:**
205
+ - Console.log for normal output
206
+ - Console.error for errors
207
+ - Chalk for colored output
208
+
209
+ **Validation:**
210
+ - Zod schemas for config file parsing
211
+ - Manual validation in command handlers
212
+ - Fail fast on invalid input
213
+
214
+ **File Operations:**
215
+ - FileService abstraction over fs-extra
216
+ - All paths validated before operations
217
+ - Atomic writes (temp file + rename)
218
+
219
+ ---
220
+
221
+ *Architecture analysis: 2025-01-20*
222
+ *Update when major patterns change*
223
+ ```
224
+ </good_examples>
225
+
226
+ <guidelines>
227
+ **What belongs in ARCHITECTURE.md:**
228
+ - Overall architectural pattern (monolith, microservices, layered, etc.)
229
+ - Conceptual layers and their relationships
230
+ - Data flow / request lifecycle
231
+ - Key abstractions and patterns
232
+ - Entry points
233
+ - Error handling strategy
234
+ - Cross-cutting concerns (logging, auth, validation)
235
+
236
+ **What does NOT belong here:**
237
+ - Exhaustive file listings (that's STRUCTURE.md)
238
+ - Technology choices (that's STACK.md)
239
+ - Line-by-line code walkthrough (defer to code reading)
240
+ - Implementation details of specific features
241
+
242
+ **File paths ARE welcome:**
243
+ Include file paths as concrete examples of abstractions. Use backtick formatting: `src/services/user.ts`. This makes the architecture document actionable for Claude when planning.
244
+
245
+ **When filling this template:**
246
+ - Read main entry points (index, server, main)
247
+ - Identify layers by reading imports/dependencies
248
+ - Trace a typical request/command execution
249
+ - Note recurring patterns (services, controllers, repositories)
250
+ - Keep descriptions conceptual, not mechanical
251
+
252
+ **Useful for phase planning when:**
253
+ - Adding new features (where does it fit in the layers?)
254
+ - Refactoring (understanding current patterns)
255
+ - Identifying where to add code (which layer handles X?)
256
+ - Understanding dependencies between components
257
+ </guidelines>
@@ -0,0 +1,312 @@
1
+ # Codebase Concerns Template
2
+
3
+ Template for `codebase/CONCERNS.md` (in planning root) - captures known issues and areas requiring care.
4
+
5
+ > **Layout-agnostic:** Workflows access the codebase directory via `${codebase_dir}` from init output. Works in both standard and root layouts.
6
+
7
+ **Purpose:** Surface actionable warnings about the codebase. Focused on "what to watch out for when making changes."
8
+
9
+ ---
10
+
11
+ ## File Template
12
+
13
+ ```markdown
14
+ # Codebase Concerns
15
+
16
+ **Analysis Date:** [YYYY-MM-DD]
17
+
18
+ ## Tech Debt
19
+
20
+ **[Area/Component]:**
21
+ - Issue: [What's the shortcut/workaround]
22
+ - Why: [Why it was done this way]
23
+ - Impact: [What breaks or degrades because of it]
24
+ - Fix approach: [How to properly address it]
25
+
26
+ **[Area/Component]:**
27
+ - Issue: [What's the shortcut/workaround]
28
+ - Why: [Why it was done this way]
29
+ - Impact: [What breaks or degrades because of it]
30
+ - Fix approach: [How to properly address it]
31
+
32
+ ## Known Bugs
33
+
34
+ **[Bug description]:**
35
+ - Symptoms: [What happens]
36
+ - Trigger: [How to reproduce]
37
+ - Workaround: [Temporary mitigation if any]
38
+ - Root cause: [If known]
39
+ - Blocked by: [If waiting on something]
40
+
41
+ **[Bug description]:**
42
+ - Symptoms: [What happens]
43
+ - Trigger: [How to reproduce]
44
+ - Workaround: [Temporary mitigation if any]
45
+ - Root cause: [If known]
46
+
47
+ ## Security Considerations
48
+
49
+ **[Area requiring security care]:**
50
+ - Risk: [What could go wrong]
51
+ - Current mitigation: [What's in place now]
52
+ - Recommendations: [What should be added]
53
+
54
+ **[Area requiring security care]:**
55
+ - Risk: [What could go wrong]
56
+ - Current mitigation: [What's in place now]
57
+ - Recommendations: [What should be added]
58
+
59
+ ## Performance Bottlenecks
60
+
61
+ **[Slow operation/endpoint]:**
62
+ - Problem: [What's slow]
63
+ - Measurement: [Actual numbers: "500ms p95", "2s load time"]
64
+ - Cause: [Why it's slow]
65
+ - Improvement path: [How to speed it up]
66
+
67
+ **[Slow operation/endpoint]:**
68
+ - Problem: [What's slow]
69
+ - Measurement: [Actual numbers]
70
+ - Cause: [Why it's slow]
71
+ - Improvement path: [How to speed it up]
72
+
73
+ ## Fragile Areas
74
+
75
+ **[Component/Module]:**
76
+ - Why fragile: [What makes it break easily]
77
+ - Common failures: [What typically goes wrong]
78
+ - Safe modification: [How to change it without breaking]
79
+ - Test coverage: [Is it tested? Gaps?]
80
+
81
+ **[Component/Module]:**
82
+ - Why fragile: [What makes it break easily]
83
+ - Common failures: [What typically goes wrong]
84
+ - Safe modification: [How to change it without breaking]
85
+ - Test coverage: [Is it tested? Gaps?]
86
+
87
+ ## Scaling Limits
88
+
89
+ **[Resource/System]:**
90
+ - Current capacity: [Numbers: "100 req/sec", "10k users"]
91
+ - Limit: [Where it breaks]
92
+ - Symptoms at limit: [What happens]
93
+ - Scaling path: [How to increase capacity]
94
+
95
+ ## Dependencies at Risk
96
+
97
+ **[Package/Service]:**
98
+ - Risk: [e.g., "deprecated", "unmaintained", "breaking changes coming"]
99
+ - Impact: [What breaks if it fails]
100
+ - Migration plan: [Alternative or upgrade path]
101
+
102
+ ## Missing Critical Features
103
+
104
+ **[Feature gap]:**
105
+ - Problem: [What's missing]
106
+ - Current workaround: [How users cope]
107
+ - Blocks: [What can't be done without it]
108
+ - Implementation complexity: [Rough effort estimate]
109
+
110
+ ## Test Coverage Gaps
111
+
112
+ **[Untested area]:**
113
+ - What's not tested: [Specific functionality]
114
+ - Risk: [What could break unnoticed]
115
+ - Priority: [High/Medium/Low]
116
+ - Difficulty to test: [Why it's not tested yet]
117
+
118
+ ---
119
+
120
+ *Concerns audit: [date]*
121
+ *Update as issues are fixed or new ones discovered*
122
+ ```
123
+
124
+ <good_examples>
125
+ ```markdown
126
+ # Codebase Concerns
127
+
128
+ **Analysis Date:** 2025-01-20
129
+
130
+ ## Tech Debt
131
+
132
+ **Database queries in React components:**
133
+ - Issue: Direct Supabase queries in 15+ page components instead of server actions
134
+ - Files: `app/dashboard/page.tsx`, `app/profile/page.tsx`, `app/courses/[id]/page.tsx`, `app/settings/page.tsx` (and 11 more in `app/`)
135
+ - Why: Rapid prototyping during MVP phase
136
+ - Impact: Can't implement RLS properly, exposes DB structure to client
137
+ - Fix approach: Move all queries to server actions in `app/actions/`, add proper RLS policies
138
+
139
+ **Manual webhook signature validation:**
140
+ - Issue: Copy-pasted Stripe webhook verification code in 3 different endpoints
141
+ - Files: `app/api/webhooks/stripe/route.ts`, `app/api/webhooks/checkout/route.ts`, `app/api/webhooks/subscription/route.ts`
142
+ - Why: Each webhook added ad-hoc without abstraction
143
+ - Impact: Easy to miss verification in new webhooks (security risk)
144
+ - Fix approach: Create shared `lib/stripe/validate-webhook.ts` middleware
145
+
146
+ ## Known Bugs
147
+
148
+ **Race condition in subscription updates:**
149
+ - Symptoms: User shows as "free" tier for 5-10 seconds after successful payment
150
+ - Trigger: Fast navigation after Stripe checkout redirect, before webhook processes
151
+ - Files: `app/checkout/success/page.tsx` (redirect handler), `app/api/webhooks/stripe/route.ts` (webhook)
152
+ - Workaround: Stripe webhook eventually updates status (self-heals)
153
+ - Root cause: Webhook processing slower than user navigation, no optimistic UI update
154
+ - Fix: Add polling in `app/checkout/success/page.tsx` after redirect
155
+
156
+ **Inconsistent session state after logout:**
157
+ - Symptoms: User redirected to /dashboard after logout instead of /login
158
+ - Trigger: Logout via button in mobile nav (desktop works fine)
159
+ - File: `components/MobileNav.tsx` (line ~45, logout handler)
160
+ - Workaround: Manual URL navigation to /login works
161
+ - Root cause: Mobile nav component not awaiting supabase.auth.signOut()
162
+ - Fix: Add await to logout handler in `components/MobileNav.tsx`
163
+
164
+ ## Security Considerations
165
+
166
+ **Admin role check client-side only:**
167
+ - Risk: Admin dashboard pages check isAdmin from Supabase client, no server verification
168
+ - Files: `app/admin/page.tsx`, `app/admin/users/page.tsx`, `components/AdminGuard.tsx`
169
+ - Current mitigation: None (relying on UI hiding)
170
+ - Recommendations: Add middleware to admin routes in `middleware.ts`, verify role server-side
171
+
172
+ **Unvalidated file uploads:**
173
+ - Risk: Users can upload any file type to avatar bucket (no size/type validation)
174
+ - File: `components/AvatarUpload.tsx` (upload handler)
175
+ - Current mitigation: Supabase bucket limits to 2MB (configured in dashboard)
176
+ - Recommendations: Add file type validation (image/* only) in `lib/storage/validate.ts`
177
+
178
+ ## Performance Bottlenecks
179
+
180
+ **/api/courses endpoint:**
181
+ - Problem: Fetching all courses with nested lessons and authors
182
+ - File: `app/api/courses/route.ts`
183
+ - Measurement: 1.2s p95 response time with 50+ courses
184
+ - Cause: N+1 query pattern (separate query per course for lessons)
185
+ - Improvement path: Use Prisma include to eager-load lessons in `lib/db/courses.ts`, add Redis caching
186
+
187
+ **Dashboard initial load:**
188
+ - Problem: Waterfall of 5 serial API calls on mount
189
+ - File: `app/dashboard/page.tsx`
190
+ - Measurement: 3.5s until interactive on slow 3G
191
+ - Cause: Each component fetches own data independently
192
+ - Improvement path: Convert to Server Component with single parallel fetch
193
+
194
+ ## Fragile Areas
195
+
196
+ **Authentication middleware chain:**
197
+ - File: `middleware.ts`
198
+ - Why fragile: 4 different middleware functions run in specific order (auth -> role -> subscription -> logging)
199
+ - Common failures: Middleware order change breaks everything, hard to debug
200
+ - Safe modification: Add tests before changing order, document dependencies in comments
201
+ - Test coverage: No integration tests for middleware chain (only unit tests)
202
+
203
+ **Stripe webhook event handling:**
204
+ - File: `app/api/webhooks/stripe/route.ts`
205
+ - Why fragile: Giant switch statement with 12 event types, shared transaction logic
206
+ - Common failures: New event type added without handling, partial DB updates on error
207
+ - Safe modification: Extract each event handler to `lib/stripe/handlers/*.ts`
208
+ - Test coverage: Only 3 of 12 event types have tests
209
+
210
+ ## Scaling Limits
211
+
212
+ **Supabase Free Tier:**
213
+ - Current capacity: 500MB database, 1GB file storage, 2GB bandwidth/month
214
+ - Limit: ~5000 users estimated before hitting limits
215
+ - Symptoms at limit: 429 rate limit errors, DB writes fail
216
+ - Scaling path: Upgrade to Pro ($25/mo) extends to 8GB DB, 100GB storage
217
+
218
+ **Server-side render blocking:**
219
+ - Current capacity: ~50 concurrent users before slowdown
220
+ - Limit: Vercel Hobby plan (10s function timeout, 100GB-hrs/mo)
221
+ - Symptoms at limit: 504 gateway timeouts on course pages
222
+ - Scaling path: Upgrade to Vercel Pro ($20/mo), add edge caching
223
+
224
+ ## Dependencies at Risk
225
+
226
+ **react-hot-toast:**
227
+ - Risk: Unmaintained (last update 18 months ago), React 19 compatibility unknown
228
+ - Impact: Toast notifications break, no graceful degradation
229
+ - Migration plan: Switch to sonner (actively maintained, similar API)
230
+
231
+ ## Missing Critical Features
232
+
233
+ **Payment failure handling:**
234
+ - Problem: No retry mechanism or user notification when subscription payment fails
235
+ - Current workaround: Users manually re-enter payment info (if they notice)
236
+ - Blocks: Can't retain users with expired cards, no dunning process
237
+ - Implementation complexity: Medium (Stripe webhooks + email flow + UI)
238
+
239
+ **Course progress tracking:**
240
+ - Problem: No persistent state for which lessons completed
241
+ - Current workaround: Users manually track progress
242
+ - Blocks: Can't show completion percentage, can't recommend next lesson
243
+ - Implementation complexity: Low (add completed_lessons junction table)
244
+
245
+ ## Test Coverage Gaps
246
+
247
+ **Payment flow end-to-end:**
248
+ - What's not tested: Full Stripe checkout -> webhook -> subscription activation flow
249
+ - Risk: Payment processing could break silently (has happened twice)
250
+ - Priority: High
251
+ - Difficulty to test: Need Stripe test fixtures and webhook simulation setup
252
+
253
+ **Error boundary behavior:**
254
+ - What's not tested: How app behaves when components throw errors
255
+ - Risk: White screen of death for users, no error reporting
256
+ - Priority: Medium
257
+ - Difficulty to test: Need to intentionally trigger errors in test environment
258
+
259
+ ---
260
+
261
+ *Concerns audit: 2025-01-20*
262
+ *Update as issues are fixed or new ones discovered*
263
+ ```
264
+ </good_examples>
265
+
266
+ <guidelines>
267
+ **What belongs in CONCERNS.md:**
268
+ - Tech debt with clear impact and fix approach
269
+ - Known bugs with reproduction steps
270
+ - Security gaps and mitigation recommendations
271
+ - Performance bottlenecks with measurements
272
+ - Fragile code that breaks easily
273
+ - Scaling limits with numbers
274
+ - Dependencies that need attention
275
+ - Missing features that block workflows
276
+ - Test coverage gaps
277
+
278
+ **What does NOT belong here:**
279
+ - Opinions without evidence ("code is messy")
280
+ - Complaints without solutions ("auth sucks")
281
+ - Future feature ideas (that's for product planning)
282
+ - Normal TODOs (those live in code comments)
283
+ - Architectural decisions that are working fine
284
+ - Minor code style issues
285
+
286
+ **When filling this template:**
287
+ - **Always include file paths** - Concerns without locations are not actionable. Use backticks: `src/file.ts`
288
+ - Be specific with measurements ("500ms p95" not "slow")
289
+ - Include reproduction steps for bugs
290
+ - Suggest fix approaches, not just problems
291
+ - Focus on actionable items
292
+ - Prioritize by risk/impact
293
+ - Update as issues get resolved
294
+ - Add new concerns as discovered
295
+
296
+ **Tone guidelines:**
297
+ - Professional, not emotional ("N+1 query pattern" not "terrible queries")
298
+ - Solution-oriented ("Fix: add index" not "needs fixing")
299
+ - Risk-focused ("Could expose user data" not "security is bad")
300
+ - Factual ("3.5s load time" not "really slow")
301
+
302
+ **Useful for phase planning when:**
303
+ - Deciding what to work on next
304
+ - Estimating risk of changes
305
+ - Understanding where to be careful
306
+ - Prioritizing improvements
307
+ - Onboarding new Claude contexts
308
+ - Planning refactoring work
309
+
310
+ **How this gets populated:**
311
+ Explore agents detect these during codebase mapping. Manual additions welcome for human-discovered issues. This is living documentation, not a complaint list.
312
+ </guidelines>