@plune-ai/cli 0.39.10 → 0.39.12

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/index.cjs CHANGED
@@ -1585,10 +1585,18 @@ async function loadConfig(opts = {}) {
1585
1585
  init_cjs_shims();
1586
1586
  function selfJudgeWarnings(config) {
1587
1587
  if ((config.providers?.length ?? 0) < 2) return [];
1588
- const inherited = (config.defaults?.assertions ?? []).some((a) => a.type === "llm-judge" && a.provider === void 0);
1589
- return config.evals.filter((ev) => inherited || ev.assertions.some((a) => a.type === "llm-judge" && a.provider === void 0)).map(
1590
- (ev) => `eval "${ev.id}" has an llm-judge check without a provider: with several models each model judges its own answer, which favours it. Set provider on the check to name one judge for all`
1591
- );
1588
+ const follows = (a) => a.type === "llm-judge" && a.provider?.model === void 0;
1589
+ const mixed = new Set(config.providers.map((p) => p.type)).size > 1;
1590
+ const typeless = (a) => mixed && a.type === "llm-judge" && a.provider?.model !== void 0 && a.provider.type === void 0;
1591
+ const any = (pred) => (ev) => (config.defaults?.assertions ?? []).some(pred) || ev.assertions.some(pred);
1592
+ return config.evals.flatMap((ev) => [
1593
+ ...any(follows)(ev) ? [
1594
+ `eval "${ev.id}" has an llm-judge check whose provider names no model: with several models each model judges its own answer, which favours it. Set provider.type and provider.model on the check to name one judge for all`
1595
+ ] : [],
1596
+ ...any(typeless)(ev) ? [
1597
+ `eval "${ev.id}" has an llm-judge check whose provider names a model but no type: the models of this run are of several types, so each cell sends that model to its own provider. Set provider.type on the check too`
1598
+ ] : []
1599
+ ]);
1592
1600
  }
1593
1601
 
1594
1602
  // src/providers/index.ts
@@ -2761,12 +2769,16 @@ function parseQuestions(judgment) {
2761
2769
 
2762
2770
  // src/assertions/llm-judge.ts
2763
2771
  var DEFAULT_PASS_THRESHOLD = 0.5;
2764
- function prompt(criteria, output) {
2765
- return `You are a strict evaluator. Score from 0 to 1 how well the OUTPUT meets the CRITERIA. Respond ONLY with JSON: {"score": <0..1>, "reason": "<short explanation>"}.
2772
+ function prompt(criteria, output, input) {
2773
+ const given = input === void 0 ? "" : "The OUTPUT is the answer to the INPUT; the CRITERIA are about the OUTPUT given that INPUT. ";
2774
+ return "You are a strict evaluator. Score from 0 to 1 how well the OUTPUT meets the CRITERIA. " + given + `Respond ONLY with JSON: {"score": <0..1>, "reason": "<short explanation>"}.
2766
2775
 
2767
2776
  CRITERIA: ${criteria}
2768
2777
 
2769
- OUTPUT:
2778
+ ` + (input === void 0 ? "" : `INPUT:
2779
+ ${input}
2780
+
2781
+ `) + `OUTPUT:
2770
2782
  ${output}`;
2771
2783
  }
2772
2784
  var llmJudge = {
@@ -2776,7 +2788,9 @@ var llmJudge = {
2776
2788
  }
2777
2789
  const criteria = interpolate(ctx.params.criteria, ctx);
2778
2790
  const threshold = ctx.params.pass_threshold ?? DEFAULT_PASS_THRESHOLD;
2779
- const { score, reason } = parseScored(await askJson(ctx.judge, prompt(criteria, ctx.output)));
2791
+ const { score, reason } = parseScored(
2792
+ await askJson(ctx.judge, prompt(criteria, ctx.output, ctx.input))
2793
+ );
2780
2794
  const passed = score >= threshold;
2781
2795
  return {
2782
2796
  passed,
@@ -4038,6 +4052,7 @@ async function runAgentRow(p) {
4038
4052
  const { records, assertionError, judgeCost, judgeUnpriced, advice } = await assess(
4039
4053
  p,
4040
4054
  output,
4055
+ prompt5,
4041
4056
  agent
4042
4057
  );
4043
4058
  const covered = p.assertions.filter((x) => x.type === "no-repeated-call");
@@ -4109,18 +4124,35 @@ function costFields(c) {
4109
4124
  function dryRunRow(vars, usage) {
4110
4125
  return { vars, output: null, cached: false, usage, inconclusive: "skipped", assertions: [] };
4111
4126
  }
4112
- async function assess(p, output, transcript) {
4127
+ async function assess(p, output, input, transcript) {
4113
4128
  let judgeCost = 0;
4114
4129
  let judgeUnpriced = false;
4115
- const judge = buildJudge(p.provider, p.providerConfig, (u) => {
4116
- const c = p.provider.estimateCost(u);
4117
- judgeCost += c.cost_usd;
4118
- if (c.priced === false) judgeUnpriced = true;
4119
- });
4120
4130
  const records = [];
4121
4131
  const advice = [];
4122
4132
  let assertionError;
4123
4133
  for (const assertion of p.assertions) {
4134
+ const own2 = assertion.type === "llm-judge" ? assertion.provider : void 0;
4135
+ const judgeCfg = own2 === void 0 ? p.providerConfig : { ...p.providerConfig, ...own2 };
4136
+ let judgedBy;
4137
+ const judge = () => {
4138
+ let provider = p.provider;
4139
+ if (own2 !== void 0) {
4140
+ if (p.resolveJudge === void 0)
4141
+ throw new Error("this run cannot build the judge named by the provider of an llm-judge check");
4142
+ provider = p.resolveJudge(judgeCfg);
4143
+ }
4144
+ const inner = buildJudge(provider, judgeCfg, (u) => {
4145
+ const c = provider.estimateCost(u);
4146
+ judgeCost += c.cost_usd;
4147
+ if (c.priced === false) judgeUnpriced = true;
4148
+ });
4149
+ return {
4150
+ ask: (q) => {
4151
+ judgedBy = `${judgeCfg.type}/${judgeCfg.model}`;
4152
+ return inner.ask(q);
4153
+ }
4154
+ };
4155
+ };
4124
4156
  const run = () => usesExpected(assertion) && (p.row.expected === void 0 || p.row.expected === "") ? Promise.resolve({
4125
4157
  passed: false,
4126
4158
  reason: "the row has no expected value, and this check compares against {{expected}}"
@@ -4130,7 +4162,8 @@ async function assess(p, output, transcript) {
4130
4162
  row: p.row,
4131
4163
  params: assertion,
4132
4164
  embedder: p.embedder,
4133
- judge,
4165
+ judge: judge(),
4166
+ ...input !== void 0 ? { input } : {},
4134
4167
  ...transcript !== void 0 ? { transcript } : {}
4135
4168
  });
4136
4169
  if (ASSERTION_CLASSES[assertion.type] === "heuristic") {
@@ -4147,7 +4180,8 @@ async function assess(p, output, transcript) {
4147
4180
  type: assertion.type,
4148
4181
  passed: result.passed,
4149
4182
  ...result.score !== void 0 ? { score: result.score } : {},
4150
- ...result.reason !== void 0 ? { reason: result.reason } : {}
4183
+ ...result.reason !== void 0 ? { reason: result.reason } : {},
4184
+ ...judgedBy !== void 0 ? { judge_model: judgedBy } : {}
4151
4185
  });
4152
4186
  } catch (err) {
4153
4187
  assertionError = toRunError(err);
@@ -4243,7 +4277,7 @@ async function runRow(p) {
4243
4277
  };
4244
4278
  }
4245
4279
  }
4246
- const { records, assertionError, judgeCost, judgeUnpriced } = await assess(p, output);
4280
+ const { records, assertionError, judgeCost, judgeUnpriced } = await assess(p, output, prompt5);
4247
4281
  const finalUsage = {
4248
4282
  ...usage,
4249
4283
  cost_usd: usage.cost_usd + judgeCost,
@@ -4432,6 +4466,15 @@ async function runOrchestration(config, options, deps) {
4432
4466
  });
4433
4467
  return { ev, template, rows, cells };
4434
4468
  });
4469
+ const judges = /* @__PURE__ */ new Map();
4470
+ const resolveJudge = (cfg) => {
4471
+ const key = canonicalJson(cfg);
4472
+ const known = judges.get(key);
4473
+ if (known !== void 0) return known;
4474
+ const made = deps.resolveProvider(cfg);
4475
+ judges.set(key, made);
4476
+ return made;
4477
+ };
4435
4478
  const swapped = Object.keys(options.toolDescriptions ?? {}).length > 0;
4436
4479
  if (swapped && !prepared.some((x) => x.ev.mcp !== void 0))
4437
4480
  throw new RunConfigError(
@@ -4451,6 +4494,7 @@ async function runOrchestration(config, options, deps) {
4451
4494
  row,
4452
4495
  providerConfig,
4453
4496
  provider,
4497
+ resolveJudge,
4454
4498
  embedder: deps.embedder,
4455
4499
  cache: deps.cache,
4456
4500
  now: deps.now,
@@ -4734,7 +4778,9 @@ var assertionResultRecordSchema2 = import_zod3.z.object({
4734
4778
  passed: import_zod3.z.boolean(),
4735
4779
  score: import_zod3.z.number().optional(),
4736
4780
  reason: import_zod3.z.string().optional(),
4737
- binaryVerdicts: import_zod3.z.array(binaryVerdictSchema).optional()
4781
+ binaryVerdicts: import_zod3.z.array(binaryVerdictSchema).optional(),
4782
+ /** plune-ai/cli#373. Optional and additive — a RunResult written before it validates unchanged. */
4783
+ judge_model: import_zod3.z.string().optional()
4738
4784
  });
4739
4785
  var usageSchema = import_zod3.z.object({
4740
4786
  input_tokens: import_zod3.z.number(),
@@ -4881,7 +4927,7 @@ function traceUrlProblem(value) {
4881
4927
  } catch {
4882
4928
  return "must be an https address";
4883
4929
  }
4884
- if (parsed2.protocol !== "https:" || parsed2.hostname === "") return "must be an https address";
4930
+ if (!url.startsWith("https://") || parsed2.hostname === "") return "must be an https address";
4885
4931
  if (parsed2.username !== "" || parsed2.password !== "") return "must carry no user name or password";
4886
4932
  return void 0;
4887
4933
  }
@@ -6008,6 +6054,17 @@ init_cjs_shims();
6008
6054
  var fs8 = __toESM(require("fs/promises"), 1);
6009
6055
  var path9 = __toESM(require("path"), 1);
6010
6056
 
6057
+ // src/importers/trace-url.ts
6058
+ init_cjs_shims();
6059
+ init_failure_detail();
6060
+ function traceUrlOf(value, title, notes) {
6061
+ if (value === void 0 || typeof value === "string" && value.trim() === "") return void 0;
6062
+ const problem = traceUrlProblem(value);
6063
+ if (problem === void 0) return value.trim();
6064
+ notes.push(`plune: ${JSON.stringify(printable(title))}: trace link not sent (${problem}) \u2014 the result is imported without it.`);
6065
+ return void 0;
6066
+ }
6067
+
6011
6068
  // src/mcp-testing/scan/config/config.ts
6012
6069
  init_cjs_shims();
6013
6070
 
@@ -7817,21 +7874,37 @@ async function defaultReadEvidence(dir) {
7817
7874
  return { name: str(rec["name"]), passed: rec["passed"] === true, ...error !== "" ? { error } : {} };
7818
7875
  });
7819
7876
  }
7820
- function casesFromDesign(report) {
7877
+ function casesFromDesign(report, notes) {
7821
7878
  const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
7822
- return list2.map((raw) => {
7879
+ const refused = /* @__PURE__ */ new Map();
7880
+ const cases = list2.map((raw) => {
7823
7881
  const c = asRecord(raw);
7824
7882
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
7883
+ const title = str(c["title"], "untitled case");
7884
+ const link = own(c, "traceUrl") ?? void 0;
7885
+ const said = [];
7886
+ const traceUrl = traceUrlOf(link, title, said);
7887
+ if (said.length > 0) {
7888
+ const key = typeof link === "string" ? link.trim() : typeof link;
7889
+ const before = refused.get(key) ?? 0;
7890
+ if (before === 0) notes.push(...said);
7891
+ refused.set(key, before + 1);
7892
+ }
7825
7893
  return {
7826
7894
  stableId: str(c["stableId"]),
7827
- title: str(c["title"], "untitled case"),
7895
+ title,
7828
7896
  execution: c["execution"] === "manual" ? "manual" : "auto",
7829
7897
  steps: steps.length > 0 ? steps : ["(no steps recorded)"],
7830
7898
  expected: str(c["expected"], "(no expected result recorded)"),
7831
7899
  ...typeof c["technique"] === "string" ? { technique: c["technique"] } : {},
7832
- ...typeof c["priority"] === "string" ? { priority: c["priority"] } : {}
7900
+ ...typeof c["priority"] === "string" ? { priority: c["priority"] } : {},
7901
+ ...traceUrl !== void 0 ? { traceUrl } : {}
7833
7902
  };
7834
7903
  });
7904
+ for (const times of refused.values()) {
7905
+ if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
7906
+ }
7907
+ return cases;
7835
7908
  }
7836
7909
  function casesFromApi(report, verdicts) {
7837
7910
  const list2 = Array.isArray(report["cases"]) ? report["cases"] : [];
@@ -7878,9 +7951,9 @@ async function readCairnRun(dir, deps = {}) {
7878
7951
  }
7879
7952
  cases = casesFromApi(report, verdicts);
7880
7953
  } else if (mode === "mcp") {
7881
- cases = own(report, "cases") === void 0 && Array.isArray(own(report, "testCases")) ? casesFromDesign(report) : await casesFromMcp(dir, report);
7954
+ cases = own(report, "cases") === void 0 && Array.isArray(own(report, "testCases")) ? casesFromDesign(report, deps.notes ?? []) : await casesFromMcp(dir, report);
7882
7955
  } else {
7883
- cases = casesFromDesign(report);
7956
+ cases = casesFromDesign(report, deps.notes ?? []);
7884
7957
  }
7885
7958
  const tokens = own(asRecord(own(report, "cost")), "totalTokens");
7886
7959
  return {
@@ -8127,7 +8200,8 @@ async function handleIngest(deps) {
8127
8200
  const token = (deps.loadToken ?? loadToken)();
8128
8201
  if (token === null) throw new IngestNotLoggedInError();
8129
8202
  const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
8130
- const payload = await readCairnRun(dir);
8203
+ const notes = [];
8204
+ const payload = await readCairnRun(dir, { notes });
8131
8205
  const session = await readCairnSessionFiles(dir).catch(() => void 0);
8132
8206
  for (const c of payload.cases) {
8133
8207
  const screencasts = session?.screencasts.get(c.stableId);
@@ -8145,6 +8219,7 @@ async function handleIngest(deps) {
8145
8219
  );
8146
8220
  if (files.length > 0) result.files = files;
8147
8221
  if (sent.repeat) result.repeat = true;
8222
+ if (notes.length > 0) result.notes = notes;
8148
8223
  await job.finish({ ok: true });
8149
8224
  if (job.problem !== void 0) result.jobProblem = job.problem;
8150
8225
  return result;
@@ -8195,6 +8270,7 @@ function formatIngestResult(r) {
8195
8270
  const files = (r.files ?? []).map((line, i) => i === 0 ? ` ${line}` : ` ${line}`);
8196
8271
  if (r.repeat === true) {
8197
8272
  return `${[
8273
+ ...r.notes ?? [],
8198
8274
  `This Cairn run was already ingested \u2192 ${r.runId}`,
8199
8275
  " nothing new was proposed or attached; a run with a new run id is ingested as new",
8200
8276
  ...files
@@ -8202,6 +8278,7 @@ function formatIngestResult(r) {
8202
8278
  `;
8203
8279
  }
8204
8280
  const lines = [
8281
+ ...r.notes ?? [],
8205
8282
  `Ingested Cairn run \u2192 ${r.runId}`,
8206
8283
  ` ${r.linked} result(s) attached to existing cases`,
8207
8284
  ` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
package/dist/index.d.cts CHANGED
@@ -39,6 +39,11 @@ interface AssertionResultRecord {
39
39
  passed: boolean;
40
40
  score?: number;
41
41
  reason?: string;
42
+ /**
43
+ * plune-ai/cli#373. `<type>/<model>` of the model that judged the check, on a check a model judged (llm-judge,
44
+ * faithfulness, answer-relevance, context-precision). Optional and additive: a run written before it reads as before.
45
+ */
46
+ judge_model?: string;
42
47
  }
43
48
  interface Usage {
44
49
  input_tokens: number;
@@ -883,6 +888,7 @@ declare const assertionResultRecordSchema: z.ZodObject<{
883
888
  question: z.ZodString;
884
889
  passed: z.ZodBoolean;
885
890
  }, z.core.$strip>>>;
891
+ judge_model: z.ZodOptional<z.ZodString>;
886
892
  }, z.core.$strip>;
887
893
  declare const runResultSchema: z.ZodObject<{
888
894
  schemaVersion: z.ZodLiteral<1>;
@@ -939,6 +945,7 @@ declare const runResultSchema: z.ZodObject<{
939
945
  question: z.ZodString;
940
946
  passed: z.ZodBoolean;
941
947
  }, z.core.$strip>>>;
948
+ judge_model: z.ZodOptional<z.ZodString>;
942
949
  }, z.core.$strip>>;
943
950
  cache_saved: z.ZodOptional<z.ZodObject<{
944
951
  input_tokens: z.ZodNumber;
@@ -978,6 +985,7 @@ declare const runResultSchema: z.ZodObject<{
978
985
  question: z.ZodString;
979
986
  passed: z.ZodBoolean;
980
987
  }, z.core.$strip>>>;
988
+ judge_model: z.ZodOptional<z.ZodString>;
981
989
  }, z.core.$strip>>;
982
990
  cache_saved: z.ZodOptional<z.ZodObject<{
983
991
  input_tokens: z.ZodNumber;
@@ -1232,6 +1240,8 @@ interface IngestResult {
1232
1240
  files?: string[];
1233
1241
  /** The platform already held a run for this report's run id (answered 200): the counters are the first ingest's, nothing new was written. */
1234
1242
  repeat?: true;
1243
+ /** What the reader left out of the payload and why (a trace link the platform would refuse): whole lines, printed first. */
1244
+ notes?: string[];
1235
1245
  }
1236
1246
  declare function handleIngest(deps: IngestDeps): Promise<IngestResult>;
1237
1247
  /**
@@ -1264,6 +1274,8 @@ interface CairnIngestCase {
1264
1274
  verdict?: CairnVerdict;
1265
1275
  technique?: string;
1266
1276
  priority?: string;
1277
+ /** The https address of the run's trace, as the report gives it to the case. Absent when it gives none or the link is refused. */
1278
+ traceUrl?: string;
1267
1279
  /** The case's recordings, from `screencasts/screencasts.json`. Absent when the run recorded none for it. */
1268
1280
  screencasts?: CairnScreencast[];
1269
1281
  }
@@ -1307,6 +1319,8 @@ interface EvidenceRecord {
1307
1319
  interface ReadCairnRunDeps {
1308
1320
  /** Injected for tests; returns `undefined` when the run executed nothing and wrote no evidence. */
1309
1321
  readEvidence?: (dir: string) => Promise<EvidenceRecord[] | undefined>;
1322
+ /** Lines for the person, filled while reading: what was left out of the payload and why. */
1323
+ notes?: string[];
1310
1324
  }
1311
1325
  /**
1312
1326
  * Read a Cairn run directory into an upload payload, or throw a typed error explaining why not.
package/dist/index.d.ts CHANGED
@@ -39,6 +39,11 @@ interface AssertionResultRecord {
39
39
  passed: boolean;
40
40
  score?: number;
41
41
  reason?: string;
42
+ /**
43
+ * plune-ai/cli#373. `<type>/<model>` of the model that judged the check, on a check a model judged (llm-judge,
44
+ * faithfulness, answer-relevance, context-precision). Optional and additive: a run written before it reads as before.
45
+ */
46
+ judge_model?: string;
42
47
  }
43
48
  interface Usage {
44
49
  input_tokens: number;
@@ -883,6 +888,7 @@ declare const assertionResultRecordSchema: z.ZodObject<{
883
888
  question: z.ZodString;
884
889
  passed: z.ZodBoolean;
885
890
  }, z.core.$strip>>>;
891
+ judge_model: z.ZodOptional<z.ZodString>;
886
892
  }, z.core.$strip>;
887
893
  declare const runResultSchema: z.ZodObject<{
888
894
  schemaVersion: z.ZodLiteral<1>;
@@ -939,6 +945,7 @@ declare const runResultSchema: z.ZodObject<{
939
945
  question: z.ZodString;
940
946
  passed: z.ZodBoolean;
941
947
  }, z.core.$strip>>>;
948
+ judge_model: z.ZodOptional<z.ZodString>;
942
949
  }, z.core.$strip>>;
943
950
  cache_saved: z.ZodOptional<z.ZodObject<{
944
951
  input_tokens: z.ZodNumber;
@@ -978,6 +985,7 @@ declare const runResultSchema: z.ZodObject<{
978
985
  question: z.ZodString;
979
986
  passed: z.ZodBoolean;
980
987
  }, z.core.$strip>>>;
988
+ judge_model: z.ZodOptional<z.ZodString>;
981
989
  }, z.core.$strip>>;
982
990
  cache_saved: z.ZodOptional<z.ZodObject<{
983
991
  input_tokens: z.ZodNumber;
@@ -1232,6 +1240,8 @@ interface IngestResult {
1232
1240
  files?: string[];
1233
1241
  /** The platform already held a run for this report's run id (answered 200): the counters are the first ingest's, nothing new was written. */
1234
1242
  repeat?: true;
1243
+ /** What the reader left out of the payload and why (a trace link the platform would refuse): whole lines, printed first. */
1244
+ notes?: string[];
1235
1245
  }
1236
1246
  declare function handleIngest(deps: IngestDeps): Promise<IngestResult>;
1237
1247
  /**
@@ -1264,6 +1274,8 @@ interface CairnIngestCase {
1264
1274
  verdict?: CairnVerdict;
1265
1275
  technique?: string;
1266
1276
  priority?: string;
1277
+ /** The https address of the run's trace, as the report gives it to the case. Absent when it gives none or the link is refused. */
1278
+ traceUrl?: string;
1267
1279
  /** The case's recordings, from `screencasts/screencasts.json`. Absent when the run recorded none for it. */
1268
1280
  screencasts?: CairnScreencast[];
1269
1281
  }
@@ -1307,6 +1319,8 @@ interface EvidenceRecord {
1307
1319
  interface ReadCairnRunDeps {
1308
1320
  /** Injected for tests; returns `undefined` when the run executed nothing and wrote no evidence. */
1309
1321
  readEvidence?: (dir: string) => Promise<EvidenceRecord[] | undefined>;
1322
+ /** Lines for the person, filled while reading: what was left out of the payload and why. */
1323
+ notes?: string[];
1310
1324
  }
1311
1325
  /**
1312
1326
  * Read a Cairn run directory into an upload payload, or throw a typed error explaining why not.