#!/usr/bin/env bash
# Logical root (PEP-18): only the bin's own symlink (~/.local/bin) is followed, so a launch
# through ~/peppa/current keeps that path in hooks and git config instead of the release dir.
_b="$0"; [ -L "$_b" ] && { _l="$(readlink "$_b")"; if [ "${_l#/}" != "$_l" ]; then _b="$_l"; else _b="$(dirname "$_b")/$_l"; fi; }
PEPPA_ROOT="$(cd "$(dirname "$_b")/../../.." && pwd)"; unset _b _l
# Not a Peppa session: nothing to do, skip node startup.
[ -z "${PEPPA_SESSION_ID:-}" ] && { [ "${1:-}" = codex-notify ] || cat >/dev/null; exit 0; }
. "$PEPPA_ROOT/scripts/lib/load-env.sh"
mkdir -p "${PEPPA_HOME:-$HOME/.peppa}"
exec "${PEPPA_NODE:-node}" --import "$PEPPA_ROOT/scripts/lib/require-node.mjs" "$PEPPA_ROOT/packages/runner/src/hook.ts" "$@"
