@echo off REM FSS-Mini-RAG Windows Installer - Beautiful & Comprehensive setlocal enabledelayedexpansion REM Enable colors and unicode for modern Windows chcp 65001 >nul 2>&1 REM Check for command line arguments set "HEADLESS_MODE=false" if "%1"=="--headless" ( set "HEADLESS_MODE=true" echo ๐Ÿค– Running in headless mode - using defaults for automation echo โš ๏ธ WARNING: Installation may take 5-10 minutes due to large dependencies echo ๐Ÿ’ก For agents: Run as background process to avoid timeouts ) else if "%1"=="--help" ( goto show_help ) else if "%1"=="-h" ( goto show_help ) goto start_installation :show_help echo. echo FSS-Mini-RAG Windows Installation Script echo. echo Usage: echo install_windows.bat # Interactive installation echo install_windows.bat --headless # Automated installation for agents/CI echo install_windows.bat --help # Show this help echo. echo Headless mode options: echo โ€ข Uses existing virtual environment if available echo โ€ข Installs core dependencies only echo โ€ข Skips AI model downloads echo โ€ข Skips interactive prompts and tests echo โ€ข Perfect for agent automation and CI/CD pipelines echo. pause exit /b 0 :start_installation echo. echo โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•— echo โ•‘ FSS-Mini-RAG Windows Installer โ•‘ echo โ•‘ Fast Semantic Search for Code โ•‘ echo โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo. echo ๐Ÿš€ Comprehensive installation process: echo โ€ข Python environment setup and validation echo โ€ข Smart dependency management echo โ€ข Optional AI model downloads (with your consent) echo โ€ข System testing and verification echo โ€ข Interactive tutorial (optional) echo. echo ๐Ÿ’ก Note: You'll be asked before downloading any models echo. if "!HEADLESS_MODE!"=="true" ( echo Headless mode: Beginning installation automatically ) else ( set /p "continue=Begin installation? [Y/n]: " if /i "!continue!"=="n" ( echo Installation cancelled. pause exit /b 0 ) ) REM Get script directory set "SCRIPT_DIR=%~dp0" set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%" echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo [1/5] Checking Python Environment... python --version >nul 2>&1 if errorlevel 1 ( echo โŒ ERROR: Python not found! echo. echo ๐Ÿ“ฆ Please install Python from: https://python.org/downloads echo ๐Ÿ”ง Installation requirements: echo โ€ข Python 3.8 or higher echo โ€ข Make sure to check "Add Python to PATH" during installation echo โ€ข Restart your command prompt after installation echo. echo ๐Ÿ’ก Quick install options: echo โ€ข Download from python.org (recommended) echo โ€ข Or use: winget install Python.Python.3.11 echo โ€ข Or use: choco install python311 echo. pause exit /b 1 ) for /f "tokens=2" %%i in ('python --version 2^>^&1') do set "PYTHON_VERSION=%%i" echo โœ… Found Python !PYTHON_VERSION! REM Check Python version (basic check for 3.x) for /f "tokens=1 delims=." %%a in ("!PYTHON_VERSION!") do set "MAJOR_VERSION=%%a" if !MAJOR_VERSION! LSS 3 ( echo โŒ ERROR: Python !PYTHON_VERSION! found, but Python 3.8+ required echo ๐Ÿ“ฆ Please upgrade Python to 3.8 or higher pause exit /b 1 ) echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo [2/5] Creating Python Virtual Environment... if exist "%SCRIPT_DIR%\.venv" ( echo ๐Ÿ”„ Found existing virtual environment, checking if it works... call "%SCRIPT_DIR%\.venv\Scripts\activate.bat" >nul 2>&1 if not errorlevel 1 ( "%SCRIPT_DIR%\.venv\Scripts\python.exe" -c "import sys; print('โœ… Existing environment works')" >nul 2>&1 if not errorlevel 1 ( echo โœ… Using existing virtual environment goto skip_venv_creation ) ) echo ๐Ÿ”„ Removing problematic virtual environment... rmdir /s /q "%SCRIPT_DIR%\.venv" 2>nul if exist "%SCRIPT_DIR%\.venv" ( echo โš ๏ธ Could not remove old environment, will try to work with it... ) ) echo ๐Ÿ“ Creating fresh virtual environment... python -m venv "%SCRIPT_DIR%\.venv" if errorlevel 1 ( echo โŒ ERROR: Failed to create virtual environment echo. echo ๐Ÿ”ง This might be because: echo โ€ข Python venv module is not installed echo โ€ข Insufficient permissions echo โ€ข Path contains special characters echo. echo ๐Ÿ’ก Try: python -m pip install --user virtualenv pause exit /b 1 ) echo โœ… Virtual environment created successfully :skip_venv_creation echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo [3/5] Installing Python Dependencies... echo ๐Ÿ“ฆ This may take 2-3 minutes depending on your internet speed... echo. call "%SCRIPT_DIR%\.venv\Scripts\activate.bat" if errorlevel 1 ( echo โŒ ERROR: Could not activate virtual environment pause exit /b 1 ) echo ๐Ÿ”ง Upgrading pip... "%SCRIPT_DIR%\.venv\Scripts\python.exe" -m pip install --upgrade pip --quiet if errorlevel 1 ( echo โš ๏ธ Warning: Could not upgrade pip, continuing anyway... ) echo ๐Ÿ“š Installing core dependencies (lancedb, pandas, numpy, etc.)... echo This provides semantic search capabilities "%SCRIPT_DIR%\.venv\Scripts\pip.exe" install -r "%SCRIPT_DIR%\requirements.txt" if errorlevel 1 ( echo โŒ ERROR: Failed to install dependencies echo. echo ๐Ÿ”ง Possible solutions: echo โ€ข Check internet connection echo โ€ข Try running as administrator echo โ€ข Check if antivirus is blocking pip echo โ€ข Manually run: pip install -r requirements.txt echo. pause exit /b 1 ) echo โœ… Dependencies installed successfully echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo [4/5] Testing Installation... echo ๐Ÿงช Verifying Python imports... echo Attempting import test... "%SCRIPT_DIR%\.venv\Scripts\python.exe" -c "from mini_rag import CodeEmbedder, ProjectIndexer, CodeSearcher; print('โœ… Core imports successful')" 2>import_error.txt if errorlevel 1 ( echo โŒ ERROR: Installation test failed echo. echo ๐Ÿ” Import error details: type import_error.txt echo. echo ๐Ÿ”ง This usually means: echo โ€ข Dependencies didn't install correctly echo โ€ข Virtual environment is corrupted echo โ€ข Python path issues echo โ€ข Module conflicts with existing installations echo. echo ๐Ÿ’ก Troubleshooting options: echo โ€ข Try: "%SCRIPT_DIR%\.venv\Scripts\pip.exe" install -r requirements.txt --force-reinstall echo โ€ข Or delete .venv folder and run installer again echo โ€ข Or check import_error.txt for specific error details del import_error.txt >nul 2>&1 pause exit /b 1 ) del import_error.txt >nul 2>&1 echo ๐Ÿ” Testing embedding system... "%SCRIPT_DIR%\.venv\Scripts\python.exe" -c "from mini_rag import CodeEmbedder; embedder = CodeEmbedder(); info = embedder.get_embedding_info(); print(f'โœ… Embedding method: {info[\"method\"]}')" 2>nul if errorlevel 1 ( echo โš ๏ธ Warning: Embedding test inconclusive, but core system is ready ) echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo [5/6] Setting Up Desktop Integration... call :setup_windows_icon echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo [6/6] Checking AI Features (Optional)... call :check_ollama_enhanced echo. echo โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•— echo โ•‘ INSTALLATION SUCCESSFUL! โ•‘ echo โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo. echo ๐ŸŽฏ Quick Start Options: echo. echo ๐ŸŽจ For Beginners (Recommended): echo rag.bat - Interactive interface with guided setup echo. echo ๐Ÿ’ป For Developers: echo rag.bat index C:\myproject - Index a project echo rag.bat search C:\myproject "authentication" - Search project echo rag.bat help - Show all commands echo. REM Offer interactive tutorial echo ๐Ÿงช Quick Test Available: echo Test FSS-Mini-RAG with a small sample project (takes ~30 seconds) echo. if "!HEADLESS_MODE!"=="true" ( echo Headless mode: Skipping interactive tutorial echo ๐Ÿ“š You can run the tutorial anytime with: rag.bat ) else ( set /p "run_test=Run interactive tutorial now? [Y/n]: " if /i "!run_test!" NEQ "n" ( call :run_tutorial ) else ( echo ๐Ÿ“š You can run the tutorial anytime with: rag.bat ) ) echo. echo ๐ŸŽ‰ Setup complete! FSS-Mini-RAG is ready to use. echo ๐Ÿ’ก Pro tip: Try indexing any folder with text files - code, docs, notes! echo. pause exit /b 0 :check_ollama_enhanced echo ๐Ÿค– Checking for AI capabilities... echo. REM Check if Ollama is installed where ollama >nul 2>&1 if errorlevel 1 ( echo โš ๏ธ Ollama not installed - using basic search mode echo. echo ๐ŸŽฏ For Enhanced AI Features: echo โ€ข ๐Ÿ“ฅ Install Ollama: https://ollama.com/download echo โ€ข ๐Ÿ”„ Run: ollama serve echo โ€ข ๐Ÿง  Download model: ollama pull qwen3:1.7b echo. echo ๐Ÿ’ก Benefits of AI features: echo โ€ข Smart query expansion for better search results echo โ€ข Interactive exploration mode with conversation memory echo โ€ข AI-powered synthesis of search results echo โ€ข Natural language understanding of your questions echo. goto :eof ) REM Check if Ollama server is running curl -s http://localhost:11434/api/version >nul 2>&1 if errorlevel 1 ( echo ๐ŸŸก Ollama installed but not running echo. if "!HEADLESS_MODE!"=="true" ( echo Headless mode: Starting Ollama server automatically set "start_ollama=y" ) else ( set /p "start_ollama=Start Ollama server now? [Y/n]: " ) if /i "!start_ollama!" NEQ "n" ( echo ๐Ÿš€ Starting Ollama server... start /b ollama serve timeout /t 3 /nobreak >nul curl -s http://localhost:11434/api/version >nul 2>&1 if errorlevel 1 ( echo โš ๏ธ Could not start Ollama automatically echo ๐Ÿ’ก Please run: ollama serve ) else ( echo โœ… Ollama server started successfully! ) ) ) else ( echo โœ… Ollama server is running! ) REM Check for available models echo ๐Ÿ” Checking for AI models... ollama list 2>nul | findstr /v "NAME" | findstr /v "^$" >nul if errorlevel 1 ( echo ๐Ÿ“ฆ No AI models found echo. echo ๐Ÿง  Recommended Models (choose one): echo โ€ข qwen3:1.7b - Excellent for RAG (1.4GB, recommended) echo โ€ข qwen3:0.6b - Lightweight and fast (~500MB) echo โ€ข qwen3:4b - Higher quality but slower (~2.5GB) echo. if "!HEADLESS_MODE!"=="true" ( echo Headless mode: Skipping model download set "install_model=n" ) else ( set /p "install_model=Download qwen3:1.7b model now? [Y/n]: " ) if /i "!install_model!" NEQ "n" ( echo ๐Ÿ“ฅ Downloading qwen3:1.7b model... echo This may take 5-10 minutes depending on your internet speed ollama pull qwen3:1.7b if errorlevel 1 ( echo โš ๏ธ Download failed - you can try again later with: ollama pull qwen3:1.7b ) else ( echo โœ… Model downloaded successfully! AI features are now available. ) ) ) else ( echo โœ… AI models found - full AI features available! echo ๐ŸŽ‰ Your system supports query expansion, exploration mode, and synthesis! ) goto :eof :run_tutorial echo. echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo ๐Ÿงช Running Interactive Tutorial echo โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• echo. echo ๐Ÿ“š This tutorial will: echo โ€ข Index the FSS-Mini-RAG documentation echo โ€ข Show you how to search effectively echo โ€ข Demonstrate AI features (if available) echo. call "%SCRIPT_DIR%\.venv\Scripts\activate.bat" echo ๐Ÿ“ Indexing project for demonstration... "%SCRIPT_DIR%\.venv\Scripts\python.exe" rag-mini.py index "%SCRIPT_DIR%" >nul 2>&1 if errorlevel 1 ( echo โŒ Indexing failed - please check the installation goto :eof ) echo โœ… Indexing complete! echo. echo ๐Ÿ” Example search: "embedding" "%SCRIPT_DIR%\.venv\Scripts\python.exe" rag-mini.py search "%SCRIPT_DIR%" "embedding" --top-k 3 echo. echo ๐ŸŽฏ Try the interactive interface: echo rag.bat echo. echo ๐Ÿ’ก You can now search any project by indexing it first! goto :eof :setup_windows_icon echo ๐ŸŽจ Setting up application icon and shortcuts... REM Check if icon exists if not exist "%SCRIPT_DIR%\assets\Fss_Mini_Rag.png" ( echo โš ๏ธ Icon file not found - skipping desktop integration goto :eof ) REM Create desktop shortcut echo ๐Ÿ“ฑ Creating desktop shortcut... set "desktop=%USERPROFILE%\Desktop" set "shortcut=%desktop%\FSS-Mini-RAG.lnk" REM Use PowerShell to create shortcut with icon powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%shortcut%'); $Shortcut.TargetPath = '%SCRIPT_DIR%\rag.bat'; $Shortcut.WorkingDirectory = '%SCRIPT_DIR%'; $Shortcut.Description = 'FSS-Mini-RAG - Fast Semantic Search'; $Shortcut.Save()}" >nul 2>&1 if exist "%shortcut%" ( echo โœ… Desktop shortcut created ) else ( echo โš ๏ธ Could not create desktop shortcut ) REM Create Start Menu shortcut echo ๐Ÿ“‚ Creating Start Menu entry... set "startmenu=%APPDATA%\Microsoft\Windows\Start Menu\Programs" set "startshortcut=%startmenu%\FSS-Mini-RAG.lnk" powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%startshortcut%'); $Shortcut.TargetPath = '%SCRIPT_DIR%\rag.bat'; $Shortcut.WorkingDirectory = '%SCRIPT_DIR%'; $Shortcut.Description = 'FSS-Mini-RAG - Fast Semantic Search'; $Shortcut.Save()}" >nul 2>&1 if exist "%startshortcut%" ( echo โœ… Start Menu entry created ) else ( echo โš ๏ธ Could not create Start Menu entry ) echo ๐Ÿ’ก FSS-Mini-RAG shortcuts have been created on your Desktop and Start Menu echo You can now launch the application from either location goto :eof