@fengrru/codegraph
v0.1.1
Published
In-memory heterogeneous code graph symbol extraction, PageRank centrality, k-hop ego-graph search, incremental file watcher
Maintainers
Readme
@fengrru/codegraph
In-memory heterogeneous code graph with PageRank centrality ranking. Build a knowledge graph from your codebase and search it with multi-signal fusion.
Install
npm install @fengrru/codegraph
# Optional: npm install web-tree-sitter (for AST parsing)Quick Start
import { CodeGraph, CodeGraphSearcher, CodeGraphRanker } from "@fengrru/codegraph"
// Build graph from codebase
const graph = new CodeGraph()
await graph.build("./src")
// Search
const searcher = new CodeGraphSearcher(graph)
const results = searcher.search("authenticateUser", { maxResults: 10 })
// Rank by PageRank
const ranker = new CodeGraphRanker(graph)
const ranked = ranker.rank()Features
- 3 node types: file, symbol, module
- 9 edge types: contains, imports, calls, extends, implements, etc.
- PageRank centrality: d=0.85, maxIter=100
- k-hop ego graph: BFS-based subgraph extraction
- Token estimation: for prompt injection
- Incremental updates: file watcher with hot reload
Modules
| Module | Description |
|--------|-------------|
| CodeGraph | Core graph engine |
| CodeGraphSearcher | Multi-mode search with relevance scoring |
| CodeGraphRanker | PageRank + centrality ranking |
| CodeGraphWatcher | Incremental file change detection |
Documentation
- API Reference — TypeDoc-generated API docs
- Source Code
- Examples
License
MIT
