MCPcopy Create free account
hub / github.com/T0UGH/codex-self-evolution-plugin / _check_hooks

Function _check_hooks

src/codex_self_evolution/diagnostics.py:84–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82
83
84def _check_hooks() -> dict[str, Any]:
85 hooks_path = Path.home() / ".codex" / "hooks.json"
86 result: dict[str, Any] = {
87 "file": str(hooks_path),
88 "exists": hooks_path.exists(),
89 "stop_installed": False,
90 "session_start_installed": False,
91 "error": None,
92 }
93 if not hooks_path.exists():
94 return result
95 try:
96 data = json.loads(hooks_path.read_text(encoding="utf-8"))
97 except (OSError, ValueError) as exc:
98 result["error"] = f"failed to parse hooks.json: {exc}"
99 return result
100 hooks = (data.get("hooks") or {}) if isinstance(data, dict) else {}
101 for event, entries in hooks.items():
102 if not isinstance(entries, list):
103 continue
104 for entry in entries:
105 for h in entry.get("hooks", []):
106 cmd = h.get("command", "")
107 if HOOK_MARKER not in cmd:
108 continue
109 if event == "Stop":
110 result["stop_installed"] = True
111 elif event == "SessionStart":
112 result["session_start_installed"] = True
113 return result
114
115
116def _check_plugin_hook_bundle(plugin_root: Path | None = None) -> dict[str, Any]:

Calls

no outgoing calls