@quikit/quikpilot-runner 9.3.0-rc.34 → 9.3.0-rc.35
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 +301 -28
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,8 @@ it, the callback carries it as `unsuppliedInputs` (at most 10 functions, 5 names
|
|
|
150
150
|
noticed" as a check. This is the shape of a change whose new tests pass only because they hand the function the field themselves. It can be
|
|
151
151
|
wrong (a field that arrives from a database row or a request), so it only warns and never blocks. TypeScript is not covered (QUIKTR-1547).
|
|
152
152
|
|
|
153
|
+
**9.3.0-rc.35 — the AI's own notes, old looks shrunk to a stub, the end-of-turn recap, a folder's guidance, and the newer versions only where a repository needs them (QUIKTR-1581, S6 release B; contract §37).** On `targeting-loop-4` and `codegen-loop-6` (each behind its own AI Runtime flag; a refusal steps one version back, `-4` to `-3` and `-6` to `-5`, then as before) a loop request carries `loop.recap`, the LAST key of `loop`: the approved cases, the folders the AI may change and its own notes. A `TOOL_CALLS` reply may carry `notes`; they replace the notes kept so far (an empty string clears them, a reply without them keeps them), credentials are hidden, at most 1,500 characters are kept, and the run record keeps their length only. The answer of a look (`list_files`, `read_file`, `grep`, `find_definition`) from a turn older than the latest three shrinks to `{dropped: true, note: "read src/a.ts lines 120-220"}`; asking for it again is answered afresh, not as a repeat. The first read under a folder that has its own `AGENTS.md`, `CLAUDE.md` or `README.md` (not the repository root's, not one already shown in the repository map) carries that file once, credentials hidden, at most 2,000 characters, at most six a run. The early look's `findings` are cut to 6,000 characters of JSON before they are handed on (open questions first, never what the verdict stands on). **`QUIKPILOT_TOOLS2` now defaults to `auto`**: search tools v2 and the notes are asked for only when the repository needs them, that is in the map view or when its file list would cost `QUIKPILOT_TOOLS_MIN_TOKENS` (default 8,000) or more tokens; a small project keeps the loops it always had (`targeting-loop-1`, `codegen-loop-3`) and pays for no extra tool, response format or recap. `on` always asks for the newest version, `off` never asks, and `QUIKPILOT_NOTES=off` keeps the tools but never asks for the notes. The run logs `tools.decided`.
|
|
154
|
+
|
|
153
155
|
**9.3.0-rc.34 — the first turn of a loop waits for a new response schema (QUIKTR-1581 follow-up).** The first call with a response schema the model provider has not seen recently is very slow (232 to 275 seconds measured on 19 Oct 2026 for a request that takes 5 to 8 once the provider has it) and fast afterwards. The targeting loop's turn limit was 180 seconds, the same as the AI Runtime's own provider timeout, so that first call was cut off every time, the provider never kept the schema, and runs fell back to the single targeting call (one found no file and failed). Now the FIRST turn of the targeting loop and of the code-writing loop waits up to 420 seconds; every later turn keeps its own limit (180 and 300), so a hung call does not cost the long wait twice. The targeting loop's whole-loop limit is 900 seconds (it was 600). A limit set by the caller still applies to every turn. Pair it with `OPENROUTER_TIMEOUT_SECONDS=420` on the AI Runtime (its default, 180, ends the call before the runner would). Nothing else changes.
|
|
154
156
|
|
|
155
157
|
**9.3.0-rc.33 — search tools v2: small, pageable answers, an outline, `find_definition` (QUIKTR-1581, S6 release A; contract §36).** Needs the AI Runtime with `targeting-loop-3` and `codegen-loop-5` (each switched on by its own flag); without them every run is exactly as on rc.32 (the runner asks once, is refused before any model call, and goes on as the version it would have spoken). (1) **What the AI gets:** `list_files` shows one folder level (`path`) with file counts, or finds files by name or glob (`pattern`, the folder being changed first), 100 entries a page; `read_file` shows a 200-line window, answers a file over 400 lines or 20,000 characters with status `too_large` plus the file's outline and a suggested range (never the text), and with `mode: "outline"` lists a file's functions, classes and methods with their line ranges (JavaScript and TypeScript exactly, read with the parser the code checks already use; every other text file by keywords and indentation; no new dependency); `grep` first answers which files match and how often, and gives lines only with `mode: "lines"`, a page at a time (`limit`, `offset`); the new `find_definition` finds where a name is defined, nearest the asking file first, and exactly (marked `exact`) when the asking file imports it, through the project's own import shortcuts, a workspace package and up to 3 `export … from` barrels. Every cut answer carries `next.offset` and a sentence saying how to get the page. (2) **Stale edits:** an `edit_file` whose text is not found in a file this attempt changed since the AI read it answers `stale_read` ("read the lines again") instead of `no_match`. (3) **Only what is usable:** `loop.tools` lists the tools offered this run (no `call_function` unless it is on); the AI Runtime refuses a call to any other. (4) **Both views:** `targeting-loop-3` / `codegen-loop-5` carry either `workspaceListing` or `repoMap`; a refusal steps ONE version back (`targeting-loop-1` / `-2`, `codegen-loop-3` / `-4`) and a fix attempt does not ask again. Map mode keeps its rule of no per-file fallback. (5) `QUIKPILOT_TOOLS2=off` never asks for the v2 versions. (6) Listing mode and the earlier versions answer every tool byte for byte as before; the targeting loop record carries `contractVersion` only for `targeting-loop-3`. Checked on the real QuikIT checkout (a folder level 1,000 characters, a search's files 1,000, a big file's outline 3,400, a definition 200).
|
package/dist/index.js
CHANGED
|
@@ -34418,6 +34418,7 @@ function executeToolCall(call, env2, ledger) {
|
|
|
34418
34418
|
return finish({ status: "duplicate", reason: earlier, message: "Identical call already made; see its result." });
|
|
34419
34419
|
}
|
|
34420
34420
|
ledger.seen.set(dupKey, call.id);
|
|
34421
|
+
(ledger.keys ??= /* @__PURE__ */ new Map()).set(call.id, dupKey);
|
|
34421
34422
|
let executed;
|
|
34422
34423
|
try {
|
|
34423
34424
|
executed = prepared.exec();
|
|
@@ -34425,6 +34426,10 @@ function executeToolCall(call, env2, ledger) {
|
|
|
34425
34426
|
executed = { result: { status: "unreadable", reason: "io", message: "That could not be read." } };
|
|
34426
34427
|
}
|
|
34427
34428
|
if (env2.scrub) executed = { ...executed, result: scrubAnswer(call.name, executed.result, env2.scrub) };
|
|
34429
|
+
if (env2.guidance && call.name === "read_file" && executed.result.status === "ok" && executed.read && isPlainObject(executed.result.output)) {
|
|
34430
|
+
const guidance = env2.guidance.forRead(executed.read.path);
|
|
34431
|
+
if (guidance) executed = { ...executed, result: { ...executed.result, output: { ...executed.result.output, guidance } } };
|
|
34432
|
+
}
|
|
34428
34433
|
if ((call.name === "edit_file" || call.name === "write_file" || call.name === "revert_file") && executed.result.status !== "ok") ledger.seen.delete(dupKey);
|
|
34429
34434
|
if (env2.serveRepeats === true && ledger.seen.has(dupKey)) (ledger.answers ??= /* @__PURE__ */ new Map()).set(call.id, executed.result);
|
|
34430
34435
|
return finish(executed.result, executed.read);
|
|
@@ -35361,6 +35366,152 @@ function ambiguousPlacesMessage(lf, starts, total) {
|
|
|
35361
35366
|
return `${header}${parts.join(", ")}. ${TAIL}`;
|
|
35362
35367
|
}
|
|
35363
35368
|
|
|
35369
|
+
// src/loopNotes.ts
|
|
35370
|
+
var NOTES_KEPT_CHARS = 1500;
|
|
35371
|
+
var KEEP_TURNS = 3;
|
|
35372
|
+
var MAX_STUB_NOTE_CHARS = 200;
|
|
35373
|
+
var MAX_RECAP_CASES = 50;
|
|
35374
|
+
var MAX_RECAP_ID_CHARS = 40;
|
|
35375
|
+
var MAX_RECAP_TITLE_CHARS = 200;
|
|
35376
|
+
var MAX_RECAP_ROOTS = 20;
|
|
35377
|
+
var MAX_RECAP_ROOT_CHARS = 300;
|
|
35378
|
+
var GUIDANCE_NAMES = ["AGENTS.md", "CLAUDE.md", "README.md"];
|
|
35379
|
+
var GUIDANCE_TEXT_CHARS = 2e3;
|
|
35380
|
+
var GUIDANCE_PER_RUN = 6;
|
|
35381
|
+
var LOOK_TOOLS = /* @__PURE__ */ new Set(["list_files", "read_file", "grep", "find_definition"]);
|
|
35382
|
+
function cutText(text, max) {
|
|
35383
|
+
if (text.length <= max) return text;
|
|
35384
|
+
let out = text.slice(0, max);
|
|
35385
|
+
const last = out.charCodeAt(out.length - 1);
|
|
35386
|
+
if (last >= 55296 && last <= 56319) out = out.slice(0, -1);
|
|
35387
|
+
return out;
|
|
35388
|
+
}
|
|
35389
|
+
function keepNotes(kept, reply, scrub) {
|
|
35390
|
+
if (typeof reply !== "string") return kept;
|
|
35391
|
+
const cleaned = (scrub ? scrub(reply) : reply).trim();
|
|
35392
|
+
return cutText(cleaned, NOTES_KEPT_CHARS).trim();
|
|
35393
|
+
}
|
|
35394
|
+
function buildRecap(i2) {
|
|
35395
|
+
const cases = [];
|
|
35396
|
+
const required2 = i2.baseContext.requiredTests;
|
|
35397
|
+
if (Array.isArray(required2)) {
|
|
35398
|
+
for (const entry of required2) {
|
|
35399
|
+
if (cases.length >= MAX_RECAP_CASES) break;
|
|
35400
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
35401
|
+
const { automationId, title } = entry;
|
|
35402
|
+
if (typeof automationId !== "string" || automationId.length === 0) continue;
|
|
35403
|
+
cases.push({
|
|
35404
|
+
automationId: cutText(automationId, MAX_RECAP_ID_CHARS),
|
|
35405
|
+
title: typeof title === "string" ? cutText(title, MAX_RECAP_TITLE_CHARS) : ""
|
|
35406
|
+
});
|
|
35407
|
+
}
|
|
35408
|
+
}
|
|
35409
|
+
const writeRoots = i2.writeRoots.filter((r) => r.length > 0 && r.length <= MAX_RECAP_ROOT_CHARS).slice(0, MAX_RECAP_ROOTS);
|
|
35410
|
+
return { cases, writeRoots, ...i2.notes.length > 0 ? { notes: i2.notes } : {} };
|
|
35411
|
+
}
|
|
35412
|
+
function argOf(args, key) {
|
|
35413
|
+
return typeof args === "object" && args !== null ? args[key] : void 0;
|
|
35414
|
+
}
|
|
35415
|
+
function textArg(args, key, max) {
|
|
35416
|
+
const v = argOf(args, key);
|
|
35417
|
+
return typeof v === "string" ? cutText(v.replace(/\s+/g, " ").trim(), max) : "";
|
|
35418
|
+
}
|
|
35419
|
+
function stubNoteFor(call) {
|
|
35420
|
+
let note;
|
|
35421
|
+
if (call.name === "read_file") {
|
|
35422
|
+
const path = textArg(call.args, "path", 120);
|
|
35423
|
+
const start = argOf(call.args, "startLine");
|
|
35424
|
+
const end = argOf(call.args, "endLine");
|
|
35425
|
+
note = argOf(call.args, "mode") === "outline" ? `outline of ${path}` : typeof start === "number" && typeof end === "number" ? `read ${path} lines ${start}-${end}` : typeof start === "number" ? `read ${path} from line ${start}` : `read the start of ${path}`;
|
|
35426
|
+
} else if (call.name === "list_files") {
|
|
35427
|
+
const path = textArg(call.args, "path", 80) || "the repository";
|
|
35428
|
+
const pattern = textArg(call.args, "pattern", 60);
|
|
35429
|
+
note = pattern ? `found files named ${pattern} under ${path}` : `listed ${path}`;
|
|
35430
|
+
} else if (call.name === "grep") {
|
|
35431
|
+
const path = textArg(call.args, "path", 60);
|
|
35432
|
+
const lines = argOf(call.args, "mode") === "lines" ? " (lines)" : "";
|
|
35433
|
+
note = `searched for ${JSON.stringify(textArg(call.args, "pattern", 60))}${path ? ` in ${path}` : ""}${lines}`;
|
|
35434
|
+
} else if (call.name === "find_definition") {
|
|
35435
|
+
note = `looked up ${textArg(call.args, "name", 80)}`;
|
|
35436
|
+
} else {
|
|
35437
|
+
note = call.name;
|
|
35438
|
+
}
|
|
35439
|
+
return cutText(note, MAX_STUB_NOTE_CHARS);
|
|
35440
|
+
}
|
|
35441
|
+
function isStubbed(output) {
|
|
35442
|
+
return typeof output === "object" && output !== null && output.dropped === true;
|
|
35443
|
+
}
|
|
35444
|
+
function stubOldLooks(i2) {
|
|
35445
|
+
let shrunk = 0;
|
|
35446
|
+
for (let index = 0; index < i2.results.length; index++) {
|
|
35447
|
+
const r = i2.results[index];
|
|
35448
|
+
if (!LOOK_TOOLS.has(r.name) || r.status !== "ok" || r.output === void 0 || isStubbed(r.output)) continue;
|
|
35449
|
+
const turn = i2.turnOf(r.id);
|
|
35450
|
+
if (turn === void 0 || turn > i2.currentTurn - KEEP_TURNS) continue;
|
|
35451
|
+
const call = i2.callOf(r.id);
|
|
35452
|
+
if (!call) continue;
|
|
35453
|
+
i2.results[index] = { ...r, output: { dropped: true, note: stubNoteFor(call) } };
|
|
35454
|
+
const key = i2.ledger.keys?.get(r.id);
|
|
35455
|
+
if (key !== void 0 && i2.ledger.seen.get(key) === r.id) i2.ledger.seen.delete(key);
|
|
35456
|
+
i2.ledger.answers?.delete(r.id);
|
|
35457
|
+
shrunk += 1;
|
|
35458
|
+
}
|
|
35459
|
+
return shrunk;
|
|
35460
|
+
}
|
|
35461
|
+
function foldersAbove(path) {
|
|
35462
|
+
const parts = path.split("/");
|
|
35463
|
+
parts.pop();
|
|
35464
|
+
const out = [];
|
|
35465
|
+
while (parts.length > 0) {
|
|
35466
|
+
out.push(parts.join("/"));
|
|
35467
|
+
parts.pop();
|
|
35468
|
+
}
|
|
35469
|
+
return out;
|
|
35470
|
+
}
|
|
35471
|
+
function makeGuidanceFinder(i2) {
|
|
35472
|
+
const given = new Set(i2.alreadyShown ?? []);
|
|
35473
|
+
const done = new Set([...given].map((p) => p.slice(0, Math.max(0, p.lastIndexOf("/")))));
|
|
35474
|
+
let count3 = 0;
|
|
35475
|
+
return {
|
|
35476
|
+
shown: () => count3,
|
|
35477
|
+
forRead(path) {
|
|
35478
|
+
if (count3 >= GUIDANCE_PER_RUN) return void 0;
|
|
35479
|
+
for (const folder of foldersAbove(path)) {
|
|
35480
|
+
if (done.has(folder)) continue;
|
|
35481
|
+
for (const name of GUIDANCE_NAMES) {
|
|
35482
|
+
const candidate = `${folder}/${name}`;
|
|
35483
|
+
if (given.has(candidate) || !i2.listing.has(candidate) || i2.isDenied(candidate)) continue;
|
|
35484
|
+
const raw = i2.readText(candidate);
|
|
35485
|
+
given.add(candidate);
|
|
35486
|
+
if (raw === null) continue;
|
|
35487
|
+
const text = cutText((i2.scrub ? i2.scrub(raw) : raw).trim(), GUIDANCE_TEXT_CHARS);
|
|
35488
|
+
if (text.length === 0) continue;
|
|
35489
|
+
done.add(folder);
|
|
35490
|
+
count3 += 1;
|
|
35491
|
+
return { path: candidate, text };
|
|
35492
|
+
}
|
|
35493
|
+
}
|
|
35494
|
+
return void 0;
|
|
35495
|
+
}
|
|
35496
|
+
};
|
|
35497
|
+
}
|
|
35498
|
+
function readFileText(fs, path) {
|
|
35499
|
+
try {
|
|
35500
|
+
const st = fs.lstat(path);
|
|
35501
|
+
if (!st || st.isSymlink || !st.isFile || st.size > 2e5 || !fs.realpathInside(path)) return null;
|
|
35502
|
+
const bytes = fs.readBytes(path);
|
|
35503
|
+
return bytes ? new TextDecoder("utf-8").decode(bytes) : null;
|
|
35504
|
+
} catch {
|
|
35505
|
+
return null;
|
|
35506
|
+
}
|
|
35507
|
+
}
|
|
35508
|
+
function clampNotesRecord(n) {
|
|
35509
|
+
if (typeof n !== "object" || n === null) return void 0;
|
|
35510
|
+
const { chars, stubbed, guidance } = n;
|
|
35511
|
+
const whole3 = (v, max) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? Math.min(v, max) : 0;
|
|
35512
|
+
return { chars: whole3(chars, NOTES_KEPT_CHARS), stubbed: whole3(stubbed, 1e5), guidance: whole3(guidance, GUIDANCE_PER_RUN) };
|
|
35513
|
+
}
|
|
35514
|
+
|
|
35364
35515
|
// ../../../../quikit1926/node_modules/eslint-scope/lib/index.js
|
|
35365
35516
|
var import_assert4 = __toESM(require("assert"), 1);
|
|
35366
35517
|
|
|
@@ -38990,6 +39141,16 @@ function createCodegenWorkspace(args) {
|
|
|
38990
39141
|
...args.scrub ? { scrub: args.scrub } : {},
|
|
38991
39142
|
...args.readRoots ? { readRoots: args.readRoots } : {},
|
|
38992
39143
|
...args.tools2 ? { tools2: args.tools2 } : {},
|
|
39144
|
+
// Section 37: the first read under a folder that has its own guidance file carries it, once (read from disk: a guidance file is not edited here).
|
|
39145
|
+
...args.tools2?.notes === true ? {
|
|
39146
|
+
guidance: makeGuidanceFinder({
|
|
39147
|
+
listing,
|
|
39148
|
+
readText: (p) => readFileText(baseFs, p),
|
|
39149
|
+
isDenied: (p) => matchesDeniedPath(p, readDenied(args.deniedPaths)) !== null,
|
|
39150
|
+
...args.scrub ? { scrub: args.scrub } : {},
|
|
39151
|
+
alreadyShown: args.shownGuidance ?? []
|
|
39152
|
+
})
|
|
39153
|
+
} : {},
|
|
38993
39154
|
extraTools: {
|
|
38994
39155
|
edit_file: prepareEdit,
|
|
38995
39156
|
write_file: prepareWrite,
|
|
@@ -39265,6 +39426,7 @@ var LOOP_CONTRACT_VERSION = "targeting-loop-1";
|
|
|
39265
39426
|
var MAP_LOOP_CONTRACT_VERSION = "targeting-loop-2";
|
|
39266
39427
|
var TOOLS2_LOOP_CONTRACT_VERSION = "targeting-loop-3";
|
|
39267
39428
|
var TOOLS2_LOOP_TOOLS = ["list_files", "read_file", "grep", "find_definition"];
|
|
39429
|
+
var NOTES_LOOP_CONTRACT_VERSION = "targeting-loop-4";
|
|
39268
39430
|
var LoopFailure = class extends Error {
|
|
39269
39431
|
reason;
|
|
39270
39432
|
runtimeCode;
|
|
@@ -39322,6 +39484,22 @@ async function runTargetingLoop(args, deps) {
|
|
|
39322
39484
|
...args.readRoots ? { readRoots: args.readRoots } : {},
|
|
39323
39485
|
...args.tools2 ? { tools2: args.tools2 } : {}
|
|
39324
39486
|
};
|
|
39487
|
+
const notesOn = args.tools2?.notes === true;
|
|
39488
|
+
if (notesOn) {
|
|
39489
|
+
const denied = readDenied(args.deniedPaths);
|
|
39490
|
+
const shownInMap = args.baseContext.repoMap?.guidance;
|
|
39491
|
+
env2.guidance = makeGuidanceFinder({
|
|
39492
|
+
listing: env2.listing,
|
|
39493
|
+
readText: (path) => readFileText(env2.fs, path),
|
|
39494
|
+
isDenied: (path) => matchesDeniedPath(path, denied) !== null,
|
|
39495
|
+
...env2.scrub ? { scrub: env2.scrub } : {},
|
|
39496
|
+
alreadyShown: (Array.isArray(shownInMap) ? shownInMap : []).map((g) => g.path).filter((p) => typeof p === "string")
|
|
39497
|
+
});
|
|
39498
|
+
}
|
|
39499
|
+
let notes = "";
|
|
39500
|
+
let stubbed = 0;
|
|
39501
|
+
const turnOfId = /* @__PURE__ */ new Map();
|
|
39502
|
+
const callOfId = /* @__PURE__ */ new Map();
|
|
39325
39503
|
const ledger = newLedger();
|
|
39326
39504
|
const reads = [];
|
|
39327
39505
|
const transcript = [];
|
|
@@ -39350,7 +39528,9 @@ async function runTargetingLoop(args, deps) {
|
|
|
39350
39528
|
},
|
|
39351
39529
|
transcript,
|
|
39352
39530
|
toolResults,
|
|
39353
|
-
...args.tools2 ? { tools: [...TOOLS2_LOOP_TOOLS] } : {}
|
|
39531
|
+
...args.tools2 ? { tools: [...TOOLS2_LOOP_TOOLS] } : {},
|
|
39532
|
+
// Section 37: LAST in `loop`, so the end of the request repeats the cases, the folders the AI may change and its own notes.
|
|
39533
|
+
...notesOn ? { recap: buildRecap({ baseContext: args.baseContext, writeRoots: args.tools2?.writeRoots ?? [], notes }) } : {}
|
|
39354
39534
|
}
|
|
39355
39535
|
});
|
|
39356
39536
|
const snapshot = (stopReason) => ({
|
|
@@ -39362,7 +39542,8 @@ async function runTargetingLoop(args, deps) {
|
|
|
39362
39542
|
reads: [...reads],
|
|
39363
39543
|
...refusedTurns.length > 0 ? { refusedTurns: refusedTurns.map((t) => ({ turn: t.turn, rules: [...t.rules] })) } : {},
|
|
39364
39544
|
...peakRequestTokens > 0 ? { peakRequestTokens } : {},
|
|
39365
|
-
...args.tools2 ? { contractVersion: args.contractVersion ?? TOOLS2_LOOP_CONTRACT_VERSION } : {}
|
|
39545
|
+
...args.tools2 ? { contractVersion: args.contractVersion ?? TOOLS2_LOOP_CONTRACT_VERSION } : {},
|
|
39546
|
+
...notesOn ? { notes: { chars: notes.length, stubbed, guidance: env2.guidance?.shown() ?? 0 } } : {}
|
|
39366
39547
|
});
|
|
39367
39548
|
log({ event: "targeting.loop_start", mode: "loop", maxTurns: limits.maxTurns, maxToolCalls: limits.maxToolCalls, listingFiles: args.listing.length });
|
|
39368
39549
|
try {
|
|
@@ -39483,6 +39664,14 @@ async function runTargetingLoop(args, deps) {
|
|
|
39483
39664
|
});
|
|
39484
39665
|
toolResults.push(...results);
|
|
39485
39666
|
refusedStreak = 0;
|
|
39667
|
+
if (notesOn) {
|
|
39668
|
+
for (const c of calls) {
|
|
39669
|
+
turnOfId.set(c.id, turn);
|
|
39670
|
+
callOfId.set(c.id, { name: c.name, args: c.args });
|
|
39671
|
+
}
|
|
39672
|
+
notes = keepNotes(notes, body.notes, env2.scrub);
|
|
39673
|
+
stubbed += stubOldLooks({ results: toolResults, turnOf: (id) => turnOfId.get(id), callOf: (id) => callOfId.get(id), currentTurn: turn, ledger });
|
|
39674
|
+
}
|
|
39486
39675
|
noProgressStreak = results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
39487
39676
|
if (noProgressStreak >= 2) forced = "no_progress";
|
|
39488
39677
|
else if (ledger.toolCalls >= limits.maxToolCalls) forced = "tool_budget";
|
|
@@ -39539,6 +39728,7 @@ var CODEGEN_LOOP_2_CONTRACT_VERSION = "codegen-loop-2";
|
|
|
39539
39728
|
var CODEGEN_LOOP_3_CONTRACT_VERSION = "codegen-loop-3";
|
|
39540
39729
|
var CODEGEN_LOOP_4_CONTRACT_VERSION = "codegen-loop-4";
|
|
39541
39730
|
var CODEGEN_LOOP_5_CONTRACT_VERSION = "codegen-loop-5";
|
|
39731
|
+
var CODEGEN_LOOP_6_CONTRACT_VERSION = "codegen-loop-6";
|
|
39542
39732
|
var MAP_SOFT_REQUEST_TOKENS = 4e4;
|
|
39543
39733
|
var CodegenLoopFailure = class extends Error {
|
|
39544
39734
|
reason;
|
|
@@ -39608,13 +39798,18 @@ function isTestAnswer(x) {
|
|
|
39608
39798
|
return isPlainObject3(x) && typeof x.passed === "number" && Array.isArray(x.failingTests);
|
|
39609
39799
|
}
|
|
39610
39800
|
var DROPPED_OUTPUT = { dropped: true, note: "Dropped to keep the request small. Read the file again if you need it." };
|
|
39801
|
+
function repoMapGuidancePaths(baseContext) {
|
|
39802
|
+
const map = baseContext.repoMap;
|
|
39803
|
+
return (Array.isArray(map?.guidance) ? map.guidance : []).map((g) => g.path).filter((p) => typeof p === "string");
|
|
39804
|
+
}
|
|
39611
39805
|
async function runCodegenLoop(args, deps) {
|
|
39806
|
+
const scrub = makeCodeScrubber(deps.secrets ?? [], (c) => (deps.log ?? ((e) => console.log(JSON.stringify(e))))({ event: "loop.scrubbed", ...nonZero(c) }));
|
|
39612
39807
|
const ws = createCodegenWorkspace({
|
|
39613
|
-
|
|
39614
|
-
scrub: makeCodeScrubber(deps.secrets ?? [], (c) => (deps.log ?? ((e) => console.log(JSON.stringify(e))))({ event: "loop.scrubbed", ...nonZero(c) })),
|
|
39808
|
+
scrub,
|
|
39615
39809
|
listing: args.readListing ?? args.listing,
|
|
39616
39810
|
...args.readRoots ? { readRoots: args.readRoots } : {},
|
|
39617
39811
|
...args.tools2 && args.tests !== void 0 && args.harness === true ? { tools2: args.tools2 } : {},
|
|
39812
|
+
...args.tools2?.notes === true && args.tests !== void 0 && args.harness === true ? { shownGuidance: repoMapGuidancePaths(args.baseContext) } : {},
|
|
39618
39813
|
deniedPaths: args.deniedPaths,
|
|
39619
39814
|
protectedTestPaths: args.protectedTestPaths,
|
|
39620
39815
|
...args.discoveredTests ? { discoveredTests: args.discoveredTests } : {},
|
|
@@ -39656,8 +39851,13 @@ async function runCodegenLoop(args, deps) {
|
|
|
39656
39851
|
log,
|
|
39657
39852
|
now
|
|
39658
39853
|
}) : null;
|
|
39659
|
-
const
|
|
39854
|
+
const notesOn = harness && args.tools2?.notes === true;
|
|
39855
|
+
const contractVersion = harness ? args.tools2 ? notesOn ? CODEGEN_LOOP_6_CONTRACT_VERSION : CODEGEN_LOOP_5_CONTRACT_VERSION : args.readRoots ? CODEGEN_LOOP_4_CONTRACT_VERSION : CODEGEN_LOOP_3_CONTRACT_VERSION : tests ? CODEGEN_LOOP_2_CONTRACT_VERSION : CODEGEN_LOOP_CONTRACT_VERSION;
|
|
39660
39856
|
let peakRequestTokens = 0;
|
|
39857
|
+
let notes = "";
|
|
39858
|
+
let stubbed = 0;
|
|
39859
|
+
const turnOfId = /* @__PURE__ */ new Map();
|
|
39860
|
+
const callOfId = /* @__PURE__ */ new Map();
|
|
39661
39861
|
const previousAttempt = args.previousAttempt && !harness ? previousForLoop2(args.previousAttempt) : args.previousAttempt;
|
|
39662
39862
|
if (tests && args.seed && args.seed.length > 0) tests.markSeen(versionOfFiles(filesOnDisk()));
|
|
39663
39863
|
let testMs = 0;
|
|
@@ -39742,7 +39942,9 @@ async function runCodegenLoop(args, deps) {
|
|
|
39742
39942
|
transcript,
|
|
39743
39943
|
toolResults,
|
|
39744
39944
|
// QUIKTR-1581 (§36): the tools this run offers, in the order the AI Runtime lists them. `call_function` only where it is on.
|
|
39745
|
-
...args.tools2 && harness ? { tools: ["list_files", "read_file", "grep", "find_definition", "edit_file", "write_file", "run_tests", ...fn ? ["call_function"] : [], "show_changes", "revert_file"] } : {}
|
|
39945
|
+
...args.tools2 && harness ? { tools: ["list_files", "read_file", "grep", "find_definition", "edit_file", "write_file", "run_tests", ...fn ? ["call_function"] : [], "show_changes", "revert_file"] } : {},
|
|
39946
|
+
// Section 37: LAST in `loop`, so the end of the request repeats the cases, the folders the AI may change and its own notes.
|
|
39947
|
+
...notesOn ? { recap: buildRecap({ baseContext: args.baseContext, writeRoots: args.tools2?.writeRoots ?? [], notes }) } : {}
|
|
39746
39948
|
}
|
|
39747
39949
|
});
|
|
39748
39950
|
const snapshot = (stopReason) => ({
|
|
@@ -39758,7 +39960,8 @@ async function runCodegenLoop(args, deps) {
|
|
|
39758
39960
|
...tests ? { contractVersion, testRuns: tests.record() } : {},
|
|
39759
39961
|
...refusedTurns.length > 0 ? { refusedTurns: refusedTurns.map((t) => ({ turn: t.turn, rules: [...t.rules] })) } : {},
|
|
39760
39962
|
reasoning: [...reasoning],
|
|
39761
|
-
...args.repoView ? { repoView: args.repoView, peakRequestTokens } : {}
|
|
39963
|
+
...args.repoView ? { repoView: args.repoView, peakRequestTokens } : {},
|
|
39964
|
+
...notesOn ? { notes: { chars: notes.length, stubbed, guidance: env2.guidance?.shown() ?? 0 } } : {}
|
|
39762
39965
|
});
|
|
39763
39966
|
const makeRoom = (nextTurn, nextFinal, finalReason) => {
|
|
39764
39967
|
const under = (limit) => estimateRequestTokens(buildContext(nextTurn, nextFinal, finalReason)) <= limit;
|
|
@@ -40059,6 +40262,14 @@ async function runCodegenLoop(args, deps) {
|
|
|
40059
40262
|
transcript.push({ turn, ...reasonText ? { reasoning: reasonText } : {}, toolCalls: calls.map((c) => ({ id: c.id, name: c.name, args: c.args })) });
|
|
40060
40263
|
toolResults.push(...results);
|
|
40061
40264
|
refusedStreak = 0;
|
|
40265
|
+
if (notesOn) {
|
|
40266
|
+
for (const c of calls) {
|
|
40267
|
+
turnOfId.set(c.id, turn);
|
|
40268
|
+
callOfId.set(c.id, { name: c.name, args: c.args });
|
|
40269
|
+
}
|
|
40270
|
+
notes = keepNotes(notes, body.notes, scrub);
|
|
40271
|
+
stubbed += stubOldLooks({ results: toolResults, turnOf: (id) => turnOfId.get(id), callOf: (id) => callOfId.get(id), currentTurn: turn, ledger });
|
|
40272
|
+
}
|
|
40062
40273
|
noProgressStreak = harness ? results.every((r) => NOTHING_NEW.has(r.status)) ? noProgressStreak + 1 : 0 : results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
40063
40274
|
if (noProgressStreak >= (harness ? HARNESS_NO_PROGRESS_TURNS : 2)) forced = "no_progress";
|
|
40064
40275
|
else if (ledger.toolCalls >= limits.maxToolCalls) forced = "tool_budget";
|
|
@@ -40490,6 +40701,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40490
40701
|
statusCounts,
|
|
40491
40702
|
...whole2(loop.syntaxWarnings) > 0 ? { syntaxWarnings: whole2(loop.syntaxWarnings) } : {},
|
|
40492
40703
|
...typeof loop.contractVersion === "string" && loop.contractVersion.length > 0 ? { contractVersion: loop.contractVersion.slice(0, 40) } : {},
|
|
40704
|
+
...clampNotesRecord(loop.notes) ? { notes: clampNotesRecord(loop.notes) } : {},
|
|
40493
40705
|
...clampRepoView(loop.repoView, loop.peakRequestTokens),
|
|
40494
40706
|
...testRuns.length > 0 ? { testRuns } : {},
|
|
40495
40707
|
...refused2.rows.length > 0 ? { refusedTurns: refused2.rows } : {},
|
|
@@ -40961,6 +41173,12 @@ async function runCodegenStep(p) {
|
|
|
40961
41173
|
log({ event: "codegen.attempt_start", attempt: 1 });
|
|
40962
41174
|
const firstStarted = now();
|
|
40963
41175
|
let first = await attempt2();
|
|
41176
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && p.tools2?.notes === true && args?.harness === true) {
|
|
41177
|
+
log({ event: "codegen.version_fallback", from: "codegen-loop-6", to: "codegen-loop-5" });
|
|
41178
|
+
p.tools2 = { ...p.tools2, notes: false };
|
|
41179
|
+
args = buildCodegenLoopArgs(p, context);
|
|
41180
|
+
first = await attempt2();
|
|
41181
|
+
}
|
|
40964
41182
|
if ("failure" in first && first.failure.reason === "contract_rejected" && p.tools2 && args?.harness === true) {
|
|
40965
41183
|
log({ event: "codegen.version_fallback", from: "codegen-loop-5", to: p.scope?.view === "map" ? "codegen-loop-4" : "codegen-loop-3" });
|
|
40966
41184
|
p.tools2 = void 0;
|
|
@@ -42280,12 +42498,45 @@ function startMapMode(i2) {
|
|
|
42280
42498
|
return { event: "map.mode", ...overrode ? { overrode: { targeting: i2.targetingMode, codegen: i2.codegenMode } } : {} };
|
|
42281
42499
|
}
|
|
42282
42500
|
|
|
42501
|
+
// src/toolsMode.ts
|
|
42502
|
+
var TOOLS2_ENV = "QUIKPILOT_TOOLS2";
|
|
42503
|
+
var TOOLS_MIN_TOKENS_ENV = "QUIKPILOT_TOOLS_MIN_TOKENS";
|
|
42504
|
+
var NOTES_ENV = "QUIKPILOT_NOTES";
|
|
42505
|
+
var DEFAULT_TOOLS_MIN_TOKENS = 8e3;
|
|
42506
|
+
function resolveToolsSetting(env2 = process.env) {
|
|
42507
|
+
const v = env2[TOOLS2_ENV]?.trim().toLowerCase();
|
|
42508
|
+
return v === "off" ? "off" : v === "on" ? "on" : "auto";
|
|
42509
|
+
}
|
|
42510
|
+
function resolveToolsMinTokens(env2 = process.env) {
|
|
42511
|
+
const n = Number(env2[TOOLS_MIN_TOKENS_ENV]);
|
|
42512
|
+
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : DEFAULT_TOOLS_MIN_TOKENS;
|
|
42513
|
+
}
|
|
42514
|
+
function notesEnabled(env2 = process.env) {
|
|
42515
|
+
return env2[NOTES_ENV]?.trim().toLowerCase() !== "off";
|
|
42516
|
+
}
|
|
42517
|
+
function decideTools(setting, scope, minTokens) {
|
|
42518
|
+
const base = { setting, listingTokens: scope.listingTokens, threshold: minTokens };
|
|
42519
|
+
if (setting === "off") return { ...base, on: false, why: "off" };
|
|
42520
|
+
if (setting === "on") return { ...base, on: true, why: "on" };
|
|
42521
|
+
if (scope.view === "map") return { ...base, on: true, why: "map_view" };
|
|
42522
|
+
return scope.listingTokens >= minTokens ? { ...base, on: true, why: "big_listing" } : { ...base, on: false, why: "small_listing" };
|
|
42523
|
+
}
|
|
42524
|
+
function buildToolsV2Env(i2) {
|
|
42525
|
+
const packageFolders = new Map(i2.scope.packages.map((p) => [p.name, p.folder]));
|
|
42526
|
+
return {
|
|
42527
|
+
writeRoots: [i2.scope.writeRoot],
|
|
42528
|
+
mapSpecifier: createAliasMapper({ readText: i2.readText, writeRoot: i2.scope.writeRoot }),
|
|
42529
|
+
...packageFolders.size > 0 ? { packageFolders } : {},
|
|
42530
|
+
...i2.notes ? { notes: true } : {}
|
|
42531
|
+
};
|
|
42532
|
+
}
|
|
42533
|
+
|
|
42283
42534
|
// src/repoMap.ts
|
|
42284
42535
|
var import_node_path19 = require("node:path");
|
|
42285
42536
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
42286
42537
|
var MAX_FOLDERS = 200;
|
|
42287
42538
|
var MAX_LANGUAGES = 12;
|
|
42288
|
-
var
|
|
42539
|
+
var GUIDANCE_NAMES2 = ["AGENTS.md", "CLAUDE.md", "CONTRIBUTING.md", "README.md"];
|
|
42289
42540
|
var GUIDANCE_FILE_CHARS = 2e3;
|
|
42290
42541
|
var GUIDANCE_TOTAL_CHARS = 6e3;
|
|
42291
42542
|
var MAX_GUIDANCE_FILES = 8;
|
|
@@ -42306,7 +42557,7 @@ function guidanceFiles(i2, perFile2, total) {
|
|
|
42306
42557
|
const out = [];
|
|
42307
42558
|
let left = total;
|
|
42308
42559
|
for (let d = i2.writeRoot; ; d = parentOf2(d)) {
|
|
42309
|
-
for (const name of
|
|
42560
|
+
for (const name of GUIDANCE_NAMES2) {
|
|
42310
42561
|
const path = d === "" ? name : `${d}/${name}`;
|
|
42311
42562
|
if (out.length >= MAX_GUIDANCE_FILES || left < MIN_GUIDANCE_CHARS) break;
|
|
42312
42563
|
if (!tracked.has(path) || matchesDeniedPath(path, denied)) continue;
|
|
@@ -42609,20 +42860,6 @@ function buildRepoScope(i2) {
|
|
|
42609
42860
|
};
|
|
42610
42861
|
}
|
|
42611
42862
|
|
|
42612
|
-
// src/toolsMode.ts
|
|
42613
|
-
var TOOLS2_ENV = "QUIKPILOT_TOOLS2";
|
|
42614
|
-
function resolveToolsSetting(env2 = process.env) {
|
|
42615
|
-
return env2[TOOLS2_ENV]?.trim().toLowerCase() === "off" ? "off" : "on";
|
|
42616
|
-
}
|
|
42617
|
-
function buildToolsV2Env(i2) {
|
|
42618
|
-
const packageFolders = new Map(i2.scope.packages.map((p) => [p.name, p.folder]));
|
|
42619
|
-
return {
|
|
42620
|
-
writeRoots: [i2.scope.writeRoot],
|
|
42621
|
-
mapSpecifier: createAliasMapper({ readText: i2.readText, writeRoot: i2.scope.writeRoot }),
|
|
42622
|
-
...packageFolders.size > 0 ? { packageFolders } : {}
|
|
42623
|
-
};
|
|
42624
|
-
}
|
|
42625
|
-
|
|
42626
42863
|
// src/targetingMode.ts
|
|
42627
42864
|
var TARGETING_MODE_ENV = "QUIKPILOT_TARGETING_MODE";
|
|
42628
42865
|
function parse5(value) {
|
|
@@ -42809,7 +43046,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
42809
43046
|
var REPORT_COPY = "final-test-report.xml";
|
|
42810
43047
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
42811
43048
|
var MAX_FILES = 200;
|
|
42812
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
43049
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.35" : "dev";
|
|
42813
43050
|
function safeDestination(base, repoPath) {
|
|
42814
43051
|
if (!repoPath || (0, import_node_path21.isAbsolute)(repoPath)) return null;
|
|
42815
43052
|
const destination = (0, import_node_path21.resolve)(base, repoPath);
|
|
@@ -43115,11 +43352,22 @@ async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, r
|
|
|
43115
43352
|
}
|
|
43116
43353
|
async function loopWithTools2(args, tools2, deps) {
|
|
43117
43354
|
if (!tools2) return runTargetingLoop(args, deps);
|
|
43355
|
+
const log = deps.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
43356
|
+
let level = tools2;
|
|
43357
|
+
if (tools2.notes === true) {
|
|
43358
|
+
try {
|
|
43359
|
+
return await runTargetingLoop({ ...args, tools2, contractVersion: NOTES_LOOP_CONTRACT_VERSION }, deps);
|
|
43360
|
+
} catch (err) {
|
|
43361
|
+
if (!(err instanceof LoopFailure) || err.reason !== "contract_rejected") throw err;
|
|
43362
|
+
log({ event: "targeting.version_fallback", from: NOTES_LOOP_CONTRACT_VERSION, to: TOOLS2_LOOP_CONTRACT_VERSION });
|
|
43363
|
+
level = { ...tools2, notes: false };
|
|
43364
|
+
}
|
|
43365
|
+
}
|
|
43118
43366
|
try {
|
|
43119
|
-
return await runTargetingLoop({ ...args, tools2, contractVersion: TOOLS2_LOOP_CONTRACT_VERSION }, deps);
|
|
43367
|
+
return await runTargetingLoop({ ...args, tools2: level, contractVersion: TOOLS2_LOOP_CONTRACT_VERSION }, deps);
|
|
43120
43368
|
} catch (err) {
|
|
43121
43369
|
if (!(err instanceof LoopFailure) || err.reason !== "contract_rejected") throw err;
|
|
43122
|
-
|
|
43370
|
+
log({
|
|
43123
43371
|
event: "targeting.version_fallback",
|
|
43124
43372
|
from: TOOLS2_LOOP_CONTRACT_VERSION,
|
|
43125
43373
|
to: args.contractVersion ?? "targeting-loop-1"
|
|
@@ -43286,6 +43534,7 @@ function clampLoop(loop) {
|
|
|
43286
43534
|
...loop.fellBack ? { fellBack: true } : {},
|
|
43287
43535
|
...loop.fallbackReason ? { fallbackReason: String(loop.fallbackReason).slice(0, MAX_FALLBACK_REASON_CHARS) } : {},
|
|
43288
43536
|
...typeof loop.contractVersion === "string" && loop.contractVersion.length > 0 ? { contractVersion: loop.contractVersion.slice(0, 40) } : {},
|
|
43537
|
+
...clampNotesRecord(loop.notes) ? { notes: clampNotesRecord(loop.notes) } : {},
|
|
43289
43538
|
...clampRepoView(loop.repoView, loop.peakRequestTokens),
|
|
43290
43539
|
reads,
|
|
43291
43540
|
...refusedTurns.rows.length > 0 ? { refusedTurns: refusedTurns.rows } : {},
|
|
@@ -43451,7 +43700,9 @@ async function run(env2) {
|
|
|
43451
43700
|
log: (e) => console.log(JSON.stringify(e))
|
|
43452
43701
|
});
|
|
43453
43702
|
const mapMode = scope.view === "map";
|
|
43454
|
-
const
|
|
43703
|
+
const toolsDecision = decideTools(resolveToolsSetting(), scope, resolveToolsMinTokens());
|
|
43704
|
+
console.log(JSON.stringify({ event: "tools.decided", ...toolsDecision }));
|
|
43705
|
+
const tools2 = toolsDecision.on ? buildToolsV2Env({ scope, readText: readCheckoutText2, notes: notesEnabled() }) : void 0;
|
|
43455
43706
|
if (mapMode) {
|
|
43456
43707
|
console.log(JSON.stringify(startMapMode({ testCommand: packet.commands.test, targetingMode: resolveTargetingMode(), codegenMode: resolveCodegenMode() })));
|
|
43457
43708
|
}
|
|
@@ -43905,6 +44156,26 @@ function emptyFindings() {
|
|
|
43905
44156
|
function isLine(n) {
|
|
43906
44157
|
return typeof n === "number" && Number.isInteger(n) && n >= 1;
|
|
43907
44158
|
}
|
|
44159
|
+
var MAX_FINDINGS_CHARS = 6e3;
|
|
44160
|
+
function capFindingsSize(findings, max = MAX_FINDINGS_CHARS) {
|
|
44161
|
+
const size = (f2) => JSON.stringify(f2).length;
|
|
44162
|
+
if (size(findings) <= max) return { findings, trimmed: false };
|
|
44163
|
+
let f = { ...findings, files: [...findings.files], callPath: [...findings.callPath], evidence: [...findings.evidence], openQuestions: [...findings.openQuestions] };
|
|
44164
|
+
const stages = [
|
|
44165
|
+
(x) => ({ ...x, openQuestions: [] }),
|
|
44166
|
+
(x) => ({ ...x, callPath: x.callPath.slice(0, 5) }),
|
|
44167
|
+
(x) => ({ ...x, files: x.files.map((y) => ({ ...y, symbols: y.symbols.slice(0, 2) })), evidence: x.evidence.map((y) => ({ ...y, symbols: y.symbols.slice(0, 2) })) }),
|
|
44168
|
+
(x) => ({ ...x, files: x.files.slice(0, 6) }),
|
|
44169
|
+
(x) => ({ ...x, callPath: [] }),
|
|
44170
|
+
(x) => ({ ...x, evidence: x.evidence.slice(0, 3) }),
|
|
44171
|
+
(x) => ({ ...x, files: x.files.slice(0, 3), evidence: x.evidence.slice(0, 1) })
|
|
44172
|
+
];
|
|
44173
|
+
for (const stage of stages) {
|
|
44174
|
+
f = stage(f);
|
|
44175
|
+
if (size(f) <= max) break;
|
|
44176
|
+
}
|
|
44177
|
+
return { findings: f, trimmed: true };
|
|
44178
|
+
}
|
|
43908
44179
|
function verifyFindings(raw, ledger, ctx) {
|
|
43909
44180
|
const dropped = emptyDropped();
|
|
43910
44181
|
const redactions = emptyRedactionCounts();
|
|
@@ -44348,7 +44619,8 @@ async function investigate(env2, runToken, deps, log) {
|
|
|
44348
44619
|
const commit2 = deps.headCommit();
|
|
44349
44620
|
const redactions = { ...summary.redactions };
|
|
44350
44621
|
addRedactionCounts(redactions, verified.redactions);
|
|
44351
|
-
const
|
|
44622
|
+
const capped = capFindingsSize(verified.findings);
|
|
44623
|
+
const { findings } = capped;
|
|
44352
44624
|
log({
|
|
44353
44625
|
event: "investigate.done",
|
|
44354
44626
|
verdict: findings.verdict,
|
|
@@ -44357,6 +44629,7 @@ async function investigate(env2, runToken, deps, log) {
|
|
|
44357
44629
|
openQuestions: findings.openQuestions.length,
|
|
44358
44630
|
downgraded: verified.downgraded,
|
|
44359
44631
|
dropped: verified.dropped,
|
|
44632
|
+
...capped.trimmed ? { capped: true } : {},
|
|
44360
44633
|
redactions
|
|
44361
44634
|
});
|
|
44362
44635
|
return {
|