From ed3d70e2bad083ca6f8d41e23fea61aaa4081e32 Mon Sep 17 00:00:00 2001 From: Shriyam Shrivastava Date: Sat, 20 Jun 2026 14:15:35 +0530 Subject: [PATCH] fix(hookify): use root-relative imports to fix marketplace install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When installed from the marketplace, CLAUDE_PLUGIN_ROOT points to a versioned directory (e.g. hookify/0.1.0/) so dirname(PLUGIN_ROOT) is hookify/ — which contains no inner hookify package. All four hook scripts and rule_engine.py were using 'from hookify.core.*' which broke silently. Switch to 'from core.*' since CLAUDE_PLUGIN_ROOT is already in sys.path, making imports self-contained regardless of install path. Fixes #69665 --- plugins/hookify/core/rule_engine.py | 4 ++-- plugins/hookify/hooks/posttooluse.py | 4 ++-- plugins/hookify/hooks/pretooluse.py | 4 ++-- plugins/hookify/hooks/stop.py | 4 ++-- plugins/hookify/hooks/userpromptsubmit.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/hookify/core/rule_engine.py b/plugins/hookify/core/rule_engine.py index 8244c00591..51561c39e9 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) @@ -275,7 +275,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)