@plune-ai/cli 0.39.3 → 0.39.5

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/dist/cli.cjs CHANGED
@@ -6878,7 +6878,7 @@ var init_catalog = __esm({
6878
6878
  });
6879
6879
 
6880
6880
  // src/mcp-testing/conformance/profile.ts
6881
- var import_node_crypto2, PROFILE_2026_11_2, PROFILE_2026_11_3, PROFILE, PROFILES, profileOf, manifestDigest;
6881
+ var import_node_crypto2, PROFILE_2026_11_2, PROFILE_2026_11_3, PROFILE_2026_11_4, PROFILE, PROFILES, profileOf, manifestDigest;
6882
6882
  var init_profile = __esm({
6883
6883
  "src/mcp-testing/conformance/profile.ts"() {
6884
6884
  "use strict";
@@ -6944,8 +6944,60 @@ var init_profile = __esm({
6944
6944
  "http-origin-invalid-403"
6945
6945
  ]
6946
6946
  };
6947
- PROFILE = PROFILE_2026_11_3;
6948
- PROFILES = [PROFILE_2026_11_2, PROFILE_2026_11_3];
6947
+ PROFILE_2026_11_4 = {
6948
+ id: "plune-mcp-conformance",
6949
+ version: "2026-11.4",
6950
+ checks: [
6951
+ "life-initialize-result",
6952
+ "life-version-negotiation",
6953
+ "life-capabilities-declared-served",
6954
+ "life-capabilities-served-declared",
6955
+ "life-ping-empty-result",
6956
+ "base-jsonrpc-parse-error",
6957
+ "base-unknown-method-error",
6958
+ "base-response-id-matches",
6959
+ "tools-list-shape",
6960
+ "tools-input-schema-valid",
6961
+ "tools-output-schema-valid",
6962
+ "tools-structured-conformant",
6963
+ "resources-list-shape",
6964
+ "resources-read-listed",
6965
+ "resources-templates-shape",
6966
+ "prompts-list-shape",
6967
+ "stdio-stdout-clean",
6968
+ "http-notification-202",
6969
+ "http-request-content-type",
6970
+ "http-response-utf8",
6971
+ "http-single-endpoint",
6972
+ "http-get-stream-or-405",
6973
+ "http-session-id-visible-ascii",
6974
+ "http-protocol-version-header-invalid-400",
6975
+ "http-concurrent-posts-matched",
6976
+ "http-sse-event-ids-unique",
6977
+ "http-sse-no-server-requests",
6978
+ "http-close-cancels",
6979
+ "http-session-terminated-404",
6980
+ "http-sse-no-broadcast",
6981
+ "http-origin-invalid-403",
6982
+ "mod-discover-result",
6983
+ "mod-unsupported-version",
6984
+ "mod-removed-methods",
6985
+ "mod-stateless-no-prior-context",
6986
+ "mod-list-stable-across-connections",
6987
+ "mod-resource-not-found",
6988
+ "mod-resource-no-empty-contents",
6989
+ "mod-cache-hints-coverage",
6990
+ "mod-cache-ttl-valid",
6991
+ "mod-cache-scope-valid",
6992
+ "mod-sub-ack-first",
6993
+ "mod-result-type-present",
6994
+ "mod-error-code-range",
6995
+ "mod-logs-need-log-level",
6996
+ "mod-wire-schema-valid"
6997
+ ]
6998
+ };
6999
+ PROFILE = PROFILE_2026_11_4;
7000
+ PROFILES = [PROFILE_2026_11_2, PROFILE_2026_11_3, PROFILE_2026_11_4];
6949
7001
  profileOf = (version2) => PROFILES.find((p) => p.version === version2);
6950
7002
  manifestDigest = (ids) => (0, import_node_crypto2.createHash)("sha256").update([...ids].sort().join("\n")).digest("hex");
6951
7003
  }
@@ -7944,121 +7996,463 @@ var init_helpers = __esm({
7944
7996
  }
7945
7997
  });
7946
7998
 
7947
- // src/reporters/matrix.ts
7948
- function median(xs) {
7949
- if (xs.length === 0) return void 0;
7950
- const s = [...xs].sort((a, b) => a - b);
7951
- const mid = s.length >> 1;
7952
- return s.length % 2 === 1 ? s[mid] : (s[mid - 1] + s[mid]) / 2;
7999
+ // src/diff/stats.ts
8000
+ function wilson(passed2, total) {
8001
+ const share2 = passed2 / total;
8002
+ const z22 = Z * Z;
8003
+ const denom = 1 + z22 / total;
8004
+ const centre = (share2 + z22 / (2 * total)) / denom;
8005
+ const half = Z * Math.sqrt(share2 * (1 - share2) / total + z22 / (4 * total * total)) / denom;
8006
+ return { share: share2, lower: Math.max(0, centre - half), upper: Math.min(1, centre + half) };
7953
8007
  }
7954
- function cellOf(ev) {
7955
- let passed2 = 0;
7956
- let total = 0;
7957
- let cost2 = 0;
7958
- const latencies = [];
7959
- const states = /* @__PURE__ */ new Set();
7960
- for (const row of ev.rows) {
7961
- const status2 = rowStatus(row);
7962
- states.add(
7963
- status2 === "passed" ? "pass" : status2 === "failed" ? "fail" : status2 === "errored" ? "error" : "unmeasured"
7964
- );
7965
- cost2 += row.usage?.cost_usd ?? 0;
7966
- const a = row.attempts;
7967
- if (a !== void 0 && a.results.length > 0) {
7968
- passed2 += a.passed;
7969
- total += a.runs;
7970
- for (const r of a.results) if (r.latency_ms !== void 0) latencies.push(r.latency_ms);
7971
- } else {
7972
- passed2 += status2 === "passed" ? 1 : 0;
7973
- total += 1;
7974
- if (row.latency_ms !== void 0) latencies.push(row.latency_ms);
7975
- }
7976
- }
7977
- const state2 = STATE_ORDER.find((s) => states.has(s)) ?? "pass";
7978
- const latency = median(latencies);
8008
+ function newcombeDifference(current, base) {
8009
+ const a = wilson(current.passed, current.total);
8010
+ const b = wilson(base.passed, base.total);
8011
+ const diff2 = a.share - b.share;
7979
8012
  return {
7980
- id: ev.id,
7981
- state: state2,
7982
- passed: passed2,
7983
- total,
7984
- cost_usd: cost2,
7985
- ...latency !== void 0 ? { latency_ms: latency } : {}
8013
+ diff: diff2,
8014
+ lower: diff2 - Math.sqrt((a.share - a.lower) ** 2 + (b.upper - b.share) ** 2),
8015
+ upper: diff2 + Math.sqrt((a.upper - a.share) ** 2 + (b.share - b.lower) ** 2)
7986
8016
  };
7987
8017
  }
7988
- function buildMatrix(result2) {
7989
- if (!result2.evals.some((e) => e.provider !== void 0)) return void 0;
7990
- const models = [];
7991
- const rows = /* @__PURE__ */ new Map();
7992
- const cells = [];
7993
- for (const ev of result2.evals) {
7994
- const p = ev.provider ?? { type: "", model: "" };
7995
- let col = models.findIndex((m) => m.model === p.model);
7996
- if (col < 0) col = models.push({ type: p.type, model: p.model }) - 1;
7997
- const id2 = baseEvalId(ev);
7998
- if (!rows.has(id2)) rows.set(id2, []);
7999
- cells.push({ eval: id2, model: col, cell: cellOf(ev) });
8000
- }
8001
- for (const c of cells) {
8002
- const row = rows.get(c.eval);
8003
- while (row.length < models.length) row.push(null);
8004
- row[c.model] = c.cell;
8005
- }
8018
+ function fmtPp(share2, directional) {
8019
+ const rounded = pp(share2);
8020
+ if (rounded === 0 && share2 !== 0 && directional)
8021
+ return signed(String(Number((share2 * 100).toPrecision(2))));
8022
+ return signed(String(rounded === 0 ? 0 : rounded));
8023
+ }
8024
+ function wordFor(lower, upper) {
8025
+ return upper < -EPS ? "worse" : lower > EPS ? "better" : "no-difference";
8026
+ }
8027
+ function compareProportions(current, base, min = MIN_ATTEMPTS) {
8028
+ const floor = Number.isFinite(min) ? Math.max(1, min) : MIN_ATTEMPTS;
8029
+ const sides = { current: current.total, base: base.total, min: floor };
8030
+ if (!valid(current) || !valid(base))
8031
+ return {
8032
+ word: "too-few",
8033
+ ...sides,
8034
+ reason: "the attempt counts are not whole numbers inside 0 and the total, so no share was computed"
8035
+ };
8036
+ const [uc, ub] = [current.unmeasured ?? 0, base.unmeasured ?? 0];
8037
+ const dropped = uc + ub > 0 ? `; not measured and left out: current ${uc}, baseline ${ub} attempt(s)` : "";
8038
+ if (current.total < floor || base.total < floor)
8039
+ return {
8040
+ word: "too-few",
8041
+ ...sides,
8042
+ reason: `at least ${floor} attempts with a verdict are needed on each side (current ${current.total}, baseline ${base.total})${dropped}`
8043
+ };
8044
+ const r = newcombeDifference(current, base);
8045
+ const [diffPp, lowerPp, upperPp] = [pp(r.diff), pp(r.lower), pp(r.upper)];
8046
+ const word = wordFor(r.lower, r.upper);
8047
+ const directional = word !== "no-difference";
8006
8048
  return {
8007
- models,
8008
- rows: [...rows].map(([id2, cs]) => ({
8009
- eval: id2,
8010
- cells: Array.from({ length: models.length }, (_, i) => cs[i] ?? null)
8011
- }))
8049
+ word,
8050
+ ...sides,
8051
+ diffPp,
8052
+ lowerPp,
8053
+ upperPp,
8054
+ reason: `${current.passed}/${current.total} against ${base.passed}/${base.total}: ${fmtPp(r.diff, false)} pp, 95% interval ${fmtPp(r.lower, directional)} to ${fmtPp(r.upper, directional)} pp${dropped}`
8012
8055
  };
8013
8056
  }
8014
- function formatLatency(ms) {
8015
- return ms < 1e3 ? `${Math.round(ms)}ms` : `${(ms / 1e3).toFixed(1)}s`;
8057
+ var Z, MIN_ATTEMPTS, pp, signed, EPS, valid;
8058
+ var init_stats = __esm({
8059
+ "src/diff/stats.ts"() {
8060
+ "use strict";
8061
+ init_cjs_shims();
8062
+ Z = 1.959963984540054;
8063
+ MIN_ATTEMPTS = 5;
8064
+ pp = (n) => Math.round(n * 1e4) / 100;
8065
+ signed = (s) => /^[1-9.]|^0\./.test(s) ? `+${s}` : s;
8066
+ EPS = 1e-12;
8067
+ valid = (x) => Number.isInteger(x.passed) && Number.isInteger(x.total) && x.passed >= 0 && x.passed <= x.total;
8068
+ }
8069
+ });
8070
+
8071
+ // src/reporters/diff.ts
8072
+ var diff_exports = {};
8073
+ __export(diff_exports, {
8074
+ COMMENT_BUDGET: () => COMMENT_BUDGET,
8075
+ NOT_MEASURED: () => NOT_MEASURED,
8076
+ STICKY_MARKER: () => STICKY_MARKER,
8077
+ renderDiff: () => renderDiff,
8078
+ renderDiffMarkdown: () => renderDiffMarkdown2
8079
+ });
8080
+ function headline(d) {
8081
+ const gates = d.gates?.gates ?? [];
8082
+ const named2 = (state2) => gates.filter((g) => g.state === state2).map((g) => g.gate);
8083
+ const regression = gates.find((g) => g.gate === "regression");
8084
+ if (d.summary.hasRegression && regression?.state !== "waived")
8085
+ return { mark: "\u274C", text: `${d.summary.regressions} regression(s)` };
8086
+ if (named2("failed").length > 0) return { mark: "\u274C", text: `gate failed: ${named2("failed").join(", ")}` };
8087
+ if (d.summary.unmeasured > 0) return { mark: "\u26A0\uFE0F", text: `${d.summary.unmeasured} eval(s) not measured` };
8088
+ if (named2("unmeasured").length > 0) return { mark: "\u26A0\uFE0F", text: `not measured: ${named2("unmeasured").join(", ")}` };
8089
+ if (named2("waived").length > 0) return { mark: "\u2705", text: `gates passed (${named2("waived").length} waived)` };
8090
+ return null;
8016
8091
  }
8017
- function cellText(cell3, dry = false) {
8018
- if (cell3 === null) return EMPTY_CELL;
8019
- const cost2 = `$${cell3.cost_usd.toFixed(4)}`;
8020
- if (dry) return cost2;
8021
- const head = cell3.state === "unmeasured" ? CELL_LABEL.unmeasured : `${CELL_LABEL[cell3.state]} ${cell3.passed}/${cell3.total}`;
8022
- return [head, cost2, ...cell3.latency_ms !== void 0 ? [formatLatency(cell3.latency_ms)] : []].join(" \xB7 ");
8092
+ function amount(gate2, n) {
8093
+ if (n === void 0) return "\u2014";
8094
+ if (gate2 === "pass-rate") return `${n} pp`;
8095
+ if (gate2 === "cost") return `$${n}`;
8096
+ if (gate2 === "cost-increase") return `${n}%`;
8097
+ return String(n);
8023
8098
  }
8024
- function matrixMarkdown(m, dry = false) {
8099
+ function waiverLines(d, quote, text6) {
8100
+ const { applied, expired, unused } = d.gates.waivers;
8025
8101
  return [
8026
- `| Eval | ${m.models.map((x) => mdCell(x.model)).join(" | ")} |`,
8027
- `| --- | ${m.models.map(() => "---").join(" | ")} |`,
8028
- ...m.rows.map((r) => `| ${mdCell(r.eval)} | ${r.cells.map((c) => cellText(c, dry)).join(" | ")} |`)
8102
+ applied.map((w) => `${target2(w, quote)} until ${w.expires}: ${text6(w.reason)}`),
8103
+ expired.map((w) => `${target2(w, quote)} on ${w.expires}: ${text6(w.reason)}`),
8104
+ unused.map((w) => `${target2(w, quote)} until ${w.expires}: ${text6(w.reason)}`)
8029
8105
  ];
8030
8106
  }
8031
- function matrixConsole(m, dry = false) {
8032
- const table = [["Eval", ...m.models.map((x) => safeLine(x.model))], ...m.rows.map((r) => [safeLine(r.eval), ...r.cells.map((c) => cellText(c, dry))])];
8033
- const widths = table[0].map((_, i) => Math.max(...table.map((row) => [...row[i]].length)));
8034
- return table.map(
8035
- (row) => row.map((c, i) => c + " ".repeat(widths[i] - [...c].length)).join(" ").trimEnd()
8036
- );
8107
+ function gatesMarkdown(d) {
8108
+ if (d.gates === void 0) return [];
8109
+ const out = ["### Gates", "", "| Gate | State | Value | Threshold | Reason |", "| --- | --- | --- | --- | --- |"];
8110
+ for (const g of d.gates.gates) {
8111
+ const s = GATE_STATE[g.state];
8112
+ out.push(
8113
+ `| ${g.gate} | ${s.mark} ${s.text} | ${amount(g.gate, g.value)} | ${amount(g.gate, g.threshold)} | ${cell2(g.reason)} |`
8114
+ );
8115
+ }
8116
+ out.push("");
8117
+ const details = d.gates.gates.flatMap((g) => (g.details ?? []).map((x) => `- ${g.gate}: ${x}`));
8118
+ const [applied, expired, unused] = waiverLines(d, (t) => `\`${t}\``, oneLine);
8119
+ const lines = [
8120
+ ...details,
8121
+ ...applied.map((l) => `- Waived: ${l}`),
8122
+ ...expired.map((l) => `- Expired: ${l}`),
8123
+ ...unused.map((l) => `- Unused: ${l}`)
8124
+ ];
8125
+ if (lines.length > 0) out.push(...lines, "");
8126
+ return out;
8037
8127
  }
8038
- var STATE_ORDER, CELL_LABEL, EMPTY_CELL;
8039
- var init_matrix = __esm({
8040
- "src/reporters/matrix.ts"() {
8041
- "use strict";
8042
- init_cjs_shims();
8043
- init_results();
8044
- init_helpers();
8045
- STATE_ORDER = ["error", "fail", "unmeasured", "pass"];
8046
- CELL_LABEL = {
8047
- pass: "PASS",
8048
- fail: "FAIL",
8049
- error: "ERROR",
8050
- unmeasured: "NOT MEASURED"
8051
- };
8052
- EMPTY_CELL = "\u2014";
8128
+ function gatesConsole(d) {
8129
+ if (d.gates === void 0) return [];
8130
+ const out = ["Gates:"];
8131
+ for (const g of d.gates.gates) {
8132
+ const value2 = g.value === void 0 ? "" : `: ${amount(g.gate, g.value)}`;
8133
+ const limit3 = g.threshold === void 0 ? "" : ` (limit ${amount(g.gate, g.threshold)})`;
8134
+ out.push(` ${g.gate}: ${GATE_STATE[g.state].text}, ${g.reason}${value2}${limit3}`);
8135
+ for (const x of g.details ?? []) out.push(` ${x}`);
8053
8136
  }
8054
- });
8055
-
8056
- // src/reporters/console.ts
8057
- function renderConsole(result2, opts = {}) {
8058
- const s = createStyler(opts.color ?? false);
8059
- const maxOut = opts.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
8060
- const { summary } = result2;
8061
- const lines = [];
8137
+ const [applied, expired, unused] = waiverLines(d, (t) => t, oneLine);
8138
+ out.push(
8139
+ ...applied.map((l) => ` waived: ${l}`),
8140
+ ...expired.map((l) => ` expired waiver: ${l}`),
8141
+ ...unused.map((l) => ` unused waiver: ${l}`)
8142
+ );
8143
+ return out;
8144
+ }
8145
+ function adviceLines(a) {
8146
+ const sections = [];
8147
+ const unavailable = (lines) => {
8148
+ const text6 = lines.map(oneLine).join("; ");
8149
+ return text6.startsWith(NOT_COMPARED) ? text6 : `${NOT_COMPARED}, ${text6}`;
8150
+ };
8151
+ const stats = a.evals.map(
8152
+ (e) => `${oneLine(e.id)}: ${e.comparison !== void 0 ? comparisonText(e.comparison) : unavailable(e.unavailable)}${e.descriptionsDiffer === true ? DIFFERED : ""}`
8153
+ );
8154
+ if (a.overall.comparison !== void 0 || a.overall.unavailable !== void 0)
8155
+ stats.push(
8156
+ `all evals together: ${a.overall.comparison !== void 0 ? comparisonText(a.overall.comparison) : unavailable(a.overall.unavailable)}${a.overall.descriptionsDiffer === true ? DIFFERED : ""}`
8157
+ );
8158
+ if (stats.length > 0)
8159
+ sections.push({
8160
+ heading: `Pass rates (at least ${MIN_ATTEMPTS} attempts with a verdict on each side; a guide, not a proof)`,
8161
+ lines: stats
8162
+ });
8163
+ const x = a.experiment;
8164
+ if (x !== void 0) {
8165
+ const names = (l) => l.map(oneLine).join(", ") || "none";
8166
+ const lines = [
8167
+ `descriptions replaced: baseline ${names(x.baseline)}; current ${names(x.current)}`
8168
+ ];
8169
+ if (x.unavailable !== void 0)
8170
+ lines.push(
8171
+ `${NOT_COMPARED}, the two runs differ in more than the descriptions: ${x.unavailable.map(oneLine).join("; ")}`
8172
+ );
8173
+ for (const e of x.evals) {
8174
+ lines.push(
8175
+ `${oneLine(e.id)}: first tool called, baseline ${countsText(e.firstTool.baseline)}; current ${countsText(e.firstTool.current)}`
8176
+ );
8177
+ if (e.hit !== void 0)
8178
+ lines.push(`${oneLine(e.id)}: first-tool hit, ${comparisonText(e.hit.comparison)}`);
8179
+ }
8180
+ sections.push({ heading: "Experiment with descriptions", lines });
8181
+ }
8182
+ return sections;
8183
+ }
8184
+ function adviceMarkdown(d) {
8185
+ if (d.advice === void 0) return [];
8186
+ const out = ["### Advice (does not affect the exit code)", "", d.advice.note, ""];
8187
+ for (const s of adviceLines(d.advice))
8188
+ out.push(`**${s.heading}**`, "", ...s.lines.map((l) => `- ${l}`), "");
8189
+ return out;
8190
+ }
8191
+ function adviceConsole(d) {
8192
+ if (d.advice === void 0) return [];
8193
+ const out = ["Advice (does not change the exit code):"];
8194
+ for (const s of adviceLines(d.advice))
8195
+ out.push(` ${s.heading}:`, ...s.lines.map((l) => ` ${l}`));
8196
+ return out;
8197
+ }
8198
+ function summaryLine2(d) {
8199
+ const s = d.summary;
8200
+ return [
8201
+ `${s.regressions} regression(s)`,
8202
+ `${s.improvements} improvement(s)`,
8203
+ `${s.newFails} new-fail`,
8204
+ `${s.preExistingFails} pre-existing-fail`,
8205
+ `${s.errored} errored`,
8206
+ `${s.removed} removed`,
8207
+ `${s.unmeasured} not measured`,
8208
+ `${s.stablePasses} stable`
8209
+ ].join(" \xB7 ");
8210
+ }
8211
+ function matrixMarkdown(d, room) {
8212
+ const m = d.matrix;
8213
+ const rank2 = (e) => e === null ? IMPORTANCE.length : IMPORTANCE.indexOf(e.status);
8214
+ const listed3 = m.rows.map((r, i) => ({ r, i, best: Math.min(...r.cells.map(rank2)), changed: r.cells.filter((c) => c !== null && c.status !== "stable-pass").length })).filter((x) => x.changed > 0);
8215
+ const head = [`| Eval | ${m.models.map((x) => cell2(x.model)).join(" | ")} |`, `| --- | ${m.models.map(() => "---").join(" | ")} |`];
8216
+ const line = (r) => `| ${cell2(r.eval)} | ${r.cells.map((c) => c === null ? "\u2014" : c.status === "stable-pass" ? "\u2705" : BADGE[c.status]).join(" | ")} |`;
8217
+ const stable = m.rows.flatMap((r) => r.cells).filter((c) => c?.status === "stable-pass").length;
8218
+ const tail = stable > 0 ? [plural3(stable, "stable pass", "stable passes") + " not listed", ""] : [];
8219
+ if (listed3.length === 0) return tail.length > 0 ? ["_" + tail[0] + "_", ""] : [];
8220
+ const byImportance = [...listed3].sort((a, b) => a.best - b.best || a.i - b.i);
8221
+ const note2 = (n) => `_${plural3(n, "more cell", "more cells")} in the job summary_`;
8222
+ const total = listed3.reduce((n, x) => n + x.changed, 0);
8223
+ const keep = [];
8224
+ let used = [...head, "", ...tail].join("\n").length + note2(total).length + 2;
8225
+ for (const x of byImportance) {
8226
+ const cost2 = line(x.r).length + 1;
8227
+ if (used + cost2 > room) break;
8228
+ used += cost2;
8229
+ keep.push(x);
8230
+ }
8231
+ const shown4 = keep.sort((a, b) => a.i - b.i);
8232
+ const left = total - shown4.reduce((n, x) => n + x.changed, 0);
8233
+ return [
8234
+ ...shown4.length > 0 ? [...head, ...shown4.map((x) => line(x.r)), ""] : [],
8235
+ ...left > 0 ? [note2(left), ""] : [],
8236
+ ...tail.length > 0 ? ["_" + tail[0] + "_", ""] : []
8237
+ ];
8238
+ }
8239
+ function renderDiffMarkdown2(d, budget = COMMENT_BUDGET) {
8240
+ const out = [STICKY_MARKER, "## Plune eval diff", ""];
8241
+ const head = headline(d);
8242
+ out.push(head ? `### ${head.mark} ${capital(head.text)}` : "### \u2705 No regressions");
8243
+ out.push("");
8244
+ const notable = d.evals.filter((e) => e.status !== "stable-pass");
8245
+ if (d.matrix !== void 0) {
8246
+ const rest = [...gatesMarkdown(d), ...adviceMarkdown(d), `_${summaryLine2(d)}_`].join("\n");
8247
+ out.push(...matrixMarkdown(d, budget - out.join("\n").length - rest.length - 2));
8248
+ } else if (notable.length > 0) {
8249
+ out.push("| Eval | Baseline \u2192 Current | Change |");
8250
+ out.push("| --- | --- | --- |");
8251
+ for (const e of notable) {
8252
+ out.push(`| ${e.id} | ${e.baseline} \u2192 ${e.current} | ${BADGE[e.status]} |`);
8253
+ }
8254
+ out.push("");
8255
+ }
8256
+ out.push(...gatesMarkdown(d));
8257
+ out.push(...adviceMarkdown(d));
8258
+ out.push(`_${summaryLine2(d)}_`);
8259
+ return out.join("\n");
8260
+ }
8261
+ function renderDiffConsole(d) {
8262
+ const head = headline(d);
8263
+ const out = [`Plune eval diff: ${head ? head.text : "no regressions"}`];
8264
+ for (const e of d.evals) {
8265
+ if (e.status === "stable-pass") continue;
8266
+ out.push(` ${e.id}: ${e.baseline} -> ${e.current} [${e.status}]`);
8267
+ }
8268
+ out.push(...gatesConsole(d));
8269
+ out.push(...adviceConsole(d));
8270
+ out.push(summaryLine2(d));
8271
+ return out.join("\n");
8272
+ }
8273
+ function renderDiffJson(d) {
8274
+ return JSON.stringify(d, null, 2);
8275
+ }
8276
+ function renderDiff(d, format = "console") {
8277
+ if (format === "json") return noCommandsJson(renderDiffJson(d));
8278
+ if (format === "markdown") return noCommands(renderDiffMarkdown2(d));
8279
+ return noCommands(renderDiffConsole(d));
8280
+ }
8281
+ var NOT_MEASURED, STICKY_MARKER, BADGE, GATE_STATE, capital, oneLine, cell2, target2, WORD, comparisonText, countsText, NOT_COMPARED, DIFFERED, COMMENT_BUDGET, IMPORTANCE, plural3;
8282
+ var init_diff2 = __esm({
8283
+ "src/reporters/diff.ts"() {
8284
+ "use strict";
8285
+ init_cjs_shims();
8286
+ init_stats();
8287
+ init_human();
8288
+ NOT_MEASURED = "not measured";
8289
+ STICKY_MARKER = "<!-- plune-eval-diff -->";
8290
+ BADGE = {
8291
+ regression: "\u{1F534} regression",
8292
+ improvement: "\u{1F7E2} improvement",
8293
+ "pre-existing-fail": "\u26AA pre-existing fail",
8294
+ "new-fail": "\u{1F195} new fail",
8295
+ "new-pass": "\u{1F7E2} new pass",
8296
+ "stable-pass": "\u2705 stable",
8297
+ errored: "\u26A0\uFE0F errored",
8298
+ unmeasured: "\u26A0\uFE0F not measured",
8299
+ removed: "\u2796 removed"
8300
+ };
8301
+ GATE_STATE = {
8302
+ passed: { mark: "\u2705", text: "passed" },
8303
+ failed: { mark: "\u274C", text: "failed" },
8304
+ unmeasured: { mark: "\u26A0\uFE0F", text: NOT_MEASURED },
8305
+ waived: { mark: "\u{1F7E1}", text: "waived" }
8306
+ };
8307
+ capital = (t) => t.charAt(0).toUpperCase() + t.slice(1);
8308
+ oneLine = (t) => t.replace(/\s*[\r\n]+\s*/g, " ");
8309
+ cell2 = (t) => oneLine(t).replace(/\|/g, "\\|");
8310
+ target2 = (w, quote) => w.eval === void 0 ? w.gate : `${w.gate} of ${quote(w.eval)}`;
8311
+ WORD = {
8312
+ worse: "probably worse",
8313
+ better: "probably better",
8314
+ "no-difference": "no difference visible",
8315
+ "too-few": "too few attempts"
8316
+ };
8317
+ comparisonText = (c) => `${WORD[c.word]}: ${c.reason}`;
8318
+ countsText = (counts3) => Object.entries(counts3).sort(([a], [b]) => a < b ? -1 : 1).map(([tool2, n]) => `${oneLine(tool2)} ${n}`).join(", ") || "(no rows)";
8319
+ NOT_COMPARED = "not compared";
8320
+ DIFFERED = " (the descriptions of the tools differed between the runs: this is the experiment, not a change of the same thing)";
8321
+ COMMENT_BUDGET = 6e4;
8322
+ IMPORTANCE = [
8323
+ "regression",
8324
+ "errored",
8325
+ "unmeasured",
8326
+ "new-fail",
8327
+ "removed",
8328
+ "pre-existing-fail",
8329
+ "improvement",
8330
+ "new-pass",
8331
+ "stable-pass"
8332
+ ];
8333
+ plural3 = (n, one, many) => `${n} ${n === 1 ? one : many}`;
8334
+ }
8335
+ });
8336
+
8337
+ // src/reporters/matrix.ts
8338
+ function median(xs) {
8339
+ if (xs.length === 0) return void 0;
8340
+ const s = [...xs].sort((a, b) => a - b);
8341
+ const mid = s.length >> 1;
8342
+ return s.length % 2 === 1 ? s[mid] : (s[mid - 1] + s[mid]) / 2;
8343
+ }
8344
+ function cellOf(ev) {
8345
+ let passed2 = 0;
8346
+ let total = 0;
8347
+ let cost2 = 0;
8348
+ let priced = false;
8349
+ const latencies = [];
8350
+ const states = /* @__PURE__ */ new Set();
8351
+ for (const row of ev.rows) {
8352
+ const status2 = rowStatus(row);
8353
+ states.add(
8354
+ status2 === "passed" ? "pass" : status2 === "failed" ? "fail" : status2 === "errored" ? "error" : "unmeasured"
8355
+ );
8356
+ cost2 += row.usage?.cost_usd ?? 0;
8357
+ if (row.usage?.priced === true) priced = true;
8358
+ const a = row.attempts;
8359
+ if (a !== void 0 && a.results.length > 0) {
8360
+ passed2 += a.passed;
8361
+ total += a.runs;
8362
+ for (const r of a.results) if (r.latency_ms !== void 0) latencies.push(r.latency_ms);
8363
+ } else {
8364
+ passed2 += status2 === "passed" ? 1 : 0;
8365
+ total += 1;
8366
+ if (row.latency_ms !== void 0) latencies.push(row.latency_ms);
8367
+ }
8368
+ }
8369
+ const state2 = STATE_ORDER.find((s) => states.has(s)) ?? "pass";
8370
+ const latency = median(latencies);
8371
+ return {
8372
+ id: ev.id,
8373
+ state: state2,
8374
+ passed: passed2,
8375
+ total,
8376
+ cost_usd: cost2,
8377
+ priced,
8378
+ ...latency !== void 0 ? { latency_ms: latency } : {}
8379
+ };
8380
+ }
8381
+ function buildMatrix(result2) {
8382
+ if (!result2.evals.some((e) => e.provider !== void 0)) return void 0;
8383
+ const models = [];
8384
+ const rows = /* @__PURE__ */ new Map();
8385
+ const cells = [];
8386
+ for (const ev of result2.evals) {
8387
+ const p = ev.provider ?? { type: "", model: "" };
8388
+ let col = models.findIndex((m) => m.model === p.model);
8389
+ if (col < 0) col = models.push({ type: p.type, model: p.model }) - 1;
8390
+ const id2 = baseEvalId(ev);
8391
+ if (!rows.has(id2)) rows.set(id2, []);
8392
+ cells.push({ eval: id2, model: col, cell: cellOf(ev) });
8393
+ }
8394
+ for (const c of cells) {
8395
+ const row = rows.get(c.eval);
8396
+ while (row.length < models.length) row.push(null);
8397
+ row[c.model] = c.cell;
8398
+ }
8399
+ return {
8400
+ models,
8401
+ rows: [...rows].map(([id2, cs]) => ({
8402
+ eval: id2,
8403
+ cells: Array.from({ length: models.length }, (_, i) => cs[i] ?? null)
8404
+ }))
8405
+ };
8406
+ }
8407
+ function formatLatency(ms) {
8408
+ return ms < 1e3 ? `${Math.round(ms)}ms` : `${(ms / 1e3).toFixed(1)}s`;
8409
+ }
8410
+ function cellText(cell3, dry = false) {
8411
+ if (cell3 === null) return EMPTY_CELL;
8412
+ const cost2 = cell3.priced ? `$${cell3.cost_usd.toFixed(4)}` : `cost ${NOT_MEASURED}`;
8413
+ if (dry) return cost2;
8414
+ const head = cell3.state === "unmeasured" ? CELL_LABEL.unmeasured : `${CELL_LABEL[cell3.state]} ${cell3.passed}/${cell3.total}`;
8415
+ return [head, cost2, ...cell3.latency_ms !== void 0 ? [formatLatency(cell3.latency_ms)] : []].join(" \xB7 ");
8416
+ }
8417
+ function matrixMarkdown2(m, dry = false) {
8418
+ return [
8419
+ `| Eval | ${m.models.map((x) => mdCell(x.model)).join(" | ")} |`,
8420
+ `| --- | ${m.models.map(() => "---").join(" | ")} |`,
8421
+ ...m.rows.map((r) => `| ${mdCell(r.eval)} | ${r.cells.map((c) => cellText(c, dry)).join(" | ")} |`)
8422
+ ];
8423
+ }
8424
+ function matrixConsole(m, dry = false) {
8425
+ const table = [["Eval", ...m.models.map((x) => safeLine(x.model))], ...m.rows.map((r) => [safeLine(r.eval), ...r.cells.map((c) => cellText(c, dry))])];
8426
+ const widths = table[0].map((_, i) => Math.max(...table.map((row) => [...row[i]].length)));
8427
+ return table.map(
8428
+ (row) => row.map((c, i) => c + " ".repeat(widths[i] - [...c].length)).join(" ").trimEnd()
8429
+ );
8430
+ }
8431
+ var STATE_ORDER, CELL_LABEL, EMPTY_CELL;
8432
+ var init_matrix = __esm({
8433
+ "src/reporters/matrix.ts"() {
8434
+ "use strict";
8435
+ init_cjs_shims();
8436
+ init_results();
8437
+ init_helpers();
8438
+ init_diff2();
8439
+ STATE_ORDER = ["error", "fail", "unmeasured", "pass"];
8440
+ CELL_LABEL = {
8441
+ pass: "PASS",
8442
+ fail: "FAIL",
8443
+ error: "ERROR",
8444
+ unmeasured: "NOT MEASURED"
8445
+ };
8446
+ EMPTY_CELL = "\u2014";
8447
+ }
8448
+ });
8449
+
8450
+ // src/reporters/console.ts
8451
+ function renderConsole(result2, opts = {}) {
8452
+ const s = createStyler(opts.color ?? false);
8453
+ const maxOut = opts.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
8454
+ const { summary } = result2;
8455
+ const lines = [];
8062
8456
  if (result2.dry_run === true) {
8063
8457
  lines.push(s.bold("Plune dry run"));
8064
8458
  const matrix2 = buildMatrix(result2);
@@ -8191,7 +8585,7 @@ function renderMarkdown(result2, opts = {}) {
8191
8585
  const matrix2 = buildMatrix(result2);
8192
8586
  if (matrix2 !== void 0) {
8193
8587
  out.splice(out.length - 1, 0, `| Models | ${matrix2.models.length} |`);
8194
- out.push("", "## Estimated cost per model", "", ...matrixMarkdown(matrix2, true));
8588
+ out.push("", "## Estimated cost per model", "", ...matrixMarkdown2(matrix2, true));
8195
8589
  }
8196
8590
  const repeated2 = result2.evals.flatMap(
8197
8591
  (ev) => ev.rows.flatMap((row) => {
@@ -8216,7 +8610,7 @@ function renderMarkdown(result2, opts = {}) {
8216
8610
  out.push(`| Duration (ms) | ${summary.duration_ms} |`);
8217
8611
  out.push("");
8218
8612
  const matrix = buildMatrix(result2);
8219
- if (matrix !== void 0) out.push("## Model matrix", "", ...matrixMarkdown(matrix), "");
8613
+ if (matrix !== void 0) out.push("## Model matrix", "", ...matrixMarkdown2(matrix), "");
8220
8614
  const repeated = result2.evals.flatMap(
8221
8615
  (ev) => ev.rows.flatMap(
8222
8616
  (row) => row.attempts !== void 0 ? [{ id: ev.id, row, a: row.attempts }] : []
@@ -9005,7 +9399,13 @@ function textRefusal(bytes) {
9005
9399
  }
9006
9400
  return void 0;
9007
9401
  }
9008
- function onDisk(result2) {
9402
+ function withoutTargets(result2) {
9403
+ if (result2.targets === void 0) return result2;
9404
+ const { targets: _targets, ...rest } = result2;
9405
+ return rest;
9406
+ }
9407
+ function onDisk(deferred) {
9408
+ const result2 = withoutTargets(deferred);
9009
9409
  if (!("files" in result2) || result2.files === void 0) return result2;
9010
9410
  const { files, ...rest } = result2;
9011
9411
  const kept = files.filter((f) => f.path !== void 0).map(({ body: _body, ...file }) => file);
@@ -9554,6 +9954,7 @@ async function startRun(passed2, declared2) {
9554
9954
  let runId = null;
9555
9955
  let joined = false;
9556
9956
  let offline = token2 === "";
9957
+ let targetsRefused = false;
9557
9958
  let done = false;
9558
9959
  const shortened = /* @__PURE__ */ new Set();
9559
9960
  const specFiles = /* @__PURE__ */ new Map();
@@ -9823,16 +10224,24 @@ async function startRun(passed2, declared2) {
9823
10224
  await send3(submissions, filesByKey);
9824
10225
  }
9825
10226
  async function send3(submissions, filesByKey) {
9826
- for (const part of packed(submissions)) {
10227
+ for (const packedPart of packed(submissions)) {
10228
+ let part = targetsRefused ? packedPart.map(withoutTargets) : packedPart;
9827
10229
  if (offline) {
9828
10230
  defer(part);
9829
10231
  continue;
9830
10232
  }
9831
- const out = await client.post(
10233
+ const post = (results4) => client.post(
9832
10234
  `/v1/runs/${runId}/results`,
9833
10235
  // The job's combination on every batch; a refusal of it is a 422 said below as it came.
9834
- { results: part, ...configuration !== void 0 ? { configuration } : {} }
10236
+ { results: results4, ...configuration !== void 0 ? { configuration } : {} }
9835
10237
  );
10238
+ let out = await post(part);
10239
+ if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0)) {
10240
+ if (!targetsRefused) log("plune: the platform does not take targets on a result yet \u2014 the results are sent without them.");
10241
+ targetsRefused = true;
10242
+ part = part.map(withoutTargets);
10243
+ out = await post(part);
10244
+ }
9836
10245
  const counts3 = out.ok ? out.body?.counts : void 0;
9837
10246
  const told = COUNTED.filter((k) => typeof counts3?.[k] === "number");
9838
10247
  if (told.length > 0) {
@@ -11492,6 +11901,10 @@ var init_xml = __esm({
11492
11901
  });
11493
11902
 
11494
11903
  // src/importers/junit.ts
11904
+ function targetsOf(test) {
11905
+ const values = test.children.filter((c) => c.name === "properties").flatMap((p) => p.children).filter((p) => p.name === "property" && p.attrs["name"] === TARGET_PROPERTY).map((p) => (p.attrs["value"] ?? "").trim()).filter((v) => v !== "" && v.length <= TARGETS.length && !CONTROL.test(v));
11906
+ return [...new Set(values)].slice(0, TARGETS.max);
11907
+ }
11495
11908
  function locate(el, suite, out) {
11496
11909
  for (const child of el.children) {
11497
11910
  if (child.name === "testcase") out.push({ test: child, suite });
@@ -11570,6 +11983,7 @@ function readJUnit(source, file, missing = [], notes = [], now = /* @__PURE__ */
11570
11983
  const title = titleOf(classname, name);
11571
11984
  const rkey = resultKey(key.value, 0);
11572
11985
  const files = filesOfTest(test, folder, title, missing, { lexical, resultKey: rkey, notes });
11986
+ const targets = targetsOf(test);
11573
11987
  return {
11574
11988
  resultKey: rkey,
11575
11989
  ...stated !== void 0 ? { testCaseId: stated } : {},
@@ -11580,14 +11994,15 @@ function readJUnit(source, file, missing = [], notes = [], now = /* @__PURE__ */
11580
11994
  ...specRef !== void 0 ? { specRef } : {},
11581
11995
  ...execution !== void 0 ? { execution } : {},
11582
11996
  ...errorContext !== "" ? { errorContext } : {},
11583
- ...files.length > 0 ? { files } : {}
11997
+ ...files.length > 0 ? { files } : {},
11998
+ ...targets.length > 0 ? { targets } : {}
11584
11999
  };
11585
12000
  });
11586
12001
  }
11587
12002
  function looksLikeJUnit(source) {
11588
12003
  return /<\s*testsuites?\b/.test(source.slice(0, 4096));
11589
12004
  }
11590
- var SOURCE2, TOKEN2, SPEC_FILE;
12005
+ var SOURCE2, TOKEN2, SPEC_FILE, TARGET_PROPERTY, TARGETS, CONTROL;
11591
12006
  var init_junit = __esm({
11592
12007
  "src/importers/junit.ts"() {
11593
12008
  "use strict";
@@ -11598,6 +12013,9 @@ var init_junit = __esm({
11598
12013
  SOURCE2 = "junit";
11599
12014
  TOKEN2 = /@P([A-Za-z0-9_-]+)/;
11600
12015
  SPEC_FILE = /\.(?:spec|test)\.[cm]?[jt]sx?$/;
12016
+ TARGET_PROPERTY = "plune.mcp.tool";
12017
+ TARGETS = { max: 50, length: 200 };
12018
+ CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
11601
12019
  }
11602
12020
  });
11603
12021
 
@@ -12374,7 +12792,7 @@ function diffMatrix(evals) {
12374
12792
  }))
12375
12793
  };
12376
12794
  }
12377
- var init_diff2 = __esm({
12795
+ var init_diff3 = __esm({
12378
12796
  "src/diff/diff.ts"() {
12379
12797
  "use strict";
12380
12798
  init_cjs_shims();
@@ -12618,115 +13036,43 @@ function evaluateGates(baseline, current, diff2, opts, waivers, now) {
12618
13036
  if (opts.maxTokens !== void 0)
12619
13037
  gates.push(limitGate("tokens", tokens(current), opts.maxTokens, "input + output tokens of the current run"));
12620
13038
  for (const g of gates)
12621
- if (g.gate !== "regression" && g.state === "failed" && take(WAIVER_OF[g.gate])) g.state = "waived";
12622
- const exitCode2 = gates.some((g) => g.state === "failed") ? 1 : gates.some((g) => g.state === "unmeasured") ? 3 : 0;
12623
- return {
12624
- exitCode: exitCode2,
12625
- gates,
12626
- waivers: {
12627
- applied: waivers.filter((w) => used.has(w)),
12628
- expired: waivers.filter((w) => isExpired(w, now)),
12629
- unused: active.filter((w) => !used.has(w))
12630
- }
12631
- };
12632
- }
12633
- var MIN_PASS_RATE_ATTEMPTS, WAIVER_OF, round, over, cost, tokens;
12634
- var init_gates = __esm({
12635
- "src/diff/gates.ts"() {
12636
- "use strict";
12637
- init_cjs_shims();
12638
- init_results();
12639
- init_waivers();
12640
- MIN_PASS_RATE_ATTEMPTS = 10;
12641
- WAIVER_OF = {
12642
- regression: "regression",
12643
- "pass-rate": "pass-rate",
12644
- cost: "cost",
12645
- "cost-increase": "cost",
12646
- tokens: "tokens"
12647
- };
12648
- round = (n) => Math.round(n * 1e6) / 1e6;
12649
- over = (value2, limit3) => value2 - limit3 > 1e-9;
12650
- cost = (run) => measure(
12651
- run,
12652
- (row, e) => row.usage === void 0 ? `eval "${e.id}" has a row with no usage` : row.usage.priced !== true ? `eval "${e.id}" has a row with no known price` : row.usage.cost_usd + (row.cache_saved?.cost_usd ?? 0)
12653
- );
12654
- tokens = (run) => measure(
12655
- run,
12656
- (row, e) => row.usage === void 0 ? `eval "${e.id}" has a row with no usage` : row.usage.input_tokens + row.usage.output_tokens
12657
- );
12658
- }
12659
- });
12660
-
12661
- // src/diff/stats.ts
12662
- function wilson(passed2, total) {
12663
- const share2 = passed2 / total;
12664
- const z22 = Z * Z;
12665
- const denom = 1 + z22 / total;
12666
- const centre = (share2 + z22 / (2 * total)) / denom;
12667
- const half = Z * Math.sqrt(share2 * (1 - share2) / total + z22 / (4 * total * total)) / denom;
12668
- return { share: share2, lower: Math.max(0, centre - half), upper: Math.min(1, centre + half) };
12669
- }
12670
- function newcombeDifference(current, base) {
12671
- const a = wilson(current.passed, current.total);
12672
- const b = wilson(base.passed, base.total);
12673
- const diff2 = a.share - b.share;
12674
- return {
12675
- diff: diff2,
12676
- lower: diff2 - Math.sqrt((a.share - a.lower) ** 2 + (b.upper - b.share) ** 2),
12677
- upper: diff2 + Math.sqrt((a.upper - a.share) ** 2 + (b.share - b.lower) ** 2)
12678
- };
12679
- }
12680
- function fmtPp(share2, directional) {
12681
- const rounded = pp(share2);
12682
- if (rounded === 0 && share2 !== 0 && directional)
12683
- return signed(String(Number((share2 * 100).toPrecision(2))));
12684
- return signed(String(rounded === 0 ? 0 : rounded));
12685
- }
12686
- function wordFor(lower, upper) {
12687
- return upper < -EPS ? "worse" : lower > EPS ? "better" : "no-difference";
12688
- }
12689
- function compareProportions(current, base, min = MIN_ATTEMPTS) {
12690
- const floor = Number.isFinite(min) ? Math.max(1, min) : MIN_ATTEMPTS;
12691
- const sides = { current: current.total, base: base.total, min: floor };
12692
- if (!valid(current) || !valid(base))
12693
- return {
12694
- word: "too-few",
12695
- ...sides,
12696
- reason: "the attempt counts are not whole numbers inside 0 and the total, so no share was computed"
12697
- };
12698
- const [uc, ub] = [current.unmeasured ?? 0, base.unmeasured ?? 0];
12699
- const dropped = uc + ub > 0 ? `; not measured and left out: current ${uc}, baseline ${ub} attempt(s)` : "";
12700
- if (current.total < floor || base.total < floor)
12701
- return {
12702
- word: "too-few",
12703
- ...sides,
12704
- reason: `at least ${floor} attempts with a verdict are needed on each side (current ${current.total}, baseline ${base.total})${dropped}`
12705
- };
12706
- const r = newcombeDifference(current, base);
12707
- const [diffPp, lowerPp, upperPp] = [pp(r.diff), pp(r.lower), pp(r.upper)];
12708
- const word = wordFor(r.lower, r.upper);
12709
- const directional = word !== "no-difference";
12710
- return {
12711
- word,
12712
- ...sides,
12713
- diffPp,
12714
- lowerPp,
12715
- upperPp,
12716
- reason: `${current.passed}/${current.total} against ${base.passed}/${base.total}: ${fmtPp(r.diff, false)} pp, 95% interval ${fmtPp(r.lower, directional)} to ${fmtPp(r.upper, directional)} pp${dropped}`
13039
+ if (g.gate !== "regression" && g.state === "failed" && take(WAIVER_OF[g.gate])) g.state = "waived";
13040
+ const exitCode2 = gates.some((g) => g.state === "failed") ? 1 : gates.some((g) => g.state === "unmeasured") ? 3 : 0;
13041
+ return {
13042
+ exitCode: exitCode2,
13043
+ gates,
13044
+ waivers: {
13045
+ applied: waivers.filter((w) => used.has(w)),
13046
+ expired: waivers.filter((w) => isExpired(w, now)),
13047
+ unused: active.filter((w) => !used.has(w))
13048
+ }
12717
13049
  };
12718
13050
  }
12719
- var Z, MIN_ATTEMPTS, pp, signed, EPS, valid;
12720
- var init_stats = __esm({
12721
- "src/diff/stats.ts"() {
13051
+ var MIN_PASS_RATE_ATTEMPTS, WAIVER_OF, round, over, cost, tokens;
13052
+ var init_gates = __esm({
13053
+ "src/diff/gates.ts"() {
12722
13054
  "use strict";
12723
13055
  init_cjs_shims();
12724
- Z = 1.959963984540054;
12725
- MIN_ATTEMPTS = 5;
12726
- pp = (n) => Math.round(n * 1e4) / 100;
12727
- signed = (s) => /^[1-9.]|^0\./.test(s) ? `+${s}` : s;
12728
- EPS = 1e-12;
12729
- valid = (x) => Number.isInteger(x.passed) && Number.isInteger(x.total) && x.passed >= 0 && x.passed <= x.total;
13056
+ init_results();
13057
+ init_waivers();
13058
+ MIN_PASS_RATE_ATTEMPTS = 10;
13059
+ WAIVER_OF = {
13060
+ regression: "regression",
13061
+ "pass-rate": "pass-rate",
13062
+ cost: "cost",
13063
+ "cost-increase": "cost",
13064
+ tokens: "tokens"
13065
+ };
13066
+ round = (n) => Math.round(n * 1e6) / 1e6;
13067
+ over = (value2, limit3) => value2 - limit3 > 1e-9;
13068
+ cost = (run) => measure(
13069
+ run,
13070
+ (row, e) => row.usage === void 0 ? `eval "${e.id}" has a row with no usage` : row.usage.priced !== true ? `eval "${e.id}" has a row with no known price` : row.usage.cost_usd + (row.cache_saved?.cost_usd ?? 0)
13071
+ );
13072
+ tokens = (run) => measure(
13073
+ run,
13074
+ (row, e) => row.usage === void 0 ? `eval "${e.id}" has a row with no usage` : row.usage.input_tokens + row.usage.output_tokens
13075
+ );
12730
13076
  }
12731
13077
  });
12732
13078
 
@@ -12853,385 +13199,121 @@ var init_advice = __esm({
12853
13199
  "src/diff/advice.ts"() {
12854
13200
  "use strict";
12855
13201
  init_cjs_shims();
12856
- init_results();
12857
- init_gates();
12858
- init_stats();
12859
- ADVICE_NOTE = "Advice only: nothing here changes the exit code, the state of an eval or a gate.";
12860
- NO_DRY = "not compared: a dry run measures nothing";
12861
- dryRuns = (baseline, current) => [
12862
- ...baseline.dry_run === true ? [`${NO_DRY} (the baseline)`] : [],
12863
- ...current.dry_run === true ? [`${NO_DRY} (the current run)`] : []
12864
- ];
12865
- hasRepeats = (e) => (e.measured?.runs ?? 1) > 1 || e.rows.some((r) => r.attempts !== void 0);
12866
- only = (run, e) => ({ ...run, evals: [e] });
12867
- SEP = String.fromCharCode(10);
12868
- swaps = (e) => [
12869
- ...new Set(
12870
- e.rows.flatMap(
12871
- (r) => (r.agent?.description_overrides ?? []).map(
12872
- (s) => `${s.tool}=${s.sha256}`
12873
- )
12874
- )
12875
- )
12876
- ].sort();
12877
- }
12878
- });
12879
-
12880
- // src/cli/commands/diff.ts
12881
- var diff_exports = {};
12882
- __export(diff_exports, {
12883
- DiffInputError: () => DiffInputError,
12884
- handleDiff: () => handleDiff
12885
- });
12886
- function isRunResult2(v) {
12887
- if (typeof v !== "object" || v === null) return false;
12888
- const o = v;
12889
- return Array.isArray(o["evals"]) && typeof o["summary"] === "object" && o["summary"] !== null;
12890
- }
12891
- function loadRunResult(file, label2) {
12892
- let raw;
12893
- try {
12894
- raw = fs14.readFileSync(file, "utf8");
12895
- } catch {
12896
- throw new DiffInputError(`Cannot read ${label2} run file: ${file}`);
12897
- }
12898
- let parsed4;
12899
- try {
12900
- parsed4 = JSON.parse(raw);
12901
- } catch {
12902
- throw new DiffInputError(`${label2} run file is not valid JSON: ${file}`);
12903
- }
12904
- if (!isRunResult2(parsed4)) {
12905
- throw new DiffInputError(`${label2} run file is not a Plune RunResult: ${file}`);
12906
- }
12907
- return parsed4;
12908
- }
12909
- function limit2(flag2, raw) {
12910
- if (raw === void 0) return void 0;
12911
- const n = Number(raw);
12912
- if (raw.trim() === "" || !Number.isFinite(n) || n < 0)
12913
- throw new DiffInputError(`--${flag2} must be a number of 0 or more (got "${raw}")`);
12914
- return n;
12915
- }
12916
- function loadWaivers(file, now) {
12917
- let raw;
12918
- try {
12919
- raw = fs14.readFileSync(file, "utf8");
12920
- } catch {
12921
- throw new DiffInputError(`Cannot read waivers file: ${file}`);
12922
- }
12923
- try {
12924
- return parseWaivers(raw, now);
12925
- } catch (err) {
12926
- if (err instanceof WaiversFileError) throw new DiffInputError(`${file}:
12927
- ${err.message}`);
12928
- throw err;
12929
- }
12930
- }
12931
- function handleDiff(opts) {
12932
- const gateOpts = {
12933
- ...opts.failOnRegression === true ? { failOnRegression: true } : {}
12934
- };
12935
- for (const [key, flag2] of [
12936
- ["maxPassRateDropPercent", "max-pass-rate-drop-percent"],
12937
- ["maxCostUsd", "max-cost-usd"],
12938
- ["maxCostIncreasePercent", "max-cost-increase-percent"],
12939
- ["maxTokens", "max-tokens"]
12940
- ]) {
12941
- const n = limit2(flag2, opts[key]);
12942
- if (n !== void 0) gateOpts[key] = n;
12943
- }
12944
- const baseline = loadRunResult(opts.baselinePath, "baseline");
12945
- const current = loadRunResult(opts.currentPath, "current");
12946
- const now = /* @__PURE__ */ new Date();
12947
- const waivers = opts.waivers === void 0 ? [] : loadWaivers(opts.waivers, now);
12948
- const diff2 = diffRuns(baseline, current);
12949
- const advice = adviceFor(baseline, current);
12950
- const withAdvice = advice === void 0 ? diff2 : { ...diff2, advice };
12951
- if (!gatesEnabled(gateOpts)) return withAdvice;
12952
- return { ...withAdvice, gates: evaluateGates(baseline, current, diff2, gateOpts, waivers, now) };
12953
- }
12954
- var fs14, DiffInputError;
12955
- var init_diff3 = __esm({
12956
- "src/cli/commands/diff.ts"() {
12957
- "use strict";
12958
- init_cjs_shims();
12959
- fs14 = __toESM(require("fs"), 1);
12960
- init_diff2();
12961
- init_advice();
12962
- init_gates();
12963
- init_waivers();
12964
- DiffInputError = class extends Error {
12965
- code = "DIFF_INPUT";
12966
- constructor(message2) {
12967
- super(message2);
12968
- this.name = "DiffInputError";
12969
- }
12970
- };
12971
- }
12972
- });
12973
-
12974
- // src/reporters/diff.ts
12975
- var diff_exports2 = {};
12976
- __export(diff_exports2, {
12977
- COMMENT_BUDGET: () => COMMENT_BUDGET,
12978
- STICKY_MARKER: () => STICKY_MARKER,
12979
- renderDiff: () => renderDiff,
12980
- renderDiffMarkdown: () => renderDiffMarkdown2
12981
- });
12982
- function headline(d) {
12983
- const gates = d.gates?.gates ?? [];
12984
- const named2 = (state2) => gates.filter((g) => g.state === state2).map((g) => g.gate);
12985
- const regression = gates.find((g) => g.gate === "regression");
12986
- if (d.summary.hasRegression && regression?.state !== "waived")
12987
- return { mark: "\u274C", text: `${d.summary.regressions} regression(s)` };
12988
- if (named2("failed").length > 0) return { mark: "\u274C", text: `gate failed: ${named2("failed").join(", ")}` };
12989
- if (d.summary.unmeasured > 0) return { mark: "\u26A0\uFE0F", text: `${d.summary.unmeasured} eval(s) not measured` };
12990
- if (named2("unmeasured").length > 0) return { mark: "\u26A0\uFE0F", text: `not measured: ${named2("unmeasured").join(", ")}` };
12991
- if (named2("waived").length > 0) return { mark: "\u2705", text: `gates passed (${named2("waived").length} waived)` };
12992
- return null;
12993
- }
12994
- function amount(gate2, n) {
12995
- if (n === void 0) return "\u2014";
12996
- if (gate2 === "pass-rate") return `${n} pp`;
12997
- if (gate2 === "cost") return `$${n}`;
12998
- if (gate2 === "cost-increase") return `${n}%`;
12999
- return String(n);
13000
- }
13001
- function waiverLines(d, quote, text6) {
13002
- const { applied, expired, unused } = d.gates.waivers;
13003
- return [
13004
- applied.map((w) => `${target2(w, quote)} until ${w.expires}: ${text6(w.reason)}`),
13005
- expired.map((w) => `${target2(w, quote)} on ${w.expires}: ${text6(w.reason)}`),
13006
- unused.map((w) => `${target2(w, quote)} until ${w.expires}: ${text6(w.reason)}`)
13007
- ];
13008
- }
13009
- function gatesMarkdown(d) {
13010
- if (d.gates === void 0) return [];
13011
- const out = ["### Gates", "", "| Gate | State | Value | Threshold | Reason |", "| --- | --- | --- | --- | --- |"];
13012
- for (const g of d.gates.gates) {
13013
- const s = GATE_STATE[g.state];
13014
- out.push(
13015
- `| ${g.gate} | ${s.mark} ${s.text} | ${amount(g.gate, g.value)} | ${amount(g.gate, g.threshold)} | ${cell2(g.reason)} |`
13016
- );
13017
- }
13018
- out.push("");
13019
- const details = d.gates.gates.flatMap((g) => (g.details ?? []).map((x) => `- ${g.gate}: ${x}`));
13020
- const [applied, expired, unused] = waiverLines(d, (t) => `\`${t}\``, oneLine);
13021
- const lines = [
13022
- ...details,
13023
- ...applied.map((l) => `- Waived: ${l}`),
13024
- ...expired.map((l) => `- Expired: ${l}`),
13025
- ...unused.map((l) => `- Unused: ${l}`)
13026
- ];
13027
- if (lines.length > 0) out.push(...lines, "");
13028
- return out;
13029
- }
13030
- function gatesConsole(d) {
13031
- if (d.gates === void 0) return [];
13032
- const out = ["Gates:"];
13033
- for (const g of d.gates.gates) {
13034
- const value2 = g.value === void 0 ? "" : `: ${amount(g.gate, g.value)}`;
13035
- const limit3 = g.threshold === void 0 ? "" : ` (limit ${amount(g.gate, g.threshold)})`;
13036
- out.push(` ${g.gate}: ${GATE_STATE[g.state].text}, ${g.reason}${value2}${limit3}`);
13037
- for (const x of g.details ?? []) out.push(` ${x}`);
13038
- }
13039
- const [applied, expired, unused] = waiverLines(d, (t) => t, oneLine);
13040
- out.push(
13041
- ...applied.map((l) => ` waived: ${l}`),
13042
- ...expired.map((l) => ` expired waiver: ${l}`),
13043
- ...unused.map((l) => ` unused waiver: ${l}`)
13044
- );
13045
- return out;
13046
- }
13047
- function adviceLines(a) {
13048
- const sections = [];
13049
- const unavailable = (lines) => {
13050
- const text6 = lines.map(oneLine).join("; ");
13051
- return text6.startsWith(NOT_COMPARED) ? text6 : `${NOT_COMPARED}, ${text6}`;
13052
- };
13053
- const stats = a.evals.map(
13054
- (e) => `${oneLine(e.id)}: ${e.comparison !== void 0 ? comparisonText(e.comparison) : unavailable(e.unavailable)}${e.descriptionsDiffer === true ? DIFFERED : ""}`
13055
- );
13056
- if (a.overall.comparison !== void 0 || a.overall.unavailable !== void 0)
13057
- stats.push(
13058
- `all evals together: ${a.overall.comparison !== void 0 ? comparisonText(a.overall.comparison) : unavailable(a.overall.unavailable)}${a.overall.descriptionsDiffer === true ? DIFFERED : ""}`
13059
- );
13060
- if (stats.length > 0)
13061
- sections.push({
13062
- heading: `Pass rates (at least ${MIN_ATTEMPTS} attempts with a verdict on each side; a guide, not a proof)`,
13063
- lines: stats
13064
- });
13065
- const x = a.experiment;
13066
- if (x !== void 0) {
13067
- const names = (l) => l.map(oneLine).join(", ") || "none";
13068
- const lines = [
13069
- `descriptions replaced: baseline ${names(x.baseline)}; current ${names(x.current)}`
13202
+ init_results();
13203
+ init_gates();
13204
+ init_stats();
13205
+ ADVICE_NOTE = "Advice only: nothing here changes the exit code, the state of an eval or a gate.";
13206
+ NO_DRY = "not compared: a dry run measures nothing";
13207
+ dryRuns = (baseline, current) => [
13208
+ ...baseline.dry_run === true ? [`${NO_DRY} (the baseline)`] : [],
13209
+ ...current.dry_run === true ? [`${NO_DRY} (the current run)`] : []
13070
13210
  ];
13071
- if (x.unavailable !== void 0)
13072
- lines.push(
13073
- `${NOT_COMPARED}, the two runs differ in more than the descriptions: ${x.unavailable.map(oneLine).join("; ")}`
13074
- );
13075
- for (const e of x.evals) {
13076
- lines.push(
13077
- `${oneLine(e.id)}: first tool called, baseline ${countsText(e.firstTool.baseline)}; current ${countsText(e.firstTool.current)}`
13078
- );
13079
- if (e.hit !== void 0)
13080
- lines.push(`${oneLine(e.id)}: first-tool hit, ${comparisonText(e.hit.comparison)}`);
13081
- }
13082
- sections.push({ heading: "Experiment with descriptions", lines });
13211
+ hasRepeats = (e) => (e.measured?.runs ?? 1) > 1 || e.rows.some((r) => r.attempts !== void 0);
13212
+ only = (run, e) => ({ ...run, evals: [e] });
13213
+ SEP = String.fromCharCode(10);
13214
+ swaps = (e) => [
13215
+ ...new Set(
13216
+ e.rows.flatMap(
13217
+ (r) => (r.agent?.description_overrides ?? []).map(
13218
+ (s) => `${s.tool}=${s.sha256}`
13219
+ )
13220
+ )
13221
+ )
13222
+ ].sort();
13083
13223
  }
13084
- return sections;
13085
- }
13086
- function adviceMarkdown(d) {
13087
- if (d.advice === void 0) return [];
13088
- const out = ["### Advice (does not affect the exit code)", "", d.advice.note, ""];
13089
- for (const s of adviceLines(d.advice))
13090
- out.push(`**${s.heading}**`, "", ...s.lines.map((l) => `- ${l}`), "");
13091
- return out;
13224
+ });
13225
+
13226
+ // src/cli/commands/diff.ts
13227
+ var diff_exports2 = {};
13228
+ __export(diff_exports2, {
13229
+ DiffInputError: () => DiffInputError,
13230
+ handleDiff: () => handleDiff
13231
+ });
13232
+ function isRunResult2(v) {
13233
+ if (typeof v !== "object" || v === null) return false;
13234
+ const o = v;
13235
+ return Array.isArray(o["evals"]) && typeof o["summary"] === "object" && o["summary"] !== null;
13092
13236
  }
13093
- function adviceConsole(d) {
13094
- if (d.advice === void 0) return [];
13095
- const out = ["Advice (does not change the exit code):"];
13096
- for (const s of adviceLines(d.advice))
13097
- out.push(` ${s.heading}:`, ...s.lines.map((l) => ` ${l}`));
13098
- return out;
13237
+ function loadRunResult(file, label2) {
13238
+ let raw;
13239
+ try {
13240
+ raw = fs14.readFileSync(file, "utf8");
13241
+ } catch {
13242
+ throw new DiffInputError(`Cannot read ${label2} run file: ${file}`);
13243
+ }
13244
+ let parsed4;
13245
+ try {
13246
+ parsed4 = JSON.parse(raw);
13247
+ } catch {
13248
+ throw new DiffInputError(`${label2} run file is not valid JSON: ${file}`);
13249
+ }
13250
+ if (!isRunResult2(parsed4)) {
13251
+ throw new DiffInputError(`${label2} run file is not a Plune RunResult: ${file}`);
13252
+ }
13253
+ return parsed4;
13099
13254
  }
13100
- function summaryLine2(d) {
13101
- const s = d.summary;
13102
- return [
13103
- `${s.regressions} regression(s)`,
13104
- `${s.improvements} improvement(s)`,
13105
- `${s.newFails} new-fail`,
13106
- `${s.preExistingFails} pre-existing-fail`,
13107
- `${s.errored} errored`,
13108
- `${s.removed} removed`,
13109
- `${s.unmeasured} not measured`,
13110
- `${s.stablePasses} stable`
13111
- ].join(" \xB7 ");
13255
+ function limit2(flag2, raw) {
13256
+ if (raw === void 0) return void 0;
13257
+ const n = Number(raw);
13258
+ if (raw.trim() === "" || !Number.isFinite(n) || n < 0)
13259
+ throw new DiffInputError(`--${flag2} must be a number of 0 or more (got "${raw}")`);
13260
+ return n;
13112
13261
  }
13113
- function matrixMarkdown2(d, room) {
13114
- const m = d.matrix;
13115
- const rank2 = (e) => e === null ? IMPORTANCE.length : IMPORTANCE.indexOf(e.status);
13116
- const listed3 = m.rows.map((r, i) => ({ r, i, best: Math.min(...r.cells.map(rank2)), changed: r.cells.filter((c) => c !== null && c.status !== "stable-pass").length })).filter((x) => x.changed > 0);
13117
- const head = [`| Eval | ${m.models.map((x) => cell2(x.model)).join(" | ")} |`, `| --- | ${m.models.map(() => "---").join(" | ")} |`];
13118
- const line = (r) => `| ${cell2(r.eval)} | ${r.cells.map((c) => c === null ? "\u2014" : c.status === "stable-pass" ? "\u2705" : BADGE[c.status]).join(" | ")} |`;
13119
- const stable = m.rows.flatMap((r) => r.cells).filter((c) => c?.status === "stable-pass").length;
13120
- const tail = stable > 0 ? [plural3(stable, "stable pass", "stable passes") + " not listed", ""] : [];
13121
- if (listed3.length === 0) return tail.length > 0 ? ["_" + tail[0] + "_", ""] : [];
13122
- const byImportance = [...listed3].sort((a, b) => a.best - b.best || a.i - b.i);
13123
- const note2 = (n) => `_${plural3(n, "more cell", "more cells")} in the job summary_`;
13124
- const total = listed3.reduce((n, x) => n + x.changed, 0);
13125
- const keep = [];
13126
- let used = [...head, "", ...tail].join("\n").length + note2(total).length + 2;
13127
- for (const x of byImportance) {
13128
- const cost2 = line(x.r).length + 1;
13129
- if (used + cost2 > room) break;
13130
- used += cost2;
13131
- keep.push(x);
13262
+ function loadWaivers(file, now) {
13263
+ let raw;
13264
+ try {
13265
+ raw = fs14.readFileSync(file, "utf8");
13266
+ } catch {
13267
+ throw new DiffInputError(`Cannot read waivers file: ${file}`);
13132
13268
  }
13133
- const shown4 = keep.sort((a, b) => a.i - b.i);
13134
- const left = total - shown4.reduce((n, x) => n + x.changed, 0);
13135
- return [
13136
- ...shown4.length > 0 ? [...head, ...shown4.map((x) => line(x.r)), ""] : [],
13137
- ...left > 0 ? [note2(left), ""] : [],
13138
- ...tail.length > 0 ? ["_" + tail[0] + "_", ""] : []
13139
- ];
13140
- }
13141
- function renderDiffMarkdown2(d, budget = COMMENT_BUDGET) {
13142
- const out = [STICKY_MARKER, "## Plune eval diff", ""];
13143
- const head = headline(d);
13144
- out.push(head ? `### ${head.mark} ${capital(head.text)}` : "### \u2705 No regressions");
13145
- out.push("");
13146
- const notable = d.evals.filter((e) => e.status !== "stable-pass");
13147
- if (d.matrix !== void 0) {
13148
- const rest = [...gatesMarkdown(d), ...adviceMarkdown(d), `_${summaryLine2(d)}_`].join("\n");
13149
- out.push(...matrixMarkdown2(d, budget - out.join("\n").length - rest.length - 2));
13150
- } else if (notable.length > 0) {
13151
- out.push("| Eval | Baseline \u2192 Current | Change |");
13152
- out.push("| --- | --- | --- |");
13153
- for (const e of notable) {
13154
- out.push(`| ${e.id} | ${e.baseline} \u2192 ${e.current} | ${BADGE[e.status]} |`);
13155
- }
13156
- out.push("");
13269
+ try {
13270
+ return parseWaivers(raw, now);
13271
+ } catch (err) {
13272
+ if (err instanceof WaiversFileError) throw new DiffInputError(`${file}:
13273
+ ${err.message}`);
13274
+ throw err;
13157
13275
  }
13158
- out.push(...gatesMarkdown(d));
13159
- out.push(...adviceMarkdown(d));
13160
- out.push(`_${summaryLine2(d)}_`);
13161
- return out.join("\n");
13162
13276
  }
13163
- function renderDiffConsole(d) {
13164
- const head = headline(d);
13165
- const out = [`Plune eval diff: ${head ? head.text : "no regressions"}`];
13166
- for (const e of d.evals) {
13167
- if (e.status === "stable-pass") continue;
13168
- out.push(` ${e.id}: ${e.baseline} -> ${e.current} [${e.status}]`);
13277
+ function handleDiff(opts) {
13278
+ const gateOpts = {
13279
+ ...opts.failOnRegression === true ? { failOnRegression: true } : {}
13280
+ };
13281
+ for (const [key, flag2] of [
13282
+ ["maxPassRateDropPercent", "max-pass-rate-drop-percent"],
13283
+ ["maxCostUsd", "max-cost-usd"],
13284
+ ["maxCostIncreasePercent", "max-cost-increase-percent"],
13285
+ ["maxTokens", "max-tokens"]
13286
+ ]) {
13287
+ const n = limit2(flag2, opts[key]);
13288
+ if (n !== void 0) gateOpts[key] = n;
13169
13289
  }
13170
- out.push(...gatesConsole(d));
13171
- out.push(...adviceConsole(d));
13172
- out.push(summaryLine2(d));
13173
- return out.join("\n");
13174
- }
13175
- function renderDiffJson(d) {
13176
- return JSON.stringify(d, null, 2);
13177
- }
13178
- function renderDiff(d, format = "console") {
13179
- if (format === "json") return noCommandsJson(renderDiffJson(d));
13180
- if (format === "markdown") return noCommands(renderDiffMarkdown2(d));
13181
- return noCommands(renderDiffConsole(d));
13290
+ const baseline = loadRunResult(opts.baselinePath, "baseline");
13291
+ const current = loadRunResult(opts.currentPath, "current");
13292
+ const now = /* @__PURE__ */ new Date();
13293
+ const waivers = opts.waivers === void 0 ? [] : loadWaivers(opts.waivers, now);
13294
+ const diff2 = diffRuns(baseline, current);
13295
+ const advice = adviceFor(baseline, current);
13296
+ const withAdvice = advice === void 0 ? diff2 : { ...diff2, advice };
13297
+ if (!gatesEnabled(gateOpts)) return withAdvice;
13298
+ return { ...withAdvice, gates: evaluateGates(baseline, current, diff2, gateOpts, waivers, now) };
13182
13299
  }
13183
- var STICKY_MARKER, BADGE, GATE_STATE, capital, oneLine, cell2, target2, WORD, comparisonText, countsText, NOT_COMPARED, DIFFERED, COMMENT_BUDGET, IMPORTANCE, plural3;
13300
+ var fs14, DiffInputError;
13184
13301
  var init_diff4 = __esm({
13185
- "src/reporters/diff.ts"() {
13302
+ "src/cli/commands/diff.ts"() {
13186
13303
  "use strict";
13187
13304
  init_cjs_shims();
13188
- init_stats();
13189
- init_human();
13190
- STICKY_MARKER = "<!-- plune-eval-diff -->";
13191
- BADGE = {
13192
- regression: "\u{1F534} regression",
13193
- improvement: "\u{1F7E2} improvement",
13194
- "pre-existing-fail": "\u26AA pre-existing fail",
13195
- "new-fail": "\u{1F195} new fail",
13196
- "new-pass": "\u{1F7E2} new pass",
13197
- "stable-pass": "\u2705 stable",
13198
- errored: "\u26A0\uFE0F errored",
13199
- unmeasured: "\u26A0\uFE0F not measured",
13200
- removed: "\u2796 removed"
13201
- };
13202
- GATE_STATE = {
13203
- passed: { mark: "\u2705", text: "passed" },
13204
- failed: { mark: "\u274C", text: "failed" },
13205
- unmeasured: { mark: "\u26A0\uFE0F", text: "not measured" },
13206
- waived: { mark: "\u{1F7E1}", text: "waived" }
13207
- };
13208
- capital = (t) => t.charAt(0).toUpperCase() + t.slice(1);
13209
- oneLine = (t) => t.replace(/\s*[\r\n]+\s*/g, " ");
13210
- cell2 = (t) => oneLine(t).replace(/\|/g, "\\|");
13211
- target2 = (w, quote) => w.eval === void 0 ? w.gate : `${w.gate} of ${quote(w.eval)}`;
13212
- WORD = {
13213
- worse: "probably worse",
13214
- better: "probably better",
13215
- "no-difference": "no difference visible",
13216
- "too-few": "too few attempts"
13305
+ fs14 = __toESM(require("fs"), 1);
13306
+ init_diff3();
13307
+ init_advice();
13308
+ init_gates();
13309
+ init_waivers();
13310
+ DiffInputError = class extends Error {
13311
+ code = "DIFF_INPUT";
13312
+ constructor(message2) {
13313
+ super(message2);
13314
+ this.name = "DiffInputError";
13315
+ }
13217
13316
  };
13218
- comparisonText = (c) => `${WORD[c.word]}: ${c.reason}`;
13219
- countsText = (counts3) => Object.entries(counts3).sort(([a], [b]) => a < b ? -1 : 1).map(([tool2, n]) => `${oneLine(tool2)} ${n}`).join(", ") || "(no rows)";
13220
- NOT_COMPARED = "not compared";
13221
- DIFFERED = " (the descriptions of the tools differed between the runs: this is the experiment, not a change of the same thing)";
13222
- COMMENT_BUDGET = 6e4;
13223
- IMPORTANCE = [
13224
- "regression",
13225
- "errored",
13226
- "unmeasured",
13227
- "new-fail",
13228
- "removed",
13229
- "pre-existing-fail",
13230
- "improvement",
13231
- "new-pass",
13232
- "stable-pass"
13233
- ];
13234
- plural3 = (n, one, many) => `${n} ${n === 1 ? one : many}`;
13235
13317
  }
13236
13318
  });
13237
13319
 
@@ -16015,6 +16097,7 @@ function lintRun(report, showInfo) {
16015
16097
  id: f.rule,
16016
16098
  title: titles.get(f.rule) ?? f.rule,
16017
16099
  target: targetOf(f.target),
16100
+ ...f.target.tool === "" ? {} : { tool: f.target.tool },
16018
16101
  state: f.state,
16019
16102
  class: f.class,
16020
16103
  level: f.level,
@@ -16032,6 +16115,7 @@ function lintRun(report, showInfo) {
16032
16115
  id: r.id,
16033
16116
  title: r.description,
16034
16117
  target: target4,
16118
+ ...target4 === "" ? {} : { tool: target4 },
16035
16119
  state: state2,
16036
16120
  class: r.class,
16037
16121
  level: r.level,
@@ -16079,7 +16163,11 @@ function checkRun(report) {
16079
16163
  of("smoke", { state: "not-applicable", detail: "--smoke was not given" }, "", null)
16080
16164
  );
16081
16165
  else {
16082
- for (const c of calls) checks.push(of("smoke", c, c.tool, callMs.get(c.tool) ?? null));
16166
+ for (const c of calls)
16167
+ checks.push({
16168
+ ...of("smoke", c, c.tool, callMs.get(c.tool) ?? null),
16169
+ ...c.state === "not-applicable" ? {} : { tool: c.tool }
16170
+ });
16083
16171
  if (!calls.some((c) => c.state !== "not-applicable"))
16084
16172
  checks.push(
16085
16173
  of(
@@ -16118,6 +16206,7 @@ function diffRun(report) {
16118
16206
  id: c.id,
16119
16207
  title: c.title,
16120
16208
  target: ch.name === "" ? ch.entity : `${ch.entity} ${ch.name}`,
16209
+ ...ch.entity === "tool" && ch.name !== "" ? { tool: ch.name } : {},
16121
16210
  state: "failed",
16122
16211
  class: c.class,
16123
16212
  // What fails the run is an error; advice a warning, and every change listed again an info line.
@@ -16190,6 +16279,7 @@ var init_runs = __esm({
16190
16279
  ...c,
16191
16280
  title: printable(c.title),
16192
16281
  target: printable(c.target),
16282
+ ...c.tool === void 0 ? {} : { tool: printable(c.tool) },
16193
16283
  message: printable(c.message),
16194
16284
  expected: printable(c.expected),
16195
16285
  actual: printable(c.actual),
@@ -16406,7 +16496,9 @@ function casesOf(run) {
16406
16496
  specRef: "",
16407
16497
  durationMs: null
16408
16498
  };
16409
- return [{ id: "run", title: check5.title, outcome: outcomeOf2([check5]), durationMs: null }];
16499
+ return [
16500
+ { id: "run", title: check5.title, outcome: outcomeOf2([check5]), durationMs: null, tools: [] }
16501
+ ];
16410
16502
  }
16411
16503
  return run.cases.map(({ id: id2, title, suite }) => {
16412
16504
  const mine = run.checks.filter((c) => c.id === id2);
@@ -16416,6 +16508,7 @@ function casesOf(run) {
16416
16508
  title,
16417
16509
  ...suite === void 0 ? {} : { suite },
16418
16510
  outcome: outcomeOf2(mine),
16511
+ tools: toolsOf(mine),
16419
16512
  durationMs: timed.length === 0 ? null : timed.reduce((sum, c) => sum + (c.durationMs ?? 0), 0)
16420
16513
  };
16421
16514
  });
@@ -16497,8 +16590,17 @@ function junitXml(run) {
16497
16590
  const time = c.durationMs === null ? "" : ` time="${(c.durationMs / 1e3).toFixed(3)}"`;
16498
16591
  const classname = c.suite === void 0 ? `mcp.${run.command}` : `mcp.${run.command}.${c.suite}`;
16499
16592
  const head = ` <testcase classname="${xmlAttr(classname)}" name="${xmlAttr(c.id)}"${time}`;
16593
+ const properties = c.tools.length === 0 ? [] : [
16594
+ " <properties>",
16595
+ ...c.tools.map(
16596
+ (t) => ` <property name="plune.mcp.tool" value="${xmlAttr(t)}"/>`
16597
+ ),
16598
+ " </properties>"
16599
+ ];
16500
16600
  if (c.outcome.kind === "pass") {
16501
- lines.push(`${head}/>`);
16601
+ lines.push(
16602
+ ...properties.length === 0 ? [`${head}/>`] : [`${head}>`, ...properties, " </testcase>"]
16603
+ );
16502
16604
  continue;
16503
16605
  }
16504
16606
  const { checks } = c.outcome;
@@ -16508,6 +16610,7 @@ function junitXml(run) {
16508
16610
  ].join("\n\n");
16509
16611
  lines.push(
16510
16612
  `${head}>`,
16613
+ ...properties,
16511
16614
  ` <${c.outcome.kind} type="${xmlAttr(c.outcome.type)}" message="${xmlAttr(c.outcome.message)}">${xmlText(body)}</${c.outcome.kind}>`,
16512
16615
  " </testcase>"
16513
16616
  );
@@ -16516,7 +16619,7 @@ function junitXml(run) {
16516
16619
  return `${lines.join("\n")}
16517
16620
  `.replace(/^([\s\u0085]*)::/gm, "$1?::").replaceAll("##[", "##&#91;");
16518
16621
  }
16519
- var import_node_fs11, import_node_path6, firstLine3, COMMAND, shown, count3, detailOf2, ANNOTATION_LIMITS, MARKDOWN_ROWS, andMore, escapeData, escapeProperty, noLegacy, NOT_XML, xmlChars, xmlText, xmlAttr;
16622
+ var import_node_fs11, import_node_path6, firstLine3, COMMAND, shown, MAX_TOOLS, MAX_TOOL_LENGTH, keptTool, toolsOf, count3, detailOf2, ANNOTATION_LIMITS, MARKDOWN_ROWS, andMore, escapeData, escapeProperty, noLegacy, NOT_XML, xmlChars, xmlText, xmlAttr;
16520
16623
  var init_report2 = __esm({
16521
16624
  "src/mcp-testing/report/index.ts"() {
16522
16625
  "use strict";
@@ -16534,6 +16637,10 @@ var init_report2 = __esm({
16534
16637
  shown = (run) => run.checks.filter(
16535
16638
  (c) => c.state !== "passed" && c.state !== "not-applicable" && (c.level !== "info" || run.showInfo || c.state === "could-not-run")
16536
16639
  );
16640
+ MAX_TOOLS = 50;
16641
+ MAX_TOOL_LENGTH = 200;
16642
+ keptTool = (t) => t !== void 0 && t.trim() !== "" && t.trim().length <= MAX_TOOL_LENGTH;
16643
+ toolsOf = (checks) => [...new Set(checks.map((c) => c.tool).filter(keptTool))].sort().slice(0, MAX_TOOLS);
16537
16644
  count3 = (cases, kind2, type) => cases.filter(
16538
16645
  (c) => c.outcome.kind === kind2 && (type === void 0 || "type" in c.outcome && c.outcome.type === type)
16539
16646
  ).length;
@@ -32173,7 +32280,7 @@ function human(r) {
32173
32280
  out.push("", 'Not evaluated (this is not "no finding"):');
32174
32281
  for (const n of r.notEvaluated)
32175
32282
  out.push(
32176
- ` ${n.group}${n.rule === void 0 ? "" : ` ${n.rule}`}${n.target === "" ? "" : ` ${n.target}`}${n.path === void 0 ? "" : ` ${n.path}`}: ${n.reason}${n.kind === "could-not-run" ? "" : " [an input was not given]"}`
32283
+ ` ${n.group}${n.rule === void 0 ? "" : ` ${n.rule}`}${n.target === "" ? "" : ` ${n.target}`}${n.path === void 0 ? "" : ` ${n.path}`}: ${n.reason}${n.kind === "missing-input" ? " [an input was not given]" : ""}`
32177
32284
  );
32178
32285
  }
32179
32286
  if (r.probes.rows.length > 0) {
@@ -32904,7 +33011,9 @@ function runScanUncached(input, opts) {
32904
33011
  couldNot("active", "", "the journal (--journal) could not be written: it is incomplete");
32905
33012
  for (const row of section.rows)
32906
33013
  if (row.outcome === "not-run")
32907
- couldNot("active", safeText(row.id), PROBE_REASONS[row.reason]);
33014
+ couldNot("active", safeText(row.id), PROBE_REASONS[row.reason], {
33015
+ ...row.reason === "stdio" ? { kind: "not-applicable" } : {}
33016
+ });
32908
33017
  for (const f of section.findings)
32909
33018
  drafts.push({
32910
33019
  rule: f.rule,
@@ -35728,8 +35837,8 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
35728
35837
  async (baseline, current, options, command) => {
35729
35838
  const verbose = command.optsWithGlobals().verbose === true;
35730
35839
  const [{ handleDiff: handleDiff2, DiffInputError: DiffInputError2 }, { renderDiff: renderDiff2 }] = await Promise.all([
35731
- Promise.resolve().then(() => (init_diff3(), diff_exports)),
35732
- Promise.resolve().then(() => (init_diff4(), diff_exports2))
35840
+ Promise.resolve().then(() => (init_diff4(), diff_exports2)),
35841
+ Promise.resolve().then(() => (init_diff2(), diff_exports))
35733
35842
  ]);
35734
35843
  try {
35735
35844
  const { format: _format, output: _output, ...gateFlags } = options;
@@ -35948,7 +36057,7 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
35948
36057
  mcp.command("conformance").description(
35949
36058
  "Check any MCP server against the specification, check by check, with a score: exit 1 on a failed MUST, 3 when conformance is not established"
35950
36059
  )
35951
- ).option("--suite <suite>", "protocol (default), oauth, tasks or apps; repeatable", repeat).option("--check <id>", "Run only this check; repeatable", repeat).option("--protocol-version <revision>", "The revision to check against, or auto (the one the server answers with)", "auto").option("--profile <version>", "The score profile: 2026-11.3 (default, with the Streamable HTTP checks) or 2026-11.2 (the score before them)").option("--format <format>", "What to print: human or json", "human").option("--reporter <reporter>", "junit-xml: a bare --out <path> is written as JUnit XML instead of JSON").option(
36060
+ ).option("--suite <suite>", "protocol (default), oauth, tasks or apps; repeatable", repeat).option("--check <id>", "Run only this check; repeatable", repeat).option("--protocol-version <revision>", "The revision to check against, or auto (the one the server answers with)", "auto").option("--profile <version>", "The score profile: 2026-11.4 (default, with the 2026-07-28 checks), 2026-11.3 (the score before them) or 2026-11.2 (before the Streamable HTTP checks)").option("--format <format>", "What to print: human or json", "human").option("--reporter <reporter>", "junit-xml: a bare --out <path> is written as JUnit XML instead of JSON").option(
35952
36061
  "--out <[format=]path>",
35953
36062
  "Also write the result to this file, as json or junit-xml (default json); repeatable, one run for every file, secrets masked",
35954
36063
  repeat