@plune-ai/cli 0.39.2 → 0.39.4

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
@@ -1102,7 +1102,29 @@ var init_prices = __esm({
1102
1102
  // OpenRouter has hundreds of models and dynamic routing, so most still need a `pricing` entry
1103
1103
  // in plune.yaml (or report cost_usd=0). Verify against OpenRouter's current rates.
1104
1104
  "openai/gpt-4o": { input_per_1k_usd: 25e-4, output_per_1k_usd: 0.01 },
1105
- "openai/gpt-4o-mini": { input_per_1k_usd: 15e-5, output_per_1k_usd: 6e-4 }
1105
+ "openai/gpt-4o-mini": { input_per_1k_usd: 15e-5, output_per_1k_usd: 6e-4 },
1106
+ // Via OpenRouter, the models the agent scenarios workflow can be run on. Source:
1107
+ // https://openrouter.ai/api/v1/models (`pricing`, USD per token), read on 2026-11-18, kept here
1108
+ // per thousand. A real OpenRouter call reports its own cost, which wins over these; they price a
1109
+ // dry run and any call that reports none. Long prompts may cost more on some of them.
1110
+ // The cheap set:
1111
+ "deepseek/deepseek-v4-flash": { input_per_1k_usd: 9e-5, output_per_1k_usd: 18e-5 },
1112
+ "qwen/qwen3.7-flash": { input_per_1k_usd: 3e-5, output_per_1k_usd: 13e-5 },
1113
+ "google/gemini-2.5-flash-lite": { input_per_1k_usd: 1e-4, output_per_1k_usd: 4e-4 },
1114
+ "mistralai/mistral-small-3.2-24b-instruct": {
1115
+ input_per_1k_usd: 75e-6,
1116
+ output_per_1k_usd: 2e-4
1117
+ },
1118
+ "openai/gpt-oss-120b": { input_per_1k_usd: 15e-5, output_per_1k_usd: 6e-4 },
1119
+ "anthropic/claude-haiku-5.5": { input_per_1k_usd: 1e-4, output_per_1k_usd: 5e-4 },
1120
+ "z-ai/glm-5.3-flash": { input_per_1k_usd: 399e-7, output_per_1k_usd: 784e-7 },
1121
+ // The middle set:
1122
+ "moonshotai/kimi-k2.6": { input_per_1k_usd: 65e-5, output_per_1k_usd: 341e-5 },
1123
+ "minimax/minimax-m3": { input_per_1k_usd: 3e-4, output_per_1k_usd: 12e-4 },
1124
+ "qwen/qwen3.7-plus": { input_per_1k_usd: 32e-5, output_per_1k_usd: 128e-5 },
1125
+ "google/gemini-3.8-flash": { input_per_1k_usd: 825e-6, output_per_1k_usd: 4125e-6 },
1126
+ "deepseek/deepseek-v4-pro": { input_per_1k_usd: 9e-4, output_per_1k_usd: 15e-4 },
1127
+ "openai/gpt-6.1-terra": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 }
1106
1128
  };
1107
1129
  }
1108
1130
  });
@@ -6856,13 +6878,13 @@ var init_catalog = __esm({
6856
6878
  });
6857
6879
 
6858
6880
  // src/mcp-testing/conformance/profile.ts
