@quikit/quikpilot-runner 9.2.0-rc.3 → 9.2.0-rc.5

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
@@ -49,12 +49,19 @@ over several short turns the AI may use five tools, the three read-only ones abo
49
49
  text in an existing file; the text must match exactly one place) and `write_file` (create a new file). Every change is held in
50
50
  memory and nothing is written to the checkout until the AI says it is finished, and then the result goes through exactly the
51
51
  checks a one-file-at-a-time run goes through (scope, overlap, test placement, format, lint, the regression gate, the
52
- coverage check, protected paths). A test file that already existed may only be added to: an edit must keep the original text
53
- and put the new text before or after it, so a test is never weakened to make code pass. The AI cannot finish before it has
52
+ coverage check, protected paths). A test file that already existed may only be added to: every character of the matched text
53
+ must stay, in the same order, and the only change is one block of whole new lines that declares a new test (`it`, `test` or
54
+ `describe`) or new `import` lines, placed before the matched text, after it or between two of its lines (JavaScript and
55
+ TypeScript files; other languages keep the older rule of new text before or after the match). Anything else is answered
56
+ `protected`, an ordinary result the AI reads and tries again from, so a test is never weakened to make code pass. Before its first turn the loop is shown the files the plan named for each target and the files each existing target imports
57
+ (one hop, JavaScript and TypeScript, the same scan and the same limits as the one-file-at-a-time path: 40,000 characters a file
58
+ and 60,000 in all, never a denied path, never the targets themselves), so the project's own names, values and rates are in front
59
+ of it instead of being guessed; the run's context record lists them like the one-file path's. The AI cannot finish before it has
54
60
  changed something and written a test for every case it was given. If the loop cannot finish for an ordinary reason (an
55
61
  older runtime, a timeout, a refused edit it cannot recover from, a cut-short file) everything it held is thrown away and the
56
- files are written one at a time, and the run's warnings say so; a protected path, a budget or credential refusal is never
57
- retried. Limits are told to the AI as ordinary answers: 20 turns, 40 actions, 60,000 characters read, 120,000 written, and the
62
+ files are written one at a time, and the run's warnings say so. A budget or credential refusal from the AI Runtime is never
63
+ retried (the one-at-a-time attempt would be refused again or paid for twice). A protected path is refused to the AI as an
64
+ ordinary answer, never read, listed or written, and the run carries on. Limits are told to the AI as ordinary answers: 20 turns, 40 actions, 60,000 characters read, 120,000 written, and the
58
65
  same 90,000-token ceiling per turn. The callback gains an optional `codegenLoop` record (paths, counts, statuses and the AI's
59
66
  short note per step; never file text) that QuikProjects shows as "What QuikPilot did". Without the variable nothing
60
67
  changes. The workflow file is unchanged; the `env:` line is the only edit, and it is optional. The AI Runtime must have
package/dist/index.js CHANGED
@@ -1218,6 +1218,163 @@ function buildCodegenLoopRecord(loop) {
1218
1218
  };
1219
1219
  }
1220
1220
 
1221
+ // src/codegenLoopContext.ts
1222
+ var import_node_fs2 = require("node:fs");
1223
+ function collectLoopContext(p) {
1224
+ const readFile = p.readFile ?? ((path) => (0, import_node_fs2.readFileSync)(path, "utf8"));
1225
+ const listing = new Set(p.listing);
1226
+ const targetPaths = new Set(p.targets.map((t) => t.path));
1227
+ const seen = new Set(targetPaths);
1228
+ const entries = [];
1229
+ const records = [];
1230
+ let total = 0;
1231
+ for (const target of p.targets) {
1232
+ const named = target.contextPaths ?? [];
1233
+ const added = [];
1234
+ const skipped = [];
1235
+ for (const path of named) {
1236
+ if (seen.has(path)) continue;
1237
+ seen.add(path);
1238
+ if (matchesDeniedPath(path, p.deniedPaths)) {
1239
+ skipped.push({ path, reason: "denied" });
1240
+ continue;
1241
+ }
1242
+ if (!listing.has(path)) {
1243
+ skipped.push({ path, reason: "not in workspace" });
1244
+ continue;
1245
+ }
1246
+ let content;
1247
+ try {
1248
+ content = readFile(path);
1249
+ } catch {
1250
+ skipped.push({ path, reason: "unreadable" });
1251
+ continue;
1252
+ }
1253
+ if (content.length > MAX_ADDED_FILE_CHARS) skipped.push({ path, reason: "too large" });
1254
+ else if (total + content.length > MAX_ADDED_CONTEXT_CHARS) skipped.push({ path, reason: "over budget" });
1255
+ else {
1256
+ entries.push({ path, content });
1257
+ added.push(path);
1258
+ total += content.length;
1259
+ }
1260
+ }
1261
+ let importedPaths = [];
1262
+ let aliasImports = 0;
1263
+ if (target.kind === "EXISTING") {
1264
+ let source = null;
1265
+ try {
1266
+ source = readFile(target.path);
1267
+ } catch {
1268
+ skipped.push({ path: target.path, reason: "import: unreadable" });
1269
+ }
1270
+ if (source !== null) {
1271
+ const imports = collectImportContext({
1272
+ targetPath: target.path,
1273
+ source,
1274
+ alreadyNamed: seen,
1275
+ deniedPaths: p.deniedPaths,
1276
+ listing,
1277
+ readFile,
1278
+ maxFileChars: MAX_ADDED_FILE_CHARS,
1279
+ maxTotalChars: MAX_ADDED_CONTEXT_CHARS,
1280
+ spentChars: total
1281
+ });
1282
+ for (const e of imports.entries) {
1283
+ entries.push(e);
1284
+ added.push(e.path);
1285
+ seen.add(e.path);
1286
+ total += e.content.length;
1287
+ }
1288
+ skipped.push(...imports.skipped);
1289
+ importedPaths = imports.importedPaths;
1290
+ aliasImports = imports.aliasImports;
1291
+ }
1292
+ }
1293
+ records.push({
1294
+ targetPath: target.path,
1295
+ contextPaths: named,
1296
+ addedPaths: added,
1297
+ skipped,
1298
+ ...importedPaths.length > 0 ? { importedPaths } : {},
1299
+ ...aliasImports > 0 ? { aliasImports } : {}
1300
+ });
1301
+ }
1302
+ return { entries, records };
1303
+ }
1304
+
1305
+ // src/addOnly.ts
1306
+ var JS_FAMILY = /\.(?:[cm]?[jt]sx?)$/i;
1307
+ var DECLARES_TEST = /^[ \t]*(?:it|test|describe)\b/m;
1308
+ var IMPORT_LINE = /^\s*import\b/;
1309
+ function usesLooseRule(path) {
1310
+ return JS_FAMILY.test(path);
1311
+ }
1312
+ function bracketsBalance(text) {
1313
+ const stack = [];
1314
+ const pairs = { ")": "(", "]": "[", "}": "{" };
1315
+ let i = 0;
1316
+ while (i < text.length) {
1317
+ const c = text[i];
1318
+ const next = text[i + 1];
1319
+ if (c === "/" && next === "/") {
1320
+ const nl = text.indexOf("\n", i);
1321
+ i = nl === -1 ? text.length : nl + 1;
1322
+ continue;
1323
+ }
1324
+ if (c === "/" && next === "*") {
1325
+ const end = text.indexOf("*/", i + 2);
1326
+ if (end === -1) return false;
1327
+ i = end + 2;
1328
+ continue;
1329
+ }
1330
+ if (c === '"' || c === "'" || c === "`") {
1331
+ let j = i + 1;
1332
+ while (j < text.length && text[j] !== c) {
1333
+ if (text[j] === "\\") j++;
1334
+ if (c !== "`" && text[j] === "\n") return false;
1335
+ j++;
1336
+ }
1337
+ if (j >= text.length) return false;
1338
+ i = j + 1;
1339
+ continue;
1340
+ }
1341
+ if (c === "(" || c === "[" || c === "{") stack.push(c);
1342
+ else if (c === ")" || c === "]" || c === "}") {
1343
+ if (stack.pop() !== pairs[c]) return false;
1344
+ }
1345
+ i++;
1346
+ }
1347
+ return stack.length === 0;
1348
+ }
1349
+ function onlyImports(text) {
1350
+ const lines = text.split("\n").filter((l) => l.trim().length > 0);
1351
+ return lines.length > 0 && lines.every((l) => IMPORT_LINE.test(l));
1352
+ }
1353
+ function isNewTestCode(added) {
1354
+ return DECLARES_TEST.test(added) && bracketsBalance(added) || onlyImports(added);
1355
+ }
1356
+ function placementOk(find, k, added) {
1357
+ if (added === "") return true;
1358
+ const wholeLines = k === 0 ? added.endsWith("\n") : k === find.length ? find.endsWith("\n") || added.startsWith("\n") : find[k - 1] === "\n" && added.endsWith("\n");
1359
+ return wholeLines && isNewTestCode(added);
1360
+ }
1361
+ function strictEndsRule(find, replace) {
1362
+ return replace.startsWith(find) || replace.endsWith(find);
1363
+ }
1364
+ function isAddOnly(path, find, replace) {
1365
+ if (replace === find) return true;
1366
+ if (!usesLooseRule(path)) return strictEndsRule(find, replace);
1367
+ if (replace.length <= find.length) return false;
1368
+ const addedLength = replace.length - find.length;
1369
+ let common = 0;
1370
+ while (common < find.length && find.charCodeAt(common) === replace.charCodeAt(common)) common++;
1371
+ for (let k = common; k >= 0; k--) {
1372
+ if (!replace.endsWith(find.slice(k))) continue;
1373
+ if (placementOk(find, k, replace.slice(k, k + addedLength))) return true;
1374
+ }
1375
+ return false;
1376
+ }
1377
+
1221
1378
  // src/targetingPaths.ts
