tree-sitter-analyzer 0.1.3__py3-none-any.whl → 0.2.0__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.

@@ -12,7 +12,7 @@ Architecture:
12
12
  - Data Models: Generic and language-specific code element representations
13
13
  """
14
14
 
15
- __version__ = "0.1.3"
15
+ __version__ = "0.2.0"
16
16
  __author__ = "aisheng.yu"
17
17
  __email__ = "aimasteracc@gmail.com"
18
18
 
@@ -39,7 +39,7 @@ class TableFormatTool:
39
39
 
40
40
  def get_tool_schema(self) -> Dict[str, Any]:
41
41
  """
42
- Get the MCP tool schema for format_table.
42
+ Get the MCP tool schema for analyze_code_structure.
43
43
 
44
44
  Returns:
45
45
  Dictionary containing the tool schema
@@ -255,7 +255,7 @@ class TableFormatTool:
255
255
  }
256
256
 
257
257
  async def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
258
- """Execute table formatting tool."""
258
+ """Execute code structure analysis tool."""
259
259
  try:
260
260
  # Validate arguments first
261
261
  if "file_path" not in args:
@@ -275,7 +275,7 @@ class TableFormatTool:
275
275
 
276
276
  # Use performance monitoring
277
277
  monitor = get_performance_monitor()
278
- with monitor.measure_operation("table_format_analysis"):
278
+ with monitor.measure_operation("code_structure_analysis"):
279
279
  # Analyze structure using the unified analysis engine
280
280
  request = AnalysisRequest(
281
281
  file_path=file_path,
@@ -328,12 +328,12 @@ class TableFormatTool:
328
328
  }
329
329
 
330
330
  except Exception as e:
331
- self.logger.error(f"Error in table format tool: {e}")
331
+ self.logger.error(f"Error in code structure analysis tool: {e}")
332
332
  raise
333
333
 
334
334
  def get_tool_definition(self) -> Any:
