@root-signals/scorable-cli 0.2.1 → 0.4.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/README.md +19 -5
- package/dist/auth.d.ts +3 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +26 -52
- package/dist/commands/auth/index.d.ts +3 -0
- package/dist/commands/auth/index.d.ts.map +1 -0
- package/dist/commands/auth/index.js +66 -0
- package/dist/commands/evaluator/create.d.ts.map +1 -1
- package/dist/commands/evaluator/create.js +5 -3
- package/dist/commands/evaluator/delete.d.ts.map +1 -1
- package/dist/commands/evaluator/delete.js +5 -2
- package/dist/commands/evaluator/duplicate.d.ts.map +1 -1
- package/dist/commands/evaluator/duplicate.js +5 -2
- package/dist/commands/evaluator/execute-by-name.d.ts.map +1 -1
- package/dist/commands/evaluator/execute-by-name.js +14 -7
- package/dist/commands/evaluator/execute.d.ts.map +1 -1
- package/dist/commands/evaluator/execute.js +14 -7
- package/dist/commands/evaluator/generate.d.ts +3 -0
- package/dist/commands/evaluator/generate.d.ts.map +1 -0
- package/dist/commands/evaluator/generate.js +49 -0
- package/dist/commands/evaluator/get.d.ts.map +1 -1
- package/dist/commands/evaluator/get.js +5 -2
- package/dist/commands/evaluator/list.d.ts.map +1 -1
- package/dist/commands/evaluator/list.js +5 -2
- package/dist/commands/evaluator/update.d.ts.map +1 -1
- package/dist/commands/evaluator/update.js +4 -2
- package/dist/commands/execution-log/get.d.ts.map +1 -1
- package/dist/commands/execution-log/get.js +5 -2
- package/dist/commands/execution-log/list.d.ts.map +1 -1
- package/dist/commands/execution-log/list.js +5 -2
- package/dist/commands/judge/create.d.ts.map +1 -1
- package/dist/commands/judge/create.js +5 -3
- package/dist/commands/judge/delete.d.ts.map +1 -1
- package/dist/commands/judge/delete.js +5 -2
- package/dist/commands/judge/duplicate.d.ts.map +1 -1
- package/dist/commands/judge/duplicate.js +5 -2
- package/dist/commands/judge/execute-by-name.d.ts.map +1 -1
- package/dist/commands/judge/execute-by-name.js +14 -7
- package/dist/commands/judge/execute.d.ts.map +1 -1
- package/dist/commands/judge/execute.js +14 -7
- package/dist/commands/judge/generate.d.ts +3 -0
- package/dist/commands/judge/generate.d.ts.map +1 -0
- package/dist/commands/judge/generate.js +98 -0
- package/dist/commands/judge/get.d.ts.map +1 -1
- package/dist/commands/judge/get.js +5 -2
- package/dist/commands/judge/index.d.ts.map +1 -1
- package/dist/commands/judge/index.js +2 -0
- package/dist/commands/judge/list.d.ts.map +1 -1
- package/dist/commands/judge/list.js +5 -2
- package/dist/commands/judge/update.d.ts.map +1 -1
- package/dist/commands/judge/update.js +4 -2
- package/dist/commands/prompt-test/run.d.ts.map +1 -1
- package/dist/commands/prompt-test/run.js +22 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -1
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +27 -10
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CA+C1D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printSuccess, printError, printJson, handleSdkError } from "../../output.js";
|
|
3
4
|
export function registerCreateCommand(judge) {
|
|
4
5
|
judge
|
|
5
6
|
.command("create")
|
|
@@ -22,15 +23,16 @@ export function registerCreateCommand(judge) {
|
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
printJson(payload);
|
|
26
|
+
const spinner = ora("Creating...").start();
|
|
27
27
|
try {
|
|
28
28
|
const client = getSdkClient(apiKey);
|
|
29
29
|
const result = await client.judges.create(payload);
|
|
30
|
+
spinner.stop();
|
|
30
31
|
printSuccess("Judge created successfully!");
|
|
31
32
|
printJson(result);
|
|
32
33
|
}
|
|
33
34
|
catch (e) {
|
|
35
|
+
spinner.stop();
|
|
34
36
|
handleSdkError(e);
|
|
35
37
|
}
|
|
36
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAoC1D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printSuccess, handleSdkError } from "../../output.js";
|
|
3
4
|
import { CliError } from "../../types.js";
|
|
4
5
|
export function registerDeleteCommand(judge) {
|
|
5
6
|
judge
|
|
@@ -21,13 +22,15 @@ export function registerDeleteCommand(judge) {
|
|
|
21
22
|
throw new CliError(1, "Aborted");
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
const spinner = ora("Deleting...").start();
|
|
25
26
|
try {
|
|
26
27
|
const client = getSdkClient(apiKey);
|
|
27
28
|
await client.judges.delete(judgeId);
|
|
29
|
+
spinner.stop();
|
|
28
30
|
printSuccess(`Judge ${judgeId} deleted successfully.`);
|
|
29
31
|
}
|
|
30
32
|
catch (e) {
|
|
33
|
+
spinner.stop();
|
|
31
34
|
handleSdkError(e);
|
|
32
35
|
}
|
|
33
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/duplicate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/duplicate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAkB7D"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printSuccess, printJson, handleSdkError } from "../../output.js";
|
|
3
4
|
export function registerDuplicateCommand(judge) {
|
|
4
5
|
judge
|
|
5
6
|
.command("duplicate <judgeId>")
|
|
6
7
|
.description("Duplicate an existing judge")
|
|
7
8
|
.action(async (judgeId) => {
|
|
8
9
|
const apiKey = await requireApiKey();
|
|
9
|
-
|
|
10
|
+
const spinner = ora("Duplicating...").start();
|
|
10
11
|
try {
|
|
11
12
|
const client = getSdkClient(apiKey);
|
|
12
13
|
const result = await client.judges.duplicate(judgeId);
|
|
14
|
+
spinner.stop();
|
|
13
15
|
printSuccess(`Judge ${judgeId} duplicated successfully!`);
|
|
14
16
|
printJson(result);
|
|
15
17
|
}
|
|
16
18
|
catch (e) {
|
|
19
|
+
spinner.stop();
|
|
17
20
|
handleSdkError(e);
|
|
18
21
|
}
|
|
19
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-by-name.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/execute-by-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"execute-by-name.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/execute-by-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,iBAAe,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAIjD;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,EACD,SAAS,0BAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA6Df;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAkEjE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printSuccess, printError, printJson, handleSdkError } from "../../output.js";
|
|
3
4
|
import { isTurnArray, isStringArray } from "../../utils.js";
|
|
4
5
|
async function readStdinDefault() {
|
|
5
6
|
const chunks = [];
|
|
@@ -60,12 +61,18 @@ export async function executeJudgeByName(judgeName, opts, readStdin = readStdinD
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const spinner = ora("Running judge...").start();
|
|
65
|
+
try {
|
|
66
|
+
const client = getSdkClient(apiKey);
|
|
67
|
+
const result = await client.judges.executeByName(judgeName, payload);
|
|
68
|
+
spinner.stop();
|
|
69
|
+
printSuccess("Judge execution by name successful!");
|
|
70
|
+
printJson(result);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
spinner.stop();
|
|
74
|
+
throw e;
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
export function registerExecuteByNameCommand(judge) {
|
|
71
78
|
judge
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,iBAAe,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAIjD;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,EACD,SAAS,0BAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA6Df;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAyE3D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printSuccess, printError, printJson, handleSdkError } from "../../output.js";
|
|
3
4
|
import { isTurnArray, isStringArray } from "../../utils.js";
|
|
4
5
|
async function readStdinDefault() {
|
|
5
6
|
const chunks = [];
|
|
@@ -60,12 +61,18 @@ export async function executeJudge(judgeId, opts, readStdin = readStdinDefault)
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const spinner = ora("Running judge...").start();
|
|
65
|
+
try {
|
|
66
|
+
const client = getSdkClient(apiKey);
|
|
67
|
+
const result = await client.judges.execute(judgeId, payload);
|
|
68
|
+
spinner.stop();
|
|
69
|
+
printSuccess("Judge execution successful!");
|
|
70
|
+
printJson(result);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
spinner.stop();
|
|
74
|
+
throw e;
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
export function registerExecuteCommand(judge) {
|
|
71
78
|
judge
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CA4H5D"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
4
|
+
import { printSuccess, printError, printWarning, printInfo, printJson, handleSdkError, } from "../../output.js";
|
|
5
|
+
import { CliError } from "../../types.js";
|
|
6
|
+
export function registerGenerateCommand(judge) {
|
|
7
|
+
judge
|
|
8
|
+
.command("generate")
|
|
9
|
+
.description("Generate a judge from an intent description using AI")
|
|
10
|
+
.addHelpText("after", `
|
|
11
|
+
Example:
|
|
12
|
+
$ scorable judge generate \\
|
|
13
|
+
--intent "I am building a customer support chatbot for a hotel chain. \\
|
|
14
|
+
I want to evaluate that responses are helpful, accurate, and reflect our brand tone. \\
|
|
15
|
+
The chatbot must never make promises about pricing or availability, and should always \\
|
|
16
|
+
offer to connect the guest with a human agent when uncertain."`)
|
|
17
|
+
.requiredOption("--intent <text>", "Detailed description of what the judge should evaluate")
|
|
18
|
+
.option("--visibility <value>", "Visibility of the generated judge: private, public", "private")
|
|
19
|
+
.option("--name <name>", "Optional name for the generated judge")
|
|
20
|
+
.option("--stage <stage>", "Stage name for the judge")
|
|
21
|
+
.option("--reasoning-effort <value>", "Reasoning effort for generation: off, low, medium, high")
|
|
22
|
+
.option("--judge-id <id>", "ID of an existing judge to regenerate")
|
|
23
|
+
.option("--overwrite", "Overwrite existing judge with the same name", false)
|
|
24
|
+
.option("--extra-contexts <json>", 'JSON object of additional context key-value pairs, e.g. \'{"Tone Of Voice":"formal","Domain":"hotel chatbot"}\'')
|
|
25
|
+
.option("--context-aware", "Enable context-aware evaluators for RAG applications (hallucination detection, context drift, etc.)", false)
|
|
26
|
+
.action(async (opts) => {
|
|
27
|
+
const acceptedVisibilities = ["private", "public"];
|
|
28
|
+
const visibility = opts.visibility;
|
|
29
|
+
if (!acceptedVisibilities.includes(visibility)) {
|
|
30
|
+
printError(`Invalid --visibility value: "${visibility}". Accepted values: private, public.`);
|
|
31
|
+
throw new CliError(1, "invalid_visibility");
|
|
32
|
+
}
|
|
33
|
+
const apiVisibility = visibility === "private" ? "unlisted" : "public";
|
|
34
|
+
const apiKey = await requireApiKey();
|
|
35
|
+
let extra_contexts;
|
|
36
|
+
if (opts.extraContexts) {
|
|
37
|
+
try {
|
|
38
|
+
extra_contexts = JSON.parse(opts.extraContexts);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
printError("Invalid --extra-contexts JSON: must be a key-value object.");
|
|
42
|
+
throw new CliError(1, "Invalid extra-contexts JSON");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const spinner = ora("Generating judge (this may take a moment)...").start();
|
|
46
|
+
try {
|
|
47
|
+
const client = getSdkClient(apiKey);
|
|
48
|
+
const result = await client.judges.generate({
|
|
49
|
+
intent: opts.intent,
|
|
50
|
+
visibility: apiVisibility,
|
|
51
|
+
overwrite: opts.overwrite,
|
|
52
|
+
name: opts.name,
|
|
53
|
+
stage: opts.stage,
|
|
54
|
+
judge_id: opts.judgeId,
|
|
55
|
+
extra_contexts: extra_contexts ?? null,
|
|
56
|
+
enable_context_aware_evaluators: opts.contextAware || undefined,
|
|
57
|
+
...(opts.reasoningEffort && {
|
|
58
|
+
generating_model_params: {
|
|
59
|
+
reasoning_effort: opts.reasoningEffort,
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
spinner.stop();
|
|
64
|
+
if (result.error_code === "multiple_stages") {
|
|
65
|
+
printWarning("Multiple evaluation stages detected. Each judge covers one stage.");
|
|
66
|
+
printInfo("Detected stages:");
|
|
67
|
+
for (const s of result.stages ?? []) {
|
|
68
|
+
console.log(` ${chalk.cyan("·")} ${s}`);
|
|
69
|
+
}
|
|
70
|
+
printInfo('Re-run with --stage "<stage name>" to target a specific stage.');
|
|
71
|
+
throw new CliError(1, "multiple_stages");
|
|
72
|
+
}
|
|
73
|
+
if (result.error_code) {
|
|
74
|
+
printError(`Generation failed with error code: ${result.error_code}`);
|
|
75
|
+
throw new CliError(1, result.error_code ?? "generation_failed");
|
|
76
|
+
}
|
|
77
|
+
const missingContext = result.missing_context_from_system_goal;
|
|
78
|
+
if (missingContext?.length) {
|
|
79
|
+
printSuccess("Judge created — but additional context would improve it:");
|
|
80
|
+
console.log();
|
|
81
|
+
for (const field of missingContext) {
|
|
82
|
+
console.log(` ${chalk.bold(field.form_field_name)}`);
|
|
83
|
+
console.log(` ${chalk.dim(field.form_field_description)}`);
|
|
84
|
+
console.log();
|
|
85
|
+
}
|
|
86
|
+
printInfo(`Re-run with --judge-id "${result.judge_id}" and --extra-contexts to refine.`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
printSuccess("Judge generated successfully!");
|
|
90
|
+
}
|
|
91
|
+
printJson(result);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
spinner.stop();
|
|
95
|
+
handleSdkError(e);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAkBvD"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printSuccess, printJson, handleSdkError } from "../../output.js";
|
|
3
4
|
export function registerGetCommand(judge) {
|
|
4
5
|
judge
|
|
5
6
|
.command("get <judgeId>")
|
|
6
7
|
.description("Get a specific judge by its ID")
|
|
7
8
|
.action(async (judgeId) => {
|
|
8
9
|
const apiKey = await requireApiKey();
|
|
9
|
-
|
|
10
|
+
const spinner = ora("Fetching...").start();
|
|
10
11
|
try {
|
|
11
12
|
const client = getSdkClient(apiKey);
|
|
12
13
|
const result = await client.judges.get(judgeId);
|
|
14
|
+
spinner.stop();
|
|
13
15
|
printSuccess(`Judge '${result.name}' details:`);
|
|
14
16
|
printJson(result);
|
|
15
17
|
}
|
|
16
18
|
catch (e) {
|
|
19
|
+
spinner.stop();
|
|
17
20
|
handleSdkError(e);
|
|
18
21
|
}
|
|
19
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgB5D"}
|
|
@@ -7,6 +7,7 @@ import { registerDeleteCommand } from "./delete.js";
|
|
|
7
7
|
import { registerExecuteCommand } from "./execute.js";
|
|
8
8
|
import { registerExecuteByNameCommand } from "./execute-by-name.js";
|
|
9
9
|
import { registerDuplicateCommand } from "./duplicate.js";
|
|
10
|
+
import { registerGenerateCommand } from "./generate.js";
|
|
10
11
|
import { registerExecOpenaiCommand } from "./exec-openai.js";
|
|
11
12
|
import { registerExecOpenaiGenericCommand } from "./exec-openai-generic.js";
|
|
12
13
|
export function registerJudgeCommands(program) {
|
|
@@ -19,6 +20,7 @@ export function registerJudgeCommands(program) {
|
|
|
19
20
|
registerExecuteCommand(judge);
|
|
20
21
|
registerExecuteByNameCommand(judge);
|
|
21
22
|
registerDuplicateCommand(judge);
|
|
23
|
+
registerGenerateCommand(judge);
|
|
22
24
|
registerExecOpenaiCommand(judge);
|
|
23
25
|
registerExecOpenaiGenericCommand(judge);
|
|
24
26
|
program.addCommand(judge);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CA4CxD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
|
-
import {
|
|
3
|
+
import { printMessage, printJudgeTable, handleSdkError } from "../../output.js";
|
|
3
4
|
export function registerListCommand(judge) {
|
|
4
5
|
judge
|
|
5
6
|
.command("list")
|
|
@@ -22,10 +23,11 @@ export function registerListCommand(judge) {
|
|
|
22
23
|
params.name = opts.name;
|
|
23
24
|
if (opts.ordering !== undefined)
|
|
24
25
|
params.ordering = opts.ordering;
|
|
25
|
-
|
|
26
|
+
const spinner = ora("Fetching...").start();
|
|
26
27
|
try {
|
|
27
28
|
const client = getSdkClient(apiKey);
|
|
28
29
|
const response = await client.judges.list(params);
|
|
30
|
+
spinner.stop();
|
|
29
31
|
if (!response.results.length) {
|
|
30
32
|
printMessage("No judges found.");
|
|
31
33
|
return;
|
|
@@ -33,6 +35,7 @@ export function registerListCommand(judge) {
|
|
|
33
35
|
printJudgeTable(response.results, response.next);
|
|
34
36
|
}
|
|
35
37
|
catch (e) {
|
|
38
|
+
spinner.stop();
|
|
36
39
|
handleSdkError(e);
|
|
37
40
|
}
|
|
38
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/judge/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAkD1D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import { requireApiKey, getSdkClient } from "../../auth.js";
|
|
2
3
|
import { printInfo, printSuccess, printError, printJson, handleSdkError } from "../../output.js";
|
|
3
4
|
export function registerUpdateCommand(judge) {
|
|
@@ -27,15 +28,16 @@ export function registerUpdateCommand(judge) {
|
|
|
27
28
|
printInfo("No update parameters provided. Aborting.");
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
printJson(payload);
|
|
31
|
+
const spinner = ora("Updating...").start();
|
|
32
32
|
try {
|
|
33
33
|
const client = getSdkClient(apiKey);
|
|
34
34
|
const result = await client.judges.update(judgeId, payload);
|
|
35
|
+
spinner.stop();
|
|
35
36
|
printSuccess(`Judge ${judgeId} updated successfully!`);
|
|
36
37
|
printJson(result);
|
|
37
38
|
}
|
|
38
39
|
catch (e) {
|
|
40
|
+
spinner.stop();
|
|
39
41
|
handleSdkError(e);
|
|
40
42
|
}
|
|
41
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/prompt-test/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/prompt-test/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6GpC,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAiD,GACnF,OAAO,CAAC,IAAI,CAAC,CAiHf;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAYpD"}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import yaml from "js-yaml";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
import Table from "cli-table3";
|
|
4
5
|
import { requireApiKey } from "../../auth.js";
|
|
5
6
|
import { apiRequest } from "../../client.js";
|
|
6
7
|
import { printInfo, printSuccess, printWarning, printError, handleSdkError } from "../../output.js";
|
|
8
|
+
const UNICODE_CHARS = {
|
|
9
|
+
top: "─",
|
|
10
|
+
"top-mid": "┬",
|
|
11
|
+
"top-left": "┌",
|
|
12
|
+
"top-right": "┐",
|
|
13
|
+
bottom: "─",
|
|
14
|
+
"bottom-mid": "┴",
|
|
15
|
+
"bottom-left": "└",
|
|
16
|
+
"bottom-right": "┘",
|
|
17
|
+
left: "│",
|
|
18
|
+
"left-mid": "├",
|
|
19
|
+
mid: "─",
|
|
20
|
+
"mid-mid": "┼",
|
|
21
|
+
right: "│",
|
|
22
|
+
"right-mid": "┤",
|
|
23
|
+
middle: "│",
|
|
24
|
+
};
|
|
7
25
|
import { CliError } from "../../types.js";
|
|
8
26
|
function isPromptTestComplete(exp) {
|
|
9
27
|
if (!exp.tasks.length)
|
|
@@ -12,8 +30,8 @@ function isPromptTestComplete(exp) {
|
|
|
12
30
|
}
|
|
13
31
|
function displayProgressTable(experiments) {
|
|
14
32
|
const table = new Table({
|
|
15
|
-
head: ["Prompt Test ID", "Status", "Tasks Completed"],
|
|
16
|
-
|
|
33
|
+
head: ["Prompt Test ID", "Status", "Tasks Completed"].map((h) => chalk.bold.cyan(h)),
|
|
34
|
+
chars: UNICODE_CHARS,
|
|
17
35
|
});
|
|
18
36
|
for (const exp of experiments) {
|
|
19
37
|
const done = exp.tasks.filter((t) => t.status === "completed" || t.status === "failed").length;
|
|
@@ -48,8 +66,8 @@ function displayAggregatedResults(experiments) {
|
|
|
48
66
|
"Latency (s)",
|
|
49
67
|
"Output",
|
|
50
68
|
...sortedEvalIds.map((id) => allEvaluators.get(id)),
|
|
51
|
-
],
|
|
52
|
-
|
|
69
|
+
].map((h) => chalk.bold.cyan(h)),
|
|
70
|
+
chars: UNICODE_CHARS,
|
|
53
71
|
wordWrap: true,
|
|
54
72
|
});
|
|
55
73
|
for (const exp of experiments) {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6CpC,wBAAgB,SAAS,IAAI,OAAO,CAmBnC"}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,62 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
4
5
|
import { Command } from "commander";
|
|
6
|
+
import chalk from "chalk";
|
|
5
7
|
import { registerJudgeCommands } from "./commands/judge/index.js";
|
|
6
8
|
import { registerPromptTestCommands } from "./commands/prompt-test/index.js";
|
|
7
9
|
import { registerEvaluatorCommands } from "./commands/evaluator/index.js";
|
|
8
10
|
import { registerExecutionLogCommands } from "./commands/execution-log/index.js";
|
|
11
|
+
import { registerAuthCommands } from "./commands/auth/index.js";
|
|
12
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
13
|
+
function buildBanner(ver) {
|
|
14
|
+
const logo = chalk.hex("#4D9FFF");
|
|
15
|
+
const name = chalk.bold.hex("#4D9FFF")("scorable");
|
|
16
|
+
const tag = chalk.dim(`v${ver}`);
|
|
17
|
+
const tagline = chalk.dim("Measurement & Control for LLM Automations");
|
|
18
|
+
const line = chalk.dim("─".repeat(52));
|
|
19
|
+
return [
|
|
20
|
+
"",
|
|
21
|
+
` ${logo("┌─┐")} ${name} ${tag}`,
|
|
22
|
+
` ${logo("╰◈╯")} ${tagline}`,
|
|
23
|
+
` ${line}`,
|
|
24
|
+
].join("\n");
|
|
25
|
+
}
|
|
26
|
+
function buildGettingStarted() {
|
|
27
|
+
const header = chalk.bold("Getting started");
|
|
28
|
+
const line = chalk.dim("─".repeat(52));
|
|
29
|
+
const num = (n) => chalk.dim(n + ".");
|
|
30
|
+
const cmd = (s) => chalk.cyan(s);
|
|
31
|
+
return [
|
|
32
|
+
"",
|
|
33
|
+
` ${header}`,
|
|
34
|
+
` ${line}`,
|
|
35
|
+
` ${num("1")} Authenticate ${chalk.dim("(pick one)")}:`,
|
|
36
|
+
` ${cmd("$ scorable auth demo-key")} ${chalk.dim("# for quick testing")}`,
|
|
37
|
+
` ${cmd("$ scorable auth set-key <api-key>")} ${chalk.dim("# permanent key")}`,
|
|
38
|
+
` ${num("2")} Explore resources:`,
|
|
39
|
+
` ${cmd("$ scorable judge list")}`,
|
|
40
|
+
` ${cmd("$ scorable evaluator list")}`,
|
|
41
|
+
"",
|
|
42
|
+
].join("\n");
|
|
43
|
+
}
|
|
9
44
|
export function createCli() {
|
|
10
45
|
const program = new Command()
|
|
11
46
|
.name("scorable")
|
|
12
47
|
.description("A CLI tool to interact with the Scorable API")
|
|
13
|
-
.
|
|
48
|
+
.version(version, "-V, --version", "Print version number")
|
|
49
|
+
.addHelpText("before", buildBanner(version))
|
|
50
|
+
.addHelpText("after", buildGettingStarted())
|
|
51
|
+
.exitOverride()
|
|
52
|
+
.action(() => {
|
|
53
|
+
program.outputHelp();
|
|
54
|
+
});
|
|
14
55
|
registerJudgeCommands(program);
|
|
15
56
|
registerPromptTestCommands(program);
|
|
16
57
|
registerEvaluatorCommands(program);
|
|
17
58
|
registerExecutionLogCommands(program);
|
|
59
|
+
registerAuthCommands(program);
|
|
18
60
|
return program;
|
|
19
61
|
}
|
|
20
62
|
if (realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1])) {
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAoBzF,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAKhD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAMD,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAmB1E;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,iBAAiB,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAmB9F;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAoB1F"}
|
package/dist/output.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import Table from "cli-table3";
|
|
3
3
|
import { CliError } from "./types.js";
|
|
4
|
+
const UNICODE_CHARS = {
|
|
5
|
+
top: "─",
|
|
6
|
+
"top-mid": "┬",
|
|
7
|
+
"top-left": "┌",
|
|
8
|
+
"top-right": "┐",
|
|
9
|
+
bottom: "─",
|
|
10
|
+
"bottom-mid": "┴",
|
|
11
|
+
"bottom-left": "└",
|
|
12
|
+
"bottom-right": "┘",
|
|
13
|
+
left: "│",
|
|
14
|
+
"left-mid": "├",
|
|
15
|
+
mid: "─",
|
|
16
|
+
"mid-mid": "┼",
|
|
17
|
+
right: "│",
|
|
18
|
+
"right-mid": "┤",
|
|
19
|
+
middle: "│",
|
|
20
|
+
};
|
|
4
21
|
export function printJson(data) {
|
|
5
22
|
console.log(JSON.stringify(data, null, 2));
|
|
6
23
|
}
|
|
7
24
|
export function printError(msg) {
|
|
8
|
-
console.error(chalk.
|
|
25
|
+
console.error(chalk.red("✖") + " " + msg);
|
|
9
26
|
}
|
|
10
27
|
export function handleSdkError(e) {
|
|
11
28
|
if (e instanceof CliError)
|
|
@@ -15,13 +32,13 @@ export function handleSdkError(e) {
|
|
|
15
32
|
throw new CliError(1, message);
|
|
16
33
|
}
|
|
17
34
|
export function printSuccess(msg) {
|
|
18
|
-
console.log(chalk.
|
|
35
|
+
console.log(chalk.green("✔") + " " + msg);
|
|
19
36
|
}
|
|
20
37
|
export function printInfo(msg) {
|
|
21
|
-
console.log(chalk.
|
|
38
|
+
console.log(chalk.cyan("›") + " " + msg);
|
|
22
39
|
}
|
|
23
40
|
export function printWarning(msg) {
|
|
24
|
-
console.log(chalk.
|
|
41
|
+
console.log(chalk.yellow("⚠") + " " + msg);
|
|
25
42
|
}
|
|
26
43
|
export function printMessage(msg) {
|
|
27
44
|
console.log(msg);
|
|
@@ -31,8 +48,8 @@ function truncate(s, max) {
|
|
|
31
48
|
}
|
|
32
49
|
export function printJudgeTable(judges, nextCursor) {
|
|
33
50
|
const table = new Table({
|
|
34
|
-
head: ["ID", "Name", "Intent", "Created At"],
|
|
35
|
-
|
|
51
|
+
head: ["ID", "Name", "Intent", "Created At"].map((h) => chalk.bold.cyan(h)),
|
|
52
|
+
chars: UNICODE_CHARS,
|
|
36
53
|
colWidths: [38, 30, 52, 12],
|
|
37
54
|
wordWrap: true,
|
|
38
55
|
});
|
|
@@ -48,8 +65,8 @@ export function printJudgeTable(judges, nextCursor) {
|
|
|
48
65
|
}
|
|
49
66
|
export function printEvaluatorTable(evaluators, nextCursor) {
|
|
50
67
|
const table = new Table({
|
|
51
|
-
head: ["ID", "Name", "Created At"],
|
|
52
|
-
|
|
68
|
+
head: ["ID", "Name", "Created At"].map((h) => chalk.bold.cyan(h)),
|
|
69
|
+
chars: UNICODE_CHARS,
|
|
53
70
|
colWidths: [38, 30, 12],
|
|
54
71
|
wordWrap: true,
|
|
55
72
|
});
|
|
@@ -65,8 +82,8 @@ export function printEvaluatorTable(evaluators, nextCursor) {
|
|
|
65
82
|
}
|
|
66
83
|
export function printExecutionLogTable(logs, nextCursor) {
|
|
67
84
|
const table = new Table({
|
|
68
|
-
head: ["ID", "Item Name", "Type", "Score", "Created At"],
|
|
69
|
-
|
|
85
|
+
head: ["ID", "Item Name", "Type", "Score", "Created At"].map((h) => chalk.bold.cyan(h)),
|
|
86
|
+
chars: UNICODE_CHARS,
|
|
70
87
|
colWidths: [38, 30, 15, 8, 12],
|
|
71
88
|
wordWrap: true,
|
|
72
89
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@root-signals/scorable-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI for Scorable",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Scorable",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@inquirer/prompts": "^8.3.2",
|
|
34
|
-
"@root-signals/scorable": "^0.3.
|
|
34
|
+
"@root-signals/scorable": "^0.3.1",
|
|
35
35
|
"chalk": "^5.6.2",
|
|
36
36
|
"cli-table3": "^0.6.5",
|
|
37
37
|
"commander": "^14.0.3",
|