@astrosheep/keiyaku 4.0.0 → 4.0.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/README.md +133 -8
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +4 -4
- package/build/integrations/marketplace/plugins/keiyaku/opencode.js +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/package.json +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +13 -5
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -32
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +134 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +41 -6
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +262 -46
- package/build/src/akuma/abort.d.ts +2 -0
- package/build/src/akuma/abort.js +50 -0
- package/build/src/akuma/akuma.d.ts +50 -33
- package/build/src/akuma/akuma.js +175 -127
- package/build/src/akuma/archetype.d.ts +14 -5
- package/build/src/akuma/archetype.js +85 -39
- package/build/src/akuma/body.d.ts +3 -5
- package/build/src/akuma/body.js +490 -183
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +22 -0
- package/build/src/akuma/heart/facts.d.ts +88 -45
- package/build/src/akuma/heart/facts.js +19 -8
- package/build/src/akuma/heart/index.d.ts +64 -55
- package/build/src/akuma/heart/index.js +172 -252
- package/build/src/akuma/heart/rows.d.ts +38 -83
- package/build/src/akuma/heart/rows.js +117 -155
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +61 -22
- package/build/src/akuma/heart/soul.d.ts +8 -0
- package/build/src/akuma/heart/soul.js +136 -0
- package/build/src/akuma/heart/storage.d.ts +47 -0
- package/build/src/akuma/heart/storage.js +224 -0
- package/build/src/akuma/heart/tells.d.ts +12 -0
- package/build/src/akuma/heart/tells.js +79 -0
- package/build/src/akuma/heart/timeline.d.ts +15 -0
- package/build/src/akuma/heart/timeline.js +86 -0
- package/build/src/akuma/identity.d.ts +2 -2
- package/build/src/akuma/identity.js +9 -9
- package/build/src/akuma/index.d.ts +10 -3
- package/build/src/akuma/index.js +7 -1
- package/build/src/akuma/projection.d.ts +176 -0
- package/build/src/akuma/projection.js +256 -0
- package/build/src/akuma/provider-recipe.d.ts +24 -0
- package/build/src/akuma/provider-recipe.js +100 -0
- package/build/src/akuma/provider.d.ts +67 -13
- package/build/src/akuma/provider.js +172 -105
- package/build/src/akuma/providers/acp/core.d.ts +19 -0
- package/build/src/akuma/providers/acp/core.js +159 -0
- package/build/src/akuma/providers/acp/events.d.ts +20 -0
- package/build/src/akuma/providers/acp/events.js +73 -0
- package/build/src/akuma/providers/acp/index.d.ts +12 -0
- package/build/src/akuma/providers/acp/index.js +94 -0
- package/build/src/akuma/providers/{claude.d.ts → claude/events.d.ts} +9 -41
- package/build/src/akuma/providers/claude/events.js +238 -0
- package/build/src/akuma/providers/claude/index.d.ts +47 -0
- package/build/src/akuma/providers/claude/index.js +279 -0
- package/build/src/akuma/providers/claude/input.d.ts +13 -0
- package/build/src/akuma/providers/claude/input.js +109 -0
- package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
- package/build/src/akuma/providers/codex-app-server/events.js +15 -12
- package/build/src/akuma/providers/codex-app-server/index.d.ts +15 -13
- package/build/src/akuma/providers/codex-app-server/index.js +77 -33
- package/build/src/akuma/providers/grok-build/index.d.ts +4 -0
- package/build/src/akuma/providers/grok-build/index.js +70 -0
- package/build/src/akuma/providers/index.d.ts +5 -3
- package/build/src/akuma/providers/index.js +35 -56
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +54 -0
- package/build/src/akuma/providers/opencode-sdk/events.js +235 -0
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +33 -0
- package/build/src/akuma/providers/opencode-sdk/index.js +308 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +26 -0
- package/build/src/akuma/providers/opencode-sdk/session.js +63 -0
- package/build/src/akuma/providers/pi/events.d.ts +33 -0
- package/build/src/akuma/providers/pi/events.js +166 -0
- package/build/src/akuma/providers/pi/index.d.ts +11 -0
- package/build/src/akuma/providers/pi/index.js +191 -0
- package/build/src/akuma/publication.d.ts +3 -3
- package/build/src/akuma/publication.js +28 -40
- package/build/src/akuma/requests.d.ts +9 -6
- package/build/src/akuma/requests.js +95 -65
- package/build/src/alias/index.d.ts +4 -3
- package/build/src/alias/index.js +12 -13
- package/build/src/body/decode.js +7 -1
- package/build/src/body/region.d.ts +2 -0
- package/build/src/body/region.js +77 -7
- package/build/src/body/render.js +2 -1
- package/build/src/body/shape.js +7 -1
- package/build/src/body/verification.js +19 -4
- package/build/src/cli/accepted.d.ts +18 -12
- package/build/src/cli/accepted.js +73 -34
- package/build/src/cli/actor.js +3 -3
- package/build/src/cli/commands/akuma-invoke.d.ts +44 -19
- package/build/src/cli/commands/akuma-invoke.js +101 -52
- package/build/src/cli/commands/akuma.d.ts +27 -9
- package/build/src/cli/commands/akuma.js +151 -80
- package/build/src/cli/commands/contract.d.ts +155 -0
- package/build/src/cli/commands/contract.js +20 -0
- package/build/src/cli/commands/install.js +2 -0
- package/build/src/cli/commands/task-invoke.d.ts +19 -4
- package/build/src/cli/commands/task-invoke.js +65 -17
- package/build/src/cli/commands/task-query.d.ts +5 -0
- package/build/src/cli/commands/task-query.js +247 -0
- package/build/src/cli/commands/task.d.ts +3 -1
- package/build/src/cli/commands/task.js +52 -14
- package/build/src/cli/coordinates.d.ts +18 -0
- package/build/src/cli/coordinates.js +120 -0
- package/build/src/cli/draft.d.ts +8 -0
- package/build/src/cli/draft.js +96 -0
- package/build/src/cli/invoke.d.ts +9 -3
- package/build/src/cli/invoke.js +287 -108
- package/build/src/cli/main.js +54 -7
- package/build/src/cli/parse.d.ts +21 -117
- package/build/src/cli/parse.js +79 -84
- package/build/src/cli/render/akuma-tool-command.d.ts +6 -0
- package/build/src/cli/render/akuma-tool-command.js +144 -0
- package/build/src/cli/render/akuma-tool.d.ts +4 -2
- package/build/src/cli/render/akuma-tool.js +35 -5
- package/build/src/cli/render/akuma.d.ts +3 -1
- package/build/src/cli/render/akuma.js +247 -212
- package/build/src/cli/render/audit.d.ts +3 -0
- package/build/src/cli/render/audit.js +104 -0
- package/build/src/cli/render/catalog.d.ts +2 -0
- package/build/src/cli/render/catalog.js +16 -0
- package/build/src/cli/render/contract.d.ts +3 -3
- package/build/src/cli/render/contract.js +200 -54
- package/build/src/cli/render/kanshi.js +272 -129
- package/build/src/cli/render/receipt.d.ts +19 -0
- package/build/src/cli/render/receipt.js +106 -0
- package/build/src/cli/render/refusal.d.ts +16 -2
- package/build/src/cli/render/refusal.js +88 -3
- package/build/src/cli/render/region.d.ts +2 -0
- package/build/src/cli/render/region.js +17 -0
- package/build/src/cli/render/task.d.ts +2 -1
- package/build/src/cli/render/task.js +223 -60
- package/build/src/cli/render/terminal.d.ts +20 -0
- package/build/src/cli/render/terminal.js +121 -0
- package/build/src/cli/render/text.js +11 -3
- package/build/src/cli/result.d.ts +126 -19
- package/build/src/cli/usage.d.ts +1 -0
- package/build/src/cli/usage.js +3 -0
- package/build/src/contract-worktree.d.ts +44 -0
- package/build/src/contract-worktree.js +251 -0
- package/build/src/coordination/durable-file.d.ts +5 -1
- package/build/src/coordination/durable-file.js +57 -10
- package/build/src/coordination/sqlite-transaction-lock.d.ts +4 -0
- package/build/src/coordination/sqlite-transaction-lock.js +22 -5
- package/build/src/core/facts/codec.js +23 -4
- package/build/src/core/facts/eligibility.d.ts +1 -10
- package/build/src/core/facts/eligibility.js +0 -49
- package/build/src/core/facts/fold.js +1 -6
- package/build/src/core/facts/gate.d.ts +1 -0
- package/build/src/core/facts/gate.js +1 -0
- package/build/src/core/facts/observation.d.ts +3 -0
- package/build/src/core/facts/observation.js +12 -0
- package/build/src/core/facts/types.d.ts +10 -3
- package/build/src/core/subject.js +2 -2
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +3 -18
- package/build/src/core/verbs/bind.js +2 -16
- package/build/src/core/verbs/deliver.d.ts +1 -1
- package/build/src/core/verbs/deliver.js +14 -4
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +7 -9
- package/build/src/dispatch/index.d.ts +5 -3
- package/build/src/dispatch/index.js +30 -21
- package/build/src/duration.d.ts +10 -0
- package/build/src/duration.js +22 -0
- package/build/src/git/admission.d.ts +2 -2
- package/build/src/git/admission.js +33 -23
- package/build/src/git/hooks.d.ts +15 -0
- package/build/src/git/hooks.js +70 -18
- package/build/src/git/identity.d.ts +5 -1
- package/build/src/git/identity.js +23 -4
- package/build/src/git/integration.d.ts +48 -0
- package/build/src/git/integration.js +250 -0
- package/build/src/git/observe.d.ts +29 -15
- package/build/src/git/observe.js +185 -76
- package/build/src/git/read-observation.d.ts +41 -0
- package/build/src/git/read-observation.js +361 -0
- package/build/src/git/reconcile.d.ts +17 -5
- package/build/src/git/reconcile.js +305 -109
- package/build/src/git/repository.d.ts +41 -18
- package/build/src/git/repository.js +220 -114
- package/build/src/git/scratch.d.ts +17 -0
- package/build/src/git/scratch.js +73 -0
- package/build/src/git/target-placement.d.ts +92 -0
- package/build/src/git/target-placement.js +375 -0
- package/build/src/git/tender.d.ts +49 -0
- package/build/src/git/tender.js +63 -0
- package/build/src/git/terminal-seal.d.ts +24 -0
- package/build/src/git/terminal-seal.js +89 -0
- package/build/src/git/tree.d.ts +2 -2
- package/build/src/git/tree.js +4 -0
- package/build/src/git/workspace.d.ts +53 -0
- package/build/src/git/workspace.js +139 -0
- package/build/src/identity/selector.d.ts +6 -0
- package/build/src/identity/selector.js +19 -0
- package/build/src/index.d.ts +4 -2
- package/build/src/index.js +2 -1
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/index.js +1 -1
- package/build/src/kanshi/read.d.ts +7 -3
- package/build/src/kanshi/read.js +245 -45
- package/build/src/kanshi/report.d.ts +81 -6
- package/build/src/kanshi/select.d.ts +5 -0
- package/build/src/kanshi/select.js +33 -1
- package/build/src/library/address.d.ts +57 -0
- package/build/src/library/address.js +165 -0
- package/build/src/library/akuma-creation.d.ts +16 -7
- package/build/src/library/akuma-creation.js +96 -22
- package/build/src/library/audit.d.ts +18 -0
- package/build/src/library/audit.js +44 -0
- package/build/src/library/bind.d.ts +21 -0
- package/build/src/library/bind.js +56 -0
- package/build/src/library/catalog.d.ts +58 -0
- package/build/src/library/catalog.js +69 -0
- package/build/src/library/configuration.d.ts +6 -15
- package/build/src/library/configuration.js +14 -17
- package/build/src/library/contract.d.ts +23 -49
- package/build/src/library/contract.js +171 -185
- package/build/src/library/delivery.d.ts +24 -0
- package/build/src/library/delivery.js +21 -0
- package/build/src/library/fleet.d.ts +65 -0
- package/build/src/library/fleet.js +153 -0
- package/build/src/library/input.d.ts +3 -0
- package/build/src/library/input.js +19 -0
- package/build/src/library/keiyaku.d.ts +18 -3
- package/build/src/library/keiyaku.js +12 -1
- package/build/src/library/mutation.d.ts +39 -0
- package/build/src/library/mutation.js +37 -0
- package/build/src/library/reconcile.d.ts +29 -0
- package/build/src/library/reconcile.js +179 -0
- package/build/src/library/refusal.d.ts +21 -0
- package/build/src/library/refusal.js +29 -0
- package/build/src/library/region.d.ts +14 -1
- package/build/src/library/region.js +18 -4
- package/build/src/library/repo.d.ts +4 -13
- package/build/src/library/repo.js +14 -24
- package/build/src/protocol/attempt.d.ts +16 -3
- package/build/src/protocol/attempt.js +41 -10
- package/build/src/protocol/bind.d.ts +9 -2
- package/build/src/protocol/bind.js +48 -40
- package/build/src/protocol/intent.d.ts +57 -20
- package/build/src/protocol/intent.js +55 -79
- package/build/src/protocol/operations.d.ts +152 -43
- package/build/src/protocol/operations.js +482 -166
- package/build/src/protocol/outcome.d.ts +14 -3
- package/build/src/protocol/outcome.js +11 -3
- package/build/src/protocol/placement.d.ts +41 -0
- package/build/src/protocol/placement.js +147 -0
- package/build/src/protocol/read/documents.d.ts +2 -2
- package/build/src/protocol/read/documents.js +4 -4
- package/build/src/protocol/read/status.d.ts +18 -5
- package/build/src/protocol/read/status.js +73 -13
- package/build/src/protocol/run.d.ts +49 -7
- package/build/src/protocol/run.js +53 -25
- package/build/src/runtime/proc/line-rpc.d.ts +4 -8
- package/build/src/runtime/proc/line-rpc.js +22 -28
- package/build/src/runtime/proc/run.d.ts +23 -21
- package/build/src/runtime/proc/run.js +123 -89
- package/build/src/runtime/proc/stdio.d.ts +18 -0
- package/build/src/runtime/proc/stdio.js +58 -0
- package/build/src/settings.d.ts +7 -1
- package/build/src/settings.js +32 -17
- package/build/src/settlement/fence.d.ts +5 -0
- package/build/src/settlement/fence.js +14 -0
- package/build/src/settlement/holder.d.ts +35 -4
- package/build/src/settlement/holder.js +127 -28
- package/build/src/settlement/settle.d.ts +9 -1
- package/build/src/settlement/settle.js +74 -37
- package/build/src/task/board.d.ts +23 -5
- package/build/src/task/board.js +17 -10
- package/build/src/task/compose.d.ts +2 -2
- package/build/src/task/compose.js +18 -10
- package/build/src/task/context.d.ts +3 -3
- package/build/src/task/context.js +15 -20
- package/build/src/task/document.d.ts +2 -1
- package/build/src/task/document.js +15 -5
- package/build/src/task/index.d.ts +27 -15
- package/build/src/task/index.js +57 -35
- package/build/src/task/operations.d.ts +38 -13
- package/build/src/task/operations.js +80 -46
- package/build/src/task/query.d.ts +67 -0
- package/build/src/task/query.js +279 -0
- package/build/src/task/store.d.ts +5 -7
- package/build/src/task/store.js +43 -28
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/execution.d.ts +51 -0
- package/build/src/verification/execution.js +108 -0
- package/build/src/workspace-place.d.ts +41 -0
- package/build/src/workspace-place.js +386 -0
- package/build/src/world.d.ts +24 -0
- package/build/src/world.js +136 -0
- package/package.json +8 -4
- package/build/src/akuma/activity.d.ts +0 -66
- package/build/src/akuma/activity.js +0 -139
- package/build/src/akuma/providers/claude.js +0 -305
- package/build/src/context-root.d.ts +0 -4
- package/build/src/context-root.js +0 -15
- package/build/src/git/delivery.d.ts +0 -20
- package/build/src/git/delivery.js +0 -109
- package/build/src/git/verification.d.ts +0 -14
- package/build/src/git/verification.js +0 -56
- package/build/src/protocol/read/audit.d.ts +0 -25
- package/build/src/protocol/read/audit.js +0 -39
- package/build/src/verification/producer.d.ts +0 -23
- package/build/src/verification/producer.js +0 -54
package/build/src/cli/parse.d.ts
CHANGED
|
@@ -1,122 +1,10 @@
|
|
|
1
1
|
import { type ParsedTaskCommand, type TaskAction } from "./commands/task.js";
|
|
2
2
|
import { type AkumaAction, type ParsedAkumaCommand } from "./commands/akuma.js";
|
|
3
|
+
import type { CatalogQuery } from "../index.js";
|
|
3
4
|
import { type ParsedInstallCommand } from "./commands/install.js";
|
|
5
|
+
import { type ContractCommand as Command } from "./commands/contract.js";
|
|
4
6
|
export { CliUsageError } from "./usage.js";
|
|
5
|
-
|
|
6
|
-
readonly bind: {
|
|
7
|
-
readonly positional: "none";
|
|
8
|
-
readonly stdin: "required";
|
|
9
|
-
readonly flags: {
|
|
10
|
-
readonly actor: "value";
|
|
11
|
-
readonly task: "value";
|
|
12
|
-
readonly target: "value";
|
|
13
|
-
readonly here: "boolean";
|
|
14
|
-
readonly after: "repeat-value";
|
|
15
|
-
readonly gates: "value";
|
|
16
|
-
readonly json: "boolean";
|
|
17
|
-
};
|
|
18
|
-
readonly usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name>] [--actor <actor>] [--json] -";
|
|
19
|
-
readonly purpose: "Create one Contract from stdin Markdown.";
|
|
20
|
-
};
|
|
21
|
-
readonly amend: {
|
|
22
|
-
readonly positional: "optional";
|
|
23
|
-
readonly stdin: "required";
|
|
24
|
-
readonly flags: {
|
|
25
|
-
readonly actor: "value";
|
|
26
|
-
readonly after: "repeat-value";
|
|
27
|
-
readonly "clear-after": "boolean";
|
|
28
|
-
readonly gates: "value";
|
|
29
|
-
readonly json: "boolean";
|
|
30
|
-
};
|
|
31
|
-
readonly usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name>] [--actor <actor>] [--json] -";
|
|
32
|
-
readonly purpose: "Apply stdin amendment operations to one Contract.";
|
|
33
|
-
};
|
|
34
|
-
readonly deliver: {
|
|
35
|
-
readonly positional: "optional";
|
|
36
|
-
readonly stdin: "none";
|
|
37
|
-
readonly flags: {
|
|
38
|
-
readonly actor: "value";
|
|
39
|
-
readonly message: "value";
|
|
40
|
-
readonly json: "boolean";
|
|
41
|
-
};
|
|
42
|
-
readonly usage: "deliver [<contract>|@<contract>] [--message <text>] [--actor <actor>] [--json]";
|
|
43
|
-
readonly purpose: "Deliver one Contract candidate.";
|
|
44
|
-
};
|
|
45
|
-
readonly review: {
|
|
46
|
-
readonly positional: "optional";
|
|
47
|
-
readonly stdin: "optional";
|
|
48
|
-
readonly flags: {
|
|
49
|
-
readonly actor: "value";
|
|
50
|
-
readonly satisfied: "boolean";
|
|
51
|
-
readonly unsatisfied: "boolean";
|
|
52
|
-
readonly summary: "value";
|
|
53
|
-
readonly json: "boolean";
|
|
54
|
-
};
|
|
55
|
-
readonly usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) [--summary <text>] [--actor <actor>] [--json] [-]";
|
|
56
|
-
readonly purpose: "Record one review verdict.";
|
|
57
|
-
};
|
|
58
|
-
readonly arc: {
|
|
59
|
-
readonly positional: "optional";
|
|
60
|
-
readonly stdin: "required";
|
|
61
|
-
readonly flags: {
|
|
62
|
-
readonly actor: "value";
|
|
63
|
-
readonly json: "boolean";
|
|
64
|
-
};
|
|
65
|
-
readonly usage: "arc [<contract>|@<contract>] [--actor <actor>] [--json] -";
|
|
66
|
-
readonly purpose: "Record stdin arc Markdown for one Contract.";
|
|
67
|
-
};
|
|
68
|
-
readonly abandon: {
|
|
69
|
-
readonly positional: "optional";
|
|
70
|
-
readonly stdin: "none";
|
|
71
|
-
readonly flags: {
|
|
72
|
-
readonly actor: "value";
|
|
73
|
-
readonly note: "value";
|
|
74
|
-
readonly json: "boolean";
|
|
75
|
-
};
|
|
76
|
-
readonly usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>] [--json]";
|
|
77
|
-
readonly purpose: "Abandon one Contract with an optional note.";
|
|
78
|
-
};
|
|
79
|
-
readonly status: {
|
|
80
|
-
readonly positional: "optional";
|
|
81
|
-
readonly stdin: "none";
|
|
82
|
-
readonly flags: {
|
|
83
|
-
readonly json: "boolean";
|
|
84
|
-
};
|
|
85
|
-
readonly usage: "status [<contract>|@<contract>|<aku/...>] [--json]";
|
|
86
|
-
readonly purpose: "Read the world status board or one Contract projection.";
|
|
87
|
-
};
|
|
88
|
-
readonly audit: {
|
|
89
|
-
readonly positional: "optional";
|
|
90
|
-
readonly stdin: "none";
|
|
91
|
-
readonly flags: {
|
|
92
|
-
readonly "show-diff-body": "boolean";
|
|
93
|
-
readonly actor: "value";
|
|
94
|
-
readonly json: "boolean";
|
|
95
|
-
};
|
|
96
|
-
readonly usage: "audit [<contract>|@<contract>] [--show-diff-body] [--actor <actor>] [--json]";
|
|
97
|
-
readonly purpose: "Audit one Contract without mutation.";
|
|
98
|
-
};
|
|
99
|
-
readonly reconcile: {
|
|
100
|
-
readonly positional: "optional";
|
|
101
|
-
readonly stdin: "none";
|
|
102
|
-
readonly flags: {
|
|
103
|
-
readonly "retry-hooks": "boolean";
|
|
104
|
-
readonly json: "boolean";
|
|
105
|
-
};
|
|
106
|
-
readonly usage: "reconcile [<contract>|@<contract>] [--retry-hooks] [--json]";
|
|
107
|
-
readonly purpose: "Reconcile one Contract or the invocation world.";
|
|
108
|
-
};
|
|
109
|
-
readonly settings: {
|
|
110
|
-
readonly positional: "none";
|
|
111
|
-
readonly stdin: "none";
|
|
112
|
-
readonly flags: {
|
|
113
|
-
readonly json: "boolean";
|
|
114
|
-
};
|
|
115
|
-
readonly usage: "settings [--json]";
|
|
116
|
-
readonly purpose: "Read user and project Settings resources.";
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
export type Command = keyof typeof CONTRACT_COMMAND_SPECS;
|
|
7
|
+
export type { Command };
|
|
120
8
|
export declare function renderRootHelp(): string;
|
|
121
9
|
export declare function renderContractHelp(command: Command): string;
|
|
122
10
|
export declare function renderCommandUsage(command: ParsedCommand): string;
|
|
@@ -145,6 +33,7 @@ export type ParsedDeliver = Output & Actor & Readonly<{
|
|
|
145
33
|
command: "deliver";
|
|
146
34
|
contract?: string;
|
|
147
35
|
message?: string;
|
|
36
|
+
includeDirty: boolean;
|
|
148
37
|
}>;
|
|
149
38
|
export type ParsedReview = Output & Actor & Readonly<{
|
|
150
39
|
command: "review";
|
|
@@ -171,10 +60,15 @@ type ParsedStatus = Output & (Readonly<{
|
|
|
171
60
|
contract: string;
|
|
172
61
|
akuma: true;
|
|
173
62
|
}>);
|
|
63
|
+
export type ParsedLs = Output & Readonly<{
|
|
64
|
+
command: "ls";
|
|
65
|
+
query: CatalogQuery;
|
|
66
|
+
}>;
|
|
174
67
|
export type ParsedAudit = Output & Readonly<{
|
|
175
68
|
command: "audit";
|
|
176
69
|
contract?: string;
|
|
177
|
-
|
|
70
|
+
includeDirty: boolean;
|
|
71
|
+
showDiff: boolean;
|
|
178
72
|
actor?: string;
|
|
179
73
|
}>;
|
|
180
74
|
type ParsedReconcile = Output & Readonly<{
|
|
@@ -185,7 +79,16 @@ type ParsedReconcile = Output & Readonly<{
|
|
|
185
79
|
export type ParsedSettings = Output & Readonly<{
|
|
186
80
|
command: "settings";
|
|
187
81
|
}>;
|
|
188
|
-
export type
|
|
82
|
+
export type ParsedRegion = Output & Readonly<{
|
|
83
|
+
command: "region";
|
|
84
|
+
contract?: string;
|
|
85
|
+
overlap: boolean;
|
|
86
|
+
path?: string;
|
|
87
|
+
}>;
|
|
88
|
+
export type ParsedCommand = ParsedBind | ParsedAmend | ParsedDeliver | ParsedReview | ParsedArc | ParsedAbandon | ParsedStatus | (Output & Readonly<{
|
|
89
|
+
command: "show";
|
|
90
|
+
contract?: string;
|
|
91
|
+
}>) | ParsedLs | ParsedAudit | ParsedReconcile | ParsedSettings | ParsedRegion | ParsedInstallCommand | ParsedAkumaCommand | ParsedTaskCommand;
|
|
189
92
|
export type CliHelpCoordinate = Readonly<{
|
|
190
93
|
kind: "root";
|
|
191
94
|
}> | Readonly<{
|
|
@@ -202,6 +105,7 @@ export type CliHelpCoordinate = Readonly<{
|
|
|
202
105
|
}>;
|
|
203
106
|
export type ParsedExecution = Readonly<{
|
|
204
107
|
cwd?: string;
|
|
108
|
+
repo?: string;
|
|
205
109
|
command: ParsedCommand;
|
|
206
110
|
}>;
|
|
207
111
|
export type ParsedInvocation = ParsedExecution | Readonly<{
|
package/build/src/cli/parse.js
CHANGED
|
@@ -1,87 +1,17 @@
|
|
|
1
1
|
import { isTaskAction, parseTaskCommand, renderTaskUsage, } from "./commands/task.js";
|
|
2
|
-
import { isAkumaAction, parseAkumaCommand, renderAkumaRootRows, renderAkumaUsage, } from "./commands/akuma.js";
|
|
2
|
+
import { isAkumaAction, parseAkumaCatalogPath, parseAkumaCommand, renderAkumaRootRows, renderAkumaUsage, } from "./commands/akuma.js";
|
|
3
3
|
import { INSTALL_USAGE, parseInstallCommand, renderInstallHelp } from "./commands/install.js";
|
|
4
|
-
import {
|
|
4
|
+
import { AMEND_MINIMAL_STDIN_HELP, CONTRACT_COMMAND_SPECS } from "./commands/contract.js";
|
|
5
|
+
import { CliUsageError, isBlankInput, usageLine } from "./usage.js";
|
|
5
6
|
export { CliUsageError } from "./usage.js";
|
|
6
|
-
const
|
|
7
|
-
bind: {
|
|
8
|
-
positional: "none",
|
|
9
|
-
stdin: "required",
|
|
10
|
-
flags: { actor: "value", task: "value", target: "value", here: "boolean", after: "repeat-value", gates: "value", json: "boolean" },
|
|
11
|
-
usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name>] [--actor <actor>] [--json] -",
|
|
12
|
-
purpose: "Create one Contract from stdin Markdown.",
|
|
13
|
-
},
|
|
14
|
-
amend: {
|
|
15
|
-
positional: "optional",
|
|
16
|
-
stdin: "required",
|
|
17
|
-
flags: { actor: "value", after: "repeat-value", "clear-after": "boolean", gates: "value", json: "boolean" },
|
|
18
|
-
usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name>] [--actor <actor>] [--json] -",
|
|
19
|
-
purpose: "Apply stdin amendment operations to one Contract.",
|
|
20
|
-
},
|
|
21
|
-
deliver: {
|
|
22
|
-
positional: "optional",
|
|
23
|
-
stdin: "none",
|
|
24
|
-
flags: { actor: "value", message: "value", json: "boolean" },
|
|
25
|
-
usage: "deliver [<contract>|@<contract>] [--message <text>] [--actor <actor>] [--json]",
|
|
26
|
-
purpose: "Deliver one Contract candidate.",
|
|
27
|
-
},
|
|
28
|
-
review: {
|
|
29
|
-
positional: "optional",
|
|
30
|
-
stdin: "optional",
|
|
31
|
-
flags: { actor: "value", satisfied: "boolean", unsatisfied: "boolean", summary: "value", json: "boolean" },
|
|
32
|
-
usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) [--summary <text>] [--actor <actor>] [--json] [-]",
|
|
33
|
-
purpose: "Record one review verdict.",
|
|
34
|
-
},
|
|
35
|
-
arc: {
|
|
36
|
-
positional: "optional",
|
|
37
|
-
stdin: "required",
|
|
38
|
-
flags: { actor: "value", json: "boolean" },
|
|
39
|
-
usage: "arc [<contract>|@<contract>] [--actor <actor>] [--json] -",
|
|
40
|
-
purpose: "Record stdin arc Markdown for one Contract.",
|
|
41
|
-
},
|
|
42
|
-
abandon: {
|
|
43
|
-
positional: "optional",
|
|
44
|
-
stdin: "none",
|
|
45
|
-
flags: { actor: "value", note: "value", json: "boolean" },
|
|
46
|
-
usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>] [--json]",
|
|
47
|
-
purpose: "Abandon one Contract with an optional note.",
|
|
48
|
-
},
|
|
49
|
-
status: {
|
|
50
|
-
positional: "optional",
|
|
51
|
-
stdin: "none",
|
|
52
|
-
flags: { json: "boolean" },
|
|
53
|
-
usage: "status [<contract>|@<contract>|<aku/...>] [--json]",
|
|
54
|
-
purpose: "Read the world status board or one Contract projection.",
|
|
55
|
-
},
|
|
56
|
-
audit: {
|
|
57
|
-
positional: "optional",
|
|
58
|
-
stdin: "none",
|
|
59
|
-
flags: { "show-diff-body": "boolean", actor: "value", json: "boolean" },
|
|
60
|
-
usage: "audit [<contract>|@<contract>] [--show-diff-body] [--actor <actor>] [--json]",
|
|
61
|
-
purpose: "Audit one Contract without mutation.",
|
|
62
|
-
},
|
|
63
|
-
reconcile: {
|
|
64
|
-
positional: "optional",
|
|
65
|
-
stdin: "none",
|
|
66
|
-
flags: { "retry-hooks": "boolean", json: "boolean" },
|
|
67
|
-
usage: "reconcile [<contract>|@<contract>] [--retry-hooks] [--json]",
|
|
68
|
-
purpose: "Reconcile one Contract or the invocation world.",
|
|
69
|
-
},
|
|
70
|
-
settings: {
|
|
71
|
-
positional: "none",
|
|
72
|
-
stdin: "none",
|
|
73
|
-
flags: { json: "boolean" },
|
|
74
|
-
usage: "settings [--json]",
|
|
75
|
-
purpose: "Read user and project Settings resources.",
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
const ROOT_USAGE = "usage: keiyaku [-C <path>] <command> [<contract>|@<contract>] [--flag ...] [-]";
|
|
7
|
+
const ROOT_USAGE = "usage: keiyaku [-C <path>] [--repo <path>] <command> [<contract>|@<contract>] [--flag ...] [-]";
|
|
79
8
|
export function renderRootHelp() {
|
|
80
9
|
return [
|
|
81
10
|
ROOT_USAGE,
|
|
82
11
|
"",
|
|
83
12
|
"global options:",
|
|
84
13
|
" -C, --cwd <path> Set the invocation working directory.",
|
|
14
|
+
" --repo <path> Select the Git repository coordinate.",
|
|
85
15
|
"",
|
|
86
16
|
"commands:",
|
|
87
17
|
...Object.values(CONTRACT_COMMAND_SPECS).flatMap((spec) => [` ${spec.usage}`, ` ${spec.purpose}`]),
|
|
@@ -94,7 +24,8 @@ export function renderRootHelp() {
|
|
|
94
24
|
}
|
|
95
25
|
export function renderContractHelp(command) {
|
|
96
26
|
const spec = CONTRACT_COMMAND_SPECS[command];
|
|
97
|
-
|
|
27
|
+
const help = `${spec.purpose}\n\n${usageLine(spec.usage)}`;
|
|
28
|
+
return command === "amend" ? `${help}\n\n${AMEND_MINIMAL_STDIN_HELP}` : help;
|
|
98
29
|
}
|
|
99
30
|
function contractUsage(command) {
|
|
100
31
|
return usageLine(CONTRACT_COMMAND_SPECS[command].usage);
|
|
@@ -140,6 +71,8 @@ function scanOption(command, argv, state, index) {
|
|
|
140
71
|
const value = argv[index + 1];
|
|
141
72
|
if (value === undefined || value === "-" || value.startsWith("--"))
|
|
142
73
|
refuse(command, `${token} requires a value`);
|
|
74
|
+
if (isBlankInput(value))
|
|
75
|
+
refuse(command, `${token} requires a nonblank value`);
|
|
143
76
|
if (kind === "repeat-value") {
|
|
144
77
|
const values = state.flags[name];
|
|
145
78
|
state.flags[name] = [...(Array.isArray(values) ? values : values === undefined ? [] : [values]), value];
|
|
@@ -167,6 +100,8 @@ function scanArgv(argv) {
|
|
|
167
100
|
index = scanOption(command, argv, state, index);
|
|
168
101
|
continue;
|
|
169
102
|
}
|
|
103
|
+
if (isBlankInput(token))
|
|
104
|
+
refuse(command, `${command} requires a nonblank value`);
|
|
170
105
|
state.positionals.push(token);
|
|
171
106
|
}
|
|
172
107
|
if (spec.positional === "none" && state.positionals.length > 0) {
|
|
@@ -222,6 +157,7 @@ function parseDeliver(parts) {
|
|
|
222
157
|
...(contract === undefined ? {} : { contract }),
|
|
223
158
|
...(parts.actor === undefined ? {} : { actor: parts.actor }),
|
|
224
159
|
...(message === undefined ? {} : { message }),
|
|
160
|
+
includeDirty: parts.flags["include-dirty"] === true,
|
|
225
161
|
output: parts.output,
|
|
226
162
|
};
|
|
227
163
|
}
|
|
@@ -230,8 +166,9 @@ function parseReview(parts) {
|
|
|
230
166
|
refuse("review", "review requires exactly one verdict flag");
|
|
231
167
|
}
|
|
232
168
|
const summary = optionalFlag(parts.flags, "summary");
|
|
233
|
-
if (parts.stdin
|
|
234
|
-
refuse("review", "review
|
|
169
|
+
if (parts.stdin === (summary !== undefined)) {
|
|
170
|
+
refuse("review", "review requires exactly one of --summary <text> or stdin '-'");
|
|
171
|
+
}
|
|
235
172
|
const contract = parts.positionals[0];
|
|
236
173
|
return {
|
|
237
174
|
command: "review",
|
|
@@ -279,13 +216,50 @@ function parseStatus(parts) {
|
|
|
279
216
|
output: parts.output,
|
|
280
217
|
};
|
|
281
218
|
}
|
|
219
|
+
function parseShow(parts) {
|
|
220
|
+
const contract = parts.positionals[0];
|
|
221
|
+
return { command: "show", ...(contract === undefined ? {} : { contract }), output: parts.output };
|
|
222
|
+
}
|
|
223
|
+
function parseRegion(parts) {
|
|
224
|
+
const contract = parts.positionals[0];
|
|
225
|
+
const path = optionalFlag(parts.flags, "path");
|
|
226
|
+
const overlap = parts.flags.overlap === true;
|
|
227
|
+
if (path !== undefined && (contract !== undefined || overlap))
|
|
228
|
+
refuse("region", "--path cannot combine with a contract or --overlap");
|
|
229
|
+
return {
|
|
230
|
+
command: "region",
|
|
231
|
+
...(contract === undefined ? {} : { contract }),
|
|
232
|
+
...(path === undefined ? {} : { path }),
|
|
233
|
+
overlap,
|
|
234
|
+
output: parts.output,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function parseLs(parts) {
|
|
238
|
+
const path = parts.positionals[0];
|
|
239
|
+
if (path === "task/")
|
|
240
|
+
return { command: "ls", query: { kind: "tasks" }, output: parts.output };
|
|
241
|
+
if (path === "kei/")
|
|
242
|
+
return { command: "ls", query: { kind: "contracts" }, output: parts.output };
|
|
243
|
+
try {
|
|
244
|
+
const query = parseAkumaCatalogPath(path);
|
|
245
|
+
if (query === null)
|
|
246
|
+
refuse("ls", "ls requires an identity directory with a trailing slash");
|
|
247
|
+
return { command: "ls", query, output: parts.output };
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
if (error instanceof CliUsageError)
|
|
251
|
+
throw error;
|
|
252
|
+
refuse("ls", error instanceof Error ? error.message : "invalid ls directory");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
282
255
|
function invocationOptions(argv) {
|
|
283
256
|
let cwd;
|
|
257
|
+
let repo;
|
|
284
258
|
let stdinSeen = false;
|
|
285
259
|
const commandArgv = [];
|
|
286
260
|
for (let index = 0; index < argv.length; index += 1) {
|
|
287
261
|
const token = argv[index];
|
|
288
|
-
if (token !== "-C" && token !== "--cwd") {
|
|
262
|
+
if (token !== "-C" && token !== "--cwd" && token !== "--repo") {
|
|
289
263
|
commandArgv.push(token);
|
|
290
264
|
if (token === "-")
|
|
291
265
|
stdinSeen = true;
|
|
@@ -293,16 +267,27 @@ function invocationOptions(argv) {
|
|
|
293
267
|
}
|
|
294
268
|
if (stdinSeen)
|
|
295
269
|
throw new CliUsageError("stdin marker '-' must be the final argument", renderRootHelp());
|
|
296
|
-
if (
|
|
270
|
+
if (token === "--repo" && repo !== undefined) {
|
|
271
|
+
throw new CliUsageError("--repo may appear only once", renderRootHelp());
|
|
272
|
+
}
|
|
273
|
+
if (token !== "--repo" && cwd !== undefined) {
|
|
297
274
|
throw new CliUsageError("-C/--cwd may appear only once", renderRootHelp());
|
|
275
|
+
}
|
|
298
276
|
const value = argv[index + 1];
|
|
299
|
-
if (value === undefined || value === "-" || value.startsWith("-")) {
|
|
277
|
+
if (value === undefined || value === "-" || value.startsWith("-") || isBlankInput(value)) {
|
|
300
278
|
throw new CliUsageError(`${token} requires a path`, renderRootHelp());
|
|
301
279
|
}
|
|
302
|
-
|
|
280
|
+
if (token === "--repo")
|
|
281
|
+
repo = value;
|
|
282
|
+
else
|
|
283
|
+
cwd = value;
|
|
303
284
|
index += 1;
|
|
304
285
|
}
|
|
305
|
-
return {
|
|
286
|
+
return {
|
|
287
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
288
|
+
...(repo === undefined ? {} : { repo }),
|
|
289
|
+
commandArgv,
|
|
290
|
+
};
|
|
306
291
|
}
|
|
307
292
|
function helpCoordinate(argv) {
|
|
308
293
|
const help = argv.indexOf("--help");
|
|
@@ -332,12 +317,15 @@ function parseCommand(parts) {
|
|
|
332
317
|
case "arc": return parseArc(parts);
|
|
333
318
|
case "abandon": return parseAbandon(parts);
|
|
334
319
|
case "status": return parseStatus(parts);
|
|
320
|
+
case "show": return parseShow(parts);
|
|
321
|
+
case "ls": return parseLs(parts);
|
|
335
322
|
case "audit": {
|
|
336
323
|
const contract = parts.positionals[0];
|
|
337
324
|
return {
|
|
338
325
|
command: "audit",
|
|
339
326
|
...(contract === undefined ? {} : { contract }),
|
|
340
|
-
|
|
327
|
+
includeDirty: parts.flags["include-dirty"] === true,
|
|
328
|
+
showDiff: parts.flags.diff === true,
|
|
341
329
|
...(parts.actor === undefined ? {} : { actor: parts.actor }),
|
|
342
330
|
output: parts.output,
|
|
343
331
|
};
|
|
@@ -352,6 +340,7 @@ function parseCommand(parts) {
|
|
|
352
340
|
};
|
|
353
341
|
}
|
|
354
342
|
case "settings": return { command: "settings", output: parts.output };
|
|
343
|
+
case "region": return parseRegion(parts);
|
|
355
344
|
}
|
|
356
345
|
}
|
|
357
346
|
export function parseArgv(argv) {
|
|
@@ -359,6 +348,11 @@ export function parseArgv(argv) {
|
|
|
359
348
|
const help = helpCoordinate(invocation.commandArgv);
|
|
360
349
|
if (help !== null)
|
|
361
350
|
return { help };
|
|
351
|
+
if (invocation.commandArgv[0] === "ls"
|
|
352
|
+
&& (invocation.commandArgv.length === 1
|
|
353
|
+
|| (invocation.commandArgv.length === 2 && invocation.commandArgv[1] === "--json"))) {
|
|
354
|
+
return { help: { kind: "contract", command: "ls" } };
|
|
355
|
+
}
|
|
362
356
|
const task = invocation.commandArgv[0] === "task"
|
|
363
357
|
? parseTaskCommand(invocation.commandArgv.slice(1))
|
|
364
358
|
: undefined;
|
|
@@ -370,6 +364,7 @@ export function parseArgv(argv) {
|
|
|
370
364
|
: undefined;
|
|
371
365
|
return {
|
|
372
366
|
...(invocation.cwd === undefined ? {} : { cwd: invocation.cwd }),
|
|
367
|
+
...(invocation.repo === undefined ? {} : { repo: invocation.repo }),
|
|
373
368
|
command: task ?? akuma ?? install ?? parseCommand(scanArgv(invocation.commandArgv)),
|
|
374
369
|
};
|
|
375
370
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwrap only complete provider transport launchers. This is deliberately not
|
|
3
|
+
* a shell parser: uncertainty preserves the persisted command's presentation.
|
|
4
|
+
*/
|
|
5
|
+
/** Return a display subject only when the full transport shape is unambiguous. */
|
|
6
|
+
export declare function normalizeToolCommand(command: string): string;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwrap only complete provider transport launchers. This is deliberately not
|
|
3
|
+
* a shell parser: uncertainty preserves the persisted command's presentation.
|
|
4
|
+
*/
|
|
5
|
+
const HORIZONTAL_WHITESPACE = new Set([" ", "\t"]);
|
|
6
|
+
const UNSUPPORTED_UNQUOTED = new Set(["$", "`", "|", "&", ";", "<", ">", "(", ")"]);
|
|
7
|
+
const DOUBLE_QUOTE_ESCAPES = new Set(["\"", "\\", "$", "`"]);
|
|
8
|
+
const POWERSHELL_OPTION_FLAGS = new Set(["-nologo", "-noprofile"]);
|
|
9
|
+
const POWERSHELL_COMMAND_FLAGS = new Set(["-command", "-c"]);
|
|
10
|
+
const SCAN_FAIL = { ok: false };
|
|
11
|
+
function scanned(index, value) {
|
|
12
|
+
return { ok: true, index, value };
|
|
13
|
+
}
|
|
14
|
+
function isLineBoundary(character) {
|
|
15
|
+
return character === "\n" || character === "\r";
|
|
16
|
+
}
|
|
17
|
+
function isAbsoluteExecutable(value) {
|
|
18
|
+
return value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value);
|
|
19
|
+
}
|
|
20
|
+
function executableName(value) {
|
|
21
|
+
const segments = value.split(/[\\/]/u);
|
|
22
|
+
return segments[segments.length - 1].toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
function isBashOrZsh(value) {
|
|
25
|
+
const name = executableName(value);
|
|
26
|
+
return (value === "bash" || value === "zsh" || isAbsoluteExecutable(value))
|
|
27
|
+
&& (name === "bash" || name === "zsh");
|
|
28
|
+
}
|
|
29
|
+
function isPowerShell(value) {
|
|
30
|
+
const name = executableName(value);
|
|
31
|
+
return (value.toLowerCase() === "powershell" || value.toLowerCase() === "pwsh" || isAbsoluteExecutable(value))
|
|
32
|
+
&& (name === "powershell" || name === "powershell.exe" || name === "pwsh" || name === "pwsh.exe");
|
|
33
|
+
}
|
|
34
|
+
function scanSingleQuoted(command, index) {
|
|
35
|
+
const end = command.indexOf("'", index + 1);
|
|
36
|
+
return end < 0 ? SCAN_FAIL : scanned(end + 1, command.slice(index + 1, end));
|
|
37
|
+
}
|
|
38
|
+
function scanDoubleQuotedEscape(command, index) {
|
|
39
|
+
const next = command[index + 1];
|
|
40
|
+
if (next === undefined || isLineBoundary(next))
|
|
41
|
+
return SCAN_FAIL;
|
|
42
|
+
return scanned(index + 2, DOUBLE_QUOTE_ESCAPES.has(next) ? next : `\\${next}`);
|
|
43
|
+
}
|
|
44
|
+
function scanDoubleQuoted(command, index) {
|
|
45
|
+
let cursor = index + 1;
|
|
46
|
+
let value = "";
|
|
47
|
+
while (cursor < command.length) {
|
|
48
|
+
const quoted = command[cursor];
|
|
49
|
+
if (quoted === "\"")
|
|
50
|
+
return scanned(cursor + 1, value);
|
|
51
|
+
if (quoted === "$" || quoted === "`")
|
|
52
|
+
return SCAN_FAIL;
|
|
53
|
+
if (quoted === "\\") {
|
|
54
|
+
const escaped = scanDoubleQuotedEscape(command, cursor);
|
|
55
|
+
if (!escaped.ok)
|
|
56
|
+
return SCAN_FAIL;
|
|
57
|
+
value += escaped.value;
|
|
58
|
+
cursor = escaped.index;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
value += quoted;
|
|
62
|
+
cursor += 1;
|
|
63
|
+
}
|
|
64
|
+
return SCAN_FAIL;
|
|
65
|
+
}
|
|
66
|
+
function scanUnquotedEscape(command, index) {
|
|
67
|
+
const next = command[index + 1];
|
|
68
|
+
if (next === undefined || isLineBoundary(next))
|
|
69
|
+
return SCAN_FAIL;
|
|
70
|
+
return scanned(index + 2, next);
|
|
71
|
+
}
|
|
72
|
+
function scanTokenSegment(command, index) {
|
|
73
|
+
const character = command[index];
|
|
74
|
+
if (isLineBoundary(character) || UNSUPPORTED_UNQUOTED.has(character))
|
|
75
|
+
return SCAN_FAIL;
|
|
76
|
+
if (character === "'")
|
|
77
|
+
return scanSingleQuoted(command, index);
|
|
78
|
+
if (character === "\"")
|
|
79
|
+
return scanDoubleQuoted(command, index);
|
|
80
|
+
if (character === "\\")
|
|
81
|
+
return scanUnquotedEscape(command, index);
|
|
82
|
+
return scanned(index + 1, character);
|
|
83
|
+
}
|
|
84
|
+
function scanToken(command, index) {
|
|
85
|
+
let cursor = index;
|
|
86
|
+
let value = "";
|
|
87
|
+
let consumed = false;
|
|
88
|
+
while (cursor < command.length && !HORIZONTAL_WHITESPACE.has(command[cursor])) {
|
|
89
|
+
const segment = scanTokenSegment(command, cursor);
|
|
90
|
+
if (!segment.ok)
|
|
91
|
+
return SCAN_FAIL;
|
|
92
|
+
value += segment.value;
|
|
93
|
+
cursor = segment.index;
|
|
94
|
+
consumed = true;
|
|
95
|
+
}
|
|
96
|
+
return consumed ? scanned(cursor, value) : SCAN_FAIL;
|
|
97
|
+
}
|
|
98
|
+
function parseTransportArgv(command) {
|
|
99
|
+
const argv = [];
|
|
100
|
+
let index = 0;
|
|
101
|
+
while (index < command.length) {
|
|
102
|
+
while (HORIZONTAL_WHITESPACE.has(command[index]))
|
|
103
|
+
index += 1;
|
|
104
|
+
if (index === command.length)
|
|
105
|
+
break;
|
|
106
|
+
if (isLineBoundary(command[index]))
|
|
107
|
+
return undefined;
|
|
108
|
+
const token = scanToken(command, index);
|
|
109
|
+
if (!token.ok)
|
|
110
|
+
return undefined;
|
|
111
|
+
argv.push(token.value);
|
|
112
|
+
index = token.index;
|
|
113
|
+
}
|
|
114
|
+
return argv;
|
|
115
|
+
}
|
|
116
|
+
function unwrapBashOrZsh(argv) {
|
|
117
|
+
const [shell, flag, script] = argv;
|
|
118
|
+
if (argv.length !== 3 || !shell || !script || !isBashOrZsh(shell))
|
|
119
|
+
return undefined;
|
|
120
|
+
return flag === "-c" || flag === "-lc" ? script : undefined;
|
|
121
|
+
}
|
|
122
|
+
function unwrapPowerShell(argv) {
|
|
123
|
+
const [shell, ...arguments_] = argv;
|
|
124
|
+
if (!shell || !isPowerShell(shell) || arguments_.length < 2)
|
|
125
|
+
return undefined;
|
|
126
|
+
const options = new Set();
|
|
127
|
+
for (let index = 0; index < arguments_.length - 1; index += 1) {
|
|
128
|
+
const flag = arguments_[index].toLowerCase();
|
|
129
|
+
if (POWERSHELL_COMMAND_FLAGS.has(flag)) {
|
|
130
|
+
return index === arguments_.length - 2 && arguments_[index + 1] ? arguments_[index + 1] : undefined;
|
|
131
|
+
}
|
|
132
|
+
if (!POWERSHELL_OPTION_FLAGS.has(flag) || options.has(flag))
|
|
133
|
+
return undefined;
|
|
134
|
+
options.add(flag);
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
/** Return a display subject only when the full transport shape is unambiguous. */
|
|
139
|
+
export function normalizeToolCommand(command) {
|
|
140
|
+
const argv = parseTransportArgv(command);
|
|
141
|
+
if (!argv)
|
|
142
|
+
return command;
|
|
143
|
+
return unwrapBashOrZsh(argv) ?? unwrapPowerShell(argv) ?? command;
|
|
144
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { ActivityRow } from "../../akuma/index.js";
|
|
2
|
-
type ToolRow = Extract<ActivityRow, {
|
|
1
|
+
import type { ActivityRow, SnapshotRow } from "../../akuma/index.js";
|
|
2
|
+
type ToolRow = Extract<ActivityRow | SnapshotRow, {
|
|
3
3
|
kind: "tool";
|
|
4
4
|
}>;
|
|
5
5
|
export type ToolRepr = Readonly<{
|
|
6
6
|
label: string;
|
|
7
7
|
text: string;
|
|
8
|
+
overflow?: "middle-ellipsis";
|
|
9
|
+
suffix?: string;
|
|
8
10
|
}>;
|
|
9
11
|
/** Pure provider-neutral tool presentation; it performs no activity selection. */
|
|
10
12
|
export declare function toolRepr(row: ToolRow): ToolRepr;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeToolCommand } from "./akuma-tool-command.js";
|
|
1
2
|
function oneLine(value) {
|
|
2
3
|
return value.replace(/\s+/gu, " ").trim();
|
|
3
4
|
}
|
|
@@ -12,7 +13,7 @@ function duration(milliseconds) {
|
|
|
12
13
|
return remainder === 0 ? `${minutes}m` : `${minutes}m ${remainder}s`;
|
|
13
14
|
}
|
|
14
15
|
function result(row) {
|
|
15
|
-
if (row.state === "
|
|
16
|
+
if (row.state === "active" || row.state === "unsettled")
|
|
16
17
|
return undefined;
|
|
17
18
|
const disposition = row.state.exitCode !== undefined
|
|
18
19
|
? row.state.exitCode === 0 ? "ok" : `exit ${row.state.exitCode}`
|
|
@@ -24,6 +25,31 @@ function result(row) {
|
|
|
24
25
|
];
|
|
25
26
|
return parts.length === 0 ? undefined : parts.join(" · ");
|
|
26
27
|
}
|
|
28
|
+
function readText(call) {
|
|
29
|
+
const path = oneLine(call.path);
|
|
30
|
+
if (call.offset !== undefined && call.limit !== undefined) {
|
|
31
|
+
return `${path} · L${call.offset}-${call.offset + call.limit - 1}`;
|
|
32
|
+
}
|
|
33
|
+
if (call.offset !== undefined)
|
|
34
|
+
return `${path} · from L${call.offset}`;
|
|
35
|
+
if (call.limit !== undefined)
|
|
36
|
+
return `${path} · ${call.limit} lines`;
|
|
37
|
+
return path;
|
|
38
|
+
}
|
|
39
|
+
function searchLabel(scope) {
|
|
40
|
+
if (scope === "files")
|
|
41
|
+
return "find";
|
|
42
|
+
if (scope === "web")
|
|
43
|
+
return "web";
|
|
44
|
+
return "search";
|
|
45
|
+
}
|
|
46
|
+
function searchText(call) {
|
|
47
|
+
return [
|
|
48
|
+
oneLine(call.query),
|
|
49
|
+
...(call.path === undefined ? [] : [oneLine(call.path)]),
|
|
50
|
+
...(call.glob === undefined ? [] : [oneLine(call.glob)]),
|
|
51
|
+
].join(" · ");
|
|
52
|
+
}
|
|
27
53
|
function fileChange(call) {
|
|
28
54
|
const first = call.changes[0];
|
|
29
55
|
if (first === undefined)
|
|
@@ -48,13 +74,13 @@ export function toolRepr(row) {
|
|
|
48
74
|
let core;
|
|
49
75
|
switch (row.call.kind) {
|
|
50
76
|
case "run":
|
|
51
|
-
core = { label: "run", text: `$ ${oneLine(row.call.command)}
|
|
77
|
+
core = { label: "run", text: `$ ${oneLine(normalizeToolCommand(row.call.command))}`, overflow: "middle-ellipsis" };
|
|
52
78
|
break;
|
|
53
79
|
case "read":
|
|
54
|
-
core = { label: "read", text:
|
|
80
|
+
core = { label: "read", text: readText(row.call) };
|
|
55
81
|
break;
|
|
56
82
|
case "search":
|
|
57
|
-
core = { label:
|
|
83
|
+
core = { label: searchLabel(row.call.scope), text: searchText(row.call) };
|
|
58
84
|
break;
|
|
59
85
|
case "fileChange":
|
|
60
86
|
core = fileChange(row.call);
|
|
@@ -64,5 +90,9 @@ export function toolRepr(row) {
|
|
|
64
90
|
break;
|
|
65
91
|
}
|
|
66
92
|
const suffix = result(row);
|
|
67
|
-
|
|
93
|
+
if (suffix === undefined)
|
|
94
|
+
return core;
|
|
95
|
+
return core.overflow === "middle-ellipsis"
|
|
96
|
+
? { ...core, suffix: ` — ${suffix}` }
|
|
97
|
+
: { ...core, text: `${core.text} — ${suffix}` };
|
|
68
98
|
}
|