diff --git a/Install-Windows.bat b/Install-Windows.bat index 8524f8c..f472a56 100644 --- a/Install-Windows.bat +++ b/Install-Windows.bat @@ -18,12 +18,15 @@ set TEMP_DIR=%TARGET_DIR%\.install-temp set ERRORS=0 set WARNINGS=0 set NEEDS_FALLBACK=0 +set SKIP_OPENCODE=0 echo [%date% %time%] Installer started >> "%LOG_FILE%" echo [STEP 1/8] OS and Architecture Detection -wmic os get osarchitecture | findstr /i "64-bit" >nul -if %ERRORLEVEL% equ 0 ( + +REM Use PowerShell for architecture detection (works on all Windows versions) +for /f "tokens=*" %%i in ('powershell -NoProfile -Command "[System.Environment]::Is64BitOperatingSystem"') do set IS64BIT=%%i +if /i "%IS64BIT%"=="True" ( set ARCH=x64 ) else ( set ARCH=x86 @@ -32,29 +35,29 @@ echo [OK] Architecture: %ARCH% echo. echo [STEP 2/8] Checking write permissions -if not exist "%BIN_DIR%" mkdir "%BIN_DIR%" -if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%" +if not exist "%BIN_DIR%" mkdir "%BIN_DIR%" 2>nul +if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%" 2>nul echo. > "%SCRIPT_DIR%\test-write.tmp" 2>nul -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( 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% + 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" + del "!TARGET_DIR!\test-write.tmp" set NEEDS_FALLBACK=1 - echo [OK] Using fallback: %TARGET_DIR% + echo [OK] Using fallback: !TARGET_DIR! ) else ( del "%SCRIPT_DIR%\test-write.tmp" echo [OK] Write permissions verified @@ -64,28 +67,26 @@ echo. echo [STEP 3/8] Ensuring system dependencies set WINGET_AVAILABLE=0 -where winget >nul 2>&1 && set WINGET_AVAILABLE=1 +where winget >nul 2>&1 +if !ERRORLEVEL! equ 0 set WINGET_AVAILABLE=1 set CHOCO_AVAILABLE=0 -where choco >nul 2>&1 && set CHOCO_AVAILABLE=1 +where choco >nul 2>&1 +if !ERRORLEVEL! equ 0 set CHOCO_AVAILABLE=1 -set DOWNLOAD_CMD= +set DOWNLOAD_CMD=powershell where curl >nul 2>&1 -if %ERRORLEVEL% equ 0 ( - set DOWNLOAD_CMD=curl -) else ( - set DOWNLOAD_CMD=powershell -) +if !ERRORLEVEL! equ 0 set DOWNLOAD_CMD=curl where node >nul 2>&1 -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( echo [INFO] Node.js not found. Attempting to install... - if %WINGET_AVAILABLE% equ 1 ( + if !WINGET_AVAILABLE! equ 1 ( winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements - ) else if %CHOCO_AVAILABLE% equ 1 ( + ) else if !CHOCO_AVAILABLE! equ 1 ( choco install nodejs-lts -y ) else ( - echo [ERROR] No supported package manager found (winget/choco). + echo [ERROR] No supported package manager found. echo Please install Node.js LTS from https://nodejs.org/ set /a ERRORS+=1 goto :SUMMARY @@ -93,7 +94,7 @@ if %ERRORLEVEL% neq 0 ( ) where node >nul 2>&1 -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( echo [ERROR] Node.js install failed or requires a new terminal session. set /a ERRORS+=1 goto :SUMMARY @@ -103,7 +104,7 @@ for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i echo [OK] Node.js: %NODE_VERSION% where npm >nul 2>&1 -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( echo [ERROR] npm not found after Node.js install. set /a ERRORS+=1 goto :SUMMARY @@ -113,19 +114,19 @@ for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i echo [OK] npm: %NPM_VERSION% where git >nul 2>&1 -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( echo [INFO] Git not found. Attempting to install... - if %WINGET_AVAILABLE% equ 1 ( + if !WINGET_AVAILABLE! equ 1 ( winget install -e --id Git.Git --accept-source-agreements --accept-package-agreements - ) else if %CHOCO_AVAILABLE% equ 1 ( + ) else if !CHOCO_AVAILABLE! equ 1 ( choco install git -y ) else ( - echo [WARN] Git not installed (optional). Continue. + echo [WARN] Git not installed - optional set /a WARNINGS+=1 ) ) else ( for /f "tokens=*" %%i in ('git --version') do set GIT_VERSION=%%i - echo [OK] Git: %GIT_VERSION% + echo [OK] Git: !GIT_VERSION! ) echo. @@ -133,7 +134,7 @@ echo [STEP 4/8] Installing npm dependencies cd /d "%SCRIPT_DIR%" echo [%date% %time%] Running npm install >> "%LOG_FILE%" call npm install -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( echo [ERROR] npm install failed! echo [%date% %time%] ERROR: npm install failed >> "%LOG_FILE%" set /a ERRORS+=1 @@ -142,64 +143,56 @@ if %ERRORLEVEL% neq 0 ( echo [OK] Dependencies installed echo. -echo [STEP 5/8] OpenCode Binary (OPTIONAL - Binary-Free Mode Available) +echo [STEP 5/8] OpenCode Binary - OPTIONAL +echo. echo [INFO] NomadArch now supports Binary-Free Mode! echo [INFO] You can use the application without OpenCode binary. echo [INFO] Free models from OpenCode Zen are available without the binary. -if not exist "%BIN_DIR%" mkdir "%BIN_DIR%" +echo. +if not exist "%BIN_DIR%" mkdir "%BIN_DIR%" 2>nul -set SKIP_OPENCODE=0 -set /p SKIP_CHOICE="Skip OpenCode binary download? (Y for Binary-Free Mode / N to download) [Y]: " -if /i "%SKIP_CHOICE%"=="" set SKIP_CHOICE=Y -if /i "%SKIP_CHOICE%"=="Y" ( - set SKIP_OPENCODE=1 - echo [INFO] Skipping OpenCode binary - using Binary-Free Mode - echo [%date% %time%] Using Binary-Free Mode >> "%LOG_FILE%" -) else ( - 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 /p SKIP_CHOICE="Skip OpenCode binary download? (Y for Binary-Free / N to download) [Y]: " +if /i "!SKIP_CHOICE!"=="" set SKIP_CHOICE=Y +if /i "!SKIP_CHOICE!"=="Y" goto :skip_opencode_download - 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 +REM Download OpenCode binary +echo [INFO] Fetching OpenCode version info... +for /f "delims=" %%v in ('powershell -NoProfile -Command "try { (Invoke-WebRequest -UseBasicParsing https://api.github.com/repos/sst/opencode/releases/latest).Content | ConvertFrom-Json | Select-Object -ExpandProperty tag_name } catch { 'v0.1.44' }"') do set OPENCODE_VERSION=%%v +set OPENCODE_VERSION=!OPENCODE_VERSION:v=! - 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 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 - 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 [WARN] OpenCode checksum mismatch - continuing with Binary-Free Mode - del "%BIN_DIR%\opencode.exe.tmp" 2>nul - set SKIP_OPENCODE=1 - ) - ) +if exist "%BIN_DIR%\opencode.exe" ( + echo [OK] OpenCode binary already exists + echo [%date% %time%] OpenCode binary exists, skipping download >> "%LOG_FILE%" + goto :opencode_done ) +echo [INFO] Downloading OpenCode v!OPENCODE_VERSION!... +if "!DOWNLOAD_CMD!"=="curl" ( + curl -L -o "%BIN_DIR%\opencode.exe.tmp" "!OPENCODE_URL!" +) else ( + powershell -NoProfile -Command "Invoke-WebRequest -Uri '!OPENCODE_URL!' -OutFile '%BIN_DIR%\opencode.exe.tmp'" +) + +if exist "%BIN_DIR%\opencode.exe.tmp" ( + move /Y "%BIN_DIR%\opencode.exe.tmp" "%BIN_DIR%\opencode.exe" >nul + echo [OK] OpenCode downloaded +) else ( + echo [WARN] OpenCode download failed - using Binary-Free Mode instead + set SKIP_OPENCODE=1 +) +goto :opencode_done + +:skip_opencode_download +set SKIP_OPENCODE=1 +echo [INFO] Skipping OpenCode binary - using Binary-Free Mode +echo [%date% %time%] Using Binary-Free Mode >> "%LOG_FILE%" + +:opencode_done + echo. echo [STEP 6/8] Building UI assets if exist "%SCRIPT_DIR%\packages\ui\dist\index.html" ( @@ -208,7 +201,7 @@ if exist "%SCRIPT_DIR%\packages\ui\dist\index.html" ( echo [INFO] Building UI assets... pushd packages\ui call npm run build - if %ERRORLEVEL% neq 0 ( + if !ERRORLEVEL! neq 0 ( echo [ERROR] UI build failed! popd set /a ERRORS+=1 @@ -227,11 +220,11 @@ 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 %HEALTH_ERRORS% equ 0 ( +if !HEALTH_ERRORS! equ 0 ( echo [OK] Health checks passed ) else ( - echo [ERROR] Health checks failed (%HEALTH_ERRORS%) - set /a ERRORS+=%HEALTH_ERRORS% + echo [ERROR] Health checks failed: !HEALTH_ERRORS! issues + set /a ERRORS+=!HEALTH_ERRORS! ) echo. @@ -241,18 +234,18 @@ echo Install Dir: %TARGET_DIR% echo Architecture: %ARCH% echo Node.js: %NODE_VERSION% echo npm: %NPM_VERSION% -if %SKIP_OPENCODE% equ 1 ( - echo Mode: Binary-Free Mode ^(OpenCode Zen free models available^) +if !SKIP_OPENCODE! equ 1 ( + echo Mode: Binary-Free Mode ) else ( - echo Mode: Full Mode ^(OpenCode binary installed^) + echo Mode: Full Mode with OpenCode binary ) -echo Errors: %ERRORS% -echo Warnings: %WARNINGS% +echo Errors: !ERRORS! +echo Warnings: !WARNINGS! echo Log File: %LOG_FILE% echo. :SUMMARY -if %ERRORS% gtr 0 ( +if !ERRORS! gtr 0 ( echo [RESULT] Installation completed with errors. echo Review the log: %LOG_FILE% echo. @@ -261,9 +254,9 @@ if %ERRORS% gtr 0 ( echo [RESULT] Installation completed successfully. echo Run Launch-Windows.bat to start the application. echo. - if %SKIP_OPENCODE% equ 1 ( + if !SKIP_OPENCODE! equ 1 ( echo NOTE: Running in Binary-Free Mode. - echo Free models ^(GPT-5 Nano, Grok Code, GLM-4.7, etc.^) are available. + echo Free models: GPT-5 Nano, Grok Code, GLM-4.7, etc. echo You can also authenticate with Qwen for additional models. ) ) @@ -271,4 +264,4 @@ if %ERRORS% gtr 0 ( echo. echo Press any key to exit... pause >nul -exit /b %ERRORS% +exit /b !ERRORS! diff --git a/Launch-Windows.bat b/Launch-Windows.bat index 8a1cf06..e18a813 100644 --- a/Launch-Windows.bat +++ b/Launch-Windows.bat @@ -43,33 +43,37 @@ for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i echo [OK] npm: %NPM_VERSION% echo. -echo [PREFLIGHT 2/7] Checking OpenCode CLI (Optional)... +echo [PREFLIGHT 2/7] Checking OpenCode CLI... where opencode >nul 2>&1 if %ERRORLEVEL% equ 0 ( - echo [OK] OpenCode CLI available in PATH - Full Mode -) else ( - if exist "bin\opencode.exe" ( - echo [OK] OpenCode binary found in bin/ - Full Mode - ) else ( - echo [INFO] OpenCode CLI not found - Using Binary-Free Mode - echo [INFO] Free models (GPT-5 Nano, Grok Code, GLM-4.7) available via OpenCode Zen - set BINARY_FREE_MODE=1 - ) + echo [OK] OpenCode CLI in PATH - Full Mode + goto :opencode_check_done ) +if exist "bin\opencode.exe" ( + echo [OK] OpenCode binary in bin/ - Full Mode + goto :opencode_check_done +) + +echo [INFO] OpenCode CLI not found - Using Binary-Free Mode +echo [INFO] Free models: GPT-5 Nano, Grok Code, GLM-4.7 via OpenCode Zen +set BINARY_FREE_MODE=1 + +:opencode_check_done + echo. echo [PREFLIGHT 3/7] Checking Dependencies... if not exist "node_modules" ( echo [INFO] Dependencies not installed. Installing now... call npm install - if %ERRORLEVEL% neq 0 ( + if !ERRORLEVEL! neq 0 ( echo [ERROR] Dependency installation failed! pause exit /b 1 ) - echo [OK] Dependencies installed (auto-fix) + echo [OK] Dependencies installed set /a AUTO_FIXED+=1 ) else ( echo [OK] Dependencies found @@ -107,14 +111,14 @@ if not exist "packages\ui\dist\index.html" ( echo [INFO] Running UI build... pushd packages\ui call npm run build - if %ERRORLEVEL% neq 0 ( + if !ERRORLEVEL! neq 0 ( echo [ERROR] UI build failed! popd set /a ERRORS+=1 goto :final_launch_check ) popd - echo [OK] UI build completed (auto-fix) + echo [OK] UI build completed set /a AUTO_FIXED+=1 ) else ( echo [OK] UI build directory exists @@ -124,12 +128,12 @@ if not exist "packages\electron-app\dist\main\main.js" ( echo [WARN] Electron build incomplete echo [INFO] Running full build... call npm run build - if %ERRORLEVEL% neq 0 ( + if !ERRORLEVEL! neq 0 ( echo [ERROR] Full build failed! set /a ERRORS+=1 goto :final_launch_check ) - echo [OK] Full build completed (auto-fix) + echo [OK] Full build completed set /a AUTO_FIXED+=1 ) @@ -140,19 +144,19 @@ echo [STATUS] echo. echo Node.js: %NODE_VERSION% echo npm: %NPM_VERSION% -if %BINARY_FREE_MODE% equ 1 ( - echo Mode: Binary-Free Mode ^(No OpenCode binary required^) +if !BINARY_FREE_MODE! equ 1 ( + echo Mode: Binary-Free Mode echo Free Models: GPT-5 Nano, Grok Code, GLM-4.7, Doubao, Big Pickle ) else ( - echo Mode: Full Mode ^(OpenCode binary available^) + echo Mode: Full Mode with OpenCode ) echo Auto-fixes applied: !AUTO_FIXED! -echo Warnings: %WARNINGS% -echo Errors: %ERRORS% +echo Warnings: !WARNINGS! +echo Errors: !ERRORS! echo Server Port: !SERVER_PORT! echo. -if %ERRORS% gtr 0 ( +if !ERRORS! gtr 0 ( echo [RESULT] Cannot start due to errors! echo. echo Please fix the errors above and try again. @@ -188,14 +192,14 @@ echo ======================================== set "VITE_DEV_SERVER_URL=http://localhost:!UI_PORT!" set "NOMADARCH_OPEN_DEVTOOLS=false" -set "NOMADARCH_BINARY_FREE_MODE=%BINARY_FREE_MODE%" +set "NOMADARCH_BINARY_FREE_MODE=!BINARY_FREE_MODE!" call npm run dev:electron -if %ERRORLEVEL% neq 0 ( +if !ERRORLEVEL! neq 0 ( echo. echo [ERROR] NomadArch exited with an error! echo. - echo Error Code: %ERRORLEVEL% + echo Error Code: !ERRORLEVEL! echo. echo Troubleshooting: echo 1. Ensure port !SERVER_PORT! is not in use @@ -208,4 +212,4 @@ if %ERRORLEVEL% neq 0 ( echo. echo Press any key to exit... pause >nul -exit /b %ERRORS% +exit /b !ERRORS! diff --git a/package-lock.json b/package-lock.json index 9baee2d..7d2ae4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codenomad-workspace", - "version": "0.4.0", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codenomad-workspace", - "version": "0.4.0", + "version": "0.5.0", "dependencies": { "7zip-bin": "^5.2.0", "google-auth-library": "^10.5.0"