@echo off setlocal EnableExtensions EnableDelayedExpansion cd /d "%~dp0" title Kronos AI Analysis set "PYTHONUTF8=1" set "PYTHONIOENCODING=utf-8" set "KRONOS_PRELOAD=1" set "VENV_DIR=%CD%\venv" set "VENV_PY=%VENV_DIR%\Scripts\python.exe" echo ========================================== echo KRONOS AI ANALYSIS - STARTUP echo ========================================== echo. echo [1/5] Checking Python 3.11... py -3.11 -V >nul 2>&1 if errorlevel 1 ( echo [ERROR] Python 3.11 is required but was not found. echo [HINT] Install Python 3.11 and run this script again. goto :end ) echo [2/5] Checking virtual environment... if exist "%VENV_PY%" ( "%VENV_PY%" -V >nul 2>&1 if errorlevel 1 ( echo [WARN] Existing venv is invalid. Rebuilding a clean one... if exist "%CD%\venv_legacy_broken" rmdir /s /q "%CD%\venv_legacy_broken" ren "%VENV_DIR%" "venv_legacy_broken" ) ) if not exist "%VENV_PY%" ( echo [INFO] Creating fresh Python 3.11 virtual environment... py -3.11 -m venv "%VENV_DIR%" if errorlevel 1 ( echo [ERROR] Failed to create virtual environment. goto :end ) ) set "REQUESTS_CA_BUNDLE=%VENV_DIR%\Lib\site-packages\pip\_vendor\certifi\cacert.pem" echo [3/5] Installing or verifying dependencies... "%VENV_PY%" -m pip install -r requirements.txt if errorlevel 1 ( echo [ERROR] Dependency installation failed. goto :end ) echo [4/5] Running Kronos runtime self-check... "%VENV_PY%" -c "import backend.main as m; assert m.KRONOS_AVAILABLE, 'Kronos import failed'; print('KRONOS_PATH=', m.KRONOS_PATH); print('SYMBOLS=', len(m.SYMBOLS))" if errorlevel 1 ( echo [ERROR] Backend self-check failed. goto :end ) echo [5/5] Starting backend... echo [INFO] Opening http://127.0.0.1:8000 start "" http://127.0.0.1:8000 echo. echo ------------------------------------------ echo KEEP THIS WINDOW OPEN WHILE USING THE APP echo TO STOP: PRESS CTRL+C echo ------------------------------------------ echo. "%VENV_PY%" -m uvicorn backend.main:app --host 127.0.0.1 --port 8000 --reload :end pause