opencode-codebase-index 0.8.0 → 0.9.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 +29 -11
- package/dist/cli.cjs +1520 -1287
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1519 -1286
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1110 -923
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1081 -894
- package/dist/index.js.map +1 -1
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/native/codebase-index-native.darwin-x64.node +0 -0
- package/native/codebase-index-native.linux-arm64-gnu.node +0 -0
- package/native/codebase-index-native.linux-x64-gnu.node +0 -0
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +8 -2
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
|
|
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": "
|
|
443
|
+
"baseUrl": "{env:EMBED_BASE_URL}",
|
|
436
444
|
"model": "BAAI/bge-m3",
|
|
437
445
|
"dimensions": 1024,
|
|
438
|
-
"apiKey": "{env:
|
|
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.
|
|
463
|
-
"model": "
|
|
464
|
-
"apiKey": "{env:
|
|
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": "
|
|
522
|
+
"baseUrl": "{env:EMBED_BASE_URL}",
|
|
515
523
|
"model": "BAAI/bge-m3",
|
|
516
524
|
"dimensions": 1024,
|
|
517
|
-
"apiKey": "{env:
|
|
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
|
|
@@ -656,6 +664,15 @@ String values in `codebase-index.json` can reference environment variables with
|
|
|
656
664
|
| `logBranch` | `true` | Log branch detection and switches |
|
|
657
665
|
| `metrics` | `false` | Enable metrics collection (indexing stats, search timing, cache performance) |
|
|
658
666
|
|
|
667
|
+
### Recovery warnings in debug logs
|
|
668
|
+
|
|
669
|
+
When debug logging is enabled, the indexer now emits warn-level recovery messages if persisted cache state cannot be read safely.
|
|
670
|
+
|
|
671
|
+
- Corrupted or unreadable `file-hashes.json` causes the in-memory file hash cache to be reset.
|
|
672
|
+
- Corrupted or unreadable `failed-batches.json` causes persisted retry batches to be skipped for that run.
|
|
673
|
+
|
|
674
|
+
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`.
|
|
675
|
+
|
|
659
676
|
### Retrieval ranking behavior
|
|
660
677
|
|
|
661
678
|
- `codebase_search` and `codebase_peek` use the hybrid path: semantic + keyword retrieval → fusion (`fusionStrategy`) → deterministic rerank (`rerankTopN`) → optional external reranker (`reranker`) → filtering.
|
|
@@ -969,6 +986,7 @@ To ensure release notes reflect all merged work, this repo uses a draft-release
|
|
|
969
986
|
- PRs are validated by CI (`Release Label Check`) and fail if no release category label is present
|
|
970
987
|
2. **Let Release Drafter build the draft notes** automatically from merged PRs on `main`.
|
|
971
988
|
3. **Before publishing**:
|
|
989
|
+
- compare `git log --oneline vX.Y.Z..HEAD` (or the previous release tag range) against the draft release notes so the release summary covers the full shipped delta, not just the current `CHANGELOG.md` `Unreleased` section
|
|
972
990
|
- copy/finalize relevant highlights into `CHANGELOG.md`
|
|
973
991
|
- bump `package.json` version
|
|
974
992
|
- run: `npm run build && npm run typecheck && npm run lint && npm run test:run`
|
|
@@ -1006,7 +1024,7 @@ The Rust native module handles performance-critical operations:
|
|
|
1006
1024
|
- **usearch**: High-performance vector similarity search with F16 quantization
|
|
1007
1025
|
- **SQLite**: Persistent storage for embeddings, chunks, branch catalog, symbols, and call edges
|
|
1008
1026
|
- **BM25 inverted index**: Fast keyword search for hybrid retrieval
|
|
1009
|
-
- **Call graph extraction**: Tree-sitter query-based extraction of function calls, method calls, constructors, and imports (TypeScript/JavaScript, Python, Go, Rust, PHP, Zig)
|
|
1027
|
+
- **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)
|
|
1010
1028
|
- **xxhash**: Fast content hashing for change detection
|
|
1011
1029
|
|
|
1012
1030
|
Rebuild with: `npm run build:native` (requires Rust toolchain)
|