@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,41 +1,20 @@
1
- import { akumaCallerFromEnvironment } from "../akuma-caller.js";
2
1
  import { CliUsageError, isBlankInput } from "../usage.js";
3
2
  import { readFile } from "node:fs/promises";
4
- import { resolve } from "node:path";
5
- import { deliveryOwner } from "../delivery-identity.js";
6
- import { canonicalBirthCwd } from "../../akuma/call-input.js";
7
3
  import { Schema } from "../../akuma/index.js";
8
- import { settings } from "../../settings.js";
9
- import { Akumas, AkumaWorldScopeError, } from "../../index.js";
10
- import { Keiyaku } from "../../index.js";
11
- import { World } from "../../world.js";
12
- import { contractFromInput } from "../selectors.js";
4
+ import { classifyVerb } from "../../library/keiyaku-verbs.js";
13
5
  import { ActivityDriver } from "../activity.js";
14
6
  import { displayContext, emit, resultContext, writeJson, writeStderr, writeStdout, } from "../streams.js";
15
- import { callObservationStream } from "../render/akuma-activity.js";
16
- import { contractWaitText } from "../render/contract-wait.js";
17
- import { askRawAnswer, callRawAnswer, historyRawAnswer, historyText, tellText, waitText, } from "../render/akuma-activity.js";
18
- import { askOutcome, askProgressStream, callOutcome, callObservationHead, forkOutcome, historyOutcome, killOutcome, renderCallText, renderFailedCallObservation, renderForkText, renderKillText, tellOutcome, } from "../render/akuma.js";
7
+ import { askRawAnswer, callObservationStream, callRawAnswer, historyRawAnswer } from "../render/akuma-activity.js";
8
+ import { askProgressStream, callObservationHead, renderFailedCallObservation } from "../render/akuma.js";
9
+ import { renderVerb } from "../render/verbs.js";
19
10
  export { isParsedAkumaCommand, renderAkumaHelp } from "./akuma-grammar.js";
20
- // ---------------------------------------------------------------------------
21
- // Leaf dispatch: acquisition, one public SDK invocation, direct rendering
22
- // ---------------------------------------------------------------------------
23
- async function settingsAt(root, home) {
24
- return settings({
25
- ...(root === undefined ? {} : { root }),
26
- ...(home === undefined ? {} : { home }),
27
- });
28
- }
29
- function akumas(input) {
30
- return Akumas.of(input.path, { reportDiagnostic: writeStderr });
31
- }
32
11
  async function schemaFromFile(path) {
33
12
  try {
34
13
  const parsed = JSON.parse(await readFile(path, "utf8"));
35
14
  return Schema.json(parsed, (value) => value);
36
15
  }
37
16
  catch (error) {
38
- throw new Error(`cannot read JSON Schema file ${path}: ${error instanceof Error ? error.message : String(error)}`);
17
+ throw new CliUsageError(`cannot read JSON Schema file ${path}: ${error instanceof Error ? error.message : String(error)}`);
39
18
  }
40
19
  }
