#!/bin/bash set -e # Start script for Hugging Face Space # Mounts the OpenSIN-Code repository if available echo "🚀 Starting A2A Cloud Coder Agent..." # Check for repo in common locations REPO_PATHS=( "/workspace/OpenSIN-Code" "/home/user/project/OpenSIN-Code" "/home/user/OpenSIN-Code" "/project/OpenSIN-Code" ) for path in "${REPO_PATHS[@]}"; do if [ -d "$path" ]; then echo "📁 Found repository at $path" REPO_DIR="$path" break fi done if [ -z "$REPO_DIR" ]; then echo "⚠️ No repository found. Clone it manually if needed." REPO_DIR="/workspace/OpenSIN-Code" fi # Export for Python code export REPO_DIR # Create opencode config if not present (uses OCI fallback proxy) mkdir -p ~/.config/opencode if [ ! -f ~/.config/opencode/opencode.json ]; then cat > ~/.config/opencode/opencode.json << 'EOF' { "model": "openai/gpt-5.4", "provider": { "openai": { "options": { "baseUrl": "http://92.5.60.87:4100/v1" } } } } EOF echo "✅ Created opencode config (using OCI fallback proxy)" fi # Check opencode availability if command -v opencode &> /dev/null; then echo "✅ opencode CLI found" opencode --version else echo "❌ opencode CLI not found. Agent will fail to generate code." fi # Check GitHub token if [ -z "$GITHUB_TOKEN" ]; then echo "⚠️ GITHUB_TOKEN not set - commits will fail" else echo "✅ GITHUB_TOKEN set" fi # Start the application echo "🎯 Starting application on port ${PORT:-7860}" exec python app.py