@echo off
setlocal EnableExtensions
set "LOG=%TEMP%\hermes-touch-strixg18-install-h2.log"
call :main > "%LOG%" 2>&1
exit /b %ERRORLEVEL%

:main
echo === HERMES H2 START %DATE% %TIME% ===
echo Hostname:
hostname
echo Whoami:
whoami
set "PY=%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
if not exist "%PY%" set "PY=C:\Python312\python.exe"
if not exist "%PY%" (
  echo [INFO] Python not found at known paths; installing Python 3.12...
  winget install -e --id Python.Python.3.12 --accept-package-agreements --accept-source-agreements
  set "PY=%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
)
if not exist "%PY%" (
  echo [ERROR] Python exe not found after install attempts.
  dir "%LOCALAPPDATA%\Programs\Python" /s /b
  exit /b 2
)
echo [INFO] Using Python: %PY%
"%PY%" --version
"%PY%" -m ensurepip --upgrade
"%PY%" -m pip install --upgrade pip pipx
where git >nul 2>&1
if %errorlevel% neq 0 (
  echo [INFO] Git not found; installing Git...
  winget install -e --id Git.Git --accept-package-agreements --accept-source-agreements
)
"%PY%" -m pipx ensurepath
"%PY%" -m pipx install --force git+https://github.com/NousResearch/hermes-agent.git
set "HERMES_EXE=%USERPROFILE%\.local\bin\hermes.exe"
if not exist "%HERMES_EXE%" (
  echo [ERROR] Hermes exe not found at %HERMES_EXE%
  dir "%USERPROFILE%\.local" /s /b
  exit /b 3
)
"%HERMES_EXE%" --version
"%HERMES_EXE%" doctor
"%HERMES_EXE%" skills list
echo === HERMES H2 DONE %DATE% %TIME% ===
exit /b 0
