@quikit/quikpilot-runner 9.3.0-rc.90 → 9.3.0-rc.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.js +563 -560
- 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");
|
|
@@ -38479,9 +38541,6 @@ function newLedger() {
|
|
|
38479
38541
|
}
|
|
38480
38542
|
var INVALID_PATH = "(invalid path)";
|
|
38481
38543
|
var CUT = "\u2026[line cut]";
|
|
38482
|
-
function isPlainObject(x) {
|
|
38483
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
38484
|
-
}
|
|
38485
38544
|
function bad(message) {
|
|
38486
38545
|
return { fail: { status: "bad_args", message } };
|
|
38487
38546
|
}
|
|
@@ -38952,11 +39011,6 @@ function createOverlayFs(base, overlay) {
|
|
|
38952
39011
|
exists: (rel) => overlay.has(rel) || base.exists(rel)
|
|
38953
39012
|
};
|
|
38954
39013
|
}
|
|
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
39014
|
function loadTextForEdit(fs2, path, maxBytes) {
|
|
38961
39015
|
let bytes;
|
|
38962
39016
|
try {
|
|
@@ -38971,7 +39025,7 @@ function loadTextForEdit(fs2, path, maxBytes) {
|
|
|
38971
39025
|
} catch {
|
|
38972
39026
|
return { ok: false, result: { status: "unreadable", reason: "io", message: "That file could not be read." } };
|
|
38973
39027
|
}
|
|
38974
|
-
if (
|
|
39028
|
+
if (hasNul(bytes)) return { ok: false, result: { status: "unreadable", reason: "binary", message: "That file is binary." } };
|
|
38975
39029
|
let text3;
|
|
38976
39030
|
try {
|
|
38977
39031
|
text3 = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
@@ -39994,6 +40048,101 @@ function loadApprovals(input) {
|
|
|
39994
40048
|
};
|
|
39995
40049
|
}
|
|
39996
40050
|
|
|
40051
|
+
// src/testLimits.ts
|
|
40052
|
+
var BASELINE_MIN_MS = 5 * 6e4;
|
|
40053
|
+
var BASELINE_MAX_MS = 25 * 6e4;
|
|
40054
|
+
var BASELINE_SHARE = 2.5;
|
|
40055
|
+
var GATE_MIN_MS = 5 * 6e4;
|
|
40056
|
+
var GATE_MAX_MS = 20 * 6e4;
|
|
40057
|
+
var GATE_BASELINES = 2.5;
|
|
40058
|
+
var GATE_MIN_START_MS = 6e4;
|
|
40059
|
+
var FILE_RUN_LIMIT_MS = 3 * 6e4;
|
|
40060
|
+
function testLimitsOff(env2 = process.env) {
|
|
40061
|
+
return env2.QUIKPILOT_TEST_LIMITS?.trim().toLowerCase() === "off";
|
|
40062
|
+
}
|
|
40063
|
+
var clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
40064
|
+
function baselineLimitMs(leftMs) {
|
|
40065
|
+
if (!Number.isFinite(leftMs)) return null;
|
|
40066
|
+
return Math.round(clamp(leftMs / BASELINE_SHARE, BASELINE_MIN_MS, BASELINE_MAX_MS));
|
|
40067
|
+
}
|
|
40068
|
+
function gateLimitMs(i3) {
|
|
40069
|
+
if (!Number.isFinite(i3.leftMs)) return null;
|
|
40070
|
+
const baseline = typeof i3.baselineMs === "number" && Number.isFinite(i3.baselineMs) && i3.baselineMs >= 0 ? i3.baselineMs : 0;
|
|
40071
|
+
if (i3.leftMs < Math.max(GATE_MIN_START_MS, baseline / 2)) return "no_time";
|
|
40072
|
+
return Math.round(Math.min(clamp(baseline * GATE_BASELINES, GATE_MIN_MS, GATE_MAX_MS), i3.leftMs));
|
|
40073
|
+
}
|
|
40074
|
+
var minutes = (ms) => Math.max(1, Math.round(ms / 6e4));
|
|
40075
|
+
function baselineTimeoutMessage(limitMs, jobMinutes) {
|
|
40076
|
+
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.`;
|
|
40077
|
+
}
|
|
40078
|
+
function gateTimeoutMessage(limitMs, baselineMs) {
|
|
40079
|
+
const before = typeof baselineMs === "number" && Number.isFinite(baselineMs) && baselineMs > 0 ? ` (they took ${minutes(baselineMs)} minutes before it)` : "";
|
|
40080
|
+
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.`;
|
|
40081
|
+
}
|
|
40082
|
+
function gateNoTimeMessage(baselineMs) {
|
|
40083
|
+
const about = typeof baselineMs === "number" && Number.isFinite(baselineMs) && baselineMs > 0 ? ` (they take about ${minutes(baselineMs)} minutes)` : "";
|
|
40084
|
+
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.`;
|
|
40085
|
+
}
|
|
40086
|
+
|
|
40087
|
+
// src/runDeadline.ts
|
|
40088
|
+
var RUN_RESERVE_MS = 7 * 6e4;
|
|
40089
|
+
var CHECKS_ALLOWANCE_MS = 2 * 6e4;
|
|
40090
|
+
var MIN_WRITING_MS = 5 * 6e4;
|
|
40091
|
+
var SETUP_FLOOR_MS = 5 * 6e4;
|
|
40092
|
+
var CHECK_COMMAND_FLOOR_MS = 2 * 6e4;
|
|
40093
|
+
var WATCHDOG_AFTER_STOP_MS = 3 * 6e4;
|
|
40094
|
+
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
40095
|
+
var clamp2 = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
40096
|
+
var minutes2 = (ms) => Math.max(1, Math.round(ms / 6e4));
|
|
40097
|
+
function runStopAtMs(startedAt, maxWallClockMinutes) {
|
|
40098
|
+
return startedAt + maxWallClockMinutes * 6e4 - RUN_RESERVE_MS;
|
|
40099
|
+
}
|
|
40100
|
+
function watchdogAtMs(stopAtMs) {
|
|
40101
|
+
return stopAtMs + WATCHDOG_AFTER_STOP_MS;
|
|
40102
|
+
}
|
|
40103
|
+
function finalChecksReserveMs(i3) {
|
|
40104
|
+
const base = finite(i3.baselineMs) && i3.baselineMs >= 0 ? i3.baselineMs : finite(i3.baselineLimitMs) ? i3.baselineLimitMs : BASELINE_MIN_MS;
|
|
40105
|
+
return clamp2(base + CHECKS_ALLOWANCE_MS, GATE_MIN_MS, GATE_MAX_MS);
|
|
40106
|
+
}
|
|
40107
|
+
function codegenStopAtMs(i3) {
|
|
40108
|
+
const byBudget = i3.now + i3.budgetMs;
|
|
40109
|
+
return finite(i3.stopAtMs) ? Math.min(byBudget, i3.stopAtMs - i3.reserveMs) : byBudget;
|
|
40110
|
+
}
|
|
40111
|
+
function commandLimitMs(kind, i3) {
|
|
40112
|
+
if (testLimitsOff(i3.env) || !finite(i3.stopAtMs)) return null;
|
|
40113
|
+
const left = i3.stopAtMs - i3.now;
|
|
40114
|
+
if (kind === "setup") return Math.round(Math.max(SETUP_FLOOR_MS, left - (BASELINE_MIN_MS + GATE_MIN_MS)));
|
|
40115
|
+
return Math.round(Math.max(CHECK_COMMAND_FLOOR_MS, left - (i3.reserveMs ?? 0)));
|
|
40116
|
+
}
|
|
40117
|
+
function commandTimeoutMessage(label, limitMs) {
|
|
40118
|
+
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.`;
|
|
40119
|
+
}
|
|
40120
|
+
function writeNoTimeMessage(leftMs, reserveMs) {
|
|
40121
|
+
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.`;
|
|
40122
|
+
}
|
|
40123
|
+
function jobTimeLimitMessage(jobMinutes) {
|
|
40124
|
+
return `The job was about to reach its ${jobMinutes}-minute time limit before QuikPilot finished, so QuikPilot stopped and reported. Nothing more was pushed.`;
|
|
40125
|
+
}
|
|
40126
|
+
function jobStoppedMessage() {
|
|
40127
|
+
return "The job was stopped before QuikPilot finished, so QuikPilot reported what it had. Nothing more was pushed.";
|
|
40128
|
+
}
|
|
40129
|
+
var SHORT_CALL_MS = 6e4;
|
|
40130
|
+
var LONG_CALL_MS = 5 * 6e4;
|
|
40131
|
+
async function fetchWithin(what, url, init2, limitMs) {
|
|
40132
|
+
const signal = AbortSignal.timeout(limitMs);
|
|
40133
|
+
try {
|
|
40134
|
+
return await fetch(url, { ...init2, signal });
|
|
40135
|
+
} catch (err2) {
|
|
40136
|
+
if (signal.aborted && err2?.name === "TimeoutError") {
|
|
40137
|
+
throw new Error(`${what} did not answer within ${minutesOrSeconds(limitMs)} and was stopped`);
|
|
40138
|
+
}
|
|
40139
|
+
throw err2;
|
|
40140
|
+
}
|
|
40141
|
+
}
|
|
40142
|
+
function minutesOrSeconds(ms) {
|
|
40143
|
+
return ms >= 12e4 ? `${Math.round(ms / 6e4)} minutes` : `${Math.max(1, Math.round(ms / 1e3))} s`;
|
|
40144
|
+
}
|
|
40145
|
+
|
|
39997
40146
|
// src/quiktrackError.ts
|
|
39998
40147
|
async function describeQuikTrackFailure(res) {
|
|
39999
40148
|
try {
|
|
@@ -40011,21 +40160,32 @@ var import_node_http = __toESM2(require("node:http"));
|
|
|
40011
40160
|
var import_node_https = __toESM2(require("node:https"));
|
|
40012
40161
|
var NATIVE_FETCH = globalThis.fetch;
|
|
40013
40162
|
var KEEP_ALIVE_INITIAL_DELAY_MS = 6e4;
|
|
40163
|
+
var MAX_RESPONSE_BYTES = 32 * 1024 * 1024;
|
|
40014
40164
|
var NULL_BODY_STATUSES = /* @__PURE__ */ new Set([204, 205, 304]);
|
|
40015
|
-
async function fetchOnOwnClock(url, init2) {
|
|
40165
|
+
async function fetchOnOwnClock(url, init2, opts = {}) {
|
|
40016
40166
|
if (!init2.signal || globalThis.fetch !== NATIVE_FETCH) return globalThis.fetch(url, init2);
|
|
40017
|
-
return requestWithoutHeadersLimit(url, init2, init2.signal);
|
|
40167
|
+
return requestWithoutHeadersLimit(url, init2, init2.signal, opts.maxResponseBytes ?? MAX_RESPONSE_BYTES);
|
|
40018
40168
|
}
|
|
40019
|
-
async function requestWithoutHeadersLimit(url, init2, signal) {
|
|
40169
|
+
async function requestWithoutHeadersLimit(url, init2, signal, maxBytes) {
|
|
40020
40170
|
if (init2.body != null && typeof init2.body !== "string") throw new TypeError("fetchOnOwnClock sends a string body only");
|
|
40021
40171
|
const target = new URL(url);
|
|
40022
40172
|
const client = target.protocol === "http:" ? import_node_http.default : import_node_https.default;
|
|
40023
40173
|
const headers = Object.fromEntries(new Headers(init2.headers).entries());
|
|
40024
|
-
return new Promise((
|
|
40174
|
+
return new Promise((resolve6, reject) => {
|
|
40025
40175
|
const fail = (err2) => reject(signal.aborted ? signal.reason : err2);
|
|
40026
40176
|
const req = client.request(target, { method: init2.method ?? "GET", headers, signal }, (res) => {
|
|
40027
40177
|
const chunks = [];
|
|
40028
|
-
|
|
40178
|
+
let bytes = 0;
|
|
40179
|
+
res.on("data", (chunk) => {
|
|
40180
|
+
bytes += chunk.length;
|
|
40181
|
+
if (bytes > maxBytes) {
|
|
40182
|
+
const kb = Math.round(maxBytes / 1024);
|
|
40183
|
+
req.destroy();
|
|
40184
|
+
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`));
|
|
40185
|
+
return;
|
|
40186
|
+
}
|
|
40187
|
+
chunks.push(chunk);
|
|
40188
|
+
});
|
|
40029
40189
|
res.on("error", fail);
|
|
40030
40190
|
res.on("end", () => {
|
|
40031
40191
|
const status = res.statusCode ?? 0;
|
|
@@ -40034,7 +40194,7 @@ async function requestWithoutHeadersLimit(url, init2, signal) {
|
|
|
40034
40194
|
for (const one of Array.isArray(value) ? value : value === void 0 ? [] : [value]) responseHeaders.append(name2, one);
|
|
40035
40195
|
}
|
|
40036
40196
|
try {
|
|
40037
|
-
|
|
40197
|
+
resolve6(new Response(NULL_BODY_STATUSES.has(status) ? null : Buffer.concat(chunks), { status, statusText: res.statusMessage ?? "", headers: responseHeaders }));
|
|
40038
40198
|
} catch (err2) {
|
|
40039
40199
|
reject(err2);
|
|
40040
40200
|
}
|
|
@@ -40082,7 +40242,7 @@ var REPORT_RETRY_WAITS_MS = [2e3, 5e3, 1e4];
|
|
|
40082
40242
|
var URGENT_REPORT_TIMEOUT_MS = 6e3;
|
|
40083
40243
|
async function reportBack(params) {
|
|
40084
40244
|
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((
|
|
40245
|
+
const sleep = params.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
|
|
40086
40246
|
const body2 = { status };
|
|
40087
40247
|
if (branch) body2.branch = branch;
|
|
40088
40248
|
if (warnings && warnings.length > 0) body2.warnings = warnings;
|
|
@@ -40109,7 +40269,8 @@ async function reportBack(params) {
|
|
|
40109
40269
|
method: "POST",
|
|
40110
40270
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "application/json" },
|
|
40111
40271
|
body: payload,
|
|
40112
|
-
|
|
40272
|
+
// QUIKTR-2708 (RN-22): every try has its own limit; the last-resort report a much shorter one (QUIKTR-2706).
|
|
40273
|
+
signal: AbortSignal.timeout(params.urgent ? URGENT_REPORT_TIMEOUT_MS : SHORT_CALL_MS)
|
|
40113
40274
|
});
|
|
40114
40275
|
} catch (err2) {
|
|
40115
40276
|
if (!isRetryableNetworkError(err2)) throw err2;
|
|
@@ -40133,87 +40294,6 @@ async function reportBack(params) {
|
|
|
40133
40294
|
|
|
40134
40295
|
// src/commands.ts
|
|
40135
40296
|
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
40297
|
var withheldLogged = false;
|
|
40218
40298
|
function repositoryCommandEnv() {
|
|
40219
40299
|
if (!withheldLogged) {
|
|
@@ -40244,7 +40324,7 @@ function runTestCommand(command) {
|
|
|
40244
40324
|
}
|
|
40245
40325
|
function runTestCommandAsync(command, signal) {
|
|
40246
40326
|
if (!command) return Promise.resolve("success");
|
|
40247
|
-
return new Promise((
|
|
40327
|
+
return new Promise((resolve6) => {
|
|
40248
40328
|
const child = (0, import_node_child_process5.spawn)(command, { shell: "/bin/bash", stdio: "inherit", detached: true, env: repositoryCommandEnv() });
|
|
40249
40329
|
track(child);
|
|
40250
40330
|
const onAbort = () => killProcessGroup(child);
|
|
@@ -40252,20 +40332,20 @@ function runTestCommandAsync(command, signal) {
|
|
|
40252
40332
|
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
40253
40333
|
const done = (outcome) => {
|
|
40254
40334
|
signal?.removeEventListener("abort", onAbort);
|
|
40255
|
-
|
|
40335
|
+
resolve6(signal?.aborted ? "failure" : outcome);
|
|
40256
40336
|
};
|
|
40257
40337
|
child.on("exit", (code) => done(code === 0 ? "success" : "failure"));
|
|
40258
40338
|
child.on("error", () => done("failure"));
|
|
40259
40339
|
});
|
|
40260
40340
|
}
|
|
40261
40341
|
function runCommandWithTimeout(command, timeoutMs) {
|
|
40262
|
-
return new Promise((
|
|
40342
|
+
return new Promise((resolve6) => {
|
|
40263
40343
|
let settled = false;
|
|
40264
40344
|
const finish = (outcome) => {
|
|
40265
40345
|
if (settled) return;
|
|
40266
40346
|
settled = true;
|
|
40267
40347
|
clearTimeout(timer);
|
|
40268
|
-
|
|
40348
|
+
resolve6(outcome);
|
|
40269
40349
|
};
|
|
40270
40350
|
const child = (0, import_node_child_process5.spawn)(command, {
|
|
40271
40351
|
shell: "/bin/bash",
|
|
@@ -40318,7 +40398,7 @@ function killProcessGroup(child) {
|
|
|
40318
40398
|
}
|
|
40319
40399
|
}
|
|
40320
40400
|
function runCapturedCommand(argv, opts) {
|
|
40321
|
-
return new Promise((
|
|
40401
|
+
return new Promise((resolve6) => {
|
|
40322
40402
|
let settled = false;
|
|
40323
40403
|
let timedOut = false;
|
|
40324
40404
|
let graceTimer;
|
|
@@ -40329,7 +40409,7 @@ function runCapturedCommand(argv, opts) {
|
|
|
40329
40409
|
settled = true;
|
|
40330
40410
|
clearTimeout(timer);
|
|
40331
40411
|
if (graceTimer) clearTimeout(graceTimer);
|
|
40332
|
-
|
|
40412
|
+
resolve6({ stdout: Buffer.concat(chunks).toString("utf8"), timedOut, started });
|
|
40333
40413
|
};
|
|
40334
40414
|
const child = (0, import_node_child_process5.spawn)(argv[0], argv.slice(1), {
|
|
40335
40415
|
cwd: opts.cwd,
|
|
@@ -40356,7 +40436,7 @@ function runCapturedCommand(argv, opts) {
|
|
|
40356
40436
|
});
|
|
40357
40437
|
}
|
|
40358
40438
|
function runShellCaptured(command, opts) {
|
|
40359
|
-
return new Promise((
|
|
40439
|
+
return new Promise((resolve6) => {
|
|
40360
40440
|
let settled = false;
|
|
40361
40441
|
let timedOut = false;
|
|
40362
40442
|
let graceTimer;
|
|
@@ -40371,7 +40451,7 @@ function runShellCaptured(command, opts) {
|
|
|
40371
40451
|
clearTimeout(timer);
|
|
40372
40452
|
if (graceTimer) clearTimeout(graceTimer);
|
|
40373
40453
|
const kept = tail2.length > opts.maxTailBytes ? tail2.subarray(tail2.length - opts.maxTailBytes) : tail2;
|
|
40374
|
-
|
|
40454
|
+
resolve6({ output: kept.toString("utf8"), exitCode, timedOut, started });
|
|
40375
40455
|
};
|
|
40376
40456
|
const child = (0, import_node_child_process5.spawn)(command, {
|
|
40377
40457
|
shell: "/bin/bash",
|
|
@@ -40394,7 +40474,7 @@ function runShellCaptured(command, opts) {
|
|
|
40394
40474
|
}
|
|
40395
40475
|
var KILL_GRACE_MS = 2e3;
|
|
40396
40476
|
function runTestCommandWithLimit(command, timeoutMs, cwd, signal) {
|
|
40397
|
-
return new Promise((
|
|
40477
|
+
return new Promise((resolve6) => {
|
|
40398
40478
|
let settled = false;
|
|
40399
40479
|
let timedOut = false;
|
|
40400
40480
|
let stopped = false;
|
|
@@ -40405,7 +40485,7 @@ function runTestCommandWithLimit(command, timeoutMs, cwd, signal) {
|
|
|
40405
40485
|
clearTimeout(timer);
|
|
40406
40486
|
if (graceTimer) clearTimeout(graceTimer);
|
|
40407
40487
|
signal?.removeEventListener("abort", onAbort);
|
|
40408
|
-
|
|
40488
|
+
resolve6(stopped ? { ...run3, outcome: "failure", stopped: true } : run3);
|
|
40409
40489
|
};
|
|
40410
40490
|
const onAbort = () => {
|
|
40411
40491
|
if (settled || timedOut || stopped) return;
|
|
@@ -40682,11 +40762,8 @@ var RULE_SHAPE = /^[a-z][a-z0-9_]{0,39}$/;
|
|
|
40682
40762
|
function count2(n) {
|
|
40683
40763
|
return typeof n === "number" && Number.isInteger(n) ? Math.min(MAX_PREVIOUS_COUNT, Math.max(0, n)) : 0;
|
|
40684
40764
|
}
|
|
40685
|
-
function isRecord(x) {
|
|
40686
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
40687
|
-
}
|
|
40688
40765
|
function testRunFrom(answer) {
|
|
40689
|
-
if (!
|
|
40766
|
+
if (!isPlainObject(answer)) return void 0;
|
|
40690
40767
|
const numbers = ["passed", "failed", "total", "regressions", "newFailures", "alreadyFailing"];
|
|
40691
40768
|
if (!numbers.every((k) => typeof answer[k] === "number") || !Array.isArray(answer.failingTests)) return void 0;
|
|
40692
40769
|
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 +40776,7 @@ function testRunFrom(answer) {
|
|
|
40699
40776
|
alreadyFailing: count2(answer.alreadyFailing),
|
|
40700
40777
|
failingTests
|
|
40701
40778
|
};
|
|
40702
|
-
if (
|
|
40779
|
+
if (isPlainObject(answer.messages)) {
|
|
40703
40780
|
const listed = new Set(failingTests);
|
|
40704
40781
|
const messages = {};
|
|
40705
40782
|
let total = 0;
|
|
@@ -40745,7 +40822,7 @@ function previousAttemptFrom(failure, attempt2) {
|
|
|
40745
40822
|
var import_node_crypto2 = require("node:crypto");
|
|
40746
40823
|
var import_node_fs13 = require("node:fs");
|
|
40747
40824
|
var import_node_os4 = require("node:os");
|
|
40748
|
-
var
|
|
40825
|
+
var import_node_path16 = require("node:path");
|
|
40749
40826
|
|
|
40750
40827
|
// src/pairedTests.ts
|
|
40751
40828
|
var import_node_path9 = require("node:path");
|
|
@@ -40887,18 +40964,16 @@ function testsThroughOneFile(p) {
|
|
|
40887
40964
|
// src/testAdapters.ts
|
|
40888
40965
|
var import_node_fs12 = require("node:fs");
|
|
40889
40966
|
var import_node_module = require("node:module");
|
|
40890
|
-
var
|
|
40967
|
+
var import_node_path14 = require("node:path");
|
|
40891
40968
|
|
|
40892
40969
|
// src/baselineCheck.ts
|
|
40893
40970
|
var import_node_child_process9 = require("node:child_process");
|
|
40894
40971
|
var import_node_fs11 = require("node:fs");
|
|
40895
|
-
var import_node_path14 = require("node:path");
|
|
40896
40972
|
|
|
40897
40973
|
// src/quiktest.ts
|
|
40898
40974
|
var import_node_child_process6 = require("node:child_process");
|
|
40899
40975
|
var import_node_fs6 = require("node:fs");
|
|
40900
40976
|
var import_node_path10 = require("node:path");
|
|
40901
|
-
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
40902
40977
|
var DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
|
|
40903
40978
|
"node_modules",
|
|
40904
40979
|
".git",
|
|
@@ -40931,35 +41006,44 @@ function isJUnitXml(path) {
|
|
|
40931
41006
|
if (fd !== null) (0, import_node_fs6.closeSync)(fd);
|
|
40932
41007
|
}
|
|
40933
41008
|
}
|
|
40934
|
-
function
|
|
40935
|
-
|
|
41009
|
+
function walkReports(cwd, opts = {}) {
|
|
41010
|
+
let firstNamed = null;
|
|
41011
|
+
const named2 = [];
|
|
41012
|
+
const others = [];
|
|
40936
41013
|
const walk3 = (dir) => {
|
|
40937
|
-
if (found.length >= MAX_REPORTS) return;
|
|
40938
41014
|
let entries;
|
|
40939
41015
|
try {
|
|
40940
|
-
entries = (0, import_node_fs6.readdirSync)(dir);
|
|
41016
|
+
entries = (0, import_node_fs6.readdirSync)(dir, { withFileTypes: true });
|
|
40941
41017
|
} catch {
|
|
40942
41018
|
return;
|
|
40943
41019
|
}
|
|
40944
41020
|
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 {
|
|
41021
|
+
if (DEPENDENCY_DIRS.has(entry.name)) continue;
|
|
41022
|
+
const full = (0, import_node_path10.join)(dir, entry.name);
|
|
41023
|
+
if (entry.isDirectory()) {
|
|
41024
|
+
walk3(full);
|
|
40951
41025
|
continue;
|
|
40952
41026
|
}
|
|
40953
|
-
if (
|
|
40954
|
-
|
|
40955
|
-
|
|
40956
|
-
|
|
41027
|
+
if (!entry.isFile() || !/\.xml$/i.test(entry.name)) continue;
|
|
41028
|
+
const isNamed = /^junit.*\.xml$/i.test(entry.name);
|
|
41029
|
+
if (isNamed && firstNamed === null && /^junit.*\.xml$/.test(entry.name)) firstNamed = full;
|
|
41030
|
+
if (!isNamed && others.length >= MAX_REPORTS) continue;
|
|
41031
|
+
if (opts.freshSinceMs !== void 0) {
|
|
41032
|
+
try {
|
|
41033
|
+
if ((0, import_node_fs6.statSync)(full).mtimeMs < opts.freshSinceMs) continue;
|
|
41034
|
+
} catch {
|
|
41035
|
+
continue;
|
|
41036
|
+
}
|
|
40957
41037
|
}
|
|
41038
|
+
if (isJUnitXml(full)) (isNamed ? named2 : others).push(full);
|
|
40958
41039
|
}
|
|
40959
41040
|
};
|
|
40960
41041
|
walk3(cwd);
|
|
40961
|
-
const
|
|
40962
|
-
return
|
|
41042
|
+
const byPath = (a, b) => a.localeCompare(b);
|
|
41043
|
+
return { firstNamed, reports: [...named2.sort(byPath), ...others.sort(byPath)].slice(0, MAX_REPORTS) };
|
|
41044
|
+
}
|
|
41045
|
+
function findJUnitReports(cwd = process.cwd(), opts = {}) {
|
|
41046
|
+
return walkReports(cwd, opts).reports;
|
|
40963
41047
|
}
|
|
40964
41048
|
function trackedPaths(paths, cwd = process.cwd()) {
|
|
40965
41049
|
if (paths.length === 0) return /* @__PURE__ */ new Set();
|
|
@@ -41003,31 +41087,6 @@ ${inner.filter(Boolean).join("\n")}
|
|
|
41003
41087
|
</testsuites>
|
|
41004
41088
|
`;
|
|
41005
41089
|
}
|
|
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
41090
|
function firstXmlIn(dir, namePattern) {
|
|
41032
41091
|
let entries;
|
|
41033
41092
|
try {
|
|
@@ -41049,7 +41108,8 @@ function readTestReportBytes(cwd = process.cwd(), opts = {}) {
|
|
|
41049
41108
|
}
|
|
41050
41109
|
}
|
|
41051
41110
|
function findJUnitReport(cwd = process.cwd()) {
|
|
41052
|
-
|
|
41111
|
+
const walked = walkReports(cwd);
|
|
41112
|
+
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
41113
|
}
|
|
41054
41114
|
function buildCiUrl(serverUrl, repository, githubRunId) {
|
|
41055
41115
|
return `${serverUrl}/${repository}/actions/runs/${githubRunId}`;
|
|
@@ -41078,11 +41138,11 @@ async function reportToQuikTest(params) {
|
|
|
41078
41138
|
if (generatedFiles) {
|
|
41079
41139
|
url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
|
|
41080
41140
|
}
|
|
41081
|
-
const res = await
|
|
41141
|
+
const res = await fetchWithin("The upload of the test results to QuikTest", url, {
|
|
41082
41142
|
method: "POST",
|
|
41083
41143
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "text/xml" },
|
|
41084
41144
|
body: body2
|
|
41085
|
-
});
|
|
41145
|
+
}, SHORT_CALL_MS);
|
|
41086
41146
|
if (!res.ok) {
|
|
41087
41147
|
throw new Error(`QuikTest report POST failed: ${res.status} ${res.statusText}`);
|
|
41088
41148
|
}
|
|
@@ -41637,27 +41697,30 @@ function ancestorInside(realRoot, abs) {
|
|
|
41637
41697
|
}
|
|
41638
41698
|
}
|
|
41639
41699
|
}
|
|
41700
|
+
function restoreOriginals(records) {
|
|
41701
|
+
const failed = [];
|
|
41702
|
+
for (const w of [...records].reverse()) {
|
|
41703
|
+
try {
|
|
41704
|
+
if (w.original !== null) (0, import_node_fs9.writeFileSync)(w.abs, w.original);
|
|
41705
|
+
else (0, import_node_fs9.rmSync)(w.abs, { force: true });
|
|
41706
|
+
for (const d of [...w.createdDirs].reverse()) {
|
|
41707
|
+
try {
|
|
41708
|
+
(0, import_node_fs9.rmdirSync)(d);
|
|
41709
|
+
} catch {
|
|
41710
|
+
}
|
|
41711
|
+
}
|
|
41712
|
+
} catch {
|
|
41713
|
+
failed.push(w.rel);
|
|
41714
|
+
}
|
|
41715
|
+
}
|
|
41716
|
+
return failed;
|
|
41717
|
+
}
|
|
41640
41718
|
function applyOverlay(root, files) {
|
|
41641
41719
|
const realRoot = (0, import_node_fs9.realpathSync)(root);
|
|
41642
41720
|
const written = [];
|
|
41643
41721
|
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
|
-
}
|
|
41722
|
+
const restore = () => {
|
|
41723
|
+
const failed = restoreOriginals(written);
|
|
41661
41724
|
written.length = 0;
|
|
41662
41725
|
return { failed: failed.sort() };
|
|
41663
41726
|
};
|
|
@@ -41687,15 +41750,15 @@ function applyOverlay(root, files) {
|
|
|
41687
41750
|
createdDirs.push(d);
|
|
41688
41751
|
}
|
|
41689
41752
|
}
|
|
41690
|
-
const w = { abs, original, createdDirs };
|
|
41753
|
+
const w = { rel, abs, original, createdDirs };
|
|
41691
41754
|
written.push(w);
|
|
41692
41755
|
(0, import_node_fs9.writeFileSync)(abs, f.content);
|
|
41693
41756
|
}
|
|
41694
41757
|
} catch (err2) {
|
|
41695
|
-
|
|
41758
|
+
restore();
|
|
41696
41759
|
throw err2;
|
|
41697
41760
|
}
|
|
41698
|
-
return { restore
|
|
41761
|
+
return { restore };
|
|
41699
41762
|
}
|
|
41700
41763
|
function git2(root, args2) {
|
|
41701
41764
|
(0, import_node_child_process8.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], { env: gitEnv(), cwd: root, stdio: ["ignore", "ignore", "ignore"] });
|
|
@@ -41815,24 +41878,7 @@ function undoableFlush(root, results, flush, options = {}) {
|
|
|
41815
41878
|
}
|
|
41816
41879
|
return { rel, abs, original, createdDirs };
|
|
41817
41880
|
});
|
|
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
|
-
};
|
|
41881
|
+
const putFilesBack = () => restoreOriginals(originals);
|
|
41836
41882
|
try {
|
|
41837
41883
|
flush(results);
|
|
41838
41884
|
} catch (err2) {
|
|
@@ -41974,7 +42020,7 @@ function shellQuote(value) {
|
|
|
41974
42020
|
}
|
|
41975
42021
|
function buildSingleFileCommand(command, path) {
|
|
41976
42022
|
const quoted2 = shellQuote(path);
|
|
41977
|
-
return command.includes("{file}") ? command.
|
|
42023
|
+
return command.includes("{file}") ? command.replace(/(["']?)\{file\}\1/g, () => quoted2) : `${command} ${quoted2}`;
|
|
41978
42024
|
}
|
|
41979
42025
|
var isTestTarget2 = (t) => (t.automationIds?.length ?? 0) > 0;
|
|
41980
42026
|
function checkableIds(ids, types2) {
|
|
@@ -41988,35 +42034,9 @@ function checkableIds(ids, types2) {
|
|
|
41988
42034
|
function insideCheckout(cwd, path) {
|
|
41989
42035
|
return safeRepoTarget(path, cwd);
|
|
41990
42036
|
}
|
|
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
|
-
}
|
|
42037
|
+
function restoreChecked(session) {
|
|
42038
|
+
if (!session) return;
|
|
42039
|
+
for (const path of session.restore().failed) console.error(`Baseline check could not restore ${path}`);
|
|
42020
42040
|
}
|
|
42021
42041
|
function untrackedFiles(cwd) {
|
|
42022
42042
|
try {
|
|
@@ -42069,7 +42089,7 @@ async function runBaselineCheck(params) {
|
|
|
42069
42089
|
}
|
|
42070
42090
|
const warnings = [];
|
|
42071
42091
|
const flagged = [];
|
|
42072
|
-
|
|
42092
|
+
let session = null;
|
|
42073
42093
|
const unsafe = /* @__PURE__ */ new Set();
|
|
42074
42094
|
const skip = (path, why) => {
|
|
42075
42095
|
const message = `Baseline check skipped for ${path}: ${why}`;
|
|
@@ -42079,16 +42099,18 @@ async function runBaselineCheck(params) {
|
|
|
42079
42099
|
try {
|
|
42080
42100
|
const contentByPath = new Map(results.map((r) => [r.targetPath, r.newContent]));
|
|
42081
42101
|
const cause = decideCause(targets, contentByPath, cwd);
|
|
42102
|
+
const toWrite = /* @__PURE__ */ new Map();
|
|
42082
42103
|
for (const target of testTargets) {
|
|
42083
42104
|
const content = contentByPath.get(target.path);
|
|
42084
42105
|
if (content === void 0) continue;
|
|
42085
|
-
const
|
|
42086
|
-
if (
|
|
42106
|
+
const rel = insideCheckout(cwd, target.path) === null ? null : canonicalPath(target.path);
|
|
42107
|
+
if (rel === null) {
|
|
42087
42108
|
unsafe.add(target.path);
|
|
42088
42109
|
continue;
|
|
42089
42110
|
}
|
|
42090
|
-
|
|
42111
|
+
toWrite.set(rel, content);
|
|
42091
42112
|
}
|
|
42113
|
+
session = applyOverlay(cwd, [...toWrite].map(([path, content]) => ({ path, content })));
|
|
42092
42114
|
for (const { target, ids } of toCheck) {
|
|
42093
42115
|
if (unsafe.has(target.path)) {
|
|
42094
42116
|
skip(target.path, "the path is outside the checkout, so the file was not written or run.");
|
|
@@ -42141,7 +42163,7 @@ async function runBaselineCheck(params) {
|
|
|
42141
42163
|
console.warn(`::warning::${message}`);
|
|
42142
42164
|
return { findings: null, warnings: [...warnings, message] };
|
|
42143
42165
|
} finally {
|
|
42144
|
-
|
|
42166
|
+
restoreChecked(session);
|
|
42145
42167
|
}
|
|
42146
42168
|
}
|
|
42147
42169
|
|
|
@@ -42157,11 +42179,11 @@ var CONFIG_FILES = ["vitest.config.ts", "vitest.config.mts", "vitest.config.cts"
|
|
|
42157
42179
|
var WORKSPACE_IN_CONFIG = /\b(?:workspace|projects)\s*:/;
|
|
42158
42180
|
function defaultResolveVitest(cwd) {
|
|
42159
42181
|
try {
|
|
42160
|
-
const pkgPath = (0, import_node_module.createRequire)((0,
|
|
42182
|
+
const pkgPath = (0, import_node_module.createRequire)((0, import_node_path14.join)(cwd, "package.json")).resolve("vitest/package.json");
|
|
42161
42183
|
const pkg = JSON.parse((0, import_node_fs12.readFileSync)(pkgPath, "utf8"));
|
|
42162
42184
|
const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.vitest;
|
|
42163
42185
|
if (typeof rel !== "string" || typeof pkg.version !== "string") return null;
|
|
42164
|
-
return { bin: forward((0,
|
|
42186
|
+
return { bin: forward((0, import_node_path14.join)((0, import_node_path14.dirname)(pkgPath), rel)), version: pkg.version };
|
|
42165
42187
|
} catch {
|
|
42166
42188
|
return null;
|
|
42167
42189
|
}
|
|
@@ -42206,9 +42228,9 @@ function detectAdapter(i3) {
|
|
|
42206
42228
|
const parsed = parseTestInvocation(rest);
|
|
42207
42229
|
if ("off" in parsed) return parsed;
|
|
42208
42230
|
if (parsed.flags.some((f) => !ALLOWED_FLAG.test(f))) return { off: "extra_flags" };
|
|
42209
|
-
const cwd = folder ?
|
|
42231
|
+
const cwd = folder ? import_node_path14.posix.join(forward(i3.root), folder) : forward(i3.root);
|
|
42210
42232
|
if (parsed.viaScript) {
|
|
42211
|
-
const pkgText = i3.readText(
|
|
42233
|
+
const pkgText = i3.readText(import_node_path14.posix.join(cwd, "package.json"));
|
|
42212
42234
|
let script = "";
|
|
42213
42235
|
try {
|
|
42214
42236
|
const scripts = JSON.parse(pkgText ?? "{}").scripts;
|
|
@@ -42219,9 +42241,9 @@ function detectAdapter(i3) {
|
|
|
42219
42241
|
if (!/\bvitest\b/.test(script)) return { off: "not_vitest" };
|
|
42220
42242
|
if (!PLAIN_VITEST_SCRIPT.test(script)) return { off: "script_not_plain" };
|
|
42221
42243
|
}
|
|
42222
|
-
if (WORKSPACE_FILES.some((f) => i3.exists(
|
|
42244
|
+
if (WORKSPACE_FILES.some((f) => i3.exists(import_node_path14.posix.join(cwd, f)))) return { off: "workspace_config" };
|
|
42223
42245
|
for (const f of CONFIG_FILES) {
|
|
42224
|
-
const text3 = i3.exists(
|
|
42246
|
+
const text3 = i3.exists(import_node_path14.posix.join(cwd, f)) ? i3.readText(import_node_path14.posix.join(cwd, f)) : null;
|
|
42225
42247
|
if (text3 !== null && WORKSPACE_IN_CONFIG.test(text3)) return { off: "workspace_config" };
|
|
42226
42248
|
}
|
|
42227
42249
|
const found = (i3.resolveVitest ?? defaultResolveVitest)(cwd);
|
|
@@ -42244,7 +42266,7 @@ var TEST_FILE_NAME = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
|
|
42244
42266
|
function forceFullReason(paths, setupFiles = []) {
|
|
42245
42267
|
for (const raw of paths) {
|
|
42246
42268
|
const p = forward(raw);
|
|
42247
|
-
const base =
|
|
42269
|
+
const base = import_node_path14.posix.basename(p);
|
|
42248
42270
|
if (base === "package.json" || base === "npm-shrinkwrap.json") return "package_manifest";
|
|
42249
42271
|
if (/^(?:package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?)$/.test(base)) return "lock_file";
|
|
42250
42272
|
if (/^[jt]sconfig(?:\.[\w.-]+)?\.json$/.test(base)) return "ts_config";
|
|
@@ -42262,7 +42284,7 @@ function setupFilesOf(configText, folderRel) {
|
|
|
42262
42284
|
for (const m of configText.matchAll(list2)) {
|
|
42263
42285
|
for (const s of (m[1] ?? "").matchAll(/["']([^"']+)["']/g)) {
|
|
42264
42286
|
const rel = forward(s[1] ?? "").replace(/^\.\//, "");
|
|
42265
|
-
if (rel) out2.push(
|
|
42287
|
+
if (rel) out2.push(import_node_path14.posix.join(folderRel, rel));
|
|
42266
42288
|
}
|
|
42267
42289
|
}
|
|
42268
42290
|
return out2;
|
|
@@ -42297,7 +42319,7 @@ function fsReadingTests(i3) {
|
|
|
42297
42319
|
}
|
|
42298
42320
|
|
|
42299
42321
|
// src/tsconfigPaths.ts
|
|
42300
|
-
var
|
|
42322
|
+
var import_node_path15 = require("node:path");
|
|
42301
42323
|
var MAX_EXTENDS_DEPTH = 5;
|
|
42302
42324
|
function parseJsonc(text3) {
|
|
42303
42325
|
let out2 = "";
|
|
@@ -42343,12 +42365,12 @@ function resolveConfig(readText, file, depth, seen) {
|
|
|
42343
42365
|
if (typeof text3 !== "string") return null;
|
|
42344
42366
|
const json = parseJsonc(text3);
|
|
42345
42367
|
if (!isObject(json)) return null;
|
|
42346
|
-
const dir =
|
|
42368
|
+
const dir = import_node_path15.posix.dirname(file) === "." ? "" : import_node_path15.posix.dirname(file);
|
|
42347
42369
|
let inherited = { paths: null, pathsDir: dir, baseUrl: null };
|
|
42348
42370
|
const ext = typeof json.extends === "string" ? [json.extends] : stringList(json.extends);
|
|
42349
42371
|
for (const e of ext) {
|
|
42350
42372
|
if (!e.startsWith(".")) continue;
|
|
42351
|
-
const parent = resolveConfig(readText,
|
|
42373
|
+
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
42374
|
if (parent) {
|
|
42353
42375
|
inherited = {
|
|
42354
42376
|
paths: parent.paths ?? inherited.paths,
|
|
@@ -42358,7 +42380,7 @@ function resolveConfig(readText, file, depth, seen) {
|
|
|
42358
42380
|
}
|
|
42359
42381
|
}
|
|
42360
42382
|
const co = isObject(json.compilerOptions) ? json.compilerOptions : {};
|
|
42361
|
-
const baseUrl = typeof co.baseUrl === "string" ?
|
|
42383
|
+
const baseUrl = typeof co.baseUrl === "string" ? import_node_path15.posix.normalize(import_node_path15.posix.join(dir, co.baseUrl)) : inherited.baseUrl;
|
|
42362
42384
|
let paths = inherited.paths;
|
|
42363
42385
|
let pathsDir = inherited.pathsDir;
|
|
42364
42386
|
if (isObject(co.paths)) {
|
|
@@ -42388,7 +42410,7 @@ function aliasTable(opts) {
|
|
|
42388
42410
|
if (!config?.paths) return [];
|
|
42389
42411
|
const lines = [];
|
|
42390
42412
|
for (const [key, targets] of Object.entries(config.paths)) {
|
|
42391
|
-
const resolved = targets.map((t) =>
|
|
42413
|
+
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
42414
|
if (resolved.length > 0) lines.push(`${key} -> ${resolved.join(", ")}`);
|
|
42393
42415
|
}
|
|
42394
42416
|
return lines.sort().slice(0, opts.max ?? 20);
|
|
@@ -42415,7 +42437,7 @@ function createAliasMapper(opts) {
|
|
|
42415
42437
|
};
|
|
42416
42438
|
return (fromPath, specifier) => {
|
|
42417
42439
|
if (specifier.startsWith(".") || specifier.startsWith("/")) return null;
|
|
42418
|
-
const dir =
|
|
42440
|
+
const dir = import_node_path15.posix.dirname(fromPath) === "." ? "" : import_node_path15.posix.dirname(fromPath);
|
|
42419
42441
|
const config = configFor(dir);
|
|
42420
42442
|
if (!config?.paths) return null;
|
|
42421
42443
|
let best = null;
|
|
@@ -42426,8 +42448,8 @@ function createAliasMapper(opts) {
|
|
|
42426
42448
|
if (!best) return null;
|
|
42427
42449
|
const bases = [];
|
|
42428
42450
|
for (const target of config.paths[best.key]) {
|
|
42429
|
-
const joined =
|
|
42430
|
-
if (joined === ".." || joined.startsWith("../") ||
|
|
42451
|
+
const joined = import_node_path15.posix.normalize(import_node_path15.posix.join(config.baseUrl ?? config.pathsDir, target.replace("*", best.captured)));
|
|
42452
|
+
if (joined === ".." || joined.startsWith("../") || import_node_path15.posix.isAbsolute(joined)) continue;
|
|
42431
42453
|
if (opts.writeRoot !== "" && !matchesPrefix(joined, opts.writeRoot)) continue;
|
|
42432
42454
|
bases.push(joined === "." ? "" : joined);
|
|
42433
42455
|
}
|
|
@@ -42481,7 +42503,7 @@ function createRelatedPlanner(d) {
|
|
|
42481
42503
|
const exists = d.exists ?? import_node_fs13.existsSync;
|
|
42482
42504
|
const mode = (env2.QUIKPILOT_RELATED_TESTS ?? "").trim().toLowerCase();
|
|
42483
42505
|
const minMs = minBaselineMs(env2);
|
|
42484
|
-
const abs = (rel) => forward2((0,
|
|
42506
|
+
const abs = (rel) => forward2((0, import_node_path16.join)(d.root, rel));
|
|
42485
42507
|
const isTest = testRule(d.discoveredTests ?? null);
|
|
42486
42508
|
let detected = null;
|
|
42487
42509
|
let setupFiles = [];
|
|
@@ -42493,9 +42515,9 @@ function createRelatedPlanner(d) {
|
|
|
42493
42515
|
function detect() {
|
|
42494
42516
|
const found = detectAdapter({ command: d.command, root: forward2(d.root), readText, exists, resolveVitest: d.resolveVitest });
|
|
42495
42517
|
if ("adapter" in found) {
|
|
42496
|
-
const folder = forward2((0,
|
|
42518
|
+
const folder = forward2((0, import_node_path16.relative)(d.root, found.adapter.cwd));
|
|
42497
42519
|
for (const name2 of CONFIG_FILES) {
|
|
42498
|
-
const text3 = exists(
|
|
42520
|
+
const text3 = exists(import_node_path16.posix.join(found.adapter.cwd, name2)) ? readText(import_node_path16.posix.join(found.adapter.cwd, name2)) : null;
|
|
42499
42521
|
if (text3 !== null) setupFiles.push(...setupFilesOf(text3, folder));
|
|
42500
42522
|
}
|
|
42501
42523
|
log({ event: "related.adapter", adapter: found.adapter.kind, version: found.adapter.version });
|
|
@@ -42605,6 +42627,9 @@ var TOKENS_PER_PUNCTUATION_CHAR = 1.05;
|
|
|
42605
42627
|
var TOKENS_PER_NON_ASCII_CHAR = 1;
|
|
42606
42628
|
var PROMPT_OVERHEAD_TOKENS = 5e3;
|
|
42607
42629
|
function estimateTokens(text3) {
|
|
42630
|
+
return tokensFrom(classCounts(text3));
|
|
42631
|
+
}
|
|
42632
|
+
function classCounts(text3) {
|
|
42608
42633
|
let alpha = 0;
|
|
42609
42634
|
let digit = 0;
|
|
42610
42635
|
let space = 0;
|
|
@@ -42618,8 +42643,11 @@ function estimateTokens(text3) {
|
|
|
42618
42643
|
else if (code === 32 || code === 9 || code === 13 || code === 10) space++;
|
|
42619
42644
|
else punct++;
|
|
42620
42645
|
}
|
|
42646
|
+
return { alpha, digit, space, punct, nonAscii };
|
|
42647
|
+
}
|
|
42648
|
+
function tokensFrom(c) {
|
|
42621
42649
|
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
|
|
42650
|
+
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
42651
|
);
|
|
42624
42652
|
}
|
|
42625
42653
|
function estimateRequestTokens(contextData) {
|
|
@@ -43031,7 +43059,9 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
43031
43059
|
expectedOutputType: "json",
|
|
43032
43060
|
userPrompt: "",
|
|
43033
43061
|
contextData
|
|
43034
|
-
})
|
|
43062
|
+
}),
|
|
43063
|
+
// QUIKTR-2708 (RN-22): a per-file call gets an explicit limit (a fresh one per call); it had none of its own.
|
|
43064
|
+
signal: AbortSignal.timeout(LONG_CALL_MS)
|
|
43035
43065
|
});
|
|
43036
43066
|
let res = await callCodegen();
|
|
43037
43067
|
if (!res.ok) {
|
|
@@ -43230,12 +43260,12 @@ function callFunctionEnabled(githubRepository, mode, env2 = process.env) {
|
|
|
43230
43260
|
|
|
43231
43261
|
// src/callFunctionTool.ts
|
|
43232
43262
|
var import_node_crypto4 = require("node:crypto");
|
|
43233
|
-
var
|
|
43263
|
+
var import_node_path18 = require("node:path");
|
|
43234
43264
|
|
|
43235
43265
|
// src/runTestsTool.ts
|
|
43236
43266
|
var import_node_crypto3 = require("node:crypto");
|
|
43237
43267
|
var import_node_fs14 = require("node:fs");
|
|
43238
|
-
var
|
|
43268
|
+
var import_node_path17 = require("node:path");
|
|
43239
43269
|
var scrubSecrets2 = (text3) => scrubForModel(text3, [], "code").text;
|
|
43240
43270
|
var RUN_TESTS_TOOL = "run_tests";
|
|
43241
43271
|
var MAX_TEST_RUNS = 3;
|
|
@@ -43314,9 +43344,9 @@ function samePlace(a, b) {
|
|
|
43314
43344
|
function ownFailureIds(newFailures, changedPaths, requiredIds, changedText) {
|
|
43315
43345
|
const own = /* @__PURE__ */ new Set();
|
|
43316
43346
|
for (const id of newFailures) {
|
|
43317
|
-
const
|
|
43318
|
-
const file =
|
|
43319
|
-
const name2 =
|
|
43347
|
+
const sep2 = id.indexOf("::");
|
|
43348
|
+
const file = sep2 >= 0 ? id.slice(0, sep2) : "";
|
|
43349
|
+
const name2 = sep2 >= 0 ? id.slice(sep2 + 2) : id;
|
|
43320
43350
|
const inChangedFile = file !== "" && changedPaths.some((p) => samePlace(file, p));
|
|
43321
43351
|
const hasToken = requiredIds.some((t) => name2.includes(`[${t}]`));
|
|
43322
43352
|
if (inChangedFile || hasToken) {
|
|
@@ -43548,7 +43578,7 @@ var RunTestsTool = class {
|
|
|
43548
43578
|
const runCommand2 = d.runCommand ?? runTestCommandWithLimit;
|
|
43549
43579
|
const readSnapshot = d.readSnapshot ?? readTestSnapshot;
|
|
43550
43580
|
const reportBefore = findReport(d.root);
|
|
43551
|
-
const preserve = reportBefore ? [(0,
|
|
43581
|
+
const preserve = reportBefore ? [(0, import_node_path17.relative)(d.root, reportBefore).split("\\").join("/")] : [];
|
|
43552
43582
|
const spend = (n) => {
|
|
43553
43583
|
if (file === void 0) this.runs += n;
|
|
43554
43584
|
else this.fileRuns += n;
|
|
@@ -43899,7 +43929,7 @@ var CallFunctionTool = class {
|
|
|
43899
43929
|
const now = d.now ?? Date.now;
|
|
43900
43930
|
const helper = {
|
|
43901
43931
|
path: `.quikpilot-call-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.mjs`,
|
|
43902
|
-
content: helperSource({ target: (0,
|
|
43932
|
+
content: helperSource({ target: (0, import_node_path18.join)(d.root, parsed.path), exportName: parsed.exportName, args: parsed.callArgs })
|
|
43903
43933
|
};
|
|
43904
43934
|
const run3 = d.run ?? runCapturedCommand;
|
|
43905
43935
|
this.calls += 1;
|
|
@@ -43909,7 +43939,7 @@ var CallFunctionTool = class {
|
|
|
43909
43939
|
captured = await withOverlayOnDisk(
|
|
43910
43940
|
d.root,
|
|
43911
43941
|
[...files, helper],
|
|
43912
|
-
() => run3([d.nodePath ?? process.execPath, (0,
|
|
43942
|
+
() => 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
43943
|
{ ...d.tree }
|
|
43914
43944
|
);
|
|
43915
43945
|
} catch (err2) {
|
|
@@ -47677,10 +47707,10 @@ function fitBlocks(blocks, paths, room) {
|
|
|
47677
47707
|
for (let i3 = 0; i3 < blocks.length; i3++) {
|
|
47678
47708
|
const block = blocks[i3];
|
|
47679
47709
|
const tail2 = i3 + 1 < blocks.length ? note(i3 + 1) : "";
|
|
47680
|
-
const
|
|
47681
|
-
if (used +
|
|
47710
|
+
const sep2 = kept.length > 0 ? 1 : 0;
|
|
47711
|
+
if (used + sep2 + block.length + (tail2 ? tail2.length + 1 : 0) <= room) {
|
|
47682
47712
|
kept.push(block);
|
|
47683
|
-
used +=
|
|
47713
|
+
used += sep2 + block.length;
|
|
47684
47714
|
continue;
|
|
47685
47715
|
}
|
|
47686
47716
|
const rest = note(i3);
|
|
@@ -48069,7 +48099,7 @@ function createCodegenWorkspace(args2) {
|
|
|
48069
48099
|
|
|
48070
48100
|
// src/scratchRunTool.ts
|
|
48071
48101
|
var import_node_fs15 = require("node:fs");
|
|
48072
|
-
var
|
|
48102
|
+
var import_node_path19 = require("node:path");
|
|
48073
48103
|
var RUN_SCRATCH_TOOL = "run_scratch";
|
|
48074
48104
|
var MAX_SCRATCH_TEXT_CHARS = 2e3;
|
|
48075
48105
|
var MAX_SCRATCH_CONTENT_CHARS = 8e3;
|
|
@@ -48155,10 +48185,10 @@ var ScratchRunTool = class {
|
|
|
48155
48185
|
if (matchesDeniedPath(path, d.deniedPaths) !== null) return false;
|
|
48156
48186
|
if (!testRule(d.discoveredTests)(path)) return false;
|
|
48157
48187
|
if (d.protectedTestPaths.includes(path) || d.listing.includes(path) || files.some((f) => f.path === path)) return false;
|
|
48158
|
-
const abs = (0,
|
|
48188
|
+
const abs = (0, import_node_path19.join)(d.root, path);
|
|
48159
48189
|
if ((0, import_node_fs15.existsSync)(abs)) return false;
|
|
48160
48190
|
try {
|
|
48161
|
-
return (0, import_node_fs15.statSync)((0,
|
|
48191
|
+
return (0, import_node_fs15.statSync)((0, import_node_path19.dirname)(abs)).isDirectory();
|
|
48162
48192
|
} catch {
|
|
48163
48193
|
return false;
|
|
48164
48194
|
}
|
|
@@ -48197,7 +48227,7 @@ var ScratchRunTool = class {
|
|
|
48197
48227
|
const run3 = d.run ?? runShellCaptured;
|
|
48198
48228
|
const command = buildSingleFileCommand(fileCommand, parsed.path);
|
|
48199
48229
|
const reportBefore = (d.findReport ?? findJUnitReport)(d.root);
|
|
48200
|
-
const preserve = reportBefore ? [(0,
|
|
48230
|
+
const preserve = reportBefore ? [(0, import_node_path19.relative)(d.root, reportBefore).split("\\").join("/")] : [];
|
|
48201
48231
|
this.calls += 1;
|
|
48202
48232
|
const startedAt = now();
|
|
48203
48233
|
let ran;
|
|
@@ -48243,17 +48273,16 @@ var MAX_CALLS_IN_ALL = 40;
|
|
|
48243
48273
|
var MAX_NOTE_CHARS = 500;
|
|
48244
48274
|
var MAX_PATH_CHARS3 = 300;
|
|
48245
48275
|
var MAX_REASON_CHARS = 200;
|
|
48246
|
-
var isRecord2 = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
|
|
48247
48276
|
var count3 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5, Math.max(0, n)) : 0;
|
|
48248
48277
|
function callOf(call, result) {
|
|
48249
48278
|
if (!result) return null;
|
|
48250
|
-
const args2 =
|
|
48279
|
+
const args2 = isPlainObject(call.args) ? call.args : {};
|
|
48251
48280
|
const named2 = typeof args2.path === "string" ? args2.path : call.name === "run_tests" && typeof args2.file === "string" ? args2.file : void 0;
|
|
48252
48281
|
const out2 = { tool: call.name, status: result.status };
|
|
48253
48282
|
if (named2 && named2.length > 0 && named2.length <= MAX_PATH_CHARS3) out2.path = named2;
|
|
48254
48283
|
if (typeof result.reason === "string" && result.reason.length > 0) out2.reason = result.reason.slice(0, MAX_REASON_CHARS);
|
|
48255
48284
|
const o = result.output;
|
|
48256
|
-
if (call.name === "run_tests" &&
|
|
48285
|
+
if (call.name === "run_tests" && isPlainObject(o) && typeof o.passed === "number" && typeof o.failed === "number") {
|
|
48257
48286
|
out2.tests = { passed: count3(o.passed), failed: count3(o.failed), regressions: count3(o.regressions), newFailures: count3(o.newFailures) };
|
|
48258
48287
|
if (o.scope === "file") out2.scope = "file";
|
|
48259
48288
|
}
|
|
@@ -48261,7 +48290,7 @@ function callOf(call, result) {
|
|
|
48261
48290
|
}
|
|
48262
48291
|
function pythonJsonLength(value) {
|
|
48263
48292
|
if (Array.isArray(value)) return value.length === 0 ? 2 : 2 + value.reduce((n, v) => n + pythonJsonLength(v), 0) + 2 * (value.length - 1);
|
|
48264
|
-
if (
|
|
48293
|
+
if (isPlainObject(value)) {
|
|
48265
48294
|
const entries = Object.entries(value).filter(([, v]) => v !== void 0);
|
|
48266
48295
|
if (entries.length === 0) return 2;
|
|
48267
48296
|
return 2 + entries.reduce((n, [k, v]) => n + JSON.stringify(k).length + 2 + pythonJsonLength(v), 0) + 2 * (entries.length - 1);
|
|
@@ -48290,7 +48319,7 @@ function stepsOf(transcript, toolResults) {
|
|
|
48290
48319
|
|
|
48291
48320
|
// src/importCheck.ts
|
|
48292
48321
|
var MAX_REPORTED = 5;
|
|
48293
|
-
function
|
|
48322
|
+
function resolve3(fromPath, spec, exists) {
|
|
48294
48323
|
const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
|
|
48295
48324
|
const out2 = [];
|
|
48296
48325
|
for (const part of [...dir ? dir.split("/") : [], ...spec.split("/")]) {
|
|
@@ -48398,7 +48427,7 @@ function missingImports(changed, read, exists) {
|
|
|
48398
48427
|
const parsed = parseProgram(path, text3);
|
|
48399
48428
|
if (!parsed || parsed.sourceType !== "module") continue;
|
|
48400
48429
|
for (const [name2, spec] of relativeImports(parsed.ast)) {
|
|
48401
|
-
const target =
|
|
48430
|
+
const target = resolve3(path, spec, exists);
|
|
48402
48431
|
if (!target) continue;
|
|
48403
48432
|
if (!exportsOf.has(target)) {
|
|
48404
48433
|
const t = read(target);
|
|
@@ -48630,26 +48659,10 @@ function proofSentences(proof) {
|
|
|
48630
48659
|
return out2.map((s) => s.length > 300 ? `${s.slice(0, 299)}\u2026` : s);
|
|
48631
48660
|
}
|
|
48632
48661
|
|
|
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
48662
|
// src/dataPathCheck.ts
|
|
48650
48663
|
var import_node_child_process10 = require("node:child_process");
|
|
48651
48664
|
var import_node_fs17 = require("node:fs");
|
|
48652
|
-
var
|
|
48665
|
+
var import_node_path20 = require("node:path");
|
|
48653
48666
|
|
|
48654
48667
|
// src/scopeCheck.ts
|
|
48655
48668
|
var import_node_fs16 = require("node:fs");
|
|
@@ -48881,7 +48894,7 @@ function screenLoaders(cwd, screen, read, skip, expired) {
|
|
|
48881
48894
|
function readFromCheckout(root) {
|
|
48882
48895
|
return (path) => {
|
|
48883
48896
|
try {
|
|
48884
|
-
const abs = (0,
|
|
48897
|
+
const abs = (0, import_node_path20.join)(root, path);
|
|
48885
48898
|
const st = (0, import_node_fs17.lstatSync)(abs);
|
|
48886
48899
|
return st.isSymbolicLink() || !st.isFile() || st.size > MAX_FILE_CHARS2 ? null : (0, import_node_fs17.readFileSync)(abs, "utf8");
|
|
48887
48900
|
} catch {
|
|
@@ -49080,24 +49093,8 @@ var SafetyRefusalError = class extends RuntimeReplyError {
|
|
|
49080
49093
|
var NO_FALLBACK_CODES = /* @__PURE__ */ new Set(["RUN_BUDGET_EXCEEDED", "RUN_CREDENTIAL_SCOPE"]);
|
|
49081
49094
|
var OUTPUT_TOO_LARGE_CODES = /* @__PURE__ */ new Set(["CODEGEN_OUTPUT_TOO_LARGE", "OUTPUT_TRUNCATED"]);
|
|
49082
49095
|
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
49096
|
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);
|
|
49097
|
+
return new LoopFailure(transportReason(err2), void 0, err2);
|
|
49101
49098
|
}
|
|
49102
49099
|
async function runTargetingLoop(args2, deps) {
|
|
49103
49100
|
const limits = { ...DEFAULT_LIMITS, ...deps.limits };
|
|
@@ -49268,18 +49265,9 @@ async function runTargetingLoop(args2, deps) {
|
|
|
49268
49265
|
}
|
|
49269
49266
|
if (body2.outcome !== "TOOL_CALLS") throw new LoopFailure("bad_reply");
|
|
49270
49267
|
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
|
-
}
|
|
49268
|
+
const parsed = parseToolCalls(body2.toolCalls, usedIds);
|
|
49269
|
+
if (typeof parsed === "string") throw new LoopFailure(parsed);
|
|
49270
|
+
const calls = parsed.calls;
|
|
49283
49271
|
for (const c of calls) usedIds.add(c.id);
|
|
49284
49272
|
const results = [];
|
|
49285
49273
|
const logged = [];
|
|
@@ -49569,9 +49557,6 @@ var PROPOSAL_SENTENCES = {
|
|
|
49569
49557
|
undo: `${NOT_RECORDED} "undo" must be text of at most 4,000 characters.`,
|
|
49570
49558
|
apply: `${NOT_RECORDED} "apply" must be text of at most 300 characters.`
|
|
49571
49559
|
};
|
|
49572
|
-
function isRecord3(x) {
|
|
49573
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
49574
|
-
}
|
|
49575
49560
|
function cleanPath(value) {
|
|
49576
49561
|
if (value.length > MAX_PATH_CHARS4) return false;
|
|
49577
49562
|
const n = normaliseToolPath(value);
|
|
@@ -49586,7 +49571,7 @@ function readProposal(text3, partIds) {
|
|
|
49586
49571
|
} catch {
|
|
49587
49572
|
return fail(PROPOSAL_SENTENCES.notJson);
|
|
49588
49573
|
}
|
|
49589
|
-
if (!
|
|
49574
|
+
if (!isPlainObject(raw)) return fail(PROPOSAL_SENTENCES.notJson);
|
|
49590
49575
|
const keys = Object.keys(raw);
|
|
49591
49576
|
if (keys.some((k) => !KEYS.includes(k))) return fail(PROPOSAL_SENTENCES.keys);
|
|
49592
49577
|
for (const k of ["parts", "additive", "schemaFile", "migrationFile", "migration"]) if (!keys.includes(k)) return fail(PROPOSAL_SENTENCES.keys);
|
|
@@ -49693,7 +49678,7 @@ function namesSentence(names) {
|
|
|
49693
49678
|
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
49679
|
}
|
|
49695
49680
|
function namesNote(args2) {
|
|
49696
|
-
if (!
|
|
49681
|
+
if (!isPlainObject(args2) || typeof args2.path !== "string") return false;
|
|
49697
49682
|
const n = normaliseToolPath(args2.path);
|
|
49698
49683
|
return n.ok && n.path === DATABASE_CHANGE_PATH;
|
|
49699
49684
|
}
|
|
@@ -49792,9 +49777,6 @@ var MAX_NAME_CHARS3 = 150;
|
|
|
49792
49777
|
var MAX_WHAT_CHARS = 300;
|
|
49793
49778
|
var PART_ID_RE = /^P\d+$/;
|
|
49794
49779
|
var MARKER_RE = /\[(P\d+)(?:=(exists|proposed))?\]/g;
|
|
49795
|
-
function isRecord4(x) {
|
|
49796
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
49797
|
-
}
|
|
49798
49780
|
function cutTo(text3, max) {
|
|
49799
49781
|
if (text3.length <= max) return text3;
|
|
49800
49782
|
const last = text3.charCodeAt(max - 1);
|
|
@@ -49803,14 +49785,14 @@ function cutTo(text3, max) {
|
|
|
49803
49785
|
}
|
|
49804
49786
|
function partsFromDesignCut(design) {
|
|
49805
49787
|
const none = { parts: [], cut: 0 };
|
|
49806
|
-
if (!
|
|
49788
|
+
if (!isPlainObject(design) || !Array.isArray(design.parts)) return none;
|
|
49807
49789
|
const raw = design.parts;
|
|
49808
49790
|
if (raw.length === 0 || raw.length > MAX_PARTS) return none;
|
|
49809
49791
|
const out2 = [];
|
|
49810
49792
|
const ids = /* @__PURE__ */ new Set();
|
|
49811
49793
|
let cut2 = 0;
|
|
49812
49794
|
for (const p of raw) {
|
|
49813
|
-
if (!
|
|
49795
|
+
if (!isPlainObject(p)) return none;
|
|
49814
49796
|
const { id, kind, name: name2, what } = p;
|
|
49815
49797
|
if (typeof id !== "string" || !PART_ID_RE.test(id) || ids.has(id)) return none;
|
|
49816
49798
|
if (typeof kind !== "string" || !PART_KINDS.includes(kind)) return none;
|
|
@@ -49998,7 +49980,6 @@ var MAX_CRITERION_ID_CHARS = 40;
|
|
|
49998
49980
|
var MAX_STATEMENT_CHARS = 500;
|
|
49999
49981
|
var MAX_QUOTE_CHARS2 = 200;
|
|
50000
49982
|
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
49983
|
var strings = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string") : [];
|
|
50003
49984
|
var oneLine2 = (s, max) => s.trim() !== "" && s.length <= max && !/[\r\n]/.test(s);
|
|
50004
49985
|
var unique3 = (xs) => [...new Set(xs)];
|
|
@@ -50011,7 +49992,7 @@ function cleanAddress(a) {
|
|
|
50011
49992
|
}
|
|
50012
49993
|
function prepareTicketHints(raw, listing, deniedPaths) {
|
|
50013
49994
|
const counts = { files: 0, routes: 0, routeFiles: 0, names: 0, tests: 0, dropped: 0 };
|
|
50014
|
-
if (!
|
|
49995
|
+
if (!isPlainObject(raw)) return { counts };
|
|
50015
49996
|
const listed = listing instanceof Set ? listing : new Set(listing);
|
|
50016
49997
|
const denied = [...deniedPaths];
|
|
50017
49998
|
const usable = (p) => cleanPath2(p) && listed.has(p) && matchesDeniedPath(p, denied) === null;
|
|
@@ -50027,7 +50008,7 @@ function prepareTicketHints(raw, listing, deniedPaths) {
|
|
|
50027
50008
|
const seen = /* @__PURE__ */ new Set();
|
|
50028
50009
|
for (const r of Array.isArray(raw.routes) ? raw.routes : []) {
|
|
50029
50010
|
if (routes.length >= MAX_HINT_ROUTES) break;
|
|
50030
|
-
if (!
|
|
50011
|
+
if (!isPlainObject(r) || typeof r.address !== "string") continue;
|
|
50031
50012
|
const address = r.address.trim();
|
|
50032
50013
|
if (!cleanAddress(address)) continue;
|
|
50033
50014
|
const method = typeof r.method === "string" && METHODS.has(r.method.toUpperCase()) ? r.method.toUpperCase() : void 0;
|
|
@@ -50059,7 +50040,7 @@ function prepareCriteriaWording(raw) {
|
|
|
50059
50040
|
const out2 = [];
|
|
50060
50041
|
for (const c of raw) {
|
|
50061
50042
|
if (out2.length >= MAX_CRITERIA) break;
|
|
50062
|
-
if (!
|
|
50043
|
+
if (!isPlainObject(c) || typeof c.id !== "string" || typeof c.statement !== "string") continue;
|
|
50063
50044
|
const id = c.id.trim();
|
|
50064
50045
|
const statement = c.statement.trim().slice(0, MAX_STATEMENT_CHARS).trim();
|
|
50065
50046
|
if (!oneLine2(id, MAX_CRITERION_ID_CHARS) || statement === "") continue;
|
|
@@ -50207,23 +50188,15 @@ function withUnreportable(stop2, tests) {
|
|
|
50207
50188
|
if (stop2.summary) carried.summary = stop2.summary;
|
|
50208
50189
|
return carried;
|
|
50209
50190
|
}
|
|
50210
|
-
var MAX_ID_CHARS2 = 64;
|
|
50211
50191
|
var MAX_RED_REFUSALS = 1;
|
|
50212
50192
|
var NOTHING_NEW = /* @__PURE__ */ new Set(["duplicate", "no_effect", "no_change_since_last_run", "no_match", "ambiguous", "conflict_rejected"]);
|
|
50213
50193
|
var HARNESS_NO_PROGRESS_TURNS = 3;
|
|
50214
|
-
var MAX_CALLS_IN_A_REPLY2 = 50;
|
|
50215
50194
|
var MAX_SUMMARY_CHARS = 300;
|
|
50216
50195
|
var READ_TOOLS = /* @__PURE__ */ new Set(["list_files", "read_file", "grep", "find_definition", "show_changes"]);
|
|
50217
50196
|
var WRITE_TOOLS = /* @__PURE__ */ new Set(["edit_file", "write_file"]);
|
|
50218
50197
|
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
50198
|
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);
|
|
50199
|
+
return new CodegenLoopFailure(transportReason(err2), void 0, err2);
|
|
50227
50200
|
}
|
|
50228
50201
|
function previousForLoop2(withSteps) {
|
|
50229
50202
|
const { steps: _steps, stepsTrimmed: _trimmed, ...previous } = withSteps;
|
|
@@ -50241,8 +50214,10 @@ function previousForLoop2(withSteps) {
|
|
|
50241
50214
|
return { ...previous, lastTestRun: Object.keys(messages).length > 0 ? { ...rest, messages } : rest };
|
|
50242
50215
|
}
|
|
50243
50216
|
function isTestAnswer(x) {
|
|
50244
|
-
return
|
|
50217
|
+
return isPlainObject(x) && typeof x.passed === "number" && Array.isArray(x.failingTests);
|
|
50245
50218
|
}
|
|
50219
|
+
var ENTRY_INDENT = 6;
|
|
50220
|
+
var roomCountCheck = { enabled: false };
|
|
50246
50221
|
var DROPPED_OUTPUT = { dropped: true, note: "Dropped to keep the request small. Read the file again if you need it." };
|
|
50247
50222
|
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
50223
|
var DROP_NOTES = /* @__PURE__ */ new Set([DROPPED_OUTPUT.note, DROPPED_UNSEEN_OUTPUT.note]);
|
|
@@ -50547,7 +50522,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
50547
50522
|
...usage.totals.calls > 0 ? { turnUsage: usage.rows.map((r) => ({ ...r, parts: { ...r.parts } })), usage: { ...usage.totals } } : {},
|
|
50548
50523
|
...usage.rowsCut ? { turnUsageCut: true } : {}
|
|
50549
50524
|
});
|
|
50550
|
-
const dropOutputs = (upTo, done, output, keep) => {
|
|
50525
|
+
const dropOutputs = (upTo, done, output, keep, onReplace) => {
|
|
50551
50526
|
const lastTestRun = toolResults.map((r) => r.name).lastIndexOf(RUN_TESTS_TOOL);
|
|
50552
50527
|
const lastCall = toolResults.map((r) => r.name).lastIndexOf(CALL_FUNCTION_TOOL);
|
|
50553
50528
|
const lastScratch = toolResults.map((r) => r.name).lastIndexOf(RUN_SCRATCH_TOOL);
|
|
@@ -50559,29 +50534,54 @@ async function runCodegenLoop(args2, deps) {
|
|
|
50559
50534
|
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
50535
|
if (!stale) continue;
|
|
50561
50536
|
toolResults[i3] = shrunkAnswer(r, output);
|
|
50537
|
+
onReplace?.(r, toolResults[i3]);
|
|
50562
50538
|
dropped++;
|
|
50563
50539
|
}
|
|
50564
50540
|
return dropped;
|
|
50565
50541
|
};
|
|
50566
50542
|
const makeRoom = (nextTurn, nextFinal, finalReason) => {
|
|
50567
|
-
const
|
|
50543
|
+
const whole4 = () => classCounts(JSON.stringify(buildContext(nextTurn, nextFinal, finalReason) ?? {}, null, 2));
|
|
50544
|
+
let counts = whole4();
|
|
50545
|
+
const replaced = (before, after) => {
|
|
50546
|
+
const b = JSON.stringify(before, null, 2);
|
|
50547
|
+
const a = JSON.stringify(after, null, 2);
|
|
50548
|
+
const cb = classCounts(b);
|
|
50549
|
+
const ca = classCounts(a);
|
|
50550
|
+
const newlines = (s) => s.split("\n").length - 1;
|
|
50551
|
+
counts = {
|
|
50552
|
+
alpha: counts.alpha - cb.alpha + ca.alpha,
|
|
50553
|
+
digit: counts.digit - cb.digit + ca.digit,
|
|
50554
|
+
space: counts.space - cb.space + ca.space + ENTRY_INDENT * (newlines(a) - newlines(b)),
|
|
50555
|
+
punct: counts.punct - cb.punct + ca.punct,
|
|
50556
|
+
nonAscii: counts.nonAscii - cb.nonAscii + ca.nonAscii
|
|
50557
|
+
};
|
|
50558
|
+
};
|
|
50559
|
+
const under = (limit) => {
|
|
50560
|
+
if (roomCountCheck.enabled) {
|
|
50561
|
+
const full = whole4();
|
|
50562
|
+
if (JSON.stringify(full) !== JSON.stringify(counts)) throw new Error(`makeRoom's running count drifted: ${JSON.stringify(counts)} vs ${JSON.stringify(full)}`);
|
|
50563
|
+
}
|
|
50564
|
+
return PROMPT_OVERHEAD_TOKENS + tokensFrom(counts) <= limit;
|
|
50565
|
+
};
|
|
50568
50566
|
const fits = () => under(limits.maxRequestTokens);
|
|
50569
50567
|
const soft = args2.readRoots ? mapSoftTarget(firstRequestTokens, limits.maxRequestTokens) : limits.maxRequestTokens;
|
|
50570
50568
|
if (under(soft)) return true;
|
|
50571
|
-
dropOutputs(sent.results, () => under(soft), DROPPED_OUTPUT, keepOn ? tracker.keep(outputOf) : void 0);
|
|
50569
|
+
dropOutputs(sent.results, () => under(soft), DROPPED_OUTPUT, keepOn ? tracker.keep(outputOf) : void 0, replaced);
|
|
50572
50570
|
for (const key of [...ledger.seen.keys()]) {
|
|
50573
50571
|
if (key.startsWith("read_file:") || key.startsWith("grep:") || key.startsWith("list_files:") || key.startsWith("show_changes:")) ledger.seen.delete(key);
|
|
50574
50572
|
}
|
|
50575
50573
|
for (const entry of transcript) {
|
|
50576
50574
|
if (fits()) break;
|
|
50575
|
+
const before = { ...entry };
|
|
50577
50576
|
entry.toolCalls = entry.toolCalls.map((c) => {
|
|
50578
|
-
if (!WRITE_TOOLS.has(c.name) || !
|
|
50577
|
+
if (!WRITE_TOOLS.has(c.name) || !isPlainObject(c.args) || "_omitted" in c.args) return c;
|
|
50579
50578
|
const path = typeof c.args.path === "string" ? { path: c.args.path } : {};
|
|
50580
50579
|
return { ...c, args: { ...path, _omitted: "written earlier; read the file to see it" } };
|
|
50581
50580
|
});
|
|
50581
|
+
replaced(before, entry);
|
|
50582
50582
|
}
|
|
50583
50583
|
if (fits()) return true;
|
|
50584
|
-
const unseen = dropOutputs(toolResults.length, fits, DROPPED_UNSEEN_OUTPUT);
|
|
50584
|
+
const unseen = dropOutputs(toolResults.length, fits, DROPPED_UNSEEN_OUTPUT, void 0, replaced);
|
|
50585
50585
|
if (unseen > 0) log({ event: "codegen.read_dropped_unseen", turn: nextTurn - 1, outputs: unseen, ceiling: limits.maxRequestTokens });
|
|
50586
50586
|
return fits();
|
|
50587
50587
|
};
|
|
@@ -51096,16 +51096,9 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51096
51096
|
}
|
|
51097
51097
|
if (body2.outcome !== "TOOL_CALLS") throw new CodegenLoopFailure("bad_reply");
|
|
51098
51098
|
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
|
-
}
|
|
51099
|
+
const parsed = parseToolCalls(body2.toolCalls, usedIds);
|
|
51100
|
+
if (typeof parsed === "string") throw new CodegenLoopFailure(parsed);
|
|
51101
|
+
const calls = parsed.calls;
|
|
51109
51102
|
for (const c of calls) usedIds.add(c.id);
|
|
51110
51103
|
const results = [];
|
|
51111
51104
|
const logged = [];
|
|
@@ -51171,7 +51164,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51171
51164
|
if (hinted.outcome === "added") result = { ...result, message: hinted.message };
|
|
51172
51165
|
}
|
|
51173
51166
|
results.push(result);
|
|
51174
|
-
if (call.name === "read_file" &&
|
|
51167
|
+
if (call.name === "read_file" && isPlainObject(call.args) && typeof call.args.path === "string" && (result.status === "ok" || result.status === "duplicate")) {
|
|
51175
51168
|
const entry = { id: call.id, turn, path: call.args.path, ...rangeOf(call.args) };
|
|
51176
51169
|
const again = tracker.reread(entry, result.status === "duplicate", (id) => results.find((x) => x.id === id)?.output ?? outputOf(id), DROP_NOTES);
|
|
51177
51170
|
if (again) {
|
|
@@ -51182,7 +51175,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51182
51175
|
}
|
|
51183
51176
|
tracker.noteRead(entry);
|
|
51184
51177
|
}
|
|
51185
|
-
if (!noted && (WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" &&
|
|
51178
|
+
if (!noted && (WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" && isPlainObject(call.args) && typeof call.args.path === "string") {
|
|
51186
51179
|
tracker.noteWrite(call.args.path, turn);
|
|
51187
51180
|
}
|
|
51188
51181
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0) {
|
|
@@ -51190,15 +51183,15 @@ async function runCodegenLoop(args2, deps) {
|
|
|
51190
51183
|
lastTestVersion = versionOfFiles(filesOnDisk());
|
|
51191
51184
|
}
|
|
51192
51185
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
|
|
51193
|
-
const file = result.output.scope === "file" &&
|
|
51186
|
+
const file = result.output.scope === "file" && isPlainObject(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
|
|
51194
51187
|
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" &&
|
|
51188
|
+
} 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
51189
|
redRuns.push({ version: versionOfFiles(filesOnDisk()), file: call.args.file, failing: [], truncated: false, fileFailed: true });
|
|
51197
51190
|
}
|
|
51198
51191
|
if (read) reads.push(read);
|
|
51199
51192
|
statusCounts[result.status] = (statusCounts[result.status] ?? 0) + 1;
|
|
51200
51193
|
const tool = TOOL_NAMES2.has(call.name) ? call.name : "unknown";
|
|
51201
|
-
const pathArg =
|
|
51194
|
+
const pathArg = isPlainObject(call.args) && typeof call.args.path === "string" && result.status !== "refused" ? { path: call.args.path } : {};
|
|
51202
51195
|
const rangeArg = call.name === "read_file" && result.status !== "refused" ? rangeOf(call.args) : {};
|
|
51203
51196
|
logged.push({ tool, status: result.status, ...result.reason && result.status !== "duplicate" ? { reason: result.reason } : {}, ...pathArg, ...rangeArg });
|
|
51204
51197
|
if (result.status === "refused" || result.status === "protected") {
|
|
@@ -51291,8 +51284,8 @@ function frozenFailingTarget(failingTests, frozen, textOf2) {
|
|
|
51291
51284
|
const file = fileOf(name2);
|
|
51292
51285
|
const candidates = frozen.filter((path) => idPlaceMatches(file, path));
|
|
51293
51286
|
if (candidates.length === 1) return { failing, amend: candidates[0] };
|
|
51294
|
-
const
|
|
51295
|
-
const testName = (
|
|
51287
|
+
const sep2 = name2.indexOf("::");
|
|
51288
|
+
const testName = (sep2 >= 0 ? name2.slice(sep2 + 2) : name2).replace(QP_TOKEN, "").trim();
|
|
51296
51289
|
const owners = candidates.filter((path) => definesTest(textOf2(path) ?? "", testName));
|
|
51297
51290
|
return { failing, amend: owners.length === 1 ? owners[0] : null };
|
|
51298
51291
|
}
|
|
@@ -51745,7 +51738,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
51745
51738
|
}
|
|
51746
51739
|
|
|
51747
51740
|
// src/langReach.ts
|
|
51748
|
-
var
|
|
51741
|
+
var import_node_path21 = require("node:path");
|
|
51749
51742
|
var LANGUAGE_BY_EXT = {
|
|
51750
51743
|
".go": "go",
|
|
51751
51744
|
".py": "python",
|
|
@@ -51761,7 +51754,7 @@ var LANGUAGE_BY_EXT = {
|
|
|
51761
51754
|
".swift": "swift"
|
|
51762
51755
|
};
|
|
51763
51756
|
function languageOf(path) {
|
|
51764
|
-
return LANGUAGE_BY_EXT[
|
|
51757
|
+
return LANGUAGE_BY_EXT[import_node_path21.posix.extname(path).toLowerCase()] ?? null;
|
|
51765
51758
|
}
|
|
51766
51759
|
var MAX_REACH_TESTS = 10;
|
|
51767
51760
|
var MAX_IMPORT_STEPS = 3;
|
|
@@ -51785,14 +51778,14 @@ function lookSymbolsOf(findings) {
|
|
|
51785
51778
|
for (const c of findings.callPath) add2(c.path, c.symbol);
|
|
51786
51779
|
return out2;
|
|
51787
51780
|
}
|
|
51788
|
-
var baseNoExt = (p) =>
|
|
51789
|
-
var dirOf = (p) =>
|
|
51781
|
+
var baseNoExt = (p) => import_node_path21.posix.basename(p).replace(/\.[^.]+$/, "");
|
|
51782
|
+
var dirOf = (p) => import_node_path21.posix.dirname(p) === "." ? "" : import_node_path21.posix.dirname(p);
|
|
51790
51783
|
function testStem(path) {
|
|
51791
51784
|
return baseNoExt(path).replace(/^test_/i, "").replace(/(_test|_spec)$/i, "").replace(/Tests?$/, "").toLowerCase();
|
|
51792
51785
|
}
|
|
51793
51786
|
function codeStem(path) {
|
|
51794
51787
|
const b = baseNoExt(path);
|
|
51795
|
-
if (b === "__init__" || b === "mod" || b === "index") return
|
|
51788
|
+
if (b === "__init__" || b === "mod" || b === "index") return import_node_path21.posix.basename(dirOf(path)).toLowerCase();
|
|
51796
51789
|
return b.toLowerCase();
|
|
51797
51790
|
}
|
|
51798
51791
|
function sharedPrefix2(a, b) {
|
|
@@ -51875,7 +51868,7 @@ function buildIndex(files, readText) {
|
|
|
51875
51868
|
}
|
|
51876
51869
|
}
|
|
51877
51870
|
let goModule = null;
|
|
51878
|
-
const gomod = files.filter((f) =>
|
|
51871
|
+
const gomod = files.filter((f) => import_node_path21.posix.basename(f) === "go.mod").sort((a, b) => a.length - b.length)[0];
|
|
51879
51872
|
if (gomod) {
|
|
51880
51873
|
const m = /^module[ \t]+(\S+)/m.exec(readText(gomod) ?? "");
|
|
51881
51874
|
if (m) goModule = { root: dirOf(gomod), module: m[1].replace(/^"|"$/g, "") };
|
|
@@ -51890,7 +51883,7 @@ function pythonImports(file, text3, ix) {
|
|
|
51890
51883
|
const relative14 = (dots, rest) => {
|
|
51891
51884
|
let base = dirOf(file);
|
|
51892
51885
|
for (let i3 = 1; i3 < dots; i3++) base = dirOf(base);
|
|
51893
|
-
const joined = rest ?
|
|
51886
|
+
const joined = rest ? import_node_path21.posix.join(base, rest.replace(/\./g, "/")) : base;
|
|
51894
51887
|
return [`${joined}.py`, `${joined}/__init__.py`].filter((p) => ix.set.has(p) && p !== file);
|
|
51895
51888
|
};
|
|
51896
51889
|
for (const line2 of text3.split("\n")) {
|
|
@@ -51930,7 +51923,7 @@ function goImports(file, text3, ix) {
|
|
|
51930
51923
|
let dir = null;
|
|
51931
51924
|
if (ix.goModule && (p === ix.goModule.module || p.startsWith(`${ix.goModule.module}/`))) {
|
|
51932
51925
|
const rest = p.slice(ix.goModule.module.length).replace(/^\//, "");
|
|
51933
|
-
dir = ix.goModule.root ?
|
|
51926
|
+
dir = ix.goModule.root ? import_node_path21.posix.join(ix.goModule.root, rest) : rest;
|
|
51934
51927
|
} else {
|
|
51935
51928
|
const tail2 = p.split("/").slice(-2).join("/");
|
|
51936
51929
|
for (const d of ix.byDir.keys()) if (d === tail2 || d.endsWith(`/${tail2}`)) {
|
|
@@ -51981,7 +51974,7 @@ function importsOf(language, file, text3, ix) {
|
|
|
51981
51974
|
if (language === "jvm") return jvmImports(file, text3, ix);
|
|
51982
51975
|
return [];
|
|
51983
51976
|
}
|
|
51984
|
-
var isPackageInit = (p) =>
|
|
51977
|
+
var isPackageInit = (p) => import_node_path21.posix.basename(p) === "__init__.py";
|
|
51985
51978
|
function testsReaching(input) {
|
|
51986
51979
|
const limit = Math.min(MAX_REACH_TESTS, Math.max(0, input.limit ?? MAX_REACH_TESTS));
|
|
51987
51980
|
const listing = input.isDenied ? input.listing.filter((p) => !input.isDenied(p)) : [...input.listing];
|
|
@@ -52701,75 +52694,73 @@ async function runCodegenStep(p) {
|
|
|
52701
52694
|
log({ event: "codegen.attempt_start", attempt: 1 });
|
|
52702
52695
|
const firstStarted = now();
|
|
52703
52696
|
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
52697
|
const databaseStop = (failure, why) => {
|
|
52719
52698
|
const stop2 = storedStop(p.databaseChange ?? []);
|
|
52720
52699
|
log({ event: "codegen.database_change_refused", ids: stop2.ids, ...why === "no_harness" ? { why } : {} });
|
|
52721
52700
|
p.out.loop = buildCodegenLoopRecord({ ...failure.summary ?? NO_SUMMARY, stopReason: "failed" });
|
|
52722
52701
|
return new PartsStopError(stop2);
|
|
52723
52702
|
};
|
|
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
|
-
|
|
52703
|
+
const notLate = (f) => f.late !== true;
|
|
52704
|
+
const FALLBACKS = [
|
|
52705
|
+
// QUIKTR-2509: `criteriaWording` first: asked the SAME version again without it, so an older AI Runtime never costs the run a version.
|
|
52706
|
+
{ when: (f) => f.criteriaKey === true && !!p.criteriaWording, kind: "retry", logged: () => ({ from: "criteria_wording" }), change: () => p.criteriaWording = void 0, from: "where_it_was" },
|
|
52707
|
+
// QUIKTR-2442: the same for `featureTestUpdates`, from where the attempt was (the tests phase is kept).
|
|
52708
|
+
{ when: (f) => f.featureKey === true && p.featureTestUpdates === true, kind: "retry", logged: () => ({ from: "feature_test_updates" }), change: () => p.featureTestUpdates = false, from: "where_it_was" },
|
|
52709
|
+
{ when: (f) => f.databaseKey === true && !!p.databaseChange && p.databaseChange.length > 0, kind: "stop", stop: (f) => databaseStop(f, "key_refused") },
|
|
52710
|
+
{ 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" },
|
|
52711
|
+
{ 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" },
|
|
52712
|
+
{ 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" },
|
|
52713
|
+
{
|
|
52714
|
+
when: (f) => notLate(f) && p.tools2?.notes === true && args2?.harness === true,
|
|
52715
|
+
kind: "retry",
|
|
52716
|
+
logged: () => ({ from: "codegen-loop-6", to: "codegen-loop-5" }),
|
|
52717
|
+
change: () => p.tools2 = { ...p.tools2, notes: false },
|
|
52718
|
+
from: "scratch"
|
|
52719
|
+
},
|
|
52720
|
+
{
|
|
52721
|
+
when: (f) => notLate(f) && !!p.tools2 && args2?.harness === true,
|
|
52722
|
+
kind: "retry",
|
|
52723
|
+
logged: () => ({ from: "codegen-loop-5", to: p.scope?.view === "map" ? "codegen-loop-4" : "codegen-loop-3" }),
|
|
52724
|
+
change: () => p.tools2 = void 0,
|
|
52725
|
+
from: "scratch"
|
|
52726
|
+
},
|
|
52727
|
+
{
|
|
52728
|
+
when: (f) => notLate(f) && p.scope?.view === "map",
|
|
52729
|
+
kind: "stop",
|
|
52730
|
+
stop: (f) => {
|
|
52731
|
+
const view = repoViewOf(p.scope);
|
|
52732
|
+
p.out.loop = buildCodegenLoopRecord({
|
|
52733
|
+
...f.summary ?? NO_SUMMARY,
|
|
52734
|
+
stopReason: "map_failed",
|
|
52735
|
+
...view ? { repoView: { ...view, failReason: "contract_rejected" } } : {}
|
|
52736
|
+
});
|
|
52737
|
+
log({ event: "codegen.map_failed", reason: "contract_rejected" });
|
|
52738
|
+
return new MapModeError("codegen", "contract_rejected");
|
|
52739
|
+
}
|
|
52740
|
+
},
|
|
52741
|
+
{
|
|
52742
|
+
when: (f) => notLate(f) && args2?.harness === true,
|
|
52743
|
+
kind: "retry",
|
|
52744
|
+
// 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
|
|
52745
|
+
// it did before, rather than write code whose database change cannot be proposed.
|
|
52746
|
+
check: (f) => {
|
|
52747
|
+
if (p.databaseChange && p.databaseChange.length > 0) throw databaseStop(f, "no_harness");
|
|
52748
|
+
},
|
|
52749
|
+
logged: () => ({ from: "codegen-loop-3", to: "codegen-loop-2" }),
|
|
52750
|
+
// A fix attempt later in this run builds its request from the same parameters: it must not ask for loop-3 again either.
|
|
52751
|
+
change: () => p.harness = false,
|
|
52752
|
+
from: "scratch"
|
|
52753
|
+
}
|
|
52754
|
+
];
|
|
52755
|
+
for (const step of FALLBACKS) {
|
|
52756
|
+
if (!("failure" in first) || first.failure.reason !== "contract_rejected" || !step.when(first.failure)) continue;
|
|
52757
|
+
if (step.kind === "stop") throw step.stop(first.failure);
|
|
52758
|
+
step.check?.(first.failure);
|
|
52759
|
+
log({ event: "codegen.version_fallback", ...step.logged() });
|
|
52760
|
+
step.change();
|
|
52761
|
+
const kept = step.from === "where_it_was" && "tests" in first ? first.tests : void 0;
|
|
52771
52762
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52772
|
-
first = await attempt2();
|
|
52763
|
+
first = step.from === "where_it_was" ? await attempt2(void 0, 1, kept) : await attempt2();
|
|
52773
52764
|
}
|
|
52774
52765
|
const firstMs = now() - firstStarted;
|
|
52775
52766
|
if ("done" in first) {
|
|
@@ -53188,7 +53179,7 @@ async function runVerifyAndFix(p) {
|
|
|
53188
53179
|
// src/hunkCheck.ts
|
|
53189
53180
|
var import_node_child_process11 = require("node:child_process");
|
|
53190
53181
|
var import_node_fs19 = require("node:fs");
|
|
53191
|
-
var
|
|
53182
|
+
var import_node_path22 = require("node:path");
|
|
53192
53183
|
var MAX_REPORTED_HUNKS = 20;
|
|
53193
53184
|
function toFinding(r) {
|
|
53194
53185
|
if (r.unnecessary.length === 0) return void 0;
|
|
@@ -53266,7 +53257,7 @@ async function runHunkCheck(input) {
|
|
|
53266
53257
|
let slowestRunMs = input.baselineMs ?? 3e4;
|
|
53267
53258
|
const runOnce = async (c) => {
|
|
53268
53259
|
const reportBefore = findReport(input.root);
|
|
53269
|
-
const preserve = reportBefore ? [(0,
|
|
53260
|
+
const preserve = reportBefore ? [(0, import_node_path22.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
53270
53261
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
53271
53262
|
const startedWall = Date.now();
|
|
53272
53263
|
const startedAt = now();
|
|
@@ -53302,7 +53293,7 @@ async function runHunkCheck(input) {
|
|
|
53302
53293
|
};
|
|
53303
53294
|
const runRelated = async (c, plan, limitMs) => {
|
|
53304
53295
|
const reportBefore = findReport(input.root);
|
|
53305
|
-
const preserve = reportBefore ? [(0,
|
|
53296
|
+
const preserve = reportBefore ? [(0, import_node_path22.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
53306
53297
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
53307
53298
|
const startedAt = now();
|
|
53308
53299
|
result.relatedRuns += 1;
|
|
@@ -53447,7 +53438,7 @@ function healFailureSuffix(heal) {
|
|
|
53447
53438
|
|
|
53448
53439
|
// src/dependencyCheck.ts
|
|
53449
53440
|
var import_node_fs20 = require("node:fs");
|
|
53450
|
-
var
|
|
53441
|
+
var import_node_path23 = require("node:path");
|
|
53451
53442
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
53452
53443
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
53453
53444
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -53535,8 +53526,8 @@ function dependencyNames(pkg) {
|
|
|
53535
53526
|
]);
|
|
53536
53527
|
}
|
|
53537
53528
|
function readDeclaredDependencies(results, workspaceRoot) {
|
|
53538
|
-
const packageJsonPath = (0,
|
|
53539
|
-
const generated = results.find((r) => (0,
|
|
53529
|
+
const packageJsonPath = (0, import_node_path23.join)((0, import_node_path23.resolve)(workspaceRoot ?? "."), "package.json");
|
|
53530
|
+
const generated = results.find((r) => (0, import_node_path23.resolve)(r.targetPath) === packageJsonPath);
|
|
53540
53531
|
let raw;
|
|
53541
53532
|
if (generated) {
|
|
53542
53533
|
raw = generated.newContent;
|
|
@@ -53606,10 +53597,10 @@ function stripJsonComments(text3) {
|
|
|
53606
53597
|
return out2.replace(/,(\s*[}\]])/g, "$1");
|
|
53607
53598
|
}
|
|
53608
53599
|
function resolveAliasPrefixes(results, workspaceRoot) {
|
|
53609
|
-
const root = (0,
|
|
53600
|
+
const root = (0, import_node_path23.resolve)(workspaceRoot ?? ".");
|
|
53610
53601
|
for (const filename of ["tsconfig.json", "jsconfig.json"]) {
|
|
53611
|
-
const configPath = (0,
|
|
53612
|
-
const generated = results.find((r) => (0,
|
|
53602
|
+
const configPath = (0, import_node_path23.join)(root, filename);
|
|
53603
|
+
const generated = results.find((r) => (0, import_node_path23.resolve)(r.targetPath) === configPath);
|
|
53613
53604
|
let raw;
|
|
53614
53605
|
if (generated) {
|
|
53615
53606
|
raw = generated.newContent;
|
|
@@ -54012,7 +54003,7 @@ function describeVanishedTests(vanished) {
|
|
|
54012
54003
|
}
|
|
54013
54004
|
|
|
54014
54005
|
// src/verifyChange.ts
|
|
54015
|
-
var
|
|
54006
|
+
var import_node_path24 = require("node:path");
|
|
54016
54007
|
|
|
54017
54008
|
// src/packageUse.ts
|
|
54018
54009
|
var import_node_child_process13 = require("node:child_process");
|
|
@@ -54075,7 +54066,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
54075
54066
|
const depCheck = checkImportDependencies(results, readDeclaredDependencies(results, packet.workspaceRoot), resolveAliasPrefixes(results, packet.workspaceRoot), {
|
|
54076
54067
|
originalOf: (path) => {
|
|
54077
54068
|
try {
|
|
54078
|
-
return (0, import_node_fs22.readFileSync)((0,
|
|
54069
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path24.join)(cwd, path), "utf8");
|
|
54079
54070
|
} catch (err2) {
|
|
54080
54071
|
return err2.code === "ENOENT" ? "" : null;
|
|
54081
54072
|
}
|
|
@@ -54135,7 +54126,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
54135
54126
|
flushedAt = now();
|
|
54136
54127
|
if (undoable) {
|
|
54137
54128
|
const report = findJUnitReport(cwd);
|
|
54138
|
-
const ignore = report ? [(0,
|
|
54129
|
+
const ignore = report ? [(0, import_node_path24.relative)(cwd, report).split("\\").join("/")] : [];
|
|
54139
54130
|
const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
|
|
54140
54131
|
undo = () => flush.undo();
|
|
54141
54132
|
} else {
|
|
@@ -54249,7 +54240,7 @@ ${violations.join("\n")}`);
|
|
|
54249
54240
|
|
|
54250
54241
|
// src/run.ts
|
|
54251
54242
|
var import_node_fs27 = require("node:fs");
|
|
54252
|
-
var
|
|
54243
|
+
var import_node_path30 = require("node:path");
|
|
54253
54244
|
|
|
54254
54245
|
// src/mapMode.ts
|
|
54255
54246
|
var MAP_ENV = "QUIKPILOT_MAP";
|
|
@@ -54307,7 +54298,7 @@ function buildToolsV2Env(i3) {
|
|
|
54307
54298
|
}
|
|
54308
54299
|
|
|
54309
54300
|
// src/repoMap.ts
|
|
54310
|
-
var
|
|
54301
|
+
var import_node_path25 = require("node:path");
|
|
54311
54302
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
54312
54303
|
var MAX_FOLDERS = 200;
|
|
54313
54304
|
var MAX_LANGUAGES = 12;
|
|
@@ -54349,7 +54340,7 @@ function guidanceFiles(i3, perFile2, total) {
|
|
|
54349
54340
|
function languages2(listing) {
|
|
54350
54341
|
const counts = /* @__PURE__ */ new Map();
|
|
54351
54342
|
for (const p of listing) {
|
|
54352
|
-
const ext =
|
|
54343
|
+
const ext = import_node_path25.posix.extname(p).toLowerCase();
|
|
54353
54344
|
if (ext && ext.length <= 12) counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
54354
54345
|
}
|
|
54355
54346
|
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 +54356,7 @@ function testFacts(i3) {
|
|
|
54365
54356
|
const depth = i3.writeRoot === "" ? 0 : i3.writeRoot.split("/").length;
|
|
54366
54357
|
for (const t of tests) {
|
|
54367
54358
|
const parts2 = t.split("/");
|
|
54368
|
-
const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") :
|
|
54359
|
+
const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") : import_node_path25.posix.dirname(t);
|
|
54369
54360
|
byFolder.set(folder, (byFolder.get(folder) ?? 0) + 1);
|
|
54370
54361
|
}
|
|
54371
54362
|
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 +54466,7 @@ function buildRepoMap(i3) {
|
|
|
54475
54466
|
}
|
|
54476
54467
|
|
|
54477
54468
|
// src/workspacePackages.ts
|
|
54478
|
-
var
|
|
54469
|
+
var import_node_path26 = require("node:path");
|
|
54479
54470
|
var MAX_READ_ROOTS = 8;
|
|
54480
54471
|
function isObject2(x) {
|
|
54481
54472
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -54537,8 +54528,8 @@ function workspacePackages(readText, packageJsonPaths) {
|
|
|
54537
54528
|
const exclude = patterns.filter((p) => p.startsWith("!")).map((p) => globMatcher(p.slice(1)));
|
|
54538
54529
|
const out2 = [];
|
|
54539
54530
|
for (const file of packageJsonPaths) {
|
|
54540
|
-
if (
|
|
54541
|
-
const folder =
|
|
54531
|
+
if (import_node_path26.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
|
|
54532
|
+
const folder = import_node_path26.posix.dirname(file);
|
|
54542
54533
|
if (!include.some((re) => re.test(folder)) || exclude.some((re) => re.test(folder))) continue;
|
|
54543
54534
|
const text3 = readText(file);
|
|
54544
54535
|
const json = text3 === null ? null : parseJsonc(text3);
|
|
@@ -54653,10 +54644,10 @@ function resolveTargetingMode(env2 = process.env, packetSetting) {
|
|
|
54653
54644
|
|
|
54654
54645
|
// src/installationToken.ts
|
|
54655
54646
|
async function exchangeForInstallationToken(installationTokenUrl, runToken) {
|
|
54656
|
-
const res = await
|
|
54647
|
+
const res = await fetchWithin("The push token exchange", installationTokenUrl, {
|
|
54657
54648
|
method: "POST",
|
|
54658
54649
|
headers: { Authorization: `Bearer ${runToken}` }
|
|
54659
|
-
});
|
|
54650
|
+
}, SHORT_CALL_MS);
|
|
54660
54651
|
if (!res.ok) {
|
|
54661
54652
|
throw new Error(`Exchange installation token failed: ${await describeQuikTrackFailure(res)}`);
|
|
54662
54653
|
}
|
|
@@ -54680,9 +54671,9 @@ async function fetchGithubOidcToken(env2 = process.env) {
|
|
|
54680
54671
|
);
|
|
54681
54672
|
const separator = requestUrl.includes("?") ? "&" : "?";
|
|
54682
54673
|
const url = `${requestUrl}${separator}audience=${encodeURIComponent(QUIKPILOT_OIDC_AUDIENCE)}`;
|
|
54683
|
-
const res = await
|
|
54674
|
+
const res = await fetchWithin("The GitHub sign-in token request", url, {
|
|
54684
54675
|
headers: { Authorization: `Bearer ${requestToken}` }
|
|
54685
|
-
});
|
|
54676
|
+
}, SHORT_CALL_MS);
|
|
54686
54677
|
if (!res.ok) {
|
|
54687
54678
|
throw new Error(`Fetch GitHub OIDC token failed: ${res.status} ${res.statusText}`);
|
|
54688
54679
|
}
|
|
@@ -54794,9 +54785,9 @@ function describeOverlapWarnings(warnings) {
|
|
|
54794
54785
|
// src/packet.ts
|
|
54795
54786
|
async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
54796
54787
|
const url = `${packetUrl}?githubRunId=${encodeURIComponent(githubRunId)}`;
|
|
54797
|
-
const res = await
|
|
54788
|
+
const res = await fetchWithin("The work packet request", url, {
|
|
54798
54789
|
headers: { Authorization: `Bearer ${runToken}` }
|
|
54799
|
-
});
|
|
54790
|
+
}, SHORT_CALL_MS);
|
|
54800
54791
|
if (!res.ok) {
|
|
54801
54792
|
throw new Error(`Fetch work packet failed: ${await describeQuikTrackFailure(res)}`);
|
|
54802
54793
|
}
|
|
@@ -54804,8 +54795,31 @@ async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
|
54804
54795
|
if (body2.success !== true) {
|
|
54805
54796
|
throw new Error("Fetch work packet failed: response did not carry success:true");
|
|
54806
54797
|
}
|
|
54798
|
+
const wrong = packetShapeProblem(body2.data);
|
|
54799
|
+
if (wrong) throw new Error(`Fetch work packet failed: the packet is not the shape the runner expects (${wrong})`);
|
|
54807
54800
|
return body2.data;
|
|
54808
54801
|
}
|
|
54802
|
+
var isStringOrNull = (x) => x === void 0 || x === null || typeof x === "string";
|
|
54803
|
+
var isFiniteNumber = (x) => typeof x === "number" && Number.isFinite(x);
|
|
54804
|
+
function packetShapeProblem(data2) {
|
|
54805
|
+
if (typeof data2 !== "object" || data2 === null) return "data";
|
|
54806
|
+
const d = data2;
|
|
54807
|
+
const commands = d.commands;
|
|
54808
|
+
if (typeof commands !== "object" || commands === null) return "commands";
|
|
54809
|
+
for (const key of ["setup", "test", "lint", "format", "testFile", "e2e"]) if (!isStringOrNull(commands[key])) return `commands.${key}`;
|
|
54810
|
+
const guardrails = d.guardrails;
|
|
54811
|
+
if (typeof guardrails !== "object" || guardrails === null) return "guardrails";
|
|
54812
|
+
if (!Array.isArray(guardrails.deniedPaths) || !guardrails.deniedPaths.every((p) => typeof p === "string")) return "guardrails.deniedPaths";
|
|
54813
|
+
if (!isFiniteNumber(guardrails.maxWallClockMinutes)) return "guardrails.maxWallClockMinutes";
|
|
54814
|
+
if (!isFiniteNumber(guardrails.maxHealIterations)) return "guardrails.maxHealIterations";
|
|
54815
|
+
const gateway = d.gateway;
|
|
54816
|
+
if (typeof gateway !== "object" || gateway === null) return "gateway";
|
|
54817
|
+
if (typeof gateway.baseUrl !== "string") return "gateway.baseUrl";
|
|
54818
|
+
if (typeof gateway.token !== "string") return "gateway.token";
|
|
54819
|
+
if (!isStringOrNull(d.branch)) return "branch";
|
|
54820
|
+
if (!isStringOrNull(d.targetBranch)) return "targetBranch";
|
|
54821
|
+
return null;
|
|
54822
|
+
}
|
|
54809
54823
|
|
|
54810
54824
|
// src/runnerSwitches.ts
|
|
54811
54825
|
var RUNNER_SWITCHES = {
|
|
@@ -54862,17 +54876,17 @@ function writePhase0Marker(runId) {
|
|
|
54862
54876
|
// src/failureArtifact.ts
|
|
54863
54877
|
var import_node_child_process14 = require("node:child_process");
|
|
54864
54878
|
var import_node_fs24 = require("node:fs");
|
|
54865
|
-
var
|
|
54879
|
+
var import_node_path27 = require("node:path");
|
|
54866
54880
|
var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
54867
54881
|
var REPORT_COPY = "final-test-report.xml";
|
|
54868
54882
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
54869
54883
|
var MAX_FILES = 200;
|
|
54870
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
54884
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.91" : "dev";
|
|
54871
54885
|
function safeDestination(base, repoPath) {
|
|
54872
|
-
if (!repoPath || (0,
|
|
54873
|
-
const destination = (0,
|
|
54874
|
-
const rel = (0,
|
|
54875
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
54886
|
+
if (!repoPath || (0, import_node_path27.isAbsolute)(repoPath)) return null;
|
|
54887
|
+
const destination = (0, import_node_path27.resolve)(base, repoPath);
|
|
54888
|
+
const rel = (0, import_node_path27.relative)(base, destination);
|
|
54889
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path27.isAbsolute)(rel)) return null;
|
|
54876
54890
|
return destination;
|
|
54877
54891
|
}
|
|
54878
54892
|
var BUNDLE_FILE = "quikpilot-change.bundle";
|
|
@@ -54882,7 +54896,7 @@ function keepCommitBundle(repo, folder, branch) {
|
|
|
54882
54896
|
if (git4(["rev-parse", "--abbrev-ref", "HEAD"]) !== branch) return null;
|
|
54883
54897
|
if (git4(["diff", "--name-only", "HEAD~1", "HEAD"]) === "") return null;
|
|
54884
54898
|
const commit2 = git4(["rev-parse", "HEAD"]);
|
|
54885
|
-
const file = (0,
|
|
54899
|
+
const file = (0, import_node_path27.join)(folder, BUNDLE_FILE);
|
|
54886
54900
|
git4(["bundle", "create", file, "HEAD", "^HEAD~1"]);
|
|
54887
54901
|
let verified = true;
|
|
54888
54902
|
try {
|
|
@@ -54898,7 +54912,7 @@ function keepCommitBundle(repo, folder, branch) {
|
|
|
54898
54912
|
function writeFailureArtifact(input) {
|
|
54899
54913
|
if (input.results.length === 0) return { written: false };
|
|
54900
54914
|
try {
|
|
54901
|
-
const base = (0,
|
|
54915
|
+
const base = (0, import_node_path27.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
54902
54916
|
(0, import_node_fs24.rmSync)(base, { recursive: true, force: true });
|
|
54903
54917
|
(0, import_node_fs24.mkdirSync)(base, { recursive: true });
|
|
54904
54918
|
const files = [];
|
|
@@ -54909,7 +54923,7 @@ function writeFailureArtifact(input) {
|
|
|
54909
54923
|
skipped.push(result.targetPath);
|
|
54910
54924
|
continue;
|
|
54911
54925
|
}
|
|
54912
|
-
(0, import_node_fs24.mkdirSync)((0,
|
|
54926
|
+
(0, import_node_fs24.mkdirSync)((0, import_node_path27.dirname)(destination), { recursive: true });
|
|
54913
54927
|
(0, import_node_fs24.writeFileSync)(destination, result.newContent);
|
|
54914
54928
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
54915
54929
|
}
|
|
@@ -54918,7 +54932,7 @@ function writeFailureArtifact(input) {
|
|
|
54918
54932
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
54919
54933
|
testReport = "too-large";
|
|
54920
54934
|
} else {
|
|
54921
|
-
(0, import_node_fs24.writeFileSync)((0,
|
|
54935
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path27.join)(base, REPORT_COPY), input.testReport);
|
|
54922
54936
|
testReport = "included";
|
|
54923
54937
|
}
|
|
54924
54938
|
}
|
|
@@ -54940,8 +54954,8 @@ function writeFailureArtifact(input) {
|
|
|
54940
54954
|
bundle
|
|
54941
54955
|
};
|
|
54942
54956
|
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,
|
|
54957
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path27.join)(base, "manifest.json"), text3);
|
|
54958
|
+
return { written: (0, import_node_fs24.existsSync)((0, import_node_path27.join)(base, "manifest.json")) };
|
|
54945
54959
|
} catch (err2) {
|
|
54946
54960
|
console.warn(`::warning::Could not keep the failed run's files: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
54947
54961
|
return { written: false };
|
|
@@ -54951,7 +54965,7 @@ function writeFailureArtifact(input) {
|
|
|
54951
54965
|
// src/finalChange.ts
|
|
54952
54966
|
var import_node_child_process15 = require("node:child_process");
|
|
54953
54967
|
var import_node_fs25 = require("node:fs");
|
|
54954
|
-
var
|
|
54968
|
+
var import_node_path28 = require("node:path");
|
|
54955
54969
|
function statusPaths(root) {
|
|
54956
54970
|
const status = (0, import_node_child_process15.execFileSync)("git", [...NO_HOOKS_ARGS, "status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
|
|
54957
54971
|
env: gitEnv(),
|
|
@@ -54965,7 +54979,7 @@ function statusPaths(root) {
|
|
|
54965
54979
|
}
|
|
54966
54980
|
var isFileOnDisk = (root, path) => {
|
|
54967
54981
|
try {
|
|
54968
|
-
return (0, import_node_fs25.statSync)((0,
|
|
54982
|
+
return (0, import_node_fs25.statSync)((0, import_node_path28.join)(root, path)).isFile();
|
|
54969
54983
|
} catch {
|
|
54970
54984
|
return false;
|
|
54971
54985
|
}
|
|
@@ -54987,7 +55001,7 @@ function allChangesAgainstBase(root) {
|
|
|
54987
55001
|
// src/nameEvidence.ts
|
|
54988
55002
|
var import_node_child_process16 = require("node:child_process");
|
|
54989
55003
|
var import_node_fs26 = require("node:fs");
|
|
54990
|
-
var
|
|
55004
|
+
var import_node_path29 = require("node:path");
|
|
54991
55005
|
|
|
54992
55006
|
// src/migrationNames.ts
|
|
54993
55007
|
var PART = String.raw`(?:"[^"]+"|\x60[^\x60]+\x60|\[[^\]]+\]|[\w$]+)`;
|
|
@@ -55067,7 +55081,7 @@ function filesNaming(word, ev, readable, denied) {
|
|
|
55067
55081
|
}
|
|
55068
55082
|
function fileHasWord(cwd, file, word) {
|
|
55069
55083
|
try {
|
|
55070
|
-
const path = (0,
|
|
55084
|
+
const path = (0, import_node_path29.join)(cwd, file);
|
|
55071
55085
|
if ((0, import_node_fs26.statSync)(path).size > MAX_FILE_BYTES2) return false;
|
|
55072
55086
|
return new RegExp(`(?<![\\w$])${escapeRegExp5(word)}(?![\\w$])`).test((0, import_node_fs26.readFileSync)(path, "utf8"));
|
|
55073
55087
|
} catch {
|
|
@@ -55256,8 +55270,8 @@ async function resolveTestDiscovery(i3) {
|
|
|
55256
55270
|
};
|
|
55257
55271
|
if (!i3.command || i3.command.trim().length === 0) return done(buildTestDiscovery({ ...base, snapshot: null }));
|
|
55258
55272
|
let timer;
|
|
55259
|
-
const timeout = new Promise((
|
|
55260
|
-
timer = setTimeout(() =>
|
|
55273
|
+
const timeout = new Promise((resolve6) => {
|
|
55274
|
+
timer = setTimeout(() => resolve6("timeout"), i3.waitMs);
|
|
55261
55275
|
});
|
|
55262
55276
|
const settled = i3.baseline.then(
|
|
55263
55277
|
(b) => b.snapshot,
|
|
@@ -55278,12 +55292,11 @@ async function resolveTestDiscovery(i3) {
|
|
|
55278
55292
|
}
|
|
55279
55293
|
|
|
55280
55294
|
// src/targetingFindings.ts
|
|
55281
|
-
var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55282
55295
|
function prepareTargetingFindings(raw, listing, deniedPaths) {
|
|
55283
|
-
if (!
|
|
55296
|
+
if (!isPlainObject(raw)) return void 0;
|
|
55284
55297
|
const { verdict, files, callPath, evidence, searches } = raw;
|
|
55285
55298
|
if (typeof verdict !== "string" || !Array.isArray(files) || !Array.isArray(callPath) || !Array.isArray(evidence)) return void 0;
|
|
55286
|
-
const keep = (entry) =>
|
|
55299
|
+
const keep = (entry) => isPlainObject(entry) && typeof entry.path === "string" && listing.has(entry.path) && matchesDeniedPath(entry.path, deniedPaths) === null;
|
|
55287
55300
|
const kept = {
|
|
55288
55301
|
files: files.filter(keep),
|
|
55289
55302
|
callPath: callPath.filter(keep),
|
|
@@ -55422,20 +55435,22 @@ function finalizeTargeting(body2, workspaceRoot, workspaceListing, deniedPaths)
|
|
|
55422
55435
|
}
|
|
55423
55436
|
async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false, storedProposals = false, ticketHints) {
|
|
55424
55437
|
const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
|
|
55425
|
-
let envelope = await postTargeting(gateway, contextData);
|
|
55438
|
+
let envelope = await postTargeting(gateway, contextData, AbortSignal.timeout(LONG_CALL_MS));
|
|
55426
55439
|
let warnings;
|
|
55427
55440
|
const refused2 = () => envelope?.errorCode === "CONTRACT_REJECTED";
|
|
55428
55441
|
if (ticketHints && refused2()) {
|
|
55429
55442
|
envelope = await postTargeting(
|
|
55430
55443
|
gateway,
|
|
55431
|
-
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals)
|
|
55444
|
+
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals),
|
|
55445
|
+
AbortSignal.timeout(LONG_CALL_MS)
|
|
55432
55446
|
);
|
|
55433
55447
|
warnings = [TICKET_HINTS_REFUSED_WARNING];
|
|
55434
55448
|
}
|
|
55435
55449
|
if (findings && refused2()) {
|
|
55436
55450
|
envelope = await postTargeting(
|
|
55437
55451
|
gateway,
|
|
55438
|
-
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck, storedProposals)
|
|
55452
|
+
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck, storedProposals),
|
|
55453
|
+
AbortSignal.timeout(LONG_CALL_MS)
|
|
55439
55454
|
);
|
|
55440
55455
|
warnings = [...warnings ?? [], "QuikPilot's targeting ran without the early look's findings (the AI service did not accept them)."];
|
|
55441
55456
|
}
|
|
@@ -55636,7 +55651,7 @@ var MAX_SKIPPED_CONTEXT = 20;
|
|
|
55636
55651
|
var MAX_SKIPPED_CASES = 200;
|
|
55637
55652
|
var MAX_CONTEXT_RECORDS = 25;
|
|
55638
55653
|
var MAX_PATH_CHARS6 = 300;
|
|
55639
|
-
var
|
|
55654
|
+
var MAX_ID_CHARS2 = 100;
|
|
55640
55655
|
var MAX_REASON_CHARS3 = 300;
|
|
55641
55656
|
var MAX_LOOP_READS = 50;
|
|
55642
55657
|
var MAX_FALLBACK_REASON_CHARS = 40;
|
|
@@ -55725,7 +55740,7 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
55725
55740
|
continue;
|
|
55726
55741
|
}
|
|
55727
55742
|
const contextPaths = clampList(t.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS6);
|
|
55728
|
-
const automationIds = clampList(t.automationIds, MAX_IDS_PER_TARGET,
|
|
55743
|
+
const automationIds = clampList(t.automationIds, MAX_IDS_PER_TARGET, MAX_ID_CHARS2);
|
|
55729
55744
|
note(contextPaths.cut);
|
|
55730
55745
|
note(automationIds.cut);
|
|
55731
55746
|
targets.push({ path, kind: t.kind, contextPaths: contextPaths.kept, automationIds: automationIds.kept });
|
|
@@ -55733,7 +55748,7 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
55733
55748
|
const skipped = clampList(
|
|
55734
55749
|
(targeting.skippedCases ?? []).map((c) => c.automationId),
|
|
55735
55750
|
MAX_SKIPPED_CASES,
|
|
55736
|
-
|
|
55751
|
+
MAX_ID_CHARS2
|
|
55737
55752
|
);
|
|
55738
55753
|
note(skipped.cut);
|
|
55739
55754
|
const codegenContext = [];
|
|
@@ -55779,10 +55794,10 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
55779
55794
|
|
|
55780
55795
|
// src/tokenExchange.ts
|
|
55781
55796
|
async function exchangeForRunToken(tokenUrl, oidcToken) {
|
|
55782
|
-
const res = await
|
|
55797
|
+
const res = await fetchWithin("The run token exchange", tokenUrl, {
|
|
55783
55798
|
method: "POST",
|
|
55784
55799
|
headers: { Authorization: `Bearer ${oidcToken}` }
|
|
55785
|
-
});
|
|
55800
|
+
}, SHORT_CALL_MS);
|
|
55786
55801
|
if (!res.ok) {
|
|
55787
55802
|
throw new Error(`Exchange run token failed: ${await describeQuikTrackFailure(res)}`);
|
|
55788
55803
|
}
|
|
@@ -55915,6 +55930,10 @@ async function runUnderGuard(env2, guard) {
|
|
|
55915
55930
|
}
|
|
55916
55931
|
jobStopAtMs = runStopAtMs(runStartedAt, packet.guardrails.maxWallClockMinutes);
|
|
55917
55932
|
guard.arm({ stopAtMs: jobStopAtMs, watchdogAtMs: watchdogAtMs(jobStopAtMs), send: lastResort });
|
|
55933
|
+
for (const [label, name2] of [["branch", packet.branch], ["target branch", packet.targetBranch]]) {
|
|
55934
|
+
const why = typeof name2 === "string" ? checkBranchName(name2) : null;
|
|
55935
|
+
if (why) throw new Error(`QuikProjects sent a ${label} name git cannot use safely (${why}), so QuikPilot did not start. Nothing was changed.`);
|
|
55936
|
+
}
|
|
55918
55937
|
checkoutTargetBranch(packet.targetBranch);
|
|
55919
55938
|
const writeRoot = normaliseWorkspaceRoot(packet.workspaceRoot);
|
|
55920
55939
|
scopeRoot = writeRoot;
|
|
@@ -56247,7 +56266,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56247
56266
|
};
|
|
56248
56267
|
const healCalls = [];
|
|
56249
56268
|
let healStop;
|
|
56250
|
-
const testCommand = packet.commands.test;
|
|
56269
|
+
const testCommand = packet.commands.test ?? "";
|
|
56251
56270
|
const reviewPlanner = createRelatedPlanner({
|
|
56252
56271
|
root: process.cwd(),
|
|
56253
56272
|
command: testCommand,
|
|
@@ -56258,7 +56277,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56258
56277
|
log: (e) => console.log(JSON.stringify(e))
|
|
56259
56278
|
});
|
|
56260
56279
|
const hunkCheckOver = async (changed, testCount) => {
|
|
56261
|
-
if (codegenMode !== "loop-tests" || process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() === "off") return null;
|
|
56280
|
+
if (codegenMode !== "loop-tests" || testCommand.trim() === "" || process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() === "off") return null;
|
|
56262
56281
|
const deadlineAtMs = Math.min(jobStopAtMs - HUNK_CHECK_END_BEFORE_STOP_MS, Date.now() + HUNK_CHECK_MAX_MS);
|
|
56263
56282
|
if (deadlineAtMs - Date.now() < HUNK_CHECK_MIN_BUDGET_MS) return null;
|
|
56264
56283
|
const files = collectHunkCheckFiles(changed, process.cwd());
|
|
@@ -56278,10 +56297,12 @@ async function runUnderGuard(env2, guard) {
|
|
|
56278
56297
|
};
|
|
56279
56298
|
const reviewOn = process.env.QUIKPILOT_REVIEW_FIX?.trim().toLowerCase() !== "off";
|
|
56280
56299
|
let fixed2;
|
|
56300
|
+
const healAttemptsRun = codegenOut.loop?.attempts?.length ?? 1;
|
|
56301
|
+
const healAllowed = healAllowance(packet.guardrails.maxHealIterations, healAttemptsRun, 0, codegenMode);
|
|
56281
56302
|
try {
|
|
56282
56303
|
fixed2 = await runVerifyAndFix({
|
|
56283
56304
|
firstResults: results,
|
|
56284
|
-
attemptsRun:
|
|
56305
|
+
attemptsRun: healAttemptsRun,
|
|
56285
56306
|
mode: codegenMode,
|
|
56286
56307
|
setting: packet.guardrails.maxHealIterations,
|
|
56287
56308
|
now: Date.now,
|
|
@@ -56296,7 +56317,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56296
56317
|
return {
|
|
56297
56318
|
putBack: () => {
|
|
56298
56319
|
const report = findJUnitReport(cwd);
|
|
56299
|
-
const ignore = report ? [(0,
|
|
56320
|
+
const ignore = report ? [(0, import_node_path30.relative)(cwd, report).split("\\").join("/")] : [];
|
|
56300
56321
|
return undoableFlush(cwd, onDisk, flushCodegenResults, { ignore }).undo;
|
|
56301
56322
|
}
|
|
56302
56323
|
};
|
|
@@ -56333,7 +56354,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56333
56354
|
}
|
|
56334
56355
|
});
|
|
56335
56356
|
} catch (err2) {
|
|
56336
|
-
if (healStop && codegenOut.loop) codegenOut.loop = mergeHealRecord(codegenOut.loop, { stop: healStop, allowed:
|
|
56357
|
+
if (healStop && codegenOut.loop) codegenOut.loop = mergeHealRecord(codegenOut.loop, { stop: healStop, allowed: healAllowed, made: Math.min(healCalls.length, healAllowed), attempts: [] }, healCalls);
|
|
56337
56358
|
throw err2;
|
|
56338
56359
|
}
|
|
56339
56360
|
generatedResults = fixed2.results;
|
|
@@ -56506,6 +56527,11 @@ async function runUnderGuard(env2, guard) {
|
|
|
56506
56527
|
packet.issueKey,
|
|
56507
56528
|
packet.issueTitle
|
|
56508
56529
|
);
|
|
56530
|
+
if (targeted && !result.changed) {
|
|
56531
|
+
throw new Error(
|
|
56532
|
+
"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."
|
|
56533
|
+
);
|
|
56534
|
+
}
|
|
56509
56535
|
branch = result.branch;
|
|
56510
56536
|
} catch (err2) {
|
|
56511
56537
|
hardFailure = true;
|
|
@@ -56535,6 +56561,7 @@ async function runUnderGuard(env2, guard) {
|
|
|
56535
56561
|
}
|
|
56536
56562
|
|
|
56537
56563
|
// src/readinessCheck.ts
|
|
56564
|
+
var import_node_path31 = require("node:path");
|
|
56538
56565
|
async function runReadinessCheck(env2) {
|
|
56539
56566
|
let setupOk = true;
|
|
56540
56567
|
try {
|
|
@@ -56545,7 +56572,8 @@ async function runReadinessCheck(env2) {
|
|
|
56545
56572
|
}
|
|
56546
56573
|
const testOutcome = runTestCommand(env2.testCmd);
|
|
56547
56574
|
const testOk = testOutcome === "success";
|
|
56548
|
-
const
|
|
56575
|
+
const found = findJUnitReport();
|
|
56576
|
+
const junitPath = found === null ? null : (0, import_node_path31.relative)(process.cwd(), found).split(import_node_path31.sep).join("/");
|
|
56549
56577
|
const result = {
|
|
56550
56578
|
setupOk,
|
|
56551
56579
|
testOk,
|
|
@@ -56553,11 +56581,11 @@ async function runReadinessCheck(env2) {
|
|
|
56553
56581
|
junitPath
|
|
56554
56582
|
};
|
|
56555
56583
|
try {
|
|
56556
|
-
const res = await
|
|
56584
|
+
const res = await fetchWithin("The readiness report", env2.readinessCallbackUrl, {
|
|
56557
56585
|
method: "POST",
|
|
56558
56586
|
headers: { Authorization: `Bearer ${env2.readinessToken}`, "Content-Type": "application/json" },
|
|
56559
56587
|
body: JSON.stringify(result)
|
|
56560
|
-
});
|
|
56588
|
+
}, SHORT_CALL_MS);
|
|
56561
56589
|
if (!res.ok) {
|
|
56562
56590
|
throw new Error(`Readiness callback POST failed: ${await describeQuikTrackFailure(res)}`);
|
|
56563
56591
|
}
|
|
@@ -56565,6 +56593,7 @@ async function runReadinessCheck(env2) {
|
|
|
56565
56593
|
console.warn(
|
|
56566
56594
|
`::warning::QuikPilot readiness check failed to report its result: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
56567
56595
|
);
|
|
56596
|
+
throw err2;
|
|
56568
56597
|
}
|
|
56569
56598
|
}
|
|
56570
56599
|
|
|
@@ -56627,9 +56656,6 @@ var EvidenceLedger = class {
|
|
|
56627
56656
|
return seen;
|
|
56628
56657
|
}
|
|
56629
56658
|
};
|
|
56630
|
-
function isRecord7(x) {
|
|
56631
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
56632
|
-
}
|
|
56633
56659
|
function arrayOf(x) {
|
|
56634
56660
|
return Array.isArray(x) ? x : [];
|
|
56635
56661
|
}
|
|
@@ -56665,7 +56691,7 @@ function capFindingsSize(findings, max = MAX_FINDINGS_CHARS) {
|
|
|
56665
56691
|
function verifyFindings(raw, ledger, ctx) {
|
|
56666
56692
|
const dropped = emptyDropped();
|
|
56667
56693
|
const redactions = emptyRedactionCounts();
|
|
56668
|
-
if (!
|
|
56694
|
+
if (!isPlainObject(raw)) return { findings: emptyFindings(), downgraded: false, dropped, redactions };
|
|
56669
56695
|
const pathOk2 = (p) => typeof p === "string" && ctx.listing.has(p) && matchesDeniedPath(p, ctx.deniedPaths) === null;
|
|
56670
56696
|
const symbolsOf = (path, list2) => {
|
|
56671
56697
|
const out2 = [];
|
|
@@ -56680,7 +56706,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
56680
56706
|
};
|
|
56681
56707
|
const files = [];
|
|
56682
56708
|
for (const f of arrayOf(raw.files)) {
|
|
56683
|
-
if (!
|
|
56709
|
+
if (!isPlainObject(f) || !pathOk2(f.path)) {
|
|
56684
56710
|
dropped.files += 1;
|
|
56685
56711
|
continue;
|
|
56686
56712
|
}
|
|
@@ -56690,7 +56716,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
56690
56716
|
}
|
|
56691
56717
|
const callPath = [];
|
|
56692
56718
|
for (const s of arrayOf(raw.callPath)) {
|
|
56693
|
-
const ok =
|
|
56719
|
+
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
56720
|
if (!ok) {
|
|
56695
56721
|
dropped.callPath += 1;
|
|
56696
56722
|
continue;
|
|
@@ -56699,7 +56725,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
56699
56725
|
}
|
|
56700
56726
|
const evidence = [];
|
|
56701
56727
|
for (const e of arrayOf(raw.evidence)) {
|
|
56702
|
-
const ok =
|
|
56728
|
+
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
56729
|
if (!ok) {
|
|
56704
56730
|
dropped.evidence += 1;
|
|
56705
56731
|
continue;
|
|
@@ -56759,25 +56785,9 @@ var InvestigateFailure = class extends Error {
|
|
|
56759
56785
|
}
|
|
56760
56786
|
};
|
|
56761
56787
|
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
56788
|
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
56789
|
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);
|
|
56790
|
+
return new InvestigateFailure(transportReason(err2), err2);
|
|
56781
56791
|
}
|
|
56782
56792
|
function classifyEnvelope(envelope) {
|
|
56783
56793
|
const e = envelope;
|
|
@@ -56793,9 +56803,9 @@ function classifyEnvelope(envelope) {
|
|
|
56793
56803
|
return null;
|
|
56794
56804
|
}
|
|
56795
56805
|
function scrubResult(call, result, secrets, counts, ledger) {
|
|
56796
|
-
if (result.status !== "ok" || !
|
|
56806
|
+
if (result.status !== "ok" || !isPlainObject(result.output)) return null;
|
|
56797
56807
|
const output = result.output;
|
|
56798
|
-
const args2 =
|
|
56808
|
+
const args2 = isPlainObject(call.args) ? call.args : {};
|
|
56799
56809
|
if (call.name === "read_file" && typeof output.content === "string" && typeof output.path === "string") {
|
|
56800
56810
|
const scrubbed = scrubForModel(output.content, secrets, modeForPath(output.path, "look"));
|
|
56801
56811
|
addRedactionCounts(counts, scrubbed.counts);
|
|
@@ -56903,7 +56913,7 @@ async function runInvestigateLoop(args2, deps) {
|
|
|
56903
56913
|
const failed = classifyEnvelope(envelope);
|
|
56904
56914
|
if (failed) throw failed;
|
|
56905
56915
|
const body2 = envelope?.structuredJson;
|
|
56906
|
-
if (!
|
|
56916
|
+
if (!isPlainObject(body2)) throw new InvestigateFailure("bad_reply");
|
|
56907
56917
|
if (body2.outcome === "FINDINGS") {
|
|
56908
56918
|
log({ event: "investigate.loop_turn", turn, outcome: "final", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
|
|
56909
56919
|
const stopReason = isFinal ? `forced_${finalReason}` : "model_final";
|
|
@@ -56912,16 +56922,9 @@ async function runInvestigateLoop(args2, deps) {
|
|
|
56912
56922
|
}
|
|
56913
56923
|
if (body2.outcome !== "TOOL_CALLS") throw new InvestigateFailure("bad_reply");
|
|
56914
56924
|
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
|
-
}
|
|
56925
|
+
const parsed = parseToolCalls(body2.toolCalls, usedIds);
|
|
56926
|
+
if (typeof parsed === "string") throw new InvestigateFailure(parsed);
|
|
56927
|
+
const calls = parsed.calls;
|
|
56925
56928
|
for (const c of calls) usedIds.add(c.id);
|
|
56926
56929
|
const results = [];
|
|
56927
56930
|
const logged = [];
|
|
@@ -56953,7 +56956,7 @@ async function runInvestigateLoop(args2, deps) {
|
|
|
56953
56956
|
logged.push({ tool, status: result.status, ...result.reason && result.status !== "duplicate" ? { reason: result.reason } : {} });
|
|
56954
56957
|
});
|
|
56955
56958
|
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:
|
|
56959
|
+
transcript.push({ turn, ...reasoning ? { reasoning } : {}, toolCalls: calls.map((c) => ({ id: c.id, name: c.name, args: safeArgs(c.args) })) });
|
|
56957
56960
|
toolResults.push(...results);
|
|
56958
56961
|
noProgressStreak = results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
|
|
56959
56962
|
if (noProgressStreak >= 2) forced = "no_progress";
|
|
@@ -57005,7 +57008,7 @@ function isStringList(x) {
|
|
|
57005
57008
|
return Array.isArray(x) && x.every((s) => typeof s === "string");
|
|
57006
57009
|
}
|
|
57007
57010
|
async function fetchInvestigatePacket(packetUrl, runToken, githubRunId) {
|
|
57008
|
-
const res = await
|
|
57011
|
+
const res = await fetchWithin("The look's packet request", `${packetUrl}?githubRunId=${encodeURIComponent(githubRunId)}`, { headers: { Authorization: `Bearer ${runToken}` } }, SHORT_CALL_MS);
|
|
57009
57012
|
if (!res.ok) throw new Error(`Fetch investigate packet failed: ${await describeQuikTrackFailure(res)}`);
|
|
57010
57013
|
const body2 = await res.json();
|
|
57011
57014
|
const data2 = body2?.data;
|
|
@@ -57042,7 +57045,7 @@ var InvestigationReportError = class extends Error {
|
|
|
57042
57045
|
status;
|
|
57043
57046
|
networkCode;
|
|
57044
57047
|
};
|
|
57045
|
-
async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) => new Promise((
|
|
57048
|
+
async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms))) {
|
|
57046
57049
|
const payload = JSON.stringify(body2);
|
|
57047
57050
|
const tries = INVESTIGATION_REPORT_RETRY_WAITS_MS.length + 1;
|
|
57048
57051
|
for (let attempt2 = 1; ; attempt2++) {
|
|
@@ -57050,11 +57053,11 @@ async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) =>
|
|
|
57050
57053
|
let status;
|
|
57051
57054
|
let networkCode;
|
|
57052
57055
|
try {
|
|
57053
|
-
const res = await
|
|
57056
|
+
const res = await fetchWithin("The look's report", callbackUrl, {
|
|
57054
57057
|
method: "POST",
|
|
57055
57058
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "application/json" },
|
|
57056
57059
|
body: payload
|
|
57057
|
-
});
|
|
57060
|
+
}, SHORT_CALL_MS);
|
|
57058
57061
|
if (res.ok) return;
|
|
57059
57062
|
failure = await describeQuikTrackFailure(res);
|
|
57060
57063
|
status = res.status;
|