iflow-mcp_kandrwmrtn-cplusplus_mcp 0.1.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.
@@ -0,0 +1,112 @@
1
+ """Configuration loader for C++ analyzer settings."""
2
+
3
+ import json
4
+ import os
5
+ from pathlib import Path
6
+ from typing import Dict, List, Any, Optional
7
+
8
+
9
+ class CppAnalyzerConfig:
10
+ """Loads and manages configuration for the C++ analyzer."""
11
+
12
+ CONFIG_FILENAME = "cpp-analyzer-config.json"
13
+
14
+ DEFAULT_CONFIG = {
15
+ "exclude_directories": [
16
+ ".git",
17
+ ".svn",
18
+ ".hg",
19
+ "node_modules",
20
+ "__pycache__",
21
+ ".pytest_cache",
22
+ ".vs",
23
+ ".vscode",
24
+ ".idea",
25
+ "CMakeFiles",
26
+ "CMakeCache.txt"
27
+ ],
28
+ "dependency_directories": [
29
+ "vcpkg_installed",
30
+ "third_party",
31
+ "ThirdParty",
32
+ "external",
33
+ "External",
34
+ "vendor",
35
+ "dependencies",
36
+ "packages"
37
+ ],
38
+ "exclude_patterns": [],
39
+ "include_dependencies": True,
40
+ "max_file_size_mb": 10
41
+ }
42
+
43
+ def __init__(self, project_root: Path):
44
+ self.project_root = project_root
45
+ # Config file is in the MCP server directory, not the project directory
46
+ mcp_server_root = Path(__file__).parent.parent
47
+ self.config_path = mcp_server_root / self.CONFIG_FILENAME
48
+ self.config = self._load_config()
49
+
50
+ def _load_config(self) -> Dict[str, Any]:
51
+ """Load configuration from file or use defaults."""
52
+ if self.config_path.exists():
53
+ try:
54
+ with open(self.config_path, 'r') as f:
55
+ user_config = json.load(f)
56
+ # Merge with defaults
57
+ config = self.DEFAULT_CONFIG.copy()
58
+ config.update(user_config)
59
+ print(f"Loaded project config from: {self.config_path}", file=os.sys.stderr)
60
+ return config
61
+ except Exception as e:
62
+ print(f"Error loading config from {self.config_path}: {e}", file=os.sys.stderr)
63
+ print("Using default configuration", file=os.sys.stderr)
64
+
65
+ return self.DEFAULT_CONFIG.copy()
66
+
67
+ def get_exclude_directories(self) -> List[str]:
68
+ """Get list of directories to exclude."""
69
+ return self.config.get("exclude_directories", self.DEFAULT_CONFIG["exclude_directories"])
70
+
71
+ def get_dependency_directories(self) -> List[str]:
72
+ """Get list of directories that contain dependencies."""
73
+ return self.config.get("dependency_directories", self.DEFAULT_CONFIG["dependency_directories"])
74
+
75
+ def get_exclude_patterns(self) -> List[str]:
76
+ """Get list of file patterns to exclude."""
77
+ return self.config.get("exclude_patterns", self.DEFAULT_CONFIG["exclude_patterns"])
78
+
79
+ def get_include_dependencies(self) -> bool:
80
+ """Get whether to include dependencies."""
81
+ return self.config.get("include_dependencies", self.DEFAULT_CONFIG["include_dependencies"])
82
+
83
+ def get_max_file_size_mb(self) -> float:
84
+ """Get maximum file size in MB."""
85
+ return self.config.get("max_file_size_mb", self.DEFAULT_CONFIG["max_file_size_mb"])
86
+
87
+ def create_example_config(self) -> None:
88
+ """Create an example configuration file."""
89
+ example_config = {
90
+ "exclude_directories": [
91
+ ".git",
92
+ ".svn",
93
+ "RepoExamples",
94
+ "ThirdParty",
95
+ "Intermediate",
96
+ "Binaries",
97
+ "DerivedDataCache"
98
+ ],
99
+ "exclude_patterns": [
100
+ "*.generated.h",
101
+ "*.generated.cpp",
102
+ "*_test.cpp"
103
+ ],
104
+ "include_dependencies": True,
105
+ "max_file_size_mb": 10,
106
+ "_comment": "Place this .cpp-analyzer.json file in your project root to customize C++ analyzer behavior"
107
+ }
108
+
109
+ with open(self.config_path, 'w') as f:
110
+ json.dump(example_config, f, indent=2)
111
+
112
+ print(f"Created example config at: {self.config_path}", file=os.sys.stderr)