ultra-builder-pro-cli 0.26.2 → 5.0.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 (82) hide show
  1. package/.ultra-template/contexts/TEMPLATE.md +70 -29
  2. package/.ultra-template/north-star.md +35 -18
  3. package/.ultra-template/tasks.json +1 -0
  4. package/.ultra-template/test-report.json +17 -1
  5. package/CHANGELOG.md +235 -1
  6. package/README.md +210 -50
  7. package/README.zh-CN.md +440 -0
  8. package/adapters/_shared/host-profile.cjs +3 -95
  9. package/adapters/_shared/plugin-core.cjs +61 -5
  10. package/adapters/_shared/runtime-assets.cjs +66 -5
  11. package/adapters/zcode.js +375 -0
  12. package/bin/delegate-worker.cjs +2 -325
  13. package/bin/delegate.cjs +3 -461
  14. package/bin/install.js +11 -6
  15. package/docs/ARCHITECTURE.md +133 -31
  16. package/docs/ARTIFACT-AUTHORITY.md +185 -24
  17. package/docs/DECISIONS.md +153 -18
  18. package/docs/PHILOSOPHY.md +58 -7
  19. package/docs/PLUGIN-ISOLATION-CONTRACT.md +34 -12
  20. package/docs/RUNTIME-COMPAT-MATRIX.md +195 -23
  21. package/docs/SKILL-AUTHORING.md +19 -6
  22. package/docs/WORKFLOW-LIFECYCLE.md +196 -44
  23. package/docs/evals/adversarial-review-2026-08-14.md +84 -0
  24. package/docs/evals/ultra-5-0-journey-results.md +62 -0
  25. package/docs/evals/ultra-5-0-live-acp-conformance.md +93 -0
  26. package/docs/evals/ultra-5-0-route-journeys.md +145 -0
  27. package/docs/evals/zcode-automation-2026-08-14.md +103 -0
  28. package/hooks/README.md +27 -4
  29. package/hooks/_common.py +1678 -61
  30. package/hooks/adapters/zcode.py +227 -0
  31. package/hooks/compact_context.py +176 -17
  32. package/hooks/mid_workflow_recall.py +27 -5
  33. package/hooks/post_edit_guard.py +133 -23
  34. package/hooks/session_context.py +707 -22
  35. package/package.json +7 -3
  36. package/skills/ultra-change/SKILL.md +69 -12
  37. package/skills/ultra-change/references/change-contract.md +93 -27
  38. package/skills/ultra-change/references/execution-grant.md +109 -0
  39. package/skills/ultra-change/references/primary-transfer.md +273 -0
  40. package/skills/ultra-change/scripts/validate_primary_transfer.cjs +1928 -0
  41. package/skills/ultra-delegate/SKILL.md +103 -8
  42. package/skills/ultra-delegate/patches/zcode-acp-0.1.0-zcode-0.16.5.patch +184 -0
  43. package/skills/ultra-delegate/references/delegation-contract.md +80 -1
  44. package/skills/ultra-delegate/scripts/acp-conformance.cjs +287 -0
  45. package/skills/ultra-delegate/scripts/acp-driver.cjs +762 -0
  46. package/skills/ultra-delegate/scripts/agent-execution-driver.cjs +320 -0
  47. package/skills/ultra-delegate/scripts/cli-driver.cjs +61 -0
  48. package/skills/ultra-delegate/scripts/delegate-worker.cjs +328 -0
  49. package/skills/ultra-delegate/scripts/delegate.cjs +690 -0
  50. package/skills/ultra-delegate/scripts/host-profile.cjs +267 -0
  51. package/skills/ultra-deliver/SKILL.md +98 -11
  52. package/skills/ultra-dev/SKILL.md +188 -42
  53. package/skills/ultra-grilling/SKILL.md +10 -7
  54. package/skills/ultra-grilling/references/reframing.md +7 -3
  55. package/skills/ultra-init/SKILL.md +56 -7
  56. package/skills/ultra-init/scripts/init_project.cjs +968 -21
  57. package/skills/ultra-plan/SKILL.md +91 -47
  58. package/skills/ultra-plan/references/task-evidence-v2.md +300 -0
  59. package/skills/ultra-plan/scripts/validate_task_evidence.cjs +859 -0
  60. package/skills/ultra-research/SKILL.md +70 -14
  61. package/skills/ultra-research/references/04-product-strategy.md +11 -2
  62. package/skills/ultra-research/references/21-features-scope.md +8 -0
  63. package/skills/ultra-research/references/22-success-metrics.md +4 -3
  64. package/skills/ultra-research/references/99-synthesis.md +19 -2
  65. package/skills/ultra-research/references/north-star-v2.md +168 -0
  66. package/skills/ultra-research/references/wayfinding.md +8 -0
  67. package/skills/ultra-research/scripts/validate_north_star.cjs +1174 -0
  68. package/skills/ultra-review/SKILL.md +201 -27
  69. package/skills/ultra-review/references/adversarial-evaluation.md +31 -0
  70. package/skills/ultra-review/references/spec.md +5 -0
  71. package/skills/ultra-review/references/unified-schema.md +146 -11
  72. package/skills/ultra-review/references/worker-packet.md +151 -8
  73. package/skills/ultra-review/scripts/review_wait.py +2653 -63
  74. package/skills/ultra-status/SKILL.md +129 -15
  75. package/skills/ultra-status/references/route-contract.md +100 -0
  76. package/skills/ultra-tdd/SKILL.md +11 -4
  77. package/skills/ultra-tdd/references/test-execution.md +6 -1
  78. package/skills/ultra-test/SKILL.md +161 -18
  79. package/skills/ultra-test/scripts/validate_review_transport.cjs +549 -0
  80. package/skills/ultra-test/scripts/worktree_digest.cjs +518 -30
  81. /package/{adapters/_shared → skills/ultra-delegate/scripts}/delegate-profiles/kimi-read-only.md +0 -0
  82. /package/{adapters/_shared → skills/ultra-delegate/scripts}/delegate-profiles/kimi-write.md +0 -0
