@astrosheep/keiyaku 4.1.0 → 4.1.2

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 (278) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
  5. package/build/src/akuma/akuma-errors.d.ts +6 -0
  6. package/build/src/akuma/akuma-errors.js +9 -0
  7. package/build/src/akuma/akuma-handle.d.ts +39 -0
  8. package/build/src/akuma/akuma-handle.js +263 -0
  9. package/build/src/akuma/akuma-observe.d.ts +19 -0
  10. package/build/src/akuma/akuma-observe.js +74 -0
  11. package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
  12. package/build/src/akuma/akuma-product-symbols.js +1 -0
  13. package/build/src/akuma/akuma-product.d.ts +18 -0
  14. package/build/src/akuma/akuma-product.js +154 -0
  15. package/build/src/akuma/akuma.d.ts +37 -81
  16. package/build/src/akuma/akuma.js +39 -447
  17. package/build/src/akuma/allowed.d.ts +1 -0
  18. package/build/src/akuma/allowed.js +6 -0
  19. package/build/src/akuma/archetype.js +8 -5
  20. package/build/src/akuma/body-supervisor.d.ts +26 -0
  21. package/build/src/akuma/body-supervisor.js +89 -0
  22. package/build/src/akuma/body.d.ts +45 -4
  23. package/build/src/akuma/body.js +145 -35
  24. package/build/src/akuma/coordinate.js +17 -7
  25. package/build/src/akuma/heart/facts.js +1 -1
  26. package/build/src/akuma/heart/index.d.ts +1 -1
  27. package/build/src/akuma/heart/index.js +2 -4
  28. package/build/src/akuma/heart/request-authority.js +4 -4
  29. package/build/src/akuma/heart/request-rows.js +27 -16
  30. package/build/src/akuma/heart/rows.js +79 -41
  31. package/build/src/akuma/heart/soul.js +1 -1
  32. package/build/src/akuma/heart/storage.d.ts +1 -0
  33. package/build/src/akuma/heart/storage.js +76 -11
  34. package/build/src/akuma/heart/tells.js +35 -18
  35. package/build/src/akuma/heart/timeline.js +19 -11
  36. package/build/src/akuma/identity.d.ts +1 -0
  37. package/build/src/akuma/identity.js +1 -0
  38. package/build/src/akuma/index.d.ts +3 -3
  39. package/build/src/akuma/index.js +1 -1
  40. package/build/src/akuma/nuke.js +106 -14
  41. package/build/src/akuma/projection-read.d.ts +17 -0
  42. package/build/src/akuma/projection-read.js +135 -0
  43. package/build/src/akuma/projection.d.ts +1 -16
  44. package/build/src/akuma/projection.js +77 -154
  45. package/build/src/akuma/provider-recipe.js +11 -5
  46. package/build/src/akuma/provider.js +105 -62
  47. package/build/src/akuma/providers/acp/config.js +5 -6
  48. package/build/src/akuma/providers/acp/core.js +17 -10
  49. package/build/src/akuma/providers/acp/events.js +38 -29
  50. package/build/src/akuma/providers/acp/index.js +13 -9
  51. package/build/src/akuma/providers/claude/events.js +8 -12
  52. package/build/src/akuma/providers/claude/index.d.ts +1 -0
  53. package/build/src/akuma/providers/claude/index.js +55 -26
  54. package/build/src/akuma/providers/claude/input.js +6 -2
  55. package/build/src/akuma/providers/codex-app-server/events.js +61 -36
  56. package/build/src/akuma/providers/codex-app-server/index.js +25 -13
  57. package/build/src/akuma/providers/grok-build/index.js +22 -25
  58. package/build/src/akuma/providers/index.js +2 -18
  59. package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
  60. package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
  61. package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
  62. package/build/src/akuma/providers/pi/events.js +26 -19
  63. package/build/src/akuma/providers/pi/index.js +58 -40
  64. package/build/src/akuma/publication.js +9 -9
  65. package/build/src/akuma/request-execution.d.ts +6 -0
  66. package/build/src/akuma/request-execution.js +86 -0
  67. package/build/src/akuma/request-serve.d.ts +12 -1
  68. package/build/src/akuma/request-serve.js +19 -122
  69. package/build/src/akuma/request-wire.d.ts +2 -2
  70. package/build/src/akuma/request-wire.js +75 -102
  71. package/build/src/akuma/requests.js +2 -2
  72. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
  73. package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
  74. package/build/src/akuma-body.js +6 -5
  75. package/build/src/body/amend.d.ts +4 -1
  76. package/build/src/body/amend.js +14 -6
  77. package/build/src/body/decode.js +2 -4
  78. package/build/src/body/envelope.js +2 -4
  79. package/build/src/body/region.d.ts +1 -2
  80. package/build/src/body/region.js +2 -70
  81. package/build/src/body/render.js +17 -12
  82. package/build/src/body/shape.js +1 -7
  83. package/build/src/cli/accepted.d.ts +1 -1
  84. package/build/src/cli/accepted.js +8 -1
  85. package/build/src/cli/commands/akuma-invoke.js +18 -6
  86. package/build/src/cli/commands/akuma.d.ts +0 -6
  87. package/build/src/cli/commands/akuma.js +11 -24
  88. package/build/src/cli/commands/amend.d.ts +2 -2
  89. package/build/src/cli/commands/amend.js +2 -4
  90. package/build/src/cli/commands/bind.d.ts +4 -4
  91. package/build/src/cli/commands/bind.js +16 -6
  92. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  93. package/build/src/cli/commands/contract-invoke.js +193 -0
  94. package/build/src/cli/commands/contract.d.ts +109 -10
  95. package/build/src/cli/commands/contract.js +339 -16
  96. package/build/src/cli/commands/install.d.ts +1 -1
  97. package/build/src/cli/commands/install.js +23 -15
  98. package/build/src/cli/commands/task-invoke.js +187 -67
  99. package/build/src/cli/commands/task-query.js +48 -24
  100. package/build/src/cli/commands/task.js +150 -38
  101. package/build/src/cli/coordinates.js +2 -4
  102. package/build/src/cli/invoke.js +92 -208
  103. package/build/src/cli/main.js +4 -2
  104. package/build/src/cli/parse.d.ts +3 -90
  105. package/build/src/cli/parse.js +27 -233
  106. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  107. package/build/src/cli/render/akuma-activity.js +362 -0
  108. package/build/src/cli/render/akuma-tool-command.js +6 -7
  109. package/build/src/cli/render/akuma-tool.js +10 -8
  110. package/build/src/cli/render/akuma.d.ts +1 -1
  111. package/build/src/cli/render/akuma.js +61 -353
  112. package/build/src/cli/render/audit.js +5 -15
  113. package/build/src/cli/render/board.d.ts +1 -0
  114. package/build/src/cli/render/board.js +17 -0
  115. package/build/src/cli/render/catalog.js +81 -8
  116. package/build/src/cli/render/contract-history.d.ts +2 -0
  117. package/build/src/cli/render/contract-history.js +83 -0
  118. package/build/src/cli/render/contract-observation.d.ts +10 -0
  119. package/build/src/cli/render/contract-observation.js +58 -0
  120. package/build/src/cli/render/contract.d.ts +1 -2
  121. package/build/src/cli/render/contract.js +41 -142
  122. package/build/src/cli/render/kanshi.js +239 -215
  123. package/build/src/cli/render/receipt.js +2 -9
  124. package/build/src/cli/render/refusal.js +10 -15
  125. package/build/src/cli/render/region.js +22 -6
  126. package/build/src/cli/render/settings.js +4 -4
  127. package/build/src/cli/render/task.js +34 -14
  128. package/build/src/cli/render/terminal.js +16 -5
  129. package/build/src/cli/result.d.ts +3 -3
  130. package/build/src/cli/runtime.d.ts +6 -1
  131. package/build/src/cli/runtime.js +84 -63
  132. package/build/src/cli/selectors.js +2 -4
  133. package/build/src/cli/usage.js +6 -5
  134. package/build/src/contract-worktree.d.ts +1 -23
  135. package/build/src/contract-worktree.js +79 -155
  136. package/build/src/coordination/durable-file.js +7 -3
  137. package/build/src/coordination/sqlite-transaction-lock.js +29 -12
  138. package/build/src/core/facts/codec.js +7 -3
  139. package/build/src/core/facts/types.d.ts +1 -1
  140. package/build/src/core/subject.js +16 -9
  141. package/build/src/core/verbs/abandon.d.ts +1 -1
  142. package/build/src/core/verbs/abandon.js +1 -1
  143. package/build/src/core/verbs/amend.d.ts +1 -1
  144. package/build/src/core/verbs/amend.js +7 -7
  145. package/build/src/core/verbs/attestation.js +4 -1
  146. package/build/src/core/verbs/bind.d.ts +1 -1
  147. package/build/src/core/verbs/bind.js +1 -1
  148. package/build/src/core/verbs/placement.d.ts +1 -1
  149. package/build/src/core/verbs/placement.js +10 -8
  150. package/build/src/dispatch/index.js +8 -6
  151. package/build/src/duration.js +5 -1
  152. package/build/src/git/admission.js +5 -3
  153. package/build/src/git/hooks.d.ts +8 -0
  154. package/build/src/git/hooks.js +63 -14
  155. package/build/src/git/identity.js +1 -4
  156. package/build/src/git/integration.d.ts +2 -3
  157. package/build/src/git/integration.js +32 -39
  158. package/build/src/git/nuke.d.ts +1 -1
  159. package/build/src/git/nuke.js +110 -57
  160. package/build/src/git/observe.d.ts +13 -1
  161. package/build/src/git/observe.js +51 -44
  162. package/build/src/git/process.js +4 -2
  163. package/build/src/git/read-observation.js +10 -8
  164. package/build/src/git/reconcile.d.ts +22 -2
  165. package/build/src/git/reconcile.js +38 -274
  166. package/build/src/git/repository.d.ts +2 -0
  167. package/build/src/git/repository.js +13 -22
  168. package/build/src/git/scratch.d.ts +8 -5
  169. package/build/src/git/scratch.js +29 -2
  170. package/build/src/git/target-placement.d.ts +9 -10
  171. package/build/src/git/target-placement.js +59 -62
  172. package/build/src/git/tender.js +13 -46
  173. package/build/src/git/terminal-reconcile.d.ts +21 -0
  174. package/build/src/git/terminal-reconcile.js +278 -0
  175. package/build/src/git/terminal-seal.js +15 -12
  176. package/build/src/git/tree.js +5 -2
  177. package/build/src/git/workspace.d.ts +24 -2
  178. package/build/src/git/workspace.js +120 -16
  179. package/build/src/identity/coordinates.js +3 -1
  180. package/build/src/identity/selector.js +6 -3
  181. package/build/src/kanshi/fleet.d.ts +6 -0
  182. package/build/src/kanshi/fleet.js +27 -0
  183. package/build/src/kanshi/index.d.ts +1 -1
  184. package/build/src/kanshi/read.js +60 -48
  185. package/build/src/kanshi/report.d.ts +11 -23
  186. package/build/src/kanshi/select.js +25 -24
  187. package/build/src/library/address.d.ts +2 -1
  188. package/build/src/library/address.js +7 -8
  189. package/build/src/library/akuma-creation.js +20 -12
  190. package/build/src/library/audit.d.ts +0 -1
  191. package/build/src/library/audit.js +1 -2
  192. package/build/src/library/bind.d.ts +53 -5
  193. package/build/src/library/bind.js +98 -22
  194. package/build/src/library/catalog.d.ts +1 -0
  195. package/build/src/library/catalog.js +6 -3
  196. package/build/src/library/configuration.js +3 -1
  197. package/build/src/library/continuation.d.ts +15 -4
  198. package/build/src/library/continuation.js +24 -16
  199. package/build/src/library/contract-bind.d.ts +26 -0
  200. package/build/src/library/contract-bind.js +106 -0
  201. package/build/src/library/contract-operations.d.ts +77 -0
  202. package/build/src/library/contract-operations.js +130 -0
  203. package/build/src/library/contract-types.d.ts +95 -0
  204. package/build/src/library/contract-types.js +1 -0
  205. package/build/src/library/contract.d.ts +19 -154
  206. package/build/src/library/contract.js +46 -261
  207. package/build/src/library/fleet.d.ts +1 -1
  208. package/build/src/library/fleet.js +19 -11
  209. package/build/src/library/input.d.ts +2 -0
  210. package/build/src/library/input.js +14 -0
  211. package/build/src/library/keiyaku.d.ts +8 -7
  212. package/build/src/library/keiyaku.js +3 -3
  213. package/build/src/library/nuke.js +14 -5
  214. package/build/src/library/reconcile.d.ts +9 -4
  215. package/build/src/library/reconcile.js +30 -24
  216. package/build/src/library/refusal.d.ts +13 -5
  217. package/build/src/library/refusal.js +7 -0
  218. package/build/src/library/region.d.ts +8 -7
  219. package/build/src/library/region.js +31 -11
  220. package/build/src/library/repo.js +2 -2
  221. package/build/src/markdown/lex.js +9 -2
  222. package/build/src/markdown/parse.js +11 -7
  223. package/build/src/markdown/query.js +4 -2
  224. package/build/src/protocol/amend.js +3 -1
  225. package/build/src/protocol/attempt.d.ts +7 -3
  226. package/build/src/protocol/attempt.js +9 -5
  227. package/build/src/protocol/audit.d.ts +1 -1
  228. package/build/src/protocol/audit.js +4 -14
  229. package/build/src/protocol/bind.d.ts +19 -6
  230. package/build/src/protocol/bind.js +28 -13
  231. package/build/src/protocol/completion.d.ts +0 -1
  232. package/build/src/protocol/completion.js +1 -3
  233. package/build/src/protocol/deliver.d.ts +1 -3
  234. package/build/src/protocol/deliver.js +15 -39
  235. package/build/src/protocol/intent.d.ts +1 -0
  236. package/build/src/protocol/intent.js +9 -7
  237. package/build/src/protocol/operations.d.ts +3 -7
  238. package/build/src/protocol/operations.js +5 -3
  239. package/build/src/protocol/placement.d.ts +0 -1
  240. package/build/src/protocol/placement.js +6 -6
  241. package/build/src/protocol/read/observation.d.ts +11 -0
  242. package/build/src/protocol/read/observation.js +37 -0
  243. package/build/src/protocol/read/status.d.ts +23 -12
  244. package/build/src/protocol/read/status.js +90 -72
  245. package/build/src/protocol/reconcile.d.ts +1 -0
  246. package/build/src/protocol/reconcile.js +2 -3
  247. package/build/src/protocol/reintegrate.js +1 -1
  248. package/build/src/protocol/review.d.ts +0 -1
  249. package/build/src/protocol/review.js +15 -22
  250. package/build/src/protocol/run.d.ts +1 -0
  251. package/build/src/protocol/run.js +4 -5
  252. package/build/src/runtime/proc/launch.d.ts +33 -0
  253. package/build/src/runtime/proc/launch.js +98 -0
  254. package/build/src/runtime/proc/line-rpc.js +9 -3
  255. package/build/src/runtime/proc/run.d.ts +12 -6
  256. package/build/src/runtime/proc/run.js +78 -21
  257. package/build/src/runtime/proc/stdio.js +7 -10
  258. package/build/src/settings.js +6 -2
  259. package/build/src/settlement/holder.js +13 -10
  260. package/build/src/settlement/settle.js +39 -6
  261. package/build/src/task/board.js +12 -6
  262. package/build/src/task/compose.js +85 -22
  263. package/build/src/task/context.js +21 -8
  264. package/build/src/task/document.js +46 -10
  265. package/build/src/task/identity.js +5 -2
  266. package/build/src/task/index.d.ts +0 -1
  267. package/build/src/task/index.js +119 -34
  268. package/build/src/task/input.js +29 -7
  269. package/build/src/task/mutation.js +61 -19
  270. package/build/src/task/operations.d.ts +6 -1
  271. package/build/src/task/operations.js +83 -29
  272. package/build/src/task/query.js +55 -26
  273. package/build/src/task/store.d.ts +3 -1
  274. package/build/src/task/store.js +81 -17
  275. package/build/src/verification/execution.js +14 -11
  276. package/build/src/workspace-place.js +19 -7
  277. package/build/src/world.js +16 -6
  278. package/package.json +8 -3
@@ -0,0 +1,83 @@
1
+ import { receiptPayload } from "./receipt.js";
2
+ function journalCount(events, source) {
3
+ return events.filter((event) => event.source === source).length;
4
+ }
5
+ function journalHead(fact) {
6
+ return fact.actor === undefined
7
+ ? `${fact.at} ${fact.kind} · ${fact.entry}`
8
+ : `${fact.at} ${fact.kind} · ${fact.entry} · ${fact.actor}`;
9
+ }
10
+ function listFact(label, values) {
11
+ return values.length === 0 ? [` ${label} 0`] : [` ${label} ${values.join(" · ")}`];
12
+ }
13
+ function journalBody(fact) {
14
+ switch (fact.kind) {
15
+ case "bind": {
16
+ const { coordinates, terms } = fact.data;
17
+ return [
18
+ ` start ${coordinates.start}`,
19
+ ...(coordinates.target === undefined ? [] : [` target ${coordinates.target}`]),
20
+ ` workspace ${coordinates.workspace}`,
21
+ ` document ${terms.document.key}`,
22
+ ...listFact("gates", terms.gates),
23
+ ...listFact("after", terms.after),
24
+ ];
25
+ }
26
+ case "amend":
27
+ return [
28
+ ` document ${fact.data.document.key}`,
29
+ ...listFact("gates", fact.data.gates),
30
+ ...listFact("after", fact.data.after),
31
+ ];
32
+ case "bound":
33
+ return [];
34
+ case "deliver": {
35
+ const { tenderSnapshot, integration, method, policy } = fact.data;
36
+ return [
37
+ ` tender ${tenderSnapshot}`,
38
+ ` predecessor ${integration.predecessor}`,
39
+ ` snapshot ${integration.snapshot}`,
40
+ ` change ${integration.changeId}`,
41
+ ` method ${method}`,
42
+ ` require-branches-to-be-up-to-date ${String(policy.requireBranchesToBeUpToDate)}`,
43
+ ];
44
+ }
45
+ case "reintegrated":
46
+ return [` predecessor ${fact.data.predecessor}`, ` snapshot ${fact.data.snapshot}`];
47
+ case "attestation": {
48
+ const lines = [` gate ${fact.data.gate}`, ` verdict ${fact.data.verdict}`, ` subject ${fact.data.subject}`];
49
+ if (fact.data.summary !== undefined)
50
+ receiptPayload(lines, "summary", fact.data.summary);
51
+ return lines;
52
+ }
53
+ case "claimed":
54
+ return [` delivery ${fact.data.delivery}`];
55
+ case "arc": {
56
+ const lines = [` sequence ${String(fact.data.seq)}`, ` title ${fact.data.title}`];
57
+ receiptPayload(lines, "objective", fact.data.objective);
58
+ receiptPayload(lines, "brief", fact.data.brief);
59
+ return lines;
60
+ }
61
+ case "abandoned": {
62
+ if (fact.data.note === undefined)
63
+ return [];
64
+ const lines = [];
65
+ receiptPayload(lines, "note", fact.data.note);
66
+ return lines;
67
+ }
68
+ }
69
+ }
70
+ function contractHistoryEventLines(event) {
71
+ if (event.source === "dispatch")
72
+ return [`${event.dispatch.dispatchedAt} dispatch · ${event.dispatch.akuId}`];
73
+ return [journalHead(event.fact), ...journalBody(event.fact)];
74
+ }
75
+ export function renderContractHistory(history) {
76
+ const journals = journalCount(history.events, "journal");
77
+ const dispatches = journalCount(history.events, "dispatch");
78
+ return [
79
+ `history ${history.id} · ${journals} journal · ${dispatches} dispatch`,
80
+ "",
81
+ ...history.events.flatMap(contractHistoryEventLines),
82
+ ].join("\n");
83
+ }
@@ -0,0 +1,10 @@
1
+ import type { ContractAfterEdge, ContractDependent, ContractGateReport, ContractRow, ContractWorkspaceObservation } from "../../index.js";
2
+ export declare function gateGlyph(report: ContractGateReport): string;
3
+ export declare function gateFact(report: ContractGateReport): string;
4
+ export declare function candidateFact(delivery: ContractRow["delivery"]): string;
5
+ export declare function afterWording(edge: ContractAfterEdge): string;
6
+ export declare function dependentWording(dependent: ContractDependent): string;
7
+ export declare function mergeSummary(observation: ContractWorkspaceObservation): string | undefined;
8
+ export declare function abbreviateGitIds(ids: readonly string[]): ReadonlyMap<string, string>;
9
+ export declare function gitIdsInRow(row: ContractRow): readonly string[];
10
+ export declare function displayGitId(value: string, abbreviations: ReadonlyMap<string, string>): string;
@@ -0,0 +1,58 @@
1
+ const GIT_OBJECT_ID = /^[0-9a-f]{40}$/iu;
2
+ export function gateGlyph(report) {
3
+ if (report.current.kind === "stale")
4
+ return "[~]";
5
+ if (report.current.kind === "missing")
6
+ return "[ ]";
7
+ return report.current.verdict === "satisfied" ? "[✓]" : "[✗]";
8
+ }
9
+ export function gateFact(report) {
10
+ return `${gateGlyph(report)} ${report.gate}${report.current.kind === "stale" ? " (stale)" : ""}`;
11
+ }
12
+ export function candidateFact(delivery) {
13
+ return delivery === null ? "no candidate" : "candidate";
14
+ }
15
+ export function afterWording(edge) {
16
+ if (edge.endpoint.kind === "claimed")
17
+ return `after ${edge.contractId} (claimed)`;
18
+ const condition = edge.endpoint.kind === "active" ? edge.endpoint.phase : edge.endpoint.kind;
19
+ return `blocked by ${edge.contractId} (${condition})`;
20
+ }
21
+ export function dependentWording(dependent) {
22
+ return `${dependent.contractId} (${dependent.phase})`;
23
+ }
24
+ export function mergeSummary(observation) {
25
+ if (observation.kind !== "clean" && observation.kind !== "dirty")
26
+ return undefined;
27
+ if (observation.merge === null)
28
+ return undefined;
29
+ const count = observation.merge.unmergedPaths.length;
30
+ return count > 0 ? `merge conflict in worktree (${count} paths)` : "merge in progress (resolution staged)";
31
+ }
32
+ export function abbreviateGitIds(ids) {
33
+ const unique = [...new Set(ids.filter((id) => GIT_OBJECT_ID.test(id)))];
34
+ let length = 7;
35
+ while (length < 40) {
36
+ const prefixes = unique.map((id) => id.slice(0, length).toLowerCase());
37
+ if (new Set(prefixes).size === unique.length)
38
+ break;
39
+ length += 1;
40
+ }
41
+ return new Map(unique.map((id) => [id, id.slice(0, length)]));
42
+ }
43
+ export function gitIdsInRow(row) {
44
+ const ids = [];
45
+ if (row.delivery !== null) {
46
+ ids.push(row.delivery.tenderSnapshot, row.delivery.integration.predecessor, row.delivery.integration.snapshot);
47
+ }
48
+ if (row.targetObservation?.head != null)
49
+ ids.push(row.targetObservation.head);
50
+ const observation = row.workspaceObservation;
51
+ if ((observation.kind === "clean" || observation.kind === "dirty") && observation.merge !== null) {
52
+ ids.push(observation.merge.head);
53
+ }
54
+ return ids;
55
+ }
56
+ export function displayGitId(value, abbreviations) {
57
+ return abbreviations.get(value) ?? value;
58
+ }
@@ -1,6 +1,5 @@
1
- import type { ContractHistory } from "../../index.js";
2
1
  import type { AcceptedResult, RetryResult } from "../result.js";
