@echo off
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul
rem ===== Auto-generated by scripts/gen-pack-installers.mjs — do not edit =====
rem Pack: Krea 2 Identity Edit — outfit swap
rem Run from your ComfyUI root (the folder containing custom_nodes\ and models\).
if not exist "custom_nodes" ( echo [ERROR] Run from your ComfyUI root ^(custom_nodes\ not found^). & pause & exit /b 1 )
where git >nul 2>&1 || ( echo [ERROR] git not found in PATH. & pause & exit /b 1 )
where curl >nul 2>&1 || ( echo [ERROR] curl not found in PATH. & pause & exit /b 1 )
rem Resolve the ComfyUI python: venv first, then portable embed, then PATH python.
set "PY=%CD%\.venv\Scripts\python.exe"
if not exist "%PY%" set "PY=%CD%\venv\Scripts\python.exe"
if not exist "%PY%" set "PY=%CD%\..\python_embeded\python.exe"
if not exist "%PY%" set "PY=python"
echo using python: %PY%

echo -------- custom nodes --------
call :clone "comfyui-krea2edit" "https://github.com/lbouaraba/comfyui-krea2edit"

echo -------- models --------
call :grab "models\diffusion_models\krea2_turbo_fp8_scaled.safetensors" "https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_turbo_fp8_scaled.safetensors"
call :grab "models\text_encoders\qwen3vl_4b_fp8_scaled.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/qwen3vl_4b_fp8_scaled.safetensors"
call :grab "models\vae\qwen_image_vae.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/qwen_image_vae.safetensors"
call :grab "models\loras\Krea2\krea2_identity_edit_v1_2.safetensors" "https://huggingface.co/conradlocke/krea2-identity-edit/resolve/main/krea2_identity_edit_v1_2.safetensors"

echo DONE. Restart ComfyUI, then load workflow.json.
pause
exit /b

:clone
if not exist "custom_nodes\%~1" (
  echo   cloning %~1
  git clone --depth 1 "%~2" "custom_nodes\%~1"
  if exist "custom_nodes\%~1\requirements.txt" ( echo   installing %~1 requirements.txt & "%PY%" -m pip install -r "custom_nodes\%~1\requirements.txt" )
) else ( echo   %~1 present - skip )
goto :eof

:grab
if not exist "%~dp1" mkdir "%~dp1"
if not exist "%~1" ( echo   downloading %~nx1 & curl -L --ssl-no-revoke -o "%~1" "%~2" ) else ( echo   %~nx1 present - skip )
goto :eof
