tree-sitter-analyzer 0.9.3__tar.gz → 0.9.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tree-sitter-analyzer might be problematic. Click here for more details.
- tree_sitter_analyzer-0.9.5/.kiro/steering/product.md +32 -0
- tree_sitter_analyzer-0.9.5/.kiro/steering/structure.md +197 -0
- tree_sitter_analyzer-0.9.5/.kiro/steering/tech.md +150 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/.pre-commit-config.yaml +23 -1
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/AI_COLLABORATION_GUIDE.md +18 -18
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/CHANGELOG.md +786 -731
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/CONTRIBUTING.md +60 -12
- tree_sitter_analyzer-0.9.5/DEPLOYMENT_GUIDE.md +207 -0
- tree_sitter_analyzer-0.9.5/LANGUAGE_GUIDELINES.md +160 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/MCP_SETUP_DEVELOPERS.md +325 -325
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/MCP_SETUP_USERS.md +206 -206
- tree_sitter_analyzer-0.9.5/PKG-INFO +567 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/PROJECT_ROOT_CONFIG.md +203 -203
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/PYPI_RELEASE_GUIDE.md +125 -125
- tree_sitter_analyzer-0.9.5/README.md +432 -0
- tree_sitter_analyzer-0.9.5/README_ja.md +432 -0
- tree_sitter_analyzer-0.9.5/README_zh.md +432 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/build_standalone.py +136 -136
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/docs/api.md +3 -3
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/project_root_demo.py +282 -247
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/security_demo.py +291 -282
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/security_integration_demo.py +222 -216
- tree_sitter_analyzer-0.9.5/pypirc_example.txt +29 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/pyproject.toml +1 -1
- tree_sitter_analyzer-0.9.5/scripts/improved_readme_updater.py +464 -0
- tree_sitter_analyzer-0.9.5/scripts/readme_config.py +133 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/start_mcp_server.py +124 -116
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/default_command.py +18 -18
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/partial_read_command.py +139 -141
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/query_command.py +92 -88
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/table_command.py +235 -235
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/info_commands.py +121 -121
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli_main.py +307 -307
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/core/analysis_engine.py +584 -584
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/core/cache_service.py +5 -4
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/core/query.py +502 -502
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/encoding_utils.py +9 -2
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/exceptions.py +400 -406
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/formatters/java_formatter.py +291 -291
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/formatters/python_formatter.py +259 -259
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/interfaces/mcp_server.py +426 -425
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/language_detector.py +398 -398
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/language_loader.py +224 -224
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/languages/java_plugin.py +1202 -1202
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/resources/project_stats_resource.py +559 -555
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/server.py +30 -9
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/read_partial_tool.py +21 -4
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/table_format_tool.py +22 -4
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/utils/error_handler.py +569 -567
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/models.py +470 -470
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/security/__init__.py +22 -22
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/security/boundary_manager.py +251 -243
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/security/regex_checker.py +297 -292
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/table_formatter.py +708 -652
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/utils.py +61 -19
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/upload_to_pypi.py +131 -24
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/uv.lock +1 -1
- tree_sitter_analyzer-0.9.3/DEPLOYMENT_GUIDE.md +0 -278
- tree_sitter_analyzer-0.9.3/PKG-INFO +0 -409
- tree_sitter_analyzer-0.9.3/README.md +0 -274
- tree_sitter_analyzer-0.9.3/README_ja.md +0 -255
- tree_sitter_analyzer-0.9.3/README_zh.md +0 -269
- tree_sitter_analyzer-0.9.3/UPLOAD_COMMANDS.md +0 -90
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/.gitignore +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/CODE_STYLE_GUIDE.md +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/LLM_CODING_GUIDELINES.md +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/check_quality.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/BigService.java +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/BigService.json +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/BigService.summary.json +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/JavaDocTest.java +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/MultiClass.java +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/Sample.java +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/calculate_token_comparison.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/examples/sample.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/llm_code_checker.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/pytest.ini +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/__main__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/api.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/__main__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/advanced_command.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/base_command.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/structure_command.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/cli/commands/summary_command.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/core/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/core/engine.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/core/parser.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/file_handler.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/formatters/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/formatters/base_formatter.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/formatters/formatter_factory.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/interfaces/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/interfaces/cli.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/interfaces/cli_adapter.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/interfaces/mcp_adapter.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/languages/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/languages/javascript_plugin.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/languages/python_plugin.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/resources/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/resources/code_file_resource.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/base_tool.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/mcp/utils/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/output_manager.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/plugins/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/plugins/base.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/plugins/manager.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/project_detector.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/queries/__init__.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/queries/java.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/queries/javascript.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/queries/python.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/queries/typescript.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/query_loader.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/tree_sitter_analyzer/security/validator.py +0 -0
- {tree_sitter_analyzer-0.9.3 → tree_sitter_analyzer-0.9.5}/upload_interactive.py +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Product Overview
|
|
2
|
+
|
|
3
|
+
## What is Tree-sitter Analyzer?
|
|
4
|
+
|
|
5
|
+
Tree-sitter Analyzer is a revolutionary code analysis tool designed specifically for the AI era. It solves the fundamental problem of LLM token limits when analyzing large code files.
|
|
6
|
+
|
|
7
|
+
## Core Value Proposition
|
|
8
|
+
|
|
9
|
+
**Problem**: Large code files (>10K lines) exceed LLM token limits, making AI-assisted code analysis impossible or inefficient.
|
|
10
|
+
|
|
11
|
+
**Solution**: Smart code analysis that provides:
|
|
12
|
+
- Code structure overview without reading entire files
|
|
13
|
+
- Precise line-range extraction of code sections
|
|
14
|
+
- Accurate positioning data for code operations
|
|
15
|
+
- Native AI assistant integration via MCP protocol
|
|
16
|
+
|
|
17
|
+
## Target Users
|
|
18
|
+
|
|
19
|
+
1. **AI Assistant Users**: Developers using Claude Desktop, Cursor, Roo Code, and other AI IDEs
|
|
20
|
+
2. **CLI Users**: Developers who prefer command-line tools for code analysis
|
|
21
|
+
3. **Enterprise Teams**: Organizations dealing with large codebases and AI-assisted development
|
|
22
|
+
|
|
23
|
+
## Key Features
|
|
24
|
+
|
|
25
|
+
- **Multi-language Support**: Java, Python, JavaScript/TypeScript (full), C/C++/Rust/Go (basic)
|
|
26
|
+
- **Three-step Workflow**: Scale check → Structure analysis → Code extraction
|
|
27
|
+
- **MCP Integration**: Native support for Model Context Protocol
|
|
28
|
+
- **Enterprise Quality**: 1,358 tests, 74.54% coverage, cross-platform compatibility
|
|
29
|
+
|
|
30
|
+
## Current Version
|
|
31
|
+
|
|
32
|
+
v0.9.4 - Latest stable release with comprehensive MCP support and enhanced security features.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Project Structure & Organization
|
|
2
|
+
|
|
3
|
+
## Root Directory Layout
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
tree-sitter-analyzer/
|
|
7
|
+
├── .git/ # Git repository
|
|
8
|
+
├── .github/ # GitHub workflows and templates
|
|
9
|
+
├── .kiro/ # Kiro IDE configuration and steering
|
|
10
|
+
├── tree_sitter_analyzer/ # Main package source code
|
|
11
|
+
├── tests/ # Comprehensive test suite
|
|
12
|
+
├── examples/ # Sample files for testing and demos
|
|
13
|
+
├── docs/ # Documentation
|
|
14
|
+
├── dist/ # Build artifacts (generated)
|
|
15
|
+
├── .venv/ # Virtual environment (generated)
|
|
16
|
+
└── Configuration files (see below)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Core Package Structure (`tree_sitter_analyzer/`)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
tree_sitter_analyzer/
|
|
23
|
+
├── __init__.py # Package initialization
|
|
24
|
+
├── __main__.py # Module entry point
|
|
25
|
+
├── api.py # Public API interface
|
|
26
|
+
├── cli_main.py # CLI entry point
|
|
27
|
+
├── models.py # Data models and types
|
|
28
|
+
├── utils.py # Utility functions
|
|
29
|
+
├── exceptions.py # Custom exception classes
|
|
30
|
+
├── encoding_utils.py # File encoding utilities
|
|
31
|
+
├── file_handler.py # File operations
|
|
32
|
+
├── language_detector.py # Language detection logic
|
|
33
|
+
├── language_loader.py # Tree-sitter language loading
|
|
34
|
+
├── output_manager.py # Output formatting and display
|
|
35
|
+
├── project_detector.py # Project root detection
|
|
36
|
+
├── query_loader.py # Query management
|
|
37
|
+
├── table_formatter.py # Table output formatting
|
|
38
|
+
├── core/ # Core analysis engine
|
|
39
|
+
├── cli/ # CLI command implementations
|
|
40
|
+
├── formatters/ # Output formatters
|
|
41
|
+
├── interfaces/ # Interface adapters (CLI, MCP)
|
|
42
|
+
├── languages/ # Language-specific plugins
|
|
43
|
+
├── mcp/ # MCP server implementation
|
|
44
|
+
├── plugins/ # Plugin system
|
|
45
|
+
├── queries/ # Tree-sitter queries
|
|
46
|
+
├── security/ # Security validation
|
|
47
|
+
└── validation/ # Input validation
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Key Subdirectories
|
|
51
|
+
|
|
52
|
+
### `core/` - Analysis Engine
|
|
53
|
+
- `analysis_engine.py` - Main analysis orchestration
|
|
54
|
+
- `query_engine.py` - Query execution engine
|
|
55
|
+
- Core business logic for code analysis
|
|
56
|
+
|
|
57
|
+
### `cli/` - Command Line Interface
|
|
58
|
+
- `commands.py` - CLI command implementations
|
|
59
|
+
- `parser.py` - Argument parsing
|
|
60
|
+
- Command-line specific logic
|
|
61
|
+
|
|
62
|
+
### `languages/` - Language Plugins
|
|
63
|
+
- `java_plugin.py` - Java language support
|
|
64
|
+
- `python_plugin.py` - Python language support
|
|
65
|
+
- `javascript_plugin.py` - JavaScript language support
|
|
66
|
+
- Language-specific analysis logic
|
|
67
|
+
|
|
68
|
+
### `mcp/` - Model Context Protocol
|
|
69
|
+
- `server.py` - MCP server implementation
|
|
70
|
+
- `tools.py` - MCP tool definitions
|
|
71
|
+
- AI assistant integration
|
|
72
|
+
|
|
73
|
+
### `security/` - Security Framework
|
|
74
|
+
- `boundary_manager.py` - Project boundary validation
|
|
75
|
+
- `validator.py` - Input validation and sanitization
|
|
76
|
+
- `regex_checker.py` - Safe regex pattern validation
|
|
77
|
+
|
|
78
|
+
## Test Structure (`tests/`)
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
tests/
|
|
82
|
+
├── conftest.py # Pytest configuration and fixtures
|
|
83
|
+
├── test_*.py # Unit tests (main level)
|
|
84
|
+
├── test_core/ # Core engine tests
|
|
85
|
+
├── test_interfaces/ # Interface adapter tests
|
|
86
|
+
├── test_languages/ # Language plugin tests
|
|
87
|
+
├── test_mcp/ # MCP server tests
|
|
88
|
+
├── test_plugins/ # Plugin system tests
|
|
89
|
+
├── test_security/ # Security framework tests
|
|
90
|
+
└── __pycache__/ # Compiled test files (generated)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Configuration Files
|
|
94
|
+
|
|
95
|
+
### Package Configuration
|
|
96
|
+
- `pyproject.toml` - Main package configuration, dependencies, build settings
|
|
97
|
+
- `uv.lock` - Dependency lock file
|
|
98
|
+
- `pytest.ini` - Test configuration
|
|
99
|
+
|
|
100
|
+
### Code Quality
|
|
101
|
+
- `.pre-commit-config.yaml` - Pre-commit hooks configuration
|
|
102
|
+
- Quality tools configured in `pyproject.toml`
|
|
103
|
+
|
|
104
|
+
### Documentation
|
|
105
|
+
- `README.md` - Main documentation (English)
|
|
106
|
+
- `README_zh.md` - Chinese documentation
|
|
107
|
+
- `README_ja.md` - Japanese documentation
|
|
108
|
+
- `CONTRIBUTING.md` - Contribution guidelines
|
|
109
|
+
- `CODE_STYLE_GUIDE.md` - Code style standards
|
|
110
|
+
- `CHANGELOG.md` - Version history
|
|
111
|
+
|
|
112
|
+
### Deployment & Release
|
|
113
|
+
- `DEPLOYMENT_GUIDE.md` - Deployment instructions
|
|
114
|
+
- `PYPI_RELEASE_GUIDE.md` - PyPI release process
|
|
115
|
+
- `upload_to_pypi.py` - Release automation script
|
|
116
|
+
- `build_standalone.py` - Standalone build script
|
|
117
|
+
|
|
118
|
+
## Examples Directory (`examples/`)
|
|
119
|
+
|
|
120
|
+
- `BigService.java` - Large Java service class (1419 lines, 66 methods) - main demo file
|
|
121
|
+
- `Sample.java` - Smaller Java example (178 lines, 8 classes)
|
|
122
|
+
- `MultiClass.java` - Multi-class Java example
|
|
123
|
+
- `sample.py` - Python example
|
|
124
|
+
- `*.json` - Analysis result examples
|
|
125
|
+
- Demo and testing files for various languages
|
|
126
|
+
|
|
127
|
+
## Naming Conventions
|
|
128
|
+
|
|
129
|
+
### Files and Directories
|
|
130
|
+
- **Snake case** for Python files: `analysis_engine.py`
|
|
131
|
+
- **Lowercase** for directories: `tree_sitter_analyzer/`
|
|
132
|
+
- **Descriptive names** that indicate purpose
|
|
133
|
+
|
|
134
|
+
### Code Organization
|
|
135
|
+
- **One class per file** when possible
|
|
136
|
+
- **Logical grouping** by functionality
|
|
137
|
+
- **Clear separation** between interfaces, core logic, and plugins
|
|
138
|
+
|
|
139
|
+
### Import Structure
|
|
140
|
+
```python
|
|
141
|
+
# Standard library imports
|
|
142
|
+
import os
|
|
143
|
+
from pathlib import Path
|
|
144
|
+
|
|
145
|
+
# Third-party imports
|
|
146
|
+
import tree_sitter
|
|
147
|
+
from typing import Dict, List
|
|
148
|
+
|
|
149
|
+
# Local imports
|
|
150
|
+
from .models import AnalysisResult
|
|
151
|
+
from .utils import log_info
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Plugin Architecture
|
|
155
|
+
|
|
156
|
+
### Language Plugins
|
|
157
|
+
- Each language has its own plugin file
|
|
158
|
+
- Plugins implement common interface
|
|
159
|
+
- Dynamic loading and registration
|
|
160
|
+
- Extensible for new languages
|
|
161
|
+
|
|
162
|
+
### Entry Points
|
|
163
|
+
- Defined in `pyproject.toml`
|
|
164
|
+
- Automatic plugin discovery
|
|
165
|
+
- Support for external plugins
|
|
166
|
+
|
|
167
|
+
## Security Boundaries
|
|
168
|
+
|
|
169
|
+
### Project Root Detection
|
|
170
|
+
- Automatic detection from `.git`, `pyproject.toml`, etc.
|
|
171
|
+
- Configurable via CLI `--project-root`
|
|
172
|
+
- Environment variable `TREE_SITTER_PROJECT_ROOT`
|
|
173
|
+
|
|
174
|
+
### File Access Control
|
|
175
|
+
- All file operations validated against project boundaries
|
|
176
|
+
- Path traversal attack prevention
|
|
177
|
+
- Symlink safety checks
|
|
178
|
+
|
|
179
|
+
## Build Artifacts (Generated)
|
|
180
|
+
|
|
181
|
+
### Distribution
|
|
182
|
+
- `dist/` - Wheel and source distributions
|
|
183
|
+
- Built via `uv build`
|
|
184
|
+
|
|
185
|
+
### Cache Directories
|
|
186
|
+
- `.mypy_cache/` - MyPy type checking cache
|
|
187
|
+
- `.pytest_cache/` - Pytest execution cache
|
|
188
|
+
- `.ruff_cache/` - Ruff linting cache
|
|
189
|
+
- `__pycache__/` - Python bytecode cache
|
|
190
|
+
|
|
191
|
+
## Development Workflow
|
|
192
|
+
|
|
193
|
+
1. **Setup**: `uv sync --extra all --extra mcp`
|
|
194
|
+
2. **Code**: Follow structure and naming conventions
|
|
195
|
+
3. **Test**: Add tests in appropriate `test_*/` directories
|
|
196
|
+
4. **Quality**: Run `uv run python check_quality.py --new-code-only --fix`
|
|
197
|
+
5. **Commit**: Pre-commit hooks ensure quality
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Technology Stack & Build System
|
|
2
|
+
|
|
3
|
+
## Build System & Package Management
|
|
4
|
+
|
|
5
|
+
- **Primary**: `uv` (fast Python package manager) - used for all development and user installations
|
|
6
|
+
- **Build Backend**: `hatchling` (modern Python build system)
|
|
7
|
+
- **Package Distribution**: PyPI with multiple installation options
|
|
8
|
+
|
|
9
|
+
## Core Technology Stack
|
|
10
|
+
|
|
11
|
+
### Language & Runtime
|
|
12
|
+
- **Python**: 3.10+ (required minimum)
|
|
13
|
+
- **Tree-sitter**: v0.24.0 (core parsing engine)
|
|
14
|
+
- **Async Support**: `asyncio` for MCP server operations
|
|
15
|
+
|
|
16
|
+
### Key Dependencies
|
|
17
|
+
- **MCP**: v1.12.3+ (Model Context Protocol for AI integration)
|
|
18
|
+
- **Character Detection**: `chardet` v5.0.0+ (encoding detection)
|
|
19
|
+
- **Caching**: `cachetools` v5.0.0+ (performance optimization)
|
|
20
|
+
|
|
21
|
+
### Language Parsers
|
|
22
|
+
- `tree-sitter-java` v0.23.5+
|
|
23
|
+
- `tree-sitter-python` v0.23.6+
|
|
24
|
+
- `tree-sitter-javascript` v0.23.1+
|
|
25
|
+
- `tree-sitter-typescript` v0.20.0+
|
|
26
|
+
- `tree-sitter-cpp` v0.23.4+
|
|
27
|
+
- Additional parsers for C, Rust, Go
|
|
28
|
+
|
|
29
|
+
## Development Tools
|
|
30
|
+
|
|
31
|
+
### Code Quality
|
|
32
|
+
- **Formatter**: Black (88 character line length)
|
|
33
|
+
- **Linter**: Ruff (fast Python linter)
|
|
34
|
+
- **Type Checker**: MyPy (with strict configuration)
|
|
35
|
+
- **Import Sorting**: isort (Black-compatible)
|
|
36
|
+
|
|
37
|
+
### Testing Framework
|
|
38
|
+
- **Test Runner**: pytest v8.4.1+
|
|
39
|
+
- **Coverage**: pytest-cov v4.0.0+
|
|
40
|
+
- **Async Testing**: pytest-asyncio v1.1.0+
|
|
41
|
+
- **Mocking**: pytest-mock v3.14.1+
|
|
42
|
+
|
|
43
|
+
### Pre-commit Hooks
|
|
44
|
+
- **Setup**: `pre-commit` v3.0.0+
|
|
45
|
+
- **Hooks**: Black, Ruff, MyPy integration
|
|
46
|
+
|
|
47
|
+
## Common Commands
|
|
48
|
+
|
|
49
|
+
### Development Setup
|
|
50
|
+
```bash
|
|
51
|
+
# Clone and setup development environment
|
|
52
|
+
git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
|
|
53
|
+
cd tree-sitter-analyzer
|
|
54
|
+
uv sync --extra all --extra mcp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Testing
|
|
58
|
+
```bash
|
|
59
|
+
# Run all tests (1,358 tests)
|
|
60
|
+
uv run pytest tests/ -v
|
|
61
|
+
|
|
62
|
+
# Run with coverage report
|
|
63
|
+
uv run pytest tests/ --cov=tree_sitter_analyzer --cov-report=html
|
|
64
|
+
|
|
65
|
+
# Run specific test categories
|
|
66
|
+
uv run pytest tests/test_mcp_server_initialization.py -v
|
|
67
|
+
uv run pytest tests/test_formatters_comprehensive.py -v
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Code Quality Checks
|
|
71
|
+
```bash
|
|
72
|
+
# Format code
|
|
73
|
+
uv run black .
|
|
74
|
+
|
|
75
|
+
# Check formatting
|
|
76
|
+
uv run black --check .
|
|
77
|
+
|
|
78
|
+
# Lint code
|
|
79
|
+
uv run ruff check .
|
|
80
|
+
|
|
81
|
+
# Auto-fix safe issues
|
|
82
|
+
uv run ruff check . --fix
|
|
83
|
+
|
|
84
|
+
# Type checking
|
|
85
|
+
uv run mypy .
|
|
86
|
+
|
|
87
|
+
# Run all quality checks
|
|
88
|
+
uv run python check_quality.py
|
|
89
|
+
|
|
90
|
+
# Auto-fix and check (recommended for new contributors)
|
|
91
|
+
uv run python check_quality.py --new-code-only --fix
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Building & Distribution
|
|
95
|
+
```bash
|
|
96
|
+
# Build package
|
|
97
|
+
uv build
|
|
98
|
+
|
|
99
|
+
# Upload to PyPI (maintainers only)
|
|
100
|
+
uv run python upload_to_pypi.py
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### CLI Usage
|
|
104
|
+
```bash
|
|
105
|
+
# Basic analysis (large file demo)
|
|
106
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
|
|
107
|
+
|
|
108
|
+
# Structure analysis (66 methods clearly displayed)
|
|
109
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
|
|
110
|
+
|
|
111
|
+
# Partial reading (extract specific code section)
|
|
112
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --start-line 100 --end-line 105
|
|
113
|
+
|
|
114
|
+
# Quiet mode
|
|
115
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full --quiet
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### MCP Server
|
|
119
|
+
```bash
|
|
120
|
+
# Start MCP server (development)
|
|
121
|
+
uv run python -m tree_sitter_analyzer.mcp.server
|
|
122
|
+
|
|
123
|
+
# Start with project root
|
|
124
|
+
TREE_SITTER_PROJECT_ROOT=/path/to/project uv run python -m tree_sitter_analyzer.mcp.server
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Installation Options
|
|
128
|
+
|
|
129
|
+
### End Users
|
|
130
|
+
```bash
|
|
131
|
+
# Basic installation
|
|
132
|
+
uv add tree-sitter-analyzer
|
|
133
|
+
|
|
134
|
+
# Popular languages (Java, Python, JS, TS)
|
|
135
|
+
uv add "tree-sitter-analyzer[popular]"
|
|
136
|
+
|
|
137
|
+
# With MCP server support
|
|
138
|
+
uv add "tree-sitter-analyzer[mcp]"
|
|
139
|
+
|
|
140
|
+
# Full installation
|
|
141
|
+
uv add "tree-sitter-analyzer[all,mcp]"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Architecture Notes
|
|
145
|
+
|
|
146
|
+
- **Plugin System**: Dynamic plugin architecture for language support
|
|
147
|
+
- **Caching**: Multi-level caching for parsers and analysis results
|
|
148
|
+
- **Security**: Project boundary validation and input sanitization
|
|
149
|
+
- **Performance**: Optimized for large file handling with minimal memory usage
|
|
150
|
+
- **Cross-platform**: Windows, macOS, Linux compatibility
|
|
@@ -80,11 +80,33 @@ repos:
|
|
|
80
80
|
hooks:
|
|
81
81
|
- id: quality-check
|
|
82
82
|
name: Tree-sitter Analyzer Quality Check
|
|
83
|
-
entry: python check_quality.py --new-code-only
|
|
83
|
+
entry: uv run python check_quality.py --new-code-only
|
|
84
84
|
language: system
|
|
85
85
|
pass_filenames: false
|
|
86
86
|
stages: [pre-push] # Only run on push
|
|
87
87
|
|
|
88
|
+
# README stats update (improved version)
|
|
89
|
+
- repo: local
|
|
90
|
+
hooks:
|
|
91
|
+
- id: update-readme-stats
|
|
92
|
+
name: Update README Statistics
|
|
93
|
+
entry: uv run python scripts/improved_readme_updater.py
|
|
94
|
+
language: system
|
|
95
|
+
pass_filenames: false
|
|
96
|
+
stages: [pre-push] # Only run on push
|
|
97
|
+
files: ^(README.*\.md|pyproject\.toml|examples/.*\.java)$
|
|
98
|
+
|
|
99
|
+
# README stats validation
|
|
100
|
+
- repo: local
|
|
101
|
+
hooks:
|
|
102
|
+
- id: validate-readme-stats
|
|
103
|
+
name: Validate README Statistics
|
|
104
|
+
entry: uv run python scripts/improved_readme_updater.py --validate-only
|
|
105
|
+
language: system
|
|
106
|
+
pass_filenames: false
|
|
107
|
+
stages: [pre-commit] # Run on every commit
|
|
108
|
+
files: ^README.*\.md$
|
|
109
|
+
|
|
88
110
|
# Configuration
|
|
89
111
|
default_stages: [pre-commit]
|
|
90
112
|
fail_fast: false
|
|
@@ -10,10 +10,10 @@ Before generating any code, AI systems should run these commands to understand t
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# 1. Check current code quality
|
|
13
|
-
python check_quality.py --new-code-only
|
|
13
|
+
uv run python check_quality.py --new-code-only
|
|
14
14
|
|
|
15
15
|
# 2. Run LLM-specific code checker
|
|
16
|
-
python llm_code_checker.py --check-all
|
|
16
|
+
uv run python llm_code_checker.py --check-all
|
|
17
17
|
|
|
18
18
|
# 3. Review test coverage
|
|
19
19
|
uv run pytest tests/ --cov=tree_sitter_analyzer --cov-report=term-missing
|
|
@@ -48,10 +48,10 @@ find tree_sitter_analyzer -name "*.py" | head -20
|
|
|
48
48
|
uv run pytest tests/ -v
|
|
49
49
|
|
|
50
50
|
# LLM-specific checks
|
|
51
|
-
python llm_code_checker.py [new_file.py]
|
|
51
|
+
uv run python llm_code_checker.py [new_file.py]
|
|
52
52
|
|
|
53
53
|
# Final quality check
|
|
54
|
-
python check_quality.py
|
|
54
|
+
uv run python check_quality.py
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### Mandatory Patterns
|
|
@@ -96,7 +96,7 @@ def analyze_code(file_path: str, options: Optional[Dict[str, Any]] = None) -> An
|
|
|
96
96
|
|
|
97
97
|
AI-generated code MUST pass all these checks:
|
|
98
98
|
|
|
99
|
-
- [ ] ✅ `python llm_code_checker.py [file]` - No issues
|
|
99
|
+
- [ ] ✅ `uv run python llm_code_checker.py [file]` - No issues
|
|
100
100
|
- [ ] ✅ `uv run black --check .` - Properly formatted
|
|
101
101
|
- [ ] ✅ `uv run ruff check .` - No linting errors
|
|
102
102
|
- [ ] ✅ `uv run mypy tree_sitter_analyzer/` - Type checks pass
|
|
@@ -115,10 +115,10 @@ When reviewing AI-generated code:
|
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
117
|
# Quick quality check
|
|
118
|
-
python llm_code_checker.py path/to/ai_generated_file.py
|
|
118
|
+
uv run python llm_code_checker.py path/to/ai_generated_file.py
|
|
119
119
|
|
|
120
120
|
# Comprehensive review
|
|
121
|
-
python check_quality.py --new-code-only
|
|
121
|
+
uv run python check_quality.py --new-code-only
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
#### 2. Common AI Code Issues
|
|
@@ -135,16 +135,16 @@ Watch out for these common problems:
|
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
137
|
# 1. Run AI code checker
|
|
138
|
-
python llm_code_checker.py ai_generated_file.py
|
|
138
|
+
uv run python llm_code_checker.py ai_generated_file.py
|
|
139
139
|
|
|
140
140
|
# 2. Fix identified issues
|
|
141
141
|
# [Manual fixes based on checker output]
|
|
142
142
|
|
|
143
143
|
# 3. Verify fixes
|
|
144
|
-
python llm_code_checker.py ai_generated_file.py
|
|
144
|
+
uv run python llm_code_checker.py ai_generated_file.py
|
|
145
145
|
|
|
146
146
|
# 4. Run full quality check
|
|
147
|
-
python check_quality.py
|
|
147
|
+
uv run python check_quality.py
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
### Requesting AI Assistance
|
|
@@ -183,16 +183,16 @@ Always provide:
|
|
|
183
183
|
|
|
184
184
|
```bash
|
|
185
185
|
# Check specific AI-generated file
|
|
186
|
-
python llm_code_checker.py tree_sitter_analyzer/new_feature.py
|
|
186
|
+
uv run python llm_code_checker.py tree_sitter_analyzer/new_feature.py
|
|
187
187
|
|
|
188
188
|
# Check all files for AI-specific issues
|
|
189
|
-
python llm_code_checker.py --check-all
|
|
189
|
+
uv run python llm_code_checker.py --check-all
|
|
190
190
|
|
|
191
191
|
# Run comprehensive quality check
|
|
192
|
-
python check_quality.py
|
|
192
|
+
uv run python check_quality.py
|
|
193
193
|
|
|
194
194
|
# Check only new/modified code
|
|
195
|
-
python check_quality.py --new-code-only
|
|
195
|
+
uv run python check_quality.py --new-code-only
|
|
196
196
|
|
|
197
197
|
# Auto-fix common issues
|
|
198
198
|
uv run black . && uv run isort . && uv run ruff check . --fix
|
|
@@ -206,11 +206,11 @@ AI-generated code should achieve:
|
|
|
206
206
|
|
|
207
207
|
| Metric | Target | Command |
|
|
208
208
|
|--------|--------|---------|
|
|
209
|
-
| Test Coverage | ≥90% | `pytest --cov=tree_sitter_analyzer` |
|
|
210
|
-
| Type Coverage | 100% | `mypy tree_sitter_analyzer/` |
|
|
211
|
-
| Linting Score | 0 errors | `ruff check .` |
|
|
209
|
+
| Test Coverage | ≥90% | `uv run pytest --cov=tree_sitter_analyzer` |
|
|
210
|
+
| Type Coverage | 100% | `uv run mypy tree_sitter_analyzer/` |
|
|
211
|
+
| Linting Score | 0 errors | `uv run ruff check .` |
|
|
212
212
|
| Security Score | 0 issues | `bandit -r tree_sitter_analyzer/` |
|
|
213
|
-
| Documentation | 100% public APIs | `llm_code_checker.py` |
|
|
213
|
+
| Documentation | 100% public APIs | `uv run python llm_code_checker.py` |
|
|
214
214
|
|
|
215
215
|
### Performance Benchmarks
|
|
216
216
|
|