MCPcopy
hub / github.com/HKUDS/DeepCode / __init__

Method __init__

tools/code_indexer.py:71–249  ·  view source on GitHub ↗
(
        self,
        code_base_path: str = None,
        target_structure: str = None,
        output_dir: str = None,
        config_path: str = "mcp_agent.secrets.yaml",
        indexer_config_path: str = None,
        enable_pre_filtering: bool = True,
    )

Source from the content-addressed store, hash-verified

69 """Main class for building code repository indexes"""
70
71 def __init__(
72 self,
73 code_base_path: str = None,
74 target_structure: str = None,
75 output_dir: str = None,
76 config_path: str = "mcp_agent.secrets.yaml",
77 indexer_config_path: str = None,
78 enable_pre_filtering: bool = True,
79 ):
80 # Load configurations first
81 self.config_path = config_path
82 self.indexer_config_path = indexer_config_path
83 # Derive main config path from secrets path (same directory)
84 secrets_dir = os.path.dirname(os.path.abspath(config_path))
85 self.main_config_path = os.path.join(secrets_dir, "mcp_agent.config.yaml")
86 self.api_config = self._load_api_config()
87 self.indexer_config = self._load_indexer_config()
88 self.default_models = get_default_models(self.main_config_path)
89
90 # Use config paths if not provided as parameters
91 paths_config = self.indexer_config.get("paths", {})
92 self.code_base_path = Path(
93 code_base_path or paths_config.get("code_base_path", "code_base")
94 )
95 self.output_dir = Path(output_dir or paths_config.get("output_dir", "indexes"))
96 self.target_structure = (
97 target_structure # This must be provided as it's project-specific
98 )
99 self.enable_pre_filtering = enable_pre_filtering
100
101 # LLM clients
102 self.llm_client = None
103 self.llm_client_type = None
104
105 # Initialize logger early
106 self.logger = self._setup_logger()
107
108 # Create output directory if it doesn't exist
109 self.output_dir.mkdir(parents=True, exist_ok=True)
110
111 # Load file analysis configuration
112 file_analysis_config = self.indexer_config.get("file_analysis", {})
113 self.supported_extensions = set(
114 file_analysis_config.get(
115 "supported_extensions",
116 [
117 ".py",
118 ".js",
119 ".ts",
120 ".java",
121 ".cpp",
122 ".c",
123 ".h",
124 ".hpp",
125 ".cs",
126 ".php",
127 ".rb",
128 ".go",

Callers

nothing calls this directly

Calls 5

_load_api_configMethod · 0.95
_load_indexer_configMethod · 0.95
_setup_loggerMethod · 0.95
get_default_modelsFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected