Skip to content

fix: preserve sibling custom hooks on install/uninstall (#484)#485

Open
tarekrached wants to merge 1 commit intoPeonPing:mainfrom
tarekrached:tarek/fix-484-preserve-sibling-hooks
Open

fix: preserve sibling custom hooks on install/uninstall (#484)#485
tarekrached wants to merge 1 commit intoPeonPing:mainfrom
tarekrached:tarek/fix-484-preserve-sibling-hooks

Conversation

@tarekrached
Copy link
Copy Markdown

Summary

Fixes #484. install.sh / peon update filtered settings.json hooks at the matcher-entry level: if any inner hook command contained peon.sh or notify.sh, the whole matcher entry (with all its siblings) was dropped. Users composing peon-ping under the same matcher as other hooks — a natural thing to do when matcher: "" is the default — silently lost those hooks on every update.

The fix filters at the inner-hook level instead: strip only peon/notify/handle-use hooks, and drop the containing entry only when its hooks list becomes empty. Applied symmetrically to install.sh, install.ps1, uninstall.sh, and uninstall.ps1.

Incidental fixes uncovered during review

  • install.ps1 regex -match "peon" narrowed to peon\.(ps1|sh). Matches the precision already in install.sh and uninstall.ps1; previously would match any path containing the string peon (e.g. openpeon-*, peony-*). Pre-existing, but made subtler by the new surgical filter.
  • uninstall.sh now strips notify.sh hooks (parity with install.sh and uninstall.ps1).
  • uninstall.sh preserves matcher entries that already had hooks: [] — the old code silently dropped them.

Test plan

  • New BATS regression test in tests/install.bats injects a custom sibling hook into peon's SessionStart and UserPromptSubmit entries, re-runs install, and asserts both the custom hooks and peon hooks survive.
  • All 47 bats tests/install.bats tests pass locally.
  • CI: BATS (macOS) + Pester (Windows).

🤖 Generated with Claude Code

install.sh / peon update filtered settings.json hooks at the matcher-entry
level: if any inner hook command contained peon.sh or notify.sh, the entire
matcher entry (with all its siblings) was dropped. Users composing peon-ping
under the same matcher as other hooks silently lost them on every update.

Filter at the inner-hook level instead — strip only peon/notify/handle-use
hooks and drop the containing entry only when its hooks list is emptied.

Applied symmetrically to install.sh, install.ps1, uninstall.sh, uninstall.ps1.

Also tightened incidental gaps uncovered while reviewing:
- install.ps1 regex `-match "peon"` narrowed to `peon\.(ps1|sh)` (matches
  install.sh / uninstall.ps1 precision; previously would match any path
  containing "peon" e.g. `openpeon-*`, `peony-*`).
- uninstall.sh now strips `notify.sh` hooks (parity with install.sh and
  uninstall.ps1).
- uninstall.sh preserves entries that already had `hooks: []` rather than
  silently dropping them.

Regression test in tests/install.bats injects a custom sibling hook into
peon's SessionStart and UserPromptSubmit entries, re-runs install, and
asserts both the custom hooks and peon hooks survive.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

@tarekrached is attempting to deploy a commit to the Gary Sheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

install.sh/peon update drops sibling custom hooks that share a matcher entry with peon.sh

1 participant