@@ -0,0 +1,273 @@
1
+ # Primary transfer between Agents (OFFER → ACK → RESULT)
2
+
3
+ Use this reference only when the owner moves the canonical implementation
4
+ authority of one work package from the current primary Agent to another Agent.
5
+ It is the exclusive way a work package changes its single canonical writer;
6
+ everything else a second Agent can do is a delegated worker slice
7
+ (`skills/ultra-delegate/`) or a read-only review.
8
+
9
+ Primary transfer and delegated work are mutually exclusive:
10
+
11
+ - a **primary transfer** moves the sole canonical `.ultra` writer role for the
12
+ work package, under an exact owner grant, after verification;
13
+ - a **delegated worker** keeps the primary writer untouched, runs in an
14
+ isolated worktree, cannot write `.ultra`, and returns a bounded result.
15
+
16
+ A delegation receipt can never serve as an ACK or RESULT, and relaxing the
17
+ worker's `.ultra` write prohibition to fake a transfer is a contract violation,
18
+ not a shortcut. While an ACK-ready transfer is open, the receiver is the one
19
+ canonical writer and the sender stops writing product and canonical files.
20
+
21
+ ## When a transfer is valid
22
+
23
+ - the owner has issued or accepted an exact durable work-package grant naming
24
+ the new primary, the scope, allowed local effects, forbidden effects, review
25
+ budget, stop conditions, and terminal outcomes;
26
+ - the current primary has written current reality, evidence, not-done, and next
27
+ steps back into the canonical task context and its closing Resume Note;
28
+ - the sender derives one OFFER from canonical authority — never from chat
29
+ memory — and stops writing after the receiver's ready ACK.
30
+
31
+ ## Receipts
32
+
33
+ Receipts live under `.ultra/.runtime/handoffs/<handoff-id>/` and are derived,
34
+ reconstructable observations, never semantic authority:
35
+
36
+ - `OFFER.json` (`ultra-primary-transfer-offer-v1`): sender, receiver and roles,
37
+ repository root/origin/base HEAD, worktree digest, dirty state and known
38
+ untracked files, every frozen input with purpose/path/SHA-256, the accepted
39
+ scope including the fresh task identity, allowed and forbidden effects, the
40
+ review budget, and the receiver protocol.
41
+ - `ACK.json` (`ultra-primary-transfer-ack-v1`): the receiver's stable-read
42
+ observations — repository identity, base HEAD, worktree digest, and every
43
+ frozen input's offered and observed SHA-256 with a match flag — plus the
44
+ accepted role and task identity. `state` is `ready` only when every value
45
+ matches; otherwise it is `blocked` with `blocked_reasons`.
46
+ - `RESULT.json` (`ultra-primary-transfer-result-v1` or `-v2`): the terminal receipt —
47
+ `terminal_state` (`completed` | `blocked` | `revoked` | `cancelled` |
48
+ `failed`), final HEAD and worktree digest, exact changed and deleted paths,
49
+ exact commands with exit codes, evidence refs, fakes, limitations, not-done,
50
+ external effects, and review risks. A v2 RESULT additionally lists
51
+ `frozen_input_final_digests`: the actual final SHA-256 (or an explicit
52
+ `absent: true`) of every OFFER frozen input.
53
+ - `CLOSEOUT.json` (`ultra-primary-transfer-closeout-v1`): optional, and only
54
+ beside a completed v2 RESULT in the same handoff — the receipt of the one
55
+ prescribed post-review closeout transition below. It cites the exact
56
+ reviewed subject (`closes_result`), the acceptance receipt that authorized
57
+ the closeout (`authorized_by`), the three prescribed paths, the
58
+ closeout-start and closeout-end observations (`subject_before` /
59
+ `subject_after`), an optional owner-authorized `continuation` covering work
60
+ that legally moved the subject between freeze and closeout, and
61
+ `effects_declined` — commit, review, and handoff all false. It never
62
+ rewrites OFFER/ACK/RESULT bytes.
63
+
64
+ A `completed` RESULT means the receiver's sole-writer execution is finished and
65
+ frozen for read-only review. It never closes the task ledger row, accepts the
66
+ review, or authorizes a delivery or release effect — those stay with the owner
67
+ and the reviewer.
68
+
69
+ ## Phase-correct freshness
70
+
71
+ The ACK's bytes are a **pre-write boundary** record, never present-current
72
+ freshness. Expected receiver edits after a ready ACK — including edits to files
73
+ the OFFER froze as starting reality, such as the task context or the WIP
74
+ checkpoint — are legal and must not invalidate an active or completed transfer:
75
+
76
+ - the ACK proves the starting subject at its own temporal boundary; the sender
77
+ validates it promptly after the ACK, before receiver writes begin;
78
+ - after that boundary, active validation observes only the current HEAD against
79
+ the base HEAD, the ledger row, and whether the current worktree digest still
80
+ equals the ACK-observed digest (`boundary intact`) or receiver writes have
81
+ legally begun — it never re-reads ACK-start bytes as present truth;
82
+ - resume and current reality come from the canonical task context, the current
83
+ grant, and the ledger, never from pretending ACK-time bytes are still current;
84
+ - a terminal v1 receipt, and any handoff superseded by a newer handoff, is
85
+ historical structure: the reviewer recaptures facts from the repository
86
+ instead of re-anchoring old receipts to current bytes;
87
+ - a newest v2 terminal RESULT is bound to the current reality: the recomputed
88
+ final HEAD, the recomputed product worktree digest, the exact final product
89
+ path inventory (every tracked change against the base HEAD plus every
90
+ product-scope untracked file — the same subject definition the worktree-digest
91
+ primitive uses), and the final bytes of every frozen input. History advancing
92
+ past the frozen final HEAD (for example an owner commit) is a warning that
93
+ makes the receipt historical; a divergence that does not preserve the frozen
94
+ HEAD is an error for the owner. A prescribed closeout receipt (below) is the
95
+ one legal way current reality moves past the frozen digest without a new
96
+ handoff.
97
+
98
+ ## Prescribed closeout transition (versioned contract)
99
+
100
+ A `completed` v2 RESULT freezes the reviewed subject but never closes the task
101
+ ledger row — the closeout (final evidence record, task-context Task
102
+ Review/Completion/Resume, ledger `completed`, readback) still has to write
103
+ product-scope authority bytes. Rewriting the frozen RESULT, opening a new
104
+ handoff for the closeout, or committing would each create a loop or conflate
105
+ separate effects. The versioned closeout-transition contract is the one
106
+ bounded answer: a CLOSEOUT receipt separates the immutable reviewed subject
107
+ from exactly one uncommitted prescribed closeout.
108
+
109
+ - The closeout is **prescribed**: exactly three paths — the task ledger
110
+ `.ultra/tasks.json`, the task context `.ultra/contexts/task-<id>.md`, and
111
+ the final evidence record `.ultra/evidence/<task-id>/evidence.json` — and,
112
+ inside the context, only the closeout sections (`## Resume Note`,
113
+ `## Task Review`, `## Completion`). The context bytes before the earliest of
114
+ those headings, the ledger rows outside the closed task, and every
115
+ pre-review evidence sibling stay byte-frozen: implementation, Acceptance,
116
+ the PPI, pre-review evidence, and unrelated authority changes remain stale.
117
+ - The closeout is **post-review only**: `authorized_by` cites the real
118
+ external-review receipt by path and SHA-256 and binds its existing
119
+ `ultra-external-review-receipt-v1` semantics — no second review schema is
120
+ invented: an identified read-only reviewer, the exact task and change
121
+ identity, the reviewer-authority and reviewed-contract refs verified by
122
+ stable bytes, a subject equal to the closeout-start HEAD and worktree
123
+ digest, an `approve` verdict with no P0/P1 finding (retained P2/P3 stay
124
+ recorded and non-blocking), and a receipt path that is a Planned Path
125
+ Inventory entry of the task context, planned before the review so the
126
+ evidence audit and this contract agree at closeout time. The closeout
127
+ starts no review, no handoff, and
128
+ no repair round, and it never commits — the frozen final
129
+ HEAD must still be the current HEAD.
130
+ - The receipt records the transition: `subject_before` and `subject_after`
131
+ pin the aggregate product worktree digest, the prescribed paths' exact
132
+ bytes, the ledger rows outside the closed task, the frozen context prefix,
133
+ and the pre-review evidence siblings, so any drift before, during, or after
134
+ the closeout fails typed instead of silently rebinding. The closed task's
135
+ own ledger row is bound the same way: unique, `in_progress` at closeout
136
+ start, `completed` at the end, and every field except `status` pinned by a
137
+ canonical ex-status digest recorded before and after and re-read live — a
138
+ missing, duplicated, or field-drifted current row is a typed stop.
139
+ - If owner-authorized work moved the subject between the freeze and the
140
+ closeout (a recorded repair round under the same durable grant), the receipt
141
+ declares it once in `continuation`: the frozen digest it starts from, every
142
+ delta path with its closeout-start bytes (prescribed paths only at their
143
+ closeout-start bytes), and the canonical records that authorize it. A
144
+ closeout that starts from a subject the RESULT never froze, with no
145
+ continuation, is a typed stop for the owner — never a silent rebind.
146
+ - The transition is **terminal and one-shot**: after the closeout, current
147
+ reality binds to `subject_after`, and any further product write of any kind
148
+ fails typed. There is no re-freeze, no second closeout, no retry loop, and
149
+ no automatic repair; a mismatch returns to the owner. Supersession rules
150
+ are unchanged — a newer same-subject handoff still makes the closed-out
151
+ receipt and its closeout historical together, and v1 receipts never carry
152
+ a closeout.
153
+
154
+ ## Host post-turn external effects
155
+
156
+ A receiver's receipts observe only what exists through their own publication
157
+ boundary. Host post-turn lifecycle effects run after the receiver's terminal
158
+ text and are never observable inside the pass that produced them, so a RESULT
159
+ never asserts future Host state. Enabled provider-local automatic memory — for
160
+ example ZCode Desktop Workspace Memory extraction — is such a
161
+ Host external effect:
162
+
163
+ - if the Host memory feature is enabled, the OFFER `effects` must allow it and
164
+ the terminal RESULT must disclose it in `external_effects`; omitting it is a
165
+ false zero-effect claim even though the files land outside the repository;
166
+ - a strict zero-external-effect transfer starts in a fresh task with the
167
+ native master setting off (`memoryEnabled=false` on ZCode Desktop; the
168
+ logged `memoryExtractionEnabled`/`memoryUse` values are absent-key,
169
+ disable-only observations, not independent owner-facing gates) and ends with
170
+ an independent reviewer postflight over the Host post-turn logs and the
171
+ external memory store;
172
+ - Host memory is never a frozen input, shared authority, evidence substitute,
173
+ or completion signal in either mode: it stays non-authoritative and
174
+ non-portable, and Ultra neither parses nor mutates provider settings — the
175
+ native setting remains owner/operator controlled.
176
+
177
+ ## Protocol
178
+
179
+ 1. Sender writes reality back to canonical task context and Resume Note.
180
+ 2. Owner grant (already recorded) names the receiver exactly.
181
+ 3. Sender derives `OFFER.json` binding canonical refs/hashes, HEAD, and the
182
+ worktree digest.
183
+ 4. Receiver stable-reads the exact refs and answers with `ACK.json`:
184
+ `ready` (all observed values match) or `blocked` (with reasons).
185
+ 5. Only a matching grant plus a ready ACK makes the receiver the sole canonical
186
+ writer; the sender then stops writing.
187
+ 6. Receiver executes, updates canonical files, and freezes the terminal
188
+ `RESULT.json`.
189
+ 7. Reviewer or next primary recaptures facts from the repository; nobody
190
+ inherits the receiver's completion narrative.
191
+ 8. Any source, grant, role, or digest mismatch returns `blocked` — never an
192
+ auto-repaired packet and never silent continuation.
193
+
194
+ ## Recovery
195
+
196
+ - **Stale offer** (frozen input, HEAD, or worktree drifted before ACK):
197
+ receiver writes a blocked ACK citing the mismatched observation; a fresh
198
+ offer under a new handoff id is created after the owner re-confirms. Old
199
+ receipts are never edited to match new bytes.
200
+ - **Receiver refusal / no ACK**: no transfer happened; the sender remains the
201
+ canonical writer. The offered handoff simply stays `offered`.
202
+ - **Interrupt / resume**: canonical task context and its Resume Note plus the
203
+ grant's activation rule are the recovery anchor; the receiver re-verifies the
204
+ grant and the ledger row (`--live`) before continuing.
205
+ - **Cancel / revoke**: the owner records a decision; the receiver (or sender,
206
+ if pre-ACK) writes a terminal RESULT `cancelled` or `revoked` citing that
207
+ decision record in `evidence_refs`.
208
+ - **Missing receipts**: receipts are derived state; create a fresh handoff
209
+ under a new id from canonical authority. Never reconstruct an old ACK or
210
+ RESULT — a lost receipt is regenerated, not remembered.
211
+ - **One-writer invariant**: at most one ACK-ready, unterminated handoff may be
212
+ open in a repository; a conflict is a typed stop for the owner.
213
+ - **Closeout drift**: a closed-out subject that moved after its CLOSEOUT
214
+ receipt is a typed stop; never edit the receipt, the frozen RESULT, or open
215
+ a handoff for it — return the exact drift to the owner.
216
+ - **Lost or repeated closeout**: a CLOSEOUT receipt is never reconstructed or
217
+ duplicated; if it is lost, the handoff stays a plain terminal RESULT and the
218
+ owner decides the next bounded step.
219
+
220
+ ## Mechanical checks
221
+
222
+ `node skills/ultra-change/scripts/validate_primary_transfer.cjs <repo-root>`
223
+ validates receipt structure, hash and HEAD bindings, state transitions, path
224
+ normalization, the delegation-boundary and one-writer invariants. All receipt
225
+ and bound-input reads go through one shared bounded mechanical primitive (the
226
+ worktree-digest tool's stable snapshot): repository-relative paths are
227
+ validated before any filesystem access, the complete parent chain is walked as
228
+ ordinary non-symlink directories, leaves open no-follow, and identities replay
229
+ after reading — symlinks, FIFOs, directories, oversize files, invalid UTF-8,
230
+ and replaced identities are typed diagnostics with recovery, never followed.
231
+ A handoff directory holds exactly `OFFER.json`, optional `ACK.json`, and
232
+ optional `RESULT.json` under a physically bounded entry scan with a final
233
+ exact replay; any other entry is a typed stop. Repo-wide discovery and
234
+ per-handoff validation share one ancestor-first optional-directory
235
+ observation: every existing `.ultra`/`.runtime`/`handoffs`/handoff component
236
+ is lstat'd no-follow before its child is touched, so a symlinked or special
237
+ ancestor fails typed even when a later component is absent; a genuinely
238
+ missing component under ordinary ancestors legally means no transfers for the
239
+ optional repo-wide root (and absence itself is replayed); a required handoff
240
+ directory's absence is a typed error; and every existing directory streams
241
+ bounded with an exact entry replay — drift, replacement, malformed entries,
242
+ and the entry ceiling fail typed and closed, never silently zero handoffs. Live validation fails closed:
243
+ when HEAD, Git, the worktree, the manifest, or a frozen input cannot be
244
+ observed, the result is an error with a restore-and-retry path, never a green
245
+ guess. For an active transfer it observes the current HEAD, the ledger row,
246
+ and whether the ACK-start digest still holds or receiver writes have begun.
247
+ For the newest v2 terminal RESULT it binds, in one finite coherent observation
248
+ (the digest re-observed once after the manifest and frozen-input reads), the
249
+ final HEAD, the recomputed worktree digest, the exact product path inventory,
250
+ and the final frozen-input digests; a subject that moves across that boundary
251
+ fails typed. A newer handoff supersedes an older terminal receipt only for the
252
+ same subject and authority — same repository, same accepted task identity,
253
+ same owner-grant decision bytes; unrelated newer work never downgrades strict
254
+ validation. Superseded and v1 terminal receipts stay historical. Beside a
255
+ completed v2 RESULT, the validator additionally accepts exactly one CLOSEOUT
256
+ receipt and binds the closed-out state instead: the closeout end-state digest,
257
+ the pinned reviewed subject and recorded continuation, the frozen-input bytes
258
+ outside the prescribed paths, the frozen ledger-row, context-prefix, and
259
+ pre-review-evidence scopes, the closed task row's canonical ex-status digest
260
+ (unique, `in_progress` → `completed`, re-read live), and the authorized_by
261
+ receipt's existing `ultra-external-review-receipt-v1` semantics. The validator
262
+ owns structure, identity, and freshness only; it never decides semantic
263
+ completion, and a green report is not an acceptance.
264
+
265
+ ## What a transfer is not
266
+
267
+ - not a scheduler, daemon, wake-up service, or license for the receiver to
268
+ extend its own grant, budget, or scope;
269
+ - not inheritable: a new transfer needs its own owner grant and receipts;
270
+ - not a memory channel: hidden chat, Host memory, Goal state, session ids, and
271
+ progress files are never shared authority;
272
+ - not available to Hooks or Skills as automatic behavior — a transfer is an
273
+ owner-directed protocol step executed by the Agents involved.