opencode-codebase-index 0.8.1 → 0.10.0

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/README.md CHANGED
@@ -211,7 +211,9 @@ graph TD
211
211
 
212
212
  1. **Parsing**: We use `tree-sitter` to intelligently parse your code into meaningful blocks (functions, classes, interfaces). JSDoc comments and docstrings are automatically included with their associated code.
213
213
 
214
- **Supported Languages (Tree-sitter semantic parsing)**: TypeScript, JavaScript, Python, Rust, Go, Java, C#, Ruby, PHP, Apex, Bash, C, C++, JSON, TOML, YAML, Zig
214
+ **Supported Languages (Tree-sitter semantic parsing)**: TypeScript, JavaScript, Python, Rust, Go, Java, C#, Ruby, PHP, Apex, Bash, C, C++, JSON, TOML, YAML, Zig, GDScript, MATLAB†
215
+
216
+ † MATLAB (`.m`) is opt-in — see below.
215
217
 
216
218
  **Additional Supported Formats (line-based chunking)**: TXT, HTML, HTM, Markdown, Shell scripts
217
219
 
@@ -223,11 +225,16 @@ graph TD
223
225
  **/*.{sql,graphql,proto} **/*.{yaml,yml,toml}
224
226
  **/*.{md,mdx} **/*.{sh,bash,zsh}
225
227
  **/*.{txt,html,htm} **/*.{cls,trigger}
226
- **/*.zig
228
+ **/*.zig **/*.gd
227
229
  ```
228
230
 
229
231
  Use `include` to replace defaults, or `additionalInclude` to extend (e.g. `"**/*.pdf"`, `"**/*.csv"`).
230
232
 
233
+ †**MATLAB opt-in**: `.m` is excluded from defaults because it conflicts with the Objective-C extension used on Apple codebases. To enable MATLAB discovery, add to your global config (`~/.config/opencode/codebase-index.json`):
234
+ ```json
235
+ { "additionalInclude": ["**/*.m"] }
236
+ ```
237
+
231
238
  **Max File Size**: Default 1MB (1048576 bytes). Configure via `indexing.maxFileSize` (bytes).
232
239
  2. **Chunking**: Large blocks are split with overlapping windows to preserve context across chunk boundaries.
233
240
  3. **Embedding**: These blocks are converted into vector representations using your configured AI provider.
@@ -353,7 +360,7 @@ Returns recent debug logs with optional filtering.
353
360
 
354
361
  ### `call_graph`
355
362
 
356
- Query the call graph to find callers or callees of a function/method. Automatically built during indexing for TypeScript, JavaScript, Python, Go, Rust, PHP, and Zig.
363
+ Query the call graph to find callers or callees of a function/method. Automatically built during indexing for TypeScript, JavaScript, Python, Go, Rust, PHP, Apex, Zig, GDScript, and MATLAB.
357
364
 
358
365
  - **Use for**: Understanding code flow, tracing dependencies, impact analysis.
359
366
  - **Parameters**: `name` (function name), `direction` (`callers` or `callees`), `symbolId` (required for `callees`, returned by previous queries).
@@ -363,6 +370,7 @@ Query the call graph to find callers or callees of a function/method. Automatica
363
370
  Add a folder as a knowledge base to be indexed alongside project code.
364
371
  - **Use for**: Indexing external documentation, API references, example programs.
365
372
  - **Parameters**: `path` (folder path, absolute or relative), `reindex` (optional, default `true`).
373
+ - **Restrictions**: System directories (`/etc`, `/proc`, `/sys`, `/dev`) and sensitive home directories (`.ssh`, `.gnupg`, `.aws`, `.docker`, `.kube`) are blocked. Symlinks are resolved before validation.
366
374
  - **Example**: `add_knowledge_base(path="/path/to/docs")`
367
375
 
368
376
  ### `list_knowledge_bases`
@@ -432,10 +440,10 @@ Global-level config (`~/.config/opencode/codebase-index.json`):
432
440
  {
433
441
  "embeddingProvider": "custom",
434
442
  "customProvider": {
435
- "baseUrl": "https://api.siliconflow.cn/v1",
443
+ "baseUrl": "{env:EMBED_BASE_URL}",
436
444
  "model": "BAAI/bge-m3",
437
445
  "dimensions": 1024,
438
- "apiKey": "{env:SILICONFLOW_API_KEY}"
446
+ "apiKey": "{env:EMBED_API_KEY}"
439
447
  }
440
448
  }
441
449
  ```
@@ -459,9 +467,9 @@ Add to your config (`.opencode/codebase-index.json` or global config):
459
467
  {
460
468
  "reranker": {
461
469
  "enabled": true,
462
- "baseUrl": "https://api.siliconflow.cn/v1",
463
- "model": "BAAI/bge-reranker-v2-m3",
464
- "apiKey": "{env:SILICONFLOW_API_KEY}",
470
+ "baseUrl": "https://api.cohere.ai/v1",
471
+ "model": "rerank-v3.5",
472
+ "apiKey": "{env:RERANK_API_KEY}",
465
473
  "topN": 20
466
474
  }
467
475
  }
@@ -511,10 +519,10 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
511
519
 
512
520
  // === Custom Embedding API (when embeddingProvider is "custom") ===
513
521
  "customProvider": {
514
- "baseUrl": "https://api.siliconflow.cn/v1",
522
+ "baseUrl": "{env:EMBED_BASE_URL}",
515
523
  "model": "BAAI/bge-m3",
516
524
  "dimensions": 1024,
517
- "apiKey": "{env:SILICONFLOW_API_KEY}",
525
+ "apiKey": "{env:EMBED_API_KEY}",
518
526
  "maxTokens": 8192, // Max tokens per input text
519
527
  "timeoutMs": 30000, // Request timeout (ms)
520
528
  "concurrency": 3, // Max concurrent requests
@@ -567,7 +575,8 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
567
575
  "rrfK": 60, // RRF smoothing constant
568
576
  "rerankTopN": 20, // Deterministic rerank depth
569
577
  "contextLines": 0, // Extra lines before/after match
570
- "routingHints": true // Runtime nudges for local discovery/definition queries
578
+ "routingHints": true, // Runtime nudges for local discovery/definition queries
579
+ "routingHintRole": "system" // system | developer (message role used for hints)
571
580
  },
572
581
  "reranker": {
573
582
  "enabled": false,
@@ -638,6 +647,7 @@ String values in `codebase-index.json` can reference environment variables with
638
647
  | `rerankTopN` | `20` | Deterministic rerank depth cap. Applies lightweight name/path/chunk-type rerank to top-N only |
639
648
  | `contextLines` | `0` | Extra lines to include before/after each match |
640
649
  | `routingHints` | `true` | Inject lightweight runtime hints for local conceptual discovery and definition lookups. Set to `false` to disable plugin-side routing nudges. |
650
+ | `routingHintRole` | `"system"` | Message role used when injecting routing hints: `"system"` (default) or `"developer"`. |
641
651
  | **reranker** | | Optional second-stage model reranker for the top candidate pool |
642
652
  | `enabled` | `false` | Turn external reranking on/off |
643
653
  | `provider` | `"custom"` | Hosted shortcuts: `cohere`, `jina`, or `custom` |
@@ -656,10 +666,19 @@ String values in `codebase-index.json` can reference environment variables with
656
666
  | `logBranch` | `true` | Log branch detection and switches |
657
667
  | `metrics` | `false` | Enable metrics collection (indexing stats, search timing, cache performance) |
658
668
 
669
+ ### Recovery warnings in debug logs
670
+
671
+ When debug logging is enabled, the indexer now emits warn-level recovery messages if persisted cache state cannot be read safely.
672
+
673
+ - Corrupted or unreadable `file-hashes.json` causes the in-memory file hash cache to be reset.
674
+ - Corrupted or unreadable `failed-batches.json` causes persisted retry batches to be skipped for that run.
675
+
676
+ These warnings improve observability but do **not** change the recovery behavior: the indexer still falls back to a safe reset/skip path instead of crashing. If these warnings recur, remove the affected file under `.opencode/index/` (or the global index directory) and rebuild with `/index force`.
677
+
659
678
  ### Retrieval ranking behavior
660
679
 
661
680
  - `codebase_search` and `codebase_peek` use the hybrid path: semantic + keyword retrieval → fusion (`fusionStrategy`) → deterministic rerank (`rerankTopN`) → optional external reranker (`reranker`) → filtering.
662
- - When `search.routingHints` is enabled (default), the plugin adds tiny per-turn runtime hints for local conceptual discovery and definition queries. Conceptual discovery is nudged toward `codebase_peek` / `codebase_search`, while definition questions are nudged toward `implementation_lookup`. Exact identifier and unrelated operational tasks are left alone.
681
+ - When `search.routingHints` is enabled (default), the plugin adds tiny per-turn runtime hints for local conceptual discovery and definition queries. Conceptual discovery is nudged toward `codebase_peek` / `codebase_search`, while definition questions are nudged toward `implementation_lookup`. Exact identifier and unrelated operational tasks are left alone. Set `search.routingHintRole` to `"developer"` if your client/runtime expects developer-role guidance instead of system-role guidance.
663
682
  - `find_similar` stays semantic-only: semantic retrieval + deterministic rerank only (no keyword retrieval, no RRF).
664
683
  - For compatibility rollbacks, set `search.fusionStrategy` to `"weighted"` to use the legacy weighted fusion path.
665
684
  - When enabled, the external reranker sees path metadata plus a bounded on-disk code snippet for each candidate so it can distinguish real implementations from docs/tests more reliably.
@@ -1007,7 +1026,7 @@ The Rust native module handles performance-critical operations:
1007
1026
  - **usearch**: High-performance vector similarity search with F16 quantization
1008
1027
  - **SQLite**: Persistent storage for embeddings, chunks, branch catalog, symbols, and call edges
1009
1028
  - **BM25 inverted index**: Fast keyword search for hybrid retrieval
1010
- - **Call graph extraction**: Tree-sitter query-based extraction of function calls, method calls, constructors, and imports (TypeScript/JavaScript, Python, Go, Rust, PHP, Zig)
1029
+ - **Call graph extraction**: Tree-sitter query-based extraction of function calls, method calls, constructors, and imports (TypeScript/JavaScript, Python, Go, Rust, PHP, Apex, Zig, GDScript, MATLAB)
1011
1030
  - **xxhash**: Fast content hashing for change detection
1012
1031
 
1013
1032
  Rebuild with: `npm run build:native` (requires Rust toolchain)