tree-sitter-analyzer 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tree-sitter-analyzer might be problematic. Click here for more details.
- tree_sitter_analyzer/__init__.py +1 -1
- tree_sitter_analyzer/interfaces/cli.py +1 -1
- tree_sitter_analyzer/mcp/server.py +45 -19
- tree_sitter_analyzer/mcp/tools/__init__.py +0 -5
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +1 -2
- tree_sitter_analyzer/plugins/python_plugin.py +598 -598
- tree_sitter_analyzer/utils.py +98 -22
- {tree_sitter_analyzer-0.1.0.dist-info → tree_sitter_analyzer-0.1.2.dist-info}/METADATA +69 -206
- {tree_sitter_analyzer-0.1.0.dist-info → tree_sitter_analyzer-0.1.2.dist-info}/RECORD +11 -12
- tree_sitter_analyzer-0.1.2.dist-info/entry_points.txt +8 -0
- tree_sitter_analyzer/mcp/tools/get_positions_tool.py +0 -448
- tree_sitter_analyzer-0.1.0.dist-info/entry_points.txt +0 -8
- {tree_sitter_analyzer-0.1.0.dist-info → tree_sitter_analyzer-0.1.2.dist-info}/WHEEL +0 -0
tree_sitter_analyzer/__init__.py
CHANGED
|
@@ -51,7 +51,7 @@ Examples:
|
|
|
51
51
|
# Get framework information
|
|
52
52
|
tree-sitter-analyzer info
|
|
53
53
|
|
|
54
|
-
For more information, visit: https://github.com/
|
|
54
|
+
For more information, visit: https://github.com/aimasteracc/tree-sitter-analyzer
|
|
55
55
|
"""
|
|
56
56
|
)
|
|
57
57
|
|
|
@@ -45,7 +45,6 @@ from ..utils import setup_logger
|
|
|
45
45
|
from . import MCP_INFO
|
|
46
46
|
from .resources import CodeFileResource, ProjectStatsResource
|
|
47
47
|
from .tools.base_tool import MCPTool
|
|
48
|
-
from .tools.get_positions_tool import GetPositionsTool
|
|
49
48
|
from .tools.read_partial_tool import ReadPartialTool
|
|
50
49
|
from .tools.table_format_tool import TableFormatTool
|
|
51
50
|
from .tools.universal_analyze_tool import UniversalAnalyzeTool
|
|
@@ -73,7 +72,6 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
73
72
|
# Initialize MCP tools
|
|
74
73
|
self.read_partial_tool: MCPTool = ReadPartialTool()
|
|
75
74
|
self.universal_analyze_tool: MCPTool = UniversalAnalyzeTool()
|
|
76
|
-
self.get_positions_tool: MCPTool = GetPositionsTool()
|
|
77
75
|
self.table_format_tool: MCPTool = TableFormatTool()
|
|
78
76
|
|
|
79
77
|
# Initialize MCP resources
|
|
@@ -145,7 +143,6 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
145
143
|
# Add tools from tool classes - FIXED VERSION
|
|
146
144
|
for tool_instance in [
|
|
147
145
|
self.read_partial_tool,
|
|
148
|
-
self.get_positions_tool,
|
|
149
146
|
self.table_format_tool,
|
|
150
147
|
self.universal_analyze_tool,
|
|
151
148
|
]:
|
|
@@ -181,14 +178,6 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
181
178
|
text=json.dumps(result, indent=2, ensure_ascii=False),
|
|
182
179
|
)
|
|
183
180
|
]
|
|
184
|
-
elif name == "get_code_positions":
|
|
185
|
-
result = await self.get_positions_tool.execute(arguments)
|
|
186
|
-
return [
|
|
187
|
-
TextContent(
|
|
188
|
-
type="text",
|
|
189
|
-
text=json.dumps(result, indent=2, ensure_ascii=False),
|
|
190
|
-
)
|
|
191
|
-
]
|
|
192
181
|
elif name == "format_table":
|
|
193
182
|
result = await self.table_format_tool.execute(arguments)
|
|
194
183
|
return [
|
|
@@ -209,7 +198,10 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
209
198
|
raise ValueError(f"Unknown tool: {name}")
|
|
210
199
|
|
|
211
200
|
except Exception as e:
|
|
212
|
-
|
|
201
|
+
try:
|
|
202
|
+
logger.error(f"Tool call error for {name}: {e}")
|
|
203
|
+
except (ValueError, OSError):
|
|
204
|
+
pass # Silently ignore logging errors during shutdown
|
|
213
205
|
return [
|
|
214
206
|
TextContent(
|
|
215
207
|
type="text",
|
|
@@ -258,11 +250,17 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
258
250
|
raise ValueError(f"Resource not found: {uri}")
|
|
259
251
|
|
|
260
252
|
except Exception as e:
|
|
261
|
-
|
|
253
|
+
try:
|
|
254
|
+
logger.error(f"Resource read error for {uri}: {e}")
|
|
255
|
+
except (ValueError, OSError):
|
|
256
|
+
pass # Silently ignore logging errors during shutdown
|
|
262
257
|
raise
|
|
263
258
|
|
|
264
259
|
self.server = server
|
|
265
|
-
|
|
260
|
+
try:
|
|
261
|
+
logger.info("MCP server created successfully")
|
|
262
|
+
except (ValueError, OSError):
|
|
263
|
+
pass # Silently ignore logging errors during shutdown
|
|
266
264
|
return server
|
|
267
265
|
|
|
268
266
|
def set_project_path(self, project_path: str) -> None:
|
|
@@ -273,7 +271,10 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
273
271
|
project_path: Path to the project directory
|
|
274
272
|
"""
|
|
275
273
|
self.project_stats_resource.set_project_path(project_path)
|
|
276
|
-
|
|
274
|
+
try:
|
|
275
|
+
logger.info(f"Set project path to: {project_path}")
|
|
276
|
+
except (ValueError, OSError):
|
|
277
|
+
pass # Silently ignore logging errors during shutdown
|
|
277
278
|
|
|
278
279
|
async def run(self) -> None:
|
|
279
280
|
"""
|
|
@@ -293,14 +294,27 @@ class TreeSitterAnalyzerMCPServer:
|
|
|
293
294
|
capabilities=MCP_INFO["capabilities"],
|
|
294
295
|
)
|
|
295
296
|
|
|
296
|
-
|
|
297
|
+
try:
|
|
298
|
+
logger.info(f"Starting MCP server: {self.name} v{self.version}")
|
|
299
|
+
except (ValueError, OSError):
|
|
300
|
+
pass # Silently ignore logging errors during shutdown
|
|
297
301
|
|
|
298
302
|
try:
|
|
299
303
|
async with stdio_server() as (read_stream, write_stream):
|
|
300
304
|
await server.run(read_stream, write_stream, options)
|
|
301
305
|
except Exception as e:
|
|
302
|
-
|
|
306
|
+
# Use safe logging to avoid I/O errors during shutdown
|
|
307
|
+
try:
|
|
308
|
+
logger.error(f"Server error: {e}")
|
|
309
|
+
except (ValueError, OSError):
|
|
310
|
+
pass # Silently ignore logging errors during shutdown
|
|
303
311
|
raise
|
|
312
|
+
finally:
|
|
313
|
+
# Safe cleanup
|
|
314
|
+
try:
|
|
315
|
+
logger.info("MCP server shutting down")
|
|
316
|
+
except (ValueError, OSError):
|
|
317
|
+
pass # Silently ignore logging errors during shutdown
|
|
304
318
|
|
|
305
319
|
|
|
306
320
|
async def main() -> None:
|
|
@@ -309,10 +323,22 @@ async def main() -> None:
|
|
|
309
323
|
server = TreeSitterAnalyzerMCPServer()
|
|
310
324
|
await server.run()
|
|
311
325
|
except KeyboardInterrupt:
|
|
312
|
-
|
|
326
|
+
try:
|
|
327
|
+
logger.info("Server stopped by user")
|
|
328
|
+
except (ValueError, OSError):
|
|
329
|
+
pass # Silently ignore logging errors during shutdown
|
|
313
330
|
except Exception as e:
|
|
314
|
-
|
|
331
|
+
try:
|
|
332
|
+
logger.error(f"Server failed: {e}")
|
|
333
|
+
except (ValueError, OSError):
|
|
334
|
+
pass # Silently ignore logging errors during shutdown
|
|
315
335
|
sys.exit(1)
|
|
336
|
+
finally:
|
|
337
|
+
# Ensure clean shutdown
|
|
338
|
+
try:
|
|
339
|
+
logger.info("MCP server shutdown complete")
|
|
340
|
+
except (ValueError, OSError):
|
|
341
|
+
pass # Silently ignore logging errors during shutdown
|
|
316
342
|
|
|
317
343
|
|
|
318
344
|
if __name__ == "__main__":
|
|
@@ -24,11 +24,6 @@ AVAILABLE_TOOLS: Dict[str, Dict[str, Any]] = {
|
|
|
24
24
|
# "module": "read_partial_tool",
|
|
25
25
|
# "class": "ReadPartialTool",
|
|
26
26
|
# },
|
|
27
|
-
# "get_code_positions": {
|
|
28
|
-
# "description": "Get position information for code elements",
|
|
29
|
-
# "module": "get_positions_tool",
|
|
30
|
-
# "class": "GetPositionsTool",
|
|
31
|
-
# },
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
__all__ = [
|
|
@@ -235,7 +235,7 @@ class AnalyzeScaleTool:
|
|
|
235
235
|
elif total_lines < 1500:
|
|
236
236
|
guidance["size_category"] = "large"
|
|
237
237
|
guidance["analysis_strategy"] = (
|
|
238
|
-
"This is a large file. Use targeted analysis with
|
|
238
|
+
"This is a large file. Use targeted analysis with read_code_partial."
|
|
239
239
|
)
|
|
240
240
|
else:
|
|
241
241
|
guidance["size_category"] = "very_large"
|
|
@@ -245,7 +245,6 @@ class AnalyzeScaleTool:
|
|
|
245
245
|
|
|
246
246
|
# Recommend tools based on file size and complexity
|
|
247
247
|
if total_lines > 200:
|
|
248
|
-
guidance["recommended_tools"].append("get_code_positions")
|
|
249
248
|
guidance["recommended_tools"].append("read_code_partial")
|
|
250
249
|
|
|
251
250
|
if len(structural_overview["complexity_hotspots"]) > 0:
|