Commit 461a8b2
committed
fix(install,uninstall): correct Claude Code hooks schema for SessionStart entry
Regression caught when opening a fresh Claude Code session post-
install.sh: settings.json failed validation with
hooks > SessionStart > 1 > hooks: Expected array, but received undefined
Root cause: my jq merge appended a flat `{"command": "..."}` entry,
but the Claude Code hook schema is `{matcher?, hooks: [{type, command,
async?}, ...]}` — each SessionStart entry must carry a `hooks` array.
Fixes:
- install.sh — merges a correctly-shaped entry:
{"hooks": [{"type": "command", "command": "python3 ~/.claude/hooks/prewarm-direct-wrappers.py"}]}
Idempotency re-checked via flat-scanning all existing entries'
`hooks[].command` for our exact string; skips append if found.
- uninstall.sh — filters our command out of each entry's `hooks`
array, then drops entries that become empty. Unrelated SessionStart
entries (other tools' hooks bundled into separate entries) preserved.
- install.sh also gained `CLAUDE="${CLAUDE:-$HOME/.claude}"` env
override to match uninstall.sh (enables dry-run testing against a
scratch settings file) and switched `mktemp` to `mktemp
"${TMPDIR:-/tmp}/install.XXXXXX"` so the atomic-swap works under
sandboxes that override $TMPDIR.
Verified dry-run against scratch settings.json with an existing
SessionStart entry:
- install.sh run 1: appends our entry → 2 entries total.
- install.sh run 2 (idempotency): still 2 entries.
- uninstall.sh: strips our entry → back to 1 entry (the pre-
existing one untouched).
Users who already ran the broken install.sh can either run
uninstall.sh then install.sh again, or manually replace the flat
entry in ~/.claude/settings.json's hooks.SessionStart[] with the
correctly-shaped object.1 parent 9878ca5 commit 461a8b2
2 files changed
Lines changed: 25 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
90 | 100 | | |
91 | 101 | | |
92 | 102 | | |
| |||
0 commit comments