Fix/claude code hook python3 fallback - #1
Merged
Conversation
Bare `python` resolves to Python 2 on machines where it's aliased that way. capture.py uses PEP 3107 annotations, which is a SyntaxError under py2, crashing the hook before AgenTrust ever runs. Mirrors the fallback pattern already shipped in plugins/agentrust-codex/ scripts/session-start.sh: try python3, fall back to python, and if neither is on PATH, emit a benign skip message and exit 0 instead of crashing the session.
Layout diagram and quickstart still described the hook as calling engine/capture.py directly. Update both to match the python3/python fallback wrapper added in the previous commit.
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.
Title
fix: fall back python3 -> python -> graceful skip in SessionStart hook
Summary
Add a small POSIX wrapper and point the SessionStart hook at it so the hook first tries python3, falls back to python, and otherwise exits 0 with a benign skip message. This prevents a SyntaxError crash on systems where bare python resolves to Python 2.
Problem
"command": "python \"${CLAUDE_PLUGIN_ROOT}/engine/capture.py\" hook"Root cause
Fix / Changes
claude-code/hooks/session-start.shexec python3 "${CLAUDE_PLUGIN_ROOT}/engine/capture.py" hookexec python "${CLAUDE_PLUGIN_ROOT}/engine/capture.py" hook{"continue":true,"systemMessage":"AgenTrust: skipped the integrity check because Python is unavailable."}and exit 0Testing
How to reproduce locally
pythonresolves to Python 2 (or use a PATH that points python to a py2 binary)CLAUDE_PLUGIN_ROOT="$(pwd)/claude-code" sh -c 'python "${CLAUDE_PLUGIN_ROOT}/engine/capture.py" hook'CLAUDE_PLUGIN_ROOT="$(pwd)/claude-code" sh claude-code/hooks/session-start.shRollout / Migration
Backwards compatibility & Risks
Security & Privacy
Related issues / PRs
Reviewer checklist
type(scope): summaryused across recent history (fix(claude-code): make install work + hook never crashes the session agentrust-io/integrations#39, ci(claude-code): run the plugin test suite in CI agentrust-io/integrations#42, release(claude-code): v0.2.0 (launch-ready) agentrust-io/integrations#43, docs(claude-code): add PRIVACY.md agentrust-io/integrations#44)9d93102, confirmed untouched by fix(claude-code): make install work + hook never crashes the session agentrust-io/integrations#39Co-authors / Acknowledgements