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

@@ -11,7 +11,7 @@ Architecture:
11
11
  - Data Models: Generic and language-specific code element representations
12
12
  """
13
13
 
14
- __version__ = "0.4.0"
14
+ __version__ = "0.8.2"
15
15
  __author__ = "aisheng.yu"
16
16
  __email__ = "aimasteracc@gmail.com"
17
17
 
@@ -24,7 +24,7 @@ class QueryCommand(BaseCommand):
24
24
  query_to_execute = query_loader.get_query(language, sanitized_query_key)
25
25
  if query_to_execute is None:
26
26
  output_error(
27
- f"ERROR: Query '{sanitized_query_key}' not found for language '{language}'"
27
+ f"Query '{sanitized_query_key}' not found for language '{language}'"
28
28
  )
29
29
  return 1
30
30
  except ValueError as e:
@@ -71,6 +71,10 @@ class TreeSitterAnalyzerMCPServer:
71
71
  def __init__(self, project_root: str = None) -> None:
72
72
  """Initialize the MCP server with analyzer components."""
73
73
  self.server: Server | None = None
74
+ self._initialization_complete = False
75
+
76
+ logger.info("Starting MCP server initialization...")
77
+
74
78
  self.analysis_engine = get_analysis_engine(project_root)
75
79
  self.security_validator = SecurityValidator(project_root)
76
80
  # Use unified analysis engine instead of deprecated AdvancedAnalyzer
@@ -88,13 +92,24 @@ class TreeSitterAnalyzerMCPServer:
88
92
  self.name = MCP_INFO["name"]
89
93
  self.version = MCP_INFO["version"]
90
94
 
91
- logger.info(f"Initializing {self.name} v{self.version}")
95
+ self._initialization_complete = True
96
+ logger.info(f"MCP server initialization complete: {self.name} v{self.version}")
97
+
98
+ def is_initialized(self) -> bool:
99
+ """Check if the server is fully initialized."""
100
+ return self._initialization_complete
101
+
102
+ def _ensure_initialized(self) -> None:
103
+ """Ensure the server is initialized before processing requests."""
104
+ if not self._initialization_complete:
105
+ raise RuntimeError("Server not fully initialized. Please wait for initialization to complete.")
92
106
 
93
107
  @handle_mcp_errors("analyze_code_scale")
94
108
  async def _analyze_code_scale(self, arguments: dict[str, Any]) -> dict[str, Any]:
95
109
  """
96
110
  Analyze code scale and complexity metrics by delegating to the universal_analyze_tool.
