fix: merge-based hook installation preserves existing user hooks#203
fix: merge-based hook installation preserves existing user hooks#203lngyeen wants to merge 1 commit intotirth8205:mainfrom
Conversation
|
This PR addresses the hooks schema bug (#97, #114, #172, #188, #191, #201) which is still not fixed in main. The current skills.py:generate_hooks_config() still generates the invalid schema. This PR provides exactly what's needed: proper nested hooks arrays, removal of PreCommit/SessionStart (invalid events), narrowed PostToolUse matcher, and merge-based installation with backup. Worth reviving — this is the #1 most-reported bug in the issue tracker. |
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.
13ddcba to
cf756f4
Compare
|
Rebased onto latest |
Summary
install_hooks()now merges new entries into existing hooks instead of overwriting them viaexisting.update(). Creates asettings.json.bakbackup before modification.Motivation
The
existing.update(hooks_config)call ininstall_hooks()replaces the entirehookskey, silently destroying user-defined hooks (e.g., linters, formatters, safety checks).Closes #114
Changes
skills.py:install_hooks()tests/test_skills.pyTest plan