fix(install): normalize null hook matcher → "" on merge (Claude Code /doctor)

Users with pre-kit hooks that have no `matcher` field end up with matcher:null,
which Claude Code /doctor rejects ("Expected string, but received null") and
skips the whole settings file. The jq merge preserved null as-is, so every
reinstall re-surfaced the error. Now map(.matcher //= "") before group_by →
null/absent collapses to "" (match-all), one group per matcher.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
KeiSei84 2026-05-22 16:53:27 +08:00
parent 9866d716d7
commit d89ddf0c74

View file

@ -60,6 +60,10 @@ _jq_merge_hooks() {
| reduce ($add.hooks | keys[]) as $phase ($orig; | reduce ($add.hooks | keys[]) as $phase ($orig;
.hooks[$phase] = ( .hooks[$phase] = (
((.hooks[$phase] // []) + ($add.hooks[$phase] // [])) ((.hooks[$phase] // []) + ($add.hooks[$phase] // []))
# Normalize null/absent matcher → "" (Claude Code /doctor rejects null;
# user's pre-kit hooks often have no matcher field). Before group_by so
# null + "" collapse into one group.
| map(.matcher //= "")
| group_by(.matcher) | group_by(.matcher)
| map( | map(
.[0].matcher as $m .[0].matcher as $m