@astrosheep/keiyaku 4.6.30 → 4.6.31
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 +5 -5
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/pi/README.md +5 -5
- package/build/plugins/pi/akuma-tools.ts +17 -23
- package/build/skills/keiyaku/SKILL.md +12 -12
- package/build/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/src/akuma/akuma-call.d.ts +1 -1
- package/build/src/akuma/akuma-call.js +9 -9
- package/build/src/akuma/akuma-errors.d.ts +5 -5
- package/build/src/akuma/akuma-instance.d.ts +355 -12
- package/build/src/akuma/akuma-instance.js +20 -20
- package/build/src/akuma/akuma-observe.d.ts +11 -12
- package/build/src/akuma/akuma-observe.js +34 -26
- package/build/src/akuma/akuma-owner.d.ts +32 -11
- package/build/src/akuma/akuma-owner.js +35 -16
- package/build/src/akuma/akuma-probe.d.ts +3 -3
- package/build/src/akuma/akuma-probe.js +2 -2
- package/build/src/akuma/akuma-selection-execution.d.ts +985 -1
- package/build/src/akuma/akuma-selection-execution.js +42 -18
- package/build/src/akuma/akuma-stream.d.ts +2 -2
- package/build/src/akuma/akuma-stream.js +1 -1
- package/build/src/akuma/akuma-wait.d.ts +5 -5
- package/build/src/akuma/akuma-wait.js +52 -14
- package/build/src/akuma/akuma.d.ts +245 -271
- package/build/src/akuma/akuma.js +98 -46
- package/build/src/akuma/archetype.d.ts +19 -6
- package/build/src/akuma/archetype.js +25 -9
- package/build/src/akuma/body-launch.d.ts +2 -2
- package/build/src/akuma/body.js +4 -4
- package/build/src/akuma/call-initial-tell.d.ts +60 -44
- package/build/src/akuma/call-initial-tell.js +41 -2
- package/build/src/akuma/caller.d.ts +26 -17
- package/build/src/akuma/caller.js +22 -9
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +13 -0
- package/build/src/akuma/detached-body.js +2 -2
- package/build/src/akuma/dispatch-association.d.ts +4 -4
- package/build/src/akuma/dispatch-association.js +12 -3
- package/build/src/akuma/execution-instructions.js +2 -2
- package/build/src/akuma/heart/facts.d.ts +29 -7
- package/build/src/akuma/heart/facts.js +13 -0
- package/build/src/akuma/heart/index.d.ts +0 -3
- package/build/src/akuma/heart/index.js +3 -6
- package/build/src/akuma/heart/rows.js +2 -2
- package/build/src/akuma/heart/soul.js +5 -5
- package/build/src/akuma/identity.d.ts +17 -16
- package/build/src/akuma/identity.js +20 -19
- package/build/src/akuma/index.d.ts +1 -2
- package/build/src/akuma/lineage-cache.d.ts +4 -4
- package/build/src/akuma/lineage-cache.js +10 -10
- package/build/src/akuma/projection-read.d.ts +2 -5
- package/build/src/akuma/projection-read.js +34 -47
- package/build/src/akuma/projection.d.ts +659 -569
- package/build/src/akuma/projection.js +203 -94
- package/build/src/akuma/providers/acp/index.js +1 -1
- package/build/src/akuma/providers/execution-environment.d.ts +1 -3
- package/build/src/akuma/providers/execution-environment.js +0 -4
- package/build/src/akuma/publication.d.ts +2 -2
- package/build/src/akuma/publication.js +3 -3
- package/build/src/akuma/retention.js +2 -2
- package/build/src/akuma/selection-observation.d.ts +507 -43
- package/build/src/akuma/selection-observation.js +153 -1
- package/build/src/akuma/status-projection.d.ts +288 -0
- package/build/src/akuma/status-projection.js +154 -0
- package/build/src/akuma/turn-drive.js +0 -3
- package/build/src/alias/index.d.ts +9 -4
- package/build/src/alias/index.js +11 -9
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +9 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +2 -2
- package/build/src/cli/commands/akuma-grammar.js +21 -21
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +115 -251
- package/build/src/cli/commands/contract-grammar.d.ts +4 -3
- package/build/src/cli/commands/contract-grammar.js +39 -22
- package/build/src/cli/commands/contract-help.d.ts +3 -1
- package/build/src/cli/commands/contract-help.js +4 -3
- package/build/src/cli/commands/contract.d.ts +6 -3
- package/build/src/cli/commands/contract.js +203 -434
- package/build/src/cli/commands/debt.d.ts +2 -3
- package/build/src/cli/commands/debt.js +101 -317
- package/build/src/cli/commands/report.js +11 -28
- package/build/src/cli/commands/whoami.d.ts +3 -43
- package/build/src/cli/commands/whoami.js +8 -121
- package/build/src/cli/coordinates.d.ts +4 -35
- package/build/src/cli/coordinates.js +13 -129
- package/build/src/cli/parse.d.ts +0 -6
- package/build/src/cli/parse.js +5 -48
- package/build/src/cli/render/akuma-activity.d.ts +31 -16
- package/build/src/cli/render/akuma-activity.js +157 -149
- package/build/src/cli/render/akuma-tool.d.ts +3 -6
- package/build/src/cli/render/akuma-tool.js +20 -14
- package/build/src/cli/render/akuma.d.ts +25 -26
- package/build/src/cli/render/akuma.js +100 -129
- package/build/src/cli/render/catalog.d.ts +4 -7
- package/build/src/cli/render/catalog.js +52 -99
- package/build/src/cli/render/contract-history.d.ts +3 -1
- package/build/src/cli/render/contract-history.js +140 -215
- package/build/src/cli/render/contract-observation.d.ts +43 -30
- package/build/src/cli/render/contract-observation.js +64 -31
- package/build/src/cli/render/contract-wait.js +6 -6
- package/build/src/cli/render/contract.d.ts +41 -6
- package/build/src/cli/render/contract.js +274 -370
- package/build/src/cli/render/debt.d.ts +9 -19
- package/build/src/cli/render/debt.js +120 -185
- package/build/src/cli/render/delivery-preview.d.ts +4 -3
- package/build/src/cli/render/delivery-preview.js +68 -96
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -4
- package/build/src/cli/render/kanshi-akuma.js +70 -59
- package/build/src/cli/render/kanshi.d.ts +4 -4
- package/build/src/cli/render/kanshi.js +205 -221
- package/build/src/cli/render/marks.d.ts +11 -2
- package/build/src/cli/render/marks.js +13 -3
- package/build/src/cli/render/nuke.d.ts +3 -3
- package/build/src/cli/render/nuke.js +13 -16
- package/build/src/cli/render/receipt.d.ts +37 -43
- package/build/src/cli/render/receipt.js +313 -236
- package/build/src/cli/render/reconcile.d.ts +6 -4
- package/build/src/cli/render/reconcile.js +53 -137
- package/build/src/cli/render/refusal.d.ts +3 -2
- package/build/src/cli/render/refusal.js +73 -54
- package/build/src/cli/render/region.d.ts +11 -2
- package/build/src/cli/render/region.js +17 -23
- package/build/src/cli/render/settings.d.ts +0 -1
- package/build/src/cli/render/settings.js +8 -17
- package/build/src/cli/render/terminal.d.ts +2 -0
- package/build/src/cli/render/verbs.d.ts +4 -0
- package/build/src/cli/render/verbs.js +312 -0
- package/build/src/cli/render/whoami.d.ts +1 -1
- package/build/src/cli/render/whoami.js +24 -31
- package/build/src/cli/runtime.d.ts +3 -11
- package/build/src/cli/runtime.js +96 -79
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/streams.js +1 -0
- package/build/src/contract-guidance.js +2 -2
- package/build/src/contract-worktree.d.ts +2 -15
- package/build/src/contract-worktree.js +19 -35
- package/build/src/core/facts/observation.d.ts +4 -5
- package/build/src/core/facts/observation.js +7 -9
- package/build/src/core/verbs/amend.d.ts +0 -1
- package/build/src/core/verbs/amend.js +3 -3
- package/build/src/core/verbs/bind.d.ts +0 -1
- package/build/src/core/verbs/bind.js +5 -5
- package/build/src/core/verbs/deliver.d.ts +3 -2
- package/build/src/core/verbs/deliver.js +2 -2
- package/build/src/core/verbs/placement.d.ts +0 -5
- package/build/src/core/verbs/placement.js +4 -6
- package/build/src/core/verbs/reintegrate.d.ts +0 -1
- package/build/src/core/verbs/reintegrate.js +2 -2
- package/build/src/debt/board.d.ts +132 -116
- package/build/src/debt/board.js +138 -94
- package/build/src/debt/catalog.d.ts +4 -4
- package/build/src/debt/catalog.js +2 -18
- package/build/src/debt/context.d.ts +15 -3
- package/build/src/debt/context.js +12 -1
- package/build/src/debt/created-observation.d.ts +5 -17
- package/build/src/debt/created-observation.js +14 -6
- package/build/src/debt/document.d.ts +20 -15
- package/build/src/debt/document.js +18 -1
- package/build/src/debt/index.d.ts +346 -23
- package/build/src/debt/index.js +68 -22
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +14 -0
- package/build/src/debt/lifecycle-operations.d.ts +2 -2
- package/build/src/debt/lifecycle-operations.js +14 -22
- package/build/src/debt/operation-types.d.ts +188 -66
- package/build/src/debt/operation-types.js +113 -1
- package/build/src/debt/operations.d.ts +11 -10
- package/build/src/debt/operations.js +46 -71
- package/build/src/debt/query.d.ts +14 -10
- package/build/src/debt/query.js +3 -12
- package/build/src/debt/store.d.ts +4 -2
- package/build/src/debt/store.js +8 -8
- package/build/src/debt/view.d.ts +0 -3
- package/build/src/debt/view.js +0 -4
- package/build/src/dispatch/index.d.ts +22 -5
- package/build/src/dispatch/index.js +46 -37
- package/build/src/git/admission.d.ts +2 -2
- package/build/src/git/admission.js +2 -1
- package/build/src/git/hooks.d.ts +14 -35
- package/build/src/git/hooks.js +45 -25
- package/build/src/git/integration.d.ts +6 -24
- package/build/src/git/integration.js +10 -16
- package/build/src/git/private-state-seat.d.ts +2 -2
- package/build/src/git/private-state-seat.js +2 -1
- package/build/src/git/reconcile.d.ts +17 -79
- package/build/src/git/reconcile.js +37 -52
- package/build/src/git/scratch.d.ts +3 -3
- package/build/src/git/scratch.js +4 -1
- package/build/src/git/target-placement.d.ts +23 -31
- package/build/src/git/target-placement.js +42 -27
- package/build/src/git/target.d.ts +2 -2
- package/build/src/git/target.js +2 -1
- package/build/src/git/tender.d.ts +7 -39
- package/build/src/git/tender.js +21 -54
- package/build/src/git/terminal-reconcile.js +15 -18
- package/build/src/git/terminal-seal.d.ts +2 -4
- package/build/src/git/terminal-seal.js +7 -33
- package/build/src/git/workspace.d.ts +65 -41
- package/build/src/git/workspace.js +45 -14
- package/build/src/identity/selector.d.ts +2 -0
- package/build/src/identity/selector.js +13 -3
- package/build/src/index.d.ts +48 -54
- package/build/src/index.js +31 -43
- package/build/src/kanshi/counts.d.ts +42 -8
- package/build/src/kanshi/counts.js +13 -2
- package/build/src/kanshi/index.d.ts +5 -5
- package/build/src/kanshi/index.js +4 -3
- package/build/src/kanshi/read.d.ts +489 -6
- package/build/src/kanshi/read.js +334 -483
- package/build/src/kanshi/report.d.ts +2504 -103
- package/build/src/kanshi/report.js +165 -1
- package/build/src/kanshi/select.d.ts +0 -8
- package/build/src/kanshi/select.js +20 -59
- package/build/src/library/address.d.ts +8 -8
- package/build/src/library/address.js +7 -7
- package/build/src/library/akuma-creation.d.ts +690 -84
- package/build/src/library/akuma-creation.js +202 -142
- package/build/src/library/akuma-retention.d.ts +2 -2
- package/build/src/library/akuma-retention.js +2 -2
- package/build/src/library/akumas.d.ts +10 -6
- package/build/src/library/akumas.js +24 -7
- package/build/src/library/bind.d.ts +28 -54
- package/build/src/library/bind.js +6 -4
- package/build/src/library/continuation.d.ts +197 -479
- package/build/src/library/continuation.js +40 -23
- package/build/src/library/contract-address.d.ts +6 -5
- package/build/src/library/contract-address.js +5 -7
- package/build/src/library/contract-composition.d.ts +18 -12
- package/build/src/library/contract-composition.js +55 -47
- package/build/src/library/contract-creation.d.ts +3 -2
- package/build/src/library/contract-creation.js +38 -32
- package/build/src/library/contract-execution.js +77 -38
- package/build/src/library/contract-outcomes.d.ts +1877 -27
- package/build/src/library/contract-outcomes.js +93 -10
- package/build/src/library/contract-settings.d.ts +2 -2
- package/build/src/library/contract-settings.js +18 -14
- package/build/src/library/contract-types.d.ts +238 -61
- package/build/src/library/contract-types.js +131 -1
- package/build/src/library/contract-wait.d.ts +38 -17
- package/build/src/library/contract-wait.js +40 -10
- package/build/src/library/delivery.d.ts +588 -36
- package/build/src/library/delivery.js +35 -27
- package/build/src/library/input.d.ts +1 -1
- package/build/src/library/input.js +1 -2
- package/build/src/library/invocation.d.ts +11 -7
- package/build/src/library/invocation.js +42 -51
- package/build/src/library/kei.d.ts +48 -0
- package/build/src/library/kei.js +256 -0
- package/build/src/library/keiyaku-attribution.d.ts +11 -0
- package/build/src/{cli/delivery-identity.js → library/keiyaku-attribution.js} +12 -1
- package/build/src/library/keiyaku-classify.d.ts +11 -0
- package/build/src/library/keiyaku-classify.js +146 -0
- package/build/src/library/keiyaku-coordinates.d.ts +31 -0
- package/build/src/library/keiyaku-coordinates.js +103 -0
- package/build/src/library/keiyaku-debt.d.ts +142 -0
- package/build/src/library/keiyaku-debt.js +188 -0
- package/build/src/library/keiyaku-identity.d.ts +58 -0
- package/build/src/library/keiyaku-identity.js +176 -0
- package/build/src/library/keiyaku-policy.d.ts +27 -0
- package/build/src/library/keiyaku-policy.js +44 -0
- package/build/src/library/keiyaku-status.d.ts +1487 -0
- package/build/src/library/keiyaku-status.js +92 -0
- package/build/src/library/keiyaku-verbs.d.ts +6774 -0
- package/build/src/library/keiyaku-verbs.js +458 -0
- package/build/src/library/keiyaku.d.ts +871 -38
- package/build/src/library/keiyaku.js +677 -127
- package/build/src/library/nuke.d.ts +22 -0
- package/build/src/library/nuke.js +4 -1
- package/build/src/library/outcome.d.ts +706 -692
- package/build/src/library/outcome.js +582 -167
- package/build/src/library/reconcile.d.ts +464 -116
- package/build/src/library/reconcile.js +174 -102
- package/build/src/library/refusal.d.ts +113 -577
- package/build/src/library/refusal.js +64 -51
- package/build/src/library/region.d.ts +5 -24
- package/build/src/library/region.js +6 -21
- package/build/src/library/selection.d.ts +181 -32
- package/build/src/library/selection.js +99 -64
- package/build/src/mcp/adapter.d.ts +11 -0
- package/build/src/mcp/adapter.js +106 -0
- package/build/src/mcp/help.d.ts +1 -0
- package/build/src/mcp/help.js +26 -0
- package/build/src/mcp/index.d.ts +2 -0
- package/build/src/mcp/index.js +37 -0
- package/build/src/plugin/public.d.ts +1 -1
- package/build/src/plugin/runtime.js +17 -14
- package/build/src/protocol/arc.d.ts +4 -1
- package/build/src/protocol/arc.js +7 -1
- package/build/src/protocol/attempt.d.ts +2 -3
- package/build/src/protocol/attempt.js +1 -10
- package/build/src/protocol/bind.d.ts +6 -7
- package/build/src/protocol/bind.js +9 -5
- package/build/src/protocol/completion.d.ts +448 -12
- package/build/src/protocol/completion.js +164 -26
- package/build/src/protocol/deliver.d.ts +26 -24
- package/build/src/protocol/deliver.js +24 -52
- package/build/src/protocol/delivery-preview.d.ts +97 -247
- package/build/src/protocol/delivery-preview.js +132 -128
- package/build/src/protocol/execution-observation.d.ts +146 -123
- package/build/src/protocol/execution-observation.js +9 -6
- package/build/src/protocol/intent.d.ts +9 -48
- package/build/src/protocol/intent.js +32 -46
- package/build/src/protocol/operations.d.ts +207 -505
- package/build/src/protocol/operations.js +81 -134
- package/build/src/protocol/placement.d.ts +0 -1
- package/build/src/protocol/placement.js +5 -2
- package/build/src/protocol/progress.d.ts +7 -97
- package/build/src/protocol/progress.js +7 -55
- package/build/src/protocol/read/observation.d.ts +13 -6
- package/build/src/protocol/read/observation.js +10 -9
- package/build/src/protocol/read/status.d.ts +464 -93
- package/build/src/protocol/read/status.js +372 -85
- package/build/src/protocol/reconcile.d.ts +2 -0
- package/build/src/protocol/reconcile.js +12 -11
- package/build/src/protocol/reintegrate.d.ts +0 -1
- package/build/src/protocol/reintegrate.js +4 -4
- package/build/src/protocol/result-leaves.d.ts +528 -0
- package/build/src/protocol/result-leaves.js +195 -0
- package/build/src/protocol/result-reasons.d.ts +129 -0
- package/build/src/protocol/result-reasons.js +87 -0
- package/build/src/protocol/review.d.ts +14 -11
- package/build/src/protocol/review.js +30 -14
- package/build/src/protocol/run.d.ts +4 -4
- package/build/src/protocol/run.js +4 -1
- package/build/src/protocol/verify.d.ts +359 -30
- package/build/src/protocol/verify.js +118 -28
- package/build/src/region.d.ts +26 -0
- package/build/src/region.js +28 -0
- package/build/src/runtime/proc/diagnostic.d.ts +11 -0
- package/build/src/runtime/proc/diagnostic.js +20 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +126 -32
- package/build/src/settings.js +107 -34
- package/build/src/settlement/settle.d.ts +29 -12
- package/build/src/settlement/settle.js +22 -15
- package/build/src/verification/declaration.d.ts +1 -3
- package/build/src/verification/declaration.js +2 -5
- package/build/src/verification/execution.d.ts +7 -19
- package/build/src/verification/execution.js +37 -16
- package/build/src/verification/observation.d.ts +13 -13
- package/build/src/verification/observation.js +9 -7
- package/build/src/world.d.ts +8 -0
- package/build/src/world.js +7 -0
- package/package.json +6 -5
- package/plugins/paseo/plugin/server/keiyaku.ts +13 -46
- package/plugins/paseo/plugin/server/message.ts +8 -30
- package/plugins/paseo/plugin/server/mirror.ts +16 -20
- package/plugins/paseo/plugin/server/provider.ts +1 -1
- package/plugins/paseo/plugin/server/sdk.ts +14 -6
- package/plugins/pi/README.md +5 -5
- package/plugins/pi/akuma-tools.ts +17 -23
- package/skills/keiyaku/SKILL.md +12 -12
- package/skills/keiyaku-akuma/SKILL.md +16 -16
- package/skills/keiyaku-akuma/references/automation.md +14 -14
- package/skills/keiyaku-babysit/SKILL.md +10 -10
- package/skills/keiyaku-bind/SKILL.md +15 -15
- package/skills/keiyaku-debt/SKILL.md +16 -16
- package/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/src/cli/actor.d.ts +0 -10
- package/build/src/cli/actor.js +0 -24
- package/build/src/cli/akuma-caller.d.ts +0 -3
- package/build/src/cli/akuma-caller.js +0 -31
- package/build/src/cli/delivery-identity.d.ts +0 -3
- package/build/src/cli/render/effects.d.ts +0 -26
- package/build/src/cli/render/effects.js +0 -41
- package/build/src/cli/selectors.d.ts +0 -10
- package/build/src/cli/selectors.js +0 -42
- package/build/src/markdown/diff.d.ts +0 -1
- package/build/src/markdown/diff.js +0 -4
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { SettingsError
|
|
7
|
-
import { akumaCallerFromEnvironment } from "../akuma-caller.js";
|
|
8
|
-
import { Debts } from "../../debt/index.js";
|
|
9
|
-
import { actorFromEdge } from "../actor.js";
|
|
1
|
+
import { KeiyakuError, KeiyakuUsageError } from "../../index.js";
|
|
2
|
+
import { KeiyakuArcDocumentError } from "../../library/keiyaku.js";
|
|
3
|
+
import { classifyVerb } from "../../library/keiyaku-verbs.js";
|
|
4
|
+
import { renderVerb } from "../render/verbs.js";
|
|
5
|
+
import { validateContractMarkdown } from "../../library/input.js";
|
|
6
|
+
import { SettingsError } from "../../settings.js";
|
|
10
7
|
import { resolveInvocationCwd } from "../coordinates.js";
|
|
11
8
|
import { BindDraftError, preserveBindDraft } from "../draft.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { renderKanshiCategoryText, renderKanshiText } from "../render/kanshi.js";
|
|
16
|
-
import { nukeOutcome, renderNukeText } from "../render/nuke.js";
|
|
17
|
-
import { reconcileHasFailure, renderReconcile } from "../render/reconcile.js";
|
|
18
|
-
import { renderConflictMaterialized, renderRefusal } from "../render/refusal.js";
|
|
19
|
-
import { renderRegionText } from "../render/region.js";
|
|
20
|
-
import { renderSettingsText, settingsJsonValue } from "../render/settings.js";
|
|
21
|
-
import { canonicalContractSelector, contractFromInput, resolveContractId } from "../selectors.js";
|
|
22
|
-
import { displayContext, emit, writeJson, writeStderr, writeStdout } from "../streams.js";
|
|
23
|
-
import { CliUsageError, commandGuide, isBlankInput } from "../usage.js";
|
|
24
|
-
import { CONTRACT_COMMAND_SPECS } from "./contract-help.js";
|
|
25
|
-
function requiredRepo(coordinates) {
|
|
26
|
-
if (coordinates.repo === undefined)
|
|
27
|
-
throw new CliUsageError("this command requires a resolved Repo");
|
|
28
|
-
return coordinates.repo;
|
|
29
|
-
}
|
|
30
|
-
async function settingsAt(root, home) {
|
|
31
|
-
return settings({
|
|
32
|
-
...(root === undefined ? {} : { root }),
|
|
33
|
-
...(home === undefined ? {} : { home }),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
9
|
+
import { renderBindDraftReceipt } from "../render/refusal.js";
|
|
10
|
+
import { displayContext, emit } from "../streams.js";
|
|
11
|
+
import { CliUsageError, isBlankInput } from "../usage.js";
|
|
36
12
|
function draftWarning(error) {
|
|
37
13
|
return { warning: `bind draft could not be preserved: ${error instanceof Error ? error.message : String(error)}` };
|
|
38
14
|
}
|
|
@@ -64,498 +40,291 @@ async function bindDraftReceipt(world, markdown) {
|
|
|
64
40
|
return draftWarning(error);
|
|
65
41
|
}
|
|
66
42
|
}
|
|
67
|
-
function
|
|
68
|
-
const
|
|
69
|
-
return
|
|
70
|
-
operation: answer.operation,
|
|
71
|
-
...(answer.contract === undefined ? {} : { contract: answer.contract }),
|
|
72
|
-
refusal,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/** The CLI's own presentation of a refused dirty delivery: the available opt-in is not SDK evidence. */
|
|
76
|
-
function deliverRefusalProjection(refusal) {
|
|
77
|
-
if (refusal.kind !== "dirty-workspace")
|
|
78
|
-
return refusal;
|
|
79
|
-
const submodules = "submodules" in refusal && Array.isArray(refusal.submodules) ? refusal.submodules : [];
|
|
80
|
-
return { ...refusal, option: { flag: "--include-dirty", available: submodules.length === 0 } };
|
|
81
|
-
}
|
|
82
|
-
function renderContractAnswer(answer, project, context) {
|
|
83
|
-
switch (answer.kind) {
|
|
84
|
-
case "handoff":
|
|
85
|
-
return renderConflictMaterialized(answer.value, context);
|
|
86
|
-
case "refused":
|
|
87
|
-
return renderRefusal(refusedInvocation(answer, project), undefined, context);
|
|
88
|
-
case "retry":
|
|
89
|
-
return renderRetry(answer, context);
|
|
90
|
-
case "accepted":
|
|
91
|
-
return renderAccepted(answer, context);
|
|
92
|
-
}
|
|
43
|
+
function finishVerb(name, input, value, output, json = value) {
|
|
44
|
+
const completion = { kind: "returned", value };
|
|
45
|
+
return emit(output, json, () => renderVerb(name, input, completion, displayContext()), classifyVerb(name, input, completion));
|
|
93
46
|
}
|
|
94
|
-
async function
|
|
95
|
-
const outcome = answer.kind === "refused" ? "refused" : answer.kind === "retry" ? "retryable" : "accepted";
|
|
96
|
-
return emit(output, answer, () => renderContractAnswer(answer, project, displayContext()), outcome);
|
|
97
|
-
}
|
|
98
|
-
async function selectedContract(repo, selector, scope) {
|
|
99
|
-
const id = await resolveContractId(repo, selector, scope);
|
|
100
|
-
return { id, contract: contractFromInput(repo, id).contract };
|
|
101
|
-
}
|
|
102
|
-
async function existingSeat(command, coordinates, runtime, library) {
|
|
103
|
-
const repo = requiredRepo(coordinates);
|
|
104
|
-
const id = await resolveContractId(repo, command.contract, coordinates.cwd);
|
|
105
|
-
const actor = "actor" in command ? actorFromEdge(command.actor, runtime.environment) : undefined;
|
|
106
|
-
return {
|
|
107
|
-
id,
|
|
108
|
-
contract: library.select({ repo, id }),
|
|
109
|
-
...(actor === undefined ? {} : { actor }),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
async function runBind(command, input, library) {
|
|
113
|
-
const { coordinates, runtime } = input;
|
|
114
|
-
const repo = requiredRepo(coordinates);
|
|
115
|
-
const actor = actorFromEdge(command.actor, runtime.environment);
|
|
47
|
+
async function runBind(command, runtime) {
|
|
116
48
|
if (command.forkOf !== undefined) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
forkOf: contractFromInput(repo, command.forkOf).id,
|
|
49
|
+
const input = {
|
|
50
|
+
forkOf: command.forkOf,
|
|
120
51
|
...(command.target === undefined ? {} : { target: command.target }),
|
|
121
|
-
...(actor === undefined ? {} : { actor }),
|
|
122
|
-
}
|
|
123
|
-
|
|
52
|
+
...(command.actor === undefined ? {} : { actor: command.actor }),
|
|
53
|
+
};
|
|
54
|
+
const answer = await runtime.facet.run("bind", input);
|
|
55
|
+
return finishVerb("bind", input, answer, command.output);
|
|
124
56
|
}
|
|
125
57
|
const markdown = await runtime.readStdin();
|
|
126
58
|
try {
|
|
127
|
-
const
|
|
128
|
-
const answer = await library.bind({
|
|
129
|
-
repo,
|
|
59
|
+
const input = {
|
|
130
60
|
markdown,
|
|
131
61
|
...(command.debt === undefined ? {} : { debt: command.debt }),
|
|
132
62
|
...(command.target === undefined ? {} : { target: command.target }),
|
|
133
|
-
...(actor === undefined ? {} : { actor }),
|
|
134
|
-
...(after === undefined ? {} : { after }),
|
|
63
|
+
...(command.actor === undefined ? {} : { actor: command.actor }),
|
|
64
|
+
...(command.after === undefined ? {} : { after: command.after }),
|
|
135
65
|
...(command.gates === undefined ? {} : { gates: command.gates }),
|
|
136
|
-
}
|
|
66
|
+
};
|
|
67
|
+
const answer = await runtime.facet.run("bind", input);
|
|
137
68
|
if (answer.kind !== "refused")
|
|
138
|
-
return
|
|
139
|
-
const draft = await bindDraftReceipt(
|
|
140
|
-
const text = () =>
|
|
141
|
-
return emit(command.output, answer, text, "
|
|
69
|
+
return finishVerb("bind", input, answer, command.output);
|
|
70
|
+
const draft = await bindDraftReceipt(runtime.draftWorld, markdown);
|
|
71
|
+
const text = () => `${renderVerb("bind", input, { kind: "returned", value: answer }, displayContext())}\n${renderBindDraftReceipt(draft)}`;
|
|
72
|
+
return emit(command.output, answer, text, classifyVerb("bind", input, { kind: "returned", value: answer }));
|
|
142
73
|
}
|
|
143
74
|
catch (error) {
|
|
144
75
|
if (error instanceof Error && "executionReceipt" in error)
|
|
145
76
|
throw error;
|
|
77
|
+
if (error instanceof KeiyakuUsageError)
|
|
78
|
+
throw error;
|
|
146
79
|
// A selected Settings namespace failure is the Contract owner's invalid input, not a bad draft.
|
|
147
80
|
if (error instanceof KeiyakuError && error.category === "invalid-input" && error.cause instanceof SettingsError)
|
|
148
81
|
throw error;
|
|
149
82
|
if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
|
|
150
83
|
throw error;
|
|
151
|
-
throw new BindDraftError(error, await bindDraftReceipt(
|
|
84
|
+
throw new BindDraftError(error, await bindDraftReceipt(runtime.draftWorld, markdown));
|
|
152
85
|
}
|
|
153
86
|
}
|
|
154
|
-
async function runAmend(command,
|
|
155
|
-
const { coordinates, runtime } = input;
|
|
87
|
+
async function runAmend(command, runtime) {
|
|
156
88
|
const markdown = command.stdin === true ? await runtime.readStdin() : undefined;
|
|
157
89
|
if (markdown !== undefined && isBlankInput(markdown))
|
|
158
90
|
throw new CliUsageError("amend requires a nonblank stdin document");
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
|
|
91
|
+
const after = command.clearAfter === true ? [] : command.after;
|
|
92
|
+
const input = {
|
|
93
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
162
94
|
...(markdown === undefined ? {} : { markdown }),
|
|
163
|
-
...(
|
|
95
|
+
...(command.actor === undefined ? {} : { actor: command.actor }),
|
|
164
96
|
...(after === undefined ? {} : { after }),
|
|
165
97
|
...(command.gates === undefined ? {} : { gates: command.gates }),
|
|
166
|
-
}
|
|
167
|
-
|
|
98
|
+
};
|
|
99
|
+
const answer = await runtime.facet.run("amend", input);
|
|
100
|
+
return finishVerb("amend", input, answer, command.output);
|
|
168
101
|
}
|
|
169
|
-
async function runDeliver(command, runtime
|
|
102
|
+
async function runDeliver(command, runtime) {
|
|
170
103
|
const driver = command.output === "text" ? await runtime.progress() : undefined;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
104
|
+
const run = { signal: runtime.signal, ...(driver === undefined ? {} : { observe: driver.observe }) };
|
|
105
|
+
const withProgress = async (operation) => {
|
|
106
|
+
try {
|
|
107
|
+
return await operation();
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
if (driver !== undefined)
|
|
111
|
+
await driver.finish().catch(() => undefined);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
if (command.dryRun) {
|
|
115
|
+
const input = {
|
|
116
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
117
|
+
includeDirty: command.includeDirty,
|
|
118
|
+
showDiff: command.showDiff,
|
|
119
|
+
};
|
|
120
|
+
const answer = await withProgress(() => runtime.facet.run("deliver.preview", input, run));
|
|
121
|
+
return finishVerb("deliver.preview", input, answer, command.output);
|
|
122
|
+
}
|
|
123
|
+
const input = {
|
|
124
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
125
|
+
...(command.message === undefined ? {} : { message: command.message }),
|
|
126
|
+
includeDirty: command.includeDirty,
|
|
127
|
+
materializeConflict: command.materializeConflict,
|
|
128
|
+
overwrite: command.overwrite,
|
|
129
|
+
};
|
|
130
|
+
const answer = await withProgress(() => runtime.facet.run("deliver", input, run));
|
|
131
|
+
return finishVerb("deliver", input, answer, command.output);
|
|
190
132
|
}
|
|
191
|
-
async function runVerify(command, runtime
|
|
133
|
+
async function runVerify(command, runtime) {
|
|
192
134
|
const driver = command.output === "text" ? await runtime.progress() : undefined;
|
|
135
|
+
const input = {
|
|
136
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
137
|
+
...(command.index === undefined ? {} : { index: command.index }),
|
|
138
|
+
includeDirty: command.includeDirty,
|
|
139
|
+
};
|
|
193
140
|
let answer;
|
|
194
141
|
try {
|
|
195
|
-
answer = await
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}, { ...(driver === undefined ? {} : { observe: driver.observe }) });
|
|
142
|
+
answer = await runtime.facet.run("verify", input, {
|
|
143
|
+
signal: runtime.signal,
|
|
144
|
+
...(driver === undefined ? {} : { observe: driver.observe }),
|
|
145
|
+
});
|
|
200
146
|
}
|
|
201
147
|
finally {
|
|
202
148
|
if (driver !== undefined)
|
|
203
149
|
await driver.finish().catch(() => undefined);
|
|
204
150
|
}
|
|
205
|
-
return
|
|
151
|
+
return finishVerb("verify", input, answer, command.output);
|
|
206
152
|
}
|
|
207
|
-
async function runReview(command, runtime
|
|
153
|
+
async function runReview(command, runtime) {
|
|
208
154
|
const summary = command.summaryFromStdin === true ? await runtime.readStdin() : command.summary;
|
|
209
|
-
if (
|
|
155
|
+
if (summary === undefined || isBlankInput(summary))
|
|
210
156
|
throw new CliUsageError("review requires a nonblank summary");
|
|
211
157
|
const driver = command.output === "text" ? await runtime.progress() : undefined;
|
|
158
|
+
const input = {
|
|
159
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
160
|
+
verdict: command.verdict,
|
|
161
|
+
summary,
|
|
162
|
+
...(command.actor === undefined ? {} : { actor: command.actor }),
|
|
163
|
+
};
|
|
212
164
|
let answer;
|
|
213
165
|
try {
|
|
214
|
-
answer = await
|
|
215
|
-
|
|
216
|
-
...(
|
|
217
|
-
|
|
218
|
-
...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
|
|
219
|
-
}, { ...(driver === undefined ? {} : { observe: driver.observe }) });
|
|
166
|
+
answer = await runtime.facet.run("review", input, {
|
|
167
|
+
signal: runtime.signal,
|
|
168
|
+
...(driver === undefined ? {} : { observe: driver.observe }),
|
|
169
|
+
});
|
|
220
170
|
}
|
|
221
171
|
finally {
|
|
222
172
|
if (driver !== undefined)
|
|
223
173
|
await driver.finish().catch(() => undefined);
|
|
224
174
|
}
|
|
225
|
-
return
|
|
175
|
+
return finishVerb("review", input, answer, command.output);
|
|
226
176
|
}
|
|
227
|
-
async function runArc(command, runtime
|
|
177
|
+
async function runArc(command, runtime) {
|
|
228
178
|
const markdown = await runtime.readStdin();
|
|
179
|
+
const input = {
|
|
180
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
181
|
+
markdown,
|
|
182
|
+
...(command.actor === undefined ? {} : { actor: command.actor }),
|
|
183
|
+
};
|
|
229
184
|
try {
|
|
230
|
-
|
|
185
|
+
const answer = await runtime.facet.run("arc", input);
|
|
186
|
+
return finishVerb("arc", input, answer, command.output);
|
|
231
187
|
}
|
|
232
188
|
catch (error) {
|
|
233
|
-
if (!(error instanceof
|
|
189
|
+
if (!(error instanceof KeiyakuArcDocumentError))
|
|
234
190
|
throw error;
|
|
191
|
+
const completion = { kind: "threw", error };
|
|
235
192
|
const refusal = { kind: "invalid-document", diagnostic: error.message };
|
|
236
|
-
const refused = { kind: "refused",
|
|
237
|
-
return emit(command.output, refused, () =>
|
|
193
|
+
const refused = { kind: "refused", contractId: error.contract, reason: refusal };
|
|
194
|
+
return emit(command.output, refused, () => renderVerb("arc", input, completion, displayContext()), classifyVerb("arc", input, completion));
|
|
238
195
|
}
|
|
239
|
-
const answer = await seat.contract.arc({
|
|
240
|
-
markdown,
|
|
241
|
-
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
242
|
-
});
|
|
243
|
-
return await finishContractAnswer(answer, command.output);
|
|
244
196
|
}
|
|
245
|
-
async function runAbandon(command,
|
|
246
|
-
const
|
|
247
|
-
...(
|
|
197
|
+
async function runAbandon(command, runtime) {
|
|
198
|
+
const input = {
|
|
199
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
200
|
+
...(command.actor === undefined ? {} : { actor: command.actor }),
|
|
248
201
|
...(command.note === undefined ? {} : { note: command.note }),
|
|
249
|
-
}
|
|
250
|
-
|
|
202
|
+
};
|
|
203
|
+
const answer = await runtime.facet.run("abandon", input);
|
|
204
|
+
return finishVerb("abandon", input, answer, command.output);
|
|
251
205
|
}
|
|
252
|
-
async function runContractMutation(command,
|
|
253
|
-
const { configuration, runtime } = input;
|
|
254
|
-
const actor = ["deliver", "verify", "review"].includes(command.command)
|
|
255
|
-
? actorFromEdge(undefined, runtime.environment)
|
|
256
|
-
: undefined;
|
|
257
|
-
const library = Keiyaku.with({
|
|
258
|
-
...(configuration === undefined ? {} : { settings: configuration }),
|
|
259
|
-
...(actor === undefined ? {} : { actor }),
|
|
260
|
-
});
|
|
261
|
-
if (command.command === "bind")
|
|
262
|
-
return await runBind(command, input, library);
|
|
263
|
-
const seat = await existingSeat(command, input.coordinates, input.runtime, library);
|
|
206
|
+
export async function runContractMutation(command, runtime) {
|
|
264
207
|
switch (command.command) {
|
|
265
|
-
case "amend":
|
|
266
|
-
return await runAmend(command, input, seat);
|
|
267
208
|
case "deliver":
|
|
268
|
-
return await runDeliver(command,
|
|
209
|
+
return await runDeliver(command, runtime);
|
|
269
210
|
case "verify":
|
|
270
|
-
return await runVerify(command,
|
|
211
|
+
return await runVerify(command, runtime);
|
|
271
212
|
case "review":
|
|
272
|
-
return await runReview(command,
|
|
273
|
-
case "arc":
|
|
274
|
-
return await runArc(command, input.runtime, seat);
|
|
213
|
+
return await runReview(command, runtime);
|
|
275
214
|
case "abandon":
|
|
276
|
-
return await runAbandon(command,
|
|
215
|
+
return await runAbandon(command, runtime);
|
|
216
|
+
case "bind":
|
|
217
|
+
return await runBind(command, runtime);
|
|
218
|
+
case "amend":
|
|
219
|
+
return await runAmend(command, runtime);
|
|
220
|
+
case "arc":
|
|
221
|
+
return await runArc(command, runtime);
|
|
277
222
|
}
|
|
278
223
|
}
|
|
279
224
|
function statusRefusal(operation, contract) {
|
|
280
|
-
return { operation, contract, refusal: { kind: "contract-missing"
|
|
225
|
+
return { operation, contract, refusal: { kind: "contract-missing" } };
|
|
281
226
|
}
|
|
282
|
-
async function runSettings(
|
|
283
|
-
const
|
|
284
|
-
|
|
227
|
+
async function runSettings(runtime, output) {
|
|
228
|
+
const input = {};
|
|
229
|
+
const value = await runtime.facet.run("settings", input);
|
|
230
|
+
return finishVerb("settings", input, value, output);
|
|
285
231
|
}
|
|
286
|
-
async function runNuke(command,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
world: coordinates.world,
|
|
291
|
-
...(command.confirm === undefined ? {} : { confirm: command.confirm }),
|
|
292
|
-
});
|
|
293
|
-
return emit(command.output, result, () => renderNukeText(result), nukeOutcome(result));
|
|
232
|
+
async function runNuke(command, runtime) {
|
|
233
|
+
const input = { ...(command.confirm === undefined ? {} : { confirm: command.confirm }) };
|
|
234
|
+
const result = await runtime.facet.run("nuke", input);
|
|
235
|
+
return finishVerb("nuke", input, result, command.output);
|
|
294
236
|
}
|
|
295
|
-
async function runLs(command,
|
|
237
|
+
async function runLs(command, runtime) {
|
|
296
238
|
const query = command.query;
|
|
297
239
|
if (query.kind === "contracts") {
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
302
|
-
return emit(command.output, list, () => renderContractCatalogue(list), "accepted");
|
|
240
|
+
const input = { of: "kei", ...(query.limit === undefined ? {} : { limit: query.limit }) };
|
|
241
|
+
const list = await runtime.facet.run("ls", input);
|
|
242
|
+
return finishVerb("ls", input, list, command.output);
|
|
303
243
|
}
|
|
304
244
|
if (query.kind === "archetypes") {
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
...(home === undefined ? {} : { home }),
|
|
309
|
-
});
|
|
310
|
-
return emit(command.output, list, () => renderArchetypeCatalogue(list), "accepted");
|
|
245
|
+
const input = { of: "akuma-name", ...(query.limit === undefined ? {} : { limit: query.limit }) };
|
|
246
|
+
const list = await runtime.facet.run("ls", input);
|
|
247
|
+
return finishVerb("ls", input, list, command.output);
|
|
311
248
|
}
|
|
312
|
-
if (coordinates.world === null)
|
|
313
|
-
throw new CliUsageError("no Keiyaku world contains the invocation cwd");
|
|
314
249
|
if (query.kind === "debts") {
|
|
315
|
-
const
|
|
316
|
-
|
|
250
|
+
const input = {
|
|
251
|
+
of: "debt",
|
|
317
252
|
namespace: query.namespace ?? [],
|
|
253
|
+
...(query.selection === undefined ? {} : { selection: query.selection }),
|
|
318
254
|
...(query.limit === undefined ? {} : { limit: query.limit }),
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return emit(command.output, listed, () => renderDebtCatalogue(listed.value, query.namespace ?? []), "accepted");
|
|
255
|
+
};
|
|
256
|
+
const listed = await runtime.facet.run("ls", input);
|
|
257
|
+
return finishVerb("ls", input, listed, command.output);
|
|
323
258
|
}
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
...(query.
|
|
259
|
+
const input = {
|
|
260
|
+
of: "aku",
|
|
261
|
+
...(query.akumaName === undefined ? {} : { akumaName: query.akumaName }),
|
|
327
262
|
...(query.limit === undefined ? {} : { limit: query.limit }),
|
|
328
|
-
...(caller === undefined ? {} : { caller }),
|
|
329
|
-
});
|
|
330
|
-
return emit(command.output, listed, () => renderAkumaCatalogue(listed, query.archetype ?? null, caller), "accepted");
|
|
331
|
-
}
|
|
332
|
-
/** `--mine` is the process caller identity; `--caller` names the same coordinate explicitly. */
|
|
333
|
-
async function lsCaller(selection, coordinates, runtime) {
|
|
334
|
-
const usage = (diagnostic) => new CliUsageError(diagnostic, commandGuide("ls", CONTRACT_COMMAND_SPECS.ls.usage));
|
|
335
|
-
if (selection === undefined)
|
|
336
|
-
return undefined;
|
|
337
|
-
if (selection.kind === "external")
|
|
338
|
-
return selection.caller;
|
|
339
|
-
if (selection.kind === "akuma") {
|
|
340
|
-
if (coordinates.world === null)
|
|
341
|
-
throw usage("no Keiyaku world contains the invocation cwd");
|
|
342
|
-
return { kind: "akuma", world: coordinates.world, akuId: selection.akuId };
|
|
343
|
-
}
|
|
344
|
-
let caller;
|
|
345
|
-
try {
|
|
346
|
-
caller = await akumaCallerFromEnvironment(runtime.environment);
|
|
347
|
-
}
|
|
348
|
-
catch (error) {
|
|
349
|
-
throw usage(error instanceof Error ? error.message : String(error));
|
|
350
|
-
}
|
|
351
|
-
if (caller === undefined)
|
|
352
|
-
throw usage("--mine requires a caller identity; set KEIYAKU_ACTOR_ID and KEIYAKU_ACTOR_WORLD or run inside a calling host");
|
|
353
|
-
return caller;
|
|
354
|
-
}
|
|
355
|
-
async function readAkumaStatus(akuma, alias, coordinates) {
|
|
356
|
-
if (coordinates.world === null)
|
|
357
|
-
throw new CliUsageError("no Keiyaku world contains the Akuma selector");
|
|
358
|
-
const status = await Akumas.of(coordinates.world, { reportDiagnostic: writeStderr }).status({
|
|
359
|
-
akuma,
|
|
360
|
-
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
361
|
-
});
|
|
362
|
-
return {
|
|
363
|
-
value: status,
|
|
364
|
-
project: () => snapshotText(status, displayContext(), ...(alias === undefined ? [{}] : [{ alias }])),
|
|
263
|
+
...(query.caller === undefined ? {} : { caller: query.caller }),
|
|
365
264
|
};
|
|
265
|
+
const listed = await runtime.facet.run("ls", input);
|
|
266
|
+
return finishVerb("ls", input, listed, command.output);
|
|
267
|
+
}
|
|
268
|
+
async function runShow(command, runtime) {
|
|
269
|
+
const input = command.contract === undefined ? {} : { contract: command.contract };
|
|
270
|
+
const guidance = await runtime.facet.run("show", input);
|
|
271
|
+
return finishVerb("show", input, guidance, command.output);
|
|
272
|
+
}
|
|
273
|
+
async function runStatus(command, runtime) {
|
|
274
|
+
const input = command.category !== undefined
|
|
275
|
+
? { category: command.category, ...(command.limit === undefined ? {} : { limit: command.limit }) }
|
|
276
|
+
: "selectors" in command && command.selectors !== undefined
|
|
277
|
+
? { selectors: command.selectors }
|
|
278
|
+
: command.contract === undefined
|
|
279
|
+
? {}
|
|
280
|
+
: { selector: command.contract };
|
|
281
|
+
const value = await runtime.facet.run("status", input);
|
|
282
|
+
const completion = { kind: "returned", value };
|
|
283
|
+
const outcome = classifyVerb("status", input, completion);
|
|
284
|
+
const json = outcome === "refused" && "selector" in input && input.selector !== undefined
|
|
285
|
+
? statusRefusal("status", input.selector).refusal
|
|
286
|
+
: value;
|
|
287
|
+
return emit(command.output, json, () => renderVerb("status", input, completion, displayContext()), outcome);
|
|
288
|
+
}
|
|
289
|
+
async function runRegion(command, runtime) {
|
|
290
|
+
const input = command.paths !== undefined
|
|
291
|
+
? { paths: command.paths }
|
|
292
|
+
: command.contract !== undefined
|
|
293
|
+
? { contract: command.contract }
|
|
294
|
+
: {};
|
|
295
|
+
const result = await runtime.facet.run("region", input);
|
|
296
|
+
return finishVerb("region", input, result, command.output);
|
|
297
|
+
}
|
|
298
|
+
export async function runContractHistoryCommand(command, runtime) {
|
|
299
|
+
const input = { selector: command.contract, full: command.full };
|
|
300
|
+
const history = await runtime.facet.run("history", input);
|
|
301
|
+
return finishVerb("history", input, history, command.output);
|
|
302
|
+
}
|
|
303
|
+
async function runReconcile(command, runtime) {
|
|
304
|
+
const input = {
|
|
305
|
+
...(command.contract === undefined ? {} : { contract: command.contract }),
|
|
306
|
+
retryHooks: command.retryHooks,
|
|
307
|
+
};
|
|
308
|
+
const report = await runtime.facet.run("reconcile", input);
|
|
309
|
+
return finishVerb("reconcile", input, report, command.output);
|
|
366
310
|
}
|
|
367
|
-
async function
|
|
368
|
-
const repo = requiredRepo(coordinates);
|
|
369
|
-
const contract = selector === undefined ? undefined : canonicalContractSelector(selector);
|
|
370
|
-
const report = await kanshi({ world: coordinates.world, repo, ...(contract === undefined ? {} : { contract }) });
|
|
371
|
-
return { value: report, project: () => renderKanshiText(report, displayContext(), "contract") };
|
|
372
|
-
}
|
|
373
|
-
/** Identity comes from the complete candidate observation; display detail is requested only after it. */
|
|
374
|
-
async function namedStatus(selector, coordinates, authority) {
|
|
375
|
-
const address = resolveNamedAddress({ selector, contracts: authority.contracts, aliases: authority.aliases });
|
|
376
|
-
if (address.kind === "akuma")
|
|
377
|
-
return await readAkumaStatus(address.id, selector, coordinates);
|
|
378
|
-
return await readContractStatus(address.id, coordinates);
|
|
379
|
-
}
|
|
380
|
-
async function runShow(command, coordinates) {
|
|
381
|
-
const repo = coordinates.repo;
|
|
382
|
-
if (repo === undefined)
|
|
383
|
-
throw new CliUsageError("cannot select a contract while the Contract world is absent");
|
|
384
|
-
const selected = await selectedContract(repo, command.contract, coordinates.cwd);
|
|
385
|
-
const guidance = await selected.contract.guidance();
|
|
386
|
-
if (guidance === null) {
|
|
387
|
-
const refusal = statusRefusal(command.command, selected.id);
|
|
388
|
-
return emit(command.output, null, () => renderRefusal(refusal, undefined, displayContext()), "refused");
|
|
389
|
-
}
|
|
390
|
-
return emit(command.output, guidance, () => guidance, "accepted");
|
|
391
|
-
}
|
|
392
|
-
async function runStatusSelection(command, coordinates) {
|
|
393
|
-
const selectors = command.selectors;
|
|
394
|
-
if (selectors.length < 2)
|
|
395
|
-
throw new CliUsageError("status requires at least two selectors");
|
|
396
|
-
if (selectors.some((selector) => !selector.startsWith("aku/") && !selector.startsWith("@")) &&
|
|
397
|
-
coordinates.repo === undefined)
|
|
398
|
-
throw new CliUsageError("cannot select a contract while the Contract world is absent");
|
|
399
|
-
const authority = selectors.some((selector) => selector.startsWith("@"))
|
|
400
|
-
? await observeNamedAddress({ world: coordinates.world, repo: coordinates.repo ?? null })
|
|
401
|
-
: undefined;
|
|
402
|
-
const values = [];
|
|
403
|
-
const blocks = [];
|
|
404
|
-
for (const selector of selectors) {
|
|
405
|
-
const resolved = selector.startsWith("aku/")
|
|
406
|
-
? await readAkumaStatus(selector, undefined, coordinates)
|
|
407
|
-
: selector.startsWith("@")
|
|
408
|
-
? await namedStatus(selector, coordinates, authority)
|
|
409
|
-
: await readContractStatus(selector, coordinates);
|
|
410
|
-
values.push(resolved.value);
|
|
411
|
-
if (command.output === "text")
|
|
412
|
-
blocks.push(resolved.project());
|
|
413
|
-
}
|
|
414
|
-
return emit(command.output, values, () => blocks.join("\n\n"), "accepted");
|
|
415
|
-
}
|
|
416
|
-
async function runStatusCategory(command, coordinates) {
|
|
417
|
-
if (command.category === "contract")
|
|
418
|
-
requiredRepo(coordinates);
|
|
419
|
-
const report = await kanshiCategory({
|
|
420
|
-
world: coordinates.world,
|
|
421
|
-
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
422
|
-
category: command.category,
|
|
423
|
-
...(command.limit === undefined ? {} : { limit: command.limit }),
|
|
424
|
-
});
|
|
425
|
-
return emit(command.output, report, () => renderKanshiCategoryText(report, displayContext()), "accepted");
|
|
426
|
-
}
|
|
427
|
-
async function runStatusIdentity(command, coordinates) {
|
|
428
|
-
if (command.contract === undefined) {
|
|
429
|
-
const report = await kanshi({
|
|
430
|
-
world: coordinates.world,
|
|
431
|
-
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
432
|
-
});
|
|
433
|
-
return emit(command.output, report, () => renderKanshiText(report, displayContext(), "world"), "accepted");
|
|
434
|
-
}
|
|
435
|
-
if (command.contract.startsWith("@")) {
|
|
436
|
-
const resolved = await namedStatus(command.contract, coordinates, await observeNamedAddress({ world: coordinates.world, repo: coordinates.repo ?? null }));
|
|
437
|
-
return emit(command.output, resolved.value, () => resolved.project(), "accepted");
|
|
438
|
-
}
|
|
439
|
-
if (command.contract.startsWith("kei/")) {
|
|
440
|
-
const repo = requiredRepo(coordinates);
|
|
441
|
-
const contract = canonicalContractSelector(command.contract);
|
|
442
|
-
const report = await kanshi({ world: coordinates.world, repo, contract });
|
|
443
|
-
if (report.contracts.kind === "present" && report.contracts.value.rows.length === 0) {
|
|
444
|
-
const refusal = statusRefusal("status", contract);
|
|
445
|
-
return emit(command.output, refusal.refusal, () => renderRefusal(refusal, undefined, displayContext()), "refused");
|
|
446
|
-
}
|
|
447
|
-
return emit(command.output, report, () => renderKanshiText(report, displayContext(), "contract"), "accepted");
|
|
448
|
-
}
|
|
449
|
-
throw new CliUsageError(`contract selector must use kei/: ${command.contract}`);
|
|
450
|
-
}
|
|
451
|
-
async function runStatus(command, coordinates) {
|
|
452
|
-
if (command.category !== undefined)
|
|
453
|
-
return await runStatusCategory(command, coordinates);
|
|
454
|
-
if ("selectors" in command && command.selectors !== undefined)
|
|
455
|
-
return await runStatusSelection({ ...command, selectors: command.selectors }, coordinates);
|
|
456
|
-
if (command.akuma === true && command.contract !== undefined) {
|
|
457
|
-
const resolved = await readAkumaStatus(command.contract, undefined, coordinates);
|
|
458
|
-
return emit(command.output, resolved.value, () => resolved.project(), "accepted");
|
|
459
|
-
}
|
|
460
|
-
return await runStatusIdentity(command, coordinates);
|
|
461
|
-
}
|
|
462
|
-
async function runRegion(command, coordinates) {
|
|
463
|
-
const repo = requiredRepo(coordinates);
|
|
464
|
-
const emitSection = (section) => emit(command.output, section, () => renderRegionText(section), "accepted");
|
|
465
|
-
if (command.paths !== undefined) {
|
|
466
|
-
const report = await kanshi({ world: coordinates.world, repo, region: { kind: "path", patterns: command.paths } });
|
|
467
|
-
return emitSection(report.region ?? { kind: "absent" });
|
|
468
|
-
}
|
|
469
|
-
const contract = command.contract === undefined ? undefined : await resolveContractId(repo, command.contract, coordinates.cwd);
|
|
470
|
-
const report = await kanshi({ world: coordinates.world, repo, region: { kind: "declarations" } });
|
|
471
|
-
if (contract === undefined)
|
|
472
|
-
return emitSection(report.region ?? { kind: "absent" });
|
|
473
|
-
const observed = await observeKeiyaku({ repo, id: contract });
|
|
474
|
-
if (observed.kind === "missing" || observed.row.phase === "claimed" || observed.row.phase === "abandoned") {
|
|
475
|
-
const refusal = {
|
|
476
|
-
kind: observed.kind === "missing" ? "contract-missing" : "terminal",
|
|
477
|
-
contractId: contract,
|
|
478
|
-
};
|
|
479
|
-
if (command.output === "json")
|
|
480
|
-
writeJson(refusal);
|
|
481
|
-
else
|
|
482
|
-
writeStdout(renderRefusal({ operation: "region", contract, refusal }, undefined, displayContext()));
|
|
483
|
-
return "refused";
|
|
484
|
-
}
|
|
485
|
-
if (report.region?.kind !== "present" || report.region.value.kind !== "declarations")
|
|
486
|
-
return emitSection(report.region ?? { kind: "absent" });
|
|
487
|
-
return emitSection({
|
|
488
|
-
kind: "present",
|
|
489
|
-
value: selectRegion({
|
|
490
|
-
declarations: report.region.value.declarations,
|
|
491
|
-
selection: { kind: "contract", contract },
|
|
492
|
-
}),
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
export async function runContractHistoryCommand(command, coordinates) {
|
|
496
|
-
const repo = requiredRepo(coordinates);
|
|
497
|
-
const selected = contractFromInput(repo, command.contract);
|
|
498
|
-
const history = await selected.contract.history();
|
|
499
|
-
if (history === null) {
|
|
500
|
-
const refusal = { kind: "contract-missing", contractId: selected.id };
|
|
501
|
-
if (command.output === "json")
|
|
502
|
-
writeJson(refusal);
|
|
503
|
-
else
|
|
504
|
-
writeStdout(renderRefusal({ operation: "history", contract: selected.id, refusal }, undefined, displayContext()));
|
|
505
|
-
return "refused";
|
|
506
|
-
}
|
|
507
|
-
return emit(command.output, history, () => renderContractHistory(history, { full: command.full }), "accepted");
|
|
508
|
-
}
|
|
509
|
-
async function runReconcile(command, coordinates, home) {
|
|
510
|
-
const repo = requiredRepo(coordinates);
|
|
511
|
-
const configuration = await settingsAt(coordinates.world ?? undefined, home);
|
|
512
|
-
const library = Keiyaku.with({ settings: configuration });
|
|
513
|
-
let report;
|
|
514
|
-
if (command.contract === undefined) {
|
|
515
|
-
report = await library.reconcile({ repo, retryHooks: command.retryHooks });
|
|
516
|
-
}
|
|
517
|
-
else {
|
|
518
|
-
const selected = await selectedContract(repo, command.contract, coordinates.cwd);
|
|
519
|
-
const observed = await observeKeiyaku({ repo, id: selected.id });
|
|
520
|
-
if (observed.kind === "missing") {
|
|
521
|
-
if (command.output === "json")
|
|
522
|
-
writeJson(statusRefusal("reconcile", selected.id).refusal);
|
|
523
|
-
else
|
|
524
|
-
writeStdout(renderRefusal(statusRefusal("reconcile", selected.id), undefined, displayContext()));
|
|
525
|
-
return "refused";
|
|
526
|
-
}
|
|
527
|
-
report = await library.reconcile({ repo, contract: selected.id, retryHooks: command.retryHooks });
|
|
528
|
-
}
|
|
529
|
-
if (command.output === "json")
|
|
530
|
-
writeJson(report);
|
|
531
|
-
else
|
|
532
|
-
writeStdout(renderReconcile(report, displayContext()));
|
|
533
|
-
return reconcileHasFailure(report) ? "failed" : "accepted";
|
|
534
|
-
}
|
|
535
|
-
export async function runContractCommand(command, coordinates, runtime) {
|
|
536
|
-
const home = runtime.home;
|
|
311
|
+
export async function runContractCommand(command, runtime) {
|
|
537
312
|
switch (command.command) {
|
|
538
313
|
case "settings":
|
|
539
|
-
return await runSettings(
|
|
314
|
+
return await runSettings(runtime, command.output);
|
|
540
315
|
case "nuke":
|
|
541
|
-
return await runNuke(command,
|
|
316
|
+
return await runNuke(command, runtime);
|
|
542
317
|
case "ls":
|
|
543
|
-
return await runLs(command,
|
|
318
|
+
return await runLs(command, runtime);
|
|
544
319
|
case "show":
|
|
545
|
-
return await runShow(command,
|
|
320
|
+
return await runShow(command, runtime);
|
|
546
321
|
case "status":
|
|
547
|
-
return await runStatus(command,
|
|
322
|
+
return await runStatus(command, runtime);
|
|
548
323
|
case "region":
|
|
549
|
-
return await runRegion(command,
|
|
324
|
+
return await runRegion(command, runtime);
|
|
550
325
|
case "reconcile":
|
|
551
|
-
return await runReconcile(command,
|
|
552
|
-
default:
|
|
553
|
-
|
|
554
|
-
return await runContractMutation(command, {
|
|
555
|
-
coordinates,
|
|
556
|
-
runtime,
|
|
557
|
-
...(configuration === undefined ? {} : { configuration }),
|
|
558
|
-
});
|
|
559
|
-
}
|
|
326
|
+
return await runReconcile(command, runtime);
|
|
327
|
+
default:
|
|
328
|
+
return await runContractMutation(command, runtime);
|
|
560
329
|
}
|
|
561
330
|
}
|