@astrosheep/keiyaku 4.6.28 → 4.6.30
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/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +24 -24
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +43 -165
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +58 -228
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +45 -56
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +43 -184
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +39 -88
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +54 -114
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +24 -24
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +43 -165
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +58 -228
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +45 -56
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +43 -184
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +39 -88
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +54 -114
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +24 -24
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +43 -165
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +58 -228
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +45 -56
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +43 -184
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +39 -88
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +54 -114
- package/build/plugins/pi/README.md +10 -0
- package/build/plugins/pi/akuma-tools.ts +2 -2
- package/build/plugins/pi/keiyaku.ts +73 -1
- package/build/skills/keiyaku/SKILL.md +24 -24
- package/build/skills/keiyaku-akuma/SKILL.md +43 -165
- package/build/skills/keiyaku-akuma/references/automation.md +58 -228
- package/build/skills/keiyaku-babysit/SKILL.md +45 -56
- package/build/skills/keiyaku-bind/SKILL.md +43 -184
- package/build/skills/keiyaku-debt/SKILL.md +39 -88
- package/build/skills/keiyaku-workflow/SKILL.md +54 -114
- package/build/src/akuma/akuma-owner.js +5 -4
- package/build/src/akuma/akuma.d.ts +2 -0
- package/build/src/akuma/akuma.js +17 -5
- package/build/src/akuma/identity.d.ts +4 -0
- package/build/src/akuma/identity.js +7 -0
- package/build/src/akuma/projection.d.ts +7 -1
- package/build/src/akuma/projection.js +6 -1
- package/build/src/cli/commands/akuma-grammar.js +4 -4
- package/build/src/cli/render/akuma-activity.js +40 -9
- package/build/src/cli/render/akuma.js +1 -1
- package/build/src/cli/render/kanshi-akuma.d.ts +3 -2
- package/build/src/cli/render/kanshi-akuma.js +1 -1
- package/build/src/cli/render/kanshi.js +19 -5
- package/build/src/contract-worktree.js +19 -4
- package/build/src/git/observe.d.ts +2 -1
- package/build/src/git/observe.js +29 -20
- package/build/src/index.d.ts +2 -1
- package/build/src/index.js +1 -1
- package/build/src/kanshi/counts.d.ts +15 -0
- package/build/src/kanshi/counts.js +66 -0
- package/build/src/kanshi/index.d.ts +2 -0
- package/build/src/kanshi/index.js +1 -0
- package/build/src/kanshi/read.js +1 -1
- package/build/src/library/selection.d.ts +6 -1
- package/build/src/library/selection.js +5 -3
- package/build/src/protocol/read/status.d.ts +2 -2
- package/build/src/protocol/read/status.js +8 -6
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/package.json +2 -2
- package/plugins/pi/README.md +10 -0
- package/plugins/pi/akuma-tools.ts +2 -2
- package/plugins/pi/keiyaku.ts +73 -1
- package/skills/keiyaku/SKILL.md +24 -24
- package/skills/keiyaku-akuma/SKILL.md +43 -165
- package/skills/keiyaku-akuma/references/automation.md +58 -228
- package/skills/keiyaku-babysit/SKILL.md +45 -56
- package/skills/keiyaku-bind/SKILL.md +43 -184
- package/skills/keiyaku-debt/SKILL.md +39 -88
- package/skills/keiyaku-workflow/SKILL.md +54 -114
|
@@ -4,6 +4,10 @@ export type AkuId = string & {
|
|
|
4
4
|
readonly [AKU_ID]: true;
|
|
5
5
|
};
|
|
6
6
|
export declare function parsePublicHistoryId(value: string): number | null;
|
|
7
|
+
export declare function parseExactHistorySelector(value: string): Readonly<{
|
|
8
|
+
kind: "turn" | "report";
|
|
9
|
+
sequence: number;
|
|
10
|
+
}> | null;
|
|
7
11
|
export declare const akumaPathsSchema: z.ZodObject<{
|
|
8
12
|
directory: z.ZodString;
|
|
9
13
|
heart: z.ZodString;
|
|
@@ -12,6 +12,13 @@ export function parsePublicHistoryId(value) {
|
|
|
12
12
|
const sequence = Number(match[1]);
|
|
13
13
|
return Number.isSafeInteger(sequence) ? sequence : null;
|
|
14
14
|
}
|
|
15
|
+
export function parseExactHistorySelector(value) {
|
|
16
|
+
const match = /^(turn|report)\/([1-9][0-9]*)$/u.exec(value);
|
|
17
|
+
if (match === null)
|
|
18
|
+
return null;
|
|
19
|
+
const sequence = Number(match[2]);
|
|
20
|
+
return Number.isSafeInteger(sequence) ? { kind: match[1], sequence } : null;
|
|
21
|
+
}
|
|
15
22
|
const pathText = z.string().refine((value) => value.trim() !== "");
|
|
16
23
|
export const akumaPathsSchema = z
|
|
17
24
|
.object({
|
|
@@ -1023,12 +1023,18 @@ export type ActivityHistory = Readonly<{
|
|
|
1023
1023
|
export type ExactHistory = Readonly<{
|
|
1024
1024
|
kind: "exact";
|
|
1025
1025
|
outcome: OutcomeRow;
|
|
1026
|
+
}> | Readonly<{
|
|
1027
|
+
kind: "exact-report";
|
|
1028
|
+
report: ReportRow;
|
|
1026
1029
|
}> | Readonly<{
|
|
1027
1030
|
kind: "unknown-history";
|
|
1028
1031
|
id: string;
|
|
1029
1032
|
}>;
|
|
1030
1033
|
export type HistoryPage = ActivityHistory;
|
|
1031
|
-
export declare function selectExactHistory(rows: readonly ActivityRow[],
|
|
1034
|
+
export declare function selectExactHistory(rows: readonly ActivityRow[], selector: Readonly<{
|
|
1035
|
+
kind: "turn" | "report";
|
|
1036
|
+
sequence: number;
|
|
1037
|
+
}>): ExactHistory;
|
|
1032
1038
|
export type HistoryCursor = Readonly<{
|
|
1033
1039
|
before?: number;
|
|
1034
1040
|
since?: number;
|
|
@@ -207,7 +207,12 @@ function publicOutcome(turnSequence, outcome) {
|
|
|
207
207
|
return { kind: "canceled", historyId };
|
|
208
208
|
return { kind: "failed", historyId, diagnostic: outcome.diagnostic };
|
|
209
209
|
}
|
|
210
|
-
export function selectExactHistory(rows,
|
|
210
|
+
export function selectExactHistory(rows, selector) {
|
|
211
|
+
const id = `${selector.kind}/${selector.sequence}`;
|
|
212
|
+
if (selector.kind === "report") {
|
|
213
|
+
const report = rows.find((row) => row.kind === "report" && row.sequence === selector.sequence);
|
|
214
|
+
return report === undefined ? { kind: "unknown-history", id } : { kind: "exact-report", report };
|
|
215
|
+
}
|
|
211
216
|
const outcome = rows.find((row) => row.kind === "outcome" && row.outcome.historyId === id);
|
|
212
217
|
return outcome === undefined ? { kind: "unknown-history", id } : { kind: "exact", outcome };
|
|
213
218
|
}
|
|
@@ -2,7 +2,7 @@ import { CliUsageError, commandGuide, usageLine } from "../usage.js";
|
|
|
2
2
|
import { scanArgs } from "../scan.js";
|
|
3
3
|
import { parseDuration as decodeDuration } from "../../duration.js";
|
|
4
4
|
import { parseAkumaAlias, parseAkumaGlob } from "../../identity/selector.js";
|
|
5
|
-
import {
|
|
5
|
+
import { parseExactHistorySelector } from "../../akuma/identity.js";
|
|
6
6
|
const SET_SELECTORS = '(<aku/...> | @alias | <kei/...> | "aku/<name-pattern>/<hex-pattern>")...';
|
|
7
7
|
const SET_DETAILS = "Globs contain * and use lowercase hex digits or * in the suffix. --repo requires at least one Contract (kei/...) selector.";
|
|
8
8
|
const SCHEMA_DETAILS = "--schema supplies a JSON Schema answer contract to the provider; on observation the CLI parses JSON but does not independently validate schema conformance.";
|
|
@@ -99,7 +99,7 @@ const AKUMA_COMMAND_SPECS = {
|
|
|
99
99
|
usage: "history <aku/...|@alias> [--before <index> | --since <index>] [--limit <count>]\nhistory <aku/...|@alias> --id <historyId>\nhistory <aku/...|@alias> --last\nhistory <kei/...> [--full] [--repo <path>]",
|
|
100
100
|
purpose: "Read an Akuma's answers and activity, or a Contract's history of changes and assigned work.",
|
|
101
101
|
details: [
|
|
102
|
-
"--id reads an exact retained terminal turn (turn/<number>)
|
|
102
|
+
"--id reads an exact retained terminal turn (turn/<number>) or report (report/<number>).",
|
|
103
103
|
"--before <index> pages older rows before that sequence; --since <index> pages newer rows after it.",
|
|
104
104
|
"--limit bounds page size (default 12); without --since, the latest rows are shown.",
|
|
105
105
|
"With --since, paging starts at the earliest newer rows.",
|
|
@@ -240,8 +240,8 @@ function parseAkumaHistory(selector, flags, output, fail) {
|
|
|
240
240
|
if (limit !== undefined && limit > 5_000)
|
|
241
241
|
fail("--limit must be no greater than 5000");
|
|
242
242
|
const id = flags.id === undefined ? undefined : stringFlag(flags.id, "history --id requires a nonblank historyId", fail);
|
|
243
|
-
if (id !== undefined &&
|
|
244
|
-
fail("history --id requires turn/<positive safe integer>");
|
|
243
|
+
if (id !== undefined && parseExactHistorySelector(id) === null)
|
|
244
|
+
fail("history --id requires turn/<positive safe integer> or report/<positive safe integer>");
|
|
245
245
|
return {
|
|
246
246
|
command: "history",
|
|
247
247
|
akuma: selector,
|
|
@@ -735,8 +735,40 @@ function renderDebtContextLines(created, columns) {
|
|
|
735
735
|
return [];
|
|
736
736
|
return [`debts ${created.rows.length}`, ...created.rows.flatMap((row) => renderDebtRow(row, columns))];
|
|
737
737
|
}
|
|
738
|
+
function selectedStatusActivity(snapshot, context) {
|
|
739
|
+
const entries = coalesceAdjacentGaps(snapshot.kind === "open" ? visibleOpenSnapshotEntries(snapshot) : orderedSnapshotEntries(snapshot));
|
|
740
|
+
const rendered = entries.map((entry) => {
|
|
741
|
+
if (entry.kind === "gap")
|
|
742
|
+
return { exempt: true, lines: [omissionMarker(`${entry.count} omitted`, context.columns)] };
|
|
743
|
+
const row = entry.row;
|
|
744
|
+
const exempt = row.kind === "outcome" ||
|
|
745
|
+
(row.kind === "tell" && row.state === "pending") ||
|
|
746
|
+
(row.kind === "tool" && (row.state === "active" || row.state === "unsettled" || row.state.status === "error"));
|
|
747
|
+
return { exempt, lines: renderRow(row, context) };
|
|
748
|
+
});
|
|
749
|
+
const kept = rendered.map(({ lines }) => lines);
|
|
750
|
+
// Allocate the budget backwards without changing the order of the resulting lines.
|
|
751
|
+
let remaining = 3;
|
|
752
|
+
for (let i = rendered.length - 1; i >= 0; i -= 1) {
|
|
753
|
+
const item = rendered[i];
|
|
754
|
+
if (item.exempt)
|
|
755
|
+
continue;
|
|
756
|
+
const take = Math.min(remaining, item.lines.length);
|
|
757
|
+
remaining -= take;
|
|
758
|
+
kept[i] = take === 0 ? [] : item.lines.slice(-take);
|
|
759
|
+
}
|
|
760
|
+
let marked = false;
|
|
761
|
+
return rendered.flatMap((item, index) => {
|
|
762
|
+
const lines = kept[index];
|
|
763
|
+
if (!item.exempt && lines.length < item.lines.length && !marked) {
|
|
764
|
+
marked = true;
|
|
765
|
+
return [omissionMarker("earlier activity omitted", context.columns), ...lines];
|
|
766
|
+
}
|
|
767
|
+
return lines;
|
|
768
|
+
});
|
|
769
|
+
}
|
|
738
770
|
function snapshotCore(view, context, options) {
|
|
739
|
-
const activity =
|
|
771
|
+
const activity = selectedStatusActivity(view.status.timeline, context);
|
|
740
772
|
// Static coordinates belong above the content boundary; a dynamic diagnostic stays below it.
|
|
741
773
|
const contextFacts = [...(view.status.cwd === undefined ? [] : [safeText(view.status.cwd)])];
|
|
742
774
|
const facts = [
|
|
@@ -806,7 +838,11 @@ export function callRawAnswer(result, streamed) {
|
|
|
806
838
|
return answerBytes(observation.observation.answer, result.structured === true);
|
|
807
839
|
}
|
|
808
840
|
export function historyRawAnswer(result, historyId) {
|
|
809
|
-
if (historyId === undefined
|
|
841
|
+
if (historyId === undefined)
|
|
842
|
+
return undefined;
|
|
843
|
+
if (result.kind === "exact-report")
|
|
844
|
+
return result.report.text;
|
|
845
|
+
if (result.kind !== "exact")
|
|
810
846
|
return undefined;
|
|
811
847
|
const outcome = result.outcome.outcome;
|
|
812
848
|
return outcome.kind === "answered" ? outcome.answer : outcome.kind === "canceled" ? "canceled" : outcome.diagnostic;
|
|
@@ -879,13 +915,8 @@ export function waitText(result, presentation, context) {
|
|
|
879
915
|
}
|
|
880
916
|
export function historyText(result, presentation, context) {
|
|
881
917
|
if (presentation.id !== undefined) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return result.outcome.outcome.kind === "answered"
|
|
885
|
-
? result.outcome.outcome.answer
|
|
886
|
-
: result.outcome.outcome.kind === "canceled"
|
|
887
|
-
? "canceled"
|
|
888
|
-
: result.outcome.outcome.diagnostic;
|
|
918
|
+
return (historyRawAnswer(result, presentation.id) ??
|
|
919
|
+
`${result.kind === "unknown-history" ? result.historyId : "unknown"} has no matching retained history`);
|
|
889
920
|
}
|
|
890
921
|
if (presentation.last === true)
|
|
891
922
|
return result.kind === "last" ? result.answer : "no answer retained";
|
|
@@ -183,5 +183,5 @@ export function forkOutcome(receipt) {
|
|
|
183
183
|
export function historyOutcome(result, id) {
|
|
184
184
|
if (id === undefined)
|
|
185
185
|
return "accepted";
|
|
186
|
-
return result.kind === "exact" ? "accepted" : "refused";
|
|
186
|
+
return result.kind === "exact" || result.kind === "exact-report" ? "accepted" : "refused";
|
|
187
187
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AkumaKanshiWorld, KanshiReport, Section } from "../../kanshi/index.js";
|
|
1
|
+
import type { AkumaKanshiRow, AkumaKanshiWorld, KanshiReport, Section } from "../../kanshi/index.js";
|
|
2
2
|
import { type TextRenderContext } from "./terminal.js";
|
|
3
3
|
declare const NARROW_COLUMNS = 72;
|
|
4
|
+
declare function akumaLabel(row: Pick<AkumaKanshiRow, "aliases">, aliasesUnavailable: boolean): string;
|
|
4
5
|
declare function endpointFact(id: string, observed: string | undefined): string;
|
|
5
6
|
/**
|
|
6
7
|
* One Akuma board section. The World board omits an empty section because its other
|
|
@@ -12,4 +13,4 @@ declare function endpointFact(id: string, observed: string | undefined): string;
|
|
|
12
13
|
declare function renderAkumaBoard(section: Section<AkumaKanshiWorld>, observedAt: string, context: TextRenderContext, emptyRows: readonly string[]): readonly string[];
|
|
13
14
|
declare function renderAkuma(report: KanshiReport, context: TextRenderContext): readonly string[];
|
|
14
15
|
declare function formatAge(source: string | null | undefined, observedAt: string): string;
|
|
15
|
-
export { endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
16
|
+
export { akumaLabel, endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
@@ -112,4 +112,4 @@ function formatAge(source, observedAt) {
|
|
|
112
112
|
return "—";
|
|
113
113
|
return ageText(source, observedAt);
|
|
114
114
|
}
|
|
115
|
-
export { endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
115
|
+
export { akumaLabel, endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { abbreviateGitIds, afterWording, progressStrip, displayGitId, gateRequirementFacts, gitIdsInRow, lifecycleWord, mergeSummary, targetMovementFacts, } from "./contract-observation.js";
|
|
2
2
|
import { DEFAULT_CLI_COLUMNS, emptyCatalogue, entityLines, elapsedMilliseconds, identityLine, plumbFacts, RECENT_TONE_MS, renderBoundedPayload, renderSectionBlock, safeText, tone, } from "./terminal.js";
|
|
3
|
-
import { endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard } from "./kanshi-akuma.js";
|
|
4
|
-
import { contractMark, debtDispositionMark } from "./marks.js";
|
|
3
|
+
import { akumaLabel, endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard } from "./kanshi-akuma.js";
|
|
4
|
+
import { akumaMark, contractMark, debtDispositionMark } from "./marks.js";
|
|
5
5
|
import { dispositionText } from "./debt.js";
|
|
6
6
|
const REVIEW_ATTENTION_MS = 15 * 60 * 1_000;
|
|
7
7
|
const PENDING_ATTENTION_MS = 60 * 60 * 1_000;
|
|
@@ -87,6 +87,21 @@ function linkedAkumaSummary(row, akuma) {
|
|
|
87
87
|
facts.push(`${row.roster.length - known.length} unavailable`);
|
|
88
88
|
return facts.join(" · ");
|
|
89
89
|
}
|
|
90
|
+
function linkedAkumaRows(row, akuma) {
|
|
91
|
+
const rows = akuma?.kind === "present" ? akuma.value.rows : [];
|
|
92
|
+
const byId = new Map(rows.map((item) => [item.id, item]));
|
|
93
|
+
return [
|
|
94
|
+
...(row.rosterUnavailable === true ? [" akuma association unavailable"] : []),
|
|
95
|
+
...row.roster.map((attached) => {
|
|
96
|
+
const observed = byId.get(attached.id);
|
|
97
|
+
const aliases = akumaLabel(attached, attached.aliasesUnavailable === true);
|
|
98
|
+
const identity = [attached.id, aliases].filter(Boolean).join(" ");
|
|
99
|
+
return observed === undefined
|
|
100
|
+
? ` ! ${safeText(identity)} · unavailable`
|
|
101
|
+
: ` ${akumaMark(observed.life)} ${safeText(identity)} · ${observed.life}`;
|
|
102
|
+
}),
|
|
103
|
+
];
|
|
104
|
+
}
|
|
90
105
|
function semanticBlock(_name, facts, _context) {
|
|
91
106
|
if (facts.length === 0)
|
|
92
107
|
return [];
|
|
@@ -144,6 +159,7 @@ function renderSelectedContractRow(row, facts, context, abbreviations) {
|
|
|
144
159
|
if (row.phase === "claimed" || row.phase === "abandoned") {
|
|
145
160
|
const outcome = terminalFacts(row, context, abbreviations);
|
|
146
161
|
lines.push(...outcome.map((fact) => (fact.startsWith(" ") ? fact : ` ${safeText(fact)}`)));
|
|
162
|
+
lines.push(...linkedAkumaRows(row, facts.akuma));
|
|
147
163
|
return lines;
|
|
148
164
|
}
|
|
149
165
|
const deniedReview = row.gates.reports.find((gate) => gate.gate === "reviewed" && gate.current.kind === "attested" && gate.current.verdict === "unsatisfied");
|
|
@@ -161,9 +177,7 @@ function renderSelectedContractRow(row, facts, context, abbreviations) {
|
|
|
161
177
|
}
|
|
162
178
|
if (deniedReview?.current.kind === "attested" && deniedReview.current.summary !== undefined)
|
|
163
179
|
lines.push(...payload("review ×", deniedReview.current.summary, context));
|
|
164
|
-
|
|
165
|
-
if (akuma !== undefined)
|
|
166
|
-
lines.push(...semanticBlock("akuma", [akuma], context));
|
|
180
|
+
lines.push(...linkedAkumaRows(row, facts.akuma));
|
|
167
181
|
if (row.worktreePath !== null)
|
|
168
182
|
lines.push(...semanticBlock("worktree", [`worktree ${row.worktreePath}`], context));
|
|
169
183
|
lines.push(...semanticBlock("alarms", liveAlarms(row, facts.debts), context));
|
|
@@ -56,16 +56,31 @@ async function repair(worktree, relativePath, bytes, tracked) {
|
|
|
56
56
|
const path = join(worktree, relativePath);
|
|
57
57
|
if (tracked.has(relativePath))
|
|
58
58
|
throw new Error(`generated path is tracked by Git: ${path}`);
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (relativePath !== ".keiyaku/KEIYAKU.md") {
|
|
60
|
+
return { kind: "contract-file", path, action: await repairDerivedFile(path, bytes) };
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const stat = await lstat(path).catch((error) => {
|
|
64
|
+
if (error.code === "ENOENT")
|
|
65
|
+
return undefined;
|
|
66
|
+
throw error;
|
|
67
|
+
});
|
|
68
|
+
if (stat?.isFile() && !stat.isSymbolicLink() && !(await readFile(path)).equals(Buffer.from(bytes))) {
|
|
69
|
+
await chmod(path, stat.mode | 0o200);
|
|
70
|
+
}
|
|
71
|
+
const action = await repairDerivedFile(path, bytes);
|
|
72
|
+
return { kind: "contract-file", path, action };
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
61
75
|
try {
|
|
62
|
-
await
|
|
76
|
+
const stat = await lstat(path);
|
|
77
|
+
if (stat.isFile() && !stat.isSymbolicLink())
|
|
78
|
+
await chmod(path, 0o444);
|
|
63
79
|
}
|
|
64
80
|
catch {
|
|
65
81
|
/* advisory protection only */
|
|
66
82
|
}
|
|
67
83
|
}
|
|
68
|
-
return { kind: "contract-file", path, action };
|
|
69
84
|
}
|
|
70
85
|
async function isKeiyakuSeatLeaf(worktree, seat) {
|
|
71
86
|
const sentinel = join(worktree, ".agents", "skills", seat, ".gitignore");
|
|
@@ -7,7 +7,8 @@ type TargetObservation = Readonly<{
|
|
|
7
7
|
head: SnapshotId | null;
|
|
8
8
|
drift: boolean;
|
|
9
9
|
}>;
|
|
10
|
-
|
|
10
|
+
/** Reuse exact target evidence only within this read, while judging each Contract's own drift. */
|
|
11
|
+
export declare function deliveryTargetObserver(observation: GitReadObservation): (state: ContractState) => Promise<TargetObservation | null>;
|
|
11
12
|
type GitJournalRecord = Readonly<{
|
|
12
13
|
entries: readonly JournalEntry[];
|
|
13
14
|
state: ContractState | null;
|
package/build/src/git/observe.js
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import { decodeJournal } from "../core/facts/codec.js";
|
|
2
2
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
3
3
|
import { foldJournal } from "../core/facts/fold.js";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveContractTarget } from "./target.js";
|
|
5
5
|
import { contractJournalPath, contractJournalPaths, mintContractHead, mintSnapshotId, } from "./identity.js";
|
|
6
|
-
import { currentBranch, isKeiyakuOwnedRef
|
|
6
|
+
import { currentBranch, isKeiyakuOwnedRef } from "./repository.js";
|
|
7
7
|
import { GitPlumbingError, executeGit } from "./process.js";
|
|
8
8
|
import { readBlobResults, readGitTreeSelection, withGitTargetedReadObservation, } from "./read-observation.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
/** Reuse exact target evidence only within this read, while judging each Contract's own drift. */
|
|
10
|
+
export function deliveryTargetObserver(observation) {
|
|
11
|
+
const targets = new Map();
|
|
12
|
+
return async (state) => {
|
|
13
|
+
const target = state.coordinates.target;
|
|
14
|
+
if (target === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
const key = typeof target === "string" ? target : `${target.contractId}\0${target.worktree.id}\0${target.worktree.identity}`;
|
|
17
|
+
let pending = targets.get(key);
|
|
18
|
+
if (pending === undefined) {
|
|
19
|
+
pending = (async () => {
|
|
20
|
+
if (typeof target !== "string") {
|
|
21
|
+
const resolved = await resolveContractTarget(observation.repository, target.contractId, target);
|
|
22
|
+
return resolved.kind === "refused"
|
|
23
|
+
? { head: null, unavailable: true }
|
|
24
|
+
: { head: resolved.head, unavailable: false };
|
|
25
|
+
}
|
|
26
|
+
const value = await observation.resolveRef(target);
|
|
27
|
+
return { head: value === null ? null : mintSnapshotId(value), unavailable: false };
|
|
28
|
+
})();
|
|
29
|
+
targets.set(key, pending);
|
|
30
|
+
}
|
|
31
|
+
const { head, unavailable } = await pending;
|
|
32
|
+
const integration = state.currentIntegration;
|
|
33
|
+
const expected = state.terminal?.kind === "claimed" ? integration?.snapshot : integration?.predecessor;
|
|
34
|
+
return { head, drift: unavailable || (integration !== null && head !== expected) };
|
|
35
|
+
};
|
|
27
36
|
}
|
|
28
37
|
const TARGET_COORDINATES_FORMAT = "%(refname)%00%(objectname)%00";
|
|
29
38
|
export async function normalizeTargetBranch(repository, input) {
|
package/build/src/index.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export { z } from "zod";
|
|
|
50
50
|
export { Akuma, AkumaArchetypeError, AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError, Schema, listArchetypeDefinitions, } from "./akuma/index.js";
|
|
51
51
|
export type { AkumaCaller, AkumaOrigin, ActivityHistory, ActivityRow, AkuId, AkumaAskObservation, AkumaAskOptions, AkumaAskResult, AkumaBirthInput, AkumaHistoryOptions, AkumaHostOptions, AkumaIdleOptions, AkumaIdleResult, AkumaReportOptions, AkumaReportResult, AkumaSignalOptions, AkumaStatus, AkumaStreamSnapshot, AkumaTellOptions, AkumaTellResult, ArchetypeCatalog, ArchetypeCatalogInput, ArchetypeCatalogRow, InterruptReceipt, JsonSchema, JsonSchemaDocument, KillEvidence, SchemaLike, StandardSchemaV1, } from "./akuma/index.js";
|
|
52
52
|
export type { ActorId, ChangeId, ContractHead, ContractId, ContractState, ContractTarget, JournalEntry as Fact, FactKind, SnapshotId, } from "./core/facts/types.js";
|
|
53
|
-
export { kanshi, kanshiCategory, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
|
|
53
|
+
export { kanshi, kanshiCategory, kanshiCounts, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
|
|
54
|
+
export type { KanshiCountsInput, KanshiCountsReport } from "./kanshi/index.js";
|
|
54
55
|
export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiRow, KanshiCategoryInput, KanshiCategoryReport, KanshiInput, KanshiRegionSelection, KanshiReport, KanshiSelection, RegionDeclaration, RegionRead, Section, DebtKanshiRow, DebtKanshiWorld, } from "./kanshi/index.js";
|
|
55
56
|
export { AkumaAddressError, AkumaWorldScopeError, Akumas } from "./library/akumas.js";
|
|
56
57
|
export type { AkumaAddressInput, AkumaAskInput, AkumaHistoryInput, AkumaHistoryResult, AkumaKillInput, AkumaKillResult, AkumaList, AkumaListInput, AkumaObservation, AkumaObservationStage, AkumaTellInput, AkumaWaitInput, AkumaWaitResult, AkumaWorldScopeRefusal, CallInput, CallResult, CallWaitHead, CreatedDebtObservation, DispatchAssociation, DispatchStage, ForkInput, ForkResult, TellResult, TellWake, } from "./library/akumas.js";
|
package/build/src/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export { actorId } from "./core/facts/types.js";
|
|
|
47
47
|
*/
|
|
48
48
|
export { z } from "zod";
|
|
49
49
|
export { Akuma, AkumaArchetypeError, AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError, Schema, listArchetypeDefinitions, } from "./akuma/index.js";
|
|
50
|
-
export { kanshi, kanshiCategory, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
|
|
50
|
+
export { kanshi, kanshiCategory, kanshiCounts, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
|
|
51
51
|
export { AkumaAddressError, AkumaWorldScopeError, Akumas } from "./library/akumas.js";
|
|
52
52
|
export { nukeKeiyaku as nuke } from "./library/nuke.js";
|
|
53
53
|
export { SettingsError, settings } from "./settings.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Repo } from "../library/repo.js";
|
|
2
|
+
import { type WorldRoot } from "../world.js";
|
|
3
|
+
import type { Section } from "./report.js";
|
|
4
|
+
export type KanshiCountsInput = Readonly<{
|
|
5
|
+
world: WorldRoot | null;
|
|
6
|
+
repo?: Repo;
|
|
7
|
+
}>;
|
|
8
|
+
export type KanshiCountsReport = Readonly<{
|
|
9
|
+
root: WorldRoot | null;
|
|
10
|
+
observedAt: string;
|
|
11
|
+
akuma: Section<number>;
|
|
12
|
+
contracts: Section<number>;
|
|
13
|
+
debts: Section<number>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function kanshiCounts(input: KanshiCountsInput): Promise<KanshiCountsReport>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { countRunningAkuma } from "../akuma/akuma.js";
|
|
2
|
+
import { DebtAuthorityCorruptionError } from "../debt/index.js";
|
|
3
|
+
import { observeDebtBoard } from "../debt/operations.js";
|
|
4
|
+
import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
|
|
5
|
+
import { Repo, scopeForRepo } from "../library/repo.js";
|
|
6
|
+
import { readContractBoard } from "../protocol/read/status.js";
|
|
7
|
+
import { World } from "../world.js";
|
|
8
|
+
async function section(read) {
|
|
9
|
+
try {
|
|
10
|
+
return { kind: "present", value: await read() };
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
const text = (error instanceof Error ? error.message : String(error)).replaceAll(/\s+/gu, " ").trim();
|
|
14
|
+
return {
|
|
15
|
+
kind: "failed",
|
|
16
|
+
failure: {
|
|
17
|
+
message: text.length <= 240 ? text : `${text.slice(0, 239)}…`,
|
|
18
|
+
...(error instanceof DebtAuthorityCorruptionError && error.coordinate !== undefined
|
|
19
|
+
? { coordinate: error.coordinate }
|
|
20
|
+
: {}),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function kanshiCounts(input) {
|
|
26
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
27
|
+
throw new TypeError("kanshi counts input must be an object");
|
|
28
|
+
for (const key of Object.keys(input))
|
|
29
|
+
if (key !== "world" && key !== "repo")
|
|
30
|
+
throw new TypeError(`kanshi counts input has unknown field: ${key}`);
|
|
31
|
+
if (input.world !== null && (typeof input.world !== "string" || input.world.trim().length === 0))
|
|
32
|
+
throw new TypeError("kanshi world must be a WorldRoot or null");
|
|
33
|
+
if (input.repo !== undefined && !(input.repo instanceof Repo))
|
|
34
|
+
throw new TypeError("kanshi repo must be a Repo");
|
|
35
|
+
const world = input.world === null ? null : await World.prove(input.world);
|
|
36
|
+
const observedAt = new Date().toISOString();
|
|
37
|
+
const absent = { kind: "absent" };
|
|
38
|
+
const contracts = input.repo === undefined
|
|
39
|
+
? Promise.resolve(absent)
|
|
40
|
+
: section(async () => {
|
|
41
|
+
const repo = scopeForRepo(input.repo);
|
|
42
|
+
return withGitDecodeChannel(repo, (channel) => withGitReadObservation(repo, channel, async (observation) => (await readContractBoard(observation)).rows.length));
|
|
43
|
+
});
|
|
44
|
+
const worldSections = async () => {
|
|
45
|
+
if (world === null)
|
|
46
|
+
return [absent, absent];
|
|
47
|
+
let established;
|
|
48
|
+
try {
|
|
49
|
+
established = await World.established(world);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const failed = await section(async () => {
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
return [failed, failed];
|
|
56
|
+
}
|
|
57
|
+
if (!established)
|
|
58
|
+
return [absent, absent];
|
|
59
|
+
return Promise.all([
|
|
60
|
+
section(() => countRunningAkuma(world)),
|
|
61
|
+
section(async () => (await observeDebtBoard(world)).statusRows.filter((row) => row.state === "open").length),
|
|
62
|
+
]);
|
|
63
|
+
};
|
|
64
|
+
const [contractSection, [akuma, debts]] = await Promise.all([contracts, worldSections()]);
|
|
65
|
+
return { root: world, observedAt, akuma, contracts: contractSection, debts };
|
|
66
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { kanshi, kanshiCategory, observeKanshi } from "./read.js";
|
|
2
|
+
export { kanshiCounts } from "./counts.js";
|
|
3
|
+
export type { KanshiCountsInput, KanshiCountsReport } from "./counts.js";
|
|
2
4
|
export { selectKanshi, selectRegion } from "./select.js";
|
|
3
5
|
export type { KanshiCategoryInput, KanshiInput } from "./read.js";
|
|
4
6
|
export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiRow, KanshiCategoryReport, KanshiReport, Section, DebtKanshiRow, DebtKanshiWorld, KanshiRegionSelection, RegionDeclaration, RegionOverlap, RegionRead, } from "./report.js";
|
package/build/src/kanshi/read.js
CHANGED
|
@@ -137,7 +137,7 @@ async function readContracts(observation, include, limit = WORLD_CONTRACT_ROWS)
|
|
|
137
137
|
kind: "present",
|
|
138
138
|
value: include === undefined
|
|
139
139
|
? await readContractCatalogue(observation, limit)
|
|
140
|
-
: await readContractBoard(observation, include),
|
|
140
|
+
: await readContractBoard(observation, include, "selected"),
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BodyLauncher } from "../akuma/body-launch.js";
|
|
2
2
|
import { type AskObserver } from "../akuma/akuma-selection-execution.js";
|
|
3
3
|
import { type AkumaStatus } from "../akuma/akuma.js";
|
|
4
|
-
import { type ActivityHistory, type OutcomeRow } from "../akuma/projection.js";
|
|
4
|
+
import { type ActivityHistory, type OutcomeRow, type ReportRow } from "../akuma/projection.js";
|
|
5
5
|
import { type Schema } from "../akuma/schema.js";
|
|
6
6
|
import type { AkumaAskResult, AkumaKillResult, AkumaObservation, AkumaTellResult, AkumaWaitResult } from "../akuma/selection-observation.js";
|
|
7
7
|
import type { DispatchAssociation } from "../akuma/dispatch-association.js";
|
|
@@ -49,6 +49,11 @@ export type AkumaHistoryResult = Readonly<{
|
|
|
49
49
|
id: AkumaStatus["id"];
|
|
50
50
|
outcome: OutcomeRow;
|
|
51
51
|
contract: DispatchAssociation;
|
|
52
|
+
}> | Readonly<{
|
|
53
|
+
kind: "exact-report";
|
|
54
|
+
id: AkumaStatus["id"];
|
|
55
|
+
report: ReportRow;
|
|
56
|
+
contract: DispatchAssociation;
|
|
52
57
|
}> | Readonly<{
|
|
53
58
|
kind: "unknown-history";
|
|
54
59
|
id: AkumaStatus["id"];
|
|
@@ -5,7 +5,7 @@ import { AkumaNotBornError, AkumaObservationError } from "../akuma/akuma-errors.
|
|
|
5
5
|
import { AkumaOwner } from "../akuma/akuma-owner.js";
|
|
6
6
|
import { decodeAskObservation, executeAskAkuma, executeKillAkuma, executeTellAkuma, } from "../akuma/akuma-selection-execution.js";
|
|
7
7
|
import { executeWaitAkuma } from "../akuma/akuma-wait.js";
|
|
8
|
-
import {
|
|
8
|
+
import { parseExactHistorySelector } from "../akuma/identity.js";
|
|
9
9
|
import { schemaJsonText } from "../akuma/schema.js";
|
|
10
10
|
import { observeDispatchAssociations } from "../dispatch/index.js";
|
|
11
11
|
import { observeContractAt } from "../git/observe.js";
|
|
@@ -277,8 +277,8 @@ function validateHistoryInput(values) {
|
|
|
277
277
|
throw new TypeError("last must be a boolean");
|
|
278
278
|
if (values.id !== undefined && (typeof values.id !== "string" || values.id.trim() === ""))
|
|
279
279
|
throw new TypeError("id must be a nonblank string");
|
|
280
|
-
if (values.id !== undefined &&
|
|
281
|
-
throw new TypeError("id must match turn/<positive safe integer>");
|
|
280
|
+
if (values.id !== undefined && parseExactHistorySelector(values.id) === null)
|
|
281
|
+
throw new TypeError("id must match turn/<positive safe integer> or report/<positive safe integer>");
|
|
282
282
|
if (values.id !== undefined &&
|
|
283
283
|
(values.last === true || values.before !== undefined || values.since !== undefined || values.limit !== undefined))
|
|
284
284
|
throw new TypeError("id cannot be combined with last, before, since, or limit");
|
|
@@ -305,6 +305,8 @@ export async function historyAkuma(input, reportDiagnostic = stderrPluginDiagnos
|
|
|
305
305
|
if (values.id !== undefined) {
|
|
306
306
|
if ("kind" in history && history.kind === "exact")
|
|
307
307
|
return { kind: "exact", id: addressed.id, outcome: history.outcome, contract };
|
|
308
|
+
if ("kind" in history && history.kind === "exact-report")
|
|
309
|
+
return { kind: "exact-report", id: addressed.id, report: history.report, contract };
|
|
308
310
|
return { kind: "unknown-history", id: addressed.id, historyId: values.id, contract };
|
|
309
311
|
}
|
|
310
312
|
return { kind: "history", id: addressed.id, history: history, contract };
|
|
@@ -95,8 +95,8 @@ export type ContractObservation = Readonly<{
|
|
|
95
95
|
}>;
|
|
96
96
|
export declare function phaseAtFor(state: Pick<ContractState, "terminal" | "delivery">, bindAt: string): string;
|
|
97
97
|
export declare function lastJournalAtFor(entries: readonly Pick<JournalEntry, "at">[]): string;
|
|
98
|
-
/** Build the
|
|
99
|
-
export declare function readContractBoard(observation: GitReadObservation, include?: ContractId): Promise<ContractBoard>;
|
|
98
|
+
/** Build the complete board by default; a selected detail read retains complete dependency evidence. */
|
|
99
|
+
export declare function readContractBoard(observation: GitReadObservation, include?: ContractId, detail?: "board" | "selected"): Promise<ContractBoard>;
|
|
100
100
|
/** Observe a bounded recent active Contract catalogue from one immutable git observation. */
|
|
101
101
|
export declare function readContractCatalogue(observation: GitReadObservation, limit: number): Promise<ContractCatalogue>;
|
|
102
102
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { observeActiveContractWorld, observeContractsForAdmissionInObservationAt,
|
|
1
|
+
import { observeActiveContractWorld, observeContractsForAdmissionInObservationAt, deliveryTargetObserver, withContractReadObservationAt, } from "../../git/observe.js";
|
|
2
2
|
import { decodeContractDocument } from "../../body/decode.js";
|
|
3
3
|
import { observeTargetLag, observeWorkspace, readConflictHandoffs, conflictRecovery, worktreePath, } from "../../git/workspace.js";
|
|
4
4
|
import { appointmentFor, readPlaceRegister } from "../../workspace-place.js";
|
|
@@ -145,20 +145,21 @@ async function hydrateRows(observation, states, endpoints, dependentStates = [])
|
|
|
145
145
|
workspace: appointedWorkspace(observation.repository, register, value.state),
|
|
146
146
|
}));
|
|
147
147
|
const handoffs = await readConflictHandoffs(observation.repository, observation.readBlobs, selected.flatMap(({ workspace }) => (workspace === undefined ? [] : [workspace])));
|
|
148
|
+
const observeTarget = deliveryTargetObserver(observation);
|
|
148
149
|
return await Promise.all(selected.map(async ({ state, bindAt, lastJournalAt, workspace }) => await rowFor({
|
|
149
150
|
repository: observation.repository,
|
|
150
151
|
state,
|
|
151
152
|
bindAt,
|
|
152
153
|
lastJournalAt,
|
|
153
|
-
targetObservation: await
|
|
154
|
+
targetObservation: await observeTarget(state),
|
|
154
155
|
workspace,
|
|
155
156
|
handoff: handoffs.get(state.id),
|
|
156
157
|
after: afterEdges(state, endpoints),
|
|
157
158
|
dependents: reverseDependents(state.id, dependentStates),
|
|
158
159
|
})));
|
|
159
160
|
}
|
|
160
|
-
/** Build the
|
|
161
|
-
export async function readContractBoard(observation, include) {
|
|
161
|
+
/** Build the complete board by default; a selected detail read retains complete dependency evidence. */
|
|
162
|
+
export async function readContractBoard(observation, include, detail = "board") {
|
|
162
163
|
const observedAt = new Date().toISOString();
|
|
163
164
|
const observed = await observeActiveContractWorld(observation);
|
|
164
165
|
const contracts = new Map(observed.contracts);
|
|
@@ -174,8 +175,9 @@ export async function readContractBoard(observation, include) {
|
|
|
174
175
|
endpoints = new Map(await afterEndpointMap(observation, endpoints, record.state.terms.after));
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
|
-
const
|
|
178
|
-
const
|
|
178
|
+
const states = selectedContractStates(contracts);
|
|
179
|
+
const selected = detail === "selected" ? states.filter(({ state }) => state.id === include) : states;
|
|
180
|
+
const rows = await hydrateRows(observation, selected, endpoints, states);
|
|
179
181
|
return {
|
|
180
182
|
root: observation.repository.primaryWorktree,
|
|
181
183
|
state: observed.snapshot,
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrosheep/keiyaku",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.30",
|
|
4
4
|
"workspaces": [
|
|
5
5
|
"plugins/square",
|
|
6
6
|
"plugins/paseo/forwarder"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@agentclientprotocol/sdk": "^1.3.0",
|
|
83
83
|
"@anthropic-ai/claude-agent-sdk": "^0.3.226",
|
|
84
|
-
"@astrosheep/keiyaku-plugin-square": "0.1.
|
|
84
|
+
"@astrosheep/keiyaku-plugin-square": "0.1.22",
|
|
85
85
|
"@astrosheep/square": "^0.4.1",
|
|
86
86
|
"@getpaseo/client": "0.14.0",
|
|
87
87
|
"@getpaseo/protocol": "0.14.0",
|