@quikit/quikpilot-runner 9.3.0-rc.33 → 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 +4 -0
- package/dist/index.js +311 -31
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,10 @@ 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
|
+
|
|
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.
|
|
156
|
+
|
|
153
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).
|
|
154
158
|
|
|
155
159
|
**9.3.0-rc.32 — map mode: a one-page summary of a large repository instead of its file list (QUIKTR-1580, S5; contract §35).** Needs the AI Runtime with `targeting-loop-2` and `codegen-loop-4` (each switched on by its own flag) before a large repository can use it; a repository small enough for its list is exactly as before. (1) **When:** `QUIKPILOT_MAP=auto` (the default) switches map mode on only when the write folder's file list would cost more than 40,000 tokens on the wire, i.e. where the old way could not work (QuikProjects alone: about 69,000; the whole QuikIT repository: about 445,000; the pilot repository: about 1,000). `on` forces it on any repository, `off` never uses it. (2) **What the AI gets:** `repoMap` first in every request, in place of `workspaceListing`: the folder it may change, the folders it may read (that folder plus the local workspace packages its project depends on, read-only, at most 8, from the root `package.json` `workspaces` or `pnpm-workspace.yaml`), how many files they hold, a folder tree with counts, the file types, the project's own import shortcuts (tsconfig `paths`), packages and test layout, and its guidance files (`AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, `README.md` of the write folder and every folder above it: tracked, not protected, scrubbed, 2,000 characters each and 6,000 in all). At most 4,000 tokens, the same bytes on the same commit (QuikIT: 3,966 for QuikProjects, 3,915 for the whole repository). The AI finds files with `list_files`, `grep` and `read_file` as before. (3) **The runner's answers:** a read, list or search outside the readable folders is answered `outside_read_scope` (from the path alone, never saying whether a file exists there), a change outside the write folder `outside_write_scope`; `not_found` and `exists` as before. (4) **No fallback:** map mode needs both loops, so it switches them on whatever `QUIKPILOT_TARGETING_MODE` / `QUIKPILOT_CODEGEN_MODE` say, and needs a test command (without one the run stops before any work, saying so). There is no single targeting call and no per-file code call to fall back to (both need the list): a map run that cannot finish ends with a plain sentence, recorded as `map_failed`. (5) **Smaller requests:** the discovered test files go on the wire only while they cost under 12,000 tokens (else the report's own no-signal form), at most 100 existing tests are named on the wire (the runner still holds every one), and old read outputs are dropped from 40,000 tokens on (the hard ceiling stays 90,000). On QuikProjects the first targeting request is about 18,000 tokens where the list alone was 69,000. (6) **The record:** both loop records gain `view`, `fileCount`, `readRoots`, `mapTokens`, `peakRequestTokens` and `failReason`, in map mode only. The job log gains `map.built` (counts) and `map.mode`.
|
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,
|
|
@@ -39253,11 +39414,19 @@ function estimateRequestTokens(contextData) {
|
|
|
39253
39414
|
return PROMPT_OVERHEAD_TOKENS + estimateTokens(JSON.stringify(contextData ?? {}, null, 2));
|
|
39254
39415
|
}
|
|
39255
39416
|
|
|
39417
|
+
// src/turnTimeout.ts
|
|
39418
|
+
var FIRST_TURN_TIMEOUT_MS = 42e4;
|
|
39419
|
+
function turnTimeoutFor(turn, perTurnMs, setByCaller) {
|
|
39420
|
+
if (setByCaller || turn > 1) return perTurnMs;
|
|
39421
|
+
return Math.max(perTurnMs, FIRST_TURN_TIMEOUT_MS);
|
|
39422
|
+
}
|
|
39423
|
+
|
|
39256
39424
|
// src/targetingLoop.ts
|
|
39257
39425
|
var LOOP_CONTRACT_VERSION = "targeting-loop-1";
|
|
39258
39426
|
var MAP_LOOP_CONTRACT_VERSION = "targeting-loop-2";
|
|
39259
39427
|
var TOOLS2_LOOP_CONTRACT_VERSION = "targeting-loop-3";
|
|
39260
39428
|
var TOOLS2_LOOP_TOOLS = ["list_files", "read_file", "grep", "find_definition"];
|
|
39429
|
+
var NOTES_LOOP_CONTRACT_VERSION = "targeting-loop-4";
|
|
39261
39430
|
var LoopFailure = class extends Error {
|
|
39262
39431
|
reason;
|
|
39263
39432
|
runtimeCode;
|
|
@@ -39303,7 +39472,7 @@ async function runTargetingLoop(args, deps) {
|
|
|
39303
39472
|
const now = deps.now ?? Date.now;
|
|
39304
39473
|
const log = deps.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
39305
39474
|
const turnTimeoutMs = deps.turnTimeoutMs ?? 18e4;
|
|
39306
|
-
const deadlineMs = deps.deadlineMs ??
|
|
39475
|
+
const deadlineMs = deps.deadlineMs ?? 9e5;
|
|
39307
39476
|
const env2 = {
|
|
39308
39477
|
listing: new Set(args.listing),
|
|
39309
39478
|
visible: buildVisibleListing(args.listing, readDenied(args.deniedPaths)),
|
|
@@ -39315,6 +39484,22 @@ async function runTargetingLoop(args, deps) {
|
|
|
39315
39484
|
...args.readRoots ? { readRoots: args.readRoots } : {},
|
|
39316
39485
|
...args.tools2 ? { tools2: args.tools2 } : {}
|
|
39317
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();
|
|
39318
39503
|
const ledger = newLedger();
|
|
39319
39504
|
const reads = [];
|
|
39320
39505
|
const transcript = [];
|
|
@@ -39343,7 +39528,9 @@ async function runTargetingLoop(args, deps) {
|
|
|
39343
39528
|
},
|
|
39344
39529
|
transcript,
|
|
39345
39530
|
toolResults,
|
|
39346
|
-
...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 }) } : {}
|
|
39347
39534
|
}
|
|
39348
39535
|
});
|
|
39349
39536
|
const snapshot = (stopReason) => ({
|
|
@@ -39355,7 +39542,8 @@ async function runTargetingLoop(args, deps) {
|
|
|
39355
39542
|
reads: [...reads],
|
|
39356
39543
|
...refusedTurns.length > 0 ? { refusedTurns: refusedTurns.map((t) => ({ turn: t.turn, rules: [...t.rules] })) } : {},
|
|
39357
39544
|
...peakRequestTokens > 0 ? { peakRequestTokens } : {},
|
|
39358
|
-
...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 } } : {}
|
|
39359
39547
|
});
|
|
39360
39548
|
log({ event: "targeting.loop_start", mode: "loop", maxTurns: limits.maxTurns, maxToolCalls: limits.maxToolCalls, listingFiles: args.listing.length });
|
|
39361
39549
|
try {
|
|
@@ -39375,7 +39563,7 @@ async function runTargetingLoop(args, deps) {
|
|
|
39375
39563
|
const turnStarted = now();
|
|
39376
39564
|
let envelope;
|
|
39377
39565
|
try {
|
|
39378
|
-
envelope = await deps.post(contextData, AbortSignal.timeout(turnTimeoutMs));
|
|
39566
|
+
envelope = await deps.post(contextData, AbortSignal.timeout(turnTimeoutFor(turn, turnTimeoutMs, deps.turnTimeoutMs !== void 0)));
|
|
39379
39567
|
} catch (err) {
|
|
39380
39568
|
throw classifyTransport(err);
|
|
39381
39569
|
}
|
|
@@ -39476,6 +39664,14 @@ async function runTargetingLoop(args, deps) {
|
|
|
39476
39664
|
});
|
|
39477
39665
|
toolResults.push(...results);
|
|
39478
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
|
+
}
|
|
39479
39675
|
noProgressStreak = results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
39480
39676
|
if (noProgressStreak >= 2) forced = "no_progress";
|
|
39481
39677
|
else if (ledger.toolCalls >= limits.maxToolCalls) forced = "tool_budget";
|
|
@@ -39532,6 +39728,7 @@ var CODEGEN_LOOP_2_CONTRACT_VERSION = "codegen-loop-2";
|
|
|
39532
39728
|
var CODEGEN_LOOP_3_CONTRACT_VERSION = "codegen-loop-3";
|
|
39533
39729
|
var CODEGEN_LOOP_4_CONTRACT_VERSION = "codegen-loop-4";
|
|
39534
39730
|
var CODEGEN_LOOP_5_CONTRACT_VERSION = "codegen-loop-5";
|
|
39731
|
+
var CODEGEN_LOOP_6_CONTRACT_VERSION = "codegen-loop-6";
|
|
39535
39732
|
var MAP_SOFT_REQUEST_TOKENS = 4e4;
|
|
39536
39733
|
var CodegenLoopFailure = class extends Error {
|
|
39537
39734
|
reason;
|
|
@@ -39601,13 +39798,18 @@ function isTestAnswer(x) {
|
|
|
39601
39798
|
return isPlainObject3(x) && typeof x.passed === "number" && Array.isArray(x.failingTests);
|
|
39602
39799
|
}
|
|
39603
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
|
+
}
|
|
39604
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) }));
|
|
39605
39807
|
const ws = createCodegenWorkspace({
|
|
39606
|
-
|
|
39607
|
-
scrub: makeCodeScrubber(deps.secrets ?? [], (c) => (deps.log ?? ((e) => console.log(JSON.stringify(e))))({ event: "loop.scrubbed", ...nonZero(c) })),
|
|
39808
|
+
scrub,
|
|
39608
39809
|
listing: args.readListing ?? args.listing,
|
|
39609
39810
|
...args.readRoots ? { readRoots: args.readRoots } : {},
|
|
39610
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) } : {},
|
|
39611
39813
|
deniedPaths: args.deniedPaths,
|
|
39612
39814
|
protectedTestPaths: args.protectedTestPaths,
|
|
39613
39815
|
...args.discoveredTests ? { discoveredTests: args.discoveredTests } : {},
|
|
@@ -39649,8 +39851,13 @@ async function runCodegenLoop(args, deps) {
|
|
|
39649
39851
|
log,
|
|
39650
39852
|
now
|
|
39651
39853
|
}) : null;
|
|
39652
|
-
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;
|
|
39653
39856
|
let peakRequestTokens = 0;
|
|
39857
|
+
let notes = "";
|
|
39858
|
+
let stubbed = 0;
|
|
39859
|
+
const turnOfId = /* @__PURE__ */ new Map();
|
|
39860
|
+
const callOfId = /* @__PURE__ */ new Map();
|
|
39654
39861
|
const previousAttempt = args.previousAttempt && !harness ? previousForLoop2(args.previousAttempt) : args.previousAttempt;
|
|
39655
39862
|
if (tests && args.seed && args.seed.length > 0) tests.markSeen(versionOfFiles(filesOnDisk()));
|
|
39656
39863
|
let testMs = 0;
|
|
@@ -39735,7 +39942,9 @@ async function runCodegenLoop(args, deps) {
|
|
|
39735
39942
|
transcript,
|
|
39736
39943
|
toolResults,
|
|
39737
39944
|
// QUIKTR-1581 (§36): the tools this run offers, in the order the AI Runtime lists them. `call_function` only where it is on.
|
|
39738
|
-
...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 }) } : {}
|
|
39739
39948
|
}
|
|
39740
39949
|
});
|
|
39741
39950
|
const snapshot = (stopReason) => ({
|
|
@@ -39751,7 +39960,8 @@ async function runCodegenLoop(args, deps) {
|
|
|
39751
39960
|
...tests ? { contractVersion, testRuns: tests.record() } : {},
|
|
39752
39961
|
...refusedTurns.length > 0 ? { refusedTurns: refusedTurns.map((t) => ({ turn: t.turn, rules: [...t.rules] })) } : {},
|
|
39753
39962
|
reasoning: [...reasoning],
|
|
39754
|
-
...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 } } : {}
|
|
39755
39965
|
});
|
|
39756
39966
|
const makeRoom = (nextTurn, nextFinal, finalReason) => {
|
|
39757
39967
|
const under = (limit) => estimateRequestTokens(buildContext(nextTurn, nextFinal, finalReason)) <= limit;
|
|
@@ -39845,7 +40055,7 @@ async function runCodegenLoop(args, deps) {
|
|
|
39845
40055
|
let envelope;
|
|
39846
40056
|
sent = { entries: transcript.length, results: toolResults.length };
|
|
39847
40057
|
try {
|
|
39848
|
-
envelope = await deps.post(contextData, AbortSignal.timeout(turnTimeoutMs));
|
|
40058
|
+
envelope = await deps.post(contextData, AbortSignal.timeout(turnTimeoutFor(turn, turnTimeoutMs, deps.turnTimeoutMs !== void 0)));
|
|
39849
40059
|
} catch (err) {
|
|
39850
40060
|
throw classifyTransport2(err);
|
|
39851
40061
|
}
|
|
@@ -40052,6 +40262,14 @@ async function runCodegenLoop(args, deps) {
|
|
|
40052
40262
|
transcript.push({ turn, ...reasonText ? { reasoning: reasonText } : {}, toolCalls: calls.map((c) => ({ id: c.id, name: c.name, args: c.args })) });
|
|
40053
40263
|
toolResults.push(...results);
|
|
40054
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
|
+
}
|
|
40055
40273
|
noProgressStreak = harness ? results.every((r) => NOTHING_NEW.has(r.status)) ? noProgressStreak + 1 : 0 : results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
40056
40274
|
if (noProgressStreak >= (harness ? HARNESS_NO_PROGRESS_TURNS : 2)) forced = "no_progress";
|
|
40057
40275
|
else if (ledger.toolCalls >= limits.maxToolCalls) forced = "tool_budget";
|
|
@@ -40483,6 +40701,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40483
40701
|
statusCounts,
|
|
40484
40702
|
...whole2(loop.syntaxWarnings) > 0 ? { syntaxWarnings: whole2(loop.syntaxWarnings) } : {},
|
|
40485
40703
|
...typeof loop.contractVersion === "string" && loop.contractVersion.length > 0 ? { contractVersion: loop.contractVersion.slice(0, 40) } : {},
|
|
40704
|
+
...clampNotesRecord(loop.notes) ? { notes: clampNotesRecord(loop.notes) } : {},
|
|
40486
40705
|
...clampRepoView(loop.repoView, loop.peakRequestTokens),
|
|
40487
40706
|
...testRuns.length > 0 ? { testRuns } : {},
|
|
40488
40707
|
...refused2.rows.length > 0 ? { refusedTurns: refused2.rows } : {},
|
|
@@ -40954,6 +41173,12 @@ async function runCodegenStep(p) {
|
|
|
40954
41173
|
log({ event: "codegen.attempt_start", attempt: 1 });
|
|
40955
41174
|
const firstStarted = now();
|
|
40956
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
|
+
}
|
|
40957
41182
|
if ("failure" in first && first.failure.reason === "contract_rejected" && p.tools2 && args?.harness === true) {
|
|
40958
41183
|
log({ event: "codegen.version_fallback", from: "codegen-loop-5", to: p.scope?.view === "map" ? "codegen-loop-4" : "codegen-loop-3" });
|
|
40959
41184
|
p.tools2 = void 0;
|
|
@@ -42273,12 +42498,45 @@ function startMapMode(i2) {
|
|
|
42273
42498
|
return { event: "map.mode", ...overrode ? { overrode: { targeting: i2.targetingMode, codegen: i2.codegenMode } } : {} };
|
|
42274
42499
|
}
|
|
42275
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
|
+
|
|
42276
42534
|
// src/repoMap.ts
|
|
42277
42535
|
var import_node_path19 = require("node:path");
|
|
42278
42536
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
42279
42537
|
var MAX_FOLDERS = 200;
|
|
42280
42538
|
var MAX_LANGUAGES = 12;
|
|
42281
|
-
var
|
|
42539
|
+
var GUIDANCE_NAMES2 = ["AGENTS.md", "CLAUDE.md", "CONTRIBUTING.md", "README.md"];
|
|
42282
42540
|
var GUIDANCE_FILE_CHARS = 2e3;
|
|
42283
42541
|
var GUIDANCE_TOTAL_CHARS = 6e3;
|
|
42284
42542
|
var MAX_GUIDANCE_FILES = 8;
|
|
@@ -42299,7 +42557,7 @@ function guidanceFiles(i2, perFile2, total) {
|
|
|
42299
42557
|
const out = [];
|
|
42300
42558
|
let left = total;
|
|
42301
42559
|
for (let d = i2.writeRoot; ; d = parentOf2(d)) {
|
|
42302
|
-
for (const name of
|
|
42560
|
+
for (const name of GUIDANCE_NAMES2) {
|
|
42303
42561
|
const path = d === "" ? name : `${d}/${name}`;
|
|
42304
42562
|
if (out.length >= MAX_GUIDANCE_FILES || left < MIN_GUIDANCE_CHARS) break;
|
|
42305
42563
|
if (!tracked.has(path) || matchesDeniedPath(path, denied)) continue;
|
|
@@ -42602,20 +42860,6 @@ function buildRepoScope(i2) {
|
|
|
42602
42860
|
};
|
|
42603
42861
|
}
|
|
42604
42862
|
|
|
42605
|
-
// src/toolsMode.ts
|
|
42606
|
-
var TOOLS2_ENV = "QUIKPILOT_TOOLS2";
|
|
42607
|
-
function resolveToolsSetting(env2 = process.env) {
|
|
42608
|
-
return env2[TOOLS2_ENV]?.trim().toLowerCase() === "off" ? "off" : "on";
|
|
42609
|
-
}
|
|
42610
|
-
function buildToolsV2Env(i2) {
|
|
42611
|
-
const packageFolders = new Map(i2.scope.packages.map((p) => [p.name, p.folder]));
|
|
42612
|
-
return {
|
|
42613
|
-
writeRoots: [i2.scope.writeRoot],
|
|
42614
|
-
mapSpecifier: createAliasMapper({ readText: i2.readText, writeRoot: i2.scope.writeRoot }),
|
|
42615
|
-
...packageFolders.size > 0 ? { packageFolders } : {}
|
|
42616
|
-
};
|
|
42617
|
-
}
|
|
42618
|
-
|
|
42619
42863
|
// src/targetingMode.ts
|
|
42620
42864
|
var TARGETING_MODE_ENV = "QUIKPILOT_TARGETING_MODE";
|
|
42621
42865
|
function parse5(value) {
|
|
@@ -42802,7 +43046,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
42802
43046
|
var REPORT_COPY = "final-test-report.xml";
|
|
42803
43047
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
42804
43048
|
var MAX_FILES = 200;
|
|
42805
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
43049
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.35" : "dev";
|
|
42806
43050
|
function safeDestination(base, repoPath) {
|
|
42807
43051
|
if (!repoPath || (0, import_node_path21.isAbsolute)(repoPath)) return null;
|
|
42808
43052
|
const destination = (0, import_node_path21.resolve)(base, repoPath);
|
|
@@ -43108,11 +43352,22 @@ async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, r
|
|
|
43108
43352
|
}
|
|
43109
43353
|
async function loopWithTools2(args, tools2, deps) {
|
|
43110
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
|
+
}
|
|
43111
43366
|
try {
|
|
43112
|
-
return await runTargetingLoop({ ...args, tools2, contractVersion: TOOLS2_LOOP_CONTRACT_VERSION }, deps);
|
|
43367
|
+
return await runTargetingLoop({ ...args, tools2: level, contractVersion: TOOLS2_LOOP_CONTRACT_VERSION }, deps);
|
|
43113
43368
|
} catch (err) {
|
|
43114
43369
|
if (!(err instanceof LoopFailure) || err.reason !== "contract_rejected") throw err;
|
|
43115
|
-
|
|
43370
|
+
log({
|
|
43116
43371
|
event: "targeting.version_fallback",
|
|
43117
43372
|
from: TOOLS2_LOOP_CONTRACT_VERSION,
|
|
43118
43373
|
to: args.contractVersion ?? "targeting-loop-1"
|
|
@@ -43279,6 +43534,7 @@ function clampLoop(loop) {
|
|
|
43279
43534
|
...loop.fellBack ? { fellBack: true } : {},
|
|
43280
43535
|
...loop.fallbackReason ? { fallbackReason: String(loop.fallbackReason).slice(0, MAX_FALLBACK_REASON_CHARS) } : {},
|
|
43281
43536
|
...typeof loop.contractVersion === "string" && loop.contractVersion.length > 0 ? { contractVersion: loop.contractVersion.slice(0, 40) } : {},
|
|
43537
|
+
...clampNotesRecord(loop.notes) ? { notes: clampNotesRecord(loop.notes) } : {},
|
|
43282
43538
|
...clampRepoView(loop.repoView, loop.peakRequestTokens),
|
|
43283
43539
|
reads,
|
|
43284
43540
|
...refusedTurns.rows.length > 0 ? { refusedTurns: refusedTurns.rows } : {},
|
|
@@ -43444,7 +43700,9 @@ async function run(env2) {
|
|
|
43444
43700
|
log: (e) => console.log(JSON.stringify(e))
|
|
43445
43701
|
});
|
|
43446
43702
|
const mapMode = scope.view === "map";
|
|
43447
|
-
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;
|
|
43448
43706
|
if (mapMode) {
|
|
43449
43707
|
console.log(JSON.stringify(startMapMode({ testCommand: packet.commands.test, targetingMode: resolveTargetingMode(), codegenMode: resolveCodegenMode() })));
|
|
43450
43708
|
}
|
|
@@ -43898,6 +44156,26 @@ function emptyFindings() {
|
|
|
43898
44156
|
function isLine(n) {
|
|
43899
44157
|
return typeof n === "number" && Number.isInteger(n) && n >= 1;
|
|
43900
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
|
+
}
|
|
43901
44179
|
function verifyFindings(raw, ledger, ctx) {
|
|
43902
44180
|
const dropped = emptyDropped();
|
|
43903
44181
|
const redactions = emptyRedactionCounts();
|
|
@@ -44341,7 +44619,8 @@ async function investigate(env2, runToken, deps, log) {
|
|
|
44341
44619
|
const commit2 = deps.headCommit();
|
|
44342
44620
|
const redactions = { ...summary.redactions };
|
|
44343
44621
|
addRedactionCounts(redactions, verified.redactions);
|
|
44344
|
-
const
|
|
44622
|
+
const capped = capFindingsSize(verified.findings);
|
|
44623
|
+
const { findings } = capped;
|
|
44345
44624
|
log({
|
|
44346
44625
|
event: "investigate.done",
|
|
44347
44626
|
verdict: findings.verdict,
|
|
@@ -44350,6 +44629,7 @@ async function investigate(env2, runToken, deps, log) {
|
|
|
44350
44629
|
openQuestions: findings.openQuestions.length,
|
|
44351
44630
|
downgraded: verified.downgraded,
|
|
44352
44631
|
dropped: verified.dropped,
|
|
44632
|
+
...capped.trimmed ? { capped: true } : {},
|
|
44353
44633
|
redactions
|
|
44354
44634
|
});
|
|
44355
44635
|
return {
|