Metadata-Version: 2.4
Name: tree-sitter-analyzer
Version: 0.8.0
Summary: Extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture
Project-URL: Homepage, https://github.com/aimasteracc/tree-sitter-analyzer
Project-URL: Documentation, https://github.com/aimasteracc/tree-sitter-analyzer#readme
Project-URL: Repository, https://github.com/aimasteracc/tree-sitter-analyzer.git
Project-URL: Issues, https://github.com/aimasteracc/tree-sitter-analyzer/issues
Project-URL: Changelog, https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CHANGELOG.md
Project-URL: Bug Reports, https://github.com/aimasteracc/tree-sitter-analyzer/issues
Project-URL: Source Code, https://github.com/aimasteracc/tree-sitter-analyzer
Author-email: "aisheng.yu" <aimasteracc@gmail.com>
Maintainer-email: "aisheng.yu" <aimasteracc@gmail.com>
License: MIT
Keywords: ai-tools,ast,code-analysis,mcp,mcp-server,model-context-protocol,multi-language,parsing,static-analysis,tree-sitter
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Communications
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: cachetools>=5.0.0
Requires-Dist: chardet>=5.0.0
Requires-Dist: mcp>=1.12.3
Requires-Dist: tree-sitter-cpp>=0.23.4
Requires-Dist: tree-sitter-java>=0.23.5
Requires-Dist: tree-sitter-javascript>=0.23.1
Requires-Dist: tree-sitter-python>=0.23.6
Requires-Dist: tree-sitter==0.24.0
Provides-Extra: all-languages
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'all-languages'
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'all-languages'
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'all-languages'
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'all-languages'
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'all-languages'
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'all-languages'
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'all-languages'
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'all-languages'
Provides-Extra: c
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'c'
Provides-Extra: cpp
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'cpp'
Provides-Extra: dev
Requires-Dist: black>=24.0.0; extra == 'dev'
Requires-Dist: isort>=5.13.0; extra == 'dev'
Requires-Dist: memory-profiler>=0.61.0; extra == 'dev'
Requires-Dist: mypy>=1.17.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: psutil>=7.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
Requires-Dist: pytest>=8.4.1; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Requires-Dist: types-psutil>=5.9.0; extra == 'dev'
Provides-Extra: full
Requires-Dist: anyio>=4.9.0; extra == 'full'
Requires-Dist: black>=24.0.0; extra == 'full'
Requires-Dist: httpx>=0.28.1; extra == 'full'
Requires-Dist: isort>=5.13.0; extra == 'full'
Requires-Dist: mcp>=1.12.2; extra == 'full'
Requires-Dist: memory-profiler>=0.61.0; extra == 'full'
Requires-Dist: mypy>=1.17.0; extra == 'full'
Requires-Dist: pre-commit>=3.0.0; extra == 'full'
Requires-Dist: psutil>=7.0.0; extra == 'full'
Requires-Dist: pydantic-settings>=2.10.1; extra == 'full'
Requires-Dist: pydantic>=2.11.7; extra == 'full'
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'full'
Requires-Dist: pytest-cov>=4.0.0; extra == 'full'
Requires-Dist: pytest-mock>=3.14.1; extra == 'full'
Requires-Dist: pytest>=8.4.1; extra == 'full'
Requires-Dist: ruff>=0.1.0; extra == 'full'
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'full'
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'full'
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'full'
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'full'
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'full'
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'full'
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'full'
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'full'
Requires-Dist: types-psutil>=5.9.0; extra == 'full'
Provides-Extra: go
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'go'
Provides-Extra: java
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'java'
Provides-Extra: javascript
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'javascript'
Provides-Extra: mcp
Requires-Dist: anyio>=4.9.0; extra == 'mcp'
Requires-Dist: httpx>=0.28.1; extra == 'mcp'
Requires-Dist: mcp>=1.12.2; extra == 'mcp'
Requires-Dist: pydantic-settings>=2.10.1; extra == 'mcp'
Requires-Dist: pydantic>=2.11.7; extra == 'mcp'
Provides-Extra: popular
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'popular'
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'popular'
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'popular'
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'popular'
Provides-Extra: python
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'python'
Provides-Extra: rust
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'rust'
Provides-Extra: systems
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'systems'
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'systems'
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'systems'
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'systems'
Provides-Extra: test
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'test'
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
Requires-Dist: pytest-mock>=3.14.1; extra == 'test'
Requires-Dist: pytest>=8.4.1; extra == 'test'
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'test'
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'test'
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'test'
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'test'
Provides-Extra: typescript
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'typescript'
Provides-Extra: web
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'web'
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'web'
Description-Content-Type: text/markdown

# Tree-sitter Analyzer

