@astrosheep/keiyaku 4.6.30 → 4.6.31

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 (398) hide show
  1. package/README.md +5 -5
  2. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  3. package/build/plugins/claude/skills/keiyaku/SKILL.md +12 -12
  4. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -16
  5. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +14 -14
  6. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +10 -10
  7. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +15 -15
  8. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +16 -16
  9. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +21 -21
  10. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  11. package/build/plugins/codex/skills/keiyaku/SKILL.md +12 -12
  12. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -16
  13. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +14 -14
  14. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +10 -10
  15. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +15 -15
  16. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +16 -16
  17. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +21 -21
  18. package/build/plugins/opencode/package.json +1 -1
  19. package/build/plugins/opencode/skills/keiyaku/SKILL.md +12 -12
  20. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -16
  21. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +14 -14
  22. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +10 -10
  23. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +15 -15
  24. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +16 -16
  25. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +21 -21
  26. package/build/plugins/pi/README.md +5 -5
  27. package/build/plugins/pi/akuma-tools.ts +17 -23
  28. package/build/skills/keiyaku/SKILL.md +12 -12
  29. package/build/skills/keiyaku-akuma/SKILL.md +16 -16
  30. package/build/skills/keiyaku-akuma/references/automation.md +14 -14
  31. package/build/skills/keiyaku-babysit/SKILL.md +10 -10
  32. package/build/skills/keiyaku-bind/SKILL.md +15 -15
  33. package/build/skills/keiyaku-debt/SKILL.md +16 -16
  34. package/build/skills/keiyaku-workflow/SKILL.md +21 -21
  35. package/build/src/akuma/akuma-call.d.ts +1 -1
  36. package/build/src/akuma/akuma-call.js +9 -9
  37. package/build/src/akuma/akuma-errors.d.ts +5 -5
  38. package/build/src/akuma/akuma-instance.d.ts +355 -12
  39. package/build/src/akuma/akuma-instance.js +20 -20
  40. package/build/src/akuma/akuma-observe.d.ts +11 -12
  41. package/build/src/akuma/akuma-observe.js +34 -26
  42. package/build/src/akuma/akuma-owner.d.ts +32 -11
  43. package/build/src/akuma/akuma-owner.js +35 -16
  44. package/build/src/akuma/akuma-probe.d.ts +3 -3
  45. package/build/src/akuma/akuma-probe.js +2 -2
  46. package/build/src/akuma/akuma-selection-execution.d.ts +985 -1
  47. package/build/src/akuma/akuma-selection-execution.js +42 -18
  48. package/build/src/akuma/akuma-stream.d.ts +2 -2
  49. package/build/src/akuma/akuma-stream.js +1 -1
  50. package/build/src/akuma/akuma-wait.d.ts +5 -5
  51. package/build/src/akuma/akuma-wait.js +52 -14
  52. package/build/src/akuma/akuma.d.ts +245 -271
  53. package/build/src/akuma/akuma.js +98 -46
  54. package/build/src/akuma/archetype.d.ts +19 -6
  55. package/build/src/akuma/archetype.js +25 -9
  56. package/build/src/akuma/body-launch.d.ts +2 -2
  57. package/build/src/akuma/body.js +4 -4
  58. package/build/src/akuma/call-initial-tell.d.ts +60 -44
  59. package/build/src/akuma/call-initial-tell.js +41 -2
  60. package/build/src/akuma/caller.d.ts +26 -17
  61. package/build/src/akuma/caller.js +22 -9
  62. package/build/src/akuma/coordinate.d.ts +9 -0
  63. package/build/src/akuma/coordinate.js +13 -0
  64. package/build/src/akuma/detached-body.js +2 -2
  65. package/build/src/akuma/dispatch-association.d.ts +4 -4
  66. package/build/src/akuma/dispatch-association.js +12 -3
  67. package/build/src/akuma/execution-instructions.js +2 -2
  68. package/build/src/akuma/heart/facts.d.ts +29 -7
  69. package/build/src/akuma/heart/facts.js +13 -0
  70. package/build/src/akuma/heart/index.d.ts +0 -3
  71. package/build/src/akuma/heart/index.js +3 -6
  72. package/build/src/akuma/heart/rows.js +2 -2
  73. package/build/src/akuma/heart/soul.js +5 -5
  74. package/build/src/akuma/identity.d.ts +17 -16
  75. package/build/src/akuma/identity.js +20 -19
  76. package/build/src/akuma/index.d.ts +1 -2
  77. package/build/src/akuma/lineage-cache.d.ts +4 -4
  78. package/build/src/akuma/lineage-cache.js +10 -10
  79. package/build/src/akuma/projection-read.d.ts +2 -5
  80. package/build/src/akuma/projection-read.js +34 -47
  81. package/build/src/akuma/projection.d.ts +659 -569
  82. package/build/src/akuma/projection.js +203 -94
  83. package/build/src/akuma/providers/acp/index.js +1 -1
  84. package/build/src/akuma/providers/execution-environment.d.ts +1 -3
  85. package/build/src/akuma/providers/execution-environment.js +0 -4
  86. package/build/src/akuma/publication.d.ts +2 -2
  87. package/build/src/akuma/publication.js +3 -3
  88. package/build/src/akuma/retention.js +2 -2
  89. package/build/src/akuma/selection-observation.d.ts +507 -43
  90. package/build/src/akuma/selection-observation.js +153 -1
  91. package/build/src/akuma/status-projection.d.ts +288 -0
  92. package/build/src/akuma/status-projection.js +154 -0
  93. package/build/src/akuma/turn-drive.js +0 -3
  94. package/build/src/alias/index.d.ts +9 -4
  95. package/build/src/alias/index.js +11 -9
  96. package/build/src/bounded-list.d.ts +8 -0
  97. package/build/src/bounded-list.js +9 -0
  98. package/build/src/cli/commands/akuma-grammar.d.ts +2 -2
  99. package/build/src/cli/commands/akuma-grammar.js +21 -21
  100. package/build/src/cli/commands/akuma.d.ts +1 -2
  101. package/build/src/cli/commands/akuma.js +115 -251
  102. package/build/src/cli/commands/contract-grammar.d.ts +4 -3
  103. package/build/src/cli/commands/contract-grammar.js +39 -22
  104. package/build/src/cli/commands/contract-help.d.ts +3 -1
  105. package/build/src/cli/commands/contract-help.js +4 -3
  106. package/build/src/cli/commands/contract.d.ts +6 -3
  107. package/build/src/cli/commands/contract.js +203 -434
  108. package/build/src/cli/commands/debt.d.ts +2 -3
  109. package/build/src/cli/commands/debt.js +101 -317
  110. package/build/src/cli/commands/report.js +11 -28
  111. package/build/src/cli/commands/whoami.d.ts +3 -43
  112. package/build/src/cli/commands/whoami.js +8 -121
  113. package/build/src/cli/coordinates.d.ts +4 -35
  114. package/build/src/cli/coordinates.js +13 -129
  115. package/build/src/cli/parse.d.ts +0 -6
  116. package/build/src/cli/parse.js +5 -48
  117. package/build/src/cli/render/akuma-activity.d.ts +31 -16
  118. package/build/src/cli/render/akuma-activity.js +157 -149
  119. package/build/src/cli/render/akuma-tool.d.ts +3 -6
  120. package/build/src/cli/render/akuma-tool.js +20 -14
  121. package/build/src/cli/render/akuma.d.ts +25 -26
  122. package/build/src/cli/render/akuma.js +100 -129
  123. package/build/src/cli/render/catalog.d.ts +4 -7
  124. package/build/src/cli/render/catalog.js +52 -99
  125. package/build/src/cli/render/contract-history.d.ts +3 -1
  126. package/build/src/cli/render/contract-history.js +140 -215
  127. package/build/src/cli/render/contract-observation.d.ts +43 -30
  128. package/build/src/cli/render/contract-observation.js +64 -31
  129. package/build/src/cli/render/contract-wait.js +6 -6
  130. package/build/src/cli/render/contract.d.ts +41 -6
  131. package/build/src/cli/render/contract.js +274 -370
  132. package/build/src/cli/render/debt.d.ts +9 -19
  133. package/build/src/cli/render/debt.js +120 -185
  134. package/build/src/cli/render/delivery-preview.d.ts +4 -3
  135. package/build/src/cli/render/delivery-preview.js +68 -96
  136. package/build/src/cli/render/kanshi-akuma.d.ts +4 -4
  137. package/build/src/cli/render/kanshi-akuma.js +70 -59
  138. package/build/src/cli/render/kanshi.d.ts +4 -4
  139. package/build/src/cli/render/kanshi.js +205 -221
  140. package/build/src/cli/render/marks.d.ts +11 -2
  141. package/build/src/cli/render/marks.js +13 -3
  142. package/build/src/cli/render/nuke.d.ts +3 -3
  143. package/build/src/cli/render/nuke.js +13 -16
  144. package/build/src/cli/render/receipt.d.ts +37 -43
  145. package/build/src/cli/render/receipt.js +313 -236
  146. package/build/src/cli/render/reconcile.d.ts +6 -4
  147. package/build/src/cli/render/reconcile.js +53 -137
  148. package/build/src/cli/render/refusal.d.ts +3 -2
  149. package/build/src/cli/render/refusal.js +73 -54
  150. package/build/src/cli/render/region.d.ts +11 -2
  151. package/build/src/cli/render/region.js +17 -23
  152. package/build/src/cli/render/settings.d.ts +0 -1
  153. package/build/src/cli/render/settings.js +8 -17
  154. package/build/src/cli/render/terminal.d.ts +2 -0
  155. package/build/src/cli/render/verbs.d.ts +4 -0
  156. package/build/src/cli/render/verbs.js +312 -0
  157. package/build/src/cli/render/whoami.d.ts +1 -1
  158. package/build/src/cli/render/whoami.js +24 -31
  159. package/build/src/cli/runtime.d.ts +3 -11
  160. package/build/src/cli/runtime.js +96 -79
  161. package/build/src/cli/scan.d.ts +1 -1
  162. package/build/src/cli/streams.js +1 -0
  163. package/build/src/contract-guidance.js +2 -2
  164. package/build/src/contract-worktree.d.ts +2 -15
  165. package/build/src/contract-worktree.js +19 -35
  166. package/build/src/core/facts/observation.d.ts +4 -5
  167. package/build/src/core/facts/observation.js +7 -9
  168. package/build/src/core/verbs/amend.d.ts +0 -1
  169. package/build/src/core/verbs/amend.js +3 -3
  170. package/build/src/core/verbs/bind.d.ts +0 -1
  171. package/build/src/core/verbs/bind.js +5 -5
  172. package/build/src/core/verbs/deliver.d.ts +3 -2
  173. package/build/src/core/verbs/deliver.js +2 -2
  174. package/build/src/core/verbs/placement.d.ts +0 -5
  175. package/build/src/core/verbs/placement.js +4 -6
  176. package/build/src/core/verbs/reintegrate.d.ts +0 -1
  177. package/build/src/core/verbs/reintegrate.js +2 -2
  178. package/build/src/debt/board.d.ts +132 -116
  179. package/build/src/debt/board.js +138 -94
  180. package/build/src/debt/catalog.d.ts +4 -4
  181. package/build/src/debt/catalog.js +2 -18
  182. package/build/src/debt/context.d.ts +15 -3
  183. package/build/src/debt/context.js +12 -1
  184. package/build/src/debt/created-observation.d.ts +5 -17
  185. package/build/src/debt/created-observation.js +14 -6
  186. package/build/src/debt/document.d.ts +20 -15
  187. package/build/src/debt/document.js +18 -1
  188. package/build/src/debt/index.d.ts +346 -23
  189. package/build/src/debt/index.js +68 -22
  190. package/build/src/debt/input.d.ts +2 -1
  191. package/build/src/debt/input.js +14 -0
  192. package/build/src/debt/lifecycle-operations.d.ts +2 -2
  193. package/build/src/debt/lifecycle-operations.js +14 -22
  194. package/build/src/debt/operation-types.d.ts +188 -66
  195. package/build/src/debt/operation-types.js +113 -1
  196. package/build/src/debt/operations.d.ts +11 -10
  197. package/build/src/debt/operations.js +46 -71
  198. package/build/src/debt/query.d.ts +14 -10
  199. package/build/src/debt/query.js +3 -12
  200. package/build/src/debt/store.d.ts +4 -2
  201. package/build/src/debt/store.js +8 -8
  202. package/build/src/debt/view.d.ts +0 -3
  203. package/build/src/debt/view.js +0 -4
  204. package/build/src/dispatch/index.d.ts +22 -5
  205. package/build/src/dispatch/index.js +46 -37
  206. package/build/src/git/admission.d.ts +2 -2
  207. package/build/src/git/admission.js +2 -1
  208. package/build/src/git/hooks.d.ts +14 -35
  209. package/build/src/git/hooks.js +45 -25
  210. package/build/src/git/integration.d.ts +6 -24
  211. package/build/src/git/integration.js +10 -16
  212. package/build/src/git/private-state-seat.d.ts +2 -2
  213. package/build/src/git/private-state-seat.js +2 -1
  214. package/build/src/git/reconcile.d.ts +17 -79
  215. package/build/src/git/reconcile.js +37 -52
  216. package/build/src/git/scratch.d.ts +3 -3
  217. package/build/src/git/scratch.js +4 -1
  218. package/build/src/git/target-placement.d.ts +23 -31
  219. package/build/src/git/target-placement.js +42 -27
  220. package/build/src/git/target.d.ts +2 -2
  221. package/build/src/git/target.js +2 -1
  222. package/build/src/git/tender.d.ts +7 -39
  223. package/build/src/git/tender.js +21 -54
  224. package/build/src/git/terminal-reconcile.js +15 -18
  225. package/build/src/git/terminal-seal.d.ts +2 -4
  226. package/build/src/git/terminal-seal.js +7 -33
  227. package/build/src/git/workspace.d.ts +65 -41
  228. package/build/src/git/workspace.js +45 -14
  229. package/build/src/identity/selector.d.ts +2 -0
  230. package/build/src/identity/selector.js +13 -3
  231. package/build/src/index.d.ts +48 -54
  232. package/build/src/index.js +31 -43
  233. package/build/src/kanshi/counts.d.ts +42 -8
  234. package/build/src/kanshi/counts.js +13 -2
  235. package/build/src/kanshi/index.d.ts +5 -5
  236. package/build/src/kanshi/index.js +4 -3
  237. package/build/src/kanshi/read.d.ts +489 -6
  238. package/build/src/kanshi/read.js +334 -483
  239. package/build/src/kanshi/report.d.ts +2504 -103
  240. package/build/src/kanshi/report.js +165 -1
  241. package/build/src/kanshi/select.d.ts +0 -8
  242. package/build/src/kanshi/select.js +20 -59
  243. package/build/src/library/address.d.ts +8 -8
  244. package/build/src/library/address.js +7 -7
  245. package/build/src/library/akuma-creation.d.ts +690 -84
  246. package/build/src/library/akuma-creation.js +202 -142
  247. package/build/src/library/akuma-retention.d.ts +2 -2
  248. package/build/src/library/akuma-retention.js +2 -2
  249. package/build/src/library/akumas.d.ts +10 -6
  250. package/build/src/library/akumas.js +24 -7
  251. package/build/src/library/bind.d.ts +28 -54
  252. package/build/src/library/bind.js +6 -4
  253. package/build/src/library/continuation.d.ts +197 -479
  254. package/build/src/library/continuation.js +40 -23
  255. package/build/src/library/contract-address.d.ts +6 -5
  256. package/build/src/library/contract-address.js +5 -7
  257. package/build/src/library/contract-composition.d.ts +18 -12
  258. package/build/src/library/contract-composition.js +55 -47
  259. package/build/src/library/contract-creation.d.ts +3 -2
  260. package/build/src/library/contract-creation.js +38 -32
  261. package/build/src/library/contract-execution.js +77 -38
  262. package/build/src/library/contract-outcomes.d.ts +1877 -27
  263. package/build/src/library/contract-outcomes.js +93 -10
  264. package/build/src/library/contract-settings.d.ts +2 -2
  265. package/build/src/library/contract-settings.js +18 -14
  266. package/build/src/library/contract-types.d.ts +238 -61
  267. package/build/src/library/contract-types.js +131 -1
  268. package/build/src/library/contract-wait.d.ts +38 -17
  269. package/build/src/library/contract-wait.js +40 -10
  270. package/build/src/library/delivery.d.ts +588 -36
  271. package/build/src/library/delivery.js +35 -27
  272. package/build/src/library/input.d.ts +1 -1
  273. package/build/src/library/input.js +1 -2
  274. package/build/src/library/invocation.d.ts +11 -7
  275. package/build/src/library/invocation.js +42 -51
  276. package/build/src/library/kei.d.ts +48 -0
  277. package/build/src/library/kei.js +256 -0
  278. package/build/src/library/keiyaku-attribution.d.ts +11 -0
  279. package/build/src/{cli/delivery-identity.js → library/keiyaku-attribution.js} +12 -1
  280. package/build/src/library/keiyaku-classify.d.ts +11 -0
  281. package/build/src/library/keiyaku-classify.js +146 -0
  282. package/build/src/library/keiyaku-coordinates.d.ts +31 -0
  283. package/build/src/library/keiyaku-coordinates.js +103 -0
  284. package/build/src/library/keiyaku-debt.d.ts +142 -0
  285. package/build/src/library/keiyaku-debt.js +188 -0
  286. package/build/src/library/keiyaku-identity.d.ts +58 -0
  287. package/build/src/library/keiyaku-identity.js +176 -0
  288. package/build/src/library/keiyaku-policy.d.ts +27 -0
  289. package/build/src/library/keiyaku-policy.js +44 -0
  290. package/build/src/library/keiyaku-status.d.ts +1487 -0
  291. package/build/src/library/keiyaku-status.js +92 -0
  292. package/build/src/library/keiyaku-verbs.d.ts +6774 -0
  293. package/build/src/library/keiyaku-verbs.js +458 -0
  294. package/build/src/library/keiyaku.d.ts +871 -38
  295. package/build/src/library/keiyaku.js +677 -127
  296. package/build/src/library/nuke.d.ts +22 -0
  297. package/build/src/library/nuke.js +4 -1
  298. package/build/src/library/outcome.d.ts +706 -692
  299. package/build/src/library/outcome.js +582 -167
  300. package/build/src/library/reconcile.d.ts +464 -116
  301. package/build/src/library/reconcile.js +174 -102
  302. package/build/src/library/refusal.d.ts +113 -577
  303. package/build/src/library/refusal.js +64 -51
  304. package/build/src/library/region.d.ts +5 -24
  305. package/build/src/library/region.js +6 -21
  306. package/build/src/library/selection.d.ts +181 -32
  307. package/build/src/library/selection.js +99 -64
  308. package/build/src/mcp/adapter.d.ts +11 -0
  309. package/build/src/mcp/adapter.js +106 -0
  310. package/build/src/mcp/help.d.ts +1 -0
  311. package/build/src/mcp/help.js +26 -0
  312. package/build/src/mcp/index.d.ts +2 -0
  313. package/build/src/mcp/index.js +37 -0
  314. package/build/src/plugin/public.d.ts +1 -1
  315. package/build/src/plugin/runtime.js +17 -14
  316. package/build/src/protocol/arc.d.ts +4 -1
  317. package/build/src/protocol/arc.js +7 -1
  318. package/build/src/protocol/attempt.d.ts +2 -3
  319. package/build/src/protocol/attempt.js +1 -10
  320. package/build/src/protocol/bind.d.ts +6 -7
  321. package/build/src/protocol/bind.js +9 -5
  322. package/build/src/protocol/completion.d.ts +448 -12
  323. package/build/src/protocol/completion.js +164 -26
  324. package/build/src/protocol/deliver.d.ts +26 -24
  325. package/build/src/protocol/deliver.js +24 -52
  326. package/build/src/protocol/delivery-preview.d.ts +97 -247
  327. package/build/src/protocol/delivery-preview.js +132 -128
  328. package/build/src/protocol/execution-observation.d.ts +146 -123
  329. package/build/src/protocol/execution-observation.js +9 -6
  330. package/build/src/protocol/intent.d.ts +9 -48
  331. package/build/src/protocol/intent.js +32 -46
  332. package/build/src/protocol/operations.d.ts +207 -505
  333. package/build/src/protocol/operations.js +81 -134
  334. package/build/src/protocol/placement.d.ts +0 -1
  335. package/build/src/protocol/placement.js +5 -2
  336. package/build/src/protocol/progress.d.ts +7 -97
  337. package/build/src/protocol/progress.js +7 -55
  338. package/build/src/protocol/read/observation.d.ts +13 -6
  339. package/build/src/protocol/read/observation.js +10 -9
  340. package/build/src/protocol/read/status.d.ts +464 -93
  341. package/build/src/protocol/read/status.js +372 -85
  342. package/build/src/protocol/reconcile.d.ts +2 -0
  343. package/build/src/protocol/reconcile.js +12 -11
  344. package/build/src/protocol/reintegrate.d.ts +0 -1
  345. package/build/src/protocol/reintegrate.js +4 -4
  346. package/build/src/protocol/result-leaves.d.ts +528 -0
  347. package/build/src/protocol/result-leaves.js +195 -0
  348. package/build/src/protocol/result-reasons.d.ts +129 -0
  349. package/build/src/protocol/result-reasons.js +87 -0
  350. package/build/src/protocol/review.d.ts +14 -11
  351. package/build/src/protocol/review.js +30 -14
  352. package/build/src/protocol/run.d.ts +4 -4
  353. package/build/src/protocol/run.js +4 -1
  354. package/build/src/protocol/verify.d.ts +359 -30
  355. package/build/src/protocol/verify.js +118 -28
  356. package/build/src/region.d.ts +26 -0
  357. package/build/src/region.js +28 -0
  358. package/build/src/runtime/proc/diagnostic.d.ts +11 -0
  359. package/build/src/runtime/proc/diagnostic.js +20 -0
  360. package/build/src/runtime/proc/windows-launch.exe +0 -0
  361. package/build/src/settings.d.ts +126 -32
  362. package/build/src/settings.js +107 -34
  363. package/build/src/settlement/settle.d.ts +29 -12
  364. package/build/src/settlement/settle.js +22 -15
  365. package/build/src/verification/declaration.d.ts +1 -3
  366. package/build/src/verification/declaration.js +2 -5
  367. package/build/src/verification/execution.d.ts +7 -19
  368. package/build/src/verification/execution.js +37 -16
  369. package/build/src/verification/observation.d.ts +13 -13
  370. package/build/src/verification/observation.js +9 -7
  371. package/build/src/world.d.ts +8 -0
  372. package/build/src/world.js +7 -0
  373. package/package.json +6 -5
  374. package/plugins/paseo/plugin/server/keiyaku.ts +13 -46
  375. package/plugins/paseo/plugin/server/message.ts +8 -30
  376. package/plugins/paseo/plugin/server/mirror.ts +16 -20
  377. package/plugins/paseo/plugin/server/provider.ts +1 -1
  378. package/plugins/paseo/plugin/server/sdk.ts +14 -6
  379. package/plugins/pi/README.md +5 -5
  380. package/plugins/pi/akuma-tools.ts +17 -23
  381. package/skills/keiyaku/SKILL.md +12 -12
  382. package/skills/keiyaku-akuma/SKILL.md +16 -16
  383. package/skills/keiyaku-akuma/references/automation.md +14 -14
  384. package/skills/keiyaku-babysit/SKILL.md +10 -10
  385. package/skills/keiyaku-bind/SKILL.md +15 -15
  386. package/skills/keiyaku-debt/SKILL.md +16 -16
  387. package/skills/keiyaku-workflow/SKILL.md +21 -21
  388. package/build/src/cli/actor.d.ts +0 -10
  389. package/build/src/cli/actor.js +0 -24
  390. package/build/src/cli/akuma-caller.d.ts +0 -3
  391. package/build/src/cli/akuma-caller.js +0 -31
  392. package/build/src/cli/delivery-identity.d.ts +0 -3
  393. package/build/src/cli/render/effects.d.ts +0 -26
  394. package/build/src/cli/render/effects.js +0 -41
  395. package/build/src/cli/selectors.d.ts +0 -10
  396. package/build/src/cli/selectors.js +0 -42
  397. package/build/src/markdown/diff.d.ts +0 -1
  398. package/build/src/markdown/diff.js +0 -4
