@plune-ai/cli 0.39.11 → 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
  }
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;
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;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.39.11",
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": [