@lzehrung/codegraph 2.3.19 → 2.3.20

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/bin/cli.js CHANGED
@@ -17,8 +17,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
17
17
  var __esm = (fn, res) => function __init() {
18
18
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
19
19
  };
20
- var __commonJS = (cb, mod2) => function __require2() {
21
- return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
20
+ var __commonJS = (cb, mod) => function __require2() {
21
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
22
  };
23
23
  var __export = (target, all) => {
24
24
  for (var name in all)
@@ -32,13 +32,13 @@ var __copyProps = (to, from, except, desc) => {
32
32
  }
33
33
  return to;
34
34
  };
35
- var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
36
  // If the importer is in node compatibility mode or this is not an ESM
37
37
  // file that has been converted to a CommonJS file using a Babel-
38
38
  // compatible transform (i.e. "__esModule" has not been set), then set
39
39
  // "default" to the CommonJS "module.exports" for node compatibility.
40
- isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
41
- mod2
40
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
+ mod
42
42
  ));
43
43
 
44
44
  // dist/cli/compileCache.js
@@ -292,12 +292,12 @@ function isRelativeToRoot(normalizedRoot, normalizedFile) {
292
292
  const relativePath3 = path2.relative(comparableRoot, comparableFile);
293
293
  return !!relativePath3.length && !relativePath3.startsWith("..") && !path2.isAbsolute(relativePath3);
294
294
  }
295
- function isFilePathWithinRoot(projectRoot, filePath) {
295
+ function isFilePathWithinRoot(projectRoot, filePath, realpathMemo) {
296
296
  const normalizedRoot = normalizePath(resolveComparableProjectRoot(projectRoot));
297
297
  const normalizedFile = normalizePath(resolveFilePathFromRoot(normalizedRoot, filePath));
298
298
  if (isRelativeToRoot(normalizedRoot, normalizedFile))
299
299
  return true;
300
- return windowsAliasRelativePath(normalizedRoot, normalizedFile) !== null;
300
+ return windowsAliasRelativePath(normalizedRoot, normalizedFile, realpathMemo) !== null;
301
301
  }
302
302
  function assertFilePathWithinRoot(projectRoot, filePath, label = "File") {
303
303
  const normalizedRoot = normalizePath(resolveComparableProjectRoot(projectRoot));
@@ -318,7 +318,7 @@ function resolveFilePathWithinRoot(projectRoot, filePath, label) {
318
318
  };
319
319
  }
320
320
  }
