@astrosheep/keiyaku 4.0.0 → 4.0.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 +133 -8
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +4 -4
- package/build/integrations/marketplace/plugins/keiyaku/opencode.js +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/package.json +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +13 -5
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -32
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +134 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +41 -6
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +262 -46
- package/build/src/akuma/abort.d.ts +2 -0
- package/build/src/akuma/abort.js +50 -0
- package/build/src/akuma/akuma.d.ts +50 -33
- package/build/src/akuma/akuma.js +175 -127
- package/build/src/akuma/archetype.d.ts +14 -5
- package/build/src/akuma/archetype.js +85 -39
- package/build/src/akuma/body.d.ts +3 -5
- package/build/src/akuma/body.js +490 -183
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +22 -0
- package/build/src/akuma/heart/facts.d.ts +88 -45
- package/build/src/akuma/heart/facts.js +19 -8
- package/build/src/akuma/heart/index.d.ts +64 -55
- package/build/src/akuma/heart/index.js +172 -252
- package/build/src/akuma/heart/rows.d.ts +38 -83
- package/build/src/akuma/heart/rows.js +117 -155
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +61 -22
- 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 +47 -0
- package/build/src/akuma/heart/storage.js +224 -0
- package/build/src/akuma/heart/tells.d.ts +12 -0
- package/build/src/akuma/heart/tells.js +79 -0
- package/build/src/akuma/heart/timeline.d.ts +15 -0
- package/build/src/akuma/heart/timeline.js +86 -0
- package/build/src/akuma/identity.d.ts +2 -2
- package/build/src/akuma/identity.js +9 -9
- package/build/src/akuma/index.d.ts +10 -3
- package/build/src/akuma/index.js +7 -1
- package/build/src/akuma/projection.d.ts +176 -0
- package/build/src/akuma/projection.js +256 -0
- 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 +67 -13
- package/build/src/akuma/provider.js +172 -105
- 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.d.ts → claude/events.d.ts} +9 -41
- package/build/src/akuma/providers/claude/events.js +238 -0
- package/build/src/akuma/providers/claude/index.d.ts +47 -0
- package/build/src/akuma/providers/claude/index.js +279 -0
- package/build/src/akuma/providers/claude/input.d.ts +13 -0
- package/build/src/akuma/providers/claude/input.js +109 -0
- package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
- package/build/src/akuma/providers/codex-app-server/events.js +15 -12
- package/build/src/akuma/providers/codex-app-server/index.d.ts +15 -13
- package/build/src/akuma/providers/codex-app-server/index.js +77 -33
- 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 +35 -56
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +54 -0
- package/build/src/akuma/providers/opencode-sdk/events.js +235 -0
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +33 -0
- package/build/src/akuma/providers/opencode-sdk/index.js +308 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +26 -0
- package/build/src/akuma/providers/opencode-sdk/session.js +63 -0
- package/build/src/akuma/providers/pi/events.d.ts +33 -0
- package/build/src/akuma/providers/pi/events.js +166 -0
- package/build/src/akuma/providers/pi/index.d.ts +11 -0
- package/build/src/akuma/providers/pi/index.js +191 -0
- package/build/src/akuma/publication.d.ts +3 -3
- package/build/src/akuma/publication.js +28 -40
- package/build/src/akuma/requests.d.ts +9 -6
- package/build/src/akuma/requests.js +95 -65
- package/build/src/alias/index.d.ts +4 -3
- package/build/src/alias/index.js +12 -13
- 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/body/render.js +2 -1
- package/build/src/body/shape.js +7 -1
- package/build/src/body/verification.js +19 -4
- package/build/src/cli/accepted.d.ts +18 -12
- package/build/src/cli/accepted.js +73 -34
- package/build/src/cli/actor.js +3 -3
- package/build/src/cli/commands/akuma-invoke.d.ts +44 -19
- package/build/src/cli/commands/akuma-invoke.js +101 -52
- package/build/src/cli/commands/akuma.d.ts +27 -9
- package/build/src/cli/commands/akuma.js +151 -80
- package/build/src/cli/commands/contract.d.ts +155 -0
- package/build/src/cli/commands/contract.js +20 -0
- package/build/src/cli/commands/install.js +2 -0
- package/build/src/cli/commands/task-invoke.d.ts +19 -4
- package/build/src/cli/commands/task-invoke.js +65 -17
- 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 +52 -14
- 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 +9 -3
- package/build/src/cli/invoke.js +287 -108
- package/build/src/cli/main.js +54 -7
- package/build/src/cli/parse.d.ts +21 -117
- package/build/src/cli/parse.js +79 -84
- 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 +4 -2
- package/build/src/cli/render/akuma-tool.js +35 -5
- package/build/src/cli/render/akuma.d.ts +3 -1
- package/build/src/cli/render/akuma.js +247 -212
- package/build/src/cli/render/audit.d.ts +3 -0
- package/build/src/cli/render/audit.js +104 -0
- package/build/src/cli/render/catalog.d.ts +2 -0
- package/build/src/cli/render/catalog.js +16 -0
- package/build/src/cli/render/contract.d.ts +3 -3
- package/build/src/cli/render/contract.js +200 -54
- package/build/src/cli/render/kanshi.js +272 -129
- 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 -3
- 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 +20 -0
- package/build/src/cli/render/terminal.js +121 -0
- package/build/src/cli/render/text.js +11 -3
- package/build/src/cli/result.d.ts +126 -19
- package/build/src/cli/usage.d.ts +1 -0
- package/build/src/cli/usage.js +3 -0
- package/build/src/contract-worktree.d.ts +44 -0
- package/build/src/contract-worktree.js +251 -0
- package/build/src/coordination/durable-file.d.ts +5 -1
- package/build/src/coordination/durable-file.js +57 -10
- 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/codec.js +23 -4
- package/build/src/core/facts/eligibility.d.ts +1 -10
- package/build/src/core/facts/eligibility.js +0 -49
- 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/facts/observation.d.ts +3 -0
- package/build/src/core/facts/observation.js +12 -0
- package/build/src/core/facts/types.d.ts +10 -3
- package/build/src/core/subject.js +2 -2
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +3 -18
- package/build/src/core/verbs/bind.js +2 -16
- package/build/src/core/verbs/deliver.d.ts +1 -1
- package/build/src/core/verbs/deliver.js +14 -4
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +7 -9
- package/build/src/dispatch/index.d.ts +5 -3
- package/build/src/dispatch/index.js +30 -21
- package/build/src/duration.d.ts +10 -0
- package/build/src/duration.js +22 -0
- package/build/src/git/admission.d.ts +2 -2
- package/build/src/git/admission.js +33 -23
- package/build/src/git/hooks.d.ts +15 -0
- package/build/src/git/hooks.js +70 -18
- package/build/src/git/identity.d.ts +5 -1
- package/build/src/git/identity.js +23 -4
- package/build/src/git/integration.d.ts +48 -0
- package/build/src/git/integration.js +250 -0
- package/build/src/git/observe.d.ts +29 -15
- package/build/src/git/observe.js +185 -76
- package/build/src/git/read-observation.d.ts +41 -0
- package/build/src/git/read-observation.js +361 -0
- package/build/src/git/reconcile.d.ts +17 -5
- package/build/src/git/reconcile.js +305 -109
- package/build/src/git/repository.d.ts +41 -18
- package/build/src/git/repository.js +220 -114
- package/build/src/git/scratch.d.ts +17 -0
- package/build/src/git/scratch.js +73 -0
- package/build/src/git/target-placement.d.ts +92 -0
- package/build/src/git/target-placement.js +375 -0
- package/build/src/git/tender.d.ts +49 -0
- package/build/src/git/tender.js +63 -0
- package/build/src/git/terminal-seal.d.ts +24 -0
- package/build/src/git/terminal-seal.js +89 -0
- package/build/src/git/tree.d.ts +2 -2
- package/build/src/git/tree.js +4 -0
- package/build/src/git/workspace.d.ts +53 -0
- package/build/src/git/workspace.js +139 -0
- package/build/src/identity/selector.d.ts +6 -0
- package/build/src/identity/selector.js +19 -0
- package/build/src/index.d.ts +4 -2
- package/build/src/index.js +2 -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 +7 -3
- package/build/src/kanshi/read.js +245 -45
- package/build/src/kanshi/report.d.ts +81 -6
- package/build/src/kanshi/select.d.ts +5 -0
- package/build/src/kanshi/select.js +33 -1
- package/build/src/library/address.d.ts +57 -0
- package/build/src/library/address.js +165 -0
- package/build/src/library/akuma-creation.d.ts +16 -7
- package/build/src/library/akuma-creation.js +96 -22
- package/build/src/library/audit.d.ts +18 -0
- package/build/src/library/audit.js +44 -0
- package/build/src/library/bind.d.ts +21 -0
- package/build/src/library/bind.js +56 -0
- package/build/src/library/catalog.d.ts +58 -0
- package/build/src/library/catalog.js +69 -0
- package/build/src/library/configuration.d.ts +6 -15
- package/build/src/library/configuration.js +14 -17
- package/build/src/library/contract.d.ts +23 -49
- package/build/src/library/contract.js +171 -185
- package/build/src/library/delivery.d.ts +24 -0
- package/build/src/library/delivery.js +21 -0
- package/build/src/library/fleet.d.ts +65 -0
- package/build/src/library/fleet.js +153 -0
- package/build/src/library/input.d.ts +3 -0
- package/build/src/library/input.js +19 -0
- package/build/src/library/keiyaku.d.ts +18 -3
- package/build/src/library/keiyaku.js +12 -1
- package/build/src/library/mutation.d.ts +39 -0
- package/build/src/library/mutation.js +37 -0
- package/build/src/library/reconcile.d.ts +29 -0
- package/build/src/library/reconcile.js +179 -0
- package/build/src/library/refusal.d.ts +21 -0
- package/build/src/library/refusal.js +29 -0
- package/build/src/library/region.d.ts +14 -1
- package/build/src/library/region.js +18 -4
- package/build/src/library/repo.d.ts +4 -13
- package/build/src/library/repo.js +14 -24
- package/build/src/protocol/attempt.d.ts +16 -3
- package/build/src/protocol/attempt.js +41 -10
- package/build/src/protocol/bind.d.ts +9 -2
- package/build/src/protocol/bind.js +48 -40
- package/build/src/protocol/intent.d.ts +57 -20
- package/build/src/protocol/intent.js +55 -79
- package/build/src/protocol/operations.d.ts +152 -43
- package/build/src/protocol/operations.js +482 -166
- package/build/src/protocol/outcome.d.ts +14 -3
- package/build/src/protocol/outcome.js +11 -3
- package/build/src/protocol/placement.d.ts +41 -0
- package/build/src/protocol/placement.js +147 -0
- package/build/src/protocol/read/documents.d.ts +2 -2
- package/build/src/protocol/read/documents.js +4 -4
- package/build/src/protocol/read/status.d.ts +18 -5
- package/build/src/protocol/read/status.js +73 -13
- package/build/src/protocol/run.d.ts +49 -7
- package/build/src/protocol/run.js +53 -25
- package/build/src/runtime/proc/line-rpc.d.ts +4 -8
- package/build/src/runtime/proc/line-rpc.js +22 -28
- package/build/src/runtime/proc/run.d.ts +23 -21
- package/build/src/runtime/proc/run.js +123 -89
- 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 +7 -1
- package/build/src/settings.js +32 -17
- package/build/src/settlement/fence.d.ts +5 -0
- package/build/src/settlement/fence.js +14 -0
- package/build/src/settlement/holder.d.ts +35 -4
- package/build/src/settlement/holder.js +127 -28
- package/build/src/settlement/settle.d.ts +9 -1
- package/build/src/settlement/settle.js +74 -37
- package/build/src/task/board.d.ts +23 -5
- package/build/src/task/board.js +17 -10
- package/build/src/task/compose.d.ts +2 -2
- package/build/src/task/compose.js +18 -10
- package/build/src/task/context.d.ts +3 -3
- package/build/src/task/context.js +15 -20
- package/build/src/task/document.d.ts +2 -1
- package/build/src/task/document.js +15 -5
- package/build/src/task/index.d.ts +27 -15
- package/build/src/task/index.js +57 -35
- package/build/src/task/operations.d.ts +38 -13
- package/build/src/task/operations.js +80 -46
- package/build/src/task/query.d.ts +67 -0
- package/build/src/task/query.js +279 -0
- package/build/src/task/store.d.ts +5 -7
- package/build/src/task/store.js +43 -28
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/execution.d.ts +51 -0
- package/build/src/verification/execution.js +108 -0
- package/build/src/workspace-place.d.ts +41 -0
- package/build/src/workspace-place.js +386 -0
- package/build/src/world.d.ts +24 -0
- package/build/src/world.js +136 -0
- package/package.json +8 -4
- package/build/src/akuma/activity.d.ts +0 -66
- package/build/src/akuma/activity.js +0 -139
- package/build/src/akuma/providers/claude.js +0 -305
- package/build/src/context-root.d.ts +0 -4
- package/build/src/context-root.js +0 -15
- package/build/src/git/delivery.d.ts +0 -20
- package/build/src/git/delivery.js +0 -109
- package/build/src/git/verification.d.ts +0 -14
- package/build/src/git/verification.js +0 -56
- package/build/src/protocol/read/audit.d.ts +0 -25
- package/build/src/protocol/read/audit.js +0 -39
- package/build/src/verification/producer.d.ts +0 -23
- package/build/src/verification/producer.js +0 -54
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { gitObjectId, gitObjectIdForSnapshot, mintSnapshotId } from "./identity.js";
|
|
2
|
+
import { runGit } from "./repository.js";
|
|
3
|
+
import { captureWorkspaceTree } from "./workspace.js";
|
|
4
|
+
export function terminalSealSnapshots(state) {
|
|
5
|
+
return [...new Set([
|
|
6
|
+
state.coordinates.start,
|
|
7
|
+
...(state.delivery === null ? [] : [
|
|
8
|
+
state.delivery.data.tenderSnapshot,
|
|
9
|
+
state.delivery.data.integration.snapshot,
|
|
10
|
+
]),
|
|
11
|
+
])];
|
|
12
|
+
}
|
|
13
|
+
function commitMetadata(snapshot, result) {
|
|
14
|
+
if (result === undefined || result.kind === "missing") {
|
|
15
|
+
throw new Error(`terminal seal commit is missing: ${snapshot}`);
|
|
16
|
+
}
|
|
17
|
+
if (result.type !== "commit")
|
|
18
|
+
throw new Error(`terminal seal snapshot is not a commit: ${snapshot}`);
|
|
19
|
+
const headerEnd = result.bytes.indexOf("\n\n");
|
|
20
|
+
if (headerEnd < 0)
|
|
21
|
+
throw new Error(`terminal seal commit has no headers: ${snapshot}`);
|
|
22
|
+
const headers = result.bytes.subarray(0, headerEnd).toString("ascii").split("\n");
|
|
23
|
+
const treeHeader = headers[0];
|
|
24
|
+
if (treeHeader === undefined || !treeHeader.startsWith("tree ")) {
|
|
25
|
+
throw new Error(`terminal seal commit has no root tree: ${snapshot}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
tree: gitObjectId(treeHeader.slice("tree ".length), "terminal seal tree"),
|
|
29
|
+
parents: headers
|
|
30
|
+
.filter((header) => header.startsWith("parent "))
|
|
31
|
+
.map((header) => mintSnapshotId(header.slice("parent ".length))),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function terminalSealExpectations(state, objects) {
|
|
35
|
+
const snapshots = terminalSealSnapshots(state);
|
|
36
|
+
const metadata = new Map(snapshots.map((snapshot) => [
|
|
37
|
+
snapshot,
|
|
38
|
+
commitMetadata(snapshot, objects.get(gitObjectIdForSnapshot(snapshot))),
|
|
39
|
+
]));
|
|
40
|
+
const treeBySnapshot = new Map([...metadata].map(([snapshot, commit]) => [snapshot, commit.tree]));
|
|
41
|
+
if (state.delivery === null) {
|
|
42
|
+
return { heads: [state.coordinates.start], trees: [...treeBySnapshot.values()], treeBySnapshot };
|
|
43
|
+
}
|
|
44
|
+
const tender = state.delivery.data.tenderSnapshot;
|
|
45
|
+
const tenderMetadata = metadata.get(tender);
|
|
46
|
+
if (tenderMetadata === undefined)
|
|
47
|
+
throw new Error(`terminal seal metadata was not resolved: ${tender}`);
|
|
48
|
+
const [tenderParent] = tenderMetadata.parents;
|
|
49
|
+
return {
|
|
50
|
+
heads: [...new Set([
|
|
51
|
+
state.coordinates.start,
|
|
52
|
+
...(tenderParent === undefined ? [] : [tenderParent]),
|
|
53
|
+
tender,
|
|
54
|
+
state.delivery.data.integration.snapshot,
|
|
55
|
+
])],
|
|
56
|
+
trees: [...treeBySnapshot.values()],
|
|
57
|
+
treeBySnapshot,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function changedPaths(repository, left, right) {
|
|
61
|
+
const fields = (await runGit(repository, ["diff", "--name-only", "-z", left, right])).toString("utf8").split("\0");
|
|
62
|
+
if (fields.at(-1) !== "")
|
|
63
|
+
throw new Error("Git tree diff paths are not NUL terminated");
|
|
64
|
+
return fields.slice(0, -1).sort();
|
|
65
|
+
}
|
|
66
|
+
export async function unsealedBytes(repository, path, expected) {
|
|
67
|
+
const workspace = await captureWorkspaceTree(repository, path);
|
|
68
|
+
const headIsSealed = expected.heads.includes(workspace.head);
|
|
69
|
+
if (workspace.changes.submodules.length > 0) {
|
|
70
|
+
return {
|
|
71
|
+
kind: "unsealed-bytes",
|
|
72
|
+
path,
|
|
73
|
+
paths: workspace.changes.submodules,
|
|
74
|
+
...(headIsSealed ? {} : { head: workspace.head }),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (headIsSealed && expected.trees.includes(workspace.tree))
|
|
78
|
+
return null;
|
|
79
|
+
const alternatives = [];
|
|
80
|
+
for (const tree of expected.trees)
|
|
81
|
+
alternatives.push(await changedPaths(repository, tree, workspace.tree));
|
|
82
|
+
alternatives.sort((left, right) => left.length - right.length || left.join("\0").localeCompare(right.join("\0")));
|
|
83
|
+
return {
|
|
84
|
+
kind: "unsealed-bytes",
|
|
85
|
+
path,
|
|
86
|
+
paths: alternatives[0] ?? [],
|
|
87
|
+
...(headIsSealed ? {} : { head: workspace.head }),
|
|
88
|
+
};
|
|
89
|
+
}
|
package/build/src/git/tree.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type TreeChange = Readonly<{
|
|
|
7
7
|
oid: string;
|
|
8
8
|
mode?: string;
|
|
9
9
|
type?: string;
|
|
10
|
-
}
|
|
10
|
+
}> | null;
|
|
11
11
|
type MutableTreeNode = Readonly<{
|
|
12
12
|
files: Map<string, TreeChange>;
|
|
13
13
|
directories: Map<string, MutableTreeNode>;
|
|
@@ -25,7 +25,7 @@ export declare function treeUpdate(changes: ReadonlyMap<string, TreeChange>): Tr
|
|
|
25
25
|
export declare function parseTreeObject(bytes: Buffer, oidBytes: number): Map<string, TreeEntry>;
|
|
26
26
|
export declare function prepareTreeUpdate(input: Readonly<{
|
|
27
27
|
update: TreeUpdate;
|
|
28
|
-
bases: ReadonlyMap<string,
|
|
28
|
+
bases: ReadonlyMap<string, ReadonlyMap<string, TreeEntry>>;
|
|
29
29
|
oidBytes: number;
|
|
30
30
|
}>): Readonly<{
|
|
31
31
|
root: string;
|
package/build/src/git/tree.js
CHANGED
|
@@ -86,6 +86,10 @@ function record(name, change) {
|
|
|
86
86
|
function prepareNode(node, path, bases, oidBytes, prepared) {
|
|
87
87
|
const entries = new Map(bases.get(path) ?? []);
|
|
88
88
|
for (const [name, change] of node.files) {
|
|
89
|
+
if (change === null) {
|
|
90
|
+
entries.delete(name);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
89
93
|
entries.set(name, {
|
|
90
94
|
oid: change.oid,
|
|
91
95
|
mode: change.mode ?? "100644",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SnapshotId } from "../core/facts/types.js";
|
|
2
|
+
import { type GitObjectId } from "./identity.js";
|
|
3
|
+
import { type GitRepository } from "./repository.js";
|
|
4
|
+
export type WorkspaceChanges = Readonly<{
|
|
5
|
+
staged: readonly string[];
|
|
6
|
+
unstaged: readonly string[];
|
|
7
|
+
untracked: readonly string[];
|
|
8
|
+
submodules: readonly string[];
|
|
9
|
+
}>;
|
|
10
|
+
export type WorkspaceTree = Readonly<{
|
|
11
|
+
tree: GitObjectId;
|
|
12
|
+
head: SnapshotId;
|
|
13
|
+
dirty: boolean;
|
|
14
|
+
changes: WorkspaceChanges;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function worktreePath(repository: GitRepository, place: string): string;
|
|
17
|
+
export declare function withPrivateGitIndex<Value>(action: (environment: Readonly<{
|
|
18
|
+
GIT_INDEX_FILE: string;
|
|
19
|
+
}>) => Value | PromiseLike<Value>): Promise<Value>;
|
|
20
|
+
export type WorkspaceChangeCounts = Readonly<{
|
|
21
|
+
staged: number;
|
|
22
|
+
unstaged: number;
|
|
23
|
+
untracked: number;
|
|
24
|
+
submodules: number;
|
|
25
|
+
}>;
|
|
26
|
+
export type ContractWorkspaceLocation = Readonly<{
|
|
27
|
+
kind: "worktree";
|
|
28
|
+
path: string;
|
|
29
|
+
}> | Readonly<{
|
|
30
|
+
kind: "here";
|
|
31
|
+
}>;
|
|
32
|
+
export type ContractWorkspaceObservation = Readonly<{
|
|
33
|
+
kind: "clean" | "dirty";
|
|
34
|
+
location: ContractWorkspaceLocation;
|
|
35
|
+
counts: WorkspaceChangeCounts;
|
|
36
|
+
}> | Readonly<{
|
|
37
|
+
kind: "unavailable";
|
|
38
|
+
location: ContractWorkspaceLocation;
|
|
39
|
+
}> | Readonly<{
|
|
40
|
+
kind: "unappointed";
|
|
41
|
+
}>;
|
|
42
|
+
export type ContractTargetLag = Readonly<{
|
|
43
|
+
kind: "counted";
|
|
44
|
+
behind: number;
|
|
45
|
+
}> | Readonly<{
|
|
46
|
+
kind: "unknown";
|
|
47
|
+
}> | Readonly<{
|
|
48
|
+
kind: "none";
|
|
49
|
+
}>;
|
|
50
|
+
export declare function observeWorkspace(repository: GitRepository, location: ContractWorkspaceLocation, workspace: string): Promise<ContractWorkspaceObservation>;
|
|
51
|
+
export declare function observeTargetLag(repository: GitRepository, workspace: string, head: SnapshotId | null | undefined): Promise<ContractTargetLag>;
|
|
52
|
+
/** Capture tracked and untracked workspace bytes without changing its real index. */
|
|
53
|
+
export declare function captureWorkspaceTree(repository: GitRepository, workspace: string): Promise<WorkspaceTree>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { gitObjectId, mintSnapshotId } from "./identity.js";
|
|
5
|
+
import { runGit, runGitWithEnvironment } from "./repository.js";
|
|
6
|
+
const WORKTREE_DIRECTORY = ["keiyaku", "wt"];
|
|
7
|
+
export function worktreePath(repository, place) {
|
|
8
|
+
return resolve(repository.commonDirectory, ...WORKTREE_DIRECTORY, place);
|
|
9
|
+
}
|
|
10
|
+
export async function withPrivateGitIndex(action) {
|
|
11
|
+
const directory = await mkdtemp(join(tmpdir(), "keiyaku-v4-index-"));
|
|
12
|
+
try {
|
|
13
|
+
return await action({ GIT_INDEX_FILE: join(directory, "index") });
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
await rm(directory, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function fields(record, count) {
|
|
20
|
+
const result = [];
|
|
21
|
+
let start = 0;
|
|
22
|
+
while (result.length < count - 1) {
|
|
23
|
+
const separator = record.indexOf(" ", start);
|
|
24
|
+
if (separator < 0)
|
|
25
|
+
throw new Error(`malformed workspace status record: ${record}`);
|
|
26
|
+
result.push(record.slice(start, separator));
|
|
27
|
+
start = separator + 1;
|
|
28
|
+
}
|
|
29
|
+
result.push(record.slice(start));
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
async function workspaceChanges(repository, workspace) {
|
|
33
|
+
const records = (await runGit(repository, [
|
|
34
|
+
"-C", workspace,
|
|
35
|
+
"status", "--porcelain=v2", "-z", "--untracked-files=all", "--ignore-submodules=none",
|
|
36
|
+
])).toString("utf8").split("\0");
|
|
37
|
+
const staged = new Set();
|
|
38
|
+
const unstaged = new Set();
|
|
39
|
+
const untracked = new Set();
|
|
40
|
+
const submodules = new Set();
|
|
41
|
+
for (let index = 0; index < records.length - 1; index += 1) {
|
|
42
|
+
const record = records[index];
|
|
43
|
+
const kind = record[0];
|
|
44
|
+
if (kind === "?") {
|
|
45
|
+
untracked.add(fields(record, 2)[1]);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (kind === "1" || kind === "2" || kind === "u") {
|
|
49
|
+
const parts = fields(record, kind === "1" ? 9 : kind === "2" ? 10 : 11);
|
|
50
|
+
const xy = parts[1];
|
|
51
|
+
const sub = parts[2];
|
|
52
|
+
const path = parts.at(-1);
|
|
53
|
+
if (xy[0] !== ".")
|
|
54
|
+
staged.add(path);
|
|
55
|
+
if (xy[1] !== ".")
|
|
56
|
+
unstaged.add(path);
|
|
57
|
+
if (sub.startsWith("S") && (sub[2] !== "." || sub[3] !== "."))
|
|
58
|
+
submodules.add(path);
|
|
59
|
+
if (kind === "2") {
|
|
60
|
+
const origin = records[index + 1];
|
|
61
|
+
if (origin === undefined)
|
|
62
|
+
throw new Error("renamed workspace status record is missing its origin path");
|
|
63
|
+
if (xy[0] !== ".")
|
|
64
|
+
staged.add(origin);
|
|
65
|
+
if (xy[1] !== ".")
|
|
66
|
+
unstaged.add(origin);
|
|
67
|
+
index += 1;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`unknown workspace status record: ${record}`);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
staged: [...staged].sort(),
|
|
75
|
+
unstaged: [...unstaged].sort(),
|
|
76
|
+
untracked: [...untracked].sort(),
|
|
77
|
+
submodules: [...submodules].sort(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function countsOf(changes) {
|
|
81
|
+
return {
|
|
82
|
+
staged: changes.staged.length,
|
|
83
|
+
unstaged: changes.unstaged.length,
|
|
84
|
+
untracked: changes.untracked.length,
|
|
85
|
+
submodules: changes.submodules.length,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export async function observeWorkspace(repository, location, workspace) {
|
|
89
|
+
try {
|
|
90
|
+
const counts = countsOf(await workspaceChanges(repository, workspace));
|
|
91
|
+
const dirty = counts.staged > 0 || counts.unstaged > 0 || counts.untracked > 0 || counts.submodules > 0;
|
|
92
|
+
return { kind: dirty ? "dirty" : "clean", location, counts };
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return { kind: "unavailable", location };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export async function observeTargetLag(repository, workspace, head) {
|
|
99
|
+
if (head === undefined)
|
|
100
|
+
return { kind: "none" };
|
|
101
|
+
if (head === null)
|
|
102
|
+
return { kind: "unknown" };
|
|
103
|
+
try {
|
|
104
|
+
const text = (await runGit(repository, ["-C", workspace, "rev-list", "--count", `HEAD..${head}`]))
|
|
105
|
+
.toString("utf8")
|
|
106
|
+
.trim();
|
|
107
|
+
if (!/^[0-9]+$/u.test(text))
|
|
108
|
+
return { kind: "unknown" };
|
|
109
|
+
return { kind: "counted", behind: Number(text) };
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return { kind: "unknown" };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Capture tracked and untracked workspace bytes without changing its real index. */
|
|
116
|
+
export async function captureWorkspaceTree(repository, workspace) {
|
|
117
|
+
const identities = (await runGit(repository, ["-C", workspace, "show", "-s", "--format=%H%n%T", "HEAD"]))
|
|
118
|
+
.toString("utf8")
|
|
119
|
+
.split("\n");
|
|
120
|
+
if (identities.length !== 3 || identities[0] === undefined || identities[1] === undefined || identities[2] !== "") {
|
|
121
|
+
throw new Error("workspace HEAD/tree resolution did not return exactly two object IDs");
|
|
122
|
+
}
|
|
123
|
+
const head = mintSnapshotId(identities[0]);
|
|
124
|
+
const tree = gitObjectId(identities[1], "workspace tree");
|
|
125
|
+
const changes = await workspaceChanges(repository, workspace);
|
|
126
|
+
const dirty = changes.staged.length > 0 || changes.unstaged.length > 0 || changes.untracked.length > 0;
|
|
127
|
+
if (!dirty)
|
|
128
|
+
return { tree, head, dirty, changes };
|
|
129
|
+
return await withPrivateGitIndex(async (environment) => {
|
|
130
|
+
await runGitWithEnvironment(repository, ["-C", workspace, "read-tree", "HEAD"], undefined, environment);
|
|
131
|
+
await runGitWithEnvironment(repository, ["-C", workspace, "add", "--all"], undefined, environment);
|
|
132
|
+
return {
|
|
133
|
+
tree: gitObjectId((await runGitWithEnvironment(repository, ["-C", workspace, "write-tree"], undefined, environment)).toString("utf8").trim(), "workspace tree"),
|
|
134
|
+
head,
|
|
135
|
+
dirty,
|
|
136
|
+
changes,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
declare const AKUMA_ALIAS: unique symbol;
|
|
2
|
+
declare const AKUMA_GLOB: unique symbol;
|
|
2
3
|
export type AkumaAlias = string & {
|
|
3
4
|
readonly [AKUMA_ALIAS]: true;
|
|
4
5
|
};
|
|
6
|
+
export type AkumaGlob = string & {
|
|
7
|
+
readonly [AKUMA_GLOB]: true;
|
|
8
|
+
};
|
|
5
9
|
export declare function parseAkumaAlias(value: string): AkumaAlias;
|
|
10
|
+
export declare function parseAkumaGlob(value: string): AkumaGlob;
|
|
11
|
+
export declare function matchesAkumaGlob(glob: AkumaGlob, value: string): boolean;
|
|
6
12
|
export {};
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
const AKUMA_ALIAS_PATTERN = /^@[a-z][a-z0-9-]{0,63}$/u;
|
|
2
|
+
const AKUMA_GLOB_SUFFIX = /^[0-9a-f*]+$/u;
|
|
2
3
|
export function parseAkumaAlias(value) {
|
|
3
4
|
if (!AKUMA_ALIAS_PATTERN.test(value)) {
|
|
4
5
|
throw new TypeError("Akuma alias must match ^@[a-z][a-z0-9-]{0,63}$");
|
|
5
6
|
}
|
|
6
7
|
return value;
|
|
7
8
|
}
|
|
9
|
+
export function parseAkumaGlob(value) {
|
|
10
|
+
const segments = value.split("/");
|
|
11
|
+
const archetype = segments[1] ?? "";
|
|
12
|
+
const archetypeProbe = archetype.replaceAll("*", "x");
|
|
13
|
+
if (segments.length !== 3 || segments[0] !== "aku" || !value.includes("*")
|
|
14
|
+
|| archetype.length === 0 || normalizeIdentityStem({ source: archetypeProbe }) !== archetypeProbe
|
|
15
|
+
|| !AKUMA_GLOB_SUFFIX.test(segments[2] ?? "")) {
|
|
16
|
+
throw new TypeError("Akuma glob must be aku/<akuma-pattern>/<hex-pattern> and contain *");
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export function matchesAkumaGlob(glob, value) {
|
|
21
|
+
const pattern = parseAkumaGlob(glob)
|
|
22
|
+
.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")
|
|
23
|
+
.replaceAll("*", "[^/]*");
|
|
24
|
+
return new RegExp(`^${pattern}$`, "u").test(value);
|
|
25
|
+
}
|
|
26
|
+
import { normalizeIdentityStem } from "./normalize.js";
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { AuthorityCorruptionError, Delivery, gatesFrom, Keiyaku, KeiyakuRefused, KeiyakuRetry, NoGitWorldError, Repo, SettingsError, worktreeHooksFrom } from "./library/keiyaku.js";
|
|
1
|
+
export { AuthorityCorruptionError, AkumaWorldScopeError, Delivery, gatesFrom, Keiyaku, KeiyakuRefused, KeiyakuRetry, NoGitWorldError, Repo, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./library/keiyaku.js";
|
|
2
2
|
export { settings } from "./settings.js";
|
|
3
|
+
export { World, WorldError } from "./world.js";
|
|
4
|
+
export type { WorldResolution, WorldResolutionInput, WorldRoot } from "./world.js";
|
|
3
5
|
export type { Settings, SettingsEntry, SettingsInput, SettingsNamespaceFailure, SettingsNamespaceView, SettingsScope, SettingsScopeState, } from "./settings.js";
|
|
4
|
-
export type { AttestationVerdict, AbandonInput, ActorId, AkuId, AkumaAlias, AkumaStatus, AliasBinding, AliasStage, AmendResult, AmendInput, ArcInput, AuditReport, BindInput, BindResult, CallInput, CallObservation, CallResult, ChangeId, ContractId, ContractState, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, DeliverInput, Fact, FactKind, Dispatch, DispatchFailure, DispatchStage, Gate, GatesFromInput, HookCommand, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, ForkInput, ForkResult, IntegrationFailure, Lag, MutationResult, PlacementStop, RegionOverlap, ReconcileInput, RepoReconcileReport, Review, ReconcileReport, ReviewInput, RepoAtInput, AuditInput, SnapshotId, SettlementAction, SettlementLag, SettlementReport,
|
|
6
|
+
export type { AttestationVerdict, AbandonInput, ActorId, AkuId, AkumaAddressInput, AkumaAlias, AkumaGlob, AkumaHistoryInput, AkumaHistoryResult, AkumaInterruptInput, AkumaInterruptResult, AkumaKillResult, AkumaSetAddressInput, AkumaStatus, AkumaStatusView, AkumaTellInput, AkumaTellResult, AkumaWaitInput, AkumaWaitResult, AkumaWorldScopeRefusal, AliasBinding, AliasStage, AmendResult, AmendInput, ArcInput, AuditReport, DeliveryPreparationRefusal, BindInput, BindResult, CallInput, CallObservation, CallResult, Catalog, CatalogInput, CatalogQuery, ChangeId, ContractId, ContractState, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, DeliverInput, Fact, FactKind, Dispatch, DispatchFailure, DispatchStage, DirectAkumaSelector, Gate, GatesFromInput, HookCommand, RequireBranchesToBeUpToDateFromInput, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, ForkInput, ForkResult, IntegrationFailure, Lag, MutationResult, PlacementStop, RegionOverlap, ReconcileInput, RepoReconcileReport, Review, ReconcileReport, ReviewInput, RepoAtInput, AuditInput, SnapshotId, SettlementAction, SettlementLag, SettlementReport, SetAkumaSelector, TaskId, TopologyEffect, VerificationReuse, VerificationStop, WorktreeHooks, } from "./library/keiyaku.js";
|
package/build/src/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { AuthorityCorruptionError, Delivery, gatesFrom, Keiyaku, KeiyakuRefused, KeiyakuRetry, NoGitWorldError, Repo, SettingsError, worktreeHooksFrom } from "./library/keiyaku.js";
|
|
1
|
+
export { AuthorityCorruptionError, AkumaWorldScopeError, Delivery, gatesFrom, Keiyaku, KeiyakuRefused, KeiyakuRetry, NoGitWorldError, Repo, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./library/keiyaku.js";
|
|
2
2
|
export { settings } from "./settings.js";
|
|
3
|
+
export { World, WorldError } from "./world.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { kanshi } from "./read.js";
|
|
2
|
-
export { selectKanshi } from "./select.js";
|
|
2
|
+
export { selectKanshi, selectRegion } from "./select.js";
|
|
3
3
|
export type { KanshiInput } from "./read.js";
|
|
4
|
-
export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, KanshiReport, Section, TaskKanshiRow, TaskKanshiWorld, } from "./report.js";
|
|
4
|
+
export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiRow, KanshiReport, Section, TaskKanshiRow, TaskKanshiWorld, KanshiRegionSelection, RegionDeclaration, RegionIntersection, RegionPathMatch, RegionRead, } from "./report.js";
|
|
5
5
|
export type { KanshiSelection } from "./select.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { kanshi } from "./read.js";
|
|
2
|
-
export { selectKanshi } from "./select.js";
|
|
2
|
+
export { selectKanshi, selectRegion } from "./select.js";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Repo } from "../library/repo.js";
|
|
2
|
+
import type { KanshiReport, KanshiRegionSelection } from "./report.js";
|
|
3
|
+
import type { WorldRoot } from "../world.js";
|
|
2
4
|
export type KanshiInput = Readonly<{
|
|
3
|
-
|
|
5
|
+
world: WorldRoot | null;
|
|
6
|
+
repo?: Repo;
|
|
7
|
+
region?: KanshiRegionSelection;
|
|
4
8
|
}>;
|
|
5
|
-
export declare function kanshi(input
|
|
9
|
+
export declare function kanshi(input: KanshiInput): Promise<KanshiReport>;
|