@diffci.com/diffci 0.3.53 → 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.
Files changed (130) hide show
  1. package/dist-client/src/client/agent-selection.d.ts +81 -1
  2. package/dist-client/src/client/agent-selection.js +107 -4
  3. package/dist-client/src/client/agent-setup.js +1 -1
  4. package/dist-client/src/client/cli.js +140 -18
  5. package/dist-client/src/client/command-batches.js +3 -2
  6. package/dist-client/src/client/context.js +32 -2
  7. package/dist-client/src/client/coverage-map.js +6 -1
  8. package/dist-client/src/client/full-command.js +19 -14
  9. package/dist-client/src/client/hook.d.ts +17 -0
  10. package/dist-client/src/client/hook.js +53 -1
  11. package/dist-client/src/client/install.d.ts +6 -0
  12. package/dist-client/src/client/install.js +30 -1
  13. package/dist-client/src/client/isolated-worktree.d.ts +31 -0
  14. package/dist-client/src/client/isolated-worktree.js +130 -0
  15. package/dist-client/src/client/mcp.js +23 -4
  16. package/dist-client/src/client/observe.d.ts +2 -0
  17. package/dist-client/src/client/observe.js +7 -2
  18. package/dist-client/src/client/report.d.ts +1 -1
  19. package/dist-client/src/client/shared-graph-cache.js +4 -2
  20. package/dist-client/src/client/telemetry.js +2 -1
  21. package/dist-client/src/client/usage-signal.d.ts +1 -1
  22. package/dist-client/src/client/verify-savings.d.ts +6 -0
  23. package/dist-client/src/client/verify-savings.js +15 -3
  24. package/dist-client/src/client/verify.d.ts +47 -3
  25. package/dist-client/src/client/verify.js +244 -22
  26. package/dist-client/src/client/working-tree.d.ts +22 -0
  27. package/dist-client/src/client/working-tree.js +45 -6
  28. package/node_modules/@diffci.com/core/README.md +17 -10
  29. package/node_modules/@diffci.com/core/dist/ci-inference/expression.d.ts +5 -0
  30. package/node_modules/@diffci.com/core/dist/ci-inference/expression.js +38 -5
  31. package/node_modules/@diffci.com/core/dist/ci-inference/expression.js.map +1 -1
  32. package/node_modules/@diffci.com/core/dist/ci-inference/infer.js +26 -6
  33. package/node_modules/@diffci.com/core/dist/ci-inference/infer.js.map +1 -1
  34. package/node_modules/@diffci.com/core/dist/ci-inference/jobs.d.ts +2 -1
  35. package/node_modules/@diffci.com/core/dist/ci-inference/jobs.js +7 -2
  36. package/node_modules/@diffci.com/core/dist/ci-inference/jobs.js.map +1 -1
  37. package/node_modules/@diffci.com/core/dist/ci-inference/matrix.js +15 -8
  38. package/node_modules/@diffci.com/core/dist/ci-inference/matrix.js.map +1 -1
  39. package/node_modules/@diffci.com/core/dist/ci-inference/purpose.js +6 -2
  40. package/node_modules/@diffci.com/core/dist/ci-inference/purpose.js.map +1 -1
  41. package/node_modules/@diffci.com/core/dist/ci-inference/resolve.js +19 -4
  42. package/node_modules/@diffci.com/core/dist/ci-inference/resolve.js.map +1 -1
  43. package/node_modules/@diffci.com/core/dist/git/ci-config-paths.js +13 -1
  44. package/node_modules/@diffci.com/core/dist/git/ci-config-paths.js.map +1 -1
  45. package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +5 -0
  46. package/node_modules/@diffci.com/core/dist/git/git-diff.js +22 -20
  47. package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
  48. package/node_modules/@diffci.com/core/dist/planner/check-narrowing.js +22 -1
  49. package/node_modules/@diffci.com/core/dist/planner/check-narrowing.js.map +1 -1
  50. package/node_modules/@diffci.com/core/dist/planner/pipeline-steps.d.ts +6 -0
  51. package/node_modules/@diffci.com/core/dist/planner/pipeline-steps.js +14 -2
  52. package/node_modules/@diffci.com/core/dist/planner/pipeline-steps.js.map +1 -1
  53. package/node_modules/@diffci.com/core/dist/planner/planner.js +65 -14
  54. package/node_modules/@diffci.com/core/dist/planner/planner.js.map +1 -1
  55. package/node_modules/@diffci.com/core/dist/planner/rust-command.js +43 -1
  56. package/node_modules/@diffci.com/core/dist/planner/rust-command.js.map +1 -1
  57. package/node_modules/@diffci.com/core/dist/planner/script-reads.js +5 -2
  58. package/node_modules/@diffci.com/core/dist/planner/script-reads.js.map +1 -1
  59. package/node_modules/@diffci.com/core/dist/planner/test-command.js +17 -2
  60. package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
  61. package/node_modules/@diffci.com/core/dist/planner/type-program.js +27 -1
  62. package/node_modules/@diffci.com/core/dist/planner/type-program.js.map +1 -1
  63. package/node_modules/@diffci.com/core/dist/repo/adapters/go.js +5 -1
  64. package/node_modules/@diffci.com/core/dist/repo/adapters/go.js.map +1 -1
  65. package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +21 -2
  66. package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
  67. package/node_modules/@diffci.com/core/dist/repo/adapters/python.d.ts +9 -1
  68. package/node_modules/@diffci.com/core/dist/repo/adapters/python.js +158 -14
  69. package/node_modules/@diffci.com/core/dist/repo/adapters/python.js.map +1 -1
  70. package/node_modules/@diffci.com/core/dist/repo/adapters/rust.d.ts +1 -0
  71. package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js +180 -15
  72. package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js.map +1 -1
  73. package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +7 -0
  74. package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
  75. package/node_modules/@diffci.com/core/dist/repo/file-references.d.ts +16 -0
  76. package/node_modules/@diffci.com/core/dist/repo/file-references.js +76 -5
  77. package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
  78. package/node_modules/@diffci.com/core/dist/repo/graph.js +100 -29
  79. package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
  80. package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +7 -0
  81. package/node_modules/@diffci.com/core/dist/repo/impact.js +55 -8
  82. package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
  83. package/node_modules/@diffci.com/core/dist/repo/layout.js +4 -1
  84. package/node_modules/@diffci.com/core/dist/repo/layout.js.map +1 -1
  85. package/node_modules/@diffci.com/core/dist/repo/runner-universe.js +10 -1
  86. package/node_modules/@diffci.com/core/dist/repo/runner-universe.js.map +1 -1
  87. package/node_modules/@diffci.com/core/dist/repo/script-universe.js +1 -1
  88. package/node_modules/@diffci.com/core/dist/repo/script-universe.js.map +1 -1
  89. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +5 -1
  90. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js.map +1 -1
  91. package/node_modules/@diffci.com/core/dist/repo/types.d.ts +3 -0
  92. package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js +3 -3
  93. package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js.map +1 -1
  94. package/node_modules/@diffci.com/core/dist/research/baseline/matcher.js +65 -13
  95. package/node_modules/@diffci.com/core/dist/research/baseline/matcher.js.map +1 -1
  96. package/node_modules/@diffci.com/core/dist/research/baseline/workflow-parser.js +47 -2
  97. package/node_modules/@diffci.com/core/dist/research/baseline/workflow-parser.js.map +1 -1
  98. package/node_modules/@diffci.com/core/package.json +1 -0
  99. package/node_modules/@diffci.com/core/src/ci-inference/expression.ts +38 -5
  100. package/node_modules/@diffci.com/core/src/ci-inference/infer.ts +21 -6
  101. package/node_modules/@diffci.com/core/src/ci-inference/jobs.ts +7 -2
  102. package/node_modules/@diffci.com/core/src/ci-inference/matrix.ts +15 -8
  103. package/node_modules/@diffci.com/core/src/ci-inference/purpose.ts +6 -2
  104. package/node_modules/@diffci.com/core/src/ci-inference/resolve.ts +18 -4
  105. package/node_modules/@diffci.com/core/src/git/ci-config-paths.ts +8 -1
  106. package/node_modules/@diffci.com/core/src/git/git-diff.ts +20 -21
  107. package/node_modules/@diffci.com/core/src/planner/check-narrowing.ts +22 -1
  108. package/node_modules/@diffci.com/core/src/planner/pipeline-steps.ts +13 -2
  109. package/node_modules/@diffci.com/core/src/planner/planner.ts +42 -14
  110. package/node_modules/@diffci.com/core/src/planner/rust-command.ts +37 -1
  111. package/node_modules/@diffci.com/core/src/planner/script-reads.ts +5 -1
  112. package/node_modules/@diffci.com/core/src/planner/test-command.ts +17 -2
  113. package/node_modules/@diffci.com/core/src/planner/type-program.ts +25 -1
  114. package/node_modules/@diffci.com/core/src/repo/adapters/go.ts +5 -1
  115. package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +20 -2
  116. package/node_modules/@diffci.com/core/src/repo/adapters/python.ts +133 -14
  117. package/node_modules/@diffci.com/core/src/repo/adapters/rust.ts +136 -16
  118. package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +7 -1
  119. package/node_modules/@diffci.com/core/src/repo/file-references.ts +70 -5
  120. package/node_modules/@diffci.com/core/src/repo/graph.ts +81 -20
  121. package/node_modules/@diffci.com/core/src/repo/impact.ts +56 -7
  122. package/node_modules/@diffci.com/core/src/repo/layout.ts +5 -1
  123. package/node_modules/@diffci.com/core/src/repo/runner-universe.ts +11 -1
  124. package/node_modules/@diffci.com/core/src/repo/script-universe.ts +1 -1
  125. package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +4 -1
  126. package/node_modules/@diffci.com/core/src/repo/types.ts +3 -1
  127. package/node_modules/@diffci.com/core/src/repo/workflow-test-steps.ts +3 -3
  128. package/node_modules/@diffci.com/core/src/research/baseline/matcher.ts +43 -13
  129. package/node_modules/@diffci.com/core/src/research/baseline/workflow-parser.ts +44 -2
  130. package/package.json +2 -2