335
335
  """
336
- Get the MCP tool definition for format_table.
336
+ Get the MCP tool definition for analyze_code_structure.
337
337
 
338
338
  Returns:
339
339
  Tool definition object compatible with MCP server
@@ -342,15 +342,15 @@ class TableFormatTool:
342
342
  from mcp.types import Tool
343
343
 
344
344
  return Tool(
345
- name="format_table",
346
- description="Format code analysis results as tables (equivalent to CLI --table=full option)",
345
+ name="analyze_code_structure",
346
+ description="Analyze code structure and generate detailed overview tables (classes, methods, fields) for large files",
347
347
  inputSchema=self.get_tool_schema(),
348
348
  )
349
349
  except ImportError:
350
350
  # Fallback for when MCP is not available
351
351
  return {
352
- "name": "format_table",
353
- "description": "Format code analysis results as tables (equivalent to CLI --table=full option)",
352
+ "name": "analyze_code_structure",
353
+ "description": "Analyze code structure and generate detailed overview tables (classes, methods, fields) for large files",
354
354
  "inputSchema": self.get_tool_schema(),
355
355
  }
356
356
 
@@ -15,7 +15,7 @@ from .models import AnalysisResult
15
15
 
16
16
 
17
17
  class TableFormatter:
18
- """テーブル形式でのフォーマッター"""
18
+ """Table formatter for code analysis results"""
19
19
 
20
20
  def __init__(self, format_type: str = "full", language: str = "java", include_javadoc: bool = False):
21
21
  self.format_type = format_type
@@ -23,17 +23,17 @@ class TableFormatter:
23
23
  self.include_javadoc = include_javadoc
24
24
 
25
25
  def _get_platform_newline(self) -> str:
26
- """プラットフォーム固有の改行コードを取得"""
26
+ """Get platform-specific newline character"""
27
27
  return os.linesep
28
28
 
29
29
  def _convert_to_platform_newlines(self, text: str) -> str:
30
- """通常の\nをプラットフォーム固有の改行コードに変換"""
30
+ """Convert standard \\n to platform-specific newline characters"""
31
31
  if os.linesep != "\n":
32
32
  return text.replace("\n", os.linesep)
33
33
  return text
34
34
 
35
35
  def format_structure(self, structure_data: Dict[str, Any]) -> str:
36
- """構造データをテーブル形式でフォーマット"""
36
+ """Format structure data as table"""
37
37
  if self.format_type == "full":
38
38
  result = self._format_full_table(structure_data)
39
39
  elif self.format_type == "compact":
@@ -43,18 +43,18 @@ class TableFormatter:
43
43
  else:
44
44
  raise ValueError(f"Unsupported format type: {self.format_type}")
45
45
 
46
- # 最終的にプラットフォーム固有の改行コードに変換
47
- # CSV形式の場合は改行変換をスキップ(改行制御は_format_csv内で完結)
46
+ # Finally convert to platform-specific newline characters
47
+ # Skip newline conversion for CSV format (newline control is handled within _format_csv)
48
48
  if self.format_type == "csv":
49
49
  return result
50
50
 
51
51
  return self._convert_to_platform_newlines(result)
52
52
 
53
53
  def _format_full_table(self, data: Dict[str, Any]) -> str:
54
- """完全版テーブル形式"""
54
+ """Full table format"""
55
55
  lines = []
56
56
 
57
- # ヘッダー - 複数クラスがある場合はファイル名を使用
57
+ # Header - use filename when multiple classes exist
58
58
  classes = data.get("classes", [])
59
59
  if classes is None:
60
60
  classes = []
@@ -201,10 +201,10 @@ class TableFormatter:
201
201
  return "\n".join(lines)
202
202
 
203
203
  def _format_compact_table(self, data: Dict[str, Any]) -> str:
204
- """コンパクト版テーブル形式"""
204
+ """Compact table format"""
205
205
  lines = []
206
206
 
207
- # ヘッダー
207
+ # Header
208
208
  package_name = (data.get("package") or {}).get("name", "unknown")
209
209
  classes = data.get("classes", [])
210
210
  if classes is None:
@@ -255,11 +255,11 @@ class TableFormatter:
255
255
  return "\n".join(lines)
256
256
 
257
257
  def _format_csv(self, data: Dict[str, Any]) -> str:
258
- """CSV形式"""
258
+ """CSV format"""
259
259
  output = io.StringIO()
260
- writer = csv.writer(output, lineterminator="\n") # 改行文字を明示的に指定
260
+ writer = csv.writer(output, lineterminator="\n") # Explicitly specify newline character
261
261
 
262
- # ヘッダー
262
+ # Header
263
263
  writer.writerow(
264
264
  ["Type", "Name", "Signature", "Visibility", "Lines", "Complexity", "Doc"]
265
265
  )
@@ -296,9 +296,9 @@ class TableFormatter:
296
296
  ]
297
297
  )
298
298
 
299
- # CSV出力の改行を完全に制御
299
+ # Completely control CSV output newlines
300
300
  csv_content = output.getvalue()
301
- # 全ての改行パターンを統一し、末尾の改行を除去
301
+ # Unify all newline patterns and remove trailing newlines
302
302
  csv_content = csv_content.replace("\r\n", "\n").replace("\r", "\n")
303
303
  csv_content = csv_content.rstrip("\n")
304
304
  output.close()
@@ -411,38 +411,38 @@ class TableFormatter:
411
411
  if not javadoc:
412
412
  return "-"
413
413
 
414
- # コメント記号を除去
414
+ # Remove comment symbols
415
415
  clean_doc = (
416
416
  javadoc.replace("/**", "").replace("*/", "").replace("*", "").strip()
417
417
  )
418
418
 
419
- # 最初の行を取得(通常の\nのみを使用)
419
+ # Get first line (use standard \\n only)
420
420
  lines = clean_doc.split("\n")
421
421
  first_line = lines[0].strip()
422
422
 
423
- # 長すぎる場合は切り詰め
423
+ # Truncate if too long
424
424
  if len(first_line) > 50:
425
425
  first_line = first_line[:47] + "..."
426
426
 
427
- # Markdownテーブルで問題となる文字をエスケープ(通常の\nのみを使用)
427
+ # Escape characters that cause problems in Markdown tables (use standard \\n only)
428
428
  return first_line.replace("|", "\\|").replace("\n", " ")
429
429
 
430
430
  def _clean_csv_text(self, text: str) -> str:
431
- """CSV形式用のテキストクリーニング"""
431
+ """Text cleaning for CSV format"""
432
432
  if not text:
433
433
  return ""
434
434
 
435
- # 改行文字を全て空白に置換
435
+ # Replace all newline characters with spaces
436
436
  cleaned = text.replace("\r\n", " ").replace("\r", " ").replace("\n", " ")
437
- # 連続する空白を単一の空白に変換
437
+ # Convert consecutive spaces to single space
438
438
  cleaned = " ".join(cleaned.split())
439
- # CSVで問題となる文字をエスケープ
440
- cleaned = cleaned.replace('"', '""') # ダブルクォートをエスケープ
439
+ # Escape characters that cause problems in CSV
440
+ cleaned = cleaned.replace('"', '""') # Escape double quotes
441
441
 
442
442
  return cleaned
443
443
 
444
444
 
445
445
  def create_table_formatter(format_type: str, language: str = "java", include_javadoc: bool = False):
446
- """テーブルフォーマッターを作成(新しいファクトリーを使用)"""
447
- # 直接TableFormatterを作成(JavaDoc対応のため)
446
+ """Create table formatter (using new factory)"""
447
+ # Create TableFormatter directly (for JavaDoc support)
448
448
  return TableFormatter(format_type, language, include_javadoc)
@@ -0,0 +1,331 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-analyzer
3
+ Version: 0.2.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: tree-sitter-cpp>=0.23.4
37
+ Requires-Dist: tree-sitter-java>=0.23.5
38
+ Requires-Dist: tree-sitter>=0.20.0
39
+ Provides-Extra: all-languages
40
+ Requires-Dist: tree-sitter-c>=0.20.0; extra == 'all-languages'
41
+ Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'all-languages'
42
+ Requires-Dist: tree-sitter-go>=0.20.0; extra == 'all-languages'
43
+ Requires-Dist: tree-sitter-java>=0.23.5; extra == 'all-languages'
44
+ Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'all-languages'
45
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == 'all-languages'
46
+ Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'all-languages'
47
+ Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'all-languages'
48
+ Provides-Extra: c
49
+ Requires-Dist: tree-sitter-c>=0.20.0; extra == 'c'
50
+ Provides-Extra: cpp
51
+ Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'cpp'
52
+ Provides-Extra: dev
53
+ Requires-Dist: black>=24.0.0; extra == 'dev'
54
+ Requires-Dist: flake8>=7.0.0; extra == 'dev'
55
+ Requires-Dist: isort>=5.13.0; extra == 'dev'
56
+ Requires-Dist: memory-profiler>=0.61.0; extra == 'dev'
57
+ Requires-Dist: mypy>=1.17.0; extra == 'dev'
58
+ Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
59
+ Requires-Dist: psutil>=7.0.0; extra == 'dev'
60
+ Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
61
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
62
+ Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
63
+ Requires-Dist: pytest>=8.4.1; extra == 'dev'
64
+ Requires-Dist: types-psutil>=5.9.0; extra == 'dev'
65
+ Provides-Extra: full
66
+ Requires-Dist: anyio>=4.9.0; extra == 'full'
67
+ Requires-Dist: black>=24.0.0; extra == 'full'
68
+ Requires-Dist: flake8>=7.0.0; extra == 'full'
69
+ Requires-Dist: httpx>=0.28.1; extra == 'full'
70
+ Requires-Dist: isort>=5.13.0; extra == 'full'
71
+ Requires-Dist: mcp>=1.12.2; extra == 'full'
72
+ Requires-Dist: memory-profiler>=0.61.0; extra == 'full'
73
+ Requires-Dist: mypy>=1.17.0; extra == 'full'
74
+ Requires-Dist: pre-commit>=3.0.0; extra == 'full'
75
+ Requires-Dist: psutil>=7.0.0; extra == 'full'
76
+ Requires-Dist: pydantic-settings>=2.10.1; extra == 'full'
77
+ Requires-Dist: pydantic>=2.11.7; extra == 'full'
78
+ Requires-Dist: pytest-asyncio>=1.1.0; extra == 'full'
79
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'full'
80
+ Requires-Dist: pytest-mock>=3.14.1; extra == 'full'
81
+ Requires-Dist: pytest>=8.4.1; extra == 'full'
82
+ Requires-Dist: tree-sitter-c>=0.20.0; extra == 'full'
83
+ Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'full'
84
+ Requires-Dist: tree-sitter-go>=0.20.0; extra == 'full'
85
+ Requires-Dist: tree-sitter-java>=0.23.5; extra == 'full'
86
+ Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'full'
87
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == 'full'
88
+ Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'full'
89
+ Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'full'
90
+ Requires-Dist: types-psutil>=5.9.0; extra == 'full'
91
+ Provides-Extra: go
92
+ Requires-Dist: tree-sitter-go>=0.20.0; extra == 'go'
93
+ Provides-Extra: java
94
+ Requires-Dist: tree-sitter-java>=0.23.5; extra == 'java'
95
+ Provides-Extra: javascript
96
+ Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'javascript'
97
+ Provides-Extra: mcp
98
+ Requires-Dist: anyio>=4.9.0; extra == 'mcp'
99
+ Requires-Dist: httpx>=0.28.1; extra == 'mcp'
100
+ Requires-Dist: mcp>=1.12.2; extra == 'mcp'
101
+ Requires-Dist: pydantic-settings>=2.10.1; extra == 'mcp'
102
+ Requires-Dist: pydantic>=2.11.7; extra == 'mcp'
103
+ Provides-Extra: popular
104
+ Requires-Dist: tree-sitter-java>=0.23.5; extra == 'popular'
105
+ Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'popular'
106
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == 'popular'
107
+ Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'popular'
108
+ Provides-Extra: python
109
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == 'python'
110
+ Provides-Extra: rust
111
+ Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'rust'
112
+ Provides-Extra: systems
113
+ Requires-Dist: tree-sitter-c>=0.20.0; extra == 'systems'
114
+ Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'systems'
115
+ Requires-Dist: tree-sitter-go>=0.20.0; extra == 'systems'
116
+ Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'systems'
117
+ Provides-Extra: test
118
+ Requires-Dist: pytest-asyncio>=1.1.0; extra == 'test'
119
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
120
+ Requires-Dist: pytest-mock>=3.14.1; extra == 'test'
121
+ Requires-Dist: pytest>=8.4.1; extra == 'test'
122
+ Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'test'
123
+ Requires-Dist: tree-sitter-java>=0.23.5; extra == 'test'
124
+ Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'test'
125
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == 'test'
126
+ Provides-Extra: typescript
127
+ Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'typescript'
128
+ Provides-Extra: web
129
+ Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'web'
130
+ Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'web'
131
+ Description-Content-Type: text/markdown
132
+
133
+ # Tree-sitter Analyzer
134
+
135
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
136
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
137
+ [![Tests](https://img.shields.io/badge/tests-1283%20passed-brightgreen.svg)](#testing)
138
+
139
+ **Solve the LLM token limit problem for large code files.**
140
+
141
+ An extensible multi-language code analyzer that helps AI assistants understand code structure without reading entire files. Get code overview, extract specific sections, and analyze complexity - all optimized for LLM workflows.
142
+
143
+ ## ✨ Why Tree-sitter Analyzer?
144
+
145
+ **The Problem:** Large code files exceed LLM token limits, making code analysis inefficient or impossible.
146
+
147
+ **The Solution:** Smart code analysis that provides:
148
+ - 📊 **Code overview** without reading complete files
149
+ - 🎯 **Targeted extraction** of specific line ranges
150
+ - 📍 **Precise positioning** for accurate code operations
151
+ - 🤖 **AI assistant integration** via MCP protocol
152
+
153
+ ## 🚀 Quick Start (5 minutes)
154
+
155
+ ### For AI Assistant Users (Claude Desktop)
156
+
157
+ 1. **Install the package:**
158
+ ```bash
159
+ # Install uv (fast Python package manager)
160
+ curl -LsSf https://astral.sh/uv/install.sh | sh # macOS/Linux
161
+ # or: powershell -c "irm https://astral.sh/uv/install.ps1 | iex" # Windows
162
+
163
+ # No need to install the package separately - uv handles it
164
+ ```
165
+
166
+ 2. **Configure Claude Desktop:**
167
+
168
+ Add to your Claude Desktop config file:
169
+
170
+ **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
171
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
172
+ **Linux:** `~/.config/claude/claude_desktop_config.json`
173
+
174
+ ```json
175
+ {
176
+ "mcpServers": {
177
+ "tree-sitter-analyzer": {
178
+ "command": "uv",
179
+ "args": [
180
+ "run",
181
+ "--with",
182
+ "tree-sitter-analyzer[mcp]",
183
+ "python",
184
+ "-m",
185
+ "tree_sitter_analyzer.mcp.server"
186
+ ]
187
+ }
188
+ }
189
+ }
190
+ ```
191
+
192
+ 3. **Restart Claude Desktop** and start analyzing code!
193
+
194
+ ### For CLI Users
195
+
196
+ ```bash
197
+ # Install with uv (recommended)
198
+ uv add "tree-sitter-analyzer[popular]"
199
+
200
+ # Step 1: Check file scale
201
+ uv run python -m tree_sitter_analyzer examples/Sample.java --advanced
202
+
203
+ # Step 2: Analyze structure (for large files)
204
+ uv run python -m tree_sitter_analyzer examples/Sample.java --table=full
205
+
206
+ # Step 3: Extract specific lines
207
+ uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
208
+ ```
209
+
210
+ ## 🛠️ Core Features
211
+
212
+ ### 1. Code Structure Analysis
213
+ Get comprehensive overview without reading entire files:
214
+ - Classes, methods, fields count
215
+ - Package information
216
+ - Import dependencies
217
+ - Complexity metrics
218
+
219
+ ### 2. Targeted Code Extraction
220
+ Extract specific code sections efficiently:
221
+ - Line range extraction
222
+ - Precise positioning data
223
+ - Content length information
224
+
225
+ ### 3. AI Assistant Integration
226
+ Four powerful MCP tools for AI assistants:
227
+ - `analyze_code_scale` - Get code metrics and complexity
228
+ - `analyze_code_structure` - Generate detailed structure tables
229
+ - `read_code_partial` - Extract specific line ranges
230
+ - `analyze_code_universal` - Universal analysis with auto-detection
231
+
232
+ ### 4. Multi-Language Support
233
+ - **Java** - Full support with advanced analysis
234
+ - **Python** - Complete support
235
+ - **JavaScript/TypeScript** - Full support
236
+ - **C/C++, Rust, Go** - Basic support
237
+
238
+ ## 📖 Usage Examples
239
+
240
+ ### AI Assistant Usage (via Claude Desktop)
241
+
242
+ **Step 1: Get code overview:**
243
+ > "What's the overall complexity and size of this Java file examples/Sample.java?"
244
+
245
+ **Step 2: Analyze code structure (for large files):**
246
+ > "Please analyze the structure of examples/Sample.java and show me a detailed table"
247
+
248
+ **Step 3: Extract specific code:**
249
+ > "Show me lines 84-86 from examples/Sample.java"
250
+
251
+ ### CLI Usage
252
+
253
+ **Step 1: Basic analysis (Check file scale):**
254
+ ```bash
255
+ uv run python -m tree_sitter_analyzer examples/Sample.java --advanced
256
+ ```
257
+
258
+ **Step 2: Structure analysis (For large files that exceed LLM limits):**
259
+ ```bash
260
+ uv run python -m tree_sitter_analyzer examples/Sample.java --table=full
261
+ ```
262
+
263
+ **Step 3: Targeted extraction (Read specific code sections):**
264
+ ```bash
265
+ uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
266
+ ```
267
+
268
+ **Additional Options:**
269
+ ```bash
270
+ # Quiet mode (suppress INFO messages, show only errors)
271
+ uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --quiet
272
+
273
+ # Table output with quiet mode
274
+ uv run python -m tree_sitter_analyzer examples/Sample.java --table=full --quiet
275
+ ```
276
+
277
+ ## 🔧 Installation Options
278
+
279
+ ### For End Users
280
+ ```bash
281
+ # Basic installation
282
+ uv add tree-sitter-analyzer
283
+
284
+ # With popular languages (Java, Python, JS, TS)
285
+ uv add "tree-sitter-analyzer[popular]"
286
+
287
+ # With MCP server support
288
+ uv add "tree-sitter-analyzer[mcp]"
289
+
290
+ # Full installation
291
+ uv add "tree-sitter-analyzer[all,mcp]"
292
+ ```
293
+
294
+ ### For Developers
295
+ ```bash
296
+ # Clone and install for development
297
+ git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
298
+ cd tree-sitter-analyzer
299
+ uv sync --extra all --extra mcp
300
+ ```
301
+
302
+ ## 📚 Documentation
303
+
304
+ - **[MCP Setup Guide for Users](MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
305
+ - **[MCP Setup Guide for Developers](MCP_SETUP_DEVELOPERS.md)** - Local development configuration
306
+ - **[API Documentation](docs/api.md)** - Detailed API reference
307
+ - **[Contributing Guide](CONTRIBUTING.md)** - How to contribute
308
+
309
+ ## 🧪 Testing
310
+
311
+ This project maintains high code quality with **1283 passing tests**.
312
+
313
+ ```bash
314
+ # Run tests
315
+ pytest tests/ -v
316
+
317
+ # Run with coverage
318
+ pytest tests/ --cov=tree_sitter_analyzer
319
+ ```
320
+
321
+ ## 📄 License
322
+
323
+ MIT License - see [LICENSE](LICENSE) file for details.
324
+
325
+ ## 🤝 Contributing
326
+
327
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
328
+
329
+ ---
330
+
331
+ **Made with ❤️ for developers who work with large codebases and AI assistants.**
@@ -1,4 +1,4 @@
1
- tree_sitter_analyzer/__init__.py,sha256=XEH63rciKeejwuvPKCWf332w3HSH_ZtqkX4QVzW5QPA,3003
1
+ tree_sitter_analyzer/__init__.py,sha256=2T4SssTp_5Zh1OTmBsoVN98EShxcUj19PCGR3FPrfrQ,3003
2
2
  tree_sitter_analyzer/__main__.py,sha256=25E8WFUzTFAYqwT5Pdlq6cn8Aa25ogHP3w_5ybbHbNc,317
3
3
  tree_sitter_analyzer/api.py,sha256=-Np6khuxbzBA_T2FN-Z8WDEXz7260OcwKIMP3iz2Kaw,17870
4
4
  tree_sitter_analyzer/cli_main.py,sha256=WTP77Shnaa9yTKy0bMVLUj2i3xtLbIaDDOlUYbS2cGc,9656
@@ -11,7 +11,7 @@ tree_sitter_analyzer/language_loader.py,sha256=okZeUmEeJo_OQJSYCfjzDf29-RuNM9K8-
11
11
  tree_sitter_analyzer/models.py,sha256=2JZAQXM4nJVu7rfnsZFwpvPpv8fpk0POVHKCKeOMLMY,17039
12
12
  tree_sitter_analyzer/output_manager.py,sha256=dh_yfAmvn-XuF7RP5DM5vnqHGRzBUDOsuiVvTjcaOwg,8769
13
13
  tree_sitter_analyzer/query_loader.py,sha256=KrpNnf-plrtymDAfUF6ukw8ELtGWnqhikwPLW_z9vY8,10225
14
- tree_sitter_analyzer/table_formatter.py,sha256=FpYywpJOkXv3FfHEDFSWjfP5ZFa1WJZ6QqN_H0YtUC4,18274
14
+ tree_sitter_analyzer/table_formatter.py,sha256=4ioaIB6Sus-5Wd6ab-GMeRPVg8WH1a4XXkE4T0Ty2SA,18000
15
15
  tree_sitter_analyzer/utils.py,sha256=mL-TexPDTmapE3x7UErVQEJjXWn613KibPbZwgTpkd0,8332
16
16
  tree_sitter_analyzer/cli/__init__.py,sha256=zCYwQW0hKFfZ4w-qoSOnqVKZGtdZ-ziH60Ax0QBE2iQ,886
17
17
  tree_sitter_analyzer/cli/__main__.py,sha256=Sa02Ye57FhkDVTlGrb6U3m9V6II_TIuyzoQIwZtBkZ0,254
@@ -54,7 +54,7 @@ tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py,sha256=Bya1dsy4a-aTzyYSI32N
54
54
  tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py,sha256=xwXuy72FEfoY2TW6URddfdS9Ha_lq8_ZgG0UxC26mLM,8954
55
55
  tree_sitter_analyzer/mcp/tools/base_tool.py,sha256=LpY_QPWbpm8ZGe3SPK7TIBFZMiwkUMpHa8zcswld2ag,1295
56
56
  tree_sitter_analyzer/mcp/tools/read_partial_tool.py,sha256=m71g5RjNkBf-DxXhHGYsRsID5fYfDFs53-2bGZ_C4sQ,11097
57
- tree_sitter_analyzer/mcp/tools/table_format_tool.py,sha256=IUF7N5Je_rV88RkEVz5wet37PZLaDdzXoAC5j1xI3EI,14428
57
+ tree_sitter_analyzer/mcp/tools/table_format_tool.py,sha256=3vfJk-KF7LMkztODZY2yBA3uaaqhvHXbXDrnCZU9ags,14538
58
58
  tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py,sha256=asH_2BLzT-ACLLampyHF61WFn5nSVKL94wE0mU-uui8,19635
59
59
  tree_sitter_analyzer/mcp/utils/__init__.py,sha256=f1WkdJ3XNWgh2NDN0LGNdwk5O-ChqEvnOQ-mINlHPG8,3064
60
60
  tree_sitter_analyzer/mcp/utils/error_handler.py,sha256=VXVutTKA8AvtP_yiX__gqkbsSmK8_pfH3rF_H7yFsVI,18012
@@ -71,7 +71,7 @@ tree_sitter_analyzer/queries/java.py,sha256=hmaj7jKQ_m9nmOAnyiWQhzH-6g41xIi3fwt5
71
71
  tree_sitter_analyzer/queries/javascript.py,sha256=TSe6uSHhBuQU0r2B8YBqpEYkU4q9CYRuTUqRK0WfM5o,4183
72
72
  tree_sitter_analyzer/queries/python.py,sha256=V5MsKmI9A_FqAT2PKkrSL_Xp9bGKBUSpyVPoBmLxxWg,8018
73
73
  tree_sitter_analyzer/queries/typescript.py,sha256=T8a9PwqqGkwLr8clVsAfu0IUIrLKH8u4sBqlU1Cz-FE,7138
74
- tree_sitter_analyzer-0.1.3.dist-info/METADATA,sha256=E-0pK1kOkkAOPLmmHWHcTXUgUzje5VHUTZU6FYw-G6A,18344
75
- tree_sitter_analyzer-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
76
- tree_sitter_analyzer-0.1.3.dist-info/entry_points.txt,sha256=-XEh1racqnCT30mhKWMv5-bgX0iqd_J6b08lZS9J4eg,336
77
- tree_sitter_analyzer-0.1.3.dist-info/RECORD,,
74
+ tree_sitter_analyzer-0.2.0.dist-info/METADATA,sha256=9rRYvib9drv587S9KdVp2ihhu6_BvbPCYut_X-881z8,12409
75
+ tree_sitter_analyzer-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
76
+ tree_sitter_analyzer-0.2.0.dist-info/entry_points.txt,sha256=-XEh1racqnCT30mhKWMv5-bgX0iqd_J6b08lZS9J4eg,336
77
+ tree_sitter_analyzer-0.2.0.dist-info/RECORD,,
@@ -1,444 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: tree-sitter-analyzer
3
- Version: 0.1.3
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: tree-sitter-cpp>=0.23.4
37
- Requires-Dist: tree-sitter-java>=0.23.5
38
- Requires-Dist: tree-sitter>=0.20.0
39
- Provides-Extra: all-languages
40
- Requires-Dist: tree-sitter-c>=0.20.0; extra == 'all-languages'
41
- Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'all-languages'
42
- Requires-Dist: tree-sitter-go>=0.20.0; extra == 'all-languages'
43
- Requires-Dist: tree-sitter-java>=0.23.5; extra == 'all-languages'
44
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'all-languages'
45
- Requires-Dist: tree-sitter-python>=0.23.0; extra == 'all-languages'
46
- Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'all-languages'
47
- Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'all-languages'
48
- Provides-Extra: c
49
- Requires-Dist: tree-sitter-c>=0.20.0; extra == 'c'
50
- Provides-Extra: cpp
51
- Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'cpp'
52
- Provides-Extra: dev
53
- Requires-Dist: black>=24.0.0; extra == 'dev'
54
- Requires-Dist: flake8>=7.0.0; extra == 'dev'
55
- Requires-Dist: isort>=5.13.0; extra == 'dev'
56
- Requires-Dist: memory-profiler>=0.61.0; extra == 'dev'
57
- Requires-Dist: mypy>=1.17.0; extra == 'dev'
58
- Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
59
- Requires-Dist: psutil>=7.0.0; extra == 'dev'
60
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
61
- Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
62
- Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
63
- Requires-Dist: pytest>=8.4.1; extra == 'dev'
64
- Requires-Dist: types-psutil>=5.9.0; extra == 'dev'
65
- Provides-Extra: full
66
- Requires-Dist: anyio>=4.9.0; extra == 'full'
67
- Requires-Dist: black>=24.0.0; extra == 'full'
68
- Requires-Dist: flake8>=7.0.0; extra == 'full'
69
- Requires-Dist: httpx>=0.28.1; extra == 'full'
70
- Requires-Dist: isort>=5.13.0; extra == 'full'
71
- Requires-Dist: mcp>=1.12.2; extra == 'full'
72
- Requires-Dist: memory-profiler>=0.61.0; extra == 'full'
73
- Requires-Dist: mypy>=1.17.0; extra == 'full'
74
- Requires-Dist: pre-commit>=3.0.0; extra == 'full'
75
- Requires-Dist: psutil>=7.0.0; extra == 'full'
76
- Requires-Dist: pydantic-settings>=2.10.1; extra == 'full'
77
- Requires-Dist: pydantic>=2.11.7; extra == 'full'
78
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'full'
79
- Requires-Dist: pytest-cov>=4.0.0; extra == 'full'
80
- Requires-Dist: pytest-mock>=3.14.1; extra == 'full'
81
- Requires-Dist: pytest>=8.4.1; extra == 'full'
82
- Requires-Dist: tree-sitter-c>=0.20.0; extra == 'full'
83
- Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'full'
84
- Requires-Dist: tree-sitter-go>=0.20.0; extra == 'full'
85
- Requires-Dist: tree-sitter-java>=0.23.5; extra == 'full'
86
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'full'
87
- Requires-Dist: tree-sitter-python>=0.23.0; extra == 'full'
88
- Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'full'
89
- Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'full'
90
- Requires-Dist: types-psutil>=5.9.0; extra == 'full'
91
- Provides-Extra: go
92
- Requires-Dist: tree-sitter-go>=0.20.0; extra == 'go'
93
- Provides-Extra: java
94
- Requires-Dist: tree-sitter-java>=0.23.5; extra == 'java'
95
- Provides-Extra: javascript
96
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'javascript'
97
- Provides-Extra: mcp
98
- Requires-Dist: anyio>=4.9.0; extra == 'mcp'
99
- Requires-Dist: httpx>=0.28.1; extra == 'mcp'
100
- Requires-Dist: mcp>=1.12.2; extra == 'mcp'
101
- Requires-Dist: pydantic-settings>=2.10.1; extra == 'mcp'
102
- Requires-Dist: pydantic>=2.11.7; extra == 'mcp'
103
- Provides-Extra: popular
104
- Requires-Dist: tree-sitter-java>=0.23.5; extra == 'popular'
105
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'popular'
106
- Requires-Dist: tree-sitter-python>=0.23.0; extra == 'popular'
107
- Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'popular'
108
- Provides-Extra: python
109
- Requires-Dist: tree-sitter-python>=0.23.0; extra == 'python'
110
- Provides-Extra: rust
111
- Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'rust'
112
- Provides-Extra: systems
113
- Requires-Dist: tree-sitter-c>=0.20.0; extra == 'systems'
114
- Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'systems'
115
- Requires-Dist: tree-sitter-go>=0.20.0; extra == 'systems'
116
- Requires-Dist: tree-sitter-rust>=0.20.0; extra == 'systems'
117
- Provides-Extra: test
118
- Requires-Dist: pytest-asyncio>=1.1.0; extra == 'test'
119
- Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
120
- Requires-Dist: pytest-mock>=3.14.1; extra == 'test'
121
- Requires-Dist: pytest>=8.4.1; extra == 'test'
122
- Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'test'
123
- Requires-Dist: tree-sitter-java>=0.23.5; extra == 'test'
124
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'test'
125
- Requires-Dist: tree-sitter-python>=0.23.0; extra == 'test'
126
- Provides-Extra: typescript
127
- Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'typescript'
128
- Provides-Extra: web
129
- Requires-Dist: tree-sitter-javascript>=0.23.1; extra == 'web'
130
- Requires-Dist: tree-sitter-typescript>=0.20.0; extra == 'web'
131
- Description-Content-Type: text/markdown
132
-
133
- # Tree-sitter Analyzer
134
-
135
- [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
136
- [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
137
- [![Tests](https://img.shields.io/badge/tests-1251%20passed-brightgreen.svg)](#测试)
138
-
139
- An extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture, designed to solve the problem of large code files exceeding LLM single-pass token limits.
140
-
141
- **Available as both CLI tool and MCP server.**
142
-
143
- ## Core Features
144
-
145
- 1. **Code Scale Analysis** - Get overall structure without reading complete files
146
- 2. **Targeted Code Extraction** - Extract specific line ranges efficiently
147
- 3. **Code Position Information** - Get detailed position data for precise extraction
148
-
149
- ## Installation
150
-
151
- ### Prerequisites
152
-
153
- First, install uv (a fast Python package manager):
154
-
155
- ```bash
156
- # On macOS and Linux
157
- curl -LsSf https://astral.sh/uv/install.sh | sh
158
-
159
- # On Windows
160
- powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
161
-
162
- # Or using pip
163
- pip install uv
164
- ```
165
-
166
- ### Install from GitHub
167
-
168
- ```bash
169
- # Basic installation with Java support
170
- # Clone and install the project
171
- git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
172
- cd tree-sitter-analyzer
173
-
174
- # Install with Java support
175
- uv sync
176
-
177
- # With popular languages (Java, Python, JavaScript, TypeScript)
178
- uv sync --extra popular
179
-
180
- # With MCP server support
181
- uv sync --extra mcp
182
-
183
- # Full installation with all features
184
- uv sync --extra all --extra mcp
185
- ```
186
-
187
- ## Usage
188
-
189
- ### CLI Commands
190
-
191
- ```bash
192
- # Code scale analysis
193
- uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --output-format=text
194
-
195
- # Partial code extraction
196
- uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
197
-
198
- # Position information table
199
- uv run python -m tree_sitter_analyzer examples/Sample.java --table=full
200
- ```
201
-
202
- #### CLI Output Examples
203
-
204
- **Code Scale Analysis (`--advanced --output-format=text`):**
205
-
206
- >```
207
- >PS C:\git-public\tree-sitter-analyzer> uv run python -m tree_sitter_analyzer examples/Sample.java --advanced --output-format=text
208
- >2025-07-30 16:57:47,827 - tree_sitter_analyzer - INFO - Successfully loaded 3 language plugins: java, javascript, python
209
- >2025-07-30 16:57:47,916 - tree_sitter_analyzer - INFO - CacheService initialized: L1=100, L2=1000, L3=10000, TTL=3600s
210
- >2025-07-30 16:57:47,917 - tree_sitter_analyzer - INFO - Loading plugins...
211
- >2025-07-30 16:57:47,920 - tree_sitter_analyzer - INFO - Plugin registered for language: java
212
- >2025-07-30 16:57:47,920 - tree_sitter_analyzer - INFO - Plugin registered for language: javascript
213
- >2025-07-30 16:57:47,922 - tree_sitter_analyzer - INFO - Plugin registered for language: python
214
- >2025-07-30 16:57:47,922 - tree_sitter_analyzer - INFO - Successfully loaded 3 language plugins: java, javascript, python
215
- >2025-07-30 16:57:47,923 - tree_sitter_analyzer - INFO - UnifiedAnalysisEngine initialized
216
- >INFO: Language auto-detected from extension: java
217
- >2025-07-30 16:57:47,925 - tree_sitter_analyzer - INFO - Starting analysis for examples/Sample.java
218
- >2025-07-30 16:57:47,945 - tree_sitter_analyzer.core.parser - INFO - Parser initialized successfully
219
- >2025-07-30 16:57:47,951 - PERF - analyze_java: 0.0253s - Operation completed
220
- >2025-07-30 16:57:47,951 - tree_sitter_analyzer.performance - INFO - analyze_java: 0.0253s - Operation completed
221
- >2025-07-30 16:57:47,958 - PERF - unified_analysis: 0.0253s - Analyzed examples/Sample.java (java)
222
- >2025-07-30 16:57:47,958 - tree_sitter_analyzer.performance - INFO - unified_analysis: 0.0253s - Analyzed examples/Sample.java (java)
223
- >
224
- >--- Advanced Analysis Results ---
225
- >"File: examples/Sample.java"
226
- >"Package: (default)"
227
- >"Lines: 178"
228
- >"Classes: 8"
229
- >"Methods: 24"
230
- >"Fields: 5"
231
- >"Imports: 2"
232
- >"Annotations: 0"
233
- >```
234
-
235
- **Partial Code Extraction (`--partial-read`):**
236
- >```
237
- >PS C:\git-public\tree-sitter-analyzer> uv run python -m tree_sitter_analyzer examples/Sample.java --partial-read --start-line 84 --end-line 86
238
- >2025-07-30 16:58:22,948 - tree_sitter_analyzer - INFO - Successfully loaded 3 language plugins: java, javascript, python
239
- >2025-07-30 16:58:23,056 - tree_sitter_analyzer - INFO - Successfully read partial file examples/Sample.java: lines 84-86
240
- >{
241
- > "file_path": "examples/Sample.java",
242
- > "range": {
243
- > "start_line": 84,
244
- > "end_line": 86,
245
- > "start_column": null,
246
- > "end_column": null
247
- > },
248
- > "content": " public void innerMethod() {\n System.out.println(\"Inner class method, value: \" + value);\n }\n",
249
- > "content_length": 117
250
- >}
251
- >```
252
-
253
- **Table Format Analysis (`--table=full`):**
254
-
255
- The `--table=full` command produces detailed analysis tables:
256
-
257
-
258
- ># Sample.java
259
- >
260
- >## Imports
261
- >```java
262
- >java.util.List
263
- >java.util.ArrayList
264
- >```
265
- >
266
- >## Classes
267
- >| Class | Type | Visibility | Lines | Methods | Fields |
268
- >|-------|------|------------|-------|---------|--------|
269
- >| AbstractParentClass | class | public | 7-15 | 2 | 0 |
270
- >| ParentClass | class | public | 18-45 | 4 | 2 |
271
- >| TestInterface | class | public | 48-64 | 3 | 0 |
272
- >| AnotherInterface | class | public | 67-69 | 1 | 0 |
273
- >| Test | class | public | 72-159 | 14 | 3 |
274
- >| InnerClass | class | public | 83-87 | 1 | 0 |
275
- >| StaticNestedClass | class | public | 90-94 | 1 | 0 |
276
- >| TestEnum | class | public | 162-178 | 0 | 0 |
277
- >
278
- >## Fields
279
- >| Name | Type | Vis | Modifiers | Line | Doc |
280
- >|------|------|-----|-----------|------|-----|
281
- >| CONSTANT | String | ~ | static,final | 20 | - |
282
- >| parentField | String | # | protected | 23 | - |
283
- >| value | int | - | private | 74 | - |
284
- >| staticValue | int | + | public,static | 77 | - |
285
- >| finalField | String | - | private,final | 80 | - |
286
- >
287
- >## Constructor
288
- >| Method | Signature | Vis | Lines | Cols | Cx | Doc |
289
- >|--------|-----------|-----|-------|------|----|----|
290
- >| ParentClass | ():void | + | 26-28 | 5-6 | 1 | - |
291
- >| Test | (value:int):void | + | 97-100 | 5-6 | 1 | - |
292
- >| Test | ():void | + | 103-105 | 5-6 | 1 | - |
293
- >
294
- >## Public Methods
295
- >| Method | Signature | Vis | Lines | Cols | Cx | Doc |
296
- >|--------|-----------|-----|-------|------|----|----|
297
- >| innerMethod | ():void | + | 84-86 | 5-6 | 1 | - |
298
- >| nestedMethod | ():void | + | 91-93 | 5-6 | 1 | - |
299
- >| getValue | ():String | + | 108-110 | 5-6 | 1 | - |
300
- >| staticMethod | ():void [static] | + | 128-130 | 5-6 | 1 | - |
301
- >| finalMethod | ():void | + | 133-135 | 5-6 | 1 | - |
302
- >| doSomething | ():void | + | 138-141 | 5-6 | 1 | - |
303
- >| anotherMethod | ():void | + | 143-146 | 5-6 | 1 | - |
304
- >| genericMethod | (input:T):void | + | 149-151 | 5-6 | 1 | - |
305
- >| createList | (item:T):List<T> | + | 154-158 | 5-6 | 1 | - |
306
- >
307
- >## Private Methods
308
- >| Method | Signature | Vis | Lines | Cols | Cx | Doc |
309
- >|--------|-----------|-----|-------|------|----|----|
310
- >| privateMethod | ():void | - | 123-125 | 5-6 | 1 | - |
311
-
312
-
313
- ### MCP Server
314
-
315
- The Tree-sitter Analyzer provides an MCP (Model Context Protocol) server that enables AI assistants to analyze code files directly.
316
-
317
-
318
- #### MCP Configuration
319
-
320
- Add to your Claude Desktop config file:
321
-
322
- ```json
323
- {
324
- "mcpServers": {
325
- "tree-sitter-analyzer": {
326
- "command": "uv",
327
- "args": [
328
- "run",
329
- "--with",
330
- "tree-sitter-analyzer[mcp]",
331
- "python",
332
- "-m",
333
- "tree_sitter_analyzer.mcp.server"
334
- ]
335
- }
336
- }
337
- }
338
- ```
339
-
340
- #### Available MCP Tools
341
-
342
- 1. **analyze_code_scale** - Get code scale and complexity metrics
343
- 2. **format_table** - Generate table-formatted analysis (equivalent to CLI `--table=full`)
344
- 3. **read_code_partial** - Extract specific line ranges from files
345
- 4. **analyze_code_universal** - Universal code analysis with automatic language detection
346
-
347
- #### MCP Usage Examples
348
-
349
- **Code Scale Analysis:**
350
- ```json
351
- {
352
- "tool": "analyze_code_scale",
353
- "arguments": {
354
- "file_path": "examples/Sample.java",
355
- "include_complexity": true,
356
- "include_details": true
357
- }
358
- }
359
- ```
360
-
361
- >```json
362
- >{
363
- > "file_path": "examples/Sample.java",
364
- > "language": "java",
365
- > "analyzer_type": "advanced",
366
- > "analysis_type": "basic",
367
- > "metrics": {
368
- > "lines_total": 178,
369
- > "lines_code": 0,
370
- > "lines_comment": 0,
371
- > "lines_blank": 0,
372
- > "elements": {
373
- > "classes": 8,
374
- > "methods": 24,
375
- > "fields": 5,
376
- > "imports": 2,
377
- > "annotations": 0
378
- > }
379
- > }
380
- >}
381
- >```
382
-
383
- **Table Format Analysis:**
384
- ```json
385
- {
386
- "tool": "format_table",
387
- "arguments": {
388
- "file_path": "examples/Sample.java",
389
- "format_type": "full"
390
- }
391
- }
392
- ```
393
- >```json
394
- >{
395
- > "table_output": "# Sample.java\n\n## Imports\n```java\njava.util.List\njava.util.ArrayList\n```\n\n## Classes\n| Class | Type | >Visibility | Lines | Methods | Fields |\n|-------|------|------------|-------|---------|--------|\n| AbstractParentClass | class | public | >7-15 | 2 | 0 |\n| ParentClass | class | public | 18-45 | 4 | 2 |\n| TestInterface | interface | public | 48-64 | 3 | 0 |\n| >AnotherInterface | interface | public | 67-69 | 1 | 0 |\n| Test | class | public | 72-159 | 14 | 3 |\n| InnerClass | class | public | >83-87 | 1 | 0 |\n| StaticNestedClass | class | public | 90-94 | 1 | 0 |\n| TestEnum | enum | public | 162-178 | 0 | 0 |\n\n## Fields\n| >Name | Type | Vis | Modifiers | Line | Doc |\n|------|------|-----|-----------|------|-----|\n| CONSTANT | String | ~ | static,final | 20 | >- |\n| parentField | String | # | protected | 23 | - |\n| value | int | - | private | 74 | - |\n| staticValue | int | + | public,static | >77 | - |\n| finalField | String | - | private,final | 80 | - |\n\n## Constructor\n| Method | Signature | Vis | Lines | Cols | Cx | Doc |\n|>--------|-----------|-----|-------|------|----|----|\n| ParentClass | ():void | + | 26-28 | 5-6 | 1 | - |\n| Test | (value:int):void | + | >97-100 | 5-6 | 1 | - |\n| Test | ():void | + | 103-105 | 5-6 | 1 | - |\n\n## Public Methods\n| Method | Signature | Vis | Lines | Cols | >Cx | Doc |\n|--------|-----------|-----|-------|------|----|----|\n| innerMethod | ():void | + | 84-86 | 5-6 | 1 | - |\n| nestedMethod | ()>:void | + | 91-93 | 5-6 | 1 | - |\n| getValue | ():String | + | 108-110 | 5-6 | 1 | - |\n| staticMethod | ():void [static] | + | 128-130 | >5-6 | 1 | - |\n| finalMethod | ():void | + | 133-135 | 5-6 | 1 | - |\n| doSomething | ():void | + | 138-141 | 5-6 | 1 | - |\n| >anotherMethod | ():void | + | 143-146 | 5-6 | 1 | - |\n| genericMethod | (input:T):void | + | 149-151 | 5-6 | 1 | - |\n| createList | >(item:T):List<T> | + | 154-158 | 5-6 | 1 | - |\n\n## Private Methods\n| Method | Signature | Vis | Lines | Cols | Cx | Doc |\n|--------|>-----------|-----|-------|------|----|----|\n| privateMethod | ():void | - | 123-125 | 5-6 | 1 | - |",
396
- > "format_type": "full",
397
- > "file_path": "examples/Sample.java",
398
- > "language": "java",
399
- > "metadata": {
400
- > "classes_count": 8,
401
- > "methods_count": 24,
402
- > "fields_count": 5,
403
- > "total_lines": 178
404
- > }
405
- >}
406
- >```
407
-
408
-
409
- **Partial Code Reading:**
410
- ```json
411
- {
412
- "tool": "read_code_partial",
413
- "arguments": {
414
- "file_path": "examples/Sample.java",
415
- "start_line": 84,
416
- "end_line": 86
417
- }
418
- }
419
- ```
420
- >```json
421
- >{
422
- > "partial_content_result": "--- Partial Read Result ---\nFile: examples/Sample.java\nRange: Line 84-86\nCharacters read: 117\n{\n \"file_path\": >\"examples/Sample.java\",\n \"range\": {\n \"start_line\": 84,\n \"end_line\": 86,\n \"start_column\": null,\n \"end_column\": >null\n },\n \"content\": \" public void innerMethod() {\\n System.out.println(\\\"Inner class method, value: \\\" + >value);\\n }\\n\",\n \"content_length\": 117\n}"
423
- >}
424
-
425
-
426
- ## Development
427
-
428
- For developers and contributors:
429
-
430
- ```bash
431
- # Clone the repository
432
- git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
433
- cd tree-sitter-analyzer
434
-
435
- # Install development dependencies
436
- uv sync
437
-
438
- # Run tests
439
- pytest tests/ -v
440
- ```
441
-
442
- ## License
443
-
444
- MIT License