@astrosheep/keiyaku 4.0.1 → 4.0.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.
- package/README.md +137 -5
- 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 +3 -3
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -35
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +89 -58
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +146 -53
- package/build/src/akuma/abort.d.ts +2 -0
- package/build/src/akuma/abort.js +50 -0
- package/build/src/akuma/akuma.d.ts +23 -14
- package/build/src/akuma/akuma.js +120 -104
- package/build/src/akuma/archetype.d.ts +7 -6
- package/build/src/akuma/archetype.js +68 -41
- package/build/src/akuma/body.d.ts +3 -5
- package/build/src/akuma/body.js +417 -214
- package/build/src/akuma/heart/facts.d.ts +25 -34
- package/build/src/akuma/heart/facts.js +18 -7
- package/build/src/akuma/heart/index.d.ts +39 -42
- package/build/src/akuma/heart/index.js +134 -93
- package/build/src/akuma/heart/rows.d.ts +9 -31
- package/build/src/akuma/heart/rows.js +26 -44
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +7 -15
- package/build/src/akuma/heart/soul.d.ts +8 -0
- package/build/src/akuma/heart/soul.js +136 -0
- package/build/src/akuma/heart/storage.d.ts +29 -14
- package/build/src/akuma/heart/storage.js +91 -26
- package/build/src/akuma/identity.d.ts +2 -2
- package/build/src/akuma/identity.js +9 -9
- package/build/src/akuma/index.d.ts +6 -1
- package/build/src/akuma/index.js +6 -0
- package/build/src/akuma/projection.d.ts +117 -38
- package/build/src/akuma/projection.js +208 -97
- package/build/src/akuma/provider-recipe.d.ts +24 -0
- package/build/src/akuma/provider-recipe.js +100 -0
- package/build/src/akuma/provider.d.ts +12 -4
- package/build/src/akuma/provider.js +117 -70
- package/build/src/akuma/providers/acp/core.d.ts +19 -0
- package/build/src/akuma/providers/acp/core.js +159 -0
- package/build/src/akuma/providers/acp/events.d.ts +20 -0
- package/build/src/akuma/providers/acp/events.js +73 -0
- package/build/src/akuma/providers/acp/index.d.ts +12 -0
- package/build/src/akuma/providers/acp/index.js +94 -0
- package/build/src/akuma/providers/claude/events.js +66 -13
- package/build/src/akuma/providers/claude/index.d.ts +2 -1
- package/build/src/akuma/providers/claude/index.js +35 -21
- package/build/src/akuma/providers/codex-app-server/events.js +4 -1
- package/build/src/akuma/providers/codex-app-server/index.d.ts +3 -3
- package/build/src/akuma/providers/codex-app-server/index.js +24 -31
- package/build/src/akuma/providers/grok-build/index.d.ts +4 -0
- package/build/src/akuma/providers/grok-build/index.js +70 -0
- package/build/src/akuma/providers/index.d.ts +5 -3
- package/build/src/akuma/providers/index.js +24 -59
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +40 -34
- package/build/src/akuma/providers/opencode-sdk/events.js +220 -101
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +3 -2
- package/build/src/akuma/providers/opencode-sdk/index.js +233 -128
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +11 -26
- package/build/src/akuma/providers/opencode-sdk/session.js +10 -9
- package/build/src/akuma/providers/pi/events.js +49 -11
- package/build/src/akuma/providers/pi/index.d.ts +1 -1
- package/build/src/akuma/providers/pi/index.js +50 -21
- package/build/src/akuma/publication.d.ts +3 -3
- package/build/src/akuma/publication.js +61 -44
- package/build/src/akuma/requests.d.ts +9 -7
- package/build/src/akuma/requests.js +92 -65
- package/build/src/alias/index.d.ts +2 -2
- package/build/src/alias/index.js +10 -10
- package/build/src/body/decode.js +7 -1
- package/build/src/body/region.d.ts +2 -0
- package/build/src/body/region.js +77 -7
- package/build/src/cli/accepted.d.ts +17 -13
- package/build/src/cli/accepted.js +72 -34
- package/build/src/cli/actor.js +3 -3
- package/build/src/cli/commands/akuma-invoke.d.ts +4 -3
- package/build/src/cli/commands/akuma-invoke.js +14 -9
- package/build/src/cli/commands/akuma.d.ts +13 -3
- package/build/src/cli/commands/akuma.js +67 -34
- package/build/src/cli/commands/contract.d.ts +18 -5
- package/build/src/cli/commands/contract.js +9 -3
- package/build/src/cli/commands/install.js +2 -2
- package/build/src/cli/commands/task-invoke.d.ts +17 -4
- package/build/src/cli/commands/task-invoke.js +43 -20
- package/build/src/cli/commands/task-query.d.ts +5 -0
- package/build/src/cli/commands/task-query.js +247 -0
- package/build/src/cli/commands/task.d.ts +3 -1
- package/build/src/cli/commands/task.js +54 -16
- package/build/src/cli/coordinates.d.ts +18 -0
- package/build/src/cli/coordinates.js +120 -0
- package/build/src/cli/draft.d.ts +8 -0
- package/build/src/cli/draft.js +96 -0
- package/build/src/cli/invoke.d.ts +4 -3
- package/build/src/cli/invoke.js +160 -179
- package/build/src/cli/main.js +34 -6
- package/build/src/cli/parse.d.ts +9 -2
- package/build/src/cli/parse.js +31 -9
- package/build/src/cli/render/akuma-tool-command.d.ts +6 -0
- package/build/src/cli/render/akuma-tool-command.js +144 -0
- package/build/src/cli/render/akuma-tool.d.ts +2 -2
- package/build/src/cli/render/akuma-tool.js +30 -4
- package/build/src/cli/render/akuma.d.ts +1 -0
- package/build/src/cli/render/akuma.js +211 -116
- package/build/src/cli/render/audit.d.ts +3 -0
- package/build/src/cli/render/audit.js +104 -0
- package/build/src/cli/render/contract.d.ts +3 -3
- package/build/src/cli/render/contract.js +192 -79
- package/build/src/cli/render/kanshi.js +263 -168
- package/build/src/cli/render/receipt.d.ts +19 -0
- package/build/src/cli/render/receipt.js +106 -0
- package/build/src/cli/render/refusal.d.ts +16 -2
- package/build/src/cli/render/refusal.js +88 -20
- package/build/src/cli/render/region.d.ts +2 -0
- package/build/src/cli/render/region.js +17 -0
- package/build/src/cli/render/task.d.ts +2 -1
- package/build/src/cli/render/task.js +223 -60
- package/build/src/cli/render/terminal.d.ts +7 -0
- package/build/src/cli/render/terminal.js +46 -0
- package/build/src/cli/render/text.js +6 -3
- package/build/src/cli/result.d.ts +115 -20
- package/build/src/cli/usage.d.ts +3 -0
- package/build/src/cli/usage.js +7 -0
- package/build/src/contract-worktree.d.ts +6 -5
- package/build/src/contract-worktree.js +95 -57
- package/build/src/coordination/durable-file.d.ts +4 -3
- package/build/src/coordination/durable-file.js +29 -25
- package/build/src/coordination/sqlite-transaction-lock.d.ts +4 -0
- package/build/src/coordination/sqlite-transaction-lock.js +22 -5
- package/build/src/core/facts/fold.js +1 -6
- package/build/src/core/facts/gate.d.ts +1 -0
- package/build/src/core/facts/gate.js +1 -0
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +0 -11
- package/build/src/core/verbs/deliver.d.ts +1 -1
- package/build/src/core/verbs/deliver.js +1 -7
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +4 -1
- package/build/src/dispatch/index.d.ts +2 -2
- package/build/src/dispatch/index.js +17 -17
- package/build/src/git/admission.d.ts +1 -1
- package/build/src/git/admission.js +11 -11
- package/build/src/git/hooks.js +13 -13
- package/build/src/git/integration.d.ts +14 -15
- package/build/src/git/integration.js +80 -44
- package/build/src/git/observe.d.ts +5 -3
- package/build/src/git/observe.js +18 -12
- package/build/src/git/read-observation.js +10 -9
- package/build/src/git/reconcile.d.ts +2 -0
- package/build/src/git/reconcile.js +138 -95
- package/build/src/git/repository.d.ts +27 -19
- package/build/src/git/repository.js +155 -83
- package/build/src/git/scratch.d.ts +7 -3
- package/build/src/git/scratch.js +44 -37
- package/build/src/git/target-placement.d.ts +40 -4
- package/build/src/git/target-placement.js +221 -101
- package/build/src/git/tender.d.ts +6 -5
- package/build/src/git/tender.js +24 -43
- package/build/src/git/terminal-seal.d.ts +1 -1
- package/build/src/git/terminal-seal.js +7 -5
- package/build/src/git/workspace.d.ts +36 -4
- package/build/src/git/workspace.js +53 -18
- package/build/src/identity/selector.js +1 -1
- package/build/src/index.d.ts +3 -3
- package/build/src/index.js +1 -1
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/index.js +1 -1
- package/build/src/kanshi/read.d.ts +2 -1
- package/build/src/kanshi/read.js +118 -27
- package/build/src/kanshi/report.d.ts +50 -0
- package/build/src/kanshi/select.d.ts +5 -0
- package/build/src/kanshi/select.js +32 -0
- package/build/src/library/address.d.ts +12 -3
- package/build/src/library/address.js +77 -46
- package/build/src/library/akuma-creation.d.ts +6 -1
- package/build/src/library/akuma-creation.js +86 -13
- package/build/src/library/audit.d.ts +18 -0
- package/build/src/library/audit.js +44 -0
- package/build/src/library/bind.js +4 -4
- package/build/src/library/catalog.d.ts +1 -1
- package/build/src/library/catalog.js +5 -8
- package/build/src/library/contract.d.ts +5 -6
- package/build/src/library/contract.js +11 -35
- package/build/src/library/delivery.d.ts +2 -1
- package/build/src/library/fleet.d.ts +2 -2
- package/build/src/library/fleet.js +35 -71
- package/build/src/library/keiyaku.d.ts +3 -2
- package/build/src/library/keiyaku.js +1 -0
- package/build/src/library/mutation.d.ts +7 -6
- package/build/src/library/mutation.js +23 -25
- package/build/src/library/reconcile.d.ts +29 -0
- package/build/src/library/reconcile.js +179 -0
- package/build/src/library/region.d.ts +12 -0
- package/build/src/library/region.js +15 -1
- package/build/src/library/repo.d.ts +4 -16
- package/build/src/library/repo.js +13 -38
- package/build/src/protocol/attempt.js +6 -6
- package/build/src/protocol/bind.js +4 -4
- package/build/src/protocol/intent.d.ts +15 -2
- package/build/src/protocol/intent.js +21 -6
- package/build/src/protocol/operations.d.ts +73 -22
- package/build/src/protocol/operations.js +292 -88
- package/build/src/protocol/outcome.d.ts +9 -3
- package/build/src/protocol/outcome.js +3 -1
- package/build/src/protocol/placement.d.ts +15 -4
- package/build/src/protocol/placement.js +58 -25
- package/build/src/protocol/read/status.d.ts +8 -1
- package/build/src/protocol/read/status.js +61 -14
- package/build/src/runtime/proc/line-rpc.d.ts +3 -8
- package/build/src/runtime/proc/line-rpc.js +16 -43
- package/build/src/runtime/proc/run.d.ts +15 -29
- package/build/src/runtime/proc/run.js +113 -105
- package/build/src/runtime/proc/stdio.d.ts +18 -0
- package/build/src/runtime/proc/stdio.js +58 -0
- package/build/src/settings.d.ts +2 -2
- package/build/src/settings.js +8 -8
- package/build/src/settlement/fence.d.ts +0 -4
- package/build/src/settlement/fence.js +0 -9
- package/build/src/settlement/holder.d.ts +11 -1
- package/build/src/settlement/holder.js +25 -0
- package/build/src/settlement/settle.d.ts +1 -1
- package/build/src/settlement/settle.js +52 -89
- package/build/src/task/board.d.ts +3 -3
- package/build/src/task/board.js +6 -9
- package/build/src/task/compose.d.ts +1 -1
- package/build/src/task/compose.js +18 -10
- package/build/src/task/context.d.ts +3 -3
- package/build/src/task/context.js +14 -14
- package/build/src/task/document.d.ts +2 -1
- package/build/src/task/document.js +15 -5
- package/build/src/task/index.d.ts +19 -7
- package/build/src/task/index.js +42 -23
- package/build/src/task/operations.d.ts +15 -9
- package/build/src/task/operations.js +78 -48
- package/build/src/task/query.d.ts +67 -0
- package/build/src/task/query.js +279 -0
- package/build/src/task/store.d.ts +2 -2
- package/build/src/task/store.js +40 -25
- package/build/src/verification/execution.d.ts +4 -2
- package/build/src/verification/execution.js +9 -5
- package/build/src/workspace-place.d.ts +41 -0
- package/build/src/workspace-place.js +386 -0
- package/build/src/world.d.ts +13 -2
- package/build/src/world.js +81 -48
- package/package.json +3 -2
- package/build/src/protocol/read/audit.d.ts +0 -31
- package/build/src/protocol/read/audit.js +0 -55
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { realpath } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { NoGitWorldError, Repo } from "../index.js";
|
|
4
|
+
import { World, WorldError } from "../world.js";
|
|
5
|
+
import { CliUsageError } from "./parse.js";
|
|
6
|
+
async function canonicalInvocationCwd(input) {
|
|
7
|
+
try {
|
|
8
|
+
return await realpath(input);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new CliUsageError(`invocation cwd is not an existing directory: ${input}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function discoverRepoAt(coordinate) {
|
|
15
|
+
try {
|
|
16
|
+
return { kind: "present", repo: await Repo.at({ path: coordinate }) };
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof NoGitWorldError)
|
|
20
|
+
return { kind: "absent", error };
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function repoPolicy(command) {
|
|
25
|
+
switch (command.command) {
|
|
26
|
+
case "bind":
|
|
27
|
+
case "amend":
|
|
28
|
+
case "deliver":
|
|
29
|
+
case "review":
|
|
30
|
+
case "arc":
|
|
31
|
+
case "abandon":
|
|
32
|
+
case "audit":
|
|
33
|
+
case "reconcile":
|
|
34
|
+
case "show":
|
|
35
|
+
case "region":
|
|
36
|
+
return { use: "required", acceptsExplicit: true };
|
|
37
|
+
case "ls":
|
|
38
|
+
return { use: command.query.kind === "contracts" ? "required" : "none", acceptsExplicit: false };
|
|
39
|
+
case "status":
|
|
40
|
+
case "tell":
|
|
41
|
+
case "history":
|
|
42
|
+
return { use: "optional", acceptsExplicit: false };
|
|
43
|
+
case "fork":
|
|
44
|
+
return { use: "optional", acceptsExplicit: true };
|
|
45
|
+
case "wait":
|
|
46
|
+
case "kill": {
|
|
47
|
+
const contractSelector = command.akuma.some((selector) => selector.startsWith("kei/"));
|
|
48
|
+
return { use: contractSelector ? "required" : "optional", acceptsExplicit: contractSelector };
|
|
49
|
+
}
|
|
50
|
+
case "call":
|
|
51
|
+
return {
|
|
52
|
+
use: command.contract === undefined ? "none" : "required",
|
|
53
|
+
acceptsExplicit: command.contract !== undefined,
|
|
54
|
+
};
|
|
55
|
+
case "settings":
|
|
56
|
+
case "task":
|
|
57
|
+
case "install":
|
|
58
|
+
return { use: "none", acceptsExplicit: false };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function refuseUnusedRepo(command) {
|
|
62
|
+
if (command.command === "call")
|
|
63
|
+
throw new CliUsageError("--repo has no consumer without --contract");
|
|
64
|
+
throw new CliUsageError(`--repo has no consumer for ${command.command}`);
|
|
65
|
+
}
|
|
66
|
+
export function assertExplicitRepoUse(command, repo) {
|
|
67
|
+
if (repo !== undefined && !repoPolicy(command).acceptsExplicit)
|
|
68
|
+
refuseUnusedRepo(command);
|
|
69
|
+
}
|
|
70
|
+
function repoFor(use, discovery) {
|
|
71
|
+
if (use === "none")
|
|
72
|
+
return undefined;
|
|
73
|
+
if (discovery.kind === "present")
|
|
74
|
+
return discovery.repo;
|
|
75
|
+
if (use === "required")
|
|
76
|
+
throw discovery.error;
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
async function resolveWorld(cwd, repo) {
|
|
80
|
+
try {
|
|
81
|
+
const resolution = await World.resolve({ cwd, ...(repo === undefined ? {} : { repositoryRoot: repo.root }) });
|
|
82
|
+
return {
|
|
83
|
+
root: resolution.root,
|
|
84
|
+
candidate: resolution.candidate,
|
|
85
|
+
async establish() {
|
|
86
|
+
try {
|
|
87
|
+
return await resolution.establish();
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof WorldError)
|
|
91
|
+
throw new CliUsageError(error.message);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error instanceof WorldError)
|
|
99
|
+
throw new CliUsageError(error.message);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export async function resolveCliCoordinates(input) {
|
|
104
|
+
const processCwd = resolve(input.processCwd ?? ".");
|
|
105
|
+
const cwd = await canonicalInvocationCwd(resolve(processCwd, input.cwd ?? "."));
|
|
106
|
+
const invocationRepo = await discoverRepoAt(cwd);
|
|
107
|
+
const selectedRepo = input.repo === undefined
|
|
108
|
+
? invocationRepo
|
|
109
|
+
: await discoverRepoAt(resolve(cwd, input.repo));
|
|
110
|
+
const worldRepo = invocationRepo.kind === "present" ? invocationRepo.repo : undefined;
|
|
111
|
+
const repo = repoFor(repoPolicy(input.command).use, selectedRepo);
|
|
112
|
+
const world = await resolveWorld(cwd, worldRepo);
|
|
113
|
+
return {
|
|
114
|
+
cwd,
|
|
115
|
+
...(repo === undefined ? {} : { repo }),
|
|
116
|
+
world: world.root,
|
|
117
|
+
candidateWorld: world.candidate,
|
|
118
|
+
establishWorld: world.establish,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorldRoot } from "../world.js";
|
|
2
|
+
import type { BindDraftReceipt } from "./result.js";
|
|
3
|
+
export declare class BindDraftError extends Error {
|
|
4
|
+
readonly original: unknown;
|
|
5
|
+
readonly draft: BindDraftReceipt;
|
|
6
|
+
constructor(original: unknown, draft: BindDraftReceipt);
|
|
7
|
+
}
|
|
8
|
+
export declare function preserveBindDraft(world: WorldRoot, markdown: string, now?: number): Promise<BindDraftReceipt>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstatSync, mkdirSync, readFileSync, readdirSync, unlinkSync, utimesSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { repairDerivedFile, replaceFileDurably } from "../coordination/durable-file.js";
|
|
5
|
+
const RETENTION_MS = 7 * 24 * 60 * 60 * 1_000;
|
|
6
|
+
const DRAFT_NAME = /^bind-[0-9a-f]{64}\.md$/u;
|
|
7
|
+
export class BindDraftError extends Error {
|
|
8
|
+
original;
|
|
9
|
+
draft;
|
|
10
|
+
constructor(original, draft) {
|
|
11
|
+
super(original instanceof Error ? original.message : String(original));
|
|
12
|
+
this.name = "BindDraftError";
|
|
13
|
+
this.original = original;
|
|
14
|
+
this.draft = draft;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function diagnostic(error) {
|
|
18
|
+
return error instanceof Error ? error.message : String(error);
|
|
19
|
+
}
|
|
20
|
+
function sweep(directory, now) {
|
|
21
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
22
|
+
if (!entry.isFile() || !DRAFT_NAME.test(entry.name))
|
|
23
|
+
continue;
|
|
24
|
+
const path = join(directory, entry.name);
|
|
25
|
+
try {
|
|
26
|
+
if (now - lstatSync(path).mtimeMs > RETENTION_MS)
|
|
27
|
+
unlinkSync(path);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error.code !== "ENOENT")
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function preserveBindDraft(world, markdown, now = Date.now()) {
|
|
36
|
+
const digest = createHash("sha256").update(markdown, "utf8").digest("hex");
|
|
37
|
+
const name = `bind-${digest}.md`;
|
|
38
|
+
const relativePath = `.keiyaku/draft/${name}`;
|
|
39
|
+
const directory = join(world, ".keiyaku", "draft");
|
|
40
|
+
const path = join(directory, name);
|
|
41
|
+
const warnings = [];
|
|
42
|
+
try {
|
|
43
|
+
mkdirSync(directory, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return { warning: `bind draft could not be preserved: ${diagnostic(error)}` };
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
await repairDerivedFile(join(directory, ".gitignore"), "*\n");
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
warnings.push(`bind draft ignore could not be maintained: ${diagnostic(error)}`);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
let equal = false;
|
|
56
|
+
try {
|
|
57
|
+
const status = lstatSync(path);
|
|
58
|
+
equal = status.isFile() && !status.isSymbolicLink() && readFileSync(path).equals(Buffer.from(markdown));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error.code !== "ENOENT")
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
if (equal) {
|
|
65
|
+
try {
|
|
66
|
+
const touched = new Date(now);
|
|
67
|
+
utimesSync(path, touched, touched);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error.code !== "ENOENT")
|
|
71
|
+
throw error;
|
|
72
|
+
await replaceFileDurably(path, markdown);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
await replaceFileDurably(path, markdown);
|
|
77
|
+
}
|
|
78
|
+
if (!readFileSync(path).equals(Buffer.from(markdown))) {
|
|
79
|
+
throw new Error(`bind draft bytes do not match their content address: ${relativePath}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
warnings.push(`bind draft could not be preserved: ${diagnostic(error)}`);
|
|
84
|
+
return { warning: warnings.join("; ") };
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
sweep(directory, now);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
warnings.push(`bind draft sweep failed: ${diagnostic(error)}`);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
path: relativePath,
|
|
94
|
+
...(warnings.length === 0 ? {} : { warning: warnings.join("; ") }),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { type ContractId, type Settings } from "../index.js";
|
|
1
|
+
import { type ActorId, type ContractId, type Settings } from "../index.js";
|
|
2
2
|
import { type AkumaInvocationResult } from "./commands/akuma-invoke.js";
|
|
3
3
|
import { type InstallInvocationResult } from "./commands/install.js";
|
|
4
4
|
import { type TaskInvocationResult } from "./commands/task-invoke.js";
|
|
5
5
|
import { type ParsedExecution } from "./parse.js";
|
|
6
6
|
import type { InvocationResult } from "./result.js";
|
|
7
|
-
export type { AcceptedFact,
|
|
7
|
+
export type { AcceptedFact, InvocationResult, Lag } from "./result.js";
|
|
8
8
|
type InvokeRuntime = Readonly<{
|
|
9
9
|
cwd?: string;
|
|
10
10
|
environment?: NodeJS.ProcessEnv;
|
|
11
|
-
readStdin?: () => string
|
|
11
|
+
readStdin?: () => Promise<string>;
|
|
12
|
+
actor?: ActorId;
|
|
12
13
|
}>;
|
|
13
14
|
export type SettingsInvocationResult = Readonly<{
|
|
14
15
|
kind: "settings";
|