@aigne/cli 1.18.1 → 1.20.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.20.0](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.19.0...cli-v1.20.0) (2025-07-02)
4
+
5
+
6
+ ### Features
7
+
8
+ * **cli:** support executing aigne.yaml via shebang (#!/usr/bin/env aigne) ([#211](https://github.com/AIGNE-io/aigne-framework/issues/211)) ([2a82c27](https://github.com/AIGNE-io/aigne-framework/commit/2a82c2754b5eab5c3d6e45a5cbe7f0c76d927967))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/agent-library bumped to 1.17.8
16
+ * @aigne/anthropic bumped to 0.5.3
17
+ * @aigne/bedrock bumped to 0.5.3
18
+ * @aigne/core bumped to 1.29.0
19
+ * @aigne/deepseek bumped to 0.4.3
20
+ * @aigne/gemini bumped to 0.4.3
21
+ * @aigne/ollama bumped to 0.4.3
22
+ * @aigne/open-router bumped to 0.4.3
23
+ * @aigne/openai bumped to 0.6.3
24
+ * @aigne/xai bumped to 0.4.3
25
+
26
+ ## [1.19.0](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.18.1...cli-v1.19.0) (2025-07-01)
27
+
28
+
29
+ ### Features
30
+
31
+ * rename command serve to serve-mcp ([#206](https://github.com/AIGNE-io/aigne-framework/issues/206)) ([f3dfc93](https://github.com/AIGNE-io/aigne-framework/commit/f3dfc932b4eeb8ff956bf2d4b1b71b36bd05056e))
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * fix: compatible with node 20.0 & polish example defintions ([#209](https://github.com/AIGNE-io/aigne-framework/issues/209)) ([9752b96](https://github.com/AIGNE-io/aigne-framework/commit/9752b96dc54a44c6f710f056fe9205c0f2b0a73e))
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @aigne/agent-library bumped to 1.17.7
44
+ * @aigne/anthropic bumped to 0.5.2
45
+ * @aigne/bedrock bumped to 0.5.2
46
+ * @aigne/core bumped to 1.28.2
47
+ * @aigne/deepseek bumped to 0.4.2
48
+ * @aigne/gemini bumped to 0.4.2
49
+ * @aigne/observability-api bumped to 0.3.2
50
+ * @aigne/ollama bumped to 0.4.2
51
+ * @aigne/open-router bumped to 0.4.2
52
+ * @aigne/openai bumped to 0.6.2
53
+ * @aigne/xai bumped to 0.4.2
54
+
3
55
  ## [1.18.1](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.18.0...cli-v1.18.1) (2025-07-01)
4
56
 
5
57
 
package/README.md CHANGED
@@ -61,7 +61,7 @@ aigne run --path xxx
61
61
  aigne test --path xxx
62
62
 
63
63
  # Start MCP server
64
- aigne serve --path xxx --mcp
64
+ aigne serve-mcp --path xxx
65
65
 
66
66
  # Start observability server
67
67
  aigne observe [option]
@@ -121,19 +121,19 @@ aigne test
121
121
  aigne test path/to/agents
122
122
  ```
123
123
 
124
- ## Serve Command
124
+ ## Serve MCP Command
125
125
 
126
126
  Serve the agents in the specified directory as a MCP server.
127
127
 
128
128
  ```bash
129
129
  # Start MCP server on default port 3000
130
- aigne serve --mcp
130
+ aigne serve-mcp
131
131
 
132
132
  # Start MCP server on specified port
133
- aigne serve --mcp --port 3001
133
+ aigne serve-mcp --port 3001
134
134
 
135
135
  # Start MCP server for agents at specified path
136
- aigne serve --path path/to/agents --mcp
136
+ aigne serve-mcp --path path/to/agents
137
137
  ```
138
138
 
139
139
  ## Serve Command (observability)
package/README.zh.md CHANGED
@@ -61,7 +61,7 @@ aigne run --path xxx
61
61
  aigne test --path xxx
62
62
 
63
63
  # 启动 MCP 服务器
64
- aigne serve --path xxx --mcp
64
+ aigne serve-mcp --path xxx
65
65
 
66
66
  # 启动 observability 服务器
67
67
  aigne observe [option]
@@ -121,19 +121,19 @@ aigne test
121
121
  aigne test path/to/agents
122
122
  ```
123
123
 
124
- ## 服务命令 (serve)
124
+ ## 服务命令 (serve-mcp)
125
125
 
126
126
  将指定目录中的代理作为 MCP 服务器提供服务。
127
127
 
128
128
  ```bash
129
129
  # 在默认端口 3000 启动 MCP 服务器
130
- aigne serve --mcp
130
+ aigne serve-mcp
131
131
 
132
132
  # 在指定端口启动 MCP 服务器
133
- aigne serve --mcp --port 3001
133
+ aigne serve-mcp --port 3001
134
134
 
135
135
  # 为指定路径的代理启动 MCP 服务器
136
- aigne serve -- path path/to/agents --mcp
136
+ aigne serve-mcp --path path/to/agents
137
137
  ```
138
138
 
139
139
  ## 服务命令 (observability)
package/dist/cli.js CHANGED
@@ -1,10 +1,22 @@
1
1
  #!/usr/bin/env node
2
+ import { existsSync, realpathSync, statSync } from "node:fs";
2
3
  import { config } from "dotenv-flow";
3
4
  import PrettyError from "pretty-error";
4
5
  import { createAIGNECommand } from "./commands/aigne.js";
5
6
  config({ silent: true });
6
- createAIGNECommand()
7
- .parseAsync()
7
+ function getAIGNEFilePath() {
8
+ let file = process.argv[2];
9
+ if (file) {
10
+ if (!existsSync(file))
11
+ return;
12
+ file = realpathSync(file);
13
+ if (statSync(file).isFile())
14
+ return file;
15
+ }
16
+ }
17
+ const aigneFilePath = getAIGNEFilePath();
18
+ createAIGNECommand({ aigneFilePath })
19
+ .parseAsync(["", "", ...process.argv.slice(aigneFilePath ? 3 : 2)])
8
20
  .catch((error) => {
9
21
  console.error(new PrettyError().render(error));
10
22
  process.exit(1);
@@ -1,2 +1,4 @@
1
1
  import { Command } from "commander";
2
- export declare function createAIGNECommand(): Command;
2
+ export declare function createAIGNECommand(options?: {
3
+ aigneFilePath?: string;
4
+ }): Command;
@@ -4,18 +4,18 @@ import { asciiLogo } from "../utils/ascii-logo.js";
4
4
  import { createCreateCommand } from "./create.js";
5
5
  import { createObservabilityCommand } from "./observe.js";
6
6
  import { createRunCommand } from "./run.js";
7
- import { createServeCommand } from "./serve.js";
7
+ import { createServeMCPCommand } from "./serve-mcp.js";
8
8
  import { createTestCommand } from "./test.js";
9
- export function createAIGNECommand() {
9
+ export function createAIGNECommand(options) {
10
10
  console.log(asciiLogo);
11
11
  return new Command()
12
12
  .name("aigne")
13
13
  .description("CLI for AIGNE framework")
14
14
  .version(AIGNE_CLI_VERSION)
15
- .addCommand(createRunCommand())
16
- .addCommand(createTestCommand())
15
+ .addCommand(createRunCommand(options))
16
+ .addCommand(createTestCommand(options))
17
17
  .addCommand(createCreateCommand())
18
- .addCommand(createServeCommand())
18
+ .addCommand(createServeMCPCommand(options))
19
19
  .addCommand(createObservabilityCommand())
20
20
  .showHelpAfterError(true)
21
21
  .showSuggestionAfterError(true);
@@ -1,6 +1,7 @@
1
1
  import { tryOrThrow } from "@aigne/core/utils/type-utils.js";
2
2
  import { startObservabilityCLIServer } from "@aigne/observability-api/cli";
3
3
  import getObservabilityDbPath from "@aigne/observability-api/db-path";
4
+ import chalk from "chalk";
4
5
  import { Command } from "commander";
5
6
  import detectPort from "detect-port";
6
7
  const DEFAULT_PORT = () => tryOrThrow(() => {
@@ -20,7 +21,7 @@ export function createObservabilityCommand() {
20
21
  .action(async (options) => {
21
22
  const port = await detectPort(options.port || DEFAULT_PORT());
22
23
  const dbUrl = getObservabilityDbPath();
23
- console.log("Observability database path:", dbUrl);
24
+ console.log("Observability database path:", chalk.greenBright(dbUrl));
24
25
  await startObservabilityCLIServer({ port, dbUrl });
25
26
  })
26
27
  .showHelpAfterError(true)
@@ -1,2 +1,4 @@
1
1
  import type { Command } from "commander";
2
- export declare function createRunCommand(): Command;
2
+ export declare function createRunCommand({ aigneFilePath }?: {
3
+ aigneFilePath?: string;
4
+ }): Command;
@@ -12,14 +12,14 @@ import { availableMemories, availableModels } from "../constants.js";
12
12
  import { isV1Package, toAIGNEPackage } from "../utils/agent-v1.js";
13
13
  import { downloadAndExtract } from "../utils/download.js";
14
14
  import { createRunAIGNECommand, parseAgentInputByCommander, parseModelOption, runAgentWithAIGNE, } from "../utils/run-with-aigne.js";
15
- export function createRunCommand() {
15
+ export function createRunCommand({ aigneFilePath } = {}) {
16
16
  return createRunAIGNECommand()
17
17
  .description("Run AIGNE from the specified agent")
18
18
  .option("--url, --path <path_or_url>", "Path to the agents directory or URL to aigne project", ".")
19
19
  .option("--entry-agent <entry-agent>", "Name of the agent to run (defaults to the first agent found)")
20
20
  .option("--cache-dir <dir>", "Directory to download the package to (defaults to the ~/.aigne/xxx)")
21
21
  .action(async (options) => {
22
- const { path } = options;
22
+ const path = aigneFilePath || options.path;
23
23
  if (options.logLevel)
24
24
  logger.level = options.logLevel;
25
25
  const { cacheDir, dir } = prepareDirs(path, options);
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ export declare function createServeMCPCommand({ aigneFilePath }?: {
3
+ aigneFilePath?: string;
4
+ }): Command;
@@ -13,31 +13,27 @@ const DEFAULT_PORT = () => tryOrThrow(() => {
13
13
  throw new Error(`Invalid PORT: ${PORT}`);
14
14
  return port;
15
15
  }, (error) => new Error(`parse PORT error ${error.message}`));
16
- export function createServeCommand() {
17
- return new Command("serve")
18
- .description("Serve the agents in the specified directory as a MCP server")
16
+ export function createServeMCPCommand({ aigneFilePath } = {}) {
17
+ return new Command("serve-mcp")
18
+ .description("Serve the agents in the specified directory as a MCP server (streamable http)")
19
19
  .option("--url, --path <path_or_url>", "Path to the agents directory or URL to aigne project", ".")
20
- .option("--mcp", "Serve the agents as a MCP server")
21
20
  .option("--host <host>", "Host to run the MCP server on, use 0.0.0.0 to publicly expose the server", "localhost")
22
21
  .option("--port <port>", "Port to run the MCP server on", (s) => Number.parseInt(s))
23
22
  .option("--pathname <pathname>", "Pathname to the service", "/mcp")
24
23
  .action(async (options) => {
25
- const { path } = options;
24
+ const path = aigneFilePath || options.path;
26
25
  const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
27
26
  const port = options.port || DEFAULT_PORT();
28
27
  const aigne = await AIGNE.load(absolutePath, {
29
28
  models: availableModels(),
30
29
  memories: availableMemories,
31
30
  });
32
- if (options.mcp)
33
- await serveMCPServer({
34
- aigne,
35
- host: options.host,
36
- port,
37
- pathname: options.pathname,
38
- });
39
- else
40
- throw new Error("Default server is not supported yet. Please use --mcp option");
31
+ await serveMCPServer({
32
+ aigne,
33
+ host: options.host,
34
+ port,
35
+ pathname: options.pathname,
36
+ });
41
37
  console.log(`MCP server is running on http://${options.host}:${port}${options.pathname}`);
42
38
  })
43
39
  .showHelpAfterError(true)
@@ -1,2 +1,4 @@
1
1
  import { Command } from "commander";
2
- export declare function createTestCommand(): Command;
2
+ export declare function createTestCommand({ aigneFilePath }?: {
3
+ aigneFilePath?: string;
4
+ }): Command;
@@ -1,12 +1,12 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import { isAbsolute, resolve } from "node:path";
3
3
  import { Command } from "commander";
4
- export function createTestCommand() {
4
+ export function createTestCommand({ aigneFilePath } = {}) {
5
5
  return new Command("test")
6
6
  .description("Run tests in the specified agents directory")
7
7
  .option("--url, --path <path_or_url>", "Path to the agents directory or URL to aigne project", ".")
8
8
  .action(async (options) => {
9
- const { path } = options;
9
+ const path = aigneFilePath || options.path;
10
10
  const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
11
11
  spawnSync("node", ["--test"], { cwd: absolutePath, stdio: "inherit" });
12
12
  })
@@ -1,5 +1,5 @@
1
1
  import { DefaultMemory } from "@aigne/agent-library/default-memory/index.js";
2
2
  import type { LoadableModel } from "@aigne/core/loader/index.js";
3
- export declare const AIGNE_CLI_VERSION: string;
3
+ export declare const AIGNE_CLI_VERSION: any;
4
4
  export declare function availableModels(): LoadableModel[];
5
5
  export declare const availableMemories: (typeof DefaultMemory)[];
package/dist/constants.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { DefaultMemory } from "@aigne/agent-library/default-memory/index.js";
2
3
  import { AnthropicChatModel } from "@aigne/anthropic";
3
4
  import { BedrockChatModel } from "@aigne/bedrock";
@@ -9,8 +10,8 @@ import { OpenAIChatModel } from "@aigne/openai";
9
10
  import { XAIChatModel } from "@aigne/xai";
10
11
  import { NodeHttpHandler, streamCollector } from "@smithy/node-http-handler";
11
12
  import { HttpsProxyAgent } from "https-proxy-agent";
12
- import pkg from "../package.json" with { type: "json" };
13
- export const AIGNE_CLI_VERSION = pkg.version;
13
+ const require = createRequire(import.meta.url);
14
+ export const AIGNE_CLI_VERSION = require("../package.json").version;
14
15
  export function availableModels() {
15
16
  const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
16
17
  .map((i) => process.env[i])
@@ -1,6 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import gradient from "gradient-string";
3
- import pkg from "../../package.json" with { type: "json" };
3
+ import { AIGNE_CLI_VERSION } from "../constants.js";
4
4
  const modernGradient = gradient(["#4facfe", "#7367f0", "#f86aad"]);
5
5
  const logo = `
6
6
  _ ___ ____ _ _ _____
@@ -9,7 +9,7 @@ const logo = `
9
9
  / ___ \\ | | |_| | |\\ | |___
10
10
  /_/ \\_\\___\\____|_| \\_|_____|
11
11
  `;
12
- const frameworkInfo = `v${pkg.version}`;
12
+ const frameworkInfo = `v${AIGNE_CLI_VERSION}`;
13
13
  const logoLines = logo.split("\n");
14
14
  const maxLength = Math.max(...logoLines.filter((line) => line.trim()).map((line) => line.length));
15
15
  const versionText = frameworkInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/cli",
3
- "version": "1.18.1",
3
+ "version": "1.20.0",
4
4
  "description": "cli for AIGNE framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -55,17 +55,17 @@
55
55
  "wrap-ansi": "^9.0.0",
56
56
  "yaml": "^2.7.1",
57
57
  "zod": "^3.24.4",
58
- "@aigne/agent-library": "^1.17.6",
59
- "@aigne/anthropic": "^0.5.1",
60
- "@aigne/bedrock": "^0.5.1",
61
- "@aigne/core": "^1.28.1",
62
- "@aigne/gemini": "^0.4.1",
63
- "@aigne/deepseek": "^0.4.1",
64
- "@aigne/ollama": "^0.4.1",
65
- "@aigne/observability-api": "^0.3.1",
66
- "@aigne/open-router": "^0.4.1",
67
- "@aigne/openai": "^0.6.1",
68
- "@aigne/xai": "^0.4.1"
58
+ "@aigne/agent-library": "^1.17.8",
59
+ "@aigne/anthropic": "^0.5.3",
60
+ "@aigne/bedrock": "^0.5.3",
61
+ "@aigne/deepseek": "^0.4.3",
62
+ "@aigne/core": "^1.29.0",
63
+ "@aigne/gemini": "^0.4.3",
64
+ "@aigne/observability-api": "^0.3.2",
65
+ "@aigne/ollama": "^0.4.3",
66
+ "@aigne/xai": "^0.4.3",
67
+ "@aigne/openai": "^0.6.3",
68
+ "@aigne/open-router": "^0.4.3"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/archiver": "^6.0.3",
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function createServeCommand(): Command;