ultra-builder-pro-cli 0.22.0 → 0.24.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 (93) hide show
  1. package/.ultra-template/docs/research/README.md +4 -4
  2. package/CHANGELOG.md +83 -0
  3. package/README.md +68 -35
  4. package/adapters/_shared/codex-assets.cjs +121 -60
  5. package/adapters/_shared/interaction-contract.cjs +20 -7
  6. package/adapters/_shared/provenance.cjs +7 -2
  7. package/adapters/_shared/runtime-assets.cjs +4 -3
  8. package/adapters/_shared/runtime-native.cjs +132 -0
  9. package/adapters/claude.js +61 -31
  10. package/adapters/codex.js +178 -81
  11. package/adapters/grok.js +372 -0
  12. package/adapters/kimi.js +8 -4
  13. package/adapters/opencode.js +211 -33
  14. package/agents/code-reviewer.md +4 -2
  15. package/agents/debugger.md +4 -1
  16. package/agents/review-code.md +7 -3
  17. package/agents/review-comments.md +7 -4
  18. package/agents/review-coordinator.md +11 -7
  19. package/agents/review-design.md +8 -4
  20. package/agents/review-errors.md +8 -4
  21. package/agents/review-spec.md +8 -5
  22. package/agents/review-tests.md +7 -4
  23. package/agents/tdd-runner.md +5 -2
  24. package/bin/install.js +9 -4
  25. package/bin/orchestrator.js +4 -13
  26. package/docs/AGENT-CONTEXT.md +141 -231
  27. package/docs/ARCHITECTURE.md +203 -498
  28. package/docs/ARTIFACT-AUTHORITY.md +38 -35
  29. package/docs/PLUGIN-ISOLATION-CONTRACT.md +12 -9
  30. package/docs/ROADMAP.md +85 -110
  31. package/docs/RUNTIME-COMPAT-MATRIX.md +139 -174
  32. package/docs/SKILL-AUTHORING.md +3 -3
  33. package/docs/STATE-DB-ACCESS-POLICY.md +25 -20
  34. package/docs/WORKFLOW-LIFECYCLE.md +174 -442
  35. package/hooks/README.md +11 -8
  36. package/hooks/active_task_context.py +16 -16
  37. package/hooks/adapters/grok.py +134 -0
  38. package/hooks/{context_spine.py → context_envelope.py} +26 -22
  39. package/hooks/health_check.py +19 -29
  40. package/hooks/pre_stop_check.py +22 -12
  41. package/hooks/subagent_tracker.py +1 -1
  42. package/hooks/workflow_checkpoint.py +14 -13
  43. package/hooks/workflow_context.py +11 -12
  44. package/hooks/workflow_resume.py +14 -13
  45. package/mcp-server/{breadcrumb.cjs → hook-context.cjs} +7 -9
  46. package/mcp-server/lib/artifact-registry.cjs +25 -1
  47. package/mcp-server/lib/baseline-workflow.cjs +36 -38
  48. package/mcp-server/lib/canonical-json.cjs +19 -0
  49. package/mcp-server/lib/change-workflow.cjs +637 -49
  50. package/mcp-server/lib/context-envelope.cjs +508 -0
  51. package/mcp-server/lib/decision-records.cjs +337 -0
  52. package/mcp-server/lib/doctor.cjs +91 -33
  53. package/mcp-server/lib/init-project.cjs +78 -39
  54. package/mcp-server/lib/managed-file-write.cjs +116 -0
  55. package/mcp-server/lib/plan-checkpoint.cjs +177 -0
  56. package/mcp-server/lib/project-context.cjs +178 -0
  57. package/mcp-server/lib/stage-checkpoints.cjs +309 -0
  58. package/mcp-server/lib/state-db.cjs +155 -24
  59. package/mcp-server/lib/task-ledger.cjs +522 -13
  60. package/mcp-server/lib/ultra-facade.cjs +834 -0
  61. package/mcp-server/lib/worker-packet.cjs +358 -0
  62. package/mcp-server/server.cjs +208 -1059
  63. package/orchestrator/daemon.cjs +27 -9
  64. package/orchestrator/parallel-orchestrator.cjs +111 -76
  65. package/orchestrator/session-runner.cjs +135 -34
  66. package/package.json +10 -3
  67. package/skills/ultra-change/SKILL.md +39 -98
  68. package/skills/ultra-deliver/SKILL.md +42 -65
  69. package/skills/ultra-dev/SKILL.md +52 -99
  70. package/skills/ultra-doctor/SKILL.md +35 -57
  71. package/skills/ultra-init/SKILL.md +48 -88
  72. package/skills/ultra-init/references/brownfield-adoption.md +11 -8
  73. package/skills/ultra-plan/SKILL.md +54 -132
  74. package/skills/ultra-research/SKILL.md +58 -112
  75. package/skills/ultra-review/SKILL.md +28 -46
  76. package/skills/ultra-review/references/unified-schema.md +2 -0
  77. package/skills/ultra-review/scripts/review_wait.py +8 -0
  78. package/skills/ultra-status/SKILL.md +22 -45
  79. package/skills/ultra-test/SKILL.md +27 -61
  80. package/skills/ultra-think/SKILL.md +29 -48
  81. package/skills/ultra-think/references/interaction-boundary.md +56 -0
  82. package/spec/cli-protocol.md +80 -187
  83. package/spec/mcp-tools.yaml +130 -2738
  84. package/spec/schemas/mcp-tools.schema.json +1 -1
  85. package/spec/schemas/state-db.sql +107 -4
  86. package/spec/schemas/{task-ledger.v1.schema.json → task-ledger.v2.schema.json} +70 -6
  87. package/ultra-tools/commands/status.cjs +369 -243
  88. package/mcp-server/lib/context-spine.cjs +0 -1208
  89. package/mcp-server/lib/decision-dialogue.cjs +0 -1128
  90. package/mcp-server/lib/project-breadcrumb.cjs +0 -173
  91. package/mcp-server/lib/spec-learning.cjs +0 -284
  92. package/mcp-server/lib/workflow-state.cjs +0 -2965
  93. package/skills/ultra-think/references/decision-dialogue.md +0 -153
