tree-sitter-analyzer 1.8.3__py3-none-any.whl → 1.8.4__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__ = "1.8.2"
14
+ __version__ = "1.8.4"
15
15
  __author__ = "aisheng.yu"
16
16
  __email__ = "aimasteracc@gmail.com"
17
17
 
@@ -9,7 +9,9 @@ import atexit
9
9
  import logging
10
10
  import os
11
11
  import sys
12
+ import tempfile
12
13
  from functools import wraps
14
+ from pathlib import Path
13
15
  from typing import Any
14
16
 
15
17
 
@@ -51,6 +53,10 @@ def setup_logger(
51
53
  if name.startswith("test_"):
52
54
  logger.handlers.clear()
53
55
 
56
+ # Initialize file logging variables at function scope
57
+ enable_file_log = os.environ.get("TREE_SITTER_ANALYZER_ENABLE_FILE_LOG", "").lower() == "true"
58
+ file_log_level = level # Default to main logger level
59
+
54
60
  if not logger.handlers: # Avoid duplicate handlers
55
61
  # Create a safe handler that writes to stderr to avoid breaking MCP stdio
56
62
  handler = SafeStreamHandler()
@@ -60,27 +66,68 @@ def setup_logger(
60
66
  handler.setFormatter(formatter)
61
67
  logger.addHandler(handler)
62
68
 
63
- # Also log to a local file for debugging when launched by clients (e.g., Cursor)
69
+ # Optional file logging for debugging when launched by clients (e.g., Cursor)
64
70
  # This helps diagnose cases where stdio is captured by the client and logs are hidden.
65
- try:
66
- file_handler = logging.FileHandler(
67
- "cursor_mcp_server.log", encoding="utf-8"
68
- )
69
- file_handler.setFormatter(formatter)
70
- logger.addHandler(file_handler)
71
- except Exception as e:
72
- # Never let logging configuration break runtime behavior; log to stderr if possible
73
- if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
74
- try:
75
- sys.stderr.write(
76
- f"[logging_setup] file handler init skipped: {e}\n"
77
- )
78
- except Exception:
79
- ...
71
+ # Only enabled when TREE_SITTER_ANALYZER_ENABLE_FILE_LOG is set to 'true'
72
+ if enable_file_log:
73
+ try:
74
+ # Determine log directory
75
+ log_dir = os.environ.get("TREE_SITTER_ANALYZER_LOG_DIR")
76
+ if log_dir:
77
+ # Use specified directory
78
+ log_path = Path(log_dir) / "tree_sitter_analyzer.log"
79
+ # Ensure directory exists
80
+ Path(log_dir).mkdir(parents=True, exist_ok=True)
81
+ else:
82
+ # Use system temporary directory
83
+ temp_dir = tempfile.gettempdir()
84
+ log_path = Path(temp_dir) / "tree_sitter_analyzer.log"
85
+
86
+ # Determine file log level
87
+ file_log_level_str = os.environ.get("TREE_SITTER_ANALYZER_FILE_LOG_LEVEL", "").upper()
88
+ if file_log_level_str and file_log_level_str in ["DEBUG", "INFO", "WARNING", "ERROR"]:
89
+ if file_log_level_str == "DEBUG":
90
+ file_log_level = logging.DEBUG
91
+ elif file_log_level_str == "INFO":
92
+ file_log_level = logging.INFO
93
+ elif file_log_level_str == "WARNING":
94
+ file_log_level = logging.WARNING
95
+ elif file_log_level_str == "ERROR":
96
+ file_log_level = logging.ERROR
97
+ else:
98
+ # Use same level as main logger
99
+ file_log_level = level
100
+
101
+ file_handler = logging.FileHandler(str(log_path), encoding="utf-8")
102
+ file_handler.setFormatter(formatter)
103
+ file_handler.setLevel(file_log_level)
104
+ logger.addHandler(file_handler)
105
+
106
+ # Log the file location for debugging purposes
107
+ if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
108
+ try:
109
+ sys.stderr.write(f"[logging_setup] File logging enabled: {log_path}\n")
110
+ except Exception:
111
+ ...
112
+
113
+ except Exception as e:
114
+ # Never let logging configuration break runtime behavior; log to stderr if possible
115
+ if hasattr(sys, "stderr") and hasattr(sys.stderr, "write"):
116
+ try:
117
+ sys.stderr.write(
118
+ f"[logging_setup] file handler init skipped: {e}\n"
119
+ )
120
+ except Exception:
121
+ ...
80
122
 
81
- # Always set the level, even if handlers already exist
82
- # Ensure the level is properly set, not inherited
83
- logger.setLevel(level)
123
+ # Set the logger level to the minimum of main level and file log level
124
+ # This ensures that all messages that should go to any handler are processed
125
+ final_level = level
126
+ if enable_file_log:
127
+ # Use the minimum level to ensure all messages reach their intended handlers
128
+ final_level = min(level, file_log_level)
129
+
130
+ logger.setLevel(final_level)
84
131
 
85
132
  # For test loggers, ensure they don't inherit from parent and force level
86
133
  if logger.name.startswith("test_"):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tree-sitter-analyzer
3
- Version: 1.8.3
3
+ Version: 1.8.4
4
4
  Summary: AI-era enterprise-grade code analysis tool with comprehensive HTML/CSS support, dynamic plugin architecture, and MCP integration
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
@@ -198,11 +198,11 @@ Description-Content-Type: text/markdown
198
198
 
199
199
  [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
200
200
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
201
- [![Tests](https://img.shields.io/badge/tests-3361%20passed-brightgreen.svg)](#quality-assurance)
201
+ [![Tests](https://img.shields.io/badge/tests-3380%20passed-brightgreen.svg)](#quality-assurance)
202
202
  [![Coverage](https://codecov.io/gh/aimasteracc/tree-sitter-analyzer/branch/main/graph/badge.svg)](https://codecov.io/gh/aimasteracc/tree-sitter-analyzer)
203
203
  [![Quality](https://img.shields.io/badge/quality-enterprise%20grade-blue.svg)](#quality-assurance)
204
204
  [![PyPI](https://img.shields.io/pypi/v/tree-sitter-analyzer.svg)](https://pypi.org/project/tree-sitter-analyzer/)
205
- [![Version](https://img.shields.io/badge/version-1.8.3-blue.svg)](https://github.com/aimasteracc/tree-sitter-analyzer/releases)
205
+ [![Version](https://img.shields.io/badge/version-1.8.4-blue.svg)](https://github.com/aimasteracc/tree-sitter-analyzer/releases)
206
206
  [![zread](https://img.sh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uNjAwMSAxMS4wMzg0IDUuNjAwMUgxMy43NTg0QzE0LjExMTkgNS42MDAxIDE0LjM5ODQgNS4zMTM1NiAxNC4zOTg0IDQuOTYwMVYyLjI0MDFDMTQuMzk4NCAxLjg4NjY0IDE0LjExMTkgMS42MDAxIDEzLjc1ODQgMS42MDAxWiIgZmlsbD0iI2ZmZiIvPgo8cGF0aCBkPSJNNCAxMkwxMiA0TDQgMTJaIiBmaWxsPSIjZmZmIi8%2BCjxwYXRoIGQ9Ik00IDEyTDEyIDQiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIvPgo8L3N2Zz4K&logoColor=ffffff)](https://zread.ai/aimasteracc/tree-sitter-analyzer)
207
207
  [![GitHub Stars](https://img.shields.io/github/stars/aimasteracc/tree-sitter-analyzer.svg?style=social)](https://github.com/aimasteracc/tree-sitter-analyzer)
208
208
 
@@ -255,7 +255,7 @@ Tree-sitter Analyzer is an enterprise-grade code analysis tool designed for the
255
255
  | **Go** | Basic Support | Basic syntax parsing |
256
256
 
257
257
  ### 🏆 Production Ready
258
- - **3,361 Tests** - 100% pass rate, enterprise-grade quality assurance
258
+ - **3,380 Tests** - 100% pass rate, enterprise-grade quality assurance
259
259
  - **High Coverage** - Comprehensive test coverage
260
260
  - **Cross-platform Support** - Compatible with Windows, macOS, Linux
261
261
  - **Continuous Maintenance** - Active development and community support
@@ -373,6 +373,7 @@ rg --version
373
373
  - **Roo Code**: Supports MCP protocol, use the same configuration format
374
374
  - **Other MCP-compatible clients**: Use the same server configuration
375
375
 
376
+
376
377
  ---
377
378
 
378
379
  ### 3.2 💻 CLI Users (Command Line Tools)
@@ -640,6 +641,19 @@ Tree-sitter Analyzer provides a rich set of MCP tools designed for AI assistants
640
641
  | **📁 Resource Access** | Code file resources | URI code file access | File content access via URI identification |
641
642
  | | Project statistics resources | Project statistics data access | Project analysis data and statistical information |
642
643
 
644
+ ### 🆕 v1.8.4 New Feature: Configurable File Logging
645
+
646
+ Revolutionary environment variable-controlled file logging system:
647
+
648
+ - **🔧 Environment Variable Control**: Flexible file logging behavior control through environment variables
649
+ - `TREE_SITTER_ANALYZER_ENABLE_FILE_LOG`: Enable/disable file logging
650
+ - `TREE_SITTER_ANALYZER_LOG_DIR`: Custom log directory path
651
+ - `TREE_SITTER_ANALYZER_FILE_LOG_LEVEL`: Control file log level
652
+ - **🛡️ Improved Default Behavior**: File logging disabled by default to prevent user project pollution
653
+ - **📁 Smart Directory Selection**: Uses system temp directory when enabled, keeping projects clean
654
+ - **🔄 Backward Compatibility**: Maintains all existing functionality unchanged
655
+ - **📚 Complete Documentation Support**: Includes debugging guides and troubleshooting documentation
656
+
643
657
  ### 🆕 v1.8.3 New Feature: MCP Tools Design Consistency Enhancement
644
658
 
645
659
  Comprehensive MCP tools unification and design consistency improvements:
@@ -859,7 +873,7 @@ uv run python -m tree_sitter_analyzer --show-query-languages
859
873
  ## 8. 🏆 Quality Assurance
860
874
 
861
875
  ### 📊 Quality Metrics
862
- - **3,361 tests** - 100% pass rate ✅
876
+ - **3,380 tests** - 100% pass rate ✅
863
877
  - **High code coverage** - Comprehensive test suite
864
878
  - **Zero test failures** - Production ready
865
879
  - **Cross-platform support** - Windows, macOS, Linux
@@ -1,4 +1,4 @@
1
- tree_sitter_analyzer/__init__.py,sha256=h6zUP8Chm-_bNNKaCIY25G3h_JKBLIed582ErUTq0Zc,3067
1
+ tree_sitter_analyzer/__init__.py,sha256=Bg7okJtLa1BS4OaksNMVLvvdDXWbdWF0AKsoRp5aTig,3067
2
2
  tree_sitter_analyzer/__main__.py,sha256=Zl79tpe4UaMu-7yeztc06tgP0CVMRnvGgas4ZQP5SCs,228
3
3
  tree_sitter_analyzer/api.py,sha256=gqHatRpVm8k0jEfFm45iokHRPYJjEcud6MtrCSg1V0A,22169
4
4
  tree_sitter_analyzer/cli_main.py,sha256=RAPn4VGHVOfC2vrU1Sef7PEPcypMwuI5GgWiwoYL1PE,11100
@@ -13,7 +13,7 @@ tree_sitter_analyzer/output_manager.py,sha256=hRAp6Aa9k05UVvZkOyRCEz2Lf7blx05fWn
13
13
  tree_sitter_analyzer/project_detector.py,sha256=-zmtm12EvVD_6TDxS_6KpzuswP2Bpppnxq50kAEDyMA,9430
14
14
  tree_sitter_analyzer/query_loader.py,sha256=rtUZ_ZBhacb2uvM8aPrf0XiigUDtxflfjbenfKcatEI,10407
15
15
  tree_sitter_analyzer/table_formatter.py,sha256=tPKw77LLlQ7k5MMs9_Ez7qsSroNaSzZPoplyPtKHLhA,28577
16
- tree_sitter_analyzer/utils.py,sha256=hezEhJ4TGAFTRa-Ii_i42jPLkspAme-GRsZR5e38OBQ,13650
16
+ tree_sitter_analyzer/utils.py,sha256=YN4n_XDJQAvcP2eKqYV7AzsZW1UMtks9O4BLR2youjs,16110
17
17
  tree_sitter_analyzer/cli/__init__.py,sha256=O_3URpbdu5Ilb2-r48LjbZuWtOWQu_BhL3pa6C0G3Bk,871
18
18
  tree_sitter_analyzer/cli/__main__.py,sha256=Xq8o8-0dPnMDU9WZqmqhzr98rx8rvoffTUHAkAwl-L8,218
19
19
  tree_sitter_analyzer/cli/argument_validator.py,sha256=n336uNVWE9FFWc5s1ADKNQq53_BSnqdTtqEFk90UDBI,2574
@@ -103,7 +103,7 @@ tree_sitter_analyzer/security/regex_checker.py,sha256=jWK6H8PTPgzbwRPfK_RZ8bBTS6
103
103
  tree_sitter_analyzer/security/validator.py,sha256=PJ2CxYANMi7Ot4rPq2sUgfEF0f7EXoS_3mWqEG4Y-8w,21966
104
104
  tree_sitter_analyzer/utils/__init__.py,sha256=U2zLA7-80BE7NB9nV5coL2hdS-TPey22U4il9VkPfRA,3747
105
105
  tree_sitter_analyzer/utils/tree_sitter_compat.py,sha256=9hvig3RQp_9H-YN1AWjW1Dl8fugYOPF-M8TRb41LMZU,10861
106
- tree_sitter_analyzer-1.8.3.dist-info/METADATA,sha256=wX-JLRVnrFtpqPkfohoMvZR2eG3dj4cFF55cAJBNdMY,48288
107
- tree_sitter_analyzer-1.8.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
108
- tree_sitter_analyzer-1.8.3.dist-info/entry_points.txt,sha256=TJmEXxAMz3og3VPphTHsuE8tNJxf7GuAPjNHwVhXRnc,972
109
- tree_sitter_analyzer-1.8.3.dist-info/RECORD,,
106
+ tree_sitter_analyzer-1.8.4.dist-info/METADATA,sha256=WWE_1AkppJ-PZ6PsD5aAa1jDwl7_vyPARYHEWSpduFA,49119
107
+ tree_sitter_analyzer-1.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
108
+ tree_sitter_analyzer-1.8.4.dist-info/entry_points.txt,sha256=TJmEXxAMz3og3VPphTHsuE8tNJxf7GuAPjNHwVhXRnc,972
109
+ tree_sitter_analyzer-1.8.4.dist-info/RECORD,,