@astrosheep/keiyaku 2.9.12 → 2.9.13
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 +22 -18
- package/build/.tsbuildinfo +1 -1
- package/build/agents/call-terms.js +1 -0
- package/build/agents/providers/claude-agent-sdk/adapter.js +2 -2
- package/build/cli/commands/akuma/akuma/handler.js +2 -1
- package/build/cli/commands/akuma/akuma/meta.js +4 -3
- package/build/cli/commands/akuma/catalog.js +2 -0
- package/build/cli/commands/akuma/list/handler.js +1 -1
- package/build/cli/commands/akuma/list/meta-list.js +12 -0
- package/build/cli/commands/akuma/list/meta-ls.js +2 -2
- package/build/cli/commands/akuma.js +5 -0
- package/build/cli/commands/contract/amend/meta.js +4 -3
- package/build/cli/commands/contract/arc/meta.js +2 -0
- package/build/cli/commands/contract/audit/handler.js +28 -2
- package/build/cli/commands/contract/audit/meta.js +4 -3
- package/build/cli/commands/contract/petition/handler.js +2 -1
- package/build/cli/commands/contract/petition/meta.js +2 -2
- package/build/cli/commands/contract/renew/handler.js +44 -3
- package/build/cli/commands/contract/renew/meta.js +5 -4
- package/build/cli/commands/metadata.js +12 -9
- package/build/cli/commands/projection/call/handler.js +1 -1
- package/build/cli/commands/projection/call/meta.js +1 -1
- package/build/cli/commands/projection/catalog.js +2 -2
- package/build/cli/commands/projection/{revive → fork}/handler.js +10 -5
- package/build/cli/commands/projection/fork/meta.js +12 -0
- package/build/cli/commands/projection/history/handler.js +46 -2
- package/build/cli/commands/projection/history/meta.js +3 -3
- package/build/cli/commands/projection/kill/meta.js +2 -2
- package/build/cli/commands/projection/status/handler.js +29 -13
- package/build/cli/commands/projection/status/meta.js +14 -3
- package/build/cli/commands/projection/tell/handler.js +8 -4
- package/build/cli/commands/projection/tell/meta.js +1 -1
- package/build/cli/commands/projection/wait/handler.js +45 -20
- package/build/cli/commands/projection/wait/meta.js +1 -1
- package/build/cli/commands/shared.js +1 -1
- package/build/cli/commands/system/catalog.js +2 -0
- package/build/cli/commands/task/add/handler.js +28 -12
- package/build/cli/commands/task/add/meta.js +18 -6
- package/build/cli/commands/task/catalog.js +2 -0
- package/build/cli/commands/task/compose/handler.js +2 -2
- package/build/cli/commands/task/compose/meta.js +2 -2
- package/build/cli/commands/task/doctor/handler.js +2 -3
- package/build/cli/commands/task/doctor/meta.js +2 -2
- package/build/cli/commands/task/done/meta.js +2 -2
- package/build/cli/commands/task/drop/handler.js +7 -2
- package/build/cli/commands/task/drop/meta.js +6 -3
- package/build/cli/commands/task/hold/meta.js +2 -2
- package/build/cli/commands/task/log/meta.js +2 -2
- package/build/cli/commands/task/ls/meta.js +2 -2
- package/build/cli/commands/task/note/handler.js +6 -0
- package/build/cli/commands/task/note/meta.js +11 -0
- package/build/cli/commands/task/resume/meta.js +2 -2
- package/build/cli/commands/task/shared.js +29 -15
- package/build/cli/commands/task/show/meta.js +2 -2
- package/build/cli/commands/task/start/meta.js +2 -2
- package/build/cli/commands/task/stop/meta.js +2 -2
- package/build/cli/commands/task/update/meta.js +3 -2
- package/build/cli/commands/verification/handler.js +43 -0
- package/build/cli/commands/verification/meta.js +13 -0
- package/build/cli/completion.js +16 -13
- package/build/cli/flags.js +43 -11
- package/build/cli/help.js +29 -30
- package/build/cli/index.js +6 -5
- package/build/cli/parse-flags.js +39 -0
- package/build/cli/parse-metadata.js +5 -2
- package/build/cli/parse-selectors.js +18 -0
- package/build/cli/parse.js +21 -8
- package/build/cli/render/arc.js +12 -3
- package/build/cli/render/audit.js +2 -2
- package/build/cli/render/call.js +4 -4
- package/build/cli/render/kanshi.js +122 -85
- package/build/cli/render/misc.js +2 -2
- package/build/cli/render/petition.js +16 -1
- package/build/cli/render/projection-history.js +17 -4
- package/build/cli/render/shared.js +5 -5
- package/build/cli/render/status-indicator.js +47 -0
- package/build/cli/render/status.js +106 -76
- package/build/cli/render/success-response.js +20 -5
- package/build/cli/render/task.js +6 -5
- package/build/cli/render/tell.js +10 -4
- package/build/cli/render/tool-command-normalization.js +137 -0
- package/build/cli/render/tool-presentation.js +2 -1
- package/build/cli/render/verification.js +23 -0
- package/build/cli/render/wait.js +101 -33
- package/build/cli/types.js +2 -1
- package/build/config/akuma-loader.js +21 -1
- package/build/config/settings/knobs.js +7 -1
- package/build/config/settings/schema.js +10 -5
- package/build/core/amend.js +102 -17
- package/build/core/arc.js +4 -4
- package/build/core/audit/candidate.js +10 -18
- package/build/core/audit/coordinates.js +12 -17
- package/build/core/audit/evidence.js +6 -4
- package/build/core/audit/facade.js +3 -3
- package/build/core/audit/report.js +1 -1
- package/build/core/bind-reconciliation.js +42 -23
- package/build/core/bind.js +182 -81
- package/build/core/call/call.js +6 -7
- package/build/core/call/context.js +43 -30
- package/build/core/call/execution.js +21 -6
- package/build/core/call/prompt.js +11 -42
- package/build/core/contract-carrier-runtime.js +209 -105
- package/build/core/contract-carrier.js +156 -73
- package/build/core/contract-view.js +42 -5
- package/build/core/contract.js +2 -1
- package/build/core/derived-replay.js +168 -35
- package/build/core/draft.js +9 -5
- package/build/core/forfeit.js +1 -1
- package/build/core/lifecycle-history.js +13 -0
- package/build/core/lifecycle-recovery.js +32 -27
- package/build/core/lifecycle-runner.js +14 -14
- package/build/core/log.js +1 -1
- package/build/core/outcome-base.js +2 -2
- package/build/core/projection/akuma-name.js +43 -0
- package/build/core/projection/generation/database.js +141 -79
- package/build/core/projection/generation/ledger.js +91 -0
- package/build/core/projection/generation/model.js +18 -13
- package/build/core/projection/generation/projection-generation-continuation.js +1 -1
- package/build/core/projection/generation/projection-generation-doorbell.js +88 -0
- package/build/core/projection/generation/projection-generation-execution.js +24 -0
- package/build/core/projection/generation/projection-generation-identity.js +4 -0
- package/build/core/projection/generation/projection-generation-launcher.js +72 -138
- package/build/core/projection/generation/projection-generation-process.js +16 -15
- package/build/core/projection/generation/projection-generation-runner.js +125 -79
- package/build/core/projection/generation/projection-generation-runtime.js +10 -61
- package/build/core/projection/generation/protocol.js +68 -0
- package/build/core/projection/generation/store.js +17 -7
- package/build/core/projection/generation/transitions.js +14 -14
- package/build/core/projection/index.js +5 -5
- package/build/core/projection/projection-core.js +6 -2
- package/build/core/projection/projection-execution-observer.js +1 -1
- package/build/core/projection/projection-history.js +7 -7
- package/build/core/projection/projection-kill.js +15 -6
- package/build/core/projection/projection-life-observer.js +8 -8
- package/build/core/projection/projection-mint.js +6 -8
- package/build/core/projection/projection-status-observation.js +77 -8
- package/build/core/projection/projection-status.js +151 -4
- package/build/core/projection/projection-wait.js +46 -27
- package/build/core/projection/projection-wake.js +27 -89
- package/build/core/projection/tell/launch-store.js +1 -1
- package/build/core/projection/tell/store.js +1 -1
- package/build/core/renew-build.js +204 -74
- package/build/core/renew-plan.js +34 -9
- package/build/core/renew-rewrite.js +56 -15
- package/build/core/renew.js +39 -35
- package/build/core/repository-ledger/accepted-fold-read.js +6 -3
- package/build/core/repository-ledger/codec.js +11 -5
- package/build/core/repository-ledger/current-state-store.js +13 -16
- package/build/core/repository-ledger/fold-repository.js +5 -6
- package/build/core/repository-ledger/identity.js +60 -0
- package/build/core/repository-ledger/inventory.js +3 -3
- package/build/core/repository-ledger/read-model.js +54 -6
- package/build/core/repository-ledger/write-transaction.js +9 -4
- package/build/core/run-control/connection-bound-close.js +41 -0
- package/build/core/run-control/detached-lease-bootstrap.js +208 -0
- package/build/core/run-control/detached-process.js +14 -0
- package/build/core/run-control/index.js +6 -0
- package/build/core/{process-group.js → run-control/process-tree.js} +1 -1
- package/build/core/run-control/runner-lease.js +172 -0
- package/build/core/{sqlite-process-lifetime-lock.js → run-control/sqlite-process-lifetime-lock.js} +4 -24
- package/build/core/seal.js +44 -32
- package/build/core/settlement/claim-delivery.js +22 -9
- package/build/core/settlement/claim.js +8 -6
- package/build/core/settlement/petition-claim-gates.js +9 -8
- package/build/core/settlement/petition-head-guard.js +5 -6
- package/build/core/settlement/petition-preview.js +21 -5
- package/build/core/settlement/petition.js +51 -17
- package/build/core/settlement/settlement.js +20 -15
- package/build/core/settlement/verdict.js +2 -2
- package/build/core/settlement/verification.js +492 -364
- package/build/core/status/board.js +184 -75
- package/build/core/status/drift.js +8 -10
- package/build/core/task/board.js +1 -0
- package/build/core/task/commands.js +25 -0
- package/build/core/task/compose.js +3 -2
- package/build/core/task/document.js +102 -39
- package/build/core/task/index.js +3 -3
- package/build/core/task/settlement-git.js +1 -4
- package/build/core/task/settlement-policy.js +27 -14
- package/build/core/task/source-board.js +1 -0
- package/build/core/task/task-bind-preparation.js +59 -9
- package/build/core/task/task-contract.js +2 -2
- package/build/core/task/task-store-repository.js +1 -0
- package/build/core/task/task.js +2 -2
- package/build/core/transcripts.js +4 -4
- package/build/core/verification-declaration.js +95 -0
- package/build/core/worktree-bootstrap.js +1 -1
- package/build/core/worktree-path.js +7 -11
- package/build/flow-error.js +9 -1
- package/build/generated/version.js +2 -2
- package/build/git/branches.js +41 -70
- package/build/git/commits.js +92 -21
- package/build/git/core.js +9 -161
- package/build/git/diff/preview.js +4 -4
- package/build/git/diff/read.js +4 -4
- package/build/git/diff/structured.js +5 -5
- package/build/git/process.js +229 -0
- package/build/git/refs.js +30 -5
- package/build/git/staging.js +39 -115
- package/build/git/streaming-batch.js +9 -16
- package/build/git/worktree.js +104 -91
- package/build/index.js +7 -0
- package/package.json +1 -1
- package/skills/keiyaku-akuma/SKILL.md +21 -20
- package/skills/keiyaku-task/SKILL.md +38 -4
- package/skills/keiyaku-workflow/SKILL.md +51 -11
- package/build/cli/commands/projection/revive/meta.js +0 -12
- package/build/core/projection/projection-life-protocol.js +0 -115
- package/build/core/projection/projection-runner-lock.js +0 -211
- package/build/core/projection/tell/database.js +0 -127
- package/build/core/settlement/verification-coordination.js +0 -305
- package/build/core/settlement/verification-supervisor.js +0 -275
|
@@ -19,6 +19,7 @@ export function buildCallTerms(snapshot, prompt, cwd, options) {
|
|
|
19
19
|
maxCaptureChars: registration.maxCaptureChars(runtimeConfig),
|
|
20
20
|
signal: options.signal,
|
|
21
21
|
...(options.initialTurn !== undefined ? { initialTurn: options.initialTurn } : {}),
|
|
22
|
+
...(options.carrier !== undefined ? { carrier: options.carrier } : {}),
|
|
22
23
|
};
|
|
23
24
|
// Live registry only admits CallTerms-producing contributions; the open
|
|
24
25
|
// registration surface returns structural RegistrationCallTerms.
|
|
@@ -162,7 +162,7 @@ export async function startClaudeAgentSdk(prompt, cwd, options) {
|
|
|
162
162
|
// Claude's source pull is the provider-native launch-input fact.
|
|
163
163
|
// The adapter records its coordinate before asking heart to reduce
|
|
164
164
|
// the exact attributed receipt.
|
|
165
|
-
const fence = { kind: "ordinal", ordinal:
|
|
165
|
+
const fence = { kind: "ordinal", ordinal: completedResultOrdinal + 1 };
|
|
166
166
|
await options.onLaunchAdmission?.({ fence, tellIds: options.launchTellIds ?? [] });
|
|
167
167
|
const admissions = (options.listLaunchAdmissions?.() ?? []).filter((admission) => (admission.fence.kind === "ordinal" && admission.fence.ordinal === fence.ordinal));
|
|
168
168
|
for (const receipt of exactLaunchInputReceipts("seen", fence, admissions))
|
|
@@ -322,7 +322,7 @@ export async function startClaudeAgentSdk(prompt, cwd, options) {
|
|
|
322
322
|
}
|
|
323
323
|
// Sync checkpoint: claim inbox tells and deliver them via steer control.
|
|
324
324
|
options.onSyncCheckpoint?.({ enqueue }, checkpoint);
|
|
325
|
-
const admissions = (options.listLaunchAdmissions?.() ?? []).filter((admission) => (admission.fence.kind === "ordinal" && admission.fence.ordinal
|
|
325
|
+
const admissions = (options.listLaunchAdmissions?.() ?? []).filter((admission) => (admission.fence.kind === "ordinal" && admission.fence.ordinal <= checkpoint.fence.ordinal));
|
|
326
326
|
for (const receipt of exactLaunchInputReceipts("consumed", checkpoint.fence, admissions))
|
|
327
327
|
options.onTellReceipt?.(receipt);
|
|
328
328
|
options.onTellReceipt?.({ stage: "consumed", correlation: { kind: "fence", fence: checkpoint.fence } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { missingSubcommandError } from "../../../missing-subcommand.js";
|
|
2
|
+
import { AKUMA_SUBCOMMANDS } from "../../../types.js";
|
|
2
3
|
export const handler = async () => {
|
|
3
|
-
throw missingSubcommandError("akuma",
|
|
4
|
+
throw missingSubcommandError("akuma", AKUMA_SUBCOMMANDS);
|
|
4
5
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { AKUMA_SUBCOMMANDS } from "../../../types.js";
|
|
1
2
|
export const meta = {
|
|
2
3
|
command: "akuma",
|
|
3
4
|
summary: "Inspect Akuma profiles",
|
|
4
|
-
usage: ["keiyaku akuma
|
|
5
|
+
usage: ["keiyaku akuma list|show"],
|
|
5
6
|
stdin: { mode: "argument" },
|
|
6
7
|
flags: [],
|
|
7
8
|
purpose: "Inspect configured helper profiles.",
|
|
8
|
-
subcommands:
|
|
9
|
+
subcommands: AKUMA_SUBCOMMANDS,
|
|
9
10
|
notes: [
|
|
10
11
|
"Define user profiles in <KEIYAKU_HOME>/akuma/<name>.md.",
|
|
11
12
|
"Define project profiles in .keiyaku/akuma/<name>.md.",
|
|
12
13
|
"See README Configuration for the Markdown frontmatter format.",
|
|
13
14
|
],
|
|
14
|
-
examples: ["keiyaku akuma
|
|
15
|
+
examples: ["keiyaku akuma list", "keiyaku akuma show akuma-codex"],
|
|
15
16
|
completionRank: 6,
|
|
16
17
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { meta as akumaMeta } from "./akuma/meta.js";
|
|
2
|
+
import { meta as listMeta } from "./list/meta-list.js";
|
|
2
3
|
import { meta as lsMeta } from "./list/meta-ls.js";
|
|
3
4
|
import { meta as showMeta } from "./show/meta.js";
|
|
4
5
|
export const akumaCatalog = [
|
|
5
6
|
{ meta: akumaMeta, load: () => import("./akuma/handler.js") },
|
|
7
|
+
{ meta: listMeta, load: () => import("./list/handler.js") },
|
|
6
8
|
{ meta: lsMeta, load: () => import("./list/handler.js") },
|
|
7
9
|
{ meta: showMeta, load: () => import("./show/handler.js") },
|
|
8
10
|
];
|
|
@@ -5,7 +5,7 @@ import { textResponse } from "../../../render/shared.js";
|
|
|
5
5
|
import { projectDirectory } from "../../shared.js";
|
|
6
6
|
import { renderAkumaList } from "../../akuma.js";
|
|
7
7
|
export const handler = async (_stdin, flags) => {
|
|
8
|
-
const cwd = await projectDirectory(flags, "akuma
|
|
8
|
+
const cwd = await projectDirectory(flags, "akuma list");
|
|
9
9
|
const loaded = await loadKeiyakuSettings(cwd);
|
|
10
10
|
// Role markers need settings pointers; catalog consumers keep legacy agents disease actionable.
|
|
11
11
|
assertSettingsKnobUsable(loaded, "agents");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
command: "akuma list",
|
|
3
|
+
summary: "List Akuma profiles",
|
|
4
|
+
usage: ["keiyaku akuma list [-C|--cwd DIR] [--repo DIR]"],
|
|
5
|
+
stdin: { mode: "argument" },
|
|
6
|
+
flags: ["cwd", "repo"],
|
|
7
|
+
purpose: "List configured helper profiles.",
|
|
8
|
+
notes: [
|
|
9
|
+
"`keiyaku akuma ls` is a short alias.",
|
|
10
|
+
"Project profiles override user profiles, which override builtins.",
|
|
11
|
+
],
|
|
12
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const meta = {
|
|
2
2
|
command: "akuma ls",
|
|
3
|
-
summary: "
|
|
3
|
+
summary: "Alias for akuma list",
|
|
4
4
|
usage: ["keiyaku akuma ls [-C|--cwd DIR] [--repo DIR]"],
|
|
5
5
|
stdin: { mode: "argument" },
|
|
6
6
|
flags: ["cwd", "repo"],
|
|
7
|
-
purpose: "
|
|
7
|
+
purpose: "Short alias for the canonical `keiyaku akuma list` command.",
|
|
8
8
|
notes: ["Project profiles override user profiles, which override builtins."],
|
|
9
9
|
};
|
|
@@ -112,10 +112,13 @@ function chooseCallHintName(validNames, settings) {
|
|
|
112
112
|
export function renderAkumaList(catalog, providerInstances, settings) {
|
|
113
113
|
const lines = ["Available Akumas:", ""];
|
|
114
114
|
const validNames = [];
|
|
115
|
+
const hasCustomSelectedCandidate = Object.values(catalog.selected).some((candidate) => candidate.source !== "builtin");
|
|
115
116
|
for (const name of Object.keys(catalog.selected).sort((a, b) => a.localeCompare(b))) {
|
|
116
117
|
const candidate = catalog.selected[name];
|
|
117
118
|
if (candidate === undefined)
|
|
118
119
|
continue;
|
|
120
|
+
if (hasCustomSelectedCandidate && candidate.source === "builtin")
|
|
121
|
+
continue;
|
|
119
122
|
const resolved = resolveAkumaInspection(candidate, providerInstances);
|
|
120
123
|
const markers = formatRoleMarkers(settings, resolved.name);
|
|
121
124
|
if (resolved.status === "invalid") {
|
|
@@ -130,6 +133,8 @@ export function renderAkumaList(catalog, providerInstances, settings) {
|
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
for (const shadow of catalog.shadows) {
|
|
136
|
+
if (hasCustomSelectedCandidate && shadow.source === "builtin")
|
|
137
|
+
continue;
|
|
133
138
|
lines.push(`- ${shadow.name} [${shadow.source}] (shadowed by ${shadow.shadowedBy})`);
|
|
134
139
|
}
|
|
135
140
|
const hintName = chooseCallHintName(validNames, settings);
|
|
@@ -2,11 +2,12 @@ export const meta = {
|
|
|
2
2
|
command: "amend",
|
|
3
3
|
summary: "Record an amendment",
|
|
4
4
|
usage: [
|
|
5
|
+
"keiyaku amend [-C|--cwd DIR] [--repo DIR] [--contract ADDR] --append-scope PATTERN [--append-scope PATTERN ...]",
|
|
5
6
|
"keiyaku amend [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--append-scope PATTERN] - < amendment.md",
|
|
6
|
-
"keiyaku @addr amend [-C|--cwd DIR] [--repo DIR] [--append-scope PATTERN] - < amendment.md",
|
|
7
|
+
"keiyaku @addr amend [-C|--cwd DIR] [--repo DIR] [--append-scope PATTERN] [-] < amendment.md",
|
|
7
8
|
],
|
|
8
|
-
stdin: { mode: "document", selector: { kind: "positional", index: 0, required:
|
|
9
|
+
stdin: { mode: "document", selector: { kind: "positional", index: 0, required: false, rejectBlank: true } },
|
|
9
10
|
flags: ["cwd", "repo", "contract", "append-scope"],
|
|
10
|
-
purpose: "Append
|
|
11
|
+
purpose: "Append narrative Markdown or ordered scope patterns. --append-scope is sufficient without Markdown; ## Replace Verifications replaces contract-only Verification declarations, with - (none) to clear them.",
|
|
11
12
|
completionRank: 8,
|
|
12
13
|
};
|
|
@@ -21,6 +21,8 @@ export const meta = {
|
|
|
21
21
|
"An empty seal is valid.",
|
|
22
22
|
"The command does not create delivery commits.",
|
|
23
23
|
"The first explicit arc seals a0; later arcs seal the previous open explicit arc.",
|
|
24
|
+
"Use arcs only for stages of one delivery and final settlement; an arc has no independent Scope, claim, or settlement.",
|
|
25
|
+
"--append-scope adds to the cumulative contract Scope, not an arc-local Scope.",
|
|
24
26
|
],
|
|
25
27
|
completionRank: 1,
|
|
26
28
|
};
|
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
import { auditContract } from "../../../../core/audit.js";
|
|
2
2
|
import { resolveContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
|
|
3
|
+
import { FlowError } from "../../../../flow-error.js";
|
|
3
4
|
import { buildAuditConstructionFailure, buildAuditResponse } from "../../../render/audit.js";
|
|
4
5
|
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
6
|
+
export function assertAuditPresentationOptions(options) {
|
|
7
|
+
if (options.skipDiffBody && options.diffBudgetBytes !== undefined) {
|
|
8
|
+
throw new FlowError("INVALID_USAGE", "audit --skip-diff-body cannot be used with --diff-budget");
|
|
9
|
+
}
|
|
10
|
+
if (options.skipDiffBody && options.json) {
|
|
11
|
+
throw new FlowError("INVALID_USAGE", "audit --skip-diff-body cannot be used with --json");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Shared ordinary audit pipeline for direct audit and renew's post-renew composition. */
|
|
15
|
+
export async function runAuditCommand(options) {
|
|
16
|
+
assertAuditPresentationOptions(options);
|
|
17
|
+
return withResolvedAddress(options.address, async () => {
|
|
18
|
+
return buildAuditResponse(await auditContract({
|
|
19
|
+
cwd: options.cwd,
|
|
20
|
+
address: options.address,
|
|
21
|
+
diffBudgetBytes: options.skipDiffBody ? 0 : options.diffBudgetBytes,
|
|
22
|
+
signal: options.signal,
|
|
23
|
+
}), options.json === true);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
5
26
|
export const handler = async (_stdin, flags, signal) => {
|
|
6
27
|
try {
|
|
7
28
|
const cwd = await repositoryDirectory(flags, "audit");
|
|
8
29
|
const address = await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
9
|
-
return await
|
|
10
|
-
|
|
30
|
+
return await runAuditCommand({
|
|
31
|
+
cwd,
|
|
32
|
+
address,
|
|
33
|
+
diffBudgetBytes: flags.auditDiffBudgetBytes,
|
|
34
|
+
skipDiffBody: flags.auditSkipDiffBody,
|
|
35
|
+
json: flags.json,
|
|
36
|
+
signal,
|
|
11
37
|
});
|
|
12
38
|
}
|
|
13
39
|
catch (error) {
|
|
@@ -2,14 +2,15 @@ export const meta = {
|
|
|
2
2
|
command: "audit",
|
|
3
3
|
summary: "Read settlement facts from one pinned delivery candidate",
|
|
4
4
|
usage: [
|
|
5
|
-
"keiyaku audit [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--diff-budget BYTES] [--json]",
|
|
6
|
-
"keiyaku @<id> audit [--diff-budget BYTES] [--json]",
|
|
5
|
+
"keiyaku audit [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--diff-budget BYTES|--skip-diff-body] [--json]",
|
|
6
|
+
"keiyaku @<id> audit [--diff-budget BYTES|--skip-diff-body] [--json]",
|
|
7
7
|
],
|
|
8
8
|
stdin: { mode: "argument" },
|
|
9
|
-
flags: ["cwd", "repo", "contract", "diff-budget", "json"],
|
|
9
|
+
flags: ["cwd", "repo", "contract", "diff-budget", "skip-diff-body", "json"],
|
|
10
10
|
purpose: "Inspect one pinned delivery candidate, report settlement facts, and recheck its coordinates without mutating the source repository.",
|
|
11
11
|
notes: [
|
|
12
12
|
"Audit never invokes an Akuma or settles the contract.",
|
|
13
|
+
"--skip-diff-body suppresses only human raw-hunk presentation; it cannot be combined with --diff-budget or --json.",
|
|
13
14
|
"Exit 0 means the report was constructed; exit 1 carries a typed construction cause.",
|
|
14
15
|
],
|
|
15
16
|
completionRank: 9,
|
|
@@ -18,11 +18,12 @@ export const handler = async (stdin, flags, signal) => {
|
|
|
18
18
|
const address = await resolveExistingContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
19
19
|
return await withResolvedAddress(address, async () => {
|
|
20
20
|
if (flags.dryRun) {
|
|
21
|
-
const input = buildPetitionClaimInput({ cwd, contractId: address.binding.commissionId, stdin, signal });
|
|
21
|
+
const input = buildPetitionClaimInput({ cwd, contractId: address.binding.commissionId, stdin, signal, appendScope: flags.appendScope });
|
|
22
22
|
return buildPetitionPreviewResponse(await previewPetition({
|
|
23
23
|
cwd,
|
|
24
24
|
contractId: address.binding.commissionId,
|
|
25
25
|
oath: input.oath,
|
|
26
|
+
appendScope: input.appendScope,
|
|
26
27
|
signal,
|
|
27
28
|
}), flags.json === true);
|
|
28
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const meta = {
|
|
2
2
|
command: "petition",
|
|
3
|
-
summary: "
|
|
3
|
+
summary: "Settle or preview settlement for a contract",
|
|
4
4
|
usage: [
|
|
5
5
|
"keiyaku petition [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--renew] [--append-scope PATTERN] [- < petition.md]",
|
|
6
6
|
"keiyaku @<id> petition [-C|--cwd DIR] [--repo DIR] [--renew] [--append-scope PATTERN] [- < petition.md]",
|
|
@@ -8,7 +8,7 @@ export const meta = {
|
|
|
8
8
|
],
|
|
9
9
|
stdin: { mode: "document", selector: { kind: "positional", index: 0, required: false, rejectBlank: false } },
|
|
10
10
|
flags: ["cwd", "repo", "contract", "renew", "append-scope", "dry-run", "json"],
|
|
11
|
-
purpose: "Seal the current
|
|
11
|
+
purpose: "Seal the current delivery stage and run settlement checks before claiming the contract; dry-run previews deterministic checks without changing the contract.",
|
|
12
12
|
input: [
|
|
13
13
|
"## Oath",
|
|
14
14
|
"<free first-person attestation>",
|
|
@@ -2,23 +2,64 @@ import { resolveContractAddress, resolveExistingContractAddress } from "../../..
|
|
|
2
2
|
import { abortRenewKeiyaku, continueRenewKeiyaku, renewKeiyaku } from "../../../../core/renew.js";
|
|
3
3
|
import { buildRenewAbortResponse, buildRenewResponse } from "../../../render/arc.js";
|
|
4
4
|
import { renderLifecycleResult } from "../../../render/lifecycle.js";
|
|
5
|
+
import { buildAuditConstructionFailure } from "../../../render/audit.js";
|
|
6
|
+
import { isCompleteLifecycleOutcome } from "../../../../core/outcome-base.js";
|
|
7
|
+
import { writeCliOutput } from "../../../output-stream-error-policy.js";
|
|
8
|
+
import { assertAuditPresentationOptions, runAuditCommand } from "../audit/handler.js";
|
|
9
|
+
import { FlowError } from "../../../../flow-error.js";
|
|
5
10
|
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
6
11
|
export const handler = async (_stdin, flags, signal) => {
|
|
12
|
+
if (flags.renewAbort && flags.renewAudit) {
|
|
13
|
+
throw new FlowError("INVALID_USAGE", "renew --audit cannot be used with --abort");
|
|
14
|
+
}
|
|
15
|
+
if (flags.auditSkipDiffBody && !flags.renewAudit) {
|
|
16
|
+
throw new FlowError("INVALID_USAGE", "renew --skip-diff-body requires --audit");
|
|
17
|
+
}
|
|
18
|
+
if (flags.renewAudit) {
|
|
19
|
+
assertAuditPresentationOptions({
|
|
20
|
+
diffBudgetBytes: flags.auditDiffBudgetBytes,
|
|
21
|
+
skipDiffBody: flags.auditSkipDiffBody,
|
|
22
|
+
json: flags.json,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
7
25
|
const cwd = await repositoryDirectory(flags, "renew");
|
|
8
26
|
const resolveAddress = flags.renewContinue || flags.renewAbort
|
|
9
27
|
? resolveContractAddress
|
|
10
28
|
: resolveExistingContractAddress;
|
|
11
29
|
const address = await resolveAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
12
30
|
if (flags.renewContinue) {
|
|
13
|
-
|
|
31
|
+
const result = await continueRenewKeiyaku({ cwd, address, appendScope: flags.appendScope, signal });
|
|
32
|
+
if (!flags.renewAudit || !isCompleteLifecycleOutcome(result)) {
|
|
33
|
+
return renderLifecycleResult(Promise.resolve(result), buildRenewResponse, { cwd, address });
|
|
34
|
+
}
|
|
35
|
+
return renderRenewThenAudit({ cwd, address, result, flags, signal });
|
|
14
36
|
}
|
|
15
37
|
if (flags.renewAbort) {
|
|
16
38
|
return renderLifecycleResult(abortRenewKeiyaku({ cwd, address, signal }), buildRenewAbortResponse, { cwd, address });
|
|
17
39
|
}
|
|
18
|
-
|
|
40
|
+
const result = await renewKeiyaku({
|
|
19
41
|
cwd,
|
|
20
42
|
address,
|
|
21
43
|
appendScope: flags.appendScope,
|
|
22
44
|
signal,
|
|
23
|
-
})
|
|
45
|
+
});
|
|
46
|
+
if (!flags.renewAudit || !isCompleteLifecycleOutcome(result)) {
|
|
47
|
+
return renderLifecycleResult(Promise.resolve(result), buildRenewResponse, { cwd, address });
|
|
48
|
+
}
|
|
49
|
+
return renderRenewThenAudit({ cwd, address, result, flags, signal });
|
|
24
50
|
};
|
|
51
|
+
async function renderRenewThenAudit({ cwd, address, result, flags, signal, }) {
|
|
52
|
+
await writeCliOutput(process.stdout, `${buildRenewResponse(result).text}\n\n`);
|
|
53
|
+
try {
|
|
54
|
+
return await runAuditCommand({
|
|
55
|
+
cwd,
|
|
56
|
+
address,
|
|
57
|
+
diffBudgetBytes: flags.auditDiffBudgetBytes,
|
|
58
|
+
skipDiffBody: flags.auditSkipDiffBody,
|
|
59
|
+
signal,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return buildAuditConstructionFailure(error, false);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -2,17 +2,18 @@ export const meta = {
|
|
|
2
2
|
command: "renew",
|
|
3
3
|
summary: "Rewrite delivery onto the current base",
|
|
4
4
|
usage: [
|
|
5
|
-
"keiyaku renew [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--append-scope PATTERN]",
|
|
6
|
-
"keiyaku @<id> renew --continue [--append-scope PATTERN]",
|
|
5
|
+
"keiyaku renew [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--append-scope PATTERN] [--audit [--skip-diff-body]]",
|
|
6
|
+
"keiyaku @<id> renew --continue [--append-scope PATTERN] [--audit [--skip-diff-body]]",
|
|
7
7
|
"keiyaku @<id> renew --abort",
|
|
8
8
|
],
|
|
9
9
|
stdin: { mode: "argument" },
|
|
10
|
-
flags: ["cwd", "repo", "contract", "append-scope", "continue", "abort"],
|
|
11
|
-
purpose: "
|
|
10
|
+
flags: ["cwd", "repo", "contract", "append-scope", "continue", "abort", "audit", "skip-diff-body"],
|
|
11
|
+
purpose: "Refresh committed contract changes onto the current target, then seal the refreshed delivery stage and record the renewal.",
|
|
12
12
|
notes: [
|
|
13
13
|
"After an explicit arc closes, refuses loose commits until another arc is open.",
|
|
14
14
|
"Refuses while an Akuma is in flight.",
|
|
15
15
|
"Conflicts create derived scratch without changing the ledger, delivery branch, or worktree; resolve that scratch with --continue or discard it with --abort.",
|
|
16
|
+
"--audit runs the ordinary read-only audit only after renew completes or reports already fresh; --skip-diff-body is available only with --audit.",
|
|
16
17
|
],
|
|
17
18
|
completionRank: 9,
|
|
18
19
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { meta as bindMeta } from "./contract/bind/meta.js";
|
|
2
2
|
import { meta as arcMeta } from "./contract/arc/meta.js";
|
|
3
3
|
import { meta as callMeta } from "./projection/call/meta.js";
|
|
4
|
-
import { meta as
|
|
4
|
+
import { meta as forkMeta } from "./projection/fork/meta.js";
|
|
5
5
|
import { meta as waitMeta } from "./projection/wait/meta.js";
|
|
6
6
|
import { meta as tellMeta } from "./projection/tell/meta.js";
|
|
7
7
|
import { meta as killMeta } from "./projection/kill/meta.js";
|
|
8
8
|
import { meta as logMeta } from "./contract/log/meta.js";
|
|
9
9
|
import { meta as akumaMeta } from "./akuma/akuma/meta.js";
|
|
10
|
+
import { meta as akumaListMeta } from "./akuma/list/meta-list.js";
|
|
10
11
|
import { meta as akumaLsMeta } from "./akuma/list/meta-ls.js";
|
|
11
12
|
import { meta as akumaShowMeta } from "./akuma/show/meta.js";
|
|
12
13
|
import { meta as skillsMeta } from "./skills/skills/meta.js";
|
|
@@ -16,6 +17,7 @@ import { meta as auditMeta } from "./contract/audit/meta.js";
|
|
|
16
17
|
import { meta as renewMeta } from "./contract/renew/meta.js";
|
|
17
18
|
import { meta as petitionMeta } from "./contract/petition/meta.js";
|
|
18
19
|
import { meta as forfeitMeta } from "./contract/forfeit/meta.js";
|
|
20
|
+
import { meta as verificationMeta } from "./verification/meta.js";
|
|
19
21
|
import { meta as guideMeta } from "./system/guide/meta.js";
|
|
20
22
|
import { meta as completionMeta } from "./system/completion/meta.js";
|
|
21
23
|
import { meta as statusMeta } from "./projection/status/meta.js";
|
|
@@ -31,24 +33,25 @@ import { meta as taskStopMeta } from "./task/stop/meta.js";
|
|
|
31
33
|
import { meta as taskHoldMeta } from "./task/hold/meta.js";
|
|
32
34
|
import { meta as taskResumeMeta } from "./task/resume/meta.js";
|
|
33
35
|
import { meta as taskDoneMeta } from "./task/done/meta.js";
|
|
36
|
+
import { meta as taskNoteMeta } from "./task/note/meta.js";
|
|
34
37
|
import { meta as taskDropMeta } from "./task/drop/meta.js";
|
|
35
38
|
import { meta as taskUpdateMeta } from "./task/update/meta.js";
|
|
36
39
|
import { meta as taskDoctorMeta } from "./task/doctor/meta.js";
|
|
37
40
|
import { meta as dumpEnvMeta } from "./system/dump-env/meta.js";
|
|
38
41
|
export const COMMAND_METADATA_ORDER = [
|
|
39
|
-
"bind", "arc", "call", "
|
|
40
|
-
"akuma", "akuma ls", "akuma show", "skills", "skills install", "amend", "audit",
|
|
41
|
-
"renew", "petition", "forfeit", "guide", "completion", "status", "history", "task",
|
|
42
|
-
"task add", "task compose", "task show", "task ls", "task log", "task start", "task stop", "task hold", "task resume", "task done",
|
|
42
|
+
"bind", "arc", "call", "fork", "wait", "tell", "kill", "log",
|
|
43
|
+
"akuma", "akuma list", "akuma ls", "akuma show", "skills", "skills install", "amend", "audit",
|
|
44
|
+
"renew", "petition", "forfeit", "verification", "guide", "completion", "status", "history", "task",
|
|
45
|
+
"task add", "task compose", "task show", "task ls", "task log", "task start", "task stop", "task hold", "task resume", "task done", "task note",
|
|
43
46
|
"task drop", "task update", "task doctor", "dump-env",
|
|
44
47
|
];
|
|
45
48
|
const COMMAND_METADATA = [
|
|
46
|
-
bindMeta, arcMeta, callMeta,
|
|
47
|
-
akumaMeta, akumaLsMeta, akumaShowMeta, skillsMeta, skillsInstallMeta, amendMeta, auditMeta,
|
|
48
|
-
renewMeta, petitionMeta, forfeitMeta, guideMeta, completionMeta, statusMeta, historyMeta,
|
|
49
|
+
bindMeta, arcMeta, callMeta, forkMeta, waitMeta, tellMeta, killMeta, logMeta,
|
|
50
|
+
akumaMeta, akumaListMeta, akumaLsMeta, akumaShowMeta, skillsMeta, skillsInstallMeta, amendMeta, auditMeta,
|
|
51
|
+
renewMeta, petitionMeta, forfeitMeta, verificationMeta, guideMeta, completionMeta, statusMeta, historyMeta,
|
|
49
52
|
taskMeta, taskAddMeta, taskComposeMeta, taskShowMeta, taskLsMeta, taskLogMeta, taskStartMeta, taskStopMeta,
|
|
50
53
|
taskHoldMeta, taskResumeMeta,
|
|
51
|
-
taskDoneMeta, taskDropMeta, taskUpdateMeta, taskDoctorMeta, dumpEnvMeta,
|
|
54
|
+
taskDoneMeta, taskNoteMeta, taskDropMeta, taskUpdateMeta, taskDoctorMeta, dumpEnvMeta,
|
|
52
55
|
];
|
|
53
56
|
export const CLI_COMMAND_METADATA = Object.fromEntries(COMMAND_METADATA.map((meta) => [meta.command, meta]));
|
|
54
57
|
export function getCommandMetadata(command) {
|
|
@@ -10,7 +10,7 @@ export const handler = async (stdin, flags, signal) => {
|
|
|
10
10
|
// Bounded outer join: same durable launch/adoption as detach, without core's unbounded join.
|
|
11
11
|
...(flags.timeoutMs !== undefined ? { detach: true } : {}),
|
|
12
12
|
signal,
|
|
13
|
-
...(!flags.detach
|
|
13
|
+
...(!flags.json && !flags.detach
|
|
14
14
|
? {
|
|
15
15
|
onLaunch: ({ address, projection, akumaName }) => {
|
|
16
16
|
process.stdout.write(`${renderAdoptedLaunchReceipt(address, projection.id, projection.alias, projection.previousAliasTarget, akumaName)}\n`);
|
|
@@ -6,7 +6,7 @@ export const meta = {
|
|
|
6
6
|
mode: "argument",
|
|
7
7
|
selector: { kind: "positional", index: 0, required: true, rejectBlank: true },
|
|
8
8
|
},
|
|
9
|
-
flags: ["cwd", "repo", "contract", "akuma", "model", "effort", "incognito", "bare", "detach", "alias", "wait"],
|
|
9
|
+
flags: ["cwd", "repo", "contract", "akuma", "model", "effort", "incognito", "bare", "detach", "alias", "wait", "json"],
|
|
10
10
|
purpose: "Run a scoped helper task.",
|
|
11
11
|
completionRank: 2,
|
|
12
12
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { meta as callMeta } from "./call/meta.js";
|
|
2
|
-
import { meta as
|
|
2
|
+
import { meta as forkMeta } from "./fork/meta.js";
|
|
3
3
|
import { meta as waitMeta } from "./wait/meta.js";
|
|
4
4
|
import { meta as tellMeta } from "./tell/meta.js";
|
|
5
5
|
import { meta as killMeta } from "./kill/meta.js";
|
|
@@ -7,7 +7,7 @@ import { meta as statusMeta } from "./status/meta.js";
|
|
|
7
7
|
import { meta as historyMeta } from "./history/meta.js";
|
|
8
8
|
export const projectionCatalog = [
|
|
9
9
|
{ meta: callMeta, load: () => import("./call/handler.js") },
|
|
10
|
-
{ meta:
|
|
10
|
+
{ meta: forkMeta, load: () => import("./fork/handler.js") },
|
|
11
11
|
{ meta: waitMeta, load: () => import("./wait/handler.js") },
|
|
12
12
|
{ meta: tellMeta, load: () => import("./tell/handler.js") },
|
|
13
13
|
{ meta: killMeta, load: () => import("./kill/handler.js") },
|
|
@@ -3,13 +3,14 @@ import { FlowError } from "../../../../flow-error.js";
|
|
|
3
3
|
import { buildArtifactResolutionAttempt, } from "../../../../core/addressing.js";
|
|
4
4
|
import { runCallAndPersist } from "../../../../core/call-persist.js";
|
|
5
5
|
import { locateResponseArtifact, reconcileResponseArtifactCatalog, } from "../../../../core/transcripts.js";
|
|
6
|
+
import { resolveProjectionHistoryAddress } from "../../../../core/projection/index.js";
|
|
6
7
|
import { observeGitRepository } from "../../../../git/branches.js";
|
|
7
8
|
import { stableRepoRoot } from "../../../../core/worktree-path.js";
|
|
8
9
|
import { buildCallResponse } from "../../../render/call.js";
|
|
9
|
-
import { buildCallInput, effectiveDirectory,
|
|
10
|
+
import { buildCallInput, effectiveDirectory, forkPrompt, projectDirectory } from "../../shared.js";
|
|
10
11
|
export const handler = async (stdin, flags, signal, positional) => {
|
|
11
12
|
const cwd = effectiveDirectory(flags);
|
|
12
|
-
const artifactCwd = await projectDirectory(flags, "
|
|
13
|
+
const artifactCwd = await projectDirectory(flags, "fork");
|
|
13
14
|
const artifactId = positional[0];
|
|
14
15
|
const repository = await observeGitRepository(artifactCwd);
|
|
15
16
|
if (repository.capability === "unknown")
|
|
@@ -20,7 +21,7 @@ export const handler = async (stdin, flags, signal, positional) => {
|
|
|
20
21
|
await reconcileResponseArtifactCatalog(responseStoreCwd);
|
|
21
22
|
}
|
|
22
23
|
catch {
|
|
23
|
-
// The catalog is disposable and cannot make an otherwise valid
|
|
24
|
+
// The catalog is disposable and cannot make an otherwise valid fork fail.
|
|
24
25
|
}
|
|
25
26
|
const artifact = await locateResponseArtifact({
|
|
26
27
|
cwd: responseStoreCwd,
|
|
@@ -34,6 +35,7 @@ export const handler = async (stdin, flags, signal, positional) => {
|
|
|
34
35
|
inference: ["response artifact identity lookup"],
|
|
35
36
|
}),
|
|
36
37
|
});
|
|
38
|
+
const sourceProjectionId = await resolveProjectionHistoryAddress(responseStoreCwd, artifactId);
|
|
37
39
|
let executionCwd;
|
|
38
40
|
let repo;
|
|
39
41
|
if (artifact.provenance.authority.kind === "repository") {
|
|
@@ -48,9 +50,12 @@ export const handler = async (stdin, flags, signal, positional) => {
|
|
|
48
50
|
repo = undefined;
|
|
49
51
|
}
|
|
50
52
|
const outcome = await runCallAndPersist({
|
|
51
|
-
...buildCallInput(
|
|
53
|
+
...buildCallInput(forkPrompt(stdin), { ...flags, cwd: executionCwd, repo }, "revive"),
|
|
52
54
|
reviveArtifact: artifact,
|
|
53
55
|
signal,
|
|
54
56
|
});
|
|
55
|
-
return buildCallResponse(
|
|
57
|
+
return buildCallResponse({
|
|
58
|
+
...outcome.result,
|
|
59
|
+
...(sourceProjectionId ? { sourceProjectionId } : {}),
|
|
60
|
+
}, { responsePath: outcome.responsePath, artifactId: outcome.artifactId, addressPlacement: "footer" });
|
|
56
61
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
command: "fork",
|
|
3
|
+
summary: "Start an Akuma helper session from a response artifact",
|
|
4
|
+
usage: ["keiyaku fork ARTIFACT [BODY|-]"],
|
|
5
|
+
stdin: {
|
|
6
|
+
mode: "argument",
|
|
7
|
+
selector: { kind: "positional", index: 1, required: false, rejectBlank: true },
|
|
8
|
+
},
|
|
9
|
+
flags: ["cwd", "repo", "model", "effort", "json"],
|
|
10
|
+
purpose: "Start a new projection from a persisted helper session.",
|
|
11
|
+
completionRank: 4,
|
|
12
|
+
};
|
|
@@ -3,19 +3,63 @@ import { FlowError } from "../../../../flow-error.js";
|
|
|
3
3
|
import { projectionHistoryJson, renderProjectionHistoryDetail, renderProjectionHistoryList } from "../../../render/projection-history.js";
|
|
4
4
|
import { textResponse } from "../../../render/shared.js";
|
|
5
5
|
import { projectDirectory } from "../../shared.js";
|
|
6
|
+
const DEFAULT_HISTORY_LIMIT = 20;
|
|
7
|
+
function page(entries, offset, requestedLimit) {
|
|
8
|
+
const limit = requestedLimit ?? DEFAULT_HISTORY_LIMIT;
|
|
9
|
+
const selected = entries.slice(offset, offset + limit);
|
|
10
|
+
const nextOffset = offset + selected.length < entries.length ? offset + selected.length : null;
|
|
11
|
+
return { entries: selected, pagination: { offset, limit, total: entries.length, nextOffset } };
|
|
12
|
+
}
|
|
13
|
+
function rawAvailability() {
|
|
14
|
+
return { retention: "unavailable", reason: "provider-raw-body-not-retained" };
|
|
15
|
+
}
|
|
6
16
|
export const handler = async (_stdin, flags, _signal, positional) => {
|
|
7
17
|
const cwd = await projectDirectory(flags, "history");
|
|
8
18
|
const [address] = positional;
|
|
19
|
+
const offset = flags.historyOffset ?? 0;
|
|
9
20
|
if (!address) {
|
|
21
|
+
if (flags.historyRaw || flags.historyEntry !== undefined) {
|
|
22
|
+
throw new FlowError("INVALID_USAGE", "history --raw and --entry require one projection, alias, or artifact address");
|
|
23
|
+
}
|
|
10
24
|
const runs = selectProjectionHistory(await readProjectionHistory(cwd), {
|
|
11
25
|
filters: flags.taskFilters,
|
|
12
26
|
sort: flags.taskSort,
|
|
13
27
|
nowMs: Date.now(),
|
|
14
28
|
});
|
|
15
|
-
|
|
29
|
+
const result = page(runs, offset, flags.historyLimit);
|
|
30
|
+
return textResponse(flags.json ? projectionHistoryJson(result) : renderProjectionHistoryList(result.entries, result.pagination));
|
|
31
|
+
}
|
|
32
|
+
if (flags.historyRaw && !flags.json) {
|
|
33
|
+
throw new FlowError("INVALID_USAGE", "history --raw requires --json");
|
|
34
|
+
}
|
|
35
|
+
if (flags.historyRaw && flags.historyEntry === undefined) {
|
|
36
|
+
throw new FlowError("INVALID_USAGE", "history --raw requires --entry N");
|
|
37
|
+
}
|
|
38
|
+
if (flags.historyEntry !== undefined && (flags.historyLimit !== undefined || offset !== 0)) {
|
|
39
|
+
throw new FlowError("INVALID_USAGE", "history --entry cannot be combined with --limit or --offset");
|
|
16
40
|
}
|
|
17
41
|
const detail = await readProjectionHistoryAddress(cwd, address);
|
|
18
42
|
if (!detail)
|
|
19
43
|
throw new FlowError("PROJECTION_HISTORY_NOT_FOUND", `history has no retained run for '${address}'`);
|
|
20
|
-
|
|
44
|
+
const addressedDetail = {
|
|
45
|
+
...detail,
|
|
46
|
+
inputToken: address,
|
|
47
|
+
canonicalId: detail.id,
|
|
48
|
+
};
|
|
49
|
+
if (flags.historyEntry !== undefined) {
|
|
50
|
+
const entry = detail.activity?.retainedTimeline[flags.historyEntry];
|
|
51
|
+
if (!entry)
|
|
52
|
+
throw new FlowError("PROJECTION_HISTORY_NOT_FOUND", `history entry ${flags.historyEntry} is not retained for '${address}'`);
|
|
53
|
+
const response = {
|
|
54
|
+
id: addressedDetail.id,
|
|
55
|
+
inputToken: addressedDetail.inputToken,
|
|
56
|
+
canonicalId: detail.id,
|
|
57
|
+
...(detail.alias ? { alias: detail.alias } : {}),
|
|
58
|
+
entry: { index: flags.historyEntry, event: entry, ...(flags.historyRaw ? { raw: rawAvailability() } : {}) },
|
|
59
|
+
};
|
|
60
|
+
return textResponse(flags.json ? projectionHistoryJson(response) : renderProjectionHistoryDetail(detail, response.entry));
|
|
61
|
+
}
|
|
62
|
+
return textResponse(flags.json
|
|
63
|
+
? projectionHistoryJson(addressedDetail)
|
|
64
|
+
: renderProjectionHistoryDetail(detail));
|
|
21
65
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const meta = {
|
|
2
2
|
command: "history",
|
|
3
3
|
summary: "Discover retained Akuma runs or inspect one run",
|
|
4
|
-
usage: ["keiyaku history [PROJECTION|ALIAS|ARTIFACT] [-C|--cwd DIR] [--
|
|
4
|
+
usage: ["keiyaku history [PROJECTION|ALIAS|ARTIFACT] [-C|--cwd DIR] [--limit COUNT] [--offset COUNT] [--entry N] [--raw --json] [--json]"],
|
|
5
5
|
stdin: { mode: "argument" },
|
|
6
|
-
flags: ["cwd", "repo", "
|
|
7
|
-
purpose: "Read retained projection history
|
|
6
|
+
flags: ["cwd", "repo", "limit", "offset", "entry", "raw", "json"],
|
|
7
|
+
purpose: "Read bounded retained projection history; raw provider bodies require --json --raw on one addressed entry.",
|
|
8
8
|
completionRank: 15,
|
|
9
9
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const meta = {
|
|
2
2
|
command: "kill",
|
|
3
|
-
summary: "Stop
|
|
3
|
+
summary: "Stop a projection's active run",
|
|
4
4
|
usage: [
|
|
5
5
|
"keiyaku kill <projection-address> [--wait DURATION]",
|
|
6
6
|
"keiyaku @addr kill <projection-address> [--wait DURATION]",
|
|
7
7
|
],
|
|
8
8
|
stdin: { mode: "argument" },
|
|
9
9
|
flags: ["cwd", "repo", "contract", "wait"],
|
|
10
|
-
purpose: "
|
|
10
|
+
purpose: "Stop the active run while keeping the projection available for inspection and follow-up messages.",
|
|
11
11
|
};
|