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
@@ -0,0 +1,93 @@
1
+ # Brownfield adoption
2
+
3
+ Execute this procedure for a detected brownfield repository, a migrated compatibility
4
+ baseline, or an existing adoption in `adopting` or `blocked` state.
5
+
6
+ ## Bind the repository boundary
7
+
8
+ Record the repository root, selected scope, workspace roots, branch, HEAD, dirty files,
9
+ generated and vendored exclusions, manifests, verification commands, and public seams.
10
+ Use `.` for a whole-repository adoption. Use selected workspace roots only when the
11
+ user's requested ownership is narrower than the monorepo.
12
+
13
+ The authoritative worktree snapshot contains only selected-scope paths. Report dirty
14
+ files outside that scope separately as repository context, but do not include them in
15
+ the baseline digest. Require `accept_dirty_worktree: true` only after the owner confirms
16
+ the exact in-scope `worktree_files` returned by the server.
17
+
18
+ ## Build the evidence model
19
+
20
+ Inspect the maintained system through its live boundaries:
21
+
22
+ - product behavior, actors, entry points, and public acceptance;
23
+ - runtime modules, consumers, data flow, persistence, and authority;
24
+ - APIs, events, integrations, permissions, security, and failure paths;
25
+ - build, test, lint, typecheck, deployment, migration, observability, and recovery;
26
+ - maintained documents and every detected source-to-document conflict.
27
+
28
+ Classify each material statement as `Observed`, `Verified`, `Decided`, or `Unknown`.
29
+ Record document/source conflicts as drift. Keep provider payloads outside Ultra and
30
+ record only bounded metadata references.
31
+
32
+ ## Write baseline artifacts
33
+
34
+ Update `.ultra/specs/product.md` with current delivered behavior and acceptance. Update
35
+ `.ultra/specs/architecture.md` with real boundaries, owners, writers, consumers,
36
+ consistency rules, permissions, failures, and recovery. Use `discovery.md` for scope
37
+ evidence, decisions, and unresolved questions.
38
+
39
+ Capture current facts without redesigning the application or manufacturing product
40
+ narratives that are absent from evidence.
41
+
42
+ ## Run characterization verification
43
+
44
+ Run the repository's existing verification commands. Record each result as `pass`,
45
+ `known_red`, or `not_run`. A known-red item needs evidence and a rationale; a missing
46
+ command is not a passing result. Record a characterization gap for a critical public
47
+ seam that has no stable verification signal; create its ordinary task only after the
48
+ baseline is ready.
49
+
50
+ ## Maintain the gap ledger
51
+
52
+ Record every adoption gap with a stable id, evidence references, owner, blocking flag,
53
+ and one category:
54
+
55
+ - `baseline_blocker`: prevents trustworthy adoption;
56
+ - `documentation_drift`: maintained prose conflicts with observed behavior;
57
+ - `known_defect`: reproducible incorrect behavior;
58
+ - `technical_debt`: accepted maintainability or quality cost;
59
+ - `unknown`: evidence is insufficient;
60
+ - `future_change`: desired behavior outside the current baseline.
61
+
62
+ Use `open` for unresolved gaps, `accepted` for owner-accepted non-blocking debt,
63
+ `resolved` when evidence closes the gap, and `deferred` for explicitly postponed
64
+ non-blocking work. Every open `baseline_blocker` remains blocking. Do not convert the
65
+ ledger into hundreds of application tasks.
66
+
67
+ ## Record authority
68
+
69
+ Call `baseline.record` with full replacement arrays for:
70
+
71
+ - scope and repository revision;
72
+ - repository classification;
73
+ - product and architecture specification paths;
74
+ - bounded source, documentation, runtime, test, deployment, or external references;
75
+ - verification results;
76
+ - blocking and non-blocking unknowns;
77
+ - the complete gap ledger;
78
+ - external provider metadata references, when supplied.
79
+
80
+ Use the server-returned revision, branch, worktree digest, and specification digests.
81
+
82
+ ## Obtain approval and converge
83
+
84
+ Present scope, observed behavior, drift, known-red verification, unknowns, gaps, dirty
85
+ worktree state, and material decisions to the owner. Call `baseline.converge` only after
86
+ explicit approval. Set `accept_known_red` and `accept_dirty_worktree` only for the exact
87
+ items the owner accepted.
88
+
89
+ Resolve returned blockers through evidence or an owner decision, record the replacement
90
+ snapshot, and retry. Adoption is complete only when `baseline.get` is `ready` and
91
+ current, the gap ledger has no open blocker, and project doctor has no authority
92
+ failure. Route new work through `ultra-change`; route already accepted planned work
93
+ through `ultra-plan`.
@@ -13,6 +13,13 @@ Markdown are generated projections.
13
13
 
14
14
  Start with a state-backed MCP read. If state or schema health blocks access, stop and
15
15
  route to `ultra-doctor`. Never read or write `.ultra/tasks/tasks.json` as a fallback.
16
+ Call `baseline.get`. Initial product planning is blocked until the baseline is
17
+ `ready` and current; route its missing, adopting, blocked, or stale state to
18
+ `ultra-init`. Planning an already active bounded change may continue with the
19
+ baseline condition recorded as a warning. Ordinary convergence still requires
20
+ approved adoption, and archive atomically reconciles revision and specification
21
+ drift. An approved break-glass incident follows its recorded recovery contract and
22
+ creates a blocking reconciliation gap at archive.
16
23
 
17
24
  Choose one input:
18
25
 
@@ -30,8 +37,10 @@ current evidence. A material unresolved assumption blocks persistence.
30
37
  2. Prefer a walking skeleton or `tracer_bullet` before horizontal layers.
31
38
  3. Give each task one outcome, bounded ownership, explicit dependencies, required
32
39
  references, and one deterministic verification command.
33
- 4. Use the context budget returned by the current Ultra contract. Widen it only when
34
- an approved slice cannot be split without losing correctness.
40
+ 4. Use the context budget as an attention signal. Prefer bounded excerpts, direct
41
+ reads, or a smaller slice, but keep necessary files when correctness requires them.
42
+ Budget overflow is a warning, never a reason to inflate a threshold or manufacture
43
+ a smaller but incomplete contract.
35
44
  5. Add integration checkpoints at actual boundaries, not after arbitrary task counts.
36
45
  6. Put validation, errors, recovery, documentation, and migrations in the task that
37
46
  owns the behavior.
@@ -56,11 +65,12 @@ id when applicable.
56
65
 
57
66
  ## PRD mode
58
67
 
59
- 1. Call `task.parse_prd` with `dry_run: true`.
68
+ 1. Call `task.parse_prd` with `dry_run: true` and the active `change_id` when
69
+ applicable.
60
70
  2. Show the proposed slices, topology, conflict surface, and cost estimate.
61
71
  3. Require explicit approval; rejection performs no state write.
62
- 4. On approval, repeat with `dry_run: false`, export the plan, and verify that the
63
- dry-run and persisted task identities agree.
72
+ 4. On approval, repeat with `dry_run: false` and the same change ownership, export
73
+ the plan, and verify that the dry-run and persisted task identities agree.
64
74
 
65
75
  ## Completion gate
66
76
 
@@ -10,8 +10,8 @@ decision. Do not force a fixed discovery ceremony onto a well-defined change.
10
10
 
11
11
  ## Preflight
12
12
 
13
- 1. Require an initialized `.ultra/specs/` directory. Route to `ultra-init` when it is
14
- absent.
13
+ 1. Require an initialized `.ultra/specs/` directory and call `baseline.get`. Route to
14
+ `ultra-init` when state or the baseline is absent. Preserve its mode and id.
15
15
  2. Read the current specification files and repository evidence before asking the
16
16
  user to repeat known facts.
17
17
  3. Define the intended deliverable, unresolved decisions, and evidence standard.
@@ -50,7 +50,19 @@ default.
50
50
  open questions. Do not duplicate the same narrative across several files.
51
51
  5. Validate cross-document consistency and trace each required behavior from problem
52
52
  or constraint to acceptance and architecture.
53
- 6. Use `references/synthesis.md` for the completion check and report one next action.
53
+ 6. Use `references/synthesis.md` for the completion check.
54
+ 7. Record unresolved evidence as the baseline gap ledger: `baseline_blocker`,
55
+ `documentation_drift`, `known_defect`, `technical_debt`, `unknown`, or
56
+ `future_change`. Keep accepted non-blocking work out of the implementation backlog
57
+ until the owner selects it.
58
+ 8. Call `baseline.record` with the complete current specification list, bounded evidence
59
+ references, actual verification results, provider metadata, explicit unknowns,
60
+ classification, and the full gap ledger. Use the returned repository revision for
61
+ convergence.
62
+ 9. Present the baseline, open gaps, dirty-worktree state, and any known-red verification
63
+ to the owner. After explicit approval, call `baseline.converge`, setting acceptance
64
+ flags only for the exact known-red or dirty snapshot approved by the owner. Resolve
65
+ deterministic blockers before routing.
54
66
 
55
67
  ## Completion gate
56
68
 
@@ -59,5 +71,5 @@ material decision is recorded, required acceptance is testable, architecture res
59
71
  known constraints, and unresolved items are either blocking or explicitly outside the
60
72
  accepted scope.
61
73
 
62
- Route a validated baseline to `ultra-plan`. Do not create business tasks, write Ultra
63
- state, or maintain a second condensed specification that can drift from the baseline.
74
+ Route a converged baseline to `ultra-plan`. Do not create business tasks, write raw
75
+ SQLite, or maintain a second condensed specification that can drift from the baseline.
@@ -12,12 +12,14 @@ authoritative; reports and Markdown are evidence or projections.
12
12
 
13
13
  1. Call `system.doctor` in read-only mode. If authority is unhealthy, route only to
14
14
  `ultra-doctor` and include the blocking diagnostic.
15
- 2. Call `change.breadcrumb` for the active change, task, role, gate, readiness,
16
- blockers, staleness, and next action.
17
- 3. Call `task.list` and `session.list` for progress and active execution details.
18
- 4. Read test and delivery reports only when present, and mark a report stale when its
15
+ 2. Call `baseline.get` for mode, lifecycle status, repository revision, branch,
16
+ worktree snapshot, specification digest health, gap ledger, and adoption blockers.
17
+ 3. Call `change.breadcrumb` for the active change, task, role, gate, readiness,
18
+ blockers, advisory warnings, staleness, and next action.
19
+ 4. Call `task.list` and `session.list` for progress and active execution details.
20
+ 5. Read test and delivery reports only when present, and mark a report stale when its
19
21
  HEAD differs from the current checkout.
20
- 5. Read Git branch, HEAD, and worktree status without mutation.
22
+ 6. Read Git branch, HEAD, and worktree status without mutation.
21
23
 
22
24
  If MCP task or change state is unavailable, label that panel unavailable. Never fall
23
25
  back to generated task JSON, context frontmatter, or raw SQLite.
@@ -28,7 +30,12 @@ Follow the breadcrumb's primary route and return one action, not a menu:
28
30
 
29
31
  - unhealthy authority: `ultra-doctor`;
30
32
  - missing Ultra project: `ultra-init`;
31
- - missing baseline evidence: `ultra-research` or `ultra-plan`, matching the gap;
33
+ - projection-only authority conflict: run the exact supported import command from the
34
+ MCP error, then `ultra-init`;
35
+ - migrated or missing baseline evidence with no active change: `ultra-init`, then
36
+ `ultra-research` or `ultra-plan` according to the gap;
37
+ - baseline or context-budget warning during an active change: keep the current route
38
+ and surface the warning; do not turn it into a refusal;
32
39
  - blocked or stale context: the workflow named by the breadcrumb;
33
40
  - ready implementation task: `ultra-dev <task-id>`;
34
41
  - completed tasks with missing or stale test evidence: `ultra-test`;
@@ -45,7 +52,9 @@ Use a compact shape:
45
52
  ```text
46
53
  Ultra: <healthy|degraded> · <branch>@<head> · worktree <clean|dirty>
47
54
  Position: change=<id|none> task=<id|none> role=<role> gate=<gate>
55
+ Baseline: <greenfield|brownfield|migrated>/<status> revision=<revision|none> gaps=<open>/<blocking>
48
56
  Readiness: <ready|blocked|stale> — <blockers or none>
57
+ Warnings: <advisory conditions or none>
49
58
  Progress: <completed>/<total>; sessions=<active count>
50
59
  Evidence: tests=<fresh|stale|missing>; delivery=<fresh|stale|missing>
51
60
  Next: <one exact action>
@@ -100,6 +100,10 @@ as a fallback unless `ultra-tools <family> --help` lists it.
100
100
  | `session.admission_check` | `session admission` | 4.5 | any |
101
101
  | `session.heartbeat` | `session heartbeat` | 4.5 | mcp |
102
102
  | `session.subscribe_events`| `session subscribe` | 4.5 | any |
103
+ | `baseline.start` | `baseline start` | 11 | mcp |
104
+ | `baseline.record` | `baseline record` | 11 | mcp |
105
+ | `baseline.get` | `baseline get` | 11 | any |
106
+ | `baseline.converge` | `baseline converge` | 11 | mcp |
103
107
  | `change.create` | `change create` | 9 | mcp |
104
108
  | `change.update` | `change update` | 9 | mcp |
105
109
  | `change.get` | `change get` | 9 | any |
@@ -116,10 +120,20 @@ as a fallback unless `ultra-tools <family> --help` lists it.
116
120
 
117
121
  Current executable maintenance surfaces are `task init-project`,
118
122
  `session close|get|list|admission|heartbeat|subscribe|reap`, `status`, `db`,
119
- `migrate`, and `legacy-memory`. In particular, `task create|update|list|get`
123
+ `migrate`, `system doctor|restore|rebaseline`, and `legacy-memory`. In particular, `task create|update|list|get`
120
124
  and all `change` lifecycle verbs are not CLI fallbacks. Change state must use
121
125
  the live MCP server; `system doctor` may additionally be exposed by the
122
126
  maintenance CLI because it is the recovery path when MCP startup is degraded.
127
+ `task init-project --resume` preserves existing `.ultra` files and installs only
128
+ missing current scaffold assets. Projection-only state uses the supported
129
+ `migrate --from=4.4 --to=4.5` or `--from=4.5 --to=12.0` transition before resume.
130
+ `system doctor --repair` applies supported schema upgrades with a pre-migration
131
+ backup before mechanical recovery.
132
+ `system restore` requires the exact `REPLACE_CORRUPT_ULTRA_STATE` confirmation and a
133
+ verified database inside `.ultra/backups`; it quarantines the corrupt state before
134
+ atomic replacement. `system rebaseline` requires the exact
135
+ `REBASELINE_CORRUPT_ULTRA_STATE` confirmation and preserves corrupt state plus the
136
+ legacy task projection before starting a new brownfield adoption.
123
137
  The full access policy lives in
124
138
  `docs/STATE-DB-ACCESS-POLICY.md` (Phase 2.2 / R25).
125
139