@astrosheep/keiyaku 4.1.0 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
- package/build/src/akuma/akuma-errors.d.ts +6 -0
- package/build/src/akuma/akuma-errors.js +9 -0
- package/build/src/akuma/akuma-handle.d.ts +39 -0
- package/build/src/akuma/akuma-handle.js +263 -0
- package/build/src/akuma/akuma-observe.d.ts +19 -0
- package/build/src/akuma/akuma-observe.js +74 -0
- package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
- package/build/src/akuma/akuma-product-symbols.js +1 -0
- package/build/src/akuma/akuma-product.d.ts +18 -0
- package/build/src/akuma/akuma-product.js +154 -0
- package/build/src/akuma/akuma.d.ts +37 -81
- package/build/src/akuma/akuma.js +39 -447
- package/build/src/akuma/allowed.d.ts +1 -0
- package/build/src/akuma/allowed.js +6 -0
- package/build/src/akuma/archetype.js +8 -5
- package/build/src/akuma/body-supervisor.d.ts +26 -0
- package/build/src/akuma/body-supervisor.js +89 -0
- package/build/src/akuma/body.d.ts +45 -4
- package/build/src/akuma/body.js +145 -35
- package/build/src/akuma/coordinate.js +17 -7
- package/build/src/akuma/heart/facts.js +1 -1
- package/build/src/akuma/heart/index.d.ts +1 -1
- package/build/src/akuma/heart/index.js +2 -4
- package/build/src/akuma/heart/request-authority.js +4 -4
- package/build/src/akuma/heart/request-rows.js +27 -16
- package/build/src/akuma/heart/rows.js +79 -41
- package/build/src/akuma/heart/soul.js +1 -1
- package/build/src/akuma/heart/storage.d.ts +1 -0
- package/build/src/akuma/heart/storage.js +76 -11
- package/build/src/akuma/heart/tells.js +35 -18
- package/build/src/akuma/heart/timeline.js +19 -11
- package/build/src/akuma/identity.d.ts +1 -0
- package/build/src/akuma/identity.js +1 -0
- package/build/src/akuma/index.d.ts +3 -3
- package/build/src/akuma/index.js +1 -1
- package/build/src/akuma/nuke.js +106 -14
- package/build/src/akuma/projection-read.d.ts +17 -0
- package/build/src/akuma/projection-read.js +135 -0
- package/build/src/akuma/projection.d.ts +1 -16
- package/build/src/akuma/projection.js +77 -154
- package/build/src/akuma/provider-recipe.js +11 -5
- package/build/src/akuma/provider.js +105 -62
- package/build/src/akuma/providers/acp/config.js +5 -6
- package/build/src/akuma/providers/acp/core.js +17 -10
- package/build/src/akuma/providers/acp/events.js +38 -29
- package/build/src/akuma/providers/acp/index.js +13 -9
- package/build/src/akuma/providers/claude/events.js +8 -12
- package/build/src/akuma/providers/claude/index.d.ts +1 -0
- package/build/src/akuma/providers/claude/index.js +55 -26
- package/build/src/akuma/providers/claude/input.js +6 -2
- package/build/src/akuma/providers/codex-app-server/events.js +61 -36
- package/build/src/akuma/providers/codex-app-server/index.js +25 -13
- package/build/src/akuma/providers/grok-build/index.js +22 -25
- package/build/src/akuma/providers/index.js +2 -18
- package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
- package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
- package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
- package/build/src/akuma/providers/pi/events.js +26 -19
- package/build/src/akuma/providers/pi/index.js +58 -40
- package/build/src/akuma/publication.js +9 -9
- package/build/src/akuma/request-execution.d.ts +6 -0
- package/build/src/akuma/request-execution.js +86 -0
- package/build/src/akuma/request-serve.d.ts +12 -1
- package/build/src/akuma/request-serve.js +19 -122
- package/build/src/akuma/request-wire.d.ts +2 -2
- package/build/src/akuma/request-wire.js +75 -102
- package/build/src/akuma/requests.js +2 -2
- package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
- package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
- package/build/src/akuma-body.js +6 -5
- package/build/src/body/amend.d.ts +4 -1
- package/build/src/body/amend.js +14 -6
- package/build/src/body/decode.js +2 -4
- package/build/src/body/envelope.js +2 -4
- package/build/src/body/region.d.ts +1 -2
- package/build/src/body/region.js +2 -70
- package/build/src/body/render.js +17 -12
- package/build/src/body/shape.js +1 -7
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +8 -1
- package/build/src/cli/commands/akuma-invoke.js +18 -6
- package/build/src/cli/commands/akuma.d.ts +0 -6
- package/build/src/cli/commands/akuma.js +11 -24
- package/build/src/cli/commands/amend.d.ts +2 -2
- package/build/src/cli/commands/amend.js +2 -4
- package/build/src/cli/commands/bind.d.ts +4 -4
- package/build/src/cli/commands/bind.js +16 -6
- package/build/src/cli/commands/contract-invoke.d.ts +25 -0
- package/build/src/cli/commands/contract-invoke.js +193 -0
- package/build/src/cli/commands/contract.d.ts +109 -10
- package/build/src/cli/commands/contract.js +339 -16
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +23 -15
- package/build/src/cli/commands/task-invoke.js +187 -67
- package/build/src/cli/commands/task-query.js +48 -24
- package/build/src/cli/commands/task.js +150 -38
- package/build/src/cli/coordinates.js +2 -4
- package/build/src/cli/invoke.js +92 -208
- package/build/src/cli/main.js +4 -2
- package/build/src/cli/parse.d.ts +3 -90
- package/build/src/cli/parse.js +27 -233
- package/build/src/cli/render/akuma-activity.d.ts +38 -0
- package/build/src/cli/render/akuma-activity.js +362 -0
- package/build/src/cli/render/akuma-tool-command.js +6 -7
- package/build/src/cli/render/akuma-tool.js +10 -8
- package/build/src/cli/render/akuma.d.ts +1 -1
- package/build/src/cli/render/akuma.js +61 -353
- package/build/src/cli/render/audit.js +5 -15
- package/build/src/cli/render/board.d.ts +1 -0
- package/build/src/cli/render/board.js +17 -0
- package/build/src/cli/render/catalog.js +81 -8
- package/build/src/cli/render/contract-history.d.ts +2 -0
- package/build/src/cli/render/contract-history.js +83 -0
- package/build/src/cli/render/contract-observation.d.ts +10 -0
- package/build/src/cli/render/contract-observation.js +58 -0
- package/build/src/cli/render/contract.d.ts +1 -2
- package/build/src/cli/render/contract.js +41 -142
- package/build/src/cli/render/kanshi.js +239 -215
- package/build/src/cli/render/receipt.js +2 -9
- package/build/src/cli/render/refusal.js +10 -15
- package/build/src/cli/render/region.js +22 -6
- package/build/src/cli/render/settings.js +4 -4
- package/build/src/cli/render/task.js +34 -14
- package/build/src/cli/render/terminal.js +16 -5
- package/build/src/cli/result.d.ts +3 -3
- package/build/src/cli/runtime.d.ts +6 -1
- package/build/src/cli/runtime.js +84 -63
- package/build/src/cli/selectors.js +2 -4
- package/build/src/cli/usage.js +6 -5
- package/build/src/contract-worktree.d.ts +1 -23
- package/build/src/contract-worktree.js +79 -155
- package/build/src/coordination/durable-file.js +7 -3
- package/build/src/coordination/sqlite-transaction-lock.js +29 -12
- package/build/src/core/facts/codec.js +7 -3
- package/build/src/core/facts/types.d.ts +1 -1
- package/build/src/core/subject.js +16 -9
- package/build/src/core/verbs/abandon.d.ts +1 -1
- package/build/src/core/verbs/abandon.js +1 -1
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +7 -7
- package/build/src/core/verbs/attestation.js +4 -1
- package/build/src/core/verbs/bind.d.ts +1 -1
- package/build/src/core/verbs/bind.js +1 -1
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +10 -8
- package/build/src/dispatch/index.js +8 -6
- package/build/src/duration.js +5 -1
- package/build/src/git/admission.js +5 -3
- package/build/src/git/hooks.d.ts +8 -0
- package/build/src/git/hooks.js +63 -14
- package/build/src/git/identity.js +1 -4
- package/build/src/git/integration.d.ts +2 -3
- package/build/src/git/integration.js +32 -39
- package/build/src/git/nuke.d.ts +1 -1
- package/build/src/git/nuke.js +110 -57
- package/build/src/git/observe.d.ts +13 -1
- package/build/src/git/observe.js +51 -44
- package/build/src/git/process.js +4 -2
- package/build/src/git/read-observation.js +10 -8
- package/build/src/git/reconcile.d.ts +22 -2
- package/build/src/git/reconcile.js +38 -274
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -22
- package/build/src/git/scratch.d.ts +8 -5
- package/build/src/git/scratch.js +29 -2
- package/build/src/git/target-placement.d.ts +9 -10
- package/build/src/git/target-placement.js +59 -62
- package/build/src/git/tender.js +13 -46
- package/build/src/git/terminal-reconcile.d.ts +21 -0
- package/build/src/git/terminal-reconcile.js +278 -0
- package/build/src/git/terminal-seal.js +15 -12
- package/build/src/git/tree.js +5 -2
- package/build/src/git/workspace.d.ts +24 -2
- package/build/src/git/workspace.js +120 -16
- package/build/src/identity/coordinates.js +3 -1
- package/build/src/identity/selector.js +6 -3
- package/build/src/kanshi/fleet.d.ts +6 -0
- package/build/src/kanshi/fleet.js +27 -0
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +60 -48
- package/build/src/kanshi/report.d.ts +11 -23
- package/build/src/kanshi/select.js +25 -24
- package/build/src/library/address.d.ts +2 -1
- package/build/src/library/address.js +7 -8
- package/build/src/library/akuma-creation.js +20 -12
- package/build/src/library/audit.d.ts +0 -1
- package/build/src/library/audit.js +1 -2
- package/build/src/library/bind.d.ts +53 -5
- package/build/src/library/bind.js +98 -22
- package/build/src/library/catalog.d.ts +1 -0
- package/build/src/library/catalog.js +6 -3
- package/build/src/library/configuration.js +3 -1
- package/build/src/library/continuation.d.ts +15 -4
- package/build/src/library/continuation.js +24 -16
- package/build/src/library/contract-bind.d.ts +26 -0
- package/build/src/library/contract-bind.js +106 -0
- package/build/src/library/contract-operations.d.ts +77 -0
- package/build/src/library/contract-operations.js +130 -0
- package/build/src/library/contract-types.d.ts +95 -0
- package/build/src/library/contract-types.js +1 -0
- package/build/src/library/contract.d.ts +19 -154
- package/build/src/library/contract.js +46 -261
- package/build/src/library/fleet.d.ts +1 -1
- package/build/src/library/fleet.js +19 -11
- package/build/src/library/input.d.ts +2 -0
- package/build/src/library/input.js +14 -0
- package/build/src/library/keiyaku.d.ts +8 -7
- package/build/src/library/keiyaku.js +3 -3
- package/build/src/library/nuke.js +14 -5
- package/build/src/library/reconcile.d.ts +9 -4
- package/build/src/library/reconcile.js +30 -24
- package/build/src/library/refusal.d.ts +13 -5
- package/build/src/library/refusal.js +7 -0
- package/build/src/library/region.d.ts +8 -7
- package/build/src/library/region.js +31 -11
- package/build/src/library/repo.js +2 -2
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/parse.js +11 -7
- package/build/src/markdown/query.js +4 -2
- package/build/src/protocol/amend.js +3 -1
- package/build/src/protocol/attempt.d.ts +7 -3
- package/build/src/protocol/attempt.js +9 -5
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +4 -14
- package/build/src/protocol/bind.d.ts +19 -6
- package/build/src/protocol/bind.js +28 -13
- package/build/src/protocol/completion.d.ts +0 -1
- package/build/src/protocol/completion.js +1 -3
- package/build/src/protocol/deliver.d.ts +1 -3
- package/build/src/protocol/deliver.js +15 -39
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +9 -7
- package/build/src/protocol/operations.d.ts +3 -7
- package/build/src/protocol/operations.js +5 -3
- package/build/src/protocol/placement.d.ts +0 -1
- package/build/src/protocol/placement.js +6 -6
- package/build/src/protocol/read/observation.d.ts +11 -0
- package/build/src/protocol/read/observation.js +37 -0
- package/build/src/protocol/read/status.d.ts +23 -12
- package/build/src/protocol/read/status.js +90 -72
- package/build/src/protocol/reconcile.d.ts +1 -0
- package/build/src/protocol/reconcile.js +2 -3
- package/build/src/protocol/reintegrate.js +1 -1
- package/build/src/protocol/review.d.ts +0 -1
- package/build/src/protocol/review.js +15 -22
- package/build/src/protocol/run.d.ts +1 -0
- package/build/src/protocol/run.js +4 -5
- package/build/src/runtime/proc/launch.d.ts +33 -0
- package/build/src/runtime/proc/launch.js +98 -0
- package/build/src/runtime/proc/line-rpc.js +9 -3
- package/build/src/runtime/proc/run.d.ts +12 -6
- package/build/src/runtime/proc/run.js +78 -21
- package/build/src/runtime/proc/stdio.js +7 -10
- package/build/src/settings.js +6 -2
- package/build/src/settlement/holder.js +13 -10
- package/build/src/settlement/settle.js +39 -6
- package/build/src/task/board.js +12 -6
- package/build/src/task/compose.js +85 -22
- package/build/src/task/context.js +21 -8
- package/build/src/task/document.js +46 -10
- package/build/src/task/identity.js +5 -2
- package/build/src/task/index.d.ts +0 -1
- package/build/src/task/index.js +119 -34
- package/build/src/task/input.js +29 -7
- package/build/src/task/mutation.js +61 -19
- package/build/src/task/operations.d.ts +6 -1
- package/build/src/task/operations.js +83 -29
- package/build/src/task/query.js +55 -26
- package/build/src/task/store.d.ts +3 -1
- package/build/src/task/store.js +81 -17
- package/build/src/verification/execution.js +14 -11
- package/build/src/workspace-place.js +19 -7
- package/build/src/world.js +16 -6
- package/package.json +8 -3
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { contractFromInput } from "../selectors.js";
|
|
2
|
-
export function amendFromCommand({ command, repo, contract, markdown, gates, actor, hooks }) {
|
|
3
|
-
const after = command.clearAfter === true
|
|
4
|
-
? []
|
|
5
|
-
: command.after?.map((id) => contractFromInput(repo, id).id);
|
|
2
|
+
export function amendFromCommand({ command, repo, contract, markdown, gates, actor, hooks, }) {
|
|
3
|
+
const after = command.clearAfter === true ? [] : command.after?.map((id) => contractFromInput(repo, id).id);
|
|
6
4
|
return contract.amend({
|
|
7
5
|
...(markdown === undefined ? {} : { markdown }),
|
|
8
6
|
...(actor === undefined ? {} : { actor }),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type ActorId, type BindResult, type Gate, type Repo, type WorktreeHooks } from "../../index.js";
|
|
2
|
-
import type { ParsedBind } from "
|
|
2
|
+
import type { ParsedBind } from "./contract.js";
|
|
3
3
|
type BindCommandInput = Readonly<{
|
|
4
4
|
command: ParsedBind;
|
|
5
5
|
repo: Repo;
|
|
6
|
-
markdown
|
|
7
|
-
gates
|
|
6
|
+
markdown?: string;
|
|
7
|
+
gates?: readonly Gate[];
|
|
8
8
|
actor?: ActorId;
|
|
9
9
|
hooks?: WorktreeHooks;
|
|
10
10
|
}>;
|
|
11
|
-
export declare function bindFromCommand({ command, repo, markdown, gates, actor, hooks }: BindCommandInput): Promise<BindResult>;
|
|
11
|
+
export declare function bindFromCommand({ command, repo, markdown, gates, actor, hooks, }: BindCommandInput): Promise<BindResult>;
|
|
12
12
|
export {};
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { Keiyaku } from "../../index.js";
|
|
1
|
+
import { Keiyaku, } from "../../index.js";
|
|
2
|
+
import { bindFromCli } from "../../library/contract.js";
|
|
2
3
|
import { contractFromInput } from "../selectors.js";
|
|
3
|
-
export async function bindFromCommand({ command, repo, markdown, gates, actor, hooks }) {
|
|
4
|
+
export async function bindFromCommand({ command, repo, markdown, gates, actor, hooks, }) {
|
|
5
|
+
if (command.forkOf !== undefined) {
|
|
6
|
+
return Keiyaku.bind({
|
|
7
|
+
repo,
|
|
8
|
+
forkOf: contractFromInput(repo, command.forkOf).id,
|
|
9
|
+
...(command.target === undefined ? {} : { target: command.target }),
|
|
10
|
+
...(actor === undefined ? {} : { actor }),
|
|
11
|
+
...(hooks === undefined ? {} : { hooks }),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
4
14
|
const after = command.after?.map((id) => contractFromInput(repo, id).id);
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
if (markdown === undefined || gates === undefined)
|
|
16
|
+
throw new Error("Markdown bind command is missing stdin terms");
|
|
17
|
+
return bindFromCli({
|
|
7
18
|
repo,
|
|
8
19
|
markdown,
|
|
9
20
|
...(command.task === undefined ? {} : { task: command.task }),
|
|
10
|
-
...(target ===
|
|
11
|
-
...(command.workspace === undefined ? {} : { workspace: command.workspace }),
|
|
21
|
+
...(command.target === undefined ? {} : { target: command.target }),
|
|
12
22
|
...(actor === undefined ? {} : { actor }),
|
|
13
23
|
...(hooks === undefined ? {} : { hooks }),
|
|
14
24
|
...(after === undefined ? {} : { after }),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InvocationResult } from "../result.js";
|
|
2
|
+
import type { ParsedCommand } from "../parse.js";
|
|
3
|
+
import type { WorktreeHooks } from "../../library/configuration.js";
|
|
4
|
+
import type { Repo } from "../../library/repo.js";
|
|
5
|
+
import type { Settings } from "../../settings.js";
|
|
6
|
+
import type { WorldRoot } from "../../world.js";
|
|
7
|
+
type ContractMutation = Extract<ParsedCommand, {
|
|
8
|
+
command: "bind" | "amend" | "deliver" | "review" | "arc" | "abandon" | "audit";
|
|
9
|
+
}>;
|
|
10
|
+
type InvocationEdge = Readonly<{
|
|
11
|
+
environment: NodeJS.ProcessEnv;
|
|
12
|
+
readStdin: () => Promise<string>;
|
|
13
|
+
}>;
|
|
14
|
+
export type ContractMutationInput = Readonly<{
|
|
15
|
+
parsed: ContractMutation;
|
|
16
|
+
repo: Repo;
|
|
17
|
+
edge: InvocationEdge;
|
|
18
|
+
scope: string;
|
|
19
|
+
configuration?: Settings;
|
|
20
|
+
hooks: WorktreeHooks;
|
|
21
|
+
establishWorld: () => Promise<WorldRoot>;
|
|
22
|
+
forwarded?: true;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function invokeContractMutation(input: ContractMutationInput): Promise<InvocationResult>;
|
|
25
|
+
export {};
|
|
@@ -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
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CatalogQuery } from "../../library/catalog.js";
|
|
1
2
|
export type ContractFlagKind = "boolean" | "value" | "raw-value" | "repeat-value";
|
|
2
3
|
export type ContractCommandSpec = Readonly<{
|
|
3
4
|
positional: "none" | "optional";
|
|
@@ -5,23 +6,109 @@ export type ContractCommandSpec = Readonly<{
|
|
|
5
6
|
flags: Readonly<Record<string, ContractFlagKind>>;
|
|
6
7
|
usage: string;
|
|
7
8
|
purpose: string;
|
|
8
|
-
|
|
9
|
+
details?: string;
|
|
10
|
+
}>;
|
|
11
|
+
type Output = Readonly<{
|
|
12
|
+
output: "text" | "json";
|
|
13
|
+
}>;
|
|
14
|
+
type Actor = Readonly<{
|
|
15
|
+
actor?: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type ParsedBind = Output & Actor & Readonly<{
|
|
18
|
+
command: "bind";
|
|
19
|
+
forkOf?: string;
|
|
20
|
+
task?: string;
|
|
21
|
+
target?: string;
|
|
22
|
+
after?: readonly string[];
|
|
23
|
+
gates?: readonly string[];
|
|
24
|
+
}>;
|
|
25
|
+
export type ParsedAmend = Output & Actor & Readonly<{
|
|
26
|
+
command: "amend";
|
|
27
|
+
contract?: string;
|
|
28
|
+
after?: readonly string[];
|
|
29
|
+
clearAfter?: true;
|
|
30
|
+
gates?: readonly string[];
|
|
31
|
+
stdin?: true;
|
|
32
|
+
}>;
|
|
33
|
+
export type ParsedDeliver = Output & Actor & Readonly<{
|
|
34
|
+
command: "deliver";
|
|
35
|
+
contract?: string;
|
|
36
|
+
message?: string;
|
|
37
|
+
includeDirty: boolean;
|
|
38
|
+
materializeConflict: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
export type ParsedReview = Output & Actor & Readonly<{
|
|
41
|
+
command: "review";
|
|
42
|
+
contract?: string;
|
|
43
|
+
verdict: "satisfied" | "unsatisfied";
|
|
44
|
+
summary?: string;
|
|
45
|
+
summaryFromStdin?: true;
|
|
46
|
+
}>;
|
|
47
|
+
export type ParsedArc = Output & Actor & Readonly<{
|
|
48
|
+
command: "arc";
|
|
49
|
+
contract?: string;
|
|
50
|
+
}>;
|
|
51
|
+
export type ParsedAbandon = Output & Actor & Readonly<{
|
|
52
|
+
command: "abandon";
|
|
53
|
+
contract?: string;
|
|
54
|
+
note?: string;
|
|
55
|
+
}>;
|
|
56
|
+
export type ParsedStatus = Output & (Readonly<{
|
|
57
|
+
command: "status";
|
|
58
|
+
contract?: string;
|
|
59
|
+
akuma?: never;
|
|
60
|
+
}> | Readonly<{
|
|
61
|
+
command: "status";
|
|
62
|
+
contract: string;
|
|
63
|
+
akuma: true;
|
|
64
|
+
}>);
|
|
65
|
+
export type ParsedLs = Output & Readonly<{
|
|
66
|
+
command: "ls";
|
|
67
|
+
query: CatalogQuery;
|
|
68
|
+
}>;
|
|
69
|
+
export type ParsedAudit = Output & Readonly<{
|
|
70
|
+
command: "audit";
|
|
71
|
+
contract?: string;
|
|
72
|
+
includeDirty: boolean;
|
|
73
|
+
showDiff: boolean;
|
|
74
|
+
actor?: string;
|
|
75
|
+
}>;
|
|
76
|
+
export type ParsedReconcile = Output & Readonly<{
|
|
77
|
+
command: "reconcile";
|
|
78
|
+
contract?: string;
|
|
79
|
+
retryHooks: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
export type ParsedNuke = Output & Readonly<{
|
|
82
|
+
command: "nuke";
|
|
83
|
+
confirm?: string;
|
|
84
|
+
}>;
|
|
85
|
+
export type ParsedSettings = Output & Readonly<{
|
|
86
|
+
command: "settings";
|
|
87
|
+
}>;
|
|
88
|
+
export type ParsedRegion = Output & Readonly<{
|
|
89
|
+
command: "region";
|
|
90
|
+
contract?: string;
|
|
91
|
+
paths?: readonly [string, ...string[]];
|
|
92
|
+
}>;
|
|
93
|
+
export type ParsedShow = Output & Readonly<{
|
|
94
|
+
command: "show";
|
|
95
|
+
contract?: string;
|
|
9
96
|
}>;
|
|
10
97
|
export declare const CONTRACT_COMMAND_SPECS: {
|
|
11
98
|
readonly bind: {
|
|
12
99
|
readonly positional: "none";
|
|
13
|
-
readonly stdin: "
|
|
100
|
+
readonly stdin: "optional";
|
|
14
101
|
readonly flags: {
|
|
15
102
|
readonly actor: "value";
|
|
16
103
|
readonly task: "value";
|
|
17
104
|
readonly target: "value";
|
|
18
|
-
readonly here: "boolean";
|
|
19
105
|
readonly after: "repeat-value";
|
|
20
106
|
readonly gates: "raw-value";
|
|
107
|
+
readonly "fork-of": "value";
|
|
21
108
|
readonly json: "boolean";
|
|
22
109
|
};
|
|
23
|
-
readonly usage: "bind [--task <task/...>] [--target <ref>] [--
|
|
24
|
-
readonly purpose: "Create one Contract from stdin Markdown.";
|
|
110
|
+
readonly usage: "bind [--task <task/...>] [--target <ref>] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] - | bind --fork-of <kei/...> [--target <ref>] [--actor <actor>]";
|
|
111
|
+
readonly purpose: "Create one Contract from stdin Markdown or a sibling fork.";
|
|
25
112
|
};
|
|
26
113
|
readonly amend: {
|
|
27
114
|
readonly positional: "optional";
|
|
@@ -35,7 +122,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
|
|
|
35
122
|
};
|
|
36
123
|
readonly usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [-]";
|
|
37
124
|
readonly purpose: "Amend one Contract's document operations or structured terms.";
|
|
38
|
-
readonly
|
|
125
|
+
readonly details: string;
|
|
39
126
|
};
|
|
40
127
|
readonly deliver: {
|
|
41
128
|
readonly positional: "optional";
|
|
@@ -49,7 +136,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
|
|
|
49
136
|
};
|
|
50
137
|
readonly usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--actor <actor>]";
|
|
51
138
|
readonly purpose: "Deliver one Contract candidate from the appointed worktree.";
|
|
52
|
-
readonly
|
|
139
|
+
readonly details: string;
|
|
53
140
|
};
|
|
54
141
|
readonly review: {
|
|
55
142
|
readonly positional: "optional";
|
|
@@ -157,12 +244,24 @@ export declare const CONTRACT_COMMAND_SPECS: {
|
|
|
157
244
|
readonly positional: "optional";
|
|
158
245
|
readonly stdin: "none";
|
|
159
246
|
readonly flags: {
|
|
160
|
-
readonly
|
|
161
|
-
readonly path: "value";
|
|
247
|
+
readonly path: "repeat-value";
|
|
162
248
|
readonly json: "boolean";
|
|
163
249
|
};
|
|
164
|
-
readonly usage: "region [<contract>]
|
|
250
|
+
readonly usage: "region [<contract>]\n region --path <pattern> [--path <pattern> ...]";
|
|
165
251
|
readonly purpose: "Read active declared Contract Regions.";
|
|
166
252
|
};
|
|
167
253
|
};
|
|
168
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;
|
|
267
|
+
export {};
|