ultra-builder-pro-cli 0.11.0 → 0.13.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 (75) hide show
  1. package/.ultra-template/docs/research/README.md +21 -44
  2. package/.ultra-template/specs/architecture.md +54 -223
  3. package/.ultra-template/specs/discovery.md +41 -228
  4. package/.ultra-template/specs/product.md +44 -200
  5. package/.ultra-template/tasks/contexts/TEMPLATE.md +36 -0
  6. package/.ultra-template/tasks/tasks.json +6 -0
  7. package/CHANGELOG.md +94 -1
  8. package/README.md +37 -9
  9. package/adapters/_shared/codex-assets.cjs +1 -1
  10. package/adapters/_shared/handbook.cjs +5 -4
  11. package/adapters/_shared/tests/handbook.test.cjs +4 -0
  12. package/adapters/opencode.js +8 -2
  13. package/adapters/tests/codex.test.cjs +10 -2
  14. package/adapters/tests/kimi-hook.test.cjs +1 -1
  15. package/adapters/tests/opencode.test.cjs +36 -1
  16. package/commands/ultra-init.md +3 -3
  17. package/docs/AGENT-CONTEXT.md +17 -8
  18. package/docs/ARCHITECTURE.md +51 -8
  19. package/docs/PLAN.zh-CN.md +9 -6
  20. package/docs/ROADMAP.md +5 -3
  21. package/docs/RUNTIME-COMPAT-MATRIX.md +8 -5
  22. package/docs/STATE-DB-ACCESS-POLICY.md +19 -13
  23. package/docs/USER-HANDBOOK-CONTRACT.md +9 -5
  24. package/hooks/README.md +4 -3
  25. package/hooks/adapters/codex.py +1 -1
  26. package/hooks/adapters/kimi.py +1 -1
  27. package/hooks/context_spine.py +153 -16
  28. package/hooks/health_check.py +11 -0
  29. package/hooks/pre_stop_check.py +6 -5
  30. package/mcp-server/lib/archive-journal.cjs +192 -0
  31. package/mcp-server/lib/archive-journal.test.cjs +35 -0
  32. package/mcp-server/lib/baseline-workflow.cjs +781 -0
  33. package/mcp-server/lib/baseline-workflow.test.cjs +477 -0
  34. package/mcp-server/lib/change-workflow.cjs +256 -85
  35. package/mcp-server/lib/change-workflow.test.cjs +436 -6
  36. package/mcp-server/lib/context-spine.cjs +74 -9
  37. package/mcp-server/lib/context-spine.test.cjs +20 -0
  38. package/mcp-server/lib/doctor.cjs +28 -1
  39. package/mcp-server/lib/doctor.test.cjs +63 -1
  40. package/mcp-server/lib/init-project.cjs +334 -16
  41. package/mcp-server/lib/provider-refs.cjs +42 -0
  42. package/mcp-server/lib/spec-learning.test.cjs +5 -0
  43. package/mcp-server/lib/state-authority.cjs +9 -3
  44. package/mcp-server/lib/state-db.cjs +202 -21
  45. package/mcp-server/lib/state-db.test.cjs +140 -3
  46. package/mcp-server/lib/state-ops.cjs +68 -6
  47. package/mcp-server/lib/task-expander.cjs +7 -1
  48. package/mcp-server/lib/task-expander.test.cjs +71 -0
  49. package/mcp-server/server.cjs +62 -6
  50. package/mcp-server/tests/init-project.test.cjs +216 -9
  51. package/mcp-server/tests/migrate.test.cjs +33 -0
  52. package/mcp-server/tests/server-contract.test.cjs +478 -3
  53. package/mcp-server/tests/state-db.test.cjs +23 -2
  54. package/mcp-server/tests/state-ops.test.cjs +108 -0
  55. package/package.json +1 -1
  56. package/skills/ultra-change/SKILL.md +32 -13
  57. package/skills/ultra-deliver/SKILL.md +19 -5
  58. package/skills/ultra-dev/SKILL.md +8 -2
  59. package/skills/ultra-doctor/SKILL.md +30 -9
  60. package/skills/ultra-init/SKILL.md +107 -66
  61. package/skills/ultra-init/references/brownfield-adoption.md +93 -0
  62. package/skills/ultra-plan/SKILL.md +15 -5
  63. package/skills/ultra-research/SKILL.md +17 -5
  64. package/skills/ultra-status/SKILL.md +15 -6
  65. package/spec/cli-protocol.md +15 -1
  66. package/spec/mcp-tools.yaml +316 -11
  67. package/spec/schemas/mcp-tools.schema.json +1 -1
  68. package/spec/schemas/state-db.sql +44 -2
  69. package/ultra-tools/cli.cjs +9 -5
  70. package/ultra-tools/commands/migrate.cjs +62 -36
  71. package/ultra-tools/commands/status.cjs +29 -2
  72. package/ultra-tools/commands/system.cjs +340 -6
  73. package/ultra-tools/commands/task.cjs +11 -2
  74. package/ultra-tools/status-command.test.cjs +49 -0
  75. package/ultra-tools/system-command.test.cjs +256 -0
@@ -1,223 +1,67 @@
1
1
  # Product Specification
2
2
 
