@astrosheep/keiyaku 4.6.32 → 4.6.33
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 +8 -6
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +8 -6
- 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 +2 -9
- package/build/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/skills/keiyaku-babysit/SKILL.md +8 -6
- 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.js +73 -14
- 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 +40 -1
- package/build/src/akuma/akuma-wait.js +58 -29
- package/build/src/akuma/akuma.d.ts +11 -0
- 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/index.d.ts +1 -1
- package/build/src/akuma/heart/index.js +9 -1
- package/build/src/akuma/heart/timeline.js +4 -4
- package/build/src/akuma/projection-read.d.ts +4 -2
- package/build/src/akuma/projection-read.js +21 -14
- 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 +23 -0
- package/build/src/akuma/selection-observation.js +15 -4
- 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/cli/commands/akuma-grammar.d.ts +3 -5
- package/build/src/cli/commands/akuma-grammar.js +22 -40
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +6 -58
- package/build/src/cli/commands/contract-grammar.d.ts +1 -0
- package/build/src/cli/commands/contract-grammar.js +7 -11
- package/build/src/cli/commands/contract-help.d.ts +3 -2
- package/build/src/cli/commands/contract-help.js +11 -5
- package/build/src/cli/commands/contract.js +3 -0
- package/build/src/cli/commands/debt-grammar.js +2 -4
- package/build/src/cli/parse.js +1 -4
- package/build/src/cli/render/akuma-activity.d.ts +3 -15
- package/build/src/cli/render/akuma-activity.js +19 -73
- 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 +1 -4
- package/build/src/cli/render/contract-history.js +2 -0
- 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 +13 -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.js +1 -2
- package/build/src/cli/render/kanshi.js +11 -17
- 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 +19 -17
- package/build/src/cli/runtime.js +3 -9
- 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/index.d.ts +0 -1
- package/build/src/debt/index.js +6 -11
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +6 -4
- 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 +3 -0
- package/build/src/git/observe.js +25 -23
- 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/index.d.ts +2 -0
- package/build/src/kanshi/index.d.ts +0 -1
- package/build/src/kanshi/index.js +0 -1
- package/build/src/kanshi/read.d.ts +21 -0
- package/build/src/kanshi/read.js +2 -1
- 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/continuation.d.ts +10 -0
- package/build/src/library/contract-creation.js +10 -11
- 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 +18 -0
- package/build/src/library/contract-types.js +2 -0
- package/build/src/library/contract-wait.d.ts +7 -0
- package/build/src/library/contract-wait.js +53 -49
- package/build/src/library/delivery.d.ts +25 -0
- package/build/src/library/input.d.ts +5 -23
- package/build/src/library/input.js +12 -7
- package/build/src/library/kei.js +39 -20
- package/build/src/library/keiyaku-classify.js +3 -3
- package/build/src/library/keiyaku-debt.js +1 -2
- package/build/src/library/keiyaku-identity.d.ts +3 -3
- package/build/src/library/keiyaku-identity.js +11 -6
- package/build/src/library/keiyaku-verbs.d.ts +456 -1362
- package/build/src/library/keiyaku-verbs.js +80 -92
- package/build/src/library/keiyaku-wait.d.ts +183 -0
- package/build/src/library/keiyaku-wait.js +213 -0
- package/build/src/library/keiyaku.d.ts +3 -1
- package/build/src/library/keiyaku.js +49 -73
- package/build/src/{mcp/output.d.ts → library/model-tools.d.ts} +227 -56
- package/build/src/library/model-tools.js +347 -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 +12 -0
- package/build/src/library/selection.js +1 -2
- package/build/src/mcp/adapter.d.ts +0 -6
- package/build/src/mcp/adapter.js +10 -159
- 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 +6 -4
- package/build/src/pi/index.d.ts +3 -0
- package/build/src/pi/index.js +83 -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 +54 -16
- package/build/src/protocol/operations.js +17 -31
- package/build/src/protocol/placement.js +7 -1
- package/build/src/protocol/progress.js +0 -6
- package/build/src/protocol/read/status.d.ts +40 -0
- package/build/src/protocol/read/status.js +7 -10
- 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/pi/README.md +55 -97
- package/plugins/pi/keiyaku.ts +2 -9
- package/skills/keiyaku-akuma/SKILL.md +13 -9
- package/skills/keiyaku-babysit/SKILL.md +8 -6
- 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.js +0 -193
- package/plugins/pi/akuma-tools.ts +0 -283
|
@@ -30,11 +30,10 @@ declare const AKUMA_COMMAND_SPECS: {
|
|
|
30
30
|
readonly flags: {
|
|
31
31
|
readonly contract: "value";
|
|
32
32
|
readonly alias: "value";
|
|
33
|
-
readonly wait: "value";
|
|
34
33
|
readonly bare: "boolean";
|
|
35
34
|
readonly json: "boolean";
|
|
36
35
|
};
|
|
37
|
-
readonly usage: "spawn <akuma-name> [--contract <kei/...>] [--repo <path>] [--workdir <path>] [--alias <name>] [--bare] [
|
|
36
|
+
readonly usage: "spawn <akuma-name> [--contract <kei/...>] [--repo <path>] [--workdir <path>] [--alias <name>] [--bare] [<prompt> | -]";
|
|
38
37
|
readonly purpose: "Spawn a new Akuma into the world.";
|
|
39
38
|
readonly details: string;
|
|
40
39
|
};
|
|
@@ -56,11 +55,10 @@ declare const AKUMA_COMMAND_SPECS: {
|
|
|
56
55
|
readonly stdin: true;
|
|
57
56
|
readonly flags: {
|
|
58
57
|
readonly interrupt: "boolean";
|
|
59
|
-
readonly wait: "value";
|
|
60
58
|
readonly json: "boolean";
|
|
61
59
|
};
|
|
62
|
-
readonly usage: "tell <aku/...|@name> [--interrupt]
|
|
63
|
-
readonly purpose: "
|
|
60
|
+
readonly usage: "tell <aku/...|@name> [--interrupt] (<prompt> | -)";
|
|
61
|
+
readonly purpose: "Admit new orders for an Akuma.";
|
|
64
62
|
readonly details: string;
|
|
65
63
|
};
|
|
66
64
|
readonly ask: {
|
|
@@ -21,23 +21,20 @@ const AKUMA_COMMAND_SPECS = {
|
|
|
21
21
|
flags: {
|
|
22
22
|
contract: "value",
|
|
23
23
|
alias: "value",
|
|
24
|
-
wait: "value",
|
|
25
24
|
bare: "boolean",
|
|
26
25
|
json: "boolean",
|
|
27
26
|
},
|
|
28
|
-
usage: "spawn <akuma-name> [--contract <kei/...>] [--repo <path>] [--workdir <path>] [--alias <name>] [--bare] [
|
|
27
|
+
usage: "spawn <akuma-name> [--contract <kei/...>] [--repo <path>] [--workdir <path>] [--alias <name>] [--bare] [<prompt> | -]",
|
|
29
28
|
purpose: "Spawn a new Akuma into the world.",
|
|
30
29
|
details: [
|
|
31
30
|
"Use keiyaku ls aku/ to list available Akuma names.",
|
|
32
31
|
"Omit the prompt to birth without a Tell; otherwise give <prompt> as one argument, or use - to read stdin.",
|
|
33
|
-
"--wait requires a prompt.",
|
|
34
32
|
"--bare omits Keiyaku's runtime instruction section for this birth and its later execution; personality, tools, permissions, and report remain unchanged.",
|
|
35
33
|
"Generic ACP needs --bare: it has no verified native runtime-instruction channel. Existing sessions without the section are not retrofitted; ordinary resume retains existing native instructions.",
|
|
36
|
-
"
|
|
34
|
+
"Spawn returns birth and optional first Tell admission, not an answer. Observe work separately with wait.",
|
|
37
35
|
"--contract records an association, not the work or execution directory; include the Contract and worktree context in the prompt as needed. --repo requires --contract.",
|
|
38
36
|
"--workdir selects where the Akuma works; relative paths resolve from the invocation directory selected by -C/--cwd, or the process cwd when omitted. Without --workdir, the invocation directory is used.",
|
|
39
37
|
"--alias <name> gives the new Akuma the selector @name instead of aku/<id>; an existing @name is reassigned to this Akuma.",
|
|
40
|
-
"With --wait, completed activity streams on stderr and the final answer is written to stdout once.",
|
|
41
38
|
].join("\n"),
|
|
42
39
|
},
|
|
43
40
|
wait: {
|
|
@@ -47,7 +44,7 @@ const AKUMA_COMMAND_SPECS = {
|
|
|
47
44
|
usage: `wait ${SET_SELECTORS} [--any | --all] [--timeout <duration>] [--repo <path>]`,
|
|
48
45
|
purpose: "Wait for Contract changes or terminal state, or Akumas to finish work.",
|
|
49
46
|
details: [
|
|
50
|
-
"Select Contracts
|
|
47
|
+
"Select Contracts and Akumas together or separately. Contract IDs wait for their next journal change or terminal state, not associated Akumas. One deadline and any/all mode cover the whole selection.",
|
|
51
48
|
"The default mode is any; --all waits for every selected member. Each Contract starts from its current journal head; already accepted or abandoned Contracts complete immediately.",
|
|
52
49
|
SET_DETAILS,
|
|
53
50
|
"An already completed Akuma counts immediately; a deadline only bounds observation.",
|
|
@@ -57,15 +54,13 @@ const AKUMA_COMMAND_SPECS = {
|
|
|
57
54
|
tell: {
|
|
58
55
|
arity: 1,
|
|
59
56
|
stdin: true,
|
|
60
|
-
flags: { interrupt: "boolean",
|
|
61
|
-
usage: "tell <aku/...|@name> [--interrupt]
|
|
62
|
-
purpose: "
|
|
57
|
+
flags: { interrupt: "boolean", json: "boolean" },
|
|
58
|
+
usage: "tell <aku/...|@name> [--interrupt] (<prompt> | -)",
|
|
59
|
+
purpose: "Admit new orders for an Akuma.",
|
|
63
60
|
details: [
|
|
64
61
|
"Give <prompt> as one argument, or use - to read stdin.",
|
|
65
62
|
"--interrupt admits the Tell and asks current work to yield; the Tell remains admitted even if yielding cannot be confirmed.",
|
|
66
|
-
"
|
|
67
|
-
"Without --wait, returns after Tell admission.",
|
|
68
|
-
"With observation, completed activity streams on stderr and the final answer is written to stdout once.",
|
|
63
|
+
"Returns Tell admission, not an answer. Observe work separately with wait, or use ask for a structured answer.",
|
|
69
64
|
].join("\n"),
|
|
70
65
|
},
|
|
71
66
|
ask: {
|
|
@@ -166,16 +161,13 @@ function positiveIndex(raw, option, fail) {
|
|
|
166
161
|
return value;
|
|
167
162
|
}
|
|
168
163
|
function validateSet(value, fail) {
|
|
169
|
-
if (value.startsWith("kei/"))
|
|
170
|
-
return value;
|
|
171
|
-
if (value.includes("*")) {
|
|
164
|
+
if (!value.startsWith("kei/") && value.includes("*")) {
|
|
172
165
|
try {
|
|
173
166
|
parseAkumaGlob(value);
|
|
174
167
|
}
|
|
175
168
|
catch (error) {
|
|
176
169
|
fail(error instanceof Error ? error.message : `invalid Akuma glob: ${value}`);
|
|
177
170
|
}
|
|
178
|
-
return value;
|
|
179
171
|
}
|
|
180
172
|
return value;
|
|
181
173
|
}
|
|
@@ -184,14 +176,15 @@ function parseWait(rawSelectors, flags, output, fail) {
|
|
|
184
176
|
fail("wait --any and --all are mutually exclusive");
|
|
185
177
|
const completion = flags.any === true ? "any" : flags.all === true ? "all" : undefined;
|
|
186
178
|
const selectors = rawSelectors.map((value) => validateSet(value, fail));
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
const timeout = flags.timeout === undefined ? undefined : stringFlag(flags.timeout, "--timeout requires a duration", fail);
|
|
180
|
+
if (timeout !== undefined)
|
|
181
|
+
parseDuration(timeout, "--timeout", fail);
|
|
189
182
|
return {
|
|
190
183
|
name: "wait",
|
|
191
184
|
input: {
|
|
192
185
|
selectors,
|
|
193
186
|
...(completion === undefined ? {} : { completion }),
|
|
194
|
-
...(
|
|
187
|
+
...(timeout === undefined ? {} : { timeout }),
|
|
195
188
|
},
|
|
196
189
|
output,
|
|
197
190
|
};
|
|
@@ -273,25 +266,20 @@ function parsePrompted(action, positionals, stdin, fail) {
|
|
|
273
266
|
}
|
|
274
267
|
function parseTell(action, flags, subject, prompt, fail) {
|
|
275
268
|
const output = flags.json === true ? "json" : "text";
|
|
276
|
-
const wait = flags.wait === undefined ? undefined : stringFlag(flags.wait, "--wait requires a duration", fail);
|
|
277
|
-
const timeoutMs = wait === undefined ? undefined : parseDuration(wait, "--wait", fail);
|
|
278
269
|
const input = {
|
|
279
270
|
akuma: subject,
|
|
280
271
|
...(flags.interrupt === true ? { interrupt: true } : {}),
|
|
281
272
|
};
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
: {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
acquire: { prompt, schema: stringFlag(flags.schema, "ask requires --schema <file>", fail) },
|
|
293
|
-
output,
|
|
294
|
-
};
|
|
273
|
+
if (action === "tell")
|
|
274
|
+
return { name: action, input, acquire: { prompt }, output };
|
|
275
|
+
const wait = flags.wait === undefined ? undefined : stringFlag(flags.wait, "--wait requires a duration", fail);
|
|
276
|
+
const timeoutMs = wait === undefined ? undefined : parseDuration(wait, "--wait", fail);
|
|
277
|
+
return {
|
|
278
|
+
name: action,
|
|
279
|
+
input: { ...input, ...(timeoutMs === undefined ? {} : { timeoutMs }) },
|
|
280
|
+
acquire: { prompt, schema: stringFlag(flags.schema, "ask requires --schema <file>", fail) },
|
|
281
|
+
output,
|
|
282
|
+
};
|
|
295
283
|
}
|
|
296
284
|
function parseSpawn(flags, akumaName, prompt, output, fail) {
|
|
297
285
|
let alias;
|
|
@@ -304,18 +292,12 @@ function parseSpawn(flags, akumaName, prompt, output, fail) {
|
|
|
304
292
|
fail(error instanceof Error ? error.message : "invalid Akuma alias");
|
|
305
293
|
}
|
|
306
294
|
}
|
|
307
|
-
const wait = flags.wait === undefined ? undefined : stringFlag(flags.wait, "--wait requires a duration", fail);
|
|
308
|
-
if (wait !== undefined)
|
|
309
|
-
parseDuration(wait, "--wait", fail);
|
|
310
|
-
if (prompt === undefined && flags.wait !== undefined)
|
|
311
|
-
fail("spawn --wait requires a prompt");
|
|
312
295
|
return {
|
|
313
296
|
name: "spawn",
|
|
314
297
|
input: {
|
|
315
298
|
akumaName,
|
|
316
299
|
...(typeof flags.contract === "string" ? { contract: flags.contract } : {}),
|
|
317
300
|
...(alias === undefined ? {} : { alias }),
|
|
318
|
-
...(wait === undefined ? {} : { wait }),
|
|
319
301
|
...(flags.bare === true ? { bare: true } : {}),
|
|
320
302
|
},
|
|
321
303
|
acquire: { ...(prompt === undefined ? {} : { prompt }) },
|
|
@@ -5,6 +5,5 @@ import type { CliRuntime } from "../runtime.js";
|
|
|
5
5
|
export declare function acquireAkumaRequest(request: Extract<PendingRequest, {
|
|
6
6
|
name: "spawn" | "tell" | "ask";
|
|
7
7
|
}>, workdir: string | undefined, runtime: CliRuntime): Promise<VerbRequest<"spawn" | "tell" | "ask">>;
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function runAsk(request: VerbRequest<"ask" | "tell">, runtime: CliRuntime): Promise<CliOutcome>;
|
|
8
|
+
export declare function runAsk(request: VerbRequest<"ask">, runtime: CliRuntime): Promise<CliOutcome>;
|
|
10
9
|
export declare function runAkumaHistory(request: VerbRequest<"history">, runtime: CliRuntime): Promise<CliOutcome>;
|
|
@@ -4,10 +4,10 @@ import { readFile } from "node:fs/promises";
|
|
|
4
4
|
import { canonicalDocument } from "../../akuma/schema.js";
|
|
5
5
|
import { classifyVerb, verbs } from "../../library/keiyaku-verbs.js";
|
|
6
6
|
import { ActivityDriver } from "../activity.js";
|
|
7
|
-
import { displayContext, resultContext, writeJson,
|
|
8
|
-
import { askRawAnswer,
|
|
9
|
-
import { askProgressStream
|
|
10
|
-
import { renderVerb } from "../render/verbs.js";
|
|
7
|
+
import { displayContext, resultContext, writeJson, writeStdout } from "../streams.js";
|
|
8
|
+
import { askRawAnswer, historyRawAnswer } from "../render/akuma-activity.js";
|
|
9
|
+
import { askProgressStream } from "../render/akuma.js";
|
|
10
|
+
import { aliasSelector, renderVerb } from "../render/verbs.js";
|
|
11
11
|
async function schemaFromFile(path) {
|
|
12
12
|
try {
|
|
13
13
|
const parsed = JSON.parse(await readFile(path, "utf8"));
|
|
@@ -17,9 +17,6 @@ async function schemaFromFile(path) {
|
|
|
17
17
|
throw new CliUsageError(`cannot read JSON Schema file ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function inputAlias(selector) {
|
|
21
|
-
return selector.startsWith("@") ? selector : undefined;
|
|
22
|
-
}
|
|
23
20
|
async function promptBody(action, prompt, runtime) {
|
|
24
21
|
if (prompt.kind !== "stdin")
|
|
25
22
|
return prompt.value;
|
|
@@ -53,56 +50,9 @@ function emitAnswer(body, exact) {
|
|
|
53
50
|
else
|
|
54
51
|
writeStdout(body);
|
|
55
52
|
}
|
|
56
|
-
export async function runSpawn(request, runtime) {
|
|
57
|
-
const { input, output } = request;
|
|
58
|
-
let stream;
|
|
59
|
-
const driver = new ActivityDriver(process.stderr);
|
|
60
|
-
const observing = input.wait !== undefined && output === "text";
|
|
61
|
-
const observe = observing
|
|
62
|
-
? (event) => {
|
|
63
|
-
if (event.kind === "admitted") {
|
|
64
|
-
stream = callObservationStream(resultContext(), callObservationHead({ akumaId: event.id, ...event.head }), {
|
|
65
|
-
admittedAt: event.tell.row.at,
|
|
66
|
-
});
|
|
67
|
-
driver.redraw(stream.frame());
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
driver.settle(stream?.observe(event.observation) ?? [], stream?.frame() ?? []);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
: undefined;
|
|
74
|
-
try {
|
|
75
|
-
const result = await runtime.facet.run("spawn", input, {
|
|
76
|
-
signal: runtime.signal,
|
|
77
|
-
...(observe === undefined ? {} : { observe }),
|
|
78
|
-
});
|
|
79
|
-
let streamed = stream !== undefined;
|
|
80
|
-
if (stream !== undefined)
|
|
81
|
-
driver.conclude(stream.conclude(result));
|
|
82
|
-
else if (observing && result.kind === "failed") {
|
|
83
|
-
writeStderr(renderFailedCallObservation(result, resultContext(), input.prompt === undefined ? {} : { prompt: input.prompt }));
|
|
84
|
-
streamed = true;
|
|
85
|
-
}
|
|
86
|
-
const completion = { kind: "returned", value: result };
|
|
87
|
-
if (output === "json")
|
|
88
|
-
writeJson(result);
|
|
89
|
-
else if (streamed) {
|
|
90
|
-
const raw = callRawAnswer(result, true);
|
|
91
|
-
emitAnswer(raw ?? "", raw !== undefined);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
const raw = callRawAnswer(result, false);
|
|
95
|
-
emitAnswer(renderVerb("spawn", input, completion, displayContext()), raw !== undefined);
|
|
96
|
-
}
|
|
97
|
-
return classifyVerb("spawn", input, completion);
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
driver.close(stream?.flush() ?? []);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
53
|
export async function runAsk(request, runtime) {
|
|
104
54
|
const { input, output } = request;
|
|
105
|
-
const progress = output === "text" ? askProgressStream(undefined,
|
|
55
|
+
const progress = output === "text" ? askProgressStream(undefined, aliasSelector(input.akuma), resultContext()) : undefined;
|
|
106
56
|
const driver = new ActivityDriver(process.stderr);
|
|
107
57
|
const observe = progress === undefined
|
|
108
58
|
? undefined
|
|
@@ -117,9 +67,7 @@ export async function runAsk(request, runtime) {
|
|
|
117
67
|
signal: runtime.signal,
|
|
118
68
|
...(observe === undefined ? {} : { observe }),
|
|
119
69
|
};
|
|
120
|
-
const result =
|
|
121
|
-
? await runtime.facet.run("ask", request.input, run)
|
|
122
|
-
: await runtime.facet.run("tell", request.input, run);
|
|
70
|
+
const result = await runtime.facet.run("ask", request.input, run);
|
|
123
71
|
if (progress !== undefined)
|
|
124
72
|
driver.conclude(progress.conclude(result).join("\n"));
|
|
125
73
|
const completion = { kind: "returned", value: result };
|
|
@@ -8,7 +8,7 @@ function optionalFlag(flags, name) {
|
|
|
8
8
|
const value = flags[name];
|
|
9
9
|
return typeof value === "string" ? value : undefined;
|
|
10
10
|
}
|
|
11
|
-
function refuse(command, message) {
|
|
11
|
+
export function refuse(command, message) {
|
|
12
12
|
throw new CliUsageError(message, commandGuide(command, CONTRACT_COMMAND_SPECS[command].usage));
|
|
13
13
|
}
|
|
14
14
|
// The CLI restates the literal gate-word grammar its help prints; the corpus
|
|
@@ -80,21 +80,17 @@ function parseAmend(parts) {
|
|
|
80
80
|
if (parts.flags["clear-after"] === true && after.length > 0)
|
|
81
81
|
refuse("amend", "--clear-after and --after are mutually exclusive");
|
|
82
82
|
const gates = parseGateNames(parts, "amend");
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
83
|
+
const target = optionalFlag(parts.flags, "target");
|
|
84
|
+
// Omitted fields stay omitted: only an explicit empty selection clears anything.
|
|
86
85
|
const input = {
|
|
87
86
|
...(contract === undefined ? {} : { contract }),
|
|
88
87
|
...(parts.flags["clear-after"] === true ? { after: [] } : parts.flags.after === undefined ? {} : { after }),
|
|
89
88
|
...(gates === undefined ? {} : { gates }),
|
|
89
|
+
...(target === undefined ? {} : { target }),
|
|
90
90
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
name: "amend",
|
|
95
|
-
input: gates === undefined ? { ...input, after } : { ...input, gates },
|
|
96
|
-
output: parts.output,
|
|
97
|
-
};
|
|
91
|
+
return parts.stdin
|
|
92
|
+
? { name: "amend", input, acquire: { markdown: true }, output: parts.output }
|
|
93
|
+
: { name: "amend", input, output: parts.output };
|
|
98
94
|
}
|
|
99
95
|
function parseDeliver(parts) {
|
|
100
96
|
const contract = parts.positionals[0];
|
|
@@ -31,10 +31,11 @@ export declare const CONTRACT_COMMAND_SPECS: {
|
|
|
31
31
|
readonly after: "repeat";
|
|
32
32
|
readonly "clear-after": "boolean";
|
|
33
33
|
readonly gates: "raw-value";
|
|
34
|
+
readonly target: "value";
|
|
34
35
|
readonly json: "boolean";
|
|
35
36
|
};
|
|
36
|
-
readonly usage: "amend [<contract>|@name] [--after <kei/...> [--after <kei/...>]... | --clear-after] [--gates <name,...>] [--repo <path>] [-]";
|
|
37
|
-
readonly purpose: "Change a Contract's document, prerequisites, or acceptance gates.";
|
|
37
|
+
readonly usage: "amend [<contract>|@name] [--after <kei/...> [--after <kei/...>]... | --clear-after] [--gates <name,...>] [--target <branch|kei/...>] [--repo <path>] [-]";
|
|
38
|
+
readonly purpose: "Change a Contract's document, target, prerequisites, or acceptance gates.";
|
|
38
39
|
readonly details: string;
|
|
39
40
|
};
|
|
40
41
|
readonly deliver: {
|
|
@@ -50,8 +50,7 @@ export const CONTRACT_COMMAND_SPECS = {
|
|
|
50
50
|
"Region lists the narrowest writes this approach needs, not every file involved;",
|
|
51
51
|
"avoid broad directories and redundant parent/child patterns. Put one repository-relative",
|
|
52
52
|
"pattern per nonblank line: bare lines, list items, or fences (no info string, or",
|
|
53
|
-
"txt) are combined. A trailing '/' means 'path/**'.
|
|
54
|
-
"binds with a warning.",
|
|
53
|
+
"txt) are combined. A trailing '/' means 'path/**'.",
|
|
55
54
|
"",
|
|
56
55
|
"Only explicit verify runs Verification; gate selection controls recording and placement.",
|
|
57
56
|
"Verification uses one or more closed bash, zsh, or pwsh fences. Its fence",
|
|
@@ -62,15 +61,22 @@ export const CONTRACT_COMMAND_SPECS = {
|
|
|
62
61
|
amend: {
|
|
63
62
|
positional: "optional",
|
|
64
63
|
stdin: "optional",
|
|
65
|
-
flags: { after: "repeat", "clear-after": "boolean", gates: "raw-value", json: "boolean" },
|
|
66
|
-
usage: "amend [<contract>|@name] [--after <kei/...> [--after <kei/...>]... | --clear-after] [--gates <name,...>] [--repo <path>] [-]",
|
|
67
|
-
purpose: "Change a Contract's document, prerequisites, or acceptance gates.",
|
|
64
|
+
flags: { after: "repeat", "clear-after": "boolean", gates: "raw-value", target: "value", json: "boolean" },
|
|
65
|
+
usage: "amend [<contract>|@name] [--after <kei/...> [--after <kei/...>]... | --clear-after] [--gates <name,...>] [--target <branch|kei/...>] [--repo <path>] [-]",
|
|
66
|
+
purpose: "Change a Contract's document, target, prerequisites, or acceptance gates.",
|
|
68
67
|
details: [
|
|
69
68
|
"Gates are checked at integration: reviewed needs a satisfied review;",
|
|
70
69
|
"verified needs satisfied evidence for every declaration. --gates <name,...> replaces them with",
|
|
71
70
|
"reviewed, verified, or configured groups (see keiyaku settings).",
|
|
72
71
|
'Omitting --gates keeps them; --gates "" clears them.',
|
|
73
72
|
"",
|
|
73
|
+
"--target explicitly selects an existing local branch or active Contract destination.",
|
|
74
|
+
"Omission keeps the current target, even after its Contract is accepted or abandoned.",
|
|
75
|
+
"Self-targets and destination cycles refuse. Use refs/heads/kei/... for a branch named kei/....",
|
|
76
|
+
"Retargeting requires fresh verify; unchanged candidate content keeps its review.",
|
|
77
|
+
"",
|
|
78
|
+
"Naming no edit at all reports the active Contract unchanged and writes nothing.",
|
|
79
|
+
"",
|
|
74
80
|
"stdin is an amendment; each heading is one edit:",
|
|
75
81
|
" ## Context|Objective|Design|Region|Criteria|Verification|<extension> (replace, or add a new extension)",
|
|
76
82
|
" ## Replace: Context|Objective|Design|Region|Criteria|Verification|<extension>",
|
|
@@ -47,6 +47,8 @@ export async function acquireContractRequest(request, runtime) {
|
|
|
47
47
|
}
|
|
48
48
|
if (request.name === "amend" && isBlankInput(bytes))
|
|
49
49
|
throw new CliUsageError("amend requires a nonblank stdin document");
|
|
50
|
+
if (request.name === "bind")
|
|
51
|
+
return { name: request.name, input: { ...request.input, markdown: bytes }, output: request.output };
|
|
50
52
|
return { name: request.name, input: { ...request.input, markdown: bytes }, output: request.output };
|
|
51
53
|
}
|
|
52
54
|
async function invokeAndFinish(request, runtime, alias) {
|
|
@@ -54,6 +56,7 @@ async function invokeAndFinish(request, runtime, alias) {
|
|
|
54
56
|
const driver = progressing && request.output === "text" ? await runtime.progress() : undefined;
|
|
55
57
|
const cancellable = progressing ||
|
|
56
58
|
request.name === "wait" ||
|
|
59
|
+
request.name === "spawn" ||
|
|
57
60
|
request.name === "tell" ||
|
|
58
61
|
request.name === "fork" ||
|
|
59
62
|
request.name === "kill";
|
|
@@ -98,8 +98,6 @@ function validateUpdate(scanned, fail) {
|
|
|
98
98
|
if (Object.keys(flags).every((name) => name === "json"))
|
|
99
99
|
fail("debt update requires at least one update option");
|
|
100
100
|
}
|
|
101
|
-
/** Actions whose positionals are all addressed DebtIds validated by the native owner. */
|
|
102
|
-
const DEBT_ID_ACTIONS = new Set(["update"]);
|
|
103
101
|
/** Validate every addressed DebtId positional through the native owner before any read or write. */
|
|
104
102
|
function validateDebtIdPositionals(positionals, fail) {
|
|
105
103
|
for (const debtId of positionals) {
|
|
@@ -123,10 +121,10 @@ function validateDebtScan(action, scanned, fail) {
|
|
|
123
121
|
fail("debt add requires either TITLE or '-' input");
|
|
124
122
|
if (action === "add" && stdin === "document" && Object.keys(flags).some((name) => name !== "json"))
|
|
125
123
|
fail("debt add document input owns its creation fields");
|
|
126
|
-
if (
|
|
124
|
+
if (action === "update") {
|
|
127
125
|
validateDebtIdPositionals(positionals, fail);
|
|
128
|
-
if (action === "update")
|
|
129
126
|
validateUpdate(scanned, fail);
|
|
127
|
+
}
|
|
130
128
|
}
|
|
131
129
|
export function parseDebtCommand(argv) {
|
|
132
130
|
const candidate = argv[0];
|
package/build/src/cli/parse.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDebtAction, parseDebtCommand, renderDebtHelp, debtUsageGuide, } from "./commands/debt-grammar.js";
|
|
2
2
|
import { akumaUsageGuide, isAkumaAction, parseAkumaCommand, renderAkumaHelp, renderAkumaRootRows, } from "./commands/akuma-grammar.js";
|
|
3
3
|
import { INSTALL_ROOT_PURPOSE, INSTALL_USAGE, parseInstallCommand, renderInstallHelp, } from "./commands/install.js";
|
|
4
|
-
import { parseContractCommand } from "./commands/contract-grammar.js";
|
|
4
|
+
import { parseContractCommand, refuse } from "./commands/contract-grammar.js";
|
|
5
5
|
import { CONTRACT_COMMAND_SPECS, renderContractHelp as renderContractHelpForOwner, } from "./commands/contract-help.js";
|
|
6
6
|
import { renderOpaqueBlock, renderTextBlock } from "./render/terminal.js";
|
|
7
7
|
import { scanArgs } from "./scan.js";
|
|
@@ -166,9 +166,6 @@ export function assertExplicitRepoUse(command, repo) {
|
|
|
166
166
|
if (repo !== undefined && !commandRepoPolicy(command).acceptsExplicit)
|
|
167
167
|
refuseUnusedRepo(command);
|
|
168
168
|
}
|
|
169
|
-
function refuse(command, message) {
|
|
170
|
-
throw new CliUsageError(message, commandGuide(command, CONTRACT_COMMAND_SPECS[command].usage));
|
|
171
|
-
}
|
|
172
169
|
/** The contract surfaces' one scan spec: `-` carries the edge's own stdin input. */
|
|
173
170
|
function contractScanSpec(command, spec) {
|
|
174
171
|
return {
|
|
@@ -106,13 +106,6 @@ export type InputWaitStream = Readonly<{
|
|
|
106
106
|
conclude: (result: InputWaitConclusion) => string;
|
|
107
107
|
opened: () => boolean;
|
|
108
108
|
}>;
|
|
109
|
-
/**
|
|
110
|
-
* The call-observation projection of one input wait: the same admitted/observe/frame/flush/opened
|
|
111
|
-
* lifetime with the closing judgment from the native compact spawn result.
|
|
112
|
-
*/
|
|
113
|
-
export type CallObservationStream = Readonly<Omit<InputWaitStream, "conclude"> & {
|
|
114
|
-
conclude: (result: SpawnResult) => string;
|
|
115
|
-
}>;
|
|
116
109
|
/**
|
|
117
110
|
* Live view over one observing input: its identity frame opens once, selected
|
|
118
111
|
* activity follows, and the input-bound outcome supplies the closing row.
|
|
@@ -122,11 +115,6 @@ export declare function inputWaitStream(context: TextRenderContext, head: () =>
|
|
|
122
115
|
now?: () => number | undefined;
|
|
123
116
|
answerSeparator?: true;
|
|
124
117
|
}>): InputWaitStream;
|
|
125
|
-
export declare function callObservationStream(context: TextRenderContext, head: ObservedCallHead, options?: Readonly<{
|
|
126
|
-
now?: () => number | undefined;
|
|
127
|
-
admittedAt?: string;
|
|
128
|
-
prompt?: string;
|
|
129
|
-
}>): CallObservationStream;
|
|
130
118
|
type SnapshotView = AkumaObservation;
|
|
131
119
|
type SnapshotCoreOptions = Readonly<{
|
|
132
120
|
alias?: string;
|
|
@@ -139,9 +127,9 @@ export declare function killResultText(id: string, evidence: KillEvidence, alias
|
|
|
139
127
|
type AkumaPresentation = Readonly<{
|
|
140
128
|
alias?: string;
|
|
141
129
|
}>;
|
|
142
|
-
|
|
143
|
-
export declare function
|
|
144
|
-
export declare function
|
|
130
|
+
/** The settlement instant a settled observation carries; an open observation has none. */
|
|
131
|
+
export declare function observationCompletedAt(observation: AkumaAskObservation): string | undefined;
|
|
132
|
+
export declare function askRawAnswer(result: AkumaAskResult): string | undefined;
|
|
145
133
|
export declare function historyRawAnswer(result: AkumaHistoryResult, historyId: string | undefined): string | undefined;
|
|
146
134
|
/**
|
|
147
135
|
* One wait's final text: one compact line per observed member, then one failure line per member
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defaultWaitComplete } from "../../akuma/akuma-observe.js";
|
|
2
2
|
import { parseExactHistorySelector } from "../../akuma/identity.js";
|
|
3
|
-
import { renderDiffstat, toolRepr } from "../../akuma/status-projection.js";
|
|
3
|
+
import { permissionText, renderDiffstat, toolRepr, } from "../../akuma/status-projection.js";
|
|
4
4
|
import { ageText, DEFAULT_CLI_COLUMNS, diagnosticLines, displayColumns, padToDisplay, renderBoundedPayload, safeText, truncateDisplayText, } from "./terminal.js";
|
|
5
5
|
export const DEFAULT_CONTEXT = { columns: DEFAULT_CLI_COLUMNS, color: false };
|
|
6
6
|
/** The action family's fixed 3-cell state margin and minimum verb cell. */
|
|
@@ -86,6 +86,8 @@ function rowText(row) {
|
|
|
86
86
|
lines: row.kind === "said" || row.kind === "thought" ? 2 : row.kind === "tell" || row.kind === "call" ? 1 : 2,
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
if (row.kind === "permission")
|
|
90
|
+
return { text: permissionText(row), lines: 2 };
|
|
89
91
|
if (row.kind === "outcome")
|
|
90
92
|
return row.outcome.kind === "answered"
|
|
91
93
|
? { text: row.outcome.answer, lines: 3 }
|
|
@@ -118,6 +120,8 @@ function rowPrefix(row, tool, columns, view) {
|
|
|
118
120
|
}
|
|
119
121
|
if (row.kind === "note")
|
|
120
122
|
return actionPrefix(ACTION_MARGIN, "note", columns);
|
|
123
|
+
if (row.kind === "permission")
|
|
124
|
+
return actionPrefix(ACTION_MARGIN, "approval", columns);
|
|
121
125
|
if (row.kind === "outcome")
|
|
122
126
|
return {
|
|
123
127
|
first: row.outcome.kind === "answered" ? TOP_ANSWER : row.outcome.kind === "canceled" ? "○ " : TOP_FAILURE,
|
|
@@ -222,9 +226,6 @@ function sameTool(left, right) {
|
|
|
222
226
|
function settledRows(activity) {
|
|
223
227
|
return activity.rows.filter((row) => isSettledStreamRow(row) && !inFlightSay(activity, row));
|
|
224
228
|
}
|
|
225
|
-
function isBoundedStreamTool(row) {
|
|
226
|
-
return row.kind === "tool";
|
|
227
|
-
}
|
|
228
229
|
function rememberPendingTells(state, activity) {
|
|
229
230
|
for (const row of activity.rows)
|
|
230
231
|
if (row.kind === "tell" &&
|
|
@@ -316,7 +317,7 @@ function observeActivitySnapshot(state, activity) {
|
|
|
316
317
|
continue;
|
|
317
318
|
// A failed tool is evidence, not routine progress, so it always prints and spends no budget.
|
|
318
319
|
const failed = row.kind === "tool" && typeof row.state === "object" && row.state.status === "error";
|
|
319
|
-
if (
|
|
320
|
+
if (row.kind === "tool" && !failed) {
|
|
320
321
|
if (state.checkpointTools >= TOOL_BUDGET) {
|
|
321
322
|
state.omitted += 1;
|
|
322
323
|
continue;
|
|
@@ -550,50 +551,6 @@ export function inputWaitStream(context, head, options) {
|
|
|
550
551
|
};
|
|
551
552
|
return { admitted: admit, observe, frame, flush, conclude, opened: () => opened };
|
|
552
553
|
}
|
|
553
|
-
export function callObservationStream(context, head, options = {}) {
|
|
554
|
-
const stream = inputWaitStream(context, () => head, {
|
|
555
|
-
cursor: "empty",
|
|
556
|
-
answerSeparator: true,
|
|
557
|
-
...(options.now === undefined ? {} : { now: options.now }),
|
|
558
|
-
});
|
|
559
|
-
stream.admitted({ ...(options.admittedAt === undefined ? {} : { at: options.admittedAt }), rows: [] });
|
|
560
|
-
const settledTells = new Set();
|
|
561
|
-
return {
|
|
562
|
-
...stream,
|
|
563
|
-
observe: (observation) => {
|
|
564
|
-
for (const row of observation.rows)
|
|
565
|
-
if (row.kind === "tell" && row.state === "told")
|
|
566
|
-
settledTells.add(row.tellId);
|
|
567
|
-
return stream.observe(observation);
|
|
568
|
-
},
|
|
569
|
-
conclude: (result) => {
|
|
570
|
-
const failures = result.kind === "failed" ? callFailureLines(result.failures, context) : [];
|
|
571
|
-
const controls = [
|
|
572
|
-
...(result.tellId === undefined || callRawAnswer(result, false) !== undefined
|
|
573
|
-
? []
|
|
574
|
-
: [`input ${result.tellId}`]),
|
|
575
|
-
...tellControlLines(result.wake === undefined ? {} : { wake: result.wake }, context),
|
|
576
|
-
];
|
|
577
|
-
if (result.input !== undefined)
|
|
578
|
-
return [
|
|
579
|
-
stream.conclude({ kind: "observed", observation: result.input }),
|
|
580
|
-
...subordinateLines([...failures, ...controls]),
|
|
581
|
-
].join("\n");
|
|
582
|
-
if (result.kind !== "failed")
|
|
583
|
-
return "";
|
|
584
|
-
return stream.conclude({
|
|
585
|
-
kind: "failed",
|
|
586
|
-
evidence: [
|
|
587
|
-
...(result.tellId === undefined || settledTells.has(result.tellId) || options.prompt === undefined
|
|
588
|
-
? []
|
|
589
|
-
: [tellAdmissionRow(options.prompt, context, result.wake)]),
|
|
590
|
-
...failures,
|
|
591
|
-
...controls,
|
|
592
|
-
],
|
|
593
|
-
});
|
|
594
|
-
},
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
554
|
function renderReportedChangeLines(view) {
|
|
598
555
|
const changes = view.changes ?? [];
|
|
599
556
|
if (changes.length === 0 && view.moreChanges !== true && view.outsideChanges === undefined)
|
|
@@ -628,13 +585,16 @@ export function currentWorkLines(work, context) {
|
|
|
628
585
|
}
|
|
629
586
|
function snapshotCore(view, context, options) {
|
|
630
587
|
const activity = currentWorkLines(view.work, context);
|
|
588
|
+
// A source later than the observation reads as the whole word `now`, so the surface only appends
|
|
589
|
+
// a unit suffix when the age actually names a unit.
|
|
590
|
+
const activityAge = view.lastActivityAt === undefined
|
|
591
|
+
? undefined
|
|
592
|
+
: ageText(view.lastActivityAt, new Date(context.now ?? Date.now()).toISOString());
|
|
631
593
|
const contextFacts = [
|
|
632
594
|
safeText(view.cwd),
|
|
633
|
-
...(
|
|
595
|
+
...(activityAge === undefined
|
|
634
596
|
? []
|
|
635
|
-
: [
|
|
636
|
-
`${view.life} · last activity ${ageText(view.lastActivityAt, new Date(context.now ?? Date.now()).toISOString())} ago`,
|
|
637
|
-
]),
|
|
597
|
+
: [`${view.life} · last activity ${activityAge === "now" ? activityAge : `${activityAge} ago`}`]),
|
|
638
598
|
];
|
|
639
599
|
const facts = [
|
|
640
600
|
...contractFacts(view.contract ?? { kind: "none" }, context.columns - SUBORDINATE_INDENT.length),
|
|
@@ -679,29 +639,15 @@ export function killResultText(id, evidence, alias) {
|
|
|
679
639
|
evidence: label.evidence,
|
|
680
640
|
}).join("\n");
|
|
681
641
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
return result;
|
|
642
|
+
/** The settlement instant a settled observation carries; an open observation has none. */
|
|
643
|
+
export function observationCompletedAt(observation) {
|
|
644
|
+
return observation.kind === "answered" || observation.kind === "failed" || observation.kind === "invalid-output"
|
|
645
|
+
? observation.completedAt
|
|
646
|
+
: undefined;
|
|
688
647
|
}
|
|
689
648
|
export function askRawAnswer(result) {
|
|
690
|
-
if (result.kind === "admitted" || (result.kind === "failed" && "failures" in result))
|
|
691
|
-
return result.input?.kind === "answered" ? result.input.answer : undefined;
|
|
692
649
|
return result.kind === "answered" ? JSON.stringify(result.answer) : undefined;
|
|
693
650
|
}
|
|
694
|
-
export function callRawAnswer(result, streamed) {
|
|
695
|
-
if (result.input?.kind !== "answered")
|
|
696
|
-
return streamed ? "" : undefined;
|
|
697
|
-
if (!streamed &&
|
|
698
|
-
(result.kind === "failed" ||
|
|
699
|
-
result.wake !== undefined ||
|
|
700
|
-
result.alias !== undefined ||
|
|
701
|
-
result.dispatchWarning !== undefined))
|
|
702
|
-
return undefined;
|
|
703
|
-
return result.input.answer;
|
|
704
|
-
}
|
|
705
651
|
export function historyRawAnswer(result, historyId) {
|
|
706
652
|
if (historyId === undefined)
|
|
707
653
|
return undefined;
|
|
@@ -722,7 +668,7 @@ export function historyRawAnswer(result, historyId) {
|
|
|
722
668
|
return `${prefix}${tool.label} ${tool.text}${tool.suffix}${tool.diagnostic === "" ? "" : ` · ${tool.diagnostic}`}`;
|
|
723
669
|
}
|
|
724
670
|
const kind = row.kind === "tell" && row.state === "pending" ? "pending-tell" : row.kind;
|
|
725
|
-
return `${kind}: ${row.text}`;
|
|
671
|
+
return `${kind}: ${rowText(row).text}`;
|
|
726
672
|
}
|
|
727
673
|
if (result.kind === "akuma-report")
|
|
728
674
|
return result.text;
|