@@ -1,29 +1,19 @@
1
- import type { CliOutcome } from "../streams.js";
2
- import type { BlockedDebtList, DebtBatchResult, DebtContextResult, DebtDecompositionTree, DebtDetail, DebtDoctorReport, DebtList, DebtMutationResult, DebtQueryResult, DebtUpdateResult } from "../../debt/index.js";
1
+ import type { BlockedDebtRow, DebtAbsent, DebtBatchResult, DebtCatalogue, DebtContextResult, DebtDoctorReport, DebtMutationResult, DebtParentReadRefusal, DebtReadPage, DebtReadRefusal, DebtShowResult, DebtSummary, DebtTreeResult, DebtUpdateResult, ReadyDebtRow } from "../../debt/index.js";
3
2
  import { type TextRenderContext } from "./terminal.js";
4
3
  export { debtMark } from "./marks.js";
5
- type DebtListOutcome = DebtList | BlockedDebtList | DebtQueryResult;
6
- /** One addressed show selection: native details, or a refusal naming a missing addressed read. */
7
- export type DebtShowResult = DebtDetail | DebtDetail[] | Extract<DebtMutationResult, {
8
- kind: "refused";
9
- }>;
10
4
  /** Presentation-only list scope the leaf acquired; never part of a product value. */
11
5
  export type DebtListScope = "world" | "current" | Readonly<{
12
6
  namespace: string;
13
7
  }>;
