@astrosheep/keiyaku 4.1.1 → 4.1.3

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 (75) 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 +7 -3
  17. package/build/src/akuma/heart/index.d.ts +1 -1
  18. package/build/src/akuma/heart/index.js +1 -1
  19. package/build/src/akuma/heart/schema.d.ts +1 -0
  20. package/build/src/akuma/heart/schema.js +9 -0
  21. package/build/src/akuma/heart/storage.d.ts +1 -0
  22. package/build/src/akuma/heart/storage.js +18 -1
  23. package/build/src/akuma/nuke.js +6 -2
  24. package/build/src/akuma/projection-read.d.ts +17 -0
  25. package/build/src/akuma/projection-read.js +135 -0
  26. package/build/src/akuma/projection.d.ts +1 -18
  27. package/build/src/akuma/projection.js +21 -155
  28. package/build/src/akuma/providers/claude/index.js +101 -89
  29. package/build/src/akuma/providers/codex-app-server/index.js +9 -6
  30. package/build/src/akuma/providers/opencode-sdk/index.js +22 -15
  31. package/build/src/akuma/providers/pi/index.js +45 -43
  32. package/build/src/akuma/publication.d.ts +2 -1
  33. package/build/src/akuma/publication.js +72 -11
  34. package/build/src/akuma/request-execution.d.ts +8 -0
  35. package/build/src/akuma/request-execution.js +98 -0
  36. package/build/src/akuma/request-serve.d.ts +14 -2
  37. package/build/src/akuma/request-serve.js +3 -103
  38. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +4 -26
  39. package/build/src/akuma/{body-turn.js → turn-drive.js} +14 -100
  40. package/build/src/cli/commands/akuma.d.ts +0 -6
  41. package/build/src/cli/commands/akuma.js +1 -11
  42. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  43. package/build/src/cli/commands/contract-invoke.js +193 -0
  44. package/build/src/cli/commands/contract.d.ts +12 -0
  45. package/build/src/cli/commands/contract.js +229 -0
  46. package/build/src/cli/invoke.js +24 -184
  47. package/build/src/cli/parse.d.ts +1 -1
  48. package/build/src/cli/parse.js +8 -222
  49. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  50. package/build/src/cli/render/akuma-activity.js +362 -0
  51. package/build/src/cli/render/akuma.d.ts +1 -1
  52. package/build/src/cli/render/akuma.js +14 -371
  53. package/build/src/cli/render/contract-history.d.ts +2 -0
  54. package/build/src/cli/render/contract-history.js +83 -0
  55. package/build/src/cli/render/contract.d.ts +1 -2
  56. package/build/src/cli/render/contract.js +1 -83
  57. package/build/src/git/read-observation.js +15 -10
  58. package/build/src/git/reconcile.d.ts +8 -1
  59. package/build/src/git/reconcile.js +13 -301
  60. package/build/src/git/scratch.d.ts +8 -5
  61. package/build/src/git/scratch.js +29 -2
  62. package/build/src/git/terminal-reconcile.d.ts +21 -0
  63. package/build/src/git/terminal-reconcile.js +278 -0
  64. package/build/src/kanshi/read.js +32 -27
  65. package/build/src/library/contract-bind.d.ts +26 -0
  66. package/build/src/library/contract-bind.js +106 -0
  67. package/build/src/library/contract-operations.d.ts +77 -0
  68. package/build/src/library/contract-operations.js +130 -0
  69. package/build/src/library/contract-types.d.ts +95 -0
  70. package/build/src/library/contract-types.js +1 -0
  71. package/build/src/library/contract.d.ts +11 -136
  72. package/build/src/library/contract.js +9 -222
  73. package/build/src/library/fleet.js +2 -1
  74. package/build/src/runtime/proc/windows-launch.exe +0 -0
  75. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ import { resolveActor } from "../actor.js";
2
+ import { CliUsageError } from "../usage.js";
3
+ function actorFromEdge(actor, environment) {
4
+ try {
5
+ return resolveActor({ env: environment, ...(actor === undefined ? {} : { actor }) });
6
+ }
7
+ catch (error) {
8
+ throw new CliUsageError(error instanceof Error ? error.message : String(error));
9
+ }
10
+ }
11
+ function consumeSettings(run, ErrorType) {
12
+ try {
13
+ return run();
14
+ }
15
+ catch (error) {
16
+ if (error instanceof ErrorType)
17
+ throw new CliUsageError(error.message);
18
+ throw error;
19
+ }
20
+ }
21
+ async function selectedGates(value, names) {
22
+ const { gatesFrom, SettingsError } = await import("../../library/configuration.js");
23
+ return consumeSettings(() => gatesFrom({ settings: value, ...(names === undefined ? {} : { names }) }), SettingsError);
24
+ }
25
+ async function selectedGitPolicy(value) {
26
+ const { requireBranchesToBeUpToDateFrom, SettingsError } = await import("../../library/configuration.js");
27
+ return consumeSettings(() => requireBranchesToBeUpToDateFrom({ settings: value }), SettingsError);
28
+ }
29
+ async function selectContract(repo, selector, scope) {
30
+ const { contractFromInput, resolveContextualContract } = await import("../selectors.js");
31
+ if (selector !== undefined && !selector.startsWith("@"))
32
+ return contractFromInput(repo, selector);
33
+ const { Keiyaku } = await import("../../library/keiyaku.js");
34
+ const id = resolveContextualContract(await Keiyaku.list({ repo }), selector, scope);
35
+ return contractFromInput(repo, id);
36
+ }
37
+ async function bindDraftReceipt(establishWorld, markdown) {
38
+ const { preserveBindDraft } = await import("../draft.js");
39
+ try {
40
+ return preserveBindDraft(await establishWorld(), markdown);
41
+ }
42
+ catch (error) {
43
+ return { warning: `bind draft could not be preserved: ${error instanceof Error ? error.message : String(error)}` };
44
+ }
45
+ }
46
+ async function invokeBind(input) {
47
+ const { parsed, repo, edge, configuration, hooks, establishWorld } = input;
48
+ if (parsed.command !== "bind")
49
+ throw new Error("bind invocation requires bind syntax");
50
+ const actor = actorFromEdge(parsed.actor, edge.environment);
51
+ const { bindFromCommand } = await import("./bind.js");
52
+ const { acceptedBind, resultFromMutationCall } = await import("../accepted.js");
53
+ if (parsed.forkOf !== undefined) {
54
+ return resultFromMutationCall("bind", () => bindFromCommand({ command: parsed, repo, ...(actor === undefined ? {} : { actor }), hooks }), (accepted) => {
55
+ const bound = accepted.facts.find((fact) => fact.kind === "bind");
56
+ if (bound === undefined || bound.kind !== "bind")
57
+ throw new Error("accepted bind is missing its bind fact");
58
+ return acceptedBind(accepted, bound.data.coordinates);
59
+ });
60
+ }
61
+ if (configuration === undefined)
62
+ throw new Error("bind invocation requires Settings");
63
+ const markdown = await edge.readStdin();
64
+ const gates = await selectedGates(configuration, parsed.gates);
65
+ try {
66
+ const result = await resultFromMutationCall("bind", () => bindFromCommand({
67
+ command: parsed,
68
+ repo,
69
+ markdown,
70
+ gates,
71
+ ...(actor === undefined ? {} : { actor }),
72
+ hooks,
73
+ }), (accepted) => {
74
+ const bound = accepted.facts.find((fact) => fact.kind === "bind");
75
+ if (bound === undefined || bound.kind !== "bind")
76
+ throw new Error("accepted bind is missing its bind fact");
77
+ return acceptedBind(accepted, bound.data.coordinates);
78
+ });
79
+ if (result.kind !== "refused")
80
+ return result;
81
+ return { ...result, draft: await bindDraftReceipt(establishWorld, markdown) };
82
+ }
83
+ catch (error) {
84
+ if (!(error instanceof TypeError))
85
+ throw error;
86
+ const { BindDraftError } = await import("../draft.js");
87
+ throw new BindDraftError(error, await bindDraftReceipt(establishWorld, markdown));
88
+ }
89
+ }
90
+ function deliverRefusal(refusal) {
91
+ if (typeof refusal !== "object" || refusal === null || !("kind" in refusal) || refusal.kind !== "dirty-workspace") {
92
+ return refusal;
93
+ }
94
+ const submodules = "submodules" in refusal && Array.isArray(refusal.submodules) ? refusal.submodules : [];
95
+ return { ...refusal, option: { flag: "--include-dirty", available: submodules.length === 0 } };
96
+ }
97
+ async function existingSeat(input, parsed) {
98
+ const { repo, edge, scope, hooks } = input;
99
+ const { id, contract } = await selectContract(repo, parsed.contract, scope);
100
+ const actor = actorFromEdge(parsed.actor, edge.environment);
101
+ return { contract, id, ...(actor === undefined ? {} : { actor }), hooks };
102
+ }
103
+ async function invokeDeliver(parsed, seat, requireBranchesToBeUpToDate) {
104
+ const { acceptedDeliver } = await import("../accepted.js");
105
+ try {
106
+ const delivered = await seat.contract.deliver({
107
+ ...(seat.actor === undefined ? {} : { actor: seat.actor }),
108
+ ...(parsed.message === undefined ? {} : { message: parsed.message }),
109
+ requireBranchesToBeUpToDate,
110
+ includeDirty: parsed.includeDirty,
111
+ materializeConflict: parsed.materializeConflict,
112
+ hooks: seat.hooks,
113
+ });
114
+ if (!("facts" in delivered))
115
+ return delivered;
116
+ return acceptedDeliver(delivered, seat.id);
117
+ }
118
+ catch (error) {
119
+ const { KeiyakuRefused, KeiyakuRetry } = await import("../../library/keiyaku.js");
120
+ if (error instanceof KeiyakuRefused) {
121
+ return { kind: "refused", verb: "deliver", contract: seat.id, refusal: deliverRefusal(error.refusal) };
122
+ }
123
+ if (error instanceof KeiyakuRetry)
124
+ return { kind: "retry", verb: "deliver", contract: seat.id, detail: error.reason };
125
+ throw error;
126
+ }
127
+ }
128
+ async function invokeReview(parsed, seat, readStdin) {
129
+ const summary = parsed.summaryFromStdin === true ? await readStdin() : parsed.summary;
130
+ const { acceptedReview, resultFromMutationCall } = await import("../accepted.js");
131
+ return resultFromMutationCall("review", () => seat.contract.review({
132
+ verdict: parsed.verdict,
133
+ ...(seat.actor === undefined ? {} : { actor: seat.actor }),
134
+ ...(summary === undefined ? {} : { summary }),
135
+ hooks: seat.hooks,
136
+ }), (result) => acceptedReview(result, seat.id), { coordinate: seat.id });
137
+ }
138
+ export async function invokeContractMutation(input) {
139
+ const { parsed, repo, edge, configuration, hooks, forwarded } = input;
140
+ if (parsed.command === "bind")
141
+ return invokeBind(input);
142
+ const seat = await existingSeat(input, parsed);
143
+ const { id, contract, actor } = seat;
144
+ switch (parsed.command) {
145
+ case "amend": {
146
+ if (configuration === undefined)
147
+ throw new Error("amend invocation requires Settings");
148
+ const markdown = parsed.stdin === true ? await edge.readStdin() : undefined;
149
+ const gates = parsed.gates === undefined ? undefined : await selectedGates(configuration, parsed.gates);
150
+ const { amendFromCommand } = await import("./amend.js");
151
+ const { acceptedAmend, resultFromMutationCall } = await import("../accepted.js");
152
+ return resultFromMutationCall("amend", () => amendFromCommand({
153
+ command: parsed,
154
+ repo,
155
+ contract,
156
+ ...(markdown === undefined ? {} : { markdown }),
157
+ gates,
158
+ ...(actor === undefined ? {} : { actor }),
159
+ hooks,
160
+ }), (result) => acceptedAmend(result, id), { coordinate: id });
161
+ }
162
+ case "deliver":
163
+ return invokeDeliver(parsed, seat, forwarded === true ? false : await selectedGitPolicy(configuration));
164
+ case "review":
165
+ return invokeReview(parsed, seat, edge.readStdin);
166
+ case "arc": {
167
+ const markdown = await edge.readStdin();
168
+ const { acceptedArc, resultFromMutationCall } = await import("../accepted.js");
169
+ return resultFromMutationCall("arc", () => contract.arc({ markdown, ...(actor === undefined ? {} : { actor }), hooks }), (result) => acceptedArc(result, id), { coordinate: id });
170
+ }
171
+ case "abandon": {
172
+ const { acceptedAbandon, resultFromMutationCall } = await import("../accepted.js");
173
+ return resultFromMutationCall("abandon", () => contract.abandon({
174
+ ...(actor === undefined ? {} : { actor }),
175
+ ...(parsed.note === undefined ? {} : { note: parsed.note }),
176
+ hooks,
177
+ }), (result) => acceptedAbandon(result, id), { coordinate: id });
178
+ }
179
+ case "audit": {
180
+ if (configuration === undefined)
181
+ throw new Error("audit invocation requires Settings");
182
+ const requireBranchesToBeUpToDate = await selectedGitPolicy(configuration);
183
+ const { acceptedAudit, resultFromMutationCall } = await import("../accepted.js");
184
+ return resultFromMutationCall("audit", () => contract.audit({
185
+ ...(actor === undefined ? {} : { actor }),
186
+ includeDirty: parsed.includeDirty,
187
+ showDiff: parsed.showDiff,
188
+ requireBranchesToBeUpToDate,
189
+ hooks,
190
+ }), (result) => acceptedAudit(result, id), { coordinate: id });
191
+ }
192
+ }
193
+ }
@@ -252,4 +252,16 @@ export declare const CONTRACT_COMMAND_SPECS: {
252
252
  };
253
253
  };
254
254
  export type ContractCommand = keyof typeof CONTRACT_COMMAND_SPECS;
255
+ export type ParsedContractParts = Readonly<{
256
+ command: ContractCommand;
257
+ flags: Readonly<Record<string, string | true | readonly string[]>>;
258
+ positionals: readonly string[];
259
+ stdin: boolean;
260
+ output: "text" | "json";
261
+ actor?: string;
262
+ }>;
263
+ export type ParsedContractCommand = ParsedBind | ParsedAmend | ParsedDeliver | ParsedReview | ParsedArc | ParsedAbandon | ParsedStatus | ParsedShow | ParsedLs | ParsedAudit | ParsedReconcile | ParsedNuke | ParsedSettings | ParsedRegion;
264
+ export declare function renderContractHelp(command: ContractCommand): string;
265
+ export declare function renderContractUsage(command: ContractCommand): string;
266
+ export declare function parseContractCommand(parts: ParsedContractParts): ParsedContractCommand;
255
267
  export {};
@@ -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
+ }