@diffci.com/diffci 0.3.38 → 0.3.40

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.
Files changed (64) hide show
  1. package/README.md +3 -3
  2. package/dist-client/src/client/agent-setup.d.ts +1 -1
  3. package/dist-client/src/client/agent-setup.js +1 -1
  4. package/node_modules/@diffci.com/core/README.md +15 -4
  5. package/node_modules/@diffci.com/core/dist/cache/economics-context.d.ts +4 -1
  6. package/node_modules/@diffci.com/core/dist/cache/economics-context.js +7 -3
  7. package/node_modules/@diffci.com/core/dist/cache/economics-context.js.map +1 -1
  8. package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
  9. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +5 -1
  10. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js.map +1 -1
  11. package/node_modules/@diffci.com/core/dist/ci-inference/evidence.js +1 -1
  12. package/node_modules/@diffci.com/core/dist/ci-inference/evidence.js.map +1 -1
  13. package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +4 -0
  14. package/node_modules/@diffci.com/core/dist/git/git-diff.js +20 -7
  15. package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
  16. package/node_modules/@diffci.com/core/dist/repo/adapters/go.js +33 -7
  17. package/node_modules/@diffci.com/core/dist/repo/adapters/go.js.map +1 -1
  18. package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +8 -0
  19. package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
  20. package/node_modules/@diffci.com/core/dist/repo/analyzer.js +16 -1
  21. package/node_modules/@diffci.com/core/dist/repo/analyzer.js.map +1 -1
  22. package/node_modules/@diffci.com/core/dist/repo/export-reach.d.ts +16 -0
  23. package/node_modules/@diffci.com/core/dist/repo/export-reach.js +113 -0
  24. package/node_modules/@diffci.com/core/dist/repo/export-reach.js.map +1 -0
  25. package/node_modules/@diffci.com/core/dist/repo/file-references.js +2 -1
  26. package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
  27. package/node_modules/@diffci.com/core/dist/repo/graph.d.ts +5 -0
  28. package/node_modules/@diffci.com/core/dist/repo/graph.js +512 -41
  29. package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
  30. package/node_modules/@diffci.com/core/dist/repo/impact-types.d.ts +1 -1
  31. package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +51 -0
  32. package/node_modules/@diffci.com/core/dist/repo/impact.js +296 -9
  33. package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
  34. package/node_modules/@diffci.com/core/dist/repo/lockfiles.d.ts +5 -0
  35. package/node_modules/@diffci.com/core/dist/repo/lockfiles.js +12 -0
  36. package/node_modules/@diffci.com/core/dist/repo/lockfiles.js.map +1 -1
  37. package/node_modules/@diffci.com/core/dist/repo/repo-config.d.ts +5 -0
  38. package/node_modules/@diffci.com/core/dist/repo/repo-config.js +3 -1
  39. package/node_modules/@diffci.com/core/dist/repo/repo-config.js.map +1 -1
  40. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +134 -3
  41. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js.map +1 -1
  42. package/node_modules/@diffci.com/core/dist/repo/types.d.ts +35 -1
  43. package/node_modules/@diffci.com/core/dist/repo/workspace-sources.d.ts +35 -0
  44. package/node_modules/@diffci.com/core/dist/repo/workspace-sources.js +292 -0
  45. package/node_modules/@diffci.com/core/dist/repo/workspace-sources.js.map +1 -0
  46. package/node_modules/@diffci.com/core/package.json +1 -1
  47. package/node_modules/@diffci.com/core/src/cache/economics-context.ts +7 -3
  48. package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +5 -1
  49. package/node_modules/@diffci.com/core/src/ci-inference/evidence.ts +1 -1
  50. package/node_modules/@diffci.com/core/src/git/git-diff.ts +22 -7
  51. package/node_modules/@diffci.com/core/src/repo/adapters/go.ts +32 -7
  52. package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +5 -0
  53. package/node_modules/@diffci.com/core/src/repo/analyzer.ts +15 -1
  54. package/node_modules/@diffci.com/core/src/repo/export-reach.ts +92 -0
  55. package/node_modules/@diffci.com/core/src/repo/file-references.ts +2 -1
  56. package/node_modules/@diffci.com/core/src/repo/graph.ts +439 -37
  57. package/node_modules/@diffci.com/core/src/repo/impact-types.ts +2 -0
  58. package/node_modules/@diffci.com/core/src/repo/impact.ts +267 -9
  59. package/node_modules/@diffci.com/core/src/repo/lockfiles.ts +13 -0
  60. package/node_modules/@diffci.com/core/src/repo/repo-config.ts +8 -1
  61. package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +107 -3
  62. package/node_modules/@diffci.com/core/src/repo/types.ts +32 -1
  63. package/node_modules/@diffci.com/core/src/repo/workspace-sources.ts +273 -0
  64. package/package.json +3 -3
@@ -15,7 +15,7 @@ import { workflowMayRunTests } from "../repo/workflow-test-steps.js";
15
15
  import { npmLockAffectedDependencies } from "../repo/npm-lockfile.js";
16
16
  import { pnpmLockAffectedDependencies } from "../repo/pnpm-lockfile.js";
17
17
  import { yarnLockAffectedDependencies } from "../repo/yarn-lockfile.js";
18
- import { LOCKFILE } from "../repo/lockfiles.js";
18
+ import { LOCKFILE, LOCKFILE_NAMES } from "../repo/lockfiles.js";
19
19
  import { ciConfigPredicate, gitlabLocalIncludes, isConventionalCiConfigPath } from "./ci-config-paths.js";
20
20
 
21
21
  export const EMPTY_TREE_SHA = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
@@ -195,12 +195,12 @@ export function normalizeDirectories(paths: Iterable<string>): string[] {
195
195
  return dirs;
196
196
  }
197
197
 
198
- const CONFIG_PATTERNS = [
198
+ /** Exported for tests only: each entry must match a real configuration file name. */
199
+ export const CONFIG_PATTERNS = [
199
200
  /^next\.config\./,
200
201
  /^tsconfig\.json$/,
201
202
  /^jsconfig\.json$/,
202
203
  /^eslint\.config\./,
203
- /^eslint\.rc/,
204
204
  /^\.eslint/,
205
205
  /^postcss\.config\./,
206
206
  /^tailwind\.config\./,
@@ -208,6 +208,9 @@ const CONFIG_PATTERNS = [
208
208
  /^prettier\.config\./,
209
209
  /^vitest\.config\./,
210
210
  /^jest\.config\./,
211
+ // babel-jest transforms every test file with these; without this a .js/.ts babel.config or .babelrc.js was
212
+ // classified as source with no importers and selected no tests (2026-11-11, #99).
213
+ /^(?:babel\.config\.|\.babelrc)/,
211
214
  /^playwright\.config\./,
212
215
  /^webpack\.config\./,
213
216
  /^rollup\.config\./,
@@ -225,7 +228,6 @@ const CONFIG_PATTERNS = [
225
228
  /^yarn\.lock$/,
226
229
  /^pnpm-lock\.yaml$/,
227
230
  /^bun\.lockb$/,
228
- /^(npm|pnpm|yarn)-lock\./,
229
231
  // Python projects (2026-11-06): what pytest, the interpreter and the installed packages are.
230
232
  /^pyproject\.toml$/,
231
233
  /^setup\.(?:py|cfg)$/,
@@ -343,7 +345,6 @@ export function testListEdit(oldBody: string, newBody: string): { added: string[
343
345
  }
344
346
 
345
347
  const DEPENDENCY_FIELDS = new Set(["dependencies", "devDependencies", "optionalDependencies"]);
346
- const PACKAGE_LOCKFILES = ["package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "bun.lockb"];
347
348
 
348
349
  /** Exact root requests for the supported Classic layout. Unlike scriptRecord, never discard an
349
350
  * invalid dependency value: an omitted root would make the lockfile attribution incomplete. */
@@ -526,6 +527,20 @@ function readRootPathsAtSha(sha: string, repoPath: string | undefined): Readonly
526
527
  return roots.size === paths.length ? roots : undefined;
527
528
  }
528
529
 
530
+ /**
531
+ * Test-runner and transform configurations that apply to the tests of the directory that holds them, so
532
+ * a workspace package's copy configures that package's tests like a root one configures the root's
533
+ * (issue #117). `CONFIG_PATTERNS` is anchored at the repository root; without this a lone
534
+ * `packages/web/jest.config.js` or `packages/web/babel.config.js` change gave a SELECTIVE plan with no tests.
535
+ */
536
+ const NESTED_TEST_CONFIG = /^(?:jest\.config\.|vitest\.config\.|babel\.config\.|\.babelrc)/;
537
+
538
+ /** Exported for tests only: a test-runner or transform configuration below the repository root. */
539
+ export function isNestedTestConfig(path: string): boolean {
540
+ const segments = path.split("/");
541
+ return segments.length > 1 && !segments.includes("node_modules") && NESTED_TEST_CONFIG.test(segments[segments.length - 1]!);
542
+ }
543
+
529
544
  /** `isCiConfig` defaults to names alone; analyzeGitDelta also passes what GitLab `include` reaches. */
530
545
  export function computeAnalysis(files: ChangedFile[], isCiConfig: (path: string) => boolean = isConventionalCiConfigPath): GitDeltaAnalysis {
531
546
  const paths = files.flatMap((f) =>
@@ -534,7 +549,7 @@ export function computeAnalysis(files: ChangedFile[], isCiConfig: (path: string)
534
549
 
535
550
  const matching = (test: (p: string) => boolean) => [...new Set(paths.filter(test))].sort();
536
551
  const signalPaths: NonNullable<GitDeltaAnalysis["signalPaths"]> = {
537
- config: matching((p) => CONFIG_PATTERNS.some((pattern) => pattern.test(p))),
552
+ config: matching((p) => CONFIG_PATTERNS.some((pattern) => pattern.test(p)) || isNestedTestConfig(p)),
538
553
  dependencyManifest: matching((p) => p === "package.json"),
539
554
  lockfile: matching((p) => LOCKFILE.test(p)),
540
555
  workflow: matching(isCiConfig),
@@ -841,7 +856,7 @@ export async function analyzeGitDelta(
841
856
  const lockfileGoverns = (path: string) => {
842
857
  for (let dir = posix.dirname(path); ; dir = posix.dirname(dir)) {
843
858
  const prefix = dir === "." ? "" : `${dir}/`;
844
- if (PACKAGE_LOCKFILES.some((name) => [baseSha, headSha].some((sha) => readFileAtSha(sha, prefix + name, repoPath) !== undefined))) return true;
859
+ if (LOCKFILE_NAMES.some((name) => [baseSha, headSha].some((sha) => readFileAtSha(sha, prefix + name, repoPath) !== undefined))) return true;
845
860
  if (dir === ".") return false;
846
861
  }
847
862
  };
@@ -77,7 +77,11 @@ export function analyzeGoMetadata(context: AdapterContext, output: string): Adap
77
77
  // Associate inactive files with their package conservatively. They are not runnable
78
78
  // tests, but edits (including build constraints) must still select that package and
79
79
  // its dependents. Unaccounted files remain a global blocker below.
80
- const files = [...(pkg.GoFiles ?? []), ...(pkg.CgoFiles ?? []), ...(pkg.TestGoFiles ?? []), ...(pkg.XTestGoFiles ?? []), ...(pkg.IgnoredGoFiles ?? [])];
80
+ // A package of a locally replaced module is a dependency of the root build only: its tests belong to
81
+ // that module and cannot run from the root, so they are neither selectable tests nor modelled sources.
82
+ const replaced = Boolean(pkg.Module?.Replace?.Dir);
83
+ const testFiles = replaced ? [] : [...(pkg.TestGoFiles ?? []), ...(pkg.XTestGoFiles ?? [])];
84
+ const files = [...(pkg.GoFiles ?? []), ...(pkg.CgoFiles ?? []), ...testFiles, ...(pkg.IgnoredGoFiles ?? [])];
81
85
  const paths = files.map((file) => internalPath(context.repoPath, resolve(pkg.Dir, file)));
82
86
  if (paths.some((p) => p === undefined)) { result.blockers.push("Go package contains files outside the repository"); continue; }
83
87
  const sources = paths as string[];
@@ -92,12 +96,12 @@ export function analyzeGoMetadata(context: AdapterContext, output: string): Adap
92
96
  if (/^\s*\/\/go:(?:generate|linkname)\b/m.test(readFileSync(resolve(context.repoPath, file), "utf8"))) result.blockers.push(`Go ${file}: generated or linked dependencies require full validation`);
93
97
  }
94
98
  const dir = internalPath(context.repoPath, pkg.Dir)!;
95
- for (const test of [...(pkg.TestGoFiles ?? []), ...(pkg.XTestGoFiles ?? [])]) {
99
+ for (const test of testFiles) {
96
100
  const path = internalPath(context.repoPath, resolve(pkg.Dir, test))!;
97
101
  result.testFiles.push(path);
98
102
  result.testPackages[path] = dir ? `./${dir}` : ".";
99
103
  }
100
- for (const file of [...(pkg.EmbedFiles ?? []), ...(pkg.TestEmbedFiles ?? []), ...(pkg.XTestEmbedFiles ?? [])]) {
104
+ for (const file of [...(pkg.EmbedFiles ?? []), ...(replaced ? [] : [...(pkg.TestEmbedFiles ?? []), ...(pkg.XTestEmbedFiles ?? [])])]) {
101
105
  const asset = internalPath(context.repoPath, resolve(pkg.Dir, file));
102
106
  if (asset === undefined) { result.blockers.push("Go embedded file escapes repository"); continue; }
103
107
  result.assetPaths.push(asset);
@@ -111,7 +115,8 @@ export function analyzeGoMetadata(context: AdapterContext, output: string): Adap
111
115
  for (const file of members.get(pkg.ImportPath) ?? []) {
112
116
  if (file !== anchor) result.edges.push({ from: anchor, to: file, kind: "import" }, { from: file, to: anchor, kind: "import" });
113
117
  }
114
- for (const imported of [...(pkg.Imports ?? []), ...(pkg.TestImports ?? []), ...(pkg.XTestImports ?? [])]) {
118
+ const replaced = Boolean(pkg.Module?.Replace?.Dir);
119
+ for (const imported of [...(pkg.Imports ?? []), ...(replaced ? [] : [...(pkg.TestImports ?? []), ...(pkg.XTestImports ?? [])])]) {
115
120
  const target = anchors.get(imported);
116
121
  if (target && target !== anchor) result.edges.push({ from: anchor, to: target, kind: "import" });
117
122
  }
@@ -131,6 +136,15 @@ export const goAdapter: RepositoryAdapter = {
131
136
  const failure = contribution(this);
132
137
  const nestedRoots = context.files.filter(f => f.endsWith("/go.mod")).map(f => f.slice(0, -"go.mod".length));
133
138
  const scoped = context.profile.diffciConfig?.go?.scope === "root-module";
139
+ // No root module and no workspace, and every Go file sits inside a nested module: those modules are
140
+ // tools beside a repository written in another language (Paperclip's tools/agent-shim, 2026-11-11).
141
+ // They are not modelled. A change that reaches one falls back; the rest of the repository is planned
142
+ // as if Go were absent, instead of every change falling back.
143
+ if (!context.files.includes("go.mod") && !context.files.includes("go.work") && nestedRoots.length
144
+ && context.files.filter(file => file.endsWith(".go")).every(file => nestedRoots.some(root => file.startsWith(root)))) {
145
+ const reason = "Go modules without a root go.mod are not modelled; a change that reaches one requires full validation";
146
+ return { ...failure, confinedOnly: true, directoryBlockers: nestedRoots.map(root => ({ directory: root.slice(0, -1), reason })) };
147
+ }
134
148
  if (!context.files.includes("go.mod") || context.files.includes("go.work") || (nestedRoots.length && !scoped)) {
135
149
  failure.blockers.push("Go support requires one root go.mod; workspaces and nested modules require full validation");
136
150
  return failure;
@@ -156,9 +170,20 @@ export const goAdapter: RepositoryAdapter = {
156
170
  const scopedContext = scoped ? { ...context, files: context.files.filter(file => !excluded(file)) } : context;
157
171
  const result = analyzeGoMetadata(scopedContext, output);
158
172
  if (scoped) {
159
- context.profile.goExcludedModuleRoots = nestedRoots;
160
- // A local replacement can make an excluded module part of the root module's build.
161
- if (parseGoList(output).some(pkg => pkg.Module?.Replace?.Dir)) result.blockers.push("Go root-module scope with local replacements requires full validation");
173
+ // A local replacement makes a nested module part of the root module's build. When it points at a
174
+ // nested module root inside the repository, go list already reports the packages the root build
175
+ // uses (with their Dir inside the checkout), so that module is modelled rather than excluded:
176
+ // changes to those packages select their importers, and its other files (its own tests, packages
177
+ // the root does not use, its go.mod) stay outside source metadata and fall back (#81).
178
+ const replaceDirs = new Set(parseGoList(output).flatMap(pkg => {
179
+ const dir = pkg.Module?.Replace?.Dir;
180
+ if (!dir) return [];
181
+ const internal = internalPath(context.repoPath, dir);
182
+ return [internal === undefined ? dir : `${internal}/`];
183
+ }));
184
+ const replacedRoots = nestedRoots.filter(root => replaceDirs.has(root));
185
+ context.profile.goExcludedModuleRoots = nestedRoots.filter(root => !replacedRoots.includes(root));
186
+ if (replaceDirs.size > replacedRoots.length) result.blockers.push("Go root-module scope with local replacements requires full validation");
162
187
  }
163
188
  result.executionEnv = { GOOS: buildEnv.GOOS, GOARCH: buildEnv.GOARCH, CGO_ENABLED: buildEnv.CGO_ENABLED, GOFLAGS: "" };
164
189
  return result;
@@ -28,6 +28,11 @@ export interface AdapterContribution {
28
28
  fileBlockers?: Array<{ path: string; reason: string }>;
29
29
  /** Blockers (also listed in `blockers`) whose missing edges start at `path`, for package-directory scoping. */
30
30
  subjectBlockers?: Array<{ path: string; reason: string }>;
31
+ /** Blockers confined to a directory the adapter cannot model (a nested module root): a change that
32
+ * reaches the directory falls back, and changes elsewhere are planned without the adapter. */
33
+ directoryBlockers?: Array<{ directory: string; reason: string }>;
34
+ /** The adapter models nothing and only reports `directoryBlockers`; it is not an active adapter. */
35
+ confinedOnly?: boolean;
31
36
  performance?: { phasesMs: Record<string, number>; counts: Record<string, number> };
32
37
  }
33
38
 
@@ -218,6 +218,14 @@ function matchesTestGlob(path: string, pattern: string): boolean {
218
218
  return matchesGlob(path, pattern);
219
219
  }
220
220
 
221
+ /**
222
+ * Build-output names skipped only where output goes: beside a package.json or at the repository root.
223
+ * 2026-11-10: skipping them at any depth hid payloadcms/payload's
224
+ * `packages/payload/src/cli/commands/build/build.spec.ts`, a source test Vitest runs, so a narrowed selection
225
+ * could never include it.
226
+ */
227
+ const OUTPUT_DIR_NAMES = new Set(["dist", "build", "tmp", "temp"]);
228
+
221
229
  function scanFiles(
222
230
  dirPath: string,
223
231
  repoPath: string,
@@ -225,9 +233,15 @@ function scanFiles(
225
233
  callback: (relativePath: string, fileName: string) => void,
226
234
  ): void {
227
235
  const entries = readdirSync(dirPath, { withFileTypes: true });
236
+ let outputRoot: boolean | undefined;
228
237
  for (const entry of entries) {
229
238
  if (entry.isDirectory()) {
230
- if (excludeDirs.has(entry.name) || entry.name.startsWith(".")) continue;
239
+ if (entry.name.startsWith(".")) continue;
240
+ if (excludeDirs.has(entry.name)) {
241
+ if (!OUTPUT_DIR_NAMES.has(entry.name)) continue;
242
+ outputRoot ??= dirPath === repoPath || existsSync(join(dirPath, "package.json"));
243
+ if (outputRoot) continue;
244
+ }
231
245
  scanFiles(join(dirPath, entry.name), repoPath, excludeDirs, callback);
232
246
  continue;
233
247
  }
@@ -0,0 +1,92 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import type { ModuleBindings } from "./types.js";
3
+
4
+ /**
5
+ * Export-level reach (2026-11-10). File-level selection treats `import { x } from "pkg"` as a dependency on
6
+ * every file `pkg`'s barrel re-exports, which is what `vitest --changed` does too. On payloadcms/payload that
7
+ * selects about 230 of 520 test files for a change in one hierarchy helper. Following re-exports by name
8
+ * inside packages that declare `sideEffects: false` (the contract bundlers rely on to drop unused re-exports)
9
+ * selected 16.5% of test files on 31 code-only commits against Vitest's 23.5%.
10
+ *
11
+ * `touched` is every file whose code a test runs or whose exports were consulted to resolve one of its
12
+ * names, so a changed barrel or a changed `export *` source still selects. Whenever the walk cannot tell
13
+ * which names a module binds (no bindings, opaque exports, a package without the side-effect contract, a
14
+ * name it cannot find) it counts the whole module, as file-level selection does.
15
+ */
16
+ export function exportLevelReach(
17
+ start: string,
18
+ bindings: Readonly<Record<string, ModuleBindings>>,
19
+ runtimeDependencies: (path: string) => readonly string[],
20
+ /** Tests may be type-checked as they run: a type import of a target takes the whole target. */
21
+ followTypes = false,
22
+ ): Set<string> {
23
+ const touched = new Set<string>();
24
+ const ran = new Set<string>();
25
+ const whole = new Set<string>();
26
+ const seen = new Set<string>();
27
+ const queue: [string, string][] = [[start, "*"]];
28
+
29
+ const runBody = (file: string): void => {
30
+ if (ran.has(file)) return;
31
+ ran.add(file);
32
+ const own = bindings[file];
33
+ for (const target of runtimeDependencies(file)) {
34
+ const imported = own?.imports[target];
35
+ if (followTypes && own?.typeImports?.includes(target)) {
36
+ queue.push([target, "*"]);
37
+ } else if (imported === undefined) {
38
+ // A target only re-exported is evaluated but contributes nothing unless a name is asked of it.
39
+ if (own?.reexports[target] && bindings[target]?.sideEffectFree) continue;
40
+ queue.push([target, "*"]);
41
+ } else if (imported === "*" || !bindings[target]?.sideEffectFree) {
42
+ queue.push([target, "*"]);
43
+ } else {
44
+ for (const name of imported) queue.push([target, name]);
45
+ }
46
+ }
47
+ };
48
+
49
+ const takeWhole = (file: string): void => {
50
+ if (whole.has(file)) return;
51
+ whole.add(file);
52
+ runBody(file);
53
+ for (const target of Object.keys(bindings[file]?.reexports ?? {})) queue.push([target, "*"]);
54
+ };
55
+
56
+ const defines = (file: string, name: string, visiting: Set<string>): boolean => {
57
+ if (visiting.has(file)) return false;
58
+ visiting.add(file);
59
+ touched.add(file);
60
+ const own = bindings[file];
61
+ if (!own || own.opaque || !own.sideEffectFree) return true;
62
+ if (own.locals.includes(name)) return true;
63
+ for (const forwarded of Object.values(own.reexports)) {
64
+ if (forwarded.namespaces.includes(name) || forwarded.pairs.some(([exported]) => exported === name)) return true;
65
+ }
66
+ return Object.entries(own.reexports).some(([target, forwarded]) => forwarded.star && defines(target, name, visiting));
67
+ };
68
+
69
+ while (queue.length) {
70
+ const [file, name] = queue.pop()!;
71
+ const key = `${file}\0${name}`;
72
+ if (seen.has(key) || whole.has(file)) continue;
73
+ seen.add(key);
74
+ touched.add(file);
75
+ const own = bindings[file];
76
+ if (name === "*" || !own || own.opaque || !own.sideEffectFree) { takeWhole(file); continue; }
77
+ if (own.locals.includes(name)) { runBody(file); continue; }
78
+ let found = false;
79
+ for (const [target, forwarded] of Object.entries(own.reexports)) {
80
+ if (forwarded.namespaces.includes(name)) { queue.push([target, "*"]); found = true; }
81
+ for (const [exported, imported] of forwarded.pairs) if (exported === name) { queue.push([target, imported]); found = true; }
82
+ }
83
+ if (!found) {
84
+ for (const [target, forwarded] of Object.entries(own.reexports)) {
85
+ if (forwarded.star && defines(target, name, new Set())) { queue.push([target, name]); found = true; }
86
+ }
87
+ }
88
+ if (!found) takeWhole(file);
89
+ }
90
+ for (const file of ran) touched.add(file);
91
+ return touched;
92
+ }
@@ -34,6 +34,7 @@
34
34
  import { readFileSync, statSync } from "node:fs";
35
35
  import { join, posix } from "node:path";
36
36
  import { matchesGlob } from "./test-discovery.js";
37
+ import { LOCKFILE_NAMES } from "./lockfiles.js";
37
38
 
38
39
  const MAX_READ_BYTES = 1_048_576;
39
40
 
@@ -210,7 +211,7 @@ export interface ReferenceResolution {
210
211
 
211
212
  const MAX_DEPTH = 5;
212
213
  const MAX_TRANSITIVE_READERS = 50;
213
- const LOCKFILES = new Set(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "bun.lockb", "npm-shrinkwrap.json"]);
214
+ const LOCKFILES: ReadonlySet<string> = new Set(LOCKFILE_NAMES);
214
215
  const TEST_LIFECYCLE = ["pretest", "test", "posttest", "prepare", "preinstall", "install", "postinstall"];
215
216
  /** Non-code files that can run something or direct what code reads: shell and interpreter scripts,
216
217
  * and structured manifests. Only these are followed to their own readers. */