diff --git a/check-enviroment.sh b/check-enviroment.sh new file mode 100755 index 0000000000..93f98cfe8d --- /dev/null +++ b/check-enviroment.sh @@ -0,0 +1,182 @@ +#!/bin/bash +# +# check-environment.sh - Setup validation for Aden Agent Framework +# +# Run this before setup to see a checklist of requirements with pass/fail status. +# Catches common issues (PEP 668, missing dirs, wrong Python, etc.) before they cause failures. +# +# Usage: ./check-enviroment.sh (from repo root) +# or: ./scripts/check-environment.sh (if moved to scripts/) +# + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Resolve project root: script may live in repo root or in scripts/ +SCRIPT_PATH="${BASH_SOURCE[0]}" +SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)" +if [[ "$(basename "$SCRIPT_DIR")" == "scripts" ]]; then + PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +else + PROJECT_ROOT="$SCRIPT_DIR" +fi + +PASS=0 +FAIL=0 +WARN=0 + +check_pass() { + echo -e " ${GREEN}✓${NC} $1" + ((PASS++)) || true +} + +check_fail() { + echo -e " ${RED}✗${NC} $1" + ((FAIL++)) || true +} + +check_warn() { + echo -e " ${YELLOW}⚠${NC} $1" + ((WARN++)) || true +} + +echo "" +echo "==================================================" +echo " Aden Agent Framework - Environment Check" +echo "==================================================" +echo "" +echo "Project root: $PROJECT_ROOT" +echo "" + +# --- Python --- +echo -e "${BLUE}Python${NC}" +if command -v python3 &> /dev/null; then + PYTHON_CMD="python3" +elif command -v python &> /dev/null; then + PYTHON_CMD="python" +else + check_fail "Python not found. Install Python 3.11+ (see ENVIRONMENT_SETUP.md)" + echo "" + exit 1 +fi + +PYTHON_VERSION=$($PYTHON_CMD -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null || echo "") +if [[ -z "$PYTHON_VERSION" ]]; then + check_fail "Could not get Python version (broken install?)" +else + PYTHON_MAJOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.major)') + PYTHON_MINOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.minor)') + if [[ "$PYTHON_MAJOR" -lt 3 ]] || { [[ "$PYTHON_MAJOR" -eq 3 ]] && [[ "$PYTHON_MINOR" -lt 11 ]]; }; then + check_fail "Python 3.11+ required; found $PYTHON_VERSION" + else + check_pass "Python $PYTHON_VERSION (3.11+ required)" + fi +fi +echo "" + +# --- pip --- +echo -e "${BLUE}pip${NC}" +if $PYTHON_CMD -m pip --version &> /dev/null; then + check_pass "pip available" +else + check_fail "pip not found. Run: $PYTHON_CMD -m ensurepip --upgrade" +fi +echo "" + +# --- Virtual environment --- +echo -e "${BLUE}Virtual environment${NC}" +if [[ -n "$VIRTUAL_ENV" ]]; then + check_pass "Active venv: $(basename "$VIRTUAL_ENV")" +else + check_warn "No virtual environment. Recommended: python3 -m venv .venv && source .venv/bin/activate" +fi +echo "" + +# --- PEP 668 (externally managed) --- +echo -e "${BLUE}PEP 668 / system Python${NC}" +PIP_CHECK=$(mktemp) +# Try dry-run to detect PEP 668 (externally-managed-environment) errors +$PYTHON_CMD -m pip install --dry-run pip &> "$PIP_CHECK" 2>&1 || true +if grep -q "externally-managed-environment\|externally managed" "$PIP_CHECK" 2>/dev/null; then + check_fail "System Python is externally managed (PEP 668). Use a venv: python3 -m venv .venv && source .venv/bin/activate" +elif grep -q "unknown option.*dry-run\|unrecognized.*dry-run" "$PIP_CHECK" 2>/dev/null; then + # Older pip version without --dry-run support + check_warn "Cannot pre-check PEP 668 (pip version may not support --dry-run). Setup will detect it." +elif grep -q "error\|Error\|ERROR" "$PIP_CHECK" 2>/dev/null; then + # Other error - might be OK, setup will handle it + check_warn "pip dry-run had issues (may be OK). Run setup: ./scripts/setup-python.sh" +else + check_pass "pip can install packages (no PEP 668 block detected)" +fi +rm -f "$PIP_CHECK" +echo "" + +# --- Project layout --- +echo -e "${BLUE}Project layout${NC}" +[[ -d "$PROJECT_ROOT/core" ]] && check_pass "core/ exists" || check_fail "core/ missing (wrong directory or incomplete clone)" +[[ -f "$PROJECT_ROOT/core/pyproject.toml" ]] && check_pass "core/pyproject.toml exists" || check_fail "core/pyproject.toml missing" +[[ -d "$PROJECT_ROOT/tools" ]] && check_pass "tools/ exists" || check_fail "tools/ missing" +[[ -f "$PROJECT_ROOT/tools/pyproject.toml" ]] && check_pass "tools/pyproject.toml exists" || check_fail "tools/pyproject.toml missing" +if [[ -d "$PROJECT_ROOT/exports" ]]; then + check_pass "exports/ exists" +else + check_warn "exports/ missing (will be created by setup-python.sh)" +fi +echo "" + +# --- Installed packages (optional) --- +echo -e "${BLUE}Installed packages (optional before setup)${NC}" +if $PYTHON_CMD -c "import framework" 2>/dev/null; then + check_pass "framework importable" +else + check_warn "framework not installed yet. Run: ./scripts/setup-python.sh" +fi +if $PYTHON_CMD -c "import aden_tools" 2>/dev/null; then + check_pass "aden_tools importable" +else + check_warn "aden_tools not installed yet. Run: ./scripts/setup-python.sh" +fi +OPENAI_VER=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null || echo "") +if [[ -n "$OPENAI_VER" ]]; then + if [[ "$OPENAI_VER" =~ ^0\. ]]; then + check_fail "openai $OPENAI_VER is too old (need >=1.0.0 for litellm). Run: pip install --upgrade \"openai>=1.0.0\"" + else + check_pass "openai $OPENAI_VER (compatible with litellm)" + fi +else + check_warn "openai not installed (setup-python.sh will install/upgrade)" +fi +if $PYTHON_CMD -c "import litellm" 2>/dev/null; then + check_pass "litellm importable" +else + check_warn "litellm not installed yet (installed with framework)" +fi +echo "" + +# --- Summary --- +echo "==================================================" +echo -e " Summary: ${GREEN}$PASS passed${NC}, ${RED}$FAIL failed${NC}, ${YELLOW}$WARN warnings${NC}" +echo "==================================================" +echo "" +if [[ "$FAIL" -gt 0 ]]; then + echo "Fix the failed checks above, then run:" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo "See ENVIRONMENT_SETUP.md for detailed help." + echo "" + exit 1 +fi +if [[ "$WARN" -gt 0 ]]; then + echo "All required checks passed. Warnings are optional improvements." + echo "To install packages and finish setup:" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + exit 0 +fi +echo "Environment looks good. To install/update packages:" +echo -e " ${BLUE}./scripts/setup-python.sh${NC}" +echo "" +exit 0 diff --git a/feature-helpful-error-messages.md b/feature-helpful-error-messages.md new file mode 100644 index 0000000000..c1351ce8ad --- /dev/null +++ b/feature-helpful-error-messages.md @@ -0,0 +1,58 @@ +# Problem Statement +When setup fails (Issues #450, #238, #202), error messages show technical stack traces but don't guide users toward solutions. This is especially problematic for: + +* First-time contributors who lack debugging experience +* Non-Python developers unfamiliar with pip/environment issues +* Users on different OS environments (Ubuntu vs Mac) +### Example from Issue #450: +Dependency conflict: openai + litellm compatibility issue +What users see: Technical error +What users need: "Run this command to fix it: pip install --upgrade "openai>=1.0.0"" + +### User Impact + +Setup failures cause abandonment (direct barrier to contribution) +Support burden increases with repetitive environment questions +Negative first impression undermines trust in platform reliability +## Proposed Solution +Implement user-friendly error handling with progressive disclosure: + +1. Error Message Structure + ❌ Setup Failed: Dependency Conflict + + What happened: Python packages openai and litellm are incompatible + + Quick fix: Run this command in your terminal: + → pip install --upgrade "openai>=1.0.0" + + Why this happened: [Show details ▼] + + Still stuck? [Common solutions] [Ask on Discord] +2. Smart Error Detection +Detect common failure patterns (PEP 668, missing exports/, permission errors) +Provide OS-specific solutions automatically +Surface relevant GitHub issues automatically +3. Setup Validation Tool +Add ./scripts/check-environment.sh that runs before setup +Shows checklist of requirements with pass/fail status +Catches issues before they cause failures +4. Recovery Flow +When setup fails, offer automated recovery options +"Try alternative setup method" (Codespaces, Docker) +"Skip this step for now" where appropriate +### Success Metrics + +Reduce setup failure rate by 40% +Decrease average time-to-resolve setup issues +Lower volume of setup-related support questions +### Technical Implementation Notes + +Wrap setup scripts with better error handling +Add fallback strategies for common failures +Create error message database with solutions +Consider interactive setup wizard vs current bash scripts +### Design Artifacts Needed + +Error message content guidelines +Flowchart for error recovery paths +Mockups of setup validation checklist UI \ No newline at end of file diff --git a/quickstart.sh b/quickstart.sh index 6d751fd777..a4bc9108d7 100755 --- a/quickstart.sh +++ b/quickstart.sh @@ -1,226 +1,430 @@ #!/bin/bash # -# quickstart.sh - Interactive onboarding for Aden Agent Framework +# quickstart.sh - Complete setup for Aden Agent Framework skills # -# An interactive setup wizard that: -# 1. Installs Python dependencies -# 2. Installs Playwright browser for web scraping -# 3. Helps configure LLM API keys -# 4. Verifies everything works +# This script: +# 1. Installs Python dependencies (framework, aden_tools, MCP) +# 2. Installs Claude Code skills for building and testing agents +# 3. Verifies the setup is ready to use # set -e -# Detect Bash version for compatibility -BASH_MAJOR_VERSION="${BASH_VERSINFO[0]}" -USE_ASSOC_ARRAYS=false -if [ "$BASH_MAJOR_VERSION" -ge 4 ]; then - USE_ASSOC_ARRAYS=true -fi -echo "[debug] Bash version: ${BASH_VERSION}" - # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' -CYAN='\033[0;36m' -BOLD='\033[1m' -DIM='\033[2m' NC='\033[0m' # No Color # Get the directory where this script is located SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Helper function for prompts -prompt_yes_no() { - local prompt="$1" - local default="${2:-y}" - local response - - if [ "$default" = "y" ]; then - prompt="$prompt [Y/n] " - else - prompt="$prompt [y/N] " - fi - - read -r -p "$prompt" response - response="${response:-$default}" - [[ "$response" =~ ^[Yy] ]] -} - -# Helper function for choice prompts -prompt_choice() { - local prompt="$1" - shift - local options=("$@") - local i=1 +# Claude Code skills directory +CLAUDE_SKILLS_DIR="$HOME/.claude/skills" - echo "" - echo -e "${BOLD}$prompt${NC}" - for opt in "${options[@]}"; do - echo -e " ${CYAN}$i)${NC} $opt" - i=$((i + 1)) - done - echo "" - - local choice - while true; do - read -r -p "Enter choice (1-${#options[@]}): " choice - if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#options[@]}" ]; then - PROMPT_CHOICE=$((choice - 1)) - return 0 - fi - echo -e "${RED}Invalid choice. Please enter 1-${#options[@]}${NC}" - done -} - -clear -echo "" -echo -e "${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}" echo "" -echo -e "${BOLD} A D E N H I V E${NC}" -echo "" -echo -e "${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}${DIM}⬡${NC}${YELLOW}⬢${NC}" -echo "" -echo -e "${DIM} Goal-driven AI agent framework${NC}" -echo "" -echo "This wizard will help you set up everything you need" -echo "to build and run goal-driven AI agents." +echo "==================================================" +echo " Aden Agent Framework - Complete Setup" +echo "==================================================" echo "" -if ! prompt_yes_no "Ready to begin?"; then +# Detect if running in virtual environment +if [ -z "$VIRTUAL_ENV" ]; then + echo -e "${YELLOW}Note:${NC} Not running in a virtual environment" + echo " Recommended: Use a virtual environment to avoid conflicts" + echo -e " Create one with: ${BLUE}python3 -m venv .venv && source .venv/bin/activate${NC}" + echo "" +else + echo -e "${GREEN}✓${NC} Running in virtual environment: $(basename "$VIRTUAL_ENV")" echo "" - echo "No problem! Run this script again when you're ready." - exit 0 fi -echo "" - # ============================================================ -# Step 1: Check Python +# Step 1: Check Python Prerequisites # ============================================================ -echo -e "${YELLOW}⬢${NC} ${BLUE}${BOLD}Step 1: Checking Python...${NC}" +echo -e "${BLUE}Step 1: Checking Python prerequisites...${NC}" echo "" # Check for Python if ! command -v python &> /dev/null && ! command -v python3 &> /dev/null; then - echo -e "${RED}Python is not installed.${NC}" echo "" - echo "Please install Python 3.11+ from https://python.org" - echo "Then run this script again." + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Python Not Found${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Python is not installed on your system" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Install Python 3.11+ using one of these methods:" + echo "" + if [[ "$OSTYPE" == "darwin"* ]]; then + echo " macOS (Homebrew):" + echo -e " ${BLUE}brew install python@3.11${NC}" + echo "" + echo " macOS (Official installer):" + echo -e " ${BLUE}https://www.python.org/downloads/${NC}" + elif [[ "$OSTYPE" == "linux"* ]]; then + echo " Ubuntu/Debian:" + echo -e " ${BLUE}sudo apt update && sudo apt install python3.11${NC}" + echo "" + echo " Fedora/RHEL:" + echo -e " ${BLUE}sudo dnf install python3.11${NC}" + else + echo " Download from:" + echo -e " ${BLUE}https://www.python.org/downloads/${NC}" + fi + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " Documentation: https://www.python.org/downloads/" + echo "" exit 1 fi -# Prefer a Python >= 3.11 if multiple are installed (common on macOS). -PYTHON_CMD="" -for CANDIDATE in python3.11 python3.12 python3.13 python3 python; do - if command -v "$CANDIDATE" &> /dev/null; then - PYTHON_MAJOR=$("$CANDIDATE" -c 'import sys; print(sys.version_info.major)') - PYTHON_MINOR=$("$CANDIDATE" -c 'import sys; print(sys.version_info.minor)') - if [ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -ge 11 ]; then - PYTHON_CMD="$CANDIDATE" - break - fi - fi -done - -if [ -z "$PYTHON_CMD" ]; then - # Fall back to python3/python just for a helpful detected version in the error message. - PYTHON_CMD="python3" - if ! command -v python3 &> /dev/null; then - PYTHON_CMD="python" - fi +# Use python3 if available, otherwise python +PYTHON_CMD="python3" +if ! command -v python3 &> /dev/null; then + PYTHON_CMD="python" fi -# Check Python version (for logging/error messages) +# Check Python version PYTHON_VERSION=$($PYTHON_CMD -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') PYTHON_MAJOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.major)') PYTHON_MINOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.minor)') +echo -e " Detected Python: ${GREEN}$PYTHON_VERSION${NC}" + if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 11 ]); then - echo -e "${RED}Python 3.11+ is required (found $PYTHON_VERSION)${NC}" echo "" - echo "Please upgrade your Python installation and run this script again." + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Python Version Too Old${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Python 3.11+ is required, but you have Python $PYTHON_VERSION" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Upgrade Python using one of these methods:" + echo "" + if [[ "$OSTYPE" == "darwin"* ]]; then + echo " macOS (Homebrew):" + echo -e " ${BLUE}brew install python@3.11${NC}" + echo "" + echo " macOS (pyenv - recommended for managing multiple versions):" + echo -e " ${BLUE}brew install pyenv${NC}" + echo -e " ${BLUE}pyenv install 3.11.0${NC}" + echo -e " ${BLUE}pyenv global 3.11.0${NC}" + elif [[ "$OSTYPE" == "linux"* ]]; then + echo " Ubuntu/Debian:" + echo -e " ${BLUE}sudo apt update && sudo apt install python3.11${NC}" + echo "" + echo " Using pyenv (recommended for managing multiple versions):" + echo -e " ${BLUE}curl https://pyenv.run | bash${NC}" + echo -e " ${BLUE}pyenv install 3.11.0${NC}" + echo -e " ${BLUE}pyenv global 3.11.0${NC}" + else + echo " Download from:" + echo -e " ${BLUE}https://www.python.org/downloads/${NC}" + fi + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " This framework requires Python 3.11+ for compatibility with modern dependencies" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " See installation guide: https://www.python.org/downloads/" + echo "" exit 1 fi -echo -e "${GREEN}⬢${NC} Python $PYTHON_VERSION" -echo "" - -# Check for uv (install automatically if missing) -if ! command -v uv &> /dev/null; then - echo -e "${YELLOW} uv not found. Installing...${NC}" - if ! command -v curl &> /dev/null; then - echo -e "${RED}Error: curl is not installed (needed to install uv)${NC}" - echo "Please install curl or install uv manually from https://astral.sh/uv/" - exit 1 - fi +if [ "$PYTHON_MINOR" -lt 11 ]; then + echo -e "${YELLOW} Warning: Python 3.11+ is recommended for best compatibility${NC}" +fi - curl -LsSf https://astral.sh/uv/install.sh | sh - export PATH="$HOME/.local/bin:$PATH" +echo -e "${GREEN} ✓ Python version OK${NC}" +echo "" - if ! command -v uv &> /dev/null; then - echo -e "${RED}Error: uv installation failed${NC}" - echo "Please install uv manually from https://astral.sh/uv/" - exit 1 +# Check for pip +if ! $PYTHON_CMD -m pip --version &> /dev/null; then + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: pip Not Found${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " pip (Python package installer) is not available for Python $PYTHON_VERSION" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + if [[ "$OSTYPE" == "darwin"* ]]; then + echo " macOS:" + echo -e " ${BLUE}python3 -m ensurepip --upgrade${NC}" + echo "" + echo " Or reinstall Python with Homebrew (includes pip):" + echo -e " ${BLUE}brew reinstall python@3.11${NC}" + elif [[ "$OSTYPE" == "linux"* ]]; then + echo " Ubuntu/Debian:" + echo -e " ${BLUE}sudo apt install python3-pip${NC}" + echo "" + echo " Fedora/RHEL:" + echo -e " ${BLUE}sudo dnf install python3-pip${NC}" + else + echo " Run:" + echo -e " ${BLUE}python3 -m ensurepip --upgrade${NC}" fi - echo -e "${GREEN} ✓ uv installed successfully${NC}" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " pip should be included with Python 3.11+, but it may need to be enabled" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " See pip installation guide: https://pip.pypa.io/en/stable/installation/" + echo "" + exit 1 fi -UV_VERSION=$(uv --version) -echo -e "${GREEN} ✓ uv detected: $UV_VERSION${NC}" +echo -e "${GREEN} ✓ pip detected${NC}" echo "" # ============================================================ # Step 2: Install Python Packages # ============================================================ -echo -e "${YELLOW}⬢${NC} ${BLUE}${BOLD}Step 2: Installing packages...${NC}" +echo -e "${BLUE}Step 2: Installing Python packages...${NC}" echo "" -echo -e "${DIM}This may take a minute...${NC}" +# Upgrade pip, setuptools, and wheel +echo " Upgrading pip, setuptools, wheel..." +$PYTHON_CMD -m pip install --upgrade pip setuptools wheel > /dev/null 2>&1 +echo -e "${GREEN} ✓ Core tools upgraded${NC}" echo "" -# Install all workspace packages (core + tools) from workspace root -echo -n " Installing workspace packages... " -cd "$SCRIPT_DIR" +# Smart Detection: Check for exports directory +if [ ! -d "$SCRIPT_DIR/exports" ]; then + echo -e "${YELLOW}Note:${NC} exports/ directory not found" + echo " Creating exports/ directory for agent modules..." + mkdir -p "$SCRIPT_DIR/exports" + echo -e "${GREEN} ✓ Created exports/ directory${NC}" + echo "" +fi +# Install framework package from core/ +echo " Installing framework package from core/..." +cd "$SCRIPT_DIR/core" if [ -f "pyproject.toml" ]; then - if uv sync > /dev/null 2>&1; then - echo -e "${GREEN} ✓ workspace packages installed${NC}" - else - echo -e "${RED} ✗ workspace installation failed${NC}" + INSTALL_OUTPUT=$(mktemp) + if ! $PYTHON_CMD -m pip install -e . > "$INSTALL_OUTPUT" 2>&1; then + INSTALL_ERROR=$(cat "$INSTALL_OUTPUT") + rm -f "$INSTALL_OUTPUT" + + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Framework Installation Error${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Failed to install framework package from core/" + echo "" + + # Smart detection of specific errors + if echo "$INSTALL_ERROR" | grep -qi "network\|connection\|timeout"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Network issue detected. Check your internet connection and try again" + elif echo "$INSTALL_ERROR" | grep -qi "permission denied\|permissionerror"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Permission error detected. Try:" + echo -e " ${BLUE}chmod -R u+w $SCRIPT_DIR/core${NC}" + echo " Or use a virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv && source .venv/bin/activate${NC}" + elif echo "$INSTALL_ERROR" | grep -qi "conflict\|incompatible"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Dependency conflict. Try in a clean virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./quickstart.sh${NC}" + else + echo -e "${YELLOW}Quick fix:${NC}" + echo " Try reinstalling with verbose output:" + echo -e " ${BLUE}cd $SCRIPT_DIR/core && pip install -e . -v${NC}" + fi + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$INSTALL_ERROR" | head -n 15 + echo "" exit 1 fi + rm -f "$INSTALL_OUTPUT" + echo -e "${GREEN} ✓ framework package installed${NC}" else - echo -e "${RED}failed (no root pyproject.toml)${NC}" + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Missing pyproject.toml${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " No pyproject.toml found in core/ directory" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " 1. Verify you cloned the full repository:" + echo -e " ${BLUE}ls -la $SCRIPT_DIR/core/pyproject.toml${NC}" + echo " 2. Re-clone if necessary:" + echo -e " ${BLUE}git clone ${NC}" + echo "" exit 1 fi -# Install Playwright browser -echo -n " Installing Playwright browser... " -if uv run python -c "import playwright" > /dev/null 2>&1; then - if uv run python -m playwright install chromium > /dev/null 2>&1; then - echo -e "${GREEN}ok${NC}" - else - echo -e "${YELLOW}⏭${NC}" +# Install aden_tools package from tools/ +echo " Installing aden_tools package from tools/..." +cd "$SCRIPT_DIR/tools" +if [ -f "pyproject.toml" ]; then + INSTALL_OUTPUT=$(mktemp) + if ! $PYTHON_CMD -m pip install -e . > "$INSTALL_OUTPUT" 2>&1; then + INSTALL_ERROR=$(cat "$INSTALL_OUTPUT") + rm -f "$INSTALL_OUTPUT" + + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Tools Package Installation Error${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Failed to install aden_tools package from tools/" + echo "" + + # Smart detection + if echo "$INSTALL_ERROR" | grep -qi "network\|connection\|timeout"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Network issue. Check internet connection and retry" + elif echo "$INSTALL_ERROR" | grep -qi "permission"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Use a virtual environment to avoid permission issues:" + echo -e " ${BLUE}python3 -m venv .venv && source .venv/bin/activate${NC}" + else + echo -e "${YELLOW}Quick fix:${NC}" + echo " Try verbose installation:" + echo -e " ${BLUE}cd $SCRIPT_DIR/tools && pip install -e . -v${NC}" + fi + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$INSTALL_ERROR" | head -n 15 + echo "" + exit 1 fi + rm -f "$INSTALL_OUTPUT" + echo -e "${GREEN} ✓ aden_tools package installed${NC}" else - echo -e "${YELLOW}⏭${NC}" + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Missing pyproject.toml${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " No pyproject.toml found in tools/ directory" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Verify repository structure:" + echo -e " ${BLUE}ls -la $SCRIPT_DIR/tools/pyproject.toml${NC}" + echo "" + exit 1 fi -cd "$SCRIPT_DIR" -echo "" -echo -e "${GREEN}⬢${NC} All packages installed" -echo "" +# Install MCP dependencies +echo " Installing MCP dependencies..." +INSTALL_OUTPUT=$(mktemp) +if ! $PYTHON_CMD -m pip install mcp fastmcp > "$INSTALL_OUTPUT" 2>&1; then + INSTALL_ERROR=$(cat "$INSTALL_OUTPUT") + rm -f "$INSTALL_OUTPUT" -# ============================================================ -# Step 3: Configure LLM API Key -# ============================================================ + echo "" + echo -e "${YELLOW}Warning:${NC} MCP dependencies installation failed" + echo " This may not be critical for basic agent functionality" + echo "" + + # Check if it's a network issue + if echo "$INSTALL_ERROR" | grep -qi "network\|connection\|timeout"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Network issue. Retry when internet is stable" + fi + echo "" +else + rm -f "$INSTALL_OUTPUT" + echo -e "${GREEN} ✓ MCP dependencies installed${NC}" +fi + +# Smart Detection: Fix openai version compatibility with litellm (Issue #450) +OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null || echo "not_installed") +if [ "$OPENAI_VERSION" = "not_installed" ]; then + echo " Installing openai package..." + INSTALL_OUTPUT=$(mktemp) + if ! $PYTHON_CMD -m pip install "openai>=1.0.0" > "$INSTALL_OUTPUT" 2>&1; then + INSTALL_ERROR=$(cat "$INSTALL_OUTPUT") + rm -f "$INSTALL_OUTPUT" + + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: openai Installation Error${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Failed to install openai package" + echo "" + + if echo "$INSTALL_ERROR" | grep -qi "network\|connection\|timeout"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Network issue. Check connection and retry" + elif echo "$INSTALL_ERROR" | grep -qi "conflict\|incompatible"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Dependency conflict. Use clean virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv && source .venv/bin/activate${NC}" + echo "" + echo -e "${YELLOW}Related issue:${NC}" + echo " GitHub: https://github.com/your-repo/issues/450" + fi + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$INSTALL_ERROR" | head -n 10 + echo "" + exit 1 + fi + rm -f "$INSTALL_OUTPUT" + echo -e "${GREEN} ✓ openai installed${NC}" +elif [[ "$OPENAI_VERSION" =~ ^0\. ]]; then + echo -e "${YELLOW} Detected Issue #450:${NC} Old openai $OPENAI_VERSION (incompatible with litellm)" + echo " Upgrading to openai 1.x+..." + UPGRADE_OUTPUT=$(mktemp) + if ! $PYTHON_CMD -m pip install --upgrade "openai>=1.0.0" > "$UPGRADE_OUTPUT" 2>&1; then + UPGRADE_ERROR=$(cat "$UPGRADE_OUTPUT") + rm -f "$UPGRADE_OUTPUT" -echo -e "${YELLOW}⬢${NC} ${BLUE}${BOLD}Step 3: Configuring LLM provider...${NC}" + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: openai Upgrade Error (Issue #450)${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Cannot upgrade openai due to dependency conflicts" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Force reinstall:" + echo -e " ${BLUE}pip uninstall -y openai litellm${NC}" + echo -e " ${BLUE}pip install 'openai>=1.0.0' litellm${NC}" + echo "" + echo -e "${YELLOW}Related issue:${NC}" + echo " GitHub: https://github.com/your-repo/issues/450" + echo "" + exit 1 + fi + rm -f "$UPGRADE_OUTPUT" + OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null) + echo -e "${GREEN} ✓ openai upgraded to $OPENAI_VERSION (Issue #450 resolved)${NC}" +else + echo -e "${GREEN} ✓ openai $OPENAI_VERSION is compatible${NC}" +fi + +# Install click for CLI +$PYTHON_CMD -m pip install click > /dev/null 2>&1 +echo -e "${GREEN} ✓ click installed${NC}" + +cd "$SCRIPT_DIR" echo "" # ============================================================ @@ -232,28 +436,55 @@ echo "" IMPORT_ERRORS=0 -# Test imports using workspace venv via uv run -if uv run python -c "import framework" > /dev/null 2>&1; then +# Test framework import with smart diagnostics +IMPORT_ERROR=$(mktemp) +if $PYTHON_CMD -c "import framework" > /dev/null 2>"$IMPORT_ERROR"; then echo -e "${GREEN} ✓ framework imports OK${NC}" else + IMPORT_ERROR_MSG=$(cat "$IMPORT_ERROR") echo -e "${RED} ✗ framework import failed${NC}" + echo "" + + # Smart detection of import issues + if echo "$IMPORT_ERROR_MSG" | grep -qi "no module"; then + echo -e "${YELLOW} Quick fix:${NC} Reinstall framework package:" + echo -e " ${BLUE}cd $SCRIPT_DIR/core && pip install -e .${NC}" + elif echo "$IMPORT_ERROR_MSG" | grep -qi "syntax"; then + echo -e "${YELLOW} Quick fix:${NC} Python version mismatch. Verify Python 3.11+:" + echo -e " ${BLUE}python --version${NC}" + fi + echo "" IMPORT_ERRORS=$((IMPORT_ERRORS + 1)) fi +rm -f "$IMPORT_ERROR" -if uv run python -c "import aden_tools" > /dev/null 2>&1; then +# Test aden_tools import with smart diagnostics +IMPORT_ERROR=$(mktemp) +if $PYTHON_CMD -c "import aden_tools" > /dev/null 2>"$IMPORT_ERROR"; then echo -e "${GREEN} ✓ aden_tools imports OK${NC}" else + IMPORT_ERROR_MSG=$(cat "$IMPORT_ERROR") echo -e "${RED} ✗ aden_tools import failed${NC}" + echo "" + + if echo "$IMPORT_ERROR_MSG" | grep -qi "no module"; then + echo -e "${YELLOW} Quick fix:${NC} Reinstall aden_tools package:" + echo -e " ${BLUE}cd $SCRIPT_DIR/tools && pip install -e .${NC}" + fi + echo "" IMPORT_ERRORS=$((IMPORT_ERRORS + 1)) fi +rm -f "$IMPORT_ERROR" -if uv run python -c "import litellm" > /dev/null 2>&1; then +# Test litellm import +if $PYTHON_CMD -c "import litellm" > /dev/null 2>&1; then echo -e "${GREEN} ✓ litellm imports OK${NC}" else echo -e "${YELLOW} ⚠ litellm import issues (may be OK)${NC}" fi -if uv run python -c "from framework.mcp import agent_builder_server" > /dev/null 2>&1; then +# Test MCP server module +if $PYTHON_CMD -c "from framework.mcp import agent_builder_server" > /dev/null 2>&1; then echo -e "${GREEN} ✓ MCP server module OK${NC}" else echo -e "${RED} ✗ MCP server module failed${NC}" @@ -262,423 +493,204 @@ fi if [ $IMPORT_ERRORS -gt 0 ]; then echo "" - echo -e "${RED}Error: $IMPORT_ERRORS import(s) failed. Please check the errors above.${NC}" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Package Import Errors${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " $IMPORT_ERRORS Python package(s) failed to import after installation" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Try reinstalling in a clean virtual environment:" + echo "" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./quickstart.sh${NC}" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " Package conflicts or incomplete installations can prevent imports" + echo " Using a fresh virtual environment often resolves these issues" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " Check the error messages above for specific package issues" + echo " Try installing packages individually to identify the problem" + echo "" exit 1 fi echo "" # ============================================================ -# Step 4: Verify Claude Code Skills +# Step 4: Install Claude Code Skills # ============================================================ -echo -e "${BLUE}Step 4: Verifying Claude Code skills...${NC}" +echo -e "${BLUE}Step 4: Installing Claude Code skills...${NC}" echo "" -# Provider configuration - use associative arrays (Bash 4+) or indexed arrays (Bash 3.2) -if [ "$USE_ASSOC_ARRAYS" = true ]; then - # Bash 4+ - use associative arrays (cleaner and more efficient) - declare -A PROVIDER_NAMES=( - ["ANTHROPIC_API_KEY"]="Anthropic (Claude)" - ["OPENAI_API_KEY"]="OpenAI (GPT)" - ["GEMINI_API_KEY"]="Google Gemini" - ["GOOGLE_API_KEY"]="Google AI" - ["GROQ_API_KEY"]="Groq" - ["CEREBRAS_API_KEY"]="Cerebras" - ["MISTRAL_API_KEY"]="Mistral" - ["TOGETHER_API_KEY"]="Together AI" - ["DEEPSEEK_API_KEY"]="DeepSeek" - ) - - declare -A PROVIDER_IDS=( - ["ANTHROPIC_API_KEY"]="anthropic" - ["OPENAI_API_KEY"]="openai" - ["GEMINI_API_KEY"]="gemini" - ["GOOGLE_API_KEY"]="google" - ["GROQ_API_KEY"]="groq" - ["CEREBRAS_API_KEY"]="cerebras" - ["MISTRAL_API_KEY"]="mistral" - ["TOGETHER_API_KEY"]="together" - ["DEEPSEEK_API_KEY"]="deepseek" - ) - - declare -A DEFAULT_MODELS=( - ["anthropic"]="claude-sonnet-4-5-20250929" - ["openai"]="gpt-4o" - ["gemini"]="gemini-3.0-flash-preview" - ["groq"]="moonshotai/kimi-k2-instruct-0905" - ["cerebras"]="zai-glm-4.7" - ["mistral"]="mistral-large-latest" - ["together_ai"]="meta-llama/Llama-3.3-70B-Instruct-Turbo" - ["deepseek"]="deepseek-chat" - ) - - # Helper functions for Bash 4+ - get_provider_name() { - echo "${PROVIDER_NAMES[$1]}" - } - - get_provider_id() { - echo "${PROVIDER_IDS[$1]}" - } - - get_default_model() { - echo "${DEFAULT_MODELS[$1]}" - } -else - # Bash 3.2 - use parallel indexed arrays - PROVIDER_ENV_VARS=(ANTHROPIC_API_KEY OPENAI_API_KEY GEMINI_API_KEY GOOGLE_API_KEY GROQ_API_KEY CEREBRAS_API_KEY MISTRAL_API_KEY TOGETHER_API_KEY DEEPSEEK_API_KEY) - PROVIDER_DISPLAY_NAMES=("Anthropic (Claude)" "OpenAI (GPT)" "Google Gemini" "Google AI" "Groq" "Cerebras" "Mistral" "Together AI" "DeepSeek") - PROVIDER_ID_LIST=(anthropic openai gemini google groq cerebras mistral together deepseek) - - # Default models by provider id (parallel arrays) - MODEL_PROVIDER_IDS=(anthropic openai gemini groq cerebras mistral together_ai deepseek) - MODEL_DEFAULTS=("claude-sonnet-4-5-20250929" "gpt-4o" "gemini-3.0-flash-preview" "moonshotai/kimi-k2-instruct-0905" "zai-glm-4.7" "mistral-large-latest" "meta-llama/Llama-3.3-70B-Instruct-Turbo" "deepseek-chat") - - # Helper: get provider display name for an env var - get_provider_name() { - local env_var="$1" - local i=0 - while [ $i -lt ${#PROVIDER_ENV_VARS[@]} ]; do - if [ "${PROVIDER_ENV_VARS[$i]}" = "$env_var" ]; then - echo "${PROVIDER_DISPLAY_NAMES[$i]}" - return - fi - i=$((i + 1)) - done - } - - # Helper: get provider id for an env var - get_provider_id() { - local env_var="$1" - local i=0 - while [ $i -lt ${#PROVIDER_ENV_VARS[@]} ]; do - if [ "${PROVIDER_ENV_VARS[$i]}" = "$env_var" ]; then - echo "${PROVIDER_ID_LIST[$i]}" - return - fi - i=$((i + 1)) - done - } - - # Helper: get default model for a provider id - get_default_model() { - local provider_id="$1" - local i=0 - while [ $i -lt ${#MODEL_PROVIDER_IDS[@]} ]; do - if [ "${MODEL_PROVIDER_IDS[$i]}" = "$provider_id" ]; then - echo "${MODEL_DEFAULTS[$i]}" - return - fi - i=$((i + 1)) - done - } -fi - -# Configuration directory -HIVE_CONFIG_DIR="$HOME/.hive" -HIVE_CONFIG_FILE="$HIVE_CONFIG_DIR/configuration.json" - -# Function to save configuration -save_configuration() { - local provider_id="$1" - local env_var="$2" - local model - model="$(get_default_model "$provider_id")" - - mkdir -p "$HIVE_CONFIG_DIR" - - $PYTHON_CMD -c " -import json -config = { - 'llm': { - 'provider': '$provider_id', - 'model': '$model', - 'api_key_env_var': '$env_var' - }, - 'created_at': '$(date -u +"%Y-%m-%dT%H:%M:%S+00:00")' -} -with open('$HIVE_CONFIG_FILE', 'w') as f: - json.dump(config, f, indent=2) -print(json.dumps(config, indent=2)) -" 2>/dev/null -} - -# Check for .env files (temporarily disable set -e for robustness on Bash 3.2) -set +e -if [ -f "$SCRIPT_DIR/.env" ]; then - set -a - source "$SCRIPT_DIR/.env" 2>/dev/null - set +a -fi - -if [ -f "$HOME/.env" ]; then - set -a - source "$HOME/.env" 2>/dev/null - set +a -fi -set -e - -# Find all available API keys -FOUND_PROVIDERS=() # Display names for UI -FOUND_ENV_VARS=() # Corresponding env var names -SELECTED_PROVIDER_ID="" # Will hold the chosen provider ID -SELECTED_ENV_VAR="" # Will hold the chosen env var - -if [ "$USE_ASSOC_ARRAYS" = true ]; then - # Bash 4+ - iterate over associative array keys - for env_var in "${!PROVIDER_NAMES[@]}"; do - value="${!env_var}" - if [ -n "$value" ]; then - FOUND_PROVIDERS+=("$(get_provider_name "$env_var")") - FOUND_ENV_VARS+=("$env_var") - fi - done -else - # Bash 3.2 - iterate over indexed array - for env_var in "${PROVIDER_ENV_VARS[@]}"; do - value="${!env_var}" - if [ -n "$value" ]; then - FOUND_PROVIDERS+=("$(get_provider_name "$env_var")") - FOUND_ENV_VARS+=("$env_var") - fi - done -fi - -if [ ${#FOUND_PROVIDERS[@]} -gt 0 ]; then - echo "Found API keys:" +# Check if .claude/skills exists in this repo +if [ ! -d "$SCRIPT_DIR/.claude/skills" ]; then echo "" - for provider in "${FOUND_PROVIDERS[@]}"; do - echo -e " ${GREEN}⬢${NC} $provider" - done + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Missing Skills Directory${NC}" + echo -e "${RED}========================================${NC}" echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Skills directory not found at: $SCRIPT_DIR/.claude/skills" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " The repository may be incomplete. Try:" + echo "" + echo " 1. Re-clone the repository:" + echo -e " ${BLUE}git clone ${NC}" + echo -e " ${BLUE}cd ${NC}" + echo -e " ${BLUE}./quickstart.sh${NC}" + echo "" + echo " 2. Or pull latest changes:" + echo -e " ${BLUE}git pull origin main${NC}" + echo -e " ${BLUE}./quickstart.sh${NC}" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " The .claude/skills directory contains Claude Code skill definitions" + echo " If it's missing, the repository clone may have failed or be outdated" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " Verify you're in the correct directory: $SCRIPT_DIR" + echo " You can skip skills installation by using ./scripts/setup-python.sh instead" + echo "" + exit 1 +fi - if [ ${#FOUND_PROVIDERS[@]} -eq 1 ]; then - # Only one provider found, use it automatically - if prompt_yes_no "Use this key?"; then - SELECTED_ENV_VAR="${FOUND_ENV_VARS[0]}" - SELECTED_PROVIDER_ID="$(get_provider_id "$SELECTED_ENV_VAR")" - - echo "" - echo -e "${GREEN}⬢${NC} Using ${FOUND_PROVIDERS[0]}" - fi - else - # Multiple providers found, let user pick one - echo -e "${BOLD}Select your default LLM provider:${NC}" - echo "" - - # Build choice menu from found providers - i=1 - for provider in "${FOUND_PROVIDERS[@]}"; do - echo -e " ${CYAN}$i)${NC} $provider" - i=$((i + 1)) - done - echo "" - - while true; do - read -r -p "Enter choice (1-${#FOUND_PROVIDERS[@]}): " choice - if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#FOUND_PROVIDERS[@]}" ]; then - idx=$((choice - 1)) - SELECTED_ENV_VAR="${FOUND_ENV_VARS[$idx]}" - SELECTED_PROVIDER_ID="$(get_provider_id "$SELECTED_ENV_VAR")" - - echo "" - echo -e "${GREEN}⬢${NC} Selected: ${FOUND_PROVIDERS[$idx]}" - break - fi - echo -e "${RED}Invalid choice. Please enter 1-${#FOUND_PROVIDERS[@]}${NC}" - done - fi +# Create Claude skills directory if it doesn't exist +if [ ! -d "$CLAUDE_SKILLS_DIR" ]; then + echo " Creating Claude skills directory: $CLAUDE_SKILLS_DIR" + mkdir -p "$CLAUDE_SKILLS_DIR" fi -if [ -z "$SELECTED_PROVIDER_ID" ]; then - echo "No API keys found. Let's configure one." - echo "" - - prompt_choice "Select your LLM provider:" \ - "Anthropic (Claude) - Recommended" \ - "OpenAI (GPT)" \ - "Google Gemini - Free tier available" \ - "Groq - Fast, free tier" \ - "Cerebras - Fast, free tier" \ - "Skip for now" - choice=$PROMPT_CHOICE - - case $choice in - 0) - SELECTED_ENV_VAR="ANTHROPIC_API_KEY" - SELECTED_PROVIDER_ID="anthropic" - PROVIDER_NAME="Anthropic" - SIGNUP_URL="https://console.anthropic.com/settings/keys" - ;; - 1) - SELECTED_ENV_VAR="OPENAI_API_KEY" - SELECTED_PROVIDER_ID="openai" - PROVIDER_NAME="OpenAI" - SIGNUP_URL="https://platform.openai.com/api-keys" - ;; - 2) - SELECTED_ENV_VAR="GEMINI_API_KEY" - SELECTED_PROVIDER_ID="gemini" - PROVIDER_NAME="Google Gemini" - SIGNUP_URL="https://aistudio.google.com/apikey" - ;; - 3) - SELECTED_ENV_VAR="GROQ_API_KEY" - SELECTED_PROVIDER_ID="groq" - PROVIDER_NAME="Groq" - SIGNUP_URL="https://console.groq.com/keys" - ;; - 4) - SELECTED_ENV_VAR="CEREBRAS_API_KEY" - SELECTED_PROVIDER_ID="cerebras" - PROVIDER_NAME="Cerebras" - SIGNUP_URL="https://cloud.cerebras.ai/" - ;; - 5) - echo "" - echo -e "${YELLOW}Skipped.${NC} An LLM API key is required to test and use worker agents." - echo -e "Add your API key later by running:" - echo "" - echo -e " ${CYAN}echo 'ANTHROPIC_API_KEY=your-key' >> .env${NC}" - echo "" - SELECTED_ENV_VAR="" - SELECTED_PROVIDER_ID="" - ;; - esac +# Function to install a skill +install_skill() { + local skill_name=$1 + local source_dir="$SCRIPT_DIR/.claude/skills/$skill_name" + local target_dir="$CLAUDE_SKILLS_DIR/$skill_name" - if [ -n "$SELECTED_ENV_VAR" ] && [ -z "${!SELECTED_ENV_VAR}" ]; then - echo "" - echo -e "Get your API key from: ${CYAN}$SIGNUP_URL${NC}" - echo "" - read -r -p "Paste your $PROVIDER_NAME API key (or press Enter to skip): " API_KEY + if [ ! -d "$source_dir" ]; then + echo -e "${RED} ✗ Skill not found: $skill_name${NC}" + return 1 + fi - if [ -n "$API_KEY" ]; then - # Save to .env - echo "" >> "$SCRIPT_DIR/.env" - echo "$SELECTED_ENV_VAR=$API_KEY" >> "$SCRIPT_DIR/.env" - export "$SELECTED_ENV_VAR=$API_KEY" - echo "" - echo -e "${GREEN}⬢${NC} API key saved to .env" - else - echo "" - echo -e "${YELLOW}Skipped.${NC} Add your API key to .env when ready." - SELECTED_ENV_VAR="" - SELECTED_PROVIDER_ID="" - fi + # Check if skill already exists + if [ -d "$target_dir" ]; then + rm -rf "$target_dir" fi -fi -# Save configuration if a provider was selected -if [ -n "$SELECTED_PROVIDER_ID" ]; then - echo "" - echo -n " Saving configuration... " - save_configuration "$SELECTED_PROVIDER_ID" "$SELECTED_ENV_VAR" > /dev/null - echo -e "${GREEN}⬢${NC}" - echo -e " ${DIM}~/.hive/configuration.json${NC}" -fi + # Copy the skill + cp -r "$source_dir" "$target_dir" + echo -e "${GREEN} ✓ Installed: $skill_name${NC}" +} + +# Install all 5 agent-related skills +install_skill "building-agents-core" +install_skill "building-agents-construction" +install_skill "building-agents-patterns" +install_skill "testing-agent" +install_skill "agent-workflow" echo "" # ============================================================ -# Step 4: Verify Setup +# Step 5: Verify MCP Configuration # ============================================================ -echo -e "${YELLOW}⬢${NC} ${BLUE}${BOLD}Step 4: Verifying installation...${NC}" +echo -e "${BLUE}Step 5: Verifying MCP configuration...${NC}" echo "" -ERRORS=0 - -# Test imports -echo -n " ⬡ framework... " -if uv run python -c "import framework" > /dev/null 2>&1; then - echo -e "${GREEN}ok${NC}" -else - echo -e "${RED}failed${NC}" - ERRORS=$((ERRORS + 1)) -fi - -echo -n " ⬡ aden_tools... " -if uv run python -c "import aden_tools" > /dev/null 2>&1; then - echo -e "${GREEN}ok${NC}" -else - echo -e "${RED}failed${NC}" - ERRORS=$((ERRORS + 1)) -fi - -echo -n " ⬡ litellm... " -if uv run python -c "import litellm" > /dev/null 2>&1; then - echo -e "${GREEN}ok${NC}" -else - echo -e "${YELLOW}--${NC}" -fi - -echo -n " ⬡ MCP config... " if [ -f "$SCRIPT_DIR/.mcp.json" ]; then - echo -e "${GREEN}ok${NC}" -else - echo -e "${YELLOW}--${NC}" -fi - -echo -n " ⬡ skills... " -if [ -d "$SCRIPT_DIR/.claude/skills" ]; then - SKILL_COUNT=$(ls -1d "$SCRIPT_DIR/.claude/skills"/*/ 2>/dev/null | wc -l) - echo -e "${GREEN}${SKILL_COUNT} found${NC}" + echo -e "${GREEN} ✓ .mcp.json found at project root${NC}" + echo "" + echo " MCP servers configured:" + $PYTHON_CMD -c " +import json +with open('$SCRIPT_DIR/.mcp.json') as f: + config = json.load(f) +for name in config.get('mcpServers', {}): + print(f' - {name}') +" 2>/dev/null || echo " (could not parse config)" else - echo -e "${YELLOW}--${NC}" + echo -e "${YELLOW} ⚠ No .mcp.json found at project root${NC}" + echo " Claude Code will not have access to MCP tools" fi echo "" -if [ $ERRORS -gt 0 ]; then - echo -e "${RED}Setup failed with $ERRORS error(s).${NC}" - echo "Please check the errors above and try again." - exit 1 -fi - # ============================================================ -# Success! +# Step 6: Check API Key # ============================================================ -clear -echo "" -echo -e "${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}" -echo "" -echo -e "${GREEN}${BOLD} ADEN HIVE — READY${NC}" -echo "" -echo -e "${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}${DIM}⬡${NC}${GREEN}⬢${NC}" -echo "" -echo -e "Your environment is configured for building AI agents." +echo -e "${BLUE}Step 6: Checking API key...${NC}" echo "" -# Show configured provider -if [ -n "$SELECTED_PROVIDER_ID" ]; then - SELECTED_MODEL="$(get_default_model "$SELECTED_PROVIDER_ID")" - echo -e "${BOLD}Default LLM:${NC}" - echo -e " ${CYAN}$SELECTED_PROVIDER_ID${NC} → ${DIM}$SELECTED_MODEL${NC}" +# Check using CredentialManager (preferred) +API_KEY_AVAILABLE=$($PYTHON_CMD -c " +from aden_tools.credentials import CredentialManager +creds = CredentialManager() +print('yes' if creds.is_available('anthropic') else 'no') +" 2>/dev/null || echo "no") + +if [ "$API_KEY_AVAILABLE" = "yes" ]; then + echo -e "${GREEN} ✓ ANTHROPIC_API_KEY is available${NC}" +elif [ -n "$ANTHROPIC_API_KEY" ]; then + echo -e "${GREEN} ✓ ANTHROPIC_API_KEY is set in environment${NC}" +else + echo -e "${YELLOW} ⚠ ANTHROPIC_API_KEY not found${NC}" + echo "" + echo " For real agent testing, you'll need to set your API key:" + echo " ${BLUE}export ANTHROPIC_API_KEY='your-key-here'${NC}" echo "" + echo " Or add it to your .env file or credential manager." fi -echo -e "${BOLD}Quick Start:${NC}" -echo "" -echo -e " 1. Open Claude Code in this directory:" -echo -e " ${CYAN}claude${NC}" -echo "" -echo -e " 2. Build a new agent:" -echo -e " ${CYAN}/agent-workflow${NC}" -echo "" -echo -e " 3. Test an existing agent:" -echo -e " ${CYAN}/testing-agent${NC}" echo "" -echo -e "${BOLD}Skills:${NC}" -if [ -d "$SCRIPT_DIR/.claude/skills" ]; then - for skill_dir in "$SCRIPT_DIR/.claude/skills"/*/; do - skill_name=$(basename "$skill_dir") - echo -e " ⬡ ${CYAN}/$skill_name${NC}" - done -fi -echo "" -echo -e "${BOLD}Examples:${NC} ${CYAN}exports/${NC}" -echo "" -echo -e "${DIM}Run ./quickstart.sh again to reconfigure.${NC}" + +# ============================================================ +# Step 7: Success Summary +# ============================================================ + +echo "==================================================" +echo -e "${GREEN} ✓ Setup Complete!${NC}" +echo "==================================================" +echo "" +echo "Installed Python packages:" +echo " • framework (core agent runtime)" +echo " • aden_tools (tools and MCP servers)" +echo " • MCP dependencies (mcp, fastmcp)" +echo "" +echo "Installed Claude Code skills:" +echo " • /building-agents-core - Fundamental concepts" +echo " • /building-agents-construction - Step-by-step build guide" +echo " • /building-agents-patterns - Best practices" +echo " • /testing-agent - Test and validate agents" +echo " • /agent-workflow - Complete workflow" +echo "" +echo "Usage:" +echo " 1. Open Claude Code in this directory:" +echo " ${BLUE}cd $SCRIPT_DIR && claude${NC}" +echo "" +echo " 2. Build a new agent:" +echo " ${BLUE}/building-agents-construction${NC}" +echo "" +echo " 3. Test an existing agent:" +echo " ${BLUE}/testing-agent${NC}" +echo "" +echo " 4. Or use the complete workflow:" +echo " ${BLUE}/agent-workflow${NC}" +echo "" +echo "MCP Tools available (when running from this directory):" +echo " • mcp__agent-builder__create_session" +echo " • mcp__agent-builder__set_goal" +echo " • mcp__agent-builder__add_node" +echo " • mcp__agent-builder__run_tests" +echo " • ... and more" +echo "" +echo "Documentation:" +echo " • Skills: $CLAUDE_SKILLS_DIR/" +echo " • Examples: $SCRIPT_DIR/exports/" echo "" diff --git a/scripts/check-environment.sh b/scripts/check-environment.sh new file mode 100644 index 0000000000..10b298dcbd --- /dev/null +++ b/scripts/check-environment.sh @@ -0,0 +1,331 @@ +#!/bin/bash +# +# check-environment.sh - Environment Validation Tool +# +# This script validates the development environment before running setup. +# Shows a checklist of requirements with pass/fail status to catch issues early. +# + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Get the directory where this script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" + +# Track validation results +PASSED=0 +FAILED=0 +WARNINGS=0 + +# Function to print check result +check_pass() { + echo -e "${GREEN}✓${NC} $1" + ((PASSED++)) +} + +check_fail() { + echo -e "${RED}✗${NC} $1" + ((FAILED++)) +} + +check_warn() { + echo -e "${YELLOW}⚠${NC} $1" + ((WARNINGS++)) +} + +# Function to print section header +section_header() { + echo "" + echo -e "${CYAN}$1${NC}" + echo "----------------------------------------" +} + +# Function to print fix suggestion +print_fix() { + echo -e " ${BLUE}→${NC} $1" +} + +echo "" +echo "==================================================" +echo " Environment Validation Checklist" +echo "==================================================" +echo "" +echo "Checking requirements before setup..." +echo "" + +# ============================================================ +# 1. Python Installation Check +# ============================================================ +section_header "1. Python Installation" + +if ! command -v python &> /dev/null && ! command -v python3 &> /dev/null; then + check_fail "Python not found" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + if [[ "$OSTYPE" == "darwin"* ]]; then + print_fix "macOS (Homebrew): brew install python@3.11" + print_fix "macOS (Official): https://www.python.org/downloads/" + elif [[ "$OSTYPE" == "linux"* ]]; then + print_fix "Ubuntu/Debian: sudo apt update && sudo apt install python3.11" + print_fix "Fedora/RHEL: sudo dnf install python3.11" + else + print_fix "Download from: https://www.python.org/downloads/" + fi +else + # Use python3 if available, otherwise python + PYTHON_CMD="python3" + if ! command -v python3 &> /dev/null; then + PYTHON_CMD="python" + fi + + PYTHON_VERSION=$($PYTHON_CMD -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null) + PYTHON_MAJOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.major)' 2>/dev/null) + PYTHON_MINOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.minor)' 2>/dev/null) + + if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 11 ]); then + check_fail "Python version too old (found $PYTHON_VERSION, requires 3.11+)" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + if [[ "$OSTYPE" == "darwin"* ]]; then + print_fix "macOS (Homebrew): brew install python@3.11" + print_fix "macOS (pyenv): brew install pyenv && pyenv install 3.11.0 && pyenv global 3.11.0" + elif [[ "$OSTYPE" == "linux"* ]]; then + print_fix "Ubuntu/Debian: sudo apt update && sudo apt install python3.11" + print_fix "Using pyenv: curl https://pyenv.run | bash && pyenv install 3.11.0 && pyenv global 3.11.0" + else + print_fix "Download from: https://www.python.org/downloads/" + fi + else + check_pass "Python $PYTHON_VERSION detected (requires 3.11+)" + fi +fi + +# ============================================================ +# 2. pip Installation Check +# ============================================================ +section_header "2. pip Package Manager" + +if [ -z "$PYTHON_CMD" ]; then + check_fail "Cannot check pip (Python not found)" +else + if ! $PYTHON_CMD -m pip --version &> /dev/null; then + check_fail "pip not available" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + if [[ "$OSTYPE" == "darwin"* ]]; then + print_fix "python3 -m ensurepip --upgrade" + print_fix "Or reinstall Python: brew reinstall python@3.11" + elif [[ "$OSTYPE" == "linux"* ]]; then + print_fix "Ubuntu/Debian: sudo apt install python3-pip" + print_fix "Fedora/RHEL: sudo dnf install python3-pip" + else + print_fix "python3 -m ensurepip --upgrade" + fi + else + PIP_VERSION=$($PYTHON_CMD -m pip --version | cut -d' ' -f2) + check_pass "pip $PIP_VERSION detected" + fi +fi + +# ============================================================ +# 3. Virtual Environment Check +# ============================================================ +section_header "3. Virtual Environment" + +if [ -z "$VIRTUAL_ENV" ]; then + check_warn "Not running in a virtual environment" + echo "" + echo -e "${YELLOW}Recommendation:${NC}" + print_fix "Create virtual environment: python3 -m venv .venv" + print_fix "Activate it: source .venv/bin/activate" + print_fix "Then run: ./scripts/setup-python.sh" +else + check_pass "Running in virtual environment: $(basename "$VIRTUAL_ENV")" +fi + +# ============================================================ +# 4. Project Structure Check +# ============================================================ +section_header "4. Project Structure" + +if [ ! -d "$PROJECT_ROOT/core" ]; then + check_fail "core/ directory not found" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + print_fix "Ensure you're in the project root directory" + print_fix "Re-clone repository if needed: git clone " +else + check_pass "core/ directory exists" +fi + +if [ ! -d "$PROJECT_ROOT/tools" ]; then + check_fail "tools/ directory not found" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + print_fix "Ensure you're in the project root directory" + print_fix "Re-clone repository if needed: git clone " +else + check_pass "tools/ directory exists" +fi + +if [ ! -f "$PROJECT_ROOT/core/pyproject.toml" ]; then + check_fail "core/pyproject.toml not found" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + print_fix "Repository may be incomplete. Try: git pull origin main" +else + check_pass "core/pyproject.toml exists" +fi + +if [ ! -f "$PROJECT_ROOT/tools/pyproject.toml" ]; then + check_fail "tools/pyproject.toml not found" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + print_fix "Repository may be incomplete. Try: git pull origin main" +else + check_pass "tools/pyproject.toml exists" +fi + +if [ ! -d "$PROJECT_ROOT/exports" ]; then + check_warn "exports/ directory not found (will be created during setup)" +else + check_pass "exports/ directory exists" +fi + +# ============================================================ +# 5. Package Installation Status Check +# ============================================================ +section_header "5. Package Installation Status" + +if [ -n "$PYTHON_CMD" ] && $PYTHON_CMD -m pip --version &> /dev/null; then + # Check framework package + if $PYTHON_CMD -c "import framework" &> /dev/null 2>&1; then + FRAMEWORK_VERSION=$($PYTHON_CMD -c "import framework; print(getattr(framework, '__version__', 'installed'))" 2>/dev/null || echo "installed") + check_pass "framework package installed" + else + check_warn "framework package not installed (will be installed during setup)" + fi + + # Check aden_tools package + if $PYTHON_CMD -c "import aden_tools" &> /dev/null 2>&1; then + check_pass "aden_tools package installed" + else + check_warn "aden_tools package not installed (will be installed during setup)" + fi + + # Check openai version compatibility + if $PYTHON_CMD -c "import openai" &> /dev/null 2>&1; then + OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null) + if [[ "$OPENAI_VERSION" =~ ^0\. ]]; then + check_fail "openai version $OPENAI_VERSION is incompatible (requires >=1.0.0)" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + print_fix "pip install --upgrade \"openai>=1.0.0\"" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " Old openai versions (0.x) are incompatible with litellm (Issue #450)" + else + check_pass "openai $OPENAI_VERSION is compatible" + fi + else + check_warn "openai package not installed (will be installed during setup)" + fi +else + check_warn "Cannot check package status (pip not available)" +fi + +# ============================================================ +# 6. Common Issue Detection +# ============================================================ +section_header "6. Common Issue Detection" + +if [ -n "$PYTHON_CMD" ] && $PYTHON_CMD -m pip --version &> /dev/null; then + # Check for PEP 668 externally-managed-environment + PIP_CHECK_OUTPUT=$(mktemp) + if $PYTHON_CMD -m pip install --dry-run pip &> "$PIP_CHECK_OUTPUT" 2>&1; then + rm -f "$PIP_CHECK_OUTPUT" + check_pass "No PEP 668 restrictions detected" + else + PIP_CHECK_ERROR=$(cat "$PIP_CHECK_OUTPUT") + rm -f "$PIP_CHECK_OUTPUT" + + if echo "$PIP_CHECK_ERROR" | grep -q "externally-managed-environment\|This environment is externally managed"; then + check_fail "PEP 668 externally-managed-environment detected" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Your system Python is protected from modifications" + echo "" + echo -e "${YELLOW}Quick fix (Recommended):${NC}" + print_fix "Create virtual environment: python3 -m venv .venv" + print_fix "Activate it: source .venv/bin/activate" + print_fix "Then run: ./scripts/setup-python.sh" + echo "" + echo -e "${YELLOW}Alternative (Not recommended):${NC}" + print_fix "Use --break-system-packages flag (may cause conflicts)" + else + check_pass "No PEP 668 restrictions detected" + fi + fi + + # Check write permissions + TEMP_TEST_DIR=$(mktemp -d 2>/dev/null || echo "/tmp") + if [ -w "$TEMP_TEST_DIR" ]; then + check_pass "Write permissions OK" + else + check_fail "Write permissions issue detected" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + print_fix "Use a virtual environment to avoid permission issues" + print_fix "python3 -m venv .venv && source .venv/bin/activate" + fi +else + check_warn "Cannot check common issues (pip not available)" +fi + +# ============================================================ +# Summary +# ============================================================ +echo "" +echo "==================================================" +echo " Validation Summary" +echo "==================================================" +echo "" +echo -e "${GREEN}Passed:${NC} $PASSED" +echo -e "${YELLOW}Warnings:${NC} $WARNINGS" +echo -e "${RED}Failed:${NC} $FAILED" +echo "" + +if [ $FAILED -eq 0 ] && [ $WARNINGS -eq 0 ]; then + echo -e "${GREEN}✓ All checks passed!${NC}" + echo "" + echo "You're ready to run setup:" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + exit 0 +elif [ $FAILED -eq 0 ]; then + echo -e "${YELLOW}⚠ Some warnings detected, but setup should proceed${NC}" + echo "" + echo "You can run setup, but consider addressing warnings:" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + exit 0 +else + echo -e "${RED}✗ Some checks failed. Please fix the issues above before running setup.${NC}" + echo "" + echo "After fixing issues, run:" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo "For help, see:" + echo " • ENVIRONMENT_SETUP.md" + echo " • DEVELOPER.md" + echo "" + exit 1 +fi diff --git a/scripts/setup-python.sh b/scripts/setup-python.sh index 11e2c782ec..7c49e62739 100755 --- a/scripts/setup-python.sh +++ b/scripts/setup-python.sh @@ -2,11 +2,8 @@ # # setup-python.sh - Python Environment Setup for Aden Agent Framework # -# DEPRECATED: Use ./quickstart.sh instead. It does everything this script -# does plus verifies MCP configuration, Claude Code skills, and API keys. -# -# This script is kept for CI/headless environments where the extra -# verification steps in quickstart.sh are not needed. +# This script sets up the Python environment with all required packages +# for building and running goal-driven agents. # set -e @@ -22,91 +19,242 @@ NC='\033[0m' # No Color SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" -# Python Version -REQUIRED_PYTHON_VERSION="3.11" - -# Python version split into Major and Minor -IFS='.' read -r PYTHON_MAJOR_VERSION PYTHON_MINOR_VERSION <<< "$REQUIRED_PYTHON_VERSION" - -# Available python interpreter (follows sequence) -POSSIBLE_PYTHONS=("python3" "python" "py") - -# Default python interpreter (initialized) -PYTHON_CMD=() - - echo "" echo "==================================================" echo " Aden Agent Framework - Python Setup" echo "==================================================" echo "" -echo -e "${YELLOW}NOTE: Consider using ./quickstart.sh instead for a complete setup.${NC}" -echo "" - -# Available Python interpreter -for cmd in "${POSSIBLE_PYTHONS[@]}"; do - # Check for python interpreter - if command -v "$cmd" >/dev/null 2>&1; then - # Specific check for Windows 'py' launcher - if [ "$cmd" = "py" ]; then - CURRENT_CMD=(py -3) - else - CURRENT_CMD=("$cmd") - fi +# Detect if running in virtual environment +if [ -z "$VIRTUAL_ENV" ]; then + echo -e "${YELLOW}Note:${NC} Not running in a virtual environment" + echo " Recommended: Use a virtual environment to avoid conflicts" + echo -e " Create one with: ${BLUE}python3 -m venv .venv && source .venv/bin/activate${NC}" + echo "" +else + echo -e "${GREEN}✓${NC} Running in virtual environment: $(basename "$VIRTUAL_ENV")" + echo "" +fi - # Check Python version - if "${CURRENT_CMD[@]}" -c "import sys; sys.exit(0 if sys.version_info >= ($PYTHON_MAJOR_VERSION, $PYTHON_MINOR_VERSION) else 1)" >/dev/null 2>&1; then - echo -e "${GREEN}✓${NC} interpreter detected: ${CURRENT_CMD[@]}" - # Check for pip - if "${CURRENT_CMD[@]}" -m pip --version >/dev/null 2>&1; then - PYTHON_CMD=("${CURRENT_CMD[@]}") - echo -e "${GREEN}✓${NC} pip detected" - echo "" - break - else - echo -e "${RED}✗${NC} pip not found" - echo "" - fi - else - echo -e "${RED}✗${NC} ${CURRENT_CMD[@]} not found" - echo "" - fi +# Check for Python +if ! command -v python &> /dev/null && ! command -v python3 &> /dev/null; then + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Python Not Found${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Python is not installed on your system" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Install Python 3.11+ using one of these methods:" + echo "" + if [[ "$OSTYPE" == "darwin"* ]]; then + echo " macOS (Homebrew):" + echo -e " ${BLUE}brew install python@3.11${NC}" + echo "" + echo " macOS (Official installer):" + echo -e " ${BLUE}https://www.python.org/downloads/${NC}" + elif [[ "$OSTYPE" == "linux"* ]]; then + echo " Ubuntu/Debian:" + echo -e " ${BLUE}sudo apt update && sudo apt install python3.11${NC}" + echo "" + echo " Fedora/RHEL:" + echo -e " ${BLUE}sudo dnf install python3.11${NC}" + else + echo " Download from:" + echo -e " ${BLUE}https://www.python.org/downloads/${NC}" fi -done + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " Documentation: https://www.python.org/downloads/" + echo "" + exit 1 +fi + +# Use python3 if available, otherwise python +PYTHON_CMD="python3" +if ! command -v python3 &> /dev/null; then + PYTHON_CMD="python" +fi -# Display error message if python not found -if [ "${#PYTHON_CMD[@]}" -eq 0 ]; then - echo -e "${RED}Error:${NC} No suitable Python interpreter found with pip installed." +# Check Python version +PYTHON_VERSION=$($PYTHON_CMD -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') +PYTHON_MAJOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.major)') +PYTHON_MINOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.minor)') + +echo -e "${BLUE}Detected Python:${NC} $PYTHON_VERSION" + +if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 11 ]); then + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Python Version Too Old${NC}" + echo -e "${RED}========================================${NC}" echo "" - echo "Requirements:" - echo " • Python $PYTHON_MAJOR_VERSION.$PYTHON_MINOR_VERSION+" - echo " • pip installed" + echo -e "${YELLOW}What happened:${NC}" + echo " Python 3.11+ is required, but you have Python $PYTHON_VERSION" echo "" - echo "Tried the following commands:" - echo " ${POSSIBLE_PYTHONS[*]}" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Upgrade Python using one of these methods:" + echo "" + if [[ "$OSTYPE" == "darwin"* ]]; then + echo " macOS (Homebrew):" + echo -e " ${BLUE}brew install python@3.11${NC}" + echo "" + echo " macOS (pyenv - recommended for managing multiple versions):" + echo -e " ${BLUE}brew install pyenv${NC}" + echo -e " ${BLUE}pyenv install 3.11.0${NC}" + echo -e " ${BLUE}pyenv global 3.11.0${NC}" + elif [[ "$OSTYPE" == "linux"* ]]; then + echo " Ubuntu/Debian:" + echo -e " ${BLUE}sudo apt update && sudo apt install python3.11${NC}" + echo "" + echo " Using pyenv (recommended for managing multiple versions):" + echo -e " ${BLUE}curl https://pyenv.run | bash${NC}" + echo -e " ${BLUE}pyenv install 3.11.0${NC}" + echo -e " ${BLUE}pyenv global 3.11.0${NC}" + else + echo " Download from:" + echo -e " ${BLUE}https://www.python.org/downloads/${NC}" + fi + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " This framework requires Python 3.11+ for compatibility with modern dependencies" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " See installation guide: https://www.python.org/downloads/" echo "" - echo "Please install Python from:" - echo " https://www.python.org/downloads/" exit 1 fi -# Display Python version -PYTHON_VERSION=$("${PYTHON_CMD[@]}" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') -echo -e "${BLUE}Detected Python:${NC} $PYTHON_VERSION" +if [ "$PYTHON_MINOR" -lt 11 ]; then + echo -e "${YELLOW}Warning: Python 3.11+ is recommended for best compatibility${NC}" + echo -e "${YELLOW}You have Python $PYTHON_VERSION which may work but is not officially supported${NC}" + echo "" +fi + echo -e "${GREEN}✓${NC} Python version check passed" echo "" -# Check for uv -if ! command -v uv &> /dev/null; then - echo -e "${RED}Error: uv is not installed${NC}" - echo "Please install uv from https://github.com/astral-sh/uv" +# Check for pip +if ! $PYTHON_CMD -m pip --version &> /dev/null; then + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: pip Not Found${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " pip (Python package installer) is not available for Python $PYTHON_VERSION" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + if [[ "$OSTYPE" == "darwin"* ]]; then + echo " macOS:" + echo -e " ${BLUE}python3 -m ensurepip --upgrade${NC}" + echo "" + echo " Or reinstall Python with Homebrew (includes pip):" + echo -e " ${BLUE}brew reinstall python@3.11${NC}" + elif [[ "$OSTYPE" == "linux"* ]]; then + echo " Ubuntu/Debian:" + echo -e " ${BLUE}sudo apt install python3-pip${NC}" + echo "" + echo " Fedora/RHEL:" + echo -e " ${BLUE}sudo dnf install python3-pip${NC}" + else + echo " Run:" + echo -e " ${BLUE}python3 -m ensurepip --upgrade${NC}" + fi + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " pip should be included with Python 3.11+, but it may need to be enabled" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " See pip installation guide: https://pip.pypa.io/en/stable/installation/" + echo "" exit 1 fi -echo -e "${GREEN}✓${NC} uv detected" +echo -e "${GREEN}✓${NC} pip detected" echo "" +# Upgrade pip, setuptools, and wheel +echo "Upgrading pip, setuptools, and wheel..." +PIP_UPGRADE_OUTPUT=$(mktemp) +if ! $PYTHON_CMD -m pip install --upgrade pip setuptools wheel 2>"$PIP_UPGRADE_OUTPUT"; then + PIP_ERROR=$(cat "$PIP_UPGRADE_OUTPUT") + rm -f "$PIP_UPGRADE_OUTPUT" + + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Package Installation Error${NC}" + echo -e "${RED}========================================${NC}" + echo "" + + # Check for PEP 668 externally-managed-environment error + if echo "$PIP_ERROR" | grep -q "externally-managed-environment\|This environment is externally managed"; then + echo -e "${YELLOW}What happened:${NC}" + echo " Your system Python is protected from modifications (PEP 668)" + echo "" + echo -e "${YELLOW}Quick fix (Recommended):${NC}" + echo " Create a virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo -e "${YELLOW}Alternative (Not recommended):${NC}" + echo " Use --break-system-packages flag (may cause conflicts):" + echo -e " ${BLUE}pip install --break-system-packages --upgrade pip setuptools wheel${NC}" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " Modern Linux distributions prevent pip from modifying system Python packages" + echo " to avoid breaking system tools. Virtual environments are the recommended solution." + elif echo "$PIP_ERROR" | grep -q "Permission denied\|PermissionError"; then + echo -e "${YELLOW}What happened:${NC}" + echo " Permission denied while trying to upgrade pip" + echo "" + echo -e "${YELLOW}Quick fix (Recommended):${NC}" + echo " Use a virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo -e "${YELLOW}Alternative:${NC}" + echo " Install to user directory:" + echo -e " ${BLUE}pip install --user --upgrade pip setuptools wheel${NC}" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " You don't have write permissions to the Python installation directory" + else + echo -e "${YELLOW}What happened:${NC}" + echo " Failed to upgrade pip, setuptools, and wheel" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Try using a virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$PIP_ERROR" | head -n 10 + fi + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " See Python virtual environments guide: https://docs.python.org/3/tutorial/venv.html" + echo "" + exit 1 +fi +rm -f "$PIP_UPGRADE_OUTPUT" +echo -e "${GREEN}✓${NC} Core packages upgraded" +echo "" + +# Smart Detection: Check for exports directory +if [ ! -d "$PROJECT_ROOT/exports" ]; then + echo -e "${YELLOW}Note:${NC} exports/ directory not found" + echo " Creating exports/ directory for agent modules..." + mkdir -p "$PROJECT_ROOT/exports" + echo -e "${GREEN}✓${NC} Created exports/ directory" + echo "" +fi + # Install core framework package echo "==================================================" echo "Installing Core Framework Package" @@ -114,20 +262,10 @@ echo "==================================================" echo "" cd "$PROJECT_ROOT/core" -# Create venv if it doesn't exist -if [ ! -d ".venv" ]; then - echo "Creating virtual environment in core/.venv..." - uv venv - echo -e "${GREEN}✓${NC} Virtual environment created" -else - echo -e "${GREEN}✓${NC} Virtual environment already exists" -fi -echo "" - if [ -f "pyproject.toml" ]; then echo "Installing framework from core/ (editable mode)..." - CORE_PYTHON=".venv/bin/python" - if uv pip install --python "$CORE_PYTHON" -e .; then + $PYTHON_CMD -m pip install -e . > /dev/null 2>&1 + if [ $? -eq 0 ]; then echo -e "${GREEN}✓${NC} Framework package installed" else echo -e "${YELLOW}⚠${NC} Framework installation encountered issues (may be OK if already installed)" @@ -144,94 +282,141 @@ echo "==================================================" echo "" cd "$PROJECT_ROOT/tools" -# Create venv if it doesn't exist -if [ ! -d ".venv" ]; then - echo "Creating virtual environment in tools/.venv..." - uv venv - echo -e "${GREEN}✓${NC} Virtual environment created" -else - echo -e "${GREEN}✓${NC} Virtual environment already exists" -fi -echo "" - if [ -f "pyproject.toml" ]; then echo "Installing aden_tools from tools/ (editable mode)..." - TOOLS_PYTHON=".venv/bin/python" - if uv pip install --python "$TOOLS_PYTHON" -e .; then + $PYTHON_CMD -m pip install -e . > /dev/null 2>&1 + if [ $? -eq 0 ]; then echo -e "${GREEN}✓${NC} Tools package installed" else echo -e "${RED}✗${NC} Tools installation failed" exit 1 fi else - echo -e "${RED}Error: No pyproject.toml found in tools/${NC}" + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Missing Project Files${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Required file 'pyproject.toml' not found in tools/ directory" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " This usually means the repository is incomplete. Try:" + echo "" + echo " 1. Re-clone the repository:" + echo -e " ${BLUE}git clone ${NC}" + echo -e " ${BLUE}cd ${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo " 2. Or if you already cloned, pull latest changes:" + echo -e " ${BLUE}git pull origin main${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + echo "" + echo -e "${YELLOW}Why this happened:${NC}" + echo " The tools/ directory should contain pyproject.toml for package installation" + echo " If it's missing, the repository may be corrupted or incomplete" + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " Check if you're in the correct directory: $PROJECT_ROOT" + echo " Report this issue if the repository is freshly cloned" + echo "" exit 1 fi echo "" -# Install Playwright browser for web scraping +# Smart Detection: Fix openai version compatibility with litellm echo "==================================================" -echo "Installing Playwright Browser" +echo "Detecting and Fixing Package Compatibility" echo "==================================================" echo "" -if $PYTHON_CMD -c "import playwright" > /dev/null 2>&1; then - echo "Installing Chromium browser for web scraping..." - if $PYTHON_CMD -m playwright install chromium > /dev/null 2>&1; then - echo -e "${GREEN}✓${NC} Playwright Chromium installed" - else - echo -e "${YELLOW}⚠${NC} Playwright browser install failed (web_scrape tool may not work)" - echo " Run manually: python -m playwright install chromium" - fi -else - echo -e "${YELLOW}⚠${NC} Playwright not found, skipping browser install" -fi -echo "" - -# Fix openai version compatibility with litellm -echo "==================================================" -echo "Fixing Package Compatibility" -echo "==================================================" -echo "" - -TOOLS_PYTHON="$PROJECT_ROOT/tools/.venv/bin/python" - -# Check openai version in tools venv -OPENAI_VERSION=$($TOOLS_PYTHON -c "import openai; print(openai.__version__)" 2>/dev/null || echo "not_installed") +# Check openai version +OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null || echo "not_installed") if [ "$OPENAI_VERSION" = "not_installed" ]; then echo "Installing openai package..." - uv pip install --python "$TOOLS_PYTHON" "openai>=1.0.0" + INSTALL_OUTPUT=$(mktemp) + if ! $PYTHON_CMD -m pip install "openai>=1.0.0" > "$INSTALL_OUTPUT" 2>&1; then + INSTALL_ERROR=$(cat "$INSTALL_OUTPUT") + rm -f "$INSTALL_OUTPUT" + + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Dependency Installation Error${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Failed to install openai package" + echo "" + + # Smart detection of specific errors + if echo "$INSTALL_ERROR" | grep -qi "network\|connection\|timeout\|unreachable"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Network connection issue detected. Try:" + echo "" + echo " 1. Check your internet connection" + echo " 2. Try again with a different network" + echo " 3. Use a different PyPI mirror:" + echo -e " ${BLUE}pip install --index-url https://pypi.org/simple openai>=1.0.0${NC}" + elif echo "$INSTALL_ERROR" | grep -qi "conflict\|incompatible\|requires"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Dependency conflict detected. Try:" + echo -e " ${BLUE}pip install --upgrade openai>=1.0.0 --force-reinstall${NC}" + echo "" + echo -e "${YELLOW}Related issue:${NC}" + echo " See: https://github.com/BerriAI/litellm/issues (search for openai compatibility)" + else + echo -e "${YELLOW}Quick fix:${NC}" + echo " Try installing in a clean virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" + fi + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$INSTALL_ERROR" | head -n 15 + echo "" + exit 1 + fi + rm -f "$INSTALL_OUTPUT" echo -e "${GREEN}✓${NC} openai package installed" elif [[ "$OPENAI_VERSION" =~ ^0\. ]]; then - echo -e "${YELLOW}Found old openai version: $OPENAI_VERSION${NC}" + echo -e "${YELLOW}Detected Issue #450:${NC} Old openai version $OPENAI_VERSION (incompatible with litellm)" echo "Upgrading to openai 1.x+ for litellm compatibility..." - uv pip install --python "$TOOLS_PYTHON" --upgrade "openai>=1.0.0" - OPENAI_VERSION=$($TOOLS_PYTHON -c "import openai; print(openai.__version__)" 2>/dev/null) - echo -e "${GREEN}✓${NC} openai upgraded to $OPENAI_VERSION" + UPGRADE_OUTPUT=$(mktemp) + if ! $PYTHON_CMD -m pip install --upgrade "openai>=1.0.0" > "$UPGRADE_OUTPUT" 2>&1; then + UPGRADE_ERROR=$(cat "$UPGRADE_OUTPUT") + rm -f "$UPGRADE_OUTPUT" + + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Dependency Conflict (Issue #450)${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " Cannot upgrade openai package due to conflicts" + echo "" + echo -e "${YELLOW}Quick fix:${NC}" + echo " Force reinstall conflicting packages:" + echo -e " ${BLUE}pip uninstall -y openai litellm${NC}" + echo -e " ${BLUE}pip install 'openai>=1.0.0' litellm${NC}" + echo "" + echo -e "${YELLOW}Related issue:${NC}" + echo " GitHub: https://github.com/your-repo/issues/450" + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$UPGRADE_ERROR" | head -n 10 + echo "" + exit 1 + fi + rm -f "$UPGRADE_OUTPUT" + OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null) + echo -e "${GREEN}✓${NC} openai upgraded to $OPENAI_VERSION (Issue #450 resolved)" else echo -e "${GREEN}✓${NC} openai $OPENAI_VERSION is compatible" fi echo "" -# Ensure exports directory exists -echo "==================================================" -echo "Checking Directory Structure" -echo "==================================================" -echo "" - -if [ ! -d "$PROJECT_ROOT/exports" ]; then - echo "Creating exports directory..." - mkdir -p "$PROJECT_ROOT/exports" - echo "# Agent Exports" > "$PROJECT_ROOT/exports/README.md" - echo "" >> "$PROJECT_ROOT/exports/README.md" - echo "This directory is the default location for generated agent packages." >> "$PROJECT_ROOT/exports/README.md" - echo -e "${GREEN}✓${NC} Created exports directory" -else - echo -e "${GREEN}✓${NC} exports directory exists" -fi -echo "" - # Verify installations echo "==================================================" echo "Verifying Installation" @@ -240,36 +425,70 @@ echo "" cd "$PROJECT_ROOT" -# Test framework import using core venv -CORE_PYTHON="$PROJECT_ROOT/core/.venv/bin/python" -if [ -f "$CORE_PYTHON" ]; then - if $CORE_PYTHON -c "import framework; print('framework OK')" > /dev/null 2>&1; then - echo -e "${GREEN}✓${NC} framework package imports successfully" - else - echo -e "${RED}✗${NC} framework package import failed" - echo -e "${YELLOW} Note: This may be OK if you don't need the framework${NC}" - fi +# Test framework import +if $PYTHON_CMD -c "import framework; print('framework OK')" > /dev/null 2>&1; then + echo -e "${GREEN}✓${NC} framework package imports successfully" else - echo -e "${RED}✗${NC} core/.venv not found - venv creation may have failed${NC}" - exit 1 + echo -e "${RED}✗${NC} framework package import failed" + echo -e "${YELLOW} Note: This may be OK if you don't need the framework${NC}" fi -# Test aden_tools import using tools venv -TOOLS_PYTHON="$PROJECT_ROOT/tools/.venv/bin/python" -if [ -f "$TOOLS_PYTHON" ]; then - if $TOOLS_PYTHON -c "import aden_tools; print('aden_tools OK')" > /dev/null 2>&1; then - echo -e "${GREEN}✓${NC} aden_tools package imports successfully" +# Test aden_tools import with smart diagnostics +IMPORT_ERROR=$(mktemp) +if ! $PYTHON_CMD -c "import aden_tools; print('aden_tools OK')" > /dev/null 2>"$IMPORT_ERROR"; then + IMPORT_ERROR_MSG=$(cat "$IMPORT_ERROR") + rm -f "$IMPORT_ERROR" + + echo -e "${RED}✗${NC} aden_tools package import failed" + echo "" + echo -e "${RED}========================================${NC}" + echo -e "${RED}Setup Failed: Package Import Error${NC}" + echo -e "${RED}========================================${NC}" + echo "" + echo -e "${YELLOW}What happened:${NC}" + echo " aden_tools package installed but cannot be imported" + echo "" + + # Smart detection of common import errors + if echo "$IMPORT_ERROR_MSG" | grep -qi "no module\|modulenotfounderror"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Package may not be installed in the current Python environment" + echo " Try reinstalling:" + echo -e " ${BLUE}cd $PROJECT_ROOT/tools${NC}" + echo -e " ${BLUE}pip install -e . --force-reinstall${NC}" + elif echo "$IMPORT_ERROR_MSG" | grep -qi "syntax\|invalid syntax"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Python version mismatch detected" + echo " Verify you're using Python 3.11+:" + echo -e " ${BLUE}python --version${NC}" + elif echo "$IMPORT_ERROR_MSG" | grep -qi "circular\|cyclic"; then + echo -e "${YELLOW}Quick fix:${NC}" + echo " Circular import detected in package" + echo " This may be a bug. Please report:" + echo " GitHub Issues: https://github.com/your-repo/issues" else - echo -e "${RED}✗${NC} aden_tools package import failed" - exit 1 + echo -e "${YELLOW}Quick fix:${NC}" + echo " Try a clean reinstall in a virtual environment:" + echo -e " ${BLUE}python3 -m venv .venv${NC}" + echo -e " ${BLUE}source .venv/bin/activate${NC}" + echo -e " ${BLUE}./scripts/setup-python.sh${NC}" fi -else - echo -e "${RED}✗${NC} tools/.venv not found - venv creation may have failed${NC}" + + echo "" + echo -e "${YELLOW}Error details:${NC}" + echo "$IMPORT_ERROR_MSG" | head -n 10 + echo "" + echo -e "${YELLOW}Still stuck?${NC}" + echo " Report this issue: https://github.com/your-repo/issues" + echo "" exit 1 +else + rm -f "$IMPORT_ERROR" + echo -e "${GREEN}✓${NC} aden_tools package imports successfully" fi -# Test litellm + openai compatibility using tools venv -if $TOOLS_PYTHON -c "import litellm; print('litellm OK')" > /dev/null 2>&1; then +# Test litellm + openai compatibility +if $PYTHON_CMD -c "import litellm; print('litellm OK')" > /dev/null 2>&1; then echo -e "${GREEN}✓${NC} litellm package imports successfully" else echo -e "${YELLOW}⚠${NC} litellm import had issues (may be OK if not using LLM features)" @@ -290,14 +509,14 @@ echo "" echo "To run agents, use:" echo "" echo " ${BLUE}# From project root:${NC}" -echo " PYTHONPATH=core:exports ${PYTHON_CMD} -m agent_name validate" -echo " PYTHONPATH=core:exports ${PYTHON_CMD} -m agent_name info" -echo " PYTHONPATH=core:exports ${PYTHON_CMD} -m agent_name run --input '{...}'" +echo " PYTHONPATH=core:exports python -m agent_name validate" +echo " PYTHONPATH=core:exports python -m agent_name info" +echo " PYTHONPATH=core:exports python -m agent_name run --input '{...}'" echo "" echo "Available commands for your new agent:" -echo " PYTHONPATH=core:exports ${PYTHON_CMD} -m support_ticket_agent validate" -echo " PYTHONPATH=core:exports ${PYTHON_CMD} -m support_ticket_agent info" -echo " PYTHONPATH=core:exports ${PYTHON_CMD} -m support_ticket_agent run --input '{\"ticket_content\":\"...\",\"customer_id\":\"...\",\"ticket_id\":\"...\"}'" +echo " PYTHONPATH=core:exports python -m support_ticket_agent validate" +echo " PYTHONPATH=core:exports python -m support_ticket_agent info" +echo " PYTHONPATH=core:exports python -m support_ticket_agent run --input '{\"ticket_content\":\"...\",\"customer_id\":\"...\",\"ticket_id\":\"...\"}'" echo "" echo "To build new agents, use Claude Code skills:" echo " • /building-agents - Build a new agent"