@quikit/quikpilot-runner 9.3.0-rc.90 → 9.3.0-rc.92
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 +596 -566
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -144,13 +144,13 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
144
144
|
}
|
|
145
145
|
readAsync = /* @__PURE__ */ __name(async (url) => {
|
|
146
146
|
if (isFileURI(url)) {
|
|
147
|
-
return new Promise((
|
|
147
|
+
return new Promise((resolve6, reject) => {
|
|
148
148
|
var xhr = new XMLHttpRequest();
|
|
149
149
|
xhr.open("GET", url, true);
|
|
150
150
|
xhr.responseType = "arraybuffer";
|
|
151
151
|
xhr.onload = () => {
|
|
152
152
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
153
|
-
|
|
153
|
+
resolve6(xhr.response);
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
reject(xhr.status);
|
|
@@ -343,9 +343,9 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
343
343
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
344
344
|
var info2 = getWasmImports();
|
|
345
345
|
if (Module["instantiateWasm"]) {
|
|
346
|
-
return new Promise((
|
|
346
|
+
return new Promise((resolve6, reject) => {
|
|
347
347
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
348
|
-
|
|
348
|
+
resolve6(receiveInstance(mod, inst));
|
|
349
349
|
});
|
|
350
350
|
});
|
|
351
351
|
}
|
|
@@ -1678,8 +1678,8 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
1678
1678
|
if (runtimeInitialized) {
|
|
1679
1679
|
moduleRtn = Module;
|
|
1680
1680
|
} else {
|
|
1681
|
-
moduleRtn = new Promise((
|
|
1682
|
-
readyPromiseResolve =
|
|
1681
|
+
moduleRtn = new Promise((resolve6, reject) => {
|
|
1682
|
+
readyPromiseResolve = resolve6;
|
|
1683
1683
|
readyPromiseReject = reject;
|
|
1684
1684
|
});
|
|
1685
1685
|
}
|
|
@@ -17394,7 +17394,7 @@ var require_resolve_uri_umd = __commonJS2({
|
|
|
17394
17394
|
}
|
|
17395
17395
|
url.path = path;
|
|
17396
17396
|
}
|
|
17397
|
-
function
|
|
17397
|
+
function resolve6(input, base) {
|
|
17398
17398
|
if (!input && !base)
|
|
17399
17399
|
return "";
|
|
17400
17400
|
const url = parseUrl(input);
|
|
@@ -17447,7 +17447,7 @@ var require_resolve_uri_umd = __commonJS2({
|
|
|
17447
17447
|
return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
17448
17448
|
}
|
|
17449
17449
|
}
|
|
17450
|
-
return
|
|
17450
|
+
return resolve6;
|
|
17451
17451
|
}));
|
|
17452
17452
|
}
|
|
17453
17453
|
});
|
|
@@ -17792,8 +17792,8 @@ var require_trace_mapping_umd = __commonJS2({
|
|
|
17792
17792
|
this.sources = sources;
|
|
17793
17793
|
this.sourcesContent = sourcesContent;
|
|
17794
17794
|
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
17795
|
-
const
|
|
17796
|
-
this.resolvedSources = sources.map(
|
|
17795
|
+
const resolve6 = resolver(mapUrl, sourceRoot);
|
|
17796
|
+
this.resolvedSources = sources.map(resolve6);
|
|
17797
17797
|
const { mappings } = parsed;
|
|
17798
17798
|
if (typeof mappings === "string") {
|
|
17799
17799
|
this._encoded = mappings;
|
|
@@ -28982,6 +28982,19 @@ function gitEnv(extra = {}, source = process.env) {
|
|
|
28982
28982
|
}
|
|
28983
28983
|
return { ...env2, ...extra };
|
|
28984
28984
|
}
|
|
28985
|
+
function checkBranchName(name2) {
|
|
28986
|
+
if (typeof name2 !== "string" || name2.length === 0) return "it is empty";
|
|
28987
|
+
if (name2.length > 255) return "it is longer than 255 characters";
|
|
28988
|
+
if (name2.startsWith("-") || name2.startsWith("+")) return `it starts with "${name2[0]}", which git would read as an option or a forced push`;
|
|
28989
|
+
if (/[\u0000-\u0020\u007f]/.test(name2)) return "it holds a space or a control character";
|
|
28990
|
+
if (/[:~^?*[\\]/.test(name2)) return "it holds one of : ~ ^ ? * [ \\";
|
|
28991
|
+
if (name2.includes("..")) return 'it holds ".."';
|
|
28992
|
+
if (name2.includes("@{") || name2 === "@") return 'it holds "@{" or is "@"';
|
|
28993
|
+
if (name2.startsWith("/") || name2.endsWith("/") || name2.includes("//")) return "it has an empty part between slashes";
|
|
28994
|
+
if (name2.endsWith(".") || name2.endsWith(".lock")) return 'it ends with "." or ".lock"';
|
|
28995
|
+
if (name2.split("/").some((part) => part.startsWith("."))) return 'a part of it starts with "."';
|
|
28996
|
+
return null;
|
|
28997
|
+
}
|
|
28985
28998
|
|
|
28986
28999
|
// src/proposal.ts
|
|
28987
29000
|
var import_node_child_process3 = require("node:child_process");
|
|
@@ -29073,8 +29086,8 @@ function currentBranch() {
|
|
|
29073
29086
|
}
|
|
29074
29087
|
function checkoutTargetBranch(targetBranch) {
|
|
29075
29088
|
if (!targetBranch || targetBranch === currentBranch()) return;
|
|
29076
|
-
git(["fetch", "origin", targetBranch]);
|
|
29077
|
-
git(["checkout", targetBranch]);
|
|
29089
|
+
git(["fetch", "origin", "--end-of-options", targetBranch]);
|
|
29090
|
+
git(["checkout", "--end-of-options", targetBranch]);
|
|
29078
29091
|
}
|
|
29079
29092
|
var LIST_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
|
|
29080
29093
|
var RUNNER_OWN_FOLDER = ".quikpilot";
|
|
@@ -29146,11 +29159,11 @@ var REPOSITORY_NOT_FOUND_RE = /Repository not found/i;
|
|
|
29146
29159
|
var SERVER_ERROR_DELAYS_MS = [5e3, 15e3, 3e4, 6e4];
|
|
29147
29160
|
var SERVER_ERROR_RE = /Internal Server Error|Bad Gateway|Service Unavailable|Gateway Timeout|returned error: 5\d\d/i;
|
|
29148
29161
|
var PUSH_TRY_TIMEOUT_MS = 3 * 6e4;
|
|
29149
|
-
var sleepAsync = (ms) => new Promise((
|
|
29162
|
+
var sleepAsync = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
29150
29163
|
function gitPushTry(args2, extraEnv) {
|
|
29151
|
-
return new Promise((
|
|
29164
|
+
return new Promise((resolve6, reject) => {
|
|
29152
29165
|
(0, import_node_child_process.execFile)("git", [...NO_HOOKS_ARGS, ...args2], { encoding: "utf8", env: gitEnv(extraEnv), timeout: PUSH_TRY_TIMEOUT_MS }, (err2, _stdout, stderr) => {
|
|
29153
|
-
if (!err2) return
|
|
29166
|
+
if (!err2) return resolve6();
|
|
29154
29167
|
if (err2.killed) return reject(new Error(`git push did not finish within ${PUSH_TRY_TIMEOUT_MS / 6e4} minutes and was stopped`));
|
|
29155
29168
|
reject(Object.assign(err2, { stderr }));
|
|
29156
29169
|
});
|
|
@@ -29163,7 +29176,7 @@ async function push(branch, installationToken, sleep = sleepAsync) {
|
|
|
29163
29176
|
let serverRetries = 0;
|
|
29164
29177
|
for (let attempt2 = 0; ; attempt2 += 1) {
|
|
29165
29178
|
try {
|
|
29166
|
-
await gitPushTry(["push", "--set-upstream", "origin", branch], {
|
|
29179
|
+
await gitPushTry(["push", "--set-upstream", "origin", "--end-of-options", `refs/heads/${branch}:refs/heads/${branch}`], {
|
|
29167
29180
|
GIT_CONFIG_COUNT: "1",
|
|
29168
29181
|
GIT_CONFIG_KEY_0: "http.https://github.com/.extraheader",
|
|
29169
29182
|
GIT_CONFIG_VALUE_0: `AUTHORIZATION: basic ${basicAuth}`
|
|
@@ -37030,6 +37043,55 @@ function usedByOf(helper, testFiles, read) {
|
|
|
37030
37043
|
return { files: using.slice(0, MAX_USED_BY), count: using.length };
|
|
37031
37044
|
}
|
|
37032
37045
|
|
|
37046
|
+
// src/targetingErrors.ts
|
|
37047
|
+
var DeniedPathError = class extends Error {
|
|
37048
|
+
constructor(message) {
|
|
37049
|
+
super(message);
|
|
37050
|
+
this.name = "DeniedPathError";
|
|
37051
|
+
}
|
|
37052
|
+
};
|
|
37053
|
+
var TargetingHttpError = class extends Error {
|
|
37054
|
+
status;
|
|
37055
|
+
constructor(status, statusText) {
|
|
37056
|
+
super(`Targeting call failed: ${status} ${statusText}`);
|
|
37057
|
+
this.name = "TargetingHttpError";
|
|
37058
|
+
this.status = status;
|
|
37059
|
+
}
|
|
37060
|
+
};
|
|
37061
|
+
|
|
37062
|
+
// src/loopShared.ts
|
|
37063
|
+
var MAX_ID_CHARS = 64;
|
|
37064
|
+
var MAX_CALLS_IN_A_REPLY = 50;
|
|
37065
|
+
var MAX_ARGS_JSON_CHARS = 1e3;
|
|
37066
|
+
function isPlainObject(x) {
|
|
37067
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
37068
|
+
}
|
|
37069
|
+
function safeArgs(args2) {
|
|
37070
|
+
try {
|
|
37071
|
+
return JSON.stringify(args2).length <= MAX_ARGS_JSON_CHARS ? args2 : { _omitted: "too large" };
|
|
37072
|
+
} catch {
|
|
37073
|
+
return { _omitted: "unreadable" };
|
|
37074
|
+
}
|
|
37075
|
+
}
|
|
37076
|
+
function transportReason(err2) {
|
|
37077
|
+
if (err2 instanceof TargetingHttpError) return "http_error";
|
|
37078
|
+
const name2 = err2?.name;
|
|
37079
|
+
if (name2 === "TimeoutError" || name2 === "AbortError") return "turn_timeout";
|
|
37080
|
+
return "transport";
|
|
37081
|
+
}
|
|
37082
|
+
function parseToolCalls(raw, usedIds) {
|
|
37083
|
+
if (!Array.isArray(raw) || raw.length === 0 || raw.length > MAX_CALLS_IN_A_REPLY) return "bad_reply";
|
|
37084
|
+
const calls = [];
|
|
37085
|
+
for (const c of raw) {
|
|
37086
|
+
if (!isPlainObject(c) || typeof c.id !== "string" || c.id.length === 0 || c.id.length > MAX_ID_CHARS || typeof c.name !== "string") {
|
|
37087
|
+
return "bad_reply";
|
|
37088
|
+
}
|
|
37089
|
+
if (usedIds.has(c.id) || calls.some((x) => x.id === c.id)) return "duplicate_call_ids";
|
|
37090
|
+
calls.push({ id: c.id, name: c.name, args: c.args });
|
|
37091
|
+
}
|
|
37092
|
+
return { calls };
|
|
37093
|
+
}
|
|
37094
|
+
|
|
37033
37095
|
// src/targetingTools.ts
|
|
37034
37096
|
var import_node_fs2 = require("node:fs");
|
|
37035
37097
|
var import_node_path5 = require("node:path");
|
|
@@ -38442,9 +38504,10 @@ var DEFAULT_LIMITS = {
|
|
|
38442
38504
|
// The per-run read cap stops the COST; the per-turn ceiling below stops the FAILURE. Different jobs.
|
|
38443
38505
|
readCharsTotal: 6e4,
|
|
38444
38506
|
resultCharsTotal: 8e4,
|
|
38445
|
-
//
|
|
38446
|
-
//
|
|
38447
|
-
//
|
|
38507
|
+
// The WHOLE request: its version's fixed part (`tokenEstimate.PROMPT_OVERHEAD_BY_VERSION`, QUIKTR-2709) plus
|
|
38508
|
+
// the rendered context. First sized for a 131,072 window (8,192 reserved output); the runtime's model now
|
|
38509
|
+
// has 1,000,000, so 90,000 is the per-turn cost and per-minute quota budget. The AI Runtime enforces the
|
|
38510
|
+
// same number (`pilot_*_max_request_tokens`).
|
|
38448
38511
|
maxRequestTokens: 9e4,
|
|
38449
38512
|
grepMaxMatches: 40,
|
|
38450
38513
|
grepLineChars: 200,
|
|
@@ -38479,9 +38542,6 @@ function newLedger() {
|
|
|
38479
38542
|
}
|
|
38480
38543
|
var INVALID_PATH = "(invalid path)";
|
|
38481
38544
|
var CUT = "\u2026[line cut]";
|
|
38482
|
-
function isPlainObject(x) {
|
|
38483
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
38484
|
-
}
|
|
38485
38545
|
function bad(message) {
|
|
38486
38546
|
return { fail: { status: "bad_args", message } };
|
|
38487
38547
|
}
|
|
@@ -38952,11 +39012,6 @@ function createOverlayFs(base, overlay) {
|
|
|
38952
39012
|
exists: (rel) => overlay.has(rel) || base.exists(rel)
|
|
38953
39013
|
};
|
|
38954
39014
|
}
|
|
38955
|
-
function hasNul2(bytes) {
|
|
38956
|
-
const n = Math.min(bytes.length, 8e3);
|
|
38957
|
-
for (let i3 = 0; i3 < n; i3++) if (bytes[i3] === 0) return true;
|
|
38958
|
-
return false;
|
|
38959
|
-
}
|
|
38960
39015
|
function loadTextForEdit(fs2, path, maxBytes) {
|
|
38961
39016
|
let bytes;
|
|
38962
39017
|
try {
|
|
@@ -38971,7 +39026,7 @@ function loadTextForEdit(fs2, path, maxBytes) {
|
|
|
38971
39026
|
} catch {
|
|
38972
39027
|
return { ok: false, result: { status: "unreadable", reason: "io", message: "That file could not be read." } };
|
|
38973
39028
|
}
|
|
38974
|
-
if (
|
|
39029
|
+
if (hasNul(bytes)) return { ok: false, result: { status: "unreadable", reason: "binary", message: "That file is binary." } };
|
|
38975
39030
|
let text3;
|
|
38976
39031
|
try {
|
|
38977
39032
|
text3 = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
@@ -39994,6 +40049,101 @@ function loadApprovals(input) {
|
|
|
39994
40049
|
};
|
|
39995
40050
|
}
|
|
39996
40051
|
|
|
40052
|
+
// src/testLimits.ts
|
|
40053
|
+
var BASELINE_MIN_MS = 5 * 6e4;
|
|
40054
|
+
var BASELINE_MAX_MS = 25 * 6e4;
|
|
40055
|
+
var BASELINE_SHARE = 2.5;
|
|
40056
|
+
var GATE_MIN_MS = 5 * 6e4;
|
|
40057
|
+
var GATE_MAX_MS = 20 * 6e4;
|
|
40058
|
+
var GATE_BASELINES = 2.5;
|
|
40059
|
+
var GATE_MIN_START_MS = 6e4;
|
|
40060
|
+
var FILE_RUN_LIMIT_MS = 3 * 6e4;
|
|
40061
|
+
function testLimitsOff(env2 = process.env) {
|
|
40062
|
+
return env2.QUIKPILOT_TEST_LIMITS?.trim().toLowerCase() === "off";
|
|
40063
|
+
}
|
|
40064
|
+
var clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
40065
|
+
function baselineLimitMs(leftMs) {
|
|
40066
|
+
if (!Number.isFinite(leftMs)) return null;
|
|
40067
|
+
return Math.round(clamp(leftMs / BASELINE_SHARE, BASELINE_MIN_MS, BASELINE_MAX_MS));
|
|
40068
|
+
}
|
|
40069
|
+
function gateLimitMs(i3) {
|
|
40070
|
+
if (!Number.isFinite(i3.leftMs)) return null;
|
|
40071
|
+
const baseline = typeof i3.baselineMs === "number" && Number.isFinite(i3.baselineMs) && i3.baselineMs >= 0 ? i3.baselineMs : 0;
|
|
40072
|
+
if (i3.leftMs < Math.max(GATE_MIN_START_MS, baseline / 2)) return "no_time";
|
|
40073
|
+
return Math.round(Math.min(clamp(baseline * GATE_BASELINES, GATE_MIN_MS, GATE_MAX_MS), i3.leftMs));
|
|
40074
|
+
}
|
|
40075
|
+
var minutes = (ms) => Math.max(1, Math.round(ms / 6e4));
|
|
40076
|
+
function baselineTimeoutMessage(limitMs, jobMinutes) {
|
|
40077
|
+
return `QuikPilot could not check this change against the project's tests: they did not finish within ${minutes(limitMs)} minutes on the code as it is, and a second full run after the change would not fit in this job's ${jobMinutes} minutes. Nothing was pushed.`;
|
|
40078
|
+
}
|
|
40079
|
+
function gateTimeoutMessage(limitMs, baselineMs) {
|
|
40080
|
+
const before = typeof baselineMs === "number" && Number.isFinite(baselineMs) && baselineMs > 0 ? ` (they took ${minutes(baselineMs)} minutes before it)` : "";
|
|
40081
|
+
return `The project's tests did not finish within ${minutes(limitMs)} minutes after QuikPilot's change${before}, so the change could not be checked and nothing was pushed.`;
|
|
40082
|
+
}
|
|
40083
|
+
function gateNoTimeMessage(baselineMs) {
|
|
40084
|
+
const about = typeof baselineMs === "number" && Number.isFinite(baselineMs) && baselineMs > 0 ? ` (they take about ${minutes(baselineMs)} minutes)` : "";
|
|
40085
|
+
return `There was not enough time left in this job to run the project's tests on QuikPilot's change${about}, so the change could not be checked and nothing was pushed.`;
|
|
40086
|
+
}
|
|
40087
|
+
|
|
40088
|
+
// src/runDeadline.ts
|
|
40089
|
+
var RUN_RESERVE_MS = 7 * 6e4;
|
|
40090
|
+
var CHECKS_ALLOWANCE_MS = 2 * 6e4;
|
|
40091
|
+
var MIN_WRITING_MS = 5 * 6e4;
|
|
40092
|
+
var SETUP_FLOOR_MS = 5 * 6e4;
|
|
40093
|
+
var CHECK_COMMAND_FLOOR_MS = 2 * 6e4;
|
|
40094
|
+
var WATCHDOG_AFTER_STOP_MS = 3 * 6e4;
|
|
40095
|
+
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
40096
|
+
var clamp2 = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
40097
|
+
var minutes2 = (ms) => Math.max(1, Math.round(ms / 6e4));
|
|
40098
|
+
function runStopAtMs(startedAt, maxWallClockMinutes) {
|
|
40099
|
+
return startedAt + maxWallClockMinutes * 6e4 - RUN_RESERVE_MS;
|
|
40100
|
+
}
|
|
40101
|
+
function watchdogAtMs(stopAtMs) {
|
|
40102
|
+
return stopAtMs + WATCHDOG_AFTER_STOP_MS;
|
|
40103
|
+
}
|
|
40104
|
+
function finalChecksReserveMs(i3) {
|
|
40105
|
+
const base = finite(i3.baselineMs) && i3.baselineMs >= 0 ? i3.baselineMs : finite(i3.baselineLimitMs) ? i3.baselineLimitMs : BASELINE_MIN_MS;
|
|
40106
|
+
return clamp2(base + CHECKS_ALLOWANCE_MS, GATE_MIN_MS, GATE_MAX_MS);
|
|
40107
|
+
}
|
|
40108
|
+
function codegenStopAtMs(i3) {
|
|
40109
|
+
const byBudget = i3.now + i3.budgetMs;
|
|
40110
|
+
return finite(i3.stopAtMs) ? Math.min(byBudget, i3.stopAtMs - i3.reserveMs) : byBudget;
|
|
40111
|
+
}
|
|
40112
|
+
function commandLimitMs(kind, i3) {
|
|
40113
|
+
if (testLimitsOff(i3.env) || !finite(i3.stopAtMs)) return null;
|
|
40114
|
+
const left = i3.stopAtMs - i3.now;
|
|
40115
|
+
if (kind === "setup") return Math.round(Math.max(SETUP_FLOOR_MS, left - (BASELINE_MIN_MS + GATE_MIN_MS)));
|
|
40116
|
+
return Math.round(Math.max(CHECK_COMMAND_FLOOR_MS, left - (i3.reserveMs ?? 0)));
|
|
40117
|
+
}
|
|
40118
|
+
function commandTimeoutMessage(label, limitMs) {
|
|
40119
|
+
return `${label} did not finish within the ${minutes2(limitMs)} minutes this job could spare for it, so QuikPilot stopped it. Nothing was pushed. Make ${label} faster (for example, cache what it installs) or raise the job's time limit in the project's QuikPilot settings.`;
|
|
40120
|
+
}
|
|
40121
|
+
function writeNoTimeMessage(leftMs, reserveMs) {
|
|
40122
|
+
return `There was not enough time left in this job to write the change (${Math.max(0, Math.round(leftMs / 6e4))} minutes left, about ${minutes2(reserveMs)} needed afterwards for the project's checks and tests), so QuikPilot did not start it. Nothing was pushed.`;
|
|
40123
|
+
}
|
|
40124
|
+
function jobTimeLimitMessage(jobMinutes) {
|
|
40125
|
+
return `The job was about to reach its ${jobMinutes}-minute time limit before QuikPilot finished, so QuikPilot stopped and reported. Nothing more was pushed.`;
|
|
40126
|
+
}
|
|
40127
|
+
function jobStoppedMessage() {
|
|
40128
|
+
return "The job was stopped before QuikPilot finished, so QuikPilot reported what it had. Nothing more was pushed.";
|
|
40129
|
+
}
|
|
40130
|
+
var SHORT_CALL_MS = 6e4;
|
|
40131
|
+
var LONG_CALL_MS = 5 * 6e4;
|
|
40132
|
+
async function fetchWithin(what, url, init2, limitMs) {
|
|
40133
|
+
const signal = AbortSignal.timeout(limitMs);
|
|
40134
|
+
try {
|
|
40135
|
+
return await fetch(url, { ...init2, signal });
|
|
40136
|
+
} catch (err2) {
|
|
40137
|
+
if (signal.aborted && err2?.name === "TimeoutError") {
|
|
40138
|
+
throw new Error(`${what} did not answer within ${minutesOrSeconds(limitMs)} and was stopped`);
|
|
40139
|
+
}
|
|
40140
|
+
throw err2;
|
|
40141
|
+
}
|
|
40142
|
+
}
|
|
40143
|
+
function minutesOrSeconds(ms) {
|
|
40144
|
+
return ms >= 12e4 ? `${Math.round(ms / 6e4)} minutes` : `${Math.max(1, Math.round(ms / 1e3))} s`;
|
|
40145
|
+
}
|
|
40146
|
+
|
|
39997
40147
|
// src/quiktrackError.ts
|
|
39998
40148
|
async function describeQuikTrackFailure(res) {
|
|
39999
40149
|
try {
|
|
@@ -40011,21 +40161,32 @@ var import_node_http = __toESM2(require("node:http"));
|
|
|
40011
40161
|
var import_node_https = __toESM2(require("node:https"));
|
|
40012
40162
|
var NATIVE_FETCH = globalThis.fetch;
|
|
40013
40163
|
var KEEP_ALIVE_INITIAL_DELAY_MS = 6e4;
|
|
40164
|
+
var MAX_RESPONSE_BYTES = 32 * 1024 * 1024;
|
|
40014
40165
|
var NULL_BODY_STATUSES = /* @__PURE__ */ new Set([204, 205, 304]);
|
|
40015
|
-
async function fetchOnOwnClock(url, init2) {
|
|
40166
|
+
async function fetchOnOwnClock(url, init2, opts = {}) {
|
|
40016
40167
|
if (!init2.signal || globalThis.fetch !== NATIVE_FETCH) return globalThis.fetch(url, init2);
|
|
40017
|
-
return requestWithoutHeadersLimit(url, init2, init2.signal);
|
|
40168
|
+
return requestWithoutHeadersLimit(url, init2, init2.signal, opts.maxResponseBytes ?? MAX_RESPONSE_BYTES);
|
|
40018
40169
|
}
|
|
40019
|
-
async function requestWithoutHeadersLimit(url, init2, signal) {
|
|
40170
|
+
async function requestWithoutHeadersLimit(url, init2, signal, maxBytes) {
|
|
40020
40171
|
if (init2.body != null && typeof init2.body !== "string") throw new TypeError("fetchOnOwnClock sends a string body only");
|
|
40021
40172
|
const target = new URL(url);
|
|
40022
40173
|
const client = target.protocol === "http:" ? import_node_http.default : import_node_https.default;
|
|
40023
40174
|
const headers = Object.fromEntries(new Headers(init2.headers).entries());
|
|
40024
|
-
return new Promise((
|
|
40175
|
+
return new Promise((resolve6, reject) => {
|
|
40025
40176
|
const fail = (err2) => reject(signal.aborted ? signal.reason : err2);
|
|
40026
40177
|
const req = client.request(target, { method: init2.method ?? "GET", headers, signal }, (res) => {
|
|
40027
40178
|
const chunks = [];
|
|
40028
|
-
|
|
40179
|
+
let bytes = 0;
|
|
40180
|
+
res.on("data", (chunk) => {
|
|
40181
|
+
bytes += chunk.length;
|
|
40182
|
+
if (bytes > maxBytes) {
|
|
40183
|
+
const kb = Math.round(maxBytes / 1024);
|
|
40184
|
+
req.destroy();
|
|
40185
|
+
reject(new Error(`The AI service's reply was larger than ${kb >= 1024 ? `${Math.round(kb / 1024)} MB` : `${kb} KB`}, so it was not read`));
|
|
40186
|
+
return;
|
|
40187
|
+
}
|
|
40188
|
+
chunks.push(chunk);
|
|
40189
|
+
});
|
|
40029
40190
|
res.on("error", fail);
|
|
40030
40191
|
res.on("end", () => {
|
|
40031
40192
|
const status = res.statusCode ?? 0;
|
|
@@ -40034,7 +40195,7 @@ async function requestWithoutHeadersLimit(url, init2, signal) {
|
|
|
40034
40195
|
for (const one of Array.isArray(value) ? value : value === void 0 ? [] : [value]) responseHeaders.append(name2, one);
|
|
40035
40196
|
}
|
|
40036
40197
|
try {
|
|
40037
|
-
|
|
40198
|
+
resolve6(new Response(NULL_BODY_STATUSES.has(status) ? null : Buffer.concat(chunks), { status, statusText: res.statusMessage ?? "", headers: responseHeaders }));
|
|
40038
40199
|
} catch (err2) {
|
|
40039
40200
|
reject(err2);
|
|
40040
40201
|
}
|
|
@@ -40082,7 +40243,7 @@ var REPORT_RETRY_WAITS_MS = [2e3, 5e3, 1e4];
|
|
|
40082
40243
|
var URGENT_REPORT_TIMEOUT_MS = 6e3;
|
|
40083
40244
|
async function reportBack(params) {
|
|
40084
40245
|
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, testsCorrected, codegenLoop, unresolved, aiCostUsd, testConflicts, approvedTestsApplied, databaseChange } = params;
|
|
40085
|
-
const sleep = params.sleep ?? ((ms) => new Promise((
|
|
40246
|
+
const sleep = params.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
|
|
40086
40247
|
const body2 = { status };
|
|
40087
40248
|
if (branch) body2.branch = branch;
|
|
40088
40249
|
if (warnings && warnings.length > 0) body2.warnings = warnings;
|
|
@@ -40109,7 +40270,8 @@ async function reportBack(params) {
|
|
|
40109
40270
|
method: "POST",
|
|
40110
40271
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "application/json" },
|
|
40111
40272
|
body: payload,
|
|
40112
|
-
|
|
40273
|
+
// QUIKTR-2708 (RN-22): every try has its own limit; the last-resort report a much shorter one (QUIKTR-2706).
|
|
40274
|
+
signal: AbortSignal.timeout(params.urgent ? URGENT_REPORT_TIMEOUT_MS : SHORT_CALL_MS)
|
|
40113
40275
|
});
|
|
40114
40276
|
} catch (err2) {
|
|
40115
40277
|
if (!isRetryableNetworkError(err2)) throw err2;
|
|
@@ -40133,87 +40295,6 @@ async function reportBack(params) {
|
|
|
40133
40295
|
|
|
40134
40296
|
// src/commands.ts
|
|
40135
40297
|
var import_node_child_process5 = require("node:child_process");
|
|
40136
|
-
|
|
40137
|
-
// src/testLimits.ts
|
|
40138
|
-
var BASELINE_MIN_MS = 5 * 6e4;
|
|
40139
|
-
var BASELINE_MAX_MS = 25 * 6e4;
|
|
40140
|
-
var BASELINE_SHARE = 2.5;
|
|
40141
|
-
var GATE_MIN_MS = 5 * 6e4;
|
|
40142
|
-
var GATE_MAX_MS = 20 * 6e4;
|
|
40143
|
-
var GATE_BASELINES = 2.5;
|
|
40144
|
-
var GATE_MIN_START_MS = 6e4;
|
|
40145
|
-
var FILE_RUN_LIMIT_MS = 3 * 6e4;
|
|
40146
|
-
function testLimitsOff(env2 = process.env) {
|
|
40147
|
-
return env2.QUIKPILOT_TEST_LIMITS?.trim().toLowerCase() === "off";
|
|
40148
|
-
}
|
|
40149
|
-
var clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
40150
|
-
function baselineLimitMs(leftMs) {
|
|
40151
|
-
if (!Number.isFinite(leftMs)) return null;
|
|
40152
|
-
return Math.round(clamp(leftMs / BASELINE_SHARE, BASELINE_MIN_MS, BASELINE_MAX_MS));
|
|
40153
|
-
}
|
|
40154
|
-
function gateLimitMs(i3) {
|
|
40155
|
-
if (!Number.isFinite(i3.leftMs)) return null;
|
|
40156
|
-
const baseline = typeof i3.baselineMs === "number" && Number.isFinite(i3.baselineMs) && i3.baselineMs >= 0 ? i3.baselineMs : 0;
|
|
40157
|
-
if (i3.leftMs < Math.max(GATE_MIN_START_MS, baseline / 2)) return "no_time";
|
|
40158
|
-
return Math.round(Math.min(clamp(baseline * GATE_BASELINES, GATE_MIN_MS, GATE_MAX_MS), i3.leftMs));
|
|
40159
|
-
}
|
|
40160
|
-
var minutes = (ms) => Math.max(1, Math.round(ms / 6e4));
|
|
40161
|
-
function baselineTimeoutMessage(limitMs, jobMinutes) {
|
|
40162
|
-
return `QuikPilot could not check this change against the project's tests: they did not finish within ${minutes(limitMs)} minutes on the code as it is, and a second full run after the change would not fit in this job's ${jobMinutes} minutes. Nothing was pushed.`;
|
|
40163
|
-
}
|
|
40164
|
-
function gateTimeoutMessage(limitMs, baselineMs) {
|
|
40165
|
-
const before = typeof baselineMs === "number" && Number.isFinite(baselineMs) && baselineMs > 0 ? ` (they took ${minutes(baselineMs)} minutes before it)` : "";
|
|
40166
|
-
return `The project's tests did not finish within ${minutes(limitMs)} minutes after QuikPilot's change${before}, so the change could not be checked and nothing was pushed.`;
|
|
40167
|
-
}
|
|
40168
|
-
function gateNoTimeMessage(baselineMs) {
|
|
40169
|
-
const about = typeof baselineMs === "number" && Number.isFinite(baselineMs) && baselineMs > 0 ? ` (they take about ${minutes(baselineMs)} minutes)` : "";
|
|
40170
|
-
return `There was not enough time left in this job to run the project's tests on QuikPilot's change${about}, so the change could not be checked and nothing was pushed.`;
|
|
40171
|
-
}
|
|
40172
|
-
|
|
40173
|
-
// src/runDeadline.ts
|
|
40174
|
-
var RUN_RESERVE_MS = 7 * 6e4;
|
|
40175
|
-
var CHECKS_ALLOWANCE_MS = 2 * 6e4;
|
|
40176
|
-
var MIN_WRITING_MS = 5 * 6e4;
|
|
40177
|
-
var SETUP_FLOOR_MS = 5 * 6e4;
|
|
40178
|
-
var CHECK_COMMAND_FLOOR_MS = 2 * 6e4;
|
|
40179
|
-
var WATCHDOG_AFTER_STOP_MS = 3 * 6e4;
|
|
40180
|
-
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
40181
|
-
var clamp2 = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
40182
|
-
var minutes2 = (ms) => Math.max(1, Math.round(ms / 6e4));
|
|
40183
|
-
function runStopAtMs(startedAt, maxWallClockMinutes) {
|
|
40184
|
-
return startedAt + maxWallClockMinutes * 6e4 - RUN_RESERVE_MS;
|
|
40185
|
-
}
|
|
40186
|
-
function watchdogAtMs(stopAtMs) {
|
|
40187
|
-
return stopAtMs + WATCHDOG_AFTER_STOP_MS;
|
|
40188
|
-
}
|
|
40189
|
-
function finalChecksReserveMs(i3) {
|
|
40190
|
-
const base = finite(i3.baselineMs) && i3.baselineMs >= 0 ? i3.baselineMs : finite(i3.baselineLimitMs) ? i3.baselineLimitMs : BASELINE_MIN_MS;
|
|
40191
|
-
return clamp2(base + CHECKS_ALLOWANCE_MS, GATE_MIN_MS, GATE_MAX_MS);
|
|
40192
|
-
}
|
|
40193
|
-
function codegenStopAtMs(i3) {
|
|
40194
|
-
const byBudget = i3.now + i3.budgetMs;
|
|
40195
|
-
return finite(i3.stopAtMs) ? Math.min(byBudget, i3.stopAtMs - i3.reserveMs) : byBudget;
|
|
40196
|
-
}
|
|
40197
|
-
function commandLimitMs(kind, i3) {
|
|
40198
|
-
if (testLimitsOff(i3.env) || !finite(i3.stopAtMs)) return null;
|
|
40199
|
-
const left = i3.stopAtMs - i3.now;
|
|
40200
|
-
if (kind === "setup") return Math.round(Math.max(SETUP_FLOOR_MS, left - (BASELINE_MIN_MS + GATE_MIN_MS)));
|
|
40201
|
-
return Math.round(Math.max(CHECK_COMMAND_FLOOR_MS, left - (i3.reserveMs ?? 0)));
|
|
40202
|
-
}
|
|
40203
|
-
function commandTimeoutMessage(label, limitMs) {
|
|
40204
|
-
return `${label} did not finish within the ${minutes2(limitMs)} minutes this job could spare for it, so QuikPilot stopped it. Nothing was pushed. Make ${label} faster (for example, cache what it installs) or raise the job's time limit in the project's QuikPilot settings.`;
|
|
40205
|
-
}
|
|
40206
|
-
function writeNoTimeMessage(leftMs, reserveMs) {
|
|
40207
|
-
return `There was not enough time left in this job to write the change (${Math.max(0, Math.round(leftMs / 6e4))} minutes left, about ${minutes2(reserveMs)} needed afterwards for the project's checks and tests), so QuikPilot did not start it. Nothing was pushed.`;
|
|
40208
|
-
}
|
|
40209
|
-
function jobTimeLimitMessage(jobMinutes) {
|
|
40210
|
-
return `The job was about to reach its ${jobMinutes}-minute time limit before QuikPilot finished, so QuikPilot stopped and reported. Nothing more was pushed.`;
|
|
40211
|
-
}
|
|
40212
|
-
function jobStoppedMessage() {
|
|
40213
|
-
return "The job was stopped before QuikPilot finished, so QuikPilot reported what it had. Nothing more was pushed.";
|
|
40214
|
-
}
|
|
40215
|
-
|
|
40216
|
-
// src/commands.ts
|
|
40217
40298
|
var withheldLogged = false;
|
|
40218
40299
|
function repositoryCommandEnv() {
|
|
40219
40300
|
if (!withheldLogged) {
|
|
@@ -40244,7 +40325,7 @@ function runTestCommand(command) {
|
|
|
40244
40325
|
}
|
|
40245
40326
|
function runTestCommandAsync(command, signal) {
|
|
40246
40327
|
if (!command) return Promise.resolve("success");
|
|
40247
|
-
return new Promise((
|
|
40328
|
+
return new Promise((resolve6) => {
|
|
40248
40329
|
const child = (0, import_node_child_process5.spawn)(command, { shell: "/bin/bash", stdio: "inherit", detached: true, env: repositoryCommandEnv() });
|
|
40249
40330
|
track(child);
|
|
40250
40331
|
const onAbort = () => killProcessGroup(child);
|
|
@@ -40252,20 +40333,20 @@ function runTestCommandAsync(command, signal) {
|
|
|
40252
40333
|
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
40253
40334
|
const done = (outcome) => {
|
|
40254
40335
|
signal?.removeEventListener("abort", onAbort);
|
|
40255
|
-
|
|
40336
|
+
resolve6(signal?.aborted ? "failure" : outcome);
|
|
40256
40337
|
};
|
|
40257
40338
|
child.on("exit", (code) => done(code === 0 ? "success" : "failure"));
|
|
40258
40339
|
child.on("error", () => done("failure"));
|
|
40259
40340
|
});
|
|
40260
40341
|
}
|
|
40261
40342
|
function runCommandWithTimeout(command, timeoutMs) {
|
|
40262
|
-
return new Promise((
|
|
40343
|
+
return new Promise((resolve6) => {
|
|
40263
40344
|
let settled = false;
|
|
40264
40345
|
const finish = (outcome) => {
|
|
40265
40346
|
if (settled) return;
|
|
40266
40347
|
settled = true;
|
|
40267
40348
|
clearTimeout(timer);
|
|
40268
|
-
|
|
40349
|
+
resolve6(outcome);
|
|
40269
40350
|
};
|
|
40270
40351
|
const child = (0, import_node_child_process5.spawn)(command, {
|
|
40271
40352
|
shell: "/bin/bash",
|
|
@@ -40318,7 +40399,7 @@ function killProcessGroup(child) {
|
|
|
40318
40399
|
}
|
|
40319
40400
|
}
|
|
40320
40401
|
function runCapturedCommand(argv, opts) {
|
|
40321
|
-
return new Promise((
|
|
40402
|
+
return new Promise((resolve6) => {
|
|
40322
40403
|
let settled = false;
|
|
40323
40404
|
let timedOut = false;
|
|
40324
40405
|
let graceTimer;
|
|
@@ -40329,7 +40410,7 @@ function runCapturedCommand(argv, opts) {
|
|
|
40329
40410
|
settled = true;
|
|
40330
40411
|
clearTimeout(timer);
|
|
40331
40412
|
if (graceTimer) clearTimeout(graceTimer);
|
|
40332
|
-
|
|
40413
|
+
resolve6({ stdout: Buffer.concat(chunks).toString("utf8"), timedOut, started });
|
|
40333
40414
|
};
|
|
40334
40415
|
const child = (0, import_node_child_process5.spawn)(argv[0], argv.slice(1), {
|
|
40335
40416
|
cwd: opts.cwd,
|
|
@@ -40356,7 +40437,7 @@ function runCapturedCommand(argv, opts) {
|
|
|
40356
40437
|
});
|
|
40357
40438
|
}
|
|
40358
40439
|
function runShellCaptured(command, opts) {
|
|
40359
|
-
return new Promise((
|
|
40440
|
+
return new Promise((resolve6) => {
|
|
40360
40441
|
let settled = false;
|
|
40361
40442
|
let timedOut = false;
|
|
40362
40443
|
let graceTimer;
|
|
@@ -40371,7 +40452,7 @@ function runShellCaptured(command, opts) {
|
|
|
40371
40452
|
clearTimeout(timer);
|
|
40372
40453
|
if (graceTimer) clearTimeout(graceTimer);
|
|
40373
40454
|
const kept = tail2.length > opts.maxTailBytes ? tail2.subarray(tail2.length - opts.maxTailBytes) : tail2;
|
|
40374
|
-
|
|
40455
|
+
resolve6({ output: kept.toString("utf8"), exitCode, timedOut, started });
|
|
40375
40456
|
};
|
|
40376
40457
|
const child = (0, import_node_child_process5.spawn)(command, {
|
|
40377
40458
|
shell: "/bin/bash",
|
|
@@ -40394,7 +40475,7 @@ function runShellCaptured(command, opts) {
|
|
|
40394
40475
|
}
|
|
40395
40476
|
var KILL_GRACE_MS = 2e3;
|
|
40396
40477
|
function runTestCommandWithLimit(command, timeoutMs, cwd, signal) {
|
|
40397
|
-
return new Promise((
|
|
40478
|
+
return new Promise((resolve6) => {
|
|
40398
40479
|
let settled = false;
|
|
40399
40480
|
let timedOut = false;
|
|
40400
40481
|
let stopped = false;
|
|
@@ -40405,7 +40486,7 @@ function runTestCommandWithLimit(command, timeoutMs, cwd, signal) {
|
|
|
40405
40486
|
clearTimeout(timer);
|
|
40406
40487
|
if (graceTimer) clearTimeout(graceTimer);
|
|
40407
40488
|
signal?.removeEventListener("abort", onAbort);
|
|
40408
|
-
|
|
40489
|
+
resolve6(stopped ? { ...run3, outcome: "failure", stopped: true } : run3);
|
|
40409
40490
|
};
|
|
40410
40491
|
const onAbort = () => {
|
|
40411
40492
|
if (settled || timedOut || stopped) return;
|
|
@@ -40682,11 +40763,8 @@ var RULE_SHAPE = /^[a-z][a-z0-9_]{0,39}$/;
|
|
|
40682
40763
|
function count2(n) {
|
|
40683
40764
|
return typeof n === "number" && Number.isInteger(n) ? Math.min(MAX_PREVIOUS_COUNT, Math.max(0, n)) : 0;
|
|
40684
40765
|
}
|
|
40685
|
-
function isRecord(x) {
|
|
40686
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
40687
|
-
}
|
|
40688
40766
|
function testRunFrom(answer) {
|
|
40689
|
-
if (!
|
|
40767
|
+
if (!isPlainObject(answer)) return void 0;
|
|
40690
40768
|
const numbers = ["passed", "failed", "total", "regressions", "newFailures", "alreadyFailing"];
|
|
40691
40769
|
if (!numbers.every((k) => typeof answer[k] === "number") || !Array.isArray(answer.failingTests)) return void 0;
|
|
40692
40770
|
const failingTests = answer.failingTests.filter((n) => typeof n === "string").map((n) => n.slice(0, MAX_PREVIOUS_NAME_CHARS)).filter((n) => n.length > 0).slice(0, MAX_PREVIOUS_TESTS);
|
|
@@ -40699,7 +40777,7 @@ function testRunFrom(answer) {
|
|
|
40699
40777
|
alreadyFailing: count2(answer.alreadyFailing),
|
|
40700
40778
|
failingTests
|
|
40701
40779
|
};
|
|
40702
|
-
if (
|
|
40780
|
+
if (isPlainObject(answer.messages)) {
|
|
40703
40781
|
const listed = new Set(failingTests);
|
|
40704
40782
|
const messages = {};
|
|
40705
40783
|
let total = 0;
|
|
@@ -40745,7 +40823,7 @@ function previousAttemptFrom(failure, attempt2) {
|
|
|
40745
40823
|
var import_node_crypto2 = require("node:crypto");
|
|
40746
40824
|
var import_node_fs13 = require("node:fs");
|
|
40747
40825
|
var import_node_os4 = require("node:os");
|
|
40748
|
-
var
|
|
40826
|
+
var import_node_path16 = require("node:path");
|
|
40749
40827
|
|
|
40750
40828
|
// src/pairedTests.ts
|
|
40751
40829
|
var import_node_path9 = require("node:path");
|
|
@@ -40887,18 +40965,16 @@ function testsThroughOneFile(p) {
|
|
|
40887
40965
|
// src/testAdapters.ts
|
|
40888
40966
|
var import_node_fs12 = require("node:fs");
|
|
40889
40967
|
var import_node_module = require("node:module");
|
|
40890
|
-
var
|
|
40968
|
+
var import_node_path14 = require("node:path");
|
|
40891
40969
|
|
|
40892
40970
|
// src/baselineCheck.ts
|
|
40893
40971
|
var import_node_child_process9 = require("node:child_process");
|
|
40894
40972
|
var import_node_fs11 = require("node:fs");
|
|
40895
|
-
var import_node_path14 = require("node:path");
|
|
40896
40973
|
|
|
40897
40974
|
// src/quiktest.ts
|
|
40898
40975
|
var import_node_child_process6 = require("node:child_process");
|
|
40899
40976
|
var import_node_fs6 = require("node:fs");
|
|
40900
40977
|
var import_node_path10 = require("node:path");
|
|
40901
|
-
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
40902
40978
|
var DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
|
|
40903
40979
|
"node_modules",
|
|
40904
40980
|
".git",
|
|
@@ -40931,35 +41007,44 @@ function isJUnitXml(path) {
|
|
|
40931
41007
|
if (fd !== null) (0, import_node_fs6.closeSync)(fd);
|
|
40932
41008
|
}
|
|
40933
41009
|
}
|
|
40934
|
-
function
|
|
40935
|
-
|
|
41010
|
+
function walkReports(cwd, opts = {}) {
|
|
41011
|
+
let firstNamed = null;
|
|
41012
|
+
const named2 = [];
|
|
41013
|
+
const others = [];
|
|
40936
41014
|
const walk3 = (dir) => {
|
|
40937
|
-
if (found.length >= MAX_REPORTS) return;
|
|
40938
41015
|
let entries;
|
|
40939
41016
|
try {
|
|
40940
|
-
entries = (0, import_node_fs6.readdirSync)(dir);
|
|
41017
|
+
entries = (0, import_node_fs6.readdirSync)(dir, { withFileTypes: true });
|
|
40941
41018
|
} catch {
|
|
40942
41019
|
return;
|
|
40943
41020
|
}
|
|
40944
41021
|
for (const entry of entries) {
|
|
40945
|
-
if (DEPENDENCY_DIRS.has(entry)) continue;
|
|
40946
|
-
const full = (0, import_node_path10.join)(dir, entry);
|
|
40947
|
-
|
|
40948
|
-
|
|
40949
|
-
stat = (0, import_node_fs6.statSync)(full);
|
|
40950
|
-
} catch {
|
|
41022
|
+
if (DEPENDENCY_DIRS.has(entry.name)) continue;
|
|
41023
|
+
const full = (0, import_node_path10.join)(dir, entry.name);
|
|
41024
|
+
if (entry.isDirectory()) {
|
|
41025
|
+
walk3(full);
|
|
40951
41026
|
continue;
|
|
40952
41027
|
}
|
|
40953
|
-
if (
|
|
40954
|
-
|
|
40955
|
-
|
|
40956
|
-
|
|
41028
|
+
if (!entry.isFile() || !/\.xml$/i.test(entry.name)) continue;
|
|
41029
|
+
const isNamed = /^junit.*\.xml$/i.test(entry.name);
|
|
41030
|
+
if (isNamed && firstNamed === null && /^junit.*\.xml$/.test(entry.name)) firstNamed = full;
|
|
41031
|
+
if (!isNamed && others.length >= MAX_REPORTS) continue;
|
|
41032
|
+
if (opts.freshSinceMs !== void 0) {
|
|
41033
|
+
try {
|
|
41034
|
+
if ((0, import_node_fs6.statSync)(full).mtimeMs < opts.freshSinceMs) continue;
|
|
41035
|
+
} catch {
|
|
41036
|
+
continue;
|
|
41037
|
+
}
|
|
40957
41038
|
}
|
|
41039
|
+
if (isJUnitXml(full)) (isNamed ? named2 : others).push(full);
|
|
40958
41040
|
}
|
|
40959
41041
|
};
|
|
40960
41042
|
walk3(cwd);
|
|
40961
|
-
const
|
|
40962
|
-
return
|
|
41043
|
+
const byPath = (a, b) => a.localeCompare(b);
|
|
41044
|
+
return { firstNamed, reports: [...named2.sort(byPath), ...others.sort(byPath)].slice(0, MAX_REPORTS) };
|
|
41045
|
+
}
|
|
41046
|
+
function findJUnitReports(cwd = process.cwd(), opts = {}) {
|
|
41047
|
+
return walkReports(cwd, opts).reports;
|
|
40963
41048
|
}
|
|
40964
41049
|
function trackedPaths(paths, cwd = process.cwd()) {
|
|
40965
41050
|
if (paths.length === 0) return /* @__PURE__ */ new Set();
|
|
@@ -41003,31 +41088,6 @@ ${inner.filter(Boolean).join("\n")}
|
|
|
41003
41088
|
</testsuites>
|
|
41004
41089
|
`;
|
|
41005
41090
|
}
|
|
41006
|
-
function walkForJUnitByName(dir) {
|
|
41007
|
-
let entries;
|
|
41008
|
-
try {
|
|
41009
|
-
entries = (0, import_node_fs6.readdirSync)(dir);
|
|
41010
|
-
} catch {
|
|
41011
|
-
return null;
|
|
41012
|
-
}
|
|
41013
|
-
for (const entry of entries) {
|
|
41014
|
-
if (SKIP_DIRS.has(entry)) continue;
|
|
41015
|
-
const full = (0, import_node_path10.join)(dir, entry);
|
|
41016
|
-
let stat;
|
|
41017
|
-
try {
|
|
41018
|
-
stat = (0, import_node_fs6.statSync)(full);
|
|
41019
|
-
} catch {
|
|
41020
|
-
continue;
|
|
41021
|
-
}
|
|
41022
|
-
if (stat.isDirectory()) {
|
|
41023
|
-
const found = walkForJUnitByName(full);
|
|
41024
|
-
if (found) return found;
|
|
41025
|
-
} else if (/^junit.*\.xml$/.test(entry)) {
|
|
41026
|
-
return full;
|
|
41027
|
-
}
|
|
41028
|
-
}
|
|
41029
|
-
return null;
|
|
41030
|
-
}
|
|
41031
41091
|
function firstXmlIn(dir, namePattern) {
|
|
41032
41092
|
let entries;
|
|
41033
41093
|
try {
|
|
@@ -41049,7 +41109,8 @@ function readTestReportBytes(cwd = process.cwd(), opts = {}) {
|
|
|
41049
41109
|
}
|
|
41050
41110
|
}
|
|
41051
41111
|
function findJUnitReport(cwd = process.cwd()) {
|
|
41052
|
-
|
|
41112
|
+
const walked = walkReports(cwd);
|
|
41113
|
+
return walked.firstNamed ?? walked.reports[0] ?? firstXmlIn((0, import_node_path10.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path10.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path10.join)(cwd, "target", "surefire-reports"), /\.xml$/);
|
|
41053
41114
|
}
|
|
41054
41115
|
function buildCiUrl(serverUrl, repository, githubRunId) {
|
|
41055
41116
|
return `${serverUrl}/${repository}/actions/runs/${githubRunId}`;
|
|
@@ -41078,11 +41139,11 @@ async function reportToQuikTest(params) {
|
|
|
41078
41139
|
if (generatedFiles) {
|
|
41079
41140
|
url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
|
|
41080
41141
|
}
|
|
41081
|
-
const res = await
|
|
41142
|
+
const res = await fetchWithin("The upload of the test results to QuikTest", url, {
|
|
41082
41143
|
method: "POST",
|
|
41083
41144
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "text/xml" },
|
|
41084
41145
|
body: body2
|
|
41085
|
-
});
|
|
41146
|
+
}, SHORT_CALL_MS);
|
|
41086
41147
|
if (!res.ok) {
|
|
41087
41148
|
throw new Error(`QuikTest report POST failed: ${res.status} ${res.statusText}`);
|
|
41088
41149
|
}
|
|
@@ -41637,27 +41698,30 @@ function ancestorInside(realRoot, abs) {
|
|
|
41637
41698
|
}
|
|
41638
41699
|
}
|
|
41639
41700
|
}
|
|
41701
|
+
function restoreOriginals(records) {
|
|
41702
|
+
const failed = [];
|
|
41703
|
+
for (const w of [...records].reverse()) {
|
|
41704
|
+
try {
|
|
41705
|
+
if (w.original !== null) (0, import_node_fs9.writeFileSync)(w.abs, w.original);
|
|
41706
|
+
else (0, import_node_fs9.rmSync)(w.abs, { force: true });
|
|
41707
|
+
for (const d of [...w.createdDirs].reverse()) {
|
|
41708
|
+
try {
|
|
41709
|
+
(0, import_node_fs9.rmdirSync)(d);
|
|
41710
|
+
} catch {
|
|
41711
|
+
}
|
|
41712
|
+
}
|
|
41713
|
+
} catch {
|
|
41714
|
+
failed.push(w.rel);
|
|
41715
|
+
}
|
|
41716
|
+
}
|
|
41717
|
+
return failed;
|
|
41718
|
+
}
|
|
41640
41719
|
function applyOverlay(root, files) {
|
|
41641
41720
|
const realRoot = (0, import_node_fs9.realpathSync)(root);
|
|
41642
41721
|
const written = [];
|
|
41643
41722
|
const seen = /* @__PURE__ */ new Set();
|
|
41644
|
-
const
|
|
41645
|
-
const failed =
|
|
41646
|
-
for (const w of [...written].reverse()) {
|
|
41647
|
-
const rel = (0, import_node_path12.relative)(root, w.abs).split("\\").join("/");
|
|
41648
|
-
try {
|
|
41649
|
-
if (w.original !== null) (0, import_node_fs9.writeFileSync)(w.abs, w.original);
|
|
41650
|
-
else (0, import_node_fs9.rmSync)(w.abs, { force: true });
|
|
41651
|
-
for (const d of [...w.createdDirs].reverse()) {
|
|
41652
|
-
try {
|
|
41653
|
-
(0, import_node_fs9.rmdirSync)(d);
|
|
41654
|
-
} catch {
|
|
41655
|
-
}
|
|
41656
|
-
}
|
|
41657
|
-
} catch {
|
|
41658
|
-
failed.push(rel);
|
|
41659
|
-
}
|
|
41660
|
-
}
|
|
41723
|
+
const restore = () => {
|
|
41724
|
+
const failed = restoreOriginals(written);
|
|
41661
41725
|
written.length = 0;
|
|
41662
41726
|
return { failed: failed.sort() };
|
|
41663
41727
|
};
|
|
@@ -41687,15 +41751,15 @@ function applyOverlay(root, files) {
|
|
|
41687
41751
|
createdDirs.push(d);
|
|
41688
41752
|
}
|
|
41689
41753
|
}
|
|
41690
|
-
const w = { abs, original, createdDirs };
|
|
41754
|
+
const w = { rel, abs, original, createdDirs };
|
|
41691
41755
|
written.push(w);
|
|
41692
41756
|
(0, import_node_fs9.writeFileSync)(abs, f.content);
|
|
41693
41757
|
}
|
|
41694
41758
|
} catch (err2) {
|
|
41695
|
-
|
|
41759
|
+
restore();
|
|
41696
41760
|
throw err2;
|
|
41697
41761
|
}
|
|
41698
|
-
return { restore
|
|
41762
|
+
return { restore };
|
|
41699
41763
|
}
|
|
41700
41764
|
function git2(root, args2) {
|
|
41701
41765
|
(0, import_node_child_process8.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], { env: gitEnv(), cwd: root, stdio: ["ignore", "ignore", "ignore"] });
|
|
@@ -41815,24 +41879,7 @@ function undoableFlush(root, results, flush, options = {}) {
|
|
|
41815
41879
|
}
|
|
41816
41880
|
return { rel, abs, original, createdDirs };
|
|
41817
41881
|
});
|
|
41818
|
-
const putFilesBack = () =>
|
|
41819
|
-
const failed = [];
|
|
41820
|
-
for (const o of [...originals].reverse()) {
|
|
41821
|
-
try {
|
|
41822
|
-
if (o.original !== null) (0, import_node_fs9.writeFileSync)(o.abs, o.original);
|
|
41823
|
-
else (0, import_node_fs9.rmSync)(o.abs, { force: true });
|
|
41824
|
-
for (const d of [...o.createdDirs].reverse()) {
|
|
41825
|
-
try {
|
|
41826
|
-
(0, import_node_fs9.rmdirSync)(d);
|
|
41827
|
-
} catch {
|
|
41828
|
-
}
|
|
41829
|
-
}
|
|
41830
|
-
} catch {
|
|
41831
|
-
failed.push(o.rel);
|
|
41832
|
-
}
|
|
41833
|
-
}
|
|
41834
|
-
return failed;
|
|
41835
|
-
};
|
|
41882
|
+
const putFilesBack = () => restoreOriginals(originals);
|
|
41836
41883
|
try {
|
|
41837
41884
|
flush(results);
|
|
41838
41885
|
} catch (err2) {
|
|
@@ -41974,7 +42021,7 @@ function shellQuote(value) {
|
|
|
41974
42021
|
}
|
|
41975
42022
|
function buildSingleFileCommand(command, path) {
|
|
41976
42023
|
const quoted2 = shellQuote(path);
|
|
41977
|
-
return command.includes("{file}") ? command.
|
|
42024
|
+
return command.includes("{file}") ? command.replace(/(["']?)\{file\}\1/g, () => quoted2) : `${command} ${quoted2}`;
|
|
41978
42025
|
}
|
|
41979
42026
|
var isTestTarget2 = (t) => (t.automationIds?.length ?? 0) > 0;
|
|
41980
42027
|
function checkableIds(ids, types2) {
|
|
@@ -41988,35 +42035,9 @@ function checkableIds(ids, types2) {
|
|
|
41988
42035
|
function insideCheckout(cwd, path) {
|
|
41989
42036
|
return safeRepoTarget(path, cwd);
|
|
41990
42037
|
}
|
|
41991
|
-
function
|
|
41992
|
-
|
|
41993
|
-
const
|
|
41994
|
-
if (original === null) {
|
|
41995
|
-
const missing = [];
|
|
41996
|
-
for (let d = (0, import_node_path14.dirname)(abs); !(0, import_node_fs11.existsSync)(d); d = (0, import_node_path14.dirname)(d)) missing.push(d);
|
|
41997
|
-
for (const d of missing.reverse()) {
|
|
41998
|
-
(0, import_node_fs11.mkdirSync)(d);
|
|
41999
|
-
createdDirs.push(d);
|
|
42000
|
-
}
|
|
42001
|
-
}
|
|
42002
|
-
(0, import_node_fs11.writeFileSync)(abs, content);
|
|
42003
|
-
return { abs, original, createdDirs };
|
|
42004
|
-
}
|
|
42005
|
-
function restore(written) {
|
|
42006
|
-
for (const file of [...written].reverse()) {
|
|
42007
|
-
try {
|
|
42008
|
-
if (file.original !== null) (0, import_node_fs11.writeFileSync)(file.abs, file.original);
|
|
42009
|
-
else (0, import_node_fs11.rmSync)(file.abs, { force: true });
|
|
42010
|
-
for (const d of [...file.createdDirs].reverse()) {
|
|
42011
|
-
try {
|
|
42012
|
-
(0, import_node_fs11.rmdirSync)(d);
|
|
42013
|
-
} catch {
|
|
42014
|
-
}
|
|
42015
|
-
}
|
|
42016
|
-
} catch (err2) {
|
|
42017
|
-
console.error(`Baseline check could not restore ${file.abs}: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
42018
|
-
}
|
|
42019
|
-
}
|
|
42038
|
+
function restoreChecked(session) {
|
|
42039
|
+
if (!session) return;
|
|
42040
|
+
for (const path of session.restore().failed) console.error(`Baseline check could not restore ${path}`);
|
|
42020
42041
|
}
|
|
42021
42042
|
function untrackedFiles(cwd) {
|
|
42022
42043
|
try {
|
|
@@ -42069,7 +42090,7 @@ async function runBaselineCheck(params) {
|
|
|
42069
42090
|
}
|
|
42070
42091
|
const warnings = [];
|
|
42071
42092
|
const flagged = [];
|
|
42072
|
-
|
|
42093
|
+
let session = null;
|
|
42073
42094
|
const unsafe = /* @__PURE__ */ new Set();
|
|
42074
42095
|
const skip = (path, why) => {
|
|
42075
42096
|
const message = `Baseline check skipped for ${path}: ${why}`;
|
|
@@ -42079,16 +42100,18 @@ async function runBaselineCheck(params) {
|
|
|
42079
42100
|
try {
|
|
42080
42101
|
const contentByPath = new Map(results.map((r) => [r.targetPath, r.newContent]));
|
|
42081
42102
|
const cause = decideCause(targets, contentByPath, cwd);
|
|
42103
|
+
const toWrite = /* @__PURE__ */ new Map();
|
|
42082
42104
|
for (const target of testTargets) {
|
|
42083
42105
|
const content = contentByPath.get(target.path);
|
|
42084
42106
|
if (content === void 0) continue;
|
|
42085
|
-
const
|
|
42086
|
-
if (
|
|
42107
|
+
const rel = insideCheckout(cwd, target.path) === null ? null : canonicalPath(target.path);
|
|
42108
|
+
if (rel === null) {
|
|
42087
42109
|
unsafe.add(target.path);
|
|
42088
42110
|
continue;
|
|
42089
42111
|
}
|
|
42090
|
-
|
|
42112
|
+
toWrite.set(rel, content);
|
|
42091
42113
|
}
|
|
42114
|
+
session = applyOverlay(cwd, [...toWrite].map(([path, content]) => ({ path, content })));
|
|
42092
42115
|
for (const { target, ids } of toCheck) {
|
|
42093
42116
|
if (unsafe.has(target.path)) {
|
|
42094
42117
|
skip(target.path, "the path is outside the checkout, so the file was not written or run.");
|
|
@@ -42141,7 +42164,7 @@ async function runBaselineCheck(params) {
|
|
|
42141
42164
|
console.warn(`::warning::${message}`);
|
|
42142
42165
|
return { findings: null, warnings: [...warnings, message] };
|
|
42143
42166
|
} finally {
|
|
42144
|
-
|
|
42167
|
+
restoreChecked(session);
|
|
42145
42168
|
}
|
|
42146
42169
|
}
|
|
42147
42170
|
|
|
@@ -42157,11 +42180,11 @@ var CONFIG_FILES = ["vitest.config.ts", "vitest.config.mts", "vitest.config.cts"
|
|
|
42157
42180
|
var WORKSPACE_IN_CONFIG = /\b(?:workspace|projects)\s*:/;
|
|
42158
42181
|
function defaultResolveVitest(cwd) {
|
|
42159
42182
|
try {
|
|
42160
|
-
const pkgPath = (0, import_node_module.createRequire)((0,
|
|
42183
|
+
const pkgPath = (0, import_node_module.createRequire)((0, import_node_path14.join)(cwd, "package.json")).resolve("vitest/package.json");
|
|
42161
42184
|
const pkg = JSON.parse((0, import_node_fs12.readFileSync)(pkgPath, "utf8"));
|
|
42162
42185
|
const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.vitest;
|
|
42163
42186
|
if (typeof rel !== "string" || typeof pkg.version !== "string") return null;
|
|
42164
|
-
return { bin: forward((0,
|
|
42187
|
+
return { bin: forward((0, import_node_path14.join)((0, import_node_path14.dirname)(pkgPath), rel)), version: pkg.version };
|
|
42165
42188
|
} catch {
|
|
42166
42189
|
return null;
|
|
42167
42190
|
}
|
|
@@ -42206,9 +42229,9 @@ function detectAdapter(i3) {
|
|
|
42206
42229
|
const parsed = parseTestInvocation(rest);
|
|
42207
42230
|
if ("off" in parsed) return parsed;
|
|
42208
42231
|
if (parsed.flags.some((f) => !ALLOWED_FLAG.test(f))) return { off: "extra_flags" };
|
|
42209
|
-
const cwd = folder ?
|
|
42232
|
+
const cwd = folder ? import_node_path14.posix.join(forward(i3.root), folder) : forward(i3.root);
|
|
42210
42233
|
if (parsed.viaScript) {
|
|
42211
|
-
const pkgText = i3.readText(
|
|
42234
|
+
const pkgText = i3.readText(import_node_path14.posix.join(cwd, "package.json"));
|
|
42212
42235
|
let script = "";
|
|
42213
42236
|
try {
|
|
42214
42237
|
const scripts = JSON.parse(pkgText ?? "{}").scripts;
|
|
@@ -42219,9 +42242,9 @@ function detectAdapter(i3) {
|
|
|
42219
42242
|
if (!/\bvitest\b/.test(script)) return { off: "not_vitest" };
|
|
42220
42243
|
if (!PLAIN_VITEST_SCRIPT.test(script)) return { off: "script_not_plain" };
|
|
42221
42244
|
}
|
|
42222
|
-
if (WORKSPACE_FILES.some((f) => i3.exists(
|
|
42245
|
+
if (WORKSPACE_FILES.some((f) => i3.exists(import_node_path14.posix.join(cwd, f)))) return { off: "workspace_config" };
|
|
42223
42246
|
for (const f of CONFIG_FILES) {
|
|
42224
|
-
const text3 = i3.exists(
|
|
42247
|
+
const text3 = i3.exists(import_node_path14.posix.join(cwd, f)) ? i3.readText(import_node_path14.posix.join(cwd, f)) : null;
|
|
42225
42248
|
if (text3 !== null && WORKSPACE_IN_CONFIG.test(text3)) return { off: "workspace_config" };
|
|
42226
42249
|
}
|
|
42227
42250
|
const found = (i3.resolveVitest ?? defaultResolveVitest)(cwd);
|
|
@@ -42244,7 +42267,7 @@ var TEST_FILE_NAME = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
|
|
42244
42267
|
function forceFullReason(paths, setupFiles = []) {
|
|
42245
42268
|
for (const raw of paths) {
|
|
42246
42269
|
const p = forward(raw);
|
|
42247
|
-
const base =
|
|
42270
|
+
const base = import_node_path14.posix.basename(p);
|
|
42248
42271
|
if (base === "package.json" || base === "npm-shrinkwrap.json") return "package_manifest";
|
|
42249
42272
|
if (/^(?:package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?)$/.test(base)) return "lock_file";
|
|
42250
42273
|
if (/^[jt]sconfig(?:\.[\w.-]+)?\.json$/.test(base)) return "ts_config";
|
|
@@ -42262,7 +42285,7 @@ function setupFilesOf(configText, folderRel) {
|
|
|
42262
42285
|
for (const m of configText.matchAll(list2)) {
|
|
42263
42286
|
for (const s of (m[1] ?? "").matchAll(/["']([^"']+)["']/g)) {
|
|
42264
42287
|
const rel = forward(s[1] ?? "").replace(/^\.\//, "");
|
|
42265
|
-
if (rel) out2.push(
|
|
42288
|
+
if (rel) out2.push(import_node_path14.posix.join(folderRel, rel));
|
|
42266
42289
|
}
|
|
42267
42290
|
}
|
|
42268
42291
|
return out2;
|
|
@@ -42297,7 +42320,7 @@ function fsReadingTests(i3) {
|
|
|
42297
42320
|
}
|
|
42298
42321
|
|
|
42299
42322
|
// src/tsconfigPaths.ts
|
|
42300
|
-
var
|
|
42323
|
+
var import_node_path15 = require("node:path");
|
|
42301
42324
|
var MAX_EXTENDS_DEPTH = 5;
|
|
42302
42325
|
function parseJsonc(text3) {
|
|
42303
42326
|
let out2 = "";
|
|
@@ -42343,12 +42366,12 @@ function resolveConfig(readText, file, depth, seen) {
|
|
|
42343
42366
|
if (typeof text3 !== "string") return null;
|
|
42344
42367
|
const json = parseJsonc(text3);
|
|
42345
42368
|
if (!isObject(json)) return null;
|
|
42346
|
-
const dir =
|
|
42369
|
+
const dir = import_node_path15.posix.dirname(file) === "." ? "" : import_node_path15.posix.dirname(file);
|
|
42347
42370
|
let inherited = { paths: null, pathsDir: dir, baseUrl: null };
|
|
42348
42371
|
const ext = typeof json.extends === "string" ? [json.extends] : stringList(json.extends);
|
|
42349
42372
|
for (const e of ext) {
|
|
42350
42373
|
if (!e.startsWith(".")) continue;
|
|
42351
|
-
const parent = resolveConfig(readText,
|
|
42374
|
+
const parent = resolveConfig(readText, import_node_path15.posix.normalize(import_node_path15.posix.join(dir, e.endsWith(".json") ? e : `${e}.json`)), depth + 1, seen);
|
|
42352
42375
|
if (parent) {
|
|
42353
42376
|
inherited = {
|
|
42354
42377
|
paths: parent.paths ?? inherited.paths,
|
|
@@ -42358,7 +42381,7 @@ function resolveConfig(readText, file, depth, seen) {
|
|
|
42358
42381
|
}
|
|
42359
42382
|
}
|
|
42360
42383
|
const co = isObject(json.compilerOptions) ? json.compilerOptions : {};
|
|
42361
|
-
const baseUrl = typeof co.baseUrl === "string" ?
|
|
42384
|
+
const baseUrl = typeof co.baseUrl === "string" ? import_node_path15.posix.normalize(import_node_path15.posix.join(dir, co.baseUrl)) : inherited.baseUrl;
|
|
42362
42385
|
let paths = inherited.paths;
|
|
42363
42386
|
let pathsDir = inherited.pathsDir;
|
|
42364
42387
|
if (isObject(co.paths)) {
|
|
@@ -42388,7 +42411,7 @@ function aliasTable(opts) {
|
|
|
42388
42411
|
if (!config?.paths) return [];
|
|
42389
42412
|
const lines = [];
|
|
42390
42413
|
for (const [key, targets] of Object.entries(config.paths)) {
|
|
42391
|
-
const resolved = targets.map((t) =>
|
|
42414
|
+
const resolved = targets.map((t) => import_node_path15.posix.normalize(import_node_path15.posix.join(config.baseUrl ?? config.pathsDir, t))).filter((p) => p !== ".." && !p.startsWith("../") && !import_node_path15.posix.isAbsolute(p));
|
|
42392
42415
|
if (resolved.length > 0) lines.push(`${key} -> ${resolved.join(", ")}`);
|
|
42393
42416
|
}
|
|
42394
42417
|
return lines.sort().slice(0, opts.max ?? 20);
|
|
@@ -42415,7 +42438,7 @@ function createAliasMapper(opts) {
|
|
|
42415
42438
|
};
|
|
42416
42439
|
return (fromPath, specifier) => {
|
|
42417
42440
|
if (specifier.startsWith(".") || specifier.startsWith("/")) return null;
|
|
42418
|
-
const dir =
|
|
42441
|
+
const dir = import_node_path15.posix.dirname(fromPath) === "." ? "" : import_node_path15.posix.dirname(fromPath);
|
|
42419
42442
|
const config = configFor(dir);
|
|
42420
42443
|
if (!config?.paths) return null;
|
|
42421
42444
|
let best = null;
|
|
@@ -42426,8 +42449,8 @@ function createAliasMapper(opts) {
|
|
|
42426
42449
|
if (!best) return null;
|
|
42427
42450
|
const bases = [];
|
|
42428
42451
|
for (const target of config.paths[best.key]) {
|
|
42429
|
-
const joined =
|
|
42430
|
-
if (joined === ".." || joined.startsWith("../") ||
|
|
42452
|
+
const joined = import_node_path15.posix.normalize(import_node_path15.posix.join(config.baseUrl ?? config.pathsDir, target.replace("*", best.captured)));
|
|
42453
|
+
if (joined === ".." || joined.startsWith("../") || import_node_path15.posix.isAbsolute(joined)) continue;
|
|
42431
42454
|
if (opts.writeRoot !== "" && !matchesPrefix(joined, opts.writeRoot)) continue;
|
|
42432
42455
|
bases.push(joined === "." ? "" : joined);
|
|
42433
42456
|
}
|
|
@@ -42481,7 +42504,7 @@ function createRelatedPlanner(d) {
|
|
|
42481
42504
|
const exists = d.exists ?? import_node_fs13.existsSync;
|
|
42482
42505
|
const mode = (env2.QUIKPILOT_RELATED_TESTS ?? "").trim().toLowerCase();
|
|
42483
42506
|
const minMs = minBaselineMs(env2);
|
|
42484
|
-
const abs = (rel) => forward2((0,
|
|
42507
|
+
const abs = (rel) => forward2((0, import_node_path16.join)(d.root, rel));
|
|
42485
42508
|
const isTest = testRule(d.discoveredTests ?? null);
|
|
42486
42509
|
let detected = null;
|
|
42487
42510
|
let setupFiles = [];
|
|
@@ -42493,9 +42516,9 @@ function createRelatedPlanner(d) {
|
|
|
42493
42516
|
function detect() {
|
|
42494
42517
|
const found = detectAdapter({ command: d.command, root: forward2(d.root), readText, exists, resolveVitest: d.resolveVitest });
|
|
42495
42518
|
if ("adapter" in found) {
|
|
42496
|
-
const folder = forward2((0,
|
|
42519
|
+
const folder = forward2((0, import_node_path16.relative)(d.root, found.adapter.cwd));
|
|
42497
42520
|
for (const name2 of CONFIG_FILES) {
|
|
42498
|
-
const text3 = exists(
|
|
42521
|
+
const text3 = exists(import_node_path16.posix.join(found.adapter.cwd, name2)) ? readText(import_node_path16.posix.join(found.adapter.cwd, name2)) : null;
|
|
42499
42522
|
if (text3 !== null) setupFiles.push(...setupFilesOf(text3, folder));
|
|
42500
42523
|
}
|
|
42501
42524
|
log({ event: "related.adapter", adapter: found.adapter.kind, version: found.adapter.version });
|
|
@@ -42603,8 +42626,36 @@ var TOKENS_PER_DIGIT_CHAR = 0.18;
|
|
|
42603
42626
|
var TOKENS_PER_SPACE_CHAR = 0.05;
|
|
42604
42627
|
var TOKENS_PER_PUNCTUATION_CHAR = 1.05;
|
|
42605
42628
|
var TOKENS_PER_NON_ASCII_CHAR = 1;
|
|
42606
|
-
var
|
|
42629
|
+
var PROMPT_OVERHEAD_BY_VERSION = Object.freeze({
|
|
42630
|
+
"codegen-loop-1": 7e3,
|
|
42631
|
+
"codegen-loop-2": 9e3,
|
|
42632
|
+
"codegen-loop-3": 11500,
|
|
42633
|
+
"codegen-loop-4": 12e3,
|
|
42634
|
+
"codegen-loop-5": 13e3,
|
|
42635
|
+
"codegen-loop-6": 16500,
|
|
42636
|
+
"codegen-loop-7": 22e3,
|
|
42637
|
+
"codegen-loop-8": 22e3,
|
|
42638
|
+
"codegen-loop-9": 23500,
|
|
42639
|
+
"targeting-loop-1": 10500,
|
|
42640
|
+
"targeting-loop-2": 10500,
|
|
42641
|
+
"targeting-loop-3": 11e3,
|
|
42642
|
+
"targeting-loop-4": 12500,
|
|
42643
|
+
"investigate-loop-1": 7e3
|
|
42644
|
+
});
|
|
42645
|
+
var LARGEST_OVERHEAD = Math.max(...Object.values(PROMPT_OVERHEAD_BY_VERSION));
|
|
42646
|
+
function promptOverheadTokens(version2) {
|
|
42647
|
+
if (typeof version2 === "string" && Object.prototype.hasOwnProperty.call(PROMPT_OVERHEAD_BY_VERSION, version2)) {
|
|
42648
|
+
return PROMPT_OVERHEAD_BY_VERSION[version2];
|
|
42649
|
+
}
|
|
42650
|
+
return LARGEST_OVERHEAD;
|
|
42651
|
+
}
|
|
42652
|
+
function versionOf(contextData) {
|
|
42653
|
+
return typeof contextData === "object" && contextData !== null ? contextData.contractVersion : void 0;
|
|
42654
|
+
}
|
|
42607
42655
|
function estimateTokens(text3) {
|
|
42656
|
+
return tokensFrom(classCounts(text3));
|
|
42657
|
+
}
|
|
42658
|
+
function classCounts(text3) {
|
|
42608
42659
|
let alpha = 0;
|
|
42609
42660
|
let digit = 0;
|
|
42610
42661
|
let space = 0;
|
|
@@ -42618,12 +42669,15 @@ function estimateTokens(text3) {
|
|
|
42618
42669
|
else if (code === 32 || code === 9 || code === 13 || code === 10) space++;
|
|
42619
42670
|
else punct++;
|
|
42620
42671
|
}
|
|
42672
|
+
return { alpha, digit, space, punct, nonAscii };
|
|
42673
|
+
}
|
|
42674
|
+
function tokensFrom(c) {
|
|
42621
42675
|
return Math.ceil(
|
|
42622
|
-
alpha * TOKENS_PER_ALPHA_CHAR + digit * TOKENS_PER_DIGIT_CHAR + space * TOKENS_PER_SPACE_CHAR + punct * TOKENS_PER_PUNCTUATION_CHAR + nonAscii * TOKENS_PER_NON_ASCII_CHAR
|
|
42676
|
+
c.alpha * TOKENS_PER_ALPHA_CHAR + c.digit * TOKENS_PER_DIGIT_CHAR + c.space * TOKENS_PER_SPACE_CHAR + c.punct * TOKENS_PER_PUNCTUATION_CHAR + c.nonAscii * TOKENS_PER_NON_ASCII_CHAR
|
|
42623
42677
|
);
|
|
42624
42678
|
}
|
|
42625
42679
|
function estimateRequestTokens(contextData) {
|
|
42626
|
-
return
|
|
42680
|
+
return promptOverheadTokens(versionOf(contextData)) + estimateTokens(JSON.stringify(contextData ?? {}, null, 2));
|
|
42627
42681
|
}
|
|
42628
42682
|
|
|
42629
42683
|
// src/turnUsage.ts
|
|
@@ -42646,7 +42700,7 @@ function usageOf(envelope) {
|
|
|
42646
42700
|
var sizeOf = (value) => value === void 0 ? 0 : estimateTokens(JSON.stringify(value, null, 2));
|
|
42647
42701
|
var RESULT_KEYS = /* @__PURE__ */ new Set(["transcript", "toolResults", "previousAttempt"]);
|
|
42648
42702
|
function requestParts(contextData) {
|
|
42649
|
-
const parts2 = { fixed:
|
|
42703
|
+
const parts2 = { fixed: promptOverheadTokens(versionOf(contextData)), map: 0, cases: 0, task: 0, results: 0, notes: 0, other: 0 };
|
|
42650
42704
|
for (const [key, value] of Object.entries(contextData)) {
|
|
42651
42705
|
if (key === "repoMap" || key === "workspaceListing") parts2.map += sizeOf(value);
|
|
42652
42706
|
else if (key === "requiredTests") parts2.cases += sizeOf(value);
|
|
@@ -43031,7 +43085,9 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
43031
43085
|
expectedOutputType: "json",
|
|
43032
43086
|
userPrompt: "",
|
|
43033
43087
|
contextData
|
|
43034
|
-
})
|
|
43088
|
+
}),
|
|
43089
|
+
// QUIKTR-2708 (RN-22): a per-file call gets an explicit limit (a fresh one per call); it had none of its own.
|
|
43090
|
+
signal: AbortSignal.timeout(LONG_CALL_MS)
|
|
43035
43091
|
});
|
|
43036
43092
|
let res = await callCodegen();
|
|
43037
43093
|
if (!res.ok) {
|
|
@@ -43230,12 +43286,12 @@ function callFunctionEnabled(githubRepository, mode, env2 = process.env) {
|
|
|
43230
43286
|
|
|
43231
43287
|
// src/callFunctionTool.ts
|
|
43232
43288
|
var import_node_crypto4 = require("node:crypto");
|
|
43233
|
-
var
|
|
43289
|
+
var import_node_path18 = require("node:path");
|
|
43234
43290
|
|
|
43235
43291
|
// src/runTestsTool.ts
|
|
43236
43292
|
var import_node_crypto3 = require("node:crypto");
|
|
43237
43293
|
var import_node_fs14 = require("node:fs");
|
|
43238
|
-
var
|
|
43294
|
+
var import_node_path17 = require("node:path");
|
|
43239
43295
|
var scrubSecrets2 = (text3) => scrubForModel(text3, [], "code").text;
|
|
43240
43296
|
var RUN_TESTS_TOOL = "run_tests";
|
|
43241
43297
|
var MAX_TEST_RUNS = 3;
|
|
@@ -43314,9 +43370,9 @@ function samePlace(a, b) {
|
|
|
43314
43370
|
function ownFailureIds(newFailures, changedPaths, requiredIds, changedText) {
|
|
43315
43371
|
const own = /* @__PURE__ */ new Set();
|
|
43316
43372
|
for (const id of newFailures) {
|
|
43317
|
-
const
|
|
43318
|
-
const file =
|
|
43319
|
-
const name2 =
|
|
43373
|
+
const sep2 = id.indexOf("::");
|
|
43374
|
+
const file = sep2 >= 0 ? id.slice(0, sep2) : "";
|
|
43375
|
+
const name2 = sep2 >= 0 ? id.slice(sep2 + 2) : id;
|
|
43320
43376
|
const inChangedFile = file !== "" && changedPaths.some((p) => samePlace(file, p));
|
|
43321
43377
|
const hasToken = requiredIds.some((t) => name2.includes(`[${t}]`));
|
|
43322
43378
|
if (inChangedFile || hasToken) {
|
|
@@ -43548,7 +43604,7 @@ var RunTestsTool = class {
|
|
|
43548
43604
|
const runCommand2 = d.runCommand ?? runTestCommandWithLimit;
|
|
43549
43605
|
const readSnapshot = d.readSnapshot ?? readTestSnapshot;
|
|
43550
43606
|
const reportBefore = findReport(d.root);
|
|
43551
|
-
const preserve = reportBefore ? [(0,
|
|
43607
|
+
const preserve = reportBefore ? [(0, import_node_path17.relative)(d.root, reportBefore).split("\\").join("/")] : [];
|
|
43552
43608
|
const spend = (n) => {
|
|
43553
43609
|
if (file === void 0) this.runs += n;
|
|
43554
43610
|
else this.fileRuns += n;
|
|
@@ -43899,7 +43955,7 @@ var CallFunctionTool = class {
|
|
|
43899
43955
|
const now = d.now ?? Date.now;
|
|
43900
43956
|
const helper = {
|
|
43901
43957
|
path: `.quikpilot-call-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.mjs`,
|
|
43902
|
-
content: helperSource({ target: (0,
|
|
43958
|
+
content: helperSource({ target: (0, import_node_path18.join)(d.root, parsed.path), exportName: parsed.exportName, args: parsed.callArgs })
|
|
43903
43959
|
};
|
|
43904
43960
|
const run3 = d.run ?? runCapturedCommand;
|
|
43905
43961
|
this.calls += 1;
|
|
@@ -43909,7 +43965,7 @@ var CallFunctionTool = class {
|
|
|
43909
43965
|
captured = await withOverlayOnDisk(
|
|
43910
43966
|
d.root,
|
|
43911
43967
|
[...files, helper],
|
|
43912
|
-
() => run3([d.nodePath ?? process.execPath, (0,
|
|
43968
|
+
() => run3([d.nodePath ?? process.execPath, (0, import_node_path18.join)(d.root, helper.path)], { cwd: d.root, timeoutMs: d.timeoutMs ?? CALL_TIMEOUT_MS, maxStdoutBytes: MAX_STDOUT_BYTES }),
|
|
43913
43969
|
{ ...d.tree }
|
|
43914
43970
|
);
|
|
43915
43971
|
} catch (err2) {
|
|
@@ -47677,10 +47733,10 @@ function fitBlocks(blocks, paths, room) {
|
|
|
47677
47733
|
for (let i3 = 0; i3 < blocks.length; i3++) {
|
|
47678
47734
|
const block = blocks[i3];
|
|
47679
47735
|
const tail2 = i3 + 1 < blocks.length ? note(i3 + 1) : "";
|
|
47680
|
-
const
|
|
47681
|
-
if (used +
|
|
47736
|
+
const sep2 = kept.length > 0 ? 1 : 0;
|
|
47737
|
+
if (used + sep2 + block.length + (tail2 ? tail2.length + 1 : 0) <= room) {
|
|
47682
47738
|
kept.push(block);
|
|
47683
|
-
used +=
|
|
47739
|
+
used += sep2 + block.length;
|
|
47684
47740
|
continue;
|
|
47685
47741
|
}
|
|
47686
47742
|
const rest = note(i3);
|
|
@@ -48069,7 +48125,7 @@ function createCodegenWorkspace(args2) {
|
|
|
48069
48125
|
|
|
48070
48126
|
// src/scratchRunTool.ts
|
|
48071
48127
|
var import_node_fs15 = require("node:fs");
|
|
48072
|
-
var
|
|
48128
|
+
var import_node_path19 = require("node:path");
|
|
48073
48129
|
var RUN_SCRATCH_TOOL = "run_scratch";
|
|
48074
48130
|
var MAX_SCRATCH_TEXT_CHARS = 2e3;
|
|
48075
48131
|
var MAX_SCRATCH_CONTENT_CHARS = 8e3;
|
|
@@ -48155,10 +48211,10 @@ var ScratchRunTool = class {
|
|
|
48155
48211
|
if (matchesDeniedPath(path, d.deniedPaths) !== null) return false;
|
|
48156
48212
|
if (!testRule(d.discoveredTests)(path)) return false;
|
|
48157
48213
|
if (d.protectedTestPaths.includes(path) || d.listing.includes(path) || files.some((f) => f.path === path)) return false;
|
|
48158
|
-
const abs = (0,
|
|
48214
|
+
const abs = (0, import_node_path19.join)(d.root, path);
|
|
48159
48215
|
if ((0, import_node_fs15.existsSync)(abs)) return false;
|
|
48160
48216
|
try {
|
|
48161
|
-
return (0, import_node_fs15.statSync)((0,
|
|
48217
|
+
return (0, import_node_fs15.statSync)((0, import_node_path19.dirname)(abs)).isDirectory();
|
|
48162
48218
|
} catch {
|
|
48163
48219
|
return false;
|
|
48164
48220
|
}
|
|
@@ -48197,7 +48253,7 @@ var ScratchRunTool = class {
|
|
|
48197
48253
|
const run3 = d.run ?? runShellCaptured;
|
|
48198
48254
|
const command = buildSingleFileCommand(fileCommand, parsed.path);
|
|
48199
48255
|
const reportBefore = (d.findReport ?? findJUnitReport)(d.root);
|
|
48200
|
-
const preserve = reportBefore ? [(0,
|
|
48256
|
+
const preserve = reportBefore ? [(0, import_node_path19.relative)(d.root, reportBefore).split("\\").join("/")] : [];
|
|
48201
48257
|
this.calls += 1;
|
|
48202
48258
|
const startedAt = now();
|
|
48203
48259
|
let ran;
|
|
@@ -48243,17 +48299,16 @@ var MAX_CALLS_IN_ALL = 40;
|
|
|
48243
48299
|
var MAX_NOTE_CHARS = 500;
|
|
48244
48300
|
var MAX_PATH_CHARS3 = 300;
|
|
48245
48301
|
var MAX_REASON_CHARS = 200;
|
|
48246
|
-
var isRecord2 = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
|
|
48247
48302
|
var count3 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5, Math.max(0, n)) : 0;
|
|
48248
48303
|
function callOf(call, result) {
|
|
48249
48304
|
if (!result) return null;
|
|
48250
|
-
const args2 =
|
|
48305
|
+
const args2 = isPlainObject(call.args) ? call.args : {};
|
|
48251
48306
|
const named2 = typeof args2.path === "string" ? args2.path : call.name === "run_tests" && typeof args2.file === "string" ? args2.file : void 0;
|
|
48252
48307
|
const out2 = { tool: call.name, status: result.status };
|
|
48253
48308
|
if (named2 && named2.length > 0 && named2.length <= MAX_PATH_CHARS3) out2.path = named2;
|
|
48254
48309
|
if (typeof result.reason === "string" && result.reason.length > 0) out2.reason = result.reason.slice(0, MAX_REASON_CHARS);
|
|
48255
48310
|
const o = result.output;
|
|
48256
|
-
if (call.name === "run_tests" &&
|
|
48311
|
+
if (call.name === "run_tests" && isPlainObject(o) && typeof o.passed === "number" && typeof o.failed === "number") {
|
|
48257
48312
|
out2.tests = { passed: count3(o.passed), failed: count3(o.failed), regressions: count3(o.regressions), newFailures: count3(o.newFailures) };
|
|
48258
48313
|
if (o.scope === "file") out2.scope = "file";
|
|
48259
48314
|
}
|
|
@@ -48261,7 +48316,7 @@ function callOf(call, result) {
|
|
|
48261
48316
|
}
|
|
48262
48317
|
function pythonJsonLength(value) {
|
|
48263
48318
|
if (Array.isArray(value)) return value.length === 0 ? 2 : 2 + value.reduce((n, v) => n + pythonJsonLength(v), 0) + 2 * (value.length - 1);
|
|
48264
|
-
if (
|
|
48319
|
+
if (isPlainObject(value)) {
|
|
48265
48320
|
const entries = Object.entries(value).filter(([, v]) => v !== void 0);
|
|
48266
48321
|
if (entries.length === 0) return 2;
|
|
48267
48322
|
return 2 + entries.reduce((n, [k, v]) => n + JSON.stringify(k).length + 2 + pythonJsonLength(v), 0) + 2 * (entries.length - 1);
|
|
@@ -48290,7 +48345,7 @@ function stepsOf(transcript, toolResults) {
|
|
|
48290
48345
|
|
|
48291
48346
|
// src/importCheck.ts
|
|
48292
48347
|
var MAX_REPORTED = 5;
|
|
48293
|
-
function
|
|
48348
|
+
function resolve3(fromPath, spec, exists) {
|
|
48294
48349
|
const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
|
|
48295
48350
|
const out2 = [];
|
|
48296
48351
|
for (const part of [...dir ? dir.split("/") : [], ...spec.split("/")]) {
|
|
@@ -48398,7 +48453,7 @@ function missingImports(changed, read, exists) {
|
|
|
48398
48453
|
const parsed = parseProgram(path, text3);
|
|
48399
48454
|
if (!parsed || parsed.sourceType !== "module") continue;
|
|
48400
48455
|
for (const [name2, spec] of relativeImports(parsed.ast)) {
|
|
48401
|
-
const target =
|
|
48456
|
+
const target = resolve3(path, spec, exists);
|
|
48402
48457
|
if (!target) continue;
|
|
48403
48458
|
if (!exportsOf.has(target)) {
|
|
48404
48459
|
const t = read(target);
|
|
@@ -48630,26 +48685,10 @@ function proofSentences(proof) {
|
|
|
48630
48685
|
return out2.map((s) => s.length > 300 ? `${s.slice(0, 299)}\u2026` : s);
|
|
48631
48686
|
}
|
|
48632
48687
|
|
|
48633
|
-
// src/targetingErrors.ts
|
|
48634
|
-
var DeniedPathError = class extends Error {
|
|
48635
|
-
constructor(message) {
|
|
48636
|
-
super(message);
|
|
48637
|
-
this.name = "DeniedPathError";
|
|
48638
|
-
}
|
|
48639
|
-
};
|
|
48640
|
-
var TargetingHttpError = class extends Error {
|
|
48641
|
-
status;
|
|
48642
|
-
constructor(status, statusText) {
|
|
48643
|
-
super(`Targeting call failed: ${status} ${statusText}`);
|
|
48644
|
-
this.name = "TargetingHttpError";
|
|
48645
|
-
this.status = status;
|
|
48646
|
-
}
|
|
48647
|
-
};
|
|
48648
|
-
|
|
48649
48688
|
// src/dataPathCheck.ts
|
|
48650
48689
|
var import_node_child_process10 = require("node:child_process");
|
|
48651
48690
|
var import_node_fs17 = require("node:fs");
|
|
48652
|
-
var
|
|
48691
|
+
var import_node_path20 = require("node:path");
|
|
48653
48692
|
|
|
48654
48693
|
// src/scopeCheck.ts
|
|
48655
48694
|
var import_node_fs16 = require("node:fs");
|
|
@@ -48881,7 +48920,7 @@ function screenLoaders(cwd, screen, read, skip, expired) {
|
|
|
48881
48920
|
function readFromCheckout(root) {
|
|
48882
48921
|
return (path) => {
|
|
48883
48922
|
try {
|
|
48884
|
-
const abs = (0,
|
|
48923
|
+
const abs = (0, import_node_path20.join)(root, path);
|
|
48885
48924
|
const st = (0, import_node_fs17.lstatSync)(abs);
|
|
48886
48925
|
return st.isSymbolicLink() || !st.isFile() || st.size > MAX_FILE_CHARS2 ? null : (0, import_node_fs17.readFileSync)(abs, "utf8");
|
|
48887
48926
|
} catch {
|
|
@@ -49080,24 +49119,8 @@ var SafetyRefusalError = class extends RuntimeReplyError {
|
|
|
49080
49119
|
var NO_FALLBACK_CODES = /* @__PURE__ */ new Set(["RUN_BUDGET_EXCEEDED", "RUN_CREDENTIAL_SCOPE"]);
|
|
49081
49120
|
var OUTPUT_TOO_LARGE_CODES = /* @__PURE__ */ new Set(["CODEGEN_OUTPUT_TOO_LARGE", "OUTPUT_TRUNCATED"]);
|
|
49082
49121
|
var TOOL_NAMES = /* @__PURE__ */ new Set(["list_files", "read_file", "grep", "find_definition"]);
|
|
49083
|
-
var MAX_ID_CHARS = 64;
|
|
49084
|
-
var MAX_CALLS_IN_A_REPLY = 50;
|
|
49085
|
-
var MAX_ARGS_JSON_CHARS = 1e3;
|
|
49086
|
-
function isPlainObject2(x) {
|
|
49087
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
49088
|
-
}
|
|
49089
|
-
function safeArgs(args2) {
|
|
49090
|
-
try {
|
|
49091
|
-
return JSON.stringify(args2).length <= MAX_ARGS_JSON_CHARS ? args2 : { _omitted: "too large" };
|
|
49092
|
-
} catch {
|
|
49093
|
-
return { _omitted: "unreadable" };
|
|
49094
|
-
}
|
|
49095
|
-
}
|
|
49096
49122
|
function classifyTransport(err2) {
|
|
49097
|
-
|
|
49098
|
-
const name2 = err2?.name;
|
|
49099
|
-
if (name2 === "TimeoutError" || name2 === "AbortError") return new LoopFailure("turn_timeout", void 0, err2);
|
|
49100
|
-
return new LoopFailure("transport", void 0, err2);
|
|
49123
|
+
return new LoopFailure(transportReason(err2), void 0, err2);
|
|
49101
49124
|
}
|
|
49102
49125
|
async function runTargetingLoop(args2, deps) {
|
|
49103
49126
|
const limits = { ...DEFAULT_LIMITS, ...deps.limits };
|
|
@@ -49268,18 +49291,9 @@ async function runTargetingLoop(args2, deps) {
|
|
|
49268
49291
|
}
|
|
49269
49292
|
if (body2.outcome !== "TOOL_CALLS") throw new LoopFailure("bad_reply");
|
|
49270
49293
|
if (isFinal) throw new LoopFailure("final_not_produced");
|
|
49271
|
-
const
|
|
49272
|
-
if (
|
|
49273
|
-
|
|
49274
|
-
}
|
|
49275
|
-
const calls = [];
|
|
49276
|
-
for (const c of rawCalls) {
|
|
49277
|
-
if (!isPlainObject2(c) || typeof c.id !== "string" || c.id.length === 0 || c.id.length > MAX_ID_CHARS || typeof c.name !== "string") {
|
|
49278
|
-
throw new LoopFailure("bad_reply");
|
|
49279
|
-
}
|
|
49280
|
-
if (usedIds.has(c.id) || calls.some((x) => x.id === c.id)) throw new LoopFailure("duplicate_call_ids");
|
|
49281
|
-
calls.push({ id: c.id, name: c.name, args: c.args });
|
|
49282
|
-
}
|
|
49294
|
+
const parsed = parseToolCalls(body2.toolCalls, usedIds);
|
|
49295
|
+
if (typeof parsed === "string") throw new LoopFailure(parsed);
|
|
49296
|
+
const calls = parsed.calls;
|
|
49283
49297
|
for (const c of calls) usedIds.add(c.id);
|
|
49284
49298
|
const results = [];
|
|
49285
49299
|
const logged = [];
|
|
@@ -49569,9 +49583,6 @@ var PROPOSAL_SENTENCES = {
|
|
|
49569
49583
|
undo: `${NOT_RECORDED} "undo" must be text of at most 4,000 characters.`,
|
|
49570
49584
|
apply: `${NOT_RECORDED} "apply" must be text of at most 300 characters.`
|
|
49571
49585
|
};
|
|
49572
|
-
function isRecord3(x) {
|
|
49573
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
49574
|
-
}
|
|
49575
49586
|
function cleanPath(value) {
|
|
49576
49587
|
if (value.length > MAX_PATH_CHARS4) return false;
|
|
49577
49588
|
const n = normaliseToolPath(value);
|
|
@@ -49586,7 +49597,7 @@ function readProposal(text3, partIds) {
|
|
|
49586
49597
|
} catch {
|
|
49587
49598
|
return fail(PROPOSAL_SENTENCES.notJson);
|
|
49588
49599
|
}
|
|
49589
|
-
if (!
|
|
49600
|
+
if (!isPlainObject(raw)) return fail(PROPOSAL_SENTENCES.notJson);
|
|
49590
49601
|
const keys = Object.keys(raw);
|
|
49591
49602
|
if (keys.some((k) => !KEYS.includes(k))) return fail(PROPOSAL_SENTENCES.keys);
|
|
49592
49603
|
for (const k of ["parts", "additive", "schemaFile", "migrationFile", "migration"]) if (!keys.includes(k)) return fail(PROPOSAL_SENTENCES.keys);
|
|
@@ -49693,7 +49704,7 @@ function namesSentence(names) {
|
|
|
49693
49704
|
return `${NOT_RECORDED} the migration names ${shown.join(", ")}${more}, which no file this run could read shows. Read the file that defines the stored data, then write the whole note again with the names the repository uses.`;
|
|
49694
49705
|
}
|
|
49695
49706
|
function namesNote(args2) {
|
|
49696
|
-
if (!
|
|
49707
|
+
if (!isPlainObject(args2) || typeof args2.path !== "string") return false;
|
|
49697
49708
|
const n = normaliseToolPath(args2.path);
|
|
49698
49709
|
return n.ok && n.path === DATABASE_CHANGE_PATH;
|
|
49699
49710
|
}
|
|
@@ -49792,9 +49803,6 @@ var MAX_NAME_CHARS3 = 150;
|
|
|
49792
49803
|
var MAX_WHAT_CHARS = 300;
|
|
49793
49804
|
var PART_ID_RE = /^P\d+$/;
|
|
49794
49805
|
var MARKER_RE = /\[(P\d+)(?:=(exists|proposed))?\]/g;
|
|
49795
|
-
function isRecord4(x) {
|
|
49796
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
49797
|
-
}
|
|
49798
49806
|
function cutTo(text3, max) {
|
|
49799
49807
|
if (text3.length <= max) return text3;
|
|
49800
49808
|
const last = text3.charCodeAt(max - 1);
|
|
@@ -49803,14 +49811,14 @@ function cutTo(text3, max) {
|
|
|
49803
49811
|
}
|
|
49804
49812
|
function partsFromDesignCut(design) {
|
|
49805
49813
|
const none = { parts: [], cut: 0 };
|
|
49806
|
-
if (!
|
|
49814
|
+
if (!isPlainObject(design) || !Array.isArray(design.parts)) return none;
|
|
49807
49815
|
const raw = design.parts;
|
|
49808
49816
|
if (raw.length === 0 || raw.length > MAX_PARTS) return none;
|
|
49809
49817
|
const out2 = [];
|
|
49810
49818
|
const ids = /* @__PURE__ */ new Set();
|
|
49811
49819
|
let cut2 = 0;
|
|
49812
49820
|
for (const p of raw) {
|
|
49813
|
-
if (!
|
|
49821
|
+
if (!isPlainObject(p)) return none;
|
|
49814
49822
|
const { id, kind, name: name2, what } = p;
|
|
49815
49823
|
if (typeof id !== "string" || !PART_ID_RE.test(id) || ids.has(id)) return none;
|
|
49816
49824
|
if (typeof kind !== "string" || !PART_KINDS.includes(kind)) return none;
|
|
@@ -49998,7 +50006,6 @@ var MAX_CRITERION_ID_CHARS = 40;
|
|
|
49998
50006
|
var MAX_STATEMENT_CHARS = 500;
|
|
49999
50007
|
var MAX_QUOTE_CHARS2 = 200;
|
|
50000
50008
|
var METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
50001
|
-
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
50002
50009
|
var strings = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string") : [];
|
|
50003
50010
|
var oneLine2 = (s, max) => s.trim() !== "" && s.length <= max && !/[\r\n]/.test(s);
|
|
50004
50011
|
var unique3 = (xs) => [...new Set(xs)];
|
|
@@ -50011,7 +50018,7 @@ function cleanAddress(a) {
|
|
|
50011
50018
|
}
|
|
50012
50019
|
function prepareTicketHints(raw, listing, deniedPaths) {
|
|
50013
50020
|
const counts = { files: 0, routes: 0, routeFiles: 0, names: 0, tests: 0, dropped: 0 };
|
|
50014
|
-
if (!
|
|
50021
|
+
if (!isPlainObject(raw)) return { counts };
|
|
50015
50022
|
const listed = listing instanceof Set ? listing : new Set(listing);
|
|
50016
50023
|
const denied = [...deniedPaths];
|
|
50017
50024
|
const usable = (p) => cleanPath2(p) && listed.has(p) && matchesDeniedPath(p, denied) === null;
|
|
@@ -50027,7 +50034,7 @@ function prepareTicketHints(raw, listing, deniedPaths) {
|
|
|
50027
50034
|
const seen = /* @__PURE__ */ new Set();
|
|
50028
50035
|
for (const r of Array.isArray(raw.routes) ? raw.routes : []) {
|
|
50029
50036
|
if (routes.length >= MAX_HINT_ROUTES) break;
|
|
50030
|
-
if (!
|
|
50037
|
+
if (!isPlainObject(r) || typeof r.address !== "string") continue;
|
|
50031
50038
|
const address = r.address.trim();
|
|
50032
50039
|
if (!cleanAddress(address)) continue;
|
|
50033
50040
|
const method = typeof r.method === "string" && METHODS.has(r.method.toUpperCase()) ? r.method.toUpperCase() : void 0;
|
|
@@ -50059,7 +50066,7 @@ function prepareCriteriaWording(raw) {
|
|
|
50059
50066
|
const out2 = [];
|
|
50060
50067
|
for (const c of raw) {
|
|
50061
50068
|
if (out2.length >= MAX_CRITERIA) break;
|
|
50062
|
-
if (!
|
|
50069
|
+
if (!isPlainObject(c) || typeof c.id !== "string" || typeof c.statement !== "string") continue;
|
|
50063
50070
|
const id = c.id.trim();
|
|
50064
50071
|
const statement = c.statement.trim().slice(0, MAX_STATEMENT_CHARS).trim();
|
|
50065
50072
|
if (!oneLine2(id, MAX_CRITERION_ID_CHARS) || statement === "") continue;
|
|
@@ -50207,23 +50214,15 @@ function withUnreportable(stop2, tests) {
|
|
|
50207
50214
|
if (stop2.summary) carried.summary = stop2.summary;
|
|
50208
50215
|
return carried;
|
|
50209
50216
|
}
|
|
50210
|
-
var MAX_ID_CHARS2 = 64;
|
|
50211
50217
|
var MAX_RED_REFUSALS = 1;
|
|
50212
50218
|
var NOTHING_NEW = /* @__PURE__ */ new Set(["duplicate", "no_effect", "no_change_since_last_run", "no_match", "ambiguous", "conflict_rejected"]);
|
|
50213
50219
|
var HARNESS_NO_PROGRESS_TURNS = 3;
|
|
50214
|
-
var MAX_CALLS_IN_A_REPLY2 = 50;
|
|
50215
50220
|
var MAX_SUMMARY_CHARS = 300;
|
|
50216
50221
|
var READ_TOOLS = /* @__PURE__ */ new Set(["list_files", "read_file", "grep", "find_definition", "show_changes"]);
|
|
50217
50222
|
var WRITE_TOOLS = /* @__PURE__ */ new Set(["edit_file", "write_file"]);
|
|
50218
50223
|
var TOOL_NAMES2 = /* @__PURE__ */ new Set([...READ_TOOLS, ...WRITE_TOOLS, RUN_TESTS_TOOL, CALL_FUNCTION_TOOL, RUN_SCRATCH_TOOL, "revert_file", REPORT_TEST_CONFLICT_TOOL]);
|
|
50219
|
-
function isPlainObject3(x) {
|
|
50220
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
50221
|
-
}
|
|
50222
50224
|
function classifyTransport2(err2) {
|
|
50223
|
-
|
|
50224
|
-
const name2 = err2?.name;
|
|
50225
|
-
if (name2 === "TimeoutError" || name2 === "AbortError") return new CodegenLoopFailure("turn_timeout", void 0, err2);
|
|
50226
|
-
return new CodegenLoopFailure("transport", void 0, err2);
|
|
50225
|
+
return new CodegenLoopFailure(transportReason(err2), void 0, err2);
|
|
50227
50226
|
}
|
|
50228
50227
|
function previousForLoop2(withSteps) {
|
|
50229
50228
|
const { steps: _steps, stepsTrimmed: _trimmed, ...previous } = withSteps;
|
|
@@ -50241,8 +50240,10 @@ function previousForLoop2(withSteps) {
|
|
|
50241
50240
|
return { ...previous, lastTestRun: Object.keys(messages).length > 0 ? { ...rest, messages } : rest };
|
|
50242
50241
|
}
|
|
50243
50242
|
function isTestAnswer(x) {
|
|
50244
|
-
return
|
|
50243
|
+
return isPlainObject(x) && typeof x.passed === "number" && Array.isArray(x.failingTests);
|
|
50245
50244
|
}
|
|
50245
|
+
var ENTRY_INDENT = 6;
|
|
50246
|
+
var roomCountCheck = { enabled: false };
|
|
50246
50247
|
var DROPPED_OUTPUT = { dropped: true, note: "Dropped to keep the request small. Read the file again if you need it." };
|
|
50247
50248
|
var DROPPED_UNSEEN_OUTPUT = { dropped: true, note: "Too large to send with the rest of this request. Read a smaller part of the file." };
|
|
50248
50249
|
var DROP_NOTES = /* @__PURE__ */ new Set([DROPPED_OUTPUT.note, DROPPED_UNSEEN_OUTPUT.note]);
|
|
@@ -50547,7 +50548,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
50547
50548
|
...usage.totals.calls > 0 ? { turnUsage: usage.rows.map((r) => ({ ...r, parts: { ...r.parts } })), usage: { ...usage.totals } } : {},
|
|
50548
50549
|
...usage.rowsCut ? { turnUsageCut: true } : {}
|
|
50549
50550
|
});
|
|
50550
|
-
const dropOutputs = (upTo, done, output, keep) => {
|
|
50551
|
+
const dropOutputs = (upTo, done, output, keep, onReplace) => {
|
|
50551
50552
|
const lastTestRun = toolResults.map((r) => r.name).lastIndexOf(RUN_TESTS_TOOL);
|
|
50552
50553
|
const lastCall = toolResults.map((r) => r.name).lastIndexOf(CALL_FUNCTION_TOOL);
|
|
50553
50554
|
const lastScratch = toolResults.map((r) => r.name).lastIndexOf(RUN_SCRATCH_TOOL);
|
|
@@ -50559,29 +50560,55 @@ async function runCodegenLoop(args2, deps) {
|
|
|
50559
50560
|
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;
|
|
50560
50561
|
if (!stale) continue;
|
|
50561
50562
|
toolResults[i3] = shrunkAnswer(r, output);
|
|
50563
|
+
onReplace?.(r, toolResults[i3]);
|
|
50562
50564
|
dropped++;
|
|
50563
50565
|
}
|
|
50564
50566
|
return dropped;
|
|
50565
50567
|
};
|
|
50566
50568
|
const makeRoom = (nextTurn, nextFinal, finalReason) => {
|
|
50567
|
-
const
|
|
50569
|
+
const whole4 = () => classCounts(JSON.stringify(buildContext(nextTurn, nextFinal, finalReason) ?? {}, null, 2));
|
|
50570
|
+
let counts = whole4();
|
|
50571
|
+
const fixed2 = promptOverheadTokens(versionOf(buildContext(nextTurn, nextFinal, finalReason)));
|
|
50572
|
+
const replaced = (before, after) => {
|
|
50573
|
+
const b = JSON.stringify(before, null, 2);
|
|
50574
|
+
const a = JSON.stringify(after, null, 2);
|
|
50575
|
+
const cb = classCounts(b);
|
|
50576
|
+
const ca = classCounts(a);
|
|
50577
|
+
const newlines = (s) => s.split("\n").length - 1;
|
|
50578
|
+
counts = {
|
|
50579
|
+
alpha: counts.alpha - cb.alpha + ca.alpha,
|
|
50580
|
+
digit: counts.digit - cb.digit + ca.digit,
|
|
50581
|
+
space: counts.space - cb.space + ca.space + ENTRY_INDENT * (newlines(a) - newlines(b)),
|
|
50582
|
+
punct: counts.punct - cb.punct + ca.punct,
|
|
50583
|
+
nonAscii: counts.nonAscii - cb.nonAscii + ca.nonAscii
|
|
50584
|
+
};
|
|
50585
|
+
};
|
|
50586
|
+
const under = (limit) => {
|
|
50587
|
+
if (roomCountCheck.enabled) {
|
|
50588
|
+
const full = whole4();
|
|
50589
|
+
if (JSON.stringify(full) !== JSON.stringify(counts)) throw new Error(`makeRoom's running count drifted: ${JSON.stringify(counts)} vs ${JSON.stringify(full)}`);
|
|
50590
|
+
}
|
|
50591
|
+
return fixed2 + tokensFrom(counts) <= limit;
|
|
50592
|
+
};
|
|
50568
50593
|
const fits = () => under(limits.maxRequestTokens);
|
|
50569
50594
|
const soft = args2.readRoots ? mapSoftTarget(firstRequestTokens, limits.maxRequestTokens) : limits.maxRequestTokens;
|
|
50570
50595
|
if (under(soft)) return true;
|
|
50571
|
-
dropOutputs(sent.results, () => under(soft), DROPPED_OUTPUT, keepOn ? tracker.keep(outputOf) : void 0);
|
|
50596
|
+
dropOutputs(sent.results, () => under(soft), DROPPED_OUTPUT, keepOn ? tracker.keep(outputOf) : void 0, replaced);
|
|
50572
50597
|
for (const key of [...ledger.seen.keys()]) {
|
|
50573
50598
|
if (key.startsWith("read_file:") || key.startsWith("grep:") || key.startsWith("list_files:") || key.startsWith("show_changes:")) ledger.seen.delete(key);
|
|
50574
50599
|
}
|
|
50575
50600
|
for (const entry of transcript) {
|
|
50576
50601
|
if (fits()) break;
|
|
50602
|
+
const before = { ...entry };
|
|
50577
50603
|
entry.toolCalls = entry.toolCalls.map((c) => {
|
|
50578
|
-
if (!WRITE_TOOLS.has(c.name) || !
|
|
50604
|
+
if (!WRITE_TOOLS.has(c.name) || !isPlainObject(c.args) || "_omitted" in c.args) return c;
|
|
50579
50605
|
const path = typeof c.args.path === "string" ? { path: c.args.path } : {};
|
|
50580
50606
|
return { ...c, args: { ...path, _omitted: "written earlier; read the file to see it" } };
|
|
50581
50607
|
});
|
|
50608
|
+
replaced(before, entry);
|
|
50582
50609
|
}
|
|
50583
50610
|
if (fits()) return true;
|
|
50584
|
-
const unseen = dropOutputs(toolResults.length, fits, DROPPED_UNSEEN_OUTPUT);
|
|
50611
|
+
const unseen = dropOutputs(toolResults.length, fits, DROPPED_UNSEEN_OUTPUT, void 0, replaced);
|
|
50585
50612
|
if (unseen > 0) log({ event: "codegen.read_dropped_unseen", turn: nextTurn - 1, outputs: unseen, ceiling: limits.maxRequestTokens });
|
|
50586
50613
|
return fits();
|
|
50587
50614
|
};
|
|
@@ -51096,16 +51123,9 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51096
51123
|
}
|
|
51097
51124
|
if (body2.outcome !== "TOOL_CALLS") throw new CodegenLoopFailure("bad_reply");
|
|
51098
51125
|
if (isFinal) throw new CodegenLoopFailure("final_not_produced");
|
|
51099
|
-
const
|
|
51100
|
-
if (
|
|
51101
|
-
const calls =
|
|
51102
|
-
for (const c of rawCalls) {
|
|
51103
|
-
if (!isPlainObject3(c) || typeof c.id !== "string" || c.id.length === 0 || c.id.length > MAX_ID_CHARS2 || typeof c.name !== "string") {
|
|
51104
|
-
throw new CodegenLoopFailure("bad_reply");
|
|
51105
|
-
}
|
|
51106
|
-
if (usedIds.has(c.id) || calls.some((x) => x.id === c.id)) throw new CodegenLoopFailure("duplicate_call_ids");
|
|
51107
|
-
calls.push({ id: c.id, name: c.name, args: c.args });
|
|
51108
|
-
}
|
|
51126
|
+
const parsed = parseToolCalls(body2.toolCalls, usedIds);
|
|
51127
|
+
if (typeof parsed === "string") throw new CodegenLoopFailure(parsed);
|
|
51128
|
+
const calls = parsed.calls;
|
|
51109
51129
|
for (const c of calls) usedIds.add(c.id);
|
|
51110
51130
|
const results = [];
|
|
51111
51131
|
const logged = [];
|
|
@@ -51171,7 +51191,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51171
51191
|
if (hinted.outcome === "added") result = { ...result, message: hinted.message };
|
|
51172
51192
|
}
|
|
51173
51193
|
results.push(result);
|
|
51174
|
-
if (call.name === "read_file" &&
|
|
51194
|
+
if (call.name === "read_file" && isPlainObject(call.args) && typeof call.args.path === "string" && (result.status === "ok" || result.status === "duplicate")) {
|
|
51175
51195
|
const entry = { id: call.id, turn, path: call.args.path, ...rangeOf(call.args) };
|
|
51176
51196
|
const again = tracker.reread(entry, result.status === "duplicate", (id) => results.find((x) => x.id === id)?.output ?? outputOf(id), DROP_NOTES);
|
|
51177
51197
|
if (again) {
|
|
@@ -51182,7 +51202,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51182
51202
|
}
|
|
51183
51203
|
tracker.noteRead(entry);
|
|
51184
51204
|
}
|
|
51185
|
-
if (!noted && (WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" &&
|
|
51205
|
+
if (!noted && (WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" && isPlainObject(call.args) && typeof call.args.path === "string") {
|
|
51186
51206
|
tracker.noteWrite(call.args.path, turn);
|
|
51187
51207
|
}
|
|
51188
51208
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0) {
|
|
@@ -51190,15 +51210,15 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51190
51210
|
lastTestVersion = versionOfFiles(filesOnDisk());
|
|
51191
51211
|
}
|
|
51192
51212
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
|
|
51193
|
-
const file = result.output.scope === "file" &&
|
|
51213
|
+
const file = result.output.scope === "file" && isPlainObject(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
|
|
51194
51214
|
redRuns.push({ version: versionOfFiles(filesOnDisk()), ...file ? { file } : {}, failing: result.output.failingTests, truncated: result.output.truncated, answer: result.output });
|
|
51195
|
-
} else if (call.name === RUN_TESTS_TOOL && result.status === "no_report" && result.reason === "test_command_failed" &&
|
|
51215
|
+
} else if (call.name === RUN_TESTS_TOOL && result.status === "no_report" && result.reason === "test_command_failed" && isPlainObject(call.args) && typeof call.args.file === "string") {
|
|
51196
51216
|
redRuns.push({ version: versionOfFiles(filesOnDisk()), file: call.args.file, failing: [], truncated: false, fileFailed: true });
|
|
51197
51217
|
}
|
|
51198
51218
|
if (read) reads.push(read);
|
|
51199
51219
|
statusCounts[result.status] = (statusCounts[result.status] ?? 0) + 1;
|
|
51200
51220
|
const tool = TOOL_NAMES2.has(call.name) ? call.name : "unknown";
|
|
51201
|
-
const pathArg =
|
|
51221
|
+
const pathArg = isPlainObject(call.args) && typeof call.args.path === "string" && result.status !== "refused" ? { path: call.args.path } : {};
|
|
51202
51222
|
const rangeArg = call.name === "read_file" && result.status !== "refused" ? rangeOf(call.args) : {};
|
|
51203
51223
|
logged.push({ tool, status: result.status, ...result.reason && result.status !== "duplicate" ? { reason: result.reason } : {}, ...pathArg, ...rangeArg });
|
|
51204
51224
|
if (result.status === "refused" || result.status === "protected") {
|
|
@@ -51291,8 +51311,8 @@ function frozenFailingTarget(failingTests, frozen, textOf2) {
|
|
|
51291
51311
|
const file = fileOf(name2);
|
|
51292
51312
|
const candidates = frozen.filter((path) => idPlaceMatches(file, path));
|
|
51293
51313
|
if (candidates.length === 1) return { failing, amend: candidates[0] };
|
|
51294
|
-
const
|
|
51295
|
-
const testName = (
|
|
51314
|
+
const sep2 = name2.indexOf("::");
|
|
51315
|
+
const testName = (sep2 >= 0 ? name2.slice(sep2 + 2) : name2).replace(QP_TOKEN, "").trim();
|
|
51296
51316
|
const owners = candidates.filter((path) => definesTest(textOf2(path) ?? "", testName));
|
|
51297
51317
|
return { failing, amend: owners.length === 1 ? owners[0] : null };
|
|
51298
51318
|
}
|
|
@@ -51745,7 +51765,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
51745
51765
|
}
|
|
51746
51766
|
|
|
51747
51767
|
// src/langReach.ts
|
|
51748
|
-
var
|
|
51768
|
+
var import_node_path21 = require("node:path");
|
|
51749
51769
|
var LANGUAGE_BY_EXT = {
|
|
51750
51770
|
".go": "go",
|
|
51751
51771
|
".py": "python",
|
|
@@ -51761,7 +51781,7 @@ var LANGUAGE_BY_EXT = {
|
|
|
51761
51781
|
".swift": "swift"
|
|
51762
51782
|
};
|
|
51763
51783
|
function languageOf(path) {
|
|
51764
|
-
return LANGUAGE_BY_EXT[
|
|
51784
|
+
return LANGUAGE_BY_EXT[import_node_path21.posix.extname(path).toLowerCase()] ?? null;
|
|
51765
51785
|
}
|
|
51766
51786
|
var MAX_REACH_TESTS = 10;
|
|
51767
51787
|
var MAX_IMPORT_STEPS = 3;
|
|
@@ -51785,14 +51805,14 @@ function lookSymbolsOf(findings) {
|
|
|
51785
51805
|
for (const c of findings.callPath) add2(c.path, c.symbol);
|
|
51786
51806
|
return out2;
|
|
51787
51807
|
}
|
|
51788
|
-
var baseNoExt = (p) =>
|
|
51789
|
-
var dirOf = (p) =>
|
|
51808
|
+
var baseNoExt = (p) => import_node_path21.posix.basename(p).replace(/\.[^.]+$/, "");
|
|
51809
|
+
var dirOf = (p) => import_node_path21.posix.dirname(p) === "." ? "" : import_node_path21.posix.dirname(p);
|
|
51790
51810
|
function testStem(path) {
|
|
51791
51811
|
return baseNoExt(path).replace(/^test_/i, "").replace(/(_test|_spec)$/i, "").replace(/Tests?$/, "").toLowerCase();
|
|
51792
51812
|
}
|
|
51793
51813
|
function codeStem(path) {
|
|
51794
51814
|
const b = baseNoExt(path);
|
|
51795
|
-
if (b === "__init__" || b === "mod" || b === "index") return
|
|
51815
|
+
if (b === "__init__" || b === "mod" || b === "index") return import_node_path21.posix.basename(dirOf(path)).toLowerCase();
|
|
51796
51816
|
return b.toLowerCase();
|
|
51797
51817
|
}
|
|
51798
51818
|
function sharedPrefix2(a, b) {
|
|
@@ -51875,7 +51895,7 @@ function buildIndex(files, readText) {
|
|
|
51875
51895
|
}
|
|
51876
51896
|
}
|
|
51877
51897
|
let goModule = null;
|
|
51878
|
-
const gomod = files.filter((f) =>
|
|
51898
|
+
const gomod = files.filter((f) => import_node_path21.posix.basename(f) === "go.mod").sort((a, b) => a.length - b.length)[0];
|
|
51879
51899
|
if (gomod) {
|
|
51880
51900
|
const m = /^module[ \t]+(\S+)/m.exec(readText(gomod) ?? "");
|
|
51881
51901
|
if (m) goModule = { root: dirOf(gomod), module: m[1].replace(/^"|"$/g, "") };
|
|
@@ -51890,7 +51910,7 @@ function pythonImports(file, text3, ix) {
|
|
|
51890
51910
|
const relative14 = (dots, rest) => {
|
|
51891
51911
|
let base = dirOf(file);
|
|
51892
51912
|
for (let i3 = 1; i3 < dots; i3++) base = dirOf(base);
|
|
51893
|
-
const joined = rest ?
|
|
51913
|
+
const joined = rest ? import_node_path21.posix.join(base, rest.replace(/\./g, "/")) : base;
|
|
51894
51914
|
return [`${joined}.py`, `${joined}/__init__.py`].filter((p) => ix.set.has(p) && p !== file);
|
|
51895
51915
|
};
|
|
51896
51916
|
for (const line2 of text3.split("\n")) {
|
|
@@ -51930,7 +51950,7 @@ function goImports(file, text3, ix) {
|
|
|
51930
51950
|
let dir = null;
|
|
51931
51951
|
if (ix.goModule && (p === ix.goModule.module || p.startsWith(`${ix.goModule.module}/`))) {
|
|
51932
51952
|
const rest = p.slice(ix.goModule.module.length).replace(/^\//, "");
|
|
51933
|
-
dir = ix.goModule.root ?
|
|
51953
|
+
dir = ix.goModule.root ? import_node_path21.posix.join(ix.goModule.root, rest) : rest;
|
|
51934
51954
|
} else {
|
|
51935
51955
|
const tail2 = p.split("/").slice(-2).join("/");
|
|
51936
51956
|
for (const d of ix.byDir.keys()) if (d === tail2 || d.endsWith(`/${tail2}`)) {
|
|
@@ -51981,7 +52001,7 @@ function importsOf(language, file, text3, ix) {
|
|
|
51981
52001
|
if (language === "jvm") return jvmImports(file, text3, ix);
|
|
51982
52002
|
return [];
|
|
51983
52003
|
}
|
|
51984
|
-
var isPackageInit = (p) =>
|
|
52004
|
+
var isPackageInit = (p) => import_node_path21.posix.basename(p) === "__init__.py";
|
|
51985
52005
|
function testsReaching(input) {
|
|
51986
52006
|
const limit = Math.min(MAX_REACH_TESTS, Math.max(0, input.limit ?? MAX_REACH_TESTS));
|
|
51987
52007
|
const listing = input.isDenied ? input.listing.filter((p) => !input.isDenied(p)) : [...input.listing];
|
|
@@ -52701,75 +52721,73 @@ async function runCodegenStep(p) {
|
|
|
52701
52721
|
log({ event: "codegen.attempt_start", attempt: 1 });
|
|
52702
52722
|
const firstStarted = now();
|
|
52703
52723
|
let first = await attempt2();
|
|
52704
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.criteriaKey === true && p.criteriaWording) {
|
|
52705
|
-
log({ event: "codegen.version_fallback", from: "criteria_wording" });
|
|
52706
|
-
p.criteriaWording = void 0;
|
|
52707
|
-
const kept = "tests" in first ? first.tests : void 0;
|
|
52708
|
-
args2 = buildCodegenLoopArgs(p, context);
|
|
52709
|
-
first = await attempt2(void 0, 1, kept);
|
|
52710
|
-
}
|
|
52711
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.featureKey === true && p.featureTestUpdates === true) {
|
|
52712
|
-
log({ event: "codegen.version_fallback", from: "feature_test_updates" });
|
|
52713
|
-
p.featureTestUpdates = false;
|
|
52714
|
-
const kept = "tests" in first ? first.tests : void 0;
|
|
52715
|
-
args2 = buildCodegenLoopArgs(p, context);
|
|
52716
|
-
first = await attempt2(void 0, 1, kept);
|
|
52717
|
-
}
|
|
52718
52724
|
const databaseStop = (failure, why) => {
|
|
52719
52725
|
const stop2 = storedStop(p.databaseChange ?? []);
|
|
52720
52726
|
log({ event: "codegen.database_change_refused", ids: stop2.ids, ...why === "no_harness" ? { why } : {} });
|
|
52721
52727
|
p.out.loop = buildCodegenLoopRecord({ ...failure.summary ?? NO_SUMMARY, stopReason: "failed" });
|
|
52722
52728
|
return new PartsStopError(stop2);
|
|
52723
52729
|
};
|
|
52724
|
-
|
|
52725
|
-
|
|
52726
|
-
|
|
52727
|
-
|
|
52728
|
-
|
|
52729
|
-
p.
|
|
52730
|
-
|
|
52731
|
-
|
|
52732
|
-
|
|
52733
|
-
|
|
52734
|
-
|
|
52735
|
-
|
|
52736
|
-
|
|
52737
|
-
|
|
52738
|
-
|
|
52739
|
-
|
|
52740
|
-
|
|
52741
|
-
|
|
52742
|
-
|
|
52743
|
-
|
|
52744
|
-
|
|
52745
|
-
|
|
52746
|
-
|
|
52747
|
-
|
|
52748
|
-
|
|
52749
|
-
|
|
52750
|
-
|
|
52751
|
-
|
|
52752
|
-
|
|
52753
|
-
|
|
52754
|
-
|
|
52755
|
-
|
|
52756
|
-
|
|
52757
|
-
|
|
52758
|
-
|
|
52759
|
-
|
|
52760
|
-
|
|
52761
|
-
|
|
52762
|
-
|
|
52763
|
-
|
|
52764
|
-
|
|
52765
|
-
|
|
52766
|
-
|
|
52767
|
-
|
|
52768
|
-
|
|
52769
|
-
|
|
52770
|
-
|
|
52730
|
+
const notLate = (f) => f.late !== true;
|
|
52731
|
+
const FALLBACKS = [
|
|
52732
|
+
// QUIKTR-2509: `criteriaWording` first: asked the SAME version again without it, so an older AI Runtime never costs the run a version.
|
|
52733
|
+
{ when: (f) => f.criteriaKey === true && !!p.criteriaWording, kind: "retry", logged: () => ({ from: "criteria_wording" }), change: () => p.criteriaWording = void 0, from: "where_it_was" },
|
|
52734
|
+
// QUIKTR-2442: the same for `featureTestUpdates`, from where the attempt was (the tests phase is kept).
|
|
52735
|
+
{ when: (f) => f.featureKey === true && p.featureTestUpdates === true, kind: "retry", logged: () => ({ from: "feature_test_updates" }), change: () => p.featureTestUpdates = false, from: "where_it_was" },
|
|
52736
|
+
{ when: (f) => f.databaseKey === true && !!p.databaseChange && p.databaseChange.length > 0, kind: "stop", stop: (f) => databaseStop(f, "key_refused") },
|
|
52737
|
+
{ when: (f) => notLate(f) && !!p.runScratch && !!args2?.runScratch, kind: "retry", logged: () => ({ from: "codegen-loop-9", to: "codegen-loop-8" }), change: () => p.runScratch = void 0, from: "scratch" },
|
|
52738
|
+
{ when: (f) => notLate(f) && p.fixFirst === true && args2?.fixFirst === true, kind: "retry", logged: () => ({ from: "codegen-loop-8", to: "codegen-loop-7" }), change: () => p.fixFirst = false, from: "scratch" },
|
|
52739
|
+
{ when: (f) => notLate(f) && !!p.conflicts && !!args2?.conflicts, kind: "retry", logged: () => ({ from: "codegen-loop-7", to: "codegen-loop-6" }), change: () => p.conflicts = void 0, from: "scratch" },
|
|
52740
|
+
{
|
|
52741
|
+
when: (f) => notLate(f) && p.tools2?.notes === true && args2?.harness === true,
|
|
52742
|
+
kind: "retry",
|
|
52743
|
+
logged: () => ({ from: "codegen-loop-6", to: "codegen-loop-5" }),
|
|
52744
|
+
change: () => p.tools2 = { ...p.tools2, notes: false },
|
|
52745
|
+
from: "scratch"
|
|
52746
|
+
},
|
|
52747
|
+
{
|
|
52748
|
+
when: (f) => notLate(f) && !!p.tools2 && args2?.harness === true,
|
|
52749
|
+
kind: "retry",
|
|
52750
|
+
logged: () => ({ from: "codegen-loop-5", to: p.scope?.view === "map" ? "codegen-loop-4" : "codegen-loop-3" }),
|
|
52751
|
+
change: () => p.tools2 = void 0,
|
|
52752
|
+
from: "scratch"
|
|
52753
|
+
},
|
|
52754
|
+
{
|
|
52755
|
+
when: (f) => notLate(f) && p.scope?.view === "map",
|
|
52756
|
+
kind: "stop",
|
|
52757
|
+
stop: (f) => {
|
|
52758
|
+
const view = repoViewOf(p.scope);
|
|
52759
|
+
p.out.loop = buildCodegenLoopRecord({
|
|
52760
|
+
...f.summary ?? NO_SUMMARY,
|
|
52761
|
+
stopReason: "map_failed",
|
|
52762
|
+
...view ? { repoView: { ...view, failReason: "contract_rejected" } } : {}
|
|
52763
|
+
});
|
|
52764
|
+
log({ event: "codegen.map_failed", reason: "contract_rejected" });
|
|
52765
|
+
return new MapModeError("codegen", "contract_rejected");
|
|
52766
|
+
}
|
|
52767
|
+
},
|
|
52768
|
+
{
|
|
52769
|
+
when: (f) => notLate(f) && args2?.harness === true,
|
|
52770
|
+
kind: "retry",
|
|
52771
|
+
// QUIKTR-2445: below the harness the key cannot be carried (the tests phase never sends it, so its refusal can land here): the run stops as
|
|
52772
|
+
// it did before, rather than write code whose database change cannot be proposed.
|
|
52773
|
+
check: (f) => {
|
|
52774
|
+
if (p.databaseChange && p.databaseChange.length > 0) throw databaseStop(f, "no_harness");
|
|
52775
|
+
},
|
|
52776
|
+
logged: () => ({ from: "codegen-loop-3", to: "codegen-loop-2" }),
|
|
52777
|
+
// A fix attempt later in this run builds its request from the same parameters: it must not ask for loop-3 again either.
|
|
52778
|
+
change: () => p.harness = false,
|
|
52779
|
+
from: "scratch"
|
|
52780
|
+
}
|
|
52781
|
+
];
|
|
52782
|
+
for (const step of FALLBACKS) {
|
|
52783
|
+
if (!("failure" in first) || first.failure.reason !== "contract_rejected" || !step.when(first.failure)) continue;
|
|
52784
|
+
if (step.kind === "stop") throw step.stop(first.failure);
|
|
52785
|
+
step.check?.(first.failure);
|
|
52786
|
+
log({ event: "codegen.version_fallback", ...step.logged() });
|
|
52787
|
+
step.change();
|
|
52788
|
+
const kept = step.from === "where_it_was" && "tests" in first ? first.tests : void 0;
|
|
52771
52789
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52772
|
-
first = await attempt2();
|
|
52790
|
+
first = step.from === "where_it_was" ? await attempt2(void 0, 1, kept) : await attempt2();
|
|
52773
52791
|
}
|
|
52774
52792
|
const firstMs = now() - firstStarted;
|
|
52775
52793
|
if ("done" in first) {
|
|
@@ -53188,7 +53206,7 @@ async function runVerifyAndFix(p) {
|
|
|
53188
53206
|
// src/hunkCheck.ts
|
|
53189
53207
|
var import_node_child_process11 = require("node:child_process");
|
|
53190
53208
|
var import_node_fs19 = require("node:fs");
|
|
53191
|
-
var
|
|
53209
|
+
var import_node_path22 = require("node:path");
|
|
53192
53210
|
var MAX_REPORTED_HUNKS = 20;
|
|
53193
53211
|
function toFinding(r) {
|
|
53194
53212
|
if (r.unnecessary.length === 0) return void 0;
|
|
@@ -53266,7 +53284,7 @@ async function runHunkCheck(input) {
|
|
|
53266
53284
|
let slowestRunMs = input.baselineMs ?? 3e4;
|
|
53267
53285
|
const runOnce = async (c) => {
|
|
53268
53286
|
const reportBefore = findReport(input.root);
|
|
53269
|
-
const preserve = reportBefore ? [(0,
|
|
53287
|
+
const preserve = reportBefore ? [(0, import_node_path22.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
53270
53288
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
53271
53289
|
const startedWall = Date.now();
|
|
53272
53290
|
const startedAt = now();
|
|
@@ -53302,7 +53320,7 @@ async function runHunkCheck(input) {
|
|
|
53302
53320
|
};
|
|
53303
53321
|
const runRelated = async (c, plan, limitMs) => {
|
|
53304
53322
|
const reportBefore = findReport(input.root);
|
|
53305
|
-
const preserve = reportBefore ? [(0,
|
|
53323
|
+
const preserve = reportBefore ? [(0, import_node_path22.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
53306
53324
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
53307
53325
|
const startedAt = now();
|
|
53308
53326
|
result.relatedRuns += 1;
|
|
@@ -53447,7 +53465,7 @@ function healFailureSuffix(heal) {
|
|
|
53447
53465
|
|
|
53448
53466
|
// src/dependencyCheck.ts
|
|
53449
53467
|
var import_node_fs20 = require("node:fs");
|
|
53450
|
-
var
|
|
53468
|
+
var import_node_path23 = require("node:path");
|
|
53451
53469
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
53452
53470
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
53453
53471
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -53535,8 +53553,8 @@ function dependencyNames(pkg) {
|
|
|
53535
53553
|
]);
|
|
53536
53554
|
}
|
|
53537
53555
|
function readDeclaredDependencies(results, workspaceRoot) {
|
|
53538
|
-
const packageJsonPath = (0,
|
|
53539
|
-
const generated = results.find((r) => (0,
|
|
53556
|
+
const packageJsonPath = (0, import_node_path23.join)((0, import_node_path23.resolve)(workspaceRoot ?? "."), "package.json");
|
|
53557
|
+
const generated = results.find((r) => (0, import_node_path23.resolve)(r.targetPath) === packageJsonPath);
|
|
53540
53558
|
let raw;
|
|
53541
53559
|
if (generated) {
|
|
53542
53560
|
raw = generated.newContent;
|
|
@@ -53606,10 +53624,10 @@ function stripJsonComments(text3) {
|
|
|
53606
53624
|
return out2.replace(/,(\s*[}\]])/g, "$1");
|
|
53607
53625
|
}
|
|
53608
53626
|
function resolveAliasPrefixes(results, workspaceRoot) {
|
|
53609
|
-
const root = (0,
|
|
53627
|
+
const root = (0, import_node_path23.resolve)(workspaceRoot ?? ".");
|
|
53610
53628
|
for (const filename of ["tsconfig.json", "jsconfig.json"]) {
|
|
53611
|
-
const configPath = (0,
|
|
53612
|
-
const generated = results.find((r) => (0,
|
|
53629
|
+
const configPath = (0, import_node_path23.join)(root, filename);
|
|
53630
|
+
const generated = results.find((r) => (0, import_node_path23.resolve)(r.targetPath) === configPath);
|
|
53613
53631
|
let raw;
|
|
53614
53632
|
if (generated) {
|
|
53615
53633
|
raw = generated.newContent;
|
|
@@ -54012,7 +54030,7 @@ function describeVanishedTests(vanished) {
|
|
|
54012
54030
|
}
|
|
54013
54031
|
|
|
54014
54032
|
// src/verifyChange.ts
|
|
54015
|
-
var
|
|
54033
|
+
var import_node_path24 = require("node:path");
|
|
54016
54034
|
|
|
54017
54035
|
// src/packageUse.ts
|
|
54018
54036
|
var import_node_child_process13 = require("node:child_process");
|
|
@@ -54075,7 +54093,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
54075
54093
|
const depCheck = checkImportDependencies(results, readDeclaredDependencies(results, packet.workspaceRoot), resolveAliasPrefixes(results, packet.workspaceRoot), {
|
|
54076
54094
|
originalOf: (path) => {
|
|
54077
54095
|
try {
|
|
54078
|
-
return (0, import_node_fs22.readFileSync)((0,
|
|
54096
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path24.join)(cwd, path), "utf8");
|
|
54079
54097
|
} catch (err2) {
|
|
54080
54098
|
return err2.code === "ENOENT" ? "" : null;
|
|
54081
54099
|
}
|
|
@@ -54135,7 +54153,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
54135
54153
|
flushedAt = now();
|
|
54136
54154
|
if (undoable) {
|
|
54137
54155
|
const report = findJUnitReport(cwd);
|
|
54138
|
-
const ignore = report ? [(0,
|
|
54156
|
+
const ignore = report ? [(0, import_node_path24.relative)(cwd, report).split("\\").join("/")] : [];
|
|
54139
54157
|
const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
|
|
54140
54158
|
undo = () => flush.undo();
|
|
54141
54159
|
} else {
|
|
@@ -54249,7 +54267,7 @@ ${violations.join("\n")}`);
|
|
|
54249
54267
|
|
|
54250
54268
|
// src/run.ts
|
|
54251
54269
|
var import_node_fs27 = require("node:fs");
|
|
54252
|
-
var
|
|
54270
|
+
var import_node_path30 = require("node:path");
|
|
54253
54271
|
|
|
54254
54272
|
// src/mapMode.ts
|
|
54255
54273
|
var MAP_ENV = "QUIKPILOT_MAP";
|
|
@@ -54307,7 +54325,7 @@ function buildToolsV2Env(i3) {
|
|
|
54307
54325
|
}
|
|
54308
54326
|
|
|
54309
54327
|
// src/repoMap.ts
|
|
54310
|
-
var
|
|
54328
|
+
var import_node_path25 = require("node:path");
|
|
54311
54329
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
54312
54330
|
var MAX_FOLDERS = 200;
|
|
54313
54331
|
var MAX_LANGUAGES = 12;
|
|
@@ -54349,7 +54367,7 @@ function guidanceFiles(i3, perFile2, total) {
|
|
|
54349
54367
|
function languages2(listing) {
|
|
54350
54368
|
const counts = /* @__PURE__ */ new Map();
|
|
54351
54369
|
for (const p of listing) {
|
|
54352
|
-
const ext =
|
|
54370
|
+
const ext = import_node_path25.posix.extname(p).toLowerCase();
|
|
54353
54371
|
if (ext && ext.length <= 12) counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
54354
54372
|
}
|
|
54355
54373
|
return [...counts.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, MAX_LANGUAGES).map(([ext, n]) => `${ext} ${n}`);
|
|
@@ -54365,7 +54383,7 @@ function testFacts(i3) {
|
|
|
54365
54383
|
const depth = i3.writeRoot === "" ? 0 : i3.writeRoot.split("/").length;
|
|
54366
54384
|
for (const t of tests) {
|
|
54367
54385
|
const parts2 = t.split("/");
|
|
54368
|
-
const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") :
|
|
54386
|
+
const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") : import_node_path25.posix.dirname(t);
|
|
54369
54387
|
byFolder.set(folder, (byFolder.get(folder) ?? 0) + 1);
|
|
54370
54388
|
}
|
|
54371
54389
|
for (const [folder, n] of [...byFolder.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 3)) {
|
|
@@ -54475,7 +54493,7 @@ function buildRepoMap(i3) {
|
|
|
54475
54493
|
}
|
|
54476
54494
|
|
|
54477
54495
|
// src/workspacePackages.ts
|
|
54478
|
-
var
|
|
54496
|
+
var import_node_path26 = require("node:path");
|
|
54479
54497
|
var MAX_READ_ROOTS = 8;
|
|
54480
54498
|
function isObject2(x) {
|
|
54481
54499
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -54537,8 +54555,8 @@ function workspacePackages(readText, packageJsonPaths) {
|
|
|
54537
54555
|
const exclude = patterns.filter((p) => p.startsWith("!")).map((p) => globMatcher(p.slice(1)));
|
|
54538
54556
|
const out2 = [];
|
|
54539
54557
|
for (const file of packageJsonPaths) {
|
|
54540
|
-
if (
|
|
54541
|
-
const folder =
|
|
54558
|
+
if (import_node_path26.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
|
|
54559
|
+
const folder = import_node_path26.posix.dirname(file);
|
|
54542
54560
|
if (!include.some((re) => re.test(folder)) || exclude.some((re) => re.test(folder))) continue;
|
|
54543
54561
|
const text3 = readText(file);
|
|
54544
54562
|
const json = text3 === null ? null : parseJsonc(text3);
|
|
@@ -54653,10 +54671,10 @@ function resolveTargetingMode(env2 = process.env, packetSetting) {
|
|
|
54653
54671
|
|
|
54654
54672
|
// src/installationToken.ts
|
|
54655
54673
|
async function exchangeForInstallationToken(installationTokenUrl, runToken) {
|
|
54656
|
-
const res = await
|
|
54674
|
+
const res = await fetchWithin("The push token exchange", installationTokenUrl, {
|
|
54657
54675
|
method: "POST",
|
|
54658
54676
|
headers: { Authorization: `Bearer ${runToken}` }
|
|
54659
|
-
});
|
|
54677
|
+
}, SHORT_CALL_MS);
|
|
54660
54678
|
if (!res.ok) {
|
|
54661
54679
|
throw new Error(`Exchange installation token failed: ${await describeQuikTrackFailure(res)}`);
|
|
54662
54680
|
}
|
|
@@ -54680,9 +54698,9 @@ async function fetchGithubOidcToken(env2 = process.env) {
|
|
|
54680
54698
|
);
|
|
54681
54699
|
const separator = requestUrl.includes("?") ? "&" : "?";
|
|
54682
54700
|
const url = `${requestUrl}${separator}audience=${encodeURIComponent(QUIKPILOT_OIDC_AUDIENCE)}`;
|
|
54683
|
-
const res = await
|
|
54701
|
+
const res = await fetchWithin("The GitHub sign-in token request", url, {
|
|
54684
54702
|
headers: { Authorization: `Bearer ${requestToken}` }
|
|
54685
|
-
});
|
|
54703
|
+
}, SHORT_CALL_MS);
|
|
54686
54704
|
if (!res.ok) {
|
|
54687
54705
|
throw new Error(`Fetch GitHub OIDC token failed: ${res.status} ${res.statusText}`);
|
|
54688
54706
|
}
|
|
@@ -54794,9 +54812,9 @@ function describeOverlapWarnings(warnings) {
|
|
|
54794
54812
|
// src/packet.ts
|
|
54795
54813
|
async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
54796
54814
|
const url = `${packetUrl}?githubRunId=${encodeURIComponent(githubRunId)}`;
|
|
54797
|
-
const res = await
|
|
54815
|
+
const res = await fetchWithin("The work packet request", url, {
|
|
54798
54816
|
headers: { Authorization: `Bearer ${runToken}` }
|
|
54799
|
-
});
|
|
54817
|
+
}, SHORT_CALL_MS);
|
|
54800
54818
|
if (!res.ok) {
|
|
54801
54819
|
throw new Error(`Fetch work packet failed: ${await describeQuikTrackFailure(res)}`);
|
|
54802
54820
|
}
|
|
@@ -54804,8 +54822,31 @@ async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
|
54804
54822
|
if (body2.success !== true) {
|
|
54805
54823
|
throw new Error("Fetch work packet failed: response did not carry success:true");
|
|
54806
54824
|
}
|
|
54825
|
+
const wrong = packetShapeProblem(body2.data);
|
|
54826
|
+
if (wrong) throw new Error(`Fetch work packet failed: the packet is not the shape the runner expects (${wrong})`);
|
|
54807
54827
|
return body2.data;
|
|
54808
54828
|
}
|
|
54829
|
+
var isStringOrNull = (x) => x === void 0 || x === null || typeof x === "string";
|
|
54830
|
+
var isFiniteNumber = (x) => typeof x === "number" && Number.isFinite(x);
|
|
54831
|
+
function packetShapeProblem(data2) {
|
|
54832
|
+
if (typeof data2 !== "object" || data2 === null) return "data";
|
|
54833
|
+
const d = data2;
|
|
54834
|
+
const commands = d.commands;
|
|
54835
|
+
if (typeof commands !== "object" || commands === null) return "commands";
|
|
54836
|
+
for (const key of ["setup", "test", "lint", "format", "testFile", "e2e"]) if (!isStringOrNull(commands[key])) return `commands.${key}`;
|
|
54837
|
+
const guardrails = d.guardrails;
|
|
54838
|
+
if (typeof guardrails !== "object" || guardrails === null) return "guardrails";
|
|
54839
|
+
if (!Array.isArray(guardrails.deniedPaths) || !guardrails.deniedPaths.every((p) => typeof p === "string")) return "guardrails.deniedPaths";
|
|
54840
|
+
if (!isFiniteNumber(guardrails.maxWallClockMinutes)) return "guardrails.maxWallClockMinutes";
|
|
54841
|
+
if (!isFiniteNumber(guardrails.maxHealIterations)) return "guardrails.maxHealIterations";
|
|
54842
|
+
const gateway = d.gateway;
|
|
54843
|
+
if (typeof gateway !== "object" || gateway === null) return "gateway";
|
|
54844
|
+
if (typeof gateway.baseUrl !== "string") return "gateway.baseUrl";
|
|
54845
|
+
if (typeof gateway.token !== "string") return "gateway.token";
|
|
54846
|
+
if (!isStringOrNull(d.branch)) return "branch";
|
|
54847
|
+
if (!isStringOrNull(d.targetBranch)) return "targetBranch";
|
|
54848
|
+
return null;
|
|
54849
|
+
}
|
|
54809
54850
|
|
|
54810
54851
|
// src/runnerSwitches.ts
|
|
54811
54852
|
var RUNNER_SWITCHES = {
|
|
@@ -54862,17 +54903,17 @@ function writePhase0Marker(runId) {
|
|
|
54862
54903
|
// src/failureArtifact.ts
|
|
54863
54904
|
var import_node_child_process14 = require("node:child_process");
|
|
54864
54905
|
var import_node_fs24 = require("node:fs");
|
|
54865
|
-
var
|
|
54906
|
+
var import_node_path27 = require("node:path");
|
|
54866
54907
|
var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
54867
54908
|
var REPORT_COPY = "final-test-report.xml";
|
|
54868
54909
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
54869
54910
|
var MAX_FILES = 200;
|
|
54870
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
54911
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.92" : "dev";
|
|
54871
54912
|
function safeDestination(base, repoPath) {
|
|
54872
|
-
if (!repoPath || (0,
|
|
54873
|
-
const destination = (0,
|
|
54874
|
-
const rel = (0,
|
|
54875
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
54913
|
+
if (!repoPath || (0, import_node_path27.isAbsolute)(repoPath)) return null;
|
|
54914
|
+
const destination = (0, import_node_path27.resolve)(base, repoPath);
|
|
54915
|
+
const rel = (0, import_node_path27.relative)(base, destination);
|
|
54916
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path27.isAbsolute)(rel)) return null;
|
|
54876
54917
|
return destination;
|
|
54877
54918
|
}
|
|
54878
54919
|
var BUNDLE_FILE = "quikpilot-change.bundle";
|
|
@@ -54882,7 +54923,7 @@ function keepCommitBundle(repo, folder, branch) {
|
|
|
54882
54923
|
if (git4(["rev-parse", "--abbrev-ref", "HEAD"]) !== branch) return null;
|
|
54883
54924
|
if (git4(["diff", "--name-only", "HEAD~1", "HEAD"]) === "") return null;
|
|
54884
54925
|
const commit2 = git4(["rev-parse", "HEAD"]);
|
|
54885
|
-
const file = (0,
|
|
54926
|
+
const file = (0, import_node_path27.join)(folder, BUNDLE_FILE);
|
|
54886
54927
|
git4(["bundle", "create", file, "HEAD", "^HEAD~1"]);
|
|
54887
54928
|
let verified = true;
|
|
54888
54929
|
try {
|
|
@@ -54898,7 +54939,7 @@ function keepCommitBundle(repo, folder, branch) {
|
|
|
54898
54939
|
function writeFailureArtifact(input) {
|
|
54899
54940
|
if (input.results.length === 0) return { written: false };
|
|
54900
54941
|
try {
|
|
54901
|
-
const base = (0,
|
|
54942
|
+
const base = (0, import_node_path27.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
54902
54943
|
(0, import_node_fs24.rmSync)(base, { recursive: true, force: true });
|
|
54903
54944
|
(0, import_node_fs24.mkdirSync)(base, { recursive: true });
|
|
54904
54945
|
const files = [];
|
|
@@ -54909,7 +54950,7 @@ function writeFailureArtifact(input) {
|
|
|
54909
54950
|
skipped.push(result.targetPath);
|
|
54910
54951
|
continue;
|
|
54911
54952
|
}
|
|
54912
|
-
(0, import_node_fs24.mkdirSync)((0,
|
|
54953
|
+
(0, import_node_fs24.mkdirSync)((0, import_node_path27.dirname)(destination), { recursive: true });
|
|
54913
54954
|
(0, import_node_fs24.writeFileSync)(destination, result.newContent);
|
|
54914
54955
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
54915
54956
|
}
|
|
@@ -54918,7 +54959,7 @@ function writeFailureArtifact(input) {
|
|
|
54918
54959
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
54919
54960
|
testReport = "too-large";
|
|
54920
54961
|
} else {
|
|
54921
|
-
(0, import_node_fs24.writeFileSync)((0,
|
|
54962
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path27.join)(base, REPORT_COPY), input.testReport);
|
|
54922
54963
|
testReport = "included";
|
|
54923
54964
|
}
|
|
54924
54965
|
}
|
|
@@ -54940,8 +54981,8 @@ function writeFailureArtifact(input) {
|
|
|
54940
54981
|
bundle
|
|
54941
54982
|
};
|
|
54942
54983
|
const text3 = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
|
|
54943
|
-
(0, import_node_fs24.writeFileSync)((0,
|
|
54944
|
-
return { written: (0, import_node_fs24.existsSync)((0,
|
|
54984
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path27.join)(base, "manifest.json"), text3);
|
|
54985
|
+
return { written: (0, import_node_fs24.existsSync)((0, import_node_path27.join)(base, "manifest.json")) };
|
|
54945
54986
|
} catch (err2) {
|
|
54946
54987
|
console.warn(`::warning::Could not keep the failed run's files: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
54947
54988
|
return { written: false };
|
|
@@ -54951,7 +54992,7 @@ function writeFailureArtifact(input) {
|
|
|
54951
54992
|
// src/finalChange.ts
|
|
54952
54993
|
var import_node_child_process15 = require("node:child_process");
|
|
54953
54994
|
var import_node_fs25 = require("node:fs");
|
|
54954
|
-
var
|
|
54995
|
+
var import_node_path28 = require("node:path");
|
|
54955
54996
|
function statusPaths(root) {
|
|
54956
54997
|
const status = (0, import_node_child_process15.execFileSync)("git", [...NO_HOOKS_ARGS, "status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
|
|
54957
54998
|
env: gitEnv(),
|
|
@@ -54965,7 +55006,7 @@ function statusPaths(root) {
|
|
|
54965
55006
|
}
|
|
54966
55007
|
var isFileOnDisk = (root, path) => {
|
|
54967
55008
|
try {
|
|
54968
|
-
return (0, import_node_fs25.statSync)((0,
|
|
55009
|
+
return (0, import_node_fs25.statSync)((0, import_node_path28.join)(root, path)).isFile();
|
|
54969
55010
|
} catch {
|
|
54970
55011
|
return false;
|
|
54971
55012
|
}
|
|
@@ -54987,7 +55028,7 @@ function allChangesAgainstBase(root) {
|
|
|
54987
55028
|
// src/nameEvidence.ts
|
|
54988
55029
|
var import_node_child_process16 = require("node:child_process");
|
|
54989
55030
|
var import_node_fs26 = require("node:fs");
|
|
54990
|
-
var
|
|
55031
|
+
var import_node_path29 = require("node:path");
|
|
54991
55032
|
|
|
54992
55033
|
// src/migrationNames.ts
|
|
54993
55034
|
var PART = String.raw`(?:"[^"]+"|\x60[^\x60]+\x60|\[[^\]]+\]|[\w$]+)`;
|
|
@@ -55067,7 +55108,7 @@ function filesNaming(word, ev, readable, denied) {
|
|
|
55067
55108
|
}
|
|
55068
55109
|
function fileHasWord(cwd, file, word) {
|
|
55069
55110
|
try {
|
|
55070
|
-
const path = (0,
|
|
55111
|
+
const path = (0, import_node_path29.join)(cwd, file);
|
|
55071
55112
|
if ((0, import_node_fs26.statSync)(path).size > MAX_FILE_BYTES2) return false;
|
|
55072
55113
|
return new RegExp(`(?<![\\w$])${escapeRegExp5(word)}(?![\\w$])`).test((0, import_node_fs26.readFileSync)(path, "utf8"));
|
|
55073
55114
|
} catch {
|
|
@@ -55256,8 +55297,8 @@ async function resolveTestDiscovery(i3) {
|
|
|
55256
55297
|
};
|
|
55257
55298
|
if (!i3.command || i3.command.trim().length === 0) return done(buildTestDiscovery({ ...base, snapshot: null }));
|
|
55258
55299
|
let timer;
|
|
55259
|
-
const timeout = new Promise((
|
|
55260
|
-
timer = setTimeout(() =>
|
|
55300
|
+
const timeout = new Promise((resolve6) => {
|
|
55301
|
+
timer = setTimeout(() => resolve6("timeout"), i3.waitMs);
|
|
55261
55302
|
});
|
|
55262
55303
|
const settled = i3.baseline.then(
|
|
55263
55304
|
(b) => b.snapshot,
|
|
@@ -55278,12 +55319,11 @@ async function resolveTestDiscovery(i3) {
|
|
|
55278
55319
|
}
|
|
55279
55320
|
|
|
55280
55321
|
// src/targetingFindings.ts
|
|
55281
|
-
var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55282
55322
|
function prepareTargetingFindings(raw, listing, deniedPaths) {
|
|
55283
|
-
if (!
|
|
55323
|
+
if (!isPlainObject(raw)) return void 0;
|
|
55284
55324
|
const { verdict, files, callPath, evidence, searches } = raw;
|
|
55285
55325
|
if (typeof verdict !== "string" || !Array.isArray(files) || !Array.isArray(callPath) || !Array.isArray(evidence)) return void 0;
|
|
55286
|
-
const keep = (entry) =>
|
|
55326
|
+
const keep = (entry) => isPlainObject(entry) && typeof entry.path === "string" && listing.has(entry.path) && matchesDeniedPath(entry.path, deniedPaths) === null;
|
|
55287
55327
|
const kept = {
|
|
55288
55328
|
files: files.filter(keep),
|
|
55289
55329
|
callPath: callPath.filter(keep),
|
|
@@ -55422,20 +55462,22 @@ function finalizeTargeting(body2, workspaceRoot, workspaceListing, deniedPaths)
|
|
|
55422
55462
|
}
|
|
55423
55463
|
async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false, storedProposals = false, ticketHints) {
|
|
55424
55464
|
const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
|
|
55425
|
-
let envelope = await postTargeting(gateway, contextData);
|
|
55465
|
+
let envelope = await postTargeting(gateway, contextData, AbortSignal.timeout(LONG_CALL_MS));
|
|
55426
55466
|
let warnings;
|
|
55427
55467
|
const refused2 = () => envelope?.errorCode === "CONTRACT_REJECTED";
|
|
55428
55468
|
if (ticketHints && refused2()) {
|
|
55429
55469
|
envelope = await postTargeting(
|
|
55430
55470
|
gateway,
|
|
55431
|
-
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals)
|
|
55471
|
+
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals),
|
|
55472
|
+
AbortSignal.timeout(LONG_CALL_MS)
|
|
55432
55473
|
);
|
|
55433
55474
|
warnings = [TICKET_HINTS_REFUSED_WARNING];
|
|
55434
55475
|
}
|
|
55435
55476
|
if (findings && refused2()) {
|
|
55436
55477
|
envelope = await postTargeting(
|
|
55437
55478
|
gateway,
|
|
55438
|
-
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck, storedProposals)
|
|
55479
|
+
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck, storedProposals),
|
|
55480
|
+
AbortSignal.timeout(LONG_CALL_MS)
|
|
55439
55481
|
);
|
|
55440
55482
|
warnings = [...warnings ?? [], "QuikPilot's targeting ran without the early look's findings (the AI service did not accept them)."];
|
|
55441
55483
|
}
|
|
@@ -55636,7 +55678,7 @@ var MAX_SKIPPED_CONTEXT = 20;
|
|
|
55636
55678
|
var MAX_SKIPPED_CASES = 200;
|
|
55637
55679
|
var MAX_CONTEXT_RECORDS = 25;
|
|
55638
55680
|
var MAX_PATH_CHARS6 = 300;
|
|
55639
|
-
var
|
|
55681
|
+
var MAX_ID_CHARS2 = 100;
|
|
55640
55682
|
var MAX_REASON_CHARS3 = 300;
|
|
55641
55683
|
var MAX_LOOP_READS = 50;
|
|
55642
55684
|
var MAX_FALLBACK_REASON_CHARS = 40;
|
|
@@ -55725,7 +55767,7 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
55725
55767
|
continue;
|
|
55726
55768
|
}
|
|
55727
55769
|
const contextPaths = clampList(t.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS6);
|
|
55728
|
-
const automationIds = clampList(t.automationIds, MAX_IDS_PER_TARGET,
|
|
55770
|
+
const automationIds = clampList(t.automationIds, MAX_IDS_PER_TARGET, MAX_ID_CHARS2);
|
|
55729
55771
|
note(contextPaths.cut);
|
|
55730
55772
|
note(automationIds.cut);
|
|
55731
55773
|
targets.push({ path, kind: t.kind, contextPaths: contextPaths.kept, automationIds: automationIds.kept });
|
|
@@ -55733,7 +55775,7 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
55733
55775
|
const skipped = clampList(
|
|
55734
55776
|
(targeting.skippedCases ?? []).map((c) => c.automationId),
|
|
55735
55777
|
MAX_SKIPPED_CASES,
|
|
55736
|
-
|
|
55778
|
+
MAX_ID_CHARS2
|
|
55737
55779
|
);
|
|
55738
55780
|
note(skipped.cut);
|
|
55739
55781
|
const codegenContext = [];
|
|
@@ -55779,10 +55821,10 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
55779
55821
|
|
|
55780
55822
|
// src/tokenExchange.ts
|
|
55781
55823
|
async function exchangeForRunToken(tokenUrl, oidcToken) {
|
|
55782
|
-
const res = await
|
|
55824
|
+
const res = await fetchWithin("The run token exchange", tokenUrl, {
|
|
55783
55825
|
method: "POST",
|
|
55784
55826
|
headers: { Authorization: `Bearer ${oidcToken}` }
|
|
55785
|
-
});
|
|
55827
|
+
}, SHORT_CALL_MS);
|
|
55786
55828
|
if (!res.ok) {
|
|
55787
55829
|
throw new Error(`Exchange run token failed: ${await describeQuikTrackFailure(res)}`);
|
|
55788
55830
|
}
|
|
@@ -55915,6 +55957,10 @@ async function runUnderGuard(env2, guard) {
|
|
|
55915
55957
|
}
|
|
55916
55958
|
jobStopAtMs = runStopAtMs(runStartedAt, packet.guardrails.maxWallClockMinutes);
|
|
55917
55959
|
guard.arm({ stopAtMs: jobStopAtMs, watchdogAtMs: watchdogAtMs(jobStopAtMs), send: lastResort });
|
|
55960
|
+
for (const [label, name2] of [["branch", packet.branch], ["target branch", packet.targetBranch]]) {
|
|
55961
|
+
const why = typeof name2 === "string" ? checkBranchName(name2) : null;
|
|
55962
|
+
if (why) throw new Error(`QuikProjects sent a ${label} name git cannot use safely (${why}), so QuikPilot did not start. Nothing was changed.`);
|
|
55963
|
+
}
|
|
55918
55964
|
checkoutTargetBranch(packet.targetBranch);
|
|
55919
55965
|
const writeRoot = normaliseWorkspaceRoot(packet.workspaceRoot);
|
|
55920
55966
|
scopeRoot = writeRoot;
|
|
@@ -56247,7 +56293,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56247
56293
|
};
|
|
56248
56294
|
const healCalls = [];
|
|
56249
56295
|
let healStop;
|
|
56250
|
-
const testCommand = packet.commands.test;
|
|
56296
|
+
const testCommand = packet.commands.test ?? "";
|
|
56251
56297
|
const reviewPlanner = createRelatedPlanner({
|
|
56252
56298
|
root: process.cwd(),
|
|
56253
56299
|
command: testCommand,
|
|
@@ -56258,7 +56304,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56258
56304
|
log: (e) => console.log(JSON.stringify(e))
|
|
56259
56305
|
});
|
|
56260
56306
|
const hunkCheckOver = async (changed, testCount) => {
|
|
56261
|
-
if (codegenMode !== "loop-tests" || process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() === "off") return null;
|
|
56307
|
+
if (codegenMode !== "loop-tests" || testCommand.trim() === "" || process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() === "off") return null;
|
|
56262
56308
|
const deadlineAtMs = Math.min(jobStopAtMs - HUNK_CHECK_END_BEFORE_STOP_MS, Date.now() + HUNK_CHECK_MAX_MS);
|
|
56263
56309
|
if (deadlineAtMs - Date.now() < HUNK_CHECK_MIN_BUDGET_MS) return null;
|
|
56264
56310
|
const files = collectHunkCheckFiles(changed, process.cwd());
|
|
@@ -56278,10 +56324,12 @@ async function runUnderGuard(env2, guard) {
|
|
|
56278
56324
|
};
|
|
56279
56325
|
const reviewOn = process.env.QUIKPILOT_REVIEW_FIX?.trim().toLowerCase() !== "off";
|
|
56280
56326
|
let fixed2;
|
|
56327
|
+
const healAttemptsRun = codegenOut.loop?.attempts?.length ?? 1;
|
|
56328
|
+
const healAllowed = healAllowance(packet.guardrails.maxHealIterations, healAttemptsRun, 0, codegenMode);
|
|
56281
56329
|
try {
|
|
56282
56330
|
fixed2 = await runVerifyAndFix({
|
|
56283
56331
|
firstResults: results,
|
|
56284
|
-
attemptsRun:
|
|
56332
|
+
attemptsRun: healAttemptsRun,
|
|
56285
56333
|
mode: codegenMode,
|
|
56286
56334
|
setting: packet.guardrails.maxHealIterations,
|
|
56287
56335
|
now: Date.now,
|
|
@@ -56296,7 +56344,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56296
56344
|
return {
|
|
56297
56345
|
putBack: () => {
|
|
56298
56346
|
const report = findJUnitReport(cwd);
|
|
56299
|
-
const ignore = report ? [(0,
|
|
56347
|
+
const ignore = report ? [(0, import_node_path30.relative)(cwd, report).split("\\").join("/")] : [];
|
|
56300
56348
|
return undoableFlush(cwd, onDisk, flushCodegenResults, { ignore }).undo;
|
|
56301
56349
|
}
|
|
56302
56350
|
};
|
|
@@ -56333,7 +56381,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56333
56381
|
}
|
|
56334
56382
|
});
|
|
56335
56383
|
} catch (err2) {
|
|
56336
|
-
if (healStop && codegenOut.loop) codegenOut.loop = mergeHealRecord(codegenOut.loop, { stop: healStop, allowed:
|
|
56384
|
+
if (healStop && codegenOut.loop) codegenOut.loop = mergeHealRecord(codegenOut.loop, { stop: healStop, allowed: healAllowed, made: Math.min(healCalls.length, healAllowed), attempts: [] }, healCalls);
|
|
56337
56385
|
throw err2;
|
|
56338
56386
|
}
|
|
56339
56387
|
generatedResults = fixed2.results;
|
|
@@ -56506,6 +56554,11 @@ async function runUnderGuard(env2, guard) {
|
|
|
56506
56554
|
packet.issueKey,
|
|
56507
56555
|
packet.issueTitle
|
|
56508
56556
|
);
|
|
56557
|
+
if (targeted && !result.changed) {
|
|
56558
|
+
throw new Error(
|
|
56559
|
+
"QuikPilot's change left nothing to commit: the files it wrote are the same as before (or were left out of the change), so no pull request was opened."
|
|
56560
|
+
);
|
|
56561
|
+
}
|
|
56509
56562
|
branch = result.branch;
|
|
56510
56563
|
} catch (err2) {
|
|
56511
56564
|
hardFailure = true;
|
|
@@ -56535,6 +56588,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56535
56588
|
}
|
|
56536
56589
|
|
|
56537
56590
|
// src/readinessCheck.ts
|
|
56591
|
+
var import_node_path31 = require("node:path");
|
|
56538
56592
|
async function runReadinessCheck(env2) {
|
|
56539
56593
|
let setupOk = true;
|
|
56540
56594
|
try {
|
|
@@ -56545,7 +56599,8 @@ async function runReadinessCheck(env2) {
|
|
|
56545
56599
|
}
|
|
56546
56600
|
const testOutcome = runTestCommand(env2.testCmd);
|
|
56547
56601
|
const testOk = testOutcome === "success";
|
|
56548
|
-
const
|
|
56602
|
+
const found = findJUnitReport();
|
|
56603
|
+
const junitPath = found === null ? null : (0, import_node_path31.relative)(process.cwd(), found).split(import_node_path31.sep).join("/");
|
|
56549
56604
|
const result = {
|
|
56550
56605
|
setupOk,
|
|
56551
56606
|
testOk,
|
|
@@ -56553,11 +56608,11 @@ async function runReadinessCheck(env2) {
|
|
|
56553
56608
|
junitPath
|
|
56554
56609
|
};
|
|
56555
56610
|
try {
|
|
56556
|
-
const res = await
|
|
56611
|
+
const res = await fetchWithin("The readiness report", env2.readinessCallbackUrl, {
|
|
56557
56612
|
method: "POST",
|
|
56558
56613
|
headers: { Authorization: `Bearer ${env2.readinessToken}`, "Content-Type": "application/json" },
|
|
56559
56614
|
body: JSON.stringify(result)
|
|
56560
|
-
});
|
|
56615
|
+
}, SHORT_CALL_MS);
|
|
56561
56616
|
if (!res.ok) {
|
|
56562
56617
|
throw new Error(`Readiness callback POST failed: ${await describeQuikTrackFailure(res)}`);
|
|
56563
56618
|
}
|
|
@@ -56565,6 +56620,7 @@ async function runReadinessCheck(env2) {
|
|
|
56565
56620
|
console.warn(
|
|
56566
56621
|
`::warning::QuikPilot readiness check failed to report its result: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
56567
56622
|
);
|
|
56623
|
+
throw err2;
|
|
56568
56624
|
}
|
|
56569
56625
|
}
|
|
56570
56626
|
|
|
@@ -56627,9 +56683,6 @@ var EvidenceLedger = class {
|
|
|
56627
56683
|
return seen;
|
|
56628
56684
|
}
|
|
56629
56685
|
};
|
|
56630
|
-
function isRecord7(x) {
|
|
56631
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
56632
|
-
}
|
|
56633
56686
|
function arrayOf(x) {
|
|
56634
56687
|
return Array.isArray(x) ? x : [];
|
|
56635
56688
|
}
|
|
@@ -56665,7 +56718,7 @@ function capFindingsSize(findings, max = MAX_FINDINGS_CHARS) {
|
|
|
56665
56718
|
function verifyFindings(raw, ledger, ctx) {
|
|
56666
56719
|
const dropped = emptyDropped();
|
|
56667
56720
|
const redactions = emptyRedactionCounts();
|
|
56668
|
-
if (!
|
|
56721
|
+
if (!isPlainObject(raw)) return { findings: emptyFindings(), downgraded: false, dropped, redactions };
|
|
56669
56722
|
const pathOk2 = (p) => typeof p === "string" && ctx.listing.has(p) && matchesDeniedPath(p, ctx.deniedPaths) === null;
|
|
56670
56723
|
const symbolsOf = (path, list2) => {
|
|
56671
56724
|
const out2 = [];
|
|
@@ -56680,7 +56733,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
56680
56733
|
};
|
|
56681
56734
|
const files = [];
|
|
56682
56735
|
for (const f of arrayOf(raw.files)) {
|
|
56683
|
-
if (!
|
|
56736
|
+
if (!isPlainObject(f) || !pathOk2(f.path)) {
|
|
56684
56737
|
dropped.files += 1;
|
|
56685
56738
|
continue;
|
|
56686
56739
|
}
|
|
@@ -56690,7 +56743,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
56690
56743
|
}
|
|
56691
56744
|
const callPath = [];
|
|
56692
56745
|
for (const s of arrayOf(raw.callPath)) {
|
|
56693
|
-
const ok =
|
|
56746
|
+
const ok = isPlainObject(s) && pathOk2(s.path) && typeof s.symbol === "string" && s.symbol.length > 0 && s.symbol.length <= MAX_SYMBOL_CHARS && isLine2(s.line) && ledger.hasLines(s.path, s.line, s.line) && ledger.textContains(s.path, s.symbol);
|
|
56694
56747
|
if (!ok) {
|
|
56695
56748
|
dropped.callPath += 1;
|
|
56696
56749
|
continue;
|
|
@@ -56699,7 +56752,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
56699
56752
|
}
|
|
56700
56753
|
const evidence = [];
|
|
56701
56754
|
for (const e of arrayOf(raw.evidence)) {
|
|
56702
|
-
const ok =
|
|
56755
|
+
const ok = isPlainObject(e) && pathOk2(e.path) && isLine2(e.startLine) && isLine2(e.endLine) && e.startLine <= e.endLine && e.endLine - e.startLine + 1 <= MAX_EVIDENCE_LINES && ledger.hasLines(e.path, e.startLine, e.endLine);
|
|
56703
56756
|
if (!ok) {
|
|
56704
56757
|
dropped.evidence += 1;
|
|
56705
56758
|
continue;
|
|
@@ -56759,25 +56812,9 @@ var InvestigateFailure = class extends Error {
|
|
|
56759
56812
|
}
|
|
56760
56813
|
};
|
|
56761
56814
|
var TOOL_NAMES3 = /* @__PURE__ */ new Set(["list_files", "read_file", "grep"]);
|
|
56762
|
-
var MAX_ID_CHARS4 = 64;
|
|
56763
|
-
var MAX_CALLS_IN_A_REPLY3 = 50;
|
|
56764
|
-
var MAX_ARGS_JSON_CHARS2 = 1e3;
|
|
56765
56815
|
var SWITCH_OFF_SENTENCE = "is not enabled on this runtime";
|
|
56766
|
-
function isPlainObject4(x) {
|
|
56767
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
56768
|
-
}
|
|
56769
|
-
function safeArgs2(args2) {
|
|
56770
|
-
try {
|
|
56771
|
-
return JSON.stringify(args2).length <= MAX_ARGS_JSON_CHARS2 ? args2 : { _omitted: "too large" };
|
|
56772
|
-
} catch {
|
|
56773
|
-
return { _omitted: "unreadable" };
|
|
56774
|
-
}
|
|
56775
|
-
}
|
|
56776
56816
|
function classifyTransport3(err2) {
|
|
56777
|
-
|
|
56778
|
-
const name2 = err2?.name;
|
|
56779
|
-
if (name2 === "TimeoutError" || name2 === "AbortError") return new InvestigateFailure("turn_timeout", err2);
|
|
56780
|
-
return new InvestigateFailure("transport", err2);
|
|
56817
|
+
return new InvestigateFailure(transportReason(err2), err2);
|
|
56781
56818
|
}
|
|
56782
56819
|
function classifyEnvelope(envelope) {
|
|
56783
56820
|
const e = envelope;
|
|
@@ -56793,9 +56830,9 @@ function classifyEnvelope(envelope) {
|
|
|
56793
56830
|
return null;
|
|
56794
56831
|
}
|
|
56795
56832
|
function scrubResult(call, result, secrets, counts, ledger) {
|
|
56796
|
-
if (result.status !== "ok" || !
|
|
56833
|
+
if (result.status !== "ok" || !isPlainObject(result.output)) return null;
|
|
56797
56834
|
const output = result.output;
|
|
56798
|
-
const args2 =
|
|
56835
|
+
const args2 = isPlainObject(call.args) ? call.args : {};
|
|
56799
56836
|
if (call.name === "read_file" && typeof output.content === "string" && typeof output.path === "string") {
|
|
56800
56837
|
const scrubbed = scrubForModel(output.content, secrets, modeForPath(output.path, "look"));
|
|
56801
56838
|
addRedactionCounts(counts, scrubbed.counts);
|
|
@@ -56903,7 +56940,7 @@ async function runInvestigateLoop(args2, deps) {
|
|
|
56903
56940
|
const failed = classifyEnvelope(envelope);
|
|
56904
56941
|
if (failed) throw failed;
|
|
56905
56942
|
const body2 = envelope?.structuredJson;
|
|
56906
|
-
if (!
|
|
56943
|
+
if (!isPlainObject(body2)) throw new InvestigateFailure("bad_reply");
|
|
56907
56944
|
if (body2.outcome === "FINDINGS") {
|
|
56908
56945
|
log({ event: "investigate.loop_turn", turn, outcome: "final", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
|
|
56909
56946
|
const stopReason = isFinal ? `forced_${finalReason}` : "model_final";
|
|
@@ -56912,16 +56949,9 @@ async function runInvestigateLoop(args2, deps) {
|
|
|
56912
56949
|
}
|
|
56913
56950
|
if (body2.outcome !== "TOOL_CALLS") throw new InvestigateFailure("bad_reply");
|
|
56914
56951
|
if (isFinal) throw new InvestigateFailure("final_not_produced");
|
|
56915
|
-
const
|
|
56916
|
-
if (
|
|
56917
|
-
const calls =
|
|
56918
|
-
for (const c of rawCalls) {
|
|
56919
|
-
if (!isPlainObject4(c) || typeof c.id !== "string" || c.id.length === 0 || c.id.length > MAX_ID_CHARS4 || typeof c.name !== "string") {
|
|
56920
|
-
throw new InvestigateFailure("bad_reply");
|
|
56921
|
-
}
|
|
56922
|
-
if (usedIds.has(c.id) || calls.some((x) => x.id === c.id)) throw new InvestigateFailure("duplicate_call_ids");
|
|
56923
|
-
calls.push({ id: c.id, name: c.name, args: c.args });
|
|
56924
|
-
}
|
|
56952
|
+
const parsed = parseToolCalls(body2.toolCalls, usedIds);
|
|
56953
|
+
if (typeof parsed === "string") throw new InvestigateFailure(parsed);
|
|
56954
|
+
const calls = parsed.calls;
|
|
56925
56955
|
for (const c of calls) usedIds.add(c.id);
|
|
56926
56956
|
const results = [];
|
|
56927
56957
|
const logged = [];
|
|
@@ -56953,7 +56983,7 @@ async function runInvestigateLoop(args2, deps) {
|
|
|
56953
56983
|
logged.push({ tool, status: result.status, ...result.reason && result.status !== "duplicate" ? { reason: result.reason } : {} });
|
|
56954
56984
|
});
|
|
56955
56985
|
const reasoning = typeof body2.reasoning === "string" ? body2.reasoning.slice(0, limits.maxReasoningChars) : void 0;
|
|
56956
|
-
transcript.push({ turn, ...reasoning ? { reasoning } : {}, toolCalls: calls.map((c) => ({ id: c.id, name: c.name, args:
|
|
56986
|
+
transcript.push({ turn, ...reasoning ? { reasoning } : {}, toolCalls: calls.map((c) => ({ id: c.id, name: c.name, args: safeArgs(c.args) })) });
|
|
56957
56987
|
toolResults.push(...results);
|
|
56958
56988
|
noProgressStreak = results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
56959
56989
|
if (noProgressStreak >= 2) forced = "no_progress";
|
|
@@ -57005,7 +57035,7 @@ function isStringList(x) {
|
|
|
57005
57035
|
return Array.isArray(x) && x.every((s) => typeof s === "string");
|
|
57006
57036
|
}
|
|
57007
57037
|
async function fetchInvestigatePacket(packetUrl, runToken, githubRunId) {
|
|
57008
|
-
const res = await
|
|
57038
|
+
const res = await fetchWithin("The look's packet request", `${packetUrl}?githubRunId=${encodeURIComponent(githubRunId)}`, { headers: { Authorization: `Bearer ${runToken}` } }, SHORT_CALL_MS);
|
|
57009
57039
|
if (!res.ok) throw new Error(`Fetch investigate packet failed: ${await describeQuikTrackFailure(res)}`);
|
|
57010
57040
|
const body2 = await res.json();
|
|
57011
57041
|
const data2 = body2?.data;
|
|
@@ -57042,7 +57072,7 @@ var InvestigationReportError = class extends Error {
|
|
|
57042
57072
|
status;
|
|
57043
57073
|
networkCode;
|
|
57044
57074
|
};
|
|
57045
|
-
async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) => new Promise((
|
|
57075
|
+
async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms))) {
|
|
57046
57076
|
const payload = JSON.stringify(body2);
|
|
57047
57077
|
const tries = INVESTIGATION_REPORT_RETRY_WAITS_MS.length + 1;
|
|
57048
57078
|
for (let attempt2 = 1; ; attempt2++) {
|
|
@@ -57050,11 +57080,11 @@ async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) =>
|
|
|
57050
57080
|
let status;
|
|
57051
57081
|
let networkCode;
|
|
57052
57082
|
try {
|
|
57053
|
-
const res = await
|
|
57083
|
+
const res = await fetchWithin("The look's report", callbackUrl, {
|
|
57054
57084
|
method: "POST",
|
|
57055
57085
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "application/json" },
|
|
57056
57086
|
body: payload
|
|
57057
|
-
});
|
|
57087
|
+
}, SHORT_CALL_MS);
|
|
57058
57088
|
if (res.ok) return;
|
|
57059
57089
|
failure = await describeQuikTrackFailure(res);
|
|
57060
57090
|
status = res.status;
|