@echo off
setlocal EnableExtensions
cd /d "%~dp0"
set "RUNTIME=%CD%\App\data\runtime"
set "HISTORY=%RUNTIME%\history"

:menu
cls
echo ================================================================
echo  PhUCKIT Runtime Truth Bundles
echo ================================================================
echo.
echo  Calculator bundle:
if exist "%RUNTIME%\active-calculator-truths.ini" (
  findstr /b "version=" "%RUNTIME%\active-calculator-truths.ini"
) else (
  echo  MISSING - PhUCKIT will use bundled fallback behavior.
)
echo.
echo  Finding-rule bundle:
if exist "%RUNTIME%\active-finding-rules.ini" (
  findstr /b "version=" "%RUNTIME%\active-finding-rules.ini"
) else (
  echo  MISSING - PhUCKIT will use bundled fallback behavior.
)
echo.
echo  1. Open runtime bundle folder
echo  2. Restore bundled RC14 calculator snapshot
echo  3. Restore bundled RC14 finding-rule snapshot
echo  4. Restore both bundled RC14 snapshots
echo  5. Exit
echo.
choice /c 12345 /n /m "Choose: "
if errorlevel 5 exit /b 0
if errorlevel 4 (
  copy /y "%HISTORY%\calculator-truths-2026.08.01-rc12.ini" "%RUNTIME%\active-calculator-truths.ini" >nul
  copy /y "%HISTORY%\finding-rules-2026.08.01-rc14.ini" "%RUNTIME%\active-finding-rules.ini" >nul
  echo Both truth bundles restored. Restart PhUCKIT.
  pause
  goto menu
)
if errorlevel 3 (
  copy /y "%HISTORY%\finding-rules-2026.08.01-rc14.ini" "%RUNTIME%\active-finding-rules.ini" >nul
  echo Finding-rule bundle restored. Restart PhUCKIT.
  pause
  goto menu
)
if errorlevel 2 (
  copy /y "%HISTORY%\calculator-truths-2026.08.01-rc12.ini" "%RUNTIME%\active-calculator-truths.ini" >nul
  echo Calculator bundle restored. Restart PhUCKIT.
  pause
  goto menu
)
if errorlevel 1 start "" "%RUNTIME%" & goto menu
