fix: hookify plugin imports broken by versioned cache path#27796
Open
hmesfin wants to merge 1 commit intoanthropics:mainfrom
Open
fix: hookify plugin imports broken by versioned cache path#27796hmesfin wants to merge 1 commit intoanthropics:mainfrom
hmesfin wants to merge 1 commit intoanthropics:mainfrom
Conversation
The hook scripts use `from hookify.core.config_loader import ...` but when installed via the plugin cache, the directory structure is: .../hookify/0.1.0/core/config_loader.py The version subdirectory (0.1.0) breaks the `hookify` package path. Since PLUGIN_ROOT (which contains `core/`) is already on sys.path, changing imports to `from core.config_loader import ...` works correctly.
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical import error in the hookify plugin that prevented all hook scripts from functioning. The issue occurred because the plugin's import paths used from hookify.core.* which assumed a package structure that doesn't exist when the plugin is installed via the versioned cache directory (.../hookify/0.1.0/). The fix changes all imports to use relative imports (from core.*) since PLUGIN_ROOT (containing the core/ directory) is already added to sys.path.
Changes:
- Updated import statements from
from hookify.core.*tofrom core.*across all hook scripts and the rule engine module - Ensures compatibility with the versioned plugin cache directory structure
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/hookify/hooks/userpromptsubmit.py | Changed imports from hookify.core to core for config_loader and rule_engine |
| plugins/hookify/hooks/stop.py | Changed imports from hookify.core to core for config_loader and rule_engine |
| plugins/hookify/hooks/pretooluse.py | Changed imports from hookify.core to core for config_loader and rule_engine |
| plugins/hookify/hooks/posttooluse.py | Changed imports from hookify.core to core for config_loader and rule_engine |
| plugins/hookify/core/rule_engine.py | Changed imports from hookify.core to core for config_loader imports (both main and test sections) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The hookify plugin's Python hook scripts all fail with
No module named 'hookify'because the import paths don't account for the versioned plugin cache directory structure.Root cause: All hook scripts and
core/rule_engine.pyusefrom hookify.core.config_loader import ..., expecting ahookifyPython package onsys.path. However, when installed via the plugin cache, the directory structure is:The scripts add
PLUGIN_ROOT(.../hookify/0.1.0/) and its parent (.../hookify/) tosys.path. Butfrom hookify.core.config_loaderrequires a directory namedhookifycontainingcore/somewhere on the path — the parent directory.../hookify/only contains0.1.0/, notcore/.Fix: Changed all
from hookify.core.imports tofrom core.sincePLUGIN_ROOT(which directly containscore/) is already onsys.path.Files changed
plugins/hookify/hooks/pretooluse.pyplugins/hookify/hooks/posttooluse.pyplugins/hookify/hooks/stop.pyplugins/hookify/hooks/userpromptsubmit.pyplugins/hookify/core/rule_engine.pyTest plan
Hookify import error: No module named 'hookify'messages appear on tool use