opencode-codebase-index 0.4.1 → 0.5.1

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
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **Stop grepping for concepts. Start searching for meaning.**
10
10
 
11
- **opencode-codebase-index** brings semantic understanding to your [OpenCode](https://opencode.ai) workflow. Instead of guessing function names or grepping for keywords, ask your codebase questions in plain English.
11
+ **opencode-codebase-index** brings semantic understanding to your [OpenCode](https://opencode.ai) workflow — and now to any MCP-compatible client like Cursor, Claude Code, and Windsurf. Instead of guessing function names or grepping for keywords, ask your codebase questions in plain English.
12
12
 
13
13
  ## 🚀 Why Use This?
14
14
 
@@ -17,6 +17,7 @@
17
17
  - 🌿 **Branch-Aware**: Seamlessly handles git branch switches — reuses embeddings, filters stale results.
18
18
  - 🔒 **Privacy Focused**: Your vector index is stored locally in your project.
19
19
  - 🔌 **Model Agnostic**: Works out-of-the-box with GitHub Copilot, OpenAI, Gemini, or local Ollama models.
20
+ - 🌐 **MCP Server**: Use with Cursor, Claude Code, Windsurf, or any MCP-compatible client — index once, search from anywhere.
20
21
 
21
22
  ## ⚡ Quick Start
22
23
 
@@ -39,6 +40,52 @@
39
40
  Ask:
40
41
  > "Find the function that handles credit card validation errors"
41
42
 
43
+ ## 🌐 MCP Server (Cursor, Claude Code, Windsurf, etc.)
44
+
45
+ Use the same semantic search from any MCP-compatible client. Index once, search from anywhere.
46
+
47
+ 1. **Install dependencies**
48
+ ```bash
49
+ npm install opencode-codebase-index @modelcontextprotocol/sdk zod
50
+ ```
51
+
52
+ 2. **Configure your MCP client**
53
+
54
+ **Cursor** (`.cursor/mcp.json`):
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "codebase-index": {
59
+ "command": "npx",
60
+ "args": ["opencode-codebase-index-mcp", "--project", "/path/to/your/project"]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ **Claude Code** (`claude_desktop_config.json`):
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "codebase-index": {
71
+ "command": "npx",
72
+ "args": ["opencode-codebase-index-mcp", "--project", "/path/to/your/project"]
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ 3. **CLI options**
79
+ ```bash
80
+ npx opencode-codebase-index-mcp --project /path/to/repo # specify project root
81
+ npx opencode-codebase-index-mcp --config /path/to/config # custom config file
82
+ npx opencode-codebase-index-mcp # uses current directory
83
+ ```
84
+
85
+ The MCP server exposes all 8 tools (`codebase_search`, `codebase_peek`, `find_similar`, `index_codebase`, `index_status`, `index_health_check`, `index_metrics`, `index_logs`) and 4 prompts (`search`, `find`, `index`, `status`).
86
+
87
+ The MCP dependencies (`@modelcontextprotocol/sdk`, `zod`) are optional peer dependencies — they're only needed if you use the MCP server.
88
+
42
89
  ## 🔍 See It In Action
43
90
 
44
91
  **Scenario**: You're new to a codebase and need to fix a bug in the payment flow.
@@ -131,6 +178,7 @@ graph TD
131
178
  - **Native speed**: Core logic written in Rust for maximum performance
132
179
  - **Memory efficient**: F16 vector quantization reduces index size by 50%
133
180
  - **Branch-aware**: Automatically tracks which chunks exist on each git branch
181
+ - **Provider validation**: Detects embedding provider/model changes and requires rebuild to prevent garbage results
134
182
 
135
183
  ## 🌿 Branch-Aware Indexing
136
184
 
@@ -267,7 +315,7 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
267
315
 
268
316
  | Option | Default | Description |
269
317
  |--------|---------|-------------|
270
- | `embeddingProvider` | `"auto"` | Which AI to use: `auto`, `github-copilot`, `openai`, `google`, `ollama` |
318
+ | `embeddingProvider` | `"auto"` | Which AI to use: `auto`, `github-copilot`, `openai`, `google`, `ollama`, `custom` |
271
319
  | `scope` | `"project"` | `project` = index per repo, `global` = shared index across repos |
272
320
  | **indexing** | | |
273
321
  | `autoIndex` | `false` | Automatically index on plugin load |
@@ -303,6 +351,8 @@ The plugin automatically detects available credentials in this order:
303
351
  3. **Google** (Gemini Embeddings)
304
352
  4. **Ollama** (Local/Private - requires `nomic-embed-text`)
305
353
 
354
+ You can also use **Custom** to connect any OpenAI-compatible embedding endpoint (llama.cpp, vLLM, text-embeddings-inference, LiteLLM, etc.).
355
+
306
356
  ### Rate Limits by Provider
307
357
 
308
358
  Each provider has different rate limits. The plugin automatically adjusts concurrency and delays:
@@ -313,6 +363,7 @@ Each provider has different rate limits. The plugin automatically adjusts concur
313
363
  | **OpenAI** | 3 | 500ms | Medium codebases |
314
364
  | **Google** | 5 | 200ms | Medium-large codebases |
315
365
  | **Ollama** | 5 | None | Large codebases (10k+ files) |
366
+ | **Custom** | 3 | 1s | Any OpenAI-compatible endpoint |
316
367
 
317
368
  **For large codebases**, use Ollama locally to avoid rate limits:
318
369
 
@@ -412,6 +463,7 @@ Use this decision tree to pick the right embedding provider:
412
463
  | **GitHub Copilot** | Slow (rate limited) | Free* | Cloud | Small codebases, existing subscribers |
413
464
  | **OpenAI** | Medium | ~$0.0001/1K tokens | Cloud | General use |
414
465
  | **Google** | Fast | Free tier available | Cloud | Medium-large codebases |
466
+ | **Custom** | Varies | Varies | Varies | Self-hosted or third-party endpoints |
415
467
 
416
468
  *Requires active Copilot subscription
417
469
 
@@ -447,6 +499,23 @@ No setup needed if you have an active Copilot subscription.
447
499
  { "embeddingProvider": "github-copilot" }
448
500
  ```
449
501
 
502
+ **Custom (OpenAI-compatible)**
503
+ Works with any server that implements the OpenAI `/v1/embeddings` API format (llama.cpp, vLLM, text-embeddings-inference, LiteLLM, etc.).
504
+ ```json
505
+ {
506
+ "embeddingProvider": "custom",
507
+ "customProvider": {
508
+ "baseUrl": "http://localhost:11434/v1",
509
+ "model": "nomic-embed-text",
510
+ "dimensions": 768,
511
+ "apiKey": "optional-api-key",
512
+ "maxTokens": 8192,
513
+ "timeoutMs": 30000
514
+ }
515
+ }
516
+ ```
517
+ Required fields: `baseUrl`, `model`, `dimensions` (positive integer). Optional: `apiKey`, `maxTokens`, `timeoutMs` (default: 30000).
518
+
450
519
  ## ⚠️ Tradeoffs
451
520
 
452
521
  Be aware of these characteristics:
@@ -493,6 +562,8 @@ CI will automatically run tests and type checking on your PR.
493
562
  ```
494
563
  ├── src/
495
564
  │ ├── index.ts # Plugin entry point
565
+ │ ├── mcp-server.ts # MCP server (Cursor, Claude Code, Windsurf)
566
+ │ ├── cli.ts # CLI entry for MCP stdio transport
496
567
  │ ├── config/ # Configuration schema
497
568
  │ ├── embeddings/ # Provider detection and API calls
498
569
  │ ├── indexer/ # Core indexing logic + inverted index
@@ -520,6 +591,20 @@ The Rust native module handles performance-critical operations:
520
591
 
521
592
  Rebuild with: `npm run build:native` (requires Rust toolchain)
522
593
 
594
+ ### Platform Support
595
+
596
+ Pre-built native binaries are published for:
597
+
598
+ | Platform | Architecture | SIMD Acceleration |
599
+ |----------|-------------|--------------------|
600
+ | macOS | x86_64 | ✅ simsimd |
601
+ | macOS | ARM64 (Apple Silicon) | ✅ simsimd |
602
+ | Linux | x86_64 (GNU) | ✅ simsimd |
603
+ | Linux | ARM64 (GNU) | ✅ simsimd |
604
+ | Windows | x86_64 (MSVC) | ❌ scalar fallback |
605
+
606
+ Windows builds use scalar distance functions instead of SIMD — functionally identical, marginally slower for very large indexes. This is due to MSVC lacking support for certain AVX-512 intrinsics used by simsimd.
607
+
523
608
  ## License
524
609
 
525
610
  MIT