@astrosheep/keiyaku 4.5.29 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +0 -13
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +47 -78
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/references/automation.md +54 -41
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +10 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +27 -9
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +68 -71
- package/build/src/akuma/akuma-call.d.ts +53 -0
- package/build/src/akuma/akuma-call.js +113 -0
- package/build/src/akuma/akuma-instance.d.ts +20 -18
- package/build/src/akuma/akuma-instance.js +65 -175
- package/build/src/akuma/akuma-observe.d.ts +3 -21
- package/build/src/akuma/akuma-observe.js +7 -24
- package/build/src/akuma/{akuma-handle.d.ts → akuma-owner.d.ts} +55 -27
- package/build/src/akuma/{akuma-handle.js → akuma-owner.js} +24 -23
- package/build/src/akuma/akuma-selection-execution.d.ts +51 -0
- package/build/src/akuma/akuma-selection-execution.js +134 -0
- package/build/src/akuma/{fleet-execution.d.ts → akuma-wait.d.ts} +24 -44
- package/build/src/akuma/akuma-wait.js +113 -0
- package/build/src/akuma/akuma.d.ts +35 -89
- package/build/src/akuma/akuma.js +148 -30
- package/build/src/akuma/archetype.d.ts +12 -0
- package/build/src/akuma/archetype.js +47 -19
- package/build/src/akuma/body.d.ts +76 -36
- package/build/src/akuma/body.js +84 -49
- package/build/src/akuma/call-initial-tell.d.ts +131 -22
- package/build/src/akuma/call-initial-tell.js +31 -1
- package/build/src/akuma/call-request.d.ts +237 -31
- package/build/src/akuma/call-request.js +67 -94
- package/build/src/akuma/coordinate.d.ts +15 -5
- package/build/src/akuma/coordinate.js +12 -22
- package/build/src/akuma/dispatch-association.d.ts +1 -1
- package/build/src/akuma/dispatch-association.js +1 -10
- package/build/src/akuma/heart/activity-schema.d.ts +325 -0
- package/build/src/akuma/heart/activity-schema.js +53 -0
- package/build/src/akuma/heart/facts.d.ts +1 -6
- package/build/src/akuma/heart/index.d.ts +3 -1
- package/build/src/akuma/heart/index.js +4 -1
- package/build/src/akuma/heart/rows.d.ts +49 -2
- package/build/src/akuma/heart/rows.js +16 -2
- package/build/src/akuma/heart/soul.d.ts +1 -0
- package/build/src/akuma/heart/soul.js +6 -4
- package/build/src/akuma/heart/tells.d.ts +1 -0
- package/build/src/akuma/heart/tells.js +18 -0
- package/build/src/akuma/identity.d.ts +10 -7
- package/build/src/akuma/identity.js +23 -0
- package/build/src/akuma/index.d.ts +10 -8
- package/build/src/akuma/index.js +2 -2
- package/build/src/akuma/nuke.d.ts +3 -0
- package/build/src/akuma/nuke.js +13 -7
- package/build/src/akuma/projection.d.ts +0 -5
- package/build/src/akuma/projection.js +22 -43
- package/build/src/akuma/provider-recipe.d.ts +58 -13
- package/build/src/akuma/provider-recipe.js +62 -80
- package/build/src/akuma/provider.d.ts +6 -76
- package/build/src/akuma/provider.js +11 -219
- package/build/src/akuma/providers/acp/config.d.ts +2 -0
- package/build/src/akuma/providers/acp/config.js +26 -1
- package/build/src/akuma/providers/acp/core.d.ts +7 -0
- package/build/src/akuma/providers/acp/core.js +49 -18
- package/build/src/akuma/providers/acp/index.js +14 -6
- package/build/src/akuma/providers/grok-build/index.js +44 -13
- package/build/src/akuma/providers/index.d.ts +3 -3
- package/build/src/akuma/providers/index.js +2 -13
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +28 -0
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +92 -0
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +0 -1
- package/build/src/akuma/providers/opencode-sdk/index.js +200 -64
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +41 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +69 -2
- package/build/src/akuma/providers/pi/events.js +5 -2
- package/build/src/akuma/providers/pi/index.d.ts +3 -4
- package/build/src/akuma/providers/pi/index.js +99 -45
- package/build/src/akuma/publication.d.ts +84 -3
- package/build/src/akuma/publication.js +145 -2
- package/build/src/akuma/read-pool.d.ts +2 -0
- package/build/src/akuma/read-pool.js +15 -0
- package/build/src/akuma/request-rendezvous.js +10 -0
- package/build/src/akuma/request-serve.js +7 -0
- package/build/src/akuma/request-wire.d.ts +14 -26
- package/build/src/akuma/request-wire.js +4 -0
- package/build/src/akuma/requests.d.ts +0 -2
- package/build/src/akuma/requests.js +0 -17
- package/build/src/akuma/{fleet-observation.d.ts → selection-observation.d.ts} +37 -36
- package/build/src/akuma/selection-observation.js +65 -0
- package/build/src/akuma/{fleet-owner-port.d.ts → selection-owner-port.d.ts} +3 -3
- package/build/src/akuma/{fleet-owner-port.js → selection-owner-port.js} +11 -17
- package/build/src/akuma/{fleet-request.d.ts → selection-request.d.ts} +42 -82
- package/build/src/akuma/{fleet-request.js → selection-request.js} +92 -136
- package/build/src/akuma/turn-drive.js +73 -14
- package/build/src/akuma-body.js +91 -56
- package/build/src/body/amend.d.ts +5 -0
- package/build/src/body/amend.js +26 -50
- package/build/src/body/arc.d.ts +4 -2
- package/build/src/body/arc.js +19 -26
- package/build/src/body/criteria.d.ts +6 -0
- package/build/src/body/criteria.js +37 -0
- package/build/src/body/decode.js +5 -42
- package/build/src/body/region.d.ts +5 -0
- package/build/src/body/region.js +45 -2
- package/build/src/body/render.js +2 -4
- package/build/src/cli/activity.d.ts +26 -0
- package/build/src/cli/activity.js +75 -0
- package/build/src/cli/actor.d.ts +3 -1
- package/build/src/cli/actor.js +15 -2
- package/build/src/cli/commands/akuma-grammar.d.ts +75 -0
- package/build/src/cli/commands/akuma-grammar.js +414 -0
- package/build/src/cli/commands/akuma.d.ts +5 -69
- package/build/src/cli/commands/akuma.js +352 -319
- package/build/src/cli/commands/amend.d.ts +4 -5
- package/build/src/cli/commands/amend.js +1 -2
- package/build/src/cli/commands/bind.d.ts +4 -5
- package/build/src/cli/commands/bind.js +7 -10
- package/build/src/cli/commands/contract-grammar.d.ts +112 -0
- package/build/src/cli/commands/contract-grammar.js +282 -0
- package/build/src/cli/commands/contract-help.d.ts +17 -22
- package/build/src/cli/commands/contract-help.js +37 -24
- package/build/src/cli/commands/contract.d.ts +18 -97
- package/build/src/cli/commands/contract.js +621 -233
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +2 -2
- package/build/src/cli/commands/task-grammar.d.ts +19 -0
- package/build/src/cli/commands/task-grammar.js +438 -0
- package/build/src/cli/commands/task-query.js +23 -104
- package/build/src/cli/commands/task.d.ts +5 -20
- package/build/src/cli/commands/task.js +414 -364
- package/build/src/cli/coordinates.d.ts +10 -0
- package/build/src/cli/coordinates.js +20 -0
- package/build/src/cli/draft.d.ts +7 -1
- package/build/src/cli/main.js +10 -1
- package/build/src/cli/parse.d.ts +8 -9
- package/build/src/cli/parse.js +62 -62
- package/build/src/cli/render/akuma-activity.d.ts +54 -36
- package/build/src/cli/render/akuma-activity.js +262 -242
- package/build/src/cli/render/akuma-tool.d.ts +8 -4
- package/build/src/cli/render/akuma-tool.js +6 -5
- package/build/src/cli/render/akuma.d.ts +36 -16
- package/build/src/cli/render/akuma.js +65 -132
- package/build/src/cli/render/audit.d.ts +6 -2
- package/build/src/cli/render/audit.js +59 -28
- package/build/src/cli/render/catalog.d.ts +11 -2
- package/build/src/cli/render/catalog.js +75 -95
- package/build/src/cli/render/contract-history.d.ts +3 -1
- package/build/src/cli/render/contract-history.js +215 -22
- package/build/src/cli/render/contract-observation.d.ts +10 -5
- package/build/src/cli/render/contract-observation.js +29 -46
- package/build/src/cli/render/contract.d.ts +10 -3
- package/build/src/cli/render/contract.js +252 -103
- package/build/src/cli/render/effects.d.ts +26 -0
- package/build/src/cli/render/effects.js +41 -0
- package/build/src/cli/render/execution-progress.d.ts +18 -6
- package/build/src/cli/render/execution-progress.js +34 -31
- package/build/src/cli/render/kanshi-akuma.d.ts +1 -2
- package/build/src/cli/render/kanshi-akuma.js +5 -26
- package/build/src/cli/render/kanshi.js +107 -128
- package/build/src/cli/render/marks.d.ts +13 -0
- package/build/src/cli/render/marks.js +74 -0
- package/build/src/cli/render/nuke.js +18 -7
- package/build/src/cli/render/receipt.d.ts +10 -4
- package/build/src/cli/render/receipt.js +124 -44
- package/build/src/cli/render/reconcile.d.ts +5 -0
- package/build/src/cli/render/reconcile.js +152 -0
- package/build/src/cli/render/refusal.d.ts +21 -4
- package/build/src/cli/render/refusal.js +60 -33
- package/build/src/cli/render/region.js +3 -2
- package/build/src/cli/render/settings.js +2 -12
- package/build/src/cli/render/task.d.ts +37 -6
- package/build/src/cli/render/task.js +161 -157
- package/build/src/cli/render/terminal.d.ts +20 -1
- package/build/src/cli/render/terminal.js +92 -18
- package/build/src/cli/runtime.d.ts +32 -8
- package/build/src/cli/runtime.js +157 -165
- package/build/src/cli/selectors.d.ts +5 -2
- package/build/src/cli/selectors.js +11 -3
- package/build/src/cli/streams.d.ts +11 -0
- package/build/src/cli/streams.js +32 -0
- package/build/src/cli/usage.d.ts +2 -0
- package/build/src/cli/usage.js +12 -8
- package/build/src/contract-guidance.js +3 -7
- package/build/src/contract-worktree.d.ts +20 -28
- package/build/src/contract-worktree.js +18 -70
- package/build/src/coordination/durable-file.d.ts +2 -2
- package/build/src/coordination/durable-file.js +0 -27
- package/build/src/core/facts/codec.d.ts +1 -2
- package/build/src/core/facts/codec.js +6 -7
- package/build/src/core/facts/gate.d.ts +0 -1
- package/build/src/core/facts/gate.js +0 -82
- package/build/src/core/facts/types.d.ts +1 -2
- package/build/src/core/verbs/abandon.d.ts +2 -6
- package/build/src/core/verbs/abandon.js +0 -16
- package/build/src/core/verbs/amend.d.ts +0 -1
- package/build/src/core/verbs/amend.js +0 -20
- package/build/src/core/verbs/arc.d.ts +7 -8
- package/build/src/core/verbs/arc.js +2 -19
- package/build/src/core/verbs/attestation.d.ts +2 -6
- package/build/src/core/verbs/attestation.js +0 -16
- package/build/src/core/verbs/bind.d.ts +0 -1
- package/build/src/core/verbs/bind.js +0 -16
- package/build/src/core/verbs/deliver.d.ts +0 -1
- package/build/src/core/verbs/deliver.js +0 -16
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +10 -59
- package/build/src/git/admission.d.ts +6 -4
- package/build/src/git/admission.js +4 -0
- package/build/src/git/hooks.d.ts +55 -30
- package/build/src/git/hooks.js +30 -3
- package/build/src/git/identity.d.ts +6 -0
- package/build/src/git/identity.js +47 -0
- package/build/src/git/integration.d.ts +31 -13
- package/build/src/git/integration.js +32 -1
- package/build/src/git/nuke.d.ts +10 -1
- package/build/src/git/nuke.js +31 -11
- package/build/src/git/observe.js +2 -15
- package/build/src/git/private-state-seat.d.ts +6 -7
- package/build/src/git/private-state-seat.js +8 -6
- package/build/src/git/read-observation.d.ts +6 -1
- package/build/src/git/read-observation.js +81 -46
- package/build/src/git/reconcile.d.ts +117 -40
- package/build/src/git/reconcile.js +169 -40
- package/build/src/git/scratch.d.ts +7 -4
- package/build/src/git/scratch.js +28 -6
- package/build/src/git/target-placement.d.ts +53 -38
- package/build/src/git/target-placement.js +69 -54
- package/build/src/git/tender.d.ts +37 -28
- package/build/src/git/tender.js +39 -0
- package/build/src/git/terminal-reconcile.js +21 -23
- package/build/src/git/terminal-seal.d.ts +8 -6
- package/build/src/git/terminal-seal.js +10 -0
- package/build/src/git/workspace.d.ts +29 -15
- package/build/src/git/workspace.js +28 -2
- package/build/src/identity/normalize.js +19 -6
- package/build/src/index.d.ts +78 -7
- package/build/src/index.js +52 -4
- package/build/src/kanshi/read.d.ts +3 -3
- package/build/src/kanshi/read.js +21 -21
- package/build/src/kanshi/report.d.ts +9 -8
- package/build/src/kanshi/roster.d.ts +2 -0
- package/build/src/kanshi/roster.js +2 -0
- package/build/src/kanshi/select.js +7 -3
- package/build/src/library/address.d.ts +3 -7
- package/build/src/library/address.js +7 -7
- package/build/src/library/akuma-creation.d.ts +21 -32
- package/build/src/library/akuma-creation.js +148 -165
- package/build/src/library/akumas.d.ts +20 -22
- package/build/src/library/akumas.js +43 -20
- package/build/src/library/bind.d.ts +107 -13
- package/build/src/library/bind.js +29 -23
- package/build/src/library/continuation.d.ts +556 -28
- package/build/src/library/continuation.js +29 -54
- package/build/src/library/contract-composition.d.ts +40 -0
- package/build/src/library/contract-composition.js +105 -0
- package/build/src/library/contract-creation.d.ts +7 -0
- package/build/src/library/contract-creation.js +192 -0
- package/build/src/library/contract-execution.d.ts +29 -40
- package/build/src/library/contract-execution.js +503 -128
- package/build/src/library/contract-operations.d.ts +275 -134
- package/build/src/library/contract-operations.js +83 -92
- package/build/src/library/contract-outcomes.d.ts +71 -0
- package/build/src/library/contract-outcomes.js +32 -0
- package/build/src/library/contract-settings.d.ts +25 -0
- package/build/src/library/contract-settings.js +135 -0
- package/build/src/library/contract-types.d.ts +17 -38
- package/build/src/library/delivery.d.ts +530 -10
- package/build/src/library/delivery.js +20 -45
- package/build/src/library/input.d.ts +3 -1
- package/build/src/library/input.js +11 -16
- package/build/src/library/invocation.d.ts +87 -0
- package/build/src/library/invocation.js +290 -0
- package/build/src/library/keiyaku.d.ts +45 -22
- package/build/src/library/keiyaku.js +134 -8
- package/build/src/library/nuke.d.ts +2 -11
- package/build/src/library/nuke.js +70 -57
- package/build/src/library/outcome.d.ts +13196 -0
- package/build/src/library/outcome.js +487 -0
- package/build/src/library/reconcile.d.ts +96 -24
- package/build/src/library/reconcile.js +102 -42
- package/build/src/library/refusal.d.ts +470 -42
- package/build/src/library/refusal.js +55 -143
- package/build/src/library/region.d.ts +15 -7
- package/build/src/library/region.js +23 -3
- package/build/src/library/repo.d.ts +2 -12
- package/build/src/library/repo.js +1 -22
- package/build/src/library/selection.d.ts +121 -0
- package/build/src/library/{fleet.js → selection.js} +169 -152
- package/build/src/plugin/public.d.ts +2 -0
- package/build/src/protocol/abandon.d.ts +2 -2
- package/build/src/protocol/abandon.js +1 -0
- package/build/src/protocol/amend.js +1 -0
- package/build/src/protocol/arc.d.ts +6 -4
- package/build/src/protocol/attempt.d.ts +4 -2
- package/build/src/protocol/attempt.js +10 -0
- package/build/src/protocol/audit.d.ts +255 -52
- package/build/src/protocol/audit.js +63 -5
- package/build/src/protocol/bind.d.ts +18 -17
- package/build/src/protocol/bind.js +9 -28
- package/build/src/protocol/completion.d.ts +256 -22
- package/build/src/protocol/completion.js +100 -12
- package/build/src/protocol/deliver.d.ts +34 -23
- package/build/src/protocol/deliver.js +39 -25
- package/build/src/protocol/execution-observation.d.ts +36 -37
- package/build/src/protocol/execution-observation.js +7 -9
- package/build/src/protocol/intent.d.ts +101 -30
- package/build/src/protocol/intent.js +74 -1
- package/build/src/protocol/operations.d.ts +570 -64
- package/build/src/protocol/operations.js +189 -9
- package/build/src/protocol/outcome.d.ts +2 -1
- package/build/src/protocol/placement.d.ts +2 -2
- package/build/src/protocol/placement.js +3 -1
- package/build/src/protocol/progress.d.ts +108 -65
- package/build/src/protocol/progress.js +82 -132
- package/build/src/protocol/read/status.d.ts +4 -3
- package/build/src/protocol/read/status.js +6 -5
- package/build/src/protocol/reconcile.d.ts +3 -3
- package/build/src/protocol/reconcile.js +4 -0
- package/build/src/protocol/reintegrate.d.ts +2 -2
- package/build/src/protocol/review.d.ts +30 -12
- package/build/src/protocol/review.js +15 -24
- package/build/src/protocol/run.d.ts +34 -5
- package/build/src/protocol/run.js +24 -12
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +0 -10
- package/build/src/settings.js +0 -76
- package/build/src/settlement/holder.d.ts +1 -1
- package/build/src/settlement/settle.d.ts +25 -16
- package/build/src/settlement/settle.js +80 -20
- package/build/src/task/board.d.ts +3 -1
- package/build/src/task/board.js +13 -17
- package/build/src/task/catalog.d.ts +0 -4
- package/build/src/task/catalog.js +0 -15
- package/build/src/task/compose-language.d.ts +19 -9
- package/build/src/task/compose-language.js +30 -20
- package/build/src/task/compose.d.ts +7 -37
- package/build/src/task/compose.js +20 -2
- package/build/src/task/created-observation.d.ts +0 -1
- package/build/src/task/created-observation.js +1 -4
- package/build/src/task/document.d.ts +12 -2
- package/build/src/task/document.js +4 -0
- package/build/src/task/identity.d.ts +4 -1
- package/build/src/task/identity.js +21 -17
- package/build/src/task/index.d.ts +36 -16
- package/build/src/task/index.js +103 -96
- package/build/src/task/lifecycle-operations.d.ts +1 -1
- package/build/src/task/mutation-result.d.ts +647 -586
- package/build/src/task/mutation-result.js +79 -46
- package/build/src/task/mutation.d.ts +298 -270
- package/build/src/task/mutation.js +93 -110
- package/build/src/task/operation-types.d.ts +6 -49
- package/build/src/task/operations.d.ts +2 -1
- package/build/src/task/operations.js +35 -12
- package/build/src/task/query.d.ts +9 -3
- package/build/src/task/query.js +42 -16
- package/build/src/task/store.d.ts +2 -1
- package/build/src/task/store.js +10 -14
- package/build/src/verification/declaration.d.ts +0 -1
- package/build/src/verification/declaration.js +1 -18
- package/build/src/verification/execution.d.ts +6 -2
- package/build/src/verification/observation.d.ts +1 -1
- package/package.json +2 -18
- package/build/src/akuma/akuma-product.d.ts +0 -58
- package/build/src/akuma/akuma-product.js +0 -276
- package/build/src/akuma/fleet-execution.js +0 -234
- package/build/src/akuma/fleet-observation.js +0 -97
- package/build/src/cli/accepted.d.ts +0 -24
- package/build/src/cli/accepted.js +0 -167
- package/build/src/cli/catalog.d.ts +0 -45
- package/build/src/cli/catalog.js +0 -1
- package/build/src/cli/commands/akuma-invoke.d.ts +0 -114
- package/build/src/cli/commands/akuma-invoke.js +0 -375
- package/build/src/cli/commands/contract-invoke.d.ts +0 -34
- package/build/src/cli/commands/contract-invoke.js +0 -259
- package/build/src/cli/commands/nuke.d.ts +0 -10
- package/build/src/cli/commands/nuke.js +0 -20
- package/build/src/cli/commands/status-set.d.ts +0 -4
- package/build/src/cli/commands/status-set.js +0 -52
- package/build/src/cli/commands/task-invoke.d.ts +0 -49
- package/build/src/cli/commands/task-invoke.js +0 -306
- package/build/src/cli/invoke.d.ts +0 -27
- package/build/src/cli/invoke.js +0 -521
- package/build/src/cli/render/board.d.ts +0 -3
- package/build/src/cli/render/board.js +0 -25
- package/build/src/cli/render/status-set.d.ts +0 -5
- package/build/src/cli/render/status-set.js +0 -19
- package/build/src/cli/render/text.d.ts +0 -3
- package/build/src/cli/render/text.js +0 -33
- package/build/src/cli/result.d.ts +0 -240
- package/build/src/cli/result.js +0 -1
- package/build/src/git/result-codec.d.ts +0 -29
- package/build/src/git/result-codec.js +0 -309
- package/build/src/kanshi/fleet.d.ts +0 -6
- package/build/src/kanshi/fleet.js +0 -27
- package/build/src/library/audit.d.ts +0 -29
- package/build/src/library/audit.js +0 -41
- package/build/src/library/composition.d.ts +0 -15
- package/build/src/library/composition.js +0 -28
- package/build/src/library/configuration.d.ts +0 -4
- package/build/src/library/configuration.js +0 -2
- package/build/src/library/contract-bind.d.ts +0 -31
- package/build/src/library/contract-bind.js +0 -140
- package/build/src/library/contract-forwarding.d.ts +0 -55
- package/build/src/library/contract-forwarding.js +0 -67
- package/build/src/library/contract-handle.d.ts +0 -50
- package/build/src/library/contract-handle.js +0 -385
- package/build/src/library/contract.d.ts +0 -46
- package/build/src/library/contract.js +0 -73
- package/build/src/library/execution-result.d.ts +0 -243
- package/build/src/library/execution-result.js +0 -101
- package/build/src/library/execution.d.ts +0 -8
- package/build/src/library/execution.js +0 -102
- package/build/src/library/fleet.d.ts +0 -83
- package/build/src/library/mutation.d.ts +0 -501
- package/build/src/library/mutation.js +0 -248
- package/build/src/library/result-codec.d.ts +0 -2
- package/build/src/library/result-codec.js +0 -12
- package/build/src/protocol/result-codec.d.ts +0 -23
- package/build/src/protocol/result-codec.js +0 -488
- package/build/src/settlement/result-codec.d.ts +0 -2
- package/build/src/settlement/result-codec.js +0 -56
- package/build/src/task/public.d.ts +0 -2
- package/build/src/task/public.js +0 -1
|
@@ -1,268 +1,656 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { listArchetypeDefinitions } from "../../akuma/archetype.js";
|
|
2
|
+
import { executionChannel } from "../../akuma/requests.js";
|
|
3
|
+
import { Akumas, Keiyaku, KeiyakuError, nuke } from "../../index.js";
|
|
4
|
+
import { kanshi, observeKanshi, selectKanshi, selectRegion } from "../../kanshi/index.js";
|
|
5
|
+
import { resolveNamedAddress } from "../../library/address.js";
|
|
6
|
+
import { composeContractLibrary, observeKeiyaku } from "../../library/contract-composition.js";
|
|
7
|
+
import { validateArcMarkdown, validateContractMarkdown } from "../../library/input.js";
|
|
8
|
+
import { createKeiyakuHandle } from "../../library/keiyaku.js";
|
|
9
|
+
import { SettingsError, settings } from "../../settings.js";
|
|
10
|
+
import { Tasks } from "../../task/index.js";
|
|
11
|
+
import { actorFromEdge } from "../actor.js";
|
|
12
|
+
import { resolveInvocationCwd } from "../coordinates.js";
|
|
13
|
+
import { BindDraftError, preserveBindDraft } from "../draft.js";
|
|
14
|
+
import { snapshotText } from "../render/akuma-activity.js";
|
|
15
|
+
import { renderAkumaCatalogue, renderArchetypeCatalogue, renderContractCatalogue, renderTaskCatalogue, } from "../render/catalog.js";
|
|
16
|
+
import { renderAccepted, renderContractHistory, renderRetry } from "../render/contract.js";
|
|
17
|
+
import { renderKanshiText } from "../render/kanshi.js";
|
|
18
|
+
import { nukeExitCode, renderNukeText } from "../render/nuke.js";
|
|
19
|
+
import { reconcileHasFailure, renderReconcile } from "../render/reconcile.js";
|
|
20
|
+
import { renderConflictMaterialized, renderRefusal } from "../render/refusal.js";
|
|
21
|
+
import { renderRegionText } from "../render/region.js";
|
|
22
|
+
import { renderSettingsText, settingsJsonValue } from "../render/settings.js";
|
|
23
|
+
import { canonicalContractSelector, contractFromInput, resolveContractId, resolveKanshiContract, } from "../selectors.js";
|
|
24
|
+
import { displayContext, writeJson, writeStdout } from "../streams.js";
|
|
25
|
+
import { CliUsageError, isBlankInput } from "../usage.js";
|
|
26
|
+
import { amendFromCommand } from "./amend.js";
|
|
27
|
+
import { bindFromCommand } from "./bind.js";
|
|
28
|
+
function requiredRepo(coordinates) {
|
|
29
|
+
if (coordinates.repo === undefined)
|
|
30
|
+
throw new CliUsageError("this command requires a resolved Repo");
|
|
31
|
+
return coordinates.repo;
|
|
32
|
+
}
|
|
33
|
+
async function settingsAt(root, home) {
|
|
34
|
+
return settings({
|
|
35
|
+
...(root === undefined ? {} : { root }),
|
|
36
|
+
...(home === undefined ? {} : { home }),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The process edge loads one Settings value and hands it to the private composition.
|
|
41
|
+
* A forwarded audit/deliver/review is served by its parent, which loads its own.
|
|
42
|
+
*/
|
|
43
|
+
async function contractSettings(command, execution, world, home) {
|
|
44
|
+
const forwarded = executionChannel(execution).kind === "body-request" &&
|
|
45
|
+
(command.command === "audit" || command.command === "deliver" || command.command === "review");
|
|
46
|
+
if (forwarded)
|
|
26
47
|
return undefined;
|
|
27
|
-
|
|
28
|
-
return [];
|
|
29
|
-
const names = value.split(",");
|
|
30
|
-
if (names.some((name) => name.length === 0)) {
|
|
31
|
-
refuse(command, '--gates requires comma-separated names or "" to clear gates');
|
|
32
|
-
}
|
|
33
|
-
return names;
|
|
34
|
-
}
|
|
35
|
-
function parseBind(parts) {
|
|
36
|
-
const forkOf = optionalFlag(parts.flags, "fork-of");
|
|
37
|
-
if (forkOf !== undefined) {
|
|
38
|
-
if (parts.stdin)
|
|
39
|
-
refuse("bind", "fork bind reads no stdin");
|
|
40
|
-
for (const option of ["task", "after", "gates"]) {
|
|
41
|
-
if (parts.flags[option] !== undefined)
|
|
42
|
-
refuse("bind", `--${option} is not valid with --fork-of`);
|
|
43
|
-
}
|
|
44
|
-
const target = optionalFlag(parts.flags, "target");
|
|
45
|
-
return {
|
|
46
|
-
command: "bind",
|
|
47
|
-
forkOf,
|
|
48
|
-
...(target === undefined ? {} : { target }),
|
|
49
|
-
...(parts.actor === undefined ? {} : { actor: parts.actor }),
|
|
50
|
-
output: parts.output,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (!parts.stdin)
|
|
54
|
-
refuse("bind", "bind requires stdin");
|
|
55
|
-
const task = optionalFlag(parts.flags, "task");
|
|
56
|
-
const target = optionalFlag(parts.flags, "target");
|
|
57
|
-
const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
|
|
58
|
-
const gates = parseGateNames(parts, "bind");
|
|
59
|
-
return {
|
|
60
|
-
command: "bind",
|
|
61
|
-
...(task === undefined ? {} : { task }),
|
|
62
|
-
...(target === undefined ? {} : { target }),
|
|
63
|
-
...(parts.flags.after === undefined ? {} : { after }),
|
|
64
|
-
...(gates === undefined ? {} : { gates }),
|
|
65
|
-
...(parts.actor === undefined ? {} : { actor: parts.actor }),
|
|
66
|
-
output: parts.output,
|
|
67
|
-
};
|
|
48
|
+
return await settingsAt(world ?? undefined, home);
|
|
68
49
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
|
|
72
|
-
if (parts.flags["clear-after"] === true && after.length > 0)
|
|
73
|
-
refuse("amend", "--clear-after and --after are mutually exclusive");
|
|
74
|
-
const gates = parseGateNames(parts, "amend");
|
|
75
|
-
if (!parts.stdin && parts.flags.after === undefined && parts.flags["clear-after"] !== true && gates === undefined) {
|
|
76
|
-
refuse("amend", "amend requires stdin or --after, --clear-after, or --gates");
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
command: "amend",
|
|
80
|
-
...(contract === undefined ? {} : { contract }),
|
|
81
|
-
...(parts.flags.after === undefined ? {} : { after }),
|
|
82
|
-
...(parts.flags["clear-after"] === true ? { clearAfter: true } : {}),
|
|
83
|
-
...(gates === undefined ? {} : { gates }),
|
|
84
|
-
...(parts.actor === undefined ? {} : { actor: parts.actor }),
|
|
85
|
-
...(parts.stdin ? { stdin: true } : {}),
|
|
86
|
-
output: parts.output,
|
|
87
|
-
};
|
|
50
|
+
function draftWarning(error) {
|
|
51
|
+
return { warning: `bind draft could not be preserved: ${error instanceof Error ? error.message : String(error)}` };
|
|
88
52
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
output: parts.output,
|
|
100
|
-
};
|
|
53
|
+
/** Preserve a refused bind draft at the invocation cwd; coordinates are not yet available. */
|
|
54
|
+
async function bindDraftReceiptAtCwd(input, markdown) {
|
|
55
|
+
try {
|
|
56
|
+
return await preserveBindDraft(await resolveInvocationCwd(input), markdown);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof Error && "executionReceipt" in error)
|
|
60
|
+
throw error;
|
|
61
|
+
return draftWarning(error);
|
|
62
|
+
}
|
|
101
63
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The one bind-document admission that runs before coordinate resolution, so a malformed document
|
|
66
|
+
* refuses as a draft-bearing refusal instead of a later Repo/Git failure. Reads the memoized stdin.
|
|
67
|
+
*/
|
|
68
|
+
export async function admitBindMarkdown(input) {
|
|
69
|
+
if (isBlankInput(input.markdown))
|
|
70
|
+
throw new CliUsageError("bind requires a nonblank stdin document");
|
|
71
|
+
try {
|
|
72
|
+
validateContractMarkdown(input.markdown);
|
|
105
73
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof Error && "executionReceipt" in error)
|
|
76
|
+
throw error;
|
|
77
|
+
if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
|
|
78
|
+
throw error;
|
|
79
|
+
throw new BindDraftError(error, await bindDraftReceiptAtCwd(input, input.markdown));
|
|
109
80
|
}
|
|
110
|
-
const contract = parts.positionals[0];
|
|
111
|
-
return {
|
|
112
|
-
command: "review",
|
|
113
|
-
...(contract === undefined ? {} : { contract }),
|
|
114
|
-
verdict: parts.flags.satisfied === true ? "satisfied" : "unsatisfied",
|
|
115
|
-
...(summary === undefined ? {} : { summary }),
|
|
116
|
-
...(parts.stdin ? { summaryFromStdin: true } : {}),
|
|
117
|
-
output: parts.output,
|
|
118
|
-
};
|
|
119
81
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
return
|
|
82
|
+
async function bindDraftReceipt(world, markdown) {
|
|
83
|
+
try {
|
|
84
|
+
return await preserveBindDraft(await world(), markdown);
|
|
123
85
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (error instanceof Error && "executionReceipt" in error)
|
|
88
|
+
throw error;
|
|
89
|
+
return draftWarning(error);
|
|
127
90
|
}
|
|
128
|
-
return { command: "status", ...(contract === undefined ? {} : { contract }), output: parts.output };
|
|
129
91
|
}
|
|
130
|
-
function
|
|
131
|
-
const
|
|
132
|
-
const pathFlag = parts.flags.path;
|
|
133
|
-
const paths = pathFlag === undefined ? undefined : Array.isArray(pathFlag) ? pathFlag : [pathFlag];
|
|
134
|
-
if (paths !== undefined && contract !== undefined)
|
|
135
|
-
refuse("region", "--path cannot combine with a contract");
|
|
92
|
+
function refusedInvocation(answer, project) {
|
|
93
|
+
const refusal = project === undefined ? answer.refusal : project(answer.refusal);
|
|
136
94
|
return {
|
|
137
|
-
|
|
138
|
-
...(contract === undefined ? {} : { contract }),
|
|
139
|
-
|
|
140
|
-
output: parts.output,
|
|
95
|
+
operation: answer.operation,
|
|
96
|
+
...(answer.contract === undefined ? {} : { contract: answer.contract }),
|
|
97
|
+
refusal,
|
|
141
98
|
};
|
|
142
99
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
100
|
+
/** The CLI's own presentation of a refused dirty delivery: the available opt-in is not SDK evidence. */
|
|
101
|
+
function deliverRefusalProjection(refusal) {
|
|
102
|
+
if (refusal.kind !== "dirty-workspace")
|
|
103
|
+
return refusal;
|
|
104
|
+
const submodules = "submodules" in refusal && Array.isArray(refusal.submodules) ? refusal.submodules : [];
|
|
105
|
+
return { ...refusal, option: { flag: "--include-dirty", available: submodules.length === 0 } };
|
|
106
|
+
}
|
|
107
|
+
function contractExitCode(answer) {
|
|
108
|
+
return answer.kind === "refused" ? 1 : answer.kind === "retry" ? 2 : 0;
|
|
109
|
+
}
|
|
110
|
+
function renderContractAnswer(answer, project, context) {
|
|
111
|
+
switch (answer.kind) {
|
|
112
|
+
case "handoff":
|
|
113
|
+
return renderConflictMaterialized(answer.value, context);
|
|
114
|
+
case "refused":
|
|
115
|
+
return renderRefusal(refusedInvocation(answer, project), undefined, context);
|
|
116
|
+
case "retry":
|
|
117
|
+
return renderRetry(answer, context);
|
|
118
|
+
case "accepted":
|
|
119
|
+
return renderAccepted(answer, context);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function finishContractAnswer(answer, output, project) {
|
|
123
|
+
if (output === "json")
|
|
124
|
+
writeJson(answer);
|
|
125
|
+
else
|
|
126
|
+
writeStdout(renderContractAnswer(answer, project, displayContext()));
|
|
127
|
+
return contractExitCode(answer);
|
|
128
|
+
}
|
|
129
|
+
async function selectedContract(repo, selector, scope) {
|
|
130
|
+
const id = await resolveContractId(repo, selector, scope);
|
|
131
|
+
return { id, contract: contractFromInput(repo, id).contract };
|
|
132
|
+
}
|
|
133
|
+
async function existingSeat(command, coordinates, runtime, library) {
|
|
134
|
+
const repo = requiredRepo(coordinates);
|
|
135
|
+
const id = await resolveContractId(repo, command.contract, coordinates.cwd);
|
|
136
|
+
const actor = "actor" in command ? actorFromEdge(command.actor, runtime.environment) : undefined;
|
|
147
137
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
id,
|
|
139
|
+
contract: library.select({ repo, id }),
|
|
140
|
+
...(actor === undefined ? {} : { actor }),
|
|
150
141
|
};
|
|
151
142
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
143
|
+
/** One composition for every mutation leaf; gates, hooks, and freshness derive lazily inside it. */
|
|
144
|
+
async function contractLibrary(command, execution, configuration, runtime) {
|
|
145
|
+
const actor = executionChannel(execution).kind === "local" && ["audit", "deliver", "review"].includes(command.command)
|
|
146
|
+
? actorFromEdge(undefined, runtime.environment)
|
|
147
|
+
: undefined;
|
|
148
|
+
return composeContractLibrary(execution, createKeiyakuHandle, {
|
|
149
|
+
...(configuration === undefined ? {} : { settings: configuration }),
|
|
150
|
+
...(actor === undefined ? {} : { actor }),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async function runBind(command, input, library) {
|
|
154
|
+
const { coordinates, runtime } = input;
|
|
155
|
+
const repo = requiredRepo(coordinates);
|
|
156
|
+
const actor = actorFromEdge(command.actor, runtime.environment);
|
|
157
|
+
if (command.forkOf !== undefined) {
|
|
158
|
+
const answer = await bindFromCommand({
|
|
159
|
+
command,
|
|
160
|
+
repo,
|
|
161
|
+
library,
|
|
162
|
+
...(actor === undefined ? {} : { actor }),
|
|
163
|
+
});
|
|
164
|
+
return await finishContractAnswer(answer, command.output);
|
|
165
|
+
}
|
|
166
|
+
const markdown = await runtime.readStdin();
|
|
167
|
+
if (isBlankInput(markdown))
|
|
168
|
+
throw new CliUsageError("bind requires a nonblank stdin document");
|
|
169
169
|
try {
|
|
170
|
-
|
|
171
|
-
return { kind: "tasks", namespace, ...(limit === undefined ? {} : { limit }) };
|
|
170
|
+
validateContractMarkdown(markdown);
|
|
172
171
|
}
|
|
173
172
|
catch (error) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
function parseLs(parts) {
|
|
178
|
-
const path = parts.positionals[0];
|
|
179
|
-
const limit = listLimit(parts);
|
|
180
|
-
const taskQuery = taskCatalogQuery(path, limit);
|
|
181
|
-
if (taskQuery !== null)
|
|
182
|
-
return { command: "ls", query: taskQuery, output: parts.output };
|
|
183
|
-
if (path === "kei" || path === "kei/") {
|
|
184
|
-
return {
|
|
185
|
-
command: "ls",
|
|
186
|
-
query: { kind: "contracts", ...(limit === undefined ? {} : { limit }) },
|
|
187
|
-
output: parts.output,
|
|
188
|
-
};
|
|
173
|
+
if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
|
|
174
|
+
throw error;
|
|
175
|
+
throw new BindDraftError(error, await bindDraftReceipt(coordinates.establishWorld, markdown));
|
|
189
176
|
}
|
|
190
177
|
try {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
178
|
+
const answer = await bindFromCommand({
|
|
179
|
+
command,
|
|
180
|
+
repo,
|
|
181
|
+
library,
|
|
182
|
+
markdown,
|
|
183
|
+
...(actor === undefined ? {} : { actor }),
|
|
184
|
+
});
|
|
185
|
+
if (answer.kind !== "refused")
|
|
186
|
+
return await finishContractAnswer(answer, command.output);
|
|
187
|
+
const draft = await bindDraftReceipt(coordinates.establishWorld, markdown);
|
|
188
|
+
if (command.output === "json")
|
|
189
|
+
writeJson(answer);
|
|
190
|
+
else
|
|
191
|
+
writeStdout(renderRefusal(refusedInvocation(answer), draft, displayContext()));
|
|
192
|
+
return 1;
|
|
195
193
|
}
|
|
196
194
|
catch (error) {
|
|
197
|
-
if (error instanceof
|
|
195
|
+
if (error instanceof Error && "executionReceipt" in error)
|
|
198
196
|
throw error;
|
|
199
|
-
|
|
197
|
+
// A selected Settings namespace failure is the Contract owner's invalid input, not a bad draft.
|
|
198
|
+
if (error instanceof KeiyakuError && error.category === "invalid-input" && error.cause instanceof SettingsError)
|
|
199
|
+
throw error;
|
|
200
|
+
if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
|
|
201
|
+
throw error;
|
|
202
|
+
throw new BindDraftError(error, await bindDraftReceipt(coordinates.establishWorld, markdown));
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
async function runAmend(command, input, seat) {
|
|
206
|
+
const { coordinates, runtime } = input;
|
|
207
|
+
const markdown = command.stdin === true ? await runtime.readStdin() : undefined;
|
|
208
|
+
if (markdown !== undefined && isBlankInput(markdown))
|
|
209
|
+
throw new CliUsageError("amend requires a nonblank stdin document");
|
|
210
|
+
const answer = await amendFromCommand({
|
|
211
|
+
command,
|
|
212
|
+
repo: requiredRepo(coordinates),
|
|
213
|
+
contract: seat.contract,
|
|
214
|
+
...(markdown === undefined ? {} : { markdown }),
|
|
215
|
+
...(command.gates === undefined ? {} : { gates: command.gates }),
|
|
216
|
+
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
217
|
+
});
|
|
218
|
+
return await finishContractAnswer(answer, command.output);
|
|
219
|
+
}
|
|
220
|
+
async function runDeliver(command, runtime, seat) {
|
|
221
|
+
const driver = command.output === "text" ? await runtime.progress() : undefined;
|
|
222
|
+
let answer;
|
|
223
|
+
try {
|
|
224
|
+
answer = await seat.contract.deliver({
|
|
225
|
+
...(command.message === undefined ? {} : { message: command.message }),
|
|
226
|
+
includeDirty: command.includeDirty,
|
|
227
|
+
materializeConflict: command.materializeConflict,
|
|
228
|
+
overwrite: command.overwrite,
|
|
229
|
+
...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
|
|
230
|
+
}, { ...(driver === undefined ? {} : { observe: driver.observe }) });
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
if (driver !== undefined)
|
|
234
|
+
await driver.finish().catch(() => undefined);
|
|
235
|
+
}
|
|
236
|
+
return await finishContractAnswer(answer, command.output, deliverRefusalProjection);
|
|
237
|
+
}
|
|
238
|
+
async function runReview(command, runtime, seat) {
|
|
239
|
+
const summary = command.summaryFromStdin === true ? await runtime.readStdin() : command.summary;
|
|
240
|
+
if (command.summaryFromStdin === true && isBlankInput(summary ?? ""))
|
|
241
|
+
throw new CliUsageError("review requires a nonblank summary");
|
|
242
|
+
const driver = command.output === "text" ? await runtime.progress() : undefined;
|
|
243
|
+
let answer;
|
|
244
|
+
try {
|
|
245
|
+
answer = await seat.contract.review({
|
|
246
|
+
verdict: command.verdict,
|
|
247
|
+
...(summary === undefined ? {} : { summary }),
|
|
248
|
+
...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
|
|
249
|
+
}, { ...(driver === undefined ? {} : { observe: driver.observe }) });
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
if (driver !== undefined)
|
|
253
|
+
await driver.finish().catch(() => undefined);
|
|
254
|
+
}
|
|
255
|
+
return await finishContractAnswer(answer, command.output);
|
|
256
|
+
}
|
|
257
|
+
async function runArc(command, runtime, seat) {
|
|
258
|
+
const markdown = await runtime.readStdin();
|
|
259
|
+
try {
|
|
260
|
+
validateArcMarkdown(markdown);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
if (!(error instanceof TypeError) && !(error instanceof KeiyakuError && error.category === "invalid-input"))
|
|
264
|
+
throw error;
|
|
265
|
+
const refusal = { kind: "invalid-document", diagnostic: error.message };
|
|
266
|
+
if (command.output === "json")
|
|
267
|
+
writeJson({ kind: "refused", operation: "arc", contract: seat.id, refusal });
|
|
268
|
+
else
|
|
269
|
+
writeStdout(renderRefusal({ operation: "arc", contract: seat.id, refusal }, undefined, displayContext()));
|
|
270
|
+
return 1;
|
|
271
|
+
}
|
|
272
|
+
const answer = await seat.contract.arc({
|
|
273
|
+
markdown,
|
|
274
|
+
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
275
|
+
});
|
|
276
|
+
return await finishContractAnswer(answer, command.output);
|
|
277
|
+
}
|
|
278
|
+
async function runAbandon(command, seat) {
|
|
279
|
+
const answer = await seat.contract.abandon({
|
|
280
|
+
...(seat.actor === undefined ? {} : { actor: seat.actor }),
|
|
281
|
+
...(command.note === undefined ? {} : { note: command.note }),
|
|
282
|
+
});
|
|
283
|
+
return await finishContractAnswer(answer, command.output);
|
|
284
|
+
}
|
|
285
|
+
async function runAudit(command, runtime, seat) {
|
|
286
|
+
const driver = command.output === "text" ? await runtime.progress() : undefined;
|
|
287
|
+
let answer;
|
|
288
|
+
try {
|
|
289
|
+
answer = await seat.contract.audit({
|
|
290
|
+
includeDirty: command.includeDirty,
|
|
291
|
+
showDiff: command.showDiff,
|
|
292
|
+
...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
|
|
293
|
+
}, { ...(driver === undefined ? {} : { observe: driver.observe }) });
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
if (driver !== undefined)
|
|
297
|
+
await driver.finish().catch(() => undefined);
|
|
298
|
+
}
|
|
299
|
+
return await finishContractAnswer(answer, command.output, deliverRefusalProjection);
|
|
300
|
+
}
|
|
301
|
+
async function runContractMutation(command, input) {
|
|
302
|
+
const library = await contractLibrary(command, input.execution, input.configuration, input.runtime);
|
|
303
|
+
if (command.command === "bind")
|
|
304
|
+
return await runBind(command, input, library);
|
|
305
|
+
const seat = await existingSeat(command, input.coordinates, input.runtime, library);
|
|
306
|
+
switch (command.command) {
|
|
206
307
|
case "amend":
|
|
207
|
-
return
|
|
308
|
+
return await runAmend(command, input, seat);
|
|
208
309
|
case "deliver":
|
|
209
|
-
return
|
|
310
|
+
return await runDeliver(command, input.runtime, seat);
|
|
210
311
|
case "review":
|
|
211
|
-
return
|
|
212
|
-
case "arc":
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
312
|
+
return await runReview(command, input.runtime, seat);
|
|
313
|
+
case "arc":
|
|
314
|
+
return await runArc(command, input.runtime, seat);
|
|
315
|
+
case "abandon":
|
|
316
|
+
return await runAbandon(command, seat);
|
|
317
|
+
case "audit":
|
|
318
|
+
return await runAudit(command, input.runtime, seat);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function statusRefusal(operation, contract) {
|
|
322
|
+
return { operation, contract, refusal: { kind: "contract-missing", contractId: contract } };
|
|
323
|
+
}
|
|
324
|
+
async function runSettings(coordinates, home, output) {
|
|
325
|
+
const value = await settingsAt(coordinates.world ?? undefined, home);
|
|
326
|
+
if (output === "json")
|
|
327
|
+
writeJson(settingsJsonValue(value));
|
|
328
|
+
else
|
|
329
|
+
writeStdout(renderSettingsText(value, displayContext().columns));
|
|
330
|
+
return 0;
|
|
331
|
+
}
|
|
332
|
+
async function runNuke(command, coordinates) {
|
|
333
|
+
if (coordinates.world === null)
|
|
334
|
+
throw new CliUsageError("no Keiyaku world contains the invocation cwd");
|
|
335
|
+
const result = await nuke({
|
|
336
|
+
world: coordinates.world,
|
|
337
|
+
...(command.confirm === undefined ? {} : { confirm: command.confirm }),
|
|
338
|
+
});
|
|
339
|
+
if (command.output === "json")
|
|
340
|
+
writeJson(result);
|
|
341
|
+
else
|
|
342
|
+
writeStdout(renderNukeText(result));
|
|
343
|
+
return nukeExitCode(result);
|
|
344
|
+
}
|
|
345
|
+
async function runLs(command, coordinates, home) {
|
|
346
|
+
const query = command.query;
|
|
347
|
+
if (query.kind === "contracts") {
|
|
348
|
+
const list = await Keiyaku.with().list({
|
|
349
|
+
repo: requiredRepo(coordinates),
|
|
350
|
+
...(query.limit === undefined ? {} : { limit: query.limit }),
|
|
351
|
+
});
|
|
352
|
+
if (command.output === "json")
|
|
353
|
+
writeJson(list);
|
|
354
|
+
else
|
|
355
|
+
writeStdout(renderContractCatalogue(list));
|
|
356
|
+
return 0;
|
|
357
|
+
}
|
|
358
|
+
if (query.kind === "archetypes") {
|
|
359
|
+
const list = await listArchetypeDefinitions({
|
|
360
|
+
...(coordinates.world === null ? {} : { project: coordinates.world }),
|
|
361
|
+
...(query.limit === undefined ? {} : { limit: query.limit }),
|
|
362
|
+
...(home === undefined ? {} : { home }),
|
|
363
|
+
});
|
|
364
|
+
if (command.output === "json")
|
|
365
|
+
writeJson(list);
|
|
366
|
+
else
|
|
367
|
+
writeStdout(renderArchetypeCatalogue(list));
|
|
368
|
+
return 0;
|
|
369
|
+
}
|
|
370
|
+
if (coordinates.world === null)
|
|
371
|
+
throw new CliUsageError("no Keiyaku world contains the invocation cwd");
|
|
372
|
+
if (query.kind === "tasks") {
|
|
373
|
+
const listed = await Tasks.of(coordinates.world).list({
|
|
374
|
+
selection: "all",
|
|
375
|
+
namespace: query.namespace ?? [],
|
|
376
|
+
...(query.limit === undefined ? {} : { limit: query.limit }),
|
|
377
|
+
});
|
|
378
|
+
if (listed.kind !== "accepted")
|
|
379
|
+
throw new Error("Task list did not return an accepted observation");
|
|
380
|
+
if (command.output === "json")
|
|
381
|
+
writeJson(listed);
|
|
382
|
+
else
|
|
383
|
+
writeStdout(renderTaskCatalogue(listed.value, query.namespace ?? []));
|
|
384
|
+
return 0;
|
|
385
|
+
}
|
|
386
|
+
const listed = await Akumas.of(coordinates.world).list({
|
|
387
|
+
...(query.archetype === undefined ? {} : { archetype: query.archetype }),
|
|
388
|
+
...(query.limit === undefined ? {} : { limit: query.limit }),
|
|
389
|
+
});
|
|
390
|
+
if (command.output === "json")
|
|
391
|
+
writeJson(listed);
|
|
392
|
+
else
|
|
393
|
+
writeStdout(renderAkumaCatalogue(listed, query.archetype ?? null));
|
|
394
|
+
return 0;
|
|
395
|
+
}
|
|
396
|
+
async function readAkumaStatus(akuma, alias, coordinates) {
|
|
397
|
+
if (coordinates.world === null)
|
|
398
|
+
throw new CliUsageError("no Keiyaku world contains the Akuma selector");
|
|
399
|
+
const status = await Akumas.of(coordinates.world).status({
|
|
400
|
+
akuma,
|
|
401
|
+
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
402
|
+
});
|
|
403
|
+
return {
|
|
404
|
+
value: status,
|
|
405
|
+
project: () => snapshotText(status, displayContext(), ...(alias === undefined ? [{}] : [{ alias }])),
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
async function readContractStatus(selector, coordinates, named) {
|
|
409
|
+
const repo = requiredRepo(coordinates);
|
|
410
|
+
if (selector !== undefined && selector.startsWith("@")) {
|
|
411
|
+
if (named === undefined)
|
|
412
|
+
throw new CliUsageError("cannot resolve a named status selector");
|
|
413
|
+
const address = resolveNamedAddress({ selector, report: named.report, aliases: named.aliases });
|
|
414
|
+
if (address.kind === "akuma")
|
|
415
|
+
throw new CliUsageError("named status selector resolved to an Akuma");
|
|
416
|
+
const report = await kanshi({ world: coordinates.world, repo, contract: address.id });
|
|
417
|
+
return { value: report, project: () => renderKanshiText(report, displayContext(), "contract") };
|
|
418
|
+
}
|
|
419
|
+
const contract = selector === undefined ? undefined : canonicalContractSelector(selector);
|
|
420
|
+
const report = await kanshi({ world: coordinates.world, repo, ...(contract === undefined ? {} : { contract }) });
|
|
421
|
+
return { value: report, project: () => renderKanshiText(report, displayContext(), "contract") };
|
|
422
|
+
}
|
|
423
|
+
async function namedStatus(selector, coordinates, named) {
|
|
424
|
+
if (named === undefined)
|
|
425
|
+
throw new CliUsageError("cannot resolve a named status selector");
|
|
426
|
+
const address = resolveNamedAddress({ selector, report: named.report, aliases: named.aliases });
|
|
427
|
+
if (address.kind === "akuma")
|
|
428
|
+
return await readAkumaStatus(address.id, selector, coordinates);
|
|
429
|
+
return await readContractStatus(address.id, coordinates, named);
|
|
430
|
+
}
|
|
431
|
+
async function runStatusGuidance(command, coordinates) {
|
|
432
|
+
const repo = coordinates.repo;
|
|
433
|
+
if (repo === undefined)
|
|
434
|
+
throw new CliUsageError("cannot select a contract while the Contract world is absent");
|
|
435
|
+
const selected = await selectedContract(repo, command.contract, coordinates.cwd);
|
|
436
|
+
const guidance = await selected.contract.guidance();
|
|
437
|
+
if (guidance === null) {
|
|
438
|
+
if (command.output === "json")
|
|
439
|
+
writeJson(null);
|
|
440
|
+
else
|
|
441
|
+
writeStdout(renderRefusal(statusRefusal("status", selected.id), undefined, displayContext()));
|
|
442
|
+
return 1;
|
|
443
|
+
}
|
|
444
|
+
if (command.output === "json")
|
|
445
|
+
writeJson(guidance);
|
|
446
|
+
else
|
|
447
|
+
writeStdout(guidance);
|
|
448
|
+
return 0;
|
|
449
|
+
}
|
|
450
|
+
async function runStatusSelection(command, coordinates) {
|
|
451
|
+
const selectors = command.selectors;
|
|
452
|
+
if (selectors.length < 2)
|
|
453
|
+
throw new CliUsageError("status requires at least two selectors");
|
|
454
|
+
if (selectors.some((selector) => !selector.startsWith("aku/") && !selector.startsWith("@")) &&
|
|
455
|
+
coordinates.repo === undefined)
|
|
456
|
+
throw new CliUsageError("cannot select a contract while the Contract world is absent");
|
|
457
|
+
const named = selectors.some((selector) => selector.startsWith("@"))
|
|
458
|
+
? await observeKanshi({
|
|
459
|
+
world: coordinates.world,
|
|
460
|
+
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
461
|
+
})
|
|
462
|
+
: undefined;
|
|
463
|
+
const values = [];
|
|
464
|
+
const blocks = [];
|
|
465
|
+
for (const selector of selectors) {
|
|
466
|
+
const resolved = selector.startsWith("aku/")
|
|
467
|
+
? await readAkumaStatus(selector, undefined, coordinates)
|
|
468
|
+
: selector.startsWith("@")
|
|
469
|
+
? await namedStatus(selector, coordinates, named)
|
|
470
|
+
: await readContractStatus(selector, coordinates, named);
|
|
471
|
+
values.push(resolved.value);
|
|
472
|
+
if (command.output === "text")
|
|
473
|
+
blocks.push(resolved.project());
|
|
474
|
+
}
|
|
475
|
+
if (command.output === "json")
|
|
476
|
+
writeJson(values);
|
|
477
|
+
else
|
|
478
|
+
writeStdout(blocks.join("\n\n"));
|
|
479
|
+
return 0;
|
|
480
|
+
}
|
|
481
|
+
async function runStatus(command, coordinates) {
|
|
482
|
+
if (command.guidance === true)
|
|
483
|
+
return await runStatusGuidance(command, coordinates);
|
|
484
|
+
if ("selectors" in command && command.selectors !== undefined)
|
|
485
|
+
return await runStatusSelection({ ...command, selectors: command.selectors }, coordinates);
|
|
486
|
+
if (command.akuma === true && command.contract !== undefined) {
|
|
487
|
+
const resolved = await readAkumaStatus(command.contract, undefined, coordinates);
|
|
488
|
+
if (command.output === "json")
|
|
489
|
+
writeJson(resolved.value);
|
|
490
|
+
else
|
|
491
|
+
writeStdout(resolved.project());
|
|
492
|
+
return 0;
|
|
493
|
+
}
|
|
494
|
+
if (command.contract === undefined) {
|
|
495
|
+
const report = await kanshi({
|
|
496
|
+
world: coordinates.world,
|
|
497
|
+
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
498
|
+
});
|
|
499
|
+
if (command.output === "json")
|
|
500
|
+
writeJson(report);
|
|
501
|
+
else
|
|
502
|
+
writeStdout(renderKanshiText(report, displayContext(), "world"));
|
|
503
|
+
return 0;
|
|
504
|
+
}
|
|
505
|
+
if (command.contract.startsWith("@")) {
|
|
506
|
+
const resolved = await namedStatus(command.contract, coordinates, await observeKanshi({
|
|
507
|
+
world: coordinates.world,
|
|
508
|
+
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
509
|
+
}));
|
|
510
|
+
if (command.output === "json")
|
|
511
|
+
writeJson(resolved.value);
|
|
512
|
+
else
|
|
513
|
+
writeStdout(resolved.project());
|
|
514
|
+
return 0;
|
|
515
|
+
}
|
|
516
|
+
if (command.contract.startsWith("kei/")) {
|
|
517
|
+
const repo = requiredRepo(coordinates);
|
|
518
|
+
const contract = canonicalContractSelector(command.contract);
|
|
519
|
+
const report = await kanshi({ world: coordinates.world, repo, contract });
|
|
520
|
+
if (report.contracts.kind === "present" && report.contracts.value.rows.length === 0) {
|
|
521
|
+
if (command.output === "json")
|
|
522
|
+
writeJson(statusRefusal("status", contract).refusal);
|
|
523
|
+
else
|
|
524
|
+
writeStdout(renderRefusal(statusRefusal("status", contract), undefined, displayContext()));
|
|
525
|
+
return 1;
|
|
258
526
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
527
|
+
if (command.output === "json")
|
|
528
|
+
writeJson(report);
|
|
529
|
+
else
|
|
530
|
+
writeStdout(renderKanshiText(report, displayContext(), "contract"));
|
|
531
|
+
return 0;
|
|
532
|
+
}
|
|
533
|
+
const report = await kanshi({
|
|
534
|
+
world: coordinates.world,
|
|
535
|
+
...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
|
|
536
|
+
});
|
|
537
|
+
const contract = resolveKanshiContract(report, command.contract);
|
|
538
|
+
const selected = selectKanshi({ report, contract });
|
|
539
|
+
if (command.output === "json")
|
|
540
|
+
writeJson(selected);
|
|
541
|
+
else
|
|
542
|
+
writeStdout(renderKanshiText(selected, displayContext(), "contract"));
|
|
543
|
+
return 0;
|
|
544
|
+
}
|
|
545
|
+
async function runRegion(command, coordinates) {
|
|
546
|
+
const repo = requiredRepo(coordinates);
|
|
547
|
+
const emit = (section) => {
|
|
548
|
+
if (command.output === "json")
|
|
549
|
+
writeJson(section);
|
|
550
|
+
else
|
|
551
|
+
writeStdout(renderRegionText(section));
|
|
552
|
+
return 0;
|
|
553
|
+
};
|
|
554
|
+
if (command.paths !== undefined) {
|
|
555
|
+
const report = await kanshi({ world: coordinates.world, repo, region: { kind: "path", patterns: command.paths } });
|
|
556
|
+
return emit(report.region ?? { kind: "absent" });
|
|
557
|
+
}
|
|
558
|
+
const report = await kanshi({ world: coordinates.world, repo, region: { kind: "declarations" } });
|
|
559
|
+
if (command.contract === undefined)
|
|
560
|
+
return emit(report.region ?? { kind: "absent" });
|
|
561
|
+
const contract = resolveKanshiContract(report, command.contract);
|
|
562
|
+
const observed = await observeKeiyaku({ repo, id: contract });
|
|
563
|
+
if (observed.kind === "missing" || observed.row.phase === "claimed" || observed.row.phase === "abandoned") {
|
|
564
|
+
const refusal = {
|
|
565
|
+
kind: observed.kind === "missing" ? "contract-missing" : "terminal",
|
|
566
|
+
contractId: contract,
|
|
567
|
+
};
|
|
568
|
+
if (command.output === "json")
|
|
569
|
+
writeJson(refusal);
|
|
570
|
+
else
|
|
571
|
+
writeStdout(renderRefusal({ operation: "region", contract, refusal }, undefined, displayContext()));
|
|
572
|
+
return 1;
|
|
573
|
+
}
|
|
574
|
+
if (report.region?.kind !== "present" || report.region.value.kind !== "declarations")
|
|
575
|
+
return emit(report.region ?? { kind: "absent" });
|
|
576
|
+
return emit({
|
|
577
|
+
kind: "present",
|
|
578
|
+
value: selectRegion({
|
|
579
|
+
declarations: report.region.value.declarations,
|
|
580
|
+
selection: { kind: "contract", contract },
|
|
581
|
+
}),
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
export async function runContractHistoryCommand(command, coordinates) {
|
|
585
|
+
const repo = requiredRepo(coordinates);
|
|
586
|
+
const selected = contractFromInput(repo, command.contract);
|
|
587
|
+
const history = await selected.contract.history();
|
|
588
|
+
if (history === null) {
|
|
589
|
+
const refusal = { kind: "contract-missing", contractId: selected.id };
|
|
590
|
+
if (command.output === "json")
|
|
591
|
+
writeJson(refusal);
|
|
592
|
+
else
|
|
593
|
+
writeStdout(renderRefusal({ operation: "history", contract: selected.id, refusal }, undefined, displayContext()));
|
|
594
|
+
return 1;
|
|
595
|
+
}
|
|
596
|
+
if (command.output === "json")
|
|
597
|
+
writeJson(history);
|
|
598
|
+
else
|
|
599
|
+
writeStdout(renderContractHistory(history, { full: command.full }));
|
|
600
|
+
return 0;
|
|
601
|
+
}
|
|
602
|
+
async function runReconcile(command, coordinates, execution, home) {
|
|
603
|
+
const repo = requiredRepo(coordinates);
|
|
604
|
+
const configuration = await contractSettings(command, execution, coordinates.world, home);
|
|
605
|
+
const library = composeContractLibrary(execution, createKeiyakuHandle, {
|
|
606
|
+
...(configuration === undefined ? {} : { settings: configuration }),
|
|
607
|
+
});
|
|
608
|
+
let report;
|
|
609
|
+
if (command.contract === undefined) {
|
|
610
|
+
report = await library.reconcile({ repo, retryHooks: command.retryHooks });
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
const selected = await selectedContract(repo, command.contract, coordinates.cwd);
|
|
614
|
+
const observed = await observeKeiyaku({ repo, id: selected.id });
|
|
615
|
+
if (observed.kind === "missing") {
|
|
616
|
+
if (command.output === "json")
|
|
617
|
+
writeJson(statusRefusal("reconcile", selected.id).refusal);
|
|
618
|
+
else
|
|
619
|
+
writeStdout(renderRefusal(statusRefusal("reconcile", selected.id), undefined, displayContext()));
|
|
620
|
+
return 1;
|
|
262
621
|
}
|
|
622
|
+
report = await library.reconcile({ repo, contract: selected.id, retryHooks: command.retryHooks });
|
|
623
|
+
}
|
|
624
|
+
if (command.output === "json")
|
|
625
|
+
writeJson(report);
|
|
626
|
+
else
|
|
627
|
+
writeStdout(renderReconcile(report, displayContext()));
|
|
628
|
+
return reconcileHasFailure(report) ? 1 : 0;
|
|
629
|
+
}
|
|
630
|
+
export async function runContractCommand(command, coordinates, runtime) {
|
|
631
|
+
const execution = runtime.execution;
|
|
632
|
+
const home = runtime.home;
|
|
633
|
+
switch (command.command) {
|
|
263
634
|
case "settings":
|
|
264
|
-
return
|
|
635
|
+
return await runSettings(coordinates, home, command.output);
|
|
636
|
+
case "nuke":
|
|
637
|
+
return await runNuke(command, coordinates);
|
|
638
|
+
case "ls":
|
|
639
|
+
return await runLs(command, coordinates, home);
|
|
640
|
+
case "status":
|
|
641
|
+
return await runStatus(command, coordinates);
|
|
265
642
|
case "region":
|
|
266
|
-
return
|
|
643
|
+
return await runRegion(command, coordinates);
|
|
644
|
+
case "reconcile":
|
|
645
|
+
return await runReconcile(command, coordinates, execution, home);
|
|
646
|
+
default: {
|
|
647
|
+
const configuration = await contractSettings(command, execution, coordinates.world, home);
|
|
648
|
+
return await runContractMutation(command, {
|
|
649
|
+
coordinates,
|
|
650
|
+
runtime,
|
|
651
|
+
execution,
|
|
652
|
+
...(configuration === undefined ? {} : { configuration }),
|
|
653
|
+
});
|
|
654
|
+
}
|
|
267
655
|
}
|
|
268
656
|
}
|