#!/bin/bash # VantaBrain installer # curl -fsSL https://vb.darkcode.ai | bash set -u REPO="vantagrid/vantabrain" BRAIN_HOME="${BRAIN_HOME:-$HOME/VantaBrain}" # -- colors --------------------------------------------------------------- RED='\033[0;31m' GREEN='\033[0;32m' BLUE='\033[0;34m' CYAN='\033[0;36m' DIM='\033[2m' BOLD='\033[1m' NC='\033[0m' info() { echo -e "${BLUE}[info]${NC} $*"; } ok() { echo -e "${GREEN}[ok]${NC} $*"; } warn() { echo -e "${RED}[warn]${NC} $*"; } # -- banner ---------------------------------------------------------------- echo "" echo -e "${BOLD}VantaBrain Installer${NC}" echo "" # -- preflight ------------------------------------------------------------- missing=0 for dep in gh git node npm; do if ! command -v "$dep" >/dev/null 2>&1; then warn "$dep is required but not installed." missing=1 fi done if [ "$missing" -eq 1 ]; then echo "" warn "Install missing dependencies and try again." echo -e "${DIM} macOS: brew install gh git node${NC}" echo -e "${DIM} Linux: apt install gh git nodejs npm${NC}" exit 1 fi if ! gh auth status >/dev/null 2>&1; then warn "gh is not authenticated. Run: gh auth login" exit 1 fi NODE_MAJOR=$(node -e "console.log(process.versions.node.split('.')[0])") if [ "$NODE_MAJOR" -lt 20 ]; then warn "Node.js >= 20 required (found $(node -v))" echo -e "${DIM} brew install node or nvm install 20${NC}" exit 1 fi ok "Dependencies: gh $(gh --version | head -1 | awk '{print $3}'), git $(git --version | awk '{print $3}'), node $(node -v | tr -d v)" # -- clone or update ------------------------------------------------------- if [ -d "$BRAIN_HOME/.git" ]; then info "Existing install at $BRAIN_HOME -- updating..." git -C "$BRAIN_HOME" pull --rebase --autostash || { warn "git pull failed -- continuing with existing version" } ok "Updated" elif [ -d "$BRAIN_HOME" ]; then warn "$BRAIN_HOME exists but is not a git repo" info "Backing up and cloning fresh..." mv "$BRAIN_HOME" "${BRAIN_HOME}.bak.$(date +%s)" gh repo clone "$REPO" "$BRAIN_HOME" ok "Cloned (old dir backed up)" else info "Cloning VantaBrain to $BRAIN_HOME..." gh repo clone "$REPO" "$BRAIN_HOME" ok "Cloned" fi # -- install CLI deps ------------------------------------------------------ if [ ! -d "$BRAIN_HOME/cli/node_modules" ]; then info "Installing CLI dependencies..." (cd "$BRAIN_HOME/cli" && npm install 2>&1 | tail -3) fi # -- hand off to Ink TUI -------------------------------------------------- ok "Ready. Launching setup..." echo "" # When run via curl|bash, stdin is the pipe. We need a real TTY for Ink. # Redirect stdin from /dev/tty before launching, and use exec to ensure # npx gets the TTY directly. if [ -t 0 ]; then cd "$BRAIN_HOME/cli" && npx tsx src/cli.tsx onboard else cd "$BRAIN_HOME/cli" && exec npx tsx src/cli.tsx onboard