3
- > **Source of Truth**: This document defines WHAT the system does and WHO it's for.
4
- > Generated by `/ultra-research` Steps 10-22
5
- > Technical HOW belongs in `architecture.md`.
3
+ This document defines accepted product behavior and scope. It is a durable contract,
4
+ not a research transcript or a task list.
6
5
 
7
- ---
6
+ ## Scope
8
7
 
9
- ## §1 Problem Statement
8
+ - Product or repository boundary:
9
+ - Intended outcome:
10
+ - Explicit non-goals:
10
11
 
11
- ### Core Problem
12
- [NEEDS CLARIFICATION] — One paragraph describing the problem, grounded in discovery.md §0
12
+ ## Observed
13
13
 
14
- ### Who It Affects
15
- [NEEDS CLARIFICATION] — Brief overview connecting problem to specific user types
14
+ Record confirmed current behavior and externally visible constraints. For an existing
15
+ project, cite source, test, runtime, or maintained documentation evidence.
16
16
 
17
- ### Current Impact
18
- - **Time cost**: [NEEDS CLARIFICATION] — Hours/week wasted on workarounds
19
- - **Money cost**: [NEEDS CLARIFICATION] — $ lost to inefficiency
20
- - **Opportunity cost**: [NEEDS CLARIFICATION] — What they can't do because of this problem
17
+ | Behavior or constraint | Evidence reference | Status |
18
+ |---|---|---|
19
+ | | | |
21
20
 
22
- ---
21
+ ## Decisions
23
22
 
24
- ## §2 User Personas
23
+ Record accepted product decisions and the evidence or owner decision behind them.
25
24
 
26
- ### Persona 1: [NEEDS CLARIFICATION] (Primary)
25
+ | Decision | Rationale | Acceptance impact | Owner |
26
+ |---|---|---|---|
27
+ | | | | |
27
28
 
28
- **Role**: Job title / context
29
- **Context**: Where they work, team dynamics, industry
29
+ ## Unknowns
30
30
 
31
- **Goals**:
32
- 1. [NEEDS CLARIFICATION] — Primary goal (what gets them promoted)
33
- 2. Secondary goal (daily care)
34
- 3. Tertiary goal (nice to have)
31
+ | Unknown | Blocking | Owner | Resolution evidence |
32
+ |---|---|---|---|
33
+ | | | | |
35
34
 
36
- **Pain Points**:
37
- 1. [NEEDS CLARIFICATION] — Connects to Opportunity O# from discovery.md §1
38
- 2. Connects to Opportunity O#
39
- 3. Source: URL or user quote
35
+ ## Actors and Entry Points
40
36
 
41
- **Current Workflow**:
42
- > Step-by-step description of how they solve this today
43
- > Tools used: List of current tools/processes
44
- > Time spent: X hours/week
37
+ Include actors only when they are supported by evidence. Describe the public entry
38
+ point through which each actor reaches the behavior.
45
39
 
46
- **Success Metric**: How they measure their own success
47
- **Adoption Trigger**: What would make them try our solution
48
- **Objections**: Why they might resist
40
+ | Actor or system | Need | Entry point | Evidence |
41
+ |---|---|---|---|
42
+ | | | | |
49
43
 
50
- ### Persona 2: [NEEDS CLARIFICATION] (Secondary)
44
+ ## Behavior Contracts
51
45
 
52
- **Role**: [NEEDS CLARIFICATION]
53
- **Context**: [NEEDS CLARIFICATION]
46
+ Give each required behavior a stable identifier. State preconditions, observable
47
+ result, failure behavior, and recovery where relevant.
54
48
 
55
- **Goals**:
56
- 1. [NEEDS CLARIFICATION]
49
+ ### Behavior: pending
57
50
 
58
- **Pain Points**:
59
- 1. [NEEDS CLARIFICATION]
51
+ - Trigger:
52
+ - Preconditions:
53
+ - Observable result:
54
+ - Failure behavior:
55
+ - Recovery:
56
+ - Evidence or decision:
60
57
 
61
- **Current Workflow**:
62
- > [NEEDS CLARIFICATION]
58
+ ## Acceptance
63
59
 
64
- **Success Metric**: [NEEDS CLARIFICATION]
65
- **Adoption Trigger**: [NEEDS CLARIFICATION]
66
- **Objections**: [NEEDS CLARIFICATION]
60
+ | Behavior | Acceptance evidence | Public seam | Verification |
61
+ |---|---|---|---|
62
+ | | | | |
67
63
 
68
- ### Persona Prioritization
64
+ ## Documentation Impact
69
65
 
70
- | Persona | Urgency | Willingness to Pay | Reachability | Priority |
71
- |---------|---------|-------------------|-------------|----------|
72
- | P1 | [NEEDS CLARIFICATION] | | | **Primary** |
73
- | P2 | | | | **Secondary** |
74
-
75
- ---
76
-
77
- ## §3 User Scenarios
78
-
79
- ### Scenario Overview
80
-
81
- | # | Scenario | Persona | Frequency | Pain | Value | Score |
82
- |---|----------|---------|-----------|------|-------|-------|
83
- | S1 | [NEEDS CLARIFICATION] | P1 | /5 | /5 | /5 | |
84
- | S2 | | | | | | |
85
- | S3 | | | | | | |
86
-
87
- > Priority Score = Frequency × Pain × Value
88
-
89
- ### Scenario 1: [NEEDS CLARIFICATION] — Primary
90
-
91
- **Persona**: [NEEDS CLARIFICATION]
92
- **Frequency**: Daily / Weekly / Monthly
93
-
94
- **Trigger**: What event causes this scenario
95
- **Context**: Where, when, device, time pressure
96
-
97
- **Current Flow** (painful):
98
- 1. [NEEDS CLARIFICATION] — What they do today
99
- 2. Where friction occurs
100
- 3. Workaround they use
101
- 4. Outcome and time wasted
102
-
103
- **Desired Flow** (with our product):
104
- 1. [NEEDS CLARIFICATION] — Trigger detected
105
- 2. Streamlined action
106
- 3. Fast resolution
107
- 4. Outcome achieved in less time
108
-
109
- **Success Outcome**: [NEEDS CLARIFICATION] — Specific and measurable
110
- **Failure Outcome**: [NEEDS CLARIFICATION] — Consequences
111
- **Emotional Arc**: Frustration → Discovery → Relief
112
-
113
- ### Scenario 2: [NEEDS CLARIFICATION]
114
-
115
- [Same structure as Scenario 1]
116
-
117
- ### Scenario 3: [NEEDS CLARIFICATION]
118
-
119
- [Same structure as Scenario 1]
120
-
121
- ---
122
-
123
- ## §4 User Stories & Features
124
-
125
- ### Story Map Overview
126
-
127
- | ID | Story | Persona | Scenario | Priority | Complexity |
128
- |----|-------|---------|----------|----------|-----------|
129
- | US-01 | [NEEDS CLARIFICATION] | P1 | S1 | Must | S/M/L |
130
- | US-02 | | | | | |
131
- | US-03 | | | | | |
132
-
133
- ### Must-Have Stories
134
-
135
- #### US-01: [NEEDS CLARIFICATION]
136
- **As a** [Persona], **I want** [action], **so that** [benefit].
137
-
138
- **Acceptance Criteria**:
139
- - [ ] Given [context], when [action], then [result]
140
- - [ ] Given [context], when [edge case], then [result]
141
-
142
- **Traces to**: Scenario S#, Opportunity O#
143
- **Complexity**: S/M/L
144
-
145
- ### Should-Have Stories
146
-
147
- #### US-04: [NEEDS CLARIFICATION]
148
- [Same structure]
149
-
150
- ### Could-Have Stories
151
-
152
- #### US-07: [NEEDS CLARIFICATION]
153
- [Same structure]
154
-
155
- ---
156
-
157
- ## §5 Feature Scope
158
-
159
- ### Features In (MVP)
160
-
161
- #### Feature 1: [NEEDS CLARIFICATION]
162
- - **Description**: What this feature does
163
- - **Stories**: US-01, US-02
164
- - **User value**: What user can do with this
165
- - **Priority**: Must-Have
166
- - **Complexity**: S/M/L
167
-
168
- ### Features In (v2 — Planned)
169
-
170
- #### Feature 4: [NEEDS CLARIFICATION]
171
- - **Description**: What this feature does
172
- - **Stories**: US-07, US-08
173
- - **Rationale for deferral**: Why not MVP
174
- - **Trigger to build**: When to reconsider
175
-
176
- ### Features Out (Explicitly Excluded)
177
-
178
- | Feature | Rationale | Reconsider When | Alternative |
179
- |---------|-----------|----------------|-------------|
180
- | [NEEDS CLARIFICATION] | Why excluded (ref strategy §4) | Condition | What users do instead |
181
-
182
- ### Scope Summary
183
- - **MVP features**: [NEEDS CLARIFICATION] features, stories
184
- - **v2 features**: features, stories
185
- - **Excluded features**: features
186
-
187
- ---
188
-
189
- ## §6 Success Metrics
190
-
191
- ### North Star Metric
192
- - **Metric**: [NEEDS CLARIFICATION]
193
- - **Definition**: Exactly what is measured
194
- - **Current baseline**: Current state or industry benchmark
195
- - **Target**: Specific number
196
- - **Timeline**: When to achieve
197
- - **Measurement method**: How to collect this data
198
-
199
- ### Business Metrics
200
-
201
- | Metric | Baseline | Target (M3) | Target (M6) | Target (M12) | How Measured |
202
- |--------|----------|-------------|-------------|--------------|-------------|
203
- | [NEEDS CLARIFICATION] | | | | | |
204
-
205
- ### User Metrics
206
-
207
- | Metric | Baseline | Target | How Measured |
208
- |--------|----------|--------|-------------|
209
- | Task completion rate | [NEEDS CLARIFICATION] | | |
210
- | Time on task | | | |
211
- | User satisfaction (NPS) | | | |
212
- | Feature adoption | | | |
213
-
214
- ### Anti-Metrics (What NOT to Optimize)
215
-
216
- | Anti-Metric | Why Not | What It Could Sacrifice |
217
- |------------|---------|------------------------|
218
- | [NEEDS CLARIFICATION] | | |
219
-
220
- ---
221
-
222
- **Document Status**: Draft
223
- **Last Updated**: [Date]
66
+ List maintained documents that must stay consistent with this contract, or record a
67
+ specific reason why no documentation change is required.
@@ -0,0 +1,36 @@
1
+ <!-- Body template only. The projector owns authoritative YAML frontmatter. -->
2
+
3
+ # Task {id}: {title}
4
+
5
+ ## Outcome
6
+
7
+ [Describe the observable result this task must produce.]
8
+
9
+ ## Required context
10
+
11
+ - `[project-relative reference]` — [why it is required]
12
+
13
+ ## Execution contract
14
+
15
+ - Public seam: [reachable entry point or observable boundary]
16
+ - Verification command: `[exact deterministic command]`
17
+ - Documentation impact: [required paths or a specific no-change rationale]
18
+
19
+ ## Constraints
20
+
21
+ - [Confirmed constraint with its evidence source]
22
+
23
+ ## Acceptance evidence
24
+
25
+ - [Expected behavior and the evidence that will verify it]
26
+
27
+ ## Traceability
28
+
29
+ - Change: [change id or initial baseline]
30
+ - Specification: [project-relative section reference]
31
+
32
+ ## Completion evidence
33
+
34
+ - Commit: [verified commit when applicable]
35
+ - Tests: [command and result]
36
+ - Summary: [delivered behavior]
@@ -0,0 +1,6 @@
1
+ {
2
+ "schema_version": "4.5",
3
+ "generated_at": "1970-01-01T00:00:00.000Z",
4
+ "source": ".ultra/state.db",
5
+ "tasks": []
6
+ }
package/CHANGELOG.md CHANGED
@@ -7,6 +7,96 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.13.0] — 2026-07-18
11
+
12
+ ### Added
13
+
14
+ - Added schema 12 repository snapshots, branch and dirty-worktree evidence,
15
+ classification metadata, and a categorized baseline gap ledger with explicit
16
+ blocker, ownership, acceptance, and resolution state.
17
+ - Added safe `task.init_project` resume semantics, bounded monorepo scope
18
+ detection, projection-only import routing, explicit migrated-baseline
19
+ replacement, and backup-first recovery for old state databases.
20
+ - Added explicit corrupt-state restore and rebaseline commands that quarantine
21
+ the original database, WAL, SHM, and task projection and restore every moved
22
+ artifact when recovery fails.
23
+ - Added approved incident break-glass records and mandatory post-incident
24
+ baseline reconciliation gaps, plus durable archive-journal crash recovery.
25
+
26
+ ### Changed
27
+
28
+ - Made `ultra-init` the single route for empty repositories, existing
29
+ codebases, healthy installations, incomplete adoptions, prior Ultra state,
30
+ and corrupt databases. Existing application and baseline files are preserved;
31
+ resume installs only missing current scaffold assets.
32
+ - New ordinary changes now require a healthy ready baseline. Already-active
33
+ work remains executable with visible drift warnings, while convergence still
34
+ requires current approved authority.
35
+ - Ready-baseline replacement now requires durable owner identity and rationale;
36
+ a bare `replace_ready` boolean is rejected and cannot erase provenance.
37
+ - Reworked baseline templates and host-neutral Skills around
38
+ `Observed`/`Verified`/`Decided`/`Unknown` evidence, characterization results,
39
+ owner approval, and one deterministic next action.
40
+
41
+ ### Fixed
42
+
43
+ - Prevented prior-version projects from being treated as approved after a
44
+ schema upgrade; compatibility baselines remain `migrated/adopting` until an
45
+ evidence-backed brownfield replacement is approved.
46
+ - Made status and doctor report old or corrupt state as structured recovery
47
+ guidance, retain pre-migration backup paths on failure, and close failed
48
+ database handles safely.
49
+ - Prevented maintenance CLI telemetry from opening corrupt authority before
50
+ evidence-preserving recovery checks, and made task creation enforce the same
51
+ baseline boundary as change creation.
52
+ - Closed bulk-parse and task-expansion task-creation bypasses; persisted PRD
53
+ tasks now carry their active change id, and expanded children inherit the
54
+ parent task's authorized change ownership.
55
+ - Rejected task writes against missing or terminal changes even when the
56
+ baseline is healthy, and enforced parent-child change ownership for generic
57
+ task creation and reassignment paths.
58
+ - Fixed installed npm tarballs so direct `ultra-tools task init-project` calls
59
+ can locate the packaged scaffold outside a source checkout.
60
+
61
+ ## [0.12.1] — 2026-07-18
62
+
63
+ ### Fixed
64
+
65
+ - Fixed the published project scaffold so its task projection and neutral context
66
+ template are tracked on fresh checkouts instead of being hidden by a broad ignore
67
+ rule; the seed projection now uses the authoritative v4.5 state contract.
68
+
69
+ ## [0.12.0] — 2026-07-18
70
+
71
+ ### Added
72
+
73
+ - Added schema 11.0 project baselines and four `baseline.*` MCP contracts for
74
+ greenfield initialization, brownfield adoption, evidence recording, explicit
75
+ approval, re-adoption history, and archive reconciliation.
76
+ - Added automatic new/existing repository detection, neutral baseline templates,
77
+ metadata-only provider references, and cross-host baseline status/doctor output.
78
+
79
+ ### Changed
80
+
81
+ - Reclassified file count, token estimate, and context-share limits as advisory
82
+ attention warnings. Necessary incident context and active work are no longer
83
+ rejected or repaired by arbitrarily raising a threshold.
84
+ - Made incomplete or stale baseline state advisory during an active bounded change,
85
+ requiring approved adoption at `change.converge` and complete revision/spec
86
+ reconciliation in the atomic archive transaction.
87
+ - Changed the Stop hook from a workflow-completion denial into a lifecycle advisory;
88
+ direct writes to the authoritative task projection remain blocked.
89
+
90
+ ### Fixed
91
+
92
+ - Prevented old projects from being initialized as empty greenfield products or
93
+ using generated `tasks.json` as project metadata authority.
94
+ - Updated Claude Code, Codex, OpenCode, and Kimi presentation so hooks expose
95
+ warnings without turning them into edit, stop, or workflow refusal gates.
96
+ - Removed the convergence deadlock where normal HEAD or tracked-spec changes made by
97
+ the active change were rejected before archive could reconcile them; incomplete
98
+ archive declarations now fail with full state and artifact rollback.
99
+
10
100
  ## [0.11.0] — 2026-07-18
