@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,9 +1,10 @@
1
1
  import { isTaskAction, parseTaskCommand, renderTaskHelp, renderTaskUsage, } from "./commands/task.js";
2
- import { isAkumaAction, parseAkumaCatalogPath, parseAkumaCommand, renderAkumaHelp, renderAkumaRootRows, renderAkumaUsage, } from "./commands/akuma.js";
3
- import { INSTALL_USAGE, parseInstallCommand, renderInstallHelp } from "./commands/install.js";
4
- import { CONTRACT_COMMAND_SPECS, } from "./commands/contract.js";
5
- import { CliUsageError, isBlankInput, usageLine } from "./usage.js";
2
+ import { isAkumaAction, parseAkumaCommand, renderAkumaHelp, renderAkumaRootRows, renderAkumaUsage, } from "./commands/akuma.js";
3
+ import { INSTALL_USAGE, parseInstallCommand, renderInstallHelp, } from "./commands/install.js";
4
+ import { CONTRACT_COMMAND_SPECS, parseContractCommand, renderContractHelp as renderContractHelpForOwner, renderContractUsage, } from "./commands/contract.js";
5
+ import { CliUsageError, isBlankInput } from "./usage.js";
6
6
  export { CliUsageError } from "./usage.js";
7
+ export { renderContractHelp } from "./commands/contract.js";
7
8
  const ROOT_USAGE = "usage: keiyaku [-C <path>] [--repo <path>] <command> [<contract>|@<contract>] [--flag ...] [-]";
