@quikit/quikpilot-runner 9.3.0-rc.70 → 9.3.0-rc.71
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 +2 -0
- package/dist/index.js +406 -118
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29584,8 +29584,8 @@ var isArray = Array.isArray || (function(obj) {
|
|
|
29584
29584
|
return toString.call(obj) === "[object Array]";
|
|
29585
29585
|
});
|
|
29586
29586
|
var regexpCache = /* @__PURE__ */ Object.create(null);
|
|
29587
|
-
function wordsRegexp(
|
|
29588
|
-
return regexpCache[
|
|
29587
|
+
function wordsRegexp(words2) {
|
|
29588
|
+
return regexpCache[words2] || (regexpCache[words2] = new RegExp("^(?:" + words2.replace(/ /g, "|") + ")$"));
|
|
29589
29589
|
}
|
|
29590
29590
|
function codePointToString(code) {
|
|
29591
29591
|
if (code <= 65535) {
|
|
@@ -42151,7 +42151,11 @@ var REASON_WORDS = {
|
|
|
42151
42151
|
out_of_time: "the time allowed for writing the change ran out",
|
|
42152
42152
|
// QUIKTR-1854: an existing test that QuikPilot cannot read pins the bug. QUIKTR-1855: JavaScript, TypeScript, Python, Go and Java test files can be read.
|
|
42153
42153
|
test_unsupported_language: "an existing test expects what an approved case calls wrong, but QuikPilot could not read that test file to ask about it (it reads JavaScript, TypeScript, Python, Go and Java test files), so no change to it could be proposed",
|
|
42154
|
-
test_conflict_unreportable: "an existing test expects what an approved case calls wrong, and it is written once for many rows, so no change to it could be proposed"
|
|
42154
|
+
test_conflict_unreportable: "an existing test expects what an approved case calls wrong, and it is written once for many rows, so no change to it could be proposed",
|
|
42155
|
+
// QUIKTR-2325 / QUIKTR-2326: the parts check. Only `part_missing` ends an attempt; the other two stop the run before any code.
|
|
42156
|
+
part_missing: "it said it was finished but had not built every part of the feature the design lists",
|
|
42157
|
+
part_not_placed: "the plan chose no file for a part of the feature the design lists",
|
|
42158
|
+
needs_database_change: "the feature needs a stored value (a database change) QuikPilot cannot make here"
|
|
42155
42159
|
};
|
|
42156
42160
|
function reasonInWords(reason) {
|
|
42157
42161
|
return REASON_WORDS[reason] ?? reason;
|
|
@@ -42168,8 +42172,8 @@ function failedAttemptRecord(n, failure) {
|
|
|
42168
42172
|
};
|
|
42169
42173
|
}
|
|
42170
42174
|
function attemptInWords(a, fallback) {
|
|
42171
|
-
const
|
|
42172
|
-
return a?.runtimeCode && a.runtimeCode !== "other" ? `${
|
|
42175
|
+
const words2 = a?.afterRecovery ? `${reasonInWords(a?.reason ?? fallback)}, a second time in a row, even after the AI was asked to take a smaller step` : reasonInWords(a?.reason ?? fallback);
|
|
42176
|
+
return a?.runtimeCode && a.runtimeCode !== "other" ? `${words2} (error code ${a.runtimeCode})` : words2;
|
|
42173
42177
|
}
|
|
42174
42178
|
function exhaustedMessage(attempts, stop2, unreportable) {
|
|
42175
42179
|
const first = attempts[0];
|
|
@@ -42198,8 +42202,14 @@ var CodegenAttemptsExhausted = class extends Error {
|
|
|
42198
42202
|
stopReason;
|
|
42199
42203
|
/** QUIKTR-1823: existing tests written once for many rows that stood in the way (path, line, case), when that is why the step ended. */
|
|
42200
42204
|
unreportable;
|
|
42201
|
-
|
|
42202
|
-
|
|
42205
|
+
/**
|
|
42206
|
+
* QUIKTR-2325: `partsMissing` - the runner's own sentence naming the parts of the feature the last attempt did not build (`part_missing`).
|
|
42207
|
+
* It goes FIRST: QuikProjects explains a run's reason by how it starts ("A part of the feature was not built:"), and the attempts follow.
|
|
42208
|
+
* Built from the design's words and the planned paths; never a file's text.
|
|
42209
|
+
*/
|
|
42210
|
+
constructor(attempts, stopReason, unreportable = [], partsMissing) {
|
|
42211
|
+
const message = exhaustedMessage(attempts, stopReason, unreportable);
|
|
42212
|
+
super(partsMissing ? `${partsMissing} ${message}` : message);
|
|
42203
42213
|
this.name = "CodegenAttemptsExhausted";
|
|
42204
42214
|
this.attempts = attempts;
|
|
42205
42215
|
this.stopReason = stopReason;
|
|
@@ -47357,6 +47367,242 @@ function reviewAnswer(lines) {
|
|
|
47357
47367
|
return { rules: ["done_rule"], violations: [...lines.slice(0, MAX_REVIEW_CASES), REVIEW_CLOSING], message: REVIEW_MESSAGE };
|
|
47358
47368
|
}
|
|
47359
47369
|
|
|
47370
|
+
// src/scopeCheck.ts
|
|
47371
|
+
var import_node_fs16 = require("node:fs");
|
|
47372
|
+
var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
|
|
47373
|
+
var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
|
|
47374
|
+
var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
|
|
47375
|
+
var NO_PATH = "(this file's route)";
|
|
47376
|
+
function detectMentions(text3) {
|
|
47377
|
+
const found = [];
|
|
47378
|
+
for (const line of text3.split("\n")) {
|
|
47379
|
+
const methodMatch = ROUTE_METHOD_RE.exec(line);
|
|
47380
|
+
const pathMatch = ROUTE_PATH_RE.exec(line);
|
|
47381
|
+
if (methodMatch && pathMatch) {
|
|
47382
|
+
found.push({ method: methodMatch[1].toUpperCase(), path: pathMatch[0].replace(/:+$/, "") });
|
|
47383
|
+
}
|
|
47384
|
+
const exportMatch = ROUTE_EXPORT_RE.exec(line);
|
|
47385
|
+
if (exportMatch) {
|
|
47386
|
+
found.push({ method: exportMatch[1].toUpperCase(), path: NO_PATH });
|
|
47387
|
+
}
|
|
47388
|
+
}
|
|
47389
|
+
return found;
|
|
47390
|
+
}
|
|
47391
|
+
function normalizePath(path) {
|
|
47392
|
+
return path.replace(/:[A-Za-z0-9_]+|\{[^}]+\}|\[[^\]]+\]/g, "*");
|
|
47393
|
+
}
|
|
47394
|
+
function surfaceCovers(surface, mention) {
|
|
47395
|
+
if (!new RegExp(`\\b${mention.method}\\b`, "i").test(surface)) return false;
|
|
47396
|
+
if (mention.path === NO_PATH) return true;
|
|
47397
|
+
const declaredPath = normalizePath(surface);
|
|
47398
|
+
const mentionPath = normalizePath(mention.path);
|
|
47399
|
+
return declaredPath.includes(mentionPath) || mentionPath.includes(declaredPath);
|
|
47400
|
+
}
|
|
47401
|
+
function addedLines(before, after) {
|
|
47402
|
+
const beforeLines = new Set(before.split("\n"));
|
|
47403
|
+
return after.split("\n").filter((line) => !beforeLines.has(line)).join("\n");
|
|
47404
|
+
}
|
|
47405
|
+
function checkApiScope(results, targets, apiChanges) {
|
|
47406
|
+
const targetsByPath = new Map(targets.map((t) => [t.path, t]));
|
|
47407
|
+
const violations = [];
|
|
47408
|
+
for (const { targetPath, newContent } of results) {
|
|
47409
|
+
if (isTestFile(targetPath)) continue;
|
|
47410
|
+
const target = targetsByPath.get(targetPath);
|
|
47411
|
+
const isNewFile = target?.kind === "NEW_FILE";
|
|
47412
|
+
let scanned;
|
|
47413
|
+
if (isNewFile) {
|
|
47414
|
+
scanned = newContent;
|
|
47415
|
+
} else {
|
|
47416
|
+
let currentContent;
|
|
47417
|
+
try {
|
|
47418
|
+
currentContent = (0, import_node_fs16.readFileSync)(targetPath, "utf8");
|
|
47419
|
+
} catch {
|
|
47420
|
+
currentContent = "";
|
|
47421
|
+
}
|
|
47422
|
+
scanned = addedLines(currentContent, newContent);
|
|
47423
|
+
}
|
|
47424
|
+
for (const mention of detectMentions(scanned)) {
|
|
47425
|
+
if (!apiChanges.some((c) => surfaceCovers(c.surface, mention))) {
|
|
47426
|
+
violations.push({ file: targetPath, method: mention.method, path: mention.path });
|
|
47427
|
+
}
|
|
47428
|
+
}
|
|
47429
|
+
}
|
|
47430
|
+
return { blocked: violations.length > 0, violations };
|
|
47431
|
+
}
|
|
47432
|
+
function describeScopeViolations(check) {
|
|
47433
|
+
return check.violations.map((v) => `${v.file} adds ${v.method} ${v.path}, not declared in the design's API changes`).join("; ");
|
|
47434
|
+
}
|
|
47435
|
+
|
|
47436
|
+
// src/partsCheck.ts
|
|
47437
|
+
var PARTS_CHECK_ENV = "QUIKPILOT_PARTS_CHECK";
|
|
47438
|
+
function partsCheckOn(env2 = process.env) {
|
|
47439
|
+
return env2[PARTS_CHECK_ENV]?.trim().toLowerCase() === "on";
|
|
47440
|
+
}
|
|
47441
|
+
var PART_KINDS = ["endpoint", "screen", "data", "stored", "logic"];
|
|
47442
|
+
var MAX_PARTS = 8;
|
|
47443
|
+
var MAX_NAME_CHARS3 = 150;
|
|
47444
|
+
var MAX_WHAT_CHARS = 300;
|
|
47445
|
+
var PART_ID_RE = /^P\d+$/;
|
|
47446
|
+
var MARKER_RE = /\[(P\d+)\]/g;
|
|
47447
|
+
function isRecord3(x) {
|
|
47448
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
47449
|
+
}
|
|
47450
|
+
function partsFromDesign(design) {
|
|
47451
|
+
if (!isRecord3(design) || !Array.isArray(design.parts)) return [];
|
|
47452
|
+
const raw = design.parts;
|
|
47453
|
+
if (raw.length === 0 || raw.length > MAX_PARTS) return [];
|
|
47454
|
+
const out2 = [];
|
|
47455
|
+
const ids = /* @__PURE__ */ new Set();
|
|
47456
|
+
for (const p of raw) {
|
|
47457
|
+
if (!isRecord3(p)) return [];
|
|
47458
|
+
const { id, kind, name: name2, what } = p;
|
|
47459
|
+
if (typeof id !== "string" || !PART_ID_RE.test(id) || ids.has(id)) return [];
|
|
47460
|
+
if (typeof kind !== "string" || !PART_KINDS.includes(kind)) return [];
|
|
47461
|
+
if (typeof name2 !== "string" || name2.trim() === "" || name2.length > MAX_NAME_CHARS3) return [];
|
|
47462
|
+
if (typeof what !== "string" || what.length > MAX_WHAT_CHARS) return [];
|
|
47463
|
+
ids.add(id);
|
|
47464
|
+
out2.push({ id, kind, name: name2, what });
|
|
47465
|
+
}
|
|
47466
|
+
return out2;
|
|
47467
|
+
}
|
|
47468
|
+
function designForTargeting(design, on) {
|
|
47469
|
+
if (on && partsFromDesign(design).length > 0) return { design, partsCheck: true };
|
|
47470
|
+
if (!design || !Object.prototype.hasOwnProperty.call(design, "parts")) return { design, partsCheck: false };
|
|
47471
|
+
const { parts: _parts, ...rest } = design;
|
|
47472
|
+
void _parts;
|
|
47473
|
+
return { design: rest, partsCheck: false };
|
|
47474
|
+
}
|
|
47475
|
+
function markedParts(targets) {
|
|
47476
|
+
const marked = /* @__PURE__ */ new Map();
|
|
47477
|
+
for (const t of targets) {
|
|
47478
|
+
for (const step of t.planStepsImplemented ?? []) {
|
|
47479
|
+
if (typeof step !== "string") continue;
|
|
47480
|
+
for (const m of step.matchAll(MARKER_RE)) {
|
|
47481
|
+
const paths = marked.get(m[1]) ?? [];
|
|
47482
|
+
if (!paths.includes(t.path)) paths.push(t.path);
|
|
47483
|
+
marked.set(m[1], paths);
|
|
47484
|
+
}
|
|
47485
|
+
}
|
|
47486
|
+
}
|
|
47487
|
+
return marked;
|
|
47488
|
+
}
|
|
47489
|
+
function words(text3) {
|
|
47490
|
+
return text3.trim().replace(/\s+/g, " ").replace(/[\s.;:,]+$/, "");
|
|
47491
|
+
}
|
|
47492
|
+
var STORED_STOP_START = "This feature needs a stored value QuikPilot cannot add here:";
|
|
47493
|
+
var NOT_PLACED_START = "No file was planned for a part of the feature:";
|
|
47494
|
+
var PART_MISSING_START = "A part of the feature was not built:";
|
|
47495
|
+
function storedSentence(stored) {
|
|
47496
|
+
const listed = stored.map((p) => `${words(p.name)} \u2014 ${words(p.what)}`).join("; ");
|
|
47497
|
+
return stored.length === 1 ? `${STORED_STOP_START} ${listed}. Add the field and its migration first, or narrow the feature.` : `${STORED_STOP_START} ${listed}. Add each field and its migration first, or narrow the feature.`;
|
|
47498
|
+
}
|
|
47499
|
+
function notPlacedSentence(parts2) {
|
|
47500
|
+
const listed = parts2.map((p) => `${p.id} ${words(p.name)} (${p.kind})`).join("; ");
|
|
47501
|
+
return `${NOT_PLACED_START} ${listed}. Nothing was written. Run it again, or narrow the feature.`;
|
|
47502
|
+
}
|
|
47503
|
+
function afterTargeting(parts2, targets) {
|
|
47504
|
+
if (parts2.length === 0) return null;
|
|
47505
|
+
const marked = markedParts(targets);
|
|
47506
|
+
const unplaced = parts2.filter((p) => !marked.has(p.id));
|
|
47507
|
+
if (unplaced.length === 0) return null;
|
|
47508
|
+
const stored = unplaced.filter((p) => p.kind === "stored");
|
|
47509
|
+
if (stored.length > 0) return { reason: "needs_database_change", ids: stored.map((p) => p.id), sentence: storedSentence(stored) };
|
|
47510
|
+
return { reason: "part_not_placed", ids: unplaced.map((p) => p.id), sentence: notPlacedSentence(unplaced) };
|
|
47511
|
+
}
|
|
47512
|
+
var PartsStopError = class extends Error {
|
|
47513
|
+
reason;
|
|
47514
|
+
ids;
|
|
47515
|
+
constructor(stop2) {
|
|
47516
|
+
super(stop2.sentence);
|
|
47517
|
+
this.name = "PartsStopError";
|
|
47518
|
+
this.reason = stop2.reason;
|
|
47519
|
+
this.ids = [...stop2.ids];
|
|
47520
|
+
}
|
|
47521
|
+
};
|
|
47522
|
+
function partsForCode(parts2, targets) {
|
|
47523
|
+
const marked = markedParts(targets);
|
|
47524
|
+
return parts2.map((p) => ({ id: p.id, kind: p.kind, name: p.name, paths: marked.get(p.id) ?? [] }));
|
|
47525
|
+
}
|
|
47526
|
+
function methodOf(name2) {
|
|
47527
|
+
const m = ROUTE_METHOD_RE.exec(name2);
|
|
47528
|
+
return m && m[1] === m[1].toUpperCase() ? m[1] : void 0;
|
|
47529
|
+
}
|
|
47530
|
+
function routeIsThePart(name2, mention) {
|
|
47531
|
+
const method = methodOf(name2);
|
|
47532
|
+
if (method && mention.method !== method) return false;
|
|
47533
|
+
const path = ROUTE_PATH_RE.exec(name2)?.[0]?.replace(/:+$/, "");
|
|
47534
|
+
if (!path) return true;
|
|
47535
|
+
return surfaceCovers(`${mention.method} ${path}`, mention);
|
|
47536
|
+
}
|
|
47537
|
+
function lastFixedSegment(name2) {
|
|
47538
|
+
const path = ROUTE_PATH_RE.exec(name2)?.[0]?.replace(/:+$/, "");
|
|
47539
|
+
if (!path) return void 0;
|
|
47540
|
+
const fixed = path.split("/").filter((s) => s && !/^[:{[]/.test(s));
|
|
47541
|
+
return fixed.length ? fixed[fixed.length - 1].toLowerCase() : void 0;
|
|
47542
|
+
}
|
|
47543
|
+
var EXPORTED_HANDLER_RE = /\bexport\s+(?:const|let|(?:async\s+)?function)\s+(GET|POST|PUT|PATCH|DELETE)\b/;
|
|
47544
|
+
function looseRouteIsThePart(name2, filePath, added) {
|
|
47545
|
+
const method = methodOf(name2);
|
|
47546
|
+
const segment = lastFixedSegment(name2);
|
|
47547
|
+
const hasSegment = (text3) => segment === void 0 || new RegExp(`(^|[^A-Za-z0-9_])${segment.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")}([^A-Za-z0-9_]|$)`, "i").test(text3);
|
|
47548
|
+
const exported = EXPORTED_HANDLER_RE.exec(added);
|
|
47549
|
+
if (exported && (!method || exported[1] === method) && hasSegment(filePath.replace(/\\/g, "/"))) return true;
|
|
47550
|
+
if (segment === void 0) return false;
|
|
47551
|
+
const methodSaid = !method || new RegExp(`\\b${method}\\b`, "i").test(added);
|
|
47552
|
+
return methodSaid && hasSegment(added);
|
|
47553
|
+
}
|
|
47554
|
+
function missingAtDone(parts2, changed, addedLinesOf, isTest) {
|
|
47555
|
+
const changedSet = new Set(changed);
|
|
47556
|
+
const missing = [];
|
|
47557
|
+
for (const part of parts2) {
|
|
47558
|
+
const built = part.paths.filter((p) => changedSet.has(p) && !isTest(p));
|
|
47559
|
+
if (built.length === 0) {
|
|
47560
|
+
missing.push({ part, why: "unchanged" });
|
|
47561
|
+
continue;
|
|
47562
|
+
}
|
|
47563
|
+
if (part.kind === "endpoint" && !built.some((p) => {
|
|
47564
|
+
const added = addedLinesOf(p) ?? "";
|
|
47565
|
+
return detectMentions(added).some((m) => routeIsThePart(part.name, m)) || looseRouteIsThePart(part.name, p, added);
|
|
47566
|
+
})) {
|
|
47567
|
+
missing.push({ part, why: "no_route" });
|
|
47568
|
+
}
|
|
47569
|
+
}
|
|
47570
|
+
return missing;
|
|
47571
|
+
}
|
|
47572
|
+
var PARTS_MESSAGE = "Your answer was sent back: the approved design lists parts this feature needs, and your change does not build each one yet. Each sentence names a part and the files the plan chose for it. This check is made once.";
|
|
47573
|
+
function withFiles(build, paths) {
|
|
47574
|
+
for (let k = paths.length; k >= 1; k--) {
|
|
47575
|
+
const files = k === paths.length ? paths.join(", ") : `${paths.slice(0, k).join(", ")} and ${paths.length - k} more`;
|
|
47576
|
+
const sentence = build(files);
|
|
47577
|
+
if (sentence.length <= MAX_REFUSED_SENTENCE_CHARS) return sentence;
|
|
47578
|
+
}
|
|
47579
|
+
return build(paths.length > 0 ? paths[0] : "no file").slice(0, MAX_REFUSED_SENTENCE_CHARS);
|
|
47580
|
+
}
|
|
47581
|
+
function partSentence(m) {
|
|
47582
|
+
const head = `Part ${m.part.id} (${m.part.kind}) "${words(m.part.name)}" is not built: `;
|
|
47583
|
+
return m.why === "no_route" ? withFiles((files) => `${head}no route line for it was added in ${files}. Add the route there.`, m.part.paths) : withFiles((files) => `${head}none of its planned files was changed (${files}). Build it there.`, m.part.paths);
|
|
47584
|
+
}
|
|
47585
|
+
function partsAnswer(missing) {
|
|
47586
|
+
return { rules: ["done_rule"], violations: missing.slice(0, MAX_REFUSED_SENTENCES).map(partSentence), message: PARTS_MESSAGE };
|
|
47587
|
+
}
|
|
47588
|
+
function partMissingSentence(missing) {
|
|
47589
|
+
const item = (m, short) => {
|
|
47590
|
+
const paths = m.part.paths;
|
|
47591
|
+
const files = paths.length === 0 ? "no file" : short && paths.length > 1 ? `${paths[0]} and ${paths.length - 1} more` : paths.join(", ");
|
|
47592
|
+
return `${m.part.id} ${words(m.part.name)} (${m.part.kind}, ${m.why === "no_route" ? "no route added in" : "planned in"} ${files})`;
|
|
47593
|
+
};
|
|
47594
|
+
const fits = (s) => s.length <= MAX_REFUSED_SENTENCE_CHARS;
|
|
47595
|
+
for (const short of [false, true]) {
|
|
47596
|
+
const all = `${PART_MISSING_START} ${missing.map((m) => item(m, short)).join("; ")}.`;
|
|
47597
|
+
if (fits(all)) return all;
|
|
47598
|
+
}
|
|
47599
|
+
for (let k = missing.length - 1; k >= 1; k--) {
|
|
47600
|
+
const some = `${PART_MISSING_START} ${missing.slice(0, k).map((m) => item(m, true)).join("; ")}; and ${missing.length - k} more.`;
|
|
47601
|
+
if (fits(some)) return some;
|
|
47602
|
+
}
|
|
47603
|
+
return `${PART_MISSING_START} ${missing[0] ? item(missing[0], true) : ""}`.slice(0, MAX_REFUSED_SENTENCE_CHARS);
|
|
47604
|
+
}
|
|
47605
|
+
|
|
47360
47606
|
// src/codegenLoop.ts
|
|
47361
47607
|
var CODEGEN_LOOP_CONTRACT_VERSION = "codegen-loop-1";
|
|
47362
47608
|
var CODEGEN_LOOP_2_CONTRACT_VERSION = "codegen-loop-2";
|
|
@@ -47601,6 +47847,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47601
47847
|
const redRuns = [];
|
|
47602
47848
|
let redRefusals = 0;
|
|
47603
47849
|
let importRefusals = 0;
|
|
47850
|
+
let partRefusals = 0;
|
|
47604
47851
|
let proofSendBacks = 0;
|
|
47605
47852
|
let giveUpRefusals = 0;
|
|
47606
47853
|
let redUnproven;
|
|
@@ -48104,6 +48351,36 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48104
48351
|
throw new CodegenLoopFailure("syntax_error", void 0, void 0, sentence, sentence.slice(0, MAX_PREVIOUS_DETAIL_CHARS));
|
|
48105
48352
|
}
|
|
48106
48353
|
}
|
|
48354
|
+
if (args2.phase === "code" && args2.parts && args2.parts.length > 0) {
|
|
48355
|
+
const missingParts = missingAtDone(
|
|
48356
|
+
args2.parts,
|
|
48357
|
+
overlay.changedPaths(),
|
|
48358
|
+
(p) => {
|
|
48359
|
+
const entry = overlay.get(p);
|
|
48360
|
+
if (!entry) return null;
|
|
48361
|
+
return entry.created || entry.originalLf === null ? entry.lf : addedLines(entry.originalLf, entry.lf);
|
|
48362
|
+
},
|
|
48363
|
+
looksLikeTest
|
|
48364
|
+
);
|
|
48365
|
+
if (missingParts.length > 0) {
|
|
48366
|
+
const ids = missingParts.map((m) => m.part.id);
|
|
48367
|
+
if (partRefusals < 1 && !isFinal) {
|
|
48368
|
+
partRefusals += 1;
|
|
48369
|
+
const answer = partsAnswer(missingParts);
|
|
48370
|
+
refusedStreak += 1;
|
|
48371
|
+
refusedTurns.push({ turn, rules: answer.rules });
|
|
48372
|
+
log({ event: "codegen.parts_check", turn, outcome: "sent", parts: args2.parts.length, missing: missingParts.length, ids });
|
|
48373
|
+
transcript.push({ turn, toolCalls: [], refused: answer });
|
|
48374
|
+
if (refusedStreak >= REFUSED_STREAK_LIMIT) forced = "refused_repeatedly";
|
|
48375
|
+
forced = settleNextTurn(turn, forced);
|
|
48376
|
+
continue;
|
|
48377
|
+
}
|
|
48378
|
+
log({ event: "codegen.parts_check", turn, outcome: "missing", parts: args2.parts.length, missing: missingParts.length, ids });
|
|
48379
|
+
const sentence = partMissingSentence(missingParts);
|
|
48380
|
+
throw new CodegenLoopFailure("part_missing", void 0, void 0, sentence, sentence.slice(0, MAX_PREVIOUS_DETAIL_CHARS));
|
|
48381
|
+
}
|
|
48382
|
+
log({ event: "codegen.parts_check", turn, outcome: "ok", parts: args2.parts.length });
|
|
48383
|
+
}
|
|
48107
48384
|
const doneSummary = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : "";
|
|
48108
48385
|
const lane = args2.lane;
|
|
48109
48386
|
if (harness && args2.phase === "code" && lane?.kind === "code" && !lane.amend && args2.keepOnGiveUp === true) {
|
|
@@ -48420,6 +48697,7 @@ async function runPhases(i3) {
|
|
|
48420
48697
|
lane: { kind: "code", testPaths: i3.testPaths, frozen: tests.frozen },
|
|
48421
48698
|
seed: tests.results,
|
|
48422
48699
|
...tests.proposals ? { seedProposals: tests.proposals } : {},
|
|
48700
|
+
...i3.parts && i3.parts.length > 0 ? { parts: i3.parts } : {},
|
|
48423
48701
|
keepOnGiveUp: true,
|
|
48424
48702
|
previousAttempt: keptChange(i3.attempt, "tests_written", tests.answer, tests.steps)
|
|
48425
48703
|
});
|
|
@@ -48740,7 +49018,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
48740
49018
|
}
|
|
48741
49019
|
|
|
48742
49020
|
// src/codegenLoopContext.ts
|
|
48743
|
-
var
|
|
49021
|
+
var import_node_fs17 = require("node:fs");
|
|
48744
49022
|
|
|
48745
49023
|
// src/langReach.ts
|
|
48746
49024
|
var import_node_path19 = require("node:path");
|
|
@@ -49122,8 +49400,8 @@ function pairedTestPaths(codePath, listing, isTest = isTestTarget) {
|
|
|
49122
49400
|
const stem = m[1].toLowerCase();
|
|
49123
49401
|
const dir = dirOf2(codePath);
|
|
49124
49402
|
const parent = parentOf(dir);
|
|
49125
|
-
const
|
|
49126
|
-
const homes = /* @__PURE__ */ new Set([dir,
|
|
49403
|
+
const join17 = (d, leaf) => d === "" ? leaf : `${d}/${leaf}`;
|
|
49404
|
+
const homes = /* @__PURE__ */ new Set([dir, join17(dir, "__tests__"), join17(parent, "__tests__"), join17(parent, "tests"), join17(parent, "test")]);
|
|
49127
49405
|
const found = [];
|
|
49128
49406
|
for (const path of listing) {
|
|
49129
49407
|
if (!homes.has(dirOf2(path))) continue;
|
|
@@ -49136,7 +49414,7 @@ function asLf(text3) {
|
|
|
49136
49414
|
return toLf(text3.charCodeAt(0) === 65279 ? text3.slice(1) : text3);
|
|
49137
49415
|
}
|
|
49138
49416
|
function collectLoopContext(p) {
|
|
49139
|
-
const readFile = p.readFile ?? ((path) => (0,
|
|
49417
|
+
const readFile = p.readFile ?? ((path) => (0, import_node_fs17.readFileSync)(path, "utf8"));
|
|
49140
49418
|
const listing = new Set(p.listing);
|
|
49141
49419
|
const mapSpecifier = p.mapSpecifier ?? createAliasMapper({
|
|
49142
49420
|
readText: (path) => {
|
|
@@ -49303,7 +49581,7 @@ function mapModeMessage(phase, reason) {
|
|
|
49303
49581
|
}
|
|
49304
49582
|
|
|
49305
49583
|
// src/testsToCheck.ts
|
|
49306
|
-
var
|
|
49584
|
+
var import_node_fs18 = require("node:fs");
|
|
49307
49585
|
var import_node_path20 = require("node:path");
|
|
49308
49586
|
var MAX_TESTS_TO_CHECK = 10;
|
|
49309
49587
|
var SECOND_HOP_BELOW = 3;
|
|
@@ -49355,7 +49633,7 @@ function testsToCheck(i3) {
|
|
|
49355
49633
|
}
|
|
49356
49634
|
var readFromRoot = (root) => (rel) => {
|
|
49357
49635
|
try {
|
|
49358
|
-
return (0,
|
|
49636
|
+
return (0, import_node_fs18.readFileSync)((0, import_node_path20.join)(root, rel), "utf8");
|
|
49359
49637
|
} catch {
|
|
49360
49638
|
return null;
|
|
49361
49639
|
}
|
|
@@ -49544,9 +49822,10 @@ function keptAttempt(n, summary) {
|
|
|
49544
49822
|
}
|
|
49545
49823
|
var keptWarning = (n) => `The ${n === 1 ? "first" : "second"} attempt said it could not finish, but its change passed every check the AI is held to apart from the project's tests, so QuikPilot kept it and let the checks decide.`;
|
|
49546
49824
|
var failedAttempt = failedAttemptRecord;
|
|
49547
|
-
function lose(p, summary, attempts, stop2, unreportable) {
|
|
49825
|
+
function lose(p, summary, attempts, stop2, unreportable, failures = []) {
|
|
49548
49826
|
p.out.loop = buildCodegenLoopRecord({ ...summary ?? NO_SUMMARY, stopReason: stop2, attempts });
|
|
49549
|
-
|
|
49827
|
+
const partsMissing = [...failures].reverse().find((f) => f.reason === "part_missing")?.detail;
|
|
49828
|
+
return new CodegenAttemptsExhausted(attempts, stop2, unreportable, partsMissing);
|
|
49550
49829
|
}
|
|
49551
49830
|
function oldCodeRunner(args2, log, now, wholeSuite = false) {
|
|
49552
49831
|
return async (files) => {
|
|
@@ -49636,6 +49915,7 @@ async function runCodegenStep(p) {
|
|
|
49636
49915
|
testPaths: testTargetPaths(p.targets, discoveredTestsOf(p.testDiscovery)),
|
|
49637
49916
|
redCheckIds: checkableIds(args2.requiredAutomationIds, p.requiredTestTypes),
|
|
49638
49917
|
...p.redReview === true ? { redReview: true } : {},
|
|
49918
|
+
...p.parts && p.parts.length > 0 ? { parts: p.parts } : {},
|
|
49639
49919
|
run: (a) => runCodegenLoop(a, loopDeps),
|
|
49640
49920
|
...args2.tests ? { onOldCode: oldCodeRunner(args2, log, now) } : {},
|
|
49641
49921
|
log
|
|
@@ -49752,14 +50032,14 @@ async function runCodegenStep(p) {
|
|
|
49752
50032
|
}
|
|
49753
50033
|
await guardTree();
|
|
49754
50034
|
const firstRecord = failedAttempt(1, f1);
|
|
49755
|
-
if ("final" in first && first.final) throw lose(p, f1.summary, [firstRecord], "failed");
|
|
50035
|
+
if ("final" in first && first.final) throw lose(p, f1.summary, [firstRecord], "failed", void 0, [f1]);
|
|
49756
50036
|
if (f1.reason === "test_conflict_unreportable") throw lose(p, f1.summary, [firstRecord], "failed", f1.unreportable);
|
|
49757
50037
|
const testLimit = p.mode === "loop-tests" && p.tests ? await oneTestRunMs(p.tests) : null;
|
|
49758
50038
|
const left = hardStopAtMs - now();
|
|
49759
50039
|
const needed = secondAttemptFloorMs({ firstAttemptMs: firstMs, testLimitMs: testLimit });
|
|
49760
50040
|
if (f1.reason === "out_of_time" || left < needed) {
|
|
49761
50041
|
log({ event: "codegen.attempt_skipped", attempt: 2, reason: "out_of_time", leftMs: Math.max(0, left), neededMs: needed });
|
|
49762
|
-
throw lose(p, f1.summary, [firstRecord, { n: 2, outcome: "not_started", reason: "out_of_time", turns: 0, toolCalls: 0 }], "out_of_time");
|
|
50042
|
+
throw lose(p, f1.summary, [firstRecord, { n: 2, outcome: "not_started", reason: "out_of_time", turns: 0, toolCalls: 0 }], "out_of_time", void 0, [f1]);
|
|
49763
50043
|
}
|
|
49764
50044
|
warn(p, `The first attempt at writing the change ended (${f1.reason}${said}), so QuikPilot is trying once more.`);
|
|
49765
50045
|
const previous = { ...previousAttemptFrom(f1, 1), ...f1.steps && f1.steps.steps.length > 0 ? f1.steps : {} };
|
|
@@ -49785,11 +50065,11 @@ async function runCodegenStep(p) {
|
|
|
49785
50065
|
}
|
|
49786
50066
|
const f2 = second.failure;
|
|
49787
50067
|
log({ event: "codegen.attempt_end", attempt: 2, outcome: "failed", reason: f2.reason, ...f2.afterRecovery ? { afterRecovery: true } : {}, turns: f2.summary?.turns ?? 0, toolCalls: f2.summary?.toolCalls ?? 0, durationMs: secondMs });
|
|
49788
|
-
throw lose(p, f2.summary, [firstRecord, failedAttempt(2, f2)], f2.reason === "out_of_time" ? "out_of_time" : "failed", f2.unreportable);
|
|
50068
|
+
throw lose(p, f2.summary, [firstRecord, failedAttempt(2, f2)], f2.reason === "out_of_time" ? "out_of_time" : "failed", f2.unreportable, [f1, f2]);
|
|
49789
50069
|
}
|
|
49790
50070
|
|
|
49791
50071
|
// src/codegenHeal.ts
|
|
49792
|
-
var
|
|
50072
|
+
var import_node_fs19 = require("node:fs");
|
|
49793
50073
|
|
|
49794
50074
|
// src/heal.ts
|
|
49795
50075
|
var MAX_ATTEMPTS_IN_ALL = 3;
|
|
@@ -49869,7 +50149,7 @@ async function runHealAttempt(i3) {
|
|
|
49869
50149
|
const created = i3.results.map((r) => r.targetPath).filter((path) => !listed.has(path));
|
|
49870
50150
|
const workspaceListing = [...p.workspaceListing, ...created];
|
|
49871
50151
|
const targets = p.targets.map((t) => t.kind === "NEW_FILE" && keptText.has(t.path) ? { ...t, kind: "EXISTING" } : t);
|
|
49872
|
-
const disk = p.readFile ?? ((path) => (0,
|
|
50152
|
+
const disk = p.readFile ?? ((path) => (0, import_node_fs19.readFileSync)(path, "utf8"));
|
|
49873
50153
|
const readFile = (path) => keptText.get(path) ?? disk(path);
|
|
49874
50154
|
const discoveredTests = discoveredTestsOf(p.testDiscovery);
|
|
49875
50155
|
const context = collectLoopContext({ targets, listing: workspaceListing, deniedPaths: p.deniedPaths, writeRoot: p.writeRoot ?? "", ...discoveredTests ? { discoveredTests } : {}, readFile });
|
|
@@ -50133,74 +50413,6 @@ async function runVerifyAndFix(p) {
|
|
|
50133
50413
|
var import_node_child_process9 = require("node:child_process");
|
|
50134
50414
|
var import_node_fs20 = require("node:fs");
|
|
50135
50415
|
var import_node_path21 = require("node:path");
|
|
50136
|
-
|
|
50137
|
-
// src/scopeCheck.ts
|
|
50138
|
-
var import_node_fs19 = require("node:fs");
|
|
50139
|
-
var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
|
|
50140
|
-
var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
|
|
50141
|
-
var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
|
|
50142
|
-
var NO_PATH = "(this file's route)";
|
|
50143
|
-
function detectMentions(text3) {
|
|
50144
|
-
const found = [];
|
|
50145
|
-
for (const line of text3.split("\n")) {
|
|
50146
|
-
const methodMatch = ROUTE_METHOD_RE.exec(line);
|
|
50147
|
-
const pathMatch = ROUTE_PATH_RE.exec(line);
|
|
50148
|
-
if (methodMatch && pathMatch) {
|
|
50149
|
-
found.push({ method: methodMatch[1].toUpperCase(), path: pathMatch[0].replace(/:+$/, "") });
|
|
50150
|
-
}
|
|
50151
|
-
const exportMatch = ROUTE_EXPORT_RE.exec(line);
|
|
50152
|
-
if (exportMatch) {
|
|
50153
|
-
found.push({ method: exportMatch[1].toUpperCase(), path: NO_PATH });
|
|
50154
|
-
}
|
|
50155
|
-
}
|
|
50156
|
-
return found;
|
|
50157
|
-
}
|
|
50158
|
-
function normalizePath(path) {
|
|
50159
|
-
return path.replace(/:[A-Za-z0-9_]+|\{[^}]+\}|\[[^\]]+\]/g, "*");
|
|
50160
|
-
}
|
|
50161
|
-
function surfaceCovers(surface, mention) {
|
|
50162
|
-
if (!new RegExp(`\\b${mention.method}\\b`, "i").test(surface)) return false;
|
|
50163
|
-
if (mention.path === NO_PATH) return true;
|
|
50164
|
-
const declaredPath = normalizePath(surface);
|
|
50165
|
-
const mentionPath = normalizePath(mention.path);
|
|
50166
|
-
return declaredPath.includes(mentionPath) || mentionPath.includes(declaredPath);
|
|
50167
|
-
}
|
|
50168
|
-
function addedLines(before, after) {
|
|
50169
|
-
const beforeLines = new Set(before.split("\n"));
|
|
50170
|
-
return after.split("\n").filter((line) => !beforeLines.has(line)).join("\n");
|
|
50171
|
-
}
|
|
50172
|
-
function checkApiScope(results, targets, apiChanges) {
|
|
50173
|
-
const targetsByPath = new Map(targets.map((t) => [t.path, t]));
|
|
50174
|
-
const violations = [];
|
|
50175
|
-
for (const { targetPath, newContent } of results) {
|
|
50176
|
-
if (isTestFile(targetPath)) continue;
|
|
50177
|
-
const target = targetsByPath.get(targetPath);
|
|
50178
|
-
const isNewFile = target?.kind === "NEW_FILE";
|
|
50179
|
-
let scanned;
|
|
50180
|
-
if (isNewFile) {
|
|
50181
|
-
scanned = newContent;
|
|
50182
|
-
} else {
|
|
50183
|
-
let currentContent;
|
|
50184
|
-
try {
|
|
50185
|
-
currentContent = (0, import_node_fs19.readFileSync)(targetPath, "utf8");
|
|
50186
|
-
} catch {
|
|
50187
|
-
currentContent = "";
|
|
50188
|
-
}
|
|
50189
|
-
scanned = addedLines(currentContent, newContent);
|
|
50190
|
-
}
|
|
50191
|
-
for (const mention of detectMentions(scanned)) {
|
|
50192
|
-
if (!apiChanges.some((c) => surfaceCovers(c.surface, mention))) {
|
|
50193
|
-
violations.push({ file: targetPath, method: mention.method, path: mention.path });
|
|
50194
|
-
}
|
|
50195
|
-
}
|
|
50196
|
-
}
|
|
50197
|
-
return { blocked: violations.length > 0, violations };
|
|
50198
|
-
}
|
|
50199
|
-
function describeScopeViolations(check) {
|
|
50200
|
-
return check.violations.map((v) => `${v.file} adds ${v.method} ${v.path}, not declared in the design's API changes`).join("; ");
|
|
50201
|
-
}
|
|
50202
|
-
|
|
50203
|
-
// src/hunkCheck.ts
|
|
50204
50416
|
var MAX_REPORTED_HUNKS = 20;
|
|
50205
50417
|
function toFinding(r) {
|
|
50206
50418
|
if (r.unnecessary.length === 0) return void 0;
|
|
@@ -50759,7 +50971,7 @@ function describeAutomationCoverageViolations(check) {
|
|
|
50759
50971
|
var estraverse5 = __toESM2(require_estraverse());
|
|
50760
50972
|
var MAX_UNSUPPLIED_ENTRIES = 10;
|
|
50761
50973
|
var MAX_UNSUPPLIED_NAMES = 5;
|
|
50762
|
-
var
|
|
50974
|
+
var MAX_NAME_CHARS4 = 80;
|
|
50763
50975
|
var MAX_FUNCTION_CHARS = 120;
|
|
50764
50976
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
|
|
50765
50977
|
var IDENTIFIER_NAME = /^[A-Za-z_$][\w$]*$/;
|
|
@@ -50900,7 +51112,7 @@ function findUnsuppliedInputs(input) {
|
|
|
50900
51112
|
if (isCallback(site)) continue;
|
|
50901
51113
|
const names = [];
|
|
50902
51114
|
for (const { name: name2 } of readsOf(site)) {
|
|
50903
|
-
if (!IDENTIFIER_NAME.test(name2) || name2.length >
|
|
51115
|
+
if (!IDENTIFIER_NAME.test(name2) || name2.length > MAX_NAME_CHARS4) continue;
|
|
50904
51116
|
if (known.has(name2) || supplied.has(name2) || names.includes(name2)) continue;
|
|
50905
51117
|
names.push(name2);
|
|
50906
51118
|
}
|
|
@@ -51183,6 +51395,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
51183
51395
|
}
|
|
51184
51396
|
|
|
51185
51397
|
// src/guardrail.ts
|
|
51398
|
+
var MAX_LEFT_OUT_NAMES2 = 10;
|
|
51186
51399
|
function checkGuardrail(deniedPaths, writeRoot = "") {
|
|
51187
51400
|
addAll(writeRoot || void 0);
|
|
51188
51401
|
const violations = deniedPaths.flatMap((pattern) => diffCachedNamesMatching(pattern));
|
|
@@ -51190,11 +51403,15 @@ function checkGuardrail(deniedPaths, writeRoot = "") {
|
|
|
51190
51403
|
throw new Error(`QuikPilot touched denied paths:
|
|
51191
51404
|
${violations.join("\n")}`);
|
|
51192
51405
|
}
|
|
51193
|
-
return { leftOut:
|
|
51406
|
+
if (!writeRoot) return { leftOut: 0, names: [], hidden: 0 };
|
|
51407
|
+
const outside = changedOutside(writeRoot);
|
|
51408
|
+
const protectedPatterns = readDenied(deniedPaths);
|
|
51409
|
+
const nameable = outside.filter((path) => matchesDeniedPath(path, protectedPatterns) === null);
|
|
51410
|
+
return { leftOut: outside.length, names: nameable.slice(0, MAX_LEFT_OUT_NAMES2), hidden: outside.length - nameable.length };
|
|
51194
51411
|
}
|
|
51195
51412
|
|
|
51196
51413
|
// src/run.ts
|
|
51197
|
-
var
|
|
51414
|
+
var import_node_fs27 = require("node:fs");
|
|
51198
51415
|
|
|
51199
51416
|
// src/mapMode.ts
|
|
51200
51417
|
var MAP_ENV = "QUIKPILOT_MAP";
|
|
@@ -51768,7 +51985,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
51768
51985
|
var REPORT_COPY = "final-test-report.xml";
|
|
51769
51986
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
51770
51987
|
var MAX_FILES = 200;
|
|
51771
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
51988
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.71" : "dev";
|
|
51772
51989
|
function safeDestination(base, repoPath) {
|
|
51773
51990
|
if (!repoPath || (0, import_node_path26.isAbsolute)(repoPath)) return null;
|
|
51774
51991
|
const destination = (0, import_node_path26.resolve)(base, repoPath);
|
|
@@ -51849,6 +52066,35 @@ function writeFailureArtifact(input) {
|
|
|
51849
52066
|
}
|
|
51850
52067
|
}
|
|
51851
52068
|
|
|
52069
|
+
// src/finalChange.ts
|
|
52070
|
+
var import_node_child_process12 = require("node:child_process");
|
|
52071
|
+
var import_node_fs26 = require("node:fs");
|
|
52072
|
+
var import_node_path27 = require("node:path");
|
|
52073
|
+
function changesAgainstBase(root, wanted) {
|
|
52074
|
+
if (wanted.size === 0) return [];
|
|
52075
|
+
const status = (0, import_node_child_process12.execFileSync)("git", ["status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
|
|
52076
|
+
cwd: root,
|
|
52077
|
+
encoding: "utf8",
|
|
52078
|
+
maxBuffer: 64 * 1024 * 1024
|
|
52079
|
+
});
|
|
52080
|
+
const changed = new Set(
|
|
52081
|
+
status.split("\0").filter((entry) => entry.length > 3).map((entry) => entry.slice(3))
|
|
52082
|
+
);
|
|
52083
|
+
const out2 = [];
|
|
52084
|
+
for (const path of [...wanted].sort()) {
|
|
52085
|
+
if (!changed.has(path)) continue;
|
|
52086
|
+
let current2;
|
|
52087
|
+
try {
|
|
52088
|
+
current2 = (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(root, path), "utf8").replace(/\r\n/g, "\n");
|
|
52089
|
+
} catch {
|
|
52090
|
+
continue;
|
|
52091
|
+
}
|
|
52092
|
+
const base = readCommittedText(root, path);
|
|
52093
|
+
out2.push({ path, added: base === null ? current2 : addedLines(base.replace(/\r\n/g, "\n"), current2) });
|
|
52094
|
+
}
|
|
52095
|
+
return out2;
|
|
52096
|
+
}
|
|
52097
|
+
|
|
51852
52098
|
// src/testDiscovery.ts
|
|
51853
52099
|
var ABSENT = { report: "ABSENT" };
|
|
51854
52100
|
var DRIVE_RE = /^[A-Za-z]:\//;
|
|
@@ -51962,12 +52208,12 @@ async function resolveTestDiscovery(i3) {
|
|
|
51962
52208
|
}
|
|
51963
52209
|
|
|
51964
52210
|
// src/targetingFindings.ts
|
|
51965
|
-
var
|
|
52211
|
+
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
51966
52212
|
function prepareTargetingFindings(raw, listing, deniedPaths) {
|
|
51967
|
-
if (!
|
|
52213
|
+
if (!isRecord4(raw)) return void 0;
|
|
51968
52214
|
const { verdict, files, callPath, evidence, searches } = raw;
|
|
51969
52215
|
if (typeof verdict !== "string" || !Array.isArray(files) || !Array.isArray(callPath) || !Array.isArray(evidence)) return void 0;
|
|
51970
|
-
const keep = (entry) =>
|
|
52216
|
+
const keep = (entry) => isRecord4(entry) && typeof entry.path === "string" && listing.has(entry.path) && matchesDeniedPath(entry.path, deniedPaths) === null;
|
|
51971
52217
|
const kept = {
|
|
51972
52218
|
files: files.filter(keep),
|
|
51973
52219
|
callPath: callPath.filter(keep),
|
|
@@ -52021,7 +52267,7 @@ function validateTarget(target, workspaceRoot, workspaceListing, deniedPaths) {
|
|
|
52021
52267
|
);
|
|
52022
52268
|
}
|
|
52023
52269
|
}
|
|
52024
|
-
function buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings) {
|
|
52270
|
+
function buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false) {
|
|
52025
52271
|
const contextData = {
|
|
52026
52272
|
// NESTED, NOT FLATTENED — a second vocabulary for the design shape is exactly what
|
|
52027
52273
|
// QUIKTR-1034 cost.
|
|
@@ -52044,6 +52290,9 @@ function buildContextData(design, workspaceListing, requiredTests, deniedPaths,
|
|
|
52044
52290
|
if (findings) {
|
|
52045
52291
|
contextData.findings = findings;
|
|
52046
52292
|
}
|
|
52293
|
+
if (partsCheck) {
|
|
52294
|
+
contextData.partsCheck = true;
|
|
52295
|
+
}
|
|
52047
52296
|
return contextData;
|
|
52048
52297
|
}
|
|
52049
52298
|
async function postTargeting(gateway, contextData, signal) {
|
|
@@ -52093,14 +52342,14 @@ function finalizeTargeting(body2, workspaceRoot, workspaceListing, deniedPaths)
|
|
|
52093
52342
|
...correctedKinds.length > 0 ? { correctedKinds } : {}
|
|
52094
52343
|
};
|
|
52095
52344
|
}
|
|
52096
|
-
async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings) {
|
|
52097
|
-
const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
52345
|
+
async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false) {
|
|
52346
|
+
const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
52098
52347
|
let envelope = await postTargeting(gateway, contextData);
|
|
52099
52348
|
let warnings;
|
|
52100
52349
|
if (findings && envelope?.errorCode === "CONTRACT_REJECTED") {
|
|
52101
52350
|
envelope = await postTargeting(
|
|
52102
52351
|
gateway,
|
|
52103
|
-
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope)
|
|
52352
|
+
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck)
|
|
52104
52353
|
);
|
|
52105
52354
|
warnings = ["QuikPilot's targeting ran without the early look's findings (the AI service did not accept them)."];
|
|
52106
52355
|
}
|
|
@@ -52136,15 +52385,18 @@ async function loopWithTools2(args2, tools2, deps) {
|
|
|
52136
52385
|
}
|
|
52137
52386
|
var CODE_LIKE = /^[A-Z0-9_]{1,40}$/;
|
|
52138
52387
|
async function runTargeting(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], options = {}) {
|
|
52388
|
+
const wired = designForTargeting(design, options.partsCheck === true);
|
|
52389
|
+
design = wired.design;
|
|
52390
|
+
const partsCheck = wired.partsCheck;
|
|
52139
52391
|
if (options.scope?.view === "map") {
|
|
52140
|
-
return runMapTargeting(gateway, design, workspaceRoot, options.scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options);
|
|
52392
|
+
return runMapTargeting(gateway, design, workspaceRoot, options.scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck);
|
|
52141
52393
|
}
|
|
52142
52394
|
const mode = options.mode ?? resolveTargetingMode();
|
|
52143
52395
|
const findings = prepareTargetingFindings(options.findings, new Set(workspaceListing), deniedPaths);
|
|
52144
52396
|
if (mode !== "loop") {
|
|
52145
|
-
return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
52397
|
+
return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
52146
52398
|
}
|
|
52147
|
-
const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
52399
|
+
const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
52148
52400
|
const listingView = repoViewOf(options.scope);
|
|
52149
52401
|
let summary;
|
|
52150
52402
|
let runtimeCode;
|
|
@@ -52191,7 +52443,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
|
|
|
52191
52443
|
toolCalls: fellBack.toolCalls,
|
|
52192
52444
|
...runtimeCode && CODE_LIKE.test(runtimeCode) ? { runtimeCode } : {}
|
|
52193
52445
|
});
|
|
52194
|
-
const single = await runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
52446
|
+
const single = await runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
52195
52447
|
return {
|
|
52196
52448
|
...single,
|
|
52197
52449
|
loop: fellBack,
|
|
@@ -52204,7 +52456,7 @@ function mapTestDiscovery(testDiscovery) {
|
|
|
52204
52456
|
if (estimateTokens(JSON.stringify(testDiscovery.discoveredTestFiles, null, 2)) <= MAP_DISCOVERY_MAX_TOKENS) return testDiscovery;
|
|
52205
52457
|
return { report: "PRESENT", discoveredTestFiles: [], unmappedEntries: Math.max(1, testDiscovery.unmappedEntries + testDiscovery.discoveredTestFiles.length) };
|
|
52206
52458
|
}
|
|
52207
|
-
function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings) {
|
|
52459
|
+
function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false) {
|
|
52208
52460
|
return {
|
|
52209
52461
|
repoMap,
|
|
52210
52462
|
design,
|
|
@@ -52213,12 +52465,13 @@ function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDi
|
|
|
52213
52465
|
...deniedPaths.length > 0 ? { deniedPaths } : {},
|
|
52214
52466
|
...outOfScope.length > 0 ? { outOfScope } : {},
|
|
52215
52467
|
testDiscovery: mapTestDiscovery(testDiscovery),
|
|
52216
|
-
...findings ? { findings } : {}
|
|
52468
|
+
...findings ? { findings } : {},
|
|
52469
|
+
...partsCheck ? { partsCheck: true } : {}
|
|
52217
52470
|
};
|
|
52218
52471
|
}
|
|
52219
|
-
async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options) {
|
|
52472
|
+
async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck) {
|
|
52220
52473
|
const findings = prepareTargetingFindings(options.findings, new Set(scope.readListing), deniedPaths);
|
|
52221
|
-
const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
52474
|
+
const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
52222
52475
|
const repoView = repoViewOf(scope);
|
|
52223
52476
|
const log = options.loopDeps?.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
52224
52477
|
let reason;
|
|
@@ -52409,6 +52662,15 @@ var JOB_RESERVE_MS = 7 * 6e4;
|
|
|
52409
52662
|
var HUNK_CHECK_MAX_MS = 6 * 6e4;
|
|
52410
52663
|
var HUNK_CHECK_MIN_BUDGET_MS = 3 * 6e4;
|
|
52411
52664
|
var HUNK_CHECK_END_BEFORE_STOP_MS = 2 * 6e4;
|
|
52665
|
+
function leftOutNote(root, out2) {
|
|
52666
|
+
const names = out2.names ?? [];
|
|
52667
|
+
const hidden = out2.hidden ?? 0;
|
|
52668
|
+
const more = Math.max(0, out2.leftOut - names.length - hidden);
|
|
52669
|
+
const protectedFiles = `${hidden} protected file${hidden === 1 ? "" : "s"}`;
|
|
52670
|
+
const listed = names.length > 0 ? `${names.join(", ")}${more > 0 ? ` and ${more} more` : ""}${hidden > 0 ? ` + ${protectedFiles}` : ""}` : hidden > 0 ? `${protectedFiles}, not named${more > 0 ? `, and ${more} more` : ""}` : `${more} not named`;
|
|
52671
|
+
const head = `${out2.leftOut} changed file${out2.leftOut === 1 ? "" : "s"} outside ${root} ${out2.leftOut === 1 ? "was" : "were"} left out of the pull request`;
|
|
52672
|
+
return `${head} (changed while the project's commands ran): ${listed}.`;
|
|
52673
|
+
}
|
|
52412
52674
|
async function run2(env2) {
|
|
52413
52675
|
const runStartedAt = Date.now();
|
|
52414
52676
|
let hardFailure = false;
|
|
@@ -52456,7 +52718,7 @@ async function run2(env2) {
|
|
|
52456
52718
|
await preloadLanguages(workspaceListing);
|
|
52457
52719
|
const readCheckoutText2 = (path) => {
|
|
52458
52720
|
try {
|
|
52459
|
-
return (0,
|
|
52721
|
+
return (0, import_node_fs27.readFileSync)(path, "utf8");
|
|
52460
52722
|
} catch {
|
|
52461
52723
|
return null;
|
|
52462
52724
|
}
|
|
@@ -52487,6 +52749,9 @@ async function run2(env2) {
|
|
|
52487
52749
|
);
|
|
52488
52750
|
}
|
|
52489
52751
|
const outOfScope = (packet.outOfScope ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
52752
|
+
const partsOn = partsCheckOn();
|
|
52753
|
+
const designParts = partsOn ? partsFromDesign(packet.design) : [];
|
|
52754
|
+
if (partsOn) console.log(JSON.stringify({ event: "parts_check.on", parts: designParts.length }));
|
|
52490
52755
|
const setupStartedAt = Date.now();
|
|
52491
52756
|
runCommand(packet.commands.setup, "Setup");
|
|
52492
52757
|
if (packet.commands.setup) console.log(JSON.stringify({ event: "timing", phase: "setup", seconds: Math.round((Date.now() - setupStartedAt) / 1e3) }));
|
|
@@ -52530,7 +52795,14 @@ async function run2(env2) {
|
|
|
52530
52795
|
// QUIKTR-1580 - and the scope: in map mode it is how targeting sees the repository; since QUIKTR-1582 it is also handed over in listing
|
|
52531
52796
|
// mode, only so the record can say which folder the run could change (listing-mode targeting reads nothing else from it).
|
|
52532
52797
|
// QUIKTR-1888 - the mode the packet and the environment settle on, so the project's switch reaches the targeting step too.
|
|
52533
|
-
|
|
52798
|
+
// QUIKTR-2325 - and `partsCheck` only when the switch is on and the design has parts.
|
|
52799
|
+
{
|
|
52800
|
+
...packet.findings ? { findings: packet.findings } : {},
|
|
52801
|
+
scope,
|
|
52802
|
+
...tools2 ? { tools2 } : {},
|
|
52803
|
+
mode: resolveTargetingMode(process.env, packet.targetingMode),
|
|
52804
|
+
...designParts.length > 0 ? { partsCheck: true } : {}
|
|
52805
|
+
}
|
|
52534
52806
|
);
|
|
52535
52807
|
targetingResult = targeting;
|
|
52536
52808
|
for (const w of targeting.warnings ?? []) {
|
|
@@ -52577,6 +52849,11 @@ async function run2(env2) {
|
|
|
52577
52849
|
`QuikPilot's generated plan gives two files identical instructions \u2014 ${describeOverlapWarnings(blockingOverlaps).join("; ")}`
|
|
52578
52850
|
);
|
|
52579
52851
|
}
|
|
52852
|
+
const partsStop = afterTargeting(designParts, targeting.targets);
|
|
52853
|
+
if (partsStop) {
|
|
52854
|
+
console.log(JSON.stringify({ event: "parts_check.stop", reason: partsStop.reason, ids: partsStop.ids }));
|
|
52855
|
+
throw new PartsStopError(partsStop);
|
|
52856
|
+
}
|
|
52580
52857
|
const judgedByPool = buildJudgedByPool(
|
|
52581
52858
|
packet.requiredTests,
|
|
52582
52859
|
targeting.targets,
|
|
@@ -52597,6 +52874,8 @@ async function run2(env2) {
|
|
|
52597
52874
|
const twoPhase = twoPhaseWanted && twoPhaseSkip === null;
|
|
52598
52875
|
const redReview = twoPhase && redReviewOn();
|
|
52599
52876
|
if (redReview) console.log(JSON.stringify({ event: "red_review.on" }));
|
|
52877
|
+
const codeParts = twoPhase && designParts.length > 0 ? partsForCode(designParts, targeting.targets) : [];
|
|
52878
|
+
if (designParts.length > 0 && !twoPhase) console.log(JSON.stringify({ event: "parts_check.done_check_off", reason: "one_phase" }));
|
|
52600
52879
|
if (twoPhaseWanted && twoPhaseSkip !== null) {
|
|
52601
52880
|
warnings.push(TWO_PHASE_SKIPPED_NOTE);
|
|
52602
52881
|
console.log(JSON.stringify({ event: "two_phase.off", reason: twoPhaseSkip }));
|
|
@@ -52628,6 +52907,7 @@ async function run2(env2) {
|
|
|
52628
52907
|
...runScratch ? { runScratch } : {},
|
|
52629
52908
|
...twoPhase ? { twoPhase: true, ...packet.requiredTestTypes ? { requiredTestTypes: packet.requiredTestTypes } : {} } : {},
|
|
52630
52909
|
...redReview ? { redReview: true } : {},
|
|
52910
|
+
...codeParts.length > 0 ? { parts: codeParts } : {},
|
|
52631
52911
|
tests: {
|
|
52632
52912
|
root: process.cwd(),
|
|
52633
52913
|
command: packet.commands.test,
|
|
@@ -52789,6 +53069,15 @@ async function run2(env2) {
|
|
|
52789
53069
|
const suffix = healFailureSuffix(fixed.heal);
|
|
52790
53070
|
throw suffix ? new Error(`${final.error.message}${suffix}`) : final.error;
|
|
52791
53071
|
}
|
|
53072
|
+
if (designParts.length > 0) {
|
|
53073
|
+
const finalParts = partsForCode(designParts, targeting.targets);
|
|
53074
|
+
const changes = changesAgainstBase(process.cwd(), new Set(finalParts.flatMap((p) => p.paths)));
|
|
53075
|
+
const added = new Map(changes.map((c) => [c.path, c.added]));
|
|
53076
|
+
const missing = missingAtDone(finalParts, [...added.keys()], (p) => added.get(p) ?? null, testRule(discoveredTestsOf(codegenDiscovery)));
|
|
53077
|
+
const ids = missing.map((m) => m.part.id);
|
|
53078
|
+
console.log(JSON.stringify({ event: "parts_check.final", outcome: missing.length > 0 ? "missing" : "ok", missing: missing.length, ids }));
|
|
53079
|
+
if (missing.length > 0) throw new PartsStopError({ reason: "part_missing", ids, sentence: partMissingSentence(missing) });
|
|
53080
|
+
}
|
|
52792
53081
|
if (codegenMode === "loop-tests" && fixed.heal && fixed.heal.made > 0 && process.env.QUIKPILOT_TESTS_CORRECTED?.trim().toLowerCase() !== "off") {
|
|
52793
53082
|
try {
|
|
52794
53083
|
const files = correctedOwnTests({ kept: results, final: fixed.results, baselineOf: (path) => readCommittedText(process.cwd(), path) });
|
|
@@ -52863,9 +53152,8 @@ async function run2(env2) {
|
|
|
52863
53152
|
try {
|
|
52864
53153
|
const guarded = checkGuardrail(packet.guardrails.deniedPaths, ...scopeRoot ? [scopeRoot] : []);
|
|
52865
53154
|
if (guarded && guarded.leftOut > 0) {
|
|
52866
|
-
|
|
52867
|
-
|
|
52868
|
-
console.log(JSON.stringify({ event: "scope.left_out", count: guarded.leftOut }));
|
|
53155
|
+
warnings.push(leftOutNote(scopeRoot, guarded));
|
|
53156
|
+
console.log(JSON.stringify({ event: "scope.left_out", count: guarded.leftOut, ...guarded.hidden > 0 ? { hidden: guarded.hidden } : {} }));
|
|
52869
53157
|
}
|
|
52870
53158
|
const installationToken = await exchangeForInstallationToken(
|
|
52871
53159
|
env2.installationTokenUrl,
|
|
@@ -53023,7 +53311,7 @@ var EvidenceLedger = class {
|
|
|
53023
53311
|
return seen;
|
|
53024
53312
|
}
|
|
53025
53313
|
};
|
|
53026
|
-
function
|
|
53314
|
+
function isRecord5(x) {
|
|
53027
53315
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
53028
53316
|
}
|
|
53029
53317
|
function arrayOf(x) {
|
|
@@ -53061,7 +53349,7 @@ function capFindingsSize(findings, max = MAX_FINDINGS_CHARS) {
|
|
|
53061
53349
|
function verifyFindings(raw, ledger, ctx) {
|
|
53062
53350
|
const dropped = emptyDropped();
|
|
53063
53351
|
const redactions = emptyRedactionCounts();
|
|
53064
|
-
if (!
|
|
53352
|
+
if (!isRecord5(raw)) return { findings: emptyFindings(), downgraded: false, dropped, redactions };
|
|
53065
53353
|
const pathOk2 = (p) => typeof p === "string" && ctx.listing.has(p) && matchesDeniedPath(p, ctx.deniedPaths) === null;
|
|
53066
53354
|
const symbolsOf = (path, list2) => {
|
|
53067
53355
|
const out2 = [];
|
|
@@ -53076,7 +53364,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
53076
53364
|
};
|
|
53077
53365
|
const files = [];
|
|
53078
53366
|
for (const f of arrayOf(raw.files)) {
|
|
53079
|
-
if (!
|
|
53367
|
+
if (!isRecord5(f) || !pathOk2(f.path)) {
|
|
53080
53368
|
dropped.files += 1;
|
|
53081
53369
|
continue;
|
|
53082
53370
|
}
|
|
@@ -53086,7 +53374,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
53086
53374
|
}
|
|
53087
53375
|
const callPath = [];
|
|
53088
53376
|
for (const s of arrayOf(raw.callPath)) {
|
|
53089
|
-
const ok =
|
|
53377
|
+
const ok = isRecord5(s) && pathOk2(s.path) && typeof s.symbol === "string" && s.symbol.length > 0 && s.symbol.length <= MAX_SYMBOL_CHARS && isLine2(s.line) && ledger.hasLines(s.path, s.line, s.line) && ledger.textContains(s.path, s.symbol);
|
|
53090
53378
|
if (!ok) {
|
|
53091
53379
|
dropped.callPath += 1;
|
|
53092
53380
|
continue;
|
|
@@ -53095,7 +53383,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
53095
53383
|
}
|
|
53096
53384
|
const evidence = [];
|
|
53097
53385
|
for (const e of arrayOf(raw.evidence)) {
|
|
53098
|
-
const ok =
|
|
53386
|
+
const ok = isRecord5(e) && pathOk2(e.path) && isLine2(e.startLine) && isLine2(e.endLine) && e.startLine <= e.endLine && e.endLine - e.startLine + 1 <= MAX_EVIDENCE_LINES && ledger.hasLines(e.path, e.startLine, e.endLine);
|
|
53099
53387
|
if (!ok) {
|
|
53100
53388
|
dropped.evidence += 1;
|
|
53101
53389
|
continue;
|