From d03374567f7a24a30b6ae1cd5e316dfeaaba71d8 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Mon, 2 Feb 2026 02:34:46 +0000 Subject: [PATCH] Initial upload with project structure and configuration --- README.md | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42174f2..fe6a2de 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,170 @@ -# codebase-knowledge-graph-cli +# Codebase Knowledge Graph CLI -A CLI tool that analyzes codebases and generates interactive knowledge graphs showing code relationships, dependencies, and architecture \ No newline at end of file +A CLI tool that analyzes codebases and generates interactive knowledge graphs showing code relationships, dependencies, and architecture. It parses source files to extract functions, classes, imports, and call hierarchies, then outputs graph visualizations for developers to understand unfamiliar codebases. + +## Features + +- **Multi-language Parser Support**: Parse Python, JavaScript, Go, and Rust source files using tree-sitter +- **Dependency Graph Generation**: Build dependency graphs showing imports and call relationships +- **Circular Dependency Detection**: Detect and report circular dependencies in the codebase +- **Complexity Estimation**: Calculate cyclomatic complexity for functions and methods +- **Graph Export**: Export graphs to DOT, JSON, and PNG formats +- **Interactive CLI**: Rich interactive exploration with filtering, search, and navigation + +## Installation + +```bash +pip install codebase-knowledge-graph-cli +``` + +Or install from source: + +```bash +git clone +cd codebase-knowledge-graph-cli +pip install -e . +``` + +## Quick Start + +```bash +# Analyze a codebase and export to JSON +codegraph analyze ./my_project --format json + +# Visualize the code structure +codegraph visualize ./my_project + +# Check complexity +codegraph complexity ./my_project + +# Analyze dependencies +codegraph deps ./my_project + +# Export to various formats +codegraph export ./my_project -o graph.dot +codegraph export ./my_project -o graph.png +codegraph export ./my_project -o graph.json +``` + +## Usage + +### analyze command + +Analyze a codebase and generate knowledge graphs: + +```bash +codegraph analyze [PATH] [OPTIONS] +``` + +Options: +- `--language, -l`: Language (python, javascript, go, rust, auto) +- `--output, -o`: Output file path +- `--format, -f`: Output format (dot, json, png) +- `--verbose, -v`: Enable verbose output + +### visualize command + +Generate a tree visualization of the codebase structure: + +```bash +codegraph visualize [PATH] [OPTIONS] +``` + +### complexity command + +Analyze cyclomatic complexity of functions and methods: + +```bash +codegraph complexity [PATH] [OPTIONS] +``` + +### deps command + +Analyze dependencies and detect circular imports: + +```bash +codegraph deps [PATH] [OPTIONS] +``` + +### export command + +Export the graph to various formats: + +```bash +codegraph export [PATH] -o [OUTPUT] [OPTIONS] +``` + +## Configuration + +Create a `config.yaml` file to customize behavior: + +```yaml +parser: + include_patterns: + - "*.py" + - "*.js" + - "*.go" + - "*.rs" + exclude_patterns: + - "**/test_*.py" + - "**/node_modules/**" + - "**/.git/**" + +analysis: + complexity_threshold: 10 + +output: + default_format: json +``` + +## Output Formats + +### DOT +Graphviz DOT format for rendering with Graphviz tools. + +### JSON +Structured JSON output compatible with graph viewers and data processing. + +### PNG/SVG +Raster and vector image formats rendered using Graphviz. + +## Architecture + +``` +codebase-knowledge-graph-cli/ +├── src/ +│ ├── parsers/ # Language parsers (Python, JS, Go, Rust) +│ ├── graph/ # Graph building with NetworkX +│ ├── analyzers/ # Dependency and complexity analysis +│ ├── exporters/ # DOT, JSON, PNG export +│ └── cli/ # Click CLI interface +├── tests/ +│ ├── unit/ # Unit tests +│ └── integration/ # Integration tests +└── config.yaml # Configuration file +``` + +## Supported Languages + +- Python (.py, .pyi) +- JavaScript (.js, .jsx, .mjs, .cjs) +- Go (.go) +- Rust (.rs) + +## Environment Variables + +- `CODEGRAPH_LANGUAGE_PATH`: Path to tree-sitter language binaries +- `CODEGRAPH_OUTPUT_DIR`: Default output directory +- `CODEGRAPH_VERBOSE`: Enable verbose output + +## Contributing + +1. Fork the repository +2. Create a feature branch +3. Make your changes +4. Run tests: `pytest tests/ -v` +5. Submit a pull request + +## License + +MIT License