fix: make Forge deck paths fully portable using %~dp0 and auto-generate forge.profile.properties
This commit is contained in:
1 parent
d98e6331e9
commit
535bdd7c70
1 file changed
+57
-29
+57
-29
@@ -7,38 +7,63 @@ REM Starts the Python FastAPI server + serves the web UI.
|
|||||||
REM Prerequisites:
|
REM Prerequisites:
|
||||||
REM - Python 3.10+ with: pip install fastapi uvicorn
|
REM - Python 3.10+ with: pip install fastapi uvicorn
|
||||||
REM - Java 17+
|
REM - Java 17+
|
||||||
REM - commander-ai-lab built: mvn package "-DskipTests"
|
REM - Forge built: mvn package "-DskipTests"
|
||||||
REM
|
REM
|
||||||
REM Edit the paths below to match your system.
|
REM All paths are resolved RELATIVE to this script's location.
|
||||||
|
REM No hardcoded drive letters — works on any machine.
|
||||||
REM ═══════════════════════════════════════════════════════════
|
REM ═══════════════════════════════════════════════════════════
|
||||||
REM ── Your Forge paths (EDIT THESE) ──────────────────────────
|
|
||||||
set FORGE_JAR=D:\ForgeCommander\forge-repo\forge-gui-desktop\target\forge-gui-desktop-2.0.12-SNAPSHOT-jar-with-dependencies.jar
|
REM ── Resolve root from script location (portable, any drive) ─
|
||||||
set FORGE_DIR=D:\ForgeCommander\forge-repo
|
set SCRIPT_DIR=%~dp0
|
||||||
REM Precon-decks folder — Forge reads .dck files directly from here.
|
set FORGE_COMMANDER_ROOT=%SCRIPT_DIR%..
|
||||||
REM This is also used as the source for precon install endpoints.
|
|
||||||
set FORGE_DECKS_DIR=D:\ForgeCommander\commander-ai-lab\precon-decks
|
REM ── Forge paths (auto-resolved, no hardcoded drive) ─────────
|
||||||
set PRECON_DECKS_DIR=D:\ForgeCommander\commander-ai-lab\precon-decks
|
set FORGE_JAR=%FORGE_COMMANDER_ROOT%\forge-repo\forge-gui-desktop\target\forge-gui-desktop-2.0.12-SNAPSHOT-jar-with-dependencies.jar
|
||||||
REM ── Lab JAR (auto-detected from target/) ─────────────────────
|
set FORGE_DIR=%FORGE_COMMANDER_ROOT%\forge-repo
|
||||||
|
set FORGE_PROFILE=%FORGE_COMMANDER_ROOT%\forge-repo\forge-gui-desktop\target\res\forge.profile.properties
|
||||||
|
|
||||||
|
REM ── Deck paths: all inside forge-repo for full portability ──
|
||||||
|
set FORGE_USER_DATA=%FORGE_COMMANDER_ROOT%\forge-repo\userdata
|
||||||
|
set FORGE_DECKS_DIR=%FORGE_USER_DATA%\decks
|
||||||
|
set PRECON_DECKS_DIR=%SCRIPT_DIR%precon-decks
|
||||||
|
|
||||||
|
REM ── Lab server port ──────────────────────────────────────────
|
||||||
set LAB_PORT=8080
|
set LAB_PORT=8080
|
||||||
|
|
||||||
REM ── API Keys (set via environment variables or .env file) ──
|
REM ── API Keys (set via environment variables or .env file) ──
|
||||||
REM If not already set in your environment, create a .env file
|
|
||||||
REM in this directory (see .env.example) or set them manually:
|
|
||||||
REM set XIMILAR_API_KEY=your-ximilar-key-here
|
|
||||||
REM set ANTHROPIC_API_KEY=your-anthropic-api-key-here
|
|
||||||
REM
|
|
||||||
REM Load from .env file if it exists and vars aren't already set
|
|
||||||
if not defined XIMILAR_API_KEY (
|
if not defined XIMILAR_API_KEY (
|
||||||
if exist "%~dp0.env" (
|
if exist "%SCRIPT_DIR%.env" (
|
||||||
for /f "usebackq tokens=1,* delims==" %%A in ("%~dp0.env") do (
|
for /f "usebackq tokens=1,* delims==" %%A in ("%SCRIPT_DIR%.env") do (
|
||||||
if "%%A"=="XIMILAR_API_KEY" set XIMILAR_API_KEY=%%B
|
if "%%A"=="XIMILAR_API_KEY" set XIMILAR_API_KEY=%%B
|
||||||
if "%%A"=="ANTHROPIC_API_KEY" set ANTHROPIC_API_KEY=%%B
|
if "%%A"=="ANTHROPIC_API_KEY" set ANTHROPIC_API_KEY=%%B
|
||||||
if "%%A"=="PRECON_DECKS_DIR" set PRECON_DECKS_DIR=%%B
|
|
||||||
if "%%A"=="FORGE_DECKS_DIR" set FORGE_DECKS_DIR=%%B
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
REM ═══════════════════════════════════════════════════════════
|
||||||
|
REM Write forge.profile.properties so Forge resolves decks from
|
||||||
|
REM forge-repo\userdata instead of %APPDATA%\Forge.
|
||||||
|
REM Backslashes are doubled as required by .properties format.
|
||||||
|
REM This is rewritten every launch so it always matches the
|
||||||
|
REM current machine's absolute path.
|
||||||
|
REM ═══════════════════════════════════════════════════════════
|
||||||
|
mkdir "%FORGE_USER_DATA%\decks\commander" 2>nul
|
||||||
|
|
||||||
|
REM Build escaped paths for .properties file
|
||||||
|
set _UD=%FORGE_USER_DATA%
|
||||||
|
set _DD=%FORGE_DECKS_DIR%
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
set _UD_ESC=!_UD:\=\\!
|
||||||
|
set _DD_ESC=!_DD:\=\\!
|
||||||
|
(echo userDir=!_UD_ESC!) > "%FORGE_PROFILE%"
|
||||||
|
(echo decksDir=!_DD_ESC!) >> "%FORGE_PROFILE%"
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
REM ── Copy precon .dck files into Forge's commander deck folder
|
||||||
|
REM (idempotent — safe to run every launch)
|
||||||
|
xcopy /Y /Q "%PRECON_DECKS_DIR%\*.dck" "%FORGE_DECKS_DIR%\commander\" >nul 2>&1
|
||||||
|
echo Synced precon decks to Forge commander folder.
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ╔══════════════════════════════════════════════════╗
|
echo ╔══════════════════════════════════════════════════╗
|
||||||
echo ║ Commander AI Lab — Launcher ║
|
echo ║ Commander AI Lab — Launcher ║
|
||||||
@@ -49,11 +74,15 @@ echo Forge Dir: %FORGE_DIR%
|
|||||||
echo Decks Dir: %FORGE_DECKS_DIR%
|
echo Decks Dir: %FORGE_DECKS_DIR%
|
||||||
echo Precon Dir: %PRECON_DECKS_DIR%
|
echo Precon Dir: %PRECON_DECKS_DIR%
|
||||||
echo Port: %LAB_PORT%
|
echo Port: %LAB_PORT%
|
||||||
|
if defined XIMILAR_API_KEY (
|
||||||
echo Ximilar: Configured
|
echo Ximilar: Configured
|
||||||
if defined ANTHROPIC_API_KEY (
|
|
||||||
echo Claude Opus: Configured
|
|
||||||
) else (
|
) else (
|
||||||
echo Claude Opus: Not configured ^(set ANTHROPIC_API_KEY env var for AI features^)
|
echo Ximilar: Not configured
|
||||||
|
)
|
||||||
|
if defined ANTHROPIC_API_KEY (
|
||||||
|
echo Claude: Configured
|
||||||
|
) else (
|
||||||
|
echo Claude: Not configured ^(set ANTHROPIC_API_KEY for AI features^)
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
@@ -75,15 +104,14 @@ if %ERRORLEVEL% neq 0 (
|
|||||||
if not exist "%FORGE_JAR%" (
|
if not exist "%FORGE_JAR%" (
|
||||||
echo ERROR: Forge JAR not found at: %FORGE_JAR%
|
echo ERROR: Forge JAR not found at: %FORGE_JAR%
|
||||||
echo Run Forge build first:
|
echo Run Forge build first:
|
||||||
echo cd D:\ForgeCommander\forge-repo
|
echo cd %FORGE_DIR%
|
||||||
echo mvn package -pl forge-gui-desktop "-DskipTests" "-Drevision=2.0.12-SNAPSHOT" -am
|
echo mvn package -pl forge-gui-desktop "-DskipTests" "-Drevision=2.0.12-SNAPSHOT" -am
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
REM ── Check if lab_api.py exists ─────────────────────────────
|
if not exist "%SCRIPT_DIR%lab_api.py" (
|
||||||
if not exist "%~dp0lab_api.py" (
|
echo ERROR: lab_api.py not found in %SCRIPT_DIR%
|
||||||
echo ERROR: lab_api.py not found in %~dp0
|
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
@@ -104,7 +132,7 @@ echo Press Ctrl+C to stop.
|
|||||||
echo.
|
echo.
|
||||||
|
|
||||||
if defined ANTHROPIC_API_KEY (
|
if defined ANTHROPIC_API_KEY (
|
||||||
python "%~dp0lab_api.py" ^
|
python "%SCRIPT_DIR%lab_api.py" ^
|
||||||
--forge-jar "%FORGE_JAR%" ^
|
--forge-jar "%FORGE_JAR%" ^
|
||||||
--forge-dir "%FORGE_DIR%" ^
|
--forge-dir "%FORGE_DIR%" ^
|
||||||
--forge-decks-dir "%FORGE_DECKS_DIR%" ^
|
--forge-decks-dir "%FORGE_DECKS_DIR%" ^
|
||||||
@@ -113,7 +141,7 @@ if defined ANTHROPIC_API_KEY (
|
|||||||
--ximilar-key "%XIMILAR_API_KEY%" ^
|
--ximilar-key "%XIMILAR_API_KEY%" ^
|
||||||
--anthropic-key "%ANTHROPIC_API_KEY%"
|
--anthropic-key "%ANTHROPIC_API_KEY%"
|
||||||
) else (
|
) else (
|
||||||
python "%~dp0lab_api.py" ^
|
python "%SCRIPT_DIR%lab_api.py" ^
|
||||||
--forge-jar "%FORGE_JAR%" ^
|
--forge-jar "%FORGE_JAR%" ^
|
||||||
--forge-dir "%FORGE_DIR%" ^
|
--forge-dir "%FORGE_DIR%" ^
|
||||||
--forge-decks-dir "%FORGE_DECKS_DIR%" ^
|
--forge-decks-dir "%FORGE_DECKS_DIR%" ^
|
||||||
|
|||||||
Reference in new issue
Block a user