#!/bin/sh
set -eu

root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
set +e
output=$("$root/.agents/scripts/protect-local" --staged 2>&1)
status=$?
set -e
if [ "$status" -eq 0 ]; then
  exit 0
fi

[ -z "$output" ] || printf '%s\n' "$output" >&2
printf '%s\n' '{"decision":"block","reason":"protect-local rejected staged paths"}'
exit "$status"
