-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
109 lines (93 loc) · 4.42 KB
/
setup.sh
File metadata and controls
109 lines (93 loc) · 4.42 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# setup.sh — Agent42 setup script
# Run once after cloning: bash setup.sh
# Use --quiet when called from install-server.sh (suppresses banners/prompts)
set -e
QUIET=false
[ "$1" = "--quiet" ] && QUIET=true
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
if ! $QUIET; then
echo ""
echo " ___ _ _ _ ____ "
echo " / _ \ __ _ ___ _ __ | |_| | |___ \ "
echo "| |_| |/ _\` |/ _ \ '_ \| __| | | __) |"
echo "| | | | (_| | __/ | | | |_|_| |/ __/ "
echo "|_| |_|\__, |\___|_| |_|\__(_)_|_____|"
echo " |___/ "
echo ""
info "The answer to all your tasks."
echo ""
fi
# ── Check Python 3.11+ ──────────────────────────────────────────────────────
if ! command -v python3 &>/dev/null; then
error "Python 3 not found. Install Python 3.11+."
fi
PY_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PY_MAJOR=$(python3 -c "import sys; print(sys.version_info.major)")
PY_MINOR=$(python3 -c "import sys; print(sys.version_info.minor)")
if [ "$PY_MAJOR" -lt 3 ] || { [ "$PY_MAJOR" -eq 3 ] && [ "$PY_MINOR" -lt 11 ]; }; then
error "Python 3.11+ required. Found: $PY_VERSION"
fi
info "Python version: $PY_VERSION"
# ── Check Node.js ────────────────────────────────────────────────────────────
if ! command -v node &>/dev/null; then
warn "Node.js not found. Installing via nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 20
nvm use 20
else
info "Node.js version: $(node --version)"
fi
# ── Check git ────────────────────────────────────────────────────────────────
if ! command -v git &>/dev/null; then
error "git not found. Install git."
fi
info "git version: $(git --version)"
# ── Python venv ──────────────────────────────────────────────────────────────
info "Creating Python virtual environment..."
python3 -m venv .venv
source .venv/bin/activate
info "Installing Python dependencies..."
pip install --quiet --upgrade pip
pip install --quiet -r requirements.txt
info "Python dependencies installed"
# ── .env setup ───────────────────────────────────────────────────────────────
if [ ! -f ".env" ]; then
cp .env.example .env
info "Created .env from .env.example"
else
info ".env already exists — skipping"
fi
# ── React frontend ───────────────────────────────────────────────────────────
if [ -d "dashboard/frontend" ] && [ -f "dashboard/frontend/package.json" ]; then
info "Installing frontend dependencies..."
cd dashboard/frontend
npm install --silent
info "Building React frontend..."
npm run build
cd ../..
info "Frontend built"
else
$QUIET || warn "No frontend found at dashboard/frontend — skipping frontend build"
fi
# ── Done ─────────────────────────────────────────────────────────────────────
if ! $QUIET; then
echo ""
info "Setup complete!"
echo ""
echo " 1. Start Agent42: source .venv/bin/activate && python agent42.py"
echo " 2. Open http://localhost:8000 to complete setup in your browser"
echo ""
warn "Your git repo needs a 'dev' branch for coding/debugging/refactoring tasks."
info " git checkout -b dev (if you don't have one)"
info " Non-code tasks (marketing, content, design, etc.) work without it."
echo ""
fi