Consolidate Notification / Stop / SubagentStop into native notify.sh#210
Draft
ikuwow wants to merge 2 commits into
Draft
Consolidate Notification / Stop / SubagentStop into native notify.sh#210ikuwow wants to merge 2 commits into
ikuwow wants to merge 2 commits into
Conversation
Implements part of #148 Phase 1 (A + B + C + E): - A: per-event sound differentiation (Stop=Glass, SubagentStop=Pop, Notification permission_prompt=Submarine, idle_prompt=Ping, other=Blow) - B: repo + branch in notification title for parallel-session disambiguation - C: drops the noti dependency in favor of native afplay + osascript - E: adds SubagentStop hook D1 (Notification matcher idle_prompt branching is a content match inside the script, not a separate settings.json matcher) and H (Kansai-ben voice) are out of scope for this PR — both are tracked in #148 for follow-up. Refs #148. Co-authored-by: Claude Opus 4.6 <[email protected]>
The earlier `[ -d "$cwd/.git" ] || git rev-parse` had a precedence shape that read as a redundant fast-path. The rev-parse alone covers worktrees, subdirectories, and empty cwd cases. Co-authored-by: Claude Opus 4.6 <[email protected]>
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.
Refs #148. Lands the A + B + C + E subset of the issue's Phase 1.
Why
The previous
Notification/Stopsetup wired a single genericnotiinvocation for every event. That is hard to triage by ear (Stop and a permission prompt sounded similar enough to ignore), invisible across parallel sessions (no repo / branch context), and dependent on a Homebrew package for what is a one-lineosascriptcall on macOS.The issue cataloged eight independent ideas (A–H). This PR picks the four that compose naturally into a single script and ship today: A (per-event sound), B (repo + branch in title), C (drop
noti), E (SubagentStop). D1 / D2 / D3 (idle reminder mechanism), F (theme JSON), G (remote channel), H (Kansai-ben voice) stay parked in #148 for a follow-up.What
claude/hooks/notify.sh(shellcheck-clean,set -u, ~70 LoC). Reads the hook JSON from stdin, picks a/System/Library/Sounds/*.aiffper event-or-matcher, builds a titleClaude Code · <repo> (<branch>), thenafplay+osascript. Notification matcher branching is content-based: themessagefield of the stdin JSON is checked forpermission/idlesubstrings to choose between Submarine / Ping / Blow.claude/settings.json: replaces the twonoticommands withbash ~/.claude/hooks/notify.sh, plus a newSubagentStopmatcher wired to the same script.block_excuse_phrases.pystays as the first Stop hook so the AIRULES guard still fires.Notes
afplayandosascriptare not available on Linux. The hook is best-effort: missing tools cause silent no-ops via|| trueand2>/dev/null, not failures.git rev-parsereturns non-zero, branch stays empty, title falls back toClaude Code · <repo>).notistays installed via the existing Brewfile for other consumers; this PR only removes its use from the Claude Code hooks. Dropping it from Brewfile is a separate decision.Verification
shellcheck claude/hooks/notify.shclean.jq . claude/settings.jsonvalidates.echo '{"hook_event_name":"Stop","cwd":"/Users/ikuwow/dotfiles","message":""}' | bash claude/hooks/notify.shexits 0 — Stop path wired."hook_event_name":"Notification","message":"Claude needs your permission to use Bash"exits 0 — Notification permission_prompt path wired (Submarine branch selected by content match)."hook_event_name":"SubagentStop"exits 0 — SubagentStop path wired (Pop sound).block_excuse_phrases.pystill fires before notify on a 断り書き violation — settings.json keepsblock_excuse_phrases.pyfirst in theStophook array; confirmed by reading the diff.