97
111
  """
112
+ self._ensure_initialized()
98
113
  # Delegate the execution to the already initialized tool
99
114
  return await self.universal_analyze_tool.execute(arguments)
100
115
 
@@ -168,6 +183,9 @@ class TreeSitterAnalyzerMCPServer:
168
183
  ) -> list[TextContent]:
169
184
  """Handle tool calls with security validation."""
170
185
  try:
186
+ # Ensure server is fully initialized
187
+ self._ensure_initialized()
188
+
171
189
  # Security validation for tool name
172
190
  sanitized_name = self.security_validator.sanitize_input(name, max_length=100)
173
191
 
@@ -491,6 +491,24 @@ def handle_mcp_errors(
491
491
  async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
492
492
  try:
493
493
  return await func(*args, **kwargs)
494
+ except RuntimeError as e:
495
+ # Handle initialization errors specifically
496
+ if "not fully initialized" in str(e):
497
+ logger.warning(f"Request received before initialization complete: {operation}")
498
+ raise MCPError(
499
+ "Server is still initializing. Please wait a moment and try again.",
500
+ category=ErrorCategory.CONFIGURATION,
501
+ severity=ErrorSeverity.LOW
502
+ ) from e
503
+ # Handle other runtime errors normally
504
+ error_handler = get_error_handler()
505
+ context = {
506
+ "function": func.__name__,
507
+ "args": str(args)[:200], # Limit length
508
+ "kwargs": str(kwargs)[:200],
509
+ }
510
+ error_info = error_handler.handle_error(e, context, operation)
511
+ raise
494
512
  except Exception as e:
495
513
  error_handler = get_error_handler()
496
514
  context = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tree-sitter-analyzer
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: Extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture
5
5
  Project-URL: Homepage, https://github.com/aimasteracc/tree-sitter-analyzer
6
6
  Project-URL: Documentation, https://github.com/aimasteracc/tree-sitter-analyzer#readme
@@ -137,7 +137,9 @@ Description-Content-Type: text/markdown
137
137
 
138
138
  [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
139
139
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
140
- [![Tests](https://img.shields.io/badge/tests-1126%20passed-brightgreen.svg)](#testing)
140
+ [![Tests](https://img.shields.io/badge/tests-1358%20passed-brightgreen.svg)](#testing)
141
+ [![Coverage](https://img.shields.io/badge/coverage-74.82%25-green.svg)](#testing)
142
+ [![Quality](https://img.shields.io/badge/quality-enterprise%20grade-blue.svg)](#quality)
141
143
 
142
144
  **Solve the LLM token limit problem for large code files.**
143
145
 
@@ -332,18 +334,43 @@ Tree-sitter-analyzer automatically detects and secures your project boundaries:
332
334
  }
333
335
  ```
334
336
 
335
- ## 🧪 Testing
337
+ ## 🧪 Testing & Quality
336
338
 
337
- This project maintains high code quality with **1126 passing tests**.
339
+ This project maintains **enterprise-grade quality** with comprehensive testing:
338
340
 
341
+ ### 📊 Quality Metrics
342
+ - **1358 tests** - 100% pass rate ✅
343
+ - **74.82% code coverage** - Industry standard quality
344
+ - **Zero test failures** - Complete CI/CD readiness
345
+ - **Cross-platform compatibility** - Windows, macOS, Linux
346
+
347
+ ### 🏆 Recent Quality Achievements (v0.8.2)
348
+ - ✅ **Complete test suite stabilization** - Fixed all 31 failing tests
349
+ - ✅ **Formatters module breakthrough** - 0% → 42.30% coverage
350
+ - ✅ **Error handling improvements** - 61.64% → 82.76% coverage
351
+ - ✅ **104 new comprehensive tests** across critical modules
352
+
353
+ ### 🔧 Running Tests
339
354
  ```bash
340
- # Run tests
355
+ # Run all tests
341
356
  pytest tests/ -v
342
357
 
343
- # Run with coverage
344
- pytest tests/ --cov=tree_sitter_analyzer
358
+ # Run with coverage report
359
+ pytest tests/ --cov=tree_sitter_analyzer --cov-report=html
360
+
361
+ # Run specific test categories
362
+ pytest tests/test_formatters_comprehensive.py -v
363
+ pytest tests/test_core_engine_extended.py -v
364
+ pytest tests/test_mcp_server_initialization.py -v
345
365
  ```
346
366
 
367
+ ### 📈 Coverage Highlights
368
+ - **Formatters**: 42.30% (newly established)
369
+ - **Error Handler**: 82.76% (major improvement)
370
+ - **Language Detector**: 98.41% (excellent)
371
+ - **CLI Main**: 97.78% (excellent)
372
+ - **Security Framework**: 78%+ across all modules
373
+
347
374
  ## 📄 License
348
375
 
349
376
  MIT License - see [LICENSE](LICENSE) file for details.
@@ -1,4 +1,4 @@
1
- tree_sitter_analyzer/__init__.py,sha256=T8urKvmHQaqEoh_-jKgNJOb2Snz2ySjMqYWE53vLKKA,3199
1
+ tree_sitter_analyzer/__init__.py,sha256=-lo6TSefiCDM_k3KrKfLoxr7KadlTEse4bSpGKEO9aQ,3199
2
2
  tree_sitter_analyzer/__main__.py,sha256=ilhMPpn_ar28oelzxLfQcX6WH_UbQ2euxiSoV3z_yCg,239
3
3
  tree_sitter_analyzer/api.py,sha256=_94HoE1LKGELSE6FpZ6pEqm2R7qfoPokyfpGSjawliQ,17487
4
4
  tree_sitter_analyzer/cli_main.py,sha256=ses68m5tLoYMP6Co3Fk2vqBACuFd38MqF85uEoa0mbw,9714
@@ -21,7 +21,7 @@ tree_sitter_analyzer/cli/commands/advanced_command.py,sha256=YJGrFBEqFPpS0VB-o28
21
21
  tree_sitter_analyzer/cli/commands/base_command.py,sha256=0CyODjCOWahH2x-PdeirxrKJMBNzTeRkfPvPuimhIXA,6770
22
22
  tree_sitter_analyzer/cli/commands/default_command.py,sha256=R9_GuI5KVYPK2DfXRuG8L89vwxv0QVW8sur_sigjZKo,542
23
23
  tree_sitter_analyzer/cli/commands/partial_read_command.py,sha256=kD3E2f1zCseSKpGQ3bgHnEuCq-DCPRQrT91JJJh8B4Q,4776
24
- tree_sitter_analyzer/cli/commands/query_command.py,sha256=5GlctGaJIc_3AGdISMNFJkbGB3hx6YixYBnKK8VmsF0,3647
24
+ tree_sitter_analyzer/cli/commands/query_command.py,sha256=TNkmuUKaTmTYD80jc8eesYLpw59YVk-6nw478SsYWH8,3640
25
25
  tree_sitter_analyzer/cli/commands/structure_command.py,sha256=u-NKm06CLgx4srdK5bVo7WtcV4dArA7WYWQWmeXcWMs,5358
26
26
  tree_sitter_analyzer/cli/commands/summary_command.py,sha256=X3pLK7t2ma4SDlG7yYsaFX6bQ4OVUrHv8OWDfgTMNMw,3703
27
27
  tree_sitter_analyzer/cli/commands/table_command.py,sha256=BAIw26WRi_yXbKvkuV7tXFKzSiWvYKVzRUxAcgsJ7VQ,9676
@@ -46,7 +46,7 @@ tree_sitter_analyzer/languages/java_plugin.py,sha256=o_9F_anKCemnUDV6hq28RatRmBm
46
46
  tree_sitter_analyzer/languages/javascript_plugin.py,sha256=9al0ScXmM5Y8Xl82oNp7cUaU9P59eNCJCPXSlfea4u8,16290
47
47
  tree_sitter_analyzer/languages/python_plugin.py,sha256=nlVxDx6thOB5o6QfQzGbD7gph3_YuM32YYzqYZoHlMw,29899
48
48
  tree_sitter_analyzer/mcp/__init__.py,sha256=mL_XjEks3tJOGAl9ULs_09KQOH1BWi92yvXpBidwmlI,752
49
- tree_sitter_analyzer/mcp/server.py,sha256=7p5LdihdLMl0BH_u6vGk1VDLTiycLzAOeBsxaug4LrY,15669
49
+ tree_sitter_analyzer/mcp/server.py,sha256=F7QIsQDI3hEdgak-9dbKqnhyN3ZWatohFBTuJGgHS0Y,16409
50
50
  tree_sitter_analyzer/mcp/resources/__init__.py,sha256=PHDvZyHZawoToDQVqrepsmcTk00ZlaTsu6uxwVjoa4A,1433
51
51
  tree_sitter_analyzer/mcp/resources/code_file_resource.py,sha256=MDHvJl6akElHtcxlN6eCcY5WYSjQEQFCyhAVGiPGk9s,6462
52
52
  tree_sitter_analyzer/mcp/resources/project_stats_resource.py,sha256=lZF9TGxjKvTwPyuWE_o3I3V4LK0zEj3lab4L0Iq-hho,19758
@@ -58,7 +58,7 @@ tree_sitter_analyzer/mcp/tools/read_partial_tool.py,sha256=Hjfl1-b0BVsT-g6zr0-px
58
58
  tree_sitter_analyzer/mcp/tools/table_format_tool.py,sha256=JUfkB32ZXf-RQ5O2nKC2jFTVR1AxD8lks5vjjDFEoNw,15502
59
59
  tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py,sha256=MbJEzWa0b2KtHLIgmy5WVcCN89YL4tB1drujoHt9axs,22173
60
60
  tree_sitter_analyzer/mcp/utils/__init__.py,sha256=F_qFFC2gvGNdgRWGLxIh4Amd0dPhZv0Ni1ZbCbaYLlI,3063
61
- tree_sitter_analyzer/mcp/utils/error_handler.py,sha256=n9ME2U5L1o65Vewnv8kD2O8dVI1CiEGm1pLWdnpnyqM,17972
61
+ tree_sitter_analyzer/mcp/utils/error_handler.py,sha256=tygl1E9fcI-2i7F-b1m3FYzJV9WvecSuskq6fDhSbgQ,18924
62
62
  tree_sitter_analyzer/plugins/__init__.py,sha256=MfSW8P9GLaL_9XgLISdlpIUY4quqapk0avPLIpBdMTg,10606
63
63
  tree_sitter_analyzer/plugins/base.py,sha256=or-p0ZkXxVPuXEsysRbOcBGo2r-Di-BgnN3e0fnN44Q,17696
64
64
  tree_sitter_analyzer/plugins/manager.py,sha256=DTe1kGNzElOKXjlcKuHkA-SOOpInBeFCeT6rSdxR3AI,12914
@@ -71,7 +71,7 @@ tree_sitter_analyzer/security/__init__.py,sha256=zVpzS5jtECwgYnhKL4YoMfnIdkJABnV
71
71
  tree_sitter_analyzer/security/boundary_manager.py,sha256=e4iOJTygHLqlImkOntjLhfTpCvqCfb2LTpYwGpYmVQg,8051
72
72
  tree_sitter_analyzer/security/regex_checker.py,sha256=Qvldh-TiVYqtcYQbD80wk0eHUvhALYtWTWBy_bGmJUk,10025
73
73
  tree_sitter_analyzer/security/validator.py,sha256=yL72kKnMN2IeqJk3i9l9FpWP9_Mt4lPErpj8ys5J_WY,9118
74
- tree_sitter_analyzer-0.8.1.dist-info/METADATA,sha256=DGfahyUO9cgkNyyOUtwQrew4UtZbTSpanuhAivGRSN8,14422
75
- tree_sitter_analyzer-0.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
76
- tree_sitter_analyzer-0.8.1.dist-info/entry_points.txt,sha256=EA0Ow27x2SqNt2300sv70RTWxKRIxJzOhNPIVlez4NM,417
77
- tree_sitter_analyzer-0.8.1.dist-info/RECORD,,
74
+ tree_sitter_analyzer-0.8.2.dist-info/METADATA,sha256=W-2T_9PbJLD8k3pO4ZlURfmbgXPYjg44ObN1FZnp1gw,15638
75
+ tree_sitter_analyzer-0.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
76
+ tree_sitter_analyzer-0.8.2.dist-info/entry_points.txt,sha256=EA0Ow27x2SqNt2300sv70RTWxKRIxJzOhNPIVlez4NM,417
77
+ tree_sitter_analyzer-0.8.2.dist-info/RECORD,,