@@ -49,7 +49,7 @@ copying memory, code-graph payloads, or large source material into Ultra.
49
49
 
50
50
  ## Completion
51
51
 
52
- Update the affected baseline specification, record the report through `workflow.step`,
53
- include it in `baseline.record` evidence when material, and record unresolved work in
54
- the authoritative gap ledger. The final synthesis also binds the three specifications
55
- and research distillate. Do not create a condensed duplicate of the baseline.
52
+ Update the affected baseline specification, register the report through typed
53
+ `ultra.record`, reference it from the Research Stage Checkpoint, and record unresolved
54
+ work in the authoritative gap ledger. The final synthesis also binds the baseline
55
+ specifications and research distillate. Do not create a condensed duplicate.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.24.0] — 2026-07-30
11
+
12
+ ### Added
13
+
14
+ - Added normalized Decision Records, reversible Stage Checkpoints, bounded Context
15
+ Envelopes, and immutable Worker Packets as the shared evidence and handoff model
16
+ across Skills, Hooks, agents, SQLite, and tracked `.ultra` artifacts.
17
+ - Added a native Grok Build plugin so Claude Code, Codex, OpenCode, Kimi Code, and
18
+ Grok Build share the same eleven explicit workflows and seven-tool MCP kernel.
19
+ - Added schema 22 backup-first migration and real-history compatibility for v4.4,
20
+ v4.5, v0.22, and v0.23 state and team-ledger formats.
21
+ - Added packaged `better-sqlite3` provenance, platform and Node ABI verification,
22
+ and durable Doctor and archive workers for every supported host.
23
+
24
+ ### Changed
25
+
26
+ - Completed the MCP boundary reduction: Skills own adaptive semantic procedure;
27
+ MCP owns persistence, identity, transactions, leases, paths, recovery, and
28
+ irreversible safety; Hooks only observe or inject bounded context; agents consume
29
+ immutable Worker Packets without writing SQLite authority.
30
+ - Folded Plan artifact publication into the accepted Plan checkpoint so a later
31
+ export cannot invalidate its own authority.
32
+ - Replaced semantic supervisor failures with mutable diagnostics and repairable
33
+ drafts. Only corruption, unsafe paths, concurrency conflicts, permission failures,
34
+ and irreversible external effects remain hard blockers.
35
+ - Made `ultra.context`, `ultra.sync`, and `ultra.doctor` own their inspection and
36
+ repair preflight so an older valid ledger cannot block the tools required to
37
+ migrate it.
38
+ - Reduced packaged and documented MCP contracts to the exact seven public tools;
39
+ removed the retired fine-grained schemas, fixtures, and command bypasses.
40
+
41
+ ### Fixed
42
+
43
+ - Fixed accepted or stale workflow runs becoming permanently self-locked after an
44
+ artifact changed, and made reversible stages reopenable without rewriting
45
+ immutable accepted history.
46
+ - Fixed v0.23 team ledgers using `research_run_id` being rejected under the newer
47
+ `research_checkpoint_id` digest contract.
48
+ - Fixed native SQLite drivers and Doctor workers being absent or unresolved in
49
+ installed plugins.
50
+ - Fixed session acquisition, archive recovery, Context identity, and Worker Packet
51
+ cleanup paths leaving partial authority after failure.
52
+ - Fixed installed interaction guidance failing to render each host's native question
53
+ surface while keeping canonical Skills host-neutral.
54
+
55
+ ## [0.23.0] — 2026-07-30
56
+
57
+ ### Added
58
+
59
+ - Added a seven-tool public MCP kernel: `ultra.context`, `ultra.record`,
60
+ `ultra.checkpoint`, `ultra.sync`, `ultra.session`, `ultra.archive`, and
61
+ `ultra.doctor`.
62
+ - Added idempotent batched recording, content-addressed Context snapshots, and
63
+ semantic checkpoints that commit accepted workflow authority in one model
64
+ round trip.
65
+ - Added mutable diagnostic envelopes for rejected draft checkpoints and
66
+ archive preflights so the host model can correct or abandon the same draft.
67
+
68
+ ### Changed
69
+
70
+ - Moved workflow sequencing and semantic judgment back into the eleven public
71
+ Skills. MCP now owns persistence, schema, transaction, concurrency, path,
72
+ recovery, and irreversible-effect boundaries instead of directing the model.
73
+ - Reduced the unconditional `tools/list` surface from 60 fine-grained tools to
74
+ seven high-level tools. The 0.22 fine-grained contracts remain callable but
75
+ hidden for one compatibility release.
76
+ - Made draft Changes and nonterminal workflows reversible while keeping
77
+ accepted revisions immutable and replaceable through a new draft.
78
+ - Updated Claude Code, Codex, OpenCode, and Kimi assets to use the same narrow
79
+ capability graph while preserving each host's native question and bounded
80
+ worker surfaces.
81
+
82
+ ### Fixed
83
+
84
+ - Fixed Plan drafts becoming permanently self-locked when a task or exported
85
+ artifact changed after validation.
86
+ - Fixed semantic validation failures surfacing as MCP transport errors and
87
+ forcing models into repeated repair calls.
88
+ - Fixed duplicate Context compilation creating competing snapshots for the
89
+ same semantic inputs.
90
+ - Fixed `ultra.context` creating `.ultra` state merely by inspecting an
91
+ uninitialized project.
92
+
10
93
  ## [0.22.0] — 2026-07-30
