fix(hooks): guard against missing jq; drop UUOC
All three hooks used `set -eu` + `cat | jq …`. Without jq installed, jq would fail and `-e` would abort the hook → non-zero exit → Claude Code refuses Edit/Write/Bash system-wide. Now each hook probes for jq BEFORE `set -eu` and exits 0 silently if absent. Also dropped the useless `cat |` pipe — `jq -r` reads stdin directly. Companion: install.sh jq check upgraded from warn to hard `exit 1` because without jq the hooks are dead weight; message states jq is required on any machine that will activate the hooks.
This commit is contained in:
parent
b1a77f393a
commit
16d4b48c77
4 changed files with 21 additions and 6 deletions
|
|
@ -9,12 +9,16 @@
|
|||
# Stdin: JSON with tool_input.file_path
|
||||
# Exit 0 always (non-blocking advisory)
|
||||
|
||||
# Silent fall-through if jq is absent; otherwise `set -eu` would abort and
|
||||
# Claude Code would refuse the tool call system-wide.
|
||||
command -v jq >/dev/null 2>&1 || exit 0
|
||||
|
||||
set -eu
|
||||
|
||||
ASSEMBLER="$HOME/.claude/agents/_assembler/target/release/assemble"
|
||||
[ -x "$ASSEMBLER" ] || exit 0
|
||||
|
||||
FILE=$(cat | jq -r '.tool_input.file_path // empty')
|
||||
FILE=$(jq -r '.tool_input.file_path // empty')
|
||||
[ -n "$FILE" ] || exit 0
|
||||
|
||||
case "$FILE" in
|
||||
|
|
|
|||
|
|
@ -6,12 +6,16 @@
|
|||
#
|
||||
# Stdin: JSON with tool_input.command
|
||||
|
||||
# Silent fall-through if jq is absent; otherwise `set -eu` would abort and
|
||||
# Claude Code would refuse the tool call system-wide.
|
||||
command -v jq >/dev/null 2>&1 || exit 0
|
||||
|
||||
set -eu
|
||||
|
||||
ASSEMBLER="$HOME/.claude/agents/_assembler/target/release/assemble"
|
||||
[ -x "$ASSEMBLER" ] || exit 0
|
||||
|
||||
CMD=$(cat | jq -r '.tool_input.command // empty')
|
||||
CMD=$(jq -r '.tool_input.command // empty')
|
||||
|
||||
# Only act on git commit inside ~/.claude
|
||||
case "$CMD" in
|
||||
|
|
|
|||
|
|
@ -8,11 +8,15 @@
|
|||
#
|
||||
# Stdin: JSON with tool_input.file_path
|
||||
|
||||
# Silent fall-through if jq is absent; otherwise `set -eu` would abort and
|
||||
# Claude Code would refuse Edit/Write system-wide.
|
||||
command -v jq >/dev/null 2>&1 || exit 0
|
||||
|
||||
set -eu
|
||||
|
||||
[ "${AGENT_MIGRATION:-0}" = "1" ] && exit 0
|
||||
|
||||
FILE=$(cat | jq -r '.tool_input.file_path // empty')
|
||||
FILE=$(jq -r '.tool_input.file_path // empty')
|
||||
[ -n "$FILE" ] || exit 0
|
||||
|
||||
# Only care about files directly under ~/.claude/agents/*.md
|
||||
|
|
|
|||
|
|
@ -43,9 +43,12 @@ if ! cargo --version >/dev/null 2>&1; then
|
|||
exit 1
|
||||
fi
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
warn "jq not found. Hooks use jq for JSON parsing — install before running Claude:"
|
||||
warn " brew install jq (macOS)"
|
||||
warn " apt install jq (Debian/Ubuntu)"
|
||||
err "jq not found. jq is REQUIRED on any machine that will activate the"
|
||||
err "KeiSeiKit hooks — without it the hooks become dead weight and would"
|
||||
err "otherwise abort Claude Code's Edit/Write/Bash tool calls. Install it:"
|
||||
err " brew install jq (macOS)"
|
||||
err " apt install jq (Debian/Ubuntu)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- create target dirs -----------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue