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

Method _parse_hooks

tutorials/09_config_system.py:169–186  ·  view source on GitHub ↗

从配置中解析 hooks

(merged: dict)

Source from the content-addressed store, hash-verified

167
168 @staticmethod
169 def _parse_hooks(merged: dict) -> dict[str, list[str]]:
170 """从配置中解析 hooks"""
171 hooks_raw = merged.get("hooks", {})
172 result = {"pre_tool_use": [], "post_tool_use": []}
173
174 for hook_def in hooks_raw.get("PreToolUse", []):
175 if isinstance(hook_def, dict) and "command" in hook_def:
176 result["pre_tool_use"].append(hook_def["command"])
177 elif isinstance(hook_def, str):
178 result["pre_tool_use"].append(hook_def)
179
180 for hook_def in hooks_raw.get("PostToolUse", []):
181 if isinstance(hook_def, dict) and "command" in hook_def:
182 result["post_tool_use"].append(hook_def["command"])
183 elif isinstance(hook_def, str):
184 result["post_tool_use"].append(hook_def)
185
186 return result
187
188
189# ============================================================

Callers 1

loadMethod · 0.95

Calls 2

appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected