ultra-builder-pro-cli 0.23.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 (91) hide show
  1. package/.ultra-template/docs/research/README.md +4 -4
  2. package/CHANGELOG.md +45 -0
  3. package/README.md +21 -18
  4. package/adapters/_shared/codex-assets.cjs +121 -65
  5. package/adapters/_shared/interaction-contract.cjs +7 -1
  6. package/adapters/_shared/provenance.cjs +7 -2
  7. package/adapters/_shared/runtime-assets.cjs +3 -2
  8. package/adapters/_shared/runtime-native.cjs +132 -0
  9. package/adapters/claude.js +60 -30
  10. package/adapters/codex.js +178 -81
  11. package/adapters/grok.js +372 -0
  12. package/adapters/kimi.js +7 -3
  13. package/adapters/opencode.js +210 -32
  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 -229
  27. package/docs/ARCHITECTURE.md +203 -494
  28. package/docs/ARTIFACT-AUTHORITY.md +26 -22
  29. package/docs/PLUGIN-ISOLATION-CONTRACT.md +12 -9
  30. package/docs/ROADMAP.md +85 -110
  31. package/docs/RUNTIME-COMPAT-MATRIX.md +139 -175
  32. package/docs/SKILL-AUTHORING.md +3 -3
  33. package/docs/STATE-DB-ACCESS-POLICY.md +13 -8
  34. package/docs/WORKFLOW-LIFECYCLE.md +174 -448
  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/baseline-workflow.cjs +36 -38
  47. package/mcp-server/lib/canonical-json.cjs +19 -0
  48. package/mcp-server/lib/change-workflow.cjs +596 -44
  49. package/mcp-server/lib/context-envelope.cjs +508 -0
  50. package/mcp-server/lib/decision-records.cjs +337 -0
  51. package/mcp-server/lib/doctor.cjs +91 -33
  52. package/mcp-server/lib/init-project.cjs +78 -39
  53. package/mcp-server/lib/managed-file-write.cjs +116 -0
  54. package/mcp-server/lib/plan-checkpoint.cjs +177 -0
  55. package/mcp-server/lib/project-context.cjs +178 -0
  56. package/mcp-server/lib/stage-checkpoints.cjs +309 -0
  57. package/mcp-server/lib/state-db.cjs +155 -24
  58. package/mcp-server/lib/task-ledger.cjs +522 -13
  59. package/mcp-server/lib/ultra-facade.cjs +630 -442
  60. package/mcp-server/lib/worker-packet.cjs +358 -0
  61. package/mcp-server/server.cjs +200 -1103
  62. package/orchestrator/daemon.cjs +27 -9
  63. package/orchestrator/parallel-orchestrator.cjs +111 -76
  64. package/orchestrator/session-runner.cjs +135 -34
  65. package/package.json +10 -3
  66. package/skills/ultra-change/SKILL.md +9 -8
  67. package/skills/ultra-deliver/SKILL.md +3 -3
  68. package/skills/ultra-dev/SKILL.md +18 -11
  69. package/skills/ultra-doctor/SKILL.md +2 -2
  70. package/skills/ultra-init/SKILL.md +6 -5
  71. package/skills/ultra-init/references/brownfield-adoption.md +11 -8
  72. package/skills/ultra-plan/SKILL.md +10 -8
  73. package/skills/ultra-research/SKILL.md +12 -7
  74. package/skills/ultra-review/SKILL.md +9 -6
  75. package/skills/ultra-review/references/unified-schema.md +2 -0
  76. package/skills/ultra-review/scripts/review_wait.py +8 -0
  77. package/skills/ultra-status/SKILL.md +2 -2
  78. package/skills/ultra-test/SKILL.md +4 -2
  79. package/skills/ultra-think/SKILL.md +7 -7
  80. package/skills/ultra-think/references/interaction-boundary.md +56 -0
  81. package/spec/cli-protocol.md +80 -199
  82. package/spec/mcp-tools.yaml +37 -2804
  83. package/spec/schemas/state-db.sql +107 -4
  84. package/spec/schemas/{task-ledger.v1.schema.json → task-ledger.v2.schema.json} +70 -6
  85. package/ultra-tools/commands/status.cjs +369 -243
  86. package/mcp-server/lib/context-spine.cjs +0 -1208
  87. package/mcp-server/lib/decision-dialogue.cjs +0 -1128
  88. package/mcp-server/lib/project-breadcrumb.cjs +0 -173
  89. package/mcp-server/lib/spec-learning.cjs +0 -284
  90. package/mcp-server/lib/workflow-state.cjs +0 -3129
  91. package/skills/ultra-think/references/decision-dialogue.md +0 -155
