@plune-ai/cli 0.40.2 → 0.41.0

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
@@ -5873,13 +5873,13 @@ async function start(options = {}) {
5873
5873
  hold(writeSlowly(res, rendered.body, failure2.bytes_per_sec, timers));
5874
5874
  return;
5875
5875
  case "truncated_json": {
5876
- const cut5 = rendered.body.subarray(0, Math.floor(rendered.body.length / 2));
5876
+ const cut6 = rendered.body.subarray(0, Math.floor(rendered.body.length / 2));
5877
5877
  if (failure2.content_length === "cut") {
5878
- head(cut5.length);
5879
- res.end(cut5);
5878
+ head(cut6.length);
5879
+ res.end(cut6);
5880
5880
  } else {
5881
5881
  head(rendered.body.length);
5882
- res.write(cut5, () => res.destroy());
5882
+ res.write(cut6, () => res.destroy());
5883
5883
  }
5884
5884
  return;
5885
5885
  }
@@ -22272,7 +22272,7 @@ async function rawRequest(target4, req, limits = {}) {
22272
22272
  const events = [];
22273
22273
  let bytes = 0;
22274
22274
  let ended = false;
22275
- let cut5;
22275
+ let cut6;
22276
22276
  const parser = sseParser();
22277
22277
  const decoder = new TextDecoder();
22278
22278
  if (res.body !== null && limits.headersOnly !== true) {
@@ -22292,7 +22292,7 @@ async function rawRequest(target4, req, limits = {}) {
22292
22292
  events.push(e);
22293
22293
  if (events.length > maxEvents) {
22294
22294
  events.pop();
22295
- cut5 = "events";
22295
+ cut6 = "events";
22296
22296
  break read;
22297
22297
  }
22298
22298
  if (limits.stopWhen?.(e) === true) {
@@ -22302,12 +22302,12 @@ async function rawRequest(target4, req, limits = {}) {
22302
22302
  }
22303
22303
  }
22304
22304
  if (fed.tooLong) {
22305
- cut5 = "line";
22305
+ cut6 = "line";
22306
22306
  break;
22307
22307
  }
22308
22308
  }
22309
22309
  if (bytes > maxBytes) {
22310
- cut5 = "bytes";
22310
+ cut6 = "bytes";
22311
22311
  break;
22312
22312
  }
22313
22313
  }
@@ -22332,7 +22332,7 @@ async function rawRequest(target4, req, limits = {}) {
22332
22332
  utf8,
22333
22333
  events,
22334
22334
  ended,
22335
- ...cut5 === void 0 ? {} : { cut: cut5 },
22335
+ ...cut6 === void 0 ? {} : { cut: cut6 },
22336
22336
  ms: Math.round(performance.now() - started)
22337
22337
  };
22338
22338
  }
@@ -25897,8 +25897,8 @@ async function streams(ctx) {
25897
25897
  const got2 = await probed(ctx);
25898
25898
  if (isOutcome3(got2)) return got2;
25899
25899
  const sse = [got2.p, ...await concurrent(ctx, got2.s)].filter((a) => isSse(a.res));
25900
- const cut5 = sse.find((a) => a.res.cut !== void 0);
25901
- return cut5 === void 0 ? sse : tooMuch(cut5);
25900
+ const cut6 = sse.find((a) => a.res.cut !== void 0);
25901
+ return cut6 === void 0 ? sse : tooMuch(cut6);
25902
25902
  }
25903
25903
  var ACCEPT, LINGER_MS, BROADCAST_MS, ok, isSse, parsed3, answers2, probeMethod, opened, isOutcome3, session, probe2, concurrent, notificationAccepted, contentType, utf8Json, singleEndpoint, getStreamOr405, modernGetDelete405, sessionIdAscii, sessionRequired400, INVALID_VERSION, versionHeaderInvalid400, concurrentMatched, cutOf, tooMuch, noSse, eventIdsUnique, streamCloses, noServerRequests, accelBuffering, closeCancels, sessionTerminated404, noBroadcast, TRANSPORT;
25904
25904
  var init_transport = __esm({
@@ -25969,8 +25969,8 @@ var init_transport = __esm({
25969
25969
  const got2 = await probed(ctx);
25970
25970
  if (isOutcome3(got2)) return got2;
25971
25971
  const { res, detail } = got2.p;
25972
- const cut5 = cutOf(res, detail);
25973
- if (cut5 !== void 0) return cut5;
25972
+ const cut6 = cutOf(res, detail);
25973
+ if (cut6 !== void 0) return cut6;
25974
25974
  const fix = "Send every JSON-RPC message as JSON encoded in UTF-8.";
25975
25975
  if (!res.utf8) return { ...failed("The body of the answer is not valid UTF-8.", fix), details: [detail] };
25976
25976
  const messages = isSse(res) ? res.events.map((e) => e.data).filter((d) => d !== "") : [res.body];
@@ -37180,14 +37180,14 @@ async function defaultReadEvidence(dir) {
37180
37180
  function casesFromDesign(report, notes) {
37181
37181
  const list3 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
37182
37182
  const refused = /* @__PURE__ */ new Map();
37183
- let cut5 = 0;
37183
+ let cut6 = 0;
37184
37184
  const cases = list3.map((raw) => {
37185
37185
  const c = asRecord2(raw);
37186
37186
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
37187
37187
  const title = str(c["title"], "untitled case");
37188
37188
  const why = own3(c, "rationale");
37189
37189
  const rationale = typeof why === "string" ? why.trim() : "";
37190
- if (rationale.length > RATIONALE_MAX) cut5 += 1;
37190
+ if (rationale.length > RATIONALE_MAX) cut6 += 1;
37191
37191
  const link = own3(c, "traceUrl") ?? void 0;
37192
37192
  const said3 = [];
37193
37193
  const traceUrl = traceUrlOf(link, title, said3);
@@ -37212,7 +37212,7 @@ function casesFromDesign(report, notes) {
37212
37212
  for (const times of refused.values()) {
37213
37213
  if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
37214
37214
  }
37215
- if (cut5 > 0) notes.push(`plune: ${cut5} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
37215
+ if (cut6 > 0) notes.push(`plune: ${cut6} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
37216
37216
  return cases;
37217
37217
  }
37218
37218
  function casesFromApi(report, verdicts) {
@@ -37265,6 +37265,7 @@ async function readCairnRun(dir, deps = {}) {
37265
37265
  cases = casesFromDesign(report, deps.notes ?? []);
37266
37266
  }
37267
37267
  const tokens2 = own3(asRecord2(own3(report, "cost")), "totalTokens");
37268
+ const observations = await readObservations(dir, deps.notes ?? []);
37268
37269
  return {
37269
37270
  schemaVersion: INGEST_SCHEMA_VERSION,
37270
37271
  run: {
@@ -37274,9 +37275,59 @@ async function readCairnRun(dir, deps = {}) {
37274
37275
  // Cairn states the run's tokens as `cost.totalTokens` in every mode; the platform copies it onto each proposal.
37275
37276
  ...Number.isInteger(tokens2) && tokens2 >= 0 ? { cost: { tokens: tokens2, cases: cases.length } } : {}
37276
37277
  },
37277
- cases
37278
+ cases,
37279
+ ...observations !== void 0 && observations.length > 0 ? { observations } : {}
37278
37280
  };
37279
37281
  }
37282
+ async function readObservations(dir, notes) {
37283
+ const file = "observations.json";
37284
+ if (!await checkSize(dir, file)) return void 0;
37285
+ const raw = await readJson(path24.join(dir, file));
37286
+ if (raw === void 0 || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
37287
+ throw new CairnArtifactShapeError(file, "", "is not a JSON object");
37288
+ }
37289
+ const doc = raw;
37290
+ if (own3(doc, "schemaVersion") !== SUPPORTED_ARTIFACT_VERSION) {
37291
+ throw new CairnRunVersionError(`${String(own3(doc, "schemaVersion"))} (in ${file})`);
37292
+ }
37293
+ const items2 = own3(doc, "observations");
37294
+ if (!Array.isArray(items2)) throw new CairnArtifactShapeError(file, "observations", "is not a list");
37295
+ const out = [];
37296
+ let dropped = 0;
37297
+ let clipped = false;
37298
+ for (const item of items2) {
37299
+ const o = asRecord2(item);
37300
+ const kind2 = own3(o, "kind");
37301
+ const severity2 = own3(o, "severity");
37302
+ const [title, page, evidence] = ["title", "page", "evidence"].map((k) => own3(o, k));
37303
+ const repro = own3(o, "repro");
37304
+ const steps = Array.isArray(repro) ? repro.filter((s) => typeof s === "string" && s.trim() !== "") : [];
37305
+ if (!OBSERVATION_KINDS.includes(kind2) || severity2 !== "low" && severity2 !== "medium" && severity2 !== "high" || [title, page, evidence].some((v) => typeof v !== "string" || v.trim() === "") || steps.length === 0) {
37306
+ dropped++;
37307
+ continue;
37308
+ }
37309
+ const L3 = OBSERVATION_LIMITS;
37310
+ const t = title.trim();
37311
+ const p = page;
37312
+ const e = redactSecrets(evidence);
37313
+ clipped ||= t.length > L3.title || p.length > L3.page || e.length > L3.evidence || steps.length > L3.steps || steps.some((s) => s.length > L3.step);
37314
+ out.push({
37315
+ kind: kind2,
37316
+ severity: severity2,
37317
+ title: cut4(t, L3.title),
37318
+ page: cut4(p, L3.page),
37319
+ repro: steps.slice(0, L3.steps).map((s) => cut4(s, L3.step)),
37320
+ evidence: cut4(e, L3.evidence)
37321
+ });
37322
+ }
37323
+ if (dropped > 0) notes.push(`plune: ${dropped} observation(s) of a kind or shape this CLI does not know \u2014 not sent.`);
37324
+ if (clipped) notes.push("plune: some observations carry text over the platform's bounds \u2014 sent cut.");
37325
+ if (out.length > OBSERVATION_LIMITS.perRun) {
37326
+ notes.push(`plune: ${out.length - OBSERVATION_LIMITS.perRun} observation(s) over the ${OBSERVATION_LIMITS.perRun} a run may carry \u2014 not sent.`);
37327
+ return out.slice(0, OBSERVATION_LIMITS.perRun);
37328
+ }
37329
+ return out;
37330
+ }
37280
37331
  async function readCairnSessionFiles(dir) {
37281
37332
  const raw = await readJson(path24.join(dir, "screencasts", "screencasts.json"));
37282
37333
  if (!Array.isArray(raw)) return void 0;
@@ -37341,7 +37392,7 @@ async function readCairnSessionFiles(dir) {
37341
37392
  }
37342
37393
  return { byCase, screencasts, unmapped, outside };
37343
37394
  }
37344
- var fs20, path24, SUPPORTED_ARTIFACT_VERSION, INGEST_SCHEMA_VERSION, RATIONALE_MAX, NoCairnRunsError, CairnRunNotFoundError, CairnRunVersionError, CairnRunPartialError, CairnArtifactShapeError, CairnEvidenceAmbiguousError, asRecord2, str, own3, MAX_ARTIFACT_BYTES, MAX_MCP_CASES, ARGS_CHARS2, SECRET_NAME2, maskNamed, MCP_STATES, DECLARED, clip;
37395
+ var fs20, path24, SUPPORTED_ARTIFACT_VERSION, INGEST_SCHEMA_VERSION, RATIONALE_MAX, OBSERVATION_KINDS, OBSERVATION_LIMITS, NoCairnRunsError, CairnRunNotFoundError, CairnRunVersionError, CairnRunPartialError, CairnArtifactShapeError, CairnEvidenceAmbiguousError, asRecord2, str, own3, MAX_ARTIFACT_BYTES, MAX_MCP_CASES, ARGS_CHARS2, SECRET_NAME2, maskNamed, MCP_STATES, cut4, DECLARED, clip;
37345
37396
  var init_cairn_artifact = __esm({
37346
37397
  "src/cli/commands/cairn-artifact.ts"() {
37347
37398
  "use strict";
@@ -37354,6 +37405,8 @@ var init_cairn_artifact = __esm({
37354
37405
  SUPPORTED_ARTIFACT_VERSION = 1;
37355
37406
  INGEST_SCHEMA_VERSION = 1;
37356
37407
  RATIONALE_MAX = 400;
37408
+ OBSERVATION_KINDS = ["console-error", "page-error", "request-failed", "dead-click", "layout-defect", "a11y-violation"];
37409
+ OBSERVATION_LIMITS = { perRun: 200, title: 200, page: 2048, steps: 50, step: 400, evidence: 2e3 };
37357
37410
  NoCairnRunsError = class extends Error {
37358
37411
  constructor(runsDir) {
37359
37412
  super(`No Cairn run found under ${runsDir} \u2014 name the directory instead: plune ingest <dir>.`);
@@ -37424,6 +37477,7 @@ var init_cairn_artifact = __esm({
37424
37477
  "could-not-run",
37425
37478
  "needs-review"
37426
37479
  ]);
37480
+ cut4 = (s, max) => s.length > max ? s.slice(0, max) : s;
37427
37481
  DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
37428
37482
  clip = (s, max = DECLARED.text) => s.slice(0, max).replace(/[\uD800-\uDBFF]$/, "");
37429
37483
  }
@@ -37620,7 +37674,8 @@ async function handleIngest(deps) {
37620
37674
  runId: typeof body.runId === "string" ? body.runId : "",
37621
37675
  linked: typeof body.linked === "number" ? body.linked : 0,
37622
37676
  proposed: typeof body.proposed === "number" ? body.proposed : 0,
37623
- skipped: typeof body.skipped === "number" ? body.skipped : 0
37677
+ skipped: typeof body.skipped === "number" ? body.skipped : 0,
37678
+ ...payload2.observations !== void 0 && typeof body.observed === "number" ? { observed: body.observed } : {}
37624
37679
  };
37625
37680
  return { result: result2, items: itemsOf(body), repeat: res.status === 200 };
37626
37681
  }
@@ -37655,6 +37710,7 @@ function formatIngestResult(r) {
37655
37710
  ` ${r.linked} result(s) attached to existing cases`,
37656
37711
  ` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
37657
37712
  ` ${r.skipped} skipped (already queued, already rejected, repeated, or never executed)`,
37713
+ ...r.observed !== void 0 ? [` Observations: ${r.observed} queued \u2014 file a bug or dismiss each in Plune`] : [],
37658
37714
  ...files
37659
37715
  ];
37660
37716
  return `${lines.join("\n")}
@@ -37714,7 +37770,7 @@ __export(requirements_import_exports, {
37714
37770
  MAX_MARKDOWN_BYTES: () => MAX_MARKDOWN_BYTES,
37715
37771
  RequirementsImportError: () => RequirementsImportError,
37716
37772
  buildImportBody: () => buildImportBody,
37717
- cut: () => cut4,
37773
+ cut: () => cut5,
37718
37774
  flat: () => flat2,
37719
37775
  formatDiscover: () => formatDiscover,
37720
37776
  formatReport: () => formatReport3,
@@ -37894,7 +37950,7 @@ function formatDiscover(file, r) {
37894
37950
  if (r.tables.length === 0) out.push(" (none)");
37895
37951
  for (const t of r.tables) {
37896
37952
  const mark = t.unreadable !== void 0 ? ` cannot be read: ${t.unreadable}` : t.looksLikeRequirements ? " <- looks like requirements" : "";
37897
- out.push(` #${t.index} line ${t.line} ${t.heading === null ? "(no heading)" : `"${flat2(t.heading)}"`} ${cut4(t.headers.map(flat2).join(" | "), 100)} ${plural8(t.rowCount, "row")}${mark}`);
37953
+ out.push(` #${t.index} line ${t.line} ${t.heading === null ? "(no heading)" : `"${flat2(t.heading)}"`} ${cut5(t.headers.map(flat2).join(" | "), 100)} ${plural8(t.rowCount, "row")}${mark}`);
37898
37954
  }
37899
37955
  out.push("", "Sections");
37900
37956
  if (r.sections.length === 0) out.push(" (none)");
@@ -37926,8 +37982,8 @@ function formatReport3(report) {
37926
37982
  for (const i of rows.slice(0, SHOWN4)) {
37927
37983
  const changes = i.changes !== void 0 && i.changes.length > 0 ? `; changes: ${i.changes.join(", ")}` : "";
37928
37984
  const notes = i.notes !== void 0 && i.notes.length > 0 ? `; note: ${i.notes.join("; ")}` : "";
37929
- const from = i.table === void 0 ? "" : `table #${i.table}${i.tableHeading ? ` "${cut4(flat2(i.tableHeading), 40)}"` : ""} `;
37930
- out.push(` ${from}line ${i.line} ${i.key ?? "-"} ${cut4(flat2(i.title), 80)} - ${flat2(i.reason)}${changes}${notes}`);
37985
+ const from = i.table === void 0 ? "" : `table #${i.table}${i.tableHeading ? ` "${cut5(flat2(i.tableHeading), 40)}"` : ""} `;
37986
+ out.push(` ${from}line ${i.line} ${i.key ?? "-"} ${cut5(flat2(i.title), 80)} - ${flat2(i.reason)}${changes}${notes}`);
37931
37987
  }
37932
37988
  if (rows.length > SHOWN4) out.push(` ... and ${rows.length - SHOWN4} more (--json lists every row)`);
37933
37989
  }
@@ -37939,7 +37995,7 @@ function formatReport3(report) {
37939
37995
  const n = report.notImported;
37940
37996
  if (n.tables.length + n.sections.length + n.frontmatterKeys.length > 0) {
37941
37997
  out.push("", "Not imported");
37942
- for (const t of n.tables) out.push(` table #${t.index} ${t.heading === null ? "" : `"${flat2(t.heading)}" `}(${cut4(t.headers.map(flat2).join(" | "), 80)}; ${plural8(t.rowCount, "row")})`);
37998
+ for (const t of n.tables) out.push(` table #${t.index} ${t.heading === null ? "" : `"${flat2(t.heading)}" `}(${cut5(t.headers.map(flat2).join(" | "), 80)}; ${plural8(t.rowCount, "row")})`);
37943
37999
  for (const x of n.sections) out.push(` section #${x.index} "${flat2(x.heading)}" (${plural8(x.bulletCount, "bullet")})`);
37944
38000
  if (n.frontmatterKeys.length > 0) out.push(` frontmatter keys: ${n.frontmatterKeys.join(", ")}`);
37945
38001
  }
@@ -37951,7 +38007,7 @@ function reportRequirementsImportFailure(err, write) {
37951
38007
  write(err.message + "\n");
37952
38008
  return err.exitCode;
37953
38009
  }
37954
- 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;
38010
+ 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, cut5, plural8;
37955
38011
  var init_requirements_import = __esm({
37956
38012
  "src/cli/commands/requirements-import.ts"() {
37957
38013
  "use strict";
@@ -38007,7 +38063,7 @@ var init_requirements_import = __esm({
38007
38063
  SUPPORT = "This platform does not support requirements import yet. Nothing was sent to a project; try a newer Plune platform.";
38008
38064
  SHOWN4 = 50;
38009
38065
  flat2 = (s) => s.replace(/\s+/g, " ").trim();
38010
- cut4 = (s, n) => s.length > n ? `${s.slice(0, n - 1)}\u2026` : s;
38066
+ cut5 = (s, n) => s.length > n ? `${s.slice(0, n - 1)}\u2026` : s;
38011
38067
  plural8 = (n, one2, many = `${one2}s`) => `${n} ${n === 1 ? one2 : many}`;
38012
38068
  }
38013
38069
  });
@@ -38056,7 +38112,7 @@ function formatLinksDiscover(file, r) {
38056
38112
  if (r.tables.length === 0) out.push(" (none)");
38057
38113
  for (const t of r.tables) {
38058
38114
  const mark = t.unreadable !== void 0 ? ` cannot be read: ${t.unreadable}` : "";
38059
- out.push(` #${t.index} line ${t.line} ${t.heading === null ? "(no heading)" : `"${flat2(t.heading)}"`} ${cut4(t.headers.map(flat2).join(" | "), 100)} ${plural8(t.rowCount, "row")}${mark}`);
38115
+ out.push(` #${t.index} line ${t.line} ${t.heading === null ? "(no heading)" : `"${flat2(t.heading)}"`} ${cut5(t.headers.map(flat2).join(" | "), 100)} ${plural8(t.rowCount, "row")}${mark}`);
38060
38116
  }
38061
38117
  if (r.truncated) out.push("", "The file has more tables than are listed here.");
38062
38118
  out.push("", "Pick the matrix and name its two columns (a dry run, nothing is written):", ` plune requirements links ${file} --table <n> --requirement-column <header> --test-column <header>`);
@@ -38070,7 +38126,7 @@ function formatLinks(report) {
38070
38126
  if (rows.length === 0) continue;
38071
38127
  out.push("", `${action} (${rows.length})`);
38072
38128
  for (const i of rows.slice(0, SHOWN5)) {
38073
- out.push(` line ${i.line} ${i.key === "" ? "-" : i.key} -> ${i.test === "" ? "-" : cut4(flat2(i.test), 80)} - ${flat2(i.reason)}`);
38129
+ out.push(` line ${i.line} ${i.key === "" ? "-" : i.key} -> ${i.test === "" ? "-" : cut5(flat2(i.test), 80)} - ${flat2(i.reason)}`);
38074
38130
  }
38075
38131
  if (rows.length > SHOWN5) out.push(` ... and ${rows.length - SHOWN5} more (--json lists every row)`);
38076
38132
  }
package/dist/index.cjs CHANGED
@@ -6067,13 +6067,13 @@ async function start(options = {}) {
6067
6067
  hold(writeSlowly(res, rendered.body, failure.bytes_per_sec, timers));
6068
6068
  return;
6069
6069
  case "truncated_json": {
6070
- const cut = rendered.body.subarray(0, Math.floor(rendered.body.length / 2));
6070
+ const cut2 = rendered.body.subarray(0, Math.floor(rendered.body.length / 2));
6071
6071
  if (failure.content_length === "cut") {
6072
- head(cut.length);
6073
- res.end(cut);
6072
+ head(cut2.length);
6073
+ res.end(cut2);
6074
6074
  } else {
6075
6075
  head(rendered.body.length);
6076
- res.write(cut, () => res.destroy());
6076
+ res.write(cut2, () => res.destroy());
6077
6077
  }
6078
6078
  return;
6079
6079
  }
@@ -9267,6 +9267,8 @@ var safeText = (text) => noCommands(
9267
9267
  var SUPPORTED_ARTIFACT_VERSION = 1;
9268
9268
  var INGEST_SCHEMA_VERSION = 1;
9269
9269
  var RATIONALE_MAX = 400;
9270
+ var OBSERVATION_KINDS = ["console-error", "page-error", "request-failed", "dead-click", "layout-defect", "a11y-violation"];
9271
+ var OBSERVATION_LIMITS = { perRun: 200, title: 200, page: 2048, steps: 50, step: 400, evidence: 2e3 };
9270
9272
  var NoCairnRunsError = class extends Error {
9271
9273
  constructor(runsDir) {
9272
9274
  super(`No Cairn run found under ${runsDir} \u2014 name the directory instead: plune ingest <dir>.`);
@@ -9537,14 +9539,14 @@ async function defaultReadEvidence(dir) {
9537
9539
  function casesFromDesign(report, notes) {
9538
9540
  const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
9539
9541
  const refused = /* @__PURE__ */ new Map();
9540
- let cut = 0;
9542
+ let cut2 = 0;
9541
9543
  const cases = list2.map((raw) => {
9542
9544
  const c = asRecord(raw);
9543
9545
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
9544
9546
  const title = str(c["title"], "untitled case");
9545
9547
  const why = own2(c, "rationale");
9546
9548
  const rationale = typeof why === "string" ? why.trim() : "";
9547
- if (rationale.length > RATIONALE_MAX) cut += 1;
9549
+ if (rationale.length > RATIONALE_MAX) cut2 += 1;
9548
9550
  const link = own2(c, "traceUrl") ?? void 0;
9549
9551
  const said = [];
9550
9552
  const traceUrl = traceUrlOf(link, title, said);
@@ -9569,7 +9571,7 @@ function casesFromDesign(report, notes) {
9569
9571
  for (const times of refused.values()) {
9570
9572
  if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
9571
9573
  }
9572
- if (cut > 0) notes.push(`plune: ${cut} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
9574
+ if (cut2 > 0) notes.push(`plune: ${cut2} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
9573
9575
  return cases;
9574
9576
  }
9575
9577
  function casesFromApi(report, verdicts) {
@@ -9622,6 +9624,7 @@ async function readCairnRun(dir, deps = {}) {
9622
9624
  cases = casesFromDesign(report, deps.notes ?? []);
9623
9625
  }
9624
9626
  const tokens = own2(asRecord(own2(report, "cost")), "totalTokens");
9627
+ const observations = await readObservations(dir, deps.notes ?? []);
9625
9628
  return {
9626
9629
  schemaVersion: INGEST_SCHEMA_VERSION,
9627
9630
  run: {
@@ -9631,9 +9634,60 @@ async function readCairnRun(dir, deps = {}) {
9631
9634
  // Cairn states the run's tokens as `cost.totalTokens` in every mode; the platform copies it onto each proposal.
9632
9635
  ...Number.isInteger(tokens) && tokens >= 0 ? { cost: { tokens, cases: cases.length } } : {}
9633
9636
  },
9634
- cases
9637
+ cases,
9638
+ ...observations !== void 0 && observations.length > 0 ? { observations } : {}
9635
9639
  };
9636
9640
  }
9641
+ var cut = (s, max) => s.length > max ? s.slice(0, max) : s;
9642
+ async function readObservations(dir, notes) {
9643
+ const file = "observations.json";
9644
+ if (!await checkSize(dir, file)) return void 0;
9645
+ const raw = await readJson(path9.join(dir, file));
9646
+ if (raw === void 0 || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
9647
+ throw new CairnArtifactShapeError(file, "", "is not a JSON object");
9648
+ }
9649
+ const doc = raw;
9650
+ if (own2(doc, "schemaVersion") !== SUPPORTED_ARTIFACT_VERSION) {
9651
+ throw new CairnRunVersionError(`${String(own2(doc, "schemaVersion"))} (in ${file})`);
9652
+ }
9653
+ const items = own2(doc, "observations");
9654
+ if (!Array.isArray(items)) throw new CairnArtifactShapeError(file, "observations", "is not a list");
9655
+ const out = [];
9656
+ let dropped = 0;
9657
+ let clipped = false;
9658
+ for (const item of items) {
9659
+ const o = asRecord(item);
9660
+ const kind = own2(o, "kind");
9661
+ const severity = own2(o, "severity");
9662
+ const [title, page, evidence] = ["title", "page", "evidence"].map((k) => own2(o, k));
9663
+ const repro = own2(o, "repro");
9664
+ const steps = Array.isArray(repro) ? repro.filter((s) => typeof s === "string" && s.trim() !== "") : [];
9665
+ if (!OBSERVATION_KINDS.includes(kind) || severity !== "low" && severity !== "medium" && severity !== "high" || [title, page, evidence].some((v) => typeof v !== "string" || v.trim() === "") || steps.length === 0) {
9666
+ dropped++;
9667
+ continue;
9668
+ }
9669
+ const L3 = OBSERVATION_LIMITS;
9670
+ const t = title.trim();
9671
+ const p = page;
9672
+ const e = redactSecrets(evidence);
9673
+ clipped ||= t.length > L3.title || p.length > L3.page || e.length > L3.evidence || steps.length > L3.steps || steps.some((s) => s.length > L3.step);
9674
+ out.push({
9675
+ kind,
9676
+ severity,
9677
+ title: cut(t, L3.title),
9678
+ page: cut(p, L3.page),
9679
+ repro: steps.slice(0, L3.steps).map((s) => cut(s, L3.step)),
9680
+ evidence: cut(e, L3.evidence)
9681
+ });
9682
+ }
9683
+ if (dropped > 0) notes.push(`plune: ${dropped} observation(s) of a kind or shape this CLI does not know \u2014 not sent.`);
9684
+ if (clipped) notes.push("plune: some observations carry text over the platform's bounds \u2014 sent cut.");
9685
+ if (out.length > OBSERVATION_LIMITS.perRun) {
9686
+ notes.push(`plune: ${out.length - OBSERVATION_LIMITS.perRun} observation(s) over the ${OBSERVATION_LIMITS.perRun} a run may carry \u2014 not sent.`);
9687
+ return out.slice(0, OBSERVATION_LIMITS.perRun);
9688
+ }
9689
+ return out;
9690
+ }
9637
9691
  var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
9638
9692
  var clip = (s, max = DECLARED.text) => s.slice(0, max).replace(/[\uD800-\uDBFF]$/, "");
9639
9693
  async function readCairnSessionFiles(dir) {
@@ -9914,7 +9968,8 @@ async function handleIngest(deps) {
9914
9968
  runId: typeof body.runId === "string" ? body.runId : "",
9915
9969
  linked: typeof body.linked === "number" ? body.linked : 0,
9916
9970
  proposed: typeof body.proposed === "number" ? body.proposed : 0,
9917
- skipped: typeof body.skipped === "number" ? body.skipped : 0
9971
+ skipped: typeof body.skipped === "number" ? body.skipped : 0,
9972
+ ...payload.observations !== void 0 && typeof body.observed === "number" ? { observed: body.observed } : {}
9918
9973
  };
9919
9974
  return { result, items: itemsOf(body), repeat: res.status === 200 };
9920
9975
  }
@@ -9949,6 +10004,7 @@ function formatIngestResult(r) {
9949
10004
  ` ${r.linked} result(s) attached to existing cases`,
9950
10005
  ` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
9951
10006
  ` ${r.skipped} skipped (already queued, already rejected, repeated, or never executed)`,
10007
+ ...r.observed !== void 0 ? [` Observations: ${r.observed} queued \u2014 file a bug or dismiss each in Plune`] : [],
9952
10008
  ...files
9953
10009
  ];
9954
10010
  return `${lines.join("\n")}
package/dist/index.d.cts CHANGED
@@ -1459,6 +1459,8 @@ interface IngestResult {
1459
1459
  linked: number;
1460
1460
  proposed: number;
1461
1461
  skipped: number;
1462
+ /** Observations queued for review; absent when the run sent none or the platform does not count them. */
1463
+ observed?: number;
1462
1464
  /** Why the platform's job queue did not take this ingest's report: the first refusal or error. The run is recorded. */
1463
1465
  jobProblem?: string;
1464
1466
  /** What became of the run's recordings (videos, traces): a count, then a line per reason a file stayed behind. */
@@ -1536,6 +1538,17 @@ interface CairnIngestPayload {
1536
1538
  };
1537
1539
  };
1538
1540
  cases: CairnIngestCase[];
1541
+ /** What an exploration noticed without a test failing (Cairn's `observations.json`); absent when the run wrote none. */
1542
+ observations?: CairnObservation[];
1543
+ }
1544
+ declare const OBSERVATION_KINDS: readonly ["console-error", "page-error", "request-failed", "dead-click", "layout-defect", "a11y-violation"];
1545
+ interface CairnObservation {
1546
+ kind: (typeof OBSERVATION_KINDS)[number];
1547
+ severity: 'low' | 'medium' | 'high';
1548
+ title: string;
1549
+ page: string;
1550
+ repro: string[];
1551
+ evidence: string;
1539
1552
  }
1540
1553
  interface EvidenceRecord {
1541
1554
  name: string;
package/dist/index.d.ts CHANGED
@@ -1459,6 +1459,8 @@ interface IngestResult {
1459
1459
  linked: number;
1460
1460
  proposed: number;
1461
1461
  skipped: number;
1462
+ /** Observations queued for review; absent when the run sent none or the platform does not count them. */
1463
+ observed?: number;
1462
1464
  /** Why the platform's job queue did not take this ingest's report: the first refusal or error. The run is recorded. */
1463
1465
  jobProblem?: string;
1464
1466
  /** What became of the run's recordings (videos, traces): a count, then a line per reason a file stayed behind. */
@@ -1536,6 +1538,17 @@ interface CairnIngestPayload {
1536
1538
  };
1537
1539
  };
1538
1540
  cases: CairnIngestCase[];
1541
+ /** What an exploration noticed without a test failing (Cairn's `observations.json`); absent when the run wrote none. */
1542
+ observations?: CairnObservation[];
1543
+ }
1544
+ declare const OBSERVATION_KINDS: readonly ["console-error", "page-error", "request-failed", "dead-click", "layout-defect", "a11y-violation"];
1545
+ interface CairnObservation {
1546
+ kind: (typeof OBSERVATION_KINDS)[number];
1547
+ severity: 'low' | 'medium' | 'high';
1548
+ title: string;
1549
+ page: string;
1550
+ repro: string[];
1551
+ evidence: string;
1539
1552
  }
1540
1553
  interface EvidenceRecord {
1541
1554
  name: string;
package/dist/index.js CHANGED
@@ -6029,13 +6029,13 @@ async function start(options = {}) {
6029
6029
  hold(writeSlowly(res, rendered.body, failure.bytes_per_sec, timers));
6030
6030
  return;
6031
6031
  case "truncated_json": {
6032
- const cut = rendered.body.subarray(0, Math.floor(rendered.body.length / 2));
6032
+ const cut2 = rendered.body.subarray(0, Math.floor(rendered.body.length / 2));
6033
6033
  if (failure.content_length === "cut") {
6034
- head(cut.length);
6035
- res.end(cut);
6034
+ head(cut2.length);
6035
+ res.end(cut2);
6036
6036
  } else {
6037
6037
  head(rendered.body.length);
6038
- res.write(cut, () => res.destroy());
6038
+ res.write(cut2, () => res.destroy());
6039
6039
  }
6040
6040
  return;
6041
6041
  }
@@ -9229,6 +9229,8 @@ var safeText = (text) => noCommands(
9229
9229
  var SUPPORTED_ARTIFACT_VERSION = 1;
9230
9230
  var INGEST_SCHEMA_VERSION = 1;
9231
9231
  var RATIONALE_MAX = 400;
9232
+ var OBSERVATION_KINDS = ["console-error", "page-error", "request-failed", "dead-click", "layout-defect", "a11y-violation"];
9233
+ var OBSERVATION_LIMITS = { perRun: 200, title: 200, page: 2048, steps: 50, step: 400, evidence: 2e3 };
9232
9234
  var NoCairnRunsError = class extends Error {
9233
9235
  constructor(runsDir) {
9234
9236
  super(`No Cairn run found under ${runsDir} \u2014 name the directory instead: plune ingest <dir>.`);
@@ -9499,14 +9501,14 @@ async function defaultReadEvidence(dir) {
9499
9501
  function casesFromDesign(report, notes) {
9500
9502
  const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
9501
9503
  const refused = /* @__PURE__ */ new Map();
9502
- let cut = 0;
9504
+ let cut2 = 0;
9503
9505
  const cases = list2.map((raw) => {
9504
9506
  const c = asRecord(raw);
9505
9507
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
9506
9508
  const title = str(c["title"], "untitled case");
9507
9509
  const why = own2(c, "rationale");
9508
9510
  const rationale = typeof why === "string" ? why.trim() : "";
9509
- if (rationale.length > RATIONALE_MAX) cut += 1;
9511
+ if (rationale.length > RATIONALE_MAX) cut2 += 1;
9510
9512
  const link = own2(c, "traceUrl") ?? void 0;
9511
9513
  const said = [];
9512
9514
  const traceUrl = traceUrlOf(link, title, said);
@@ -9531,7 +9533,7 @@ function casesFromDesign(report, notes) {
9531
9533
  for (const times of refused.values()) {
9532
9534
  if (times > 1) notes.push(`plune: ${times - 1} more case(s) carry the same trace link \u2014 sent without it.`);
9533
9535
  }
9534
- if (cut > 0) notes.push(`plune: ${cut} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
9536
+ if (cut2 > 0) notes.push(`plune: ${cut2} case(s) carry an explanation over ${RATIONALE_MAX} characters \u2014 sent cut to ${RATIONALE_MAX}.`);
9535
9537
  return cases;
9536
9538
  }
9537
9539
  function casesFromApi(report, verdicts) {
@@ -9584,6 +9586,7 @@ async function readCairnRun(dir, deps = {}) {
9584
9586
  cases = casesFromDesign(report, deps.notes ?? []);
9585
9587
  }
9586
9588
  const tokens = own2(asRecord(own2(report, "cost")), "totalTokens");
9589
+ const observations = await readObservations(dir, deps.notes ?? []);
9587
9590
  return {
9588
9591
  schemaVersion: INGEST_SCHEMA_VERSION,
9589
9592
  run: {
@@ -9593,9 +9596,60 @@ async function readCairnRun(dir, deps = {}) {
9593
9596
  // Cairn states the run's tokens as `cost.totalTokens` in every mode; the platform copies it onto each proposal.
9594
9597
  ...Number.isInteger(tokens) && tokens >= 0 ? { cost: { tokens, cases: cases.length } } : {}
9595
9598
  },
9596
- cases
9599
+ cases,
9600
+ ...observations !== void 0 && observations.length > 0 ? { observations } : {}
9597
9601
  };
9598
9602
  }
9603
+ var cut = (s, max) => s.length > max ? s.slice(0, max) : s;
9604
+ async function readObservations(dir, notes) {
9605
+ const file = "observations.json";
9606
+ if (!await checkSize(dir, file)) return void 0;
9607
+ const raw = await readJson(path10.join(dir, file));
9608
+ if (raw === void 0 || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
9609
+ throw new CairnArtifactShapeError(file, "", "is not a JSON object");
9610
+ }
9611
+ const doc = raw;
9612
+ if (own2(doc, "schemaVersion") !== SUPPORTED_ARTIFACT_VERSION) {
9613
+ throw new CairnRunVersionError(`${String(own2(doc, "schemaVersion"))} (in ${file})`);
9614
+ }
9615
+ const items = own2(doc, "observations");
9616
+ if (!Array.isArray(items)) throw new CairnArtifactShapeError(file, "observations", "is not a list");
9617
+ const out = [];
9618
+ let dropped = 0;
9619
+ let clipped = false;
9620
+ for (const item of items) {
9621
+ const o = asRecord(item);
9622
+ const kind = own2(o, "kind");
9623
+ const severity = own2(o, "severity");
9624
+ const [title, page, evidence] = ["title", "page", "evidence"].map((k) => own2(o, k));
9625
+ const repro = own2(o, "repro");
9626
+ const steps = Array.isArray(repro) ? repro.filter((s) => typeof s === "string" && s.trim() !== "") : [];
9627
+ if (!OBSERVATION_KINDS.includes(kind) || severity !== "low" && severity !== "medium" && severity !== "high" || [title, page, evidence].some((v) => typeof v !== "string" || v.trim() === "") || steps.length === 0) {
9628
+ dropped++;
9629
+ continue;
9630
+ }
9631
+ const L3 = OBSERVATION_LIMITS;
9632
+ const t = title.trim();
9633
+ const p = page;
9634
+ const e = redactSecrets(evidence);
9635
+ clipped ||= t.length > L3.title || p.length > L3.page || e.length > L3.evidence || steps.length > L3.steps || steps.some((s) => s.length > L3.step);
9636
+ out.push({
9637
+ kind,
9638
+ severity,
9639
+ title: cut(t, L3.title),
9640
+ page: cut(p, L3.page),
9641
+ repro: steps.slice(0, L3.steps).map((s) => cut(s, L3.step)),
9642
+ evidence: cut(e, L3.evidence)
9643
+ });
9644
+ }
9645
+ if (dropped > 0) notes.push(`plune: ${dropped} observation(s) of a kind or shape this CLI does not know \u2014 not sent.`);
9646
+ if (clipped) notes.push("plune: some observations carry text over the platform's bounds \u2014 sent cut.");
9647
+ if (out.length > OBSERVATION_LIMITS.perRun) {
9648
+ notes.push(`plune: ${out.length - OBSERVATION_LIMITS.perRun} observation(s) over the ${OBSERVATION_LIMITS.perRun} a run may carry \u2014 not sent.`);
9649
+ return out.slice(0, OBSERVATION_LIMITS.perRun);
9650
+ }
9651
+ return out;
9652
+ }
9599
9653
  var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
9600
9654
  var clip = (s, max = DECLARED.text) => s.slice(0, max).replace(/[\uD800-\uDBFF]$/, "");
9601
9655
  async function readCairnSessionFiles(dir) {
@@ -9876,7 +9930,8 @@ async function handleIngest(deps) {
9876
9930
  runId: typeof body.runId === "string" ? body.runId : "",
9877
9931
  linked: typeof body.linked === "number" ? body.linked : 0,
9878
9932
  proposed: typeof body.proposed === "number" ? body.proposed : 0,
9879
- skipped: typeof body.skipped === "number" ? body.skipped : 0
9933
+ skipped: typeof body.skipped === "number" ? body.skipped : 0,
9934
+ ...payload.observations !== void 0 && typeof body.observed === "number" ? { observed: body.observed } : {}
9880
9935
  };
9881
9936
  return { result, items: itemsOf(body), repeat: res.status === 200 };
9882
9937
  }
@@ -9911,6 +9966,7 @@ function formatIngestResult(r) {
9911
9966
  ` ${r.linked} result(s) attached to existing cases`,
9912
9967
  ` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
9913
9968
  ` ${r.skipped} skipped (already queued, already rejected, repeated, or never executed)`,
9969
+ ...r.observed !== void 0 ? [` Observations: ${r.observed} queued \u2014 file a bug or dismiss each in Plune`] : [],
9914
9970
  ...files
9915
9971
  ];
9916
9972
  return `${lines.join("\n")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.40.2",
3
+ "version": "0.41.0",
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": [