@maiaos/cli 0.1.0-canary.23 → 0.1.0-canary.25

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/dist/cli/cli.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import type * as Scope from "effect/Scope";
3
- import { type CliDependencies, type CliIo } from "../command-line/index.js";
3
+ import { type CliDependencies, type CliIo, type ParsedArguments } from "../command-line/index.js";
4
+ import { type TreeNode } from "../command-tree/index.js";
4
5
  import type { CliNodeConnector } from "../local-node/index.js";
5
6
  import type { SshLayer } from "../remote-node/index.js";
6
7
  export type { CliDependencies, CliErrorOutput, CliIo, CliSuccessOutput, CliSuccessResult, } from "../command-line/index.js";
@@ -12,6 +13,10 @@ export type CliRemoteNode = {
12
13
  };
13
14
  export type CliDependencyResolver = (profile: string | undefined, remote?: CliRemoteNode) => CliDependencies;
14
15
  type CliDependencySource = CliDependencies | CliDependencyResolver;
16
+ export declare const resolveCommand: (parsed: ParsedArguments) => {
17
+ readonly node: TreeNode;
18
+ readonly rest: readonly string[];
19
+ };
15
20
  export declare const makeCli: (dependencies: CliDependencySource) => (arguments_: readonly string[], version: string, io: CliIo) => Effect.Effect<number>;
16
21
  export declare const makeCliDependencies: (connector?: CliNodeConnector, ssh?: SshLayer) => CliDependencyResolver;
17
22
  export declare const runCli: (arguments_: readonly string[], version: string, io: CliIo) => Effect.Effect<number>;
package/dist/cli/cli.js CHANGED
@@ -49,7 +49,6 @@ const noInputFrom = (value) => value !== undefined && value !== "" && value !==
49
49
  const resolveOptions = (parsed, leaf, environment) => {
50
50
  const nodeBacked = isNodeBacked(leaf);
51
51
  const remote = nodeBacked && leaf.remote !== false;
52
- checkGlobalOptions(parsed, leaf, remote);
53
52
  const node = parsed.node ??
54
53
  (remote ? fromEnvironment("--node", environment.node) : undefined);
55
54
  const profile = parsed.profile ??
@@ -104,7 +103,7 @@ const reportFailures = (effect, context, tokens) => effect.pipe(Effect.catchDefe
104
103
  ? Effect.interrupt
105
104
  : Effect.sync(() => reportFailure(Cause.squash(cause), context, tokens))));
106
105
  const isHelpInvocation = (parsed) => parsed.help || parsed.tokens[0] === undefined || parsed.tokens[0] === "help";
107
- const runHelp = (input, parsed) => Effect.sync(() => {
106
+ const helpNode = (parsed) => {
108
107
  const strict = parsed.tokens[0] === "help";
109
108
  const end = parsed.tokens.indexOf("--");
110
109
  const tokens = end === -1 ? parsed.tokens : parsed.tokens.slice(0, end);
@@ -112,6 +111,10 @@ const runHelp = (input, parsed) => Effect.sync(() => {
112
111
  const { consumed, node } = findNode(path);
113
112
  if (consumed < path.length && (strict || node.forms.length === 0))
114
113
  throw new CliArgumentError(unknownPathMessage(path));
114
+ return node;
115
+ };
116
+ const runHelp = (input, parsed) => Effect.sync(() => {
117
+ const node = helpNode(parsed);
115
118
  const root = node.path.length === 0;
116
119
  writeSuccess(root
117
120
  ? createHelpTree(input.version)
@@ -125,6 +128,13 @@ const findLeaf = (typed) => {
125
128
  throw new CliArgumentError(unknownPathMessage(tokens));
126
129
  return { leaf: node, rest: tokens.slice(consumed) };
127
130
  };
131
+ export const resolveCommand = (parsed) => {
132
+ if (isHelpInvocation(parsed))
133
+ return { node: helpNode(parsed), rest: [] };
134
+ const { leaf, rest } = findLeaf(parsed.tokens);
135
+ checkGlobalOptions(parsed, leaf, isNodeBacked(leaf) && leaf.remote !== false);
136
+ return { node: leaf, rest };
137
+ };
128
138
  const leafProgram = (leaf, rest, context) => {
129
139
  const reference = leaf.run;
130
140
  if (reference === undefined)
@@ -167,7 +177,7 @@ const runParsed = (input, parsed) => {
167
177
  if (isHelpInvocation(parsed))
168
178
  return runHelp(input, parsed);
169
179
  return Effect.gen(function* () {
170
- const { leaf, rest } = findLeaf(parsed.tokens);
180
+ const { node: leaf, rest } = resolveCommand(parsed);
171
181
  const resolved = resolveOptions(parsed, leaf, yield* readEnvironment(leaf));
172
182
  if (parsed.node === undefined &&
173
183
  resolved.node !== undefined &&
@@ -1,2 +1,2 @@
1
- export { type CliDependencies, type CliDependencyResolver, type CliErrorOutput, type CliHelpResult, type CliIo, type CliStatusResult, type CliSuccessOutput, type CliSuccessResult, type CliVersionResult, makeCli, makeCliDependencies, runCli, } from "./cli.js";
1
+ export { type CliDependencies, type CliDependencyResolver, type CliErrorOutput, type CliHelpResult, type CliIo, type CliStatusResult, type CliSuccessOutput, type CliSuccessResult, type CliVersionResult, makeCli, makeCliDependencies, resolveCommand, runCli, } from "./cli.js";
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/cli/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { makeCli, makeCliDependencies, runCli, } from "./cli.js";
1
+ export { makeCli, makeCliDependencies, resolveCommand, runCli, } from "./cli.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -11,7 +11,7 @@ description: >
11
11
  ## Goal
12
12
 
13
13
  Use the installed `maia` binary as the public client. Treat `maia help --json`
14
- and `maia help <family> --json` as the command allowlist.
14
+ and `maia help session --json` (or any other family) as the command allowlist.
15
15
 
16
16
  ## Main rules
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiaos/cli",
3
- "version": "0.1.0-canary.23",
3
+ "version": "0.1.0-canary.25",
4
4
  "description": "The maia CLI and MCP server: start, drive, observe and stop swarms of Claude Code and Codex agents from a terminal, a script or another agent.",
5
5
  "keywords": [
6
6
  "maia",
@@ -64,9 +64,9 @@
64
64
  "dependencies": {
65
65
  "@earendil-works/pi-tui": "1.0.0",
66
66
  "@effect/platform-node-shared": "4.0.0",
67
- "@maiaos/agent": "0.1.0-canary.23",
68
- "@maiaos/client-core": "0.1.0-canary.23",
69
- "@maiaos/sdk": "0.1.0-canary.23",
67
+ "@maiaos/agent": "0.1.0-canary.25",
68
+ "@maiaos/client-core": "0.1.0-canary.25",
69
+ "@maiaos/sdk": "0.1.0-canary.25",
70
70
  "effect": "4.0.0"
71
71
  },
72
72
  "scripts": {