@muvon/octocode 0.21.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 +470 -0
- package/cli.js +84 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Muvon/octocode/master/logo.svg" width="240" alt="Octocode">
|
|
4
|
+
|
|
5
|
+
### **Structural Code Intelligence for AI Agents β MCP Server + Knowledge Graph + Semantic Search**
|
|
6
|
+
|
|
7
|
+
[](https://github.com/Muvon/octocode/stargazers)
|
|
8
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
9
|
+
[](https://www.rust-lang.org)
|
|
10
|
+
[](https://github.com/Muvon/octocode/releases)
|
|
11
|
+
|
|
12
|
+
**Give your AI assistant a brain for your codebase.** Octocode transforms your project into a navigable knowledge graph that Claude, Cursor, and other AI agents can search, understand, and navigate.
|
|
13
|
+
|
|
14
|
+
[π Quick Start](#-quick-start) β’ [π€ MCP Integration](#-mcp-server-integration) β’ [π Documentation](#-documentation) β’ [π Website](https://octocode.muvon.io)
|
|
15
|
+
|
|
16
|
+
<a href="https://glama.ai/mcp/servers/Muvon/octocode">
|
|
17
|
+
<img width="300" src="https://glama.ai/mcp/servers/Muvon/octocode/badge" alt="Octocode MCP server" />
|
|
18
|
+
</a>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## π€ Built for AI Agents
|
|
25
|
+
|
|
26
|
+
**The Problem:** AI assistants are blind to your codebase. They can't search your files, understand dependencies, or remember context across sessions.
|
|
27
|
+
|
|
28
|
+
**The Solution:** Octocode's MCP server gives AI agents:
|
|
29
|
+
- π **Semantic search** β Find code by meaning, not keywords
|
|
30
|
+
- πΈοΈ **Knowledge graph** β Navigate imports, calls, and dependencies
|
|
31
|
+
- π **Code signatures** β View structure without reading entire files
|
|
32
|
+
- π§ **LSP precision** β Go-to-definition, find-references, and hover docs via your language server
|
|
33
|
+
|
|
34
|
+
**Works with:** Claude Desktop β’ Cursor β’ Windsurf β’ Any MCP-compatible AI
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
// Add to your AI assistant config
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"octocode": {
|
|
41
|
+
"command": "octocode",
|
|
42
|
+
"args": ["mcp", "--path", "/your/project"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Now your AI assistant can:
|
|
49
|
+
```
|
|
50
|
+
You: "Where is authentication handled?"
|
|
51
|
+
AI: *searches your codebase* "Authentication is in src/middleware/auth.rs,
|
|
52
|
+
which imports jwt.rs for token validation and calls user_store.rs for lookup."
|
|
53
|
+
|
|
54
|
+
You: "What files depend on the payment module?"
|
|
55
|
+
AI: *queries knowledge graph* "src/api/handlers/payment.rs imports payment/mod.rs,
|
|
56
|
+
which is also used by src/workers/refund.rs and src/cron/billing.rs"
|
|
57
|
+
|
|
58
|
+
You: "Find every call site of this function"
|
|
59
|
+
AI: *uses LSP find-references* "process_payment() is called from 4 places:
|
|
60
|
+
checkout.rs:87, refund.rs:134, billing.rs:56, and tests/payment_test.rs:23"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## π€ Why Octocode?
|
|
64
|
+
|
|
65
|
+
**Standard RAG treats your code as flat text chunks.** It finds similar-sounding snippets but has no idea that `auth_middleware.rs` imports `jwt.rs`, calls `user_store.rs`, and is wired into `router.rs`. Octocode understands *structure*.
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
# Semantic search finds the right code
|
|
69
|
+
octocode search "authentication middleware"
|
|
70
|
+
β src/middleware/auth.rs | Similarity 0.923
|
|
71
|
+
|
|
72
|
+
# The GraphRAG CLI queries the optional persisted graph
|
|
73
|
+
octocode config --graphrag-enabled true
|
|
74
|
+
octocode index
|
|
75
|
+
octocode graphrag get-relationships --node-id src/middleware/auth.rs
|
|
76
|
+
Outgoing:
|
|
77
|
+
imports β jwt (src/auth/jwt.rs): token validation logic
|
|
78
|
+
calls β user_store (src/db/user_store.rs): user lookup by token
|
|
79
|
+
Incoming:
|
|
80
|
+
imports β router (src/router.rs): wires auth into the request pipeline
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Octocode uses **tree-sitter AST parsing** to build a live graph of files, symbols, imports, calls, inheritance, and implementations. The MCP `graphrag` tool builds this graph lazily from the current source tree, without an index, embeddings, or an LLM. Optional indexed GraphRAG adds semantic file discovery, descriptions, and broader architectural relationships.
|
|
84
|
+
|
|
85
|
+
## π¬ How It Works
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Current Source β Tree-sitter AST β Live Symbol Graph βββββββββββββββ MCP `graphrag`
|
|
89
|
+
β β
|
|
90
|
+
Indexed Code β Embeddings + Optional LLM β Persisted File Enrichment ββββββ
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
1. **Live AST Graph** β tree-sitter extracts file and symbol nodes plus deterministic `contains`, `imports`, `calls`, `extends`, and `implements` relationships directly from current source
|
|
94
|
+
2. **Always-on Graph Navigation** β MCP graph lookup, relationship traversal, path finding, and overview work with `[graphrag].enabled = false`
|
|
95
|
+
3. **Optional Enrichment** β enabling indexed GraphRAG overlays semantic file matches, LLM descriptions, and broader file-level architectural relationships; symbols are never embedded or LLM-generated
|
|
96
|
+
4. **Hybrid Search** β semantic similarity + BM25 full-text search + reranking handles meaning-based code retrieval separately
|
|
97
|
+
5. **MCP Server** β exposes `semantic_search`, `view_signatures`, `graphrag`, and `structural_search` to any MCP-compatible client
|
|
98
|
+
|
|
99
|
+
## β¨ What Makes It Different
|
|
100
|
+
|
|
101
|
+
| | Standard RAG | Doc Lookup Tools | **Octocode** |
|
|
102
|
+
|---|---|---|---|
|
|
103
|
+
| **Indexes** | Text chunks | External library docs | Your codebase structure (AST) |
|
|
104
|
+
| **Understands** | Similar text | API specs & usage | Functions, imports, dependencies |
|
|
105
|
+
| **Cross-file** | No | No | Yes β navigates the dependency graph |
|
|
106
|
+
| **Relationships** | No | No | `imports`, `calls`, `implements`, `extends`... |
|
|
107
|
+
| **AI integration** | Varies | MCP | Native MCP server + LSP |
|
|
108
|
+
|
|
109
|
+
> **Doc tools give AI the manual for libraries you use. Octocode gives AI the blueprint of how you put them together.**
|
|
110
|
+
|
|
111
|
+
**Built with Rust** for performance. **Local-first** for privacy. **Open source** (Apache 2.0) for transparency.
|
|
112
|
+
|
|
113
|
+
## π Retrieval Quality
|
|
114
|
+
|
|
115
|
+
Octocode ships a **reproducible retrieval benchmark** ([`benchmark/`](benchmark/)): 127 curated code-search queries with line-range ground truth, run against octocode's own source (pinned at `b1771ba` so annotations never drift). The numbers below use a **fully local, no-API-key** stack β `jina-embeddings-v2-base-code` via fastembed, **no reranker** β so they are a floor, not a ceiling:
|
|
116
|
+
|
|
117
|
+
| Config | Hit@5 | Hit@10 | MRR | NDCG@10 | Recall@10 |
|
|
118
|
+
|---|---|---|---|---|---|
|
|
119
|
+
| Dense vector only | 0.598 | 0.717 | 0.485 | 0.528 | 0.671 |
|
|
120
|
+
| Hybrid, default RRF weights (0.7/0.3) | 0.598 | 0.717 | 0.485 | 0.528 | 0.671 |
|
|
121
|
+
| **Hybrid, keyword-tuned (0.3/0.7)** | **0.732** | **0.835** | **0.572** | **0.620** | **0.807** |
|
|
122
|
+
|
|
123
|
+
Tilting RRF fusion toward the BM25/keyword signal β which carries disproportionate weight for code's exact identifiers β lifts **Hit@5 by +22%** and **Recall@10 by +20%** at zero added cost.
|
|
124
|
+
|
|
125
|
+
The benchmark also flags what _doesn't_ help here (full 6-variant matrix in [`benchmark/RESULTS.md`](benchmark/RESULTS.md)): a **generic** local cross-encoder reranker (`bge-reranker-base`) actually **regressed** results (Hit@5 0.732 β 0.598) β code retrieval needs a _code-aware_ reranker (e.g. `voyage:rerank-2.5`), not an off-the-shelf one.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
git worktree add /tmp/corpus b1771ba # pin the corpus to the ground-truth commit
|
|
129
|
+
CORPUS=/tmp/corpus python3 benchmark/run_matrix.py
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See [benchmark/README.md](benchmark/README.md) for methodology and metric definitions.
|
|
133
|
+
|
|
134
|
+
## π Quick Start
|
|
135
|
+
|
|
136
|
+
### 1. Install
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Universal installer (Linux, macOS, Windows)
|
|
140
|
+
curl -fsSL https://raw.githubusercontent.com/Muvon/octocode/master/install.sh | sh
|
|
141
|
+
|
|
142
|
+
# macOS with Homebrew
|
|
143
|
+
brew install muvon/tap/octocode
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary><strong>Other installation methods</strong></summary>
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Cargo (build from source)
|
|
151
|
+
cargo install --git https://github.com/Muvon/octocode
|
|
152
|
+
|
|
153
|
+
# Download binary from releases
|
|
154
|
+
# https://github.com/Muvon/octocode/releases
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
See [Installation Guide](INSTALL.md) for platform-specific instructions.
|
|
158
|
+
</details>
|
|
159
|
+
|
|
160
|
+
### 2. Set Up API Keys
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Required: Embedding provider (Voyage AI has 200M free tokens/month)
|
|
164
|
+
export VOYAGE_API_KEY="your-voyage-api-key"
|
|
165
|
+
|
|
166
|
+
# Optional: LLM for commit messages, code review
|
|
167
|
+
export OPENROUTER_API_KEY="your-openrouter-api-key"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Get your Voyage API key:** [voyageai.com](https://www.voyageai.com/) (free tier available)
|
|
171
|
+
|
|
172
|
+
<details>
|
|
173
|
+
<summary><strong>Other embedding providers</strong></summary>
|
|
174
|
+
|
|
175
|
+
Octocode supports multiple embedding providers:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# OpenAI
|
|
179
|
+
export OPENAI_API_KEY="your-key"
|
|
180
|
+
octocode config --code-embedding-model "openai:text-embedding-3-small"
|
|
181
|
+
|
|
182
|
+
# Jina AI
|
|
183
|
+
export JINA_API_KEY="your-key"
|
|
184
|
+
octocode config --code-embedding-model "jina:jina-embeddings-v3"
|
|
185
|
+
|
|
186
|
+
# Google
|
|
187
|
+
export GOOGLE_API_KEY="your-key"
|
|
188
|
+
octocode config --code-embedding-model "google:text-embedding-005"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
See [API Keys guide](doc/API_KEYS.md) for all supported providers.
|
|
192
|
+
</details>
|
|
193
|
+
|
|
194
|
+
### 3. Index Your Codebase
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
cd /your/project
|
|
198
|
+
octocode index
|
|
199
|
+
# β Indexed 12,847 blocks across 342 files
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 4. Search Your Code
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Natural language search
|
|
206
|
+
octocode search "authentication middleware"
|
|
207
|
+
|
|
208
|
+
# Multi-query for broader results
|
|
209
|
+
octocode search "auth" "middleware" "session"
|
|
210
|
+
|
|
211
|
+
# Filter by language
|
|
212
|
+
octocode search "database connection pool" --lang rust
|
|
213
|
+
|
|
214
|
+
# Search commit history
|
|
215
|
+
octocode search "authentication refactor" --mode commits
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 5. Connect Your AI Assistant
|
|
219
|
+
|
|
220
|
+
Add to your MCP client config (Claude Desktop, Cursor, Windsurf):
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"mcpServers": {
|
|
225
|
+
"octocode": {
|
|
226
|
+
"command": "octocode",
|
|
227
|
+
"args": ["mcp", "--path", "/your/project"]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Done! Your AI assistant now understands your codebase structure.
|
|
234
|
+
|
|
235
|
+
## π MCP Server Integration
|
|
236
|
+
|
|
237
|
+
Octocode includes a **built-in MCP server** that exposes your codebase as tools to AI assistants. This is the primary way to use Octocode β give your AI assistant direct access to search and navigate your code.
|
|
238
|
+
|
|
239
|
+
### Available Tools
|
|
240
|
+
|
|
241
|
+
| Tool | What It Does |
|
|
242
|
+
|------|--------------|
|
|
243
|
+
| `semantic_search` | Find code by meaning β "authentication flow", "error handling", "database queries" |
|
|
244
|
+
| `view_signatures` | View file structure β function signatures, class definitions, imports |
|
|
245
|
+
| `graphrag` | Always-on file/symbol graph β search nodes, inspect relationships, and find paths without indexing |
|
|
246
|
+
| `structural_search` | AST pattern matching β find `.unwrap()` calls, `new` instantiations, specific patterns |
|
|
247
|
+
| `lsp_goto_definition` | Jump to a symbol's definition (requires `--with-lsp`) |
|
|
248
|
+
| `lsp_find_references` | Find all usages of a symbol across the workspace (requires `--with-lsp`) |
|
|
249
|
+
| `lsp_hover` | Type info and documentation for a symbol (requires `--with-lsp`) |
|
|
250
|
+
| `lsp_document_symbols` / `lsp_workspace_symbols` / `lsp_completion` | File symbols, workspace-wide symbol search, completions (requires `--with-lsp`) |
|
|
251
|
+
|
|
252
|
+
Enable the LSP tools by starting the server with your language server:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
octocode mcp --path /your/project --with-lsp="rust-analyzer"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Conversational AI Examples
|
|
259
|
+
|
|
260
|
+
Once connected, your AI assistant can answer questions about your codebase:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
You: "Where is user authentication implemented?"
|
|
264
|
+
AI: *uses semantic_search* "Found in src/auth/login.rs. The authenticate() function
|
|
265
|
+
validates credentials against the database, generates a JWT token, and stores
|
|
266
|
+
the session in Redis."
|
|
267
|
+
|
|
268
|
+
You: "What files depend on the payment module?"
|
|
269
|
+
AI: *uses graphrag* "src/api/handlers/payment.rs imports payment/mod.rs, which is also
|
|
270
|
+
used by src/workers/refund.rs and src/cron/billing.rs. The payment module exports
|
|
271
|
+
process_payment() and validate_transaction() functions."
|
|
272
|
+
|
|
273
|
+
You: "Show me all error handling in the API layer"
|
|
274
|
+
AI: *uses structural_search* "Found 23 error handling patterns in src/api/:
|
|
275
|
+
- 15 use Result<T, ApiError> with explicit error types
|
|
276
|
+
- 8 use .unwrap() (potential panics in handlers/user.rs:42, handlers/auth.rs:87)
|
|
277
|
+
- 3 use .expect() with custom messages"
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Quick Setup
|
|
281
|
+
|
|
282
|
+
**Octomind (Recommended)** β Zero setup, Octocode pre-configured:
|
|
283
|
+
```bash
|
|
284
|
+
curl -fsSL https://raw.githubusercontent.com/muvon/octomind/master/install.sh | bash
|
|
285
|
+
octomind run developer:rust
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Claude Code (CLI)** β Command-line setup:
|
|
289
|
+
```bash
|
|
290
|
+
claude mcp add octocode -- octocode mcp --path /path/to/your/project
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Claude Desktop / Cursor / Windsurf** β Add to config:
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"mcpServers": {
|
|
297
|
+
"octocode": {
|
|
298
|
+
"command": "octocode",
|
|
299
|
+
"args": ["mcp", "--path", "/path/to/your/project"]
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Config locations:**
|
|
306
|
+
- Claude Desktop: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
|
|
307
|
+
- Cursor: `~/.cursor/mcp.json` or Settings β MCP Servers
|
|
308
|
+
- Windsurf: Settings β MCP
|
|
309
|
+
|
|
310
|
+
π **[Complete MCP Client Setup Guide](doc/MCP_CLIENTS.md)** β Detailed instructions for 15+ clients including VS Code (Cline/Continue), Zed, Replit, and more.
|
|
311
|
+
|
|
312
|
+
## π― What Can You Do With It?
|
|
313
|
+
|
|
314
|
+
**New developer onboarding:**
|
|
315
|
+
```
|
|
316
|
+
You: "How does the authentication system work?"
|
|
317
|
+
AI: *searches and navigates* "Authentication starts in src/middleware/auth.rs which
|
|
318
|
+
validates JWT tokens. It calls src/auth/jwt.rs for token verification, which uses
|
|
319
|
+
the public key from config. Failed auth returns 401 via src/errors/auth_error.rs.
|
|
320
|
+
Sessions are stored in Redis via src/cache/session.rs."
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**Code archaeology:**
|
|
324
|
+
```
|
|
325
|
+
You: "Find all places we handle database errors"
|
|
326
|
+
AI: *structural search* "Found 47 error handling patterns:
|
|
327
|
+
- 32 use Result<T, DbError> with proper error types
|
|
328
|
+
- 15 use .unwrap() (potential issues in src/db/user.rs:23, src/db/order.rs:156)
|
|
329
|
+
- Recommend adding proper error handling to those locations"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Refactoring with confidence:**
|
|
333
|
+
```
|
|
334
|
+
You: "What depends on the PaymentProcessor trait?"
|
|
335
|
+
AI: *queries graph* "src/api/handlers/checkout.rs, src/workers/refund_worker.rs,
|
|
336
|
+
and src/cron/billing.rs all depend on PaymentProcessor. The trait is defined
|
|
337
|
+
in src/domain/payment.rs and implemented by src/infrastructure/stripe.rs
|
|
338
|
+
and src/infrastructure/paypal.rs."
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Code review assistance:**
|
|
342
|
+
```
|
|
343
|
+
You: "Review this PR for security issues"
|
|
344
|
+
AI: *analyzes changes* "The PR adds password hashing in src/auth/hash.rs. However,
|
|
345
|
+
it uses SHA256 which is fast and vulnerable to brute force. Recommend using
|
|
346
|
+
bcrypt or argon2 instead. Also found 3 instances of .unwrap() that could panic
|
|
347
|
+
in production."
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## π Supported Languages
|
|
351
|
+
|
|
352
|
+
16 languages with full tree-sitter AST parsing:
|
|
353
|
+
|
|
354
|
+
| Language | Extensions | Features |
|
|
355
|
+
|----------|------------|----------|
|
|
356
|
+
| **Rust** | `.rs` | Full AST parsing, pub/use detection, module structure |
|
|
357
|
+
| **Python** | `.py` | Import/class/function extraction, docstring parsing |
|
|
358
|
+
| **TypeScript/JavaScript** | `.ts`, `.tsx`, `.js`, `.jsx` | ES6 imports/exports, type definitions |
|
|
359
|
+
| **Go** | `.go` | Package/import analysis, struct/interface parsing |
|
|
360
|
+
| **PHP** | `.php` | Class/function extraction, namespace support |
|
|
361
|
+
| **C++** | `.cpp`, `.cc`, `.cxx`, `.c++`, `.c`, `.h`, `.hpp`, `.hxx`, `.cppm`, `.ixx`, `.mxx`, `.ccm`, `.cxxm` | Include analysis, class/function extraction, C++20 module support |
|
|
362
|
+
| **Ruby** | `.rb` | Class/module extraction, method definitions |
|
|
363
|
+
| **Java** | `.java` | Import analysis, class/method extraction |
|
|
364
|
+
| **Swift** | `.swift` | Class/struct/protocol extraction, import analysis |
|
|
365
|
+
| **Svelte** | `.svelte` | Component structure, script/style block extraction |
|
|
366
|
+
| **Lua** | `.lua` | Function and table extraction |
|
|
367
|
+
| **CSS** | `.css` | Rule and selector extraction |
|
|
368
|
+
| **JSON** | `.json` | Structure analysis, key extraction |
|
|
369
|
+
| **Bash** | `.sh`, `.bash` | Function and variable extraction |
|
|
370
|
+
| **Markdown** | `.md` | Document section indexing, header extraction |
|
|
371
|
+
|
|
372
|
+
## π Documentation
|
|
373
|
+
|
|
374
|
+
- **[Getting Started](doc/GETTING_STARTED.md)** β First steps and basic workflow
|
|
375
|
+
- **[Installation Guide](INSTALL.md)** β Detailed methods and building from source
|
|
376
|
+
- **[MCP Client Setup](doc/MCP_CLIENTS.md)** β Connect to Claude, Cursor, Windsurf, and 15+ clients
|
|
377
|
+
- **[MCP Integration](doc/MCP_INTEGRATION.md)** β MCP server details and advanced configuration
|
|
378
|
+
- **[Commands Reference](doc/COMMANDS.md)** β Complete CLI reference
|
|
379
|
+
- **[Configuration](doc/CONFIGURATION.md)** β Templates and customization
|
|
380
|
+
- **[API Keys](doc/API_KEYS.md)** β Provider setup guide
|
|
381
|
+
- **[Architecture](doc/ARCHITECTURE.md)** β How it works under the hood
|
|
382
|
+
- **[Contributing](doc/CONTRIBUTING.md)** β Development setup
|
|
383
|
+
|
|
384
|
+
## π Privacy & Security
|
|
385
|
+
|
|
386
|
+
- **π Local-first** β local embedding models available on supported platforms (macOS ARM default builds); cloud providers on all platforms
|
|
387
|
+
- **π Secure** β API keys stored locally, env vars supported
|
|
388
|
+
- **π« Respects .gitignore** β Never indexes sensitive files
|
|
389
|
+
- **π‘οΈ MCP security** β Local-only server, no external network for search
|
|
390
|
+
- **π€ Cloud-safe** β Embeddings process only metadata, never source code
|
|
391
|
+
|
|
392
|
+
<details>
|
|
393
|
+
<summary><strong>π Retrieval Quality Benchmark</strong></summary>
|
|
394
|
+
|
|
395
|
+
We measure semantic search quality using a hand-annotated ground truth dataset of 254 queries (127 code + 127 docs) with precise line-range annotations. Each query has 1β3 expected results scored by relevance.
|
|
396
|
+
|
|
397
|
+
Tested on commit [`b1771ba`](https://github.com/Muvon/octocode/commit/b1771ba) with [benchmark config](benchmark/config.toml) (contextual retrieval, Voyage reranker, RaBitQ quantization).
|
|
398
|
+
|
|
399
|
+
<details>
|
|
400
|
+
<summary><strong>Documentation search</strong> (<code>--mode docs</code>) β Hit@10: 0.953, MRR: 0.776</summary>
|
|
401
|
+
|
|
402
|
+
| Metric | Score |
|
|
403
|
+
|--------|-------|
|
|
404
|
+
| Hit@5 | 0.929 (118/127) |
|
|
405
|
+
| Hit@10 | 0.953 (121/127) |
|
|
406
|
+
| MRR | 0.776 |
|
|
407
|
+
| NDCG@10 | 0.801 |
|
|
408
|
+
| Recall@5 | 0.902 |
|
|
409
|
+
| Recall@10 | 0.921 |
|
|
410
|
+
|
|
411
|
+
**Missed queries** (6 of 127):
|
|
412
|
+
|
|
413
|
+
| # | Query | Expected | Got (top 1) |
|
|
414
|
+
|---|-------|----------|-------------|
|
|
415
|
+
| 43 | how to set up MCP proxy for managing multiple repositories | `doc/MCP_INTEGRATION.md:286-311` | `doc/MCP_INTEGRATION.md:286-4` |
|
|
416
|
+
| 51 | what are the prerequisites before using octocode | `doc/GETTING_STARTED.md:6-12` | `doc/CONTRIBUTING.md:7-33` |
|
|
417
|
+
| 59 | what to do when hitting API rate limits | `doc/GETTING_STARTED.md:209-216` | `doc/PERFORMANCE.md:304-356` |
|
|
418
|
+
| 75 | typical performance metrics for small medium and large projects | `doc/PERFORMANCE.md:4-13` | `doc/PERFORMANCE.md:414-14` |
|
|
419
|
+
| 112 | how to install octocode on different operating systems | `INSTALL.md:4-14` | `INSTALL.md:49-70` |
|
|
420
|
+
| 115 | how to fix macOS Gatekeeper blocking the binary | `INSTALL.md:199-206` | `INSTALL.md:198-119` |
|
|
421
|
+
|
|
422
|
+
</details>
|
|
423
|
+
|
|
424
|
+
<details>
|
|
425
|
+
<summary><strong>Code search</strong> (<code>--mode code</code>) β Hit@10: 0.992, MRR: 0.895</summary>
|
|
426
|
+
|
|
427
|
+
| Metric | Score |
|
|
428
|
+
|--------|-------|
|
|
429
|
+
| Hit@5 | 0.992 (126/127) |
|
|
430
|
+
| Hit@10 | 0.992 (126/127) |
|
|
431
|
+
| MRR | 0.895 |
|
|
432
|
+
| NDCG@10 | 0.906 |
|
|
433
|
+
| Recall@5 | 0.962 |
|
|
434
|
+
| Recall@10 | 0.974 |
|
|
435
|
+
|
|
436
|
+
**Missed queries** (1 of 127):
|
|
437
|
+
|
|
438
|
+
| # | Query | Expected | Got (top 1) |
|
|
439
|
+
|---|-------|----------|-------------|
|
|
440
|
+
| 105 | how does the system ensure two developers get the same database path | `src/storage.rs:60-83` | `src/mcp/proxy.rs:631-644` |
|
|
441
|
+
|
|
442
|
+
</details>
|
|
443
|
+
|
|
444
|
+
Metrics: **Hit@k** (did the answer appear?), **MRR** (how high?), **NDCG@10** (are best results ranked first?), **Recall@k** (how many found?). See [benchmark/](benchmark/) for methodology, scoring script, and the full dataset.
|
|
445
|
+
|
|
446
|
+
</details>
|
|
447
|
+
|
|
448
|
+
## π€ Community & Support
|
|
449
|
+
|
|
450
|
+
- β **Star us on GitHub** β It really helps!
|
|
451
|
+
- π [Report Issues](https://github.com/Muvon/octocode/issues)
|
|
452
|
+
- π¬ [Discussions](https://github.com/Muvon/octocode/discussions)
|
|
453
|
+
- π§ [opensource@muvon.io](mailto:opensource@muvon.io)
|
|
454
|
+
- π [muvon.io](https://muvon.io)
|
|
455
|
+
|
|
456
|
+
## βοΈ License
|
|
457
|
+
|
|
458
|
+
Apache License 2.0 β See [LICENSE](LICENSE) for details.
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
<div align="center">
|
|
463
|
+
|
|
464
|
+
**Built with π¦ Rust by [Muvon](https://muvon.io) in Hong Kong**
|
|
465
|
+
|
|
466
|
+
[β Star](https://github.com/Muvon/octocode) β’ [π΄ Fork](https://github.com/Muvon/octocode/fork) β’ [π£ Share](https://twitter.com/intent/tweet?text=Octocode%20-%20AI-powered%20code%20intelligence%20with%20built-in%20MCP%20server&url=https://github.com/Muvon/octocode)
|
|
467
|
+
|
|
468
|
+
</div>
|
|
469
|
+
|
|
470
|
+
mcp-name: io.github.Muvon/octocode
|
package/cli.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Generic launcher shipped inside every @muvon/* npm package. Downloads the
|
|
3
|
+
// matching binary from the GitHub release on first run, caches it under
|
|
4
|
+
// ~/.cache/muvon, then execs it with the caller's args.
|
|
5
|
+
//
|
|
6
|
+
// No build-time substitution: name/version come from the package.json next to
|
|
7
|
+
// this file, and the GitHub repo is derived from the scoped package name.
|
|
8
|
+
'use strict'
|
|
9
|
+
|
|
10
|
+
const fs = require('fs')
|
|
11
|
+
const os = require('os')
|
|
12
|
+
const path = require('path')
|
|
13
|
+
const { spawnSync } = require('child_process')
|
|
14
|
+
const { execFileSync } = require('child_process')
|
|
15
|
+
const { Readable } = require('stream')
|
|
16
|
+
const { pipeline } = require('stream/promises')
|
|
17
|
+
|
|
18
|
+
const { name, version } = require('./package.json')
|
|
19
|
+
|
|
20
|
+
const TARGETS = {
|
|
21
|
+
'darwin-arm64': 'aarch64-apple-darwin',
|
|
22
|
+
'darwin-x64': 'x86_64-apple-darwin',
|
|
23
|
+
'linux-arm64': 'aarch64-unknown-linux-musl',
|
|
24
|
+
'linux-x64': 'x86_64-unknown-linux-musl',
|
|
25
|
+
'win32-arm64': 'aarch64-pc-windows-msvc',
|
|
26
|
+
'win32-x64': 'x86_64-pc-windows-msvc',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const bin = name.split('/')[1]
|
|
30
|
+
const repo = `muvon/${bin}`
|
|
31
|
+
const isWindows = process.platform === 'win32'
|
|
32
|
+
const dir = path.join(os.homedir(), '.cache', 'muvon', bin, version)
|
|
33
|
+
const exe = path.join(dir, isWindows ? `${bin}.exe` : bin)
|
|
34
|
+
|
|
35
|
+
async function install() {
|
|
36
|
+
const target = TARGETS[`${process.platform}-${process.arch}`]
|
|
37
|
+
if (!target) {
|
|
38
|
+
throw new Error(`unsupported platform ${process.platform}-${process.arch}`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const ext = isWindows ? 'zip' : 'tar.gz'
|
|
42
|
+
const url = `https://github.com/${repo}/releases/download/${version}/${bin}-${version}-${target}.${ext}`
|
|
43
|
+
const res = await fetch(url)
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
throw new Error(`download failed (${res.status}): ${url}`)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Unpack into a pid-scoped directory and rename into place: concurrent runs
|
|
49
|
+
// (MCP clients spawn several servers at once) must never see a partial binary.
|
|
50
|
+
const tmp = `${dir}.${process.pid}`
|
|
51
|
+
fs.rmSync(tmp, { recursive: true, force: true })
|
|
52
|
+
fs.mkdirSync(tmp, { recursive: true })
|
|
53
|
+
const archive = path.join(tmp, `archive.${ext}`)
|
|
54
|
+
await pipeline(Readable.fromWeb(res.body), fs.createWriteStream(archive))
|
|
55
|
+
// bsdtar reads zip too, and ships with Windows 10 1803+.
|
|
56
|
+
execFileSync('tar', ['-xf', archive, '-C', tmp], { stdio: 'inherit' })
|
|
57
|
+
fs.rmSync(archive)
|
|
58
|
+
fs.chmodSync(path.join(tmp, path.basename(exe)), 0o755)
|
|
59
|
+
|
|
60
|
+
fs.mkdirSync(path.dirname(dir), { recursive: true })
|
|
61
|
+
try {
|
|
62
|
+
fs.renameSync(tmp, dir)
|
|
63
|
+
} catch (err) {
|
|
64
|
+
// Another process won the race; its copy is equivalent.
|
|
65
|
+
if (!fs.existsSync(exe)) throw err
|
|
66
|
+
fs.rmSync(tmp, { recursive: true, force: true })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function main() {
|
|
71
|
+
if (!fs.existsSync(exe)) {
|
|
72
|
+
// stderr only β stdout is the MCP stdio transport.
|
|
73
|
+
process.stderr.write(`${bin}: downloading ${version}...\n`)
|
|
74
|
+
await install()
|
|
75
|
+
}
|
|
76
|
+
const run = spawnSync(exe, process.argv.slice(2), { stdio: 'inherit' })
|
|
77
|
+
if (run.error) throw run.error
|
|
78
|
+
process.exit(run.status === null ? 1 : run.status)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main().catch((err) => {
|
|
82
|
+
process.stderr.write(`${bin}: ${err.message}\n`)
|
|
83
|
+
process.exit(1)
|
|
84
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@muvon/octocode",
|
|
3
|
+
"version": "0.21.0",
|
|
4
|
+
"description": "AI-powered code indexer with semantic search and knowledge graphs",
|
|
5
|
+
"mcpName": "io.github.Muvon/octocode",
|
|
6
|
+
"bin": {
|
|
7
|
+
"octocode": "cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"cli.js"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"homepage": "https://octocode.muvon.io",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/muvon/octocode.git"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
}
|
|
21
|
+
}
|