@@ -182,32 +182,44 @@ function globPattern(glob) {
182
182
  const cut = body.lastIndexOf("/", firstWild < 0 ? body.length : firstWild);
183
183
  if (cut < 0 || body.includes("["))
184
184
  return undefined;
185
- let regex = "";
186
- const rest = body.slice(cut + 1);
187
- for (let i = 0; i < rest.length; i++) {
188
- const char = rest[i];
189
- if (rest.startsWith("**/", i)) {
190
- regex += "(?:.*/)?";
191
- i += 2;
192
- }
193
- else if (rest.startsWith("**", i)) {
194
- regex += ".*";
195
- i += 1;
196
- }
197
- else if (char === "*")
198
- regex += "[^/]*";
199
- else if (char === "?")
200
- regex += "[^/]";
201
- else if (char === "{") {
202
- const close = rest.indexOf("}", i);
203
- if (close < 0)
185
+ // Brace alternatives are globs too (`{index,*-icon}.ts`); escaping them as literals matched only the
186
+ // literal ones and dropped the rest. Nested braces are not translated and keep the load computed.
187
+ const translate = (text) => {
188
+ let regex = "";
189
+ for (let i = 0; i < text.length; i++) {
190
+ const char = text[i];
191
+ if (text.startsWith("**/", i)) {
192
+ regex += "(?:.*/)?";
193
+ i += 2;
194
+ }
195
+ else if (text.startsWith("**", i)) {
196
+ regex += ".*";
197
+ i += 1;
198
+ }
199
+ else if (char === "*")
200
+ regex += "[^/]*";
201
+ else if (char === "?")
202
+ regex += "[^/]";
203
+ else if (char === "{") {
204
+ const close = text.indexOf("}", i);
205
+ if (close < 0 || text.slice(i + 1, close).includes("{"))
206
+ return undefined;
207
+ const alternatives = text.slice(i + 1, close).split(",").map(translate);
208
+ if (alternatives.some((alternative) => alternative === undefined))
209
+ return undefined;
210
+ regex += `(?:${alternatives.join("|")})`;
211
+ i = close;
212
+ }
213
+ else if (char === "}")
204
214
  return undefined;
205
- regex += `(?:${rest.slice(i + 1, close).split(",").map(escapeRegex).join("|")})`;
206
- i = close;
215
+ else
216
+ regex += escapeRegex(char);
207
217
  }
208
- else
209
- regex += escapeRegex(char);
210
- }
218
+ return regex;
219
+ };
220
+ const regex = translate(body.slice(cut + 1));
221
+ if (regex === undefined)
222
+ return undefined;
211
223
  // Vite resolves a glob starting with "/" from its project root, not the filesystem root.
212
224
  return { base: body.slice(0, cut + 1), regex, negated, ...(body.startsWith("/") ? { viteRoot: true } : {}) };
213
225
  }
@@ -1050,8 +1062,13 @@ export async function buildDependencyGraph(options = {}) {
1050
1062
  adapterBlockers.push("Mixed Go/JavaScript repositories require explicit cross-language dependencies; full validation required");
1051
1063
  }
1052
1064
  const rustModeled = contributions.some((item) => item.id === "rust");
1053
- if (rustModeled && files.some(file => /\.(?:[cm]?[jt]sx?|vue|go|py|java|kt|cs|svelte|astro|c|h|cpp|cc|cxx)$/.test(file))) {
1054
- adapterBlockers.push("Mixed Rust/language repositories require explicit cross-language dependencies; full validation required");
1065
+ const rustScope = rustLanguageFileScope(contributions);
1066
+ const mixedRustFiles = rustModeled ? files.filter(file => /\.(?:[cm]?[jt]sx?|vue|go|py|java|kt|cs|svelte|astro|c|h|cpp|cc|cxx)$/.test(file)) : [];
1067
+ if (mixedRustFiles.length) {
1068
+ const reason = "Mixed Rust/language repositories require explicit cross-language dependencies; full validation required";
1069
+ adapterBlockers.push(reason);
1070
+ for (const file of mixedRustFiles)
1071
+ addScope(reason, rustScope(file));
1055
1072
  }
1056
1073
  const pythonModeled = contributions.some((item) => item.id === "python");
1057
1074
  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)) : [];
@@ -1061,7 +1078,7 @@ export async function buildDependencyGraph(options = {}) {
1061
1078
  // Files in a top-level dot-directory outside every package (agent skills, editor tooling) are confined
1062
1079
  // to that directory: no package's sources or tests can load them.
1063
1080
  for (const file of unmodeledLanguageFiles)
1064
- addScope(reason, packageScope(file) || (/^\.[^/]+\//.test(file) && !file.startsWith(".github/") ? file.slice(0, file.indexOf("/")) : ""));
1081
+ addScope(reason, packageScope(file) || (/^\.[^/]+\//.test(file) && !file.startsWith(".github/") ? file.slice(0, file.indexOf("/")) : "") || rustScope(file));
1065
1082
  }
1066
1083
  profile.adapters = contributions.map(({ id, version, blockers }) => ({ id, version, blockers }));
1067
1084
  // Rust test targets are not Go packages; other adapters keep their existing routing here.
@@ -1095,7 +1112,11 @@ export async function buildDependencyGraph(options = {}) {
1095
1112
  profile.testFilePaths = [...new Set([...profile.testFilePaths, ...adapterTests])].sort();
1096
1113
  if (profile.testUniverse) {
1097
1114
  profile.testUniverse.discoveredTestFiles = profile.testFilePaths.length;
1098
- profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || contributions.some((item) => item.id === "go" || item.id === "maven" || item.id === "python" || item.id === "rust")) && profile.testFilePaths.length === 0;
1115
+ const runners = { go: "go test", maven: "Maven", python: "pytest", rust: "cargo test" };
1116
+ const adapterRunners = contributions.flatMap((item) => runners[item.id] ? [runners[item.id]] : []);
1117
+ if (adapterRunners.length)
1118
+ profile.testUniverse.adapterRunners = adapterRunners;
1119
+ profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || adapterRunners.length > 0) && profile.testFilePaths.length === 0;
1099
1120
  }
1100
1121
  const entryPointPaths = new Set(profile.entryPoints.map((e) => e.path));
1101
1122
  const vueSources = scope || contributions.some((item) => item.id === "vue")
@@ -1347,6 +1368,21 @@ export async function buildDependencyGraph(options = {}) {
1347
1368
  }
1348
1369
  return undefined;
1349
1370
  }
1371
+ /** The JavaScript file a repository declaration file describes, when it exists and is not excluded. */
1372
+ function declarationImplementation(declarationRel) {
1373
+ const match = /^(.*)\.d\.([mc]?)ts$/.exec(declarationRel);
1374
+ if (!match)
1375
+ return undefined;
1376
+ const extensions = match[2] === "m" ? [".mjs"] : match[2] === "c" ? [".cjs"] : [".js", ".jsx"];
1377
+ for (const extension of extensions) {
1378
+ const candidate = match[1] + extension;
1379
+ if (isExcludedPath(candidate, options.excludeDirs ?? []) || candidate.split("/").includes("node_modules"))
1380
+ continue;
1381
+ if (internalSourcePaths.has(candidate) || existsSync(join(repoPath, candidate)))
1382
+ return candidate;
1383
+ }
1384
+ return undefined;
1385
+ }
1350
1386
  /** Parses an implementation file an import reaches outside the initial walk, rather than silently dropping
1351
1387
  * the edge or loading every TypeScript declaration library again; false, with a blocker, past the budget. */
1352
1388
  function followImplementation(absolute, rel) {
@@ -1446,7 +1482,11 @@ export async function buildDependencyGraph(options = {}) {
1446
1482
  // TypeScript may resolve a Vue import to a declaration shim. Preserve the actual SFC edge.
1447
1483
  if (resolvableSpecifier.endsWith(".vue")) {
1448
1484
  const compilerAliases = Object.entries(importerOptions.paths ?? {}).map(([pattern, substitutions]) => ({ pattern, substitutions }));
1449
- const candidate = findAssetCandidate(sf.fileName, resolvableSpecifier, compilerAliases.length ? compilerAliases : profile.pathAliases, importerOptions.baseUrl ?? dirname(sf.fileName));
1485
+ // `paths` resolve against `baseUrl`, or without one against the declaring tsconfig's directory
1486
+ // (TypeScript's pathsBasePath), never the importer's. Root aliases are repo-relative, as for assets.
1487
+ const candidate = compilerAliases.length
1488
+ ? findAssetCandidate(sf.fileName, resolvableSpecifier, compilerAliases, importerOptions.baseUrl ?? importerOptions.pathsBasePath ?? dirname(sf.fileName))
1489
+ : findAssetCandidate(sf.fileName, resolvableSpecifier, profile.pathAliases, profile.tsconfig?.baseUrl ? resolve(repoPath, profile.tsconfig.baseUrl) : repoPath);
1450
1490
  const target = candidate && toRelativeInternal(repoPath, candidate);
1451
1491
  if (target && internalSourcePaths.has(target)) {
1452
1492
  addEdge(importerRel, target, ref.kind, ref);
@@ -1542,6 +1582,12 @@ export async function buildDependencyGraph(options = {}) {
1542
1582
  continue;
1543
1583
  internalSourcePaths.add(targetRel);
1544
1584
  addEdge(importerRel, targetRel, ref.kind, ref);
1585
+ // A hand-written declaration beside its JavaScript (`foo.d.ts` next to `foo.js`) is what TypeScript
1586
+ // resolves to, but the runner loads the JavaScript. Without this edge a change to `foo.js` reached
1587
+ // no importer and selected nothing.
1588
+ const implementation = declarationImplementation(targetRel);
1589
+ if (implementation && followImplementation(join(repoPath, implementation), implementation))
1590
+ addEdge(importerRel, implementation, ref.kind, ref);
1545
1591
  recordReference("internal-source", importerRel, ref);
1546
1592
  continue;
1547
1593
  }
@@ -2246,6 +2292,31 @@ function confinedConfigScope(repoPath, configRel, config, directory, workspaceRo
2246
2292
  }
2247
2293
  return directory;
2248
2294
  }
2295
+ /** In a Cargo-only repository, the directory a helper script or native source is confined to: the
2296
+ * deepest member crate that contains it, or its top-level directory outside every crate of a virtual
2297
+ * workspace. Cargo can reach such a file only through code in that crate (a build script, which already
2298
+ * depends on every crate, or an `include!`, which falls back), and a change to the file itself keeps the
2299
+ * full suite, so only changes that reach the directory need full validation. "" (global) when another
2300
+ * adapter is active, when Rust code starts external programs that could run the file from anywhere, for
2301
+ * languages another engine could test (JavaScript, Go, Java and so on), for files that look like
2302
+ * Python tests, and inside a root package. */
2303
+ function rustLanguageFileScope(contributions) {
2304
+ const rust = contributions.length === 1 && contributions[0].id === "rust" ? contributions[0] : undefined;
2305
+ const crates = rust?.rustCrateDirectories;
2306
+ if (!rust || !crates || rust.rustRunsPrograms !== false)
2307
+ return () => "";
2308
+ return (file) => {
2309
+ if (!/\.(?:py|c|h|cc|cpp|cxx)$/.test(file))
2310
+ return "";
2311
+ const name = file.slice(file.lastIndexOf("/") + 1);
2312
+ if (/^(?:test_.*|.*_test|conftest)\.py$/.test(name))
2313
+ return "";
2314
+ const crate = crates.filter(directory => directory === "" || file.startsWith(`${directory}/`)).sort((a, b) => b.length - a.length)[0];
2315
+ if (crate !== undefined)
2316
+ return crate;
2317
+ return file.includes("/") ? file.slice(0, file.indexOf("/")) : "";
2318
+ };
2319
+ }
2249
2320
  /** Moves blockers confined to directories out of `adapterBlockers` and returns them scoped to those
2250
2321
  * directories (2026-11-08: Sentry's JavaScript SDK keeps 19 Nuxt, SvelteKit and Vue E2E applications whose
2251
2322
  * tsconfig extends generated `.nuxt/`/`.svelte-kit/` files; they made every change in its SDK packages fall