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,102 @@
1
+ # ultra-builder-pro-cli — Roadmap
2
+
3
+ > **Authoritative roadmap**: [`PLAN.zh-CN.md`](./PLAN.zh-CN.md) (v0.3.1).
4
+ > This file is a one-page summary; details, decisions, and time estimates
5
+ > live in PLAN. If they disagree, PLAN wins.
6
+
7
+ **Goal**: distribute the Ultra Builder Pro engineering loop as native Claude
8
+ Code, OpenCode, and Codex plugins, retain a Gemini compatibility extension, and
9
+ run the loop with isolated sessions sharing one authoritative workflow store.
10
+
11
+ **First-class runtimes**: Claude Code · OpenCode · Codex.
12
+
13
+ **Distribution channels (v1.0)**: npm · Homebrew · pip.
14
+
15
+ **Confidence**: 86% (PLAN §10).
16
+
17
+ **Timeline**: 14–18 weeks AI-assisted (PLAN §11).
18
+
19
+ ---
20
+
21
+ ## Milestones
22
+
23
+ | Release | Week | Contents |
24
+ |---------|-----:|---------------------------------------------------------------------------|
25
+ | **v0.1**| 8 | Rule layer + execution-lite (session isolation + admission + event subscribe + active-session visibility) — solves the core "independent conversations don't pollute each other" pain |
26
+ | **v0.2**| 11 | Auto-recovery + monitoring + real-time code-review-graph + full conformance |
27
+ | **v0.3**| 16 | PRD → execution-plan artifact → parallel dispatch / merge — coding factory |
28
+ | **v1.0**| 17–18| Three-channel publish (npm + Homebrew + pip) |
29
+
30
+ ## Phase status
31
+
32
+ | Phase | Title | Status |
33
+ |-------|------------------------------------------------|---------------|
34
+ | 0 | Skeleton | ✅ done (`da69a7a`) |
35
+ | 1 | Three-layer interface contracts (`spec/`) | ✅ done (D38) |
36
+ | 2 | Authoritative state — SQLite + WAL | ✅ done (D39, `e286e41`) |
37
+ | 3 | Command thin-shells (skill + MCP + CLI) | ✅ done (D40, `b3d1797`) |
38
+ | 4 | Cross-runtime distribution + 4.6a smoke flow | ✅ done (D41, `5aa1fd0`) |
39
+ | 4.5 | Execution-lite (session + admission + events) | ✅ done (D42, `0d3e5ed`) — **v0.1 ready** |
40
+ | 5 | Recovery + staleness + auto-routing | ✅ done (D43) → v0.2 |
41
+ | 6 | Monitoring + code-review-graph live watcher | ✅ done (D44) → v0.2 |
42
+ | 4.6b | Full conformance suite | ✅ done (D45) — 20 conformance + 21 resolveTarget tests |
43
+ | 7 | tagged tasks + skill mining; retired Ultra memory handed to cloud-mem/claude-mem | ✅ superseded by D50 boundary cleanup |
44
+ | 8A | Plan automation (parse / topo / expand + artifact + human gate) | ✅ done (D47, `a932cb8`) → v0.3 |
45
+ | 8B | Execution automation (dispatch / parallel worktree / merge) | ✅ done (D48, `8224159`) — **v0.3 ready** |
46
+ | 9 | Release pipeline (npm / Homebrew / pip) | pending → v1.0 |
47
+
48
+ ## What is in the repo today
49
+
50
+ ```
51
+ spec/ ← Phase 1 single source of truth
52
+ ├── mcp-tools.yaml (30 declared tools across 7 families; 21 live)
53
+ ├── cli-protocol.md (CLI ↔ MCP mapping table)
54
+ ├── schemas/ (state-db.sql + 4 JSON schemas)
55
+ ├── fixtures/{valid,invalid}/ (+ v4.4-project for migration)
56
+ └── scripts/test-all.cjs (npm run test:spec — 5 validators)
57
+
58
+ mcp-server/ ← Phase 2 authoritative state layer
59
+ ├── server.cjs (stdio MCP server, 21 task/session/plan tools)
60
+ ├── lib/
61
+ │ ├── state-db.cjs (SQLite + WAL + pragmas)
62
+ │ ├── state-ops.cjs (full write API, status state machine)
63
+ │ └── projector.cjs (state.db → tasks.json + context md)
64
+ └── tests/ (npm run test:state — 44 tests)
65
+
66
+ ultra-tools/ ← CLI fallback, migration, and diagnostics
67
+ ├── cli.cjs
68
+ └── commands/
69
+ ├── db.cjs (init/checkpoint/vacuum/integrity/backup)
70
+ ├── migrate.cjs (v4.4 → v4.5 + dry/rollback)
71
+ └── legacy-memory.cjs (explicit inspect/archive/confirmed prune)
72
+
73
+ bin/install.js ← multi-runtime installer
74
+ bin/handbook.js ← explicit managed user-handbook sync
75
+ adapters/ ← native Claude/OpenCode/Codex plugin builders + Gemini compatibility
76
+ skills/ ← allowlisted Ultra workflows, internal rules, and collab companions
77
+ hooks/ ← 7 workflow-only Python hooks; OpenCode uses native JavaScript hooks
78
+ docs/
79
+ ├── PLAN.zh-CN.md authoritative plan (1670+ lines)
80
+ ├── ARCHITECTURE.md Phase 1 single-page entry point
81
+ ├── AGENT-CONTEXT.md Phase 3 canonical runtime context contract
82
+ ├── USER-HANDBOOK-CONTRACT.md managed CLAUDE.md / AGENTS.md boundary
83
+ ├── RUNTIME-COMPAT-MATRIX.md Phase 4 runtime capability matrix
84
+ ├── STATE-DB-ACCESS-POLICY.md Phase 2 multi-process write contract
85
+ ├── COMMIT-HASH-BACKFILL.md Phase 2.8 two-commit completion flow
86
+ └── ROADMAP.md this file
87
+ ```
88
+
89
+ ## How to verify
90
+
91
+ ```
92
+ npm install
93
+ npm run test:all
94
+ python3 -m pytest hooks/tests -q
95
+ npm audit
96
+ ```
97
+
98
+ ## Out of scope for v1.0 (deferred)
99
+
100
+ PLAN §13 lists Copilot / Cursor / Windsurf / 7 more runtimes, web
101
+ dashboard / TUI, LLM provider abstraction, team-collab server, plugin
102
+ marketplace.
@@ -0,0 +1,98 @@
1
+ # Runtime Compatibility Matrix
2
+
3
+ Current presentation contract for Ultra Builder Pro. Claude Code, OpenCode, and
4
+ Codex are first-class native plugins; Gemini CLI remains a compatibility
5
+ extension. The canonical asset boundary lives in
6
+ `adapters/_shared/runtime-assets.cjs`.
7
+
8
+ Legend: **FULL** = native host surface, **DEGRADED** = compatible but missing an
9
+ equivalent lifecycle/control surface, **N/A** = intentionally not installed.
10
+
11
+ ## 1. Plugin and workflow surface
12
+
13
+ | Capability | Claude Code | OpenCode | Codex | Gemini CLI |
14
+ |---|---|---|---|---|
15
+ | Package form | `.claude-plugin` native plugin | native config bundle + JS plugin | personal `.codex-plugin` | compatibility extension |
16
+ | Public entry | `/ultra-*`, `/learn` | `/ultra-*`, `/learn` | `$ultra-builder-pro:<skill>` | generated command TOML |
17
+ | Public Ultra workflows | 10 | 10 | 10 | 10 |
18
+ | Internal agent-rule skills | 4, non-user-facing | 4, non-user-facing | 4 with implicit invocation disabled | 4 prompt dependencies |
19
+ | Collaboration companions | `codex-collab`, `gemini-collab`, `ultra-verify` | `cc-collab`, `codex-collab`, `gemini-collab`, `ultra-verify` | `cc-collab`, `gemini-collab`, `ultra-verify` | `cc-collab`, `codex-collab`, `ultra-verify` |
20
+ | External browser/deploy/framework skills | N/A | N/A | N/A | N/A |
21
+
22
+ Codex does not emulate deprecated custom slash prompts. Its adapter converts
23
+ the workflows into namespaced skills and records nine legacy command mappings
24
+ in `command-map.json`; `ultra-review` is directly invocable as a skill.
25
+
26
+ ## 2. Agents and collaboration
27
+
28
+ | Capability | Claude Code | OpenCode | Codex | Gemini CLI |
29
+ |---|---|---|---|---|
30
+ | Bundled review/debug agents | FULL, native Markdown agents | FULL, lowercased native agent frontmatter | FULL, nine managed TOML custom agents | N/A |
31
+ | Native bounded delegation | `Task`/agent surface | native agent surface | native Codex subagents | evolving host surface, not packaged |
32
+ | Cross-host advisor | explicit collab skill; read-only | explicit collab skill; read-only | explicit collab skill; read-only | explicit collab skill; read-only |
33
+ | Primary-agent ownership | FULL | FULL | FULL | FULL |
34
+
35
+ No bundled agent declares private persistent memory. It receives current
36
+ checkout evidence and bounded context from the primary host, then returns a
37
+ result for primary verification.
38
+
39
+ ## 3. Workflow hooks
40
+
41
+ | Lifecycle | Claude Code | OpenCode | Codex | Gemini CLI |
42
+ |---|---|---|---|---|
43
+ | Session context/health | FULL, native `SessionStart` | FULL, system transform + event refresh | FULL, native `SessionStart` | N/A |
44
+ | Active edit boundary | FULL, `PreToolUse Edit|Write` | DEGRADED, tool lifecycle can refresh but not inject a native pre-edit message | FULL, `PreToolUse Edit|Write` | N/A |
45
+ | Compaction recovery | FULL, `PreCompact` + compact resume matcher | FULL, native compacting context | FULL, `PreCompact` + `PostCompact` | N/A |
46
+ | Incomplete-stop gate | FULL, native blocking `Stop` hook | DEGRADED, no equivalent blocking stop hook | FULL, native blocking `Stop` hook | N/A |
47
+ | Subagent lifecycle evidence | FULL | DEGRADED, no equivalent packaged event | FULL | N/A |
48
+
49
+ All reachable hooks are workflow-only and no-op without an active non-terminal
50
+ `.ultra/workflow-state.json`. No runtime receives Ultra prompt capture,
51
+ transcript capture, observation journal, session-summary memory, generic command
52
+ blocking, or generic post-edit policy.
53
+
54
+ ## 4. MCP and state
55
+
56
+ | Capability | Claude Code | OpenCode | Codex | Gemini CLI |
57
+ |---|---|---|---|---|
58
+ | stdio MCP registration | plugin `.mcp.json` | `opencode.json` local MCP entry | plugin `.mcp.json` | extension manifest |
59
+ | Live contracts | 21 | 21 | 21 | 21 |
60
+ | Declared upstream contracts | 30 | 30 | 30 | 30 |
61
+ | Nine non-live contracts | host-native review/discovery/ask surfaces | host-native review/discovery/ask surfaces | explicit `codex-capability-map.json` | compatibility guidance |
62
+ | Durable authority | project `.ultra/state.db` | project `.ultra/state.db` | project `.ultra/state.db` | project workflow state when invoked from the project |
63
+ | Ultra memory API | N/A | N/A | N/A | N/A |
64
+
65
+ The seven declared tool families are `task`, `session`, `plan`, `review`,
66
+ `impact`, `skill`, and `ask`. Only the 21 `task.*`, `session.*`, and `plan.*`
67
+ operations registered by `mcp-server/server.cjs` are advertised as live.
68
+
69
+ ## 5. User handbook presentation
70
+
71
+ | Capability | Claude Code | OpenCode | Codex | Gemini CLI |
72
+ |---|---|---|---|---|
73
+ | Durable user file | `~/.claude/CLAUDE.md` | `~/.config/opencode/AGENTS.md` | `~/.codex/AGENTS.md` | extension `GEMINI.md` context |
74
+ | Automatic overwrite by plugin install | no | no | no | extension-owned context only |
75
+ | Explicit managed-block sync | `ubp-handbook --runtime claude` | `ubp-handbook --runtime opencode` | `ubp-handbook --runtime codex` | N/A |
76
+ | Backup before change | FULL | FULL | FULL | N/A |
77
+
78
+ ## 6. Install, update, and uninstall
79
+
80
+ | Capability | Claude Code | OpenCode | Codex | Gemini CLI |
81
+ |---|---|---|---|---|
82
+ | Adapter install | FULL | FULL | FULL | FULL compatibility |
83
+ | Native registration/update | host loads plugin directory on next session | host loads local JS plugin on restart | cachebuster + `codex plugin add`; start a new task | host loads extension |
84
+ | Removes stale managed assets | FULL | FULL | FULL | FULL while preserving extension runtime state |
85
+ | Preserves unrelated user config | FULL | FULL | FULL | FULL inside user config; extension directory is managed |
86
+ | Uninstall ownership guard | managed plugin root | sentinels + owned MCP entry | managed root/manifest/agent headers | extension `_ubp.source` |
87
+
88
+ ## 7. Verification sources
89
+
90
+ - `adapters/tests/*.test.cjs` verifies each installer and native manifest.
91
+ - `tests/conformance/<runtime>/*.test.cjs` verifies command/skill, hook, MCP,
92
+ idempotency, and smoke presentation.
93
+ - `adapters/_shared/tests/runtime-assets.test.cjs` prevents retired or external
94
+ skills and generic/memory hooks from re-entering any package.
95
+ - `adapters/_shared/tests/handbook.test.cjs` verifies host rendering, safe
96
+ legacy-section migration, backup, and idempotency.
97
+
98
+ Any capability claim elsewhere must match current adapter code and these tests.
@@ -0,0 +1,109 @@
1
+ # `.ultra/state.db` access policy
2
+
3
+ > Phase 2.2 contract. Trace: PLAN §6 Phase 2.2, decisions D18 / D32 / D37,
4
+ > risks R21 / R25.
5
+
6
+ `.ultra/state.db` is the only authoritative state store for tasks,
7
+ events, sessions, telemetry, and spec references (D18). Every process
8
+ that touches it must follow the rules below; deviations are bugs.
9
+
10
+ ## 1. Three-role write matrix
11
+
12
+ | Role | tasks | events | sessions | telemetry | specs_refs | migration_history |
13
+ |----------------------------|:-----:|:------:|:--------:|:---------:|:----------:|:-----------------:|
14
+ | **MCP server** (single writer for mutables) | RW | RW | RW | RW | RW | RW |
15
+ | **CLI** (`ultra-tools …`) | R | RW (append-only) | R | R | R | R |
16
+ | **Orchestrator daemon** (Phase 5+) | R | RW | RW | RW | RW | R |
17
+
18
+ - **R** = read-only;
19
+ - **RW** = read + write;
20
+ - A `(append-only)` qualifier means the role may execute `INSERT INTO`
21
+ but never `UPDATE` / `DELETE`.
22
+
23
+ The CLI may indirectly mutate any table by spawning the MCP server over
24
+ stdio and calling `task.update`, `session.spawn`, etc. — but the actual
25
+ SQLite write is performed by the MCP server's writer connection. The CLI
26
+ never opens a writer connection on `tasks`, `sessions`, `telemetry`,
27
+ `specs_refs`, or `migration_history`.
28
+
29
+ The append-only carve-out for `events` exists because `events.id INTEGER
30
+ PRIMARY KEY AUTOINCREMENT` makes concurrent inserts collision-free under
31
+ WAL + `busy_timeout`. This lets hooks and short-lived CLI invocations
32
+ record audit events without paying the cost of a full MCP round trip.
33
+
34
+ ## 2. Connection discipline
35
+
36
+ Every process **must**:
37
+
38
+ 1. Open the database with WAL + `busy_timeout=5000` + `foreign_keys=ON`.
39
+ Use `mcp-server/lib/state-db.cjs` `openStateDb` so the pragmas are
40
+ applied uniformly.
41
+ 2. Wrap every write in `BEGIN IMMEDIATE` (use the helper `withWrite(db,
42
+ fn)` once Phase 2.3 lands; until then call `db.transaction(fn)()` and
43
+ know that better-sqlite3 promotes to IMMEDIATE on the first write).
44
+ 3. Retry up to **3 times** on `SQLITE_BUSY`, with exponential backoff
45
+ starting at 25 ms. Each retry must re-issue the full transaction —
46
+ never partially commit.
47
+ 4. Close the connection in a `finally` block. WAL files (`-wal`,
48
+ `-shm`) are reclaimed on the last writer's close.
49
+
50
+ Reads never need explicit transactions; better-sqlite3 reads observe a
51
+ consistent snapshot under WAL.
52
+
53
+ ## 3. WAL fallback
54
+
55
+ WAL is **unsafe on NFS / SMB / certain Docker bind mounts** (R21). When
56
+ `.ultra/state.db` resides on such a filesystem the orchestrator must
57
+ either:
58
+
59
+ - refuse to start (preferred — surfaces the deployment problem early), or
60
+ - downgrade to `PRAGMA journal_mode = DELETE` and warn loudly. Concurrent
61
+ writers fall back to short-burst contention; throughput drops but
62
+ correctness holds.
63
+
64
+ Detection happens at boot: `statvfs` of `.ultra/state.db`'s mount;
65
+ `f_type` ∈ `{NFS_SUPER_MAGIC, SMB_SUPER_MAGIC}` ⇒ refuse / downgrade.
66
+
67
+ ## 4. Where each table is owned
68
+
69
+ | Table | Writer of record |
70
+ |--------------------|--------------------------------------------------------|
71
+ | `tasks` | MCP server (`task.create` / `task.update` / `task.delete`) |
72
+ | `events` | MCP server **and** any process via append-only INSERT |
73
+ | `sessions` | MCP server (`session.spawn` / `session.close` / `session.heartbeat`); orchestrator may write status transitions |
74
+ | `telemetry` | MCP server (collected from tool-call wrappers); orchestrator may dump bulk samples |
75
+ | `specs_refs` | MCP server (rebuilt on `spec_changed` event); orchestrator may rebuild |
76
+ | `migration_history`| `ultra-tools migrate` CLI only |
77
+ | `schema_version` | `ultra-tools db init` and `ultra-tools migrate` only |
78
+
79
+ ## 5. Forbidden patterns
80
+
81
+ - **No file copies for state.** Don't `cp .ultra/state.db
82
+ somewhere/state.db` and edit; use `ultra-tools db backup`.
83
+ - **No long-held writer connections** outside the MCP server. Pop a
84
+ short transaction, finish, close.
85
+ - **No `PRAGMA journal_mode` toggling at runtime** by any process other
86
+ than the orchestrator's boot-time WAL detector.
87
+ - **No raw SQL in command md files.** Commands call MCP tools or
88
+ `ultra-tools …` subcommands; the SQL lives in `mcp-server/lib`.
89
+ - **No `vacuum` / `wal_checkpoint(TRUNCATE)` from inside a transaction.**
90
+ Maintenance subcommands open their own connection.
91
+
92
+ ## 6. Maintenance windows
93
+
94
+ `ultra-tools db checkpoint` and `ultra-tools db vacuum` are safe to run
95
+ while the MCP server is up (they take their own connection and obey the
96
+ busy timeout). `db backup` uses better-sqlite3's online `.backup` API
97
+ and produces a consistent snapshot without blocking writers.
98
+
99
+ ## 7. Verification
100
+
101
+ The contract on this page is enforced by:
102
+
103
+ - `mcp-server/tests/concurrency.test.cjs` — three writer threads
104
+ appending to `events` simultaneously; asserts no `SQLITE_BUSY` escapes
105
+ the retry loop and the resulting `events.id` sequence has no gaps and
106
+ no duplicates.
107
+ - Phase 2.3 will add `concurrency-update.test.cjs` — 20 worker threads
108
+ driving `task.update` against disjoint task ids, verifying serialized
109
+ writes through the MCP server.
@@ -0,0 +1,61 @@
1
+ # Ultra Builder Pro — User Handbook Contract
2
+
3
+ Ultra Builder Pro does not own a user's complete `CLAUDE.md` or `AGENTS.md`.
4
+ Those files contain durable engineering doctrine for the host. The plugin owns
5
+ only one small managed section describing its runtime boundary.
6
+
7
+ ## Source and render targets
8
+
9
+ `adapters/_shared/handbook.cjs` is the canonical source. It renders the common
10
+ authority, memory, hook, agent, and package boundaries with host-native command
11
+ syntax:
12
+
13
+ | Runtime | Default target | Main invocation form |
14
+ |---|---|---|
15
+ | Claude Code | `~/.claude/CLAUDE.md` | `/ultra-plan` |
16
+ | Codex | `~/.codex/AGENTS.md` | `$ultra-builder-pro:ultra-plan` |
17
+ | OpenCode | `~/.config/opencode/AGENTS.md` | `/ultra-plan` |
18
+
19
+ The renderer never copies Claude Code-only APIs into Codex or OpenCode. Each
20
+ host receives only its native invocation and collaboration names.
21
+
22
+ ## Managed-block contract
23
+
24
+ The owned content is bounded by:
25
+
26
+ ```markdown
27
+ <!-- ultra-builder-pro:handbook:start -->
28
+ ...
29
+ <!-- ultra-builder-pro:handbook:end -->
30
+ ```
31
+
32
+ Rules outside those markers remain byte-for-byte user-owned. A malformed or
33
+ duplicated marker pair is an error, not an invitation to guess. For Codex only,
34
+ the first apply can migrate the old unmarked
35
+ `## Ultra Builder Pro Runtime Contract` section up to the next level-two heading.
36
+
37
+ ## Safe workflow
38
+
39
+ Preview the full merged result before applying:
40
+
41
+ ```bash
42
+ ubp-handbook preview --runtime claude
43
+ ubp-handbook preview --runtime codex
44
+ ubp-handbook preview --runtime opencode
45
+ ```
46
+
47
+ Apply when the preview is correct:
48
+
49
+ ```bash
50
+ ubp-handbook apply --runtime claude
51
+ ubp-handbook apply --runtime codex
52
+ ubp-handbook apply --runtime opencode
53
+ ```
54
+
55
+ An existing target is copied to
56
+ `<file>.ubp-backup-<timestamp>` before the atomic replacement. Re-running apply
57
+ with the same rendered content is a no-op and creates no additional backup.
58
+
59
+ The plugin installer intentionally does not apply this section implicitly. A
60
+ plugin update and a durable user-handbook change have different rollback and
61
+ review requirements, so handbook mutation stays explicit.
@@ -0,0 +1,24 @@
1
+ # Ultra Builder Pro workflow hooks
2
+
3
+ These hooks protect only a currently active Ultra workflow. Every hook is a no-op unless the
4
+ project contains `.ultra/workflow-state.json` with a non-terminal status.
5
+
6
+ | Lifecycle | Hook | Purpose |
7
+ |---|---|---|
8
+ | Session start | `health_check.py` | Advisory check of `.ultra/state.db` core tables |
9
+ | Session start | `workflow_context.py` | Inject current command, task, step, and authority |
10
+ | Before edit | `active_task_context.py` | Restate the active task boundary |
11
+ | Before compact | `workflow_checkpoint.py` | Atomically save a minimal workflow checkpoint |
12
+ | After compact/resume | `workflow_resume.py` | Re-inject the current workflow boundary |
13
+ | Stop | `pre_stop_check.py` | Block once when the Ultra workflow is incomplete |
14
+ | Subagent lifecycle | `subagent_tracker.py` | Append lifecycle evidence under `.ultra/runtime/` |
15
+
16
+ The plugin deliberately does not capture prompts, tool observations, transcripts, summaries, or
17
+ cross-session memory. Generic command blocking and post-edit policy are user/repository governance,
18
+ not Ultra plugin hooks. Persistent memory belongs to the separately installed memory provider.
19
+
20
+ Runtime wiring:
21
+
22
+ - Claude Code: native `hooks/hooks.json` with `${CLAUDE_PLUGIN_ROOT}` paths.
23
+ - Codex: native `hooks/hooks.json` through `hooks/adapters/codex.py` for wire normalization.
24
+ - OpenCode: native JavaScript plugin events; the Python hook suite is not copied.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env python3
2
+ """Remind an active Ultra workflow of its task boundary before edits."""
3
+
4
+ import json
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ TERMINAL = {"committed", "completed", "done", "cancelled"}
9
+
10
+
11
+ def main() -> None:
12
+ try:
13
+ data = json.loads(sys.stdin.read() or "{}")
14
+ data = data if isinstance(data, dict) else {}
15
+ except json.JSONDecodeError as exc:
16
+ print(f"[active_task_context] invalid hook input: {exc}", file=sys.stderr)
17
+ data = {}
18
+ start = Path(data.get("cwd") or Path.cwd()).resolve()
19
+ for root in (start, *start.parents):
20
+ state_file = root / ".ultra" / "workflow-state.json"
21
+ if not state_file.is_file():
22
+ continue
23
+ try:
24
+ state = json.loads(state_file.read_text(encoding="utf-8"))
25
+ except (OSError, json.JSONDecodeError) as exc:
26
+ print(f"[active_task_context] cannot read {state_file}: {exc}", file=sys.stderr)
27
+ break
28
+ if not isinstance(state, dict) or state.get("status") in TERMINAL:
29
+ break
30
+ task = state.get("task_id", state.get("task", "unknown"))
31
+ step = state.get("step", "unknown")
32
+ print(json.dumps({"hookSpecificOutput": {
33
+ "hookEventName": "PreToolUse",
34
+ "additionalContext": (
35
+ f"Active Ultra task {task}, step {step}. Keep this edit inside the approved "
36
+ "task and preserve .ultra/state.db as workflow authority."
37
+ ),
38
+ }}))
39
+ return
40
+ print(json.dumps({}))
41
+
42
+
43
+ if __name__ == "__main__":
44
+ main()