Skip to content

fix(hookify): use relative imports so plugin works when installed via plugin cache#42162

Open
lcaiger wants to merge 1 commit intoanthropics:mainfrom
lcaiger:fix/hookify-absolute-imports
Open

fix(hookify): use relative imports so plugin works when installed via plugin cache#42162
lcaiger wants to merge 1 commit intoanthropics:mainfrom
lcaiger:fix/hookify-absolute-imports

Conversation

@lcaiger
Copy link
Copy Markdown

@lcaiger lcaiger commented Apr 1, 2026

Problem

When the hookify plugin is installed via Claude Code's plugin system, files are placed at a path like:

~/.claude/plugins/cache/claude-code-plugins/hookify/0.1.0/

In this layout, core/ is a direct child of the plugin root directory — there is no hookify/ package subdirectory wrapping it. Python therefore cannot resolve from hookify.core. imports, and every hook script fails immediately with an ImportError.

The hook scripts do add PLUGIN_ROOT and its parent to sys.path, but since there is no hookify/ directory at either of those locations, the hookify.core package simply does not exist at runtime.

Fix

Change all from hookify.core.<module> import ... statements to from core.<module> import ... across the five affected files:

  • plugins/hookify/core/rule_engine.py (2 occurrences)
  • plugins/hookify/hooks/stop.py
  • plugins/hookify/hooks/posttooluse.py
  • plugins/hookify/hooks/pretooluse.py
  • plugins/hookify/hooks/userpromptsubmit.py

With PLUGIN_ROOT already on sys.path, from core. resolves correctly to the core/ directory sitting directly inside the plugin installation.

Test plan

  • Install the hookify plugin via the Claude Code plugin system
  • Trigger a PreToolUse, PostToolUse, Stop, or UserPromptSubmit hook
  • Confirm hooks execute without an ImportError in the output

…lugin cache

When the hookify plugin is installed via Claude Code's plugin system, files
are placed at a path like ~/.claude/plugins/cache/.../hookify/0.1.0/ where
core/ is a direct child of the plugin root, not under a hookify/ subdirectory.
The previous `from hookify.core.` imports therefore fail with ImportError.

Change all `from hookify.core.` imports to `from core.` in rule_engine.py and
all four hook scripts so the plugin resolves modules correctly at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant