ultra-builder-pro-cli 0.16.0 → 0.17.1

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 (66) hide show
  1. package/.ultra-template/reports/templates/delivery-report.json +17 -0
  2. package/.ultra-template/reports/templates/test-report.json +18 -0
  3. package/.ultra-template/specs/research-distillate.md +4 -3
  4. package/CHANGELOG.md +95 -0
  5. package/README.md +54 -24
  6. package/adapters/_shared/codex-assets.cjs +10 -5
  7. package/adapters/_shared/handbook.cjs +1 -1
  8. package/adapters/_shared/interaction-contract.cjs +61 -0
  9. package/adapters/claude.js +1 -1
  10. package/adapters/opencode.js +1 -1
  11. package/bin/orchestrator.js +175 -19
  12. package/commands/ultra-change.md +1 -1
  13. package/commands/ultra-deliver.md +3 -3
  14. package/commands/ultra-init.md +1 -1
  15. package/commands/ultra-plan.md +1 -1
  16. package/commands/ultra-research.md +2 -2
  17. package/commands/ultra-review.md +10 -0
  18. package/commands/ultra-status.md +1 -1
  19. package/commands/ultra-test.md +1 -1
  20. package/docs/AGENT-CONTEXT.md +11 -8
  21. package/docs/ARCHITECTURE.md +67 -9
  22. package/docs/LEGACY-CLI-CROSSWALK.md +163 -0
  23. package/docs/PLAN.zh-CN.md +19 -13
  24. package/docs/RUNTIME-COMPAT-MATRIX.md +2 -2
  25. package/docs/WORKFLOW-LIFECYCLE.md +123 -59
  26. package/hooks/pre_stop_check.py +3 -2
  27. package/mcp-server/lib/baseline-workflow.cjs +84 -16
  28. package/mcp-server/lib/change-workflow.cjs +55 -35
  29. package/mcp-server/lib/context-spine.cjs +171 -105
  30. package/mcp-server/lib/git-bootstrap.cjs +240 -0
  31. package/mcp-server/lib/init-project.cjs +178 -41
  32. package/mcp-server/lib/project-breadcrumb.cjs +14 -14
  33. package/mcp-server/lib/state-db.cjs +257 -10
  34. package/mcp-server/lib/state-ops.cjs +64 -1
  35. package/mcp-server/lib/workflow-state.cjs +300 -205
  36. package/mcp-server/server.cjs +58 -34
  37. package/orchestrator/auto-merge.cjs +19 -0
  38. package/orchestrator/daemon.cjs +104 -0
  39. package/orchestrator/parallel-orchestrator.cjs +371 -49
  40. package/orchestrator/session-runner.cjs +354 -25
  41. package/package.json +2 -1
  42. package/skills/ultra-change/SKILL.md +69 -94
  43. package/skills/ultra-deliver/SKILL.md +37 -65
  44. package/skills/ultra-dev/SKILL.md +50 -52
  45. package/skills/ultra-doctor/SKILL.md +34 -49
  46. package/skills/ultra-init/SKILL.md +78 -105
  47. package/skills/ultra-plan/SKILL.md +78 -99
  48. package/skills/ultra-research/SKILL.md +99 -113
  49. package/skills/ultra-review/SKILL.md +38 -53
  50. package/skills/ultra-review/references/review-modes.md +5 -3
  51. package/skills/ultra-review/references/unified-schema.md +26 -6
  52. package/skills/ultra-review/scripts/review_wait.py +12 -0
  53. package/skills/ultra-status/SKILL.md +34 -44
  54. package/skills/ultra-test/SKILL.md +61 -54
  55. package/skills/ultra-think/SKILL.md +37 -51
  56. package/skills/ultra-think/references/decision-dialogue.md +87 -111
  57. package/spec/cli-protocol.md +35 -0
  58. package/spec/mcp-tools.yaml +145 -28
  59. package/spec/schemas/delivery-report.v1.schema.json +1 -46
  60. package/spec/schemas/state-db.sql +8 -2
  61. package/spec/schemas/test-report.v1.schema.json +45 -14
  62. package/ultra-tools/cli.cjs +1 -1
  63. package/ultra-tools/commands/session.cjs +10 -3
  64. package/ultra-tools/commands/status.cjs +19 -14
  65. package/ultra-tools/commands/system.cjs +2 -2
  66. package/ultra-tools/commands/task.cjs +3 -0
