@astrosheep/keiyaku 4.1.1 → 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 (58) hide show
  1. package/build/src/akuma/akuma-errors.d.ts +6 -0
  2. package/build/src/akuma/akuma-errors.js +9 -0
  3. package/build/src/akuma/akuma-handle.d.ts +39 -0
  4. package/build/src/akuma/akuma-handle.js +263 -0
  5. package/build/src/akuma/akuma-observe.d.ts +19 -0
  6. package/build/src/akuma/akuma-observe.js +74 -0
  7. package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
  8. package/build/src/akuma/akuma-product-symbols.js +1 -0
  9. package/build/src/akuma/akuma-product.d.ts +18 -0
  10. package/build/src/akuma/akuma-product.js +154 -0
  11. package/build/src/akuma/akuma.d.ts +23 -70
  12. package/build/src/akuma/akuma.js +17 -433
  13. package/build/src/akuma/body-supervisor.d.ts +26 -0
  14. package/build/src/akuma/body-supervisor.js +89 -0
  15. package/build/src/akuma/body.d.ts +1 -1
  16. package/build/src/akuma/body.js +3 -2
  17. package/build/src/akuma/projection-read.d.ts +17 -0
  18. package/build/src/akuma/projection-read.js +135 -0
  19. package/build/src/akuma/projection.d.ts +1 -18
  20. package/build/src/akuma/projection.js +21 -155
  21. package/build/src/akuma/request-execution.d.ts +6 -0
  22. package/build/src/akuma/request-execution.js +86 -0
  23. package/build/src/akuma/request-serve.d.ts +12 -1
  24. package/build/src/akuma/request-serve.js +2 -102
  25. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
  26. package/build/src/akuma/{body-turn.js → turn-drive.js} +4 -99
  27. package/build/src/cli/commands/akuma.d.ts +0 -6
  28. package/build/src/cli/commands/akuma.js +1 -11
  29. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  30. package/build/src/cli/commands/contract-invoke.js +193 -0
  31. package/build/src/cli/commands/contract.d.ts +12 -0
  32. package/build/src/cli/commands/contract.js +229 -0
  33. package/build/src/cli/invoke.js +24 -184
  34. package/build/src/cli/parse.d.ts +1 -1
  35. package/build/src/cli/parse.js +8 -222
  36. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  37. package/build/src/cli/render/akuma-activity.js +362 -0
  38. package/build/src/cli/render/akuma.d.ts +1 -1
  39. package/build/src/cli/render/akuma.js +14 -371
  40. package/build/src/cli/render/contract-history.d.ts +2 -0
  41. package/build/src/cli/render/contract-history.js +83 -0
  42. package/build/src/cli/render/contract.d.ts +1 -2
  43. package/build/src/cli/render/contract.js +1 -83
  44. package/build/src/git/reconcile.d.ts +8 -1
  45. package/build/src/git/reconcile.js +13 -301
  46. package/build/src/git/scratch.d.ts +8 -5
  47. package/build/src/git/scratch.js +29 -2
  48. package/build/src/git/terminal-reconcile.d.ts +21 -0
  49. package/build/src/git/terminal-reconcile.js +278 -0
  50. package/build/src/library/contract-bind.d.ts +26 -0
  51. package/build/src/library/contract-bind.js +106 -0
  52. package/build/src/library/contract-operations.d.ts +77 -0
  53. package/build/src/library/contract-operations.js +130 -0
  54. package/build/src/library/contract-types.d.ts +95 -0
  55. package/build/src/library/contract-types.js +1 -0
  56. package/build/src/library/contract.d.ts +11 -136
  57. package/build/src/library/contract.js +9 -222
  58. package/package.json +1 -1
@@ -1,3 +1,15 @@
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
14
  bind: {
3
15
  positional: "none",
@@ -128,3 +140,220 @@ export const CONTRACT_COMMAND_SPECS = {
128
140
  purpose: "Read active declared Contract Regions.",
129
141
  },
130
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,5 +1,6 @@
1
1
  import { resolveActor } from "./actor.js";
2
2
  import { isParsedAkumaCommand } from "./commands/akuma.js";
3
+ import { invokeContractMutation } from "./commands/contract-invoke.js";
3
4
  import { assertExplicitRepoUse, CliUsageError, renderCommandUsage, } from "./parse.js";
4
5
  import { isBlankInput } from "./usage.js";
5
6
  async function readStdin() {
@@ -65,14 +66,6 @@ function consumeSettings(run, ErrorType) {
65
66
  throw error;
66
67
  }
67
68
  }
68
- async function selectedGates(value, names) {
69
- const { gatesFrom, SettingsError } = await import("../library/configuration.js");
70
- return consumeSettings(() => gatesFrom({ settings: value, ...(names === undefined ? {} : { names }) }), SettingsError);
71
- }
72
- async function selectedGitPolicy(value) {
73
- const { requireBranchesToBeUpToDateFrom, SettingsError } = await import("../library/configuration.js");
74
- return consumeSettings(() => requireBranchesToBeUpToDateFrom({ settings: value }), SettingsError);
75
- }
76
69
  function actorFromEdge(actor, environment) {
77
70
  let resolved;
78
71
  try {
@@ -99,162 +92,6 @@ async function selectContract(repo, selector, scope) {
99
92
  const id = resolveContextualContract(await Keiyaku.list({ repo }), selector, scope);
100
93
  return contractFromInput(repo, id);
101
94
  }
102
- async function bindDraftReceipt(establishWorld, markdown) {
103
- const { preserveBindDraft } = await import("./draft.js");
104
- try {
105
- return preserveBindDraft(await establishWorld(), markdown);
106
- }
107
- catch (error) {
108
- return { warning: `bind draft could not be preserved: ${error instanceof Error ? error.message : String(error)}` };
109
- }
110
- }
111
- async function invokeBind({ parsed, repo, edge, configuration, hooks, establishWorld, }) {
112
- if (parsed.forkOf !== undefined) {
113
- const actor = actorFromEdge(parsed.actor, edge.environment);
114
- const { bindFromCommand } = await import("./commands/bind.js");
115
- const { acceptedBind, resultFromMutationCall } = await import("./accepted.js");
116
- return resultFromMutationCall("bind", () => bindFromCommand({ command: parsed, repo, ...(actor === undefined ? {} : { actor }), hooks }), (accepted) => {
117
- const bound = accepted.facts.find((fact) => fact.kind === "bind");
118
- if (bound === undefined || bound.kind !== "bind")
119
- throw new Error("accepted bind is missing its bind fact");
120
- return acceptedBind(accepted, bound.data.coordinates);
121
- });
122
- }
123
- const markdown = await edge.readStdin();
124
- const gates = await selectedGates(configuration, parsed.gates);
125
- const actor = actorFromEdge(parsed.actor, edge.environment);
126
- const { bindFromCommand } = await import("./commands/bind.js");
127
- const { acceptedBind, resultFromMutationCall } = await import("./accepted.js");
128
- try {
129
- const result = await resultFromMutationCall("bind", () => bindFromCommand({
130
- command: parsed,
131
- repo,
132
- markdown,
133
- gates,
134
- ...(actor === undefined ? {} : { actor }),
135
- hooks,
136
- }), (accepted) => {
137
- const bound = accepted.facts.find((fact) => fact.kind === "bind");
138
- if (bound === undefined || bound.kind !== "bind")
139
- throw new Error("accepted bind is missing its bind fact");
140
- return acceptedBind(accepted, bound.data.coordinates);
141
- });
142
- if (result.kind !== "refused")
143
- return result;
144
- return { ...result, draft: await bindDraftReceipt(establishWorld, markdown) };
145
- }
146
- catch (error) {
147
- if (!(error instanceof TypeError))
148
- throw error;
149
- const { BindDraftError } = await import("./draft.js");
150
- throw new BindDraftError(error, await bindDraftReceipt(establishWorld, markdown));
151
- }
152
- }
153
- function deliverRefusal(refusal) {
154
- if (typeof refusal !== "object" || refusal === null || !("kind" in refusal) || refusal.kind !== "dirty-workspace") {
155
- return refusal;
156
- }
157
- const submodules = "submodules" in refusal && Array.isArray(refusal.submodules) ? refusal.submodules : [];
158
- return { ...refusal, option: { flag: "--include-dirty", available: submodules.length === 0 } };
159
- }
160
- async function invokeDeliver(parsed, seat, requireBranchesToBeUpToDate) {
161
- const { acceptedDeliver } = await import("./accepted.js");
162
- try {
163
- const delivered = await seat.contract.deliver({
164
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
165
- ...(parsed.message === undefined ? {} : { message: parsed.message }),
166
- requireBranchesToBeUpToDate,
167
- includeDirty: parsed.includeDirty,
168
- materializeConflict: parsed.materializeConflict,
169
- hooks: seat.hooks,
170
- });
171
- if (!("facts" in delivered))
172
- return delivered;
173
- return acceptedDeliver(delivered, seat.id);
174
- }
175
- catch (error) {
176
- const { KeiyakuRefused, KeiyakuRetry } = await import("../library/keiyaku.js");
177
- if (error instanceof KeiyakuRefused) {
178
- return { kind: "refused", verb: "deliver", contract: seat.id, refusal: deliverRefusal(error.refusal) };
179
- }
180
- if (error instanceof KeiyakuRetry) {
181
- return { kind: "retry", verb: "deliver", contract: seat.id, detail: error.reason };
182
- }
183
- throw error;
184
- }
185
- }
186
- async function invokeReview(parsed, seat, readStdin) {
187
- const summary = parsed.summaryFromStdin === true ? await readStdin() : parsed.summary;
188
- const { acceptedReview, resultFromMutationCall } = await import("./accepted.js");
189
- return resultFromMutationCall("review", () => seat.contract.review({
190
- verdict: parsed.verdict,
191
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
192
- ...(summary === undefined ? {} : { summary }),
193
- hooks: seat.hooks,
194
- }), (result) => acceptedReview(result, seat.id), { coordinate: seat.id });
195
- }
196
- async function invokeAudit(parsed, seat, requireBranchesToBeUpToDate) {
197
- const { acceptedAudit, resultFromMutationCall } = await import("./accepted.js");
198
- return resultFromMutationCall("audit", () => seat.contract.audit({
199
- ...(seat.actor === undefined ? {} : { actor: seat.actor }),
200
- includeDirty: parsed.includeDirty,
201
- showDiff: parsed.showDiff,
202
- requireBranchesToBeUpToDate,
203
- hooks: seat.hooks,
204
- }), (result) => acceptedAudit(result, seat.id), { coordinate: seat.id });
205
- }
206
- async function existingSeat({ parsed, repo, edge, scope, hooks, }) {
207
- const { id, contract } = await selectContract(repo, parsed.contract, scope);
208
- const actor = actorFromEdge(parsed.actor, edge.environment);
209
- return { contract, id, ...(actor === undefined ? {} : { actor }), hooks };
210
- }
211
- async function invokeExisting(input) {
212
- const { parsed, repo, edge, configuration, hooks } = input;
213
- const seat = await existingSeat(input);
214
- const { id, contract, actor } = seat;
215
- switch (parsed.command) {
216
- case "amend": {
217
- const markdown = parsed.stdin === true ? await edge.readStdin() : undefined;
218
- const gates = parsed.gates === undefined ? undefined : await selectedGates(configuration, parsed.gates);
219
- const { amendFromCommand } = await import("./commands/amend.js");
220
- const { acceptedAmend, resultFromMutationCall } = await import("./accepted.js");
221
- return resultFromMutationCall("amend", () => amendFromCommand({
222
- command: parsed,
223
- repo,
224
- contract,
225
- ...(markdown === undefined ? {} : { markdown }),
226
- gates,
227
- ...(actor === undefined ? {} : { actor }),
228
- hooks,
229
- }), (result) => acceptedAmend(result, id), { coordinate: id });
230
- }
231
- case "deliver":
232
- return invokeDeliver(parsed, seat, await selectedGitPolicy(configuration));
233
- case "review":
234
- return invokeReview(parsed, seat, edge.readStdin);
235
- case "arc": {
236
- const markdown = await edge.readStdin();
237
- const { acceptedArc, resultFromMutationCall } = await import("./accepted.js");
238
- return resultFromMutationCall("arc", () => contract.arc({
239
- markdown,
240
- ...(actor === undefined ? {} : { actor }),
241
- hooks,
242
- }), (result) => acceptedArc(result, id), { coordinate: id });
243
- }
244
- case "abandon": {
245
- const { acceptedAbandon, resultFromMutationCall } = await import("./accepted.js");
246
- return resultFromMutationCall("abandon", () => contract.abandon({
247
- ...(actor === undefined ? {} : { actor }),
248
- ...(parsed.note === undefined ? {} : { note: parsed.note }),
249
- hooks,
250
- }), (result) => acceptedAbandon(result, id), { coordinate: id });
251
- }
252
- case "audit":
253
- return invokeAudit(parsed, seat, await selectedGitPolicy(configuration));
254
- default:
255
- return parsed;
256
- }
257
- }
258
95
  async function invokeAkumaFromEdge(parsed, input) {
259
96
  try {
260
97
  const { statedCwd, repo, edge } = input;
@@ -433,6 +270,18 @@ async function invokeContractHistory(repo, contract) {
433
270
  throw error;
434
271
  }
435
272
  }
273
+ async function invokeForwardedContractMutation(parsed, repo, edge, scope, establishWorld) {
274
+ const { EMPTY_WORKTREE_HOOKS } = await import("../library/configuration.js");
275
+ return invokeContractMutation({
276
+ parsed,
277
+ repo,
278
+ edge,
279
+ scope,
280
+ hooks: EMPTY_WORKTREE_HOOKS,
281
+ establishWorld,
282
+ forwarded: true,
283
+ });
284
+ }
436
285
  async function resolveInvocationCoordinates(invocation, runtime) {
437
286
  const environment = runtime.environment ?? process.env, gitPath = gitPathFromEdge(environment);
438
287
  const { resolveCliCoordinates } = await import("./coordinates.js");
@@ -493,11 +342,7 @@ async function invokeParsed(invocation, runtime) {
493
342
  const scope = cwd;
494
343
  if ((parsed.command === "deliver" || parsed.command === "review") &&
495
344
  (await import("../akuma/requests.js")).injectedBodyRequests() !== null) {
496
- const { EMPTY_WORKTREE_HOOKS } = await import("../library/configuration.js");
497
- const seat = await existingSeat({ parsed, repo, edge, scope, hooks: EMPTY_WORKTREE_HOOKS });
498
- return parsed.command === "deliver"
499
- ? await invokeDeliver(parsed, seat, false)
500
- : await invokeReview(parsed, seat, edge.readStdin);
345
+ return invokeForwardedContractMutation(parsed, repo, edge, scope, establishWorld);
501
346
  }
502
347
  const configuration = await settingsAt(world ?? undefined, home);
503
348
  const { worktreeHooksFrom, SettingsError } = await import("../library/configuration.js");
@@ -506,27 +351,22 @@ async function invokeParsed(invocation, runtime) {
506
351
  const selected = await selectContract(repo, parsed.contract, scope);
507
352
  return { kind: "guidance", contract: selected.id, guidance: await selected.contract.guidance() };
508
353
  }
509
- switch (parsed.command) {
510
- case "reconcile": {
511
- if (parsed.contract === undefined) {
512
- return {
513
- kind: "observation",
514
- command: "reconcile",
515
- report: await repo.reconcile({ hooks, retryHooks: parsed.retryHooks }),
516
- };
517
- }
518
- const { contract } = await selectContract(repo, parsed.contract, scope);
354
+ if (parsed.command === "reconcile") {
355
+ if (parsed.contract === undefined) {
519
356
  return {
520
357
  kind: "observation",
521
358
  command: "reconcile",
522
- ...(await contract.reconcile({ hooks, retryHooks: parsed.retryHooks })),
359
+ report: await repo.reconcile({ hooks, retryHooks: parsed.retryHooks }),
523
360
  };
524
361
  }
525
- case "bind":
526
- return invokeBind({ parsed, repo, edge, configuration, hooks, establishWorld });
527
- default:
528
- return invokeExisting({ parsed, repo, edge, scope, configuration, hooks });
362
+ const { contract } = await selectContract(repo, parsed.contract, scope);
363
+ return {
364
+ kind: "observation",
365
+ command: "reconcile",
366
+ ...(await contract.reconcile({ hooks, retryHooks: parsed.retryHooks })),
367
+ };
529
368
  }
369
+ return invokeContractMutation({ parsed, repo, edge, scope, configuration, hooks, establishWorld });
530
370
  }
531
371
  function withResolvedTaskActor(command, runtime) {
532
372
  if (command.command !== "task" || (command.action !== "add" && command.action !== "compose"))
@@ -3,9 +3,9 @@ import { type AkumaAction, type ParsedAkumaCommand } from "./commands/akuma.js";
3
3
  import { type ParsedInstallCommand } from "./commands/install.js";
4
4
  import { type ContractCommand as Command, type ParsedAbandon, type ParsedAmend, type ParsedArc, type ParsedAudit, type ParsedBind, type ParsedDeliver, type ParsedLs, type ParsedNuke, type ParsedReconcile, type ParsedRegion, type ParsedReview, type ParsedSettings, type ParsedShow, type ParsedStatus } from "./commands/contract.js";
5
5
  export { CliUsageError } from "./usage.js";
6
+ export { renderContractHelp } from "./commands/contract.js";
6
7
  export type { Command };
7
8
  export declare function renderRootHelp(): string;
8
- export declare function renderContractHelp(command: Command): string;
9
9
  export declare function renderCommandUsage(command: ParsedCommand): string;
10
10
  export declare function renderHelp(coordinate: CliHelpCoordinate): string;
11
11
  export type ParsedCommand = ParsedBind | ParsedAmend | ParsedDeliver | ParsedReview | ParsedArc | ParsedAbandon | ParsedStatus | ParsedShow | ParsedLs | ParsedAudit | ParsedReconcile | ParsedNuke | ParsedSettings | ParsedRegion | ParsedInstallCommand | ParsedAkumaCommand | ParsedTaskCommand;