Skip to content

fix(hooks): resolve Claude plugin hook runner cross-platform#942

Open
fatkobra wants to merge 4 commits intoMemPalace:developfrom
fatkobra:fix-hooks-resolve-claude-plugin
Open

fix(hooks): resolve Claude plugin hook runner cross-platform#942
fatkobra wants to merge 4 commits intoMemPalace:developfrom
fatkobra:fix-hooks-resolve-claude-plugin

Conversation

@fatkobra
Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #753

Summary

  • update .claude-plugin/hooks/mempal-stop-hook.sh
  • update .claude-plugin/hooks/mempal-precompact-hook.sh
  • prefer the installed mempalace CLI
  • fall back to importable python3 / python
  • add execution tests for the wrapper scripts

Scope
This PR intentionally fixes the Claude plugin shell hook wrappers only.
It does not change .claude-plugin/plugin.json or .claude-plugin/.mcp.json,
which still need a separate supported mechanism for MCP command resolution.

How to test

Manual verification

  • before: both wrappers failed with python3: command not found
  • after: both wrappers returned {} with exit code 0 in a PATH containing python but no python3

Validation

  • bash -n .claude-plugin/hooks/mempal-stop-hook.sh
  • bash -n .claude-plugin/hooks/mempal-precompact-hook.sh
  • ruff format tests/test_claude_plugin_hook_wrappers.py
  • ruff check tests/test_claude_plugin_hook_wrappers.py
  • ruff format --check tests/test_claude_plugin_hook_wrappers.py
  • python -m pytest tests/test_claude_plugin_hook_wrappers.py -v
  • python -m pytest tests/test_hooks_cli.py tests/test_claude_plugin_hook_wrappers.py -v
  • python -m pytest tests/ -v

Checklist

  • Tests pass (python -m pytest tests/ -v)
  • No hardcoded paths
  • Linter passes (ruff check .)

@mvalentsev
Copy link
Copy Markdown
Contributor

mvalentsev commented Apr 16, 2026

#833 by igorls already covers this (same issue #753) -- real python resolution with MEMPAL_PYTHON override, all CI green.

Also #670, #325, #384, #410 target the same problem.

@fatkobra
Copy link
Copy Markdown
Contributor Author

Thanks for the pointer @mvalentsev .

I checked #833, and it looks complementary rather than identical:

Issue #753’s current code example is the wrapper path (python3 -m mempalace hook run --hook stop --harness claude-code), which is what this PR fixes.

If maintainers would prefer a single combined solution, I’m happy to close this and rework it on top of #833, but as written it looks like #942 fixes the plugin wrapper layer while #833 fixes the legacy save/precompact shell hooks.

@mvalentsev
Copy link
Copy Markdown
Contributor

You're right, my mistake -- #833 targets hooks/ (legacy scripts) while this PR targets .claude-plugin/hooks/ (plugin wrappers). Different files, complementary fixes. Thanks for checking.

@mvalentsev
Copy link
Copy Markdown
Contributor

btw, .codex-plugin/hooks/mempal-hook.sh has the same hardcoded python3 on line 6. Might be worth including in this PR since it's the same class of fix.

@mvalentsev
Copy link
Copy Markdown
Contributor

Also worth noting: the plugin JSON configs (.claude-plugin/plugin.json, .mcp.json, .codex-plugin/plugin.json) also hardcode python3 as the MCP server command. Those need an entry point fix rather than shell fallbacks -- #805 and #340 both address that side of things.

@fatkobra
Copy link
Copy Markdown
Contributor Author

Thanks — agreed on both points.

.codex-plugin/hooks/mempal-hook.sh does look like the same wrapper-layer issue, so I’m happy to add that here if maintainers want this PR to cover all plugin hook wrappers.

However, I think it is better to keep the MCP config files (.claude-plugin/plugin.json, .claude-plugin/.mcp.json, .codex-plugin/plugin.json) out of scope for this PR, since those seem to need the separate entry-point/config approach already being discussed in #805 / #340.

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.

Windows: python3 command not found in hook scripts

2 participants