41
20
  function inputAlias(selector) {
@@ -44,302 +23,187 @@ function inputAlias(selector) {
44
23
  async function promptBody(action, command, input) {
45
24
  if (command.prompt.kind !== "stdin")
46
25
  return command.prompt.value;
47
- const bytes = await input.readStdin();
26
+ const bytes = await input.runtime.readStdin();
48
27
  if (isBlankInput(bytes))
49
28
  throw new CliUsageError(`${action} requires a nonblank prompt`);
50
29
  return bytes;
51
30
  }
52
- function inputInitiator(input) {
53
- const initiator = deliveryOwner(input.environment);
54
- return initiator === undefined ? {} : { initiator };
55
- }
56
31
  function emitAnswer(body, exact) {
57
32
  if (exact)
58
33
  process.stdout.write(body);
59
34
  else
60
35
  writeStdout(body);
61
36
  }
62
- // eslint-disable-next-line complexity -- one call owns prompt/schema/placement plus live observation.
63
- async function runCall(command, input) {
64
- const body = command.prompt === undefined ? undefined : await promptBody("call", { prompt: command.prompt }, input);
65
- const schema = command.schema === undefined ? undefined : await schemaFromFile(command.schema);
66
- const declaredCaller = await akumaCallerFromEnvironment(input.environment);
67
- await World.at(input.path);
68
- const caller = akumas(input);
69
- const request = {
70
- ...(await inputInitiator(input)),
71
- ...(declaredCaller === undefined ? {} : { caller: declaredCaller }),
72
- archetype: command.archetype,
73
- ...(body === undefined ? {} : { body }),
74
- ...(input.home === undefined ? {} : { home: input.home }),
75
- ...(input.settings === undefined ? {} : { settings: input.settings }),
76
- ...(input.executionCwd === undefined ? {} : { cwd: input.executionCwd }),
77
- ...(input.contract === undefined ? {} : { contract: input.contract }),
37
+ function spawnWire(command, input, body, schema) {
38
+ return {
39
+ akumaName: command.akumaName,
40
+ ...(body === undefined ? {} : { prompt: body }),
41
+ ...(command.contract === undefined ? {} : { contract: command.contract }),
42
+ ...(input.workdir === undefined ? {} : { workdir: input.workdir }),
78
43
  ...(command.alias === undefined ? {} : { alias: command.alias }),
79
- ...(input.writableDirectories === undefined ? {} : { writableDirectories: input.writableDirectories }),
44
+ ...(command.writableDirectories === undefined ? {} : { writableDirectories: command.writableDirectories }),
80
45
  ...(command.bare === undefined ? {} : { bare: command.bare }),
81
- ...(schema === undefined ? {} : { schema }),
82
- ...(input.signal === undefined ? {} : { signal: input.signal }),
46
+ ...(schema === undefined ? {} : { schema: schema.jsonSchema }),
47
+ mode: command.mode,
48
+ ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
83
49
  };
50
+ }
51
+ async function runSpawn(command, input) {
52
+ const body = command.prompt === undefined ? undefined : await promptBody("spawn", { prompt: command.prompt }, input);
53
+ const schema = command.schema === undefined ? undefined : await schemaFromFile(command.schema);
54
+ const wire = spawnWire(command, input, body, schema);
84
55
  let stream;
85
56
  const driver = new ActivityDriver(process.stderr);
86
57
  const observing = command.mode === "wait" && command.output === "text";
87
58
  const observe = observing
88
- ? {
89
- admitted: (tell, id, head) => {
90
- stream = callObservationStream(resultContext(), callObservationHead({
91
- akuma: id,
92
- ...head,
93
- ...(input.executionCwd === undefined ? {} : { cwd: input.executionCwd }),
94
- }), { admittedAt: tell.row.at });
59
+ ? (event) => {
60
+ if (event.kind === "admitted") {
61
+ stream = callObservationStream(resultContext(), callObservationHead({ akumaId: event.id, ...event.head }), {
62
+ admittedAt: event.tell.row.at,
63
+ });
95
64
  driver.redraw(stream.frame());
96
- },
97
- observe: (observation) => {
98
- driver.settle(stream?.observe(observation) ?? [], stream?.frame() ?? []);
99
- },
65
+ }
66
+ else {
67
+ driver.settle(stream?.observe(event.observation) ?? [], stream?.frame() ?? []);
68
+ }
100
69
  }
101
70
  : undefined;
102
71
  try {
103
- const result = await caller.call({
104
- ...request,
105
- mode: command.mode,
106
- ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
72
+ const result = await input.runtime.facet.run("spawn", wire, {
73
+ signal: input.runtime.signal,
107
74
  ...(observe === undefined ? {} : { observe }),
75
+ ...(schema === undefined ? {} : { decode: schema.decode }),
108
76
  });
109
77
  let streamed = stream !== undefined;
110
- if (stream !== undefined) {
111
- driver.conclude(stream.conclude(result.observation));
112
- }
113
- else if (observing && result.observation.kind === "failed") {
114
- writeStderr(renderFailedCallObservation(result, resultContext()));
78
+ if (stream !== undefined)
79
+ driver.conclude(stream.conclude(result));
80
+ else if (observing && result.failure !== undefined) {
81
+ writeStderr(renderFailedCallObservation(result, resultContext(), body === undefined ? {} : { prompt: body }));
115
82
  streamed = true;
116
83
  }
84
+ const completion = { kind: "returned", value: result };
117
85
  if (command.output === "json")
118
86
  writeJson(result);
87
+ else if (streamed)
88
+ emitAnswer(callRawAnswer(result, schema !== undefined, true) ?? "", callRawAnswer(result, schema !== undefined, true) !== undefined);
119
89
  else {
120
- const raw = callRawAnswer(result, streamed);
121
- if (raw === undefined)
122
- emitAnswer(renderCallText(result, streamed, displayContext()), false);
123
- else
124
- emitAnswer(raw, true);
90
+ const raw = callRawAnswer(result, schema !== undefined, false);
91
+ emitAnswer(renderVerb("spawn", wire, completion, displayContext()), raw !== undefined);
125
92
  }
126
- return callOutcome(result);
93
+ return classifyVerb("spawn", wire, completion);
127
94
  }
128
95
  finally {
129
96
  driver.close(stream?.flush() ?? []);
130
97
  }
131
98
  }
132
99
  async function runWait(command, input) {
133
- const alias = command.akuma.length === 1 ? inputAlias(command.akuma[0]) : undefined;
134
- const result = await akumas(input).wait({
135
- akuma: command.akuma,
136
- ...(input.repo === undefined ? {} : { repo: input.repo }),
100
+ const wire = {
101
+ selectors: command.akuma,
137
102
  ...(command.completion === undefined ? {} : { completion: command.completion }),
138
103
  ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
139
- ...(input.signal === undefined ? {} : { signal: input.signal }),
140
- });
141
- const outcome = result.unobserved.length === 0 ? "accepted" : "failed";
142
- if (command.output === "json")
143
- writeJson(result);
144
- else
145
- emitAnswer(waitText(result, { ...(alias === undefined ? {} : { alias }) }, displayContext()), false);
146
- return outcome;
104
+ };
105
+ const result = await input.runtime.facet.run("wait", wire, { signal: input.runtime.signal });
106
+ const completion = { kind: "returned", value: result };
107
+ return emit(command.output, result, () => renderVerb("wait", wire, completion, displayContext()), classifyVerb("wait", wire, completion));
147
108
  }
148
109
  async function runTell(command, input) {
149
- const body = await promptBody("tell", command, input);
150
- const result = await akumas(input).tell({
151
- ...(await inputInitiator(input)),
110
+ const wire = {
152
111
  akuma: command.akuma,
153
- body,
112
+ prompt: await promptBody("tell", command, input),
154
113
  ...(command.interrupt ? { interrupt: true } : {}),
155
- ...(input.repo === undefined ? {} : { repo: input.repo }),
156
- ...(input.signal === undefined ? {} : { signal: input.signal }),
157
- });
158
- const text = () => tellText(result, inputAlias(command.akuma), displayContext());
159
- return emit(command.output, result, text, tellOutcome(result));
114
+ };
115
+ const result = await input.runtime.facet.run("tell", wire, { signal: input.runtime.signal });
116
+ const completion = { kind: "returned", value: result };
117
+ return emit(command.output, result, () => renderVerb("tell", wire, completion, displayContext()), classifyVerb("tell", wire, completion));
160
118
  }
161
119
  async function runAsk(command, input) {
162
120
  const body = await promptBody("ask", command, input);
163
121
  const schema = command.schema === undefined ? undefined : await schemaFromFile(command.schema);
164
- const alias = inputAlias(command.akuma);
165
- const progress = command.output === "text" ? askProgressStream(undefined, alias, resultContext()) : undefined;
122
+ const wire = {
123
+ akuma: command.akuma,
124
+ prompt: body,
125
+ ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
126
+ ...(schema === undefined ? {} : { schema: schema.jsonSchema }),
127
+ ...(command.interrupt ? { interrupt: true } : {}),
128
+ };
129
+ const progress = command.output === "text" ? askProgressStream(undefined, inputAlias(command.akuma), resultContext()) : undefined;
166
130
  const driver = new ActivityDriver(process.stderr);
131
+ const observe = progress === undefined
132
+ ? undefined
133
+ : (event) => {
134
+ if (event.kind === "admitted")
135
+ driver.settle(progress.admitted(event.tell, event.id), progress.frame());
136
+ else
137
+ driver.settle(progress.observe(event.observation), progress.frame());
138
+ };
167
139
  try {
168
- const result = await akumas(input).ask({
169
- ...(await inputInitiator(input)),
170
- akuma: command.akuma,
171
- body,
172
- ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
173
- ...(schema === undefined ? {} : { schema }),
174
- ...(command.interrupt ? { interrupt: true } : {}),
175
- ...(input.repo === undefined ? {} : { repo: input.repo }),
176
- ...(input.signal === undefined ? {} : { signal: input.signal }),
177
- ...(progress === undefined
178
- ? {}
179
- : {
180
- observe: {
181
- admitted: (tell, id) => {
182
- driver.settle(progress.admitted(tell, id), progress.frame());
183
- },
184
- observe: (observation) => {
185
- driver.settle(progress.observe(observation), progress.frame());
186
- },
187
- },
188
- }),
140
+ const result = await input.runtime.facet.run("ask", wire, {
141
+ signal: input.runtime.signal,
142
+ ...(observe === undefined ? {} : { observe }),
143
+ ...(schema === undefined ? {} : { decode: schema.decode }),
189
144
  });
190
145
  if (progress !== undefined)
191
146
  driver.conclude(progress.conclude(result).join("\n"));
147
+ const completion = { kind: "returned", value: result };
192
148
  if (command.output === "json")
193
149
  writeJson(result);
194
150
  else
195
151
  emitAnswer(askRawAnswer(result, schema !== undefined) ?? "", true);
196
- return askOutcome(result);
152
+ return classifyVerb("ask", wire, completion);
197
153
  }
198
154
  finally {
199
155
  driver.close(progress?.flush() ?? []);
200
156
  }
201
157
  }
202
158
  async function runHistory(command, input) {
203
- const result = await akumas(input).history({
204
- akuma: command.akuma,
205
- ...(input.repo === undefined ? {} : { repo: input.repo }),
159
+ const wire = {
160
+ selector: command.akuma,
206
161
  ...(command.before === undefined ? {} : { before: command.before }),
207
162
  ...(command.since === undefined ? {} : { since: command.since }),
208
163
  ...(command.limit === undefined ? {} : { limit: command.limit }),
209
164
  ...(command.id === undefined ? {} : { id: command.id }),
210
165
  last: command.last,
211
- });
212
- if (command.output === "json") {
166
+ };
167
+ const result = await input.runtime.facet.run("history", wire, { signal: input.runtime.signal });
168
+ if (result.kind === "contract" || result.kind === "contract-missing")
169
+ throw new Error("Akuma history returned a non-Akuma result");
170
+ const completion = { kind: "returned", value: result };
171
+ if (command.output === "json")
213
172
  writeJson(result);
214
- return historyOutcome(result, command.id);
173
+ else {
174
+ const raw = historyRawAnswer(result, command.id) !== undefined || (command.last && result.kind === "akuma-last");
175
+ emitAnswer(renderVerb("history", wire, completion, displayContext()), raw);
215
176
  }
216
- const raw = historyRawAnswer(result, command.id);
217
- const presentation = {
218
- ...(inputAlias(command.akuma) === undefined ? {} : { alias: command.akuma }),
219
- ...(command.id === undefined ? {} : { id: command.id }),
220
- last: command.last,
221
- };
222
- if (raw !== undefined)
223
- emitAnswer(raw, true);
224
- else if (command.last && result.kind === "last")
225
- emitAnswer(result.answer, true);
226
- else
227
- emitAnswer(historyText(result, presentation, displayContext()), false);
228
- return historyOutcome(result, command.id);
177
+ return classifyVerb("history", wire, completion);
229
178
  }
230
179
  async function runFork(command, input) {
231
- const caller = await akumaCallerFromEnvironment(input.environment);
232
- const receipt = await akumas(input).fork({
233
- ...(await inputInitiator(input)),
234
- ...(caller === undefined ? {} : { caller }),
235
- akuma: command.akuma,
236
- at: command.at,
237
- ...(command.bare === undefined ? {} : { bare: command.bare }),
238
- ...(input.repo === undefined ? {} : { repo: input.repo }),
239
- });
240
- return emit(command.output, receipt, () => renderForkText(receipt), forkOutcome(receipt));
180
+ const wire = { akuma: command.akuma, at: command.at, ...(command.bare === undefined ? {} : { bare: command.bare }) };
181
+ const result = await input.runtime.facet.run("fork", wire, { signal: input.runtime.signal });
182
+ const completion = { kind: "returned", value: result };
183
+ return emit(command.output, result, () => renderVerb("fork", wire, completion, displayContext()), classifyVerb("fork", wire, completion));
241
184
  }
242
185
  async function runKill(command, input) {
243
- const alias = command.akuma.length === 1 ? inputAlias(command.akuma[0]) : undefined;
244
- const result = await akumas(input).kill({
245
- akuma: command.akuma,
246
- ...(input.repo === undefined ? {} : { repo: input.repo }),
247
- ...(input.signal === undefined ? {} : { signal: input.signal }),
248
- });
249
- const text = () => renderKillText(result, alias, displayContext());
250
- return emit(command.output, result, text, killOutcome(result));
251
- }
252
- async function akumaWorld(command, coordinates) {
253
- const world = command.command === "call"
254
- ? (coordinates.candidateWorld ?? (await coordinates.establishWorld()))
255
- : coordinates.world;
256
- if (world === null)
257
- throw new CliUsageError("no Keiyaku world contains the invocation cwd");
258
- return world;
259
- }
260
- async function callExecutionCwd(command, cwd, workdir) {
261
- if (command.command !== "call")
262
- return undefined;
263
- if (workdir !== undefined)
264
- return await canonicalBirthCwd(resolve(cwd, workdir), `workdir is not an existing directory: ${workdir}`);
265
- return cwd;
266
- }
267
- async function akumaInput(command, coordinates, workdir, runtime) {
268
- const path = await akumaWorld(command, coordinates);
269
- const executionCwd = await callExecutionCwd(command, coordinates.cwd, workdir);
270
- const writableDirectories = command.command !== "call" || command.writableDirectories === undefined
271
- ? undefined
272
- : await Promise.all(command.writableDirectories.map((path) => {
273
- if (path.trim() === "")
274
- throw new TypeError("--add-dir requires a nonblank directory");
275
- return canonicalBirthCwd(resolve(coordinates.cwd, path));
276
- }));
277
- const home = command.command === "call" ? runtime.home : undefined;
278
- const configuration = command.command === "call" ? await settingsAt(path, home) : undefined;
279
- if (command.command === "call" && command.contract !== undefined && coordinates.repo === undefined)
280
- throw new Error("call with Contract requires a resolved Repo");
281
- const contract = command.command === "call" && command.contract !== undefined
282
- ? contractFromInput(coordinates.repo, command.contract).contract
283
- : undefined;
284
- return {
285
- path,
286
- ...(executionCwd === undefined ? {} : { executionCwd }),
287
- ...(writableDirectories === undefined ? {} : { writableDirectories }),
288
- ...(home === undefined ? {} : { home }),
289
- ...(configuration === undefined ? {} : { settings: configuration }),
290
- ...(contract === undefined ? {} : { contract }),
291
- ...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
292
- environment: runtime.environment,
293
- readStdin: runtime.readStdin,
294
- ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
295
- };
296
- }
297
- export async function runAkumaCommand(command, coordinates, workdir, runtime) {
298
- try {
299
- if (command.command === "wait") {
300
- const contracts = command.akuma.filter((selector) => selector.startsWith("kei/"));
301
- if (contracts.length > 0) {
302
- if (coordinates.repo === undefined)
303
- throw new CliUsageError("Contract wait requires a repository");
304
- const result = await Keiyaku.with().wait({
305
- repo: coordinates.repo,
306
- contracts,
307
- ...(command.completion === undefined ? {} : { completion: command.completion }),
308
- ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
309
- ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
310
- });
311
- if (command.output === "json")
312
- writeJson(result);
313
- else
314
- writeStdout(contractWaitText(result));
315
- return result.kind === "missing" ? "refused" : "accepted";
316
- }
317
- }
318
- const input = await akumaInput(command, coordinates, workdir, runtime);
319
- switch (command.command) {
320
- case "call":
321
- return await runCall(command, input);
322
- case "wait":
323
- return await runWait(command, input);
324
- case "tell":
325
- return await runTell(command, input);
326
- case "ask":
327
- return await runAsk(command, input);
328
- case "history":
329
- return await runHistory(command, input);
330
- case "fork":
331
- return await runFork(command, input);
332
- case "kill":
333
- return await runKill(command, input);
334
- }
335
- }
336
- catch (error) {
337
- if (error instanceof Error && "executionReceipt" in error)
338
- throw error;
339
- if (error instanceof AkumaWorldScopeError)
340
- throw error;
341
- if (error instanceof TypeError)
342
- throw new CliUsageError(error.message);
343
- throw error;
186
+ const wire = { akuma: command.akuma };
187
+ const result = await input.runtime.facet.run("kill", wire, { signal: input.runtime.signal });
188
+ const completion = { kind: "returned", value: result };
189
+ return emit(command.output, result, () => renderVerb("kill", wire, completion, displayContext()), classifyVerb("kill", wire, completion));
190
+ }
191
+ export async function runAkumaCommand(command, workdir, runtime) {
192
+ const input = { ...(workdir === undefined ? {} : { workdir }), runtime };
193
+ switch (command.command) {
194
+ case "spawn":
195
+ return runSpawn(command, input);
196
+ case "wait":
197
+ return runWait(command, input);
198
+ case "tell":
199
+ return runTell(command, input);
200
+ case "ask":
201
+ return runAsk(command, input);
202
+ case "history":
203
+ return runHistory(command, input);
204
+ case "fork":
205
+ return runFork(command, input);
206
+ case "kill":
207
+ return runKill(command, input);
344
208
  }
345
209
  }
@@ -1,5 +1,5 @@
1
1
  import { type AkumaCaller } from "../../akuma/caller.js";
2
- import { type AkuId } from "../../akuma/identity.js";
2
+ import { type AkumaId } from "../../akuma/identity.js";
3
3
  import { type ContractCommand } from "./contract-help.js";
4
4
  type AkumaCallerSelector = Readonly<{
5
5
  kind: "mine";
@@ -8,12 +8,13 @@ type AkumaCallerSelector = Readonly<{
8
8
  caller: AkumaCaller;
9
9
  }> | Readonly<{
10
10
  kind: "akuma";
11
- akuId: AkuId;
11
+ akumaId: AkumaId;
12
12
  }>;
13
13
  type CatalogQuery = Readonly<{
14
14
  kind: "debts";
15
15
  namespace?: readonly string[];
16
16
  limit?: number;
17
+ selection?: "closed" | "all";
17
18
  }> | Readonly<{
18
19
  kind: "contracts";
19
20
  limit?: number;
@@ -22,7 +23,7 @@ type CatalogQuery = Readonly<{
22
23
  limit?: number;
23
24
  }> | Readonly<{
24
25
  kind: "akuma";
25
- archetype?: string;
26
+ akumaName?: string;
26
27
  caller?: AkumaCallerSelector;
27
28
  limit?: number;
28
29
  }>;
@@ -1,6 +1,6 @@
1
1
  import { validateAkumaName } from "../../identity/normalize.js";
2
2
  import { decodeAkumaCaller } from "../../akuma/caller.js";
3
- import { parseAkuId } from "../../akuma/identity.js";
3
+ import { parseAkumaId } from "../../akuma/identity.js";
4
4
  import { parseDebtNamespaceSelector } from "../../debt/catalog.js";
5
5
  import { CliUsageError, commandGuide } from "../usage.js";
6
6
  import { CONTRACT_COMMAND_SPECS } from "./contract-help.js";
@@ -11,11 +11,11 @@ function parseAkumaCatalogPath(value) {
11
11
  return { kind: "akuma" };
12
12
  const scopedGlob = /^aku\/([^/]+)\/\*$/u.exec(value);
13
13
  if (scopedGlob !== null)
14
- return { kind: "akuma", archetype: validateAkumaName(scopedGlob[1]) };
14
+ return { kind: "akuma", akumaName: validateAkumaName(scopedGlob[1]) };
15
15
  const match = /^aku\/([^/]+)\/?$/u.exec(value);
16
16
  if (match === null)
17
17
  return null;
18
- return { kind: "akuma", archetype: validateAkumaName(match[1]) };
18
+ return { kind: "akuma", akumaName: validateAkumaName(match[1]) };
19
19
  }
20
20
  function optionalFlag(flags, name) {
21
21
  const value = flags[name];
@@ -258,7 +258,7 @@ function parseCallerSelector(parts) {
258
258
  const text = value.trim();
259
259
  if (text.startsWith("aku/")) {
260
260
  try {
261
- return { kind: "akuma", akuId: parseAkuId(text).id };
261
+ return { kind: "akuma", akumaId: parseAkumaId(text).id };
262
262
  }
263
263
  catch (error) {
264
264
  refuse("ls", `--caller has an invalid Akuma identity: ${error instanceof Error ? error.message : text}`);
@@ -281,18 +281,49 @@ function parseCallerSelector(parts) {
281
281
  refuse("ls", `--caller is invalid: ${error instanceof Error ? error.message : String(error)}`);
282
282
  }
283
283
  }
284
+ function parseAkumaLs(parts, path, limit, caller) {
285
+ if (path === undefined && caller === undefined)
286
+ refuse("ls", "ls requires a selector");
287
+ try {
288
+ const query = path === undefined ? { kind: "akuma" } : parseAkumaCatalogPath(path);
289
+ if (query === null)
290
+ refuse("ls", "ls requires a supported identity directory selector");
291
+ return {
292
+ command: "ls",
293
+ query: { ...query, ...(limit === undefined ? {} : { limit }), ...(caller === undefined ? {} : { caller }) },
294
+ output: parts.output,
295
+ };
296
+ }
297
+ catch (error) {
298
+ if (error instanceof CliUsageError)
299
+ throw error;
300
+ refuse("ls", error instanceof Error ? error.message : "invalid ls directory");
301
+ }
302
+ }
284
303
  function parseLs(parts) {
285
304
  const path = parts.positionals[0];
286
305
  const limit = listLimit(parts);
287
306
  const caller = parseCallerSelector(parts);
288
307
  const callerRefusal = "--mine and --caller select Akuma instances only";
308
+ const all = parts.flags.all === true, closed = parts.flags.closed === true;
309
+ if (all && closed)
310
+ refuse("ls", "--all and --closed are mutually exclusive");
289
311
  if (path !== undefined) {
290
312
  const debtQuery = debtCatalogQuery(path, limit);
291
313
  if (debtQuery !== null) {
292
314
  if (caller !== undefined)
293
315
  refuse("ls", callerRefusal);
294
- return { command: "ls", query: debtQuery, output: parts.output };
316
+ return {
317
+ command: "ls",
318
+ query: {
319
+ ...debtQuery,
320
+ ...(all ? { selection: "all" } : closed ? { selection: "closed" } : {}),
321
+ },
322
+ output: parts.output,
323
+ };
295
324
  }
325
+ if (all || closed)
326
+ refuse("ls", "--all and --closed select Debts only");
296
327
  if (path === "kei" || path === "kei/") {
297
328
  if (caller !== undefined)
298
329
  refuse("ls", callerRefusal);
@@ -305,23 +336,9 @@ function parseLs(parts) {
305
336
  if (caller !== undefined && (path === "aku" || path === "aku/"))
306
337
  refuse("ls", "--mine and --caller need an Akuma instance catalogue, not Akuma names");
307
338
  }
308
- if (path === undefined && caller === undefined)
309
- refuse("ls", "ls requires a selector");
310
- try {
311
- const query = path === undefined ? { kind: "akuma" } : parseAkumaCatalogPath(path);
312
- if (query === null)
313
- refuse("ls", "ls requires a supported identity directory selector");
314
- return {
315
- command: "ls",
316
- query: { ...query, ...(limit === undefined ? {} : { limit }), ...(caller === undefined ? {} : { caller }) },
317
- output: parts.output,
318
- };
319
- }
320
- catch (error) {
321
- if (error instanceof CliUsageError)
322
- throw error;
323
- refuse("ls", error instanceof Error ? error.message : "invalid ls directory");
324
- }
339
+ if (all || closed)
340
+ refuse("ls", "--all and --closed select Debts only");
341
+ return parseAkumaLs(parts, path, limit, caller);
325
342
  }
326
343
  export function parseContractCommand(parts) {
327
344
  switch (parts.command) {
@@ -132,8 +132,10 @@ export declare const CONTRACT_COMMAND_SPECS: {
132
132
  readonly json: "boolean";
133
133
  readonly mine: "boolean";
134
134
  readonly caller: "value";
135
+ readonly closed: "boolean";
136
+ readonly all: "boolean";
135
137
  };
136
- readonly usage: "ls debt[/] [--limit <count>]\nls debt/<namespace>/ [--limit <count>]\nls kei[/] [--limit <count>]\nls aku[/] [--limit <count>]\nls aku/<name>[/] [--limit <count>]\nls \"aku/<name>/*\" [--limit <count>]\nls \"aku/*/*\" [--limit <count>]\nls [aku/<name>[/] | \"aku/<name>/*\" | \"aku/*/*\"] (--mine | --caller (<integration>:<id> | aku/<name>/<suffix>)) [--limit <count>]";
138
+ readonly usage: "ls debt[/] [--closed | --all] [--limit <count>]\nls debt/<namespace>/ [--closed | --all] [--limit <count>]\nls kei[/] [--limit <count>]\nls aku[/] [--limit <count>]\nls aku/<name>[/] [--limit <count>]\nls \"aku/<name>/*\" [--limit <count>]\nls \"aku/*/*\" [--limit <count>]\nls [aku/<name>[/] | \"aku/<name>/*\" | \"aku/*/*\"] (--mine | --caller (<integration>:<id> | aku/<name>/<suffix>)) [--limit <count>]";
137
139
  readonly purpose: "List debts (ls debt), contracts (ls kei), or akumas (ls aku).";
138
140
  readonly details: string;
139
141
  };
@@ -218,12 +218,13 @@ export const CONTRACT_COMMAND_SPECS = {
218
218
  ls: {
219
219
  positional: "optional",
220
220
  stdin: "none",
221
- flags: { limit: "value", json: "boolean", mine: "boolean", caller: "value" },
222
- usage: 'ls debt[/] [--limit <count>]\nls debt/<namespace>/ [--limit <count>]\nls kei[/] [--limit <count>]\nls aku[/] [--limit <count>]\nls aku/<name>[/] [--limit <count>]\nls "aku/<name>/*" [--limit <count>]\nls "aku/*/*" [--limit <count>]\nls [aku/<name>[/] | "aku/<name>/*" | "aku/*/*"] (--mine | --caller (<integration>:<id> | aku/<name>/<suffix>)) [--limit <count>]',
221
+ flags: { limit: "value", json: "boolean", mine: "boolean", caller: "value", closed: "boolean", all: "boolean" },
222
+ usage: 'ls debt[/] [--closed | --all] [--limit <count>]\nls debt/<namespace>/ [--closed | --all] [--limit <count>]\nls kei[/] [--limit <count>]\nls aku[/] [--limit <count>]\nls aku/<name>[/] [--limit <count>]\nls "aku/<name>/*" [--limit <count>]\nls "aku/*/*" [--limit <count>]\nls [aku/<name>[/] | "aku/<name>/*" | "aku/*/*"] (--mine | --caller (<integration>:<id> | aku/<name>/<suffix>)) [--limit <count>]',
223
223
  purpose: "List debts (ls debt), contracts (ls kei), or akumas (ls aku).",
224
224
  details: [
225
+ "Debt lists open work by default; --closed selects terminal work and --all selects both.",
225
226
  "ls kei lists active Contracts; accepted and abandoned ones leave the list, and their record stays in history and Git.",
226
- "ls aku/ lists the callable Akuma-name catalog; ls aku/<name> lists recent retained Akuma instances under one name.",
227
+ "ls aku/ lists the spawnable Akuma-name catalog; ls aku/<name> lists recent retained Akuma instances under one name.",
227
228
  'ls "aku/<name>/*" is the same roster in glob form; ls "aku/*/*" lists recent retained Akuma instances across names.',
228
229
  "--mine selects the caller identity of this process and lists that caller's direct and transitive descendants in this World.",
229
230
  "--caller selects an explicit caller instead; both selectors are World-local and refuse for Contract, Debt, or Akuma-name catalogues.",