@quikit/quikpilot-runner 9.3.0-rc.1 → 9.3.0-rc.3
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/dist/index.js +47 -7
- package/dist/index.js.map +4 -4
- package/package.json +29 -29
package/dist/index.js
CHANGED
|
@@ -1201,6 +1201,7 @@ function toLf(text) {
|
|
|
1201
1201
|
function fromLf(text, ending) {
|
|
1202
1202
|
return ending === "CRLF" ? text.replace(/\n/g, "\r\n") : text;
|
|
1203
1203
|
}
|
|
1204
|
+
var MAX_MATCH_STARTS = 5;
|
|
1204
1205
|
function occurrences(haystack, needle) {
|
|
1205
1206
|
const found = [];
|
|
1206
1207
|
let index = haystack.indexOf(needle);
|
|
@@ -1246,6 +1247,7 @@ function applyEdits(originalLf, edits) {
|
|
|
1246
1247
|
kind: "ambiguous",
|
|
1247
1248
|
edits: [number],
|
|
1248
1249
|
matchCount: starts.length,
|
|
1250
|
+
matchStarts: starts.slice(0, MAX_MATCH_STARTS),
|
|
1249
1251
|
message: `edit ${number}: the anchor matched ${starts.length} times`
|
|
1250
1252
|
});
|
|
1251
1253
|
} else {
|
|
@@ -2421,6 +2423,40 @@ function collectLoopContext(p) {
|
|
|
2421
2423
|
return { entries, testPaths, records };
|
|
2422
2424
|
}
|
|
2423
2425
|
|
|
2426
|
+
// src/anchorPlaces.ts
|
|
2427
|
+
var MAX_NAMED = 4;
|
|
2428
|
+
var QUOTE_WIDTH = 50;
|
|
2429
|
+
var TAIL = "Make `find` longer by adding the line before or after the place you mean, so it matches exactly once.";
|
|
2430
|
+
function lineNumberAt(text, index) {
|
|
2431
|
+
let line = 1;
|
|
2432
|
+
for (let at2 = text.indexOf("\n"); at2 !== -1 && at2 < index; at2 = text.indexOf("\n", at2 + 1)) line += 1;
|
|
2433
|
+
return line;
|
|
2434
|
+
}
|
|
2435
|
+
function previousTextLine(text, index) {
|
|
2436
|
+
let end = (index === 0 ? 0 : text.lastIndexOf("\n", index - 1) + 1) - 1;
|
|
2437
|
+
while (end >= 0) {
|
|
2438
|
+
const start = end === 0 ? 0 : text.lastIndexOf("\n", end - 1) + 1;
|
|
2439
|
+
const line = text.slice(start, end);
|
|
2440
|
+
if (line.trim() !== "") return line;
|
|
2441
|
+
end = start - 1;
|
|
2442
|
+
}
|
|
2443
|
+
return null;
|
|
2444
|
+
}
|
|
2445
|
+
function quoted(line, width) {
|
|
2446
|
+
return line.replace(/`/g, "").trim().slice(0, width).trimEnd();
|
|
2447
|
+
}
|
|
2448
|
+
function ambiguousPlacesMessage(lf, starts, total) {
|
|
2449
|
+
const named = starts.slice(0, MAX_NAMED);
|
|
2450
|
+
if (named.length === 0) return `That text matches ${total} places. ${TAIL}`;
|
|
2451
|
+
const header = total <= MAX_NAMED ? `That text matches ${total} places: ` : `That text matches ${total} places; the first four are `;
|
|
2452
|
+
const places = named.map((start) => ({ line: lineNumberAt(lf, start), before: previousTextLine(lf, start) }));
|
|
2453
|
+
const parts = places.map((p) => {
|
|
2454
|
+
const q = p.before !== null ? quoted(p.before, QUOTE_WIDTH) : "";
|
|
2455
|
+
return q === "" ? `line ${p.line}` : `line ${p.line} (after \`${q}\`)`;
|
|
2456
|
+
});
|
|
2457
|
+
return `${header}${parts.join(", ")}. ${TAIL}`;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2424
2460
|
// src/addOnly.ts
|
|
2425
2461
|
var JS_FAMILY = /\.(?:[cm]?[jt]sx?)$/i;
|
|
2426
2462
|
var DECLARES_TEST = /^[ \t]*(?:it|test|describe)\b/m;
|
|
@@ -11289,8 +11325,7 @@ function createCodegenWorkspace(args) {
|
|
|
11289
11325
|
return { result: { status: "no_match", message: "That text was not found in the file. Read it again and copy it exactly." } };
|
|
11290
11326
|
}
|
|
11291
11327
|
if (refusal?.kind === "ambiguous") {
|
|
11292
|
-
|
|
11293
|
-
return { result: { status: "ambiguous", message: `That text matches ${n} places. Include more surrounding text so it matches exactly once.` } };
|
|
11328
|
+
return { result: { status: "ambiguous", message: ambiguousPlacesMessage(lf, refusal.matchStarts ?? [], refusal.matchCount ?? 0) } };
|
|
11294
11329
|
}
|
|
11295
11330
|
return { result: { status: "bad_args", message: "That edit could not be applied." } };
|
|
11296
11331
|
}
|
|
@@ -12831,7 +12866,11 @@ function perFile(p) {
|
|
|
12831
12866
|
}
|
|
12832
12867
|
async function runCodegenStep(p) {
|
|
12833
12868
|
if (p.mode !== "loop" && p.mode !== "loop-tests") return perFile(p);
|
|
12834
|
-
const
|
|
12869
|
+
const testSetup = p.mode === "loop-tests" ? p.tests : void 0;
|
|
12870
|
+
const treeAtStart = testSetup ? testSetup.baseline().then(
|
|
12871
|
+
() => captureTree(testSetup.root, [], testSetup.tree),
|
|
12872
|
+
() => captureTree(testSetup.root, [], testSetup.tree)
|
|
12873
|
+
).catch(() => null) : null;
|
|
12835
12874
|
const context = collectLoopContext({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, ...p.readFile ? { readFile: p.readFile } : {} });
|
|
12836
12875
|
p.contextLog.push(...context.records);
|
|
12837
12876
|
console.log(
|
|
@@ -12872,7 +12911,8 @@ async function runCodegenStep(p) {
|
|
|
12872
12911
|
const w = `The code-writing loop could not finish (${failure.reason}${said}), so the files were written one at a time instead.`;
|
|
12873
12912
|
p.warnings.push(w);
|
|
12874
12913
|
console.warn(`QuikPilot codegen warning (not blocking): ${w}`);
|
|
12875
|
-
|
|
12914
|
+
const before = treeAtStart ? await treeAtStart : null;
|
|
12915
|
+
if (before && p.tests) assertTreeUnchanged(p.tests.root, before, [], p.tests.tree);
|
|
12876
12916
|
return perFile(p);
|
|
12877
12917
|
}
|
|
12878
12918
|
}
|
|
@@ -13144,8 +13184,8 @@ function shellQuote(value) {
|
|
|
13144
13184
|
return `'${value.split("'").join("'\\''")}'`;
|
|
13145
13185
|
}
|
|
13146
13186
|
function buildSingleFileCommand(command, path) {
|
|
13147
|
-
const
|
|
13148
|
-
return command.includes("{file}") ? command.split("{file}").join(
|
|
13187
|
+
const quoted2 = shellQuote(path);
|
|
13188
|
+
return command.includes("{file}") ? command.split("{file}").join(quoted2) : `${command} ${quoted2}`;
|
|
13149
13189
|
}
|
|
13150
13190
|
var isTestTarget2 = (t) => (t.automationIds?.length ?? 0) > 0;
|
|
13151
13191
|
function checkableIds(ids, types2) {
|
|
@@ -13323,7 +13363,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
13323
13363
|
var REPORT_COPY = "final-test-report.xml";
|
|
13324
13364
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
13325
13365
|
var MAX_FILES = 200;
|
|
13326
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
13366
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.3" : "dev";
|
|
13327
13367
|
function safeDestination(base, repoPath) {
|
|
13328
13368
|
if (!repoPath || (0, import_node_path12.isAbsolute)(repoPath)) return null;
|
|
13329
13369
|
const destination = (0, import_node_path12.resolve)(base, repoPath);
|