ultra-builder-pro-cli 0.21.1 → 0.23.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 (58) hide show
  1. package/.ultra-template/tasks/tasks.json +10 -3
  2. package/.ultra-template/templates/task-context.md +19 -0
  3. package/CHANGELOG.md +78 -0
  4. package/README.md +210 -36
  5. package/adapters/_shared/codex-assets.cjs +8 -3
  6. package/adapters/_shared/interaction-contract.cjs +13 -6
  7. package/adapters/_shared/runtime-assets.cjs +1 -1
  8. package/adapters/claude.js +1 -1
  9. package/adapters/kimi.js +1 -1
  10. package/adapters/opencode.js +24 -13
  11. package/docs/AGENT-CONTEXT.md +58 -51
  12. package/docs/ARCHITECTURE.md +82 -51
  13. package/docs/ARTIFACT-AUTHORITY.md +83 -44
  14. package/docs/COMMIT-HASH-BACKFILL.md +33 -90
  15. package/docs/DECISIONS.md +9 -7
  16. package/docs/LEGACY-CLI-CROSSWALK.md +10 -2
  17. package/docs/PLUGIN-ISOLATION-CONTRACT.md +3 -2
  18. package/docs/ROADMAP.md +3 -3
  19. package/docs/RUNTIME-COMPAT-MATRIX.md +13 -10
  20. package/docs/STATE-DB-ACCESS-POLICY.md +47 -19
  21. package/docs/WORKFLOW-LIFECYCLE.md +79 -49
  22. package/hooks/README.md +5 -4
  23. package/hooks/active_task_context.py +41 -39
  24. package/mcp-server/lib/artifact-registry.cjs +32 -7
  25. package/mcp-server/lib/baseline-workflow.cjs +60 -24
  26. package/mcp-server/lib/change-workflow.cjs +42 -6
  27. package/mcp-server/lib/context-paths.cjs +34 -3
  28. package/mcp-server/lib/doctor.cjs +28 -0
  29. package/mcp-server/lib/git-bootstrap.cjs +0 -1
  30. package/mcp-server/lib/init-project.cjs +52 -2
  31. package/mcp-server/lib/projector.cjs +43 -8
  32. package/mcp-server/lib/state-authority.cjs +19 -3
  33. package/mcp-server/lib/state-ops.cjs +6 -1
  34. package/mcp-server/lib/task-ledger.cjs +1342 -0
  35. package/mcp-server/lib/ultra-facade.cjs +646 -0
  36. package/mcp-server/lib/workflow-state.cjs +166 -2
  37. package/mcp-server/server.cjs +214 -26
  38. package/package.json +1 -1
  39. package/skills/ultra-change/SKILL.md +38 -90
  40. package/skills/ultra-deliver/SKILL.md +42 -62
  41. package/skills/ultra-dev/SKILL.md +34 -73
  42. package/skills/ultra-doctor/SKILL.md +26 -39
  43. package/skills/ultra-init/SKILL.md +37 -69
  44. package/skills/ultra-plan/SKILL.md +52 -125
  45. package/skills/ultra-research/SKILL.md +41 -101
  46. package/skills/ultra-review/SKILL.md +25 -44
  47. package/skills/ultra-status/SKILL.md +21 -40
  48. package/skills/ultra-test/SKILL.md +25 -60
  49. package/skills/ultra-think/SKILL.md +29 -48
  50. package/skills/ultra-think/references/decision-dialogue.md +6 -4
  51. package/spec/cli-protocol.md +15 -0
  52. package/spec/mcp-tools.yaml +286 -0
  53. package/spec/schemas/context-file.v4.5.schema.json +1 -1
  54. package/spec/schemas/mcp-tools.schema.json +1 -1
  55. package/spec/schemas/state-db.sql +1 -1
  56. package/spec/schemas/task-ledger.v1.schema.json +217 -0
  57. package/ultra-tools/commands/migrate.cjs +5 -2
  58. package/.ultra-template/tasks/contexts/TEMPLATE.md +0 -19
@@ -3,97 +3,45 @@ name: ultra-change
3
3
  description: Capture or revise one bounded feature, fix, redesign, or incident contract against a ready Ultra baseline. Use when post-baseline work needs accepted intent before research, planning, or implementation.
4
4
  ---
5
5
 
6
- # Capture accepted change intent
6
+ # Capture accepted Change intent
7
7
 
8
- Change is the durable unit that connects later research, plan, implementation,
9
- verification, review, and baseline reconciliation. Capturing a change does not start
10
- those workflows or compile execution context.
11
-
12
- Read `../ultra-think/references/decision-dialogue.md` before asking a material question.
8
+ A Change is the durable unit connecting research, plan, implementation, verification,
9
+ review, documentation, and delivery. Its draft stays editable until a semantic
10
+ checkpoint accepts the downstream authority.
13
11
 
14
12
  ## Inspect and align
15
13
 
16
- 1. Read `system.doctor`, `baseline.get`, active changes, breadcrumb `accepted_intent`,
17
- decisions, and `change.breadcrumb`.
18
- 2. Resume an existing change that matches the request. Do not duplicate authority.
19
- 3. Ordinary work requires a healthy ready baseline. An incident may use only an
20
- explicit `baseline_bypass` reason and approver; urgency is not approval.
21
- 4. Inspect the checkout and accepted baseline before asking the user. Resolve code and
22
- runtime facts yourself.
23
- 5. Convert the request into a Change Contract:
24
- - observable outcome and executable acceptance;
25
- - non-goals and public seams;
26
- - recovery strategy and verification;
27
- - unresolved material decisions;
28
- - documentation impact;
29
- - change kind and evidence-backed risk flags;
30
- - research disposition.
31
-
32
- Recommend `quick`, `standard`, `major`, or `incident` from actual scope and risk,
33
- together with the research disposition. A quick change may have no material risk,
34
- research obligation, or more than one task. MCP may reject a profile that contradicts
35
- hard risk invariants; it does not choose a replacement.
36
-
37
- After `change.create` or `change.update`, read back the complete Change Contract. When
38
- that write applies a durable decision, complete the decision thread with the change
39
- reference in `applied_refs`.
40
-
41
- Ask only when a choice changes accepted product intent, scope, public behavior,
42
- compatibility, security, material cost, external effects, or recovery. Use the host's
43
- native question UI when available. Normalize clear choices already in the user's
44
- request. When profile or research posture remains unresolved, present the recommended
45
- route and credible alternatives through that same UI, then stop. The user selects,
46
- modifies, delegates, or defers the semantic route. The model owns reversible
47
- implementation detail inside the accepted contract.
48
-
49
- ## Persist the contract
50
-
51
- When a durable alignment checkpoint is necessary, bind it to a compact artifact and
52
- pass its id as `alignment_thread_id`. Do not require a checkpoint for a complete,
53
- unambiguous request that already provides current authority.
54
-
55
- Call `change.create`. It records and completes exactly:
56
-
57
- 1. `bind-baseline`
58
- 2. `classify-change`
59
- 3. `record-intent`
60
-
61
- The returned change workflow must be `completed`; research, plan, context, dev, test,
62
- review, and deliver remain independent capabilities. Keep every Change-owned semantic
63
- artifact, finding, plan, context, test result, review result, documentation update,
64
- and progress projection below `.ultra/changes/active/<id>/`. Incidents maintain the
65
- structured diagnosis artifact there as well.
66
-
67
- Before planning a standard or major change, write the accepted specification updates
68
- to the Change overlay and call `change.delta` with exact baseline id, repository
69
- revision, specification digests, decisions, non-goals, acceptance, documentation
70
- impact, unknowns, and mutation before/after digests. If accepted behavior truly does
71
- not change baseline semantics, record an empty typed delta with a specific
72
- `no_semantic_change_reason`; do not manufacture a mutation. Read back the registered
73
- delta and deterministic `progress.md`. This records proposed authority only and must
74
- not edit baseline specifications.
75
-
76
- Use `change.update` when accepted intent or evidence changes. Update the Change
77
- Contract, classification, research disposition, and docs impact together when their
78
- meaning is coupled. Downstream task, context, test, or review evidence affected by that
79
- change must become stale and be regenerated; never keep old evidence green by prompt
80
- assertion.
81
-
82
- If research is required, recommend `ultra-research` with the recorded disposition. If
83
- the contract is sufficiently evidenced, finish the typed delta and recommend
84
- `ultra-plan`. Direct Build skips Research only; it never skips Plan, DB-backed task
85
- contracts, or fresh task context. Return and wait for an explicit user invocation; do
86
- not start another workflow. `change.context` is compiled only for an actual plan,
87
- implementation, test, or review consumer.
88
-
89
- Stable implementation discoveries use the approval-gated specification-learning
90
- transitions. External memory and graph providers retain their own content; Ultra stores
91
- metadata references only.
92
-
93
- Return the normalized contract, change id and kind, research disposition, blockers,
94
- and `allowed_transitions`. Recommend a semantic next action from those transitions.
95
- If current intent does not already select it, present the recommendation and credible
96
- alternatives through the interaction protocol, then wait. MCP does not encode a
97
- semantic next action.
98
-
99
- Never invoke the recommended capability here; wait for an explicit user invocation.
14
+ 1. Call `ultra.context { stage: project, detail: full }`.
15
+ 2. Inspect or import the team checkpoint with `ultra.sync`. Stop only on a real
16
+ baseline, Change, task, ancestry, or active-session conflict.
17
+ 3. Reuse an existing matching Change. Do not duplicate authority.
18
+ 4. Convert the request into observable outcome, executable acceptance, non-goals,
19
+ public seams, recovery, verification, documentation impact, risk, and research
20
+ disposition.
21
+ 5. Recommend `quick`, `standard`, `major`, or `incident` from evidence. Ask only when
22
+ a choice changes accepted product intent, compatibility, security, material cost,
23
+ external effects, or recovery.
24
+
25
+ Read `../ultra-think/references/decision-dialogue.md` before asking. MCP may report
26
+ contradictory risk fields, but the model and owner choose the semantic correction.
27
+
28
+ ## Record the contract
29
+
30
+ Use one `ultra.record` batch for `change.create` or `change.update`, relevant
31
+ `decision.*`, and `change.delta` when the delta is already known. Every entry carries
32
+ a stable idempotency key. Read the result through `ultra.context`.
33
+
34
+ Keep every Change-owned semantic artifact below
35
+ `.ultra/changes/active/<change-id>/`. Standard and major Changes require a typed delta
36
+ before planning. A true no-semantic-change case records an explicit reason instead of
37
+ manufacturing a mutation.
38
+
39
+ Changing accepted intent reopens the draft and makes only genuinely dependent evidence
40
+ stale. `ready` is not an absorbing state. A semantic rejection returns diagnostics;
41
+ repair and retry the same draft. Use `workflow.abandon` only to preserve and cancel an
42
+ attempt intentionally.
43
+
44
+ Publish the durable Change contract with `ultra.sync { action: publish }` when it is a
45
+ useful team handoff. Recommend bounded `ultra-research` for a real evidence gap or
46
+ `ultra-plan` when the contract is sufficiently evidenced. Do not invoke the next
47
+ capability automatically.
@@ -1,68 +1,48 @@
1
1
  ---
