@quikit/quikpilot-runner 9.2.0-rc.4 → 9.2.0-rc.6
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 +4 -1
- package/dist/index.js +304 -150
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1218,6 +1218,250 @@ function buildCodegenLoopRecord(loop) {
|
|
|
1218
1218
|
};
|
|
1219
1219
|
}
|
|
1220
1220
|
|
|
1221
|
+
// src/codegenLoopContext.ts
|
|
1222
|
+
var import_node_fs2 = require("node:fs");
|
|
1223
|
+
|
|
1224
|
+
// src/overlapCheck.ts
|
|
1225
|
+
var TEST_PATH_RE = /(\.(test|spec)\.[jt]sx?$)|(^|\/)(__tests__|tests?)\//i;
|
|
1226
|
+
function isTestTarget(path) {
|
|
1227
|
+
return TEST_PATH_RE.test(path);
|
|
1228
|
+
}
|
|
1229
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
1230
|
+
"a",
|
|
1231
|
+
"an",
|
|
1232
|
+
"the",
|
|
1233
|
+
"is",
|
|
1234
|
+
"are",
|
|
1235
|
+
"was",
|
|
1236
|
+
"were",
|
|
1237
|
+
"be",
|
|
1238
|
+
"been",
|
|
1239
|
+
"being",
|
|
1240
|
+
"of",
|
|
1241
|
+
"to",
|
|
1242
|
+
"in",
|
|
1243
|
+
"on",
|
|
1244
|
+
"for",
|
|
1245
|
+
"with",
|
|
1246
|
+
"at",
|
|
1247
|
+
"by",
|
|
1248
|
+
"from",
|
|
1249
|
+
"as",
|
|
1250
|
+
"and",
|
|
1251
|
+
"or",
|
|
1252
|
+
"not",
|
|
1253
|
+
"no",
|
|
1254
|
+
"nor",
|
|
1255
|
+
"this",
|
|
1256
|
+
"that",
|
|
1257
|
+
"these",
|
|
1258
|
+
"those",
|
|
1259
|
+
"it",
|
|
1260
|
+
"its",
|
|
1261
|
+
"cannot",
|
|
1262
|
+
"can't",
|
|
1263
|
+
"should",
|
|
1264
|
+
"must",
|
|
1265
|
+
"may",
|
|
1266
|
+
"will",
|
|
1267
|
+
"shall",
|
|
1268
|
+
"when",
|
|
1269
|
+
"if",
|
|
1270
|
+
"than",
|
|
1271
|
+
"then",
|
|
1272
|
+
"so",
|
|
1273
|
+
"do",
|
|
1274
|
+
"does",
|
|
1275
|
+
"did"
|
|
1276
|
+
]);
|
|
1277
|
+
var MIN_WORD_LENGTH = 3;
|
|
1278
|
+
function significantWords(step) {
|
|
1279
|
+
return new Set(
|
|
1280
|
+
step.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter((w) => w.length >= MIN_WORD_LENGTH && !STOPWORDS.has(w))
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1283
|
+
function jaccard(a, b) {
|
|
1284
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
1285
|
+
let intersection = 0;
|
|
1286
|
+
for (const w of a) if (b.has(w)) intersection++;
|
|
1287
|
+
const union = a.size + b.size - intersection;
|
|
1288
|
+
return intersection / union;
|
|
1289
|
+
}
|
|
1290
|
+
function normalizedStep(step) {
|
|
1291
|
+
return step.trim().toLowerCase().replace(/\s+/g, " ");
|
|
1292
|
+
}
|
|
1293
|
+
var OVERLAP_THRESHOLD = 0.5;
|
|
1294
|
+
function findOverlappingSteps(targets) {
|
|
1295
|
+
const items = targets.flatMap(
|
|
1296
|
+
(target) => target.planStepsImplemented.map((step) => ({
|
|
1297
|
+
target: target.path,
|
|
1298
|
+
step,
|
|
1299
|
+
words: significantWords(step)
|
|
1300
|
+
}))
|
|
1301
|
+
);
|
|
1302
|
+
const warnings = [];
|
|
1303
|
+
for (let i = 0; i < items.length; i++) {
|
|
1304
|
+
for (let j = i + 1; j < items.length; j++) {
|
|
1305
|
+
if (items[i].target === items[j].target) continue;
|
|
1306
|
+
if (isTestTarget(items[i].target) || isTestTarget(items[j].target)) continue;
|
|
1307
|
+
if (jaccard(items[i].words, items[j].words) >= OVERLAP_THRESHOLD) {
|
|
1308
|
+
warnings.push({
|
|
1309
|
+
targetA: items[i].target,
|
|
1310
|
+
stepA: items[i].step,
|
|
1311
|
+
targetB: items[j].target,
|
|
1312
|
+
stepB: items[j].step,
|
|
1313
|
+
severity: normalizedStep(items[i].step) === normalizedStep(items[j].step) ? "identical" : "similar"
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return warnings;
|
|
1319
|
+
}
|
|
1320
|
+
function describeOverlapWarnings(warnings) {
|
|
1321
|
+
return warnings.map(
|
|
1322
|
+
(w) => `${w.targetA} and ${w.targetB} both implement what looks like the same rule \u2014 "${w.stepA}" / "${w.stepB}". Check these aren't two independent implementations of the same behavior.`
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// src/codegenLoopContext.ts
|
|
1327
|
+
var TEST_NAME_RE = /^(.+)\.(?:test|spec)\.[cm]?[jt]sx?$/i;
|
|
1328
|
+
var CODE_NAME_RE = /^(.+)\.[cm]?[jt]sx?$/i;
|
|
1329
|
+
function dirOf(path) {
|
|
1330
|
+
const i = path.lastIndexOf("/");
|
|
1331
|
+
return i === -1 ? "" : path.slice(0, i);
|
|
1332
|
+
}
|
|
1333
|
+
function baseOf(path) {
|
|
1334
|
+
return path.slice(path.lastIndexOf("/") + 1);
|
|
1335
|
+
}
|
|
1336
|
+
function parentOf(dir) {
|
|
1337
|
+
return dir === "" ? "" : dirOf(dir);
|
|
1338
|
+
}
|
|
1339
|
+
function pairedTestPaths(codePath, listing) {
|
|
1340
|
+
if (isTestTarget(codePath)) return [];
|
|
1341
|
+
const m = CODE_NAME_RE.exec(baseOf(codePath));
|
|
1342
|
+
if (!m) return [];
|
|
1343
|
+
const stem = m[1].toLowerCase();
|
|
1344
|
+
const dir = dirOf(codePath);
|
|
1345
|
+
const parent = parentOf(dir);
|
|
1346
|
+
const join6 = (d, leaf) => d === "" ? leaf : `${d}/${leaf}`;
|
|
1347
|
+
const homes = /* @__PURE__ */ new Set([dir, join6(dir, "__tests__"), join6(parent, "__tests__"), join6(parent, "tests"), join6(parent, "test")]);
|
|
1348
|
+
const found = [];
|
|
1349
|
+
for (const path of listing) {
|
|
1350
|
+
if (!homes.has(dirOf(path))) continue;
|
|
1351
|
+
const t = TEST_NAME_RE.exec(baseOf(path));
|
|
1352
|
+
if (t && t[1].toLowerCase() === stem) found.push(path);
|
|
1353
|
+
}
|
|
1354
|
+
return found.sort();
|
|
1355
|
+
}
|
|
1356
|
+
function asLf(text) {
|
|
1357
|
+
return toLf(text.charCodeAt(0) === 65279 ? text.slice(1) : text);
|
|
1358
|
+
}
|
|
1359
|
+
function collectLoopContext(p) {
|
|
1360
|
+
const readFile = p.readFile ?? ((path) => (0, import_node_fs2.readFileSync)(path, "utf8"));
|
|
1361
|
+
const listing = new Set(p.listing);
|
|
1362
|
+
const seen = new Set(p.targets.filter((t) => !(t.kind === "EXISTING" && isTestTarget(t.path))).map((t) => t.path));
|
|
1363
|
+
const entries = [];
|
|
1364
|
+
const testPaths = [];
|
|
1365
|
+
const records = [];
|
|
1366
|
+
let total = 0;
|
|
1367
|
+
for (const target of p.targets) {
|
|
1368
|
+
const named = target.contextPaths ?? [];
|
|
1369
|
+
const added = [];
|
|
1370
|
+
const skipped = [];
|
|
1371
|
+
for (const path of named) {
|
|
1372
|
+
if (seen.has(path)) continue;
|
|
1373
|
+
seen.add(path);
|
|
1374
|
+
if (matchesDeniedPath(path, p.deniedPaths)) {
|
|
1375
|
+
skipped.push({ path, reason: "denied" });
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
if (!listing.has(path)) {
|
|
1379
|
+
skipped.push({ path, reason: "not in workspace" });
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
let content;
|
|
1383
|
+
try {
|
|
1384
|
+
content = readFile(path);
|
|
1385
|
+
} catch {
|
|
1386
|
+
skipped.push({ path, reason: "unreadable" });
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
if (content.length > MAX_ADDED_FILE_CHARS) skipped.push({ path, reason: "too large" });
|
|
1390
|
+
else if (total + content.length > MAX_ADDED_CONTEXT_CHARS) skipped.push({ path, reason: "over budget" });
|
|
1391
|
+
else {
|
|
1392
|
+
entries.push({ path, content });
|
|
1393
|
+
added.push(path);
|
|
1394
|
+
total += content.length;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
const wantedTests = target.kind !== "EXISTING" ? [] : isTestTarget(target.path) ? [target.path] : pairedTestPaths(target.path, listing);
|
|
1398
|
+
for (const path of wantedTests) {
|
|
1399
|
+
if (seen.has(path)) continue;
|
|
1400
|
+
seen.add(path);
|
|
1401
|
+
if (matchesDeniedPath(path, p.deniedPaths)) {
|
|
1402
|
+
skipped.push({ path, reason: "denied" });
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
let content;
|
|
1406
|
+
try {
|
|
1407
|
+
content = asLf(readFile(path));
|
|
1408
|
+
} catch {
|
|
1409
|
+
skipped.push({ path, reason: "unreadable" });
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1412
|
+
if (content.length > MAX_ADDED_FILE_CHARS) skipped.push({ path, reason: "too large" });
|
|
1413
|
+
else if (total + content.length > MAX_ADDED_CONTEXT_CHARS) skipped.push({ path, reason: "over budget" });
|
|
1414
|
+
else {
|
|
1415
|
+
entries.push({ path, content });
|
|
1416
|
+
added.push(path);
|
|
1417
|
+
testPaths.push(path);
|
|
1418
|
+
total += content.length;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
let importedPaths = [];
|
|
1422
|
+
let aliasImports = 0;
|
|
1423
|
+
if (target.kind === "EXISTING") {
|
|
1424
|
+
let source = null;
|
|
1425
|
+
try {
|
|
1426
|
+
source = readFile(target.path);
|
|
1427
|
+
} catch {
|
|
1428
|
+
skipped.push({ path: target.path, reason: "import: unreadable" });
|
|
1429
|
+
}
|
|
1430
|
+
if (source !== null) {
|
|
1431
|
+
const imports = collectImportContext({
|
|
1432
|
+
targetPath: target.path,
|
|
1433
|
+
source,
|
|
1434
|
+
alreadyNamed: seen,
|
|
1435
|
+
deniedPaths: p.deniedPaths,
|
|
1436
|
+
listing,
|
|
1437
|
+
readFile,
|
|
1438
|
+
maxFileChars: MAX_ADDED_FILE_CHARS,
|
|
1439
|
+
maxTotalChars: MAX_ADDED_CONTEXT_CHARS,
|
|
1440
|
+
spentChars: total
|
|
1441
|
+
});
|
|
1442
|
+
for (const e of imports.entries) {
|
|
1443
|
+
entries.push(e);
|
|
1444
|
+
added.push(e.path);
|
|
1445
|
+
seen.add(e.path);
|
|
1446
|
+
total += e.content.length;
|
|
1447
|
+
}
|
|
1448
|
+
skipped.push(...imports.skipped);
|
|
1449
|
+
importedPaths = imports.importedPaths;
|
|
1450
|
+
aliasImports = imports.aliasImports;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
records.push({
|
|
1454
|
+
targetPath: target.path,
|
|
1455
|
+
contextPaths: named,
|
|
1456
|
+
addedPaths: added,
|
|
1457
|
+
skipped,
|
|
1458
|
+
...importedPaths.length > 0 ? { importedPaths } : {},
|
|
1459
|
+
...aliasImports > 0 ? { aliasImports } : {}
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
return { entries, testPaths, records };
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1221
1465
|
// src/addOnly.ts
|
|
1222
1466
|
var JS_FAMILY = /\.(?:[cm]?[jt]sx?)$/i;
|
|
1223
1467
|
var DECLARES_TEST = /^[ \t]*(?:it|test|describe)\b/m;
|
|
@@ -1326,7 +1570,7 @@ function buildVisibleListing(listing, deniedPaths) {
|
|
|
1326
1570
|
}
|
|
1327
1571
|
|
|
1328
1572
|
// src/targetingTools.ts
|
|
1329
|
-
var
|
|
1573
|
+
var import_node_fs3 = require("node:fs");
|
|
1330
1574
|
var import_node_path4 = require("node:path");
|
|
1331
1575
|
var DEFAULT_LIMITS = {
|
|
1332
1576
|
maxTurns: 12,
|
|
@@ -1351,20 +1595,20 @@ var DEFAULT_LIMITS = {
|
|
|
1351
1595
|
maxPatternChars: 200
|
|
1352
1596
|
};
|
|
1353
1597
|
function createNodeToolFs(rootDir = process.cwd()) {
|
|
1354
|
-
const rootReal = (0,
|
|
1598
|
+
const rootReal = (0, import_node_fs3.realpathSync)(rootDir);
|
|
1355
1599
|
return {
|
|
1356
1600
|
rootReal,
|
|
1357
1601
|
lstat(rel) {
|
|
1358
|
-
const s = (0,
|
|
1602
|
+
const s = (0, import_node_fs3.lstatSync)((0, import_node_path4.join)(rootDir, rel));
|
|
1359
1603
|
return { isSymlink: s.isSymbolicLink(), isFile: s.isFile(), size: s.size };
|
|
1360
1604
|
},
|
|
1361
1605
|
realpathInside(rel) {
|
|
1362
|
-
const real = (0,
|
|
1606
|
+
const real = (0, import_node_fs3.realpathSync)((0, import_node_path4.join)(rootDir, rel));
|
|
1363
1607
|
const r = (0, import_node_path4.relative)(rootReal, real);
|
|
1364
1608
|
return r !== "" && !r.startsWith("..") && !(0, import_node_path4.isAbsolute)(r);
|
|
1365
1609
|
},
|
|
1366
1610
|
readBytes(rel) {
|
|
1367
|
-
return (0,
|
|
1611
|
+
return (0, import_node_fs3.readFileSync)((0, import_node_path4.join)(rootDir, rel));
|
|
1368
1612
|
}
|
|
1369
1613
|
};
|
|
1370
1614
|
}
|
|
@@ -1665,7 +1909,7 @@ function executeToolCall(call, env2, ledger) {
|
|
|
1665
1909
|
}
|
|
1666
1910
|
|
|
1667
1911
|
// src/workspaceOverlay.ts
|
|
1668
|
-
var
|
|
1912
|
+
var import_node_fs4 = require("node:fs");
|
|
1669
1913
|
var import_node_path5 = require("node:path");
|
|
1670
1914
|
function createNodeWriteFs(rootDir = process.cwd()) {
|
|
1671
1915
|
const base = createNodeToolFs(rootDir);
|
|
@@ -1679,7 +1923,7 @@ function createNodeWriteFs(rootDir = process.cwd()) {
|
|
|
1679
1923
|
let dir = (0, import_node_path5.dirname)((0, import_node_path5.join)(rootDir, rel));
|
|
1680
1924
|
for (; ; ) {
|
|
1681
1925
|
try {
|
|
1682
|
-
return inside((0,
|
|
1926
|
+
return inside((0, import_node_fs4.realpathSync)(dir));
|
|
1683
1927
|
} catch {
|
|
1684
1928
|
const up = (0, import_node_path5.dirname)(dir);
|
|
1685
1929
|
if (up === dir) return false;
|
|
@@ -1689,7 +1933,7 @@ function createNodeWriteFs(rootDir = process.cwd()) {
|
|
|
1689
1933
|
},
|
|
1690
1934
|
exists(rel) {
|
|
1691
1935
|
try {
|
|
1692
|
-
(0,
|
|
1936
|
+
(0, import_node_fs4.lstatSync)((0, import_node_path5.join)(rootDir, rel));
|
|
1693
1937
|
return true;
|
|
1694
1938
|
} catch {
|
|
1695
1939
|
return false;
|
|
@@ -2489,108 +2733,6 @@ async function runCodegenLoop(args, deps) {
|
|
|
2489
2733
|
}
|
|
2490
2734
|
}
|
|
2491
2735
|
|
|
2492
|
-
// src/overlapCheck.ts
|
|
2493
|
-
var TEST_PATH_RE = /(\.(test|spec)\.[jt]sx?$)|(^|\/)(__tests__|tests?)\//i;
|
|
2494
|
-
function isTestTarget(path) {
|
|
2495
|
-
return TEST_PATH_RE.test(path);
|
|
2496
|
-
}
|
|
2497
|
-
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
2498
|
-
"a",
|
|
2499
|
-
"an",
|
|
2500
|
-
"the",
|
|
2501
|
-
"is",
|
|
2502
|
-
"are",
|
|
2503
|
-
"was",
|
|
2504
|
-
"were",
|
|
2505
|
-
"be",
|
|
2506
|
-
"been",
|
|
2507
|
-
"being",
|
|
2508
|
-
"of",
|
|
2509
|
-
"to",
|
|
2510
|
-
"in",
|
|
2511
|
-
"on",
|
|
2512
|
-
"for",
|
|
2513
|
-
"with",
|
|
2514
|
-
"at",
|
|
2515
|
-
"by",
|
|
2516
|
-
"from",
|
|
2517
|
-
"as",
|
|
2518
|
-
"and",
|
|
2519
|
-
"or",
|
|
2520
|
-
"not",
|
|
2521
|
-
"no",
|
|
2522
|
-
"nor",
|
|
2523
|
-
"this",
|
|
2524
|
-
"that",
|
|
2525
|
-
"these",
|
|
2526
|
-
"those",
|
|
2527
|
-
"it",
|
|
2528
|
-
"its",
|
|
2529
|
-
"cannot",
|
|
2530
|
-
"can't",
|
|
2531
|
-
"should",
|
|
2532
|
-
"must",
|
|
2533
|
-
"may",
|
|
2534
|
-
"will",
|
|
2535
|
-
"shall",
|
|
2536
|
-
"when",
|
|
2537
|
-
"if",
|
|
2538
|
-
"than",
|
|
2539
|
-
"then",
|
|
2540
|
-
"so",
|
|
2541
|
-
"do",
|
|
2542
|
-
"does",
|
|
2543
|
-
"did"
|
|
2544
|
-
]);
|
|
2545
|
-
var MIN_WORD_LENGTH = 3;
|
|
2546
|
-
function significantWords(step) {
|
|
2547
|
-
return new Set(
|
|
2548
|
-
step.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter((w) => w.length >= MIN_WORD_LENGTH && !STOPWORDS.has(w))
|
|
2549
|
-
);
|
|
2550
|
-
}
|
|
2551
|
-
function jaccard(a, b) {
|
|
2552
|
-
if (a.size === 0 || b.size === 0) return 0;
|
|
2553
|
-
let intersection = 0;
|
|
2554
|
-
for (const w of a) if (b.has(w)) intersection++;
|
|
2555
|
-
const union = a.size + b.size - intersection;
|
|
2556
|
-
return intersection / union;
|
|
2557
|
-
}
|
|
2558
|
-
function normalizedStep(step) {
|
|
2559
|
-
return step.trim().toLowerCase().replace(/\s+/g, " ");
|
|
2560
|
-
}
|
|
2561
|
-
var OVERLAP_THRESHOLD = 0.5;
|
|
2562
|
-
function findOverlappingSteps(targets) {
|
|
2563
|
-
const items = targets.flatMap(
|
|
2564
|
-
(target) => target.planStepsImplemented.map((step) => ({
|
|
2565
|
-
target: target.path,
|
|
2566
|
-
step,
|
|
2567
|
-
words: significantWords(step)
|
|
2568
|
-
}))
|
|
2569
|
-
);
|
|
2570
|
-
const warnings = [];
|
|
2571
|
-
for (let i = 0; i < items.length; i++) {
|
|
2572
|
-
for (let j = i + 1; j < items.length; j++) {
|
|
2573
|
-
if (items[i].target === items[j].target) continue;
|
|
2574
|
-
if (isTestTarget(items[i].target) || isTestTarget(items[j].target)) continue;
|
|
2575
|
-
if (jaccard(items[i].words, items[j].words) >= OVERLAP_THRESHOLD) {
|
|
2576
|
-
warnings.push({
|
|
2577
|
-
targetA: items[i].target,
|
|
2578
|
-
stepA: items[i].step,
|
|
2579
|
-
targetB: items[j].target,
|
|
2580
|
-
stepB: items[j].step,
|
|
2581
|
-
severity: normalizedStep(items[i].step) === normalizedStep(items[j].step) ? "identical" : "similar"
|
|
2582
|
-
});
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
|
-
return warnings;
|
|
2587
|
-
}
|
|
2588
|
-
function describeOverlapWarnings(warnings) {
|
|
2589
|
-
return warnings.map(
|
|
2590
|
-
(w) => `${w.targetA} and ${w.targetB} both implement what looks like the same rule \u2014 "${w.stepA}" / "${w.stepB}". Check these aren't two independent implementations of the same behavior.`
|
|
2591
|
-
);
|
|
2592
|
-
}
|
|
2593
|
-
|
|
2594
2736
|
// src/codegenStep.ts
|
|
2595
2737
|
var MAX_PROTECTED_PATHS_ON_WIRE = 300;
|
|
2596
2738
|
async function postCodegenTurn(gateway, contextData, signal) {
|
|
@@ -2617,7 +2759,7 @@ function protectedTestFiles(listing, testDiscovery) {
|
|
|
2617
2759
|
}
|
|
2618
2760
|
return [...found].sort();
|
|
2619
2761
|
}
|
|
2620
|
-
function buildCodegenLoopArgs(p) {
|
|
2762
|
+
function buildCodegenLoopArgs(p, context = collectLoopContext({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, ...p.readFile ? { readFile: p.readFile } : {} })) {
|
|
2621
2763
|
const skipped = new Set(p.skippedCases.map((s) => s.automationId));
|
|
2622
2764
|
const claimed = /* @__PURE__ */ new Set();
|
|
2623
2765
|
for (const t of p.targets) for (const id of t.automationIds ?? []) if (!skipped.has(id)) claimed.add(id);
|
|
@@ -2634,6 +2776,7 @@ function buildCodegenLoopArgs(p) {
|
|
|
2634
2776
|
requiredTests,
|
|
2635
2777
|
workspaceListing: p.workspaceListing
|
|
2636
2778
|
};
|
|
2779
|
+
if (context.entries.length > 0) baseContext.contextContents = context.entries;
|
|
2637
2780
|
if (p.deniedPaths.length > 0) baseContext.deniedPaths = p.deniedPaths;
|
|
2638
2781
|
if (protectedTestPaths.length > 0) baseContext.protectedTestPaths = protectedTestPaths.slice(0, MAX_PROTECTED_PATHS_ON_WIRE);
|
|
2639
2782
|
if (p.outOfScope.length > 0) baseContext.outOfScope = p.outOfScope;
|
|
@@ -2672,8 +2815,19 @@ function perFile(p) {
|
|
|
2672
2815
|
}
|
|
2673
2816
|
async function runCodegenStep(p) {
|
|
2674
2817
|
if (p.mode !== "loop") return perFile(p);
|
|
2818
|
+
const context = collectLoopContext({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, ...p.readFile ? { readFile: p.readFile } : {} });
|
|
2819
|
+
p.contextLog.push(...context.records);
|
|
2820
|
+
console.log(
|
|
2821
|
+
JSON.stringify({
|
|
2822
|
+
event: "codegen.loop_context",
|
|
2823
|
+
files: context.entries.length,
|
|
2824
|
+
chars: context.entries.reduce((n, e) => n + e.content.length, 0),
|
|
2825
|
+
paths: context.entries.map((e) => e.path),
|
|
2826
|
+
existingTests: context.testPaths
|
|
2827
|
+
})
|
|
2828
|
+
);
|
|
2675
2829
|
try {
|
|
2676
|
-
const { results, summary } = await runCodegenLoop(buildCodegenLoopArgs(p), {
|
|
2830
|
+
const { results, summary } = await runCodegenLoop(buildCodegenLoopArgs(p, context), {
|
|
2677
2831
|
post: (contextData, signal) => postCodegenTurn(p.gateway, contextData, signal),
|
|
2678
2832
|
...p.deps
|
|
2679
2833
|
});
|
|
@@ -2705,7 +2859,7 @@ async function runCodegenStep(p) {
|
|
|
2705
2859
|
}
|
|
2706
2860
|
|
|
2707
2861
|
// src/dependencyCheck.ts
|
|
2708
|
-
var
|
|
2862
|
+
var import_node_fs5 = require("node:fs");
|
|
2709
2863
|
var import_node_path6 = require("node:path");
|
|
2710
2864
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
2711
2865
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
@@ -2792,7 +2946,7 @@ function readDeclaredDependencies(results, workspaceRoot) {
|
|
|
2792
2946
|
raw = generated.newContent;
|
|
2793
2947
|
} else {
|
|
2794
2948
|
try {
|
|
2795
|
-
raw = (0,
|
|
2949
|
+
raw = (0, import_node_fs5.readFileSync)(packageJsonPath, "utf8");
|
|
2796
2950
|
} catch {
|
|
2797
2951
|
raw = null;
|
|
2798
2952
|
}
|
|
@@ -2865,7 +3019,7 @@ function resolveAliasPrefixes(results, workspaceRoot) {
|
|
|
2865
3019
|
raw = generated.newContent;
|
|
2866
3020
|
} else {
|
|
2867
3021
|
try {
|
|
2868
|
-
raw = (0,
|
|
3022
|
+
raw = (0, import_node_fs5.readFileSync)(configPath, "utf8");
|
|
2869
3023
|
} catch {
|
|
2870
3024
|
raw = null;
|
|
2871
3025
|
}
|
|
@@ -2955,21 +3109,21 @@ async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
|
2955
3109
|
}
|
|
2956
3110
|
|
|
2957
3111
|
// src/phase0.ts
|
|
2958
|
-
var
|
|
3112
|
+
var import_node_fs6 = require("node:fs");
|
|
2959
3113
|
function writePhase0Marker(runId) {
|
|
2960
|
-
(0,
|
|
2961
|
-
(0,
|
|
3114
|
+
(0, import_node_fs6.mkdirSync)(".quikpilot", { recursive: true });
|
|
3115
|
+
(0, import_node_fs6.appendFileSync)(".quikpilot/phase0-marker.txt", `QuikPilot Phase 0 skeleton marker for run ${runId}
|
|
2962
3116
|
`);
|
|
2963
3117
|
}
|
|
2964
3118
|
|
|
2965
3119
|
// src/quiktest.ts
|
|
2966
|
-
var
|
|
3120
|
+
var import_node_fs7 = require("node:fs");
|
|
2967
3121
|
var import_node_path7 = require("node:path");
|
|
2968
3122
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
2969
3123
|
function walkForJUnitByName(dir) {
|
|
2970
3124
|
let entries;
|
|
2971
3125
|
try {
|
|
2972
|
-
entries = (0,
|
|
3126
|
+
entries = (0, import_node_fs7.readdirSync)(dir);
|
|
2973
3127
|
} catch {
|
|
2974
3128
|
return null;
|
|
2975
3129
|
}
|
|
@@ -2978,7 +3132,7 @@ function walkForJUnitByName(dir) {
|
|
|
2978
3132
|
const full = (0, import_node_path7.join)(dir, entry);
|
|
2979
3133
|
let stat;
|
|
2980
3134
|
try {
|
|
2981
|
-
stat = (0,
|
|
3135
|
+
stat = (0, import_node_fs7.statSync)(full);
|
|
2982
3136
|
} catch {
|
|
2983
3137
|
continue;
|
|
2984
3138
|
}
|
|
@@ -2994,7 +3148,7 @@ function walkForJUnitByName(dir) {
|
|
|
2994
3148
|
function firstXmlIn(dir, namePattern) {
|
|
2995
3149
|
let entries;
|
|
2996
3150
|
try {
|
|
2997
|
-
entries = (0,
|
|
3151
|
+
entries = (0, import_node_fs7.readdirSync)(dir);
|
|
2998
3152
|
} catch {
|
|
2999
3153
|
return null;
|
|
3000
3154
|
}
|
|
@@ -3004,7 +3158,7 @@ function firstXmlIn(dir, namePattern) {
|
|
|
3004
3158
|
function readTestReportBytes(cwd = process.cwd()) {
|
|
3005
3159
|
try {
|
|
3006
3160
|
const report = findJUnitReport(cwd);
|
|
3007
|
-
return report ? (0,
|
|
3161
|
+
return report ? (0, import_node_fs7.readFileSync)(report) : null;
|
|
3008
3162
|
} catch {
|
|
3009
3163
|
return null;
|
|
3010
3164
|
}
|
|
@@ -3034,8 +3188,8 @@ async function reportToQuikTest(params) {
|
|
|
3034
3188
|
try {
|
|
3035
3189
|
console.log(`reporting ${report}`);
|
|
3036
3190
|
const ciUrl = buildCiUrl(githubServerUrl, githubRepository, githubRunId);
|
|
3037
|
-
const { readFileSync:
|
|
3038
|
-
const body =
|
|
3191
|
+
const { readFileSync: readFileSync9 } = await import("node:fs");
|
|
3192
|
+
const body = readFileSync9(report);
|
|
3039
3193
|
let url = `${resultsUrl}?ciUrl=${encodeURIComponent(ciUrl)}&automationIdFormat=bracket`;
|
|
3040
3194
|
if (generatedFiles) {
|
|
3041
3195
|
url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
|
|
@@ -3048,7 +3202,7 @@ async function reportToQuikTest(params) {
|
|
|
3048
3202
|
if (!res.ok) {
|
|
3049
3203
|
throw new Error(`QuikTest report POST failed: ${res.status} ${res.statusText}`);
|
|
3050
3204
|
}
|
|
3051
|
-
(0,
|
|
3205
|
+
(0, import_node_fs7.rmSync)(report, { force: true });
|
|
3052
3206
|
let unmatched = [];
|
|
3053
3207
|
try {
|
|
3054
3208
|
const json = await res.json();
|
|
@@ -3064,11 +3218,11 @@ async function reportToQuikTest(params) {
|
|
|
3064
3218
|
|
|
3065
3219
|
// src/baselineCheck.ts
|
|
3066
3220
|
var import_node_child_process3 = require("node:child_process");
|
|
3067
|
-
var
|
|
3221
|
+
var import_node_fs9 = require("node:fs");
|
|
3068
3222
|
var import_node_path8 = require("node:path");
|
|
3069
3223
|
|
|
3070
3224
|
// src/regressionCheck.ts
|
|
3071
|
-
var
|
|
3225
|
+
var import_node_fs8 = require("node:fs");
|
|
3072
3226
|
var TESTCASE_RE = /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g;
|
|
3073
3227
|
var NAME_ATTR_RE = /\bname="([^"]*)"/;
|
|
3074
3228
|
var CLASSNAME_ATTR_RE = /\bclassname="([^"]*)"/;
|
|
@@ -3154,7 +3308,7 @@ function readJUnitOutcomes(cwd) {
|
|
|
3154
3308
|
const report = findJUnitReport(cwd);
|
|
3155
3309
|
if (!report) return null;
|
|
3156
3310
|
try {
|
|
3157
|
-
return parseJUnitOutcomes((0,
|
|
3311
|
+
return parseJUnitOutcomes((0, import_node_fs8.readFileSync)(report, "utf8"));
|
|
3158
3312
|
} catch {
|
|
3159
3313
|
return null;
|
|
3160
3314
|
}
|
|
@@ -3256,27 +3410,27 @@ function insideCheckout(cwd, path) {
|
|
|
3256
3410
|
return rel === "" || rel.startsWith("..") || (0, import_node_path8.isAbsolute)(rel) ? null : abs;
|
|
3257
3411
|
}
|
|
3258
3412
|
function writeForCheck(abs, content) {
|
|
3259
|
-
const original = (0,
|
|
3413
|
+
const original = (0, import_node_fs9.existsSync)(abs) ? (0, import_node_fs9.readFileSync)(abs) : null;
|
|
3260
3414
|
const createdDirs = [];
|
|
3261
3415
|
if (original === null) {
|
|
3262
3416
|
const missing = [];
|
|
3263
|
-
for (let d = (0, import_node_path8.dirname)(abs); !(0,
|
|
3417
|
+
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);
|
|
3264
3418
|
for (const d of missing.reverse()) {
|
|
3265
|
-
(0,
|
|
3419
|
+
(0, import_node_fs9.mkdirSync)(d);
|
|
3266
3420
|
createdDirs.push(d);
|
|
3267
3421
|
}
|
|
3268
3422
|
}
|
|
3269
|
-
(0,
|
|
3423
|
+
(0, import_node_fs9.writeFileSync)(abs, content);
|
|
3270
3424
|
return { abs, original, createdDirs };
|
|
3271
3425
|
}
|
|
3272
3426
|
function restore(written) {
|
|
3273
3427
|
for (const file of [...written].reverse()) {
|
|
3274
3428
|
try {
|
|
3275
|
-
if (file.original !== null) (0,
|
|
3276
|
-
else (0,
|
|
3429
|
+
if (file.original !== null) (0, import_node_fs9.writeFileSync)(file.abs, file.original);
|
|
3430
|
+
else (0, import_node_fs9.rmSync)(file.abs, { force: true });
|
|
3277
3431
|
for (const d of [...file.createdDirs].reverse()) {
|
|
3278
3432
|
try {
|
|
3279
|
-
(0,
|
|
3433
|
+
(0, import_node_fs9.rmdirSync)(d);
|
|
3280
3434
|
} catch {
|
|
3281
3435
|
}
|
|
3282
3436
|
}
|
|
@@ -3300,7 +3454,7 @@ function untrackedFiles(cwd) {
|
|
|
3300
3454
|
}
|
|
3301
3455
|
var mtimeOf = (path) => {
|
|
3302
3456
|
try {
|
|
3303
|
-
return (0,
|
|
3457
|
+
return (0, import_node_fs9.statSync)(path).mtimeMs;
|
|
3304
3458
|
} catch {
|
|
3305
3459
|
return null;
|
|
3306
3460
|
}
|
|
@@ -3314,7 +3468,7 @@ function decideCause(targets, results, cwd) {
|
|
|
3314
3468
|
const abs = insideCheckout(cwd, t.path);
|
|
3315
3469
|
if (next === void 0 || abs === null) return "ALREADY_TRUE";
|
|
3316
3470
|
try {
|
|
3317
|
-
if ((0,
|
|
3471
|
+
if ((0, import_node_fs9.readFileSync)(abs, "utf8") !== next) return "ALREADY_TRUE";
|
|
3318
3472
|
} catch {
|
|
3319
3473
|
return "ALREADY_TRUE";
|
|
3320
3474
|
}
|
|
@@ -3390,7 +3544,7 @@ async function runBaselineCheck(params) {
|
|
|
3390
3544
|
for (const file of untrackedAfter) {
|
|
3391
3545
|
if (untrackedBefore.has(file)) continue;
|
|
3392
3546
|
const abs = insideCheckout(cwd, file);
|
|
3393
|
-
if (abs) (0,
|
|
3547
|
+
if (abs) (0, import_node_fs9.rmSync)(abs, { force: true });
|
|
3394
3548
|
}
|
|
3395
3549
|
}
|
|
3396
3550
|
}
|
|
@@ -3411,7 +3565,7 @@ async function runBaselineCheck(params) {
|
|
|
3411
3565
|
}
|
|
3412
3566
|
|
|
3413
3567
|
// src/failureArtifact.ts
|
|
3414
|
-
var
|
|
3568
|
+
var import_node_fs10 = require("node:fs");
|
|
3415
3569
|
var import_node_path9 = require("node:path");
|
|
3416
3570
|
|
|
3417
3571
|
// src/failureReason.ts
|
|
@@ -3453,7 +3607,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
3453
3607
|
var REPORT_COPY = "final-test-report.xml";
|
|
3454
3608
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
3455
3609
|
var MAX_FILES = 200;
|
|
3456
|
-
var RUNNER_VERSION = true ? "9.2.0-rc.
|
|
3610
|
+
var RUNNER_VERSION = true ? "9.2.0-rc.6" : "dev";
|
|
3457
3611
|
function safeDestination(base, repoPath) {
|
|
3458
3612
|
if (!repoPath || (0, import_node_path9.isAbsolute)(repoPath)) return null;
|
|
3459
3613
|
const destination = (0, import_node_path9.resolve)(base, repoPath);
|
|
@@ -3465,8 +3619,8 @@ function writeFailureArtifact(input) {
|
|
|
3465
3619
|
if (input.results.length === 0) return { written: false };
|
|
3466
3620
|
try {
|
|
3467
3621
|
const base = (0, import_node_path9.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
3468
|
-
(0,
|
|
3469
|
-
(0,
|
|
3622
|
+
(0, import_node_fs10.rmSync)(base, { recursive: true, force: true });
|
|
3623
|
+
(0, import_node_fs10.mkdirSync)(base, { recursive: true });
|
|
3470
3624
|
const files = [];
|
|
3471
3625
|
const skipped = [];
|
|
3472
3626
|
for (const result of input.results) {
|
|
@@ -3475,8 +3629,8 @@ function writeFailureArtifact(input) {
|
|
|
3475
3629
|
skipped.push(result.targetPath);
|
|
3476
3630
|
continue;
|
|
3477
3631
|
}
|
|
3478
|
-
(0,
|
|
3479
|
-
(0,
|
|
3632
|
+
(0, import_node_fs10.mkdirSync)((0, import_node_path9.dirname)(destination), { recursive: true });
|
|
3633
|
+
(0, import_node_fs10.writeFileSync)(destination, result.newContent);
|
|
3480
3634
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
3481
3635
|
}
|
|
3482
3636
|
let testReport = "none";
|
|
@@ -3484,7 +3638,7 @@ function writeFailureArtifact(input) {
|
|
|
3484
3638
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
3485
3639
|
testReport = "too-large";
|
|
3486
3640
|
} else {
|
|
3487
|
-
(0,
|
|
3641
|
+
(0, import_node_fs10.writeFileSync)((0, import_node_path9.join)(base, REPORT_COPY), input.testReport);
|
|
3488
3642
|
testReport = "included";
|
|
3489
3643
|
}
|
|
3490
3644
|
}
|
|
@@ -3504,8 +3658,8 @@ function writeFailureArtifact(input) {
|
|
|
3504
3658
|
failureReasons: input.failureReasons
|
|
3505
3659
|
};
|
|
3506
3660
|
const text = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
|
|
3507
|
-
(0,
|
|
3508
|
-
return { written: (0,
|
|
3661
|
+
(0, import_node_fs10.writeFileSync)((0, import_node_path9.join)(base, "manifest.json"), text);
|
|
3662
|
+
return { written: (0, import_node_fs10.existsSync)((0, import_node_path9.join)(base, "manifest.json")) };
|
|
3509
3663
|
} catch (err) {
|
|
3510
3664
|
console.warn(`::warning::Could not keep the failed run's files: ${err instanceof Error ? err.message : String(err)}`);
|
|
3511
3665
|
return { written: false };
|
|
@@ -3513,7 +3667,7 @@ function writeFailureArtifact(input) {
|
|
|
3513
3667
|
}
|
|
3514
3668
|
|
|
3515
3669
|
// src/scopeCheck.ts
|
|
3516
|
-
var
|
|
3670
|
+
var import_node_fs11 = require("node:fs");
|
|
3517
3671
|
var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
|
|
3518
3672
|
var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
|
|
3519
3673
|
var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
|
|
@@ -3570,7 +3724,7 @@ function checkApiScope(results, targets, apiChanges) {
|
|
|
3570
3724
|
} else {
|
|
3571
3725
|
let currentContent;
|
|
3572
3726
|
try {
|
|
3573
|
-
currentContent = (0,
|
|
3727
|
+
currentContent = (0, import_node_fs11.readFileSync)(targetPath, "utf8");
|
|
3574
3728
|
} catch {
|
|
3575
3729
|
currentContent = "";
|
|
3576
3730
|
}
|