opencode-codebase-index 0.6.0 → 0.7.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 +298 -28
- package/commands/index.md +6 -4
- package/dist/cli.cjs +950 -150
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +950 -150
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +8024 -6826
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7942 -6744
- 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 +21 -16
- package/skill/SKILL.md +63 -10
package/README.md
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
- [🎯 When to Use What](#-when-to-use-what)
|
|
18
18
|
- [🧰 Tools Available](#-tools-available)
|
|
19
19
|
- [🎮 Slash Commands](#-slash-commands)
|
|
20
|
+
- [📚 Knowledge Base](#-knowledge-base)
|
|
21
|
+
- [🔄 Reranking](#-reranking)
|
|
20
22
|
- [⚙️ Configuration](#️-configuration)
|
|
21
23
|
- [🤝 Contributing](#-contributing)
|
|
22
24
|
|
|
@@ -130,12 +132,13 @@ src/api/checkout.ts:89 (Route handler for /pay)
|
|
|
130
132
|
| Don't know the function name | `codebase_search` | Semantic search finds by meaning |
|
|
131
133
|
| Exploring unfamiliar codebase | `codebase_search` | Discovers related code across files |
|
|
132
134
|
| Just need to find locations | `codebase_peek` | Returns metadata only, saves ~90% tokens |
|
|
135
|
+
| Need the authoritative definition site | `implementation_lookup` | Prioritizes real implementation definitions over docs/tests |
|
|
133
136
|
| Understand code flow | `call_graph` | Find callers/callees of any function |
|
|
134
137
|
| Know exact identifier | `grep` | Faster, finds all occurrences |
|
|
135
138
|
| Need ALL matches | `grep` | Semantic returns top N only |
|
|
136
139
|
| Mixed discovery + precision | `/find` (hybrid) | Best of both worlds |
|
|
137
140
|
|
|
138
|
-
**Rule of thumb**: `codebase_peek` to find locations → `Read` to examine → `grep` for precision.
|
|
141
|
+
**Rule of thumb**: `codebase_peek` to find locations → `Read` to examine → `grep` for precision. For symbol-definition questions, use `implementation_lookup` first.
|
|
139
142
|
|
|
140
143
|
## 📊 Token Usage
|
|
141
144
|
|
|
@@ -186,7 +189,23 @@ graph TD
|
|
|
186
189
|
|
|
187
190
|
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.
|
|
188
191
|
|
|
189
|
-
**Supported Languages**: TypeScript, JavaScript, Python, Rust, Go, Java, C#, Ruby, PHP, Bash, C, C++, JSON, TOML, YAML
|
|
192
|
+
**Supported Languages (Tree-sitter semantic parsing)**: TypeScript, JavaScript, Python, Rust, Go, Java, C#, Ruby, PHP, Bash, C, C++, JSON, TOML, YAML
|
|
193
|
+
|
|
194
|
+
**Additional Supported Formats (line-based chunking)**: TXT, HTML, HTM, Markdown, Shell scripts
|
|
195
|
+
|
|
196
|
+
**Default File Patterns**:
|
|
197
|
+
```
|
|
198
|
+
**/*.{ts,tsx,js,jsx,mjs,cjs} **/*.{py,pyi}
|
|
199
|
+
**/*.{go,rs,java,kt,scala} **/*.{c,cpp,cc,h,hpp}
|
|
200
|
+
**/*.{rb,php,inc,swift} **/*.{vue,svelte,astro}
|
|
201
|
+
**/*.{sql,graphql,proto} **/*.{yaml,yml,toml}
|
|
202
|
+
**/*.{md,mdx} **/*.{sh,bash,zsh}
|
|
203
|
+
**/*.{txt,html,htm}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Use `include` to replace defaults, or `additionalInclude` to extend (e.g. `"**/*.pdf"`, `"**/*.csv"`).
|
|
207
|
+
|
|
208
|
+
**Max File Size**: Default 1MB (1048576 bytes). Configure via `indexing.maxFileSize` (bytes).
|
|
190
209
|
2. **Chunking**: Large blocks are split with overlapping windows to preserve context across chunk boundaries.
|
|
191
210
|
3. **Embedding**: These blocks are converted into vector representations using your configured AI provider.
|
|
192
211
|
4. **Storage**: Embeddings are stored in SQLite (deduplicated by content hash) and vectors in `usearch` with F16 quantization for 50% memory savings. A branch catalog tracks which chunks exist on each branch.
|
|
@@ -237,6 +256,14 @@ When you switch branches, code changes but embeddings for unchanged content rema
|
|
|
237
256
|
└── file-hashes.json # File change detection
|
|
238
257
|
```
|
|
239
258
|
|
|
259
|
+
### File Exclusions
|
|
260
|
+
|
|
261
|
+
The following files/folders are excluded from indexing by default:
|
|
262
|
+
|
|
263
|
+
- **Hidden files/folders**: Files starting with `.` (e.g., `.github`, `.vscode`, `.env`)
|
|
264
|
+
- **Build folders**: Folders containing "build" in their name (e.g., `build`, `mingwBuildDebug`, `cmake-build-debug`)
|
|
265
|
+
- **Default excludes**: `node_modules`, `dist`, `vendor`, `__pycache__`, `target`, `coverage`, etc.
|
|
266
|
+
|
|
240
267
|
## 🧰 Tools Available
|
|
241
268
|
|
|
242
269
|
The plugin exposes these tools to the OpenCode agent:
|
|
@@ -270,6 +297,12 @@ The plugin exposes these tools to the OpenCode agent:
|
|
|
270
297
|
```
|
|
271
298
|
- **Workflow**: `codebase_peek` → find locations → `Read` specific files
|
|
272
299
|
|
|
300
|
+
### `implementation_lookup`
|
|
301
|
+
**Definition-first lookup.** Jumps to the authoritative definition site for a symbol or natural-language definition query.
|
|
302
|
+
- **Use for**: "Where is X defined?", symbol-definition requests, and cases where you want the implementation site rather than all usages.
|
|
303
|
+
- **Behavior**: Prefers real implementation files over tests, docs, examples, and fixtures.
|
|
304
|
+
- **Fallback**: If nothing authoritative is found, use `codebase_search` for broader discovery.
|
|
305
|
+
|
|
273
306
|
### `find_similar`
|
|
274
307
|
Find code similar to a provided snippet.
|
|
275
308
|
- **Use for**: Duplicate detection, refactor prep, pattern mining.
|
|
@@ -300,6 +333,20 @@ Query the call graph to find callers or callees of a function/method. Automatica
|
|
|
300
333
|
- **Parameters**: `name` (function name), `direction` (`callers` or `callees`), `symbolId` (required for `callees`, returned by previous queries).
|
|
301
334
|
- **Example**: Find who calls `validateToken` → `call_graph(name="validateToken", direction="callers")`
|
|
302
335
|
|
|
336
|
+
### `add_knowledge_base`
|
|
337
|
+
Add a folder as a knowledge base to be indexed alongside project code.
|
|
338
|
+
- **Use for**: Indexing external documentation, API references, example programs.
|
|
339
|
+
- **Parameters**: `path` (folder path, absolute or relative), `reindex` (optional, default `true`).
|
|
340
|
+
- **Example**: `add_knowledge_base(path="/path/to/docs")`
|
|
341
|
+
|
|
342
|
+
### `list_knowledge_bases`
|
|
343
|
+
List all configured knowledge base folders and their status.
|
|
344
|
+
|
|
345
|
+
### `remove_knowledge_base`
|
|
346
|
+
Remove a knowledge base folder from the index.
|
|
347
|
+
- **Parameters**: `path` (folder path to remove), `reindex` (optional, default `false`).
|
|
348
|
+
- **Example**: `remove_knowledge_base(path="/path/to/docs")`
|
|
349
|
+
|
|
303
350
|
## 🎮 Slash Commands
|
|
304
351
|
|
|
305
352
|
The plugin automatically registers these slash commands:
|
|
@@ -312,38 +359,218 @@ The plugin automatically registers these slash commands:
|
|
|
312
359
|
| `/index` | **Update Index**. Forces a refresh of the codebase index. |
|
|
313
360
|
| `/status` | **Check Status**. Shows if indexed, chunk count, and provider info. |
|
|
314
361
|
|
|
362
|
+
## 📚 Knowledge Base
|
|
363
|
+
|
|
364
|
+
The plugin can index **external documentation** alongside your project code. The indexed codebase includes:
|
|
365
|
+
|
|
366
|
+
- **Project Source Code** — all code files in the current workspace
|
|
367
|
+
- **API References** — hardware API docs, library documentation
|
|
368
|
+
- **Usage Guides** — tutorials, how-to guides
|
|
369
|
+
- **Example Programs** — code samples, demo projects
|
|
370
|
+
|
|
371
|
+
### Adding Knowledge Base Folders
|
|
372
|
+
|
|
373
|
+
Use the built-in tools to add documentation folders:
|
|
374
|
+
|
|
375
|
+
```
|
|
376
|
+
add_knowledge_base(path="/path/to/api-docs")
|
|
377
|
+
add_knowledge_base(path="/path/to/examples")
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
The folder will be indexed into the **same database** as your project code. All searches automatically include both sources.
|
|
381
|
+
|
|
382
|
+
### Managing Knowledge Bases
|
|
383
|
+
|
|
384
|
+
```
|
|
385
|
+
list_knowledge_bases # Show configured knowledge bases
|
|
386
|
+
remove_knowledge_base(path="/path/to/api-docs") # Remove a knowledge base
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Configuration Example
|
|
390
|
+
|
|
391
|
+
Project-level config (`.opencode/codebase-index.json`):
|
|
392
|
+
```json
|
|
393
|
+
{
|
|
394
|
+
"knowledgeBases": [
|
|
395
|
+
"/home/user/docs/esp-idf",
|
|
396
|
+
"/home/user/docs/arduino"
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Global-level config (`~/.config/opencode/codebase-index.json`):
|
|
402
|
+
```json
|
|
403
|
+
{
|
|
404
|
+
"embeddingProvider": "custom",
|
|
405
|
+
"customProvider": {
|
|
406
|
+
"baseUrl": "https://api.siliconflow.cn/v1",
|
|
407
|
+
"model": "BAAI/bge-m3",
|
|
408
|
+
"dimensions": 1024,
|
|
409
|
+
"apiKey": "{env:SILICONFLOW_API_KEY}"
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Config merging: Global config is the base, project config overrides. Knowledge bases from both levels are merged.
|
|
415
|
+
|
|
416
|
+
### Syncing Changes
|
|
417
|
+
|
|
418
|
+
- **Project code**: Auto-synced via file watcher (real-time)
|
|
419
|
+
- **Knowledge base folders**: Manual sync — run `/index force` after changes
|
|
420
|
+
|
|
421
|
+
## 🔄 Reranking
|
|
422
|
+
|
|
423
|
+
The plugin supports **API-based reranking** for improved search result quality. Reranking uses a cross-encoder model to rescore the top search results.
|
|
424
|
+
|
|
425
|
+
### Enable Reranking
|
|
426
|
+
|
|
427
|
+
Add to your config (`.opencode/codebase-index.json` or global config):
|
|
428
|
+
|
|
429
|
+
```json
|
|
430
|
+
{
|
|
431
|
+
"reranker": {
|
|
432
|
+
"enabled": true,
|
|
433
|
+
"baseUrl": "https://api.siliconflow.cn/v1",
|
|
434
|
+
"model": "BAAI/bge-reranker-v2-m3",
|
|
435
|
+
"apiKey": "{env:SILICONFLOW_API_KEY}",
|
|
436
|
+
"topN": 20
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Reranker Options
|
|
442
|
+
|
|
443
|
+
| Option | Default | Description |
|
|
444
|
+
|--------|---------|-------------|
|
|
445
|
+
| `enabled` | `false` | Enable reranking |
|
|
446
|
+
| `baseUrl` | - | Rerank API endpoint |
|
|
447
|
+
| `model` | - | Reranking model name |
|
|
448
|
+
| `apiKey` | - | API key (use `{env:VAR}` for security) |
|
|
449
|
+
| `topN` | `20` | Number of top results to rerank |
|
|
450
|
+
| `timeoutMs` | `30000` | Request timeout |
|
|
451
|
+
|
|
452
|
+
### How It Works
|
|
453
|
+
|
|
454
|
+
```
|
|
455
|
+
Query → Embedding Search → BM25 Search → Fusion → Reranking → Results
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
1. **Embedding Search**: Semantic similarity via vector search
|
|
459
|
+
2. **BM25 Search**: Keyword matching via inverted index
|
|
460
|
+
3. **Fusion**: Combine semantic + keyword results (RRF or weighted)
|
|
461
|
+
4. **Reranking**: Cross-encoder rescores top N results via API
|
|
462
|
+
5. **Results**: Final ranked results
|
|
463
|
+
|
|
464
|
+
### Supported Reranking APIs
|
|
465
|
+
|
|
466
|
+
Any OpenAI-compatible reranking endpoint. Examples:
|
|
467
|
+
- **SiliconFlow**: `BAAI/bge-reranker-v2-m3`
|
|
468
|
+
- **Cohere**: `rerank-english-v3.0`
|
|
469
|
+
- **Local models**: Any server implementing `/v1/rerank` format
|
|
470
|
+
|
|
315
471
|
## ⚙️ Configuration
|
|
316
472
|
|
|
317
473
|
Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-index.json`:
|
|
318
474
|
|
|
475
|
+
### Full Configuration Example
|
|
476
|
+
|
|
319
477
|
```json
|
|
320
478
|
{
|
|
321
|
-
|
|
322
|
-
"
|
|
479
|
+
// === Embedding Provider ===
|
|
480
|
+
"embeddingProvider": "custom", // auto | github-copilot | openai | google | ollama | custom
|
|
481
|
+
"scope": "project", // project (per-repo) | global (shared)
|
|
482
|
+
|
|
483
|
+
// === Custom Embedding API (when embeddingProvider is "custom") ===
|
|
484
|
+
"customProvider": {
|
|
485
|
+
"baseUrl": "https://api.siliconflow.cn/v1",
|
|
486
|
+
"model": "BAAI/bge-m3",
|
|
487
|
+
"dimensions": 1024,
|
|
488
|
+
"apiKey": "{env:SILICONFLOW_API_KEY}",
|
|
489
|
+
"maxTokens": 8192, // Max tokens per input text
|
|
490
|
+
"timeoutMs": 30000, // Request timeout (ms)
|
|
491
|
+
"concurrency": 3, // Max concurrent requests
|
|
492
|
+
"requestIntervalMs": 1000, // Min delay between requests (ms)
|
|
493
|
+
"maxBatchSize": 64 // Max inputs per /embeddings request
|
|
494
|
+
},
|
|
495
|
+
|
|
496
|
+
// === File Patterns ===
|
|
497
|
+
"include": [ // Override default include patterns
|
|
498
|
+
"**/*.{ts,js,py,go,rs}"
|
|
499
|
+
],
|
|
500
|
+
"exclude": [ // Override default exclude patterns
|
|
501
|
+
"**/node_modules/**"
|
|
502
|
+
],
|
|
503
|
+
"additionalInclude": [ // Extend defaults (not replace)
|
|
504
|
+
"**/*.{txt,html,htm}",
|
|
505
|
+
"**/*.pdf"
|
|
506
|
+
],
|
|
507
|
+
|
|
508
|
+
// === Knowledge Bases ===
|
|
509
|
+
"knowledgeBases": [ // External docs to index alongside code
|
|
510
|
+
"/home/user/docs/esp-idf",
|
|
511
|
+
"/home/user/docs/arduino"
|
|
512
|
+
],
|
|
513
|
+
|
|
514
|
+
// === Indexing ===
|
|
323
515
|
"indexing": {
|
|
324
|
-
"autoIndex": false,
|
|
325
|
-
"watchFiles": true,
|
|
326
|
-
"maxFileSize": 1048576,
|
|
327
|
-
"maxChunksPerFile": 100,
|
|
328
|
-
"semanticOnly": false,
|
|
329
|
-
"
|
|
330
|
-
"
|
|
331
|
-
"
|
|
332
|
-
"
|
|
516
|
+
"autoIndex": false, // Auto-index on plugin load
|
|
517
|
+
"watchFiles": true, // Re-index on file changes
|
|
518
|
+
"maxFileSize": 1048576, // Max file size in bytes (default: 1MB)
|
|
519
|
+
"maxChunksPerFile": 100, // Max chunks per file
|
|
520
|
+
"semanticOnly": false, // Only index functions/classes (skip blocks)
|
|
521
|
+
"retries": 3, // Embedding API retry attempts
|
|
522
|
+
"retryDelayMs": 1000, // Delay between retries (ms)
|
|
523
|
+
"autoGc": true, // Auto garbage collection
|
|
524
|
+
"gcIntervalDays": 7, // GC interval (days)
|
|
525
|
+
"gcOrphanThreshold": 100, // GC trigger threshold
|
|
526
|
+
"requireProjectMarker": true, // Require .git/package.json to index
|
|
527
|
+
"maxDepth": 5, // Max directory depth (-1=unlimited, 0=root only)
|
|
528
|
+
"maxFilesPerDirectory": 100, // Max files per directory (smallest first)
|
|
529
|
+
"fallbackToTextOnMaxChunks": true // Fallback to text chunking on maxChunksPerFile
|
|
333
530
|
},
|
|
531
|
+
|
|
532
|
+
// === Search ===
|
|
334
533
|
"search": {
|
|
335
|
-
"maxResults": 20,
|
|
336
|
-
"minScore": 0.1,
|
|
337
|
-
"hybridWeight": 0.5,
|
|
338
|
-
"fusionStrategy": "rrf",
|
|
339
|
-
"rrfK": 60,
|
|
340
|
-
"rerankTopN": 20,
|
|
341
|
-
"contextLines": 0
|
|
534
|
+
"maxResults": 20, // Max results to return
|
|
535
|
+
"minScore": 0.1, // Min similarity score (0-1)
|
|
536
|
+
"hybridWeight": 0.5, // Keyword (1.0) vs semantic (0.0)
|
|
537
|
+
"fusionStrategy": "rrf", // rrf | weighted
|
|
538
|
+
"rrfK": 60, // RRF smoothing constant
|
|
539
|
+
"rerankTopN": 20, // Deterministic rerank depth
|
|
540
|
+
"contextLines": 0, // Extra lines before/after match
|
|
541
|
+
"routingHints": true // Runtime nudges for local discovery/definition queries
|
|
342
542
|
},
|
|
343
|
-
"
|
|
543
|
+
"reranker": {
|
|
344
544
|
"enabled": false,
|
|
345
|
-
"
|
|
346
|
-
"
|
|
545
|
+
"provider": "cohere",
|
|
546
|
+
"model": "rerank-v3.5",
|
|
547
|
+
"apiKey": "{env:RERANK_API_KEY}",
|
|
548
|
+
"topN": 15,
|
|
549
|
+
"timeoutMs": 10000
|
|
550
|
+
},
|
|
551
|
+
"debug": {
|
|
552
|
+
"enabled": false, // Enable debug logging
|
|
553
|
+
"logLevel": "info", // error | warn | info | debug
|
|
554
|
+
"logSearch": true, // Log search operations
|
|
555
|
+
"logEmbedding": true, // Log embedding API calls
|
|
556
|
+
"logCache": true, // Log cache hits/misses
|
|
557
|
+
"logGc": true, // Log garbage collection
|
|
558
|
+
"logBranch": true, // Log branch detection
|
|
559
|
+
"metrics": false // Enable metrics collection
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
String values in `codebase-index.json` can reference environment variables with `{env:VAR_NAME}` when the placeholder is the entire string value. Variable names must match `[A-Z_][A-Z0-9_]*`. This is useful for secrets such as custom provider API keys so they do not need to be committed to the config file.
|
|
565
|
+
|
|
566
|
+
```json
|
|
567
|
+
{
|
|
568
|
+
"embeddingProvider": "custom",
|
|
569
|
+
"customProvider": {
|
|
570
|
+
"baseUrl": "{env:EMBED_BASE_URL}",
|
|
571
|
+
"model": "nomic-embed-text",
|
|
572
|
+
"dimensions": 768,
|
|
573
|
+
"apiKey": "{env:EMBED_API_KEY}"
|
|
347
574
|
}
|
|
348
575
|
}
|
|
349
576
|
```
|
|
@@ -354,6 +581,10 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
|
|
|
354
581
|
|--------|---------|-------------|
|
|
355
582
|
| `embeddingProvider` | `"auto"` | Which AI to use: `auto`, `github-copilot`, `openai`, `google`, `ollama`, `custom` |
|
|
356
583
|
| `scope` | `"project"` | `project` = index per repo, `global` = shared index across repos |
|
|
584
|
+
| `include` | (defaults) | Override the default include patterns (replaces defaults) |
|
|
585
|
+
| `exclude` | (defaults) | Override the default exclude patterns (replaces defaults) |
|
|
586
|
+
| `additionalInclude` | `[]` | Additional file patterns to include (extends defaults, e.g. `"**/*.txt"`, `"**/*.html"`) |
|
|
587
|
+
| `knowledgeBases` | `[]` | External directories to index as knowledge bases (absolute or relative paths) |
|
|
357
588
|
| **indexing** | | |
|
|
358
589
|
| `autoIndex` | `false` | Automatically index on plugin load |
|
|
359
590
|
| `watchFiles` | `true` | Re-index when files change |
|
|
@@ -366,6 +597,9 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
|
|
|
366
597
|
| `gcIntervalDays` | `7` | Run GC on initialization if last GC was more than N days ago |
|
|
367
598
|
| `gcOrphanThreshold` | `100` | Run GC after indexing if orphan count exceeds this threshold |
|
|
368
599
|
| `requireProjectMarker` | `true` | Require a project marker (`.git`, `package.json`, etc.) to enable file watching and auto-indexing. Prevents accidentally indexing large directories like home. Set to `false` to index any directory. |
|
|
600
|
+
| `maxDepth` | `5` | Max directory traversal depth. `-1` = unlimited, `0` = only files in root dir, `1` = one level of subdirectories, etc. |
|
|
601
|
+
| `maxFilesPerDirectory` | `100` | Max files to index per directory. Always picks the smallest files first. |
|
|
602
|
+
| `fallbackToTextOnMaxChunks` | `true` | When a file exceeds `maxChunksPerFile`, fallback to text-based (line-by-line) chunking instead of skipping the rest of the file. |
|
|
369
603
|
| **search** | | |
|
|
370
604
|
| `maxResults` | `20` | Maximum results to return |
|
|
371
605
|
| `minScore` | `0.1` | Minimum similarity score (0-1). Lower = more results |
|
|
@@ -374,6 +608,15 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
|
|
|
374
608
|
| `rrfK` | `60` | RRF smoothing constant. Higher values flatten rank impact, lower values prioritize top-ranked candidates more strongly |
|
|
375
609
|
| `rerankTopN` | `20` | Deterministic rerank depth cap. Applies lightweight name/path/chunk-type rerank to top-N only |
|
|
376
610
|
| `contextLines` | `0` | Extra lines to include before/after each match |
|
|
611
|
+
| `routingHints` | `true` | Inject lightweight runtime hints for local conceptual discovery and definition lookups. Set to `false` to disable plugin-side routing nudges. |
|
|
612
|
+
| **reranker** | | Optional second-stage model reranker for the top candidate pool |
|
|
613
|
+
| `enabled` | `false` | Turn external reranking on/off |
|
|
614
|
+
| `provider` | `"custom"` | Hosted shortcuts: `cohere`, `jina`, or `custom` |
|
|
615
|
+
| `model` | — | Reranker model name required when enabled |
|
|
616
|
+
| `baseUrl` | provider default | Override reranker endpoint base URL. `cohere` → `https://api.cohere.ai/v1`, `jina` → `https://api.jina.ai/v1` |
|
|
617
|
+
| `apiKey` | — | API key for hosted reranker providers |
|
|
618
|
+
| `topN` | `15` | Number of top candidates to send to the external reranker |
|
|
619
|
+
| `timeoutMs` | `10000` | Timeout for external rerank requests |
|
|
377
620
|
| **debug** | | |
|
|
378
621
|
| `enabled` | `false` | Enable debug logging and metrics collection |
|
|
379
622
|
| `logLevel` | `"info"` | Log level: `error`, `warn`, `info`, `debug` |
|
|
@@ -386,9 +629,11 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
|
|
|
386
629
|
|
|
387
630
|
### Retrieval ranking behavior
|
|
388
631
|
|
|
389
|
-
- `codebase_search` and `codebase_peek` use the hybrid path: semantic + keyword retrieval → fusion (`fusionStrategy`) → deterministic rerank (`rerankTopN`) → filtering.
|
|
632
|
+
- `codebase_search` and `codebase_peek` use the hybrid path: semantic + keyword retrieval → fusion (`fusionStrategy`) → deterministic rerank (`rerankTopN`) → optional external reranker (`reranker`) → filtering.
|
|
633
|
+
- 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.
|
|
390
634
|
- `find_similar` stays semantic-only: semantic retrieval + deterministic rerank only (no keyword retrieval, no RRF).
|
|
391
635
|
- For compatibility rollbacks, set `search.fusionStrategy` to `"weighted"` to use the legacy weighted fusion path.
|
|
636
|
+
- 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.
|
|
392
637
|
- Retrieval benchmark artifacts are separated by role:
|
|
393
638
|
- baseline (versioned): `benchmarks/baselines/retrieval-baseline.json`
|
|
394
639
|
- latest candidate run (generated): `benchmark-results/retrieval-candidate.json`
|
|
@@ -557,6 +802,10 @@ ollama pull nomic-embed-text
|
|
|
557
802
|
}
|
|
558
803
|
```
|
|
559
804
|
|
|
805
|
+
The built-in `ollama` provider uses Ollama's native `/api/embeddings` endpoint and is the simplest setup when you want to use `nomic-embed-text`.
|
|
806
|
+
|
|
807
|
+
If you want to use a different Ollama embedding model through its OpenAI-compatible API, use the `custom` provider instead and set `customProvider.baseUrl` to `http://127.0.0.1:11434/v1` so the plugin calls `.../v1/embeddings`.
|
|
808
|
+
|
|
560
809
|
## 📈 Performance
|
|
561
810
|
|
|
562
811
|
The plugin is built for speed with a Rust native module (`tree-sitter`, `usearch`, SQLite). In practice, indexing and retrieval remain fast enough for interactive use on medium/large repositories.
|
|
@@ -604,16 +853,37 @@ Works with any server that implements the OpenAI `/v1/embeddings` API format (ll
|
|
|
604
853
|
{
|
|
605
854
|
"embeddingProvider": "custom",
|
|
606
855
|
"customProvider": {
|
|
607
|
-
"baseUrl": "
|
|
856
|
+
"baseUrl": "{env:EMBED_BASE_URL}",
|
|
608
857
|
"model": "nomic-embed-text",
|
|
609
858
|
"dimensions": 768,
|
|
610
|
-
"apiKey": "
|
|
859
|
+
"apiKey": "{env:EMBED_API_KEY}",
|
|
611
860
|
"maxTokens": 8192,
|
|
612
|
-
"timeoutMs": 30000
|
|
861
|
+
"timeoutMs": 30000,
|
|
862
|
+
"maxBatchSize": 64
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
```
|
|
866
|
+
Required fields: `baseUrl`, `model`, `dimensions` (positive integer). Optional: `apiKey`, `maxTokens`, `timeoutMs` (default: 30000), `maxBatchSize` (or `max_batch_size`) to cap inputs per `/embeddings` request for servers like text-embeddings-inference. `{env:VAR_NAME}` placeholders are resolved before config validation for fields that are actually used and throw if the referenced environment variable is missing or malformed.
|
|
867
|
+
|
|
868
|
+
**Custom Ollama models via OpenAI-compatible API**
|
|
869
|
+
If you are running Ollama locally and want to use an embedding model other than the built-in `ollama` setup, point the custom provider at Ollama's OpenAI-compatible base URL with the `/v1` suffix:
|
|
870
|
+
|
|
871
|
+
```json
|
|
872
|
+
{
|
|
873
|
+
"embeddingProvider": "custom",
|
|
874
|
+
"customProvider": {
|
|
875
|
+
"baseUrl": "http://127.0.0.1:11434/v1",
|
|
876
|
+
"model": "qwen3-embedding:0.6b",
|
|
877
|
+
"dimensions": 1024,
|
|
878
|
+
"apiKey": "ollama"
|
|
613
879
|
}
|
|
614
880
|
}
|
|
615
881
|
```
|
|
616
|
-
|
|
882
|
+
|
|
883
|
+
Notes:
|
|
884
|
+
- The plugin appends `/embeddings`, so `baseUrl` should be `http://127.0.0.1:11434/v1`, not just `http://127.0.0.1:11434`.
|
|
885
|
+
- Ollama ignores the API key, but some OpenAI-compatible clients expect one, so a placeholder like `"ollama"` is fine.
|
|
886
|
+
- Make sure `dimensions` matches the actual output size of the model you pulled locally.
|
|
617
887
|
|
|
618
888
|
## ⚠️ Tradeoffs
|
|
619
889
|
|
package/commands/index.md
CHANGED
|
@@ -9,12 +9,14 @@ User input: $ARGUMENTS
|
|
|
9
9
|
Parse the input and set tool arguments:
|
|
10
10
|
- force=true if input contains "force"
|
|
11
11
|
- estimateOnly=true if input contains "estimate"
|
|
12
|
-
- verbose=
|
|
12
|
+
- verbose=false (default, for token efficiency)
|
|
13
|
+
- verbose=true if input contains "verbose" (for detailed output)
|
|
13
14
|
|
|
14
15
|
Examples:
|
|
15
|
-
- `/index` → force=false, estimateOnly=false, verbose=
|
|
16
|
-
- `/index force` → force=true, estimateOnly=false, verbose=
|
|
17
|
-
- `/index estimate` → force=false, estimateOnly=true, verbose=
|
|
16
|
+
- `/index` → force=false, estimateOnly=false, verbose=false
|
|
17
|
+
- `/index force` → force=true, estimateOnly=false, verbose=false
|
|
18
|
+
- `/index estimate` → force=false, estimateOnly=true, verbose=false
|
|
19
|
+
- `/index verbose` → force=false, estimateOnly=false, verbose=true
|
|
18
20
|
|
|
19
21
|
IMPORTANT: You MUST pass the parsed arguments to `index_codebase`. Do not ignore them.
|
|
20
22
|
|