ultra-builder-pro-cli 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/.ultra-template/delivery-report.json +9 -0
  2. package/.ultra-template/docs/research/README.md +53 -0
  3. package/.ultra-template/specs/architecture.md +250 -0
  4. package/.ultra-template/specs/discovery.md +248 -0
  5. package/.ultra-template/specs/product.md +223 -0
  6. package/.ultra-template/tasks/contexts/TEMPLATE.md +57 -0
  7. package/.ultra-template/tasks/tasks.json +33 -0
  8. package/.ultra-template/test-report.json +8 -0
  9. package/CHANGELOG.md +194 -0
  10. package/LICENSE +21 -0
  11. package/README.md +187 -0
  12. package/adapters/_shared/codex-assets.cjs +1128 -0
  13. package/adapters/_shared/codex-ultra-tools-entry.cjs +11 -0
  14. package/adapters/_shared/file-ops.cjs +115 -0
  15. package/adapters/_shared/frontmatter.cjs +52 -0
  16. package/adapters/_shared/handbook.cjs +144 -0
  17. package/adapters/_shared/md-to-toml.cjs +54 -0
  18. package/adapters/_shared/path-rewrite.cjs +79 -0
  19. package/adapters/_shared/rtk-detect.cjs +86 -0
  20. package/adapters/_shared/runtime-assets.cjs +70 -0
  21. package/adapters/_shared/settings-merge.cjs +76 -0
  22. package/adapters/_shared/tests/file-ops.test.cjs +54 -0
  23. package/adapters/_shared/tests/frontmatter.test.cjs +47 -0
  24. package/adapters/_shared/tests/handbook.test.cjs +86 -0
  25. package/adapters/_shared/tests/md-to-toml.test.cjs +48 -0
  26. package/adapters/_shared/tests/path-rewrite.test.cjs +60 -0
  27. package/adapters/_shared/tests/resolve-target.test.cjs +85 -0
  28. package/adapters/_shared/tests/rtk-detect.test.cjs +116 -0
  29. package/adapters/_shared/tests/runtime-assets.test.cjs +107 -0
  30. package/adapters/_shared/tests/settings-merge.test.cjs +85 -0
  31. package/adapters/_shared/tests/validate.test.cjs +30 -0
  32. package/adapters/_shared/validate.cjs +24 -0
  33. package/adapters/claude.js +182 -0
  34. package/adapters/codex.js +385 -0
  35. package/adapters/gemini.js +204 -0
  36. package/adapters/opencode.js +506 -0
  37. package/adapters/tests/claude.test.cjs +117 -0
  38. package/adapters/tests/codex-hook.test.cjs +90 -0
  39. package/adapters/tests/codex.test.cjs +356 -0
  40. package/adapters/tests/gemini.test.cjs +112 -0
  41. package/adapters/tests/opencode.test.cjs +246 -0
  42. package/agents/code-reviewer.md +102 -0
  43. package/agents/debugger.md +127 -0
  44. package/agents/review-code.md +125 -0
  45. package/agents/review-comments.md +98 -0
  46. package/agents/review-coordinator.md +146 -0
  47. package/agents/review-design.md +133 -0
  48. package/agents/review-errors.md +87 -0
  49. package/agents/review-tests.md +93 -0
  50. package/agents/tdd-runner.md +92 -0
  51. package/bin/handbook.js +54 -0
  52. package/bin/install.js +254 -0
  53. package/bin/orchestrator.js +214 -0
  54. package/commands/learn.md +41 -0
  55. package/commands/ultra-deliver.md +45 -0
  56. package/commands/ultra-dev.md +50 -0
  57. package/commands/ultra-init.md +51 -0
  58. package/commands/ultra-plan.md +49 -0
  59. package/commands/ultra-research.md +59 -0
  60. package/commands/ultra-status.md +46 -0
  61. package/commands/ultra-test.md +48 -0
  62. package/commands/ultra-think.md +45 -0
  63. package/docs/AGENT-CONTEXT.md +143 -0
  64. package/docs/ARCHITECTURE.md +197 -0
  65. package/docs/COMMIT-HASH-BACKFILL.md +101 -0
  66. package/docs/LEGACY-HERMES.md +1175 -0
  67. package/docs/PLAN.zh-CN.md +1683 -0
  68. package/docs/ROADMAP.md +102 -0
  69. package/docs/RUNTIME-COMPAT-MATRIX.md +98 -0
  70. package/docs/STATE-DB-ACCESS-POLICY.md +109 -0
  71. package/docs/USER-HANDBOOK-CONTRACT.md +61 -0
  72. package/hooks/README.md +24 -0
  73. package/hooks/active_task_context.py +44 -0
  74. package/hooks/adapters/codex.py +302 -0
  75. package/hooks/health_check.py +61 -0
  76. package/hooks/pre_stop_check.py +56 -0
  77. package/hooks/subagent_tracker.py +116 -0
  78. package/hooks/workflow_checkpoint.py +56 -0
  79. package/hooks/workflow_context.py +63 -0
  80. package/hooks/workflow_resume.py +50 -0
  81. package/mcp-server/lib/init-project.cjs +162 -0
  82. package/mcp-server/lib/llm-client.cjs +157 -0
  83. package/mcp-server/lib/llm-client.test.cjs +156 -0
  84. package/mcp-server/lib/plan-store.cjs +96 -0
  85. package/mcp-server/lib/plan-store.test.cjs +132 -0
  86. package/mcp-server/lib/prd-parser.cjs +110 -0
  87. package/mcp-server/lib/prd-parser.test.cjs +171 -0
  88. package/mcp-server/lib/pricing.cjs +53 -0
  89. package/mcp-server/lib/projector.cjs +158 -0
  90. package/mcp-server/lib/state-db.cjs +113 -0
  91. package/mcp-server/lib/state-db.test.cjs +116 -0
  92. package/mcp-server/lib/state-ops.cjs +725 -0
  93. package/mcp-server/lib/task-expander.cjs +123 -0
  94. package/mcp-server/lib/task-expander.test.cjs +253 -0
  95. package/mcp-server/lib/telemetry.cjs +72 -0
  96. package/mcp-server/lib/topo.cjs +131 -0
  97. package/mcp-server/lib/topo.test.cjs +158 -0
  98. package/mcp-server/server.cjs +482 -0
  99. package/mcp-server/tests/circuit-breaker.test.cjs +125 -0
  100. package/mcp-server/tests/commit-hash-flow.test.cjs +117 -0
  101. package/mcp-server/tests/concurrency-update.test.cjs +96 -0
  102. package/mcp-server/tests/concurrency.test.cjs +112 -0
  103. package/mcp-server/tests/db-ops.test.cjs +117 -0
  104. package/mcp-server/tests/init-project.test.cjs +141 -0
  105. package/mcp-server/tests/migrate.test.cjs +144 -0
  106. package/mcp-server/tests/projector.test.cjs +130 -0
  107. package/mcp-server/tests/server-contract.test.cjs +750 -0
  108. package/mcp-server/tests/staleness.test.cjs +190 -0
  109. package/mcp-server/tests/state-ops.test.cjs +286 -0
  110. package/mcp-server/tests/tagged-tasks.test.cjs +163 -0
  111. package/mcp-server/tests/telemetry.test.cjs +205 -0
  112. package/orchestrator/auto-merge.cjs +109 -0
  113. package/orchestrator/code-graph-watcher.cjs +121 -0
  114. package/orchestrator/daemon.cjs +112 -0
  115. package/orchestrator/dispatch-rules.cjs +93 -0
  116. package/orchestrator/parallel-orchestrator.cjs +195 -0
  117. package/orchestrator/planner/expand-prompt.cjs +62 -0
  118. package/orchestrator/planner/expand-prompt.test.cjs +52 -0
  119. package/orchestrator/planner/plan-builder.cjs +116 -0
  120. package/orchestrator/planner/plan-builder.test.cjs +165 -0
  121. package/orchestrator/planner/prd-prompt.cjs +44 -0
  122. package/orchestrator/planner/prd-prompt.test.cjs +30 -0
  123. package/orchestrator/recovery.cjs +70 -0
  124. package/orchestrator/session-runner.cjs +224 -0
  125. package/orchestrator/skill-miner.cjs +133 -0
  126. package/orchestrator/tests/auto-merge.test.cjs +216 -0
  127. package/orchestrator/tests/code-graph-watcher.test.cjs +183 -0
  128. package/orchestrator/tests/daemon.test.cjs +260 -0
  129. package/orchestrator/tests/dispatch-rules.test.cjs +122 -0
  130. package/orchestrator/tests/parallel-orchestrator.test.cjs +233 -0
  131. package/orchestrator/tests/phase-8b-gate.test.cjs +183 -0
  132. package/orchestrator/tests/recovery.test.cjs +190 -0
  133. package/orchestrator/tests/session-runner.test.cjs +314 -0
  134. package/orchestrator/tests/skill-miner.test.cjs +147 -0
  135. package/orchestrator/tests/worktree-manager.test.cjs +148 -0
  136. package/orchestrator/worktree-manager.cjs +131 -0
  137. package/output-styles/coding-vibes.md +67 -0
  138. package/output-styles/structural-thinking.md +61 -0
  139. package/package.json +109 -0
  140. package/settings.json +8 -0
  141. package/skills/cc-collab/SKILL.md +41 -0
  142. package/skills/code-review-expert/SKILL.md +118 -0
  143. package/skills/code-review-expert/references/code-quality-checklist.md +112 -0
  144. package/skills/code-review-expert/references/integration-checklist.md +46 -0
  145. package/skills/code-review-expert/references/removal-plan.md +52 -0
  146. package/skills/code-review-expert/references/security-checklist.md +100 -0
  147. package/skills/code-review-expert/references/solid-checklist.md +65 -0
  148. package/skills/codex-collab/SKILL.md +52 -0
  149. package/skills/codex-collab/evals/evals.json +40 -0
  150. package/skills/gemini-collab/SKILL.md +51 -0
  151. package/skills/gemini-collab/evals/evals.json +42 -0
  152. package/skills/integration-rules/SKILL.md +71 -0
  153. package/skills/learn/SKILL.md +117 -0
  154. package/skills/security-rules/SKILL.md +60 -0
  155. package/skills/testing-rules/SKILL.md +56 -0
  156. package/skills/ultra-deliver/SKILL.md +171 -0
  157. package/skills/ultra-dev/SKILL.md +324 -0
  158. package/skills/ultra-init/SKILL.md +148 -0
  159. package/skills/ultra-plan/SKILL.md +314 -0
  160. package/skills/ultra-research/SKILL.md +156 -0
  161. package/skills/ultra-research/steps/step-00-problem-validation.md +154 -0
  162. package/skills/ultra-research/steps/step-01-opportunity-discovery.md +172 -0
  163. package/skills/ultra-research/steps/step-02-market-assessment.md +195 -0
  164. package/skills/ultra-research/steps/step-03-competitive-landscape.md +197 -0
  165. package/skills/ultra-research/steps/step-04-product-strategy.md +196 -0
  166. package/skills/ultra-research/steps/step-05-assumptions-validation.md +234 -0
  167. package/skills/ultra-research/steps/step-10-user-personas.md +169 -0
  168. package/skills/ultra-research/steps/step-11-user-scenarios.md +181 -0
  169. package/skills/ultra-research/steps/step-20-user-stories.md +156 -0
  170. package/skills/ultra-research/steps/step-21-features-scope.md +157 -0
  171. package/skills/ultra-research/steps/step-22-success-metrics.md +195 -0
  172. package/skills/ultra-research/steps/step-30-architecture-context.md +154 -0
  173. package/skills/ultra-research/steps/step-31-solution-strategy.md +172 -0
  174. package/skills/ultra-research/steps/step-32-building-blocks.md +188 -0
  175. package/skills/ultra-research/steps/step-40-deployment.md +123 -0
  176. package/skills/ultra-research/steps/step-41-quality-risks.md +135 -0
  177. package/skills/ultra-research/steps/step-99-synthesis.md +188 -0
  178. package/skills/ultra-review/SKILL.md +437 -0
  179. package/skills/ultra-review/references/unified-schema.md +127 -0
  180. package/skills/ultra-review/scripts/review_verdict_update.py +99 -0
  181. package/skills/ultra-review/scripts/review_wait.py +120 -0
  182. package/skills/ultra-status/SKILL.md +162 -0
  183. package/skills/ultra-test/SKILL.md +195 -0
  184. package/skills/ultra-think/SKILL.md +109 -0
  185. package/skills/ultra-verify/SKILL.md +111 -0
  186. package/skills/ultra-verify/evals/evals.json +51 -0
  187. package/skills/ultra-verify/references/confidence-system.md +38 -0
  188. package/skills/ultra-verify/references/cross-verify-modes.md +73 -0
  189. package/skills/ultra-verify/scripts/verify_wait.py +131 -0
  190. package/spec/cli-protocol.md +118 -0
  191. package/spec/mcp-tools.yaml +658 -0
  192. package/spec/schemas/command-manifest.schema.json +47 -0
  193. package/spec/schemas/context-file.v4.5.schema.json +54 -0
  194. package/spec/schemas/mcp-tools.schema.json +136 -0
  195. package/spec/schemas/skill-manifest.schema.json +94 -0
  196. package/spec/schemas/state-db.sql +154 -0
  197. package/spec/schemas/tasks.v4.5.schema.json +66 -0
  198. package/ultra-tools/cli.cjs +121 -0
  199. package/ultra-tools/commands/db.cjs +175 -0
  200. package/ultra-tools/commands/legacy-memory.cjs +159 -0
  201. package/ultra-tools/commands/migrate.cjs +354 -0
  202. package/ultra-tools/commands/session.cjs +180 -0
  203. package/ultra-tools/commands/status.cjs +158 -0
  204. package/ultra-tools/commands/task.cjs +95 -0
  205. package/ultra-tools/legacy-memory.test.cjs +80 -0
  206. package/ultra-tools/status-command.test.cjs +132 -0
