#!/bin/bash
# ============================================================
#      CLAUDE CODE ON ANTIGRAVITY - POWERED BY BAYONSTORE
# ============================================================
#  Server : https://bayonstore.com
#  Check  : https://bayonstore.com/check-key
# ============================================================

clear
echo ""
echo "============================================================"
echo "     CLAUDE CODE ON ANTIGRAVITY - POWERED BY BAYONSTORE"
echo "============================================================"
echo ""
echo "  Server : https://bayonstore.com"
echo "  Check  : https://bayonstore.com/check-key"
echo ""
echo "============================================================"
echo ""

# Ask for the customer's API key
read -r -p "Enter your API Key (sk-...): " APIKEY

if [ -z "$APIKEY" ]; then
    echo ""
    echo "[ERROR] No API Key entered. Close this window and try again."
    echo ""
    read -r -n 1 -s
    exit 1
fi

# Point Claude Code at the BayonStore server (this session only)
export ANTHROPIC_BASE_URL="https://bayonstore.com"
export ANTHROPIC_AUTH_TOKEN="$APIKEY"
export ANTHROPIC_API_KEY="$APIKEY"
export ANTHROPIC_MODEL="nghi/claude-opus-4.8"
export ANTHROPIC_SMALL_FAST_MODEL="nghi/claude-haiku-4.5"

echo ""
echo "[OK] Configured. Opening Antigravity..."
echo ""

# Launch Antigravity with the environment applied. Prefer the CLI; fall back to open -a.
if command -v antigravity >/dev/null 2>&1; then
    antigravity .
elif [ -d "/Applications/Antigravity.app" ]; then
    open -a "Antigravity" .
else
    echo "[NOTE] Could not find Antigravity. Install it, or add the 'antigravity' command"
    echo "       via the app: Cmd+Shift+P -> 'Shell Command: Install command in PATH'."
fi

echo ""
echo "============================================================"
echo "  Antigravity has started. You can close this window."
echo "============================================================"
