Backup before continuing from Codex 5.2 session - User storage, compaction suggestions, streaming improvements
This commit is contained in:
@@ -1,318 +1,253 @@
|
||||
@echo off
|
||||
title NomadArch Installer
|
||||
color 0A
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
title NomadArch Installer
|
||||
|
||||
echo.
|
||||
echo ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗
|
||||
echo ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║
|
||||
echo ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║
|
||||
echo ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║
|
||||
echo ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║
|
||||
echo ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
|
||||
echo.
|
||||
echo INSTALLER - Enhanced with Auto-Dependency Resolution
|
||||
echo ═══════════════════════════════════════════════════════════════════════════════
|
||||
echo NomadArch Installer (Windows)
|
||||
echo Version: 0.4.0
|
||||
echo.
|
||||
|
||||
set SCRIPT_DIR=%~dp0
|
||||
set SCRIPT_DIR=%SCRIPT_DIR:~0,-1%
|
||||
set TARGET_DIR=%SCRIPT_DIR%
|
||||
set BIN_DIR=%TARGET_DIR%\bin
|
||||
set LOG_FILE=%TARGET_DIR%\install.log
|
||||
set TEMP_DIR=%TARGET_DIR%\.install-temp
|
||||
|
||||
set ERRORS=0
|
||||
set WARNINGS=0
|
||||
set NEEDS_FALLBACK=0
|
||||
|
||||
cd /d "%~dp0"
|
||||
echo [%date% %time%] Installer started >> "%LOG_FILE%"
|
||||
|
||||
echo [STEP 1/9] OS and Architecture Detection
|
||||
wmic os get osarchitecture | findstr /i "64-bit" >nul
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
set ARCH=x64
|
||||
) else (
|
||||
set ARCH=x86
|
||||
)
|
||||
echo [OK] Architecture: %ARCH%
|
||||
|
||||
echo [STEP 1/6] Checking System Requirements...
|
||||
echo.
|
||||
echo [STEP 2/9] Checking write permissions
|
||||
if not exist "%BIN_DIR%" mkdir "%BIN_DIR%"
|
||||
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"
|
||||
|
||||
:: Check for Administrator privileges
|
||||
net session >nul 2>&1
|
||||
echo. > "%SCRIPT_DIR%\test-write.tmp" 2>nul
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [WARN] Not running as Administrator. Some operations may fail.
|
||||
set /a WARNINGS+=1
|
||||
echo.
|
||||
echo [WARN] Cannot write to current directory: %SCRIPT_DIR%
|
||||
set TARGET_DIR=%USERPROFILE%\NomadArch-Install
|
||||
set BIN_DIR=%TARGET_DIR%\bin
|
||||
set LOG_FILE=%TARGET_DIR%\install.log
|
||||
set TEMP_DIR=%TARGET_DIR%\.install-temp
|
||||
if not exist "%TARGET_DIR%" mkdir "%TARGET_DIR%"
|
||||
if not exist "%BIN_DIR%" mkdir "%BIN_DIR%"
|
||||
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"
|
||||
echo. > "%TARGET_DIR%\test-write.tmp" 2>nul
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] Cannot write to fallback directory: %TARGET_DIR%
|
||||
echo [%date% %time%] ERROR: Write permission denied >> "%LOG_FILE%"
|
||||
set /a ERRORS+=1
|
||||
goto :SUMMARY
|
||||
)
|
||||
del "%TARGET_DIR%\test-write.tmp"
|
||||
set NEEDS_FALLBACK=1
|
||||
echo [OK] Using fallback: %TARGET_DIR%
|
||||
) else (
|
||||
del "%SCRIPT_DIR%\test-write.tmp"
|
||||
echo [OK] Write permissions verified
|
||||
)
|
||||
|
||||
echo.
|
||||
echo [STEP 3/9] Ensuring system dependencies
|
||||
|
||||
set WINGET_AVAILABLE=0
|
||||
where winget >nul 2>&1 && set WINGET_AVAILABLE=1
|
||||
|
||||
set CHOCO_AVAILABLE=0
|
||||
where choco >nul 2>&1 && set CHOCO_AVAILABLE=1
|
||||
|
||||
set DOWNLOAD_CMD=
|
||||
where curl >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
set DOWNLOAD_CMD=curl
|
||||
) else (
|
||||
set DOWNLOAD_CMD=powershell
|
||||
)
|
||||
|
||||
:: Check for Node.js
|
||||
echo [INFO] Checking Node.js...
|
||||
where node >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] Node.js not found!
|
||||
echo.
|
||||
echo NomadArch requires Node.js to run.
|
||||
echo.
|
||||
echo Download from: https://nodejs.org/
|
||||
echo Recommended: Node.js 18.x LTS or 20.x LTS
|
||||
echo.
|
||||
echo Opening download page...
|
||||
start "" "https://nodejs.org/"
|
||||
echo.
|
||||
echo Please install Node.js and run this installer again.
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
echo [INFO] Node.js not found. Attempting to install...
|
||||
if %WINGET_AVAILABLE% equ 1 (
|
||||
winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements
|
||||
) else if %CHOCO_AVAILABLE% equ 1 (
|
||||
choco install nodejs-lts -y
|
||||
) else (
|
||||
echo [ERROR] No supported package manager found (winget/choco).
|
||||
echo Please install Node.js LTS from https://nodejs.org/
|
||||
set /a ERRORS+=1
|
||||
goto :SUMMARY
|
||||
)
|
||||
)
|
||||
|
||||
:: Display Node.js version
|
||||
for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i
|
||||
echo [OK] Node.js found: %NODE_VERSION%
|
||||
where node >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] Node.js install failed or requires a new terminal session.
|
||||
set /a ERRORS+=1
|
||||
goto :SUMMARY
|
||||
)
|
||||
|
||||
for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i
|
||||
echo [OK] Node.js: %NODE_VERSION%
|
||||
|
||||
:: Check for npm
|
||||
echo [INFO] Checking npm...
|
||||
where npm >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] npm not found!
|
||||
echo.
|
||||
echo npm is required for dependency management.
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
echo [ERROR] npm not found after Node.js install.
|
||||
set /a ERRORS+=1
|
||||
goto :SUMMARY
|
||||
)
|
||||
|
||||
for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i
|
||||
echo [OK] npm found: %NPM_VERSION%
|
||||
echo [OK] npm: %NPM_VERSION%
|
||||
|
||||
echo.
|
||||
echo [STEP 2/6] Checking OpenCode CLI...
|
||||
echo.
|
||||
|
||||
:: Check if opencode is already installed globally
|
||||
where opencode >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo [OK] OpenCode is already installed globally
|
||||
goto :OPENCODE_DONE
|
||||
)
|
||||
|
||||
:: Check if opencode exists in bin/ folder
|
||||
if exist "bin\opencode.exe" (
|
||||
echo [OK] OpenCode binary found in bin/ folder
|
||||
goto :OPENCODE_DONE
|
||||
)
|
||||
|
||||
:: Install OpenCode CLI
|
||||
echo [SETUP] OpenCode CLI not found. Installing...
|
||||
echo.
|
||||
echo [INFO] Attempting to install OpenCode via npm...
|
||||
call npm install -g opencode-ai@latest
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo [SUCCESS] OpenCode installed successfully via npm
|
||||
where opencode >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo [OK] OpenCode is now available in system PATH
|
||||
goto :OPENCODE_DONE
|
||||
where git >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [INFO] Git not found. Attempting to install...
|
||||
if %WINGET_AVAILABLE% equ 1 (
|
||||
winget install -e --id Git.Git --accept-source-agreements --accept-package-agreements
|
||||
) else if %CHOCO_AVAILABLE% equ 1 (
|
||||
choco install git -y
|
||||
) else (
|
||||
echo [WARN] Git not installed (optional). Continue.
|
||||
set /a WARNINGS+=1
|
||||
)
|
||||
)
|
||||
|
||||
echo [WARN] npm install failed or not in PATH, trying fallback method...
|
||||
echo.
|
||||
|
||||
:: Fallback: Download from GitHub releases
|
||||
echo [SETUP] Downloading OpenCode from GitHub releases...
|
||||
echo.
|
||||
|
||||
:: Download Windows x64 ZIP
|
||||
curl -L -o "opencode-windows-x64.zip" "https://github.com/sst/opencode/releases/latest/download/opencode-windows-x64.zip"
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] Failed to download OpenCode from GitHub!
|
||||
set /a ERRORS+=1
|
||||
goto :INSTALL_DEPS
|
||||
)
|
||||
|
||||
echo [OK] Downloaded OpenCode ZIP
|
||||
echo [SETUP] Extracting OpenCode binary...
|
||||
|
||||
:: Create bin directory if not exists
|
||||
if not exist "bin" mkdir bin
|
||||
|
||||
:: Extract using PowerShell
|
||||
powershell -Command "Expand-Archive -Path 'opencode-windows-x64.zip' -DestinationPath 'opencode-temp' -Force"
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] Failed to extract OpenCode!
|
||||
set /a ERRORS+=1
|
||||
goto :CLEANUP
|
||||
)
|
||||
|
||||
:: Move opencode.exe to bin/ folder
|
||||
if exist "opencode-temp\opencode.exe" (
|
||||
move /Y "opencode-temp\opencode.exe" "bin\opencode.exe" >nul
|
||||
echo [OK] OpenCode binary placed in bin/ folder
|
||||
) else (
|
||||
echo [ERROR] opencode.exe not found in extracted files!
|
||||
set /a ERRORS+=1
|
||||
for /f "tokens=*" %%i in ('git --version') do set GIT_VERSION=%%i
|
||||
echo [OK] Git: %GIT_VERSION%
|
||||
)
|
||||
|
||||
:CLEANUP
|
||||
if exist "opencode-windows-x64.zip" del "opencode-windows-x64.zip"
|
||||
if exist "opencode-temp" rmdir /s /q "opencode-temp"
|
||||
|
||||
:OPENCODE_DONE
|
||||
echo.
|
||||
|
||||
echo [STEP 3/6] Installing NomadArch Dependencies...
|
||||
echo.
|
||||
|
||||
:: Check if node_modules exists
|
||||
if exist "node_modules" (
|
||||
echo [INFO] node_modules found. Skipping dependency installation.
|
||||
echo [INFO] To force reinstall, delete node_modules and run again.
|
||||
goto :BUILD_CHECK
|
||||
)
|
||||
|
||||
echo [INFO] Installing root dependencies...
|
||||
echo [STEP 4/9] Installing npm dependencies
|
||||
cd /d "%SCRIPT_DIR%"
|
||||
echo [%date% %time%] Running npm install >> "%LOG_FILE%"
|
||||
call npm install
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] Failed to install root dependencies!
|
||||
echo [ERROR] npm install failed!
|
||||
echo [%date% %time%] ERROR: npm install failed >> "%LOG_FILE%"
|
||||
set /a ERRORS+=1
|
||||
goto :INSTALL_REPORT
|
||||
goto :SUMMARY
|
||||
)
|
||||
echo [OK] Dependencies installed
|
||||
|
||||
echo.
|
||||
echo [STEP 5/9] Fetching OpenCode binary
|
||||
if not exist "%BIN_DIR%" mkdir "%BIN_DIR%"
|
||||
|
||||
for /f "delims=" %%v in ('powershell -NoProfile -Command "(Invoke-WebRequest -UseBasicParsing https://api.github.com/repos/sst/opencode/releases/latest).Content ^| Select-String -Pattern '""tag_name""' ^| ForEach-Object { $_.Line.Split(''\"'')[3] }"') do (
|
||||
set OPENCODE_VERSION=%%v
|
||||
)
|
||||
|
||||
set OPENCODE_BASE=https://github.com/sst/opencode/releases/download/v!OPENCODE_VERSION!
|
||||
set OPENCODE_URL=!OPENCODE_BASE!/opencode-windows-%ARCH%.exe
|
||||
set CHECKSUM_URL=!OPENCODE_BASE!/checksums.txt
|
||||
|
||||
if exist "%BIN_DIR%\opencode.exe" (
|
||||
echo [OK] OpenCode binary already exists
|
||||
echo [%date% %time%] OpenCode binary exists, skipping download >> "%LOG_FILE%"
|
||||
) else (
|
||||
echo [INFO] Downloading OpenCode v!OPENCODE_VERSION!...
|
||||
if "%DOWNLOAD_CMD%"=="curl" (
|
||||
curl -L -o "%BIN_DIR%\opencode.exe.tmp" "!OPENCODE_URL!"
|
||||
curl -L -o "%BIN_DIR%\checksums.txt" "!CHECKSUM_URL!"
|
||||
) else (
|
||||
powershell -NoProfile -Command "Invoke-WebRequest -Uri '%OPENCODE_URL%' -OutFile '%BIN_DIR%\\opencode.exe.tmp'"
|
||||
powershell -NoProfile -Command "Invoke-WebRequest -Uri '%CHECKSUM_URL%' -OutFile '%BIN_DIR%\\checksums.txt'"
|
||||
)
|
||||
|
||||
set EXPECTED_HASH=
|
||||
for /f "tokens=1,2" %%h in ('type "%BIN_DIR%\checksums.txt" ^| findstr /i "opencode-windows-%ARCH%"') do (
|
||||
set EXPECTED_HASH=%%h
|
||||
)
|
||||
|
||||
set ACTUAL_HASH=
|
||||
for /f "skip=1 tokens=*" %%h in ('certutil -hashfile "%BIN_DIR%\opencode.exe.tmp" SHA256 ^| findstr /v "CertUtil" ^| findstr /v "hash of"') do (
|
||||
set ACTUAL_HASH=%%h
|
||||
goto :hash_found
|
||||
)
|
||||
:hash_found
|
||||
|
||||
if "!ACTUAL_HASH!"=="!EXPECTED_HASH!" (
|
||||
move /Y "%BIN_DIR%\opencode.exe.tmp" "%BIN_DIR%\opencode.exe"
|
||||
echo [OK] OpenCode downloaded and verified
|
||||
) else (
|
||||
echo [ERROR] OpenCode checksum mismatch!
|
||||
del "%BIN_DIR%\opencode.exe.tmp"
|
||||
set /a ERRORS+=1
|
||||
)
|
||||
)
|
||||
|
||||
echo [OK] Root dependencies installed
|
||||
echo.
|
||||
|
||||
echo [INFO] Installing package dependencies...
|
||||
|
||||
:: Install server dependencies
|
||||
if exist "packages\server" (
|
||||
echo [INFO] Installing server dependencies...
|
||||
cd packages\server
|
||||
call npm install
|
||||
echo [STEP 6/9] Building UI assets
|
||||
if exist "%SCRIPT_DIR%\packages\ui\dist\index.html" (
|
||||
echo [OK] UI build already exists
|
||||
) else (
|
||||
echo [INFO] Building UI assets...
|
||||
pushd packages\ui
|
||||
call npm run build
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [WARN] Failed to install server dependencies!
|
||||
set /a WARNINGS+=1
|
||||
) else (
|
||||
echo [OK] Server dependencies installed
|
||||
echo [ERROR] UI build failed!
|
||||
popd
|
||||
set /a ERRORS+=1
|
||||
goto :SUMMARY
|
||||
)
|
||||
cd ..\..
|
||||
popd
|
||||
echo [OK] UI assets built successfully
|
||||
)
|
||||
|
||||
:: Install UI dependencies
|
||||
if exist "packages\ui" (
|
||||
echo [INFO] Installing UI dependencies...
|
||||
cd packages\ui
|
||||
call npm install
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [WARN] Failed to install UI dependencies!
|
||||
set /a WARNINGS+=1
|
||||
) else (
|
||||
echo [OK] UI dependencies installed
|
||||
)
|
||||
cd ..\..
|
||||
)
|
||||
|
||||
:: Install Electron app dependencies
|
||||
if exist "packages\electron-app" (
|
||||
echo [INFO] Installing Electron app dependencies...
|
||||
cd packages\electron-app
|
||||
call npm install
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [WARN] Failed to install Electron app dependencies!
|
||||
set /a WARNINGS+=1
|
||||
) else (
|
||||
echo [OK] Electron app dependencies installed
|
||||
)
|
||||
cd ..\..
|
||||
)
|
||||
|
||||
:BUILD_CHECK
|
||||
echo.
|
||||
echo [STEP 7/9] Post-install health check
|
||||
set HEALTH_ERRORS=0
|
||||
|
||||
echo [STEP 4/6] Checking for Existing Build...
|
||||
echo.
|
||||
if not exist "%SCRIPT_DIR%\package.json" set /a HEALTH_ERRORS+=1
|
||||
if not exist "%SCRIPT_DIR%\packages\ui" set /a HEALTH_ERRORS+=1
|
||||
if not exist "%SCRIPT_DIR%\packages\server" set /a HEALTH_ERRORS+=1
|
||||
if not exist "%SCRIPT_DIR%\packages\ui\dist\index.html" set /a HEALTH_ERRORS+=1
|
||||
|
||||
if exist "packages\ui\dist" (
|
||||
echo [OK] UI build found. Skipping build step.
|
||||
echo [INFO] To rebuild, delete packages\ui\dist and run installer again.
|
||||
goto :INSTALL_REPORT
|
||||
)
|
||||
|
||||
echo [INFO] No UI build found. Building UI...
|
||||
echo.
|
||||
|
||||
:: Build UI
|
||||
cd packages\ui
|
||||
call npm run build
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [WARN] Failed to build UI!
|
||||
set /a WARNINGS+=1
|
||||
echo [INFO] You can build manually later by running: cd packages\ui ^&^& npm run build
|
||||
)
|
||||
cd ..\..
|
||||
|
||||
:INSTALL_REPORT
|
||||
echo.
|
||||
echo ═══════════════════════════════════════════════════════════════════════════════
|
||||
echo INSTALLATION COMPLETE
|
||||
echo ═══════════════════════════════════════════════════════════════════════════════
|
||||
echo.
|
||||
echo Summary:
|
||||
echo.
|
||||
if %ERRORS% equ 0 (
|
||||
echo ✓ No errors encountered
|
||||
if %HEALTH_ERRORS% equ 0 (
|
||||
echo [OK] Health checks passed
|
||||
) else (
|
||||
echo ✗ %ERRORS% error(s) encountered
|
||||
)
|
||||
echo.
|
||||
if %WARNINGS% equ 0 (
|
||||
echo ✓ No warnings
|
||||
) else (
|
||||
echo ⚠ %WARNINGS% warning(s) encountered
|
||||
)
|
||||
echo.
|
||||
|
||||
echo [STEP 5/6] Testing Installation...
|
||||
echo.
|
||||
|
||||
:: Test node command
|
||||
node --version >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo [OK] Node.js is working
|
||||
) else (
|
||||
echo [FAIL] Node.js is not working correctly
|
||||
set /a ERRORS+=1
|
||||
)
|
||||
|
||||
:: Test npm command
|
||||
npm --version >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo [OK] npm is working
|
||||
) else (
|
||||
echo [FAIL] npm is not working correctly
|
||||
set /a ERRORS+=1
|
||||
)
|
||||
|
||||
:: Test opencode command
|
||||
where opencode >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo [OK] OpenCode CLI is available
|
||||
) else (
|
||||
if exist "bin\opencode.exe" (
|
||||
echo [OK] OpenCode binary found in bin/ folder
|
||||
) else (
|
||||
echo [FAIL] OpenCode CLI not available
|
||||
set /a WARNINGS+=1
|
||||
)
|
||||
echo [ERROR] Health checks failed (%HEALTH_ERRORS%)
|
||||
set /a ERRORS+=%HEALTH_ERRORS%
|
||||
)
|
||||
|
||||
echo.
|
||||
echo [STEP 6/6] Next Steps...
|
||||
echo [STEP 8/9] Installation Summary
|
||||
echo.
|
||||
echo To start NomadArch:
|
||||
echo 1. Double-click and run: Launch-Windows.bat
|
||||
echo OR
|
||||
echo 2. Run from command line: npm run dev:electron
|
||||
echo.
|
||||
echo For development mode:
|
||||
echo Run: Launch-Dev-Windows.bat
|
||||
echo Install Dir: %TARGET_DIR%
|
||||
echo Architecture: %ARCH%
|
||||
echo Node.js: %NODE_VERSION%
|
||||
echo npm: %NPM_VERSION%
|
||||
echo Errors: %ERRORS%
|
||||
echo Warnings: %WARNINGS%
|
||||
echo Log File: %LOG_FILE%
|
||||
echo.
|
||||
|
||||
echo [STEP 9/9] Next steps
|
||||
|
||||
:SUMMARY
|
||||
if %ERRORS% gtr 0 (
|
||||
echo ⚠ INSTALLATION HAD ERRORS!
|
||||
echo Please review the messages above and fix any issues.
|
||||
echo [RESULT] Installation completed with errors.
|
||||
echo Review the log: %LOG_FILE%
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
echo If Node.js was just installed, open a new terminal and run this installer again.
|
||||
) else (
|
||||
echo ✓ Installation completed successfully!
|
||||
echo.
|
||||
echo Press any key to exit...
|
||||
pause >nul
|
||||
exit /b 0
|
||||
echo [RESULT] Installation completed successfully.
|
||||
echo Run Launch-Windows.bat to start the application.
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Press any key to exit...
|
||||
pause >nul
|
||||
exit /b %ERRORS%
|
||||
|
||||
Reference in New Issue
Block a user