14
- /** The union of native Debt SDK answers one leaf renders directly; the CLI adds no result envelope. */
15
- type DebtNativeResult = DebtMutationResult | DebtUpdateResult | DebtBatchResult | DebtShowResult | DebtList | BlockedDebtList | DebtQueryResult | DebtDecompositionTree | DebtDoctorReport | DebtContextResult;
16
- /** Debt dispositions and relation states are snake_case facts; people read them as words. */
17
8
  export declare function dispositionText(word: string): string;
18
9
  export declare function debtFrameHead(view: string, scope: string): string;
19
- export declare function renderDebtList(action: "ls" | "ready" | "blocked" | "query", scope: DebtListScope, result: DebtListOutcome, context?: TextRenderContext): string;
20
- export declare function renderDebtShow(result: DebtShowResult, context?: TextRenderContext): string;
21
- export declare function renderDoctor(report: DebtDoctorReport): string;
22
- export declare function renderDebtUpdate(result: DebtUpdateResult, context?: TextRenderContext): string;
23
- export declare function renderDebtTree(result: DebtDecompositionTree, context?: TextRenderContext): string;
10
+ export declare function renderDebtList(action: "ls" | "ready" | "blocked" | "query", scope: DebtListScope, result: DebtCatalogue | DebtReadPage<DebtSummary | BlockedDebtRow | ReadyDebtRow, DebtReadRefusal | DebtParentReadRefusal>, context?: TextRenderContext): string;
11
+ /** Each item corresponds to the same invocation position, including missing targets. */
12
+ export declare function renderDebtShow(ids: readonly string[], result: DebtShowResult | DebtAbsent, context?: TextRenderContext): string;
13
+ export declare function renderDoctor(report: DebtDoctorReport | DebtAbsent): string;
14
+ export declare function renderDebtUpdate(id: string | undefined, result: DebtUpdateResult, context?: TextRenderContext): string;
15
+ export declare function renderDebtTree(id: string, result: DebtTreeResult | DebtAbsent, context?: TextRenderContext): string;
24
16
  export declare function renderDebtContext(result: DebtContextResult, context?: TextRenderContext): string;