11
94
 
12
95
  ### Added
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  **An adaptive delivery harness for AI coding agents.**
4
4
 
5
- Ultra Builder Pro helps Claude Code, Codex, OpenCode, and Kimi Code carry a
6
- software project from an unclear request to a verified, recoverable delivery.
5
+ Ultra Builder Pro helps Claude Code, Codex, OpenCode, Kimi Code, and Grok Build
6
+ carry a software project from an unclear request to a verified, recoverable delivery.
7
7
  It keeps the user and the agent aligned, preserves project authority across
8
8
  sessions, and prevents specifications from quietly drifting away from the code.
9
9
 
@@ -44,7 +44,7 @@ Ultra Builder Pro addresses those gaps with four ideas:
44
44
  and asks the user only for material intent, scope, risk, or authorization
45
45
  decisions—normally one dependent decision at a time.
46
46
  3. **Durable project authority.** `.ultra/.runtime/state.db` records checkout-local
47
- lifecycle, decisions, workflows, evidence digests, sessions, incidents, and
47
+ lifecycle facts, decisions, checkpoints, evidence digests, sessions, incidents, and
48
48
  recovery state across host sessions. Tracked semantic artifacts plus the
49
49
  MCP-published `.ultra/tasks/tasks.json` checkpoint carry reviewed project intent
50
50
  across Git checkouts without committing SQLite, leases, or telemetry.
@@ -65,13 +65,13 @@ flowchart TB
65
65
  U["User<br/>goals, acceptance, trade-offs, risk, and external authorization"]
66
66
 
67
67
  subgraph HOST["Supported coding host"]
68
- UI["Host-native interaction<br/>Claude Code / Codex / OpenCode / Kimi Code"]
68
+ UI["Host-native interaction<br/>Claude Code / Codex / OpenCode / Kimi Code / Grok Build"]
69
69
  MODEL["Host agent<br/>inspect, recommend, implement, test, and review"]
70
70
  ADAPTER["Host adapter<br/>native questions, commands, tools, and lifecycle wiring"]
71
71
  end
72
72
 
73
73
  SKILLS["Eleven explicit Ultra Skills<br/>init / research / think / change / plan / dev<br/>test / review / deliver / status / doctor"]
74
- MCP["Ultra MCP<br/>60 typed tools across nine families"]
74
+ MCP["Ultra MCP safety kernel<br/>exactly 7 public tools"]
75
75
  DB[(".ultra/.runtime/state.db<br/>SQLite lifecycle and index authority")]
76
76
  LEDGER[".ultra/tasks/tasks.json<br/>Git team checkpoint for portable baseline, Change, and task state"]
77
77
  VIEWS[".ultra/.runtime/projections<br/>checkout-local generated views"]
@@ -103,13 +103,41 @@ The responsibility split is deliberate:
103
103
  |---|---|
104
104
  | **User** | Product intent, semantic route selection, material scope and trade-offs, risk acceptance, destructive actions, publishing and deployment authorization |
105
105
  | **Host model** | Fact-finding, synthesis, research-coverage and route recommendations, reversible implementation decisions |
106
- | **Ultra MCP** | Checkout-local state, evidence references, digests, freshness, locks, valid transitions, hard recovery, and Git checkpoint publish/import |
106
+ | **Ultra MCP** | Structure validation, durable checkpoints, evidence references, digests, team sync, leases, archive transactions, and mechanical recovery; never semantic route selection |
107
107
  | **Host adapter** | Native Skill discovery, user questions, tool invocation, installation, and runtime wiring |
108
108
  | **Hooks** | Fast lifecycle observation, current breadcrumb injection, and protection of MCP-owned checkpoint and generated projection paths |
109
109
 
110
- The MCP does not replace the model's judgment. A hook does not decide product
111
- strategy. A prompt does not become durable authority merely because it appeared
112
- in a conversation.
110
+ The MCP does not replace the model's judgment or pre-authorize a semantic route. It
111
+ reports draft diagnostics and commits accepted checkpoints. A hook does not decide
112
+ product strategy. A prompt does not become durable authority merely because it
113
+ appeared in a conversation.
114
+
115
+ ### The seven-tool MCP kernel
116
+
117
+ The public model-facing surface is intentionally small:
118
+
119
+ | Tool | Responsibility |
120
+ |---|---|
121
+ | `ultra.context` | Read the complete current spine without side effects |
122
+ | `ultra.record` | Batch typed draft facts and events with idempotency |
123
+ | `ultra.checkpoint` | Attempt one semantic stage checkpoint; rejection leaves the draft editable |
124
+ | `ultra.sync` | Inspect, import, or publish the Git team checkpoint |
125
+ | `ultra.session` | Own the transactional execution lease |
126
+ | `ultra.archive` | Converge and archive through the recoverable filesystem/DB boundary |
127
+ | `ultra.doctor` | Inspect or repair mechanical health, backup first |
128
+
129
+ Retired fine-grained operation names are neither discoverable nor callable. Workflow
130
+ prose stays in Skills, model judgment stays with the host, and SQLite records what
131
+ happened rather than deciding what the model is allowed to think next.
132
+
133
+ The enforcement gradient is:
134
+
135
+ ```text
136
+ exploration and iteration: advisory
137
+ durable semantic checkpoint: validated and recoverable
138
+ corruption / unsafe path / real concurrency / permission: fail closed
139
+ irreversible external effect: explicit owner authority plus fail closed
140
+ ```
113
141
 
114
142
  ### How owner intent becomes durable authority
115
143
 
@@ -121,9 +149,9 @@ flowchart TD
121
149
  CLEAR -->|"Yes"| NORMALIZE["Normalize the accepted intent"]
122
150
  CLEAR -->|"No: a material choice remains"| ASK["Ask one dependent question through the host-native question tool"]
123
151
  ASK --> NORMALIZE
124
- NORMALIZE --> DECISION["Persist the normalized result through decision.*"]
125
- DECISION --> APPLY["Apply it through the owning MCP operation or digest-bound artifact"]
126
- APPLY --> AUTHORITY["Bind state, artifact digest, provenance, and downstream effects"]
152
+ NORMALIZE --> RECORD["Batch the normalized result through ultra.record"]
153
+ RECORD --> CHECKPOINT["Attempt the owning ultra.checkpoint when authority is ready"]
154
+ CHECKPOINT --> AUTHORITY["Bind state, artifact digest, provenance, and downstream effects"]
127
155
  AUTHORITY --> READBACK["Read back the authoritative result"]
128
156
  READBACK --> RESUME["Resume the exact workflow step and recommend the next explicit capability"]
129
157
  ```
@@ -136,8 +164,9 @@ and effects—not chain-of-thought, raw prompts, transcripts, or UI receipts.
136
164
 
137
165
  ## What you get
138
166
 
139
- - Native plugins for **Claude Code**, **OpenCode**, **Codex**, and **Kimi Code**.
140
- - One workflow vocabulary across all four hosts.
167
+ - Native plugins for **Claude Code**, **OpenCode**, **Codex**, **Kimi Code**, and
168
+ **Grok Build**.
169
+ - One workflow vocabulary across all five hosts.
141
170
  - Deterministic initialization for new, existing, monorepo, and older Ultra
142
171
  projects.
143
172
  - Evidence-backed greenfield research and brownfield adoption.
@@ -189,6 +218,7 @@ npx --yes ultra-builder-pro-cli@latest --claude --global
189
218
  npx --yes ultra-builder-pro-cli@latest --opencode --global
190
219
  npx --yes ultra-builder-pro-cli@latest --codex --global
191
220
  npx --yes ultra-builder-pro-cli@latest --kimi --global
221
+ npx --yes ultra-builder-pro-cli@latest --grok --global
192
222
  ```
193
223
 
194
224
  Use `--local` instead of `--global` to install into the current project's host
@@ -299,9 +329,9 @@ already resolves the route. The normalized accepted coverage is then stored in
299
329
  - `deferred` — record the consequence and accepted owner.
300
330
 
301
331
  The catalog is not a mandatory document set or questionnaire. Omitted areas
302
- create no workflow rows; an explicit exclusion is recorded only when retaining
303
- that rationale is useful. MCP validates state, evidence, and transitions; it
304
- does not store or prove the preceding UI interaction.
332
+ create no workflow rows; an explicit exclusion is recorded only when retaining
333
+ that rationale is useful. MCP validates accepted checkpoints and mechanical
334
+ integrity; it does not store or prove the preceding UI interaction.
305
335
 
306
336
  Older projection-only Ultra projects are preserved and routed through a
307
337
  backup-first migration or rebaseline. The first supported checkpoint publication
@@ -358,19 +388,19 @@ The next piece of daily work starts with a new `ultra-change`.
358
388
  | `ultra-test` | Run the risk-selected verification profile and persist the gate result |
359
389
  | `ultra-review` | Coordinate independent specification-fidelity and engineering review |
360
390
  | `ultra-deliver` | Reconcile specifications, close local authority, and archive the change |
361
- | `ultra-status` | Read the current breadcrumb, blockers, evidence, and allowed transitions |
391
+ | `ultra-status` | Read the current context, warnings, blockers, and evidence |
362
392
  | `ultra-doctor` | Diagnose installation or project-state faults and expose safe recovery |
363
393
 
364
- These eleven capabilities are the complete public Ultra command graph. Each capability
365
- returns current `allowed_transitions`; the host may recommend one, but another public
366
- capability starts only after an explicit user command or skill invocation.
394
+ These eleven capabilities are the complete public Ultra command graph. The host model
395
+ recommends the next capability from current context and owner intent; SQLite does not
396
+ encode the semantic route. Another public capability starts only after an explicit
397
+ user command or skill invocation.
367
398
 
368
399
  ### Command interaction graph
369
400
 
370
- Every solid handoff below means: the current capability returns
371
- `allowed_transitions`, the model recommends a route, and the owner explicitly
372
- invokes the next public capability. It does not mean that one public command
373
- silently launches another.
401
+ Every solid handoff below means: the current capability returns context and checkpoint
402
+ diagnostics, the model recommends a route, and the owner explicitly invokes the next
403
+ public capability. It does not mean that one public command silently launches another.
374
404
 
375
405
  ```mermaid
376
406
  flowchart TD
@@ -425,7 +455,7 @@ health without selecting product intent.
425
455
  ```text
426
456
  .ultra/
427
457
  .runtime/ # local mutable state; ignored by Git
428
- state.db # lifecycle, index, transition, and freshness authority
458
+ state.db # facts, indexes, checkpoints, leases, CAS, and recovery
429
459
  checkpoint.json # advisory recovery projection
430
460
  projections/ # generated local task and task-context views
431
461
  backups/ # verified migration and recovery snapshots
@@ -434,17 +464,18 @@ health without selecting product intent.
434
464
  worktrees/ # registered local Git worktrees
435
465
  telemetry/ # local operational telemetry
436
466
  specs/ # digest-bound product and architecture baseline
467
+ decisions/baseline/ # normalized accepted baseline decisions
437
468
  changes/
438
469
  active/<id>/ # all current Change semantics and evidence
439
470
  intent.md # accepted Change Contract
440
- findings.md # durable Change findings
471
+ decisions/ # normalized accepted Change decisions
441
472
  progress.md # generated human-readable projection
442
473
  research/ # Change-only findings and research reports
443
474
  delta/ # typed baseline overlay and semantic payloads
444
475
  documentation/ # documentation overlay and reconciliation evidence
445
476
  plan.json # machine-readable task topology
446
477
  plan.md # deterministic human plan projection
447
- contexts/ # immutable role/task context snapshots
478
+ contexts/ # immutable canonical Context Envelopes
448
479
  test/ # Change-scoped test reports
449
480
  review/ # Change-scoped review workers and summary
450
481
  delivery/ # Change-scoped delivery evidence
@@ -459,8 +490,8 @@ health without selecting product intent.
459
490
 
460
491
  Together, `.ultra/` is Ultra's project-local cross-session workflow memory. The
461
492
  host model writes semantic specifications and evidence through the active
462
- workflow. MCP records lifecycle state, references, digests, provenance, and
463
- accepted intent, then rejects stale or illegal transitions. The DB is the
493
+ capability. MCP records lifecycle state, references, digests, provenance, and
494
+ accepted intent, then validates durable checkpoints and mechanical integrity. The DB is the
464
495
  lifecycle and index authority for one checkout; registered digest-bound files carry
465
496
  the semantic or evidence bodies that the DB references. The Git checkpoint is a
466
497
  portable, digest-chained handoff of baseline, Change, and durable task records. It is
@@ -551,12 +582,14 @@ host's existing model session.
551
582
  - **Project state is unhealthy:** invoke `ultra-doctor` or run
552
583
  `ultra-tools system doctor`. Repairs and schema migrations are backup-first.
553
584
  - **The team checkpoint disagrees with local state:** run `ultra-status`, inspect the
554
- typed ledger condition, then use the recommended `task.ledger_import` or
555
- `task.ledger_publish` path. Never edit `.ultra/tasks/tasks.json` by hand.
585
+ typed ledger condition, then use `ultra.sync` to import or publish after reviewing
586
+ any real conflict. Never edit `.ultra/tasks/tasks.json` by hand.
556
587
  - **A generated view disagrees with MCP:** trust `.ultra/.runtime/state.db`; never edit
557
588
  `.ultra/.runtime/projections/` by hand.
558
- - **A workflow appears blocked:** use `ultra-status` to read the exact current
559
- workflow, blocker, owner decision, and mechanically valid transitions.
589
+ - **A draft checkpoint is rejected:** use `ultra-status` to read the exact warnings
590
+ and blockers, fix the same mutable draft, and retry. If the attempt is no longer
591
+ relevant, leave it as history and open a new draft revision; no hidden workflow
592
+ state must be cancelled first.
560
593
  - **Kimi reports a native-module ABI error:** ensure an external Node.js 22+
561
594
  executable is available on `PATH`; the generated Kimi MCP launcher uses
562
595
  `env node`.
@@ -586,7 +619,7 @@ and `test:rest`.
586
619
  |---|---|
587
620
  | [Architecture](./docs/ARCHITECTURE.md) | Components, authority boundaries, and live integration paths |
588
621
  | [Workflow Lifecycle](./docs/WORKFLOW-LIFECYCLE.md) | Command ownership, transitions, invalidation, recovery, and convergence |
589
- | [Runtime Compatibility Matrix](./docs/RUNTIME-COMPAT-MATRIX.md) | Claude Code, OpenCode, Codex, and Kimi presentation details |
622
+ | [Runtime Compatibility Matrix](./docs/RUNTIME-COMPAT-MATRIX.md) | Claude Code, OpenCode, Codex, Kimi Code, and Grok Build presentation details |
590
623
  | [Legacy CLI Crosswalk](./docs/LEGACY-CLI-CROSSWALK.md) | What was preserved, strengthened, or replaced from the original Ultra Builder Pro |
591
624
  | [Agent Context](./docs/AGENT-CONTEXT.md) | Context Manifest and host-agent execution contract |
592
625
  | [Plugin Isolation Contract](./docs/PLUGIN-ISOLATION-CONTRACT.md) | Plugin ownership, explicit activation, idle behavior, and user-instruction isolation |
@@ -30,44 +30,6 @@ const {
30
30
 
31
31
  const PLUGIN_NAME = 'ultra-builder-pro';
32
32
  const MANAGED_MARKER = 'Managed by Ultra Builder Pro Codex adapter.';
33
- const CODEX_NATIVE_MCP_REPLACEMENTS = Object.freeze({
34
- 'review.run': {
35
- surface: 'native_custom_agents',
36
- replacement: '$ultra-builder-pro:ultra-review with the installed review-* agents',
37
- },
38
- 'review.verdict': {
39
- surface: 'native_custom_agents',
40
- replacement: 'review-coordinator synthesis using the Ultra unified review artifact',
41
- },
42
- 'impact.radius': {
43
- surface: 'codex_code_discovery',
44
- replacement: 'indexed code graph tools when current, otherwise targeted repository reads',
45
- },
46
- 'impact.changes': {
47
- surface: 'codex_code_discovery',
48
- replacement: 'git diff plus indexed code graph tools when current',
49
- },
50
- 'impact.dependents': {
51
- surface: 'codex_code_discovery',
52
- replacement: 'indexed caller/dependency tracing when current, otherwise targeted repository search',
53
- },
54
- 'skill.resolve': {
55
- surface: 'plugin_skill_discovery',
56
- replacement: 'Codex plugin skill discovery with explicit $ultra-builder-pro:<skill> invocation',
57
- },
58
- 'skill.manifest': {
59
- surface: 'plugin_skill_discovery',
60
- replacement: 'the installed plugin skill SKILL.md and agents/openai.yaml contract',
61
- },
62
- 'ask.question': {
63
- surface: 'request_user_input',
64
- replacement: 'use request_user_input when available, otherwise ask one concise direct question',
65
- },
66
- 'ask.menu': {
67
- surface: 'request_user_input',
68
- replacement: 'use request_user_input when available, otherwise present one concise direct choice',
69
- },
70
- });
71
33
  const COMMAND_NAMES = Object.freeze(CORE_PUBLIC_SKILLS.filter((name) => name !== 'ultra-review'));
72
34
  const SKILL_REFERENCE_NAMES = Object.freeze([
73
35
  ...COMMAND_NAMES,
@@ -77,6 +39,11 @@ const SKILL_REFERENCE_NAMES = Object.freeze([
77
39
  ]);
78
40
  const CODEX_PRIMARY_SKILLS = new Set([...COMMAND_NAMES, 'ultra-review']);
79
41
  const TEXT_EXTENSIONS = new Set(['.md', '.json', '.py', '.sh', '.txt', '.yaml', '.yml']);
42
+ const NATIVE_PACKAGES = Object.freeze([
43
+ 'better-sqlite3',
44
+ 'bindings',
45
+ 'file-uri-to-path',
46
+ ]);
80
47
 
81
48
  function titleCase(name) {
82
49
  const special = { 'cc-collab': 'Claude Code Collaboration' };
@@ -96,7 +63,7 @@ function adaptCodexPrimaryText(input, skillName) {
96
63
  let text = String(input);
97
64
  if (skillName === 'ultra-review') {
98
65
  text = text.replace(
99
- /the current host's native bounded-worker\s+mechanism/g,
66
+ /(?:the current host's native|the host-native) bounded-worker\s+mechanism/g,
100
67
  'native Codex custom agents installed for the selected review workers',
101
68
  );
102
69
  }
@@ -273,7 +240,7 @@ function buildHooksManifest(pluginRoot) {
273
240
  };
274
241
  }
275
242
 
276
- function copyHooks(repoRoot, pluginRoot) {
243
+ function copyHooks(repoRoot, pluginRoot, publishedRoot = pluginRoot) {
277
244
  const sourceRoot = path.join(repoRoot, 'hooks');
278
245
  const targetRoot = path.join(pluginRoot, 'hooks');
279
246
  ensureDir(targetRoot);
@@ -287,7 +254,7 @@ function copyHooks(repoRoot, pluginRoot) {
287
254
  );
288
255
  writeAtomic(
289
256
  path.join(targetRoot, 'hooks.json'),
290
- JSON.stringify(buildHooksManifest(pluginRoot), null, 2) + '\n',
257
+ JSON.stringify(buildHooksManifest(publishedRoot), null, 2) + '\n',
291
258
  );
292
259
  }
293
260
 
@@ -322,6 +289,8 @@ function buildMcpRuntime(repoRoot, pluginRoot, { runtime = 'codex' } = {}) {
322
289
  buildRoot,
323
290
  '--no-cache',
324
291
  '--quiet',
292
+ '-e',
293
+ 'better-sqlite3',
325
294
  ], {
326
295
  cwd: repoRoot,
327
296
  encoding: 'utf8',
@@ -347,6 +316,8 @@ function buildMcpRuntime(repoRoot, pluginRoot, { runtime = 'codex' } = {}) {
347
316
  cliBuildRoot,
348
317
  '--no-cache',
349
318
  '--quiet',
319
+ '-e',
320
+ 'better-sqlite3',
350
321
  ], {
351
322
  cwd: repoRoot,
352
323
  encoding: 'utf8',
@@ -386,6 +357,8 @@ function buildMcpRuntime(repoRoot, pluginRoot, { runtime = 'codex' } = {}) {
386
357
  workerBuildRoot,
387
358
  '--no-cache',
388
359
  '--quiet',
360
+ '-e',
361
+ 'better-sqlite3',
389
362
  ], {
390
363
  cwd: repoRoot,
391
364
  encoding: 'utf8',
@@ -416,6 +389,52 @@ function buildMcpRuntime(repoRoot, pluginRoot, { runtime = 'codex' } = {}) {
416
389
  fs.copyFileSync(sourceFile, path.join(runtimeRoot, supportFile));
417
390
  }
418
391
 
392
+ const nodeModulesRoot = path.join(runtimeRoot, 'node_modules');
393
+ for (const packageName of NATIVE_PACKAGES) {
394
+ let packageFile;
395
+ try {
396
+ packageFile = require.resolve(`${packageName}/package.json`, { paths: [repoRoot] });
397
+ } catch (error) {
398
+ throw new Error(`Ultra native runtime dependency ${packageName} is unavailable: ${error.message}`);
399
+ }
400
+ copyTree(
401
+ path.dirname(packageFile),
402
+ path.join(nodeModulesRoot, packageName),
403
+ );
404
+ }
405
+ const nativeRelative = path.join(
406
+ 'node_modules',
407
+ 'better-sqlite3',
408
+ 'build',
409
+ 'Release',
410
+ 'better_sqlite3.node',
411
+ );
412
+ const nativeFile = path.join(runtimeRoot, nativeRelative);
413
+ if (!fs.existsSync(nativeFile) || !fs.statSync(nativeFile).isFile()) {
414
+ throw new Error(`Ultra native SQLite driver is missing after staging: ${nativeFile}`);
415
+ }
416
+ const betterSqlitePackage = JSON.parse(fs.readFileSync(
417
+ path.join(nodeModulesRoot, 'better-sqlite3', 'package.json'),
418
+ 'utf8',
419
+ ));
420
+ writeAtomic(path.join(runtimeRoot, 'native-runtime.json'), JSON.stringify({
421
+ schema_version: 1,
422
+ platform: process.platform,
423
+ arch: process.arch,
424
+ modules: process.versions.modules,
425
+ node_version: process.versions.node,
426
+ package: {
427
+ name: 'better-sqlite3',
428
+ version: betterSqlitePackage.version,
429
+ },
430
+ native_module: nativeRelative.split(path.sep).join('/'),
431
+ native_sha256: crypto.createHash('sha256').update(fs.readFileSync(nativeFile)).digest('hex'),
432
+ }, null, 2) + '\n');
433
+ fs.copyFileSync(
434
+ path.join(repoRoot, 'adapters', '_shared', 'runtime-native.cjs'),
435
+ path.join(runtimeRoot, 'runtime-native.cjs'),
436
+ );
437
+
419
438
  const runtimeBootstrap = runtime === 'kimi' ? `
420
439
  const fs = require('node:fs');
421
440
  const pluginRoot = path.resolve(__dirname, '..');
@@ -443,10 +462,12 @@ if (!process.env.UBP_ROOT_DIR) {
443
462
  const launcher = `'use strict';
444
463
 
445
464
  const path = require('node:path');
465
+ const { inspectRuntimeNative } = require('./runtime-native.cjs');
446
466
 
447
467
  process.env.UBP_RUNTIME_ROOT = path.resolve(__dirname, '..');
448
468
  ${runtimeBootstrap}
449
469
 
470
+ inspectRuntimeNative(__dirname);
450
471
  const { main } = require('./index.cjs');
451
472
 
452
473
  main().catch((error) => {
@@ -456,8 +477,8 @@ main().catch((error) => {
456
477
  `;
457
478
  writeAtomic(path.join(runtimeRoot, 'launch.cjs'), launcher);
458
479
  fs.copyFileSync(
459
- path.join(repoRoot, 'mcp-server', 'breadcrumb.cjs'),
460
- path.join(runtimeRoot, 'breadcrumb.cjs'),
480
+ path.join(repoRoot, 'mcp-server', 'hook-context.cjs'),
481
+ path.join(runtimeRoot, 'hook-context.cjs'),
461
482
  );
462
483
  fs.copyFileSync(
463
484
  path.join(repoRoot, 'mcp-server', 'hook-event.cjs'),
@@ -491,14 +512,6 @@ main().catch((error) => {
491
512
  path.join(specRoot, 'interaction-contract.json'),
492
513
  JSON.stringify(interactionContract(runtime), null, 2) + '\n',
493
514
  );
494
- if (runtime === 'codex') {
495
- fs.copyFileSync(sourceToolsFile, path.join(specRoot, 'upstream-mcp-tools.yaml'));
496
- writeAtomic(path.join(specRoot, 'codex-capability-map.json'), JSON.stringify({
497
- runtime: 'codex',
498
- live_mcp_tools: REGISTERED_TOOLS,
499
- codex_native_replacements: CODEX_NATIVE_MCP_REPLACEMENTS,
500
- }, null, 2) + '\n');
501
- }
502
515
  const sourceSchema = path.join(repoRoot, 'spec', 'schemas', 'state-db.sql');
503
516
  const targetSchema = path.join(specRoot, 'schemas', 'state-db.sql');
504
517
  ensureDir(path.dirname(targetSchema));
@@ -516,9 +529,49 @@ main().catch((error) => {
516
529
  launcher: path.join(runtimeRoot, 'launch.cjs'),
517
530
  bundle: path.join(runtimeRoot, 'index.cjs'),
518
531
  ultraTools: path.join(runtimeRoot, 'ultra-tools.cjs'),
532
+ nativeManifest: path.join(runtimeRoot, 'native-runtime.json'),
519
533
  };
520
534
  }
521
535
 
536
+ function mcpCommand(launcher) {
537
+ if (process.platform === 'win32') {
538
+ return { command: 'node.exe', args: [launcher] };
539
+ }
540
+ return { command: '/usr/bin/env', args: ['node', launcher] };
541
+ }
542
+
543
+ function inspectInstalledRuntime(runtimeRoot) {
544
+ const report = {
545
+ status: 'healthy',
546
+ checks: {},
547
+ issues: [],
548
+ };
549
+ try {
550
+ const detail = require(path.join(runtimeRoot, 'runtime-native.cjs'))
551
+ .inspectRuntimeNative(runtimeRoot);
552
+ report.checks.native_runtime = { status: 'pass', ...detail };
553
+ } catch (error) {
554
+ report.status = 'degraded';
555
+ report.checks.native_runtime = { status: 'fail' };
556
+ report.issues.push({
557
+ code: error.code || 'RUNTIME_NATIVE_MISSING',
558
+ message: error.message,
559
+ ...(error.details || {}),
560
+ });
561
+ }
562
+ return report;
563
+ }
564
+
565
+ function applyNativeDoctor(report, runtimeRoot) {
566
+ const native = inspectInstalledRuntime(runtimeRoot);
567
+ report.checks = { ...(report.checks || {}), ...native.checks };
568
+ report.issues = [...(report.issues || []), ...native.issues];
569
+ if (report.status !== 'missing') {
570
+ report.status = report.issues.length === 0 ? 'healthy' : 'degraded';
571
+ }
572
+ return report;
573
+ }
574
+
522
575
  function pluginContentHash(pluginRoot, baseVersion) {
523
576
  const hash = crypto.createHash('sha256');
524
577
  hash.update(baseVersion);
@@ -530,13 +583,14 @@ function pluginContentHash(pluginRoot, baseVersion) {
530
583
  return hash.digest('hex').slice(0, 12);
531
584
  }
532
585
 
533
- function buildPlugin({ repoRoot, pluginRoot }) {
586
+ function buildPlugin({ repoRoot, pluginRoot, publishedRoot = pluginRoot }) {
534
587
  if (fs.existsSync(pluginRoot)) {
535
588
  const marker = path.join(pluginRoot, '.ubp-managed');
536
- if (!fs.existsSync(marker)) {
589
+ const entries = fs.readdirSync(pluginRoot);
590
+ if (entries.length > 0 && !fs.existsSync(marker)) {
537
591
  throw new Error(`refusing to replace unmanaged plugin directory: ${pluginRoot}`);
538
592
  }
539
- removeTree(pluginRoot);
593
+ if (entries.length > 0) removeTree(pluginRoot);
540
594
  }
541
595
  ensureDir(pluginRoot);
542
596
 
@@ -550,14 +604,18 @@ function buildPlugin({ repoRoot, pluginRoot }) {
550
604
  installedSkills.push(name);
551
605
  }
552
606
 
553
- copyHooks(repoRoot, pluginRoot);
607
+ copyHooks(repoRoot, pluginRoot, publishedRoot);
554
608
  const mcpRuntime = buildMcpRuntime(repoRoot, pluginRoot);
609
+ const command = mcpCommand(path.join(
610
+ publishedRoot,
611
+ path.relative(pluginRoot, mcpRuntime.launcher),
612
+ ));
555
613
  writeAtomic(path.join(pluginRoot, '.mcp.json'), JSON.stringify({
556
614
  mcpServers: {
557
615
  [PLUGIN_NAME]: {
558
616
  type: 'stdio',
559
- command: process.execPath,
560
- args: [mcpRuntime.launcher],
617
+ command: command.command,
618
+ args: command.args,
561
619
  },
562
620
  },
563
621
  }, null, 2) + '\n');
@@ -571,7 +629,7 @@ function buildPlugin({ repoRoot, pluginRoot }) {
571
629
  const manifest = {
572
630
  name: PLUGIN_NAME,
573
631
  version,
574
- description: 'Codex-native Ultra Builder Pro workflows, agents, hooks, and MCP task state.',
632
+ description: 'Codex-native Ultra Builder Pro workflows with a persistent safety kernel.',
575
633
  author: { name: typeof pkg.author === 'string' ? pkg.author : 'Ultra Builder Pro contributors' },
576
634
  homepage: pkg.homepage,
577
635
  repository: 'https://github.com/rocky2431/ultra-builder-pro-cli',
@@ -582,7 +640,7 @@ function buildPlugin({ repoRoot, pluginRoot }) {
582
640
  interface: {
583
641
  displayName: 'Ultra Builder Pro',
584
642
  shortDescription: 'Codex-native engineering workflows and verification gates.',
585
- longDescription: 'Complete Codex adaptation of Ultra Builder Pro skills, command workflows, custom agents, lifecycle hooks, and project-local MCP state.',
643
+ longDescription: 'Complete Codex adaptation of Ultra Builder Pro skills, command workflows, custom agents, lifecycle hooks, and a project-local persistence and safety kernel.',
586
644
  developerName: typeof pkg.author === 'string' ? pkg.author : 'Ultra Builder Pro contributors',
587
645
  category: 'Developer Tools',
588
646
  capabilities: ['Interactive', 'Write'],
@@ -597,7 +655,7 @@ function buildPlugin({ repoRoot, pluginRoot }) {
597
655
  };
598
656
  writeAtomic(path.join(pluginRoot, '.codex-plugin', 'plugin.json'), JSON.stringify(manifest, null, 2) + '\n');
599
657
  writeAtomic(path.join(pluginRoot, '.ubp-managed'), JSON.stringify({ source: 'ubp', adapter: 'codex', version }, null, 2) + '\n');
600
- return { root: pluginRoot, version, skills: installedSkills.sort() };
658
+ return { root: publishedRoot, version, skills: installedSkills.sort() };
601
659
  }
602
660
 
603
661
  function tomlMultiline(value) {
@@ -658,6 +716,9 @@ module.exports = {
658
716
  buildCommandMap,
659
717
  buildHooksManifest,
660
718
  buildMcpRuntime,
719
+ inspectInstalledRuntime,
720
+ applyNativeDoctor,
721
+ mcpCommand,
661
722
  buildPlugin,
662
723
  buildAgentToml,
663
724
  installAgents,