@@ -0,0 +1,195 @@
1
+ # Step 22: Success Metrics
2
+
3
+ ## MANDATORY EXECUTION RULES
4
+
5
+ - EVERY METRIC must have a specific numerical TARGET — not "improve X"
6
+ - INCLUDE both business AND user metrics
7
+ - DEFINE how each metric is MEASURED — not just what to measure
8
+ - BASELINE required — you can't improve what you haven't measured
9
+ - WRITE output to spec file BEFORE presenting to user
10
+ - ALL output in English (spec files); conversation in Chinese
11
+
12
+ ## PREREQUISITES
13
+
14
+ - Step 21 (Features & Scope) completed with [C]
15
+ - `.ultra/specs/product.md` §1-5 exist
16
+
17
+ ## CONTEXT BOUNDARIES
18
+
19
+ - Focus: How will we know if this product is succeeding?
20
+ - Metrics must be measurable, specific, and time-bound
21
+ - Connect metrics to strategic goals from step-04
22
+ - This is the LAST step of Round 2
23
+
24
+ ## SEARCH STRATEGY (MANDATORY)
25
+
26
+ Execute these web searches:
27
+
28
+ ```
29
+ Search: "{{product_domain}} key metrics KPIs benchmarks"
30
+ Search: "{{product_domain}} SaaS metrics success benchmarks"
31
+ Search: "{{product_domain}} user engagement retention benchmarks"
32
+ Search: "{{product_domain}} north star metric examples"
33
+ ```
34
+
35
+ ## EXECUTION SEQUENCE
36
+
37
+ ### 1. Define North Star Metric
38
+
39
+ Ask user via AskUserQuestion:
40
+ "What single metric best captures whether this product is delivering value? (e.g., 'Weekly active workflows completed', 'Time saved per user per week')"
41
+
42
+ The North Star Metric should:
43
+ - Reflect core value delivery
44
+ - Be leading (not lagging)
45
+ - Be actionable (team can influence it)
46
+
47
+ ### 2. Define Business Metrics
48
+
49
+ | Metric | What to define |
50
+ |--------|---------------|
51
+ | Revenue/adoption targets | Month 1, 3, 6, 12 |
52
+ | Growth rate | MoM or WoW targets |
53
+ | Retention | Day 1, Day 7, Day 30 |
54
+ | Conversion | Free → Paid (if applicable) |
55
+ | Unit economics | CAC, LTV, LTV/CAC ratio |
56
+
57
+ Use web search benchmarks for realistic targets.
58
+
59
+ ### 3. Define User Metrics
60
+
61
+ | Metric | What to define |
62
+ |--------|---------------|
63
+ | Task completion | Success rate for key scenarios |
64
+ | Time on task | vs baseline (current workflow) |
65
+ | User satisfaction | NPS or CSAT target |
66
+ | Feature adoption | % of users using key features |
67
+ | Error rate | Failure frequency |
68
+
69
+ ### 4. Write Output
70
+
71
+ **WRITE IMMEDIATELY** to `.ultra/specs/product.md` §6:
72
+
73
+ ```markdown
74
+ ## §6 Success Metrics
75
+
76
+ ### North Star Metric
77
+ - **Metric**: [Name]
78
+ - **Definition**: [Exactly what is measured]
79
+ - **Current baseline**: [Current state or industry benchmark]
80
+ - **Target**: [Specific number]
81
+ - **Timeline**: [When to achieve]
82
+ - **Measurement method**: [How to collect this data]
83
+
84
+ ### Business Metrics
85
+
86
+ | Metric | Baseline | Target (M3) | Target (M6) | Target (M12) | How Measured |
87
+ |--------|----------|-------------|-------------|--------------|-------------|
88
+ | [Revenue/Users] | [N/A or current] | [Target] | [Target] | [Target] | [Method] |
89
+ | [Growth rate] | [Benchmark] | [Target] | [Target] | [Target] | [Method] |
90
+ | [Retention D30] | [Benchmark] | [Target] | [Target] | [Target] | [Method] |
91
+ | [Conversion] | [Benchmark] | [Target] | [Target] | [Target] | [Method] |
92
+
93
+ _Benchmark sources: [URLs]_
94
+
95
+ ### User Metrics
96
+
97
+ | Metric | Baseline | Target | How Measured |
98
+ |--------|----------|--------|-------------|
99
+ | Task completion rate | [Current %] | [Target %] | [Method] |
100
+ | Time on task | [Current min] | [Target min] | [Method] |
101
+ | User satisfaction (NPS) | [Industry avg] | [Target] | [Survey] |
102
+ | Feature adoption | [N/A] | [Target %] | [Analytics] |
103
+ | Error rate | [Current %] | [Target %] | [Logging] |
104
+
105
+ ### Metric Prioritization
106
+
107
+ | Priority | Metric | Why |
108
+ |----------|--------|-----|
109
+ | P0 (check daily) | [North Star] | [Core value signal] |
110
+ | P0 (check daily) | [Critical metric] | [Business health] |
111
+ | P1 (check weekly) | [Important metric] | [Growth signal] |
112
+ | P2 (check monthly) | [Supporting metric] | [Quality signal] |
113
+
114
+ ### Anti-Metrics (What NOT to Optimize)
115
+
116
+ | Anti-Metric | Why Not | What It Could Sacrifice |
117
+ |------------|---------|------------------------|
118
+ | [e.g., Page views] | [Vanity metric] | [Could sacrifice quality for clicks] |
119
+ | [e.g., Time in app] | [Could mean confusion] | [Could sacrifice efficiency] |
120
+
121
+ ### Round 2 Summary
122
+
123
+ **Feature Definition Confidence**:
124
+ - **Story completeness**: [X]% — [One-line assessment]
125
+ - **Scope clarity**: [X]% — [One-line assessment]
126
+ - **Metric measurability**: [X]% — [One-line assessment]
127
+ - **Overall R2 confidence**: [X]%
128
+ ```
129
+
130
+ ### 5. Write Round 2 Research Report
131
+
132
+ **WRITE** to `.ultra/docs/research/feature-definition-{date}.md`:
133
+
134
+ ```markdown
135
+ # Round 2: Feature Definition
136
+
137
+ > **Confidence**: [X]%
138
+ > **Steps completed**: 20-22
139
+ > **Completed**: [date]
140
+
141
+ ## Key Findings
142
+ [3-5 bullet points]
143
+
144
+ ## Stories Created
145
+ [Count by priority: Must/Should/Could]
146
+
147
+ ## Scope Decisions
148
+ [Key inclusions and exclusions]
149
+
150
+ ## Metrics Defined
151
+ [North Star + top 3 metrics]
152
+ ```
153
+
154
+ ### 6. Present to User and Gate
155
+
156
+ Show the Success Metrics summary. Ask:
157
+ - Are the targets realistic?
158
+ - Is the North Star metric right?
159
+ - Any metrics missing?
160
+
161
+ ```
162
+ [C] Continue — Metrics defined, proceed to Round 3 (Architecture Design)
163
+ [R] Revise — Adjust targets or metrics
164
+ [D] Discuss — Explore specific metric benchmarks
165
+ ```
166
+
167
+ **HALT — wait for user response before proceeding.**
168
+
169
+ ### 7. Handle Response
170
+
171
+ - **[C]**: Load next step: `./step-30-architecture-context.md`
172
+ - **[R]**: Revise metrics, update product.md §6, re-present
173
+ - **[D]**: Deep-dive specific benchmarks, then re-present gate
174
+
175
+ ## SUCCESS METRICS
176
+
177
+ - North Star metric defined with baseline and target
178
+ - Business metrics have specific targets at M3/M6/M12
179
+ - User metrics have baselines and targets
180
+ - Benchmark sources cited from web search
181
+ - Anti-metrics defined (what NOT to optimize)
182
+ - Round 2 research report written
183
+ - Output written to product.md §6
184
+
185
+ ## FAILURE MODES
186
+
187
+ - Metrics without specific targets ("improve retention")
188
+ - No baseline or benchmark for comparison
189
+ - Only business metrics, no user metrics (or vice versa)
190
+ - Unrealistic targets (100% retention, 0% error rate)
191
+ - Not writing output before presenting to user
192
+
193
+ ## NEXT STEP
194
+
195
+ After user selects [C], read and follow: `./step-30-architecture-context.md`
@@ -0,0 +1,154 @@
1
+ # Step 30: Architecture Context
2
+
3
+ ## MANDATORY EXECUTION RULES
4
+
5
+ - WEB SEARCH REQUIRED — verify technology claims against official docs
6
+ - USE Context7 MCP for framework/library documentation lookups
7
+ - ARCHITECTURE FOLLOWS PRODUCT — decisions must trace to product requirements
8
+ - WRITE output to spec file BEFORE presenting to user
9
+ - ALL output in English (spec files); conversation in Chinese
10
+
11
+ ## PREREQUISITES
12
+
13
+ - Round 2 completed (steps 20-22) with [C], OR user chose "Architecture Change" starting at step-30
14
+ - `.ultra/specs/architecture.md` exists
15
+
16
+ ## CONTEXT BOUNDARIES
17
+
18
+ - Focus: Quality goals, constraints, and system context (arc42 §1-3)
19
+ - Decisions must be grounded in product requirements from product.md
20
+ - This is about WHAT the system must achieve, not HOW to build it (that's step-31)
21
+
22
+ ## SEARCH STRATEGY (MANDATORY)
23
+
24
+ ```
25
+ Search: "{{product_domain}} architecture quality attributes"
26
+ Search: "{{product_domain}} system integration patterns"
27
+ Search: "{{product_domain}} technical constraints regulations"
28
+ ```
29
+
30
+ Use Context7 MCP for specific framework/library documentation.
31
+
32
+ ## EXECUTION SEQUENCE
33
+
34
+ ### 1. Define Quality Goals
35
+
36
+ Derive from product.md §6 (Success Metrics) and user scenarios:
37
+
38
+ | Quality Attribute | Concrete Scenario | Priority |
39
+ |------------------|-------------------|----------|
40
+ | Performance | [e.g., "API response < 200ms for 95th percentile"] | [1-3] |
41
+ | Scalability | [e.g., "Handle 10K concurrent users"] | [1-3] |
42
+ | Security | [e.g., "SOC 2 compliance, encrypted at rest"] | [1-3] |
43
+ | Availability | [e.g., "99.9% uptime, < 5min recovery"] | [1-3] |
44
+ | Maintainability | [e.g., "New developer productive in < 1 week"] | [1-3] |
45
+
46
+ Ask user via AskUserQuestion: "Which quality attributes matter most? Performance? Security? Scalability?"
47
+
48
+ ### 2. Identify Constraints
49
+
50
+ **Technical constraints**:
51
+ - Required platforms/browsers
52
+ - Mandatory integrations
53
+ - Technology restrictions (e.g., "must use Python for ML team compatibility")
54
+
55
+ **Organizational constraints**:
56
+ - Team size and skill profile
57
+ - Budget limitations
58
+ - Timeline constraints
59
+
60
+ **Regulatory constraints**:
61
+ - Data privacy (GDPR, CCPA)
62
+ - Industry regulations
63
+ - Compliance requirements
64
+
65
+ ### 3. Map System Context
66
+
67
+ Identify all external systems and interfaces:
68
+
69
+ **Users**: Who interacts with the system?
70
+ **External systems**: What APIs, services, databases does it connect to?
71
+ **Data flows**: What data enters and leaves the system?
72
+
73
+ ### 4. Write Output
74
+
75
+ **WRITE IMMEDIATELY** to `.ultra/specs/architecture.md` §1-3:
76
+
77
+ ```markdown
78
+ ## §1 Quality Goals
79
+
80
+ | Priority | Quality Attribute | Scenario | Metric |
81
+ |----------|------------------|----------|--------|
82
+ | 1 | [Attribute] | [Concrete scenario] | [Measurable target] |
83
+ | 2 | [Attribute] | [Concrete scenario] | [Measurable target] |
84
+ | 3 | [Attribute] | [Concrete scenario] | [Measurable target] |
85
+
86
+ ## §2 Constraints
87
+
88
+ ### Technical Constraints
89
+ | Constraint | Rationale | Impact |
90
+ |-----------|-----------|--------|
91
+ | [Constraint] | [Why this exists] | [What it limits] |
92
+
93
+ ### Organizational Constraints
94
+ | Constraint | Rationale | Impact |
95
+ |-----------|-----------|--------|
96
+ | [Constraint] | [Why this exists] | [What it limits] |
97
+
98
+ ### Regulatory Constraints
99
+ | Constraint | Rationale | Impact |
100
+ |-----------|-----------|--------|
101
+ | [Constraint] | [Why this exists] | [What it limits] |
102
+
103
+ ## §3 System Context
104
+
105
+ ### Context Diagram
106
+
107
+ **Users**:
108
+ - [User type 1]: [How they interact]
109
+ - [User type 2]: [How they interact]
110
+
111
+ **External Systems**:
112
+ | System | Direction | Data | Protocol | Notes |
113
+ |--------|-----------|------|----------|-------|
114
+ | [System A] | Inbound | [What data] | [REST/gRPC/etc] | [Notes] |
115
+ | [System B] | Outbound | [What data] | [Protocol] | [Notes] |
116
+ | [System C] | Bidirectional | [What data] | [Protocol] | [Notes] |
117
+
118
+ **Data Flows**:
119
+ - [User] → [System] → [External]: [Description of flow]
120
+ - [External] → [System] → [User]: [Description of flow]
121
+ ```
122
+
123
+ ### 5. Present to User and Gate
124
+
125
+ ```
126
+ [C] Continue — Context defined, proceed to Solution Strategy
127
+ [R] Revise — Adjust quality goals, constraints, or context
128
+ ```
129
+
130
+ **HALT — wait for user response before proceeding.**
131
+
132
+ ### 6. Handle Response
133
+
134
+ - **[C]**: Load next step: `./step-31-solution-strategy.md`
135
+ - **[R]**: Revise, update architecture.md §1-3, re-present
136
+
137
+ ## SUCCESS METRICS
138
+
139
+ - Quality goals are specific and measurable (not "good performance")
140
+ - Constraints identified across technical/organizational/regulatory
141
+ - System context shows all external interfaces
142
+ - All quality goals trace to product requirements
143
+ - Output written to architecture.md §1-3
144
+
145
+ ## FAILURE MODES
146
+
147
+ - Vague quality goals ("system should be fast")
148
+ - Missing regulatory constraints
149
+ - System context missing key external integrations
150
+ - Quality goals not derived from product requirements
151
+
152
+ ## NEXT STEP
153
+
154
+ After user selects [C], read and follow: `./step-31-solution-strategy.md`
@@ -0,0 +1,172 @@
1
+ # Step 31: Solution Strategy & Tech Stack
2
+
3
+ ## MANDATORY EXECUTION RULES
4
+
5
+ - WEB SEARCH REQUIRED — verify all technology claims
6
+ - USE Context7 MCP for framework documentation
7
+ - COMPARE TOP 3 OPTIONS for every major tech decision
8
+ - EVERY CHOICE needs RATIONALE — "it's popular" is not enough
9
+ - WRITE output to spec file BEFORE presenting to user
10
+ - ALL output in English (spec files); conversation in Chinese
11
+
12
+ ## PREREQUISITES
13
+
14
+ - Step 30 (Architecture Context) completed with [C]
15
+ - `.ultra/specs/architecture.md` §1-3 exist
16
+
17
+ ## CONTEXT BOUNDARIES
18
+
19
+ - Focus: Tech stack selection with evidence-based rationale (arc42 §4)
20
+ - Decisions must satisfy quality goals from §1
21
+ - Decisions must respect constraints from §2
22
+ - Compare options — never recommend without alternatives analyzed
23
+
24
+ ## SEARCH STRATEGY (MANDATORY)
25
+
26
+ For each major technology decision:
27
+
28
+ ```
29
+ Search: "[option A] vs [option B] vs [option C] {{product_domain}} 2024 2025"
30
+ Search: "[chosen framework] production performance benchmarks"
31
+ Search: "[chosen framework] scalability limitations"
32
+ Search: "[chosen database] vs alternatives for {{use_case}}"
33
+ ```
34
+
35
+ Use Context7 MCP: Query official docs for each selected technology.
36
+
37
+ ## EXECUTION SEQUENCE
38
+
39
+ ### 1. Identify Key Technology Decisions
40
+
41
+ Based on system context (§3) and quality goals (§1):
42
+
43
+ | Decision Area | What to Decide |
44
+ |--------------|---------------|
45
+ | Language/Runtime | Primary programming language |
46
+ | Web Framework | API/web framework |
47
+ | Database | Primary data store |
48
+ | Caching | Caching layer (if needed) |
49
+ | Authentication | Auth approach |
50
+ | Hosting | Cloud/infrastructure |
51
+ | CI/CD | Build and deploy pipeline |
52
+ | Monitoring | Observability stack |
53
+
54
+ ### 2. Compare Options (Top 3 per Decision)
55
+
56
+ For each decision, research and compare 3 options:
57
+
58
+ | Criterion | Option A | Option B | Option C |
59
+ |-----------|---------|---------|---------|
60
+ | Quality goal fit | [How it meets §1 goals] | ... | ... |
61
+ | Constraint fit | [How it respects §2] | ... | ... |
62
+ | Community/maturity | [Stars, contributors, releases] | ... | ... |
63
+ | Performance | [Benchmarks with source] | ... | ... |
64
+ | Learning curve | [Team skill match] | ... | ... |
65
+ | Cost | [Licensing, hosting costs] | ... | ... |
66
+
67
+ ### 3. Make Decisions with Rationale
68
+
69
+ For each decision:
70
+ - **Chosen**: [Option]
71
+ - **Rationale**: [Why this one — reference quality goals and constraints]
72
+ - **Trade-off accepted**: [What we give up]
73
+ - **Risk**: [What could go wrong]
74
+ - **Migration path**: [How to change if this doesn't work]
75
+
76
+ ### 4. Write Output
77
+
78
+ **WRITE IMMEDIATELY** to `.ultra/specs/architecture.md` §4:
79
+
80
+ ```markdown
81
+ ## §4 Solution Strategy
82
+
83
+ ### Technology Decisions
84
+
85
+ #### Language & Runtime
86
+ - **Chosen**: [Language/Runtime]
87
+ - **Alternatives considered**: [Option B], [Option C]
88
+ - **Rationale**: [Why — reference §1 quality goals]
89
+ - **Trade-off**: [What we give up]
90
+ - **Source**: [Benchmark/doc URL]
91
+
92
+ #### Web Framework
93
+ - **Chosen**: [Framework]
94
+ - **Alternatives considered**: [Option B], [Option C]
95
+ - **Rationale**: [Why]
96
+ - **Trade-off**: [What we give up]
97
+ - **Source**: [URL]
98
+
99
+ #### Database
100
+ - **Chosen**: [Database]
101
+ - **Alternatives considered**: [Option B], [Option C]
102
+ - **Rationale**: [Why]
103
+ - **Trade-off**: [What we give up]
104
+ - **Source**: [URL]
105
+
106
+ #### Authentication
107
+ - **Chosen**: [Approach]
108
+ - **Alternatives considered**: [Option B], [Option C]
109
+ - **Rationale**: [Why]
110
+ - **Source**: [URL]
111
+
112
+ #### Hosting & Infrastructure
113
+ - **Chosen**: [Platform]
114
+ - **Alternatives considered**: [Option B], [Option C]
115
+ - **Rationale**: [Why]
116
+ - **Estimated cost**: [$X/month at launch scale]
117
+ - **Source**: [URL]
118
+
119
+ ### Tech Stack Summary
120
+
121
+ | Layer | Technology | Version | Purpose |
122
+ |-------|-----------|---------|---------|
123
+ | Frontend | [Tech] | [Ver] | [What it does] |
124
+ | Backend | [Tech] | [Ver] | [What it does] |
125
+ | Database | [Tech] | [Ver] | [What it does] |
126
+ | Cache | [Tech] | [Ver] | [What it does] |
127
+ | Auth | [Tech] | [Ver] | [What it does] |
128
+ | Hosting | [Tech] | - | [What it does] |
129
+ | CI/CD | [Tech] | - | [What it does] |
130
+ | Monitoring | [Tech] | - | [What it does] |
131
+
132
+ ### Decision Confidence
133
+ - **Overall**: [X]%
134
+ - **Most confident**: [Decision] — [Why]
135
+ - **Least confident**: [Decision] — [Risk]
136
+ ```
137
+
138
+ ### 5. Present to User and Gate
139
+
140
+ ```
141
+ [C] Continue — Tech stack defined, proceed to Building Blocks
142
+ [R] Revise — Reconsider specific technology choices
143
+ [D] Discuss — Deep-dive on a specific decision
144
+ ```
145
+
146
+ **HALT — wait for user response before proceeding.**
147
+
148
+ ### 6. Handle Response
149
+
150
+ - **[C]**: Load next step: `./step-32-building-blocks.md`
151
+ - **[R]**: Revise decisions, update architecture.md §4, re-present
152
+ - **[D]**: Deep-dive with additional research, then re-present
153
+
154
+ ## SUCCESS METRICS
155
+
156
+ - Top 3 options compared for every major decision
157
+ - Every choice has explicit rationale referencing quality goals
158
+ - Trade-offs stated honestly
159
+ - All claims verified via web search or Context7
160
+ - Output written to architecture.md §4
161
+
162
+ ## FAILURE MODES
163
+
164
+ - Single option considered ("just use React")
165
+ - No rationale beyond popularity
166
+ - Ignoring constraints from §2
167
+ - Not verifying version compatibility
168
+ - Technology choices that conflict with quality goals
169
+
170
+ ## NEXT STEP
171
+
172
+ After user selects [C], read and follow: `./step-32-building-blocks.md`
@@ -0,0 +1,188 @@
1
+ # Step 32: Building Blocks & Runtime Scenarios
2
+
3
+ ## MANDATORY EXECUTION RULES
4
+
5
+ - MODULE DECOMPOSITION must follow Functional Core / Imperative Shell pattern
6
+ - EVERY MODULE must trace to at least one feature from product.md §5
7
+ - RUNTIME SCENARIOS must cover the top 3 user scenarios from product.md §3
8
+ - WRITE output to spec file BEFORE presenting to user
9
+ - ALL output in English (spec files); conversation in Chinese
10
+
11
+ ## PREREQUISITES
12
+
13
+ - Step 31 (Solution Strategy) completed with [C]
14
+ - `.ultra/specs/architecture.md` §1-4 exist
15
+
16
+ ## CONTEXT BOUNDARIES
17
+
18
+ - Focus: Module decomposition and runtime behavior (arc42 §5-6)
19
+ - Structure follows: `src/{domain/, application/usecases/, infrastructure/}`
20
+ - Domain logic is pure (no IO); Infrastructure handles IO
21
+ - This step bridges product (WHAT) to code (HOW)
22
+
23
+ ## EXECUTION SEQUENCE
24
+
25
+ ### 1. Module Decomposition
26
+
27
+ Based on features from product.md §5 and tech stack from §4:
28
+
29
+ **Layer structure**:
30
+ ```
31
+ src/
32
+ ├── domain/ # Functional Core (pure logic)
33
+ │ ├── entities/ # Domain objects
34
+ │ ├── values/ # Value objects
35
+ │ └── services/ # Domain services (pure functions)
36
+ ├── application/ # Use cases (orchestration)
37
+ │ └── usecases/ # One file per use case
38
+ ├── infrastructure/ # Imperative Shell (IO)
39
+ │ ├── http/ # HTTP handlers/routes
40
+ │ ├── persistence/ # Database repositories
41
+ │ └── external/ # External API clients
42
+ └── config/ # Configuration
43
+ ```
44
+
45
+ Map each feature to modules:
46
+ - Feature 1 → domain/entities/X, application/usecases/Y, infrastructure/http/Z
47
+
48
+ ### 2. Define Key Interfaces
49
+
50
+ For each module boundary, define the contract:
51
+
52
+ | Interface | Provider | Consumer | Data |
53
+ |-----------|---------|----------|------|
54
+ | [Interface A] | [Module] | [Module] | [DTO/Entity] |
55
+
56
+ ### 3. Runtime Scenarios
57
+
58
+ For the top 3 user scenarios from product.md §3, describe the runtime flow:
59
+
60
+ **Scenario S1**: [Name]
61
+ ```
62
+ User → HTTP Handler → Use Case → Domain Service → Repository → Database
63
+ ↓
64
+ User ← HTTP Response ← Use Case ← Domain Entity ← Repository ← Query Result
65
+ ```
66
+
67
+ ### 4. Write Output
68
+
69
+ **WRITE IMMEDIATELY** to `.ultra/specs/architecture.md` §5-6:
70
+
71
+ ```markdown
72
+ ## §5 Building Block View
73
+
74
+ ### Level 1: System Decomposition
75
+
76
+ | Module | Layer | Responsibility | Dependencies |
77
+ |--------|-------|---------------|-------------|
78
+ | [Module A] | Domain | [What it does] | None (pure) |
79
+ | [Module B] | Application | [What it orchestrates] | [Module A] |
80
+ | [Module C] | Infrastructure | [What IO it handles] | [Module B] |
81
+
82
+ ### Module Details
83
+
84
+ #### domain/
85
+ - **entities/[Entity]**: [Description, key fields, business rules]
86
+ - **values/[ValueObject]**: [Description, validation rules]
87
+ - **services/[Service]**: [Pure functions, input → output]
88
+
89
+ #### application/usecases/
90
+ - **[UseCase1]**: [Input → orchestration → output]
91
+ - **[UseCase2]**: [Input → orchestration → output]
92
+
93
+ #### infrastructure/
94
+ - **http/[Handler]**: [Routes, request/response mapping]
95
+ - **persistence/[Repository]**: [Database operations]
96
+ - **external/[Client]**: [External API integration]
97
+
98
+ ### Feature → Module Mapping
99
+
100
+ | Feature | Domain | Application | Infrastructure |
101
+ |---------|--------|------------|---------------|
102
+ | [Feature 1] | [Entities] | [UseCases] | [Handlers, Repos] |
103
+ | [Feature 2] | [Entities] | [UseCases] | [Handlers, Repos] |
104
+
105
+ ## §6 Runtime Scenarios
106
+
107
+ ### Scenario 1: [S1 Name from product.md]
108
+
109
+ **Trigger**: [User action]
110
+ **Flow**:
111
+ 1. User sends [request type] to [endpoint]
112
+ 2. [Handler] validates input, maps to [DTO]
113
+ 3. [UseCase] orchestrates: loads [Entity] via [Repository]
114
+ 4. [DomainService] applies business logic (pure)
115
+ 5. [Repository] persists result
116
+ 6. [Handler] returns [response]
117
+
118
+ **Data flow**: [Input] → [Transformation] → [Output]
119
+ **Error paths**: [What can go wrong and how it's handled]
120
+
121
+ ### Scenario 2: [S2 Name]
122
+ [Same structure]
123
+
124
+ ### Scenario 3: [S3 Name]
125
+ [Same structure]
126
+
127
+ ### Round 3 Summary
128
+
129
+ **Architecture Design Confidence**:
130
+ - **Quality goal coverage**: [X]%
131
+ - **Tech stack confidence**: [X]%
132
+ - **Module clarity**: [X]%
133
+ - **Overall R3 confidence**: [X]%
134
+ ```
135
+
136
+ ### 5. Write Round 3 Research Report
137
+
138
+ **WRITE** to `.ultra/docs/research/architecture-design-{date}.md`:
139
+
140
+ ```markdown
141
+ # Round 3: Architecture Design
142
+
143
+ > **Confidence**: [X]%
144
+ > **Steps completed**: 30-32
145
+ > **Completed**: [date]
146
+
147
+ ## Key Decisions
148
+ [Tech stack choices with rationale]
149
+
150
+ ## Architecture Pattern
151
+ [Functional Core / Imperative Shell overview]
152
+
153
+ ## Risk Areas
154
+ [Where architecture is weakest]
155
+ ```
156
+
157
+ ### 6. Present to User and Gate
158
+
159
+ ```
160
+ [C] Continue — Architecture defined, proceed to Round 4 (Deployment & Quality)
161
+ [R] Revise — Adjust modules or scenarios
162
+ ```
163
+
164
+ **HALT — wait for user response before proceeding.**
165
+
166
+ ### 7. Handle Response
167
+
168
+ - **[C]**: Load next step: `./step-40-deployment.md`
169
+ - **[R]**: Revise, update architecture.md §5-6, re-present
170
+
171
+ ## SUCCESS METRICS
172
+
173
+ - Every module traces to a feature
174
+ - Functional Core / Imperative Shell separation clear
175
+ - Top 3 runtime scenarios documented with data flow
176
+ - Error paths identified
177
+ - Round 3 research report written
178
+
179
+ ## FAILURE MODES
180
+
181
+ - Modules that don't map to any feature (orphan code)
182
+ - Business logic in infrastructure layer
183
+ - Missing error paths in runtime scenarios
184
+ - No interface contracts between modules
185
+
186
+ ## NEXT STEP
187
+
188
+ After user selects [C], read and follow: `./step-40-deployment.md`