File size: 1,557 Bytes
3b8a335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/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