#!/bin/bash set -euo pipefail echo "========================================" echo "Autonoma Community Edition Installer" echo "========================================" echo "" # Check prerequisites echo "Checking prerequisites..." # Check Python if command -v python3 &> /dev/null; then PYTHON_VERSION=$(python3 --version 2>&1) echo "[OK] Python found: $PYTHON_VERSION" PYTHON_CMD=python3 elif command -v python &> /dev/null; then PYTHON_VERSION=$(python --version 2>&1) echo "[OK] Python found: $PYTHON_VERSION" PYTHON_CMD=python else echo "[ERROR] Python not found. Please install Python 3.10+ from python.org" exit 1 fi # Check Node.js if command -v node &> /dev/null; then NODE_VERSION=$(node --version 2>&1) echo "[OK] Node.js found: $NODE_VERSION" else echo "[ERROR] Node.js not found. Please install Node.js 18+ from nodejs.org" exit 1 fi # Check VS Code if command -v code &> /dev/null; then CODE_VERSION=$(code --version 2>&1 | head -n 1) echo "[OK] VS Code found: $CODE_VERSION" VSCODE_AVAILABLE=true else echo "[WARN] VS Code CLI not found. Extension will be packaged but not auto-installed." echo " You can install it manually: code --install-extension autonoma-ai-engine-*.vsix" VSCODE_AVAILABLE=false fi echo "" # Check unzip (needed for bootstrap) if ! command -v unzip &> /dev/null; then echo "[WARN] 'unzip' not found. Bootstrap download will fail if daemon folder is missing." echo " Install it: sudo apt-get install unzip (Debian/Ubuntu)" fi # Bootstrap: Check if running standalone (no daemon folder) if [ ! -d "daemon" ]; then echo "[WARN] Core components not found locally." echo "[INFO] Downloading Autonoma Community Edition (Latest)..." ZIP_URL="https://github.com/vihaaninnovations/autonoma/releases/latest/download/Autonoma_Community_Edition.zip" ZIP_PATH="Autonoma_Community_Edition.zip" if command -v curl &> /dev/null; then curl -L -o "$ZIP_PATH" "$ZIP_URL" elif command -v wget &> /dev/null; then wget -O "$ZIP_PATH" "$ZIP_URL" else echo "[ERROR] Neither curl nor wget found. Please download $ZIP_URL manually." exit 1 fi if [ $? -eq 0 ]; then echo "[OK] Download complete." echo "[INFO] Extracting..." if ! command -v unzip &> /dev/null; then echo "[ERROR] 'unzip' is required but not installed." exit 1 fi unzip -o "$ZIP_PATH" rm "$ZIP_PATH" # Move up if nested if [ -d "Autonoma_Community_Edition" ]; then mv Autonoma_Community_Edition/* . rm -rf Autonoma_Community_Edition fi else echo "[ERROR] Failed to download installer content." exit 1 fi fi # Step 1: Install Python dependencies echo "Step 1: Installing Python dependencies..." cd daemon || exit 1 # Create virtual environment if it doesn't exist or was created on Windows if [ ! -d "venv" ] || [ ! -f "venv/bin/activate" ]; then if [ -d "venv" ]; then echo "[INFO] Existing venv is not Linux-compatible (likely created on Windows). Recreating..." rm -rf venv fi echo "Creating virtual environment..." $PYTHON_CMD -m venv venv fi # Activate virtual environment echo "Activating virtual environment..." source venv/bin/activate # Install dependencies echo "Installing Python packages..." pip install -r requirements.txt if [ $? -ne 0 ]; then echo "[ERROR] Failed to install Python dependencies" exit 1 fi echo "[OK] Python dependencies installed" echo "" # Step 2: Initialize database echo "Step 2: Initializing database..." # Use 'python' which now points to the venv Python after activation python -c "from db.db import init_db; init_db()" if [ $? -ne 0 ]; then echo "[ERROR] Failed to initialize database" exit 1 fi echo "[OK] Database initialized" echo "" # Step 3: Install VS Code extension echo "Step 3: Installing VS Code extension..." cd ../vscode-extension || exit 1 # Install Node.js dependencies echo "Installing Node.js dependencies..." npm install if [ $? -ne 0 ]; then echo "[ERROR] Failed to install Node.js dependencies" exit 1 fi # Install vsce if not present echo "Checking for vsce (VS Code Extension Manager)..." if ! npm list -g @vscode/vsce &> /dev/null; then echo "Installing vsce..." npm install --save-dev @vscode/vsce fi # Compile extension echo "Compiling extension..." npm run compile if [ $? -ne 0 ]; then echo "[ERROR] Failed to compile extension" exit 1 fi # Package extension (--allow-missing-repository avoids interactive prompts) echo "Packaging extension..." npx vsce package --allow-missing-repository if [ $? -ne 0 ]; then echo "[ERROR] Failed to package extension" exit 1 fi echo "[OK] Extension packaged successfully" # Install extension if VS Code CLI is available if [ "$VSCODE_AVAILABLE" = true ]; then echo "Installing extension to VS Code..." # Find the VSIX file using glob instead of parsing ls VSIX_FILE="" for f in autonoma-ai-engine-*.vsix; do if [ -f "$f" ]; then VSIX_FILE="$f" break fi done if [ -n "$VSIX_FILE" ]; then code --install-extension "$VSIX_FILE" if [ $? -eq 0 ]; then echo "[OK] Extension installed successfully" echo " Please reload VS Code (Ctrl+Shift+P > 'Developer: Reload Window')" else echo "[WARN] Extension packaged but not installed. Install manually:" echo " code --install-extension $VSIX_FILE" fi else echo "[ERROR] VSIX file not found after packaging." exit 1 fi else echo "[WARN] VS Code CLI not found. Extension packaged but not installed." echo " Install manually: code --install-extension autonoma-ai-engine-*.vsix" fi echo "" # Summary echo "========================================" echo "Installation Complete!" echo "========================================" echo "" echo "Next steps:" echo "1. Start the daemon:" echo " ./run.sh (Linux/Mac)" echo " OR: ./run.ps1 (Windows)" echo "" echo "2. Reload VS Code (if extension was installed):" echo " Press Ctrl+Shift+P, then type: 'Developer: Reload Window'" echo "" echo "3. Verify installation:" echo " - Open Command Palette (Ctrl+Shift+P)" echo " - Search for 'Autonoma'" echo " - You should see all commands available" echo "" echo "4. Check daemon health:" echo " Open browser: http://127.0.0.1:8000/health" echo ""