#!/usr/bin/env sh
# ClipsHeist launcher (macOS / Linux / Git-Bash). Uses the private runtime when installed.
SKILL_DIR="$(cd "$(dirname "$0")/.." && pwd)"
HOME_DIR="${CLIPSHEIST_HOME:-$HOME/.clipsheist}"
for PY in "$HOME_DIR/venv/bin/python" "$HOME_DIR/venv/Scripts/python.exe"; do
  [ -x "$PY" ] && exec "$PY" "$SKILL_DIR/scripts/cli.py" "$@"
done
# Not installed yet: doctor/version can still run on any system Python 3.
for PY in python3 python py; do
  if command -v "$PY" >/dev/null 2>&1 && "$PY" -c "import sys; sys.exit(0 if sys.version_info >= (3, 8) else 1)" 2>/dev/null; then
    exec "$PY" "$SKILL_DIR/scripts/cli.py" "$@"
  fi
done
echo '{"ready": false, "python": null, "next_step": "run install/setup.sh (macOS/Linux) or install/setup.ps1 (Windows) - it installs a private Python automatically"}'
exit 3