2
2
  name: ultra-deliver
3
- description: Converge a verified Ultra change, reconcile baseline specifications, and archive it with recoverable local evidence. Use when implementation, testing, and review are current.
3
+ description: Converge a verified Ultra Change, reconcile baseline specifications, and archive it with recoverable local evidence. Use when implementation, testing, and review are current.
4
4
  ---
5
5
 
6
6
  # Converge and archive local authority
7
7
 
8
- Delivery closes Ultra's local change authority. It does not grant or perform commit,
9
- push, tag, registry publication, deployment, or another external effect.
10
-
11
- ## Bind current evidence
12
-
13
- 1. Read doctor, baseline, change, breadcrumb `accepted_intent`, decisions, tasks, test,
14
- review, learning, and current checkout.
15
- 2. Resume or start a deliver workflow bound to the change and baseline.
16
- 3. Require complete task evidence, a current test report, both review axes, current
17
- context, and resolved material decisions. Record `bind-evidence`.
18
-
19
- Evidence from another revision, task set, or change is invalid.
20
-
21
- ## Reconcile specifications
22
-
23
- Resolve every specification-learning candidate. Apply approved learning to its target
24
- inside the Change overlay; preserve rejection reasons. Read the current registered
25
- `change.delta` and verify every baseline anchor, payload digest, acceptance reference,
26
- and unknown.
27
-
28
- Write documentation updates below
29
- `.ultra/changes/active/<change-id>/documentation/`. Call
30
- `change.documentation_reconcile` for every Change: bind the current delta id and
31
- digest, exact before/after document digests, delta and acceptance references,
32
- verification, and each verified consumer. When no documentation changes, record an
33
- empty reconciliation with a specific `no_change_reason`. An unexplained orphan
34
- document is blocking. Record `reconcile-specifications`.
35
-
36
- Compile final convergence context and run the risk-selected candidate checks, install
37
- or doctor smoke when this change modifies distributed assets, public-seam verification,
38
- and recovery sanity. Record the immutable context under `verify-candidate`.
39
-
40
- Call `change.converge`; MCP derives readiness from durable dev, test, review,
41
- typed delta, documentation reconciliation, diagnosis, and current checkout evidence.
42
- Record
43
- `converge-authority` only when ready.
44
-
45
- Call `change.archive` with the summary. MCP preflights all target before states and
46
- overlay digests, applies the complete packet atomically, refreshes baseline authority,
47
- rebinds every registered artifact into the self-contained archive, and rolls back or
48
- resumes from its transaction journal after interruption. A partial success is not
49
- delivery. Verify the refreshed baseline and archived packet, then record
50
- `archive-change`.
51
-
52
- Write `<archived-change-root>/delivery/<workflow-id>/report.json` with
53
- `ultra-delivery-report-v1`: archived change, baseline, HEAD, worktree and context
54
- digests, local checks, rollback notes, and timestamp. The report must not contain a
55
- release decision. Record it under `verify-delivery` and complete the workflow.
56
-
57
- ## External effects
58
-
59
- If the user separately requests commit, push, tag, publish, or deploy, handle that as a
60
- host-owned effect after Ultra delivery. Confirm only missing material authority, run
61
- the repository's release checks, and report remote evidence separately. Never infer an
62
- external effect from `ultra-deliver`, and never encode it as completed Ultra delivery
63
- state.
64
-
65
- Return archive and baseline state, evidence digests, recovery notes, residual risks,
66
- and allowed transitions.
67
-
68
- Never invoke the recommended capability here; wait for an explicit user invocation.
8
+ Delivery closes local Ultra authority. It never grants commit, push, tag, registry
9
+ publication, deployment, or another external effect.
10
+
11
+ ## Prepare the packet
12
+
13
+ 1. Call `ultra.context { stage: deliver, scope: { change_id }, detail: full }`.
14
+ 2. Import a newer team checkpoint with `ultra.sync`; stop on a real conflict.
15
+ 3. Require current task outcomes, test report, both review axes, accepted decisions,
16
+ typed delta, documentation reconciliation, and current checkout evidence.
17
+ 4. Resolve every specification-learning candidate. Keep updates inside the Change
18
+ overlay until archive.
19
+ 5. Write and register documentation reconciliation and an
20
+ `ultra-delivery-report-v1` report. The report binds Change, baseline, HEAD,
21
+ worktree/context digests, local checks, rollback guidance, and timestamp; it contains
22
+ no release decision.
23
+
24
+ Use one `ultra.record` batch for the reconciliation, report artifact, learning
25
+ resolutions, and other durable facts.
26
+
27
+ ## Archive once
28
+
29
+ Call `ultra.archive` once with the Change id, stable idempotency key, archive summary,
30
+ reconciliation fields, delivery evidence steps, and report output. The operation
31
+ internally:
32
+
33
+ - compiles or reuses convergence context;
34
+ - checks the deliver draft;
35
+ - derives convergence from current dev, test, review, delta, docs, and checkout;
36
+ - applies the overlay and archive through the recoverable filesystem/DB transaction;
37
+ - rebinds registered artifacts into a self-contained archive;
38
+ - completes the durable delivery checkpoint;
39
+ - publishes the updated team checkpoint.
40
+
41
+ A semantic rejection returns mutable blockers. Repair the same packet and retry. A
42
+ hard corruption, path, concurrency, or recovery error remains fail-closed and routes to
43
+ `ultra-doctor`.
44
+
45
+ Verify the archived packet, baseline, checkpoint, and rollback state. Handle any
46
+ separately authorized Git or release effect only after local delivery and report it as
47
+ external evidence, not Ultra delivery authority. Do not invoke another capability
48
+ automatically.
@@ -5,87 +5,48 @@ description: Implement one authoritative Ultra task through a fresh-context, tes
5
5
 
6
6
  # Implement one task
7
7
 
8
- The host model owns code reasoning and edits. Ultra owns the task and workflow state,
9
- fresh context contract, session lease, evidence references, and recovery.
8
+ The model owns code reasoning and edits. Ultra owns the durable task contract, current
9
+ Context Manifest, execution lease, evidence references, and checkpoint.
10
10
 
11
- ## Bind and resume
11
+ ## Bind execution
12
12
 
13
- 1. Read doctor, breadcrumb `accepted_intent`, active decisions, task contract,
14
- dependencies, dev runs, sessions, HEAD, and worktree.
15
- 2. Resume the matching dev run or start one with `change_id` and `task_id`.
16
- 3. Record `bind-task` with current authority and dependency evidence.
17
- 4. Compile `change.context` with `role: implement` and `gate: implementation`. The
18
- public seam, verification command, and context refs come from the DB-backed task
19
- contract; update that contract before compilation instead of overriding it in the
20
- call. Persist any changed external-provider metadata with `change.update` first.
21
- Context compilation itself is read-only with respect to Change and provider
22
- authority.
23
- 5. Confirm the manifest contains the selected task, its direct dependencies, direct
24
- dependents needed for integration, and relevant integration checkpoints—not the
25
- entire task graph. Referenced file bodies stay lazy. The token estimate includes
26
- inline Change/task authority as well as file estimates; budget overflow is
27
- advisory, while a missing or stale required reference is blocking. Record the
28
- immutable manifest as `compile-context`.
29
- 6. Reuse an existing valid session. Otherwise pass admission and call `session.spawn`.
30
- Work only in the returned worktree and preserve unrelated changes.
13
+ 1. Call `ultra.context { stage: dev, scope: { change_id, task_id }, detail: full }`.
14
+ 2. Import a newer team checkpoint with `ultra.sync`; stop on a real same-record or
15
+ active-session conflict.
16
+ 3. Reuse a valid lease or call `ultra.session { action: admission }`, then
17
+ `ultra.session { action: acquire }`. Work only in the returned worktree.
18
+ 4. Confirm purpose, acceptance, dependencies, public seam, verification command,
19
+ non-goals, recovery, and required context refs. Update the task contract before
20
+ implementation when accepted intent changed.
31
21
 