25
- /** One single-Debt mutation answer; `verb` is the literal action the leaf invoked. */
17
+ /** Creation retains its minted identity in the native answer. */
26
18
  export declare function renderDebtMutation(verb: string, result: DebtMutationResult, context?: TextRenderContext): string;
27
- /** One lifecycle answer: a single mutation or a plural batch, both native shapes. */
28
- export declare function renderDebtLifecycle(verb: string, result: DebtMutationResult | DebtBatchResult, context?: TextRenderContext): string;
29
- export declare function debtOutcome(result: DebtNativeResult): CliOutcome;
19
+ export declare function renderDebtLifecycle(verb: string, ids: readonly string[], result: DebtBatchResult, context?: TextRenderContext): string;
@@ -1,174 +1,131 @@
1
1
  import { debtMark } from "./marks.js";
2
2
  import { outcomeLines, receiptPayload, receiptRow, refusalLines } from "./receipt.js";
3
- import { DEFAULT_CLI_COLUMNS, displayColumns, emptyCatalogue, renderTextBlock, safeText, } from "./terminal.js";
3
+ import { DEFAULT_CLI_COLUMNS, displayColumns, emptyCatalogue, renderOpaqueBlock, renderTextBlock, safeText, } from "./terminal.js";
4
4
  export { debtMark } from "./marks.js";
5
5
  const DEFAULT_CONTEXT = { columns: DEFAULT_CLI_COLUMNS, color: false };
6
- /** Debt dispositions and relation states are snake_case facts; people read them as words. */
7
6
  export function dispositionText(word) {
8
7
  return word === "drop" ? "dropped" : word.replaceAll("_", " ");
9
8
  }
10
- function priorityText(priority) {
11
- return priority === null ? "P?" : `P${priority}`;
12
- }
13
- function scanUnit(id, priority, word) {
14
- return word === undefined
15
- ? `${debtMark("ready")} ${id} · ${priorityText(priority)}`
16
- : `${debtMark(word)} ${id} · ${dispositionText(word)} · ${priorityText(priority)}`;
17
- }
18
9
  function entityLines(entity, columns, indent = "") {
19
- const scan = `${indent}${scanUnit(entity.id, entity.priority, entity.word)}${entity.facts === undefined ? "" : ` · ${entity.facts}`}`;
20
- if (entity.title === null || entity.title.length === 0)
21
- return [scan];
10
+ const parts = [
11
+ `${entity.mark} ${entity.id}`,
12
+ ...(entity.word === undefined ? [] : [dispositionText(entity.word)]),
13
+ `P${entity.priority}`,
14
+ ];
15
+ const scan = `${indent}${parts.join(" · ")}`;
22
16
  const title = safeText(entity.title);
23
17
  const inline = `${scan} — ${title}`;
24
18
  if (displayColumns(inline) <= columns)
25
19
  return [inline];
26
20
  return [scan, ...renderTextBlock(title, `${indent} `, columns, "—")];
27
21
  }
28
- function stateEntity(debt) {
29
- return {
30
- id: debt.id,
31
- priority: "priority" in debt && debt.priority !== undefined ? debt.priority : null,
32
- word: debt.state,
33
- title: debt.title,
34
- };
35
- }
36
22
  function projectRefusal(refusal) {
37
- const diagnostic = refusal.kind.replaceAll("-", " ");
38
- if (refusal.kind === "debt-missing")
39
- return { diagnostic, facts: [`debt ${refusal.debtId}`] };
40
- if (refusal.kind === "invalid-lifecycle-transition") {
41
- return { diagnostic, facts: [`debt ${refusal.debtId}`, `state ${refusal.state} · verb ${refusal.verb}`] };
42
- }
43
- if (refusal.kind === "invalid-namespace-context")
44
- return { diagnostic, facts: [`path ${refusal.path}`] };
45
- if (refusal.kind === "relation-owned-by-other") {
46
- return {
47
- diagnostic,
48
- facts: [
49
- `debt ${refusal.debtId}`,
50
- `related debt ${refusal.related}`,
51
- `declaring debt ${refusal.declaringDebt}`,
52
- ],
53
- };
54
- }
55
- return refusal.diagnostic === undefined ? { diagnostic } : { diagnostic, facts: [`detail ${refusal.diagnostic}`] };
56
- }
57
- function renderFailure(verb, result, columns) {
58
- if (result.kind === "retry") {
59
- return [...outcomeLines("?", verb, "retry", undefined, columns), result.reason].join("\n");
60
- }
61
- const facts = projectRefusal(result.refusal);
62
- return refusalLines(verb, [`reason ${facts.diagnostic}`, ...(facts.facts ?? [])], columns).join("\n");
63
- }
64
- function edge(label, ref, mark) {
65
- const prefix = mark === undefined ? ` ${label}` : ` ${mark} ${label}`;
66
- return `${prefix} ${ref.id} · ${dispositionText(ref.state)}`;
23
+ const diagnostic = refusal.reason.replaceAll("-", " ");
24
+ if (refusal.reason === "debt-missing")
25
+ return { diagnostic, ...("debtId" in refusal ? { facts: [`debt ${refusal.debtId}`] } : {}) };
26
+ if (refusal.reason === "invalid-lifecycle-transition")
27
+ return { diagnostic, facts: [`state ${dispositionText(refusal.state)}`] };
28
+ if (refusal.reason === "invalid-namespace-context")
29
+ return { diagnostic, ...(refusal.path === undefined ? {} : { facts: [`path ${refusal.path}`] }) };
30
+ if (refusal.reason === "relation-owned-by-other")
31
+ return { diagnostic, facts: [`related debt ${refusal.related}`] };
32
+ return { diagnostic, facts: [`detail ${refusal.diagnostic}`] };
33
+ }
34
+ function renderFailure(verb, result, columns, id) {
35
+ if (result.kind === "retry")
36
+ return [...outcomeLines("?", verb, "retry", id, columns), result.reason].join("\n");
37
+ const facts = projectRefusal(result);
38
+ return refusalLines(verb, [...(id === undefined ? [] : [`debt ${id}`]), `reason ${facts.diagnostic}`, ...(facts.facts ?? [])], columns).join("\n");
39
+ }
40
+ /** A cleanup problem cannot reverse the confirmed write. */
41
+ function warningLines(warning, columns) {
42
+ return [" ! warning", ...renderOpaqueBlock(warning, " ", columns)];
43
+ }
44
+ function edge(label, ref) {
45
+ return ` ${label} ${ref.id} · ${dispositionText(ref.state)}`;
67
46
  }
68
47
  export function debtFrameHead(view, scope) {
69
48
  return `${view.toUpperCase()} // ${scope}`;
70
49
  }