3
2
  import { type TextRenderContext } from "./terminal.js";
4
3
  export declare function renderAccepted(result: AcceptedResult, context?: TextRenderContext): string;
5
4
  export declare function renderRetry(result: RetryResult, context?: TextRenderContext): string;
6
- export declare function renderContractHistory(history: ContractHistory): string;
5
+ export { renderContractHistory } from "./contract-history.js";
@@ -24,18 +24,10 @@ function effectRows(effect, columns) {
24
24
  receiptRow(lines, mark, "contract-file", [{ text: effect.action }, { text: effect.path, opaque: true }], columns);
25
25
  }
26
26
  else if (effect.kind === "target-checkout") {
27
- receiptRow(lines, mark, "target-checkout", [
28
- { text: effect.action },
29
- { text: effect.target, opaque: true },
30
- { text: effect.path, opaque: true },
31
- ], columns);
27
+ receiptRow(lines, mark, "target-checkout", [{ text: effect.action }, { text: effect.target, opaque: true }, { text: effect.path, opaque: true }], columns);
32
28
  }
33
29
  else if (effect.kind === "recovery-snapshot") {
34
- receiptRow(lines, mark, "recovery-snapshot", [
35
- { text: effect.action },
36
- { text: effect.snapshot, opaque: true },
37
- { text: effect.retention },
38
- ], columns);
30
+ receiptRow(lines, mark, "recovery-snapshot", [{ text: effect.action }, { text: effect.snapshot, opaque: true }, { text: effect.retention }], columns);
39
31
  }
