@khivi/opencode-codebase-index 0.5.2 → 0.5.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/git-cli.js CHANGED
@@ -657,13 +657,30 @@ var require_ignore = __commonJS({
657
657
  import { execSync } from "child_process";
658
658
  import { existsSync, readFileSync, mkdirSync, writeFileSync } from "fs";
659
659
  import * as path from "path";
660
- var EXTENSIONS = [".py", ".ts", ".js", ".go", ".rs", ".java", ".cs", ".rb"];
660
+ function extractExtensions(includePatterns) {
661
+ const exts = /* @__PURE__ */ new Set();
662
+ for (const pattern of includePatterns) {
663
+ const braceMatch = pattern.match(/\*\.?\{([^}]+)\}/);
664
+ if (braceMatch) {
665
+ for (const ext of braceMatch[1].split(",")) {
666
+ exts.add(`.${ext.trim()}`);
667
+ }
668
+ continue;
669
+ }
670
+ const singleMatch = pattern.match(/\*\.(\w+)$/);
671
+ if (singleMatch) {
672
+ exts.add(`.${singleMatch[1]}`);
673
+ }
674
+ }
675
+ return exts;
676
+ }
661
677
  function repoRoot() {
662
678
  return execSync("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
663
679
  }
664
- function activeFiles(root) {
680
+ function activeFiles(root, includePatterns) {
665
681
  const output = execSync("git ls-files", { cwd: root, encoding: "utf-8" });
666
- return output.split("\n").filter((f) => f.length > 0 && EXTENSIONS.includes(path.extname(f)));
682
+ const exts = extractExtensions(includePatterns);
683
+ return output.split("\n").filter((f) => f.length > 0 && exts.has(path.extname(f)));
667
684
  }
668
685
  function blobSha(filepath, root) {
669
686
  return execSync(`git hash-object ${JSON.stringify(filepath)}`, {
@@ -5839,7 +5856,9 @@ function loadPluginConfig(projectRoot) {
5839
5856
  // src/commands/incremental.ts
5840
5857
  async function runIncremental() {
5841
5858
  const root = repoRoot();
5842
- const files = activeFiles(root);
5859
+ const rawConfig = loadPluginConfig(root);
5860
+ const config = parseConfig(rawConfig);
5861
+ const files = activeFiles(root, config.include);
5843
5862
  const stored = loadHashes(root);
5844
5863
  const current = {};
5845
5864
  const changed = [];
@@ -5856,8 +5875,6 @@ async function runIncremental() {
5856
5875
  console.log(`${files.length} files checked, 0 reindexed, 0 deleted`);
5857
5876
  return;
5858
5877
  }
5859
- const rawConfig = loadPluginConfig(root);
5860
- const config = parseConfig(rawConfig);
5861
5878
  const indexer = new Indexer(root, config);
5862
5879
  await indexer.initialize();
5863
5880
  const stats = await indexer.index((progress) => {
@@ -5888,7 +5905,7 @@ async function runQuery(queryText, limit) {
5888
5905
  const indexer = new Indexer(root, config);
5889
5906
  await indexer.initialize();
5890
5907
  const results = await indexer.search(queryText, limit * 2);
5891
- const active = new Set(activeFiles(root));
5908
+ const active = new Set(activeFiles(root, config.include));
5892
5909
  const filtered = results.filter((r) => {
5893
5910
  const rel = path9.relative(root, r.filePath);
5894
5911
  return active.has(rel);