6859
- var import_node_crypto2, PROFILE, manifestDigest;
6881
+ var import_node_crypto2, PROFILE_2026_11_2, PROFILE_2026_11_3, PROFILE_2026_11_4, PROFILE, PROFILES, profileOf, manifestDigest;
6860
6882
  var init_profile = __esm({
6861
6883
  "src/mcp-testing/conformance/profile.ts"() {
6862
6884
  "use strict";
6863
6885
  init_cjs_shims();
6864
6886
  import_node_crypto2 = require("crypto");
6865
- PROFILE = {
6887
+ PROFILE_2026_11_2 = {
6866
6888
  id: "plune-mcp-conformance",
6867
6889
  version: "2026-11.2",
6868
6890
  checks: [
@@ -6885,6 +6907,98 @@ var init_profile = __esm({
6885
6907
  "stdio-stdout-clean"
6886
6908
  ]
6887
6909
  };
6910
+ PROFILE_2026_11_3 = {
6911
+ id: "plune-mcp-conformance",
6912
+ version: "2026-11.3",
6913
+ checks: [
6914
+ "life-initialize-result",
6915
+ "life-version-negotiation",
6916
+ "life-capabilities-declared-served",
6917
+ "life-capabilities-served-declared",
6918
+ "life-ping-empty-result",
6919
+ "base-jsonrpc-parse-error",
6920
+ "base-unknown-method-error",
6921
+ "base-response-id-matches",
6922
+ "tools-list-shape",
6923
+ "tools-input-schema-valid",
6924
+ "tools-output-schema-valid",
6925
+ "tools-structured-conformant",
6926
+ "resources-list-shape",
6927
+ "resources-read-listed",
6928
+ "resources-templates-shape",
6929
+ "prompts-list-shape",
6930
+ "stdio-stdout-clean",
6931
+ "http-notification-202",
6932
+ "http-request-content-type",
6933
+ "http-response-utf8",
6934
+ "http-single-endpoint",
6935
+ "http-get-stream-or-405",
6936
+ "http-session-id-visible-ascii",
6937
+ "http-protocol-version-header-invalid-400",
6938
+ "http-concurrent-posts-matched",
6939
+ "http-sse-event-ids-unique",
6940
+ "http-sse-no-server-requests",
6941
+ "http-close-cancels",
6942
+ "http-session-terminated-404",
6943
+ "http-sse-no-broadcast",
6944
+ "http-origin-invalid-403"
6945
+ ]
6946
+ };
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];
7001
+ profileOf = (version2) => PROFILES.find((p) => p.version === version2);
6888
7002
  manifestDigest = (ids) => (0, import_node_crypto2.createHash)("sha256").update([...ids].sort().join("\n")).digest("hex");
6889
7003
  }
6890
7004
  });
@@ -7882,6 +7996,344 @@ var init_helpers = __esm({
7882
7996
  }
7883
7997
  });
7884
7998
 
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) };
8007
+ }
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;
8012
+ return {
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)
8016
+ };
8017
+ }
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";
8048
+ return {
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}`
8055
+ };
8056
+ }
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;
8091
+ }
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);
8098
+ }
8099
+ function waiverLines(d, quote, text6) {
8100
+ const { applied, expired, unused } = d.gates.waivers;
8101
+ return [
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)}`)
8105
+ ];
8106
+ }
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;
8127
+ }
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}`);
8136
+ }
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
+
7885
8337
  // src/reporters/matrix.ts
7886
8338
  function median(xs) {
7887
8339
  if (xs.length === 0) return void 0;
@@ -7893,6 +8345,7 @@ function cellOf(ev) {
7893
8345
  let passed2 = 0;
7894
8346
  let total = 0;
7895
8347
  let cost2 = 0;
8348
+ let priced = false;
7896
8349
  const latencies = [];
7897
8350
  const states = /* @__PURE__ */ new Set();
7898
8351
  for (const row of ev.rows) {
@@ -7901,6 +8354,7 @@ function cellOf(ev) {
7901
8354
  status2 === "passed" ? "pass" : status2 === "failed" ? "fail" : status2 === "errored" ? "error" : "unmeasured"
7902
8355
  );
7903
8356
  cost2 += row.usage?.cost_usd ?? 0;
8357
+ if (row.usage?.priced === true) priced = true;
7904
8358
  const a = row.attempts;
7905
8359
  if (a !== void 0 && a.results.length > 0) {
7906
8360
  passed2 += a.passed;
@@ -7920,6 +8374,7 @@ function cellOf(ev) {
7920
8374
  passed: passed2,
7921
8375
  total,
7922
8376
  cost_usd: cost2,
8377
+ priced,
7923
8378
  ...latency !== void 0 ? { latency_ms: latency } : {}
7924
8379
  };
7925
8380
  }
@@ -7954,12 +8409,12 @@ function formatLatency(ms) {
7954
8409
  }
7955
8410
  function cellText(cell3, dry = false) {
7956
8411
  if (cell3 === null) return EMPTY_CELL;
7957
- const cost2 = `$${cell3.cost_usd.toFixed(4)}`;
8412
+ const cost2 = cell3.priced ? `$${cell3.cost_usd.toFixed(4)}` : `cost ${NOT_MEASURED}`;
7958
8413
  if (dry) return cost2;
7959
8414
  const head = cell3.state === "unmeasured" ? CELL_LABEL.unmeasured : `${CELL_LABEL[cell3.state]} ${cell3.passed}/${cell3.total}`;
7960
8415
  return [head, cost2, ...cell3.latency_ms !== void 0 ? [formatLatency(cell3.latency_ms)] : []].join(" \xB7 ");
7961
8416
  }
7962
- function matrixMarkdown(m, dry = false) {
8417
+ function matrixMarkdown2(m, dry = false) {
7963
8418
  return [
7964
8419
  `| Eval | ${m.models.map((x) => mdCell(x.model)).join(" | ")} |`,
7965
8420
  `| --- | ${m.models.map(() => "---").join(" | ")} |`,
@@ -7980,6 +8435,7 @@ var init_matrix = __esm({
7980
8435
  init_cjs_shims();
7981
8436
  init_results();
7982
8437
  init_helpers();
8438
+ init_diff2();
7983
8439
  STATE_ORDER = ["error", "fail", "unmeasured", "pass"];
7984
8440
  CELL_LABEL = {
7985
8441
  pass: "PASS",
@@ -8129,7 +8585,7 @@ function renderMarkdown(result2, opts = {}) {
8129
8585
  const matrix2 = buildMatrix(result2);
8130
8586
  if (matrix2 !== void 0) {
8131
8587
  out.splice(out.length - 1, 0, `| Models | ${matrix2.models.length} |`);
8132
- out.push("", "## Estimated cost per model", "", ...matrixMarkdown(matrix2, true));
8588
+ out.push("", "## Estimated cost per model", "", ...matrixMarkdown2(matrix2, true));
8133
8589
  }
8134
8590
  const repeated2 = result2.evals.flatMap(
8135
8591
  (ev) => ev.rows.flatMap((row) => {
@@ -8154,7 +8610,7 @@ function renderMarkdown(result2, opts = {}) {
8154
8610
  out.push(`| Duration (ms) | ${summary.duration_ms} |`);
8155
8611
  out.push("");
8156
8612
  const matrix = buildMatrix(result2);
8157
- if (matrix !== void 0) out.push("## Model matrix", "", ...matrixMarkdown(matrix), "");
8613
+ if (matrix !== void 0) out.push("## Model matrix", "", ...matrixMarkdown2(matrix), "");
8158
8614
  const repeated = result2.evals.flatMap(
8159
8615
  (ev) => ev.rows.flatMap(
8160
8616
  (row) => row.attempts !== void 0 ? [{ id: ev.id, row, a: row.attempts }] : []
@@ -8468,6 +8924,7 @@ function createClient(opts) {
8468
8924
  upload: (path25, bytes, contentType2) => send3("POST", path25, { body: bytes, type: contentType2 }, uploadRetries ?? DEFAULT_RETRIES),
8469
8925
  del: (path25) => send3("DELETE", path25),
8470
8926
  get: (path25) => send3("GET", path25),
8927
+ patch: (path25, body) => send3("PATCH", path25, { body: JSON.stringify(body), type: "application/json" }),
8471
8928
  async put(url, headers, source) {
8472
8929
  const putRetries = uploadRetries ?? 3;
8473
8930
  let last = { ok: false, status: null, code: "network" };
@@ -8729,6 +9186,180 @@ var init_files_batch = __esm({
8729
9186
  }
8730
9187
  });
8731
9188
 
9189
+ // src/reporter-core/code-snapshot.ts
9190
+ function skipString(src, i, quote) {
9191
+ for (let j = i + 1; j < src.length; j += 1) {
9192
+ const c = src[j];
9193
+ if (c === "\\") j += 1;
9194
+ else if (c === quote) return j + 1;
9195
+ else if (c === "\n") return -1;
9196
+ }
9197
+ return -1;
9198
+ }
9199
+ function skipTemplate(src, i) {
9200
+ for (let j = i + 1; j < src.length; j += 1) {
9201
+ const c = src[j];
9202
+ if (c === "\\") j += 1;
9203
+ else if (c === "`") return j + 1;
9204
+ else if (c === "$" && src[j + 1] === "{") {
9205
+ const end2 = matching(src, j + 2, "}");
9206
+ if (end2 < 0) return -1;
9207
+ j = end2;
9208
+ }
9209
+ }
9210
+ return -1;
9211
+ }
9212
+ function skipRegex(src, i) {
9213
+ let inClass = false;
9214
+ for (let j = i + 1; j < src.length; j += 1) {
9215
+ const c = src[j];
9216
+ if (c === "\\") j += 1;
9217
+ else if (c === "\n") return -1;
9218
+ else if (c === "[") inClass = true;
9219
+ else if (c === "]") inClass = false;
9220
+ else if (c === "/" && !inClass) {
9221
+ let k = j + 1;
9222
+ while (k < src.length && /[a-z]/i.test(src[k])) k += 1;
9223
+ return k;
9224
+ }
9225
+ }
9226
+ return -1;
9227
+ }
9228
+ function matching(src, i, close) {
9229
+ const stack = [close];
9230
+ let prev = "(";
9231
+ while (i < src.length) {
9232
+ const c = src[i];
9233
+ const next = src[i + 1];
9234
+ let to = -2;
9235
+ if (c === "/" && next === "/") to = src.indexOf("\n", i);
9236
+ else if (c === "/" && next === "*")
9237
+ to = src.indexOf("*/", i + 2) < 0 ? -1 : src.indexOf("*/", i + 2) + 2;
9238
+ else if (c === "'" || c === '"') to = skipString(src, i, c);
9239
+ else if (c === "`") to = skipTemplate(src, i);
9240
+ else if (c === "/" && BEFORE_REGEX.has(prev)) to = skipRegex(src, i);
9241
+ if (to === -1) return -1;
9242
+ if (to !== -2) {
9243
+ if (c !== "/" || next !== "/" && next !== "*") prev = "a";
9244
+ i = to;
9245
+ continue;
9246
+ }
9247
+ if (c === "(") stack.push(")");
9248
+ else if (c === "[") stack.push("]");
9249
+ else if (c === "{") stack.push("}");
9250
+ else if (c === ")" || c === "]" || c === "}") {
9251
+ if (stack.pop() !== c) return -1;
9252
+ if (stack.length === 0) return i;
9253
+ }
9254
+ if (!/\s/.test(c)) prev = c;
9255
+ i += 1;
9256
+ }
9257
+ return -1;
9258
+ }
9259
+ function callTextAt(source, line, column) {
9260
+ const lines = source.split("\n");
9261
+ if (line < 1 || line > lines.length) return void 0;
9262
+ const lineStart = lines.slice(0, line - 1).reduce((n, l) => n + l.length + 1, 0);
9263
+ const lineEnd = lineStart + lines[line - 1].length;
9264
+ const heads = [];
9265
+ CALL.lastIndex = lineStart;
9266
+ for (let h = CALL.exec(source); h !== null && h.index < lineEnd; h = CALL.exec(source))
9267
+ heads.push(h);
9268
+ const at2 = column === void 0 ? -1 : lineStart + column - 1;
9269
+ const head = heads.find((h) => h.index <= at2 && at2 < h.index + h[0].length) ?? (heads.length === 1 ? heads[0] : void 0);
9270
+ if (head === void 0) return void 0;
9271
+ const end2 = matching(source, head.index + head[0].length, ")");
9272
+ if (end2 < 0) return void 0;
9273
+ const text6 = source.slice(head.index, end2 + 1).replace(/\r\n/g, "\n");
9274
+ return Buffer.byteLength(text6, "utf8") <= SNAPSHOT_MAX_BYTES ? text6 : void 0;
9275
+ }
9276
+ function maskCredentials(text6) {
9277
+ let out = text6;
9278
+ for (const { kind: kind2, re } of SHAPES) out = out.replace(re, `\u2039${kind2}\u203A`);
9279
+ for (const re of PLACES) {
9280
+ out = out.replace(re, (...args) => {
9281
+ const groups = args.at(-1);
9282
+ return `${groups.lead}${groups.q}\u2039${groups.role.toLowerCase().replace(/^[^a-z]+/, "")}\u203A${groups.q}`;
9283
+ });
9284
+ }
9285
+ return out.replace(HEADER_LINE, "$1$2$3\u2039header\u203A").replace(/\b(Bearer)([ \t]+)(?!‹)[\w.~+/=-]{8,}/g, "$1$2\u2039credential\u203A").replace(
9286
+ /\b(Basic|Token)([ \t]+)(?!‹)(?=[\w.~+/=-]*[\d=+/]|[\w.~+/=-]*[a-z][\w.~+/=-]*[A-Z])[\w.~+/=-]{8,}/g,
9287
+ "$1$2\u2039credential\u203A"
9288
+ ).replace(/\b(PLUNE_[A-Z0-9_]*=)(?!‹)[^\s'"\x60;,)]+/g, "$1\u2039env-secret\u203A").replace(QUERY_PARAM, "$1\u2039credential\u203A").replace(/\b([a-z][\w+.-]*:\/\/)[^\s/@'"\x60]+@/gi, "$1\u2039credential\u203A@");
9289
+ }
9290
+ function snapshotAt(at2, files) {
9291
+ let source = files.get(at2.file);
9292
+ if (source === void 0) {
9293
+ try {
9294
+ source = (0, import_node_fs8.readFileSync)(at2.file, "utf8");
9295
+ } catch {
9296
+ source = null;
9297
+ }
9298
+ files.set(at2.file, source);
9299
+ }
9300
+ if (source === null) return void 0;
9301
+ const text6 = callTextAt(source, at2.line, at2.column);
9302
+ if (text6 === void 0) return void 0;
9303
+ const masked = maskCredentials(text6);
9304
+ return Buffer.byteLength(masked, "utf8") <= SNAPSHOT_MAX_BYTES ? masked : void 0;
9305
+ }
9306
+ var import_node_fs8, SNAPSHOT_MAX_BYTES, CALL, BEFORE_REGEX, CREDENTIAL, LITERAL, TYPING, SHAPES, PLACES, HEADER_LINE, QUERY_PARAM;
9307
+ var init_code_snapshot = __esm({
9308
+ "src/reporter-core/code-snapshot.ts"() {
9309
+ "use strict";
9310
+ init_cjs_shims();
9311
+ import_node_fs8 = require("fs");
9312
+ SNAPSHOT_MAX_BYTES = 16384;
9313
+ CALL = /\b(?:test|it)(?:\.(?:skip|fixme|only|fail|slow))?\s*\(/g;
9314
+ BEFORE_REGEX = /* @__PURE__ */ new Set([..."(,=:[!&|?{};+-*%<>~^"]);
9315
+ CREDENTIAL = "password|passphrase|passwd|pass|pwd|token|secret|api[-_]?key|private[-_]?key|credential|auth|session|cookie";
9316
+ LITERAL = String.raw`(?<q>['"\x60])(?:\\.|(?!\k<q>)[^\\\n])*\k<q>`;
9317
+ TYPING = "(?:fill|type|pressSequentially)";
9318
+ SHAPES = [
9319
+ { kind: "github-token", re: /\b(?:ghp|gho|ghs|ghu)_[A-Za-z0-9]{36}\b|\bgithub_pat_\w{20,}/g },
9320
+ { kind: "api-key", re: /\bsk-[\w-]{20,}/g },
9321
+ { kind: "api-key", re: /\b[sr]k_(?:live|test)_[A-Za-z0-9]{10,}/g },
9322
+ { kind: "npm-token", re: /\bnpm_[A-Za-z0-9]{20,}/g },
9323
+ { kind: "google-key", re: /\bAIza[\w-]{30,}/g },
9324
+ { kind: "plune-token", re: /\bplune_[A-Za-z0-9_]{16,}/g },
9325
+ { kind: "aws-key", re: /\bAKIA[0-9A-Z]{16}\b/g },
9326
+ { kind: "slack-token", re: /\bxox[abprs]-[A-Za-z0-9-]{10,}/g },
9327
+ {
9328
+ kind: "private-key",
9329
+ re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g
9330
+ },
9331
+ { kind: "jwt", re: /\beyJ[\w-]{10,}\.[\w-]{10,}\.[\w-]{10,}/g }
9332
+ ];
9333
+ PLACES = [
9334
+ // `password = '…'`, `apiKey: "…"`, `'x-api-key': '…'`
9335
+ new RegExp(
9336
+ String.raw`(?<lead>\b(?<role>[\w$-]*(?:${CREDENTIAL})[\w$-]*)['"]?\s*[:=]\s*)${LITERAL}`,
9337
+ "gi"
9338
+ ),
9339
+ // `setToken('…')`: the call is named for a credential
9340
+ new RegExp(String.raw`(?<lead>\b(?<role>[\w$]*(?:${CREDENTIAL})[\w$]*)\s*\(\s*)${LITERAL}`, "gi"),
9341
+ // `.fill('#password', '…')`, `.type('#pwd', '…')`: the field is named in the same call
9342
+ new RegExp(
9343
+ String.raw`(?<lead>\.${TYPING}\(\s*['"][^'"\n]*?(?<role>${CREDENTIAL})[^'"\n]*['"]\s*,\s*)${LITERAL}`,
9344
+ "gi"
9345
+ ),
9346
+ // `getByLabel('Password').fill('…')`, `getByRole('textbox', { name: 'Password' }).type('…')`: … or
9347
+ // anywhere in the call the typing is chained off
9348
+ new RegExp(
9349
+ String.raw`(?<lead>\([^()\n]*?(?<role>${CREDENTIAL})[^()\n]*\)\s*\.${TYPING}\(\s*)${LITERAL}`,
9350
+ "gi"
9351
+ ),
9352
+ // `{ name: 'session', value: '…' }`: a cookie (or any name/value pair) named for a credential
9353
+ new RegExp(
9354
+ String.raw`(?<lead>\bname\s*:\s*['"][^'"\n]*?(?<role>${CREDENTIAL})[^'"\n]*['"]\s*,\s*value\s*:\s*)${LITERAL}`,
9355
+ "gi"
9356
+ )
9357
+ ];
9358
+ HEADER_LINE = /((?:^|\\[nr]|\x60)[ \t>*<+-]*['"]?)((?:proxy-)?authorization|(?:set-)?cookie|[\w-]*session[\w-]*)(['"]?[ \t]*:[ \t]*)(?![\w$.]+(?:\([^()\n]*\))?[ \t]*[,;)}\]])[^\s'"\x60\\][^\r\n'"\x60\\]*/gim;
9359
+ QUERY_PARAM = /([?&][\w.-]*(?:token|key|secret|password|passwd|pass|pwd|auth|signature|sig|credential|session)[\w.-]*=)(?!‹)[^&#\s'"\x60]+/gi;
9360
+ }
9361
+ });
9362
+
8732
9363
  // src/reporter-core/session.ts
8733
9364
  function nameOf(file) {
8734
9365
  const own3 = file.name.split(/[\\/]/).pop()?.trim() || (file.path === void 0 ? "" : (0, import_node_path5.basename)(file.path));
@@ -8768,7 +9399,13 @@ function textRefusal(bytes) {
8768
9399
  }
8769
9400
  return void 0;
8770
9401
  }
8771
- 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);
8772
9409
  if (!("files" in result2) || result2.files === void 0) return result2;
8773
9410
  const { files, ...rest } = result2;
8774
9411
  const kept = files.filter((f) => f.path !== void 0).map(({ body: _body, ...file }) => file);
@@ -8878,7 +9515,7 @@ function fileSender(options) {
8878
9515
  if (job.body !== void 0) bytes = job.body;
8879
9516
  else {
8880
9517
  try {
8881
- bytes = await import_node_fs8.promises.readFile(job.path);
9518
+ bytes = await import_node_fs9.promises.readFile(job.path);
8882
9519
  } catch {
8883
9520
  return skip(kind2, job.name, "missing");
8884
9521
  }
@@ -8933,7 +9570,7 @@ function fileSender(options) {
8933
9570
  else if (job.path === void 0) return void skip(kind2, job.name, "missing");
8934
9571
  else {
8935
9572
  try {
8936
- size = (await import_node_fs8.promises.stat(job.path)).size;
9573
+ size = (await import_node_fs9.promises.stat(job.path)).size;
8937
9574
  } catch {
8938
9575
  return void skip(kind2, job.name, "missing");
8939
9576
  }
@@ -8989,7 +9626,7 @@ function fileSender(options) {
8989
9626
  else if (job.path === void 0) return void skip(job.kind, job.name, "missing");
8990
9627
  else {
8991
9628
  try {
8992
- size = (await import_node_fs8.promises.stat(job.path)).size;
9629
+ size = (await import_node_fs9.promises.stat(job.path)).size;
8993
9630
  } catch {
8994
9631
  return void skip(job.kind, job.name, "missing");
8995
9632
  }
@@ -9163,7 +9800,7 @@ function fileSender(options) {
9163
9800
  }
9164
9801
  let data;
9165
9802
  try {
9166
- data = job.body ?? await import_node_fs8.promises.readFile(job.path);
9803
+ data = job.body ?? await import_node_fs9.promises.readFile(job.path);
9167
9804
  } catch {
9168
9805
  skip(kind2, job.name, "missing");
9169
9806
  continue;
@@ -9317,8 +9954,12 @@ async function startRun(passed2, declared2) {
9317
9954
  let runId = null;
9318
9955
  let joined = false;
9319
9956
  let offline = token2 === "";
9957
+ let targetsRefused = false;
9320
9958
  let done = false;
9321
9959
  const shortened = /* @__PURE__ */ new Set();
9960
+ const specFiles = /* @__PURE__ */ new Map();
9961
+ const snapshotByKey = /* @__PURE__ */ new Map();
9962
+ const snapshots = /* @__PURE__ */ new Map();
9322
9963
  function bound(keys) {
9323
9964
  return keys.map((key) => {
9324
9965
  const fit = boundKey(key);
@@ -9472,6 +10113,8 @@ async function startRun(passed2, declared2) {
9472
10113
  const { keys: _keys, files: files2, ...rest } = pending;
9473
10114
  submissions.push({ ...rest, testCaseId: r.id });
9474
10115
  if (files2 !== void 0) filesByKey.set(pending.resultKey, files2);
10116
+ const text6 = snapshotByKey.get(pending.resultKey);
10117
+ if (text6 !== void 0) snapshots.set(r.id, text6);
9475
10118
  }
9476
10119
  if (submissions.length > 0) {
9477
10120
  const before = stats.deferred;
@@ -9481,6 +10124,46 @@ async function startRun(passed2, declared2) {
9481
10124
  }
9482
10125
  }
9483
10126
  }
10127
+ async function syncSnapshots() {
10128
+ if (snapshots.size === 0 || offline) return;
10129
+ const stored = /* @__PURE__ */ new Map();
10130
+ let cursor = null;
10131
+ do {
10132
+ const query = `type=automated&stability=0&limit=200${cursor === null ? "" : `&cursor=${encodeURIComponent(cursor)}`}`;
10133
+ const out = await client.get(`/v1/test-cases?${query}`);
10134
+ if (!out.ok || !Array.isArray(out.body?.testCases)) {
10135
+ log(`plune: could not update the code snapshots (${out.ok ? "the case list had no cases" : out.detail || out.kind}).`);
10136
+ return;
10137
+ }
10138
+ for (const row of out.body.testCases) {
10139
+ if (typeof row?.id === "string" && snapshots.has(row.id)) stored.set(row.id, row.codeSnapshotHash ?? null);
10140
+ }
10141
+ cursor = typeof out.body.nextCursor === "string" ? out.body.nextCursor : null;
10142
+ } while (cursor !== null && stored.size < snapshots.size);
10143
+ const sha = (text6) => (0, import_node_crypto4.createHash)("sha256").update(text6).digest("hex");
10144
+ const due = [...snapshots].filter(([id2, text6]) => stored.has(id2) && stored.get(id2) !== sha(text6)).sort(([a], [b]) => sha(`${runId}:${a}`).localeCompare(sha(`${runId}:${b}`)));
10145
+ let updated = 0;
10146
+ let refused = 0;
10147
+ let tried = 0;
10148
+ for (const [id2, text6] of due.slice(0, SNAPSHOT_UPDATES_MAX)) {
10149
+ tried += 1;
10150
+ const out = await client.patch(`/v1/test-cases/${encodeURIComponent(id2)}`, { codeSnapshot: text6 });
10151
+ if (out.ok) {
10152
+ updated += 1;
10153
+ continue;
10154
+ }
10155
+ if (out.kind === "auth" || out.kind === "unavailable" || out.status === 429) {
10156
+ log(`plune: could not update the code snapshot of test case ${id2} (${out.detail || out.kind}); the rest are left as they are.`);
10157
+ break;
10158
+ }
10159
+ refused += 1;
10160
+ }
10161
+ const left = due.length - tried;
10162
+ const parts = [`${updated} code snapshot(s) updated`];
10163
+ if (refused > 0) parts.push(`${refused} not updated`);
10164
+ if (left > 0 && tried === Math.min(due.length, SNAPSHOT_UPDATES_MAX)) parts.push(`${left} left for the next run`);
10165
+ if (updated + refused > 0) log(`plune: ${parts.join(", ")}`);
10166
+ }
9484
10167
  const sending = /* @__PURE__ */ new Set();
9485
10168
  let sendError;
9486
10169
  let answered = false;
@@ -9523,6 +10206,8 @@ async function startRun(passed2, declared2) {
9523
10206
  if (match.kind === "found") {
9524
10207
  const { keys: _keys, files: files2, ...rest } = result2;
9525
10208
  submissions.push({ ...rest, testCaseId: match.testCaseId });
10209
+ const text6 = snapshotByKey.get(result2.resultKey);
10210
+ if (text6 !== void 0) snapshots.set(match.testCaseId, text6);
9526
10211
  if (files2 !== void 0) filesByKey.set(result2.resultKey, files2);
9527
10212
  } else if (match.kind === "unmatched") {
9528
10213
  stats.unresolved += 1;
@@ -9539,16 +10224,24 @@ async function startRun(passed2, declared2) {
9539
10224
  await send3(submissions, filesByKey);
9540
10225
  }
9541
10226
  async function send3(submissions, filesByKey) {
9542
- for (const part of packed(submissions)) {
10227
+ for (const packedPart of packed(submissions)) {
10228
+ let part = targetsRefused ? packedPart.map(withoutTargets) : packedPart;
9543
10229
  if (offline) {
9544
10230
  defer(part);
9545
10231
  continue;
9546
10232
  }
9547
- const out = await client.post(
10233
+ const post = (results4) => client.post(
9548
10234
  `/v1/runs/${runId}/results`,
9549
10235
  // The job's combination on every batch; a refusal of it is a 422 said below as it came.
9550
- { results: part, ...configuration !== void 0 ? { configuration } : {} }
10236
+ { results: results4, ...configuration !== void 0 ? { configuration } : {} }
9551
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
+ }
9552
10245
  const counts3 = out.ok ? out.body?.counts : void 0;
9553
10246
  const told = COUNTED.filter((k) => typeof counts3?.[k] === "number");
9554
10247
  if (told.length > 0) {
@@ -9628,7 +10321,10 @@ async function startRun(passed2, declared2) {
9628
10321
  return stats;
9629
10322
  },
9630
10323
  async add(result2) {
9631
- buffer.push({ ...result2, keys: bound(result2.keys) });
10324
+ const { codeAt, ...rest } = result2;
10325
+ const text6 = codeAt === void 0 ? void 0 : snapshotAt(codeAt, specFiles);
10326
+ if (text6 !== void 0) snapshotByKey.set(result2.resultKey, text6);
10327
+ buffer.push({ ...rest, keys: bound(result2.keys) });
9632
10328
  if (buffer.length >= batchSize) await flushBuffer();
9633
10329
  },
9634
10330
  flush,
@@ -9637,6 +10333,7 @@ async function startRun(passed2, declared2) {
9637
10333
  done = true;
9638
10334
  await flush();
9639
10335
  await offer();
10336
+ await syncSnapshots();
9640
10337
  let frozen;
9641
10338
  if (runId !== null && !offline) {
9642
10339
  const out = await client.post(`/v1/runs/${runId}/events`, {
@@ -9660,6 +10357,7 @@ async function startRun(passed2, declared2) {
9660
10357
  done = true;
9661
10358
  await flush();
9662
10359
  await offer();
10360
+ await syncSnapshots();
9663
10361
  let frozen;
9664
10362
  const after = [];
9665
10363
  const shard = env.shard;
@@ -9694,13 +10392,13 @@ async function startRun(passed2, declared2) {
9694
10392
  }
9695
10393
  };
9696
10394
  }
9697
- var import_node_crypto4, import_node_fs8, import_node_path5, import_node_util2, RESOLVE_CHUNK, BATCH_MAX, DISCOVER_MAX, BATCH_DEFAULT, 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, METADATA_TYPE2, NAME_MAX, SKIPPED, BUCKET_FOUND, KINDS, codeOf2, keyId, BATCH_BYTES, ENVELOPE_BYTES;
10395
+ 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, METADATA_TYPE2, NAME_MAX, SKIPPED, BUCKET_FOUND, KINDS, codeOf2, keyId, BATCH_BYTES, ENVELOPE_BYTES;
9698
10396
  var init_session2 = __esm({
9699
10397
  "src/reporter-core/session.ts"() {
9700
10398
  "use strict";
9701
10399
  init_cjs_shims();
9702
10400
  import_node_crypto4 = require("crypto");
9703
- import_node_fs8 = require("fs");
10401
+ import_node_fs9 = require("fs");
9704
10402
  import_node_path5 = require("path");
9705
10403
  import_node_util2 = require("util");
9706
10404
  init_api_url();
@@ -9710,10 +10408,12 @@ var init_session2 = __esm({
9710
10408
  init_failure_detail();
9711
10409
  init_files_batch();
9712
10410
  init_fallback();
10411
+ init_code_snapshot();
9713
10412
  RESOLVE_CHUNK = 500;
9714
10413
  BATCH_MAX = 500;
9715
10414
  DISCOVER_MAX = 500;
9716
10415
  BATCH_DEFAULT = 500;
10416
+ SNAPSHOT_UPDATES_MAX = 100;
9717
10417
  SEND_CONCURRENCY = 4;
9718
10418
  EXPECTED_MAX = 1e4;
9719
10419
  KEY_MAX = 1024;
@@ -11201,6 +11901,10 @@ var init_xml = __esm({
11201
11901
  });
11202
11902
 
11203
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
+ }
11204
11908
  function locate(el, suite, out) {
11205
11909
  for (const child of el.children) {
11206
11910
  if (child.name === "testcase") out.push({ test: child, suite });
@@ -11279,6 +11983,7 @@ function readJUnit(source, file, missing = [], notes = [], now = /* @__PURE__ */
11279
11983
  const title = titleOf(classname, name);
11280
11984
  const rkey = resultKey(key.value, 0);
11281
11985
  const files = filesOfTest(test, folder, title, missing, { lexical, resultKey: rkey, notes });
11986
+ const targets = targetsOf(test);
11282
11987
  return {
11283
11988
  resultKey: rkey,
11284
11989
  ...stated !== void 0 ? { testCaseId: stated } : {},
@@ -11289,14 +11994,15 @@ function readJUnit(source, file, missing = [], notes = [], now = /* @__PURE__ */
11289
11994
  ...specRef !== void 0 ? { specRef } : {},
11290
11995
  ...execution !== void 0 ? { execution } : {},
11291
11996
  ...errorContext !== "" ? { errorContext } : {},
11292
- ...files.length > 0 ? { files } : {}
11997
+ ...files.length > 0 ? { files } : {},
11998
+ ...targets.length > 0 ? { targets } : {}
11293
11999
  };
11294
12000
  });
11295
12001
  }
11296
12002
  function looksLikeJUnit(source) {
11297
12003
  return /<\s*testsuites?\b/.test(source.slice(0, 4096));
11298
12004
  }
11299
- var SOURCE2, TOKEN2, SPEC_FILE;
12005
+ var SOURCE2, TOKEN2, SPEC_FILE, TARGET_PROPERTY, TARGETS, CONTROL;
11300
12006
  var init_junit = __esm({
11301
12007
  "src/importers/junit.ts"() {
11302
12008
  "use strict";
@@ -11307,6 +12013,9 @@ var init_junit = __esm({
11307
12013
  SOURCE2 = "junit";
11308
12014
  TOKEN2 = /@P([A-Za-z0-9_-]+)/;
11309
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]/;
11310
12019
  }
11311
12020
  });
11312
12021
 
@@ -11361,6 +12070,8 @@ function pendingFrom(spec, test, result2, file, titles, ctx) {
11361
12070
  keys,
11362
12071
  title: titles.join(" \u203A "),
11363
12072
  specRef: spec.line !== void 0 ? `${file}:${spec.line}` : file,
12073
+ // The test's own text is read from here for its case's code snapshot; a report from another machine names a file that is not here, and then there is none.
12074
+ ...spec.line !== void 0 ? { codeAt: { file: attempt.testFile, line: spec.line, ...typeof spec.column === "number" ? { column: spec.column } : {} } } : {},
11364
12075
  source: SOURCE3,
11365
12076
  // Untouched, as everywhere: `timedOut` means what the project's map says it means, not what
11366
12077
  // this file decided.
@@ -11404,7 +12115,7 @@ function readPlaywrightJson(source, file) {
11404
12115
  const { config, suites } = parsed4;
11405
12116
  const rootDir = typeof config?.rootDir === "string" ? config.rootDir : void 0;
11406
12117
  const buildHref = config?.metadata?.ci?.buildHref;
11407
- const repoRoot = rootDir !== void 0 && (0, import_node_fs9.existsSync)(rootDir) ? repoRootOf(rootDir) : void 0;
12118
+ const repoRoot = rootDir !== void 0 && (0, import_node_fs10.existsSync)(rootDir) ? repoRootOf(rootDir) : void 0;
11408
12119
  const ctx = {
11409
12120
  ...rootDir !== void 0 ? { rootDir } : {},
11410
12121
  ...repoRoot !== void 0 ? { repoRoot } : {},
@@ -11423,12 +12134,12 @@ function readPlaywrightJson(source, file) {
11423
12134
  function looksLikePlaywrightJson(source) {
11424
12135
  return /^\s*\{/.test(source) && source.includes('"suites"');
11425
12136
  }
11426
- var import_node_fs9, SOURCE3, TOKEN3, NOT_FAILED, JsonReportError;
12137
+ var import_node_fs10, SOURCE3, TOKEN3, NOT_FAILED, JsonReportError;
11427
12138
  var init_playwright_json = __esm({
11428
12139
  "src/importers/playwright-json.ts"() {
11429
12140
  "use strict";
11430
12141
  init_cjs_shims();
11431
- import_node_fs9 = require("fs");
12142
+ import_node_fs10 = require("fs");
11432
12143
  init_failure_detail();
11433
12144
  init_result_key();
11434
12145
  SOURCE3 = "playwright";
@@ -12081,7 +12792,7 @@ function diffMatrix(evals) {
12081
12792
  }))
12082
12793
  };
12083
12794
  }
12084
- var init_diff2 = __esm({
12795
+ var init_diff3 = __esm({
12085
12796
  "src/diff/diff.ts"() {
12086
12797
  "use strict";
12087
12798
  init_cjs_shims();
@@ -12365,78 +13076,6 @@ var init_gates = __esm({
12365
13076
  }
12366
13077
  });
12367
13078
 
12368
- // src/diff/stats.ts
12369
- function wilson(passed2, total) {
12370
- const share2 = passed2 / total;
12371
- const z22 = Z * Z;
12372
- const denom = 1 + z22 / total;
12373
- const centre = (share2 + z22 / (2 * total)) / denom;
12374
- const half = Z * Math.sqrt(share2 * (1 - share2) / total + z22 / (4 * total * total)) / denom;
12375
- return { share: share2, lower: Math.max(0, centre - half), upper: Math.min(1, centre + half) };
12376
- }
12377
- function newcombeDifference(current, base) {
12378
- const a = wilson(current.passed, current.total);
12379
- const b = wilson(base.passed, base.total);
12380
- const diff2 = a.share - b.share;
12381
- return {
12382
- diff: diff2,
12383
- lower: diff2 - Math.sqrt((a.share - a.lower) ** 2 + (b.upper - b.share) ** 2),
12384
- upper: diff2 + Math.sqrt((a.upper - a.share) ** 2 + (b.share - b.lower) ** 2)
12385
- };
12386
- }
12387
- function fmtPp(share2, directional) {
12388
- const rounded = pp(share2);
12389
- if (rounded === 0 && share2 !== 0 && directional)
12390
- return signed(String(Number((share2 * 100).toPrecision(2))));
12391
- return signed(String(rounded === 0 ? 0 : rounded));
12392
- }
12393
- function wordFor(lower, upper) {
12394
- return upper < -EPS ? "worse" : lower > EPS ? "better" : "no-difference";
12395
- }
12396
- function compareProportions(current, base, min = MIN_ATTEMPTS) {
12397
- const floor = Number.isFinite(min) ? Math.max(1, min) : MIN_ATTEMPTS;
12398
- const sides = { current: current.total, base: base.total, min: floor };
12399
- if (!valid(current) || !valid(base))
12400
- return {
12401
- word: "too-few",
12402
- ...sides,
12403
- reason: "the attempt counts are not whole numbers inside 0 and the total, so no share was computed"
12404
- };
12405
- const [uc, ub] = [current.unmeasured ?? 0, base.unmeasured ?? 0];
12406
- const dropped = uc + ub > 0 ? `; not measured and left out: current ${uc}, baseline ${ub} attempt(s)` : "";
12407
- if (current.total < floor || base.total < floor)
12408
- return {
12409
- word: "too-few",
12410
- ...sides,
12411
- reason: `at least ${floor} attempts with a verdict are needed on each side (current ${current.total}, baseline ${base.total})${dropped}`
12412
- };
12413
- const r = newcombeDifference(current, base);
12414
- const [diffPp, lowerPp, upperPp] = [pp(r.diff), pp(r.lower), pp(r.upper)];
12415
- const word = wordFor(r.lower, r.upper);
12416
- const directional = word !== "no-difference";
12417
- return {
12418
- word,
12419
- ...sides,
12420
- diffPp,
12421
- lowerPp,
12422
- upperPp,
12423
- 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}`
12424
- };
12425
- }
12426
- var Z, MIN_ATTEMPTS, pp, signed, EPS, valid;
12427
- var init_stats = __esm({
12428
- "src/diff/stats.ts"() {
12429
- "use strict";
12430
- init_cjs_shims();
12431
- Z = 1.959963984540054;
12432
- MIN_ATTEMPTS = 5;
12433
- pp = (n) => Math.round(n * 1e4) / 100;
12434
- signed = (s) => /^[1-9.]|^0\./.test(s) ? `+${s}` : s;
12435
- EPS = 1e-12;
12436
- valid = (x) => Number.isInteger(x.passed) && Number.isInteger(x.total) && x.passed >= 0 && x.passed <= x.total;
12437
- }
12438
- });
12439
-
12440
13079
  // src/diff/advice.ts
12441
13080
  function attemptsOf(e) {
12442
13081
  let [passed2, total, unmeasured2] = [0, 0, 0];
@@ -12585,8 +13224,8 @@ var init_advice = __esm({
12585
13224
  });
12586
13225
 
12587
13226
  // src/cli/commands/diff.ts
12588
- var diff_exports = {};
12589
- __export(diff_exports, {
13227
+ var diff_exports2 = {};
13228
+ __export(diff_exports2, {
12590
13229
  DiffInputError: () => DiffInputError,
12591
13230
  handleDiff: () => handleDiff
12592
13231
  });
@@ -12659,12 +13298,12 @@ function handleDiff(opts) {
12659
13298
  return { ...withAdvice, gates: evaluateGates(baseline, current, diff2, gateOpts, waivers, now) };
12660
13299
  }
12661
13300
  var fs14, DiffInputError;
12662
- var init_diff3 = __esm({
13301
+ var init_diff4 = __esm({
12663
13302
  "src/cli/commands/diff.ts"() {
12664
13303
  "use strict";
12665
13304
  init_cjs_shims();
12666
13305
  fs14 = __toESM(require("fs"), 1);
12667
- init_diff2();
13306
+ init_diff3();
12668
13307
  init_advice();
12669
13308
  init_gates();
12670
13309
  init_waivers();
@@ -12678,270 +13317,6 @@ var init_diff3 = __esm({
12678
13317
  }
12679
13318
  });
12680
13319
 
12681
- // src/reporters/diff.ts
12682
- var diff_exports2 = {};
12683
- __export(diff_exports2, {
12684
- COMMENT_BUDGET: () => COMMENT_BUDGET,
12685
- STICKY_MARKER: () => STICKY_MARKER,
12686
- renderDiff: () => renderDiff,
12687
- renderDiffMarkdown: () => renderDiffMarkdown2
12688
- });
12689
- function headline(d) {
12690
- const gates = d.gates?.gates ?? [];
12691
- const named2 = (state2) => gates.filter((g) => g.state === state2).map((g) => g.gate);
12692
- const regression = gates.find((g) => g.gate === "regression");
12693
- if (d.summary.hasRegression && regression?.state !== "waived")
12694
- return { mark: "\u274C", text: `${d.summary.regressions} regression(s)` };
12695
- if (named2("failed").length > 0) return { mark: "\u274C", text: `gate failed: ${named2("failed").join(", ")}` };
12696
- if (d.summary.unmeasured > 0) return { mark: "\u26A0\uFE0F", text: `${d.summary.unmeasured} eval(s) not measured` };
12697
- if (named2("unmeasured").length > 0) return { mark: "\u26A0\uFE0F", text: `not measured: ${named2("unmeasured").join(", ")}` };
12698
- if (named2("waived").length > 0) return { mark: "\u2705", text: `gates passed (${named2("waived").length} waived)` };
12699
- return null;
12700
- }
12701
- function amount(gate2, n) {
12702
- if (n === void 0) return "\u2014";
12703
- if (gate2 === "pass-rate") return `${n} pp`;
12704
- if (gate2 === "cost") return `$${n}`;
12705
- if (gate2 === "cost-increase") return `${n}%`;
12706
- return String(n);
12707
- }
12708
- function waiverLines(d, quote, text6) {
12709
- const { applied, expired, unused } = d.gates.waivers;
12710
- return [
12711
- applied.map((w) => `${target2(w, quote)} until ${w.expires}: ${text6(w.reason)}`),
12712
- expired.map((w) => `${target2(w, quote)} on ${w.expires}: ${text6(w.reason)}`),
12713
- unused.map((w) => `${target2(w, quote)} until ${w.expires}: ${text6(w.reason)}`)
12714
- ];
12715
- }
12716
- function gatesMarkdown(d) {
12717
- if (d.gates === void 0) return [];
12718
- const out = ["### Gates", "", "| Gate | State | Value | Threshold | Reason |", "| --- | --- | --- | --- | --- |"];
12719
- for (const g of d.gates.gates) {
12720
- const s = GATE_STATE[g.state];
12721
- out.push(
12722
- `| ${g.gate} | ${s.mark} ${s.text} | ${amount(g.gate, g.value)} | ${amount(g.gate, g.threshold)} | ${cell2(g.reason)} |`
12723
- );
12724
- }
12725
- out.push("");
12726
- const details = d.gates.gates.flatMap((g) => (g.details ?? []).map((x) => `- ${g.gate}: ${x}`));
12727
- const [applied, expired, unused] = waiverLines(d, (t) => `\`${t}\``, oneLine);
12728
- const lines = [
12729
- ...details,
12730
- ...applied.map((l) => `- Waived: ${l}`),
12731
- ...expired.map((l) => `- Expired: ${l}`),
12732
- ...unused.map((l) => `- Unused: ${l}`)
12733
- ];
12734
- if (lines.length > 0) out.push(...lines, "");
12735
- return out;
12736
- }
12737
- function gatesConsole(d) {
12738
- if (d.gates === void 0) return [];
12739
- const out = ["Gates:"];
12740
- for (const g of d.gates.gates) {
12741
- const value2 = g.value === void 0 ? "" : `: ${amount(g.gate, g.value)}`;
12742
- const limit3 = g.threshold === void 0 ? "" : ` (limit ${amount(g.gate, g.threshold)})`;
12743
- out.push(` ${g.gate}: ${GATE_STATE[g.state].text}, ${g.reason}${value2}${limit3}`);
12744
- for (const x of g.details ?? []) out.push(` ${x}`);
12745
- }
12746
- const [applied, expired, unused] = waiverLines(d, (t) => t, oneLine);
12747
- out.push(
12748
- ...applied.map((l) => ` waived: ${l}`),
12749
- ...expired.map((l) => ` expired waiver: ${l}`),
12750
- ...unused.map((l) => ` unused waiver: ${l}`)
12751
- );
12752
- return out;
12753
- }
12754
- function adviceLines(a) {
12755
- const sections = [];
12756
- const unavailable = (lines) => {
12757
- const text6 = lines.map(oneLine).join("; ");
12758
- return text6.startsWith(NOT_COMPARED) ? text6 : `${NOT_COMPARED}, ${text6}`;
12759
- };
12760
- const stats = a.evals.map(
12761
- (e) => `${oneLine(e.id)}: ${e.comparison !== void 0 ? comparisonText(e.comparison) : unavailable(e.unavailable)}${e.descriptionsDiffer === true ? DIFFERED : ""}`
12762
- );
12763
- if (a.overall.comparison !== void 0 || a.overall.unavailable !== void 0)
12764
- stats.push(
12765
- `all evals together: ${a.overall.comparison !== void 0 ? comparisonText(a.overall.comparison) : unavailable(a.overall.unavailable)}${a.overall.descriptionsDiffer === true ? DIFFERED : ""}`
12766
- );
12767
- if (stats.length > 0)
12768
- sections.push({
12769
- heading: `Pass rates (at least ${MIN_ATTEMPTS} attempts with a verdict on each side; a guide, not a proof)`,
12770
- lines: stats
12771
- });
12772
- const x = a.experiment;
12773
- if (x !== void 0) {
12774
- const names = (l) => l.map(oneLine).join(", ") || "none";
12775
- const lines = [
12776
- `descriptions replaced: baseline ${names(x.baseline)}; current ${names(x.current)}`
12777
- ];
12778
- if (x.unavailable !== void 0)
12779
- lines.push(
12780
- `${NOT_COMPARED}, the two runs differ in more than the descriptions: ${x.unavailable.map(oneLine).join("; ")}`
12781
- );
12782
- for (const e of x.evals) {
12783
- lines.push(
12784
- `${oneLine(e.id)}: first tool called, baseline ${countsText(e.firstTool.baseline)}; current ${countsText(e.firstTool.current)}`
12785
- );
12786
- if (e.hit !== void 0)
12787
- lines.push(`${oneLine(e.id)}: first-tool hit, ${comparisonText(e.hit.comparison)}`);
12788
- }
12789
- sections.push({ heading: "Experiment with descriptions", lines });
12790
- }
12791
- return sections;
12792
- }
12793
- function adviceMarkdown(d) {
12794
- if (d.advice === void 0) return [];
12795
- const out = ["### Advice (does not affect the exit code)", "", d.advice.note, ""];
12796
- for (const s of adviceLines(d.advice))
12797
- out.push(`**${s.heading}**`, "", ...s.lines.map((l) => `- ${l}`), "");
12798
- return out;
12799
- }
12800
- function adviceConsole(d) {
12801
- if (d.advice === void 0) return [];
12802
- const out = ["Advice (does not change the exit code):"];
12803
- for (const s of adviceLines(d.advice))
12804
- out.push(` ${s.heading}:`, ...s.lines.map((l) => ` ${l}`));
12805
- return out;
12806
- }
12807
- function summaryLine2(d) {
12808
- const s = d.summary;
12809
- return [
12810
- `${s.regressions} regression(s)`,
12811
- `${s.improvements} improvement(s)`,
12812
- `${s.newFails} new-fail`,
12813
- `${s.preExistingFails} pre-existing-fail`,
12814
- `${s.errored} errored`,
12815
- `${s.removed} removed`,
12816
- `${s.unmeasured} not measured`,
12817
- `${s.stablePasses} stable`
12818
- ].join(" \xB7 ");
12819
- }
12820
- function matrixMarkdown2(d, room) {
12821
- const m = d.matrix;
12822
- const rank2 = (e) => e === null ? IMPORTANCE.length : IMPORTANCE.indexOf(e.status);
12823
- 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);
12824
- const head = [`| Eval | ${m.models.map((x) => cell2(x.model)).join(" | ")} |`, `| --- | ${m.models.map(() => "---").join(" | ")} |`];
12825
- const line = (r) => `| ${cell2(r.eval)} | ${r.cells.map((c) => c === null ? "\u2014" : c.status === "stable-pass" ? "\u2705" : BADGE[c.status]).join(" | ")} |`;
12826
- const stable = m.rows.flatMap((r) => r.cells).filter((c) => c?.status === "stable-pass").length;
12827
- const tail = stable > 0 ? [plural3(stable, "stable pass", "stable passes") + " not listed", ""] : [];
12828
- if (listed3.length === 0) return tail.length > 0 ? ["_" + tail[0] + "_", ""] : [];
12829
- const byImportance = [...listed3].sort((a, b) => a.best - b.best || a.i - b.i);
12830
- const note2 = (n) => `_${plural3(n, "more cell", "more cells")} in the job summary_`;
12831
- const total = listed3.reduce((n, x) => n + x.changed, 0);
12832
- const keep = [];
12833
- let used = [...head, "", ...tail].join("\n").length + note2(total).length + 2;
12834
- for (const x of byImportance) {
12835
- const cost2 = line(x.r).length + 1;
12836
- if (used + cost2 > room) break;
12837
- used += cost2;
12838
- keep.push(x);
12839
- }
12840
- const shown4 = keep.sort((a, b) => a.i - b.i);
12841
- const left = total - shown4.reduce((n, x) => n + x.changed, 0);
12842
- return [
12843
- ...shown4.length > 0 ? [...head, ...shown4.map((x) => line(x.r)), ""] : [],
12844
- ...left > 0 ? [note2(left), ""] : [],
12845
- ...tail.length > 0 ? ["_" + tail[0] + "_", ""] : []
12846
- ];
12847
- }
12848
- function renderDiffMarkdown2(d, budget = COMMENT_BUDGET) {
12849
- const out = [STICKY_MARKER, "## Plune eval diff", ""];
12850
- const head = headline(d);
12851
- out.push(head ? `### ${head.mark} ${capital(head.text)}` : "### \u2705 No regressions");
12852
- out.push("");
12853
- const notable = d.evals.filter((e) => e.status !== "stable-pass");
12854
- if (d.matrix !== void 0) {
12855
- const rest = [...gatesMarkdown(d), ...adviceMarkdown(d), `_${summaryLine2(d)}_`].join("\n");
12856
- out.push(...matrixMarkdown2(d, budget - out.join("\n").length - rest.length - 2));
12857
- } else if (notable.length > 0) {
12858
- out.push("| Eval | Baseline \u2192 Current | Change |");
12859
- out.push("| --- | --- | --- |");
12860
- for (const e of notable) {
12861
- out.push(`| ${e.id} | ${e.baseline} \u2192 ${e.current} | ${BADGE[e.status]} |`);
12862
- }
12863
- out.push("");
12864
- }
12865
- out.push(...gatesMarkdown(d));
12866
- out.push(...adviceMarkdown(d));
12867
- out.push(`_${summaryLine2(d)}_`);
12868
- return out.join("\n");
12869
- }
12870
- function renderDiffConsole(d) {
12871
- const head = headline(d);
12872
- const out = [`Plune eval diff: ${head ? head.text : "no regressions"}`];
12873
- for (const e of d.evals) {
12874
- if (e.status === "stable-pass") continue;
12875
- out.push(` ${e.id}: ${e.baseline} -> ${e.current} [${e.status}]`);
12876
- }
12877
- out.push(...gatesConsole(d));
12878
- out.push(...adviceConsole(d));
12879
- out.push(summaryLine2(d));
12880
- return out.join("\n");
12881
- }
12882
- function renderDiffJson(d) {
12883
- return JSON.stringify(d, null, 2);
12884
- }
12885
- function renderDiff(d, format = "console") {
12886
- if (format === "json") return noCommandsJson(renderDiffJson(d));
12887
- if (format === "markdown") return noCommands(renderDiffMarkdown2(d));
12888
- return noCommands(renderDiffConsole(d));
12889
- }
12890
- var STICKY_MARKER, BADGE, GATE_STATE, capital, oneLine, cell2, target2, WORD, comparisonText, countsText, NOT_COMPARED, DIFFERED, COMMENT_BUDGET, IMPORTANCE, plural3;
12891
- var init_diff4 = __esm({
12892
- "src/reporters/diff.ts"() {
12893
- "use strict";
12894
- init_cjs_shims();
12895
- init_stats();
12896
- init_human();
12897
- STICKY_MARKER = "<!-- plune-eval-diff -->";
12898
- BADGE = {
12899
- regression: "\u{1F534} regression",
12900
- improvement: "\u{1F7E2} improvement",
12901
- "pre-existing-fail": "\u26AA pre-existing fail",
12902
- "new-fail": "\u{1F195} new fail",
12903
- "new-pass": "\u{1F7E2} new pass",
12904
- "stable-pass": "\u2705 stable",
12905
- errored: "\u26A0\uFE0F errored",
12906
- unmeasured: "\u26A0\uFE0F not measured",
12907
- removed: "\u2796 removed"
12908
- };
12909
- GATE_STATE = {
12910
- passed: { mark: "\u2705", text: "passed" },
12911
- failed: { mark: "\u274C", text: "failed" },
12912
- unmeasured: { mark: "\u26A0\uFE0F", text: "not measured" },
12913
- waived: { mark: "\u{1F7E1}", text: "waived" }
12914
- };
12915
- capital = (t) => t.charAt(0).toUpperCase() + t.slice(1);
12916
- oneLine = (t) => t.replace(/\s*[\r\n]+\s*/g, " ");
12917
- cell2 = (t) => oneLine(t).replace(/\|/g, "\\|");
12918
- target2 = (w, quote) => w.eval === void 0 ? w.gate : `${w.gate} of ${quote(w.eval)}`;
12919
- WORD = {
12920
- worse: "probably worse",
12921
- better: "probably better",
12922
- "no-difference": "no difference visible",
12923
- "too-few": "too few attempts"
12924
- };
12925
- comparisonText = (c) => `${WORD[c.word]}: ${c.reason}`;
12926
- countsText = (counts3) => Object.entries(counts3).sort(([a], [b]) => a < b ? -1 : 1).map(([tool2, n]) => `${oneLine(tool2)} ${n}`).join(", ") || "(no rows)";
12927
- NOT_COMPARED = "not compared";
12928
- DIFFERED = " (the descriptions of the tools differed between the runs: this is the experiment, not a change of the same thing)";
12929
- COMMENT_BUDGET = 6e4;
12930
- IMPORTANCE = [
12931
- "regression",
12932
- "errored",
12933
- "unmeasured",
12934
- "new-fail",
12935
- "removed",
12936
- "pre-existing-fail",
12937
- "improvement",
12938
- "new-pass",
12939
- "stable-pass"
12940
- ];
12941
- plural3 = (n, one, many) => `${n} ${n === 1 ? one : many}`;
12942
- }
12943
- });
12944
-
12945
13320
  // src/config/init/wizard.ts
12946
13321
  async function runInitWizard(cwd) {
12947
13322
  if (!process.stdin.isTTY) {
@@ -13461,8 +13836,13 @@ function pluneTool(name) {
13461
13836
  function isPluneToolName(name) {
13462
13837
  return BY_NAME.has(name);
13463
13838
  }
13839
+ function offeredTo(tool2, scope) {
13840
+ if (scope !== "read") return true;
13841
+ if (tool2.write) return false;
13842
+ return tool2.name !== "plune_discover_tools" || PLUNE_TOOLS.some((t) => t.visibility !== "core" && !t.write);
13843
+ }
13464
13844
  function defaultVisibleTools(scope) {
13465
- return PLUNE_TOOLS.filter((t) => t.visibility === "core" && !(scope === "read" && t.write)).map((t) => t.name);
13845
+ return PLUNE_TOOLS.filter((t) => t.visibility === "core" && offeredTo(t, scope)).map((t) => t.name);
13466
13846
  }
13467
13847
  var import_zod5, MAX_VISIBLE_TOOLS, define, listPage, missionId, projectId, PLUNE_TOOLS, PLUNE_TOOL_NAMES, BY_NAME;
13468
13848
  var init_contract = __esm({
@@ -14007,7 +14387,9 @@ function createPluneToolExecutor(opts) {
14007
14387
  async plune_cases_search(i) {
14008
14388
  const query = withoutUndefined({
14009
14389
  ...i["filters"],
14010
- limit: i["limit"] === void 0 ? void 0 : String(i["limit"]),
14390
+ // A full case weighs ~160 estimated tokens, so the platform's own page of up to 200 filled a model's context
14391
+ // in one answer; 20 a page, the rest a cursor away, unless the caller asks for more.
14392
+ limit: String(i["limit"] ?? 20),
14011
14393
  cursor: i["cursor"],
14012
14394
  stability: "0"
14013
14395
  });
@@ -14318,7 +14700,7 @@ function createPluneMcpServer(opts, era) {
14318
14700
  }
14319
14701
  };
14320
14702
  for (const tool2 of PLUNE_TOOLS) {
14321
- if (opts.scope === "read" && tool2.write) continue;
14703
+ if (!offeredTo(tool2, opts.scope)) continue;
14322
14704
  const handle = server2.registerTool(
14323
14705
  tool2.name,
14324
14706
  {
@@ -14736,8 +15118,8 @@ var init_thresholds = __esm({
14736
15118
  writeFirst: 9272,
14737
15119
  /** 2025 era, write scope, after plune_discover_tools: 22 tools, measured 10841 (10739 before the memory rules). */
14738
15120
  writeAll: 11926,
14739
- /** Read scope, either era: 8 tools, measured 2482 (2380 before the memory rules). */
14740
- read: 2731,
15121
+ /** Read scope, either era: 7 tools, measured 2222 (2482 with plune_discover_tools, which a read token is not offered). */
15122
+ read: 2445,
14741
15123
  /** 2026-07-28 era, write scope: 17 tools, the list does not change after discover; measured 8429 (8327 before the memory rules). */
14742
15124
  modernWrite: 9272
14743
15125
  },
@@ -15715,6 +16097,7 @@ function lintRun(report, showInfo) {
15715
16097
  id: f.rule,
15716
16098
  title: titles.get(f.rule) ?? f.rule,
15717
16099
  target: targetOf(f.target),
16100
+ ...f.target.tool === "" ? {} : { tool: f.target.tool },
15718
16101
  state: f.state,
15719
16102
  class: f.class,
15720
16103
  level: f.level,
@@ -15732,6 +16115,7 @@ function lintRun(report, showInfo) {
15732
16115
  id: r.id,
15733
16116
  title: r.description,
15734
16117
  target: target4,
16118
+ ...target4 === "" ? {} : { tool: target4 },
15735
16119
  state: state2,
15736
16120
  class: r.class,
15737
16121
  level: r.level,
@@ -15779,7 +16163,11 @@ function checkRun(report) {
15779
16163
  of("smoke", { state: "not-applicable", detail: "--smoke was not given" }, "", null)
15780
16164
  );
15781
16165
  else {
15782
- 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
+ });
15783
16171
  if (!calls.some((c) => c.state !== "not-applicable"))
15784
16172
  checks.push(
15785
16173
  of(
@@ -15818,6 +16206,7 @@ function diffRun(report) {
15818
16206
  id: c.id,
15819
16207
  title: c.title,
15820
16208
  target: ch.name === "" ? ch.entity : `${ch.entity} ${ch.name}`,
16209
+ ...ch.entity === "tool" && ch.name !== "" ? { tool: ch.name } : {},
15821
16210
  state: "failed",
15822
16211
  class: c.class,
15823
16212
  // What fails the run is an error; advice a warning, and every change listed again an info line.
@@ -15890,6 +16279,7 @@ var init_runs = __esm({
15890
16279
  ...c,
15891
16280
  title: printable(c.title),
15892
16281
  target: printable(c.target),
16282
+ ...c.tool === void 0 ? {} : { tool: printable(c.tool) },
15893
16283
  message: printable(c.message),
15894
16284
  expected: printable(c.expected),
15895
16285
  actual: printable(c.actual),
@@ -16025,12 +16415,12 @@ function writeFiles(files) {
16025
16415
  (f, i) => (0, import_node_path6.join)((0, import_node_path6.dirname)(f.path), `.${(0, import_node_path6.basename)(f.path)}.${process.pid}.${i}.tmp`)
16026
16416
  );
16027
16417
  const drop = (from) => {
16028
- for (const t of temps.slice(from)) (0, import_node_fs10.rmSync)(t, { force: true });
16418
+ for (const t of temps.slice(from)) (0, import_node_fs11.rmSync)(t, { force: true });
16029
16419
  };
16030
16420
  const code = (err) => err.code ?? "error";
16031
16421
  for (const [i, f] of files.entries()) {
16032
16422
  try {
16033
- (0, import_node_fs10.writeFileSync)(temps[i] ?? "", f.text);
16423
+ (0, import_node_fs11.writeFileSync)(temps[i] ?? "", f.text);
16034
16424
  } catch (err) {
16035
16425
  drop(0);
16036
16426
  throw new UsageError(`--out: could not write ${f.name} (${code(err)}); no file was written.`);
@@ -16039,7 +16429,7 @@ function writeFiles(files) {
16039
16429
  const written = [];
16040
16430
  for (const [i, f] of files.entries()) {
16041
16431
  try {
16042
- (0, import_node_fs10.renameSync)(temps[i] ?? "", f.path);
16432
+ (0, import_node_fs11.renameSync)(temps[i] ?? "", f.path);
16043
16433
  written.push(f.name);
16044
16434
  } catch (err) {
16045
16435
  drop(i);
@@ -16106,7 +16496,9 @@ function casesOf(run) {
16106
16496
  specRef: "",
16107
16497
  durationMs: null
16108
16498
  };
16109
- 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
+ ];
16110
16502
  }
16111
16503
  return run.cases.map(({ id: id2, title, suite }) => {
16112
16504
  const mine = run.checks.filter((c) => c.id === id2);
@@ -16116,6 +16508,7 @@ function casesOf(run) {
16116
16508
  title,
16117
16509
  ...suite === void 0 ? {} : { suite },
16118
16510
  outcome: outcomeOf2(mine),
16511
+ tools: toolsOf(mine),
16119
16512
  durationMs: timed.length === 0 ? null : timed.reduce((sum, c) => sum + (c.durationMs ?? 0), 0)
16120
16513
  };
16121
16514
  });
@@ -16197,8 +16590,17 @@ function junitXml(run) {
16197
16590
  const time = c.durationMs === null ? "" : ` time="${(c.durationMs / 1e3).toFixed(3)}"`;
16198
16591
  const classname = c.suite === void 0 ? `mcp.${run.command}` : `mcp.${run.command}.${c.suite}`;
16199
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
+ ];
16200
16600
  if (c.outcome.kind === "pass") {
16201
- lines.push(`${head}/>`);
16601
+ lines.push(
16602
+ ...properties.length === 0 ? [`${head}/>`] : [`${head}>`, ...properties, " </testcase>"]
16603
+ );
16202
16604
  continue;
16203
16605
  }
16204
16606
  const { checks } = c.outcome;
@@ -16208,6 +16610,7 @@ function junitXml(run) {
16208
16610
  ].join("\n\n");
16209
16611
  lines.push(
16210
16612
  `${head}>`,
16613
+ ...properties,
16211
16614
  ` <${c.outcome.kind} type="${xmlAttr(c.outcome.type)}" message="${xmlAttr(c.outcome.message)}">${xmlText(body)}</${c.outcome.kind}>`,
16212
16615
  " </testcase>"
16213
16616
  );
@@ -16216,12 +16619,12 @@ function junitXml(run) {
16216
16619
  return `${lines.join("\n")}
16217
16620
  `.replace(/^([\s\u0085]*)::/gm, "$1?::").replaceAll("##[", "##&#91;");
16218
16621
  }
16219
- var import_node_fs10, 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;
16220
16623
  var init_report2 = __esm({
16221
16624
  "src/mcp-testing/report/index.ts"() {
16222
16625
  "use strict";
16223
16626
  init_cjs_shims();
16224
- import_node_fs10 = require("fs");
16627
+ import_node_fs11 = require("fs");
16225
16628
  import_node_path6 = require("path");
16226
16629
  init_options();
16227
16630
  init_snapshot2();
@@ -16234,6 +16637,10 @@ var init_report2 = __esm({
16234
16637
  shown = (run) => run.checks.filter(
16235
16638
  (c) => c.state !== "passed" && c.state !== "not-applicable" && (c.level !== "info" || run.showInfo || c.state === "could-not-run")
16236
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);
16237
16644
  count3 = (cases, kind2, type) => cases.filter(
16238
16645
  (c) => c.outcome.kind === kind2 && (type === void 0 || "type" in c.outcome && c.outcome.type === type)
16239
16646
  ).length;
@@ -16750,12 +17157,12 @@ async function lint(flags2, server2, io, rawOut) {
16750
17157
  function readExceptions(flag2, io) {
16751
17158
  const name = flag2 ?? DEFAULT_IGNORE_FILE;
16752
17159
  const path25 = (0, import_node_path7.resolve)(io.cwd, name);
16753
- if (!(0, import_node_fs11.existsSync)(path25)) {
17160
+ if (!(0, import_node_fs12.existsSync)(path25)) {
16754
17161
  if (flag2 !== void 0) throw new UsageError(`--ignore-file: ${name} does not exist.`);
16755
17162
  return void 0;
16756
17163
  }
16757
17164
  const today = io.today ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
16758
- return { name, ...parseExceptionsFile((0, import_node_fs11.readFileSync)(path25, "utf8"), name, today) };
17165
+ return { name, ...parseExceptionsFile((0, import_node_fs12.readFileSync)(path25, "utf8"), name, today) };
16759
17166
  }
16760
17167
  async function listTools(session2) {
16761
17168
  try {
@@ -16883,12 +17290,12 @@ function sorted(findings) {
16883
17290
  (a, b) => compareLevels(b.level, a.level) || cmp(a.target.tool, b.target.tool) || cmp(a.rule, b.rule) || cmp(a.target.param ?? "", b.target.param ?? "") || cmp(a.message, b.message)
16884
17291
  );
16885
17292
  }
16886
- var import_node_fs11, import_node_path7, import_client8, import__, DEFAULT_IGNORE_FILE, FAIL_ON, isRecord10, NAMED_SCHEMAS2, DATA, MAX_SCHEMA_NODES, MAX_SCHEMA_DEPTH, SchemaTooBig, note, cmp;
17293
+ var import_node_fs12, import_node_path7, import_client8, import__, DEFAULT_IGNORE_FILE, FAIL_ON, isRecord10, NAMED_SCHEMAS2, DATA, MAX_SCHEMA_NODES, MAX_SCHEMA_DEPTH, SchemaTooBig, note, cmp;
16887
17294
  var init_mcp_lint = __esm({
16888
17295
  "src/cli/commands/mcp-lint.ts"() {
16889
17296
  "use strict";
16890
17297
  init_cjs_shims();
16891
- import_node_fs11 = require("fs");
17298
+ import_node_fs12 = require("fs");
16892
17299
  import_node_path7 = require("path");
16893
17300
  import_client8 = require("@modelcontextprotocol/client");
16894
17301
  init_options();
@@ -17306,21 +17713,21 @@ function writeAtomically(path25, text6, shown4, flag2 = "--out") {
17306
17713
  `.${(0, import_node_path8.basename)(path25)}.${process.pid}.${(0, import_node_crypto7.randomBytes)(4).toString("hex")}.tmp`
17307
17714
  );
17308
17715
  try {
17309
- (0, import_node_fs12.writeFileSync)(temporary, text6, { flag: "wx" });
17310
- (0, import_node_fs12.renameSync)(temporary, path25);
17716
+ (0, import_node_fs13.writeFileSync)(temporary, text6, { flag: "wx" });
17717
+ (0, import_node_fs13.renameSync)(temporary, path25);
17311
17718
  } catch (err) {
17312
- (0, import_node_fs12.rmSync)(temporary, { force: true });
17719
+ (0, import_node_fs13.rmSync)(temporary, { force: true });
17313
17720
  const code = err.code ?? "an error";
17314
17721
  throw new UsageError(`${flag2}: could not write ${shown4} (${code}).`);
17315
17722
  }
17316
17723
  }
17317
- var import_node_crypto7, import_node_fs12, import_node_os4, import_node_path8, KEPT_FILE, isRecord11, plural5, counts2, MASK_DEPTH, MIN_ARGUMENT_LENGTH, METHOD_NOT_FOUND2;
17724
+ var import_node_crypto7, import_node_fs13, import_node_os4, import_node_path8, KEPT_FILE, isRecord11, plural5, counts2, MASK_DEPTH, MIN_ARGUMENT_LENGTH, METHOD_NOT_FOUND2;
17318
17725
  var init_mcp_snapshot = __esm({
17319
17726
  "src/cli/commands/mcp-snapshot.ts"() {
17320
17727
  "use strict";
17321
17728
  init_cjs_shims();
17322
17729
  import_node_crypto7 = require("crypto");
17323
- import_node_fs12 = require("fs");
17730
+ import_node_fs13 = require("fs");
17324
17731
  import_node_os4 = require("os");
17325
17732
  import_node_path8 = require("path");
17326
17733
  init_options();
@@ -17375,7 +17782,7 @@ function diffOperands(operands, rawArgs) {
17375
17782
  function readSnapshotFile(name, cwd) {
17376
17783
  let text6;
17377
17784
  try {
17378
- text6 = (0, import_node_fs13.readFileSync)((0, import_node_path9.resolve)(cwd, name), "utf8");
17785
+ text6 = (0, import_node_fs14.readFileSync)((0, import_node_path9.resolve)(cwd, name), "utf8");
17379
17786
  } catch (err) {
17380
17787
  throw new UsageError(
17381
17788
  `${name}: cannot be read (${err.code ?? "an error"}).`
@@ -17436,12 +17843,12 @@ async function diff(flags2, operands, io, rawOut) {
17436
17843
  writeReport(diffRun(report), outputs, { out: rawOut, err: io.err, cwd: io.cwd });
17437
17844
  return report.exitCode;
17438
17845
  }
17439
- var import_node_fs13, import_node_path9, FAIL_ON2;
17846
+ var import_node_fs14, import_node_path9, FAIL_ON2;
17440
17847
  var init_mcp_diff = __esm({
17441
17848
  "src/cli/commands/mcp-diff.ts"() {
17442
17849
  "use strict";
17443
17850
  init_cjs_shims();
17444
- import_node_fs13 = require("fs");
17851
+ import_node_fs14 = require("fs");
17445
17852
  import_node_path9 = require("path");
17446
17853
  init_options();
17447
17854
  init_exit_codes();
@@ -18196,13 +18603,13 @@ ${err.stderrTail.map((l) => ` ${l}
18196
18603
  }
18197
18604
  }
18198
18605
  function readLock(path25, name, required) {
18199
- if (!(0, import_node_fs14.existsSync)(path25)) {
18606
+ if (!(0, import_node_fs15.existsSync)(path25)) {
18200
18607
  if (required) throw new UsageError(`${name} does not exist; pin the server first with plune mcp pin.`);
18201
18608
  return emptyLock();
18202
18609
  }
18203
18610
  let text6;
18204
18611
  try {
18205
- text6 = (0, import_node_fs14.readFileSync)(path25, "utf8");
18612
+ text6 = (0, import_node_fs15.readFileSync)(path25, "utf8");
18206
18613
  } catch (err) {
18207
18614
  throw new UsageError(`${name}: cannot be read (${err.code ?? "an error"}).`);
18208
18615
  }
@@ -18442,12 +18849,12 @@ async function stability(flags2, config, io, json2) {
18442
18849
  `);
18443
18850
  return exitCode2;
18444
18851
  }
18445
- var import_node_fs14, import_node_path10, STABILITY_LIMIT, isRecord14, shown2, asciiJson, KIND, plural6, NOUN, block, primitive, renderFinding;
18852
+ var import_node_fs15, import_node_path10, STABILITY_LIMIT, isRecord14, shown2, asciiJson, KIND, plural6, NOUN, block, primitive, renderFinding;
18446
18853
  var init_mcp_pin = __esm({
18447
18854
  "src/cli/commands/mcp-pin.ts"() {
18448
18855
  "use strict";
18449
18856
  init_cjs_shims();
18450
- import_node_fs14 = require("fs");
18857
+ import_node_fs15 = require("fs");
18451
18858
  import_node_path10 = require("path");
18452
18859
  init_options();
18453
18860
  init_session();
@@ -28775,8 +29182,8 @@ function parseOauthConfig(source, format = "json") {
28775
29182
  function loadOauthConfig(path25) {
28776
29183
  let source;
28777
29184
  try {
28778
- if ((0, import_node_fs15.statSync)(path25).size > MAX_CONFIG_BYTES) throw new UsageError(tooLarge());
28779
- source = (0, import_node_fs15.readFileSync)(path25, "utf8");
29185
+ if ((0, import_node_fs16.statSync)(path25).size > MAX_CONFIG_BYTES) throw new UsageError(tooLarge());
29186
+ source = (0, import_node_fs16.readFileSync)(path25, "utf8");
28780
29187
  } catch (err) {
28781
29188
  if (err instanceof UsageError) throw err;
28782
29189
  const code = err.code;
@@ -28786,12 +29193,12 @@ function loadOauthConfig(path25) {
28786
29193
  }
28787
29194
  return parseOauthConfig(source, /\.ya?ml$/i.test(path25) ? "yaml" : "json");
28788
29195
  }
28789
- var import_node_fs15, import_yaml6, TOP, REGISTRATION2, METHODS, MODES, SECRET_KEY2, ENV_NAME, isObject6, MAX_CONFIG_BYTES, tooLarge;
29196
+ var import_node_fs16, import_yaml6, TOP, REGISTRATION2, METHODS, MODES, SECRET_KEY2, ENV_NAME, isObject6, MAX_CONFIG_BYTES, tooLarge;
28790
29197
  var init_auth_config = __esm({
28791
29198
  "src/mcp-testing/conformance/checks/auth-config.ts"() {
28792
29199
  "use strict";
28793
29200
  init_cjs_shims();
28794
- import_node_fs15 = require("fs");
29201
+ import_node_fs16 = require("fs");
28795
29202
  import_yaml6 = require("yaml");
28796
29203
  init_options();
28797
29204
  TOP = /* @__PURE__ */ new Set([
@@ -28844,7 +29251,7 @@ __export(mcp_conformance_exports, {
28844
29251
  function loadFixture(path25) {
28845
29252
  let doc;
28846
29253
  try {
28847
- doc = JSON.parse((0, import_node_fs16.readFileSync)(path25, "utf8"));
29254
+ doc = JSON.parse((0, import_node_fs17.readFileSync)(path25, "utf8"));
28848
29255
  } catch (err) {
28849
29256
  const code = err.code;
28850
29257
  throw new UsageError(`--fixture: could not read ${path25} as JSON${code === void 0 ? "" : ` (${code})`}.`);
@@ -28901,24 +29308,24 @@ function selection(flags2) {
28901
29308
  );
28902
29309
  return { suites, entries: entries2 };
28903
29310
  }
28904
- function catalogText(entries2) {
29311
+ function catalogText(entries2, profile) {
28905
29312
  const rows = entries2.map((e) => [
28906
29313
  e.id,
28907
29314
  e.suite,
28908
29315
  e.kind === "check" ? `${e.level}${e.derived ? "*" : ""}` : e.kind,
28909
29316
  e.eras.join("+"),
28910
29317
  e.transports.join("+"),
28911
- PROFILE.checks.includes(e.id) ? "scored" : ""
29318
+ profile.checks.includes(e.id) ? "scored" : ""
28912
29319
  ]);
28913
29320
  const head = ["id", "suite", "level", "eras", "transports", "profile"];
28914
29321
  const widths = head.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)));
28915
29322
  const line = (r) => r.map((c, i) => c.padEnd(widths[i] ?? 0)).join(" ").trimEnd();
28916
29323
  return `${[head, ...rows].map(line).join("\n")}
28917
29324
 
28918
- ${entries2.length} checks. * level derived from neighbouring provisions. Profile ${PROFILE.id} ${PROFILE.version}: ${PROFILE.checks.length} scored.
29325
+ ${entries2.length} checks. * level derived from neighbouring provisions. Profile ${profile.id} ${profile.version}: ${profile.checks.length} scored.
28919
29326
  `;
28920
29327
  }
28921
- function explainText(e) {
29328
+ function explainText(e, profile) {
28922
29329
  const lines = [
28923
29330
  `${e.id}: ${e.title}`,
28924
29331
  e.description,
@@ -28929,7 +29336,7 @@ function explainText(e) {
28929
29336
  `eras: ${e.eras.join(", ")}`,
28930
29337
  `transports: ${e.transports.join(", ")}`,
28931
29338
  `needs a fixture: ${e.needsFixture ? "yes" : "no"}`,
28932
- `in profile ${PROFILE.id} ${PROFILE.version}: ${PROFILE.checks.includes(e.id) ? "yes, scored" : "no"}`,
29339
+ `in profile ${profile.id} ${profile.version}: ${profile.checks.includes(e.id) ? "yes, scored" : "no"}`,
28933
29340
  ...e.specRefs.map((r) => `spec: ${specUrl(r)} (${r.section})`)
28934
29341
  ];
28935
29342
  return `${lines.join("\n")}
@@ -28937,13 +29344,15 @@ function explainText(e) {
28937
29344
  }
28938
29345
  async function conformance(flags2, server2, io, rawOut) {
28939
29346
  const format = oneOf4("--format", flags2.format ?? "human", FORMATS);
29347
+ const versions = PROFILES.map((p) => p.version);
29348
+ const profile = profileOf(oneOf4("--profile", flags2.profile ?? PROFILE.version, versions)) ?? PROFILE;
28940
29349
  if (flags2.listChecks === true || flags2.explain !== void 0) {
28941
29350
  if (flags2.out !== void 0 || flags2.reporter !== void 0)
28942
29351
  throw new UsageError("--list-checks and --explain print the catalog: --out is for a run.");
28943
29352
  if (flags2.explain !== void 0) {
28944
29353
  const entry2 = catalogEntry(flags2.explain);
28945
29354
  if (entry2 === void 0) throw new UsageError(`--explain ${flags2.explain}: no such check.`);
28946
- io.out(format === "json" ? json(entry2) : explainText(entry2));
29355
+ io.out(format === "json" ? json(entry2) : explainText(entry2, profile));
28947
29356
  return MCP_EXIT.ok;
28948
29357
  }
28949
29358
  const entries3 = flags2.suite === void 0 ? CATALOG : selection(flags2).entries;
@@ -28951,9 +29360,9 @@ async function conformance(flags2, server2, io, rawOut) {
28951
29360
  format === "json" ? json({
28952
29361
  kind: "mcp-conformance-catalog",
28953
29362
  schemaVersion: 1,
28954
- profile: { id: PROFILE.id, version: PROFILE.version, manifestDigest: manifestDigest(PROFILE.checks), checks: PROFILE.checks },
29363
+ profile: { id: profile.id, version: profile.version, manifestDigest: manifestDigest(profile.checks), checks: profile.checks },
28955
29364
  checks: entries3
28956
- }) : catalogText(entries3)
29365
+ }) : catalogText(entries3, profile)
28957
29366
  );
28958
29367
  return MCP_EXIT.ok;
28959
29368
  }
@@ -28980,7 +29389,7 @@ async function conformance(flags2, server2, io, rawOut) {
28980
29389
  const plan = requested === "both" ? ["legacy", "modern"] : requested === "auto" ? "auto" : [eraOf(requested)];
28981
29390
  if (config.target.kind === "sse" && plan !== "auto" && plan.includes("modern"))
28982
29391
  throw new UsageError("--protocol-version: the HTTP+SSE transport carries the legacy era only (2025-11-25 and earlier).");
28983
- const base = { requested, suites, entries: entries2, fixture };
29392
+ const base = { requested, suites, entries: entries2, fixture, profile };
28984
29393
  const reports = [];
28985
29394
  if (suites.includes("oauth")) {
28986
29395
  if (suites.length > 1) throw new UsageError("--suite oauth cannot be run together with another suite yet: run it on its own.");
@@ -29061,7 +29470,7 @@ function discoverRaw(session2, version2) {
29061
29470
  const body = { jsonrpc: "2.0", id: id2, method: "server/discover", params: { _meta: modernMeta(version2) } };
29062
29471
  return session2.raw(JSON.stringify(body), id2);
29063
29472
  }
29064
- async function measure2(config, { requested, suites, entries: entries2, fixture }, plan, io) {
29473
+ async function measure2(config, { requested, suites, entries: entries2, fixture, profile }, plan, io) {
29065
29474
  const transport = config.target.kind === "stdio" ? "stdio" : "http";
29066
29475
  const results4 = [];
29067
29476
  let serverInfo = null;
@@ -29177,19 +29586,19 @@ async function measure2(config, { requested, suites, entries: entries2, fixture
29177
29586
  }
29178
29587
  }
29179
29588
  }
29180
- const summary = summarize2(results4);
29589
+ const summary = summarize2(results4, CATALOG, profile);
29181
29590
  const bucket = new Map(BUCKETS.flatMap((k) => summary[k].map((id2) => [id2, k])));
29182
29591
  for (const r of results4) r.bucket = bucket.get(r.id) ?? "pending";
29183
29592
  const bySuite = {};
29184
- for (const s of suites) bySuite[s] = summarize2(results4.filter((r) => r.suite === s));
29593
+ for (const s of suites) bySuite[s] = summarize2(results4.filter((r) => r.suite === s), CATALOG, profile);
29185
29594
  return {
29186
29595
  kind: "mcp-conformance-report",
29187
29596
  schemaVersion: 1,
29188
29597
  command: "conformance",
29189
29598
  checkerVersion: io.clientVersion ?? "0.0.0",
29190
- profileId: PROFILE.id,
29191
- profileVersion: PROFILE.version,
29192
- manifestDigest: manifestDigest(PROFILE.checks),
29599
+ profileId: profile.id,
29600
+ profileVersion: profile.version,
29601
+ manifestDigest: manifestDigest(profile.checks),
29193
29602
  protocolVersion,
29194
29603
  protocolVersionRequested: requested,
29195
29604
  era: plan.era,
@@ -29226,7 +29635,7 @@ function oauthSetup(flags2, cwd, env) {
29226
29635
  }
29227
29636
  return { config: flags2.config === void 0 ? {} : loadOauthConfig((0, import_node_path11.resolve)(cwd, flags2.config)), allowOrigins, env };
29228
29637
  }
29229
- async function measureOauth(config, { requested, suites, entries: entries2 }, revision, setup, io) {
29638
+ async function measureOauth(config, { requested, suites, entries: entries2, profile }, revision, setup, io) {
29230
29639
  const era = eraOf(revision);
29231
29640
  const transport = config.target.kind === "stdio" ? "stdio" : "http";
29232
29641
  const secrets = /* @__PURE__ */ new Set();
@@ -29269,19 +29678,19 @@ async function measureOauth(config, { requested, suites, entries: entries2 }, re
29269
29678
  timeouts = outcome.state === "could-not-run" && outcome.reason === "timeout" ? timeouts + 1 : 0;
29270
29679
  results4.push(result(entry2, outcome, clean3));
29271
29680
  }
29272
- const summary = summarize2(results4);
29681
+ const summary = summarize2(results4, CATALOG, profile);
29273
29682
  const bucket = new Map(BUCKETS.flatMap((k) => summary[k].map((id2) => [id2, k])));
29274
29683
  for (const r of results4) r.bucket = bucket.get(r.id) ?? "pending";
29275
29684
  const bySuite = {};
29276
- for (const s of suites) bySuite[s] = summarize2(results4.filter((r) => r.suite === s));
29685
+ for (const s of suites) bySuite[s] = summarize2(results4.filter((r) => r.suite === s), CATALOG, profile);
29277
29686
  return {
29278
29687
  kind: "mcp-conformance-report",
29279
29688
  schemaVersion: 1,
29280
29689
  command: "conformance",
29281
29690
  checkerVersion: io.clientVersion ?? "0.0.0",
29282
- profileId: PROFILE.id,
29283
- profileVersion: PROFILE.version,
29284
- manifestDigest: manifestDigest(PROFILE.checks),
29691
+ profileId: profile.id,
29692
+ profileVersion: profile.version,
29693
+ manifestDigest: manifestDigest(profile.checks),
29285
29694
  protocolVersion: revision,
29286
29695
  protocolVersionRequested: requested,
29287
29696
  era,
@@ -29315,12 +29724,12 @@ function result(entry2, outcome, clean3) {
29315
29724
  ...outcome.details === void 0 ? {} : { details: outcome.details }
29316
29725
  };
29317
29726
  }
29318
- var import_node_fs16, import_node_path11, FORMATS, REVISION2, MAX_TEXT2, cut3, HANDSHAKE_CHECK, DISCOVER_CHECK, TIMEOUTS_IN_A_ROW, json, MODERN5, worstExit, MODERN_ERRORS, OAUTH_REVISIONS;
29727
+ var import_node_fs17, import_node_path11, FORMATS, REVISION2, MAX_TEXT2, cut3, HANDSHAKE_CHECK, DISCOVER_CHECK, TIMEOUTS_IN_A_ROW, json, MODERN5, worstExit, MODERN_ERRORS, OAUTH_REVISIONS;
29319
29728
  var init_mcp_conformance = __esm({
29320
29729
  "src/cli/commands/mcp-conformance.ts"() {
29321
29730
  "use strict";
29322
29731
  init_cjs_shims();
29323
- import_node_fs16 = require("fs");
29732
+ import_node_fs17 = require("fs");
29324
29733
  import_node_path11 = require("path");
29325
29734
  init_options();
29326
29735
  init_redact();
@@ -29464,7 +29873,7 @@ function parseJson(text6, opts) {
29464
29873
  let end2 = i;
29465
29874
  while (end2 < n && !",]} \r\n/".includes(text6[end2])) end2++;
29466
29875
  if (end2 === i) stop("unexpected-character");
29467
- if (!LITERAL.test(text6.slice(i, end2))) stop("bad-literal");
29876
+ if (!LITERAL2.test(text6.slice(i, end2))) stop("bad-literal");
29468
29877
  i = end2;
29469
29878
  return { t: "other", at: at2 };
29470
29879
  };
@@ -29494,7 +29903,7 @@ function lineLocator(text6) {
29494
29903
  return { line: lo + 1, column: at2 - starts[lo] + 1 };
29495
29904
  };
29496
29905
  }
29497
- var MAX_DEPTH3, Stop, LITERAL, PLAIN, HEX4, ESCAPES;
29906
+ var MAX_DEPTH3, Stop, LITERAL2, PLAIN, HEX4, ESCAPES;
29498
29907
  var init_json_tree = __esm({
29499
29908
  "src/mcp-testing/scan/config/json-tree.ts"() {
29500
29909
  "use strict";
@@ -29508,7 +29917,7 @@ var init_json_tree = __esm({
29508
29917
  category;
29509
29918
  at;
29510
29919
  };
29511
- LITERAL = /^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)$/;
29920
+ LITERAL2 = /^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)$/;
29512
29921
  PLAIN = /[^"\\\u0000-\u001f]*/y;
29513
29922
  HEX4 = /^[0-9a-fA-F]{4}$/;
29514
29923
  ESCAPES = {
@@ -30699,8 +31108,8 @@ function journalHeaders(headers) {
30699
31108
  function openProbeJournal(path25) {
30700
31109
  let fd;
30701
31110
  try {
30702
- fd = (0, import_node_fs17.openSync)(path25, "w", 384);
30703
- if (process.platform !== "win32") (0, import_node_fs17.fchmodSync)(fd, 384);
31111
+ fd = (0, import_node_fs18.openSync)(path25, "w", 384);
31112
+ if (process.platform !== "win32") (0, import_node_fs18.fchmodSync)(fd, 384);
30704
31113
  } catch {
30705
31114
  throw new UsageError("--journal: the file cannot be opened for writing.");
30706
31115
  }
@@ -30714,21 +31123,21 @@ function openProbeJournal(path25) {
30714
31123
  if (closed) throw new Error("journal closed");
30715
31124
  if (redact2 === void 0) throw new Error("journal not bound");
30716
31125
  const masked = redact2.value({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...line });
30717
- (0, import_node_fs17.writeSync)(fd, JSON.stringify(masked) + "\n");
31126
+ (0, import_node_fs18.writeSync)(fd, JSON.stringify(masked) + "\n");
30718
31127
  },
30719
31128
  close() {
30720
31129
  if (closed) return;
30721
31130
  closed = true;
30722
- (0, import_node_fs17.closeSync)(fd);
31131
+ (0, import_node_fs18.closeSync)(fd);
30723
31132
  }
30724
31133
  };
30725
31134
  }
30726
- var import_node_fs17;
31135
+ var import_node_fs18;
30727
31136
  var init_journal2 = __esm({
30728
31137
  "src/mcp-testing/scan/probes/journal.ts"() {
30729
31138
  "use strict";
30730
31139
  init_cjs_shims();
30731
- import_node_fs17 = require("fs");
31140
+ import_node_fs18 = require("fs");
30732
31141
  init_options();
30733
31142
  init_redact();
30734
31143
  }
@@ -32912,12 +33321,12 @@ function shown3(cwd, path25) {
32912
33321
  }
32913
33322
  function readText(cwd, path25, flag2, limit3 = true, max = MAX_FILE_BYTES) {
32914
33323
  const full2 = (0, import_node_path12.resolve)(cwd, path25);
32915
- if (!(0, import_node_fs18.existsSync)(full2)) throw new UsageError(`${flag2}: ${path25} does not exist.`);
33324
+ if (!(0, import_node_fs19.existsSync)(full2)) throw new UsageError(`${flag2}: ${path25} does not exist.`);
32916
33325
  const unreadable2 = () => new UnreadableError(`${flag2}: ${safeText(shown3(cwd, path25))} cannot be read.`);
32917
33326
  let size = 0;
32918
33327
  if (limit3)
32919
33328
  try {
32920
- size = (0, import_node_fs18.statSync)(full2).size;
33329
+ size = (0, import_node_fs19.statSync)(full2).size;
32921
33330
  } catch {
32922
33331
  throw unreadable2();
32923
33332
  }
@@ -32926,7 +33335,7 @@ function readText(cwd, path25, flag2, limit3 = true, max = MAX_FILE_BYTES) {
32926
33335
  `${flag2}: ${path25} is too large to read (over ${max >= 1024 * 1024 ? `${max / 1024 / 1024} MiB` : `${max / 1024} KiB`}).`
32927
33336
  );
32928
33337
  try {
32929
- return (0, import_node_fs18.readFileSync)(full2, "utf8");
33338
+ return (0, import_node_fs19.readFileSync)(full2, "utf8");
32930
33339
  } catch {
32931
33340
  throw unreadable2();
32932
33341
  }
@@ -32956,12 +33365,12 @@ function fileKeys(cwd, path25) {
32956
33365
  const keys = [];
32957
33366
  let real = full2;
32958
33367
  try {
32959
- real = import_node_fs18.realpathSync.native(full2);
32960
- const st = (0, import_node_fs18.statSync)(full2, { bigint: true });
33368
+ real = import_node_fs19.realpathSync.native(full2);
33369
+ const st = (0, import_node_fs19.statSync)(full2, { bigint: true });
32961
33370
  if (st.ino !== 0n) keys.push(`id:${st.dev}:${st.ino}`);
32962
33371
  } catch {
32963
33372
  try {
32964
- real = (0, import_node_path12.join)(import_node_fs18.realpathSync.native((0, import_node_path12.dirname)(full2)), (0, import_node_path12.basename)(full2));
33373
+ real = (0, import_node_path12.join)(import_node_fs19.realpathSync.native((0, import_node_path12.dirname)(full2)), (0, import_node_path12.basename)(full2));
32965
33374
  } catch {
32966
33375
  }
32967
33376
  }
@@ -33108,7 +33517,7 @@ async function scan(flags2, server2, io) {
33108
33517
  if ((flags2.config ?? []).length === 0 && flags2.client !== void 0) {
33109
33518
  configRequested = true;
33110
33519
  const path25 = CLIENT_FILES[flags2.client];
33111
- if ((0, import_node_fs18.existsSync)((0, import_node_path12.resolve)(io.cwd, path25)))
33520
+ if ((0, import_node_fs19.existsSync)((0, import_node_path12.resolve)(io.cwd, path25)))
33112
33521
  configFiles.push({
33113
33522
  path: path25,
33114
33523
  client: flags2.client,
@@ -33139,7 +33548,7 @@ async function scan(flags2, server2, io) {
33139
33548
  }
33140
33549
  }
33141
33550
  const today = io.today ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
33142
- const ignoreName = flags2.ignoreFile ?? ((0, import_node_fs18.existsSync)((0, import_node_path12.resolve)(io.cwd, DEFAULT_SCAN_IGNORE_FILE)) ? DEFAULT_SCAN_IGNORE_FILE : void 0);
33551
+ const ignoreName = flags2.ignoreFile ?? ((0, import_node_fs19.existsSync)((0, import_node_path12.resolve)(io.cwd, DEFAULT_SCAN_IGNORE_FILE)) ? DEFAULT_SCAN_IGNORE_FILE : void 0);
33143
33552
  const exceptions = ignoreName === void 0 ? void 0 : {
33144
33553
  file: shown3(io.cwd, ignoreName),
33145
33554
  ...parseScanExceptions(readText(io.cwd, ignoreName, "--ignore-file"), ignoreName, today, {
@@ -33234,12 +33643,12 @@ function planProbes(flags2, server2, io) {
33234
33643
  timeoutMs: config?.timeoutMs ?? 3e4
33235
33644
  };
33236
33645
  }
33237
- var import_node_fs18, import_node_path12, DEFAULT_SCAN_IGNORE_FILE, CLIENT_FILES, CLIENTS2, FORMATS2, FILE_FORMATS2, TooLargeError, UnreadableError;
33646
+ var import_node_fs19, import_node_path12, DEFAULT_SCAN_IGNORE_FILE, CLIENT_FILES, CLIENTS2, FORMATS2, FILE_FORMATS2, TooLargeError, UnreadableError;
33238
33647
  var init_mcp_scan = __esm({
33239
33648
  "src/cli/commands/mcp-scan.ts"() {
33240
33649
  "use strict";
33241
33650
  init_cjs_shims();
33242
- import_node_fs18 = require("fs");
33651
+ import_node_fs19 = require("fs");
33243
33652
  import_node_path12 = require("path");
33244
33653
  init_session();
33245
33654
  init_options();
@@ -34072,7 +34481,7 @@ function readMarkdown(cwd, file) {
34072
34481
  const target4 = (0, import_node_path13.resolve)(cwd, file);
34073
34482
  let size;
34074
34483
  try {
34075
- const st = (0, import_node_fs19.statSync)(target4);
34484
+ const st = (0, import_node_fs20.statSync)(target4);
34076
34485
  if (!st.isFile()) return usage(`${target4} is not a file.`);
34077
34486
  size = st.size;
34078
34487
  } catch {
@@ -34083,7 +34492,7 @@ function readMarkdown(cwd, file) {
34083
34492
  }
34084
34493
  let text6;
34085
34494
  try {
34086
- text6 = new TextDecoder("utf-8", { fatal: true }).decode((0, import_node_fs19.readFileSync)(target4));
34495
+ text6 = new TextDecoder("utf-8", { fatal: true }).decode((0, import_node_fs20.readFileSync)(target4));
34087
34496
  } catch {
34088
34497
  return usage(`${target4} is not valid UTF-8. Save it as UTF-8 and try again.`);
34089
34498
  }
@@ -34207,12 +34616,12 @@ function reportRequirementsImportFailure(err, write) {
34207
34616
  write(err.message + "\n");
34208
34617
  return err.exitCode;
34209
34618
  }
34210
- var import_node_fs19, import_node_path13, MAX_MARKDOWN_BYTES, RequirementsImportError, usage, COLUMN_FLAGS, SECTION_FLAGS, oneOf5, TABLE_SPEC_KEYS, SPEC_HELP, SUPPORT, SHOWN4, flat2, cut4, plural8;
34619
+ var import_node_fs20, import_node_path13, MAX_MARKDOWN_BYTES, RequirementsImportError, usage, COLUMN_FLAGS, SECTION_FLAGS, oneOf5, TABLE_SPEC_KEYS, SPEC_HELP, SUPPORT, SHOWN4, flat2, cut4, plural8;
34211
34620
  var init_requirements_import = __esm({
34212
34621
  "src/cli/commands/requirements-import.ts"() {
34213
34622
  "use strict";
34214
34623
  init_cjs_shims();
34215
- import_node_fs19 = require("fs");
34624
+ import_node_fs20 = require("fs");
34216
34625
  import_node_path13 = require("path");
34217
34626
  init_client();
34218
34627
  init_api_url();
@@ -34413,7 +34822,7 @@ async function loadSources(deps) {
34413
34822
  let raw;
34414
34823
  if (deps.from !== void 0) {
34415
34824
  try {
34416
- raw = (0, import_node_fs20.readFileSync)(deps.from, "utf8");
34825
+ raw = (0, import_node_fs21.readFileSync)(deps.from, "utf8");
34417
34826
  } catch {
34418
34827
  throw new SyncFileError(`cannot read ${deps.from}`);
34419
34828
  }
@@ -34465,13 +34874,13 @@ function formatVerify(r) {
34465
34874
  );
34466
34875
  return lines.join("\n") + "\n";
34467
34876
  }
34468
- var import_node_child_process4, import_node_fs20, TOKEN5;
34877
+ var import_node_child_process4, import_node_fs21, TOKEN5;
34469
34878
  var init_verify = __esm({
34470
34879
  "src/cli/commands/verify.ts"() {
34471
34880
  "use strict";
34472
34881
  init_cjs_shims();
34473
34882
  import_node_child_process4 = require("child_process");
34474
- import_node_fs20 = require("fs");
34883
+ import_node_fs21 = require("fs");
34475
34884
  init_plan();
34476
34885
  init_sync();
34477
34886
  TOKEN5 = /@P([A-Za-z0-9_-]+)/;
@@ -34886,10 +35295,10 @@ __export(ids_exports, {
34886
35295
  serializeMap: () => serializeMap
34887
35296
  });
34888
35297
  function readMap(file) {
34889
- if (!(0, import_node_fs21.existsSync)(file)) return {};
35298
+ if (!(0, import_node_fs22.existsSync)(file)) return {};
34890
35299
  let parsed4;
34891
35300
  try {
34892
- parsed4 = JSON.parse((0, import_node_fs21.readFileSync)(file, "utf8"));
35301
+ parsed4 = JSON.parse((0, import_node_fs22.readFileSync)(file, "utf8"));
34893
35302
  } catch {
34894
35303
  throw new SyncFileError(`${file} is not valid JSON; fix or remove it, nothing was written`);
34895
35304
  }
@@ -34937,8 +35346,8 @@ async function handleIds(deps) {
34937
35346
  let written = false;
34938
35347
  if (deps.write === true && Object.keys(plan.added).length > 0) {
34939
35348
  try {
34940
- (0, import_node_fs21.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true });
34941
- (0, import_node_fs21.writeFileSync)(file, serializeMap({ ...current, ...plan.added }));
35349
+ (0, import_node_fs22.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true });
35350
+ (0, import_node_fs22.writeFileSync)(file, serializeMap({ ...current, ...plan.added }));
34942
35351
  } catch {
34943
35352
  throw new SyncFileError(`cannot write ${file}`);
34944
35353
  }
@@ -34966,12 +35375,12 @@ function formatIds(r, write) {
34966
35375
  );
34967
35376
  return lines.join("\n") + "\n";
34968
35377
  }
34969
- var import_node_fs21, import_node_path14, DEFAULT_IDS_FILE, compareKeys;
35378
+ var import_node_fs22, import_node_path14, DEFAULT_IDS_FILE, compareKeys;
34970
35379
  var init_ids = __esm({
34971
35380
  "src/cli/commands/ids.ts"() {
34972
35381
  "use strict";
34973
35382
  init_cjs_shims();
34974
- import_node_fs21 = require("fs");
35383
+ import_node_fs22 = require("fs");
34975
35384
  import_node_path14 = require("path");
34976
35385
  init_verify();
34977
35386
  init_sync();
@@ -34990,7 +35399,7 @@ module.exports = __toCommonJS(cli_exports);
34990
35399
  init_cjs_shims();
34991
35400
  init_api_url();
34992
35401
  var import_commander = require("commander");
34993
- var import_node_fs22 = require("fs");
35402
+ var import_node_fs23 = require("fs");
34994
35403
  var import_node_path15 = require("path");
34995
35404
  var import_node_url = require("url");
34996
35405
  init_duration();
@@ -35027,7 +35436,7 @@ var rawArgsOf = (program) => program.rawArgs ?? [];
35027
35436
 
35028
35437
  // src/cli.ts
35029
35438
  var __dirname = (0, import_node_path15.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl));
35030
- var pkg = JSON.parse((0, import_node_fs22.readFileSync)((0, import_node_path15.join)(__dirname, "..", "package.json"), "utf-8"));
35439
+ var pkg = JSON.parse((0, import_node_fs23.readFileSync)((0, import_node_path15.join)(__dirname, "..", "package.json"), "utf-8"));
35031
35440
  function toFormat(s) {
35032
35441
  return s === "json" || s === "markdown" ? s : "console";
35033
35442
  }
@@ -35036,7 +35445,7 @@ function shouldColor(outputPath) {
35036
35445
  }
35037
35446
  function writeReport2(text6, outputPath) {
35038
35447
  if (outputPath !== void 0) {
35039
- (0, import_node_fs22.writeFileSync)(outputPath, text6);
35448
+ (0, import_node_fs23.writeFileSync)(outputPath, text6);
35040
35449
  } else {
35041
35450
  process.stdout.write(text6 + "\n");
35042
35451
  }
@@ -35426,8 +35835,8 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
35426
35835
  async (baseline, current, options, command) => {
35427
35836
  const verbose = command.optsWithGlobals().verbose === true;
35428
35837
  const [{ handleDiff: handleDiff2, DiffInputError: DiffInputError2 }, { renderDiff: renderDiff2 }] = await Promise.all([
35429
- Promise.resolve().then(() => (init_diff3(), diff_exports)),
35430
- Promise.resolve().then(() => (init_diff4(), diff_exports2))
35838
+ Promise.resolve().then(() => (init_diff4(), diff_exports2)),
35839
+ Promise.resolve().then(() => (init_diff2(), diff_exports))
35431
35840
  ]);
35432
35841
  try {
35433
35842
  const { format: _format, output: _output, ...gateFlags } = options;
@@ -35646,7 +36055,7 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
35646
36055
  mcp.command("conformance").description(
35647
36056
  "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"
35648
36057
  )
35649
- ).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("--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(
36058
+ ).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(
35650
36059
  "--out <[format=]path>",
35651
36060
  "Also write the result to this file, as json or junit-xml (default json); repeatable, one run for every file, secrets masked",
35652
36061
  repeat
@@ -35960,7 +36369,7 @@ function isMainModule() {
35960
36369
  const entry2 = process.argv[1];
35961
36370
  if (entry2 === void 0) return false;
35962
36371
  try {
35963
- return (0, import_node_fs22.realpathSync)(entry2) === (0, import_node_fs22.realpathSync)((0, import_node_url.fileURLToPath)(importMetaUrl));
36372
+ return (0, import_node_fs23.realpathSync)(entry2) === (0, import_node_fs23.realpathSync)((0, import_node_url.fileURLToPath)(importMetaUrl));
35964
36373
  } catch {
35965
36374
  return false;
35966
36375
  }