@astrosheep/keiyaku 4.6.32 → 4.6.34
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 +18 -7
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/README.md +55 -97
- package/build/plugins/pi/keiyaku.ts +1 -142
- package/build/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/src/akuma/akuma-instance.d.ts +11 -0
- package/build/src/akuma/akuma-instance.js +1 -2
- package/build/src/akuma/akuma-observe.d.ts +8 -0
- package/build/src/akuma/akuma-observe.js +81 -14
- package/build/src/akuma/akuma-owner.d.ts +1 -0
- package/build/src/akuma/akuma-owner.js +3 -5
- package/build/src/akuma/akuma-selection-execution.d.ts +82 -7
- package/build/src/akuma/akuma-selection-execution.js +26 -27
- package/build/src/akuma/akuma-wait.d.ts +155 -1
- package/build/src/akuma/akuma-wait.js +94 -34
- package/build/src/akuma/akuma.d.ts +17 -1
- package/build/src/akuma/akuma.js +37 -18
- package/build/src/akuma/body.js +13 -18
- package/build/src/akuma/call-initial-tell.d.ts +0 -1
- package/build/src/akuma/call-initial-tell.js +0 -1
- package/build/src/akuma/heart/activity-schema.d.ts +16 -0
- package/build/src/akuma/heart/activity-schema.js +7 -0
- package/build/src/akuma/heart/facts.d.ts +1 -0
- package/build/src/akuma/heart/facts.js +14 -0
- package/build/src/akuma/heart/index.d.ts +7 -1
- package/build/src/akuma/heart/index.js +35 -9
- package/build/src/akuma/heart/rows.d.ts +1 -0
- package/build/src/akuma/heart/rows.js +4 -0
- package/build/src/akuma/heart/timeline.js +4 -4
- package/build/src/akuma/lineage-cache.d.ts +7 -2
- package/build/src/akuma/lineage-cache.js +48 -24
- package/build/src/akuma/projection-read.d.ts +4 -2
- package/build/src/akuma/projection-read.js +25 -23
- package/build/src/akuma/projection.d.ts +94 -2
- package/build/src/akuma/projection.js +47 -47
- package/build/src/akuma/provider.d.ts +2 -2
- package/build/src/akuma/provider.js +27 -20
- package/build/src/akuma/providers/acp/core.js +2 -5
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
- package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
- package/build/src/akuma/publication.js +3 -2
- package/build/src/akuma/selection-observation.d.ts +645 -0
- package/build/src/akuma/selection-observation.js +22 -7
- package/build/src/akuma/status-projection.d.ts +14 -1
- package/build/src/akuma/status-projection.js +40 -2
- package/build/src/akuma/turn-drive.js +21 -15
- package/build/src/body/amend.js +5 -17
- package/build/src/body/decode.js +11 -1
- package/build/src/body/envelope.d.ts +5 -1
- package/build/src/body/envelope.js +4 -2
- package/build/src/body/render.js +4 -6
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +10 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +5 -8
- package/build/src/cli/commands/akuma-grammar.js +52 -77
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +12 -61
- package/build/src/cli/commands/contract-grammar.d.ts +1 -0
- package/build/src/cli/commands/contract-grammar.js +39 -42
- package/build/src/cli/commands/contract-help.d.ts +6 -5
- package/build/src/cli/commands/contract-help.js +21 -13
- package/build/src/cli/commands/contract.d.ts +3 -3
- package/build/src/cli/commands/contract.js +13 -9
- package/build/src/cli/commands/debt-grammar.js +2 -4
- package/build/src/cli/parse.d.ts +4 -10
- package/build/src/cli/parse.js +2 -5
- package/build/src/cli/render/akuma-activity.d.ts +12 -34
- package/build/src/cli/render/akuma-activity.js +99 -180
- package/build/src/cli/render/akuma.d.ts +5 -11
- package/build/src/cli/render/akuma.js +22 -30
- package/build/src/cli/render/catalog.js +4 -6
- package/build/src/cli/render/contract-history.d.ts +1 -3
- package/build/src/cli/render/contract-history.js +70 -49
- package/build/src/cli/render/contract-observation.d.ts +2 -1
- package/build/src/cli/render/contract-observation.js +25 -1
- package/build/src/cli/render/contract-wait.d.ts +2 -2
- package/build/src/cli/render/contract-wait.js +21 -17
- package/build/src/cli/render/contract.js +12 -9
- package/build/src/cli/render/debt.js +1 -2
- package/build/src/cli/render/execution-progress.js +1 -3
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
- package/build/src/cli/render/kanshi-akuma.js +27 -23
- package/build/src/cli/render/kanshi.js +45 -60
- package/build/src/cli/render/receipt.d.ts +1 -1
- package/build/src/cli/render/receipt.js +33 -28
- package/build/src/cli/render/reconcile.js +2 -5
- package/build/src/cli/render/refusal.js +3 -6
- package/build/src/cli/render/terminal.d.ts +2 -4
- package/build/src/cli/render/terminal.js +10 -17
- package/build/src/cli/render/verbs.d.ts +1 -0
- package/build/src/cli/render/verbs.js +39 -34
- package/build/src/cli/runtime.js +12 -32
- package/build/src/core/facts/codec.js +7 -2
- package/build/src/core/facts/eligibility.d.ts +4 -4
- package/build/src/core/facts/eligibility.js +11 -0
- package/build/src/core/facts/fold.js +9 -5
- package/build/src/core/facts/gate.d.ts +5 -1
- package/build/src/core/facts/gate.js +14 -10
- package/build/src/core/facts/types.d.ts +5 -1
- package/build/src/core/facts/types.js +7 -0
- package/build/src/core/subject.d.ts +4 -1
- package/build/src/core/subject.js +10 -2
- package/build/src/core/verbs/amend.d.ts +15 -4
- package/build/src/core/verbs/amend.js +19 -9
- package/build/src/debt/board.d.ts +2 -1
- package/build/src/debt/board.js +3 -3
- package/build/src/debt/catalog.js +2 -1
- package/build/src/debt/document.d.ts +1 -0
- package/build/src/debt/document.js +3 -0
- package/build/src/debt/index.d.ts +2 -2
- package/build/src/debt/index.js +9 -14
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +6 -4
- package/build/src/debt/operations.d.ts +2 -1
- package/build/src/dispatch/index.d.ts +0 -17
- package/build/src/dispatch/index.js +1 -10
- package/build/src/git/identity.js +16 -45
- package/build/src/git/nuke.js +13 -23
- package/build/src/git/observe.d.ts +7 -3
- package/build/src/git/observe.js +29 -26
- package/build/src/git/process.js +11 -18
- package/build/src/git/read-observation.d.ts +5 -4
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -1
- package/build/src/git/scratch.js +2 -14
- package/build/src/git/terminal-reconcile.js +1 -13
- package/build/src/history.d.ts +26 -0
- package/build/src/history.js +43 -0
- package/build/src/index.d.ts +6 -3
- package/build/src/kanshi/counts.d.ts +15 -1
- package/build/src/kanshi/counts.js +14 -3
- package/build/src/kanshi/index.d.ts +3 -4
- package/build/src/kanshi/index.js +2 -3
- package/build/src/kanshi/read.d.ts +21 -0
- package/build/src/kanshi/read.js +7 -3
- package/build/src/kanshi/report.d.ts +94 -0
- package/build/src/library/address.d.ts +12 -5
- package/build/src/library/address.js +18 -32
- package/build/src/library/akuma-creation.d.ts +39 -0
- package/build/src/library/akuma-creation.js +3 -9
- package/build/src/library/akumas.d.ts +5 -1
- package/build/src/library/akumas.js +11 -5
- package/build/src/library/continuation.d.ts +10 -0
- package/build/src/library/contract-composition.js +10 -10
- package/build/src/library/contract-creation.js +12 -13
- package/build/src/library/contract-outcomes.d.ts +72 -1
- package/build/src/library/contract-outcomes.js +1 -0
- package/build/src/library/contract-types.d.ts +233 -25
- package/build/src/library/contract-types.js +32 -12
- package/build/src/library/contract-wait.d.ts +212 -0
- package/build/src/library/contract-wait.js +65 -49
- package/build/src/library/delivery.d.ts +25 -0
- package/build/src/library/input.d.ts +8 -26
- package/build/src/library/input.js +17 -12
- package/build/src/library/kei.js +167 -90
- package/build/src/library/keiyaku-attribution.d.ts +1 -1
- package/build/src/library/keiyaku-attribution.js +3 -1
- package/build/src/library/keiyaku-classify.js +8 -4
- package/build/src/library/keiyaku-debt.d.ts +8 -7
- package/build/src/library/keiyaku-debt.js +1 -2
- package/build/src/library/keiyaku-identity.d.ts +4 -3
- package/build/src/library/keiyaku-identity.js +35 -7
- package/build/src/library/keiyaku-verbs.d.ts +974 -1409
- package/build/src/library/keiyaku-verbs.js +154 -161
- package/build/src/library/keiyaku-wait.d.ts +753 -0
- package/build/src/library/keiyaku-wait.js +230 -0
- package/build/src/library/keiyaku.d.ts +3110 -29
- package/build/src/library/keiyaku.js +342 -438
- package/build/src/library/model-tools.d.ts +754 -0
- package/build/src/library/model-tools.js +362 -0
- package/build/src/library/outcome.js +5 -6
- package/build/src/library/refusal.d.ts +25 -1
- package/build/src/library/refusal.js +4 -5
- package/build/src/library/selection.d.ts +18 -5
- package/build/src/library/selection.js +11 -5
- package/build/src/mcp/adapter.d.ts +0 -6
- package/build/src/mcp/adapter.js +11 -160
- package/build/src/mcp/description.d.ts +2 -0
- package/build/src/mcp/description.js +2 -0
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +10 -7
- package/build/src/pi/index.d.ts +5 -0
- package/build/src/pi/index.js +99 -0
- package/build/src/pi/status.d.ts +12 -0
- package/build/src/pi/status.js +140 -0
- package/build/src/protocol/amend.d.ts +14 -3
- package/build/src/protocol/amend.js +113 -46
- package/build/src/protocol/bind.d.ts +1 -1
- package/build/src/protocol/bind.js +5 -16
- package/build/src/protocol/completion.d.ts +30 -0
- package/build/src/protocol/completion.js +8 -5
- package/build/src/protocol/deliver.js +7 -20
- package/build/src/protocol/delivery-preview.d.ts +5 -0
- package/build/src/protocol/execution-observation.d.ts +8 -0
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +4 -1
- package/build/src/protocol/operations.d.ts +56 -16
- package/build/src/protocol/operations.js +18 -32
- package/build/src/protocol/placement.js +7 -1
- package/build/src/protocol/progress.js +0 -6
- package/build/src/protocol/read/status.d.ts +52 -4
- package/build/src/protocol/read/status.js +26 -22
- package/build/src/protocol/reintegrate.js +2 -2
- package/build/src/protocol/result-leaves.d.ts +56 -8
- package/build/src/protocol/result-leaves.js +11 -2
- package/build/src/protocol/run.js +1 -4
- package/build/src/protocol/verify.d.ts +10 -0
- package/build/src/protocol/verify.js +1 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/settle.js +19 -68
- package/package.json +7 -3
- package/plugins/paseo/plugin/index.server.ts +6 -2
- package/plugins/paseo/plugin/server/attach.ts +68 -48
- package/plugins/paseo/plugin/server/directory.ts +259 -0
- package/plugins/paseo/plugin/server/mirror-identity.ts +3 -32
- package/plugins/paseo/plugin/server/reopen.ts +52 -38
- package/plugins/pi/README.md +55 -97
- package/plugins/pi/keiyaku.ts +1 -142
- package/skills/keiyaku-akuma/SKILL.md +18 -11
- package/skills/keiyaku-babysit/SKILL.md +8 -6
- package/skills/keiyaku-debt/SKILL.md +2 -1
- package/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/akuma-tools.ts +0 -283
- package/build/src/body/keys.d.ts +0 -4
- package/build/src/body/keys.js +0 -11
- package/build/src/kanshi/roster.d.ts +0 -2
- package/build/src/kanshi/roster.js +0 -2
- package/build/src/mcp/output.d.ts +0 -385
- package/build/src/mcp/output.js +0 -193
- package/plugins/pi/akuma-tools.ts +0 -283
|
@@ -1,73 +1,57 @@
|
|
|
1
1
|
import { contractAttentionFacts, abbreviateGitIds, afterWording, displayGitId, gateGlyph, requirementDisplayName, gateRequirementFacts, gitIdsInDetail, lifecycleWord, mergeSummary, progressStrip, targetMoved, targetMovementFacts, workspaceState, } from "./contract-observation.js";
|
|
2
|
-
import { DEFAULT_CLI_COLUMNS,
|
|
3
|
-
import { associationFact, formatAge, NARROW_COLUMNS,
|
|
2
|
+
import { DEFAULT_CLI_COLUMNS, entityLines, identityLine, renderBoundedPayload, renderSectionBlock, safeText, tone, } from "./terminal.js";
|
|
3
|
+
import { associationFact, formatAge, NARROW_COLUMNS, renderAkumaBoard, akumaLabel, akumaRowLines, } from "./kanshi-akuma.js";
|
|
4
4
|
import { contractDetailMark, contractMark, debtDispositionMark } from "./marks.js";
|
|
5
5
|
import { dispositionText } from "./debt.js";
|
|
6
|
-
const REVIEW_ATTENTION_MS = 15 * 60 * 1_000;
|
|
7
|
-
const PENDING_ATTENTION_MS = 60 * 60 * 1_000;
|
|
8
6
|
function contractHasError(row) {
|
|
9
7
|
return (row.title === undefined ||
|
|
10
8
|
row.attention !== undefined ||
|
|
11
9
|
(row.gates ?? []).some((gate) => gate.verdict === "unsatisfied"));
|
|
12
10
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return "alert";
|
|
16
|
-
const phaseAge = elapsedMilliseconds(row.phaseAt, observedAt);
|
|
17
|
-
if (phaseAge === null)
|
|
18
|
-
return null;
|
|
19
|
-
if (row.delivered === true && phaseAge >= REVIEW_ATTENTION_MS)
|
|
20
|
-
return "attention";
|
|
21
|
-
return row.delivered !== true && phaseAge >= PENDING_ATTENTION_MS ? "attention" : null;
|
|
22
|
-
}
|
|
23
|
-
/** Summary associations name their observed owner identity; unavailable authority stays explicit. */
|
|
24
|
-
function associationFacts(associations) {
|
|
25
|
-
return associations.map((association) => {
|
|
11
|
+
function contractSummaryFacts(row) {
|
|
12
|
+
const associations = (row.associations ?? []).flatMap((association) => {
|
|
26
13
|
if (association.kind === "unavailable")
|
|
27
|
-
return `${association.source} association unavailable
|
|
28
|
-
|
|
29
|
-
return `debt ${association.debtId}`;
|
|
30
|
-
if (association.aliases !== undefined)
|
|
31
|
-
return `akuma ${association.akumaId} (${association.aliases.join(" ")})`;
|
|
32
|
-
return association.aliasesUnavailable === true
|
|
33
|
-
? `akuma ${association.akumaId} (aliases unavailable)`
|
|
34
|
-
: `akuma ${association.akumaId}`;
|
|
14
|
+
return [`${association.source} association unavailable`];
|
|
15
|
+
return association.kind === "debt" ? [`debt ${association.debtId}`] : [];
|
|
35
16
|
});
|
|
36
|
-
}
|
|
37
|
-
function contractSummaryFacts(row) {
|
|
38
|
-
const associations = row.associations === undefined ? [] : associationFacts(row.associations);
|
|
39
17
|
return [progressStrip(row), ...contractAttentionFacts(row), ...associations];
|
|
40
18
|
}
|
|
41
19
|
function renderWorldContractRow(row, observedAt, context) {
|
|
42
|
-
const statusTone =
|
|
20
|
+
const statusTone = contractHasError(row) ? "alert" : null;
|
|
43
21
|
return entityLines({
|
|
44
22
|
mark: statusTone === null ? contractMark(row) : tone(contractMark(row), statusTone, context.color),
|
|
45
23
|
identity: row.id,
|
|
46
|
-
state: formatAge(row.phaseAt, observedAt)
|
|
24
|
+
state: `${lifecycleWord(row.phase)} · ${formatAge(row.phaseAt, observedAt)}`,
|
|
47
25
|
title: row.title ?? "title unavailable",
|
|
48
26
|
facts: contractSummaryFacts(row),
|
|
49
27
|
context,
|
|
50
28
|
});
|
|
51
29
|
}
|
|
52
30
|
/** The World omits an empty Contract section. */
|
|
53
|
-
function contractBoardRows(board, observedAt, context) {
|
|
31
|
+
function contractBoardRows(board, observedAt, context, children, aliasesUnavailable) {
|
|
32
|
+
const nestedContext = { ...context, columns: Math.max(1, context.columns - 2) };
|
|
54
33
|
const rendered = renderSectionBlock({
|
|
55
34
|
name: "CONTRACTS",
|
|
56
|
-
rows: (board.rows ?? []).map((row) =>
|
|
35
|
+
rows: (board.rows ?? []).map((row) => [
|
|
36
|
+
...renderWorldContractRow(row, observedAt, context),
|
|
37
|
+
...(children.get(row.id) ?? []).flatMap((child) => {
|
|
38
|
+
const { contract: _contract, ...facts } = child;
|
|
39
|
+
return akumaRowLines(facts, aliasesUnavailable, observedAt, nestedContext).map((line) => ` ${line}`);
|
|
40
|
+
}),
|
|
41
|
+
]),
|
|
57
42
|
hasMore: board.more === true,
|
|
58
43
|
});
|
|
59
44
|
return ["CONTRACTS // recent", ...rendered.slice(1)];
|
|
60
45
|
}
|
|
61
|
-
function renderContractBoard(section, observedAt, context) {
|
|
46
|
+
function renderContractBoard(section, observedAt, context, children, aliasesUnavailable) {
|
|
62
47
|
if (section.kind === "absent")
|
|
63
48
|
return ["CONTRACTS // absent"];
|
|
64
49
|
if (section.kind === "failed") {
|
|
65
|
-
|
|
66
|
-
return failure;
|
|
50
|
+
return ["CONTRACTS // unavailable", "", tone(`! ${safeText(section.diagnostic)}`, "alert", context.color)];
|
|
67
51
|
}
|
|
68
52
|
if ((section.rows ?? []).length === 0)
|
|
69
53
|
return [];
|
|
70
|
-
return contractBoardRows(section, observedAt, context);
|
|
54
|
+
return contractBoardRows(section, observedAt, context, children, aliasesUnavailable);
|
|
71
55
|
}
|
|
72
56
|
function detailHasError(row) {
|
|
73
57
|
if (row.title === undefined)
|
|
@@ -79,7 +63,7 @@ function detailHasError(row) {
|
|
|
79
63
|
row.workspace.kind === "unavailable" ||
|
|
80
64
|
row.issue !== undefined);
|
|
81
65
|
}
|
|
82
|
-
function semanticBlock(
|
|
66
|
+
function semanticBlock(facts) {
|
|
83
67
|
if (facts.length === 0)
|
|
84
68
|
return [];
|
|
85
69
|
return facts.map((fact) => ` ${safeText(fact)}`);
|
|
@@ -126,13 +110,8 @@ function linkedAkumaRows(row) {
|
|
|
126
110
|
if ("kind" in roster)
|
|
127
111
|
return [" akuma association unavailable"];
|
|
128
112
|
return roster.map((attached) => {
|
|
129
|
-
const aliases = attached.
|
|
130
|
-
|
|
131
|
-
: attached.aliasesUnavailable === true
|
|
132
|
-
? "aliases unavailable"
|
|
133
|
-
: "";
|
|
134
|
-
const identity = [safeText(attached.id), aliases.length === 0 ? "" : `(${aliases})`].filter(Boolean).join(" ");
|
|
135
|
-
return ` akuma ${identity}`;
|
|
113
|
+
const aliases = safeText(akumaLabel(attached, attached.aliasesUnavailable === true));
|
|
114
|
+
return ` akuma ${safeText(attached.id)}${aliases === "" ? "" : ` ${aliases}`}`;
|
|
136
115
|
});
|
|
137
116
|
}
|
|
138
117
|
function mergeFacts(row) {
|
|
@@ -192,29 +171,29 @@ function renderSelectedContractRow(id, row, context) {
|
|
|
192
171
|
const outcome = terminalFacts(row, context, abbreviations);
|
|
193
172
|
lines.push(...outcome.map((fact) => (fact.startsWith(" ") ? fact : ` ${safeText(fact)}`)));
|
|
194
173
|
// A terminal Contract still carries a physical retention issue; its worktree is expected to be gone.
|
|
195
|
-
lines.push(...semanticBlock(
|
|
174
|
+
lines.push(...semanticBlock(row.issue === undefined ? [] : [`! ${issueAlarm(row.issue, row.target)}`]));
|
|
196
175
|
lines.push(...linkedAkumaRows(row));
|
|
197
176
|
return lines;
|
|
198
177
|
}
|
|
199
178
|
const deniedReview = (row.gates ?? [])
|
|
200
179
|
.find((gate) => gate.gate === "reviewed")
|
|
201
180
|
?.requirements.find((requirement) => requirement.current.kind === "attested" && requirement.current.verdict === "unsatisfied");
|
|
202
|
-
lines.push(...semanticBlock(
|
|
203
|
-
lines.push(...semanticBlock(
|
|
204
|
-
lines.push(...semanticBlock(
|
|
181
|
+
lines.push(...semanticBlock([detailProgressStrip(row)]));
|
|
182
|
+
lines.push(...semanticBlock((row.gates ?? []).flatMap(gateRequirementFacts)));
|
|
183
|
+
lines.push(...semanticBlock((row.after ?? []).map(afterWording)));
|
|
205
184
|
if (row.delivery !== undefined) {
|
|
206
185
|
const moved = targetMoved(row);
|
|
207
|
-
lines.push(...semanticBlock(
|
|
186
|
+
lines.push(...semanticBlock([
|
|
208
187
|
`candidate ${displayGitId(row.delivery.candidate, abbreviations)}`,
|
|
209
188
|
`integration result ${displayGitId(row.delivery.integration, abbreviations)}${moved ? " · target moved since" : ""}`,
|
|
210
189
|
...(moved ? targetMovementFacts(row, abbreviations) : []),
|
|
211
|
-
]
|
|
190
|
+
]));
|
|
212
191
|
}
|
|
213
192
|
if (deniedReview?.current.kind === "attested" && deniedReview.current.summary !== undefined)
|
|
214
193
|
lines.push(...payload("review ×", deniedReview.current.summary, context));
|
|
215
194
|
lines.push(...linkedAkumaRows(row));
|
|
216
|
-
lines.push(...semanticBlock(
|
|
217
|
-
lines.push(...semanticBlock(
|
|
195
|
+
lines.push(...semanticBlock(worktreeFacts(row)));
|
|
196
|
+
lines.push(...semanticBlock(liveAlarms(row)));
|
|
218
197
|
return lines;
|
|
219
198
|
}
|
|
220
199
|
function debtFailureFact(failure) {
|
|
@@ -241,21 +220,27 @@ function renderDebts(report, context) {
|
|
|
241
220
|
if (section.kind === "absent")
|
|
242
221
|
return ["DEBTS // absent"];
|
|
243
222
|
if (section.kind === "failed") {
|
|
244
|
-
|
|
245
|
-
"DEBTS // unavailable",
|
|
246
|
-
"",
|
|
247
|
-
tone(`! ${safeText(debtFailureFact(section))}`, "alert", context.color),
|
|
248
|
-
];
|
|
249
|
-
return failure;
|
|
223
|
+
return ["DEBTS // unavailable", "", tone(`! ${safeText(debtFailureFact(section))}`, "alert", context.color)];
|
|
250
224
|
}
|
|
251
225
|
return (section.rows ?? []).length === 0 ? [] : debtBoardRows(section, context);
|
|
252
226
|
}
|
|
227
|
+
function renderUngroupedAkumas(report, rows, context) {
|
|
228
|
+
return renderAkumaBoard(report.akumas, report.observedAt, context, [], rows);
|
|
229
|
+
}
|
|
253
230
|
export function renderKanshiText(report, context = { columns: DEFAULT_CLI_COLUMNS, color: false }) {
|
|
254
231
|
if (!("contracts" in report))
|
|
255
232
|
return renderSelectedContract(report, context).join("\n");
|
|
233
|
+
const children = new Map(report.contracts.kind === "present" ? (report.contracts.rows ?? []).map((row) => [row.id, []]) : []);
|
|
234
|
+
const ungrouped = [];
|
|
235
|
+
if (report.akumas.kind === "present") {
|
|
236
|
+
for (const row of report.akumas.rows ?? []) {
|
|
237
|
+
const group = row.contract?.kind === "associated" ? children.get(row.contract.contractId) : undefined;
|
|
238
|
+
(group ?? ungrouped).push(row);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
256
241
|
const blocks = [
|
|
257
|
-
renderContractBoard(report.contracts, report.observedAt, context),
|
|
258
|
-
|
|
242
|
+
renderContractBoard(report.contracts, report.observedAt, context, children, report.akumas.kind === "present" && report.akumas.aliasesError !== undefined),
|
|
243
|
+
renderUngroupedAkumas(report, ungrouped, context),
|
|
259
244
|
renderDebts(report, context),
|
|
260
245
|
].filter((block) => block.length > 0);
|
|
261
246
|
return blocks.length === 0 ? "○ world empty" : blocks.map((block) => block.join("\n")).join("\n\n");
|
|
@@ -39,7 +39,7 @@ export declare function targetMovementRows(lines: string[], placement: Readonly<
|
|
|
39
39
|
}>, columns: number): void;
|
|
40
40
|
export declare function gatesAwaitLines(placement: PlacementStop | undefined): readonly string[];
|
|
41
41
|
/** The performed work and its admission conclusion, with no aggregate gate testimony. */
|
|
42
|
-
export declare function verificationCheckLines(checks: readonly VerificationCheck[],
|
|
42
|
+
export declare function verificationCheckLines(checks: readonly VerificationCheck[], columns: number, addressed: string, surface?: TextRenderContext["surface"]): readonly string[];
|
|
43
43
|
type RecoverySnapshot = string | Readonly<{
|
|
44
44
|
snapshot: string;
|
|
45
45
|
contractId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { contractOperationName, requirementDisplayName } from "./contract-observation.js";
|
|
1
|
+
import { contractOperationName, requirementDisplayName, staleReasonFact } from "./contract-observation.js";
|
|
2
2
|
import { renderRefusalFacts } from "./refusal.js";
|
|
3
|
-
import { DEFAULT_CLI_COLUMNS, displayColumns, orderRefusalFacts, quotedText, renderOpaqueBlock, safeText, } from "./terminal.js";
|
|
3
|
+
import { DEFAULT_CLI_COLUMNS, displayColumns, kindWords, orderRefusalFacts, quotedText, renderOpaqueBlock, safeText, } from "./terminal.js";
|
|
4
4
|
import { abbreviateGitIds, displayGitId } from "./contract-observation.js";
|
|
5
5
|
export function receiptRow(lines, mark, label, segments, columns) {
|
|
6
6
|
const prefix = mark.trim().length === 0 ? " " : `${mark} `;
|
|
@@ -44,9 +44,6 @@ export function titleLines(mark, title, contract, columns = DEFAULT_CLI_COLUMNS)
|
|
|
44
44
|
const inline = `${base} ${contract}`;
|
|
45
45
|
return displayColumns(inline) <= columns ? [inline] : [base, ` contract ${safeText(contract)}`];
|
|
46
46
|
}
|
|
47
|
-
function words(kind) {
|
|
48
|
-
return kind.replaceAll("-", " ");
|
|
49
|
-
}
|
|
50
47
|
function unmetRequirementLines(unmet, columns) {
|
|
51
48
|
const lines = [];
|
|
52
49
|
const ids = abbreviateGitIds(unmet.flatMap((problem) => problem.state === "stale" ? [problem.previousContentId ?? "", problem.currentContentId ?? ""] : []));
|
|
@@ -55,6 +52,7 @@ function unmetRequirementLines(unmet, columns) {
|
|
|
55
52
|
const detail = problem.state === "stale"
|
|
56
53
|
? [
|
|
57
54
|
{ text: "stale" },
|
|
55
|
+
...(problem.reason === undefined ? [] : [{ text: staleReasonFact(problem.reason) }]),
|
|
58
56
|
...(problem.previousContentId === undefined || problem.currentContentId === undefined
|
|
59
57
|
? []
|
|
60
58
|
: [
|
|
@@ -75,7 +73,7 @@ export { unmetRequirementLines };
|
|
|
75
73
|
function retryRows(reason, columns, dependent) {
|
|
76
74
|
const lines = [];
|
|
77
75
|
receiptRow(lines, "?", "retry", [
|
|
78
|
-
{ text:
|
|
76
|
+
{ text: kindWords(reason.reason) },
|
|
79
77
|
...(dependent === undefined ? [] : [{ text: "·" }, { text: dependent, opaque: true }]),
|
|
80
78
|
], columns);
|
|
81
79
|
if (reason.reason === "publication-failed")
|
|
@@ -99,7 +97,7 @@ function runtimeStopLines(stop, columns, dependent) {
|
|
|
99
97
|
const segments = dependent === undefined ? [] : [{ text: "·" }, { text: dependent, opaque: true }];
|
|
100
98
|
if (stop.kind === "environment-hook-failure")
|
|
101
99
|
segments.push({ text: `name ${quotedText(stop.name)}` });
|
|
102
|
-
receiptRow(lines, "!", dependent ??
|
|
100
|
+
receiptRow(lines, "!", dependent ?? kindWords(stop.kind), segments, columns);
|
|
103
101
|
const diagnostic = "diagnostic" in stop ? stop.diagnostic : undefined;
|
|
104
102
|
if (diagnostic !== undefined && diagnostic.length > 0)
|
|
105
103
|
receiptPayload(lines, "reason", diagnostic);
|
|
@@ -127,10 +125,10 @@ function requirementStopRows(stop, columns, dependent) {
|
|
|
127
125
|
function availabilityStopRows(stop, columns, dependent) {
|
|
128
126
|
const lines = [];
|
|
129
127
|
if (stop.kind !== "target-workspace-unavailable") {
|
|
130
|
-
dependentRow(lines, dependent,
|
|
128
|
+
dependentRow(lines, dependent, kindWords(stop.kind), columns);
|
|
131
129
|
return lines;
|
|
132
130
|
}
|
|
133
|
-
receiptRow(lines, "!", "target workspace unavailable", [{ text: stop.targetContractId, opaque: true }, { text:
|
|
131
|
+
receiptRow(lines, "!", "target workspace unavailable", [{ text: stop.targetContractId, opaque: true }, { text: kindWords(stop.reason) }], columns);
|
|
134
132
|
return lines;
|
|
135
133
|
}
|
|
136
134
|
function outcomeStopRows(stop, columns, addressed, dependent, surface) {
|
|
@@ -251,29 +249,27 @@ export function gatesAwaitLines(placement) {
|
|
|
251
249
|
return events.length === 0 ? [] : [`⧗ awaiting ${events.join(", ")}`];
|
|
252
250
|
}
|
|
253
251
|
/** The performed work and its admission conclusion, with no aggregate gate testimony. */
|
|
254
|
-
export function verificationCheckLines(checks,
|
|
255
|
-
const ids = abbreviateGitIds([snapshot]);
|
|
252
|
+
export function verificationCheckLines(checks, columns, addressed, surface) {
|
|
256
253
|
const lines = [];
|
|
257
254
|
for (const check of checks) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
{ text: check.requirement, opaque: true },
|
|
261
|
-
{ text: `· snapshot ${displayGitId(snapshot, ids)}` },
|
|
262
|
-
], columns);
|
|
263
|
-
if (check.kind !== "terminal") {
|
|
255
|
+
if (check.kind === "stopped") {
|
|
256
|
+
receiptRow(lines, "!", `check ${check.index}`, [{ text: "execution stopped" }], columns);
|
|
264
257
|
lines.push(...stopLines(check.stop, columns, addressed, undefined, surface));
|
|
265
258
|
}
|
|
266
259
|
else {
|
|
267
|
-
|
|
260
|
+
const admission = check.admission;
|
|
261
|
+
const recording = typeof admission !== "string"
|
|
262
|
+
? "admission stopped"
|
|
263
|
+
: admission === "unrecorded"
|
|
264
|
+
? "not recorded"
|
|
265
|
+
: admission === "admitted"
|
|
266
|
+
? "recorded"
|
|
267
|
+
: "reused";
|
|
268
|
+
receiptRow(lines, check.verdict === "satisfied" ? "✓" : "×", `check ${check.index}`, [{ text: `${check.verdict} · ${recording}` }], columns);
|
|
268
269
|
if (check.verdict === "unsatisfied")
|
|
269
270
|
receiptPayload(lines, "summary", check.summary);
|
|
270
|
-
|
|
271
|
-
if (typeof admission === "string")
|
|
272
|
-
receiptRow(lines, " ", "attestation", [{ text: admission === "unrecorded" ? "not recorded" : admission }], columns);
|
|
273
|
-
else {
|
|
274
|
-
receiptRow(lines, "!", "admission", [{ text: "stopped" }], columns);
|
|
271
|
+
if (typeof admission !== "string")
|
|
275
272
|
lines.push(...stopLines(admission, columns, addressed, undefined, surface));
|
|
276
|
-
}
|
|
277
273
|
}
|
|
278
274
|
if (check.retainedPath !== undefined)
|
|
279
275
|
receiptRow(lines, " ", "scratch retained", [{ text: check.retainedPath, opaque: true }], columns);
|
|
@@ -369,7 +365,7 @@ function effectLines(effect, columns, primary) {
|
|
|
369
365
|
return lines;
|
|
370
366
|
case "worktree-created":
|
|
371
367
|
case "worktree-removed":
|
|
372
|
-
receiptRow(lines, " ",
|
|
368
|
+
receiptRow(lines, " ", kindWords(effect.kind), [{ text: effect.path, opaque: true }], columns);
|
|
373
369
|
return lines;
|
|
374
370
|
}
|
|
375
371
|
}
|
|
@@ -385,8 +381,17 @@ function placementEvidenceLines(placement, columns, addressed, surface) {
|
|
|
385
381
|
/** Confirmed admissions and irreversible movement survive a trailing failure without a journal reread. */
|
|
386
382
|
export function executionEvidenceLines(receipt, columns, surface) {
|
|
387
383
|
const lines = [];
|
|
388
|
-
|
|
389
|
-
lines
|
|
384
|
+
if (receipt.snapshot !== undefined)
|
|
385
|
+
receiptRow(lines, " ", "snapshot", [{ text: displayGitId(receipt.snapshot, abbreviateGitIds([receipt.snapshot])) }], columns);
|
|
386
|
+
if (receipt.checks !== undefined)
|
|
387
|
+
lines.push(...verificationCheckLines(receipt.checks, columns, receipt.contractId ?? "", surface));
|
|
388
|
+
for (const admission of receipt.admitted ?? []) {
|
|
389
|
+
const shownByCheck = admission.kind === "attestation" &&
|
|
390
|
+
(admission.contractId === undefined || admission.contractId === receipt.contractId) &&
|
|
391
|
+
receipt.checks?.some((check) => check.kind === "terminal" && check.admission === "admitted" && check.requirement === admission.requirement);
|
|
392
|
+
if (!shownByCheck)
|
|
393
|
+
lines.push(...admittedLines(admission, columns, receipt.contractId));
|
|
394
|
+
}
|
|
390
395
|
if (receipt.placement !== undefined)
|
|
391
396
|
lines.push(...placementEvidenceLines(receipt.placement, columns, receipt.contractId ?? "", surface));
|
|
392
397
|
for (const effect of receipt.effects ?? [])
|
|
@@ -406,7 +411,7 @@ export function executionFailureLines(operation, receipt, failure, columns, surf
|
|
|
406
411
|
for (const [owner, count] of Object.entries(receipt.removed ?? {}))
|
|
407
412
|
receiptRow(lines, " ", `${owner} removed`, [{ text: String(count) }], columns);
|
|
408
413
|
for (const issue of receipt.issues ?? []) {
|
|
409
|
-
receiptRow(lines, "!",
|
|
414
|
+
receiptRow(lines, "!", kindWords(issue.kind), issue.kind === "reset-owner-stopped" ? [{ text: issue.owner }] : [], columns);
|
|
410
415
|
receiptPayload(lines, "reason", issue.diagnostic);
|
|
411
416
|
}
|
|
412
417
|
}
|
|
@@ -2,10 +2,7 @@ import { invocationIssueIsFailure } from "../../library/outcome.js";
|
|
|
2
2
|
import { contractIssueLines } from "./contract.js";
|
|
3
3
|
import { abbreviateGitIds, displayGitId } from "./contract-observation.js";
|
|
4
4
|
import { receiptRow } from "./receipt.js";
|
|
5
|
-
import { DEFAULT_CLI_COLUMNS, safeText } from "./terminal.js";
|
|
6
|
-
function words(kind) {
|
|
7
|
-
return kind.replaceAll("-", " ");
|
|
8
|
-
}
|
|
5
|
+
import { DEFAULT_CLI_COLUMNS, kindWords, safeText } from "./terminal.js";
|
|
9
6
|
function effectSegments(effect) {
|
|
10
7
|
switch (effect.kind) {
|
|
11
8
|
case "ref": {
|
|
@@ -29,7 +26,7 @@ function effectSegments(effect) {
|
|
|
29
26
|
return [{ text: "debt settled" }, { text: effect.debtId, opaque: true }];
|
|
30
27
|
case "worktree-created":
|
|
31
28
|
case "worktree-removed":
|
|
32
|
-
return [{ text:
|
|
29
|
+
return [{ text: kindWords(effect.kind) }, { text: effect.path, opaque: true }];
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
function nativeDisposition(report) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { usageAcceptanceLines } from "../usage.js";
|
|
2
2
|
import { contractOperationName, shortGitId } from "./contract-observation.js";
|
|
3
|
-
import { DEFAULT_CLI_COLUMNS, formatNextCall, orderRefusalFacts, renderOpaqueBlock, safeText, } from "./terminal.js";
|
|
3
|
+
import { DEFAULT_CLI_COLUMNS, formatNextCall, kindWords, orderRefusalFacts, renderOpaqueBlock, safeText, } from "./terminal.js";
|
|
4
4
|
function wrap(lines, text, indent, columns) {
|
|
5
5
|
lines.push(...renderOpaqueBlock(text, indent, columns));
|
|
6
6
|
}
|
|
7
|
-
function words(kind) {
|
|
8
|
-
return kind.replaceAll("-", " ");
|
|
9
|
-
}
|
|
10
7
|
function collectionLines(name, members, indent) {
|
|
11
8
|
if (members.length === 0)
|
|
12
9
|
return [];
|
|
@@ -23,7 +20,7 @@ const REFUSAL_WORDS = {
|
|
|
23
20
|
"contract-missing": "contract missing",
|
|
24
21
|
};
|
|
25
22
|
function refusalWords(kind) {
|
|
26
|
-
return REFUSAL_WORDS[kind] ??
|
|
23
|
+
return REFUSAL_WORDS[kind] ?? kindWords(kind);
|
|
27
24
|
}
|
|
28
25
|
function renderDirtyRefusal(refusal, indent, columns, surface) {
|
|
29
26
|
const lines = [];
|
|
@@ -134,7 +131,7 @@ function refusalFacts(refusal, indent, columns, addressed, surface) {
|
|
|
134
131
|
if (refusal.kind === "target-workspace-unavailable") {
|
|
135
132
|
return [
|
|
136
133
|
`${indent}reason target workspace unavailable`,
|
|
137
|
-
...targetRefusalLines(target, indent, identity,
|
|
134
|
+
...targetRefusalLines(target, indent, identity, kindWords(refusal.reason)),
|
|
138
135
|
];
|
|
139
136
|
}
|
|
140
137
|
if (refusal.kind === "target-contract-missing" || refusal.kind === "target-contract-terminal") {
|
|
@@ -21,10 +21,6 @@ export declare function takeDisplayColumns(value: string, maximum: number): Read
|
|
|
21
21
|
text: string;
|
|
22
22
|
rest: string;
|
|
23
23
|
}>;
|
|
24
|
-
export declare function takeDisplayColumnsFromEnd(value: string, maximum: number): Readonly<{
|
|
25
|
-
text: string;
|
|
26
|
-
rest: string;
|
|
27
|
-
}>;
|
|
28
24
|
export declare function truncateDisplayText(value: string, maximum: number): string;
|
|
29
25
|
/** Pad text to a terminal-column width; raw string length is never the measuring stick. */
|
|
30
26
|
export declare function padToDisplay(text: string, width: number): string;
|
|
@@ -76,6 +72,8 @@ export declare function elapsedMilliseconds(source: string | null | undefined, o
|
|
|
76
72
|
*/
|
|
77
73
|
export declare function ageText(source: string, observedAt: string, future?: "now" | "future"): string;
|
|
78
74
|
export declare function tone(value: string, kind: SemanticTone, color: boolean): string;
|
|
75
|
+
/** One machine kind as words; every receipt vocabulary spells kinds through this one rule. */
|
|
76
|
+
export declare function kindWords(kind: string): string;
|
|
79
77
|
export declare function plumbFacts(facts: readonly string[], columns: number): readonly string[];
|
|
80
78
|
export declare function identityLine(mark: string, identity: string, extra?: string): string;
|
|
81
79
|
export declare function entityLines(entity: Readonly<{
|
|
@@ -113,18 +113,6 @@ export function takeDisplayColumns(value, maximum) {
|
|
|
113
113
|
}
|
|
114
114
|
return { text: clusters.slice(0, index).join(""), rest: clusters.slice(index).join("") };
|
|
115
115
|
}
|
|
116
|
-
export function takeDisplayColumnsFromEnd(value, maximum) {
|
|
117
|
-
const clusters = [...GRAPHEMES.segment(value)].map(({ segment }) => segment);
|
|
118
|
-
let columns = 0;
|
|
119
|
-
let index = clusters.length;
|
|
120
|
-
for (; index > 0; index -= 1) {
|
|
121
|
-
const width = graphemeColumns(clusters[index - 1]);
|
|
122
|
-
if (columns + width > maximum)
|
|
123
|
-
break;
|
|
124
|
-
columns += width;
|
|
125
|
-
}
|
|
126
|
-
return { text: clusters.slice(index).join(""), rest: clusters.slice(0, index).join("") };
|
|
127
|
-
}
|
|
128
116
|
export function truncateDisplayText(value, maximum) {
|
|
129
117
|
const clean = safeText(value);
|
|
130
118
|
if (displayColumns(clean) <= maximum)
|
|
@@ -182,10 +170,11 @@ export function renderBoundedPayload(input) {
|
|
|
182
170
|
const diagnostic = safeText(input.trailer.diagnostic).replace(/\s+/gu, " ").trim();
|
|
183
171
|
const extra = diagnostic === "" ? "" : `${suffix === "" ? " — " : " · "}${diagnostic}`;
|
|
184
172
|
const extraWidth = displayColumns(extra);
|
|
185
|
-
const [firstBody] = GRAPHEMES.segment(input.text
|
|
186
|
-
const bodyMinimum = displayColumns(firstBody.segment) + omissionWidth;
|
|
187
|
-
// Reserve
|
|
188
|
-
//
|
|
173
|
+
const [firstBody] = GRAPHEMES.segment(input.text);
|
|
174
|
+
const bodyMinimum = firstBody === undefined ? 0 : displayColumns(firstBody.segment) + omissionWidth;
|
|
175
|
+
// Reserve the body's first grapheme plus its omission and any diagnostic omission before clipping the prefix.
|
|
176
|
+
// An absent preview reserves nothing, so the tool identity keeps its full width; sharing spare cells
|
|
177
|
+
// monotonically keeps wider rows from reducing the body allowance.
|
|
189
178
|
const minimumPayload = bodyMinimum + (extra === "" ? 0 : omissionWidth);
|
|
190
179
|
const prefixWidth = Math.min(displayColumns(input.first), Math.max(0, columns - displayColumns(suffix) - minimumPayload));
|
|
191
180
|
const labelWidth = Math.max(0, prefixWidth - displayColumns(" "));
|
|
@@ -196,7 +185,7 @@ export function renderBoundedPayload(input) {
|
|
|
196
185
|
const body = renderFoldedPayload({
|
|
197
186
|
...input,
|
|
198
187
|
first,
|
|
199
|
-
text: input.text
|
|
188
|
+
text: input.text,
|
|
200
189
|
columns: columns - displayColumns(suffix) - diagnosticReserve,
|
|
201
190
|
maxLines: 1,
|
|
202
191
|
})[0];
|
|
@@ -432,6 +421,10 @@ export function tone(value, kind, color) {
|
|
|
432
421
|
const code = kind === "dim" ? 2 : kind === "recent" ? 32 : kind === "attention" ? 33 : 31;
|
|
433
422
|
return `\u001b[${code}m${value}\u001b[0m`;
|
|
434
423
|
}
|
|
424
|
+
/** One machine kind as words; every receipt vocabulary spells kinds through this one rule. */
|
|
425
|
+
export function kindWords(kind) {
|
|
426
|
+
return kind.replaceAll("-", " ");
|
|
427
|
+
}
|
|
435
428
|
export function plumbFacts(facts, columns) {
|
|
436
429
|
const lines = [];
|
|
437
430
|
let current = " ";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { VerbCompletion, VerbInput, VerbName, VerbOutput } from "../../library/keiyaku-verbs.js";
|
|
2
2
|
import { type TextRenderContext } from "./terminal.js";
|
|
3
|
+
export declare function aliasSelector(selector: string | undefined): string | undefined;
|
|
3
4
|
/** Render native completion values without observing the World or parsing output. */
|
|
4
5
|
export declare function renderVerb<K extends VerbName>(name: K, input: VerbInput<K>, completion: VerbCompletion<VerbOutput<K>>, context: TextRenderContext & Readonly<{
|
|
5
6
|
alias?: string;
|
|
@@ -3,13 +3,13 @@ import { AkumaNameError } from "../../akuma/archetype.js";
|
|
|
3
3
|
import { AkumaAddressError, AkumaWorldScopeError } from "../../library/address.js";
|
|
4
4
|
import { KeiyakuArcDocumentError, KeiyakuUsageError } from "../../library/keiyaku-coordinates.js";
|
|
5
5
|
import { KeiyakuError, projectFailure } from "../../library/outcome.js";
|
|
6
|
-
import { askRawAnswer,
|
|
6
|
+
import { askRawAnswer, historyRawAnswer, historyText, snapshotText, tellControlLines, tellText, waitText, } from "./akuma-activity.js";
|
|
7
7
|
import { renderCallText, renderForkText, renderKillText, renderSpawnFailure, waitedTellProgress } from "./akuma.js";
|
|
8
8
|
import { renderAkumaNameCatalogue, renderContractCatalogue } from "./catalog.js";
|
|
9
9
|
import { renderAkumaBoard } from "./kanshi-akuma.js";
|
|
10
10
|
import { contractIssueLines, renderAccepted, renderContractHistory, renderRetry, } from "./contract.js";
|
|
11
11
|
import { renderDeliveryPreview } from "./delivery-preview.js";
|
|
12
|
-
import {
|
|
12
|
+
import { contractWaitMemberText } from "./contract-wait.js";
|
|
13
13
|
import { renderDebtList, renderDebtMutation, renderDebtShow, renderDebtUpdate, renderDoctor } from "./debt.js";
|
|
14
14
|
import { renderKanshiText } from "./kanshi.js";
|
|
15
15
|
import { renderNukeText } from "./nuke.js";
|
|
@@ -20,7 +20,7 @@ import { renderRegionText } from "./region.js";
|
|
|
20
20
|
import { renderSettingsText } from "./settings.js";
|
|
21
21
|
import { formatNextCall, safeText } from "./terminal.js";
|
|
22
22
|
import { renderWhoami } from "./whoami.js";
|
|
23
|
-
function
|
|
23
|
+
export function aliasSelector(selector) {
|
|
24
24
|
return selector?.startsWith("@") === true ? selector : undefined;
|
|
25
25
|
}
|
|
26
26
|
function missing(operation, contract, context) {
|
|
@@ -114,35 +114,41 @@ function renderRegion(input, result, context) {
|
|
|
114
114
|
return renderRegionText(result, input);
|
|
115
115
|
}
|
|
116
116
|
function renderWait(input, result, context) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
const selectedAlias = input.selectors.length === 1 ? aliasSelector(input.selectors[0]) : undefined;
|
|
118
|
+
const rows = result.members.map((member) => {
|
|
119
|
+
if (member.kind === "contract")
|
|
120
|
+
return contractWaitMemberText(member.observation);
|
|
121
|
+
if (member.observation.kind === "unknown")
|
|
122
|
+
return `? ${member.observation.id} (unobserved)`;
|
|
123
|
+
return waitText({ kind: "akuma", reason: result.reason === "deadline" ? "deadline" : "completed", results: [member.observation] }, selectedAlias === undefined ? {} : { alias: selectedAlias }, context);
|
|
124
|
+
});
|
|
125
|
+
return [result.reason, ...rows].join("\n");
|
|
122
126
|
}
|
|
123
127
|
function renderHistory(query, result, context) {
|
|
124
|
-
const options = query;
|
|
125
128
|
if (query.selector.startsWith("kei/")) {
|
|
126
129
|
if (result.kind === "contract-missing")
|
|
127
|
-
return missing("history",
|
|
128
|
-
if (result.kind
|
|
130
|
+
return missing("history", result.contractId, context);
|
|
131
|
+
if (result.kind === "contract-unknown-history")
|
|
132
|
+
return `${result.contractId} has no matching history at ${"item" in query ? query.item : ""}`;
|
|
133
|
+
if (result.kind !== "contract" && result.kind !== "contract-exact")
|
|
129
134
|
throw new Error("Contract history returned a non-Contract result");
|
|
130
|
-
return renderContractHistory(result
|
|
135
|
+
return renderContractHistory(result);
|
|
131
136
|
}
|
|
132
|
-
if (result.kind === "contract" ||
|
|
137
|
+
if (result.kind === "contract" ||
|
|
138
|
+
result.kind === "contract-exact" ||
|
|
139
|
+
result.kind === "contract-unknown-history" ||
|
|
140
|
+
result.kind === "contract-missing")
|
|
133
141
|
throw new Error("Akuma history returned a non-Akuma result");
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const selectedAlias =
|
|
142
|
+
const answer = "item" in query && query.item === "answer";
|
|
143
|
+
const id = "item" in query && !answer ? query.item : undefined;
|
|
144
|
+
const selectedAlias = aliasSelector(query.selector);
|
|
137
145
|
return (historyRawAnswer(result, id) ??
|
|
138
|
-
(
|
|
139
|
-
?
|
|
140
|
-
:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
last,
|
|
145
|
-
}, context)));
|
|
146
|
+
historyText(result, {
|
|
147
|
+
...(selectedAlias === undefined ? {} : { alias: selectedAlias }),
|
|
148
|
+
...(id === undefined ? {} : { id }),
|
|
149
|
+
...("since" in query && query.since !== undefined ? { since: query.since } : {}),
|
|
150
|
+
answer,
|
|
151
|
+
}, context));
|
|
146
152
|
}
|
|
147
153
|
function renderDebtVerb(name, input, value, context) {
|
|
148
154
|
switch (name) {
|
|
@@ -160,11 +166,11 @@ function renderDebtVerb(name, input, value, context) {
|
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
function renderKill(input, value, context) {
|
|
163
|
-
return renderKillText(value,
|
|
169
|
+
return renderKillText(value, aliasSelector(input.akuma), context);
|
|
164
170
|
}
|
|
165
|
-
function
|
|
166
|
-
const selectedAlias =
|
|
167
|
-
if (
|
|
171
|
+
function renderInput(input, result, context) {
|
|
172
|
+
const selectedAlias = aliasSelector(input.akuma);
|
|
173
|
+
if (result.kind === "admitted" || (result.kind === "failed" && "failures" in result))
|
|
168
174
|
return tellText(result, input.prompt, selectedAlias, context);
|
|
169
175
|
const answer = askRawAnswer(result);
|
|
170
176
|
return answer !== undefined && tellControlLines(result, context).length === 0
|
|
@@ -179,10 +185,8 @@ function spawnPresentation(input) {
|
|
|
179
185
|
...(input.contract === undefined ? {} : { contractId: input.contract }),
|
|
180
186
|
};
|
|
181
187
|
}
|
|
182
|
-
/** Spawn's optional observation carries text. */
|
|
183
188
|
function renderSpawn(input, result, context) {
|
|
184
|
-
|
|
185
|
-
return raw ?? renderCallText(result, false, context, spawnPresentation(input));
|
|
189
|
+
return renderCallText(result, context, spawnPresentation(input));
|
|
186
190
|
}
|
|
187
191
|
function renderReport(result, context) {
|
|
188
192
|
const actor = context.actor === undefined ? "" : ` ${context.actor}`;
|
|
@@ -192,7 +196,7 @@ function renderShow(input, result, context) {
|
|
|
192
196
|
if (result.kind === "present")
|
|
193
197
|
return result.guidance;
|
|
194
198
|
if (result.kind === "missing")
|
|
195
|
-
return missing("show", input.
|
|
199
|
+
return missing("show", input.selector, context);
|
|
196
200
|
return renderDebtShow(result, context);
|
|
197
201
|
}
|
|
198
202
|
/** Render native completion values without observing the World or parsing output. */
|
|
@@ -243,8 +247,9 @@ export function renderVerb(name, input, completion, context) {
|
|
|
243
247
|
return renderKanshiText(value, context);
|
|
244
248
|
case "status": {
|
|
245
249
|
const result = value;
|
|
250
|
+
const alias = aliasSelector(input.selector);
|
|
246
251
|
return result.kind === "akuma"
|
|
247
|
-
? snapshotText(result, context,
|
|
252
|
+
? snapshotText(result, context, alias === undefined ? {} : { alias })
|
|
248
253
|
: result.kind === "contract-missing"
|
|
249
254
|
? missing("status", result.id, context)
|
|
250
255
|
: renderKanshiText(result, context);
|
|
@@ -255,7 +260,7 @@ export function renderVerb(name, input, completion, context) {
|
|
|
255
260
|
return renderForkText(value, input);
|
|
256
261
|
case "tell":
|
|
257
262
|
case "ask":
|
|
258
|
-
return
|
|
263
|
+
return renderInput(input, value, context);
|
|
259
264
|
case "kill":
|
|
260
265
|
return renderKill(input, value, context);
|
|
261
266
|
case "wait":
|