@plune-ai/cli 0.40.0 → 0.40.2

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
@@ -5852,9 +5852,11 @@ function notLocal(req, port, bound = "127.0.0.1") {
5852
5852
  const hosts = names.flatMap((name) => port === 80 ? [name, `${name}:80`] : [`${name}:${port}`]);
5853
5853
  const host = (req.headers.host ?? "").toLowerCase();
5854
5854
  const { origin } = req.headers;
5855
- return !hosts.includes(host) || origin !== void 0 && !hosts.some((h) => origin.toLowerCase() === `http://${h}`);
5855
+ const site = req.headers["sec-fetch-site"];
5856
+ return !hosts.includes(host) || origin !== void 0 && !hosts.some((h) => origin.toLowerCase() === `http://${h}`) || // Fail closed: of the four values a browser sends, `cross-site` and `same-site` are another origin.
5857
+ site !== void 0 && !["same-origin", "none"].includes(String(site).toLowerCase());
5856
5858
  }
5857
- var NOT_LOCAL_MESSAGE = "This server answers only a request addressed to 127.0.0.1, localhost or [::1] with its own port, and none a web page of another origin sent";
5859
+ var NOT_LOCAL_MESSAGE = "This server answers only a request addressed to 127.0.0.1, localhost or [::1] with its own port, and none a browser marks as sent from another origin";
5858
5860
  function maskedHeaders(headers) {
5859
5861
  const out = {};
5860
5862
  for (const [name, value] of Object.entries(headers)) {
@@ -9264,6 +9266,7 @@ var safeText = (text) => noCommands(
9264
9266
  // src/cli/commands/cairn-artifact.ts
9265
9267
  var SUPPORTED_ARTIFACT_VERSION = 1;
9266
9268
  var INGEST_SCHEMA_VERSION = 1;
9269
+ var RATIONALE_MAX = 400;
9267
9270
  var NoCairnRunsError = class extends Error {
9268
9271
  constructor(runsDir) {
9269
9272
  super(`No Cairn run found under ${runsDir} \u2014 name the directory instead: plune ingest <dir>.`);
@@ -9534,10 +9537,14 @@ async function defaultReadEvidence(dir) {
9534
9537
  function casesFromDesign(report, notes) {
9535
9538
  const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
9536
9539
  const refused = /* @__PURE__ */ new Map();
9540
+ let cut = 0;
9537
9541
  const cases = list2.map((raw) => {
9538
9542
  const c = asRecord(raw);
9539
9543
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
9540
9544
  const title = str(c["title"], "untitled case");
9545
+ const why = own2(c, "rationale");
9546
+ const rationale = typeof why === "string" ? why.trim() : "";
9547
+ if (rationale.length > RATIONALE_MAX) cut += 1;
9541
9548
  const link = own2(c, "traceUrl") ?? void 0;
9542
9549
  const said = [];
9543
9550
  const traceUrl = traceUrlOf(link, title, said);
@@ -9555,12 +9562,14 @@ function casesFromDesign(report, notes) {
9555
9562
  expected: str(c["expected"], "(no expected result recorded)"),
9556
9563
  ...typeof c["technique"] === "string" ? { technique: c["technique"] } : {},
9557
9564
  ...typeof c["priority"] === "string" ? { priority: c["priority"] } : {},
9565
+ ...rationale !== "" ? { rationale: clip(rationale, RATIONALE_MAX) } : {},
9558
9566
  ...traceUrl !== void 0 ? { traceUrl } : {}
9559
9567
  };
9560
9568
  });
9561
9569
  for (const times of refused.values()) {
9562
9570
  if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
9563
9571
  }
9572
+ if (cut > 0) notes.push(`plune: ${cut} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
9564
9573
  return cases;
9565
9574
  }
9566
9575
  function casesFromApi(report, verdicts) {
@@ -9626,7 +9635,7 @@ async function readCairnRun(dir, deps = {}) {
9626
9635
  };
9627
9636
  }
9628
9637
  var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
9629
- var clip = (s) => s.slice(0, DECLARED.text).replace(/[\uD800-\uDBFF]$/, "");
9638
+ var clip = (s, max = DECLARED.text) => s.slice(0, max).replace(/[\uD800-\uDBFF]$/, "");
9630
9639
  async function readCairnSessionFiles(dir) {
9631
9640
  const raw = await readJson(path9.join(dir, "screencasts", "screencasts.json"));
9632
9641
  if (!Array.isArray(raw)) return void 0;
package/dist/index.d.cts CHANGED
@@ -1499,6 +1499,8 @@ interface CairnIngestCase {
1499
1499
  verdict?: CairnVerdict;
1500
1500
  technique?: string;
1501
1501
  priority?: string;
1502
+ /** Why the case exists, in the words of whoever wrote it; the review queue shows it when the proposal is opened. */
1503
+ rationale?: string;
1502
1504
  /** 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. */
1503
1505
  traceUrl?: string;
1504
1506
  /** The case's recordings, from `screencasts/screencasts.json`. Absent when the run recorded none for it. */
package/dist/index.d.ts CHANGED
@@ -1499,6 +1499,8 @@ interface CairnIngestCase {
1499
1499
  verdict?: CairnVerdict;
1500
1500
  technique?: string;
1501
1501
  priority?: string;
1502
+ /** Why the case exists, in the words of whoever wrote it; the review queue shows it when the proposal is opened. */
1503
+ rationale?: string;
1502
1504
  /** 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. */
1503
1505
  traceUrl?: string;
1504
1506
  /** The case's recordings, from `screencasts/screencasts.json`. Absent when the run recorded none for it. */
package/dist/index.js CHANGED
@@ -5814,9 +5814,11 @@ function notLocal(req, port, bound = "127.0.0.1") {
5814
5814
  const hosts = names.flatMap((name) => port === 80 ? [name, `${name}:80`] : [`${name}:${port}`]);
5815
5815
  const host = (req.headers.host ?? "").toLowerCase();
5816
5816
  const { origin } = req.headers;
5817
- return !hosts.includes(host) || origin !== void 0 && !hosts.some((h) => origin.toLowerCase() === `http://${h}`);
5817
+ const site = req.headers["sec-fetch-site"];
5818
+ return !hosts.includes(host) || origin !== void 0 && !hosts.some((h) => origin.toLowerCase() === `http://${h}`) || // Fail closed: of the four values a browser sends, `cross-site` and `same-site` are another origin.
5819
+ site !== void 0 && !["same-origin", "none"].includes(String(site).toLowerCase());
5818
5820
  }
5819
- var NOT_LOCAL_MESSAGE = "This server answers only a request addressed to 127.0.0.1, localhost or [::1] with its own port, and none a web page of another origin sent";
5821
+ var NOT_LOCAL_MESSAGE = "This server answers only a request addressed to 127.0.0.1, localhost or [::1] with its own port, and none a browser marks as sent from another origin";
5820
5822
  function maskedHeaders(headers) {
5821
5823
  const out = {};
5822
5824
  for (const [name, value] of Object.entries(headers)) {
@@ -9226,6 +9228,7 @@ var safeText = (text) => noCommands(
9226
9228
  // src/cli/commands/cairn-artifact.ts
9227
9229
  var SUPPORTED_ARTIFACT_VERSION = 1;
9228
9230
  var INGEST_SCHEMA_VERSION = 1;
9231
+ var RATIONALE_MAX = 400;
9229
9232
  var NoCairnRunsError = class extends Error {
9230
9233
  constructor(runsDir) {
9231
9234
  super(`No Cairn run found under ${runsDir} \u2014 name the directory instead: plune ingest <dir>.`);
@@ -9496,10 +9499,14 @@ async function defaultReadEvidence(dir) {
9496
9499
  function casesFromDesign(report, notes) {
9497
9500
  const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
9498
9501
  const refused = /* @__PURE__ */ new Map();
9502
+ let cut = 0;
9499
9503
  const cases = list2.map((raw) => {
9500
9504
  const c = asRecord(raw);
9501
9505
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
9502
9506
  const title = str(c["title"], "untitled case");
9507
+ const why = own2(c, "rationale");
9508
+ const rationale = typeof why === "string" ? why.trim() : "";
9509
+ if (rationale.length > RATIONALE_MAX) cut += 1;
9503
9510
  const link = own2(c, "traceUrl") ?? void 0;
9504
9511
  const said = [];
9505
9512
  const traceUrl = traceUrlOf(link, title, said);
@@ -9517,12 +9524,14 @@ function casesFromDesign(report, notes) {
9517
9524
  expected: str(c["expected"], "(no expected result recorded)"),
9518
9525
  ...typeof c["technique"] === "string" ? { technique: c["technique"] } : {},
9519
9526
  ...typeof c["priority"] === "string" ? { priority: c["priority"] } : {},
9527
+ ...rationale !== "" ? { rationale: clip(rationale, RATIONALE_MAX) } : {},
9520
9528
  ...traceUrl !== void 0 ? { traceUrl } : {}
9521
9529
  };
9522
9530
  });
9523
9531
  for (const times of refused.values()) {
9524
9532
  if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
9525
9533
  }
9534
+ if (cut > 0) notes.push(`plune: ${cut} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
9526
9535
  return cases;
9527
9536
  }
9528
9537
  function casesFromApi(report, verdicts) {
@@ -9588,7 +9597,7 @@ async function readCairnRun(dir, deps = {}) {
9588
9597
  };
9589
9598
  }
9590
9599
  var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
9591
- var clip = (s) => s.slice(0, DECLARED.text).replace(/[\uD800-\uDBFF]$/, "");
9600
+ var clip = (s, max = DECLARED.text) => s.slice(0, max).replace(/[\uD800-\uDBFF]$/, "");
9592
9601
  async function readCairnSessionFiles(dir) {
9593
9602
  const raw = await readJson(path10.join(dir, "screencasts", "screencasts.json"));
9594
9603
  if (!Array.isArray(raw)) return void 0;
@@ -45,6 +45,7 @@ __export(reporter_core_exports, {
45
45
  repoRootOf: () => repoRootOf,
46
46
  resultKey: () => resultKey,
47
47
  startRun: () => startRun,
48
+ stepTitlesOf: () => stepTitlesOf,
48
49
  webLink: () => webLink
49
50
  });
50
51
  module.exports = __toCommonJS(reporter_core_exports);
@@ -567,6 +568,11 @@ function chosen({ status, errors }) {
567
568
  }
568
569
  return errors[0];
569
570
  }
571
+ function stepTitlesOf(attempt) {
572
+ if (attempt.status !== "passed") return void 0;
573
+ const titles = attempt.steps.map((s) => s.title.trim()).filter((t) => t !== "");
574
+ return titles.length > 0 ? titles : void 0;
575
+ }
570
576
  function chainOf(steps) {
571
577
  const chain = [];
572
578
  for (let failed = steps.find((s) => s.failed); failed !== void 0; failed = failed.steps.find((s) => s.failed)) {
@@ -1993,5 +1999,6 @@ function resultKey(testId, retry) {
1993
1999
  repoRootOf,
1994
2000
  resultKey,
1995
2001
  startRun,
2002
+ stepTitlesOf,
1996
2003
  webLink
1997
2004
  });
@@ -238,6 +238,11 @@ interface PendingResult {
238
238
  * nothing found. A platform older than the field is handled as for `targets`.
239
239
  */
240
240
  findings?: ResultFindings;
241
+ /**
242
+ * The titles of the top-level `test.step` calls of a passed attempt, in order (`stepTitlesOf`). The platform proposes them as the text of
243
+ * the test's case when they differ from its description. Absent rather than empty; a platform older than the field ignores it.
244
+ */
245
+ stepTitles?: string[];
241
246
  }
242
247
  /** Where in the test a finding belongs: a declared step, by its position from 1 and its title. */
243
248
  interface FindingStep {
@@ -713,6 +718,13 @@ declare function errorContextFields(attempt: FailedAttempt, home?: string): {
713
718
  * bodies must not hold them all until a batch is sent.
714
719
  */
715
720
  declare function filesOf(attempt: FailedAttempt): ResultFile[];
721
+ /**
722
+ * The titles of a passed attempt's top-level declared steps (`test.step`), in the order they ran, the empty ones left out. The platform
723
+ * compares them with the description of the test's case and, when they differ, queues a proposal to update it. Only a passed attempt
724
+ * says which steps the test has - a failed one stopped somewhere among them - and the nested steps stay out: a case's description is a
725
+ * flat list. Absent when there are none.
726
+ */
727
+ declare function stepTitlesOf(attempt: Pick<FailedAttempt, 'status' | 'steps'>): string[] | undefined;
716
728
  /**
717
729
  * A link only for an address a browser opens as a page — never `file:`, `javascript:` or half a URL.
718
730
  * As the platform checks it: `new URL` alone mends `https:/host` and `https:host` into https, and a
@@ -729,4 +741,4 @@ declare function webLink(href: string | undefined): string | undefined;
729
741
  */
730
742
  declare function maskCredentials(text: string): string;
731
743
 
732
- export { type AssertionRecord, type Attachment, type AttemptError, type ClientFailureKind, type ClientOptions, type ClientOutcome, DEFAULT_FALLBACK_PATH, type DeclaredStep, type DeferredBatch, type DeferredResult, type EnvSettings, type Execution, type ExpectedEntry, type ExternalKeyKind, type FailedAttempt, type FailureDetail, type Finding, type FindingStep, type FrozenSummary, type KeyRef, type PendingResult, type PlatformClient, RESULT_KEY_MAX, type ReporterConfig, type ResultFile, type ResultFindings, type ResultStatus, type ResultSubmission, type RunKind, type RunMeta, type RunRecord, type RunSession, type RunStats, type RunnerLocation, type SubmitCounts, UNSUPPORTED_VARS, type UnofferedWhy, appendBatch, ciCommit, createClient, errorContextFields, errorContextOf, failureOf, filesOf, maskCredentials, readEnv, repoRootOf, resultKey, startRun, webLink };
744
+ export { type AssertionRecord, type Attachment, type AttemptError, type ClientFailureKind, type ClientOptions, type ClientOutcome, DEFAULT_FALLBACK_PATH, type DeclaredStep, type DeferredBatch, type DeferredResult, type EnvSettings, type Execution, type ExpectedEntry, type ExternalKeyKind, type FailedAttempt, type FailureDetail, type Finding, type FindingStep, type FrozenSummary, type KeyRef, type PendingResult, type PlatformClient, RESULT_KEY_MAX, type ReporterConfig, type ResultFile, type ResultFindings, type ResultStatus, type ResultSubmission, type RunKind, type RunMeta, type RunRecord, type RunSession, type RunStats, type RunnerLocation, type SubmitCounts, UNSUPPORTED_VARS, type UnofferedWhy, appendBatch, ciCommit, createClient, errorContextFields, errorContextOf, failureOf, filesOf, maskCredentials, readEnv, repoRootOf, resultKey, startRun, stepTitlesOf, webLink };
@@ -238,6 +238,11 @@ interface PendingResult {
238
238
  * nothing found. A platform older than the field is handled as for `targets`.
239
239
  */
240
240
  findings?: ResultFindings;
241
+ /**
242
+ * The titles of the top-level `test.step` calls of a passed attempt, in order (`stepTitlesOf`). The platform proposes them as the text of
243
+ * the test's case when they differ from its description. Absent rather than empty; a platform older than the field ignores it.
244
+ */
245
+ stepTitles?: string[];
241
246
  }
242
247
  /** Where in the test a finding belongs: a declared step, by its position from 1 and its title. */
243
248
  interface FindingStep {
@@ -713,6 +718,13 @@ declare function errorContextFields(attempt: FailedAttempt, home?: string): {
713
718
  * bodies must not hold them all until a batch is sent.
714
719
  */
715
720
  declare function filesOf(attempt: FailedAttempt): ResultFile[];
721
+ /**
722
+ * The titles of a passed attempt's top-level declared steps (`test.step`), in the order they ran, the empty ones left out. The platform
723
+ * compares them with the description of the test's case and, when they differ, queues a proposal to update it. Only a passed attempt
724
+ * says which steps the test has - a failed one stopped somewhere among them - and the nested steps stay out: a case's description is a
725
+ * flat list. Absent when there are none.
726
+ */
727
+ declare function stepTitlesOf(attempt: Pick<FailedAttempt, 'status' | 'steps'>): string[] | undefined;
716
728
  /**
717
729
  * A link only for an address a browser opens as a page — never `file:`, `javascript:` or half a URL.
718
730
  * As the platform checks it: `new URL` alone mends `https:/host` and `https:host` into https, and a
@@ -729,4 +741,4 @@ declare function webLink(href: string | undefined): string | undefined;
729
741
  */
730
742
  declare function maskCredentials(text: string): string;
731
743
 
732
- export { type AssertionRecord, type Attachment, type AttemptError, type ClientFailureKind, type ClientOptions, type ClientOutcome, DEFAULT_FALLBACK_PATH, type DeclaredStep, type DeferredBatch, type DeferredResult, type EnvSettings, type Execution, type ExpectedEntry, type ExternalKeyKind, type FailedAttempt, type FailureDetail, type Finding, type FindingStep, type FrozenSummary, type KeyRef, type PendingResult, type PlatformClient, RESULT_KEY_MAX, type ReporterConfig, type ResultFile, type ResultFindings, type ResultStatus, type ResultSubmission, type RunKind, type RunMeta, type RunRecord, type RunSession, type RunStats, type RunnerLocation, type SubmitCounts, UNSUPPORTED_VARS, type UnofferedWhy, appendBatch, ciCommit, createClient, errorContextFields, errorContextOf, failureOf, filesOf, maskCredentials, readEnv, repoRootOf, resultKey, startRun, webLink };
744
+ export { type AssertionRecord, type Attachment, type AttemptError, type ClientFailureKind, type ClientOptions, type ClientOutcome, DEFAULT_FALLBACK_PATH, type DeclaredStep, type DeferredBatch, type DeferredResult, type EnvSettings, type Execution, type ExpectedEntry, type ExternalKeyKind, type FailedAttempt, type FailureDetail, type Finding, type FindingStep, type FrozenSummary, type KeyRef, type PendingResult, type PlatformClient, RESULT_KEY_MAX, type ReporterConfig, type ResultFile, type ResultFindings, type ResultStatus, type ResultSubmission, type RunKind, type RunMeta, type RunRecord, type RunSession, type RunStats, type RunnerLocation, type SubmitCounts, UNSUPPORTED_VARS, type UnofferedWhy, appendBatch, ciCommit, createClient, errorContextFields, errorContextOf, failureOf, filesOf, maskCredentials, readEnv, repoRootOf, resultKey, startRun, stepTitlesOf, webLink };
@@ -516,6 +516,11 @@ function chosen({ status, errors }) {
516
516
  }
517
517
  return errors[0];
518
518
  }
519
+ function stepTitlesOf(attempt) {
520
+ if (attempt.status !== "passed") return void 0;
521
+ const titles = attempt.steps.map((s) => s.title.trim()).filter((t) => t !== "");
522
+ return titles.length > 0 ? titles : void 0;
523
+ }
519
524
  function chainOf(steps) {
520
525
  const chain = [];
521
526
  for (let failed = steps.find((s) => s.failed); failed !== void 0; failed = failed.steps.find((s) => s.failed)) {
@@ -1941,5 +1946,6 @@ export {
1941
1946
  repoRootOf,
1942
1947
  resultKey,
1943
1948
  startRun,
1949
+ stepTitlesOf,
1944
1950
  webLink
1945
1951
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.40.0",
3
+ "version": "0.40.2",
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": [