#!/bin/bash
# Quick start script for Cheshire Cat testing

set -e

echo "======================================================================"
echo "🐱 Cheshire Cat Test Environment - Quick Start"
echo "======================================================================"
echo ""

# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
    echo "❌ Docker is not running. Please start Docker first."
    exit 1
fi

echo "✅ Docker is running"
echo ""

# Check if llama-swap is running
if ! docker ps | grep -q "llama-swap"; then
    echo "⚠️  Warning: llama-swap container not found"
    echo "   Make sure your Miku bot's llama-swap is running"
    echo "   Continuing anyway..."
else
    echo "✅ llama-swap is running"
fi
echo ""

# Start Cheshire Cat
echo "🚀 Starting Cheshire Cat services..."
docker-compose -f docker-compose.test.yml up -d

echo ""
echo "⏳ Waiting for services to be ready (30 seconds)..."
sleep 30

# Check if services are up
if docker ps | grep -q "miku_cheshire_cat_test"; then
    echo "✅ Cheshire Cat is running"
else
    echo "❌ Cheshire Cat failed to start"
    echo "   Check logs: docker logs miku_cheshire_cat_test"
    exit 1
fi

if docker ps | grep -q "miku_qdrant_test"; then
    echo "✅ Qdrant is running"
else
    echo "❌ Qdrant failed to start"
    exit 1
fi

echo ""
echo "======================================================================"
echo "✅ Services are running!"
echo "======================================================================"
echo ""
echo "Next steps:"
echo ""
echo "  1. Run setup script:"
echo "     python3 test_setup.py"
echo ""
echo "  2. Run benchmarks:"
echo "     python3 benchmark_cat.py"
echo ""
echo "  3. Compare with current system:"
echo "     python3 compare_systems.py"
echo ""
echo "  4. Access admin panel:"
echo "     http://localhost:1865/admin"
echo ""
echo "======================================================================"
