@astrosheep/keiyaku 4.6.31 → 4.6.32
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 +34 -17
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/plugins/pi/README.md +16 -18
- package/build/plugins/pi/akuma-tools.ts +31 -38
- package/build/plugins/pi/keiyaku.ts +15 -4
- package/build/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/src/akuma/akuma-call.d.ts +3 -5
- package/build/src/akuma/akuma-call.js +7 -10
- package/build/src/akuma/akuma-errors.d.ts +7 -4
- package/build/src/akuma/akuma-errors.js +16 -12
- package/build/src/akuma/akuma-instance.d.ts +39 -303
- package/build/src/akuma/akuma-instance.js +48 -48
- package/build/src/akuma/akuma-observe.d.ts +5 -4
- package/build/src/akuma/akuma-observe.js +1 -7
- package/build/src/akuma/akuma-owner.d.ts +14 -6
- package/build/src/akuma/akuma-owner.js +33 -27
- package/build/src/akuma/akuma-selection-execution.d.ts +22 -19
- package/build/src/akuma/akuma-selection-execution.js +71 -124
- package/build/src/akuma/akuma-wait.d.ts +3 -3
- package/build/src/akuma/akuma.d.ts +47 -384
- package/build/src/akuma/akuma.js +8 -58
- package/build/src/akuma/archetype.d.ts +16 -19
- package/build/src/akuma/archetype.js +48 -49
- package/build/src/akuma/body.js +31 -26
- package/build/src/akuma/call-initial-tell.d.ts +4 -1
- package/build/src/akuma/call-initial-tell.js +9 -1
- package/build/src/akuma/call-input.d.ts +8 -1
- package/build/src/akuma/call-input.js +27 -18
- package/build/src/akuma/caller.js +2 -1
- package/build/src/akuma/detached-body.js +1 -1
- package/build/src/akuma/heart/facts.d.ts +5 -4
- package/build/src/akuma/heart/facts.js +5 -5
- package/build/src/akuma/heart/soul.js +20 -4
- package/build/src/akuma/identity.d.ts +1 -1
- package/build/src/akuma/identity.js +9 -4
- package/build/src/akuma/index.d.ts +6 -7
- package/build/src/akuma/index.js +2 -3
- package/build/src/akuma/projection.d.ts +3 -0
- package/build/src/akuma/provider-recipe.js +3 -2
- package/build/src/akuma/providers/acp/config.js +11 -10
- package/build/src/akuma/providers/acp/index.js +2 -1
- package/build/src/akuma/providers/codex-app-server/index.js +7 -1
- package/build/src/akuma/providers/grok-build/index.js +2 -1
- package/build/src/akuma/providers/index.d.ts +0 -1
- package/build/src/akuma/providers/index.js +0 -8
- package/build/src/akuma/providers/paseo/index.js +7 -4
- package/build/src/akuma/providers/pi/index.js +4 -3
- package/build/src/akuma/publication.d.ts +1 -2
- package/build/src/akuma/publication.js +16 -14
- package/build/src/akuma/schema.d.ts +3 -49
- package/build/src/akuma/schema.js +6 -147
- package/build/src/akuma/selection-observation.d.ts +281 -240
- package/build/src/akuma/selection-observation.js +122 -68
- package/build/src/akuma/status-projection.d.ts +49 -285
- package/build/src/akuma/status-projection.js +178 -138
- package/build/src/body/amend.js +2 -1
- package/build/src/body/arc.js +3 -2
- package/build/src/body/criteria.js +4 -3
- package/build/src/body/decode.js +2 -1
- package/build/src/body/envelope.js +2 -1
- package/build/src/body/region.d.ts +1 -3
- package/build/src/body/region.js +3 -8
- package/build/src/body-host.d.ts +4 -11
- package/build/src/body-host.js +5 -4
- package/build/src/bounded-list.js +2 -1
- package/build/src/cli/commands/akuma-grammar.d.ts +109 -66
- package/build/src/cli/commands/akuma-grammar.js +75 -95
- package/build/src/cli/commands/akuma.d.ts +8 -3
- package/build/src/cli/commands/akuma.js +63 -122
- package/build/src/cli/commands/contract-grammar.d.ts +3 -135
- package/build/src/cli/commands/contract-grammar.js +125 -218
- package/build/src/cli/commands/contract-help.d.ts +24 -21
- package/build/src/cli/commands/contract-help.js +43 -35
- package/build/src/cli/commands/contract.d.ts +6 -18
- package/build/src/cli/commands/contract.js +65 -272
- package/build/src/cli/commands/debt-grammar.d.ts +2 -4
- package/build/src/cli/commands/debt-grammar.js +22 -190
- package/build/src/cli/commands/debt.js +10 -87
- package/build/src/cli/commands/report.d.ts +2 -4
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/main.js +9 -3
- package/build/src/cli/parse.d.ts +80 -3
- package/build/src/cli/parse.js +76 -16
- package/build/src/cli/render/akuma-activity.d.ts +19 -24
- package/build/src/cli/render/akuma-activity.js +164 -259
- package/build/src/cli/render/akuma.d.ts +3 -3
- package/build/src/cli/render/akuma.js +36 -43
- package/build/src/cli/render/catalog.d.ts +2 -5
- package/build/src/cli/render/catalog.js +2 -33
- package/build/src/cli/render/contract-history.js +1 -2
- package/build/src/cli/render/contract-observation.d.ts +0 -7
- package/build/src/cli/render/contract-observation.js +0 -3
- package/build/src/cli/render/contract.d.ts +7 -9
- package/build/src/cli/render/contract.js +35 -64
- package/build/src/cli/render/debt.d.ts +3 -11
- package/build/src/cli/render/debt.js +17 -88
- package/build/src/cli/render/delivery-preview.js +4 -4
- package/build/src/cli/render/kanshi-akuma.d.ts +5 -3
- package/build/src/cli/render/kanshi-akuma.js +22 -18
- package/build/src/cli/render/kanshi.d.ts +1 -3
- package/build/src/cli/render/kanshi.js +16 -39
- package/build/src/cli/render/receipt.d.ts +21 -12
- package/build/src/cli/render/receipt.js +49 -44
- package/build/src/cli/render/refusal.d.ts +4 -3
- package/build/src/cli/render/refusal.js +15 -17
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/terminal.d.ts +9 -8
- package/build/src/cli/render/terminal.js +48 -32
- package/build/src/cli/render/verbs.d.ts +3 -1
- package/build/src/cli/render/verbs.js +74 -116
- package/build/src/cli/runtime.js +66 -65
- package/build/src/cli/streams.d.ts +2 -9
- package/build/src/cli/streams.js +8 -1
- package/build/src/cli/usage.d.ts +2 -1
- package/build/src/cli/usage.js +3 -2
- package/build/src/contract-worktree.js +2 -10
- package/build/src/core/facts/codec.js +9 -23
- package/build/src/core/facts/errors.d.ts +2 -1
- package/build/src/core/facts/errors.js +3 -3
- package/build/src/core/facts/types.d.ts +2 -13
- package/build/src/core/facts/types.js +1 -6
- package/build/src/core/verbs/abandon.d.ts +1 -2
- package/build/src/core/verbs/amend.d.ts +1 -2
- package/build/src/core/verbs/arc.d.ts +1 -2
- package/build/src/core/verbs/attestation.d.ts +1 -2
- package/build/src/core/verbs/bind.d.ts +1 -2
- package/build/src/core/verbs/deliver.d.ts +1 -2
- package/build/src/core/verbs/placement.d.ts +1 -2
- package/build/src/core/verbs/reintegrate.d.ts +1 -2
- package/build/src/debt/board.d.ts +14 -94
- package/build/src/debt/board.js +25 -160
- package/build/src/debt/catalog.d.ts +0 -2
- package/build/src/debt/catalog.js +1 -22
- package/build/src/debt/document.d.ts +8 -11
- package/build/src/debt/document.js +19 -62
- package/build/src/debt/identity.d.ts +2 -14
- package/build/src/debt/identity.js +19 -49
- package/build/src/debt/index.d.ts +81 -219
- package/build/src/debt/index.js +61 -110
- package/build/src/debt/input.d.ts +19 -5
- package/build/src/debt/input.js +51 -177
- package/build/src/debt/lifecycle-operations.d.ts +1 -3
- package/build/src/debt/lifecycle-operations.js +1 -73
- package/build/src/debt/operation-types.d.ts +24 -128
- package/build/src/debt/operation-types.js +6 -62
- package/build/src/debt/operations.d.ts +8 -17
- package/build/src/debt/operations.js +58 -154
- package/build/src/debt/store.d.ts +0 -2
- package/build/src/debt/store.js +32 -87
- package/build/src/errors.d.ts +28 -0
- package/build/src/errors.js +26 -0
- package/build/src/git/hooks.d.ts +1 -1
- package/build/src/git/observe.d.ts +3 -0
- package/build/src/git/observe.js +19 -5
- package/build/src/git/reconcile.d.ts +3 -16
- package/build/src/git/reconcile.js +0 -18
- package/build/src/git/repository.d.ts +2 -1
- package/build/src/git/repository.js +3 -3
- package/build/src/git/target-placement.d.ts +4 -4
- package/build/src/git/target.d.ts +2 -2
- package/build/src/git/tender.d.ts +1 -2
- package/build/src/git/tender.js +5 -12
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/identity/coordinates.js +3 -2
- package/build/src/identity/normalize.js +2 -1
- package/build/src/identity/selector.js +4 -3
- package/build/src/index.d.ts +34 -57
- package/build/src/index.js +11 -36
- package/build/src/kanshi/counts.d.ts +3 -8
- package/build/src/kanshi/counts.js +6 -14
- package/build/src/kanshi/index.d.ts +22 -7
- package/build/src/kanshi/index.js +30 -4
- package/build/src/kanshi/read.d.ts +81 -270
- package/build/src/kanshi/read.js +39 -199
- package/build/src/kanshi/report.d.ts +340 -1619
- package/build/src/kanshi/report.js +19 -31
- package/build/src/library/address.d.ts +11 -11
- package/build/src/library/address.js +34 -27
- package/build/src/library/akuma-creation.d.ts +210 -79
- package/build/src/library/akuma-creation.js +201 -242
- package/build/src/library/akumas.d.ts +24 -5
- package/build/src/library/akumas.js +96 -29
- package/build/src/library/bind.d.ts +7 -10
- package/build/src/library/bind.js +2 -8
- package/build/src/library/continuation.d.ts +141 -231
- package/build/src/library/continuation.js +22 -31
- package/build/src/library/contract-address.d.ts +6 -9
- package/build/src/library/contract-address.js +11 -16
- package/build/src/library/contract-composition.d.ts +2 -3
- package/build/src/library/contract-composition.js +12 -19
- package/build/src/library/contract-creation.js +33 -34
- package/build/src/library/contract-outcomes.d.ts +1278 -806
- package/build/src/library/contract-outcomes.js +11 -37
- package/build/src/library/contract-settings.d.ts +1 -2
- package/build/src/library/contract-settings.js +5 -7
- package/build/src/library/contract-types.d.ts +42 -67
- package/build/src/library/contract-types.js +15 -56
- package/build/src/library/contract-wait.d.ts +40 -3
- package/build/src/library/contract-wait.js +28 -21
- package/build/src/library/delivery.d.ts +366 -389
- package/build/src/library/delivery.js +5 -25
- package/build/src/library/input.d.ts +31 -5
- package/build/src/library/input.js +40 -40
- package/build/src/library/invocation.d.ts +13 -11
- package/build/src/library/invocation.js +69 -58
- package/build/src/library/kei.d.ts +16 -8
- package/build/src/library/kei.js +459 -19
- package/build/src/library/keiyaku-attribution.d.ts +0 -8
- package/build/src/library/keiyaku-attribution.js +0 -11
- package/build/src/library/keiyaku-classify.d.ts +2 -2
- package/build/src/library/keiyaku-classify.js +40 -59
- package/build/src/library/keiyaku-coordinates.d.ts +3 -8
- package/build/src/library/keiyaku-coordinates.js +6 -26
- package/build/src/library/keiyaku-debt.d.ts +21 -93
- package/build/src/library/keiyaku-debt.js +8 -157
- package/build/src/library/keiyaku-identity.js +5 -4
- package/build/src/library/keiyaku-verbs.d.ts +4004 -3885
- package/build/src/library/keiyaku-verbs.js +309 -271
- package/build/src/library/keiyaku.d.ts +30 -860
- package/build/src/library/keiyaku.js +169 -256
- package/build/src/library/nuke.d.ts +4 -2
- package/build/src/library/nuke.js +5 -1
- package/build/src/library/outcome.d.ts +424 -307
- package/build/src/library/outcome.js +167 -362
- package/build/src/library/reconcile.d.ts +331 -143
- package/build/src/library/reconcile.js +38 -72
- package/build/src/library/refusal.d.ts +20 -28
- package/build/src/library/refusal.js +1 -11
- package/build/src/library/repo.js +4 -3
- package/build/src/library/selection.d.ts +32 -21
- package/build/src/library/selection.js +63 -87
- package/build/src/mcp/adapter.d.ts +6 -0
- package/build/src/mcp/adapter.js +177 -42
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +12 -7
- package/build/src/mcp/output.d.ts +385 -0
- package/build/src/mcp/output.js +193 -0
- package/build/src/plugin/public.d.ts +4 -0
- package/build/src/plugin/runtime.d.ts +1 -1
- package/build/src/plugin/runtime.js +2 -2
- package/build/src/protocol/amend.d.ts +1 -1
- package/build/src/protocol/amend.js +2 -2
- package/build/src/protocol/bind.d.ts +5 -7
- package/build/src/protocol/bind.js +3 -3
- package/build/src/protocol/completion.d.ts +158 -195
- package/build/src/protocol/completion.js +55 -19
- package/build/src/protocol/deliver.d.ts +11 -6
- package/build/src/protocol/deliver.js +30 -30
- package/build/src/protocol/delivery-preview.d.ts +13 -11
- package/build/src/protocol/delivery-preview.js +2 -2
- package/build/src/protocol/execution-observation.d.ts +5 -13
- package/build/src/protocol/intent.d.ts +6 -9
- package/build/src/protocol/intent.js +18 -31
- package/build/src/protocol/operations.d.ts +48 -53
- package/build/src/protocol/operations.js +16 -25
- package/build/src/protocol/outcome.d.ts +3 -1
- package/build/src/protocol/placement.d.ts +1 -2
- package/build/src/protocol/placement.js +1 -1
- package/build/src/protocol/progress.d.ts +1 -0
- package/build/src/protocol/read/status.d.ts +29 -112
- package/build/src/protocol/read/status.js +52 -78
- package/build/src/protocol/reintegrate.d.ts +1 -2
- package/build/src/protocol/reintegrate.js +0 -1
- package/build/src/protocol/result-leaves.d.ts +11 -32
- package/build/src/protocol/result-leaves.js +18 -57
- package/build/src/protocol/result-reasons.d.ts +6 -6
- package/build/src/protocol/review.js +0 -1
- package/build/src/protocol/verify.d.ts +192 -146
- package/build/src/protocol/verify.js +60 -47
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +8 -9
- package/build/src/settings.js +16 -13
- package/build/src/settlement/holder.js +2 -2
- package/build/src/settlement/settle.d.ts +0 -6
- package/build/src/settlement/settle.js +0 -4
- package/build/src/verification/declaration.d.ts +3 -6
- package/build/src/verification/declaration.js +3 -5
- package/build/src/verification/observation.d.ts +2 -2
- package/build/src/world.d.ts +3 -2
- package/build/src/world.js +5 -6
- package/package.json +1 -1
- package/plugins/paseo/plugin/index.server.ts +1 -1
- package/plugins/paseo/plugin/server/attach.ts +74 -67
- package/plugins/paseo/plugin/server/keiyaku.ts +80 -14
- package/plugins/paseo/plugin/server/message.ts +2 -1
- package/plugins/paseo/plugin/server/mirror-identity.ts +6 -4
- package/plugins/paseo/plugin/server/sdk.ts +9 -11
- package/plugins/paseo/plugin/server/transport.ts +24 -1
- package/plugins/pi/README.md +16 -18
- package/plugins/pi/akuma-tools.ts +31 -38
- package/plugins/pi/keiyaku.ts +15 -4
- package/skills/keiyaku-akuma/SKILL.md +16 -11
- package/skills/keiyaku-babysit/SKILL.md +5 -3
- package/skills/keiyaku-bind/SKILL.md +4 -3
- package/skills/keiyaku-debt/SKILL.md +17 -17
- package/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/src/akuma/providers/codex-app-server/configuration.d.ts +0 -5
- package/build/src/akuma/providers/codex-app-server/configuration.js +0 -72
- package/build/src/cli/commands/debt-query.d.ts +0 -5
- package/build/src/cli/commands/debt-query.js +0 -194
- package/build/src/cli/render/akuma-tool-command.d.ts +0 -6
- package/build/src/cli/render/akuma-tool-command.js +0 -143
- package/build/src/cli/render/akuma-tool.d.ts +0 -29
- package/build/src/cli/render/akuma-tool.js +0 -225
- package/build/src/debt/context.d.ts +0 -28
- package/build/src/debt/context.js +0 -102
- package/build/src/debt/created-observation.d.ts +0 -26
- package/build/src/debt/created-observation.js +0 -38
- package/build/src/debt/query.d.ts +0 -80
- package/build/src/debt/query.js +0 -283
- package/build/src/library/contract-execution.d.ts +0 -28
- package/build/src/library/contract-execution.js +0 -506
- package/build/src/library/keiyaku-policy.d.ts +0 -27
- package/build/src/library/keiyaku-policy.js +0 -44
- package/build/src/library/keiyaku-status.d.ts +0 -1487
- package/build/src/library/keiyaku-status.js +0 -92
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { actionReceipt, callObservationStream, inputWaitStream, killResultText, subordinateLines, tellAdmissionRow, tellControlLines, tellPayloadLines, } from "./akuma-activity.js";
|
|
1
|
+
import { actionReceipt, callObservationStream, inputWaitStream, killResultText, subordinateLines, tellAdmissionRow, callFailureLines, askRawAnswer, inputObservation, tellControlLines, tellPayloadLines, } from "./akuma-activity.js";
|
|
2
2
|
import { safeText } from "./terminal.js";
|
|
3
3
|
export function askProgressStream(akuma, alias, context, now) {
|
|
4
4
|
let target = akuma;
|
|
@@ -19,10 +19,16 @@ export function askProgressStream(akuma, alias, context, now) {
|
|
|
19
19
|
observe: (observation) => stream.observe(observation),
|
|
20
20
|
frame: () => stream.frame(),
|
|
21
21
|
flush: () => stream.flush(),
|
|
22
|
-
conclude: (result) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
conclude: (result) => {
|
|
23
|
+
const controls = tellControlLines(result, context);
|
|
24
|
+
return [
|
|
25
|
+
stream.conclude({ kind: "observed", observation: inputObservation(result) }),
|
|
26
|
+
...subordinateLines([
|
|
27
|
+
...(controls.length === 0 && askRawAnswer(result) !== undefined ? [] : [`input ${result.tellId}`]),
|
|
28
|
+
...controls,
|
|
29
|
+
]),
|
|
30
|
+
];
|
|
31
|
+
},
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
34
|
export function waitedTellProgress(result, input, context) {
|
|
@@ -35,35 +41,32 @@ export function waitedTellProgress(result, input, context) {
|
|
|
35
41
|
const admitted = stream.admitted({ rows: [tellAdmissionRow(input.prompt, context, result.wake)] });
|
|
36
42
|
return [
|
|
37
43
|
...admitted,
|
|
38
|
-
stream.conclude({
|
|
39
|
-
|
|
44
|
+
stream.conclude({
|
|
45
|
+
kind: "observed",
|
|
46
|
+
observation: inputObservation(result),
|
|
47
|
+
}),
|
|
48
|
+
...subordinateLines([`input ${result.tellId}`, ...tellControlLines(result, context)]),
|
|
49
|
+
...(askRawAnswer(result) === undefined ? [] : [askRawAnswer(result)]),
|
|
50
|
+
...(result.kind === "invalid-output" ? ["invalid answer", result.answer] : []),
|
|
40
51
|
].join("\n");
|
|
41
52
|
}
|
|
42
|
-
function dispatchFailureLine(failure) {
|
|
43
|
-
return failure.kind === "conflict"
|
|
44
|
-
? `! dispatch failed conflict ${failure.currentContractId}`
|
|
45
|
-
: `! dispatch failed ${failure.kind} ${safeText(failure.diagnostic)}`;
|
|
46
|
-
}
|
|
47
53
|
/** The shared frame consumes owner evidence and explicit invocation context. */
|
|
48
54
|
export function callObservationHead(input, presentation = {}) {
|
|
49
|
-
const
|
|
55
|
+
const failures = "failures" in input ? (input.failures ?? []) : [];
|
|
56
|
+
const alias = failures.some((failure) => failure.stage === "dispatch" || failure.stage === "alias")
|
|
50
57
|
? undefined
|
|
51
58
|
: "aliasName" in input
|
|
52
59
|
? input.aliasName
|
|
53
60
|
: presentation.alias;
|
|
54
|
-
const contractId =
|
|
61
|
+
const contractId = failures.some((failure) => failure.stage === "dispatch")
|
|
55
62
|
? undefined
|
|
56
63
|
: "contractId" in input
|
|
57
64
|
? input.contractId
|
|
58
65
|
: presentation.contractId;
|
|
59
66
|
const cwd = "cwd" in input ? input.cwd : presentation.cwd;
|
|
60
67
|
const facts = [
|
|
61
|
-
...(input.dispatchFailure === undefined ? [] : [dispatchFailureLine(input.dispatchFailure)]),
|
|
62
68
|
...(input.dispatchWarning === undefined ? [] : [`dispatch lag ${safeText(input.dispatchWarning)}`]),
|
|
63
|
-
...(input.alias
|
|
64
|
-
? [`! alias failed ${input.alias.kind} ${safeText(input.alias.diagnostic)}`]
|
|
65
|
-
: []),
|
|
66
|
-
...(input.alias?.kind === "moved" ? [`alias moved · previous ${input.alias.previousAkumaId}`] : []),
|
|
69
|
+
...(input.alias === undefined ? [] : [`alias moved · previous ${input.alias.previousAkumaId}`]),
|
|
67
70
|
];
|
|
68
71
|
return {
|
|
69
72
|
id: input.akumaId,
|
|
@@ -79,37 +82,24 @@ function spawnEvidence(result, context, input) {
|
|
|
79
82
|
...(head.contract.kind === "associated" ? [safeText(head.contract.contractId)] : []),
|
|
80
83
|
...(head.cwd === undefined ? [] : [safeText(head.cwd)]),
|
|
81
84
|
...head.facts,
|
|
82
|
-
...tellControlLines(result, context),
|
|
85
|
+
...tellControlLines(result.wake === undefined ? {} : { wake: result.wake }, context),
|
|
86
|
+
...(result.tellId === undefined ? [] : [`input ${result.tellId}`]),
|
|
83
87
|
...(result.tellId === undefined || input.prompt === undefined
|
|
84
88
|
? []
|
|
85
89
|
: tellPayloadLines(input.prompt, context).map((line) => line.trimStart())),
|
|
86
|
-
...(result.
|
|
87
|
-
? []
|
|
88
|
-
: [
|
|
89
|
-
`! ${result.failure.kind} · ${safeText(result.failure.diagnostic)}`,
|
|
90
|
-
...(result.failure.attemptedTellId === undefined
|
|
91
|
-
? []
|
|
92
|
-
: [`attempted input ${safeText(result.failure.attemptedTellId)}`]),
|
|
93
|
-
]),
|
|
90
|
+
...(result.kind === "failed" ? callFailureLines(result.failures, context) : []),
|
|
94
91
|
];
|
|
95
92
|
}
|
|
96
93
|
export function renderCallText(result, streamed, context, input = {}) {
|
|
97
94
|
if (streamed)
|
|
98
95
|
return "";
|
|
99
96
|
const head = callObservationHead(result, input);
|
|
100
|
-
if (result.input !== undefined
|
|
101
|
-
const stream =
|
|
102
|
-
stream.
|
|
103
|
-
return [
|
|
104
|
-
stream.conclude({ kind: "observed", observation: result.input }),
|
|
105
|
-
...subordinateLines(tellControlLines(result, context)),
|
|
106
|
-
].join("\n");
|
|
97
|
+
if (result.input !== undefined) {
|
|
98
|
+
const stream = callObservationStream(context, head, { now: () => context.now });
|
|
99
|
+
return [stream.conclude(result), ...(result.input.kind === "answered" ? [result.input.answer] : [])].join("\n");
|
|
107
100
|
}
|
|
108
|
-
const failed = result.failure !== undefined ||
|
|
109
|
-
result.dispatchFailure !== undefined ||
|
|
110
|
-
(result.alias !== undefined && result.alias.kind !== "moved");
|
|
111
101
|
return actionReceipt({
|
|
112
|
-
mark: failed ? "!" : "✓",
|
|
102
|
+
mark: result.kind === "failed" ? "!" : "✓",
|
|
113
103
|
verb: "spawned",
|
|
114
104
|
id: result.akumaId,
|
|
115
105
|
...(head.alias === undefined ? {} : { alias: head.alias }),
|
|
@@ -132,7 +122,7 @@ export function renderFailedCallObservation(result, context, input = {}) {
|
|
|
132
122
|
}
|
|
133
123
|
export function renderForkText(receipt, input) {
|
|
134
124
|
const parent = receipt.parentAkumaId ?? input.akuma;
|
|
135
|
-
if (receipt.kind !== "forked") {
|
|
125
|
+
if (receipt.kind !== "forked" && receipt.kind !== "failed") {
|
|
136
126
|
const reason = receipt.kind === "unknown-history"
|
|
137
127
|
? `${input.at} has no matching retained answered turn`
|
|
138
128
|
: receipt.kind === "provider-cannot-fork"
|
|
@@ -142,13 +132,16 @@ export function renderForkText(receipt, input) {
|
|
|
142
132
|
return actionReceipt({ mark: "!", verb: "fork", id: parent, evidence: [reason, ...session] }).join("\n");
|
|
143
133
|
}
|
|
144
134
|
return actionReceipt({
|
|
145
|
-
mark: receipt.
|
|
135
|
+
mark: receipt.kind === "forked" ? "✓" : "!",
|
|
146
136
|
verb: "forked",
|
|
147
137
|
id: receipt.childAkumaId,
|
|
148
138
|
evidence: [
|
|
149
139
|
`from ${parent}`,
|
|
150
|
-
...(receipt.
|
|
151
|
-
|
|
140
|
+
...(receipt.kind === "failed"
|
|
141
|
+
? callFailureLines([receipt.failure], { columns: 100, color: false })
|
|
142
|
+
: receipt.dispatchWarning === undefined
|
|
143
|
+
? []
|
|
144
|
+
: [`dispatch lag ${safeText(receipt.dispatchWarning)}`]),
|
|
152
145
|
],
|
|
153
146
|
}).join("\n");
|
|
154
147
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AkumaCaller } from "../../akuma/caller.js";
|
|
3
|
-
import type { ArchetypeCatalog, ContractCatalogue } from "../../index.js";
|
|
4
|
-
export declare function renderAkumaCatalogue(list: AkumaList, akumaName: string | null, caller?: AkumaCaller): string;
|
|
1
|
+
import type { AkumaNameCatalog, ContractCatalogue } from "../../index.js";
|
|
5
2
|
export declare function renderContractCatalogue(list: ContractCatalogue): string;
|
|
6
|
-
export declare function
|
|
3
|
+
export declare function renderAkumaNameCatalogue(list: AkumaNameCatalog): string;
|
|
@@ -1,37 +1,6 @@
|
|
|
1
1
|
import { contractAttentionFacts, progressStrip } from "./contract-observation.js";
|
|
2
2
|
import { ageText, emptyCatalogue, safeText } from "./terminal.js";
|
|
3
|
-
import {
|
|
4
|
-
function relativeAge(source, observedAt) {
|
|
5
|
-
return source === undefined ? null : ageText(source, observedAt);
|
|
6
|
-
}
|
|
7
|
-
function akumaAgeFacts(row, observedAt) {
|
|
8
|
-
const lifeAge = relativeAge("lifeAt" in row ? row.lifeAt : undefined, observedAt);
|
|
9
|
-
const activityAge = relativeAge("lastActivityAt" in row ? row.lastActivityAt : undefined, observedAt);
|
|
10
|
-
return [
|
|
11
|
-
...(lifeAge === null ? [] : [lifeAge]),
|
|
12
|
-
...(activityAge === null || activityAge === lifeAge ? [] : [`activity ${activityAge}`]),
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
function akumaCatalogueRow(row, observedAt, root) {
|
|
16
|
-
const ages = akumaAgeFacts(row, observedAt);
|
|
17
|
-
const aliases = row.aliases === undefined ? "" : ` (${row.aliases.map((alias) => safeText(alias)).join(" ")})`;
|
|
18
|
-
const by = root !== undefined && "parentAkumaId" in row && row.parentAkumaId !== undefined && row.parentAkumaId !== root
|
|
19
|
-
? ` · by ${safeText(row.parentAkumaId)}`
|
|
20
|
-
: "";
|
|
21
|
-
return `${akumaMark(row.life)} ${safeText(row.id)}${aliases} · ${row.life}${ages.length === 0 ? "" : ` · ${ages.join(" · ")}`}${by}`;
|
|
22
|
-
}
|
|
23
|
-
export function renderAkumaCatalogue(list, akumaName, caller) {
|
|
24
|
-
const rows = list.rows ?? [];
|
|
25
|
-
if (rows.length === 0)
|
|
26
|
-
return emptyCatalogue("akuma");
|
|
27
|
-
const root = caller === undefined ? undefined : caller.kind === "akuma" ? caller.akumaId : "external";
|
|
28
|
-
return [
|
|
29
|
-
akumaName === null ? "AKUMA // recent" : `AKUMA // ${safeText(akumaName)}`,
|
|
30
|
-
"",
|
|
31
|
-
...rows.map((row) => akumaCatalogueRow(row, list.observedAt, root)),
|
|
32
|
-
...(list.more === true ? ["…"] : []),
|
|
33
|
-
].join("\n");
|
|
34
|
-
}
|
|
3
|
+
import { contractMark } from "./marks.js";
|
|
35
4
|
function formatAge(source, observedAt) {
|
|
36
5
|
return ageText(source, observedAt, "future");
|
|
37
6
|
}
|
|
@@ -51,7 +20,7 @@ export function renderContractCatalogue(list) {
|
|
|
51
20
|
...(list.more === true ? ["…"] : []),
|
|
52
21
|
].join("\n");
|
|
53
22
|
}
|
|
54
|
-
export function
|
|
23
|
+
export function renderAkumaNameCatalogue(list) {
|
|
55
24
|
const rows = list.rows ?? [];
|
|
56
25
|
if (rows.length === 0)
|
|
57
26
|
return emptyCatalogue("akuma names");
|
|
@@ -116,8 +116,7 @@ function semanticBody(event) {
|
|
|
116
116
|
/** Full mode exposes supplied historical facts, never a current-state reread. */
|
|
117
117
|
function fullEventLines(event) {
|
|
118
118
|
const identity = event.kind === "dispatch" ? event.akumaId : event.id;
|
|
119
|
-
const
|
|
120
|
-
const header = `${event.at} ${event.kind} · ${identity}${actor}`;
|
|
119
|
+
const header = `${event.at} ${event.kind} · ${identity}`;
|
|
121
120
|
const detail = [
|
|
122
121
|
...semanticBody(event),
|
|
123
122
|
...(event.kind === "bind" || event.kind === "amend"
|
|
@@ -17,13 +17,6 @@ export declare function gateGlyph(report: Readonly<{
|
|
|
17
17
|
verdict?: string;
|
|
18
18
|
};
|
|
19
19
|
}>): string;
|
|
20
|
-
export declare function gateFact(report: Readonly<{
|
|
21
|
-
gate: string;
|
|
22
|
-
current: {
|
|
23
|
-
kind: string;
|
|
24
|
-
verdict?: string;
|
|
25
|
-
};
|
|
26
|
-
}>): string;
|
|
27
20
|
export declare function requirementDisplayName(gate: string, requirement: Readonly<{
|
|
28
21
|
requirement?: string | undefined;
|
|
29
22
|
index?: number | undefined;
|
|
@@ -64,9 +64,6 @@ export function gateGlyph(report) {
|
|
|
64
64
|
return "○";
|
|
65
65
|
return report.current.verdict === "satisfied" ? "✓" : "×";
|
|
66
66
|
}
|
|
67
|
-
export function gateFact(report) {
|
|
68
|
-
return `${gateGlyph(report)} ${gateDisplayName(report.gate)}${report.current.kind === "stale" ? " · stale" : ""}`;
|
|
69
|
-
}
|
|
70
67
|
export function requirementDisplayName(gate, requirement) {
|
|
71
68
|
const name = gateDisplayName(gate);
|
|
72
69
|
if (gate === "verified")
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AbandonOutcome, AmendOutcome, ArcOutcome, BindOutcome as NativeBindOutcome, DeliverOutcome, ReviewOutcome, VerifyOutcome, ContractId, InvocationIssue } from "../../index.js";
|
|
2
2
|
import { type TextRenderContext } from "./terminal.js";
|
|
3
|
-
type BindOutcome =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type ReviewOutcome = z.output<typeof reviewOutcomeSchema>;
|
|
9
|
-
type VerifyOutcome = z.output<typeof verifyOutcomeSchema>;
|
|
3
|
+
type BindOutcome = Exclude<NativeBindOutcome, {
|
|
4
|
+
kind: "accepted";
|
|
5
|
+
}> | Omit<Extract<NativeBindOutcome, {
|
|
6
|
+
kind: "accepted";
|
|
7
|
+
}>, "kei">;
|
|
10
8
|
type ContractAnswers = {
|
|
11
9
|
bind: BindOutcome;
|
|
12
10
|
amend: AmendOutcome;
|
|
@@ -41,7 +39,7 @@ type IssuePresentation = Readonly<{
|
|
|
41
39
|
export declare function contractIssueLines(result: ContractReceipt, columns: number, presentation?: IssuePresentation): readonly string[];
|
|
42
40
|
/** The operation and supplied input stay renderer context, never fields manufactured on the native result. */
|
|
43
41
|
export declare function renderAccepted<K extends ContractMutationName>(operation: K, result: AcceptedOf<K>, context?: TextRenderContext, input?: PresentationInput): string;
|
|
44
|
-
export declare function renderRetry(operation: ContractMutationName | "deliver
|
|
42
|
+
export declare function renderRetry(operation: ContractMutationName | "deliver --dry-run", result: Extract<ContractOutcome, {
|
|
45
43
|
kind: "retry";
|
|
46
44
|
}>, context?: TextRenderContext): string;
|
|
47
45
|
export { renderContractHistory } from "./contract-history.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gatesAwaitLines,
|
|
1
|
+
import { deliveryIdentityRows, gatesAwaitLines, targetMovementRows, receiptPayload, receiptRow, recoverySnapshotLines, stopLines, titleLines, verificationCheckLines, outcomeLines, } from "./receipt.js";
|
|
2
2
|
import { abbreviateGitIds, displayGitId } from "./contract-observation.js";
|
|
3
3
|
import { DEFAULT_CLI_COLUMNS, quotedText, renderOpaqueBlock, safeText, tone, } from "./terminal.js";
|
|
4
4
|
function words(kind) {
|
|
@@ -57,24 +57,12 @@ function retainedIssueRows(issue, columns) {
|
|
|
57
57
|
function residualIssueRows(issue, columns) {
|
|
58
58
|
const lines = [];
|
|
59
59
|
switch (issue.kind) {
|
|
60
|
-
case "
|
|
61
|
-
receiptPayload(lines, "cleanup", issue.diagnostic);
|
|
62
|
-
return lines;
|
|
63
|
-
case "verification-cleanup":
|
|
60
|
+
case "diagnostic":
|
|
64
61
|
lines.push(...cleanupResourceRows(issue, columns));
|
|
65
|
-
receiptRow(lines, "
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
lines.push(...cleanupResourceRows(issue, columns));
|
|
70
|
-
if (issue.path === undefined)
|
|
71
|
-
receiptRow(lines, " ", "verification scratch not retained", [], columns);
|
|
72
|
-
else
|
|
73
|
-
receiptRow(lines, " ", "verification scratch kept at", [{ text: issue.path, opaque: true }], columns);
|
|
74
|
-
receiptPayload(lines, "reason", issue.diagnostic);
|
|
75
|
-
return lines;
|
|
76
|
-
case "private-state-seat-close":
|
|
77
|
-
receiptRow(lines, "!", "lag", [{ text: "private-state-seat-close-failed", opaque: true }], columns);
|
|
62
|
+
receiptRow(lines, issue.severity === "required" ? "!" : " ", issue.severity === "required" ? "stopped" : "residue", [
|
|
63
|
+
...(issue.name === undefined ? [] : [{ text: `name ${quotedText(issue.name)}` }]),
|
|
64
|
+
...(issue.path === undefined ? [] : [{ text: issue.path, opaque: true }]),
|
|
65
|
+
], columns);
|
|
78
66
|
receiptPayload(lines, "reason", issue.diagnostic);
|
|
79
67
|
return lines;
|
|
80
68
|
case "execution-stopped":
|
|
@@ -210,60 +198,42 @@ function amend(result, columns, color) {
|
|
|
210
198
|
lines.push(...deviations(result, columns, color), ...contractIssueLines(result, columns, { mode: "receipt" }), ...recoverySnapshotLines(result.recoverySnapshots, columns, result.contractId));
|
|
211
199
|
return lines.join("\n");
|
|
212
200
|
}
|
|
213
|
-
function
|
|
214
|
-
return placement.integration ?? fallback;
|
|
215
|
-
}
|
|
216
|
-
function placedMovementLines(placement, integration, columns) {
|
|
217
|
-
if (placement.target === undefined)
|
|
218
|
-
return [];
|
|
219
|
-
const ids = abbreviateGitIds([placement.predecessor ?? "", integration]);
|
|
220
|
-
const lines = [];
|
|
221
|
-
const movement = placement.predecessor === undefined
|
|
222
|
-
? displayGitId(integration, ids)
|
|
223
|
-
: `${displayGitId(placement.predecessor, ids)}..${displayGitId(integration, ids)}`;
|
|
224
|
-
receiptRow(lines, " ", "target", [{ text: movement }, { text: placement.target, opaque: true }], columns);
|
|
225
|
-
receiptRow(lines, "✓", "accepted", [], columns);
|
|
226
|
-
return lines;
|
|
227
|
-
}
|
|
228
|
-
function continuationLines(continuation, columns) {
|
|
201
|
+
function continuationLines(continuation, columns, surface) {
|
|
229
202
|
if (continuation === undefined)
|
|
230
203
|
return [];
|
|
231
204
|
const lines = [];
|
|
232
205
|
for (const contractId of continuation.claimed ?? [])
|
|
233
206
|
receiptRow(lines, "✓", "dependent", [{ text: "complete" }, { text: contractId, opaque: true }], columns);
|
|
234
|
-
for (const stop of continuation.stopped ?? [])
|
|
235
|
-
|
|
236
|
-
receiptRow(lines, "!", stop.contractId, [{ text: "already terminal" }], columns);
|
|
237
|
-
else if (stop.kind === "physical-lag")
|
|
238
|
-
receiptRow(lines, "!", "dependent", [{ text: stop.contractId, opaque: true }, { text: "physical follow stopped" }], columns);
|
|
239
|
-
else
|
|
240
|
-
lines.push(...stopLines(stop, columns, stop.contractId, stop.contractId));
|
|
241
|
-
}
|
|
207
|
+
for (const { contractId, stop } of continuation.stopped ?? [])
|
|
208
|
+
lines.push(...stopLines(stop, columns, contractId, contractId, surface));
|
|
242
209
|
return lines;
|
|
243
210
|
}
|
|
244
|
-
function completionPlacementLines(result, columns) {
|
|
211
|
+
function completionPlacementLines(result, columns, surface) {
|
|
245
212
|
const placement = result.placement;
|
|
246
213
|
if (placement === undefined)
|
|
247
214
|
return [];
|
|
248
215
|
if (placement.kind !== "placed")
|
|
249
|
-
return
|
|
216
|
+
return stopLines(placement, columns, result.contractId, undefined, surface);
|
|
250
217
|
const fallback = "integration" in result ? result.integration : undefined;
|
|
251
|
-
const integration =
|
|
252
|
-
if (integration === undefined)
|
|
218
|
+
const integration = ("integration" in placement ? placement.integration : undefined) ?? fallback;
|
|
219
|
+
if (integration === undefined || placement.target === undefined)
|
|
253
220
|
return [];
|
|
254
|
-
|
|
221
|
+
const lines = [];
|
|
222
|
+
targetMovementRows(lines, { ...placement, integration }, columns);
|
|
223
|
+
receiptRow(lines, "✓", "accepted", [], columns);
|
|
224
|
+
return lines;
|
|
255
225
|
}
|
|
256
|
-
function trailingPlacementLines(result, columns) {
|
|
226
|
+
function trailingPlacementLines(result, columns, surface) {
|
|
257
227
|
const placement = result.placement;
|
|
258
228
|
return [
|
|
259
|
-
...completionPlacementLines(result, columns),
|
|
260
|
-
...continuationLines(result.continuation, columns),
|
|
229
|
+
...completionPlacementLines(result, columns, surface),
|
|
230
|
+
...continuationLines(result.continuation, columns, surface),
|
|
261
231
|
...recoverySnapshotLines(result.recoverySnapshots, columns, result.contractId),
|
|
262
232
|
...contractIssueLines(result, columns, { mode: "receipt", follow: placement !== undefined }),
|
|
263
233
|
...gatesAwaitLines(placement?.kind === "placed" ? undefined : placement),
|
|
264
234
|
];
|
|
265
235
|
}
|
|
266
|
-
function deliver(result, columns, input) {
|
|
236
|
+
function deliver(result, columns, input, surface) {
|
|
267
237
|
const lines = titleLines("✓", "delivered", result.contractId, columns);
|
|
268
238
|
const placement = result.placement;
|
|
269
239
|
const ids = abbreviateGitIds([
|
|
@@ -272,19 +242,20 @@ function deliver(result, columns, input) {
|
|
|
272
242
|
result.contentId,
|
|
273
243
|
result.previousContentId ?? "",
|
|
274
244
|
placement?.kind === "placed" ? (placement.predecessor ?? "") : "",
|
|
275
|
-
placement?.kind === "placed" ? (
|
|
245
|
+
placement?.kind === "placed" ? (placement.integration ?? result.integration) : "",
|
|
276
246
|
]);
|
|
277
247
|
if (result.admission === "reused")
|
|
278
248
|
receiptRow(lines, " ", "admission", [{ text: "reused" }], columns);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
249
|
+
deliveryIdentityRows(lines, {
|
|
250
|
+
candidate: `${displayGitId(result.candidate, ids)}${placement?.kind === "placed" ? "" : " · kept"}`,
|
|
251
|
+
integration: displayGitId(result.integration, ids),
|
|
252
|
+
contentId: /^0{40}$/u.test(result.contentId) ? undefined : displayGitId(result.contentId, ids),
|
|
253
|
+
}, columns);
|
|
283
254
|
if (result.previousContentId !== undefined)
|
|
284
255
|
receiptRow(lines, " ", "candidate content changed", [{ text: `previous ${displayGitId(result.previousContentId, ids)}`, opaque: true }], columns);
|
|
285
256
|
if (input.message !== undefined && result.admission !== "reused")
|
|
286
257
|
receiptPayload(lines, "note", input.message);
|
|
287
|
-
lines.push(...trailingPlacementLines(result, columns));
|
|
258
|
+
lines.push(...trailingPlacementLines(result, columns, surface));
|
|
288
259
|
return lines.join("\n");
|
|
289
260
|
}
|
|
290
261
|
function worktreeChangeLines(result, columns) {
|
|
@@ -294,16 +265,16 @@ function worktreeChangeLines(result, columns) {
|
|
|
294
265
|
receiptRow(lines, " ", field === "unmergedPaths" ? "unmerged" : field, [{ text: path, opaque: true }], columns);
|
|
295
266
|
return lines;
|
|
296
267
|
}
|
|
297
|
-
function review(result, columns, input) {
|
|
268
|
+
function review(result, columns, input, surface) {
|
|
298
269
|
if (input.verdict === undefined)
|
|
299
270
|
throw new Error("review renderer requires its invocation verdict");
|
|
300
271
|
const lines = titleLines("✓", `review ${input.verdict}`, result.contractId, columns);
|
|
301
|
-
lines.push(...worktreeChangeLines(result, columns), ...trailingPlacementLines(result, columns));
|
|
272
|
+
lines.push(...worktreeChangeLines(result, columns), ...trailingPlacementLines(result, columns, surface));
|
|
302
273
|
return lines.join("\n");
|
|
303
274
|
}
|
|
304
|
-
function verify(result, columns) {
|
|
275
|
+
function verify(result, columns, surface) {
|
|
305
276
|
const lines = titleLines("✓", "verify", result.contractId, columns);
|
|
306
|
-
lines.push(...verificationCheckLines(result.checks, result.snapshot, columns, result.contractId), ...trailingPlacementLines(result, columns));
|
|
277
|
+
lines.push(...verificationCheckLines(result.checks, result.snapshot, columns, result.contractId, surface), ...trailingPlacementLines(result, columns, surface));
|
|
307
278
|
return lines.join("\n");
|
|
308
279
|
}
|
|
309
280
|
/** The operation and supplied input stay renderer context, never fields manufactured on the native result. */
|
|
@@ -315,11 +286,11 @@ export function renderAccepted(operation, result, context, input = {}) {
|
|
|
315
286
|
case "amend":
|
|
316
287
|
return amend(result, columns, context?.color === true);
|
|
317
288
|
case "deliver":
|
|
318
|
-
return deliver(result, columns, input);
|
|
289
|
+
return deliver(result, columns, input, context?.surface);
|
|
319
290
|
case "review":
|
|
320
|
-
return review(result, columns, input);
|
|
291
|
+
return review(result, columns, input, context?.surface);
|
|
321
292
|
case "verify":
|
|
322
|
-
return verify(result, columns);
|
|
293
|
+
return verify(result, columns, context?.surface);
|
|
323
294
|
case "arc": {
|
|
324
295
|
const arc = result;
|
|
325
296
|
return [
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DebtAbsent, DebtCatalogue, DebtDoctorReport, DebtMutationResult, DebtShowResult, DebtUpdateResult } from "../../debt/index.js";
|
|
2
2
|
import { type TextRenderContext } from "./terminal.js";
|
|
3
3
|
export { debtMark } from "./marks.js";
|
|
4
|
-
/** Presentation-only list scope the leaf acquired; never part of a product value. */
|
|
5
|
-
export type DebtListScope = "world" | "current" | Readonly<{
|
|
6
|
-
namespace: string;
|
|
7
|
-
}>;
|
|
8
4
|
export declare function dispositionText(word: string): string;
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function renderDebtList(action: "ls" | "ready" | "blocked" | "query", scope: DebtListScope, result: DebtCatalogue | DebtReadPage<DebtSummary | BlockedDebtRow | ReadyDebtRow, DebtReadRefusal | DebtParentReadRefusal>, context?: TextRenderContext): string;
|
|
5
|
+
export declare function renderDebtList(result: DebtCatalogue, context?: TextRenderContext): string;
|
|
11
6
|
/** Each item corresponds to the same invocation position, including missing targets. */
|
|
12
|
-
export declare function renderDebtShow(
|
|
7
|
+
export declare function renderDebtShow(result: DebtShowResult | DebtAbsent, context?: TextRenderContext): string;
|
|
13
8
|
export declare function renderDoctor(report: DebtDoctorReport | DebtAbsent): string;
|
|
14
9
|
export declare function renderDebtUpdate(id: string | undefined, result: DebtUpdateResult, context?: TextRenderContext): string;
|
|
15
|
-
export declare function renderDebtTree(id: string, result: DebtTreeResult | DebtAbsent, context?: TextRenderContext): string;
|
|
16
|
-
export declare function renderDebtContext(result: DebtContextResult, context?: TextRenderContext): string;
|
|
17
10
|
/** Creation retains its minted identity in the native answer. */
|
|
18
11
|
export declare function renderDebtMutation(verb: string, result: DebtMutationResult, context?: TextRenderContext): string;
|
|
19
|
-
export declare function renderDebtLifecycle(verb: string, ids: readonly string[], result: DebtBatchResult, context?: TextRenderContext): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { debtMark } from "./marks.js";
|
|
2
|
-
import { outcomeLines,
|
|
2
|
+
import { outcomeLines, receiptRow, refusalLines } from "./receipt.js";
|
|
3
3
|
import { DEFAULT_CLI_COLUMNS, displayColumns, emptyCatalogue, renderOpaqueBlock, renderTextBlock, safeText, } from "./terminal.js";
|
|
4
4
|
export { debtMark } from "./marks.js";
|
|
5
5
|
const DEFAULT_CONTEXT = { columns: DEFAULT_CLI_COLUMNS, color: false };
|
|
@@ -22,13 +22,7 @@ function entityLines(entity, columns, indent = "") {
|
|
|
22
22
|
function projectRefusal(refusal) {
|
|
23
23
|
const diagnostic = refusal.reason.replaceAll("-", " ");
|
|
24
24
|
if (refusal.reason === "debt-missing")
|
|
25
|
-
return { diagnostic
|
|
26
|
-
if (refusal.reason === "invalid-lifecycle-transition")
|
|
27
|
-
return { diagnostic, facts: [`state ${dispositionText(refusal.state)}`] };
|
|
28
|
-
if (refusal.reason === "invalid-namespace-context")
|
|
29
|
-
return { diagnostic, ...(refusal.path === undefined ? {} : { facts: [`path ${refusal.path}`] }) };
|
|
30
|
-
if (refusal.reason === "relation-owned-by-other")
|
|
31
|
-
return { diagnostic, facts: [`related debt ${refusal.related}`] };
|
|
25
|
+
return { diagnostic };
|
|
32
26
|
return { diagnostic, facts: [`detail ${refusal.diagnostic}`] };
|
|
33
27
|
}
|
|
34
28
|
function renderFailure(verb, result, columns, id) {
|
|
@@ -44,44 +38,18 @@ function warningLines(warning, columns) {
|
|
|
44
38
|
function edge(label, ref) {
|
|
45
39
|
return ` ${label} ${ref.id} · ${dispositionText(ref.state)}`;
|
|
46
40
|
}
|
|
47
|
-
export function
|
|
48
|
-
return `${view.toUpperCase()} // ${scope}`;
|
|
49
|
-
}
|
|
50
|
-
function renderListRow(item, columns, action) {
|
|
51
|
-
const disposition = "disposition" in item ? item.disposition : action === "blocked" ? "blocked" : "ready";
|
|
52
|
-
const lines = [
|
|
53
|
-
...entityLines({
|
|
54
|
-
...item,
|
|
55
|
-
mark: debtMark(disposition),
|
|
56
|
-
...(action === "ready" || action === "blocked" ? {} : { word: disposition }),
|
|
57
|
-
}, columns),
|
|
58
|
-
];
|
|
59
|
-
if ("blockers" in item)
|
|
60
|
-
for (const blocker of item.blockers)
|
|
61
|
-
lines.push(` needs ${blocker.id} · ${blocker.missing === true ? "missing" : "open"}`);
|
|
62
|
-
return lines;
|
|
63
|
-
}
|
|
64
|
-
export function renderDebtList(action, scope, result, context = DEFAULT_CONTEXT) {
|
|
41
|
+
export function renderDebtList(result, context = DEFAULT_CONTEXT) {
|
|
65
42
|
const page = result;
|
|
66
43
|
const columns = context.columns;
|
|
67
|
-
if (
|
|
44
|
+
if ("absent" in page)
|
|
68
45
|
return "debt world absent";
|
|
69
|
-
if (page.kind === "invalid-namespace-context")
|
|
70
|
-
return refusalLines(action, ["reason invalid namespace context", `path ${page.path}`], columns).join("\n");
|
|
71
|
-
if (page.kind === "refused")
|
|
72
|
-
return renderFailure(action, page, columns);
|
|
73
46
|
const rows = page.rows ?? [];
|
|
74
|
-
const view =
|
|
47
|
+
const view = "debts";
|
|
75
48
|
if (rows.length === 0)
|
|
76
49
|
return emptyCatalogue(view);
|
|
77
|
-
const scopeText = scope === "world"
|
|
78
|
-
? "world"
|
|
79
|
-
: scope === "current"
|
|
80
|
-
? "current namespace"
|
|
81
|
-
: `namespace ${scope.namespace.replace(/^debt\//u, "").replace(/\/$/u, "") || "root"}`;
|
|
82
50
|
return [
|
|
83
|
-
|
|
84
|
-
...rows.flatMap((row) =>
|
|
51
|
+
"DEBTS // world",
|
|
52
|
+
...rows.flatMap((row) => entityLines({ ...row, mark: debtMark(row.disposition), word: row.disposition }, columns)),
|
|
85
53
|
...(page.more === true ? ["…"] : []),
|
|
86
54
|
].join("\n");
|
|
87
55
|
}
|
|
@@ -93,41 +61,26 @@ function renderShowDetail(id, debt, columns) {
|
|
|
93
61
|
...entityLines({ id, priority: debt.priority, mark: debtMark(debt.state), word: debt.state, title: debt.title }, columns),
|
|
94
62
|
` created ${textTimestamp(debt.createdAt)}`,
|
|
95
63
|
` updated ${textTimestamp(debt.updatedAt)}`,
|
|
96
|
-
...(debt.createdBy === undefined ? [] : [` created by ${debt.createdBy}`]),
|
|
97
64
|
];
|
|
98
65
|
for (const need of debt.needs ?? [])
|
|
99
66
|
lines.push(edge("needs", need));
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
lines.push(edge("relates", item));
|
|
106
|
-
if (debt.note !== undefined)
|
|
107
|
-
receiptPayload(lines, "note", debt.note);
|
|
108
|
-
if (debt.body !== undefined)
|
|
109
|
-
receiptPayload(lines, "body", debt.body);
|
|
67
|
+
for (const label of ["note", "body"]) {
|
|
68
|
+
const payload = debt[label];
|
|
69
|
+
if (payload !== undefined)
|
|
70
|
+
lines.push(` ${label}`, ...payload.split("\n").map((line) => ` ${safeText(line)}`), "");
|
|
71
|
+
}
|
|
110
72
|
return lines.join("\n");
|
|
111
73
|
}
|
|
112
74
|
/** Each item corresponds to the same invocation position, including missing targets. */
|
|
113
|
-
export function renderDebtShow(
|
|
75
|
+
export function renderDebtShow(result, context = DEFAULT_CONTEXT) {
|
|
114
76
|
if (result.kind === "absent")
|
|
115
77
|
return "debt world absent";
|
|
116
78
|
return result.items
|
|
117
|
-
.map((item
|
|
118
|
-
? renderShowDetail(
|
|
119
|
-
: refusalLines("show", ["reason debt missing", `debt ${
|
|
79
|
+
.map((item) => item.kind === "found"
|
|
80
|
+
? renderShowDetail(item.id, item, context.columns)
|
|
81
|
+
: refusalLines("show", ["reason debt missing", `debt ${item.id}`], context.columns).join("\n"))
|
|
120
82
|
.join("\n\n");
|
|
121
83
|
}
|
|
122
|
-
function treeLines(id, node, columns, depth = 0) {
|
|
123
|
-
const indent = " ".repeat(depth);
|
|
124
|
-
if ("kind" in node && node.kind === "cycle")
|
|
125
|
-
return [`${indent}! ${node.id} · cycle`];
|
|
126
|
-
return [
|
|
127
|
-
...entityLines({ id, priority: node.priority, mark: debtMark(node.state), word: node.state, title: node.title }, columns, indent),
|
|
128
|
-
...(node.children ?? []).flatMap((child) => treeLines(child.id, child, columns, depth + 1)),
|
|
129
|
-
];
|
|
130
|
-
}
|
|
131
84
|
function doctorIssue(issue) {
|
|
132
85
|
if (issue.kind === "missing-target")
|
|
133
86
|
return `! missing-target ${issue.debtId} ${issue.relation} ${issue.target}`;
|
|
@@ -143,7 +96,7 @@ export function renderDoctor(report) {
|
|
|
143
96
|
const noun = report.issues.length === 1 ? "issue" : "issues";
|
|
144
97
|
return [`! doctor ${report.issues.length} ${noun}`, ...report.issues.map(doctorIssue)].join("\n");
|
|
145
98
|
}
|
|
146
|
-
const PAST_VERBS = { add: "added",
|
|
99
|
+
const PAST_VERBS = { add: "added", update: "updated" };
|
|
147
100
|
export function renderDebtUpdate(id, result, context = DEFAULT_CONTEXT) {
|
|
148
101
|
const columns = context.columns;
|
|
149
102
|
if (result.kind !== "accepted")
|
|
@@ -156,27 +109,6 @@ export function renderDebtUpdate(id, result, context = DEFAULT_CONTEXT) {
|
|
|
156
109
|
lines.push(...warningLines(result.warning, columns));
|
|
157
110
|
return lines.join("\n");
|
|
158
111
|
}
|
|
159
|
-
function renderBatchItem(verb, id, item, columns) {
|
|
160
|
-
if (item.kind !== "accepted")
|
|
161
|
-
return renderFailure(verb, item, columns, id).split("\n");
|
|
162
|
-
return [
|
|
163
|
-
`✓ ${PAST_VERBS[verb] ?? verb} ${id}`,
|
|
164
|
-
...(item.warning === undefined ? [] : warningLines(item.warning, columns)),
|
|
165
|
-
];
|
|
166
|
-
}
|
|
167
|
-
export function renderDebtTree(id, result, context = DEFAULT_CONTEXT) {
|
|
168
|
-
if (result.kind === "absent")
|
|
169
|
-
return "debt world absent";
|
|
170
|
-
if (result.kind === "missing")
|
|
171
|
-
return refusalLines("tree", ["reason debt missing", `debt ${id}`], context.columns).join("\n");
|
|
172
|
-
return treeLines(id, result, context.columns).join("\n");
|
|
173
|
-
}
|
|
174
|
-
export function renderDebtContext(result, context = DEFAULT_CONTEXT) {
|
|
175
|
-
if (result.kind === "refused")
|
|
176
|
-
return refusalLines("context", ["reason invalid namespace context", `path ${result.path}`], context.columns).join("\n");
|
|
177
|
-
const value = "namespace" in result ? (result.namespace ?? "root") : "root";
|
|
178
|
-
return `context ${value} · ${result.source}`;
|
|
179
|
-
}
|
|
180
112
|
/** Creation retains its minted identity in the native answer. */
|
|
181
113
|
export function renderDebtMutation(verb, result, context = DEFAULT_CONTEXT) {
|
|
182
114
|
if (result.kind !== "accepted")
|
|
@@ -187,6 +119,3 @@ export function renderDebtMutation(verb, result, context = DEFAULT_CONTEXT) {
|
|
|
187
119
|
lines.push(...warningLines(result.warning, context.columns));
|
|
188
120
|
return lines.join("\n");
|
|
189
121
|
}
|
|
190
|
-
export function renderDebtLifecycle(verb, ids, result, context = DEFAULT_CONTEXT) {
|
|
191
|
-
return result.items.flatMap((item, index) => renderBatchItem(verb, ids[index], item, context.columns)).join("\n");
|
|
192
|
-
}
|