tree-sitter-analyzer 1.5.0__py3-none-any.whl → 1.6.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.

@@ -1,1229 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: tree-sitter-analyzer
3
- Version: 1.5.0
4
- Summary: Extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture
5
- Project-URL: Homepage, https://github.com/aimasteracc/tree-sitter-analyzer
6
- Project-URL: Documentation, https://github.com/aimasteracc/tree-sitter-analyzer#readme
7
- Project-URL: Repository, https://github.com/aimasteracc/tree-sitter-analyzer.git
8
- Project-URL: Issues, https://github.com/aimasteracc/tree-sitter-analyzer/issues
9
- Project-URL: Changelog, https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CHANGELOG.md
10
- Project-URL: Bug Reports, https://github.com/aimasteracc/tree-sitter-analyzer/issues
11
- Project-URL: Source Code, https://github.com/aimasteracc/tree-sitter-analyzer
12
- Author-email: "aisheng.yu" <aimasteracc@gmail.com>
13
- Maintainer-email: "aisheng.yu" <aimasteracc@gmail.com>
14
- License: MIT
15
- Keywords: ai-tools,ast,code-analysis,mcp,mcp-server,model-context-protocol,multi-language,parsing,static-analysis,tree-sitter
16
- Classifier: Development Status :: 4 - Beta
17
- Classifier: Framework :: AsyncIO
18
- Classifier: Intended Audience :: Developers
19
- Classifier: License :: OSI Approved :: MIT License
20
- Classifier: Operating System :: OS Independent
21
- Classifier: Programming Language :: Python :: 3
22
- Classifier: Programming Language :: Python :: 3.10
23
- Classifier: Programming Language :: Python :: 3.11
24
- Classifier: Programming Language :: Python :: 3.12
25
- Classifier: Programming Language :: Python :: 3.13
26
- Classifier: Topic :: Communications
27
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
28
- Classifier: Topic :: Software Development :: Code Generators
29
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
- Classifier: Topic :: Software Development :: Quality Assurance
31
- Classifier: Topic :: Text Processing :: Linguistic
32
- Classifier: Typing :: Typed
33
- Requires-Python: >=3.10
34
- Requires-Dist: cachetools>=5.0.0
35
- Requires-Dist: chardet>=5.0.0
36
- Requires-Dist: mcp>=1.12.3
37
- Requires-Dist: tree-sitter-cpp<0.25.0,>=0.23.4
38
- Requires-Dist: tree-sitter-java<0.25.0,>=0.23.5
39
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1
40
- Requires-Dist: tree-sitter-python<0.25.0,>=0.23.6
41
- Requires-Dist: tree-sitter==0.24.0
42
- Provides-Extra: all
43
- Requires-Dist: anyio>=4.0.0; extra == 'all'
44
- Requires-Dist: black>=24.0.0; extra == 'all'
45
- Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'all'
46
- Requires-Dist: isort>=5.13.0; extra == 'all'
47
- Requires-Dist: mcp>=1.12.2; extra == 'all'
48
- Requires-Dist: memory-profiler>=0.61.0; extra == 'all'
49
- Requires-Dist: mypy>=1.17.0; extra == 'all'
50
- Requires-Dist: pre-commit>=3.0.0; extra == 'all'
51
- Requires-Dist: psutil<6,>=5.9.6; extra == 'all'
52
- Requires-Dist: pydantic-settings>=2.2.1; extra == 'all'
53
- Requires-Dist: pydantic>=2.5.0; extra == 'all'
54
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'all'
55
- Requires-Dist: pytest-cov>=4.0.0; extra == 'all'
56
- Requires-Dist: pytest-mock>=3.14.1; extra == 'all'
57
- Requires-Dist: pytest>=8.4.1; extra == 'all'
58
- Requires-Dist: ruff>=0.5.0; extra == 'all'
59
- Requires-Dist: tree-sitter-c<0.25.0,>=0.20.0; extra == 'all'
60
- Requires-Dist: tree-sitter-cpp<0.25.0,>=0.23.4; extra == 'all'
61
- Requires-Dist: tree-sitter-go<0.25.0,>=0.20.0; extra == 'all'
62
- Requires-Dist: tree-sitter-java<0.25.0,>=0.23.5; extra == 'all'
63
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'all'
64
- Requires-Dist: tree-sitter-python<0.25.0,>=0.23.0; extra == 'all'
65
- Requires-Dist: tree-sitter-rust<0.25.0,>=0.20.0; extra == 'all'
66
- Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'all'
67
- Requires-Dist: types-psutil>=5.9.0; extra == 'all'
68
- Provides-Extra: all-languages
69
- Requires-Dist: tree-sitter-c<0.25.0,>=0.20.0; extra == 'all-languages'
70
- Requires-Dist: tree-sitter-cpp<0.25.0,>=0.23.4; extra == 'all-languages'
71
- Requires-Dist: tree-sitter-go<0.25.0,>=0.20.0; extra == 'all-languages'
72
- Requires-Dist: tree-sitter-java<0.25.0,>=0.23.5; extra == 'all-languages'
73
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'all-languages'
74
- Requires-Dist: tree-sitter-python<0.25.0,>=0.23.0; extra == 'all-languages'
75
- Requires-Dist: tree-sitter-rust<0.25.0,>=0.20.0; extra == 'all-languages'
76
- Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'all-languages'
77
- Provides-Extra: c
78
- Requires-Dist: tree-sitter-c<0.25.0,>=0.20.0; extra == 'c'
79
- Provides-Extra: cpp
80
- Requires-Dist: tree-sitter-cpp<0.25.0,>=0.23.4; extra == 'cpp'
81
- Provides-Extra: dev
82
- Requires-Dist: black>=24.0.0; extra == 'dev'
83
- Requires-Dist: isort>=5.13.0; extra == 'dev'
84
- Requires-Dist: memory-profiler>=0.61.0; extra == 'dev'
85
- Requires-Dist: mypy>=1.17.0; extra == 'dev'
86
- Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
87
- Requires-Dist: psutil<6,>=5.9.6; extra == 'dev'
88
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
89
- Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
90
- Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
91
- Requires-Dist: pytest>=8.4.1; extra == 'dev'
92
- Requires-Dist: ruff>=0.5.0; extra == 'dev'
93
- Requires-Dist: types-psutil>=5.9.0; extra == 'dev'
94
- Provides-Extra: full
95
- Requires-Dist: anyio>=4.0.0; extra == 'full'
96
- Requires-Dist: black>=24.0.0; extra == 'full'
97
- Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'full'
98
- Requires-Dist: isort>=5.13.0; extra == 'full'
99
- Requires-Dist: mcp>=1.12.2; extra == 'full'
100
- Requires-Dist: memory-profiler>=0.61.0; extra == 'full'
101
- Requires-Dist: mypy>=1.17.0; extra == 'full'
102
- Requires-Dist: pre-commit>=3.0.0; extra == 'full'
103
- Requires-Dist: psutil<6,>=5.9.6; extra == 'full'
104
- Requires-Dist: pydantic-settings>=2.2.1; extra == 'full'
105
- Requires-Dist: pydantic>=2.5.0; extra == 'full'
106
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'full'
107
- Requires-Dist: pytest-cov>=4.0.0; extra == 'full'
108
- Requires-Dist: pytest-mock>=3.14.1; extra == 'full'
109
- Requires-Dist: pytest>=8.4.1; extra == 'full'
110
- Requires-Dist: ruff>=0.5.0; extra == 'full'
111
- Requires-Dist: tree-sitter-c<0.25.0,>=0.20.0; extra == 'full'
112
- Requires-Dist: tree-sitter-cpp<0.25.0,>=0.23.4; extra == 'full'
113
- Requires-Dist: tree-sitter-go<0.25.0,>=0.20.0; extra == 'full'
114
- Requires-Dist: tree-sitter-java<0.25.0,>=0.23.5; extra == 'full'
115
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'full'
116
- Requires-Dist: tree-sitter-python<0.25.0,>=0.23.0; extra == 'full'
117
- Requires-Dist: tree-sitter-rust<0.25.0,>=0.20.0; extra == 'full'
118
- Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'full'
119
- Requires-Dist: types-psutil>=5.9.0; extra == 'full'
120
- Provides-Extra: go
121
- Requires-Dist: tree-sitter-go<0.25.0,>=0.20.0; extra == 'go'
122
- Provides-Extra: java
123
- Requires-Dist: tree-sitter-java<0.25.0,>=0.23.5; extra == 'java'
124
- Provides-Extra: javascript
125
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'javascript'
126
- Provides-Extra: mcp
127
- Requires-Dist: anyio>=4.0.0; extra == 'mcp'
128
- Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'mcp'
129
- Requires-Dist: mcp>=1.12.2; extra == 'mcp'
130
- Requires-Dist: pydantic-settings>=2.2.1; extra == 'mcp'
131
- Requires-Dist: pydantic>=2.5.0; extra == 'mcp'
132
- Provides-Extra: popular
133
- Requires-Dist: tree-sitter-java<0.25.0,>=0.23.5; extra == 'popular'
134
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'popular'
135
- Requires-Dist: tree-sitter-python<0.25.0,>=0.23.0; extra == 'popular'
136
- Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'popular'
137
- Provides-Extra: python
138
- Requires-Dist: tree-sitter-python<0.25.0,>=0.23.0; extra == 'python'
139
- Provides-Extra: rust
140
- Requires-Dist: tree-sitter-rust<0.25.0,>=0.20.0; extra == 'rust'
141
- Provides-Extra: systems
142
- Requires-Dist: tree-sitter-c<0.25.0,>=0.20.0; extra == 'systems'
143
- Requires-Dist: tree-sitter-cpp<0.25.0,>=0.23.4; extra == 'systems'
144
- Requires-Dist: tree-sitter-go<0.25.0,>=0.20.0; extra == 'systems'
145
- Requires-Dist: tree-sitter-rust<0.25.0,>=0.20.0; extra == 'systems'
146
- Provides-Extra: test
147
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'test'
148
- Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
149
- Requires-Dist: pytest-mock>=3.14.1; extra == 'test'
150
- Requires-Dist: pytest>=8.4.1; extra == 'test'
151
- Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'test'
152
- Requires-Dist: tree-sitter-java>=0.23.5; extra == 'test'
153
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'test'
154
- Requires-Dist: tree-sitter-python>=0.23.0; extra == 'test'
155
- Provides-Extra: typescript
156
- Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'typescript'
157
- Provides-Extra: web
158
- Requires-Dist: tree-sitter-javascript<0.25.0,>=0.23.1; extra == 'web'
159
- Requires-Dist: tree-sitter-typescript<0.25.0,>=0.20.0; extra == 'web'
160
- Description-Content-Type: text/markdown
161
-
162
- # Tree-sitter Analyzer
163
-
164
- [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
165
- [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
166
- [![Tests](https://img.shields.io/badge/tests-1869%20passed-brightgreen.svg)](#quality-assurance)
167
- [![Coverage](https://img.shields.io/badge/coverage-71.90%25-green.svg)](#quality-assurance)
168
- [![Quality](https://img.shields.io/badge/quality-enterprise%20grade-blue.svg)](#quality-assurance)
169
- [![PyPI](https://img.shields.io/pypi/v/tree-sitter-analyzer.svg)](https://pypi.org/project/tree-sitter-analyzer/)
170
- [![Version](https://img.shields.io/badge/version-1.5.0-blue.svg)](https://github.com/aimasteracc/tree-sitter-analyzer/releases)
171
- [![GitHub Stars](https://img.shields.io/github/stars/aimasteracc/tree-sitter-analyzer.svg?style=social)](https://github.com/aimasteracc/tree-sitter-analyzer)
172
-
173
- ## 🚀 Break LLM Token Limits, Let AI Understand Code Files of Any Size
174
-
175
- > **Revolutionary Code Analysis Tool Designed for the AI Era**
176
-
177
- ## 📋 Table of Contents
178
-
179
- - [🚀 Break LLM Token Limits](#-break-llm-token-limits-let-ai-understand-code-files-of-any-size)
180
- - [📋 Table of Contents](#-table-of-contents)
181
- - [💡 Unique Features](#-unique-features)
182
- - [📊 Real-time Demo and Results](#-real-time-demo-and-results)
183
- - [🚀 30-Second Quick Start](#-30-second-quick-start)
184
- - [🤖 AI Users (Claude Desktop, Cursor, etc.)](#-ai-users-claude-desktop-cursor-etc)
185
- - [💻 Developers (CLI)](#-developers-cli)
186
- - [❓ Why Choose Tree-sitter Analyzer](#-why-choose-tree-sitter-analyzer)
187
- - [📖 Practical Usage Examples](#-practical-usage-examples)
188
- - [🛠️ Core Features](#️-core-features)
189
- - [📦 Installation Guide](#-installation-guide)
190
- - [🔒 Security and Configuration](#-security-and-configuration)
191
- - [🏆 Quality Assurance](#-quality-assurance)
192
- - [🤖 AI Collaboration Support](#-ai-collaboration-support)
193
- - [📚 Documentation](#-documentation)
194
- - [🤝 Contributing](#-contributing)
195
- - [📄 License](#-license)
196
-
197
- ## 💡 Unique Features
198
-
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
-
201
- - ⚡ **Get complete code structure overview in 3 seconds**
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
206
-
207
- **No more AI being helpless with large files!**
208
-
209
- ## 📊 Real-time Demo and Results
210
-
211
- ### ⚡ **Lightning-fast Analysis Speed**
212
- ```bash
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)
216
- ```
217
-
218
- ### 📊 **Precise Structure Table**
219
- | Class Name | Type | Visibility | Line Range | Method Count | Field Count |
220
- |------------|------|------------|------------|--------------|-------------|
221
- | BigService | class | public | 17-1419 | 66 | 9 |
222
-
223
- ### 🔄 **AI Assistant SMART Workflow**
224
- - **S**: `set_project_path` - Setup project root directory
225
- - **M**: `list_files`, `search_content`, `find_and_grep` - Map target files with precision
226
- - **A**: `analyze_code_structure` - Analyze core structure with unified elements
227
- - **R**: `extract_code_section` - Retrieve essential code snippets on demand
228
- - **T**: Advanced dependency tracing (when needed)
229
-
230
- ---
231
-
232
- ## 🆕 New CLI Commands (v1.3.8+)
233
-
234
- ### 🔧 **Standalone CLI Tools for File System Operations**
235
-
236
- Tree-sitter Analyzer now provides dedicated CLI commands that wrap powerful MCP tools for file system operations:
237
-
238
- > **💡 Usage Note**: In development environments, use `uv run` prefix to execute CLI commands:
239
- > - `uv run list-files` instead of `list-files`
240
- > - `uv run search-content` instead of `search-content`
241
- > - `uv run find-and-grep` instead of `find-and-grep`
242
- >
243
- > After installing from PyPI, these commands will be available directly in your PATH.
244
-
245
- #### 📁 **`list-files`** - File Discovery with fd
246
- ```bash
247
- # List all Java files in current directory
248
- uv run list-files . --extensions java
249
-
250
- # Find test files with specific naming patterns
251
- uv run list-files src --pattern "test_*" --extensions java --types f
252
-
253
- # Find large files modified in the last week
254
- uv run list-files . --types f --size "+1k" --changed-within "1week"
255
-
256
- # Find service classes with specific naming patterns
257
- uv run list-files src --pattern "*Service*" --extensions java --output-format json
258
- ```
259
-
260
- #### 🔍 **`search-content`** - Content Search with ripgrep
261
- ```bash
262
- # Search for class definitions in Java files
263
- uv run search-content --roots . --query "class.*extends" --include-globs "*.java"
264
-
265
- # Find TODO comments with context
266
- uv run search-content --roots src --query "TODO|FIXME" --context-before 2 --context-after 2
267
-
268
- # Search in specific files with case-insensitive matching
269
- uv run search-content --files file1.java file2.java --query "public.*method" --case insensitive
270
- ```
271
-
272
- #### 🎯 **`find-and-grep`** - Two-Stage Search (fd → ripgrep)
273
- ```bash
274
- # Find Java files first, then search for Spring annotations
275
- uv run find-and-grep --roots . --query "@SpringBootApplication" --extensions java
276
-
277
- # Combined file filtering and content search with limits
278
- uv run find-and-grep --roots src --query "import.*spring" --extensions java --file-limit 10 --max-count 5
279
-
280
- # Advanced search with multiple filters
281
- uv run find-and-grep --roots . --query "public.*static.*void" --extensions java --types f --size "+500" --output-format json
282
- ```
283
-
284
- ### 🛡️ **Security & Safety Features**
285
- - **Project Boundary Detection**: All commands automatically detect and respect project boundaries
286
- - **Input Validation**: Comprehensive parameter validation and sanitization
287
- - **Error Handling**: Graceful error handling with informative messages
288
- - **Resource Limits**: Built-in limits to prevent resource exhaustion
289
-
290
- ### 📊 **Output Formats**
291
- - **JSON**: Structured output for programmatic processing
292
- - **Text**: Human-readable output for terminal use
293
- - **Quiet Mode**: Suppress non-essential output for scripting
294
-
295
- ---
296
-
297
- ## 🚀 30-Second Quick Start
298
-
299
- ### 🤖 AI Users (Claude Desktop, Cursor, etc.)
300
-
301
- **📋 0. Prerequisites (for Advanced MCP Tools)**
302
- For advanced file search and content analysis features, install these tools first:
303
- ```bash
304
- # Install fd and ripgrep (see Prerequisites section for detailed instructions)
305
- # macOS
306
- brew install fd ripgrep
307
-
308
- # Windows (using winget - recommended)
309
- winget install sharkdp.fd BurntSushi.ripgrep.MSVC
310
-
311
- # Windows (alternative methods)
312
- # choco install fd ripgrep
313
- # scoop install fd ripgrep
314
-
315
- # Ubuntu/Debian
316
- sudo apt install fd-find ripgrep
317
- ```
318
-
319
- **📦 1. One-click Installation**
320
- ```bash
321
- # macOS/Linux
322
- curl -LsSf https://astral.sh/uv/install.sh | sh
323
-
324
- # Windows PowerShell
325
- powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
326
- ```
327
-
328
- **⚙️ 2. AI Client Configuration**
329
-
330
- **Claude Desktop Configuration:**
331
-
332
- Add the following to your configuration file:
333
- - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
334
- - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
335
- - **Linux**: `~/.config/claude/claude_desktop_config.json`
336
-
337
- **Basic Configuration (Recommended):**
338
- ```json
339
- {
340
- "mcpServers": {
341
- "tree-sitter-analyzer": {
342
- "command": "uv",
343
- "args": [
344
- "run", "--with", "tree-sitter-analyzer[mcp]",
345
- "python", "-m", "tree_sitter_analyzer.mcp.server"
346
- ]
347
- }
348
- }
349
- }
350
- ```
351
-
352
- **Advanced Configuration (Specify Project Root Directory):**
353
- ```json
354
- {
355
- "mcpServers": {
356
- "tree-sitter-analyzer": {
357
- "command": "uv",
358
- "args": [
359
- "run", "--with", "tree-sitter-analyzer[mcp]",
360
- "python", "-m", "tree_sitter_analyzer.mcp.server"
361
- ],
362
- "env": {
363
- "TREE_SITTER_PROJECT_ROOT": "/absolute/path/to/your/project"
364
- }
365
- }
366
- }
367
- }
368
- ```
369
-
370
- **Other AI Clients:**
371
- - **Cursor**: Built-in MCP support, refer to Cursor documentation for configuration
372
- - **Roo Code**: Supports MCP protocol, check corresponding configuration guides
373
- - **Other MCP-compatible clients**: Use the same server configuration
374
-
375
- **⚠️ Configuration Notes:**
376
- - **Basic Configuration**: Tool automatically detects project root directory (recommended)
377
- - **Advanced Configuration**: If you need to specify a particular directory, replace `/absolute/path/to/your/project` with an absolute path
378
- - **Avoid Using**: Variables like `${workspaceFolder}` may not be supported in some clients
379
-
380
- **🎉 3. Restart AI client and start analyzing large code files!**
381
-
382
- ### 💻 Developers (CLI)
383
-
384
- ```bash
385
- # Installation
386
- uv add "tree-sitter-analyzer[popular]"
387
-
388
- # Check file size (1419-line large service class, completed instantly)
389
- uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
390
-
391
- # Generate structure table (1 class, 66 methods, clearly displayed)
392
- uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
393
-
394
- # Precise code extraction
395
- uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --start-line 100 --end-line 105
396
- ```
397
-
398
- ---
399
-
400
- ## ❓ Why Choose Tree-sitter Analyzer
401
-
402
- ### 🎯 Solve Real Pain Points
403
-
404
- **Traditional Method Difficulties:**
405
- - ❌ Large files exceed LLM token limits
406
- - ❌ AI cannot understand code structure
407
- - ❌ Need to manually split files
408
- - ❌ Context loss leads to inaccurate analysis
409
-
410
- **Tree-sitter Analyzer Breakthrough:**
411
- - ✅ **Smart Analysis**: Understand structure without reading complete files
412
- - ✅ **Precise Positioning**: Accurate line-by-line code extraction
413
- - ✅ **AI Native**: Optimized for LLM workflows
414
- - ✅ **Multi-language Support**: Java, Python, JavaScript/TypeScript, etc.
415
-
416
- ## 📖 Practical Usage Examples
417
-
418
- ### 💬 AI IDE Prompts (SMART Analysis Workflow)
419
-
420
- > **✅ Test Verification Status:** All prompts below have been tested and verified in real environments, ensuring 100% availability
421
- >
422
- > **🎯 SMART Analysis Workflow:**
423
- > - **S** - Setup project (set_project_path)
424
- > - **M** - Map target files (precision pattern matching)
425
- > - **A** - Analyze core structure (analyze_code_structure)
426
- > - **R** - Retrieve essential code (extract_code_section)
427
- > - **T** - Trace dependencies (when needed)
428
- >
429
- > **⚠️ Important Notes:**
430
- > - Follow SMART workflow sequence for optimal results
431
- > - For files within the project, use **relative paths** (e.g., `examples/BigService.java`)
432
- > - For files outside the project, use **absolute paths** (e.g., `C:\git-public\tree-sitter-analyzer\examples\BigService.java`)
433
- > - All tools support both Windows and Unix style paths
434
- > - Project path should point to your code repository root directory
435
-
436
- #### 🔧 **S - Setup Project (Required First Step)**
437
-
438
- **Option 1: Configure in MCP Settings**
439
- ```json
440
- {
441
- "mcpServers": {
442
- "tree-sitter-analyzer": {
443
- "command": "uv",
444
- "args": ["run", "python", "-m", "tree_sitter_analyzer.mcp.server"],
445
- "env": {
446
- "TREE_SITTER_PROJECT_ROOT": "/path/to/your/project"
447
- }
448
- }
449
- }
450
- }
451
- ```
452
-
453
- **Option 2: Tell AI Directly (Recommended, More Natural)**
454
-
455
- **Method 1: Explicit Setup Request**
456
- ```
457
- Please help me set the project root directory, the path is: C:\git-public\tree-sitter-analyzer
458
- ```
459
-
460
- **Method 2: Provide Project Information**
461
- ```
462
- My project is at: C:\git-public\tree-sitter-analyzer
463
- Please set this path as the project root
464
- ```
465
-
466
- **Method 3: Simple Statement**
467
- ```
468
- Project path: C:\git-public\tree-sitter-analyzer
469
- ```
470
-
471
- **AI will automatically call the appropriate tool to set the path, no need to remember complex command formats**
472
-
473
- **⚠️ Important Notes:**
474
- - After setting project path, you can use relative paths to reference files within the project
475
- - Example: `examples/BigService.java` instead of full paths
476
- - Once project path is successfully set, all subsequent analysis commands will automatically use this root directory
477
-
478
- #### 🗺️ **M - Map Target Files (Precision Pattern Matching)**
479
-
480
- > **📋 Prerequisites:** This step requires `fd` and `ripgrep` tools to be installed. See [Prerequisites](#prerequisites) section for installation instructions.
481
-
482
- **Smart File Discovery:**
483
- ```
484
- Find all Python files in the project
485
- ```
486
-
487
- ```
488
- List all Java files larger than 10KB
489
- ```
490
-
491
- ```
492
- Find configuration files (*.json, *.yaml, *.toml) in the project
493
- ```
494
-
495
- **Intelligent Content Search:**
496
- ```
497
- Search for "def authenticate" in all Python files with context
498
- ```
499
-
500
- ```
501
- Find all TODO comments in source files
502
- ```
503
-
504
- ```
505
- Search for "class.*Service" patterns in all files, case insensitive
506
- ```
507
-
508
- **Combined Discovery & Search:**
509
- ```
510
- Find all Python files and search for "async def" functions
511
- ```
512
-
513
- ```
514
- Search for "class.*Service" in all source files
515
- ```
516
-
517
- **Return Format:**
518
- ```json
519
- {
520
- "success": true,
521
- "results": [
522
- {
523
- "file": "tree_sitter_analyzer/core/query_service.py",
524
- "line": 20,
525
- "text": "class QueryService:",
526
- "matches": [[0, 18]]
527
- }
528
- ],
529
- "count": 25,
530
- "meta": {
531
- "searched_file_count": 256,
532
- "truncated": false,
533
- "fd_elapsed_ms": 225,
534
- "rg_elapsed_ms": 2969
535
- }
536
- }
537
- ```
538
-
539
- #### 🔍 **A - Analyze Core Structure**
540
-
541
- **Method 1: Explicit Analysis Request**
542
- ```
543
- Please help me analyze this file: examples/BigService.java
544
- ```
545
-
546
- **Method 2: Describe Analysis Needs**
547
- ```
548
- I want to understand the size and structure of this Java file: examples/BigService.java
549
- ```
550
-
551
- **Method 3: Simple Request**
552
- ```
553
- Analyze this file: examples/BigService.java
554
- ```
555
-
556
- **Alternative using absolute path:**
557
- ```
558
- Please analyze this file: C:\git-public\tree-sitter-analyzer\examples\BigService.java
559
- ```
560
-
561
- **💡 Tip: After setting project path, using relative paths is recommended, more concise and convenient**
562
-
563
- **Return Format:**
564
- ```json
565
- {
566
- "file_path": "examples/BigService.java",
567
- "language": "java",
568
- "metrics": {
569
- "lines_total": 1419,
570
- "lines_code": 907,
571
- "lines_comment": 246,
572
- "lines_blank": 267,
573
- "elements": {
574
- "classes": 1,
575
- "methods": 66,
576
- "fields": 9,
577
- "imports": 8,
578
- "packages": 1,
579
- "total": 85
580
- },
581
- "complexity": {
582
- "total": 348,
583
- "average": 5.27,
584
- "max": 15
585
- }
586
- }
587
- }
588
- ```
589
-
590
- #### 📊 **R - Retrieve Essential Code**
591
-
592
- **Method 1: Explicit Table Request**
593
- ```
594
- Please generate a detailed structure table for this file: examples/BigService.java
595
- ```
596
-
597
- **Method 2: Describe Table Needs**
598
- ```
599
- I want to see the complete structure of this Java file, including all classes, methods, and fields: examples/BigService.java
600
- ```
601
-
602
- **Method 3: Simple Request**
603
- ```
604
- Generate structure table: examples/BigService.java
605
- ```
606
-
607
- **Alternative using absolute path:**
608
- ```
609
- Please generate a detailed structure table: C:\git-public\tree-sitter-analyzer\examples\BigService.java
610
- ```
611
-
612
- **💡 Tip: After setting project path, using relative paths is recommended, more concise and convenient**
613
-
614
- **Return Format:**
615
- - Complete Markdown table
616
- - Including class information, method list (with line numbers), field list
617
- - Method signatures, visibility, line ranges, complexity, and other detailed information
618
-
619
- #### ✂️ **Precise Code Extraction**
620
-
621
- **Method 1: Explicit Extraction Request**
622
- ```
623
- Please extract lines 93-105 of this file: examples/BigService.java
624
- ```
625
-
626
- **Method 2: Describe Extraction Needs**
627
- ```
628
- I want to see the code content from lines 93 to 105 of this Java file: examples/BigService.java
629
- ```
630
-
631
- **Method 3: Simple Request**
632
- ```
633
- Extract lines 93-105: examples/BigService.java
634
- ```
635
-
636
- **Alternative using absolute path:**
637
- ```
638
- Please extract code snippet: C:\git-public\tree-sitter-analyzer\examples\BigService.java, lines 93-105
639
- ```
640
-
641
- **💡 Tip: After setting project path, using relative paths is recommended, more concise and convenient**
642
-
643
- **Return Format:**
644
- ```json
645
- {
646
- "file_path": "examples/BigService.java",
647
- "range": {
648
- "start_line": 93,
649
- "end_line": 105,
650
- "start_column": null,
651
- "end_column": null
652
- },
653
- "content": " private void checkMemoryUsage() {\n Runtime runtime = Runtime.getRuntime();\n long totalMemory = runtime.totalMemory();\n long freeMemory = runtime.freeMemory();\n long usedMemory = totalMemory - freeMemory;\n\n System.out.println(\"Total Memory: \" + totalMemory);\n System.out.println(\"Free Memory: \" + freeMemory);\n System.out.println(\"Used Memory: \" + usedMemory);\n\n if (usedMemory > totalMemory * 0.8) {\n System.out.println(\"WARNING: High memory usage detected!\");\n }\n",
654
- "content_length": 542
655
- }
656
- ```
657
-
658
- #### 🔗 **T - Trace Dependencies (Advanced Analysis)**
659
-
660
- **Error Handling Enhancement (v0.9.7):**
661
- - Improved `@handle_mcp_errors` decorator with tool name recognition
662
- - Better error context for easier debugging and troubleshooting
663
- - Enhanced file path security validation
664
-
665
- **Find Specific Methods:**
666
- ```
667
- Please help me find the main method in this file: examples/BigService.java
668
- ```
669
-
670
- **Find Authentication-related Methods:**
671
- ```
672
- I want to find all authentication-related methods: examples/BigService.java
673
- ```
674
-
675
- **Find Public Methods with No Parameters:**
676
- ```
677
- Please help me find all public getter methods with no parameters: examples/BigService.java
678
- ```
679
-
680
- **Return Format:**
681
- ```json
682
- {
683
- "success": true,
684
- "results": [
685
- {
686
- "capture_name": "method",
687
- "node_type": "method_declaration",
688
- "start_line": 1385,
689
- "end_line": 1418,
690
- "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 }"
691
- }
692
- ],
693
- "count": 1,
694
- "file_path": "examples/BigService.java",
695
- "language": "java",
696
- "query": "methods"
697
- }
698
- ```
699
-
700
-
701
- #### 💡 **SMART Workflow Best Practices**
702
- - **Natural Language**: Tell AI directly in natural language what you want, no need to remember complex parameter formats
703
- - **Sequential Flow**: Follow S→M→A→R→T sequence for optimal analysis results
704
- - **Path Processing**: After setting project path, relative paths automatically resolve to project root directory
705
- - **Security Protection**: Tool automatically performs project boundary checks to ensure security
706
- - **Smart Understanding**: AI automatically understands your needs and calls appropriate tools
707
- - **Performance**: All MCP tools are optimized for speed with built-in timeouts and result limits
708
- - **Dependency Tracing**: Use T step only when you need to understand complex relationships between code elements
709
-
710
- ### 🛠️ CLI Command Examples
711
-
712
- ```bash
713
- # Quick analysis (1419-line large file, completed instantly)
714
- uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
715
-
716
- # Detailed structure table (66 methods clearly displayed)
717
- uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
718
-
719
- # Precise code extraction (memory usage monitoring code snippet)
720
- uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --start-line 100 --end-line 105
721
-
722
- # Multi-language support test (Python file)
723
- uv run python -m tree_sitter_analyzer examples/sample.py --table=full
724
-
725
- # Small file quick analysis (54-line Java file)
726
- uv run python -m tree_sitter_analyzer examples/MultiClass.java --advanced
727
-
728
- # Silent mode (only show results)
729
- uv run python -m tree_sitter_analyzer examples/BigService.java --table=full --quiet
730
-
731
- # 🔍 Query Filter Examples (v0.9.6+)
732
- # Find specific methods
733
- uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "name=main"
734
-
735
- # Find authentication-related methods
736
- uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "name=~auth*"
737
-
738
- # Find public methods with no parameters
739
- uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "params=0,public=true"
740
-
741
- # Find static methods
742
- uv run python -m tree_sitter_analyzer examples/BigService.java --query-key methods --filter "static=true"
743
-
744
- # View filter syntax help
745
- uv run python -m tree_sitter_analyzer --filter-help
746
-
747
- # 🆕 New CLI Commands (v1.3.8+)
748
- # File listing with fd functionality
749
- uv run list-files . --extensions java --output-format json
750
-
751
- # Content search with ripgrep functionality
752
- uv run search-content --roots . --query "class.*extends" --include-globs "*.java" --output-format text
753
-
754
- # Two-stage search: find files first, then search content
755
- uv run find-and-grep --roots . --query "public.*method" --extensions java --output-format json
756
-
757
- # Advanced file filtering
758
- uv run list-files . --types f --size "+1k" --changed-within "1week" --hidden --output-format text
759
-
760
- # Content search with context
761
- uv run search-content --roots src --query "TODO|FIXME" --context-before 2 --context-after 2 --output-format json
762
-
763
- # Combined file and content search with limits
764
- uv run find-and-grep --roots . --query "import.*spring" --extensions java --file-limit 10 --max-count 5 --output-format text
765
- ```
766
-
767
- ---
768
-
769
- ## 🏗️ Architecture Improvements (v1.2.0+)
770
-
771
- ### 🔄 **Unified Element Management System**
772
-
773
- Tree-sitter Analyzer now features a revolutionary unified architecture that integrates all code elements into a unified system:
774
-
775
- #### **Before (Traditional Architecture):**
776
- - Independent collections of classes, methods, fields, and imports
777
- - Inconsistent data structures across different analysis modes
778
- - Complex maintenance and potential inconsistencies
779
-
780
- #### **After (Unified Architecture):**
781
- - **Single `elements` list**: All code elements (classes, methods, fields, imports, packages) unified
782
- - **Consistent element types**: Each element has an `element_type` attribute for easy identification
783
- - **Simplified API**: Clearer interfaces and reduced complexity
784
- - **Better maintainability**: Single source of truth for all code elements
785
-
786
- #### **Benefits:**
787
- - ✅ **Consistency**: Unified data structures across all analysis modes
788
- - ✅ **Simplicity**: Easier to use and understand
789
- - ✅ **Extensibility**: Easy to add new element types
790
- - ✅ **Performance**: Optimized memory usage and processing
791
- - ✅ **Backward compatibility**: Existing APIs continue to work seamlessly
792
-
793
- #### **Supported Element Types:**
794
- - `class` - Classes and interfaces
795
- - `function` - Methods and functions
796
- - `variable` - Fields and variables
797
- - `import` - Import statements
798
- - `package` - Package declarations
799
-
800
- ---
801
-
802
- ## 🛠️ Core Features
803
-
804
- ### 📊 **Code Structure Analysis**
805
- Get insights without reading complete files:
806
- - Class, method, and field statistics
807
- - Package information and import dependencies
808
- - Complexity metrics
809
- - Precise line number positioning
810
-
811
- ### ✂️ **Smart Code Extraction**
812
- - Precise extraction by line range
813
- - Maintains original format and indentation
814
- - Includes position metadata
815
- - Supports efficient processing of large files
816
-
817
- ### 🔍 **Advanced Query Filtering**
818
- Powerful code element query and filtering system:
819
- - **Exact matching**: `--filter "name=main"` to find specific methods
820
- - **Pattern matching**: `--filter "name=~auth*"` to find authentication-related methods
821
- - **Parameter filtering**: `--filter "params=2"` to find methods with specific parameter counts
822
- - **Modifier filtering**: `--filter "static=true,public=true"` to find static public methods
823
- - **Compound conditions**: `--filter "name=~get*,params=0,public=true"` to combine multiple conditions
824
- - **CLI/MCP consistency**: Same filtering syntax used in command line and AI assistants
825
-
826
- ### 🔗 **AI Assistant Integration**
827
- Deep integration through MCP protocol:
828
- - Claude Desktop
829
- - Cursor IDE
830
- - Roo Code
831
- - Other MCP-compatible AI tools
832
-
833
- ### 🔍 **Advanced File Search & Content Analysis (v1.2.4+)**
834
- Powerful file discovery and content search capabilities powered by fd and ripgrep:
835
-
836
- #### **📋 Prerequisites**
837
- To use the advanced MCP tools (ListFilesTool, SearchContentTool, FindAndGrepTool), you need to install the following command-line tools:
838
-
839
- **Install fd (fast file finder):**
840
- ```bash
841
- # macOS (using Homebrew)
842
- brew install fd
843
-
844
- # Windows (using winget - recommended)
845
- winget install sharkdp.fd
846
-
847
- # Windows (using Chocolatey)
848
- choco install fd
849
-
850
- # Windows (using Scoop)
851
- scoop install fd
852
-
853
- # Ubuntu/Debian
854
- sudo apt install fd-find
855
-
856
- # CentOS/RHEL/Fedora
857
- sudo dnf install fd-find
858
-
859
- # Arch Linux
860
- sudo pacman -S fd
861
- ```
862
-
863
- **Install ripgrep (fast text search):**
864
- ```bash
865
- # macOS (using Homebrew)
866
- brew install ripgrep
867
-
868
- # Windows (using winget - recommended)
869
- winget install BurntSushi.ripgrep.MSVC
870
-
871
- # Windows (using Chocolatey)
872
- choco install ripgrep
873
-
874
- # Windows (using Scoop)
875
- scoop install ripgrep
876
-
877
- # Ubuntu/Debian
878
- sudo apt install ripgrep
879
-
880
- # CentOS/RHEL/Fedora
881
- sudo dnf install ripgrep
882
-
883
- # Arch Linux
884
- sudo pacman -S ripgrep
885
- ```
886
-
887
- **Verify Installation:**
888
- ```bash
889
- # Check fd installation
890
- fd --version
891
-
892
- # Check ripgrep installation
893
- rg --version
894
- ```
895
-
896
- > **⚠️ Important:** Without these tools installed, the advanced MCP file search and content analysis features will not work. The basic MCP tools (analyze_code_structure, extract_code_section, etc.) will continue to work normally.
897
-
898
- #### **🗂️ ListFilesTool - Smart File Discovery**
899
- - **Advanced filtering**: File type, size, modification time, extension-based filtering
900
- - **Pattern matching**: Glob patterns and regex support for flexible file discovery
901
- - **Metadata enrichment**: File size, modification time, directory status, and extension information
902
- - **Performance optimized**: Built on fd for lightning-fast file system traversal
903
-
904
- #### **🔎 SearchContentTool - Intelligent Content Search**
905
- - **Regex & literal search**: Flexible pattern matching with case sensitivity controls
906
- - **Context-aware results**: Configurable before/after context lines for better understanding
907
- - **Multiple output formats**: Standard results, count-only, summary, and grouped by file
908
- - **Encoding support**: Handle files with different text encodings
909
- - **Performance limits**: Built-in timeout and result limits for responsive operation
910
-
911
- #### **🎯 FindAndGrepTool - Combined Discovery & Search**
912
- - **Two-stage workflow**: First discover files with fd, then search content with ripgrep
913
- - **Comprehensive filtering**: Combine file discovery filters with content search patterns
914
- - **Advanced options**: Multiline patterns, word boundaries, fixed strings, and case controls
915
- - **Rich metadata**: File discovery timing, search timing, and result statistics
916
- - **Token optimization**: Path optimization and result grouping to minimize AI token usage
917
-
918
- #### **✨ Key Benefits:**
919
- - 🚀 **Enterprise-grade reliability**: 50+ comprehensive test cases ensuring stability
920
- - 🎯 **Token-efficient**: Multiple output formats optimized for AI assistant interactions
921
- - 🔧 **Highly configurable**: Extensive parameter support for precise control
922
- - 📊 **Performance monitoring**: Built-in timing and result statistics
923
- - 🛡️ **Error resilient**: Comprehensive error handling and validation
924
-
925
- ### 🌍 **Multi-language Support**
926
- - **Java** - Full support, including Spring, JPA frameworks
927
- - **Python** - Full support, including type annotations, decorators
928
- - **JavaScript** - 🆕 **Enterprise-grade support**, including modern ES6+ features, React/Vue/Angular frameworks, JSX, async functions, generators, arrow functions, classes, module systems
929
- - **TypeScript** - Full support, including type annotations, interfaces
930
- - **C/C++, Rust, Go** - Basic support
931
-
932
- ---
933
-
934
- ## 🆕 JavaScript Enterprise Support (v1.5.0+)
935
-
936
- ### 🚀 **Modern JavaScript Complete Support**
937
-
938
- Tree-sitter Analyzer now provides enterprise-level JavaScript support at the same level as Java, including:
939
-
940
- #### **📋 Core Language Features**
941
- - **Function Types**: Traditional functions, arrow functions, async functions, generator functions
942
- - **Class System**: ES6 classes, inheritance, static methods, getters/setters, constructors
943
- - **Variable Declarations**: var, let, const, destructuring assignment, template literals
944
- - **Module System**: ES6 import/export, CommonJS require/module.exports
945
- - **Modern Features**: Spread/rest operators, Promises, async/await
946
-
947
- #### **🎨 Framework & Ecosystem**
948
- - **React Support**: JSX syntax, component analysis, Hook recognition, lifecycle methods
949
- - **Vue.js Support**: Single-file components, template syntax, reactive data
950
- - **Angular Support**: Components, services, dependency injection pattern recognition
951
- - **Node.js Support**: Server-side patterns, Express routing, middleware
952
-
953
- #### **🔍 Advanced Analysis Capabilities**
954
- - **JSDoc Extraction**: Complete documentation comment parsing and type information
955
- - **Complexity Analysis**: Cyclomatic complexity calculation and code quality metrics
956
- - **Framework Detection**: Automatic recognition of React, Vue, Angular project types
957
- - **Export Analysis**: Module export mapping and dependency relationship tracking
958
-
959
- #### **💼 Enterprise Features**
960
- - **Table Formatting**: Dedicated JavaScript table formatter for clear code structure display
961
- - **Performance Optimization**: Caching mechanisms, iterative traversal, efficient large file handling
962
- - **Error Handling**: Robust exception handling and detailed error reporting
963
- - **Type Safety**: TypeScript-style type annotation support
964
-
965
- ### 📊 **JavaScript Analysis Examples**
966
-
967
- ```bash
968
- # Analyze modern JavaScript files
969
- uv run python -m tree_sitter_analyzer examples/ModernJavaScript.js --language javascript --advanced
970
-
971
- # Generate detailed structure tables
972
- uv run python -m tree_sitter_analyzer examples/ModernJavaScript.js --language javascript --table full
973
-
974
- # Analyze React components
975
- uv run python -m tree_sitter_analyzer examples/ReactComponent.jsx --language javascript --table full
976
-
977
- # Query specific function types
978
- uv run python -m tree_sitter_analyzer examples/ModernJavaScript.js --language javascript --query-key async_function
979
- ```
980
-
981
- ### 🎯 **Supported JavaScript Query Types**
982
- - `function_declaration` - Traditional function declarations
983
- - `arrow_function` - Arrow functions
984
- - `async_function` - Async functions
985
- - `generator_function` - Generator functions
986
- - `class_declaration` - Class declarations
987
- - `variable_declaration` - Variable declarations
988
- - `import_statement` - Import statements
989
- - `export_statement` - Export statements
990
- - `jsx_element` - JSX elements
991
- - `method_definition` - Method definitions
992
-
993
- ### 🏗️ **AI Assistant JavaScript Workflow**
994
-
995
- ```
996
- I want to analyze the structure of this JavaScript file: examples/ModernJavaScript.js
997
- ```
998
-
999
- **Example Response Format:**
1000
- ```json
1001
- {
1002
- "file_path": "examples/ModernJavaScript.js",
1003
- "language": "javascript",
1004
- "element_count": 24,
1005
- "elements": [
1006
- {
1007
- "name": "fetchUserData",
1008
- "type": "function",
1009
- "start_line": 208,
1010
- "end_line": 211,
1011
- "is_async": true,
1012
- "framework_type": "vanilla"
1013
- },
1014
- {
1015
- "name": "ModernComponent",
1016
- "type": "class",
1017
- "start_line": 31,
1018
- "end_line": 200,
1019
- "is_react_component": true,
1020
- "framework_type": "react"
1021
- }
1022
- ],
1023
- "success": true
1024
- }
1025
- ```
1026
-
1027
- ---
1028
-
1029
- ## 📦 Installation Guide
1030
-
1031
- ### 👤 **End Users**
1032
- ```bash
1033
- # Basic installation
1034
- uv add tree-sitter-analyzer
1035
-
1036
- # Popular language packages (recommended)
1037
- uv add "tree-sitter-analyzer[popular]"
1038
-
1039
- # MCP server support
1040
- uv add "tree-sitter-analyzer[mcp]"
1041
-
1042
- # Complete installation
1043
- uv add "tree-sitter-analyzer[all,mcp]"
1044
- ```
1045
-
1046
- ### 👨‍💻 **Developers**
1047
- ```bash
1048
- git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
1049
- cd tree-sitter-analyzer
1050
- uv sync --extra all --extra mcp
1051
- ```
1052
-
1053
- ---
1054
-
1055
- ## 🔒 Security and Configuration
1056
-
1057
- ### 🛡️ **Project Boundary Protection**
1058
-
1059
- Tree-sitter Analyzer automatically detects and protects project boundaries:
1060
-
1061
- - **Auto-detection**: Based on `.git`, `pyproject.toml`, `package.json`, etc.
1062
- - **CLI control**: `--project-root /path/to/project`
1063
- - **MCP integration**: `TREE_SITTER_PROJECT_ROOT=/path/to/project` or use auto-detection
1064
- - **Security guarantee**: Only analyze files within project boundaries
1065
-
1066
- **Recommended MCP Configuration:**
1067
-
1068
- **Option 1: Auto-detection (Recommended)**
1069
- ```json
1070
- {
1071
- "mcpServers": {
1072
- "tree-sitter-analyzer": {
1073
- "command": "uv",
1074
- "args": ["run", "--with", "tree-sitter-analyzer[mcp]", "python", "-m", "tree_sitter_analyzer.mcp.server"]
1075
- }
1076
- }
1077
- }
1078
- ```
1079
-
1080
- **Option 2: Manually specify project root directory**
1081
- ```json
1082
- {
1083
- "mcpServers": {
1084
- "tree-sitter-analyzer": {
1085
- "command": "uv",
1086
- "args": ["run", "--with", "tree-sitter-analyzer[mcp]", "python", "-m", "tree_sitter_analyzer.mcp.server"],
1087
- "env": {"TREE_SITTER_PROJECT_ROOT": "/path/to/your/project"}
1088
- }
1089
- }
1090
- }
1091
- ```
1092
-
1093
- ---
1094
-
1095
- ## 🏆 Quality Assurance
1096
-
1097
- ### 📊 **Quality Metrics**
1098
- - **1,797 tests** - 100% pass rate ✅
1099
- - **74.45% code coverage** - Industry-leading level
1100
- - **Zero test failures** - Fully CI/CD ready
1101
- - **Cross-platform compatibility** - Windows, macOS, Linux
1102
-
1103
- ### ⚡ **Latest Quality Achievements (v1.5.0)**
1104
- - ✅ **Cross-platform path compatibility** - Fixed Windows short path names and macOS symbolic link differences
1105
- - ✅ **Windows environment** - Implemented robust path normalization using Windows API
1106
- - ✅ **macOS environment** - Fixed `/var` vs `/private/var` symbolic link differences
1107
- - ✅ **Comprehensive test coverage** - 1797 tests, 74.45% coverage
1108
- - ✅ **GitFlow implementation** - Professional development/release branch strategy. See [GitFlow documentation](GITFLOW.md) for details.
1109
-
1110
- ### ⚙️ **Running Tests**
1111
- ```bash
1112
- # Run all tests
1113
- uv run pytest tests/ -v
1114
-
1115
- # Generate coverage report
1116
- uv run pytest tests/ --cov=tree_sitter_analyzer --cov-report=html --cov-report=term-missing
1117
-
1118
- # Run specific tests
1119
- uv run pytest tests/test_mcp_server_initialization.py -v
1120
- ```
1121
-
1122
- ### 📈 **Coverage Highlights**
1123
- - **Language detector**: 98.41% (Excellent)
1124
- - **CLI main entry**: 94.36% (Excellent)
1125
- - **Query filtering system**: 96.06% (Excellent)
1126
- - **MCP fd/rg tools**: 93.04% (Excellent) - *Enhanced in v1.3.2 with cache format compatibility fix*
1127
- - **Query service**: 86.25% (Good)
1128
- - **Error handling**: 82.76% (Good)
1129
-
1130
- ---
1131
-
1132
- ## 🤖 AI Collaboration Support
1133
-
1134
- ### ⚡ **Optimized for AI Development**
1135
-
1136
- This project supports AI-assisted development with dedicated quality control:
1137
-
1138
- ```bash
1139
- # AI system code generation pre-check
1140
- uv run python check_quality.py --new-code-only
1141
- uv run python llm_code_checker.py --check-all
1142
-
1143
- # AI-generated code review
1144
- uv run python llm_code_checker.py path/to/new_file.py
1145
- ```
1146
-
1147
- 📖 **Detailed Guides**:
1148
- - [AI Collaboration Guide](AI_COLLABORATION_GUIDE.md)
1149
- - [LLM Coding Guidelines](LLM_CODING_GUIDELINES.md)
1150
-
1151
- ---
1152
-
1153
- ## 📚 Documentation
1154
-
1155
- - **[User MCP Setup Guide](MCP_SETUP_USERS.md)** - Simple configuration guide
1156
- - **[Developer MCP Setup Guide](MCP_SETUP_DEVELOPERS.md)** - Local development configuration
1157
- - **[Project Root Configuration](PROJECT_ROOT_CONFIG.md)** - Complete configuration reference
1158
- - **[API Documentation](docs/api.md)** - Detailed API reference
1159
- - **[Contributing Guide](CONTRIBUTING.md)** - How to contribute
1160
- - **[Takeover and Training Guide](training/README.md)** - System onboarding materials for new members/maintainers
1161
-
1162
- ---
1163
-
1164
- ## 💝 Sponsors & Acknowledgments
1165
-
1166
- We are grateful to our sponsors who make this project possible:
1167
-
1168
- ### 🌟 **Special Thanks**
1169
-
1170
- **[@o93](https://github.com/o93)** - *Primary Sponsor & Supporter*
1171
- - 🚀 **MCP Tools Enhancement**: Sponsored the comprehensive MCP fd/ripgrep tools development
1172
- - 🧪 **Testing Infrastructure**: Enabled enterprise-grade test coverage (50+ comprehensive test cases)
1173
- - 🔧 **Quality Assurance**: Supported bug fixes and performance improvements
1174
- - 💡 **Innovation Support**: Made early release of advanced file search and content analysis features possible
1175
-
1176
- *"Thanks to @o93's generous support, we were able to deliver powerful MCP tools that revolutionize how AI assistants interact with codebases. This sponsorship directly enabled the development of ListFilesTool, SearchContentTool, and FindAndGrepTool with comprehensive test coverage."*
1177
-
1178
- ### 🤝 **Become a Sponsor**
1179
-
1180
- Your support helps us:
1181
- - 🔬 Develop new features and tools
1182
- - 🧪 Maintain comprehensive test coverage
1183
- - 📚 Create better documentation
1184
- - 🚀 Accelerate development cycles
1185
-
1186
- **[💖 Sponsor this project](https://github.com/sponsors/aimasteracc)** to help us continue building amazing tools for the developer community!
1187
-
1188
- ---
1189
-
1190
- ## 🤝 Contributing
1191
-
1192
- We welcome all forms of contributions! Please see [Contributing Guide](CONTRIBUTING.md) for details.
1193
-
1194
- ### ⭐ **Give Us a Star!**
1195
-
1196
- If this project has been helpful to you, please give us a ⭐ on GitHub - this is the greatest support for us!
1197
-
1198
- ---
1199
-
1200
- ## 📄 License
1201
-
1202
- MIT License - See [LICENSE](LICENSE) file for details.
1203
-
1204
- ---
1205
-
1206
- **🎯 Built for developers dealing with large codebases and AI assistants**
1207
-
1208
- *Let every line of code be understood by AI, let every project break through token limits*
1209
-
1210
- ---
1211
-
1212
- ## ✅ Prompt Testing Verification
1213
-
1214
- All AI prompts in this document have been thoroughly tested in real environments, ensuring:
1215
-
1216
- - **100% Availability** - All prompts work correctly
1217
- - **Multi-language Support** - Supports Java, Python, JavaScript and other mainstream languages
1218
- - **Path Compatibility** - Both relative and absolute paths are fully supported
1219
- - **Windows/Linux Compatibility** - Cross-platform path formats are automatically handled
1220
- - **Real-time Verification** - Tested using real code files
1221
-
1222
- **Test Environment:**
1223
- - Operating System: Windows 10
1224
- - Project: tree-sitter-analyzer v1.5.0
1225
- - Test Files: BigService.java (1419 lines), sample.py (256 lines), MultiClass.java (54 lines)
1226
- - Test Coverage: 1797 tests passed, 74.45% coverage
1227
- - Test Tools: All MCP tools (check_code_scale, analyze_code_structure, extract_code_section, query_code, list_files, search_content, find_and_grep)
1228
-
1229
- **🚀 Start Now** → [30-Second Quick Start](#-30-second-quick-start)