@astrosheep/keiyaku 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
  5. package/build/src/akuma/akuma-errors.d.ts +6 -0
  6. package/build/src/akuma/akuma-errors.js +9 -0
  7. package/build/src/akuma/akuma-handle.d.ts +39 -0
  8. package/build/src/akuma/akuma-handle.js +263 -0
  9. package/build/src/akuma/akuma-observe.d.ts +19 -0
  10. package/build/src/akuma/akuma-observe.js +74 -0
  11. package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
  12. package/build/src/akuma/akuma-product-symbols.js +1 -0
  13. package/build/src/akuma/akuma-product.d.ts +18 -0
  14. package/build/src/akuma/akuma-product.js +154 -0
  15. package/build/src/akuma/akuma.d.ts +37 -81
  16. package/build/src/akuma/akuma.js +39 -447
  17. package/build/src/akuma/allowed.d.ts +1 -0
  18. package/build/src/akuma/allowed.js +6 -0
  19. package/build/src/akuma/archetype.js +8 -5
  20. package/build/src/akuma/body-supervisor.d.ts +26 -0
  21. package/build/src/akuma/body-supervisor.js +89 -0
  22. package/build/src/akuma/body.d.ts +45 -4
  23. package/build/src/akuma/body.js +145 -35
  24. package/build/src/akuma/coordinate.js +17 -7
  25. package/build/src/akuma/heart/facts.js +1 -1
  26. package/build/src/akuma/heart/index.d.ts +1 -1
  27. package/build/src/akuma/heart/index.js +2 -4
  28. package/build/src/akuma/heart/request-authority.js +4 -4
  29. package/build/src/akuma/heart/request-rows.js +27 -16
  30. package/build/src/akuma/heart/rows.js +79 -41
  31. package/build/src/akuma/heart/soul.js +1 -1
  32. package/build/src/akuma/heart/storage.d.ts +1 -0
  33. package/build/src/akuma/heart/storage.js +76 -11
  34. package/build/src/akuma/heart/tells.js +35 -18
  35. package/build/src/akuma/heart/timeline.js +19 -11
  36. package/build/src/akuma/identity.d.ts +1 -0
  37. package/build/src/akuma/identity.js +1 -0
  38. package/build/src/akuma/index.d.ts +3 -3
  39. package/build/src/akuma/index.js +1 -1
  40. package/build/src/akuma/nuke.js +106 -14
  41. package/build/src/akuma/projection-read.d.ts +17 -0
  42. package/build/src/akuma/projection-read.js +135 -0
  43. package/build/src/akuma/projection.d.ts +1 -16
  44. package/build/src/akuma/projection.js +77 -154
  45. package/build/src/akuma/provider-recipe.js +11 -5
  46. package/build/src/akuma/provider.js +105 -62
  47. package/build/src/akuma/providers/acp/config.js +5 -6
  48. package/build/src/akuma/providers/acp/core.js +17 -10
  49. package/build/src/akuma/providers/acp/events.js +38 -29
  50. package/build/src/akuma/providers/acp/index.js +13 -9
  51. package/build/src/akuma/providers/claude/events.js +8 -12
  52. package/build/src/akuma/providers/claude/index.d.ts +1 -0
  53. package/build/src/akuma/providers/claude/index.js +55 -26
  54. package/build/src/akuma/providers/claude/input.js +6 -2
  55. package/build/src/akuma/providers/codex-app-server/events.js +61 -36
  56. package/build/src/akuma/providers/codex-app-server/index.js +25 -13
  57. package/build/src/akuma/providers/grok-build/index.js +22 -25
  58. package/build/src/akuma/providers/index.js +2 -18
  59. package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
  60. package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
  61. package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
  62. package/build/src/akuma/providers/pi/events.js +26 -19
  63. package/build/src/akuma/providers/pi/index.js +58 -40
  64. package/build/src/akuma/publication.js +9 -9
  65. package/build/src/akuma/request-execution.d.ts +6 -0
  66. package/build/src/akuma/request-execution.js +86 -0
  67. package/build/src/akuma/request-serve.d.ts +12 -1
  68. package/build/src/akuma/request-serve.js +19 -122
  69. package/build/src/akuma/request-wire.d.ts +2 -2
  70. package/build/src/akuma/request-wire.js +75 -102
  71. package/build/src/akuma/requests.js +2 -2
  72. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
  73. package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
  74. package/build/src/akuma-body.js +6 -5
  75. package/build/src/body/amend.d.ts +4 -1
  76. package/build/src/body/amend.js +14 -6
  77. package/build/src/body/decode.js +2 -4
  78. package/build/src/body/envelope.js +2 -4
  79. package/build/src/body/region.d.ts +1 -2
  80. package/build/src/body/region.js +2 -70
  81. package/build/src/body/render.js +17 -12
  82. package/build/src/body/shape.js +1 -7
  83. package/build/src/cli/accepted.d.ts +1 -1
  84. package/build/src/cli/accepted.js +8 -1
  85. package/build/src/cli/commands/akuma-invoke.js +18 -6
  86. package/build/src/cli/commands/akuma.d.ts +0 -6
  87. package/build/src/cli/commands/akuma.js +11 -24
  88. package/build/src/cli/commands/amend.d.ts +2 -2
  89. package/build/src/cli/commands/amend.js +2 -4
  90. package/build/src/cli/commands/bind.d.ts +4 -4
  91. package/build/src/cli/commands/bind.js +16 -6
  92. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  93. package/build/src/cli/commands/contract-invoke.js +193 -0
  94. package/build/src/cli/commands/contract.d.ts +109 -10
  95. package/build/src/cli/commands/contract.js +339 -16
  96. package/build/src/cli/commands/install.d.ts +1 -1
  97. package/build/src/cli/commands/install.js +23 -15
  98. package/build/src/cli/commands/task-invoke.js +187 -67
  99. package/build/src/cli/commands/task-query.js +48 -24
  100. package/build/src/cli/commands/task.js +150 -38
  101. package/build/src/cli/coordinates.js +2 -4
  102. package/build/src/cli/invoke.js +92 -208
  103. package/build/src/cli/main.js +4 -2
  104. package/build/src/cli/parse.d.ts +3 -90
  105. package/build/src/cli/parse.js +27 -233
  106. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  107. package/build/src/cli/render/akuma-activity.js +362 -0
  108. package/build/src/cli/render/akuma-tool-command.js +6 -7
  109. package/build/src/cli/render/akuma-tool.js +10 -8
  110. package/build/src/cli/render/akuma.d.ts +1 -1
  111. package/build/src/cli/render/akuma.js +61 -353
  112. package/build/src/cli/render/audit.js +5 -15
  113. package/build/src/cli/render/board.d.ts +1 -0
  114. package/build/src/cli/render/board.js +17 -0
  115. package/build/src/cli/render/catalog.js +81 -8
  116. package/build/src/cli/render/contract-history.d.ts +2 -0
  117. package/build/src/cli/render/contract-history.js +83 -0
  118. package/build/src/cli/render/contract-observation.d.ts +10 -0
  119. package/build/src/cli/render/contract-observation.js +58 -0
  120. package/build/src/cli/render/contract.d.ts +1 -2
  121. package/build/src/cli/render/contract.js +41 -142
  122. package/build/src/cli/render/kanshi.js +239 -215
  123. package/build/src/cli/render/receipt.js +2 -9
  124. package/build/src/cli/render/refusal.js +10 -15
  125. package/build/src/cli/render/region.js +22 -6
  126. package/build/src/cli/render/settings.js +4 -4
  127. package/build/src/cli/render/task.js +34 -14
  128. package/build/src/cli/render/terminal.js +16 -5
  129. package/build/src/cli/result.d.ts +3 -3
  130. package/build/src/cli/runtime.d.ts +6 -1
  131. package/build/src/cli/runtime.js +84 -63
  132. package/build/src/cli/selectors.js +2 -4
  133. package/build/src/cli/usage.js +6 -5
  134. package/build/src/contract-worktree.d.ts +1 -23
  135. package/build/src/contract-worktree.js +79 -155
  136. package/build/src/coordination/durable-file.js +7 -3
  137. package/build/src/coordination/sqlite-transaction-lock.js +29 -12
  138. package/build/src/core/facts/codec.js +7 -3
  139. package/build/src/core/facts/types.d.ts +1 -1
  140. package/build/src/core/subject.js +16 -9
  141. package/build/src/core/verbs/abandon.d.ts +1 -1
  142. package/build/src/core/verbs/abandon.js +1 -1
  143. package/build/src/core/verbs/amend.d.ts +1 -1
  144. package/build/src/core/verbs/amend.js +7 -7
  145. package/build/src/core/verbs/attestation.js +4 -1
  146. package/build/src/core/verbs/bind.d.ts +1 -1
  147. package/build/src/core/verbs/bind.js +1 -1
  148. package/build/src/core/verbs/placement.d.ts +1 -1
  149. package/build/src/core/verbs/placement.js +10 -8
  150. package/build/src/dispatch/index.js +8 -6
  151. package/build/src/duration.js +5 -1
  152. package/build/src/git/admission.js +5 -3
  153. package/build/src/git/hooks.d.ts +8 -0
  154. package/build/src/git/hooks.js +63 -14
  155. package/build/src/git/identity.js +1 -4
  156. package/build/src/git/integration.d.ts +2 -3
  157. package/build/src/git/integration.js +32 -39
  158. package/build/src/git/nuke.d.ts +1 -1
  159. package/build/src/git/nuke.js +110 -57
  160. package/build/src/git/observe.d.ts +13 -1
  161. package/build/src/git/observe.js +51 -44
  162. package/build/src/git/process.js +4 -2
  163. package/build/src/git/read-observation.js +10 -8
  164. package/build/src/git/reconcile.d.ts +22 -2
  165. package/build/src/git/reconcile.js +38 -274
  166. package/build/src/git/repository.d.ts +2 -0
  167. package/build/src/git/repository.js +13 -22
  168. package/build/src/git/scratch.d.ts +8 -5
  169. package/build/src/git/scratch.js +29 -2
  170. package/build/src/git/target-placement.d.ts +9 -10
  171. package/build/src/git/target-placement.js +59 -62
  172. package/build/src/git/tender.js +13 -46
  173. package/build/src/git/terminal-reconcile.d.ts +21 -0
  174. package/build/src/git/terminal-reconcile.js +278 -0
  175. package/build/src/git/terminal-seal.js +15 -12
  176. package/build/src/git/tree.js +5 -2
  177. package/build/src/git/workspace.d.ts +24 -2
  178. package/build/src/git/workspace.js +120 -16
  179. package/build/src/identity/coordinates.js +3 -1
  180. package/build/src/identity/selector.js +6 -3
  181. package/build/src/kanshi/fleet.d.ts +6 -0
  182. package/build/src/kanshi/fleet.js +27 -0
  183. package/build/src/kanshi/index.d.ts +1 -1
  184. package/build/src/kanshi/read.js +60 -48
  185. package/build/src/kanshi/report.d.ts +11 -23
  186. package/build/src/kanshi/select.js +25 -24
  187. package/build/src/library/address.d.ts +2 -1
  188. package/build/src/library/address.js +7 -8
  189. package/build/src/library/akuma-creation.js +20 -12
  190. package/build/src/library/audit.d.ts +0 -1
  191. package/build/src/library/audit.js +1 -2
  192. package/build/src/library/bind.d.ts +53 -5
  193. package/build/src/library/bind.js +98 -22
  194. package/build/src/library/catalog.d.ts +1 -0
  195. package/build/src/library/catalog.js +6 -3
  196. package/build/src/library/configuration.js +3 -1
  197. package/build/src/library/continuation.d.ts +15 -4
  198. package/build/src/library/continuation.js +24 -16
  199. package/build/src/library/contract-bind.d.ts +26 -0
  200. package/build/src/library/contract-bind.js +106 -0
  201. package/build/src/library/contract-operations.d.ts +77 -0
  202. package/build/src/library/contract-operations.js +130 -0
  203. package/build/src/library/contract-types.d.ts +95 -0
  204. package/build/src/library/contract-types.js +1 -0
  205. package/build/src/library/contract.d.ts +19 -154
  206. package/build/src/library/contract.js +46 -261
  207. package/build/src/library/fleet.d.ts +1 -1
  208. package/build/src/library/fleet.js +19 -11
  209. package/build/src/library/input.d.ts +2 -0
  210. package/build/src/library/input.js +14 -0
  211. package/build/src/library/keiyaku.d.ts +8 -7
  212. package/build/src/library/keiyaku.js +3 -3
  213. package/build/src/library/nuke.js +14 -5
  214. package/build/src/library/reconcile.d.ts +9 -4
  215. package/build/src/library/reconcile.js +30 -24
  216. package/build/src/library/refusal.d.ts +13 -5
  217. package/build/src/library/refusal.js +7 -0
  218. package/build/src/library/region.d.ts +8 -7
  219. package/build/src/library/region.js +31 -11
  220. package/build/src/library/repo.js +2 -2
  221. package/build/src/markdown/lex.js +9 -2
  222. package/build/src/markdown/parse.js +11 -7
  223. package/build/src/markdown/query.js +4 -2
  224. package/build/src/protocol/amend.js +3 -1
  225. package/build/src/protocol/attempt.d.ts +7 -3
  226. package/build/src/protocol/attempt.js +9 -5
  227. package/build/src/protocol/audit.d.ts +1 -1
  228. package/build/src/protocol/audit.js +4 -14
  229. package/build/src/protocol/bind.d.ts +19 -6
  230. package/build/src/protocol/bind.js +28 -13
  231. package/build/src/protocol/completion.d.ts +0 -1
  232. package/build/src/protocol/completion.js +1 -3
  233. package/build/src/protocol/deliver.d.ts +1 -3
  234. package/build/src/protocol/deliver.js +15 -39
  235. package/build/src/protocol/intent.d.ts +1 -0
  236. package/build/src/protocol/intent.js +9 -7
  237. package/build/src/protocol/operations.d.ts +3 -7
  238. package/build/src/protocol/operations.js +5 -3
  239. package/build/src/protocol/placement.d.ts +0 -1
  240. package/build/src/protocol/placement.js +6 -6
  241. package/build/src/protocol/read/observation.d.ts +11 -0
  242. package/build/src/protocol/read/observation.js +37 -0
  243. package/build/src/protocol/read/status.d.ts +23 -12
  244. package/build/src/protocol/read/status.js +90 -72
  245. package/build/src/protocol/reconcile.d.ts +1 -0
  246. package/build/src/protocol/reconcile.js +2 -3
  247. package/build/src/protocol/reintegrate.js +1 -1
  248. package/build/src/protocol/review.d.ts +0 -1
  249. package/build/src/protocol/review.js +15 -22
  250. package/build/src/protocol/run.d.ts +1 -0
  251. package/build/src/protocol/run.js +4 -5
  252. package/build/src/runtime/proc/launch.d.ts +33 -0
  253. package/build/src/runtime/proc/launch.js +98 -0
  254. package/build/src/runtime/proc/line-rpc.js +9 -3
  255. package/build/src/runtime/proc/run.d.ts +12 -6
  256. package/build/src/runtime/proc/run.js +78 -21
  257. package/build/src/runtime/proc/stdio.js +7 -10
  258. package/build/src/settings.js +6 -2
  259. package/build/src/settlement/holder.js +13 -10
  260. package/build/src/settlement/settle.js +39 -6
  261. package/build/src/task/board.js +12 -6
  262. package/build/src/task/compose.js +85 -22
  263. package/build/src/task/context.js +21 -8
  264. package/build/src/task/document.js +46 -10
  265. package/build/src/task/identity.js +5 -2
  266. package/build/src/task/index.d.ts +0 -1
  267. package/build/src/task/index.js +119 -34
  268. package/build/src/task/input.js +29 -7
  269. package/build/src/task/mutation.js +61 -19
  270. package/build/src/task/operations.d.ts +6 -1
  271. package/build/src/task/operations.js +83 -29
  272. package/build/src/task/query.js +55 -26
  273. package/build/src/task/store.d.ts +3 -1
  274. package/build/src/task/store.js +81 -17
  275. package/build/src/verification/execution.js +14 -11
  276. package/build/src/workspace-place.js +19 -7
  277. package/build/src/world.js +16 -6
  278. package/package.json +8 -3
@@ -1,8 +1,38 @@
1
+ import { archetypeName } from "../../akuma/identity.js";
2
+ import { CliUsageError, usageLine } from "../usage.js";
3
+ function parseAkumaCatalogPath(value) {
4
+ if (value === "aku" || value === "aku/")
5
+ return { kind: "archetypes" };
6
+ if (value === "aku/*/*")
7
+ return { kind: "akuma" };
8
+ const match = /^aku\/([^/]+)\/?$/u.exec(value);
9
+ if (match === null)
10
+ return null;
11
+ return { kind: "akuma", archetype: archetypeName(match[1]) };
12
+ }
1
13
  export const CONTRACT_COMMAND_SPECS = {
2
- bind: { positional: "none", stdin: "required", flags: { actor: "value", task: "value", target: "value", here: "boolean", after: "repeat-value", gates: "raw-value", json: "boolean" }, usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] -", purpose: "Create one Contract from stdin Markdown." },
14
+ bind: {
15
+ positional: "none",
16
+ stdin: "optional",
17
+ flags: {
18
+ actor: "value",
19
+ task: "value",
20
+ target: "value",
21
+ after: "repeat-value",
22
+ gates: "raw-value",
23
+ "fork-of": "value",
24
+ json: "boolean",
25
+ },
26
+ usage: "bind [--task <task/...>] [--target <ref>] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] - | bind --fork-of <kei/...> [--target <ref>] [--actor <actor>]",
27
+ purpose: "Create one Contract from stdin Markdown or a sibling fork.",
28
+ },
3
29
  amend: {
4
- positional: "optional", stdin: "optional", flags: { actor: "value", after: "repeat-value", "clear-after": "boolean", gates: "raw-value", json: "boolean" }, usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [-]", purpose: "Amend one Contract's document operations or structured terms.",
5
- help: [
30
+ positional: "optional",
31
+ stdin: "optional",
32
+ flags: { actor: "value", after: "repeat-value", "clear-after": "boolean", gates: "raw-value", json: "boolean" },
33
+ usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [-]",
34
+ purpose: "Amend one Contract's document operations or structured terms.",
35
+ details: [
6
36
  " ## Replace: Context|Objective|Design|Region|Criteria|Verification|<extension>",
7
37
  " ## Append: Context|Objective|Design|Criteria|<extension>",
8
38
  " ## Add: Criteria|<new-extension-title>",
@@ -12,8 +42,18 @@ export const CONTRACT_COMMAND_SPECS = {
12
42
  ].join("\n"),
13
43
  },
14
44
  deliver: {
15
- positional: "optional", stdin: "none", flags: { actor: "value", message: "value", "include-dirty": "boolean", "materialize-conflict": "boolean", json: "boolean" }, usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--actor <actor>]", purpose: "Deliver one Contract candidate from the appointed worktree.",
16
- help: [
45
+ positional: "optional",
46
+ stdin: "none",
47
+ flags: {
48
+ actor: "value",
49
+ message: "value",
50
+ "include-dirty": "boolean",
51
+ "materialize-conflict": "boolean",
52
+ json: "boolean",
53
+ },
54
+ usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--actor <actor>]",
55
+ purpose: "Deliver one Contract candidate from the appointed worktree.",
56
+ details: [
17
57
  " --include-dirty Capture the complete non-ignored worktree tree as the",
18
58
  " candidate; stages nothing, commits nothing. Refused",
19
59
  " while unmerged paths exist.",
@@ -22,15 +62,298 @@ export const CONTRACT_COMMAND_SPECS = {
22
62
  " delivery: resolve, stage, deliver again.",
23
63
  ].join("\n"),
24
64
  },
25
- review: { positional: "optional", stdin: "optional", flags: { actor: "value", satisfied: "boolean", unsatisfied: "boolean", summary: "value", json: "boolean" }, usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) (--summary <text> | -) [--actor <actor>]", purpose: "Record one review verdict." },
26
- arc: { positional: "optional", stdin: "required", flags: { actor: "value", json: "boolean" }, usage: "arc [<contract>|@<contract>] [--actor <actor>] -", purpose: "Record stdin arc Markdown for one Contract." },
27
- abandon: { positional: "optional", stdin: "none", flags: { actor: "value", note: "value", json: "boolean" }, usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>]", purpose: "Abandon one Contract with an optional note." },
28
- status: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "status [<contract>|@name|<aku/...>]", purpose: "Read the world status board or one Contract projection." },
29
- show: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "show [<contract>|@<contract>]", purpose: "Read one Contract guidance projection." },
30
- ls: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "ls task[/]\n keiyaku ls kei[/]\n keiyaku ls aku[/]\n keiyaku ls aku/<akuma>[/]\n keiyaku ls \"aku/*/*\"", purpose: "List one identity directory." },
31
- audit: { positional: "optional", stdin: "none", flags: { "include-dirty": "boolean", diff: "boolean", actor: "value", json: "boolean" }, usage: "audit [<contract>|@<contract>] [--include-dirty] [--diff] [--actor <actor>]", purpose: "Ask what candidate preparation, Verification, and target placement would do." },
32
- reconcile: { positional: "optional", stdin: "none", flags: { "retry-hooks": "boolean", json: "boolean" }, usage: "reconcile [<contract>|@<contract>] [--retry-hooks]", purpose: "Reconcile one Contract or the invocation world." },
33
- nuke: { positional: "none", stdin: "none", flags: { confirm: "value", json: "boolean" }, usage: "nuke [--confirm <WorldRoot>] [--json]", purpose: "Remove Keiyaku-owned data from one confirmed World." },
34
- settings: { positional: "none", stdin: "none", flags: { json: "boolean" }, usage: "settings", purpose: "Read user and project Settings resources." },
35
- region: { positional: "optional", stdin: "none", flags: { overlap: "boolean", path: "value", json: "boolean" }, usage: "region [<contract>] [--overlap]\n region --path <repo-relative-path>", purpose: "Read active declared Contract Regions." },
65
+ review: {
66
+ positional: "optional",
67
+ stdin: "optional",
68
+ flags: { actor: "value", satisfied: "boolean", unsatisfied: "boolean", summary: "value", json: "boolean" },
69
+ usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) (--summary <text> | -) [--actor <actor>]",
70
+ purpose: "Record one review verdict.",
71
+ },
72
+ arc: {
73
+ positional: "optional",
74
+ stdin: "required",
75
+ flags: { actor: "value", json: "boolean" },
76
+ usage: "arc [<contract>|@<contract>] [--actor <actor>] -",
77
+ purpose: "Record stdin arc Markdown for one Contract.",
78
+ },
79
+ abandon: {
80
+ positional: "optional",
81
+ stdin: "none",
82
+ flags: { actor: "value", note: "value", json: "boolean" },
83
+ usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>]",
84
+ purpose: "Abandon one Contract with an optional note.",
85
+ },
86
+ status: {
87
+ positional: "optional",
88
+ stdin: "none",
89
+ flags: { json: "boolean" },
90
+ usage: "status [<contract>|@name|<aku/...>]",
91
+ purpose: "Read the world status board or one Contract projection.",
92
+ },
93
+ show: {
94
+ positional: "optional",
95
+ stdin: "none",
96
+ flags: { json: "boolean" },
97
+ usage: "show [<contract>|@<contract>]",
98
+ purpose: "Read one Contract guidance projection.",
99
+ },
100
+ ls: {
101
+ positional: "optional",
102
+ stdin: "none",
103
+ flags: { json: "boolean" },
104
+ usage: 'ls task[/]\n keiyaku ls kei[/]\n keiyaku ls aku[/]\n keiyaku ls aku/<akuma>[/]\n keiyaku ls "aku/*/*"',
105
+ purpose: "List one identity directory.",
106
+ },
107
+ audit: {
108
+ positional: "optional",
109
+ stdin: "none",
110
+ flags: { "include-dirty": "boolean", diff: "boolean", actor: "value", json: "boolean" },
111
+ usage: "audit [<contract>|@<contract>] [--include-dirty] [--diff] [--actor <actor>]",
112
+ purpose: "Ask what candidate preparation, Verification, and target placement would do.",
113
+ },
114
+ reconcile: {
115
+ positional: "optional",
116
+ stdin: "none",
117
+ flags: { "retry-hooks": "boolean", json: "boolean" },
118
+ usage: "reconcile [<contract>|@<contract>] [--retry-hooks]",
119
+ purpose: "Reconcile one Contract or the invocation world.",
120
+ },
121
+ nuke: {
122
+ positional: "none",
123
+ stdin: "none",
124
+ flags: { confirm: "value", json: "boolean" },
125
+ usage: "nuke [--confirm <WorldRoot>] [--json]",
126
+ purpose: "Remove Keiyaku-owned data from one confirmed World.",
127
+ },
128
+ settings: {
129
+ positional: "none",
130
+ stdin: "none",
131
+ flags: { json: "boolean" },
132
+ usage: "settings",
133
+ purpose: "Read user and project Settings resources.",
134
+ },
135
+ region: {
136
+ positional: "optional",
137
+ stdin: "none",
138
+ flags: { path: "repeat-value", json: "boolean" },
139
+ usage: "region [<contract>]\n region --path <pattern> [--path <pattern> ...]",
140
+ purpose: "Read active declared Contract Regions.",
141
+ },
36
142
  };
143
+ function optionalFlag(flags, name) {
144
+ const value = flags[name];
145
+ return typeof value === "string" ? value : undefined;
146
+ }
147
+ function refuse(command, message) {
148
+ throw new CliUsageError(message, renderContractUsage(command));
149
+ }
150
+ function parseGateBundleNames(parts, command) {
151
+ const value = optionalFlag(parts.flags, "gates");
152
+ if (value === undefined)
153
+ return undefined;
154
+ const names = value.split(",");
155
+ if (names.some((name) => name.length === 0)) {
156
+ refuse(command, "--gates requires nonempty comma-separated names");
157
+ }
158
+ return names;
159
+ }
160
+ function parseBind(parts) {
161
+ const forkOf = optionalFlag(parts.flags, "fork-of");
162
+ if (forkOf !== undefined) {
163
+ if (parts.stdin)
164
+ refuse("bind", "fork bind reads no stdin");
165
+ for (const option of ["task", "after", "gates"]) {
166
+ if (parts.flags[option] !== undefined)
167
+ refuse("bind", `--${option} is not valid with --fork-of`);
168
+ }
169
+ const target = optionalFlag(parts.flags, "target");
170
+ return {
171
+ command: "bind",
172
+ forkOf,
173
+ ...(target === undefined ? {} : { target }),
174
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
175
+ output: parts.output,
176
+ };
177
+ }
178
+ if (!parts.stdin)
179
+ refuse("bind", "bind requires stdin");
180
+ const task = optionalFlag(parts.flags, "task");
181
+ const target = optionalFlag(parts.flags, "target");
182
+ const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
183
+ const gates = parseGateBundleNames(parts, "bind");
184
+ return {
185
+ command: "bind",
186
+ ...(task === undefined ? {} : { task }),
187
+ ...(target === undefined ? {} : { target }),
188
+ ...(parts.flags.after === undefined ? {} : { after }),
189
+ ...(gates === undefined ? {} : { gates }),
190
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
191
+ output: parts.output,
192
+ };
193
+ }
194
+ function parseAmend(parts) {
195
+ const contract = parts.positionals[0];
196
+ const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
197
+ if (parts.flags["clear-after"] === true && after.length > 0)
198
+ refuse("amend", "--clear-after and --after are mutually exclusive");
199
+ const gates = parseGateBundleNames(parts, "amend");
200
+ if (!parts.stdin && parts.flags.after === undefined && parts.flags["clear-after"] !== true && gates === undefined) {
201
+ refuse("amend", "amend requires stdin or --after, --clear-after, or --gates");
202
+ }
203
+ return {
204
+ command: "amend",
205
+ ...(contract === undefined ? {} : { contract }),
206
+ ...(parts.flags.after === undefined ? {} : { after }),
207
+ ...(parts.flags["clear-after"] === true ? { clearAfter: true } : {}),
208
+ ...(gates === undefined ? {} : { gates }),
209
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
210
+ ...(parts.stdin ? { stdin: true } : {}),
211
+ output: parts.output,
212
+ };
213
+ }
214
+ function parseDeliver(parts) {
215
+ const contract = parts.positionals[0];
216
+ const message = optionalFlag(parts.flags, "message");
217
+ return {
218
+ command: "deliver",
219
+ ...(contract === undefined ? {} : { contract }),
220
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
221
+ ...(message === undefined ? {} : { message }),
222
+ includeDirty: parts.flags["include-dirty"] === true,
223
+ materializeConflict: parts.flags["materialize-conflict"] === true,
224
+ output: parts.output,
225
+ };
226
+ }
227
+ function parseReview(parts) {
228
+ if (Number(parts.flags.satisfied === true) + Number(parts.flags.unsatisfied === true) !== 1) {
229
+ refuse("review", "review requires exactly one verdict flag");
230
+ }
231
+ const summary = optionalFlag(parts.flags, "summary");
232
+ if (parts.stdin === (summary !== undefined)) {
233
+ refuse("review", "review requires exactly one of --summary <text> or stdin '-'");
234
+ }
235
+ const contract = parts.positionals[0];
236
+ return {
237
+ command: "review",
238
+ ...(contract === undefined ? {} : { contract }),
239
+ verdict: parts.flags.satisfied === true ? "satisfied" : "unsatisfied",
240
+ ...(summary === undefined ? {} : { summary }),
241
+ ...(parts.stdin ? { summaryFromStdin: true } : {}),
242
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
243
+ output: parts.output,
244
+ };
245
+ }
246
+ function parseStatus(parts) {
247
+ const contract = parts.positionals[0];
248
+ if (contract?.startsWith("aku/") === true) {
249
+ return { command: "status", contract, akuma: true, output: parts.output };
250
+ }
251
+ return { command: "status", ...(contract === undefined ? {} : { contract }), output: parts.output };
252
+ }
253
+ function parseRegion(parts) {
254
+ const contract = parts.positionals[0];
255
+ const pathFlag = parts.flags.path;
256
+ const paths = pathFlag === undefined ? undefined : Array.isArray(pathFlag) ? pathFlag : [pathFlag];
257
+ if (paths !== undefined && contract !== undefined)
258
+ refuse("region", "--path cannot combine with a contract");
259
+ return {
260
+ command: "region",
261
+ ...(contract === undefined ? {} : { contract }),
262
+ ...(paths === undefined ? {} : { paths: paths }),
263
+ output: parts.output,
264
+ };
265
+ }
266
+ function parseLs(parts) {
267
+ const path = parts.positionals[0];
268
+ if (path === "task" || path === "task/")
269
+ return { command: "ls", query: { kind: "tasks" }, output: parts.output };
270
+ if (path === "kei" || path === "kei/")
271
+ return { command: "ls", query: { kind: "contracts" }, output: parts.output };
272
+ try {
273
+ const query = parseAkumaCatalogPath(path);
274
+ if (query === null)
275
+ refuse("ls", "ls requires a supported identity directory selector");
276
+ return { command: "ls", query, output: parts.output };
277
+ }
278
+ catch (error) {
279
+ if (error instanceof CliUsageError)
280
+ throw error;
281
+ refuse("ls", error instanceof Error ? error.message : "invalid ls directory");
282
+ }
283
+ }
284
+ export function renderContractHelp(command) {
285
+ const spec = CONTRACT_COMMAND_SPECS[command];
286
+ const help = `${spec.purpose}\n\n${usageLine(spec.usage)}`;
287
+ return spec.details === undefined ? help : `${help}\n\n${spec.details}`;
288
+ }
289
+ export function renderContractUsage(command) {
290
+ return usageLine(CONTRACT_COMMAND_SPECS[command].usage);
291
+ }
292
+ export function parseContractCommand(parts) {
293
+ switch (parts.command) {
294
+ case "bind":
295
+ return parseBind(parts);
296
+ case "amend":
297
+ return parseAmend(parts);
298
+ case "deliver":
299
+ return parseDeliver(parts);
300
+ case "review":
301
+ return parseReview(parts);
302
+ case "arc": {
303
+ const contract = parts.positionals[0];
304
+ return {
305
+ command: "arc",
306
+ ...(contract === undefined ? {} : { contract }),
307
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
308
+ output: parts.output,
309
+ };
310
+ }
311
+ case "abandon": {
312
+ const contract = parts.positionals[0];
313
+ const note = optionalFlag(parts.flags, "note");
314
+ return {
315
+ command: "abandon",
316
+ ...(contract === undefined ? {} : { contract }),
317
+ ...(note === undefined ? {} : { note }),
318
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
319
+ output: parts.output,
320
+ };
321
+ }
322
+ case "status":
323
+ return parseStatus(parts);
324
+ case "show": {
325
+ const contract = parts.positionals[0];
326
+ return { command: "show", ...(contract === undefined ? {} : { contract }), output: parts.output };
327
+ }
328
+ case "ls":
329
+ return parseLs(parts);
330
+ case "audit": {
331
+ const contract = parts.positionals[0];
332
+ return {
333
+ command: "audit",
334
+ ...(contract === undefined ? {} : { contract }),
335
+ includeDirty: parts.flags["include-dirty"] === true,
336
+ showDiff: parts.flags.diff === true,
337
+ ...(parts.actor === undefined ? {} : { actor: parts.actor }),
338
+ output: parts.output,
339
+ };
340
+ }
341
+ case "reconcile": {
342
+ const contract = parts.positionals[0];
343
+ return {
344
+ command: "reconcile",
345
+ ...(contract === undefined ? {} : { contract }),
346
+ retryHooks: parts.flags["retry-hooks"] === true,
347
+ output: parts.output,
348
+ };
349
+ }
350
+ case "nuke": {
351
+ const confirm = optionalFlag(parts.flags, "confirm");
352
+ return { command: "nuke", ...(confirm === undefined ? {} : { confirm }), output: parts.output };
353
+ }
354
+ case "settings":
355
+ return { command: "settings", output: parts.output };
356
+ case "region":
357
+ return parseRegion(parts);
358
+ }
359
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ProcessInput, ProcessOutcome } from "../../runtime/proc/run.js";
2
2
  export declare const HARNESS_NAMES: readonly ["codex", "claude", "opencode", "pi"];
3
- export type HarnessName = typeof HARNESS_NAMES[number];
3
+ export type HarnessName = (typeof HARNESS_NAMES)[number];
4
4
  export type ParsedInstallCommand = Readonly<{
5
5
  command: "install";
6
6
  harnesses: readonly HarnessName[];
@@ -49,17 +49,21 @@ const ASSET_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../../../in
49
49
  const PLUGIN_ROOT = resolve(ASSET_ROOT, "plugins/keiyaku");
50
50
  function recipes(harness) {
51
51
  switch (harness) {
52
- case "codex": return [
53
- ["codex", "plugin", "marketplace", "add", ASSET_ROOT, "--json"],
54
- ["codex", "plugin", "add", "keiyaku", "--marketplace", "keiyaku", "--json"],
55
- ];
56
- case "claude": return [
57
- ["claude", "plugin", "marketplace", "add", ASSET_ROOT],
58
- ["claude", "plugin", "install", "keiyaku@keiyaku", "--scope", "user"],
59
- ["claude", "plugin", "update", "keiyaku@keiyaku", "--scope", "user"],
60
- ];
61
- case "opencode": return [["opencode", "plugin", PLUGIN_ROOT, "--global", "--force"]];
62
- case "pi": return [["pi", "install", PLUGIN_ROOT]];
52
+ case "codex":
53
+ return [
54
+ ["codex", "plugin", "marketplace", "add", ASSET_ROOT, "--json"],
55
+ ["codex", "plugin", "add", "keiyaku", "--marketplace", "keiyaku", "--json"],
56
+ ];
57
+ case "claude":
58
+ return [
59
+ ["claude", "plugin", "marketplace", "add", ASSET_ROOT],
60
+ ["claude", "plugin", "install", "keiyaku@keiyaku", "--scope", "user"],
61
+ ["claude", "plugin", "update", "keiyaku@keiyaku", "--scope", "user"],
62
+ ];
63
+ case "opencode":
64
+ return [["opencode", "plugin", PLUGIN_ROOT, "--global", "--force"]];
65
+ case "pi":
66
+ return [["pi", "install", PLUGIN_ROOT]];
63
67
  }
64
68
  }
65
69
  function diagnostic(argv, outcome) {
@@ -91,14 +95,18 @@ export async function installHarnesses(harnesses, environment, runner) {
91
95
  break;
92
96
  }
93
97
  }
94
- results.push({ harness, status: failure === undefined ? "installed" : "failed", ...(failure === undefined ? {} : { diagnostic: failure }) });
98
+ results.push({
99
+ harness,
100
+ status: failure === undefined ? "installed" : "failed",
101
+ ...(failure === undefined ? {} : { diagnostic: failure }),
102
+ });
95
103
  }
96
104
  return { kind: "install", results };
97
105
  }
98
106
  export function renderInstallText(result) {
99
- return result.results.map((item) => item.status === "installed"
100
- ? `${item.harness} installed`
101
- : `${item.harness} failed: ${item.diagnostic}`).join("\n");
107
+ return result.results
108
+ .map((item) => item.status === "installed" ? `${item.harness} installed` : `${item.harness} failed: ${item.diagnostic}`)
109
+ .join("\n");
102
110
  }
103
111
  export function installExitCode(result) {
104
112
  return result.results.some((item) => item.status === "failed") ? 1 : 0;