tree-sitter-analyzer 1.6.2__py3-none-any.whl → 1.7.1__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/__init__.py +1 -1
- tree_sitter_analyzer/formatters/javascript_formatter.py +113 -13
- tree_sitter_analyzer/formatters/python_formatter.py +57 -15
- tree_sitter_analyzer/languages/java_plugin.py +68 -7
- tree_sitter_analyzer/languages/javascript_plugin.py +43 -1
- tree_sitter_analyzer/languages/python_plugin.py +157 -49
- tree_sitter_analyzer/languages/typescript_plugin.py +241 -65
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +10 -0
- tree_sitter_analyzer/mcp/server.py +73 -18
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +21 -1
- tree_sitter_analyzer/mcp/utils/gitignore_detector.py +36 -17
- tree_sitter_analyzer/project_detector.py +6 -8
- tree_sitter_analyzer/utils.py +26 -5
- {tree_sitter_analyzer-1.6.2.dist-info → tree_sitter_analyzer-1.7.1.dist-info}/METADATA +198 -222
- {tree_sitter_analyzer-1.6.2.dist-info → tree_sitter_analyzer-1.7.1.dist-info}/RECORD +17 -17
- {tree_sitter_analyzer-1.6.2.dist-info → tree_sitter_analyzer-1.7.1.dist-info}/entry_points.txt +1 -0
- {tree_sitter_analyzer-1.6.2.dist-info → tree_sitter_analyzer-1.7.1.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tree-sitter-analyzer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.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
|
|
@@ -159,81 +159,75 @@ Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'web'
|
|
|
159
159
|
Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'web'
|
|
160
160
|
Description-Content-Type: text/markdown
|
|
161
161
|
|
|
162
|
-
# Tree-sitter Analyzer
|
|
162
|
+
# 🌳 Tree-sitter Analyzer
|
|
163
163
|
|
|
164
164
|
**English** | **[日本語](README_ja.md)** | **[简体中文](README_zh.md)**
|
|
165
165
|
|
|
166
166
|
[](https://python.org)
|
|
167
167
|
[](LICENSE)
|
|
168
|
-
[](#quality-assurance)
|
|
169
|
+
[](#quality-assurance)
|
|
170
170
|
[](#quality-assurance)
|
|
171
171
|
[](https://pypi.org/project/tree-sitter-analyzer/)
|
|
172
|
-
[](https://github.com/aimasteracc/tree-sitter-analyzer/releases)
|
|
173
173
|
[](https://github.com/aimasteracc/tree-sitter-analyzer)
|
|
174
174
|
|
|
175
175
|
## 🚀 Enterprise-Grade Code Analysis Tool for the AI Era
|
|
176
176
|
|
|
177
|
-
> **Deep AI Integration · Powerful File Search ·
|
|
177
|
+
> **Deep AI Integration · Powerful File Search · Multilingual Support · Intelligent Code Analysis**
|
|
178
178
|
|
|
179
179
|
## 📋 Table of Contents
|
|
180
180
|
|
|
181
|
-
- [💡
|
|
182
|
-
- [📋 Prerequisites (Required for All Users)](
|
|
183
|
-
- [🚀 Quick Start](
|
|
184
|
-
- [🤖 AI Users (Claude Desktop, Cursor, etc.)](
|
|
185
|
-
- [💻 CLI Users (Command Line Tools)](
|
|
186
|
-
- [👨💻 Developers (Source Development)](
|
|
187
|
-
- [📖 Usage Workflow & Examples](
|
|
188
|
-
- [🔄 AI Assistant SMART Workflow](
|
|
189
|
-
|
|
190
|
-
- [
|
|
191
|
-
- [
|
|
192
|
-
- [
|
|
193
|
-
- [
|
|
181
|
+
- [1. 💡 Project Features](#1--project-features)
|
|
182
|
+
- [2. 📋 Prerequisites (Required for All Users)](#2--prerequisites-required-for-all-users)
|
|
183
|
+
- [3. 🚀 Quick Start](#3--quick-start)
|
|
184
|
+
- [3.1 🤖 AI Users (Claude Desktop, Cursor, etc.)](#31--ai-users-claude-desktop-cursor-etc)
|
|
185
|
+
- [3.2 💻 CLI Users (Command Line Tools)](#32--cli-users-command-line-tools)
|
|
186
|
+
- [3.3 👨💻 Developers (Source Code Development)](#33--developers-source-code-development)
|
|
187
|
+
- [4. 📖 Usage Workflow & Examples](#4--usage-workflow--examples)
|
|
188
|
+
- [4.1 🔄 AI Assistant SMART Workflow](#41--ai-assistant-smart-workflow)
|
|
189
|
+
- [5. 🤖 Complete MCP Tool List](#5--complete-mcp-tool-list)
|
|
190
|
+
- [6. ⚡ Complete CLI Commands](#6--complete-cli-commands)
|
|
191
|
+
- [7. 🛠️ Core Features](#7-️-core-features)
|
|
192
|
+
- [8. 🏆 Quality Assurance](#8--quality-assurance)
|
|
193
|
+
- [9. 📚 Documentation & Support](#9--documentation--support)
|
|
194
|
+
- [10. 🤝 Contributing & License](#10--contributing--license)
|
|
194
195
|
|
|
195
196
|
---
|
|
196
197
|
|
|
197
|
-
## 💡
|
|
198
|
+
## 1. 💡 Project Features
|
|
198
199
|
|
|
199
200
|
Tree-sitter Analyzer is an enterprise-grade code analysis tool designed for the AI era, providing:
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
###
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
### 🌍 Enterprise-Grade Multi-Language Support
|
|
220
|
-
- **Java** - Full support (1103 lines of plugin code, 73% coverage), including Spring, JPA frameworks
|
|
221
|
-
- **Python** - Full support (584 lines of plugin code, 63% coverage), including type annotations, decorators
|
|
222
|
-
- **JavaScript** - Enterprise-grade support (1445 lines of plugin code, 68% coverage), including ES6+, React/Vue/Angular, JSX
|
|
223
|
-
- **TypeScript** - **Complete support** (1553 lines of plugin code, 29% coverage), including interfaces, types, decorators, TSX/JSX, framework detection
|
|
224
|
-
- **More Languages** - Basic support for C/C++, Rust, Go
|
|
202
|
+
| Feature Category | Key Capabilities | Core Benefits |
|
|
203
|
+
|------------------|------------------|---------------|
|
|
204
|
+
| **🤖 Deep AI Integration** | • MCP Protocol Support<br>• SMART Workflow<br>• Token Limitation Breaking<br>• Natural Language Interaction | Native support for Claude Desktop, Cursor, Roo Code<br>Systematic AI-assisted methodology<br>Handle code files of any size<br>Complex analysis via natural language |
|
|
205
|
+
| **🔍 Powerful Search** | • Intelligent File Discovery<br>• Precise Content Search<br>• Two-Stage Search<br>• Project Boundary Protection | fd-based high-performance search<br>ripgrep regex content search<br>Combined file + content workflow<br>Automatic security boundaries |
|
|
206
|
+
| **📊 Intelligent Analysis** | • Fast Structure Analysis<br>• Precise Code Extraction<br>• Complexity Analysis<br>• Unified Element System | Architecture understanding without full read<br>Line-range code snippet extraction<br>Cyclomatic complexity metrics<br>Revolutionary element management |
|
|
207
|
+
|
|
208
|
+
### 🌍 Enterprise Multi-language Support
|
|
209
|
+
|
|
210
|
+
| Programming Language | Support Level | Key Features |
|
|
211
|
+
|---------------------|---------------|--------------|
|
|
212
|
+
| **Java** | Complete Support | Spring framework, JPA, enterprise features |
|
|
213
|
+
| **Python** | Complete Support | Type annotations, decorators, modern Python features |
|
|
214
|
+
| **JavaScript** | Complete Support | ES6+, React/Vue/Angular, JSX |
|
|
215
|
+
| **TypeScript** | Complete Support | Interfaces, types, decorators, TSX/JSX, framework detection |
|
|
216
|
+
| **C/C++** | Basic Support | Basic syntax parsing |
|
|
217
|
+
| **Rust** | Basic Support | Basic syntax parsing |
|
|
218
|
+
| **Go** | Basic Support | Basic syntax parsing |
|
|
225
219
|
|
|
226
220
|
### 🏆 Production Ready
|
|
227
|
-
- **2,
|
|
228
|
-
- **
|
|
229
|
-
- **Cross-
|
|
221
|
+
- **2,662 Tests** - 100% pass rate, enterprise-grade quality assurance
|
|
222
|
+
- **79.16% Coverage** - Comprehensive test coverage
|
|
223
|
+
- **Cross-platform Support** - Compatible with Windows, macOS, Linux
|
|
230
224
|
- **Continuous Maintenance** - Active development and community support
|
|
231
225
|
|
|
232
226
|
---
|
|
233
227
|
|
|
234
|
-
## 📋 Prerequisites (Required for All Users)
|
|
228
|
+
## 2. 📋 Prerequisites (Required for All Users)
|
|
235
229
|
|
|
236
|
-
|
|
230
|
+
Regardless of whether you are an AI user, CLI user, or developer, you need to install the following tools first:
|
|
237
231
|
|
|
238
232
|
### 1️⃣ Install uv (Required - for running tools)
|
|
239
233
|
|
|
@@ -254,28 +248,17 @@ uv --version
|
|
|
254
248
|
|
|
255
249
|
### 2️⃣ Install fd and ripgrep (Required for search functionality)
|
|
256
250
|
|
|
257
|
-
**fd** and **ripgrep** are high-performance file and content search tools used for advanced MCP
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
# macOS
|
|
261
|
-
brew install fd ripgrep
|
|
262
|
-
|
|
263
|
-
# Windows (recommended using winget)
|
|
264
|
-
winget install sharkdp.fd BurntSushi.ripgrep.MSVC
|
|
265
|
-
|
|
266
|
-
# Windows (alternative methods)
|
|
267
|
-
# choco install fd ripgrep
|
|
268
|
-
# scoop install fd ripgrep
|
|
251
|
+
**fd** and **ripgrep** are high-performance file search and content search tools used for advanced MCP functionality.
|
|
269
252
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
sudo
|
|
278
|
-
|
|
253
|
+
| Operating System | Package Manager | Installation Command | Notes |
|
|
254
|
+
|-----------------|----------------|---------------------|-------|
|
|
255
|
+
| **macOS** | Homebrew | `brew install fd ripgrep` | Recommended |
|
|
256
|
+
| **Windows** | winget | `winget install sharkdp.fd BurntSushi.ripgrep.MSVC` | Recommended |
|
|
257
|
+
| | Chocolatey | `choco install fd ripgrep` | Alternative |
|
|
258
|
+
| | Scoop | `scoop install fd ripgrep` | Alternative |
|
|
259
|
+
| **Ubuntu/Debian** | apt | `sudo apt install fd-find ripgrep` | Official repository |
|
|
260
|
+
| **CentOS/RHEL/Fedora** | dnf | `sudo dnf install fd-find ripgrep` | Official repository |
|
|
261
|
+
| **Arch Linux** | pacman | `sudo pacman -S fd ripgrep` | Official repository |
|
|
279
262
|
|
|
280
263
|
**Verify installation:**
|
|
281
264
|
```bash
|
|
@@ -284,15 +267,15 @@ rg --version
|
|
|
284
267
|
```
|
|
285
268
|
|
|
286
269
|
> **⚠️ Important Note:**
|
|
287
|
-
> - **uv** is required for running all
|
|
270
|
+
> - **uv** is required for running all functionality
|
|
288
271
|
> - **fd** and **ripgrep** are required for using advanced file search and content analysis features
|
|
289
|
-
> - If fd and ripgrep are not installed, basic code analysis
|
|
272
|
+
> - If fd and ripgrep are not installed, basic code analysis functionality will still be available, but file search features will not work
|
|
290
273
|
|
|
291
274
|
---
|
|
292
275
|
|
|
293
|
-
## 🚀 Quick Start
|
|
276
|
+
## 3. 🚀 Quick Start
|
|
294
277
|
|
|
295
|
-
### 🤖 AI Users (Claude Desktop, Cursor, etc.)
|
|
278
|
+
### 3.1 🤖 AI Users (Claude Desktop, Cursor, etc.)
|
|
296
279
|
|
|
297
280
|
**For:** Users who use AI assistants (such as Claude Desktop, Cursor) for code analysis
|
|
298
281
|
|
|
@@ -301,13 +284,13 @@ rg --version
|
|
|
301
284
|
**Claude Desktop Configuration:**
|
|
302
285
|
|
|
303
286
|
1. Find the configuration file location:
|
|
304
|
-
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
305
|
-
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
306
|
-
- **Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
287
|
+
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
288
|
+
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
289
|
+
- **Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
307
290
|
|
|
308
291
|
2. Add the following configuration:
|
|
309
292
|
|
|
310
|
-
**Basic Configuration (Recommended -
|
|
293
|
+
**Basic Configuration (Recommended - auto-detect project path):**
|
|
311
294
|
```json
|
|
312
295
|
{
|
|
313
296
|
"mcpServers": {
|
|
@@ -322,7 +305,7 @@ rg --version
|
|
|
322
305
|
}
|
|
323
306
|
```
|
|
324
307
|
|
|
325
|
-
**Advanced Configuration (
|
|
308
|
+
**Advanced Configuration (manually specify project path):**
|
|
326
309
|
```json
|
|
327
310
|
{
|
|
328
311
|
"mcpServers": {
|
|
@@ -341,7 +324,7 @@ rg --version
|
|
|
341
324
|
}
|
|
342
325
|
```
|
|
343
326
|
|
|
344
|
-
3. Restart
|
|
327
|
+
3. Restart AI client
|
|
345
328
|
|
|
346
329
|
4. Start using! Tell the AI:
|
|
347
330
|
```
|
|
@@ -355,9 +338,9 @@ rg --version
|
|
|
355
338
|
|
|
356
339
|
---
|
|
357
340
|
|
|
358
|
-
### 💻 CLI Users (Command Line Tools)
|
|
341
|
+
### 3.2 💻 CLI Users (Command Line Tools)
|
|
359
342
|
|
|
360
|
-
**For:** Developers who prefer using command
|
|
343
|
+
**For:** Developers who prefer using command line tools
|
|
361
344
|
|
|
362
345
|
#### 📦 Installation
|
|
363
346
|
|
|
@@ -365,10 +348,10 @@ rg --version
|
|
|
365
348
|
# Basic installation
|
|
366
349
|
uv add tree-sitter-analyzer
|
|
367
350
|
|
|
368
|
-
# Popular language
|
|
351
|
+
# Popular language packages (recommended)
|
|
369
352
|
uv add "tree-sitter-analyzer[popular]"
|
|
370
353
|
|
|
371
|
-
#
|
|
354
|
+
# Complete installation (including MCP support)
|
|
372
355
|
uv add "tree-sitter-analyzer[all,mcp]"
|
|
373
356
|
```
|
|
374
357
|
|
|
@@ -378,10 +361,10 @@ uv add "tree-sitter-analyzer[all,mcp]"
|
|
|
378
361
|
# View help
|
|
379
362
|
uv run python -m tree_sitter_analyzer --help
|
|
380
363
|
|
|
381
|
-
# Analyze file
|
|
364
|
+
# Analyze large file scale (1419 lines completed instantly)
|
|
382
365
|
uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
|
|
383
366
|
|
|
384
|
-
# Generate detailed structure table
|
|
367
|
+
# Generate detailed structure table for code files
|
|
385
368
|
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
|
|
386
369
|
|
|
387
370
|
# Precise code extraction
|
|
@@ -390,9 +373,9 @@ uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --
|
|
|
390
373
|
|
|
391
374
|
---
|
|
392
375
|
|
|
393
|
-
### 👨💻 Developers (Source Development)
|
|
376
|
+
### 3.3 👨💻 Developers (Source Code Development)
|
|
394
377
|
|
|
395
|
-
**For:** Developers who need to modify source code or contribute
|
|
378
|
+
**For:** Developers who need to modify source code or contribute code
|
|
396
379
|
|
|
397
380
|
#### 🛠️ Development Environment Setup
|
|
398
381
|
|
|
@@ -414,20 +397,20 @@ uv run pytest tests/ --cov=tree_sitter_analyzer --cov-report=html
|
|
|
414
397
|
#### 🔍 Code Quality Checks
|
|
415
398
|
|
|
416
399
|
```bash
|
|
417
|
-
# AI-generated code
|
|
400
|
+
# AI-generated code checks
|
|
418
401
|
uv run python llm_code_checker.py --check-all
|
|
419
402
|
|
|
420
|
-
# Quality
|
|
403
|
+
# Quality checks
|
|
421
404
|
uv run python check_quality.py --new-code-only
|
|
422
405
|
```
|
|
423
406
|
|
|
424
407
|
---
|
|
425
408
|
|
|
426
|
-
## 📖 Usage Workflow & Examples
|
|
409
|
+
## 4. 📖 Usage Workflow & Examples
|
|
427
410
|
|
|
428
|
-
### 🔄 AI Assistant SMART Workflow
|
|
411
|
+
### 4.1 🔄 AI Assistant SMART Workflow
|
|
429
412
|
|
|
430
|
-
The SMART workflow is the recommended process for analyzing code using AI assistants. The following demonstrates the complete
|
|
413
|
+
The SMART workflow is the recommended process for analyzing code using AI assistants. The following demonstrates the complete process using `examples/BigService.java` (a large service class with 1419 lines):
|
|
431
414
|
|
|
432
415
|
- **S** (Set): Set project root directory
|
|
433
416
|
- **M** (Map): Precisely map target files
|
|
@@ -444,9 +427,9 @@ The SMART workflow is the recommended process for analyzing code using AI assist
|
|
|
444
427
|
Please set the project root directory to: C:\git-public\tree-sitter-analyzer
|
|
445
428
|
```
|
|
446
429
|
|
|
447
|
-
**
|
|
430
|
+
**AI will automatically call** the `set_project_path` tool.
|
|
448
431
|
|
|
449
|
-
> 💡 **Tip**: You can also pre-set this through the `TREE_SITTER_PROJECT_ROOT`
|
|
432
|
+
> 💡 **Tip**: You can also pre-set this through the environment variable `TREE_SITTER_PROJECT_ROOT` in MCP configuration.
|
|
450
433
|
|
|
451
434
|
---
|
|
452
435
|
|
|
@@ -458,7 +441,7 @@ Please set the project root directory to: C:\git-public\tree-sitter-analyzer
|
|
|
458
441
|
Find all Java files containing "BigService" in the project
|
|
459
442
|
```
|
|
460
443
|
|
|
461
|
-
**
|
|
444
|
+
**AI will call** the `find_and_grep` tool and return showing 8 matches in BigService.java.
|
|
462
445
|
|
|
463
446
|
**Scenario 2: Known file path, use directly**
|
|
464
447
|
```
|
|
@@ -467,14 +450,14 @@ I want to analyze the file examples/BigService.java
|
|
|
467
450
|
|
|
468
451
|
---
|
|
469
452
|
|
|
470
|
-
#### **A - Analyze Core Structure (Understand file
|
|
453
|
+
#### **A - Analyze Core Structure (Understand file scale and organization)**
|
|
471
454
|
|
|
472
455
|
**Tell the AI:**
|
|
473
456
|
```
|
|
474
|
-
Please analyze the structure of examples/BigService.java, I want to know how
|
|
457
|
+
Please analyze the structure of examples/BigService.java, I want to know how big this file is and what main components it contains
|
|
475
458
|
```
|
|
476
459
|
|
|
477
|
-
**
|
|
460
|
+
**AI will call** the `analyze_code_structure` tool and return:
|
|
478
461
|
```json
|
|
479
462
|
{
|
|
480
463
|
"file_path": "examples/BigService.java",
|
|
@@ -504,18 +487,18 @@ Please analyze the structure of examples/BigService.java, I want to know how lar
|
|
|
504
487
|
**Key Information:**
|
|
505
488
|
|
|
506
489
|
- File has **1419 lines** total
|
|
507
|
-
- Contains **1 class**, **66 methods**, **9 fields**, **1 package**, **total
|
|
490
|
+
- Contains **1 class**, **66 methods**, **9 fields**, **1 package**, **total 85 elements**
|
|
508
491
|
|
|
509
492
|
---
|
|
510
493
|
|
|
511
|
-
#### **R - Retrieve Key Code (Deep
|
|
494
|
+
#### **R - Retrieve Key Code (Deep understanding of specific implementations)**
|
|
512
495
|
|
|
513
496
|
**Scenario 1: View complete structure table**
|
|
514
497
|
```
|
|
515
498
|
Please generate a detailed structure table for examples/BigService.java, I want to see a list of all methods
|
|
516
499
|
```
|
|
517
500
|
|
|
518
|
-
**
|
|
501
|
+
**AI will generate a Markdown table containing:**
|
|
519
502
|
|
|
520
503
|
- Class information: package name, type, visibility, line range
|
|
521
504
|
- Field list: 9 fields (DEFAULT_ENCODING, MAX_RETRY_COUNT, etc.)
|
|
@@ -525,10 +508,10 @@ Please generate a detailed structure table for examples/BigService.java, I want
|
|
|
525
508
|
|
|
526
509
|
**Scenario 2: Extract specific code snippet**
|
|
527
510
|
```
|
|
528
|
-
Please extract lines 93-106
|
|
511
|
+
Please extract lines 93-106 from examples/BigService.java, I want to see the specific implementation of memory checking
|
|
529
512
|
```
|
|
530
513
|
|
|
531
|
-
**
|
|
514
|
+
**AI will call** the `extract_code_section` tool and return the code for the checkMemoryUsage method.
|
|
532
515
|
|
|
533
516
|
---
|
|
534
517
|
|
|
@@ -539,14 +522,14 @@ Please extract lines 93-106 of examples/BigService.java, I want to see the speci
|
|
|
539
522
|
Find all methods related to authentication (auth) in examples/BigService.java
|
|
540
523
|
```
|
|
541
524
|
|
|
542
|
-
**
|
|
525
|
+
**AI will call query filtering** and return the authenticateUser method code (lines 141-172).
|
|
543
526
|
|
|
544
|
-
**Scenario 2: Find entry
|
|
527
|
+
**Scenario 2: Find entry points**
|
|
545
528
|
```
|
|
546
529
|
Where is the main method in this file? What does it do?
|
|
547
530
|
```
|
|
548
531
|
|
|
549
|
-
**
|
|
532
|
+
**AI will locate:**
|
|
550
533
|
|
|
551
534
|
- **Location**: Lines 1385-1418
|
|
552
535
|
- **Function**: Demonstrates various features of BigService (authentication, sessions, customer management, report generation, performance monitoring, security checks)
|
|
@@ -556,7 +539,7 @@ Where is the main method in this file? What does it do?
|
|
|
556
539
|
Which methods call the authenticateUser method?
|
|
557
540
|
```
|
|
558
541
|
|
|
559
|
-
**
|
|
542
|
+
**AI will search the code** and find the call in the `main` method:
|
|
560
543
|
```java
|
|
561
544
|
service.authenticateUser("testuser", "password123");
|
|
562
545
|
```
|
|
@@ -565,35 +548,63 @@ service.authenticateUser("testuser", "password123");
|
|
|
565
548
|
|
|
566
549
|
### 💡 SMART Workflow Best Practices
|
|
567
550
|
|
|
568
|
-
1. **Natural
|
|
569
|
-
2. **
|
|
570
|
-
3. **
|
|
571
|
-
4. **Combined
|
|
551
|
+
1. **Natural language first**: Describe your needs in natural language, and AI will automatically select appropriate tools
|
|
552
|
+
2. **Step-by-step approach**: First understand the overall structure (A), then dive into specific code (R)
|
|
553
|
+
3. **Use tracking when needed**: Only use tracking (T) when you need to understand complex relationships
|
|
554
|
+
4. **Combined usage**: You can combine multiple steps in one conversation
|
|
572
555
|
|
|
573
|
-
**Complete
|
|
556
|
+
**Complete example conversation:**
|
|
574
557
|
```
|
|
575
558
|
I want to understand the large file examples/BigService.java:
|
|
576
|
-
1. How
|
|
559
|
+
1. How big is it? What main features does it contain?
|
|
577
560
|
2. How is the authentication feature implemented?
|
|
578
|
-
3. What public API methods are
|
|
561
|
+
3. What public API methods are available?
|
|
579
562
|
```
|
|
580
563
|
|
|
581
|
-
|
|
564
|
+
AI will automatically:
|
|
582
565
|
1. Analyze file structure (1419 lines, 66 methods)
|
|
583
566
|
2. Locate and extract the `authenticateUser` method (lines 141-172)
|
|
584
|
-
3. Generate
|
|
567
|
+
3. Generate list of public methods (19 public methods)
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
## 5. 🤖 Complete MCP Tool List
|
|
572
|
+
|
|
573
|
+
Tree-sitter Analyzer provides a rich set of MCP tools designed for AI assistants:
|
|
574
|
+
|
|
575
|
+
| Tool Category | Tool Name | Main Function | Core Features |
|
|
576
|
+
|-------------|---------|---------|---------|
|
|
577
|
+
| **📊 Code Analysis** | `check_code_scale` | Fast code file scale analysis | File size statistics, line count statistics, complexity analysis, performance metrics |
|
|
578
|
+
| | `analyze_code_structure` | Code structure analysis and table generation | 🆕 suppress_output parameter, multiple formats (full/compact/csv/json), automatic language detection |
|
|
579
|
+
| | `extract_code_section` | Precise code section extraction | Specified line range extraction, large file efficient processing, original format preservation |
|
|
580
|
+
| **🔍 Intelligent Search** | `list_files` | High-performance file discovery | fd-based, glob patterns, file type filters, time range control |
|
|
581
|
+
| | `search_content` | Regex content search | ripgrep-based, multiple output formats, context control, encoding handling |
|
|
582
|
+
| | `find_and_grep` | Two-stage search | File discovery → content search, fd+ripgrep combination, intelligent cache optimization |
|
|
583
|
+
| **🔧 Advanced Queries** | `query_code` | tree-sitter queries | Predefined query keys, custom query strings, filter expression support |
|
|
584
|
+
| **⚙️ System Management** | `set_project_path` | Project root path setting | Security boundary control, automatic path validation |
|
|
585
|
+
| **📁 Resource Access** | Code file resources | URI code file access | File content access via URI identification |
|
|
586
|
+
| | Project statistics resources | Project statistics data access | Project analysis data and statistical information |
|
|
587
|
+
|
|
588
|
+
### 🆕 v1.7.0 New Feature: suppress_output Function
|
|
589
|
+
|
|
590
|
+
The newly added `suppress_output` parameter in the `analyze_code_structure` tool is a revolutionary token optimization feature:
|
|
591
|
+
|
|
592
|
+
- **Problem solved**: When analysis results are too large, traditional methods return complete table data, consuming massive tokens
|
|
593
|
+
- **Intelligent optimization**: When `suppress_output=true` and `output_file` specified, only basic metadata is returned
|
|
594
|
+
- **Significant effect**: Response size reduced by up to 99%, dramatically saving AI dialog token consumption
|
|
595
|
+
- **Use cases**: Particularly suitable for large code file structure analysis and batch processing scenarios
|
|
585
596
|
|
|
586
597
|
---
|
|
587
598
|
|
|
588
|
-
|
|
599
|
+
## 6. ⚡ Complete CLI Commands
|
|
589
600
|
|
|
590
601
|
#### 📊 Code Structure Analysis Commands
|
|
591
602
|
|
|
592
603
|
```bash
|
|
593
|
-
# Quick analysis (
|
|
604
|
+
# Quick analysis (show summary information)
|
|
594
605
|
uv run python -m tree_sitter_analyzer examples/BigService.java --summary
|
|
595
606
|
|
|
596
|
-
# Detailed analysis (
|
|
607
|
+
# Detailed analysis (show complete structure)
|
|
597
608
|
uv run python -m tree_sitter_analyzer examples/BigService.java --structure
|
|
598
609
|
|
|
599
610
|
# Advanced analysis (including complexity metrics)
|
|
@@ -621,7 +632,7 @@ uv run python -m tree_sitter_analyzer examples/BigService.java --query-key metho
|
|
|
621
632
|
uv run python -m tree_sitter_analyzer examples/BigService.java --query-key classes
|
|
622
633
|
|
|
623
634
|
# Filter query results
|
|
624
|
-
# Find specific
|
|
635
|
+
# Find specific methods
|
|
625
636
|
uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "name=main"
|
|
626
637
|
|
|
627
638
|
# Find authentication-related methods (pattern matching)
|
|
@@ -650,7 +661,7 @@ uv run search-content --roots . --query "class.*extends" --include-globs "*.java
|
|
|
650
661
|
uv run search-content --roots tests --query "TODO|FIXME" --context-before 2 --context-after 2
|
|
651
662
|
uv run search-content --files examples/BigService.java examples/Sample.java --query "public.*method" --case insensitive
|
|
652
663
|
|
|
653
|
-
# Two-stage search (find files
|
|
664
|
+
# Two-stage search (first find files, then search content)
|
|
654
665
|
uv run find-and-grep --roots . --query "@SpringBootApplication" --extensions java
|
|
655
666
|
uv run find-and-grep --roots examples --query "import.*SQLException" --extensions java --file-limit 10 --max-count 5
|
|
656
667
|
uv run find-and-grep --roots . --query "public.*static.*void" --extensions java --types f --size "+1k" --output-format json
|
|
@@ -659,88 +670,56 @@ uv run find-and-grep --roots . --query "public.*static.*void" --extensions java
|
|
|
659
670
|
#### ℹ️ Information Query Commands
|
|
660
671
|
|
|
661
672
|
```bash
|
|
662
|
-
#
|
|
673
|
+
# Show help
|
|
663
674
|
uv run python -m tree_sitter_analyzer --help
|
|
664
675
|
|
|
665
676
|
# List supported query keys
|
|
666
677
|
uv run python -m tree_sitter_analyzer --list-queries
|
|
667
678
|
|
|
668
|
-
#
|
|
679
|
+
# Show supported languages
|
|
669
680
|
uv run python -m tree_sitter_analyzer --show-supported-languages
|
|
670
681
|
|
|
671
|
-
#
|
|
682
|
+
# Show supported extensions
|
|
672
683
|
uv run python -m tree_sitter_analyzer --show-supported-extensions
|
|
673
684
|
|
|
674
|
-
#
|
|
685
|
+
# Show common queries
|
|
675
686
|
uv run python -m tree_sitter_analyzer --show-common-queries
|
|
676
687
|
|
|
677
|
-
#
|
|
688
|
+
# Show query language support
|
|
678
689
|
uv run python -m tree_sitter_analyzer --show-query-languages
|
|
679
690
|
```
|
|
680
691
|
|
|
681
692
|
---
|
|
682
693
|
|
|
683
|
-
## 🛠️ Core Features
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
-
|
|
689
|
-
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
-
|
|
693
|
-
-
|
|
694
|
-
- Include position metadata
|
|
695
|
-
- Efficient handling of large files
|
|
696
|
-
|
|
697
|
-
### 🔍 Advanced Query Filtering
|
|
698
|
-
- **Exact Match**: `--filter "name=main"`
|
|
699
|
-
- **Pattern Match**: `--filter "name=~auth*"`
|
|
700
|
-
- **Parameter Filter**: `--filter "params=2"`
|
|
701
|
-
- **Modifier Filter**: `--filter "static=true,public=true"`
|
|
702
|
-
- **Compound Conditions**: Combine multiple conditions for precise queries
|
|
703
|
-
|
|
704
|
-
### 🔗 AI Assistant Integration
|
|
705
|
-
- **Claude Desktop** - Full MCP support
|
|
706
|
-
- **Cursor IDE** - Built-in MCP integration
|
|
707
|
-
- **Roo Code** - MCP protocol support
|
|
708
|
-
- **Other MCP-compatible tools** - Universal MCP server
|
|
709
|
-
|
|
710
|
-
### 🌍 Multi-Language Support
|
|
711
|
-
- **Java** - Full support (1103 lines of plugin), including Spring, JPA frameworks
|
|
712
|
-
- **Python** - Full support (584 lines of plugin), including type annotations, decorators
|
|
713
|
-
- **JavaScript** - Enterprise-grade support (1445 lines of plugin), including ES6+, React/Vue/Angular, JSX
|
|
714
|
-
- **TypeScript** - **Complete support** (1553 lines of plugin), including interfaces, types, decorators, TSX/JSX, framework detection
|
|
715
|
-
- **C/C++, Rust, Go** - Basic support
|
|
716
|
-
|
|
717
|
-
### 📁 Advanced File Search
|
|
718
|
-
Powerful file discovery and content search based on fd and ripgrep:
|
|
719
|
-
- **ListFilesTool** - Intelligent file discovery with multiple filtering conditions
|
|
720
|
-
- **SearchContentTool** - Intelligent content search with regular expressions
|
|
721
|
-
- **FindAndGrepTool** - Combined discovery and search, two-stage workflow
|
|
722
|
-
|
|
723
|
-
### 🏗️ Unified Element System
|
|
724
|
-
- **Single Element List** - Unified management of all code elements (classes, methods, fields, imports, packages)
|
|
725
|
-
- **Consistent Element Types** - Each element has an `element_type` attribute
|
|
726
|
-
- **Simplified API** - Clearer interfaces and reduced complexity
|
|
727
|
-
- **Better Maintainability** - Single source of truth for all code elements
|
|
694
|
+
## 7. 🛠️ Core Features
|
|
695
|
+
|
|
696
|
+
| Feature Category | Feature Name | Core Capabilities | Technical Advantages |
|
|
697
|
+
|------------------|--------------|-------------------|---------------------|
|
|
698
|
+
| **📊 Code Structure Analysis** | Intelligent Parsing Engine | Class, method, and field statistics<br>Package information and import dependencies<br>Complexity metrics (cyclomatic complexity)<br>Precise line number positioning | Tree-sitter based high-precision parsing<br>Large enterprise codebase support<br>Real-time performance optimization |
|
|
699
|
+
| **✂️ Intelligent Code Extraction** | Precision Extraction Tool | Precise extraction by line range<br>Preserves original formatting and indentation<br>Includes position metadata<br>Efficient processing of large files | Zero-loss format preservation<br>Memory-optimized algorithms<br>Streaming processing support |
|
|
700
|
+
| **🔍 Advanced Query Filtering** | Multi-dimensional Filters | **Exact match**: `--filter "name=main"`<br>**Pattern match**: `--filter "name=~auth*"`<br>**Parameter filter**: `--filter "params=2"`<br>**Modifier filter**: `--filter "static=true,public=true"`<br>**Compound conditions**: Combine multiple conditions for precise queries | Flexible query syntax<br>High-performance indexing<br>Intelligent caching mechanisms |
|
|
701
|
+
| **🔗 AI Assistant Integration** | MCP Protocol Support | **Claude Desktop** - Full MCP support<br>**Cursor IDE** - Built-in MCP integration<br>**Roo Code** - MCP protocol support<br>**Other MCP-compatible tools** - Universal MCP server | Standard MCP protocol<br>Plug-and-play design<br>Cross-platform compatibility |
|
|
702
|
+
| **🌍 Multi-language Support** | Enterprise Language Engine | **Java** - Complete support, including Spring, JPA frameworks<br>**Python** - Complete support, including type annotations, decorators<br>**JavaScript** - Enterprise-grade support, including ES6+, React/Vue/Angular, JSX<br>**TypeScript** - **Complete support**, including interfaces, types, decorators, TSX/JSX, framework detection<br>**C/C++, Rust, Go** - Basic support | Framework-aware parsing<br>Syntax extension support<br>Continuous language updates |
|
|
703
|
+
| **📁 Advanced File Search** | fd+ripgrep Integration | **ListFilesTool** - Intelligent file discovery with multiple filtering conditions<br>**SearchContentTool** - Intelligent content search using regular expressions<br>**FindAndGrepTool** - Combined discovery and search, two-stage workflow | Rust-based high-performance tools<br>Parallel processing capabilities<br>Intelligent cache optimization |
|
|
704
|
+
| **🏗️ Unified Element System** | Revolutionary Architecture Design | **Single element list** - Unified management of all code elements (classes, methods, fields, imports, packages)<br>**Consistent element types** - Each element has an `element_type` attribute<br>**Simplified API** - Clearer interfaces and reduced complexity<br>**Better maintainability** - Single source of truth for all code elements | Unified data model<br>Type safety guarantees<br>Extensible design |
|
|
728
705
|
|
|
729
706
|
---
|
|
730
707
|
|
|
731
|
-
## 🏆 Quality Assurance
|
|
708
|
+
## 8. 🏆 Quality Assurance
|
|
732
709
|
|
|
733
710
|
### 📊 Quality Metrics
|
|
734
|
-
- **
|
|
735
|
-
- **
|
|
736
|
-
- **Zero
|
|
737
|
-
- **Cross-
|
|
738
|
-
|
|
739
|
-
### ⚡ Latest Quality Achievements (v1.
|
|
740
|
-
- ✅ **
|
|
741
|
-
- ✅ **
|
|
742
|
-
- ✅ **
|
|
743
|
-
- ✅ **
|
|
711
|
+
- **2,662 tests** - 100% pass rate ✅
|
|
712
|
+
- **79.16% code coverage** - Comprehensive test suite
|
|
713
|
+
- **Zero test failures** - Production ready
|
|
714
|
+
- **Cross-platform support** - Windows, macOS, Linux
|
|
715
|
+
|
|
716
|
+
### ⚡ Latest Quality Achievements (v1.7.0)
|
|
717
|
+
- ✅ **Token saving feature** - New suppress_output parameter automatically suppresses table output when file output is specified, saving AI token consumption
|
|
718
|
+
- ✅ **Intelligent output control** - Automatically optimizes response size when output_file is specified and suppress_output=true
|
|
719
|
+
- ✅ **Enterprise-grade test coverage** - Comprehensive test suite including complete validation of suppress_output functionality
|
|
720
|
+
- ✅ **MCP tool enhancement** - Complete MCP server tool set supporting advanced file search and content analysis
|
|
721
|
+
- ✅ **Cross-platform path compatibility** - Fixed differences between Windows short path names and macOS symbolic links
|
|
722
|
+
- ✅ **GitFlow implementation** - Professional development/release branch strategy
|
|
744
723
|
|
|
745
724
|
### ⚙️ Running Tests
|
|
746
725
|
```bash
|
|
@@ -756,65 +735,62 @@ uv run pytest tests/test_mcp_server_initialization.py -v
|
|
|
756
735
|
|
|
757
736
|
### 📈 Test Coverage Details
|
|
758
737
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
- **File Search Tool**: 88.77% (Excellent) - fd/ripgrep integration
|
|
773
|
-
- **Content Search Tool**: 92.70% (Excellent) - Regular expression search
|
|
774
|
-
- **Combined Search Tool**: 91.57% (Excellent) - Two-stage search
|
|
738
|
+
| Module Category | Module Name | Coverage | Quality Level | Main Features |
|
|
739
|
+
|------------------|-------------|-----------|---------------|---------------|
|
|
740
|
+
| **🔧 Core Modules** | Language Detector | 98.41% | Excellent | Automatic programming language recognition |
|
|
741
|
+
| | CLI Main Entry | 94.36% | Excellent | Command line interface |
|
|
742
|
+
| | Query Filter System | 96.06% | Excellent | Code querying and filtering |
|
|
743
|
+
| | Query Service | 86.25% | Good | Query execution engine |
|
|
744
|
+
| | MCP Error Handling | 82.76% | Good | AI assistant integration error handling |
|
|
745
|
+
| **🌍 Language Plugins** | Java Plugin | 80.30% | Excellent | Complete enterprise-grade support |
|
|
746
|
+
| | JavaScript Plugin | 76.74% | Good | Modern ES6+ feature support |
|
|
747
|
+
| | Python Plugin | 82.84% | Excellent | Complete type annotation support |
|
|
748
|
+
| **🤖 MCP Tools** | File Search Tool | 88.77% | Excellent | fd/ripgrep integration |
|
|
749
|
+
| | Content Search Tool | 92.70% | Excellent | Regular expression search |
|
|
750
|
+
| | Combined Search Tool | 91.57% | Excellent | Two-stage search |
|
|
775
751
|
|
|
776
752
|
### ✅ Documentation Verification Status
|
|
777
753
|
|
|
778
754
|
**All content in this README has been verified:**
|
|
779
|
-
- ✅ **All
|
|
780
|
-
- ✅ **All
|
|
781
|
-
- ✅ **SMART
|
|
782
|
-
- ✅ **Cross-
|
|
755
|
+
- ✅ **All commands tested** - All CLI commands have been executed and verified in real environments
|
|
756
|
+
- ✅ **All data is real** - Data such as coverage rates and test counts are directly obtained from test reports
|
|
757
|
+
- ✅ **SMART flow is real** - Demonstrated based on actual BigService.java (1419 lines)
|
|
758
|
+
- ✅ **Cross-platform verified** - Tested on Windows, macOS, Linux environments
|
|
783
759
|
|
|
784
|
-
**Verification
|
|
785
|
-
- Operating
|
|
786
|
-
- Python
|
|
787
|
-
- Project
|
|
788
|
-
- Test
|
|
760
|
+
**Verification environment:**
|
|
761
|
+
- Operating systems: Windows 10, macOS, Linux
|
|
762
|
+
- Python version: 3.10+
|
|
763
|
+
- Project version: tree-sitter-analyzer v1.7.0
|
|
764
|
+
- Test files: BigService.java (1419 lines), sample.py (256 lines), MultiClass.java (54 lines)
|
|
789
765
|
|
|
790
766
|
---
|
|
791
767
|
|
|
792
|
-
## 📚 Documentation & Support
|
|
768
|
+
## 9. 📚 Documentation & Support
|
|
793
769
|
|
|
794
770
|
### 📖 Complete Documentation
|
|
795
|
-
- **[User MCP Setup Guide](MCP_SETUP_USERS.md)** - Simple
|
|
796
|
-
- **[Developer MCP Setup Guide](MCP_SETUP_DEVELOPERS.md)** - Local development
|
|
771
|
+
- **[User MCP Setup Guide](MCP_SETUP_USERS.md)** - Simple setup guide
|
|
772
|
+
- **[Developer MCP Setup Guide](MCP_SETUP_DEVELOPERS.md)** - Local development setup
|
|
797
773
|
- **[Project Root Configuration](PROJECT_ROOT_CONFIG.md)** - Complete configuration reference
|
|
798
774
|
- **[API Documentation](docs/api.md)** - Detailed API reference
|
|
799
775
|
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute code
|
|
800
776
|
- **[Onboarding & Training Guide](training/README.md)** - System onboarding materials for new members/maintainers
|
|
801
777
|
|
|
802
778
|
### 🤖 AI Collaboration Support
|
|
803
|
-
This project supports AI-assisted development with
|
|
779
|
+
This project supports AI-assisted development with professional quality control:
|
|
804
780
|
|
|
805
781
|
```bash
|
|
806
|
-
#
|
|
782
|
+
# AI system pre-generation checks
|
|
807
783
|
uv run python check_quality.py --new-code-only
|
|
808
784
|
uv run python llm_code_checker.py --check-all
|
|
809
785
|
```
|
|
810
786
|
|
|
811
|
-
📖 **Detailed
|
|
787
|
+
📖 **Detailed guides**:
|
|
812
788
|
- [AI Collaboration Guide](AI_COLLABORATION_GUIDE.md)
|
|
813
789
|
- [LLM Coding Guidelines](LLM_CODING_GUIDELINES.md)
|
|
814
790
|
|
|
815
791
|
### 💝 Sponsors & Acknowledgments
|
|
816
792
|
|
|
817
|
-
**[@o93](https://github.com/o93)** - *
|
|
793
|
+
**[@o93](https://github.com/o93)** - *Lead Sponsor & Supporter*
|
|
818
794
|
- 🚀 **MCP Tool Enhancement**: Sponsored comprehensive MCP fd/ripgrep tool development
|
|
819
795
|
- 🧪 **Test Infrastructure**: Implemented enterprise-grade test coverage (50+ comprehensive test cases)
|
|
820
796
|
- 🔧 **Quality Assurance**: Supported bug fixes and performance improvements
|
|
@@ -824,22 +800,22 @@ uv run python llm_code_checker.py --check-all
|
|
|
824
800
|
|
|
825
801
|
---
|
|
826
802
|
|
|
827
|
-
## 🤝 Contributing & License
|
|
803
|
+
## 10. 🤝 Contributing & License
|
|
828
804
|
|
|
829
805
|
### 🤝 Contributing Guide
|
|
830
806
|
|
|
831
|
-
We welcome
|
|
807
|
+
We welcome all kinds of contributions! Please check our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
832
808
|
|
|
833
|
-
### ⭐ Give us a
|
|
809
|
+
### ⭐ Give us a star!
|
|
834
810
|
|
|
835
|
-
If this project
|
|
811
|
+
If this project has been helpful to you, please give us a ⭐ on GitHub - that's the biggest support for us!
|
|
836
812
|
|
|
837
813
|
### 📄 License
|
|
838
814
|
|
|
839
|
-
MIT License -
|
|
815
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
840
816
|
|
|
841
817
|
---
|
|
842
818
|
|
|
843
|
-
**🎯 Built for developers
|
|
819
|
+
**🎯 Built for developers working with large codebases and AI assistants**
|
|
844
820
|
|
|
845
|
-
*
|
|
821
|
+
*Making every line of code understandable to AI, enabling every project to break through token limitations*
|