fix: preserve existing hooks on install#145
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
|
CI passed, but this now has merge conflicts with |
Two fixes for Claude Code hooks integration: 1. Hook schema: use proper Claude Code format with nested hooks array and remove unsupported PreCommit event. Narrow PostToolUse matcher from Edit|Write|Bash to Edit|Write since Bash commands do not directly modify source files. (cherry-picked from PR tirth8205#180) 2. Merge logic: install_hooks now merges new entries into existing hooks instead of overwriting them. Creates a backup of settings.json before modification. (based on PR tirth8205#145) Closes tirth8205#97, tirth8205#114, tirth8205#172.
Two fixes for Claude Code hooks integration: 1. Hook schema: use proper Claude Code format with nested hooks array and remove unsupported PreCommit event. Narrow PostToolUse matcher from Edit|Write|Bash to Edit|Write since Bash commands do not directly modify source files. (cherry-picked from PR tirth8205#180) 2. Merge logic: install_hooks now merges new entries into existing hooks instead of overwriting them. Creates a backup of settings.json before modification. (based on PR tirth8205#145) Closes tirth8205#97, tirth8205#114, tirth8205#172.
|
Thanks for tackling issue #114! The merge logic and backup approach are the right solution. However there are two bugs that need fixing before this can merge: 1. Missing The original settings_path.write_text(json.dumps(existing, indent=2) + "\n", encoding="utf-8")The PR drops the encoding parameter: settings_path.write_text(json.dumps(existing, indent=2) + "\n")On Windows with non-UTF-8 system locale this will break. Please restore 2. Hook format generated is invalid The PR still calls the original
These bugs were also present before this PR, but since you're changing the merge logic it would be good to fix the format here too. PR #192 has the correct format if you want to pull from it. The backup creation and merge loop logic itself is correct — just these two things to fix. |
Summary
Fixes #114.
Testing