32
- Do not spawn recursively from a parent-owned worker session. Process exit is transport
33
- evidence, never task completion.
22
+ ## Implement adaptively
34
23
 
35
- ## Focused inner loop
24
+ Reproduce the failure, write a failing test, or establish a characterization signal
25
+ before changing logic. Implement the smallest complete vertical slice. Ask the owner
26
+ only when new evidence changes product intent, compatibility, security, material cost,
27
+ external effects, or recovery.
36
28
 
37
- 1. Reproduce the bug, write a failing test, or establish a characterization signal
38
- before a logic change. Record `establish-feedback-loop`.
39
- 2. Mark the task `in_progress` and implement the smallest complete slice through the
40
- declared public seam.
41
- 3. Keep the loop adaptive. The model may choose implementation details inside the
42
- accepted contract. If new evidence changes product intent, compatibility, security,
43
- material cost, external effects, or recovery, use the host's native question UI and
44
- the decision protocol; do not ask about ordinary reversible details.
45
- 4. Record `implement-slice`, then run focused tests plus the adjacent checks justified
46
- by the task risk. Record exact results under `verify-slice`.
47
- 5. Run a task-scoped independent review on specification fidelity and relevant
48
- engineering risks. Record `review-slice`. Fix blocking findings and refresh affected
49
- evidence.
50
- 6. Create the authorized local task commit. Do not push, publish, tag, or deploy unless
51
- the user separately authorized that external effect.
29
+ Use `ultra.record` batches for task status, bounded events, artifacts, decisions, and
30
+ documentation candidates. Live ownership, `in_progress`, session ids, leases,
31
+ worktrees, telemetry, and completion hashes remain local runtime state; durable task
32
+ outcome and evidence may enter the team checkpoint.
52
33
 