[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Tests](https://img.shields.io/badge/tests-1126%20passed-brightgreen.svg)](#testing)

**Solve the LLM token limit problem for large code files.**

An extensible multi-language code analyzer that helps AI assistants understand code structure without reading entire files. Get code overview, extract specific sections, and analyze complexity - all optimized for LLM workflows.

## ✨ Why Tree-sitter Analyzer?

**The Problem:** Large code files exceed LLM token limits, making code analysis inefficient or impossible.

**The Solution:** Smart code analysis that provides:
- 📊 **Code overview** without reading complete files
- 🎯 **Targeted extraction** of specific line ranges  
- 📍 **Precise positioning** for accurate code operations
- 🤖 **AI assistant integration** via MCP protocol

## 🚀 Quick Start (5 minutes)

### For AI Assistant Users (Claude Desktop)

1. **Install the package:**
```bash
# Install uv (fast Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh  # macOS/Linux
# or: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"  # Windows

# No need to install the package separately - uv handles it
```

2. **Configure Claude Desktop:**

Add to your Claude Desktop config file:

**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Linux:** `~/.config/claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "tree-sitter-analyzer": {
      "command": "uv",
      "args": [
        "run", 
        "--with", 
        "tree-sitter-analyzer[mcp]",
        "python", 
        "-m", 
        "tree_sitter_analyzer.mcp.server"
      ]
    }
  }
}
```

3. **Restart Claude Desktop** and start analyzing code!

### For CLI Users

```bash
# Install with uv (recommended)
uv add "tree-sitter-analyzer[popular]"

# Step 1: Check file scale
uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --output-format=text

# Step 2: Analyze structure (for large files)
uv run python -m tree_sitter_analyzer examples/Sample.java --table=full

# Step 3: Extract specific lines
uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
```

## 🛠️ Core Features

### 1. Code Structure Analysis
Get comprehensive overview without reading entire files:
- Classes, methods, fields count
- Package information
- Import dependencies
- Complexity metrics

### 2. Targeted Code Extraction
Extract specific code sections efficiently:
- Line range extraction
- Precise positioning data
- Content length information

### 3. AI Assistant Integration
Four powerful MCP tools for AI assistants:
- `analyze_code_scale` - Get code metrics and complexity
- `analyze_code_structure` - Generate detailed structure tables
- `read_code_partial` - Extract specific line ranges
- `analyze_code_universal` - Universal analysis with auto-detection

### 4. Multi-Language Support
- **Java** - Full support with advanced analysis
- **Python** - Complete support
- **JavaScript/TypeScript** - Full support
- **C/C++, Rust, Go** - Basic support

## 📖 Usage Examples

### AI Assistant Usage (via Claude Desktop)

**Step 1: Get code overview:**
> "What's the overall complexity and size of this Java file examples/Sample.java?"

**Step 2: Analyze code structure (for large files):**
> "Please analyze the structure of examples/Sample.java and show me a detailed table"

**Step 3: Extract specific code:**
> "Show me lines 84-86 from examples/Sample.java"

### CLI Usage

**Step 1: Basic analysis (Check file scale):**
```bash
uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --output-format=text
```

**Step 2: Structure analysis (For large files that exceed LLM limits):**
```bash
uv run python -m tree_sitter_analyzer examples/Sample.java --table=full
```

**Step 3: Targeted extraction (Read specific code sections):**
```bash
uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
```

**Additional Options:**
```bash
# Quiet mode (suppress INFO messages, show only errors)
uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --output-format=text --quiet

# Table output with quiet mode
uv run python -m tree_sitter_analyzer examples/Sample.java --table=full --quiet
```

## 🔧 Installation Options

### For End Users
```bash
# Basic installation
uv add tree-sitter-analyzer

# With popular languages (Java, Python, JS, TS)
uv add "tree-sitter-analyzer[popular]"

# With MCP server support
uv add "tree-sitter-analyzer[mcp]"

# Full installation
uv add "tree-sitter-analyzer[all,mcp]"
```

### For Developers
```bash
# Clone and install for development
git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
cd tree-sitter-analyzer
uv sync --extra all --extra mcp
```

## 📚 Documentation

- **[MCP Setup Guide for Users](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
- **[MCP Setup Guide for Developers](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_DEVELOPERS.md)** - Local development configuration
- **[API Documentation](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/docs/api.md)** - Detailed API reference
- **[Contributing Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CONTRIBUTING.md)** - How to contribute

## 🧪 Testing

This project maintains high code quality with **1126 passing tests**.

```bash
# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=tree_sitter_analyzer
```

## 📄 License

MIT License - see [LICENSE](LICENSE) file for details.

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CONTRIBUTING.md) for details.

### 🤖 AI/LLM Collaboration

This project supports AI-assisted development with specialized quality controls:

```bash
# For AI systems - run before generating code
python check_quality.py --new-code-only
python llm_code_checker.py --check-all

# For AI-generated code review
python llm_code_checker.py path/to/new_file.py
```

📖 **See our [AI Collaboration Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/AI_COLLABORATION_GUIDE.md) and [LLM Coding Guidelines](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/LLM_CODING_GUIDELINES.md) for detailed instructions on working with AI systems.**

---

**Made with ❤️ for developers who work with large codebases and AI assistants.**
