@astrosheep/keiyaku 2.9.3 → 2.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.tsbuildinfo +1 -1
- package/build/agents/call-terms.js +14 -94
- package/build/agents/harness/activity-values.js +16 -0
- package/build/agents/harness/event-persistence.js +218 -0
- package/build/agents/harness/execution-handle.js +26 -222
- package/build/agents/harness/index.js +3 -1
- package/build/agents/harness/outcome.js +68 -5
- package/build/agents/harness/projection.js +179 -124
- package/build/agents/harness/provider-adapter.js +58 -0
- package/build/agents/harness/router.js +11 -187
- package/build/agents/harness/runtime.js +17 -4
- package/build/agents/harness/session.js +15 -0
- package/build/agents/launch-snapshot/model.js +15 -236
- package/build/agents/launch-snapshot/parse-helpers.js +114 -0
- package/build/agents/launch-snapshot/resolve.js +17 -43
- package/build/agents/opencode-sdk.js +45 -12
- package/build/agents/providers/claude-agent-sdk/adapter.js +6 -17
- package/build/agents/providers/claude-agent-sdk/registration.js +214 -0
- package/build/agents/providers/claude-agent-sdk/session-schema.js +2 -0
- package/build/agents/providers/codex-app-server/adapter.js +82 -53
- package/build/agents/providers/codex-app-server/events.js +90 -11
- package/build/agents/providers/codex-app-server/identity.js +1 -0
- package/build/agents/providers/codex-app-server/policy.js +29 -0
- package/build/agents/providers/codex-app-server/registration.js +248 -0
- package/build/agents/providers/codex-app-server/session-schema.js +6 -0
- package/build/agents/providers/codex-app-server/session.js +23 -17
- package/build/agents/providers/codex-app-server/terms.js +1 -0
- package/build/agents/providers/opencode-sdk/adapter.js +94 -50
- package/build/agents/providers/opencode-sdk/events.js +8 -4
- package/build/agents/providers/opencode-sdk/registration.js +135 -0
- package/build/agents/providers/opencode-sdk/session-schema.js +2 -0
- package/build/agents/providers/opencode-sdk/session.js +21 -14
- package/build/agents/providers/opencode-sdk/terms.js +1 -0
- package/build/agents/providers/pi/adapter.js +36 -30
- package/build/agents/providers/pi/events.js +4 -3
- package/build/agents/providers/pi/registration.js +145 -0
- package/build/agents/providers/pi/session-schema.js +6 -0
- package/build/agents/providers/pi/terms.js +1 -0
- package/build/agents/providers/registration.js +7 -0
- package/build/agents/providers/registry.js +76 -0
- package/build/agents/selector.js +2 -29
- package/build/agents/types.js +10 -0
- package/build/artifact-directories.js +22 -0
- package/build/cli/commands/akuma/akuma/handler.js +1 -1
- package/build/cli/commands/akuma/akuma/meta.js +1 -1
- package/build/cli/commands/akuma/list/meta-ls.js +1 -1
- package/build/cli/commands/akuma/view/handler.js +5 -4
- package/build/cli/commands/akuma/view/meta.js +1 -1
- package/build/cli/commands/akuma.js +6 -0
- package/build/cli/commands/contract/amend/handler.js +8 -2
- package/build/cli/commands/contract/amend/meta.js +4 -4
- package/build/cli/commands/contract/arc/handler.js +8 -2
- package/build/cli/commands/contract/arc/meta.js +4 -4
- package/build/cli/commands/contract/audit/handler.js +16 -0
- package/build/cli/commands/contract/audit/meta.js +16 -0
- package/build/cli/commands/contract/bind/handler.js +4 -3
- package/build/cli/commands/contract/bind/meta.js +44 -8
- package/build/cli/commands/contract/catalog.js +2 -0
- package/build/cli/commands/contract/forfeit/handler.js +4 -4
- package/build/cli/commands/contract/forfeit/meta.js +1 -1
- package/build/cli/commands/contract/log/handler.js +3 -3
- package/build/cli/commands/contract/log/meta.js +1 -1
- package/build/cli/commands/contract/petition/handler.js +5 -8
- package/build/cli/commands/contract/petition/meta.js +6 -6
- package/build/cli/commands/contract/renew/handler.js +20 -6
- package/build/cli/commands/contract/renew/meta.js +6 -5
- package/build/cli/commands/metadata.js +59 -0
- package/build/cli/commands/projection/call/handler.js +6 -5
- package/build/cli/commands/projection/call/meta.js +4 -1
- package/build/cli/commands/projection/kill/handler.js +16 -32
- package/build/cli/commands/projection/kill/meta.js +1 -1
- package/build/cli/commands/projection/revive/meta.js +4 -1
- package/build/cli/commands/projection/shared.js +28 -0
- package/build/cli/commands/projection/status/handler.js +1 -1
- package/build/cli/commands/projection/status/meta.js +1 -1
- package/build/cli/commands/projection/tell/handler.js +14 -30
- package/build/cli/commands/projection/tell/meta.js +4 -1
- package/build/cli/commands/projection/wait/handler.js +45 -22
- package/build/cli/commands/projection/wait/meta.js +8 -3
- package/build/cli/commands/registry.js +2 -54
- package/build/cli/commands/shared.js +10 -7
- package/build/cli/commands/skills/install/handler.js +2 -5
- package/build/cli/commands/skills/install/meta.js +1 -1
- package/build/cli/commands/skills/skills/handler.js +1 -1
- package/build/cli/commands/skills/skills/meta.js +1 -1
- package/build/cli/commands/system/completion/meta.js +1 -1
- package/build/cli/commands/system/dump-env/meta.js +1 -1
- package/build/cli/commands/system/guide/meta.js +1 -1
- package/build/cli/commands/task/add/handler.js +7 -15
- package/build/cli/commands/task/add/meta.js +4 -1
- package/build/cli/commands/task/catalog.js +2 -2
- package/build/cli/commands/task/doctor/meta.js +1 -1
- package/build/cli/commands/task/done/handler.js +4 -8
- package/build/cli/commands/task/done/meta.js +1 -1
- package/build/cli/commands/task/drop/handler.js +3 -6
- package/build/cli/commands/task/drop/meta.js +1 -1
- package/build/cli/commands/task/ls/handler.js +12 -8
- package/build/cli/commands/task/ls/meta.js +3 -3
- package/build/cli/commands/task/shared.js +14 -4
- package/build/cli/commands/task/{view → show}/handler.js +7 -8
- package/build/cli/commands/task/show/meta.js +8 -0
- package/build/cli/commands/task/start/handler.js +3 -6
- package/build/cli/commands/task/start/meta.js +1 -1
- package/build/cli/commands/task/stop/handler.js +4 -8
- package/build/cli/commands/task/stop/meta.js +1 -1
- package/build/cli/commands/task/task/handler.js +1 -1
- package/build/cli/commands/task/task/meta.js +1 -1
- package/build/cli/commands/task/update/handler.js +6 -11
- package/build/cli/commands/task/update/meta.js +4 -1
- package/build/cli/completion.js +1 -1
- package/build/cli/flags.js +37 -6
- package/build/cli/help.js +7 -14
- package/build/cli/index.js +112 -154
- package/build/cli/missing-subcommand.js +7 -0
- package/build/cli/output-stream-error-policy.js +19 -5
- package/build/cli/parse-flags.js +33 -7
- package/build/cli/parse-metadata.js +3 -9
- package/build/cli/parse-selectors.js +2 -1
- package/build/cli/parse.js +35 -5
- package/build/cli/projection-address.js +12 -12
- package/build/cli/render/address.js +41 -37
- package/build/cli/render/arc.js +24 -12
- package/build/cli/render/audit.js +121 -0
- package/build/cli/render/call.js +11 -5
- package/build/cli/render/errors.js +36 -1
- package/build/cli/render/format.js +4 -0
- package/build/cli/render/kanshi.js +6 -12
- package/build/cli/render/kill.js +9 -0
- package/build/cli/render/misc.js +58 -13
- package/build/cli/render/petition.js +20 -15
- package/build/cli/render/projection-activity.js +15 -6
- package/build/cli/render/shared.js +60 -21
- package/build/cli/render/skills.js +10 -0
- package/build/cli/render/status.js +56 -23
- package/build/cli/render/success-response.js +78 -0
- package/build/cli/render/task.js +66 -57
- package/build/cli/render/tell.js +5 -0
- package/build/cli/render/terminal-failure.js +63 -0
- package/build/cli/render/types.js +1 -0
- package/build/cli/render/wait.js +68 -38
- package/build/cli/types.js +1 -1
- package/build/config/akuma-loader.js +0 -5
- package/build/config/env-keys.js +3 -1
- package/build/config/env.js +3 -0
- package/build/config/provider-policy-ownership.js +3 -32
- package/build/config/settings/disease.js +8 -1
- package/build/config/settings/loader.js +11 -3
- package/build/config/settings/provider-instance-fields.js +51 -0
- package/build/config/settings/schema.js +6 -176
- package/build/core/addressing.js +66 -16
- package/build/core/amend.js +61 -18
- package/build/core/arc.js +33 -73
- package/build/core/audit.js +650 -0
- package/build/core/bind.js +82 -35
- package/build/core/call/call.js +15 -9
- package/build/core/call/context.js +6 -51
- package/build/core/call/execution.js +22 -22
- package/build/core/call/prompt.js +14 -1
- package/build/core/command-markdown.js +45 -0
- package/build/core/context.js +13 -7
- package/build/core/contract-view.js +22 -6
- package/build/core/draft.js +139 -19
- package/build/core/entry.js +3 -4
- package/build/core/forfeit.js +5 -2
- package/build/core/hints.js +1 -75
- package/build/core/identifier-slug.js +66 -0
- package/build/core/ids.js +25 -11
- package/build/core/ledger.js +20 -68
- package/build/core/markdown/lex.js +2 -1
- package/build/core/markdown/parser.js +0 -68
- package/build/core/markdown/render.js +68 -0
- package/build/core/markdown/sections.js +2 -1
- package/build/core/outcome-base.js +4 -0
- package/build/core/projection/generation/database.js +41 -52
- package/build/core/projection/generation/model.js +63 -2
- package/build/core/{projection-generation-continuation.js → projection/generation/projection-generation-continuation.js} +3 -3
- package/build/core/{projection-generation-execution.js → projection/generation/projection-generation-execution.js} +36 -53
- package/build/core/{projection-generation-identity.js → projection/generation/projection-generation-identity.js} +2 -2
- package/build/core/{projection-generation-launcher.js → projection/generation/projection-generation-launcher.js} +9 -7
- package/build/core/{projection-generation-process.js → projection/generation/projection-generation-process.js} +2 -1
- package/build/core/{projection-generation-runner.js → projection/generation/projection-generation-runner.js} +19 -3
- package/build/core/projection/generation/store.js +3 -3
- package/build/core/projection/generation/transitions.js +19 -3
- package/build/core/projection/index.js +27 -0
- package/build/core/{projection-activity.js → projection/projection-activity.js} +12 -0
- package/build/core/{projection-alias.js → projection/projection-alias.js} +13 -13
- package/build/core/projection/projection-coordinate.js +61 -0
- package/build/core/{projection-core.js → projection/projection-core.js} +9 -9
- package/build/core/{projection-execution-observer.js → projection/projection-execution-observer.js} +37 -78
- package/build/core/{projection-identity.js → projection/projection-identity.js} +1 -1
- package/build/core/{projection-kill.js → projection/projection-kill.js} +1 -1
- package/build/core/{projection-life-observer.js → projection/projection-life-observer.js} +16 -2
- package/build/core/{projection-mint.js → projection/projection-mint.js} +10 -10
- package/build/core/{projection-status.js → projection/projection-status.js} +163 -45
- package/build/core/projection/projection-terminal-failure.js +106 -0
- package/build/core/projection/projection-wait.js +275 -0
- package/build/core/projection/projection-wake.js +227 -0
- package/build/core/provider-loader-ports.js +4 -0
- package/build/core/ref-log.js +65 -40
- package/build/core/registry.js +63 -10
- package/build/core/renew-session.js +128 -0
- package/build/core/renew.js +448 -102
- package/build/core/scope.js +272 -68
- package/build/core/seal.js +165 -40
- package/build/core/{claim-delivery.js → settlement/claim-delivery.js} +8 -8
- package/build/core/{claim.js → settlement/claim.js} +32 -8
- package/build/core/settlement/index.js +19 -0
- package/build/core/{petition-claim-gates.js → settlement/petition-claim-gates.js} +24 -49
- package/build/core/{petition-forfeit.js → settlement/petition-forfeit.js} +2 -2
- package/build/core/{petition-head-guard.js → settlement/petition-head-guard.js} +2 -2
- package/build/core/settlement/petition-io.js +1 -0
- package/build/core/{petition-preview.js → settlement/petition-preview.js} +2 -2
- package/build/core/{petition.js → settlement/petition.js} +21 -12
- package/build/core/settlement/queue-read-model.js +143 -0
- package/build/core/settlement/queue-seat-allocation.js +156 -0
- package/build/core/settlement/queue.js +6 -0
- package/build/core/settlement/settlement.js +288 -0
- package/build/core/{verdict.js → settlement/verdict.js} +9 -37
- package/build/core/settlement/verification.js +59 -0
- package/build/core/status/board.js +62 -41
- package/build/core/status/ledger-batch.js +158 -0
- package/build/core/status/reconciliation.js +10 -4
- package/build/core/stored-agent-event.js +6 -2
- package/build/core/task/board.js +41 -4
- package/build/core/task/commands.js +45 -28
- package/build/core/task/document.js +5 -0
- package/build/core/task/index.js +12 -0
- package/build/core/task/model.js +8 -1
- package/build/core/task/query.js +172 -0
- package/build/core/task/settlement-git.js +265 -74
- package/build/core/task/settlement-policy.js +67 -29
- package/build/core/task/source-board.js +1 -0
- package/build/core/task/task-contract.js +444 -0
- package/build/core/{task-doctor.js → task/task-doctor.js} +1 -1
- package/build/core/{task-git-actor.js → task/task-git-actor.js} +5 -10
- package/build/core/{task-git-runtime.js → task/task-git-runtime.js} +3 -3
- package/build/core/{task-git-store.js → task/task-git-store.js} +90 -19
- package/build/core/task/task-repository.js +1 -0
- package/build/core/{task-store-repository.js → task/task-store-repository.js} +6 -4
- package/build/core/task/task-store.js +1 -0
- package/build/core/{task-worktree.js → task/task-worktree.js} +2 -1
- package/build/core/task/task.js +7 -0
- package/build/core/task/tree.js +37 -0
- package/build/core/task/validation.js +5 -2
- package/build/core/transcripts.js +15 -3
- package/build/core/worktree-path.js +43 -28
- package/build/flow-error.js +83 -39
- package/build/fs/path-coordinate.js +16 -0
- package/build/generated/version.js +3 -2
- package/build/git/branches.js +2 -1
- package/build/git/core.js +106 -2
- package/build/git/diff/parsers.js +23 -13
- package/build/git/diff/structured.js +127 -0
- package/build/git/path-coordinate.js +17 -0
- package/build/git/refs.js +57 -0
- package/build/git/streaming-batch.js +301 -0
- package/build/git/worktree.js +65 -0
- package/build/index.js +9 -9
- package/build/keiyaku.js +2 -36
- package/build/telemetry/logger.js +4 -2
- package/package.json +4 -10
- package/skills/keiyaku/SKILL.md +5 -4
- package/skills/keiyaku-akuma/SKILL.md +25 -11
- package/skills/keiyaku-task/SKILL.md +17 -8
- package/skills/keiyaku-workflow/SKILL.md +58 -9
- package/build/agents/providers/codex-sdk.js +0 -329
- package/build/cli/commands/task/view/meta.js +0 -8
- package/build/core/command-io.js +0 -174
- package/build/core/path-coordinate.js +0 -27
- package/build/core/petition-claim.js +0 -117
- package/build/core/petition-run.js +0 -83
- package/build/core/projection-coordinate.js +0 -63
- package/build/core/projection-wait.js +0 -165
- package/build/core/projection-wake.js +0 -136
- package/build/core/queue.js +0 -343
- package/build/core/task-contract.js +0 -237
- package/build/core/task.js +0 -4
- /package/build/{core/task-repository.js → agents/launch-snapshot/types.js} +0 -0
- /package/build/{core/task-store.js → agents/providers/claude-agent-sdk/terms.js} +0 -0
- /package/build/core/{projection-generation-runtime.js → projection/generation/projection-generation-runtime.js} +0 -0
- /package/build/core/{projection-life-protocol.js → projection/projection-life-protocol.js} +0 -0
- /package/build/core/{projection-runner-lock.js → projection/projection-runner-lock.js} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { AddressResolutionError, buildObjectResolutionAttempt, } from "../core/addressing.js";
|
|
4
|
-
import { resolveProjectionCoordinate } from "../core/projection
|
|
5
|
-
import { isProjectionId, projectionDir } from "../core/projection
|
|
6
|
-
import { isProjectionAlias, readProjectionAlias } from "../core/projection
|
|
7
|
-
import { readProjectionIdentity } from "../core/projection
|
|
8
|
-
import { isProjectionGenerationSchemaV1Residue } from "../core/projection/generation/store.js";
|
|
4
|
+
import { assertProjectionTellable, resolveProjectionCoordinate } from "../core/projection/index.js";
|
|
5
|
+
import { isProjectionId, projectionDir } from "../core/projection/index.js";
|
|
6
|
+
import { isProjectionAlias, readProjectionAlias } from "../core/projection/index.js";
|
|
7
|
+
import { readProjectionIdentity } from "../core/projection/index.js";
|
|
9
8
|
import { isResponseArtifactId } from "../core/response-artifact-id.js";
|
|
10
9
|
import { isErrnoException } from "../errno.js";
|
|
11
10
|
function isRealDirectory(directory) {
|
|
@@ -41,7 +40,7 @@ export async function resolveProjectionAddress(input) {
|
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
else {
|
|
44
|
-
const coordinate = resolveProjectionCoordinate(input.cwd);
|
|
43
|
+
const coordinate = await resolveProjectionCoordinate(input.cwd);
|
|
45
44
|
repo = coordinate.authority.kind === "repository"
|
|
46
45
|
? { kind: "repository", stableRoot: coordinate.authority.stableRoot }
|
|
47
46
|
: { kind: "user" };
|
|
@@ -70,21 +69,22 @@ export async function resolveProjectionAddress(input) {
|
|
|
70
69
|
else {
|
|
71
70
|
if (!isProjectionAlias(input.address))
|
|
72
71
|
throw new AddressResolutionError("EMPTY_PARAM", `projection alias ${input.address} has no match ${suffix}`, attempt);
|
|
73
|
-
const target = readProjectionAlias(physicalRoot, input.address);
|
|
72
|
+
const target = await readProjectionAlias(physicalRoot, input.address);
|
|
74
73
|
if (!target)
|
|
75
74
|
throw new AddressResolutionError("EMPTY_PARAM", `projection alias ${input.address} has no match ${suffix}`, attempt);
|
|
76
75
|
id = target;
|
|
77
76
|
alias = input.address;
|
|
78
77
|
}
|
|
79
|
-
const directory = projectionDir(physicalRoot, id);
|
|
78
|
+
const directory = await projectionDir(physicalRoot, id);
|
|
80
79
|
if (!isRealDirectory(directory)) {
|
|
81
80
|
const subject = alias ? `projection alias ${alias} points to missing projection ${id}` : `projection ${id}`;
|
|
82
81
|
throw new AddressResolutionError("EMPTY_PARAM", `${subject} has no match ${suffix}`, attempt);
|
|
83
82
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
// Historical projection storage has no current identity to resolve. Tell
|
|
84
|
+
// still reaches its typed no-mutation refusal instead of exposing storage
|
|
85
|
+
// parser details or creating a mailbox row.
|
|
86
|
+
if (input.verb === "tell")
|
|
87
|
+
assertProjectionTellable(directory);
|
|
88
88
|
let identity;
|
|
89
89
|
try {
|
|
90
90
|
identity = readProjectionIdentity(directory);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
return sourceName(address.spelling.source);
|
|
3
|
-
}
|
|
4
|
-
function sourceName(source) {
|
|
5
|
-
switch (source) {
|
|
6
|
-
case "at-address": return "explicit @";
|
|
7
|
-
case "explicit-flag": return "explicit --contract";
|
|
8
|
-
case "worktree-presented": return "worktree cwd";
|
|
9
|
-
case "sole-active": return "only active commission";
|
|
10
|
-
case "artifact-provenance": return "artifact provenance";
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { formatCommissionCoordinate } from "../../core/ids.js";
|
|
13
2
|
function isCommissionAddress(address) {
|
|
14
3
|
return address.binding.kind === "commission";
|
|
15
4
|
}
|
|
5
|
+
function projectionSegment(facts) {
|
|
6
|
+
if (!facts.projectionId)
|
|
7
|
+
return undefined;
|
|
8
|
+
return facts.projectionAlias
|
|
9
|
+
? `projection ${facts.projectionId} (${facts.projectionAlias})`
|
|
10
|
+
: `projection ${facts.projectionId}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Human-facing address receipt. Contract coordinates are `<slug> @<place>` or `<slug>`;
|
|
14
|
+
* Opaque contract identity, branch ref, binding source, and repo path stay in payload/carrier.
|
|
15
|
+
*/
|
|
16
16
|
export function renderResolvedAddressReceipt(address, facts = {}) {
|
|
17
17
|
if (!isCommissionAddress(address)) {
|
|
18
18
|
if (address.binding.kind === "unbound") {
|
|
@@ -22,43 +22,50 @@ export function renderResolvedAddressReceipt(address, facts = {}) {
|
|
|
22
22
|
return [
|
|
23
23
|
"Unbound",
|
|
24
24
|
"no active commission",
|
|
25
|
-
`repo ${address.repo.stableRoot}`,
|
|
26
25
|
`workdir ${address.workdir}`,
|
|
27
26
|
facts.artifactId ? `artifact ${facts.artifactId}` : undefined,
|
|
28
|
-
|
|
27
|
+
projectionSegment(facts),
|
|
29
28
|
].filter((part) => part !== undefined).join(" · ");
|
|
30
29
|
}
|
|
31
|
-
const repository = address.repo.kind === "repository"
|
|
32
|
-
? `repo ${address.repo.stableRoot}`
|
|
33
|
-
: "no repository";
|
|
34
30
|
return [
|
|
35
31
|
"Bare",
|
|
36
32
|
"no contract",
|
|
37
|
-
repository,
|
|
38
33
|
`workdir ${address.workdir}`,
|
|
39
34
|
facts.artifactId ? `artifact ${facts.artifactId}` : undefined,
|
|
40
|
-
|
|
35
|
+
projectionSegment(facts),
|
|
41
36
|
].filter((part) => part !== undefined).join(" · ");
|
|
42
37
|
}
|
|
38
|
+
const place = address.place.display;
|
|
39
|
+
if (facts.akumaName) {
|
|
40
|
+
if (!facts.projectionId)
|
|
41
|
+
throw new Error("commissioned call receipt requires projection id");
|
|
42
|
+
return `call ${facts.akumaName} · ${formatCommissionCoordinate({
|
|
43
|
+
commissionId: address.binding.commissionId,
|
|
44
|
+
place,
|
|
45
|
+
})} · projection ${facts.projectionId} · out there`;
|
|
46
|
+
}
|
|
43
47
|
return [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
formatCommissionCoordinate({
|
|
49
|
+
commissionId: address.binding.commissionId,
|
|
50
|
+
place,
|
|
51
|
+
}),
|
|
48
52
|
facts.artifactId ? `artifact ${facts.artifactId}` : undefined,
|
|
49
|
-
|
|
50
|
-
`via ${sourceLabel(address)}`,
|
|
53
|
+
projectionSegment(facts),
|
|
51
54
|
].filter((part) => part !== undefined).join(" · ");
|
|
52
55
|
}
|
|
53
56
|
function renderAttemptCandidate(candidate) {
|
|
57
|
+
const coordinate = formatCommissionCoordinate({
|
|
58
|
+
commissionId: candidate.commissionId,
|
|
59
|
+
place: candidate.place,
|
|
60
|
+
});
|
|
61
|
+
const objectiveLine = candidate.objective.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
62
|
+
const objective = objectiveLine.length > 60
|
|
63
|
+
? `${objectiveLine.slice(0, 60)}…`
|
|
64
|
+
: objectiveLine;
|
|
54
65
|
return [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
candidate.
|
|
58
|
-
`target ${candidate.target.branch}`,
|
|
59
|
-
`commission ${candidate.commissionId}`,
|
|
60
|
-
`lifecycle ${candidate.lifecycle.state}`,
|
|
61
|
-
candidate.matchedBy ? `matched by ${candidate.matchedBy}` : undefined,
|
|
66
|
+
coordinate,
|
|
67
|
+
objective || undefined,
|
|
68
|
+
candidate.commissionId,
|
|
62
69
|
].filter((part) => part !== undefined).join(" · ");
|
|
63
70
|
}
|
|
64
71
|
function isCommissionResolutionAttempt(attempt) {
|
|
@@ -67,20 +74,17 @@ function isCommissionResolutionAttempt(attempt) {
|
|
|
67
74
|
export function renderResolutionAttemptPreamble(attempt) {
|
|
68
75
|
if (!isCommissionResolutionAttempt(attempt)) {
|
|
69
76
|
return [
|
|
70
|
-
attempt.repo.kind === "repository" ? `At repo ${attempt.repo.stableRoot}` : "At no repository",
|
|
71
77
|
attempt.scope ? `scope ${attempt.scope.asTyped}` : undefined,
|
|
72
|
-
].filter((part) => part !== undefined).join(" · ");
|
|
78
|
+
].filter((part) => part !== undefined).join(" · ") || "resolution failed";
|
|
73
79
|
}
|
|
74
80
|
const parts = [
|
|
75
|
-
attempt.repo.kind === "repository" ? `At repo ${attempt.repo.stableRoot}` : "At no repository",
|
|
76
81
|
attempt.spelling ? `address ${attempt.spelling.asTyped}` : undefined,
|
|
77
82
|
attempt.candidates.length > 0
|
|
78
83
|
? `candidates ${attempt.candidates.map(renderAttemptCandidate).join("; ")}`
|
|
79
84
|
: undefined,
|
|
80
|
-
attempt.spelling ? `via ${sourceName(attempt.spelling.source)}` : undefined,
|
|
81
85
|
attempt.inference.length > 0 ? `inference ${attempt.inference.join("; ")}` : undefined,
|
|
82
86
|
];
|
|
83
|
-
return parts.filter((part) => part !== undefined).join(" · ");
|
|
87
|
+
return parts.filter((part) => part !== undefined).join(" · ") || "resolution failed";
|
|
84
88
|
}
|
|
85
89
|
export function renderAddressCarrier(carrier, facts = {}) {
|
|
86
90
|
return "expected" in carrier
|
package/build/cli/render/arc.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { renderSealDiffSection } from "../../core/transcripts.js";
|
|
1
2
|
import { shortCommitHash } from "../../git/commits.js";
|
|
2
3
|
import { assembleResponse, buildPayload, buildSection, formatHints, formatList, formatMaybe, formatWarnings, } from "./format.js";
|
|
3
4
|
import { DIFF_OVERVIEW_SECTION_TITLE, RESPONSE_MARKERS, WARNING_SECTION_TITLE } from "./response-style.js";
|
|
4
|
-
import { appendPersistenceSummary,
|
|
5
|
+
import { appendPersistenceSummary, CONTENT_SECTION_TITLE, HINTS_LIST_MAX_ITEMS, HINTS_SECTION_TITLE, INFO_COMMIT_MAX_CHARS, INFO_PLEA_MAX_CHARS, INFO_SECTION_TITLE, } from "./shared.js";
|
|
5
6
|
import { prependAddressReceipt } from "./address.js";
|
|
6
7
|
function sealLines(result) {
|
|
7
8
|
if (!result.sealed)
|
|
@@ -15,25 +16,27 @@ function sealLines(result) {
|
|
|
15
16
|
}
|
|
16
17
|
export function buildArcResponse(result) {
|
|
17
18
|
const { status: _status, address: _address, ...resultData } = result;
|
|
19
|
+
const diff = renderSealDiffSection(result.sealed, "working tree untouched");
|
|
20
|
+
const payload = { ...resultData, diff };
|
|
18
21
|
const summarySection = buildSection(CONTENT_SECTION_TITLE, sealLines(result));
|
|
19
22
|
const warningSection = buildSection(WARNING_SECTION_TITLE, formatWarnings(result.meta?.warnings ?? []));
|
|
20
23
|
const hintsSection = buildSection(HINTS_SECTION_TITLE, formatHints(result.meta?.hints ?? [], { maxItems: HINTS_LIST_MAX_ITEMS }));
|
|
21
24
|
const infoSection = buildSection(INFO_SECTION_TITLE, [
|
|
22
|
-
...formatMaybe("Title", result.title
|
|
25
|
+
...formatMaybe("Title", result.title),
|
|
23
26
|
...formatMaybe("Objective", result.objective, INFO_PLEA_MAX_CHARS),
|
|
24
27
|
...formatMaybe("Brief", result.brief, INFO_PLEA_MAX_CHARS),
|
|
25
28
|
...formatMaybe("Ledger Commit", result.ledgerCommit, INFO_COMMIT_MAX_CHARS),
|
|
26
|
-
...formatMaybe(BRANCH_LABEL, result.currentBranch, INFO_BRANCH_MAX_CHARS),
|
|
27
|
-
...formatMaybe("Base Branch", result.baseBranch, INFO_BRANCH_MAX_CHARS),
|
|
28
29
|
]);
|
|
29
30
|
const summaryLine = appendPersistenceSummary(result.summary, result.responsePath);
|
|
30
31
|
return prependAddressReceipt({
|
|
31
|
-
text: assembleResponse(`${RESPONSE_MARKERS.arc} Arc Opened (a${result.arc})`, summaryLine, [summarySection, infoSection, buildSection(DIFF_OVERVIEW_SECTION_TITLE,
|
|
32
|
-
payload: buildPayload(
|
|
32
|
+
text: assembleResponse(`${RESPONSE_MARKERS.arc} Arc Opened (a${result.arc})`, summaryLine, [summarySection, infoSection, buildSection(DIFF_OVERVIEW_SECTION_TITLE, diff), warningSection, hintsSection].filter((section) => section !== null)),
|
|
33
|
+
payload: buildPayload(payload, result.responsePath),
|
|
33
34
|
}, result.address);
|
|
34
35
|
}
|
|
35
36
|
export function buildRenewResponse(result) {
|
|
36
37
|
const { status: _status, address: _address, ...resultData } = result;
|
|
38
|
+
const diff = renderSealDiffSection(result.sealed, "nothing sealed");
|
|
39
|
+
const payload = { ...resultData, diff };
|
|
37
40
|
const infoSection = buildSection(INFO_SECTION_TITLE, [
|
|
38
41
|
...formatMaybe("Old Base", result.oldBase, INFO_COMMIT_MAX_CHARS),
|
|
39
42
|
...formatMaybe("New Base", result.newBase, INFO_COMMIT_MAX_CHARS),
|
|
@@ -42,22 +45,31 @@ export function buildRenewResponse(result) {
|
|
|
42
45
|
...formatMaybe("Ledger Head", result.ledgerHead, INFO_COMMIT_MAX_CHARS),
|
|
43
46
|
...formatList("Seal", sealLines(result)),
|
|
44
47
|
]);
|
|
48
|
+
const warningSection = buildSection(WARNING_SECTION_TITLE, formatWarnings(result.meta?.warnings ?? []));
|
|
45
49
|
return prependAddressReceipt({
|
|
46
|
-
text: assembleResponse(`${RESPONSE_MARKERS.arc} Renewed`, appendPersistenceSummary(result.summary, result.responsePath), [buildSection(CONTENT_SECTION_TITLE,
|
|
47
|
-
payload: buildPayload(
|
|
50
|
+
text: assembleResponse(`${RESPONSE_MARKERS.arc} Renewed`, appendPersistenceSummary(result.summary, result.responsePath), [buildSection(CONTENT_SECTION_TITLE, diff), infoSection, warningSection].filter((section) => section !== null)),
|
|
51
|
+
payload: buildPayload(payload, result.responsePath),
|
|
48
52
|
}, result.address);
|
|
49
53
|
}
|
|
54
|
+
export function buildRenewAbortResponse(result) {
|
|
55
|
+
const payload = {
|
|
56
|
+
contractId: result.contractId,
|
|
57
|
+
oldHead: result.oldHead,
|
|
58
|
+
recoveryCleanup: result.recoveryCleanup,
|
|
59
|
+
summary: result.summary,
|
|
60
|
+
};
|
|
61
|
+
return prependAddressReceipt({ text: result.summary, payload }, result.address);
|
|
62
|
+
}
|
|
50
63
|
export function buildAmendResponse(result) {
|
|
51
64
|
const { status: _status, address: _address, ...resultData } = result;
|
|
65
|
+
const payload = resultData;
|
|
52
66
|
const renderedLedgerCommit = shortCommitHash(result.ledgerCommit);
|
|
53
67
|
const infoSection = buildSection(INFO_SECTION_TITLE, [
|
|
54
68
|
...formatMaybe("Amendment", String(result.amendmentNumber), INFO_COMMIT_MAX_CHARS),
|
|
55
|
-
...formatMaybe(BRANCH_LABEL, result.currentBranch, INFO_BRANCH_MAX_CHARS),
|
|
56
|
-
...formatMaybe("Base Branch", result.baseBranch, INFO_BRANCH_MAX_CHARS),
|
|
57
69
|
...formatMaybe("Ledger Commit", renderedLedgerCommit, INFO_COMMIT_MAX_CHARS),
|
|
58
70
|
]);
|
|
59
71
|
return prependAddressReceipt({
|
|
60
|
-
text: assembleResponse(`${RESPONSE_MARKERS.arc} Amended`, `Amended contract ledger
|
|
61
|
-
payload: buildPayload(
|
|
72
|
+
text: assembleResponse(`${RESPONSE_MARKERS.arc} Amended`, `Amended contract ledger with Amendment ${result.amendmentNumber} [${renderedLedgerCommit}].`, [buildSection(CONTENT_SECTION_TITLE, result.summary), infoSection].filter((section) => section !== null)),
|
|
73
|
+
payload: buildPayload(payload),
|
|
62
74
|
}, result.address);
|
|
63
75
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { asMessage, FlowError } from "../../flow-error.js";
|
|
2
|
+
function streamLines(name, result) {
|
|
3
|
+
const stream = result[name];
|
|
4
|
+
return [
|
|
5
|
+
`${name} tail (${stream.truncated ? `truncated, ${stream.omittedBytes} bytes omitted` : "complete, 0 bytes omitted"}):`,
|
|
6
|
+
stream.tail || "(empty)",
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
function renderVerification(report) {
|
|
10
|
+
if (report.verification.status === "not_configured")
|
|
11
|
+
return ["not configured"];
|
|
12
|
+
if (report.verification.status === "not_evaluated")
|
|
13
|
+
return [`not evaluated: ${report.verification.reason}`];
|
|
14
|
+
if (report.verification.status === "unknown")
|
|
15
|
+
return [`unknown: ${report.verification.cause.code}: ${report.verification.cause.message}`];
|
|
16
|
+
const lines = [];
|
|
17
|
+
for (const result of report.verification.results) {
|
|
18
|
+
lines.push(`command ${result.label}`, `exec ${result.command}`, `argv ${JSON.stringify(result.argv)}`, `head ${result.head}`);
|
|
19
|
+
if (result.status === "unverifiable") {
|
|
20
|
+
lines.push(`not executable: ${result.cause}`, "");
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
lines.push(`\`\`\`${result.executor}`, result.body, "\`\`\`", `exit ${result.exitCode} · duration ${result.durationMs}ms`, ...streamLines("stdout", result), ...streamLines("stderr", result), "");
|
|
24
|
+
}
|
|
25
|
+
return lines;
|
|
26
|
+
}
|
|
27
|
+
function renderScope(report) {
|
|
28
|
+
if (!report.scope)
|
|
29
|
+
return ["not evaluated"];
|
|
30
|
+
return report.scope.flatMap((row) => {
|
|
31
|
+
const decisive = row.matcher.decisivePattern
|
|
32
|
+
? `rule ${row.matcher.decisivePattern.index}:${row.matcher.decisivePattern.pattern} (${row.matcher.decisivePattern.effect})`
|
|
33
|
+
: `rule none (${row.matcher.outcome})`;
|
|
34
|
+
const explanations = row.explanations.map((item) => {
|
|
35
|
+
if (item.kind === "file-rename")
|
|
36
|
+
return ` explain file rename ${item.from} -> ${item.to} (${item.similarity}%)`;
|
|
37
|
+
if (item.kind === "symbol-rename")
|
|
38
|
+
return ` explain symbol rename ${item.from} -> ${item.to} at h${item.hunk} old:${item.oldLine ?? "-"} new:${item.newLine ?? "-"}`;
|
|
39
|
+
return ` explain import at h${item.hunk} old:${item.oldLine ?? "-"} new:${item.newLine ?? "-"}`;
|
|
40
|
+
});
|
|
41
|
+
const residue = row.residue.map((item) => ` residue h${item.hunk} old:${item.oldLine ?? "-"} new:${item.newLine ?? "-"} ${item.kind} ${item.content}`);
|
|
42
|
+
return [`${row.class} ${row.path} · ${decisive}`, ...explanations, ...residue];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function renderReadiness(report) {
|
|
46
|
+
const readiness = report.readiness;
|
|
47
|
+
if (!readiness)
|
|
48
|
+
return ["not evaluated: coordinate race"];
|
|
49
|
+
return [
|
|
50
|
+
`delivery residue tracked=${readiness.deliveryResidue.tracked.length} staged=${readiness.deliveryResidue.staged.length} unstaged=${readiness.deliveryResidue.unstaged.length} untracked=${readiness.deliveryResidue.untracked.length}`,
|
|
51
|
+
`arc open=${readiness.arc.open ?? "none"} max=${readiness.arc.max} fence=${readiness.arc.fence} loose=${readiness.arc.looseCommits.length}`,
|
|
52
|
+
`renew session=${readiness.renewSession.open ? "open" : "none"}`,
|
|
53
|
+
`rewrite guard=${readiness.rewriteGuard.liveProjection ? "live projection" : "clear"}`,
|
|
54
|
+
...readiness.dependencies.map((item) => `dependency ${item.id} ${item.satisfied ? "satisfied" : `open (${item.state})`}`),
|
|
55
|
+
`petition state=${readiness.petition.state}${readiness.petition.queue ? ` queue=${readiness.petition.queue.position ?? "?"}/${readiness.petition.queue.length}` : " queue=none"}`,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
function omissionLine(omission) {
|
|
59
|
+
const subject = omission.hunk === null ? "file" : `hunk ${omission.hunk}`;
|
|
60
|
+
return `omit ${subject} ${omission.path} · ${omission.bytes} bytes · ${omission.reason} · retrieve ${omission.retrieval.argv.map((part) => JSON.stringify(part)).join(" ")}`;
|
|
61
|
+
}
|
|
62
|
+
function renderDiff(report) {
|
|
63
|
+
if (!report.diff || !report.presentation)
|
|
64
|
+
return ["not evaluated"];
|
|
65
|
+
const selected = report.presentation.selected.map((item) => item.content);
|
|
66
|
+
const omissions = report.presentation.omissions.map(omissionLine);
|
|
67
|
+
const rows = report.files?.map((file) => `${file.status} ${file.oldPath ? `${file.oldPath} -> ` : ""}${file.path} · +${file.stats.insertions} -${file.stats.deletions} · ${file.class}`) ?? [];
|
|
68
|
+
return [
|
|
69
|
+
`${report.diff.stat.filesChanged} files · +${report.diff.stat.insertions} -${report.diff.stat.deletions}`,
|
|
70
|
+
`budget ${report.presentation.budget.limit} bytes · used ${report.presentation.budget.used} bytes · omissions ${report.presentation.omissions.length}`,
|
|
71
|
+
...rows,
|
|
72
|
+
...selected,
|
|
73
|
+
...omissions,
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
export function buildAuditResponse(report, json) {
|
|
77
|
+
const payload = report;
|
|
78
|
+
if (json)
|
|
79
|
+
return { text: JSON.stringify(report), payload };
|
|
80
|
+
const text = [
|
|
81
|
+
`Audit ${report.contract}`,
|
|
82
|
+
"",
|
|
83
|
+
"Coordinates",
|
|
84
|
+
`ledger ${report.coordinates.ledger.head}`,
|
|
85
|
+
`delivery ${report.coordinates.delivery.ref} ${report.coordinates.delivery.head} tree ${report.coordinates.delivery.tree}`,
|
|
86
|
+
`target ${report.coordinates.target.ref} ${report.coordinates.target.head} tree ${report.coordinates.target.tree}`,
|
|
87
|
+
"",
|
|
88
|
+
"Criteria",
|
|
89
|
+
...report.terms.criteria.map((term) => `criterion ${term}`),
|
|
90
|
+
...report.terms.scope.map((term) => `scope ${term}`),
|
|
91
|
+
...report.terms.appendScope.map((term) => `append-scope ${term}`),
|
|
92
|
+
"",
|
|
93
|
+
"Renew Rehearsal",
|
|
94
|
+
JSON.stringify(report.rehearsal),
|
|
95
|
+
"",
|
|
96
|
+
"Diff",
|
|
97
|
+
...renderDiff(report),
|
|
98
|
+
`counts files=${report.counts.files} selected=${report.counts.selected} omitted=${report.counts.omitted} in-scope=${report.counts.inScope} downgraded=${report.counts.downgraded} violated=${report.counts.violated} findings=${report.counts.findings}`,
|
|
99
|
+
"",
|
|
100
|
+
"Scope",
|
|
101
|
+
...renderScope(report),
|
|
102
|
+
"",
|
|
103
|
+
"Verification",
|
|
104
|
+
...renderVerification(report),
|
|
105
|
+
"Readiness",
|
|
106
|
+
...renderReadiness(report),
|
|
107
|
+
"",
|
|
108
|
+
"Findings",
|
|
109
|
+
...(report.findings.length === 0 ? ["none"] : report.findings.flatMap((finding) => [`${finding.code}: ${finding.detail}`, `Next: ${finding.nextCommand}`])),
|
|
110
|
+
].join("\n");
|
|
111
|
+
return { text, payload };
|
|
112
|
+
}
|
|
113
|
+
export function buildAuditConstructionFailure(error, json) {
|
|
114
|
+
const cause = { code: error instanceof FlowError ? error.code : "INTERNAL_STATE", message: asMessage(error) };
|
|
115
|
+
const payload = { audit: { status: "construction_failed", cause } };
|
|
116
|
+
return {
|
|
117
|
+
text: json ? JSON.stringify(payload) : `Audit construction failure\n${cause.code}: ${cause.message}`,
|
|
118
|
+
payload,
|
|
119
|
+
exitCode: 1,
|
|
120
|
+
};
|
|
121
|
+
}
|
package/build/cli/render/call.js
CHANGED
|
@@ -2,9 +2,13 @@ import { assembleResponse, buildPayload, buildSection, formatMaybe, formatWarnin
|
|
|
2
2
|
import { WARNING_SECTION_TITLE } from "./response-style.js";
|
|
3
3
|
import { CONTENT_SECTION_TITLE, formatPersistenceSummary, formatCallCompletionHeading, formatCallNextAction, INFO_AKUMA_MAX_CHARS, projectionRejoinHintLines, } from "./shared.js";
|
|
4
4
|
import { carryAddress, prependAddressReceipt, renderResolvedAddressReceipt } from "./address.js";
|
|
5
|
-
export function renderAdoptedLaunchReceipt(address, projectionId, alias, previousAliasTarget) {
|
|
5
|
+
export function renderAdoptedLaunchReceipt(address, projectionId, alias, previousAliasTarget, akumaName) {
|
|
6
6
|
return [
|
|
7
|
-
renderResolvedAddressReceipt(address, {
|
|
7
|
+
renderResolvedAddressReceipt(address, {
|
|
8
|
+
projectionId,
|
|
9
|
+
...(alias ? { projectionAlias: alias } : {}),
|
|
10
|
+
...(akumaName ? { akumaName } : {}),
|
|
11
|
+
}),
|
|
8
12
|
...(alias ? [`alias ${alias} → ${projectionId}`] : []),
|
|
9
13
|
...(alias && previousAliasTarget ? [`(moved from ${previousAliasTarget}, still running)`] : []),
|
|
10
14
|
...projectionRejoinHintLines(alias ?? projectionId),
|
|
@@ -15,14 +19,15 @@ export function buildCallResponse(result, input) {
|
|
|
15
19
|
if (!result.projection)
|
|
16
20
|
throw new Error("launched call response requires projection facts");
|
|
17
21
|
const { session: _session, evidenceCwd: _evidenceCwd, address: _address, foregroundWait: _foregroundWait, ...responseData } = result;
|
|
22
|
+
const payload = responseData;
|
|
18
23
|
const output = {
|
|
19
24
|
text: input.addressPlacement === "stdout"
|
|
20
|
-
? renderAdoptedLaunchReceipt(result.address, result.projection.id, result.projection.alias, result.projection.previousAliasTarget)
|
|
25
|
+
? renderAdoptedLaunchReceipt(result.address, result.projection.id, result.projection.alias, result.projection.previousAliasTarget, result.agent ?? input.agent)
|
|
21
26
|
: [
|
|
22
27
|
...(result.projection.alias ? [`alias ${result.projection.alias} → ${result.projection.id}`] : []),
|
|
23
28
|
...projectionRejoinHintLines(result.projection.alias ?? result.projection.id),
|
|
24
29
|
].join("\n"),
|
|
25
|
-
payload: buildPayload(
|
|
30
|
+
payload: buildPayload(payload),
|
|
26
31
|
};
|
|
27
32
|
switch (input.addressPlacement) {
|
|
28
33
|
case "stdout":
|
|
@@ -49,9 +54,10 @@ export function buildCallResponse(result, input) {
|
|
|
49
54
|
repositoryCoordinate,
|
|
50
55
|
})}`;
|
|
51
56
|
const { session: _session, evidenceCwd: _evidenceCwd, address: _address, foregroundWait: _foregroundWait, ...responseData } = result;
|
|
57
|
+
const payload = responseData;
|
|
52
58
|
const output = {
|
|
53
59
|
text,
|
|
54
|
-
payload: buildPayload(
|
|
60
|
+
payload: buildPayload(payload, input.responsePath),
|
|
55
61
|
};
|
|
56
62
|
switch (input.addressPlacement) {
|
|
57
63
|
case "stdout":
|
|
@@ -6,6 +6,40 @@ import { appendDebugLog } from "../../telemetry/debug-log.js";
|
|
|
6
6
|
import { ACTOR_IDENTITY, TOOL_NAMES, BUILTIN_AGENT_NAMES } from "../../keiyaku.js";
|
|
7
7
|
import { buildErrorResponse } from "./misc.js";
|
|
8
8
|
import { addressCarrierFromError } from "../../core/addressing.js";
|
|
9
|
+
function renderScopeViolation(evidence) {
|
|
10
|
+
if (evidence.outcome === "no-positive-match") {
|
|
11
|
+
return ` ${evidence.path}\n no positive pattern matched`;
|
|
12
|
+
}
|
|
13
|
+
const decisions = evidence.patterns.map((decision) => {
|
|
14
|
+
const isDecisive = evidence.decisivePattern?.index === decision.index
|
|
15
|
+
&& evidence.decisivePattern?.pattern === decision.pattern;
|
|
16
|
+
const effectLabel = decision.effect === "exclude" ? "excluded" : "included";
|
|
17
|
+
if (isDecisive) {
|
|
18
|
+
return ` ${decision.pattern} → decisive (${effectLabel})`;
|
|
19
|
+
}
|
|
20
|
+
return ` ${decision.pattern} → ${effectLabel}`;
|
|
21
|
+
});
|
|
22
|
+
return ` ${evidence.path}\n${decisions.join("\n")}`;
|
|
23
|
+
}
|
|
24
|
+
/** CLI face for scope_violation facts. Preserves pre-migration multi-line bytes. */
|
|
25
|
+
export function renderScopeAuditMessage(scope, evidence) {
|
|
26
|
+
const count = evidence.length;
|
|
27
|
+
const fileLabel = count === 1 ? "file" : "files";
|
|
28
|
+
const body = evidence.map(renderScopeViolation).join("\n\n");
|
|
29
|
+
return [
|
|
30
|
+
`scope violation — ${count} ${fileLabel} outside declared scope:`,
|
|
31
|
+
"",
|
|
32
|
+
body,
|
|
33
|
+
"",
|
|
34
|
+
`declared scope: ${scope.join(" ")}`,
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
function renderErrorMessage(error) {
|
|
38
|
+
if (isFlowError(error) && error.facts?.kind === "scope_violation") {
|
|
39
|
+
return renderScopeAuditMessage(error.facts.scope, error.facts.violations);
|
|
40
|
+
}
|
|
41
|
+
return asMessage(error);
|
|
42
|
+
}
|
|
9
43
|
export function classifyCliError(error) {
|
|
10
44
|
if (isFlowError(error)) {
|
|
11
45
|
return { errorType: "keiyaku_error", errorCode: error.code };
|
|
@@ -26,7 +60,7 @@ async function getAvailableActorNames(cwd, fallback) {
|
|
|
26
60
|
}
|
|
27
61
|
}
|
|
28
62
|
export async function handleCliError(input) {
|
|
29
|
-
const message =
|
|
63
|
+
const message = renderErrorMessage(input.error);
|
|
30
64
|
appendDebugLog(`${input.logLabel} error: ${message}`, { cwd: input.cwd, section: "script" });
|
|
31
65
|
const availableActorNames = await getAvailableActorNames(input.cwd, BUILTIN_AGENT_NAMES);
|
|
32
66
|
const hints = pickHintsFromError(input.error, {
|
|
@@ -42,6 +76,7 @@ export async function handleCliError(input) {
|
|
|
42
76
|
message,
|
|
43
77
|
hints,
|
|
44
78
|
review: isFlowError(input.error) ? input.error.review : undefined,
|
|
79
|
+
facts: isFlowError(input.error) ? input.error.facts : undefined,
|
|
45
80
|
errorType,
|
|
46
81
|
errorCode,
|
|
47
82
|
addressCarrier: addressCarrierFromError(input.error),
|
|
@@ -212,6 +212,10 @@ function truncateStructuredObject(data, parentKey) {
|
|
|
212
212
|
}
|
|
213
213
|
return truncated;
|
|
214
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Final serialization boundary for command payloads: optional responsePath stamp
|
|
217
|
+
* plus structured truncation. Callers supply a named *Payload that is JsonObject-compatible.
|
|
218
|
+
*/
|
|
215
219
|
export function buildPayload(data, responsePath) {
|
|
216
220
|
const dataWithPath = responsePath ? { ...data, responsePath } : data;
|
|
217
221
|
const truncatedData = truncateStructuredObject(dataWithPath);
|
|
@@ -4,9 +4,6 @@ function shortHead(hash) {
|
|
|
4
4
|
return "????????";
|
|
5
5
|
return hash.slice(0, 7);
|
|
6
6
|
}
|
|
7
|
-
function compactWhitespace(value) {
|
|
8
|
-
return value.replace(/\s+/g, " ").trim();
|
|
9
|
-
}
|
|
10
7
|
function arcSparkline(arcs) {
|
|
11
8
|
if (arcs <= 0)
|
|
12
9
|
return "";
|
|
@@ -35,31 +32,28 @@ export function renderKanshiBoard(status) {
|
|
|
35
32
|
const head = shortHead(status.defaultHead);
|
|
36
33
|
if (status.contracts.length === 0) {
|
|
37
34
|
if (status.targetFilter !== null) {
|
|
38
|
-
return `現世 ${head} · target
|
|
35
|
+
return `現世 ${head} · target selected\nno commissions on selected target\n`;
|
|
39
36
|
}
|
|
40
37
|
return `現世 ${head} 无在飞契约\n`;
|
|
41
38
|
}
|
|
42
39
|
const header = status.targetFilter !== null
|
|
43
|
-
? `現世 ${head} · target
|
|
40
|
+
? `現世 ${head} · target selected`
|
|
44
41
|
: `現世 ${head}`;
|
|
45
42
|
const lines = [header, ""];
|
|
46
43
|
for (const contract of status.contracts) {
|
|
47
44
|
const glyph = kanshiGlyph(contract);
|
|
48
|
-
const name = contract.slug;
|
|
45
|
+
const name = contract.place ? `${contract.slug} @${contract.place}` : contract.slug;
|
|
49
46
|
const spark = arcSparkline(contract.arcs);
|
|
50
47
|
const facts = [];
|
|
51
48
|
const lifecycle = contract.state.state;
|
|
52
49
|
if (lifecycle === "bound" || lifecycle === "active" || lifecycle === "petitioned") {
|
|
53
50
|
facts.push(lifecycle);
|
|
54
51
|
}
|
|
55
|
-
if (contract.place) {
|
|
56
|
-
facts.push(`@${contract.place}`);
|
|
57
|
-
}
|
|
58
|
-
const arcObjective = compactWhitespace(contract.currentArc.objective || "(no arc objective)");
|
|
59
52
|
const arcMark = contract.currentArc.state === "open"
|
|
60
53
|
? `a${contract.currentArc.number}+`
|
|
61
54
|
: `a${contract.currentArc.number}`;
|
|
62
|
-
facts.push(
|
|
55
|
+
facts.push(contract.title);
|
|
56
|
+
facts.push(arcMark);
|
|
63
57
|
facts.push(`next ${contract.nextStep.detail}`);
|
|
64
58
|
const age = formatAgeMs(contract.lastActiveMs);
|
|
65
59
|
if (age)
|
|
@@ -99,7 +93,7 @@ export function renderKanshiBoard(status) {
|
|
|
99
93
|
lines.push(` ! seat ${diagnostic.seat} duplicated with ${diagnostic.with} · ordered by contract id`);
|
|
100
94
|
continue;
|
|
101
95
|
}
|
|
102
|
-
lines.push(
|
|
96
|
+
lines.push(" ! target mismatch");
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
99
|
return `${lines.join("\n")}\n`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { textResponse } from "./shared.js";
|
|
2
|
+
/** Default kill acceptance: intent landed; wait is still required for the terminal face. */
|
|
3
|
+
export function buildKillAcceptedResponse(projectionId) {
|
|
4
|
+
return textResponse(`✓ kill ${projectionId}\n» keiyaku wait ${projectionId}`);
|
|
5
|
+
}
|
|
6
|
+
/** Kill against an already-terminal generation. */
|
|
7
|
+
export function buildKillAlreadyClosedResponse(projectionId) {
|
|
8
|
+
return textResponse(`· ${projectionId} already closed`);
|
|
9
|
+
}
|