53
- Treat the compiled task-context contract as the handoff boundary: purpose, why,
54
- constraints, non-goals, target seams/files, pattern refs, acceptance, documentation
55
- impact, recovery, and definition of drift. If accepted intent, the task contract, or a
56
- digest-bound reference changes, update the owning authority and recompile rather than
57
- continuing from a stale packet.
34
+ Run focused and adjacent risk-justified checks, then a task-scoped independent review.
35
+ Fix blocking findings and refresh affected evidence.
58
36
 
59
- Keep implementation findings and documentation candidates inside the owning Change
60
- root. When code changes invalidate or extend maintained documentation, update the
61
- Change documentation overlay and its evidence rather than editing accepted baseline
62
- specifications. Hooks may remind the host to reconcile documentation; they must not
63
- block ordinary development or choose the semantic update.
37
+ ## Commit one semantic checkpoint
64
38
 
65
- Task-level tests and review belong to this inner loop. They do not replace aggregate
66
- change testing or review when multiple slices, integrations, or broader risks require
67
- those capabilities.
39
+ Call `ultra.checkpoint` once with `stage: dev`, the exact Change/Task scope, evidence,
40
+ and stable idempotency key. It compiles or reuses the implementation Context Manifest
41
+ and validates the durable outcome. A rejection leaves the draft mutable.
68
42
 
69
- ## Complete or recover
43
+ After acceptance, mark the task durably completed, publish with `ultra.sync`, and
44
+ create at most one authorized local task commit containing code and semantic
45
+ artifacts. Record its SHA only in local state; never create a bookkeeping commit.
70
46
 
71
- In direct mode, integrate the task commit through the repository's accepted path,
72
- verify ancestry and the public seam, close the session, update the task to `completed`,
73
- record `record-completion`, and complete the dev workflow.
47
+ Release the lease through `ultra.session`. Preserve a dirty or unintegrated worktree
48
+ on interruption. Commit, push, tag, publish, deploy, or destructive cleanup require
49
+ separate owner authority.
74
50
 
75
- Change convergence revalidates the exact latest
76
- `change_id + task_id + implement + implementation` snapshot for every executable
77
- task. A newer review, test, or plan packet cannot substitute for it.
78
-
79
- In a parent-supervised worker, record completion evidence and exit without closing the
80
- parent-owned lease. The primary host verifies the exact session commit, performs any
81
- integration, refreshes review if the reviewed checkout changed, settles the lease, and
82
- completes the workflow.
83
-
84
- Preserve worktrees by default. Remove one only when Git proves it is clean and
85
- integrated. On interruption, record the current step and task as blocked, preserve
86
- worktree and evidence, and resume the same run later.
87
-
88
- Return outcome, changed paths, public seam, exact checks, review axes, commit and
89
- session state, residual risk, and allowed transitions.
90
-
91
- Never invoke the recommended capability here; wait for an explicit user invocation.
51
+ Return changed paths, public seam, exact checks, review result, checkpoint, commit,
52
+ session state, and residual risk. Do not invoke the next capability automatically.
@@ -1,54 +1,41 @@
1
1
  ---
