# collet-treemap

Tree-sitter based repository code map generator.

Analyze repository structure and generate code maps in JSON or text format.

## Features

- 🌳 Repository structure analysis using tree-sitter
- 📊 Generate code maps with file and symbol information
- 🗣️ Multi-language support (Rust, Python, JavaScript)
- 📤 Multiple output formats (JSON, plain text)
- 🔧 Both CLI and library interfaces

## Installation

```bash
cargo add collet-treemap
```

## CLI Usage

```bash
# Generate JSON code map for current directory
collet-treemap . --format json

# Analyze only Rust files
collet-treemap . --lang rust

# Generate text report
collet-treemap . --format text

# Custom output with options
collet-treemap /path/to/repo --format json --lang python --max-depth 5
```

## Library Usage

```rust
use collet_treemap::{generate_map, Config, Language};
use std::path::Path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config {
        language: Some(Language::Rust),
        ..Default::default()
    };

    let map = generate_map(Path::new("."), config)?;
    println!("Found {} files", map.files.len());

    Ok(())
}
```

## Output Example

JSON output includes:
```json
{
  "root": "/path/to/repo",
  "files": [
    {
      "path": "src/main.rs",
      "language": "rust",
      "lines": 245
    }
  ],
  "summary": {
    "total_files": 12,
    "total_symbols": 45
  }
}
```

## Supported Languages

- **Rust** - `.rs` files
- **Python** - `.py` files
- **JavaScript** - `.js`, `.jsx`, `.ts`, `.tsx` files

## Options

- `--format <FORMAT>` - Output format: `json` or `text` (default: json)
- `--lang <LANGUAGE>` - Filter by language: `rust`, `python`, `js`
- `--max-depth <DEPTH>` - Maximum directory traversal depth (default: 10)

## License

Apache-2.0
