Remove graphify PreToolUse hook from .codex/hooks.json.
(project_dir: Path)
| 2096 | |
| 2097 | |
| 2098 | def _uninstall_codex_hook(project_dir: Path) -> None: |
| 2099 | """Remove graphify PreToolUse hook from .codex/hooks.json.""" |
| 2100 | hooks_path = project_dir / ".codex" / "hooks.json" |
| 2101 | if not hooks_path.exists(): |
| 2102 | return |
| 2103 | try: |
| 2104 | existing = json.loads(hooks_path.read_text(encoding="utf-8")) |
| 2105 | except json.JSONDecodeError: |
| 2106 | return |
| 2107 | pre_tool = existing.get("hooks", {}).get("PreToolUse", []) |
| 2108 | if not isinstance(pre_tool, list): |
| 2109 | return |
| 2110 | filtered = _strip_graphify_hooks(pre_tool) |
| 2111 | if filtered == pre_tool: |
| 2112 | return |
| 2113 | existing["hooks"]["PreToolUse"] = filtered |
| 2114 | _write_settings_with_backup(hooks_path, existing) |
| 2115 | print(f" .codex/hooks.json -> PreToolUse hook removed") |
| 2116 | def _agents_install(project_dir: Path, platform: str, project: bool = False) -> None: |
| 2117 | """Write the graphify section to the local AGENTS.md for always-on platforms.""" |
| 2118 | target = (project_dir or Path(".")) / "AGENTS.md" |
no test coverage detected