@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,38 +1,14 @@
1
- import { Akumas, Keiyaku, KeiyakuError, kanshiCategory, listArchetypeDefinitions, nuke } from "../../index.js";
2
- import { kanshi, selectRegion } from "../../kanshi/index.js";
3
- import { observeNamedAddress, resolveNamedAddress } from "../../library/address.js";
4
- import { observeKeiyaku } from "../../library/contract-composition.js";
5
- import { validateArcMarkdown, validateContractMarkdown } from "../../library/input.js";
6
- import { SettingsError, settings } from "../../settings.js";
7
- import { akumaCallerFromEnvironment } from "../akuma-caller.js";
8
- import { Debts } from "../../debt/index.js";
9
- import { actorFromEdge } from "../actor.js";
1
+ import { KeiyakuError, KeiyakuUsageError } from "../../index.js";
2
+ import { KeiyakuArcDocumentError } from "../../library/keiyaku.js";
3
+ import { classifyVerb } from "../../library/keiyaku-verbs.js";
4
+ import { renderVerb } from "../render/verbs.js";
5
+ import { validateContractMarkdown } from "../../library/input.js";
6
+ import { SettingsError } from "../../settings.js";
10
7
  import { resolveInvocationCwd } from "../coordinates.js";
11
8
  import { BindDraftError, preserveBindDraft } from "../draft.js";
12
- import { snapshotText } from "../render/akuma-activity.js";
13
- import { renderAkumaCatalogue, renderArchetypeCatalogue, renderContractCatalogue, renderDebtCatalogue, } from "../render/catalog.js";
14
- import { renderAccepted, renderContractHistory, renderRetry } from "../render/contract.js";
15
- import { renderKanshiCategoryText, renderKanshiText } from "../render/kanshi.js";
16
- import { nukeOutcome, renderNukeText } from "../render/nuke.js";
17
- import { reconcileHasFailure, renderReconcile } from "../render/reconcile.js";
18
- import { renderConflictMaterialized, renderRefusal } from "../render/refusal.js";
19
- import { renderRegionText } from "../render/region.js";
20
- import { renderSettingsText, settingsJsonValue } from "../render/settings.js";
21
- import { canonicalContractSelector, contractFromInput, resolveContractId } from "../selectors.js";
22
- import { displayContext, emit, writeJson, writeStderr, writeStdout } from "../streams.js";
23
- import { CliUsageError, commandGuide, isBlankInput } from "../usage.js";
24
- import { CONTRACT_COMMAND_SPECS } from "./contract-help.js";
25
- function requiredRepo(coordinates) {
26
- if (coordinates.repo === undefined)
27
- throw new CliUsageError("this command requires a resolved Repo");
28
- return coordinates.repo;
29
- }
30
- async function settingsAt(root, home) {
31
- return settings({
32
- ...(root === undefined ? {} : { root }),
33
- ...(home === undefined ? {} : { home }),
34
- });
35
- }
9
+ import { renderBindDraftReceipt } from "../render/refusal.js";
10
+ import { displayContext, emit } from "../streams.js";
11
+ import { CliUsageError, isBlankInput } from "../usage.js";
36
12
  function draftWarning(error) {
37
13
  return { warning: `bind draft could not be preserved: ${error instanceof Error ? error.message : String(error)}` };
38
14
  }
@@ -64,498 +40,291 @@ async function bindDraftReceipt(world, markdown) {
64
40
  return draftWarning(error);
65
41
  }
66
42
  }
67
- function refusedInvocation(answer, project) {
68
- const refusal = project === undefined ? answer.refusal : project(answer.refusal);
69
- return {
70
- operation: answer.operation,
71
- ...(answer.contract === undefined ? {} : { contract: answer.contract }),
72
- refusal,
73
- };
74
- }
75
- /** The CLI's own presentation of a refused dirty delivery: the available opt-in is not SDK evidence. */
76
- function deliverRefusalProjection(refusal) {
77
- if (refusal.kind !== "dirty-workspace")
78
- return refusal;
79
- const submodules = "submodules" in refusal && Array.isArray(refusal.submodules) ? refusal.submodules : [];
80
- return { ...refusal, option: { flag: "--include-dirty", available: submodules.length === 0 } };
81
- }
82
- function renderContractAnswer(answer, project, context) {
83
- switch (answer.kind) {
84
- case "handoff":
85
- return renderConflictMaterialized(answer.value, context);
86
- case "refused":
87
- return renderRefusal(refusedInvocation(answer, project), undefined, context);
88
- case "retry":
89
- return renderRetry(answer, context);
90
- case "accepted":
91
- return renderAccepted(answer, context);
92
- }
43
+ function finishVerb(name, input, value, output, json = value) {
44
+ const completion = { kind: "returned", value };
45
+ return emit(output, json, () => renderVerb(name, input, completion, displayContext()), classifyVerb(name, input, completion));
93
46
  }
94
- async function finishContractAnswer(answer, output, project) {
95
- const outcome = answer.kind === "refused" ? "refused" : answer.kind === "retry" ? "retryable" : "accepted";
96
- return emit(output, answer, () => renderContractAnswer(answer, project, displayContext()), outcome);
97
- }
98
- async function selectedContract(repo, selector, scope) {
99
- const id = await resolveContractId(repo, selector, scope);
100
- return { id, contract: contractFromInput(repo, id).contract };
101
- }
102
- async function existingSeat(command, coordinates, runtime, library) {
103
- const repo = requiredRepo(coordinates);
104
- const id = await resolveContractId(repo, command.contract, coordinates.cwd);
105
- const actor = "actor" in command ? actorFromEdge(command.actor, runtime.environment) : undefined;
106
- return {
107
- id,
108
- contract: library.select({ repo, id }),
109
- ...(actor === undefined ? {} : { actor }),
110
- };
111
- }
112
- async function runBind(command, input, library) {
113
- const { coordinates, runtime } = input;
114
- const repo = requiredRepo(coordinates);
115
- const actor = actorFromEdge(command.actor, runtime.environment);
47
+ async function runBind(command, runtime) {
116
48
  if (command.forkOf !== undefined) {
117
- const answer = await library.bind({
118
- repo,
119
- forkOf: contractFromInput(repo, command.forkOf).id,
49
+ const input = {
50
+ forkOf: command.forkOf,
120
51
  ...(command.target === undefined ? {} : { target: command.target }),
121
- ...(actor === undefined ? {} : { actor }),
122
- });
123
- return await finishContractAnswer(answer, command.output);
52
+ ...(command.actor === undefined ? {} : { actor: command.actor }),
53
+ };
54
+ const answer = await runtime.facet.run("bind", input);
55
+ return finishVerb("bind", input, answer, command.output);
124
56
  }
125
57
  const markdown = await runtime.readStdin();
126
58
  try {
127
- const after = command.after?.map((id) => contractFromInput(repo, id).id);
128
- const answer = await library.bind({
129
- repo,
59
+ const input = {
130
60
  markdown,
131
61
  ...(command.debt === undefined ? {} : { debt: command.debt }),
132
62
  ...(command.target === undefined ? {} : { target: command.target }),
133
- ...(actor === undefined ? {} : { actor }),
134
- ...(after === undefined ? {} : { after }),
63
+ ...(command.actor === undefined ? {} : { actor: command.actor }),
64
+ ...(command.after === undefined ? {} : { after: command.after }),
135
65
  ...(command.gates === undefined ? {} : { gates: command.gates }),
136
- });
66
+ };
67
+ const answer = await runtime.facet.run("bind", input);
137
68
  if (answer.kind !== "refused")
138
- return await finishContractAnswer(answer, command.output);
139
- const draft = await bindDraftReceipt(coordinates.establishWorld, markdown);
140
- const text = () => renderRefusal(refusedInvocation(answer), draft, displayContext());
141
- return emit(command.output, answer, text, "refused");
69
+ return finishVerb("bind", input, answer, command.output);
70
+ const draft = await bindDraftReceipt(runtime.draftWorld, markdown);
71
+ const text = () => `${renderVerb("bind", input, { kind: "returned", value: answer }, displayContext())}\n${renderBindDraftReceipt(draft)}`;
72
+ return emit(command.output, answer, text, classifyVerb("bind", input, { kind: "returned", value: answer }));
142
73
  }
143
74
  catch (error) {
144
75
  if (error instanceof Error && "executionReceipt" in error)
145
76
  throw error;
77
+ if (error instanceof KeiyakuUsageError)
78
+ throw error;
146
79
  // A selected Settings namespace failure is the Contract owner's invalid input, not a bad draft.
147
80
  if (error instanceof KeiyakuError && error.category === "invalid-input" && error.cause instanceof SettingsError)
148
81
  throw error;
149
82
  if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
150
83
  throw error;
151
- throw new BindDraftError(error, await bindDraftReceipt(coordinates.establishWorld, markdown));
84
+ throw new BindDraftError(error, await bindDraftReceipt(runtime.draftWorld, markdown));
152
85
  }
153
86
  }
154
- async function runAmend(command, input, seat) {
155
- const { coordinates, runtime } = input;
87
+ async function runAmend(command, runtime) {
156
88
  const markdown = command.stdin === true ? await runtime.readStdin() : undefined;
157
89
  if (markdown !== undefined && isBlankInput(markdown))
158
90
  throw new CliUsageError("amend requires a nonblank stdin document");
159
- const repo = requiredRepo(coordinates);
160
- const after = command.clearAfter === true ? [] : command.after?.map((id) => contractFromInput(repo, id).id);
161
- const answer = await seat.contract.amend({
91
+ const after = command.clearAfter === true ? [] : command.after;
92
+ const input = {
93
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
162
94
  ...(markdown === undefined ? {} : { markdown }),
163
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
95
+ ...(command.actor === undefined ? {} : { actor: command.actor }),
164
96
  ...(after === undefined ? {} : { after }),
165
97
  ...(command.gates === undefined ? {} : { gates: command.gates }),
166
- });
167
- return await finishContractAnswer(answer, command.output);
98
+ };
99
+ const answer = await runtime.facet.run("amend", input);
100
+ return finishVerb("amend", input, answer, command.output);
168
101
  }
169
- async function runDeliver(command, runtime, seat) {
102
+ async function runDeliver(command, runtime) {
170
103
  const driver = command.output === "text" ? await runtime.progress() : undefined;
171
- let answer;
172
- try {
173
- const progress = { ...(driver === undefined ? {} : { observe: driver.observe }) };
174
- const signal = { ...(runtime.signal === undefined ? {} : { signal: runtime.signal }) };
175
- answer = command.dryRun
176
- ? await seat.contract.previewDelivery({ includeDirty: command.includeDirty, showDiff: command.showDiff, ...signal }, progress)
177
- : await seat.contract.deliver({
178
- ...(command.message === undefined ? {} : { message: command.message }),
179
- includeDirty: command.includeDirty,
180
- materializeConflict: command.materializeConflict,
181
- overwrite: command.overwrite,
182
- ...signal,
183
- }, progress);
184
- }
185
- finally {
186
- if (driver !== undefined)
187
- await driver.finish().catch(() => undefined);
188
- }
189
- return await finishContractAnswer(answer, command.output, deliverRefusalProjection);
104
+ const run = { signal: runtime.signal, ...(driver === undefined ? {} : { observe: driver.observe }) };
105
+ const withProgress = async (operation) => {
106
+ try {
107
+ return await operation();
108
+ }
109
+ finally {
110
+ if (driver !== undefined)
111
+ await driver.finish().catch(() => undefined);
112
+ }
113
+ };
114
+ if (command.dryRun) {
115
+ const input = {
116
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
117
+ includeDirty: command.includeDirty,
118
+ showDiff: command.showDiff,
119
+ };
120
+ const answer = await withProgress(() => runtime.facet.run("deliver.preview", input, run));
121
+ return finishVerb("deliver.preview", input, answer, command.output);
122
+ }
123
+ const input = {
124
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
125
+ ...(command.message === undefined ? {} : { message: command.message }),
126
+ includeDirty: command.includeDirty,
127
+ materializeConflict: command.materializeConflict,
128
+ overwrite: command.overwrite,
129
+ };
130
+ const answer = await withProgress(() => runtime.facet.run("deliver", input, run));
131
+ return finishVerb("deliver", input, answer, command.output);
190
132
  }
191
- async function runVerify(command, runtime, seat) {
133
+ async function runVerify(command, runtime) {
192
134
  const driver = command.output === "text" ? await runtime.progress() : undefined;
135
+ const input = {
136
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
137
+ ...(command.index === undefined ? {} : { index: command.index }),
138
+ includeDirty: command.includeDirty,
139
+ };
193
140
  let answer;
194
141
  try {
195
- answer = await seat.contract.verify({
196
- ...(command.index === undefined ? {} : { index: command.index }),
197
- includeDirty: command.includeDirty,
198
- ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
199
- }, { ...(driver === undefined ? {} : { observe: driver.observe }) });
142
+ answer = await runtime.facet.run("verify", input, {
143
+ signal: runtime.signal,
144
+ ...(driver === undefined ? {} : { observe: driver.observe }),
145
+ });
200
146
  }
201
147
  finally {
202
148
  if (driver !== undefined)
203
149
  await driver.finish().catch(() => undefined);
204
150
  }
205
- return await finishContractAnswer(answer, command.output, deliverRefusalProjection);
151
+ return finishVerb("verify", input, answer, command.output);
206
152
  }
207
- async function runReview(command, runtime, seat) {
153
+ async function runReview(command, runtime) {
208
154
  const summary = command.summaryFromStdin === true ? await runtime.readStdin() : command.summary;
209
- if (command.summaryFromStdin === true && isBlankInput(summary ?? ""))
155
+ if (summary === undefined || isBlankInput(summary))
210
156
  throw new CliUsageError("review requires a nonblank summary");
211
157
  const driver = command.output === "text" ? await runtime.progress() : undefined;
158
+ const input = {
159
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
160
+ verdict: command.verdict,
161
+ summary,
162
+ ...(command.actor === undefined ? {} : { actor: command.actor }),
163
+ };
212
164
  let answer;
213
165
  try {
214
- answer = await seat.contract.review({
215
- verdict: command.verdict,
216
- ...(summary === undefined ? {} : { summary }),
217
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
218
- ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
219
- }, { ...(driver === undefined ? {} : { observe: driver.observe }) });
166
+ answer = await runtime.facet.run("review", input, {
167
+ signal: runtime.signal,
168
+ ...(driver === undefined ? {} : { observe: driver.observe }),
169
+ });
220
170
  }
221
171
  finally {
222
172
  if (driver !== undefined)
223
173
  await driver.finish().catch(() => undefined);
224
174
  }
225
- return await finishContractAnswer(answer, command.output);
175
+ return finishVerb("review", input, answer, command.output);
226
176
  }
227
- async function runArc(command, runtime, seat) {
177
+ async function runArc(command, runtime) {
228
178
  const markdown = await runtime.readStdin();
179
+ const input = {
180
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
181
+ markdown,
182
+ ...(command.actor === undefined ? {} : { actor: command.actor }),
183
+ };
229
184
  try {
230
- validateArcMarkdown(markdown);
185
+ const answer = await runtime.facet.run("arc", input);
186
+ return finishVerb("arc", input, answer, command.output);
231
187
  }
232
188
  catch (error) {
233
- if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
189
+ if (!(error instanceof KeiyakuArcDocumentError))
234
190
  throw error;
191
+ const completion = { kind: "threw", error };
235
192
  const refusal = { kind: "invalid-document", diagnostic: error.message };
236
- const refused = { kind: "refused", operation: "arc", contract: seat.id, refusal };
237
- return emit(command.output, refused, () => renderRefusal(refused, undefined, displayContext()), "refused");
193
+ const refused = { kind: "refused", contractId: error.contract, reason: refusal };
194
+ return emit(command.output, refused, () => renderVerb("arc", input, completion, displayContext()), classifyVerb("arc", input, completion));
238
195
  }
239
- const answer = await seat.contract.arc({
240
- markdown,
241
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
242
- });
243
- return await finishContractAnswer(answer, command.output);
244
196
  }
245
- async function runAbandon(command, seat) {
246
- const answer = await seat.contract.abandon({
247
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
197
+ async function runAbandon(command, runtime) {
198
+ const input = {
199
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
200
+ ...(command.actor === undefined ? {} : { actor: command.actor }),
248
201
  ...(command.note === undefined ? {} : { note: command.note }),
249
- });
250
- return await finishContractAnswer(answer, command.output);
202
+ };
203
+ const answer = await runtime.facet.run("abandon", input);
204
+ return finishVerb("abandon", input, answer, command.output);
251
205
  }
252
- async function runContractMutation(command, input) {
253
- const { configuration, runtime } = input;
254
- const actor = ["deliver", "verify", "review"].includes(command.command)
255
- ? actorFromEdge(undefined, runtime.environment)
256
- : undefined;
257
- const library = Keiyaku.with({
258
- ...(configuration === undefined ? {} : { settings: configuration }),
259
- ...(actor === undefined ? {} : { actor }),
260
- });
261
- if (command.command === "bind")
262
- return await runBind(command, input, library);
263
- const seat = await existingSeat(command, input.coordinates, input.runtime, library);
206
+ export async function runContractMutation(command, runtime) {
264
207
  switch (command.command) {
265
- case "amend":
266
- return await runAmend(command, input, seat);
267
208
  case "deliver":
268
- return await runDeliver(command, input.runtime, seat);
209
+ return await runDeliver(command, runtime);
269
210
  case "verify":
270
- return await runVerify(command, input.runtime, seat);
211
+ return await runVerify(command, runtime);
271
212
  case "review":
272
- return await runReview(command, input.runtime, seat);
273
- case "arc":
274
- return await runArc(command, input.runtime, seat);
213
+ return await runReview(command, runtime);
275
214
  case "abandon":
276
- return await runAbandon(command, seat);
215
+ return await runAbandon(command, runtime);
216
+ case "bind":
217
+ return await runBind(command, runtime);
218
+ case "amend":
219
+ return await runAmend(command, runtime);
220
+ case "arc":
221
+ return await runArc(command, runtime);
277
222
  }
278
223
  }
279
224
  function statusRefusal(operation, contract) {
280
- return { operation, contract, refusal: { kind: "contract-missing", contractId: contract } };
225
+ return { operation, contract, refusal: { kind: "contract-missing" } };
281
226
  }
282
- async function runSettings(coordinates, home, output) {
283
- const value = await settingsAt(coordinates.world ?? undefined, home);
284
- return emit(output, settingsJsonValue(value), () => renderSettingsText(value, displayContext().columns), "accepted");
227
+ async function runSettings(runtime, output) {
228
+ const input = {};
229
+ const value = await runtime.facet.run("settings", input);
230
+ return finishVerb("settings", input, value, output);
285
231
  }
286
- async function runNuke(command, coordinates) {
287
- if (coordinates.world === null)
288
- throw new CliUsageError("no Keiyaku world contains the invocation cwd");
289
- const result = await nuke({
290
- world: coordinates.world,
291
- ...(command.confirm === undefined ? {} : { confirm: command.confirm }),
292
- });
293
- return emit(command.output, result, () => renderNukeText(result), nukeOutcome(result));
232
+ async function runNuke(command, runtime) {
233
+ const input = { ...(command.confirm === undefined ? {} : { confirm: command.confirm }) };
234
+ const result = await runtime.facet.run("nuke", input);
235
+ return finishVerb("nuke", input, result, command.output);
294
236
  }
295
- async function runLs(command, coordinates, home, runtime) {
237
+ async function runLs(command, runtime) {
296
238
  const query = command.query;
297
239
  if (query.kind === "contracts") {
298
- const list = await Keiyaku.with().list({
299
- repo: requiredRepo(coordinates),
300
- ...(query.limit === undefined ? {} : { limit: query.limit }),
301
- });
302
- return emit(command.output, list, () => renderContractCatalogue(list), "accepted");
240
+ const input = { of: "kei", ...(query.limit === undefined ? {} : { limit: query.limit }) };
241
+ const list = await runtime.facet.run("ls", input);
242
+ return finishVerb("ls", input, list, command.output);
303
243
  }
304
244
  if (query.kind === "archetypes") {
305
- const list = await listArchetypeDefinitions({
306
- ...(coordinates.world === null ? {} : { project: coordinates.world }),
307
- ...(query.limit === undefined ? {} : { limit: query.limit }),
308
- ...(home === undefined ? {} : { home }),
309
- });
310
- return emit(command.output, list, () => renderArchetypeCatalogue(list), "accepted");
245
+ const input = { of: "akuma-name", ...(query.limit === undefined ? {} : { limit: query.limit }) };
246
+ const list = await runtime.facet.run("ls", input);
247
+ return finishVerb("ls", input, list, command.output);
311
248
  }
312
- if (coordinates.world === null)
313
- throw new CliUsageError("no Keiyaku world contains the invocation cwd");
314
249
  if (query.kind === "debts") {
315
- const listed = await Debts.of(coordinates.world).list({
316
- selection: "all",
250
+ const input = {
251
+ of: "debt",
317
252
  namespace: query.namespace ?? [],
253
+ ...(query.selection === undefined ? {} : { selection: query.selection }),
318
254
  ...(query.limit === undefined ? {} : { limit: query.limit }),
319
- });
320
- if (listed.kind !== "accepted")
321
- throw new Error("Debt list did not return an accepted observation");
322
- return emit(command.output, listed, () => renderDebtCatalogue(listed.value, query.namespace ?? []), "accepted");
255
+ };
256
+ const listed = await runtime.facet.run("ls", input);
257
+ return finishVerb("ls", input, listed, command.output);
323
258
  }
324
- const caller = await lsCaller(query.caller, coordinates, runtime);
325
- const listed = await Akumas.of(coordinates.world).list({
326
- ...(query.archetype === undefined ? {} : { archetype: query.archetype }),
259
+ const input = {
260
+ of: "aku",
261
+ ...(query.akumaName === undefined ? {} : { akumaName: query.akumaName }),
327
262
  ...(query.limit === undefined ? {} : { limit: query.limit }),
328
- ...(caller === undefined ? {} : { caller }),
329
- });
330
- return emit(command.output, listed, () => renderAkumaCatalogue(listed, query.archetype ?? null, caller), "accepted");
331
- }
332
- /** `--mine` is the process caller identity; `--caller` names the same coordinate explicitly. */
333
- async function lsCaller(selection, coordinates, runtime) {
334
- const usage = (diagnostic) => new CliUsageError(diagnostic, commandGuide("ls", CONTRACT_COMMAND_SPECS.ls.usage));
335
- if (selection === undefined)
336
- return undefined;
337
- if (selection.kind === "external")
338
- return selection.caller;
339
- if (selection.kind === "akuma") {
340
- if (coordinates.world === null)
341
- throw usage("no Keiyaku world contains the invocation cwd");
342
- return { kind: "akuma", world: coordinates.world, akuId: selection.akuId };
343
- }
344
- let caller;
345
- try {
346
- caller = await akumaCallerFromEnvironment(runtime.environment);
347
- }
348
- catch (error) {
349
- throw usage(error instanceof Error ? error.message : String(error));
350
- }
351
- if (caller === undefined)
352
- throw usage("--mine requires a caller identity; set KEIYAKU_ACTOR_ID and KEIYAKU_ACTOR_WORLD or run inside a calling host");
353
- return caller;
354
- }
355
- async function readAkumaStatus(akuma, alias, coordinates) {
356
- if (coordinates.world === null)
357
- throw new CliUsageError("no Keiyaku world contains the Akuma selector");
358
- const status = await Akumas.of(coordinates.world, { reportDiagnostic: writeStderr }).status({
359
- akuma,
360
- ...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
361
- });
362
- return {
363
- value: status,
364
- project: () => snapshotText(status, displayContext(), ...(alias === undefined ? [{}] : [{ alias }])),
263
+ ...(query.caller === undefined ? {} : { caller: query.caller }),
365
264
  };
265
+ const listed = await runtime.facet.run("ls", input);
266
+ return finishVerb("ls", input, listed, command.output);
267
+ }
268
+ async function runShow(command, runtime) {
269
+ const input = command.contract === undefined ? {} : { contract: command.contract };
270
+ const guidance = await runtime.facet.run("show", input);
271
+ return finishVerb("show", input, guidance, command.output);
272
+ }
273
+ async function runStatus(command, runtime) {
274
+ const input = command.category !== undefined
275
+ ? { category: command.category, ...(command.limit === undefined ? {} : { limit: command.limit }) }
276
+ : "selectors" in command && command.selectors !== undefined
277
+ ? { selectors: command.selectors }
278
+ : command.contract === undefined
279
+ ? {}
280
+ : { selector: command.contract };
281
+ const value = await runtime.facet.run("status", input);
282
+ const completion = { kind: "returned", value };
283
+ const outcome = classifyVerb("status", input, completion);
284
+ const json = outcome === "refused" && "selector" in input && input.selector !== undefined
285
+ ? statusRefusal("status", input.selector).refusal
286
+ : value;
287
+ return emit(command.output, json, () => renderVerb("status", input, completion, displayContext()), outcome);
288
+ }
289
+ async function runRegion(command, runtime) {
290
+ const input = command.paths !== undefined
291
+ ? { paths: command.paths }
292
+ : command.contract !== undefined
293
+ ? { contract: command.contract }
294
+ : {};
295
+ const result = await runtime.facet.run("region", input);
296
+ return finishVerb("region", input, result, command.output);
297
+ }
298
+ export async function runContractHistoryCommand(command, runtime) {
299
+ const input = { selector: command.contract, full: command.full };
300
+ const history = await runtime.facet.run("history", input);
301
+ return finishVerb("history", input, history, command.output);
302
+ }
303
+ async function runReconcile(command, runtime) {
304
+ const input = {
305
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
306
+ retryHooks: command.retryHooks,
307
+ };
308
+ const report = await runtime.facet.run("reconcile", input);
309
+ return finishVerb("reconcile", input, report, command.output);
366
310
  }
367
- async function readContractStatus(selector, coordinates) {
368
- const repo = requiredRepo(coordinates);
369
- const contract = selector === undefined ? undefined : canonicalContractSelector(selector);
370
- const report = await kanshi({ world: coordinates.world, repo, ...(contract === undefined ? {} : { contract }) });
371
- return { value: report, project: () => renderKanshiText(report, displayContext(), "contract") };
372
- }
373
- /** Identity comes from the complete candidate observation; display detail is requested only after it. */
374
- async function namedStatus(selector, coordinates, authority) {
375
- const address = resolveNamedAddress({ selector, contracts: authority.contracts, aliases: authority.aliases });
376
- if (address.kind === "akuma")
377
- return await readAkumaStatus(address.id, selector, coordinates);
378
- return await readContractStatus(address.id, coordinates);
379
- }
380
- async function runShow(command, coordinates) {
381
- const repo = coordinates.repo;
382
- if (repo === undefined)
383
- throw new CliUsageError("cannot select a contract while the Contract world is absent");
384
- const selected = await selectedContract(repo, command.contract, coordinates.cwd);
385
- const guidance = await selected.contract.guidance();
386
- if (guidance === null) {
387
- const refusal = statusRefusal(command.command, selected.id);
388
- return emit(command.output, null, () => renderRefusal(refusal, undefined, displayContext()), "refused");
389
- }
390
- return emit(command.output, guidance, () => guidance, "accepted");
391
- }
392
- async function runStatusSelection(command, coordinates) {
393
- const selectors = command.selectors;
394
- if (selectors.length < 2)
395
- throw new CliUsageError("status requires at least two selectors");
396
- if (selectors.some((selector) => !selector.startsWith("aku/") && !selector.startsWith("@")) &&
397
- coordinates.repo === undefined)
398
- throw new CliUsageError("cannot select a contract while the Contract world is absent");
399
- const authority = selectors.some((selector) => selector.startsWith("@"))
400
- ? await observeNamedAddress({ world: coordinates.world, repo: coordinates.repo ?? null })
401
- : undefined;
402
- const values = [];
403
- const blocks = [];
404
- for (const selector of selectors) {
405
- const resolved = selector.startsWith("aku/")
406
- ? await readAkumaStatus(selector, undefined, coordinates)
407
- : selector.startsWith("@")
408
- ? await namedStatus(selector, coordinates, authority)
409
- : await readContractStatus(selector, coordinates);
410
- values.push(resolved.value);
411
- if (command.output === "text")
412
- blocks.push(resolved.project());
413
- }
414
- return emit(command.output, values, () => blocks.join("\n\n"), "accepted");
415
- }
416
- async function runStatusCategory(command, coordinates) {
417
- if (command.category === "contract")
418
- requiredRepo(coordinates);
419
- const report = await kanshiCategory({
420
- world: coordinates.world,
421
- ...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
422
- category: command.category,
423
- ...(command.limit === undefined ? {} : { limit: command.limit }),
424
- });
425
- return emit(command.output, report, () => renderKanshiCategoryText(report, displayContext()), "accepted");
426
- }
427
- async function runStatusIdentity(command, coordinates) {
428
- if (command.contract === undefined) {
429
- const report = await kanshi({
430
- world: coordinates.world,
431
- ...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
432
- });
433
- return emit(command.output, report, () => renderKanshiText(report, displayContext(), "world"), "accepted");
434
- }
435
- if (command.contract.startsWith("@")) {
436
- const resolved = await namedStatus(command.contract, coordinates, await observeNamedAddress({ world: coordinates.world, repo: coordinates.repo ?? null }));
437
- return emit(command.output, resolved.value, () => resolved.project(), "accepted");
438
- }
439
- if (command.contract.startsWith("kei/")) {
440
- const repo = requiredRepo(coordinates);
441
- const contract = canonicalContractSelector(command.contract);
442
- const report = await kanshi({ world: coordinates.world, repo, contract });
443
- if (report.contracts.kind === "present" && report.contracts.value.rows.length === 0) {
444
- const refusal = statusRefusal("status", contract);
445
- return emit(command.output, refusal.refusal, () => renderRefusal(refusal, undefined, displayContext()), "refused");
446
- }
447
- return emit(command.output, report, () => renderKanshiText(report, displayContext(), "contract"), "accepted");
448
- }
449
- throw new CliUsageError(`contract selector must use kei/: ${command.contract}`);
450
- }
451
- async function runStatus(command, coordinates) {
452
- if (command.category !== undefined)
453
- return await runStatusCategory(command, coordinates);
454
- if ("selectors" in command && command.selectors !== undefined)
455
- return await runStatusSelection({ ...command, selectors: command.selectors }, coordinates);
456
- if (command.akuma === true && command.contract !== undefined) {
457
- const resolved = await readAkumaStatus(command.contract, undefined, coordinates);
458
- return emit(command.output, resolved.value, () => resolved.project(), "accepted");
459
- }
460
- return await runStatusIdentity(command, coordinates);
461
- }
462
- async function runRegion(command, coordinates) {
463
- const repo = requiredRepo(coordinates);
464
- const emitSection = (section) => emit(command.output, section, () => renderRegionText(section), "accepted");
465
- if (command.paths !== undefined) {
466
- const report = await kanshi({ world: coordinates.world, repo, region: { kind: "path", patterns: command.paths } });
467
- return emitSection(report.region ?? { kind: "absent" });
468
- }
469
- const contract = command.contract === undefined ? undefined : await resolveContractId(repo, command.contract, coordinates.cwd);
470
- const report = await kanshi({ world: coordinates.world, repo, region: { kind: "declarations" } });
471
- if (contract === undefined)
472
- return emitSection(report.region ?? { kind: "absent" });
473
- const observed = await observeKeiyaku({ repo, id: contract });
474
- if (observed.kind === "missing" || observed.row.phase === "claimed" || observed.row.phase === "abandoned") {
475
- const refusal = {
476
- kind: observed.kind === "missing" ? "contract-missing" : "terminal",
477
- contractId: contract,
478
- };
479
- if (command.output === "json")
480
- writeJson(refusal);
481
- else
482
- writeStdout(renderRefusal({ operation: "region", contract, refusal }, undefined, displayContext()));
483
- return "refused";
484
- }
485
- if (report.region?.kind !== "present" || report.region.value.kind !== "declarations")
486
- return emitSection(report.region ?? { kind: "absent" });
487
- return emitSection({
488
- kind: "present",
489
- value: selectRegion({
490
- declarations: report.region.value.declarations,
491
- selection: { kind: "contract", contract },
492
- }),
493
- });
494
- }
495
- export async function runContractHistoryCommand(command, coordinates) {
496
- const repo = requiredRepo(coordinates);
497
- const selected = contractFromInput(repo, command.contract);
498
- const history = await selected.contract.history();
499
- if (history === null) {
500
- const refusal = { kind: "contract-missing", contractId: selected.id };
501
- if (command.output === "json")
502
- writeJson(refusal);
503
- else
504
- writeStdout(renderRefusal({ operation: "history", contract: selected.id, refusal }, undefined, displayContext()));
505
- return "refused";
506
- }
507
- return emit(command.output, history, () => renderContractHistory(history, { full: command.full }), "accepted");
508
- }
509
- async function runReconcile(command, coordinates, home) {
510
- const repo = requiredRepo(coordinates);
511
- const configuration = await settingsAt(coordinates.world ?? undefined, home);
512
- const library = Keiyaku.with({ settings: configuration });
513
- let report;
514
- if (command.contract === undefined) {
515
- report = await library.reconcile({ repo, retryHooks: command.retryHooks });
516
- }
517
- else {
518
- const selected = await selectedContract(repo, command.contract, coordinates.cwd);
519
- const observed = await observeKeiyaku({ repo, id: selected.id });
520
- if (observed.kind === "missing") {
521
- if (command.output === "json")
522
- writeJson(statusRefusal("reconcile", selected.id).refusal);
523
- else
524
- writeStdout(renderRefusal(statusRefusal("reconcile", selected.id), undefined, displayContext()));
525
- return "refused";
526
- }
527
- report = await library.reconcile({ repo, contract: selected.id, retryHooks: command.retryHooks });
528
- }
529
- if (command.output === "json")
530
- writeJson(report);
531
- else
532
- writeStdout(renderReconcile(report, displayContext()));
533
- return reconcileHasFailure(report) ? "failed" : "accepted";
534
- }
535
- export async function runContractCommand(command, coordinates, runtime) {
536
- const home = runtime.home;
311
+ export async function runContractCommand(command, runtime) {
537
312
  switch (command.command) {
538
313
  case "settings":
539
- return await runSettings(coordinates, home, command.output);
314
+ return await runSettings(runtime, command.output);
540
315
  case "nuke":
541
- return await runNuke(command, coordinates);
316
+ return await runNuke(command, runtime);
542
317
  case "ls":
543
- return await runLs(command, coordinates, home, runtime);
318
+ return await runLs(command, runtime);
544
319
  case "show":
545
- return await runShow(command, coordinates);
320
+ return await runShow(command, runtime);
546
321
  case "status":
547
- return await runStatus(command, coordinates);
322
+ return await runStatus(command, runtime);
548
323
  case "region":
549
- return await runRegion(command, coordinates);
324
+ return await runRegion(command, runtime);
550
325
  case "reconcile":
551
- return await runReconcile(command, coordinates, home);
552
- default: {
553
- const configuration = await settingsAt(coordinates.world ?? undefined, home);
554
- return await runContractMutation(command, {
555
- coordinates,
556
- runtime,
557
- ...(configuration === undefined ? {} : { configuration }),
558
- });
559
- }
326
+ return await runReconcile(command, runtime);
327
+ default:
328
+ return await runContractMutation(command, runtime);
560
329
  }
561
330
  }