tree-sitter-analyzer 0.9.3__py3-none-any.whl → 0.9.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tree-sitter-analyzer might be problematic. Click here for more details.
- tree_sitter_analyzer/cli/commands/default_command.py +18 -18
- tree_sitter_analyzer/cli/commands/partial_read_command.py +139 -141
- tree_sitter_analyzer/cli/commands/query_command.py +92 -88
- tree_sitter_analyzer/cli/commands/table_command.py +235 -235
- tree_sitter_analyzer/cli/info_commands.py +121 -121
- tree_sitter_analyzer/cli_main.py +307 -307
- tree_sitter_analyzer/core/analysis_engine.py +584 -584
- tree_sitter_analyzer/core/cache_service.py +5 -4
- tree_sitter_analyzer/core/query.py +502 -502
- tree_sitter_analyzer/encoding_utils.py +9 -2
- tree_sitter_analyzer/exceptions.py +400 -406
- tree_sitter_analyzer/formatters/java_formatter.py +291 -291
- tree_sitter_analyzer/formatters/python_formatter.py +259 -259
- tree_sitter_analyzer/interfaces/mcp_server.py +426 -425
- tree_sitter_analyzer/language_detector.py +398 -398
- tree_sitter_analyzer/language_loader.py +224 -224
- tree_sitter_analyzer/languages/java_plugin.py +1202 -1202
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +559 -555
- tree_sitter_analyzer/mcp/server.py +30 -9
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +21 -4
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +22 -4
- tree_sitter_analyzer/mcp/utils/error_handler.py +569 -567
- tree_sitter_analyzer/models.py +470 -470
- tree_sitter_analyzer/security/__init__.py +22 -22
- tree_sitter_analyzer/security/boundary_manager.py +251 -243
- tree_sitter_analyzer/security/regex_checker.py +297 -292
- tree_sitter_analyzer/table_formatter.py +708 -652
- tree_sitter_analyzer/utils.py +61 -19
- tree_sitter_analyzer-0.9.5.dist-info/METADATA +567 -0
- {tree_sitter_analyzer-0.9.3.dist-info → tree_sitter_analyzer-0.9.5.dist-info}/RECORD +32 -32
- tree_sitter_analyzer-0.9.3.dist-info/METADATA +0 -409
- {tree_sitter_analyzer-0.9.3.dist-info → tree_sitter_analyzer-0.9.5.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.9.3.dist-info → tree_sitter_analyzer-0.9.5.dist-info}/entry_points.txt +0 -0
tree_sitter_analyzer/utils.py
CHANGED
|
@@ -49,9 +49,15 @@ def setup_logger(
|
|
|
49
49
|
)
|
|
50
50
|
file_handler.setFormatter(formatter)
|
|
51
51
|
logger.addHandler(file_handler)
|
|
52
|
-
except Exception:
|
|
53
|
-
# Never let logging configuration break runtime behavior
|
|
54
|
-
|
|
52
|
+
except Exception as e:
|
|
53
|
+
# Never let logging configuration break runtime behavior; log to stderr if possible
|
|
54
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
55
|
+
try:
|
|
56
|
+
sys.stderr.write(
|
|
57
|
+
f"[logging_setup] file handler init skipped: {e}\n"
|
|
58
|
+
)
|
|
59
|
+
except Exception:
|
|
60
|
+
...
|
|
55
61
|
|
|
56
62
|
logger.setLevel(level)
|
|
57
63
|
|
|
@@ -107,10 +113,20 @@ def setup_safe_logging_shutdown() -> None:
|
|
|
107
113
|
try:
|
|
108
114
|
handler.close()
|
|
109
115
|
logger.removeHandler(handler)
|
|
110
|
-
except Exception:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
except Exception as e:
|
|
117
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
118
|
+
try:
|
|
119
|
+
sys.stderr.write(
|
|
120
|
+
f"[logging_cleanup] handler close/remove skipped: {e}\n"
|
|
121
|
+
)
|
|
122
|
+
except Exception:
|
|
123
|
+
...
|
|
124
|
+
except Exception as e:
|
|
125
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
126
|
+
try:
|
|
127
|
+
sys.stderr.write(f"[logging_cleanup] cleanup skipped: {e}\n")
|
|
128
|
+
except Exception:
|
|
129
|
+
...
|
|
114
130
|
|
|
115
131
|
# Register cleanup function
|
|
116
132
|
atexit.register(cleanup_logging)
|
|
@@ -128,32 +144,48 @@ def log_info(message: str, *args: Any, **kwargs: Any) -> None:
|
|
|
128
144
|
"""Log info message"""
|
|
129
145
|
try:
|
|
130
146
|
logger.info(message, *args, **kwargs)
|
|
131
|
-
except (ValueError, OSError):
|
|
132
|
-
|
|
147
|
+
except (ValueError, OSError) as e:
|
|
148
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
149
|
+
try:
|
|
150
|
+
sys.stderr.write(f"[log_info] suppressed: {e}\n")
|
|
151
|
+
except Exception:
|
|
152
|
+
...
|
|
133
153
|
|
|
134
154
|
|
|
135
155
|
def log_warning(message: str, *args: Any, **kwargs: Any) -> None:
|
|
136
156
|
"""Log warning message"""
|
|
137
157
|
try:
|
|
138
158
|
logger.warning(message, *args, **kwargs)
|
|
139
|
-
except (ValueError, OSError):
|
|
140
|
-
|
|
159
|
+
except (ValueError, OSError) as e:
|
|
160
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
161
|
+
try:
|
|
162
|
+
sys.stderr.write(f"[log_warning] suppressed: {e}\n")
|
|
163
|
+
except Exception:
|
|
164
|
+
...
|
|
141
165
|
|
|
142
166
|
|
|
143
167
|
def log_error(message: str, *args: Any, **kwargs: Any) -> None:
|
|
144
168
|
"""Log error message"""
|
|
145
169
|
try:
|
|
146
170
|
logger.error(message, *args, **kwargs)
|
|
147
|
-
except (ValueError, OSError):
|
|
148
|
-
|
|
171
|
+
except (ValueError, OSError) as e:
|
|
172
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
173
|
+
try:
|
|
174
|
+
sys.stderr.write(f"[log_error] suppressed: {e}\n")
|
|
175
|
+
except Exception:
|
|
176
|
+
...
|
|
149
177
|
|
|
150
178
|
|
|
151
179
|
def log_debug(message: str, *args: Any, **kwargs: Any) -> None:
|
|
152
180
|
"""Log debug message"""
|
|
153
181
|
try:
|
|
154
182
|
logger.debug(message, *args, **kwargs)
|
|
155
|
-
except (ValueError, OSError):
|
|
156
|
-
|
|
183
|
+
except (ValueError, OSError) as e:
|
|
184
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
185
|
+
try:
|
|
186
|
+
sys.stderr.write(f"[log_debug] suppressed: {e}\n")
|
|
187
|
+
except Exception:
|
|
188
|
+
...
|
|
157
189
|
|
|
158
190
|
|
|
159
191
|
def suppress_output(func: Any) -> Any:
|
|
@@ -175,8 +207,14 @@ def suppress_output(func: Any) -> Any:
|
|
|
175
207
|
finally:
|
|
176
208
|
try:
|
|
177
209
|
sys.stdout.close()
|
|
178
|
-
except Exception:
|
|
179
|
-
|
|
210
|
+
except Exception as e:
|
|
211
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
212
|
+
try:
|
|
213
|
+
sys.stderr.write(
|
|
214
|
+
f"[suppress_output] stdout close suppressed: {e}\n"
|
|
215
|
+
)
|
|
216
|
+
except Exception:
|
|
217
|
+
...
|
|
180
218
|
sys.stdout = old_stdout
|
|
181
219
|
|
|
182
220
|
return result
|
|
@@ -253,8 +291,12 @@ def log_performance(
|
|
|
253
291
|
detail_str = str(details)
|
|
254
292
|
message += f" - {detail_str}"
|
|
255
293
|
perf_logger.debug(message) # Change to DEBUG level
|
|
256
|
-
except (ValueError, OSError):
|
|
257
|
-
|
|
294
|
+
except (ValueError, OSError) as e:
|
|
295
|
+
if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
|
|
296
|
+
try:
|
|
297
|
+
sys.stderr.write(f"[log_performance] suppressed: {e}\n")
|
|
298
|
+
except Exception:
|
|
299
|
+
...
|
|
258
300
|
|
|
259
301
|
|
|
260
302
|
def setup_performance_logger() -> logging.Logger:
|
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-analyzer
|
|
3
|
+
Version: 0.9.5
|
|
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.23.4
|
|
38
|
+
Requires-Dist: tree-sitter-java>=0.23.5
|
|
39
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1
|
|
40
|
+
Requires-Dist: tree-sitter-python>=0.23.6
|
|
41
|
+
Requires-Dist: tree-sitter==0.24.0
|
|
42
|
+
Provides-Extra: all-languages
|
|
43
|
+
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'all-languages'
|
|
44
|
+
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'all-languages'
|
|
45
|
+
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'all-languages'
|
|
46
|
+
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'all-languages'
|
|
47
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'all-languages'
|
|
48
|
+
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'all-languages'
|
|
49
|
+
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'all-languages'
|
|
50
|
+
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'all-languages'
|
|
51
|
+
Provides-Extra: c
|
|
52
|
+
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'c'
|
|
53
|
+
Provides-Extra: cpp
|
|
54
|
+
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'cpp'
|
|
55
|
+
Provides-Extra: dev
|
|
56
|
+
Requires-Dist: black>=24.0.0; extra == 'dev'
|
|
57
|
+
Requires-Dist: isort>=5.13.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: memory-profiler>=0.61.0; extra == 'dev'
|
|
59
|
+
Requires-Dist: mypy>=1.17.0; extra == 'dev'
|
|
60
|
+
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
|
|
61
|
+
Requires-Dist: psutil<6,>=5.9.6; extra == 'dev'
|
|
62
|
+
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
|
|
63
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
64
|
+
Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
|
|
65
|
+
Requires-Dist: pytest>=8.4.1; extra == 'dev'
|
|
66
|
+
Requires-Dist: ruff>=0.5.0; extra == 'dev'
|
|
67
|
+
Requires-Dist: types-psutil>=5.9.0; extra == 'dev'
|
|
68
|
+
Provides-Extra: full
|
|
69
|
+
Requires-Dist: anyio>=4.0.0; extra == 'full'
|
|
70
|
+
Requires-Dist: black>=24.0.0; extra == 'full'
|
|
71
|
+
Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'full'
|
|
72
|
+
Requires-Dist: isort>=5.13.0; extra == 'full'
|
|
73
|
+
Requires-Dist: mcp>=1.12.2; extra == 'full'
|
|
74
|
+
Requires-Dist: memory-profiler>=0.61.0; extra == 'full'
|
|
75
|
+
Requires-Dist: mypy>=1.17.0; extra == 'full'
|
|
76
|
+
Requires-Dist: pre-commit>=3.0.0; extra == 'full'
|
|
77
|
+
Requires-Dist: psutil<6,>=5.9.6; extra == 'full'
|
|
78
|
+
Requires-Dist: pydantic-settings>=2.2.1; extra == 'full'
|
|
79
|
+
Requires-Dist: pydantic>=2.5.0; extra == 'full'
|
|
80
|
+
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'full'
|
|
81
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'full'
|
|
82
|
+
Requires-Dist: pytest-mock>=3.14.1; extra == 'full'
|
|
83
|
+
Requires-Dist: pytest>=8.4.1; extra == 'full'
|
|
84
|
+
Requires-Dist: ruff>=0.5.0; extra == 'full'
|
|
85
|
+
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'full'
|
|
86
|
+
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'full'
|
|
87
|
+
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'full'
|
|
88
|
+
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'full'
|
|
89
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'full'
|
|
90
|
+
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'full'
|
|
91
|
+
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'full'
|
|
92
|
+
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'full'
|
|
93
|
+
Requires-Dist: types-psutil>=5.9.0; extra == 'full'
|
|
94
|
+
Provides-Extra: go
|
|
95
|
+
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'go'
|
|
96
|
+
Provides-Extra: java
|
|
97
|
+
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'java'
|
|
98
|
+
Provides-Extra: javascript
|
|
99
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'javascript'
|
|
100
|
+
Provides-Extra: mcp
|
|
101
|
+
Requires-Dist: anyio>=4.0.0; extra == 'mcp'
|
|
102
|
+
Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'mcp'
|
|
103
|
+
Requires-Dist: mcp>=1.12.2; extra == 'mcp'
|
|
104
|
+
Requires-Dist: pydantic-settings>=2.2.1; extra == 'mcp'
|
|
105
|
+
Requires-Dist: pydantic>=2.5.0; extra == 'mcp'
|
|
106
|
+
Provides-Extra: popular
|
|
107
|
+
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'popular'
|
|
108
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'popular'
|
|
109
|
+
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'popular'
|
|
110
|
+
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'popular'
|
|
111
|
+
Provides-Extra: python
|
|
112
|
+
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'python'
|
|
113
|
+
Provides-Extra: rust
|
|
114
|
+
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'rust'
|
|
115
|
+
Provides-Extra: systems
|
|
116
|
+
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'systems'
|
|
117
|
+
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'systems'
|
|
118
|
+
Requires-Dist: tree-sitter-go>=0.20.0; extra == 'systems'
|
|
119
|
+
Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'systems'
|
|
120
|
+
Provides-Extra: test
|
|
121
|
+
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'test'
|
|
122
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
|
|
123
|
+
Requires-Dist: pytest-mock>=3.14.1; extra == 'test'
|
|
124
|
+
Requires-Dist: pytest>=8.4.1; extra == 'test'
|
|
125
|
+
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'test'
|
|
126
|
+
Requires-Dist: tree-sitter-java>=0.23.5; extra == 'test'
|
|
127
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'test'
|
|
128
|
+
Requires-Dist: tree-sitter-python>=0.23.0; extra == 'test'
|
|
129
|
+
Provides-Extra: typescript
|
|
130
|
+
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'typescript'
|
|
131
|
+
Provides-Extra: web
|
|
132
|
+
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'web'
|
|
133
|
+
Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'web'
|
|
134
|
+
Description-Content-Type: text/markdown
|
|
135
|
+
|
|
136
|
+
# Tree-sitter Analyzer
|
|
137
|
+
|
|
138
|
+
[](https://python.org)
|
|
139
|
+
[](LICENSE)
|
|
140
|
+
[](#quality-assurance)
|
|
141
|
+
[](#quality-assurance)
|
|
142
|
+
[](#quality-assurance)
|
|
143
|
+
[](https://pypi.org/project/tree-sitter-analyzer/)
|
|
144
|
+
[](https://github.com/aimasteracc/tree-sitter-analyzer)
|
|
145
|
+
|
|
146
|
+
## 🚀 Break Through LLM Token Limits, Let AI Understand Code Files of Any Size
|
|
147
|
+
|
|
148
|
+
> **A revolutionary code analysis tool designed for the AI era**
|
|
149
|
+
|
|
150
|
+
## 📋 Table of Contents
|
|
151
|
+
|
|
152
|
+
- [🚀 Break Through LLM Token Limits](#-break-through-llm-token-limits-let-ai-understand-code-files-of-any-size)
|
|
153
|
+
- [📋 Table of Contents](#-table-of-contents)
|
|
154
|
+
- [💡 What Makes This Special](#-what-makes-this-special)
|
|
155
|
+
- [📊 Live Demo & Results](#-live-demo--results)
|
|
156
|
+
- [🚀 30-Second Quick Start](#-30-second-quick-start)
|
|
157
|
+
- [🤖 For AI Users (Claude Desktop, Cursor, etc.)](#-for-ai-users-claude-desktop-cursor-etc)
|
|
158
|
+
- [💻 For Developers (CLI)](#-for-developers-cli)
|
|
159
|
+
- [❓ Why Choose Tree-sitter Analyzer](#-why-choose-tree-sitter-analyzer)
|
|
160
|
+
- [📖 Practical Usage Examples](#-practical-usage-examples)
|
|
161
|
+
- [🛠️ Core Features](#️-core-features)
|
|
162
|
+
- [📦 Installation Guide](#-installation-guide)
|
|
163
|
+
- [🔒 Security & Configuration](#-security--configuration)
|
|
164
|
+
- [🏆 Quality Assurance](#-quality-assurance)
|
|
165
|
+
- [🤖 AI Collaboration Support](#-ai-collaboration-support)
|
|
166
|
+
- [📚 Documentation](#-documentation)
|
|
167
|
+
- [🤝 Contributing](#-contributing)
|
|
168
|
+
- [📄 License](#-license)
|
|
169
|
+
|
|
170
|
+
## 💡 What Makes This Special
|
|
171
|
+
|
|
172
|
+
Imagine: You have a 1,400+ line Java service class that Claude or ChatGPT can't analyze due to token limits. Now, Tree-sitter Analyzer enables AI assistants to:
|
|
173
|
+
|
|
174
|
+
- ⚡ **Get complete code structure overview in 3 seconds**
|
|
175
|
+
- 🎯 **Precisely extract** any line range of code snippets
|
|
176
|
+
- 📍 **Smart positioning** exact locations of classes, methods, fields
|
|
177
|
+
- 🔗 **Seamless integration** with Claude Desktop, Cursor, Roo Code and other AI IDEs
|
|
178
|
+
|
|
179
|
+
**No more AI helplessness due to large files!**
|
|
180
|
+
|
|
181
|
+
## 📊 Live Demo & Results
|
|
182
|
+
|
|
183
|
+
### ⚡ **Lightning-Fast Analysis Speed**
|
|
184
|
+
```bash
|
|
185
|
+
# 1419-line large Java service class analysis result (< 1 second)
|
|
186
|
+
Lines: 1419 | Classes: 1 | Methods: 66 | Fields: 9 | Imports: 8
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 📊 **Precise Structure Tables**
|
|
190
|
+
| Class Name | Type | Visibility | Line Range | Methods | Fields |
|
|
191
|
+
|------------|------|------------|------------|---------|--------|
|
|
192
|
+
| BigService | class | public | 17-1419 | 66 | 9 |
|
|
193
|
+
|
|
194
|
+
### 🔄 **AI Assistant Three-Step Workflow**
|
|
195
|
+
- **Step 1**: `check_code_scale` - Check file scale and complexity
|
|
196
|
+
- **Step 2**: `analyze_code_structure` - Generate detailed structure tables
|
|
197
|
+
- **Step 3**: `extract_code_section` - Extract code snippets on demand
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 🚀 30-Second Quick Start
|
|
202
|
+
|
|
203
|
+
### 🤖 For AI Users (Claude Desktop, Cursor, etc.)
|
|
204
|
+
|
|
205
|
+
**📦 1. One-Click Installation**
|
|
206
|
+
```bash
|
|
207
|
+
# macOS/Linux
|
|
208
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
209
|
+
|
|
210
|
+
# Windows PowerShell
|
|
211
|
+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**⚙️ 2. Configure AI Client**
|
|
215
|
+
|
|
216
|
+
**Claude Desktop Configuration:**
|
|
217
|
+
|
|
218
|
+
Add the following to your config file:
|
|
219
|
+
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
220
|
+
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
221
|
+
- **Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
222
|
+
|
|
223
|
+
**Basic Configuration (Recommended):**
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"mcpServers": {
|
|
227
|
+
"tree-sitter-analyzer": {
|
|
228
|
+
"command": "uv",
|
|
229
|
+
"args": [
|
|
230
|
+
"run", "--with", "tree-sitter-analyzer[mcp]",
|
|
231
|
+
"python", "-m", "tree_sitter_analyzer.mcp.server"
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Advanced Configuration (Specify Project Root):**
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"mcpServers": {
|
|
242
|
+
"tree-sitter-analyzer": {
|
|
243
|
+
"command": "uv",
|
|
244
|
+
"args": [
|
|
245
|
+
"run", "--with", "tree-sitter-analyzer[mcp]",
|
|
246
|
+
"python", "-m", "tree_sitter_analyzer.mcp.server"
|
|
247
|
+
],
|
|
248
|
+
"env": {
|
|
249
|
+
"TREE_SITTER_PROJECT_ROOT": "/absolute/path/to/your/project"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Other AI Clients:**
|
|
257
|
+
- **Cursor**: Built-in MCP support, refer to Cursor documentation for configuration
|
|
258
|
+
- **Roo Code**: Supports MCP protocol, check respective configuration guides
|
|
259
|
+
- **Other MCP-compatible clients**: Use the same server configuration
|
|
260
|
+
|
|
261
|
+
**⚠️ Configuration Notes:**
|
|
262
|
+
- **Basic Configuration**: Tool will auto-detect project root (recommended)
|
|
263
|
+
- **Advanced Configuration**: If you need to specify a particular directory, use absolute path to replace `/absolute/path/to/your/project`
|
|
264
|
+
- **Avoid using**: Variables like `${workspaceFolder}` may not be supported in some clients
|
|
265
|
+
|
|
266
|
+
**🎉 3. Restart AI client and start analyzing massive code files!**
|
|
267
|
+
|
|
268
|
+
### 💻 For Developers (CLI)
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Install
|
|
272
|
+
uv add "tree-sitter-analyzer[popular]"
|
|
273
|
+
|
|
274
|
+
# Check file scale (1419-line large service class, instant completion)
|
|
275
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
|
|
276
|
+
|
|
277
|
+
# Generate structure table (1 class, 66 methods, clearly displayed)
|
|
278
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
|
|
279
|
+
|
|
280
|
+
# Precise code extraction
|
|
281
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --start-line 100 --end-line 105
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## ❓ Why Choose Tree-sitter Analyzer
|
|
287
|
+
|
|
288
|
+
### 🎯 Solving Real Pain Points
|
|
289
|
+
|
|
290
|
+
**Traditional Approach Dilemmas:**
|
|
291
|
+
- ❌ Large files exceed LLM token limits
|
|
292
|
+
- ❌ AI cannot understand code structure
|
|
293
|
+
- ❌ Manual file splitting required
|
|
294
|
+
- ❌ Context loss leads to inaccurate analysis
|
|
295
|
+
|
|
296
|
+
**Tree-sitter Analyzer's Breakthrough:**
|
|
297
|
+
- ✅ **Smart Analysis**: Understand structure without reading complete files
|
|
298
|
+
- ✅ **Precise Positioning**: Accurate line-by-line code extraction
|
|
299
|
+
- ✅ **AI Native**: Optimized for LLM workflows
|
|
300
|
+
- ✅ **Multi-language Support**: Java, Python, JavaScript/TypeScript, etc.
|
|
301
|
+
|
|
302
|
+
## 📖 Practical Usage Examples
|
|
303
|
+
|
|
304
|
+
### 💬 AI IDE Prompts (Copy and Use)
|
|
305
|
+
|
|
306
|
+
#### 🔍 **Step 1: Check File Scale**
|
|
307
|
+
|
|
308
|
+
**Prompt:**
|
|
309
|
+
```
|
|
310
|
+
Use MCP tool check_code_scale to analyze file scale
|
|
311
|
+
Parameters: {"file_path": "examples/BigService.java"}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Return Format:**
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"file_path": "examples/BigService.java",
|
|
318
|
+
"language": "java",
|
|
319
|
+
"metrics": {
|
|
320
|
+
"lines_total": 1419,
|
|
321
|
+
"lines_code": 1419,
|
|
322
|
+
"elements": {
|
|
323
|
+
"classes": 1,
|
|
324
|
+
"methods": 66,
|
|
325
|
+
"fields": 9
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
#### 📊 **Step 2: Generate Structure Table**
|
|
332
|
+
|
|
333
|
+
**Prompt:**
|
|
334
|
+
```
|
|
335
|
+
Use MCP tool analyze_code_structure to generate detailed structure
|
|
336
|
+
Parameters: {"file_path": "examples/BigService.java"}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Return Format:**
|
|
340
|
+
- Complete Markdown table
|
|
341
|
+
- Including class info, method list (with line numbers), field list
|
|
342
|
+
- Method signatures, visibility, line ranges, complexity and other detailed information
|
|
343
|
+
|
|
344
|
+
#### ✂️ **Step 3: Extract Code Snippets**
|
|
345
|
+
|
|
346
|
+
**Prompt:**
|
|
347
|
+
```
|
|
348
|
+
Use MCP tool extract_code_section to extract specified code section
|
|
349
|
+
Parameters: {"file_path": "examples/BigService.java", "start_line": 100, "end_line": 105}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Return Format:**
|
|
353
|
+
```json
|
|
354
|
+
{
|
|
355
|
+
"file_path": "examples/BigService.java",
|
|
356
|
+
"range": {"start_line": 100, "end_line": 105},
|
|
357
|
+
"content": "Actual code content...",
|
|
358
|
+
"content_length": 245
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
#### 💡 **Important Notes**
|
|
363
|
+
- **Parameter Format**: Use snake_case (`file_path`, `start_line`, `end_line`)
|
|
364
|
+
- **Path Handling**: Relative paths auto-resolve to project root
|
|
365
|
+
- **Security Protection**: Tool automatically performs project boundary checks
|
|
366
|
+
- **Workflow**: Recommended to use in order: Step 1 → 2 → 3
|
|
367
|
+
|
|
368
|
+
### 🛠️ CLI Command Examples
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# Quick analysis (1419-line large file, instant completion)
|
|
372
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --advanced --output-format=text
|
|
373
|
+
|
|
374
|
+
# Detailed structure table (66 methods clearly displayed)
|
|
375
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full
|
|
376
|
+
|
|
377
|
+
# Precise code extraction (memory usage monitoring code snippet)
|
|
378
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --partial-read --start-line 100 --end-line 105
|
|
379
|
+
|
|
380
|
+
# Silent mode (display results only)
|
|
381
|
+
uv run python -m tree_sitter_analyzer examples/BigService.java --table=full --quiet
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## 🛠️ Core Features
|
|
387
|
+
|
|
388
|
+
### 📊 **Code Structure Analysis**
|
|
389
|
+
Get insights without reading complete files:
|
|
390
|
+
- Class, method, field statistics
|
|
391
|
+
- Package information and import dependencies
|
|
392
|
+
- Complexity metrics
|
|
393
|
+
- Precise line number positioning
|
|
394
|
+
|
|
395
|
+
### ✂️ **Smart Code Extraction**
|
|
396
|
+
- Extract by line range precisely
|
|
397
|
+
- Maintain original formatting and indentation
|
|
398
|
+
- Include position metadata
|
|
399
|
+
- Support efficient processing of large files
|
|
400
|
+
|
|
401
|
+
### 🔗 **AI Assistant Integration**
|
|
402
|
+
Deep integration via MCP protocol:
|
|
403
|
+
- Claude Desktop
|
|
404
|
+
- Cursor IDE
|
|
405
|
+
- Roo Code
|
|
406
|
+
- Other MCP-supporting AI tools
|
|
407
|
+
|
|
408
|
+
### 🌍 **Multi-Language Support**
|
|
409
|
+
- **Java** - Full support, including Spring, JPA frameworks
|
|
410
|
+
- **Python** - Complete support, including type annotations, decorators
|
|
411
|
+
- **JavaScript/TypeScript** - Full support, including ES6+ features
|
|
412
|
+
- **C/C++, Rust, Go** - Basic support
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## 📦 Installation Guide
|
|
417
|
+
|
|
418
|
+
### 👤 **End Users**
|
|
419
|
+
```bash
|
|
420
|
+
# Basic installation
|
|
421
|
+
uv add tree-sitter-analyzer
|
|
422
|
+
|
|
423
|
+
# Popular languages package (recommended)
|
|
424
|
+
uv add "tree-sitter-analyzer[popular]"
|
|
425
|
+
|
|
426
|
+
# MCP server support
|
|
427
|
+
uv add "tree-sitter-analyzer[mcp]"
|
|
428
|
+
|
|
429
|
+
# Full installation
|
|
430
|
+
uv add "tree-sitter-analyzer[all,mcp]"
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### 👨💻 **Developers**
|
|
434
|
+
```bash
|
|
435
|
+
git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
|
|
436
|
+
cd tree-sitter-analyzer
|
|
437
|
+
uv sync --extra all --extra mcp
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## 🔒 Security & Configuration
|
|
443
|
+
|
|
444
|
+
### 🛡️ **Project Boundary Protection**
|
|
445
|
+
|
|
446
|
+
Tree-sitter Analyzer automatically detects and protects project boundaries:
|
|
447
|
+
|
|
448
|
+
- **Auto-detection**: Based on `.git`, `pyproject.toml`, `package.json`, etc.
|
|
449
|
+
- **CLI Control**: `--project-root /path/to/project`
|
|
450
|
+
- **MCP Integration**: `TREE_SITTER_PROJECT_ROOT=/path/to/project` or use auto-detection
|
|
451
|
+
- **Security Guarantee**: Only analyze files within project boundaries
|
|
452
|
+
|
|
453
|
+
**Recommended MCP Configuration:**
|
|
454
|
+
|
|
455
|
+
**Option 1: Auto-detection (Recommended)**
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"mcpServers": {
|
|
459
|
+
"tree-sitter-analyzer": {
|
|
460
|
+
"command": "uv",
|
|
461
|
+
"args": ["run", "--with", "tree-sitter-analyzer[mcp]", "python", "-m", "tree_sitter_analyzer.mcp.server"]
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
**Option 2: Manual Project Root Specification**
|
|
468
|
+
```json
|
|
469
|
+
{
|
|
470
|
+
"mcpServers": {
|
|
471
|
+
"tree-sitter-analyzer": {
|
|
472
|
+
"command": "uv",
|
|
473
|
+
"args": ["run", "--with", "tree-sitter-analyzer[mcp]", "python", "-m", "tree_sitter_analyzer.mcp.server"],
|
|
474
|
+
"env": {"TREE_SITTER_PROJECT_ROOT": "/path/to/your/project"}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## 🏆 Quality Assurance
|
|
483
|
+
|
|
484
|
+
### 📊 **Quality Metrics**
|
|
485
|
+
- **1,358 Tests** - 100% pass rate ✅
|
|
486
|
+
- **74.54% Code Coverage** - Industry-leading level
|
|
487
|
+
- **Zero Test Failures** - Complete CI/CD ready
|
|
488
|
+
- **Cross-platform Compatible** - Windows, macOS, Linux
|
|
489
|
+
|
|
490
|
+
### ⚡ **Latest Quality Achievements (v0.9.4)**
|
|
491
|
+
- ✅ **Test Suite Completely Stable** - Fixed all historical issues
|
|
492
|
+
- ✅ **Formatter Module Breakthrough** - Coverage significantly improved
|
|
493
|
+
- ✅ **Error Handling Optimization** - Enterprise-grade exception handling
|
|
494
|
+
- ✅ **100+ New Comprehensive Tests** - Covering critical modules
|
|
495
|
+
|
|
496
|
+
### ⚙️ **Running Tests**
|
|
497
|
+
```bash
|
|
498
|
+
# Run all tests
|
|
499
|
+
uv run pytest tests/ -v
|
|
500
|
+
|
|
501
|
+
# Generate coverage report
|
|
502
|
+
uv run pytest tests/ --cov=tree_sitter_analyzer --cov-report=html
|
|
503
|
+
|
|
504
|
+
# Run specific tests
|
|
505
|
+
uv run pytest tests/test_mcp_server_initialization.py -v
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### 📈 **Coverage Highlights**
|
|
509
|
+
- **Language Detector**: 98.41% (Excellent)
|
|
510
|
+
- **CLI Main Entry**: 97.78% (Excellent)
|
|
511
|
+
- **Error Handling**: 82.76% (Good)
|
|
512
|
+
- **Security Framework**: 78%+ (Reliable)
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## 🤖 AI Collaboration Support
|
|
517
|
+
|
|
518
|
+
### ⚡ **Optimized for AI Development**
|
|
519
|
+
|
|
520
|
+
This project supports AI-assisted development with specialized quality controls:
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
# AI system pre-code generation checks
|
|
524
|
+
uv run python check_quality.py --new-code-only
|
|
525
|
+
uv run python llm_code_checker.py --check-all
|
|
526
|
+
|
|
527
|
+
# AI-generated code review
|
|
528
|
+
uv run python llm_code_checker.py path/to/new_file.py
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
📖 **Detailed Guides**:
|
|
532
|
+
- [AI Collaboration Guide](AI_COLLABORATION_GUIDE.md)
|
|
533
|
+
- [LLM Coding Guidelines](LLM_CODING_GUIDELINES.md)
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
## 📚 Documentation
|
|
538
|
+
|
|
539
|
+
- **[User MCP Setup Guide](MCP_SETUP_USERS.md)** - Simple configuration guide
|
|
540
|
+
- **[Developer MCP Setup Guide](MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
541
|
+
- **[Project Root Configuration](PROJECT_ROOT_CONFIG.md)** - Complete configuration reference
|
|
542
|
+
- **[API Documentation](docs/api.md)** - Detailed API reference
|
|
543
|
+
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
## 🤝 Contributing
|
|
548
|
+
|
|
549
|
+
We welcome all forms of contributions! Please check the [Contributing Guide](CONTRIBUTING.md) for details.
|
|
550
|
+
|
|
551
|
+
### ⭐ **Give Us a Star!**
|
|
552
|
+
|
|
553
|
+
If this project helps you, please give us a ⭐ on GitHub - it's the greatest support for us!
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## 📄 License
|
|
558
|
+
|
|
559
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
**🎯 Built for developers dealing with large codebases and AI assistants**
|
|
564
|
+
|
|
565
|
+
*Let every line of code be understood by AI, let every project break through token limits*
|
|
566
|
+
|
|
567
|
+
**🚀 Start Now** → [30-Second Quick Start](#-30-second-quick-start)
|