@quikit/quikpilot-runner 9.3.0-rc.43 → 9.3.0-rc.44
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 +336 -130
- package/dist/index.js.map +4 -4
- package/package.json +30 -30
package/dist/index.js
CHANGED
|
@@ -30592,6 +30592,35 @@ function parseProgram(path, text2) {
|
|
|
30592
30592
|
}
|
|
30593
30593
|
|
|
30594
30594
|
// src/testLocate.ts
|
|
30595
|
+
function allTests(file) {
|
|
30596
|
+
return [...file.tests, ...file.generated];
|
|
30597
|
+
}
|
|
30598
|
+
var PLACEHOLDER = /%[sdifjoOp#%]|\$(?:#|[A-Za-z_]\w*(?:\.\w+)*)/g;
|
|
30599
|
+
var escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
30600
|
+
function titlePattern(title) {
|
|
30601
|
+
let source = "";
|
|
30602
|
+
let placeholders = false;
|
|
30603
|
+
let at2 = 0;
|
|
30604
|
+
for (const m of title.matchAll(PLACEHOLDER)) {
|
|
30605
|
+
const index = m.index ?? 0;
|
|
30606
|
+
source += escapeRegExp(title.slice(at2, index));
|
|
30607
|
+
if (m[0] === "%%") {
|
|
30608
|
+
source += "%";
|
|
30609
|
+
} else {
|
|
30610
|
+
source += ".*?";
|
|
30611
|
+
placeholders = true;
|
|
30612
|
+
}
|
|
30613
|
+
at2 = index + m[0].length;
|
|
30614
|
+
}
|
|
30615
|
+
return { source: source + escapeRegExp(title.slice(at2)), placeholders };
|
|
30616
|
+
}
|
|
30617
|
+
function nameEndsWithTitle(name, title) {
|
|
30618
|
+
return new RegExp(`(?:^|(?: > | \u203A | ))${titlePattern(title).source}$`, "s").test(name);
|
|
30619
|
+
}
|
|
30620
|
+
function rowPattern(test) {
|
|
30621
|
+
const parts = [...test.describes, test.title].map((s) => titlePattern(s).source);
|
|
30622
|
+
return new RegExp(`^(?:${parts.join("(?: > | \u203A | )")}|${parts[parts.length - 1]})$`, "s");
|
|
30623
|
+
}
|
|
30595
30624
|
var TEST_ROOTS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
30596
30625
|
var X_ROOTS = /* @__PURE__ */ new Set(["xit", "xtest"]);
|
|
30597
30626
|
var DESCRIBE_ROOTS = /* @__PURE__ */ new Set(["describe", "context", "suite"]);
|
|
@@ -30645,12 +30674,17 @@ function locateTests(path, text2) {
|
|
|
30645
30674
|
const call = node;
|
|
30646
30675
|
const chain = chainOf(call.callee);
|
|
30647
30676
|
const title = chain ? titleOf(call) : null;
|
|
30648
|
-
const each = call.callee.type === "CallExpression" ? chainOf(call.callee.callee) : null;
|
|
30677
|
+
const each = call.callee.type === "CallExpression" ? chainOf(call.callee.callee) : call.callee.type === "TaggedTemplateExpression" ? chainOf(call.callee.tag) : null;
|
|
30649
30678
|
if (each) {
|
|
30650
30679
|
innerDynamic = true;
|
|
30651
30680
|
const eachTitle = titleOf(call);
|
|
30652
|
-
if (eachTitle && DESCRIBE_ROOTS.has(each.root))
|
|
30653
|
-
|
|
30681
|
+
if (eachTitle && DESCRIBE_ROOTS.has(each.root)) {
|
|
30682
|
+
inner = [...describes, eachTitle.text];
|
|
30683
|
+
} else if (eachTitle) {
|
|
30684
|
+
const test = located(call, eachTitle, describes, each.skipped);
|
|
30685
|
+
const body = call.arguments[1];
|
|
30686
|
+
generated.push(body ? { ...test, bodyStartLine: lineAt(parsed.code, body.start) } : test);
|
|
30687
|
+
}
|
|
30654
30688
|
}
|
|
30655
30689
|
if (chain && title) {
|
|
30656
30690
|
if (DESCRIBE_ROOTS.has(chain.root)) {
|
|
@@ -30777,12 +30811,14 @@ function testEditOverreach(input) {
|
|
|
30777
30811
|
const after = locateTests(input.path, input.after);
|
|
30778
30812
|
if (!before) return "the file could not be read before the edit";
|
|
30779
30813
|
if (!after) return "the file can no longer be read after the edit";
|
|
30780
|
-
if (after.tests.length !== before.tests.length) return "a test was added or removed";
|
|
30814
|
+
if (after.tests.length !== before.tests.length || after.generated.length !== before.generated.length) return "a test was added or removed";
|
|
30815
|
+
const beforeAll = allTests(before);
|
|
30816
|
+
const afterAll = allTests(after);
|
|
30781
30817
|
const wasTests = [];
|
|
30782
30818
|
const nowTests = [];
|
|
30783
30819
|
for (const index of input.indexes) {
|
|
30784
|
-
const was =
|
|
30785
|
-
const now =
|
|
30820
|
+
const was = beforeAll[index];
|
|
30821
|
+
const now = afterAll[index];
|
|
30786
30822
|
if (!was || !now) return "the test could not be found again after the edit";
|
|
30787
30823
|
wasTests.push(was);
|
|
30788
30824
|
nowTests.push(now);
|
|
@@ -32495,7 +32531,7 @@ var CONFLICT_CASE_FIELDS = ["given", "when", "then"];
|
|
|
32495
32531
|
var REJECT_MESSAGES = {
|
|
32496
32532
|
not_existing_test: "That is not an existing test file of this project that can be reported.",
|
|
32497
32533
|
unsupported_language: "Only JavaScript and TypeScript test files can be reported.",
|
|
32498
|
-
title_not_found: "No test with that title was found in that file. Copy the title exactly as the file writes it.",
|
|
32534
|
+
title_not_found: "No test with that title was found in that file. Copy the title exactly as the file writes it. For a test written once for each row of a table, that is the title in the file with its $name or %s placeholders as they are, not the name of one row.",
|
|
32499
32535
|
title_not_unique: "More than one test in that file has that title, so it cannot be told which one you mean.",
|
|
32500
32536
|
no_match: "find was not found in that file. Copy it exactly as read_file shows it.",
|
|
32501
32537
|
ambiguous: "find matches more than once in that file. Make it longer so it matches once.",
|
|
@@ -32506,7 +32542,7 @@ var REJECT_MESSAGES = {
|
|
|
32506
32542
|
still_passes_old_code: "With your replacement that test still passes on the code before this run, so it would not show the bug.",
|
|
32507
32543
|
already_decided: "A person has already decided about that test. Do not report it again.",
|
|
32508
32544
|
too_many_conflicts: "Too many tests have been reported already. Finish with what you have.",
|
|
32509
|
-
generated_test: "That test is written once and run for each row of a table (describe.each or it.each),
|
|
32545
|
+
generated_test: "That test is written once and run for each row of a table (describe.each or it.each), and its rows were not found in the test run made before your change, so it cannot be checked. Do not report it again: answer CANNOT_COMPLETE, and in your summary name the test and the case it contradicts. A person will change it."
|
|
32510
32546
|
};
|
|
32511
32547
|
var RECORDED_MESSAGE = "Recorded. This run will now stop before any code is delivered, and a person will decide about this test. Finish your answer; there is nothing more to do for this test.";
|
|
32512
32548
|
var BOUNDS = { find: 8e3, replace: 2e4, title: 300, reason: 300, caseText: 1e3, value: 120, why: 300 };
|
|
@@ -32533,13 +32569,17 @@ function nameIsTitle(name, title, describes = []) {
|
|
|
32533
32569
|
const full = [...describes, title];
|
|
32534
32570
|
return name === title || name === full.join(" > ") || name === full.join(" ") || name === full.join(" \u203A ");
|
|
32535
32571
|
}
|
|
32536
|
-
function isRowsTitle(sent, title) {
|
|
32537
|
-
return sent === title || [" > ", " \u203A ", " "].some((sep) => sent.endsWith(`${sep}${title}`) && sent.length > sep.length + title.length);
|
|
32538
|
-
}
|
|
32539
32572
|
function splitTestId(id) {
|
|
32540
32573
|
const at2 = id.indexOf("::");
|
|
32541
32574
|
return at2 === -1 ? { file: null, name: id } : { file: id.slice(0, at2), name: id.slice(at2 + 2) };
|
|
32542
32575
|
}
|
|
32576
|
+
function matchRows(results, path, test) {
|
|
32577
|
+
const pattern = rowPattern(test);
|
|
32578
|
+
return [...results.entries()].filter(([id]) => {
|
|
32579
|
+
const { file, name } = splitTestId(id);
|
|
32580
|
+
return (file === null || sameFile(file, path)) && pattern.test(name);
|
|
32581
|
+
});
|
|
32582
|
+
}
|
|
32543
32583
|
function text(v, min, max) {
|
|
32544
32584
|
return typeof v === "string" && v.length >= min && v.length <= max ? v : null;
|
|
32545
32585
|
}
|
|
@@ -32619,6 +32659,8 @@ var TestConflictTool = class {
|
|
|
32619
32659
|
counts = { calls: 0, recorded: 0, rejected: 0 };
|
|
32620
32660
|
rejectedBy = {};
|
|
32621
32661
|
generated = /* @__PURE__ */ new Map();
|
|
32662
|
+
/** QUIKTR-1827: every test the AI has reported, whatever the answer was: the tests it has looked at and said something about. */
|
|
32663
|
+
reported = [];
|
|
32622
32664
|
max;
|
|
32623
32665
|
/** The reports that stand, one per test, in the order they were first made. */
|
|
32624
32666
|
recorded() {
|
|
@@ -32628,6 +32670,10 @@ var TestConflictTool = class {
|
|
|
32628
32670
|
unreportable() {
|
|
32629
32671
|
return [...this.generated.values()];
|
|
32630
32672
|
}
|
|
32673
|
+
/** QUIKTR-1827: where each test the AI reported is and the title it gave, answered or rejected. For the check on a give-up; never sent anywhere. */
|
|
32674
|
+
reportedTests() {
|
|
32675
|
+
return this.reported.map((r) => ({ ...r }));
|
|
32676
|
+
}
|
|
32631
32677
|
/** Counts and closed words only, for the run's log. */
|
|
32632
32678
|
record() {
|
|
32633
32679
|
return { ...this.counts, rejectedBy: { ...this.rejectedBy } };
|
|
@@ -32649,6 +32695,7 @@ var TestConflictTool = class {
|
|
|
32649
32695
|
const parsed = parseConflictReport(call.args, this.deps.caseIds);
|
|
32650
32696
|
if (!parsed.ok) return finish({ status: "bad_args", message: `${parsed.field} is not valid for report_test_conflict.` });
|
|
32651
32697
|
const report = parsed.report;
|
|
32698
|
+
if (!this.reported.some((r) => r.path === report.path && r.title === report.testTitle)) this.reported.push({ path: report.path, title: report.testTitle });
|
|
32652
32699
|
const dupKey = `${call.name}:${JSON.stringify(report)}`;
|
|
32653
32700
|
const earlier = ledger.seen.get(dupKey);
|
|
32654
32701
|
if (earlier !== void 0) {
|
|
@@ -32680,31 +32727,31 @@ var TestConflictTool = class {
|
|
|
32680
32727
|
if (!loaded.ok) return this.reject("not_existing_test");
|
|
32681
32728
|
const located = locateTests(path.path, loaded.lf);
|
|
32682
32729
|
if (!located) return this.reject("unsupported_language");
|
|
32683
|
-
const matches = located.
|
|
32684
|
-
if (matches.length === 0)
|
|
32685
|
-
const rows = located.generated.find((t) => isRowsTitle(r.testTitle, t.title));
|
|
32686
|
-
if (!rows) return this.reject("title_not_found");
|
|
32687
|
-
const rowsKey = `${path.path}\0${rows.startLine}`;
|
|
32688
|
-
if (!this.generated.has(rowsKey)) this.generated.set(rowsKey, { path: path.path, line: rows.startLine, caseId: r.caseId });
|
|
32689
|
-
return this.reject("generated_test");
|
|
32690
|
-
}
|
|
32730
|
+
const matches = allTests(located).map((t, index2) => ({ t, index: index2 })).filter(({ t }) => t.title === r.testTitle);
|
|
32731
|
+
if (matches.length === 0) return this.reject("title_not_found");
|
|
32691
32732
|
if (matches.length > 1) return this.reject("title_not_unique");
|
|
32692
32733
|
const { t: test, index } = matches[0];
|
|
32734
|
+
const isTable = index >= located.tests.length;
|
|
32693
32735
|
const applied = applyEdits(loaded.lf, [{ find: r.find, replace: r.replace }]);
|
|
32694
32736
|
if (!applied.ok) return this.reject(applied.refusals[0]?.kind === "ambiguous" ? "ambiguous" : "no_match");
|
|
32695
32737
|
const at2 = loaded.lf.indexOf(r.find);
|
|
32696
32738
|
const changeLine = lineAt(loaded.lf, at2);
|
|
32697
32739
|
const lastLine = lineAt(loaded.lf, at2 + r.find.length - 1);
|
|
32698
|
-
if (changeLine < test.startLine || lastLine > test.endLine) return this.reject("find_outside_test");
|
|
32740
|
+
if (changeLine < (test.bodyStartLine ?? test.startLine) || lastLine > test.endLine) return this.reject("find_outside_test");
|
|
32699
32741
|
if (testEditOverreach({ path: path.path, before: loaded.lf, after: applied.content, indexes: [index] }) !== null) return this.reject("beyond_expectations");
|
|
32700
32742
|
const base = await d.baseline().catch(() => null);
|
|
32701
32743
|
const results = base?.snapshot.results ?? null;
|
|
32702
32744
|
if (!base || base.snapshot.timedOut === true || !results) return this.reject("baseline_unknown");
|
|
32703
|
-
const mine = [...results.entries()].filter(([id]) => {
|
|
32745
|
+
const mine = isTable ? matchRows(results, path.path, test) : [...results.entries()].filter(([id]) => {
|
|
32704
32746
|
const { file, name } = splitTestId(id);
|
|
32705
32747
|
return (file === null || sameFile(file, path.path)) && nameIsTitle(name, r.testTitle, test.describes);
|
|
32706
32748
|
});
|
|
32707
|
-
if (mine.length === 0)
|
|
32749
|
+
if (mine.length === 0) {
|
|
32750
|
+
if (!isTable) return this.reject("baseline_unknown");
|
|
32751
|
+
const rowsKey = `${path.path}\0${test.startLine}`;
|
|
32752
|
+
if (!this.generated.has(rowsKey)) this.generated.set(rowsKey, { path: path.path, line: test.startLine, caseId: r.caseId });
|
|
32753
|
+
return this.reject("generated_test");
|
|
32754
|
+
}
|
|
32708
32755
|
if (mine.some(([, passed]) => !passed)) return this.reject("not_passing_before");
|
|
32709
32756
|
const scrub = d.scrub ?? ((s) => s);
|
|
32710
32757
|
const history = mapHistory((d.history ?? ((p, title) => readTestHistory({ path: p, title })))(path.path, r.testTitle), scrub);
|
|
@@ -32716,6 +32763,7 @@ var TestConflictTool = class {
|
|
|
32716
32763
|
endLine: test.endLine,
|
|
32717
32764
|
changeLine,
|
|
32718
32765
|
index,
|
|
32766
|
+
...isTable ? { rows: mine.length } : {},
|
|
32719
32767
|
history,
|
|
32720
32768
|
originalLf: loaded.lf,
|
|
32721
32769
|
ending: loaded.ending,
|
|
@@ -32724,7 +32772,7 @@ var TestConflictTool = class {
|
|
|
32724
32772
|
};
|
|
32725
32773
|
this.byTest.set(key, conflict);
|
|
32726
32774
|
this.counts.recorded += 1;
|
|
32727
|
-
d.log?.({ event: "codegen.conflict_recorded", reading: r.reading, phase: d.phase ?? null, historyAvailable: history.available });
|
|
32775
|
+
d.log?.({ event: "codegen.conflict_recorded", reading: r.reading, phase: d.phase ?? null, historyAvailable: history.available, ...isTable ? { rows: mine.length } : {} });
|
|
32728
32776
|
return { status: "conflict_recorded", message: RECORDED_MESSAGE, output: { history } };
|
|
32729
32777
|
}
|
|
32730
32778
|
};
|
|
@@ -32763,7 +32811,7 @@ function buildProposalFiles(conflicts) {
|
|
|
32763
32811
|
ending: first.ending,
|
|
32764
32812
|
bom: first.bom,
|
|
32765
32813
|
conflicts: kept,
|
|
32766
|
-
newTitles: new Map(kept.map((c) => [c.index, located
|
|
32814
|
+
newTitles: new Map(kept.map((c) => [c.index, allTests(located)[c.index]?.title ?? c.testTitle]))
|
|
32767
32815
|
});
|
|
32768
32816
|
}
|
|
32769
32817
|
return { files, dropped };
|
|
@@ -32806,7 +32854,8 @@ function lineOf2(c, file) {
|
|
|
32806
32854
|
reason: c.reason,
|
|
32807
32855
|
correction: c.correction,
|
|
32808
32856
|
history: c.history,
|
|
32809
|
-
oldCodeChecked: c.oldCodeChecked === true
|
|
32857
|
+
oldCodeChecked: c.oldCodeChecked === true,
|
|
32858
|
+
...c.rows !== void 0 ? { rows: c.rows } : {}
|
|
32810
32859
|
};
|
|
32811
32860
|
}
|
|
32812
32861
|
function oneLine(s) {
|
|
@@ -32854,7 +32903,7 @@ function parseProposalMessage(message) {
|
|
|
32854
32903
|
const o = j;
|
|
32855
32904
|
const c = o.correction;
|
|
32856
32905
|
const h = o.history;
|
|
32857
|
-
if (o.v !== 1 || !isStr(o.path, 300) || !isStr(o.title, 300) || o.newTitle !== void 0 && !isStr(o.newTitle, 300) || !isStr(o.caseId, 64) || !CONFLICT_READINGS.includes(o.reading) || !isLine(o.startLine) || !isLine(o.endLine) || !isLine(o.changeLine) || !isStr(o.reason, 300) || typeof c !== "object" || c === null || !CONFLICT_CASE_FIELDS.includes(c.field) || !isStr(c.text, 1e3) || !isStr(c.why, 300) || typeof h !== "object" || h === null || typeof h.available !== "boolean" || typeof o.oldCodeChecked !== "boolean") {
|
|
32906
|
+
if (o.v !== 1 || !isStr(o.path, 300) || !isStr(o.title, 300) || o.newTitle !== void 0 && !isStr(o.newTitle, 300) || !isStr(o.caseId, 64) || !CONFLICT_READINGS.includes(o.reading) || !isLine(o.startLine) || !isLine(o.endLine) || !isLine(o.changeLine) || !isStr(o.reason, 300) || typeof c !== "object" || c === null || !CONFLICT_CASE_FIELDS.includes(c.field) || !isStr(c.text, 1e3) || !isStr(c.why, 300) || typeof h !== "object" || h === null || typeof h.available !== "boolean" || typeof o.oldCodeChecked !== "boolean" || o.rows !== void 0 && !(typeof o.rows === "number" && Number.isInteger(o.rows) && o.rows >= 1 && o.rows <= 1e4)) {
|
|
32858
32907
|
continue;
|
|
32859
32908
|
}
|
|
32860
32909
|
out.push(o);
|
|
@@ -32901,6 +32950,7 @@ function conflictsReport(p) {
|
|
|
32901
32950
|
caseId: l.caseId,
|
|
32902
32951
|
reading: l.reading,
|
|
32903
32952
|
oldCodeChecked: l.oldCodeChecked,
|
|
32953
|
+
...l.rows !== void 0 ? { rows: l.rows } : {},
|
|
32904
32954
|
...l.history.available ? {
|
|
32905
32955
|
history: {
|
|
32906
32956
|
...l.history.addedAt ? { addedAt: l.history.addedAt } : {},
|
|
@@ -32982,7 +33032,7 @@ function loadApprovedTests(input) {
|
|
|
32982
33032
|
continue;
|
|
32983
33033
|
}
|
|
32984
33034
|
const before = locateTests(path, toLf(stripBom(current2)));
|
|
32985
|
-
const indexes = mine.map((l) => before
|
|
33035
|
+
const indexes = mine.map((l) => (before ? allTests(before) : []).findIndex((t) => t.title === l.title));
|
|
32986
33036
|
if (!before || indexes.some((i2) => i2 < 0)) {
|
|
32987
33037
|
warnings.push(`The tests proposed for change in ${path} were not found in it, so that change was not applied.`);
|
|
32988
33038
|
continue;
|
|
@@ -33672,8 +33722,8 @@ async function reportToQuikTest(params) {
|
|
|
33672
33722
|
try {
|
|
33673
33723
|
console.log(`reporting ${report}`);
|
|
33674
33724
|
const ciUrl = buildCiUrl(githubServerUrl, githubRepository, githubRunId);
|
|
33675
|
-
const { readFileSync:
|
|
33676
|
-
const body =
|
|
33725
|
+
const { readFileSync: readFileSync19 } = await import("node:fs");
|
|
33726
|
+
const body = readFileSync19(report);
|
|
33677
33727
|
let url = `${resultsUrl}?ciUrl=${encodeURIComponent(ciUrl)}&automationIdFormat=bracket`;
|
|
33678
33728
|
if (generatedFiles) {
|
|
33679
33729
|
url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
|
|
@@ -33700,6 +33750,66 @@ async function reportToQuikTest(params) {
|
|
|
33700
33750
|
}
|
|
33701
33751
|
}
|
|
33702
33752
|
|
|
33753
|
+
// src/giveUpCheck.ts
|
|
33754
|
+
var GIVE_UP_RULE = "give_up_rule";
|
|
33755
|
+
var GIVE_UP_MESSAGE = "Your answer was sent back once: existing tests your change broke are neither reported nor explained. Report each one that expects what a bug case calls wrong with report_test_conflict; otherwise change your code. Read the test file to see what it expects.";
|
|
33756
|
+
var MAX_SENTENCES = 8;
|
|
33757
|
+
var MAX_SENTENCE_CHARS = 300;
|
|
33758
|
+
var MAX_TITLE_CHARS = 150;
|
|
33759
|
+
var MAX_FILE_CHARS = 100;
|
|
33760
|
+
function lastPart(name) {
|
|
33761
|
+
const at2 = Math.max(name.lastIndexOf(" > "), name.lastIndexOf(" \u203A "));
|
|
33762
|
+
return at2 === -1 ? name : name.slice(at2 + 3);
|
|
33763
|
+
}
|
|
33764
|
+
function groupRegressions(ids) {
|
|
33765
|
+
const groups = /* @__PURE__ */ new Map();
|
|
33766
|
+
for (const id of ids) {
|
|
33767
|
+
const { file, name } = splitTestId(id);
|
|
33768
|
+
const title = lastPart(name);
|
|
33769
|
+
const key = `${file ?? ""}\0${title}`;
|
|
33770
|
+
const have = groups.get(key);
|
|
33771
|
+
if (have) have.rows += 1;
|
|
33772
|
+
else groups.set(key, { file: file ?? "", title, rows: 1 });
|
|
33773
|
+
}
|
|
33774
|
+
return [...groups.values()];
|
|
33775
|
+
}
|
|
33776
|
+
var samePlace = (a, b) => {
|
|
33777
|
+
const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
33778
|
+
const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
33779
|
+
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
33780
|
+
};
|
|
33781
|
+
function unexplainedRegressions(answer, reported) {
|
|
33782
|
+
if (answer.regressions <= 0) return [];
|
|
33783
|
+
const regressed = answer.failingTests.slice(0, answer.regressions);
|
|
33784
|
+
return groupRegressions(regressed).filter(
|
|
33785
|
+
(g) => !reported.some((r) => (g.file === "" || samePlace(g.file, r.path)) && nameEndsWithTitle(g.title, r.title))
|
|
33786
|
+
);
|
|
33787
|
+
}
|
|
33788
|
+
var clip2 = (s, max) => s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
|
|
33789
|
+
function sentenceOf(g) {
|
|
33790
|
+
const rows = g.rows > 1 ? ` (${g.rows} rows)` : "";
|
|
33791
|
+
return clip2(`${g.file ? `${clip2(g.file, MAX_FILE_CHARS)}: ` : ""}"${clip2(g.title, MAX_TITLE_CHARS)}"${rows} passed before this run and fails now.`, MAX_SENTENCE_CHARS);
|
|
33792
|
+
}
|
|
33793
|
+
function giveUpSentences(groups) {
|
|
33794
|
+
if (groups.length <= MAX_SENTENCES) return groups.map(sentenceOf);
|
|
33795
|
+
const shown = groups.slice(0, MAX_SENTENCES - 1).map(sentenceOf);
|
|
33796
|
+
return [...shown, `${groups.length - (MAX_SENTENCES - 1)} more existing tests passed before this run and fail now.`];
|
|
33797
|
+
}
|
|
33798
|
+
function oldBehaviourSentence(groups, max = 600) {
|
|
33799
|
+
const parts = groups.map((g) => `${g.file ? `${g.file}: ` : ""}"${g.title}"${g.rows > 1 ? ` (${g.rows} rows)` : ""}`);
|
|
33800
|
+
return clip2(`existing tests that may expect the old behaviour: ${parts.join("; ")}`, max);
|
|
33801
|
+
}
|
|
33802
|
+
function withoutLoop7Words(previous) {
|
|
33803
|
+
if (!previous.steps?.some((s) => s.refused?.includes(GIVE_UP_RULE))) return previous;
|
|
33804
|
+
const steps = previous.steps.map((s) => {
|
|
33805
|
+
if (!s.refused?.includes(GIVE_UP_RULE)) return s;
|
|
33806
|
+
const { refused: refused2, ...rest } = s;
|
|
33807
|
+
const kept = refused2.filter((w) => w !== GIVE_UP_RULE);
|
|
33808
|
+
return kept.length > 0 ? { ...rest, refused: kept } : rest;
|
|
33809
|
+
});
|
|
33810
|
+
return { ...previous, steps };
|
|
33811
|
+
}
|
|
33812
|
+
|
|
33703
33813
|
// src/regressionCheck.ts
|
|
33704
33814
|
var import_node_fs7 = require("node:fs");
|
|
33705
33815
|
|
|
@@ -33958,7 +34068,7 @@ function checkForRegressions(baseline, after) {
|
|
|
33958
34068
|
}
|
|
33959
34069
|
return { blocked: regressions.length > 0 || newFailures.length > 0, regressions, newFailures, preExisting, failureText, failureWhere, failureDetail };
|
|
33960
34070
|
}
|
|
33961
|
-
function describeRegressions(check) {
|
|
34071
|
+
function describeRegressions(check, options = {}) {
|
|
33962
34072
|
const withText = (id) => {
|
|
33963
34073
|
const text2 = check.failureText.get(id);
|
|
33964
34074
|
return text2 ? `${id} (${text2})` : id;
|
|
@@ -33966,7 +34076,7 @@ function describeRegressions(check) {
|
|
|
33966
34076
|
const parts = [];
|
|
33967
34077
|
if (check.regressions.length > 0) {
|
|
33968
34078
|
parts.push(
|
|
33969
|
-
`${check.regressions.length} regression(s) (passed before, now fail): ${check.regressions.map(withText).join(", ")}`
|
|
34079
|
+
options.existingTestsMayExpectOldBehaviour === true ? `${check.regressions.length} regression(s) (passed before, now fail), ${oldBehaviourSentence(groupRegressions(check.regressions), 700)}` : `${check.regressions.length} regression(s) (passed before, now fail): ${check.regressions.map(withText).join(", ")}`
|
|
33970
34080
|
);
|
|
33971
34081
|
}
|
|
33972
34082
|
if (check.newFailures.length > 0) {
|
|
@@ -34457,6 +34567,21 @@ var IMPORTERS_PER_FILE = 20;
|
|
|
34457
34567
|
var RELATED_SENTENCE = "Related tests only; the whole suite runs last.";
|
|
34458
34568
|
var forward2 = (p) => p.split("\\").join("/");
|
|
34459
34569
|
var unique = (xs) => [...new Set(xs)];
|
|
34570
|
+
function buildTestWorld(d) {
|
|
34571
|
+
const isTest = testRule(d.discoveredTests ?? null);
|
|
34572
|
+
const listing = new Set(d.listing);
|
|
34573
|
+
const corpus = new TestCorpus(
|
|
34574
|
+
listing,
|
|
34575
|
+
(rel) => {
|
|
34576
|
+
const text2 = d.readRel(rel);
|
|
34577
|
+
if (text2 === null) throw new Error("unreadable");
|
|
34578
|
+
return text2;
|
|
34579
|
+
},
|
|
34580
|
+
d.deniedPaths,
|
|
34581
|
+
isTest
|
|
34582
|
+
);
|
|
34583
|
+
return { listing, corpus, mapSpecifier: createAliasMapper({ readText: d.readRel, writeRoot: d.writeRoot }), readRel: d.readRel, isTest };
|
|
34584
|
+
}
|
|
34460
34585
|
function relatedLimitMs(baselineMs) {
|
|
34461
34586
|
if (baselineMs === null || !Number.isFinite(baselineMs)) return 3e5;
|
|
34462
34587
|
return Math.min(RELATED_MAX_LIMIT_MS, Math.max(RELATED_MIN_LIMIT_MS, baselineMs));
|
|
@@ -34504,20 +34629,13 @@ function createRelatedPlanner(d) {
|
|
|
34504
34629
|
}
|
|
34505
34630
|
let world = null;
|
|
34506
34631
|
function theWorld() {
|
|
34507
|
-
|
|
34508
|
-
|
|
34509
|
-
|
|
34510
|
-
|
|
34511
|
-
|
|
34512
|
-
(rel) =>
|
|
34513
|
-
|
|
34514
|
-
if (text2 === null) throw new Error("unreadable");
|
|
34515
|
-
return text2;
|
|
34516
|
-
},
|
|
34517
|
-
d.deniedPaths,
|
|
34518
|
-
isTest
|
|
34519
|
-
);
|
|
34520
|
-
world = { listing, corpus, mapSpecifier: createAliasMapper({ readText: readRel, writeRoot: d.writeRoot }), readRel };
|
|
34632
|
+
world ??= buildTestWorld({
|
|
34633
|
+
listing: d.listing,
|
|
34634
|
+
deniedPaths: d.deniedPaths,
|
|
34635
|
+
writeRoot: d.writeRoot,
|
|
34636
|
+
discoveredTests: d.discoveredTests ?? null,
|
|
34637
|
+
readRel: (rel) => readText(abs(rel))
|
|
34638
|
+
});
|
|
34521
34639
|
return world;
|
|
34522
34640
|
}
|
|
34523
34641
|
function findAlwaysRun() {
|
|
@@ -35755,7 +35873,7 @@ function wholeFailure(text2, where, max) {
|
|
|
35755
35873
|
return `${safe.slice(0, max - 1)}\u2026`;
|
|
35756
35874
|
}
|
|
35757
35875
|
var normalisePath = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
35758
|
-
function
|
|
35876
|
+
function samePlace2(a, b) {
|
|
35759
35877
|
const x = normalisePath(a);
|
|
35760
35878
|
const y = normalisePath(b);
|
|
35761
35879
|
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
@@ -35766,7 +35884,7 @@ function ownFailureIds(newFailures, changedPaths, requiredIds) {
|
|
|
35766
35884
|
const sep = id.indexOf("::");
|
|
35767
35885
|
const file = sep >= 0 ? id.slice(0, sep) : "";
|
|
35768
35886
|
const name = sep >= 0 ? id.slice(sep + 2) : id;
|
|
35769
|
-
const inChangedFile = file !== "" && changedPaths.some((p) =>
|
|
35887
|
+
const inChangedFile = file !== "" && changedPaths.some((p) => samePlace2(file, p));
|
|
35770
35888
|
const hasToken = requiredIds.some((t) => name.includes(`[${t}]`));
|
|
35771
35889
|
if (inChangedFile || hasToken) own.add(id);
|
|
35772
35890
|
}
|
|
@@ -40886,7 +41004,7 @@ function withUnreportable(stop, tests) {
|
|
|
40886
41004
|
if (stop.summary) carried.summary = stop.summary;
|
|
40887
41005
|
return carried;
|
|
40888
41006
|
}
|
|
40889
|
-
function
|
|
41007
|
+
function samePlace3(a, b) {
|
|
40890
41008
|
const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
40891
41009
|
const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
40892
41010
|
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
@@ -41025,6 +41143,7 @@ async function runCodegenLoop(args, deps) {
|
|
|
41025
41143
|
const redRuns = [];
|
|
41026
41144
|
let redRefusals = 0;
|
|
41027
41145
|
let importRefusals = 0;
|
|
41146
|
+
let giveUpRefusals = 0;
|
|
41028
41147
|
let redUnproven;
|
|
41029
41148
|
const currentRedRuns = () => {
|
|
41030
41149
|
const now2 = versionOfFiles(filesOnDisk());
|
|
@@ -41065,11 +41184,15 @@ async function runCodegenLoop(args, deps) {
|
|
|
41065
41184
|
let noProgressStreak = 0;
|
|
41066
41185
|
let forced = null;
|
|
41067
41186
|
const started = now();
|
|
41187
|
+
let toCheckList = null;
|
|
41188
|
+
const toCheck = () => toCheckList ??= (args.testsToCheck?.() ?? []).slice(0, 10);
|
|
41068
41189
|
const buildContext = (turn, isFinal, finalReason) => ({
|
|
41069
41190
|
...args.baseContext,
|
|
41070
41191
|
contractVersion,
|
|
41071
41192
|
// QUIKTR-1717 (§38.6): what a person has already decided about existing tests. Loop-7 only, and only when there is something to say.
|
|
41072
41193
|
...conflictTool && args.conflicts && args.conflicts.decided.length > 0 ? { decidedTests: args.conflicts.decided } : {},
|
|
41194
|
+
// QUIKTR-1827 (§38.8): the existing test files to read first. The tests phase of loop-7 only.
|
|
41195
|
+
...conflictTool && args.phase === "tests" && toCheck().length > 0 ? { testsToCheck: toCheck() } : {},
|
|
41073
41196
|
loop: {
|
|
41074
41197
|
turn,
|
|
41075
41198
|
maxTurns: limits.maxTurns,
|
|
@@ -41077,7 +41200,8 @@ async function runCodegenLoop(args, deps) {
|
|
|
41077
41200
|
...isFinal ? { finalReason } : {},
|
|
41078
41201
|
// Says this runner can carry a REFUSED answer (24.12a). Without it the runtime fails the request, as it always did.
|
|
41079
41202
|
acceptsRefused: true,
|
|
41080
|
-
|
|
41203
|
+
// QUIKTR-1827: a request below loop-7 is refused for a rule word only loop-7 raises, so the earlier attempt's steps are told without it.
|
|
41204
|
+
...previousAttempt ? { previousAttempt: conflictTool ? previousAttempt : withoutLoop7Words(previousAttempt) } : {},
|
|
41081
41205
|
// QUIKTR-1608 (§33): the phase, and the tests a disagreement step may amend. Harness version only.
|
|
41082
41206
|
...harness && args.phase ? { phase: args.phase } : {},
|
|
41083
41207
|
...harness && args.phase === "code" && args.lane?.kind === "code" && args.lane.amend ? { amend: args.lane.amend } : {},
|
|
@@ -41272,6 +41396,19 @@ async function runCodegenLoop(args, deps) {
|
|
|
41272
41396
|
if (conflictTool && conflictTool.unreportable().length > 0) {
|
|
41273
41397
|
throw unreportableFailure(conflictTool.unreportable(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
|
|
41274
41398
|
}
|
|
41399
|
+
const unexplained = conflictTool && lastTestAnswer ? unexplainedRegressions(lastTestAnswer, conflictTool.reportedTests()) : [];
|
|
41400
|
+
if (unexplained.length > 0 && giveUpRefusals < 1 && !isFinal) {
|
|
41401
|
+
giveUpRefusals += 1;
|
|
41402
|
+
const answer = { rules: [GIVE_UP_RULE], violations: giveUpSentences(unexplained), message: GIVE_UP_MESSAGE };
|
|
41403
|
+
refusedStreak += 1;
|
|
41404
|
+
refusedTurns.push({ turn, rules: answer.rules });
|
|
41405
|
+
log({ event: "codegen.give_up_check", turn, outcome: "sent_back", tests: unexplained.length });
|
|
41406
|
+
transcript.push({ turn, toolCalls: [], refused: answer });
|
|
41407
|
+
if (refusedStreak >= REFUSED_STREAK_LIMIT) forced = "refused_repeatedly";
|
|
41408
|
+
forced = settleNextTurn(turn, forced);
|
|
41409
|
+
continue;
|
|
41410
|
+
}
|
|
41411
|
+
if (unexplained.length > 0) log({ event: "codegen.give_up_check", turn, outcome: "gave_up_again", tests: unexplained.length });
|
|
41275
41412
|
const last = lastTestAnswer;
|
|
41276
41413
|
const redLeft = harness && args.phase === "tests" ? redProblem() : null;
|
|
41277
41414
|
if (harness && args.phase === "tests" && currentRedRuns().some((r) => r.failing.length > 0) && handOverRefusal(turn, true) === null && (redLeft === null || redLeft.kind === "passing")) {
|
|
@@ -41283,7 +41420,7 @@ async function runCodegenLoop(args, deps) {
|
|
|
41283
41420
|
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
|
|
41284
41421
|
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", gaveUp: true, steps: sentSteps(), ...lastTestAnswer ? { lastTestAnswer } : {} };
|
|
41285
41422
|
}
|
|
41286
|
-
throw new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said);
|
|
41423
|
+
throw new CodegenLoopFailure("cannot_complete", void 0, void 0, unexplained.length > 0 ? oldBehaviourSentence(unexplained, MAX_PREVIOUS_DETAIL_CHARS) : said, said);
|
|
41287
41424
|
}
|
|
41288
41425
|
if (body.outcome === "DONE") {
|
|
41289
41426
|
log({ event: "codegen.loop_turn", turn, outcome: "done", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
|
|
@@ -41358,7 +41495,7 @@ async function runCodegenLoop(args, deps) {
|
|
|
41358
41495
|
const doneSummary = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : "";
|
|
41359
41496
|
const lane = args.lane;
|
|
41360
41497
|
if (harness && args.phase === "code" && lane?.kind === "code" && !lane.amend && args.keepOnGiveUp === true) {
|
|
41361
|
-
const red2 = currentRedRuns().filter((r) => r.failing.some((name) => lane.frozen.some((p) =>
|
|
41498
|
+
const red2 = currentRedRuns().filter((r) => r.failing.some((name) => lane.frozen.some((p) => samePlace3(name.split("::")[0] ?? "", p)))).at(-1);
|
|
41362
41499
|
if (red2) {
|
|
41363
41500
|
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: red2.answer.regressions, newFailures: red2.answer.newFailures, after: "done" });
|
|
41364
41501
|
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary, gaveUp: true, steps: sentSteps(), lastTestAnswer: red2.answer };
|
|
@@ -41618,11 +41755,11 @@ async function runPhases(i2) {
|
|
|
41618
41755
|
}
|
|
41619
41756
|
const frozenFailing = (d2.lastTestAnswer?.failingTests ?? []).filter((name) => {
|
|
41620
41757
|
const file2 = name.split("::")[0] ?? "";
|
|
41621
|
-
return file2 !== "" && tests.frozen.some((path2) =>
|
|
41758
|
+
return file2 !== "" && tests.frozen.some((path2) => samePlace3(file2, path2));
|
|
41622
41759
|
});
|
|
41623
41760
|
const token = frozenFailing.length === 1 && d2.lastTestAnswer?.truncated !== true ? QP_TOKEN.exec(frozenFailing[0])?.[0] : void 0;
|
|
41624
41761
|
const file = token ? frozenFailing[0].split("::")[0] ?? "" : "";
|
|
41625
|
-
const amend = token ? tests.frozen.filter((path2) =>
|
|
41762
|
+
const amend = token ? tests.frozen.filter((path2) => samePlace3(file, path2)).slice(0, 1) : [];
|
|
41626
41763
|
phases.push(record("code", "gave_up", d2.summary));
|
|
41627
41764
|
i2.log({ event: "codegen.phase_end", attempt: i2.attempt, phase: "code", outcome: "gave_up", amendFiles: amend.length, frozenFailing: frozenFailing.length });
|
|
41628
41765
|
if (amend.length === 0 || !token) return { done: d2, tests, phases, summaries };
|
|
@@ -41942,8 +42079,8 @@ function pairedTestPaths(codePath, listing, isTest = isTestTarget) {
|
|
|
41942
42079
|
const stem = m[1].toLowerCase();
|
|
41943
42080
|
const dir = dirOf(codePath);
|
|
41944
42081
|
const parent = parentOf(dir);
|
|
41945
|
-
const
|
|
41946
|
-
const homes = /* @__PURE__ */ new Set([dir,
|
|
42082
|
+
const join15 = (d, leaf) => d === "" ? leaf : `${d}/${leaf}`;
|
|
42083
|
+
const homes = /* @__PURE__ */ new Set([dir, join15(dir, "__tests__"), join15(parent, "__tests__"), join15(parent, "tests"), join15(parent, "test")]);
|
|
41947
42084
|
const found = [];
|
|
41948
42085
|
for (const path of listing) {
|
|
41949
42086
|
if (!homes.has(dirOf(path))) continue;
|
|
@@ -42122,13 +42259,14 @@ function mapModeMessage(phase, reason) {
|
|
|
42122
42259
|
var CUT_AT = 190;
|
|
42123
42260
|
function failingNameIs(id, file, conflict) {
|
|
42124
42261
|
const { file: where, name } = splitTestId(id);
|
|
42125
|
-
if (where !== null && !
|
|
42262
|
+
if (where !== null && !samePlace4(where, file.path)) return false;
|
|
42126
42263
|
const title = file.newTitles.get(conflict.index) ?? conflict.testTitle;
|
|
42264
|
+
if (conflict.rows !== void 0) return rowPattern({ describes: conflict.describes, title }).test(name);
|
|
42127
42265
|
const full = [...conflict.describes, title];
|
|
42128
42266
|
const candidates = [title, full.join(" > "), full.join(" "), full.join(" \u203A ")];
|
|
42129
42267
|
return candidates.includes(name) || name.length >= CUT_AT && candidates.some((c) => c.startsWith(name));
|
|
42130
42268
|
}
|
|
42131
|
-
function
|
|
42269
|
+
function samePlace4(a, b) {
|
|
42132
42270
|
const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
42133
42271
|
const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
42134
42272
|
return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
|
|
@@ -42168,6 +42306,34 @@ async function verifyOnOldCode(conflicts, run2, log = () => void 0) {
|
|
|
42168
42306
|
return { kept, dropped };
|
|
42169
42307
|
}
|
|
42170
42308
|
|
|
42309
|
+
// src/testsToCheck.ts
|
|
42310
|
+
var import_node_fs16 = require("node:fs");
|
|
42311
|
+
var import_node_path18 = require("node:path");
|
|
42312
|
+
var MAX_TESTS_TO_CHECK = 10;
|
|
42313
|
+
function testsToCheck(i2) {
|
|
42314
|
+
const limit = Math.min(MAX_TESTS_TO_CHECK, Math.max(0, i2.limit ?? MAX_TESTS_TO_CHECK));
|
|
42315
|
+
const world = buildTestWorld(i2);
|
|
42316
|
+
const code = i2.targets.filter((t) => t.kind === "EXISTING" && !world.isTest(t.path) && (t.automationIds?.length ?? 0) === 0);
|
|
42317
|
+
if (code.length === 0 || limit === 0) return [];
|
|
42318
|
+
const taken = new Set(i2.targets.map((t) => t.path));
|
|
42319
|
+
const out = [];
|
|
42320
|
+
const add = (path) => {
|
|
42321
|
+
if (out.length < limit && !taken.has(path) && !out.includes(path)) out.push(path);
|
|
42322
|
+
};
|
|
42323
|
+
for (const t of code) for (const path of pairedTestPaths(t.path, world.listing, world.isTest)) add(path);
|
|
42324
|
+
for (const t of code) {
|
|
42325
|
+
for (const path of testsImporting({ target: t.path, listing: world.listing, corpus: world.corpus, mapSpecifier: world.mapSpecifier, limit, isTest: world.isTest })) add(path);
|
|
42326
|
+
}
|
|
42327
|
+
return out;
|
|
42328
|
+
}
|
|
42329
|
+
var readFromRoot = (root) => (rel) => {
|
|
42330
|
+
try {
|
|
42331
|
+
return (0, import_node_fs16.readFileSync)((0, import_node_path18.join)(root, rel), "utf8");
|
|
42332
|
+
} catch {
|
|
42333
|
+
return null;
|
|
42334
|
+
}
|
|
42335
|
+
};
|
|
42336
|
+
|
|
42171
42337
|
// src/codegenStep.ts
|
|
42172
42338
|
function testTargetPaths(targets, discoveredTests) {
|
|
42173
42339
|
const isTest = testRule(discoveredTests);
|
|
@@ -42228,6 +42394,26 @@ function orderProtectedForWire(protectedPaths, targetPaths, shownTests) {
|
|
|
42228
42394
|
keyed.sort((a, b) => a.tier - b.tier || b.near - a.near || (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
42229
42395
|
return keyed.map((k) => k.path);
|
|
42230
42396
|
}
|
|
42397
|
+
function testsToCheckOf(p) {
|
|
42398
|
+
const tests = p.tests;
|
|
42399
|
+
if (!tests) return {};
|
|
42400
|
+
return {
|
|
42401
|
+
testsToCheck: () => {
|
|
42402
|
+
try {
|
|
42403
|
+
const read = p.readFile ? (rel) => {
|
|
42404
|
+
try {
|
|
42405
|
+
return p.readFile(rel);
|
|
42406
|
+
} catch {
|
|
42407
|
+
return null;
|
|
42408
|
+
}
|
|
42409
|
+
} : readFromRoot(tests.root);
|
|
42410
|
+
return testsToCheck({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, writeRoot: p.writeRoot ?? "", discoveredTests: discoveredTestsOf(p.testDiscovery) ?? null, readRel: read });
|
|
42411
|
+
} catch {
|
|
42412
|
+
return [];
|
|
42413
|
+
}
|
|
42414
|
+
}
|
|
42415
|
+
};
|
|
42416
|
+
}
|
|
42231
42417
|
function buildCodegenLoopArgs(p, context = collectLoopContext({
|
|
42232
42418
|
targets: p.targets,
|
|
42233
42419
|
listing: p.workspaceListing,
|
|
@@ -42284,7 +42470,7 @@ function buildCodegenLoopArgs(p, context = collectLoopContext({
|
|
|
42284
42470
|
...p.mode === "loop-tests" && p.tests && p.harness !== false ? { harness: true } : {},
|
|
42285
42471
|
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2 ? { tools2: p.tools2 } : {},
|
|
42286
42472
|
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.callFunction ? { callFunction: p.callFunction } : {},
|
|
42287
|
-
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2?.notes === true && p.conflicts ? { conflicts: p.conflicts } : {},
|
|
42473
|
+
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2?.notes === true && p.conflicts ? { conflicts: p.conflicts, ...testsToCheckOf(p) } : {},
|
|
42288
42474
|
// An approved test change stands whatever version the AI Runtime speaks: a person decided it.
|
|
42289
42475
|
...p.approved && p.approved.length > 0 ? { approved: p.approved.map((r) => ({ targetPath: r.targetPath, newContent: r.newContent })) } : {}
|
|
42290
42476
|
};
|
|
@@ -42348,6 +42534,23 @@ function oldCodeRunner(args, log, now) {
|
|
|
42348
42534
|
return isTestAnswer(answer.output) ? answer.output : null;
|
|
42349
42535
|
};
|
|
42350
42536
|
}
|
|
42537
|
+
async function settleConflictStop(p, args, stop, clock) {
|
|
42538
|
+
const run2 = args?.tests && clock.now() < clock.hardStopAtMs ? oldCodeRunner(args, clock.log, clock.now) : null;
|
|
42539
|
+
const verified = await verifyOnOldCode(stop.conflicts, run2, clock.log);
|
|
42540
|
+
clock.log({ event: "codegen.conflict_stop", reported: stop.conflicts.length, standing: verified.kept.length, dropped: verified.dropped.length });
|
|
42541
|
+
if (verified.kept.length === 0) return null;
|
|
42542
|
+
const settled = new TestConflictStop(verified.kept, stop.fallback);
|
|
42543
|
+
if (stop.summary) {
|
|
42544
|
+
settled.summary = stop.summary;
|
|
42545
|
+
p.out.loop = buildCodegenLoopRecord({ ...stop.summary, stopReason: "test_conflict" });
|
|
42546
|
+
}
|
|
42547
|
+
return settled;
|
|
42548
|
+
}
|
|
42549
|
+
function warnUnreportable(p, stop) {
|
|
42550
|
+
for (const t of stop.unreportable) {
|
|
42551
|
+
warn(p, `Another existing test, in ${t.path} line ${t.line}, also expects what case ${t.caseId} calls wrong. It is written once for many rows, so no change to it was proposed: look at it before you approve.`);
|
|
42552
|
+
}
|
|
42553
|
+
}
|
|
42351
42554
|
async function runCodegenStep(p) {
|
|
42352
42555
|
if (p.mode !== "loop" && p.mode !== "loop-tests") return perFile(p);
|
|
42353
42556
|
const testSetup = p.mode === "loop-tests" ? p.tests : void 0;
|
|
@@ -42423,9 +42626,7 @@ async function runCodegenStep(p) {
|
|
|
42423
42626
|
if (err instanceof TestConflictStop) {
|
|
42424
42627
|
const settled = await settleStop(err);
|
|
42425
42628
|
if (settled) {
|
|
42426
|
-
|
|
42427
|
-
warn(p, `Another existing test, in ${t.path} line ${t.line}, also expects what case ${t.caseId} calls wrong. It is written once for many rows, so no change to it was proposed: look at it before you approve.`);
|
|
42428
|
-
}
|
|
42629
|
+
warnUnreportable(p, err);
|
|
42429
42630
|
throw settled;
|
|
42430
42631
|
}
|
|
42431
42632
|
return { failure: err.fallback instanceof CodegenLoopFailure ? err.fallback : new CodegenLoopFailure("cannot_complete") };
|
|
@@ -42435,16 +42636,7 @@ async function runCodegenStep(p) {
|
|
|
42435
42636
|
};
|
|
42436
42637
|
const settleStop = async (stop) => {
|
|
42437
42638
|
await guardTree();
|
|
42438
|
-
|
|
42439
|
-
const verified = await verifyOnOldCode(stop.conflicts, run2, log);
|
|
42440
|
-
log({ event: "codegen.conflict_stop", reported: stop.conflicts.length, standing: verified.kept.length, dropped: verified.dropped.length });
|
|
42441
|
-
if (verified.kept.length === 0) return null;
|
|
42442
|
-
const settled = new TestConflictStop(verified.kept, stop.fallback);
|
|
42443
|
-
if (stop.summary) {
|
|
42444
|
-
settled.summary = stop.summary;
|
|
42445
|
-
p.out.loop = buildCodegenLoopRecord({ ...stop.summary, stopReason: "test_conflict" });
|
|
42446
|
-
}
|
|
42447
|
-
return settled;
|
|
42639
|
+
return settleConflictStop(p, args, stop, { log, now, hardStopAtMs });
|
|
42448
42640
|
};
|
|
42449
42641
|
const finish = (done, attempts) => {
|
|
42450
42642
|
if (done.steps && done.steps.steps.length > 0) p.out.steps = done.steps;
|
|
@@ -42550,7 +42742,7 @@ async function runCodegenStep(p) {
|
|
|
42550
42742
|
}
|
|
42551
42743
|
|
|
42552
42744
|
// src/codegenHeal.ts
|
|
42553
|
-
var
|
|
42745
|
+
var import_node_fs17 = require("node:fs");
|
|
42554
42746
|
|
|
42555
42747
|
// src/heal.ts
|
|
42556
42748
|
var MAX_ATTEMPTS_IN_ALL = 3;
|
|
@@ -42616,7 +42808,7 @@ async function runHealAttempt(i2) {
|
|
|
42616
42808
|
const created = i2.results.map((r) => r.targetPath).filter((path) => !listed.has(path));
|
|
42617
42809
|
const workspaceListing = [...p.workspaceListing, ...created];
|
|
42618
42810
|
const targets = p.targets.map((t) => t.kind === "NEW_FILE" && keptText.has(t.path) ? { ...t, kind: "EXISTING" } : t);
|
|
42619
|
-
const disk = p.readFile ?? ((path) => (0,
|
|
42811
|
+
const disk = p.readFile ?? ((path) => (0, import_node_fs17.readFileSync)(path, "utf8"));
|
|
42620
42812
|
const readFile = (path) => keptText.get(path) ?? disk(path);
|
|
42621
42813
|
const discoveredTests = discoveredTestsOf(p.testDiscovery);
|
|
42622
42814
|
const context = collectLoopContext({ targets, listing: workspaceListing, deniedPaths: p.deniedPaths, writeRoot: p.writeRoot ?? "", ...discoveredTests ? { discoveredTests } : {}, readFile });
|
|
@@ -42625,7 +42817,7 @@ async function runHealAttempt(i2) {
|
|
|
42625
42817
|
collectLoopContext({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, writeRoot: p.writeRoot ?? "", ...discoveredTests ? { discoveredTests } : {}, readFile: disk })
|
|
42626
42818
|
);
|
|
42627
42819
|
const args = buildCodegenLoopArgs({ ...p, targets, workspaceListing }, context);
|
|
42628
|
-
delete args.conflicts;
|
|
42820
|
+
if (i2.review !== void 0 || i2.answer.regressions <= 0) delete args.conflicts;
|
|
42629
42821
|
args.protectedTestPaths = original.protectedTestPaths;
|
|
42630
42822
|
if (original.baseContext.protectedTestPaths !== void 0) args.baseContext.protectedTestPaths = original.baseContext.protectedTestPaths;
|
|
42631
42823
|
else delete args.baseContext.protectedTestPaths;
|
|
@@ -42658,6 +42850,18 @@ async function runHealAttempt(i2) {
|
|
|
42658
42850
|
if (done.steps && done.steps.steps.length > 0) p.out.steps = done.steps;
|
|
42659
42851
|
return done.results;
|
|
42660
42852
|
} catch (err) {
|
|
42853
|
+
if (err instanceof TestConflictStop) {
|
|
42854
|
+
i2.out.summary = err.summary;
|
|
42855
|
+
const log = p.deps?.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
42856
|
+
const settled = await settleConflictStop(p, args, err, { log, now, hardStopAtMs: i2.hardStopAtMs });
|
|
42857
|
+
if (settled) {
|
|
42858
|
+
warnUnreportable(p, err);
|
|
42859
|
+
throw settled;
|
|
42860
|
+
}
|
|
42861
|
+
const failure = err.fallback instanceof CodegenLoopFailure ? err.fallback : new CodegenLoopFailure("cannot_complete");
|
|
42862
|
+
i2.out.failure = failure;
|
|
42863
|
+
throw failure;
|
|
42864
|
+
}
|
|
42661
42865
|
if (err instanceof CodegenLoopFailure) {
|
|
42662
42866
|
i2.out.failure = err;
|
|
42663
42867
|
i2.out.summary = err.summary;
|
|
@@ -42859,11 +43063,11 @@ async function runVerifyAndFix(p) {
|
|
|
42859
43063
|
|
|
42860
43064
|
// src/hunkCheck.ts
|
|
42861
43065
|
var import_node_child_process9 = require("node:child_process");
|
|
42862
|
-
var
|
|
42863
|
-
var
|
|
43066
|
+
var import_node_fs19 = require("node:fs");
|
|
43067
|
+
var import_node_path19 = require("node:path");
|
|
42864
43068
|
|
|
42865
43069
|
// src/scopeCheck.ts
|
|
42866
|
-
var
|
|
43070
|
+
var import_node_fs18 = require("node:fs");
|
|
42867
43071
|
var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
|
|
42868
43072
|
var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
|
|
42869
43073
|
var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
|
|
@@ -42910,7 +43114,7 @@ function checkApiScope(results, targets, apiChanges) {
|
|
|
42910
43114
|
} else {
|
|
42911
43115
|
let currentContent;
|
|
42912
43116
|
try {
|
|
42913
|
-
currentContent = (0,
|
|
43117
|
+
currentContent = (0, import_node_fs18.readFileSync)(targetPath, "utf8");
|
|
42914
43118
|
} catch {
|
|
42915
43119
|
currentContent = "";
|
|
42916
43120
|
}
|
|
@@ -43006,7 +43210,7 @@ async function runHunkCheck(input) {
|
|
|
43006
43210
|
let slowestRunMs = input.baselineMs ?? 3e4;
|
|
43007
43211
|
const runOnce = async (c) => {
|
|
43008
43212
|
const reportBefore = findReport(input.root);
|
|
43009
|
-
const preserve = reportBefore ? [(0,
|
|
43213
|
+
const preserve = reportBefore ? [(0, import_node_path19.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
43010
43214
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
43011
43215
|
const startedWall = Date.now();
|
|
43012
43216
|
const startedAt = now();
|
|
@@ -43016,13 +43220,13 @@ async function runHunkCheck(input) {
|
|
|
43016
43220
|
input.root,
|
|
43017
43221
|
[{ path: c.file, content }],
|
|
43018
43222
|
async () => {
|
|
43019
|
-
if (reportBefore) (0,
|
|
43223
|
+
if (reportBefore) (0, import_node_fs19.rmSync)(reportBefore, { force: true });
|
|
43020
43224
|
const run2 = await runCommand2(input.command, perRunMs, input.root);
|
|
43021
43225
|
if (!run2.started || run2.timedOut) return "unknown";
|
|
43022
43226
|
const report = findReport(input.root);
|
|
43023
43227
|
if (!report) return "unknown";
|
|
43024
43228
|
try {
|
|
43025
|
-
if ((0,
|
|
43229
|
+
if ((0, import_node_fs19.statSync)(report).mtimeMs < startedWall - FRESH_SLACK_MS3) return "unknown";
|
|
43026
43230
|
} catch {
|
|
43027
43231
|
return "unknown";
|
|
43028
43232
|
}
|
|
@@ -43042,7 +43246,7 @@ async function runHunkCheck(input) {
|
|
|
43042
43246
|
};
|
|
43043
43247
|
const runRelated = async (c, plan, limitMs) => {
|
|
43044
43248
|
const reportBefore = findReport(input.root);
|
|
43045
|
-
const preserve = reportBefore ? [(0,
|
|
43249
|
+
const preserve = reportBefore ? [(0, import_node_path19.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
43046
43250
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
43047
43251
|
const startedAt = now();
|
|
43048
43252
|
result.relatedRuns += 1;
|
|
@@ -43051,7 +43255,7 @@ async function runHunkCheck(input) {
|
|
|
43051
43255
|
input.root,
|
|
43052
43256
|
[{ path: c.file, content }],
|
|
43053
43257
|
async () => {
|
|
43054
|
-
(0,
|
|
43258
|
+
(0, import_node_fs19.rmSync)(plan.report, { force: true });
|
|
43055
43259
|
try {
|
|
43056
43260
|
const run2 = await runCommand2(plan.command, limitMs, plan.cwd);
|
|
43057
43261
|
if (!run2.started || run2.timedOut) return "unknown";
|
|
@@ -43059,7 +43263,7 @@ async function runHunkCheck(input) {
|
|
|
43059
43263
|
if (!after.results || after.results.size === 0) return "unknown";
|
|
43060
43264
|
return checkForRegressions(input.baseline, after).blocked ? "needed" : "unneeded";
|
|
43061
43265
|
} finally {
|
|
43062
|
-
(0,
|
|
43266
|
+
(0, import_node_fs19.rmSync)(plan.report, { force: true });
|
|
43063
43267
|
}
|
|
43064
43268
|
},
|
|
43065
43269
|
{ ...input.tree, preserve }
|
|
@@ -43186,8 +43390,8 @@ function healFailureSuffix(heal) {
|
|
|
43186
43390
|
}
|
|
43187
43391
|
|
|
43188
43392
|
// src/dependencyCheck.ts
|
|
43189
|
-
var
|
|
43190
|
-
var
|
|
43393
|
+
var import_node_fs20 = require("node:fs");
|
|
43394
|
+
var import_node_path20 = require("node:path");
|
|
43191
43395
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
43192
43396
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
43193
43397
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -43275,14 +43479,14 @@ function dependencyNames(pkg) {
|
|
|
43275
43479
|
]);
|
|
43276
43480
|
}
|
|
43277
43481
|
function readDeclaredDependencies(results, workspaceRoot) {
|
|
43278
|
-
const packageJsonPath = (0,
|
|
43279
|
-
const generated = results.find((r) => (0,
|
|
43482
|
+
const packageJsonPath = (0, import_node_path20.join)((0, import_node_path20.resolve)(workspaceRoot ?? "."), "package.json");
|
|
43483
|
+
const generated = results.find((r) => (0, import_node_path20.resolve)(r.targetPath) === packageJsonPath);
|
|
43280
43484
|
let raw;
|
|
43281
43485
|
if (generated) {
|
|
43282
43486
|
raw = generated.newContent;
|
|
43283
43487
|
} else {
|
|
43284
43488
|
try {
|
|
43285
|
-
raw = (0,
|
|
43489
|
+
raw = (0, import_node_fs20.readFileSync)(packageJsonPath, "utf8");
|
|
43286
43490
|
} catch {
|
|
43287
43491
|
raw = null;
|
|
43288
43492
|
}
|
|
@@ -43346,16 +43550,16 @@ function stripJsonComments(text2) {
|
|
|
43346
43550
|
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
43347
43551
|
}
|
|
43348
43552
|
function resolveAliasPrefixes(results, workspaceRoot) {
|
|
43349
|
-
const root = (0,
|
|
43553
|
+
const root = (0, import_node_path20.resolve)(workspaceRoot ?? ".");
|
|
43350
43554
|
for (const filename of ["tsconfig.json", "jsconfig.json"]) {
|
|
43351
|
-
const configPath = (0,
|
|
43352
|
-
const generated = results.find((r) => (0,
|
|
43555
|
+
const configPath = (0, import_node_path20.join)(root, filename);
|
|
43556
|
+
const generated = results.find((r) => (0, import_node_path20.resolve)(r.targetPath) === configPath);
|
|
43353
43557
|
let raw;
|
|
43354
43558
|
if (generated) {
|
|
43355
43559
|
raw = generated.newContent;
|
|
43356
43560
|
} else {
|
|
43357
43561
|
try {
|
|
43358
|
-
raw = (0,
|
|
43562
|
+
raw = (0, import_node_fs20.readFileSync)(configPath, "utf8");
|
|
43359
43563
|
} catch {
|
|
43360
43564
|
raw = null;
|
|
43361
43565
|
}
|
|
@@ -43605,13 +43809,13 @@ function describeUnsuppliedInputs(found) {
|
|
|
43605
43809
|
}
|
|
43606
43810
|
|
|
43607
43811
|
// src/unsuppliedInputsDisk.ts
|
|
43608
|
-
var
|
|
43812
|
+
var import_node_fs21 = require("node:fs");
|
|
43609
43813
|
var MAX_READ_BYTES = 1e6;
|
|
43610
43814
|
function readCheckoutText(path) {
|
|
43611
43815
|
try {
|
|
43612
|
-
const info = (0,
|
|
43816
|
+
const info = (0, import_node_fs21.statSync)(path);
|
|
43613
43817
|
if (!info.isFile() || info.size > MAX_READ_BYTES) return null;
|
|
43614
|
-
const bytes = (0,
|
|
43818
|
+
const bytes = (0, import_node_fs21.readFileSync)(path);
|
|
43615
43819
|
if (bytes.includes(0)) return null;
|
|
43616
43820
|
return bytes.toString("utf8");
|
|
43617
43821
|
} catch {
|
|
@@ -43641,7 +43845,7 @@ function describeVanishedTests(vanished) {
|
|
|
43641
43845
|
}
|
|
43642
43846
|
|
|
43643
43847
|
// src/verifyChange.ts
|
|
43644
|
-
var
|
|
43848
|
+
var import_node_path21 = require("node:path");
|
|
43645
43849
|
|
|
43646
43850
|
// src/packageUse.ts
|
|
43647
43851
|
var import_node_child_process10 = require("node:child_process");
|
|
@@ -43668,7 +43872,7 @@ function packageImportedInWorkspace(pkg, root, cwd = process.cwd()) {
|
|
|
43668
43872
|
}
|
|
43669
43873
|
|
|
43670
43874
|
// src/verifyChange.ts
|
|
43671
|
-
var
|
|
43875
|
+
var import_node_fs22 = require("node:fs");
|
|
43672
43876
|
async function verifyChange(ctx, results, undoable) {
|
|
43673
43877
|
const cwd = ctx.cwd ?? process.cwd();
|
|
43674
43878
|
const now = ctx.now ?? Date.now;
|
|
@@ -43703,7 +43907,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
43703
43907
|
const depCheck = checkImportDependencies(results, readDeclaredDependencies(results, packet.workspaceRoot), resolveAliasPrefixes(results, packet.workspaceRoot), {
|
|
43704
43908
|
originalOf: (path) => {
|
|
43705
43909
|
try {
|
|
43706
|
-
return (0,
|
|
43910
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path21.join)(cwd, path), "utf8");
|
|
43707
43911
|
} catch (err) {
|
|
43708
43912
|
return err.code === "ENOENT" ? "" : null;
|
|
43709
43913
|
}
|
|
@@ -43753,7 +43957,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
43753
43957
|
flushedAt = now();
|
|
43754
43958
|
if (undoable) {
|
|
43755
43959
|
const report = findJUnitReport(cwd);
|
|
43756
|
-
const ignore = report ? [(0,
|
|
43960
|
+
const ignore = report ? [(0, import_node_path21.relative)(cwd, report).split("\\").join("/")] : [];
|
|
43757
43961
|
const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
|
|
43758
43962
|
undo = () => flush.undo();
|
|
43759
43963
|
} else {
|
|
@@ -43800,7 +44004,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
43800
44004
|
if (check.blocked) {
|
|
43801
44005
|
const readable = Boolean(baseline.results && after.results);
|
|
43802
44006
|
const answered = readable ? testAnswerFrom({ baseline, after, changedPaths: results.map((r) => r.targetPath), requiredIds: ctx.requiredAutomationIds, harness: ctx.harness === true }) : null;
|
|
43803
|
-
return fail(new Error(`QuikPilot's generated code introduced test failures \u2014 ${describeRegressions(check)}`), {
|
|
44007
|
+
return fail(new Error(`QuikPilot's generated code introduced test failures \u2014 ${describeRegressions(check, { existingTestsMayExpectOldBehaviour: ctx.conflictsOn === true })}`), {
|
|
43804
44008
|
check,
|
|
43805
44009
|
bothSnapshotsReadable: readable,
|
|
43806
44010
|
...answered ? { answer: answered.output, failingKey: answered.failingKey } : {}
|
|
@@ -43829,7 +44033,7 @@ ${violations.join("\n")}`);
|
|
|
43829
44033
|
}
|
|
43830
44034
|
|
|
43831
44035
|
// src/run.ts
|
|
43832
|
-
var
|
|
44036
|
+
var import_node_fs25 = require("node:fs");
|
|
43833
44037
|
|
|
43834
44038
|
// src/mapMode.ts
|
|
43835
44039
|
var MAP_ENV = "QUIKPILOT_MAP";
|
|
@@ -43887,7 +44091,7 @@ function buildToolsV2Env(i2) {
|
|
|
43887
44091
|
}
|
|
43888
44092
|
|
|
43889
44093
|
// src/repoMap.ts
|
|
43890
|
-
var
|
|
44094
|
+
var import_node_path22 = require("node:path");
|
|
43891
44095
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
43892
44096
|
var MAX_FOLDERS = 200;
|
|
43893
44097
|
var MAX_LANGUAGES = 12;
|
|
@@ -43900,7 +44104,7 @@ var MAX_ENTRY_CHARS = 200;
|
|
|
43900
44104
|
var inside = (path, root) => root === "" || path === root || path.startsWith(`${root}/`);
|
|
43901
44105
|
var cap = (s) => s.length <= MAX_ENTRY_CHARS ? s : `${s.slice(0, MAX_ENTRY_CHARS - 1)}\u2026`;
|
|
43902
44106
|
var parentOf2 = (d) => d.includes("/") ? d.slice(0, d.lastIndexOf("/")) : "";
|
|
43903
|
-
function
|
|
44107
|
+
function clip3(text2, max) {
|
|
43904
44108
|
if (text2.length <= max) return { text: text2, truncated: false };
|
|
43905
44109
|
const cut = text2.slice(0, max);
|
|
43906
44110
|
const nl = cut.lastIndexOf("\n");
|
|
@@ -43918,7 +44122,7 @@ function guidanceFiles(i2, perFile2, total) {
|
|
|
43918
44122
|
if (!tracked.has(path) || matchesDeniedPath(path, denied)) continue;
|
|
43919
44123
|
const raw = i2.readText(path);
|
|
43920
44124
|
if (raw === null || raw.trim() === "") continue;
|
|
43921
|
-
const clipped =
|
|
44125
|
+
const clipped = clip3(i2.scrub(raw.replace(/\r\n/g, "\n")).trim(), Math.min(perFile2, left));
|
|
43922
44126
|
out.push({ path, ...clipped });
|
|
43923
44127
|
left -= clipped.text.length;
|
|
43924
44128
|
}
|
|
@@ -43929,7 +44133,7 @@ function guidanceFiles(i2, perFile2, total) {
|
|
|
43929
44133
|
function languages(listing) {
|
|
43930
44134
|
const counts = /* @__PURE__ */ new Map();
|
|
43931
44135
|
for (const p of listing) {
|
|
43932
|
-
const ext =
|
|
44136
|
+
const ext = import_node_path22.posix.extname(p).toLowerCase();
|
|
43933
44137
|
if (ext && ext.length <= 12) counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
43934
44138
|
}
|
|
43935
44139
|
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}`);
|
|
@@ -43945,7 +44149,7 @@ function testFacts(i2) {
|
|
|
43945
44149
|
const depth = i2.writeRoot === "" ? 0 : i2.writeRoot.split("/").length;
|
|
43946
44150
|
for (const t of tests) {
|
|
43947
44151
|
const parts = t.split("/");
|
|
43948
|
-
const folder = parts.length > depth + 1 ? parts.slice(0, depth + 1).join("/") :
|
|
44152
|
+
const folder = parts.length > depth + 1 ? parts.slice(0, depth + 1).join("/") : import_node_path22.posix.dirname(t);
|
|
43949
44153
|
byFolder.set(folder, (byFolder.get(folder) ?? 0) + 1);
|
|
43950
44154
|
}
|
|
43951
44155
|
for (const [folder, n] of [...byFolder.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 3)) {
|
|
@@ -44055,7 +44259,7 @@ function buildRepoMap(i2) {
|
|
|
44055
44259
|
}
|
|
44056
44260
|
|
|
44057
44261
|
// src/workspacePackages.ts
|
|
44058
|
-
var
|
|
44262
|
+
var import_node_path23 = require("node:path");
|
|
44059
44263
|
var MAX_READ_ROOTS = 8;
|
|
44060
44264
|
function isObject2(x) {
|
|
44061
44265
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -44117,8 +44321,8 @@ function workspacePackages(readText, packageJsonPaths) {
|
|
|
44117
44321
|
const exclude = patterns.filter((p) => p.startsWith("!")).map((p) => globMatcher(p.slice(1)));
|
|
44118
44322
|
const out = [];
|
|
44119
44323
|
for (const file of packageJsonPaths) {
|
|
44120
|
-
if (
|
|
44121
|
-
const folder =
|
|
44324
|
+
if (import_node_path23.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
|
|
44325
|
+
const folder = import_node_path23.posix.dirname(file);
|
|
44122
44326
|
if (!include.some((re) => re.test(folder)) || exclude.some((re) => re.test(folder))) continue;
|
|
44123
44327
|
const text2 = readText(file);
|
|
44124
44328
|
const json = text2 === null ? null : parseJsonc(text2);
|
|
@@ -44387,34 +44591,34 @@ async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
|
44387
44591
|
}
|
|
44388
44592
|
|
|
44389
44593
|
// src/phase0.ts
|
|
44390
|
-
var
|
|
44594
|
+
var import_node_fs23 = require("node:fs");
|
|
44391
44595
|
function writePhase0Marker(runId) {
|
|
44392
|
-
(0,
|
|
44393
|
-
(0,
|
|
44596
|
+
(0, import_node_fs23.mkdirSync)(".quikpilot", { recursive: true });
|
|
44597
|
+
(0, import_node_fs23.appendFileSync)(".quikpilot/phase0-marker.txt", `QuikPilot Phase 0 skeleton marker for run ${runId}
|
|
44394
44598
|
`);
|
|
44395
44599
|
}
|
|
44396
44600
|
|
|
44397
44601
|
// src/failureArtifact.ts
|
|
44398
|
-
var
|
|
44399
|
-
var
|
|
44602
|
+
var import_node_fs24 = require("node:fs");
|
|
44603
|
+
var import_node_path24 = require("node:path");
|
|
44400
44604
|
var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
44401
44605
|
var REPORT_COPY = "final-test-report.xml";
|
|
44402
44606
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
44403
44607
|
var MAX_FILES = 200;
|
|
44404
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
44608
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.44" : "dev";
|
|
44405
44609
|
function safeDestination(base, repoPath) {
|
|
44406
|
-
if (!repoPath || (0,
|
|
44407
|
-
const destination = (0,
|
|
44408
|
-
const rel = (0,
|
|
44409
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
44610
|
+
if (!repoPath || (0, import_node_path24.isAbsolute)(repoPath)) return null;
|
|
44611
|
+
const destination = (0, import_node_path24.resolve)(base, repoPath);
|
|
44612
|
+
const rel = (0, import_node_path24.relative)(base, destination);
|
|
44613
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path24.isAbsolute)(rel)) return null;
|
|
44410
44614
|
return destination;
|
|
44411
44615
|
}
|
|
44412
44616
|
function writeFailureArtifact(input) {
|
|
44413
44617
|
if (input.results.length === 0) return { written: false };
|
|
44414
44618
|
try {
|
|
44415
|
-
const base = (0,
|
|
44416
|
-
(0,
|
|
44417
|
-
(0,
|
|
44619
|
+
const base = (0, import_node_path24.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
44620
|
+
(0, import_node_fs24.rmSync)(base, { recursive: true, force: true });
|
|
44621
|
+
(0, import_node_fs24.mkdirSync)(base, { recursive: true });
|
|
44418
44622
|
const files = [];
|
|
44419
44623
|
const skipped = [];
|
|
44420
44624
|
for (const result of input.results) {
|
|
@@ -44423,8 +44627,8 @@ function writeFailureArtifact(input) {
|
|
|
44423
44627
|
skipped.push(result.targetPath);
|
|
44424
44628
|
continue;
|
|
44425
44629
|
}
|
|
44426
|
-
(0,
|
|
44427
|
-
(0,
|
|
44630
|
+
(0, import_node_fs24.mkdirSync)((0, import_node_path24.dirname)(destination), { recursive: true });
|
|
44631
|
+
(0, import_node_fs24.writeFileSync)(destination, result.newContent);
|
|
44428
44632
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
44429
44633
|
}
|
|
44430
44634
|
let testReport = "none";
|
|
@@ -44432,7 +44636,7 @@ function writeFailureArtifact(input) {
|
|
|
44432
44636
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
44433
44637
|
testReport = "too-large";
|
|
44434
44638
|
} else {
|
|
44435
|
-
(0,
|
|
44639
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path24.join)(base, REPORT_COPY), input.testReport);
|
|
44436
44640
|
testReport = "included";
|
|
44437
44641
|
}
|
|
44438
44642
|
}
|
|
@@ -44452,8 +44656,8 @@ function writeFailureArtifact(input) {
|
|
|
44452
44656
|
failureReasons: input.failureReasons
|
|
44453
44657
|
};
|
|
44454
44658
|
const text2 = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
|
|
44455
|
-
(0,
|
|
44456
|
-
return { written: (0,
|
|
44659
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path24.join)(base, "manifest.json"), text2);
|
|
44660
|
+
return { written: (0, import_node_fs24.existsSync)((0, import_node_path24.join)(base, "manifest.json")) };
|
|
44457
44661
|
} catch (err) {
|
|
44458
44662
|
console.warn(`::warning::Could not keep the failed run's files: ${err instanceof Error ? err.message : String(err)}`);
|
|
44459
44663
|
return { written: false };
|
|
@@ -45051,7 +45255,7 @@ async function run(env2) {
|
|
|
45051
45255
|
const workspaceListing = listWorkspaceFiles(writeRoot === "" ? null : writeRoot);
|
|
45052
45256
|
const readCheckoutText2 = (path) => {
|
|
45053
45257
|
try {
|
|
45054
|
-
return (0,
|
|
45258
|
+
return (0, import_node_fs25.readFileSync)(path, "utf8");
|
|
45055
45259
|
} catch {
|
|
45056
45260
|
return null;
|
|
45057
45261
|
}
|
|
@@ -45250,6 +45454,8 @@ async function run(env2) {
|
|
|
45250
45454
|
requiredAutomationIds: claimedAutomationIds(stepParams),
|
|
45251
45455
|
// The harness version, unless the AI Runtime refused it during code writing (then every fix speaks loop-2 too).
|
|
45252
45456
|
harness: codegenMode === "loop-tests" && stepParams.harness !== false,
|
|
45457
|
+
// QUIKTR-1827: a regression of an existing test is worded as a test that may expect the old behaviour where a person can be asked.
|
|
45458
|
+
conflictsOn,
|
|
45253
45459
|
// S4: the final run of the project's tests has a clock sized from how long the baseline took and from what is left of the job.
|
|
45254
45460
|
baselineMs: timedBaseline.durationMs,
|
|
45255
45461
|
jobStopAtMs,
|
|
@@ -45259,7 +45465,7 @@ async function run(env2) {
|
|
|
45259
45465
|
const at2 = id.indexOf("::");
|
|
45260
45466
|
const file = at2 === -1 ? "" : id.slice(0, at2);
|
|
45261
45467
|
const name = at2 === -1 ? id : id.slice(at2 + 2);
|
|
45262
|
-
return approved.titles.some((t) => (file === "" || file.endsWith(t.path) || t.path.endsWith(file)) && (name
|
|
45468
|
+
return approved.titles.some((t) => (file === "" || file.endsWith(t.path) || t.path.endsWith(file)) && nameEndsWithTitle(name, t.title));
|
|
45263
45469
|
}
|
|
45264
45470
|
} : {}
|
|
45265
45471
|
};
|