MCPcopy Create free account
hub / github.com/Louisym/MiniCC / load

Method load

tutorials/09_config_system.py:122–154  ·  view source on GitHub ↗

加载并合并所有配置。 算法: 1. 遍历所有可能的配置文件路径 2. 跳过不存在的文件 3. 读取存在的文件(JSON) 4. 按优先级深度合并 对应源码: config.rs:214-247

(self)

Source from the content-addressed store, hash-verified

120 ]
121
122 def load(self) -> "RuntimeConfig":
123 """
124 加载并合并所有配置。
125
126 算法:
127 1. 遍历所有可能的配置文件路径
128 2. 跳过不存在的文件
129 3. 读取存在的文件(JSON)
130 4. 按优先级深度合并
131
132 对应源码: config.rs:214-247
133 """
134 merged: dict[str, Any] = {}
135 loaded_entries: list[ConfigEntry] = []
136
137 for entry in self.discover():
138 # 尝试读取文件
139 content = self._read_json(entry.path)
140 if content is None:
141 continue # 文件不存在或不是有效 JSON,跳过
142
143 # 深度合并
144 deep_merge(merged, content)
145 loaded_entries.append(entry)
146
147 # 从合并后的字典中解析出具体的配置项
148 return RuntimeConfig(
149 merged=merged,
150 loaded_entries=loaded_entries,
151 hooks=self._parse_hooks(merged),
152 model=merged.get("model"),
153 permission_mode=merged.get("permissionMode"),
154 )
155
156 @staticmethod
157 def _read_json(path: str) -> Optional[dict]:

Callers 7

mainFunction · 0.95
sendMethod · 0.45
receiveMethod · 0.45
peekMethod · 0.45
_read_jsonMethod · 0.45
load_session_jsonFunction · 0.45
load_from_fileMethod · 0.45

Calls 7

discoverMethod · 0.95
_read_jsonMethod · 0.95
_parse_hooksMethod · 0.95
appendMethod · 0.80
deep_mergeFunction · 0.70
RuntimeConfigClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected