fix(skills): add PATH guard and remove absolute paths from hooks#565
Open
itxaiohanglover wants to merge 1 commit into
Open
fix(skills): add PATH guard and remove absolute paths from hooks#565itxaiohanglover wants to merge 1 commit into
itxaiohanglover wants to merge 1 commit into
Conversation
Two related bugs in generate_hooks_config(): 1. tirth8205#549: Hooks called bare `code-review-graph` without checking if the binary is on PATH. When installed in a project venv, every Edit/Write/Bash tool call surfaced "code-review-graph: not found". Also, the `Bash` matcher fired on every shell command, not just file mutations. Fix: add `command -v code-review-graph >/dev/null 2>&1 || exit 0` guard. Narrow matcher from `Edit|Write|Bash` to `Edit|Write`. 2. tirth8205#558: Hooks embedded `json.dumps(repo_root.resolve().as_posix())` — an absolute path — making settings.json non-shareable across collaborators with different checkout paths. Fix: use `$(git rev-parse --show-toplevel 2>/dev/null)` to resolve the repo root dynamically at runtime. Also fixes the `json.dumps()` shell-quoting abuse from tirth8205#497 for the hooks path (though tirth8205#497 also covers the .mcp.json cwd field separately). Closes tirth8205#549, tirth8205#558
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 two related bugs in
generate_hooks_config():code-review-graphwithout checking PATH. When installed in a project venv, every Edit/Write/Bash tool call surfacedcode-review-graph: not found. Also, theBashmatcher fired on every shell command (git status,ls, test runs), not just file mutations.json.dumps(repo_root.resolve().as_posix())— an absolute path — making.claude/settings.jsonnon-shareable across collaborators with different checkout paths.Changes
PATH guard (#549)
This mirrors the pattern already used by the git pre-commit hook installed by the same
installcommand.Narrowed matcher (#549)
Edit|Writecovers the cases where the graph can actually become stale from within Claude Code. Bash-driven file mutations are rare and the cost of firing on every shell command is high.Dynamic repo root (#558)
The
repo_rootparameter is retained for backward compatibility but no longer embedded in commands.Test plan
test_hooks_have_path_guard— verifies both hooks includecommand -v code-review-graphtest_hooks_use_dynamic_repo_root— verifies both hooks usegit rev-parse --show-topleveltest_hooks_no_absolute_path_embedded— verifies no hardcoded path appears in commandstest_post_tool_use_matcher_excludes_bash— verifies matcher isEdit|Write, notEdit|Write|Bashruff checkpasses (no new lint errors introduced)Closes #549, #558