@sdsrs/code-graph 0.5.42 → 0.5.43
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 +1 -1
- package/claude-plugin/commands/impact.md +4 -14
- package/claude-plugin/commands/rebuild.md +3 -2
- package/claude-plugin/commands/status.md +2 -5
- package/claude-plugin/commands/trace.md +7 -10
- package/claude-plugin/commands/understand.md +6 -15
- package/claude-plugin/hooks/hooks.json +14 -1
- package/claude-plugin/scripts/pre-edit-guide.js +3 -3
- package/claude-plugin/scripts/pre-explore-guide.js +5 -5
- package/claude-plugin/scripts/pre-glob-guide.js +3 -3
- package/claude-plugin/scripts/pre-search-guide.js +6 -6
- package/claude-plugin/scripts/session-init.js +34 -2
- package/claude-plugin/scripts/user-prompt-context.js +115 -0
- package/claude-plugin/skills/code-navigation.md +13 -28
- package/package.json +6 -6
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Analyze
|
|
2
|
+
description: Analyze impact scope before modifying a symbol
|
|
3
3
|
argument-hint: <symbol_name>
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## Impact Analysis
|
|
7
|
+
!`code-graph-mcp impact $ARGUMENTS 2>/dev/null || echo "Symbol not found or no index. Run: code-graph-mcp incremental-index"`
|
|
7
8
|
|
|
8
|
-
|
|
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
|
|
9
|
+
Present the risk assessment and recommend whether it's safe to proceed.
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
description: Force a full code-graph index rebuild
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Run via Bash: `code-graph-mcp incremental-index`
|
|
6
|
+
This updates the index incrementally (only changed files).
|
|
7
|
+
For a full rebuild, delete `.code-graph/` first, then run the MCP server.
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Show code-graph index status
|
|
2
|
+
description: Show code-graph index status
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- files_count, nodes_count, edges_count
|
|
7
|
-
- embedding_status and embedding_progress
|
|
8
|
-
- model_available, is_watching
|
|
5
|
+
!`code-graph-mcp health-check --format json 2>/dev/null || echo '{"error":"No index found"}'`
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Trace
|
|
3
|
-
argument-hint: <
|
|
2
|
+
description: Trace call flow from a handler or route
|
|
3
|
+
argument-hint: <handler_or_route>
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## Call Graph (callees)
|
|
7
|
+
!`code-graph-mcp callgraph $ARGUMENTS --direction callees --depth 4 2>/dev/null || echo "Symbol not found or no index."`
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Call Graph (callers)
|
|
10
|
+
!`code-graph-mcp callgraph $ARGUMENTS --direction callers --depth 2 2>/dev/null`
|
|
9
11
|
|
|
10
|
-
|
|
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 `get_ast_node` (by node_id, with `context_lines`) 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
|
|
12
|
+
Map the flow and highlight error handling, auth checks, and data access points.
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Deep dive into a module or file's architecture
|
|
2
|
+
description: Deep dive into a module or file's architecture
|
|
3
3
|
argument-hint: <file_or_dir_path>
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## Module Overview
|
|
7
|
+
!`code-graph-mcp overview $ARGUMENTS 2>/dev/null || echo "No index or no symbols found. Run: code-graph-mcp incremental-index"`
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Call Graph (top symbols)
|
|
10
|
+
!`code-graph-mcp search "$ARGUMENTS" --limit 5 2>/dev/null`
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
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)
|
|
12
|
+
Analyze the above and summarize: purpose, public API, key internal helpers, and hot paths.
|
|
@@ -59,6 +59,19 @@
|
|
|
59
59
|
"description": "Auto-update code graph index after file edits"
|
|
60
60
|
}
|
|
61
61
|
],
|
|
62
|
+
"UserPromptSubmit": [
|
|
63
|
+
{
|
|
64
|
+
"matcher": "",
|
|
65
|
+
"hooks": [
|
|
66
|
+
{
|
|
67
|
+
"type": "command",
|
|
68
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/user-prompt-context.js\"",
|
|
69
|
+
"timeout": 4
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"description": "Inject relevant code-graph context based on user's question"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
62
75
|
"SessionStart": [
|
|
63
76
|
{
|
|
64
77
|
"matcher": "startup",
|
|
@@ -69,7 +82,7 @@
|
|
|
69
82
|
"timeout": 5
|
|
70
83
|
}
|
|
71
84
|
],
|
|
72
|
-
"description": "StatusLine self-heal, lifecycle sync,
|
|
85
|
+
"description": "StatusLine self-heal, lifecycle sync, project map injection at session start"
|
|
73
86
|
}
|
|
74
87
|
]
|
|
75
88
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// PreToolUse hook: On FIRST Edit/Write call per session window, remind Claude
|
|
4
|
-
// to check
|
|
4
|
+
// to check impact analysis before modifying functions. Fast and non-blocking.
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const os = require('os');
|
|
@@ -16,6 +16,6 @@ try {
|
|
|
16
16
|
|
|
17
17
|
fs.writeFileSync(flag, '');
|
|
18
18
|
process.stdout.write(
|
|
19
|
-
'[code-graph] Before modifying functions, consider
|
|
20
|
-
'
|
|
19
|
+
'[code-graph] Before modifying functions, consider checking blast radius:\n' +
|
|
20
|
+
' code-graph-mcp impact <function_name>\n'
|
|
21
21
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// PreToolUse hook: On FIRST Agent call per session window, suggest
|
|
4
|
-
// code-graph
|
|
4
|
+
// code-graph CLI commands for structural code understanding before spawning agents.
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const os = require('os');
|
|
@@ -16,9 +16,9 @@ try {
|
|
|
16
16
|
|
|
17
17
|
fs.writeFileSync(flag, '');
|
|
18
18
|
process.stdout.write(
|
|
19
|
-
'[code-graph] For code structure understanding, try
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
19
|
+
'[code-graph] For code structure understanding, try CLI first (one Bash call vs agent):\n' +
|
|
20
|
+
' code-graph-mcp map \u2190 full architecture overview\n' +
|
|
21
|
+
' code-graph-mcp overview src/module \u2190 module structure and exports\n' +
|
|
22
|
+
' code-graph-mcp callgraph symbol \u2190 trace call chains\n' +
|
|
23
23
|
'Explore agents remain best for: non-code files, runtime behavior, open-ended investigation.\n'
|
|
24
24
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// PreToolUse hook: On FIRST Glob call per session window, suggest
|
|
4
|
-
// code-graph
|
|
4
|
+
// code-graph CLI commands — but only when exploring project structure,
|
|
5
5
|
// NOT finding specific files by name.
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const path = require('path');
|
|
@@ -32,7 +32,7 @@ try {
|
|
|
32
32
|
fs.writeFileSync(flag, '');
|
|
33
33
|
process.stdout.write(
|
|
34
34
|
'[code-graph] If exploring project structure (not finding specific files):\n' +
|
|
35
|
-
'
|
|
36
|
-
'
|
|
35
|
+
' code-graph-mcp map \u2190 project architecture (modules, deps, entry points)\n' +
|
|
36
|
+
' code-graph-mcp overview src/mcp \u2190 module symbols grouped by file and type\n' +
|
|
37
37
|
'Glob remains best for: finding specific files, configs, non-code assets.\n'
|
|
38
38
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// PreToolUse hook: On FIRST Grep call per session window, suggest
|
|
4
|
-
// code-graph
|
|
4
|
+
// code-graph CLI commands — but only when the pattern looks like code understanding
|
|
5
5
|
// (function names, module patterns), NOT exact string/constant searches.
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const path = require('path');
|
|
@@ -31,9 +31,9 @@ try {
|
|
|
31
31
|
|
|
32
32
|
fs.writeFileSync(flag, '');
|
|
33
33
|
process.stdout.write(
|
|
34
|
-
'[code-graph]
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'Grep remains best for: exact strings,
|
|
34
|
+
'[code-graph] CLI commands for code understanding (via Bash):\n' +
|
|
35
|
+
' code-graph-mcp grep "pattern" \u2190 AST context grep (match + containing function/class)\n' +
|
|
36
|
+
' code-graph-mcp search "concept" \u2190 semantic search (find code by concept, not exact name)\n' +
|
|
37
|
+
' code-graph-mcp callgraph symbol \u2190 call chain tracing\n' +
|
|
38
|
+
'Grep remains best for: exact strings, constants, regex, non-code files.\n'
|
|
39
39
|
);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
const { spawn } = require('child_process');
|
|
3
|
+
const { spawn, execSync } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const os = require('os');
|
|
6
|
+
const fs = require('fs');
|
|
6
7
|
const {
|
|
7
8
|
install, update, readManifest, getPluginVersion, checkScopeConflict,
|
|
8
9
|
cleanupDisabledStatusline, isPluginInactive, readJson,
|
|
@@ -62,12 +63,43 @@ function runSessionInit() {
|
|
|
62
63
|
|
|
63
64
|
const lifecycle = syncLifecycleConfig();
|
|
64
65
|
const autoUpdateLaunched = launchBackgroundAutoUpdate();
|
|
65
|
-
|
|
66
|
+
const mapInjected = injectProjectMap();
|
|
67
|
+
return { inactive: false, lifecycle, autoUpdateLaunched, mapInjected };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Inject project_map summary into session context if index exists.
|
|
72
|
+
* Similar to aider's repo-map — gives Claude project structure upfront.
|
|
73
|
+
*/
|
|
74
|
+
function injectProjectMap() {
|
|
75
|
+
try {
|
|
76
|
+
const cwd = process.cwd();
|
|
77
|
+
const dbPath = path.join(cwd, '.code-graph', 'index.db');
|
|
78
|
+
if (!fs.existsSync(dbPath)) return false;
|
|
79
|
+
|
|
80
|
+
const output = execSync('code-graph-mcp map --compact', {
|
|
81
|
+
cwd,
|
|
82
|
+
timeout: 5000,
|
|
83
|
+
encoding: 'utf8',
|
|
84
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (output && output.trim()) {
|
|
88
|
+
process.stdout.write(
|
|
89
|
+
'[code-graph] Project map (indexed):\n' + output.trim() + '\n'
|
|
90
|
+
);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
// Index not ready or binary not found — skip silently
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
66
97
|
}
|
|
67
98
|
|
|
68
99
|
module.exports = {
|
|
69
100
|
launchBackgroundAutoUpdate,
|
|
70
101
|
syncLifecycleConfig,
|
|
102
|
+
injectProjectMap,
|
|
71
103
|
runSessionInit,
|
|
72
104
|
};
|
|
73
105
|
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
// UserPromptSubmit hook: inject relevant code-graph context based on user's question.
|
|
4
|
+
// Only activates when user message references code entities + has understanding intent.
|
|
5
|
+
// This is a CODE INDEX, not a memory store — only inject structural code context.
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
|
|
11
|
+
// --- Rate limiting ---
|
|
12
|
+
const flag = path.join(os.tmpdir(), '.code-graph-prompt-ctx');
|
|
13
|
+
const COOLDOWN_MS = 60 * 1000; // 1 minute between injections
|
|
14
|
+
try {
|
|
15
|
+
const stat = fs.statSync(flag);
|
|
16
|
+
if (Date.now() - stat.mtimeMs < COOLDOWN_MS) process.exit(0);
|
|
17
|
+
} catch { /* first time */ }
|
|
18
|
+
|
|
19
|
+
// --- Read user message ---
|
|
20
|
+
let message;
|
|
21
|
+
try {
|
|
22
|
+
const input = JSON.parse(fs.readFileSync('/dev/stdin', 'utf8'));
|
|
23
|
+
message = (input && input.message) || '';
|
|
24
|
+
} catch {
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
// Chinese chars are ~3 bytes but 1 char; "看看 fts5_search" is only 16 chars
|
|
28
|
+
if (!message || message.length < 8) process.exit(0);
|
|
29
|
+
|
|
30
|
+
// --- Check index ---
|
|
31
|
+
const cwd = process.cwd();
|
|
32
|
+
const dbPath = path.join(cwd, '.code-graph', 'index.db');
|
|
33
|
+
if (!fs.existsSync(dbPath)) process.exit(0);
|
|
34
|
+
|
|
35
|
+
// --- Constants ---
|
|
36
|
+
|
|
37
|
+
const STOP_WORDS = new Set([
|
|
38
|
+
'this', 'that', 'with', 'from', 'what', 'when', 'which', 'there',
|
|
39
|
+
'their', 'these', 'those', 'have', 'been', 'some', 'will', 'would',
|
|
40
|
+
'could', 'should', 'about', 'after', 'before', 'other', 'every',
|
|
41
|
+
'where', 'while', 'first', 'under', 'still', 'between', 'without',
|
|
42
|
+
'being', 'through', 'default', 'function', 'method', 'class',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
// --- Detect intent + entities ---
|
|
46
|
+
|
|
47
|
+
// Skip non-code prompts (commit, push, simple confirmations, chat, instructions, etc.)
|
|
48
|
+
const trimmed = message.trim();
|
|
49
|
+
if (/^(yes|no|ok|commit|push|y|n|done|thanks|thank you|继续|确认|好的|好|是的|不|可以|行|对|提交|推送|没问题|谢谢|发布|更新|编译|安装|卸载|重启|重连|清理)\s*[.!?。!?]?\s*$/i.test(trimmed)) {
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
// Skip action-only prompts without code entities (修复这些问题, 按优先级实施, etc.)
|
|
53
|
+
if (/^(修复|优化|实施|执行|开始|按|实测|帮我|进入|用|重新)/.test(trimmed) && !/[a-zA-Z_]{4,}/.test(trimmed)) {
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Extract file paths from message
|
|
58
|
+
const filePaths = (message.match(/(?:src|lib|test|pkg|cmd|internal|app|components?)\/[\w/.-]+/g) || [])
|
|
59
|
+
.slice(0, 2);
|
|
60
|
+
|
|
61
|
+
// Extract potential symbol names (camelCase, snake_case, PascalCase, qualified like Foo::bar)
|
|
62
|
+
const symbolCandidates = (message.match(/\b(?:[A-Z]\w*(?:::\w+)+|[a-z]\w*(?:_\w+){1,}|[a-z]\w*(?:[A-Z]\w*)+|[A-Z][a-z]+(?:[A-Z][a-z]+)+)\b/g) || [])
|
|
63
|
+
.filter(s => s.length > 4)
|
|
64
|
+
.filter(s => !STOP_WORDS.has(s.toLowerCase()))
|
|
65
|
+
.slice(0, 3);
|
|
66
|
+
|
|
67
|
+
// Detect intent keywords (EN + ZH, derived from user's actual prompt history)
|
|
68
|
+
const intentImpact = /(?:impact|影响|修改前|改之前|blast radius|before (?:edit|chang|modif)|risk|风险|改动范围|波及|问题在|bug|干扰|冲突|卡)/i.test(message);
|
|
69
|
+
const intentUnderstand = /(?:how does|怎么工作|怎么实现|怎么做|什么|理解|看看|看一下|了解|分析|explain|understand|架构|architecture|structure|overview|模块|概览|干什么|做什么|工作原理|逻辑|机制|流程|功能|结合度|效率|评估|调研|是什么|有什么|能用不|高效不|达标|起作用|科学|深入思考|源码)/i.test(message);
|
|
70
|
+
const intentCallgraph = /(?:who calls|what calls|调用|call(?:graph|er|ee)|trace|链路|追踪|谁调|被谁调|调了谁|上下游|依赖关系|触发|路径|覆盖|介入)/i.test(message);
|
|
71
|
+
const intentSearch = /(?:where is|在哪|find|search|搜索|找|locate|哪里用|哪里定义|定义在|实现在|处理没|在源码|加不加)/i.test(message);
|
|
72
|
+
|
|
73
|
+
// Need entities AND intent, or strong entity signal (qualified names like Foo::bar)
|
|
74
|
+
const hasQualifiedSymbol = symbolCandidates.some(s => s.includes('::'));
|
|
75
|
+
const hasIntent = intentImpact || intentUnderstand || intentCallgraph || intentSearch;
|
|
76
|
+
if (!hasIntent && !hasQualifiedSymbol && filePaths.length === 0) {
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// --- Run ONE targeted CLI query ---
|
|
81
|
+
let result = '';
|
|
82
|
+
try {
|
|
83
|
+
if (intentImpact && symbolCandidates.length > 0) {
|
|
84
|
+
result = run(`code-graph-mcp impact "${symbolCandidates[0]}"`);
|
|
85
|
+
} else if (filePaths.length > 0 && intentUnderstand) {
|
|
86
|
+
// Overview of the mentioned file's directory
|
|
87
|
+
const dir = filePaths[0].replace(/\/[^/]+$/, '/');
|
|
88
|
+
result = run(`code-graph-mcp overview "${dir}"`);
|
|
89
|
+
} else if (intentCallgraph && symbolCandidates.length > 0) {
|
|
90
|
+
result = run(`code-graph-mcp callgraph "${symbolCandidates[0]}" --depth 2`);
|
|
91
|
+
} else if ((intentSearch || hasQualifiedSymbol) && symbolCandidates.length > 0) {
|
|
92
|
+
result = run(`code-graph-mcp search "${symbolCandidates[0]}" --limit 8`);
|
|
93
|
+
} else if (filePaths.length > 0) {
|
|
94
|
+
const dir = filePaths[0].replace(/\/[^/]+$/, '/');
|
|
95
|
+
result = run(`code-graph-mcp overview "${dir}"`);
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (result && result.trim()) {
|
|
102
|
+
fs.writeFileSync(flag, ''); // update cooldown
|
|
103
|
+
process.stdout.write(result.trim() + '\n');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// --- Helpers ---
|
|
107
|
+
|
|
108
|
+
function run(cmd) {
|
|
109
|
+
return execSync(cmd, {
|
|
110
|
+
cwd,
|
|
111
|
+
timeout: 3000,
|
|
112
|
+
encoding: 'utf8',
|
|
113
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-navigation
|
|
3
|
-
description:
|
|
3
|
+
description: Code search and understanding via CLI. Use when exploring code structure, searching by concept, or checking impact before edits.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Code
|
|
6
|
+
# Code Graph CLI
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Indexed project. Use Bash — one command replaces multi-file Grep/Read:
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
| Task | Command | Replaces |
|
|
11
|
+
|------|---------|----------|
|
|
12
|
+
| grep + AST context | `code-graph-mcp grep "pattern" [path]` | Grep |
|
|
13
|
+
| search by concept | `code-graph-mcp search "query"` | Grep (no exact name needed) |
|
|
14
|
+
| structural search | `code-graph-mcp ast-search "q" --type fn --returns Result` | — |
|
|
15
|
+
| project map | `code-graph-mcp map` | Read multiple files |
|
|
16
|
+
| module overview | `code-graph-mcp overview src/path/` | Read directory files |
|
|
17
|
+
| call graph | `code-graph-mcp callgraph symbol` | Grep + Read tracing |
|
|
18
|
+
| impact analysis | `code-graph-mcp impact symbol` | — |
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
| Task | Tool | Savings |
|
|
15
|
-
|---|---|---|
|
|
16
|
-
| Architecture overview | `project_map(compact=true)` | 20x vs Read multiple |
|
|
17
|
-
| Who calls X / what X calls | `get_call_graph(symbol, compact=true)` | 13x vs Grep+Read |
|
|
18
|
-
| Understand module/directory | `module_overview(path, compact=true)` | 20x vs Read files |
|
|
19
|
-
| **Before modifying a function** | `impact_analysis(symbol)` FIRST | prevents breakage |
|
|
20
|
-
| Find code by concept | `semantic_code_search(query, compact=true)` | 10x vs Grep |
|
|
21
|
-
| Trace HTTP request flow | `trace_http_chain(route)` | 10x vs Read |
|
|
22
|
-
| Symbol signature+relations | `get_ast_node(node_id)` | 10x vs Read file |
|
|
23
|
-
| File dependencies | `dependency_graph(file)` | 5x vs Grep |
|
|
24
|
-
|
|
25
|
-
## Workflow Patterns
|
|
26
|
-
|
|
27
|
-
1. **Quick lookup**: `semantic_code_search(compact=true)` → `get_ast_node(node_id=N)`
|
|
28
|
-
2. **Before edit**: `impact_analysis(symbol)` → Edit
|
|
29
|
-
3. **Understand**: `project_map(compact=true)` → `module_overview(path, compact=true)` → `get_call_graph(symbol)`
|
|
30
|
-
|
|
31
|
-
## When to use native tools instead
|
|
32
|
-
|
|
33
|
-
- **Grep**: exact string match, constants, regex patterns, literal text search
|
|
34
|
-
- **Glob**: find files by name/path pattern
|
|
35
|
-
- **Read**: specific file you already know and need to edit
|
|
20
|
+
Still use Grep for exact strings/constants/regex. Still use Read for files you'll edit.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.43",
|
|
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.43",
|
|
37
|
+
"@sdsrs/code-graph-linux-arm64": "0.5.43",
|
|
38
|
+
"@sdsrs/code-graph-darwin-x64": "0.5.43",
|
|
39
|
+
"@sdsrs/code-graph-darwin-arm64": "0.5.43",
|
|
40
|
+
"@sdsrs/code-graph-win32-x64": "0.5.43"
|
|
41
41
|
}
|
|
42
42
|
}
|