71
- function updatedAge(updatedAt) {
72
- const elapsed = Math.max(0, performance.timeOrigin + performance.now() - Date.parse(updatedAt));
73
- const minutes = Math.floor(elapsed / 60_000);
74
- if (minutes < 60)
75
- return `${minutes}m`;
76
- const hours = Math.floor(minutes / 60);
77
- if (hours < 24)
78
- return `${hours}h`;
79
- return `${Math.floor(hours / 24)}d`;
80
- }
81
- function compactFacts(item) {
82
- return [
83
- `updated ${updatedAge(item.updatedAt)}`,
84
- ...(item.children === undefined ? [] : [`children ${item.children.live} live · ${item.children.total} total`]),
85
- ].join(" · ");
86
- }
87
- function listEntity(item, omitDisposition) {
88
- return {
89
- id: item.id,
90
- priority: item.priority,
91
- ...(omitDisposition ? {} : { word: item.disposition }),
92
- facts: compactFacts(item),
93
- title: item.title,
94
- };
95
- }
96
- function renderListRow(item, columns, omitDisposition) {
97
- const lines = [...entityLines(listEntity(item, omitDisposition), columns)];
98
- if ("blockers" in item) {
50
+ function renderListRow(item, columns, action) {
51
+ const disposition = "disposition" in item ? item.disposition : action === "blocked" ? "blocked" : "ready";
52
+ const lines = [
53
+ ...entityLines({
54
+ ...item,
55
+ mark: debtMark(disposition),
56
+ ...(action === "ready" || action === "blocked" ? {} : { word: disposition }),
57
+ }, columns),
58
+ ];
59
+ if ("blockers" in item)
99
60
  for (const blocker of item.blockers)
100
- lines.push(` needs ${blocker.id} · ${dispositionText(blocker.state)}`);
101
- }
61
+ lines.push(` needs ${blocker.id} · ${blocker.missing === true ? "missing" : "open"}`);
102
62
  return lines;
103
63
  }
104
64
  export function renderDebtList(action, scope, result, context = DEFAULT_CONTEXT) {
65
+ const page = result;
105
66
  const columns = context.columns;
106
- if (result.kind !== "accepted")
107
- return renderFailure(action, result, columns);
67
+ if (page.kind === "absent")
68
+ return "debt world absent";
69
+ if (page.kind === "invalid-namespace-context")
70
+ return refusalLines(action, ["reason invalid namespace context", `path ${page.path}`], columns).join("\n");
71
+ if (page.kind === "refused")
72
+ return renderFailure(action, page, columns);
73
+ const rows = page.rows ?? [];
108
74
  const view = action === "ls" ? "debts" : action;
109
- const footer = result.value.hasMore ? ["…"] : [];
75
+ if (rows.length === 0)
76
+ return emptyCatalogue(view);
110
77
  const scopeText = scope === "world"
111
78
  ? "world"
112
79
  : scope === "current"
113
80
  ? "current namespace"
114
81
  : `namespace ${scope.namespace.replace(/^debt\//u, "").replace(/\/$/u, "") || "root"}`;
115
- const heading = debtFrameHead(view, scopeText);
116
- if (result.value.rows.length === 0)
117
- return emptyCatalogue(view);
118
82
  return [
119
- heading,
120
- ...result.value.rows.flatMap((item) => renderListRow(item, columns, action === "ready")),
121
- ...footer,
83
+ debtFrameHead(view, scopeText),
84
+ ...rows.flatMap((row) => renderListRow(row, columns, action)),
85
+ ...(page.more === true ? ["…"] : []),
122
86
  ].join("\n");
123
87
  }
124
88
  function textTimestamp(timestamp) {
125
89
  return timestamp.replace(/\.\d+(?=Z$)/u, "");
126
90
  }
127
- function renderShowDetail(result, columns) {
128
- const debt = result.debt;
91
+ function renderShowDetail(id, debt, columns) {
129
92
  const lines = [
130
- ...entityLines(stateEntity(debt), columns),
93
+ ...entityLines({ id, priority: debt.priority, mark: debtMark(debt.state), word: debt.state, title: debt.title }, columns),
131
94
  ` created ${textTimestamp(debt.createdAt)}`,
132
95
  ` updated ${textTimestamp(debt.updatedAt)}`,
133
96
  ...(debt.createdBy === undefined ? [] : [` created by ${debt.createdBy}`]),
134
97
  ];
135
- for (const need of result.needs.filter((item) => !item.released))
136
- lines.push(edge("needs", need, "!"));
137
- for (const need of result.needs.filter((item) => item.released))
138
- lines.push(edge("needs", need, "✓"));
139
- for (const item of result.blocks)
140
- lines.push(edge("blocks", item));
141
- if (result.parent !== null)
142
- lines.push(edge("parent", result.parent));
143
- for (const item of result.children)
144
- lines.push(edge("child", item));
145
- for (const item of result.supersedes)
98
+ for (const need of debt.needs ?? [])
99
+ lines.push(edge("needs", need));
100
+ if (debt.parent !== undefined)
101
+ lines.push(edge("parent", debt.parent));
102
+ for (const item of debt.supersedes ?? [])
146
103
  lines.push(edge("supersedes", item));
147
- for (const item of result.supersededBy)
148
- lines.push(edge("superseded-by", item));
149
- for (const item of result.related)
150
- lines.push(edge("related", item));
151
- if (debt.note.length > 0)
104
+ for (const item of debt.relates ?? [])
105
+ lines.push(edge("relates", item));
106
+ if (debt.note !== undefined)
152
107
  receiptPayload(lines, "note", debt.note);
153
- if (debt.body.length > 0)
108
+ if (debt.body !== undefined)
154
109
  receiptPayload(lines, "body", debt.body);
155
110
  return lines.join("\n");
156
111
  }
157
- export function renderDebtShow(result, context = DEFAULT_CONTEXT) {
158
- const columns = context.columns;
159
- if (Array.isArray(result))
160
- return result.map((detail) => renderShowDetail(detail, columns)).join("\n\n");
161
- if ("kind" in result)
162
- return renderFailure("show", result, columns);
163
- return renderShowDetail(result, columns);
164
- }
165
- function treeLines(node, columns, depth = 0) {
112
+ /** Each item corresponds to the same invocation position, including missing targets. */
113
+ export function renderDebtShow(ids, result, context = DEFAULT_CONTEXT) {
114
+ if (result.kind === "absent")
115
+ return "debt world absent";
116
+ return result.items
117
+ .map((item, index) => item.kind === "found"
118
+ ? renderShowDetail(ids[index], item, context.columns)
119
+ : refusalLines("show", ["reason debt missing", `debt ${ids[index]}`], context.columns).join("\n"))
120
+ .join("\n\n");
121
+ }
122
+ function treeLines(id, node, columns, depth = 0) {
166
123
  const indent = " ".repeat(depth);
167
- if (node.cycle === true)
168
- return [`${indent}! ${node.debt.id} · cycle`];
124
+ if ("kind" in node && node.kind === "cycle")
125
+ return [`${indent}! ${node.id} · cycle`];
169
126
  return [
170
- ...entityLines(stateEntity(node.debt), columns, indent),
171
- ...node.children.flatMap((child) => treeLines(child, columns, depth + 1)),
127
+ ...entityLines({ id, priority: node.priority, mark: debtMark(node.state), word: node.state, title: node.title }, columns, indent),
128
+ ...(node.children ?? []).flatMap((child) => treeLines(child.id, child, columns, depth + 1)),
172
129
  ];
173
130
  }
174
131
  function doctorIssue(issue) {
@@ -179,79 +136,57 @@ function doctorIssue(issue) {
179
136
  return `! cycle ${issue.relation} ${issue.debts.join(" ")}`;
180
137
  }
181
138
  export function renderDoctor(report) {
182
- if (report.issues.length === 0)
139
+ if (report.kind === "absent")
140
+ return "debt world absent";
141
+ if (report.issues === undefined)
183
142
  return "✓ doctor healthy";
184
143
  const noun = report.issues.length === 1 ? "issue" : "issues";
185
144
  return [`! doctor ${report.issues.length} ${noun}`, ...report.issues.map(doctorIssue)].join("\n");
186
145
  }
187
- const PAST_VERBS = {
188
- add: "added",
189
- done: "done",
190
- drop: "dropped",
191
- update: "updated",
192
- };
193
- function renderAcceptedMutation(verb, debt, columns, changes = []) {
194
- const lines = [];
195
- receiptRow(lines, "✓", PAST_VERBS[verb] ?? verb, [{ text: debt.id, opaque: true }], columns);
196
- lines.push(...entityLines(stateEntity(debt), columns));
197
- for (const change of changes)
198
- lines.push(` ${change.field} ${change.action}`);
199
- return lines.join("\n");
200
- }
201
- function renderMutation(action, result, columns) {
202
- if (result.kind !== "accepted")
203
- return renderFailure(action, result, columns);
204
- return renderAcceptedMutation(action, result.value, columns);
205
- }
206
- export function renderDebtUpdate(result, context = DEFAULT_CONTEXT) {
146
+ const PAST_VERBS = { add: "added", done: "done", drop: "dropped", update: "updated" };
147
+ export function renderDebtUpdate(id, result, context = DEFAULT_CONTEXT) {
207
148
  const columns = context.columns;
208
149
  if (result.kind !== "accepted")
209
- return renderFailure("update", result, columns);
210
- return renderAcceptedMutation("update", result.value.debt, columns, result.value.changedFields);
211
- }
212
- function renderBatchItem(verb, item, columns) {
213
- if (item.outcome.kind === "accepted")
214
- return `✓ ${PAST_VERBS[verb] ?? verb} ${item.id}`;
215
- if (item.outcome.kind === "retry")
216
- return `? ${verb} ${item.id} ${item.outcome.reason}`;
217
- const facts = projectRefusal(item.outcome.refusal);
218
- const rest = (facts.facts ?? []).filter((fact) => fact !== `debt ${item.id}`);
219
- return refusalLines(verb, [`debt ${item.id}`, `reason ${facts.diagnostic}`, ...rest], columns).join("\n");
150
+ return renderFailure("update", result, columns, id);
151
+ const lines = [];
152
+ receiptRow(lines, "✓", PAST_VERBS.update, id === undefined ? [] : [{ text: id, opaque: true }], columns);
153
+ for (const field of result.changes ?? [])
154
+ lines.push(` ${field} changed`);
155
+ if (result.warning !== undefined)
156
+ lines.push(...warningLines(result.warning, columns));
157
+ return lines.join("\n");
220
158
  }
221
- function renderBatch(verb, batch, columns) {
222
- return batch.items.map((item) => renderBatchItem(verb, item, columns)).join("\n");
159
+ function renderBatchItem(verb, id, item, columns) {
160
+ if (item.kind !== "accepted")
161
+ return renderFailure(verb, item, columns, id).split("\n");
162
+ return [
163
+ `✓ ${PAST_VERBS[verb] ?? verb} ${id}`,
164
+ ...(item.warning === undefined ? [] : warningLines(item.warning, columns)),
165
+ ];
223
166
  }
224
- export function renderDebtTree(result, context = DEFAULT_CONTEXT) {
225
- return result.kind === "accepted"
226
- ? treeLines(result.value, context.columns).join("\n")
227
- : renderFailure("tree", result, context.columns);
167
+ export function renderDebtTree(id, result, context = DEFAULT_CONTEXT) {
168
+ if (result.kind === "absent")
169
+ return "debt world absent";
170
+ if (result.kind === "missing")
171
+ return refusalLines("tree", ["reason debt missing", `debt ${id}`], context.columns).join("\n");
172
+ return treeLines(id, result, context.columns).join("\n");
228
173
  }
229
174
  export function renderDebtContext(result, context = DEFAULT_CONTEXT) {
230
- if (result.kind !== "accepted")
231
- return renderFailure("context", result, context.columns);
232
- const value = result.value.namespace.length === 0 ? "root" : result.value.namespace.join("/");
233
- return `context ${value} · ${result.value.source}`;
175
+ if (result.kind === "refused")
176
+ return refusalLines("context", ["reason invalid namespace context", `path ${result.path}`], context.columns).join("\n");
177
+ const value = "namespace" in result ? (result.namespace ?? "root") : "root";
178
+ return `context ${value} · ${result.source}`;
234
179
  }
235
- /** One single-Debt mutation answer; `verb` is the literal action the leaf invoked. */
180
+ /** Creation retains its minted identity in the native answer. */
236
181
  export function renderDebtMutation(verb, result, context = DEFAULT_CONTEXT) {
237
- return renderMutation(verb, result, context.columns);
238
- }
239
- /** One lifecycle answer: a single mutation or a plural batch, both native shapes. */
240
- export function renderDebtLifecycle(verb, result, context = DEFAULT_CONTEXT) {
241
- return "items" in result ? renderBatch(verb, result, context.columns) : renderMutation(verb, result, context.columns);
182
+ if (result.kind !== "accepted")
183
+ return renderFailure(verb, result, context.columns);
184
+ const lines = [];
185
+ receiptRow(lines, "✓", PAST_VERBS[verb] ?? verb, [{ text: result.id, opaque: true }], context.columns);
186
+ if (result.warning !== undefined)
187
+ lines.push(...warningLines(result.warning, context.columns));
188
+ return lines.join("\n");
242
189
  }
243
- export function debtOutcome(result) {
244
- if ("issues" in result)
245
- return result.issues.length === 0 ? "accepted" : "failed";
246
- if ("items" in result) {
247
- const kinds = result.items.map((item) => item.outcome.kind);
248
- return kinds.includes("retry") ? "retryable" : kinds.includes("refused") ? "refused" : "accepted";
249
- }
250
- if ("kind" in result) {
251
- if (result.kind === "retry")
252
- return "retryable";
253
- if (result.kind === "refused")
254
- return "refused";
255
- }
256
- return "accepted";
190
+ export function renderDebtLifecycle(verb, ids, result, context = DEFAULT_CONTEXT) {
191
+ return result.items.flatMap((item, index) => renderBatchItem(verb, ids[index], item, context.columns)).join("\n");
257
192
  }
@@ -1,7 +1,8 @@
1
1
  import type { DeliveryPreviewOutcome } from "../../index.js";
2
2
  import { type TextRenderContext } from "./terminal.js";
3
- type AcceptedDeliveryPreview = Extract<DeliveryPreviewOutcome, {
4
- kind: "accepted";
3
+ type Preview = Extract<DeliveryPreviewOutcome, {
4
+ kind: "ready" | "blocked";
5
5
  }>;
6
- export declare function renderDeliveryPreview(result: AcceptedDeliveryPreview, context?: TextRenderContext): string;
6
+ /** A preview is an observation, not a successful mutation or a prediction of placement. */
7
+ export declare function renderDeliveryPreview(report: Preview, context?: TextRenderContext): string;
7
8
  export {};
@@ -1,129 +1,101 @@
1
- import { effectCleanup, effectExecutionStops } from "./effects.js";
2
- import { executionCleanupLines, executionStopLines, standingGateLines, receiptPayload, receiptRow, titleLines, } from "./receipt.js";
1
+ import { unmetRequirementLines, receiptPayload, receiptRow, titleLines } from "./receipt.js";
3
2
  import { renderRefusalFacts } from "./refusal.js";
4
3
  import { abbreviateGitIds, displayGitId } from "./contract-observation.js";
5
- import { DEFAULT_CLI_COLUMNS, gitShortStat, renderTextBlock, safeText } from "./terminal.js";
6
- const CHILD = " ";
7
- function workspaceEvidence(workspace) {
8
- return [`${CHILD}worktree ${safeText(workspace.path)}`];
9
- }
10
- function candidateLines(report, columns, addressed, abbreviations) {
11
- const candidate = report.candidate;
12
- const lines = [];
13
- if (candidate.kind === "blocked") {
14
- receiptRow(lines, "!", "candidate", [{ text: "blocked" }], columns);
15
- lines.push(...renderRefusalFacts(candidate.refusal, CHILD, columns, addressed));
16
- return lines;
17
- }
18
- const identity = candidate.identity;
19
- receiptRow(lines, " ", "candidate", [{ text: "prepared" }, { text: displayGitId(identity.tenderSnapshot, abbreviations), opaque: true }], columns);
20
- lines.push(`${CHILD}integration result ${displayGitId(identity.integration.snapshot, abbreviations)}`);
21
- if (!/^0{40}$/u.test(identity.integration.changeId))
22
- lines.push(`${CHILD}content identity ${displayGitId(identity.integration.changeId, abbreviations)}`);
23
- lines.push(...workspaceEvidence(candidate.workspace));
24
- lines.push(...standingGateLines(candidate.requirements.gates.filter((report) => report.gate !== "verified"), columns));
25
- for (const prerequisite of candidate.requirements.unmetPrerequisites) {
26
- receiptRow(lines, "!", "prerequisite", [{ text: prerequisite.contractId }, { text: prerequisite.state }], columns);
27
- }
28
- lines.push(...renderTextBlock(gitShortStat(candidate.scope), CHILD, columns));
29
- if (candidate.scope.paths !== undefined) {
30
- for (const path of candidate.scope.paths) {
31
- lines.push(`${CHILD}${safeText(path)}`);
32
- }
33
- }
34
- if (candidate.diff !== undefined)
35
- receiptPayload(lines, "diff", candidate.diff);
36
- return lines;
37
- }
38
- function verificationLines(verification, columns) {
39
- if (verification.kind === "requirements")
40
- return standingGateLines([{ gate: "verified", requirements: verification.requirements }], columns);
41
- const lines = [];
42
- receiptRow(lines, " ", "verification", [{ text: verification.kind === "undeclared" ? "none declared" : "not run" }], columns);
43
- return lines;
44
- }
45
- function admittedCandidateLines(report, columns) {
46
- if (report.delivery === undefined)
47
- return [];
48
- const lines = [];
49
- receiptRow(lines, " ", "admitted candidate", [
50
- { text: report.delivery.relation },
51
- {
52
- text: `· content identity ${displayGitId(report.delivery.changeId, abbreviateGitIds([report.delivery.changeId]))}`,
53
- },
54
- ], columns);
55
- return lines;
56
- }
57
- function targetLines(report, columns, addressed, abbreviations) {
4
+ import { DEFAULT_CLI_COLUMNS, gitShortStat, safeText } from "./terminal.js";
5
+ import { contractIssueLines } from "./contract.js";
6
+ function targetLines(report, columns, ids) {
58
7
  const target = report.target;
59
8
  const lines = [];
60
- if (target.kind === "not-observed") {
61
- receiptRow(lines, " ", "target", [{ text: "none" }], columns);
9
+ if (target === undefined)
62
10
  return lines;
63
- }
64
11
  if (target.kind === "placeable") {
12
+ const lag = target.behind === undefined ? "" : ` · behind ${target.behind === "unknown" ? "unknown" : String(target.behind)}`;
65
13
  receiptRow(lines, " ", "target", [
66
14
  { text: "placeable" },
67
15
  {
68
- text: `${target.ref.replace(/^refs\/heads\//u, "")} @ ${displayGitId(target.head, abbreviations)}${report.targetLag?.kind === "counted" && report.targetLag.behind > 0 ? ` · behind ${report.targetLag.behind}` : report.targetLag?.kind === "unknown" ? " · behind unknown" : ""}`,
16
+ text: `${target.ref.replace(/^refs\/heads\//u, "")} @ ${displayGitId(target.head, ids)}${lag}`,
69
17
  opaque: true,
70
18
  },
71
19
  ], columns);
72
- for (const checkout of target.checkouts) {
73
- if (checkout.kind === "followable")
74
- continue;
20
+ for (const checkout of target.checkouts ?? []) {
75
21
  receiptRow(lines, "!", "checkout cannot follow", [{ text: checkout.path, opaque: true }], columns);
76
22
  receiptPayload(lines, "reason", checkout.diagnostic);
77
23
  }
78
- return lines;
79
24
  }
80
- if (target.kind === "moved") {
25
+ else if (target.kind === "moved") {
81
26
  receiptRow(lines, "!", "target", [
82
27
  { text: "moved" },
83
28
  { text: target.ref, opaque: true },
84
29
  {
85
- text: `${displayGitId(target.expected, abbreviations)} -> ${target.observed === null ? "absent" : displayGitId(target.observed, abbreviations)}`,
30
+ text: `${displayGitId(target.expected, ids)} -> ${target.observed === null ? "absent" : displayGitId(target.observed, ids)}`,
86
31
  opaque: true,
87
32
  },
88
33
  ], columns);
89
- return lines;
90
34
  }
91
- if (target.kind === "failed") {
35
+ else if (target.kind === "failed") {
92
36
  receiptRow(lines, "!", "target", [{ text: "failed" }], columns);
93
37
  receiptPayload(lines, "reason", target.diagnostic);
94
- return lines;
95
38
  }
96
- receiptRow(lines, "!", "target", [{ text: "refused" }], columns);
97
- lines.push(...renderRefusalFacts(target.refusal, CHILD, columns, addressed));
39
+ else {
40
+ receiptRow(lines, "!", "target", [{ text: "refused" }], columns);
41
+ lines.push(...renderRefusalFacts(target.reason, " ", columns, report.contractId));
42
+ }
43
+ return lines;
44
+ }
45
+ function previewGitIds(report) {
46
+ const ids = [report.candidate, report.integration, report.contentId];
47
+ if (report.previousContentId !== undefined)
48
+ ids.push(report.previousContentId);
49
+ if (report.target?.kind === "placeable")
50
+ ids.push(report.target.head);
51
+ if (report.target?.kind === "moved")
52
+ ids.push(report.target.expected, report.target.observed ?? "");
53
+ return abbreviateGitIds(ids);
54
+ }
55
+ function unmetLines(report, columns) {
56
+ const lines = [];
57
+ lines.push(...unmetRequirementLines(report.unmetGates ?? [], columns));
58
+ for (const prerequisite of report.unmetPrerequisites ?? [])
59
+ receiptRow(lines, "!", "prerequisite", [{ text: prerequisite.contractId, opaque: true }, { text: prerequisite.state }], columns);
98
60
  return lines;
99
61
  }
100
- function obligationLines(result, columns) {
101
- return [
102
- ...executionCleanupLines(effectCleanup(result.effects), columns, result.contract),
103
- ...executionStopLines(effectExecutionStops(result.effects), columns),
62
+ function scopeLines(report) {
63
+ const lines = [
64
+ ` ${safeText(gitShortStat({
65
+ filesChanged: report.scope.filesChanged ?? 0,
66
+ insertions: report.scope.insertions ?? 0,
67
+ deletions: report.scope.deletions ?? 0,
68
+ }))}`,
104
69
  ];
70
+ for (const path of report.scope.paths ?? [])
71
+ lines.push(` ${safeText(path)}`);
72
+ return lines;
105
73
  }
106
- export function renderDeliveryPreview(result, context) {
107
- const report = result.value;
74
+ /** A preview is an observation, not a successful mutation or a prediction of placement. */
75
+ export function renderDeliveryPreview(report, context) {
108
76
  const columns = context?.columns ?? DEFAULT_CLI_COLUMNS;
109
- const ids = report.candidate.kind === "ready"
110
- ? [
111
- report.candidate.identity.tenderSnapshot,
112
- report.candidate.identity.integration.snapshot,
113
- report.candidate.identity.integration.changeId,
114
- ]
115
- : [];
116
- if (report.target.kind === "placeable")
117
- ids.push(report.target.head);
118
- if (report.target.kind === "moved")
119
- ids.push(report.target.expected, report.target.observed ?? "");
120
- const abbreviations = abbreviateGitIds(ids);
121
- return [
122
- ...titleLines("✓", "deliver --dry-run", result.contract, columns),
123
- ...candidateLines(report, columns, result.contract, abbreviations),
124
- ...admittedCandidateLines(report, columns),
125
- ...verificationLines(report.verification, columns),
126
- ...targetLines(report, columns, result.contract, abbreviations),
127
- ...obligationLines(result, columns),
128
- ].join("\n");
77
+ const lines = titleLines(report.kind === "ready" ? "✓" : "!", "deliver --dry-run", report.contractId, columns);
78
+ if (report.kind === "blocked") {
79
+ receiptRow(lines, "!", "candidate", [{ text: "blocked" }], columns);
80
+ lines.push(...renderRefusalFacts(report.reason, " ", columns, report.contractId), ...contractIssueLines(report, columns));
81
+ return lines.join("\n");
82
+ }
83
+ const ids = previewGitIds(report);
84
+ receiptRow(lines, " ", "candidate", [{ text: "prepared" }, { text: displayGitId(report.candidate, ids), opaque: true }], columns);
85
+ receiptRow(lines, " ", "integration result", [{ text: displayGitId(report.integration, ids), opaque: true }], columns);
86
+ if (!/^0{40}$/u.test(report.contentId))
87
+ receiptRow(lines, " ", "content identity", [{ text: displayGitId(report.contentId, ids), opaque: true }], columns);
88
+ lines.push(...unmetLines(report, columns), ...scopeLines(report));
89
+ if (report.diff?.kind === "present") {
90
+ if (report.diff.text.length === 0)
91
+ receiptRow(lines, " ", "diff", [{ text: "empty" }], columns);
92
+ else
93
+ receiptPayload(lines, "diff", report.diff.text);
94
+ }
95
+ else if (report.diff?.kind === "unavailable")
96
+ receiptRow(lines, "!", "diff", [{ text: "unavailable" }], columns);
97
+ if (report.previousContentId !== undefined)
98
+ receiptRow(lines, " ", "admitted candidate", [{ text: `previous content ${displayGitId(report.previousContentId, ids)}` }], columns);
99
+ lines.push(...targetLines(report, columns, ids), ...contractIssueLines(report, columns));
100
+ return lines.join("\n");
129
101
  }