11
101
 
12
102
  ### Added
@@ -451,7 +541,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
451
541
  skill manifest, CLI protocol + mapping table; 5 spec validators.
452
542
  - **Phase 0 — skeleton**: multi-runtime installer scaffolding.
453
543
 
454
- [Unreleased]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.11.0...HEAD
544
+ [Unreleased]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.13.0...HEAD
545
+ [0.13.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.12.1...v0.13.0
546
+ [0.12.1]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.12.0...v0.12.1
547
+ [0.12.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.11.0...v0.12.0
455
548
  [0.11.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.10.0...v0.11.0
456
549
  [0.10.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.9.0...v0.10.0
457
550
  [0.9.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.8.1...v0.9.0
package/README.md CHANGED
@@ -8,7 +8,7 @@ authoritative `.ultra/state.db`.
8
8
 
9
9
  <div align="center">
10
10
 
11
- [![Version](https://img.shields.io/badge/version-0.11.0-blue)](./CHANGELOG.md)
11
+ [![Version](https://img.shields.io/badge/version-0.13.0-blue)](./CHANGELOG.md)
12
12
  [![Tests](https://img.shields.io/badge/tests-passing-brightgreen)](#verification)
13
13
  [![License: MIT](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
14
14
  [![Node](https://img.shields.io/badge/node-%E2%89%A522-informational)](./package.json)
@@ -27,7 +27,7 @@ authoritative `.ultra/state.db`.
27
27
  Install and uninstall are symmetric on every supported host; `ubp --doctor`
28
28
  verifies the installed asset hashes and host entry points without mutation.
29
29
  - **Shares state across runtimes.** `.ultra/state.db` (SQLite + WAL) is the
30
- authoritative source for changes, tasks, sessions, events, incidents,
30
+ authoritative source for baselines, changes, tasks, sessions, events, incidents,
31
31
  projection jobs, and telemetry. `tasks.json` and context markdown are
32
32
  generated projections, not handwritten.
33
33
  - **Keeps memory ownership explicit.** Ultra Builder Pro does not collect
@@ -37,12 +37,17 @@ authoritative `.ultra/state.db`.
37
37
  `.ultra/execution-plan.json` → parallel worktree sessions → auto-merge back.
38
38
  - **Keeps daily work convergent.** `/ultra-change` creates a bounded delta and
39
39
  Context Manifest v2; the Context Spine assigns a role/gate, verifies required
40
- references and fresh-context budget, exposes one DB-derived breadcrumb, and
40
+ references, reports fresh-context budget pressure as advisory warnings, exposes one DB-derived breadcrumb, and
41
41
  routes a single next action. `/ultra-deliver` requires applied specification
42
42
  learning plus docs/test/two-axis review evidence before archive. `/ultra-doctor` reports incidents,
43
43
  projection lag, orphan sessions, and backup-first mechanical recovery.
44
44
  Incident changes additionally require a five-section `diagnosis.md` covering
45
45
  reproduction, hypotheses, root cause, regression test, and recovery.
46
+ - **Adopts existing repositories without pretending they are new.** `ultra-init`
47
+ classifies greenfield, brownfield, and monorepo scope. Brownfield adoption records
48
+ current specifications, repository/runtime evidence, worktree snapshot, known-red
49
+ verification, categorized gaps, unknowns, and explicit approval without rewriting
50
+ application code. v4.4 and v4.5 projection-only projects have backup-first imports.
46
51
  - **Keeps external context external.** Memory and code-graph providers retain
47
52
  their own content; Ultra stores only provider/project/revision/status metadata
48
53
  references in a compiled change context.
@@ -82,6 +87,14 @@ install or update.
82
87
  See [`docs/RUNTIME-COMPAT-MATRIX.md`](./docs/RUNTIME-COMPAT-MATRIX.md)
83
88
  for per-runtime capabilities.
84
89
 
90
+ Start with `ultra-init` in both new and existing projects. An empty project opens
91
+ a `draft` greenfield baseline. An existing codebase opens an `adopting`
92
+ brownfield baseline; inspect current behavior, call `baseline.record`, then
93
+ approve it through `baseline.converge` before normal planning or delivery. Existing
94
+ active work may continue while adoption drift is visible. A new incident requires an
95
+ explicit break-glass approver and leaves a blocking reconciliation gap at archive;
96
+ new ordinary work always requires a healthy ready baseline.
97
+
85
98
  ## Three-layer architecture
86
99
 
87
100
  | Layer | Purpose | When it's used |
@@ -93,7 +106,7 @@ for per-runtime capabilities.
93
106
  The layers share one `.ultra/state.db`, but the CLI is not a mirror of every MCP
94
107
  tool: continuous change mutations are MCP-only and fail closed. See
95
108
  [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md) for the full contract and
96
- [`spec/cli-protocol.md`](./spec/cli-protocol.md) for the 32 live contracts.
109
+ [`spec/cli-protocol.md`](./spec/cli-protocol.md) for the 36 live contracts.
97
110
  Review, impact discovery, skill resolution, and user interaction stay on each
98
111
  Host's native surfaces; the generated Codex capability map documents those
99
112
  replacements without advertising non-existent MCP tools.
@@ -121,11 +134,15 @@ Full details in [`docs/RUNTIME-COMPAT-MATRIX.md`](./docs/RUNTIME-COMPAT-MATRIX.m
121
134
  ## Typical workflow
122
135
 
123
136
  ```bash
124
- # 1. Initialize a project (writes .ultra/ skeleton and initializes state.db)
125
- ultra-tools task init-project --name myapp
137
+ # 1. Bootstrap project state (the ultra-init skill completes adoption and approval)
138
+ ultra-tools task init-project --project-name myapp --mode auto
139
+
140
+ # Projection-only projects from prior releases use one backup-first import:
141
+ ultra-tools migrate --from=4.4 --to=4.5 --source-dir .
142
+ ultra-tools migrate --from=4.5 --to=12.0 --source-dir .
126
143
 
127
- # 2. Turn a PRD into a task graph + execution plan (human-gate via dry-run)
128
- # (invoked by /ultra-plan skill or via MCP task.parse_prd + plan.export)
144
+ # 2. Record and converge the greenfield/brownfield baseline, then turn accepted
145
+ # behavior into a task graph (normally driven by ultra-init/research/plan)
129
146
 
130
147
  # 3. Run the plan — parallel sessions, auto-merge back to main on success
131
148
  ubp-orchestrator run
@@ -138,7 +155,7 @@ ultra-tools system doctor
138
155
  ```
139
156
 
140
157
  Or let the skills drive it. In Codex, invoke
141
- `$ultra-builder-pro:ultra-plan` → `$ultra-builder-pro:ultra-dev` →
158
+ `$ultra-builder-pro:ultra-init` → `$ultra-builder-pro:ultra-plan` → `$ultra-builder-pro:ultra-dev` →
142
159
  `$ultra-builder-pro:ultra-test` → `$ultra-builder-pro:ultra-review` →
143
160
  `$ultra-builder-pro:ultra-deliver`; after the baseline is delivered, daily work
144
161
  starts with `$ultra-builder-pro:ultra-change`, while
@@ -196,6 +213,17 @@ Individual suites: `test:state`, `test:orch`, `test:spec`, `test:rest`.
196
213
  the recorded install provenance with current asset hashes and validates the
197
214
  host-specific hook, MCP, plugin, and runtime-manifest entry points. Reinstall
198
215
  only after preserving the degraded report as evidence.
216
+ - **Projection tasks exist but state.db has no tasks**: run the exact v4.4 or v4.5
217
+ `ultra-tools migrate` command returned by MCP, verify the backup and imported counts,
218
+ then run `ultra-init` to replace the compatibility row with a reviewed brownfield
219
+ baseline.
220
+ - **Old or corrupt state.db**: `ultra-tools system doctor` is read-only;
221
+ `ultra-tools system doctor --repair` upgrades supported schemas with two backup
222
+ checkpoints. A corrupt database is never overwritten automatically. After explicit
223
+ owner approval, restore a verified managed copy with
224
+ `ultra-tools system restore --backup <path> --confirm REPLACE_CORRUPT_ULTRA_STATE`,
225
+ or preserve the corrupt DB and legacy projection before rebuilding authority with
226
+ `ultra-tools system rebaseline --project-name <name> --confirm REBASELINE_CORRUPT_ULTRA_STATE`.
199
227
  - **Legacy Ultra memory data remains on disk**: inspect first with
200
228
  `ultra-tools legacy-memory inspect`, archive with
201
229
  `ultra-tools legacy-memory archive`, then prune only with the explicit
@@ -400,7 +400,7 @@ function buildHooksManifest() {
400
400
  { hooks: [commandHook('workflow_resume.py', 10, 'Restoring Ultra workflow checkpoint')] },
401
401
  ],
402
402
  Stop: [
403
- { hooks: [commandHook('pre_stop_check.py', 5, 'Checking Ultra completion gates')] },
403
+ { hooks: [commandHook('pre_stop_check.py', 5, 'Reporting Ultra workflow position')] },
404
404
  ],
405
405
  SubagentStart: [
406
406
  { hooks: [commandHook('subagent_tracker.py', 5, 'Tracking Ultra subagent', 'start')] },
@@ -59,12 +59,13 @@ function renderHandbook(runtime) {
59
59
  `- Workflow entry points: ${value.invocation}.`,
60
60
  `- Collaboration boundary: ${value.collaboration}. The current host remains primary and owns final verification.`,
61
61
  `- Coordination boundary: ${value.coordination}.`,
62
- '- Authority: `.ultra/state.db` is the only durable Ultra authority for changes, tasks, sessions, events, incidents, projection state, telemetry, and review evidence. Generated JSON and Markdown are projections or workflow artifacts.',
63
- '- Context Spine boundary: `change.context` compiles role/gate readiness, bounded references, fresh-context budget, public seam, verification command, and one next action. Hooks inject only the DB-derived `change.breadcrumb`; stale or blocked context must be recompiled.',
62
+ '- Authority: `.ultra/state.db` is the only durable Ultra authority for baselines, changes, tasks, sessions, events, incidents, projection state, telemetry, and review evidence. Generated JSON and Markdown are projections or workflow artifacts.',
63
+ '- Baseline boundary: `task.init_project` classifies greenfield or brownfield work and records repository scope. Projection-only prior state uses the exact supported backup-first import returned by the authority check; migrated compatibility rows require explicit brownfield re-adoption. `baseline.record` owns evidence, verification, repository snapshot, and the gap ledger; `baseline.converge` requires explicit owner approval. New ordinary changes require a healthy ready baseline. Existing active work may continue with warnings, but baseline readiness blocks change convergence; normal drift reconciliation is health-checked atomically at archive. Only an explicitly approved incident break-glass may start without baseline readiness, and its archive creates a blocking reconciliation gap.',
64
+ '- Context Spine boundary: `change.context` compiles role/gate readiness, required references, a fresh-context budget, public seam, verification command, and one next action. File, token, and context-share budgets are advisory attention signals, not refusal gates. Hooks inject only the DB-derived `change.breadcrumb`; missing required evidence or stale execution context must be recompiled.',
64
65
  '- Specification learning boundary: stable implementation discoveries use approval-gated propose/approve-or-reject/apply transitions. Unresolved learning blocks convergence; review requires independent specification-fidelity and engineering-standards evidence.',
65
66
  '- Memory and graph boundary: Ultra Builder Pro does not capture prompts, transcripts, observations, summaries, cross-session memory, or code-graph content. Separately installed providers own that data; Ultra may store only their metadata references in a change context manifest.',
66
- '- Hook boundary: Ultra hooks observe workflow/change lifecycle only. Health/context may run when `.ultra/state.db` exists; projection protection is always authoritative, while edit/compact/stop/subagent enforcement remains active-workflow scoped. Generic command blocking and post-edit policy stay in user or repository governance.',
67
- '- Installation boundary: `ubp --doctor` is the read-only authority for installed asset provenance, content hashes, and host entry-point wiring; `system.doctor` remains scoped to project state and workflow recovery.',
67
+ '- Hook boundary: Ultra hooks observe workflow/change lifecycle only. Health/context may run when `.ultra/state.db` exists; advisory warnings never reject work, and an incomplete workflow never traps session stop. Direct projection protection remains authoritative; compact and subagent recovery stays active-workflow scoped. Generic command blocking and post-edit policy stay in user or repository governance.',
68
+ '- Installation boundary: `ubp --doctor` is the read-only authority for installed asset provenance, content hashes, and host entry-point wiring. Project `system.doctor` diagnoses state and performs only authorized backup-first schema, projection, session, and archive-journal recovery; it never approves a baseline.',
68
69
  '- Agent boundary: the bundled review and debugging agents are bounded workers. They use the current checkout and parent-supplied context, do not own private persistent state, and never replace the primary agent.',
69
70
  '- Package boundary: only the twelve Ultra workflows, four internal review-rule skills, host-specific collaboration companions, and the minimal host bootstrap belong to this plugin. General browser, deployment, discovery, and framework skills must be installed from their owners.',
70
71
  END_MARKER,
@@ -34,6 +34,10 @@ test('renders one common contract with host-native invocation syntax', () => {
34
34
  assert.match(rendered, /ultra-doctor/);
35
35
  assert.match(rendered, /metadata references/);
36
36
  assert.match(rendered, /Context Spine boundary/);
37
+ assert.match(rendered, /budgets are advisory attention signals/);
38
+ assert.match(rendered, /blocks change convergence/);
39
+ assert.match(rendered, /health-checked atomically at archive/);
40
+ assert.match(rendered, /never traps session stop/);
37
41
  assert.match(rendered, /change\.breadcrumb/);
38
42
  assert.match(rendered, /Specification learning boundary/);
39
43
  assert.doesNotMatch(rendered, /\.ultra\/memory|memory\.retain|memory\.recall/);
@@ -345,11 +345,14 @@ function findUltraContext(directory) {
345
345
  const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
346
346
  if (manifest?.change) {
347
347
  const compiledHead = manifest.git?.head ?? null;
348
- const legacyContext = manifest.schema_version !== "2.0";
348
+ const legacyContext = manifest.schema_version !== "2.0" || !manifest.baseline;
349
349
  const headStale = Boolean(compiledHead && currentHead && compiledHead !== currentHead);
350
350
  const blockers = Array.isArray(manifest.readiness?.blockers)
351
351
  ? [...manifest.readiness.blockers]
352
352
  : [];
353
+ const warnings = Array.isArray(manifest.readiness?.warnings)
354
+ ? [...manifest.readiness.warnings]
355
+ : [];
353
356
  if (headStale && !blockers.includes("CONTEXT_HEAD_STALE")) blockers.push("CONTEXT_HEAD_STALE");
354
357
  if (legacyContext && !blockers.includes("CONTEXT_SNAPSHOT_UPGRADE_REQUIRED")) {
355
358
  blockers.unshift("CONTEXT_SNAPSHOT_UPGRADE_REQUIRED");
@@ -367,6 +370,8 @@ function findUltraContext(directory) {
367
370
  : (manifest.next_action ?? "Inspect Ultra status."),
368
371
  readiness: legacyContext || headStale ? "blocked" : (manifest.readiness?.status ?? "ready"),
369
372
  blockers,
373
+ warnings,
374
+ baseline: manifest.baseline ?? null,
370
375
  taskId: manifest.selected_task?.id ?? manifest.resume?.task_id ?? null,
371
376
  taskStatus: manifest.selected_task?.status ?? manifest.resume?.task_status ?? null,
372
377
  tokenEstimate: manifest.context?.token_estimate ?? 0,
@@ -411,6 +416,7 @@ function contextText(active) {
411
416
  \`Gate: \${change.gate}\`,
412
417
  \`Readiness: \${change.readiness}\`,
413
418
  ...(change.blockers.length > 0 ? [\`Blockers: \${change.blockers.join(", ")}\`] : []),
419
+ ...(change.warnings.length > 0 ? [\`Warnings: \${change.warnings.join(", ")}\`] : []),
414
420
  \`Next: \${change.nextAction}\`,
415
421
  \`Context manifest: \${change.manifestPath}\`,
416
422
  );
@@ -422,7 +428,7 @@ function contextText(active) {
422
428
  lines.push(
423
429
  "[Ultra baseline]",
424
430
  \`Project: \${active.root}\`,
425
- "No active continuous change. Start daily work with the ultra-change workflow.",
431
+ "No active continuous change. Run ultra-status; resume ultra-init when the baseline is missing, incomplete, or stale, otherwise start ultra-change.",
426
432
  );
427
433
  }
428
434
  lines.push("Authority: .ultra/state.db; JSON/Markdown remain projections or evidence artifacts.");
@@ -9,6 +9,7 @@ const { spawnSync } = require('node:child_process');
9
9
  const yaml = require('js-yaml');
10
10
  const { Client } = require('@modelcontextprotocol/sdk/client/index.js');
11
11
  const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio.js');
12
+ const { initStateDb, closeStateDb } = require('../../mcp-server/lib/state-db.cjs');
12
13
 
13
14
  const codex = require('../codex.js');
14
15
  const { parse: parseFrontmatter } = require('../_shared/frontmatter.cjs');
@@ -245,8 +246,8 @@ test('plugin declares current Codex hooks and a project-local Ultra MCP server',
245
246
  const liveSpec = yaml.load(fs.readFileSync(path.join(layout.pluginRoot, 'spec', 'mcp-tools.yaml'), 'utf8'));
246
247
  const upstreamSpec = yaml.load(fs.readFileSync(path.join(layout.pluginRoot, 'spec', 'upstream-mcp-tools.yaml'), 'utf8'));
247
248
  const capabilityMap = JSON.parse(fs.readFileSync(path.join(layout.pluginRoot, 'spec', 'codex-capability-map.json'), 'utf8'));
248
- assert.equal(liveSpec.tools.length, 32);
249
- assert.equal(upstreamSpec.tools.length, 32);
249
+ assert.equal(liveSpec.tools.length, 36);
250
+ assert.equal(upstreamSpec.tools.length, 36);
250
251
  assert.deepEqual(upstreamSpec.tools.map((tool) => tool.name).sort(), liveSpec.tools.map((tool) => tool.name).sort());
251
252
  assert.deepEqual(capabilityMap.live_mcp_tools.sort(), liveSpec.tools.map((tool) => tool.name).sort());
252
253
  assert.equal(Object.keys(capabilityMap.codex_native_replacements).length, 9);
@@ -263,6 +264,13 @@ test('bundled plugin MCP runs outside the source checkout and keeps state in the
263
264
  let client;
264
265
  try {
265
266
  install(layout);
267
+ const seededState = initStateDb(path.join(projectDir, '.ultra', 'state.db'));
268
+ seededState.db.prepare(
269
+ `INSERT INTO baselines
270
+ (id, project_name, mode, status, approved_by, approval_note, converged_at)
271
+ VALUES ('test-baseline', 'codex-bundle', 'greenfield', 'ready', 'test', 'smoke fixture', ?)`,
272
+ ).run(new Date().toISOString());
273
+ closeStateDb(seededState.db);
266
274
  const mcp = JSON.parse(fs.readFileSync(path.join(layout.pluginRoot, '.mcp.json'), 'utf8'));
267
275
  const server = mcp.mcpServers['ultra-builder-pro'];
268
276
  const env = { ...process.env };