@sdsrs/code-graph 0.5.14 → 0.5.16
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
|
@@ -43,6 +43,46 @@ Single binary, embedded SQLite, bundled sqlite-vec extension, optional local emb
|
|
|
43
43
|
|
|
44
44
|
Every design decision — from token-aware compression to node_id-based snippet expansion — is optimized for LLM context windows. Works out of the box with Claude Code, Cursor, Windsurf, and any MCP-compatible client.
|
|
45
45
|
|
|
46
|
+
## Efficiency: code-graph vs Traditional Tools
|
|
47
|
+
|
|
48
|
+
Real-world benchmarks comparing code-graph-mcp tools against traditional approaches (Grep + Read + Glob) on a 33-file Rust project (~537 AST nodes).
|
|
49
|
+
|
|
50
|
+
### Tool Call Reduction
|
|
51
|
+
|
|
52
|
+
| Scenario | Traditional | code-graph | Savings |
|
|
53
|
+
|----------|:-----------:|:----------:|:-------:|
|
|
54
|
+
| Project architecture overview | 5-8 calls | 1 call (`project_map`) | **~85%** |
|
|
55
|
+
| Find function by concept | 3-5 calls | 1 call (`semantic_code_search`) | **~75%** |
|
|
56
|
+
| Trace 2-level call chain | 8-15 calls | 1 call (`get_call_graph`) | **~90%** |
|
|
57
|
+
| Pre-change impact analysis | 10-20+ calls | 1 call (`impact_analysis`) | **~95%** |
|
|
58
|
+
| Module structure & exports | 5+ calls | 1 call (`module_overview`) | **~80%** |
|
|
59
|
+
| File dependency mapping | 3-5 calls | 1 call (`dependency_graph`) | **~75%** |
|
|
60
|
+
| Similar code detection | N/A | 1 call (`find_similar_code`) | **unique** |
|
|
61
|
+
|
|
62
|
+
### Overall Session Efficiency
|
|
63
|
+
|
|
64
|
+
| Metric | Without code-graph | With code-graph | Improvement |
|
|
65
|
+
|--------|:------------------:|:---------------:|:-----------:|
|
|
66
|
+
| Tool calls per navigation task | ~6 | ~1.2 | **~80% fewer** |
|
|
67
|
+
| Source lines read into context | ~8,000 lines | ~400 lines (structured) | **~95% less** |
|
|
68
|
+
| Navigation token cost | ~36K tokens | ~7K tokens | **~80% saved** |
|
|
69
|
+
| Full session token savings | — | — | **40-60%** |
|
|
70
|
+
|
|
71
|
+
### What code-graph Uniquely Enables
|
|
72
|
+
|
|
73
|
+
- **Impact analysis** — "Changing `conn` affects 33 functions across 4 files, 78 tests at HIGH risk" — impossible to derive manually with Grep
|
|
74
|
+
- **Transitive call tracing** — Follow `main` → `run_serve` → `handle_message` → `handle_tools_call` → `conn` in one query
|
|
75
|
+
- **Semantic search** — Find `authenticate_session` when searching "handle user login"
|
|
76
|
+
- **Dependency strength** — Not just "file A imports file B", but "file A uses 38 symbols from file B"
|
|
77
|
+
|
|
78
|
+
### When Traditional Tools Are Still Better
|
|
79
|
+
|
|
80
|
+
| Use Case | Best Tool |
|
|
81
|
+
|----------|-----------|
|
|
82
|
+
| Exact string / constant search | Grep |
|
|
83
|
+
| Reading a file to edit it | Read |
|
|
84
|
+
| Finding files by name pattern | Glob |
|
|
85
|
+
|
|
46
86
|
## Architecture
|
|
47
87
|
|
|
48
88
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-explorer
|
|
3
3
|
description: Deep code understanding expert using AST knowledge graph. Use when exploring unfamiliar code, tracing complex relationships, or understanding module architecture.
|
|
4
|
-
tools: ["Read", "Grep", "Glob", "Bash", "mcp__code-graph__semantic_code_search", "mcp__code-graph__get_call_graph", "mcp__code-graph__get_ast_node", "mcp__code-
|
|
4
|
+
tools: ["Read", "Grep", "Glob", "Bash", "mcp__code-graph__semantic_code_search", "mcp__code-graph__get_call_graph", "mcp__code-graph__get_ast_node", "mcp__code-graph__trace_http_chain"]
|
|
5
5
|
model: sonnet
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -11,10 +11,9 @@ You are a code exploration specialist with access to an AST knowledge graph.
|
|
|
11
11
|
|
|
12
12
|
1. **Start with semantic_code_search** to locate relevant code by meaning
|
|
13
13
|
2. **Use get_call_graph** to understand function relationships and call chains
|
|
14
|
-
3. **Use get_ast_node** to get symbol metadata
|
|
15
|
-
4. **Use
|
|
16
|
-
5. **
|
|
17
|
-
6. **Fall back to Grep/Read** only when code-graph tools lack coverage (e.g., config files, non-code assets)
|
|
14
|
+
3. **Use get_ast_node** to get symbol metadata, code, and callers/callees (use `context_lines` for surrounding source)
|
|
15
|
+
4. **Use trace_http_chain** for HTTP request flow analysis
|
|
16
|
+
5. **Fall back to Grep/Read** only when code-graph tools lack coverage (e.g., config files, non-code assets)
|
|
18
17
|
|
|
19
18
|
## Rules
|
|
20
19
|
|
|
@@ -10,6 +10,6 @@ Trace the complete execution path of an HTTP request.
|
|
|
10
10
|
## Steps
|
|
11
11
|
|
|
12
12
|
1. Call `trace_http_chain(route, depth=5)` to get the full chain
|
|
13
|
-
2. For each key node in the chain, call `
|
|
13
|
+
2. For each key node in the chain, call `get_ast_node` (by node_id, with `context_lines`) to show the implementation
|
|
14
14
|
3. Map the flow: route → middleware → validation → business logic → data access → response
|
|
15
15
|
4. Highlight any error handling, authentication checks, or database operations
|
|
@@ -9,9 +9,9 @@ Understand what a module does, its public API, and how it connects to the rest o
|
|
|
9
9
|
|
|
10
10
|
## Steps
|
|
11
11
|
|
|
12
|
-
1. Call `
|
|
13
|
-
2. Call `
|
|
14
|
-
3. For
|
|
12
|
+
1. Call `module_overview(path)` to get exports, hot paths, and file structure in one call
|
|
13
|
+
2. Call `dependency_graph(file_path)` for the main file to map imports and dependents
|
|
14
|
+
3. For key functions that need deeper understanding, call `get_call_graph` to trace call chains
|
|
15
15
|
4. Summarize:
|
|
16
16
|
- **Purpose**: what this module does
|
|
17
17
|
- **Public API**: exported functions/classes with signatures
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.16",
|
|
4
4
|
"description": "MCP server that indexes codebases into an AST knowledge graph with semantic search, call graph traversal, and HTTP route tracing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"node": ">=16"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@sdsrs/code-graph-linux-x64": "0.5.
|
|
37
|
-
"@sdsrs/code-graph-linux-arm64": "0.5.
|
|
38
|
-
"@sdsrs/code-graph-darwin-x64": "0.5.
|
|
39
|
-
"@sdsrs/code-graph-darwin-arm64": "0.5.
|
|
40
|
-
"@sdsrs/code-graph-win32-x64": "0.5.
|
|
36
|
+
"@sdsrs/code-graph-linux-x64": "0.5.16",
|
|
37
|
+
"@sdsrs/code-graph-linux-arm64": "0.5.16",
|
|
38
|
+
"@sdsrs/code-graph-darwin-x64": "0.5.16",
|
|
39
|
+
"@sdsrs/code-graph-darwin-arm64": "0.5.16",
|
|
40
|
+
"@sdsrs/code-graph-win32-x64": "0.5.16"
|
|
41
41
|
}
|
|
42
42
|
}
|