Skip to content

Commit 165f6ca

Browse files
feat: add node role classification (entry/core/utility/adapter/dead/leaf)
Auto-classify every symbol based on fan-in/fan-out connectivity patterns using adaptive median thresholds. Roles are computed during graph build and stored in the DB (migration v5). - classifyNodeRoles() in structure.js with median-based thresholds - New `roles` CLI command with --role and --file filters - New `node_roles` MCP tool (18 tools total) - Role field surfaced in where/explain/context/stats/list-functions - Dead code detection via `roles --role dead` - Unit + integration tests for classification and queries - Updated README, BACKLOG, and COMPETITIVE_ANALYSIS docs Impact: 19 functions changed, 13 affected
1 parent 7b538bc commit 165f6ca

13 files changed

Lines changed: 750 additions & 43 deletions

File tree

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cd your-project
5555
codegraph build
5656
```
5757

58-
That's it. No config files, no Docker, no JVM, no API keys, no accounts. The graph is ready to query. Add `codegraph mcp` to your AI agent's config and it has full access to your dependency graph through 17 MCP tools.
58+
That's it. No config files, no Docker, no JVM, no API keys, no accounts. The graph is ready to query. Add `codegraph mcp` to your AI agent's config and it has full access to your dependency graph through 18 MCP tools.
5959

6060
### Why it matters
6161

@@ -79,6 +79,7 @@ That's it. No config files, no Docker, no JVM, no API keys, no accounts. The gra
7979
| MCP / AI agent support | **Yes** || **Yes** | **Yes** | **Yes** | **Yes** | **Yes** ||
8080
| Git diff impact | **Yes** ||||| **Yes** || **Yes** |
8181
| Watch mode | **Yes** || **Yes** ||||||
82+
| Dead code / role classification | **Yes** || **Yes** ||||| **Yes** |
8283
| Cycle detection | **Yes** || **Yes** ||||| **Yes** |
8384
| Incremental rebuilds | **O(changed)** || O(n) Merkle ||||||
8485
| Zero config | **Yes** || **Yes** ||||||
@@ -94,7 +95,8 @@ That's it. No config files, no Docker, no JVM, no API keys, no accounts. The gra
9495
| **** | **Always-fresh graph** | Three-tier change detection: journal (O(changed)) → mtime+size (O(n) stats) → hash (O(changed) reads). Sub-second rebuilds even on large codebases |
9596
| **🔓** | **Zero-cost core, LLM-enhanced when you want** | Full graph analysis with no API keys, no accounts, no cost. Optionally bring your own LLM provider — your code only goes where you choose |
9697
| **🔬** | **Function-level, not just files** | Traces `handleAuth()``validateToken()``decryptJWT()` and shows 14 callers across 9 files break if `decryptJWT` changes |
97-
| **🤖** | **Built for AI agents** | 17-tool [MCP server](https://modelcontextprotocol.io/) — AI assistants query your graph directly. Single-repo by default |
98+
| **🏷️** | **Role classification** | Every symbol auto-tagged as `entry`/`core`/`utility`/`adapter`/`dead`/`leaf` — agents instantly know what they're looking at |
99+
| **🤖** | **Built for AI agents** | 18-tool [MCP server](https://modelcontextprotocol.io/) — AI assistants query your graph directly. Single-repo by default |
98100
| **🌐** | **Multi-language, one CLI** | JS/TS + Python + Go + Rust + Java + C# + PHP + Ruby + HCL in a single graph |
99101
| **💥** | **Git diff impact** | `codegraph diff-impact` shows changed functions, their callers, and full blast radius — ships with a GitHub Actions workflow |
100102
| **🧠** | **Semantic search** | Local embeddings by default, LLM-powered when opted in — multi-query with RRF ranking via `"auth; token; JWT"` |
@@ -141,7 +143,7 @@ After modifying code:
141143
Or connect directly via MCP:
142144

143145
```bash
144-
codegraph mcp # 17-tool MCP server — AI queries the graph directly
146+
codegraph mcp # 18-tool MCP server — AI queries the graph directly
145147
```
146148

147149
Full agent setup: [AI Agent Guide](docs/ai-agent-guide.md) · [CLAUDE.md template](docs/ai-agent-guide.md#claudemd-template)
@@ -161,11 +163,12 @@ Full agent setup: [AI Agent Guide](docs/ai-agent-guide.md) · [CLAUDE.md t
161163
| 📊 | **Diff impact** | Parse `git diff`, find overlapping functions, trace their callers |
162164
| 🗺️ | **Module map** | Bird's-eye view of your most-connected files |
163165
| 🏗️ | **Structure & hotspots** | Directory cohesion scores, fan-in/fan-out hotspot detection, module boundaries |
166+
| 🏷️ | **Node role classification** | Every symbol auto-tagged as `entry`/`core`/`utility`/`adapter`/`dead`/`leaf` based on connectivity patterns — agents instantly know architectural role |
164167
| 🔄 | **Cycle detection** | Find circular dependencies at file or function level |
165168
| 📤 | **Export** | DOT (Graphviz), Mermaid, and JSON graph export |
166169
| 🧠 | **Semantic search** | Embeddings-powered natural language search with multi-query RRF ranking |
167170
| 👀 | **Watch mode** | Incrementally update the graph as files change |
168-
| 🤖 | **MCP server** | 17-tool MCP server for AI assistants; single-repo by default, opt-in multi-repo |
171+
| 🤖 | **MCP server** | 18-tool MCP server for AI assistants; single-repo by default, opt-in multi-repo |
169172
|| **Always fresh** | Three-tier incremental detection — sub-second rebuilds even on large codebases |
170173

171174
## 📦 Commands
@@ -189,6 +192,9 @@ codegraph map -n 50 --no-tests # Top 50, excluding test files
189192
codegraph where <name> # Where is a symbol defined and used?
190193
codegraph where --file src/db.js # List symbols, imports, exports for a file
191194
codegraph stats # Graph health: nodes, edges, languages, quality score
195+
codegraph roles # Node role classification (entry, core, utility, adapter, dead, leaf)
196+
codegraph roles --role dead -T # Find dead code (unreferenced, non-exported symbols)
197+
codegraph roles --role core --file src/ # Core symbols in src/
192198
```
193199

