@aigne/cli 1.74.0-beta.1 → 1.74.0-beta.3
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 +153 -14
- package/dist/commands/aigne.cjs +3 -4
- package/dist/commands/aigne.mjs +3 -4
- package/dist/commands/aigne.mjs.map +1 -1
- package/dist/commands/app/agent.cjs +2 -27
- package/dist/commands/app/agent.mjs +2 -26
- package/dist/commands/app/agent.mjs.map +1 -1
- package/dist/commands/create.cjs +1 -1
- package/dist/commands/create.mjs +1 -1
- package/dist/commands/eval.cjs +42 -3
- package/dist/commands/eval.mjs +43 -4
- package/dist/commands/eval.mjs.map +1 -1
- package/dist/commands/explain.cjs +340 -0
- package/dist/commands/explain.mjs +340 -0
- package/dist/commands/explain.mjs.map +1 -0
- package/dist/commands/hub.cjs +111 -14
- package/dist/commands/hub.mjs +111 -14
- package/dist/commands/hub.mjs.map +1 -1
- package/dist/commands/observe.cjs +44 -1
- package/dist/commands/observe.mjs +44 -1
- package/dist/commands/observe.mjs.map +1 -1
- package/dist/commands/run-skill.cjs +29 -13
- package/dist/commands/run-skill.mjs +29 -13
- package/dist/commands/run-skill.mjs.map +1 -1
- package/dist/commands/run.cjs +5 -4
- package/dist/commands/run.mjs +5 -4
- package/dist/commands/run.mjs.map +1 -1
- package/dist/commands/serve-mcp.cjs +49 -4
- package/dist/commands/serve-mcp.mjs +49 -3
- package/dist/commands/serve-mcp.mjs.map +1 -1
- package/dist/commands/shell.cjs +106 -0
- package/dist/commands/shell.mjs +105 -0
- package/dist/commands/shell.mjs.map +1 -0
- package/dist/shell/repl.cjs +544 -0
- package/dist/shell/repl.mjs +543 -0
- package/dist/shell/repl.mjs.map +1 -0
- package/dist/shell/tools/ask-user.cjs +191 -0
- package/dist/shell/tools/ask-user.mjs +187 -0
- package/dist/shell/tools/ask-user.mjs.map +1 -0
- package/dist/shell/tools/index.cjs +2 -0
- package/dist/shell/tools/index.mjs +4 -0
- package/dist/shell/tools/render.cjs +189 -0
- package/dist/shell/tools/render.mjs +186 -0
- package/dist/shell/tools/render.mjs.map +1 -0
- package/dist/tracer/terminal.cjs +120 -133
- package/dist/tracer/terminal.mjs +121 -134
- package/dist/tracer/terminal.mjs.map +1 -1
- package/dist/ui/utils/terminal-select.cjs +73 -0
- package/dist/ui/utils/terminal-select.mjs +72 -0
- package/dist/ui/utils/terminal-select.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +2 -2
- package/dist/utils/agent-v1.mjs +2 -2
- package/dist/utils/aigne-hub/credential.cjs +3 -3
- package/dist/utils/aigne-hub/credential.mjs +3 -3
- package/dist/utils/aigne-hub/model.cjs +2 -2
- package/dist/utils/aigne-hub/model.mjs +1 -1
- package/dist/utils/ascii-logo.cjs +12 -13
- package/dist/utils/ascii-logo.d.cts.map +1 -1
- package/dist/utils/ascii-logo.d.mts.map +1 -1
- package/dist/utils/ascii-logo.mjs +12 -13
- package/dist/utils/ascii-logo.mjs.map +1 -1
- package/dist/utils/evaluation/evaluator.cjs +1 -1
- package/dist/utils/evaluation/evaluator.mjs +1 -1
- package/dist/utils/evaluation/reporter.cjs +78 -1
- package/dist/utils/evaluation/reporter.mjs +76 -1
- package/dist/utils/evaluation/reporter.mjs.map +1 -1
- package/dist/utils/exit-codes.cjs +73 -0
- package/dist/utils/exit-codes.d.cts +52 -0
- package/dist/utils/exit-codes.d.cts.map +1 -0
- package/dist/utils/exit-codes.d.mts +52 -0
- package/dist/utils/exit-codes.d.mts.map +1 -0
- package/dist/utils/exit-codes.mjs +71 -0
- package/dist/utils/exit-codes.mjs.map +1 -0
- package/dist/utils/output.cjs +61 -0
- package/dist/utils/output.d.cts +43 -0
- package/dist/utils/output.d.cts.map +1 -0
- package/dist/utils/output.d.mts +43 -0
- package/dist/utils/output.d.mts.map +1 -0
- package/dist/utils/output.mjs +56 -0
- package/dist/utils/output.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +1 -1
- package/dist/utils/run-chat-loop.mjs +1 -1
- package/dist/utils/run-with-aigne.cjs +10 -3
- package/dist/utils/run-with-aigne.d.cts.map +1 -1
- package/dist/utils/run-with-aigne.d.mts.map +1 -1
- package/dist/utils/run-with-aigne.mjs +10 -3
- package/dist/utils/run-with-aigne.mjs.map +1 -1
- package/dist/utils/serve-mcp.cjs +1 -1
- package/dist/utils/serve-mcp.mjs +1 -1
- package/dist/utils/view.cjs +34 -0
- package/dist/utils/view.d.cts +47 -0
- package/dist/utils/view.d.cts.map +1 -0
- package/dist/utils/view.d.mts +47 -0
- package/dist/utils/view.d.mts.map +1 -0
- package/dist/utils/view.mjs +33 -0
- package/dist/utils/view.mjs.map +1 -0
- package/dist/utils/yargs.cjs +27 -5
- package/dist/utils/yargs.d.cts +13 -0
- package/dist/utils/yargs.d.cts.map +1 -1
- package/dist/utils/yargs.d.mts +14 -1
- package/dist/utils/yargs.d.mts.map +1 -1
- package/dist/utils/yargs.mjs +32 -10
- package/dist/utils/yargs.mjs.map +1 -1
- package/package.json +25 -21
- package/dist/commands/app/app.cjs +0 -92
- package/dist/commands/app/app.mjs +0 -90
- package/dist/commands/app/app.mjs.map +0 -1
- package/dist/commands/app/cli.cjs +0 -6
- package/dist/commands/app/cli.d.cts +0 -1
- package/dist/commands/app/cli.d.mts +0 -1
- package/dist/commands/app/cli.mjs +0 -8
- package/dist/commands/app/cli.mjs.map +0 -1
- package/dist/commands/app/upgrade.cjs +0 -243
- package/dist/commands/app/upgrade.mjs +0 -240
- package/dist/commands/app/upgrade.mjs.map +0 -1
- package/dist/commands/app.cjs +0 -53
- package/dist/commands/app.mjs +0 -53
- package/dist/commands/app.mjs.map +0 -1
- package/dist/commands/deploy.cjs +0 -237
- package/dist/commands/deploy.mjs +0 -237
- package/dist/commands/deploy.mjs.map +0 -1
- package/dist/utils/listr.cjs +0 -226
- package/dist/utils/listr.d.cts +0 -71
- package/dist/utils/listr.d.cts.map +0 -1
- package/dist/utils/listr.d.mts +0 -71
- package/dist/utils/listr.d.mts.map +0 -1
- package/dist/utils/listr.mjs +0 -222
- package/dist/utils/listr.mjs.map +0 -1
|
@@ -4,16 +4,16 @@ const require_crypto = require('./crypto.cjs');
|
|
|
4
4
|
const require_index = require('./store/index.cjs');
|
|
5
5
|
let node_fs = require("node:fs");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
|
-
let _aigne_core_utils_fetch = require("@aigne/core/utils/fetch");
|
|
8
|
-
let ufo = require("ufo");
|
|
9
|
-
let _aigne_aigne_hub = require("@aigne/aigne-hub");
|
|
10
7
|
let inquirer = require("inquirer");
|
|
11
8
|
inquirer = require_rolldown_runtime.__toESM(inquirer);
|
|
9
|
+
let _aigne_aigne_hub = require("@aigne/aigne-hub");
|
|
12
10
|
let node_os = require("node:os");
|
|
11
|
+
let _aigne_core_utils_fetch = require("@aigne/core/utils/fetch");
|
|
13
12
|
let open = require("open");
|
|
14
13
|
open = require_rolldown_runtime.__toESM(open);
|
|
15
14
|
let p_wait_for = require("p-wait-for");
|
|
16
15
|
p_wait_for = require_rolldown_runtime.__toESM(p_wait_for);
|
|
16
|
+
let ufo = require("ufo");
|
|
17
17
|
|
|
18
18
|
//#region src/utils/aigne-hub/credential.ts
|
|
19
19
|
const request = async (config) => {
|
|
@@ -3,13 +3,13 @@ import { decrypt, encodeEncryptionKey } from "./crypto.mjs";
|
|
|
3
3
|
import store_default from "./store/index.mjs";
|
|
4
4
|
import { existsSync, mkdirSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { fetch } from "@aigne/core/utils/fetch";
|
|
7
|
-
import { joinURL, withQuery } from "ufo";
|
|
8
|
-
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_URL, getAIGNEHubMountPoint } from "@aigne/aigne-hub";
|
|
9
6
|
import inquirer from "inquirer";
|
|
7
|
+
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_URL, getAIGNEHubMountPoint } from "@aigne/aigne-hub";
|
|
10
8
|
import { homedir } from "node:os";
|
|
9
|
+
import { fetch } from "@aigne/core/utils/fetch";
|
|
11
10
|
import open from "open";
|
|
12
11
|
import pWaitFor from "p-wait-for";
|
|
12
|
+
import { joinURL, withQuery } from "ufo";
|
|
13
13
|
|
|
14
14
|
//#region src/utils/aigne-hub/credential.ts
|
|
15
15
|
const request = async (config) => {
|
|
@@ -4,10 +4,10 @@ const require_index = require('./store/index.cjs');
|
|
|
4
4
|
const require_credential = require('./credential.cjs');
|
|
5
5
|
let chalk = require("chalk");
|
|
6
6
|
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
7
|
-
let _aigne_core_utils_type_utils = require("@aigne/core/utils/type-utils");
|
|
8
|
-
let _aigne_aigne_hub = require("@aigne/aigne-hub");
|
|
9
7
|
let inquirer = require("inquirer");
|
|
10
8
|
inquirer = require_rolldown_runtime.__toESM(inquirer);
|
|
9
|
+
let _aigne_core_utils_type_utils = require("@aigne/core/utils/type-utils");
|
|
10
|
+
let _aigne_aigne_hub = require("@aigne/aigne-hub");
|
|
11
11
|
|
|
12
12
|
//#region src/utils/aigne-hub/model.ts
|
|
13
13
|
function maskApiKey(apiKey) {
|
|
@@ -2,9 +2,9 @@ import { AIGNE_HUB_PROVIDER } from "./constants.mjs";
|
|
|
2
2
|
import store_default from "./store/index.mjs";
|
|
3
3
|
import { loadAIGNEHubCredential } from "./credential.mjs";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
+
import inquirer from "inquirer";
|
|
5
6
|
import { flat, omit } from "@aigne/core/utils/type-utils";
|
|
6
7
|
import { AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_URL, findImageModel, findModel, getSupportedProviders, parseModel, resolveProviderModelId } from "@aigne/aigne-hub";
|
|
7
|
-
import inquirer from "inquirer";
|
|
8
8
|
|
|
9
9
|
//#region src/utils/aigne-hub/model.ts
|
|
10
10
|
function maskApiKey(apiKey) {
|
|
@@ -6,25 +6,24 @@ let gradient_string = require("gradient-string");
|
|
|
6
6
|
gradient_string = require_rolldown_runtime.__toESM(gradient_string);
|
|
7
7
|
|
|
8
8
|
//#region src/utils/ascii-logo.ts
|
|
9
|
-
const
|
|
10
|
-
"#
|
|
11
|
-
"#
|
|
12
|
-
"#
|
|
9
|
+
const tiffanyGradient = (0, gradient_string.default)([
|
|
10
|
+
"#0ABAB5",
|
|
11
|
+
"#00CED1",
|
|
12
|
+
"#40E0D0"
|
|
13
13
|
]);
|
|
14
14
|
const logo = `
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/ _ \\ | | | _| \\| | _|
|
|
18
|
-
/ ___ \\ | | |_| | |\\ | |___
|
|
19
|
-
/_/ \\_\\___\\____|_| \\_|_____|
|
|
15
|
+
▄▀█ █ █▀▀ █▄░█ █▀▀
|
|
16
|
+
█▀█ █ █▄█ █░▀█ ██▄
|
|
20
17
|
`;
|
|
18
|
+
const pronunciation = "[ˈei dʒən]";
|
|
21
19
|
const frameworkInfo = `v${require_constants.AIGNE_CLI_VERSION}`;
|
|
22
20
|
const logoLines = logo.split("\n");
|
|
23
21
|
const maxLength = Math.max(...logoLines.filter((line) => line.trim()).map((line) => line.length));
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
22
|
+
const pronunciationPadding = Math.floor((maxLength - 10) / 2);
|
|
23
|
+
const versionPadding = Math.floor((maxLength - frameworkInfo.length) / 2);
|
|
24
|
+
const centeredPronunciation = " ".repeat(pronunciationPadding) + pronunciation;
|
|
25
|
+
const centeredVersion = " ".repeat(versionPadding) + frameworkInfo;
|
|
26
|
+
const asciiLogo = `${tiffanyGradient(logo)}\n${chalk.default.gray(centeredPronunciation)}\n${chalk.default.cyan(centeredVersion)}\n\n`;
|
|
28
27
|
|
|
29
28
|
//#endregion
|
|
30
29
|
exports.asciiLogo = asciiLogo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii-logo.d.cts","names":[],"sources":["../../src/utils/ascii-logo.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"ascii-logo.d.cts","names":[],"sources":["../../src/utils/ascii-logo.ts"],"mappings":";cAuBa,SAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii-logo.d.mts","names":[],"sources":["../../src/utils/ascii-logo.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"ascii-logo.d.mts","names":[],"sources":["../../src/utils/ascii-logo.ts"],"mappings":";cAuBa,SAAA"}
|
|
@@ -3,25 +3,24 @@ import chalk from "chalk";
|
|
|
3
3
|
import gradient from "gradient-string";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/ascii-logo.ts
|
|
6
|
-
const
|
|
7
|
-
"#
|
|
8
|
-
"#
|
|
9
|
-
"#
|
|
6
|
+
const tiffanyGradient = gradient([
|
|
7
|
+
"#0ABAB5",
|
|
8
|
+
"#00CED1",
|
|
9
|
+
"#40E0D0"
|
|
10
10
|
]);
|
|
11
11
|
const logo = `
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/ _ \\ | | | _| \\| | _|
|
|
15
|
-
/ ___ \\ | | |_| | |\\ | |___
|
|
16
|
-
/_/ \\_\\___\\____|_| \\_|_____|
|
|
12
|
+
▄▀█ █ █▀▀ █▄░█ █▀▀
|
|
13
|
+
█▀█ █ █▄█ █░▀█ ██▄
|
|
17
14
|
`;
|
|
15
|
+
const pronunciation = "[ˈei dʒən]";
|
|
18
16
|
const frameworkInfo = `v${AIGNE_CLI_VERSION}`;
|
|
19
17
|
const logoLines = logo.split("\n");
|
|
20
18
|
const maxLength = Math.max(...logoLines.filter((line) => line.trim()).map((line) => line.length));
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
19
|
+
const pronunciationPadding = Math.floor((maxLength - 10) / 2);
|
|
20
|
+
const versionPadding = Math.floor((maxLength - frameworkInfo.length) / 2);
|
|
21
|
+
const centeredPronunciation = " ".repeat(pronunciationPadding) + pronunciation;
|
|
22
|
+
const centeredVersion = " ".repeat(versionPadding) + frameworkInfo;
|
|
23
|
+
const asciiLogo = `${tiffanyGradient(logo)}\n${chalk.gray(centeredPronunciation)}\n${chalk.cyan(centeredVersion)}\n\n`;
|
|
25
24
|
|
|
26
25
|
//#endregion
|
|
27
26
|
export { asciiLogo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii-logo.mjs","names":[],"sources":["../../src/utils/ascii-logo.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport gradient from \"gradient-string\";\nimport { AIGNE_CLI_VERSION } from \"../constants.js\";\n\nconst
|
|
1
|
+
{"version":3,"file":"ascii-logo.mjs","names":[],"sources":["../../src/utils/ascii-logo.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport gradient from \"gradient-string\";\nimport { AIGNE_CLI_VERSION } from \"../constants.js\";\n\n// Tiffany Blue inspired gradient\nconst tiffanyGradient = gradient([\"#0ABAB5\", \"#00CED1\", \"#40E0D0\"]);\n\n// Block-style logo with pronunciation guide\nconst logo = `\n ▄▀█ █ █▀▀ █▄░█ █▀▀\n █▀█ █ █▄█ █░▀█ ██▄\n`;\n\nconst pronunciation = \"[ˈei dʒən]\";\nconst frameworkInfo = `v${AIGNE_CLI_VERSION}`;\n\nconst logoLines = logo.split(\"\\n\");\nconst maxLength = Math.max(...logoLines.filter((line) => line.trim()).map((line) => line.length));\nconst pronunciationPadding = Math.floor((maxLength - pronunciation.length) / 2);\nconst versionPadding = Math.floor((maxLength - frameworkInfo.length) / 2);\nconst centeredPronunciation = \" \".repeat(pronunciationPadding) + pronunciation;\nconst centeredVersion = \" \".repeat(versionPadding) + frameworkInfo;\n\nexport const asciiLogo = `${tiffanyGradient(logo)}\\n${chalk.gray(centeredPronunciation)}\\n${chalk.cyan(centeredVersion)}\\n\\n`;\n"],"mappings":";;;;;AAKA,MAAM,kBAAkB,SAAS;CAAC;CAAW;CAAW;CAAU,CAAC;AAGnE,MAAM,OAAO;;;;AAKb,MAAM,gBAAgB;AACtB,MAAM,gBAAgB,IAAI;AAE1B,MAAM,YAAY,KAAK,MAAM,KAAK;AAClC,MAAM,YAAY,KAAK,IAAI,GAAG,UAAU,QAAQ,SAAS,KAAK,MAAM,CAAC,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC;AACjG,MAAM,uBAAuB,KAAK,OAAO,YAAY,MAAwB,EAAE;AAC/E,MAAM,iBAAiB,KAAK,OAAO,YAAY,cAAc,UAAU,EAAE;AACzE,MAAM,wBAAwB,IAAI,OAAO,qBAAqB,GAAG;AACjE,MAAM,kBAAkB,IAAI,OAAO,eAAe,GAAG;AAErD,MAAa,YAAY,GAAG,gBAAgB,KAAK,CAAC,IAAI,MAAM,KAAK,sBAAsB,CAAC,IAAI,MAAM,KAAK,gBAAgB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let _aigne_core = require("@aigne/core");
|
|
3
2
|
let zod = require("zod");
|
|
3
|
+
let _aigne_core = require("@aigne/core");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/evaluation/evaluator.ts
|
|
6
6
|
const defaultAgent = _aigne_core.AIAgent.from({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_utils_output = require('../output.cjs');
|
|
2
3
|
let node_fs = require("node:fs");
|
|
3
4
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
4
5
|
let chalk = require("chalk");
|
|
@@ -219,7 +220,83 @@ var CsvReporter = class extends BaseReporter {
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
};
|
|
223
|
+
/**
|
|
224
|
+
* JSON Reporter - outputs evaluation results in structured JSON format.
|
|
225
|
+
*/
|
|
226
|
+
var JsonReporter = class extends BaseReporter {
|
|
227
|
+
name = "json";
|
|
228
|
+
async report(report) {
|
|
229
|
+
const output = {
|
|
230
|
+
summary: {
|
|
231
|
+
total: report.summary.total,
|
|
232
|
+
successRate: report.summary.successRate,
|
|
233
|
+
duration: report.summary.duration,
|
|
234
|
+
avgLatency: report.summary.avgLatency,
|
|
235
|
+
totalTokens: report.summary.totalTokens,
|
|
236
|
+
errorCount: report.summary.errorCount
|
|
237
|
+
},
|
|
238
|
+
results: report.results.map((r) => ({
|
|
239
|
+
id: r.id,
|
|
240
|
+
input: r.input,
|
|
241
|
+
output: r.output,
|
|
242
|
+
expected: r.expected,
|
|
243
|
+
evaluations: r.evaluations,
|
|
244
|
+
error: r.error,
|
|
245
|
+
latency: r.latency,
|
|
246
|
+
usage: r.usage
|
|
247
|
+
}))
|
|
248
|
+
};
|
|
249
|
+
console.log(require_utils_output.formatJSON(output));
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* LLM Reporter - outputs evaluation results in LLM-friendly DSL format.
|
|
254
|
+
*/
|
|
255
|
+
var LLMReporter = class extends BaseReporter {
|
|
256
|
+
name = "llm";
|
|
257
|
+
async report(report) {
|
|
258
|
+
console.log(require_utils_output.formatLLMDSL({
|
|
259
|
+
total: report.summary.total,
|
|
260
|
+
success_rate: report.summary.successRate,
|
|
261
|
+
duration: report.summary.duration ? `${report.summary.duration.toFixed(3)}s` : "-",
|
|
262
|
+
avg_latency: report.summary.avgLatency ? `${report.summary.avgLatency.toFixed(3)}s` : "-",
|
|
263
|
+
total_tokens: report.summary.totalTokens ?? "-",
|
|
264
|
+
error_count: report.summary.errorCount ?? 0
|
|
265
|
+
}, [
|
|
266
|
+
"total",
|
|
267
|
+
"success_rate",
|
|
268
|
+
"duration",
|
|
269
|
+
"avg_latency",
|
|
270
|
+
"total_tokens",
|
|
271
|
+
"error_count"
|
|
272
|
+
]));
|
|
273
|
+
for (const r of report.results) {
|
|
274
|
+
console.log("---");
|
|
275
|
+
console.log(require_utils_output.formatLLMDSL({
|
|
276
|
+
id: r.id,
|
|
277
|
+
input: JSON.stringify(r.input),
|
|
278
|
+
output: r.output ? JSON.stringify(r.output) : "-",
|
|
279
|
+
expected: r.expected ? JSON.stringify(r.expected) : "-",
|
|
280
|
+
score: r.evaluations.map((e) => `${e.name}:${e.score}`).join(","),
|
|
281
|
+
rating: r.evaluations.map((e) => e.rating).join(","),
|
|
282
|
+
error: r.error ?? "-",
|
|
283
|
+
latency: r.latency ? `${r.latency.toFixed(2)}s` : "-"
|
|
284
|
+
}, [
|
|
285
|
+
"id",
|
|
286
|
+
"input",
|
|
287
|
+
"output",
|
|
288
|
+
"expected",
|
|
289
|
+
"score",
|
|
290
|
+
"rating",
|
|
291
|
+
"error",
|
|
292
|
+
"latency"
|
|
293
|
+
]));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
222
297
|
|
|
223
298
|
//#endregion
|
|
224
299
|
exports.ConsoleReporter = ConsoleReporter;
|
|
225
|
-
exports.CsvReporter = CsvReporter;
|
|
300
|
+
exports.CsvReporter = CsvReporter;
|
|
301
|
+
exports.JsonReporter = JsonReporter;
|
|
302
|
+
exports.LLMReporter = LLMReporter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatJSON, formatLLMDSL } from "../output.mjs";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import chalk from "chalk";
|
|
3
4
|
import path from "node:path";
|
|
@@ -214,7 +215,81 @@ var CsvReporter = class extends BaseReporter {
|
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
};
|
|
218
|
+
/**
|
|
219
|
+
* JSON Reporter - outputs evaluation results in structured JSON format.
|
|
220
|
+
*/
|
|
221
|
+
var JsonReporter = class extends BaseReporter {
|
|
222
|
+
name = "json";
|
|
223
|
+
async report(report) {
|
|
224
|
+
const output = {
|
|
225
|
+
summary: {
|
|
226
|
+
total: report.summary.total,
|
|
227
|
+
successRate: report.summary.successRate,
|
|
228
|
+
duration: report.summary.duration,
|
|
229
|
+
avgLatency: report.summary.avgLatency,
|
|
230
|
+
totalTokens: report.summary.totalTokens,
|
|
231
|
+
errorCount: report.summary.errorCount
|
|
232
|
+
},
|
|
233
|
+
results: report.results.map((r) => ({
|
|
234
|
+
id: r.id,
|
|
235
|
+
input: r.input,
|
|
236
|
+
output: r.output,
|
|
237
|
+
expected: r.expected,
|
|
238
|
+
evaluations: r.evaluations,
|
|
239
|
+
error: r.error,
|
|
240
|
+
latency: r.latency,
|
|
241
|
+
usage: r.usage
|
|
242
|
+
}))
|
|
243
|
+
};
|
|
244
|
+
console.log(formatJSON(output));
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* LLM Reporter - outputs evaluation results in LLM-friendly DSL format.
|
|
249
|
+
*/
|
|
250
|
+
var LLMReporter = class extends BaseReporter {
|
|
251
|
+
name = "llm";
|
|
252
|
+
async report(report) {
|
|
253
|
+
console.log(formatLLMDSL({
|
|
254
|
+
total: report.summary.total,
|
|
255
|
+
success_rate: report.summary.successRate,
|
|
256
|
+
duration: report.summary.duration ? `${report.summary.duration.toFixed(3)}s` : "-",
|
|
257
|
+
avg_latency: report.summary.avgLatency ? `${report.summary.avgLatency.toFixed(3)}s` : "-",
|
|
258
|
+
total_tokens: report.summary.totalTokens ?? "-",
|
|
259
|
+
error_count: report.summary.errorCount ?? 0
|
|
260
|
+
}, [
|
|
261
|
+
"total",
|
|
262
|
+
"success_rate",
|
|
263
|
+
"duration",
|
|
264
|
+
"avg_latency",
|
|
265
|
+
"total_tokens",
|
|
266
|
+
"error_count"
|
|
267
|
+
]));
|
|
268
|
+
for (const r of report.results) {
|
|
269
|
+
console.log("---");
|
|
270
|
+
console.log(formatLLMDSL({
|
|
271
|
+
id: r.id,
|
|
272
|
+
input: JSON.stringify(r.input),
|
|
273
|
+
output: r.output ? JSON.stringify(r.output) : "-",
|
|
274
|
+
expected: r.expected ? JSON.stringify(r.expected) : "-",
|
|
275
|
+
score: r.evaluations.map((e) => `${e.name}:${e.score}`).join(","),
|
|
276
|
+
rating: r.evaluations.map((e) => e.rating).join(","),
|
|
277
|
+
error: r.error ?? "-",
|
|
278
|
+
latency: r.latency ? `${r.latency.toFixed(2)}s` : "-"
|
|
279
|
+
}, [
|
|
280
|
+
"id",
|
|
281
|
+
"input",
|
|
282
|
+
"output",
|
|
283
|
+
"expected",
|
|
284
|
+
"score",
|
|
285
|
+
"rating",
|
|
286
|
+
"error",
|
|
287
|
+
"latency"
|
|
288
|
+
]));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
217
292
|
|
|
218
293
|
//#endregion
|
|
219
|
-
export { ConsoleReporter, CsvReporter };
|
|
294
|
+
export { ConsoleReporter, CsvReporter, JsonReporter, LLMReporter };
|
|
220
295
|
//# sourceMappingURL=reporter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.mjs","names":["resolve"],"sources":["../../../src/utils/evaluation/reporter.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { format } from \"@fast-csv/format\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport type { Report, Reporter } from \"./type.js\";\n\nconst borderColor = chalk.green;\nconst chars = {\n top: borderColor(\"─\"),\n \"top-mid\": borderColor(\"┬\"),\n \"top-left\": borderColor(\"┌\"),\n \"top-right\": borderColor(\"┐\"),\n bottom: borderColor(\"─\"),\n \"bottom-mid\": borderColor(\"┴\"),\n \"bottom-left\": borderColor(\"└\"),\n \"bottom-right\": borderColor(\"┘\"),\n left: borderColor(\"│\"),\n \"left-mid\": borderColor(\"├\"),\n mid: borderColor(\"─\"),\n \"mid-mid\": borderColor(\"┼\"),\n right: borderColor(\"│\"),\n \"right-mid\": borderColor(\"┤\"),\n middle: borderColor(\"│\"),\n};\n\nconst MAX_CELL_LENGTH = 300;\n\nfunction renderPagedTable(\n list: { header: string; width?: number; value: any }[][],\n { maxCols = 6, chars }: { maxCols?: number; chars: Record<string, string> },\n) {\n if (!list.length) return [];\n\n const tables: string[] = [];\n const head = list[0]?.map((h) => h.header) ?? [];\n const widths = list[0]?.map((h) => h.width ?? 20) ?? [];\n\n for (let i = 0; i < head.length; i += maxCols) {\n const subHead = head.slice(i, i + maxCols);\n const subWidths = widths.slice(i, i + maxCols);\n\n const table = new Table({\n head: subHead,\n colWidths: subWidths,\n wordWrap: true,\n chars,\n });\n\n for (const row of list) {\n table.push(\n row\n .slice(i, i + maxCols)\n .map((h) =>\n String(h.value).length > MAX_CELL_LENGTH\n ? `${String(h.value).slice(0, MAX_CELL_LENGTH)}...`\n : h.value,\n ),\n );\n }\n\n tables.push(table.toString());\n }\n\n return tables;\n}\n\nexport class BaseReporter implements Reporter {\n name = \"base\";\n\n async report(_report: Report): Promise<void> {\n throw new Error(\"Not implemented\");\n }\n\n protected formatReport(\n report: Report,\n ): { header: string; key: string; width: number; value: string | number }[][] {\n return report.results.map((r) => {\n return [\n { header: \"ID\", key: \"ID\", width: 10, value: r.id },\n { header: \"Input\", key: \"Input\", width: 40, value: JSON.stringify(r.input) },\n {\n header: \"Output\",\n key: \"Output\",\n width: 40,\n value: r.output ? JSON.stringify(r.output) : \"-\",\n },\n {\n header: \"Expected\",\n key: \"Expected\",\n width: 40,\n value: r.expected ? JSON.stringify(r.expected) : \"-\",\n },\n {\n header: \"Evaluations\",\n key: \"Evaluations\",\n width: 30,\n value: r.evaluations.map((e) => `${e.name}:${e.score}`).join(\", \"),\n },\n {\n header: \"Rating\",\n key: \"Rating\",\n width: 20,\n value: r.evaluations.map((e) => `${e.rating}`).join(\", \"),\n },\n { header: \"Error\", key: \"Error\", width: 20, value: r.error ?? \"-\" },\n {\n header: \"Reason\",\n key: \"Reason\",\n width: 50,\n value: r.evaluations\n .map((e) => e.reason ?? \"\")\n .filter(Boolean)\n .join(\" | \"),\n },\n {\n header: \"Latency\",\n key: \"Latency\",\n width: 15,\n value: r.latency ? `${r.latency.toFixed(2)}s` : \"-\",\n },\n {\n header: \"Tokens\",\n key: \"Tokens\",\n width: 40,\n value: r.usage\n ? `${(r.usage.inputTokens || 0) + (r.usage.outputTokens || 0)} (input:${r.usage.inputTokens || 0}, output:${r.usage.outputTokens || 0})`\n : \"-\",\n },\n ];\n });\n }\n\n protected formatSummary(\n summary: Report[\"summary\"],\n ): { header: string; key: string; width: number; value: string | number }[] {\n return [\n {\n header: \"Total\",\n key: \"Total\",\n width: 10,\n value: summary.total,\n },\n {\n header: \"Success Rate\",\n key: \"SuccessRate\",\n width: 15,\n value: summary.successRate,\n },\n {\n header: \"Total Duration\",\n key: \"Duration\",\n width: 15,\n value: summary.duration ? `${summary.duration.toFixed(3)}s` : \"-\",\n },\n {\n header: \"Avg Latency\",\n key: \"AvgLatency\",\n width: 15,\n value: summary.avgLatency ? `${summary.avgLatency.toFixed(3)}s` : \"-\",\n },\n {\n header: \"Total Tokens\",\n key: \"TotalTokens\",\n width: 15,\n value: summary.totalTokens ?? \"-\",\n },\n {\n header: \"Errors\",\n key: \"Errors\",\n width: 8,\n value: summary.errorCount ?? 0,\n },\n ];\n }\n}\n\nexport class ConsoleReporter extends BaseReporter {\n override name = \"console\";\n\n override async report(report: Report): Promise<void> {\n const summary = report.summary;\n\n console.log(\"\\n=== 📊 Evaluation Summary ===\");\n const summaryList = this.formatSummary(summary);\n const summaryTable = new Table({\n head: summaryList.map((h) => h.header),\n colWidths: summaryList.map((h) => h.width),\n chars,\n });\n\n summaryTable.push(summaryList.map((h) => h.value));\n console.log(summaryTable.toString());\n\n const list = this.formatReport(report);\n if (!list.length) return;\n\n console.log(\"\\n=== 📋 Detailed Results ===\");\n const pages = renderPagedTable(list, { maxCols: 5, chars });\n for (const page of pages) {\n console.log(page);\n }\n\n const failed = report.results.filter((r) => r.error);\n if (failed.length) {\n console.log(chalk.red(\"\\n=== ❌ Failed Cases ===\"));\n for (const f of failed) {\n console.log(\n `#${f.id} Input: ${JSON.stringify(f.input)}\\n Expected: ${\n f.expected ? JSON.stringify(f.expected) : \"-\"\n }\\n Output: ${f.output ? JSON.stringify(f.output) : \"-\"}\\n Error: ${f.error ?? \"-\"}\\n`,\n );\n }\n }\n }\n}\n\nexport class CsvReporter extends BaseReporter {\n override name = \"csv\";\n\n constructor(private filePath: string) {\n super();\n }\n\n private async writeCsv(filePath: string, data: Record<string, any>[], headers: string[]) {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n const stream = format({ headers });\n const writeStream = fs.createWriteStream(filePath);\n stream.pipe(writeStream);\n\n for (const row of data) {\n stream.write(row);\n }\n\n stream.end();\n\n await new Promise<void>((resolve, reject) => {\n writeStream.on(\"finish\", resolve);\n writeStream.on(\"error\", reject);\n });\n }\n\n override async report(report: Report): Promise<void> {\n const list = this.formatReport(report);\n if (list.length > 0) {\n const resultsHeaders = list[0]?.map((h) => h.header) ?? [];\n const resultsRows = list.map((row) => {\n const record: Record<string, string | number> = {};\n for (const item of row) {\n record[item.header] = item.value;\n }\n return record;\n });\n\n const ext = path.extname(this.filePath).toLowerCase();\n const outputFile = ext ? this.filePath : `${this.filePath}.csv`;\n\n await this.writeCsv(outputFile, resultsRows, resultsHeaders);\n\n console.log(`✅ Results CSV saved to ${outputFile}`);\n }\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAM,cAAc,MAAM;AAC1B,MAAM,QAAQ;CACZ,KAAK,YAAY,IAAI;CACrB,WAAW,YAAY,IAAI;CAC3B,YAAY,YAAY,IAAI;CAC5B,aAAa,YAAY,IAAI;CAC7B,QAAQ,YAAY,IAAI;CACxB,cAAc,YAAY,IAAI;CAC9B,eAAe,YAAY,IAAI;CAC/B,gBAAgB,YAAY,IAAI;CAChC,MAAM,YAAY,IAAI;CACtB,YAAY,YAAY,IAAI;CAC5B,KAAK,YAAY,IAAI;CACrB,WAAW,YAAY,IAAI;CAC3B,OAAO,YAAY,IAAI;CACvB,aAAa,YAAY,IAAI;CAC7B,QAAQ,YAAY,IAAI;CACzB;AAED,MAAM,kBAAkB;AAExB,SAAS,iBACP,MACA,EAAE,UAAU,GAAG,SACf;AACA,KAAI,CAAC,KAAK,OAAQ,QAAO,EAAE;CAE3B,MAAM,SAAmB,EAAE;CAC3B,MAAM,OAA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,SAAO,KAAK,YAAY;AAExB,OAAK,MAAM,OAAO,KAChB,QAAO,MAAM,IAAI;AAGnB,SAAO,KAAK;AAEZ,QAAM,IAAI,SAAe,WAAS,WAAW;AAC3C,eAAY,GAAG,UAAUA,UAAQ;AACjC,eAAY,GAAG,SAAS,OAAO;IAC/B;;CAGJ,MAAe,OAAO,QAA+B;EACnD,MAAM,OAAO,KAAK,aAAa,OAAO;AACtC,MAAI,KAAK,SAAS,GAAG;GACnB,MAAM,iBAAiB,KAAK,IAAI,KAAK,MAAM,EAAE,OAAO,IAAI,EAAE;GAC1D,MAAM,cAAc,KAAK,KAAK,QAAQ;IACpC,MAAM,SAA0C,EAAE;AAClD,SAAK,MAAM,QAAQ,IACjB,QAAO,KAAK,UAAU,KAAK;AAE7B,WAAO;KACP;GAGF,MAAM,aADM,KAAK,QAAQ,KAAK,SAAS,CAAC,aAAa,GAC5B,KAAK,WAAW,GAAG,KAAK,SAAS;AAE1D,SAAM,KAAK,SAAS,YAAY,aAAa,eAAe;AAE5D,WAAQ,IAAI,0BAA0B,aAAa"}
|
|
1
|
+
{"version":3,"file":"reporter.mjs","names":["resolve"],"sources":["../../../src/utils/evaluation/reporter.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { format } from \"@fast-csv/format\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport { formatJSON, formatLLMDSL } from \"../output.js\";\nimport type { Report, Reporter } from \"./type.js\";\n\nconst borderColor = chalk.green;\nconst chars = {\n top: borderColor(\"─\"),\n \"top-mid\": borderColor(\"┬\"),\n \"top-left\": borderColor(\"┌\"),\n \"top-right\": borderColor(\"┐\"),\n bottom: borderColor(\"─\"),\n \"bottom-mid\": borderColor(\"┴\"),\n \"bottom-left\": borderColor(\"└\"),\n \"bottom-right\": borderColor(\"┘\"),\n left: borderColor(\"│\"),\n \"left-mid\": borderColor(\"├\"),\n mid: borderColor(\"─\"),\n \"mid-mid\": borderColor(\"┼\"),\n right: borderColor(\"│\"),\n \"right-mid\": borderColor(\"┤\"),\n middle: borderColor(\"│\"),\n};\n\nconst MAX_CELL_LENGTH = 300;\n\nfunction renderPagedTable(\n list: { header: string; width?: number; value: any }[][],\n { maxCols = 6, chars }: { maxCols?: number; chars: Record<string, string> },\n) {\n if (!list.length) return [];\n\n const tables: string[] = [];\n const head = list[0]?.map((h) => h.header) ?? [];\n const widths = list[0]?.map((h) => h.width ?? 20) ?? [];\n\n for (let i = 0; i < head.length; i += maxCols) {\n const subHead = head.slice(i, i + maxCols);\n const subWidths = widths.slice(i, i + maxCols);\n\n const table = new Table({\n head: subHead,\n colWidths: subWidths,\n wordWrap: true,\n chars,\n });\n\n for (const row of list) {\n table.push(\n row\n .slice(i, i + maxCols)\n .map((h) =>\n String(h.value).length > MAX_CELL_LENGTH\n ? `${String(h.value).slice(0, MAX_CELL_LENGTH)}...`\n : h.value,\n ),\n );\n }\n\n tables.push(table.toString());\n }\n\n return tables;\n}\n\nexport class BaseReporter implements Reporter {\n name = \"base\";\n\n async report(_report: Report): Promise<void> {\n throw new Error(\"Not implemented\");\n }\n\n protected formatReport(\n report: Report,\n ): { header: string; key: string; width: number; value: string | number }[][] {\n return report.results.map((r) => {\n return [\n { header: \"ID\", key: \"ID\", width: 10, value: r.id },\n { header: \"Input\", key: \"Input\", width: 40, value: JSON.stringify(r.input) },\n {\n header: \"Output\",\n key: \"Output\",\n width: 40,\n value: r.output ? JSON.stringify(r.output) : \"-\",\n },\n {\n header: \"Expected\",\n key: \"Expected\",\n width: 40,\n value: r.expected ? JSON.stringify(r.expected) : \"-\",\n },\n {\n header: \"Evaluations\",\n key: \"Evaluations\",\n width: 30,\n value: r.evaluations.map((e) => `${e.name}:${e.score}`).join(\", \"),\n },\n {\n header: \"Rating\",\n key: \"Rating\",\n width: 20,\n value: r.evaluations.map((e) => `${e.rating}`).join(\", \"),\n },\n { header: \"Error\", key: \"Error\", width: 20, value: r.error ?? \"-\" },\n {\n header: \"Reason\",\n key: \"Reason\",\n width: 50,\n value: r.evaluations\n .map((e) => e.reason ?? \"\")\n .filter(Boolean)\n .join(\" | \"),\n },\n {\n header: \"Latency\",\n key: \"Latency\",\n width: 15,\n value: r.latency ? `${r.latency.toFixed(2)}s` : \"-\",\n },\n {\n header: \"Tokens\",\n key: \"Tokens\",\n width: 40,\n value: r.usage\n ? `${(r.usage.inputTokens || 0) + (r.usage.outputTokens || 0)} (input:${r.usage.inputTokens || 0}, output:${r.usage.outputTokens || 0})`\n : \"-\",\n },\n ];\n });\n }\n\n protected formatSummary(\n summary: Report[\"summary\"],\n ): { header: string; key: string; width: number; value: string | number }[] {\n return [\n {\n header: \"Total\",\n key: \"Total\",\n width: 10,\n value: summary.total,\n },\n {\n header: \"Success Rate\",\n key: \"SuccessRate\",\n width: 15,\n value: summary.successRate,\n },\n {\n header: \"Total Duration\",\n key: \"Duration\",\n width: 15,\n value: summary.duration ? `${summary.duration.toFixed(3)}s` : \"-\",\n },\n {\n header: \"Avg Latency\",\n key: \"AvgLatency\",\n width: 15,\n value: summary.avgLatency ? `${summary.avgLatency.toFixed(3)}s` : \"-\",\n },\n {\n header: \"Total Tokens\",\n key: \"TotalTokens\",\n width: 15,\n value: summary.totalTokens ?? \"-\",\n },\n {\n header: \"Errors\",\n key: \"Errors\",\n width: 8,\n value: summary.errorCount ?? 0,\n },\n ];\n }\n}\n\nexport class ConsoleReporter extends BaseReporter {\n override name = \"console\";\n\n override async report(report: Report): Promise<void> {\n const summary = report.summary;\n\n console.log(\"\\n=== 📊 Evaluation Summary ===\");\n const summaryList = this.formatSummary(summary);\n const summaryTable = new Table({\n head: summaryList.map((h) => h.header),\n colWidths: summaryList.map((h) => h.width),\n chars,\n });\n\n summaryTable.push(summaryList.map((h) => h.value));\n console.log(summaryTable.toString());\n\n const list = this.formatReport(report);\n if (!list.length) return;\n\n console.log(\"\\n=== 📋 Detailed Results ===\");\n const pages = renderPagedTable(list, { maxCols: 5, chars });\n for (const page of pages) {\n console.log(page);\n }\n\n const failed = report.results.filter((r) => r.error);\n if (failed.length) {\n console.log(chalk.red(\"\\n=== ❌ Failed Cases ===\"));\n for (const f of failed) {\n console.log(\n `#${f.id} Input: ${JSON.stringify(f.input)}\\n Expected: ${\n f.expected ? JSON.stringify(f.expected) : \"-\"\n }\\n Output: ${f.output ? JSON.stringify(f.output) : \"-\"}\\n Error: ${f.error ?? \"-\"}\\n`,\n );\n }\n }\n }\n}\n\nexport class CsvReporter extends BaseReporter {\n override name = \"csv\";\n\n constructor(private filePath: string) {\n super();\n }\n\n private async writeCsv(filePath: string, data: Record<string, any>[], headers: string[]) {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n const stream = format({ headers });\n const writeStream = fs.createWriteStream(filePath);\n stream.pipe(writeStream);\n\n for (const row of data) {\n stream.write(row);\n }\n\n stream.end();\n\n await new Promise<void>((resolve, reject) => {\n writeStream.on(\"finish\", resolve);\n writeStream.on(\"error\", reject);\n });\n }\n\n override async report(report: Report): Promise<void> {\n const list = this.formatReport(report);\n if (list.length > 0) {\n const resultsHeaders = list[0]?.map((h) => h.header) ?? [];\n const resultsRows = list.map((row) => {\n const record: Record<string, string | number> = {};\n for (const item of row) {\n record[item.header] = item.value;\n }\n return record;\n });\n\n const ext = path.extname(this.filePath).toLowerCase();\n const outputFile = ext ? this.filePath : `${this.filePath}.csv`;\n\n await this.writeCsv(outputFile, resultsRows, resultsHeaders);\n\n console.log(`✅ Results CSV saved to ${outputFile}`);\n }\n }\n}\n\n/**\n * JSON Reporter - outputs evaluation results in structured JSON format.\n */\nexport class JsonReporter extends BaseReporter {\n override name = \"json\";\n\n override async report(report: Report): Promise<void> {\n const output = {\n summary: {\n total: report.summary.total,\n successRate: report.summary.successRate,\n duration: report.summary.duration,\n avgLatency: report.summary.avgLatency,\n totalTokens: report.summary.totalTokens,\n errorCount: report.summary.errorCount,\n },\n results: report.results.map((r) => ({\n id: r.id,\n input: r.input,\n output: r.output,\n expected: r.expected,\n evaluations: r.evaluations,\n error: r.error,\n latency: r.latency,\n usage: r.usage,\n })),\n };\n console.log(formatJSON(output));\n }\n}\n\n/**\n * LLM Reporter - outputs evaluation results in LLM-friendly DSL format.\n */\nexport class LLMReporter extends BaseReporter {\n override name = \"llm\";\n\n override async report(report: Report): Promise<void> {\n // Summary\n console.log(\n formatLLMDSL(\n {\n total: report.summary.total,\n success_rate: report.summary.successRate,\n duration: report.summary.duration ? `${report.summary.duration.toFixed(3)}s` : \"-\",\n avg_latency: report.summary.avgLatency ? `${report.summary.avgLatency.toFixed(3)}s` : \"-\",\n total_tokens: report.summary.totalTokens ?? \"-\",\n error_count: report.summary.errorCount ?? 0,\n },\n [\"total\", \"success_rate\", \"duration\", \"avg_latency\", \"total_tokens\", \"error_count\"],\n ),\n );\n\n // Results\n for (const r of report.results) {\n console.log(\"---\");\n console.log(\n formatLLMDSL(\n {\n id: r.id,\n input: JSON.stringify(r.input),\n output: r.output ? JSON.stringify(r.output) : \"-\",\n expected: r.expected ? JSON.stringify(r.expected) : \"-\",\n score: r.evaluations.map((e) => `${e.name}:${e.score}`).join(\",\"),\n rating: r.evaluations.map((e) => e.rating).join(\",\"),\n error: r.error ?? \"-\",\n latency: r.latency ? `${r.latency.toFixed(2)}s` : \"-\",\n },\n [\"id\", \"input\", \"output\", \"expected\", \"score\", \"rating\", \"error\", \"latency\"],\n ),\n );\n }\n }\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,cAAc,MAAM;AAC1B,MAAM,QAAQ;CACZ,KAAK,YAAY,IAAI;CACrB,WAAW,YAAY,IAAI;CAC3B,YAAY,YAAY,IAAI;CAC5B,aAAa,YAAY,IAAI;CAC7B,QAAQ,YAAY,IAAI;CACxB,cAAc,YAAY,IAAI;CAC9B,eAAe,YAAY,IAAI;CAC/B,gBAAgB,YAAY,IAAI;CAChC,MAAM,YAAY,IAAI;CACtB,YAAY,YAAY,IAAI;CAC5B,KAAK,YAAY,IAAI;CACrB,WAAW,YAAY,IAAI;CAC3B,OAAO,YAAY,IAAI;CACvB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exit-codes.ts
|
|
3
|
+
/**
|
|
4
|
+
* CLI Exit Codes
|
|
5
|
+
*
|
|
6
|
+
* Standardized exit codes for AIGNE CLI commands.
|
|
7
|
+
* Following Unix conventions where 0 = success, non-zero = error.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* import { ExitCode } from "./utils/exit-codes.js";
|
|
11
|
+
* process.exit(ExitCode.NOT_FOUND);
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Standard exit codes for CLI commands.
|
|
15
|
+
*
|
|
16
|
+
* - OK (0): Operation completed successfully
|
|
17
|
+
* - NOT_FOUND (1): Requested resource does not exist
|
|
18
|
+
* - USAGE (2): Invalid command-line arguments or usage
|
|
19
|
+
* - CONFLICT (3): Operation conflicts with existing state
|
|
20
|
+
* - PARTIAL (4): Operation partially succeeded
|
|
21
|
+
* - RUNTIME (5): Runtime error during execution
|
|
22
|
+
* - VALIDATION (6): Input validation failed
|
|
23
|
+
* - NETWORK (7): Network-related error
|
|
24
|
+
*/
|
|
25
|
+
let ExitCode = /* @__PURE__ */ function(ExitCode) {
|
|
26
|
+
/** Success */
|
|
27
|
+
ExitCode[ExitCode["OK"] = 0] = "OK";
|
|
28
|
+
/** Resource not found */
|
|
29
|
+
ExitCode[ExitCode["NOT_FOUND"] = 1] = "NOT_FOUND";
|
|
30
|
+
/** Invalid arguments */
|
|
31
|
+
ExitCode[ExitCode["USAGE"] = 2] = "USAGE";
|
|
32
|
+
/** Conflict */
|
|
33
|
+
ExitCode[ExitCode["CONFLICT"] = 3] = "CONFLICT";
|
|
34
|
+
/** Partial success */
|
|
35
|
+
ExitCode[ExitCode["PARTIAL"] = 4] = "PARTIAL";
|
|
36
|
+
/** Runtime error */
|
|
37
|
+
ExitCode[ExitCode["RUNTIME"] = 5] = "RUNTIME";
|
|
38
|
+
/** Validation failed */
|
|
39
|
+
ExitCode[ExitCode["VALIDATION"] = 6] = "VALIDATION";
|
|
40
|
+
/** Network error */
|
|
41
|
+
ExitCode[ExitCode["NETWORK"] = 7] = "NETWORK";
|
|
42
|
+
return ExitCode;
|
|
43
|
+
}({});
|
|
44
|
+
/**
|
|
45
|
+
* Human-readable descriptions for exit codes.
|
|
46
|
+
*/
|
|
47
|
+
const EXIT_CODE_DESCRIPTIONS = {
|
|
48
|
+
[ExitCode.OK]: "Success",
|
|
49
|
+
[ExitCode.NOT_FOUND]: "Resource not found",
|
|
50
|
+
[ExitCode.USAGE]: "Invalid arguments",
|
|
51
|
+
[ExitCode.CONFLICT]: "Conflict",
|
|
52
|
+
[ExitCode.PARTIAL]: "Partial success",
|
|
53
|
+
[ExitCode.RUNTIME]: "Runtime error",
|
|
54
|
+
[ExitCode.VALIDATION]: "Validation failed",
|
|
55
|
+
[ExitCode.NETWORK]: "Network error"
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Get human-readable description for an exit code.
|
|
59
|
+
*/
|
|
60
|
+
function getExitCodeDescription(code) {
|
|
61
|
+
return EXIT_CODE_DESCRIPTIONS[code] ?? "Unknown error";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if an exit code indicates success.
|
|
65
|
+
*/
|
|
66
|
+
function isSuccessExitCode(code) {
|
|
67
|
+
return code === ExitCode.OK;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.ExitCode = ExitCode;
|
|
72
|
+
exports.getExitCodeDescription = getExitCodeDescription;
|
|
73
|
+
exports.isSuccessExitCode = isSuccessExitCode;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/utils/exit-codes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* CLI Exit Codes
|
|
4
|
+
*
|
|
5
|
+
* Standardized exit codes for AIGNE CLI commands.
|
|
6
|
+
* Following Unix conventions where 0 = success, non-zero = error.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { ExitCode } from "./utils/exit-codes.js";
|
|
10
|
+
* process.exit(ExitCode.NOT_FOUND);
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Standard exit codes for CLI commands.
|
|
14
|
+
*
|
|
15
|
+
* - OK (0): Operation completed successfully
|
|
16
|
+
* - NOT_FOUND (1): Requested resource does not exist
|
|
17
|
+
* - USAGE (2): Invalid command-line arguments or usage
|
|
18
|
+
* - CONFLICT (3): Operation conflicts with existing state
|
|
19
|
+
* - PARTIAL (4): Operation partially succeeded
|
|
20
|
+
* - RUNTIME (5): Runtime error during execution
|
|
21
|
+
* - VALIDATION (6): Input validation failed
|
|
22
|
+
* - NETWORK (7): Network-related error
|
|
23
|
+
*/
|
|
24
|
+
declare enum ExitCode {
|
|
25
|
+
/** Success */
|
|
26
|
+
OK = 0,
|
|
27
|
+
/** Resource not found */
|
|
28
|
+
NOT_FOUND = 1,
|
|
29
|
+
/** Invalid arguments */
|
|
30
|
+
USAGE = 2,
|
|
31
|
+
/** Conflict */
|
|
32
|
+
CONFLICT = 3,
|
|
33
|
+
/** Partial success */
|
|
34
|
+
PARTIAL = 4,
|
|
35
|
+
/** Runtime error */
|
|
36
|
+
RUNTIME = 5,
|
|
37
|
+
/** Validation failed */
|
|
38
|
+
VALIDATION = 6,
|
|
39
|
+
/** Network error */
|
|
40
|
+
NETWORK = 7,
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get human-readable description for an exit code.
|
|
44
|
+
*/
|
|
45
|
+
declare function getExitCodeDescription(code: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Check if an exit code indicates success.
|
|
48
|
+
*/
|
|
49
|
+
declare function isSuccessExitCode(code: number): boolean;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ExitCode, getExitCodeDescription, isSuccessExitCode };
|
|
52
|
+
//# sourceMappingURL=exit-codes.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.d.cts","names":[],"sources":["../../src/utils/exit-codes.ts"],"mappings":";;AAuBA;AAoCA;AAOA;;;;;;;;AA3CA;AAoCA;AAOA;;;;;;;;;aA3CY,QAAA;EAAA;EAAA,EAAA;EAAA;EAAA,SAAA;EAAA;EAAA,KAAA;EAAA;EAAA,QAAA;EAAA;EAAA,OAAA;EAAA;EAAA,OAAA;EAAA;EAAA,UAAA;EAAA;EAAA,OAAA;AAAA;AAAA;AAoCZ;AAOA;AA3CY,iBAoCI,sBAAA,CAAA,IAAA;AAAA;AAOhB;;AAPgB,iBAOA,iBAAA,CAAA,IAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/utils/exit-codes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* CLI Exit Codes
|
|
4
|
+
*
|
|
5
|
+
* Standardized exit codes for AIGNE CLI commands.
|
|
6
|
+
* Following Unix conventions where 0 = success, non-zero = error.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { ExitCode } from "./utils/exit-codes.js";
|
|
10
|
+
* process.exit(ExitCode.NOT_FOUND);
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Standard exit codes for CLI commands.
|
|
14
|
+
*
|
|
15
|
+
* - OK (0): Operation completed successfully
|
|
16
|
+
* - NOT_FOUND (1): Requested resource does not exist
|
|
17
|
+
* - USAGE (2): Invalid command-line arguments or usage
|
|
18
|
+
* - CONFLICT (3): Operation conflicts with existing state
|
|
19
|
+
* - PARTIAL (4): Operation partially succeeded
|
|
20
|
+
* - RUNTIME (5): Runtime error during execution
|
|
21
|
+
* - VALIDATION (6): Input validation failed
|
|
22
|
+
* - NETWORK (7): Network-related error
|
|
23
|
+
*/
|
|
24
|
+
declare enum ExitCode {
|
|
25
|
+
/** Success */
|
|
26
|
+
OK = 0,
|
|
27
|
+
/** Resource not found */
|
|
28
|
+
NOT_FOUND = 1,
|
|
29
|
+
/** Invalid arguments */
|
|
30
|
+
USAGE = 2,
|
|
31
|
+
/** Conflict */
|
|
32
|
+
CONFLICT = 3,
|
|
33
|
+
/** Partial success */
|
|
34
|
+
PARTIAL = 4,
|
|
35
|
+
/** Runtime error */
|
|
36
|
+
RUNTIME = 5,
|
|
37
|
+
/** Validation failed */
|
|
38
|
+
VALIDATION = 6,
|
|
39
|
+
/** Network error */
|
|
40
|
+
NETWORK = 7,
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get human-readable description for an exit code.
|
|
44
|
+
*/
|
|
45
|
+
declare function getExitCodeDescription(code: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Check if an exit code indicates success.
|
|
48
|
+
*/
|
|
49
|
+
declare function isSuccessExitCode(code: number): boolean;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ExitCode, getExitCodeDescription, isSuccessExitCode };
|
|
52
|
+
//# sourceMappingURL=exit-codes.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.d.mts","names":[],"sources":["../../src/utils/exit-codes.ts"],"mappings":";;AAuBA;AAoCA;AAOA;;;;;;;;AA3CA;AAoCA;AAOA;;;;;;;;;aA3CY,QAAA;EAAA;EAAA,EAAA;EAAA;EAAA,SAAA;EAAA;EAAA,KAAA;EAAA;EAAA,QAAA;EAAA;EAAA,OAAA;EAAA;EAAA,OAAA;EAAA;EAAA,UAAA;EAAA;EAAA,OAAA;AAAA;AAAA;AAoCZ;AAOA;AA3CY,iBAoCI,sBAAA,CAAA,IAAA;AAAA;AAOhB;;AAPgB,iBAOA,iBAAA,CAAA,IAAA"}
|