@quikit/quikpilot-runner 9.3.0-rc.63 → 9.3.0-rc.65
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 -0
- package/dist/index.js +196 -29
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,6 +172,10 @@ wrong (a field that arrives from a database row or a request), so it only warns
|
|
|
172
172
|
|
|
173
173
|
**9.3.0-rc.62 - an approved test that is reported again is refused with what to do (QUIKTR-1951).** When a person has approved a change to an existing test and the AI reports that test again before the final test run (a second row of a table test that still expects the old behaviour), the answer was only `already_decided`: "Do not report it again". It now also says what the AI can do: finish the code first, and if rows of that test still fail in the final test run, the fix step that follows may report the test once more (QUIKTR-1844). Nothing about WHEN a test can be reported changes, so a person is still asked only when there is evidence; a test a person judged right, or reported in another file, keeps the bare refusal exactly. A new log event `codegen.conflict_refused_approved` (phase only) counts how often it happens. No change to the contract with the AI service. The AI Runtime's QUIKTR-1952 (a hung OpenRouter call is cut at 150 s for QuikPilot calls, so the backup model answers inside the runner's turn limit) ships with this version and needs no runner setting.
|
|
174
174
|
|
|
175
|
+
**9.3.0-rc.65 - the one correction of QuikPilot's own test now works on Python and Go (QUIKTR-2000).** When the code phase gives up because exactly one of the tests QuikPilot wrote itself still fails, it gets one chance to correct that test's expected value (QUIKTR-1608). Until now the runner recognised the failing test only by its file path, but pytest names a test by its module (`tests.test_grouping`) and gotestsum by its package, so on those languages the correction never ran: sqlparse run QTPY-15 (2 Nov) logged `frozenFailing: 0, amendFiles: 0` with exactly one of its own tests failing, and failed with no PR. Both places that match failing tests to the run's frozen tests (the amendment and the hand-over of a DONE whose own test still fails) now use the rule QUIKTR-1950 uses for the same names (`idPlaceMatches`); a path name is matched exactly as before. When several frozen files share the test's place (a Go or Java package), the one whose text defines the test is chosen, and when that is not exactly one file nothing is amended. The give-up log line also says how many failing tests the last run listed (`failingSeen`). Nothing changes on the AI Runtime or in QuikProjects; `QUIKPILOT_ROW_NAMES=js` gives back the old path-only matching. Also in rc.65: everything in rc.64.
|
|
176
|
+
|
|
177
|
+
**9.3.0-rc.64 - every re-read of a file says why it happened, and (switched off by default) the files the AI is working in are no longer shrunk while it works on them (QUIKTR-1963).** In QuikIT bug 3 (31 Oct) the AI read the same 429-line test file 28 times in 40 turns and gave up. On the notes versions an answer older than the latest three turns is shrunk to a one-line stub on every turn, whatever the request's size, with no exception for the file being worked on; but some re-reads came one turn later, so paging through the file or indecision may be part of it. (1) Always on, log only: each `read_file` on the turn line now carries its line range, and a read of a file already read in the loop logs `codegen.reread` with the earlier read's turn and range, how the two ranges meet (`same`, `overlapping`, `disjoint`), what had become of the earlier answer (`whole`, `stubbed`, `dropped`, `after_write`) and whether it was answered as a repeat; `codegen.reread_summary` counts them at the loop's end. Paths and line numbers only, never file text. (2) `QUIKPILOT_KEEP_WORKING_FILES=on` (off by default; the workflow can set it): the newest answer per range of the files the AI is working in (a file it changed, or read in two different turns; at most three files and 40,000 characters, newest first) stays whole instead of shrinking, and only answers made after the file's latest change count, so a stale read is never kept; a repeat's copy of an earlier answer can then shrink like the answer itself. The hard ceiling's last-resort drop still drops anything, so a request never exceeds today's limit. With the switch off every request the AI Runtime receives is what it was. Nothing changes on the AI Runtime or in QuikProjects. Also in rc.64: everything in rc.63.
|
|
178
|
+
|
|
175
179
|
**9.3.0-rc.63 - a reply the AI service could not read is asked again once instead of ending the attempt (QUIKTR-1953).** On 30 Oct 3% of the AI calls of a run (8 of 267) came back as `SCHEMA_MISMATCH`: the AI service could not read the AI's reply in the required format, even after its own repair and one retry. Each one ended the whole attempt, and with two attempts per job two of them ended a job with nothing written (QTRIA-28 lost its file search to one). The runner lost nothing with such a turn, so the request is now made again, once, in the way a cut-off or a slow turn already is (QUIKTR-1853): one fixed sentence in the AI's transcript says its last answer could not be read in the required format and asks for exactly one reply in that format and a smaller step; the turn is recorded like the other recovered turns and is never counted as a refusal. It applies to the code-writing loop and to the file-search loop (where only this code is recovered: a cut-off or a slow turn there still falls back to the single call, as before). A second unreadable reply straight after the first, the final turn, and `QUIKPILOT_TURN_RECOVERY=off` end the attempt exactly as before; when it is the second in a row the failure message says so. New log event `targeting.loop_recovered` (the code-writing loop's `codegen.loop_recovered` now also carries `reason: schema_mismatch`). Nothing is deployed on the AI service, and nothing about the reply that failed is shown to the AI or logged.
|
|
176
180
|
|
|
177
181
|
**9.3.0-rc.58 - write the fix first, then ask once about every existing test it breaks, with proof (QUIKTR-1851, absorbing QUIKTR-1850; release 1).** Until now, when an existing test expected the bug, the run stopped BEFORE any code was written and a person approved a change to that test with nothing to show it could ever pass, and the tests were found one at a time: QTRIA-23 approved a change that moved the status line off 401 and left `expect(body).toEqual({ ..., error: "Unauthorized" })`, which no fix can satisfy, and spent all three stops. Now, when the project switches it on (`packet.fixFirst`; `QUIKPILOT_FIX_FIRST=off` turns it off without a rebuild) the run speaks `codegen-loop-8`: a `report_test_conflict` is a PROPOSAL that does not end the run, the AI writes the tests and the fix and reports every existing test its fix breaks, and at its DONE the runner proves the proposals (`proofCheck.ts`): it runs the project's WHOLE suite (the related-tests planner off, a fresh tool, outside the AI's run allowance) with the fix and every proposed change written over the old code. A proposal whose test still fails is sent back with its name ("change EVERY expectation of it"), and an existing test the fix broke that no proposal covers is sent back by name (never a failure message: QUIKTR-1474), at most twice; one that still fails after that is not offered to a person. Then ONE stop, as before, whose proposals carry `oldCodeChecked` (fails on the old code with the change alone), `newCode` (`passes` / `fails` / `not_checked`) and `newEndLine` (where the changed test now ends, for showing the whole test); no time, no answer or a list of failures cut to fit is `not_checked`, never proven. The tests phase hands its proposals to the code phase. An AI Runtime that refuses `codegen-loop-8` is asked again as loop-7 (nothing else changes), a fix turn stays loop-7, and a project that did not switch it on sends and receives exactly what it did. Release 2 (keeping the fix across the stop) is not in this version: the next job still writes the code again. Also in rc.58: everything in rc.57.
|
package/dist/index.js
CHANGED
|
@@ -29193,6 +29193,12 @@ function rowBase(name2) {
|
|
|
29193
29193
|
if (paren > 0 && base.endsWith(")")) base = base.slice(0, paren);
|
|
29194
29194
|
return base;
|
|
29195
29195
|
}
|
|
29196
|
+
function definesTest(text3, name2) {
|
|
29197
|
+
const base = rowBase(name2);
|
|
29198
|
+
if (base === "" || base === PARAMETERIZED_ROWS) return false;
|
|
29199
|
+
if (!/^[A-Za-z0-9_]+$/.test(base)) return text3.includes(base);
|
|
29200
|
+
return new RegExp(`(^|[^A-Za-z0-9_])${base}([^A-Za-z0-9_]|$)`).test(text3);
|
|
29201
|
+
}
|
|
29196
29202
|
function rowNamesOf(names) {
|
|
29197
29203
|
return names.filter((n) => !names.some((o) => o.startsWith(`${n}/`)));
|
|
29198
29204
|
}
|
|
@@ -41370,12 +41376,6 @@ function samePlace(a, b) {
|
|
|
41370
41376
|
const y = normalisePath2(b);
|
|
41371
41377
|
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
41372
41378
|
}
|
|
41373
|
-
function definesTest(text3, name2) {
|
|
41374
|
-
const base = rowBase(name2);
|
|
41375
|
-
if (base === "" || base === PARAMETERIZED_ROWS) return false;
|
|
41376
|
-
if (!/^[A-Za-z0-9_]+$/.test(base)) return text3.includes(base);
|
|
41377
|
-
return new RegExp(`(^|[^A-Za-z0-9_])${base}([^A-Za-z0-9_]|$)`).test(text3);
|
|
41378
|
-
}
|
|
41379
41379
|
function ownFailureIds(newFailures, changedPaths, requiredIds, changedText) {
|
|
41380
41380
|
const own = /* @__PURE__ */ new Set();
|
|
41381
41381
|
for (const id of newFailures) {
|
|
@@ -42366,7 +42366,9 @@ function stubOldLooks(i3) {
|
|
|
42366
42366
|
let shrunk = 0;
|
|
42367
42367
|
for (let index = 0; index < i3.results.length; index++) {
|
|
42368
42368
|
const r = i3.results[index];
|
|
42369
|
-
|
|
42369
|
+
const shrinkable = r.status === "ok" || i3.repeats === true && r.status === "duplicate";
|
|
42370
|
+
if (!LOOK_TOOLS.has(r.name) || !shrinkable || r.output === void 0 || isStubbed(r.output)) continue;
|
|
42371
|
+
if (i3.keep?.(r.id)) continue;
|
|
42370
42372
|
const turn = i3.turnOf(r.id);
|
|
42371
42373
|
if (turn === void 0 || turn > i3.currentTurn - KEEP_TURNS) continue;
|
|
42372
42374
|
const call = i3.callOf(r.id);
|
|
@@ -47178,6 +47180,123 @@ async function runTargetingLoop(args2, deps) {
|
|
|
47178
47180
|
}
|
|
47179
47181
|
}
|
|
47180
47182
|
|
|
47183
|
+
// src/workingFiles.ts
|
|
47184
|
+
var KEEP_WORKING_FILES_ENV = "QUIKPILOT_KEEP_WORKING_FILES";
|
|
47185
|
+
var MAX_WORKING_PATHS = 3;
|
|
47186
|
+
var MAX_KEPT_CHARS = 4e4;
|
|
47187
|
+
function keepWorkingFilesOn(env2 = process.env) {
|
|
47188
|
+
return env2[KEEP_WORKING_FILES_ENV]?.trim().toLowerCase() === "on";
|
|
47189
|
+
}
|
|
47190
|
+
function rangeOf(args2) {
|
|
47191
|
+
if (typeof args2 !== "object" || args2 === null) return {};
|
|
47192
|
+
const a = args2;
|
|
47193
|
+
if (a.mode === "outline") return { mode: "outline" };
|
|
47194
|
+
const out2 = {};
|
|
47195
|
+
if (typeof a.startLine === "number" && Number.isInteger(a.startLine)) out2.startLine = a.startLine;
|
|
47196
|
+
if (typeof a.endLine === "number" && Number.isInteger(a.endLine)) out2.endLine = a.endLine;
|
|
47197
|
+
return out2;
|
|
47198
|
+
}
|
|
47199
|
+
function overlapOf(a, b) {
|
|
47200
|
+
if (a.mode === "outline" || b.mode === "outline") return a.mode === b.mode ? "same" : "disjoint";
|
|
47201
|
+
const aStart = a.startLine ?? 1;
|
|
47202
|
+
const bStart = b.startLine ?? 1;
|
|
47203
|
+
const aEnd = a.endLine ?? Number.POSITIVE_INFINITY;
|
|
47204
|
+
const bEnd = b.endLine ?? Number.POSITIVE_INFINITY;
|
|
47205
|
+
if (aStart === bStart && aEnd === bEnd) return "same";
|
|
47206
|
+
return aStart <= bEnd && bStart <= aEnd ? "overlapping" : "disjoint";
|
|
47207
|
+
}
|
|
47208
|
+
function stateOf(output, writtenSince, dropNotes) {
|
|
47209
|
+
if (writtenSince) return "after_write";
|
|
47210
|
+
if (!isStubbed(output)) return "whole";
|
|
47211
|
+
const note = output.note;
|
|
47212
|
+
return typeof note === "string" && dropNotes.has(note) ? "dropped" : "stubbed";
|
|
47213
|
+
}
|
|
47214
|
+
function rangeKey(r) {
|
|
47215
|
+
return r.mode === "outline" ? "outline" : `${r.startLine ?? ""}-${r.endLine ?? ""}`;
|
|
47216
|
+
}
|
|
47217
|
+
function sizeOf2(output) {
|
|
47218
|
+
try {
|
|
47219
|
+
return JSON.stringify(output)?.length ?? 0;
|
|
47220
|
+
} catch {
|
|
47221
|
+
return Number.POSITIVE_INFINITY;
|
|
47222
|
+
}
|
|
47223
|
+
}
|
|
47224
|
+
var ReadTracker = class {
|
|
47225
|
+
reads = [];
|
|
47226
|
+
writes = [];
|
|
47227
|
+
seq = 0;
|
|
47228
|
+
noteRead(entry) {
|
|
47229
|
+
this.reads.push({ ...entry, seq: this.seq++ });
|
|
47230
|
+
}
|
|
47231
|
+
noteWrite(path, turn) {
|
|
47232
|
+
this.writes.push({ path, turn, seq: this.seq++ });
|
|
47233
|
+
}
|
|
47234
|
+
lastWriteSeq(path) {
|
|
47235
|
+
let last = -1;
|
|
47236
|
+
for (const w of this.writes) if (w.path === path) last = w.seq;
|
|
47237
|
+
return last;
|
|
47238
|
+
}
|
|
47239
|
+
/**
|
|
47240
|
+
* The re-read report for `entry`, called BEFORE it is noted: null for a path not read before in this loop. `outputOf(id)` answers what the
|
|
47241
|
+
* earlier answer is now; `duplicate` is whether this read was answered as a repeat.
|
|
47242
|
+
*/
|
|
47243
|
+
reread(entry, duplicate, outputOf, dropNotes) {
|
|
47244
|
+
let prev;
|
|
47245
|
+
for (const r of this.reads) if (r.path === entry.path) prev = r;
|
|
47246
|
+
if (!prev) return null;
|
|
47247
|
+
const writtenSince = this.writes.some((w) => w.path === entry.path && w.seq > prev.seq);
|
|
47248
|
+
const range = { startLine: entry.startLine, endLine: entry.endLine, mode: entry.mode };
|
|
47249
|
+
const prevRange = { startLine: prev.startLine, endLine: prev.endLine, mode: prev.mode };
|
|
47250
|
+
return {
|
|
47251
|
+
turn: entry.turn,
|
|
47252
|
+
path: entry.path,
|
|
47253
|
+
...entry.mode ? { mode: entry.mode } : {},
|
|
47254
|
+
...entry.startLine !== void 0 ? { startLine: entry.startLine } : {},
|
|
47255
|
+
...entry.endLine !== void 0 ? { endLine: entry.endLine } : {},
|
|
47256
|
+
prevTurn: prev.turn,
|
|
47257
|
+
...prev.mode ? { prevMode: prev.mode } : {},
|
|
47258
|
+
...prev.startLine !== void 0 ? { prevStartLine: prev.startLine } : {},
|
|
47259
|
+
...prev.endLine !== void 0 ? { prevEndLine: prev.endLine } : {},
|
|
47260
|
+
overlap: overlapOf(range, prevRange),
|
|
47261
|
+
prevState: stateOf(outputOf(prev.id), writtenSince, dropNotes),
|
|
47262
|
+
duplicate
|
|
47263
|
+
};
|
|
47264
|
+
}
|
|
47265
|
+
/**
|
|
47266
|
+
* The ids of the answers to keep whole: for each working file (written in this loop, or read in two different turns; the three most recently
|
|
47267
|
+
* used), the newest answer per range made after the file's latest write, while it is still whole; at most 40,000 characters, newest first.
|
|
47268
|
+
*/
|
|
47269
|
+
keep(outputOf) {
|
|
47270
|
+
const lastUse = /* @__PURE__ */ new Map();
|
|
47271
|
+
const turnsRead = /* @__PURE__ */ new Map();
|
|
47272
|
+
for (const r of this.reads) {
|
|
47273
|
+
lastUse.set(r.path, Math.max(lastUse.get(r.path) ?? -1, r.seq));
|
|
47274
|
+
turnsRead.set(r.path, (turnsRead.get(r.path) ?? /* @__PURE__ */ new Set()).add(r.turn));
|
|
47275
|
+
}
|
|
47276
|
+
for (const w of this.writes) lastUse.set(w.path, Math.max(lastUse.get(w.path) ?? -1, w.seq));
|
|
47277
|
+
const working = [...lastUse.keys()].filter((path) => this.writes.some((w) => w.path === path) || (turnsRead.get(path)?.size ?? 0) >= 2).sort((a, b) => lastUse.get(b) - lastUse.get(a)).slice(0, MAX_WORKING_PATHS);
|
|
47278
|
+
const candidates = [];
|
|
47279
|
+
for (const path of working) {
|
|
47280
|
+
const after = this.lastWriteSeq(path);
|
|
47281
|
+
const newestPerRange = /* @__PURE__ */ new Map();
|
|
47282
|
+
for (const r of this.reads) if (r.path === path && r.seq > after) newestPerRange.set(rangeKey(r), r);
|
|
47283
|
+
candidates.push(...newestPerRange.values());
|
|
47284
|
+
}
|
|
47285
|
+
candidates.sort((a, b) => b.seq - a.seq);
|
|
47286
|
+
const kept = /* @__PURE__ */ new Set();
|
|
47287
|
+
let chars = 0;
|
|
47288
|
+
for (const c of candidates) {
|
|
47289
|
+
const output = outputOf(c.id);
|
|
47290
|
+
if (output === void 0 || isStubbed(output)) continue;
|
|
47291
|
+
const size = sizeOf2(output);
|
|
47292
|
+
if (chars + size > MAX_KEPT_CHARS) continue;
|
|
47293
|
+
chars += size;
|
|
47294
|
+
kept.add(c.id);
|
|
47295
|
+
}
|
|
47296
|
+
return kept;
|
|
47297
|
+
}
|
|
47298
|
+
};
|
|
47299
|
+
|
|
47181
47300
|
// src/codegenLoop.ts
|
|
47182
47301
|
var CODEGEN_LOOP_CONTRACT_VERSION = "codegen-loop-1";
|
|
47183
47302
|
var CODEGEN_LOOP_2_CONTRACT_VERSION = "codegen-loop-2";
|
|
@@ -47250,11 +47369,6 @@ function withUnreportable(stop2, tests) {
|
|
|
47250
47369
|
if (stop2.summary) carried.summary = stop2.summary;
|
|
47251
47370
|
return carried;
|
|
47252
47371
|
}
|
|
47253
|
-
function samePlace2(a, b) {
|
|
47254
|
-
const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
47255
|
-
const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
47256
|
-
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
47257
|
-
}
|
|
47258
47372
|
var MAX_ID_CHARS2 = 64;
|
|
47259
47373
|
var MAX_RED_REFUSALS = 1;
|
|
47260
47374
|
var NOTHING_NEW = /* @__PURE__ */ new Set(["duplicate", "no_effect", "no_change_since_last_run", "no_match", "ambiguous", "conflict_rejected"]);
|
|
@@ -47293,6 +47407,7 @@ function isTestAnswer(x) {
|
|
|
47293
47407
|
}
|
|
47294
47408
|
var DROPPED_OUTPUT = { dropped: true, note: "Dropped to keep the request small. Read the file again if you need it." };
|
|
47295
47409
|
var DROPPED_UNSEEN_OUTPUT = { dropped: true, note: "Too large to send with the rest of this request. Read a smaller part of the file." };
|
|
47410
|
+
var DROP_NOTES = /* @__PURE__ */ new Set([DROPPED_OUTPUT.note, DROPPED_UNSEEN_OUTPUT.note]);
|
|
47296
47411
|
function repoMapGuidancePaths(baseContext) {
|
|
47297
47412
|
const map = baseContext.repoMap;
|
|
47298
47413
|
return (Array.isArray(map?.guidance) ? map.guidance : []).map((g) => g.path).filter((p) => typeof p === "string");
|
|
@@ -47349,6 +47464,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47349
47464
|
now
|
|
47350
47465
|
}) : null;
|
|
47351
47466
|
const notesOn = harness && args2.tools2?.notes === true;
|
|
47467
|
+
const keepOn = notesOn && keepWorkingFilesOn();
|
|
47352
47468
|
const conflictTool = notesOn && args2.conflicts !== void 0 && args2.tests !== void 0 ? new TestConflictTool({
|
|
47353
47469
|
existingTests: new Set(args2.protectedTestPaths),
|
|
47354
47470
|
deniedPaths: args2.deniedPaths,
|
|
@@ -47394,6 +47510,16 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47394
47510
|
const usage = new TurnUsage();
|
|
47395
47511
|
let notes = "";
|
|
47396
47512
|
let stubbed = 0;
|
|
47513
|
+
const tracker = new ReadTracker();
|
|
47514
|
+
const rereadCounts = { rereads: 0, rereadsAfterStub: 0, rereadsAfterDrop: 0 };
|
|
47515
|
+
let keptMax = 0;
|
|
47516
|
+
let rereadsLogged = false;
|
|
47517
|
+
const logRereads = () => {
|
|
47518
|
+
if (rereadsLogged) return;
|
|
47519
|
+
rereadsLogged = true;
|
|
47520
|
+
log({ event: "codegen.reread_summary", ...rereadCounts, ...keepOn ? { kept: keptMax } : {} });
|
|
47521
|
+
};
|
|
47522
|
+
const outputOf = (id) => toolResults.find((r) => r.id === id)?.output;
|
|
47397
47523
|
const turnOfId = /* @__PURE__ */ new Map();
|
|
47398
47524
|
const callOfId = /* @__PURE__ */ new Map();
|
|
47399
47525
|
const previousAttempt = args2.previousAttempt && !harness ? previousForLoop2(args2.previousAttempt) : args2.previousAttempt;
|
|
@@ -47520,7 +47646,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47520
47646
|
...usage.totals.calls > 0 ? { turnUsage: usage.rows.map((r) => ({ ...r, parts: { ...r.parts } })), usage: { ...usage.totals } } : {},
|
|
47521
47647
|
...usage.rowsCut ? { turnUsageCut: true } : {}
|
|
47522
47648
|
});
|
|
47523
|
-
const dropOutputs = (upTo, done, output) => {
|
|
47649
|
+
const dropOutputs = (upTo, done, output, keep) => {
|
|
47524
47650
|
const lastTestRun = toolResults.map((r) => r.name).lastIndexOf(RUN_TESTS_TOOL);
|
|
47525
47651
|
const lastCall = toolResults.map((r) => r.name).lastIndexOf(CALL_FUNCTION_TOOL);
|
|
47526
47652
|
const lastScratch = toolResults.map((r) => r.name).lastIndexOf(RUN_SCRATCH_TOOL);
|
|
@@ -47528,7 +47654,8 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47528
47654
|
for (let i3 = 0; i3 < upTo && !done(); i3++) {
|
|
47529
47655
|
const r = toolResults[i3];
|
|
47530
47656
|
if (r.output === DROPPED_OUTPUT || r.output === DROPPED_UNSEEN_OUTPUT) continue;
|
|
47531
|
-
|
|
47657
|
+
if (keep?.has(r.id)) continue;
|
|
47658
|
+
const stale = READ_TOOLS.has(r.name) && (r.status === "ok" || keepOn && r.status === "duplicate" && r.output !== void 0) || r.name === RUN_TESTS_TOOL && i3 !== lastTestRun && r.output !== void 0 || r.name === CALL_FUNCTION_TOOL && i3 !== lastCall && r.output !== void 0 || r.name === RUN_SCRATCH_TOOL && i3 !== lastScratch && r.output !== void 0;
|
|
47532
47659
|
if (!stale) continue;
|
|
47533
47660
|
toolResults[i3] = { ...r, output };
|
|
47534
47661
|
dropped++;
|
|
@@ -47540,7 +47667,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47540
47667
|
const fits = () => under(limits.maxRequestTokens);
|
|
47541
47668
|
const soft = args2.readRoots ? mapSoftTarget(firstRequestTokens, limits.maxRequestTokens) : limits.maxRequestTokens;
|
|
47542
47669
|
if (under(soft)) return true;
|
|
47543
|
-
dropOutputs(sent.results, () => under(soft), DROPPED_OUTPUT);
|
|
47670
|
+
dropOutputs(sent.results, () => under(soft), DROPPED_OUTPUT, keepOn ? tracker.keep(outputOf) : void 0);
|
|
47544
47671
|
for (const key of [...ledger.seen.keys()]) {
|
|
47545
47672
|
if (key.startsWith("read_file:") || key.startsWith("grep:") || key.startsWith("list_files:") || key.startsWith("show_changes:")) ledger.seen.delete(key);
|
|
47546
47673
|
}
|
|
@@ -47848,13 +47975,14 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47848
47975
|
const doneSummary = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : "";
|
|
47849
47976
|
const lane = args2.lane;
|
|
47850
47977
|
if (harness && args2.phase === "code" && lane?.kind === "code" && !lane.amend && args2.keepOnGiveUp === true) {
|
|
47851
|
-
const red2 = currentRedRuns().filter((r) => r.failing.some((name2) => lane.frozen.some((p) =>
|
|
47978
|
+
const red2 = currentRedRuns().filter((r) => r.failing.some((name2) => lane.frozen.some((p) => idPlaceMatches(name2.split("::")[0] ?? "", p)))).at(-1);
|
|
47852
47979
|
if (red2?.answer) {
|
|
47853
47980
|
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: red2.answer.regressions, newFailures: red2.answer.newFailures, after: "done" });
|
|
47854
47981
|
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary, gaveUp: true, steps: sentSteps(), lastTestAnswer: red2.answer };
|
|
47855
47982
|
}
|
|
47856
47983
|
}
|
|
47857
47984
|
const stopReason = isFinal ? `forced_${finalReason}` : "model_done";
|
|
47985
|
+
logRereads();
|
|
47858
47986
|
log({ event: "codegen.loop_done", turns, toolCalls: ledger.toolCalls, edits: ws.edits.size, created: ws.created.size, stopReason });
|
|
47859
47987
|
const told = lastTestAnswer ?? (args2.phase === "tests" ? currentRedRuns().at(-1)?.answer : void 0);
|
|
47860
47988
|
const proposals = args2.fixFirst === true && conflictTool ? conflictTool.recorded() : [];
|
|
@@ -47937,6 +48065,20 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47937
48065
|
}
|
|
47938
48066
|
}
|
|
47939
48067
|
results.push(result);
|
|
48068
|
+
if (call.name === "read_file" && isPlainObject3(call.args) && typeof call.args.path === "string" && (result.status === "ok" || result.status === "duplicate")) {
|
|
48069
|
+
const entry = { id: call.id, turn, path: call.args.path, ...rangeOf(call.args) };
|
|
48070
|
+
const again = tracker.reread(entry, result.status === "duplicate", (id) => results.find((x) => x.id === id)?.output ?? outputOf(id), DROP_NOTES);
|
|
48071
|
+
if (again) {
|
|
48072
|
+
rereadCounts.rereads += 1;
|
|
48073
|
+
if (again.prevState === "stubbed") rereadCounts.rereadsAfterStub += 1;
|
|
48074
|
+
else if (again.prevState === "dropped") rereadCounts.rereadsAfterDrop += 1;
|
|
48075
|
+
log({ event: "codegen.reread", ...again });
|
|
48076
|
+
}
|
|
48077
|
+
tracker.noteRead(entry);
|
|
48078
|
+
}
|
|
48079
|
+
if ((WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" && isPlainObject3(call.args) && typeof call.args.path === "string") {
|
|
48080
|
+
tracker.noteWrite(call.args.path, turn);
|
|
48081
|
+
}
|
|
47940
48082
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0) lastTestAnswer = result.output;
|
|
47941
48083
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
|
|
47942
48084
|
const file = result.output.scope === "file" && isPlainObject3(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
|
|
@@ -47948,7 +48090,8 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47948
48090
|
statusCounts[result.status] = (statusCounts[result.status] ?? 0) + 1;
|
|
47949
48091
|
const tool = TOOL_NAMES2.has(call.name) ? call.name : "unknown";
|
|
47950
48092
|
const pathArg = isPlainObject3(call.args) && typeof call.args.path === "string" && result.status !== "refused" ? { path: call.args.path } : {};
|
|
47951
|
-
|
|
48093
|
+
const rangeArg = call.name === "read_file" && result.status !== "refused" ? rangeOf(call.args) : {};
|
|
48094
|
+
logged.push({ tool, status: result.status, ...result.reason && result.status !== "duplicate" ? { reason: result.reason } : {}, ...pathArg, ...rangeArg });
|
|
47952
48095
|
if (result.status === "refused" || result.status === "protected") {
|
|
47953
48096
|
log({ event: "codegen.loop_refused", turn, tool, status: result.status, reason: result.reason });
|
|
47954
48097
|
}
|
|
@@ -47963,7 +48106,16 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47963
48106
|
callOfId.set(c.id, { name: c.name, args: c.args });
|
|
47964
48107
|
}
|
|
47965
48108
|
notes = keepNotes(notes, body2.notes, scrub);
|
|
47966
|
-
|
|
48109
|
+
const kept = keepOn ? tracker.keep(outputOf) : null;
|
|
48110
|
+
if (kept) keptMax = Math.max(keptMax, kept.size);
|
|
48111
|
+
stubbed += stubOldLooks({
|
|
48112
|
+
results: toolResults,
|
|
48113
|
+
turnOf: (id) => turnOfId.get(id),
|
|
48114
|
+
callOf: (id) => callOfId.get(id),
|
|
48115
|
+
currentTurn: turn,
|
|
48116
|
+
ledger,
|
|
48117
|
+
...kept ? { keep: (id) => kept.has(id), repeats: true } : {}
|
|
48118
|
+
});
|
|
47967
48119
|
}
|
|
47968
48120
|
noProgressStreak = harness ? results.every((r) => NOTHING_NEW.has(r.status)) ? noProgressStreak + 1 : 0 : results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
47969
48121
|
if (noProgressStreak >= (harness ? HARNESS_NO_PROGRESS_TURNS : 2)) forced = "no_progress";
|
|
@@ -47975,6 +48127,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47975
48127
|
}
|
|
47976
48128
|
throw new CodegenLoopFailure("final_not_produced");
|
|
47977
48129
|
} catch (err2) {
|
|
48130
|
+
logRereads();
|
|
47978
48131
|
if (err2 instanceof SafetyRefusalError) throw err2;
|
|
47979
48132
|
if (err2 instanceof TreeNotRestoredError) throw err2;
|
|
47980
48133
|
const unreportable = conflictTool?.unreportable() ?? [];
|
|
@@ -47999,6 +48152,22 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47999
48152
|
|
|
48000
48153
|
// src/codegenPhases.ts
|
|
48001
48154
|
var QP_TOKEN = /\[QP-[^\]\s]+\]/;
|
|
48155
|
+
function frozenFailingTarget(failingTests, frozen, textOf) {
|
|
48156
|
+
const fileOf = (name3) => name3.split("::")[0] ?? "";
|
|
48157
|
+
const failing = failingTests.filter((name3) => {
|
|
48158
|
+
const file2 = fileOf(name3);
|
|
48159
|
+
return file2 !== "" && frozen.some((path) => idPlaceMatches(file2, path));
|
|
48160
|
+
});
|
|
48161
|
+
if (failing.length !== 1 || !QP_TOKEN.test(failing[0])) return { failing, amend: null };
|
|
48162
|
+
const name2 = failing[0];
|
|
48163
|
+
const file = fileOf(name2);
|
|
48164
|
+
const candidates = frozen.filter((path) => idPlaceMatches(file, path));
|
|
48165
|
+
if (candidates.length === 1) return { failing, amend: candidates[0] };
|
|
48166
|
+
const sep = name2.indexOf("::");
|
|
48167
|
+
const testName = (sep >= 0 ? name2.slice(sep + 2) : name2).replace(QP_TOKEN, "").trim();
|
|
48168
|
+
const owners = candidates.filter((path) => definesTest(textOf(path) ?? "", testName));
|
|
48169
|
+
return { failing, amend: owners.length === 1 ? owners[0] : null };
|
|
48170
|
+
}
|
|
48002
48171
|
function testBlock(text3, token) {
|
|
48003
48172
|
const lines = text3.split("\n");
|
|
48004
48173
|
const at2 = lines.flatMap((line, n) => line.includes(token) ? [n] : []);
|
|
@@ -48133,15 +48302,13 @@ async function runPhases(i3) {
|
|
|
48133
48302
|
i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "finished" });
|
|
48134
48303
|
return { done: d2, tests, phases, summaries };
|
|
48135
48304
|
}
|
|
48136
|
-
const
|
|
48137
|
-
|
|
48138
|
-
|
|
48139
|
-
|
|
48140
|
-
const
|
|
48141
|
-
const file = token ? frozenFailing[0].split("::")[0] ?? "" : "";
|
|
48142
|
-
const amend = token ? tests.frozen.filter((path2) => samePlace2(file, path2)).slice(0, 1) : [];
|
|
48305
|
+
const failingSeen = d2.lastTestAnswer?.failingTests ?? [];
|
|
48306
|
+
const target = frozenFailingTarget(failingSeen, tests.frozen, (path2) => tests.results.find((r) => r.targetPath === path2)?.newContent);
|
|
48307
|
+
const frozenFailing = target.failing;
|
|
48308
|
+
const token = target.amend !== null && d2.lastTestAnswer?.truncated !== true ? QP_TOKEN.exec(frozenFailing[0])?.[0] : void 0;
|
|
48309
|
+
const amend = token && target.amend !== null ? [target.amend] : [];
|
|
48143
48310
|
phases.push(record("code", "gave_up", d2.summary));
|
|
48144
|
-
i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "gave_up", amendFiles: amend.length, frozenFailing: frozenFailing.length });
|
|
48311
|
+
i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "gave_up", amendFiles: amend.length, frozenFailing: frozenFailing.length, failingSeen: failingSeen.length });
|
|
48145
48312
|
if (amend.length === 0 || !token) return { done: d2, tests, phases, summaries };
|
|
48146
48313
|
i3.log({ event: "codegen.phase_start", attempt: i3.attempt, phase: "amend", files: amend.length });
|
|
48147
48314
|
let d3;
|
|
@@ -49547,13 +49714,13 @@ function healReviewPreviousAttempt(attempt2, blocks, answer) {
|
|
|
49547
49714
|
}
|
|
49548
49715
|
|
|
49549
49716
|
// src/codegenHeal.ts
|
|
49550
|
-
var
|
|
49717
|
+
var samePlace2 = (a, b) => {
|
|
49551
49718
|
const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
49552
49719
|
const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
49553
49720
|
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
49554
49721
|
};
|
|
49555
49722
|
function withMisfits(conflicts, misfits) {
|
|
49556
|
-
const misfitOf = (path, title) => misfits.find((m) =>
|
|
49723
|
+
const misfitOf = (path, title) => misfits.find((m) => samePlace2(m.path, path) && m.testTitle === title);
|
|
49557
49724
|
const decided = conflicts.decided.map((d) => d.decision === "TEST_CHANGED" && misfitOf(d.path, d.testTitle) ? { ...d, stillFailing: true } : d);
|
|
49558
49725
|
const revisable = (conflicts.approvedTests ?? []).flatMap((t) => {
|
|
49559
49726
|
const m = misfitOf(t.path, t.title);
|
|
@@ -51466,7 +51633,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
51466
51633
|
var REPORT_COPY = "final-test-report.xml";
|
|
51467
51634
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
51468
51635
|
var MAX_FILES = 200;
|
|
51469
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
51636
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.65" : "dev";
|
|
51470
51637
|
function safeDestination(base, repoPath) {
|
|
51471
51638
|
if (!repoPath || (0, import_node_path26.isAbsolute)(repoPath)) return null;
|
|
51472
51639
|
const destination = (0, import_node_path26.resolve)(base, repoPath);
|