@sdsrs/code-graph 0.2.2 → 0.4.0-rc1
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/claude-plugin/.claude-plugin/plugin.json +9 -0
- package/claude-plugin/.mcp.json +9 -0
- package/claude-plugin/agents/code-explorer.md +24 -0
- package/claude-plugin/commands/impact.md +19 -0
- package/claude-plugin/commands/trace.md +15 -0
- package/claude-plugin/commands/understand.md +21 -0
- package/claude-plugin/hooks/hooks.json +29 -0
- package/claude-plugin/scripts/statusline.js +16 -0
- package/claude-plugin/skills/code-navigation.md +29 -0
- package/package.json +8 -7
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "code-graph",
|
|
3
|
+
"description": "AST knowledge graph for intelligent code navigation — auto-indexes your codebase and provides semantic search, call graph traversal, HTTP route tracing, and impact analysis via MCP tools",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "sdsrs"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.3.0",
|
|
8
|
+
"keywords": ["code-graph", "ast", "navigation", "mcp", "knowledge-graph"]
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-explorer
|
|
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-graph__read_snippet", "mcp__code-graph__trace_http_chain"]
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a code exploration specialist with access to an AST knowledge graph.
|
|
9
|
+
|
|
10
|
+
## Strategy
|
|
11
|
+
|
|
12
|
+
1. **Start with semantic_code_search** to locate relevant code by meaning
|
|
13
|
+
2. **Use get_call_graph** to understand function relationships and call chains
|
|
14
|
+
3. **Use get_ast_node** to get symbol metadata (signature, type, doc comment)
|
|
15
|
+
4. **Use read_snippet** to examine specific code implementations
|
|
16
|
+
5. **Use trace_http_chain** for HTTP request flow analysis
|
|
17
|
+
6. **Fall back to Grep/Read** only when code-graph tools lack coverage (e.g., config files, non-code assets)
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- Always prefer structured graph queries over raw text search
|
|
22
|
+
- Return structured findings: name, file, line, relationships
|
|
23
|
+
- When reporting call chains, include depth and direction
|
|
24
|
+
- Estimate token cost: if Read would require >3 files, prefer code-graph tools
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze the impact scope of changing a symbol before modifying it
|
|
3
|
+
argument-hint: <symbol_name>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Impact Analysis
|
|
7
|
+
|
|
8
|
+
Analyze what will be affected if you change the given symbol.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
|
|
12
|
+
1. Call `get_call_graph(symbol, "callers", depth=3)` to find all upstream callers
|
|
13
|
+
2. Call `get_call_graph(symbol, "callees", depth=2)` to find downstream dependencies
|
|
14
|
+
3. Check if any callers are HTTP route handlers (look for route-related nodes)
|
|
15
|
+
4. Summarize findings:
|
|
16
|
+
- **Affected files**: list all unique files containing callers/callees
|
|
17
|
+
- **Affected routes**: list any HTTP routes that flow through this symbol
|
|
18
|
+
- **Risk level**: LOW (≤3 callers, no routes), MEDIUM (4-10 callers OR 1-2 routes), HIGH (>10 callers OR ≥3 routes)
|
|
19
|
+
5. Present the analysis before making any modifications
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Trace a full HTTP request flow from route to data layer
|
|
3
|
+
argument-hint: <route_path>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# HTTP Request Flow Tracing
|
|
7
|
+
|
|
8
|
+
Trace the complete execution path of an HTTP request.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
|
|
12
|
+
1. Call `trace_http_chain(route, depth=5)` to get the full chain
|
|
13
|
+
2. For each key node in the chain, call `read_snippet` to show the implementation
|
|
14
|
+
3. Map the flow: route → middleware → validation → business logic → data access → response
|
|
15
|
+
4. Highlight any error handling, authentication checks, or database operations
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Deep dive into a module or file's architecture and relationships
|
|
3
|
+
argument-hint: <file_or_dir_path>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Module Deep Dive
|
|
7
|
+
|
|
8
|
+
Understand what a module does, its public API, and how it connects to the rest of the codebase.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
|
|
12
|
+
1. Call `get_index_status` to verify the code graph index is current
|
|
13
|
+
2. Call `semantic_code_search` with the module name to find its key symbols
|
|
14
|
+
3. For each important export, call `get_call_graph` to map caller/callee relationships
|
|
15
|
+
4. Summarize:
|
|
16
|
+
- **Purpose**: what this module does
|
|
17
|
+
- **Public API**: exported functions/classes with signatures
|
|
18
|
+
- **Internal structure**: key internal helpers
|
|
19
|
+
- **Dependencies**: what it imports
|
|
20
|
+
- **Dependents**: who imports it
|
|
21
|
+
- **Hot paths**: most-called functions (by caller count)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PostToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "tool == \"Write\" || tool == \"Edit\"",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "code-graph-mcp incremental-index --quiet",
|
|
10
|
+
"timeout": 10
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"description": "Auto-update code graph index after file edits"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"SessionStart": [
|
|
17
|
+
{
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "code-graph-mcp health-check --format oneline",
|
|
22
|
+
"timeout": 5
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"description": "Verify code graph index freshness at session start"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
try {
|
|
4
|
+
const out = execSync('code-graph-mcp health-check --format json', {
|
|
5
|
+
timeout: 3000,
|
|
6
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
7
|
+
}).toString().trim();
|
|
8
|
+
const s = JSON.parse(out);
|
|
9
|
+
const icon = s.healthy ? '\u2713' : '\u2717';
|
|
10
|
+
process.stdout.write(
|
|
11
|
+
`code-graph: ${icon} ${s.nodes} nodes | ${s.files} files` +
|
|
12
|
+
(s.watching ? ' | watching' : '')
|
|
13
|
+
);
|
|
14
|
+
} catch {
|
|
15
|
+
process.stdout.write('code-graph: offline');
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-navigation
|
|
3
|
+
description: Smart code navigation decision tree for code-graph MCP tools. Use when exploring, understanding, or navigating code in a project indexed by code-graph.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Navigation with Code Graph
|
|
7
|
+
|
|
8
|
+
This project has a code-graph MCP server providing AST-level code intelligence.
|
|
9
|
+
These tools return structured, token-efficient results. Use them as your
|
|
10
|
+
PRIMARY navigation method for code understanding tasks.
|
|
11
|
+
|
|
12
|
+
| You want to... | Use this | NOT this |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| Find code by concept/meaning | `semantic_code_search` | Grep multiple patterns |
|
|
15
|
+
| Understand who calls what | `get_call_graph` | Grep function name + Read files |
|
|
16
|
+
| Trace HTTP request flow | `trace_http_chain` | Read router -> handler -> service |
|
|
17
|
+
| Find route handler | `find_http_route` | Grep route string |
|
|
18
|
+
| Get symbol signature + relations | `get_ast_node` | Read entire file |
|
|
19
|
+
| Read specific code after search | `read_snippet` (by node_id) | Read entire file |
|
|
20
|
+
| Analyze change impact | `impact_analysis` | Manual call graph tracing |
|
|
21
|
+
| Understand a module | `module_overview` | Read all files in directory |
|
|
22
|
+
| Map dependencies | `dependency_graph` | Grep import statements |
|
|
23
|
+
| Find similar code | `find_similar_code` | Grep partial function names |
|
|
24
|
+
|
|
25
|
+
## Still use native tools for
|
|
26
|
+
- Exact string match → Grep
|
|
27
|
+
- File path lookup → Glob
|
|
28
|
+
- Reading a specific known file → Read
|
|
29
|
+
- Creating/editing files → Write/Edit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-rc1",
|
|
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": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"bin/cli.js",
|
|
26
|
-
"README.md"
|
|
26
|
+
"README.md",
|
|
27
|
+
"claude-plugin"
|
|
27
28
|
],
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "cargo build --release --no-default-features && node scripts/copy-binary.js"
|
|
@@ -32,10 +33,10 @@
|
|
|
32
33
|
"node": ">=16"
|
|
33
34
|
},
|
|
34
35
|
"optionalDependencies": {
|
|
35
|
-
"@sdsrs/code-graph-linux-x64": "0.
|
|
36
|
-
"@sdsrs/code-graph-linux-arm64": "0.
|
|
37
|
-
"@sdsrs/code-graph-darwin-x64": "0.
|
|
38
|
-
"@sdsrs/code-graph-darwin-arm64": "0.
|
|
39
|
-
"@sdsrs/code-graph-win32-x64": "0.
|
|
36
|
+
"@sdsrs/code-graph-linux-x64": "0.4.0-rc1",
|
|
37
|
+
"@sdsrs/code-graph-linux-arm64": "0.4.0-rc1",
|
|
38
|
+
"@sdsrs/code-graph-darwin-x64": "0.4.0-rc1",
|
|
39
|
+
"@sdsrs/code-graph-darwin-arm64": "0.4.0-rc1",
|
|
40
|
+
"@sdsrs/code-graph-win32-x64": "0.4.0-rc1"
|
|
40
41
|
}
|
|
41
42
|
}
|