@sdsrs/code-graph 0.5.1 → 0.5.2

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.
@@ -4,6 +4,6 @@
4
4
  "author": {
5
5
  "name": "sdsrs"
6
6
  },
7
- "version": "0.5.1",
7
+ "version": "0.5.2",
8
8
  "keywords": ["code-graph", "ast", "navigation", "mcp", "knowledge-graph"]
9
9
  }
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Force a full code-graph index rebuild
3
+ ---
4
+
5
+ Call the `rebuild_index` tool with `{"confirm": true}` to rebuild the index from scratch.
6
+ Report the number of files indexed and nodes created.
@@ -0,0 +1,8 @@
1
+ ---
2
+ description: Show code-graph index status and embedding progress
3
+ ---
4
+
5
+ Call the `get_index_status` tool and present the results:
6
+ - files_count, nodes_count, edges_count
7
+ - embedding_status and embedding_progress
8
+ - model_available, is_watching
@@ -1,5 +1,29 @@
1
1
  {
2
2
  "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "tool == \"Grep\"",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/pre-search-guide.js\"",
10
+ "timeout": 2
11
+ }
12
+ ],
13
+ "description": "Suggest code-graph alternatives on first Grep call"
14
+ },
15
+ {
16
+ "matcher": "tool == \"Edit\" || tool == \"Write\"",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/pre-edit-guide.js\"",
21
+ "timeout": 2
22
+ }
23
+ ],
24
+ "description": "Remind about impact_analysis before first code modification"
25
+ }
26
+ ],
3
27
  "PostToolUse": [
4
28
  {
5
29
  "matcher": "tool == \"Write\" || tool == \"Edit\"",
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // PreToolUse hook: On FIRST Edit/Write call per session window, remind Claude
4
+ // to check impact_analysis before modifying functions. Fast and non-blocking.
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const os = require('os');
8
+
9
+ const flag = path.join(os.tmpdir(), '.code-graph-edit-guided');
10
+ const WINDOW_MS = 2 * 60 * 60 * 1000; // 2 hours
11
+
12
+ try {
13
+ const stat = fs.statSync(flag);
14
+ if (Date.now() - stat.mtimeMs < WINDOW_MS) process.exit(0);
15
+ } catch { /* first time */ }
16
+
17
+ fs.writeFileSync(flag, '');
18
+ process.stdout.write(
19
+ '[code-graph] Before modifying functions, consider running impact_analysis(symbol_name) ' +
20
+ 'to check blast radius (callers, affected routes, risk level).\n'
21
+ );
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // PreToolUse hook: On FIRST Grep call per session window, remind Claude
4
+ // about code-graph alternatives. Runs fast (<10ms) and only outputs once.
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const os = require('os');
8
+
9
+ const flag = path.join(os.tmpdir(), '.code-graph-search-guided');
10
+ const WINDOW_MS = 2 * 60 * 60 * 1000; // 2 hours (approximate session window)
11
+
12
+ try {
13
+ const stat = fs.statSync(flag);
14
+ if (Date.now() - stat.mtimeMs < WINDOW_MS) process.exit(0);
15
+ } catch { /* flag doesn't exist — first time */ }
16
+
17
+ fs.writeFileSync(flag, '');
18
+ process.stdout.write(
19
+ '[code-graph] For code understanding, prefer code-graph tools over Grep:\n' +
20
+ ' semantic_code_search → find code by concept (10x fewer tokens)\n' +
21
+ ' get_call_graph → who calls X / what X calls (13x fewer tokens)\n' +
22
+ ' module_overview → understand a module (20x fewer tokens)\n' +
23
+ 'Use Grep only for exact strings, constants, or regex patterns.\n'
24
+ );
@@ -1,29 +1,30 @@
1
1
  ---
2
2
  name: code-navigation
3
- description: Code-graph tool selection guide. Use BEFORE any code exploration, bug fixing, feature implementation, or refactoring task to choose the most token-efficient tool (code-graph vs Grep/Read). Especially important before modifying functions — check impact_analysis first.
3
+ description: PROACTIVE code-graph tool selection. Triggers automatically when you need to explore, understand, trace, or modify code. Use BEFORE choosing Grep/Read for code understanding tasks — code-graph tools save 10-40x tokens. Especially critical before modifying functions (impact_analysis first).
4
4
  ---
5
5
 
6
- # Code Navigation with Code Graph
6
+ # Code Navigation Rules
7
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.
8
+ This project has a code-graph MCP server. These tools return structured, token-efficient results.
9
+ **Use them as your PRIMARY navigation method. Fall back to Grep/Read only for exact-match or file editing.**
11
10
 
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 |
11
+ ## Decision Rules
24
12
 
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
13
+ | Task | MUST use | NOT this | Token savings |
14
+ |---|---|---|---|
15
+ | Who calls X / what X calls | `get_call_graph` | Grep + Read ×5 | 13x |
16
+ | Understand module/directory | `module_overview` | Read multiple files | 20x |
17
+ | **Before modifying a function** | `impact_analysis` FIRST | Just Edit | prevents breakage |
18
+ | Find code by concept/meaning | `semantic_code_search` | Grep multiple patterns | 10x |
19
+ | Trace HTTP request flow | `trace_http_chain` | Read router→handler→service | 10x |
20
+ | One symbol's signature+relations | `get_ast_node` | Read entire file | 10x |
21
+ | File import/export dependencies | `dependency_graph` | Grep import statements | 5x |
22
+ | Find similar/duplicate code | `find_similar_code` | Grep partial names | 5x |
23
+ | Read code of a search result | `read_snippet` (by node_id) | Read entire file | 3x |
24
+
25
+ ## When to use native tools instead
26
+
27
+ - **Grep**: exact string match, constants, regex patterns, literal text search
28
+ - **Glob**: find files by name/path pattern
29
+ - **Read**: specific file you already know and need to edit
30
+ - **Write/Edit**: creating or modifying files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdsrs/code-graph",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
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.1",
37
- "@sdsrs/code-graph-linux-arm64": "0.5.1",
38
- "@sdsrs/code-graph-darwin-x64": "0.5.1",
39
- "@sdsrs/code-graph-darwin-arm64": "0.5.1",
40
- "@sdsrs/code-graph-win32-x64": "0.5.1"
36
+ "@sdsrs/code-graph-linux-x64": "0.5.2",
37
+ "@sdsrs/code-graph-linux-arm64": "0.5.2",
38
+ "@sdsrs/code-graph-darwin-x64": "0.5.2",
39
+ "@sdsrs/code-graph-darwin-arm64": "0.5.2",
40
+ "@sdsrs/code-graph-win32-x64": "0.5.2"
41
41
  }
42
42
  }