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,148 @@
1
+ ---
2
+ name: ultra-init
3
+ description: "Initialize Ultra Builder Pro project: detect context, confirm with user, scaffold .ultra/ via task.init_project, set up git."
4
+ runtime: all
5
+ mcp_tools_required:
6
+ - task.init_project
7
+ cli_fallback: "task init-project"
8
+ ---
9
+
10
+ # ultra-init — Phase 3.1
11
+
12
+ 把当前工作目录(或 `--target-dir`)初始化为一个 Ultra Builder Pro 项目:拉起
13
+ `.ultra/` 骨架、写入 `tasks.json` 元数据、按需配 git。
14
+
15
+ 真实的目录搭建 + 模板拷贝 + tasks.json 注入统一由 **MCP tool `task.init_project`** 完成;
16
+ MCP 不可达时回退 `ultra-tools task init-project`。
17
+
18
+ ## 设计要点(对比 pre-Phase-3 行为)
19
+
20
+ - **无 Claude 独占依赖**:`task.init_project` + `ultra-tools init-project` 两条路径
21
+ 都不调 Claude 原生工具,4 个 runtime 都能走通。
22
+ - **模板内置**:`.ultra/` 骨架来自仓内 `templates/.ultra/`;不再依赖 `~/.claude/.ultra-template/`。
23
+ - **幂等**:二次 init 默认拒绝,`--overwrite` 才会备份旧 `.ultra/` 为
24
+ `.ultra.backup.<ts>` 后重建。
25
+
26
+ ## Workflow
27
+
28
+ ### Step 0: 状态检测(skill 调用方做)
29
+
30
+ 在调 `task.init_project` 之前,调用方(Claude / CLI / SDK)需要先判断:
31
+
32
+ - `target_dir/.ultra/` 是否已存在 → 决定是否需要 `overwrite=true`
33
+ - `target_dir/.git/` 是否已存在 → 影响 Step 3 的分支
34
+ - 读 `package.json` / `Cargo.toml` / `pyproject.toml` / `go.mod` 推断项目类型和栈
35
+ - 如果调用方是 Claude,可在此用 `TaskCreate` 跟踪 Step 0–4 的 session 内进度
36
+ (这是 runtime 的 session-local 跟踪,不走 MCP)
37
+
38
+ ### Step 1: 补全参数
39
+
40
+ 入参不足时补:
41
+
42
+ | 字段 | 缺省 |
43
+ |------|------|
44
+ | `project_name` | 当前目录名(`path.basename(target_dir)`) |
45
+ | `project_type` | Step 0 识别结果;多技术栈 → `fullstack` |
46
+ | `stack` | Step 0 识别到的依赖(逗号分隔多值,如 `react,express,postgres`) |
47
+ | `git_init` | `.git/` 不存在 → 询问用户 |
48
+
49
+ ### Step 1.5: 交互确认(仅当检测到模糊或重入)
50
+
51
+ 触发条件:
52
+ - `target_dir/.ultra/` 已存在(重入)
53
+ - 识别到多项目类型(Web + API)
54
+ - 显式 `--interactive` 标志
55
+
56
+ 交互渠道:
57
+ - **Claude runtime**:调 `AskUserQuestion`(原生)
58
+ - **其他 runtime**:使用 Host 原生提问界面;若当前表面不支持交互,
59
+ 要求用户通过显式命令行参数选择
60
+
61
+ 确认 4 个问题:
62
+ 1. 项目类型(可多选,`detected` 标签打在识别项)
63
+ 2. 技术栈(可多选)
64
+ 3. 已有 `.git/` → 保留 / 重置备份 / 不用 git
65
+ 4. 已有 `.ultra/` → 覆盖(备份) / 保留 / 取消
66
+
67
+ ### Step 2: 调 `task.init_project` 拉起骨架
68
+
69
+ **MCP 主路径**:
70
+ ```jsonc
71
+ // call: task.init_project
72
+ {
73
+ "target_dir": "/abs/path/to/project",
74
+ "project_name": "my-app",
75
+ "project_type": "fullstack",
76
+ "stack": "react,express,postgres",
77
+ "overwrite": false
78
+ }
79
+ // response
80
+ {
81
+ "created_path": "/abs/path/to/project/.ultra",
82
+ "status": "created",
83
+ "copied_files": [
84
+ "specs/discovery.md", "specs/product.md", "specs/architecture.md",
85
+ "tasks/tasks.json", "tasks/contexts/TEMPLATE.md",
86
+ "docs/research/README.md",
87
+ "test-report.json", "delivery-report.json"
88
+ ]
89
+ }
90
+ ```
91
+
92
+ **CLI 回退路径**(`UBP_MCP=off` 或 MCP 调用返回网络错):
93
+ ```bash
94
+ ultra-tools task init-project \
95
+ --target-dir "$TARGET" \
96
+ --project-name "$NAME" \
97
+ --project-type "$TYPE" \
98
+ --stack "$STACK" \
99
+ $([ "$OVERWRITE" = "1" ] && echo --overwrite)
100
+ ```
101
+ CLI 最后一行是 `{ "ok": true, "data": { ... } }`(见 spec/cli-protocol.md §2)。
102
+
103
+ **错误处理**:
104
+ - `ULTRA_DIR_EXISTS` → Step 1.5 重新询问是否 overwrite
105
+ - `TEMPLATE_MISSING` → 致命;提示检查 `templates/.ultra/` 是否被 gitignore 吞了
106
+ - `TARGET_NOT_DIR` / `VALIDATION_ERROR` → 返回调用方,修参数
107
+ - `IO_ERROR` → retriable=true;最多重试 2 次
108
+
109
+ ### Step 3: Git 集成
110
+
111
+ 根据 Step 1.5 结果:
112
+
113
+ - **初始化新仓**:`git init` + 写 `.gitignore`(排除 `.ultra/backups/`、`node_modules/`、
114
+ 敏感文件等项目通用规则)+ 写基础 `README.md`(若不存在)。
115
+ - **保留现有 `.git/`**:仅追加 `.gitignore` 里的 `.ultra/backups/` 一行(若缺失)。
116
+ - **不用 git**:跳过。
117
+
118
+ 提示建议第一个 commit:`git add . && git commit -m "feat: initialize Ultra Builder Pro"`,
119
+ 但不代为执行(commit 是用户决策)。
120
+
121
+ ### Step 4: 成功总结 + 下一步
122
+
123
+ 用中文输出:
124
+ - ✅ `.ultra/` 骨架(specs / tasks / docs / reports)
125
+ - ✅ tasks.json 注入元数据(name / type / stack / created / updated)
126
+ - ✅ git 状态(按选择)
127
+ - ⚠️ **下一步**:跑 `/ultra-research` 做 17 步 discovery 填 spec;不要跳过直接 `/ultra-plan`
128
+
129
+ ## 调用方式(按 runtime)
130
+
131
+ | Runtime | 调用形态 |
132
+ |---------|----------|
133
+ | Claude | `/ultra-init [name] [type] [stack] [git]` — 命令薄壳拉起此 skill |
134
+ | OpenCode | `/ultra-init …` 同上(agent frontmatter 小写化) |
135
+ | Codex | `codex exec "run /ultra-init …"`(Phase 4.4 adapter 接) |
136
+ | Gemini | `gemini --prompt "run /ultra-init …"`(Phase 4.5 extension 接) |
137
+
138
+ ## 输出锚点
139
+
140
+ - `target_dir/.ultra/tasks/tasks.json` — project.name / project.type / project.stack 已注入
141
+ - `target_dir/.ultra/specs/{discovery,product,architecture}.md` — 带 `[NEEDS CLARIFICATION]` 标记
142
+ - 若 `overwrite=true`:`target_dir/.ultra.backup.<ts>/` 保存旧骨架
143
+
144
+ ## 不做的事
145
+
146
+ - **不**创建业务 task(业务 task 由 `/ultra-plan` 在 spec 填完后批量创建)
147
+ - **不**写入 state.db(state.db 由第一次 MCP 写操作或显式 `ultra-tools db init` 触发)
148
+ - **不**调 web:离线可执行
@@ -0,0 +1,314 @@
1
+ ---
2
+ name: ultra-plan
3
+ description: "Generate task breakdown from complete specs OR from a raw PRD (Phase 8A). Scope-mode-aware; writes state.db via task.create or task.parse_prd; projector generates tasks.json + contexts/*.md."
4
+ runtime: all
5
+ mcp_tools_required:
6
+ - task.create
7
+ - task.parse_prd
8
+ - task.dependency_topo
9
+ - plan.export
10
+ - plan.get
11
+ cli_fallback: "task create"
12
+ ---
13
+
14
+ # ultra-plan — Phase 3.3
15
+
16
+ Transform validated `.ultra/specs/` into an executable task plan. **state.db is
17
+ the authority** (D32): every new task is created via MCP `task.create`; the
18
+ projector regenerates `.ultra/tasks/tasks.json` and context-md frontmatter
19
+ automatically. Context-md bodies are written by this skill (not projector).
20
+
21
+ ## Prerequisites
22
+
23
+ - `/ultra-research` completed — specs must be 100% (no `[NEEDS CLARIFICATION]`)
24
+ - `.ultra/specs/product.md` + `.ultra/specs/architecture.md` exist
25
+ - `.ultra/specs/research-distillate.md` preferred when present (token-efficient)
26
+
27
+ ## Workflow
28
+
29
+ ### Input Mode Selection (BEFORE Step 0)
30
+
31
+ Two entry points lead into the planner:
32
+
33
+ | Mode | When | Path |
34
+ |------|------|------|
35
+ | **Spec Mode** (default) | `.ultra/specs/` exists and `/ultra-research` is complete | Steps 0–7 below |
36
+ | **PRD Direct** (Phase 8A) | User hands you a raw PRD (path or inline text) and wants to skip the spec layer | see **PRD Direct Workflow** below |
37
+
38
+ ---
39
+
40
+ ### PRD Direct Workflow (Phase 8A — human-gated artifact)
41
+
42
+ For a one-shot PRD → task graph pipeline with approval gate:
43
+
44
+ 1. **Dry-run parse** (no state.db writes):
45
+ ```jsonc
46
+ // MCP
47
+ { "tool": "task.parse_prd", "args": { "prd_path": "<path>", "dry_run": true, "tag": "<branch>" } }
48
+ ```
49
+ Returns `{ tasks: [...], topo: [[...],[...]] }` without touching state.db.
50
+
51
+ 2. **Build execution plan** (in-memory via the server's `plan-builder`):
52
+ The server composes `computeWaves` + `files_modified` overlap + `pricing.computeCost`
53
+ into a plan with `waves`, `ownership_forecast`, `conflict_surface`, and
54
+ estimated cost / duration.
55
+
56
+ 3. **Human gate** — ask through the current Host's native user-interaction
57
+ surface with the plan summary and estimated cost:
58
+ - `approve` → re-run `task.parse_prd` **with `dry_run: false`** to commit
59
+ tasks, then `plan.export { out_path: ".ultra/execution-plan.json" }`
60
+ to land the artifact and emit the `plan_approved` event.
61
+ - `reject` → **do not** call the non-dry-run path. No state.db rows, no
62
+ artifact. Prompt user for PRD revision and loop.
63
+
64
+ 4. **Post-approval** — the artifact at `.ultra/execution-plan.json` is the
65
+ source of truth for Phase 8B orchestration (wave-by-wave dispatch).
66
+ Use `plan.get { section: "topo" | "conflicts" | "all" }` to inspect
67
+ without re-reading the file.
68
+
69
+ **AC guarantees**:
70
+ - `reject` path performs zero state.db writes (dry_run=true on parse).
71
+ - `approve` path emits exactly one `plan_approved` event, tied to the
72
+ persisted artifact path.
73
+ - Task IDs returned by the dry-run and the final persisted tasks are
74
+ identical (parser is deterministic given the same LLM output).
75
+
76
+ ---
77
+
78
+ ### Step 0 — Scope Mode Selection
79
+
80
+ Ask the user which posture this plan takes. **Commit once selected — do not
81
+ drift silently.**
82
+
83
+ | Mode | Posture | Use when |
84
+ |------|---------|----------|
85
+ | **EXPAND** | "What would make this 10x better for 2x effort?" — surface stretch opportunities | Greenfield, user wants to think bigger |
86
+ | **SELECTIVE** (default) | Baseline scope held; optional expansions surfaced individually | Most common; feature work on existing product |
87
+ | **HOLD** | Scope locked; make it bulletproof; catch every failure mode | Requirements clear, need execution depth |
88
+ | **REDUCE** | Find the minimum viable version; cut ruthlessly | MVP, time pressure, PoC |
89
+
90
+ Use the current Host's native picker. If that Host has no structured picker,
91
+ present the choices directly and require an explicit answer.
92
+
93
+ **Dual-scale effort** on every EXPAND/SELECTIVE expansion decision:
94
+ `Complete: ~X LOC, AI ~Y min | Shortcut: ~X LOC, saves Y min but ___`
95
+
96
+ ### Step 1 — Specification Completeness Validation (BLOCK gate)
97
+
98
+ Read specs and check field-by-field. **Fail loud** — don't generate a plan
99
+ against broken specs.
100
+
101
+ **discovery.md** (if present):
102
+ - §0 Problem Validation has demand signal + confidence %
103
+ - §2 Market Assessment has TAM/SAM/SOM with numbers + sources
104
+ - §3 Competitive Landscape has ≥2 competitors compared
105
+ - §4 Product Strategy has ≥3 trade-offs
106
+
107
+ **product.md**:
108
+ - §2 Personas: ≥2 with goals + pain points
109
+ - §3 Scenarios: ≥3 with current + desired flow
110
+ - §4 User Stories: acceptance criteria in Given/When/Then
111
+ - §5 Feature Scope: Features Out section with rationale
112
+ - §6 Success Metrics: North Star has numeric target
113
+
114
+ **architecture.md**:
115
+ - §1 Quality Goals: ≥3 measurable scenarios
116
+ - §4 Solution Strategy: tech stack with URL-cited rationale
117
+ - §5 Building Blocks: modules map to features
118
+ - §6 Runtime Scenarios: ≥1 with data flow
119
+
120
+ **Fail if**: `[NEEDS CLARIFICATION]` markers present / file missing / checklist fails.
121
+ On fail → instruct user to run `/ultra-research` targeting the gap.
122
+
123
+ ### Step 2 — Requirements + Codebase Analysis
124
+
125
+ **Requirements extraction** (prefer distillate):
126
+ - Functional requirements (product.md §4)
127
+ - Technical constraints (architecture.md §2)
128
+ - Quality requirements (architecture.md §10)
129
+ - Success metrics (product.md §6)
130
+
131
+ **Codebase analysis** (for AI-executable context):
132
+ - Directory structure (src/ tests/ config/)
133
+ - Existing patterns worth referencing
134
+ - Tech stack detection (framework versions, test runners)
135
+ - Naming conventions
136
+
137
+ ### Step 3 — Task Generation
138
+
139
+ #### tasks.json schema (v4.5 projection, source in state.db)
140
+
141
+ Fields per task: `id`, `title` (action verb + target), `type`
142
+ (architecture/feature/bugfix), `priority` (P0-P3), `complexity` (1-10),
143
+ `status` (pending initially), `dependencies` (task IDs), `estimated_days`,
144
+ `context_file`, `trace_to` (spec section anchor).
145
+
146
+ #### Integration tasks — MANDATORY inserts
147
+
148
+ 1. **Walking Skeleton — always Task #1, P0, type=architecture**
149
+ - Title: "Walking skeleton: {primary use case} end-to-end"
150
+ - Must touch every layer: entry → use case → domain → persistence
151
+ - Acceptance: one real request returns real data through all layers
152
+
153
+ 2. **Contract Definition** (when specs show component boundaries)
154
+ - Title: "Define contract: {component A} ↔ {component B}"
155
+ - Must PRECEDE implementation tasks on both sides
156
+ - Acceptance: shared interface/schema + contract test
157
+
158
+ 3. **Integration Checkpoint** — every 3-4 feature tasks
159
+ - Title: "Integration checkpoint: verify {feature group} connectivity"
160
+ - Acceptance: components from recent tasks communicate end-to-end
161
+
162
+ #### Task granularity
163
+
164
+ - Ideal complexity: 3-5 (one-session completable)
165
+ - Too large (>6) → split
166
+ - Too small (<3) → merge
167
+ - Context budget: target 40% per task; max 8 files touched; complexity ≥7 must split
168
+
169
+ ### Step 4 — Dependency Analysis
170
+
171
+ - Build dependency graph from each task's `deps` list
172
+ - Detect cycles (DFS with visited + recursion stack) — cycles are **fatal**
173
+ - Topological order → surface parallel opportunities
174
+ - Vertical slicing check: flag any task touching only one layer → split or merge
175
+ - Walking skeleton blocks all feature tasks
176
+ - Contract tasks precede their consumer implementations
177
+
178
+ ### Step 5 — Persist via MCP `task.create`
179
+
180
+ For **each** task in the planned list (topological order):
181
+
182
+ ```jsonc
183
+ // MCP call per task
184
+ {
185
+ "id": "1", // optional; server mints uuid if omitted
186
+ "title": "Walking skeleton: …",
187
+ "type": "architecture",
188
+ "priority": "P0",
189
+ "complexity": 4,
190
+ "deps": [],
191
+ "tag": "<git branch>", // optional
192
+ "trace_to": ".ultra/specs/product.md#US-01"
193
+ }
194
+ ```
195
+
196
+ **CLI fallback** (per task):
197
+ ```bash
198
+ ultra-tools task create \
199
+ --title "Walking skeleton: …" --type architecture --priority P0 \
200
+ --complexity 4 --trace-to ".ultra/specs/product.md#US-01"
201
+ ```
202
+
203
+ After each `task.create`, the server auto-runs the projector — `tasks.json`
204
+ and `contexts/task-{id}.md` (frontmatter only) appear.
205
+
206
+ Create one task per `task.create` call so every write is schema-validated and
207
+ projected through the same live MCP contract.
208
+
209
+ ### Step 5.5 — Context-md body (skill responsibility)
210
+
211
+ Projector writes the frontmatter; this skill writes the body. For each task,
212
+ write `.ultra/tasks/contexts/task-{id}.md` body (projector preserves it):
213
+
214
+ ```markdown
215
+ ## Context
216
+ **What**: …
217
+ **Why**: … (Persona/Scenario link)
218
+ **Constraints**: - …
219
+
220
+ ## Implementation
221
+ **Target Files**: - path/to/file.ts (create|modify: desc)
222
+ **Pattern**: …
223
+ **Tech Notes**: …
224
+
225
+ ## Acceptance
226
+ **Tests**: - [ ] `test cmd`
227
+ **Verification**: ```bash …```
228
+
229
+ ## Trace
230
+ **Source**: `.ultra/specs/product.md#US-01`
231
+
232
+ ## Change Log
233
+ | Date | Change | Specs Updated | Reason |
234
+ |------|--------|---------------|--------|
235
+
236
+ ## Completion
237
+ > _Filled when task completed by /ultra-dev_
238
+ ```
239
+
240
+ ### Step 6 — Plan Verification (BLOCKING)
241
+
242
+ Run programmatic checks **before** presenting to user:
243
+
244
+ | Check | Severity | Action on fail |
245
+ |-------|----------|----------------|
246
+ | Every user story (US-XX) mapped to ≥1 task via `trace_to` | CRITICAL | create missing task or flag |
247
+ | Dependency graph acyclic | CRITICAL | report cycle chain, block |
248
+ | `trace_to` points at real spec anchor | WARN | suggest correction |
249
+ | Tasks with complexity ≥7 | WARN | suggest split |
250
+ | Tasks touching >8 files | WARN | suggest split |
251
+ | Total tasks >20 | WARN | suggest phased delivery |
252
+ | Per-task complexity × 5% context > 40% | WARN | split recommended |
253
+
254
+ All CRITICAL pass → present to user (Step 7). Any CRITICAL fail → auto-fix or surface.
255
+
256
+ ### Step 7 — Report + Next Steps
257
+
258
+ Summary output:
259
+ - Total tasks, priority distribution (P0/P1/P2), complexity histogram
260
+ - Dependency edge count, parallel-track count
261
+ - Estimated total effort (sum of `estimated_days`)
262
+ - Requirement coverage % (stories mapped / stories total)
263
+ - First task details (Walking Skeleton)
264
+ - Suggest `/ultra-dev`
265
+
266
+ ### Continuation block (MANDATORY)
267
+
268
+ ```markdown
269
+ ---
270
+ ## ▶ Next Up
271
+ **Start Development** — TDD workflow on Task #1: {Walking Skeleton title}
272
+
273
+ `/clear` then `/ultra-dev`
274
+
275
+ ---
276
+ **Also available**: `/ultra-status`
277
+ ---
278
+ ```
279
+
280
+ ## Quality Standards
281
+
282
+ - 100% requirement coverage (every user story mapped)
283
+ - Clear acceptance criteria per task
284
+ - No circular dependencies
285
+ - Realistic complexity (justifiable in review)
286
+ - Action-verb titles
287
+ - Walking Skeleton is Task #1
288
+ - Every feature task is a vertical slice (≥2 layers)
289
+ - Integration checkpoint every 3-4 feature tasks
290
+ - Contract tasks precede cross-boundary implementations
291
+
292
+ ## Integration Points
293
+
294
+ | | |
295
+ |---|---|
296
+ | **Prerequisite** | `/ultra-research` — specs 100% complete |
297
+ | **Input** | `.ultra/specs/research-distillate.md` (primary), `product.md`, `architecture.md`, `discovery.md` |
298
+ | **Writes** | state.db via `task.create`; context-md bodies |
299
+ | **Output (projected)** | `.ultra/tasks/tasks.json`, `.ultra/tasks/contexts/task-*.md` |
300
+ | **Next** | `/ultra-dev` |
301
+
302
+ ## MCP → CLI fallback matrix
303
+
304
+ | Purpose | MCP tool | CLI fallback |
305
+ |---------|----------|--------------|
306
+ | Scope mode prompt | none | current Host's native user-interaction surface |
307
+ | Create task | `task.create` | `ultra-tools task create --title … --type … --priority …` |
308
+
309
+ ## What this skill DOES NOT do
310
+
311
+ - Does NOT write state.db directly — all task writes go through `task.create`
312
+ - Does NOT regenerate `tasks.json` — projector owns that
313
+ - Does NOT start implementation — that's `/ultra-dev`
314
+ - Does NOT re-run research — if specs are incomplete, redirects to `/ultra-research`
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: ultra-research
3
+ description: "Think-Driven Interactive Discovery - Deep research with step-file architecture for high-density output"
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Ultra Research v2 — Step-File Architecture
8
+
9
+ ## Overview
10
+
11
+ Transform vague ideas into complete, high-confidence specifications through progressive interactive discovery. Each research step is a self-contained instruction file loaded just-in-time for maximum LLM attention density.
12
+
13
+ **Philosophy**: Research is collaborative. Each decision validated with user before proceeding. All findings must have 90%+ confidence. Every claim needs a source.
14
+
15
+ ## WORKFLOW ARCHITECTURE
16
+
17
+ ### Core Principles
18
+
19
+ - **Step-File Design**: Each step is a self-contained .md file with full execution instructions
20
+ - **Just-In-Time Loading**: Only the current step file is in context — never load future steps
21
+ - **Sequential Enforcement**: Steps must be completed in order, no skipping
22
+ - **Write-Immediately**: Every step writes its output to the spec file BEFORE presenting to user
23
+ - **User Gate**: User must explicitly confirm [C] Continue before proceeding to next step
24
+ - **State Tracking**: Track per-session progress via the runtime's native TaskCreate/TaskUpdate (session-local). Research does NOT write business tasks to state.db — it only emits spec files. Business tasks are created later by `/ultra-plan` via MCP `task.create`.
25
+ - **Web-First**: Every analysis step REQUIRES web search with citations. No search = no proceed.
26
+
27
+ ### Step Processing Rules
28
+
29
+ 1. **READ COMPLETELY**: Always read the entire step file before taking any action
30
+ 2. **FOLLOW SEQUENCE**: Execute all numbered sections in order
31
+ 3. **SEARCH FIRST**: Execute web searches BEFORE generating analysis
32
+ 4. **WRITE IMMEDIATELY**: Append content to spec file as soon as analysis is complete
33
+ 5. **WAIT FOR INPUT**: Present [C] Continue — halt and wait for user selection
34
+ 6. **LOAD NEXT**: When user confirms, Read the next step file and follow it
35
+
36
+ ### Critical Rules (NO EXCEPTIONS)
37
+
38
+ - NEVER load multiple step files simultaneously
39
+ - ALWAYS read entire step file before execution
40
+ - NEVER skip steps or optimize the sequence
41
+ - ALWAYS write output to spec file before presenting to user
42
+ - ALWAYS halt at [C] Continue and wait for user input
43
+ - NEVER proceed without user confirmation
44
+ - NEVER rely solely on training data — web search is mandatory for factual claims
45
+
46
+ ## STEP SEQUENCE
47
+
48
+ ### Round 0: Product Discovery & Strategy
49
+
50
+ | Step | File | Focus | Output |
51
+ |------|------|-------|--------|
52
+ | 00 | `step-00-problem-validation.md` | Validate the problem is real and worth solving | discovery.md §0 |
53
+ | 01 | `step-01-opportunity-discovery.md` | Opportunity Solution Tree (Teresa Torres) | discovery.md §1 |
54
+ | 02 | `step-02-market-assessment.md` | TAM/SAM/SOM with dual approach | discovery.md §2 |
55
+ | 03 | `step-03-competitive-landscape.md` | Competitors + Porter's Five Forces | discovery.md §3 |
56
+ | 04 | `step-04-product-strategy.md` | Vision, segments, value prop, trade-offs | discovery.md §4 |
57
+ | 05 | `step-05-assumptions-validation.md` | Risk assumptions + experiment design | discovery.md §5 |
58
+
59
+ ### Round 1: User & Scenario Discovery
60
+
61
+ | Step | File | Focus | Output |
62
+ |------|------|-------|--------|
63
+ | 10 | `step-10-user-personas.md` | 2-3 personas with goals, pain points, context | product.md §1-2 |
64
+ | 11 | `step-11-user-scenarios.md` | 3-5 user scenarios with trigger/flow/outcome | product.md §3 |
65
+
66
+ ### Round 2: Feature Definition
67
+
68
+ | Step | File | Focus | Output |
69
+ |------|------|-------|--------|
70
+ | 20 | `step-20-user-stories.md` | User stories with acceptance criteria | product.md §4 |
71
+ | 21 | `step-21-features-scope.md` | Feature prioritization + explicit exclusions | product.md §5 |
72
+ | 22 | `step-22-success-metrics.md` | Business + user metrics with targets | product.md §6 |
73
+
74
+ ### Round 3: Architecture Design
75
+
76
+ | Step | File | Focus | Output |
77
+ |------|------|-------|--------|
78
+ | 30 | `step-30-architecture-context.md` | Quality goals, constraints, system context | architecture.md §1-3 |
79
+ | 31 | `step-31-solution-strategy.md` | Tech stack selection with rationale | architecture.md §4 |
80
+ | 32 | `step-32-building-blocks.md` | Module decomposition + runtime scenarios | architecture.md §5-6 |
81
+
82
+ ### Round 4: Quality & Deployment
83
+
84
+ | Step | File | Focus | Output |
85
+ |------|------|-------|--------|
86
+ | 40 | `step-40-deployment.md` | Infrastructure, environments, CI/CD | architecture.md §7-9 |
87
+ | 41 | `step-41-quality-risks.md` | Quality scenarios, risks, tech debt | architecture.md §10-12 |
88
+
89
+ ### Synthesis
90
+
91
+ | Step | File | Focus | Output |
92
+ |------|------|-------|--------|
93
+ | 99 | `step-99-synthesis.md` | Distillate + validation + quality summary | research-distillate.md |
94
+
95
+ ## ACTIVATION
96
+
97
+ When invoked, follow this sequence:
98
+
99
+ ### 1. Pre-Research Check
100
+
101
+ - If `.ultra/specs/product.md` has [NEEDS CLARIFICATION] → proceed with research
102
+ - If `.ultra/specs/` doesn't exist → suggest `/ultra-init` first
103
+ - If specs 100% complete → suggest skip to `/ultra-plan`
104
+
105
+ ### 2. Project Type Detection
106
+
107
+ Ask user to determine research scope:
108
+
109
+ | Type | Steps | Focus |
110
+ |------|-------|-------|
111
+ | Full Project | 00-99 | All rounds |
112
+ | Product Only | 00-22 | Discovery + product |
113
+ | Feature Only | 10-22 | User scenarios + features (skip discovery) |
114
+ | Architecture Change | 30-41 | Architecture + deployment |
115
+ | Custom | User selects | Specific steps |
116
+
117
+ **Round 0 skip conditions**: Skip if user provides existing market research, validated strategy docs, or explicitly states "I already know the market".
118
+
119
+ ### 3. Begin Step Execution
120
+
121
+ Read the first applicable step file:
122
+ ```
123
+ Read: skills/ultra-research/steps/step-{NN}-{name}.md
124
+ ```
125
+
126
+ Follow every instruction in that file. When the step is complete and user confirms [C], read the next step file.
127
+
128
+ ### 4. Output Files
129
+
130
+ | File | Content |
131
+ |------|---------|
132
+ | `.ultra/specs/discovery.md` | §0-5: Problem, Opportunities, Market, Competition, Strategy, Assumptions |
133
+ | `.ultra/specs/product.md` | §1-6: Problem, Personas, Scenarios, Stories, Scope, Metrics |
134
+ | `.ultra/specs/architecture.md` | §1-12: arc42 structure |
135
+ | `.ultra/specs/research-distillate.md` | Token-efficient summary for /ultra-plan consumption |
136
+ | `.ultra/docs/research/*.md` | Per-round research reports |
137
+
138
+ ## QUALITY STANDARDS
139
+
140
+ | Element | Requirement |
141
+ |---------|-------------|
142
+ | Sources | Every factual claim has URL citation |
143
+ | Confidence | 90%+ for recommendations |
144
+ | Code | Production-ready (no TODO/demo) |
145
+ | Trade-offs | Quantified pros/cons |
146
+ | Next steps | Specific, actionable items |
147
+
148
+ ## COMPLETION
149
+
150
+ Research is complete when:
151
+ - All selected steps have [C] confirmed by user
152
+ - All spec files have no [NEEDS CLARIFICATION] markers
153
+ - Research distillate generated
154
+ - All recommendations have 90%+ confidence
155
+
156
+ **Next**: Run `/ultra-plan` to generate task breakdown from complete specs.