opencode-codebase-index 0.2.2 → 0.2.3

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.js CHANGED
@@ -654,6 +654,7 @@ var require_ignore = __commonJS({
654
654
  // src/index.ts
655
655
  import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
656
656
  import * as path7 from "path";
657
+ import * as os3 from "os";
657
658
 
658
659
  // src/config/schema.ts
659
660
  var DEFAULT_INCLUDE = [
@@ -5576,15 +5577,26 @@ function formatStatus(status) {
5576
5577
  }
5577
5578
 
5578
5579
  // src/index.ts
5579
- function loadPluginConfig(projectRoot) {
5580
- const configPath = path7.join(projectRoot, ".opencode", "codebase-index.json");
5580
+ function loadJsonFile(filePath) {
5581
5581
  try {
5582
- if (existsSync5(configPath)) {
5583
- const content = readFileSync5(configPath, "utf-8");
5582
+ if (existsSync5(filePath)) {
5583
+ const content = readFileSync5(filePath, "utf-8");
5584
5584
  return JSON.parse(content);
5585
5585
  }
5586
5586
  } catch {
5587
5587
  }
5588
+ return null;
5589
+ }
5590
+ function loadPluginConfig(projectRoot) {
5591
+ const projectConfig = loadJsonFile(path7.join(projectRoot, ".opencode", "codebase-index.json"));
5592
+ if (projectConfig) {
5593
+ return projectConfig;
5594
+ }
5595
+ const globalConfigPath = path7.join(os3.homedir(), ".config", "opencode", "codebase-index.json");
5596
+ const globalConfig = loadJsonFile(globalConfigPath);
5597
+ if (globalConfig) {
5598
+ return globalConfig;
5599
+ }
5588
5600
  return {};
5589
5601
  }
5590
5602
  var plugin = async ({ directory }) => {