tree-sitter-analyzer 1.1.3__py3-none-any.whl → 1.2.2__py3-none-any.whl
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/cli/commands/advanced_command.py +145 -6
- tree_sitter_analyzer/cli/commands/structure_command.py +23 -5
- tree_sitter_analyzer/cli/commands/summary_command.py +19 -4
- tree_sitter_analyzer/cli/commands/table_command.py +14 -6
- tree_sitter_analyzer/constants.py +68 -0
- tree_sitter_analyzer/core/analysis_engine.py +0 -5
- tree_sitter_analyzer/core/engine.py +0 -12
- tree_sitter_analyzer/interfaces/cli_adapter.py +27 -12
- tree_sitter_analyzer/interfaces/mcp_adapter.py +31 -15
- tree_sitter_analyzer/mcp/server.py +187 -35
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +42 -19
- tree_sitter_analyzer/mcp/tools/base_tool.py +90 -5
- tree_sitter_analyzer/mcp/tools/query_tool.py +73 -6
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +3 -6
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +37 -11
- tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +102 -22
- tree_sitter_analyzer/models.py +138 -43
- tree_sitter_analyzer/security/boundary_manager.py +29 -9
- tree_sitter_analyzer/security/validator.py +16 -3
- {tree_sitter_analyzer-1.1.3.dist-info → tree_sitter_analyzer-1.2.2.dist-info}/METADATA +298 -127
- {tree_sitter_analyzer-1.1.3.dist-info → tree_sitter_analyzer-1.2.2.dist-info}/RECORD +23 -22
- {tree_sitter_analyzer-1.1.3.dist-info → tree_sitter_analyzer-1.2.2.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-1.1.3.dist-info → tree_sitter_analyzer-1.2.2.dist-info}/entry_points.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tree-sitter-analyzer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.2
|
|
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
|
|
@@ -163,73 +163,75 @@ Description-Content-Type: text/markdown
|
|
|
163
163
|
|
|
164
164
|
[](https://python.org)
|
|
165
165
|
[](LICENSE)
|
|
166
|
-
[](#quality-assurance)
|
|
167
|
+
[](#quality-assurance)
|
|
168
168
|
[](#quality-assurance)
|
|
169
169
|
[](https://pypi.org/project/tree-sitter-analyzer/)
|
|
170
|
-
[](https://github.com/aimasteracc/tree-sitter-analyzer/releases)
|
|
171
171
|
[](https://github.com/aimasteracc/tree-sitter-analyzer)
|
|
172
172
|
|
|
173
|
-
## 🚀 Break
|
|
173
|
+
## 🚀 Break LLM Token Limits, Let AI Understand Code Files of Any Size
|
|
174
174
|
|
|
175
|
-
> **
|
|
175
|
+
> **Revolutionary Code Analysis Tool Designed for the AI Era**
|
|
176
176
|
|
|
177
177
|
## 📋 Table of Contents
|
|
178
178
|
|
|
179
|
-
- [🚀 Break
|
|
179
|
+
- [🚀 Break LLM Token Limits](#-break-llm-token-limits-let-ai-understand-code-files-of-any-size)
|
|
180
180
|
- [📋 Table of Contents](#-table-of-contents)
|
|
181
|
-
- [💡
|
|
182
|
-
- [📊
|
|
181
|
+
- [💡 Unique Features](#-unique-features)
|
|
182
|
+
- [📊 Real-time Demo and Results](#-real-time-demo-and-results)
|
|
183
183
|
- [🚀 30-Second Quick Start](#-30-second-quick-start)
|
|
184
|
-
- [🤖
|
|
185
|
-
- [💻
|
|
184
|
+
- [🤖 AI Users (Claude Desktop, Cursor, etc.)](#-ai-users-claude-desktop-cursor-etc)
|
|
185
|
+
- [💻 Developers (CLI)](#-developers-cli)
|
|
186
186
|
- [❓ Why Choose Tree-sitter Analyzer](#-why-choose-tree-sitter-analyzer)
|
|
187
187
|
- [📖 Practical Usage Examples](#-practical-usage-examples)
|
|
188
188
|
- [🛠️ Core Features](#️-core-features)
|
|
189
189
|
- [📦 Installation Guide](#-installation-guide)
|
|
190
|
-
- [🔒 Security
|
|
190
|
+
- [🔒 Security and Configuration](#-security-and-configuration)
|
|
191
191
|
- [🏆 Quality Assurance](#-quality-assurance)
|
|
192
192
|
- [🤖 AI Collaboration Support](#-ai-collaboration-support)
|
|
193
193
|
- [📚 Documentation](#-documentation)
|
|
194
194
|
- [🤝 Contributing](#-contributing)
|
|
195
195
|
- [📄 License](#-license)
|
|
196
196
|
|
|
197
|
-
## 💡
|
|
197
|
+
## 💡 Unique Features
|
|
198
198
|
|
|
199
|
-
Imagine:
|
|
199
|
+
Imagine this: you have a Java service class with over 1400 lines, and Claude or ChatGPT can't analyze it due to token limits. Now, Tree-sitter Analyzer enables AI assistants to:
|
|
200
200
|
|
|
201
201
|
- ⚡ **Get complete code structure overview in 3 seconds**
|
|
202
|
-
- 🎯 **
|
|
203
|
-
- 📍 **Smart positioning** exact locations
|
|
204
|
-
- 🔗 **Seamless integration** with Claude Desktop, Cursor, Roo Code and other AI IDEs
|
|
202
|
+
- 🎯 **Accurate extraction** of code snippets from any line range
|
|
203
|
+
- 📍 **Smart positioning** of exact locations for classes, methods, and fields
|
|
204
|
+
- 🔗 **Seamless integration** with Claude Desktop, Cursor, Roo Code, and other AI IDEs
|
|
205
|
+
- 🏗️ **Unified element management** - All code elements (classes, methods, fields, imports) in a unified system
|
|
205
206
|
|
|
206
|
-
**No more AI
|
|
207
|
+
**No more AI being helpless with large files!**
|
|
207
208
|
|
|
208
|
-
## 📊
|
|
209
|
+
## 📊 Real-time Demo and Results
|
|
209
210
|
|
|
210
|
-
### ⚡ **Lightning-
|
|
211
|
+
### ⚡ **Lightning-fast Analysis Speed**
|
|
211
212
|
```bash
|
|
212
|
-
# 1419-line large Java service class
|
|
213
|
-
Lines: 1419 | Classes: 1 | Methods: 66 | Fields: 9 | Imports: 8
|
|
213
|
+
# Analysis result of 1419-line large Java service class (< 1 second)
|
|
214
|
+
Lines: 1419 | Classes: 1 | Methods: 66 | Fields: 9 | Imports: 8 | Packages: 1
|
|
215
|
+
Total Elements: 85 | Complexity: 348 (avg: 5.27, max: 15)
|
|
214
216
|
```
|
|
215
217
|
|
|
216
|
-
### 📊 **Precise Structure
|
|
217
|
-
| Class Name | Type | Visibility | Line Range |
|
|
218
|
-
|
|
218
|
+
### 📊 **Precise Structure Table**
|
|
219
|
+
| Class Name | Type | Visibility | Line Range | Method Count | Field Count |
|
|
220
|
+
|------------|------|------------|------------|--------------|-------------|
|
|
219
221
|
| BigService | class | public | 17-1419 | 66 | 9 |
|
|
220
222
|
|
|
221
223
|
### 🔄 **AI Assistant Three-Step Workflow**
|
|
222
|
-
- **Step 1**: `check_code_scale` - Check file
|
|
223
|
-
- **Step 2**: `analyze_code_structure` - Generate detailed structure
|
|
224
|
+
- **Step 1**: `check_code_scale` - Check file size and complexity
|
|
225
|
+
- **Step 2**: `analyze_code_structure` - Generate detailed structure table with unified elements
|
|
224
226
|
- **Step 3**: `extract_code_section` - Extract code snippets on demand
|
|
225
227
|
|
|
226
228
|
---
|
|
227
229
|
|
|
228
230
|
## 🚀 30-Second Quick Start
|
|
229
231
|
|
|
230
|
-
### 🤖
|
|
232
|
+
### 🤖 AI Users (Claude Desktop, Cursor, etc.)
|
|
231
233
|
|
|
232
|
-
**📦 1. One-
|
|
234
|
+
**📦 1. One-click Installation**
|
|
233
235
|
```bash
|
|
234
236
|
# macOS/Linux
|
|
235
237
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
@@ -238,11 +240,11 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
238
240
|
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
239
241
|
```
|
|
240
242
|
|
|
241
|
-
**⚙️ 2.
|
|
243
|
+
**⚙️ 2. AI Client Configuration**
|
|
242
244
|
|
|
243
245
|
**Claude Desktop Configuration:**
|
|
244
246
|
|
|
245
|
-
Add the following to your
|
|
247
|
+
Add the following to your configuration file:
|
|
246
248
|
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
247
249
|
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
248
250
|
- **Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
@@ -262,7 +264,7 @@ Add the following to your config file:
|
|
|
262
264
|
}
|
|
263
265
|
```
|
|
264
266
|
|
|
265
|
-
**Advanced Configuration (Specify Project Root):**
|
|
267
|
+
**Advanced Configuration (Specify Project Root Directory):**
|
|
266
268
|
```json
|
|
267
269
|
{
|
|
268
270
|
"mcpServers": {
|
|
@@ -282,23 +284,23 @@ Add the following to your config file:
|
|
|
282
284
|
|
|
283
285
|
**Other AI Clients:**
|
|
284
286
|
- **Cursor**: Built-in MCP support, refer to Cursor documentation for configuration
|
|
285
|
-
- **Roo Code**: Supports MCP protocol, check
|
|
287
|
+
- **Roo Code**: Supports MCP protocol, check corresponding configuration guides
|
|
286
288
|
- **Other MCP-compatible clients**: Use the same server configuration
|
|
287
289
|
|
|
288
290
|
**⚠️ Configuration Notes:**
|
|
289
|
-
- **Basic Configuration**: Tool
|
|
290
|
-
- **Advanced Configuration**: If you need to specify a particular directory,
|
|
291
|
-
- **Avoid
|
|
291
|
+
- **Basic Configuration**: Tool automatically detects project root directory (recommended)
|
|
292
|
+
- **Advanced Configuration**: If you need to specify a particular directory, replace `/absolute/path/to/your/project` with an absolute path
|
|
293
|
+
- **Avoid Using**: Variables like `${workspaceFolder}` may not be supported in some clients
|
|
292
294
|
|
|
293
|
-
**🎉 3. Restart AI client and start analyzing
|
|
295
|
+
**🎉 3. Restart AI client and start analyzing large code files!**
|
|
294
296
|
|
|
295
|
-
### 💻
|
|
297
|
+
### 💻 Developers (CLI)
|
|
296
298
|
|
|
297
299
|
```bash
|
|
298
|
-
#
|
|
300
|
+
# Installation
|
|
299
301
|
uv add "tree-sitter-analyzer[popular]"
|
|
300
302
|
|
|
301
|
-
# Check file
|
|
303
|
+
# Check file size (1419-line large service class, completed instantly)
|
|
302
304
|
uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
|
|
303
305
|
|
|
304
306
|
# Generate structure table (1 class, 66 methods, clearly displayed)
|
|
@@ -312,15 +314,15 @@ uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --
|
|
|
312
314
|
|
|
313
315
|
## ❓ Why Choose Tree-sitter Analyzer
|
|
314
316
|
|
|
315
|
-
### 🎯
|
|
317
|
+
### 🎯 Solve Real Pain Points
|
|
316
318
|
|
|
317
|
-
**Traditional
|
|
319
|
+
**Traditional Method Difficulties:**
|
|
318
320
|
- ❌ Large files exceed LLM token limits
|
|
319
321
|
- ❌ AI cannot understand code structure
|
|
320
|
-
- ❌
|
|
322
|
+
- ❌ Need to manually split files
|
|
321
323
|
- ❌ Context loss leads to inaccurate analysis
|
|
322
324
|
|
|
323
|
-
**Tree-sitter Analyzer
|
|
325
|
+
**Tree-sitter Analyzer Breakthrough:**
|
|
324
326
|
- ✅ **Smart Analysis**: Understand structure without reading complete files
|
|
325
327
|
- ✅ **Precise Positioning**: Accurate line-by-line code extraction
|
|
326
328
|
- ✅ **AI Native**: Optimized for LLM workflows
|
|
@@ -328,16 +330,84 @@ uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --
|
|
|
328
330
|
|
|
329
331
|
## 📖 Practical Usage Examples
|
|
330
332
|
|
|
331
|
-
### 💬 AI IDE Prompts (
|
|
333
|
+
### 💬 AI IDE Prompts (Tested and Verified, Ready to Use)
|
|
332
334
|
|
|
333
|
-
|
|
335
|
+
> **✅ Test Verification Status:** All prompts below have been tested and verified in real environments, ensuring 100% availability
|
|
336
|
+
>
|
|
337
|
+
> **⚠️ Important Notes:**
|
|
338
|
+
> - **Step 0 is required** - Always set project path before using other tools
|
|
339
|
+
> - For files within the project, use **relative paths** (e.g., `examples/BigService.java`)
|
|
340
|
+
> - For files outside the project, use **absolute paths** (e.g., `C:\git-public\tree-sitter-analyzer\examples\BigService.java`)
|
|
341
|
+
> - All tools support both Windows and Unix style paths
|
|
342
|
+
> - Project path should point to your code repository root directory
|
|
343
|
+
> - You can set project path in MCP configuration or set it dynamically
|
|
334
344
|
|
|
335
|
-
**
|
|
345
|
+
#### 🔧 **Step 0: Set Project Path (Required First Step)**
|
|
346
|
+
|
|
347
|
+
**Option 1: Configure in MCP Settings**
|
|
348
|
+
```json
|
|
349
|
+
{
|
|
350
|
+
"mcpServers": {
|
|
351
|
+
"tree-sitter-analyzer": {
|
|
352
|
+
"command": "uv",
|
|
353
|
+
"args": ["run", "python", "-m", "tree_sitter_analyzer.mcp.server"],
|
|
354
|
+
"env": {
|
|
355
|
+
"TREE_SITTER_PROJECT_ROOT": "/path/to/your/project"
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Option 2: Tell AI Directly (Recommended, More Natural)**
|
|
363
|
+
|
|
364
|
+
**Method 1: Explicit Setup Request**
|
|
365
|
+
```
|
|
366
|
+
Please help me set the project root directory, the path is: C:\git-public\tree-sitter-analyzer
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**Method 2: Provide Project Information**
|
|
370
|
+
```
|
|
371
|
+
My project is at: C:\git-public\tree-sitter-analyzer
|
|
372
|
+
Please set this path as the project root
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
**Method 3: Simple Statement**
|
|
376
|
+
```
|
|
377
|
+
Project path: C:\git-public\tree-sitter-analyzer
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**AI will automatically call the appropriate tool to set the path, no need to remember complex command formats**
|
|
381
|
+
|
|
382
|
+
**⚠️ Important Notes:**
|
|
383
|
+
- After setting project path, you can use relative paths to reference files within the project
|
|
384
|
+
- Example: `examples/BigService.java` instead of full paths
|
|
385
|
+
- Once project path is successfully set, all subsequent analysis commands will automatically use this root directory
|
|
386
|
+
|
|
387
|
+
#### 🔍 **Step 1: Check File Size**
|
|
388
|
+
|
|
389
|
+
**Method 1: Explicit Analysis Request**
|
|
390
|
+
```
|
|
391
|
+
Please help me analyze this file: examples/BigService.java
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Method 2: Describe Analysis Needs**
|
|
336
395
|
```
|
|
337
|
-
|
|
338
|
-
Parameters: {"file_path": "examples/BigService.java"}
|
|
396
|
+
I want to understand the size and structure of this Java file: examples/BigService.java
|
|
339
397
|
```
|
|
340
398
|
|
|
399
|
+
**Method 3: Simple Request**
|
|
400
|
+
```
|
|
401
|
+
Analyze this file: examples/BigService.java
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Alternative using absolute path:**
|
|
405
|
+
```
|
|
406
|
+
Please analyze this file: C:\git-public\tree-sitter-analyzer\examples\BigService.java
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**💡 Tip: After setting project path, using relative paths is recommended, more concise and convenient**
|
|
410
|
+
|
|
341
411
|
**Return Format:**
|
|
342
412
|
```json
|
|
343
413
|
{
|
|
@@ -345,11 +415,21 @@ Parameters: {"file_path": "examples/BigService.java"}
|
|
|
345
415
|
"language": "java",
|
|
346
416
|
"metrics": {
|
|
347
417
|
"lines_total": 1419,
|
|
348
|
-
"lines_code":
|
|
418
|
+
"lines_code": 907,
|
|
419
|
+
"lines_comment": 246,
|
|
420
|
+
"lines_blank": 267,
|
|
349
421
|
"elements": {
|
|
350
422
|
"classes": 1,
|
|
351
423
|
"methods": 66,
|
|
352
|
-
"fields": 9
|
|
424
|
+
"fields": 9,
|
|
425
|
+
"imports": 8,
|
|
426
|
+
"packages": 1,
|
|
427
|
+
"total": 85
|
|
428
|
+
},
|
|
429
|
+
"complexity": {
|
|
430
|
+
"total": 348,
|
|
431
|
+
"average": 5.27,
|
|
432
|
+
"max": 15
|
|
353
433
|
}
|
|
354
434
|
}
|
|
355
435
|
}
|
|
@@ -357,25 +437,57 @@ Parameters: {"file_path": "examples/BigService.java"}
|
|
|
357
437
|
|
|
358
438
|
#### 📊 **Step 2: Generate Structure Table**
|
|
359
439
|
|
|
360
|
-
**
|
|
440
|
+
**Method 1: Explicit Table Request**
|
|
361
441
|
```
|
|
362
|
-
|
|
363
|
-
Parameters: {"file_path": "examples/BigService.java"}
|
|
442
|
+
Please generate a detailed structure table for this file: examples/BigService.java
|
|
364
443
|
```
|
|
365
444
|
|
|
445
|
+
**Method 2: Describe Table Needs**
|
|
446
|
+
```
|
|
447
|
+
I want to see the complete structure of this Java file, including all classes, methods, and fields: examples/BigService.java
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Method 3: Simple Request**
|
|
451
|
+
```
|
|
452
|
+
Generate structure table: examples/BigService.java
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
**Alternative using absolute path:**
|
|
456
|
+
```
|
|
457
|
+
Please generate a detailed structure table: C:\git-public\tree-sitter-analyzer\examples\BigService.java
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**💡 Tip: After setting project path, using relative paths is recommended, more concise and convenient**
|
|
461
|
+
|
|
366
462
|
**Return Format:**
|
|
367
463
|
- Complete Markdown table
|
|
368
|
-
- Including class
|
|
369
|
-
- Method signatures, visibility, line ranges, complexity and other detailed information
|
|
464
|
+
- Including class information, method list (with line numbers), field list
|
|
465
|
+
- Method signatures, visibility, line ranges, complexity, and other detailed information
|
|
370
466
|
|
|
371
467
|
#### ✂️ **Step 3: Extract Code Snippets**
|
|
372
468
|
|
|
373
|
-
**
|
|
469
|
+
**Method 1: Explicit Extraction Request**
|
|
374
470
|
```
|
|
375
|
-
|
|
376
|
-
Parameters: {"file_path": "examples/BigService.java", "start_line": 93, "end_line": 105}
|
|
471
|
+
Please extract lines 93-105 of this file: examples/BigService.java
|
|
377
472
|
```
|
|
378
473
|
|
|
474
|
+
**Method 2: Describe Extraction Needs**
|
|
475
|
+
```
|
|
476
|
+
I want to see the code content from lines 93 to 105 of this Java file: examples/BigService.java
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**Method 3: Simple Request**
|
|
480
|
+
```
|
|
481
|
+
Extract lines 93-105: examples/BigService.java
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
**Alternative using absolute path:**
|
|
485
|
+
```
|
|
486
|
+
Please extract code snippet: C:\git-public\tree-sitter-analyzer\examples\BigService.java, lines 93-105
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**💡 Tip: After setting project path, using relative paths is recommended, more concise and convenient**
|
|
490
|
+
|
|
379
491
|
**Return Format:**
|
|
380
492
|
```json
|
|
381
493
|
{
|
|
@@ -393,27 +505,24 @@ Parameters: {"file_path": "examples/BigService.java", "start_line": 93, "end_lin
|
|
|
393
505
|
|
|
394
506
|
#### 🔍 **Step 4: Smart Query Filtering (v0.9.6+)**
|
|
395
507
|
|
|
396
|
-
**
|
|
397
|
-
- Improved `@handle_mcp_errors` decorator with tool name
|
|
398
|
-
- Better error context for debugging and troubleshooting
|
|
399
|
-
- Enhanced security validation
|
|
508
|
+
**Error Handling Enhancement (v0.9.7):**
|
|
509
|
+
- Improved `@handle_mcp_errors` decorator with tool name recognition
|
|
510
|
+
- Better error context for easier debugging and troubleshooting
|
|
511
|
+
- Enhanced file path security validation
|
|
400
512
|
|
|
401
|
-
**Find
|
|
513
|
+
**Find Specific Methods:**
|
|
402
514
|
```
|
|
403
|
-
|
|
404
|
-
Parameters: {"file_path": "examples/BigService.java", "query_key": "methods", "filter": "name=main"}
|
|
515
|
+
Please help me find the main method in this file: examples/BigService.java
|
|
405
516
|
```
|
|
406
517
|
|
|
407
|
-
**Find
|
|
518
|
+
**Find Authentication-related Methods:**
|
|
408
519
|
```
|
|
409
|
-
|
|
410
|
-
Parameters: {"file_path": "examples/BigService.java", "query_key": "methods", "filter": "name=~auth*"}
|
|
520
|
+
I want to find all authentication-related methods: examples/BigService.java
|
|
411
521
|
```
|
|
412
522
|
|
|
413
|
-
**Find
|
|
523
|
+
**Find Public Methods with No Parameters:**
|
|
414
524
|
```
|
|
415
|
-
|
|
416
|
-
Parameters: {"file_path": "examples/BigService.java", "query_key": "methods", "filter": "params=0,public=true"}
|
|
525
|
+
Please help me find all public getter methods with no parameters: examples/BigService.java
|
|
417
526
|
```
|
|
418
527
|
|
|
419
528
|
**Return Format:**
|
|
@@ -426,24 +535,28 @@ Parameters: {"file_path": "examples/BigService.java", "query_key": "methods", "f
|
|
|
426
535
|
"node_type": "method_declaration",
|
|
427
536
|
"start_line": 1385,
|
|
428
537
|
"end_line": 1418,
|
|
429
|
-
"content": "public static void main(String[] args) {
|
|
538
|
+
"content": "public static void main(String[] args) {\n System.out.println(\"BigService Demo Application\");\n System.out.println(\"==========================\");\n\n BigService service = new BigService();\n\n // Test basic functions\n System.out.println(\"\\n--- Testing Basic Functions ---\");\n service.authenticateUser(\"testuser\", \"password123\");\n service.createSession(\"testuser\");\n\n // Test customer management\n System.out.println(\"\\n--- Testing Customer Management ---\");\n service.updateCustomerName(\"CUST001\", \"New Customer Name\");\n Map<String, Object> customerInfo = service.getCustomerInfo(\"CUST001\");\n\n // Test report generation\n System.out.println(\"\\n--- Testing Report Generation ---\");\n Map<String, Object> reportParams = new HashMap<>();\n reportParams.put(\"start_date\", \"2024-01-01\");\n reportParams.put(\"end_date\", \"2024-12-31\");\n service.generateReport(\"sales\", reportParams);\n\n // Test performance monitoring\n System.out.println(\"\\n--- Testing Performance Monitoring ---\");\n service.monitorPerformance();\n\n // Test security check\n System.out.println(\"\\n--- Testing Security Check ---\");\n service.performSecurityCheck();\n\n System.out.println(\"\\n--- Demo Completed ---\");\n System.out.println(\"BigService demo application finished successfully.\");\n }"
|
|
430
539
|
}
|
|
431
540
|
],
|
|
432
|
-
"count": 1
|
|
541
|
+
"count": 1,
|
|
542
|
+
"file_path": "examples/BigService.java",
|
|
543
|
+
"language": "java",
|
|
544
|
+
"query": "methods"
|
|
433
545
|
}
|
|
434
546
|
```
|
|
435
547
|
|
|
436
548
|
#### 💡 **Important Notes**
|
|
437
|
-
- **
|
|
438
|
-
- **Path
|
|
439
|
-
- **Security Protection**: Tool automatically performs project boundary checks
|
|
440
|
-
- **Workflow**: Recommended to use in order: Step 1 → 2 → 4 (
|
|
441
|
-
- **
|
|
549
|
+
- **Natural Language**: Tell AI directly in natural language what you want, no need to remember complex parameter formats
|
|
550
|
+
- **Path Processing**: After setting project path, relative paths automatically resolve to project root directory, absolute paths also fully supported
|
|
551
|
+
- **Security Protection**: Tool automatically performs project boundary checks to ensure security
|
|
552
|
+
- **Workflow**: Recommended to use in order: Step 0 (set path) → Step 1 → 2 → 4 (query filter) → 3 (precise extraction)
|
|
553
|
+
- **Smart Understanding**: AI automatically understands your needs and calls appropriate tools
|
|
554
|
+
- **Project Path**: Once project path is set, all subsequent operations automatically use that root directory
|
|
442
555
|
|
|
443
556
|
### 🛠️ CLI Command Examples
|
|
444
557
|
|
|
445
558
|
```bash
|
|
446
|
-
# Quick analysis (1419-line large file,
|
|
559
|
+
# Quick analysis (1419-line large file, completed instantly)
|
|
447
560
|
uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
|
|
448
561
|
|
|
449
562
|
# Detailed structure table (66 methods clearly displayed)
|
|
@@ -452,17 +565,23 @@ uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
|
|
|
452
565
|
# Precise code extraction (memory usage monitoring code snippet)
|
|
453
566
|
uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --start-line 100 --end-line 105
|
|
454
567
|
|
|
455
|
-
#
|
|
568
|
+
# Multi-language support test (Python file)
|
|
569
|
+
uv run python -m tree_sitter_analyzer examples/sample.py --table=full
|
|
570
|
+
|
|
571
|
+
# Small file quick analysis (54-line Java file)
|
|
572
|
+
uv run python -m tree_sitter_analyzer examples/MultiClass.java --advanced
|
|
573
|
+
|
|
574
|
+
# Silent mode (only show results)
|
|
456
575
|
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full --quiet
|
|
457
576
|
|
|
458
|
-
# 🔍 Query
|
|
577
|
+
# 🔍 Query Filter Examples (v0.9.6+)
|
|
459
578
|
# Find specific methods
|
|
460
579
|
uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "name=main"
|
|
461
580
|
|
|
462
581
|
# Find authentication-related methods
|
|
463
582
|
uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "name=~auth*"
|
|
464
583
|
|
|
465
|
-
# Find
|
|
584
|
+
# Find public methods with no parameters
|
|
466
585
|
uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "params=0,public=true"
|
|
467
586
|
|
|
468
587
|
# Find static methods
|
|
@@ -474,40 +593,73 @@ uv run python -m tree_sitter_analyzer --filter-help
|
|
|
474
593
|
|
|
475
594
|
---
|
|
476
595
|
|
|
596
|
+
## 🏗️ Architecture Improvements (v1.2.0+)
|
|
597
|
+
|
|
598
|
+
### 🔄 **Unified Element Management System**
|
|
599
|
+
|
|
600
|
+
Tree-sitter Analyzer now features a revolutionary unified architecture that integrates all code elements into a unified system:
|
|
601
|
+
|
|
602
|
+
#### **Before (Traditional Architecture):**
|
|
603
|
+
- Independent collections of classes, methods, fields, and imports
|
|
604
|
+
- Inconsistent data structures across different analysis modes
|
|
605
|
+
- Complex maintenance and potential inconsistencies
|
|
606
|
+
|
|
607
|
+
#### **After (Unified Architecture):**
|
|
608
|
+
- **Single `elements` list**: All code elements (classes, methods, fields, imports, packages) unified
|
|
609
|
+
- **Consistent element types**: Each element has an `element_type` attribute for easy identification
|
|
610
|
+
- **Simplified API**: Clearer interfaces and reduced complexity
|
|
611
|
+
- **Better maintainability**: Single source of truth for all code elements
|
|
612
|
+
|
|
613
|
+
#### **Benefits:**
|
|
614
|
+
- ✅ **Consistency**: Unified data structures across all analysis modes
|
|
615
|
+
- ✅ **Simplicity**: Easier to use and understand
|
|
616
|
+
- ✅ **Extensibility**: Easy to add new element types
|
|
617
|
+
- ✅ **Performance**: Optimized memory usage and processing
|
|
618
|
+
- ✅ **Backward compatibility**: Existing APIs continue to work seamlessly
|
|
619
|
+
|
|
620
|
+
#### **Supported Element Types:**
|
|
621
|
+
- `class` - Classes and interfaces
|
|
622
|
+
- `function` - Methods and functions
|
|
623
|
+
- `variable` - Fields and variables
|
|
624
|
+
- `import` - Import statements
|
|
625
|
+
- `package` - Package declarations
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
477
629
|
## 🛠️ Core Features
|
|
478
630
|
|
|
479
631
|
### 📊 **Code Structure Analysis**
|
|
480
632
|
Get insights without reading complete files:
|
|
481
|
-
- Class, method, field statistics
|
|
633
|
+
- Class, method, and field statistics
|
|
482
634
|
- Package information and import dependencies
|
|
483
635
|
- Complexity metrics
|
|
484
636
|
- Precise line number positioning
|
|
485
637
|
|
|
486
638
|
### ✂️ **Smart Code Extraction**
|
|
487
|
-
-
|
|
488
|
-
-
|
|
489
|
-
-
|
|
490
|
-
-
|
|
639
|
+
- Precise extraction by line range
|
|
640
|
+
- Maintains original format and indentation
|
|
641
|
+
- Includes position metadata
|
|
642
|
+
- Supports efficient processing of large files
|
|
491
643
|
|
|
492
644
|
### 🔍 **Advanced Query Filtering**
|
|
493
|
-
Powerful code element
|
|
494
|
-
- **Exact matching**: `--filter "name=main"`
|
|
495
|
-
- **Pattern matching**: `--filter "name=~auth*"`
|
|
496
|
-
- **Parameter filtering**: `--filter "params=2"`
|
|
497
|
-
- **Modifier filtering**: `--filter "static=true,public=true"`
|
|
498
|
-
- **Compound conditions**: `--filter "name=~get*,params=0,public=true"`
|
|
499
|
-
- **CLI/MCP consistency**: Same filtering syntax in command line and AI assistants
|
|
645
|
+
Powerful code element query and filtering system:
|
|
646
|
+
- **Exact matching**: `--filter "name=main"` to find specific methods
|
|
647
|
+
- **Pattern matching**: `--filter "name=~auth*"` to find authentication-related methods
|
|
648
|
+
- **Parameter filtering**: `--filter "params=2"` to find methods with specific parameter counts
|
|
649
|
+
- **Modifier filtering**: `--filter "static=true,public=true"` to find static public methods
|
|
650
|
+
- **Compound conditions**: `--filter "name=~get*,params=0,public=true"` to combine multiple conditions
|
|
651
|
+
- **CLI/MCP consistency**: Same filtering syntax used in command line and AI assistants
|
|
500
652
|
|
|
501
653
|
### 🔗 **AI Assistant Integration**
|
|
502
|
-
Deep integration
|
|
654
|
+
Deep integration through MCP protocol:
|
|
503
655
|
- Claude Desktop
|
|
504
656
|
- Cursor IDE
|
|
505
657
|
- Roo Code
|
|
506
|
-
- Other MCP-
|
|
658
|
+
- Other MCP-compatible AI tools
|
|
507
659
|
|
|
508
|
-
### 🌍 **Multi-
|
|
660
|
+
### 🌍 **Multi-language Support**
|
|
509
661
|
- **Java** - Full support, including Spring, JPA frameworks
|
|
510
|
-
- **Python** -
|
|
662
|
+
- **Python** - Full support, including type annotations, decorators
|
|
511
663
|
- **JavaScript/TypeScript** - Full support, including ES6+ features
|
|
512
664
|
- **C/C++, Rust, Go** - Basic support
|
|
513
665
|
|
|
@@ -520,13 +672,13 @@ Deep integration via MCP protocol:
|
|
|
520
672
|
# Basic installation
|
|
521
673
|
uv add tree-sitter-analyzer
|
|
522
674
|
|
|
523
|
-
# Popular
|
|
675
|
+
# Popular language packages (recommended)
|
|
524
676
|
uv add "tree-sitter-analyzer[popular]"
|
|
525
677
|
|
|
526
678
|
# MCP server support
|
|
527
679
|
uv add "tree-sitter-analyzer[mcp]"
|
|
528
680
|
|
|
529
|
-
#
|
|
681
|
+
# Complete installation
|
|
530
682
|
uv add "tree-sitter-analyzer[all,mcp]"
|
|
531
683
|
```
|
|
532
684
|
|
|
@@ -539,16 +691,16 @@ uv sync --extra all --extra mcp
|
|
|
539
691
|
|
|
540
692
|
---
|
|
541
693
|
|
|
542
|
-
## 🔒 Security
|
|
694
|
+
## 🔒 Security and Configuration
|
|
543
695
|
|
|
544
696
|
### 🛡️ **Project Boundary Protection**
|
|
545
697
|
|
|
546
698
|
Tree-sitter Analyzer automatically detects and protects project boundaries:
|
|
547
699
|
|
|
548
700
|
- **Auto-detection**: Based on `.git`, `pyproject.toml`, `package.json`, etc.
|
|
549
|
-
- **CLI
|
|
550
|
-
- **MCP
|
|
551
|
-
- **Security
|
|
701
|
+
- **CLI control**: `--project-root /path/to/project`
|
|
702
|
+
- **MCP integration**: `TREE_SITTER_PROJECT_ROOT=/path/to/project` or use auto-detection
|
|
703
|
+
- **Security guarantee**: Only analyze files within project boundaries
|
|
552
704
|
|
|
553
705
|
**Recommended MCP Configuration:**
|
|
554
706
|
|
|
@@ -564,7 +716,7 @@ Tree-sitter Analyzer automatically detects and protects project boundaries:
|
|
|
564
716
|
}
|
|
565
717
|
```
|
|
566
718
|
|
|
567
|
-
**Option 2:
|
|
719
|
+
**Option 2: Manually specify project root directory**
|
|
568
720
|
```json
|
|
569
721
|
{
|
|
570
722
|
"mcpServers": {
|
|
@@ -582,17 +734,17 @@ Tree-sitter Analyzer automatically detects and protects project boundaries:
|
|
|
582
734
|
## 🏆 Quality Assurance
|
|
583
735
|
|
|
584
736
|
### 📊 **Quality Metrics**
|
|
585
|
-
- **1,
|
|
586
|
-
- **74.
|
|
587
|
-
- **Zero
|
|
588
|
-
- **Cross-platform
|
|
589
|
-
|
|
590
|
-
### ⚡ **Latest Quality Achievements (v1.
|
|
591
|
-
- ✅ **Cross-
|
|
592
|
-
- ✅ **Windows
|
|
593
|
-
- ✅ **macOS
|
|
594
|
-
- ✅ **Comprehensive
|
|
595
|
-
- ✅ **GitFlow
|
|
737
|
+
- **1,514 tests** - 100% pass rate ✅
|
|
738
|
+
- **74.24% code coverage** - Industry-leading level
|
|
739
|
+
- **Zero test failures** - Fully CI/CD ready
|
|
740
|
+
- **Cross-platform compatibility** - Windows, macOS, Linux
|
|
741
|
+
|
|
742
|
+
### ⚡ **Latest Quality Achievements (v1.2.2)**
|
|
743
|
+
- ✅ **Cross-platform path compatibility** - Fixed Windows short path names and macOS symbolic link differences
|
|
744
|
+
- ✅ **Windows environment** - Implemented robust path normalization using Windows API
|
|
745
|
+
- ✅ **macOS environment** - Fixed `/var` vs `/private/var` symbolic link differences
|
|
746
|
+
- ✅ **Comprehensive test coverage** - 1514 tests, 74.24% coverage
|
|
747
|
+
- ✅ **GitFlow implementation** - Professional development/release branch strategy. See [GitFlow documentation](GITFLOW.md) for details.
|
|
596
748
|
|
|
597
749
|
### ⚙️ **Running Tests**
|
|
598
750
|
```bash
|
|
@@ -607,11 +759,11 @@ uv run pytest tests/test_mcp_server_initialization.py -v
|
|
|
607
759
|
```
|
|
608
760
|
|
|
609
761
|
### 📈 **Coverage Highlights**
|
|
610
|
-
- **Language
|
|
611
|
-
- **CLI
|
|
612
|
-
- **Query
|
|
613
|
-
- **Query
|
|
614
|
-
- **Error
|
|
762
|
+
- **Language detector**: 98.41% (Excellent)
|
|
763
|
+
- **CLI main entry**: 94.36% (Excellent)
|
|
764
|
+
- **Query filtering system**: 96.06% (Excellent)
|
|
765
|
+
- **Query service**: 86.25% (Good)
|
|
766
|
+
- **Error handling**: 82.76% (Good)
|
|
615
767
|
|
|
616
768
|
---
|
|
617
769
|
|
|
@@ -619,10 +771,10 @@ uv run pytest tests/test_mcp_server_initialization.py -v
|
|
|
619
771
|
|
|
620
772
|
### ⚡ **Optimized for AI Development**
|
|
621
773
|
|
|
622
|
-
This project supports AI-assisted development with
|
|
774
|
+
This project supports AI-assisted development with dedicated quality control:
|
|
623
775
|
|
|
624
776
|
```bash
|
|
625
|
-
# AI system
|
|
777
|
+
# AI system code generation pre-check
|
|
626
778
|
uv run python check_quality.py --new-code-only
|
|
627
779
|
uv run python llm_code_checker.py --check-all
|
|
628
780
|
|
|
@@ -643,22 +795,23 @@ uv run python llm_code_checker.py path/to/new_file.py
|
|
|
643
795
|
- **[Project Root Configuration](PROJECT_ROOT_CONFIG.md)** - Complete configuration reference
|
|
644
796
|
- **[API Documentation](docs/api.md)** - Detailed API reference
|
|
645
797
|
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute
|
|
798
|
+
- **[Takeover and Training Guide](training/README.md)** - System onboarding materials for new members/maintainers
|
|
646
799
|
|
|
647
800
|
---
|
|
648
801
|
|
|
649
802
|
## 🤝 Contributing
|
|
650
803
|
|
|
651
|
-
We welcome all forms of contributions! Please
|
|
804
|
+
We welcome all forms of contributions! Please see [Contributing Guide](CONTRIBUTING.md) for details.
|
|
652
805
|
|
|
653
806
|
### ⭐ **Give Us a Star!**
|
|
654
807
|
|
|
655
|
-
If this project
|
|
808
|
+
If this project has been helpful to you, please give us a ⭐ on GitHub - this is the greatest support for us!
|
|
656
809
|
|
|
657
810
|
---
|
|
658
811
|
|
|
659
812
|
## 📄 License
|
|
660
813
|
|
|
661
|
-
MIT License -
|
|
814
|
+
MIT License - See [LICENSE](LICENSE) file for details.
|
|
662
815
|
|
|
663
816
|
---
|
|
664
817
|
|
|
@@ -666,4 +819,22 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
666
819
|
|
|
667
820
|
*Let every line of code be understood by AI, let every project break through token limits*
|
|
668
821
|
|
|
822
|
+
---
|
|
823
|
+
|
|
824
|
+
## ✅ Prompt Testing Verification
|
|
825
|
+
|
|
826
|
+
All AI prompts in this document have been thoroughly tested in real environments, ensuring:
|
|
827
|
+
|
|
828
|
+
- **100% Availability** - All prompts work correctly
|
|
829
|
+
- **Multi-language Support** - Supports Java, Python, JavaScript and other mainstream languages
|
|
830
|
+
- **Path Compatibility** - Both relative and absolute paths are fully supported
|
|
831
|
+
- **Windows/Linux Compatibility** - Cross-platform path formats are automatically handled
|
|
832
|
+
- **Real-time Verification** - Tested using real code files
|
|
833
|
+
|
|
834
|
+
**Test Environment:**
|
|
835
|
+
- Operating System: Windows 10
|
|
836
|
+
- Project: tree-sitter-analyzer v1.2.0
|
|
837
|
+
- Test Files: BigService.java (1419 lines), sample.py (256 lines), MultiClass.java (54 lines)
|
|
838
|
+
- Test Tools: All MCP tools (check_code_scale, analyze_code_structure, extract_code_section, query_code)
|
|
839
|
+
|
|
669
840
|
**🚀 Start Now** → [30-Second Quick Start](#-30-second-quick-start)
|