321
- function toProjectRelativePath(projectRoot, filePath) {
321
+ function toProjectRelativePath(projectRoot, filePath, realpathMemo) {
322
322
  const normalizedRoot = normalizePath(resolveComparableProjectRoot(projectRoot));
323
323
  const normalizedFile = normalizePath(resolveFilePathFromRoot(normalizedRoot, filePath));
324
324
  if (isRelativeToRoot(normalizedRoot, normalizedFile)) {
@@ -332,21 +332,37 @@ function toProjectRelativePath(projectRoot, filePath) {
332
332
  }
333
333
  return normalizePath(path2.relative(normalizedRoot, normalizedFile));
334
334
  }
335
- return windowsAliasRelativePath(normalizedRoot, normalizedFile);
335
+ return windowsAliasRelativePath(normalizedRoot, normalizedFile, realpathMemo);
336
336
  }
337
- function windowsAliasRelativePath(normalizedRoot, normalizedFile) {
337
+ function resolveWindowsRealpath(filePath, realpathMemo) {
338
+ if (!realpathMemo)
339
+ return fs2.realpathSync.native(filePath);
340
+ const key = fileIdentityKey(filePath);
341
+ const cached2 = realpathMemo.get(key);
342
+ if (cached2 !== void 0)
343
+ return cached2;
344
+ const resolved = fs2.realpathSync.native(filePath);
345
+ realpathMemo.set(key, resolved);
346
+ return resolved;
347
+ }
348
+ function windowsAliasRelativePath(normalizedRoot, normalizedFile, realpathMemo) {
338
349
  if (process.platform !== "win32")
339
350
  return null;
340
351
  if (!isWindowsQualifiedAbsolutePath(normalizedRoot) || !isWindowsQualifiedAbsolutePath(normalizedFile)) {
341
352
  return null;
342
353
  }
343
354
  try {
344
- const realRoot = fs2.realpathSync.native(normalizedRoot);
345
- const realFile = fs2.realpathSync.native(normalizedFile);
355
+ const realRoot = resolveWindowsRealpath(normalizedRoot, realpathMemo);
356
+ const realFile = resolveWindowsRealpath(normalizedFile, realpathMemo);
346
357
  const directRelativePath = path2.win32.relative(realRoot, realFile);
347
358
  if (!directRelativePath.startsWith("..") && !path2.win32.isAbsolute(directRelativePath)) {
348
359
  return normalizePath(directRelativePath);
349
360
  }
361
+ const rootHasNoReparsePoint = fileIdentityKey(realRoot) === fileIdentityKey(normalizedRoot);
362
+ const fileHasNoReparsePoint = fileIdentityKey(realFile) === fileIdentityKey(normalizedFile);
363
+ if (rootHasNoReparsePoint && fileHasNoReparsePoint) {
364
+ return null;
365
+ }
350
366
  const rootStat = fs2.statSync(realRoot, { bigint: true });
351
367
  let ancestorPath = realFile;
352
368
  while (true) {
@@ -14224,6 +14240,7 @@ __export(projectFiles_exports, {
14224
14240
  DEFAULT_PROJECT_MANIFESTS: () => DEFAULT_PROJECT_MANIFESTS,
14225
14241
  DEFAULT_PROJECT_PATTERNS: () => DEFAULT_PROJECT_PATTERNS,
14226
14242
  createDiscoveredFileMatcher: () => createDiscoveredFileMatcher,
14243
+ createGitIgnoreSourceOwnershipLookup: () => createGitIgnoreSourceOwnershipLookup,
14227
14244
  discoverProjectFiles: () => discoverProjectFiles,
14228
14245
  discoverProjectFilesWithGitCandidates: () => discoverProjectFilesWithGitCandidates,
14229
14246
  filterRealPathsWithinRoot: () => filterRealPathsWithinRoot,
@@ -14231,6 +14248,7 @@ __export(projectFiles_exports, {
14231
14248
  listProjectFiles: () => listProjectFiles,
14232
14249
  listProjectFilesWithGitCandidates: () => listProjectFilesWithGitCandidates,
14233
14250
  matchesDiscoveryGlob: () => matchesDiscoveryGlob,
14251
+ owningGitIgnoreSourceRoot: () => owningGitIgnoreSourceRoot,
14234
14252
  translateGlobRootIgnoreGlobsForScanRoot: () => translateGlobRootIgnoreGlobsForScanRoot
14235
14253
  });
14236
14254
  import fs6 from "node:fs";
@@ -14516,11 +14534,11 @@ function collectCandidateAncestorDirectories(root, files) {
14516
14534
  }
14517
14535
  return directories;
14518
14536
  }
14519
- function owningGitIgnoreSourceRoot(file2, roots) {
14537
+ function owningGitIgnoreSourceRoot(file2, roots, realpathMemo) {
14520
14538
  const normalized = normalizePath(file2);
14521
14539
  let owning;
14522
14540
  for (const root of roots) {
14523
- if (!isFilePathWithinRoot(root.path, normalized) && !isFilePathWithinRoot(root.repositoryRoot, normalized)) {
14541
+ if (!isFilePathWithinRoot(root.path, normalized, realpathMemo) && !isFilePathWithinRoot(root.repositoryRoot, normalized, realpathMemo)) {
14524
14542
  continue;
14525
14543
  }
14526
14544
  if (!owning || root.repositoryRoot.length > owning.repositoryRoot.length) {
@@ -14529,6 +14547,19 @@ function owningGitIgnoreSourceRoot(file2, roots) {
14529
14547
  }
14530
14548
  return owning;
14531
14549
  }
14550
+ function createGitIgnoreSourceOwnershipLookup(roots, realpathMemo) {
14551
+ const ownershipByDirectory = /* @__PURE__ */ new Map();
14552
+ return (file2) => {
14553
+ const directory = normalizePath(path9.dirname(file2));
14554
+ const key = fileIdentityKey(directory);
14555
+ if (ownershipByDirectory.has(key)) {
14556
+ return ownershipByDirectory.get(key);
14557
+ }
14558
+ const owning = owningGitIgnoreSourceRoot(directory, roots, realpathMemo);
14559
+ ownershipByDirectory.set(key, owning);
14560
+ return owning;
14561
+ };
14562
+ }
14532
14563
  async function gitignoreFileIfPresent(directory) {
14533
14564
  const file2 = normalizePath(path9.join(directory, ".gitignore"));
14534
14565
  try {
@@ -14554,13 +14585,15 @@ async function findGitIgnoreSources(sourceRoots, candidateFiles) {
14554
14585
  for (const { path: sourceRoot, repositoryRoot } of roots) {
14555
14586
  addDirectory(sourceRoot, repositoryRoot);
14556
14587
  }
14588
+ const realpathMemo = /* @__PURE__ */ new Map();
14589
+ const owningOf = createGitIgnoreSourceOwnershipLookup(roots, realpathMemo);
14557
14590
  for (const file2 of candidateFiles) {
14558
- const owning = owningGitIgnoreSourceRoot(file2, roots);
14591
+ const owning = owningOf(file2);
14559
14592
  if (!owning)
14560
14593
  continue;
14561
14594
  let dir = normalizePath(path9.dirname(file2));
14562
14595
  const stopKey = fileIdentityKey(owning.repositoryRoot);
14563
- for (; ; ) {
14596
+ while (true) {
14564
14597
  const dirKey = fileIdentityKey(dir);
14565
14598
  const walkKey = `${dirKey}\0${stopKey}`;
14566
14599
  if (walkedDirectoryKeys.has(walkKey))
@@ -14570,7 +14603,7 @@ async function findGitIgnoreSources(sourceRoots, candidateFiles) {
14570
14603
  if (dirKey === stopKey)
14571
14604
  break;
14572
14605
  const parent = normalizePath(path9.dirname(dir));
14573
- if (parent === dir || !isFilePathWithinRoot(owning.path, parent) && !isFilePathWithinRoot(owning.repositoryRoot, parent)) {
14606
+ if (parent === dir || !isFilePathWithinRoot(owning.path, parent, realpathMemo) && !isFilePathWithinRoot(owning.repositoryRoot, parent, realpathMemo)) {
14574
14607
  break;
14575
14608
  }
14576
14609
  dir = parent;
@@ -14690,7 +14723,9 @@ async function listProjectFilesInternal(projectRoot, patterns = DEFAULT_PROJECT_
14690
14723
  try {
14691
14724
  const useGitignore = options?.useGitignore ?? true;
14692
14725
  const realRoot = await fsp5.realpath(root);
14693
- const attemptedGitCandidates = useGitignore && options?.gitignoreRoot === void 0 && normalizePath(realRoot) === normalizePath(root);
14726
+ const scanRootKey = fileIdentityKey(root);
14727
+ const gitignoreRootMatchesScanRoot = options?.gitignoreRoot === void 0 || fileIdentityKey(options.gitignoreRoot) === scanRootKey;
14728
+ const attemptedGitCandidates = useGitignore && gitignoreRootMatchesScanRoot && fileIdentityKey(realRoot) === scanRootKey;
14694
14729
  const gitDiscoveryCallbacks = {
14695
14730
  ...options?.onDiscoveryProgress ? { onDiscoveryProgress: options.onDiscoveryProgress } : {},
14696
14731
  ...options?.onDiscoveryTiming ? { onDiscoveryTiming: options.onDiscoveryTiming } : {}
@@ -24687,9 +24722,9 @@ function collectModuleSpecifiersFromSource(support, source, opts) {
24687
24722
  if (mFrom) {
24688
24723
  const dots = mFrom[1] ?? "";
24689
24724
  const name = mFrom[2] ?? "";
24690
- const mod2 = `${dots}${name}`;
24691
- if (mod2)
24692
- out.push({ spec: mod2 });
24725
+ const mod = `${dots}${name}`;
24726
+ if (mod)
24727
+ out.push({ spec: mod });
24693
24728
  }
24694
24729
  }
24695
24730
  } catch {
@@ -27866,8 +27901,8 @@ function resolvePythonNamespaceMember(resolved, imported) {
27866
27901
  return void 0;
27867
27902
  }
27868
27903
  async function pushStarImport(context, moduleSpec, moduleLevel) {
27869
- const { relDots, mod: mod2 } = splitRelativeModuleSpec(moduleSpec);
27870
- const resolved = await resolvePythonModule(context.projectRoot, context.file, mod2, relDots);
27904
+ const { relDots, mod } = splitRelativeModuleSpec(moduleSpec);
27905
+ const resolved = await resolvePythonModule(context.projectRoot, context.file, mod, relDots);
27871
27906
  context.pushBinding({
27872
27907
  kind: "star",
27873
27908
  from: moduleSpec,
@@ -27877,8 +27912,8 @@ async function pushStarImport(context, moduleSpec, moduleLevel) {
27877
27912
  });
27878
27913
  }
27879
27914
  async function pushNamedImport(context, moduleSpec, imported, local, moduleLevel) {
27880
- const { relDots, mod: mod2 } = splitRelativeModuleSpec(moduleSpec);
27881
- const resolved = await resolvePythonModule(context.projectRoot, context.file, mod2, relDots);
27915
+ const { relDots, mod } = splitRelativeModuleSpec(moduleSpec);
27916
+ const resolved = await resolvePythonModule(context.projectRoot, context.file, mod, relDots);
27882
27917
  const namespaceResolved = resolvePythonNamespaceMember(resolved, imported);
27883
27918
  if (namespaceResolved) {
27884
27919
  context.pushBinding({
@@ -27916,12 +27951,12 @@ async function collectPythonImportsFromSource(context) {
27916
27951
  const pySrc = stripPythonCommentsAndStrings(context.source);
27917
27952
  const fromLinePattern = /^[\t ]*from\s+([^\s]+)\s+import\s+([^\n#]+)/gm;
27918
27953
  for (const match of pySrc.matchAll(fromLinePattern)) {
27919
- const mod2 = match[1].trim();
27954
+ const mod = match[1].trim();
27920
27955
  const moduleLevel = !/^[\t ]/.test(match[0]);
27921
27956
  const items = match[2].split(",").map((item) => item.trim());
27922
27957
  for (const item of items) {
27923
27958
  if (item === "*") {
27924
- await pushStarImport(context, mod2, moduleLevel);
27959
+ await pushStarImport(context, mod, moduleLevel);
27925
27960
  continue;
27926
27961
  }
27927
27962
  const aliasMatch = item.match(PYTHON_NAMED_IMPORT_PATTERN);
@@ -27929,7 +27964,7 @@ async function collectPythonImportsFromSource(context) {
27929
27964
  continue;
27930
27965
  const imported = aliasMatch[1];
27931
27966
  const local = aliasMatch[2] ?? imported;
27932
- await pushNamedImport(context, mod2, imported, local, moduleLevel);
27967
+ await pushNamedImport(context, mod, imported, local, moduleLevel);
27933
27968
  }
27934
27969
  }
27935
27970
  const importPattern = PYTHON_MODULE_IMPORT_PATTERN;
@@ -28220,8 +28255,8 @@ function isSymbolHandleExported(exports, handle) {
28220
28255
  return exports.some((entry) => entry.type === "local" && symbolHandleFromLocal(entry.target.file, entry.target) === handle);
28221
28256
  }
28222
28257
  function isProjectSymbolExported(index, file2, symbolDef) {
28223
- const mod2 = index.byFile.get(fileIdentityKey(file2));
28224
- return mod2 ? isLocalSymbolExported(mod2.exports, symbolDef) : false;
28258
+ const mod = index.byFile.get(fileIdentityKey(file2));
28259
+ return mod ? isLocalSymbolExported(mod.exports, symbolDef) : false;
28225
28260
  }
28226
28261
  var DESCENDANT_DECLARATION_CONTAINER_TYPES;
28227
28262
  var init_declarations = __esm({
@@ -29498,14 +29533,14 @@ function expandStarImports(modules, opts) {
29498
29533
  }
29499
29534
  return null;
29500
29535
  };
29501
- for (const mod2 of modules.values()) {
29536
+ for (const mod of modules.values()) {
29502
29537
  const expandedImportKeys = /* @__PURE__ */ new Set();
29503
- for (const existing of mod2.imports) {
29538
+ for (const existing of mod.imports) {
29504
29539
  const key = expandedImportKey(existing);
29505
29540
  if (key)
29506
29541
  expandedImportKeys.add(key);
29507
29542
  }
29508
- for (const imp of [...mod2.imports]) {
29543
+ for (const imp of [...mod.imports]) {
29509
29544
  if (imp.kind !== "star" || typeof imp.resolved !== "string")
29510
29545
  continue;
29511
29546
  const target = modules.get(fileIdentityKey(imp.resolved));
@@ -29537,7 +29572,7 @@ function expandStarImports(modules, opts) {
29537
29572
  if (!expandedImportKeyValue || expandedImportKeys.has(expandedImportKeyValue))
29538
29573
  continue;
29539
29574
  expandedImportKeys.add(expandedImportKeyValue);
29540
- mod2.imports.push(expandedImport);
29575
+ mod.imports.push(expandedImport);
29541
29576
  }
29542
29577
  }
29543
29578
  }
@@ -32363,15 +32398,15 @@ function readSqliteSchemaVersion(db, key) {
32363
32398
  return { status: "missing" };
32364
32399
  if (typeof row.value !== "string")
32365
32400
  return { status: "invalid" };
32366
- const version3 = Number(row.value);
32367
- if (!Number.isInteger(version3) || version3 < 0)
32401
+ const version2 = Number(row.value);
32402
+ if (!Number.isInteger(version2) || version2 < 0)
32368
32403
  return { status: "invalid" };
32369
- return { status: "ok", version: version3 };
32404
+ return { status: "ok", version: version2 };
32370
32405
  }
32371
- function writeSqliteSchemaVersion(db, key, version3) {
32406
+ function writeSqliteSchemaVersion(db, key, version2) {
32372
32407
  db.prepare(`INSERT INTO cache_schema_metadata (key, value)
32373
32408
  VALUES (?, ?)
32374
- ON CONFLICT(key) DO UPDATE SET value = excluded.value`).run(key, String(version3));
32409
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value`).run(key, String(version2));
32375
32410
  }
32376
32411
  function ensureSqliteVersionedTableSchema(args) {
32377
32412
  ensureSqliteSchemaMetadataTable(args.db);
@@ -32952,6 +32987,9 @@ import path37 from "node:path";
32952
32987
  function memoryCacheKey(projectRoot, file2) {
32953
32988
  return `${normalizePath(projectRoot)}::${file2}`;
32954
32989
  }
32990
+ function clearMemoryCache() {
32991
+ memoryCache.clear();
32992
+ }
32955
32993
  function clearMemoryCacheForProject(projectRoot) {
32956
32994
  const prefix = `${normalizePath(projectRoot)}::`;
32957
32995
  for (const key of memoryCache.keys()) {
@@ -33221,8 +33259,8 @@ async function buildBloomFilterForFile(file2, opts) {
33221
33259
  function isModuleIndex(value) {
33222
33260
  if (!value || typeof value !== "object")
33223
33261
  return false;
33224
- const mod2 = value;
33225
- return typeof mod2.file === "string" && Array.isArray(mod2.exports) && Array.isArray(mod2.imports) && Array.isArray(mod2.locals);
33262
+ const mod = value;
33263
+ return typeof mod.file === "string" && Array.isArray(mod.exports) && Array.isArray(mod.imports) && Array.isArray(mod.locals);
33226
33264
  }
33227
33265
  function transformPersistedExportFromModule(projectRoot, entry, toRelative) {
33228
33266
  if (toRelative) {
@@ -33419,6 +33457,9 @@ function writeModulesToCache(projectRoot, writes, opts) {
33419
33457
  }
33420
33458
  }
33421
33459
  }
33460
+ function writeToCache(projectRoot, file2, sig, mod, opts) {
33461
+ writeModulesToCache(projectRoot, [{ file: file2, sig, mod }], opts);
33462
+ }
33422
33463
  var PARSED_CACHE_VERSION, MODULE_CACHE_SCHEMA_VERSION, MODULE_CACHE_TABLE, MODULE_CACHE_SCHEMA_VERSION_KEY, MODULE_CACHE_COLUMNS, MAX_MEMORY_CACHE_ENTRIES, memoryCache, cachedExecutionFingerprint, cachedExecutionHash, diskModuleCaches, warnedMissingNodeSqlite;
33423
33464
  var init_module_cache = __esm({
33424
33465
  "dist/indexer/build-cache/module-cache.js"() {
@@ -37329,10 +37370,10 @@ var init_regexes = __esm({
37329
37370
  duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
37330
37371
  extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
37331
37372
  guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
37332
- uuid = (version3) => {
37333
- if (!version3)
37373
+ uuid = (version2) => {
37374
+ if (!version2)
37334
37375
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
37335
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
37376
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
37336
37377
  };
37337
37378
  uuid4 = /* @__PURE__ */ uuid(4);
37338
37379
  uuid6 = /* @__PURE__ */ uuid(6);
@@ -50882,10 +50923,10 @@ function fromJSONSchema(schema, params) {
50882
50923
  } catch {
50883
50924
  throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
50884
50925
  }
50885
- const version3 = detectVersion(normalized, params?.defaultTarget);
50926
+ const version2 = detectVersion(normalized, params?.defaultTarget);
50886
50927
  const defs = normalized.$defs || normalized.definitions || {};
50887
50928
  const ctx = {
50888
- version: version3,
50929
+ version: version2,
50889
50930
  defs,
50890
50931
  refs: /* @__PURE__ */ new Map(),
50891
50932
  processing: /* @__PURE__ */ new Set(),
@@ -52474,21 +52515,21 @@ async function buildSymbolGraph(index, opts) {
52474
52515
  addEdge(aliasId, targetId, label);
52475
52516
  return true;
52476
52517
  };
52477
- for (const mod2 of index.byFile.values()) {
52478
- const displayFile = normalizePath(mod2.file);
52518
+ for (const mod of index.byFile.values()) {
52519
+ const displayFile = normalizePath(mod.file);
52479
52520
  if (!shouldIncludeFile(displayFile))
52480
52521
  continue;
52481
- for (const def of mod2.locals) {
52522
+ for (const def of mod.locals) {
52482
52523
  const node = nodeForDef(def);
52483
52524
  if (!nodes.has(node.id))
52484
52525
  nodes.set(node.id, node);
52485
52526
  }
52486
52527
  }
52487
- for (const mod2 of index.byFile.values()) {
52488
- const displayFile = normalizePath(mod2.file);
52528
+ for (const mod of index.byFile.values()) {
52529
+ const displayFile = normalizePath(mod.file);
52489
52530
  if (!shouldIncludeFile(displayFile))
52490
52531
  continue;
52491
- for (const imp of mod2.imports) {
52532
+ for (const imp of mod.imports) {
52492
52533
  if (!imp)
52493
52534
  continue;
52494
52535
  const targetFile = typeof imp.resolved === "string" ? normalizePath(imp.resolved) : void 0;
@@ -52983,12 +53024,12 @@ async function tryLoadProjectSnapshotModules(projectRoot, opts, fileSignatures,
52983
53024
  if (!candidates)
52984
53025
  return /* @__PURE__ */ new Map();
52985
53026
  const modules = /* @__PURE__ */ new Map();
52986
- for (const [moduleKey, mod2] of candidates) {
53027
+ for (const [moduleKey, mod] of candidates) {
52987
53028
  const signature = normalizedCurrentSignatures.get(moduleKey);
52988
53029
  const snapshotSignature = normalizedFileSignatures.get(moduleKey);
52989
53030
  if (!signature || !snapshotSignature || !snapshotSignatureMatches(snapshotSignature, signature))
52990
53031
  continue;
52991
- modules.set(moduleKey, mod2);
53032
+ modules.set(moduleKey, mod);
52992
53033
  }
52993
53034
  return modules;
52994
53035
  } catch (error51) {
@@ -53079,21 +53120,21 @@ function createPersistedBloomFilters(bloomFilters, fileSignatures, projectRoot)
53079
53120
  }
53080
53121
  };
53081
53122
  }
53082
- function isSupportedProjectSnapshotVersion(version3) {
53083
- return version3 === PROJECT_SNAPSHOT_VERSION || version3 === LEGACY_EMBEDDED_MODULE_SNAPSHOT_VERSION;
53123
+ function isSupportedProjectSnapshotVersion(version2) {
53124
+ return version2 === PROJECT_SNAPSHOT_VERSION || version2 === LEGACY_EMBEDDED_MODULE_SNAPSHOT_VERSION;
53084
53125
  }
53085
- function snapshotHydratesModulesFromDisk(version3) {
53086
- return version3 === PROJECT_SNAPSHOT_VERSION;
53126
+ function snapshotHydratesModulesFromDisk(version2) {
53127
+ return version2 === PROJECT_SNAPSHOT_VERSION;
53087
53128
  }
53088
- function mutableModuleIndex(mod2) {
53089
- if (!Object.isFrozen(mod2) && !Object.isFrozen(mod2.imports) && !Object.isFrozen(mod2.exports) && !Object.isFrozen(mod2.locals)) {
53090
- return mod2;
53129
+ function mutableModuleIndex(mod) {
53130
+ if (!Object.isFrozen(mod) && !Object.isFrozen(mod.imports) && !Object.isFrozen(mod.exports) && !Object.isFrozen(mod.locals)) {
53131
+ return mod;
53091
53132
  }
53092
53133
  return {
53093
- file: mod2.file,
53094
- exports: [...mod2.exports],
53095
- imports: [...mod2.imports],
53096
- locals: [...mod2.locals]
53134
+ file: mod.file,
53135
+ exports: [...mod.exports],
53136
+ imports: [...mod.imports],
53137
+ locals: [...mod.locals]
53097
53138
  };
53098
53139
  }
53099
53140
  function modulesForThinSnapshot(index, projectRoot, opts) {
@@ -53110,8 +53151,8 @@ function collectSnapshotModules(projectRoot, opts, payload, snapshotPath, identi
53110
53151
  return cached2.modules;
53111
53152
  }
53112
53153
  const modules = /* @__PURE__ */ new Map();
53113
- for (const mod2 of payload.modules) {
53114
- modules.set(fileIdentityKey(mod2.file), mod2);
53154
+ for (const mod of payload.modules) {
53155
+ modules.set(fileIdentityKey(mod.file), mod);
53115
53156
  }
53116
53157
  if (snapshotHydratesModulesFromDisk(payload.version)) {
53117
53158
  const cachedModules = loadAllCachedModules(projectRoot, opts);
@@ -53124,16 +53165,16 @@ function collectSnapshotModules(projectRoot, opts, payload, snapshotPath, identi
53124
53165
  modules.set(key, row.mod);
53125
53166
  }
53126
53167
  }
53127
- for (const [key, mod2] of modules) {
53128
- if (!mod2.imports.some((binding) => binding.kind === "star"))
53168
+ for (const [key, mod] of modules) {
53169
+ if (!mod.imports.some((binding) => binding.kind === "star"))
53129
53170
  continue;
53130
- modules.set(key, mutableModuleIndex(mod2));
53171
+ modules.set(key, mutableModuleIndex(mod));
53131
53172
  }
53132
53173
  expandStarImports(modules, opts);
53133
- for (const [key, mod2] of modules) {
53134
- if (Object.isFrozen(mod2))
53174
+ for (const [key, mod] of modules) {
53175
+ if (Object.isFrozen(mod))
53135
53176
  continue;
53136
- modules.set(key, freezeSnapshotPayload(mod2));
53177
+ modules.set(key, freezeSnapshotPayload(mod));
53137
53178
  }
53138
53179
  }
53139
53180
  const entry = { identity, root: projectRoot, modules };
@@ -53779,6 +53820,55 @@ var init_project_snapshot = __esm({
53779
53820
  });
53780
53821
 
53781
53822
  // dist/indexer/build-cache.js
53823
+ var build_cache_exports = {};
53824
+ __export(build_cache_exports, {
53825
+ BLOOM_FILTER_SNAPSHOT_FILENAME: () => BLOOM_FILTER_SNAPSHOT_FILENAME,
53826
+ BLOOM_FILTER_SNAPSHOT_VERSION: () => BLOOM_FILTER_SNAPSHOT_VERSION,
53827
+ MANIFEST_VERSION: () => MANIFEST_VERSION,
53828
+ PROJECT_SNAPSHOT_VERSION: () => PROJECT_SNAPSHOT_VERSION,
53829
+ buildBloomFilterForFile: () => buildBloomFilterForFile,
53830
+ cacheRoot: () => cacheRoot,
53831
+ cacheSignatureForFile: () => cacheSignatureForFile,
53832
+ clearMemoryCache: () => clearMemoryCache,
53833
+ closeDiskCacheDatabase: () => closeDiskCacheDatabase,
53834
+ collectWorkspaceManifestDependencyEdges: () => collectWorkspaceManifestDependencyEdges,
53835
+ computeConfigHash: () => computeConfigHash,
53836
+ createFallbackImportExtractionHandler: () => createFallbackImportExtractionHandler,
53837
+ createProjectSnapshotIdentity: () => createProjectSnapshotIdentity,
53838
+ diffBuildOptions: () => diffBuildOptions,
53839
+ diskModuleCacheExists: () => diskModuleCacheExists,
53840
+ fileSignature: () => fileSignature,
53841
+ fileSignatureFromSource: () => fileSignatureFromSource,
53842
+ graphOptionsEqual: () => graphOptionsEqual,
53843
+ initCacheReport: () => initCacheReport,
53844
+ initFileReport: () => initFileReport,
53845
+ initManifestReport: () => initManifestReport,
53846
+ loadManifest: () => loadManifest,
53847
+ normalizeGraphOptions: () => normalizeGraphOptions,
53848
+ normalizeIndexedFileInputs: () => normalizeIndexedFileInputs,
53849
+ normalizeIndexedFileInputsWithinRoot: () => normalizeIndexedFileInputsWithinRoot,
53850
+ normalizeLanguageExtensions: () => normalizeLanguageExtensions,
53851
+ projectSnapshotFilesSignature: () => projectSnapshotFilesSignature,
53852
+ pruneDiskModuleCache: () => pruneDiskModuleCache,
53853
+ recordConfigHashResult: () => recordConfigHashResult,
53854
+ recordFileFailure: () => recordFileFailure,
53855
+ resolveCacheLocation: () => resolveCacheLocation,
53856
+ sanitizeManifestEntriesForRoot: () => sanitizeManifestEntriesForRoot,
53857
+ sanitizeManifestTransientFilesForRoot: () => sanitizeManifestTransientFilesForRoot,
53858
+ summarizeBuildOptions: () => summarizeBuildOptions,
53859
+ transformManifestEntries: () => transformManifestEntries,
53860
+ tryLoadDetailedSymbolGraphSnapshot: () => tryLoadDetailedSymbolGraphSnapshot,
53861
+ tryLoadFromCache: () => tryLoadFromCache,
53862
+ tryLoadPersistedBloomFilters: () => tryLoadPersistedBloomFilters,
53863
+ tryLoadProjectIndexSnapshot: () => tryLoadProjectIndexSnapshot,
53864
+ tryLoadProjectSnapshotModules: () => tryLoadProjectSnapshotModules,
53865
+ verifyManifestEntries: () => verifyManifestEntries,
53866
+ writeDetailedSymbolGraphSnapshot: () => writeDetailedSymbolGraphSnapshot,
53867
+ writeManifest: () => writeManifest2,
53868
+ writeModulesToCache: () => writeModulesToCache,
53869
+ writeProjectIndexSnapshot: () => writeProjectIndexSnapshot,
53870
+ writeToCache: () => writeToCache
53871
+ });
53782
53872
  var init_build_cache = __esm({
53783
53873
  "dist/indexer/build-cache.js"() {
53784
53874
  "use strict";
@@ -53988,13 +54078,20 @@ var init_parsed_cache = __esm({
53988
54078
  import { performance as performance4 } from "node:perf_hooks";
53989
54079
  async function finalizeProjectIndex(args) {
53990
54080
  const discoveryTimings = args.opts?.report ? args.opts.report.timings ??= {} : void 0;
53991
- const metadataDiscoveryStart = args.projectFiles === void 0 ? performance4.now() : void 0;
53992
- const projectFiles = await (args.projectFiles ?? discoverProjectFilesWithGitCandidates(args.projectRoot, {
53993
- ...args.opts?.logLevel ? { logLevel: args.opts.logLevel } : {},
53994
- ...args.knownGitCandidates !== void 0 ? { knownGitCandidates: args.knownGitCandidates } : {}
53995
- }));
53996
- if (metadataDiscoveryStart !== void 0 && discoveryTimings) {
53997
- discoveryTimings.metadataDiscoveryMs = Math.round(performance4.now() - metadataDiscoveryStart);
54081
+ let projectFiles;
54082
+ if (args.projectFiles !== void 0) {
54083
+ projectFiles = await args.projectFiles;
54084
+ } else {
54085
+ const metadataDiscoveryStart = performance4.now();
54086
+ projectFiles = await discoverProjectFilesWithGitCandidates(args.projectRoot, {
54087
+ ...args.opts?.logLevel ? { logLevel: args.opts.logLevel } : {},
54088
+ ...args.knownGitCandidates !== void 0 ? { knownGitCandidates: args.knownGitCandidates } : {}
54089
+ });
54090
+ if (discoveryTimings) {
54091
+ const metadataDiscoveryMs = Math.round(performance4.now() - metadataDiscoveryStart);
54092
+ discoveryTimings.metadataDiscoveryMs = metadataDiscoveryMs;
54093
+ (discoveryTimings.steps ??= []).push({ name: "metadata-discovery", ms: metadataDiscoveryMs });
54094
+ }
53998
54095
  }
53999
54096
  if (args.timings)
54000
54097
  args.timings.totalMs = Math.round(performance4.now() - args.totalStart);
@@ -54046,15 +54143,25 @@ function toManifestFileEntry(entry) {
54046
54143
  edges: entry.edges
54047
54144
  };
54048
54145
  }
54146
+ function recordManifestTimingStep(timings, name, startedAt) {
54147
+ if (!timings)
54148
+ return;
54149
+ (timings.steps ??= []).push({ name, ms: Math.round(performance5.now() - startedAt) });
54150
+ }
54049
54151
  async function writeIndexManifestSnapshot(args) {
54050
54152
  const files = args.files instanceof Map ? Object.fromEntries(args.files) : args.files;
54051
54153
  if (!Object.keys(files).length && !args.allowEmpty)
54052
54154
  return;
54053
54155
  const writeManifestStart = performance5.now();
54156
+ const gitHeadStartedAt = performance5.now();
54054
54157
  const lastCommit = await getGitHead(args.projectRoot);
54055
- const configHashResult = await computeConfigHash(args.projectRoot, args.opts?.logLevel);
54158
+ recordManifestTimingStep(args.timings, "git-head", gitHeadStartedAt);
54159
+ const configHashStartedAt = performance5.now();
54160
+ const configHashResult = args.configHash ?? await computeConfigHash(args.projectRoot, args.opts?.logLevel);
54161
+ recordManifestTimingStep(args.timings, "config-hash", configHashStartedAt);
54056
54162
  const projectRootMtimeMs = args.symlinkDirectories !== void 0 ? (await fsp24.stat(args.projectRoot)).mtimeMs : void 0;
54057
54163
  const configHash = recordConfigHashResult(args.manifestReport, configHashResult, args.opts?.logLevel);
54164
+ const transformStartedAt = performance5.now();
54058
54165
  const manifestData = {
54059
54166
  version: MANIFEST_VERSION,
54060
54167
  projectRoot: path45.resolve(args.projectRoot).replace(/\\/g, "/"),
@@ -54071,9 +54178,15 @@ async function writeIndexManifestSnapshot(args) {
54071
54178
  ...projectRootMtimeMs !== void 0 ? { symlinkDirectoriesRootMtimeMs: projectRootMtimeMs } : {}
54072
54179
  } : {}
54073
54180
  };
54181
+ recordManifestTimingStep(args.timings, "manifest-transform", transformStartedAt);
54182
+ const manifestWriteStartedAt = performance5.now();
54074
54183
  const manifestWritten = await writeManifest2(args.projectRoot, args.opts, manifestData);
54075
- if (manifestWritten)
54184
+ recordManifestTimingStep(args.timings, "manifest-write", manifestWriteStartedAt);
54185
+ if (manifestWritten) {
54186
+ const cachePruneStartedAt = performance5.now();
54076
54187
  pruneDiskModuleCache(args.projectRoot, Object.keys(files), args.opts);
54188
+ recordManifestTimingStep(args.timings, "cache-prune", cachePruneStartedAt);
54189
+ }
54077
54190
  if (args.timings) {
54078
54191
  args.timings.writeManifestMs = Math.round(performance5.now() - writeManifestStart);
54079
54192
  }
@@ -54087,1367 +54200,6 @@ var init_build_manifest = __esm({
54087
54200
  }
54088
54201
  });
54089
54202
 
54090
- // node_modules/piscina/package.json
54091
- var require_package = __commonJS({
54092
- "node_modules/piscina/package.json"(exports, module2) {
54093
- module2.exports = {
54094
- name: "piscina",
54095
- version: "4.9.3",
54096
- description: "A fast, efficient Node.js Worker Thread Pool implementation",
54097
- main: "./dist/main.js",
54098
- types: "./dist/index.d.ts",
54099
- exports: {
54100
- types: "./dist/index.d.ts",
54101
- import: "./dist/esm-wrapper.mjs",
54102
- require: "./dist/main.js"
54103
- },
54104
- scripts: {
54105
- build: "tsc && gen-esm-wrapper . dist/esm-wrapper.mjs",
54106
- lint: 'standardx "**/*.{ts,mjs,js,cjs}" | snazzy',
54107
- test: "c8 tap",
54108
- "test:ci": "npm run lint && npm run build && npm run test:coverage",
54109
- "test:coverage": "c8 --reporter=lcov tap --cov",
54110
- prepack: "npm run build",
54111
- bench: "npm run bench:taskqueue && npm run bench:piscina",
54112
- "bench:piscina": "npm run benchmark:piscina-default &&npm run benchmark:piscina-fixed-queue && npm run benchmark:piscina-comparison",
54113
- "bench:taskqueue": "npm run benchmark:queue-comparison",
54114
- "benchmark:piscina-default": "node benchmark/simple-benchmark.js",
54115
- "benchmark:piscina-fixed-queue": "node benchmark/simple-benchmark-fixed-queue.js",
54116
- "benchmark:piscina-comparison": "node benchmark/piscina-queue-comparison.js",
54117
- "benchmark:queue-comparison": "node benchmark/queue-comparison.js"
54118
- },
54119
- repository: {
54120
- type: "git",
54121
- url: "git+https://github.com/piscinajs/piscina.git"
54122
- },
54123
- keywords: [
54124
- "fast",
54125
- "worker threads",
54126
- "thread pool",
54127
- "wade wilson"
54128
- ],
54129
- author: "James M Snell <jasnell@gmail.com>",
54130
- contributors: [
54131
- "Anna Henningsen <anna@addaleax.net>",
54132
- "Matteo Collina <matteo.collina@gmail.com>"
54133
- ],
54134
- license: "MIT",
54135
- devDependencies: {
54136
- "@types/node": "^22.4.1",
54137
- "@typescript-eslint/eslint-plugin": "^6.9.0",
54138
- "@typescript-eslint/parser": "^6.9.0",
54139
- "abort-controller": "^3.0.0",
54140
- c8: "^10.1.2",
54141
- "concat-stream": "^2.0.0",
54142
- "gen-esm-wrapper": "^1.1.1",
54143
- snazzy: "^9.0.0",
54144
- standardx: "^7.0.0",
54145
- tap: "^16.3.7",
54146
- tinybench: "^2.8.0",
54147
- "ts-node": "^10.9.2",
54148
- typescript: "5.6.2"
54149
- },
54150
- optionalDependencies: {
54151
- "@napi-rs/nice": "^1.0.1"
54152
- },
54153
- eslintConfig: {
54154
- rules: {
54155
- semi: [
54156
- "error",
54157
- "always"
54158
- ],
54159
- "no-unused-vars": "off",
54160
- "no-use-before-define": "off",
54161
- "no-unreachable-loop": "off",
54162
- "no-dupe-class-members": "off",
54163
- "@typescript-eslint/no-unused-vars": "error"
54164
- },
54165
- globals: {
54166
- SharedArrayBuffer: true,
54167
- Atomics: true,
54168
- AbortController: true,
54169
- MessageChannel: true
54170
- }
54171
- },
54172
- standardx: {
54173
- parser: "@typescript-eslint/parser",
54174
- plugins: [
54175
- "@typescript-eslint/eslint-plugin"
54176
- ]
54177
- },
54178
- bugs: {
54179
- url: "https://github.com/piscinajs/piscina/issues"
54180
- },
54181
- homepage: "https://github.com/piscinajs/piscina#readme",
54182
- directories: {
54183
- example: "examples",
54184
- test: "test"
54185
- }
54186
- };
54187
- }
54188
- });
54189
-
54190
- // node_modules/piscina/dist/symbols.js
54191
- var require_symbols = __commonJS({
54192
- "node_modules/piscina/dist/symbols.js"(exports) {
54193
- "use strict";
54194
- Object.defineProperty(exports, "__esModule", { value: true });
54195
- exports.kFieldCount = exports.kResponseCountField = exports.kRequestCountField = exports.kQueueOptions = exports.kValue = exports.kTransferable = exports.kMovable = void 0;
54196
- exports.kMovable = /* @__PURE__ */ Symbol("Piscina.kMovable");
54197
- exports.kTransferable = /* @__PURE__ */ Symbol.for("Piscina.transferable");
54198
- exports.kValue = /* @__PURE__ */ Symbol.for("Piscina.valueOf");
54199
- exports.kQueueOptions = /* @__PURE__ */ Symbol.for("Piscina.queueOptions");
54200
- exports.kRequestCountField = 0;
54201
- exports.kResponseCountField = 1;
54202
- exports.kFieldCount = 2;
54203
- }
54204
- });
54205
-
54206
- // node_modules/piscina/dist/common.js
54207
- var require_common3 = __commonJS({
54208
- "node_modules/piscina/dist/common.js"(exports) {
54209
- "use strict";
54210
- Object.defineProperty(exports, "__esModule", { value: true });
54211
- exports.commonState = exports.READY = void 0;
54212
- exports.isTransferable = isTransferable;
54213
- exports.isMovable = isMovable;
54214
- exports.markMovable = markMovable;
54215
- exports.createHistogramSummary = createHistogramSummary;
54216
- exports.toHistogramIntegerNano = toHistogramIntegerNano;
54217
- exports.maybeFileURLToPath = maybeFileURLToPath;
54218
- exports.getAvailableParallelism = getAvailableParallelism;
54219
- var node_url_1 = __require("node:url");
54220
- var node_os_1 = __require("node:os");
54221
- var symbols_1 = require_symbols();
54222
- exports.READY = "_WORKER_READY";
54223
- function isTransferable(value) {
54224
- return value != null && typeof value === "object" && symbols_1.kTransferable in value && symbols_1.kValue in value;
54225
- }
54226
- function isMovable(value) {
54227
- return isTransferable(value) && value[symbols_1.kMovable] === true;
54228
- }
54229
- function markMovable(value) {
54230
- Object.defineProperty(value, symbols_1.kMovable, {
54231
- enumerable: false,
54232
- configurable: true,
54233
- writable: true,
54234
- value: true
54235
- });
54236
- }
54237
- exports.commonState = {
54238
- isWorkerThread: false,
54239
- workerData: void 0
54240
- };
54241
- function createHistogramSummary(histogram) {
54242
- const { mean, stddev, min, max } = histogram;
54243
- return {
54244
- average: mean / 1e3,
54245
- mean: mean / 1e3,
54246
- stddev,
54247
- min: min / 1e3,
54248
- max: max / 1e3,
54249
- p0_001: histogram.percentile(1e-3) / 1e3,
54250
- p0_01: histogram.percentile(0.01) / 1e3,
54251
- p0_1: histogram.percentile(0.1) / 1e3,
54252
- p1: histogram.percentile(1) / 1e3,
54253
- p2_5: histogram.percentile(2.5) / 1e3,
54254
- p10: histogram.percentile(10) / 1e3,
54255
- p25: histogram.percentile(25) / 1e3,
54256
- p50: histogram.percentile(50) / 1e3,
54257
- p75: histogram.percentile(75) / 1e3,
54258
- p90: histogram.percentile(90) / 1e3,
54259
- p97_5: histogram.percentile(97.5) / 1e3,
54260
- p99: histogram.percentile(99) / 1e3,
54261
- p99_9: histogram.percentile(99.9) / 1e3,
54262
- p99_99: histogram.percentile(99.99) / 1e3,
54263
- p99_999: histogram.percentile(99.999) / 1e3
54264
- };
54265
- }
54266
- function toHistogramIntegerNano(milliseconds) {
54267
- return Math.max(1, Math.trunc(milliseconds * 1e3));
54268
- }
54269
- function maybeFileURLToPath(filename) {
54270
- return filename.startsWith("file:") ? (0, node_url_1.fileURLToPath)(new node_url_1.URL(filename)) : filename;
54271
- }
54272
- function getAvailableParallelism() {
54273
- if (typeof node_os_1.availableParallelism === "function") {
54274
- return (0, node_os_1.availableParallelism)();
54275
- }
54276
- try {
54277
- return (0, node_os_1.cpus)().length;
54278
- } catch {
54279
- return 1;
54280
- }
54281
- }
54282
- }
54283
- });
54284
-
54285
- // node_modules/piscina/dist/task_queue/array_queue.js
54286
- var require_array_queue = __commonJS({
54287
- "node_modules/piscina/dist/task_queue/array_queue.js"(exports) {
54288
- "use strict";
54289
- var __importDefault = exports && exports.__importDefault || function(mod2) {
54290
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
54291
- };
54292
- Object.defineProperty(exports, "__esModule", { value: true });
54293
- exports.ArrayTaskQueue = void 0;
54294
- var node_assert_1 = __importDefault(__require("node:assert"));
54295
- var ArrayTaskQueue2 = class {
54296
- constructor() {
54297
- this.tasks = [];
54298
- }
54299
- get size() {
54300
- return this.tasks.length;
54301
- }
54302
- shift() {
54303
- var _a3;
54304
- return (_a3 = this.tasks.shift()) !== null && _a3 !== void 0 ? _a3 : null;
54305
- }
54306
- push(task) {
54307
- this.tasks.push(task);
54308
- }
54309
- remove(task) {
54310
- const index = this.tasks.indexOf(task);
54311
- node_assert_1.default.notStrictEqual(index, -1);
54312
- this.tasks.splice(index, 1);
54313
- }
54314
- };
54315
- exports.ArrayTaskQueue = ArrayTaskQueue2;
54316
- }
54317
- });
54318
-
54319
- // node_modules/piscina/dist/task_queue/fixed_queue.js
54320
- var require_fixed_queue = __commonJS({
54321
- "node_modules/piscina/dist/task_queue/fixed_queue.js"(exports) {
54322
- "use strict";
54323
- var __importDefault = exports && exports.__importDefault || function(mod2) {
54324
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
54325
- };
54326
- Object.defineProperty(exports, "__esModule", { value: true });
54327
- exports.FixedQueue = void 0;
54328
- var node_assert_1 = __importDefault(__require("node:assert"));
54329
- var kSize = 2048;
54330
- var kMask = kSize - 1;
54331
- var FixedCircularBuffer = class {
54332
- constructor() {
54333
- this.bottom = 0;
54334
- this.top = 0;
54335
- this.list = new Array(kSize);
54336
- this.next = null;
54337
- }
54338
- isEmpty() {
54339
- return this.top === this.bottom;
54340
- }
54341
- isFull() {
54342
- return (this.top + 1 & kMask) === this.bottom;
54343
- }
54344
- push(data) {
54345
- this.list[this.top] = data;
54346
- this.top = this.top + 1 & kMask;
54347
- }
54348
- shift() {
54349
- const nextItem = this.list[this.bottom];
54350
- if (nextItem === void 0) {
54351
- return null;
54352
- }
54353
- this.list[this.bottom] = void 0;
54354
- this.bottom = this.bottom + 1 & kMask;
54355
- return nextItem;
54356
- }
54357
- remove(task) {
54358
- const indexToRemove = this.list.indexOf(task);
54359
- node_assert_1.default.notStrictEqual(indexToRemove, -1);
54360
- let curr = indexToRemove;
54361
- while (true) {
54362
- const next = curr + 1 & kMask;
54363
- this.list[curr] = this.list[next];
54364
- if (this.list[curr] === void 0) {
54365
- break;
54366
- }
54367
- if (next === indexToRemove) {
54368
- this.list[curr] = void 0;
54369
- break;
54370
- }
54371
- curr = next;
54372
- }
54373
- this.top = this.top - 1 & kMask;
54374
- }
54375
- };
54376
- var FixedQueue2 = class {
54377
- constructor() {
54378
- this._size = 0;
54379
- this.head = this.tail = new FixedCircularBuffer();
54380
- }
54381
- isEmpty() {
54382
- return this.head.isEmpty();
54383
- }
54384
- push(data) {
54385
- if (this.head.isFull()) {
54386
- this.head = this.head.next = new FixedCircularBuffer();
54387
- }
54388
- this.head.push(data);
54389
- this._size++;
54390
- }
54391
- shift() {
54392
- const tail = this.tail;
54393
- const next = tail.shift();
54394
- if (next !== null)
54395
- this._size--;
54396
- if (tail.isEmpty() && tail.next !== null) {
54397
- this.tail = tail.next;
54398
- tail.next = null;
54399
- }
54400
- return next;
54401
- }
54402
- remove(task) {
54403
- let prev = null;
54404
- let buffer = this.tail;
54405
- while (true) {
54406
- if (buffer.list.includes(task)) {
54407
- buffer.remove(task);
54408
- this._size--;
54409
- break;
54410
- }
54411
- if (buffer.next === null)
54412
- break;
54413
- prev = buffer;
54414
- buffer = buffer.next;
54415
- }
54416
- if (buffer.isEmpty()) {
54417
- if (prev === null) {
54418
- if (buffer.next !== null)
54419
- this.tail = buffer.next;
54420
- } else {
54421
- if (buffer.next === null) {
54422
- this.head = prev;
54423
- } else {
54424
- prev.next = buffer.next;
54425
- }
54426
- }
54427
- }
54428
- }
54429
- get size() {
54430
- return this._size;
54431
- }
54432
- };
54433
- exports.FixedQueue = FixedQueue2;
54434
- }
54435
- });
54436
-
54437
- // node_modules/piscina/dist/task_queue/index.js
54438
- var require_task_queue = __commonJS({
54439
- "node_modules/piscina/dist/task_queue/index.js"(exports) {
54440
- "use strict";
54441
- Object.defineProperty(exports, "__esModule", { value: true });
54442
- exports.TaskInfo = exports.FixedQueue = exports.ArrayTaskQueue = void 0;
54443
- exports.isTaskQueue = isTaskQueue;
54444
- var node_perf_hooks_1 = __require("node:perf_hooks");
54445
- var node_async_hooks_1 = __require("node:async_hooks");
54446
- var common_1 = require_common3();
54447
- var symbols_1 = require_symbols();
54448
- var array_queue_1 = require_array_queue();
54449
- Object.defineProperty(exports, "ArrayTaskQueue", { enumerable: true, get: function() {
54450
- return array_queue_1.ArrayTaskQueue;
54451
- } });
54452
- var fixed_queue_1 = require_fixed_queue();
54453
- Object.defineProperty(exports, "FixedQueue", { enumerable: true, get: function() {
54454
- return fixed_queue_1.FixedQueue;
54455
- } });
54456
- function isTaskQueue(value) {
54457
- return typeof value === "object" && value !== null && "size" in value && typeof value.shift === "function" && typeof value.remove === "function" && typeof value.push === "function";
54458
- }
54459
- var taskIdCounter = 0;
54460
- var TaskInfo = class extends node_async_hooks_1.AsyncResource {
54461
- constructor(task, transferList, filename, name, callback, abortSignal, triggerAsyncId) {
54462
- super("Piscina.Task", { requireManualDestroy: true, triggerAsyncId });
54463
- this.abortListener = null;
54464
- this.workerInfo = null;
54465
- this.callback = callback;
54466
- this.task = task;
54467
- this.transferList = transferList;
54468
- if ((0, common_1.isMovable)(task)) {
54469
- if (this.transferList == null) {
54470
- this.transferList = [];
54471
- }
54472
- this.transferList = this.transferList.concat(task[symbols_1.kTransferable]);
54473
- this.task = task[symbols_1.kValue];
54474
- }
54475
- this.filename = filename;
54476
- this.name = name;
54477
- this.taskId = taskIdCounter++;
54478
- this.abortSignal = abortSignal;
54479
- this.created = node_perf_hooks_1.performance.now();
54480
- this.started = 0;
54481
- }
54482
- releaseTask() {
54483
- const ret = this.task;
54484
- this.task = null;
54485
- return ret;
54486
- }
54487
- done(err, result) {
54488
- this.runInAsyncScope(this.callback, null, err, result);
54489
- this.emitDestroy();
54490
- if (this.abortSignal && this.abortListener) {
54491
- if ("removeEventListener" in this.abortSignal && this.abortListener) {
54492
- this.abortSignal.removeEventListener("abort", this.abortListener);
54493
- } else {
54494
- this.abortSignal.off("abort", this.abortListener);
54495
- }
54496
- }
54497
- }
54498
- get [symbols_1.kQueueOptions]() {
54499
- return symbols_1.kQueueOptions in this.task ? this.task[symbols_1.kQueueOptions] : null;
54500
- }
54501
- get interface() {
54502
- return {
54503
- taskId: this.taskId,
54504
- filename: this.filename,
54505
- name: this.name,
54506
- created: this.created,
54507
- isAbortable: this.abortSignal !== null,
54508
- [symbols_1.kQueueOptions]: this[symbols_1.kQueueOptions]
54509
- };
54510
- }
54511
- };
54512
- exports.TaskInfo = TaskInfo;
54513
- }
54514
- });
54515
-
54516
- // node_modules/piscina/dist/errors.js
54517
- var require_errors = __commonJS({
54518
- "node_modules/piscina/dist/errors.js"(exports) {
54519
- "use strict";
54520
- Object.defineProperty(exports, "__esModule", { value: true });
54521
- exports.Errors = void 0;
54522
- exports.Errors = {
54523
- ThreadTermination: () => new Error("Terminating worker thread"),
54524
- FilenameNotProvided: () => new Error("filename must be provided to run() or in options object"),
54525
- TaskQueueAtLimit: () => new Error("Task queue is at limit"),
54526
- NoTaskQueueAvailable: () => new Error("No task queue available and all Workers are busy"),
54527
- CloseTimeout: () => new Error("Close operation timed out")
54528
- };
54529
- }
54530
- });
54531
-
54532
- // node_modules/piscina/dist/worker_pool/index.js
54533
- var require_worker_pool = __commonJS({
54534
- "node_modules/piscina/dist/worker_pool/index.js"(exports) {
54535
- "use strict";
54536
- var __importDefault = exports && exports.__importDefault || function(mod2) {
54537
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
54538
- };
54539
- Object.defineProperty(exports, "__esModule", { value: true });
54540
- exports.WorkerInfo = exports.AsynchronouslyCreatedResourcePool = void 0;
54541
- var node_worker_threads_1 = __require("node:worker_threads");
54542
- var node_assert_1 = __importDefault(__require("node:assert"));
54543
- var errors_1 = require_errors();
54544
- var symbols_1 = require_symbols();
54545
- var AsynchronouslyCreatedResource = class {
54546
- constructor() {
54547
- this.onreadyListeners = [];
54548
- }
54549
- markAsReady() {
54550
- const listeners = this.onreadyListeners;
54551
- (0, node_assert_1.default)(listeners !== null);
54552
- this.onreadyListeners = null;
54553
- for (const listener of listeners) {
54554
- listener();
54555
- }
54556
- }
54557
- isReady() {
54558
- return this.onreadyListeners === null;
54559
- }
54560
- onReady(fn) {
54561
- if (this.onreadyListeners === null) {
54562
- fn();
54563
- return;
54564
- }
54565
- this.onreadyListeners.push(fn);
54566
- }
54567
- };
54568
- var AsynchronouslyCreatedResourcePool = class {
54569
- constructor(maximumUsage) {
54570
- this.pendingItems = /* @__PURE__ */ new Set();
54571
- this.readyItems = /* @__PURE__ */ new Set();
54572
- this.maximumUsage = maximumUsage;
54573
- this.onAvailableListeners = [];
54574
- }
54575
- add(item) {
54576
- this.pendingItems.add(item);
54577
- item.onReady(() => {
54578
- if (this.pendingItems.has(item)) {
54579
- this.pendingItems.delete(item);
54580
- this.readyItems.add(item);
54581
- this.maybeAvailable(item);
54582
- }
54583
- });
54584
- }
54585
- delete(item) {
54586
- this.pendingItems.delete(item);
54587
- this.readyItems.delete(item);
54588
- }
54589
- findAvailable() {
54590
- let minUsage = this.maximumUsage;
54591
- let candidate = null;
54592
- for (const item of this.readyItems) {
54593
- const usage = item.currentUsage();
54594
- if (usage === 0)
54595
- return item;
54596
- if (usage < minUsage) {
54597
- candidate = item;
54598
- minUsage = usage;
54599
- }
54600
- }
54601
- return candidate;
54602
- }
54603
- *[Symbol.iterator]() {
54604
- yield* this.pendingItems;
54605
- yield* this.readyItems;
54606
- }
54607
- get size() {
54608
- return this.pendingItems.size + this.readyItems.size;
54609
- }
54610
- maybeAvailable(item) {
54611
- if (item.currentUsage() < this.maximumUsage) {
54612
- for (const listener of this.onAvailableListeners) {
54613
- listener(item);
54614
- }
54615
- }
54616
- }
54617
- onAvailable(fn) {
54618
- this.onAvailableListeners.push(fn);
54619
- }
54620
- };
54621
- exports.AsynchronouslyCreatedResourcePool = AsynchronouslyCreatedResourcePool;
54622
- var WorkerInfo = class extends AsynchronouslyCreatedResource {
54623
- constructor(worker, port, onMessage) {
54624
- super();
54625
- this.idleTimeout = null;
54626
- this.lastSeenResponseCount = 0;
54627
- this.worker = worker;
54628
- this.port = port;
54629
- this.port.on("message", (message) => this._handleResponse(message));
54630
- this.onMessage = onMessage;
54631
- this.taskInfos = /* @__PURE__ */ new Map();
54632
- this.sharedBuffer = new Int32Array(new SharedArrayBuffer(symbols_1.kFieldCount * Int32Array.BYTES_PER_ELEMENT));
54633
- }
54634
- destroy() {
54635
- this.worker.terminate();
54636
- this.port.close();
54637
- this.clearIdleTimeout();
54638
- for (const taskInfo of this.taskInfos.values()) {
54639
- taskInfo.done(errors_1.Errors.ThreadTermination());
54640
- }
54641
- this.taskInfos.clear();
54642
- }
54643
- clearIdleTimeout() {
54644
- if (this.idleTimeout !== null) {
54645
- clearTimeout(this.idleTimeout);
54646
- this.idleTimeout = null;
54647
- }
54648
- }
54649
- ref() {
54650
- this.port.ref();
54651
- return this;
54652
- }
54653
- unref() {
54654
- this.port.unref();
54655
- return this;
54656
- }
54657
- _handleResponse(message) {
54658
- this.onMessage(message);
54659
- if (this.taskInfos.size === 0) {
54660
- this.unref();
54661
- }
54662
- }
54663
- postTask(taskInfo) {
54664
- (0, node_assert_1.default)(!this.taskInfos.has(taskInfo.taskId));
54665
- const message = {
54666
- task: taskInfo.releaseTask(),
54667
- taskId: taskInfo.taskId,
54668
- filename: taskInfo.filename,
54669
- name: taskInfo.name
54670
- };
54671
- try {
54672
- this.port.postMessage(message, taskInfo.transferList);
54673
- } catch (err) {
54674
- taskInfo.done(err);
54675
- return;
54676
- }
54677
- taskInfo.workerInfo = this;
54678
- this.taskInfos.set(taskInfo.taskId, taskInfo);
54679
- this.ref();
54680
- this.clearIdleTimeout();
54681
- Atomics.add(this.sharedBuffer, symbols_1.kRequestCountField, 1);
54682
- Atomics.notify(this.sharedBuffer, symbols_1.kRequestCountField, 1);
54683
- }
54684
- processPendingMessages() {
54685
- const actualResponseCount = Atomics.load(this.sharedBuffer, symbols_1.kResponseCountField);
54686
- if (actualResponseCount !== this.lastSeenResponseCount) {
54687
- this.lastSeenResponseCount = actualResponseCount;
54688
- let entry;
54689
- while ((entry = (0, node_worker_threads_1.receiveMessageOnPort)(this.port)) !== void 0) {
54690
- this._handleResponse(entry.message);
54691
- }
54692
- }
54693
- }
54694
- isRunningAbortableTask() {
54695
- if (this.taskInfos.size !== 1)
54696
- return false;
54697
- const [[, task]] = this.taskInfos;
54698
- return task.abortSignal !== null;
54699
- }
54700
- currentUsage() {
54701
- if (this.isRunningAbortableTask())
54702
- return Infinity;
54703
- return this.taskInfos.size;
54704
- }
54705
- };
54706
- exports.WorkerInfo = WorkerInfo;
54707
- }
54708
- });
54709
-
54710
- // node_modules/piscina/dist/abort.js
54711
- var require_abort = __commonJS({
54712
- "node_modules/piscina/dist/abort.js"(exports) {
54713
- "use strict";
54714
- Object.defineProperty(exports, "__esModule", { value: true });
54715
- exports.AbortError = void 0;
54716
- exports.onabort = onabort;
54717
- var AbortError = class extends Error {
54718
- constructor(reason) {
54719
- super("The task has been aborted", { cause: reason });
54720
- }
54721
- get name() {
54722
- return "AbortError";
54723
- }
54724
- };
54725
- exports.AbortError = AbortError;
54726
- function onabort(abortSignal, listener) {
54727
- if ("addEventListener" in abortSignal) {
54728
- abortSignal.addEventListener("abort", listener, { once: true });
54729
- } else {
54730
- abortSignal.once("abort", listener);
54731
- }
54732
- }
54733
- }
54734
- });
54735
-
54736
- // node_modules/piscina/dist/index.js
54737
- var require_dist = __commonJS({
54738
- "node_modules/piscina/dist/index.js"(exports) {
54739
- "use strict";
54740
- var __classPrivateFieldSet = exports && exports.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
54741
- if (kind === "m") throw new TypeError("Private method is not writable");
54742
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
54743
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
54744
- return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
54745
- };
54746
- var __classPrivateFieldGet = exports && exports.__classPrivateFieldGet || function(receiver, state, kind, f) {
54747
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
54748
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
54749
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
54750
- };
54751
- var __importDefault = exports && exports.__importDefault || function(mod2) {
54752
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
54753
- };
54754
- var _DirectlyTransferable_value;
54755
- var _ArrayBufferViewTransferable_view;
54756
- var _Piscina_pool;
54757
- Object.defineProperty(exports, "__esModule", { value: true });
54758
- exports.FixedQueue = exports.version = exports.queueOptionsSymbol = exports.valueSymbol = exports.transferableSymbol = exports.Piscina = exports.workerData = exports.isWorkerThread = exports.move = void 0;
54759
- var node_worker_threads_1 = __require("node:worker_threads");
54760
- var node_events_1 = __require("node:events");
54761
- var node_path_1 = __require("node:path");
54762
- var node_util_1 = __require("node:util");
54763
- var node_perf_hooks_1 = __require("node:perf_hooks");
54764
- var promises_1 = __require("node:timers/promises");
54765
- var node_assert_1 = __importDefault(__require("node:assert"));
54766
- var package_json_1 = require_package();
54767
- Object.defineProperty(exports, "version", { enumerable: true, get: function() {
54768
- return package_json_1.version;
54769
- } });
54770
- var symbols_1 = require_symbols();
54771
- Object.defineProperty(exports, "queueOptionsSymbol", { enumerable: true, get: function() {
54772
- return symbols_1.kQueueOptions;
54773
- } });
54774
- Object.defineProperty(exports, "transferableSymbol", { enumerable: true, get: function() {
54775
- return symbols_1.kTransferable;
54776
- } });
54777
- Object.defineProperty(exports, "valueSymbol", { enumerable: true, get: function() {
54778
- return symbols_1.kValue;
54779
- } });
54780
- var task_queue_1 = require_task_queue();
54781
- Object.defineProperty(exports, "FixedQueue", { enumerable: true, get: function() {
54782
- return task_queue_1.FixedQueue;
54783
- } });
54784
- var worker_pool_1 = require_worker_pool();
54785
- var abort_1 = require_abort();
54786
- var errors_1 = require_errors();
54787
- var common_1 = require_common3();
54788
- var cpuParallelism = (0, common_1.getAvailableParallelism)();
54789
- var kDefaultOptions = {
54790
- filename: null,
54791
- name: "default",
54792
- minThreads: Math.max(Math.floor(cpuParallelism / 2), 1),
54793
- maxThreads: cpuParallelism * 1.5,
54794
- idleTimeout: 0,
54795
- maxQueue: Infinity,
54796
- concurrentTasksPerWorker: 1,
54797
- useAtomics: true,
54798
- taskQueue: new task_queue_1.ArrayTaskQueue(),
54799
- niceIncrement: 0,
54800
- trackUnmanagedFds: true,
54801
- closeTimeout: 3e4,
54802
- recordTiming: true
54803
- };
54804
- var kDefaultRunOptions = {
54805
- transferList: void 0,
54806
- filename: null,
54807
- signal: null,
54808
- name: null
54809
- };
54810
- var kDefaultCloseOptions = {
54811
- force: false
54812
- };
54813
- var DirectlyTransferable = class {
54814
- constructor(value) {
54815
- _DirectlyTransferable_value.set(this, void 0);
54816
- __classPrivateFieldSet(this, _DirectlyTransferable_value, value, "f");
54817
- }
54818
- get [(_DirectlyTransferable_value = /* @__PURE__ */ new WeakMap(), symbols_1.kTransferable)]() {
54819
- return __classPrivateFieldGet(this, _DirectlyTransferable_value, "f");
54820
- }
54821
- get [symbols_1.kValue]() {
54822
- return __classPrivateFieldGet(this, _DirectlyTransferable_value, "f");
54823
- }
54824
- };
54825
- var ArrayBufferViewTransferable = class {
54826
- constructor(view) {
54827
- _ArrayBufferViewTransferable_view.set(this, void 0);
54828
- __classPrivateFieldSet(this, _ArrayBufferViewTransferable_view, view, "f");
54829
- }
54830
- get [(_ArrayBufferViewTransferable_view = /* @__PURE__ */ new WeakMap(), symbols_1.kTransferable)]() {
54831
- return __classPrivateFieldGet(this, _ArrayBufferViewTransferable_view, "f").buffer;
54832
- }
54833
- get [symbols_1.kValue]() {
54834
- return __classPrivateFieldGet(this, _ArrayBufferViewTransferable_view, "f");
54835
- }
54836
- };
54837
- var ThreadPool = class {
54838
- constructor(publicInterface, options) {
54839
- var _a3;
54840
- this.skipQueue = [];
54841
- this.completed = 0;
54842
- this.start = node_perf_hooks_1.performance.now();
54843
- this.inProcessPendingMessages = false;
54844
- this.startingUp = false;
54845
- this.closingUp = false;
54846
- this.workerFailsDuringBootstrap = false;
54847
- this.destroying = false;
54848
- this.publicInterface = publicInterface;
54849
- this.taskQueue = options.taskQueue || new task_queue_1.ArrayTaskQueue();
54850
- const filename = options.filename ? (0, common_1.maybeFileURLToPath)(options.filename) : null;
54851
- this.options = { ...kDefaultOptions, ...options, filename, maxQueue: 0 };
54852
- if (this.options.recordTiming) {
54853
- this.runTime = (0, node_perf_hooks_1.createHistogram)();
54854
- this.waitTime = (0, node_perf_hooks_1.createHistogram)();
54855
- }
54856
- if (options.maxThreads !== void 0 && this.options.minThreads >= options.maxThreads) {
54857
- this.options.minThreads = options.maxThreads;
54858
- }
54859
- if (options.minThreads !== void 0 && this.options.maxThreads <= options.minThreads) {
54860
- this.options.maxThreads = options.minThreads;
54861
- }
54862
- if (options.maxQueue === "auto") {
54863
- this.options.maxQueue = this.options.maxThreads ** 2;
54864
- } else {
54865
- this.options.maxQueue = (_a3 = options.maxQueue) !== null && _a3 !== void 0 ? _a3 : kDefaultOptions.maxQueue;
54866
- }
54867
- this.workers = new worker_pool_1.AsynchronouslyCreatedResourcePool(this.options.concurrentTasksPerWorker);
54868
- this.workers.onAvailable((w) => this._onWorkerAvailable(w));
54869
- this.startingUp = true;
54870
- this._ensureMinimumWorkers();
54871
- this.startingUp = false;
54872
- this.needsDrain = false;
54873
- }
54874
- _ensureMinimumWorkers() {
54875
- if (this.closingUp || this.destroying) {
54876
- return;
54877
- }
54878
- while (this.workers.size < this.options.minThreads) {
54879
- this._addNewWorker();
54880
- }
54881
- }
54882
- _addNewWorker() {
54883
- const pool = this;
54884
- const worker = new node_worker_threads_1.Worker((0, node_path_1.resolve)(__dirname, "worker.js"), {
54885
- env: this.options.env,
54886
- argv: this.options.argv,
54887
- execArgv: this.options.execArgv,
54888
- resourceLimits: this.options.resourceLimits,
54889
- workerData: this.options.workerData,
54890
- trackUnmanagedFds: this.options.trackUnmanagedFds
54891
- });
54892
- const { port1, port2 } = new node_worker_threads_1.MessageChannel();
54893
- const workerInfo = new worker_pool_1.WorkerInfo(worker, port1, onMessage);
54894
- if (this.startingUp) {
54895
- workerInfo.markAsReady();
54896
- }
54897
- const message = {
54898
- filename: this.options.filename,
54899
- name: this.options.name,
54900
- port: port2,
54901
- sharedBuffer: workerInfo.sharedBuffer,
54902
- useAtomics: this.options.useAtomics,
54903
- niceIncrement: this.options.niceIncrement
54904
- };
54905
- worker.postMessage(message, [port2]);
54906
- function onMessage(message2) {
54907
- const { taskId, result } = message2;
54908
- const taskInfo = workerInfo.taskInfos.get(taskId);
54909
- workerInfo.taskInfos.delete(taskId);
54910
- pool.workers.maybeAvailable(workerInfo);
54911
- if (taskInfo === void 0) {
54912
- const err = new Error(`Unexpected message from Worker: ${(0, node_util_1.inspect)(message2)}`);
54913
- pool.publicInterface.emit("error", err);
54914
- } else {
54915
- taskInfo.done(message2.error, result);
54916
- }
54917
- pool._processPendingMessages();
54918
- }
54919
- function onReady() {
54920
- if (workerInfo.currentUsage() === 0) {
54921
- workerInfo.unref();
54922
- }
54923
- if (!workerInfo.isReady()) {
54924
- workerInfo.markAsReady();
54925
- }
54926
- }
54927
- function onEventMessage(message2) {
54928
- pool.publicInterface.emit("message", message2);
54929
- }
54930
- worker.on("message", (message2) => {
54931
- message2 instanceof Object && common_1.READY in message2 ? onReady() : onEventMessage(message2);
54932
- });
54933
- worker.on("error", (err) => {
54934
- this._onError(worker, workerInfo, err, false);
54935
- });
54936
- worker.on("exit", (exitCode) => {
54937
- if (this.destroying) {
54938
- return;
54939
- }
54940
- const err = new Error(`worker exited with code: ${exitCode}`);
54941
- this._onError(worker, workerInfo, err, true);
54942
- });
54943
- worker.unref();
54944
- port1.on("close", () => {
54945
- worker.ref();
54946
- });
54947
- this.workers.add(workerInfo);
54948
- }
54949
- _onError(worker, workerInfo, err, onlyErrorUnfinishedTasks) {
54950
- worker.ref = () => {
54951
- };
54952
- const taskInfos = [...workerInfo.taskInfos.values()];
54953
- workerInfo.taskInfos.clear();
54954
- this._removeWorker(workerInfo);
54955
- if (workerInfo.isReady() && !this.workerFailsDuringBootstrap) {
54956
- this._ensureMinimumWorkers();
54957
- } else {
54958
- this.workerFailsDuringBootstrap = true;
54959
- }
54960
- if (taskInfos.length > 0) {
54961
- for (const taskInfo of taskInfos) {
54962
- taskInfo.done(err, null);
54963
- }
54964
- } else if (!onlyErrorUnfinishedTasks) {
54965
- this.publicInterface.emit("error", err);
54966
- }
54967
- }
54968
- _processPendingMessages() {
54969
- if (this.inProcessPendingMessages || !this.options.useAtomics) {
54970
- return;
54971
- }
54972
- this.inProcessPendingMessages = true;
54973
- try {
54974
- for (const workerInfo of this.workers) {
54975
- workerInfo.processPendingMessages();
54976
- }
54977
- } finally {
54978
- this.inProcessPendingMessages = false;
54979
- }
54980
- }
54981
- _removeWorker(workerInfo) {
54982
- workerInfo.destroy();
54983
- this.workers.delete(workerInfo);
54984
- }
54985
- _onWorkerAvailable(workerInfo) {
54986
- var _a3;
54987
- while ((this.taskQueue.size > 0 || this.skipQueue.length > 0) && workerInfo.currentUsage() < this.options.concurrentTasksPerWorker) {
54988
- const taskInfo = this.skipQueue.shift() || this.taskQueue.shift();
54989
- if (taskInfo.abortSignal && workerInfo.taskInfos.size > 0) {
54990
- this.skipQueue.push(taskInfo);
54991
- break;
54992
- }
54993
- const now = node_perf_hooks_1.performance.now();
54994
- (_a3 = this.waitTime) === null || _a3 === void 0 ? void 0 : _a3.record((0, common_1.toHistogramIntegerNano)(now - taskInfo.created));
54995
- taskInfo.started = now;
54996
- workerInfo.postTask(taskInfo);
54997
- this._maybeDrain();
54998
- return;
54999
- }
55000
- if (this.options.idleTimeout === Infinity) {
55001
- return;
55002
- }
55003
- if (workerInfo.taskInfos.size === 0 && this.workers.size > this.options.minThreads) {
55004
- workerInfo.idleTimeout = setTimeout(() => {
55005
- node_assert_1.default.strictEqual(workerInfo.taskInfos.size, 0);
55006
- if (this.workers.size > this.options.minThreads) {
55007
- this._removeWorker(workerInfo);
55008
- }
55009
- }, this.options.idleTimeout).unref();
55010
- }
55011
- }
55012
- runTask(task, options) {
55013
- var _a3, _b;
55014
- let { filename, name } = options;
55015
- const { transferList = [] } = options;
55016
- if (filename == null) {
55017
- filename = this.options.filename;
55018
- }
55019
- if (name == null) {
55020
- name = this.options.name;
55021
- }
55022
- if (typeof filename !== "string") {
55023
- return Promise.reject(errors_1.Errors.FilenameNotProvided());
55024
- }
55025
- filename = (0, common_1.maybeFileURLToPath)(filename);
55026
- let signal;
55027
- if (this.closingUp) {
55028
- const closingUpAbortController = new AbortController();
55029
- closingUpAbortController.abort("queue is closing up");
55030
- signal = closingUpAbortController.signal;
55031
- } else {
55032
- signal = (_a3 = options.signal) !== null && _a3 !== void 0 ? _a3 : null;
55033
- }
55034
- let resolve;
55035
- let reject;
55036
- const ret = new Promise((res, rej) => {
55037
- resolve = res;
55038
- reject = rej;
55039
- });
55040
- const taskInfo = new task_queue_1.TaskInfo(task, transferList, filename, name, (err, result) => {
55041
- var _a4;
55042
- this.completed++;
55043
- if (taskInfo.started) {
55044
- (_a4 = this.runTime) === null || _a4 === void 0 ? void 0 : _a4.record((0, common_1.toHistogramIntegerNano)(node_perf_hooks_1.performance.now() - taskInfo.started));
55045
- }
55046
- if (err !== null) {
55047
- reject(err);
55048
- } else {
55049
- resolve(result);
55050
- }
55051
- this._maybeDrain();
55052
- }, signal, this.publicInterface.asyncResource.asyncId());
55053
- if (signal !== null) {
55054
- if (signal.aborted) {
55055
- return Promise.reject(new abort_1.AbortError(signal.reason));
55056
- }
55057
- taskInfo.abortListener = () => {
55058
- reject(new abort_1.AbortError(signal.reason));
55059
- if (taskInfo.workerInfo !== null) {
55060
- this._removeWorker(taskInfo.workerInfo);
55061
- this._ensureMinimumWorkers();
55062
- } else {
55063
- this.taskQueue.remove(taskInfo);
55064
- }
55065
- };
55066
- (0, abort_1.onabort)(signal, taskInfo.abortListener);
55067
- }
55068
- if (this.taskQueue.size > 0) {
55069
- const totalCapacity = this.options.maxQueue + this.pendingCapacity();
55070
- if (this.taskQueue.size >= totalCapacity) {
55071
- if (this.options.maxQueue === 0) {
55072
- return Promise.reject(errors_1.Errors.NoTaskQueueAvailable());
55073
- } else {
55074
- return Promise.reject(errors_1.Errors.TaskQueueAtLimit());
55075
- }
55076
- } else {
55077
- if (this.workers.size < this.options.maxThreads) {
55078
- this._addNewWorker();
55079
- }
55080
- this.taskQueue.push(taskInfo);
55081
- }
55082
- this._maybeDrain();
55083
- return ret;
55084
- }
55085
- let workerInfo = this.workers.findAvailable();
55086
- if (workerInfo !== null && workerInfo.currentUsage() > 0 && signal) {
55087
- workerInfo = null;
55088
- }
55089
- let waitingForNewWorker = false;
55090
- if ((workerInfo === null || workerInfo.currentUsage() > 0) && this.workers.size < this.options.maxThreads) {
55091
- this._addNewWorker();
55092
- waitingForNewWorker = true;
55093
- }
55094
- if (workerInfo === null) {
55095
- if (this.options.maxQueue <= 0 && !waitingForNewWorker) {
55096
- return Promise.reject(errors_1.Errors.NoTaskQueueAvailable());
55097
- } else {
55098
- this.taskQueue.push(taskInfo);
55099
- }
55100
- this._maybeDrain();
55101
- return ret;
55102
- }
55103
- const now = node_perf_hooks_1.performance.now();
55104
- (_b = this.waitTime) === null || _b === void 0 ? void 0 : _b.record((0, common_1.toHistogramIntegerNano)(now - taskInfo.created));
55105
- taskInfo.started = now;
55106
- workerInfo.postTask(taskInfo);
55107
- this._maybeDrain();
55108
- return ret;
55109
- }
55110
- pendingCapacity() {
55111
- return this.workers.pendingItems.size * this.options.concurrentTasksPerWorker;
55112
- }
55113
- _maybeDrain() {
55114
- const totalCapacity = this.options.maxQueue + this.pendingCapacity();
55115
- const totalQueueSize = this.taskQueue.size + this.skipQueue.length;
55116
- if (totalQueueSize === 0) {
55117
- this.needsDrain = false;
55118
- this.publicInterface.emit("drain");
55119
- }
55120
- if (totalQueueSize >= totalCapacity) {
55121
- this.needsDrain = true;
55122
- this.publicInterface.emit("needsDrain");
55123
- }
55124
- }
55125
- async destroy() {
55126
- this.destroying = true;
55127
- while (this.skipQueue.length > 0) {
55128
- const taskInfo = this.skipQueue.shift();
55129
- taskInfo.done(new Error("Terminating worker thread"));
55130
- }
55131
- while (this.taskQueue.size > 0) {
55132
- const taskInfo = this.taskQueue.shift();
55133
- taskInfo.done(new Error("Terminating worker thread"));
55134
- }
55135
- const exitEvents = [];
55136
- while (this.workers.size > 0) {
55137
- const [workerInfo] = this.workers;
55138
- exitEvents.push((0, node_events_1.once)(workerInfo.worker, "exit"));
55139
- this._removeWorker(workerInfo);
55140
- }
55141
- try {
55142
- await Promise.all(exitEvents);
55143
- } finally {
55144
- this.destroying = false;
55145
- }
55146
- }
55147
- async close(options) {
55148
- this.closingUp = true;
55149
- if (options.force) {
55150
- const skipQueueLength = this.skipQueue.length;
55151
- for (let i = 0; i < skipQueueLength; i++) {
55152
- const taskInfo = this.skipQueue.shift();
55153
- if (taskInfo.workerInfo === null) {
55154
- taskInfo.done(new abort_1.AbortError("pool is closed"));
55155
- } else {
55156
- this.skipQueue.push(taskInfo);
55157
- }
55158
- }
55159
- const taskQueueLength = this.taskQueue.size;
55160
- for (let i = 0; i < taskQueueLength; i++) {
55161
- const taskInfo = this.taskQueue.shift();
55162
- if (taskInfo.workerInfo === null) {
55163
- taskInfo.done(new abort_1.AbortError("pool is closed"));
55164
- } else {
55165
- this.taskQueue.push(taskInfo);
55166
- }
55167
- }
55168
- }
55169
- const onPoolFlushed = () => new Promise((resolve) => {
55170
- const numberOfWorkers = this.workers.size;
55171
- if (numberOfWorkers === 0) {
55172
- resolve();
55173
- return;
55174
- }
55175
- let numberOfWorkersDone = 0;
55176
- const checkIfWorkerIsDone = (workerInfo) => {
55177
- if (workerInfo.taskInfos.size === 0) {
55178
- numberOfWorkersDone++;
55179
- }
55180
- if (numberOfWorkers === numberOfWorkersDone) {
55181
- resolve();
55182
- }
55183
- };
55184
- for (const workerInfo of this.workers) {
55185
- checkIfWorkerIsDone(workerInfo);
55186
- workerInfo.port.on("message", () => checkIfWorkerIsDone(workerInfo));
55187
- }
55188
- });
55189
- const throwOnTimeOut = async (timeout) => {
55190
- await (0, promises_1.setTimeout)(timeout);
55191
- throw errors_1.Errors.CloseTimeout();
55192
- };
55193
- try {
55194
- await Promise.race([
55195
- onPoolFlushed(),
55196
- throwOnTimeOut(this.options.closeTimeout)
55197
- ]);
55198
- } catch (error51) {
55199
- this.publicInterface.emit("error", error51);
55200
- } finally {
55201
- await this.destroy();
55202
- this.publicInterface.emit("close");
55203
- this.closingUp = false;
55204
- }
55205
- }
55206
- };
55207
- var Piscina2 = class _Piscina extends node_events_1.EventEmitterAsyncResource {
55208
- constructor(options = {}) {
55209
- const opts = { ...options, "__proto__": null };
55210
- super({ ...opts, name: "Piscina" });
55211
- _Piscina_pool.set(this, void 0);
55212
- if (typeof opts.filename !== "string" && opts.filename != null) {
55213
- throw new TypeError("options.filename must be a string or null");
55214
- }
55215
- if (typeof opts.name !== "string" && opts.name != null) {
55216
- throw new TypeError("options.name must be a string or null");
55217
- }
55218
- if (opts.minThreads !== void 0 && (typeof opts.minThreads !== "number" || opts.minThreads < 0)) {
55219
- throw new TypeError("options.minThreads must be a non-negative integer");
55220
- }
55221
- if (opts.maxThreads !== void 0 && (typeof opts.maxThreads !== "number" || opts.maxThreads < 1)) {
55222
- throw new TypeError("options.maxThreads must be a positive integer");
55223
- }
55224
- if (opts.minThreads !== void 0 && opts.maxThreads !== void 0 && opts.minThreads > opts.maxThreads) {
55225
- throw new RangeError("options.minThreads and options.maxThreads must not conflict");
55226
- }
55227
- if (opts.idleTimeout !== void 0 && (typeof opts.idleTimeout !== "number" || opts.idleTimeout < 0)) {
55228
- throw new TypeError("options.idleTimeout must be a non-negative integer");
55229
- }
55230
- if (opts.maxQueue !== void 0 && opts.maxQueue !== "auto" && (typeof opts.maxQueue !== "number" || opts.maxQueue < 0)) {
55231
- throw new TypeError("options.maxQueue must be a non-negative integer");
55232
- }
55233
- if (opts.concurrentTasksPerWorker !== void 0 && (typeof opts.concurrentTasksPerWorker !== "number" || opts.concurrentTasksPerWorker < 1)) {
55234
- throw new TypeError("options.concurrentTasksPerWorker must be a positive integer");
55235
- }
55236
- if (opts.useAtomics !== void 0 && typeof opts.useAtomics !== "boolean") {
55237
- throw new TypeError("options.useAtomics must be a boolean value");
55238
- }
55239
- if (opts.resourceLimits !== void 0 && (typeof opts.resourceLimits !== "object" || opts.resourceLimits === null)) {
55240
- throw new TypeError("options.resourceLimits must be an object");
55241
- }
55242
- if (opts.taskQueue !== void 0 && !(0, task_queue_1.isTaskQueue)(opts.taskQueue)) {
55243
- throw new TypeError("options.taskQueue must be a TaskQueue object");
55244
- }
55245
- if (opts.niceIncrement !== void 0 && (typeof opts.niceIncrement !== "number" || opts.niceIncrement < 0 && process.platform !== "win32")) {
55246
- throw new TypeError("options.niceIncrement must be a non-negative integer on Unix systems");
55247
- }
55248
- if (opts.trackUnmanagedFds !== void 0 && typeof opts.trackUnmanagedFds !== "boolean") {
55249
- throw new TypeError("options.trackUnmanagedFds must be a boolean value");
55250
- }
55251
- if (opts.closeTimeout !== void 0 && (typeof opts.closeTimeout !== "number" || opts.closeTimeout < 0)) {
55252
- throw new TypeError("options.closeTimeout must be a non-negative integer");
55253
- }
55254
- __classPrivateFieldSet(this, _Piscina_pool, new ThreadPool(this, opts), "f");
55255
- }
55256
- /** @deprecated Use run(task, options) instead **/
55257
- runTask(task, transferList, filename, signal) {
55258
- if (typeof transferList === "object" && !Array.isArray(transferList) || typeof transferList === "string") {
55259
- signal = filename;
55260
- filename = transferList;
55261
- transferList = void 0;
55262
- }
55263
- if (typeof filename === "object" && !Array.isArray(filename)) {
55264
- signal = filename;
55265
- filename = void 0;
55266
- }
55267
- if (transferList !== void 0 && !Array.isArray(transferList)) {
55268
- return Promise.reject(new TypeError("transferList argument must be an Array"));
55269
- }
55270
- if (filename !== void 0 && typeof filename !== "string") {
55271
- return Promise.reject(new TypeError("filename argument must be a string"));
55272
- }
55273
- if (signal !== void 0 && typeof signal !== "object") {
55274
- return Promise.reject(new TypeError("signal argument must be an object"));
55275
- }
55276
- return __classPrivateFieldGet(this, _Piscina_pool, "f").runTask(task, {
55277
- transferList,
55278
- filename: filename || null,
55279
- name: "default",
55280
- signal: signal || null
55281
- });
55282
- }
55283
- run(task, options = kDefaultRunOptions) {
55284
- if (options === null || typeof options !== "object") {
55285
- return Promise.reject(new TypeError("options must be an object"));
55286
- }
55287
- const { transferList, filename, name, signal } = options;
55288
- if (transferList !== void 0 && !Array.isArray(transferList)) {
55289
- return Promise.reject(new TypeError("transferList argument must be an Array"));
55290
- }
55291
- if (filename != null && typeof filename !== "string") {
55292
- return Promise.reject(new TypeError("filename argument must be a string"));
55293
- }
55294
- if (name != null && typeof name !== "string") {
55295
- return Promise.reject(new TypeError("name argument must be a string"));
55296
- }
55297
- if (signal != null && typeof signal !== "object") {
55298
- return Promise.reject(new TypeError("signal argument must be an object"));
55299
- }
55300
- return __classPrivateFieldGet(this, _Piscina_pool, "f").runTask(task, { transferList, filename, name, signal });
55301
- }
55302
- async close(options = kDefaultCloseOptions) {
55303
- if (options === null || typeof options !== "object") {
55304
- throw TypeError("options must be an object");
55305
- }
55306
- let { force } = options;
55307
- if (force !== void 0 && typeof force !== "boolean") {
55308
- return Promise.reject(new TypeError("force argument must be a boolean"));
55309
- }
55310
- force !== null && force !== void 0 ? force : force = kDefaultCloseOptions.force;
55311
- return __classPrivateFieldGet(this, _Piscina_pool, "f").close({
55312
- force
55313
- });
55314
- }
55315
- destroy() {
55316
- return __classPrivateFieldGet(this, _Piscina_pool, "f").destroy();
55317
- }
55318
- get maxThreads() {
55319
- return __classPrivateFieldGet(this, _Piscina_pool, "f").options.maxThreads;
55320
- }
55321
- get minThreads() {
55322
- return __classPrivateFieldGet(this, _Piscina_pool, "f").options.minThreads;
55323
- }
55324
- get options() {
55325
- return __classPrivateFieldGet(this, _Piscina_pool, "f").options;
55326
- }
55327
- get threads() {
55328
- const ret = [];
55329
- for (const workerInfo of __classPrivateFieldGet(this, _Piscina_pool, "f").workers) {
55330
- ret.push(workerInfo.worker);
55331
- }
55332
- return ret;
55333
- }
55334
- get queueSize() {
55335
- const pool = __classPrivateFieldGet(this, _Piscina_pool, "f");
55336
- return Math.max(pool.taskQueue.size - pool.pendingCapacity(), 0);
55337
- }
55338
- get completed() {
55339
- return __classPrivateFieldGet(this, _Piscina_pool, "f").completed;
55340
- }
55341
- get waitTime() {
55342
- if (!__classPrivateFieldGet(this, _Piscina_pool, "f").waitTime) {
55343
- return null;
55344
- }
55345
- return (0, common_1.createHistogramSummary)(__classPrivateFieldGet(this, _Piscina_pool, "f").waitTime);
55346
- }
55347
- get runTime() {
55348
- if (!__classPrivateFieldGet(this, _Piscina_pool, "f").runTime) {
55349
- return null;
55350
- }
55351
- return (0, common_1.createHistogramSummary)(__classPrivateFieldGet(this, _Piscina_pool, "f").runTime);
55352
- }
55353
- get utilization() {
55354
- if (!__classPrivateFieldGet(this, _Piscina_pool, "f").runTime) {
55355
- return 0;
55356
- }
55357
- const count = __classPrivateFieldGet(this, _Piscina_pool, "f").runTime.count;
55358
- if (count === 0) {
55359
- return 0;
55360
- }
55361
- const capacity = this.duration * __classPrivateFieldGet(this, _Piscina_pool, "f").options.maxThreads;
55362
- const totalMeanRuntime = __classPrivateFieldGet(this, _Piscina_pool, "f").runTime.mean / 1e3 * count;
55363
- return totalMeanRuntime / capacity;
55364
- }
55365
- get duration() {
55366
- return node_perf_hooks_1.performance.now() - __classPrivateFieldGet(this, _Piscina_pool, "f").start;
55367
- }
55368
- get needsDrain() {
55369
- return __classPrivateFieldGet(this, _Piscina_pool, "f").needsDrain;
55370
- }
55371
- static get isWorkerThread() {
55372
- return common_1.commonState.isWorkerThread;
55373
- }
55374
- static get workerData() {
55375
- return common_1.commonState.workerData;
55376
- }
55377
- static get version() {
55378
- return package_json_1.version;
55379
- }
55380
- static get Piscina() {
55381
- return _Piscina;
55382
- }
55383
- static get FixedQueue() {
55384
- return task_queue_1.FixedQueue;
55385
- }
55386
- static get ArrayTaskQueue() {
55387
- return task_queue_1.ArrayTaskQueue;
55388
- }
55389
- static move(val) {
55390
- if (val != null && typeof val === "object" && typeof val !== "function") {
55391
- if (!(0, common_1.isTransferable)(val)) {
55392
- if (node_util_1.types.isArrayBufferView(val)) {
55393
- val = new ArrayBufferViewTransferable(val);
55394
- } else {
55395
- val = new DirectlyTransferable(val);
55396
- }
55397
- }
55398
- (0, common_1.markMovable)(val);
55399
- }
55400
- return val;
55401
- }
55402
- static get transferableSymbol() {
55403
- return symbols_1.kTransferable;
55404
- }
55405
- static get valueSymbol() {
55406
- return symbols_1.kValue;
55407
- }
55408
- static get queueOptionsSymbol() {
55409
- return symbols_1.kQueueOptions;
55410
- }
55411
- };
55412
- exports.Piscina = Piscina2;
55413
- _Piscina_pool = /* @__PURE__ */ new WeakMap();
55414
- exports.default = Piscina2;
55415
- exports.move = Piscina2.move;
55416
- exports.isWorkerThread = Piscina2.isWorkerThread;
55417
- exports.workerData = Piscina2.workerData;
55418
- }
55419
- });
55420
-
55421
- // node_modules/piscina/dist/main.js
55422
- var require_main = __commonJS({
55423
- "node_modules/piscina/dist/main.js"(exports, module2) {
55424
- "use strict";
55425
- var __importDefault = exports && exports.__importDefault || function(mod2) {
55426
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
55427
- };
55428
- var index_1 = __importDefault(require_dist());
55429
- module2.exports = index_1.default;
55430
- }
55431
- });
55432
-
55433
- // node_modules/piscina/dist/esm-wrapper.mjs
55434
- var import_main, ArrayTaskQueue, FixedQueue, Piscina, isWorkerThread, move, queueOptionsSymbol, transferableSymbol, valueSymbol, version2, workerData2;
55435
- var init_esm_wrapper = __esm({
55436
- "node_modules/piscina/dist/esm-wrapper.mjs"() {
55437
- import_main = __toESM(require_main(), 1);
55438
- ArrayTaskQueue = import_main.default.ArrayTaskQueue;
55439
- FixedQueue = import_main.default.FixedQueue;
55440
- Piscina = import_main.default.Piscina;
55441
- isWorkerThread = import_main.default.isWorkerThread;
55442
- move = import_main.default.move;
55443
- queueOptionsSymbol = import_main.default.queueOptionsSymbol;
55444
- transferableSymbol = import_main.default.transferableSymbol;
55445
- valueSymbol = import_main.default.valueSymbol;
55446
- version2 = import_main.default.version;
55447
- workerData2 = import_main.default.workerData;
55448
- }
55449
- });
55450
-
55451
54203
  // dist/worker/nativeWorkerPool.js
55452
54204
  var nativeWorkerPool_exports = {};
55453
54205
  __export(nativeWorkerPool_exports, {
@@ -55460,6 +54212,7 @@ import os6 from "node:os";
55460
54212
  import fs21 from "node:fs";
55461
54213
  import { fileURLToPath as fileURLToPath4 } from "node:url";
55462
54214
  import path46 from "node:path";
54215
+ import { Piscina } from "piscina";
55463
54216
  function defaultNativeWorkerThreadCount(availableParallelism = os6.availableParallelism()) {
55464
54217
  return Math.min(DEFAULT_NATIVE_THREAD_CAP, Math.max(1, Math.floor(availableParallelism * 0.75)));
55465
54218
  }
@@ -55503,7 +54256,6 @@ var HARD_MAX_THREADS, DEFAULT_NATIVE_THREAD_CAP;
55503
54256
  var init_nativeWorkerPool = __esm({
55504
54257
  "dist/worker/nativeWorkerPool.js"() {
55505
54258
  "use strict";
55506
- init_esm_wrapper();
55507
54259
  init_workerThreads();
55508
54260
  init_windowsProcessDrain();
55509
54261
  HARD_MAX_THREADS = 64;
@@ -55925,10 +54677,10 @@ function isConfinedFileReadError(error51) {
55925
54677
  function createEmptyModuleIndex(file2) {
55926
54678
  return { file: file2, exports: [], imports: [], locals: [] };
55927
54679
  }
55928
- async function resolveCrossModuleSymbolExports(file2, mod2, support, projectRoot, graphOptions, workspaceConfig, matchPath) {
54680
+ async function resolveCrossModuleSymbolExports(file2, mod, support, projectRoot, graphOptions, workspaceConfig, matchPath) {
55929
54681
  if (!support.supportsCrossModuleSymbols || !isJsTsLanguage(support.id))
55930
54682
  return;
55931
- const reexports = mod2.exports.filter((entry) => entry.type === "reexport" || entry.type === "exportStar" || entry.type === "namespaceReexport");
54683
+ const reexports = mod.exports.filter((entry) => entry.type === "reexport" || entry.type === "exportStar" || entry.type === "namespaceReexport");
55932
54684
  if (!reexports.length)
55933
54685
  return;
55934
54686
  for (const entry of reexports) {
@@ -56016,30 +54768,30 @@ async function buildIndexedModuleForFile(args) {
56016
54768
  }));
56017
54769
  }
56018
54770
  collectJsonDependencies(imports, args.jsonDependencies);
56019
- let mod2;
54771
+ let mod;
56020
54772
  if (sup.id === "sql") {
56021
- mod2 = buildSqlModuleIndex(args.file, source);
54773
+ mod = buildSqlModuleIndex(args.file, source);
56022
54774
  } else if (lacksParserContext) {
56023
- mod2 = { ...createEmptyModuleIndex(args.file), imports };
54775
+ mod = { ...createEmptyModuleIndex(args.file), imports };
56024
54776
  } else {
56025
- mod2 = collectLocalsAndExportsFromSource(args.file, source, sup, imports, {
54777
+ mod = collectLocalsAndExportsFromSource(args.file, source, sup, imports, {
56026
54778
  ...tree ? { tree } : {},
56027
54779
  ...nativeQueries !== void 0 ? { nativeQueries } : {},
56028
54780
  ...args.opts?.native ? { nativeMode: args.opts.native } : {},
56029
54781
  ...args.opts?.logLevel ? { logLevel: args.opts.logLevel } : {}
56030
54782
  });
56031
54783
  }
56032
- mod2.imports = imports;
56033
- await resolveCrossModuleSymbolExports(args.file, mod2, sup, args.projectRoot, args.graphOptions, args.workspaceConfig, args.matchPath);
54784
+ mod.imports = imports;
54785
+ await resolveCrossModuleSymbolExports(args.file, mod, sup, args.projectRoot, args.graphOptions, args.workspaceConfig, args.matchPath);
56034
54786
  const sigInfo = args.fileSignatures.get(args.file);
56035
54787
  const cacheable = !prepared.nativeFallbackReason && !lacksParserContext;
56036
54788
  let cacheWrite;
56037
54789
  if (sigInfo && cacheable) {
56038
54790
  const cacheSig = args.cacheEnabled ? await moduleCacheSignatureForFile(args.file, sigInfo, args.opts, args.resolverEnvironmentFingerprint) : sigInfo.cacheSig;
56039
- cacheWrite = { file: args.file, sig: cacheSig, mod: mod2 };
54791
+ cacheWrite = { file: args.file, sig: cacheSig, mod };
56040
54792
  }
56041
54793
  return {
56042
- module: mod2,
54794
+ module: mod,
56043
54795
  ...cacheWrite !== void 0 ? { cacheWrite } : {},
56044
54796
  graphContext: {
56045
54797
  source,
@@ -56125,7 +54877,9 @@ function createIndexBuildRunState(projectRoot, opts, graphOptions = normalizeGra
56125
54877
  normalizedProjectRoot: normalizePath(path47.resolve(projectRoot)),
56126
54878
  report,
56127
54879
  timings: report?.timings,
56128
- totalStart: performance7.now(),
54880
+ // Delegated rebuilds mint a fresh run state after the preamble; reuse the caller's
54881
+ // origin so totalMs covers the whole wait, matching progress completion.
54882
+ totalStart: opts?.progressStartedAt ?? performance7.now(),
56129
54883
  cacheMode,
56130
54884
  cacheEnabled: cacheMode !== "off",
56131
54885
  graphOptions,
@@ -56226,6 +54980,12 @@ function recordBuildTimingStep(timings, step) {
56226
54980
  if (step.name === "filesystem-scan")
56227
54981
  timings.filesystemScanMs = step.ms;
56228
54982
  }
54983
+ async function recordTimedBuildStep(timings, name, fn) {
54984
+ const startedAt = performance7.now();
54985
+ const result = await fn();
54986
+ recordBuildTimingStep(timings, { name, ms: Math.round(performance7.now() - startedAt) });
54987
+ return result;
54988
+ }
56229
54989
  function buildConcurrency(opts) {
56230
54990
  return resolveWorkerThreadCount({ requested: Number(opts?.threads || 0), defaultCount: 8, max: 64 });
56231
54991
  }
@@ -56375,8 +55135,8 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56375
55135
  }
56376
55136
  const cacheSig = cacheEnabled ? await moduleCacheSignatureForFile(file2, sigInfo, opts, resolverEnvironmentFingerprint) : sigInfo.cacheSig;
56377
55137
  const canReuseModuleCache = cacheEnabled && (!graphOptions.resolveNodeModules || resolverEnvironmentFingerprint !== null);
56378
- const mod2 = canReuseModuleCache ? tryLoadFromCache(projectRoot, file2, cacheSig, opts, report, moduleCacheAvailable) : null;
56379
- return [file2, { sigInfo, mod: mod2 }];
55138
+ const mod = canReuseModuleCache ? tryLoadFromCache(projectRoot, file2, cacheSig, opts, report, moduleCacheAvailable) : null;
55139
+ return [file2, { sigInfo, mod }];
56380
55140
  } catch (error51) {
56381
55141
  return [file2, { error: error51 }];
56382
55142
  } finally {
@@ -56433,15 +55193,15 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56433
55193
  if ("error" in cacheProbe)
56434
55194
  throw cacheProbe.error;
56435
55195
  const { sigInfo } = cacheProbe;
56436
- let mod2 = cacheProbe.mod;
56437
- if (mod2 && fileReport) {
55196
+ let mod = cacheProbe.mod;
55197
+ if (mod && fileReport) {
56438
55198
  fileReport.cached = (fileReport.cached ?? 0) + 1;
56439
55199
  }
56440
55200
  const cachedEdgesEntry = cachedGraphEntries?.get(file2);
56441
55201
  const edgesCached = !!cachedEdgesEntry && (cachedEdgesEntry.gitSig && cachedEdgesEntry.gitSig === sigInfo.gitSig || cachedEdgesEntry.sig === sigInfo.sig);
56442
55202
  const sqlFactCache = shouldProvideSqlFactCache(file2, sigInfo, cachedEdgesEntry) ? await getSqlFactCache() : void 0;
56443
55203
  let edges = [];
56444
- if (mod2 && edgesCached) {
55204
+ if (mod && edgesCached) {
56445
55205
  edges = await collectEdgesForFile(file2, projectRoot, workspaceConfig, {
56446
55206
  fast: !!graphOptions.fast,
56447
55207
  ...graphOptions.fastRegexDisabledLanguages ? { fastRegexDisabledLanguages: graphOptions.fastRegexDisabledLanguages } : {},
@@ -56470,7 +55230,7 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56470
55230
  bloomFilterCache.set(file2, filter);
56471
55231
  }
56472
55232
  }
56473
- return [file2, mod2, edges, void 0];
55233
+ return [file2, mod, edges, void 0];
56474
55234
  }
56475
55235
  if (fileReport)
56476
55236
  fileReport.parsed = (fileReport.parsed ?? 0) + 1;
@@ -56481,7 +55241,7 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56481
55241
  let graphContext;
56482
55242
  let cacheWrite;
56483
55243
  const matchPath = support.id === "ts" || support.id === "tsx" ? await loadMatchPathForFile(file2) : void 0;
56484
- if (!mod2) {
55244
+ if (!mod) {
56485
55245
  const built = await buildIndexedModuleForFile({
56486
55246
  file: file2,
56487
55247
  support,
@@ -56502,11 +55262,11 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56502
55262
  cacheEnabled,
56503
55263
  ...confinedRoot ? { confinedRoot, trustedSource: trustedSources?.get(file2) } : {}
56504
55264
  });
56505
- mod2 = built.module;
55265
+ mod = built.module;
56506
55266
  graphContext = built.graphContext;
56507
55267
  cacheWrite = built.cacheWrite;
56508
55268
  } else {
56509
- collectJsonDependencies(mod2.imports, jsonDependencies);
55269
+ collectJsonDependencies(mod.imports, jsonDependencies);
56510
55270
  }
56511
55271
  edges = await collectEdgesForFile(file2, projectRoot, workspaceConfig, {
56512
55272
  ...graphContext ? { parsed: graphContext } : {},
@@ -56527,7 +55287,7 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56527
55287
  allFiles: normalizedFiles,
56528
55288
  ...sqlFactCache ? { sqlFactCache } : {}
56529
55289
  });
56530
- return [file2, mod2 ?? createEmptyModuleIndex(file2), edges, cacheWrite];
55290
+ return [file2, mod ?? createEmptyModuleIndex(file2), edges, cacheWrite];
56531
55291
  } catch (error51) {
56532
55292
  if (isNativeRequiredUnavailableError(error51) || isNodeSqliteUnavailableError(error51))
56533
55293
  throw error51;
@@ -56571,8 +55331,8 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56571
55331
  }
56572
55332
  };
56573
55333
  const pendingCacheWrites = [];
56574
- for (const [file2, mod2, edges, cacheWrite] of fileResults) {
56575
- modules.set(fileIdentityKey(file2), mod2);
55334
+ for (const [file2, mod, edges, cacheWrite] of fileResults) {
55335
+ modules.set(fileIdentityKey(file2), mod);
56576
55336
  appendUniqueGraphEdges(edges);
56577
55337
  if (cacheWrite)
56578
55338
  pendingCacheWrites.push(cacheWrite);
@@ -56638,6 +55398,7 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56638
55398
  files: manifestEntries,
56639
55399
  timings,
56640
55400
  manifestReport: report?.manifest,
55401
+ ...helperOpts?.configHash ? { configHash: helperOpts.configHash } : {},
56641
55402
  ...helperOpts?.transientFiles !== void 0 ? { transientFiles: helperOpts.transientFiles } : {},
56642
55403
  ...helperOpts?.symlinkDirectories !== void 0 ? { symlinkDirectories: helperOpts.symlinkDirectories } : {}
56643
55404
  })
@@ -56647,29 +55408,31 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56647
55408
  const cacheSig = fileSignatures.get(file2)?.cacheSig;
56648
55409
  return [file2, { ...entry, ...cacheSig ? { cacheSig } : {} }];
56649
55410
  })) : manifestEntriesForIndex;
56650
- const index = await timeIndexBuildPhase({
55411
+ const discoveredInsideFinalize = projectFiles === void 0;
55412
+ const finalizeStartedAt = performance7.now();
55413
+ if (buildStartedAt !== void 0) {
55414
+ emitIndexBuildActivity(opts, "Finalizing project graph", totalFiles, totalFiles);
55415
+ }
55416
+ const index = await finalizeProjectIndex({
55417
+ projectRoot,
55418
+ normalizedProjectRoot,
56651
55419
  opts,
56652
55420
  timings,
56653
- buildStartedAt,
56654
- stepName: "finalize",
56655
- activity: "Finalizing project graph",
56656
- current: totalFiles,
56657
- total: totalFiles,
56658
- fn: () => finalizeProjectIndex({
56659
- projectRoot,
56660
- normalizedProjectRoot,
56661
- opts,
56662
- timings,
56663
- totalStart,
56664
- graph,
56665
- modules,
56666
- parsedMap,
56667
- bloomFilterCache,
56668
- ...projectFiles !== void 0 ? { projectFiles } : {},
56669
- buildReport: report,
56670
- manifestEntries: indexManifestEntries
56671
- })
56672
- });
55421
+ totalStart,
55422
+ graph,
55423
+ modules,
55424
+ parsedMap,
55425
+ bloomFilterCache,
55426
+ ...projectFiles !== void 0 ? { projectFiles } : {},
55427
+ buildReport: report,
55428
+ manifestEntries: indexManifestEntries
55429
+ });
55430
+ if (timings) {
55431
+ const elapsed = Math.round(performance7.now() - finalizeStartedAt);
55432
+ const discoveryMs = discoveredInsideFinalize ? timings.metadataDiscoveryMs ?? 0 : 0;
55433
+ const finalizeMs = discoveredInsideFinalize ? Math.max(0, elapsed - discoveryMs) : elapsed;
55434
+ recordBuildTimingStep(timings, { name: "finalize", ms: finalizeMs });
55435
+ }
56673
55436
  if (manifestEntries) {
56674
55437
  await timeIndexBuildPhase({
56675
55438
  opts,
@@ -56693,7 +55456,6 @@ async function buildIndexFromFileListShared(projectRoot, rawFiles, opts, helperO
56693
55456
  }
56694
55457
  async function buildProjectIndexWithManifestOptions(projectRoot, opts, helperOpts) {
56695
55458
  const timings = opts?.report ? opts.report.timings ??= {} : void 0;
56696
- resetTransientBuildTimings(timings);
56697
55459
  await initializeFileIdentityCaseSensitivity(projectRoot);
56698
55460
  try {
56699
55461
  const useDiskCache = (opts?.cache ?? "off") === "disk";
@@ -56752,6 +55514,7 @@ async function buildProjectIndexWithManifestOptions(projectRoot, opts, helperOpt
56752
55514
  warnNoFilesMessage: `Warning: No files found in project root: ${projectRoot}. Check codegraph.config.json globs and CLI --include-glob/--ignore-glob filters. Diagnostic: codegraph doctor`,
56753
55515
  ...helperOpts?.ignoreExistingManifest ? { ignoreExistingManifest: true } : {},
56754
55516
  ...helperOpts?.reportDiscoveryProgress ? { reportDiscoveryProgress: true } : {},
55517
+ ...helperOpts?.configHash ? { configHash: helperOpts.configHash } : {},
56755
55518
  projectFiles,
56756
55519
  transientFiles,
56757
55520
  ...discoveredSymlinkDirectories !== void 0 ? { symlinkDirectories: discoveredSymlinkDirectories } : {}
@@ -56764,13 +55527,18 @@ async function buildProjectIndexWithManifestOptions(projectRoot, opts, helperOpt
56764
55527
  }
56765
55528
  }
56766
55529
  async function buildProjectIndex(projectRoot, opts) {
55530
+ const progressStartedAt = opts?.progressStartedAt ?? performance7.now();
55531
+ const timings = opts?.report ? opts.report.timings ??= {} : void 0;
55532
+ resetTransientBuildTimings(timings);
56767
55533
  return buildProjectIndexWithManifestOptions(projectRoot, {
56768
55534
  ...opts,
56769
- progressStartedAt: opts?.progressStartedAt ?? performance7.now()
55535
+ progressStartedAt
56770
55536
  });
56771
55537
  }
56772
55538
  async function buildProjectIndexFromFiles(projectRoot, inputFiles, rawOpts) {
56773
55539
  const opts = { ...rawOpts, progressStartedAt: rawOpts?.progressStartedAt ?? performance7.now() };
55540
+ const timings = opts.report ? opts.report.timings ??= {} : void 0;
55541
+ resetTransientBuildTimings(timings);
56774
55542
  try {
56775
55543
  const useDiskCache = (opts?.cache ?? "off") === "disk";
56776
55544
  const normalizedInputFiles = await normalizeIndexedFileInputsWithinRoot(projectRoot, inputFiles, "Index file");
@@ -56804,15 +55572,17 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56804
55572
  ...rawOpts,
56805
55573
  progressStartedAt: rawOpts?.progressStartedAt ?? performance7.now()
56806
55574
  };
56807
- await initializeFileIdentityCaseSensitivity(projectRoot);
56808
- clearResolutionCaches();
55575
+ const discoveryTimings = opts.report ? opts.report.timings ??= {} : void 0;
55576
+ resetTransientBuildTimings(discoveryTimings);
55577
+ await recordTimedBuildStep(discoveryTimings, "file-identity", () => initializeFileIdentityCaseSensitivity(projectRoot));
55578
+ await recordTimedBuildStep(discoveryTimings, "clear-resolution-caches", () => {
55579
+ clearResolutionCaches();
55580
+ });
56809
55581
  const graphOptions = normalizeGraphOptions(opts?.graph);
56810
55582
  const strictIncremental = opts?.incrementalStrict ?? false;
56811
55583
  if (strictIncremental && graphOptions.fast)
56812
55584
  graphOptions.fast = false;
56813
55585
  const { normalizedProjectRoot, report, timings, totalStart, cacheMode, cacheEnabled, onFallbackImportExtraction } = createIndexBuildRunState(projectRoot, opts, graphOptions);
56814
- const discoveryTimings = opts?.report ? opts.report.timings ??= {} : void 0;
56815
- resetTransientBuildTimings(discoveryTimings);
56816
55586
  let checkProgressActive = false;
56817
55587
  const startCheckProgress = () => {
56818
55588
  if (checkProgressActive)
@@ -56854,14 +55624,14 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56854
55624
  }
56855
55625
  startCheckProgress();
56856
55626
  const manifestStart = performance7.now();
56857
- const manifest = await loadManifest(projectRoot, opts, report);
55627
+ const manifest = await recordTimedBuildStep(timings, "load-manifest", () => loadManifest(projectRoot, opts, report));
56858
55628
  if (timings)
56859
55629
  timings.manifestMs = Math.round(performance7.now() - manifestStart);
56860
55630
  const manifestUsed = !!manifest;
56861
55631
  const manifestReport = initManifestReport(report, manifestUsed, false);
56862
55632
  if (manifestReport && !manifestUsed)
56863
55633
  manifestReport.reason = "missing";
56864
- const optionDiffs = diffBuildOptions(manifest?.buildOptions, opts);
55634
+ const optionDiffs = await recordTimedBuildStep(timings, "diff-build-options", () => diffBuildOptions(manifest?.buildOptions, opts));
56865
55635
  const warningOptionDiffs = optionDiffs.filter((diff) => diff !== "cache");
56866
55636
  if (manifest && warningOptionDiffs.length) {
56867
55637
  logWithLevel(opts?.logLevel, "warn", `Warning: Manifest options differ from current build options: ${warningOptionDiffs.join(", ")}`);
@@ -56869,7 +55639,7 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56869
55639
  if (manifestReport && optionDiffs.length) {
56870
55640
  manifestReport.optionsMismatch = optionDiffs;
56871
55641
  }
56872
- const currentConfigHashResult = await computeConfigHash(projectRoot, opts?.logLevel);
55642
+ const currentConfigHashResult = await recordTimedBuildStep(timings, "config-hash", () => computeConfigHash(projectRoot, opts?.logLevel));
56873
55643
  const currentConfigHash = recordConfigHashResult(manifestReport, currentConfigHashResult, opts?.logLevel);
56874
55644
  const configChanged = !!currentConfigHashResult.error || !manifest?.configHash || currentConfigHash !== manifest.configHash;
56875
55645
  let resolverEnvironmentFingerprint;
@@ -56898,7 +55668,8 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56898
55668
  }
56899
55669
  return await buildProjectIndexFromExport(projectRoot, opts, {
56900
55670
  ignoreExistingManifest: true,
56901
- reportDiscoveryProgress: true
55671
+ reportDiscoveryProgress: true,
55672
+ configHash: currentConfigHashResult
56902
55673
  });
56903
55674
  }
56904
55675
  const gitAvailable = await isGitRepo(projectRoot);
@@ -56940,7 +55711,8 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56940
55711
  logWithLevel(opts?.logLevel, "warn", "Warning: Manifest commit is no longer available; rebuilding full index.");
56941
55712
  const rebuiltIndex = await buildProjectIndexFromExport(projectRoot, opts, {
56942
55713
  ignoreExistingManifest: true,
56943
- reportDiscoveryProgress: true
55714
+ reportDiscoveryProgress: true,
55715
+ configHash: currentConfigHashResult
56944
55716
  });
56945
55717
  if (manifestReport) {
56946
55718
  manifestReport.reason = "staleGitCommit";
@@ -56961,7 +55733,8 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56961
55733
  logWithLevel(opts?.logLevel, "warn", `Warning: Manifest verification failed (mismatches: ${mismatches}, missing: ${missing}). Rebuilding full index.`);
56962
55734
  return await buildProjectIndexFromExport(projectRoot, opts, {
56963
55735
  ignoreExistingManifest: true,
56964
- reportDiscoveryProgress: true
55736
+ reportDiscoveryProgress: true,
55737
+ configHash: currentConfigHashResult
56965
55738
  });
56966
55739
  }
56967
55740
  }
@@ -56997,7 +55770,8 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
56997
55770
  logWithLevel(opts?.logLevel, "warn", "Warning: Failed to list untracked project files via Git; rebuilding full index.", error51);
56998
55771
  return await buildProjectIndexFromExport(projectRoot, opts, {
56999
55772
  ignoreExistingManifest: true,
57000
- reportDiscoveryProgress: true
55773
+ reportDiscoveryProgress: true,
55774
+ configHash: currentConfigHashResult
57001
55775
  });
57002
55776
  }
57003
55777
  } else if (!opts?.filesAreProjectScope) {
@@ -57054,17 +55828,27 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
57054
55828
  const dependentFilesOfDeletedTracked = collectDeletedTrackedFileDependents(trackedEntries, deletedTrackedFiles);
57055
55829
  if (allFiles.size === 0) {
57056
55830
  completeCheckProgress(0);
57057
- await writeIndexManifestSnapshot({
57058
- projectRoot,
55831
+ await timeIndexBuildPhase({
57059
55832
  opts,
57060
- graphOptions,
57061
- ...resolverEnvironmentFingerprint ? { resolverEnvironmentFingerprint } : {},
57062
- files: {},
57063
55833
  timings,
57064
- manifestReport,
57065
- allowEmpty: true,
57066
- transientFiles,
57067
- ...manifest.symlinkDirectories !== void 0 ? { symlinkDirectories: manifest.symlinkDirectories } : {}
55834
+ buildStartedAt: void 0,
55835
+ stepName: "index-manifest",
55836
+ activity: "Writing index manifest",
55837
+ current: 0,
55838
+ total: 0,
55839
+ fn: () => writeIndexManifestSnapshot({
55840
+ projectRoot,
55841
+ opts,
55842
+ graphOptions,
55843
+ ...resolverEnvironmentFingerprint ? { resolverEnvironmentFingerprint } : {},
55844
+ files: {},
55845
+ timings,
55846
+ manifestReport,
55847
+ allowEmpty: true,
55848
+ transientFiles,
55849
+ configHash: currentConfigHashResult,
55850
+ ...manifest.symlinkDirectories !== void 0 ? { symlinkDirectories: manifest.symlinkDirectories } : {}
55851
+ })
57068
55852
  });
57069
55853
  return {
57070
55854
  graph: { nodes: /* @__PURE__ */ new Set(), edges: [] },
@@ -57331,8 +56115,8 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
57331
56115
  }
57332
56116
  });
57333
56117
  const pendingIncrementalCacheWrites = [];
57334
- for (const [file2, mod2, cacheWrite] of fileResults) {
57335
- modules.set(fileIdentityKey(file2), mod2);
56118
+ for (const [file2, mod, cacheWrite] of fileResults) {
56119
+ modules.set(fileIdentityKey(file2), mod);
57336
56120
  if (cacheWrite)
57337
56121
  pendingIncrementalCacheWrites.push(cacheWrite);
57338
56122
  }
@@ -57418,16 +56202,27 @@ async function buildProjectIndexIncremental(projectRoot, rawOpts) {
57418
56202
  ...signature.gitSig ? { gitSig: signature.gitSig } : {}
57419
56203
  });
57420
56204
  }
57421
- await writeIndexManifestSnapshot({
57422
- projectRoot,
56205
+ await timeIndexBuildPhase({
57423
56206
  opts,
57424
- graphOptions,
57425
- ...resolverEnvironmentFingerprint ? { resolverEnvironmentFingerprint } : {},
57426
- files: manifestEntries,
57427
56207
  timings,
57428
- manifestReport,
57429
- transientFiles,
57430
- ...manifest.symlinkDirectories !== void 0 ? { symlinkDirectories: manifest.symlinkDirectories } : {}
56208
+ buildStartedAt: updateStartedAt,
56209
+ stepName: "index-manifest",
56210
+ activity: "Writing index manifest",
56211
+ current: allFiles.size,
56212
+ total: allFiles.size,
56213
+ mode: "update",
56214
+ fn: () => writeIndexManifestSnapshot({
56215
+ projectRoot,
56216
+ opts,
56217
+ graphOptions,
56218
+ ...resolverEnvironmentFingerprint ? { resolverEnvironmentFingerprint } : {},
56219
+ files: manifestEntries,
56220
+ timings,
56221
+ manifestReport,
56222
+ transientFiles,
56223
+ configHash: currentConfigHashResult,
56224
+ ...manifest.symlinkDirectories !== void 0 ? { symlinkDirectories: manifest.symlinkDirectories } : {}
56225
+ })
57431
56226
  });
57432
56227
  const index = await finalizeProjectIndex({
57433
56228
  projectRoot,
@@ -57661,6 +56456,16 @@ var init_build_index = __esm({
57661
56456
  "persist-cache": true,
57662
56457
  "workspace-manifests": true,
57663
56458
  "index-manifest": true,
56459
+ "file-identity": true,
56460
+ "clear-resolution-caches": true,
56461
+ "load-manifest": true,
56462
+ "diff-build-options": true,
56463
+ "git-head": true,
56464
+ "config-hash": true,
56465
+ "manifest-transform": true,
56466
+ "manifest-write": true,
56467
+ "cache-prune": true,
56468
+ "metadata-discovery": true,
57664
56469
  finalize: true,
57665
56470
  "snapshot-write": true
57666
56471
  };
@@ -58036,7 +56841,7 @@ var init_navigation_provenance = __esm({
58036
56841
 
58037
56842
  // dist/indexer/navigation-goto.js
58038
56843
  async function resolveMemberAccessDefinition(params) {
58039
- const { index, mod: mod2, node, source, sup, resolveLexicalBinding } = params;
56844
+ const { index, mod, node, source, sup, resolveLexicalBinding } = params;
58040
56845
  const parent = node.parent;
58041
56846
  if (!parent || !sup.supportsCrossModuleSymbols || !isMemberAccessNode(sup, parent)) {
58042
56847
  return null;
@@ -58051,7 +56856,7 @@ async function resolveMemberAccessDefinition(params) {
58051
56856
  if (lexicalBinding)
58052
56857
  return { kind: "resolved", def: lexicalBinding };
58053
56858
  const exprName = sliceText(expr, source);
58054
- const imp = mod2.imports.find((candidate) => candidate.kind === "named" && candidate.local === exprName || candidate.kind === "default" && candidate.local === exprName || candidate.kind === "namespace" && candidate.localNS === exprName);
56859
+ const imp = mod.imports.find((candidate) => candidate.kind === "named" && candidate.local === exprName || candidate.kind === "default" && candidate.local === exprName || candidate.kind === "namespace" && candidate.localNS === exprName);
58055
56860
  if (imp) {
58056
56861
  if (imp.kind === "namespace") {
58057
56862
  return {
@@ -58067,10 +56872,10 @@ async function resolveMemberAccessDefinition(params) {
58067
56872
  return { kind: "resolved", def: result };
58068
56873
  }
58069
56874
  }
58070
- const local = mod2.locals.find((candidate) => candidate.localName === exprName);
56875
+ const local = mod.locals.find((candidate) => candidate.localName === exprName);
58071
56876
  if (local)
58072
56877
  return { kind: "resolved", def: local };
58073
- for (const starImport of mod2.imports.filter((candidate) => candidate.kind === "star")) {
56878
+ for (const starImport of mod.imports.filter((candidate) => candidate.kind === "star")) {
58074
56879
  const result = resolveImported(index, starImport, exprName);
58075
56880
  if (result) {
58076
56881
  if ("namespace" in result) {
@@ -58155,7 +56960,7 @@ async function resolveMemberAccessDefinition(params) {
58155
56960
  const member = sliceText(prop, source);
58156
56961
  if (!sup.membersAreImplicitlyInScope && implicitClassReceiver) {
58157
56962
  const classContainer = findEnclosingClassContainer(node);
58158
- const memberDef = classContainer ? findLocalWithinNode(mod2.locals, member, classContainer, sup.normalizeIdentifier) : void 0;
56963
+ const memberDef = classContainer ? findLocalWithinNode(mod.locals, member, classContainer, sup.normalizeIdentifier) : void 0;
58159
56964
  if (memberDef) {
58160
56965
  return okGoToResult(index, memberDef, {
58161
56966
  via: { exportedName: member },
@@ -60606,6 +59411,7 @@ function codegraphLifecycleManifestPath(root) {
60606
59411
  return path51.join(root, CODEGRAPH_DIR, MANIFEST_FILE);
60607
59412
  }
60608
59413
  async function initCodegraphLifecycle(root, options = {}) {
59414
+ emitLifecyclePostBuildProgress(options.buildOptions, "Updating Git ignore policy");
60609
59415
  const gitignore = await prepareCodegraphLifecycleGitignore(root, {
60610
59416
  updateGitignore: options.updateGitignore ?? true
60611
59417
  });
@@ -60627,9 +59433,13 @@ async function initCodegraphLifecycle(root, options = {}) {
60627
59433
  return await syncCodegraphLifecycleCore(root, { ...options, init: true }, existing, gitignore);
60628
59434
  }
60629
59435
  async function syncCodegraphLifecycle(root, options = {}) {
60630
- const gitignore = options.init ? await prepareCodegraphLifecycleGitignore(root, {
60631
- updateGitignore: options.updateGitignore ?? true
60632
- }) : void 0;
59436
+ let gitignore;
59437
+ if (options.init) {
59438
+ emitLifecyclePostBuildProgress(options.buildOptions, "Updating Git ignore policy");
59439
+ gitignore = await prepareCodegraphLifecycleGitignore(root, {
59440
+ updateGitignore: options.updateGitignore ?? true
59441
+ });
59442
+ }
60633
59443
  const existing = await readLifecycleManifest(root, { allowInvalid: Boolean(options.init && options.force) });
60634
59444
  return await syncCodegraphLifecycleCore(root, options, existing, gitignore);
60635
59445
  }
@@ -60638,6 +59448,7 @@ async function syncCodegraphLifecycleCore(root, options, existing, gitignore) {
60638
59448
  throw new CodegraphLifecycleUserError("Codegraph is not initialized for this project. Run codegraph init or codegraph sync --init.");
60639
59449
  }
60640
59450
  const manifest = await buildLifecycleManifest(root, options.buildOptions, existing, options.force ? { force: true } : {});
59451
+ emitLifecyclePostBuildProgress(options.buildOptions, "Writing lifecycle manifest");
60641
59452
  await writeLifecycleManifest(root, manifest);
60642
59453
  const thenCount = existing?.fileCount ?? 0;
60643
59454
  const fallbackTotalDelta = manifest.fileCount - thenCount;
@@ -60724,20 +59535,31 @@ async function uninitCodegraphLifecycle(root, options = {}) {
60724
59535
  }
60725
59536
  async function buildLifecycleManifest(root, buildOptions, existing, options = {}) {
60726
59537
  const now = (/* @__PURE__ */ new Date()).toISOString();
60727
- const sessionBuildOptions = { ...buildOptions ?? {}, cache: "disk" };
59538
+ const sessionBuildOptions = {
59539
+ ...withIndexTeardownProgress(buildOptions),
59540
+ cache: "disk"
59541
+ };
60728
59542
  const forcedSessionBuildOptions = options.force ? { ...sessionBuildOptions, cacheStrict: true, cacheVerify: true } : sessionBuildOptions;
60729
59543
  const session = createAgentSession({ root, buildOptions: forcedSessionBuildOptions });
60730
59544
  const snapshot = await session.loadProject({ symbolGraph: "skip" });
59545
+ const configHash = await resolveLifecycleConfigHash(root, sessionBuildOptions, buildOptions);
59546
+ emitLifecyclePostBuildProgress(buildOptions, "Hashing file signatures");
59547
+ let fileSignatureHash = hashManifestEntries(snapshot.files, root, snapshot.index.manifestEntries, snapshot.index.manifestSignaturesFresh);
59548
+ if (!fileSignatureHash) {
59549
+ emitLifecyclePostBuildProgress(buildOptions, "Hashing discovered files");
59550
+ fileSignatureHash = await hashDiscoveredFiles(snapshot.files, root);
59551
+ }
59552
+ const files = discoveredFileRelativePaths(snapshot.files, root);
60731
59553
  return {
60732
59554
  schemaVersion: MANIFEST_SCHEMA_VERSION,
60733
59555
  root: ".",
60734
59556
  createdAt: existing?.createdAt ?? now,
60735
59557
  lastSyncAt: now,
60736
- configHash: await hashConfig(root, buildOptions?.logLevel),
59558
+ configHash,
60737
59559
  buildOptionsHash: hashBuildOptions(buildOptions),
60738
59560
  fileCount: snapshot.files.length,
60739
- fileSignatureHash: hashManifestEntries(snapshot.files, root, snapshot.index.manifestEntries, snapshot.index.manifestSignaturesFresh) ?? await hashDiscoveredFiles(snapshot.files, root),
60740
- files: discoveredFileRelativePaths(snapshot.files, root),
59561
+ fileSignatureHash,
59562
+ files,
60741
59563
  analysis: snapshot.analysis
60742
59564
  };
60743
59565
  }
@@ -60781,6 +59603,43 @@ async function writeLifecycleManifest(root, manifest) {
60781
59603
  throw new CodegraphLifecycleUserError(`Unable to write Codegraph lifecycle manifest at ${manifestPath}: ${stringifyError(error51)}`);
60782
59604
  }
60783
59605
  }
59606
+ function emitLifecyclePostBuildProgress(buildOptions, activity) {
59607
+ buildOptions?.onProgress?.({
59608
+ type: "progress",
59609
+ phase: "start",
59610
+ mode: "check",
59611
+ message: activity,
59612
+ activity,
59613
+ current: 0,
59614
+ total: 0
59615
+ });
59616
+ }
59617
+ function withIndexTeardownProgress(buildOptions) {
59618
+ const onProgress = buildOptions?.onProgress;
59619
+ if (!onProgress)
59620
+ return { ...buildOptions ?? {} };
59621
+ return {
59622
+ ...buildOptions,
59623
+ onProgress: (update) => {
59624
+ onProgress(update);
59625
+ if (update.phase !== "complete")
59626
+ return;
59627
+ const indexFinished = update.mode === "build" || update.mode === "update" || update.mode === "check" && update.message === "Checked project index";
59628
+ if (!indexFinished)
59629
+ return;
59630
+ emitLifecyclePostBuildProgress(buildOptions, "Closing disk cache");
59631
+ }
59632
+ };
59633
+ }
59634
+ async function resolveLifecycleConfigHash(root, sessionBuildOptions, buildOptions) {
59635
+ emitLifecyclePostBuildProgress(buildOptions, "Reading index config hash");
59636
+ const indexManifest = await loadManifest(root, sessionBuildOptions);
59637
+ const storedHash = indexManifest?.configHash;
59638
+ if (storedHash)
59639
+ return storedHash;
59640
+ emitLifecyclePostBuildProgress(buildOptions, "Hashing project config");
59641
+ return await hashConfig(root, buildOptions?.logLevel);
59642
+ }
60784
59643
  async function hashConfig(root, logLevel) {
60785
59644
  const result = await computeConfigHash(root, logLevel);
60786
59645
  if (result.error) {
@@ -63936,30 +62795,30 @@ function readGraphSchemaVersion(db) {
63936
62795
  const row = db.prepare("SELECT value FROM graph_metadata WHERE key = ?").get(GRAPH_SCHEMA_VERSION_KEY);
63937
62796
  if (!row?.value)
63938
62797
  return 0;
63939
- const version3 = Number(String(row.value));
63940
- if (!Number.isInteger(version3) || version3 < 0)
62798
+ const version2 = Number(String(row.value));
62799
+ if (!Number.isInteger(version2) || version2 < 0)
63941
62800
  return 0;
63942
- return version3;
62801
+ return version2;
63943
62802
  } catch {
63944
62803
  return 0;
63945
62804
  }
63946
62805
  }
63947
- function writeGraphSchemaVersion(db, version3) {
62806
+ function writeGraphSchemaVersion(db, version2) {
63948
62807
  db.prepare("INSERT OR REPLACE INTO graph_metadata (key, value) VALUES (?, ?);").run([
63949
62808
  GRAPH_SCHEMA_VERSION_KEY,
63950
- String(version3)
62809
+ String(version2)
63951
62810
  ]);
63952
62811
  }
63953
62812
  function migrateGraphSchema(db, fromVersion) {
63954
- let version3 = fromVersion;
63955
- if (version3 < 1) {
63956
- version3 = 1;
62813
+ let version2 = fromVersion;
62814
+ if (version2 < 1) {
62815
+ version2 = 1;
63957
62816
  }
63958
- if (version3 < 2) {
62817
+ if (version2 < 2) {
63959
62818
  ensureSymbolsVisibilityColumn(db);
63960
- version3 = 2;
62819
+ version2 = 2;
63961
62820
  }
63962
- if (version3 < 3) {
62821
+ if (version2 < 3) {
63963
62822
  db.exec(`
63964
62823
  DELETE FROM graph_snapshot_files
63965
62824
  WHERE snapshot_id NOT IN (
@@ -63970,10 +62829,10 @@ function migrateGraphSchema(db, fromVersion) {
63970
62829
  SELECT id FROM graph_snapshots ORDER BY created_at DESC, id DESC LIMIT ${GRAPH_SNAPSHOT_RETENTION}
63971
62830
  );
63972
62831
  `);
63973
- version3 = 3;
62832
+ version2 = 3;
63974
62833
  }
63975
- if (version3 !== fromVersion) {
63976
- writeGraphSchemaVersion(db, version3);
62834
+ if (version2 !== fromVersion) {
62835
+ writeGraphSchemaVersion(db, version2);
63977
62836
  }
63978
62837
  }
63979
62838
  var SQLITE_SCHEMA_VERSION, GRAPH_SNAPSHOT_RETENTION, GRAPH_SCHEMA_VERSION_KEY, hasColumn, ensureSymbolsVisibilityColumn, ensureGraphIndexes, ensureSchema;
@@ -64641,6 +63500,7 @@ var init_rowBounds = __esm({
64641
63500
  import fs27 from "node:fs";
64642
63501
  import path59 from "node:path";
64643
63502
  import { fileURLToPath as fileURLToPath5 } from "node:url";
63503
+ import { Piscina as Piscina2 } from "piscina";
64644
63504
  function resolveRawSqlQueryWorkerPath() {
64645
63505
  const selfDirectory = path59.dirname(fileURLToPath5(import.meta.url));
64646
63506
  const sibling = path59.resolve(selfDirectory, "rawQueryWorker.js");
@@ -64659,7 +63519,7 @@ async function runRawSqlQueryInWorker(task, deadlineMs, signal) {
64659
63519
  const workerPath = resolveRawSqlQueryWorkerPath();
64660
63520
  return await rawSqlQueryWorkerLifecycle.run(task, deadlineMs, signal, () => {
64661
63521
  markWindowsProcessDrainRequired();
64662
- return new Piscina({
63522
+ return new Piscina2({
64663
63523
  filename: workerPath,
64664
63524
  minThreads: 1,
64665
63525
  maxThreads: 1,
@@ -64671,7 +63531,6 @@ var MAX_RAW_SQL_QUERY_WORKERS, SqliteQueryDeadlineExceededError, SqliteQueryCanc
64671
63531
  var init_rawQueryWorkerPool = __esm({
64672
63532
  "dist/sqlite/rawQueryWorkerPool.js"() {
64673
63533
  "use strict";
64674
- init_esm_wrapper();
64675
63534
  init_packageInfo();
64676
63535
  init_windowsProcessDrain();
64677
63536
  MAX_RAW_SQL_QUERY_WORKERS = 2;
@@ -66569,12 +65428,12 @@ function findDeclarationNameNode(sup, currentNode) {
66569
65428
  }
66570
65429
  return null;
66571
65430
  }
66572
- function getOrBuildScopeIndex(index, file2, source, sup, mod2, tree) {
65431
+ function getOrBuildScopeIndex(index, file2, source, sup, mod, tree) {
66573
65432
  const fileKey = fileIdentityKey(file2);
66574
65433
  let scopeIndex = index.scopeCache.get(fileKey);
66575
65434
  if (scopeIndex)
66576
65435
  return scopeIndex;
66577
- scopeIndex = buildScopeIndexFromSource(file2, source, sup, mod2.imports, { tree });
65436
+ scopeIndex = buildScopeIndexFromSource(file2, source, sup, mod.imports, { tree });
66578
65437
  index.scopeCache.set(fileKey, scopeIndex);
66579
65438
  return scopeIndex;
66580
65439
  }
@@ -66621,10 +65480,10 @@ function toModuleRef(resolved) {
66621
65480
  return void 0;
66622
65481
  return typeof resolved === "string" ? resolved : resolved.external;
66623
65482
  }
66624
- function resolveNamedDefinition(index, mod2, file2, support, name) {
65483
+ function resolveNamedDefinition(index, mod, file2, support, name) {
66625
65484
  const normalizedName = support.normalizeIdentifier(name);
66626
65485
  const requiresExplicitReceiver = !support.membersAreImplicitlyInScope;
66627
- const directExport = requiresExplicitReceiver ? mod2.exports.find((entry) => entry.type === "local" && support.normalizeIdentifier(entry.exportedAs) === normalizedName && !entry.target.isMember) : void 0;
65486
+ const directExport = requiresExplicitReceiver ? mod.exports.find((entry) => entry.type === "local" && support.normalizeIdentifier(entry.exportedAs) === normalizedName && !entry.target.isMember) : void 0;
66628
65487
  const hit = directExport && directExport.type === "local" ? { kind: "resolved", def: directExport.target } : resolveExport(index, file2, name, { allowLocalFallback: support.membersAreImplicitlyInScope });
66629
65488
  if (hit?.kind === "resolved" && (!requiresExplicitReceiver || !hit.def.isMember)) {
66630
65489
  return okGoToResult(index, hit.def, {
@@ -66644,7 +65503,7 @@ function resolveNamedDefinition(index, mod2, file2, support, name) {
66644
65503
  });
66645
65504
  }
66646
65505
  }
66647
- for (const imp of mod2.imports) {
65506
+ for (const imp of mod.imports) {
66648
65507
  if (imp.kind === "default" && support.normalizeIdentifier(imp.local) === normalizedName) {
66649
65508
  const result = resolveImported(index, imp, "default");
66650
65509
  if (result && !("namespace" in result)) {
@@ -67642,8 +66501,8 @@ var init_navigation = __esm({
67642
66501
  // dist/indexer/navigation.js
67643
66502
  async function goToDefinition(index, req, parsedContext) {
67644
66503
  const { file: file2, line, column } = req;
67645
- const mod2 = index.byFile.get(fileIdentityKey(file2));
67646
- if (!mod2)
66504
+ const mod = index.byFile.get(fileIdentityKey(file2));
66505
+ if (!mod)
67647
66506
  return { status: "not_found", reason: "File not indexed" };
67648
66507
  const sqlResult = await goToSqlDefinition(index, req);
67649
66508
  if (sqlResult)
@@ -67709,10 +66568,10 @@ async function goToDefinition(index, req, parsedContext) {
67709
66568
  }
67710
66569
  }
67711
66570
  if (sup.supportsCrossModuleSymbols) {
67712
- const scopeIndex = node.parent && isMemberAccessNode(sup, node.parent) ? getOrBuildScopeIndex(index, file2, source, sup, mod2, tree) : null;
66571
+ const scopeIndex = node.parent && isMemberAccessNode(sup, node.parent) ? getOrBuildScopeIndex(index, file2, source, sup, mod, tree) : null;
67713
66572
  const memberAccessResult = await resolveMemberAccessDefinition({
67714
66573
  index,
67715
- mod: mod2,
66574
+ mod,
67716
66575
  node,
67717
66576
  source,
67718
66577
  sup,
@@ -67762,7 +66621,7 @@ async function goToDefinition(index, req, parsedContext) {
67762
66621
  }
67763
66622
  }
67764
66623
  if (name) {
67765
- const scopeIndex = getOrBuildScopeIndex(index, file2, source, sup, mod2, tree);
66624
+ const scopeIndex = getOrBuildScopeIndex(index, file2, source, sup, mod, tree);
67766
66625
  const local = findClosestBinding(scopeIndex, file2, name, node, sup);
67767
66626
  if (local) {
67768
66627
  return okGoToResult(index, local, {
@@ -67771,7 +66630,7 @@ async function goToDefinition(index, req, parsedContext) {
67771
66630
  });
67772
66631
  }
67773
66632
  if (sup.supportsCrossModuleSymbols) {
67774
- const resolvedName = resolveNamedDefinition(index, mod2, file2, sup, name);
66633
+ const resolvedName = resolveNamedDefinition(index, mod, file2, sup, name);
67775
66634
  if (resolvedName) {
67776
66635
  return resolvedName;
67777
66636
  }
@@ -67822,10 +66681,10 @@ async function findReferences(index, req, opts) {
67822
66681
  const definitionFile = def.file;
67823
66682
  const parsedDef = index.parsed?.get(fileIdentityKey(definitionFile));
67824
66683
  const parsedContext = await ensureParsedContext(definitionFile, parsedDef, index.languageExtensions);
67825
- const mod2 = index.byFile.get(fileIdentityKey(definitionFile));
67826
- if (!mod2)
66684
+ const mod = index.byFile.get(fileIdentityKey(definitionFile));
66685
+ if (!mod)
67827
66686
  return { status: "not_found", reason: "Module not found" };
67828
- const scope = getCachedScope(index, definitionFile, mod2, parsedContext);
66687
+ const scope = getCachedScope(index, definitionFile, mod, parsedContext);
67829
66688
  const refs = [];
67830
66689
  const maxReferences = typeof opts?.maxReferences === "number" && opts.maxReferences > 0 ? opts.maxReferences : void 0;
67831
66690
  const seenRefs = /* @__PURE__ */ new Set();
@@ -67849,7 +66708,7 @@ async function findReferences(index, req, opts) {
67849
66708
  }
67850
66709
  }
67851
66710
  const exportedNames = [];
67852
- for (const entry of mod2.exports) {
66711
+ for (const entry of mod.exports) {
67853
66712
  if (entry.type === "local" && sameDef(entry.target, def, index.languageExtensions)) {
67854
66713
  exportedNames.push(entry.exportedAs);
67855
66714
  }
@@ -68254,13 +67113,13 @@ function defFromSymbolId(index, id) {
68254
67113
  const startStr = parts[2];
68255
67114
  const file2 = normalizePath(rawFile);
68256
67115
  const startIndex = Number(startStr);
68257
- const mod2 = index.byFile.get(fileIdentityKey(file2));
68258
- if (!mod2)
67116
+ const mod = index.byFile.get(fileIdentityKey(file2));
67117
+ if (!mod)
68259
67118
  return null;
68260
- const exact = mod2.locals.find((def) => def.localName === localName && (def.range?.start?.index ?? 0) === startIndex);
67119
+ const exact = mod.locals.find((def) => def.localName === localName && (def.range?.start?.index ?? 0) === startIndex);
68261
67120
  if (exact)
68262
67121
  return exact;
68263
- const byName = mod2.locals.find((def) => def.localName === localName);
67122
+ const byName = mod.locals.find((def) => def.localName === localName);
68264
67123
  return byName ?? null;
68265
67124
  }
68266
67125
  function resolveSymbolId(index, id) {
@@ -68271,10 +67130,10 @@ function resolveSymbolId(index, id) {
68271
67130
  const rawFile = parts[0];
68272
67131
  const alias = parts[1];
68273
67132
  const file2 = normalizePath(rawFile);
68274
- const mod2 = index.byFile.get(fileIdentityKey(file2));
68275
- if (!mod2)
67133
+ const mod = index.byFile.get(fileIdentityKey(file2));
67134
+ if (!mod)
68276
67135
  return null;
68277
- const named = mod2.imports.find((imp) => imp.kind === "named" && imp.local === alias);
67136
+ const named = mod.imports.find((imp) => imp.kind === "named" && imp.local === alias);
68278
67137
  if (named) {
68279
67138
  const result = resolveImported(index, named, named.imported);
68280
67139
  if (result && !("namespace" in result))
@@ -68286,7 +67145,7 @@ function resolveSymbolId(index, id) {
68286
67145
  return hit.def;
68287
67146
  }
68288
67147
  }
68289
- const defaultImport = mod2.imports.find((imp) => imp.kind === "default" && imp.local === alias);
67148
+ const defaultImport = mod.imports.find((imp) => imp.kind === "default" && imp.local === alias);
68290
67149
  if (defaultImport) {
68291
67150
  const result = resolveImported(index, defaultImport, "default");
68292
67151
  if (result && !("namespace" in result))
@@ -68302,7 +67161,7 @@ function resolveSymbolId(index, id) {
68302
67161
  return first.target;
68303
67162
  }
68304
67163
  }
68305
- const namespaceImport = mod2.imports.find((imp) => imp.kind === "namespace" && imp.localNS === alias);
67164
+ const namespaceImport = mod.imports.find((imp) => imp.kind === "namespace" && imp.localNS === alias);
68306
67165
  if (namespaceImport) {
68307
67166
  const target = typeof namespaceImport.resolved === "string" ? namespaceImport.resolved : void 0;
68308
67167
  if (target) {
@@ -68321,8 +67180,8 @@ function resolveSymbolId(index, id) {
68321
67180
  }
68322
67181
  function getApiSurface(index) {
68323
67182
  const out = [];
68324
- for (const mod2 of index.byFile.values()) {
68325
- const exports = mod2.exports.map((entry) => {
67183
+ for (const mod of index.byFile.values()) {
67184
+ const exports = mod.exports.map((entry) => {
68326
67185
  if (entry.type === "local") {
68327
67186
  return {
68328
67187
  name: entry.target.localName,
@@ -68354,7 +67213,7 @@ function getApiSurface(index) {
68354
67213
  };
68355
67214
  });
68356
67215
  if (exports.length) {
68357
- out.push({ file: mod2.file, exports });
67216
+ out.push({ file: mod.file, exports });
68358
67217
  }
68359
67218
  }
68360
67219
  return out;
@@ -68444,12 +67303,12 @@ async function listDirectDeletedFileImporters(index, deletedFiles, projectRoot)
68444
67303
  ...edge.to.type === "file" ? { resolved: edge.to.path } : {}
68445
67304
  });
68446
67305
  }
68447
- for (const mod2 of index.byFile.values()) {
67306
+ for (const mod of index.byFile.values()) {
68448
67307
  const uniqueImports = /* @__PURE__ */ new Map();
68449
- for (const entry of importsByFile.get(mod2.file) ?? []) {
67308
+ for (const entry of importsByFile.get(mod.file) ?? []) {
68450
67309
  uniqueImports.set(`${entry.spec}::${entry.resolved ?? ""}`, entry);
68451
67310
  }
68452
- for (const imp of mod2.imports) {
67311
+ for (const imp of mod.imports) {
68453
67312
  const resolved = getImportResolvedPath(imp);
68454
67313
  uniqueImports.set(`${imp.from}::${resolved ?? ""}`, {
68455
67314
  spec: imp.from,
@@ -68459,12 +67318,12 @@ async function listDirectDeletedFileImporters(index, deletedFiles, projectRoot)
68459
67318
  for (const entry of uniqueImports.values()) {
68460
67319
  for (const deletedFile of deletedFileSet) {
68461
67320
  const resolvedImportPath = entry.resolved ? normalizePath(entry.resolved) : void 0;
68462
- const resolvedAliasTarget = resolvedImportPath === deletedFile ? resolvedImportPath : await resolveDeletedAliasImportTarget(projectRoot, workspaceConfig, mod2.file, entry.spec, deletedFile);
68463
- if (!matchesDeletedImportTarget(mod2.file, entry.spec, resolvedAliasTarget, deletedFile)) {
67321
+ const resolvedAliasTarget = resolvedImportPath === deletedFile ? resolvedImportPath : await resolveDeletedAliasImportTarget(projectRoot, workspaceConfig, mod.file, entry.spec, deletedFile);
67322
+ if (!matchesDeletedImportTarget(mod.file, entry.spec, resolvedAliasTarget, deletedFile)) {
68464
67323
  continue;
68465
67324
  }
68466
- candidates.set(`${mod2.file}::${deletedFile}`, {
68467
- file: mod2.file,
67325
+ candidates.set(`${mod.file}::${deletedFile}`, {
67326
+ file: mod.file,
68468
67327
  deletedFile
68469
67328
  });
68470
67329
  }
@@ -68688,17 +67547,17 @@ async function collectDeletedImporterEdges(index, deletedFiles, projectRoot) {
68688
67547
  const deletedFileSet = new Set(deletedFiles.map((file2) => normalizePath(file2)));
68689
67548
  const edges = /* @__PURE__ */ new Map();
68690
67549
  const workspaceConfig = projectRoot ? await loadWorkspaceConfig(projectRoot) : void 0;
68691
- for (const mod2 of index.byFile.values()) {
68692
- for (const imp of mod2.imports) {
67550
+ for (const mod of index.byFile.values()) {
67551
+ for (const imp of mod.imports) {
68693
67552
  for (const deletedFile of deletedFileSet) {
68694
67553
  const resolvedImportPath = getImportResolvedPath(imp);
68695
67554
  const normalizedResolvedImportPath = resolvedImportPath ? normalizePath(resolvedImportPath) : void 0;
68696
- const resolvedAliasTarget = normalizedResolvedImportPath === deletedFile ? normalizedResolvedImportPath : await resolveDeletedAliasImportTarget(projectRoot, workspaceConfig, mod2.file, imp.from, deletedFile);
68697
- const matchesDeletedFile = matchesDeletedImportTarget(mod2.file, imp.from, resolvedAliasTarget, deletedFile);
67555
+ const resolvedAliasTarget = normalizedResolvedImportPath === deletedFile ? normalizedResolvedImportPath : await resolveDeletedAliasImportTarget(projectRoot, workspaceConfig, mod.file, imp.from, deletedFile);
67556
+ const matchesDeletedFile = matchesDeletedImportTarget(mod.file, imp.from, resolvedAliasTarget, deletedFile);
68698
67557
  if (!matchesDeletedFile)
68699
67558
  continue;
68700
67559
  const edge = {
68701
- from: mod2.file,
67560
+ from: mod.file,
68702
67561
  to: { type: "file", path: deletedFile },
68703
67562
  raw: imp.from,
68704
67563
  ...imp.typeOnly ? { typeOnly: imp.typeOnly } : {}
@@ -68709,8 +67568,8 @@ async function collectDeletedImporterEdges(index, deletedFiles, projectRoot) {
68709
67568
  }
68710
67569
  return Array.from(edges.values());
68711
67570
  }
68712
- function listReviewableExports(mod2) {
68713
- return mod2.exports.filter((entry) => entry.type !== "local");
67571
+ function listReviewableExports(mod) {
67572
+ return mod.exports.filter((entry) => entry.type !== "local");
68714
67573
  }
68715
67574
  async function collectDeletedSnapshotEdges(deletedSnapshots, projectRoot) {
68716
67575
  const edges = /* @__PURE__ */ new Map();
@@ -71853,14 +70712,14 @@ async function locateChangedSymbolsWithLines(index, file2, hunks) {
71853
70712
  const changedNodes = findNodesInLines(tree, changedLines);
71854
70713
  const changedByteRanges = computeChangedByteRanges(source, hunks);
71855
70714
  const seenHandles = /* @__PURE__ */ new Map();
71856
- const mod2 = index.byFile.get(fileIdentityKey(file2));
71857
- const trackedPositions = mod2 ? buildTrackedSymbolPositions(mod2.locals) : void 0;
70715
+ const mod = index.byFile.get(fileIdentityKey(file2));
70716
+ const trackedPositions = mod ? buildTrackedSymbolPositions(mod.locals) : void 0;
71858
70717
  for (const node of changedNodes) {
71859
70718
  const classification = classifyChangedNode(node, source, sup);
71860
70719
  const symbolHandle = findSymbolHandleForNode(index, file2, node, sup, classification, source, trackedPositions);
71861
70720
  if (!symbolHandle)
71862
70721
  continue;
71863
- const symbolDef = mod2?.locals.find((l) => symbolHandleFromLocal(file2, l) === symbolHandle);
70722
+ const symbolDef = mod?.locals.find((l) => symbolHandleFromLocal(file2, l) === symbolHandle);
71864
70723
  if (!symbolDef)
71865
70724
  continue;
71866
70725
  const existing = seenHandles.get(symbolHandle);
@@ -71991,8 +70850,8 @@ async function mapChangedLinesToSymbols(index, file2, hunks, changedLinesOverrid
71991
70850
  const { source, tree } = parsedEntry;
71992
70851
  const sup = parsedEntry.sup;
71993
70852
  const changedLines = changedLinesOverride ?? collectChangedLines(hunks);
71994
- const mod2 = index.byFile.get(fileIdentityKey(file2));
71995
- const trackedPositions = mod2 ? buildTrackedSymbolPositions(mod2.locals) : void 0;
70853
+ const mod = index.byFile.get(fileIdentityKey(file2));
70854
+ const trackedPositions = mod ? buildTrackedSymbolPositions(mod.locals) : void 0;
71996
70855
  const nodes = findNodesInLines(tree, changedLines);
71997
70856
  const linesByHandle = /* @__PURE__ */ new Map();
71998
70857
  for (const node of nodes) {
@@ -72353,13 +71212,13 @@ function signatureOnlyDeclarationLineChanged(tree, symbolDef, changedLines) {
72353
71212
  return false;
72354
71213
  }
72355
71214
  function findSymbolHandleForNode(index, file2, node, sup, classification, source, trackedPositions) {
72356
- const mod2 = index.byFile.get(fileIdentityKey(file2));
72357
- if (!mod2)
71215
+ const mod = index.byFile.get(fileIdentityKey(file2));
71216
+ if (!mod)
72358
71217
  return null;
72359
71218
  if (classification?.type === "definition" && isDefinitionNameNode(node, sup, source)) {
72360
71219
  const definitionLine = node.startPosition?.row + 1;
72361
71220
  const definitionColumn = node.startPosition?.column + 1;
72362
- const local = findLocalByStartPosition(mod2.locals, definitionLine, definitionColumn);
71221
+ const local = findLocalByStartPosition(mod.locals, definitionLine, definitionColumn);
72363
71222
  if (local) {
72364
71223
  return symbolHandleFromLocal(file2, local);
72365
71224
  }
@@ -72368,7 +71227,7 @@ function findSymbolHandleForNode(index, file2, node, sup, classification, source
72368
71227
  if (nameNode) {
72369
71228
  const ancestorLine = nameNode.startPosition?.row + 1;
72370
71229
  const ancestorColumn = nameNode.startPosition?.column + 1;
72371
- const local = findLocalByStartPosition(mod2.locals, ancestorLine, ancestorColumn);
71230
+ const local = findLocalByStartPosition(mod.locals, ancestorLine, ancestorColumn);
72372
71231
  return local ? symbolHandleFromLocal(file2, local) : null;
72373
71232
  }
72374
71233
  return null;
@@ -72617,11 +71476,11 @@ function relativePath2(root, file2) {
72617
71476
  function sortSymbols(symbols) {
72618
71477
  return symbols.slice().sort((left, right) => symbolId(left).localeCompare(symbolId(right)));
72619
71478
  }
72620
- function isExported(mod2, handle) {
72621
- return isSymbolHandleExported(mod2.exports, handle);
71479
+ function isExported(mod, handle) {
71480
+ return isSymbolHandleExported(mod.exports, handle);
72622
71481
  }
72623
- function listReviewableExports2(mod2) {
72624
- return mod2.exports.filter((entry) => entry.type !== "local");
71482
+ function listReviewableExports2(mod) {
71483
+ return mod.exports.filter((entry) => entry.type !== "local");
72625
71484
  }
72626
71485
  function exportSummaryName(entry) {
72627
71486
  return entry.type === "exportStar" ? "*" : entry.exportedAs;
@@ -72758,8 +71617,8 @@ function collectRemovedExportGroups(hunks) {
72758
71617
  function statementDeclaresSpecifier(statement, specifier) {
72759
71618
  return statement.specifiers.some((candidate) => candidate.kind === specifier.kind && candidate.name === specifier.name && candidate.fromModule === specifier.fromModule);
72760
71619
  }
72761
- function buildExportSummaryGroups(file2, mod2, source, hunks) {
72762
- const entries = listReviewableExports2(mod2);
71620
+ function buildExportSummaryGroups(file2, mod, source, hunks) {
71621
+ const entries = listReviewableExports2(mod);
72763
71622
  if (!hunks) {
72764
71623
  return { changed: uniqueExportSummaries(buildExportSummaries(file2, entries)), context: [] };
72765
71624
  }
@@ -72891,12 +71750,12 @@ async function summarizeChangedFiles2(input) {
72891
71750
  mod: index.byFile.get(fileIdentityKey(file2)),
72892
71751
  hunks: diffHunksByFile.get(fileIdentityKey(file2)) ?? diffHunksByFile.get(file2)
72893
71752
  }));
72894
- const fileEntries = await mapLimit(filesWithModules, Math.max(1, referenceConcurrency), async ({ file: file2, mod: mod2, hunks }) => {
71753
+ const fileEntries = await mapLimit(filesWithModules, Math.max(1, referenceConcurrency), async ({ file: file2, mod, hunks }) => {
72895
71754
  const isBinary = diffChangesByFile.get(file2)?.isBinary ?? false;
72896
71755
  if (isBinary) {
72897
71756
  return {
72898
71757
  file: file2,
72899
- mod: mod2,
71758
+ mod,
72900
71759
  hunks,
72901
71760
  locals: [],
72902
71761
  handles: [],
@@ -72905,10 +71764,10 @@ async function summarizeChangedFiles2(input) {
72905
71764
  parseFailed: false
72906
71765
  };
72907
71766
  }
72908
- if (!mod2) {
71767
+ if (!mod) {
72909
71768
  return {
72910
71769
  file: file2,
72911
- mod: mod2,
71770
+ mod,
72912
71771
  hunks,
72913
71772
  locals: [],
72914
71773
  handles: [],
@@ -72918,10 +71777,10 @@ async function summarizeChangedFiles2(input) {
72918
71777
  };
72919
71778
  }
72920
71779
  if (!hunks) {
72921
- const locals2 = sortSymbols(mod2.locals);
71780
+ const locals2 = sortSymbols(mod.locals);
72922
71781
  return {
72923
71782
  file: file2,
72924
- mod: mod2,
71783
+ mod,
72925
71784
  hunks,
72926
71785
  locals: locals2,
72927
71786
  handles: locals2.map((local) => symbolId(local)),
@@ -72947,7 +71806,7 @@ async function summarizeChangedFiles2(input) {
72947
71806
  const handles = locals.map((local) => symbolId(local));
72948
71807
  return {
72949
71808
  file: file2,
72950
- mod: mod2,
71809
+ mod,
72951
71810
  hunks,
72952
71811
  locals,
72953
71812
  handles,
@@ -73030,7 +71889,7 @@ async function summarizeChangedFiles2(input) {
73030
71889
  ...callsites ? { callsites } : {}
73031
71890
  };
73032
71891
  };
73033
- const summariesWithHandles = await mapLimit(fileEntries, Math.max(1, referenceConcurrency), async ({ file: file2, mod: mod2, hunks, locals, handles, diffLinesByHandle }) => {
71892
+ const summariesWithHandles = await mapLimit(fileEntries, Math.max(1, referenceConcurrency), async ({ file: file2, mod, hunks, locals, handles, diffLinesByHandle }) => {
73034
71893
  const diffChange = diffChangesByFile.get(file2);
73035
71894
  const diffMetadata = reviewFileDiffMetadata(projectRoot, diffChange);
73036
71895
  const deletedSnapshot = deletedSnapshots.get(file2);
@@ -73047,7 +71906,7 @@ async function summarizeChangedFiles2(input) {
73047
71906
  handles: []
73048
71907
  };
73049
71908
  }
73050
- if (!mod2 && deletedSnapshot) {
71909
+ if (!mod && deletedSnapshot) {
73051
71910
  const deletedLocals = sortSymbols(deletedSnapshot.module.locals);
73052
71911
  const localSymbols2 = includeSymbolDetails ? deletedLocals.map((local) => {
73053
71912
  const handle = symbolId(local);
@@ -73084,7 +71943,7 @@ async function summarizeChangedFiles2(input) {
73084
71943
  handles: handles2
73085
71944
  };
73086
71945
  }
73087
- if (!mod2) {
71946
+ if (!mod) {
73088
71947
  const fileExistsOnDisk = existenceByFile.get(file2) ?? false;
73089
71948
  const isDeletedByDiff = diffKindsByFile.get(file2) === "deleted";
73090
71949
  const isMissingExplicitInput = !fileExistsOnDisk && explicitFiles.has(file2) && !isDeletedByDiff;
@@ -73107,8 +71966,8 @@ async function summarizeChangedFiles2(input) {
73107
71966
  handles: []
73108
71967
  };
73109
71968
  }
73110
- const localSymbols = await mapLimit(locals, Math.max(1, referenceConcurrency), async (local) => await buildSymbolSummary(local, mod2, diffLinesByHandle));
73111
- const exportSummaryGroups = buildExportSummaryGroups(file2, mod2, await loadSource(file2), hunks);
71969
+ const localSymbols = await mapLimit(locals, Math.max(1, referenceConcurrency), async (local) => await buildSymbolSummary(local, mod, diffLinesByHandle));
71970
+ const exportSummaryGroups = buildExportSummaryGroups(file2, mod, await loadSource(file2), hunks);
73112
71971
  const symbols = [...localSymbols, ...exportSummaryGroups.changed];
73113
71972
  return {
73114
71973
  summary: {
@@ -73401,8 +72260,8 @@ async function buildReviewReport(projectRoot, opts = {}, cached2) {
73401
72260
  }
73402
72261
  function buildSymbolDefLookup(index) {
73403
72262
  const lookup = /* @__PURE__ */ new Map();
73404
- for (const mod2 of index.byFile.values()) {
73405
- for (const local of mod2.locals) {
72263
+ for (const mod of index.byFile.values()) {
72264
+ for (const local of mod.locals) {
73406
72265
  lookup.set(symbolId(local), local);
73407
72266
  }
73408
72267
  }
@@ -75768,10 +74627,10 @@ function rebuildDerivedQueryIndexSchema(db) {
75768
74627
  })();
75769
74628
  }
75770
74629
  function ensureQueryIndexSchema(db) {
75771
- const version3 = readQueryIndexSchemaVersion(db);
75772
- if (version3 > QUERY_INDEX_SCHEMA_VERSION)
75773
- throw new QueryIndexFutureSchemaError(version3);
75774
- if (!version3) {
74630
+ const version2 = readQueryIndexSchemaVersion(db);
74631
+ if (version2 > QUERY_INDEX_SCHEMA_VERSION)
74632
+ throw new QueryIndexFutureSchemaError(version2);
74633
+ if (!version2) {
75775
74634
  const existing2 = existingQueryTables(db);
75776
74635
  if (existing2.size) {
75777
74636
  throw new QueryIndexSchemaError("Query index has tables but no recognized schema version.");
@@ -75781,10 +74640,10 @@ function ensureQueryIndexSchema(db) {
75781
74640
  db.pragma(`user_version = ${QUERY_INDEX_SCHEMA_VERSION}`);
75782
74641
  return;
75783
74642
  }
75784
- if (version3 === 1 || version3 === 2) {
74643
+ if (version2 === 1 || version2 === 2) {
75785
74644
  rebuildDerivedQueryIndexSchema(db);
75786
- } else if (version3 < QUERY_INDEX_SCHEMA_VERSION) {
75787
- throw new QueryIndexSchemaError(`Query index schema version ${version3} has no supported migration.`);
74645
+ } else if (version2 < QUERY_INDEX_SCHEMA_VERSION) {
74646
+ throw new QueryIndexSchemaError(`Query index schema version ${version2} has no supported migration.`);
75788
74647
  }
75789
74648
  const existing = existingQueryTables(db);
75790
74649
  const missing = REQUIRED_TABLES.filter((table) => !existing.has(table));
@@ -75819,8 +74678,8 @@ var init_schema2 = __esm({
75819
74678
  init_content();
75820
74679
  QUERY_INDEX_SCHEMA_VERSION = 3;
75821
74680
  QueryIndexFutureSchemaError = class extends Error {
75822
- constructor(version3) {
75823
- super(`Query index schema version ${version3} is newer than supported version ${QUERY_INDEX_SCHEMA_VERSION}.`);
74681
+ constructor(version2) {
74682
+ super(`Query index schema version ${version2} is newer than supported version ${QUERY_INDEX_SCHEMA_VERSION}.`);
75824
74683
  this.name = "QueryIndexFutureSchemaError";
75825
74684
  }
75826
74685
  };
@@ -76487,6 +75346,7 @@ __export(workerPool_exports, {
76487
75346
  import fs33 from "node:fs";
76488
75347
  import path75 from "node:path";
76489
75348
  import { fileURLToPath as fileURLToPath6 } from "node:url";
75349
+ import { Piscina as Piscina3 } from "piscina";
76490
75350
  function shouldPrepareQueryIndexFilesInWorker(fileCount, threadCount = resolveWorkerThreads()) {
76491
75351
  return threadCount > 1 && fileCount >= QUERY_INDEX_WORKER_MIN_FILES;
76492
75352
  }
@@ -76532,7 +75392,7 @@ async function prepareQueryIndexFilesInWorker(projectRoot, files) {
76532
75392
  return await prepareQueryIndexFilesInProcess(projectRoot, files);
76533
75393
  }
76534
75394
  markWindowsProcessDrainRequired();
76535
- const pool = new Piscina({
75395
+ const pool = new Piscina3({
76536
75396
  filename: workerPath,
76537
75397
  minThreads: 1,
76538
75398
  maxThreads: threads,
@@ -76567,7 +75427,6 @@ var QUERY_INDEX_MAX_THREADS, QUERY_INDEX_WORKER_MIN_FILES;
76567
75427
  var init_workerPool = __esm({
76568
75428
  "dist/agent/query-index/workerPool.js"() {
76569
75429
  "use strict";
76570
- init_esm_wrapper();
76571
75430
  init_packageInfo();
76572
75431
  init_content();
76573
75432
  init_paths2();
@@ -81808,9 +80667,9 @@ function buildReexportChains(index, changedSymbols, maxDepth = REEXPORT_CHAIN_MA
81808
80667
  if (!exportedSymbols.length)
81809
80668
  return void 0;
81810
80669
  const reexportsBySource = /* @__PURE__ */ new Map();
81811
- for (const mod2 of index.byFile.values()) {
81812
- const file2 = mod2.file;
81813
- for (const entry of mod2.exports) {
80670
+ for (const mod of index.byFile.values()) {
80671
+ const file2 = mod.file;
80672
+ for (const entry of mod.exports) {
81814
80673
  if (entry.type !== "reexport" && entry.type !== "exportStar" && entry.type !== "namespaceReexport") {
81815
80674
  continue;
81816
80675
  }
@@ -82058,10 +80917,10 @@ async function collectImpactSuggestions(index, projectRoot, diffFiles, options)
82058
80917
  break;
82059
80918
  const absoluteFile = resolveFilePath(projectRoot, fileChange.path);
82060
80919
  const reportFile = toProjectRelative(projectRoot, absoluteFile);
82061
- const mod2 = index.byFile.get(fileIdentityKey(absoluteFile));
82062
- const importedLocals = collectImportedLocals(mod2);
82063
- const importedFiles = collectImportedFiles(mod2);
82064
- const missingExportSuggestions = collectMissingExportSuggestions(mod2, exportLookup, reportFile, projectRoot, importedFiles);
80920
+ const mod = index.byFile.get(fileIdentityKey(absoluteFile));
80921
+ const importedLocals = collectImportedLocals(mod);
80922
+ const importedFiles = collectImportedFiles(mod);
80923
+ const missingExportSuggestions = collectMissingExportSuggestions(mod, exportLookup, reportFile, projectRoot, importedFiles);
82065
80924
  for (const suggestion of missingExportSuggestions) {
82066
80925
  if (maxSuggestions !== void 0 && output.length >= maxSuggestions)
82067
80926
  break;
@@ -82077,7 +80936,7 @@ async function collectImpactSuggestions(index, projectRoot, diffFiles, options)
82077
80936
  break;
82078
80937
  if (importedLocals.has(candidate.name))
82079
80938
  continue;
82080
- if (mod2 && mod2.locals.some((local) => local.localName === candidate.name))
80939
+ if (mod && mod.locals.some((local) => local.localName === candidate.name))
82081
80940
  continue;
82082
80941
  const result = await goToDefinition(index, {
82083
80942
  file: absoluteFile,
@@ -82126,9 +80985,9 @@ async function collectImpactSuggestions(index, projectRoot, diffFiles, options)
82126
80985
  function buildExportLookup(index) {
82127
80986
  const exportNamesByFile = /* @__PURE__ */ new Map();
82128
80987
  const filesByExportName = /* @__PURE__ */ new Map();
82129
- for (const mod2 of index.byFile.values()) {
82130
- const file2 = mod2.file;
82131
- const names = collectExportNames(mod2);
80988
+ for (const mod of index.byFile.values()) {
80989
+ const file2 = mod.file;
80990
+ const names = collectExportNames(mod);
82132
80991
  exportNamesByFile.set(fileIdentityKey(file2), names);
82133
80992
  for (const name of names) {
82134
80993
  const existing = filesByExportName.get(name) ?? /* @__PURE__ */ new Set();
@@ -82138,9 +80997,9 @@ function buildExportLookup(index) {
82138
80997
  }
82139
80998
  return { exportNamesByFile, filesByExportName };
82140
80999
  }
82141
- function collectExportNames(mod2) {
81000
+ function collectExportNames(mod) {
82142
81001
  const names = /* @__PURE__ */ new Set();
82143
- for (const entry of mod2.exports) {
81002
+ for (const entry of mod.exports) {
82144
81003
  const exportedName = getExportedName(entry);
82145
81004
  if (exportedName)
82146
81005
  names.add(exportedName);
@@ -82152,11 +81011,11 @@ function getExportedName(entry) {
82152
81011
  return entry.exportedAs;
82153
81012
  return null;
82154
81013
  }
82155
- function collectImportedLocals(mod2) {
81014
+ function collectImportedLocals(mod) {
82156
81015
  const locals = /* @__PURE__ */ new Set();
82157
- if (!mod2)
81016
+ if (!mod)
82158
81017
  return locals;
82159
- for (const binding of mod2.imports) {
81018
+ for (const binding of mod.imports) {
82160
81019
  const local = getImportLocal(binding);
82161
81020
  if (local)
82162
81021
  locals.add(local);
@@ -82170,11 +81029,11 @@ function getImportLocal(binding) {
82170
81029
  return binding.local;
82171
81030
  return null;
82172
81031
  }
82173
- function collectImportedFiles(mod2) {
81032
+ function collectImportedFiles(mod) {
82174
81033
  const files = /* @__PURE__ */ new Set();
82175
- if (!mod2)
81034
+ if (!mod)
82176
81035
  return files;
82177
- for (const binding of mod2.imports) {
81036
+ for (const binding of mod.imports) {
82178
81037
  if (binding.resolved && typeof binding.resolved === "string") {
82179
81038
  files.add(binding.resolved);
82180
81039
  }
@@ -82193,11 +81052,11 @@ function determineSuggestionConfidence({ symbol: symbol2, exportCandidateCount,
82193
81052
  function isCommonSymbolName(symbol2) {
82194
81053
  return COMMON_SYMBOLS.has(symbol2);
82195
81054
  }
82196
- function collectMissingExportSuggestions(mod2, lookup, reportFile, projectRoot, importedFiles) {
82197
- if (!mod2)
81055
+ function collectMissingExportSuggestions(mod, lookup, reportFile, projectRoot, importedFiles) {
81056
+ if (!mod)
82198
81057
  return [];
82199
81058
  const suggestions = [];
82200
- for (const binding of mod2.imports) {
81059
+ for (const binding of mod.imports) {
82201
81060
  if (!binding.resolved)
82202
81061
  continue;
82203
81062
  if (typeof binding.resolved !== "string")
@@ -82596,8 +81455,8 @@ function collectConfigAndBreakingSuggestions(index, projectRoot, fileChanges, ch
82596
81455
  const removedLines = removedLinesByFile.get(normalized);
82597
81456
  if (!removedLines || removedLines.size === 0)
82598
81457
  continue;
82599
- const mod2 = index.byFile.get(fileIdentityKey(normalized));
82600
- const hasExports = !!mod2?.exports.length;
81458
+ const mod = index.byFile.get(fileIdentityKey(normalized));
81459
+ const hasExports = !!mod?.exports.length;
82601
81460
  const alreadyHasForFile = Array.from(breakingByKey.values()).some((entry) => fileIdentityKey(entry.file) === fileIdentityKey(normalized));
82602
81461
  if (!hasExports || alreadyHasForFile)
82603
81462
  continue;
@@ -86775,7 +85634,7 @@ var init_chunk_Br0eD_fh = __esm({
86775
85634
  __getOwnPropNames2 = Object.getOwnPropertyNames;
86776
85635
  __getProtoOf2 = Object.getPrototypeOf;
86777
85636
  __hasOwnProp2 = Object.prototype.hasOwnProperty;
86778
- __commonJSMin = (cb, mod2) => () => (mod2 || cb((mod2 = { exports: {} }).exports, mod2), mod2.exports);
85637
+ __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
86779
85638
  __exportAll = (all, symbols) => {
86780
85639
  let target = {};
86781
85640
  for (var name in all) {
@@ -86803,10 +85662,10 @@ var init_chunk_Br0eD_fh = __esm({
86803
85662
  }
86804
85663
  return to;
86805
85664
  };
86806
- __toESM2 = (mod2, isNodeMode, target) => (target = mod2 != null ? __create2(__getProtoOf2(mod2)) : {}, __copyProps2(isNodeMode || !mod2 || !mod2.__esModule ? __defProp2(target, "default", {
86807
- value: mod2,
85665
+ __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", {
85666
+ value: mod,
86808
85667
  enumerable: true
86809
- }) : target, mod2));
85668
+ }) : target, mod));
86810
85669
  }
86811
85670
  });
86812
85671
 
@@ -87866,14 +86725,14 @@ function missingClientCapabilities(required2, declared) {
87866
86725
  }
87867
86726
  return Object.keys(missing).length > 0 ? missing : void 0;
87868
86727
  }
87869
- function isModernProtocolVersion(version3) {
87870
- return version3 >= FIRST_MODERN_PROTOCOL_VERSION;
86728
+ function isModernProtocolVersion(version2) {
86729
+ return version2 >= FIRST_MODERN_PROTOCOL_VERSION;
87871
86730
  }
87872
86731
  function legacyProtocolVersions(versions) {
87873
- return versions.filter((version3) => !isModernProtocolVersion(version3));
86732
+ return versions.filter((version2) => !isModernProtocolVersion(version2));
87874
86733
  }
87875
86734
  function modernProtocolVersions(versions) {
87876
- return versions.filter((version3) => isModernProtocolVersion(version3));
86735
+ return versions.filter((version2) => isModernProtocolVersion(version2));
87877
86736
  }
87878
86737
  function appendTextFallbackForNonObject(result) {
87879
86738
  const sc = result.structuredContent;
@@ -89987,8 +88846,8 @@ function getWireResultSchemas() {
89987
88846
  };
89988
88847
  return wireResultSchemasMemo;
89989
88848
  }
89990
- function codecForVersion(version3) {
89991
- return version3 !== void 0 && isModernProtocolVersion(version3) ? rev2026Codec : rev2025Codec;
88849
+ function codecForVersion(version2) {
88850
+ return version2 !== void 0 && isModernProtocolVersion(version2) ? rev2026Codec : rev2025Codec;
89992
88851
  }
89993
88852
  function classifiedWireEra(classification) {
89994
88853
  if (classification.revision !== void 0) return codecForVersion(classification.revision).era;
@@ -90654,8 +89513,8 @@ function withRequestStateValue(ctx, value) {
90654
89513
  }
90655
89514
  };
90656
89515
  }
90657
- function setNegotiatedProtocolVersion(instance, version3) {
90658
- writeNegotiatedProtocolVersion(instance, version3);
89516
+ function setNegotiatedProtocolVersion(instance, version2) {
89517
+ writeNegotiatedProtocolVersion(instance, version2);
90659
89518
  }
90660
89519
  function isPlainObject$1(value) {
90661
89520
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -91896,8 +90755,8 @@ var init_src_CX2iR2pK = __esm({
91896
90755
  */
91897
90756
  _negotiatedProtocolVersion;
91898
90757
  static {
91899
- writeNegotiatedProtocolVersion = (instance, version3) => {
91900
- instance._negotiatedProtocolVersion = version3;
90758
+ writeNegotiatedProtocolVersion = (instance, version2) => {
90759
+ instance._negotiatedProtocolVersion = version2;
91901
90760
  };
91902
90761
  }
91903
90762
  _supportedProtocolVersions;
@@ -92699,7 +91558,7 @@ function createDefaultAjvInstance(engineClass) {
92699
91558
  addFormats(ajv);
92700
91559
  return ajv;
92701
91560
  }
92702
- var require_code$1, require_scope, require_codegen, require_util2, require_names, require_errors2, require_boolSchema, require_rules, require_applicability, require_dataType, require_defaults, require_code, require_keyword, require_subschema, require_fast_deep_equal, require_json_schema_traverse, require_resolve, require_validate, require_validation_error, require_ref_error, require_compile2, require_data, require_utils6, require_schemes, require_fast_uri, require_uri, require_core$3, require_id, require_ref, require_core$2, require_limitNumber, require_multipleOf, require_ucs2length, require_limitLength, require_pattern2, require_limitProperties, require_required, require_limitItems, require_equal, require_uniqueItems, require_const, require_enum, require_validation$2, require_additionalItems, require_items, require_prefixItems, require_items2020, require_contains, require_dependencies, require_propertyNames, require_additionalProperties, require_properties, require_patternProperties, require_not, require_anyOf, require_oneOf, require_allOf, require_if, require_thenElse, require_applicator$2, require_format$2, require_format$1, require_metadata, require_draft7, require_types, require_discriminator, require_json_schema_draft_07, require_ajv, require_dynamicAnchor, require_dynamicRef, require_recursiveAnchor, require_recursiveRef, require_dynamic, require_dependentRequired, require_dependentSchemas, require_limitContains, require_next, require_unevaluatedProperties, require_unevaluatedItems, require_unevaluated$1, require_schema$1, require_applicator$1, require_content$1, require_core$1, require_format, require_meta_data$1, require_validation$1, require_json_schema_2019_09, require__2019, require_draft2020, require_schema, require_applicator, require_unevaluated, require_content, require_core, require_format_annotation, require_meta_data, require_validation, require_json_schema_2020_12, require__2020, require_formats, require_limit, require_dist2, import_ajv, import__2019, import__2020, import_dist, addFormats, AjvJsonSchemaValidator, Ajv;
91561
+ var require_code$1, require_scope, require_codegen, require_util2, require_names, require_errors, require_boolSchema, require_rules, require_applicability, require_dataType, require_defaults, require_code, require_keyword, require_subschema, require_fast_deep_equal, require_json_schema_traverse, require_resolve, require_validate, require_validation_error, require_ref_error, require_compile2, require_data, require_utils6, require_schemes, require_fast_uri, require_uri, require_core$3, require_id, require_ref, require_core$2, require_limitNumber, require_multipleOf, require_ucs2length, require_limitLength, require_pattern2, require_limitProperties, require_required, require_limitItems, require_equal, require_uniqueItems, require_const, require_enum, require_validation$2, require_additionalItems, require_items, require_prefixItems, require_items2020, require_contains, require_dependencies, require_propertyNames, require_additionalProperties, require_properties, require_patternProperties, require_not, require_anyOf, require_oneOf, require_allOf, require_if, require_thenElse, require_applicator$2, require_format$2, require_format$1, require_metadata, require_draft7, require_types, require_discriminator, require_json_schema_draft_07, require_ajv, require_dynamicAnchor, require_dynamicRef, require_recursiveAnchor, require_recursiveRef, require_dynamic, require_dependentRequired, require_dependentSchemas, require_limitContains, require_next, require_unevaluatedProperties, require_unevaluatedItems, require_unevaluated$1, require_schema$1, require_applicator$1, require_content$1, require_core$1, require_format, require_meta_data$1, require_validation$1, require_json_schema_2019_09, require__2019, require_draft2020, require_schema, require_applicator, require_unevaluated, require_content, require_core, require_format_annotation, require_meta_data, require_validation, require_json_schema_2020_12, require__2020, require_formats, require_limit, require_dist, import_ajv, import__2019, import__2020, import_dist, addFormats, AjvJsonSchemaValidator, Ajv;
92703
91562
  var init_ajvProvider_CEoC_sr = __esm({
92704
91563
  "node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs"() {
92705
91564
  init_chunk_Br0eD_fh();
@@ -93805,7 +92664,7 @@ var init_ajvProvider_CEoC_sr = __esm({
93805
92664
  };
93806
92665
  exports.default = names;
93807
92666
  }));
93808
- require_errors2 = /* @__PURE__ */ __commonJSMin(((exports) => {
92667
+ require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
93809
92668
  Object.defineProperty(exports, "__esModule", { value: true });
93810
92669
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
93811
92670
  const codegen_1 = require_codegen();
@@ -93901,7 +92760,7 @@ var init_ajvProvider_CEoC_sr = __esm({
93901
92760
  require_boolSchema = /* @__PURE__ */ __commonJSMin(((exports) => {
93902
92761
  Object.defineProperty(exports, "__esModule", { value: true });
93903
92762
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
93904
- const errors_1 = require_errors2();
92763
+ const errors_1 = require_errors();
93905
92764
  const codegen_1 = require_codegen();
93906
92765
  const names_1 = require_names();
93907
92766
  const boolError = { message: "boolean schema is false" };
@@ -94017,7 +92876,7 @@ var init_ajvProvider_CEoC_sr = __esm({
94017
92876
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
94018
92877
  const rules_1 = require_rules();
94019
92878
  const applicability_1 = require_applicability();
94020
- const errors_1 = require_errors2();
92879
+ const errors_1 = require_errors();
94021
92880
  const codegen_1 = require_codegen();
94022
92881
  const util_1 = require_util2();
94023
92882
  var DataType;
@@ -94328,7 +93187,7 @@ var init_ajvProvider_CEoC_sr = __esm({
94328
93187
  const codegen_1 = require_codegen();
94329
93188
  const names_1 = require_names();
94330
93189
  const code_1 = require_code();
94331
- const errors_1 = require_errors2();
93190
+ const errors_1 = require_errors();
94332
93191
  function macroKeywordCode(cxt, def) {
94333
93192
  const { gen, keyword, schema, parentSchema, it } = cxt;
94334
93193
  const macroSchema = def.macro.call(it.self, schema, parentSchema, it);
@@ -94732,7 +93591,7 @@ var init_ajvProvider_CEoC_sr = __esm({
94732
93591
  const names_1 = require_names();
94733
93592
  const resolve_1 = require_resolve();
94734
93593
  const util_1 = require_util2();
94735
- const errors_1 = require_errors2();
93594
+ const errors_1 = require_errors();
94736
93595
  function validateFunctionCode(it) {
94737
93596
  if (isSchemaObj(it)) {
94738
93597
  checkKeywords(it);
@@ -99608,7 +98467,7 @@ var init_ajvProvider_CEoC_sr = __esm({
99608
98467
  };
99609
98468
  exports.default = formatLimitPlugin;
99610
98469
  }));
99611
- require_dist2 = /* @__PURE__ */ __commonJSMin(((exports, module2) => {
98470
+ require_dist = /* @__PURE__ */ __commonJSMin(((exports, module2) => {
99612
98471
  Object.defineProperty(exports, "__esModule", { value: true });
99613
98472
  const formats_1 = require_formats();
99614
98473
  const limit_1 = require_limit();
@@ -99643,7 +98502,7 @@ var init_ajvProvider_CEoC_sr = __esm({
99643
98502
  import_ajv = require_ajv();
99644
98503
  import__2019 = require__2019();
99645
98504
  import__2020 = require__2020();
99646
- import_dist = /* @__PURE__ */ __toESM2(require_dist2(), 1);
98505
+ import_dist = /* @__PURE__ */ __toESM2(require_dist(), 1);
99647
98506
  addFormats = import_dist.default;
99648
98507
  AjvJsonSchemaValidator = class {
99649
98508
  _ajv;
@@ -100302,7 +99161,7 @@ var init_mcp_DXXb3Vv3 = __esm({
100302
99161
  if (identity.clientInfo !== void 0) server._clientVersion = identity.clientInfo;
100303
99162
  };
100304
99163
  installDiscoverHandler = (server, servedModernVersions) => {
100305
- const missing = servedModernVersions.filter((version3) => !server._supportedProtocolVersions.includes(version3));
99164
+ const missing = servedModernVersions.filter((version2) => !server._supportedProtocolVersions.includes(version2));
100306
99165
  if (missing.length > 0) server._supportedProtocolVersions = [...server._supportedProtocolVersions, ...missing];
100307
99166
  server.setRequestHandler("server/discover", () => server._ondiscover());
100308
99167
  };
@@ -101860,8 +100719,8 @@ var init_stdio = __esm({
101860
100719
  if (this._outboundIntercept?.(message) === "handled") return;
101861
100720
  return this._wire.send(message, options);
101862
100721
  }
101863
- setProtocolVersion = (version3) => {
101864
- this._wire.setProtocolVersion?.(version3);
100722
+ setProtocolVersion = (version2) => {
100723
+ this._wire.setProtocolVersion?.(version2);
101865
100724
  };
101866
100725
  /** Forwards one inbound message to the connected instance. */
101867
100726
  deliver(message, extra) {
@@ -108936,8 +107795,8 @@ function formatIndexOutput(output) {
108936
107795
  return lines.join("\n");
108937
107796
  }
108938
107797
  lines.push("Modules:");
108939
- for (const mod2 of output.modules) {
108940
- lines.push(`- ${mod2.file}: ${mod2.locals.length} locals, ${mod2.exports.length} exports, ${mod2.imports.length} imports`);
107798
+ for (const mod of output.modules) {
107799
+ lines.push(`- ${mod.file}: ${mod.locals.length} locals, ${mod.exports.length} exports, ${mod.imports.length} imports`);
108941
107800
  }
108942
107801
  return lines.join("\n");
108943
107802
  }
@@ -108945,10 +107804,16 @@ async function handleIndexCommand(context) {
108945
107804
  const verbose = context.hasFlag("--verbose");
108946
107805
  const commandReport = context.reportEnabled ? { command: "index", timings: {} } : void 0;
108947
107806
  const commandStart = performance16.now();
108948
- const resolveStart = performance16.now();
108949
- const files = await context.resolveFiles();
108950
- if (commandReport) {
108951
- commandReport.timings.resolveFilesMs = Math.round(performance16.now() - resolveStart);
107807
+ const shouldWriteManifest = !context.includeRootsAbs.length && !context.gitBase && !context.changedSince;
107808
+ const hasCliDiscoveryGlob = context.getOpt("--include-glob") !== void 0 || context.getOpt("--ignore-glob") !== void 0;
107809
+ const needsResolvedFiles = !shouldWriteManifest || hasCliDiscoveryGlob;
107810
+ let files = [];
107811
+ if (needsResolvedFiles) {
107812
+ const resolveStart = performance16.now();
107813
+ files = await context.resolveFiles();
107814
+ if (commandReport) {
107815
+ commandReport.timings.resolveFilesMs = Math.round(performance16.now() - resolveStart);
107816
+ }
108952
107817
  }
108953
107818
  const threads = parseNonNegativeIntegerOption(context.getOpt("--threads"), "--threads", 0);
108954
107819
  const cache = parseCacheModeOption(context.getOpt("--cache"));
@@ -108956,7 +107821,6 @@ async function handleIndexCommand(context) {
108956
107821
  const cacheStrict = context.hasFlag("--cache-strict");
108957
107822
  const full = context.hasFlag("--json") || context.hasFlag("--full");
108958
107823
  const cacheVerify = context.hasFlag("--cache-verify");
108959
- const shouldWriteManifest = !context.includeRootsAbs.length && !context.gitBase && !context.changedSince;
108960
107824
  const indexReport = { timings: {} };
108961
107825
  if (commandReport) {
108962
107826
  commandReport.index = indexReport;
@@ -110612,8 +109476,8 @@ async function handleDumpmodCommand(context) {
110612
109476
  }
110613
109477
  const file2 = resolvedFile.file;
110614
109478
  const index = await loadNavigationIndex(context);
110615
- const mod2 = index.byFile.get(fileIdentityKey(file2));
110616
- if (!mod2) {
109479
+ const mod = index.byFile.get(fileIdentityKey(file2));
109480
+ if (!mod) {
110617
109481
  writeCliOutput(context, {
110618
109482
  status: "not_found",
110619
109483
  reason: "Module not indexed",
@@ -110623,13 +109487,13 @@ async function handleDumpmodCommand(context) {
110623
109487
  }
110624
109488
  writeCliOutput(context, {
110625
109489
  file: file2,
110626
- locals: mod2.locals.map((l) => ({
109490
+ locals: mod.locals.map((l) => ({
110627
109491
  name: l.localName,
110628
109492
  kind: l.kind,
110629
109493
  start: l.range.start
110630
109494
  })),
110631
- imports: mod2.imports,
110632
- exports: mod2.exports.map((e) => e.type === "local" ? {
109495
+ imports: mod.imports,
109496
+ exports: mod.exports.map((e) => e.type === "local" ? {
110633
109497
  type: e.type,
110634
109498
  exportedAs: e.exportedAs,
110635
109499
  def: {
@@ -113902,6 +112766,7 @@ var init_discoveryGlobs = __esm({
113902
112766
 
113903
112767
  // dist/cli/invocationContext.js
113904
112768
  import fs46 from "node:fs";
112769
+ import fsp44 from "node:fs/promises";
113905
112770
  import path96 from "node:path";
113906
112771
  function loadDiscoveryGlobHelpers() {
113907
112772
  discoveryGlobHelpersPromise ??= Promise.resolve().then(() => (init_discoveryGlobs(), discoveryGlobs_exports));
@@ -114004,7 +112869,7 @@ function createCliBaseContext(command, parsed) {
114004
112869
  }
114005
112870
  async function loadCliProjectContext(base) {
114006
112871
  const { command, parsed, getOpt, hasFlag, projectRootFs } = base;
114007
- const { cliGlobDiscoveryOptions, activeCliRootGlobDiscoveryOptions, cliGitignoreDiscoveryOptions, gitBase, gitHead, changedSince, graphFlags } = base;
112872
+ const { cliGlobDiscoveryOptions, activeCliRootGlobDiscoveryOptions, cliGitignoreDiscoveryOptions, hasCliDiscoveryGlobs, gitBase, gitHead, changedSince, graphFlags } = base;
114008
112873
  const { hasDiscoveryOptions: hasDiscoveryOptions2, loadCodegraphConfig: loadCodegraphConfig2, mergeDiscoveryOptions: mergeDiscoveryOptions2 } = await loadConfigHelpers();
114009
112874
  const explicitDiscoveryOptions = mergeDiscoveryOptions2(cliGlobDiscoveryOptions, cliGitignoreDiscoveryOptions);
114010
112875
  const config2 = await loadCodegraphConfig2(projectRootFs);
@@ -114072,48 +112937,101 @@ async function loadCliProjectContext(base) {
114072
112937
  }
114073
112938
  return rootFilteredFiles.filter((filePath) => matchedFiles.has(filePath));
114074
112939
  };
114075
- const resolveFilesFromRoots = async () => {
114076
- const { listProjectFiles: listProjectFiles2 } = await loadProjectFilesHelpers();
112940
+ const discoveryWalkCache = /* @__PURE__ */ new Map();
112941
+ let knownSymlinkDirectories;
112942
+ let symlinkHintResolved = false;
112943
+ const resolveKnownSymlinkDirectories = async () => {
112944
+ if (symlinkHintResolved)
112945
+ return knownSymlinkDirectories;
112946
+ symlinkHintResolved = true;
112947
+ try {
112948
+ const { loadManifest: loadManifest2 } = await Promise.resolve().then(() => (init_build_cache(), build_cache_exports));
112949
+ const symlinkHintManifest = await loadManifest2(projectRootFs, {
112950
+ ...config2.cache?.location ? { cacheLocation: config2.cache.location } : {}
112951
+ });
112952
+ if (symlinkHintManifest?.symlinkDirectories !== void 0 && symlinkHintManifest.symlinkDirectoriesRootMtimeMs !== void 0) {
112953
+ const rootMtime = (await fsp44.stat(projectRootFs)).mtimeMs;
112954
+ if (rootMtime === symlinkHintManifest.symlinkDirectoriesRootMtimeMs) {
112955
+ knownSymlinkDirectories = symlinkHintManifest.symlinkDirectories;
112956
+ }
112957
+ }
112958
+ } catch {
112959
+ knownSymlinkDirectories = void 0;
112960
+ }
112961
+ return knownSymlinkDirectories;
112962
+ };
112963
+ const discoveryWalkCacheKey = (scanRoot, patterns, options) => JSON.stringify({
112964
+ scanRoot: normalizePath(scanRoot),
112965
+ patterns: patterns ?? null,
112966
+ includeGlobs: options.includeGlobs ?? null,
112967
+ ignoreGlobs: options.ignoreGlobs ?? null,
112968
+ globRoot: options.globRoot ? normalizePath(options.globRoot) : null,
112969
+ useGitignore: options.useGitignore ?? null,
112970
+ gitignoreRoot: options.gitignoreRoot ? normalizePath(options.gitignoreRoot) : null,
112971
+ logLevel: options.logLevel ?? null
112972
+ });
112973
+ const listDiscoveredProjectFiles = async (scanRoot, patterns, options) => {
112974
+ const symlinkDirectories = await resolveKnownSymlinkDirectories();
112975
+ const walkOptions = {
112976
+ ...options,
112977
+ ...symlinkDirectories !== void 0 ? { knownSymlinkDirectories: symlinkDirectories } : {}
112978
+ };
112979
+ const key = discoveryWalkCacheKey(scanRoot, patterns, walkOptions);
112980
+ let pending = discoveryWalkCache.get(key);
112981
+ if (!pending) {
112982
+ pending = (async () => {
112983
+ const { listProjectFilesWithGitCandidates: listProjectFilesWithGitCandidates2 } = await loadProjectFilesHelpers();
112984
+ return await listProjectFilesWithGitCandidates2(scanRoot, patterns, walkOptions);
112985
+ })();
112986
+ discoveryWalkCache.set(key, pending);
112987
+ }
112988
+ return await pending;
112989
+ };
112990
+ const resolveDiscoveryPatterns = async () => {
114077
112991
  const basePatterns = command === "duplicates" ? await getDuplicateProjectPatterns() : void 0;
114078
112992
  const [{ languageExtensionPatterns: languageExtensionPatterns2 }, { DEFAULT_PROJECT_PATTERNS: DEFAULT_PROJECT_PATTERNS2 }] = await Promise.all([
114079
112993
  Promise.resolve().then(() => (init_languages(), languages_exports)),
114080
112994
  loadProjectFilesHelpers()
114081
112995
  ]);
114082
112996
  const customPatterns = languageExtensionPatterns2(config2.languages?.extensions);
114083
- const patterns = customPatterns.length ? [...basePatterns ?? DEFAULT_PROJECT_PATTERNS2, ...customPatterns] : basePatterns;
112997
+ return customPatterns.length ? [...basePatterns ?? DEFAULT_PROJECT_PATTERNS2, ...customPatterns] : basePatterns;
112998
+ };
112999
+ const resolveFilesFromRoots = async () => {
113000
+ const patterns = await resolveDiscoveryPatterns();
113001
+ const walkDiscoveryOptions = hasCliDiscoveryGlobs ? diagnosticDiscoveryOptions : discoveryOptions;
113002
+ const walkOptions = {
113003
+ ...walkDiscoveryOptions,
113004
+ gitignoreRoot: projectRootFs
113005
+ };
114084
113006
  if (!includeRootsAbs.length) {
114085
- const diagnosticFiles = await listProjectFiles2(projectRootFs, patterns, {
114086
- ...diagnosticDiscoveryOptions,
114087
- gitignoreRoot: projectRootFs
114088
- });
114089
- recordCliGlobDiagnostics(diagnosticFiles, projectRootFs);
114090
- flushCliGlobDiagnostics();
114091
- if (!hasDiscoveryOptions2(activeCliRootGlobDiscoveryOptions)) {
114092
- return await listProjectFiles2(projectRootFs, patterns, {
114093
- ...discoveryOptions,
114094
- gitignoreRoot: projectRootFs
114095
- });
113007
+ const files = await listDiscoveredProjectFiles(projectRootFs, patterns, walkOptions);
113008
+ if (hasCliDiscoveryGlobs) {
113009
+ recordCliGlobDiagnostics(files, projectRootFs);
113010
+ flushCliGlobDiagnostics();
113011
+ return applyCliDiscoveryFilters(files);
114096
113012
  }
114097
- return applyCliDiscoveryFilters(diagnosticFiles);
113013
+ return files;
114098
113014
  }
114099
- const normalizedRoots = includeRootsAbs;
114100
- const all = await Promise.all(normalizedRoots.map(async (r) => {
114101
- const files = await listProjectFiles2(r, patterns, {
114102
- ...diagnosticDiscoveryOptions,
114103
- gitignoreRoot: projectRootFs
114104
- });
114105
- recordCliGlobDiagnostics(files, r);
113015
+ const all = await Promise.all(includeRootsAbs.map(async (scanRoot) => {
113016
+ const files = await listDiscoveredProjectFiles(scanRoot, patterns, walkOptions);
113017
+ if (hasCliDiscoveryGlobs) {
113018
+ recordCliGlobDiagnostics(files, scanRoot);
113019
+ }
114106
113020
  return files;
114107
113021
  }));
114108
- flushCliGlobDiagnostics();
113022
+ if (hasCliDiscoveryGlobs) {
113023
+ flushCliGlobDiagnostics();
113024
+ }
114109
113025
  return applyCliDiscoveryFilters(Array.from(new Set(all.flat())));
114110
113026
  };
114111
113027
  const listProjectFilesForScan = async (scanRoot) => {
114112
- const { listProjectFiles: listProjectFiles2 } = await loadProjectFilesHelpers();
114113
113028
  if (scanRoot === projectRootFs) {
114114
- return await listProjectFiles2(scanRoot, void 0, discoveryOptions);
113029
+ return await listDiscoveredProjectFiles(scanRoot, void 0, {
113030
+ ...discoveryOptions,
113031
+ gitignoreRoot: projectRootFs
113032
+ });
114115
113033
  }
114116
- const files = await listProjectFiles2(scanRoot, void 0, {
113034
+ const files = await listDiscoveredProjectFiles(scanRoot, void 0, {
114117
113035
  ...includeRootDiscoveryOptions,
114118
113036
  gitignoreRoot: projectRootFs
114119
113037
  });
@@ -114141,8 +113059,7 @@ async function loadCliProjectContext(base) {
114141
113059
  const deletedFiles = files.filter((filePath) => !fs46.existsSync(filePath));
114142
113060
  const scanRoots = includeRootsAbs.length ? includeRootsAbs : [projectRootFs];
114143
113061
  await Promise.all(scanRoots.map(async (scanRoot) => {
114144
- const { listProjectFiles: listProjectFiles2 } = await loadProjectFilesHelpers();
114145
- const currentFiles = fs46.existsSync(scanRoot) ? await listProjectFiles2(scanRoot, patterns, {
113062
+ const currentFiles = fs46.existsSync(scanRoot) ? await listDiscoveredProjectFiles(scanRoot, patterns, {
114146
113063
  ...diagnosticDiscoveryOptions,
114147
113064
  gitignoreRoot: projectRootFs
114148
113065
  }) : [];