@diffci.com/diffci 0.3.54 → 0.3.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/src/client/agent-selection.d.ts +9 -2
- package/dist-client/src/client/agent-selection.js +20 -8
- package/dist-client/src/client/agent-setup.js +1 -1
- package/dist-client/src/client/cli.js +15 -4
- package/dist-client/src/client/command-batches.js +3 -2
- package/dist-client/src/client/context.js +32 -2
- package/dist-client/src/client/coverage-map.js +6 -1
- package/dist-client/src/client/full-command.js +19 -14
- package/dist-client/src/client/hook.d.ts +17 -0
- package/dist-client/src/client/hook.js +53 -1
- package/dist-client/src/client/install.d.ts +6 -0
- package/dist-client/src/client/install.js +29 -1
- package/dist-client/src/client/mcp.js +4 -0
- package/dist-client/src/client/observe.js +3 -2
- package/dist-client/src/client/report.d.ts +1 -1
- package/dist-client/src/client/shared-graph-cache.js +4 -2
- package/dist-client/src/client/telemetry.js +2 -1
- package/dist-client/src/client/usage-signal.d.ts +1 -1
- package/dist-client/src/client/verify-savings.d.ts +6 -0
- package/dist-client/src/client/verify-savings.js +15 -3
- package/dist-client/src/client/verify.js +124 -22
- package/node_modules/@diffci.com/core/README.md +17 -10
- package/node_modules/@diffci.com/core/dist/ci-inference/expression.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/ci-inference/expression.js +38 -5
- package/node_modules/@diffci.com/core/dist/ci-inference/expression.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/infer.js +26 -6
- package/node_modules/@diffci.com/core/dist/ci-inference/infer.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/jobs.d.ts +2 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/jobs.js +7 -2
- package/node_modules/@diffci.com/core/dist/ci-inference/jobs.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/matrix.js +15 -8
- package/node_modules/@diffci.com/core/dist/ci-inference/matrix.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/purpose.js +6 -2
- package/node_modules/@diffci.com/core/dist/ci-inference/purpose.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/resolve.js +19 -4
- package/node_modules/@diffci.com/core/dist/ci-inference/resolve.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/ci-config-paths.js +13 -1
- package/node_modules/@diffci.com/core/dist/git/ci-config-paths.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +22 -20
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/check-narrowing.js +22 -1
- package/node_modules/@diffci.com/core/dist/planner/check-narrowing.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/pipeline-steps.d.ts +6 -0
- package/node_modules/@diffci.com/core/dist/planner/pipeline-steps.js +14 -2
- package/node_modules/@diffci.com/core/dist/planner/pipeline-steps.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/planner.js +65 -14
- package/node_modules/@diffci.com/core/dist/planner/planner.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/rust-command.js +43 -1
- package/node_modules/@diffci.com/core/dist/planner/rust-command.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/script-reads.js +5 -2
- package/node_modules/@diffci.com/core/dist/planner/script-reads.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/test-command.js +17 -2
- package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/type-program.js +27 -1
- package/node_modules/@diffci.com/core/dist/planner/type-program.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/go.js +5 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/go.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +21 -2
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.d.ts +9 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.js +158 -14
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.d.ts +1 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js +180 -15
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +7 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/file-references.d.ts +16 -0
- package/node_modules/@diffci.com/core/dist/repo/file-references.js +76 -5
- package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js +100 -29
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +7 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js +55 -8
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/layout.js +4 -1
- package/node_modules/@diffci.com/core/dist/repo/layout.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/runner-universe.js +10 -1
- package/node_modules/@diffci.com/core/dist/repo/runner-universe.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/script-universe.js +1 -1
- package/node_modules/@diffci.com/core/dist/repo/script-universe.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +5 -1
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/types.d.ts +3 -0
- package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js +3 -3
- package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/research/baseline/matcher.js +65 -13
- package/node_modules/@diffci.com/core/dist/research/baseline/matcher.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/research/baseline/workflow-parser.js +47 -2
- package/node_modules/@diffci.com/core/dist/research/baseline/workflow-parser.js.map +1 -1
- package/node_modules/@diffci.com/core/package.json +1 -0
- package/node_modules/@diffci.com/core/src/ci-inference/expression.ts +38 -5
- package/node_modules/@diffci.com/core/src/ci-inference/infer.ts +21 -6
- package/node_modules/@diffci.com/core/src/ci-inference/jobs.ts +7 -2
- package/node_modules/@diffci.com/core/src/ci-inference/matrix.ts +15 -8
- package/node_modules/@diffci.com/core/src/ci-inference/purpose.ts +6 -2
- package/node_modules/@diffci.com/core/src/ci-inference/resolve.ts +18 -4
- package/node_modules/@diffci.com/core/src/git/ci-config-paths.ts +8 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +20 -21
- package/node_modules/@diffci.com/core/src/planner/check-narrowing.ts +22 -1
- package/node_modules/@diffci.com/core/src/planner/pipeline-steps.ts +13 -2
- package/node_modules/@diffci.com/core/src/planner/planner.ts +42 -14
- package/node_modules/@diffci.com/core/src/planner/rust-command.ts +37 -1
- package/node_modules/@diffci.com/core/src/planner/script-reads.ts +5 -1
- package/node_modules/@diffci.com/core/src/planner/test-command.ts +17 -2
- package/node_modules/@diffci.com/core/src/planner/type-program.ts +25 -1
- package/node_modules/@diffci.com/core/src/repo/adapters/go.ts +5 -1
- package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +20 -2
- package/node_modules/@diffci.com/core/src/repo/adapters/python.ts +133 -14
- package/node_modules/@diffci.com/core/src/repo/adapters/rust.ts +136 -16
- package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +7 -1
- package/node_modules/@diffci.com/core/src/repo/file-references.ts +70 -5
- package/node_modules/@diffci.com/core/src/repo/graph.ts +81 -20
- package/node_modules/@diffci.com/core/src/repo/impact.ts +56 -7
- package/node_modules/@diffci.com/core/src/repo/layout.ts +5 -1
- package/node_modules/@diffci.com/core/src/repo/runner-universe.ts +11 -1
- package/node_modules/@diffci.com/core/src/repo/script-universe.ts +1 -1
- package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +4 -1
- package/node_modules/@diffci.com/core/src/repo/types.ts +3 -1
- package/node_modules/@diffci.com/core/src/repo/workflow-test-steps.ts +3 -3
- package/node_modules/@diffci.com/core/src/research/baseline/matcher.ts +43 -13
- package/node_modules/@diffci.com/core/src/research/baseline/workflow-parser.ts +44 -2
- package/package.json +2 -2
|
@@ -36,6 +36,26 @@ import { join, posix } from "node:path";
|
|
|
36
36
|
import { matchesGlob } from "./test-discovery.js";
|
|
37
37
|
import { LOCKFILE_NAMES } from "./lockfiles.js";
|
|
38
38
|
|
|
39
|
+
/** Trailing slashes. The lookbehind starts a match only at the first slash of a run; `/\/+$/` alone retries from every
|
|
40
|
+
* slash of a run that is not at the end, which is quadratic on long runs (CodeQL alerts 16, 17). */
|
|
41
|
+
const TRAILING_SLASHES = /(?<!\/)\/+$/;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `glob` with each `[...]` (up to the next `]`) replaced by `?`, as `/\[[^\]]*\]/g` would, in linear time: that
|
|
45
|
+
* regex rescans to the end from every `[` of a line with no `]`, quadratic on a long run of `[` (CodeQL alert 18).
|
|
46
|
+
*/
|
|
47
|
+
export function widenCharacterClasses(glob: string): string {
|
|
48
|
+
let out = "";
|
|
49
|
+
let from = 0;
|
|
50
|
+
for (let open = glob.indexOf("["); open !== -1; open = glob.indexOf("[", from)) {
|
|
51
|
+
const close = glob.indexOf("]", open + 1);
|
|
52
|
+
if (close === -1) break;
|
|
53
|
+
out += `${glob.slice(from, open)}?`;
|
|
54
|
+
from = close + 1;
|
|
55
|
+
}
|
|
56
|
+
return out + glob.slice(from);
|
|
57
|
+
}
|
|
58
|
+
|
|
39
59
|
const MAX_READ_BYTES = 1_048_576;
|
|
40
60
|
|
|
41
61
|
/** Reads repo-relative text files from a checkout at HEAD, the same tree the dependency graph reads.
|
|
@@ -269,11 +289,11 @@ export function scriptNamesPath(body: string, target: string, pattern: RegExp, {
|
|
|
269
289
|
if (posix.basename(candidate) === targetBase || pattern.test(` ${candidate} `)) return true;
|
|
270
290
|
continue;
|
|
271
291
|
}
|
|
272
|
-
const resolved = posix.normalize(posix.join(cwd || ".", candidate)).replace(
|
|
292
|
+
const resolved = posix.normalize(posix.join(cwd || ".", candidate)).replace(TRAILING_SLASHES, "");
|
|
273
293
|
if (GLOB_CHARS.test(candidate)) {
|
|
274
294
|
// Character classes are widened to any character, so an unsupported class syntax can only
|
|
275
295
|
// over-match. A glob naming a directory (`ops/*`) reaches the files inside it.
|
|
276
|
-
const widened = resolved
|
|
296
|
+
const widened = widenCharacterClasses(resolved);
|
|
277
297
|
if ([target, ...dirs].some((path) => matchesGlob(path, widened))) return true;
|
|
278
298
|
continue;
|
|
279
299
|
}
|
|
@@ -335,7 +355,8 @@ function namesDirectoryOf(content: string, readerPath: string, target: string):
|
|
|
335
355
|
const dir = posix.dirname(target);
|
|
336
356
|
if (dir === "." || posix.dirname(readerPath) === dir) return true;
|
|
337
357
|
const names = dir.split("/").filter(Boolean);
|
|
338
|
-
|
|
358
|
+
// `\\s`, not `\s`: in a template literal `\s` is just `s` (CodeQL alerts 27, 28).
|
|
359
|
+
return names.some((name) => new RegExp(`(?:^|["'\`/\\s(])${escape(name)}(?=$|["'\`/\\s),])`, "m").test(content));
|
|
339
360
|
}
|
|
340
361
|
|
|
341
362
|
/**
|
|
@@ -364,7 +385,7 @@ export function contentNamesPath(content: string, readerPath: string, target: st
|
|
|
364
385
|
// an unknown directory (2026-11-04: a LobeHub composite action blocked every changed file under scripts/).
|
|
365
386
|
const variable = /^\$(?:\{[\w.]+\}|\w+)\/(.+)$/.exec(word);
|
|
366
387
|
if (variable && !/[*?{}[\]!$]/.test(variable[1]!)) {
|
|
367
|
-
const rest = variable[1]!.replace(/^(?:\.\.?\/)+/, "").replace(
|
|
388
|
+
const rest = variable[1]!.replace(/^(?:\.\.?\/)+/, "").replace(TRAILING_SLASHES, "");
|
|
368
389
|
if (names.some((name) => name === rest || name.endsWith(`/${rest}`) || rest.endsWith(`/${name}`))) return true;
|
|
369
390
|
continue;
|
|
370
391
|
}
|
|
@@ -380,7 +401,7 @@ export function contentNamesPath(content: string, readerPath: string, target: st
|
|
|
380
401
|
if (names.some((name) => globs.some((glob) => matchesGlob(name, glob)))) return true;
|
|
381
402
|
continue;
|
|
382
403
|
}
|
|
383
|
-
const trimmed = word.replace(
|
|
404
|
+
const trimmed = word.replace(TRAILING_SLASHES, "");
|
|
384
405
|
const resolved = [posix.normalize(posix.join(readerDir, trimmed))];
|
|
385
406
|
if (!trimmed.startsWith("../")) resolved.push(posix.normalize(trimmed.replace(/^\/+/, "")));
|
|
386
407
|
if (resolved.some((path) => names.includes(path))) return true;
|
|
@@ -542,6 +563,50 @@ function directTestPhases(content: string, target: string, pattern: RegExp, ance
|
|
|
542
563
|
return found.length > 0 ? found : undefined;
|
|
543
564
|
}
|
|
544
565
|
|
|
566
|
+
const PROGRAM_INTERPRETERS = new Set(["node", "tsx", "ts-node", "bun"]);
|
|
567
|
+
const NO_PROGRAM_FLAGS = /^(?:--test(?:=|$)|--run(?:=|$)|-e$|--eval(?:=|$)|-p$|--print(?:=|$)|--check$|-c$|--help$|-h$|--version$|-v$)/;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* The programs the root test closure runs with an interpreter, by repository path, each with the `&&`
|
|
571
|
+
* phases that run it and whether every one of them can run alone (`direct`, as for directTestPhases)
|
|
572
|
+
* (2026-11-18). `node scripts/check.mjs && node --test` runs `scripts/check.mjs` as part of the suite,
|
|
573
|
+
* though no test imports it, so a change to it, or to code it imports, is a change to the suite.
|
|
574
|
+
* `node --test`, `node -e` and similar phases run no program file.
|
|
575
|
+
*/
|
|
576
|
+
export function testScriptPrograms(scripts: Readonly<Record<string, string>>): Map<string, { phases: string[]; direct: boolean }> {
|
|
577
|
+
const programs = new Map<string, { phases: string[]; direct: boolean }>();
|
|
578
|
+
for (const name of testScriptClosure(scripts)) {
|
|
579
|
+
// A phase of `a || b` or `a; b` is not one that can run alone, so only whole `&&` phases are direct.
|
|
580
|
+
const parts = (scripts[name] ?? "").split("&&").flatMap((part) => {
|
|
581
|
+
const pieces = part.split(/\|\||;/).map((piece) => piece.trim());
|
|
582
|
+
return pieces.map((phase) => ({ phase, alone: pieces.length === 1 }));
|
|
583
|
+
});
|
|
584
|
+
for (const { phase, alone } of parts) {
|
|
585
|
+
const words = phase.split(/\s+/).map((word) => word.replace(/^[\x22\x27]+|[\x22\x27]+$/g, ""));
|
|
586
|
+
// An `npx tsx` or `npx --yes tsx` prefix runs the same interpreter.
|
|
587
|
+
let start = 0;
|
|
588
|
+
if (words[0] === "npx") { start = 1; while (words[start]?.startsWith("-")) start += 1; }
|
|
589
|
+
if (!PROGRAM_INTERPRETERS.has(words[start] ?? "")) continue;
|
|
590
|
+
let index = start + 1;
|
|
591
|
+
let runsNoProgram = false;
|
|
592
|
+
while (index < words.length && words[index]!.startsWith("-")) {
|
|
593
|
+
if (NO_PROGRAM_FLAGS.test(words[index]!)) runsNoProgram = true;
|
|
594
|
+
index += PHASE_VALUE_FLAGS.has(words[index]!) ? 2 : 1;
|
|
595
|
+
}
|
|
596
|
+
const program = words[index];
|
|
597
|
+
if (runsNoProgram || !program || !/\.[cm]?[jt]sx?$/.test(program) || /[*?[\]{}$\x60]/.test(program)) continue;
|
|
598
|
+
const path = posix.normalize(program);
|
|
599
|
+
if (path.startsWith("../") || posix.isAbsolute(path)) continue;
|
|
600
|
+
const direct = alone && start === 0 && index === words.length - 1 && !/[|;<>\x60$(]/.test(phase);
|
|
601
|
+
const entry = programs.get(path) ?? { phases: [], direct: true };
|
|
602
|
+
if (!entry.phases.includes(phase)) entry.phases.push(phase);
|
|
603
|
+
entry.direct &&= direct;
|
|
604
|
+
programs.set(path, entry);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return programs;
|
|
608
|
+
}
|
|
609
|
+
|
|
545
610
|
function packageJsonNames(content: string, pattern: RegExp, target: string, ancestors: boolean, cwd: string): "yes" | "no" | "unparseable" {
|
|
546
611
|
let parsed: unknown;
|
|
547
612
|
try { parsed = JSON.parse(content); } catch { return "unparseable"; }
|
|
@@ -5,6 +5,7 @@ import { dirname, extname, isAbsolute, join, normalize, posix, relative, resolve
|
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
import { adapterFiles, REPOSITORY_ADAPTERS } from "./adapters/index.js";
|
|
7
7
|
import { rustAdapter } from "./adapters/rust.js";
|
|
8
|
+
import type { AdapterContribution } from "./adapters/types.js";
|
|
8
9
|
import { rustTestInvocation } from "./adapters/rust-invocation.js";
|
|
9
10
|
import { pythonAdapter } from "./adapters/python.js";
|
|
10
11
|
import { analyzeRepository, type AnalyzeRepositoryOptions } from "./analyzer.js";
|
|
@@ -204,21 +205,30 @@ function globPattern(glob: string): NonNullable<ImportRef["patterns"]>[number] |
|
|
|
204
205
|
const firstWild = body.search(/[*?{[]/);
|
|
205
206
|
const cut = body.lastIndexOf("/", firstWild < 0 ? body.length : firstWild);
|
|
206
207
|
if (cut < 0 || body.includes("[")) return undefined;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
// Brace alternatives are globs too (`{index,*-icon}.ts`); escaping them as literals matched only the
|
|
209
|
+
// literal ones and dropped the rest. Nested braces are not translated and keep the load computed.
|
|
210
|
+
const translate = (text: string): string | undefined => {
|
|
211
|
+
let regex = "";
|
|
212
|
+
for (let i = 0; i < text.length; i++) {
|
|
213
|
+
const char = text[i]!;
|
|
214
|
+
if (text.startsWith("**/", i)) { regex += "(?:.*/)?"; i += 2; }
|
|
215
|
+
else if (text.startsWith("**", i)) { regex += ".*"; i += 1; }
|
|
216
|
+
else if (char === "*") regex += "[^/]*";
|
|
217
|
+
else if (char === "?") regex += "[^/]";
|
|
218
|
+
else if (char === "{") {
|
|
219
|
+
const close = text.indexOf("}", i);
|
|
220
|
+
if (close < 0 || text.slice(i + 1, close).includes("{")) return undefined;
|
|
221
|
+
const alternatives = text.slice(i + 1, close).split(",").map(translate);
|
|
222
|
+
if (alternatives.some((alternative) => alternative === undefined)) return undefined;
|
|
223
|
+
regex += `(?:${alternatives.join("|")})`;
|
|
224
|
+
i = close;
|
|
225
|
+
} else if (char === "}") return undefined;
|
|
226
|
+
else regex += escapeRegex(char);
|
|
227
|
+
}
|
|
228
|
+
return regex;
|
|
229
|
+
};
|
|
230
|
+
const regex = translate(body.slice(cut + 1));
|
|
231
|
+
if (regex === undefined) return undefined;
|
|
222
232
|
// Vite resolves a glob starting with "/" from its project root, not the filesystem root.
|
|
223
233
|
return { base: body.slice(0, cut + 1), regex, negated, ...(body.startsWith("/") ? { viteRoot: true } : {}) };
|
|
224
234
|
}
|
|
@@ -1085,8 +1095,12 @@ export async function buildDependencyGraph(
|
|
|
1085
1095
|
adapterBlockers.push("Mixed Go/JavaScript repositories require explicit cross-language dependencies; full validation required");
|
|
1086
1096
|
}
|
|
1087
1097
|
const rustModeled = contributions.some((item) => item.id === "rust");
|
|
1088
|
-
|
|
1089
|
-
|
|
1098
|
+
const rustScope = rustLanguageFileScope(contributions);
|
|
1099
|
+
const mixedRustFiles = rustModeled ? files.filter(file => /\.(?:[cm]?[jt]sx?|vue|go|py|java|kt|cs|svelte|astro|c|h|cpp|cc|cxx)$/.test(file)) : [];
|
|
1100
|
+
if (mixedRustFiles.length) {
|
|
1101
|
+
const reason = "Mixed Rust/language repositories require explicit cross-language dependencies; full validation required";
|
|
1102
|
+
adapterBlockers.push(reason);
|
|
1103
|
+
for (const file of mixedRustFiles) addScope(reason, rustScope(file));
|
|
1090
1104
|
}
|
|
1091
1105
|
const pythonModeled = contributions.some((item) => item.id === "python");
|
|
1092
1106
|
const unmodeledLanguageFiles = contributions.length ? files.filter((file) => (!pythonModeled && /\.py$/.test(file)) || (!rustModeled && /\.rs$/.test(file)) || /\.(?:cs|svelte|astro)$/.test(file) || !contributions.some((item) => item.id === "maven") && /\.(?:java|kt)$/.test(file)) : [];
|
|
@@ -1095,7 +1109,7 @@ export async function buildDependencyGraph(
|
|
|
1095
1109
|
adapterBlockers.push(reason);
|
|
1096
1110
|
// Files in a top-level dot-directory outside every package (agent skills, editor tooling) are confined
|
|
1097
1111
|
// to that directory: no package's sources or tests can load them.
|
|
1098
|
-
for (const file of unmodeledLanguageFiles) addScope(reason, packageScope(file) || (/^\.[^/]+\//.test(file) && !file.startsWith(".github/") ? file.slice(0, file.indexOf("/")) : ""));
|
|
1112
|
+
for (const file of unmodeledLanguageFiles) addScope(reason, packageScope(file) || (/^\.[^/]+\//.test(file) && !file.startsWith(".github/") ? file.slice(0, file.indexOf("/")) : "") || rustScope(file));
|
|
1099
1113
|
}
|
|
1100
1114
|
profile.adapters = contributions.map(({ id, version, blockers }) => ({ id, version, blockers }));
|
|
1101
1115
|
// Rust test targets are not Go packages; other adapters keep their existing routing here.
|
|
@@ -1127,7 +1141,10 @@ export async function buildDependencyGraph(
|
|
|
1127
1141
|
profile.testFilePaths = [...new Set([...profile.testFilePaths, ...adapterTests])].sort();
|
|
1128
1142
|
if (profile.testUniverse) {
|
|
1129
1143
|
profile.testUniverse.discoveredTestFiles = profile.testFilePaths.length;
|
|
1130
|
-
|
|
1144
|
+
const runners: Record<string, string> = { go: "go test", maven: "Maven", python: "pytest", rust: "cargo test" };
|
|
1145
|
+
const adapterRunners = contributions.flatMap((item) => runners[item.id] ? [runners[item.id]!] : []);
|
|
1146
|
+
if (adapterRunners.length) profile.testUniverse.adapterRunners = adapterRunners;
|
|
1147
|
+
profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || adapterRunners.length > 0) && profile.testFilePaths.length === 0;
|
|
1131
1148
|
}
|
|
1132
1149
|
const entryPointPaths = new Set(profile.entryPoints.map((e) => e.path));
|
|
1133
1150
|
|
|
@@ -1378,6 +1395,19 @@ export async function buildDependencyGraph(
|
|
|
1378
1395
|
return undefined;
|
|
1379
1396
|
}
|
|
1380
1397
|
|
|
1398
|
+
/** The JavaScript file a repository declaration file describes, when it exists and is not excluded. */
|
|
1399
|
+
function declarationImplementation(declarationRel: string): string | undefined {
|
|
1400
|
+
const match = /^(.*)\.d\.([mc]?)ts$/.exec(declarationRel);
|
|
1401
|
+
if (!match) return undefined;
|
|
1402
|
+
const extensions = match[2] === "m" ? [".mjs"] : match[2] === "c" ? [".cjs"] : [".js", ".jsx"];
|
|
1403
|
+
for (const extension of extensions) {
|
|
1404
|
+
const candidate = match[1] + extension;
|
|
1405
|
+
if (isExcludedPath(candidate, options.excludeDirs ?? []) || candidate.split("/").includes("node_modules")) continue;
|
|
1406
|
+
if (internalSourcePaths.has(candidate) || existsSync(join(repoPath, candidate))) return candidate;
|
|
1407
|
+
}
|
|
1408
|
+
return undefined;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1381
1411
|
/** Parses an implementation file an import reaches outside the initial walk, rather than silently dropping
|
|
1382
1412
|
* the edge or loading every TypeScript declaration library again; false, with a blocker, past the budget. */
|
|
1383
1413
|
function followImplementation(absolute: string, rel: string): boolean {
|
|
@@ -1468,7 +1498,11 @@ export async function buildDependencyGraph(
|
|
|
1468
1498
|
// TypeScript may resolve a Vue import to a declaration shim. Preserve the actual SFC edge.
|
|
1469
1499
|
if (resolvableSpecifier.endsWith(".vue")) {
|
|
1470
1500
|
const compilerAliases = Object.entries(importerOptions.paths ?? {}).map(([pattern, substitutions]) => ({ pattern, substitutions }));
|
|
1471
|
-
|
|
1501
|
+
// `paths` resolve against `baseUrl`, or without one against the declaring tsconfig's directory
|
|
1502
|
+
// (TypeScript's pathsBasePath), never the importer's. Root aliases are repo-relative, as for assets.
|
|
1503
|
+
const candidate = compilerAliases.length
|
|
1504
|
+
? findAssetCandidate(sf.fileName, resolvableSpecifier, compilerAliases, importerOptions.baseUrl ?? (importerOptions as { pathsBasePath?: string }).pathsBasePath ?? dirname(sf.fileName))
|
|
1505
|
+
: findAssetCandidate(sf.fileName, resolvableSpecifier, profile.pathAliases, profile.tsconfig?.baseUrl ? resolve(repoPath, profile.tsconfig.baseUrl) : repoPath);
|
|
1472
1506
|
const target = candidate && toRelativeInternal(repoPath, candidate);
|
|
1473
1507
|
if (target && internalSourcePaths.has(target)) {
|
|
1474
1508
|
addEdge(importerRel, target, ref.kind, ref);
|
|
@@ -1576,6 +1610,11 @@ export async function buildDependencyGraph(
|
|
|
1576
1610
|
if (!resolved.endsWith(".d.ts") && !followImplementation(resolved, targetRel)) continue;
|
|
1577
1611
|
internalSourcePaths.add(targetRel);
|
|
1578
1612
|
addEdge(importerRel, targetRel, ref.kind, ref);
|
|
1613
|
+
// A hand-written declaration beside its JavaScript (`foo.d.ts` next to `foo.js`) is what TypeScript
|
|
1614
|
+
// resolves to, but the runner loads the JavaScript. Without this edge a change to `foo.js` reached
|
|
1615
|
+
// no importer and selected nothing.
|
|
1616
|
+
const implementation = declarationImplementation(targetRel);
|
|
1617
|
+
if (implementation && followImplementation(join(repoPath, implementation), implementation)) addEdge(importerRel, implementation, ref.kind, ref);
|
|
1579
1618
|
recordReference("internal-source", importerRel, ref);
|
|
1580
1619
|
continue;
|
|
1581
1620
|
}
|
|
@@ -2218,6 +2257,28 @@ function confinedConfigScope(repoPath: string, configRel: string, config: unknow
|
|
|
2218
2257
|
return directory;
|
|
2219
2258
|
}
|
|
2220
2259
|
|
|
2260
|
+
/** In a Cargo-only repository, the directory a helper script or native source is confined to: the
|
|
2261
|
+
* deepest member crate that contains it, or its top-level directory outside every crate of a virtual
|
|
2262
|
+
* workspace. Cargo can reach such a file only through code in that crate (a build script, which already
|
|
2263
|
+
* depends on every crate, or an `include!`, which falls back), and a change to the file itself keeps the
|
|
2264
|
+
* full suite, so only changes that reach the directory need full validation. "" (global) when another
|
|
2265
|
+
* adapter is active, when Rust code starts external programs that could run the file from anywhere, for
|
|
2266
|
+
* languages another engine could test (JavaScript, Go, Java and so on), for files that look like
|
|
2267
|
+
* Python tests, and inside a root package. */
|
|
2268
|
+
function rustLanguageFileScope(contributions: readonly AdapterContribution[]): (file: string) => string {
|
|
2269
|
+
const rust = contributions.length === 1 && contributions[0]!.id === "rust" ? contributions[0]! : undefined;
|
|
2270
|
+
const crates = rust?.rustCrateDirectories;
|
|
2271
|
+
if (!rust || !crates || rust.rustRunsPrograms !== false) return () => "";
|
|
2272
|
+
return (file: string) => {
|
|
2273
|
+
if (!/\.(?:py|c|h|cc|cpp|cxx)$/.test(file)) return "";
|
|
2274
|
+
const name = file.slice(file.lastIndexOf("/") + 1);
|
|
2275
|
+
if (/^(?:test_.*|.*_test|conftest)\.py$/.test(name)) return "";
|
|
2276
|
+
const crate = crates.filter(directory => directory === "" || file.startsWith(`${directory}/`)).sort((a, b) => b.length - a.length)[0];
|
|
2277
|
+
if (crate !== undefined) return crate;
|
|
2278
|
+
return file.includes("/") ? file.slice(0, file.indexOf("/")) : "";
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2221
2282
|
/** Moves blockers confined to directories out of `adapterBlockers` and returns them scoped to those
|
|
2222
2283
|
* directories (2026-11-08: Sentry's JavaScript SDK keeps 19 Nuxt, SvelteKit and Vue E2E applications whose
|
|
2223
2284
|
* tsconfig extends generated `.nuxt/`/`.svelte-kit/` files; they made every change in its SDK packages fall
|
|
@@ -8,7 +8,7 @@ import { refineConfidenceForDelta, relevantScopedAdapterBlockers } from "./graph
|
|
|
8
8
|
import { repositoryLayout, UNKNOWN_REPOSITORY_LAYOUT, type RepositoryLayout } from "./layout.js";
|
|
9
9
|
import { DEFAULT_TEST_FILE_MATCHER, matchesGlob as matchesTestGlob, testDiscoveryErrors, testFileMatcherForProfile } from "./test-discovery.js";
|
|
10
10
|
import { resolveTestFixtureOwners } from "./test-fixture-ownership.js";
|
|
11
|
-
import { compilerConfigNames, contentNamesPath, directoryWalkers, DIRECTING_EXTENSIONS, infrastructureRole, isAgentConfigurationPath, listsDirectories, loadsWithoutNaming, isImplicitlyLoadedFile, isWorkerConfig, referencePattern, referenceTokens, resolveFileReferences, suiteMayRunWorkers, testScriptClosure } from "./file-references.js";
|
|
11
|
+
import { compilerConfigNames, contentNamesPath, directoryWalkers, DIRECTING_EXTENSIONS, infrastructureRole, isAgentConfigurationPath, listsDirectories, loadsWithoutNaming, isImplicitlyLoadedFile, isWorkerConfig, referencePattern, referenceTokens, resolveFileReferences, suiteMayRunWorkers, testScriptClosure, testScriptPrograms } from "./file-references.js";
|
|
12
12
|
import { workflowFeedsTests } from "./workflow-test-steps.js";
|
|
13
13
|
import { modelTestScriptUniverse, type ScriptUniverse } from "./script-universe.js";
|
|
14
14
|
import { compiledProjects, type CompiledProject } from "./compiled-projects.js";
|
|
@@ -66,6 +66,7 @@ function toolConfigurationSubject(filePath: string): string | undefined {
|
|
|
66
66
|
if (base === ".nvmrc" || base === ".node-version") return "Node version";
|
|
67
67
|
if (base === ".npmrc") return "package manager settings";
|
|
68
68
|
if (/^tsconfig\.[^/]+\.json$/.test(base) || /^jsconfig\.[^/]+\.json$/.test(base)) return "TypeScript configuration";
|
|
69
|
+
if (base === ".mocharc" || base.startsWith(".mocharc.")) return "Mocha settings";
|
|
69
70
|
return undefined;
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -358,10 +359,10 @@ export class ImpactAnalyzer {
|
|
|
358
359
|
private knownTestPaths(profile: RepositoryProfile, graph: DependencyGraph): string[] {
|
|
359
360
|
if (this.knownTests) return this.knownTests;
|
|
360
361
|
const known = new Set<string>();
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
// Adapter repositories (pytest, Maven) declare no JavaScript test locations, so the matcher must not
|
|
363
|
+
// depend on profile.tests being non-empty.
|
|
364
|
+
for (const node of graph.nodes) {
|
|
365
|
+
if (this.isTestFile(node.path) || profile.tests.some((testLocation) => matchesTestGlob(node.path, testLocation.glob))) known.add(node.path);
|
|
365
366
|
}
|
|
366
367
|
this.knownTests = [...known].sort();
|
|
367
368
|
return this.knownTests;
|
|
@@ -707,7 +708,8 @@ export class ImpactAnalyzer {
|
|
|
707
708
|
// whose entire `__tests__/` suite was invisible: graph confidence COMPLETE, 5 of 5 commits
|
|
708
709
|
// SELECTIVE, zero tests. Fails closed to FULL instead.
|
|
709
710
|
if (profile.testUniverse?.blindSpot === true) {
|
|
710
|
-
|
|
711
|
+
// A language adapter (Go, Maven, pytest, Cargo) declares its runner without a package.json framework.
|
|
712
|
+
const declared = [...profile.testUniverse.declaredFrameworks, ...(profile.testUniverse.adapterRunners ?? [])].join(", ");
|
|
711
713
|
const message = `Repository declares ${declared} but no test files were discovered; full validation required`;
|
|
712
714
|
riskSignals.push({ level: "critical", reason: "TEST_UNIVERSE_EMPTY", message });
|
|
713
715
|
if (!fallbackReasons.includes(message)) fallbackReasons.push(message);
|
|
@@ -947,6 +949,14 @@ export class ImpactAnalyzer {
|
|
|
947
949
|
.map((ref) => packageRoot(ref.specifier)).filter((name) => !declared.has(name)))].sort();
|
|
948
950
|
if (undeclared.length) fail(`pnpm lockfile changed and repository imports undeclared dependencies (${undeclared.join(", ")}); full validation required`);
|
|
949
951
|
}
|
|
952
|
+
if (!delta.analysis.dependencyLockfile && delta.files.some((file) => file.path === "package-lock.json")) {
|
|
953
|
+
// npm hoists transitive packages to the root node_modules, where repository code can import them
|
|
954
|
+
// without declaring them. Attribution reaches only declared roots, so such an import is not covered.
|
|
955
|
+
const declared = new Set([...profile.packageJson.dependencies, ...profile.packageJson.devDependencies, ...packages]);
|
|
956
|
+
const undeclared = [...new Set(graphResult.references.filter((ref) => ref.resolution === "external-package")
|
|
957
|
+
.map((ref) => packageRoot(ref.specifier)).filter((name) => !declared.has(name)))].sort();
|
|
958
|
+
if (undeclared.length) fail(`npm lockfile changed and repository imports undeclared dependencies (${undeclared.join(", ")}); full validation required`);
|
|
959
|
+
}
|
|
950
960
|
const scripts = profile.packageJson.scripts;
|
|
951
961
|
const closureBodies = [...testScriptClosure(scripts)].map((name) => scripts[name] ?? "");
|
|
952
962
|
for (const name of packages) {
|
|
@@ -1255,6 +1265,7 @@ export class ImpactAnalyzer {
|
|
|
1255
1265
|
if (changedPath.endsWith(".py") && profile.pythonSources?.includes(changedPath)) {
|
|
1256
1266
|
this.resolveByReference(changedPath, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence, { allowNoReaders: true });
|
|
1257
1267
|
}
|
|
1268
|
+
this.coverTestScriptPrograms(changedPath, graph, profile, evidence, riskSignals, fallbackReasons);
|
|
1258
1269
|
this.processSourceChange(changedPath, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence);
|
|
1259
1270
|
this.failToolLoadedOrphan(changedPath, changedImpact, graph, affectedTests, evidence, riskSignals, fallbackReasons, covered);
|
|
1260
1271
|
}
|
|
@@ -1267,6 +1278,41 @@ export class ImpactAnalyzer {
|
|
|
1267
1278
|
* name anywhere, or any one at the repository root, that no file imports and that reached no test.
|
|
1268
1279
|
* An unused module elsewhere (`src/unused.ts`) still selects nothing: no tool loads it by name.
|
|
1269
1280
|
*/
|
|
1281
|
+
/**
|
|
1282
|
+
* A program the root test script runs itself (`node scripts/check.mjs && node --test`) is part of the
|
|
1283
|
+
* suite although no test imports it: the graph saw only an entry point, so a change to it, or to code it
|
|
1284
|
+
* imports, selected nothing for it and `verify` passed while `npm test` failed (2026-11-18). Callers
|
|
1285
|
+
* that run test-script phases run the phase; everyone else gets the full suite.
|
|
1286
|
+
*/
|
|
1287
|
+
private coverTestScriptPrograms(
|
|
1288
|
+
changedPath: string,
|
|
1289
|
+
graph: DependencyGraph,
|
|
1290
|
+
profile: RepositoryProfile,
|
|
1291
|
+
evidence: ImpactEvidence[],
|
|
1292
|
+
riskSignals: ImpactRiskSignal[],
|
|
1293
|
+
fallbackReasons: string[],
|
|
1294
|
+
): void {
|
|
1295
|
+
if (!JS_TS_CODE.test(changedPath) || this.isTestFile(changedPath)) return;
|
|
1296
|
+
const programs = testScriptPrograms(profile.packageJson.scripts);
|
|
1297
|
+
if (programs.size === 0) return;
|
|
1298
|
+
const reached = [changedPath, ...(hasNode(graph, changedPath) ? graph.transitiveDependentsOf(changedPath) : [])];
|
|
1299
|
+
for (const path of reached) {
|
|
1300
|
+
const program = programs.get(path);
|
|
1301
|
+
if (!program || this.isTestFile(path)) continue;
|
|
1302
|
+
if (this.selectTestPhases && program.direct) {
|
|
1303
|
+
for (const phase of program.phases) {
|
|
1304
|
+
this.testPhases.add(phase);
|
|
1305
|
+
evidence.push(makeEvidence("FILE_REFERENCE", changedPath, `the test script runs \`${phase}\`, which ${path === changedPath ? "is" : "imports"} ${changedPath}`));
|
|
1306
|
+
}
|
|
1307
|
+
continue;
|
|
1308
|
+
}
|
|
1309
|
+
const message = path === changedPath ? `The test script runs ${path}; full validation required` : `The test script runs ${path}, which imports ${changedPath}; full validation required`;
|
|
1310
|
+
evidence.push(makeEvidence("CONFIG_GLOBAL", changedPath, message));
|
|
1311
|
+
riskSignals.push({ level: "critical", reason: "CONFIG_GLOBAL", message, paths: [changedPath] });
|
|
1312
|
+
if (!fallbackReasons.includes(message)) fallbackReasons.push(message);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1270
1316
|
private failToolLoadedOrphan(
|
|
1271
1317
|
changedPath: string,
|
|
1272
1318
|
changedImpact: ChangedImpact,
|
|
@@ -1402,13 +1448,16 @@ export class ImpactAnalyzer {
|
|
|
1402
1448
|
}
|
|
1403
1449
|
const layout = this.layout;
|
|
1404
1450
|
const scripts = profile.packageJson.scripts;
|
|
1451
|
+
// A .py file the Python adapter modelled is code like a .js file: pytest runs a test that reads the
|
|
1452
|
+
// changed file without anything naming the test, so it must not be followed as a script.
|
|
1453
|
+
const pythonSources = new Set(profile.pythonSources ?? []);
|
|
1405
1454
|
const resolution = resolveFileReferences(changedPath, {
|
|
1406
1455
|
files: this.sortedRepositoryFiles,
|
|
1407
1456
|
read: this.readRepositoryFile,
|
|
1408
1457
|
isTestFile: this.isTestFile,
|
|
1409
1458
|
isDocumentation: (path) => layout.isDocumentationPath(path) || isAgentConfigurationPath(path),
|
|
1410
1459
|
inGraph: (path) => hasNode(graph, path),
|
|
1411
|
-
isCodeFile: isSourceFilePath,
|
|
1460
|
+
isCodeFile: (path) => isSourceFilePath(path) || pythonSources.has(path),
|
|
1412
1461
|
workflowFeedsTests: (content, names) => workflowFeedsTests(content, names, scripts),
|
|
1413
1462
|
contentCleared: this.contentCleared,
|
|
1414
1463
|
implicitReadersUnresolvable,
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
import { extname } from "node:path";
|
|
28
28
|
import type { RepositoryProfile } from "./types.js";
|
|
29
29
|
|
|
30
|
+
/** Trailing slashes. The lookbehind starts a match only at the first slash of a run; `/\/+$/` alone retries from every
|
|
31
|
+
* slash of a run that is not at the end, which is quadratic on long runs (CodeQL alerts 16, 17). */
|
|
32
|
+
const TRAILING_SLASHES = /(?<!\/)\/+$/;
|
|
33
|
+
|
|
30
34
|
/**
|
|
31
35
|
* Directory names that mean "documentation" across the ecosystem. Deliberately short: a name earns a
|
|
32
36
|
* place here by being a convention many projects share, not by appearing in one repository.
|
|
@@ -47,7 +51,7 @@ export interface RepositoryLayout {
|
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
function normalizeRoot(root: string): string {
|
|
50
|
-
return root.replace(/\\/g, "/").replace(/^\.\//, "").replace(
|
|
54
|
+
return root.replace(/\\/g, "/").replace(/^\.\//, "").replace(TRAILING_SLASHES, "");
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
function isUnder(path: string, root: string): boolean {
|
|
@@ -38,6 +38,16 @@ function stripRootDir(value: string): string {
|
|
|
38
38
|
return value.startsWith(ROOT_DIR) ? value.slice(ROOT_DIR.length).replace(/^\//, "") : value;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Jest replaces a leading `<rootDir>` in `testPathIgnorePatterns` with the absolute root directory.
|
|
43
|
+
* Ignore sources are matched against "/" + the repo-relative path, so the root becomes an anchored
|
|
44
|
+
* "^/". Anchoring keeps `<rootDir>/e2e/` from also ignoring `packages/a/e2e/`. A `<rootDir>` that
|
|
45
|
+
* is not at the front stays literal, as it does in jest.
|
|
46
|
+
*/
|
|
47
|
+
function rootDirIgnoreSource(source: string): string {
|
|
48
|
+
return source.startsWith(ROOT_DIR) ? `^/${source.slice(ROOT_DIR.length).replace(/^\/+/, "")}` : source;
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
export interface ExtractedTestPatterns {
|
|
42
52
|
/** Declared test globs, `<rootDir>/` stripped. */
|
|
43
53
|
includes: string[];
|
|
@@ -232,7 +242,7 @@ export function extractTestPatterns(source: string): ExtractedTestPatterns {
|
|
|
232
242
|
return {
|
|
233
243
|
includes: Array.from(new Set(includes)),
|
|
234
244
|
excludeGlobs: Array.from(new Set((readKey("exclude") ?? []).map(stripRootDir).filter((g) => g.length > 0 && !g.includes(ROOT_DIR)))),
|
|
235
|
-
ignoreRegexSources: Array.from(new Set(readKey("testPathIgnorePatterns") ?? [])),
|
|
245
|
+
ignoreRegexSources: Array.from(new Set((readKey("testPathIgnorePatterns") ?? []).map(rootDirIgnoreSource))),
|
|
236
246
|
roots,
|
|
237
247
|
declaresTests,
|
|
238
248
|
complete,
|
|
@@ -64,7 +64,7 @@ function expandScript(name: string, scripts: Readonly<Record<string, string>>, d
|
|
|
64
64
|
const phases: string[] = [];
|
|
65
65
|
for (const hook of [`pre${name}`, name, `post${name}`]) {
|
|
66
66
|
if (hook !== name && typeof scripts[hook] !== "string") continue;
|
|
67
|
-
for (const phase of (hook === name ? body : scripts[hook]!).split(
|
|
67
|
+
for (const phase of (hook === name ? body : scripts[hook]!).split("&&")) {
|
|
68
68
|
const words = shellWords(phase.trim());
|
|
69
69
|
const nested = words && /^(?:npm|pnpm|yarn|bun)$/.test(words[0] ?? "")
|
|
70
70
|
? (words[1] === "run" || words[1] === "run-script" ? words[2] : words[1] === "test" || words[1] === "t" ? "test" : undefined)
|
|
@@ -584,7 +584,10 @@ function globToRegex(pattern: string): RegExp {
|
|
|
584
584
|
return `\0X${groups.length - 1}\0`;
|
|
585
585
|
});
|
|
586
586
|
|
|
587
|
-
|
|
587
|
+
// `+`, `$` and `^` (outside a `[^...]` class) are literal in globs, as in picomatch: Remix route files
|
|
588
|
+
// (`users.$id.tsx`) and remix-flat-routes folders (`_auth+/`) use them. A bare `**` matches every path.
|
|
589
|
+
working = working.replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/[+$]|(?<!\[)\^/g, "\\$&");
|
|
590
|
+
if (working === "**") return /^.*$/;
|
|
588
591
|
working = working
|
|
589
592
|
.replace(/\*\*\//g, "\0GS\0")
|
|
590
593
|
.replace(/\/\*\*/g, "\0SG\0")
|
|
@@ -53,7 +53,7 @@ export interface RepositoryProfile {
|
|
|
53
53
|
mavenTestModules?: Record<string, string>;
|
|
54
54
|
/** Cargo target source to owning package name and target, verified by metadata. */
|
|
55
55
|
rustTestPackages?: Record<string, string>;
|
|
56
|
-
rustTestTargets?: Record<string, { name: string; kind: "lib" | "bin" | "test" | "bench" | "example" }>;
|
|
56
|
+
rustTestTargets?: Record<string, { name: string; kind: "lib" | "bin" | "test" | "bench" | "example"; requiredFeatures?: string[] }>;
|
|
57
57
|
rustSources?: string[];
|
|
58
58
|
/** Rust files that may read documentation (adapters/rust.ts). While one exists, documentation
|
|
59
59
|
* changes keep the full suite; otherwise they follow the shared documentation classification. */
|
|
@@ -133,6 +133,8 @@ export interface RepositoryProfile {
|
|
|
133
133
|
/** How each framework was detected - "dependency:<pkg>" or "script:<name>". */
|
|
134
134
|
frameworkEvidence: Record<string, string>;
|
|
135
135
|
discoveredTestFiles: number;
|
|
136
|
+
/** Runners that language adapters found sources for (`go test`, `Maven`, `pytest`, `cargo test`). */
|
|
137
|
+
adapterRunners?: string[];
|
|
136
138
|
/** True when the repository declares a test framework and zero test files were discovered - the
|
|
137
139
|
* engine does not understand this repository's test layout, and must not propose a selection
|
|
138
140
|
* against an empty universe. */
|
|
@@ -32,17 +32,17 @@ const NON_TEST_ACTIONS = [
|
|
|
32
32
|
/** DiffCI subcommands that run no tests. `verify`, `check`, `pilot` and `enforce-misses` do, so `diffci`
|
|
33
33
|
* followed by anything else stays a test runner (2026-10-29: DiffCI's own observation workflows were
|
|
34
34
|
* 60 of 65 workflow-triggered fallbacks in one dogfood repository's telemetry). */
|
|
35
|
-
const DIFFCI_NON_TEST_COMMAND = /\bdiffci["']?(?:\s
|
|
35
|
+
const DIFFCI_NON_TEST_COMMAND = /\bdiffci["']?(?:\s+-\S*)*\s+(?:observe|init|version|telemetry|pilot-packet|verify-workflow|validate-specs|mcp)\b/g;
|
|
36
36
|
|
|
37
37
|
/** `diffci` invoked with a subcommand still present after removing the non-test ones. */
|
|
38
|
-
const DIFFCI_COMMAND = /\bdiffci["']?(?:\s
|
|
38
|
+
const DIFFCI_COMMAND = /\bdiffci["']?(?:\s+-\S*)*\s+[a-z][\w-]*/;
|
|
39
39
|
|
|
40
40
|
/** A job whose `if` is the literal false never runs (a retired workflow kept for its history). */
|
|
41
41
|
function jobDisabled(job: object): boolean {
|
|
42
42
|
const condition = (job as { if?: unknown }).if;
|
|
43
43
|
return condition === false || (typeof condition === "string" && /^\s*(?:\$\{\{\s*)?false(?:\s*\}\})?\s*$/.test(condition));
|
|
44
44
|
}
|
|
45
|
-
const TEST_RUNNERS = /(?:^|[\s/"'`(;&|])(?:vitest|jest|mocha|ava|tap|playwright|cypress|karma|jasmine|pytest|tox|nox|phpunit|rspec|ctest)(?=$|[\s"'`);&|])|(?:node|tsx|bun|deno)(?:\s
|
|
45
|
+
const TEST_RUNNERS = /(?:^|[\s/"'`(;&|])(?:vitest|jest|mocha|ava|tap|playwright|cypress|karma|jasmine|pytest|tox|nox|phpunit|rspec|ctest)(?=$|[\s"'`);&|])|(?:node|tsx|bun|deno)(?:\s+-\S*)*\s+--?test\b|\b(?:go|cargo|dotnet|swift|mix|zig)\s+test\b|\b(?:mvn|mvnw|gradle|gradlew|sbt|bazel|make|just)\b/;
|
|
46
46
|
const PACKAGE_SCRIPT = /\b(?:npm|pnpm|yarn|bun)\s+(?:(?:run|run-script|-w\s+\S+|--workspace[= ]\S+|--prefix[= ]\S+|--if-present|-r|--recursive|--silent|-s)\s+)*([\w:.-]+)/g;
|
|
47
47
|
const INTERPRETER_FILE = /\b(?:node|tsx|ts-node|bash|sh|zsh|pwsh|powershell|python3?|ruby|perl|deno\s+run|bun(?:\s+run)?|npx\s+(?:--\S+\s+)*tsx)\s+(?:-{1,2}[\w-]+(?:=\S+)?\s+)*\.{0,2}\/?[\w./-]+\.(?:m?[jt]s|c[jt]s|sh|ps1|py|rb|pl)\b|(?:^|[\s;&|])\.{1,2}\/[\w./-]+/;
|
|
48
48
|
const PACKAGE_MANAGER_BUILTINS = new Set(["ci", "install", "i", "add", "remove", "uninstall", "publish", "pack", "version", "view", "info", "whoami", "login", "config", "cache", "audit", "outdated", "ls", "list", "exec", "dlx", "init", "create", "link", "prune", "dedupe", "rebuild", "set-script", "pkg", "fund", "doctor", "help", "--version", "-v"]);
|
|
@@ -10,24 +10,54 @@ function expandBraces(pattern: string): string[] {
|
|
|
10
10
|
return result;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const REGEX_SPECIAL = /[.*+?^${}()|[\]\\/]/g;
|
|
14
|
+
const literal = (char: string): string => char.replace(REGEX_SPECIAL, "\\$&");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Compiles one brace-free glob. `*` and `?` stay within a path segment, `**` crosses segments (a `**`
|
|
18
|
+
* followed by a slash, or a trailing slash and `**`, also matches zero directories), `[...]`/`[!...]` is a character class, `\` escapes the
|
|
19
|
+
* next character, and every other character is literal (#178: `(`, `+`, `|`, `$` and `^` used to reach
|
|
20
|
+
* the RegExp as operators, and `+` threw).
|
|
21
|
+
*/
|
|
13
22
|
function regexFrom(pattern: string): RegExp {
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
let source = "";
|
|
24
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
25
|
+
const char = pattern[i]!;
|
|
26
|
+
if (pattern.startsWith("**/", i)) { source += "(?:.*/)?"; i += 2; continue; }
|
|
27
|
+
if (pattern.startsWith("/**", i) && i + 3 === pattern.length) { source += "(?:/.*)?"; i += 2; continue; }
|
|
28
|
+
if (pattern.startsWith("**", i)) { source += ".*"; i += 1; continue; }
|
|
29
|
+
if (char === "*") { source += "[^/]*"; continue; }
|
|
30
|
+
if (char === "?") { source += "[^/]"; continue; }
|
|
31
|
+
if (char === "\\" && i + 1 < pattern.length) { source += literal(pattern[++i]!); continue; }
|
|
32
|
+
if (char === "[") {
|
|
33
|
+
const close = pattern.indexOf("]", i + 2);
|
|
34
|
+
if (close > i) {
|
|
35
|
+
let body = pattern.slice(i + 1, close);
|
|
36
|
+
const negated = body.startsWith("!") || body.startsWith("^");
|
|
37
|
+
if (negated) body = body.slice(1);
|
|
38
|
+
source += `[${negated ? "^/" : ""}${body.replace(/[\\\]^[]/g, "\\$&")}]`;
|
|
39
|
+
i = close;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
source += literal(char);
|
|
44
|
+
}
|
|
45
|
+
return new RegExp(`^${source}$`);
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
function matches(path: string, pattern: string): boolean {
|
|
29
49
|
const normalized = path.replace(/\\/g, "/");
|
|
30
|
-
return expandBraces(pattern).some((p) =>
|
|
50
|
+
return expandBraces(pattern).some((p) => {
|
|
51
|
+
let regex: RegExp;
|
|
52
|
+
try {
|
|
53
|
+
regex = regexFrom(p);
|
|
54
|
+
} catch {
|
|
55
|
+
// A class RegExp rejects, such as the reversed range in `[z-a]`, cannot rule a change out: count it
|
|
56
|
+
// as matching, so the task runs (the same reading as the planner's matcher in #174).
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return regex.test(normalized);
|
|
60
|
+
});
|
|
31
61
|
}
|
|
32
62
|
|
|
33
63
|
export function matchesAny(path: string, patterns: string[] | undefined): boolean {
|