@astrosheep/keiyaku 4.6.33 → 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 +10 -1
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/pi/keiyaku.ts +1 -135
- package/build/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/src/akuma/akuma-observe.d.ts +8 -0
- package/build/src/akuma/akuma-observe.js +8 -0
- package/build/src/akuma/akuma-owner.d.ts +1 -0
- package/build/src/akuma/akuma-owner.js +3 -5
- package/build/src/akuma/akuma-wait.d.ts +117 -2
- package/build/src/akuma/akuma-wait.js +53 -22
- package/build/src/akuma/akuma.d.ts +6 -1
- package/build/src/akuma/akuma.js +37 -18
- 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 +6 -0
- package/build/src/akuma/heart/index.js +27 -9
- package/build/src/akuma/heart/rows.d.ts +1 -0
- package/build/src/akuma/heart/rows.js +4 -0
- 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.js +4 -9
- package/build/src/akuma/selection-observation.d.ts +622 -0
- package/build/src/akuma/selection-observation.js +7 -3
- 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 +2 -3
- package/build/src/cli/commands/akuma-grammar.js +32 -39
- package/build/src/cli/commands/akuma.js +6 -3
- package/build/src/cli/commands/contract-grammar.js +32 -31
- package/build/src/cli/commands/contract-help.d.ts +3 -3
- package/build/src/cli/commands/contract-help.js +10 -8
- package/build/src/cli/commands/contract.d.ts +3 -3
- package/build/src/cli/commands/contract.js +11 -10
- package/build/src/cli/parse.d.ts +4 -10
- package/build/src/cli/parse.js +1 -1
- package/build/src/cli/render/akuma-activity.d.ts +9 -19
- package/build/src/cli/render/akuma-activity.js +83 -110
- package/build/src/cli/render/catalog.js +3 -2
- package/build/src/cli/render/contract-history.d.ts +1 -3
- package/build/src/cli/render/contract-history.js +68 -49
- package/build/src/cli/render/contract-wait.js +9 -1
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
- package/build/src/cli/render/kanshi-akuma.js +26 -21
- package/build/src/cli/render/kanshi.js +34 -43
- package/build/src/cli/render/verbs.js +20 -17
- package/build/src/cli/runtime.js +9 -23
- 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 -1
- package/build/src/debt/index.js +3 -3
- package/build/src/debt/operations.d.ts +2 -1
- package/build/src/git/observe.d.ts +4 -3
- package/build/src/git/observe.js +8 -7
- package/build/src/history.d.ts +26 -0
- package/build/src/history.js +43 -0
- package/build/src/index.d.ts +4 -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 -3
- package/build/src/kanshi/index.js +2 -2
- package/build/src/kanshi/read.js +5 -2
- package/build/src/library/akumas.d.ts +5 -1
- package/build/src/library/akumas.js +11 -5
- package/build/src/library/contract-composition.js +10 -10
- package/build/src/library/contract-creation.js +2 -2
- package/build/src/library/contract-types.d.ts +215 -25
- package/build/src/library/contract-types.js +31 -13
- package/build/src/library/contract-wait.d.ts +205 -0
- package/build/src/library/contract-wait.js +15 -3
- package/build/src/library/input.d.ts +3 -3
- package/build/src/library/input.js +5 -5
- package/build/src/library/kei.js +134 -76
- 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 +5 -1
- package/build/src/library/keiyaku-debt.d.ts +8 -7
- package/build/src/library/keiyaku-identity.d.ts +4 -3
- package/build/src/library/keiyaku-identity.js +30 -7
- package/build/src/library/keiyaku-verbs.d.ts +515 -44
- package/build/src/library/keiyaku-verbs.js +84 -79
- package/build/src/library/keiyaku-wait.d.ts +570 -0
- package/build/src/library/keiyaku-wait.js +25 -8
- package/build/src/library/keiyaku.d.ts +3110 -31
- package/build/src/library/keiyaku.js +335 -407
- package/build/src/library/model-tools.d.ts +268 -70
- package/build/src/library/model-tools.js +110 -95
- package/build/src/library/selection.d.ts +6 -5
- package/build/src/library/selection.js +10 -3
- package/build/src/mcp/adapter.js +1 -1
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +4 -3
- package/build/src/pi/index.d.ts +2 -0
- package/build/src/pi/index.js +23 -7
- package/build/src/pi/status.d.ts +12 -0
- package/build/src/pi/status.js +140 -0
- package/build/src/protocol/operations.d.ts +2 -0
- package/build/src/protocol/operations.js +1 -1
- package/build/src/protocol/read/status.d.ts +12 -4
- package/build/src/protocol/read/status.js +19 -12
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/package.json +1 -1
- 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/keiyaku.ts +1 -135
- package/skills/keiyaku-akuma/SKILL.md +5 -2
- package/skills/keiyaku-debt/SKILL.md +2 -1
|
@@ -30,9 +30,6 @@ const TOOL_BUDGET = 3;
|
|
|
30
30
|
function identity(id, alias) {
|
|
31
31
|
return `${id}${alias === undefined ? "" : ` (${alias})`}`;
|
|
32
32
|
}
|
|
33
|
-
function associatedContractId(contract) {
|
|
34
|
-
return contract.kind === "associated" ? contract.contractId : undefined;
|
|
35
|
-
}
|
|
36
33
|
/** The one human-fact separator of this family. */
|
|
37
34
|
const FACT_SEPARATOR = " · ";
|
|
38
35
|
/** A supporting fact of an action receipt or an observation panel is one indent deep. */
|
|
@@ -44,17 +41,13 @@ export function subordinateLines(lines) {
|
|
|
44
41
|
/**
|
|
45
42
|
* The one observation identity line: complete Akuma identity, optional alias as a parenthetical
|
|
46
43
|
* supplement, and a known associated Contract inline behind the shared separator.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const contractId = contract === undefined ? undefined : associatedContractId(contract);
|
|
50
|
-
return `${identity(id, alias)}${contractId === undefined ? "" : `${FACT_SEPARATOR}${contractId}`}`;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Identity and its static coordinates. The execution directory and any already-exposed effective
|
|
54
|
-
* actions belong above the content boundary; an absent coordinate is an absent line.
|
|
44
|
+
* The execution directory and any already-exposed effective actions belong above the content
|
|
45
|
+
* boundary; an absent coordinate is an absent line.
|
|
55
46
|
*/
|
|
56
47
|
export function panelHead(id, alias, contract, context = []) {
|
|
57
|
-
|
|
48
|
+
const contractId = contract?.kind === "associated" ? contract.contractId : undefined;
|
|
49
|
+
const line = `${identity(id, alias)}${contractId === undefined ? "" : `${FACT_SEPARATOR}${contractId}`}`;
|
|
50
|
+
return [line, ...subordinateLines(context)];
|
|
58
51
|
}
|
|
59
52
|
/**
|
|
60
53
|
* One action receipt: the verdict and the complete subject on the first line, every supporting fact
|
|
@@ -413,17 +406,6 @@ function lifeConclusion(life, pending) {
|
|
|
413
406
|
return { mark: "?", verb: "hung" };
|
|
414
407
|
return { mark: "!", verb: life };
|
|
415
408
|
}
|
|
416
|
-
function conclusionMarkVerb(status, outcome) {
|
|
417
|
-
if (outcome === "failed" || (status !== undefined && failedOutcomeDiagnostic(status) !== undefined))
|
|
418
|
-
return { mark: "!", verb: "failed" };
|
|
419
|
-
if (outcome === "answered")
|
|
420
|
-
return { mark: "✓", verb: "answered" };
|
|
421
|
-
if (outcome === "unanswered")
|
|
422
|
-
return { mark: "○", verb: "unanswered" };
|
|
423
|
-
if (status === undefined)
|
|
424
|
-
return { mark: "⧗", verb: "pending tell" };
|
|
425
|
-
return lifeConclusion(status.life, !defaultWaitComplete(status));
|
|
426
|
-
}
|
|
427
409
|
function durationText(durationMs) {
|
|
428
410
|
const seconds = Math.max(0, Math.round(durationMs / 1000));
|
|
429
411
|
if (seconds < 60)
|
|
@@ -434,37 +416,33 @@ function durationText(durationMs) {
|
|
|
434
416
|
* One wait-style conclusion for every observer of an input-bound Tell. A target
|
|
435
417
|
* that settled at or after this wait began keeps its duration, a target already
|
|
436
418
|
* settled names no duration, and an unfinished target carries the elapsed wait.
|
|
419
|
+
* An ended wait is the deadline itself, so it never reads a pinned completion.
|
|
437
420
|
*/
|
|
438
|
-
function
|
|
439
|
-
const
|
|
440
|
-
? input.at !== undefined && input.at >= input.startedAt
|
|
441
|
-
? ` — ${durationText(Math.max(0, input.at - input.startedAt))}`
|
|
442
|
-
: ""
|
|
443
|
-
: input.end === undefined || !Number.isFinite(input.startedAt)
|
|
444
|
-
? ""
|
|
445
|
-
: ` — waited ${durationText(Math.max(0, input.end - input.startedAt))}`;
|
|
446
|
-
return `${input.mark} ${input.verb}${duration}`;
|
|
447
|
-
}
|
|
448
|
-
export function inputWaitConclusion(observation, input) {
|
|
449
|
-
const end = input.now;
|
|
450
|
-
const complete = observation.kind !== "deadline";
|
|
421
|
+
function waitConclusion(observation, input) {
|
|
422
|
+
const ended = observation.kind === "deadline";
|
|
451
423
|
const pinned = input.completedAt == null ? Number.NaN : Date.parse(input.completedAt);
|
|
452
|
-
const at =
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
424
|
+
const at = ended ? input.now : Number.isFinite(pinned) ? pinned : undefined;
|
|
425
|
+
const failed = observation.kind === "failed" ||
|
|
426
|
+
observation.kind === "invalid-output" ||
|
|
427
|
+
(input.status !== undefined && failedOutcomeDiagnostic(input.status) !== undefined);
|
|
428
|
+
const state = failed
|
|
429
|
+
? { mark: "!", verb: "failed" }
|
|
430
|
+
: observation.kind === "answered"
|
|
431
|
+
? { mark: "✓", verb: "answered" }
|
|
457
432
|
: observation.kind === "unanswered"
|
|
458
|
-
? "unanswered"
|
|
459
|
-
:
|
|
433
|
+
? { mark: "○", verb: "unanswered" }
|
|
434
|
+
: input.status === undefined
|
|
435
|
+
? { mark: "⧗", verb: "pending tell" }
|
|
436
|
+
: lifeConclusion(input.status.life, !defaultWaitComplete(input.status));
|
|
437
|
+
const elapsed = ended
|
|
438
|
+
? at === undefined || !Number.isFinite(input.startedAt)
|
|
439
|
+
? ""
|
|
440
|
+
: ` — waited ${durationText(Math.max(0, at - input.startedAt))}`
|
|
441
|
+
: at !== undefined && at >= input.startedAt
|
|
442
|
+
? ` — ${durationText(Math.max(0, at - input.startedAt))}`
|
|
443
|
+
: "";
|
|
460
444
|
return [
|
|
461
|
-
|
|
462
|
-
...(at === undefined ? {} : { at }),
|
|
463
|
-
startedAt: input.startedAt,
|
|
464
|
-
complete,
|
|
465
|
-
...(end === undefined ? {} : { end }),
|
|
466
|
-
...conclusion,
|
|
467
|
-
}),
|
|
445
|
+
`${state.mark} ${state.verb}${elapsed}`,
|
|
468
446
|
...(observation.kind === "failed" || observation.kind === "invalid-output"
|
|
469
447
|
? [`! ${safeText(observation.diagnostic)}`]
|
|
470
448
|
: []),
|
|
@@ -539,7 +517,7 @@ export function inputWaitStream(context, head, options) {
|
|
|
539
517
|
}
|
|
540
518
|
else {
|
|
541
519
|
const currentTime = now();
|
|
542
|
-
lines.push(...
|
|
520
|
+
lines.push(...waitConclusion(result.observation, {
|
|
543
521
|
startedAt,
|
|
544
522
|
...(result.completedAt === undefined ? {} : { completedAt: result.completedAt }),
|
|
545
523
|
...(currentTime === undefined ? {} : { now: currentTime }),
|
|
@@ -583,41 +561,31 @@ export function currentWorkLines(work, context) {
|
|
|
583
561
|
: [`${work.outcome.verdict} ${work.outcome.historyId} · activity ${work.outcome.activityId}`]),
|
|
584
562
|
];
|
|
585
563
|
}
|
|
586
|
-
function
|
|
587
|
-
const
|
|
564
|
+
function snapshotConclusion(status) {
|
|
565
|
+
const conclusion = lifeConclusion(status.life, status.work.pending !== undefined);
|
|
566
|
+
return `${conclusion.mark} ${conclusion.verb}${status.strandedReason === undefined ? "" : ` · ${status.strandedReason}`}`;
|
|
567
|
+
}
|
|
568
|
+
export function snapshotText(view, context, options = {}) {
|
|
588
569
|
// A source later than the observation reads as the whole word `now`, so the surface only appends
|
|
589
570
|
// a unit suffix when the age actually names a unit.
|
|
590
571
|
const activityAge = view.lastActivityAt === undefined
|
|
591
572
|
? undefined
|
|
592
573
|
: ageText(view.lastActivityAt, new Date(context.now ?? Date.now()).toISOString());
|
|
593
|
-
const
|
|
574
|
+
const head = panelHead(view.id, options.alias, view.contract, [
|
|
594
575
|
safeText(view.cwd),
|
|
595
576
|
...(activityAge === undefined
|
|
596
577
|
? []
|
|
597
578
|
: [`${view.life} · last activity ${activityAge === "now" ? activityAge : `${activityAge} ago`}`]),
|
|
598
|
-
];
|
|
599
|
-
const facts = [
|
|
600
|
-
...contractFacts(view.contract ?? { kind: "none" }, context.columns - SUBORDINATE_INDENT.length),
|
|
601
|
-
...(options.facts ?? []),
|
|
602
|
-
];
|
|
603
|
-
return {
|
|
604
|
-
activity,
|
|
605
|
-
head: panelHead(view.id, options.alias, view.contract, contextFacts),
|
|
606
|
-
facts,
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function snapshotConclusion(status) {
|
|
610
|
-
const conclusion = lifeConclusion(status.life, status.work.pending !== undefined);
|
|
611
|
-
return `${conclusion.mark} ${conclusion.verb}${status.strandedReason === undefined ? "" : ` · ${status.strandedReason}`}`;
|
|
612
|
-
}
|
|
613
|
-
export function snapshotText(view, context, options = {}) {
|
|
614
|
-
const core = snapshotCore(view, context, options);
|
|
579
|
+
]);
|
|
615
580
|
const conclusion = snapshotConclusion(view);
|
|
616
|
-
const content = [...
|
|
581
|
+
const content = [...currentWorkLines(view.work, context), ...(conclusion.length === 0 ? [] : [conclusion])];
|
|
617
582
|
return [
|
|
618
|
-
...
|
|
619
|
-
...(content.length === 0 ? [] : [frameRule(
|
|
620
|
-
...subordinateLines([
|
|
583
|
+
...head,
|
|
584
|
+
...(content.length === 0 ? [] : [frameRule(head, context.columns), ...content]),
|
|
585
|
+
...subordinateLines([
|
|
586
|
+
...renderReportedChangeLines(view),
|
|
587
|
+
...contractFacts(view.contract ?? { kind: "none" }, context.columns - SUBORDINATE_INDENT.length),
|
|
588
|
+
]),
|
|
621
589
|
].join("\n");
|
|
622
590
|
}
|
|
623
591
|
function killResultLabel(evidence) {
|
|
@@ -679,19 +647,9 @@ export function historyRawAnswer(result, historyId) {
|
|
|
679
647
|
}
|
|
680
648
|
/** One compact wait result line: an observed life mark, the complete identity, a bounded summary. */
|
|
681
649
|
const WAIT_SUMMARY_SEPARATOR = " — ";
|
|
682
|
-
const WAIT_LIFE = {
|
|
683
|
-
running: { mark: "●", state: "running" },
|
|
684
|
-
killed: { mark: "×", state: "killed" },
|
|
685
|
-
hung: { mark: "?", state: "hung" },
|
|
686
|
-
untidy: { mark: "!", state: "untidy" },
|
|
687
|
-
stranded: { mark: "!", state: "stranded" },
|
|
688
|
-
};
|
|
689
650
|
function foldedSummary(value) {
|
|
690
651
|
return safeText(value).replace(/\s+/gu, " ").trim();
|
|
691
652
|
}
|
|
692
|
-
function preview(value, fallback) {
|
|
693
|
-
return foldedSummary(value) || fallback;
|
|
694
|
-
}
|
|
695
653
|
function waitLine(mark, subject, summary, columns) {
|
|
696
654
|
const head = `${mark} ${subject}`;
|
|
697
655
|
const room = columns - displayColumns(head) - displayColumns(WAIT_SUMMARY_SEPARATOR);
|
|
@@ -703,38 +661,31 @@ function waitLine(mark, subject, summary, columns) {
|
|
|
703
661
|
/**
|
|
704
662
|
* The final public snapshot as one wait summary. A stopped life stays explicit over any older
|
|
705
663
|
* outcome; pending input stays visible beside the life it belongs to; a sleeping member without
|
|
706
|
-
* pending input shows its
|
|
707
|
-
*
|
|
664
|
+
* pending input shows its settled outcome, else completion. The mark reports the observed life,
|
|
665
|
+
* never continuing liveness.
|
|
708
666
|
*/
|
|
709
667
|
function waitSummary(member) {
|
|
710
668
|
const pending = member.pending !== undefined;
|
|
711
669
|
const outcome = member.outcome;
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
: outcome.kind === "canceled"
|
|
721
|
-
? { mark: "○", state: "canceled" }
|
|
722
|
-
: { mark: "!", state: preview(outcome.diagnostic, "failed") });
|
|
670
|
+
const observed = member.life === "asleep" && !pending && outcome !== undefined
|
|
671
|
+
? outcome.kind === "answered"
|
|
672
|
+
? { mark: "✓", verb: "answered" }
|
|
673
|
+
: outcome.kind === "canceled"
|
|
674
|
+
? { mark: "○", verb: "canceled" }
|
|
675
|
+
: { mark: "!", verb: "failed" }
|
|
676
|
+
: lifeConclusion(member.life, pending);
|
|
677
|
+
const stopped = member.life !== "asleep";
|
|
723
678
|
return {
|
|
724
|
-
|
|
679
|
+
mark: observed.mark,
|
|
725
680
|
summary: [
|
|
726
|
-
observed.
|
|
727
|
-
...(pending &&
|
|
728
|
-
...(outcome?.kind === "failed" && (
|
|
681
|
+
observed.verb,
|
|
682
|
+
...(pending && stopped ? ["pending tell"] : []),
|
|
683
|
+
...(outcome?.kind === "failed" && (stopped || pending) ? ["failed"] : []),
|
|
729
684
|
...(member.strandedReason === undefined ? [] : [member.strandedReason]),
|
|
730
685
|
].join(FACT_SEPARATOR),
|
|
731
686
|
};
|
|
732
687
|
}
|
|
733
|
-
/**
|
|
734
|
-
* One wait's final text: one compact line per observed member, then one failure line per member
|
|
735
|
-
* the wait could not read. A wait opens no frame and extracts no separate answer, so an answer is
|
|
736
|
-
* visible only as the snapshot's own bounded summary.
|
|
737
|
-
*/
|
|
688
|
+
/** Compact final facts, actual recent events, and an exact-turn full outcome; never a live frame. */
|
|
738
689
|
export function waitText(result, presentation, context) {
|
|
739
690
|
const alias = result.results.length === 1 ? presentation.alias : undefined;
|
|
740
691
|
return result.results
|
|
@@ -744,7 +695,29 @@ export function waitText(result, presentation, context) {
|
|
|
744
695
|
if (member.kind === "unobserved")
|
|
745
696
|
return waitLine("!", identity(member.id, alias), `observation failed${FACT_SEPARATOR}${member.diagnostic}`, context.columns);
|
|
746
697
|
const { mark, summary } = waitSummary(member);
|
|
747
|
-
|
|
698
|
+
const outcome = member.outcome;
|
|
699
|
+
const payload = outcome?.kind === "answered" ? outcome.answer : outcome?.kind === "failed" ? outcome.diagnostic : undefined;
|
|
700
|
+
return [
|
|
701
|
+
waitLine(mark, identity(member.id, alias), summary, context.columns),
|
|
702
|
+
...(member.lastActivityAt === undefined ? [] : [` activity ${safeText(member.lastActivityAt)}`]),
|
|
703
|
+
...groupedRows(member.events ?? [], context),
|
|
704
|
+
...(member.eventsUnavailable === undefined
|
|
705
|
+
? []
|
|
706
|
+
: diagnosticLines("recent activity", member.eventsUnavailable, context.columns, { state: "unavailable" })),
|
|
707
|
+
...(outcome === undefined ? [] : [` ${outcome.historyId} · ${outcome.kind}`]),
|
|
708
|
+
...(payload === undefined
|
|
709
|
+
? []
|
|
710
|
+
: renderBoundedPayload({
|
|
711
|
+
text: payload,
|
|
712
|
+
first: " ",
|
|
713
|
+
continuation: " ",
|
|
714
|
+
columns: context.columns,
|
|
715
|
+
maxLines: Number.MAX_SAFE_INTEGER,
|
|
716
|
+
quote: "",
|
|
717
|
+
preserveLines: true,
|
|
718
|
+
truncated: false,
|
|
719
|
+
})),
|
|
720
|
+
].join("\n");
|
|
748
721
|
})
|
|
749
722
|
.join("\n");
|
|
750
723
|
}
|
|
@@ -752,8 +725,8 @@ export function historyText(result, presentation, context) {
|
|
|
752
725
|
if (presentation.id !== undefined) {
|
|
753
726
|
return historyRawAnswer(result, presentation.id) ?? `${presentation.id} has no matching retained history`;
|
|
754
727
|
}
|
|
755
|
-
if (presentation.
|
|
756
|
-
return result.kind === "akuma-
|
|
728
|
+
if (presentation.answer === true)
|
|
729
|
+
return result.kind === "akuma-answer" ? result.answer : "no answer retained";
|
|
757
730
|
if (result.kind !== "akuma")
|
|
758
731
|
throw new Error("history result lacks page");
|
|
759
732
|
const rows = groupedRows(result.events, context, { history: true });
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { contractAttentionFacts, progressStrip } from "./contract-observation.js";
|
|
1
|
+
import { contractAttentionFacts, lifecycleWord, progressStrip } from "./contract-observation.js";
|
|
2
2
|
import { ageText, emptyCatalogue, safeText } from "./terminal.js";
|
|
3
3
|
import { contractMark } from "./marks.js";
|
|
4
4
|
/** One summary row names identity, age, title, and a terminal outcome or the current candidate strip. */
|
|
5
5
|
function contractCatalogueBlock(row, observedAt) {
|
|
6
6
|
const head = `${contractMark(row)} ${safeText(row.id)} · ${ageText(row.phaseAt, observedAt, "future")} · ${safeText(row.title ?? "title unavailable")}`;
|
|
7
|
-
|
|
7
|
+
const state = row.phase === "bound" ? progressStrip(row) : lifecycleWord(row.phase);
|
|
8
|
+
return [head, ` ${state}`, ...contractAttentionFacts(row).map((fact) => ` ${safeText(fact)}`)].join("\n");
|
|
8
9
|
}
|
|
9
10
|
export function renderContractCatalogue(list) {
|
|
10
11
|
const rows = list.rows ?? [];
|
|
@@ -1,8 +1,47 @@
|
|
|
1
1
|
import { gateDisplayName, lifecycleWord, shortGitId } from "./contract-observation.js";
|
|
2
|
-
import { receiptPayload } from "./receipt.js";
|
|
3
2
|
import { DEFAULT_CLI_COLUMNS, renderOpaqueBlock, safeText } from "./terminal.js";
|
|
4
3
|
function listFact(label, values) {
|
|
5
|
-
return values === undefined
|
|
4
|
+
return values === undefined ? [] : [` ${label} ${values.length === 0 ? "none" : values.map(safeText).join(" · ")}`];
|
|
5
|
+
}
|
|
6
|
+
function historicalPayload(label, payload) {
|
|
7
|
+
return [` ${label}`, ...payload.split("\n").map((line) => (line.length === 0 ? "" : ` ${safeText(line)}`))];
|
|
8
|
+
}
|
|
9
|
+
/** Lay out a recorded dependency-key set as its labeled facts; unknown representations stay literal. */
|
|
10
|
+
function subjectFact(subject) {
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = JSON.parse(subject);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return safeText(subject);
|
|
17
|
+
}
|
|
18
|
+
if (!Array.isArray(parsed) || parsed.length === 0)
|
|
19
|
+
return safeText(subject);
|
|
20
|
+
const parts = [];
|
|
21
|
+
for (const key of parsed) {
|
|
22
|
+
if (!Array.isArray(key) || key.length !== 2)
|
|
23
|
+
return safeText(subject);
|
|
24
|
+
const [kind, identity] = key;
|
|
25
|
+
if (typeof kind !== "string" || typeof identity !== "string")
|
|
26
|
+
return safeText(subject);
|
|
27
|
+
const value = safeText(identity);
|
|
28
|
+
switch (kind) {
|
|
29
|
+
case "change":
|
|
30
|
+
case "document":
|
|
31
|
+
case "segment":
|
|
32
|
+
parts.push(`${kind} ${value}`);
|
|
33
|
+
break;
|
|
34
|
+
case "snapshot":
|
|
35
|
+
parts.push(`snapshot ${shortGitId(value)}`);
|
|
36
|
+
break;
|
|
37
|
+
case "target":
|
|
38
|
+
parts.push(`target revision ${value}`);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
return safeText(subject);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return parts.join(" · ");
|
|
6
45
|
}
|
|
7
46
|
function targetName(target) {
|
|
8
47
|
if (target === undefined)
|
|
@@ -19,15 +58,14 @@ function payloadSuffix(payload) {
|
|
|
19
58
|
const count = renderOpaqueBlock(payload, " ", DEFAULT_CLI_COLUMNS).length;
|
|
20
59
|
return ` · ${count} line${count === 1 ? "" : "s"}`;
|
|
21
60
|
}
|
|
22
|
-
function eventLine(event
|
|
61
|
+
function eventLine(event) {
|
|
23
62
|
switch (event.kind) {
|
|
24
63
|
case "dispatch":
|
|
25
64
|
return `dispatch · ${event.akumaId}`;
|
|
26
65
|
case "bind": {
|
|
27
66
|
const gates = event.gates?.map(gateDisplayName) ?? [];
|
|
28
67
|
const gateFact = gates.length === 0 ? "" : ` · ${gates.length === 1 ? "gate" : "gates"} ${gates.join(" · ")}`;
|
|
29
|
-
|
|
30
|
-
return `bound to ${targetName(event.target)} @ ${shortGitId(event.start)}${gateFact}${callers}`;
|
|
68
|
+
return `bound to ${targetName(event.target)} @ ${shortGitId(event.start)}${gateFact}`;
|
|
31
69
|
}
|
|
32
70
|
case "amend": {
|
|
33
71
|
const changed = [
|
|
@@ -44,7 +82,7 @@ function eventLine(event, dispatches = []) {
|
|
|
44
82
|
return `integrated ${shortGitId(event.predecessor)}..${shortGitId(event.integration)}`;
|
|
45
83
|
case "attestation": {
|
|
46
84
|
const requirement = event.gate === "verified" || event.requirement !== `gate:${event.gate}` ? ` ${event.requirement}` : "";
|
|
47
|
-
return `${event.verdict === "satisfied" ? "✓" : "×"} ${gateDisplayName(event.gate)}${requirement} · subject ${
|
|
85
|
+
return `${event.verdict === "satisfied" ? "✓" : "×"} ${gateDisplayName(event.gate)}${requirement} · subject ${subjectFact(event.subject)}${payloadSuffix(event.summary)}`;
|
|
48
86
|
}
|
|
49
87
|
case "claimed":
|
|
50
88
|
return lifecycleWord("claimed");
|
|
@@ -80,7 +118,7 @@ function semanticBody(event) {
|
|
|
80
118
|
` content identity ${event.contentId}`,
|
|
81
119
|
];
|
|
82
120
|
if (event.note !== undefined)
|
|
83
|
-
|
|
121
|
+
lines.push(...historicalPayload("note", event.note));
|
|
84
122
|
return lines;
|
|
85
123
|
}
|
|
86
124
|
case "reintegrated":
|
|
@@ -93,10 +131,10 @@ function semanticBody(event) {
|
|
|
93
131
|
` gate ${event.gate}`,
|
|
94
132
|
` requirement ${event.requirement}`,
|
|
95
133
|
` verdict ${event.verdict}`,
|
|
96
|
-
` subject ${
|
|
134
|
+
` subject ${subjectFact(event.subject)}`,
|
|
97
135
|
];
|
|
98
136
|
if (event.summary !== undefined)
|
|
99
|
-
|
|
137
|
+
lines.push(...historicalPayload("summary", event.summary));
|
|
100
138
|
return lines;
|
|
101
139
|
}
|
|
102
140
|
case "claimed":
|
|
@@ -105,28 +143,25 @@ function semanticBody(event) {
|
|
|
105
143
|
return [
|
|
106
144
|
` sequence ${event.chapter}`,
|
|
107
145
|
` title ${safeText(event.title)}`,
|
|
108
|
-
...(event.body === undefined ? [] :
|
|
146
|
+
...(event.body === undefined ? [] : historicalPayload("body", event.body)),
|
|
109
147
|
];
|
|
110
148
|
case "abandoned": {
|
|
111
149
|
const lines = [];
|
|
112
150
|
if (event.note !== undefined)
|
|
113
|
-
|
|
151
|
+
lines.push(...historicalPayload("note", event.note));
|
|
114
152
|
return lines;
|
|
115
153
|
}
|
|
116
154
|
}
|
|
117
155
|
}
|
|
118
|
-
/**
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const detail = [
|
|
156
|
+
/** One complete retained record, without substituting a current-state read. */
|
|
157
|
+
function exactEventLines(event) {
|
|
158
|
+
return [
|
|
159
|
+
`${event.at} ${event.kind} · ${event.id}`,
|
|
123
160
|
...semanticBody(event),
|
|
124
161
|
...(event.kind === "bind" || event.kind === "amend"
|
|
125
162
|
? [
|
|
126
|
-
...(event.document === undefined
|
|
127
|
-
|
|
128
|
-
: [" document", ...renderOpaqueBlock(event.document, " ", DEFAULT_CLI_COLUMNS)]),
|
|
129
|
-
...(event.kind !== "bind" || event.targetIncarnation === undefined
|
|
163
|
+
...(event.document === undefined ? [] : historicalPayload("document", event.document)),
|
|
164
|
+
...(event.targetIncarnation === undefined
|
|
130
165
|
? []
|
|
131
166
|
: [
|
|
132
167
|
` target incarnation ${safeText(event.targetIncarnation.id)} · ${safeText(event.targetIncarnation.identity)}`,
|
|
@@ -137,35 +172,22 @@ function fullEventLines(event) {
|
|
|
137
172
|
? []
|
|
138
173
|
: [` require branches up to date ${event.requireBranchesToBeUpToDate}`]),
|
|
139
174
|
];
|
|
140
|
-
return [header, ...detail];
|
|
141
175
|
}
|
|
142
|
-
export function renderContractHistory(history
|
|
176
|
+
export function renderContractHistory(history) {
|
|
177
|
+
const header = `history ${history.contractId}`;
|
|
178
|
+
if (history.kind === "contract-exact")
|
|
179
|
+
return [header, "", ...exactEventLines(history.event)].join("\n");
|
|
143
180
|
const journals = history.events.filter((event) => event.kind !== "dispatch").length;
|
|
144
181
|
const dispatches = history.events.length - journals;
|
|
145
182
|
const counts = [
|
|
146
|
-
...(journals === 0
|
|
147
|
-
? []
|
|
148
|
-
: [`${journals} ${options.full === true ? "journal " : ""}${journals === 1 ? "entry" : "entries"}`]),
|
|
183
|
+
...(journals === 0 ? [] : [`${journals} ${journals === 1 ? "entry" : "entries"}`]),
|
|
149
184
|
...(dispatches === 0 ? [] : [`${dispatches} ${dispatches === 1 ? "dispatch" : "dispatches"}`]),
|
|
150
185
|
];
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
? "abandoned"
|
|
155
|
-
: "bound";
|
|
156
|
-
const header = `history ${history.contractId}${options.full === true ? "" : ` · ${state}`}${counts.length === 0 ? "" : ` · ${counts.join(" · ")}`}`;
|
|
157
|
-
const failure = history.dispatches === undefined
|
|
158
|
-
? []
|
|
159
|
-
: [
|
|
160
|
-
"",
|
|
161
|
-
`! Dispatch history unavailable · ${history.dispatches.category} · ${safeText(history.dispatches.diagnostic)}`,
|
|
162
|
-
];
|
|
163
|
-
if (options.full === true)
|
|
164
|
-
return [header, "", ...history.events.flatMap(fullEventLines), ...failure].join("\n");
|
|
165
|
-
const lines = [header, ""];
|
|
186
|
+
const lines = [header + (counts.length === 0 ? "" : ` · ${counts.join(" · ")}`), ""];
|
|
187
|
+
if (history.omitted !== undefined)
|
|
188
|
+
lines.push(`… ${history.omitted} journal entries omitted`, "");
|
|
166
189
|
let day;
|
|
167
|
-
for (
|
|
168
|
-
const event = history.events[index];
|
|
190
|
+
for (const event of history.events) {
|
|
169
191
|
const nextDay = event.at.slice(0, 10);
|
|
170
192
|
if (nextDay !== day) {
|
|
171
193
|
if (day !== undefined)
|
|
@@ -173,12 +195,9 @@ export function renderContractHistory(history, options = {}) {
|
|
|
173
195
|
lines.push(nextDay, "");
|
|
174
196
|
day = nextDay;
|
|
175
197
|
}
|
|
176
|
-
|
|
177
|
-
if (event.kind === "bind") {
|
|
178
|
-
while (history.events[index + 1]?.kind === "dispatch")
|
|
179
|
-
adjacent.push(history.events[++index]);
|
|
180
|
-
}
|
|
181
|
-
lines.push(`${clock(event)} ${eventLine(event, adjacent)}`);
|
|
198
|
+
lines.push(`${clock(event)} ${event.kind === "dispatch" ? "" : `${event.id} `}${eventLine(event)}`);
|
|
182
199
|
}
|
|
183
|
-
|
|
200
|
+
if (history.dispatches !== undefined)
|
|
201
|
+
lines.push("", `! Dispatch history unavailable · ${history.dispatches.category} · ${safeText(history.dispatches.diagnostic)}`);
|
|
202
|
+
return lines.join("\n");
|
|
184
203
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { progressStrip } from "./contract-observation.js";
|
|
2
|
+
import { safeText } from "./terminal.js";
|
|
1
3
|
export function contractWaitMemberText(member) {
|
|
2
4
|
const facts = [];
|
|
3
5
|
if (member.presence === "unknown")
|
|
@@ -10,5 +12,11 @@ export function contractWaitMemberText(member) {
|
|
|
10
12
|
if (member.terminal !== undefined)
|
|
11
13
|
facts.push(member.terminal === "claimed" ? "accepted" : "abandoned");
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
const head = `${member.id}${facts.length === 0 ? "" : ` (${facts.join(", ")})`}`;
|
|
16
|
+
return member.summary === undefined
|
|
17
|
+
? head
|
|
18
|
+
: [
|
|
19
|
+
`${head}${member.summary.title === undefined ? "" : ` · ${safeText(member.summary.title)}`}`,
|
|
20
|
+
` ${progressStrip(member.summary)}`,
|
|
21
|
+
].join("\n");
|
|
14
22
|
}
|
|
@@ -3,16 +3,17 @@ import { type TextRenderContext } from "./terminal.js";
|
|
|
3
3
|
declare const NARROW_COLUMNS = 72;
|
|
4
4
|
declare function akumaLabel(row: Pick<AkumaKanshiRow, "aliases">, aliasesUnavailable: boolean): string;
|
|
5
5
|
declare function associationFact(contract: NonNullable<AkumaKanshiRow["contract"]>): string;
|
|
6
|
+
declare function akumaRowLines(row: AkumaKanshiRow, aliasesUnavailable: boolean, observedAt: string, context: TextRenderContext, caller?: string): readonly string[];
|
|
6
7
|
/**
|
|
7
8
|
* One Akuma board section. The World board omits an empty section because its other
|
|
8
9
|
* sections already say what the World holds; a standalone catalogue states its
|
|
9
10
|
* own emptiness. A failed Alias observation belongs to the
|
|
10
11
|
* section, so an empty roster still states its emptiness rather than dropping that
|
|
11
|
-
* evidence.
|
|
12
|
+
* evidence. `rows` narrows a present section to one already-partitioned subset.
|
|
12
13
|
*/
|
|
13
14
|
declare function renderAkumaBoard(section: BoardSection<AkumaKanshiWorld>, observedAt: string, context: TextRenderContext & Readonly<{
|
|
14
15
|
caller?: string;
|
|
15
|
-
}>, emptyRows?: readonly string[]): readonly string[];
|
|
16
|
+
}>, emptyRows?: readonly string[], rows?: readonly AkumaKanshiRow[] | undefined): readonly string[];
|
|
16
17
|
declare function renderAkuma(report: KanshiReport, context: TextRenderContext): readonly string[];
|
|
17
18
|
declare function formatAge(source: string | null | undefined, observedAt: string): string;
|
|
18
|
-
export { akumaLabel, associationFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
19
|
+
export { akumaLabel, akumaRowLines, associationFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { currentWorkLines } from "./akuma-activity.js";
|
|
2
2
|
import { akumaMark } from "./marks.js";
|
|
3
|
-
import { ageText, elapsedMilliseconds, emptyCatalogue, entityLines, identityLine, RECENT_TONE_MS,
|
|
3
|
+
import { ageText, elapsedMilliseconds, emptyCatalogue, entityLines, identityLine, RECENT_TONE_MS, safeText, tone, } from "./terminal.js";
|
|
4
4
|
const NARROW_COLUMNS = 72;
|
|
5
5
|
const ACTIVITY_INDENT = " ";
|
|
6
6
|
function mostRecentTimestamp(...values) {
|
|
@@ -83,40 +83,45 @@ function akumaRowLines(row, aliasesUnavailable, observedAt, context, caller) {
|
|
|
83
83
|
...previewLines,
|
|
84
84
|
];
|
|
85
85
|
}
|
|
86
|
-
function akumaBoardRows(board, rows, observedAt, context, caller) {
|
|
87
|
-
const aliasesUnavailable = board.aliasesError !== undefined;
|
|
88
|
-
const rendered = renderSectionBlock({
|
|
89
|
-
name: "AKUMA",
|
|
90
|
-
rows: rows.map((row) => akumaRowLines(row, aliasesUnavailable, observedAt, context, caller)),
|
|
91
|
-
hasMore: board.more === true,
|
|
92
|
-
});
|
|
93
|
-
return [`AKUMA // ${rows.length} recent`, ...rendered.slice(1)];
|
|
94
|
-
}
|
|
95
86
|
/**
|
|
96
87
|
* One Akuma board section. The World board omits an empty section because its other
|
|
97
88
|
* sections already say what the World holds; a standalone catalogue states its
|
|
98
89
|
* own emptiness. A failed Alias observation belongs to the
|
|
99
90
|
* section, so an empty roster still states its emptiness rather than dropping that
|
|
100
|
-
* evidence.
|
|
91
|
+
* evidence. `rows` narrows a present section to one already-partitioned subset.
|
|
101
92
|
*/
|
|
102
|
-
function renderAkumaBoard(section, observedAt, context, emptyRows = [emptyCatalogue("akuma")]) {
|
|
93
|
+
function renderAkumaBoard(section, observedAt, context, emptyRows = [emptyCatalogue("akuma")], rows = section.kind === "present" ? (section.rows ?? []) : []) {
|
|
103
94
|
if (section.kind === "absent")
|
|
104
95
|
return ["AKUMA // absent"];
|
|
105
96
|
if (section.kind === "failed") {
|
|
106
97
|
return ["AKUMA // unavailable", "", tone(`! ${safeText(section.diagnostic)}`, "alert", context.color)];
|
|
107
98
|
}
|
|
108
|
-
const
|
|
109
|
-
const rows = board.rows ?? [];
|
|
110
|
-
const aliasFailure = board.aliasesError;
|
|
99
|
+
const aliasesUnavailable = section.aliasesError !== undefined;
|
|
111
100
|
if (rows.length === 0) {
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
// A non-empty complete page narrowed to no rows has all its evidence nested elsewhere.
|
|
102
|
+
if ((section.rows ?? []).length > 0) {
|
|
103
|
+
const evidence = [
|
|
104
|
+
...(section.aliasesError === undefined
|
|
105
|
+
? []
|
|
106
|
+
: [tone(`! aliases unavailable · ${safeText(section.aliasesError)}`, "alert", context.color)]),
|
|
107
|
+
...(section.more === true ? ["…"] : []),
|
|
108
|
+
];
|
|
109
|
+
return evidence.length === 0 ? [] : ["AKUMA", "", ...evidence];
|
|
110
|
+
}
|
|
111
|
+
const empty = emptyRows.length === 0 && section.aliasesError !== undefined ? [emptyCatalogue("akuma")] : emptyRows;
|
|
114
112
|
return [
|
|
115
|
-
...
|
|
116
|
-
|
|
113
|
+
...empty,
|
|
114
|
+
...(section.aliasesError === undefined
|
|
115
|
+
? []
|
|
116
|
+
: [tone(`! aliases unavailable · ${section.aliasesError}`, "alert", context.color)]),
|
|
117
117
|
];
|
|
118
118
|
}
|
|
119
|
-
return
|
|
119
|
+
return [
|
|
120
|
+
`AKUMA // ${rows.length} recent`,
|
|
121
|
+
"",
|
|
122
|
+
...rows.flatMap((row) => akumaRowLines(row, aliasesUnavailable, observedAt, context, context.caller)),
|
|
123
|
+
...(section.more === true ? ["…"] : []),
|
|
124
|
+
];
|
|
120
125
|
}
|
|
121
126
|
function renderAkuma(report, context) {
|
|
122
127
|
return renderAkumaBoard(report.akumas, report.observedAt, context, []);
|
|
@@ -126,4 +131,4 @@ function formatAge(source, observedAt) {
|
|
|
126
131
|
return "—";
|
|
127
132
|
return ageText(source, observedAt);
|
|
128
133
|
}
|
|
129
|
-
export { akumaLabel, associationFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
134
|
+
export { akumaLabel, akumaRowLines, associationFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|