@echo off
chcp 65001 >nul 2>&1
setlocal EnableDelayedExpansion

echo ============================================
echo   Soar MCP — Emergency Unlock Tool
echo ============================================
echo.

set "TARGET=%LOCALAPPDATA%\SoarAutoCADMCP"

if not exist "%TARGET%" (
    echo [!] Lock folder not found.
    echo     MCP may not be installed or has not been locked.
    pause
    goto :eof
)

set "FIXED=0"

if exist "%TARGET%\.Cac_Chk" (
    del /f /q "%TARGET%\.Cac_Chk" >nul 2>&1
    echo [OK] Removed local kill switch
    set "FIXED=1"
) else (
    echo [--] Kill switch not found, skipping
)

if exist "%TARGET%\telemetry.json" (
    del /f /q "%TARGET%\telemetry.json" >nul 2>&1
    echo [OK] Removed telemetry log
    set "FIXED=1"
) else (
    echo [--] Telemetry log not found, skipping
)

echo.
if "!FIXED!"=="1" (
    echo ============================================
    echo   Unlock complete! Please restart the MCP.
    echo ============================================
) else (
    echo   No files needed cleaning.
)

echo.
pause
endlocal
