@plune-ai/cli 0.39.0 → 0.39.1

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/README.md CHANGED
@@ -138,7 +138,7 @@ the last resort, used only when `PLUNE_TOKEN` is set nowhere else. Nothing write
138
138
  | `plune run exec -- <command>` | Open a run, run the command inside it, close the run — and exit with whatever the command returned. Sets `PLUNE_SHARED_RUN` for you, so anything reporting inside joins that run. Flags: `--key <externalKey>`, `--name <text>` (as on `run start`), `--fail-on-failures` to exit with [the gate](#a-release-gate---fail-on-failures)'s code instead — or with the command's own when no result reached the run. |
139
139
  | `plune run delete <id>` | Delete a run and everything it produced — its results and the review-queue entries it raised. Approved test cases and the audit log stay. **Recoverable for 30 days** (an owner of the project can put it back from Settings → Bin), then gone for good. No prompt: it is your data, and this command belongs in scripts. |
140
140
  | `plune run report` | Replay `.plune/pending-results.jsonl` — send what the reporter could not. The lines of one reporter run go back as one run, with the commit and branch the reporter recorded. Once every result has gone the file is renamed to `pending-results.<time>.sent.jsonl`; if anything did not go, it stays as it was. Flags: `--file <path>`. |
141
- | `plune ingest [dir]` | Record a [Cairn](https://github.com/plune-ai/cairn) run in Plune. Omit `[dir]` for the newest run under `./runs`, or name the directory holding `report.json`. Generated cases arrive as **review proposals** — nothing is created until a person approves it. A run recorded with `--screencast` also sends each case's video and trace to its proposal (or to its result, for a case approved before), up to 100 MiB a file; a file that does not go is a line under the counters, never a failure. Against a platform with `POST /v1/jobs` the ingest is also reported as a job (kind `ingest`, counting the cases sent, linked to the run it landed in) that ends completed, or failed with the error text if the ingest fails; as with `sync`, an older platform is not told and a job report never fails the ingest or changes its exit code. |
141
+ | `plune ingest [dir]` | Record a [Cairn](https://github.com/plune-ai/cairn) run in Plune. Omit `[dir]` for the newest run under `./runs`, or name the directory holding `report.json`. Generated cases arrive as **review proposals** — nothing is created until a person approves it. A run recorded with `--screencast` also sends each case's video and trace to its proposal (or to its result, for a case approved before), up to 100 MiB a file; a file that does not go is a line under the counters, never a failure. The ingest declares those recordings on each case first (title, chapters, and each file's run-relative path, kind and size, a file over 100 MiB included), so the proposal can show what each file became. Against a platform with `POST /v1/jobs` the ingest is also reported as a job (kind `ingest`, counting the cases sent, linked to the run it landed in) that ends completed, or failed with the error text if the ingest fails; as with `sync`, an older platform is not told and a job report never fails the ingest or changes its exit code. |
142
142
  | `plune pull [file]` | Write the project's test cases as **one Markdown document** — Testomat's classical format, plus Plune's own columns — to `plune/cases.md` (or `[file]`). Refuses to overwrite a file git sees as modified; `--force` overrides, `--suite <id>` takes one suite or folder and what is under it. |
143
143
  | `plune push [file] [--dry-run]` | Send the document back. Cases are matched by `id`; a block without one becomes a draft; an unknown id is refused by line; **nothing is deleted**. Prints the report — created, updated, unchanged, refused, warnings — and with `--dry-run` writes nothing. Exit `4` when anything was refused. |
144
144
  | `plune requirements import <file.md>` | Import requirements from a **Markdown file** (an SRS, a PRD, a page exported from a wiki). With no mapping flags it lists the tables and sections the file has and exits `0`; with `--table` or `--sections` it is a **dry run** that writes nothing until you add `--yes`. See [Requirements from a Markdown file](#requirements-from-a-markdown-file). Needs a Plune platform that serves `POST /v1/projects/:id/requirements/import`. |
package/dist/cli.cjs CHANGED
@@ -8845,7 +8845,7 @@ function fileSender(options) {
8845
8845
  function ask3(job, size) {
8846
8846
  requests += 1;
8847
8847
  return client.post(`${filesOf2(job)}/uploads`, {
8848
- files: [{ name: job.name, contentType: job.type, size }]
8848
+ files: [{ name: job.name, contentType: job.type, size, ...job.key !== void 0 ? { key: job.key } : {} }]
8849
8849
  }, uploadRetries);
8850
8850
  }
8851
8851
  function failed2(job, why) {
@@ -14887,8 +14887,8 @@ function jsonText(value2) {
14887
14887
  const entries2 = Object.entries(step.value).filter(([, v]) => array || !skipped(v));
14888
14888
  const parts = [{ text: array ? "[" : "{" }];
14889
14889
  entries2.forEach(([key, v], i) => {
14890
- const sep3 = i === 0 ? "" : ",";
14891
- parts.push({ text: array ? sep3 : `${sep3}${JSON.stringify(key)}:` }, { value: v });
14890
+ const sep4 = i === 0 ? "" : ",";
14891
+ parts.push({ text: array ? sep4 : `${sep4}${JSON.stringify(key)}:` }, { value: v });
14892
14892
  });
14893
14893
  parts.push({ text: array ? "]" : "}" });
14894
14894
  for (const part of parts.reverse()) todo.push(part);
@@ -33562,27 +33562,58 @@ async function readCairnSessionFiles(dir) {
33562
33562
  if (typeof p !== "string" || p === "") return void 0;
33563
33563
  const abs = path22.resolve(root, p);
33564
33564
  const real = await fs18.realpath(abs).catch(() => void 0);
33565
- if (within2(abs) && (real === void 0 || within2(real))) return real ?? abs;
33565
+ if (within2(abs) && (real === void 0 || within2(real))) {
33566
+ const file = real ?? abs;
33567
+ const size = await fs18.stat(file).then((s) => s.size, () => void 0);
33568
+ return { path: file, rel: path22.relative(root, abs).split(path22.sep).join("/"), ...size !== void 0 ? { size } : {} };
33569
+ }
33566
33570
  outside += 1;
33567
33571
  return void 0;
33568
33572
  };
33569
33573
  const byCase = /* @__PURE__ */ new Map();
33574
+ const screencasts = /* @__PURE__ */ new Map();
33570
33575
  let unmapped = 0;
33571
33576
  for (const entry2 of raw) {
33572
33577
  const rec = asRecord2(entry2);
33573
- const files = [];
33574
- for (const p of [own2(rec, "video"), own2(rec, "trace")]) {
33575
- const file = await inside(p);
33576
- if (file !== void 0) files.push(file);
33578
+ const found = [];
33579
+ for (const kind2 of ["video", "trace"]) {
33580
+ const at2 = await inside(own2(rec, kind2));
33581
+ if (at2 !== void 0) found.push({ file: { path: at2.path, ...at2.size !== void 0 ? { size: at2.size } : {} }, rel: at2.rel, kind: kind2 });
33577
33582
  }
33578
- if (files.length === 0) continue;
33583
+ if (found.length === 0) continue;
33579
33584
  const stableId = own2(rec, "stableId");
33580
- if (typeof stableId !== "string" || stableId === "") unmapped += 1;
33581
- else byCase.set(stableId, [...byCase.get(stableId) ?? [], ...files]);
33585
+ if (typeof stableId !== "string" || stableId === "") {
33586
+ unmapped += 1;
33587
+ continue;
33588
+ }
33589
+ byCase.set(stableId, [...byCase.get(stableId) ?? [], ...found.map((f) => f.file)]);
33590
+ const declared2 = screencasts.get(stableId) ?? [];
33591
+ const keys = new Set(declared2.flatMap((s) => s.files.map((f) => f.key)));
33592
+ const title = clip(str(own2(rec, "test")));
33593
+ const files = found.filter((f) => {
33594
+ if ((f.file.size ?? 0) < 1 || f.rel.length > DECLARED.text || path22.basename(f.file.path).length > DECLARED.name || keys.has(f.rel)) return false;
33595
+ keys.add(f.rel);
33596
+ return true;
33597
+ });
33598
+ if (title === "" || files.length === 0 || declared2.length >= DECLARED.perCase) continue;
33599
+ for (const f of files) f.file.key = f.rel;
33600
+ const timing = own2(rec, "timing");
33601
+ declared2.push({
33602
+ title,
33603
+ ...timing === "trace" || timing === "estimated" ? { timing } : {},
33604
+ chapters: (Array.isArray(own2(rec, "chapters")) ? own2(rec, "chapters") : []).flatMap((c) => {
33605
+ const chapter = asRecord2(c);
33606
+ const t = clip(str(own2(chapter, "title")));
33607
+ const atMs = own2(chapter, "atMs");
33608
+ return t !== "" && Number.isInteger(atMs) && atMs >= 0 ? [{ title: t, atMs }] : [];
33609
+ }).slice(0, DECLARED.chapters),
33610
+ files: files.map((f) => ({ key: f.rel, name: path22.basename(f.file.path), kind: f.kind, size: f.file.size }))
33611
+ });
33612
+ screencasts.set(stableId, declared2);
33582
33613
  }
33583
- return { byCase, unmapped, outside };
33614
+ return { byCase, screencasts, unmapped, outside };
33584
33615
  }
33585
- var fs18, path22, SUPPORTED_ARTIFACT_VERSION, INGEST_SCHEMA_VERSION, NoCairnRunsError, CairnRunNotFoundError, CairnRunVersionError, CairnRunPartialError, CairnArtifactShapeError, CairnEvidenceAmbiguousError, asRecord2, str, own2, MAX_ARTIFACT_BYTES, MAX_MCP_CASES, ARGS_CHARS2, SECRET_NAME, maskNamed, MCP_STATES;
33616
+ var fs18, path22, SUPPORTED_ARTIFACT_VERSION, INGEST_SCHEMA_VERSION, NoCairnRunsError, CairnRunNotFoundError, CairnRunVersionError, CairnRunPartialError, CairnArtifactShapeError, CairnEvidenceAmbiguousError, asRecord2, str, own2, MAX_ARTIFACT_BYTES, MAX_MCP_CASES, ARGS_CHARS2, SECRET_NAME, maskNamed, MCP_STATES, DECLARED, clip;
33586
33617
  var init_cairn_artifact = __esm({
33587
33618
  "src/cli/commands/cairn-artifact.ts"() {
33588
33619
  "use strict";
@@ -33663,6 +33694,8 @@ var init_cairn_artifact = __esm({
33663
33694
  "could-not-run",
33664
33695
  "needs-review"
33665
33696
  ]);
33697
+ DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
33698
+ clip = (s) => s.slice(0, DECLARED.text).replace(/[\uD800-\uDBFF]$/, "");
33666
33699
  }
33667
33700
  });
33668
33701
 
@@ -33721,8 +33754,7 @@ async function heldBy(client, runId, jobs) {
33721
33754
  for (const job of results4) held.set(targetOf3(job), byResult === void 0 ? void 0 : byResult.get(job.id) ?? /* @__PURE__ */ new Set());
33722
33755
  return held;
33723
33756
  }
33724
- async function sendSessionFiles(dir, sent, platform) {
33725
- const session2 = await readCairnSessionFiles(dir);
33757
+ async function sendSessionFiles(session2, sent, platform) {
33726
33758
  if (session2 === void 0 || session2.byCase.size === 0 && session2.unmapped === 0 && session2.outside === 0) return [];
33727
33759
  if (sent.items === void 0) {
33728
33760
  return ["session files not uploaded \u2014 this Plune is older than the routes that take them"];
@@ -33737,9 +33769,8 @@ async function sendSessionFiles(dir, sent, platform) {
33737
33769
  const paths = session2.byCase.get(item.stableId);
33738
33770
  if (paths === void 0 || placed.has(item.stableId)) continue;
33739
33771
  placed.add(item.stableId);
33740
- for (const file of paths) {
33772
+ for (const { path: file, size, key } of paths) {
33741
33773
  const name = path23.basename(file);
33742
- const size = await import_node_fs19.promises.stat(file).then((s) => s.size, () => void 0);
33743
33774
  if (size !== void 0 && size > SESSION_FILE_MAX) {
33744
33775
  tooBig += 1;
33745
33776
  lines.push(`"${name}" skipped \u2014 larger than the ${SESSION_FILE_MAX / (1024 * 1024)} MiB a session file may be`);
@@ -33752,7 +33783,9 @@ async function sendSessionFiles(dir, sent, platform) {
33752
33783
  kind: "file",
33753
33784
  name,
33754
33785
  type,
33755
- path: file
33786
+ path: file,
33787
+ // Declared on the proposal only: a result's route has no declaration to match.
33788
+ ...key !== void 0 && item.reviewItemId !== void 0 ? { key } : {}
33756
33789
  });
33757
33790
  }
33758
33791
  }
@@ -33810,6 +33843,11 @@ async function handleIngest(deps) {
33810
33843
  if (token2 === null) throw new IngestNotLoggedInError();
33811
33844
  const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
33812
33845
  const payload2 = await readCairnRun(dir);
33846
+ const session2 = await readCairnSessionFiles(dir).catch(() => void 0);
33847
+ for (const c of payload2.cases) {
33848
+ const screencasts = session2?.screencasts.get(c.stableId);
33849
+ if (screencasts !== void 0) c.screencasts = screencasts;
33850
+ }
33813
33851
  const doFetch = deps.fetchImpl ?? fetch;
33814
33852
  const endpoint = `${apiUrl}/v1/ingest/cairn`;
33815
33853
  const job = new JobReporter(doFetch, apiUrl, token2, "ingest");
@@ -33817,7 +33855,7 @@ async function handleIngest(deps) {
33817
33855
  try {
33818
33856
  const { result: result2, ...sent } = await upload();
33819
33857
  await job.uploaded({ subjectId: result2.runId || void 0 });
33820
- const files = await sendSessionFiles(dir, { ...sent, runId: result2.runId }, { apiUrl, token: token2, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
33858
+ const files = await sendSessionFiles(session2, { ...sent, runId: result2.runId }, { apiUrl, token: token2, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
33821
33859
  () => ["session files not uploaded (an unexpected error) \u2014 the run is recorded"]
33822
33860
  );
33823
33861
  if (files.length > 0) result2.files = files;
@@ -33878,12 +33916,11 @@ function formatIngestResult(r) {
33878
33916
  return `${lines.join("\n")}
33879
33917
  `;
33880
33918
  }
33881
- var import_node_fs19, path23, IngestNotLoggedInError, IngestTokenRejectedError, IngestNetworkError, IngestHttpError, SESSION_FILE_MAX, SESSION_UPLOADS_AT_ONCE, TYPE_BY_EXTENSION2, RESULT_PAGES_MAX, namesOf, targetOf3;
33919
+ var path23, IngestNotLoggedInError, IngestTokenRejectedError, IngestNetworkError, IngestHttpError, SESSION_FILE_MAX, SESSION_UPLOADS_AT_ONCE, TYPE_BY_EXTENSION2, RESULT_PAGES_MAX, namesOf, targetOf3;
33882
33920
  var init_ingest = __esm({
33883
33921
  "src/cli/commands/ingest.ts"() {
33884
33922
  "use strict";
33885
33923
  init_cjs_shims();
33886
- import_node_fs19 = require("fs");
33887
33924
  path23 = __toESM(require("path"), 1);
33888
33925
  init_client();
33889
33926
  init_env2();
@@ -34035,7 +34072,7 @@ function readMarkdown(cwd, file) {
34035
34072
  const target4 = (0, import_node_path13.resolve)(cwd, file);
34036
34073
  let size;
34037
34074
  try {
34038
- const st = (0, import_node_fs20.statSync)(target4);
34075
+ const st = (0, import_node_fs19.statSync)(target4);
34039
34076
  if (!st.isFile()) return usage(`${target4} is not a file.`);
34040
34077
  size = st.size;
34041
34078
  } catch {
@@ -34046,7 +34083,7 @@ function readMarkdown(cwd, file) {
34046
34083
  }
34047
34084
  let text6;
34048
34085
  try {
34049
- text6 = new TextDecoder("utf-8", { fatal: true }).decode((0, import_node_fs20.readFileSync)(target4));
34086
+ text6 = new TextDecoder("utf-8", { fatal: true }).decode((0, import_node_fs19.readFileSync)(target4));
34050
34087
  } catch {
34051
34088
  return usage(`${target4} is not valid UTF-8. Save it as UTF-8 and try again.`);
34052
34089
  }
@@ -34170,12 +34207,12 @@ function reportRequirementsImportFailure(err, write) {
34170
34207
  write(err.message + "\n");
34171
34208
  return err.exitCode;
34172
34209
  }
34173
- 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;
34210
+ var import_node_fs19, import_node_path13, MAX_MARKDOWN_BYTES, RequirementsImportError, usage, COLUMN_FLAGS, SECTION_FLAGS, oneOf5, TABLE_SPEC_KEYS, SPEC_HELP, SUPPORT, SHOWN4, flat2, cut4, plural8;
34174
34211
  var init_requirements_import = __esm({
34175
34212
  "src/cli/commands/requirements-import.ts"() {
34176
34213
  "use strict";
34177
34214
  init_cjs_shims();
34178
- import_node_fs20 = require("fs");
34215
+ import_node_fs19 = require("fs");
34179
34216
  import_node_path13 = require("path");
34180
34217
  init_client();
34181
34218
  init_api_url();
@@ -34376,7 +34413,7 @@ async function loadSources(deps) {
34376
34413
  let raw;
34377
34414
  if (deps.from !== void 0) {
34378
34415
  try {
34379
- raw = (0, import_node_fs21.readFileSync)(deps.from, "utf8");
34416
+ raw = (0, import_node_fs20.readFileSync)(deps.from, "utf8");
34380
34417
  } catch {
34381
34418
  throw new SyncFileError(`cannot read ${deps.from}`);
34382
34419
  }
@@ -34428,13 +34465,13 @@ function formatVerify(r) {
34428
34465
  );
34429
34466
  return lines.join("\n") + "\n";
34430
34467
  }
34431
- var import_node_child_process4, import_node_fs21, TOKEN5;
34468
+ var import_node_child_process4, import_node_fs20, TOKEN5;
34432
34469
  var init_verify = __esm({
34433
34470
  "src/cli/commands/verify.ts"() {
34434
34471
  "use strict";
34435
34472
  init_cjs_shims();
34436
34473
  import_node_child_process4 = require("child_process");
34437
- import_node_fs21 = require("fs");
34474
+ import_node_fs20 = require("fs");
34438
34475
  init_plan();
34439
34476
  init_sync();
34440
34477
  TOKEN5 = /@P([A-Za-z0-9_-]+)/;
@@ -34849,10 +34886,10 @@ __export(ids_exports, {
34849
34886
  serializeMap: () => serializeMap
34850
34887
  });
34851
34888
  function readMap(file) {
34852
- if (!(0, import_node_fs22.existsSync)(file)) return {};
34889
+ if (!(0, import_node_fs21.existsSync)(file)) return {};
34853
34890
  let parsed4;
34854
34891
  try {
34855
- parsed4 = JSON.parse((0, import_node_fs22.readFileSync)(file, "utf8"));
34892
+ parsed4 = JSON.parse((0, import_node_fs21.readFileSync)(file, "utf8"));
34856
34893
  } catch {
34857
34894
  throw new SyncFileError(`${file} is not valid JSON; fix or remove it, nothing was written`);
34858
34895
  }
@@ -34900,8 +34937,8 @@ async function handleIds(deps) {
34900
34937
  let written = false;
34901
34938
  if (deps.write === true && Object.keys(plan.added).length > 0) {
34902
34939
  try {
34903
- (0, import_node_fs22.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true });
34904
- (0, import_node_fs22.writeFileSync)(file, serializeMap({ ...current, ...plan.added }));
34940
+ (0, import_node_fs21.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true });
34941
+ (0, import_node_fs21.writeFileSync)(file, serializeMap({ ...current, ...plan.added }));
34905
34942
  } catch {
34906
34943
  throw new SyncFileError(`cannot write ${file}`);
34907
34944
  }
@@ -34929,12 +34966,12 @@ function formatIds(r, write) {
34929
34966
  );
34930
34967
  return lines.join("\n") + "\n";
34931
34968
  }
34932
- var import_node_fs22, import_node_path14, DEFAULT_IDS_FILE, compareKeys;
34969
+ var import_node_fs21, import_node_path14, DEFAULT_IDS_FILE, compareKeys;
34933
34970
  var init_ids = __esm({
34934
34971
  "src/cli/commands/ids.ts"() {
34935
34972
  "use strict";
34936
34973
  init_cjs_shims();
34937
- import_node_fs22 = require("fs");
34974
+ import_node_fs21 = require("fs");
34938
34975
  import_node_path14 = require("path");
34939
34976
  init_verify();
34940
34977
  init_sync();
@@ -34953,7 +34990,7 @@ module.exports = __toCommonJS(cli_exports);
34953
34990
  init_cjs_shims();
34954
34991
  init_api_url();
34955
34992
  var import_commander = require("commander");
34956
- var import_node_fs23 = require("fs");
34993
+ var import_node_fs22 = require("fs");
34957
34994
  var import_node_path15 = require("path");
34958
34995
  var import_node_url = require("url");
34959
34996
  init_duration();
@@ -34990,7 +35027,7 @@ var rawArgsOf = (program) => program.rawArgs ?? [];
34990
35027
 
34991
35028
  // src/cli.ts
34992
35029
  var __dirname = (0, import_node_path15.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl));
34993
- var pkg = JSON.parse((0, import_node_fs23.readFileSync)((0, import_node_path15.join)(__dirname, "..", "package.json"), "utf-8"));
35030
+ var pkg = JSON.parse((0, import_node_fs22.readFileSync)((0, import_node_path15.join)(__dirname, "..", "package.json"), "utf-8"));
34994
35031
  function toFormat(s) {
34995
35032
  return s === "json" || s === "markdown" ? s : "console";
34996
35033
  }
@@ -34999,7 +35036,7 @@ function shouldColor(outputPath) {
34999
35036
  }
35000
35037
  function writeReport2(text6, outputPath) {
35001
35038
  if (outputPath !== void 0) {
35002
- (0, import_node_fs23.writeFileSync)(outputPath, text6);
35039
+ (0, import_node_fs22.writeFileSync)(outputPath, text6);
35003
35040
  } else {
35004
35041
  process.stdout.write(text6 + "\n");
35005
35042
  }
@@ -35923,7 +35960,7 @@ function isMainModule() {
35923
35960
  const entry2 = process.argv[1];
35924
35961
  if (entry2 === void 0) return false;
35925
35962
  try {
35926
- return (0, import_node_fs23.realpathSync)(entry2) === (0, import_node_fs23.realpathSync)((0, import_node_url.fileURLToPath)(importMetaUrl));
35963
+ return (0, import_node_fs22.realpathSync)(entry2) === (0, import_node_fs22.realpathSync)((0, import_node_url.fileURLToPath)(importMetaUrl));
35927
35964
  } catch {
35928
35965
  return false;
35929
35966
  }
package/dist/index.cjs CHANGED
@@ -4983,7 +4983,6 @@ function reportSyncFailure(err, write) {
4983
4983
 
4984
4984
  // src/cli/commands/ingest.ts
4985
4985
  init_cjs_shims();
4986
- var import_node_fs8 = require("fs");
4987
4986
  var path10 = __toESM(require("path"), 1);
4988
4987
 
4989
4988
  // src/reporter-core/client.ts
@@ -5359,7 +5358,7 @@ function fileSender(options) {
5359
5358
  function ask(job, size) {
5360
5359
  requests += 1;
5361
5360
  return client.post(`${filesOf(job)}/uploads`, {
5362
- files: [{ name: job.name, contentType: job.type, size }]
5361
+ files: [{ name: job.name, contentType: job.type, size, ...job.key !== void 0 ? { key: job.key } : {} }]
5363
5362
  }, uploadRetries);
5364
5363
  }
5365
5364
  function failed(job, why) {
@@ -7665,6 +7664,8 @@ async function readCairnRun(dir, deps = {}) {
7665
7664
  cases
7666
7665
  };
7667
7666
  }
7667
+ var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
7668
+ var clip = (s) => s.slice(0, DECLARED.text).replace(/[\uD800-\uDBFF]$/, "");
7668
7669
  async function readCairnSessionFiles(dir) {
7669
7670
  const raw = await readJson(path9.join(dir, "screencasts", "screencasts.json"));
7670
7671
  if (!Array.isArray(raw)) return void 0;
@@ -7678,25 +7679,56 @@ async function readCairnSessionFiles(dir) {
7678
7679
  if (typeof p !== "string" || p === "") return void 0;
7679
7680
  const abs = path9.resolve(root, p);
7680
7681
  const real = await fs8.realpath(abs).catch(() => void 0);
7681
- if (within(abs) && (real === void 0 || within(real))) return real ?? abs;
7682
+ if (within(abs) && (real === void 0 || within(real))) {
7683
+ const file = real ?? abs;
7684
+ const size = await fs8.stat(file).then((s) => s.size, () => void 0);
7685
+ return { path: file, rel: path9.relative(root, abs).split(path9.sep).join("/"), ...size !== void 0 ? { size } : {} };
7686
+ }
7682
7687
  outside += 1;
7683
7688
  return void 0;
7684
7689
  };
7685
7690
  const byCase = /* @__PURE__ */ new Map();
7691
+ const screencasts = /* @__PURE__ */ new Map();
7686
7692
  let unmapped = 0;
7687
7693
  for (const entry of raw) {
7688
7694
  const rec = asRecord(entry);
7689
- const files = [];
7690
- for (const p of [own(rec, "video"), own(rec, "trace")]) {
7691
- const file = await inside(p);
7692
- if (file !== void 0) files.push(file);
7695
+ const found = [];
7696
+ for (const kind of ["video", "trace"]) {
7697
+ const at = await inside(own(rec, kind));
7698
+ if (at !== void 0) found.push({ file: { path: at.path, ...at.size !== void 0 ? { size: at.size } : {} }, rel: at.rel, kind });
7693
7699
  }
7694
- if (files.length === 0) continue;
7700
+ if (found.length === 0) continue;
7695
7701
  const stableId = own(rec, "stableId");
7696
- if (typeof stableId !== "string" || stableId === "") unmapped += 1;
7697
- else byCase.set(stableId, [...byCase.get(stableId) ?? [], ...files]);
7702
+ if (typeof stableId !== "string" || stableId === "") {
7703
+ unmapped += 1;
7704
+ continue;
7705
+ }
7706
+ byCase.set(stableId, [...byCase.get(stableId) ?? [], ...found.map((f) => f.file)]);
7707
+ const declared = screencasts.get(stableId) ?? [];
7708
+ const keys = new Set(declared.flatMap((s) => s.files.map((f) => f.key)));
7709
+ const title = clip(str(own(rec, "test")));
7710
+ const files = found.filter((f) => {
7711
+ if ((f.file.size ?? 0) < 1 || f.rel.length > DECLARED.text || path9.basename(f.file.path).length > DECLARED.name || keys.has(f.rel)) return false;
7712
+ keys.add(f.rel);
7713
+ return true;
7714
+ });
7715
+ if (title === "" || files.length === 0 || declared.length >= DECLARED.perCase) continue;
7716
+ for (const f of files) f.file.key = f.rel;
7717
+ const timing = own(rec, "timing");
7718
+ declared.push({
7719
+ title,
7720
+ ...timing === "trace" || timing === "estimated" ? { timing } : {},
7721
+ chapters: (Array.isArray(own(rec, "chapters")) ? own(rec, "chapters") : []).flatMap((c) => {
7722
+ const chapter = asRecord(c);
7723
+ const t = clip(str(own(chapter, "title")));
7724
+ const atMs = own(chapter, "atMs");
7725
+ return t !== "" && Number.isInteger(atMs) && atMs >= 0 ? [{ title: t, atMs }] : [];
7726
+ }).slice(0, DECLARED.chapters),
7727
+ files: files.map((f) => ({ key: f.rel, name: path9.basename(f.file.path), kind: f.kind, size: f.file.size }))
7728
+ });
7729
+ screencasts.set(stableId, declared);
7698
7730
  }
7699
- return { byCase, unmapped, outside };
7731
+ return { byCase, screencasts, unmapped, outside };
7700
7732
  }
7701
7733
 
7702
7734
  // src/cli/commands/ingest.ts
@@ -7776,8 +7808,7 @@ async function heldBy(client, runId, jobs) {
7776
7808
  return held;
7777
7809
  }
7778
7810
  var targetOf = (job) => `${job.owner ?? "results"}/${job.id}`;
7779
- async function sendSessionFiles(dir, sent, platform) {
7780
- const session = await readCairnSessionFiles(dir);
7811
+ async function sendSessionFiles(session, sent, platform) {
7781
7812
  if (session === void 0 || session.byCase.size === 0 && session.unmapped === 0 && session.outside === 0) return [];
7782
7813
  if (sent.items === void 0) {
7783
7814
  return ["session files not uploaded \u2014 this Plune is older than the routes that take them"];
@@ -7792,9 +7823,8 @@ async function sendSessionFiles(dir, sent, platform) {
7792
7823
  const paths = session.byCase.get(item.stableId);
7793
7824
  if (paths === void 0 || placed.has(item.stableId)) continue;
7794
7825
  placed.add(item.stableId);
7795
- for (const file of paths) {
7826
+ for (const { path: file, size, key } of paths) {
7796
7827
  const name = path10.basename(file);
7797
- const size = await import_node_fs8.promises.stat(file).then((s) => s.size, () => void 0);
7798
7828
  if (size !== void 0 && size > SESSION_FILE_MAX) {
7799
7829
  tooBig += 1;
7800
7830
  lines.push(`"${name}" skipped \u2014 larger than the ${SESSION_FILE_MAX / (1024 * 1024)} MiB a session file may be`);
@@ -7807,7 +7837,9 @@ async function sendSessionFiles(dir, sent, platform) {
7807
7837
  kind: "file",
7808
7838
  name,
7809
7839
  type,
7810
- path: file
7840
+ path: file,
7841
+ // Declared on the proposal only: a result's route has no declaration to match.
7842
+ ...key !== void 0 && item.reviewItemId !== void 0 ? { key } : {}
7811
7843
  });
7812
7844
  }
7813
7845
  }
@@ -7865,6 +7897,11 @@ async function handleIngest(deps) {
7865
7897
  if (token === null) throw new IngestNotLoggedInError();
7866
7898
  const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
7867
7899
  const payload = await readCairnRun(dir);
7900
+ const session = await readCairnSessionFiles(dir).catch(() => void 0);
7901
+ for (const c of payload.cases) {
7902
+ const screencasts = session?.screencasts.get(c.stableId);
7903
+ if (screencasts !== void 0) c.screencasts = screencasts;
7904
+ }
7868
7905
  const doFetch = deps.fetchImpl ?? fetch;
7869
7906
  const endpoint = `${apiUrl}/v1/ingest/cairn`;
7870
7907
  const job = new JobReporter(doFetch, apiUrl, token, "ingest");
@@ -7872,7 +7909,7 @@ async function handleIngest(deps) {
7872
7909
  try {
7873
7910
  const { result, ...sent } = await upload();
7874
7911
  await job.uploaded({ subjectId: result.runId || void 0 });
7875
- const files = await sendSessionFiles(dir, { ...sent, runId: result.runId }, { apiUrl, token, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
7912
+ const files = await sendSessionFiles(session, { ...sent, runId: result.runId }, { apiUrl, token, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
7876
7913
  () => ["session files not uploaded (an unexpected error) \u2014 the run is recorded"]
7877
7914
  );
7878
7915
  if (files.length > 0) result.files = files;
package/dist/index.d.cts CHANGED
@@ -1256,6 +1256,25 @@ interface CairnIngestCase {
1256
1256
  verdict?: CairnVerdict;
1257
1257
  technique?: string;
1258
1258
  priority?: string;
1259
+ /** The case's recordings, from `screencasts/screencasts.json`. Absent when the run recorded none for it. */
1260
+ screencasts?: CairnScreencast[];
1261
+ }
1262
+ /** One recorded test, declared so the platform can show each file's state (uploaded, too big, no bucket) on the proposal. */
1263
+ interface CairnScreencast {
1264
+ /** The screencasts.json `test`. */
1265
+ title: string;
1266
+ timing?: 'trace' | 'estimated';
1267
+ chapters: {
1268
+ title: string;
1269
+ atMs: number;
1270
+ }[];
1271
+ /** `key` is the file's run-relative path, unique within the case; the upload of that file sends it back. */
1272
+ files: {
1273
+ key: string;
1274
+ name: string;
1275
+ kind: 'video' | 'trace';
1276
+ size: number;
1277
+ }[];
1259
1278
  }
1260
1279
  interface CairnIngestPayload {
1261
1280
  schemaVersion: typeof INGEST_SCHEMA_VERSION;
package/dist/index.d.ts CHANGED
@@ -1256,6 +1256,25 @@ interface CairnIngestCase {
1256
1256
  verdict?: CairnVerdict;
1257
1257
  technique?: string;
1258
1258
  priority?: string;
1259
+ /** The case's recordings, from `screencasts/screencasts.json`. Absent when the run recorded none for it. */
1260
+ screencasts?: CairnScreencast[];
1261
+ }
1262
+ /** One recorded test, declared so the platform can show each file's state (uploaded, too big, no bucket) on the proposal. */
1263
+ interface CairnScreencast {
1264
+ /** The screencasts.json `test`. */
1265
+ title: string;
1266
+ timing?: 'trace' | 'estimated';
1267
+ chapters: {
1268
+ title: string;
1269
+ atMs: number;
1270
+ }[];
1271
+ /** `key` is the file's run-relative path, unique within the case; the upload of that file sends it back. */
1272
+ files: {
1273
+ key: string;
1274
+ name: string;
1275
+ kind: 'video' | 'trace';
1276
+ size: number;
1277
+ }[];
1259
1278
  }
1260
1279
  interface CairnIngestPayload {
1261
1280
  schemaVersion: typeof INGEST_SCHEMA_VERSION;
package/dist/index.js CHANGED
@@ -4945,7 +4945,6 @@ function reportSyncFailure(err, write) {
4945
4945
 
4946
4946
  // src/cli/commands/ingest.ts
4947
4947
  init_esm_shims();
4948
- import { promises as disk2 } from "fs";
4949
4948
  import * as path11 from "path";
4950
4949
 
4951
4950
  // src/reporter-core/client.ts
@@ -5321,7 +5320,7 @@ function fileSender(options) {
5321
5320
  function ask(job, size) {
5322
5321
  requests += 1;
5323
5322
  return client.post(`${filesOf(job)}/uploads`, {
5324
- files: [{ name: job.name, contentType: job.type, size }]
5323
+ files: [{ name: job.name, contentType: job.type, size, ...job.key !== void 0 ? { key: job.key } : {} }]
5325
5324
  }, uploadRetries);
5326
5325
  }
5327
5326
  function failed(job, why) {
@@ -7627,6 +7626,8 @@ async function readCairnRun(dir, deps = {}) {
7627
7626
  cases
7628
7627
  };
7629
7628
  }
7629
+ var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
7630
+ var clip = (s) => s.slice(0, DECLARED.text).replace(/[\uD800-\uDBFF]$/, "");
7630
7631
  async function readCairnSessionFiles(dir) {
7631
7632
  const raw = await readJson(path10.join(dir, "screencasts", "screencasts.json"));
7632
7633
  if (!Array.isArray(raw)) return void 0;
@@ -7640,25 +7641,56 @@ async function readCairnSessionFiles(dir) {
7640
7641
  if (typeof p !== "string" || p === "") return void 0;
7641
7642
  const abs = path10.resolve(root, p);
7642
7643
  const real = await fs8.realpath(abs).catch(() => void 0);
7643
- if (within(abs) && (real === void 0 || within(real))) return real ?? abs;
7644
+ if (within(abs) && (real === void 0 || within(real))) {
7645
+ const file = real ?? abs;
7646
+ const size = await fs8.stat(file).then((s) => s.size, () => void 0);
7647
+ return { path: file, rel: path10.relative(root, abs).split(path10.sep).join("/"), ...size !== void 0 ? { size } : {} };
7648
+ }
7644
7649
  outside += 1;
7645
7650
  return void 0;
7646
7651
  };
7647
7652
  const byCase = /* @__PURE__ */ new Map();
7653
+ const screencasts = /* @__PURE__ */ new Map();
7648
7654
  let unmapped = 0;
7649
7655
  for (const entry of raw) {
7650
7656
  const rec = asRecord(entry);
7651
- const files = [];
7652
- for (const p of [own(rec, "video"), own(rec, "trace")]) {
7653
- const file = await inside(p);
7654
- if (file !== void 0) files.push(file);
7657
+ const found = [];
7658
+ for (const kind of ["video", "trace"]) {
7659
+ const at = await inside(own(rec, kind));
7660
+ if (at !== void 0) found.push({ file: { path: at.path, ...at.size !== void 0 ? { size: at.size } : {} }, rel: at.rel, kind });
7655
7661
  }
7656
- if (files.length === 0) continue;
7662
+ if (found.length === 0) continue;
7657
7663
  const stableId = own(rec, "stableId");
7658
- if (typeof stableId !== "string" || stableId === "") unmapped += 1;
7659
- else byCase.set(stableId, [...byCase.get(stableId) ?? [], ...files]);
7664
+ if (typeof stableId !== "string" || stableId === "") {
7665
+ unmapped += 1;
7666
+ continue;
7667
+ }
7668
+ byCase.set(stableId, [...byCase.get(stableId) ?? [], ...found.map((f) => f.file)]);
7669
+ const declared = screencasts.get(stableId) ?? [];
7670
+ const keys = new Set(declared.flatMap((s) => s.files.map((f) => f.key)));
7671
+ const title = clip(str(own(rec, "test")));
7672
+ const files = found.filter((f) => {
7673
+ if ((f.file.size ?? 0) < 1 || f.rel.length > DECLARED.text || path10.basename(f.file.path).length > DECLARED.name || keys.has(f.rel)) return false;
7674
+ keys.add(f.rel);
7675
+ return true;
7676
+ });
7677
+ if (title === "" || files.length === 0 || declared.length >= DECLARED.perCase) continue;
7678
+ for (const f of files) f.file.key = f.rel;
7679
+ const timing = own(rec, "timing");
7680
+ declared.push({
7681
+ title,
7682
+ ...timing === "trace" || timing === "estimated" ? { timing } : {},
7683
+ chapters: (Array.isArray(own(rec, "chapters")) ? own(rec, "chapters") : []).flatMap((c) => {
7684
+ const chapter = asRecord(c);
7685
+ const t = clip(str(own(chapter, "title")));
7686
+ const atMs = own(chapter, "atMs");
7687
+ return t !== "" && Number.isInteger(atMs) && atMs >= 0 ? [{ title: t, atMs }] : [];
7688
+ }).slice(0, DECLARED.chapters),
7689
+ files: files.map((f) => ({ key: f.rel, name: path10.basename(f.file.path), kind: f.kind, size: f.file.size }))
7690
+ });
7691
+ screencasts.set(stableId, declared);
7660
7692
  }
7661
- return { byCase, unmapped, outside };
7693
+ return { byCase, screencasts, unmapped, outside };
7662
7694
  }
7663
7695
 
7664
7696
  // src/cli/commands/ingest.ts
@@ -7738,8 +7770,7 @@ async function heldBy(client, runId, jobs) {
7738
7770
  return held;
7739
7771
  }
7740
7772
  var targetOf = (job) => `${job.owner ?? "results"}/${job.id}`;
7741
- async function sendSessionFiles(dir, sent, platform) {
7742
- const session = await readCairnSessionFiles(dir);
7773
+ async function sendSessionFiles(session, sent, platform) {
7743
7774
  if (session === void 0 || session.byCase.size === 0 && session.unmapped === 0 && session.outside === 0) return [];
7744
7775
  if (sent.items === void 0) {
7745
7776
  return ["session files not uploaded \u2014 this Plune is older than the routes that take them"];
@@ -7754,9 +7785,8 @@ async function sendSessionFiles(dir, sent, platform) {
7754
7785
  const paths = session.byCase.get(item.stableId);
7755
7786
  if (paths === void 0 || placed.has(item.stableId)) continue;
7756
7787
  placed.add(item.stableId);
7757
- for (const file of paths) {
7788
+ for (const { path: file, size, key } of paths) {
7758
7789
  const name = path11.basename(file);
7759
- const size = await disk2.stat(file).then((s) => s.size, () => void 0);
7760
7790
  if (size !== void 0 && size > SESSION_FILE_MAX) {
7761
7791
  tooBig += 1;
7762
7792
  lines.push(`"${name}" skipped \u2014 larger than the ${SESSION_FILE_MAX / (1024 * 1024)} MiB a session file may be`);
@@ -7769,7 +7799,9 @@ async function sendSessionFiles(dir, sent, platform) {
7769
7799
  kind: "file",
7770
7800
  name,
7771
7801
  type,
7772
- path: file
7802
+ path: file,
7803
+ // Declared on the proposal only: a result's route has no declaration to match.
7804
+ ...key !== void 0 && item.reviewItemId !== void 0 ? { key } : {}
7773
7805
  });
7774
7806
  }
7775
7807
  }
@@ -7827,6 +7859,11 @@ async function handleIngest(deps) {
7827
7859
  if (token === null) throw new IngestNotLoggedInError();
7828
7860
  const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
7829
7861
  const payload = await readCairnRun(dir);
7862
+ const session = await readCairnSessionFiles(dir).catch(() => void 0);
7863
+ for (const c of payload.cases) {
7864
+ const screencasts = session?.screencasts.get(c.stableId);
7865
+ if (screencasts !== void 0) c.screencasts = screencasts;
7866
+ }
7830
7867
  const doFetch = deps.fetchImpl ?? fetch;
7831
7868
  const endpoint = `${apiUrl}/v1/ingest/cairn`;
7832
7869
  const job = new JobReporter(doFetch, apiUrl, token, "ingest");
@@ -7834,7 +7871,7 @@ async function handleIngest(deps) {
7834
7871
  try {
7835
7872
  const { result, ...sent } = await upload();
7836
7873
  await job.uploaded({ subjectId: result.runId || void 0 });
7837
- const files = await sendSessionFiles(dir, { ...sent, runId: result.runId }, { apiUrl, token, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
7874
+ const files = await sendSessionFiles(session, { ...sent, runId: result.runId }, { apiUrl, token, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
7838
7875
  () => ["session files not uploaded (an unexpected error) \u2014 the run is recorded"]
7839
7876
  );
7840
7877
  if (files.length > 0) result.files = files;
@@ -789,7 +789,7 @@ function fileSender(options) {
789
789
  function ask(job, size) {
790
790
  requests += 1;
791
791
  return client.post(`${filesOf2(job)}/uploads`, {
792
- files: [{ name: job.name, contentType: job.type, size }]
792
+ files: [{ name: job.name, contentType: job.type, size, ...job.key !== void 0 ? { key: job.key } : {} }]
793
793
  }, uploadRetries);
794
794
  }
795
795
  function failed(job, why) {
@@ -739,7 +739,7 @@ function fileSender(options) {
739
739
  function ask(job, size) {
740
740
  requests += 1;
741
741
  return client.post(`${filesOf2(job)}/uploads`, {
742
- files: [{ name: job.name, contentType: job.type, size }]
742
+ files: [{ name: job.name, contentType: job.type, size, ...job.key !== void 0 ? { key: job.key } : {} }]
743
743
  }, uploadRetries);
744
744
  }
745
745
  function failed(job, why) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.39.0",
3
+ "version": "0.39.1",
4
4
  "description": "AI-powered assertion testing for LLM apps — write assertions, run them against any provider, get a pass/fail report (local, CI, or diff).",
5
5
  "keywords": [
6
6
  "ai",