@@ -1,221 +1,102 @@
1
1
  # `ultra-tools` CLI protocol
2
2
 
3
- `ultra-tools` is the maintenance CLI around the live MCP runtime. The mapping
4
- registry below reserves stable command names for MCP tools;
5
- it does not mean every mapping is executable. Task lifecycle workflows must use
6
- the live MCP server and fail closed when it is unavailable.
3
+ `ultra-tools` is the maintenance and degraded-mode client for the same seven-tool
4
+ kernel exposed through MCP. It does not publish the retired lifecycle families as
5
+ model-facing tools and it does not contain a second semantic workflow engine.
7
6
 
8
7
  Authority boundary: [`docs/DECISIONS.md`](../docs/DECISIONS.md).
9
8
 
10
- ## 1. Invocation
9
+ ## Invocation
11
10
 
12
- ```
13
- ultra-tools <family> <verb> [--flag value] [positional ...]
11
+ ```text
12
+ ultra-tools ultra <verb> [--json '<object>']
14
13
  ```
15
14
 
16
- - `family` and `verb` together correspond to a `tool.name` in
17
- `spec/mcp-tools.yaml` (e.g. `task create`, `session admission`).
18
- - Flags map 1-to-1 to the `input_schema.properties` of the tool.
19
- - Positional args are reserved for the **id-like primary key** of the tool,
20
- if the tool has one (`task get <id>`, `session get <sid>`). All other
21
- fields must be flags so machine callers do not depend on argument order.
22
- - Boolean flags: `--takeover` for true; `--no-takeover` for false. Default
23
- is whatever the schema declares.
24
- - JSON values: pass with `--json '<inline json>'` or `--json-file <path>`
25
- when an input field is itself an object/array.
15
+ The supported verbs map exactly to the public MCP contract. JSON input uses the
16
+ corresponding `input_schema` in `spec/mcp-tools.yaml`. Large inputs may use
17
+ `--json-file <path>`.
26
18
 
27
- ## 2. Output
19
+ Maintenance-only commands such as installation diagnostics, explicit backup
20
+ restore, schema migration, and runtime inspection remain available under their
21
+ documented non-MCP command groups. They are operator surfaces, not hidden model
22
+ tools.
28
23
 
29
- The CLI may print human-readable lines to stdout while it runs. The **last
30
- line of stdout MUST be a single JSON object** matching the tool's
31
- `output_schema` on success, or an error envelope on failure:
24
+ ## Output
32
25
 
33
- ```json
34
- // success
35
- { "ok": true, "data": { ... output_schema ... } }
36
- ```
26
+ The final stdout line is always one JSON envelope:
37
27
 
38
28
  ```json
39
- // failure
40
- { "ok": false, "error": { "code": "<ERROR_CODE>", "message": "...", "retriable": false } }
29
+ { "ok": true, "data": {} }
41
30
  ```
42
31
 
43
- `error.code` MUST be one of the `errors[].code` values declared for that
44
- tool in `spec/mcp-tools.yaml`. Hooks parse this last line; any extra noise
45
- must come **before** it.
46
-
47
- Streaming subcommands (e.g. `task subscribe`) emit one JSON object per
48
- line during the stream, and finish with the standard envelope on stdout's
49
- last line.
50
-
51
- ## 3. Exit codes
52
-
53
- | Code | Meaning |
54
- |-----:|---------------------------------------------------|
55
- | `0` | success — `data` envelope is on stdout |
56
- | `1` | user error (bad flags, missing required input) |
57
- | `2` | system error (DB unavailable, IO failure) |
58
- | `3` | lease conflict — see `error.code = ADMISSION_DENIED` (D33) |
59
- | `4` | schema mismatch (input or output failed validation) |
60
- | `5` | timeout — operation exceeded its budget |
61
- | `124`| reserved for SIGTERM / killed by orchestrator |
62
-
63
- Exit code is **the** ground truth for hooks; the JSON envelope is
64
- informational. Never rely on stderr for status.
65
-
66
- ## 4. Stdin / stdout / stderr discipline
67
-
68
- - **stdin**: closed by default. Tools that accept large input
69
- (`task parse-prd`) read from `--prd-file <path>` rather than stdin to
70
- keep streaming pipelines deterministic.
71
- - **stdout**: human-readable lines + the trailing JSON envelope.
72
- - **stderr**: log lines only (structured JSON; `level / message / context`).
73
- Never carry success data on stderr.
74
-
75
- ## 5. Tool ↔ CLI mapping
76
-
77
- The compatibility mapping below is generated from `spec/mcp-tools.yaml` by
78
- `spec/scripts/check-cli-mapping.cjs` and asserted at gate time. This table
79
- is a naming contract, not an implementation inventory; do not advertise a row
80
- as a fallback unless `ultra-tools <family> --help` lists it.
81
-
82
- | MCP tool | CLI subcommand | Phase | Writer |
83
- |---------------------------|-----------------------------|------:|---------|
84
- | `ultra.context` | `ultra context` | 23 | mcp |
85
- | `ultra.record` | `ultra record` | 23 | mcp |
86
- | `ultra.checkpoint` | `ultra checkpoint` | 23 | mcp |
87
- | `ultra.sync` | `ultra sync` | 23 | mcp |
88
- | `ultra.session` | `ultra session` | 23 | mcp |
89
- | `ultra.archive` | `ultra archive` | 23 | mcp |
90
- | `ultra.doctor` | `ultra doctor` | 23 | mcp |
91
- | `task.create` | `task create` | 2 | mcp |
92
- | `task.update` | `task update` | 2 | mcp |
93
- | `task.list` | `task list` | 2 | any |
94
- | `task.get` | `task get` | 2 | any |
95
- | `task.delete` | `task delete` | 2 | mcp |
96
- | `task.switch_tag` | `task switch-tag` | 7.2 | mcp |
97
- | `task.init_project` | `task init-project` | 3 | mcp |
98
- | `task.expand` | `task expand` | 8a | mcp |
99
- | `task.parse_prd` | `task parse-prd` | 8a | mcp |
100
- | `task.dependency_topo` | `task topo` | 8a | mcp |
101
- | `task.ledger_get` | `task ledger-get` | 21 | any |
102
- | `task.ledger_publish` | `task ledger-publish` | 21 | mcp |
103
- | `task.ledger_import` | `task ledger-import` | 21 | mcp |
104
- | `task.append_event` | `task append-event` | 2 | any (allowlisted observations only) |
105
- | `task.subscribe_events` | `task subscribe` | 2 | any |
106
- | `session.spawn` | `session spawn` | 4.5 | mcp |
107
- | `session.close` | `session close` | 4.5 | mcp |
108
- | `session.get` | `session get` | 4.5 | any |
109
- | `session.list` | `session list` | 4.5 | any |
110
- | `session.admission_check` | `session admission` | 4.5 | any |
111
- | `session.heartbeat` | `session heartbeat` | 4.5 | mcp |
112
- | `session.subscribe_events`| `session subscribe` | 4.5 | any |
113
- | `baseline.start` | `baseline start` | 11 | mcp |
114
- | `baseline.record` | `baseline record` | 11 | mcp |
115
- | `baseline.get` | `baseline get` | 11 | any |
116
- | `baseline.converge` | `baseline converge` | 11 | mcp |
117
- | `change.create` | `change create` | 9 | mcp |
118
- | `change.update` | `change update` | 9 | mcp |
119
- | `change.delta` | `change delta` | 21 | mcp |
120
- | `change.documentation_reconcile` | `change documentation-reconcile` | 21 | mcp |
121
- | `change.get` | `change get` | 9 | any |
122
- | `change.list` | `change list` | 9 | any |
123
- | `change.context` | `change context` | 9 | mcp |
124
- | `change.breadcrumb` | `change breadcrumb` | 10 | any |
125
- | `change.learning_propose` | `change learning-propose` | 10 | mcp |
126
- | `change.learning_resolve` | `change learning-resolve` | 10 | mcp |
127
- | `change.converge` | `change converge` | 9 | mcp |
128
- | `change.archive` | `change archive` | 9 | mcp |
129
- | `decision.thread_start` | `decision thread-start` | 16 | mcp |
130
- | `decision.get` | `decision get` | 16 | any |
131
- | `decision.list` | `decision list` | 16 | any |
132
- | `decision.open` | `decision open` | 16 | mcp |
133
- | `decision.resolve` | `decision resolve` | 16 | mcp |
134
- | `decision.delegate` | `decision delegate` | 16 | mcp |
135
- | `decision.defer` | `decision defer` | 16 | mcp |
136
- | `decision.supersede` | `decision supersede` | 16 | mcp |
137
- | `decision.complete` | `decision complete` | 19 | mcp |
138
- | `decision.checkpoint` | `decision checkpoint` | 16 | mcp |
139
- | `workflow.start` | `workflow start` | 13 | mcp |
140
- | `workflow.get` | `workflow get` | 13 | any |
141
- | `workflow.list` | `workflow list` | 13 | any |
142
- | `workflow.step` | `workflow step` | 13 | mcp |
143
- | `workflow.revise` | `workflow revise` | 21 | mcp |
144
- | `workflow.supersede` | `workflow supersede` | 21 | mcp |
145
- | `workflow.complete` | `workflow complete` | 13 | mcp |
146
- | `artifact.record` | `artifact record` | 20 | mcp |
147
- | `artifact.get` | `artifact get` | 20 | any |
148
- | `system.doctor` | `system doctor` | 9 | mcp |
149
- | `plan.export` | `plan export` | 8a | mcp |
150
- | `plan.get` | `plan get` | 8a | any |
151
-
152
- The seven `ultra.*` rows are the public model-facing MCP surface. The remaining
153
- rows are one-release compatibility operations and CLI naming reservations; they
154
- are callable by an already-running 0.22 session but are not returned by
155
- `tools/list`.
156
-
157
- Current executable maintenance surfaces are `task init-project`,
158
- `session close|get|list|admission|heartbeat|subscribe|reap`, `status`, `db`,
159
- `migrate`, `system doctor|restore|rebaseline`, and `legacy-memory`. In particular, `task create|update|list|get`
160
- and all `change`, `decision`, and `artifact` lifecycle verbs are not CLI fallbacks. Their state must use
161
- the live MCP server; `system doctor` may additionally be exposed by the
162
- maintenance CLI because it is the recovery path when MCP startup is degraded.
163
- `task init-project --resume` preserves existing `.ultra` files and installs only
164
- missing current scaffold assets. Projection-only state uses the supported
165
- `migrate --from=4.4 --to=4.5` or the current supported state-schema transition before resume.
166
- `session close` preserves the worktree by default. `--remove-worktree` delegates to
167
- the same Git ancestry and dirty-state verifier as MCP and fails with
168
- `WORKTREE_NOT_INTEGRATED` instead of deleting uncommitted or unintegrated work.
169
- `system doctor --repair` applies supported schema upgrades with a pre-migration
170
- backup before mechanical recovery.
171
- `system restore` requires the exact `REPLACE_CORRUPT_ULTRA_STATE` confirmation and a
172
- verified database inside `.ultra/.runtime/backups`; it quarantines the corrupt state before
173
- atomic replacement. `system rebaseline` requires the exact
174
- `REBASELINE_CORRUPT_ULTRA_STATE` confirmation and preserves corrupt state plus the
175
- legacy task projection before starting a new brownfield adoption.
176
- The full access policy lives in
177
- `docs/STATE-DB-ACCESS-POLICY.md` (Phase 2.2 / R25).
178
-
179
- ## 6. Versioning
180
-
181
- The CLI follows the `version` field of `spec/mcp-tools.yaml`. Adding a new
182
- flag is a minor bump; renaming or removing a flag, or changing exit-code
183
- semantics, is a major bump. Major bumps require an entry in
184
- [`docs/DECISIONS.md`](../docs/DECISIONS.md) and the changelog.
185
-
186
- ## 7. `ubp-orchestrator`
187
-
188
- `ubp-orchestrator execute-plan` resolves the completed current plan from the active
189
- Change's DB row and `<artifact_root>/plan.json`, then resumes from the first unfinished
190
- dependency wave. Use `--change <id>` when more than one active Change has a completed
191
- plan. The legacy global `.ultra/execution-plan.json` is never selected implicitly;
192
- `--plan <path>` is explicit read-only migration compatibility for an unbound legacy
193
- plan and cannot be combined with `--change`.
194
- Before creating a session it rejects an empty, malformed, cyclic, duplicate-task, or
195
- cross-change plan. For change-owned tasks, the plan must exactly match the current DB
196
- task graph, planning-context digest, canonical Change artifact paths, and a healthy
197
- completed `plan` workflow; an exported but incomplete, displaced, or stale artifact is
198
- not executable. A separate owner approval is present only when a material planning
199
- decision required it.
200
- It returns `status: "paused"` when that wave still has non-terminal Ultra tasks and
201
- does not dispatch later waves. Worktrees are preserved unless `--auto-merge` is
202
- explicitly supplied and the corresponding change task has an exact completion commit,
203
- ready dev workflow, and current task review. `run` and `start` are optional queue daemons and additionally require
204
- `orchestrator.auto_dispatch: true`.
205
-
206
- Every execution mode requires a shell-free worker contract:
32
+ or:
207
33
 
208
34
  ```json
209
35
  {
210
- "orchestrator": {
211
- "command": "/absolute/path/to/ultra-worker",
212
- "command_args": []
36
+ "ok": false,
37
+ "error": {
38
+ "code": "ERROR_CODE",
39
+ "message": "What failed",
40
+ "retriable": false
213
41
  }
214
42
  }
215
43
  ```
216
44
 
217
- `UBP_ORCH_COMMAND` and a JSON-array `UBP_ORCH_ARGS_JSON` may override that contract.
218
- The daemon refuses startup without a real executable. Worker exit zero is execution
219
- evidence only and leaves the Ultra task `in_progress`; failure blocks the task and
220
- records session-linked circuit-breaker evidence. Worker spawn errors follow the same
221
- failure path instead of leaving a running lease.
45
+ Human-readable progress may precede the envelope. Structured logs go to stderr.
46
+ Exit code `0` means success, `1` means invalid user input, `2` means a mechanical
47
+ runtime or I/O failure, `3` means a lease conflict, `4` means a schema mismatch,
48
+ and `5` means timeout.
49
+
50
+ ## Public tool mapping
51
+
52
+ The table is checked against `spec/mcp-tools.yaml` at gate time.
53
+
54
+ | MCP tool | CLI subcommand | Phase | Writer |
55
+ |---|---|---:|---|
56
+ | `ultra.context` | `ultra context` | 24 | mcp |
57
+ | `ultra.record` | `ultra record` | 24 | mcp |
58
+ | `ultra.checkpoint` | `ultra checkpoint` | 24 | mcp |
59
+ | `ultra.sync` | `ultra sync` | 24 | mcp |
60
+ | `ultra.session` | `ultra session` | 24 | mcp |
61
+ | `ultra.archive` | `ultra archive` | 24 | mcp |
62
+ | `ultra.doctor` | `ultra doctor` | 24 | mcp |
63
+
64
+ The retired `task.*`, `change.*`, `decision.*`, `workflow.*`, `artifact.*`,
65
+ `plan.*`, `session.*`, `baseline.*`, and `system.doctor` names are historical
66
+ migration vocabulary only. They are neither returned by `tools/list` nor accepted
67
+ by the MCP call handler.
68
+
69
+ ## Behavioral boundary
70
+
71
+ - `ultra.context` is read-only and returns one canonical Context Envelope.
72
+ - `ultra.record` appends typed facts or revises mutable drafts. Semantic
73
+ diagnostics are returned as data.
74
+ - `ultra.checkpoint` attempts an immutable stage checkpoint. An unsuccessful
75
+ attempt remains a revisable draft.
76
+ - `ultra.sync` imports, publishes, inspects, or migrates the Git team ledger.
77
+ - `ultra.session` owns only leases, Worker Packets, heartbeats, and terminal
78
+ session transitions.
79
+ - `ultra.archive` is the recoverable filesystem and database commit boundary.
80
+ - `ultra.doctor` reports mechanical health and performs only explicit,
81
+ backup-first deterministic repairs.
82
+
83
+ Skills own adaptive workflow prose and host-native user interaction. Hooks observe
84
+ lifecycle events and inject bounded context. Neither surface may silently write
85
+ semantic authority.
86
+
87
+ ## Orchestrator
88
+
89
+ `ubp-orchestrator` consumes an accepted Plan checkpoint and a task-specific
90
+ Worker Packet. It may schedule independent tasks but may not infer missing owner
91
+ decisions, rewrite a Change contract, or bypass a rejected checkpoint.
92
+
93
+ Every worker result must echo the exact `packet_digest`. A zero exit code is
94
+ execution evidence, not automatic semantic completion; the responsible Skill
95
+ records the outcome and attempts the appropriate checkpoint.
96
+
97
+ ## Versioning
98
+
99
+ The CLI follows the `version` in `spec/mcp-tools.yaml`. Public tool removal,
100
+ renaming, or incompatible envelope changes require a major contract revision and
101
+ a migration note. Adding an optional field or a new typed record action requires
102
+ a minor contract revision.