194200
### Deep Context (AI-Optimized)
@@ -402,7 +408,7 @@ Optional: `@huggingface/transformers` (semantic search), `@modelcontextprotocol/
402408

403409
### MCP Server
404410

405-
Codegraph includes a built-in [Model Context Protocol](https://modelcontextprotocol.io/) server with 17 tools, so AI assistants can query your dependency graph directly:
411+
Codegraph includes a built-in [Model Context Protocol](https://modelcontextprotocol.io/) server with 18 tools, so AI assistants can query your dependency graph directly:
406412

407413
```bash
408414
codegraph mcp # Single-repo mode (default) — only local project
@@ -589,6 +595,7 @@ const { results: fused } = await multiSearchData(
589595
| Incremental rebuilds | **O(changed)** || O(n) Merkle ||||
590596
| MCP / AI agent support | **Yes** || **Yes** | **Yes** | **Yes** | **Yes** |
591597
| Git diff impact | **Yes** ||||| **Yes** |
598+
| Dead code / role classification | **Yes** || **Yes** ||||
592599
| Semantic search | **Yes** || **Yes** | **Yes** || **Yes** |
593600
| Watch mode | **Yes** || **Yes** ||||
594601
| Zero config, no Docker/JVM | **Yes** || **Yes** ||||
@@ -606,7 +613,7 @@ See **[ROADMAP.md](ROADMAP.md)** for the full development roadmap and **[STABILI
606613
5. **Natural Language Queries**`codegraph ask` command, conversational sessions
607614
6. **Expanded Language Support** — 8 new languages (12 → 20)
608615
7. **GitHub Integration & CI** — reusable GitHub Action, PR review, SARIF output
609-
8. **Visualization & Advanced** — web UI, dead code detection, monorepo support, agentic search
616+
8. **Visualization & Advanced** — web UI, monorepo support, agentic search
610617

611618
## 🤝 Contributing
612619

0 commit comments

Comments
 (0)