#!/usr/bin/env sh
set -eu

if ! command -v bun >/dev/null 2>&1; then
  echo "bun is required to run @opencode-linear-agent/server" >&2
  exit 1
fi

PRG="$0"
while [ -h "$PRG" ]; do
  LINK=$(readlink "$PRG")
  case "$LINK" in
    /*) PRG="$LINK" ;;
    *) PRG="$(dirname "$PRG")/$LINK" ;;
  esac
done

DIR=$(CDPATH= cd -- "$(dirname -- "$PRG")" && pwd)
exec bun run "$DIR/../dist/index.js" "$@"
