opencode-codebase-index 0.3.0 → 0.4.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
@@ -64,11 +64,12 @@ src/api/checkout.ts:89 (Route handler for /pay)
64
64
  |----------|------|-----|
65
65
  | Don't know the function name | `codebase_search` | Semantic search finds by meaning |
66
66
  | Exploring unfamiliar codebase | `codebase_search` | Discovers related code across files |
67
+ | Just need to find locations | `codebase_peek` | Returns metadata only, saves ~90% tokens |
67
68
  | Know exact identifier | `grep` | Faster, finds all occurrences |
68
69
  | Need ALL matches | `grep` | Semantic returns top N only |
69
70
  | Mixed discovery + precision | `/find` (hybrid) | Best of both worlds |
70
71
 
71
- **Rule of thumb**: Semantic search for discovery → grep for precision.
72
+ **Rule of thumb**: `codebase_peek` to find locations`Read` to examine → `grep` for precision.
72
73
 
73
74
  ## 📊 Token Usage
74
75
 
@@ -117,6 +118,8 @@ graph TD
117
118
  ```
118
119
 
119
120
  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.
121
+
122
+ **Supported Languages**: TypeScript, JavaScript, Python, Rust, Go, Java, C#, Ruby, Bash, C, C++, JSON, TOML, YAML
120
123
  2. **Chunking**: Large blocks are split with overlapping windows to preserve context across chunk boundaries.
121
124
  3. **Embedding**: These blocks are converted into vector representations using your configured AI provider.
122
125
  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.
@@ -185,6 +188,18 @@ The plugin exposes these tools to the OpenCode agent:
185
188
  | "code that calculates shipping costs" | "shipping" |
186
189
  | "where user permissions are checked" | "permissions" |
187
190
 
191
+ ### `codebase_peek`
192
+ **Token-efficient discovery.** Returns only metadata (file, line, name, type) without code content.
193
+ - **Use for**: Finding WHERE code is before deciding what to read. Saves ~90% tokens vs `codebase_search`.
194
+ - **Example output**:
195
+ ```
196
+ [1] function "validatePayment" at src/billing.ts:45-67 (score: 0.92)
197
+ [2] class "PaymentProcessor" at src/processor.ts:12-89 (score: 0.87)
198
+
199
+ Use Read tool to examine specific files.
200
+ ```
201
+ - **Workflow**: `codebase_peek` → find locations → `Read` specific files
202
+
188
203
  ### `index_codebase`
189
204
  Manually trigger indexing.
190
205
  - **Use for**: Forcing a re-index or checking stats.
@@ -196,6 +211,14 @@ Checks if the index is ready and healthy.
196
211
  ### `index_health_check`
197
212
  Maintenance tool to remove stale entries from deleted files and orphaned embeddings/chunks from the database.
198
213
 
214
+ ### `index_metrics`
215
+ Returns collected metrics about indexing and search performance. Requires `debug.enabled` and `debug.metrics` to be `true`.
216
+ - **Metrics include**: Files indexed, chunks created, cache hit rate, search timing breakdown, GC stats, embedding API call stats.
217
+
218
+ ### `index_logs`
219
+ Returns recent debug logs with optional filtering.
220
+ - **Parameters**: `category` (optional: `search`, `embedding`, `cache`, `gc`, `branch`), `level` (optional: `error`, `warn`, `info`, `debug`), `limit` (default: 50).
221
+
199
222
  ## 🎮 Slash Commands
200
223
 
201
224
  The plugin automatically registers these slash commands:
@@ -230,6 +253,11 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
230
253
  "minScore": 0.1,
231
254
  "hybridWeight": 0.5,
232
255
  "contextLines": 0
256
+ },
257
+ "debug": {
258
+ "enabled": false,
259
+ "logLevel": "info",
260
+ "metrics": false
233
261
  }
234
262
  }
235
263
  ```
@@ -256,6 +284,15 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
256
284
  | `minScore` | `0.1` | Minimum similarity score (0-1). Lower = more results |
257
285
  | `hybridWeight` | `0.5` | Balance between keyword (1.0) and semantic (0.0) search |
258
286
  | `contextLines` | `0` | Extra lines to include before/after each match |
287
+ | **debug** | | |
288
+ | `enabled` | `false` | Enable debug logging and metrics collection |
289
+ | `logLevel` | `"info"` | Log level: `error`, `warn`, `info`, `debug` |
290
+ | `logSearch` | `true` | Log search operations with timing breakdown |
291
+ | `logEmbedding` | `true` | Log embedding API calls (success, error, rate-limit) |
292
+ | `logCache` | `true` | Log cache hits and misses |
293
+ | `logGc` | `true` | Log garbage collection operations |
294
+ | `logBranch` | `true` | Log branch detection and switches |
295
+ | `metrics` | `false` | Enable metrics collection (indexing stats, search timing, cache performance) |
259
296
 
260
297
  ### Embedding Providers
261
298
  The plugin automatically detects available credentials in this order: