@maiaos/cli 0.1.0-canary.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 +287 -0
- package/dist/bin/maia.NOTICES.txt +59 -0
- package/dist/bin/maia.cdx.json +145 -0
- package/dist/bin/maia.mjs +2 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.js +3 -0
- package/dist/bootstrap/process.d.ts +5 -0
- package/dist/bootstrap/process.js +45 -0
- package/dist/bootstrap/run.d.ts +25 -0
- package/dist/bootstrap/run.js +95 -0
- package/dist/bootstrap/stdio.d.ts +4 -0
- package/dist/bootstrap/stdio.js +9 -0
- package/dist/cli/cli.d.ts +17 -0
- package/dist/cli/cli.js +481 -0
- package/dist/cli/environment.d.ts +8 -0
- package/dist/cli/environment.js +12 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/services.d.ts +4 -0
- package/dist/cli/services.js +4 -0
- package/dist/command-line/context.d.ts +178 -0
- package/dist/command-line/context.js +2 -0
- package/dist/command-line/index.d.ts +7 -0
- package/dist/command-line/index.js +6 -0
- package/dist/command-line/input/arguments.d.ts +55 -0
- package/dist/command-line/input/arguments.js +220 -0
- package/dist/command-line/input/index.d.ts +4 -0
- package/dist/command-line/input/index.js +4 -0
- package/dist/command-line/input/prompt.d.ts +8 -0
- package/dist/command-line/input/prompt.js +44 -0
- package/dist/command-line/input/stdin-stream.d.ts +4 -0
- package/dist/command-line/input/stdin-stream.js +3 -0
- package/dist/command-line/input/stdin.d.ts +11 -0
- package/dist/command-line/input/stdin.js +23 -0
- package/dist/command-line/json-decoder.d.ts +3 -0
- package/dist/command-line/json-decoder.js +3 -0
- package/dist/command-line/json.d.ts +3 -0
- package/dist/command-line/json.js +4 -0
- package/dist/command-line/output.d.ts +57 -0
- package/dist/command-line/output.js +94 -0
- package/dist/command-line/rows.d.ts +10 -0
- package/dist/command-line/rows.js +32 -0
- package/dist/command-line/two-phase.d.ts +57 -0
- package/dist/command-line/two-phase.js +148 -0
- package/dist/command-receipt/command.d.ts +4 -0
- package/dist/command-receipt/command.js +59 -0
- package/dist/command-receipt/compact-list.d.ts +20 -0
- package/dist/command-receipt/compact-list.js +29 -0
- package/dist/command-receipt/index.d.ts +3 -0
- package/dist/command-receipt/index.js +3 -0
- package/dist/command-tree/commands.d.ts +17 -0
- package/dist/command-tree/commands.js +41 -0
- package/dist/command-tree/completion.d.ts +6 -0
- package/dist/command-tree/completion.js +36 -0
- package/dist/command-tree/grammar.d.ts +18 -0
- package/dist/command-tree/grammar.js +160 -0
- package/dist/command-tree/help.d.ts +62 -0
- package/dist/command-tree/help.js +219 -0
- package/dist/command-tree/index.d.ts +8 -0
- package/dist/command-tree/index.js +6 -0
- package/dist/command-tree/local.d.ts +3 -0
- package/dist/command-tree/local.js +126 -0
- package/dist/command-tree/placeholder.d.ts +3 -0
- package/dist/command-tree/placeholder.js +4 -0
- package/dist/command-tree/row.d.ts +29 -0
- package/dist/command-tree/row.js +2 -0
- package/dist/command-tree/suggest.d.ts +3 -0
- package/dist/command-tree/suggest.js +81 -0
- package/dist/command-tree/tree.d.ts +34 -0
- package/dist/command-tree/tree.js +124 -0
- package/dist/connection/client.d.ts +692 -0
- package/dist/connection/client.js +28 -0
- package/dist/connection/commands.d.ts +15 -0
- package/dist/connection/commands.js +118 -0
- package/dist/connection/index.d.ts +7 -0
- package/dist/connection/index.js +7 -0
- package/dist/connection/input.d.ts +50 -0
- package/dist/connection/input.js +90 -0
- package/dist/connection/login.d.ts +13 -0
- package/dist/connection/login.js +69 -0
- package/dist/connection/output/format.d.ts +32 -0
- package/dist/connection/output/format.js +94 -0
- package/dist/connection/output/index.d.ts +2 -0
- package/dist/connection/output/index.js +2 -0
- package/dist/connection/resolve.d.ts +60 -0
- package/dist/connection/resolve.js +30 -0
- package/dist/connection/signin.d.ts +4 -0
- package/dist/connection/signin.js +32 -0
- package/dist/connection/system.d.ts +4 -0
- package/dist/connection/system.js +190 -0
- package/dist/connection/tree/index.d.ts +2 -0
- package/dist/connection/tree/index.js +2 -0
- package/dist/connection/tree/tree.d.ts +3 -0
- package/dist/connection/tree/tree.js +209 -0
- package/dist/container/client.d.ts +142 -0
- package/dist/container/client.js +11 -0
- package/dist/container/commands.d.ts +7 -0
- package/dist/container/commands.js +100 -0
- package/dist/container/index.d.ts +3 -0
- package/dist/container/index.js +3 -0
- package/dist/container/output/format.d.ts +11 -0
- package/dist/container/output/format.js +28 -0
- package/dist/container/output/index.d.ts +2 -0
- package/dist/container/output/index.js +2 -0
- package/dist/context/client.d.ts +7 -0
- package/dist/context/client.js +21 -0
- package/dist/context/commands.d.ts +3 -0
- package/dist/context/commands.js +27 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.js +3 -0
- package/dist/development/cli.d.ts +3 -0
- package/dist/development/cli.js +44 -0
- package/dist/execution/client.d.ts +25 -0
- package/dist/execution/client.js +24 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +3 -0
- package/dist/execution/relocation.d.ts +6 -0
- package/dist/execution/relocation.js +123 -0
- package/dist/execution/tree/index.d.ts +2 -0
- package/dist/execution/tree/index.js +2 -0
- package/dist/execution/tree/tree.d.ts +3 -0
- package/dist/execution/tree/tree.js +137 -0
- package/dist/hold/client.d.ts +137 -0
- package/dist/hold/client.js +12 -0
- package/dist/hold/commands.d.ts +5 -0
- package/dist/hold/commands.js +91 -0
- package/dist/hold/index.d.ts +3 -0
- package/dist/hold/index.js +3 -0
- package/dist/hold/output/format.d.ts +11 -0
- package/dist/hold/output/format.js +29 -0
- package/dist/hold/output/index.d.ts +2 -0
- package/dist/hold/output/index.js +2 -0
- package/dist/hold/tree/index.d.ts +2 -0
- package/dist/hold/tree/index.js +2 -0
- package/dist/hold/tree/tree.d.ts +3 -0
- package/dist/hold/tree/tree.js +96 -0
- package/dist/import/client.d.ts +14 -0
- package/dist/import/client.js +16 -0
- package/dist/import/commands.d.ts +5 -0
- package/dist/import/commands.js +76 -0
- package/dist/import/index.d.ts +3 -0
- package/dist/import/index.js +3 -0
- package/dist/import/input.d.ts +16 -0
- package/dist/import/input.js +92 -0
- package/dist/import/output.d.ts +6 -0
- package/dist/import/output.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/integration/client.d.ts +1284 -0
- package/dist/integration/client.js +24 -0
- package/dist/integration/commands.d.ts +10 -0
- package/dist/integration/commands.js +104 -0
- package/dist/integration/index.d.ts +3 -0
- package/dist/integration/index.js +3 -0
- package/dist/integration/output.d.ts +22 -0
- package/dist/integration/output.js +20 -0
- package/dist/local-node/call.d.ts +7 -0
- package/dist/local-node/call.js +13 -0
- package/dist/local-node/client.d.ts +67 -0
- package/dist/local-node/client.js +241 -0
- package/dist/local-node/index.d.ts +3 -0
- package/dist/local-node/index.js +3 -0
- package/dist/login/agent-provider.d.ts +20 -0
- package/dist/login/agent-provider.js +109 -0
- package/dist/login/commands.d.ts +4 -0
- package/dist/login/commands.js +93 -0
- package/dist/login/failure.d.ts +3 -0
- package/dist/login/failure.js +14 -0
- package/dist/login/gateway.d.ts +12 -0
- package/dist/login/gateway.js +71 -0
- package/dist/login/index.d.ts +3 -0
- package/dist/login/index.js +2 -0
- package/dist/login/menu.d.ts +4 -0
- package/dist/login/menu.js +105 -0
- package/dist/login/output/format.d.ts +16 -0
- package/dist/login/output/format.js +31 -0
- package/dist/login/output/index.d.ts +2 -0
- package/dist/login/output/index.js +2 -0
- package/dist/login/vendor-account.d.ts +95 -0
- package/dist/login/vendor-account.js +75 -0
- package/dist/login/vendor-input.d.ts +14 -0
- package/dist/login/vendor-input.js +36 -0
- package/dist/mcp/calls.d.ts +7 -0
- package/dist/mcp/calls.js +202 -0
- package/dist/mcp/commands.d.ts +9 -0
- package/dist/mcp/commands.js +21 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +57 -0
- package/dist/orchestration/client.d.ts +78 -0
- package/dist/orchestration/client.js +89 -0
- package/dist/orchestration/commands.d.ts +14 -0
- package/dist/orchestration/commands.js +312 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/index.js +3 -0
- package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
- package/dist/orchestration/output/compact-aggregate.js +110 -0
- package/dist/orchestration/output/compact-run-list.d.ts +20 -0
- package/dist/orchestration/output/compact-run-list.js +16 -0
- package/dist/orchestration/output/human.d.ts +80 -0
- package/dist/orchestration/output/human.js +252 -0
- package/dist/orchestration/output/index.d.ts +4 -0
- package/dist/orchestration/output/index.js +4 -0
- package/dist/orchestration/tree/index.d.ts +2 -0
- package/dist/orchestration/tree/index.js +2 -0
- package/dist/orchestration/tree/tree.d.ts +3 -0
- package/dist/orchestration/tree/tree.js +142 -0
- package/dist/port-lease/client.d.ts +160 -0
- package/dist/port-lease/client.js +11 -0
- package/dist/port-lease/commands.d.ts +6 -0
- package/dist/port-lease/commands.js +17 -0
- package/dist/port-lease/index.d.ts +3 -0
- package/dist/port-lease/index.js +3 -0
- package/dist/port-lease/input.d.ts +65 -0
- package/dist/port-lease/input.js +67 -0
- package/dist/port-lease/output/format.d.ts +11 -0
- package/dist/port-lease/output/format.js +24 -0
- package/dist/port-lease/output/index.d.ts +2 -0
- package/dist/port-lease/output/index.js +2 -0
- package/dist/presentation/client.d.ts +10 -0
- package/dist/presentation/client.js +9 -0
- package/dist/presentation/commands.d.ts +6 -0
- package/dist/presentation/commands.js +78 -0
- package/dist/presentation/index.d.ts +4 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/output/format.d.ts +11 -0
- package/dist/presentation/output/format.js +32 -0
- package/dist/presentation/output/index.d.ts +3 -0
- package/dist/presentation/output/index.js +2 -0
- package/dist/project-guard/client.d.ts +88 -0
- package/dist/project-guard/client.js +7 -0
- package/dist/project-guard/commands.d.ts +4 -0
- package/dist/project-guard/commands.js +39 -0
- package/dist/project-guard/index.d.ts +3 -0
- package/dist/project-guard/index.js +3 -0
- package/dist/project-guard/input.d.ts +18 -0
- package/dist/project-guard/input.js +47 -0
- package/dist/project-guard/output/format.d.ts +11 -0
- package/dist/project-guard/output/format.js +35 -0
- package/dist/project-guard/output/index.d.ts +2 -0
- package/dist/project-guard/output/index.js +2 -0
- package/dist/project-workspace/client.d.ts +86 -0
- package/dist/project-workspace/client.js +159 -0
- package/dist/project-workspace/commands.d.ts +30 -0
- package/dist/project-workspace/commands.js +700 -0
- package/dist/project-workspace/index.d.ts +5 -0
- package/dist/project-workspace/index.js +5 -0
- package/dist/project-workspace/metadata-client.d.ts +99 -0
- package/dist/project-workspace/metadata-client.js +8 -0
- package/dist/project-workspace/metadata-commands.d.ts +4 -0
- package/dist/project-workspace/metadata-commands.js +56 -0
- package/dist/project-workspace/output/human.d.ts +126 -0
- package/dist/project-workspace/output/human.js +103 -0
- package/dist/project-workspace/output/index.d.ts +3 -0
- package/dist/project-workspace/output/index.js +3 -0
- package/dist/project-workspace/output/metadata.d.ts +11 -0
- package/dist/project-workspace/output/metadata.js +17 -0
- package/dist/project-workspace/tree/index.d.ts +2 -0
- package/dist/project-workspace/tree/index.js +2 -0
- package/dist/project-workspace/tree/tree.d.ts +3 -0
- package/dist/project-workspace/tree/tree.js +197 -0
- package/dist/provider/client.d.ts +6 -0
- package/dist/provider/client.js +5 -0
- package/dist/provider/commands.d.ts +3 -0
- package/dist/provider/commands.js +38 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.js +3 -0
- package/dist/reference/commands.d.ts +3 -0
- package/dist/reference/commands.js +39 -0
- package/dist/reference/index.d.ts +3 -0
- package/dist/reference/index.js +3 -0
- package/dist/reference/resolve.d.ts +29 -0
- package/dist/reference/resolve.js +294 -0
- package/dist/reference/tree/index.d.ts +2 -0
- package/dist/reference/tree/index.js +2 -0
- package/dist/reference/tree/tree.d.ts +3 -0
- package/dist/reference/tree/tree.js +17 -0
- package/dist/remote-node/client.d.ts +258 -0
- package/dist/remote-node/client.js +12 -0
- package/dist/remote-node/commands.d.ts +6 -0
- package/dist/remote-node/commands.js +264 -0
- package/dist/remote-node/connector.d.ts +59 -0
- package/dist/remote-node/connector.js +122 -0
- package/dist/remote-node/index.d.ts +4 -0
- package/dist/remote-node/index.js +4 -0
- package/dist/remote-node/reachability.d.ts +22 -0
- package/dist/remote-node/reachability.js +34 -0
- package/dist/remote-node/text.d.ts +9 -0
- package/dist/remote-node/text.js +64 -0
- package/dist/remote-node/tree/index.d.ts +2 -0
- package/dist/remote-node/tree/index.js +2 -0
- package/dist/remote-node/tree/tree.d.ts +3 -0
- package/dist/remote-node/tree/tree.js +51 -0
- package/dist/run-ledger/client.d.ts +358 -0
- package/dist/run-ledger/client.js +13 -0
- package/dist/run-ledger/commands.d.ts +8 -0
- package/dist/run-ledger/commands.js +19 -0
- package/dist/run-ledger/index.d.ts +3 -0
- package/dist/run-ledger/index.js +3 -0
- package/dist/run-ledger/input.d.ts +42 -0
- package/dist/run-ledger/input.js +107 -0
- package/dist/run-ledger/output/format.d.ts +11 -0
- package/dist/run-ledger/output/format.js +49 -0
- package/dist/run-ledger/output/index.d.ts +2 -0
- package/dist/run-ledger/output/index.js +2 -0
- package/dist/session/agent-permission.d.ts +63 -0
- package/dist/session/agent-permission.js +20 -0
- package/dist/session/approval/client.d.ts +117 -0
- package/dist/session/approval/client.js +7 -0
- package/dist/session/approval/commands.d.ts +7 -0
- package/dist/session/approval/commands.js +123 -0
- package/dist/session/approval/index.d.ts +3 -0
- package/dist/session/approval/index.js +3 -0
- package/dist/session/approval/output/format.d.ts +12 -0
- package/dist/session/approval/output/format.js +25 -0
- package/dist/session/approval/output/index.d.ts +2 -0
- package/dist/session/approval/output/index.js +2 -0
- package/dist/session/attach-client.d.ts +16 -0
- package/dist/session/attach-client.js +8 -0
- package/dist/session/attach-render.d.ts +16 -0
- package/dist/session/attach-render.js +154 -0
- package/dist/session/attach.d.ts +5 -0
- package/dist/session/attach.js +106 -0
- package/dist/session/client.d.ts +132 -0
- package/dist/session/client.js +128 -0
- package/dist/session/coding-client.d.ts +16 -0
- package/dist/session/coding-client.js +15 -0
- package/dist/session/coding-commands.d.ts +4 -0
- package/dist/session/coding-commands.js +50 -0
- package/dist/session/commands.d.ts +13 -0
- package/dist/session/commands.js +488 -0
- package/dist/session/create-tasks.d.ts +20 -0
- package/dist/session/create-tasks.js +110 -0
- package/dist/session/index.d.ts +9 -0
- package/dist/session/index.js +7 -0
- package/dist/session/interaction/client.d.ts +347 -0
- package/dist/session/interaction/client.js +15 -0
- package/dist/session/interaction/commands.d.ts +7 -0
- package/dist/session/interaction/commands.js +101 -0
- package/dist/session/interaction/index.d.ts +3 -0
- package/dist/session/interaction/index.js +3 -0
- package/dist/session/interaction/input.d.ts +15 -0
- package/dist/session/interaction/input.js +46 -0
- package/dist/session/interaction/output/format.d.ts +11 -0
- package/dist/session/interaction/output/format.js +3 -0
- package/dist/session/interaction/output/index.d.ts +2 -0
- package/dist/session/interaction/output/index.js +2 -0
- package/dist/session/output/diff.d.ts +3 -0
- package/dist/session/output/diff.js +30 -0
- package/dist/session/output/failure.d.ts +11 -0
- package/dist/session/output/failure.js +24 -0
- package/dist/session/output/human.d.ts +112 -0
- package/dist/session/output/human.js +71 -0
- package/dist/session/output/index.d.ts +6 -0
- package/dist/session/output/index.js +6 -0
- package/dist/session/output/observe.d.ts +4 -0
- package/dist/session/output/observe.js +46 -0
- package/dist/session/output/tasks.d.ts +19 -0
- package/dist/session/output/tasks.js +34 -0
- package/dist/session/rename.d.ts +3 -0
- package/dist/session/rename.js +37 -0
- package/dist/session/task-file.d.ts +5 -0
- package/dist/session/task-file.js +23 -0
- package/dist/session/tree/index.d.ts +2 -0
- package/dist/session/tree/index.js +2 -0
- package/dist/session/tree/tree.d.ts +3 -0
- package/dist/session/tree/tree.js +309 -0
- package/dist/session/turn/client.d.ts +25 -0
- package/dist/session/turn/client.js +40 -0
- package/dist/session/turn/commands.d.ts +6 -0
- package/dist/session/turn/commands.js +157 -0
- package/dist/session/turn/index.d.ts +4 -0
- package/dist/session/turn/index.js +3 -0
- package/dist/session/turn/output.d.ts +42 -0
- package/dist/session/turn/output.js +38 -0
- package/dist/status/client.d.ts +119 -0
- package/dist/status/client.js +5 -0
- package/dist/status/command.d.ts +4 -0
- package/dist/status/command.js +40 -0
- package/dist/status/doctor.d.ts +15 -0
- package/dist/status/doctor.js +111 -0
- package/dist/status/index.d.ts +5 -0
- package/dist/status/index.js +4 -0
- package/dist/status/output/compact.d.ts +31 -0
- package/dist/status/output/compact.js +46 -0
- package/dist/status/output/human.d.ts +7 -0
- package/dist/status/output/human.js +30 -0
- package/dist/status/output/index.d.ts +3 -0
- package/dist/status/output/index.js +3 -0
- package/dist/terminal/arguments.d.ts +13 -0
- package/dist/terminal/arguments.js +79 -0
- package/dist/terminal/client.d.ts +79 -0
- package/dist/terminal/client.js +68 -0
- package/dist/terminal/commands.d.ts +7 -0
- package/dist/terminal/commands.js +131 -0
- package/dist/terminal/control-commands.d.ts +10 -0
- package/dist/terminal/control-commands.js +212 -0
- package/dist/terminal/index.d.ts +4 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/output/compact-list.d.ts +147 -0
- package/dist/terminal/output/compact-list.js +152 -0
- package/dist/terminal/output/human.d.ts +59 -0
- package/dist/terminal/output/human.js +55 -0
- package/dist/terminal/output/index.d.ts +3 -0
- package/dist/terminal/output/index.js +3 -0
- package/dist/terminal/tree/index.d.ts +2 -0
- package/dist/terminal/tree/index.js +2 -0
- package/dist/terminal/tree/tree.d.ts +3 -0
- package/dist/terminal/tree/tree.js +104 -0
- package/guidance/maia-cli/SKILL.md +58 -0
- package/guidance/maia-orchestration/SKILL.md +54 -0
- package/package.json +76 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const PATH_WORD = /^[a-z][a-z0-9-]*$/u;
|
|
2
|
+
const RANGE = /^<(\d+)\.\.(\d+)(?: [a-z]+)?>$/u;
|
|
3
|
+
const CHOICES = /^<([a-z0-9-]+(?:\|[a-z0-9-]+)+)>$/u;
|
|
4
|
+
const LIST = /^<([a-z-]+)>\[,<[a-z-]+>\.\.\.\]$/u;
|
|
5
|
+
const splitTopLevel = (text, separator) => {
|
|
6
|
+
const cuts = (text.match(/./gsu) ?? []).reduce((state, character, index) => {
|
|
7
|
+
if ("[(<".includes(character))
|
|
8
|
+
return { ...state, depth: state.depth + 1 };
|
|
9
|
+
if ("])>".includes(character))
|
|
10
|
+
return { ...state, depth: state.depth - 1 };
|
|
11
|
+
return character === separator &&
|
|
12
|
+
state.depth === 0 &&
|
|
13
|
+
(separator === " " || text[index - 1] === " ")
|
|
14
|
+
? { ...state, indexes: [...state.indexes, index] }
|
|
15
|
+
: state;
|
|
16
|
+
}, { depth: 0, indexes: [] }).indexes;
|
|
17
|
+
return [-1, ...cuts]
|
|
18
|
+
.map((cut, position) => text.slice(cut + 1, cuts[position] ?? text.length))
|
|
19
|
+
.map((part) => part.trim())
|
|
20
|
+
.filter((part) => part !== "");
|
|
21
|
+
};
|
|
22
|
+
const NAMED_TYPES = [
|
|
23
|
+
[/^(?:revision|epoch|n|port)$/u, "integer"],
|
|
24
|
+
[/cursor$/u, "cursor"],
|
|
25
|
+
[/(?:^|-)id$/u, "id"],
|
|
26
|
+
[/(?:path|repository|dir|executable|\.json)$/u, "path"],
|
|
27
|
+
[/^url$/u, "url"],
|
|
28
|
+
[/^duration$/u, "duration"],
|
|
29
|
+
[/^(?:digest|sha256)$/u, "digest"],
|
|
30
|
+
[/(?:timestamp|recorded-at)$/u, "timestamp"],
|
|
31
|
+
];
|
|
32
|
+
const describeValue = (value) => {
|
|
33
|
+
const range = RANGE.exec(value);
|
|
34
|
+
if (range !== null)
|
|
35
|
+
return { max: Number(range[2]), min: Number(range[1]), type: "integer" };
|
|
36
|
+
const choices = CHOICES.exec(value);
|
|
37
|
+
if (choices !== null)
|
|
38
|
+
return { choices: (choices[1] ?? "").split("|"), type: "choice" };
|
|
39
|
+
if (LIST.test(value))
|
|
40
|
+
return { type: "list" };
|
|
41
|
+
if (!value.startsWith("<")) {
|
|
42
|
+
return value.includes(",")
|
|
43
|
+
? { choices: value.split(","), type: "list" }
|
|
44
|
+
: { choices: [value], type: "choice" };
|
|
45
|
+
}
|
|
46
|
+
const name = /^<([a-z0-9.-]+)>$/u.exec(value)?.[1];
|
|
47
|
+
const named = name === undefined
|
|
48
|
+
? undefined
|
|
49
|
+
: NAMED_TYPES.find(([pattern]) => pattern.test(name));
|
|
50
|
+
return named === undefined ? {} : { type: named[1] };
|
|
51
|
+
};
|
|
52
|
+
const pushArgument = (state, argument, scope) => {
|
|
53
|
+
if (state.output.some((existing) => existing.name === argument.name))
|
|
54
|
+
return;
|
|
55
|
+
state.output.push({
|
|
56
|
+
...argument,
|
|
57
|
+
...(scope.oneOf === undefined ? {} : { oneOf: scope.oneOf }),
|
|
58
|
+
...(scope.optional ? {} : { required: true }),
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const isValueToken = (token) => token !== undefined && !/^[-[(|]/u.test(token);
|
|
62
|
+
const parseGroup = (state, token, scope) => {
|
|
63
|
+
const alternatives = splitTopLevel(token.slice(1, -1), "|");
|
|
64
|
+
const oneOf = alternatives.length > 1 ? (state.groups += 1) : scope.oneOf;
|
|
65
|
+
alternatives.forEach((alternative) => {
|
|
66
|
+
parseSequence(state, splitTopLevel(alternative, " "), {
|
|
67
|
+
optional: scope.optional || token.startsWith("["),
|
|
68
|
+
...(oneOf === undefined ? {} : { oneOf }),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const parseOption = (state, [token = "", next], scope) => {
|
|
73
|
+
const name = token.split("|").at(-1) ?? token;
|
|
74
|
+
if (!isValueToken(next)) {
|
|
75
|
+
pushArgument(state, { name }, scope);
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
pushArgument(state, { name, value: next, ...describeValue(next) }, scope);
|
|
79
|
+
return 2;
|
|
80
|
+
};
|
|
81
|
+
const parseToken = (state, tokens, scope) => {
|
|
82
|
+
const [token = ""] = tokens;
|
|
83
|
+
if (token.startsWith("[") || token.startsWith("(")) {
|
|
84
|
+
parseGroup(state, token, scope);
|
|
85
|
+
}
|
|
86
|
+
else if (token === "--") {
|
|
87
|
+
pushArgument(state, { name: "--", type: "separator" }, scope);
|
|
88
|
+
}
|
|
89
|
+
else if (token.startsWith("-")) {
|
|
90
|
+
return parseOption(state, tokens, scope);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const name = token.replace(/\.\.\.$/u, "");
|
|
94
|
+
pushArgument(state, {
|
|
95
|
+
name,
|
|
96
|
+
...(name.startsWith("<") ? describeValue(name) : {}),
|
|
97
|
+
...(token.endsWith("...") ? { repeated: true } : {}),
|
|
98
|
+
}, scope);
|
|
99
|
+
}
|
|
100
|
+
return 1;
|
|
101
|
+
};
|
|
102
|
+
const parseSequence = (state, tokens, scope) => {
|
|
103
|
+
if (tokens.length === 0)
|
|
104
|
+
return;
|
|
105
|
+
parseSequence(state, tokens.slice(parseToken(state, tokens, scope)), scope);
|
|
106
|
+
};
|
|
107
|
+
export const parseUsage = (usage) => {
|
|
108
|
+
const tokens = splitTopLevel(usage, " ");
|
|
109
|
+
const boundary = tokens.findIndex((token) => !PATH_WORD.test(token));
|
|
110
|
+
const pathLength = boundary === -1 ? tokens.length : boundary;
|
|
111
|
+
const state = { groups: 0, output: [] };
|
|
112
|
+
parseSequence(state, tokens.slice(pathLength), { optional: false });
|
|
113
|
+
return { args: state.output, path: tokens.slice(0, pathLength) };
|
|
114
|
+
};
|
|
115
|
+
const SAMPLE_VALUES = [
|
|
116
|
+
[/^<command-id>$/u, "cmd-1"],
|
|
117
|
+
[/^<(?:[a-z]+-)*([a-z]+)-id>$/u, "$1_1"],
|
|
118
|
+
[/^<relative-path>$/u, "README.md"],
|
|
119
|
+
[/^<absolute-executable>$/u, "/usr/bin/env"],
|
|
120
|
+
[/^<url>$/u, "https://example.com"],
|
|
121
|
+
[/^<id>$/u, "id-1"],
|
|
122
|
+
[/^<timestamp>$/u, "2026-01-01T00:00:00Z"],
|
|
123
|
+
[/^<duration>$/u, "30s"],
|
|
124
|
+
[/^<text>$|^<answer>$/u, "'text'"],
|
|
125
|
+
];
|
|
126
|
+
const sampleFor = (argument) => {
|
|
127
|
+
const raw = argument.value ?? argument.name;
|
|
128
|
+
if (argument.choices !== undefined)
|
|
129
|
+
return argument.choices[0] ?? raw;
|
|
130
|
+
if (argument.min !== undefined)
|
|
131
|
+
return String(argument.min);
|
|
132
|
+
const sample = SAMPLE_VALUES.find(([pattern]) => pattern.test(raw));
|
|
133
|
+
if (sample !== undefined)
|
|
134
|
+
return raw.replace(sample[0], sample[1]);
|
|
135
|
+
if (argument.type === "integer" || argument.type === "cursor")
|
|
136
|
+
return "1";
|
|
137
|
+
if (argument.type === "path")
|
|
138
|
+
return ".";
|
|
139
|
+
return raw.replaceAll(/[<>]/gu, "").replace(/\[.*$/u, "");
|
|
140
|
+
};
|
|
141
|
+
const isBareOption = (argument) => argument.type === "separator" ||
|
|
142
|
+
(argument.name.startsWith("-") && argument.value === undefined);
|
|
143
|
+
export const exampleFor = (form) => {
|
|
144
|
+
const seen = new Set();
|
|
145
|
+
const words = form.args.flatMap((argument) => {
|
|
146
|
+
if (argument.required === undefined)
|
|
147
|
+
return [];
|
|
148
|
+
if (argument.oneOf !== undefined) {
|
|
149
|
+
if (seen.has(argument.oneOf))
|
|
150
|
+
return [];
|
|
151
|
+
seen.add(argument.oneOf);
|
|
152
|
+
}
|
|
153
|
+
if (isBareOption(argument))
|
|
154
|
+
return [argument.name];
|
|
155
|
+
const sample = sampleFor(argument);
|
|
156
|
+
return argument.name.startsWith("-") ? [argument.name, sample] : [sample];
|
|
157
|
+
});
|
|
158
|
+
return ["maia", ...form.path, ...words].join(" ");
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=grammar.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type TreeArgument } from "./grammar.js";
|
|
2
|
+
import type { TreeLeafKind } from "./row.js";
|
|
3
|
+
import { type TreeAvailability, type TreeNode } from "./tree.js";
|
|
4
|
+
export declare const CLI_CONTRACT: {
|
|
5
|
+
readonly envelope: {
|
|
6
|
+
readonly failure: '{"ok":false,"error":{"code","message","retryable"},"usage"?,"hint"?,"recovery"?} on stderr';
|
|
7
|
+
readonly success: '{"ok":true,"resolved"?,"result":{"command","result"}} on stdout';
|
|
8
|
+
};
|
|
9
|
+
readonly exitCodes: readonly [readonly [0, "done"], readonly [64, "invalid usage"], readonly [66, "unknown ID"], readonly [69, "Node unavailable"], readonly [70, "other failure: read the message"], readonly [74, "deadline reached"], readonly [75, "retry later: revision changed, full, limited or held"], readonly [76, "outcome unknown: run maia receipt show <command-id>"], readonly [77, "not permitted"]];
|
|
10
|
+
readonly grammar: "<x> is a value, [x] optional, (a | b) one of, <a|b> a choice, <1..100> an integer range, <duration> 30s, 10m or 1h, x... repeats; 'maia <command> --help --json' lists typed arguments.";
|
|
11
|
+
readonly idempotency: "A mutation that guards a revision takes the current --expected-revision (or a named --expected-*-revision); --command-id <id> names the mutation, and a retry with the same command ID replays the first result.";
|
|
12
|
+
readonly input: "Prompts appear only when stdin and stderr are terminals and --json and --no-input (MAIA_NO_INPUT=1) are absent; otherwise a command that confirms fails (exit 64) and names its flags. A two-phase command previews with --dry-run and confirms that preview from stdin with --confirm-stdin.";
|
|
13
|
+
readonly pagination: "Lists take --limit and --after <cursor>; pass the result's nextCursor as --after.";
|
|
14
|
+
readonly precedence: "A flag wins over its environment variable (MAIA_PROFILE, MAIA_NODE, MAIA_NO_INPUT), which wins over the default.";
|
|
15
|
+
readonly references: "A resource argument takes a full ID, a unique ID prefix of 4+ hex digits or a unique name or Session title; an ambiguous one fails (exit 64) listing candidates. A missing required --project or --workspace comes from the current folder, then the selected Workspace. 'resolved' lists each argument the CLI resolved and how.";
|
|
16
|
+
readonly version: 3;
|
|
17
|
+
};
|
|
18
|
+
declare const GLOBAL_OPTIONS: readonly ["--json", "--profile <name>", "--node <name>", "--no-input", "-h|--help"];
|
|
19
|
+
type HelpChild = {
|
|
20
|
+
readonly availability?: TreeAvailability;
|
|
21
|
+
readonly kind: "group" | TreeLeafKind;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly summary: string;
|
|
24
|
+
};
|
|
25
|
+
type HelpForm = {
|
|
26
|
+
readonly args?: readonly TreeArgument[];
|
|
27
|
+
readonly availability: TreeAvailability;
|
|
28
|
+
readonly summary?: string;
|
|
29
|
+
readonly usage: string;
|
|
30
|
+
};
|
|
31
|
+
export type CliHelpNode = HelpChild & Partial<Omit<HelpForm, "summary">> & {
|
|
32
|
+
readonly children?: readonly (CliHelpNode | HelpChild)[];
|
|
33
|
+
readonly example?: string;
|
|
34
|
+
readonly forms?: readonly HelpForm[];
|
|
35
|
+
readonly operations?: readonly string[];
|
|
36
|
+
};
|
|
37
|
+
export type CliHelpTreeResult = {
|
|
38
|
+
readonly command: "help";
|
|
39
|
+
readonly commands: readonly CliHelpNode[];
|
|
40
|
+
readonly contract: typeof CLI_CONTRACT;
|
|
41
|
+
readonly globalOptions: typeof GLOBAL_OPTIONS;
|
|
42
|
+
readonly name: "maia";
|
|
43
|
+
readonly registryDigest: string;
|
|
44
|
+
readonly version: string;
|
|
45
|
+
};
|
|
46
|
+
export type CliHelpNodeResult = CliHelpNode & {
|
|
47
|
+
readonly command: "help";
|
|
48
|
+
readonly path: string;
|
|
49
|
+
readonly version: string;
|
|
50
|
+
};
|
|
51
|
+
export type CliHelpResult = CliHelpNodeResult | CliHelpTreeResult;
|
|
52
|
+
export declare const leafExample: (node: TreeNode) => string | undefined;
|
|
53
|
+
export declare const formatNodeHelp: (node: TreeNode) => string;
|
|
54
|
+
export declare const formatRootHelp: (version: string) => string;
|
|
55
|
+
export declare const createHelpTree: (version: string) => CliHelpTreeResult;
|
|
56
|
+
export declare const createNodeHelp: (version: string, node: TreeNode) => CliHelpNodeResult;
|
|
57
|
+
export declare const usageHint: (tokens: readonly string[]) => {
|
|
58
|
+
readonly hint: string;
|
|
59
|
+
readonly usage: readonly string[];
|
|
60
|
+
};
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { exampleFor, parseUsage } from "./grammar.js";
|
|
2
|
+
import { commandTree, createTreeDigest, findNode, TREE_SECTIONS, } from "./tree.js";
|
|
3
|
+
export const CLI_CONTRACT = {
|
|
4
|
+
envelope: {
|
|
5
|
+
failure: '{"ok":false,"error":{"code","message","retryable"},"usage"?,"hint"?,"recovery"?} on stderr',
|
|
6
|
+
success: '{"ok":true,"resolved"?,"result":{"command","result"}} on stdout',
|
|
7
|
+
},
|
|
8
|
+
exitCodes: [
|
|
9
|
+
[0, "done"],
|
|
10
|
+
[64, "invalid usage"],
|
|
11
|
+
[66, "unknown ID"],
|
|
12
|
+
[69, "Node unavailable"],
|
|
13
|
+
[70, "other failure: read the message"],
|
|
14
|
+
[74, "deadline reached"],
|
|
15
|
+
[75, "retry later: revision changed, full, limited or held"],
|
|
16
|
+
[76, "outcome unknown: run maia receipt show <command-id>"],
|
|
17
|
+
[77, "not permitted"],
|
|
18
|
+
],
|
|
19
|
+
grammar: "<x> is a value, [x] optional, (a | b) one of, <a|b> a choice, <1..100> an integer range, <duration> 30s, 10m or 1h, x... repeats; 'maia <command> --help --json' lists typed arguments.",
|
|
20
|
+
idempotency: "A mutation that guards a revision takes the current --expected-revision (or a named --expected-*-revision); --command-id <id> names the mutation, and a retry with the same command ID replays the first result.",
|
|
21
|
+
input: "Prompts appear only when stdin and stderr are terminals and --json and --no-input (MAIA_NO_INPUT=1) are absent; otherwise a command that confirms fails (exit 64) and names its flags. A two-phase command previews with --dry-run and confirms that preview from stdin with --confirm-stdin.",
|
|
22
|
+
pagination: "Lists take --limit and --after <cursor>; pass the result's nextCursor as --after.",
|
|
23
|
+
precedence: "A flag wins over its environment variable (MAIA_PROFILE, MAIA_NODE, MAIA_NO_INPUT), which wins over the default.",
|
|
24
|
+
references: "A resource argument takes a full ID, a unique ID prefix of 4+ hex digits or a unique name or Session title; an ambiguous one fails (exit 64) listing candidates. A missing required --project or --workspace comes from the current folder, then the selected Workspace. 'resolved' lists each argument the CLI resolved and how.",
|
|
25
|
+
version: 3,
|
|
26
|
+
};
|
|
27
|
+
const GLOBAL_OPTIONS = [
|
|
28
|
+
"--json",
|
|
29
|
+
"--profile <name>",
|
|
30
|
+
"--node <name>",
|
|
31
|
+
"--no-input",
|
|
32
|
+
"-h|--help",
|
|
33
|
+
];
|
|
34
|
+
const GLOBAL_LINE = `Global options: ${GLOBAL_OPTIONS.join(", ")} (anywhere before --)`;
|
|
35
|
+
const nodeAvailability = (node) => {
|
|
36
|
+
const values = new Set(node.forms.map((form) => form.availability));
|
|
37
|
+
return values.size === 1 ? [...values][0] : undefined;
|
|
38
|
+
};
|
|
39
|
+
const describeChild = (node) => {
|
|
40
|
+
const availability = nodeAvailability(node);
|
|
41
|
+
return {
|
|
42
|
+
...(availability === undefined ? {} : { availability }),
|
|
43
|
+
kind: node.kind ?? "group",
|
|
44
|
+
name: node.name,
|
|
45
|
+
summary: node.summary,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export const leafExample = (node) => {
|
|
49
|
+
const form = node.forms[0];
|
|
50
|
+
if (node.example !== undefined)
|
|
51
|
+
return node.example;
|
|
52
|
+
return form === undefined ? undefined : exampleFor(parseUsage(form.usage));
|
|
53
|
+
};
|
|
54
|
+
const formFields = (form, typed) => ({
|
|
55
|
+
...(typed ? { args: parseUsage(form.usage).args } : {}),
|
|
56
|
+
availability: form.availability,
|
|
57
|
+
usage: `maia ${form.usage}`,
|
|
58
|
+
});
|
|
59
|
+
const describeLeaf = (node, typed) => {
|
|
60
|
+
const [first] = node.forms;
|
|
61
|
+
if (first === undefined)
|
|
62
|
+
return {};
|
|
63
|
+
return {
|
|
64
|
+
...(node.forms.length === 1
|
|
65
|
+
? formFields(first, typed)
|
|
66
|
+
: {
|
|
67
|
+
forms: node.forms.map((form) => ({
|
|
68
|
+
...formFields(form, typed),
|
|
69
|
+
summary: form.summary,
|
|
70
|
+
})),
|
|
71
|
+
}),
|
|
72
|
+
example: leafExample(node) ?? "",
|
|
73
|
+
operations: node.operations,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const describeNode = (node, deep) => ({
|
|
77
|
+
...describeChild(node),
|
|
78
|
+
...describeLeaf(node, !deep),
|
|
79
|
+
...(node.children.length === 0
|
|
80
|
+
? {}
|
|
81
|
+
: {
|
|
82
|
+
children: node.children.map((child) => deep ? describeNode(child, true) : describeChild(child)),
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
const pad = (rows) => {
|
|
86
|
+
const width = Math.max(...rows.map(([left]) => left.length)) + 2;
|
|
87
|
+
return rows.map(([left, right]) => ` ${left.padEnd(width)}${right}`);
|
|
88
|
+
};
|
|
89
|
+
const candidateMark = (node) => nodeAvailability(node) === "source_implemented_candidate"
|
|
90
|
+
? " (candidate)"
|
|
91
|
+
: "";
|
|
92
|
+
const childLines = (node) => pad(node.children.map((child) => [
|
|
93
|
+
child.name,
|
|
94
|
+
`${child.summary}${candidateMark(child)}`,
|
|
95
|
+
]));
|
|
96
|
+
const describeArgument = (argument) => {
|
|
97
|
+
const bounds = argument.min === undefined
|
|
98
|
+
? ""
|
|
99
|
+
: ` ${String(argument.min)}..${String(argument.max)}`;
|
|
100
|
+
return [
|
|
101
|
+
`${argument.type ?? (argument.value === undefined ? "flag" : "text")}${bounds}`,
|
|
102
|
+
...(argument.required === undefined ? [] : ["required"]),
|
|
103
|
+
...(argument.repeated === undefined ? [] : ["repeatable"]),
|
|
104
|
+
...(argument.oneOf === undefined
|
|
105
|
+
? []
|
|
106
|
+
: [`one of group ${String(argument.oneOf)}`]),
|
|
107
|
+
].join(", ");
|
|
108
|
+
};
|
|
109
|
+
const operationLine = (node) => {
|
|
110
|
+
if (node.operations.length === 0)
|
|
111
|
+
return `Kind: ${node.kind ?? "local"}`;
|
|
112
|
+
const label = node.operations.length > 1 ? "Operations" : "Operation";
|
|
113
|
+
const kind = node.kind === "operation" ? "" : ` (${node.kind ?? ""})`;
|
|
114
|
+
return `${label}: ${node.operations.join(", ")}${kind}`;
|
|
115
|
+
};
|
|
116
|
+
const argumentLines = (node) => {
|
|
117
|
+
const entries = node.forms
|
|
118
|
+
.flatMap((form) => parseUsage(form.usage).args)
|
|
119
|
+
.filter((argument, index, all) => all.findIndex((other) => other.name === argument.name) === index);
|
|
120
|
+
return entries.length === 0
|
|
121
|
+
? []
|
|
122
|
+
: [
|
|
123
|
+
"",
|
|
124
|
+
"Arguments:",
|
|
125
|
+
...pad(entries.map((argument) => [
|
|
126
|
+
argument.value === undefined
|
|
127
|
+
? argument.name
|
|
128
|
+
: `${argument.name} ${argument.value}`,
|
|
129
|
+
describeArgument(argument),
|
|
130
|
+
])),
|
|
131
|
+
];
|
|
132
|
+
};
|
|
133
|
+
const usageLines = (node) => {
|
|
134
|
+
const [form] = node.forms;
|
|
135
|
+
if (node.forms.length === 1 && form !== undefined)
|
|
136
|
+
return [
|
|
137
|
+
`Usage: maia ${form.usage}`,
|
|
138
|
+
`${form.summary}${candidateMark(node)}`,
|
|
139
|
+
];
|
|
140
|
+
return [
|
|
141
|
+
`${node.summary}${candidateMark(node)}`,
|
|
142
|
+
"",
|
|
143
|
+
"Usage:",
|
|
144
|
+
...node.forms.map((each) => ` maia ${each.usage}\n ${each.summary}`),
|
|
145
|
+
];
|
|
146
|
+
};
|
|
147
|
+
const formatLeaf = (node) => [
|
|
148
|
+
...usageLines(node),
|
|
149
|
+
...argumentLines(node),
|
|
150
|
+
"",
|
|
151
|
+
"Example:",
|
|
152
|
+
` ${leafExample(node) ?? ""}`,
|
|
153
|
+
operationLine(node),
|
|
154
|
+
];
|
|
155
|
+
const formatGroup = (node) => [
|
|
156
|
+
...(node.forms.length === 0
|
|
157
|
+
? [`Usage: maia ${node.path.join(" ")} <command>`, node.summary]
|
|
158
|
+
: []),
|
|
159
|
+
"",
|
|
160
|
+
"Commands:",
|
|
161
|
+
...childLines(node),
|
|
162
|
+
"",
|
|
163
|
+
`Run 'maia ${node.path.join(" ")} <command> --help' for details.`,
|
|
164
|
+
];
|
|
165
|
+
export const formatNodeHelp = (node) => `${[
|
|
166
|
+
...(node.forms.length === 0 ? [] : formatLeaf(node)),
|
|
167
|
+
...(node.children.length === 0 ? [] : formatGroup(node)),
|
|
168
|
+
GLOBAL_LINE,
|
|
169
|
+
].join("\n")}\n`;
|
|
170
|
+
export const formatRootHelp = (version) => {
|
|
171
|
+
const root = commandTree();
|
|
172
|
+
const sections = TREE_SECTIONS.flatMap(([title, names]) => [
|
|
173
|
+
"",
|
|
174
|
+
title,
|
|
175
|
+
...pad(names.map((name) => {
|
|
176
|
+
const node = root.children.find((child) => child.name === name);
|
|
177
|
+
return [name, node === undefined ? "" : node.summary];
|
|
178
|
+
})),
|
|
179
|
+
]);
|
|
180
|
+
return `${[
|
|
181
|
+
`Maia CLI ${version}`,
|
|
182
|
+
"",
|
|
183
|
+
`Usage: maia [--json] [--profile <name>] [--node <name>] [--no-input] <command> [-h|--help]`,
|
|
184
|
+
...sections,
|
|
185
|
+
"",
|
|
186
|
+
"Run 'maia <command> --help' for one command; 'maia help --json' describes every command.",
|
|
187
|
+
].join("\n")}\n`;
|
|
188
|
+
};
|
|
189
|
+
export const createHelpTree = (version) => ({
|
|
190
|
+
command: "help",
|
|
191
|
+
commands: commandTree().children.map((child) => describeNode(child, true)),
|
|
192
|
+
contract: CLI_CONTRACT,
|
|
193
|
+
globalOptions: GLOBAL_OPTIONS,
|
|
194
|
+
name: "maia",
|
|
195
|
+
registryDigest: createTreeDigest(),
|
|
196
|
+
version,
|
|
197
|
+
});
|
|
198
|
+
export const createNodeHelp = (version, node) => ({
|
|
199
|
+
command: "help",
|
|
200
|
+
...describeNode(node, false),
|
|
201
|
+
path: node.path.join(" "),
|
|
202
|
+
version,
|
|
203
|
+
});
|
|
204
|
+
export const usageHint = (tokens) => {
|
|
205
|
+
const { node } = findNode(tokens);
|
|
206
|
+
const path = node.path.join(" ");
|
|
207
|
+
const usage = [
|
|
208
|
+
...node.forms.map((form) => `maia ${form.usage}`),
|
|
209
|
+
...(node.children.length > 0 || node.path.length === 0
|
|
210
|
+
? [`maia ${path === "" ? "" : `${path} `}<command>`]
|
|
211
|
+
: []),
|
|
212
|
+
];
|
|
213
|
+
const example = leafExample(node);
|
|
214
|
+
return {
|
|
215
|
+
hint: `${example === undefined ? "" : `Example: ${example}\n`}Run 'maia ${path === "" ? "" : `${path} `}--help' for details.`,
|
|
216
|
+
usage,
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { CliVersionResult } from "./commands.js";
|
|
2
|
+
export { exampleFor, parseUsage, type TreeArgument, type TreeForm, } from "./grammar.js";
|
|
3
|
+
export { CLI_CONTRACT, type CliHelpNode, type CliHelpNodeResult, type CliHelpResult, type CliHelpTreeResult, createHelpTree, createNodeHelp, formatNodeHelp, formatRootHelp, leafExample, usageHint, } from "./help.js";
|
|
4
|
+
export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE } from "./placeholder.js";
|
|
5
|
+
export type { GroupRow, LeafRow, LeafRunner, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation, } from "./row.js";
|
|
6
|
+
export { suggestPaths, unknownPathMessage } from "./suggest.js";
|
|
7
|
+
export { commandTree, createTreeDigest, findNode, isNodeBacked, TREE_FRAGMENTS, TREE_SECTIONS, type TreeAvailability, type TreeLeafForm, type TreeNode, treeNodes, treeUsages, usagePath, } from "./tree.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { exampleFor, parseUsage, } from "./grammar.js";
|
|
2
|
+
export { CLI_CONTRACT, createHelpTree, createNodeHelp, formatNodeHelp, formatRootHelp, leafExample, usageHint, } from "./help.js";
|
|
3
|
+
export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE } from "./placeholder.js";
|
|
4
|
+
export { suggestPaths, unknownPathMessage } from "./suggest.js";
|
|
5
|
+
export { commandTree, createTreeDigest, findNode, isNodeBacked, TREE_FRAGMENTS, TREE_SECTIONS, treeNodes, treeUsages, usagePath, } from "./tree.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const local = () => import("./commands.js");
|
|
2
|
+
const doctor = () => import("../status/index.js");
|
|
3
|
+
const mcp = () => import("../mcp/index.js");
|
|
4
|
+
const presentation = () => import("../presentation/index.js");
|
|
5
|
+
const agent = [local, "runAgent"];
|
|
6
|
+
export const LOCAL_TREE = {
|
|
7
|
+
groups: [
|
|
8
|
+
["agent extension", "Agent extensions."],
|
|
9
|
+
["presentation", "Read-only view specifications."],
|
|
10
|
+
["presentation catalog", "The presentation view catalog."],
|
|
11
|
+
["presentation workspace-directory", "The Workspace directory view."],
|
|
12
|
+
["presentation project-list", "The Project list view."],
|
|
13
|
+
["presentation session-list", "The Session list view."],
|
|
14
|
+
],
|
|
15
|
+
leaves: [
|
|
16
|
+
[
|
|
17
|
+
"help [<command>...]",
|
|
18
|
+
0,
|
|
19
|
+
"",
|
|
20
|
+
"Show help for the CLI or one command.",
|
|
21
|
+
{
|
|
22
|
+
example: "maia --json help session create",
|
|
23
|
+
kind: "local",
|
|
24
|
+
run: [local, "runHelp"],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
"version",
|
|
29
|
+
0,
|
|
30
|
+
"",
|
|
31
|
+
"Show the CLI version, protocol and commit.",
|
|
32
|
+
{
|
|
33
|
+
example: "maia --json version",
|
|
34
|
+
kind: "local",
|
|
35
|
+
run: [local, "runVersion"],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"completion <bash|zsh|fish>",
|
|
40
|
+
0,
|
|
41
|
+
"",
|
|
42
|
+
"Print a shell completion script.",
|
|
43
|
+
{
|
|
44
|
+
example: "maia completion zsh",
|
|
45
|
+
kind: "local",
|
|
46
|
+
run: [local, "runCompletion"],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"doctor",
|
|
51
|
+
0,
|
|
52
|
+
"",
|
|
53
|
+
"Check this installation, the Node and accounts; name each fix.",
|
|
54
|
+
{
|
|
55
|
+
example: "maia doctor",
|
|
56
|
+
kind: "local",
|
|
57
|
+
node: true,
|
|
58
|
+
run: [doctor, "runDoctor"],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
"agent [--continue] [-e|--extension <path>] [-ne|--no-extensions] [--model <provider/model>] [--thinking <level>] [extension flags] [--] [prompt]",
|
|
63
|
+
0,
|
|
64
|
+
"",
|
|
65
|
+
"Run Maia's coding agent interactively.",
|
|
66
|
+
{ kind: "local", run: agent },
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
"agent --print [--no-session] [-e|--extension <path>] [-ne|--no-extensions] [--model <provider/model>] [--thinking <level>] [extension flags] [--] <prompt>",
|
|
70
|
+
0,
|
|
71
|
+
"",
|
|
72
|
+
"Print one answer from Maia's coding agent.",
|
|
73
|
+
{ kind: "local", run: agent },
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"agent --json-events [--no-session] [-e|--extension <path>] [-ne|--no-extensions] [--model <provider/model>] [--thinking <level>] [extension flags] [--] <prompt>",
|
|
77
|
+
0,
|
|
78
|
+
"",
|
|
79
|
+
"Stream one answer as JSON events.",
|
|
80
|
+
{ kind: "local", run: agent },
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
"agent extension digest <path>",
|
|
84
|
+
0,
|
|
85
|
+
"",
|
|
86
|
+
"Print an agent extension's digest.",
|
|
87
|
+
{ kind: "local", run: [local, "runAgentExtensionDigest"] },
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
"presentation catalog show",
|
|
91
|
+
1,
|
|
92
|
+
"presentation.catalog.show",
|
|
93
|
+
"Show the presentation view catalog.",
|
|
94
|
+
{ run: [presentation, "runCatalogShow"] },
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"presentation workspace-directory show --input-stdin",
|
|
98
|
+
1,
|
|
99
|
+
"presentation.workspace-directory.show",
|
|
100
|
+
"Show the Workspace directory view.",
|
|
101
|
+
{ run: [presentation, "runWorkspaceDirectoryShow"] },
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"presentation project-list show --input-stdin",
|
|
105
|
+
1,
|
|
106
|
+
"presentation.project-list.show",
|
|
107
|
+
"Show the Project list view.",
|
|
108
|
+
{ run: [presentation, "runProjectListShow"] },
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
"presentation session-list show --input-stdin",
|
|
112
|
+
1,
|
|
113
|
+
"presentation.session-list.show",
|
|
114
|
+
"Show the Session list view.",
|
|
115
|
+
{ run: [presentation, "runSessionListShow"] },
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"mcp [--worker]",
|
|
119
|
+
1,
|
|
120
|
+
"",
|
|
121
|
+
"Serve coordinator or worker tools over MCP stdio.",
|
|
122
|
+
{ kind: "local", node: true, run: [mcp, "runMcpCommand"] },
|
|
123
|
+
],
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const KINDS = "connection|container|project|session|workspace";
|
|
2
|
+
export const REFERENCE_PLACEHOLDER = new RegExp(`^<(?:[a-z]+-)*?(${KINDS})(?:-id)?>$`, "u");
|
|
3
|
+
export const REFERENCE_USAGE = new RegExp(`<(?:[a-z]+-)*?(?:${KINDS})(?:-id)?>`, "u");
|
|
4
|
+
//# sourceMappingURL=placeholder.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { localNodeRequestPayloadSchema, SessionAttachFrame } from "@maiaos/sdk";
|
|
2
|
+
import type { CommandContext, CommandEffect } from "../command-line/index.js";
|
|
3
|
+
export type TreeOperation = ReturnType<typeof localNodeRequestPayloadSchema.parse>["method"] | SessionAttachFrame["operationId"];
|
|
4
|
+
export type TreeLeafKind = "composite" | "discriminant" | "local" | "operation" | "shortcut" | "two-phase";
|
|
5
|
+
export type LeafRunner = (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
|
+
export type RunnerReference = readonly [
|
|
7
|
+
load: () => Promise<object>,
|
|
8
|
+
name: string
|
|
9
|
+
];
|
|
10
|
+
export type LeafExtra = {
|
|
11
|
+
readonly example?: string;
|
|
12
|
+
readonly kind?: Exclude<TreeLeafKind, "operation">;
|
|
13
|
+
readonly node?: true;
|
|
14
|
+
readonly remote?: false;
|
|
15
|
+
readonly run: RunnerReference;
|
|
16
|
+
};
|
|
17
|
+
export type LeafRow = readonly [
|
|
18
|
+
usage: string,
|
|
19
|
+
availability: 0 | 1,
|
|
20
|
+
operations: "" | readonly TreeOperation[] | TreeOperation,
|
|
21
|
+
summary: string,
|
|
22
|
+
extra: LeafExtra
|
|
23
|
+
];
|
|
24
|
+
export type GroupRow = readonly [path: string, summary: string];
|
|
25
|
+
export type TreeFragment = {
|
|
26
|
+
readonly groups: readonly GroupRow[];
|
|
27
|
+
readonly leaves: readonly LeafRow[];
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=row.d.ts.map
|