#!/bin/bash
# Email Send Gate — PreToolUse hook shim (global, all projects).
# The judgement lives in email-send-gate.mjs beside this file; see its header
# for what the gate does and why. This shim only locates and runs it.
# ROLLBACK: remove the PreToolUse entries in ~/.claude/settings.json that point here.
HERE="$(cd "$(dirname "$0")" && pwd)"
GATE="$HERE/email-send-gate.mjs"
if [ ! -f "$GATE" ]; then
  # Fail loud, not open: a missing judge must not wave sends through.
  printf '%s' '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"EMAIL SEND GATE misconfigured: email-send-gate.mjs is missing next to email-send-gate.sh in ~/.claude/hooks. Reinstall both files."}}'
  exit 0
fi
exec node "$GATE"
