tree-sitter-analyzer 0.8.0__tar.gz → 0.8.1__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.8.0 → tree_sitter_analyzer-0.8.1}/CHANGELOG.md +22 -0
- tree_sitter_analyzer-0.8.1/MCP_SETUP_DEVELOPERS.md +325 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/MCP_SETUP_USERS.md +48 -5
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/PKG-INFO +24 -1
- tree_sitter_analyzer-0.8.1/PROJECT_ROOT_CONFIG.md +203 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/README.md +23 -0
- tree_sitter_analyzer-0.8.1/examples/project_root_demo.py +247 -0
- tree_sitter_analyzer-0.8.1/examples/security_integration_demo.py +216 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/pyproject.toml +1 -1
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/base_command.py +27 -9
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/default_command.py +1 -1
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/partial_read_command.py +7 -7
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/query_command.py +11 -4
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/table_command.py +1 -1
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/info_commands.py +2 -2
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli_main.py +13 -7
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/core/analysis_engine.py +38 -13
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/server.py +74 -12
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +22 -3
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/read_partial_tool.py +10 -2
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/table_format_tool.py +20 -3
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +18 -2
- tree_sitter_analyzer-0.8.1/tree_sitter_analyzer/project_detector.py +317 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/security/validator.py +24 -7
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/uv.lock +1 -1
- tree_sitter_analyzer-0.8.0/MCP_SETUP_DEVELOPERS.md +0 -181
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/.gitignore +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/.pre-commit-config.yaml +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/AI_COLLABORATION_GUIDE.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/CODE_STYLE_GUIDE.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/CONTRIBUTING.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/DEPLOYMENT_GUIDE.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/LLM_CODING_GUIDELINES.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/README_ja.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/README_zh.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/build_standalone.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/check_quality.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/docs/api.md +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/BigService.java +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/BigService.json +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/BigService.summary.json +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/JavaDocTest.java +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/MultiClass.java +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/Sample.java +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/calculate_token_comparison.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/sample.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/examples/security_demo.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/llm_code_checker.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/pytest.ini +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/__main__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/api.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/__main__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/advanced_command.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/structure_command.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/cli/commands/summary_command.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/core/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/core/cache_service.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/core/engine.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/core/parser.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/core/query.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/encoding_utils.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/exceptions.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/file_handler.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/formatters/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/formatters/base_formatter.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/formatters/formatter_factory.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/formatters/java_formatter.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/formatters/python_formatter.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/interfaces/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/interfaces/cli.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/interfaces/cli_adapter.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/interfaces/mcp_adapter.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/interfaces/mcp_server.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/language_detector.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/language_loader.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/languages/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/languages/java_plugin.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/languages/javascript_plugin.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/languages/python_plugin.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/resources/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/resources/code_file_resource.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/resources/project_stats_resource.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/tools/base_tool.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/utils/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/mcp/utils/error_handler.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/models.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/output_manager.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/plugins/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/plugins/base.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/plugins/manager.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/queries/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/queries/java.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/queries/javascript.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/queries/python.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/queries/typescript.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/query_loader.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/security/__init__.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/security/boundary_manager.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/security/regex_checker.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/table_formatter.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/tree_sitter_analyzer/utils.py +0 -0
- {tree_sitter_analyzer-0.8.0 → tree_sitter_analyzer-0.8.1}/upload_to_pypi.py +0 -0
|
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.1] - 2025-08-05
|
|
9
|
+
|
|
10
|
+
### 🔧 Fixed
|
|
11
|
+
- **Fixed**: Eliminated duplicate "ERROR:" prefixes in error messages across all CLI commands
|
|
12
|
+
- **Fixed**: Updated all CLI tests to match unified error message format
|
|
13
|
+
- **Fixed**: Resolved missing `--project-root` parameters in comprehensive CLI tests
|
|
14
|
+
- **Fixed**: Corrected module import issues in language detection tests
|
|
15
|
+
- **Fixed**: Updated test expectations to match security validation behavior
|
|
16
|
+
|
|
17
|
+
### 🧪 Testing Improvements
|
|
18
|
+
- **Enhanced**: Fixed 6 failing tests in `test_partial_read_command_validation.py`
|
|
19
|
+
- **Enhanced**: Fixed 6 failing tests in `test_cli_comprehensive.py` and Java structure analyzer tests
|
|
20
|
+
- **Enhanced**: Improved test stability and reliability across all CLI functionality
|
|
21
|
+
- **Enhanced**: Unified error message testing with consistent format expectations
|
|
22
|
+
|
|
23
|
+
### 📦 Code Quality
|
|
24
|
+
- **Improved**: Centralized error message formatting in `output_manager.py`
|
|
25
|
+
- **Improved**: Consistent error handling architecture across all CLI commands
|
|
26
|
+
- **Improved**: Better separation of concerns between error content and formatting
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
8
30
|
## [0.8.0] - 2025-08-04
|
|
9
31
|
|
|
10
32
|
### 🚀 Added
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# MCP Setup Guide for Developers
|
|
2
|
+
|
|
3
|
+
**Local development setup for Tree-sitter Analyzer MCP server**
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Python 3.10+
|
|
8
|
+
- uv package manager
|
|
9
|
+
- Git
|
|
10
|
+
- Claude Desktop (for testing)
|
|
11
|
+
|
|
12
|
+
## Development Setup
|
|
13
|
+
|
|
14
|
+
### 1. Clone and Setup Project
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Clone the repository
|
|
18
|
+
git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
|
|
19
|
+
cd tree-sitter-analyzer
|
|
20
|
+
|
|
21
|
+
# Install development dependencies
|
|
22
|
+
uv sync --extra all --extra mcp
|
|
23
|
+
|
|
24
|
+
# Verify installation
|
|
25
|
+
uv run python -c "import tree_sitter_analyzer; print('Development setup OK')"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Configure Claude Desktop for Local Development
|
|
29
|
+
|
|
30
|
+
#### Recommended Development Configuration
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"tree-sitter-analyzer-dev": {
|
|
36
|
+
"command": "uv",
|
|
37
|
+
"args": [
|
|
38
|
+
"run",
|
|
39
|
+
"--directory",
|
|
40
|
+
"/absolute/path/to/tree-sitter-analyzer",
|
|
41
|
+
"python",
|
|
42
|
+
"-m",
|
|
43
|
+
"tree_sitter_analyzer.mcp.server"
|
|
44
|
+
],
|
|
45
|
+
"env": {
|
|
46
|
+
"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Important:** Replace `/absolute/path/to/tree-sitter-analyzer` with your actual project path.
|
|
54
|
+
|
|
55
|
+
## Project Root Configuration Options
|
|
56
|
+
|
|
57
|
+
The MCP server supports multiple ways to configure the project root directory for security and functionality:
|
|
58
|
+
|
|
59
|
+
### Configuration Priority (Highest to Lowest)
|
|
60
|
+
|
|
61
|
+
1. **Command Line Argument** (Highest Priority)
|
|
62
|
+
2. **Environment Variable** (Medium Priority)
|
|
63
|
+
3. **Auto-Detection** (Lowest Priority)
|
|
64
|
+
|
|
65
|
+
### Option 1: Environment Variable (Recommended)
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"tree-sitter-analyzer-dev": {
|
|
71
|
+
"command": "uv",
|
|
72
|
+
"args": ["run", "--directory", "/path/to/tree-sitter-analyzer", "python", "-m", "tree_sitter_analyzer.mcp.server"],
|
|
73
|
+
"env": {
|
|
74
|
+
"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Benefits:**
|
|
82
|
+
- ✅ Automatically adapts to current workspace
|
|
83
|
+
- ✅ Works with any IDE supporting workspace variables
|
|
84
|
+
- ✅ Flexible and dynamic configuration
|
|
85
|
+
|
|
86
|
+
### Option 2: Command Line Argument
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"tree-sitter-analyzer-dev": {
|
|
92
|
+
"command": "uv",
|
|
93
|
+
"args": [
|
|
94
|
+
"run", "--directory", "/path/to/tree-sitter-analyzer",
|
|
95
|
+
"python", "-m", "tree_sitter_analyzer.mcp.server",
|
|
96
|
+
"--project-root", "/specific/project/path"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Use cases:**
|
|
104
|
+
- 🎯 Fixed project path requirements
|
|
105
|
+
- 🎯 Override environment variable settings
|
|
106
|
+
- 🎯 Multi-project environments
|
|
107
|
+
|
|
108
|
+
### Option 3: Auto-Detection (Zero Configuration)
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"tree-sitter-analyzer-dev": {
|
|
114
|
+
"command": "uv",
|
|
115
|
+
"args": ["run", "--directory", "/path/to/tree-sitter-analyzer", "python", "-m", "tree_sitter_analyzer.mcp.server"]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**How it works:**
|
|
122
|
+
- 🔍 Searches for project markers (.git, pyproject.toml, package.json, etc.)
|
|
123
|
+
- 🔍 Traverses up directory tree from server working directory
|
|
124
|
+
- 🔍 Falls back to current working directory if no markers found
|
|
125
|
+
|
|
126
|
+
**Supported project markers:**
|
|
127
|
+
- Version control: `.git`, `.hg`, `.svn`
|
|
128
|
+
- Python: `pyproject.toml`, `setup.py`, `requirements.txt`
|
|
129
|
+
- JavaScript: `package.json`, `yarn.lock`, `node_modules`
|
|
130
|
+
- Java: `pom.xml`, `build.gradle`, `gradlew`
|
|
131
|
+
- And many more...
|
|
132
|
+
|
|
133
|
+
## Testing Project Root Configuration
|
|
134
|
+
|
|
135
|
+
### Test Auto-Detection
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Test from project directory
|
|
139
|
+
cd /your/project/directory
|
|
140
|
+
uv run python -m tree_sitter_analyzer.mcp.server --help
|
|
141
|
+
|
|
142
|
+
# Should show detected project root in logs
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Test Command Line Override
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Test explicit project root
|
|
149
|
+
uv run python -m tree_sitter_analyzer.mcp.server --project-root /specific/path --help
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Test Environment Variable
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Test environment variable
|
|
156
|
+
export TREE_SITTER_PROJECT_ROOT=/your/project
|
|
157
|
+
uv run python -m tree_sitter_analyzer.mcp.server --help
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Test Priority Handling
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Test priority (command line should win)
|
|
164
|
+
export TREE_SITTER_PROJECT_ROOT=/env/path
|
|
165
|
+
uv run python -m tree_sitter_analyzer.mcp.server --project-root /cmd/path --help
|
|
166
|
+
# Should use /cmd/path
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Debugging Project Root Issues
|
|
170
|
+
|
|
171
|
+
### Check Current Configuration
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Run with verbose logging
|
|
175
|
+
uv run python -c "
|
|
176
|
+
from tree_sitter_analyzer.project_detector import detect_project_root
|
|
177
|
+
import logging
|
|
178
|
+
logging.basicConfig(level=logging.INFO)
|
|
179
|
+
result = detect_project_root()
|
|
180
|
+
print(f'Detected project root: {result}')
|
|
181
|
+
"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Verify Security Boundaries
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Test file access validation
|
|
188
|
+
uv run python -c "
|
|
189
|
+
from tree_sitter_analyzer.security import SecurityValidator
|
|
190
|
+
validator = SecurityValidator('/your/project/root')
|
|
191
|
+
is_valid, msg = validator.validate_file_path('/your/project/root/src/file.py')
|
|
192
|
+
print(f'Valid: {is_valid}, Message: {msg}')
|
|
193
|
+
"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 3. Dual Configuration (Development + Stable)
|
|
197
|
+
|
|
198
|
+
For testing both versions, use this configuration:
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"mcpServers": {
|
|
203
|
+
"tree-sitter-analyzer-dev": {
|
|
204
|
+
"command": "uv",
|
|
205
|
+
"args": [
|
|
206
|
+
"run",
|
|
207
|
+
"--directory",
|
|
208
|
+
"/path/to/your/tree-sitter-analyzer",
|
|
209
|
+
"python",
|
|
210
|
+
"-m",
|
|
211
|
+
"tree_sitter_analyzer.mcp.server"
|
|
212
|
+
],
|
|
213
|
+
"disabled": false
|
|
214
|
+
},
|
|
215
|
+
"tree-sitter-analyzer-stable": {
|
|
216
|
+
"command": "uv",
|
|
217
|
+
"args": [
|
|
218
|
+
"run",
|
|
219
|
+
"--with",
|
|
220
|
+
"tree-sitter-analyzer[mcp]",
|
|
221
|
+
"python",
|
|
222
|
+
"-m",
|
|
223
|
+
"tree_sitter_analyzer.mcp.server"
|
|
224
|
+
],
|
|
225
|
+
"disabled": true
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Switch between versions by changing the `disabled` flag.
|
|
232
|
+
|
|
233
|
+
## Development Workflow
|
|
234
|
+
|
|
235
|
+
### 1. Make Changes
|
|
236
|
+
```bash
|
|
237
|
+
# Edit code
|
|
238
|
+
vim tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py
|
|
239
|
+
|
|
240
|
+
# Run tests
|
|
241
|
+
pytest tests/ -v
|
|
242
|
+
|
|
243
|
+
# Test CLI
|
|
244
|
+
uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --output-format=text
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### 2. Test MCP Server
|
|
248
|
+
```bash
|
|
249
|
+
# Test server manually
|
|
250
|
+
uv run python -m tree_sitter_analyzer.mcp.server
|
|
251
|
+
|
|
252
|
+
# Should show server initialization logs
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### 3. Test with Claude Desktop
|
|
256
|
+
- Restart Claude Desktop
|
|
257
|
+
- Test your changes through the AI assistant
|
|
258
|
+
- Check logs for any issues
|
|
259
|
+
|
|
260
|
+
## Debugging
|
|
261
|
+
|
|
262
|
+
### Enable Debug Logging
|
|
263
|
+
```bash
|
|
264
|
+
export TREE_SITTER_ANALYZER_LOG_LEVEL=DEBUG
|
|
265
|
+
uv run python -m tree_sitter_analyzer.mcp.server
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Common Issues
|
|
269
|
+
|
|
270
|
+
**Import Errors:**
|
|
271
|
+
```bash
|
|
272
|
+
# Check dependencies
|
|
273
|
+
uv run python -c "import tree_sitter_analyzer.mcp.server"
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Path Issues:**
|
|
277
|
+
- Use absolute paths in MCP configuration
|
|
278
|
+
- Verify project directory structure
|
|
279
|
+
|
|
280
|
+
**MCP Protocol Issues:**
|
|
281
|
+
- Check Claude Desktop logs
|
|
282
|
+
- Verify MCP package version: `uv run python -c "import mcp; print(mcp.__version__)"`
|
|
283
|
+
|
|
284
|
+
## Testing Changes
|
|
285
|
+
|
|
286
|
+
### Unit Tests
|
|
287
|
+
```bash
|
|
288
|
+
# Run all tests
|
|
289
|
+
pytest tests/ -v
|
|
290
|
+
|
|
291
|
+
# Run specific test
|
|
292
|
+
pytest tests/test_mcp_tools.py -v
|
|
293
|
+
|
|
294
|
+
# Run with coverage
|
|
295
|
+
pytest tests/ --cov=tree_sitter_analyzer
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Integration Tests
|
|
299
|
+
```bash
|
|
300
|
+
# Test MCP tools
|
|
301
|
+
uv run python -m pytest tests/test_mcp_integration.py -v
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Manual Testing
|
|
305
|
+
```bash
|
|
306
|
+
# Test CLI commands
|
|
307
|
+
uv run python -m tree_sitter_analyzer examples/Sample.java --table=full
|
|
308
|
+
|
|
309
|
+
# Test partial read
|
|
310
|
+
uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Contributing
|
|
314
|
+
|
|
315
|
+
1. Create feature branch
|
|
316
|
+
2. Make changes
|
|
317
|
+
3. Run tests: `pytest tests/ -v`
|
|
318
|
+
4. Test MCP integration
|
|
319
|
+
5. Submit pull request
|
|
320
|
+
|
|
321
|
+
## Need Help?
|
|
322
|
+
|
|
323
|
+
- [GitHub Issues](https://github.com/aimasteracc/tree-sitter-analyzer/issues)
|
|
324
|
+
- [User Setup Guide](MCP_SETUP_USERS.md) - For end users
|
|
325
|
+
- [API Documentation](docs/api.md)
|
|
@@ -47,7 +47,7 @@ uv --version
|
|
|
47
47
|
|
|
48
48
|
### Add Configuration
|
|
49
49
|
|
|
50
|
-
Open the config file and add this configuration
|
|
50
|
+
Open the config file and add this **recommended configuration**:
|
|
51
51
|
|
|
52
52
|
```json
|
|
53
53
|
{
|
|
@@ -55,18 +55,61 @@ Open the config file and add this configuration:
|
|
|
55
55
|
"tree-sitter-analyzer": {
|
|
56
56
|
"command": "uv",
|
|
57
57
|
"args": [
|
|
58
|
-
"run",
|
|
59
|
-
"--with",
|
|
58
|
+
"run",
|
|
59
|
+
"--with",
|
|
60
60
|
"tree-sitter-analyzer[mcp]",
|
|
61
|
-
"python",
|
|
62
|
-
"-m",
|
|
61
|
+
"python",
|
|
62
|
+
"-m",
|
|
63
63
|
"tree_sitter_analyzer.mcp.server"
|
|
64
|
+
],
|
|
65
|
+
"env": {
|
|
66
|
+
"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> **💡 Why this configuration?**
|
|
74
|
+
> - `${workspaceFolder}` automatically uses your current project directory
|
|
75
|
+
> - Provides secure file access boundaries
|
|
76
|
+
> - Works with any project without manual path changes
|
|
77
|
+
> - Enables intelligent project root detection
|
|
78
|
+
|
|
79
|
+
## Project Root Configuration
|
|
80
|
+
|
|
81
|
+
The tree-sitter-analyzer automatically detects your project boundaries for security and functionality. Here's how it works:
|
|
82
|
+
|
|
83
|
+
### ✅ Recommended: Use the configuration above
|
|
84
|
+
The `${workspaceFolder}` setting automatically adapts to your current project directory. This works for:
|
|
85
|
+
- VS Code workspaces
|
|
86
|
+
- Any IDE that supports workspace variables
|
|
87
|
+
- Most development environments
|
|
88
|
+
|
|
89
|
+
### 🔧 Alternative: Fixed project path (for specific use cases)
|
|
90
|
+
If you need to analyze files from a specific directory only:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"tree-sitter-analyzer": {
|
|
96
|
+
"command": "uv",
|
|
97
|
+
"args": [
|
|
98
|
+
"run", "--with", "tree-sitter-analyzer[mcp]",
|
|
99
|
+
"python", "-m", "tree_sitter_analyzer.mcp.server",
|
|
100
|
+
"--project-root", "/absolute/path/to/your/project"
|
|
64
101
|
]
|
|
65
102
|
}
|
|
66
103
|
}
|
|
67
104
|
}
|
|
68
105
|
```
|
|
69
106
|
|
|
107
|
+
### 🎯 What happens with project root?
|
|
108
|
+
- **Security**: Only files within the project directory can be analyzed
|
|
109
|
+
- **Smart detection**: Automatically finds project markers (.git, package.json, pyproject.toml, etc.)
|
|
110
|
+
- **Path resolution**: Resolves relative paths correctly
|
|
111
|
+
- **Performance**: Optimizes analysis for your project structure
|
|
112
|
+
|
|
70
113
|
## Step 3: Restart Claude Desktop
|
|
71
114
|
|
|
72
115
|
Close and restart Claude Desktop completely.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tree-sitter-analyzer
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.1
|
|
4
4
|
Summary: Extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture
|
|
5
5
|
Project-URL: Homepage, https://github.com/aimasteracc/tree-sitter-analyzer
|
|
6
6
|
Project-URL: Documentation, https://github.com/aimasteracc/tree-sitter-analyzer#readme
|
|
@@ -306,9 +306,32 @@ uv sync --extra all --extra mcp
|
|
|
306
306
|
|
|
307
307
|
- **[MCP Setup Guide for Users](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
|
|
308
308
|
- **[MCP Setup Guide for Developers](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
309
|
+
- **[Project Root Configuration](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/PROJECT_ROOT_CONFIG.md)** - Complete configuration reference
|
|
309
310
|
- **[API Documentation](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/docs/api.md)** - Detailed API reference
|
|
310
311
|
- **[Contributing Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CONTRIBUTING.md)** - How to contribute
|
|
311
312
|
|
|
313
|
+
### 🔒 Project Root Configuration
|
|
314
|
+
|
|
315
|
+
Tree-sitter-analyzer automatically detects and secures your project boundaries:
|
|
316
|
+
|
|
317
|
+
- **Auto-detection**: Finds project root from `.git`, `pyproject.toml`, `package.json`, etc.
|
|
318
|
+
- **CLI**: Use `--project-root /path/to/project` for explicit control
|
|
319
|
+
- **MCP**: Set `TREE_SITTER_PROJECT_ROOT=${workspaceFolder}` for workspace integration
|
|
320
|
+
- **Security**: Only analyzes files within project boundaries
|
|
321
|
+
|
|
322
|
+
**Recommended MCP configuration:**
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"mcpServers": {
|
|
326
|
+
"tree-sitter-analyzer": {
|
|
327
|
+
"command": "uv",
|
|
328
|
+
"args": ["run", "--with", "tree-sitter-analyzer[mcp]", "python", "-m", "tree_sitter_analyzer.mcp.server"],
|
|
329
|
+
"env": {"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
312
335
|
## 🧪 Testing
|
|
313
336
|
|
|
314
337
|
This project maintains high code quality with **1126 passing tests**.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Project Root Configuration Guide
|
|
2
|
+
|
|
3
|
+
**Quick reference for configuring project root in tree-sitter-analyzer**
|
|
4
|
+
|
|
5
|
+
## 🎯 Recommended Configuration (Most Users)
|
|
6
|
+
|
|
7
|
+
### MCP Server (Claude Desktop)
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"mcpServers": {
|
|
12
|
+
"tree-sitter-analyzer": {
|
|
13
|
+
"command": "uv",
|
|
14
|
+
"args": [
|
|
15
|
+
"run", "--with", "tree-sitter-analyzer[mcp]",
|
|
16
|
+
"python", "-m", "tree_sitter_analyzer.mcp.server"
|
|
17
|
+
],
|
|
18
|
+
"env": {
|
|
19
|
+
"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### CLI Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Auto-detect project root (recommended)
|
|
30
|
+
tree-sitter-analyzer src/main.py --table=full
|
|
31
|
+
|
|
32
|
+
# Explicit project root (when needed)
|
|
33
|
+
tree-sitter-analyzer src/main.py --project-root /path/to/project --table=full
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 🔧 How It Works
|
|
37
|
+
|
|
38
|
+
### Auto-Detection Process
|
|
39
|
+
|
|
40
|
+
1. **Searches for project markers** (in priority order):
|
|
41
|
+
- Version control: `.git`, `.hg`, `.svn`
|
|
42
|
+
- Python: `pyproject.toml`, `setup.py`, `requirements.txt`
|
|
43
|
+
- JavaScript: `package.json`, `yarn.lock`, `node_modules`
|
|
44
|
+
- Java: `pom.xml`, `build.gradle`, `gradlew`
|
|
45
|
+
- And 20+ more project types
|
|
46
|
+
|
|
47
|
+
2. **Traverses upward** from file location
|
|
48
|
+
3. **Selects best match** based on marker priority and count
|
|
49
|
+
4. **Falls back** to file directory if no markers found
|
|
50
|
+
|
|
51
|
+
### Security Benefits
|
|
52
|
+
|
|
53
|
+
- ✅ **File access control**: Only files within project boundaries
|
|
54
|
+
- ✅ **Path traversal protection**: Blocks `../../../etc/passwd` attacks
|
|
55
|
+
- ✅ **Symlink safety**: Prevents symlink-based boundary bypass
|
|
56
|
+
- ✅ **Audit logging**: Records all security events
|
|
57
|
+
|
|
58
|
+
## 📋 Configuration Options
|
|
59
|
+
|
|
60
|
+
### Priority Order (Highest to Lowest)
|
|
61
|
+
|
|
62
|
+
| Priority | Method | CLI | MCP | Use Case |
|
|
63
|
+
|----------|--------|-----|-----|----------|
|
|
64
|
+
| 🥇 **1st** | Command line argument | `--project-root /path` | `"args": [..., "--project-root", "/path"]` | Fixed paths, overrides |
|
|
65
|
+
| 🥈 **2nd** | Environment variable | `TREE_SITTER_PROJECT_ROOT=/path` | `"env": {"TREE_SITTER_PROJECT_ROOT": "/path"}` | Dynamic, workspace integration |
|
|
66
|
+
| 🥉 **3rd** | Auto-detection | *(default)* | *(default)* | Zero configuration |
|
|
67
|
+
|
|
68
|
+
### When to Use Each Method
|
|
69
|
+
|
|
70
|
+
#### Environment Variable (Recommended)
|
|
71
|
+
```json
|
|
72
|
+
"env": {"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"}
|
|
73
|
+
```
|
|
74
|
+
- ✅ **Best for**: Most users, IDE integration
|
|
75
|
+
- ✅ **Benefits**: Automatic workspace adaptation, flexible
|
|
76
|
+
- ✅ **Works with**: VS Code, most IDEs
|
|
77
|
+
|
|
78
|
+
#### Command Line Argument
|
|
79
|
+
```bash
|
|
80
|
+
--project-root /specific/path
|
|
81
|
+
```
|
|
82
|
+
- ✅ **Best for**: Fixed paths, CI/CD, overrides
|
|
83
|
+
- ✅ **Benefits**: Explicit control, highest priority
|
|
84
|
+
- ✅ **Works with**: Scripts, automation
|
|
85
|
+
|
|
86
|
+
#### Auto-Detection
|
|
87
|
+
```bash
|
|
88
|
+
# No configuration needed
|
|
89
|
+
```
|
|
90
|
+
- ✅ **Best for**: Development, quick testing
|
|
91
|
+
- ✅ **Benefits**: Zero configuration, intelligent
|
|
92
|
+
- ✅ **Works with**: Standard project structures
|
|
93
|
+
|
|
94
|
+
## 🚨 Common Issues & Solutions
|
|
95
|
+
|
|
96
|
+
### Issue: "Absolute path must be within project directory"
|
|
97
|
+
|
|
98
|
+
**Cause**: File is outside detected project boundary
|
|
99
|
+
|
|
100
|
+
**Solutions:**
|
|
101
|
+
1. Use explicit project root: `--project-root /correct/path`
|
|
102
|
+
2. Check project markers exist in expected location
|
|
103
|
+
3. Verify file is actually within intended project
|
|
104
|
+
|
|
105
|
+
### Issue: "No project root detected"
|
|
106
|
+
|
|
107
|
+
**Cause**: No project markers found
|
|
108
|
+
|
|
109
|
+
**Solutions:**
|
|
110
|
+
1. Add a project marker file (`.git`, `pyproject.toml`, etc.)
|
|
111
|
+
2. Use explicit project root: `--project-root .`
|
|
112
|
+
3. Check current working directory
|
|
113
|
+
|
|
114
|
+
### Issue: Wrong project root detected
|
|
115
|
+
|
|
116
|
+
**Cause**: Multiple nested projects or unexpected markers
|
|
117
|
+
|
|
118
|
+
**Solutions:**
|
|
119
|
+
1. Use explicit project root to override
|
|
120
|
+
2. Remove unwanted project markers
|
|
121
|
+
3. Check marker priority (`.git` > `pyproject.toml` > `README.md`)
|
|
122
|
+
|
|
123
|
+
## 🧪 Testing Your Configuration
|
|
124
|
+
|
|
125
|
+
### Test Auto-Detection
|
|
126
|
+
```bash
|
|
127
|
+
cd /your/project
|
|
128
|
+
python -c "
|
|
129
|
+
from tree_sitter_analyzer.project_detector import detect_project_root
|
|
130
|
+
print('Detected:', detect_project_root())
|
|
131
|
+
"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Test MCP Server
|
|
135
|
+
```bash
|
|
136
|
+
# Test with your configuration
|
|
137
|
+
python -m tree_sitter_analyzer.mcp.server --help
|
|
138
|
+
# Check logs for "MCP server starting with project root: ..."
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Test Security Boundaries
|
|
142
|
+
```bash
|
|
143
|
+
# Should work (file within project)
|
|
144
|
+
tree-sitter-analyzer src/main.py --table=compact
|
|
145
|
+
|
|
146
|
+
# Should fail (file outside project)
|
|
147
|
+
tree-sitter-analyzer ../outside.py --table=compact
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## 📖 Examples by Project Type
|
|
151
|
+
|
|
152
|
+
### Python Project
|
|
153
|
+
```
|
|
154
|
+
my-python-project/
|
|
155
|
+
├── pyproject.toml # ← Detected as project root
|
|
156
|
+
├── src/
|
|
157
|
+
│ └── mypackage/
|
|
158
|
+
│ └── main.py # ← Analyze this file
|
|
159
|
+
└── tests/
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### JavaScript Project
|
|
163
|
+
```
|
|
164
|
+
my-js-project/
|
|
165
|
+
├── package.json # ← Detected as project root
|
|
166
|
+
├── src/
|
|
167
|
+
│ └── index.js # ← Analyze this file
|
|
168
|
+
└── node_modules/
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Java Project
|
|
172
|
+
```
|
|
173
|
+
my-java-project/
|
|
174
|
+
├── pom.xml # ← Detected as project root
|
|
175
|
+
├── src/
|
|
176
|
+
│ └── main/
|
|
177
|
+
│ └── java/
|
|
178
|
+
│ └── Main.java # ← Analyze this file
|
|
179
|
+
└── target/
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Git Repository
|
|
183
|
+
```
|
|
184
|
+
any-project/
|
|
185
|
+
├── .git/ # ← Detected as project root (highest priority)
|
|
186
|
+
├── src/
|
|
187
|
+
│ └── code.ext # ← Analyze this file
|
|
188
|
+
└── docs/
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 🎯 Best Practices
|
|
192
|
+
|
|
193
|
+
1. **Use environment variable for MCP**: `${workspaceFolder}` adapts automatically
|
|
194
|
+
2. **Let auto-detection work**: Most projects have standard markers
|
|
195
|
+
3. **Override when needed**: Use command line for special cases
|
|
196
|
+
4. **Test your setup**: Verify project root detection works as expected
|
|
197
|
+
5. **Keep it simple**: Start with recommended configuration, customize only if needed
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
**Need help?** Check the full setup guides:
|
|
202
|
+
- [MCP Setup for Users](MCP_SETUP_USERS.md)
|
|
203
|
+
- [MCP Setup for Developers](MCP_SETUP_DEVELOPERS.md)
|
|
@@ -171,9 +171,32 @@ uv sync --extra all --extra mcp
|
|
|
171
171
|
|
|
172
172
|
- **[MCP Setup Guide for Users](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
|
|
173
173
|
- **[MCP Setup Guide for Developers](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
174
|
+
- **[Project Root Configuration](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/PROJECT_ROOT_CONFIG.md)** - Complete configuration reference
|
|
174
175
|
- **[API Documentation](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/docs/api.md)** - Detailed API reference
|
|
175
176
|
- **[Contributing Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CONTRIBUTING.md)** - How to contribute
|
|
176
177
|
|
|
178
|
+
### 🔒 Project Root Configuration
|
|
179
|
+
|
|
180
|
+
Tree-sitter-analyzer automatically detects and secures your project boundaries:
|
|
181
|
+
|
|
182
|
+
- **Auto-detection**: Finds project root from `.git`, `pyproject.toml`, `package.json`, etc.
|
|
183
|
+
- **CLI**: Use `--project-root /path/to/project` for explicit control
|
|
184
|
+
- **MCP**: Set `TREE_SITTER_PROJECT_ROOT=${workspaceFolder}` for workspace integration
|
|
185
|
+
- **Security**: Only analyzes files within project boundaries
|
|
186
|
+
|
|
187
|
+
**Recommended MCP configuration:**
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"mcpServers": {
|
|
191
|
+
"tree-sitter-analyzer": {
|
|
192
|
+
"command": "uv",
|
|
193
|
+
"args": ["run", "--with", "tree-sitter-analyzer[mcp]", "python", "-m", "tree_sitter_analyzer.mcp.server"],
|
|
194
|
+
"env": {"TREE_SITTER_PROJECT_ROOT": "${workspaceFolder}"}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
177
200
|
## 🧪 Testing
|
|
178
201
|
|
|
179
202
|
This project maintains high code quality with **1126 passing tests**.
|