40
32
  else {
41
33
  receiptRow(lines, mark, "ref", [
@@ -51,15 +43,33 @@ function lagRows(lag, columns) {
51
43
  if (lag.kind === "worktree-retained") {
52
44
  receiptRow(lines, "!", "lag", [{ text: `worktree-retained ${lag.path}`, opaque: true }], columns);
53
45
  }
46
+ else if (lag.kind === "worktree-follow-retained") {
47
+ receiptRow(lines, "!", "lag", [
48
+ {
49
+ text: `${lag.kind} reason=${lag.reason} tender=${lag.tender} head=${lag.head} path=${lag.path}`,
50
+ opaque: true,
51
+ },
52
+ ], columns);
53
+ }
54
54
  else if (lag.kind === "unsealed-bytes") {
55
- receiptRow(lines, "!", "lag", [{ text: `unsealed-bytes ${lag.path}${lag.head === undefined ? "" : ` head=${lag.head}`}${lag.paths.length === 0 ? "" : ` paths=${lag.paths.join(",")}`}`, opaque: true }], columns);
55
+ receiptRow(lines, "!", "lag", [
56
+ {
57
+ text: `unsealed-bytes ${lag.path}${lag.head === undefined ? "" : ` head=${lag.head}`}${lag.paths.length === 0 ? "" : ` paths=${lag.paths.join(",")}`}`,
58
+ opaque: true,
59
+ },
60
+ ], columns);
56
61
  }
57
62
  else if (lag.kind === "target-checkout-retained") {
58
63
  receiptRow(lines, "!", "lag", [{ text: `target-checkout-retained ${lag.target} ${lag.path}`, opaque: true }], columns);
59
64
  receiptPayload(lines, "diagnostic", lag.diagnostic);
60
65
  }
61
66
  else if (lag.kind === "worktree-hook-failed") {
62
- receiptRow(lines, "!", "lag", [{ text: `worktree-hook-failed ${lag.phase} ${lag.path} command=${lag.command} ${hookFailureSummary(lag.failure)}`, opaque: true }], columns);
67
+ receiptRow(lines, "!", "lag", [
68
+ {
69
+ text: `worktree-hook-failed ${lag.phase} ${lag.path} command=${lag.command} ${hookFailureSummary(lag.failure)}`,
70
+ opaque: true,
71
+ },
72
+ ], columns);
63
73
  appendHookPayload(lines, lag.failure);
64
74
  }
65
75
  else if (lag.kind === "contract-file-failed") {
@@ -74,11 +84,18 @@ function lagRows(lag, columns) {
74
84
  }
75
85
  function settlementLagRows(lag, columns) {
76
86
  const lines = [];
77
- receiptRow(lines, "!", "settlement", [{ text: [
87
+ receiptRow(lines, "!", "settlement", [
88
+ {
89
+ text: [
78
90
  `surface=${lag.surface}`,
79
91
  lag.taskId === undefined ? undefined : `task=${lag.taskId}`,
80
92
  lag.path === undefined ? undefined : `path=${lag.path}`,
81
- ].filter((part) => part !== undefined).join(" "), opaque: true }], columns);
93
+ ]
94
+ .filter((part) => part !== undefined)
95
+ .join(" "),
96
+ opaque: true,
97
+ },
98
+ ], columns);
82
99
  receiptPayload(lines, "diagnostic", lag.diagnostic);
83
100
  return lines;
84
101
  }
@@ -122,11 +139,7 @@ function acceptedRecord(result, columns) {
122
139
  { text: "->" },
123
140
  { text: fact.data.snapshot, opaque: true },
124
141
  ]
125
- : [
126
- ...contract,
127
- { text: fact.entry, opaque: true },
128
- { text: `· ${fact.kind}` },
129
- ], columns);
142
+ : [...contract, { text: fact.entry, opaque: true }, { text: `· ${fact.kind}` }], columns);
130
143
  }
131
144
  receiptRow(record, " ", "head", [{ text: result.head, opaque: true }], columns);
132
145
  if (result.verb === "deliver") {
@@ -194,15 +207,10 @@ function completionLines(result, columns) {
194
207
  receiptRow(lines, " ", "target", [
195
208
  { text: "->" },
196
209
  { text: completion.integration, opaque: true },
197
- ...(verification?.verdict === "satisfied"
198
- ? [{ text: `· verified (${verification.mode})` }]
199
- : []),
210
+ ...(verification?.verdict === "satisfied" ? [{ text: `· verified (${verification.mode})` }] : []),
200
211
  ], columns);
201
212
  if (verification?.verdict === "unsatisfied") {
202
- receiptRow(lines, "!", "verification", [
203
- { text: "unsatisfied" },
204
- { text: `(${verification.mode})` },
205
- ], columns);
213
+ receiptRow(lines, "!", "verification", [{ text: "unsatisfied" }, { text: `(${verification.mode})` }], columns);
206
214
  if (result.verificationSummary !== undefined) {
207
215
  receiptPayload(lines, " summary", result.verificationSummary);
208
216
  }
@@ -223,27 +231,17 @@ function continuationLines(result, columns) {
223
231
  return [];
224
232
  const lines = [];
225
233
  for (const contractId of report.claimed) {
226
- receiptRow(lines, "✓", "continuation", [
227
- { text: "complete" },
228
- { text: contractId, opaque: true },
229
- ], columns);
234
+ receiptRow(lines, "✓", "continuation", [{ text: "complete" }, { text: contractId, opaque: true }], columns);
230
235
  }
231
236
  for (const { contractId, stop } of report.stopped) {
232
237
  const detail = "kind" in stop ? [{ text: stop.kind }] : stopSummary(stop, contractId);
233
- receiptRow(lines, "!", "continuation", [
234
- { text: "blocked" },
235
- { text: contractId, opaque: true },
236
- { text: "·" },
237
- ...detail,
238
- ], columns);
238
+ receiptRow(lines, "!", "continuation", [{ text: "blocked" }, { text: contractId, opaque: true }, { text: "·" }, ...detail], columns);
239
239
  }
240
240
  return lines;
241
241
  }
242
242
  function renderAcceptedBind(result, columns) {
243
243
  const lines = titleLines("✓", "bound", result.contract, columns);
244
- receiptRow(lines, " ", "workspace", [
245
- { text: result.workspace === "worktree" ? "managed worktree" : "here" },
246
- ], columns);
244
+ receiptRow(lines, " ", "workspace", [{ text: "managed worktree" }], columns);
247
245
  if (result.target === null)
248
246
  receiptRow(lines, " ", "no target", [], columns);
249
247
  else
@@ -298,11 +296,7 @@ function renderAcceptedReview(result, columns) {
298
296
  }
299
297
  function renderAcceptedArc(result, columns) {
300
298
  const lines = titleLines("✓", "chapter recorded", result.contract, columns);
301
- receiptRow(lines, " ", "chapter", [
302
- { text: String(result.chapter.seq) },
303
- { text: "·" },
304
- { text: result.chapter.title },
305
- ], columns);
299
+ receiptRow(lines, " ", "chapter", [{ text: String(result.chapter.seq) }, { text: "·" }, { text: result.chapter.title }], columns);
306
300
  lines.push(...recordBlock(result, columns));
307
301
  return lines.join("\n");
308
302
  }
@@ -312,16 +306,10 @@ function renderAcceptedAbandon(result, columns) {
312
306
  receiptRow(lines, " ", "note", [{ text: result.note }], columns);
313
307
  for (const effect of result.effects) {
314
308
  if (effect.kind === "worktree") {
315
- receiptRow(lines, " ", "workspace", [
316
- { text: effect.action },
317
- { text: effect.path, opaque: true },
318
- ], columns);
309
+ receiptRow(lines, " ", "workspace", [{ text: effect.action }, { text: effect.path, opaque: true }], columns);
319
310
  }
320
311
  else if (effect.kind === "recovery-snapshot") {
321
- receiptRow(lines, " ", "recovery snapshot", [
322
- { text: effect.snapshot, opaque: true },
323
- { text: `· ${effect.retention}` },
324
- ], columns);
312
+ receiptRow(lines, " ", "recovery snapshot", [{ text: effect.snapshot, opaque: true }, { text: `· ${effect.retention}` }], columns);
325
313
  }
326
314
  }
327
315
  lines.push(...recordBlock(result, columns));
@@ -353,93 +341,4 @@ export function renderRetry(result, context) {
353
341
  : [];
354
342
  return [...outcomeLines("?", result.verb, "retry", result.contract, columns), ...detail].join("\n");
355
343
  }
356
- function journalCount(events, source) {
357
- return events.filter((event) => event.source === source).length;
358
- }
359
- function journalHead(fact) {
360
- return fact.actor === undefined
361
- ? `${fact.at} ${fact.kind} · ${fact.entry}`
362
- : `${fact.at} ${fact.kind} · ${fact.entry} · ${fact.actor}`;
363
- }
364
- function listFact(label, values) {
365
- return values.length === 0 ? [` ${label} 0`] : [` ${label} ${values.join(" · ")}`];
366
- }
367
- function journalBody(fact) {
368
- switch (fact.kind) {
369
- case "bind": {
370
- const { coordinates, terms } = fact.data;
371
- return [
372
- ` start ${coordinates.start}`,
373
- ...(coordinates.target === undefined ? [] : [` target ${coordinates.target}`]),
374
- ` workspace ${coordinates.workspace}`,
375
- ` document ${terms.document.key}`,
376
- ...listFact("gates", terms.gates),
377
- ...listFact("after", terms.after),
378
- ];
379
- }
380
- case "amend":
381
- return [
382
- ` document ${fact.data.document.key}`,
383
- ...listFact("gates", fact.data.gates),
384
- ...listFact("after", fact.data.after),
385
- ];
386
- case "bound":
387
- return [];
388
- case "deliver": {
389
- const { tenderSnapshot, integration, method, policy } = fact.data;
390
- return [
391
- ` tender ${tenderSnapshot}`,
392
- ` predecessor ${integration.predecessor}`,
393
- ` snapshot ${integration.snapshot}`,
394
- ` change ${integration.changeId}`,
395
- ` method ${method}`,
396
- ` require-branches-to-be-up-to-date ${String(policy.requireBranchesToBeUpToDate)}`,
397
- ];
398
- }
399
- case "reintegrated":
400
- return [
401
- ` predecessor ${fact.data.predecessor}`,
402
- ` snapshot ${fact.data.snapshot}`,
403
- ];
404
- case "attestation": {
405
- const lines = [
406
- ` gate ${fact.data.gate}`,
407
- ` verdict ${fact.data.verdict}`,
408
- ` subject ${fact.data.subject}`,
409
- ];
410
- if (fact.data.summary !== undefined)
411
- receiptPayload(lines, "summary", fact.data.summary);
412
- return lines;
413
- }
414
- case "claimed":
415
- return [` delivery ${fact.data.delivery}`];
416
- case "arc": {
417
- const lines = [` sequence ${String(fact.data.seq)}`, ` title ${fact.data.title}`];
418
- receiptPayload(lines, "objective", fact.data.objective);
419
- receiptPayload(lines, "brief", fact.data.brief);
420
- return lines;
421
- }
422
- case "abandoned": {
423
- if (fact.data.note === undefined)
424
- return [];
425
- const lines = [];
426
- receiptPayload(lines, "note", fact.data.note);
427
- return lines;
428
- }
429
- }
430
- }
431
- function contractHistoryEventLines(event) {
432
- if (event.source === "dispatch") {
433
- return [`${event.dispatch.dispatchedAt} dispatch · ${event.dispatch.akuId}`];
434
- }
435
- return [journalHead(event.fact), ...journalBody(event.fact)];
436
- }
437
- export function renderContractHistory(history) {
438
- const journals = journalCount(history.events, "journal");
439
- const dispatches = journalCount(history.events, "dispatch");
440
- return [
441
- `history ${history.id} · ${journals} journal · ${dispatches} dispatch`,
442
- "",
443
- ...history.events.flatMap(contractHistoryEventLines),
444
- ].join("\n");
445
- }
344
+ export { renderContractHistory } from "./contract-history.js";