8
9
  export function renderRootHelp() {
9
10
  return [
@@ -22,13 +23,8 @@ export function renderRootHelp() {
22
23
  ...renderAkumaRootRows(),
23
24
  ].join("\n");
24
25
  }
25
- export function renderContractHelp(command) {
26
- const spec = CONTRACT_COMMAND_SPECS[command];
27
- const help = `${spec.purpose}\n\n${usageLine(spec.usage)}`;
28
- return spec.help === undefined ? help : `${help}\n\n${spec.help}`;
29
- }
30
26
  function contractUsage(command) {
31
- return usageLine(CONTRACT_COMMAND_SPECS[command].usage);
27
+ return renderContractUsage(command);
32
28
  }
33
29
  export function renderCommandUsage(command) {
34
30
  if (command.command === "install")
@@ -41,11 +37,16 @@ export function renderCommandUsage(command) {
41
37
  }
42
38
  export function renderHelp(coordinate) {
43
39
  switch (coordinate.kind) {
44
- case "root": return renderRootHelp();
45
- case "contract": return renderContractHelp(coordinate.command);
46
- case "task": return renderTaskHelp(coordinate.action);
47
- case "install": return renderInstallHelp();
48
- case "akuma": return renderAkumaHelp(coordinate.action);
40
+ case "root":
41
+ return renderRootHelp();
42
+ case "contract":
43
+ return renderContractHelpForOwner(coordinate.command);
44
+ case "task":
45
+ return renderTaskHelp(coordinate.action);
46
+ case "install":
47
+ return renderInstallHelp();
48
+ case "akuma":
49
+ return renderAkumaHelp(coordinate.action);
49
50
  }
50
51
  }
51
52
  export function commandRepoPolicy(command) {
@@ -98,18 +99,12 @@ export function assertExplicitRepoUse(command, repo) {
98
99
  if (repo !== undefined && !commandRepoPolicy(command).acceptsExplicit)
99
100
  refuseUnusedRepo(command);
100
101
  }
101
- function optionalFlag(flags, name) {
102
- const value = flags[name];
103
- return typeof value === "string" ? value : undefined;
104
- }
105
102
  function refuse(command, message) {
106
103
  throw new CliUsageError(message, contractUsage(command));
107
104
  }
108
- function scanStdin(command, state, index, length) {
105
+ function scanStdin(command, state) {
109
106
  if (state.stdin)
110
107
  refuse(command, "stdin marker '-' may appear only once");
111
- if (index !== length - 1)
112
- refuse(command, "stdin marker '-' must be the final argument");
113
108
  if (CONTRACT_COMMAND_SPECS[command].stdin === "none")
114
109
  refuse(command, `${command} reads no stdin`);
115
110
  state.stdin = true;
@@ -155,7 +150,7 @@ function scanArgv(argv) {
155
150
  for (let index = 1; index < argv.length; index += 1) {
156
151
  const token = argv[index];
157
152
  if (token === "-") {
158
- scanStdin(command, state, index, argv.length);
153
+ scanStdin(command, state);
159
154
  continue;
160
155
  }
161
156
  if (token.startsWith("--")) {
@@ -176,174 +171,19 @@ function scanArgv(argv) {
176
171
  refuse(command, `${command} requires stdin`);
177
172
  }
178
173
  const output = state.flags.json === true ? "json" : "text";
179
- const actor = optionalFlag(state.flags, "actor");
174
+ const actor = typeof state.flags.actor === "string" ? state.flags.actor : undefined;
180
175
  return { command, ...state, output, ...(actor === undefined ? {} : { actor }) };
181
176
  }
182
- function parseBind(parts) {
183
- const task = optionalFlag(parts.flags, "task");
184
- const target = optionalFlag(parts.flags, "target");
185
- const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
186
- const gates = parseGateBundleNames(parts, "bind");
187
- return {
188
- command: "bind",
189
- ...(task === undefined ? {} : { task }),
190
- ...(target === undefined ? {} : { target }),
191
- ...(parts.flags.here === true ? { workspace: "here" } : {}),
192
- ...(parts.flags.after === undefined ? {} : { after }),
193
- ...(gates === undefined ? {} : { gates }),
194
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
195
- output: parts.output,
196
- };
197
- }
198
- function parseAmend(parts) {
199
- const contract = parts.positionals[0];
200
- const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
201
- if (parts.flags["clear-after"] === true && after.length > 0)
202
- refuse("amend", "--clear-after and --after are mutually exclusive");
203
- const gates = parseGateBundleNames(parts, "amend");
204
- if (!parts.stdin && parts.flags.after === undefined && parts.flags["clear-after"] !== true && gates === undefined) {
205
- refuse("amend", "amend requires stdin or --after, --clear-after, or --gates");
206
- }
207
- return {
208
- command: "amend",
209
- ...(contract === undefined ? {} : { contract }),
210
- ...(parts.flags.after === undefined ? {} : { after }),
211
- ...(parts.flags["clear-after"] === true ? { clearAfter: true } : {}),
212
- ...(gates === undefined ? {} : { gates }),
213
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
214
- ...(parts.stdin ? { stdin: true } : {}),
215
- output: parts.output,
216
- };
217
- }
218
- function parseGateBundleNames(parts, command) {
219
- const value = optionalFlag(parts.flags, "gates");
220
- if (value === undefined)
221
- return undefined;
222
- const names = value.split(",");
223
- if (names.some((name) => name.length === 0)) {
224
- refuse(command, "--gates requires nonempty comma-separated names");
225
- }
226
- return names;
227
- }
228
- function parseDeliver(parts) {
229
- const contract = parts.positionals[0];
230
- const message = optionalFlag(parts.flags, "message");
231
- return {
232
- command: "deliver",
233
- ...(contract === undefined ? {} : { contract }),
234
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
235
- ...(message === undefined ? {} : { message }),
236
- includeDirty: parts.flags["include-dirty"] === true,
237
- materializeConflict: parts.flags["materialize-conflict"] === true,
238
- output: parts.output,
239
- };
240
- }
241
- function parseReview(parts) {
242
- if (Number(parts.flags.satisfied === true) + Number(parts.flags.unsatisfied === true) !== 1) {
243
- refuse("review", "review requires exactly one verdict flag");
244
- }
245
- const summary = optionalFlag(parts.flags, "summary");
246
- if (parts.stdin === (summary !== undefined)) {
247
- refuse("review", "review requires exactly one of --summary <text> or stdin '-'");
248
- }
249
- const contract = parts.positionals[0];
250
- return {
251
- command: "review",
252
- ...(contract === undefined ? {} : { contract }),
253
- verdict: parts.flags.satisfied === true ? "satisfied" : "unsatisfied",
254
- ...(summary === undefined ? {} : { summary }),
255
- ...(parts.stdin ? { summaryFromStdin: true } : {}),
256
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
257
- output: parts.output,
258
- };
259
- }
260
- function parseArc(parts) {
261
- const contract = parts.positionals[0];
262
- return {
263
- command: "arc",
264
- ...(contract === undefined ? {} : { contract }),
265
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
266
- output: parts.output,
267
- };
268
- }
269
- function parseAbandon(parts) {
270
- const contract = parts.positionals[0];
271
- const note = optionalFlag(parts.flags, "note");
272
- return {
273
- command: "abandon",
274
- ...(contract === undefined ? {} : { contract }),
275
- ...(note === undefined ? {} : { note }),
276
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
277
- output: parts.output,
278
- };
279
- }
280
- function parseStatus(parts) {
281
- const contract = parts.positionals[0];
282
- if (contract?.startsWith("aku/") === true) {
283
- return {
284
- command: "status",
285
- contract,
286
- akuma: true,
287
- output: parts.output,
288
- };
289
- }
290
- return {
291
- command: "status",
292
- ...(contract === undefined ? {} : { contract }),
293
- output: parts.output,
294
- };
295
- }
296
- function parseShow(parts) {
297
- const contract = parts.positionals[0];
298
- return { command: "show", ...(contract === undefined ? {} : { contract }), output: parts.output };
299
- }
300
- function parseRegion(parts) {
301
- const contract = parts.positionals[0];
302
- const path = optionalFlag(parts.flags, "path");
303
- const overlap = parts.flags.overlap === true;
304
- if (path !== undefined && (contract !== undefined || overlap))
305
- refuse("region", "--path cannot combine with a contract or --overlap");
306
- return {
307
- command: "region",
308
- ...(contract === undefined ? {} : { contract }),
309
- ...(path === undefined ? {} : { path }),
310
- overlap,
311
- output: parts.output,
312
- };
313
- }
314
- function parseLs(parts) {
315
- const path = parts.positionals[0];
316
- if (path === "task" || path === "task/")
317
- return { command: "ls", query: { kind: "tasks" }, output: parts.output };
318
- if (path === "kei" || path === "kei/")
319
- return { command: "ls", query: { kind: "contracts" }, output: parts.output };
320
- try {
321
- const query = parseAkumaCatalogPath(path);
322
- if (query === null)
323
- refuse("ls", "ls requires a supported identity directory selector");
324
- return { command: "ls", query, output: parts.output };
325
- }
326
- catch (error) {
327
- if (error instanceof CliUsageError)
328
- throw error;
329
- refuse("ls", error instanceof Error ? error.message : "invalid ls directory");
330
- }
331
- }
332
177
  function invocationOptions(argv) {
333
178
  let cwd;
334
179
  let repo;
335
- let stdinSeen = false;
336
180
  const commandArgv = [];
337
181
  for (let index = 0; index < argv.length; index += 1) {
338
182
  const token = argv[index];
339
183
  if (token !== "-C" && token !== "--cwd" && token !== "--repo") {
340
184
  commandArgv.push(token);
341
- if (token === "-")
342
- stdinSeen = true;
343
185
  continue;
344
186
  }
345
- if (stdinSeen)
346
- throw new CliUsageError("stdin marker '-' must be the final argument", renderRootHelp());
347
187
  if (token === "--repo" && repo !== undefined) {
348
188
  throw new CliUsageError("--repo may appear only once", renderRootHelp());
349
189
  }
@@ -385,68 +225,22 @@ function helpCoordinate(argv) {
385
225
  }
386
226
  return { kind: "root" };
387
227
  }
388
- function parseCommand(parts) {
389
- switch (parts.command) {
390
- case "bind": return parseBind(parts);
391
- case "amend": return parseAmend(parts);
392
- case "deliver": return parseDeliver(parts);
393
- case "review": return parseReview(parts);
394
- case "arc": return parseArc(parts);
395
- case "abandon": return parseAbandon(parts);
396
- case "status": return parseStatus(parts);
397
- case "show": return parseShow(parts);
398
- case "ls": return parseLs(parts);
399
- case "audit": {
400
- const contract = parts.positionals[0];
401
- return {
402
- command: "audit",
403
- ...(contract === undefined ? {} : { contract }),
404
- includeDirty: parts.flags["include-dirty"] === true,
405
- showDiff: parts.flags.diff === true,
406
- ...(parts.actor === undefined ? {} : { actor: parts.actor }),
407
- output: parts.output,
408
- };
409
- }
410
- case "reconcile": {
411
- const contract = parts.positionals[0];
412
- return {
413
- command: "reconcile",
414
- ...(contract === undefined ? {} : { contract }),
415
- retryHooks: parts.flags["retry-hooks"] === true,
416
- output: parts.output,
417
- };
418
- }
419
- case "nuke": {
420
- const confirm = optionalFlag(parts.flags, "confirm");
421
- return { command: "nuke", ...(confirm === undefined ? {} : { confirm }), output: parts.output };
422
- }
423
- case "settings": return { command: "settings", output: parts.output };
424
- case "region": return parseRegion(parts);
425
- }
426
- }
427
228
  export function parseArgv(argv) {
428
229
  const invocation = invocationOptions(argv);
429
230
  const help = helpCoordinate(invocation.commandArgv);
430
231
  if (help !== null)
431
232
  return { help };
432
- if (invocation.commandArgv[0] === "ls"
433
- && (invocation.commandArgv.length === 1
434
- || (invocation.commandArgv.length === 2 && invocation.commandArgv[1] === "--json"))) {
233
+ if (invocation.commandArgv[0] === "ls" &&
234
+ (invocation.commandArgv.length === 1 ||
235
+ (invocation.commandArgv.length === 2 && invocation.commandArgv[1] === "--json"))) {
435
236
  return { help: { kind: "contract", command: "ls" } };
436
237
  }
437
- const task = invocation.commandArgv[0] === "task"
438
- ? parseTaskCommand(invocation.commandArgv.slice(1))
439
- : undefined;
440
- const install = invocation.commandArgv[0] === "install"
441
- ? parseInstallCommand(invocation.commandArgv.slice(1))
442
- : undefined;
443
- const akuma = isAkumaAction(invocation.commandArgv[0])
444
- ? parseAkumaCommand(invocation.commandArgv)
445
- : undefined;
446
- const parsed = {
238
+ const task = invocation.commandArgv[0] === "task" ? parseTaskCommand(invocation.commandArgv.slice(1)) : undefined;
239
+ const install = invocation.commandArgv[0] === "install" ? parseInstallCommand(invocation.commandArgv.slice(1)) : undefined;
240
+ const akuma = isAkumaAction(invocation.commandArgv[0]) ? parseAkumaCommand(invocation.commandArgv) : undefined;
241
+ return {
447
242
  ...(invocation.cwd === undefined ? {} : { cwd: invocation.cwd }),
448
243
  ...(invocation.repo === undefined ? {} : { repo: invocation.repo }),
449
- command: task ?? akuma ?? install ?? parseCommand(scanArgv(invocation.commandArgv)),
244
+ command: task ?? akuma ?? install ?? parseContractCommand(scanArgv(invocation.commandArgv)),
450
245
  };
451
- return parsed;
452
246
  }
@@ -0,0 +1,38 @@
1
+ import type { AkumaObservation, AkumaObservationStage, CreatedTaskObservation, DispatchAssociation } from "../../index.js";
2
+ import type { AkumaInvocationResult } from "../commands/akuma-invoke.js";
3
+ import type { ParsedCommand } from "../parse.js";
4
+ import { type TextRenderContext } from "./terminal.js";
5
+ export declare const DEFAULT_CONTEXT: TextRenderContext;
6
+ export declare function associatedIdentity(id: string, alias?: string, contract?: DispatchAssociation): string;
7
+ export declare function snapshotHeading(id: string, alias: string | undefined, contract: DispatchAssociation | undefined): readonly string[];
8
+ type SnapshotView = Readonly<{
9
+ status: AkumaObservation["status"];
10
+ contract: DispatchAssociation;
11
+ createdTasks?: CreatedTaskObservation;
12
+ }>;
13
+ type SnapshotCoreOptions = Readonly<{
14
+ alias?: string;
15
+ facts?: readonly string[];
16
+ }>;
17
+ export declare function snapshotText(view: SnapshotView, context: TextRenderContext, options?: SnapshotCoreOptions): string;
18
+ export declare function mutationObservationStageText(id: string, observation: AkumaObservationStage, context: TextRenderContext, options?: SnapshotCoreOptions & Readonly<{
19
+ showLife?: boolean;
20
+ }>): string;
21
+ export declare function statusAnswer(view: Readonly<{
22
+ status: AkumaObservation["status"];
23
+ }>): string | undefined;
24
+ export declare function akumaRawAnswer(result: AkumaInvocationResult): string | undefined;
25
+ export declare function waitText(result: Extract<AkumaInvocationResult, {
26
+ action: "wait";
27
+ }>, context: TextRenderContext): string;
28
+ export declare function historyText(command: Extract<ParsedCommand, {
29
+ command: "history";
30
+ last: boolean;
31
+ }>, result: Extract<AkumaInvocationResult, {
32
+ action: "history";
33
+ }>, context: TextRenderContext): string;
34
+ export declare function tellText(result: Extract<AkumaInvocationResult, {
35
+ action: "tell";
36
+ mode: "ordinary";
37
+ }>, context: TextRenderContext): string;
38
+ export {};