1222
1379
  var import_node_path3 = require("node:path");
1223
1380
  var MAX_PATH_CHARS = 300;
@@ -1253,7 +1410,7 @@ function buildVisibleListing(listing, deniedPaths) {
1253
1410
  }
1254
1411
 
1255
1412
  // src/targetingTools.ts
1256
- var import_node_fs2 = require("node:fs");
1413
+ var import_node_fs3 = require("node:fs");
1257
1414
  var import_node_path4 = require("node:path");
1258
1415
  var DEFAULT_LIMITS = {
1259
1416
  maxTurns: 12,
@@ -1278,20 +1435,20 @@ var DEFAULT_LIMITS = {
1278
1435
  maxPatternChars: 200
1279
1436
  };
1280
1437
  function createNodeToolFs(rootDir = process.cwd()) {
1281
- const rootReal = (0, import_node_fs2.realpathSync)(rootDir);
1438
+ const rootReal = (0, import_node_fs3.realpathSync)(rootDir);
1282
1439
  return {
1283
1440
  rootReal,
1284
1441
  lstat(rel) {
1285
- const s = (0, import_node_fs2.lstatSync)((0, import_node_path4.join)(rootDir, rel));
1442
+ const s = (0, import_node_fs3.lstatSync)((0, import_node_path4.join)(rootDir, rel));
1286
1443
  return { isSymlink: s.isSymbolicLink(), isFile: s.isFile(), size: s.size };
1287
1444
  },
1288
1445
  realpathInside(rel) {
1289
- const real = (0, import_node_fs2.realpathSync)((0, import_node_path4.join)(rootDir, rel));
1446
+ const real = (0, import_node_fs3.realpathSync)((0, import_node_path4.join)(rootDir, rel));
1290
1447
  const r = (0, import_node_path4.relative)(rootReal, real);
1291
1448
  return r !== "" && !r.startsWith("..") && !(0, import_node_path4.isAbsolute)(r);
1292
1449
  },
1293
1450
  readBytes(rel) {
1294
- return (0, import_node_fs2.readFileSync)((0, import_node_path4.join)(rootDir, rel));
1451
+ return (0, import_node_fs3.readFileSync)((0, import_node_path4.join)(rootDir, rel));
1295
1452
  }
1296
1453
  };
1297
1454
  }
@@ -1592,7 +1749,7 @@ function executeToolCall(call, env2, ledger) {
1592
1749
  }
1593
1750
 
1594
1751
  // src/workspaceOverlay.ts
1595
- var import_node_fs3 = require("node:fs");
1752
+ var import_node_fs4 = require("node:fs");
1596
1753
  var import_node_path5 = require("node:path");
1597
1754
  function createNodeWriteFs(rootDir = process.cwd()) {
1598
1755
  const base = createNodeToolFs(rootDir);
@@ -1606,7 +1763,7 @@ function createNodeWriteFs(rootDir = process.cwd()) {
1606
1763
  let dir = (0, import_node_path5.dirname)((0, import_node_path5.join)(rootDir, rel));
1607
1764
  for (; ; ) {
1608
1765
  try {
1609
- return inside((0, import_node_fs3.realpathSync)(dir));
1766
+ return inside((0, import_node_fs4.realpathSync)(dir));
1610
1767
  } catch {
1611
1768
  const up = (0, import_node_path5.dirname)(dir);
1612
1769
  if (up === dir) return false;
@@ -1616,7 +1773,7 @@ function createNodeWriteFs(rootDir = process.cwd()) {
1616
1773
  },
1617
1774
  exists(rel) {
1618
1775
  try {
1619
- (0, import_node_fs3.lstatSync)((0, import_node_path5.join)(rootDir, rel));
1776
+ (0, import_node_fs4.lstatSync)((0, import_node_path5.join)(rootDir, rel));
1620
1777
  return true;
1621
1778
  } catch {
1622
1779
  return false;
@@ -1804,8 +1961,14 @@ function createCodegenWorkspace(args) {
1804
1961
  lf = loaded.lf;
1805
1962
  base = { ending: loaded.ending, bom: loaded.bom, originalLf: loaded.lf };
1806
1963
  }
1807
- if (protectedTests.has(path) && !(replace.startsWith(find) || replace.endsWith(find))) {
1808
- return { result: { status: "protected", reason: "existing_test", message: "An existing test can only be added to: keep the anchor text and add new text before or after it." } };
1964
+ if (protectedTests.has(path) && !isAddOnly(path, find, replace)) {
1965
+ return {
1966
+ result: {
1967
+ status: "protected",
1968
+ reason: "existing_test",
1969
+ message: "An existing test can only be added to. Keep every character of the text you matched, in the same order, and add only whole new lines that declare a new test (it, test or describe), before the text, after it, or between two of its lines. To add a test to a block, match the last lines of that block and put the new test after them."
1970
+ }
1971
+ };
1809
1972
  }
1810
1973
  const applied = applyEdits(lf, [{ find, replace }]);
1811
1974
  if (!applied.ok) {
@@ -2538,7 +2701,7 @@ function protectedTestFiles(listing, testDiscovery) {
2538
2701
  }
2539
2702
  return [...found].sort();
2540
2703
  }
2541
- function buildCodegenLoopArgs(p) {
2704
+ function buildCodegenLoopArgs(p, context = collectLoopContext({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, ...p.readFile ? { readFile: p.readFile } : {} })) {
2542
2705
  const skipped = new Set(p.skippedCases.map((s) => s.automationId));
2543
2706
  const claimed = /* @__PURE__ */ new Set();
2544
2707
  for (const t of p.targets) for (const id of t.automationIds ?? []) if (!skipped.has(id)) claimed.add(id);
@@ -2555,6 +2718,7 @@ function buildCodegenLoopArgs(p) {
2555
2718
  requiredTests,
2556
2719
  workspaceListing: p.workspaceListing
2557
2720
  };
2721
+ if (context.entries.length > 0) baseContext.contextContents = context.entries;
2558
2722
  if (p.deniedPaths.length > 0) baseContext.deniedPaths = p.deniedPaths;
2559
2723
  if (protectedTestPaths.length > 0) baseContext.protectedTestPaths = protectedTestPaths.slice(0, MAX_PROTECTED_PATHS_ON_WIRE);
2560
2724
  if (p.outOfScope.length > 0) baseContext.outOfScope = p.outOfScope;
@@ -2593,8 +2757,18 @@ function perFile(p) {
2593
2757
  }
2594
2758
  async function runCodegenStep(p) {
2595
2759
  if (p.mode !== "loop") return perFile(p);
2760
+ const context = collectLoopContext({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, ...p.readFile ? { readFile: p.readFile } : {} });
2761
+ p.contextLog.push(...context.records);
2762
+ console.log(
2763
+ JSON.stringify({
2764
+ event: "codegen.loop_context",
2765
+ files: context.entries.length,
2766
+ chars: context.entries.reduce((n, e) => n + e.content.length, 0),
2767
+ paths: context.entries.map((e) => e.path)
2768
+ })
2769
+ );
2596
2770
  try {
2597
- const { results, summary } = await runCodegenLoop(buildCodegenLoopArgs(p), {
2771
+ const { results, summary } = await runCodegenLoop(buildCodegenLoopArgs(p, context), {
2598
2772
  post: (contextData, signal) => postCodegenTurn(p.gateway, contextData, signal),
2599
2773
  ...p.deps
2600
2774
  });
@@ -2626,7 +2800,7 @@ async function runCodegenStep(p) {
2626
2800
  }
2627
2801
 
2628
2802
  // src/dependencyCheck.ts
2629
- var import_node_fs4 = require("node:fs");
2803
+ var import_node_fs5 = require("node:fs");
2630
2804
  var import_node_path6 = require("node:path");
2631
2805
  var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
2632
2806
  var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
@@ -2713,7 +2887,7 @@ function readDeclaredDependencies(results, workspaceRoot) {
2713
2887
  raw = generated.newContent;
2714
2888
  } else {
2715
2889
  try {
2716
- raw = (0, import_node_fs4.readFileSync)(packageJsonPath, "utf8");
2890
+ raw = (0, import_node_fs5.readFileSync)(packageJsonPath, "utf8");
2717
2891
  } catch {
2718
2892
  raw = null;
2719
2893
  }
@@ -2786,7 +2960,7 @@ function resolveAliasPrefixes(results, workspaceRoot) {
2786
2960
  raw = generated.newContent;
2787
2961
  } else {
2788
2962
  try {
2789
- raw = (0, import_node_fs4.readFileSync)(configPath, "utf8");
2963
+ raw = (0, import_node_fs5.readFileSync)(configPath, "utf8");
2790
2964
  } catch {
2791
2965
  raw = null;
2792
2966
  }
@@ -2876,21 +3050,21 @@ async function fetchPacket(packetUrl, runToken, githubRunId) {
2876
3050
  }
2877
3051
 
2878
3052
  // src/phase0.ts
2879
- var import_node_fs5 = require("node:fs");
3053
+ var import_node_fs6 = require("node:fs");
2880
3054
  function writePhase0Marker(runId) {
2881
- (0, import_node_fs5.mkdirSync)(".quikpilot", { recursive: true });
2882
- (0, import_node_fs5.appendFileSync)(".quikpilot/phase0-marker.txt", `QuikPilot Phase 0 skeleton marker for run ${runId}
3055
+ (0, import_node_fs6.mkdirSync)(".quikpilot", { recursive: true });
3056
+ (0, import_node_fs6.appendFileSync)(".quikpilot/phase0-marker.txt", `QuikPilot Phase 0 skeleton marker for run ${runId}
2883
3057
  `);
2884
3058
  }
2885
3059
 
2886
3060
  // src/quiktest.ts
2887
- var import_node_fs6 = require("node:fs");
3061
+ var import_node_fs7 = require("node:fs");
2888
3062
  var import_node_path7 = require("node:path");
2889
3063
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
2890
3064
  function walkForJUnitByName(dir) {
2891
3065
  let entries;
2892
3066
  try {
2893
- entries = (0, import_node_fs6.readdirSync)(dir);
3067
+ entries = (0, import_node_fs7.readdirSync)(dir);
2894
3068
  } catch {
2895
3069
  return null;
2896
3070
  }
@@ -2899,7 +3073,7 @@ function walkForJUnitByName(dir) {
2899
3073
  const full = (0, import_node_path7.join)(dir, entry);
2900
3074
  let stat;
2901
3075
  try {
2902
- stat = (0, import_node_fs6.statSync)(full);
3076
+ stat = (0, import_node_fs7.statSync)(full);
2903
3077
  } catch {
2904
3078
  continue;
2905
3079
  }
@@ -2915,7 +3089,7 @@ function walkForJUnitByName(dir) {
2915
3089
  function firstXmlIn(dir, namePattern) {
2916
3090
  let entries;
2917
3091
  try {
2918
- entries = (0, import_node_fs6.readdirSync)(dir);
3092
+ entries = (0, import_node_fs7.readdirSync)(dir);
2919
3093
  } catch {
2920
3094
  return null;
2921
3095
  }
@@ -2925,7 +3099,7 @@ function firstXmlIn(dir, namePattern) {
2925
3099
  function readTestReportBytes(cwd = process.cwd()) {
2926
3100
  try {
2927
3101
  const report = findJUnitReport(cwd);
2928
- return report ? (0, import_node_fs6.readFileSync)(report) : null;
3102
+ return report ? (0, import_node_fs7.readFileSync)(report) : null;
2929
3103
  } catch {
2930
3104
  return null;
2931
3105
  }
@@ -2955,8 +3129,8 @@ async function reportToQuikTest(params) {
2955
3129
  try {
2956
3130
  console.log(`reporting ${report}`);
2957
3131
  const ciUrl = buildCiUrl(githubServerUrl, githubRepository, githubRunId);
2958
- const { readFileSync: readFileSync8 } = await import("node:fs");
2959
- const body = readFileSync8(report);
3132
+ const { readFileSync: readFileSync9 } = await import("node:fs");
3133
+ const body = readFileSync9(report);
2960
3134
  let url = `${resultsUrl}?ciUrl=${encodeURIComponent(ciUrl)}&automationIdFormat=bracket`;
2961
3135
  if (generatedFiles) {
2962
3136
  url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
@@ -2969,7 +3143,7 @@ async function reportToQuikTest(params) {
2969
3143
  if (!res.ok) {
2970
3144
  throw new Error(`QuikTest report POST failed: ${res.status} ${res.statusText}`);
2971
3145
  }
2972
- (0, import_node_fs6.rmSync)(report, { force: true });
3146
+ (0, import_node_fs7.rmSync)(report, { force: true });
2973
3147
  let unmatched = [];
2974
3148
  try {
2975
3149
  const json = await res.json();
@@ -2985,11 +3159,11 @@ async function reportToQuikTest(params) {
2985
3159
 
2986
3160
  // src/baselineCheck.ts
2987
3161
  var import_node_child_process3 = require("node:child_process");
2988
- var import_node_fs8 = require("node:fs");
3162
+ var import_node_fs9 = require("node:fs");
2989
3163
  var import_node_path8 = require("node:path");
2990
3164
 
2991
3165
  // src/regressionCheck.ts
2992
- var import_node_fs7 = require("node:fs");
3166
+ var import_node_fs8 = require("node:fs");
2993
3167
  var TESTCASE_RE = /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g;
2994
3168
  var NAME_ATTR_RE = /\bname="([^"]*)"/;
2995
3169
  var CLASSNAME_ATTR_RE = /\bclassname="([^"]*)"/;
@@ -3075,7 +3249,7 @@ function readJUnitOutcomes(cwd) {
3075
3249
  const report = findJUnitReport(cwd);
3076
3250
  if (!report) return null;
3077
3251
  try {
3078
- return parseJUnitOutcomes((0, import_node_fs7.readFileSync)(report, "utf8"));
3252
+ return parseJUnitOutcomes((0, import_node_fs8.readFileSync)(report, "utf8"));
3079
3253
  } catch {
3080
3254
  return null;
3081
3255
  }
@@ -3177,27 +3351,27 @@ function insideCheckout(cwd, path) {
3177
3351
  return rel === "" || rel.startsWith("..") || (0, import_node_path8.isAbsolute)(rel) ? null : abs;
3178
3352
  }
3179
3353
  function writeForCheck(abs, content) {
3180
- const original = (0, import_node_fs8.existsSync)(abs) ? (0, import_node_fs8.readFileSync)(abs) : null;
3354
+ const original = (0, import_node_fs9.existsSync)(abs) ? (0, import_node_fs9.readFileSync)(abs) : null;
3181
3355
  const createdDirs = [];
3182
3356
  if (original === null) {
3183
3357
  const missing = [];
3184
- for (let d = (0, import_node_path8.dirname)(abs); !(0, import_node_fs8.existsSync)(d); d = (0, import_node_path8.dirname)(d)) missing.push(d);
3358
+ for (let d = (0, import_node_path8.dirname)(abs); !(0, import_node_fs9.existsSync)(d); d = (0, import_node_path8.dirname)(d)) missing.push(d);
3185
3359
  for (const d of missing.reverse()) {
3186
- (0, import_node_fs8.mkdirSync)(d);
3360
+ (0, import_node_fs9.mkdirSync)(d);
3187
3361
  createdDirs.push(d);
3188
3362
  }
3189
3363
  }
3190
- (0, import_node_fs8.writeFileSync)(abs, content);
3364
+ (0, import_node_fs9.writeFileSync)(abs, content);
3191
3365
  return { abs, original, createdDirs };
3192
3366
  }
3193
3367
  function restore(written) {
3194
3368
  for (const file of [...written].reverse()) {
3195
3369
  try {
3196
- if (file.original !== null) (0, import_node_fs8.writeFileSync)(file.abs, file.original);
3197
- else (0, import_node_fs8.rmSync)(file.abs, { force: true });
3370
+ if (file.original !== null) (0, import_node_fs9.writeFileSync)(file.abs, file.original);
3371
+ else (0, import_node_fs9.rmSync)(file.abs, { force: true });
3198
3372
  for (const d of [...file.createdDirs].reverse()) {
3199
3373
  try {
3200
- (0, import_node_fs8.rmdirSync)(d);
3374
+ (0, import_node_fs9.rmdirSync)(d);
3201
3375
  } catch {
3202
3376
  }
3203
3377
  }
@@ -3221,7 +3395,7 @@ function untrackedFiles(cwd) {
3221
3395
  }
3222
3396
  var mtimeOf = (path) => {
3223
3397
  try {
3224
- return (0, import_node_fs8.statSync)(path).mtimeMs;
3398
+ return (0, import_node_fs9.statSync)(path).mtimeMs;
3225
3399
  } catch {
3226
3400
  return null;
3227
3401
  }
@@ -3235,7 +3409,7 @@ function decideCause(targets, results, cwd) {
3235
3409
  const abs = insideCheckout(cwd, t.path);
3236
3410
  if (next === void 0 || abs === null) return "ALREADY_TRUE";
3237
3411
  try {
3238
- if ((0, import_node_fs8.readFileSync)(abs, "utf8") !== next) return "ALREADY_TRUE";
3412
+ if ((0, import_node_fs9.readFileSync)(abs, "utf8") !== next) return "ALREADY_TRUE";
3239
3413
  } catch {
3240
3414
  return "ALREADY_TRUE";
3241
3415
  }
@@ -3311,7 +3485,7 @@ async function runBaselineCheck(params) {
3311
3485
  for (const file of untrackedAfter) {
3312
3486
  if (untrackedBefore.has(file)) continue;
3313
3487
  const abs = insideCheckout(cwd, file);
3314
- if (abs) (0, import_node_fs8.rmSync)(abs, { force: true });
3488
+ if (abs) (0, import_node_fs9.rmSync)(abs, { force: true });
3315
3489
  }
3316
3490
  }
3317
3491
  }
@@ -3332,7 +3506,7 @@ async function runBaselineCheck(params) {
3332
3506
  }
3333
3507
 
3334
3508
  // src/failureArtifact.ts
3335
- var import_node_fs9 = require("node:fs");
3509
+ var import_node_fs10 = require("node:fs");
3336
3510
  var import_node_path9 = require("node:path");
3337
3511
 
3338
3512
  // src/failureReason.ts
@@ -3374,7 +3548,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
3374
3548
  var REPORT_COPY = "final-test-report.xml";
3375
3549
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
3376
3550
  var MAX_FILES = 200;
3377
- var RUNNER_VERSION = true ? "9.2.0-rc.3" : "dev";
3551
+ var RUNNER_VERSION = true ? "9.2.0-rc.5" : "dev";
3378
3552
  function safeDestination(base, repoPath) {
3379
3553
  if (!repoPath || (0, import_node_path9.isAbsolute)(repoPath)) return null;
3380
3554
  const destination = (0, import_node_path9.resolve)(base, repoPath);
@@ -3386,8 +3560,8 @@ function writeFailureArtifact(input) {
3386
3560
  if (input.results.length === 0) return { written: false };
3387
3561
  try {
3388
3562
  const base = (0, import_node_path9.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
3389
- (0, import_node_fs9.rmSync)(base, { recursive: true, force: true });
3390
- (0, import_node_fs9.mkdirSync)(base, { recursive: true });
3563
+ (0, import_node_fs10.rmSync)(base, { recursive: true, force: true });
3564
+ (0, import_node_fs10.mkdirSync)(base, { recursive: true });
3391
3565
  const files = [];
3392
3566
  const skipped = [];
3393
3567
  for (const result of input.results) {
@@ -3396,8 +3570,8 @@ function writeFailureArtifact(input) {
3396
3570
  skipped.push(result.targetPath);
3397
3571
  continue;
3398
3572
  }
3399
- (0, import_node_fs9.mkdirSync)((0, import_node_path9.dirname)(destination), { recursive: true });
3400
- (0, import_node_fs9.writeFileSync)(destination, result.newContent);
3573
+ (0, import_node_fs10.mkdirSync)((0, import_node_path9.dirname)(destination), { recursive: true });
3574
+ (0, import_node_fs10.writeFileSync)(destination, result.newContent);
3401
3575
  files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
3402
3576
  }
3403
3577
  let testReport = "none";
@@ -3405,7 +3579,7 @@ function writeFailureArtifact(input) {
3405
3579
  if (input.testReport.byteLength > MAX_REPORT_BYTES) {
3406
3580
  testReport = "too-large";
3407
3581
  } else {
3408
- (0, import_node_fs9.writeFileSync)((0, import_node_path9.join)(base, REPORT_COPY), input.testReport);
3582
+ (0, import_node_fs10.writeFileSync)((0, import_node_path9.join)(base, REPORT_COPY), input.testReport);
3409
3583
  testReport = "included";
3410
3584
  }
3411
3585
  }
@@ -3425,8 +3599,8 @@ function writeFailureArtifact(input) {
3425
3599
  failureReasons: input.failureReasons
3426
3600
  };
3427
3601
  const text = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
3428
- (0, import_node_fs9.writeFileSync)((0, import_node_path9.join)(base, "manifest.json"), text);
3429
- return { written: (0, import_node_fs9.existsSync)((0, import_node_path9.join)(base, "manifest.json")) };
3602
+ (0, import_node_fs10.writeFileSync)((0, import_node_path9.join)(base, "manifest.json"), text);
3603
+ return { written: (0, import_node_fs10.existsSync)((0, import_node_path9.join)(base, "manifest.json")) };
3430
3604
  } catch (err) {
3431
3605
  console.warn(`::warning::Could not keep the failed run's files: ${err instanceof Error ? err.message : String(err)}`);
3432
3606
  return { written: false };
@@ -3434,7 +3608,7 @@ function writeFailureArtifact(input) {
3434
3608
  }
3435
3609
 
3436
3610
  // src/scopeCheck.ts
3437
- var import_node_fs10 = require("node:fs");
3611
+ var import_node_fs11 = require("node:fs");
3438
3612
  var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
3439
3613
  var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
3440
3614
  var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
@@ -3491,7 +3665,7 @@ function checkApiScope(results, targets, apiChanges) {
3491
3665
  } else {
3492
3666
  let currentContent;
3493
3667
  try {
3494
- currentContent = (0, import_node_fs10.readFileSync)(targetPath, "utf8");
3668
+ currentContent = (0, import_node_fs11.readFileSync)(targetPath, "utf8");
3495
3669
  } catch {
3496
3670
  currentContent = "";
3497
3671
  }