#!/usr/bin/env bash
# spool onSessionStart hook for Cursor (managed by `spool mcp install`).
#
# Outputs a wakeup packet block to stdout when Cursor starts a new
# session. Failure-silent: any non-zero exit from spool is swallowed (D7).

set -e

SPOOL_BIN="@@SPOOL_BIN@@"
SPOOL_CONFIG="@@SPOOL_CONFIG@@"
CWD="${CURSOR_PROJECT_DIR:-$PWD}"

if [ ! -x "$SPOOL_BIN" ]; then
  echo "<!-- spool hook: binary missing at $SPOOL_BIN -->"
  exit 0
fi

"$SPOOL_BIN" hook session-start --config "$SPOOL_CONFIG" --cwd "$CWD" 2>/dev/null || true
exit 0
