#!/usr/bin/env bash # One-command runner for Screen Leads (macOS / Linux). # Creates the virtualenv, installs deps on first run (or when requirements # change), checks for the API key, and launches the dashboard. set -euo pipefail cd "$(dirname "$0")" PYTHON="${PYTHON:-python3}" # 1. Virtual environment if [ ! -d ".venv" ]; then echo "→ Creating virtual environment (.venv)…" "$PYTHON" -m venv .venv fi # shellcheck disable=SC1091 source .venv/bin/activate # 2. Dependencies — (re)install only when requirements.txt is newer than the marker if [ ! -f ".venv/.installed" ] || [ requirements.txt -nt ".venv/.installed" ]; then echo "→ Installing dependencies…" pip install -q --upgrade pip pip install -q -r requirements.txt touch ".venv/.installed" fi # 3. API key — config.py also loads a .env file, so either is fine if [ -z "${ANTHROPIC_API_KEY:-}" ] && [ ! -f ".env" ]; then echo "⚠ ANTHROPIC_API_KEY is not set and no .env file was found." echo " Fix with one of:" echo " export ANTHROPIC_API_KEY=sk-ant-... (this terminal)" echo " cp .env.example .env && edit it (persisted)" exit 1 fi # 4. Launch HOST="${SCREEN_LEADS_HOST:-127.0.0.1}" PORT="${SCREEN_LEADS_PORT:-8000}" echo "→ Starting Screen Leads at http://${HOST}:${PORT} (Ctrl-C to stop)" exec python main.py