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,49 @@
1
+ ---
2
+ description: Generate task breakdown from complete specs — walking-skeleton first, vertical slices, via MCP task.create
3
+ argument-hint: [scope]
4
+ allowed-tools: Read, Write, Edit, Bash(mkdir .ultra/*), Grep, Glob, AskUserQuestion
5
+ model: opus
6
+ workflow-ref: "@skills/ultra-plan/SKILL.md"
7
+ mcp_tools_required:
8
+ - task.create
9
+ cli_fallback: "task create"
10
+ ---
11
+
12
+ # /ultra-plan
13
+
14
+ ## 目标
15
+
16
+ 把 `/ultra-research` 验证过的完整 spec 转成可执行的任务计划:先 Walking
17
+ Skeleton 贯穿所有层,再切 vertical slices,每 3-4 个 feature task 插一个
18
+ Integration Checkpoint。任务写入 state.db(MCP `task.create`),projector
19
+ 自动生成 `.ultra/tasks/tasks.json` + contexts/*.md frontmatter。
20
+
21
+ ## 参数
22
+
23
+ | 位 | 含义 | 缺省 |
24
+ |----|------|------|
25
+ | `$1` | scope 模式(EXPAND / SELECTIVE / HOLD / REDUCE) | 询问用户;默认 SELECTIVE |
26
+
27
+ ## Workflow
28
+
29
+ 完整 8 步流程见 `@skills/ultra-plan/SKILL.md`。
30
+
31
+ **命令入口做的事**:
32
+ 1. 探测 spec 完整度 — 未填充则 block 并转 `/ultra-research`
33
+ 2. 使用 Host 原生提问界面交互选 scope 模式
34
+ 3. 驱动 skill 跑生成 → 依赖分析 → `task.create` 循环 → 写 context-md 正文
35
+ 4. 跑 7 项 verification(requirement coverage / 无环 / trace_to / 复杂度等)
36
+ 5. 输出 report + 下一步
37
+
38
+ ## 用法
39
+
40
+ ```bash
41
+ /ultra-plan # 交互模式;默认 SELECTIVE
42
+ /ultra-plan EXPAND # 直接进入"激进扩张"模式
43
+ /ultra-plan REDUCE # MVP 最小化模式
44
+ ```
45
+
46
+ ## 下一步
47
+
48
+ 所有 CRITICAL check 过了 → `/clear` 然后 `/ultra-dev` 开始 TDD。
49
+ 单个 task 完成后 `/ultra-status` 看进度。
@@ -0,0 +1,59 @@
1
+ ---
2
+ description: Think-Driven Interactive Discovery — 17-step research with per-step web search and spec-file output
3
+ argument-hint: [topic]
4
+ allowed-tools: Task, Read, Write, WebSearch, WebFetch, Grep, Glob, AskUserQuestion
5
+ model: opus
6
+ workflow-ref: "@skills/ultra-research/SKILL.md"
7
+ ---
8
+
9
+ # Ultra Research v2
10
+
11
+ **Step-file architecture**: Each research step is a self-contained instruction file loaded just-in-time for maximum LLM attention density.
12
+
13
+ ## How This Works
14
+
15
+ 1. Read the main skill file: `skills/ultra-research/SKILL.md`
16
+ 2. Follow the activation sequence (pre-checks → project type detection → step routing)
17
+ 3. For each step: Read `skills/ultra-research/steps/step-{NN}-{name}.md` and follow ALL instructions
18
+ 4. Each step writes output immediately to spec files, then presents [C] Continue gate
19
+ 5. Only proceed to next step after user confirms [C]
20
+
21
+ ## Step Sequence
22
+
23
+ | Step | File | Focus |
24
+ |------|------|-------|
25
+ | **R0: Product Discovery** | | |
26
+ | 00 | `step-00-problem-validation.md` | Validate the problem is real |
27
+ | 01 | `step-01-opportunity-discovery.md` | Map opportunity space (OST) |
28
+ | 02 | `step-02-market-assessment.md` | TAM/SAM/SOM sizing |
29
+ | 03 | `step-03-competitive-landscape.md` | Competitor analysis |
30
+ | 04 | `step-04-product-strategy.md` | Vision, segments, trade-offs |
31
+ | 05 | `step-05-assumptions-validation.md` | Risk assumptions + experiments |
32
+ | **R1: User & Scenario** | | |
33
+ | 10 | `step-10-user-personas.md` | 2-3 personas |
34
+ | 11 | `step-11-user-scenarios.md` | 3-5 user scenarios |
35
+ | **R2: Feature Definition** | | |
36
+ | 20 | `step-20-user-stories.md` | Stories + acceptance criteria |
37
+ | 21 | `step-21-features-scope.md` | MVP scope + exclusions |
38
+ | 22 | `step-22-success-metrics.md` | KPIs + targets |
39
+ | **R3: Architecture** | | |
40
+ | 30 | `step-30-architecture-context.md` | Quality goals, constraints |
41
+ | 31 | `step-31-solution-strategy.md` | Tech stack decisions |
42
+ | 32 | `step-32-building-blocks.md` | Modules + runtime scenarios |
43
+ | **R4: Quality & Deploy** | | |
44
+ | 40 | `step-40-deployment.md` | Infrastructure + CI/CD |
45
+ | 41 | `step-41-quality-risks.md` | Quality scenarios + risks |
46
+ | **Synthesis** | | |
47
+ | 99 | `step-99-synthesis.md` | Distillate + validation |
48
+
49
+ ## Critical Rules
50
+
51
+ - **Read SKILL.md first** — it has activation logic and project type detection
52
+ - **One step at a time** — never load multiple step files simultaneously
53
+ - **Write immediately** — every step writes to spec file before presenting to user
54
+ - **Web search mandatory** — factual claims need sources, no exceptions
55
+ - **User gate** — halt at [C] Continue, do not auto-proceed
56
+
57
+ ## Begin
58
+
59
+ Read `skills/ultra-research/SKILL.md` now and follow the activation sequence.
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: Real-time project status — progress + risks + workflow routing, via MCP task.list
3
+ argument-hint: "[task-id]"
4
+ allowed-tools: Read, Bash(git status), Bash(git log *), Grep, Glob, Task
5
+ model: opus
6
+ workflow-ref: "@skills/ultra-status/SKILL.md"
7
+ mcp_tools_required:
8
+ - task.list
9
+ - task.get
10
+ cli_fallback: "task list"
11
+ ---
12
+
13
+ # /ultra-status
14
+
15
+ ## 目标
16
+
17
+ 一次调用拿整个项目近况:任务进度(来自 state.db `task.list`)+ 测试状态(`test-report.json`)+
18
+ 发布状态(`delivery-report.json`)+ 风险检测 + 下一步命令路由。只读。
19
+
20
+ ## 参数
21
+
22
+ | 位 | 含义 | 缺省 |
23
+ |----|------|------|
24
+ | `$1` | 单 task id(只看这个 task) | 不填 → 全局报告 |
25
+
26
+ ## Workflow
27
+
28
+ 完整 5 阶段见 `@skills/ultra-status/SKILL.md`(validation → load → progress → risk → routing)。
29
+
30
+ **命令入口做的事**:
31
+ 1. 环境检查(state.db 可达 + 有 task)
32
+ 2. `task.list` 拿全量;读 test-report / delivery-report
33
+ 3. 算进度 + 风险(blocked / stalled / overdue / complexity spike / test stale)
34
+ 4. 按当前 artifact 组合路由到下一个命令(/ultra-init → /ultra-research → /ultra-plan → /ultra-dev → /ultra-test → /ultra-deliver)
35
+
36
+ ## 用法
37
+
38
+ ```bash
39
+ /ultra-status # 项目全局报告
40
+ /ultra-status 3 # 只看 task 3
41
+ ```
42
+
43
+ ## 下一步
44
+
45
+ 看输出的 `▶ Next Up` 块。常见场景:有 pending → `/ultra-dev`;全绿 → `/ultra-test`;
46
+ test passed → `/ultra-deliver`。
@@ -0,0 +1,48 @@
1
+ ---
2
+ description: Pre-delivery quality audit — Anti-Pattern + Coverage Gap + Wiring + E2E + Perf + Security
3
+ argument-hint: [scope]
4
+ allowed-tools: Bash, Read, Write, Edit, Task, Grep, Glob, AskUserQuestion
5
+ model: opus
6
+ workflow-ref: "@skills/ultra-test/SKILL.md"
7
+ mcp_tools_required:
8
+ - task.list
9
+ cli_fallback: "task list"
10
+ ---
11
+
12
+ # /ultra-test
13
+
14
+ ## 目标
15
+
16
+ `/ultra-deliver` 前的项目级质量审计:6 类 gate(Anti-Pattern / Coverage Gap /
17
+ Wiring / E2E / Performance / Security)× auto-fix loop。**只读** state.db,
18
+ 写 `.ultra/test-report.json` 作为 `/ultra-deliver` 的准入凭证。
19
+
20
+ **注意**:这不是跑单测(那是 `/ultra-dev`)。这是交付前的体检。
21
+
22
+ ## 参数
23
+
24
+ | 位 | 含义 | 缺省 |
25
+ |----|------|------|
26
+ | `$1` | 审计范围(`all`/`anti-pattern`/`coverage`/`e2e`/`perf`/`security`) | `all` |
27
+
28
+ ## Workflow
29
+
30
+ 完整 8 步见 `@skills/ultra-test/SKILL.md`(pre-check → 6 gates → auto-fix → persist → report)。
31
+
32
+ **命令入口做的事**:
33
+ 1. 探测项目类型 + `task.list` 确认 ≥1 completed
34
+ 2. 按 scope 跑 gates;失败进 auto-fix(最多 5 轮)
35
+ 3. 写 `.ultra/test-report.json`(`passed` + gate-level 明细 + blocking_issues)
36
+ 4. 通过 → 提示 `/ultra-deliver`
37
+
38
+ ## 用法
39
+
40
+ ```bash
41
+ /ultra-test # 全量审计
42
+ /ultra-test security # 只跑安全审计
43
+ /ultra-test coverage # 只找覆盖缺口
44
+ ```
45
+
46
+ ## 下一步
47
+
48
+ `passed=true` → `/ultra-deliver`;`passed=false` → 修或跟进 `blocking_issues`。
@@ -0,0 +1,45 @@
1
+ ---
2
+ description: Deep analysis with adversarial reasoning — Evidence-First + Multi-Perspective + Stress-Test + Confidence-Quantified recommendation
3
+ argument-hint: "[problem or decision to analyze]"
4
+ allowed-tools: Read, Grep, Glob, Bash, Write, Task, WebSearch, WebFetch, AskUserQuestion, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa, mcp__context7__resolve-library-id, mcp__context7__query-docs
5
+ model: opus
6
+ workflow-ref: "@skills/ultra-think/SKILL.md"
7
+ cli_fallback: "direct user interaction"
8
+ ---
9
+
10
+ # /ultra-think
11
+
12
+ ## 目标
13
+
14
+ 结构化深度分析复杂问题/决策/诊断。Evidence-First 标注(Fact/Inference/Speculation)+
15
+ 多视角 + 对抗压测(Steel-Man / Pre-Mortem / Sensitivity / Second-Order)→
16
+ 量化置信度的推荐 + 验证计划。
17
+
18
+ ## 参数
19
+
20
+ <problem>
21
+ $ARGUMENTS
22
+ </problem>
23
+
24
+ ## Workflow
25
+
26
+ 完整 5 步见 `@skills/ultra-think/SKILL.md`(Scope → Evidence → Multi-Perspective →
27
+ Adversarial → Synthesis)。
28
+
29
+ **命令入口做的事**:
30
+ 1. 读 `$ARGUMENTS` 判定问题范围 — 模糊 → 用 Host 原生提问界面最多澄清 3 个问题
31
+ 2. 简单问题 → 直接答;复杂 → 跑完整框架
32
+ 3. 输出 Markdown 报告(Problem / Analysis / Options / Adversarial / Recommendation /
33
+ Verification / Next Steps)
34
+
35
+ ## 用法
36
+
37
+ ```bash
38
+ /ultra-think "should we switch from REST to gRPC for the internal API?"
39
+ /ultra-think "why is the deploy pipeline flaky every 3rd run?"
40
+ ```
41
+
42
+ ## 下一步
43
+
44
+ 方案进入 spec → `/ultra-research` 补证据或 `/ultra-plan` 直接排任务;
45
+ 纯诊断 → 跟着 Verification Plan 走,取证后再定。
@@ -0,0 +1,143 @@
1
+ # Ultra Builder Pro — Agent Context
2
+
3
+ Current shared runtime contract for the native Claude Code, OpenCode, and Codex
4
+ plugins. Gemini CLI remains a compatibility adapter and is not the reference
5
+ shape for the three first-class plugins.
6
+
7
+ ## 1. Ownership boundary
8
+
9
+ Ultra Builder Pro owns only:
10
+
11
+ - ten public workflows: `learn`, `ultra-init`, `ultra-research`, `ultra-plan`,
12
+ `ultra-dev`, `ultra-test`, `ultra-review`, `ultra-deliver`, `ultra-status`, and
13
+ `ultra-think`;
14
+ - four internal agent-only rule skills: `code-review-expert`, `security-rules`,
15
+ `integration-rules`, and `testing-rules`;
16
+ - the host-specific collaboration companions and `ultra-verify`;
17
+ - bounded review/debug agents, workflow-only hooks, MCP task state, and the
18
+ portable CLI/orchestrator.
19
+
20
+ Browser automation, deployment helpers, skill discovery, Vercel guidance, and
21
+ other framework skills are external packages. Adapters build exclusively from
22
+ `adapters/_shared/runtime-assets.cjs`; adding a directory under `skills/` does
23
+ not put it in a plugin until that allowlist classifies it.
24
+
25
+ ## 2. Three-layer architecture
26
+
27
+ ```text
28
+ native command or skill -> MCP workflow-state operation -> CLI fallback
29
+ |
30
+ v
31
+ .ultra/state.db
32
+ ```
33
+
34
+ | Layer | Artifact | Contract |
35
+ |---|---|---|
36
+ | Skill/command | `skills/*/SKILL.md`, `commands/*.md` | Model-facing workflow and host-native entry point |
37
+ | MCP | `mcp-server/server.cjs` | Authoritative typed operations over `.ultra/state.db` |
38
+ | CLI | `ultra-tools`, `ubp-orchestrator` | Portable fallback, automation, and diagnostics |
39
+
40
+ `.ultra/state.db` is the only durable Ultra authority for tasks, sessions,
41
+ events, telemetry, review evidence, and circuit-breaker state. `tasks.json`,
42
+ context Markdown, execution plans, and reports are projections or workflow
43
+ artifacts; never treat them as a second writable authority.
44
+
45
+ ## 3. Live MCP and declared contracts
46
+
47
+ `spec/mcp-tools.yaml` declares 30 contracts across seven families. The bundled
48
+ server registers 21 tools:
49
+
50
+ | Family | Live tools |
51
+ |---|---|
52
+ | `task.*` | create, update, list, get, switch_tag, delete, init_project, expand, parse_prd, dependency_topo, append_event, subscribe_events |
53
+ | `session.*` | spawn, close, get, list, admission_check, heartbeat, subscribe_events |
54
+ | `plan.*` | export, get |
55
+
56
+ The nine declared `review.*`, `impact.*`, `skill.*`, and `ask.*` contracts are
57
+ not advertised by the live server. A generated Codex plugin records their
58
+ native replacements in `spec/codex-capability-map.json`; other hosts use their
59
+ own native review agents, repository discovery, skill loader, and user
60
+ interaction surfaces.
61
+
62
+ Any new MCP contract starts in `spec/mcp-tools.yaml` with valid and invalid
63
+ fixtures. Do not add an ad-hoc server handler first.
64
+
65
+ ## 4. Native host presentation
66
+
67
+ | Host | Plugin form | Workflow entry | Hook form | Collaboration companions |
68
+ |---|---|---|---|---|
69
+ | Claude Code | `.claude-plugin/plugin.json`, native commands/skills/agents, `.mcp.json` | `/ultra-*`, `/learn` | native `hooks/hooks.json` | `codex-collab`, `gemini-collab` |
70
+ | Codex | personal plugin with `.codex-plugin/plugin.json`, namespaced skills, TOML agents, `.mcp.json` | `$ultra-builder-pro:ultra-*`, `$ultra-builder-pro:learn` | native `hooks/hooks.json` through the Codex wire adapter | `cc-collab`, `gemini-collab` |
71
+ | OpenCode | config bundle plus native JavaScript plugin | `/ultra-*`, `/learn` | `event`, system transform, compaction, and tool lifecycle handlers | `cc-collab`, `codex-collab`, `gemini-collab` |
72
+
73
+ The current host remains primary. Collaboration skills call another runtime
74
+ only when explicitly requested, use it as a read-only advisor, and return the
75
+ evidence to the primary host for final verification.
76
+
77
+ ## 5. Hook boundary
78
+
79
+ The canonical Python hook allowlist contains seven workflow-only adapters:
80
+
81
+ - `health_check.py` and `workflow_context.py` on session start;
82
+ - `active_task_context.py` before an edit;
83
+ - `workflow_checkpoint.py` before compaction;
84
+ - `workflow_resume.py` after compaction/resume;
85
+ - `pre_stop_check.py` at stop;
86
+ - `subagent_tracker.py` for bounded worker lifecycle evidence.
87
+
88
+ Every hook is a no-op unless `.ultra/workflow-state.json` describes an active,
89
+ non-terminal workflow. OpenCode expresses the same boundary in its native
90
+ JavaScript plugin. Generic command blocking, post-edit governance, and unrelated
91
+ user hooks are not copied into Ultra Builder Pro.
92
+
93
+ ## 6. Memory boundary
94
+
95
+ Ultra Builder Pro has no memory MCP family, recall skill, prompt capture,
96
+ transcript capture, observation journal, or session-summary hook. Persistent
97
+ cross-session memory belongs to a separately installed provider such as
98
+ cloud-mem/claude-mem.
99
+
100
+ Old Ultra data is never deleted during install. The explicit migration path is:
101
+
102
+ ```bash
103
+ ultra-tools legacy-memory inspect
104
+ ultra-tools legacy-memory archive
105
+ ultra-tools legacy-memory prune --confirm DELETE_ULTRA_LEGACY_MEMORY
106
+ ```
107
+
108
+ Archive before prune; the confirmation token is intentionally required.
109
+
110
+ ## 7. Project state layout
111
+
112
+ ```text
113
+ .ultra/
114
+ ├── state.db # authoritative SQLite store
115
+ ├── workflow-state.json # active workflow/recovery checkpoint
116
+ ├── tasks/ # projections and task contexts
117
+ ├── specs/ # research/product/architecture artifacts
118
+ ├── sessions/ # bounded runtime artifacts
119
+ ├── reviews/ # review evidence
120
+ ├── test-report.json
121
+ └── delivery-report.json
122
+ ```
123
+
124
+ ## 8. User handbook integration
125
+
126
+ General engineering doctrine remains user-owned in `CLAUDE.md` or `AGENTS.md`.
127
+ Ultra Builder Pro contributes one managed section only. Preview or apply it with:
128
+
129
+ ```bash
130
+ ubp-handbook preview --runtime codex
131
+ ubp-handbook apply --runtime codex
132
+ ```
133
+
134
+ Supported runtime names are `claude`, `codex`, and `opencode`. Apply creates a
135
+ timestamped backup, replaces only the marked block, and can migrate the old
136
+ Codex `## Ultra Builder Pro Runtime Contract` section without touching the next
137
+ user section. Plugin adapters themselves do not silently overwrite handbooks.
138
+
139
+ ## 9. Verification
140
+
141
+ Run `npm run test:all`, `python3 -m pytest hooks/tests -q`, and `npm audit`.
142
+ Adapter tests assert the allowlisted assets, native manifests, hook boundary,
143
+ MCP visibility, and host-specific skill rendering.
@@ -0,0 +1,197 @@
1
+ # Ultra Builder Pro CLI — Architecture
2
+
3
+ > Single-page entry point for reviewers and contributors. The detailed
4
+ > roadmap and decision log live in [`docs/PLAN.zh-CN.md`](./PLAN.zh-CN.md);
5
+ > this file freezes the architectural shape that the PLAN drives toward.
6
+ >
7
+ > Trace: PLAN §4, decisions D12 / D13 / D18 / D20 / D29 / D32 / D33.
8
+
9
+ ## 1. One sentence
10
+
11
+ `ultra-builder-pro-cli` is a multi-runtime plugin suite that **distributes** the
12
+ Ultra Builder Pro engineering loop (skills + commands + workflow hooks) as
13
+ native Claude Code, OpenCode, and Codex plugins, with a Gemini compatibility
14
+ adapter, and
15
+ **runs** that loop with isolated sessions sharing one authoritative state
16
+ store (`.ultra/state.db`).
17
+
18
+ It is not an agent and it is not a memory provider. It is the workflow substrate
19
+ the supported hosts share.
20
+
21
+ ## 2. Three layers
22
+
23
+ ```
24
+ ┌──────────────────────────┐
25
+ │ runtime CLI │
26
+ │ (claude / opencode / │
27
+ │ codex / gemini) │
28
+ └────────────┬─────────────┘
29
+ │
30
+ ┌───────────────────┼────────────────────┐
31
+ │ │ │
32
+ ▼ ▼ ▼
33
+ ╔══════════════╗ ╔════════════════╗ ╔══════════════╗
34
+ ║ skill/ ║ ║ MCP server ║ ║ ultra-tools ║
35
+ ║ (knowledge) ║ ║ (state ops) ║ ║ (Bash ║
36
+ ║ ║ ║ ║ ║ fallback) ║
37
+ ╚══════╤═══════╝ ╚════════╤═══════╝ ╚══════╤═══════╝
38
+ │ │ │
39
+ │ resolve / read │ task.* etc. │ same tools
40
+ │ (D29 read-only) │ │ via stdio
41
+ └────────────┬───────┴──────────────────┘
42
+ ▼
43
+ ┌─────────────────────┐
44
+ │ .ultra/state.db │
45
+ │ (SQLite + WAL) │ ← single authoritative store
46
+ └──────────┬──────────┘
47
+ │ projector (Phase 2.6)
48
+ ▼
49
+ .ultra/tasks/tasks.json (read-only view)
50
+ .ultra/tasks/contexts/*.md (read-only header)
51
+ .ultra/activity-log.json (optional dump)
52
+ ```
53
+
54
+ | Layer | Role | Form |
55
+ |--------------|----------------------------------------------|-------------------------------------------------------|
56
+ | **skill** | knowledge carrier; tells the runtime *what to do* | `skills/<name>/SKILL.md` discovered natively by all four runtimes |
57
+ | **MCP** | authoritative workflow-state API | stdio MCP server exposing seven declared tool families in [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml); 21 tools are live and nine scheduled contracts map to host-native surfaces |
58
+ | **CLI** | the lowest common denominator hooks can call | `ultra-tools <family> <verb>` — same contract, last-line JSON envelope (see [`spec/cli-protocol.md`](../spec/cli-protocol.md)) |
59
+
60
+ Why three: skills give us behavior portability across runtimes; MCP gives
61
+ us a strongly-typed contract so we can refactor implementations without
62
+ rewriting prompts; CLI gives us a Python-hook-callable fallback when a
63
+ runtime's MCP transport is unavailable. None of the three could carry the
64
+ load alone (D12).
65
+
66
+ The skill layer is **read-only by design** (D29). We keep `skill.resolve`
67
+ and `skill.manifest` to let the runtime locate a SKILL.md and parse its
68
+ frontmatter; we deliberately removed `skill.invoke` and `skill.list`
69
+ because skills are documentation, not RPC.
70
+
71
+ ## 3. Authoritative state — `.ultra/state.db`
72
+
73
+ All durable Ultra workflow state lives in one SQLite file with WAL enabled. Schema is
74
+ fixed in [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) and
75
+ covers eight tables:
76
+
77
+ | Table | Holds | Phase |
78
+ |--------------------|---------------------------------------------------|-------|
79
+ | `tasks` | task rows — id, status, deps, files_modified, … | 2 |
80
+ | `events` | append-only event stream; `id` is subscription cursor (D31) | 2 |
81
+ | `sessions` | execution sessions, **including lease + heartbeat fields** (D32) | 4.5 |
82
+ | `schema_version` | applied schema version (cross-version misread guard, D30) | 2 |
83
+ | `migration_history`| one row per migration attempt (audit trail) | 2 |
84
+ | `telemetry` | per-session token / cost / tool-call counters | 6 |
85
+ | `specs_refs` | spec change tracking → staleness propagation | 5 |
86
+ | `circuit_breaker` | bounded retry and halt state for failed tasks | 5 |
87
+
88
+ Two rules make this work:
89
+
90
+ 1. **No double source (D32).** lease/heartbeat live only in `sessions`,
91
+ not in a `lease.json` file. Activity log lives only in `events`, not
92
+ in JSON files. `tasks.json` and the status header in
93
+ `contexts/task-*.md` are **projections** generated by the projector;
94
+ manual edits are overwritten on the next state.db change.
95
+
96
+ 2. **Single writer for mutable tables, multi-writer for `events`.**
97
+ `.ultra/state.db` opens in WAL with `busy_timeout=5000`. The MCP
98
+ server holds the single writer connection for `tasks`, `sessions`,
99
+ `telemetry`, `specs_refs`, and `migration_history`; the CLI calls
100
+ those tools over stdio rather than opening its own writer. The
101
+ `events` table is append-only and explicitly multi-writer — CLI and
102
+ orchestrator processes append directly to it under the same WAL +
103
+ `busy_timeout` discipline, since independent INSERTs do not conflict.
104
+ In `spec/mcp-tools.yaml` this split is captured by `writer_role: mcp`
105
+ (must go through the MCP server) versus `writer_role: any` (any
106
+ process may execute). Full policy lives in
107
+ `docs/STATE-DB-ACCESS-POLICY.md` (Phase 2.2 / R25).
108
+
109
+ Subscribers always pull `events.id > since_id` rather than `max(ts)`,
110
+ because two events may share the same millisecond timestamp (D31).
111
+
112
+ ### Memory ownership is outside Ultra Builder Pro
113
+
114
+ Ultra Builder Pro does not retain prompts, transcripts, tool observations,
115
+ session summaries, or cross-session memory. It ships no `memory.*` MCP family,
116
+ no recall skill, and no memory-capture hook. A separately installed provider
117
+ such as cloud-mem/claude-mem owns persistent memory and its own lifecycle. The
118
+ only related migration surface is the explicit `ultra-tools legacy-memory`
119
+ archive/prune command for data created by older releases.
120
+
121
+ ## 4. Sessions — the execution unit
122
+
123
+ A **session** is the standard unit of execution across all four runtimes
124
+ (D20). One session =
125
+
126
+ - a fresh OS process for the runtime,
127
+ - an isolated `git worktree`,
128
+ - a lease + heartbeat row in `sessions` (D32),
129
+ - an `artifact_dir` under `.ultra/sessions/<sid>/` for logs and scratch.
130
+
131
+ Spawning a new session for a task is gated by `session.admission_check`
132
+ (D33). If another session already owns an active lease on the same task,
133
+ the caller must pick one of three strategies before proceeding:
134
+
135
+ - `takeover` — kill the prior process, claim the lease,
136
+ - `resume` — attach to the existing session and continue,
137
+ - `abandon` — give up and let the existing session finish.
138
+
139
+ This admission gate is the smallest piece that prevents two agents from
140
+ silently double-writing the same task — it is part of the v0.1 minimum
141
+ execution layer, not deferred to Phase 5.
142
+
143
+ ## 5. Two timelines — rule layer vs execution layer
144
+
145
+ The roadmap separates two concerns that compete for the same surface
146
+ area (D13):
147
+
148
+ ```
149
+ ┌─ Rule layer (Phase 1-4.5) ────────────────────────────────┐
150
+ │ contracts, state schema, command shells, runtime │
151
+ │ installers, smoke flow, execution-lite │
152
+ │ │
153
+ │ v0.1 (Week 8) = rule layer fully wired + execution-lite │
154
+ └────────────────────────────────────────────────────────────┘
155
+
156
+ ┌─ Execution layer (Phase 4.5-8B) ───────────────────────────┐
157
+ │ recovery, staleness, monitoring, intelligence, planning │
158
+ │ automation, parallel worktree dispatch │
159
+ │ │
160
+ │ v0.2 (Week 11) = recovery + monitoring + full conformance │
161
+ │ v0.3 (Week 16) = PRD → execution-plan → parallel factory │
162
+ │ v1.0 (Week 17-18) = npm + Homebrew + pip distribution │
163
+ └────────────────────────────────────────────────────────────┘
164
+ ```
165
+
166
+ The rule layer is shipped before the execution layer because users get
167
+ value from "skills + tasks survive across sessions" long before they get
168
+ value from "ten agents in parallel." Each milestone is independently
169
+ shippable; downstream slip never blocks an earlier release.
170
+
171
+ ## 6. Where to look next
172
+
173
+ | Question | File |
174
+ |----------------------------------------------------|-----------------------------------------------------|
175
+ | What does each MCP tool accept and return? | [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml) |
176
+ | How do CLI subcommands map to MCP tools? | [`spec/cli-protocol.md`](../spec/cli-protocol.md) |
177
+ | Exact SQLite schema? | [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) |
178
+ | What does a tasks.json look like after projection? | [`spec/fixtures/valid/tasks.v4.5.json`](../spec/fixtures/valid/tasks.v4.5.json) |
179
+ | Phase-by-phase work breakdown + decision log | [`docs/PLAN.zh-CN.md`](./PLAN.zh-CN.md) |
180
+
181
+ ## 7. Verifying the architecture
182
+
183
+ Every contract on this page is enforced by `npm run test:spec`:
184
+
185
+ - `validate-mcp-tools.cjs` — meta-schema for the tool manifest, plus
186
+ per-tool sample input/output fixtures.
187
+ - `validate-state-db.cjs` — schema applies cleanly to a fresh in-memory
188
+ SQLite, valid fixtures insert, invalid fixtures are rejected by
189
+ CHECK / NOT NULL / FK constraints.
190
+ - `validate-json-schemas.cjs` — projection schemas for `tasks.json` and
191
+ `contexts/task-*.md`.
192
+ - `validate-skills.cjs` — every existing skill passes the manifest
193
+ contract; failures are recorded in `spec/migration-notes.md`.
194
+ - `check-cli-mapping.cjs` — every MCP tool has exactly one CLI
195
+ subcommand and the doc table never drifts from the YAML manifest.
196
+
197
+ If any of these fails, the architecture is no longer the architecture.