@aigne/cli 1.22.5 → 1.22.6

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.22.6](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.22.5...cli-v1.22.6) (2025-07-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **cli:** reduce excessive console output to improve cli performance ([#246](https://github.com/AIGNE-io/aigne-framework/issues/246)) ([4430504](https://github.com/AIGNE-io/aigne-framework/commit/4430504b643bba92775e5a908ca1c1153d90a402))
9
+
3
10
  ## [1.22.5](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.22.4...cli-v1.22.5) (2025-07-10)
4
11
 
5
12
 
@@ -1,3 +1,4 @@
1
+ import { type InspectOptions } from "node:util";
1
2
  import { type Agent, type Context, type ContextUsage, type Message } from "@aigne/core";
2
3
  import { promiseWithResolvers } from "@aigne/core/utils/promise.js";
3
4
  import { type Listr } from "@aigne/listr2";
@@ -26,8 +27,13 @@ export declare class TerminalTracer {
26
27
  }): string;
27
28
  private marked;
28
29
  get outputKey(): string;
29
- formatRequest(agent: Agent, _context: Context, m?: Message): string | undefined;
30
- formatResult(agent: Agent, context: Context, m?: Message): string;
30
+ formatRequest(agent: Agent, _context: Context, m?: Message, { running }?: {
31
+ running?: boolean | undefined;
32
+ }): string | undefined;
33
+ formatResult(agent: Agent, context: Context, m?: Message, { running }?: {
34
+ running?: boolean | undefined;
35
+ }): string;
36
+ protected runningInspectOptions: InspectOptions;
31
37
  }
32
38
  type Task = ReturnType<typeof promiseWithResolvers<void>> & {
33
39
  listr: ReturnType<typeof promiseWithResolvers<{
@@ -22,8 +22,10 @@ export class TerminalTracer {
22
22
  await this.context.observer?.serve();
23
23
  const context = this.context.newContext({ reset: true });
24
24
  const listr = new AIGNEListr({
25
- formatRequest: () => this.options.printRequest ? this.formatRequest(agent, context, input) : undefined,
26
- formatResult: (result) => [this.formatResult(agent, context, result)].filter(Boolean),
25
+ formatRequest: (options) => this.options.printRequest
26
+ ? this.formatRequest(agent, context, input, options)
27
+ : undefined,
28
+ formatResult: (result, options) => [this.formatResult(agent, context, result, options)].filter(Boolean),
27
29
  }, [], { concurrent: true });
28
30
  const onAgentStarted = async ({ contextId, parentContextId, agent, timestamp, }) => {
29
31
  const task = {
@@ -135,7 +137,7 @@ export class TerminalTracer {
135
137
  get outputKey() {
136
138
  return this.options.outputKey || DEFAULT_OUTPUT_KEY;
137
139
  }
138
- formatRequest(agent, _context, m = {}) {
140
+ formatRequest(agent, _context, m = {}, { running = false } = {}) {
139
141
  if (!logger.enabled(LogLevel.INFO))
140
142
  return;
141
143
  const prefix = `${chalk.grey(figures.pointer)} 💬 `;
@@ -143,10 +145,12 @@ export class TerminalTracer {
143
145
  const msg = inputKey ? m[inputKey] : undefined;
144
146
  const message = inputKey ? omit(m, inputKey) : m;
145
147
  const text = msg && typeof msg === "string" ? this.marked.parse(msg, { async: false }).trim() : undefined;
146
- const json = Object.keys(message).length > 0 ? inspect(message, { colors: true }) : undefined;
148
+ const json = Object.keys(message).length > 0
149
+ ? inspect(message, { colors: true, ...(running ? this.runningInspectOptions : undefined) })
150
+ : undefined;
147
151
  return [prefix, [text, json].filter(Boolean).join(EOL)].join(" ");
148
152
  }
149
- formatResult(agent, context, m = {}) {
153
+ formatResult(agent, context, m = {}, { running = false } = {}) {
150
154
  const { isTTY } = process.stdout;
151
155
  const outputKey = this.outputKey || (agent instanceof AIAgent ? agent.outputKey : undefined);
152
156
  const prefix = logger.enabled(LogLevel.INFO)
@@ -159,7 +163,13 @@ export class TerminalTracer {
159
163
  ? this.marked.parse(msg, { async: false }).trim()
160
164
  : msg
161
165
  : undefined;
162
- const json = Object.keys(message).length > 0 ? inspect(message, { colors: isTTY }) : undefined;
166
+ const json = Object.keys(message).length > 0
167
+ ? inspect(message, { colors: isTTY, ...(running ? this.runningInspectOptions : undefined) })
168
+ : undefined;
163
169
  return [prefix, text, json].filter(Boolean).join(EOL);
164
170
  }
171
+ runningInspectOptions = {
172
+ maxArrayLength: 3,
173
+ maxStringLength: 200,
174
+ };
165
175
  }
@@ -6,14 +6,18 @@ export type AIGNEListrTaskWrapper = ListrTaskWrapper<unknown, typeof AIGNEListrR
6
6
  export declare class AIGNEListr extends Listr<object, typeof AIGNEListrRenderer, typeof AIGNEListrFallbackRenderer> {
7
7
  myOptions: {
8
8
  formatRequest: () => string | undefined;
9
- formatResult: (result: Message) => string[];
9
+ formatResult: (result: Message, options?: {
10
+ running?: boolean;
11
+ }) => string[];
10
12
  };
11
13
  private result;
12
14
  private logs;
13
15
  private spinner;
14
16
  constructor(myOptions: {
15
17
  formatRequest: () => string | undefined;
16
- formatResult: (result: Message) => string[];
18
+ formatResult: (result: Message, options?: {
19
+ running?: boolean;
20
+ }) => string[];
17
21
  }, ...[task, options, parentTask]: ConstructorParameters<typeof Listr<object, typeof AIGNEListrRenderer, typeof AIGNEListrFallbackRenderer>>);
18
22
  run(stream: () => PromiseOrValue<AgentResponseStream<Message>>): Promise<Message>;
19
23
  private extractStream;
@@ -21,7 +25,9 @@ export declare class AIGNEListr extends Listr<object, typeof AIGNEListrRenderer,
21
25
  export interface AIGNEListrRendererOptions extends ListrDefaultRendererOptions {
22
26
  aigne?: {
23
27
  getStdoutLogs?: () => string[];
24
- getBottomBarLogs?: () => string[];
28
+ getBottomBarLogs?: (options?: {
29
+ running?: boolean;
30
+ }) => string[];
25
31
  };
26
32
  }
27
33
  export declare class AIGNEListrRenderer extends DefaultRenderer {
@@ -14,8 +14,8 @@ export class AIGNEListr extends Listr {
14
14
  getStdoutLogs: () => {
15
15
  return this.logs.splice(0);
16
16
  },
17
- getBottomBarLogs: () => {
18
- return this.myOptions.formatResult(this.result);
17
+ getBottomBarLogs: (options) => {
18
+ return this.myOptions.formatResult(this.result, options);
19
19
  },
20
20
  };
21
21
  super(task, {
@@ -78,20 +78,16 @@ export class AIGNEListrRenderer extends DefaultRenderer {
78
78
  ...DefaultRenderer.rendererOptions,
79
79
  };
80
80
  get _updater() {
81
- // @ts-ignore `updater` is a private property
82
- return this.updater;
81
+ return this["updater"];
83
82
  }
84
83
  get _logger() {
85
- // @ts-ignore `logger` is a private property
86
- return this.logger;
84
+ return this["logger"];
87
85
  }
88
86
  get _options() {
89
- // @ts-ignore `options` is a private property
90
- return this.options;
87
+ return this["options"];
91
88
  }
92
89
  get _spinner() {
93
- // @ts-ignore `spinner` is a private property
94
- return this.spinner;
90
+ return this["spinner"];
95
91
  }
96
92
  update() {
97
93
  this._updater(this.create({ running: true }));
@@ -102,12 +98,25 @@ export class AIGNEListrRenderer extends DefaultRenderer {
102
98
  this._updater.clear();
103
99
  this._logger.toStdout(logs.join(EOL));
104
100
  }
105
- const tasks = [super.create(options)];
106
- const bottomBar = this._options.aigne?.getBottomBarLogs?.();
101
+ let tasks = super.create(options);
102
+ const bottomBar = this._options.aigne?.getBottomBarLogs?.({ running });
107
103
  if (bottomBar?.length) {
108
- tasks.push([...bottomBar, running ? this._spinner.fetch() : ""].map((i) => this._wrap(i)).join(EOL));
104
+ tasks += EOL.repeat(2);
105
+ const output = [...bottomBar, running ? this._spinner.fetch() : ""]
106
+ .map((i) => this._wrap(i))
107
+ .join(EOL);
108
+ // If the task is not running, we show all lines
109
+ if (!running) {
110
+ tasks += output;
111
+ }
112
+ // For running tasks, we only show the last few lines
113
+ else {
114
+ const { rows } = process.stdout;
115
+ const lines = rows - tasks.split(EOL).length - 2;
116
+ tasks += output.split(EOL).slice(-Math.max(4, lines)).join(EOL);
117
+ }
109
118
  }
110
- return tasks.join(EOL.repeat(2));
119
+ return tasks;
111
120
  }
112
121
  _wrap(str) {
113
122
  return wrap(str, process.stdout.columns ?? 80, {
@@ -121,12 +130,10 @@ export class AIGNEListrFallbackRenderer extends SimpleRenderer {
121
130
  ...SimpleRenderer.rendererOptions,
122
131
  };
123
132
  get _logger() {
124
- // @ts-ignore `logger` is a private property
125
- return this.logger;
133
+ return this["logger"];
126
134
  }
127
135
  get _options() {
128
- // @ts-ignore `options` is a private property
129
- return this.options;
136
+ return this["options"];
130
137
  }
131
138
  end() {
132
139
  const logs = [this._options.aigne?.getStdoutLogs?.(), this._options.aigne?.getBottomBarLogs?.()]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/cli",
3
- "version": "1.22.5",
3
+ "version": "1.22.6",
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.8.0",
57
57
  "zod": "^3.25.67",
58
- "@aigne/agent-library": "^1.20.3",
59
58
  "@aigne/anthropic": "^0.8.0",
60
- "@aigne/bedrock": "^0.7.3",
61
59
  "@aigne/core": "^1.33.0",
62
60
  "@aigne/gemini": "^0.7.0",
61
+ "@aigne/bedrock": "^0.7.3",
62
+ "@aigne/observability-api": "^0.7.1",
63
63
  "@aigne/deepseek": "^0.6.3",
64
64
  "@aigne/ollama": "^0.6.3",
65
65
  "@aigne/open-router": "^0.6.3",
66
- "@aigne/observability-api": "^0.7.1",
67
66
  "@aigne/openai": "^0.9.0",
68
- "@aigne/xai": "^0.6.4"
67
+ "@aigne/xai": "^0.6.4",
68
+ "@aigne/agent-library": "^1.20.3"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/archiver": "^6.0.3",