fix(install): keep foreign Claude hooks in mixed groups

Remove only setup-owned hook entries from a hook group and keep foreign
entries with their group options, such as matcher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian lechnerandClaude Opus 5.5 committed 2026-10-01 10:23:23 +02:00
1 parent 857720bcfd
commit e2394ca1d1
2 files changed
+24 -6

No files matched your search

+11 -6
View File
@@ -73,18 +73,23 @@ def merge_json(current, managed):
groups = value.get(event, [])
old_groups = hooks.get(event, [])
if isinstance(groups, list) and isinstance(old_groups, list):
retained = [group for group in old_groups if not any(
re.search(r'(?:flashbang|statusline|record-compact|session-state-pointer)\.(?:ps1|sh)',
str(hook.get('command', '')) + str(hook.get('command_windows', '')), re.I)
for hook in group.get('hooks', []) if isinstance(hook, dict)
)]
retained = []
for group in old_groups:
if not isinstance(group, dict) or not isinstance(group.get('hooks'), list):
retained.append(group)
continue
foreign = [hook for hook in group['hooks'] if not (isinstance(hook, dict) and re.search(
r'(?:flashbang|statusline|record-compact|session-state-pointer)\.(?:ps1|sh)',
str(hook.get('command', '')) + str(hook.get('command_windows', '')), re.I))]
if foreign:
retained.append(dict(group, hooks=foreign))
merged = groups + [group for group in retained if group not in groups]
if merged:
hooks[event] = merged
else:
hooks.pop(event, None)
else:
hooks[event] = value
hooks[event] = groups
result[key] = hooks
elif isinstance(value, dict) and isinstance(result.get(key), dict):
result[key] = merge_json(result[key], value)