@astrosheep/keiyaku 4.0.4 → 4.0.6
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.
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +4 -4
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +15 -7
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +5 -3
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +24 -4
- package/build/src/akuma/akuma.d.ts +2 -1
- package/build/src/akuma/akuma.js +27 -9
- package/build/src/akuma/allowed.d.ts +1 -1
- package/build/src/akuma/allowed.js +3 -10
- package/build/src/akuma/archetype.d.ts +3 -1
- package/build/src/akuma/archetype.js +11 -6
- package/build/src/akuma/body-turn.d.ts +64 -0
- package/build/src/akuma/body-turn.js +449 -0
- package/build/src/akuma/body.d.ts +4 -5
- package/build/src/akuma/body.js +9 -414
- package/build/src/akuma/heart/facts.d.ts +37 -9
- package/build/src/akuma/heart/facts.js +3 -1
- package/build/src/akuma/heart/index.d.ts +4 -13
- package/build/src/akuma/heart/index.js +14 -135
- package/build/src/akuma/heart/request-authority.d.ts +12 -0
- package/build/src/akuma/heart/request-authority.js +119 -0
- package/build/src/akuma/heart/request-rows.d.ts +16 -0
- package/build/src/akuma/heart/request-rows.js +88 -0
- package/build/src/akuma/heart/rows.d.ts +1 -28
- package/build/src/akuma/heart/rows.js +4 -138
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +11 -3
- package/build/src/akuma/heart/soul.js +0 -36
- package/build/src/akuma/heart/timeline.d.ts +1 -0
- package/build/src/akuma/heart/timeline.js +19 -0
- package/build/src/akuma/index.d.ts +1 -1
- package/build/src/akuma/nuke.d.ts +2 -0
- package/build/src/akuma/nuke.js +152 -0
- package/build/src/akuma/provider-recipe.js +1 -11
- package/build/src/akuma/provider.d.ts +4 -7
- package/build/src/akuma/providers/acp/config.d.ts +8 -0
- package/build/src/akuma/providers/acp/config.js +37 -0
- package/build/src/akuma/providers/acp/core.js +12 -2
- package/build/src/akuma/providers/acp/index.d.ts +1 -8
- package/build/src/akuma/providers/acp/index.js +2 -38
- package/build/src/akuma/providers/claude/index.d.ts +0 -4
- package/build/src/akuma/providers/claude/index.js +12 -3
- package/build/src/akuma/providers/codex-app-server/index.d.ts +2 -27
- package/build/src/akuma/providers/codex-app-server/index.js +5 -2
- package/build/src/akuma/providers/grok-build/index.js +1 -2
- package/build/src/akuma/providers/index.d.ts +3 -2
- package/build/src/akuma/providers/index.js +36 -36
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +2 -28
- package/build/src/akuma/providers/opencode-sdk/index.js +14 -4
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +2 -2
- package/build/src/akuma/providers/opencode-sdk/session.js +2 -2
- package/build/src/akuma/providers/pi/index.d.ts +1 -1
- package/build/src/akuma/providers/pi/index.js +29 -6
- package/build/src/akuma/request-serve.d.ts +88 -0
- package/build/src/akuma/request-serve.js +484 -0
- package/build/src/akuma/request-wire.d.ts +125 -0
- package/build/src/akuma/request-wire.js +383 -0
- package/build/src/akuma/requests.d.ts +28 -94
- package/build/src/akuma/requests.js +52 -562
- package/build/src/akuma-body.d.ts +7 -0
- package/build/src/akuma-body.js +69 -2
- package/build/src/alias/index.d.ts +1 -0
- package/build/src/alias/index.js +34 -1
- package/build/src/body/arc.js +4 -29
- package/build/src/body/decode.js +5 -39
- package/build/src/body/envelope.d.ts +7 -0
- package/build/src/body/envelope.js +37 -0
- package/build/src/cli/accepted.js +21 -9
- package/build/src/cli/commands/akuma-invoke.js +1 -0
- package/build/src/cli/commands/akuma.d.ts +1 -0
- package/build/src/cli/commands/akuma.js +13 -10
- package/build/src/cli/commands/contract.d.ts +28 -17
- package/build/src/cli/commands/contract.js +23 -17
- package/build/src/cli/commands/install.d.ts +2 -2
- package/build/src/cli/commands/install.js +6 -6
- package/build/src/cli/commands/nuke.d.ts +10 -0
- package/build/src/cli/commands/nuke.js +20 -0
- package/build/src/cli/commands/task-invoke.d.ts +15 -0
- package/build/src/cli/commands/task-invoke.js +144 -24
- package/build/src/cli/commands/task-query.d.ts +2 -2
- package/build/src/cli/commands/task-query.js +1 -2
- package/build/src/cli/commands/task.js +22 -22
- package/build/src/cli/coordinates.d.ts +6 -2
- package/build/src/cli/coordinates.js +12 -56
- package/build/src/cli/invoke.d.ts +5 -4
- package/build/src/cli/invoke.js +112 -58
- package/build/src/cli/main.d.ts +0 -2
- package/build/src/cli/main.js +4 -140
- package/build/src/cli/parse.d.ts +17 -4
- package/build/src/cli/parse.js +93 -15
- package/build/src/cli/render/akuma.js +111 -53
- package/build/src/cli/render/audit.js +2 -6
- package/build/src/cli/render/contract.js +61 -20
- package/build/src/cli/render/kanshi.js +15 -5
- package/build/src/cli/render/nuke.d.ts +3 -0
- package/build/src/cli/render/nuke.js +8 -0
- package/build/src/cli/render/receipt.js +28 -1
- package/build/src/cli/render/refusal.d.ts +2 -1
- package/build/src/cli/render/refusal.js +31 -0
- package/build/src/cli/render/terminal.d.ts +0 -2
- package/build/src/cli/render/terminal.js +0 -29
- package/build/src/cli/render/text.js +6 -1
- package/build/src/cli/result.d.ts +36 -9
- package/build/src/cli/runtime.d.ts +2 -0
- package/build/src/cli/runtime.js +140 -0
- package/build/src/cli/usage.d.ts +0 -2
- package/build/src/cli/usage.js +0 -4
- package/build/src/contract-worktree.d.ts +29 -14
- package/build/src/contract-worktree.js +131 -70
- package/build/src/core/facts/codec.js +9 -0
- package/build/src/core/facts/fold.js +13 -1
- package/build/src/core/facts/types.d.ts +8 -1
- package/build/src/core/subject.js +4 -3
- package/build/src/core/verbs/placement.d.ts +9 -1
- package/build/src/core/verbs/placement.js +24 -6
- package/build/src/core/verbs/reintegrate.d.ts +13 -0
- package/build/src/core/verbs/reintegrate.js +24 -0
- package/build/src/dispatch/index.d.ts +1 -1
- package/build/src/git/admission.d.ts +2 -1
- package/build/src/git/hooks.d.ts +2 -0
- package/build/src/git/hooks.js +34 -1
- package/build/src/git/integration.d.ts +9 -2
- package/build/src/git/integration.js +92 -1
- package/build/src/git/nuke.d.ts +2 -0
- package/build/src/git/nuke.js +97 -0
- package/build/src/git/observe.d.ts +2 -1
- package/build/src/git/observe.js +6 -5
- package/build/src/git/process.d.ts +28 -0
- package/build/src/git/process.js +94 -0
- package/build/src/git/read-observation.d.ts +2 -1
- package/build/src/git/read-observation.js +3 -2
- package/build/src/git/reconcile.d.ts +4 -1
- package/build/src/git/reconcile.js +42 -8
- package/build/src/git/repository.d.ts +2 -29
- package/build/src/git/repository.js +7 -118
- package/build/src/git/scratch.d.ts +1 -1
- package/build/src/git/scratch.js +1 -1
- package/build/src/git/target-placement.d.ts +3 -2
- package/build/src/git/target-placement.js +15 -14
- package/build/src/git/tender.d.ts +2 -1
- package/build/src/git/tender.js +4 -3
- package/build/src/git/terminal-seal.d.ts +2 -2
- package/build/src/git/terminal-seal.js +3 -6
- package/build/src/git/workspace.d.ts +4 -1
- package/build/src/git/workspace.js +1 -1
- package/build/src/index.d.ts +1 -2
- package/build/src/index.js +1 -1
- package/build/src/kanshi/read.js +5 -1
- package/build/src/library/address.js +7 -1
- package/build/src/library/akuma-creation.d.ts +1 -0
- package/build/src/library/akuma-creation.js +8 -1
- package/build/src/library/audit.d.ts +3 -1
- package/build/src/library/audit.js +2 -1
- package/build/src/library/bind.d.ts +2 -1
- package/build/src/library/bind.js +1 -1
- package/build/src/library/configuration.d.ts +1 -1
- package/build/src/library/configuration.js +52 -18
- package/build/src/library/contract.d.ts +59 -4
- package/build/src/library/contract.js +195 -34
- package/build/src/library/delivery.d.ts +4 -2
- package/build/src/library/fleet.d.ts +27 -7
- package/build/src/library/fleet.js +79 -39
- package/build/src/library/input.d.ts +0 -1
- package/build/src/library/input.js +0 -5
- package/build/src/library/keiyaku.d.ts +6 -2
- package/build/src/library/keiyaku.js +2 -0
- package/build/src/library/mutation.d.ts +3 -1
- package/build/src/library/mutation.js +3 -0
- package/build/src/library/nuke.d.ts +14 -0
- package/build/src/library/nuke.js +54 -0
- package/build/src/library/reconcile.d.ts +2 -1
- package/build/src/library/reconcile.js +8 -3
- package/build/src/library/refusal.d.ts +10 -1
- package/build/src/library/region.d.ts +1 -1
- package/build/src/library/repo.d.ts +4 -1
- package/build/src/library/repo.js +10 -4
- package/build/src/protocol/abandon.d.ts +9 -0
- package/build/src/protocol/abandon.js +15 -0
- package/build/src/protocol/amend.d.ts +16 -0
- package/build/src/protocol/amend.js +77 -0
- package/build/src/protocol/arc.d.ts +6 -0
- package/build/src/protocol/arc.js +12 -0
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/audit.d.ts +53 -0
- package/build/src/protocol/audit.js +147 -0
- package/build/src/protocol/bind.d.ts +1 -1
- package/build/src/protocol/completion.d.ts +42 -0
- package/build/src/protocol/completion.js +183 -0
- package/build/src/protocol/deliver.d.ts +49 -0
- package/build/src/protocol/deliver.js +261 -0
- package/build/src/protocol/intent.d.ts +2 -1
- package/build/src/protocol/intent.js +8 -2
- package/build/src/protocol/operations.d.ts +93 -202
- package/build/src/protocol/operations.js +23 -642
- package/build/src/protocol/placement.d.ts +12 -13
- package/build/src/protocol/placement.js +8 -19
- package/build/src/protocol/read/status.d.ts +17 -5
- package/build/src/protocol/read/status.js +57 -13
- package/build/src/protocol/reconcile.d.ts +35 -0
- package/build/src/protocol/reconcile.js +41 -0
- package/build/src/protocol/reintegrate.d.ts +31 -0
- package/build/src/protocol/reintegrate.js +74 -0
- package/build/src/protocol/review.d.ts +34 -0
- package/build/src/protocol/review.js +156 -0
- package/build/src/protocol/run.d.ts +1 -1
- package/build/src/runtime/proc/run.js +9 -5
- package/build/src/settlement/fence.d.ts +3 -1
- package/build/src/settlement/fence.js +24 -0
- package/build/src/settlement/holder.d.ts +1 -1
- package/build/src/settlement/settle.d.ts +1 -1
- package/build/src/settlement/settle.js +1 -2
- package/build/src/task/board.d.ts +0 -1
- package/build/src/task/board.js +0 -3
- package/build/src/task/compose.d.ts +2 -2
- package/build/src/task/compose.js +13 -11
- package/build/src/task/context.d.ts +14 -2
- package/build/src/task/context.js +30 -7
- package/build/src/task/index.d.ts +7 -6
- package/build/src/task/index.js +17 -145
- package/build/src/task/input.d.ts +18 -0
- package/build/src/task/input.js +189 -0
- package/build/src/task/mutation.d.ts +44 -0
- package/build/src/task/mutation.js +93 -0
- package/build/src/task/operations.d.ts +14 -6
- package/build/src/task/operations.js +57 -57
- package/build/src/task/store.d.ts +1 -0
- package/build/src/task/store.js +91 -3
- package/build/src/verification/execution.d.ts +1 -1
- package/build/src/workspace-place.d.ts +3 -4
- package/build/src/workspace-place.js +26 -15
- package/package.json +3 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { type TaskInvocationResult } from "./commands/task-invoke.js";
|
|
1
|
+
import type { AkumaInvocationResult } from "./commands/akuma-invoke.js";
|
|
2
|
+
import type { InstallInvocationResult } from "./commands/install.js";
|
|
3
|
+
import type { TaskInvocationResult } from "./commands/task-invoke.js";
|
|
5
4
|
import { type ParsedExecution } from "./parse.js";
|
|
6
5
|
import type { InvocationResult } from "./result.js";
|
|
6
|
+
import type { ActorId, ContractId } from "../index.js";
|
|
7
|
+
import type { Settings } from "../settings.js";
|
|
7
8
|
export type { AcceptedFact, InvocationResult, Lag } from "./result.js";
|
|
8
9
|
type InvokeRuntime = Readonly<{
|
|
9
10
|
cwd?: string;
|
package/build/src/cli/invoke.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { AkumaWorldScopeError, gatesFrom, Keiyaku, KeiyakuRefused, requireBranchesToBeUpToDateFrom, settings, SettingsError, worktreeHooksFrom, } from "../index.js";
|
|
2
|
-
import { kanshi, observeKanshi, selectKanshi, selectRegion, } from "../kanshi/index.js";
|
|
3
1
|
import { resolveActor } from "./actor.js";
|
|
4
|
-
import { acceptedAbandon, acceptedAmend, acceptedArc, acceptedAudit, acceptedBind, acceptedDeliver, acceptedReview, resultFromMutationCall, } from "./accepted.js";
|
|
5
|
-
import { amendFromCommand } from "./commands/amend.js";
|
|
6
|
-
import { invokeAkuma, invokeAkumaStatus } from "./commands/akuma-invoke.js";
|
|
7
2
|
import { isParsedAkumaCommand } from "./commands/akuma.js";
|
|
8
|
-
import {
|
|
9
|
-
import { installHarnesses } from "./commands/install.js";
|
|
10
|
-
import { invokeTask } from "./commands/task-invoke.js";
|
|
11
|
-
import { CliUsageError, renderCommandUsage } from "./parse.js";
|
|
3
|
+
import { assertExplicitRepoUse, CliUsageError, renderCommandUsage, } from "./parse.js";
|
|
12
4
|
import { isBlankInput } from "./usage.js";
|
|
13
|
-
import { canonicalContractSelector, contractFromInput, resolveContextualContract, resolveKanshiContract, } from "./selectors.js";
|
|
14
|
-
import { resolveNamedAddress } from "../library/address.js";
|
|
15
|
-
import { assertExplicitRepoUse, resolveCliCoordinates } from "./coordinates.js";
|
|
16
|
-
import { BindDraftError, preserveBindDraft } from "./draft.js";
|
|
17
5
|
async function readStdin() {
|
|
18
6
|
const chunks = [];
|
|
19
7
|
for await (const chunk of process.stdin)
|
|
@@ -54,24 +42,27 @@ async function withAcquiredStdin(command, runtime) {
|
|
|
54
42
|
throw new CliUsageError(diagnostic);
|
|
55
43
|
return { ...runtime, readStdin: async () => bytes };
|
|
56
44
|
}
|
|
57
|
-
function settingsAt(root, home) {
|
|
45
|
+
async function settingsAt(root, home) {
|
|
46
|
+
const { settings } = await import("../settings.js");
|
|
58
47
|
return settings({ ...(root === undefined ? {} : { root }), ...(home === undefined ? {} : { home }) });
|
|
59
48
|
}
|
|
60
|
-
function consumeSettings(run) {
|
|
49
|
+
function consumeSettings(run, ErrorType) {
|
|
61
50
|
try {
|
|
62
51
|
return run();
|
|
63
52
|
}
|
|
64
53
|
catch (error) {
|
|
65
|
-
if (error instanceof
|
|
54
|
+
if (error instanceof ErrorType)
|
|
66
55
|
throw new CliUsageError(error.message);
|
|
67
56
|
throw error;
|
|
68
57
|
}
|
|
69
58
|
}
|
|
70
|
-
function selectedGates(value,
|
|
71
|
-
|
|
59
|
+
async function selectedGates(value, names) {
|
|
60
|
+
const { gatesFrom, SettingsError } = await import("../library/configuration.js");
|
|
61
|
+
return consumeSettings(() => gatesFrom({ settings: value, ...(names === undefined ? {} : { names }) }), SettingsError);
|
|
72
62
|
}
|
|
73
|
-
function selectedGitPolicy(value) {
|
|
74
|
-
|
|
63
|
+
async function selectedGitPolicy(value) {
|
|
64
|
+
const { requireBranchesToBeUpToDateFrom, SettingsError } = await import("../library/configuration.js");
|
|
65
|
+
return consumeSettings(() => requireBranchesToBeUpToDateFrom({ settings: value }), SettingsError);
|
|
75
66
|
}
|
|
76
67
|
function actorFromEdge(actor, environment) {
|
|
77
68
|
let resolved;
|
|
@@ -83,13 +74,24 @@ function actorFromEdge(actor, environment) {
|
|
|
83
74
|
}
|
|
84
75
|
return resolved;
|
|
85
76
|
}
|
|
77
|
+
function gitPathFromEdge(environment) {
|
|
78
|
+
const value = environment.KEIYAKU_GIT_PATH;
|
|
79
|
+
if (value === undefined)
|
|
80
|
+
return undefined;
|
|
81
|
+
if (value.trim().length === 0)
|
|
82
|
+
throw new CliUsageError("KEIYAKU_GIT_PATH requires a nonblank value");
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
86
85
|
async function selectContract(repo, selector, scope) {
|
|
86
|
+
const { contractFromInput, resolveContextualContract } = await import("./selectors.js");
|
|
87
87
|
if (selector !== undefined && !selector.startsWith("@"))
|
|
88
88
|
return contractFromInput(repo, selector);
|
|
89
|
+
const { Keiyaku } = await import("../library/keiyaku.js");
|
|
89
90
|
const id = resolveContextualContract(await Keiyaku.list({ repo }), selector, scope);
|
|
90
91
|
return contractFromInput(repo, id);
|
|
91
92
|
}
|
|
92
93
|
async function bindDraftReceipt(establishWorld, markdown) {
|
|
94
|
+
const { preserveBindDraft } = await import("./draft.js");
|
|
93
95
|
try {
|
|
94
96
|
return preserveBindDraft(await establishWorld(), markdown);
|
|
95
97
|
}
|
|
@@ -99,8 +101,10 @@ async function bindDraftReceipt(establishWorld, markdown) {
|
|
|
99
101
|
}
|
|
100
102
|
async function invokeBind({ parsed, repo, edge, configuration, hooks, establishWorld }) {
|
|
101
103
|
const markdown = await edge.readStdin();
|
|
102
|
-
const gates = selectedGates(configuration, parsed.gates);
|
|
104
|
+
const gates = await selectedGates(configuration, parsed.gates);
|
|
103
105
|
const actor = actorFromEdge(parsed.actor, edge.environment);
|
|
106
|
+
const { bindFromCommand } = await import("./commands/bind.js");
|
|
107
|
+
const { acceptedBind, resultFromMutationCall } = await import("./accepted.js");
|
|
104
108
|
try {
|
|
105
109
|
const result = await resultFromMutationCall("bind", () => bindFromCommand({
|
|
106
110
|
command: parsed,
|
|
@@ -122,6 +126,7 @@ async function invokeBind({ parsed, repo, edge, configuration, hooks, establishW
|
|
|
122
126
|
catch (error) {
|
|
123
127
|
if (!(error instanceof TypeError))
|
|
124
128
|
throw error;
|
|
129
|
+
const { BindDraftError } = await import("./draft.js");
|
|
125
130
|
throw new BindDraftError(error, await bindDraftReceipt(establishWorld, markdown));
|
|
126
131
|
}
|
|
127
132
|
}
|
|
@@ -133,19 +138,34 @@ function deliverRefusal(refusal) {
|
|
|
133
138
|
return { ...refusal, option: { flag: "--include-dirty", available: submodules.length === 0 } };
|
|
134
139
|
}
|
|
135
140
|
async function invokeDeliver(parsed, seat, requireBranchesToBeUpToDate) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
const { acceptedDeliver } = await import("./accepted.js");
|
|
142
|
+
try {
|
|
143
|
+
const delivered = await seat.contract.deliver({
|
|
144
|
+
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
145
|
+
...(parsed.message === undefined ? {} : { message: parsed.message }),
|
|
146
|
+
requireBranchesToBeUpToDate,
|
|
147
|
+
includeDirty: parsed.includeDirty,
|
|
148
|
+
materializeConflict: parsed.materializeConflict,
|
|
149
|
+
hooks: seat.hooks,
|
|
150
|
+
});
|
|
151
|
+
if (!("facts" in delivered))
|
|
152
|
+
return delivered;
|
|
153
|
+
return acceptedDeliver(delivered, seat.id);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
const { KeiyakuRefused, KeiyakuRetry } = await import("../library/keiyaku.js");
|
|
157
|
+
if (error instanceof KeiyakuRefused) {
|
|
158
|
+
return { kind: "refused", verb: "deliver", contract: seat.id, refusal: deliverRefusal(error.refusal) };
|
|
159
|
+
}
|
|
160
|
+
if (error instanceof KeiyakuRetry) {
|
|
161
|
+
return { kind: "retry", verb: "deliver", contract: seat.id, detail: error.reason };
|
|
162
|
+
}
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
146
165
|
}
|
|
147
166
|
async function invokeReview(parsed, seat, readStdin) {
|
|
148
167
|
const summary = parsed.summaryFromStdin === true ? await readStdin() : parsed.summary;
|
|
168
|
+
const { acceptedReview, resultFromMutationCall } = await import("./accepted.js");
|
|
149
169
|
return resultFromMutationCall("review", () => seat.contract.review({
|
|
150
170
|
verdict: parsed.verdict,
|
|
151
171
|
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
@@ -154,6 +174,7 @@ async function invokeReview(parsed, seat, readStdin) {
|
|
|
154
174
|
}), (result) => acceptedReview(result, seat.id), { coordinate: seat.id });
|
|
155
175
|
}
|
|
156
176
|
async function invokeAudit(parsed, seat, requireBranchesToBeUpToDate) {
|
|
177
|
+
const { acceptedAudit, resultFromMutationCall } = await import("./accepted.js");
|
|
157
178
|
return resultFromMutationCall("audit", () => seat.contract.audit({
|
|
158
179
|
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
159
180
|
includeDirty: parsed.includeDirty,
|
|
@@ -162,16 +183,23 @@ async function invokeAudit(parsed, seat, requireBranchesToBeUpToDate) {
|
|
|
162
183
|
hooks: seat.hooks,
|
|
163
184
|
}), (result) => acceptedAudit(result, seat.id), { coordinate: seat.id });
|
|
164
185
|
}
|
|
165
|
-
async function
|
|
186
|
+
async function existingSeat({ parsed, repo, edge, scope, hooks }) {
|
|
166
187
|
const { id, contract } = await selectContract(repo, parsed.contract, scope);
|
|
167
188
|
const actor = actorFromEdge(parsed.actor, edge.environment);
|
|
168
|
-
|
|
189
|
+
return { contract, id, ...(actor === undefined ? {} : { actor }), hooks };
|
|
190
|
+
}
|
|
191
|
+
async function invokeExisting(input) {
|
|
192
|
+
const { parsed, repo, edge, configuration, hooks } = input;
|
|
193
|
+
const seat = await existingSeat(input);
|
|
194
|
+
const { id, contract, actor } = seat;
|
|
169
195
|
switch (parsed.command) {
|
|
170
196
|
case "amend": {
|
|
171
197
|
const markdown = parsed.stdin === true ? await edge.readStdin() : undefined;
|
|
172
198
|
const gates = parsed.gates === undefined
|
|
173
199
|
? undefined
|
|
174
|
-
: selectedGates(configuration, parsed.gates);
|
|
200
|
+
: await selectedGates(configuration, parsed.gates);
|
|
201
|
+
const { amendFromCommand } = await import("./commands/amend.js");
|
|
202
|
+
const { acceptedAmend, resultFromMutationCall } = await import("./accepted.js");
|
|
175
203
|
return resultFromMutationCall("amend", () => amendFromCommand({
|
|
176
204
|
command: parsed,
|
|
177
205
|
repo,
|
|
@@ -183,25 +211,28 @@ async function invokeExisting({ parsed, repo, edge, scope, configuration, hooks
|
|
|
183
211
|
}), (result) => acceptedAmend(result, id), { coordinate: id });
|
|
184
212
|
}
|
|
185
213
|
case "deliver":
|
|
186
|
-
return invokeDeliver(parsed, seat, selectedGitPolicy(configuration));
|
|
214
|
+
return invokeDeliver(parsed, seat, await selectedGitPolicy(configuration));
|
|
187
215
|
case "review":
|
|
188
216
|
return invokeReview(parsed, seat, edge.readStdin);
|
|
189
217
|
case "arc": {
|
|
190
218
|
const markdown = await edge.readStdin();
|
|
219
|
+
const { acceptedArc, resultFromMutationCall } = await import("./accepted.js");
|
|
191
220
|
return resultFromMutationCall("arc", () => contract.arc({
|
|
192
221
|
markdown,
|
|
193
222
|
...(actor === undefined ? {} : { actor }),
|
|
194
223
|
hooks,
|
|
195
224
|
}), (result) => acceptedArc(result, id), { coordinate: id });
|
|
196
225
|
}
|
|
197
|
-
case "abandon":
|
|
226
|
+
case "abandon": {
|
|
227
|
+
const { acceptedAbandon, resultFromMutationCall } = await import("./accepted.js");
|
|
198
228
|
return resultFromMutationCall("abandon", () => contract.abandon({
|
|
199
229
|
...(actor === undefined ? {} : { actor }),
|
|
200
230
|
...(parsed.note === undefined ? {} : { note: parsed.note }),
|
|
201
231
|
hooks,
|
|
202
232
|
}), (result) => acceptedAbandon(result, id), { coordinate: id });
|
|
233
|
+
}
|
|
203
234
|
case "audit":
|
|
204
|
-
return invokeAudit(parsed, seat, selectedGitPolicy(configuration));
|
|
235
|
+
return invokeAudit(parsed, seat, await selectedGitPolicy(configuration));
|
|
205
236
|
default:
|
|
206
237
|
return parsed;
|
|
207
238
|
}
|
|
@@ -212,18 +243,21 @@ async function invokeAkumaFromEdge(parsed, input) {
|
|
|
212
243
|
if (parsed.command === "call" && parsed.contract !== undefined && repo === undefined) {
|
|
213
244
|
throw new Error("call with Contract requires a resolved Repo");
|
|
214
245
|
}
|
|
246
|
+
const { invokeAkuma } = await import("./commands/akuma-invoke.js");
|
|
247
|
+
const contract = parsed.command === "call" && parsed.contract !== undefined
|
|
248
|
+
? (await import("./selectors.js")).contractFromInput(repo, parsed.contract).contract
|
|
249
|
+
: undefined;
|
|
215
250
|
return await invokeAkuma(parsed, {
|
|
216
251
|
path,
|
|
217
252
|
...(statedCwd === undefined ? {} : { statedCwd }),
|
|
218
253
|
...(home === undefined ? {} : { home }),
|
|
219
254
|
...(configuration === undefined ? {} : { settings: configuration }),
|
|
220
|
-
...(
|
|
221
|
-
? { contract: contractFromInput(repo, parsed.contract).contract }
|
|
222
|
-
: repo === undefined ? {} : { repo }),
|
|
255
|
+
...(contract === undefined ? repo === undefined ? {} : { repo } : { contract }),
|
|
223
256
|
readStdin: edge.readStdin,
|
|
224
257
|
});
|
|
225
258
|
}
|
|
226
259
|
catch (error) {
|
|
260
|
+
const { AkumaWorldScopeError } = await import("../library/address.js");
|
|
227
261
|
if (error instanceof AkumaWorldScopeError)
|
|
228
262
|
throw error;
|
|
229
263
|
if (error instanceof TypeError)
|
|
@@ -239,6 +273,7 @@ async function akumaWorldFor(parsed, located, candidate, establish) {
|
|
|
239
273
|
}
|
|
240
274
|
async function invokeCatalog(parsed, world, repo, home) {
|
|
241
275
|
try {
|
|
276
|
+
const { Keiyaku } = await import("../library/keiyaku.js");
|
|
242
277
|
if (parsed.query.kind === "contracts") {
|
|
243
278
|
if (repo === undefined)
|
|
244
279
|
throw new Error("Contract catalog requires a resolved Repo");
|
|
@@ -267,8 +302,9 @@ async function invokeStatus(parsed, world, repo) {
|
|
|
267
302
|
if (parsed.akuma === true) {
|
|
268
303
|
if (world === null)
|
|
269
304
|
throw new CliUsageError("no Keiyaku world contains the invocation cwd");
|
|
270
|
-
return invokeAkumaStatus(world, parsed.contract, undefined, repo);
|
|
305
|
+
return (await import("./commands/akuma-invoke.js")).invokeAkumaStatus(world, parsed.contract, undefined, repo);
|
|
271
306
|
}
|
|
307
|
+
const { kanshi, observeKanshi, selectKanshi } = await import("../kanshi/index.js");
|
|
272
308
|
if (parsed.contract === undefined) {
|
|
273
309
|
const report = await kanshi({ world, ...(repo === undefined ? {} : { repo }) });
|
|
274
310
|
return { kind: "status", report, selection: "world" };
|
|
@@ -276,6 +312,7 @@ async function invokeStatus(parsed, world, repo) {
|
|
|
276
312
|
if (parsed.contract.startsWith("@")) {
|
|
277
313
|
try {
|
|
278
314
|
const observation = await observeKanshi({ world, ...(repo === undefined ? {} : { repo }) });
|
|
315
|
+
const { resolveNamedAddress } = await import("../library/address.js");
|
|
279
316
|
const address = resolveNamedAddress({
|
|
280
317
|
selector: parsed.contract,
|
|
281
318
|
report: observation.report,
|
|
@@ -284,7 +321,7 @@ async function invokeStatus(parsed, world, repo) {
|
|
|
284
321
|
if (address.kind === "akuma") {
|
|
285
322
|
if (world === null)
|
|
286
323
|
throw new CliUsageError("no Keiyaku world contains the invocation cwd");
|
|
287
|
-
return invokeAkumaStatus(world, address.id, parsed.contract, repo);
|
|
324
|
+
return (await import("./commands/akuma-invoke.js")).invokeAkumaStatus(world, address.id, parsed.contract, repo);
|
|
288
325
|
}
|
|
289
326
|
return { kind: "status", report: selectKanshi({ report: observation.report, contract: address.id }), selection: "contract" };
|
|
290
327
|
}
|
|
@@ -297,6 +334,7 @@ async function invokeStatus(parsed, world, repo) {
|
|
|
297
334
|
if (parsed.contract.startsWith("kei/")) {
|
|
298
335
|
if (repo === undefined)
|
|
299
336
|
throw new CliUsageError("cannot select a contract while the Contract world is absent");
|
|
337
|
+
const { canonicalContractSelector } = await import("./selectors.js");
|
|
300
338
|
const contract = canonicalContractSelector(parsed.contract);
|
|
301
339
|
return {
|
|
302
340
|
kind: "status",
|
|
@@ -305,10 +343,12 @@ async function invokeStatus(parsed, world, repo) {
|
|
|
305
343
|
};
|
|
306
344
|
}
|
|
307
345
|
const report = await kanshi({ world, ...(repo === undefined ? {} : { repo }) });
|
|
346
|
+
const { resolveKanshiContract } = await import("./selectors.js");
|
|
308
347
|
const contract = resolveKanshiContract(report, parsed.contract);
|
|
309
348
|
return { kind: "status", report: selectKanshi({ report, contract }), selection: "contract" };
|
|
310
349
|
}
|
|
311
350
|
async function invokeRegion(parsed, world, repo) {
|
|
351
|
+
const { kanshi, selectRegion } = await import("../kanshi/index.js");
|
|
312
352
|
const read = async (region) => {
|
|
313
353
|
try {
|
|
314
354
|
return await kanshi({ world, repo, region });
|
|
@@ -327,6 +367,7 @@ async function invokeRegion(parsed, world, repo) {
|
|
|
327
367
|
return { kind: "region", region: report.region ?? { kind: "absent" } };
|
|
328
368
|
}
|
|
329
369
|
const report = await read({ kind: "declarations" });
|
|
370
|
+
const { resolveKanshiContract } = await import("./selectors.js");
|
|
330
371
|
const contract = resolveKanshiContract(report, parsed.contract);
|
|
331
372
|
if (report.contracts.kind !== "present" || report.contracts.value.rows.every((row) => row.id !== contract || row.disposition !== "active")) {
|
|
332
373
|
throw new CliUsageError(`unknown contract selector: ${parsed.contract}`);
|
|
@@ -340,6 +381,7 @@ async function invokeRegion(parsed, world, repo) {
|
|
|
340
381
|
async function invokeContractHistory(repo, contract) {
|
|
341
382
|
if (repo === undefined)
|
|
342
383
|
throw new Error("history kei/... requires a resolved Repo");
|
|
384
|
+
const { contractFromInput } = await import("./selectors.js");
|
|
343
385
|
const selected = contractFromInput(repo, contract);
|
|
344
386
|
try {
|
|
345
387
|
return { kind: "contract-history", history: await selected.contract.history() };
|
|
@@ -347,6 +389,7 @@ async function invokeContractHistory(repo, contract) {
|
|
|
347
389
|
catch (error) {
|
|
348
390
|
if (error instanceof TypeError)
|
|
349
391
|
throw new CliUsageError(error.message);
|
|
392
|
+
const { KeiyakuRefused } = await import("../library/keiyaku.js");
|
|
350
393
|
if (error instanceof KeiyakuRefused) {
|
|
351
394
|
return { kind: "refused", verb: "history", contract: selected.id, refusal: error.refusal };
|
|
352
395
|
}
|
|
@@ -355,13 +398,17 @@ async function invokeContractHistory(repo, contract) {
|
|
|
355
398
|
}
|
|
356
399
|
// eslint-disable-next-line complexity -- command dispatch keeps the CLI's existing boundary in one place.
|
|
357
400
|
async function invokeParsed(invocation, runtime) {
|
|
401
|
+
const environment = runtime.environment ?? process.env;
|
|
402
|
+
const gitPath = gitPathFromEdge(environment);
|
|
403
|
+
const { resolveCliCoordinates } = await import("./coordinates.js");
|
|
358
404
|
const coordinates = await resolveCliCoordinates({
|
|
359
405
|
...(runtime.cwd === undefined ? {} : { processCwd: runtime.cwd }),
|
|
360
406
|
...(invocation.cwd === undefined ? {} : { cwd: invocation.cwd }),
|
|
361
407
|
...(invocation.repo === undefined ? {} : { repo: invocation.repo }),
|
|
408
|
+
...(gitPath === undefined ? {} : { gitPath }),
|
|
362
409
|
command: invocation.command,
|
|
363
410
|
});
|
|
364
|
-
const { cwd, cwdSource, repo, world, candidateWorld, establishWorld } = coordinates;
|
|
411
|
+
const { cwd, cwdSource, repo, world, candidateWorld, establishWorld, taskContext } = coordinates;
|
|
365
412
|
const edge = {
|
|
366
413
|
environment: runtime.environment ?? process.env,
|
|
367
414
|
readStdin: runtime.readStdin ?? readStdin,
|
|
@@ -372,20 +419,19 @@ async function invokeParsed(invocation, runtime) {
|
|
|
372
419
|
if (parsed.command === "settings") {
|
|
373
420
|
return { kind: "settings", value: await settingsAt(world ?? undefined, home) };
|
|
374
421
|
}
|
|
422
|
+
if (parsed.command === "nuke") {
|
|
423
|
+
return await (await import("./commands/nuke.js")).invokeNuke(parsed, world);
|
|
424
|
+
}
|
|
375
425
|
if (parsed.command === "task") {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (error instanceof TypeError)
|
|
386
|
-
throw new CliUsageError(error.message);
|
|
387
|
-
throw error;
|
|
388
|
-
}
|
|
426
|
+
const actor = runtime.actor ?? actorFromEdge(typeof parsed.flags.actor === "string" ? parsed.flags.actor : undefined, edge.environment);
|
|
427
|
+
return await (await import("./commands/task-invoke.js")).invokeTaskFromEdge({
|
|
428
|
+
parsed,
|
|
429
|
+
world,
|
|
430
|
+
context: taskContext,
|
|
431
|
+
establish: coordinates.establishWorld,
|
|
432
|
+
readStdin: edge.readStdin,
|
|
433
|
+
actor,
|
|
434
|
+
});
|
|
389
435
|
}
|
|
390
436
|
if (parsed.command === "history" && "contract" in parsed)
|
|
391
437
|
return await invokeContractHistory(repo, parsed.contract);
|
|
@@ -410,8 +456,16 @@ async function invokeParsed(invocation, runtime) {
|
|
|
410
456
|
if (parsed.command === "region")
|
|
411
457
|
return invokeRegion(parsed, world, repo);
|
|
412
458
|
const scope = cwd;
|
|
459
|
+
if ((parsed.command === "deliver" || parsed.command === "review") && (await import("../akuma/requests.js")).injectedBodyRequests() !== null) {
|
|
460
|
+
const { EMPTY_WORKTREE_HOOKS } = await import("../library/configuration.js");
|
|
461
|
+
const seat = await existingSeat({ parsed, repo, edge, scope, hooks: EMPTY_WORKTREE_HOOKS });
|
|
462
|
+
return parsed.command === "deliver"
|
|
463
|
+
? await invokeDeliver(parsed, seat, false)
|
|
464
|
+
: await invokeReview(parsed, seat, edge.readStdin);
|
|
465
|
+
}
|
|
413
466
|
const configuration = await settingsAt(world ?? undefined, home);
|
|
414
|
-
const
|
|
467
|
+
const { worktreeHooksFrom, SettingsError } = await import("../library/configuration.js");
|
|
468
|
+
const hooks = consumeSettings(() => worktreeHooksFrom({ settings: configuration }), SettingsError);
|
|
415
469
|
if (parsed.command === "show") {
|
|
416
470
|
const selected = await selectContract(repo, parsed.contract, scope);
|
|
417
471
|
return { kind: "guidance", contract: selected.id, guidance: await selected.contract.guidance() };
|
|
@@ -442,7 +496,7 @@ export async function invoke(invocation, runtime = {}) {
|
|
|
442
496
|
assertExplicitRepoUse(command, invocation.repo);
|
|
443
497
|
if (command.command === "install") {
|
|
444
498
|
runtime.onOperationStart?.();
|
|
445
|
-
return installHarnesses(command.harnesses, runtime.environment ?? process.env);
|
|
499
|
+
return (await import("./commands/install.js")).installHarnesses(command.harnesses, runtime.environment ?? process.env);
|
|
446
500
|
}
|
|
447
501
|
const acquiredRuntime = await withAcquiredStdin(command, withResolvedTaskActor(command, runtime));
|
|
448
502
|
runtime.onOperationStart?.();
|
package/build/src/cli/main.d.ts
CHANGED
package/build/src/cli/main.js
CHANGED
|
@@ -1,151 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CliUsageError, parseArgv, renderContractHelp, renderRootHelp, } from "./parse.js";
|
|
3
|
-
import { renderText } from "./render/text.js";
|
|
4
|
-
import { renderTaskIncompleteDiagnostic, renderTaskText, taskExitCode } from "./render/task.js";
|
|
5
|
-
import { akumaExitCode, akumaRawAnswer, renderAkumaJson, renderAkumaText } from "./render/akuma.js";
|
|
6
|
-
import { isParsedAkumaCommand, renderAkumaHelp } from "./commands/akuma.js";
|
|
7
|
-
import { installExitCode, renderInstallHelp, renderInstallText } from "./commands/install.js";
|
|
8
|
-
import { renderTaskHelp } from "./commands/task.js";
|
|
9
|
-
import { renderSettingsText, settingsJsonValue } from "./render/settings.js";
|
|
10
|
-
import { renderCatalogText } from "./render/catalog.js";
|
|
11
|
-
import { BindDraftError } from "./draft.js";
|
|
12
|
-
import { renderBindDraftReceipt } from "./render/refusal.js";
|
|
13
|
-
function writeTask(command, result) {
|
|
14
|
-
const context = {
|
|
15
|
-
columns: process.stdout.isTTY === true && Number.isInteger(process.stdout.columns) ? process.stdout.columns : 80,
|
|
16
|
-
color: false,
|
|
17
|
-
};
|
|
18
|
-
if (command.output === "json")
|
|
19
|
-
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
20
|
-
else if (command.action === "compose" && typeof result === "object" && result !== null && "kind" in result && result.kind === "incomplete") {
|
|
21
|
-
const diagnostic = renderTaskIncompleteDiagnostic(result);
|
|
22
|
-
if (diagnostic.length > 0)
|
|
23
|
-
process.stderr.write(`${diagnostic}\n`);
|
|
24
|
-
process.stdout.write(result.draft);
|
|
25
|
-
}
|
|
26
|
-
else
|
|
27
|
-
process.stdout.write(`${renderTaskText(command, result, context)}\n`);
|
|
28
|
-
return taskExitCode(result);
|
|
29
|
-
}
|
|
30
|
-
function writeAkuma(command, result) {
|
|
31
|
-
const output = command.output === "json" ? renderAkumaJson(result) : renderAkumaText(command, result, {
|
|
32
|
-
columns: process.stdout.isTTY === true && Number.isInteger(process.stdout.columns) ? process.stdout.columns : 80,
|
|
33
|
-
color: process.stdout.isTTY === true && process.env.NO_COLOR === undefined,
|
|
34
|
-
});
|
|
35
|
-
const raw = command.output === "text"
|
|
36
|
-
&& ((command.command === "history" && command.last) || akumaRawAnswer(result) !== undefined);
|
|
37
|
-
process.stdout.write(raw ? output : `${output}\n`);
|
|
38
|
-
return akumaExitCode(result);
|
|
39
|
-
}
|
|
40
|
-
function renderHelp(coordinate) {
|
|
41
|
-
switch (coordinate.kind) {
|
|
42
|
-
case "root": return renderRootHelp();
|
|
43
|
-
case "contract": return renderContractHelp(coordinate.command);
|
|
44
|
-
case "task": return renderTaskHelp(coordinate.action);
|
|
45
|
-
case "install": return renderInstallHelp();
|
|
46
|
-
case "akuma": return renderAkumaHelp(coordinate.action);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export function invocationStart(command) {
|
|
50
|
-
if (command.output === "json")
|
|
51
|
-
return undefined;
|
|
52
|
-
switch (command.command) {
|
|
53
|
-
case "bind": return "⧖ preparing keiyaku";
|
|
54
|
-
case "deliver": return "⧖ delivering";
|
|
55
|
-
case "audit": return "⧖ auditing";
|
|
56
|
-
case "reconcile": return "⧖ reconciling";
|
|
57
|
-
case "install": return "⧖ installing skills";
|
|
58
|
-
default: return undefined;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function writeGuidance(command, result) {
|
|
62
|
-
if (command.output === "json")
|
|
63
|
-
process.stdout.write(`${JSON.stringify({ contract: result.contract, guidance: result.guidance })}\n`);
|
|
64
|
-
else
|
|
65
|
-
process.stdout.write(result.guidance.endsWith("\n") ? result.guidance : `${result.guidance}\n`);
|
|
66
|
-
return 0;
|
|
67
|
-
}
|
|
68
|
-
function writeCatalog(command, result) {
|
|
69
|
-
process.stdout.write(`${command.output === "json" ? JSON.stringify(result.catalog) : renderCatalogText(result.catalog)}\n`);
|
|
70
|
-
return 0;
|
|
71
|
-
}
|
|
72
|
-
// eslint-disable-next-line complexity -- output dispatch is the single CLI presentation boundary.
|
|
73
|
-
function writeResult(command, result) {
|
|
74
|
-
if (command.command === "install") {
|
|
75
|
-
const value = result;
|
|
76
|
-
process.stdout.write(`${command.output === "json" ? JSON.stringify(value) : renderInstallText(value)}\n`);
|
|
77
|
-
return installExitCode(value);
|
|
78
|
-
}
|
|
79
|
-
if (command.command === "task")
|
|
80
|
-
return writeTask(command, result);
|
|
81
|
-
if (command.command === "settings") {
|
|
82
|
-
const value = result.value;
|
|
83
|
-
process.stdout.write(`${command.output === "json" ? JSON.stringify(settingsJsonValue(value)) : renderSettingsText(value)}\n`);
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
if (typeof result === "object" && result !== null && "kind" in result && result.kind === "contract-history") {
|
|
87
|
-
const history = result.history;
|
|
88
|
-
const output = command.output === "json" ? JSON.stringify(history) : renderText(result);
|
|
89
|
-
process.stdout.write(`${output}\n`);
|
|
90
|
-
return 0;
|
|
91
|
-
}
|
|
92
|
-
const akumaResult = typeof result === "object" && result !== null && "kind" in result && result.kind === "akuma";
|
|
93
|
-
if (isParsedAkumaCommand(command)) {
|
|
94
|
-
return writeAkuma(command, result);
|
|
95
|
-
}
|
|
96
|
-
if (akumaResult && command.command === "status") {
|
|
97
|
-
return writeAkuma(command, result);
|
|
98
|
-
}
|
|
99
|
-
const contractResult = result;
|
|
100
|
-
if (contractResult.kind === "guidance")
|
|
101
|
-
return writeGuidance(command, contractResult);
|
|
102
|
-
if (contractResult.kind === "catalog")
|
|
103
|
-
return writeCatalog(command, contractResult);
|
|
104
|
-
if (contractResult.kind === "region") {
|
|
105
|
-
const output = command.output === "json" ? JSON.stringify(contractResult.region) : renderText(contractResult);
|
|
106
|
-
process.stdout.write(`${output}\n`);
|
|
107
|
-
return 0;
|
|
108
|
-
}
|
|
109
|
-
const output = command.output === "json"
|
|
110
|
-
? JSON.stringify(contractResult.kind === "status" ? contractResult.report : contractResult)
|
|
111
|
-
: renderText(contractResult, {
|
|
112
|
-
columns: process.stdout.isTTY === true && Number.isInteger(process.stdout.columns) ? process.stdout.columns : 80,
|
|
113
|
-
color: process.stdout.isTTY === true && process.env.NO_COLOR === undefined,
|
|
114
|
-
});
|
|
115
|
-
process.stdout.write(`${output}\n`);
|
|
116
|
-
return contractResult.kind === "refused" ? 1 : contractResult.kind === "retry" ? 2 : 0;
|
|
117
|
-
}
|
|
118
|
-
function writeWorldScopeRefusal(error, output) {
|
|
119
|
-
const body = output === "json"
|
|
120
|
-
? JSON.stringify(error.refusal)
|
|
121
|
-
: `${error.refusal.kind} ${error.refusal.world} ${error.refusal.ids.join(" ")}`;
|
|
122
|
-
process.stderr.write(`${body}\n`);
|
|
123
|
-
return 1;
|
|
124
|
-
}
|
|
1
|
+
import { CliUsageError, parseArgv, renderHelp } from "./parse.js";
|
|
125
2
|
export async function main(argv = process.argv.slice(2)) {
|
|
126
|
-
let output = "text";
|
|
127
3
|
try {
|
|
128
4
|
const parsed = parseArgv(argv);
|
|
129
5
|
if ("help" in parsed) {
|
|
130
6
|
process.stdout.write(`${renderHelp(parsed.help)}\n`);
|
|
131
7
|
return 0;
|
|
132
8
|
}
|
|
133
|
-
|
|
134
|
-
const { invoke } = await import("./invoke.js");
|
|
135
|
-
const start = invocationStart(parsed.command);
|
|
136
|
-
const result = await invoke(parsed, {
|
|
137
|
-
cwd: process.cwd(),
|
|
138
|
-
...(start === undefined ? {} : { onOperationStart: () => { process.stderr.write(`${start}\n`); } }),
|
|
139
|
-
});
|
|
140
|
-
return writeResult(parsed.command, result);
|
|
9
|
+
return await (await import("./runtime.js")).runCliCommand(parsed);
|
|
141
10
|
}
|
|
142
11
|
catch (error) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const original = error instanceof BindDraftError ? error.original : error;
|
|
146
|
-
process.stderr.write(`${original instanceof Error ? original.message : String(original)}\n`);
|
|
147
|
-
if (error instanceof BindDraftError)
|
|
148
|
-
process.stderr.write(`${renderBindDraftReceipt(error.draft)}\n`);
|
|
149
|
-
return original instanceof CliUsageError ? 1 : 3;
|
|
12
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
13
|
+
return error instanceof CliUsageError ? 1 : 3;
|
|
150
14
|
}
|
|
151
15
|
}
|
package/build/src/cli/parse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ParsedTaskCommand, type TaskAction } from "./commands/task.js";
|
|
2
2
|
import { type AkumaAction, type ParsedAkumaCommand } from "./commands/akuma.js";
|
|
3
|
-
import type { CatalogQuery } from "../
|
|
3
|
+
import type { CatalogQuery } from "../library/catalog.js";
|
|
4
4
|
import { type ParsedInstallCommand } from "./commands/install.js";
|
|
5
5
|
import { type ContractCommand as Command } from "./commands/contract.js";
|
|
6
6
|
export { CliUsageError } from "./usage.js";
|
|
@@ -8,6 +8,7 @@ export type { Command };
|
|
|
8
8
|
export declare function renderRootHelp(): string;
|
|
9
9
|
export declare function renderContractHelp(command: Command): string;
|
|
10
10
|
export declare function renderCommandUsage(command: ParsedCommand): string;
|
|
11
|
+
export declare function renderHelp(coordinate: CliHelpCoordinate): string;
|
|
11
12
|
type Output = Readonly<{
|
|
12
13
|
output: "text" | "json";
|
|
13
14
|
}>;
|
|
@@ -20,14 +21,14 @@ export type ParsedBind = Output & Actor & Readonly<{
|
|
|
20
21
|
target?: string;
|
|
21
22
|
workspace?: "here";
|
|
22
23
|
after?: readonly string[];
|
|
23
|
-
gates?: string;
|
|
24
|
+
gates?: readonly string[];
|
|
24
25
|
}>;
|
|
25
26
|
export type ParsedAmend = Output & Actor & Readonly<{
|
|
26
27
|
command: "amend";
|
|
27
28
|
contract?: string;
|
|
28
29
|
after?: readonly string[];
|
|
29
30
|
clearAfter?: true;
|
|
30
|
-
gates?: string;
|
|
31
|
+
gates?: readonly string[];
|
|
31
32
|
stdin?: true;
|
|
32
33
|
}>;
|
|
33
34
|
export type ParsedDeliver = Output & Actor & Readonly<{
|
|
@@ -35,6 +36,7 @@ export type ParsedDeliver = Output & Actor & Readonly<{
|
|
|
35
36
|
contract?: string;
|
|
36
37
|
message?: string;
|
|
37
38
|
includeDirty: boolean;
|
|
39
|
+
materializeConflict: boolean;
|
|
38
40
|
}>;
|
|
39
41
|
export type ParsedReview = Output & Actor & Readonly<{
|
|
40
42
|
command: "review";
|
|
@@ -77,6 +79,10 @@ type ParsedReconcile = Output & Readonly<{
|
|
|
77
79
|
contract?: string;
|
|
78
80
|
retryHooks: boolean;
|
|
79
81
|
}>;
|
|
82
|
+
export type ParsedNuke = Output & Readonly<{
|
|
83
|
+
command: "nuke";
|
|
84
|
+
confirm?: string;
|
|
85
|
+
}>;
|
|
80
86
|
export type ParsedSettings = Output & Readonly<{
|
|
81
87
|
command: "settings";
|
|
82
88
|
}>;
|
|
@@ -89,7 +95,7 @@ export type ParsedRegion = Output & Readonly<{
|
|
|
89
95
|
export type ParsedCommand = ParsedBind | ParsedAmend | ParsedDeliver | ParsedReview | ParsedArc | ParsedAbandon | ParsedStatus | (Output & Readonly<{
|
|
90
96
|
command: "show";
|
|
91
97
|
contract?: string;
|
|
92
|
-
}>) | ParsedLs | ParsedAudit | ParsedReconcile | ParsedSettings | ParsedRegion | ParsedInstallCommand | ParsedAkumaCommand | ParsedTaskCommand;
|
|
98
|
+
}>) | ParsedLs | ParsedAudit | ParsedReconcile | ParsedNuke | ParsedSettings | ParsedRegion | ParsedInstallCommand | ParsedAkumaCommand | ParsedTaskCommand;
|
|
93
99
|
export type CliHelpCoordinate = Readonly<{
|
|
94
100
|
kind: "root";
|
|
95
101
|
}> | Readonly<{
|
|
@@ -112,4 +118,11 @@ export type ParsedExecution = Readonly<{
|
|
|
112
118
|
export type ParsedInvocation = ParsedExecution | Readonly<{
|
|
113
119
|
help: CliHelpCoordinate;
|
|
114
120
|
}>;
|
|
121
|
+
type RepoUse = "none" | "optional" | "required";
|
|
122
|
+
export type CommandRepoPolicy = Readonly<{
|
|
123
|
+
use: RepoUse;
|
|
124
|
+
acceptsExplicit: boolean;
|
|
125
|
+
}>;
|
|
126
|
+
export declare function commandRepoPolicy(command: ParsedCommand): CommandRepoPolicy;
|
|
127
|
+
export declare function assertExplicitRepoUse(command: ParsedCommand, repo: string | undefined): void;
|
|
115
128
|
export declare function parseArgv(argv: readonly string[]): ParsedInvocation;
|