@quikit/quikpilot-runner 9.3.0-rc.7 → 9.3.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12278,6 +12278,9 @@ var MAX_TEST_LIMIT_MS = 6e5;
12278
12278
  var DEFAULT_TEST_LIMIT_MS = 3e5;
12279
12279
  var MAX_LISTED_TESTS = 20;
12280
12280
  var MAX_TEST_NAME_CHARS = 200;
12281
+ var MAX_MESSAGE_CHARS = 120;
12282
+ var LINE_BREAK = /\r\n|\n|\r|&#0*10;|&#x0*a;/i;
12283
+ var CONTROL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g;
12281
12284
  var FRESH_SLACK_MS = 2e3;
12282
12285
  function testTimeLimitMs(baselineMs) {
12283
12286
  if (baselineMs === null) return DEFAULT_TEST_LIMIT_MS;
@@ -12286,16 +12289,40 @@ function testTimeLimitMs(baselineMs) {
12286
12289
  }
12287
12290
  var MESSAGES = {
12288
12291
  tests_passed: "The tests passed.",
12289
- tests_failed: "Some tests failed. output lists their names, regressions first: a regression passed before your change.",
12292
+ tests_failed: "Some tests failed. output lists their names, regressions first: a regression passed before your change. For a test you wrote in this run, messages gives the first line of why it failed.",
12290
12293
  timed_out: "The tests did not finish within the time limit and were stopped.",
12291
12294
  no_report: "The test run produced no readable report, so there is nothing to tell you about the tests.",
12292
12295
  no_change_since_last_run: "Nothing has been changed since the last test run; change something first.",
12293
12296
  tests_exhausted: "No test runs are left. Finish with what you have, or say you cannot complete it.",
12294
- no_progress: "The same tests failed as in the last run. Another run would not help; say you cannot complete it if you cannot fix it.",
12297
+ no_progress: "The same tests failed in the same way as in the last run. Another run would not help; say you cannot complete it if you cannot fix it.",
12295
12298
  tests_unavailable: "The tests could not be run here.",
12296
12299
  tests_too_slow: "This project's test suite is too slow to run inside this loop."
12297
12300
  };
12298
12301
  var sha = (s) => (0, import_node_crypto2.createHash)("sha256").update(s).digest("hex");
12302
+ function firstLine(text) {
12303
+ const line = text.split(LINE_BREAK).map((l) => l.replace(CONTROL_CHARS, "").trim()).find((l) => l.length > 0);
12304
+ if (line === void 0) return "";
12305
+ const safe = scrubSecrets(line);
12306
+ return safe.length > MAX_MESSAGE_CHARS ? `${safe.slice(0, MAX_MESSAGE_CHARS - 1)}\u2026` : safe;
12307
+ }
12308
+ var normalisePath = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
12309
+ function samePlace(a, b) {
12310
+ const x = normalisePath(a);
12311
+ const y = normalisePath(b);
12312
+ return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
12313
+ }
12314
+ function ownFailureIds(newFailures, changedPaths, requiredIds) {
12315
+ const own = /* @__PURE__ */ new Set();
12316
+ for (const id of newFailures) {
12317
+ const sep = id.indexOf("::");
12318
+ const file = sep >= 0 ? id.slice(0, sep) : "";
12319
+ const name = sep >= 0 ? id.slice(sep + 2) : id;
12320
+ const inChangedFile = file !== "" && changedPaths.some((p) => samePlace(file, p));
12321
+ const hasToken = requiredIds.some((t) => name.includes(`[${t}]`));
12322
+ if (inChangedFile || hasToken) own.add(id);
12323
+ }
12324
+ return own;
12325
+ }
12299
12326
  function versionOfFiles(files) {
12300
12327
  const h = (0, import_node_crypto2.createHash)("sha256");
12301
12328
  for (const f of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
@@ -12358,6 +12385,8 @@ var RunTestsTool = class {
12358
12385
  failed: entry.failed,
12359
12386
  regressions: entry.regressions,
12360
12387
  newFailures: entry.newFailures,
12388
+ // How many failure messages the AI was shown: a COUNT, never the text.
12389
+ messages: parts.messageCount ?? 0,
12361
12390
  timedOut: entry.timedOut,
12362
12391
  seconds: entry.seconds
12363
12392
  });
@@ -12437,18 +12466,30 @@ var RunTestsTool = class {
12437
12466
  let regressions;
12438
12467
  let newFailures;
12439
12468
  let alreadyFailing;
12469
+ let own = /* @__PURE__ */ new Set();
12470
+ let failureText = /* @__PURE__ */ new Map();
12440
12471
  if (baseline?.snapshot.results) {
12441
12472
  const check = checkForRegressions(baseline.snapshot, after);
12442
12473
  regressions = check.regressions;
12443
12474
  newFailures = check.newFailures;
12444
12475
  alreadyFailing = check.preExisting;
12476
+ own = ownFailureIds(newFailures, files.map((f) => f.path), d.requiredAutomationIds ?? []);
12477
+ failureText = check.failureText;
12445
12478
  } else {
12446
12479
  regressions = [];
12447
12480
  newFailures = [...after.results.entries()].filter(([, ok]) => !ok).map(([id]) => id);
12448
12481
  alreadyFailing = [];
12449
12482
  }
12450
12483
  const ordered = [...regressions, ...newFailures, ...alreadyFailing];
12451
- const names = ordered.slice(0, MAX_LISTED_TESTS).map((n) => scrubSecrets(n).slice(0, MAX_TEST_NAME_CHARS));
12484
+ const listed = ordered.slice(0, MAX_LISTED_TESTS);
12485
+ const names = listed.map((n) => scrubSecrets(n).slice(0, MAX_TEST_NAME_CHARS));
12486
+ const messages = {};
12487
+ listed.forEach((id, i2) => {
12488
+ if (!own.has(id)) return;
12489
+ const line = firstLine(failureText.get(id) ?? "");
12490
+ if (line) messages[names[i2]] = line;
12491
+ });
12492
+ const messageCount = Object.keys(messages).length;
12452
12493
  const output = {
12453
12494
  passed,
12454
12495
  failed,
@@ -12457,18 +12498,20 @@ var RunTestsTool = class {
12457
12498
  newFailures: newFailures.length,
12458
12499
  alreadyFailing: alreadyFailing.length,
12459
12500
  failingTests: names,
12501
+ ...messageCount > 0 ? { messages } : {},
12460
12502
  timedOut: false,
12461
12503
  truncated: ordered.length > names.length
12462
12504
  };
12463
12505
  const counts = { passed, failed, regressions: regressions.length, newFailures: newFailures.length, alreadyFailing: alreadyFailing.length };
12464
12506
  const green = failed === 0 && ran.run.outcome === "success";
12465
- const failingKey = failed > 0 ? sha([...ordered].sort().join("\0")) : null;
12507
+ const messageKey = Object.keys(messages).sort().map((k) => `${k}${messages[k]}`).join("");
12508
+ const failingKey = failed > 0 ? sha(`${[...ordered].sort().join("\0")}${messageKey}`) : null;
12466
12509
  if (!green && failingKey !== null && failingKey === this.lastFailingKey) {
12467
12510
  this.locked = true;
12468
- return this.answer(callId, "no_progress", { output, counts, seconds });
12511
+ return this.answer(callId, "no_progress", { output, counts, seconds, messageCount });
12469
12512
  }
12470
12513
  this.lastFailingKey = failingKey;
12471
- return this.answer(callId, green ? "tests_passed" : "tests_failed", { output, counts, seconds });
12514
+ return this.answer(callId, green ? "tests_passed" : "tests_failed", { output, counts, seconds, messageCount });
12472
12515
  }
12473
12516
  };
12474
12517
  async function executeRunTestsCall(call, tool, ledger, limits) {
@@ -12825,7 +12868,15 @@ async function runCodegenLoop(args, deps) {
12825
12868
  const now = deps.now ?? Date.now;
12826
12869
  const log = deps.log ?? ((e) => console.log(JSON.stringify(e)));
12827
12870
  const filesOnDisk = () => overlay.results().map((r) => ({ path: r.targetPath, content: r.newContent }));
12828
- const tests = args.tests ? new RunTestsTool({ ...args.tests, overlayFiles: filesOnDisk, overlayVersion: () => versionOfFiles(filesOnDisk()), log, now }) : null;
12871
+ const tests = args.tests ? new RunTestsTool({
12872
+ ...args.tests,
12873
+ // The ids of the cases THIS run writes: a failing test named with one is shown to be the run's own (QUIKTR-1541).
12874
+ requiredAutomationIds: args.requiredAutomationIds,
12875
+ overlayFiles: filesOnDisk,
12876
+ overlayVersion: () => versionOfFiles(filesOnDisk()),
12877
+ log,
12878
+ now
12879
+ }) : null;
12829
12880
  let testMs = 0;
12830
12881
  const turnTimeoutMs = deps.turnTimeoutMs ?? 3e5;
12831
12882
  const deadlineMs = deps.deadlineMs ?? 15e5;
@@ -13635,7 +13686,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
13635
13686
  var REPORT_COPY = "final-test-report.xml";
13636
13687
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
13637
13688
  var MAX_FILES = 200;
13638
- var RUNNER_VERSION = true ? "9.3.0-rc.7" : "dev";
13689
+ var RUNNER_VERSION = true ? "9.3.0-rc.8" : "dev";
13639
13690
  function safeDestination(base, repoPath) {
13640
13691
  if (!repoPath || (0, import_node_path12.isAbsolute)(repoPath)) return null;
13641
13692
  const destination = (0, import_node_path12.resolve)(base, repoPath);