Skip to content

fix(hooks): preserve script-style hooks in the index; warn when nothing merges - #63

Merged
nmccready merged 1 commit into
mainfrom
fix/hooks-preserve-scripts
Jul 3, 2026
Merged

fix(hooks): preserve script-style hooks in the index; warn when nothing merges#63
nmccready merged 1 commit into
mainfrom
fix/hooks-preserve-scripts

Conversation

@nmccready

Copy link
Copy Markdown
Contributor

Fixes the regression Nick hit in the acme repo: .agents/hooks/backfill-session-id.sh and sync-permissions.sh were erased from AGENTS.md on index regeneration.

Root cause

The SPEC-004 hooks bucket models hooks as .json settings-fragments, and the ## Hooks index section filtered to .json — so any hooks directory using the older script convention (.sh files) lost its entries every time index ran. 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)

  1. Preserve: the index now lists every non-hidden file in hooks/.json fragments 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.
  2. Warn that it would never work: sync now warns when hooks/ 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 + .json mix 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 index there once this ships — the Hooks section comes back with both scripts listed.

🤖 Generated with Claude Code

…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>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🤖 AI Code Review Complete

Review performed on changed files. Check inline comments for specific findings.

Severity Levels:

  • 🔴 Critical: Must fix (bugs, security, data loss)
  • 🟡 Warning: Should fix (performance, maintainability)
  • 🔵 Suggestion: Nice to have (style, alternatives)
  • Nit: Optional (cosmetic)

@nmccready
nmccready merged commit 18753d4 into main Jul 3, 2026
6 checks passed
@nmccready
nmccready deleted the fix/hooks-preserve-scripts branch July 3, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant