From 7e40115c0329d0fe8e2203cbedb50d0d1a22b93c Mon Sep 17 00:00:00 2001 From: Ethan Hurst Date: Sat, 28 Feb 2026 16:07:34 +1000 Subject: [PATCH] fix: Fix three bugs making hookify plugin non-functional (#28299, #20749, #20747) Fix broken Python imports by changing `from hookify.core.X` to `from core.X` since PLUGIN_ROOT points directly to the hookify directory. Use absolute path for rule file discovery so rules load from any CWD. Add hookSpecificOutput with additionalContext to warning responses so the model sees warnings. Co-Authored-By: Claude Opus 4.6 --- plugins/hookify/core/config_loader.py | 3 ++- plugins/hookify/core/rule_engine.py | 12 +++++++++--- plugins/hookify/hooks/posttooluse.py | 4 ++-- plugins/hookify/hooks/pretooluse.py | 4 ++-- plugins/hookify/hooks/stop.py | 4 ++-- plugins/hookify/hooks/userpromptsubmit.py | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/plugins/hookify/core/config_loader.py b/plugins/hookify/core/config_loader.py index fa2fc3e36f..1c971864b0 100644 --- a/plugins/hookify/core/config_loader.py +++ b/plugins/hookify/core/config_loader.py @@ -207,7 +207,8 @@ def load_rules(event: Optional[str] = None) -> List[Rule]: rules = [] # Find all hookify.*.local.md files - pattern = os.path.join('.claude', 'hookify.*.local.md') + claude_dir = os.path.join(os.path.expanduser('~'), '.claude') + pattern = os.path.join(claude_dir, 'hookify.*.local.md') files = glob.glob(pattern) for file_path in files: diff --git a/plugins/hookify/core/rule_engine.py b/plugins/hookify/core/rule_engine.py index 8244c00591..6853f73447 100644 --- a/plugins/hookify/core/rule_engine.py +++ b/plugins/hookify/core/rule_engine.py @@ -7,7 +7,7 @@ from typing import List, Dict, Any, Optional # Import from local module -from hookify.core.config_loader import Rule, Condition +from core.config_loader import Rule, Condition # Cache compiled regexes (max 128 patterns) @@ -86,8 +86,14 @@ def evaluate_rules(self, rules: List[Rule], input_data: Dict[str, Any]) -> Dict[ # If only warnings, show them but allow operation if warning_rules: messages = [f"**[{r.name}]**\n{r.message}" for r in warning_rules] + combined_message = "\n\n".join(messages) return { - "systemMessage": "\n\n".join(messages) + "systemMessage": combined_message, + "hookSpecificOutput": { + "hookEventName": hook_event or "PreToolUse", + "permissionDecision": "allow", + "additionalContext": combined_message + } } # No matches - allow operation @@ -275,7 +281,7 @@ def _regex_match(self, pattern: str, text: str) -> bool: # For testing if __name__ == '__main__': - from hookify.core.config_loader import Condition, Rule + from core.config_loader import Condition, Rule # Test rule evaluation rule = Rule( diff --git a/plugins/hookify/hooks/posttooluse.py b/plugins/hookify/hooks/posttooluse.py index a9e12cc797..02faa18498 100755 --- a/plugins/hookify/hooks/posttooluse.py +++ b/plugins/hookify/hooks/posttooluse.py @@ -19,8 +19,8 @@ sys.path.insert(0, PLUGIN_ROOT) try: - from hookify.core.config_loader import load_rules - from hookify.core.rule_engine import RuleEngine + from core.config_loader import load_rules + from core.rule_engine import RuleEngine except ImportError as e: error_msg = {"systemMessage": f"Hookify import error: {e}"} print(json.dumps(error_msg), file=sys.stdout) diff --git a/plugins/hookify/hooks/pretooluse.py b/plugins/hookify/hooks/pretooluse.py index f265c277e3..22db22ae20 100755 --- a/plugins/hookify/hooks/pretooluse.py +++ b/plugins/hookify/hooks/pretooluse.py @@ -23,8 +23,8 @@ sys.path.insert(0, PLUGIN_ROOT) try: - from hookify.core.config_loader import load_rules - from hookify.core.rule_engine import RuleEngine + from core.config_loader import load_rules + from core.rule_engine import RuleEngine except ImportError as e: # If imports fail, allow operation and log error error_msg = {"systemMessage": f"Hookify import error: {e}"} diff --git a/plugins/hookify/hooks/stop.py b/plugins/hookify/hooks/stop.py index fc299bc696..b1e55bb165 100755 --- a/plugins/hookify/hooks/stop.py +++ b/plugins/hookify/hooks/stop.py @@ -19,8 +19,8 @@ sys.path.insert(0, PLUGIN_ROOT) try: - from hookify.core.config_loader import load_rules - from hookify.core.rule_engine import RuleEngine + from core.config_loader import load_rules + from core.rule_engine import RuleEngine except ImportError as e: error_msg = {"systemMessage": f"Hookify import error: {e}"} print(json.dumps(error_msg), file=sys.stdout) diff --git a/plugins/hookify/hooks/userpromptsubmit.py b/plugins/hookify/hooks/userpromptsubmit.py index 28ee51fdf3..9f672a47ab 100755 --- a/plugins/hookify/hooks/userpromptsubmit.py +++ b/plugins/hookify/hooks/userpromptsubmit.py @@ -19,8 +19,8 @@ sys.path.insert(0, PLUGIN_ROOT) try: - from hookify.core.config_loader import load_rules - from hookify.core.rule_engine import RuleEngine + from core.config_loader import load_rules + from core.rule_engine import RuleEngine except ImportError as e: error_msg = {"systemMessage": f"Hookify import error: {e}"} print(json.dumps(error_msg), file=sys.stdout)