opencode-codebase-index 0.1.8 → 0.1.10

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/index.cjs CHANGED
@@ -491,7 +491,7 @@ var require_ignore = __commonJS({
491
491
  // path matching.
492
492
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
493
493
  // @returns {TestResult} true if a file is ignored
494
- test(path9, checkUnignored, mode) {
494
+ test(path8, checkUnignored, mode) {
495
495
  let ignored = false;
496
496
  let unignored = false;
497
497
  let matchedRule;
@@ -500,7 +500,7 @@ var require_ignore = __commonJS({
500
500
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
501
501
  return;
502
502
  }
503
- const matched = rule[mode].test(path9);
503
+ const matched = rule[mode].test(path8);
504
504
  if (!matched) {
505
505
  return;
506
506
  }
@@ -521,17 +521,17 @@ var require_ignore = __commonJS({
521
521
  var throwError = (message, Ctor) => {
522
522
  throw new Ctor(message);
523
523
  };
524
- var checkPath = (path9, originalPath, doThrow) => {
525
- if (!isString(path9)) {
524
+ var checkPath = (path8, originalPath, doThrow) => {
525
+ if (!isString(path8)) {
526
526
  return doThrow(
527
527
  `path must be a string, but got \`${originalPath}\``,
528
528
  TypeError
529
529
  );
530
530
  }
531
- if (!path9) {
531
+ if (!path8) {
532
532
  return doThrow(`path must not be empty`, TypeError);
533
533
  }
534
- if (checkPath.isNotRelative(path9)) {
534
+ if (checkPath.isNotRelative(path8)) {
535
535
  const r = "`path.relative()`d";
536
536
  return doThrow(
537
537
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -540,7 +540,7 @@ var require_ignore = __commonJS({
540
540
  }
541
541
  return true;
542
542
  };
543
- var isNotRelative = (path9) => REGEX_TEST_INVALID_PATH.test(path9);
543
+ var isNotRelative = (path8) => REGEX_TEST_INVALID_PATH.test(path8);
544
544
  checkPath.isNotRelative = isNotRelative;
545
545
  checkPath.convert = (p) => p;
546
546
  var Ignore2 = class {
@@ -570,19 +570,19 @@ var require_ignore = __commonJS({
570
570
  }
571
571
  // @returns {TestResult}
572
572
  _test(originalPath, cache, checkUnignored, slices) {
573
- const path9 = originalPath && checkPath.convert(originalPath);
573
+ const path8 = originalPath && checkPath.convert(originalPath);
574
574
  checkPath(
575
- path9,
575
+ path8,
576
576
  originalPath,
577
577
  this._strictPathCheck ? throwError : RETURN_FALSE
578
578
  );
579
- return this._t(path9, cache, checkUnignored, slices);
579
+ return this._t(path8, cache, checkUnignored, slices);
580
580
  }
581
- checkIgnore(path9) {
582
- if (!REGEX_TEST_TRAILING_SLASH.test(path9)) {
583
- return this.test(path9);
581
+ checkIgnore(path8) {
582
+ if (!REGEX_TEST_TRAILING_SLASH.test(path8)) {
583
+ return this.test(path8);
584
584
  }
585
- const slices = path9.split(SLASH2).filter(Boolean);
585
+ const slices = path8.split(SLASH2).filter(Boolean);
586
586
  slices.pop();
587
587
  if (slices.length) {
588
588
  const parent = this._t(
@@ -595,18 +595,18 @@ var require_ignore = __commonJS({
595
595
  return parent;
596
596
  }
597
597
  }
598
- return this._rules.test(path9, false, MODE_CHECK_IGNORE);
598
+ return this._rules.test(path8, false, MODE_CHECK_IGNORE);
599
599
  }
600
- _t(path9, cache, checkUnignored, slices) {
601
- if (path9 in cache) {
602
- return cache[path9];
600
+ _t(path8, cache, checkUnignored, slices) {
601
+ if (path8 in cache) {
602
+ return cache[path8];
603
603
  }
604
604
  if (!slices) {
605
- slices = path9.split(SLASH2).filter(Boolean);
605
+ slices = path8.split(SLASH2).filter(Boolean);
606
606
  }
607
607
  slices.pop();
608
608
  if (!slices.length) {
609
- return cache[path9] = this._rules.test(path9, checkUnignored, MODE_IGNORE);
609
+ return cache[path8] = this._rules.test(path8, checkUnignored, MODE_IGNORE);
610
610
  }
611
611
  const parent = this._t(
612
612
  slices.join(SLASH2) + SLASH2,
@@ -614,29 +614,29 @@ var require_ignore = __commonJS({
614
614
  checkUnignored,
615
615
  slices
616
616
  );
617
- return cache[path9] = parent.ignored ? parent : this._rules.test(path9, checkUnignored, MODE_IGNORE);
617
+ return cache[path8] = parent.ignored ? parent : this._rules.test(path8, checkUnignored, MODE_IGNORE);
618
618
  }
619
- ignores(path9) {
620
- return this._test(path9, this._ignoreCache, false).ignored;
619
+ ignores(path8) {
620
+ return this._test(path8, this._ignoreCache, false).ignored;
621
621
  }
622
622
  createFilter() {
623
- return (path9) => !this.ignores(path9);
623
+ return (path8) => !this.ignores(path8);
624
624
  }
625
625
  filter(paths) {
626
626
  return makeArray(paths).filter(this.createFilter());
627
627
  }
628
628
  // @returns {TestResult}
629
- test(path9) {
630
- return this._test(path9, this._testCache, true);
629
+ test(path8) {
630
+ return this._test(path8, this._testCache, true);
631
631
  }
632
632
  };
633
633
  var factory = (options) => new Ignore2(options);
634
- var isPathValid = (path9) => checkPath(path9 && checkPath.convert(path9), path9, RETURN_FALSE);
634
+ var isPathValid = (path8) => checkPath(path8 && checkPath.convert(path8), path8, RETURN_FALSE);
635
635
  var setupWindows = () => {
636
636
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
637
637
  checkPath.convert = makePosix;
638
638
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
639
- checkPath.isNotRelative = (path9) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path9) || isNotRelative(path9);
639
+ checkPath.isNotRelative = (path8) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path8) || isNotRelative(path8);
640
640
  };
641
641
  if (
642
642
  // Detect `process` so that it can run in browsers.
@@ -657,8 +657,8 @@ __export(index_exports, {
657
657
  default: () => index_default
658
658
  });
659
659
  module.exports = __toCommonJS(index_exports);
660
- var import_fs6 = require("fs");
661
- var path8 = __toESM(require("path"), 1);
660
+ var import_fs5 = require("fs");
661
+ var path7 = __toESM(require("path"), 1);
662
662
 
663
663
  // src/config/schema.ts
664
664
  var DEFAULT_INCLUDE = [
@@ -807,8 +807,8 @@ function getDefaultModelForProvider(provider) {
807
807
  }
808
808
 
809
809
  // src/indexer/index.ts
810
- var import_fs5 = require("fs");
811
- var path6 = __toESM(require("path"), 1);
810
+ var import_fs4 = require("fs");
811
+ var path5 = __toESM(require("path"), 1);
812
812
 
813
813
  // node_modules/eventemitter3/index.mjs
814
814
  var import_index = __toESM(require_eventemitter3(), 1);
@@ -1879,7 +1879,7 @@ function getGitHubCopilotCredentials() {
1879
1879
  if (!copilotAuth || copilotAuth.type !== "oauth") {
1880
1880
  return null;
1881
1881
  }
1882
- const baseUrl = copilotAuth.enterpriseUrl ? `https://copilot-api.${copilotAuth.enterpriseUrl.replace(/^https?:\/\//, "").replace(/\/$/, "")}` : "https://api.githubcopilot.com";
1882
+ const baseUrl = copilotAuth.enterpriseUrl ? `https://copilot-api.${copilotAuth.enterpriseUrl.replace(/^https?:\/\//, "").replace(/\/$/, "")}` : "https://models.github.ai";
1883
1883
  return {
1884
1884
  provider: "github-copilot",
1885
1885
  baseUrl,
@@ -1954,9 +1954,6 @@ function getProviderDisplayName(provider) {
1954
1954
  }
1955
1955
 
1956
1956
  // src/embeddings/provider.ts
1957
- var import_fs2 = require("fs");
1958
- var path2 = __toESM(require("path"), 1);
1959
- var os2 = __toESM(require("os"), 1);
1960
1957
  function createEmbeddingProvider(credentials, modelInfo) {
1961
1958
  switch (credentials.provider) {
1962
1959
  case "github-copilot":
@@ -1971,56 +1968,16 @@ function createEmbeddingProvider(credentials, modelInfo) {
1971
1968
  throw new Error(`Unsupported embedding provider: ${credentials.provider}`);
1972
1969
  }
1973
1970
  }
1974
- var COPILOT_HEADERS = {
1975
- "User-Agent": "GitHubCopilotChat/0.35.0",
1976
- "Editor-Version": "vscode/1.107.0",
1977
- "Editor-Plugin-Version": "copilot-chat/0.35.0",
1978
- "Copilot-Integration-Id": "vscode-chat",
1979
- "Openai-Intent": "conversation-edits"
1980
- };
1981
1971
  var GitHubCopilotEmbeddingProvider = class {
1982
1972
  constructor(credentials, modelInfo) {
1983
1973
  this.credentials = credentials;
1984
1974
  this.modelInfo = modelInfo;
1985
- this.accessToken = credentials.accessToken || "";
1986
- this.tokenExpires = credentials.tokenExpires || 0;
1987
1975
  }
1988
- accessToken;
1989
- tokenExpires;
1990
- async ensureValidToken() {
1991
- if (this.accessToken && this.tokenExpires > Date.now()) {
1992
- return this.accessToken;
1993
- }
1976
+ getToken() {
1994
1977
  if (!this.credentials.refreshToken) {
1995
- throw new Error("No refresh token available for GitHub Copilot");
1996
- }
1997
- const response = await fetch("https://api.github.com/copilot_internal/v2/token", {
1998
- headers: {
1999
- Accept: "application/json",
2000
- Authorization: `Bearer ${this.credentials.refreshToken}`,
2001
- ...COPILOT_HEADERS
2002
- }
2003
- });
2004
- if (!response.ok) {
2005
- throw new Error(`Token refresh failed: ${response.status}`);
2006
- }
2007
- const tokenData = await response.json();
2008
- this.accessToken = tokenData.token;
2009
- this.tokenExpires = tokenData.expires_at * 1e3 - 5 * 60 * 1e3;
2010
- this.persistToken(tokenData.token, this.tokenExpires);
2011
- return this.accessToken;
2012
- }
2013
- persistToken(token, expires) {
2014
- try {
2015
- const authPath = path2.join(os2.homedir(), ".local", "share", "opencode", "auth.json");
2016
- const authData = JSON.parse((0, import_fs2.readFileSync)(authPath, "utf-8"));
2017
- if (authData["github-copilot"]) {
2018
- authData["github-copilot"].access = token;
2019
- authData["github-copilot"].expires = expires;
2020
- (0, import_fs2.writeFileSync)(authPath, JSON.stringify(authData, null, 2));
2021
- }
2022
- } catch {
1978
+ throw new Error("No OAuth token available for GitHub");
2023
1979
  }
1980
+ return this.credentials.refreshToken;
2024
1981
  }
2025
1982
  async embed(text) {
2026
1983
  const result = await this.embedBatch([text]);
@@ -2030,16 +1987,17 @@ var GitHubCopilotEmbeddingProvider = class {
2030
1987
  };
2031
1988
  }
2032
1989
  async embedBatch(texts) {
2033
- const token = await this.ensureValidToken();
2034
- const response = await fetch(`${this.credentials.baseUrl}/embeddings`, {
1990
+ const token = this.getToken();
1991
+ const response = await fetch(`${this.credentials.baseUrl}/inference/embeddings`, {
2035
1992
  method: "POST",
2036
1993
  headers: {
2037
1994
  Authorization: `Bearer ${token}`,
2038
1995
  "Content-Type": "application/json",
2039
- ...COPILOT_HEADERS
1996
+ Accept: "application/vnd.github+json",
1997
+ "X-GitHub-Api-Version": "2022-11-28"
2040
1998
  },
2041
1999
  body: JSON.stringify({
2042
- model: this.modelInfo.model,
2000
+ model: `openai/${this.modelInfo.model}`,
2043
2001
  input: texts
2044
2002
  })
2045
2003
  });
@@ -2188,8 +2146,8 @@ var OllamaEmbeddingProvider = class {
2188
2146
 
2189
2147
  // src/utils/files.ts
2190
2148
  var import_ignore = __toESM(require_ignore(), 1);
2191
- var import_fs3 = require("fs");
2192
- var path3 = __toESM(require("path"), 1);
2149
+ var import_fs2 = require("fs");
2150
+ var path2 = __toESM(require("path"), 1);
2193
2151
  function createIgnoreFilter(projectRoot) {
2194
2152
  const ig = (0, import_ignore.default)();
2195
2153
  const defaultIgnores = [
@@ -2206,15 +2164,15 @@ function createIgnoreFilter(projectRoot) {
2206
2164
  ".opencode"
2207
2165
  ];
2208
2166
  ig.add(defaultIgnores);
2209
- const gitignorePath = path3.join(projectRoot, ".gitignore");
2210
- if ((0, import_fs3.existsSync)(gitignorePath)) {
2211
- const gitignoreContent = (0, import_fs3.readFileSync)(gitignorePath, "utf-8");
2167
+ const gitignorePath = path2.join(projectRoot, ".gitignore");
2168
+ if ((0, import_fs2.existsSync)(gitignorePath)) {
2169
+ const gitignoreContent = (0, import_fs2.readFileSync)(gitignorePath, "utf-8");
2212
2170
  ig.add(gitignoreContent);
2213
2171
  }
2214
2172
  return ig;
2215
2173
  }
2216
2174
  function shouldIncludeFile(filePath, projectRoot, includePatterns, excludePatterns, ignoreFilter) {
2217
- const relativePath = path3.relative(projectRoot, filePath);
2175
+ const relativePath = path2.relative(projectRoot, filePath);
2218
2176
  if (ignoreFilter.ignores(relativePath)) {
2219
2177
  return false;
2220
2178
  }
@@ -2236,10 +2194,10 @@ function matchGlob(filePath, pattern) {
2236
2194
  return regex.test(filePath);
2237
2195
  }
2238
2196
  async function* walkDirectory(dir, projectRoot, includePatterns, excludePatterns, ignoreFilter, maxFileSize, skipped) {
2239
- const entries = await import_fs3.promises.readdir(dir, { withFileTypes: true });
2197
+ const entries = await import_fs2.promises.readdir(dir, { withFileTypes: true });
2240
2198
  for (const entry of entries) {
2241
- const fullPath = path3.join(dir, entry.name);
2242
- const relativePath = path3.relative(projectRoot, fullPath);
2199
+ const fullPath = path2.join(dir, entry.name);
2200
+ const relativePath = path2.relative(projectRoot, fullPath);
2243
2201
  if (ignoreFilter.ignores(relativePath)) {
2244
2202
  if (entry.isFile()) {
2245
2203
  skipped.push({ path: relativePath, reason: "gitignore" });
@@ -2257,7 +2215,7 @@ async function* walkDirectory(dir, projectRoot, includePatterns, excludePatterns
2257
2215
  skipped
2258
2216
  );
2259
2217
  } else if (entry.isFile()) {
2260
- const stat4 = await import_fs3.promises.stat(fullPath);
2218
+ const stat4 = await import_fs2.promises.stat(fullPath);
2261
2219
  if (stat4.size > maxFileSize) {
2262
2220
  skipped.push({ path: relativePath, reason: "too_large" });
2263
2221
  continue;
@@ -2362,13 +2320,13 @@ function padRight(str, length) {
2362
2320
  }
2363
2321
 
2364
2322
  // src/native/index.ts
2365
- var path4 = __toESM(require("path"), 1);
2366
- var os3 = __toESM(require("os"), 1);
2323
+ var path3 = __toESM(require("path"), 1);
2324
+ var os2 = __toESM(require("os"), 1);
2367
2325
  var import_url = require("url");
2368
2326
  var import_meta = {};
2369
2327
  function getNativeBinding() {
2370
- const platform2 = os3.platform();
2371
- const arch2 = os3.arch();
2328
+ const platform2 = os2.platform();
2329
+ const arch2 = os2.arch();
2372
2330
  let bindingName;
2373
2331
  if (platform2 === "darwin" && arch2 === "arm64") {
2374
2332
  bindingName = "codebase-index-native.darwin-arm64.node";
@@ -2385,15 +2343,15 @@ function getNativeBinding() {
2385
2343
  }
2386
2344
  let currentDir;
2387
2345
  if (typeof import_meta !== "undefined" && import_meta.url) {
2388
- currentDir = path4.dirname((0, import_url.fileURLToPath)(import_meta.url));
2346
+ currentDir = path3.dirname((0, import_url.fileURLToPath)(import_meta.url));
2389
2347
  } else if (typeof __dirname !== "undefined") {
2390
2348
  currentDir = __dirname;
2391
2349
  } else {
2392
2350
  currentDir = process.cwd();
2393
2351
  }
2394
2352
  const isDevMode = currentDir.includes("/src/native");
2395
- const packageRoot = isDevMode ? path4.resolve(currentDir, "../..") : path4.resolve(currentDir, "..");
2396
- const nativePath = path4.join(packageRoot, "native", bindingName);
2353
+ const packageRoot = isDevMode ? path3.resolve(currentDir, "../..") : path3.resolve(currentDir, "..");
2354
+ const nativePath = path3.join(packageRoot, "native", bindingName);
2397
2355
  return require(nativePath);
2398
2356
  }
2399
2357
  var native = getNativeBinding();
@@ -2670,22 +2628,22 @@ function generateChunkHash(chunk) {
2670
2628
  }
2671
2629
 
2672
2630
  // src/indexer/inverted-index.ts
2673
- var import_fs4 = require("fs");
2674
- var path5 = __toESM(require("path"), 1);
2631
+ var import_fs3 = require("fs");
2632
+ var path4 = __toESM(require("path"), 1);
2675
2633
  var InvertedIndex = class {
2676
2634
  indexPath;
2677
2635
  termToChunks = /* @__PURE__ */ new Map();
2678
2636
  chunkTokens = /* @__PURE__ */ new Map();
2679
2637
  totalTokenCount = 0;
2680
2638
  constructor(indexPath) {
2681
- this.indexPath = path5.join(indexPath, "inverted-index.json");
2639
+ this.indexPath = path4.join(indexPath, "inverted-index.json");
2682
2640
  }
2683
2641
  load() {
2684
- if (!(0, import_fs4.existsSync)(this.indexPath)) {
2642
+ if (!(0, import_fs3.existsSync)(this.indexPath)) {
2685
2643
  return;
2686
2644
  }
2687
2645
  try {
2688
- const content = (0, import_fs4.readFileSync)(this.indexPath, "utf-8");
2646
+ const content = (0, import_fs3.readFileSync)(this.indexPath, "utf-8");
2689
2647
  const data = JSON.parse(content);
2690
2648
  for (const [term, chunkIds] of Object.entries(data.termToChunks)) {
2691
2649
  this.termToChunks.set(term, new Set(chunkIds));
@@ -2715,7 +2673,7 @@ var InvertedIndex = class {
2715
2673
  for (const [chunkId, tokens] of this.chunkTokens) {
2716
2674
  data.chunkTokens[chunkId] = Object.fromEntries(tokens);
2717
2675
  }
2718
- (0, import_fs4.writeFileSync)(this.indexPath, JSON.stringify(data));
2676
+ (0, import_fs3.writeFileSync)(this.indexPath, JSON.stringify(data));
2719
2677
  }
2720
2678
  addChunk(chunkId, content) {
2721
2679
  const tokens = this.tokenize(content);
@@ -2819,19 +2777,19 @@ var Indexer = class {
2819
2777
  this.projectRoot = projectRoot;
2820
2778
  this.config = config;
2821
2779
  this.indexPath = this.getIndexPath();
2822
- this.fileHashCachePath = path6.join(this.indexPath, "file-hashes.json");
2780
+ this.fileHashCachePath = path5.join(this.indexPath, "file-hashes.json");
2823
2781
  }
2824
2782
  getIndexPath() {
2825
2783
  if (this.config.scope === "global") {
2826
2784
  const homeDir = process.env.HOME || process.env.USERPROFILE || "";
2827
- return path6.join(homeDir, ".opencode", "global-index");
2785
+ return path5.join(homeDir, ".opencode", "global-index");
2828
2786
  }
2829
- return path6.join(this.projectRoot, ".opencode", "index");
2787
+ return path5.join(this.projectRoot, ".opencode", "index");
2830
2788
  }
2831
2789
  loadFileHashCache() {
2832
2790
  try {
2833
- if ((0, import_fs5.existsSync)(this.fileHashCachePath)) {
2834
- const data = (0, import_fs5.readFileSync)(this.fileHashCachePath, "utf-8");
2791
+ if ((0, import_fs4.existsSync)(this.fileHashCachePath)) {
2792
+ const data = (0, import_fs4.readFileSync)(this.fileHashCachePath, "utf-8");
2835
2793
  const parsed = JSON.parse(data);
2836
2794
  this.fileHashCache = new Map(Object.entries(parsed));
2837
2795
  }
@@ -2844,7 +2802,7 @@ var Indexer = class {
2844
2802
  for (const [k, v] of this.fileHashCache) {
2845
2803
  obj[k] = v;
2846
2804
  }
2847
- (0, import_fs5.writeFileSync)(this.fileHashCachePath, JSON.stringify(obj));
2805
+ (0, import_fs4.writeFileSync)(this.fileHashCachePath, JSON.stringify(obj));
2848
2806
  }
2849
2807
  async initialize() {
2850
2808
  this.detectedProvider = await detectEmbeddingProvider(this.config.embeddingProvider);
@@ -2857,12 +2815,12 @@ var Indexer = class {
2857
2815
  this.detectedProvider.credentials,
2858
2816
  this.detectedProvider.modelInfo
2859
2817
  );
2860
- await import_fs5.promises.mkdir(this.indexPath, { recursive: true });
2818
+ await import_fs4.promises.mkdir(this.indexPath, { recursive: true });
2861
2819
  const dimensions = this.detectedProvider.modelInfo.dimensions;
2862
- const storePath = path6.join(this.indexPath, "vectors");
2820
+ const storePath = path5.join(this.indexPath, "vectors");
2863
2821
  this.store = new VectorStore(storePath, dimensions);
2864
- const indexFilePath = path6.join(this.indexPath, "vectors.usearch");
2865
- if ((0, import_fs5.existsSync)(indexFilePath)) {
2822
+ const indexFilePath = path5.join(this.indexPath, "vectors.usearch");
2823
+ if ((0, import_fs4.existsSync)(indexFilePath)) {
2866
2824
  this.store.load();
2867
2825
  }
2868
2826
  this.invertedIndex = new InvertedIndex(this.indexPath);
@@ -2929,7 +2887,7 @@ var Indexer = class {
2929
2887
  if (this.fileHashCache.get(f.path) === currentHash) {
2930
2888
  unchangedFilePaths.add(f.path);
2931
2889
  } else {
2932
- const content = await import_fs5.promises.readFile(f.path, "utf-8");
2890
+ const content = await import_fs4.promises.readFile(f.path, "utf-8");
2933
2891
  changedFiles.push({ path: f.path, content, hash: currentHash });
2934
2892
  }
2935
2893
  }
@@ -2964,7 +2922,7 @@ var Indexer = class {
2964
2922
  for (const parsed of parsedFiles) {
2965
2923
  currentFilePaths.add(parsed.path);
2966
2924
  if (parsed.chunks.length === 0) {
2967
- const relativePath = path6.relative(this.projectRoot, parsed.path);
2925
+ const relativePath = path5.relative(this.projectRoot, parsed.path);
2968
2926
  stats.parseFailures.push(relativePath);
2969
2927
  }
2970
2928
  for (const chunk of parsed.chunks) {
@@ -3133,7 +3091,7 @@ var Indexer = class {
3133
3091
  let contextEndLine = r.metadata.endLine;
3134
3092
  if (this.config.search.includeContext) {
3135
3093
  try {
3136
- const fileContent = await import_fs5.promises.readFile(
3094
+ const fileContent = await import_fs4.promises.readFile(
3137
3095
  r.metadata.filePath,
3138
3096
  "utf-8"
3139
3097
  );
@@ -3236,7 +3194,7 @@ var Indexer = class {
3236
3194
  const removedFilePaths = [];
3237
3195
  let removedCount = 0;
3238
3196
  for (const [filePath, chunkKeys] of filePathsToChunkKeys) {
3239
- if (!(0, import_fs5.existsSync)(filePath)) {
3197
+ if (!(0, import_fs4.existsSync)(filePath)) {
3240
3198
  for (const key of chunkKeys) {
3241
3199
  store.remove(key);
3242
3200
  invertedIndex.removeChunk(key);
@@ -3343,7 +3301,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
3343
3301
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
3344
3302
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
3345
3303
  if (wantBigintFsStats) {
3346
- this._stat = (path9) => statMethod(path9, { bigint: true });
3304
+ this._stat = (path8) => statMethod(path8, { bigint: true });
3347
3305
  } else {
3348
3306
  this._stat = statMethod;
3349
3307
  }
@@ -3368,8 +3326,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
3368
3326
  const par = this.parent;
3369
3327
  const fil = par && par.files;
3370
3328
  if (fil && fil.length > 0) {
3371
- const { path: path9, depth } = par;
3372
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path9));
3329
+ const { path: path8, depth } = par;
3330
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path8));
3373
3331
  const awaited = await Promise.all(slice);
3374
3332
  for (const entry of awaited) {
3375
3333
  if (!entry)
@@ -3409,20 +3367,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
3409
3367
  this.reading = false;
3410
3368
  }
3411
3369
  }
3412
- async _exploreDir(path9, depth) {
3370
+ async _exploreDir(path8, depth) {
3413
3371
  let files;
3414
3372
  try {
3415
- files = await (0, import_promises.readdir)(path9, this._rdOptions);
3373
+ files = await (0, import_promises.readdir)(path8, this._rdOptions);
3416
3374
  } catch (error) {
3417
3375
  this._onError(error);
3418
3376
  }
3419
- return { files, depth, path: path9 };
3377
+ return { files, depth, path: path8 };
3420
3378
  }
3421
- async _formatEntry(dirent, path9) {
3379
+ async _formatEntry(dirent, path8) {
3422
3380
  let entry;
3423
3381
  const basename3 = this._isDirent ? dirent.name : dirent;
3424
3382
  try {
3425
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path9, basename3));
3383
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path8, basename3));
3426
3384
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename3 };
3427
3385
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
3428
3386
  } catch (err) {
@@ -3822,16 +3780,16 @@ var delFromSet = (main, prop, item) => {
3822
3780
  };
3823
3781
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
3824
3782
  var FsWatchInstances = /* @__PURE__ */ new Map();
3825
- function createFsWatchInstance(path9, options, listener, errHandler, emitRaw) {
3783
+ function createFsWatchInstance(path8, options, listener, errHandler, emitRaw) {
3826
3784
  const handleEvent = (rawEvent, evPath) => {
3827
- listener(path9);
3828
- emitRaw(rawEvent, evPath, { watchedPath: path9 });
3829
- if (evPath && path9 !== evPath) {
3830
- fsWatchBroadcast(sp.resolve(path9, evPath), KEY_LISTENERS, sp.join(path9, evPath));
3785
+ listener(path8);
3786
+ emitRaw(rawEvent, evPath, { watchedPath: path8 });
3787
+ if (evPath && path8 !== evPath) {
3788
+ fsWatchBroadcast(sp.resolve(path8, evPath), KEY_LISTENERS, sp.join(path8, evPath));
3831
3789
  }
3832
3790
  };
3833
3791
  try {
3834
- return (0, import_node_fs.watch)(path9, {
3792
+ return (0, import_node_fs.watch)(path8, {
3835
3793
  persistent: options.persistent
3836
3794
  }, handleEvent);
3837
3795
  } catch (error) {
@@ -3847,12 +3805,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
3847
3805
  listener(val1, val2, val3);
3848
3806
  });
3849
3807
  };
3850
- var setFsWatchListener = (path9, fullPath, options, handlers) => {
3808
+ var setFsWatchListener = (path8, fullPath, options, handlers) => {
3851
3809
  const { listener, errHandler, rawEmitter } = handlers;
3852
3810
  let cont = FsWatchInstances.get(fullPath);
3853
3811
  let watcher;
3854
3812
  if (!options.persistent) {
3855
- watcher = createFsWatchInstance(path9, options, listener, errHandler, rawEmitter);
3813
+ watcher = createFsWatchInstance(path8, options, listener, errHandler, rawEmitter);
3856
3814
  if (!watcher)
3857
3815
  return;
3858
3816
  return watcher.close.bind(watcher);
@@ -3863,7 +3821,7 @@ var setFsWatchListener = (path9, fullPath, options, handlers) => {
3863
3821
  addAndConvert(cont, KEY_RAW, rawEmitter);
3864
3822
  } else {
3865
3823
  watcher = createFsWatchInstance(
3866
- path9,
3824
+ path8,
3867
3825
  options,
3868
3826
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
3869
3827
  errHandler,
@@ -3878,7 +3836,7 @@ var setFsWatchListener = (path9, fullPath, options, handlers) => {
3878
3836
  cont.watcherUnusable = true;
3879
3837
  if (isWindows && error.code === "EPERM") {
3880
3838
  try {
3881
- const fd = await (0, import_promises2.open)(path9, "r");
3839
+ const fd = await (0, import_promises2.open)(path8, "r");
3882
3840
  await fd.close();
3883
3841
  broadcastErr(error);
3884
3842
  } catch (err) {
@@ -3909,7 +3867,7 @@ var setFsWatchListener = (path9, fullPath, options, handlers) => {
3909
3867
  };
3910
3868
  };
3911
3869
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
3912
- var setFsWatchFileListener = (path9, fullPath, options, handlers) => {
3870
+ var setFsWatchFileListener = (path8, fullPath, options, handlers) => {
3913
3871
  const { listener, rawEmitter } = handlers;
3914
3872
  let cont = FsWatchFileInstances.get(fullPath);
3915
3873
  const copts = cont && cont.options;
@@ -3931,7 +3889,7 @@ var setFsWatchFileListener = (path9, fullPath, options, handlers) => {
3931
3889
  });
3932
3890
  const currmtime = curr.mtimeMs;
3933
3891
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
3934
- foreach(cont.listeners, (listener2) => listener2(path9, curr));
3892
+ foreach(cont.listeners, (listener2) => listener2(path8, curr));
3935
3893
  }
3936
3894
  })
3937
3895
  };
@@ -3961,13 +3919,13 @@ var NodeFsHandler = class {
3961
3919
  * @param listener on fs change
3962
3920
  * @returns closer for the watcher instance
3963
3921
  */
3964
- _watchWithNodeFs(path9, listener) {
3922
+ _watchWithNodeFs(path8, listener) {
3965
3923
  const opts = this.fsw.options;
3966
- const directory = sp.dirname(path9);
3967
- const basename3 = sp.basename(path9);
3924
+ const directory = sp.dirname(path8);
3925
+ const basename3 = sp.basename(path8);
3968
3926
  const parent = this.fsw._getWatchedDir(directory);
3969
3927
  parent.add(basename3);
3970
- const absolutePath = sp.resolve(path9);
3928
+ const absolutePath = sp.resolve(path8);
3971
3929
  const options = {
3972
3930
  persistent: opts.persistent
3973
3931
  };
@@ -3977,12 +3935,12 @@ var NodeFsHandler = class {
3977
3935
  if (opts.usePolling) {
3978
3936
  const enableBin = opts.interval !== opts.binaryInterval;
3979
3937
  options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
3980
- closer = setFsWatchFileListener(path9, absolutePath, options, {
3938
+ closer = setFsWatchFileListener(path8, absolutePath, options, {
3981
3939
  listener,
3982
3940
  rawEmitter: this.fsw._emitRaw
3983
3941
  });
3984
3942
  } else {
3985
- closer = setFsWatchListener(path9, absolutePath, options, {
3943
+ closer = setFsWatchListener(path8, absolutePath, options, {
3986
3944
  listener,
3987
3945
  errHandler: this._boundHandleError,
3988
3946
  rawEmitter: this.fsw._emitRaw
@@ -4004,7 +3962,7 @@ var NodeFsHandler = class {
4004
3962
  let prevStats = stats;
4005
3963
  if (parent.has(basename3))
4006
3964
  return;
4007
- const listener = async (path9, newStats) => {
3965
+ const listener = async (path8, newStats) => {
4008
3966
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
4009
3967
  return;
4010
3968
  if (!newStats || newStats.mtimeMs === 0) {
@@ -4018,11 +3976,11 @@ var NodeFsHandler = class {
4018
3976
  this.fsw._emit(EV.CHANGE, file, newStats2);
4019
3977
  }
4020
3978
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
4021
- this.fsw._closeFile(path9);
3979
+ this.fsw._closeFile(path8);
4022
3980
  prevStats = newStats2;
4023
3981
  const closer2 = this._watchWithNodeFs(file, listener);
4024
3982
  if (closer2)
4025
- this.fsw._addPathCloser(path9, closer2);
3983
+ this.fsw._addPathCloser(path8, closer2);
4026
3984
  } else {
4027
3985
  prevStats = newStats2;
4028
3986
  }
@@ -4054,7 +4012,7 @@ var NodeFsHandler = class {
4054
4012
  * @param item basename of this item
4055
4013
  * @returns true if no more processing is needed for this entry.
4056
4014
  */
4057
- async _handleSymlink(entry, directory, path9, item) {
4015
+ async _handleSymlink(entry, directory, path8, item) {
4058
4016
  if (this.fsw.closed) {
4059
4017
  return;
4060
4018
  }
@@ -4064,7 +4022,7 @@ var NodeFsHandler = class {
4064
4022
  this.fsw._incrReadyCount();
4065
4023
  let linkPath;
4066
4024
  try {
4067
- linkPath = await (0, import_promises2.realpath)(path9);
4025
+ linkPath = await (0, import_promises2.realpath)(path8);
4068
4026
  } catch (e) {
4069
4027
  this.fsw._emitReady();
4070
4028
  return true;
@@ -4074,12 +4032,12 @@ var NodeFsHandler = class {
4074
4032
  if (dir.has(item)) {
4075
4033
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
4076
4034
  this.fsw._symlinkPaths.set(full, linkPath);
4077
- this.fsw._emit(EV.CHANGE, path9, entry.stats);
4035
+ this.fsw._emit(EV.CHANGE, path8, entry.stats);
4078
4036
  }
4079
4037
  } else {
4080
4038
  dir.add(item);
4081
4039
  this.fsw._symlinkPaths.set(full, linkPath);
4082
- this.fsw._emit(EV.ADD, path9, entry.stats);
4040
+ this.fsw._emit(EV.ADD, path8, entry.stats);
4083
4041
  }
4084
4042
  this.fsw._emitReady();
4085
4043
  return true;
@@ -4109,9 +4067,9 @@ var NodeFsHandler = class {
4109
4067
  return;
4110
4068
  }
4111
4069
  const item = entry.path;
4112
- let path9 = sp.join(directory, item);
4070
+ let path8 = sp.join(directory, item);
4113
4071
  current.add(item);
4114
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path9, item)) {
4072
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path8, item)) {
4115
4073
  return;
4116
4074
  }
4117
4075
  if (this.fsw.closed) {
@@ -4120,8 +4078,8 @@ var NodeFsHandler = class {
4120
4078
  }
4121
4079
  if (item === target || !target && !previous.has(item)) {
4122
4080
  this.fsw._incrReadyCount();
4123
- path9 = sp.join(dir, sp.relative(dir, path9));
4124
- this._addToNodeFs(path9, initialAdd, wh, depth + 1);
4081
+ path8 = sp.join(dir, sp.relative(dir, path8));
4082
+ this._addToNodeFs(path8, initialAdd, wh, depth + 1);
4125
4083
  }
4126
4084
  }).on(EV.ERROR, this._boundHandleError);
4127
4085
  return new Promise((resolve4, reject) => {
@@ -4190,13 +4148,13 @@ var NodeFsHandler = class {
4190
4148
  * @param depth Child path actually targeted for watch
4191
4149
  * @param target Child path actually targeted for watch
4192
4150
  */
4193
- async _addToNodeFs(path9, initialAdd, priorWh, depth, target) {
4151
+ async _addToNodeFs(path8, initialAdd, priorWh, depth, target) {
4194
4152
  const ready = this.fsw._emitReady;
4195
- if (this.fsw._isIgnored(path9) || this.fsw.closed) {
4153
+ if (this.fsw._isIgnored(path8) || this.fsw.closed) {
4196
4154
  ready();
4197
4155
  return false;
4198
4156
  }
4199
- const wh = this.fsw._getWatchHelpers(path9);
4157
+ const wh = this.fsw._getWatchHelpers(path8);
4200
4158
  if (priorWh) {
4201
4159
  wh.filterPath = (entry) => priorWh.filterPath(entry);
4202
4160
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -4212,8 +4170,8 @@ var NodeFsHandler = class {
4212
4170
  const follow = this.fsw.options.followSymlinks;
4213
4171
  let closer;
4214
4172
  if (stats.isDirectory()) {
4215
- const absPath = sp.resolve(path9);
4216
- const targetPath = follow ? await (0, import_promises2.realpath)(path9) : path9;
4173
+ const absPath = sp.resolve(path8);
4174
+ const targetPath = follow ? await (0, import_promises2.realpath)(path8) : path8;
4217
4175
  if (this.fsw.closed)
4218
4176
  return;
4219
4177
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -4223,29 +4181,29 @@ var NodeFsHandler = class {
4223
4181
  this.fsw._symlinkPaths.set(absPath, targetPath);
4224
4182
  }
4225
4183
  } else if (stats.isSymbolicLink()) {
4226
- const targetPath = follow ? await (0, import_promises2.realpath)(path9) : path9;
4184
+ const targetPath = follow ? await (0, import_promises2.realpath)(path8) : path8;
4227
4185
  if (this.fsw.closed)
4228
4186
  return;
4229
4187
  const parent = sp.dirname(wh.watchPath);
4230
4188
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
4231
4189
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
4232
- closer = await this._handleDir(parent, stats, initialAdd, depth, path9, wh, targetPath);
4190
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path8, wh, targetPath);
4233
4191
  if (this.fsw.closed)
4234
4192
  return;
4235
4193
  if (targetPath !== void 0) {
4236
- this.fsw._symlinkPaths.set(sp.resolve(path9), targetPath);
4194
+ this.fsw._symlinkPaths.set(sp.resolve(path8), targetPath);
4237
4195
  }
4238
4196
  } else {
4239
4197
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
4240
4198
  }
4241
4199
  ready();
4242
4200
  if (closer)
4243
- this.fsw._addPathCloser(path9, closer);
4201
+ this.fsw._addPathCloser(path8, closer);
4244
4202
  return false;
4245
4203
  } catch (error) {
4246
4204
  if (this.fsw._handleError(error)) {
4247
4205
  ready();
4248
- return path9;
4206
+ return path8;
4249
4207
  }
4250
4208
  }
4251
4209
  }
@@ -4288,24 +4246,24 @@ function createPattern(matcher) {
4288
4246
  }
4289
4247
  return () => false;
4290
4248
  }
4291
- function normalizePath(path9) {
4292
- if (typeof path9 !== "string")
4249
+ function normalizePath(path8) {
4250
+ if (typeof path8 !== "string")
4293
4251
  throw new Error("string expected");
4294
- path9 = sp2.normalize(path9);
4295
- path9 = path9.replace(/\\/g, "/");
4252
+ path8 = sp2.normalize(path8);
4253
+ path8 = path8.replace(/\\/g, "/");
4296
4254
  let prepend = false;
4297
- if (path9.startsWith("//"))
4255
+ if (path8.startsWith("//"))
4298
4256
  prepend = true;
4299
- path9 = path9.replace(DOUBLE_SLASH_RE, "/");
4257
+ path8 = path8.replace(DOUBLE_SLASH_RE, "/");
4300
4258
  if (prepend)
4301
- path9 = "/" + path9;
4302
- return path9;
4259
+ path8 = "/" + path8;
4260
+ return path8;
4303
4261
  }
4304
4262
  function matchPatterns(patterns, testString, stats) {
4305
- const path9 = normalizePath(testString);
4263
+ const path8 = normalizePath(testString);
4306
4264
  for (let index = 0; index < patterns.length; index++) {
4307
4265
  const pattern = patterns[index];
4308
- if (pattern(path9, stats)) {
4266
+ if (pattern(path8, stats)) {
4309
4267
  return true;
4310
4268
  }
4311
4269
  }
@@ -4343,19 +4301,19 @@ var toUnix = (string) => {
4343
4301
  }
4344
4302
  return str;
4345
4303
  };
4346
- var normalizePathToUnix = (path9) => toUnix(sp2.normalize(toUnix(path9)));
4347
- var normalizeIgnored = (cwd = "") => (path9) => {
4348
- if (typeof path9 === "string") {
4349
- return normalizePathToUnix(sp2.isAbsolute(path9) ? path9 : sp2.join(cwd, path9));
4304
+ var normalizePathToUnix = (path8) => toUnix(sp2.normalize(toUnix(path8)));
4305
+ var normalizeIgnored = (cwd = "") => (path8) => {
4306
+ if (typeof path8 === "string") {
4307
+ return normalizePathToUnix(sp2.isAbsolute(path8) ? path8 : sp2.join(cwd, path8));
4350
4308
  } else {
4351
- return path9;
4309
+ return path8;
4352
4310
  }
4353
4311
  };
4354
- var getAbsolutePath = (path9, cwd) => {
4355
- if (sp2.isAbsolute(path9)) {
4356
- return path9;
4312
+ var getAbsolutePath = (path8, cwd) => {
4313
+ if (sp2.isAbsolute(path8)) {
4314
+ return path8;
4357
4315
  }
4358
- return sp2.join(cwd, path9);
4316
+ return sp2.join(cwd, path8);
4359
4317
  };
4360
4318
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
4361
4319
  var DirEntry = class {
@@ -4420,10 +4378,10 @@ var WatchHelper = class {
4420
4378
  dirParts;
4421
4379
  followSymlinks;
4422
4380
  statMethod;
4423
- constructor(path9, follow, fsw) {
4381
+ constructor(path8, follow, fsw) {
4424
4382
  this.fsw = fsw;
4425
- const watchPath = path9;
4426
- this.path = path9 = path9.replace(REPLACER_RE, "");
4383
+ const watchPath = path8;
4384
+ this.path = path8 = path8.replace(REPLACER_RE, "");
4427
4385
  this.watchPath = watchPath;
4428
4386
  this.fullWatchPath = sp2.resolve(watchPath);
4429
4387
  this.dirParts = [];
@@ -4563,20 +4521,20 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4563
4521
  this._closePromise = void 0;
4564
4522
  let paths = unifyPaths(paths_);
4565
4523
  if (cwd) {
4566
- paths = paths.map((path9) => {
4567
- const absPath = getAbsolutePath(path9, cwd);
4524
+ paths = paths.map((path8) => {
4525
+ const absPath = getAbsolutePath(path8, cwd);
4568
4526
  return absPath;
4569
4527
  });
4570
4528
  }
4571
- paths.forEach((path9) => {
4572
- this._removeIgnoredPath(path9);
4529
+ paths.forEach((path8) => {
4530
+ this._removeIgnoredPath(path8);
4573
4531
  });
4574
4532
  this._userIgnored = void 0;
4575
4533
  if (!this._readyCount)
4576
4534
  this._readyCount = 0;
4577
4535
  this._readyCount += paths.length;
4578
- Promise.all(paths.map(async (path9) => {
4579
- const res = await this._nodeFsHandler._addToNodeFs(path9, !_internal, void 0, 0, _origAdd);
4536
+ Promise.all(paths.map(async (path8) => {
4537
+ const res = await this._nodeFsHandler._addToNodeFs(path8, !_internal, void 0, 0, _origAdd);
4580
4538
  if (res)
4581
4539
  this._emitReady();
4582
4540
  return res;
@@ -4598,17 +4556,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4598
4556
  return this;
4599
4557
  const paths = unifyPaths(paths_);
4600
4558
  const { cwd } = this.options;
4601
- paths.forEach((path9) => {
4602
- if (!sp2.isAbsolute(path9) && !this._closers.has(path9)) {
4559
+ paths.forEach((path8) => {
4560
+ if (!sp2.isAbsolute(path8) && !this._closers.has(path8)) {
4603
4561
  if (cwd)
4604
- path9 = sp2.join(cwd, path9);
4605
- path9 = sp2.resolve(path9);
4562
+ path8 = sp2.join(cwd, path8);
4563
+ path8 = sp2.resolve(path8);
4606
4564
  }
4607
- this._closePath(path9);
4608
- this._addIgnoredPath(path9);
4609
- if (this._watched.has(path9)) {
4565
+ this._closePath(path8);
4566
+ this._addIgnoredPath(path8);
4567
+ if (this._watched.has(path8)) {
4610
4568
  this._addIgnoredPath({
4611
- path: path9,
4569
+ path: path8,
4612
4570
  recursive: true
4613
4571
  });
4614
4572
  }
@@ -4672,38 +4630,38 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4672
4630
  * @param stats arguments to be passed with event
4673
4631
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
4674
4632
  */
4675
- async _emit(event, path9, stats) {
4633
+ async _emit(event, path8, stats) {
4676
4634
  if (this.closed)
4677
4635
  return;
4678
4636
  const opts = this.options;
4679
4637
  if (isWindows)
4680
- path9 = sp2.normalize(path9);
4638
+ path8 = sp2.normalize(path8);
4681
4639
  if (opts.cwd)
4682
- path9 = sp2.relative(opts.cwd, path9);
4683
- const args = [path9];
4640
+ path8 = sp2.relative(opts.cwd, path8);
4641
+ const args = [path8];
4684
4642
  if (stats != null)
4685
4643
  args.push(stats);
4686
4644
  const awf = opts.awaitWriteFinish;
4687
4645
  let pw;
4688
- if (awf && (pw = this._pendingWrites.get(path9))) {
4646
+ if (awf && (pw = this._pendingWrites.get(path8))) {
4689
4647
  pw.lastChange = /* @__PURE__ */ new Date();
4690
4648
  return this;
4691
4649
  }
4692
4650
  if (opts.atomic) {
4693
4651
  if (event === EVENTS.UNLINK) {
4694
- this._pendingUnlinks.set(path9, [event, ...args]);
4652
+ this._pendingUnlinks.set(path8, [event, ...args]);
4695
4653
  setTimeout(() => {
4696
- this._pendingUnlinks.forEach((entry, path10) => {
4654
+ this._pendingUnlinks.forEach((entry, path9) => {
4697
4655
  this.emit(...entry);
4698
4656
  this.emit(EVENTS.ALL, ...entry);
4699
- this._pendingUnlinks.delete(path10);
4657
+ this._pendingUnlinks.delete(path9);
4700
4658
  });
4701
4659
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
4702
4660
  return this;
4703
4661
  }
4704
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path9)) {
4662
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path8)) {
4705
4663
  event = EVENTS.CHANGE;
4706
- this._pendingUnlinks.delete(path9);
4664
+ this._pendingUnlinks.delete(path8);
4707
4665
  }
4708
4666
  }
4709
4667
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -4721,16 +4679,16 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4721
4679
  this.emitWithAll(event, args);
4722
4680
  }
4723
4681
  };
4724
- this._awaitWriteFinish(path9, awf.stabilityThreshold, event, awfEmit);
4682
+ this._awaitWriteFinish(path8, awf.stabilityThreshold, event, awfEmit);
4725
4683
  return this;
4726
4684
  }
4727
4685
  if (event === EVENTS.CHANGE) {
4728
- const isThrottled = !this._throttle(EVENTS.CHANGE, path9, 50);
4686
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path8, 50);
4729
4687
  if (isThrottled)
4730
4688
  return this;
4731
4689
  }
4732
4690
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
4733
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path9) : path9;
4691
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path8) : path8;
4734
4692
  let stats2;
4735
4693
  try {
4736
4694
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -4761,23 +4719,23 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4761
4719
  * @param timeout duration of time to suppress duplicate actions
4762
4720
  * @returns tracking object or false if action should be suppressed
4763
4721
  */
4764
- _throttle(actionType, path9, timeout) {
4722
+ _throttle(actionType, path8, timeout) {
4765
4723
  if (!this._throttled.has(actionType)) {
4766
4724
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
4767
4725
  }
4768
4726
  const action = this._throttled.get(actionType);
4769
4727
  if (!action)
4770
4728
  throw new Error("invalid throttle");
4771
- const actionPath = action.get(path9);
4729
+ const actionPath = action.get(path8);
4772
4730
  if (actionPath) {
4773
4731
  actionPath.count++;
4774
4732
  return false;
4775
4733
  }
4776
4734
  let timeoutObject;
4777
4735
  const clear = () => {
4778
- const item = action.get(path9);
4736
+ const item = action.get(path8);
4779
4737
  const count = item ? item.count : 0;
4780
- action.delete(path9);
4738
+ action.delete(path8);
4781
4739
  clearTimeout(timeoutObject);
4782
4740
  if (item)
4783
4741
  clearTimeout(item.timeoutObject);
@@ -4785,7 +4743,7 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4785
4743
  };
4786
4744
  timeoutObject = setTimeout(clear, timeout);
4787
4745
  const thr = { timeoutObject, clear, count: 0 };
4788
- action.set(path9, thr);
4746
+ action.set(path8, thr);
4789
4747
  return thr;
4790
4748
  }
4791
4749
  _incrReadyCount() {
@@ -4799,44 +4757,44 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4799
4757
  * @param event
4800
4758
  * @param awfEmit Callback to be called when ready for event to be emitted.
4801
4759
  */
4802
- _awaitWriteFinish(path9, threshold, event, awfEmit) {
4760
+ _awaitWriteFinish(path8, threshold, event, awfEmit) {
4803
4761
  const awf = this.options.awaitWriteFinish;
4804
4762
  if (typeof awf !== "object")
4805
4763
  return;
4806
4764
  const pollInterval = awf.pollInterval;
4807
4765
  let timeoutHandler;
4808
- let fullPath = path9;
4809
- if (this.options.cwd && !sp2.isAbsolute(path9)) {
4810
- fullPath = sp2.join(this.options.cwd, path9);
4766
+ let fullPath = path8;
4767
+ if (this.options.cwd && !sp2.isAbsolute(path8)) {
4768
+ fullPath = sp2.join(this.options.cwd, path8);
4811
4769
  }
4812
4770
  const now = /* @__PURE__ */ new Date();
4813
4771
  const writes = this._pendingWrites;
4814
4772
  function awaitWriteFinishFn(prevStat) {
4815
4773
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
4816
- if (err || !writes.has(path9)) {
4774
+ if (err || !writes.has(path8)) {
4817
4775
  if (err && err.code !== "ENOENT")
4818
4776
  awfEmit(err);
4819
4777
  return;
4820
4778
  }
4821
4779
  const now2 = Number(/* @__PURE__ */ new Date());
4822
4780
  if (prevStat && curStat.size !== prevStat.size) {
4823
- writes.get(path9).lastChange = now2;
4781
+ writes.get(path8).lastChange = now2;
4824
4782
  }
4825
- const pw = writes.get(path9);
4783
+ const pw = writes.get(path8);
4826
4784
  const df = now2 - pw.lastChange;
4827
4785
  if (df >= threshold) {
4828
- writes.delete(path9);
4786
+ writes.delete(path8);
4829
4787
  awfEmit(void 0, curStat);
4830
4788
  } else {
4831
4789
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
4832
4790
  }
4833
4791
  });
4834
4792
  }
4835
- if (!writes.has(path9)) {
4836
- writes.set(path9, {
4793
+ if (!writes.has(path8)) {
4794
+ writes.set(path8, {
4837
4795
  lastChange: now,
4838
4796
  cancelWait: () => {
4839
- writes.delete(path9);
4797
+ writes.delete(path8);
4840
4798
  clearTimeout(timeoutHandler);
4841
4799
  return event;
4842
4800
  }
@@ -4847,8 +4805,8 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4847
4805
  /**
4848
4806
  * Determines whether user has asked to ignore this path.
4849
4807
  */
4850
- _isIgnored(path9, stats) {
4851
- if (this.options.atomic && DOT_RE.test(path9))
4808
+ _isIgnored(path8, stats) {
4809
+ if (this.options.atomic && DOT_RE.test(path8))
4852
4810
  return true;
4853
4811
  if (!this._userIgnored) {
4854
4812
  const { cwd } = this.options;
@@ -4858,17 +4816,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4858
4816
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
4859
4817
  this._userIgnored = anymatch(list, void 0);
4860
4818
  }
4861
- return this._userIgnored(path9, stats);
4819
+ return this._userIgnored(path8, stats);
4862
4820
  }
4863
- _isntIgnored(path9, stat4) {
4864
- return !this._isIgnored(path9, stat4);
4821
+ _isntIgnored(path8, stat4) {
4822
+ return !this._isIgnored(path8, stat4);
4865
4823
  }
4866
4824
  /**
4867
4825
  * Provides a set of common helpers and properties relating to symlink handling.
4868
4826
  * @param path file or directory pattern being watched
4869
4827
  */
4870
- _getWatchHelpers(path9) {
4871
- return new WatchHelper(path9, this.options.followSymlinks, this);
4828
+ _getWatchHelpers(path8) {
4829
+ return new WatchHelper(path8, this.options.followSymlinks, this);
4872
4830
  }
4873
4831
  // Directory helpers
4874
4832
  // -----------------
@@ -4900,63 +4858,63 @@ var FSWatcher = class extends import_node_events.EventEmitter {
4900
4858
  * @param item base path of item/directory
4901
4859
  */
4902
4860
  _remove(directory, item, isDirectory) {
4903
- const path9 = sp2.join(directory, item);
4904
- const fullPath = sp2.resolve(path9);
4905
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path9) || this._watched.has(fullPath);
4906
- if (!this._throttle("remove", path9, 100))
4861
+ const path8 = sp2.join(directory, item);
4862
+ const fullPath = sp2.resolve(path8);
4863
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path8) || this._watched.has(fullPath);
4864
+ if (!this._throttle("remove", path8, 100))
4907
4865
  return;
4908
4866
  if (!isDirectory && this._watched.size === 1) {
4909
4867
  this.add(directory, item, true);
4910
4868
  }
4911
- const wp = this._getWatchedDir(path9);
4869
+ const wp = this._getWatchedDir(path8);
4912
4870
  const nestedDirectoryChildren = wp.getChildren();
4913
- nestedDirectoryChildren.forEach((nested) => this._remove(path9, nested));
4871
+ nestedDirectoryChildren.forEach((nested) => this._remove(path8, nested));
4914
4872
  const parent = this._getWatchedDir(directory);
4915
4873
  const wasTracked = parent.has(item);
4916
4874
  parent.remove(item);
4917
4875
  if (this._symlinkPaths.has(fullPath)) {
4918
4876
  this._symlinkPaths.delete(fullPath);
4919
4877
  }
4920
- let relPath = path9;
4878
+ let relPath = path8;
4921
4879
  if (this.options.cwd)
4922
- relPath = sp2.relative(this.options.cwd, path9);
4880
+ relPath = sp2.relative(this.options.cwd, path8);
4923
4881
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
4924
4882
  const event = this._pendingWrites.get(relPath).cancelWait();
4925
4883
  if (event === EVENTS.ADD)
4926
4884
  return;
4927
4885
  }
4928
- this._watched.delete(path9);
4886
+ this._watched.delete(path8);
4929
4887
  this._watched.delete(fullPath);
4930
4888
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
4931
- if (wasTracked && !this._isIgnored(path9))
4932
- this._emit(eventName, path9);
4933
- this._closePath(path9);
4889
+ if (wasTracked && !this._isIgnored(path8))
4890
+ this._emit(eventName, path8);
4891
+ this._closePath(path8);
4934
4892
  }
4935
4893
  /**
4936
4894
  * Closes all watchers for a path
4937
4895
  */
4938
- _closePath(path9) {
4939
- this._closeFile(path9);
4940
- const dir = sp2.dirname(path9);
4941
- this._getWatchedDir(dir).remove(sp2.basename(path9));
4896
+ _closePath(path8) {
4897
+ this._closeFile(path8);
4898
+ const dir = sp2.dirname(path8);
4899
+ this._getWatchedDir(dir).remove(sp2.basename(path8));
4942
4900
  }
4943
4901
  /**
4944
4902
  * Closes only file-specific watchers
4945
4903
  */
4946
- _closeFile(path9) {
4947
- const closers = this._closers.get(path9);
4904
+ _closeFile(path8) {
4905
+ const closers = this._closers.get(path8);
4948
4906
  if (!closers)
4949
4907
  return;
4950
4908
  closers.forEach((closer) => closer());
4951
- this._closers.delete(path9);
4909
+ this._closers.delete(path8);
4952
4910
  }
4953
- _addPathCloser(path9, closer) {
4911
+ _addPathCloser(path8, closer) {
4954
4912
  if (!closer)
4955
4913
  return;
4956
- let list = this._closers.get(path9);
4914
+ let list = this._closers.get(path8);
4957
4915
  if (!list) {
4958
4916
  list = [];
4959
- this._closers.set(path9, list);
4917
+ this._closers.set(path8, list);
4960
4918
  }
4961
4919
  list.push(closer);
4962
4920
  }
@@ -4986,7 +4944,7 @@ function watch(paths, options = {}) {
4986
4944
  var chokidar_default = { watch, FSWatcher };
4987
4945
 
4988
4946
  // src/watcher/index.ts
4989
- var path7 = __toESM(require("path"), 1);
4947
+ var path6 = __toESM(require("path"), 1);
4990
4948
  var FileWatcher = class {
4991
4949
  watcher = null;
4992
4950
  projectRoot;
@@ -5007,7 +4965,7 @@ var FileWatcher = class {
5007
4965
  const ignoreFilter = createIgnoreFilter(this.projectRoot);
5008
4966
  this.watcher = chokidar_default.watch(this.projectRoot, {
5009
4967
  ignored: (filePath) => {
5010
- const relativePath = path7.relative(this.projectRoot, filePath);
4968
+ const relativePath = path6.relative(this.projectRoot, filePath);
5011
4969
  if (!relativePath) return false;
5012
4970
  if (ignoreFilter.ignores(relativePath)) {
5013
4971
  return true;
@@ -5051,7 +5009,7 @@ var FileWatcher = class {
5051
5009
  return;
5052
5010
  }
5053
5011
  const changes = Array.from(this.pendingChanges.entries()).map(
5054
- ([path9, type]) => ({ path: path9, type })
5012
+ ([path8, type]) => ({ path: path8, type })
5055
5013
  );
5056
5014
  this.pendingChanges.clear();
5057
5015
  try {
@@ -5243,10 +5201,10 @@ function formatStatus(status) {
5243
5201
 
5244
5202
  // src/index.ts
5245
5203
  function loadPluginConfig(projectRoot) {
5246
- const configPath = path8.join(projectRoot, ".opencode", "codebase-index.json");
5204
+ const configPath = path7.join(projectRoot, ".opencode", "codebase-index.json");
5247
5205
  try {
5248
- if ((0, import_fs6.existsSync)(configPath)) {
5249
- const content = (0, import_fs6.readFileSync)(configPath, "utf-8");
5206
+ if ((0, import_fs5.existsSync)(configPath)) {
5207
+ const content = (0, import_fs5.readFileSync)(configPath, "utf-8");
5250
5208
  return JSON.parse(content);
5251
5209
  }
5252
5210
  } catch {