From b3777a2eceac3a8e9a4bd06c1b223dff67a7dcb1 Mon Sep 17 00:00:00 2001 From: SARAMALI15792 Date: Fri, 10 Apr 2026 10:36:13 +0500 Subject: [PATCH 1/3] fix(codex): remove early-exit check in _install_codex_hook - Replace early-exit with remove-then-install pattern - Ensures hook updates work when upgrading graphify versions - Part of fix for issue #182 --- graphify/__main__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/graphify/__main__.py b/graphify/__main__.py index 604fa5248..e958005aa 100644 --- a/graphify/__main__.py +++ b/graphify/__main__.py @@ -417,11 +417,13 @@ def _install_codex_hook(project_dir: Path) -> None: existing = {} pre_tool = existing.setdefault("hooks", {}).setdefault("PreToolUse", []) - if any("graphify" in str(h) for h in pre_tool): - print(f" .codex/hooks.json -> hook already registered (no change)") - return - pre_tool.extend(_CODEX_HOOK["hooks"]["PreToolUse"]) + # Remove any existing graphify hooks (handles upgrades from old versions) + filtered = [h for h in pre_tool if "graphify" not in str(h)] + existing["hooks"]["PreToolUse"] = filtered + + # Install fresh hook with correct format + existing["hooks"]["PreToolUse"].extend(_CODEX_HOOK["hooks"]["PreToolUse"]) hooks_path.write_text(json.dumps(existing, indent=2), encoding="utf-8") print(f" .codex/hooks.json -> PreToolUse hook registered") From 007298c93b8ac2e871641739ba65cb61ccc8f3ab Mon Sep 17 00:00:00 2001 From: SARAMALI15792 Date: Fri, 10 Apr 2026 10:42:45 +0500 Subject: [PATCH 2/3] fix(claude): remove early-exit check in _install_claude_hook - Replace early-exit with remove-then-install pattern - Ensures hook updates work when upgrading graphify versions - Part of fix for issue #182 --- graphify/__main__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/graphify/__main__.py b/graphify/__main__.py index e958005aa..c8fc2dbca 100644 --- a/graphify/__main__.py +++ b/graphify/__main__.py @@ -542,12 +542,12 @@ def _install_claude_hook(project_dir: Path) -> None: hooks = settings.setdefault("hooks", {}) pre_tool = hooks.setdefault("PreToolUse", []) - # Check if already installed - if any(h.get("matcher") == "Glob|Grep" and "graphify" in str(h) for h in pre_tool): - print(f" .claude/settings.json -> hook already registered (no change)") - return + # Remove any existing graphify hooks (handles upgrades from old versions) + filtered = [h for h in pre_tool if not (h.get("matcher") == "Glob|Grep" and "graphify" in str(h))] + settings["hooks"]["PreToolUse"] = filtered - pre_tool.append(_SETTINGS_HOOK) + # Install fresh hook + settings["hooks"]["PreToolUse"].append(_SETTINGS_HOOK) settings_path.write_text(json.dumps(settings, indent=2), encoding="utf-8") print(f" .claude/settings.json -> PreToolUse hook registered") From 00a9ca7e748a6ecc10f420698fd7c585b2de202b Mon Sep 17 00:00:00 2001 From: SARAMALI15792 Date: Fri, 10 Apr 2026 10:46:02 +0500 Subject: [PATCH 3/3] fix(gemini): remove early-exit check in _install_gemini_hook - Replace early-exit with remove-then-install pattern - Ensures hook updates work when upgrading graphify versions - Part of fix for issue #182 --- graphify/__main__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/graphify/__main__.py b/graphify/__main__.py index c8fc2dbca..df53c8bea 100644 --- a/graphify/__main__.py +++ b/graphify/__main__.py @@ -217,10 +217,13 @@ def _install_gemini_hook(project_dir: Path) -> None: except json.JSONDecodeError: settings = {} before_tool = settings.setdefault("hooks", {}).setdefault("BeforeTool", []) - if any("graphify" in str(h) for h in before_tool): - print(" .gemini/settings.json -> hook already registered (no change)") - return - before_tool.append(_GEMINI_HOOK) + + # Remove any existing graphify hooks (handles upgrades from old versions) + filtered = [h for h in before_tool if "graphify" not in str(h)] + settings["hooks"]["BeforeTool"] = filtered + + # Install fresh hook + settings["hooks"]["BeforeTool"].append(_GEMINI_HOOK) settings_path.write_text(json.dumps(settings, indent=2), encoding="utf-8") print(" .gemini/settings.json -> BeforeTool hook registered")