@@ -1,109 +1,82 @@
1
1
  ---
2
2
  name: ultra-init
3
- description: Initialize a new repository, adopt an existing codebase, or migrate prior Ultra authority into a verified project baseline. Use when `.ultra` is absent, initialization is incomplete, baseline readiness is blocked, or a legacy Ultra project must be resumed.
3
+ description: Create or recover Ultra project authority for a new repository, an existing codebase, or an older Ultra installation. Use when `.ultra` is absent, initialization is incomplete, or doctor reports a migration or initialization fault.
4
4
  ---
5
5
 
6
- # Establish project authority
7
-
8
- Use host reasoning to inspect repository evidence and prepare baseline content. Use
9
- Ultra MCP for classification records, schema migration, workflow state, evidence
10
- digests, approval, and convergence. Never treat generated Markdown or JSON as state.
11
- Read `../ultra-think/references/decision-dialogue.md` before asking about repository
12
- scope, replacement authority, or another load-bearing owner choice.
13
-
14
- ## Classify without guessing product scope
15
-
16
- Run `system.doctor` read-only when `.ultra/state.db` exists. Otherwise call
17
- `task.init_project` with `mode: "auto"`, the repository root, project name, and an
18
- owner-selected monorepo scope when applicable.
19
-
20
- Interpret classification independently from readiness:
21
-
22
- - `greenfield`: no meaningful delivered application behavior exists outside docs,
23
- generated output, or a starter skeleton;
24
- - `brownfield`: source, runtime, deployment, API, schema, or test evidence shows an
25
- existing maintained system;
26
- - `migrated`: older DB or projection-only authority was preserved and must be
27
- replaced by an evidence-backed brownfield baseline.
28
-
29
- The presence of `.ultra/`, a manifest, or a Git repository does not make a baseline
30
- ready. Classification never chooses an MVP, reduced scope, or delivery posture.
31
- Report the detected project type, technology signals, verification commands, and
32
- monorepo roots. Pass an explicit `project_type` or `stack` only when repository evidence
33
- or an owner decision supports the override; MCP preserves both detection and selection.
34
- Inspect first and ask only one unresolved scope or replacement decision at a time. Do
35
- not request a complete project questionnaire during initialization.
36
-
37
- ## Resume safely
38
-
39
- When `.ultra/` exists, call `task.init_project` with `resume: true`. It must preserve
40
- existing artifacts, create a pre-migration backup when needed, upgrade the schema,
41
- install only missing assets, and return the durable workflow ids and exact route.
42
-
43
- For projection-only state, execute only the backup-first migration command returned by
44
- the structured error. For a `migrated` compatibility row, call `baseline.start` with a
45
- new brownfield id and `replace_migrated: true`; never treat migration as owner approval.
46
-
47
- Replacing a healthy baseline requires a new id plus `replace_ready: true` and explicit
48
- `replacement_authorization`. Preserve corrupt DB, WAL, SHM, and backups; use the
49
- documented restore or rebaseline command only after the owner selects that destructive
50
- recovery path.
51
-
52
- ## Follow durable initialization state
53
-
54
- Read the returned init and research runs with `workflow.get`.
55
-
56
- - `inspect-authority`: `task.init_project` records the bounded repository and existing
57
- Ultra evidence it inspected.
58
- - `classify-repository`: `task.init_project` records classification, detected signals,
59
- selected scope, and supported overrides.
60
- - `scaffold-authority`: `task.init_project` creates or resumes DB authority and installs
61
- only missing scaffold assets.
62
- - `establish-baseline`: research completion, `baseline.record`, and owner-approved
63
- `baseline.converge` establish the evidence-backed authority.
64
- - `verify-initialization`: convergence re-reads baseline, init, research, repository,
65
- verification, and output health before completing initialization.
66
-
67
- The first three steps are deterministic writes owned by `task.init_project`; the final
68
- two are completed atomically by successful baseline convergence. Do not mark or emulate
69
- these transitions in Prompt text or projection files.
70
-
71
- - Greenfield starts a `full` research run.
72
- - Brownfield starts an `adoption` research run.
73
- - Both modes require all seventeen research steps before baseline convergence.
74
- - A migrated project remains routed to re-adoption before research can authorize work.
75
-
76
- Continue through `ultra-research`. Research completion records output digests; then
77
- `baseline.record` captures current scope, revision, discovery/product/architecture
78
- specs, source and runtime evidence, actual verification, unknowns, gaps,
79
- classification, and external provider metadata references.
80
-
81
- Call `baseline.converge` only after the compact research checkpoint receives explicit
82
- owner approval; do not ask for the same approval twice. The MCP rejects missing
83
- research, missing discovery/product/architecture refs, stale evidence, revision or
84
- worktree drift, unaccepted known failures, blocking unknowns, and blocking gaps. A
85
- successful convergence atomically marks the baseline ready and completes the init run.
86
-
87
- ## Recovery
88
-
89
- - Record deterministic blockers on the current workflow; never create a parallel run.
90
- - Use `system.doctor` repair only for supported schema, projection, session, incident,
91
- archive, or legacy workflow-provenance recovery. A recovered legacy change workflow
92
- remains blocked for real baseline evidence; repair cannot invent research or approve
93
- a baseline.
94
- - Treat context budgets as advisory. Missing authority, evidence, output, or approval
95
- is blocking.
96
- - Store only references to external memory and code-graph providers.
97
-
98
- ## Completion
99
-
100
- Read `baseline.get`, `workflow.get`, and `system.doctor` after convergence. Report
101
- classification evidence, scope, revision, worktree snapshot, migration backups,
102
- research run and output health, verification, gaps, approval, and one route.
103
-
104
- Initialization is complete only when the baseline is `ready`, the init workflow is
105
- `completed`, the research workflow is `completed`, and
106
- `baseline.research_run_id` names that exact research run with healthy outputs. Route
107
- every newly converged or already initialized baseline through `ultra-change`; planning
108
- starts only after that command persists a complete Change Contract, profile, and
109
- research disposition. Otherwise return the exact current workflow step or blocker.
6
+ # Initialize project authority
7
+
8
+ Initialization is a bounded setup capability. It creates or repairs the repository and
9
+ Ultra authority; it does not perform product research, approve a baseline, or choose
10
+ the next semantic workflow.
11
+
12
+ ## Inspect before mutation
13
+
14
+ 1. Identify the repository root, existing `.ultra` state, Git state, meaningful source,
15
+ monorepo boundaries, and current owner request.
16
+ 2. If `.ultra/state.db` exists, run `system.doctor` read-only and resume with
17
+ `task.init_project` only when its report permits it.
18
+ 3. Otherwise call `task.init_project` with `mode: "auto"`, the project name, and an
19
+ explicit scope only when the repository contains multiple plausible roots.
20
+ 4. Leave `git_mode` as `auto` unless the user explicitly requires a non-Git workspace.
21
+
22
+ Use repository evidence to classify:
23
+
24
+ - `greenfield`: no meaningful delivered application behavior is present;
25
+ - `brownfield`: source, runtime, API, data, deployment, or tests describe an existing
26
+ maintained system;
27
+ - `migrated`: older Ultra authority was preserved but is not a trusted baseline.
28
+
29
+ The model may override an automatic classification only with evidence or an explicit
30
+ user decision. Classification must not infer product scope, an MVP, or a release plan.
31
+
32
+ ## Interaction boundary
33
+
34
+ Read `../ultra-think/references/decision-dialogue.md` before asking a material question.
35
+ Inspect observable facts yourself. Use the host's native question UI when available and
36
+ plain direct interaction otherwise. Ask only when repository scope, replacement of
37
+ healthy authority, destructive recovery, or another material owner decision is truly
38
+ unresolved. Normalize clear intent already present in the request without asking again.
39
+
40
+ ## Deterministic initialization contract
41
+
42
+ `task.init_project` owns these steps:
43
+
44
+ 1. `inspect-authority`
45
+ 2. `classify-repository`
46
+ 3. `scaffold-authority`
47
+ 4. `verify-initialization`
48
+
49
+ The operation must:
50
+
51
+ - create or migrate `.ultra/state.db` with a backup before schema migration;
52
+ - install only missing scaffold assets on resume;
53
+ - preserve existing artifacts and unrelated work;
54
+ - preserve an existing Git repository and HEAD;
55
+ - initialize Git and a safe `.gitignore` entry when Git is absent;
56
+ - report an unborn repository as `initial_commit_required` without manufacturing a
57
+ commit, remote, tag, or push;
58
+ - read back the created DB, classification, projection, and Git result before
59
+ completing the init workflow.
60
+
61
+ Projection-only projects must use the exact backup-first migration command returned by
62
+ the runtime. A migrated compatibility baseline requires a new brownfield adoption with
63
+ `replace_migrated: true`. Replacing a healthy baseline requires explicit replacement
64
+ authority. Corrupt DB, WAL, SHM, and backups must be preserved until the user chooses a
65
+ documented recovery operation.
66
+
67
+ ## Completion and handoff
68
+
69
+ Initialization is complete when the init workflow is `completed`, the current schema is
70
+ healthy, the scaffold is readable, and repository classification and Git state are
71
+ durable. Research status may still be `not_started`; that is not incomplete init.
72
+
73
+ Read the returned `allowed_transitions` and `required_transition`:
74
+
75
+ - a required transition represents a hard recovery invariant and must be followed;
76
+ - otherwise the host model recommends among the allowed capabilities using the user's
77
+ goal and current evidence;
78
+ - start `ultra-research` only when the user invoked it or the host selects it after init.
79
+
80
+ Report classification, scope, schema and backup result, Git state, init workflow id,
81
+ baseline state, and allowed transitions. Do not claim that a baseline is ready until a
82
+ separate research/adoption workflow has recorded and converged it.
@@ -1,103 +1,82 @@
1
1
  ---
2
2
  name: ultra-plan
3
- description: Convert a ready Ultra baseline or approved active-change delta into dependency-valid, DB-backed execution contracts and fresh-context vertical slices. Use when accepted requirements are ready for implementation planning or an existing plan must be resumed and verified.
3
+ description: Turn an accepted Ultra Change Contract into dependency-valid, DB-backed vertical task contracts. Use when research obligations are resolved and implementation needs an executable plan.
4
4
  ---
5
5
 
6
- # Review and persist an executable plan
7
-
8
- Use host reasoning for decomposition, tradeoffs, and approval. Use Ultra MCP for
9
- workflow position, decision authority, task contracts, graph validation, projection,
10
- and recovery. Read `../ultra-think/references/decision-dialogue.md` before presenting a
11
- planning choice.
12
-
13
- ## Bind authority
14
-
15
- 1. Call `system.doctor`, `baseline.get`, `change.list`, and `change.breadcrumb`.
16
- 2. Require a current ready baseline for new ordinary work. Resume an already-authorized
17
- active change when appropriate; an incident uses only its recorded break-glass
18
- authority.
19
- 3. Ensure exactly one active change owns the plan. For initial implementation, open a
20
- standard or major change from the accepted baseline before creating tasks.
21
- 4. Read `references/semantic-preflight.md`. Resolve every blocking Change decision and
22
- complete the exact recorded bounded research selection before starting the plan.
23
- 5. Resume the active `plan` workflow from `workflow.list`, or call `workflow.start`
24
- with its `baseline_id`, `change_id`, subject, and source refs.
25
-
26
- ## Build a candidate before writing authority
27
-
28
- Inspect requirements, source, consumers, state, tests, deployment, and recovery before
29
- drafting slices. Build the candidate plan privately. Separate evidence-backed design
30
- detail from choices that change accepted scope, public behavior, compatibility, cost,
31
- risk, delivery semantics, or recovery.
32
-
33
- When a material planning decision remains, start or resume a decision thread bound to
34
- the plan workflow. Present exactly one decision with the recommendation, credible
35
- alternatives, and the tasks or contracts it changes, then STOP. The plan document is
36
- the result of this review; never use a large plan dump as a substitute for interaction.
37
-
38
- After all blocking choices are resolved, prepare one checkpoint. Present the compact
39
- topology, public seams, recovery, and material tradeoffs for approval. After approval,
40
- write the evidence-linked `plan.md`, confirm the checkpoint with its digest, and reuse
41
- that same approval for the durable `approve-plan` and workflow completion gates.
42
-
43
- ## Record the durable steps
44
-
45
- Record each completed step with `workflow.step`:
46
-
47
- 1. `validate-baseline`: verify baseline and completed research provenance.
48
- 2. `select-posture`: preserve the owner-approved scope and delivery posture. Never
49
- infer an MVP, reduction, phase, or exclusion. Ask only when a proposed plan changes
50
- accepted scope, cost, risk, compatibility, or delivery semantics.
51
- 3. `analyze-requirements`: trace stable requirement ids to acceptance and public seams.
52
- 4. `analyze-codebase`: inspect current entry points, consumers, patterns, state
53
- authority, tests, deployment, and recovery paths before designing new structure.
54
- 5. `design-slices`: design a walking skeleton and subsequent vertical slices. Every
55
- slice must reach a real consumer; include validation, side effects, errors,
56
- documentation, migration, observability, and recovery in the owning slice.
57
- 6. `validate-dependencies`: validate ownership, missing dependencies, cycles, conflict
58
- surfaces, and meaningful integration checkpoints.
59
- 7. `approve-plan`: persist the already obtained checkpoint approval; do not ask again.
60
-
61
- ## Persist complete task contracts
62
-
63
- Only after the plan checkpoint is confirmed, call `task.create` for each approved task
64
- with:
65
-
66
- - one observable `outcome` and stable `trace_to`;
67
- - `slice_kind`, `public_seam`, and exact `verification_command`;
68
- - structured `acceptance` items with their verification;
69
- - bounded `context_refs` with reasons;
70
- - resolved `docs_impact` and durable `ownership`;
71
- - dependencies, affected files when known, estimates only when evidence supports them,
72
- and the owning `change_id`.
73
-
74
- Copy each Change acceptance id into at least one task acceptance item without changing
75
- its meaning. Set `trace_to` to that accepted id, a current research semantic id, or a
76
- real project-relative Markdown `path#anchor`. A quick profile has exactly one task.
77
- The MCP derives the coverage matrix and rejects uncovered acceptance, orphan tasks,
78
- stale research, and oversized quick plans.
79
-
80
- Never read or write `.ultra/tasks.json` or generated context Markdown as authority.
81
- The DB owns the task contract and the projector regenerates both views.
82
- `persist-task-contracts` completes only after `task.get` reads every field back without
83
- a contract blocker.
84
-
85
- Call `task.dependency_topo` with the current `change_id`, then call
86
- `plan.export` with `change_id`, `format: "json"`, and
87
- `out_path: ".ultra/execution-plan.json"`. Export records `plan_exported`; it does
88
- not approve the plan. Read the same change back with `plan.get`.
89
- The exported artifact is change-bound and may not include tasks from another active
90
- or historical change. Recompile `change.context`
91
- for the first task; it derives its execution contract and context refs from DB and
92
- rejects a conflicting prompt override. Missing required refs block readiness; context
93
- size is advisory.
94
-
95
- Record `verify-plan` with `.ultra/execution-plan.json` as its sole output, then call
96
- `workflow.complete` with
97
- `approval.approved_by` and `approval.approval_note`. Do not send a task summary: MCP
98
- derives the complete task set from every task owned by the change. Completion
99
- revalidates every task contract, change ownership, dependency existence, graph cycles,
100
- the exact exported topology, approval, and current output digests; it also advances
101
- the linked change workflow to context compilation.
102
- Return the persisted topology, first task/public seam,
103
- approval evidence, plan workflow id, and one `ultra-dev` route.
6
+ # Build an executable plan
7
+
8
+ The model owns decomposition and technical design. MCP owns plan state, task contracts,
9
+ dependency integrity, output digests, and recovery. Planning must stay inside the
10
+ accepted Change Contract without adding ceremonial approval.
11
+
12
+ ## Bind current authority
13
+
14
+ 1. Read doctor, baseline, change, decisions, existing plan runs, tasks, and current
15
+ checkout.
16
+ 2. Require one mutable change with a healthy baseline or recorded incident bypass.
17
+ 3. Complete the exact change-bound research disposition before planning.
18
+ 4. Resume the matching plan run or start one bound to the change and baseline.
19
+
20
+ Read `references/semantic-preflight.md` and inspect requirements, real consumers,
21
+ state, tests, deployment, and recovery paths.
22
+
23
+ ## Design with model autonomy
24
+
25
+ Build a candidate plan privately. Ask the user only if the plan would change accepted
26
+ scope, public behavior, compatibility, security, material cost, external effects, or
27
+ recovery. Use the host's native question UI when available and the interaction protocol
28
+ in `../ultra-think/references/decision-dialogue.md`.
29
+
30
+ When the candidate remains inside the accepted Change Contract, proceed without a
31
+ second approval. A user may still request a plan review before persistence; that is an
32
+ interaction preference, not a runtime invariant.
33
+
34
+ Record:
35
+
36
+ 1. `validate-baseline`
37
+ 2. `analyze-requirements`
38
+ 3. `analyze-codebase`
39
+ 4. `design-slices`
40
+ 5. `validate-dependencies`
41
+ 6. `persist-task-contracts`
42
+ 7. `verify-plan`
43
+
44
+ Design a walking skeleton and subsequent vertical slices. Every slice reaches a real
45
+ consumer and owns its validation, side effects, errors, documentation, migration,
46
+ observability, and recovery obligations. Avoid unconsumed horizontal scaffolding.
47
+
48
+ ## Persist task contracts
49
+
50
+ Create each task with:
51
+
52
+ - observable outcome and stable trace;
53
+ - `slice_kind`, public seam, and exact verification command;
54
+ - structured acceptance mapped to Change acceptance ids;
55
+ - bounded context refs and reasons;
56
+ - documentation impact, ownership, dependencies, and affected files when known.
57
+
58
+ Use estimates only when evidence supports them. A quick change has exactly one task.
59
+ Read every task back from DB. Never read or write `.ultra/tasks/tasks.json` directly;
60
+ it is a generated projection, not authority.
61
+
62
+ If a semantic `change.update` invalidated existing tasks, reconcile every affected
63
+ task contract against the current intent, acceptance, decisions, and research
64
+ evidence. Rebind the complete execution contract while clearing `stale` through
65
+ `task.update`; MCP rejects a marker-only clear, validates the read-back, and records
66
+ the current Change authority digest. Never clear staleness merely to pass a gate.
67
+
68
+ Validate the change-scoped graph with `task.dependency_topo`. Export
69
+ `.ultra/execution-plan.json` with `plan.export`, read it through `plan.get`, and record
70
+ it as the `verify-plan` output.
71
+
72
+ Call `workflow.complete`. `approval` is optional: include it only when a material plan
73
+ decision actually required and received user approval. MCP derives task coverage and
74
+ topology from DB and must reject incomplete contracts, uncovered acceptance, cycles,
75
+ cross-change tasks, stale research, or a mismatched export.
76
+
77
+ Do not advance or complete the Change workflow; change capture is already complete.
78
+ Compile task context later for the consumer that needs it.
79
+
80
+ Return topology, first executable slices, public seams, verification commands, plan
81
+ workflow id, and allowed transitions. The host may recommend parallel or sequential
82
+ execution based on dependency and conflict evidence.