opencode-codebase-index 0.11.0 → 0.12.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 +42 -3
- package/commands/call-graph.md +9 -5
- package/commands/pr-impact.md +23 -0
- package/dist/cli.cjs +570 -162
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +570 -162
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +745 -328
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +745 -328
- 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 +2 -2
- package/skill/SKILL.md +6 -3
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- [⚡ Quick Start](#-quick-start)
|
|
16
16
|
- [🌐 MCP Server (Cursor, Claude Code, Windsurf, etc.)](#-mcp-server-cursor-claude-code-windsurf-etc)
|
|
17
17
|
- [🎯 When to Use What](#-when-to-use-what)
|
|
18
|
+
- [🧭 OMO CodeGraph Compatibility](#-omo-codegraph-compatibility)
|
|
18
19
|
- [🧰 Tools Available](#-tools-available)
|
|
19
20
|
- [🎮 Slash Commands](#-slash-commands)
|
|
20
21
|
- [📚 Knowledge Base](#-knowledge-base)
|
|
@@ -124,7 +125,7 @@ Use the same semantic search from any MCP-compatible client. Index once, search
|
|
|
124
125
|
npx opencode-codebase-index-mcp # uses current directory
|
|
125
126
|
```
|
|
126
127
|
|
|
127
|
-
The MCP server exposes all
|
|
128
|
+
The MCP server exposes all 12 tools (`codebase_search`, `codebase_peek`, `find_similar`, `implementation_lookup`, `call_graph`, `call_graph_path`, `pr_impact`, `index_codebase`, `index_status`, `index_health_check`, `index_metrics`, `index_logs`) and 5 prompts (`search`, `find`, `definition`, `index`, `status`).
|
|
128
129
|
|
|
129
130
|
The MCP dependencies (`@modelcontextprotocol/sdk`, `zod`) are optional peer dependencies — they're only needed if you use the MCP server.
|
|
130
131
|
|
|
@@ -156,12 +157,35 @@ src/api/checkout.ts:89 (Route handler for /pay)
|
|
|
156
157
|
| Just need to find locations | `codebase_peek` | Returns metadata only, saves ~90% tokens |
|
|
157
158
|
| Need the authoritative definition site | `implementation_lookup` | Prioritizes real implementation definitions over docs/tests |
|
|
158
159
|
| Understand code flow | `call_graph` | Find callers/callees of any function |
|
|
160
|
+
| Trace dependency paths | `call_graph_path` | Find the shortest known call path between two symbols |
|
|
159
161
|
| Know exact identifier | `grep` | Faster, finds all occurrences |
|
|
160
162
|
| Need ALL matches | `grep` | Semantic returns top N only |
|
|
161
163
|
| Mixed discovery + precision | `/find` (hybrid) | Best of both worlds |
|
|
162
164
|
|
|
163
165
|
**Rule of thumb**: `codebase_peek` to find locations → `Read` to examine → `grep` for precision. For symbol-definition questions, use `implementation_lookup` first.
|
|
164
166
|
|
|
167
|
+
## 🧭 OMO CodeGraph Compatibility
|
|
168
|
+
|
|
169
|
+
Recent OMO releases include a built-in CodeGraph MCP and make it part of the default agent workflow. This does **not** replace `opencode-codebase-index`; the two tools answer different first questions.
|
|
170
|
+
|
|
171
|
+
| Need | Prefer | Why |
|
|
172
|
+
|------|--------|-----|
|
|
173
|
+
| Find code by intent, behavior, or natural language | `codebase_peek` / `codebase_search` | Semantic + hybrid retrieval works when you do not know exact names |
|
|
174
|
+
| Jump to the likely implementation site | `implementation_lookup` | Definition-oriented ranking prefers source over tests/docs |
|
|
175
|
+
| Find similar implementations or duplicate patterns | `find_similar` | Embedding similarity compares code shape and meaning |
|
|
176
|
+
| Follow callers, callees, imports, inheritance, or implementations | OMO CodeGraph or `call_graph` | Structural graph tools are best for dependency topology |
|
|
177
|
+
| Find a shortest known relationship chain | `call_graph_path` | Uses this plugin's indexed call edges to connect two symbols |
|
|
178
|
+
| Include external docs, examples, or API references in discovery | `add_knowledge_base` + `codebase_search` | Knowledge bases are indexed into the same retrieval store |
|
|
179
|
+
|
|
180
|
+
Recommended OMO workflow:
|
|
181
|
+
|
|
182
|
+
1. Start broad with `codebase_peek` when the prompt is conceptual, such as "where is auth enforced?" or "payment validation flow".
|
|
183
|
+
2. Use `implementation_lookup` once you have a symbol or concept that should resolve to a definition.
|
|
184
|
+
3. Use OMO CodeGraph, `call_graph`, or `call_graph_path` after locating the relevant symbol to check blast radius and dependency flow.
|
|
185
|
+
4. Keep `grep` for exact identifiers and exhaustive text matches.
|
|
186
|
+
|
|
187
|
+
If OMO reports an uninitialized CodeGraph workspace, follow its `codegraph init` guidance. That setup is independent from this plugin's index under `.opencode/index/`, so `/index` and `codegraph init` may both be useful in the same repository.
|
|
188
|
+
|
|
165
189
|
## 📊 Token Usage
|
|
166
190
|
|
|
167
191
|
In our testing across open-source codebases (axios, express), we observed **up to 90% reduction in token usage** for conceptual queries like *"find the error handling middleware"*.
|
|
@@ -363,9 +387,21 @@ Returns recent debug logs with optional filtering.
|
|
|
363
387
|
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.
|
|
364
388
|
|
|
365
389
|
- **Use for**: Understanding code flow, tracing dependencies, impact analysis.
|
|
366
|
-
- **Parameters**: `name` (function name), `direction` (`callers` or `callees`), `symbolId` (required for `callees`, returned by previous queries).
|
|
390
|
+
- **Parameters**: `name` (function name), `direction` (`callers` or `callees`), `symbolId` (required for `callees`, returned by previous queries), `relationshipType` (optional: `Call`, `MethodCall`, `Constructor`, `Import`, `Inherits`, `Implements`).
|
|
367
391
|
- **Example**: Find who calls `validateToken` → `call_graph(name="validateToken", direction="callers")`
|
|
368
392
|
|
|
393
|
+
### `call_graph_path`
|
|
394
|
+
|
|
395
|
+
Find the shortest known call-graph path between two symbols. Use it after `codebase_peek`, `implementation_lookup`, or `call_graph` identifies the important source and target names.
|
|
396
|
+
|
|
397
|
+
- **Use for**: Blast-radius checks, dependency-chain discovery, explaining how one subsystem reaches another.
|
|
398
|
+
- **Parameters**: `from` (source symbol name), `to` (target symbol name), `maxDepth` (optional, default `10`).
|
|
399
|
+
- **Example**: Trace how `createOrder` reaches `chargeCard` → `call_graph_path(from="createOrder", to="chargeCard")`
|
|
400
|
+
|
|
401
|
+
### `pr_impact`
|
|
402
|
+
Analyzes a PR's changed files to determine impact scope within the codebase.
|
|
403
|
+
- **Use for**: Understanding which symbols are affected by a PR, their call-graph reach, risk level, and community/cluster detection.
|
|
404
|
+
- **Parameters**: `checkConflicts` (optional, default `false`) — when `true`, detects overlapping concurrent PRs sharing affected symbols and returns `conflictingPRs`.
|
|
369
405
|
### `add_knowledge_base`
|
|
370
406
|
Add a folder as a knowledge base to be indexed alongside project code.
|
|
371
407
|
- **Use for**: Indexing external documentation, API references, example programs.
|
|
@@ -393,6 +429,7 @@ The plugin automatically registers these slash commands:
|
|
|
393
429
|
| `/search <query>` | **Pure Semantic Search**. Best for "How does X work?" |
|
|
394
430
|
| `/find <query>` | **Hybrid Search**. Combines semantic search + grep. Best for "Find usage of X". |
|
|
395
431
|
| `/call-graph <query>` | **Call Graph Trace**. Find callers/callees to understand execution flow. |
|
|
432
|
+
| `/pr-impact <PR number or branch>` | **PR Impact Analysis**. Analyze changed files, affected symbols, communities, hub nodes, and risk. |
|
|
396
433
|
| `/index` | **Update Index**. Runs incremental indexing by default; use `/index force` for a full rebuild. |
|
|
397
434
|
| `/status` | **Check Status**. Shows if indexed, chunk count, and provider info. |
|
|
398
435
|
|
|
@@ -576,6 +613,7 @@ Zero-config by default (uses `auto` mode). Customize in `.opencode/codebase-inde
|
|
|
576
613
|
"rerankTopN": 20, // Deterministic rerank depth
|
|
577
614
|
"contextLines": 0, // Extra lines before/after match
|
|
578
615
|
"routingHints": true, // Runtime nudges for local discovery/definition queries
|
|
616
|
+
"routingGraphHandoffHints": false, // Add opt-in graph/OMO CodeGraph handoff wording
|
|
579
617
|
"routingHintRole": "system" // system | developer (message role used for hints)
|
|
580
618
|
},
|
|
581
619
|
"reranker": {
|
|
@@ -647,6 +685,7 @@ String values in `codebase-index.json` can reference environment variables with
|
|
|
647
685
|
| `rerankTopN` | `20` | Deterministic rerank depth cap. Applies lightweight name/path/chunk-type rerank to top-N only |
|
|
648
686
|
| `contextLines` | `0` | Extra lines to include before/after each match |
|
|
649
687
|
| `routingHints` | `true` | Inject lightweight runtime hints for local conceptual discovery and definition lookups. Set to `false` to disable plugin-side routing nudges. |
|
|
688
|
+
| `routingGraphHandoffHints` | `false` | When `true`, conceptual discovery hints also say to use graph tools (including OMO CodeGraph) after semantic discovery identifies relevant symbols. |
|
|
650
689
|
| `routingHintRole` | `"system"` | Message role used when injecting routing hints: `"system"` (default) or `"developer"`. |
|
|
651
690
|
| **reranker** | | Optional second-stage model reranker for the top candidate pool |
|
|
652
691
|
| `enabled` | `false` | Turn external reranking on/off |
|
|
@@ -678,7 +717,7 @@ These warnings improve observability but do **not** change the recovery behavior
|
|
|
678
717
|
### Retrieval ranking behavior
|
|
679
718
|
|
|
680
719
|
- `codebase_search` and `codebase_peek` use the hybrid path: semantic + keyword retrieval → fusion (`fusionStrategy`) → deterministic rerank (`rerankTopN`) → optional external reranker (`reranker`) → filtering.
|
|
681
|
-
- 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. Set `search.routingHintRole` to `"developer"` if your client/runtime expects developer-role guidance instead of system-role guidance.
|
|
720
|
+
- 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. Set `search.routingGraphHandoffHints` to `true` to add opt-in graph/OMO CodeGraph handoff wording, and set `search.routingHintRole` to `"developer"` if your client/runtime expects developer-role guidance instead of system-role guidance.
|
|
682
721
|
- `find_similar` stays semantic-only: semantic retrieval + deterministic rerank only (no keyword retrieval, no RRF).
|
|
683
722
|
- For compatibility rollbacks, set `search.fusionStrategy` to `"weighted"` to use the legacy weighted fusion path.
|
|
684
723
|
- 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.
|
package/commands/call-graph.md
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Trace callers or
|
|
2
|
+
description: Trace callers, callees, or paths using the call graph
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Trace function dependencies using the `call_graph`
|
|
5
|
+
Trace function dependencies using the `call_graph` and `call_graph_path` tools.
|
|
6
6
|
|
|
7
7
|
User input: $ARGUMENTS
|
|
8
8
|
|
|
9
9
|
Interpret input as follows:
|
|
10
|
+
- If input asks for a path, connection, route, chain, or "from X to Y", use `call_graph_path`.
|
|
10
11
|
- Default to `direction="callers"` unless input asks for callees/calls/makes calls.
|
|
11
12
|
- `name=<function>` or plain text function name sets `name`.
|
|
12
13
|
- `symbolId=<id>` is required for `direction="callees"`.
|
|
14
|
+
- For path queries, parse `from=<function>`, `to=<function>`, and optional `maxDepth=<number>`.
|
|
13
15
|
|
|
14
16
|
Execution flow:
|
|
15
|
-
1. If
|
|
16
|
-
2. If direction is `
|
|
17
|
-
3. If direction is `callees` and `symbolId` is
|
|
17
|
+
1. If input asks for a path and has source/target names, call `call_graph_path` with `{ from, to, maxDepth? }`.
|
|
18
|
+
2. If direction is `callers`, call `call_graph` with `{ name, direction: "callers" }`.
|
|
19
|
+
3. If direction is `callees` and `symbolId` is present, call `call_graph` with `{ name, direction: "callees", symbolId }`.
|
|
20
|
+
4. If direction is `callees` and `symbolId` is missing, first call `call_graph` with `direction="callers"` to get symbol IDs, then ask the user to choose one if multiple are returned.
|
|
18
21
|
|
|
19
22
|
Examples:
|
|
20
23
|
- `/call-graph Database` → callers for `Database`
|
|
21
24
|
- `/call-graph callers name=Indexer` → callers for `Indexer`
|
|
22
25
|
- `/call-graph callees name=Database symbolId=sym_abc123` → callees for selected symbol
|
|
26
|
+
- `/call-graph path from=createOrder to=chargeCard` → shortest known path between the two symbols
|
|
23
27
|
|
|
24
28
|
If output says no callers found, suggest running `/index force` first.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze PR or branch impact using the call graph
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Analyze the impact of a pull request or branch before merging.
|
|
6
|
+
|
|
7
|
+
User input: $ARGUMENTS
|
|
8
|
+
|
|
9
|
+
Interpret input as follows:
|
|
10
|
+
- `pr=N` or plain number at the start → set `pr`
|
|
11
|
+
- `branch=<name>` or plain branch name → set `branch`
|
|
12
|
+
- `maxDepth=N` → set max traversal depth
|
|
13
|
+
- `hubThreshold=N` → set hub node threshold
|
|
14
|
+
- `checkConflicts` or `conflicts` → set `checkConflicts=true`
|
|
15
|
+
|
|
16
|
+
Call `pr_impact` with the parsed arguments.
|
|
17
|
+
|
|
18
|
+
Examples:
|
|
19
|
+
- `/pr-impact 42` → pr=42
|
|
20
|
+
- `/pr-impact branch=feature/auth` → branch="feature/auth"
|
|
21
|
+
- `/pr-impact branch=feature/x maxDepth=3 checkConflicts` → branch="feature/x", maxDepth=3, checkConflicts=true
|
|
22
|
+
|
|
23
|
+
If the index doesn't exist, run `index_codebase` first.
|