fix(hookify): fix Python import path for cached plugins#13681
Open
saasom wants to merge 1 commit intoanthropics:mainfrom
Open
fix(hookify): fix Python import path for cached plugins#13681saasom wants to merge 1 commit intoanthropics:mainfrom
saasom wants to merge 1 commit intoanthropics:mainfrom
Conversation
When plugins are cached by Claude Code, the directory structure becomes `hookify/<version>/core/` instead of `hookify/core/`. This breaks the `from hookify.core.X import Y` imports because Python looks for a `hookify` subdirectory within the paths in sys.path. The fix changes imports to use direct module paths (`from core.X import Y`) since CLAUDE_PLUGIN_ROOT is already added to sys.path and points to the versioned directory containing the `core/` module. Affected files: - hooks/stop.py - hooks/pretooluse.py - hooks/posttooluse.py - hooks/userpromptsubmit.py - core/rule_engine.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Hey @saasom! 👋 The import path issue you're fixing is handled in hookify-plus via symlink installation. hookify-plus aggregates community fixes that Anthropic hasn't merged (10+ PRs sitting open). Feel free to use it while waiting for upstream review! 🚀 ln -s /path/to/hookify-plus ~/.claude/plugins/cache/claude-code-plugins/hookify/0.1.0 |
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
Fixes the hookify plugin's Python import path issue that occurs when plugins are cached by Claude Code.
The Problem:
When Claude Code caches plugins, it creates a versioned directory structure:
The original code tried to import using package-style imports:
This fails because:
CLAUDE_PLUGIN_ROOTpoints to.../hookify/0.1.0/parent_dir(.../hookify/) tosys.pathhookifydirectory withcore/inside ithookify/0.1.0/core/- the version directory breaks the package pathThe Fix:
Since
PLUGIN_ROOTis already added tosys.pathand points directly to the versioned directory (.../0.1.0/), we can import directly:This works because
core/is a direct child ofPLUGIN_ROOT.Files Changed
plugins/hookify/hooks/stop.py- Updated imports and path setupplugins/hookify/hooks/pretooluse.py- Updated imports and path setupplugins/hookify/hooks/posttooluse.py- Updated imports and path setupplugins/hookify/hooks/userpromptsubmit.py- Updated imports and path setupplugins/hookify/core/rule_engine.py- Updated internal importsTest Plan
Reproduction Steps (for the original bug)
Hookify import error: No module named 'hookify'~/.claude/plugins/cache/claude-code-plugins/hookify/to see versioned structure