cli-node-graph
v1.0.8
Published
TypeScript codebase knowledge graph analyzer (Nx-style)
Maintainers
Readme
cli-node-graph
TypeScript codebase knowledge graph analyzer — an Nx-style dependency graph tool with deep symbol-level analysis.
Features
- Deep AST Analysis: Parses TypeScript files to extract classes, interfaces, functions, methods, and decorators.
- Rich Relationships: Tracks imports, function calls, class inheritance, and structural dependencies.
- Advanced Graph Algorithms: Includes cycle detection, shortest path, impact analysis, and topological sorting.
- Multiple Export Formats: Export to JSON, DOT (Graphviz), GraphML, Mermaid, Cytoscape, React Flow, and Neo4j CSV.
- Visualization Tools: Use the built-in React Flow visualizer for interactive graph exploration.
Installation
Install globally to use the CLI from anywhere:
npm install -g cli-node-graph
# or
pnpm add -g cli-node-graph
# or
yarn global add cli-node-graphOr run it directly using npx:
npx cli-node-graph <command> [options]Usage
Analyzing a Project
Analyze a TypeScript codebase to build the knowledge graph:
cli-node-graph analyze ./path/to/projectExporting the Graph
Export the knowledge graph to various formats (e.g., reactflow, json, dot, mermaid):
cli-node-graph export ./path/to/project --format reactflow -o graph.jsonFinding Cycles
Detect circular dependencies in your project:
cli-node-graph cycles ./path/to/projectImpact Analysis
Determine what files or symbols are affected if you change a specific symbol:
cli-node-graph impact UserService ./path/to/projectProject Statistics
View overall statistics of your codebase:
cli-node-graph stats ./path/to/projectAPI Usage
You can also use cli-node-graph programmatically in your Node.js scripts:
npm install cli-node-graphimport { GraphBuilder, GraphAlgorithms, JsonExporter } from 'cli-node-graph';
// Build the graph
const graph = new GraphBuilder().build({ projectRoot: './my-project' });
// Analyze the graph
const cycles = new GraphAlgorithms(graph).detectCycles();
console.log('Cycles found:', cycles);
// Export the graph
const json = new JsonExporter().export(graph);Contributing
If you're interested in contributing to the project, please see our Contributing Guide for details on setting up the development environment, architecture, and running tests.
