fix(hooks): preserve script-style hooks in the index; warn when nothing merges - #63
Merged
Merged
Conversation
…ng merges The ## Hooks index section filtered to .json fragments, so hooks directories using the pre-SPEC-004 script convention (.sh files) had their entries silently erased from AGENTS.md on every regeneration — files that exist on disk must never disappear from the index. - index now lists EVERY non-hidden hooks file: .json fragments are annotated 'merged into .claude/settings.json', anything else as a companion file (not merged; reference it from a fragment) - sync now warns when hooks/ contains only non-JSON files: they are indexed and synced but will never merge into settings.json, with the fragment shape to wrap them shown inline Fixes the acme AGENTS.md regression (backfill-session-id.sh / sync-permissions.sh dropped from the index). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🤖 AI Code Review CompleteReview performed on changed files. Check inline comments for specific findings. Severity Levels:
|
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.
Fixes the regression Nick hit in the acme repo:
.agents/hooks/backfill-session-id.shandsync-permissions.shwere erased from AGENTS.md on index regeneration.Root cause
The SPEC-004 hooks bucket models hooks as
.jsonsettings-fragments, and the## Hooksindex section filtered to.json— so any hooks directory using the older script convention (.shfiles) lost its entries every timeindexran. The files themselves were never touched; only their index entries were destroyed. The merge engine already skipped non-JSON files harmlessly.Fix (both halves of the ask)
hooks/—.jsonfragments annotated "merged into.claude/settings.json", everything else annotated "companion file (not merged; reference it from a fragment)". Files on disk can no longer vanish from AGENTS.md.syncnow warns whenhooks/contains only non-JSON files — they're indexed and synced but nothing will ever merge into settings.json — and shows the exact fragment shape to wrap a script so Claude actually runs it.Tests
Two regressions reproducing the acme scenario exactly:
.sh+.jsonmix survives two index cycles byte-identically with correct annotations; script-only dir merges nothing, warns, and conjures no settings.json. Full suite green (go + all bats).To restore the acme index: re-run
sync-agents indexthere once this ships — the Hooks section comes back with both scripts listed.🤖 Generated with Claude Code