@quikit/quikpilot-runner 9.3.0-rc.50 → 9.3.0-rc.51
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 +479 -49
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24695,12 +24695,35 @@ function push(branch, installationToken, sleep = sleepSync) {
|
|
|
24695
24695
|
// src/testHistory.ts
|
|
24696
24696
|
var import_node_child_process2 = require("node:child_process");
|
|
24697
24697
|
|
|
24698
|
+
// src/testFileRules.ts
|
|
24699
|
+
var TEST_NAME_RULES = [
|
|
24700
|
+
// Go: `foo_test.go`, in the package folder beside `foo.go`.
|
|
24701
|
+
/_test\.go$/i,
|
|
24702
|
+
// Python: `test_foo.py` and `foo_test.py`, wherever they sit. `conftest.py` is a helper, not a test (a `tests/` folder still covers it).
|
|
24703
|
+
/(^|\/)test_[^/]+\.py$/i,
|
|
24704
|
+
/_test\.py$/i,
|
|
24705
|
+
// Java, Kotlin, Scala, C#, Swift: `FooTest`, `FooTests`. Case-sensitive on purpose: `Contest.java` is not a test.
|
|
24706
|
+
/Tests?\.(?:java|kt|kts|scala|cs|swift)$/,
|
|
24707
|
+
// Ruby: `foo_spec.rb`, `foo_test.rb`.
|
|
24708
|
+
/_(?:spec|test)\.rb$/,
|
|
24709
|
+
// PHP (PHPUnit): `FooTest.php`.
|
|
24710
|
+
/Test\.php$/,
|
|
24711
|
+
// Rust and Dart: `foo_test.rs`, `foo_test.dart`.
|
|
24712
|
+
/_test\.(?:rs|dart)$/
|
|
24713
|
+
];
|
|
24714
|
+
function nameRulesEnabled(env2 = process.env) {
|
|
24715
|
+
return env2.QUIKPILOT_TEST_RULES?.trim().toLowerCase() !== "js";
|
|
24716
|
+
}
|
|
24717
|
+
function isTestByName(path, env2 = process.env) {
|
|
24718
|
+
return nameRulesEnabled(env2) && TEST_NAME_RULES.some((re) => re.test(path));
|
|
24719
|
+
}
|
|
24720
|
+
|
|
24698
24721
|
// src/testPath.ts
|
|
24699
24722
|
var TEST_PATH_RE = /(\.(test|spec)\.[jt]sx?$)|(^|\/)(__tests__|tests?)\//i;
|
|
24700
24723
|
var STRONG_TEST_RE = /(\.(test|spec)\.[jt]sx?$)|(^|\/)__tests__\//i;
|
|
24701
|
-
var TEST_STYLE_NAME_RES = [/\.(test|spec)\.[^/.]+$/i, /(^|\/)test_[^/]+\.py$/i, /_test\.(py|go)$/i, /Tests?\.(java|kt|cs)
|
|
24724
|
+
var TEST_STYLE_NAME_RES = [/\.(test|spec)\.[^/.]+$/i, /(^|\/)test_[^/]+\.py$/i, /_test\.(py|go)$/i, /Tests?\.(java|kt|cs)$/, ...TEST_NAME_RULES];
|
|
24702
24725
|
function isTestTarget(path, discovered) {
|
|
24703
|
-
if (!TEST_PATH_RE.test(path)) return
|
|
24726
|
+
if (!TEST_PATH_RE.test(path)) return isTestByName(path);
|
|
24704
24727
|
if (!discovered || STRONG_TEST_RE.test(path)) return true;
|
|
24705
24728
|
return discovered.has(path) || TEST_STYLE_NAME_RES.some((re) => re.test(path));
|
|
24706
24729
|
}
|
|
@@ -24713,7 +24736,9 @@ var TEST_FILE_RES = [
|
|
|
24713
24736
|
/\.(test|spec)\.[^/.]+$/i,
|
|
24714
24737
|
/(^|\/)test_[^/]+\.py$/i,
|
|
24715
24738
|
/_test\.(py|go)$/i,
|
|
24716
|
-
/Tests?\.(java|kt|cs)
|
|
24739
|
+
/Tests?\.(java|kt|cs)$/,
|
|
24740
|
+
// QUIKTR-1854: the same names `isTestTarget` knows, so the two rules agree on them (a superset of what this one said before).
|
|
24741
|
+
...TEST_NAME_RULES
|
|
24717
24742
|
];
|
|
24718
24743
|
function isTestFile(path) {
|
|
24719
24744
|
return TEST_FILE_RES.some((re) => re.test(path));
|
|
@@ -33854,7 +33879,7 @@ function testsImporting(p) {
|
|
|
33854
33879
|
function testsThroughOneFile(p) {
|
|
33855
33880
|
const isTest = p.isTest ?? isTestTarget;
|
|
33856
33881
|
if (p.limit <= 0 || isTest(p.target) || !supportsImportScan(p.target)) return [];
|
|
33857
|
-
const
|
|
33882
|
+
const importsOf2 = /* @__PURE__ */ new Map();
|
|
33858
33883
|
const shared = /* @__PURE__ */ new Map();
|
|
33859
33884
|
for (const file of p.corpus.files()) {
|
|
33860
33885
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -33862,7 +33887,7 @@ function testsThroughOneFile(p) {
|
|
|
33862
33887
|
const r = resolveImport(file.path, spec, p.listing, p.mapSpecifier);
|
|
33863
33888
|
if (r.kind === "repo" && r.path !== file.path) seen.add(r.path);
|
|
33864
33889
|
}
|
|
33865
|
-
|
|
33890
|
+
importsOf2.set(file.path, seen);
|
|
33866
33891
|
for (const q of seen) {
|
|
33867
33892
|
if (q === p.target || isTest(q) || !supportsImportScan(q) || matchesDeniedPath(q, p.deniedPaths ?? [])) continue;
|
|
33868
33893
|
shared.set(q, (shared.get(q) ?? 0) + 1);
|
|
@@ -33886,7 +33911,7 @@ function testsThroughOneFile(p) {
|
|
|
33886
33911
|
}
|
|
33887
33912
|
if (via.size === 0) return [];
|
|
33888
33913
|
const importers = /* @__PURE__ */ new Map();
|
|
33889
|
-
for (const [test, imports] of
|
|
33914
|
+
for (const [test, imports] of importsOf2) {
|
|
33890
33915
|
if (p.exclude?.has(test) || test === p.target || imports.has(p.target)) continue;
|
|
33891
33916
|
for (const q of imports) if (via.has(q)) importers.set(q, [...importers.get(q) ?? [], test]);
|
|
33892
33917
|
}
|
|
@@ -37160,6 +37185,8 @@ var REASON_WORDS = {
|
|
|
37160
37185
|
truncation_guard: "a file it rewrote looked cut short",
|
|
37161
37186
|
syntax_error: "a file it changed would not run (a syntax error, or a name that is used but never defined or imported)",
|
|
37162
37187
|
out_of_time: "the time allowed for writing the change ran out",
|
|
37188
|
+
// QUIKTR-1854: an existing test in a language QuikPilot cannot yet ask about pins the bug (only JavaScript and TypeScript tests can be reported).
|
|
37189
|
+
test_unsupported_language: "an existing test expects what an approved case calls wrong, but QuikPilot cannot yet ask about existing tests in this language (only JavaScript and TypeScript), so no change to it could be proposed",
|
|
37163
37190
|
test_conflict_unreportable: "an existing test expects what an approved case calls wrong, and it is written once for many rows, so no change to it could be proposed"
|
|
37164
37191
|
};
|
|
37165
37192
|
function reasonInWords(reason) {
|
|
@@ -41541,6 +41568,7 @@ var CodegenLoopFailure = class extends Error {
|
|
|
41541
41568
|
}
|
|
41542
41569
|
};
|
|
41543
41570
|
var MAX_UNREPORTABLE_DETAIL_CHARS = 300;
|
|
41571
|
+
var UNSUPPORTED_TEST_LANGUAGE_SENTENCE = "an existing test expects what an approved case calls wrong, but existing tests in this language cannot be reported yet (QUIKTR-1855)";
|
|
41544
41572
|
function unreportableFailure(tests, cause) {
|
|
41545
41573
|
const detail = tests.map((t) => `${t.path} line ${t.line} (case ${t.caseId})`).join("; ").slice(0, MAX_UNREPORTABLE_DETAIL_CHARS);
|
|
41546
41574
|
const failure = new CodegenLoopFailure("test_conflict_unreportable", void 0, cause, detail);
|
|
@@ -41983,6 +42011,9 @@ async function runCodegenLoop(args, deps) {
|
|
|
41983
42011
|
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
|
|
41984
42012
|
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", gaveUp: true, steps: sentSteps(), ...lastTestAnswer ? { lastTestAnswer } : {} };
|
|
41985
42013
|
}
|
|
42014
|
+
if ((conflictTool?.record().rejectedBy["unsupported_language"] ?? 0) > 0) {
|
|
42015
|
+
throw new CodegenLoopFailure("test_unsupported_language", void 0, void 0, UNSUPPORTED_TEST_LANGUAGE_SENTENCE, said);
|
|
42016
|
+
}
|
|
41986
42017
|
throw new CodegenLoopFailure("cannot_complete", void 0, void 0, unexplained.length > 0 ? oldBehaviourSentence(unexplained, MAX_PREVIOUS_DETAIL_CHARS) : said, said);
|
|
41987
42018
|
}
|
|
41988
42019
|
if (body.outcome === "DONE") {
|
|
@@ -42631,8 +42662,371 @@ function buildCodegenLoopRecord(loop) {
|
|
|
42631
42662
|
|
|
42632
42663
|
// src/codegenLoopContext.ts
|
|
42633
42664
|
var import_node_fs15 = require("node:fs");
|
|
42665
|
+
|
|
42666
|
+
// src/langReach.ts
|
|
42667
|
+
var import_node_path18 = require("node:path");
|
|
42668
|
+
var LANGUAGE_BY_EXT = {
|
|
42669
|
+
".go": "go",
|
|
42670
|
+
".py": "python",
|
|
42671
|
+
".java": "jvm",
|
|
42672
|
+
".kt": "jvm",
|
|
42673
|
+
".kts": "jvm",
|
|
42674
|
+
".scala": "jvm",
|
|
42675
|
+
".cs": "csharp",
|
|
42676
|
+
".rb": "ruby",
|
|
42677
|
+
".php": "php",
|
|
42678
|
+
".rs": "rust",
|
|
42679
|
+
".dart": "dart",
|
|
42680
|
+
".swift": "swift"
|
|
42681
|
+
};
|
|
42682
|
+
function languageOf(path) {
|
|
42683
|
+
return LANGUAGE_BY_EXT[import_node_path18.posix.extname(path).toLowerCase()] ?? null;
|
|
42684
|
+
}
|
|
42685
|
+
var MAX_REACH_TESTS = 10;
|
|
42686
|
+
var MAX_IMPORT_STEPS = 3;
|
|
42687
|
+
var MAX_WALK_ROUNDS = 10;
|
|
42688
|
+
var MAX_WALK_FILES = 5e3;
|
|
42689
|
+
var HUB_LIMIT = 25;
|
|
42690
|
+
var COMMON_MENTION_LIMIT = 12;
|
|
42691
|
+
var MAX_FILES_READ = 4e3;
|
|
42692
|
+
var MAX_FILE_CHARS2 = 2e5;
|
|
42693
|
+
var MIN_NAME_CHARS = 4;
|
|
42694
|
+
var MIN_CLASS_NAME_CHARS = 3;
|
|
42695
|
+
var GENERIC_NAMES = /* @__PURE__ */ new Set(["main", "init", "test", "tests", "self", "this", "none", "true", "false", "null", "name", "value", "data", "type", "list", "dict", "string", "int", "bool", "error", "result", "new", "get", "set", "run"]);
|
|
42696
|
+
function lookSymbolsOf(findings) {
|
|
42697
|
+
const out = /* @__PURE__ */ new Map();
|
|
42698
|
+
if (!findings) return out;
|
|
42699
|
+
const add = (path, name) => {
|
|
42700
|
+
const list2 = out.get(path) ?? out.set(path, []).get(path);
|
|
42701
|
+
if (!list2.includes(name)) list2.push(name);
|
|
42702
|
+
};
|
|
42703
|
+
for (const f of findings.files) for (const s of f.symbols) add(f.path, s);
|
|
42704
|
+
for (const c of findings.callPath) add(c.path, c.symbol);
|
|
42705
|
+
return out;
|
|
42706
|
+
}
|
|
42707
|
+
var baseNoExt = (p) => import_node_path18.posix.basename(p).replace(/\.[^.]+$/, "");
|
|
42708
|
+
var dirOf = (p) => import_node_path18.posix.dirname(p) === "." ? "" : import_node_path18.posix.dirname(p);
|
|
42709
|
+
function testStem(path) {
|
|
42710
|
+
return baseNoExt(path).replace(/^test_/i, "").replace(/(_test|_spec)$/i, "").replace(/Tests?$/, "").toLowerCase();
|
|
42711
|
+
}
|
|
42712
|
+
function codeStem(path) {
|
|
42713
|
+
const b = baseNoExt(path);
|
|
42714
|
+
if (b === "__init__" || b === "mod" || b === "index") return import_node_path18.posix.basename(dirOf(path)).toLowerCase();
|
|
42715
|
+
return b.toLowerCase();
|
|
42716
|
+
}
|
|
42717
|
+
function sharedPrefix2(a, b) {
|
|
42718
|
+
const x = dirOf(a) === "" ? [] : dirOf(a).split("/");
|
|
42719
|
+
const y = dirOf(b) === "" ? [] : dirOf(b).split("/");
|
|
42720
|
+
let n = 0;
|
|
42721
|
+
while (n < x.length && n < y.length && x[n] === y[n]) n++;
|
|
42722
|
+
return n;
|
|
42723
|
+
}
|
|
42724
|
+
var splitName = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t) => t.toLowerCase());
|
|
42725
|
+
var squash = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
42726
|
+
function mentionsOf(names) {
|
|
42727
|
+
const out = [];
|
|
42728
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42729
|
+
const add = (m) => {
|
|
42730
|
+
const key = `${m.word ?? ""}|${m.squashed ?? ""}`;
|
|
42731
|
+
if (!seen.has(key)) {
|
|
42732
|
+
seen.add(key);
|
|
42733
|
+
out.push(m);
|
|
42734
|
+
}
|
|
42735
|
+
};
|
|
42736
|
+
for (const name of names) {
|
|
42737
|
+
if (name.length < MIN_NAME_CHARS || GENERIC_NAMES.has(name.toLowerCase())) continue;
|
|
42738
|
+
const tokens = splitName(name);
|
|
42739
|
+
if (tokens.length >= 2) {
|
|
42740
|
+
const two = squash(tokens.slice(0, 2).join(""));
|
|
42741
|
+
if (two.length >= 9) add({ squashed: two });
|
|
42742
|
+
const all = squash(name);
|
|
42743
|
+
if (all.length >= 9) add({ squashed: all });
|
|
42744
|
+
} else {
|
|
42745
|
+
add({ word: name });
|
|
42746
|
+
}
|
|
42747
|
+
}
|
|
42748
|
+
return out;
|
|
42749
|
+
}
|
|
42750
|
+
var escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42751
|
+
function textMentions(text2, squashedText, m) {
|
|
42752
|
+
if (m.word !== void 0) return new RegExp(`\\b${escapeRe(m.word)}\\b`).test(text2);
|
|
42753
|
+
return m.squashed !== void 0 && squashedText.includes(m.squashed);
|
|
42754
|
+
}
|
|
42755
|
+
function definedNames(language, text2) {
|
|
42756
|
+
const names = /* @__PURE__ */ new Set();
|
|
42757
|
+
const grab = (re) => {
|
|
42758
|
+
for (const m of text2.matchAll(re)) if (m[1]) names.add(m[1]);
|
|
42759
|
+
};
|
|
42760
|
+
if (language === "python") {
|
|
42761
|
+
grab(/^[ \t]*(?:async[ \t]+)?def[ \t]+([A-Za-z_]\w*)/gm);
|
|
42762
|
+
grab(/^[ \t]*class[ \t]+([A-Za-z_]\w*)/gm);
|
|
42763
|
+
} else if (language === "go") {
|
|
42764
|
+
grab(/^func[ \t]+(?:\([^)]*\)[ \t]*)?([A-Za-z_]\w*)/gm);
|
|
42765
|
+
grab(/^type[ \t]+([A-Za-z_]\w*)/gm);
|
|
42766
|
+
} else if (language === "jvm") {
|
|
42767
|
+
grab(/\b(?:class|interface|object|enum|trait)[ \t]+([A-Za-z_]\w*)/g);
|
|
42768
|
+
} else if (language === "csharp" || language === "php" || language === "swift") {
|
|
42769
|
+
grab(/\b(?:class|interface|struct|enum|trait|protocol)[ \t]+([A-Za-z_]\w*)/g);
|
|
42770
|
+
} else if (language === "ruby") {
|
|
42771
|
+
grab(/^[ \t]*(?:class|module)[ \t]+([A-Za-z_]\w*)/gm);
|
|
42772
|
+
grab(/^[ \t]*def[ \t]+(?:self\.)?([A-Za-z_]\w*[?!]?)/gm);
|
|
42773
|
+
} else if (language === "rust") {
|
|
42774
|
+
grab(/\bfn[ \t]+([A-Za-z_]\w*)/g);
|
|
42775
|
+
grab(/\b(?:struct|enum|trait)[ \t]+([A-Za-z_]\w*)/g);
|
|
42776
|
+
} else if (language === "dart") {
|
|
42777
|
+
grab(/\bclass[ \t]+([A-Za-z_]\w*)/g);
|
|
42778
|
+
}
|
|
42779
|
+
return [...names];
|
|
42780
|
+
}
|
|
42781
|
+
function buildIndex(files, readText) {
|
|
42782
|
+
const pyModules = /* @__PURE__ */ new Map();
|
|
42783
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
42784
|
+
for (const f of files) {
|
|
42785
|
+
const d = dirOf(f);
|
|
42786
|
+
(byDir.get(d) ?? byDir.set(d, []).get(d)).push(f);
|
|
42787
|
+
if (f.endsWith(".py")) {
|
|
42788
|
+
const parts = f.replace(/\.py$/, "").split("/");
|
|
42789
|
+
if (parts[parts.length - 1] === "__init__") parts.pop();
|
|
42790
|
+
for (let i2 = 0; i2 < parts.length; i2++) {
|
|
42791
|
+
const dotted = parts.slice(i2).join(".");
|
|
42792
|
+
if (dotted) (pyModules.get(dotted) ?? pyModules.set(dotted, []).get(dotted)).push(f);
|
|
42793
|
+
}
|
|
42794
|
+
}
|
|
42795
|
+
}
|
|
42796
|
+
let goModule = null;
|
|
42797
|
+
const gomod = files.filter((f) => import_node_path18.posix.basename(f) === "go.mod").sort((a, b) => a.length - b.length)[0];
|
|
42798
|
+
if (gomod) {
|
|
42799
|
+
const m = /^module[ \t]+(\S+)/m.exec(readText(gomod) ?? "");
|
|
42800
|
+
if (m) goModule = { root: dirOf(gomod), module: m[1].replace(/^"|"$/g, "") };
|
|
42801
|
+
}
|
|
42802
|
+
return { files, set: new Set(files), pyModules, byDir, goModule };
|
|
42803
|
+
}
|
|
42804
|
+
function pythonImports(file, text2, ix) {
|
|
42805
|
+
const out = /* @__PURE__ */ new Set();
|
|
42806
|
+
const lookup = (dotted) => {
|
|
42807
|
+
for (const hit of ix.pyModules.get(dotted) ?? []) if (hit !== file) out.add(hit);
|
|
42808
|
+
};
|
|
42809
|
+
const relative10 = (dots, rest) => {
|
|
42810
|
+
let base = dirOf(file);
|
|
42811
|
+
for (let i2 = 1; i2 < dots; i2++) base = dirOf(base);
|
|
42812
|
+
const joined = rest ? import_node_path18.posix.join(base, rest.replace(/\./g, "/")) : base;
|
|
42813
|
+
return [`${joined}.py`, `${joined}/__init__.py`].filter((p) => ix.set.has(p) && p !== file);
|
|
42814
|
+
};
|
|
42815
|
+
for (const line of text2.split("\n")) {
|
|
42816
|
+
const from = /^[ \t]*from[ \t]+(\.*)([\w.]*)[ \t]+import[ \t]+(.+?)\s*$/.exec(line);
|
|
42817
|
+
if (from) {
|
|
42818
|
+
const dots = from[1].length;
|
|
42819
|
+
const mod = from[2];
|
|
42820
|
+
const names = from[3].replace(/[()\\]/g, "").split(",").map((s) => s.trim().split(/\s+as\s+/)[0].trim()).filter((s) => /^\w+$/.test(s));
|
|
42821
|
+
if (dots > 0) {
|
|
42822
|
+
for (const p of relative10(dots, mod)) out.add(p);
|
|
42823
|
+
for (const n of names) for (const p of relative10(dots, mod ? `${mod}.${n}` : n)) out.add(p);
|
|
42824
|
+
} else {
|
|
42825
|
+
lookup(mod);
|
|
42826
|
+
for (const n of names) lookup(`${mod}.${n}`);
|
|
42827
|
+
}
|
|
42828
|
+
continue;
|
|
42829
|
+
}
|
|
42830
|
+
const imp = /^[ \t]*import[ \t]+(.+?)\s*$/.exec(line);
|
|
42831
|
+
if (imp) {
|
|
42832
|
+
for (const part of imp[1].split(",")) {
|
|
42833
|
+
const mod = part.trim().split(/\s+as\s+/)[0].trim();
|
|
42834
|
+
if (/^[\w.]+$/.test(mod)) lookup(mod);
|
|
42835
|
+
}
|
|
42836
|
+
}
|
|
42837
|
+
}
|
|
42838
|
+
return [...out];
|
|
42839
|
+
}
|
|
42840
|
+
function goImports(file, text2, ix) {
|
|
42841
|
+
const out = /* @__PURE__ */ new Set();
|
|
42842
|
+
if (file.endsWith("_test.go")) {
|
|
42843
|
+
for (const f of ix.byDir.get(dirOf(file)) ?? []) if (f.endsWith(".go") && !f.endsWith("_test.go")) out.add(f);
|
|
42844
|
+
}
|
|
42845
|
+
const paths = [];
|
|
42846
|
+
for (const m of text2.matchAll(/^[ \t]*import[ \t]+(?:\w+[ \t]+)?"([^"]+)"/gm)) paths.push(m[1]);
|
|
42847
|
+
for (const block of text2.matchAll(/^import[ \t]*\(([\s\S]*?)\n\)/gm)) for (const m of block[1].matchAll(/"([^"]+)"/g)) paths.push(m[1]);
|
|
42848
|
+
for (const p of paths) {
|
|
42849
|
+
let dir = null;
|
|
42850
|
+
if (ix.goModule && (p === ix.goModule.module || p.startsWith(`${ix.goModule.module}/`))) {
|
|
42851
|
+
const rest = p.slice(ix.goModule.module.length).replace(/^\//, "");
|
|
42852
|
+
dir = ix.goModule.root ? import_node_path18.posix.join(ix.goModule.root, rest) : rest;
|
|
42853
|
+
} else {
|
|
42854
|
+
const tail = p.split("/").slice(-2).join("/");
|
|
42855
|
+
for (const d of ix.byDir.keys()) if (d === tail || d.endsWith(`/${tail}`)) {
|
|
42856
|
+
dir = d;
|
|
42857
|
+
break;
|
|
42858
|
+
}
|
|
42859
|
+
}
|
|
42860
|
+
if (dir === null) continue;
|
|
42861
|
+
for (const f of ix.byDir.get(dir) ?? []) if (f.endsWith(".go") && !f.endsWith("_test.go") && f !== file) out.add(f);
|
|
42862
|
+
}
|
|
42863
|
+
return [...out];
|
|
42864
|
+
}
|
|
42865
|
+
function jvmImports(file, text2, ix) {
|
|
42866
|
+
const out = /* @__PURE__ */ new Set();
|
|
42867
|
+
for (const m of text2.matchAll(/^[ \t]*import[ \t]+(?:static[ \t]+)?([\w.]+?)(\.\*)?[ \t]*;?[ \t]*$/gm)) {
|
|
42868
|
+
const rel = m[1].replace(/\./g, "/");
|
|
42869
|
+
if (m[2]) {
|
|
42870
|
+
for (const [d, fs] of ix.byDir) if (d === rel || d.endsWith(`/${rel}`)) {
|
|
42871
|
+
for (const f of fs) if (languageOf(f) === "jvm" && f !== file) out.add(f);
|
|
42872
|
+
}
|
|
42873
|
+
} else {
|
|
42874
|
+
for (const ext of [".java", ".kt", ".scala"]) {
|
|
42875
|
+
const want = `${rel}${ext}`;
|
|
42876
|
+
for (const f of ix.files) if ((f === want || f.endsWith(`/${want}`)) && f !== file) out.add(f);
|
|
42877
|
+
}
|
|
42878
|
+
const upper = rel.split("/").slice(0, -1).join("/");
|
|
42879
|
+
if (upper) {
|
|
42880
|
+
for (const ext of [".java", ".kt", ".scala"]) for (const f of ix.files) if ((f === `${upper}${ext}` || f.endsWith(`/${upper}${ext}`)) && f !== file) out.add(f);
|
|
42881
|
+
}
|
|
42882
|
+
}
|
|
42883
|
+
}
|
|
42884
|
+
const pkg = /^[ \t]*package[ \t]+([\w.]+)/m.exec(text2);
|
|
42885
|
+
const tail = pkg ? pkg[1].replace(/\./g, "/") : null;
|
|
42886
|
+
const siblings = [];
|
|
42887
|
+
for (const [d, fs] of ix.byDir) if (d === dirOf(file) || tail !== null && (d === tail || d.endsWith(`/${tail}`))) siblings.push(...fs);
|
|
42888
|
+
if (siblings.length <= 400) {
|
|
42889
|
+
for (const f of siblings) {
|
|
42890
|
+
if (f === file || languageOf(f) !== "jvm") continue;
|
|
42891
|
+
const name = baseNoExt(f);
|
|
42892
|
+
if (name.length >= MIN_CLASS_NAME_CHARS && new RegExp(`\\b${escapeRe(name)}\\b`).test(text2)) out.add(f);
|
|
42893
|
+
}
|
|
42894
|
+
}
|
|
42895
|
+
return [...out];
|
|
42896
|
+
}
|
|
42897
|
+
function importsOf(language, file, text2, ix) {
|
|
42898
|
+
if (language === "python") return pythonImports(file, text2, ix);
|
|
42899
|
+
if (language === "go") return goImports(file, text2, ix);
|
|
42900
|
+
if (language === "jvm") return jvmImports(file, text2, ix);
|
|
42901
|
+
return [];
|
|
42902
|
+
}
|
|
42903
|
+
var isPackageInit = (p) => import_node_path18.posix.basename(p) === "__init__.py";
|
|
42904
|
+
function testsReaching(input) {
|
|
42905
|
+
const limit = Math.min(MAX_REACH_TESTS, Math.max(0, input.limit ?? MAX_REACH_TESTS));
|
|
42906
|
+
const listing = input.isDenied ? input.listing.filter((p) => !input.isDenied(p)) : [...input.listing];
|
|
42907
|
+
const maxSteps = Math.min(MAX_IMPORT_STEPS, Math.max(1, input.maxSteps ?? MAX_IMPORT_STEPS));
|
|
42908
|
+
const targets = input.targets.filter((t) => languageOf(t) !== null && !input.isTest(t));
|
|
42909
|
+
if (limit === 0 || targets.length === 0) return [];
|
|
42910
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
42911
|
+
let reads = 0;
|
|
42912
|
+
const text2 = (p) => {
|
|
42913
|
+
if (cache2.has(p)) return cache2.get(p);
|
|
42914
|
+
let t = null;
|
|
42915
|
+
if (reads < MAX_FILES_READ) {
|
|
42916
|
+
reads += 1;
|
|
42917
|
+
try {
|
|
42918
|
+
t = input.readText(p);
|
|
42919
|
+
} catch {
|
|
42920
|
+
t = null;
|
|
42921
|
+
}
|
|
42922
|
+
if (t !== null && (t.length > MAX_FILE_CHARS2 || t.includes("\0"))) t = null;
|
|
42923
|
+
}
|
|
42924
|
+
cache2.set(p, t);
|
|
42925
|
+
return t;
|
|
42926
|
+
};
|
|
42927
|
+
const ix = buildIndex(listing, (p) => input.readText(p));
|
|
42928
|
+
const hits = /* @__PURE__ */ new Map();
|
|
42929
|
+
const keep = (path, tier, steps, target) => {
|
|
42930
|
+
const size = text2(path)?.length ?? 0;
|
|
42931
|
+
const near = sharedPrefix2(path, target);
|
|
42932
|
+
const old = hits.get(path);
|
|
42933
|
+
if (old && (old.tier < tier || old.tier === tier && old.steps <= steps)) return;
|
|
42934
|
+
hits.set(path, { path, tier, steps, target, near, size });
|
|
42935
|
+
};
|
|
42936
|
+
const reverse = /* @__PURE__ */ new Map();
|
|
42937
|
+
const reverseOf = (language) => {
|
|
42938
|
+
const done = reverse.get(language);
|
|
42939
|
+
if (done) return done;
|
|
42940
|
+
const map = /* @__PURE__ */ new Map();
|
|
42941
|
+
for (const f of listing) {
|
|
42942
|
+
if (languageOf(f) !== language) continue;
|
|
42943
|
+
const t = text2(f);
|
|
42944
|
+
if (t === null) continue;
|
|
42945
|
+
for (const to of importsOf(language, f, t, ix)) (map.get(to) ?? map.set(to, []).get(to)).push(f);
|
|
42946
|
+
}
|
|
42947
|
+
reverse.set(language, map);
|
|
42948
|
+
return map;
|
|
42949
|
+
};
|
|
42950
|
+
for (const target of targets) {
|
|
42951
|
+
const language = languageOf(target);
|
|
42952
|
+
if (language === null) continue;
|
|
42953
|
+
const sameLanguageTests = listing.filter((p) => input.isTest(p) && languageOf(p) === language);
|
|
42954
|
+
if (sameLanguageTests.length === 0) continue;
|
|
42955
|
+
const targetText = text2(target);
|
|
42956
|
+
const look = [...input.lookSymbols?.entries() ?? []].find(([p]) => p === target || target.endsWith(`/${p}`) || p.endsWith(`/${target}`))?.[1] ?? [];
|
|
42957
|
+
const names = [.../* @__PURE__ */ new Set([...look, ...targetText ? definedNames(language, targetText) : []])];
|
|
42958
|
+
const mentions = mentionsOf(names);
|
|
42959
|
+
const mentionIn = /* @__PURE__ */ new Map();
|
|
42960
|
+
const mentioned = (testPath) => {
|
|
42961
|
+
const cached = mentionIn.get(testPath);
|
|
42962
|
+
if (cached !== void 0) return cached;
|
|
42963
|
+
const t = text2(testPath);
|
|
42964
|
+
let yes = false;
|
|
42965
|
+
if (t !== null && mentions.length > 0) {
|
|
42966
|
+
const sq = squash(t);
|
|
42967
|
+
yes = mentions.some((m) => textMentions(t, sq, m));
|
|
42968
|
+
}
|
|
42969
|
+
mentionIn.set(testPath, yes);
|
|
42970
|
+
return yes;
|
|
42971
|
+
};
|
|
42972
|
+
const mentioners = sameLanguageTests.filter(mentioned);
|
|
42973
|
+
const useMentions = mentioners.length > 0 && mentioners.length <= COMMON_MENTION_LIMIT;
|
|
42974
|
+
const mention = (p) => useMentions && mentionIn.get(p) === true;
|
|
42975
|
+
const stem = codeStem(target);
|
|
42976
|
+
for (const t of sameLanguageTests) if (testStem(t) === stem && stem.length >= 2) keep(t, 0, 0, target);
|
|
42977
|
+
if (language === "go") {
|
|
42978
|
+
for (const t of ix.byDir.get(dirOf(target)) ?? []) {
|
|
42979
|
+
if (!t.endsWith("_test.go") || !input.isTest(t)) continue;
|
|
42980
|
+
keep(t, mention(t) ? 1 : 2, 0, target);
|
|
42981
|
+
}
|
|
42982
|
+
}
|
|
42983
|
+
if (language === "python" || language === "go" || language === "jvm") {
|
|
42984
|
+
const rev = reverseOf(language);
|
|
42985
|
+
const seen = /* @__PURE__ */ new Map([[target, 0]]);
|
|
42986
|
+
let frontier = [target];
|
|
42987
|
+
for (let round = 0; round < MAX_WALK_ROUNDS && frontier.length > 0 && seen.size <= MAX_WALK_FILES; round++) {
|
|
42988
|
+
const next = [];
|
|
42989
|
+
for (const node of frontier) {
|
|
42990
|
+
const importers = rev.get(node) ?? [];
|
|
42991
|
+
if (node !== target && !isPackageInit(node) && importers.length > HUB_LIMIT) continue;
|
|
42992
|
+
for (const imp of importers) {
|
|
42993
|
+
const cost = isPackageInit(imp) ? 0 : 1;
|
|
42994
|
+
const at2 = (seen.get(node) ?? 0) + cost;
|
|
42995
|
+
if (at2 > maxSteps) continue;
|
|
42996
|
+
if (seen.has(imp) && seen.get(imp) <= at2) continue;
|
|
42997
|
+
seen.set(imp, at2);
|
|
42998
|
+
next.push(imp);
|
|
42999
|
+
if (input.isTest(imp) && languageOf(imp) === language) keep(imp, mention(imp) ? 1 : 2, Math.max(1, at2), target);
|
|
43000
|
+
}
|
|
43001
|
+
}
|
|
43002
|
+
frontier = next;
|
|
43003
|
+
}
|
|
43004
|
+
}
|
|
43005
|
+
if (useMentions) {
|
|
43006
|
+
for (const t of mentioners) if (!hits.has(t)) keep(t, 3, 0, target);
|
|
43007
|
+
}
|
|
43008
|
+
}
|
|
43009
|
+
return [...hits.values()].sort(
|
|
43010
|
+
(a, b) => a.tier - b.tier || a.steps - b.steps || b.near - a.near || a.size - b.size || (a.path < b.path ? -1 : a.path > b.path ? 1 : 0)
|
|
43011
|
+
).slice(0, limit).map(({ path, tier, steps, target }) => ({ path, tier, steps, target }));
|
|
43012
|
+
}
|
|
43013
|
+
function testsNamedAfter(target, listing, isTest) {
|
|
43014
|
+
const language = languageOf(target);
|
|
43015
|
+
if (language === null || isTest(target)) return [];
|
|
43016
|
+
const stem = codeStem(target);
|
|
43017
|
+
if (stem.length < 2) return [];
|
|
43018
|
+
const out = [];
|
|
43019
|
+
for (const t of listing) {
|
|
43020
|
+
if (!isTest(t) || languageOf(t) !== language) continue;
|
|
43021
|
+
if (testStem(t) === stem) out.push(t);
|
|
43022
|
+
else if (language === "go" && dirOf(t) === dirOf(target) && t.endsWith("_test.go") && testStem(t) === stem) out.push(t);
|
|
43023
|
+
}
|
|
43024
|
+
return out.sort();
|
|
43025
|
+
}
|
|
43026
|
+
|
|
43027
|
+
// src/codegenLoopContext.ts
|
|
42634
43028
|
var CODE_NAME_RE = /^(.+)\.[cm]?[jt]sx?$/i;
|
|
42635
|
-
function
|
|
43029
|
+
function dirOf2(path) {
|
|
42636
43030
|
const i2 = path.lastIndexOf("/");
|
|
42637
43031
|
return i2 === -1 ? "" : path.slice(0, i2);
|
|
42638
43032
|
}
|
|
@@ -42640,20 +43034,20 @@ function baseOf(path) {
|
|
|
42640
43034
|
return path.slice(path.lastIndexOf("/") + 1);
|
|
42641
43035
|
}
|
|
42642
43036
|
function parentOf(dir) {
|
|
42643
|
-
return dir === "" ? "" :
|
|
43037
|
+
return dir === "" ? "" : dirOf2(dir);
|
|
42644
43038
|
}
|
|
42645
43039
|
function pairedTestPaths(codePath, listing, isTest = isTestTarget) {
|
|
42646
43040
|
if (isTest(codePath)) return [];
|
|
42647
43041
|
const m = CODE_NAME_RE.exec(baseOf(codePath));
|
|
42648
43042
|
if (!m) return [];
|
|
42649
43043
|
const stem = m[1].toLowerCase();
|
|
42650
|
-
const dir =
|
|
43044
|
+
const dir = dirOf2(codePath);
|
|
42651
43045
|
const parent = parentOf(dir);
|
|
42652
43046
|
const join15 = (d, leaf) => d === "" ? leaf : `${d}/${leaf}`;
|
|
42653
43047
|
const homes = /* @__PURE__ */ new Set([dir, join15(dir, "__tests__"), join15(parent, "__tests__"), join15(parent, "tests"), join15(parent, "test")]);
|
|
42654
43048
|
const found = [];
|
|
42655
43049
|
for (const path of listing) {
|
|
42656
|
-
if (!homes.has(
|
|
43050
|
+
if (!homes.has(dirOf2(path))) continue;
|
|
42657
43051
|
const t = TEST_NAME_RE.exec(baseOf(path));
|
|
42658
43052
|
if (t && t[1].toLowerCase() === stem) found.push(path);
|
|
42659
43053
|
}
|
|
@@ -42714,7 +43108,11 @@ function collectLoopContext(p) {
|
|
|
42714
43108
|
total += content.length;
|
|
42715
43109
|
}
|
|
42716
43110
|
}
|
|
42717
|
-
const
|
|
43111
|
+
const pairedByName = (path) => {
|
|
43112
|
+
const paired = pairedTestPaths(path, listing, isTest);
|
|
43113
|
+
return paired.length > 0 ? paired : testsNamedAfter(path, [...listing], isTest);
|
|
43114
|
+
};
|
|
43115
|
+
const folderTests = target.kind !== "EXISTING" ? [] : isTest(target.path) ? [target.path] : pairedByName(target.path);
|
|
42718
43116
|
const reverseTests = target.kind === "EXISTING" ? testsImporting({
|
|
42719
43117
|
target: target.path,
|
|
42720
43118
|
listing,
|
|
@@ -42878,7 +43276,7 @@ async function verifyOnOldCode(conflicts, run2, log = () => void 0) {
|
|
|
42878
43276
|
|
|
42879
43277
|
// src/testsToCheck.ts
|
|
42880
43278
|
var import_node_fs16 = require("node:fs");
|
|
42881
|
-
var
|
|
43279
|
+
var import_node_path19 = require("node:path");
|
|
42882
43280
|
var MAX_TESTS_TO_CHECK = 10;
|
|
42883
43281
|
var SECOND_HOP_BELOW = 3;
|
|
42884
43282
|
function testsToCheck(i2) {
|
|
@@ -42912,11 +43310,24 @@ function testsToCheck(i2) {
|
|
|
42912
43310
|
add(path);
|
|
42913
43311
|
}
|
|
42914
43312
|
}
|
|
43313
|
+
const other = code.map((t) => t.path).filter((path) => languageOf(path) !== null);
|
|
43314
|
+
if (other.length > 0 && out.length < limit) {
|
|
43315
|
+
const reached = testsReaching({
|
|
43316
|
+
targets: other,
|
|
43317
|
+
listing: [...world.listing],
|
|
43318
|
+
readText: i2.readRel,
|
|
43319
|
+
isTest: world.isTest,
|
|
43320
|
+
isDenied: (path) => matchesDeniedPath(path, i2.deniedPaths) !== null,
|
|
43321
|
+
limit,
|
|
43322
|
+
...i2.lookSymbols ? { lookSymbols: i2.lookSymbols } : {}
|
|
43323
|
+
});
|
|
43324
|
+
for (const hit of reached) add(hit.path);
|
|
43325
|
+
}
|
|
42915
43326
|
return out;
|
|
42916
43327
|
}
|
|
42917
43328
|
var readFromRoot = (root) => (rel) => {
|
|
42918
43329
|
try {
|
|
42919
|
-
return (0, import_node_fs16.readFileSync)((0,
|
|
43330
|
+
return (0, import_node_fs16.readFileSync)((0, import_node_path19.join)(root, rel), "utf8");
|
|
42920
43331
|
} catch {
|
|
42921
43332
|
return null;
|
|
42922
43333
|
}
|
|
@@ -42995,7 +43406,7 @@ function testsToCheckOf(p) {
|
|
|
42995
43406
|
return null;
|
|
42996
43407
|
}
|
|
42997
43408
|
} : readFromRoot(tests.root);
|
|
42998
|
-
return testsToCheck({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, writeRoot: p.writeRoot ?? "", discoveredTests: discoveredTestsOf(p.testDiscovery) ?? null, readRel: read });
|
|
43409
|
+
return testsToCheck({ targets: p.targets, listing: p.workspaceListing, deniedPaths: p.deniedPaths, writeRoot: p.writeRoot ?? "", discoveredTests: discoveredTestsOf(p.testDiscovery) ?? null, readRel: read, ...p.lookSymbols ? { lookSymbols: p.lookSymbols } : {} });
|
|
42999
43410
|
} catch {
|
|
43000
43411
|
return [];
|
|
43001
43412
|
}
|
|
@@ -43673,7 +44084,7 @@ async function runVerifyAndFix(p) {
|
|
|
43673
44084
|
// src/hunkCheck.ts
|
|
43674
44085
|
var import_node_child_process9 = require("node:child_process");
|
|
43675
44086
|
var import_node_fs19 = require("node:fs");
|
|
43676
|
-
var
|
|
44087
|
+
var import_node_path20 = require("node:path");
|
|
43677
44088
|
|
|
43678
44089
|
// src/scopeCheck.ts
|
|
43679
44090
|
var import_node_fs18 = require("node:fs");
|
|
@@ -43819,7 +44230,7 @@ async function runHunkCheck(input) {
|
|
|
43819
44230
|
let slowestRunMs = input.baselineMs ?? 3e4;
|
|
43820
44231
|
const runOnce = async (c) => {
|
|
43821
44232
|
const reportBefore = findReport(input.root);
|
|
43822
|
-
const preserve = reportBefore ? [(0,
|
|
44233
|
+
const preserve = reportBefore ? [(0, import_node_path20.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
43823
44234
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
43824
44235
|
const startedWall = Date.now();
|
|
43825
44236
|
const startedAt = now();
|
|
@@ -43855,7 +44266,7 @@ async function runHunkCheck(input) {
|
|
|
43855
44266
|
};
|
|
43856
44267
|
const runRelated = async (c, plan, limitMs) => {
|
|
43857
44268
|
const reportBefore = findReport(input.root);
|
|
43858
|
-
const preserve = reportBefore ? [(0,
|
|
44269
|
+
const preserve = reportBefore ? [(0, import_node_path20.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
43859
44270
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
43860
44271
|
const startedAt = now();
|
|
43861
44272
|
result.relatedRuns += 1;
|
|
@@ -44000,7 +44411,7 @@ function healFailureSuffix(heal) {
|
|
|
44000
44411
|
|
|
44001
44412
|
// src/dependencyCheck.ts
|
|
44002
44413
|
var import_node_fs20 = require("node:fs");
|
|
44003
|
-
var
|
|
44414
|
+
var import_node_path21 = require("node:path");
|
|
44004
44415
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
44005
44416
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
44006
44417
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -44088,8 +44499,8 @@ function dependencyNames(pkg) {
|
|
|
44088
44499
|
]);
|
|
44089
44500
|
}
|
|
44090
44501
|
function readDeclaredDependencies(results, workspaceRoot) {
|
|
44091
|
-
const packageJsonPath = (0,
|
|
44092
|
-
const generated = results.find((r) => (0,
|
|
44502
|
+
const packageJsonPath = (0, import_node_path21.join)((0, import_node_path21.resolve)(workspaceRoot ?? "."), "package.json");
|
|
44503
|
+
const generated = results.find((r) => (0, import_node_path21.resolve)(r.targetPath) === packageJsonPath);
|
|
44093
44504
|
let raw;
|
|
44094
44505
|
if (generated) {
|
|
44095
44506
|
raw = generated.newContent;
|
|
@@ -44159,10 +44570,10 @@ function stripJsonComments(text2) {
|
|
|
44159
44570
|
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
44160
44571
|
}
|
|
44161
44572
|
function resolveAliasPrefixes(results, workspaceRoot) {
|
|
44162
|
-
const root = (0,
|
|
44573
|
+
const root = (0, import_node_path21.resolve)(workspaceRoot ?? ".");
|
|
44163
44574
|
for (const filename of ["tsconfig.json", "jsconfig.json"]) {
|
|
44164
|
-
const configPath = (0,
|
|
44165
|
-
const generated = results.find((r) => (0,
|
|
44575
|
+
const configPath = (0, import_node_path21.join)(root, filename);
|
|
44576
|
+
const generated = results.find((r) => (0, import_node_path21.resolve)(r.targetPath) === configPath);
|
|
44166
44577
|
let raw;
|
|
44167
44578
|
if (generated) {
|
|
44168
44579
|
raw = generated.newContent;
|
|
@@ -44523,7 +44934,7 @@ function describeVanishedTests(vanished) {
|
|
|
44523
44934
|
}
|
|
44524
44935
|
|
|
44525
44936
|
// src/verifyChange.ts
|
|
44526
|
-
var
|
|
44937
|
+
var import_node_path22 = require("node:path");
|
|
44527
44938
|
|
|
44528
44939
|
// src/packageUse.ts
|
|
44529
44940
|
var import_node_child_process10 = require("node:child_process");
|
|
@@ -44585,7 +44996,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
44585
44996
|
const depCheck = checkImportDependencies(results, readDeclaredDependencies(results, packet.workspaceRoot), resolveAliasPrefixes(results, packet.workspaceRoot), {
|
|
44586
44997
|
originalOf: (path) => {
|
|
44587
44998
|
try {
|
|
44588
|
-
return (0, import_node_fs22.readFileSync)((0,
|
|
44999
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path22.join)(cwd, path), "utf8");
|
|
44589
45000
|
} catch (err) {
|
|
44590
45001
|
return err.code === "ENOENT" ? "" : null;
|
|
44591
45002
|
}
|
|
@@ -44635,7 +45046,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
44635
45046
|
flushedAt = now();
|
|
44636
45047
|
if (undoable) {
|
|
44637
45048
|
const report = findJUnitReport(cwd);
|
|
44638
|
-
const ignore = report ? [(0,
|
|
45049
|
+
const ignore = report ? [(0, import_node_path22.relative)(cwd, report).split("\\").join("/")] : [];
|
|
44639
45050
|
const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
|
|
44640
45051
|
undo = () => flush.undo();
|
|
44641
45052
|
} else {
|
|
@@ -44795,7 +45206,7 @@ function buildToolsV2Env(i2) {
|
|
|
44795
45206
|
}
|
|
44796
45207
|
|
|
44797
45208
|
// src/repoMap.ts
|
|
44798
|
-
var
|
|
45209
|
+
var import_node_path23 = require("node:path");
|
|
44799
45210
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
44800
45211
|
var MAX_FOLDERS = 200;
|
|
44801
45212
|
var MAX_LANGUAGES = 12;
|
|
@@ -44837,7 +45248,7 @@ function guidanceFiles(i2, perFile2, total) {
|
|
|
44837
45248
|
function languages(listing) {
|
|
44838
45249
|
const counts = /* @__PURE__ */ new Map();
|
|
44839
45250
|
for (const p of listing) {
|
|
44840
|
-
const ext =
|
|
45251
|
+
const ext = import_node_path23.posix.extname(p).toLowerCase();
|
|
44841
45252
|
if (ext && ext.length <= 12) counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
44842
45253
|
}
|
|
44843
45254
|
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}`);
|
|
@@ -44853,7 +45264,7 @@ function testFacts(i2) {
|
|
|
44853
45264
|
const depth = i2.writeRoot === "" ? 0 : i2.writeRoot.split("/").length;
|
|
44854
45265
|
for (const t of tests) {
|
|
44855
45266
|
const parts = t.split("/");
|
|
44856
|
-
const folder = parts.length > depth + 1 ? parts.slice(0, depth + 1).join("/") :
|
|
45267
|
+
const folder = parts.length > depth + 1 ? parts.slice(0, depth + 1).join("/") : import_node_path23.posix.dirname(t);
|
|
44857
45268
|
byFolder.set(folder, (byFolder.get(folder) ?? 0) + 1);
|
|
44858
45269
|
}
|
|
44859
45270
|
for (const [folder, n] of [...byFolder.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 3)) {
|
|
@@ -44963,7 +45374,7 @@ function buildRepoMap(i2) {
|
|
|
44963
45374
|
}
|
|
44964
45375
|
|
|
44965
45376
|
// src/workspacePackages.ts
|
|
44966
|
-
var
|
|
45377
|
+
var import_node_path24 = require("node:path");
|
|
44967
45378
|
var MAX_READ_ROOTS = 8;
|
|
44968
45379
|
function isObject2(x) {
|
|
44969
45380
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -45025,8 +45436,8 @@ function workspacePackages(readText, packageJsonPaths) {
|
|
|
45025
45436
|
const exclude = patterns.filter((p) => p.startsWith("!")).map((p) => globMatcher(p.slice(1)));
|
|
45026
45437
|
const out = [];
|
|
45027
45438
|
for (const file of packageJsonPaths) {
|
|
45028
|
-
if (
|
|
45029
|
-
const folder =
|
|
45439
|
+
if (import_node_path24.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
|
|
45440
|
+
const folder = import_node_path24.posix.dirname(file);
|
|
45030
45441
|
if (!include.some((re) => re.test(folder)) || exclude.some((re) => re.test(folder))) continue;
|
|
45031
45442
|
const text2 = readText(file);
|
|
45032
45443
|
const json = text2 === null ? null : parseJsonc(text2);
|
|
@@ -45305,23 +45716,23 @@ function writePhase0Marker(runId) {
|
|
|
45305
45716
|
|
|
45306
45717
|
// src/failureArtifact.ts
|
|
45307
45718
|
var import_node_fs24 = require("node:fs");
|
|
45308
|
-
var
|
|
45719
|
+
var import_node_path25 = require("node:path");
|
|
45309
45720
|
var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
45310
45721
|
var REPORT_COPY = "final-test-report.xml";
|
|
45311
45722
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
45312
45723
|
var MAX_FILES = 200;
|
|
45313
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
45724
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.51" : "dev";
|
|
45314
45725
|
function safeDestination(base, repoPath) {
|
|
45315
|
-
if (!repoPath || (0,
|
|
45316
|
-
const destination = (0,
|
|
45317
|
-
const rel = (0,
|
|
45318
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
45726
|
+
if (!repoPath || (0, import_node_path25.isAbsolute)(repoPath)) return null;
|
|
45727
|
+
const destination = (0, import_node_path25.resolve)(base, repoPath);
|
|
45728
|
+
const rel = (0, import_node_path25.relative)(base, destination);
|
|
45729
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path25.isAbsolute)(rel)) return null;
|
|
45319
45730
|
return destination;
|
|
45320
45731
|
}
|
|
45321
45732
|
function writeFailureArtifact(input) {
|
|
45322
45733
|
if (input.results.length === 0) return { written: false };
|
|
45323
45734
|
try {
|
|
45324
|
-
const base = (0,
|
|
45735
|
+
const base = (0, import_node_path25.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
45325
45736
|
(0, import_node_fs24.rmSync)(base, { recursive: true, force: true });
|
|
45326
45737
|
(0, import_node_fs24.mkdirSync)(base, { recursive: true });
|
|
45327
45738
|
const files = [];
|
|
@@ -45332,7 +45743,7 @@ function writeFailureArtifact(input) {
|
|
|
45332
45743
|
skipped.push(result.targetPath);
|
|
45333
45744
|
continue;
|
|
45334
45745
|
}
|
|
45335
|
-
(0, import_node_fs24.mkdirSync)((0,
|
|
45746
|
+
(0, import_node_fs24.mkdirSync)((0, import_node_path25.dirname)(destination), { recursive: true });
|
|
45336
45747
|
(0, import_node_fs24.writeFileSync)(destination, result.newContent);
|
|
45337
45748
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
45338
45749
|
}
|
|
@@ -45341,7 +45752,7 @@ function writeFailureArtifact(input) {
|
|
|
45341
45752
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
45342
45753
|
testReport = "too-large";
|
|
45343
45754
|
} else {
|
|
45344
|
-
(0, import_node_fs24.writeFileSync)((0,
|
|
45755
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path25.join)(base, REPORT_COPY), input.testReport);
|
|
45345
45756
|
testReport = "included";
|
|
45346
45757
|
}
|
|
45347
45758
|
}
|
|
@@ -45361,8 +45772,8 @@ function writeFailureArtifact(input) {
|
|
|
45361
45772
|
failureReasons: input.failureReasons
|
|
45362
45773
|
};
|
|
45363
45774
|
const text2 = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
|
|
45364
|
-
(0, import_node_fs24.writeFileSync)((0,
|
|
45365
|
-
return { written: (0, import_node_fs24.existsSync)((0,
|
|
45775
|
+
(0, import_node_fs24.writeFileSync)((0, import_node_path25.join)(base, "manifest.json"), text2);
|
|
45776
|
+
return { written: (0, import_node_fs24.existsSync)((0, import_node_path25.join)(base, "manifest.json")) };
|
|
45366
45777
|
} catch (err) {
|
|
45367
45778
|
console.warn(`::warning::Could not keep the failed run's files: ${err instanceof Error ? err.message : String(err)}`);
|
|
45368
45779
|
return { written: false };
|
|
@@ -45438,15 +45849,26 @@ function twoPhaseSkipReason(reason, snapshot) {
|
|
|
45438
45849
|
if (reason === "no_report" && (snapshot === null || snapshot === void 0 || snapshot.results === null)) return "no_report";
|
|
45439
45850
|
return null;
|
|
45440
45851
|
}
|
|
45852
|
+
function listForCodegen(live, stored) {
|
|
45853
|
+
if (live.report !== "PRESENT" || live.discoveredTestFiles.length === 0) return stored;
|
|
45854
|
+
if (stored.report !== "PRESENT") return live;
|
|
45855
|
+
const files = [.../* @__PURE__ */ new Set([...live.discoveredTestFiles, ...stored.discoveredTestFiles])].sort();
|
|
45856
|
+
return { report: "PRESENT", discoveredTestFiles: files, unmappedEntries: live.unmappedEntries };
|
|
45857
|
+
}
|
|
45441
45858
|
var TWO_PHASE_SKIPPED_NOTE = "Tests-first was skipped: this project's test command writes no per-test report, so QuikPilot could not tell which tests fail on the code as it was.";
|
|
45442
45859
|
var TIMEOUT_WARNING = "QuikPilot could not list the project's test files in time, so it skipped the early check of where tests are placed.";
|
|
45860
|
+
function lateReportWarning(waitedSeconds, namedTestFiles) {
|
|
45861
|
+
return `The project's test report was not ready after ${waitedSeconds} seconds, so QuikPilot listed the test files by their names (${namedTestFiles} found) and skipped the early check of where tests are placed.`;
|
|
45862
|
+
}
|
|
45443
45863
|
async function resolveTestDiscovery(i2) {
|
|
45444
45864
|
const now = i2.now ?? Date.now;
|
|
45445
45865
|
const started = now();
|
|
45446
45866
|
const base = { command: i2.command, listing: i2.listing, workspaceRoot: i2.workspaceRoot, cwd: i2.cwd };
|
|
45447
45867
|
const done = (result, warning) => {
|
|
45448
45868
|
const waitedMs = now() - started;
|
|
45449
|
-
|
|
45869
|
+
const named = i2.namedTestFiles ?? 0;
|
|
45870
|
+
const method = result.source === "live" ? "report" : named > 0 ? "names" : "none";
|
|
45871
|
+
i2.log?.({ event: "test_discovery", source: result.source, reason: result.reason, files: result.files, unmapped: result.unmapped, waitedMs, method, named });
|
|
45450
45872
|
return { result, waitedMs, ...warning ? { warning } : {} };
|
|
45451
45873
|
};
|
|
45452
45874
|
if (!i2.command || i2.command.trim().length === 0) return done(buildTestDiscovery({ ...base, snapshot: null }));
|
|
@@ -45460,7 +45882,10 @@ async function resolveTestDiscovery(i2) {
|
|
|
45460
45882
|
);
|
|
45461
45883
|
try {
|
|
45462
45884
|
const first = await Promise.race([settled, timeout]);
|
|
45463
|
-
if (first === "timeout")
|
|
45885
|
+
if (first === "timeout") {
|
|
45886
|
+
const named = i2.namedTestFiles ?? 0;
|
|
45887
|
+
return done(absent("timeout"), named > 0 ? lateReportWarning(Math.round(i2.waitMs / 1e3), named) : TIMEOUT_WARNING);
|
|
45888
|
+
}
|
|
45464
45889
|
return done(buildTestDiscovery({ ...base, snapshot: first }));
|
|
45465
45890
|
} finally {
|
|
45466
45891
|
if (timer !== void 0) clearTimeout(timer);
|
|
@@ -46009,10 +46434,13 @@ async function run(env2) {
|
|
|
46009
46434
|
workspaceRoot: packet.workspaceRoot,
|
|
46010
46435
|
cwd: process.cwd(),
|
|
46011
46436
|
waitMs: discoveryWaitMs(),
|
|
46437
|
+
// QUIKTR-1854 - how many files look like tests by their names, so a late report is described as what it was.
|
|
46438
|
+
namedTestFiles: workspaceListing.filter(testRule(null)).length,
|
|
46012
46439
|
log: (e) => console.log(JSON.stringify(e))
|
|
46013
46440
|
});
|
|
46014
46441
|
const settledBaseline = discovery.result.reason === "timeout" || discovery.result.reason === "no_command" ? void 0 : await baselineRun.then((b) => b.snapshot, () => null);
|
|
46015
46442
|
const twoPhaseSkip = twoPhaseSkipReason(discovery.result.reason, settledBaseline);
|
|
46443
|
+
const codegenDiscovery = listForCodegen(discovery.result.value, packet.testDiscovery);
|
|
46016
46444
|
if (discovery.warning) {
|
|
46017
46445
|
warnings.push(discovery.warning);
|
|
46018
46446
|
console.warn(`QuikPilot targeting warning (not blocking): ${discovery.warning}`);
|
|
@@ -46086,7 +46514,7 @@ async function run(env2) {
|
|
|
46086
46514
|
const codegenMode = mapMode ? "loop-tests" : resolveCodegenMode(process.env, packet.codegenMode);
|
|
46087
46515
|
const keepOnGiveUp = codegenMode === "loop-tests" && packet.guardrails.maxHealIterations > 0 && process.env.QUIKPILOT_KEEP_ON_GIVE_UP?.trim().toLowerCase() !== "off";
|
|
46088
46516
|
const callFunctionAllowed = callFunctionEnabled(env2.githubRepository, codegenMode);
|
|
46089
|
-
const callFunctionFits = callFunctionFitsTargets(targeting.targets, discoveredTestsOf(
|
|
46517
|
+
const callFunctionFits = callFunctionFitsTargets(targeting.targets, discoveredTestsOf(codegenDiscovery));
|
|
46090
46518
|
if (callFunctionAllowed && !callFunctionFits) console.log(JSON.stringify({ event: "call_function.off", reason: "not_js" }));
|
|
46091
46519
|
const callFunction = callFunctionAllowed && callFunctionFits ? { root: process.cwd(), secrets: [runToken, packet.gateway.token].filter((s) => typeof s === "string" && s.length > 0) } : void 0;
|
|
46092
46520
|
const twoPhaseWanted = codegenMode === "loop-tests" && process.env.QUIKPILOT_TWO_PHASE?.trim().toLowerCase() !== "off";
|
|
@@ -46131,7 +46559,7 @@ async function run(env2) {
|
|
|
46131
46559
|
listing: workspaceListing,
|
|
46132
46560
|
deniedPaths: packet.guardrails.deniedPaths,
|
|
46133
46561
|
writeRoot,
|
|
46134
|
-
discoveredTests: discoveredTestsOf(
|
|
46562
|
+
discoveredTests: discoveredTestsOf(codegenDiscovery),
|
|
46135
46563
|
log: (e) => console.log(JSON.stringify(e))
|
|
46136
46564
|
})
|
|
46137
46565
|
},
|
|
@@ -46142,13 +46570,15 @@ async function run(env2) {
|
|
|
46142
46570
|
scope,
|
|
46143
46571
|
...codegenTools2 ? { tools2: codegenTools2 } : {},
|
|
46144
46572
|
...writeRoot ? { writeRoot } : {},
|
|
46573
|
+
// QUIKTR-1854 - what the early look named, so the tests of code in another language can be found by what they talk about.
|
|
46574
|
+
...packet.findings ? { lookSymbols: lookSymbolsOf(packet.findings) } : {},
|
|
46145
46575
|
requiredTests: packet.requiredTests,
|
|
46146
46576
|
deniedPaths: packet.guardrails.deniedPaths,
|
|
46147
46577
|
judgedByPool,
|
|
46148
46578
|
warnings,
|
|
46149
46579
|
contextLog,
|
|
46150
46580
|
outOfScope,
|
|
46151
|
-
testDiscovery:
|
|
46581
|
+
testDiscovery: codegenDiscovery,
|
|
46152
46582
|
skippedCases: targeting.skippedCases ?? [],
|
|
46153
46583
|
out: codegenOut
|
|
46154
46584
|
};
|
|
@@ -46194,7 +46624,7 @@ async function run(env2) {
|
|
|
46194
46624
|
listing: workspaceListing,
|
|
46195
46625
|
deniedPaths: packet.guardrails.deniedPaths,
|
|
46196
46626
|
writeRoot,
|
|
46197
|
-
discoveredTests: discoveredTestsOf(
|
|
46627
|
+
discoveredTests: discoveredTestsOf(codegenDiscovery),
|
|
46198
46628
|
log: (e) => console.log(JSON.stringify(e))
|
|
46199
46629
|
});
|
|
46200
46630
|
const hunkCheckOver = async (changed, testCount) => {
|