@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.js CHANGED
@@ -1547,10 +1547,18 @@ async function loadConfig(opts = {}) {
1547
1547
  init_esm_shims();
1548
1548
  function selfJudgeWarnings(config) {
1549
1549
  if ((config.providers?.length ?? 0) < 2) return [];
1550
- const inherited = (config.defaults?.assertions ?? []).some((a) => a.type === "llm-judge" && a.provider === void 0);
1551
- return config.evals.filter((ev) => inherited || ev.assertions.some((a) => a.type === "llm-judge" && a.provider === void 0)).map(
1552
- (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`
1553
- );
1550
+ const follows = (a) => a.type === "llm-judge" && a.provider?.model === void 0;
1551
+ const mixed = new Set(config.providers.map((p) => p.type)).size > 1;
1552
+ const typeless = (a) => mixed && a.type === "llm-judge" && a.provider?.model !== void 0 && a.provider.type === void 0;
1553
+ const any = (pred) => (ev) => (config.defaults?.assertions ?? []).some(pred) || ev.assertions.some(pred);
1554
+ return config.evals.flatMap((ev) => [
1555
+ ...any(follows)(ev) ? [
1556
+ `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`
1557
+ ] : [],
1558
+ ...any(typeless)(ev) ? [
1559
+ `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`
1560
+ ] : []
1561
+ ]);
1554
1562
  }
1555
1563
 
1556
1564
  // src/providers/index.ts
@@ -2723,12 +2731,16 @@ function parseQuestions(judgment) {
2723
2731
 
2724
2732
  // src/assertions/llm-judge.ts
2725
2733
  var DEFAULT_PASS_THRESHOLD = 0.5;
2726
- function prompt(criteria, output) {
2727
- 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>"}.
2734
+ function prompt(criteria, output, input) {
2735
+ const given = input === void 0 ? "" : "The OUTPUT is the answer to the INPUT; the CRITERIA are about the OUTPUT given that INPUT. ";
2736
+ 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>"}.
2728
2737
 
2729
2738
  CRITERIA: ${criteria}
2730
2739
 
2731
- OUTPUT:
2740
+ ` + (input === void 0 ? "" : `INPUT:
2741
+ ${input}
2742
+
2743
+ `) + `OUTPUT:
2732
2744
  ${output}`;
2733
2745
  }
2734
2746
  var llmJudge = {
@@ -2738,7 +2750,9 @@ var llmJudge = {
2738
2750
  }
2739
2751
  const criteria = interpolate(ctx.params.criteria, ctx);
2740
2752
  const threshold = ctx.params.pass_threshold ?? DEFAULT_PASS_THRESHOLD;
2741
- const { score, reason } = parseScored(await askJson(ctx.judge, prompt(criteria, ctx.output)));
2753
+ const { score, reason } = parseScored(
2754
+ await askJson(ctx.judge, prompt(criteria, ctx.output, ctx.input))
2755
+ );
2742
2756
  const passed = score >= threshold;
2743
2757
  return {
2744
2758
  passed,
@@ -4000,6 +4014,7 @@ async function runAgentRow(p) {
4000
4014
  const { records, assertionError, judgeCost, judgeUnpriced, advice } = await assess(
4001
4015
  p,
4002
4016
  output,
4017
+ prompt5,
4003
4018
  agent
4004
4019
  );
4005
4020
  const covered = p.assertions.filter((x) => x.type === "no-repeated-call");
@@ -4071,18 +4086,35 @@ function costFields(c) {
4071
4086
  function dryRunRow(vars, usage) {
4072
4087
  return { vars, output: null, cached: false, usage, inconclusive: "skipped", assertions: [] };
4073
4088
  }
4074
- async function assess(p, output, transcript) {
4089
+ async function assess(p, output, input, transcript) {
4075
4090
  let judgeCost = 0;
4076
4091
  let judgeUnpriced = false;
4077
- const judge = buildJudge(p.provider, p.providerConfig, (u) => {
4078
- const c = p.provider.estimateCost(u);
4079
- judgeCost += c.cost_usd;
4080
- if (c.priced === false) judgeUnpriced = true;
4081
- });
4082
4092
  const records = [];
4083
4093
  const advice = [];
4084
4094
  let assertionError;
4085
4095
  for (const assertion of p.assertions) {
4096
+ const own2 = assertion.type === "llm-judge" ? assertion.provider : void 0;
4097
+ const judgeCfg = own2 === void 0 ? p.providerConfig : { ...p.providerConfig, ...own2 };
4098
+ let judgedBy;
4099
+ const judge = () => {
4100
+ let provider = p.provider;
4101
+ if (own2 !== void 0) {
4102
+ if (p.resolveJudge === void 0)
4103
+ throw new Error("this run cannot build the judge named by the provider of an llm-judge check");
4104
+ provider = p.resolveJudge(judgeCfg);
4105
+ }
4106
+ const inner = buildJudge(provider, judgeCfg, (u) => {
4107
+ const c = provider.estimateCost(u);
4108
+ judgeCost += c.cost_usd;
4109
+ if (c.priced === false) judgeUnpriced = true;
4110
+ });
4111
+ return {
4112
+ ask: (q) => {
4113
+ judgedBy = `${judgeCfg.type}/${judgeCfg.model}`;
4114
+ return inner.ask(q);
4115
+ }
4116
+ };
4117
+ };
4086
4118
  const run = () => usesExpected(assertion) && (p.row.expected === void 0 || p.row.expected === "") ? Promise.resolve({
4087
4119
  passed: false,
4088
4120
  reason: "the row has no expected value, and this check compares against {{expected}}"
@@ -4092,7 +4124,8 @@ async function assess(p, output, transcript) {
4092
4124
  row: p.row,
4093
4125
  params: assertion,
4094
4126
  embedder: p.embedder,
4095
- judge,
4127
+ judge: judge(),
4128
+ ...input !== void 0 ? { input } : {},
4096
4129
  ...transcript !== void 0 ? { transcript } : {}
4097
4130
  });
4098
4131
  if (ASSERTION_CLASSES[assertion.type] === "heuristic") {
@@ -4109,7 +4142,8 @@ async function assess(p, output, transcript) {
4109
4142
  type: assertion.type,
4110
4143
  passed: result.passed,
4111
4144
  ...result.score !== void 0 ? { score: result.score } : {},
4112
- ...result.reason !== void 0 ? { reason: result.reason } : {}
4145
+ ...result.reason !== void 0 ? { reason: result.reason } : {},
4146
+ ...judgedBy !== void 0 ? { judge_model: judgedBy } : {}
4113
4147
  });
4114
4148
  } catch (err) {
4115
4149
  assertionError = toRunError(err);
@@ -4205,7 +4239,7 @@ async function runRow(p) {
4205
4239
  };
4206
4240
  }
4207
4241
  }
4208
- const { records, assertionError, judgeCost, judgeUnpriced } = await assess(p, output);
4242
+ const { records, assertionError, judgeCost, judgeUnpriced } = await assess(p, output, prompt5);
4209
4243
  const finalUsage = {
4210
4244
  ...usage,
4211
4245
  cost_usd: usage.cost_usd + judgeCost,
@@ -4394,6 +4428,15 @@ async function runOrchestration(config, options, deps) {
4394
4428
  });
4395
4429
  return { ev, template, rows, cells };
4396
4430
  });
4431
+ const judges = /* @__PURE__ */ new Map();
4432
+ const resolveJudge = (cfg) => {
4433
+ const key = canonicalJson(cfg);
4434
+ const known = judges.get(key);
4435
+ if (known !== void 0) return known;
4436
+ const made = deps.resolveProvider(cfg);
4437
+ judges.set(key, made);
4438
+ return made;
4439
+ };
4397
4440
  const swapped = Object.keys(options.toolDescriptions ?? {}).length > 0;
4398
4441
  if (swapped && !prepared.some((x) => x.ev.mcp !== void 0))
4399
4442
  throw new RunConfigError(
@@ -4413,6 +4456,7 @@ async function runOrchestration(config, options, deps) {
4413
4456
  row,
4414
4457
  providerConfig,
4415
4458
  provider,
4459
+ resolveJudge,
4416
4460
  embedder: deps.embedder,
4417
4461
  cache: deps.cache,
4418
4462
  now: deps.now,
@@ -4696,7 +4740,9 @@ var assertionResultRecordSchema2 = z3.object({
4696
4740
  passed: z3.boolean(),
4697
4741
  score: z3.number().optional(),
4698
4742
  reason: z3.string().optional(),
4699
- binaryVerdicts: z3.array(binaryVerdictSchema).optional()
4743
+ binaryVerdicts: z3.array(binaryVerdictSchema).optional(),
4744
+ /** plune-ai/cli#373. Optional and additive — a RunResult written before it validates unchanged. */
4745
+ judge_model: z3.string().optional()
4700
4746
  });
4701
4747
  var usageSchema = z3.object({
4702
4748
  input_tokens: z3.number(),
@@ -4843,7 +4889,7 @@ function traceUrlProblem(value) {
4843
4889
  } catch {
4844
4890
  return "must be an https address";
4845
4891
  }
4846
- if (parsed2.protocol !== "https:" || parsed2.hostname === "") return "must be an https address";
4892
+ if (!url.startsWith("https://") || parsed2.hostname === "") return "must be an https address";
4847
4893
  if (parsed2.username !== "" || parsed2.password !== "") return "must carry no user name or password";
4848
4894
  return void 0;
4849
4895
  }
@@ -5970,6 +6016,17 @@ init_esm_shims();
5970
6016
  import * as fs8 from "fs/promises";
5971
6017
  import * as path10 from "path";
5972
6018
 
6019
+ // src/importers/trace-url.ts
6020
+ init_esm_shims();
6021
+ init_failure_detail();
6022
+ function traceUrlOf(value, title, notes) {
6023
+ if (value === void 0 || typeof value === "string" && value.trim() === "") return void 0;
6024
+ const problem = traceUrlProblem(value);
6025
+ if (problem === void 0) return value.trim();
6026
+ notes.push(`plune: ${JSON.stringify(printable(title))}: trace link not sent (${problem}) \u2014 the result is imported without it.`);
6027
+ return void 0;
6028
+ }
6029
+
5973
6030
  // src/mcp-testing/scan/config/config.ts
5974
6031
  init_esm_shims();
5975
6032
 
@@ -7779,21 +7836,37 @@ async function defaultReadEvidence(dir) {
7779
7836
  return { name: str(rec["name"]), passed: rec["passed"] === true, ...error !== "" ? { error } : {} };
7780
7837
  });
7781
7838
  }
7782
- function casesFromDesign(report) {
7839
+ function casesFromDesign(report, notes) {
7783
7840
  const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
7784
- return list2.map((raw) => {
7841
+ const refused = /* @__PURE__ */ new Map();
7842
+ const cases = list2.map((raw) => {
7785
7843
  const c = asRecord(raw);
7786
7844
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
7845
+ const title = str(c["title"], "untitled case");
7846
+ const link = own(c, "traceUrl") ?? void 0;
7847
+ const said = [];
7848
+ const traceUrl = traceUrlOf(link, title, said);
7849
+ if (said.length > 0) {
7850
+ const key = typeof link === "string" ? link.trim() : typeof link;
7851
+ const before = refused.get(key) ?? 0;
7852
+ if (before === 0) notes.push(...said);
7853
+ refused.set(key, before + 1);
7854
+ }
7787
7855
  return {
7788
7856
  stableId: str(c["stableId"]),
7789
- title: str(c["title"], "untitled case"),
7857
+ title,
7790
7858
  execution: c["execution"] === "manual" ? "manual" : "auto",
7791
7859
  steps: steps.length > 0 ? steps : ["(no steps recorded)"],
7792
7860
  expected: str(c["expected"], "(no expected result recorded)"),
7793
7861
  ...typeof c["technique"] === "string" ? { technique: c["technique"] } : {},
7794
- ...typeof c["priority"] === "string" ? { priority: c["priority"] } : {}
7862
+ ...typeof c["priority"] === "string" ? { priority: c["priority"] } : {},
7863
+ ...traceUrl !== void 0 ? { traceUrl } : {}
7795
7864
  };
7796
7865
  });
7866
+ for (const times of refused.values()) {
7867
+ if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
7868
+ }
7869
+ return cases;
7797
7870
  }
7798
7871
  function casesFromApi(report, verdicts) {
7799
7872
  const list2 = Array.isArray(report["cases"]) ? report["cases"] : [];
@@ -7840,9 +7913,9 @@ async function readCairnRun(dir, deps = {}) {
7840
7913
  }
7841
7914
  cases = casesFromApi(report, verdicts);
7842
7915
  } else if (mode === "mcp") {
7843
- cases = own(report, "cases") === void 0 && Array.isArray(own(report, "testCases")) ? casesFromDesign(report) : await casesFromMcp(dir, report);
7916
+ cases = own(report, "cases") === void 0 && Array.isArray(own(report, "testCases")) ? casesFromDesign(report, deps.notes ?? []) : await casesFromMcp(dir, report);
7844
7917
  } else {
7845
- cases = casesFromDesign(report);
7918
+ cases = casesFromDesign(report, deps.notes ?? []);
7846
7919
  }
7847
7920
  const tokens = own(asRecord(own(report, "cost")), "totalTokens");
7848
7921
  return {
@@ -8089,7 +8162,8 @@ async function handleIngest(deps) {
8089
8162
  const token = (deps.loadToken ?? loadToken)();
8090
8163
  if (token === null) throw new IngestNotLoggedInError();
8091
8164
  const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
8092
- const payload = await readCairnRun(dir);
8165
+ const notes = [];
8166
+ const payload = await readCairnRun(dir, { notes });
8093
8167
  const session = await readCairnSessionFiles(dir).catch(() => void 0);
8094
8168
  for (const c of payload.cases) {
8095
8169
  const screencasts = session?.screencasts.get(c.stableId);
@@ -8107,6 +8181,7 @@ async function handleIngest(deps) {
8107
8181
  );
8108
8182
  if (files.length > 0) result.files = files;
8109
8183
  if (sent.repeat) result.repeat = true;
8184
+ if (notes.length > 0) result.notes = notes;
8110
8185
  await job.finish({ ok: true });
8111
8186
  if (job.problem !== void 0) result.jobProblem = job.problem;
8112
8187
  return result;
@@ -8157,6 +8232,7 @@ function formatIngestResult(r) {
8157
8232
  const files = (r.files ?? []).map((line, i) => i === 0 ? ` ${line}` : ` ${line}`);
8158
8233
  if (r.repeat === true) {
8159
8234
  return `${[
8235
+ ...r.notes ?? [],
8160
8236
  `This Cairn run was already ingested \u2192 ${r.runId}`,
8161
8237
  " nothing new was proposed or attached; a run with a new run id is ingested as new",
8162
8238
  ...files
@@ -8164,6 +8240,7 @@ function formatIngestResult(r) {
8164
8240
  `;
8165
8241
  }
8166
8242
  const lines = [
8243
+ ...r.notes ?? [],
8167
8244
  `Ingested Cairn run \u2192 ${r.runId}`,
8168
8245
  ` ${r.linked} result(s) attached to existing cases`,
8169
8246
  ` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.39.10",
3
+ "version": "0.39.12",
4
4
  "mcpName": "ai.plune/cli",
5
5
  "description": "AI-powered assertion testing for LLM apps — write assertions, run them against any provider, get a pass/fail report (local, CI, or diff).",
6
6
  "keywords": [