@plune-ai/cli 0.39.9 → 0.39.11
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 +2 -2
- package/dist/cli.cjs +574 -103
- package/dist/index.cjs +51 -10
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +51 -10
- package/dist/mcp-http.cjs +22 -2
- package/dist/mcp-http.js +22 -2
- package/dist/reporter-core.cjs +24 -5
- package/dist/reporter-core.d.cts +38 -1
- package/dist/reporter-core.d.ts +38 -1
- package/dist/reporter-core.js +23 -5
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1078,7 +1078,7 @@ var init_retry = __esm({
|
|
|
1078
1078
|
"use strict";
|
|
1079
1079
|
init_cjs_shims();
|
|
1080
1080
|
init_errors2();
|
|
1081
|
-
defaultSleep = (ms) => new Promise((
|
|
1081
|
+
defaultSleep = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
1082
1082
|
}
|
|
1083
1083
|
});
|
|
1084
1084
|
|
|
@@ -4276,7 +4276,7 @@ function failureOf(attempt, home = (0, import_node_os.homedir)()) {
|
|
|
4276
4276
|
const headline2 = line !== void 0 && jsonBytes(line) <= HEADLINE_LIMIT ? line : void 0;
|
|
4277
4277
|
const steps = chainOf(attempt.steps);
|
|
4278
4278
|
const location = error === void 0 ? void 0 : fromRoot(placeOf(error, attempt.testFile), attempt.repoRoot);
|
|
4279
|
-
const artifacts = attempt.attachments.filter((a) => a.path !== void 0 && !a.name.startsWith("_") && a.contentType
|
|
4279
|
+
const artifacts = attempt.attachments.filter((a) => a.path !== void 0 && !a.name.startsWith("_") && !READ_NOT_KEPT.has(a.contentType ?? "")).map(({ name, contentType: contentType2 }) => ({ name: fileNameOf(name), ...contentType2 ? { contentType: contentType2 } : {} })).filter((a) => a.name !== "");
|
|
4280
4280
|
const ciUrl = webLink(attempt.buildHref);
|
|
4281
4281
|
const failure2 = {
|
|
4282
4282
|
...headline2 !== void 0 ? { headline: headline2 } : {},
|
|
@@ -4387,7 +4387,7 @@ function fromRoot(place, root) {
|
|
|
4387
4387
|
function webLink(href) {
|
|
4388
4388
|
return href !== void 0 && /^https?:\/\//i.test(href) && URL.canParse(href) ? href : void 0;
|
|
4389
4389
|
}
|
|
4390
|
-
var import_node_fs2, import_node_os, import_node_path3, import_node_util, printable, mediaTypeOf, TEXT_TYPES, isTextType, PATH_START, TEXT_LIMIT, HEADLINE_LIMIT, jsonBytes, ANY_HOME, fileNameOf, omitted,
|
|
4390
|
+
var import_node_fs2, import_node_os, import_node_path3, import_node_util, printable, mediaTypeOf, TEXT_TYPES, isTextType, PATH_START, TEXT_LIMIT, HEADLINE_LIMIT, jsonBytes, ANY_HOME, fileNameOf, omitted, READ_NOT_KEPT, REPO_RELATIVE, FRAME, FRAME_MAX, firstLine, normal;
|
|
4391
4391
|
var init_failure_detail = __esm({
|
|
4392
4392
|
"src/reporter-core/failure-detail.ts"() {
|
|
4393
4393
|
"use strict";
|
|
@@ -4407,7 +4407,7 @@ var init_failure_detail = __esm({
|
|
|
4407
4407
|
ANY_HOME = /(?<=^|[\s'"`(=,[])(?:(?:file|webpack|webpack-internal):(?:\\*\/){2,3})?(?:\\*\/home\\*\/|\\*\/Users\\*\/|[A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s'"`:*?<>|]+/g;
|
|
4408
4408
|
fileNameOf = (name) => /^(?:file:\/\/|[\\/]|~[\\/]|[A-Za-z]:[\\/])/.test(name) ? name.split(/[\\/]/).pop() ?? "" : name;
|
|
4409
4409
|
omitted = (lines) => `\u2026[omitted ${lines} lines]\u2026`;
|
|
4410
|
-
|
|
4410
|
+
READ_NOT_KEPT = /* @__PURE__ */ new Set(["application/plune.metadata+json", "application/plune.findings+json"]);
|
|
4411
4411
|
REPO_RELATIVE = /^(?![A-Za-z][A-Za-z0-9+.-]*:)(?![\\/~])(?!(?:.*[\\/])?\.\.(?:[\\/]|$)).+$/;
|
|
4412
4412
|
FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
|
|
4413
4413
|
FRAME_MAX = 8192;
|
|
@@ -4771,14 +4771,14 @@ function readLines(stream, onLine, stats) {
|
|
|
4771
4771
|
if (stats !== void 0 && rest.length > stats.high) stats.high = rest.length;
|
|
4772
4772
|
partial = rest.slice(0, STDERR_LINE_LIMIT);
|
|
4773
4773
|
};
|
|
4774
|
-
return new Promise((
|
|
4774
|
+
return new Promise((resolve24) => {
|
|
4775
4775
|
let done = false;
|
|
4776
4776
|
const finish = () => {
|
|
4777
4777
|
if (done) return;
|
|
4778
4778
|
done = true;
|
|
4779
4779
|
feed(decoder.end());
|
|
4780
4780
|
if (partial !== "") onLine(partial.endsWith("\r") ? partial.slice(0, -1) : partial);
|
|
4781
|
-
|
|
4781
|
+
resolve24();
|
|
4782
4782
|
};
|
|
4783
4783
|
stream.on(
|
|
4784
4784
|
"data",
|
|
@@ -5076,7 +5076,7 @@ async function openSession(config, options = {}) {
|
|
|
5076
5076
|
const stdin = transport._process?.stdin;
|
|
5077
5077
|
if (stdin === null || stdin === void 0 || stdin.writableEnded)
|
|
5078
5078
|
throw spawnError !== void 0 ? await toConnectError(spawnError) : new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
|
|
5079
|
-
return new Promise((
|
|
5079
|
+
return new Promise((resolve24, reject) => {
|
|
5080
5080
|
const done = () => {
|
|
5081
5081
|
clearTimeout(timer2);
|
|
5082
5082
|
listeners.delete(listener);
|
|
@@ -5090,7 +5090,7 @@ async function openSession(config, options = {}) {
|
|
|
5090
5090
|
const frame2 = parsed(line);
|
|
5091
5091
|
if (!answers(frame2, id2)) return;
|
|
5092
5092
|
done();
|
|
5093
|
-
|
|
5093
|
+
resolve24({ frame: frame2, text: clean3(line).slice(0, RAW_TEXT) });
|
|
5094
5094
|
};
|
|
5095
5095
|
const stop = () => {
|
|
5096
5096
|
done();
|
|
@@ -5170,10 +5170,10 @@ async function openSession(config, options = {}) {
|
|
|
5170
5170
|
const proc = transport._process;
|
|
5171
5171
|
if (proc === void 0) return true;
|
|
5172
5172
|
if (proc.exitCode !== null || proc.signalCode !== null) return true;
|
|
5173
|
-
const exited = new Promise((
|
|
5173
|
+
const exited = new Promise((resolve24) => proc.once("exit", () => resolve24(true)));
|
|
5174
5174
|
proc.stdin?.end();
|
|
5175
5175
|
let timer2;
|
|
5176
|
-
const late = new Promise((
|
|
5176
|
+
const late = new Promise((resolve24) => timer2 = setTimeout(() => resolve24(false), waitMs));
|
|
5177
5177
|
const result2 = await Promise.race([exited, late]);
|
|
5178
5178
|
clearTimeout(timer2);
|
|
5179
5179
|
return result2;
|
|
@@ -8908,7 +8908,7 @@ function parseRetryAfter(raw, now = Date.now()) {
|
|
|
8908
8908
|
return Math.min(Math.max(seconds, 0) * 1e3, RETRY_AFTER_CAP_MS);
|
|
8909
8909
|
}
|
|
8910
8910
|
function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
8911
|
-
return new Promise((
|
|
8911
|
+
return new Promise((resolve24, reject) => {
|
|
8912
8912
|
const target4 = new URL(url);
|
|
8913
8913
|
const send3 = target4.protocol === "https:" ? import_node_https.request : import_node_http.request;
|
|
8914
8914
|
const agent = POOLS[target4.protocol === "https:" ? "https:" : "http:"];
|
|
@@ -8919,7 +8919,7 @@ function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
|
8919
8919
|
res.on("end", () => {
|
|
8920
8920
|
const status2 = res.statusCode ?? 0;
|
|
8921
8921
|
const text6 = Buffer.concat(chunks).toString("utf8");
|
|
8922
|
-
|
|
8922
|
+
resolve24({
|
|
8923
8923
|
ok: status2 >= 200 && status2 <= 299,
|
|
8924
8924
|
status: status2,
|
|
8925
8925
|
headers: {
|
|
@@ -8938,12 +8938,12 @@ function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
|
8938
8938
|
});
|
|
8939
8939
|
}
|
|
8940
8940
|
function nodePut(url, headers, source, idleMs) {
|
|
8941
|
-
return new Promise((
|
|
8941
|
+
return new Promise((resolve24, reject) => {
|
|
8942
8942
|
const target4 = new URL(url);
|
|
8943
8943
|
const send3 = target4.protocol === "https:" ? import_node_https.request : import_node_http.request;
|
|
8944
8944
|
const length = "body" in source ? source.body.length : source.size;
|
|
8945
8945
|
let answered;
|
|
8946
|
-
const settle = (err) => answered !== void 0 ?
|
|
8946
|
+
const settle = (err) => answered !== void 0 ? resolve24(answered) : reject(err);
|
|
8947
8947
|
const req = send3(
|
|
8948
8948
|
target4,
|
|
8949
8949
|
{ method: "PUT", headers: { ...withoutLength(headers), "content-length": String(length) } },
|
|
@@ -8952,7 +8952,7 @@ function nodePut(url, headers, source, idleMs) {
|
|
|
8952
8952
|
answered = { status: res.statusCode ?? 0, retryAfter: Array.isArray(retry) ? retry[0] ?? null : retry ?? null };
|
|
8953
8953
|
res.on("error", settle);
|
|
8954
8954
|
res.on("close", () => {
|
|
8955
|
-
|
|
8955
|
+
resolve24(answered);
|
|
8956
8956
|
req.destroy();
|
|
8957
8957
|
});
|
|
8958
8958
|
res.resume();
|
|
@@ -9574,8 +9574,13 @@ function withoutTargets(result2) {
|
|
|
9574
9574
|
const { targets: _targets, traceUrl: _traceUrl, ...rest } = result2;
|
|
9575
9575
|
return rest;
|
|
9576
9576
|
}
|
|
9577
|
+
function withoutFindings(result2) {
|
|
9578
|
+
if (result2.findings === void 0) return result2;
|
|
9579
|
+
const { findings: _findings, ...rest } = result2;
|
|
9580
|
+
return rest;
|
|
9581
|
+
}
|
|
9577
9582
|
function onDisk(deferred) {
|
|
9578
|
-
const result2 = withoutTargets(deferred);
|
|
9583
|
+
const result2 = withoutFindings(withoutTargets(deferred));
|
|
9579
9584
|
if (!("files" in result2) || result2.files === void 0) return result2;
|
|
9580
9585
|
const { files, ...rest } = result2;
|
|
9581
9586
|
const kept = files.filter((f) => f.path !== void 0).map(({ body: _body, ...file }) => file);
|
|
@@ -9723,7 +9728,7 @@ function fileSender(options) {
|
|
|
9723
9728
|
let free = uploadsAtOnce;
|
|
9724
9729
|
const waiting = [];
|
|
9725
9730
|
async function gated(work) {
|
|
9726
|
-
if (free === 0) await new Promise((
|
|
9731
|
+
if (free === 0) await new Promise((resolve24) => waiting.push(resolve24));
|
|
9727
9732
|
else free -= 1;
|
|
9728
9733
|
try {
|
|
9729
9734
|
return await work();
|
|
@@ -10022,7 +10027,7 @@ function fileSender(options) {
|
|
|
10022
10027
|
if (item?.status !== "accepted" || typeof item.id !== "string" || typeof item.resultKey !== "string") continue;
|
|
10023
10028
|
for (const file of filesByKey.get(item.resultKey) ?? []) {
|
|
10024
10029
|
const type = mediaTypeOf(file.contentType) ?? (file.path === void 0 ? void 0 : TYPE_BY_EXTENSION[(0, import_node_path5.extname)(file.path).toLowerCase()]);
|
|
10025
|
-
if (type === void 0 || type
|
|
10030
|
+
if (type === void 0 || READ_NOT_KEPT2.has(type)) continue;
|
|
10026
10031
|
const kind2 = kindOf3(type);
|
|
10027
10032
|
if (kind2 !== "text" && file.path === void 0) continue;
|
|
10028
10033
|
const name = nameOf(file);
|
|
@@ -10125,6 +10130,7 @@ async function startRun(passed2, declared2) {
|
|
|
10125
10130
|
let joined = false;
|
|
10126
10131
|
let offline = token2 === "";
|
|
10127
10132
|
let targetsRefused = false;
|
|
10133
|
+
let findingsRefused = false;
|
|
10128
10134
|
let done = false;
|
|
10129
10135
|
const shortened = /* @__PURE__ */ new Set();
|
|
10130
10136
|
const specFiles = /* @__PURE__ */ new Map();
|
|
@@ -10396,6 +10402,7 @@ async function startRun(passed2, declared2) {
|
|
|
10396
10402
|
async function send3(submissions, filesByKey) {
|
|
10397
10403
|
for (const packedPart of packed(submissions)) {
|
|
10398
10404
|
let part = targetsRefused ? packedPart.map(withoutTargets) : packedPart;
|
|
10405
|
+
if (findingsRefused) part = part.map(withoutFindings);
|
|
10399
10406
|
if (offline) {
|
|
10400
10407
|
defer(part);
|
|
10401
10408
|
continue;
|
|
@@ -10406,12 +10413,22 @@ async function startRun(passed2, declared2) {
|
|
|
10406
10413
|
{ results: results4, ...configuration !== void 0 ? { configuration } : {} }
|
|
10407
10414
|
);
|
|
10408
10415
|
let out = await post(part);
|
|
10416
|
+
let withoutItsFindings = false;
|
|
10417
|
+
if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.findings !== void 0)) {
|
|
10418
|
+
withoutItsFindings = true;
|
|
10419
|
+
part = part.map(withoutFindings);
|
|
10420
|
+
out = await post(part);
|
|
10421
|
+
}
|
|
10409
10422
|
if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0 || r.traceUrl !== void 0)) {
|
|
10410
10423
|
if (!targetsRefused) log("plune: the platform does not take targets or a trace link on a result yet \u2014 the results are sent without them.");
|
|
10411
10424
|
targetsRefused = true;
|
|
10412
10425
|
part = part.map(withoutTargets);
|
|
10413
10426
|
out = await post(part);
|
|
10414
10427
|
}
|
|
10428
|
+
if (withoutItsFindings && out.ok) {
|
|
10429
|
+
if (!findingsRefused) log("plune: the platform does not take findings on a result yet \u2014 the results are sent without them.");
|
|
10430
|
+
findingsRefused = true;
|
|
10431
|
+
}
|
|
10415
10432
|
const counts3 = out.ok ? out.body?.counts : void 0;
|
|
10416
10433
|
const told = COUNTED.filter((k) => typeof counts3?.[k] === "number");
|
|
10417
10434
|
if (told.length > 0) {
|
|
@@ -10584,7 +10601,7 @@ async function startRun(passed2, declared2) {
|
|
|
10584
10601
|
}
|
|
10585
10602
|
};
|
|
10586
10603
|
}
|
|
10587
|
-
var import_node_crypto4, import_node_fs9, import_node_path5, import_node_util2, RESOLVE_CHUNK, BATCH_MAX, DISCOVER_MAX, BATCH_DEFAULT, SNAPSHOT_UPDATES_MAX, SEND_CONCURRENCY, EXPECTED_MAX, KEY_MAX, TITLE_MAX, COUNTED, SCREENSHOT_TYPES, SCREENSHOT_BYTES, SCREENSHOTS_PER_RESULT, TEXT_BYTES, TEXTS_PER_RESULT, UTF8, TYPE_BY_EXTENSION,
|
|
10604
|
+
var import_node_crypto4, import_node_fs9, import_node_path5, import_node_util2, RESOLVE_CHUNK, BATCH_MAX, DISCOVER_MAX, BATCH_DEFAULT, SNAPSHOT_UPDATES_MAX, SEND_CONCURRENCY, EXPECTED_MAX, KEY_MAX, TITLE_MAX, COUNTED, SCREENSHOT_TYPES, SCREENSHOT_BYTES, SCREENSHOTS_PER_RESULT, TEXT_BYTES, TEXTS_PER_RESULT, UTF8, TYPE_BY_EXTENSION, READ_NOT_KEPT2, NAME_MAX, SKIPPED, BUCKET_FOUND, KINDS, codeOf2, keyId, BATCH_BYTES, ENVELOPE_BYTES;
|
|
10588
10605
|
var init_session2 = __esm({
|
|
10589
10606
|
"src/reporter-core/session.ts"() {
|
|
10590
10607
|
"use strict";
|
|
@@ -10623,7 +10640,7 @@ var init_session2 = __esm({
|
|
|
10623
10640
|
".jpeg": "image/jpeg",
|
|
10624
10641
|
".webp": "image/webp"
|
|
10625
10642
|
};
|
|
10626
|
-
|
|
10643
|
+
READ_NOT_KEPT2 = /* @__PURE__ */ new Set(["application/plune.metadata+json", "application/plune.findings+json"]);
|
|
10627
10644
|
NAME_MAX = 200;
|
|
10628
10645
|
SKIPPED = {
|
|
10629
10646
|
hidden: "its name starts with an underscore, which hides an attachment in Playwright's own reports too",
|
|
@@ -10771,14 +10788,14 @@ async function handleRunExec(options) {
|
|
|
10771
10788
|
if (command === void 0) throw new RunCommandError("Nothing to run \u2014 pass a command after `--`.");
|
|
10772
10789
|
const run = await handleRunStart(options);
|
|
10773
10790
|
const spawnImpl = options.spawnImpl ?? import_node_child_process2.spawn;
|
|
10774
|
-
const code = await new Promise((
|
|
10791
|
+
const code = await new Promise((resolve24) => {
|
|
10775
10792
|
const child = spawnImpl(command, args, {
|
|
10776
10793
|
stdio: "inherit",
|
|
10777
10794
|
shell: process.platform === "win32",
|
|
10778
10795
|
env: { ...process.env, PLUNE_RUN: run.externalKey, PLUNE_PROCEED: "1" }
|
|
10779
10796
|
});
|
|
10780
|
-
child.on("close", (exitCode2) =>
|
|
10781
|
-
child.on("error", () =>
|
|
10797
|
+
child.on("close", (exitCode2) => resolve24(exitCode2 ?? 1));
|
|
10798
|
+
child.on("error", () => resolve24(1));
|
|
10782
10799
|
});
|
|
10783
10800
|
return handleRunFinish(run.id, options, code);
|
|
10784
10801
|
}
|
|
@@ -12747,7 +12764,7 @@ async function timeoutMessage(limit3, runId, ours, options) {
|
|
|
12747
12764
|
if (!ours) return `${head}; run ${runId} is shared with other jobs and was left open - close it with "plune run finish ${runId}" once they are done, then import this report again.`;
|
|
12748
12765
|
const wait = options.terminateWaitMs ?? 15e3;
|
|
12749
12766
|
let timer;
|
|
12750
|
-
const gaveUp = new Promise((
|
|
12767
|
+
const gaveUp = new Promise((resolve24) => timer = setTimeout(() => resolve24("gaveup"), wait));
|
|
12751
12768
|
const quiet = () => void 0;
|
|
12752
12769
|
const closed = handleRunFinish(runId, { ...options, write: quiet, terminate: true, reason: `import timed out after ${limit3} s` }).then(
|
|
12753
12770
|
() => true,
|
|
@@ -12853,7 +12870,7 @@ async function handleRunImport(options) {
|
|
|
12853
12870
|
else {
|
|
12854
12871
|
sent.catch(() => void 0);
|
|
12855
12872
|
let timer;
|
|
12856
|
-
const late = new Promise((
|
|
12873
|
+
const late = new Promise((resolve24) => timer = setTimeout(() => resolve24("late"), limit3 * 1e3));
|
|
12857
12874
|
const first = await Promise.race([sent, late]).finally(() => clearTimeout(timer));
|
|
12858
12875
|
if (first === "late") {
|
|
12859
12876
|
throw new ImportTimeoutError(await timeoutMessage(limit3, session2?.runId ?? null, !env.keepOpen, { ...options, apiUrl, token: token2 }));
|
|
@@ -13768,10 +13785,355 @@ evals:
|
|
|
13768
13785
|
}
|
|
13769
13786
|
});
|
|
13770
13787
|
|
|
13788
|
+
// src/config/init/from-openai-eval.ts
|
|
13789
|
+
var from_openai_eval_exports = {};
|
|
13790
|
+
__export(from_openai_eval_exports, {
|
|
13791
|
+
OpenAiEvalImportError: () => OpenAiEvalImportError,
|
|
13792
|
+
convertOpenAiEval: () => convertOpenAiEval,
|
|
13793
|
+
formatReport: () => formatReport2
|
|
13794
|
+
});
|
|
13795
|
+
function rewriteItemRefs(text6, prefix, seen, bad) {
|
|
13796
|
+
return text6.replace(ITEM_REF, (match, name) => {
|
|
13797
|
+
if (!FLAT.test(name)) {
|
|
13798
|
+
bad.add(name);
|
|
13799
|
+
return match;
|
|
13800
|
+
}
|
|
13801
|
+
seen.add(name);
|
|
13802
|
+
return `{{${prefix}${name}}}`;
|
|
13803
|
+
});
|
|
13804
|
+
}
|
|
13805
|
+
function hasNonText(messages) {
|
|
13806
|
+
const nonText = (content) => Array.isArray(content) ? content.some(nonText) : isObj(content) && typeof content.text !== "string";
|
|
13807
|
+
return Array.isArray(messages) && messages.some((m) => isObj(m) && nonText(m.content));
|
|
13808
|
+
}
|
|
13809
|
+
function textOf2(content) {
|
|
13810
|
+
if (typeof content === "string") return content;
|
|
13811
|
+
if (Array.isArray(content))
|
|
13812
|
+
return content.map(textOf2).filter((t) => t !== "").join("\n");
|
|
13813
|
+
if (isObj(content) && typeof content.text === "string") return content.text;
|
|
13814
|
+
return "";
|
|
13815
|
+
}
|
|
13816
|
+
function joinMessages(messages, keep = () => true) {
|
|
13817
|
+
if (!Array.isArray(messages)) return "";
|
|
13818
|
+
return messages.map((m) => isObj(m) ? textOf2(m.content) : "").filter((t) => t !== "" && keep(t)).join("\n\n");
|
|
13819
|
+
}
|
|
13820
|
+
function slug(name) {
|
|
13821
|
+
const s = typeof name === "string" ? name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") : "";
|
|
13822
|
+
return s === "" ? "imported-eval" : s;
|
|
13823
|
+
}
|
|
13824
|
+
function criteriaOf(grader, seen, bad) {
|
|
13825
|
+
const more = (text6) => text6.replace(SAMPLE_REF, "").trim() !== "";
|
|
13826
|
+
return rewriteItemRefs(joinMessages(grader.input, more), "vars.", seen, bad).replace(
|
|
13827
|
+
SAMPLE_REF,
|
|
13828
|
+
"the OUTPUT"
|
|
13829
|
+
);
|
|
13830
|
+
}
|
|
13831
|
+
function judgeProvider(grader) {
|
|
13832
|
+
return typeof grader.model === "string" && grader.model !== "" ? { provider: { type: "openai", model: grader.model } } : {};
|
|
13833
|
+
}
|
|
13834
|
+
function convertGrader(grader, seen) {
|
|
13835
|
+
const type = typeof grader.type === "string" ? grader.type : "unknown";
|
|
13836
|
+
const subject2 = `${typeof grader.name === "string" ? grader.name : "(no name)"} [${type}]`;
|
|
13837
|
+
const skip = (note2) => ({
|
|
13838
|
+
line: { status: "not converted", subject: subject2, note: note2 }
|
|
13839
|
+
});
|
|
13840
|
+
if (type === "string_check" || type === "text_similarity") {
|
|
13841
|
+
if (typeof grader.input !== "string" || !OUTPUT_TEXT.test(grader.input.trim())) {
|
|
13842
|
+
return skip(
|
|
13843
|
+
`its input is ${JSON.stringify(grader.input)}; a check here reads the model's text answer ({{ sample.output_text }}) only`
|
|
13844
|
+
);
|
|
13845
|
+
}
|
|
13846
|
+
if (typeof grader.reference !== "string") return skip("it has no reference text");
|
|
13847
|
+
if (grader.reference === "" && !(type === "string_check" && grader.operation === "eq"))
|
|
13848
|
+
return skip("its reference is empty");
|
|
13849
|
+
if (SAMPLE_REF.test(grader.reference)) {
|
|
13850
|
+
SAMPLE_REF.lastIndex = 0;
|
|
13851
|
+
return skip(
|
|
13852
|
+
"its reference reads the model sample; a check here compares with the row or a fixed text"
|
|
13853
|
+
);
|
|
13854
|
+
}
|
|
13855
|
+
const local = /* @__PURE__ */ new Set();
|
|
13856
|
+
const bad = /* @__PURE__ */ new Set();
|
|
13857
|
+
const reference = rewriteItemRefs(grader.reference, "vars.", local, bad);
|
|
13858
|
+
if (bad.size > 0) return skip(`its reference points at ${badRefs(bad)}: ${NOT_FLAT}`);
|
|
13859
|
+
const ok2 = (assertion, status2, note2) => {
|
|
13860
|
+
local.forEach((n) => seen.add(n));
|
|
13861
|
+
return { assertion, line: { status: status2, subject: subject2, note: note2 } };
|
|
13862
|
+
};
|
|
13863
|
+
if (type === "string_check") {
|
|
13864
|
+
switch (grader.operation) {
|
|
13865
|
+
case "eq":
|
|
13866
|
+
return ok2({ type: "exact-match", value: reference }, "converted", "exact-match");
|
|
13867
|
+
case "like":
|
|
13868
|
+
return ok2({ type: "contains", value: reference }, "converted", "contains");
|
|
13869
|
+
case "ilike":
|
|
13870
|
+
return ok2(
|
|
13871
|
+
{ type: "contains", value: reference, ignore_case: true },
|
|
13872
|
+
"converted",
|
|
13873
|
+
"contains, ignore_case"
|
|
13874
|
+
);
|
|
13875
|
+
default:
|
|
13876
|
+
return skip(
|
|
13877
|
+
`operation ${JSON.stringify(grader.operation)} has no check here (there is no negated check)`
|
|
13878
|
+
);
|
|
13879
|
+
}
|
|
13880
|
+
}
|
|
13881
|
+
if (grader.evaluation_metric !== "cosine") {
|
|
13882
|
+
return skip(
|
|
13883
|
+
`metric ${JSON.stringify(grader.evaluation_metric)} has no check here; only cosine has one (semantic-similarity)`
|
|
13884
|
+
);
|
|
13885
|
+
}
|
|
13886
|
+
const t = grader.pass_threshold;
|
|
13887
|
+
const inRange = typeof t === "number" && t >= 0 && t <= 1;
|
|
13888
|
+
return ok2(
|
|
13889
|
+
{ type: "semantic-similarity", reference, ...inRange ? { threshold: t } : {} },
|
|
13890
|
+
"approximate",
|
|
13891
|
+
"semantic-similarity: the embedding model is a different, local one, so run it and look at the threshold again" + (t !== void 0 && !inRange ? `; pass_threshold ${JSON.stringify(t)} is not between 0 and 1 and was left out` : "")
|
|
13892
|
+
);
|
|
13893
|
+
}
|
|
13894
|
+
if (type === "score_model" || type === "label_model") {
|
|
13895
|
+
const local = /* @__PURE__ */ new Set();
|
|
13896
|
+
const bad = /* @__PURE__ */ new Set();
|
|
13897
|
+
const criteria = criteriaOf(grader, local, bad);
|
|
13898
|
+
if (bad.size > 0) return skip(`its messages point at ${badRefs(bad)}: ${NOT_FLAT}`);
|
|
13899
|
+
local.forEach((n) => seen.add(n));
|
|
13900
|
+
const parts = hasNonText(grader.input) ? "; parts of its messages that are not text were left out" : "";
|
|
13901
|
+
if (type === "label_model") return labelModel(grader, criteria, subject2, parts);
|
|
13902
|
+
if (criteria === "") return skip("its messages hold no text");
|
|
13903
|
+
const range = Array.isArray(grader.range) ? grader.range : [0, 1];
|
|
13904
|
+
const [min, max] = [range[0], range[1]];
|
|
13905
|
+
const t = grader.pass_threshold;
|
|
13906
|
+
let pass2 = {};
|
|
13907
|
+
let scale = "no pass_threshold in the grader, so the default of llm-judge applies";
|
|
13908
|
+
if (typeof t === "number" && typeof min === "number" && typeof max === "number" && max > min) {
|
|
13909
|
+
const scaled = Math.min(1, Math.max(0, (t - min) / (max - min)));
|
|
13910
|
+
pass2 = { pass_threshold: Number(scaled.toFixed(4)) };
|
|
13911
|
+
scale = `pass_threshold ${t} on ${min}..${max} became ${pass2.pass_threshold} on 0..1`;
|
|
13912
|
+
} else if (t !== void 0) {
|
|
13913
|
+
scale = `pass_threshold ${JSON.stringify(t)} could not be rescaled from the range ${JSON.stringify(grader.range)} and was left out, so the default of llm-judge applies`;
|
|
13914
|
+
}
|
|
13915
|
+
return {
|
|
13916
|
+
assertion: { type: "llm-judge", criteria, ...pass2, ...judgeProvider(grader) },
|
|
13917
|
+
line: {
|
|
13918
|
+
status: "approximate",
|
|
13919
|
+
subject: subject2,
|
|
13920
|
+
note: `llm-judge: the grader's messages are the criteria and the judge scores 0..1; ${scale}${parts}`
|
|
13921
|
+
}
|
|
13922
|
+
};
|
|
13923
|
+
}
|
|
13924
|
+
if (type === "python") return skip("a Python grader runs code; no check here runs code");
|
|
13925
|
+
return skip("this grader type has no check here");
|
|
13926
|
+
}
|
|
13927
|
+
function labelModel(grader, text6, subject2, parts) {
|
|
13928
|
+
const skip = (note2) => ({
|
|
13929
|
+
line: { status: "not converted", subject: subject2, note: note2 }
|
|
13930
|
+
});
|
|
13931
|
+
const labels = Array.isArray(grader.labels) ? grader.labels.filter((l) => typeof l === "string") : [];
|
|
13932
|
+
const passing = Array.isArray(grader.passing_labels) ? grader.passing_labels.filter((l) => typeof l === "string") : [];
|
|
13933
|
+
if (labels.length === 0 || passing.length === 0)
|
|
13934
|
+
return skip("it has no labels or no passing labels");
|
|
13935
|
+
const rule = `Pick one label for the OUTPUT from: ${labels.join(", ")}. Score 1 if the label is one of: ${passing.join(", ")}. Otherwise score 0.`;
|
|
13936
|
+
return {
|
|
13937
|
+
assertion: {
|
|
13938
|
+
type: "llm-judge",
|
|
13939
|
+
criteria: text6 === "" ? rule : `${text6}
|
|
13940
|
+
|
|
13941
|
+
${rule}`,
|
|
13942
|
+
...judgeProvider(grader)
|
|
13943
|
+
},
|
|
13944
|
+
line: {
|
|
13945
|
+
status: "approximate",
|
|
13946
|
+
subject: subject2,
|
|
13947
|
+
note: `llm-judge: the judge gives a score, 1 for a passing label, in place of the label itself${parts}`
|
|
13948
|
+
}
|
|
13949
|
+
};
|
|
13950
|
+
}
|
|
13951
|
+
function convertRows(items2, report) {
|
|
13952
|
+
const asText = /* @__PURE__ */ new Set();
|
|
13953
|
+
const rows = items2.map((raw, i) => {
|
|
13954
|
+
const item = isObj(raw) && "item" in raw ? raw.item : raw;
|
|
13955
|
+
if (!isObj(item)) throw new OpenAiEvalImportError(`test data row ${i + 1} is not an object`);
|
|
13956
|
+
const vars = Object.fromEntries(
|
|
13957
|
+
Object.entries(item).map(([key, value2]) => {
|
|
13958
|
+
if (typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean")
|
|
13959
|
+
return [key, value2];
|
|
13960
|
+
asText.add(key);
|
|
13961
|
+
return [key, JSON.stringify(value2)];
|
|
13962
|
+
})
|
|
13963
|
+
);
|
|
13964
|
+
return { vars };
|
|
13965
|
+
});
|
|
13966
|
+
if (asText.size > 0) {
|
|
13967
|
+
report.push({
|
|
13968
|
+
status: "check",
|
|
13969
|
+
subject: "test data",
|
|
13970
|
+
note: `written as JSON text, as a row value here is a string, a number or a boolean: ${[...asText].sort().join(", ")}`
|
|
13971
|
+
});
|
|
13972
|
+
}
|
|
13973
|
+
return rows;
|
|
13974
|
+
}
|
|
13975
|
+
function parseJsonl(text6) {
|
|
13976
|
+
const out = [];
|
|
13977
|
+
text6.split(/\r?\n/).forEach((line, i) => {
|
|
13978
|
+
if (line.trim() === "") return;
|
|
13979
|
+
try {
|
|
13980
|
+
out.push(JSON.parse(line));
|
|
13981
|
+
} catch {
|
|
13982
|
+
throw new OpenAiEvalImportError(`test data line ${i + 1} is not JSON`);
|
|
13983
|
+
}
|
|
13984
|
+
});
|
|
13985
|
+
return out;
|
|
13986
|
+
}
|
|
13987
|
+
function convertOpenAiEval({ evalObject, run, rows }) {
|
|
13988
|
+
if (!isObj(evalObject) || !Array.isArray(evalObject.testing_criteria)) {
|
|
13989
|
+
throw new OpenAiEvalImportError(
|
|
13990
|
+
"the eval file is not an eval object: it has no testing_criteria list (save the answer of GET /v1/evals/{eval_id})"
|
|
13991
|
+
);
|
|
13992
|
+
}
|
|
13993
|
+
if (run !== void 0 && !isObj(run))
|
|
13994
|
+
throw new OpenAiEvalImportError("the run file is not a run object");
|
|
13995
|
+
const id2 = slug(evalObject.name);
|
|
13996
|
+
const report = [];
|
|
13997
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13998
|
+
const assertions = [];
|
|
13999
|
+
for (const grader of evalObject.testing_criteria) {
|
|
14000
|
+
const { assertion, line } = convertGrader(isObj(grader) ? grader : {}, seen);
|
|
14001
|
+
if (assertion !== void 0) assertions.push(assertion);
|
|
14002
|
+
report.push(line);
|
|
14003
|
+
}
|
|
14004
|
+
if (assertions.length === 0) {
|
|
14005
|
+
report.push({
|
|
14006
|
+
status: "check",
|
|
14007
|
+
subject: "checks",
|
|
14008
|
+
note: "no grader was converted: the eval has no checks until you add some"
|
|
14009
|
+
});
|
|
14010
|
+
}
|
|
14011
|
+
const source = isObj(run) && isObj(run.data_source) ? run.data_source : {};
|
|
14012
|
+
const template = isObj(source.input_messages) ? source.input_messages.template : void 0;
|
|
14013
|
+
const count6 = Array.isArray(template) ? template.length : 0;
|
|
14014
|
+
const inPrompt = /* @__PURE__ */ new Set();
|
|
14015
|
+
let prompt5 = rewriteItemRefs(joinMessages(template), "", inPrompt, /* @__PURE__ */ new Set());
|
|
14016
|
+
inPrompt.forEach((n) => seen.add(n));
|
|
14017
|
+
const left = [...new Set(prompt5.match(ANY_REF) ?? [])].filter(
|
|
14018
|
+
(m) => !inPrompt.has(m.slice(2, -2))
|
|
14019
|
+
);
|
|
14020
|
+
if (left.length > 0) {
|
|
14021
|
+
report.push({
|
|
14022
|
+
status: "check",
|
|
14023
|
+
subject: "prompt",
|
|
14024
|
+
note: `it still holds ${left.join(", ")}, which is not a field of a row: plune run refuses the prompt until you change it`
|
|
14025
|
+
});
|
|
14026
|
+
}
|
|
14027
|
+
if (hasNonText(template)) {
|
|
14028
|
+
report.push({
|
|
14029
|
+
status: "check",
|
|
14030
|
+
subject: "prompt",
|
|
14031
|
+
note: "parts of its messages that are not text were left out"
|
|
14032
|
+
});
|
|
14033
|
+
}
|
|
14034
|
+
const sampling = isObj(source.sampling_params) ? Object.keys(source.sampling_params).sort() : [];
|
|
14035
|
+
if (sampling.length > 0) {
|
|
14036
|
+
report.push({
|
|
14037
|
+
status: "check",
|
|
14038
|
+
subject: "model",
|
|
14039
|
+
note: `the sampling parameters of the run are not carried over: ${sampling.join(", ")}`
|
|
14040
|
+
});
|
|
14041
|
+
}
|
|
14042
|
+
if (prompt5 === "") {
|
|
14043
|
+
prompt5 = "Replace this line with your prompt.";
|
|
14044
|
+
report.push({
|
|
14045
|
+
status: "check",
|
|
14046
|
+
subject: "prompt",
|
|
14047
|
+
note: "no prompt template was found (give a run with --run): the prompt is a placeholder"
|
|
14048
|
+
});
|
|
14049
|
+
} else if (count6 > 1) {
|
|
14050
|
+
report.push({
|
|
14051
|
+
status: "check",
|
|
14052
|
+
subject: "prompt",
|
|
14053
|
+
note: `${count6} messages were joined into one prompt; their roles are not kept`
|
|
14054
|
+
});
|
|
14055
|
+
}
|
|
14056
|
+
let model = typeof source.model === "string" && source.model !== "" ? source.model : void 0;
|
|
14057
|
+
if (model === void 0) {
|
|
14058
|
+
model = "gpt-4o";
|
|
14059
|
+
report.push({
|
|
14060
|
+
status: "check",
|
|
14061
|
+
subject: "model",
|
|
14062
|
+
note: "no model was found (give a run with --run): it is set to gpt-4o"
|
|
14063
|
+
});
|
|
14064
|
+
}
|
|
14065
|
+
const inline = isObj(source.source) && Array.isArray(source.source.content) ? source.source.content : void 0;
|
|
14066
|
+
const fromFile = rows !== void 0 ? parseJsonl(rows) : [];
|
|
14067
|
+
const items2 = fromFile.length > 0 ? fromFile : inline;
|
|
14068
|
+
let dataset;
|
|
14069
|
+
let datasetField;
|
|
14070
|
+
if (items2 !== void 0 && items2.length > 0) {
|
|
14071
|
+
const path25 = `datasets/${id2}.jsonl`;
|
|
14072
|
+
dataset = {
|
|
14073
|
+
path: path25,
|
|
14074
|
+
jsonl: convertRows(items2, report).map((r) => JSON.stringify(r)).join("\n") + "\n"
|
|
14075
|
+
};
|
|
14076
|
+
datasetField = `./${path25}`;
|
|
14077
|
+
} else {
|
|
14078
|
+
const vars = Object.fromEntries([...seen].sort().map((n) => [n, "replace me"]));
|
|
14079
|
+
datasetField = { examples: [{ vars }] };
|
|
14080
|
+
report.push({
|
|
14081
|
+
status: "check",
|
|
14082
|
+
subject: "test data",
|
|
14083
|
+
note: rows !== void 0 ? "the test data file holds no rows: the dataset is one placeholder row" : "no test data was found (give the file with --data): the dataset is one placeholder row"
|
|
14084
|
+
});
|
|
14085
|
+
}
|
|
14086
|
+
const config = {
|
|
14087
|
+
version: 1,
|
|
14088
|
+
provider: { type: "openai", model },
|
|
14089
|
+
evals: [
|
|
14090
|
+
{
|
|
14091
|
+
id: id2,
|
|
14092
|
+
...typeof evalObject.name === "string" ? { description: evalObject.name } : {},
|
|
14093
|
+
prompt: prompt5,
|
|
14094
|
+
dataset: datasetField,
|
|
14095
|
+
assertions
|
|
14096
|
+
}
|
|
14097
|
+
]
|
|
14098
|
+
};
|
|
14099
|
+
const header3 = "# Plune configuration, written by `plune init --from-openai-eval`. Read the report it printed.\n";
|
|
14100
|
+
return { yaml: header3 + (0, import_yaml4.stringify)(config), ...dataset ? { dataset } : {}, report };
|
|
14101
|
+
}
|
|
14102
|
+
function formatReport2(report) {
|
|
14103
|
+
const count6 = (s) => report.filter((l) => l.status === s).length;
|
|
14104
|
+
return report.map((l) => ` ${l.status.padEnd(13)} ${l.subject}: ${l.note}`).join("\n") + `
|
|
14105
|
+
|
|
14106
|
+
${count6("converted")} converted \xB7 ${count6("approximate")} approximate \xB7 ${count6("not converted")} not converted
|
|
14107
|
+
`;
|
|
14108
|
+
}
|
|
14109
|
+
var import_yaml4, OpenAiEvalImportError, isObj, ITEM_REF, ANY_REF, FLAT, NOT_FLAT, SAMPLE_REF, OUTPUT_TEXT, badRefs;
|
|
14110
|
+
var init_from_openai_eval = __esm({
|
|
14111
|
+
"src/config/init/from-openai-eval.ts"() {
|
|
14112
|
+
"use strict";
|
|
14113
|
+
init_cjs_shims();
|
|
14114
|
+
import_yaml4 = require("yaml");
|
|
14115
|
+
OpenAiEvalImportError = class extends Error {
|
|
14116
|
+
constructor(message2) {
|
|
14117
|
+
super(message2);
|
|
14118
|
+
this.name = "OpenAiEvalImportError";
|
|
14119
|
+
}
|
|
14120
|
+
};
|
|
14121
|
+
isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
14122
|
+
ITEM_REF = /\{\{\s*item\.([^{}]*?)\s*\}\}/g;
|
|
14123
|
+
ANY_REF = /\{\{[^{}]*\}\}/g;
|
|
14124
|
+
FLAT = /^\w+$/;
|
|
14125
|
+
NOT_FLAT = "a row here is flat, and a field a placeholder names is letters, digits and _";
|
|
14126
|
+
SAMPLE_REF = /\{\{\s*sample\.[\w.]+\s*\}\}/g;
|
|
14127
|
+
OUTPUT_TEXT = /^\{\{\s*sample\.output_text\s*\}\}$/;
|
|
14128
|
+
badRefs = (bad) => [...bad].sort().map((n) => `{{ item.${n} }}`).join(", ");
|
|
14129
|
+
}
|
|
14130
|
+
});
|
|
14131
|
+
|
|
13771
14132
|
// src/cli/commands/init.ts
|
|
13772
14133
|
var init_exports = {};
|
|
13773
14134
|
__export(init_exports, {
|
|
13774
14135
|
initCommand: () => initCommand,
|
|
14136
|
+
initFromOpenAiEval: () => initFromOpenAiEval,
|
|
13775
14137
|
nextSteps: () => nextSteps
|
|
13776
14138
|
});
|
|
13777
14139
|
function reportWrite(cwd, rel, content, force) {
|
|
@@ -13798,13 +14160,46 @@ function nextSteps(keyVar) {
|
|
|
13798
14160
|
}
|
|
13799
14161
|
function keyVarOf(cwd) {
|
|
13800
14162
|
try {
|
|
13801
|
-
const cfg = (0,
|
|
14163
|
+
const cfg = (0, import_yaml5.parse)(fs17.readFileSync(path20.join(cwd, "plune.yaml"), "utf8"));
|
|
13802
14164
|
const type = cfg?.provider?.type;
|
|
13803
14165
|
return typeof type === "string" && Object.hasOwn(PROVIDER_KEY_VARS, type) ? PROVIDER_KEY_VARS[type] : void 0;
|
|
13804
14166
|
} catch {
|
|
13805
14167
|
return void 0;
|
|
13806
14168
|
}
|
|
13807
14169
|
}
|
|
14170
|
+
async function initFromOpenAiEval(options) {
|
|
14171
|
+
const { cwd, force } = options;
|
|
14172
|
+
const { convertOpenAiEval: convertOpenAiEval2, formatReport: formatReport4, OpenAiEvalImportError: OpenAiEvalImportError2 } = await Promise.resolve().then(() => (init_from_openai_eval(), from_openai_eval_exports));
|
|
14173
|
+
const read = (file) => {
|
|
14174
|
+
try {
|
|
14175
|
+
return fs17.readFileSync(path20.resolve(cwd, file), "utf8").replace(/^/, "");
|
|
14176
|
+
} catch (err) {
|
|
14177
|
+
throw new OpenAiEvalImportError2(`cannot read ${file}: ${err.message}`);
|
|
14178
|
+
}
|
|
14179
|
+
};
|
|
14180
|
+
const json2 = (file) => {
|
|
14181
|
+
try {
|
|
14182
|
+
return JSON.parse(read(file));
|
|
14183
|
+
} catch (err) {
|
|
14184
|
+
if (err instanceof OpenAiEvalImportError2) throw err;
|
|
14185
|
+
throw new OpenAiEvalImportError2(`${file} is not JSON`);
|
|
14186
|
+
}
|
|
14187
|
+
};
|
|
14188
|
+
const converted = convertOpenAiEval2({
|
|
14189
|
+
evalObject: json2(options.evalPath),
|
|
14190
|
+
...options.runPath !== void 0 ? { run: json2(options.runPath) } : {},
|
|
14191
|
+
...options.dataPath !== void 0 ? { rows: read(options.dataPath) } : {}
|
|
14192
|
+
});
|
|
14193
|
+
try {
|
|
14194
|
+
reportWrite(cwd, "plune.yaml", converted.yaml, force);
|
|
14195
|
+
if (converted.dataset) reportWrite(cwd, converted.dataset.path, converted.dataset.jsonl, force);
|
|
14196
|
+
reportWrite(cwd, ".env.example", ENV_EXAMPLE_TPL, force);
|
|
14197
|
+
} catch (err) {
|
|
14198
|
+
throw new OpenAiEvalImportError2(`cannot write the files: ${err.message}`);
|
|
14199
|
+
}
|
|
14200
|
+
process.stdout.write("\n" + formatReport4(converted.report));
|
|
14201
|
+
process.stdout.write(nextSteps(keyVarOf(cwd)));
|
|
14202
|
+
}
|
|
13808
14203
|
async function initCommand({ cwd, force, yes = false }) {
|
|
13809
14204
|
if (yes) {
|
|
13810
14205
|
reportWrite(cwd, "plune.yaml", PLUNE_YAML_TPL, force);
|
|
@@ -13816,14 +14211,14 @@ async function initCommand({ cwd, force, yes = false }) {
|
|
|
13816
14211
|
}
|
|
13817
14212
|
process.stdout.write(nextSteps(keyVarOf(cwd)));
|
|
13818
14213
|
}
|
|
13819
|
-
var fs17, path20,
|
|
14214
|
+
var fs17, path20, import_yaml5, TEMPLATES;
|
|
13820
14215
|
var init_init = __esm({
|
|
13821
14216
|
"src/cli/commands/init.ts"() {
|
|
13822
14217
|
"use strict";
|
|
13823
14218
|
init_cjs_shims();
|
|
13824
14219
|
fs17 = __toESM(require("fs"), 1);
|
|
13825
14220
|
path20 = __toESM(require("path"), 1);
|
|
13826
|
-
|
|
14221
|
+
import_yaml5 = require("yaml");
|
|
13827
14222
|
init_wizard();
|
|
13828
14223
|
init_templates();
|
|
13829
14224
|
TEMPLATES = [
|
|
@@ -15174,8 +15569,15 @@ function createPluneMcpServer(opts, era, traits = {}) {
|
|
|
15174
15569
|
else if (!visible2.has(name) && tool2.enabled) tool2.disable();
|
|
15175
15570
|
}
|
|
15176
15571
|
};
|
|
15572
|
+
let refusesWriters = false;
|
|
15177
15573
|
for (const tool2 of PLUNE_TOOLS) {
|
|
15178
|
-
if (!offeredTo(tool2, opts.scope))
|
|
15574
|
+
if (!offeredTo(tool2, opts.scope)) {
|
|
15575
|
+
if (tool2.write) {
|
|
15576
|
+
server2.registerTool(tool2.name, { description: tool2.description }, () => toResult(readOnlyRefusal(tool2.name)));
|
|
15577
|
+
refusesWriters = true;
|
|
15578
|
+
}
|
|
15579
|
+
continue;
|
|
15580
|
+
}
|
|
15179
15581
|
const handle = server2.registerTool(
|
|
15180
15582
|
tool2.name,
|
|
15181
15583
|
{
|
|
@@ -15196,7 +15598,13 @@ function createPluneMcpServer(opts, era, traits = {}) {
|
|
|
15196
15598
|
if (fixed) {
|
|
15197
15599
|
const tools2 = PLUNE_TOOLS.filter((t) => defaultVisibleTools(opts.scope).includes(t.name)).map(listed);
|
|
15198
15600
|
server2.server.setRequestHandler("tools/list", () => ({ tools: tools2 }));
|
|
15199
|
-
} else
|
|
15601
|
+
} else {
|
|
15602
|
+
sync();
|
|
15603
|
+
if (refusesWriters)
|
|
15604
|
+
server2.server.setRequestHandler("tools/list", () => ({
|
|
15605
|
+
tools: PLUNE_TOOLS.filter((t) => registered.get(t.name)?.enabled === true).map(listed)
|
|
15606
|
+
}));
|
|
15607
|
+
}
|
|
15200
15608
|
return server2;
|
|
15201
15609
|
}
|
|
15202
15610
|
function answeringParseErrors(answer) {
|
|
@@ -15231,7 +15639,7 @@ function answeringParseErrors(answer) {
|
|
|
15231
15639
|
async function serveMcpStdio(opts) {
|
|
15232
15640
|
const input = process.stdin.pipe(answeringParseErrors((line) => process.stdout.write(line)));
|
|
15233
15641
|
const transport = new import_stdio2.StdioServerTransport(input, process.stdout);
|
|
15234
|
-
await new Promise((
|
|
15642
|
+
await new Promise((resolve24) => {
|
|
15235
15643
|
(0, import_stdio2.serveStdio)((ctx) => createPluneMcpServer(opts, ctx.era), {
|
|
15236
15644
|
transport,
|
|
15237
15645
|
onerror: (error) => {
|
|
@@ -15249,7 +15657,7 @@ async function serveMcpStdio(opts) {
|
|
|
15249
15657
|
const owned = transport.onclose;
|
|
15250
15658
|
transport.onclose = () => {
|
|
15251
15659
|
owned?.();
|
|
15252
|
-
|
|
15660
|
+
resolve24();
|
|
15253
15661
|
};
|
|
15254
15662
|
});
|
|
15255
15663
|
}
|
|
@@ -15261,7 +15669,7 @@ function unsupportedClaim(message2) {
|
|
|
15261
15669
|
const error = new import_server.UnsupportedProtocolVersionError({ supported: [...MODERN_REVISIONS], requested });
|
|
15262
15670
|
return { jsonrpc: "2.0", id: message2.id, error: { code: error.code, message: error.message, data: error.data } };
|
|
15263
15671
|
}
|
|
15264
|
-
var import_node_stream2, import_node_string_decoder2, import_server, import_zod7, import_stdio2, annotationsOf, listed, PARSE_ERROR_LINE, MODERN_REVISIONS;
|
|
15672
|
+
var import_node_stream2, import_node_string_decoder2, import_server, import_zod7, import_stdio2, annotationsOf, listed, readOnlyRefusal, PARSE_ERROR_LINE, MODERN_REVISIONS;
|
|
15265
15673
|
var init_server = __esm({
|
|
15266
15674
|
"src/mcp/server.ts"() {
|
|
15267
15675
|
"use strict";
|
|
@@ -15288,6 +15696,13 @@ var init_server = __esm({
|
|
|
15288
15696
|
outputSchema: import_zod7.z.toJSONSchema(tool2.output, { target: "draft-2020-12", io: "output" }),
|
|
15289
15697
|
annotations: annotationsOf(tool2)
|
|
15290
15698
|
});
|
|
15699
|
+
readOnlyRefusal = (name) => ({
|
|
15700
|
+
ok: false,
|
|
15701
|
+
error: {
|
|
15702
|
+
code: "read_only_token",
|
|
15703
|
+
message: `This connection has read-only access: ${name} writes. Ask the person to reconnect with read and write access.`
|
|
15704
|
+
}
|
|
15705
|
+
});
|
|
15291
15706
|
PARSE_ERROR_LINE = '{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}\n';
|
|
15292
15707
|
MODERN_REVISIONS = ["2026-07-28"];
|
|
15293
15708
|
}
|
|
@@ -15375,7 +15790,7 @@ var init_run3 = __esm({
|
|
|
15375
15790
|
now: () => import_node_perf_hooks2.performance.now(),
|
|
15376
15791
|
after(ms) {
|
|
15377
15792
|
let timer;
|
|
15378
|
-
const done = new Promise((
|
|
15793
|
+
const done = new Promise((resolve24) => timer = setTimeout(resolve24, ms));
|
|
15379
15794
|
return { done, cancel: () => clearTimeout(timer) };
|
|
15380
15795
|
}
|
|
15381
15796
|
};
|
|
@@ -17246,8 +17661,8 @@ var init_mcp_check = __esm({
|
|
|
17246
17661
|
|
|
17247
17662
|
// src/mcp-testing/exceptions-file.ts
|
|
17248
17663
|
function parseExceptionsFile(text6, name, today) {
|
|
17249
|
-
const lines = new
|
|
17250
|
-
const doc = (0,
|
|
17664
|
+
const lines = new import_yaml6.LineCounter();
|
|
17665
|
+
const doc = (0, import_yaml6.parseDocument)(text6, { lineCounter: lines });
|
|
17251
17666
|
const lineOf = (node) => lines.linePos(node?.range?.[0] ?? 0).line;
|
|
17252
17667
|
const problems = [];
|
|
17253
17668
|
const fail3 = (node, message2) => problems.push(`${name}:${lineOf(node)}: ${message2}`);
|
|
@@ -17257,19 +17672,19 @@ function parseExceptionsFile(text6, name, today) {
|
|
|
17257
17672
|
const expired = [];
|
|
17258
17673
|
const root = doc.contents;
|
|
17259
17674
|
if (problems.length === 0 && root !== null) {
|
|
17260
|
-
const list3 = (0,
|
|
17261
|
-
if (!(0,
|
|
17675
|
+
const list3 = (0, import_yaml6.isMap)(root) ? root.get("ignore", true) : void 0;
|
|
17676
|
+
if (!(0, import_yaml6.isMap)(root) || list3 !== void 0 && list3 !== null && !(0, import_yaml6.isSeq)(list3))
|
|
17262
17677
|
fail3(root, 'expected "ignore:" with a list of entries.');
|
|
17263
|
-
else if ((0,
|
|
17678
|
+
else if ((0, import_yaml6.isSeq)(list3)) {
|
|
17264
17679
|
for (const item of list3.items) {
|
|
17265
|
-
if (!(0,
|
|
17680
|
+
if (!(0, import_yaml6.isMap)(item)) {
|
|
17266
17681
|
fail3(item, "an entry needs rule and reason.");
|
|
17267
17682
|
continue;
|
|
17268
17683
|
}
|
|
17269
17684
|
const field = (key) => {
|
|
17270
|
-
const pair = item.items.find((p) => (0,
|
|
17685
|
+
const pair = item.items.find((p) => (0, import_yaml6.isScalar)(p.key) && p.key.value === key);
|
|
17271
17686
|
if (pair === void 0) return void 0;
|
|
17272
|
-
const plain = (0,
|
|
17687
|
+
const plain = (0, import_yaml6.isScalar)(pair.value) ? pair.value.value : pair.value;
|
|
17273
17688
|
if (plain !== null && plain !== void 0 && typeof plain !== "string")
|
|
17274
17689
|
fail3(
|
|
17275
17690
|
pair.key,
|
|
@@ -17316,12 +17731,12 @@ function parseExceptionsFile(text6, name, today) {
|
|
|
17316
17731
|
if (problems.length > 0) throw new ExceptionsFileError(problems.join("\n"));
|
|
17317
17732
|
return { active, expired };
|
|
17318
17733
|
}
|
|
17319
|
-
var
|
|
17734
|
+
var import_yaml6, ExceptionsFileError, DATE2, isDate2;
|
|
17320
17735
|
var init_exceptions_file = __esm({
|
|
17321
17736
|
"src/mcp-testing/exceptions-file.ts"() {
|
|
17322
17737
|
"use strict";
|
|
17323
17738
|
init_cjs_shims();
|
|
17324
|
-
|
|
17739
|
+
import_yaml6 = require("yaml");
|
|
17325
17740
|
init_failure_detail();
|
|
17326
17741
|
init_exit_codes();
|
|
17327
17742
|
ExceptionsFileError = class extends Error {
|
|
@@ -19258,12 +19673,12 @@ function hostFetch(target4, req, signal) {
|
|
|
19258
19673
|
for (const [n, v] of Object.entries(target4.headers)) if (!given.has(n.toLowerCase())) headers.push(n, v);
|
|
19259
19674
|
for (const [n, v] of req.headers) headers.push(n, v);
|
|
19260
19675
|
const send3 = url.protocol === "https:" ? import_node_https2.request : import_node_http2.request;
|
|
19261
|
-
return new Promise((
|
|
19676
|
+
return new Promise((resolve24, reject) => {
|
|
19262
19677
|
const r = send3(url, { method: req.method, headers, signal }, (res) => {
|
|
19263
19678
|
const pairs2 = [];
|
|
19264
19679
|
for (let i = 0; i + 1 < res.rawHeaders.length; i += 2) pairs2.push([res.rawHeaders[i], res.rawHeaders[i + 1]]);
|
|
19265
19680
|
const nobody = res.statusCode === 204 || res.statusCode === 304;
|
|
19266
|
-
|
|
19681
|
+
resolve24(
|
|
19267
19682
|
new Response(nobody ? null : import_node_stream3.Readable.toWeb(res), {
|
|
19268
19683
|
status: res.statusCode ?? 0,
|
|
19269
19684
|
headers: pairs2
|
|
@@ -23277,7 +23692,7 @@ var init_transport = __esm({
|
|
|
23277
23692
|
const open2 = () => {
|
|
23278
23693
|
let opened2 = () => {
|
|
23279
23694
|
};
|
|
23280
|
-
const ready2 = new Promise((
|
|
23695
|
+
const ready2 = new Promise((resolve24) => opened2 = resolve24);
|
|
23281
23696
|
const req = {
|
|
23282
23697
|
method: "GET",
|
|
23283
23698
|
headers: [
|
|
@@ -28064,11 +28479,11 @@ var init_security = __esm({
|
|
|
28064
28479
|
details
|
|
28065
28480
|
};
|
|
28066
28481
|
};
|
|
28067
|
-
reach = (host, p) => new Promise((
|
|
28482
|
+
reach = (host, p) => new Promise((resolve24) => {
|
|
28068
28483
|
const socket = (0, import_node_net.connect)({ host, port: p });
|
|
28069
28484
|
const done = (got2) => {
|
|
28070
28485
|
socket.destroy();
|
|
28071
|
-
|
|
28486
|
+
resolve24(got2);
|
|
28072
28487
|
};
|
|
28073
28488
|
socket.setTimeout(CONNECT_MS, () => done(`no answer in ${CONNECT_MS} ms`));
|
|
28074
28489
|
socket.once("connect", () => done("open"));
|
|
@@ -28949,7 +29364,7 @@ var init_tasks = __esm({
|
|
|
28949
29364
|
reason: "needs-input",
|
|
28950
29365
|
actual
|
|
28951
29366
|
});
|
|
28952
|
-
sleep3 = (ms) => new Promise((
|
|
29367
|
+
sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
28953
29368
|
results3 = (answers3) => answers3.flatMap((a) => a.kind === "result" ? [a.result] : []);
|
|
28954
29369
|
resultType2 = async (ctx) => {
|
|
28955
29370
|
const s = await ready(ctx);
|
|
@@ -29410,11 +29825,11 @@ function parseRegistration(value2, label2) {
|
|
|
29410
29825
|
return reg;
|
|
29411
29826
|
}
|
|
29412
29827
|
function readYaml(source) {
|
|
29413
|
-
const parsed4 = (0,
|
|
29828
|
+
const parsed4 = (0, import_yaml7.parseDocument)(source, { merge: false, schema: "core", uniqueKeys: true });
|
|
29414
29829
|
const first = parsed4.errors[0];
|
|
29415
29830
|
if (first !== void 0)
|
|
29416
29831
|
throw new UsageError(`--config: the file is not valid YAML (${first.code}).`);
|
|
29417
|
-
(0,
|
|
29832
|
+
(0, import_yaml7.visit)(parsed4, {
|
|
29418
29833
|
Alias() {
|
|
29419
29834
|
throw new UsageError("--config: YAML aliases and anchors are not allowed.");
|
|
29420
29835
|
},
|
|
@@ -29425,7 +29840,7 @@ function readYaml(source) {
|
|
|
29425
29840
|
throw new UsageError(`--config: a YAML tag (${node.tag.slice(0, 40)}) is not allowed.`);
|
|
29426
29841
|
},
|
|
29427
29842
|
Pair(_key, pair) {
|
|
29428
|
-
if ((0,
|
|
29843
|
+
if ((0, import_yaml7.isScalar)(pair.key) && pair.key.value === "<<")
|
|
29429
29844
|
throw new UsageError("--config: a YAML merge key (<<) is not allowed.");
|
|
29430
29845
|
}
|
|
29431
29846
|
});
|
|
@@ -29515,13 +29930,13 @@ function loadOauthConfig(path25) {
|
|
|
29515
29930
|
}
|
|
29516
29931
|
return parseOauthConfig(source, /\.ya?ml$/i.test(path25) ? "yaml" : "json");
|
|
29517
29932
|
}
|
|
29518
|
-
var import_node_fs16,
|
|
29933
|
+
var import_node_fs16, import_yaml7, TOP, REGISTRATION2, METHODS, MODES, SECRET_KEY2, ENV_NAME, isObject6, MAX_CONFIG_BYTES, tooLarge;
|
|
29519
29934
|
var init_auth_config = __esm({
|
|
29520
29935
|
"src/mcp-testing/conformance/checks/auth-config.ts"() {
|
|
29521
29936
|
"use strict";
|
|
29522
29937
|
init_cjs_shims();
|
|
29523
29938
|
import_node_fs16 = require("fs");
|
|
29524
|
-
|
|
29939
|
+
import_yaml7 = require("yaml");
|
|
29525
29940
|
init_options();
|
|
29526
29941
|
TOP = /* @__PURE__ */ new Set([
|
|
29527
29942
|
"protocolVersions",
|
|
@@ -31169,8 +31584,8 @@ var init_config = __esm({
|
|
|
31169
31584
|
|
|
31170
31585
|
// src/mcp-testing/scan/exceptions.ts
|
|
31171
31586
|
function parseScanExceptions(text6, name, today, opts = {}) {
|
|
31172
|
-
const lines = new
|
|
31173
|
-
const doc = (0,
|
|
31587
|
+
const lines = new import_yaml8.LineCounter();
|
|
31588
|
+
const doc = (0, import_yaml8.parseDocument)(text6, { lineCounter: lines });
|
|
31174
31589
|
const lineOf = (node) => lines.linePos(node?.range?.[0] ?? 0).line;
|
|
31175
31590
|
const problems = [];
|
|
31176
31591
|
const fail3 = (node, message2) => problems.push(`${name}:${lineOf(node)}: ${message2}`);
|
|
@@ -31180,25 +31595,25 @@ function parseScanExceptions(text6, name, today, opts = {}) {
|
|
|
31180
31595
|
const expired = [];
|
|
31181
31596
|
const root = doc.contents;
|
|
31182
31597
|
if (problems.length === 0 && root !== null) {
|
|
31183
|
-
const list3 = (0,
|
|
31184
|
-
if (!(0,
|
|
31598
|
+
const list3 = (0, import_yaml8.isMap)(root) ? root.get("ignore", true) : void 0;
|
|
31599
|
+
if (!(0, import_yaml8.isMap)(root) || list3 !== void 0 && list3 !== null && !(0, import_yaml8.isSeq)(list3))
|
|
31185
31600
|
fail3(root, 'expected "ignore:" with a list of entries.');
|
|
31186
|
-
else if (root.items.some((p) => !((0,
|
|
31601
|
+
else if (root.items.some((p) => !((0, import_yaml8.isScalar)(p.key) && p.key.value === "ignore")))
|
|
31187
31602
|
fail3(
|
|
31188
31603
|
root,
|
|
31189
|
-
`the only key of this file is "ignore:"; "${printable(String(root.items.map((p) => (0,
|
|
31604
|
+
`the only key of this file is "ignore:"; "${printable(String(root.items.map((p) => (0, import_yaml8.isScalar)(p.key) ? p.key.value : "?").find((k) => k !== "ignore")))}" is a typo or is not read.`
|
|
31190
31605
|
);
|
|
31191
|
-
else if ((0,
|
|
31606
|
+
else if ((0, import_yaml8.isSeq)(list3)) {
|
|
31192
31607
|
for (const item of list3.items) {
|
|
31193
|
-
if (!(0,
|
|
31608
|
+
if (!(0, import_yaml8.isMap)(item)) {
|
|
31194
31609
|
fail3(item, "an entry needs rule, scope, reason and expires.");
|
|
31195
31610
|
continue;
|
|
31196
31611
|
}
|
|
31197
|
-
const pair = (map, key) => map.items.find((p) => (0,
|
|
31612
|
+
const pair = (map, key) => map.items.find((p) => (0, import_yaml8.isScalar)(p.key) && p.key.value === key);
|
|
31198
31613
|
const str2 = (map, key) => {
|
|
31199
31614
|
const p = pair(map, key);
|
|
31200
31615
|
if (p === void 0) return void 0;
|
|
31201
|
-
const plain = (0,
|
|
31616
|
+
const plain = (0, import_yaml8.isScalar)(p.value) ? p.value.value : p.value;
|
|
31202
31617
|
if (plain !== null && plain !== void 0 && typeof plain !== "string") {
|
|
31203
31618
|
fail3(
|
|
31204
31619
|
p.key,
|
|
@@ -31213,7 +31628,7 @@ function parseScanExceptions(text6, name, today, opts = {}) {
|
|
|
31213
31628
|
let server2;
|
|
31214
31629
|
let path25;
|
|
31215
31630
|
const scope = pair(item, "scope");
|
|
31216
|
-
if (scope !== void 0 && (0,
|
|
31631
|
+
if (scope !== void 0 && (0, import_yaml8.isMap)(scope.value)) {
|
|
31217
31632
|
server2 = str2(scope.value, "server");
|
|
31218
31633
|
path25 = str2(scope.value, "path");
|
|
31219
31634
|
} else server2 = str2(item, "scope");
|
|
@@ -31265,12 +31680,12 @@ function covers2(e, f) {
|
|
|
31265
31680
|
if (e.rule !== f.rule || e.server !== f.target) return false;
|
|
31266
31681
|
return e.path === void 0 || f.path === e.path || f.path.startsWith(`${e.path}.`) || f.path.startsWith(`${e.path}[`) || f.path.startsWith(`${e.path}/`);
|
|
31267
31682
|
}
|
|
31268
|
-
var
|
|
31683
|
+
var import_yaml8, MAX_EXCEPTION_DAYS, DATE3, isDate3, days;
|
|
31269
31684
|
var init_exceptions2 = __esm({
|
|
31270
31685
|
"src/mcp-testing/scan/exceptions.ts"() {
|
|
31271
31686
|
"use strict";
|
|
31272
31687
|
init_cjs_shims();
|
|
31273
|
-
|
|
31688
|
+
import_yaml8 = require("yaml");
|
|
31274
31689
|
init_failure_detail();
|
|
31275
31690
|
init_exceptions_file();
|
|
31276
31691
|
MAX_EXCEPTION_DAYS = 180;
|
|
@@ -31970,9 +32385,9 @@ async function startPage() {
|
|
|
31970
32385
|
server2.headersTimeout = 5e3;
|
|
31971
32386
|
server2.requestTimeout = 5e3;
|
|
31972
32387
|
server2.keepAliveTimeout = 1e3;
|
|
31973
|
-
await new Promise((
|
|
32388
|
+
await new Promise((resolve24, reject) => {
|
|
31974
32389
|
server2.once("error", reject);
|
|
31975
|
-
server2.listen(0, "127.0.0.1",
|
|
32390
|
+
server2.listen(0, "127.0.0.1", resolve24);
|
|
31976
32391
|
});
|
|
31977
32392
|
const { address, port: port2 } = server2.address();
|
|
31978
32393
|
return {
|
|
@@ -31985,9 +32400,9 @@ async function startPage() {
|
|
|
31985
32400
|
requestTimeout: server2.requestTimeout,
|
|
31986
32401
|
keepAliveTimeout: server2.keepAliveTimeout
|
|
31987
32402
|
},
|
|
31988
|
-
close: () => new Promise((
|
|
32403
|
+
close: () => new Promise((resolve24) => {
|
|
31989
32404
|
server2.closeAllConnections();
|
|
31990
|
-
server2.close(() =>
|
|
32405
|
+
server2.close(() => resolve24());
|
|
31991
32406
|
})
|
|
31992
32407
|
};
|
|
31993
32408
|
}
|
|
@@ -34210,21 +34625,37 @@ async function defaultReadEvidence(dir) {
|
|
|
34210
34625
|
return { name: str(rec["name"]), passed: rec["passed"] === true, ...error !== "" ? { error } : {} };
|
|
34211
34626
|
});
|
|
34212
34627
|
}
|
|
34213
|
-
function casesFromDesign(report) {
|
|
34628
|
+
function casesFromDesign(report, notes) {
|
|
34214
34629
|
const list3 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
|
|
34215
|
-
|
|
34630
|
+
const refused = /* @__PURE__ */ new Map();
|
|
34631
|
+
const cases = list3.map((raw) => {
|
|
34216
34632
|
const c = asRecord2(raw);
|
|
34217
34633
|
const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
|
|
34634
|
+
const title = str(c["title"], "untitled case");
|
|
34635
|
+
const link = own2(c, "traceUrl") ?? void 0;
|
|
34636
|
+
const said3 = [];
|
|
34637
|
+
const traceUrl = traceUrlOf(link, title, said3);
|
|
34638
|
+
if (said3.length > 0) {
|
|
34639
|
+
const key = typeof link === "string" ? link.trim() : typeof link;
|
|
34640
|
+
const before = refused.get(key) ?? 0;
|
|
34641
|
+
if (before === 0) notes.push(...said3);
|
|
34642
|
+
refused.set(key, before + 1);
|
|
34643
|
+
}
|
|
34218
34644
|
return {
|
|
34219
34645
|
stableId: str(c["stableId"]),
|
|
34220
|
-
title
|
|
34646
|
+
title,
|
|
34221
34647
|
execution: c["execution"] === "manual" ? "manual" : "auto",
|
|
34222
34648
|
steps: steps.length > 0 ? steps : ["(no steps recorded)"],
|
|
34223
34649
|
expected: str(c["expected"], "(no expected result recorded)"),
|
|
34224
34650
|
...typeof c["technique"] === "string" ? { technique: c["technique"] } : {},
|
|
34225
|
-
...typeof c["priority"] === "string" ? { priority: c["priority"] } : {}
|
|
34651
|
+
...typeof c["priority"] === "string" ? { priority: c["priority"] } : {},
|
|
34652
|
+
...traceUrl !== void 0 ? { traceUrl } : {}
|
|
34226
34653
|
};
|
|
34227
34654
|
});
|
|
34655
|
+
for (const times of refused.values()) {
|
|
34656
|
+
if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
|
|
34657
|
+
}
|
|
34658
|
+
return cases;
|
|
34228
34659
|
}
|
|
34229
34660
|
function casesFromApi(report, verdicts) {
|
|
34230
34661
|
const list3 = Array.isArray(report["cases"]) ? report["cases"] : [];
|
|
@@ -34271,9 +34702,9 @@ async function readCairnRun(dir, deps = {}) {
|
|
|
34271
34702
|
}
|
|
34272
34703
|
cases = casesFromApi(report, verdicts);
|
|
34273
34704
|
} else if (mode === "mcp") {
|
|
34274
|
-
cases = own2(report, "cases") === void 0 && Array.isArray(own2(report, "testCases")) ? casesFromDesign(report) : await casesFromMcp(dir, report);
|
|
34705
|
+
cases = own2(report, "cases") === void 0 && Array.isArray(own2(report, "testCases")) ? casesFromDesign(report, deps.notes ?? []) : await casesFromMcp(dir, report);
|
|
34275
34706
|
} else {
|
|
34276
|
-
cases = casesFromDesign(report);
|
|
34707
|
+
cases = casesFromDesign(report, deps.notes ?? []);
|
|
34277
34708
|
}
|
|
34278
34709
|
const tokens2 = own2(asRecord2(own2(report, "cost")), "totalTokens");
|
|
34279
34710
|
return {
|
|
@@ -34359,6 +34790,7 @@ var init_cairn_artifact = __esm({
|
|
|
34359
34790
|
init_cjs_shims();
|
|
34360
34791
|
fs18 = __toESM(require("fs/promises"), 1);
|
|
34361
34792
|
path22 = __toESM(require("path"), 1);
|
|
34793
|
+
init_trace_url();
|
|
34362
34794
|
init_config();
|
|
34363
34795
|
init_errors2();
|
|
34364
34796
|
SUPPORTED_ARTIFACT_VERSION = 1;
|
|
@@ -34581,7 +35013,8 @@ async function handleIngest(deps) {
|
|
|
34581
35013
|
const token2 = (deps.loadToken ?? loadToken)();
|
|
34582
35014
|
if (token2 === null) throw new IngestNotLoggedInError();
|
|
34583
35015
|
const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
|
|
34584
|
-
const
|
|
35016
|
+
const notes = [];
|
|
35017
|
+
const payload2 = await readCairnRun(dir, { notes });
|
|
34585
35018
|
const session2 = await readCairnSessionFiles(dir).catch(() => void 0);
|
|
34586
35019
|
for (const c of payload2.cases) {
|
|
34587
35020
|
const screencasts = session2?.screencasts.get(c.stableId);
|
|
@@ -34598,6 +35031,8 @@ async function handleIngest(deps) {
|
|
|
34598
35031
|
() => ["session files not uploaded (an unexpected error) \u2014 the run is recorded"]
|
|
34599
35032
|
);
|
|
34600
35033
|
if (files.length > 0) result2.files = files;
|
|
35034
|
+
if (sent.repeat) result2.repeat = true;
|
|
35035
|
+
if (notes.length > 0) result2.notes = notes;
|
|
34601
35036
|
await job.finish({ ok: true });
|
|
34602
35037
|
if (job.problem !== void 0) result2.jobProblem = job.problem;
|
|
34603
35038
|
return result2;
|
|
@@ -34645,12 +35080,23 @@ function reportIngestFailure(err, write) {
|
|
|
34645
35080
|
return null;
|
|
34646
35081
|
}
|
|
34647
35082
|
function formatIngestResult(r) {
|
|
35083
|
+
const files = (r.files ?? []).map((line, i) => i === 0 ? ` ${line}` : ` ${line}`);
|
|
35084
|
+
if (r.repeat === true) {
|
|
35085
|
+
return `${[
|
|
35086
|
+
...r.notes ?? [],
|
|
35087
|
+
`This Cairn run was already ingested \u2192 ${r.runId}`,
|
|
35088
|
+
" nothing new was proposed or attached; a run with a new run id is ingested as new",
|
|
35089
|
+
...files
|
|
35090
|
+
].join("\n")}
|
|
35091
|
+
`;
|
|
35092
|
+
}
|
|
34648
35093
|
const lines = [
|
|
35094
|
+
...r.notes ?? [],
|
|
34649
35095
|
`Ingested Cairn run \u2192 ${r.runId}`,
|
|
34650
35096
|
` ${r.linked} result(s) attached to existing cases`,
|
|
34651
35097
|
` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
|
|
34652
35098
|
` ${r.skipped} skipped (already queued, already rejected, repeated, or never executed)`,
|
|
34653
|
-
...
|
|
35099
|
+
...files
|
|
34654
35100
|
];
|
|
34655
35101
|
return `${lines.join("\n")}
|
|
34656
35102
|
`;
|
|
@@ -34712,7 +35158,7 @@ __export(requirements_import_exports, {
|
|
|
34712
35158
|
cut: () => cut4,
|
|
34713
35159
|
flat: () => flat2,
|
|
34714
35160
|
formatDiscover: () => formatDiscover,
|
|
34715
|
-
formatReport: () =>
|
|
35161
|
+
formatReport: () => formatReport3,
|
|
34716
35162
|
handleRequirementsImport: () => handleRequirementsImport,
|
|
34717
35163
|
parseMap: () => parseMap,
|
|
34718
35164
|
parseTableSpec: () => parseTableSpec,
|
|
@@ -34907,7 +35353,7 @@ function formatDiscover(file, r) {
|
|
|
34907
35353
|
);
|
|
34908
35354
|
return out.join("\n") + "\n";
|
|
34909
35355
|
}
|
|
34910
|
-
function
|
|
35356
|
+
function formatReport3(report) {
|
|
34911
35357
|
const s = report.summary;
|
|
34912
35358
|
const out = [`create ${s.create} \xB7 update ${s.update} \xB7 unchanged ${s.unchanged} \xB7 skip ${s.skip}`];
|
|
34913
35359
|
if (report.emptyTemplate === true) {
|
|
@@ -35347,13 +35793,13 @@ async function handleAutomate(deps) {
|
|
|
35347
35793
|
const viaShell = process.platform === "win32" && /\.(cmd|bat)$/i.test(executable);
|
|
35348
35794
|
const quoted = (s) => `"${s.replace(/"/g, '""')}"`;
|
|
35349
35795
|
const spawnImpl = deps.spawnImpl ?? import_node_child_process5.spawn;
|
|
35350
|
-
const runCairn = (args, capture) => new Promise((
|
|
35796
|
+
const runCairn = (args, capture) => new Promise((resolve24) => {
|
|
35351
35797
|
const opts = { cwd: repo, env: childEnv, stdio: ["ignore", capture ? "pipe" : 2, 2] };
|
|
35352
35798
|
const child = isScript ? spawnImpl(process.execPath, [executable, ...args], opts) : viaShell ? spawnImpl([executable, ...args].map(quoted).join(" "), { ...opts, shell: true }) : spawnImpl(executable, args, opts);
|
|
35353
35799
|
let out = "";
|
|
35354
35800
|
child.stdout?.on("data", (chunk2) => void (out += chunk2.toString("utf8")));
|
|
35355
|
-
child.on("close", (exitCode2) =>
|
|
35356
|
-
child.on("error", () =>
|
|
35801
|
+
child.on("close", (exitCode2) => resolve24({ code: exitCode2 ?? 1, out }));
|
|
35802
|
+
child.on("error", () => resolve24({ code: -1, out }));
|
|
35357
35803
|
});
|
|
35358
35804
|
const { code } = await runCairn(["automate", "--run", runDir, ...deps.cairnArgs ?? []], false);
|
|
35359
35805
|
if (code === -1) throw new CairnMissingError(command);
|
|
@@ -36187,23 +36633,48 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
|
|
|
36187
36633
|
}
|
|
36188
36634
|
}
|
|
36189
36635
|
);
|
|
36190
|
-
program.command("init").description("Scaffold plune.yaml (interactive), an example dataset, and .env.example").option("--force", "Overwrite existing files instead of skipping them", false).option("--yes", "Non-interactive: scaffold defaults without prompts (for CI)", false).
|
|
36191
|
-
|
|
36192
|
-
|
|
36193
|
-
|
|
36194
|
-
|
|
36195
|
-
|
|
36196
|
-
|
|
36197
|
-
|
|
36198
|
-
|
|
36199
|
-
|
|
36200
|
-
|
|
36201
|
-
process.
|
|
36636
|
+
program.command("init").description("Scaffold plune.yaml (interactive), an example dataset, and .env.example").option("--force", "Overwrite existing files instead of skipping them", false).option("--yes", "Non-interactive: scaffold defaults without prompts (for CI)", false).option(
|
|
36637
|
+
"--from-openai-eval <eval.json>",
|
|
36638
|
+
"Build plune.yaml from an exported OpenAI eval (the answer of GET /v1/evals/{eval_id}) and print what each grader became"
|
|
36639
|
+
).option("--run <run.json>", "With --from-openai-eval: one run of that eval, for the prompt and the model").option("--data <rows.jsonl>", 'With --from-openai-eval: the test data, one {"item": {...}} per line').action(
|
|
36640
|
+
async (options, command) => {
|
|
36641
|
+
const verbose = command.optsWithGlobals().verbose === true;
|
|
36642
|
+
const [{ initCommand: initCommand2, initFromOpenAiEval: initFromOpenAiEval2 }, { NonTtyError: NonTtyError2 }] = await Promise.all([
|
|
36643
|
+
Promise.resolve().then(() => (init_init(), init_exports)),
|
|
36644
|
+
Promise.resolve().then(() => (init_errors(), errors_exports))
|
|
36645
|
+
]);
|
|
36646
|
+
if (options.fromOpenaiEval === void 0 && (options.run !== void 0 || options.data !== void 0)) {
|
|
36647
|
+
process.stderr.write("--run and --data need --from-openai-eval <eval.json>\n");
|
|
36648
|
+
process.exit(2);
|
|
36202
36649
|
return;
|
|
36203
36650
|
}
|
|
36204
|
-
|
|
36651
|
+
try {
|
|
36652
|
+
if (options.fromOpenaiEval !== void 0) {
|
|
36653
|
+
await initFromOpenAiEval2({
|
|
36654
|
+
cwd: process.cwd(),
|
|
36655
|
+
force: options.force,
|
|
36656
|
+
evalPath: options.fromOpenaiEval,
|
|
36657
|
+
...options.run !== void 0 ? { runPath: options.run } : {},
|
|
36658
|
+
...options.data !== void 0 ? { dataPath: options.data } : {}
|
|
36659
|
+
});
|
|
36660
|
+
return;
|
|
36661
|
+
}
|
|
36662
|
+
await initCommand2({ cwd: process.cwd(), force: options.force, yes: options.yes });
|
|
36663
|
+
} catch (err) {
|
|
36664
|
+
if (err instanceof Error && err.name === "OpenAiEvalImportError") {
|
|
36665
|
+
process.stderr.write(err.message + "\n");
|
|
36666
|
+
process.exit(2);
|
|
36667
|
+
return;
|
|
36668
|
+
}
|
|
36669
|
+
if (err instanceof NonTtyError2) {
|
|
36670
|
+
process.stderr.write(err.message + "\n");
|
|
36671
|
+
process.exit(1);
|
|
36672
|
+
return;
|
|
36673
|
+
}
|
|
36674
|
+
failUnexpected(err, verbose);
|
|
36675
|
+
}
|
|
36205
36676
|
}
|
|
36206
|
-
|
|
36677
|
+
);
|
|
36207
36678
|
program.command("login").description("Save your Plune API token (get one in the dashboard: Account \u2192 API tokens)").option("--token <token>", "API token (omit to paste it / pipe it via stdin)").option(
|
|
36208
36679
|
"--skip-verify",
|
|
36209
36680
|
"Save without checking the token against the API (offline setup)",
|
|
@@ -36512,13 +36983,13 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
|
|
|
36512
36983
|
"Send a Markdown document of test cases back to Plune (POST /v1/test-cases/markdown)"
|
|
36513
36984
|
).option("--dry-run", "Show what would change and write nothing", false).action(async (file, options, command) => {
|
|
36514
36985
|
const verbose = command.optsWithGlobals().verbose === true;
|
|
36515
|
-
const { handlePush: handlePush2, formatReport:
|
|
36986
|
+
const { handlePush: handlePush2, formatReport: formatReport4, reportCasesFailure: reportCasesFailure2 } = await Promise.resolve().then(() => (init_cases(), cases_exports));
|
|
36516
36987
|
try {
|
|
36517
36988
|
const report = await handlePush2({
|
|
36518
36989
|
...file !== void 0 ? { file } : {},
|
|
36519
36990
|
dryRun: options.dryRun
|
|
36520
36991
|
});
|
|
36521
|
-
process.stdout.write(
|
|
36992
|
+
process.stdout.write(formatReport4(report));
|
|
36522
36993
|
if (report.refused.length > 0) process.exitCode = 4;
|
|
36523
36994
|
} catch (err) {
|
|
36524
36995
|
const code = reportCasesFailure2(err, (s) => process.stderr.write(s));
|
|
@@ -36539,13 +37010,13 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
|
|
|
36539
37010
|
(value2, previous = []) => [...previous, value2]
|
|
36540
37011
|
).option("--key-column <header>", "Table: the column holding the requirement key").option("--title-column <header>", "Table: the column holding the title").option("--text-column <header>", "Table: one text column; the title is its first line (not with --title-column)").option("--description-column <header>", "Table: the description column").option("--priority-column <header>", "Table: the priority column").option("--category-column <header>", "Table: the category column").option("--type-column <header>", "Table: the type column").option("--status-column <header>", "Table: the status column (draft, active or done)").option("--criteria-column <header>", "Table: the acceptance criteria column").option("--map-priority <pairs>", 'Rename priority values, e.g. "Critical=Must-have,High=Should-have"').option("--map-category <pairs>", 'Table: rename category values, e.g. "Quality=non-functional"').option("--sections <heading|n>", "Read the section with this heading or number (from the list)").option("--unit <unit>", "Sections: bullets or subheadings (default: sub-headings if it has any)").option("--key-prefix <text>", "Sections: text a bullet or sub-heading starts with that carries its key").option("--priority-from <source>", "Sections: subheading \u2014 bullets take their sub-heading as priority").option("--type <type>", "What a row without a type becomes: user_story, feature or epic").option("--project <id>", "The project (default: PLUNE_PROJECT, else the only project of the account)").option("--yes", "Write it. Without it the import is a dry run", false).option("--json", "Print the platform\u2019s answer as JSON", false).action(async (file, options, command) => {
|
|
36541
37012
|
const verbose = command.optsWithGlobals().verbose === true;
|
|
36542
|
-
const { handleRequirementsImport: handleRequirementsImport2, formatDiscover: formatDiscover2, formatReport:
|
|
37013
|
+
const { handleRequirementsImport: handleRequirementsImport2, formatDiscover: formatDiscover2, formatReport: formatReport4, reportRequirementsImportFailure: reportRequirementsImportFailure2 } = await Promise.resolve().then(() => (init_requirements_import(), requirements_import_exports));
|
|
36543
37014
|
try {
|
|
36544
37015
|
const res = await handleRequirementsImport2({ file, ...options });
|
|
36545
37016
|
if (options.json === true) {
|
|
36546
37017
|
process.stdout.write(JSON.stringify(res.step === "discover" ? res.result : res.report, null, 2) + "\n");
|
|
36547
37018
|
} else {
|
|
36548
|
-
process.stdout.write(res.step === "discover" ? formatDiscover2(file, res.result) :
|
|
37019
|
+
process.stdout.write(res.step === "discover" ? formatDiscover2(file, res.result) : formatReport4(res.report));
|
|
36549
37020
|
}
|
|
36550
37021
|
} catch (err) {
|
|
36551
37022
|
const code = reportRequirementsImportFailure2(err, (s) => process.stderr.write(s));
|