@aigne/cli 1.49.1 → 1.49.2-beta.1

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,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.49.2-beta.1](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.49.2-beta...cli-v1.49.2-beta.1) (2025-09-29)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **cli:** improve app loading reliability with force upgrade on error ([#566](https://github.com/AIGNE-io/aigne-framework/issues/566)) ([d7c49cf](https://github.com/AIGNE-io/aigne-framework/commit/d7c49cfdfdc72c0d1a98c3033babe1392cb707c1))
9
+
10
+ ## [1.49.2-beta](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.49.1...cli-v1.49.2-beta) (2025-09-29)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **checkbox:** display options list alongside error messages in search mode ([#563](https://github.com/AIGNE-io/aigne-framework/issues/563)) ([b0ebbed](https://github.com/AIGNE-io/aigne-framework/commit/b0ebbed933362fe462a6af2c812886f8e80d5194))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * The following workspace dependencies were updated
21
+ * dependencies
22
+ * @aigne/agent-library bumped to 1.21.47-beta
23
+ * @aigne/agentic-memory bumped to 1.0.47-beta
24
+ * @aigne/aigne-hub bumped to 0.10.1-beta
25
+ * @aigne/core bumped to 1.61.1-beta
26
+ * @aigne/default-memory bumped to 1.2.10-beta
27
+ * @aigne/observability-api bumped to 0.11.1-beta
28
+ * @aigne/openai bumped to 0.16.1-beta
29
+ * devDependencies
30
+ * @aigne/test-utils bumped to 0.5.54-beta
31
+
3
32
  ## [1.49.1](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.49.1-beta...cli-v1.49.1) (2025-09-27)
4
33
 
5
34
  ## [1.49.1-beta](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.49.0...cli-v1.49.1-beta) (2025-09-27)
package/dist/cli.js CHANGED
@@ -16,7 +16,8 @@ function getAIGNEFilePath() {
16
16
  }
17
17
  }
18
18
  const aigneFilePath = getAIGNEFilePath();
19
- export default createAIGNECommand({ aigneFilePath })
19
+ const argv = process.argv.slice(aigneFilePath ? 3 : 2);
20
+ export default createAIGNECommand({ argv, aigneFilePath })
20
21
  .fail((message, error, yargs) => {
21
22
  // We catch all errors below, here just print the help message non-error case like demandCommand
22
23
  if (!error) {
@@ -25,7 +26,7 @@ export default createAIGNECommand({ aigneFilePath })
25
26
  process.exit(1);
26
27
  }
27
28
  })
28
- .parseAsync(process.argv.slice(aigneFilePath ? 3 : 2))
29
+ .parseAsync(argv)
29
30
  .catch((error) => {
30
31
  console.log(""); // Add an empty line for better readability
31
32
  console.error(`${chalk.red("Error:")} ${highlightUrl(error.message)}`);
@@ -1,4 +1,5 @@
1
1
  import yargs from "yargs";
2
2
  export declare function createAIGNECommand(options?: {
3
+ argv?: string[];
3
4
  aigneFilePath?: string;
4
5
  }): yargs.Argv<{}>;
@@ -21,7 +21,7 @@ export function createAIGNECommand(options) {
21
21
  .command(createCreateCommand())
22
22
  .command(createServeMCPCommand(options))
23
23
  .command(createObservabilityCommand())
24
- .command(createAppCommands())
24
+ .command(createAppCommands(options))
25
25
  .command(createHubCommand())
26
26
  .command(createDeployCommands())
27
27
  .demandCommand()
@@ -1,7 +1,9 @@
1
1
  import type { CommandModule } from "yargs";
2
2
  import { type AgentInChildProcess, type LoadAIGNEInChildProcessResult } from "../utils/workers/run-aigne-in-child-process.js";
3
3
  import { type AgentRunCommonOptions } from "../utils/yargs.js";
4
- export declare function createAppCommands(): CommandModule[];
4
+ export declare function createAppCommands({ argv }?: {
5
+ argv?: string[];
6
+ }): CommandModule[];
5
7
  export declare const agentCommandModule: ({ dir, agent, }: {
6
8
  dir: string;
7
9
  agent: AgentInChildProcess;
@@ -7,6 +7,7 @@ import { jsonSchemaToZod } from "@aigne/json-schema-to-zod";
7
7
  import { Listr, PRESET_TIMER } from "@aigne/listr2";
8
8
  import { joinURL } from "ufo";
9
9
  import { downloadAndExtract } from "../utils/download.js";
10
+ import { withSpinner } from "../utils/spinner.js";
10
11
  import { runAIGNEInChildProcess, } from "../utils/workers/run-aigne-in-child-process.js";
11
12
  import { withAgentInputSchema } from "../utils/yargs.js";
12
13
  import { serveMCPServerFromDir } from "./serve-mcp.js";
@@ -32,36 +33,36 @@ const builtinApps = [
32
33
  aliases: ["websmith", "web"],
33
34
  },
34
35
  ];
35
- export function createAppCommands() {
36
+ export function createAppCommands({ argv } = {}) {
36
37
  return builtinApps.map((app) => ({
37
38
  command: app.name,
38
39
  describe: app.describe,
39
40
  aliases: app.aliases,
40
- builder: async (yargs) => {
41
+ builder: async (y) => {
41
42
  const dir = join(homedir(), ".aigne", "registry.npmjs.org", app.packageName);
42
- const { aigne, version } = await loadApplication({
43
- dir,
44
- packageName: app.packageName,
45
- install: true,
46
- });
47
- if (aigne.cli?.chat) {
48
- yargs.command({
49
- ...agentCommandModule({ dir, agent: aigne.cli.chat }),
50
- command: "$0",
43
+ y.command(upgradeCommandModule({ packageName: app.packageName, dir }));
44
+ if (!argv || !isUpgradeCommand(argv)) {
45
+ const { aigne, version } = await loadApplication({
46
+ dir,
47
+ packageName: app.packageName,
48
+ install: true,
51
49
  });
50
+ if (aigne.cli?.chat) {
51
+ y.command({
52
+ ...agentCommandModule({ dir, agent: aigne.cli.chat }),
53
+ command: "$0",
54
+ });
55
+ }
56
+ for (const agent of aigne.cli?.agents ?? []) {
57
+ y.command(agentCommandModule({ dir, agent }));
58
+ }
59
+ y.option("model", {
60
+ type: "string",
61
+ description: "Model to use for the application, example: openai:gpt-4.1 or google:gemini-2.5-flash",
62
+ }).command(serveMcpCommandModule({ name: app.name, dir }));
63
+ y.version(`${app.name} v${version}`).alias("version", "v");
52
64
  }
53
- for (const agent of aigne.cli?.agents ?? []) {
54
- yargs.command(agentCommandModule({ dir, agent }));
55
- }
56
- yargs
57
- .option("model", {
58
- type: "string",
59
- description: "Model to use for the application, example: openai:gpt-4.1 or google:gemini-2.5-flash",
60
- })
61
- .command(serveMcpCommandModule({ name: app.name, dir }))
62
- .command(upgradeCommandModule({ packageName: app.packageName, dir }));
63
- yargs.version(`${app.name} v${version}`).alias("version", "v");
64
- return yargs.demandCommand();
65
+ return y.demandCommand();
65
66
  },
66
67
  handler: () => { },
67
68
  }));
@@ -90,11 +91,15 @@ const serveMcpCommandModule = ({ name, dir, }) => ({
90
91
  await serveMCPServerFromDir({ ...options, dir });
91
92
  },
92
93
  });
94
+ function isUpgradeCommand(argv) {
95
+ const skipGlobalOptions = ["-v", "--version"];
96
+ return argv[1] === "upgrade" && !argv.some((arg) => skipGlobalOptions.includes(arg));
97
+ }
93
98
  const upgradeCommandModule = ({ packageName, dir, }) => ({
94
99
  command: "upgrade",
95
100
  describe: `Upgrade ${packageName} to the latest version`,
96
- builder: (argv) => {
97
- return argv
101
+ builder: (yargs) => {
102
+ return yargs
98
103
  .option("beta", {
99
104
  type: "boolean",
100
105
  describe: "Use beta versions if available",
@@ -112,11 +117,13 @@ const upgradeCommandModule = ({ packageName, dir, }) => ({
112
117
  },
113
118
  handler: async ({ beta, targetVersion, force }) => {
114
119
  beta ??= shouldUseBetaApps();
115
- let app = await loadApplication({ packageName, dir });
116
- const npm = await getNpmTgzInfo(packageName, { beta, version: targetVersion });
117
- if (!app || force || npm.version !== app.version) {
120
+ const npm = await withSpinner("", async () => {
118
121
  if (force)
119
122
  await rm(dir, { force: true, recursive: true });
123
+ return await getNpmTgzInfo(packageName, { beta, version: targetVersion });
124
+ });
125
+ let app = await loadApplication({ packageName, dir });
126
+ if (!app || force || npm.version !== app.version) {
120
127
  await installApp({ packageName, dir, beta, version: targetVersion });
121
128
  app = await loadApplication({ dir, packageName, install: true });
122
129
  console.log(`\n✅ Upgraded ${packageName} to version ${app.version}`);
@@ -149,8 +156,12 @@ export async function loadApplication(options) {
149
156
  const { dir, packageName } = options;
150
157
  const check = await checkInstallation(dir);
151
158
  if (check && !check.expired) {
152
- const aigne = await runAIGNEInChildProcess("loadAIGNE", dir).catch((error) => {
153
- console.warn(`⚠️ Failed to load ${packageName}, trying to reinstall:`, error.message);
159
+ const aigne = await runAIGNEInChildProcess("loadAIGNE", dir).catch(async (error) => {
160
+ logger.error(`⚠️ Failed to load ${packageName}, trying to reinstall:`, error.message);
161
+ await withSpinner("", async () => {
162
+ await rm(options.dir, { recursive: true, force: true });
163
+ await mkdir(options.dir, { recursive: true });
164
+ });
154
165
  });
155
166
  if (aigne) {
156
167
  return { aigne, version: check.version, isCache: true };
@@ -313,7 +313,7 @@ export default createPrompt((config, done) => {
313
313
  const searchStr = theme.style.searchTerm(searchTerm);
314
314
  return [
315
315
  [prefix, message, searchStr].filter(Boolean).join(" "),
316
- `${error || page}${helpTipBottom}${choiceDescription}`,
316
+ `${error}${error ? "\n" : ""}${page}${helpTipBottom}${choiceDescription}`,
317
317
  ];
318
318
  }
319
319
  return `${prefix} ${message}${helpTipTop}\n${page}${helpTipBottom}${choiceDescription}${error}${ansiEscapes.cursorHide}`;
@@ -0,0 +1 @@
1
+ export declare function withSpinner<T>(message: string, fn: () => Promise<T>): Promise<T>;
@@ -0,0 +1,14 @@
1
+ import { Spinner } from "@aigne/listr2";
2
+ export async function withSpinner(message, fn) {
3
+ const spinner = new Spinner();
4
+ spinner.start(() => {
5
+ process.stdout.write(`\r\x1b[K${spinner.fetch()} ${message}`);
6
+ });
7
+ try {
8
+ return await fn();
9
+ }
10
+ finally {
11
+ spinner.stop();
12
+ process.stdout.write("\r\x1b[K"); // Clear the spinner line
13
+ }
14
+ }
@@ -18,7 +18,7 @@ export async function runAIGNEInChildProcess(method, ...args) {
18
18
  if (event.method !== method)
19
19
  reject(new Error(`Unknown method: ${event.method} expected: ${method}`));
20
20
  else if (event.error)
21
- reject(new Error(`Failed to execute ${method}: ${event.error.message}`));
21
+ reject(new Error(event.error.message));
22
22
  else
23
23
  resolve(event.result);
24
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/cli",
3
- "version": "1.49.1",
3
+ "version": "1.49.2-beta.1",
4
4
  "description": "Your command center for agent development",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -84,13 +84,13 @@
84
84
  "yoctocolors-cjs": "^2.1.3",
85
85
  "zod": "^3.25.67",
86
86
  "zod-to-json-schema": "^3.24.6",
87
- "@aigne/agent-library": "^1.21.46",
88
- "@aigne/aigne-hub": "^0.10.0",
89
- "@aigne/agentic-memory": "^1.0.46",
90
- "@aigne/core": "^1.61.0",
91
- "@aigne/default-memory": "^1.2.9",
92
- "@aigne/openai": "^0.16.0",
93
- "@aigne/observability-api": "^0.11.0"
87
+ "@aigne/agent-library": "^1.21.47-beta",
88
+ "@aigne/agentic-memory": "^1.0.47-beta",
89
+ "@aigne/aigne-hub": "^0.10.1-beta",
90
+ "@aigne/core": "^1.61.1-beta",
91
+ "@aigne/default-memory": "^1.2.10-beta",
92
+ "@aigne/observability-api": "^0.11.1-beta",
93
+ "@aigne/openai": "^0.16.1-beta"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@inquirer/testing": "^2.1.50",
@@ -107,7 +107,7 @@
107
107
  "rimraf": "^6.0.1",
108
108
  "typescript": "^5.9.2",
109
109
  "ufo": "^1.6.1",
110
- "@aigne/test-utils": "^0.5.53"
110
+ "@aigne/test-utils": "^0.5.54-beta"
111
111
  },
112
112
  "scripts": {
113
113
  "lint": "tsc --noEmit",