2
2
  name: ultra-doctor
3
- description: Diagnose and mechanically recover Ultra schema, workflow, projection, session, archive, hook, and installed-asset faults. Use when authority is degraded, stale, contradictory, or unavailable.
3
+ description: Diagnose and mechanically recover Ultra schema, projection, session, archive, hook, and installed-asset faults. Use when authority is degraded, contradictory, or unavailable.
4
4
  ---
5
5
 
6
6
  # Diagnose before repair
7
7
 
8
- Doctor owns deterministic health and supported recovery. It cannot decide product
9
- scope, invent evidence, approve a baseline, answer a user decision, or mark semantic
10
- work complete.
8
+ Doctor owns deterministic health and supported recovery. It cannot choose product
9
+ scope, invent evidence, accept a baseline, resolve a user decision, or declare
10
+ semantic work complete.
11
11
 
12
- ## Read-only diagnosis
12
+ ## Diagnose
13
13
 
14
- Run `system.doctor` without repair and inspect:
14
+ Call `ultra.doctor { repair: false }` and inspect:
15
15
 
16
- - SQLite integrity, schema 20 migration, required tables, and backups;
17
- - artifact registration, ownership, digest freshness, dependency edges, consumers,
18
- and orphan or duplicate authority;
19
- - baseline and research provenance, gaps, digests, and Git/worktree drift;
20
- - workflow status, obsolete-step migration, blockers, and output freshness;
21
- - decisions and checkpoint artifact freshness;
22
- - projection jobs and event cursors;
23
- - sessions, preserved worktrees, incidents, circuit state, and archive journals;
24
- - external provider boundaries.
16
+ - SQLite integrity, schema, backups, WAL/SHM, and migration state;
17
+ - artifact ownership, digest freshness, edges, orphans, and duplicate authority;
18
+ - team-checkpoint ancestry and real concurrent record conflicts;
19
+ - projection jobs, sessions, leases, worktrees, and recovery journals;
20
+ - installed plugin assets, MCP startup, and hook paths.
25
21
 
26
- An expected workflow pause or awaiting user decision is a warning, not corruption.
27
- Missing or changed required evidence is an authority failure but cannot be reconstructed
28
- by doctor.
22
+ An expected workflow pause, editable draft, failed semantic checkpoint, or awaiting
23
+ owner decision is a warning, not corruption.
29
24
 
30
- ## Recovery boundary
25
+ ## Repair
31
26
 
32
- With explicit repair authorization, `system.doctor` may:
27
+ With explicit repair authority, call `ultra.doctor { repair: true }`. It may apply
28
+ backup-first schema migration, regenerate local projections, recover supported
29
+ journals, reconcile orphan sessions, and repair installed mechanical assets.
33
30
 
34
- - apply backup-first supported schema migrations;
35
- - migrate incompatible rigid workflows into recoverable adaptive state;
36
- - requeue or regenerate projections from healthy DB authority;
37
- - reconcile orphan sessions without deleting unrelated or dirty worktrees;
38
- - resume supported archive journals;
39
- - recover missing workflow provenance as a blocked run requiring real evidence.
31
+ It may not manufacture semantic evidence, import or publish a team checkpoint, replace
32
+ a healthy baseline, resolve decisions, edit application code, or force a draft to
33
+ accepted. Use `ultra.sync` for reviewed checkpoint import/publish and
34
+ `workflow.abandon` through `ultra.record` for intentional draft cancellation.
40
35
 
41
- It may not create a Git checkpoint, replace a healthy baseline, accept known failures,
42
- resolve decisions, regenerate semantic content, or edit application code.
36
+ Preserve corrupt DB/WAL/SHM and dirty worktrees. Never patch plugin cache files by
37
+ hand; reinstall through `ubp` and verify the installed manifest and hook targets.
43
38
 
44
- Corrupt SQLite requires preservation of DB, WAL, and SHM followed by an explicit
45
- restore-or-rebaseline choice. Missing hook adapters or stale cache paths require
46
- `ubp --doctor` and adapter reinstall; never patch plugin cache contents by hand.
47
-
48
- After repair, rerun doctor read-only and verify backup paths, schema, installed hashes,
49
- entry points, MCP startup, and hook smoke tests as applicable.
50
-
51
- Return health first, failed checks, mechanical repairs performed, preserved recovery
52
- paths, unresolved owners, and allowed transitions plus any unique required transition.
53
-
54
- Never invoke the recommended capability here; wait for an explicit user invocation.
39
+ Rerun doctor read-only after repair. Report health, exact failed checks, backups,
40
+ repairs, preserved recovery paths, and remaining owner or semantic work. Do not invoke
41
+ another capability automatically.
@@ -1,85 +1,53 @@
1
1
  ---
2
2
  name: ultra-init
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.
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 fault.
4
4
  ---
5
5
 
6
6
  # Initialize project authority
7
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.
8
+ Initialization creates the repository-local Ultra authority. It does not perform
9
+ research, accept a product baseline, choose a Change, or start another public
10
+ capability.
11
11
 
12
- ## Inspect before mutation
12
+ ## Inspect and align
13
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/.runtime/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.
14
+ 1. Inspect the repository root, Git state, meaningful source, existing `.ultra`,
15
+ monorepo boundaries, and the current request.
16
+ 2. When authority already exists, call `ultra.doctor { repair: false }` and preserve
17
+ healthy state. Never replace or delete it merely to obtain a clean init.
18
+ 3. Classify the repository from evidence:
19
+ - `greenfield`: no meaningful delivered behavior exists;
20
+ - `brownfield`: source, runtime, API, data, deployment, or tests describe an
21
+ existing maintained system;
22
+ - `migrated`: older Ultra authority was preserved but is not yet a trusted baseline.
23
+ 4. Ask the owner only when scope, healthy-authority replacement, destructive recovery,
24
+ or another material choice cannot be derived. Reuse explicit intent.
21
25
 
22
- Use repository evidence to classify:
26
+ Read `../ultra-think/references/decision-dialogue.md` before asking a material
27
+ question.
23
28
 
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.
29
+ ## Initialize once
28
30
 
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
+ Call `ultra.record` with one entry:
31
32
 
32
- ## Interaction boundary
33
+ ```text
34
+ operation: task.init_project
35
+ data: target_dir, project_name, mode=auto, git_mode=auto, optional scope
36
+ idempotency_key: stable init attempt id
37
+ ```
33
38
 
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
+ This stateless bootstrap is the only `ultra.record` operation allowed before
40
+ `state.db` exists. It must create or migrate `.ultra/.runtime/state.db`, preserve
41
+ existing artifacts and Git history, install only missing scaffold assets on resume,
42
+ validate or safely upgrade a legacy task ledger, and read back the result.
39
43
 
40
- ## Deterministic initialization contract
44
+ An unborn Git repository may require a local initial commit, but init never creates a
45
+ remote, tag, push, publish, or deployment. Corrupt DB/WAL/SHM and backups remain
46
+ preserved until an explicit recovery choice is made.
41
47
 
42
- `task.init_project` owns these steps:
48
+ ## Return control
43
49
 
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/.runtime/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
- - never invoke another public Ultra workflow automatically; recommend the best allowed
79
- capability and wait for an explicit user invocation.
80
-
81
- Report classification, scope, schema and backup result, Git state, init workflow id,
82
- baseline state, and allowed transitions. Do not claim that a baseline is ready until a
83
- separate research/adoption workflow has recorded and converged it.
84
-
85
- Never invoke the recommended capability here; wait for an explicit user invocation.
50
+ Report classification, scope, schema and backup result, Git state, imported team
51
+ checkpoint state, and any mechanical blocker. Recommend the next useful capability
52
+ from current evidence, usually `ultra-research`, `ultra-change`, `ultra-status`, or
53
+ `ultra-doctor`; do not invoke it automatically.