Skip to content

Instantly share code, notes, and snippets.

@zbyhoo
Last active April 16, 2026 10:07
Show Gist options
  • Select an option

  • Save zbyhoo/89272e07c138ff491f3ffc407c2ce39f to your computer and use it in GitHub Desktop.

Select an option

Save zbyhoo/89272e07c138ff491f3ffc407c2ce39f to your computer and use it in GitHub Desktop.
Gamesture — Codex CLI Setup (Windows)
@echo off
chcp 65001 >nul 2>&1
setlocal EnableDelayedExpansion
REM ---------------------------------------------------------------------------
REM Gamesture -- Codex CLI Setup (Windows)
REM
REM Instaluje wszystko co potrzebne:
REM 1. Git for Windows
REM 2. Codex CLI
REM 3. GitHub SSH (auto-generowanie klucza + pomoc)
REM 4. Tailscale (sprawdzenie polaczenia z siecia firmowa)
REM 5. Clone marketplace + export skills
REM 6. Konfiguracja MCP + rules
REM
REM Po zakonczeniu uzytkownik uruchamia: codex -> /gs-onboarding
REM ---------------------------------------------------------------------------
set "REPO=gamesture/marketplace"
set "CODEX_HOME=%USERPROFILE%\.codex"
set "MARKETPLACE_DIR=%CODEX_HOME%\gamesture-marketplace"
echo.
echo =====================================
echo Gamesture -- Codex CLI Setup
echo =====================================
REM -- Krok 1: Git --------------------------------------------------------------
echo.
echo -- Krok 1/7: Git
where git >nul 2>&1
if !ERRORLEVEL! neq 0 (
echo [!!] Git nie znaleziony w PATH. Szukam w standardowych lokalizacjach...
if exist "C:\Program Files\Git\cmd\git.exe" (
set "PATH=!PATH!;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin"
echo [OK] Znaleziono Git w C:\Program Files\Git
)
)
where git >nul 2>&1
if %ERRORLEVEL% equ 0 (
for /f "tokens=*" %%v in ('git --version') do echo [OK] %%v
) else (
echo [!!] Git nie jest zainstalowany. Instaluje...
where winget >nul 2>&1
if !ERRORLEVEL! equ 0 (
winget install --id Git.Git -e --accept-package-agreements --accept-source-agreements
) else (
echo [X] winget niedostepny. Zainstaluj Git for Windows recznie:
echo https://git-scm.com/downloads/win
start "" "https://git-scm.com/downloads/win"
exit /b 1
)
call :RefreshPath
if exist "C:\Program Files\Git\cmd" set "PATH=!PATH!;C:\Program Files\Git\cmd"
if exist "C:\Program Files\Git\usr\bin" set "PATH=!PATH!;C:\Program Files\Git\usr\bin"
where git >nul 2>&1
if !ERRORLEVEL! neq 0 (
echo [X] Git zainstalowany, ale nie widoczny w PATH.
echo Zamknij terminal, otworz nowy i uruchom ponownie.
exit /b 1
)
for /f "tokens=*" %%v in ('git --version') do echo [OK] %%v
)
call :EnsureSsh
if %ERRORLEVEL% neq 0 exit /b 1
REM -- Krok 2: Codex CLI -------------------------------------------------------
echo.
echo -- Krok 2/7: Codex CLI
echo !PATH! | findstr /i /c:".local\bin" >nul 2>&1 || set "PATH=!PATH!;%USERPROFILE%\.local\bin"
echo !PATH! | findstr /i /c:"AppData\Roaming\npm" >nul 2>&1 || set "PATH=!PATH!;%APPDATA%\npm"
where codex >nul 2>&1
if !ERRORLEVEL! equ 0 goto :CodexFound
echo [!!] Codex CLI nie znaleziony. Instaluje...
where npm >nul 2>&1
if !ERRORLEVEL! equ 0 (
npm install -g @openai/codex
call :RefreshPath
where codex >nul 2>&1
if !ERRORLEVEL! neq 0 (
echo [X] Codex CLI zainstalowany, ale nie widoczny w PATH.
echo Zamknij terminal, otworz nowy i uruchom ponownie.
exit /b 1
)
echo [OK] Codex CLI zainstalowany
) else (
echo [X] npm nie jest dostepny. Zainstaluj Node.js:
echo winget install --id OpenJS.NodeJS.LTS -e --accept-package-agreements --accept-source-agreements
echo Potem uruchom: npm install -g @openai/codex
exit /b 1
)
goto :AfterCodex
:CodexFound
for /f "tokens=*" %%v in ('codex --version 2^>nul') do set "CODEX_VER=%%v"
echo [OK] Juz zainstalowany (!CODEX_VER!)
:AfterCodex
REM -- Krok 3: GitHub SSH -------------------------------------------------------
echo.
echo -- Krok 3/7: GitHub SSH
set "SSH_KEY=%USERPROFILE%\.ssh\id_ed25519"
set "SSH_DIR=%USERPROFILE%\.ssh"
set "KNOWN_HOSTS=%SSH_DIR%\known_hosts"
if not exist "%SSH_DIR%" mkdir "%SSH_DIR%"
if not exist "%KNOWN_HOSTS%" type nul > "%KNOWN_HOSTS%"
findstr /c:"github.com" "%KNOWN_HOSTS%" >nul 2>&1
if !ERRORLEVEL! neq 0 (
ssh-keyscan -T 5 -t ed25519,rsa github.com >> "%KNOWN_HOSTS%" 2>nul
)
REM Wymus Windows OpenSSH dla Git (MinGW SSH z Git for Windows zle koduje polskie znaki)
REM UWAGA: forward slashes w GIT_SSH_COMMAND — MinGW sh.exe interpretuje backslashes
REM jako escape (C:\Windows -> C:Windows). Forward slashes dzialaja w cmd.exe i MinGW.
set "WIN_SSH_CHECK=C:\Windows\System32\OpenSSH\ssh.exe"
set "WIN_SSH=C:/Windows/System32/OpenSSH/ssh.exe"
if exist "!WIN_SSH_CHECK!" (
REM Naprawa dla starszych instalacji (backslashes w GIT_SSH_COMMAND psuja MinGW).
set "SSH_NEEDS_FIX="
if not defined GIT_SSH_COMMAND set "SSH_NEEDS_FIX=1"
if defined GIT_SSH_COMMAND (
echo !GIT_SSH_COMMAND! | findstr /c:"\Windows\System32\OpenSSH" >nul 2>&1
if !ERRORLEVEL! equ 0 set "SSH_NEEDS_FIX=1"
)
if defined SSH_NEEDS_FIX (
set "GIT_SSH_COMMAND=!WIN_SSH!"
setx GIT_SSH_COMMAND "!WIN_SSH!" >nul 2>&1
echo [OK] Git SSH: ustawiono Windows OpenSSH ^(kompatybilnosc z polskimi znakami^)
)
)
git -c core.sshCommand="ssh -o StrictHostKeyChecking=accept-new" ls-remote "git@github.com:%REPO%.git" HEAD >nul 2>&1 && (
echo [OK] GitHub SSH -- autoryzacja OK
goto :AfterSsh
)
REM SSH nie dziala -- wygeneruj klucz
if not exist "%SSH_KEY%" (
echo [!!] Brak klucza SSH. Generuje nowy...
ssh-keygen -t ed25519 -C "gamesture" -f "%SSH_KEY%" -N "" -q < NUL
if not exist "%SSH_KEY%" (
echo [X] Wygeneruj klucz recznie: ssh-keygen -t ed25519 -C "gamesture"
exit /b 1
)
icacls "%SSH_KEY%" /inheritance:r >nul 2>&1
icacls "%SSH_KEY%" /grant:r "%USERNAME%:R" >nul 2>&1
echo [OK] Klucz wygenerowany
)
echo.
echo Musisz dodac klucz SSH do swojego konta GitHub.
type "%SSH_KEY%.pub" | clip
echo [OK] Klucz SSH skopiowany do schowka!
start "" "https://github.com/settings/ssh/new"
echo.
echo Wklej klucz na GitHub i kliknij 'Add SSH key'
pause
git -c core.sshCommand="ssh -o StrictHostKeyChecking=accept-new" ls-remote "git@github.com:%REPO%.git" HEAD >nul 2>&1 && (
echo [OK] GitHub SSH -- autoryzacja OK
goto :AfterSsh
)
echo [X] SSH nadal nie dziala. Uruchom skrypt ponownie po dodaniu klucza.
echo Napisz do @zkominek na Slacku jesli potrzebujesz dostepu do organizacji.
exit /b 1
:AfterSsh
REM -- Krok 4: Tailscale --------------------------------------------------------
echo.
echo -- Krok 4/7: Tailscale
set "TS_EXE="
if exist "C:\Program Files\Tailscale\tailscale.exe" set "TS_EXE=C:\Program Files\Tailscale\tailscale.exe"
if "!TS_EXE!"=="" (
where tailscale >nul 2>&1 && for /f "tokens=*" %%t in ('where tailscale') do set "TS_EXE=%%t"
)
if "!TS_EXE!"=="" (
echo [X] Tailscale nie jest zainstalowany.
echo Zainstaluj: https://tailscale.com/download/windows
echo Po instalacji uruchom skrypt ponownie.
exit /b 1
)
"!TS_EXE!" status >nul 2>&1
if "!ERRORLEVEL!"=="0" (
echo [OK] Tailscale polaczony
) else (
echo [!!] Tailscale zainstalowany, ale nie polaczony.
echo Wlacz Tailscale i zaloguj sie do sieci firmowej.
pause
"!TS_EXE!" status >nul 2>&1
if "!ERRORLEVEL!" neq "0" (
echo [X] Tailscale nadal nie polaczony. Uruchom ponownie.
exit /b 1
)
echo [OK] Tailscale polaczony
)
REM -- Krok 5: Clone marketplace + export skills --------------------------------
echo.
echo -- Krok 5/7: Marketplace + Skills
set "GIT_TERMINAL_PROMPT=0"
REM Upewnij sie ze GIT_SSH_COMMAND ma forward slashes.
REM Krok 3 testuje SSH przez core.sshCommand override (StrictHostKeyChecking),
REM wiec test przechodzi nawet gdy GIT_SSH_COMMAND ma backslashes.
REM Tutaj git clone uzywa GIT_SSH_COMMAND bezposrednio — musi byc poprawny.
if exist "C:\Windows\System32\OpenSSH\ssh.exe" set "GIT_SSH_COMMAND=C:/Windows/System32/OpenSSH/ssh.exe"
if not exist "%USERPROFILE%\.agents\skills" mkdir "%USERPROFILE%\.agents\skills"
if exist "%MARKETPLACE_DIR%\.git" (
echo [OK] Marketplace repo juz sklonowane
echo Aktualizuje...
cd /d "%MARKETPLACE_DIR%" && git pull --ff-only >nul 2>&1
) else (
echo Klonuje marketplace...
git clone "git@github.com:%REPO%.git" "%MARKETPLACE_DIR%"
echo [OK] Marketplace sklonowane
)
REM -- Krok 6: Symlink skills ---------------------------------------------------
echo.
echo -- Krok 6/7: Instalacja skills
REM Symlink (junction) calego katalogu skills
set "AGENTS_SKILLS=%USERPROFILE%\.agents\skills"
if exist "%AGENTS_SKILLS%\gamesture" rmdir "%AGENTS_SKILLS%\gamesture" >nul 2>&1
mklink /J "%AGENTS_SKILLS%\gamesture" "%MARKETPLACE_DIR%\codex\skills" >nul 2>&1
set "SKILL_COUNT=0"
for /d %%d in ("%MARKETPLACE_DIR%\codex\skills\gs-*") do set /a SKILL_COUNT+=1
echo [OK] !SKILL_COUNT! skills zainstalowanych
REM -- Krok 7: MCP + Rules -----------------------------------------------------
echo.
echo -- Krok 7/7: Konfiguracja MCP + Rules
REM Dodaj MCP servers do config.toml
python3 -c "import os; config_path = os.path.expanduser(r'%CODEX_HOME%\config.toml'); content = open(config_path,'r').read() if os.path.exists(config_path) else ''; f = open(config_path,'a'); wrote = False; [f.write(s) or setattr(type('',(),{'x':True}),'x',True) for s in ['\n[mcp_servers.gamesture-mcp-hub]\nurl = \"http://mcp-hub:9000/mcp\"\n' if 'gamesture-mcp-hub' not in content else '', '\n[mcp_servers.context7]\ncommand = \"npx\"\nargs = [\"-y\", \"@upstash/context7-mcp\"]\n' if 'context7' not in content else ''] if s]; f.close(); print('MCP servers zaktualizowane')" 2>nul
echo [OK] MCP config zaktualizowany
REM Permission rules
if not exist "%CODEX_HOME%\rules" mkdir "%CODEX_HOME%\rules"
if not exist "%CODEX_HOME%\rules\gamesture.rules" (
(
echo prefix_rule^(pattern=["curl"], decision="allow"^)
echo prefix_rule^(pattern=["git", "add"], decision="allow"^)
echo prefix_rule^(pattern=["git", "commit"], decision="allow"^)
echo prefix_rule^(pattern=["npm", "install"], decision="allow"^)
) > "%CODEX_HOME%\rules\gamesture.rules"
echo [OK] Permission rules dodane
) else (
echo [OK] Permission rules juz istnieja
)
REM -- Gotowe -------------------------------------------------------------------
echo.
echo =====================================
echo Setup zakonczony!
echo =====================================
echo.
echo Zainstalowano: !SKILL_COUNT! skills
echo MCP Hub: gamesture-mcp-hub
echo.
echo Uruchom: codex
echo Potem wpisz: /gs-onboarding
echo =====================================
echo.
endlocal & set "PATH=%PATH%"
exit /b 0
REM ---------------------------------------------------------------------------
REM Funkcje pomocnicze
REM ---------------------------------------------------------------------------
:RefreshPath
for /f "tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path 2^>nul') do set "SYS_PATH=%%b"
for /f "tokens=2*" %%a in ('reg query "HKCU\Environment" /v Path 2^>nul') do set "USR_PATH=%%b"
set "PATH=!SYS_PATH!;!USR_PATH!"
exit /b 0
:EnsureSsh
where ssh >nul 2>&1
if %ERRORLEVEL% equ 0 exit /b 0
where git >nul 2>&1
if %ERRORLEVEL% equ 0 (
for /f "tokens=*" %%g in ('where git') do set "GIT_PATH=%%~dpg"
set "GIT_USR_BIN=!GIT_PATH!..\usr\bin"
if exist "!GIT_USR_BIN!" set "PATH=!PATH!;!GIT_USR_BIN!"
)
where ssh >nul 2>&1
if %ERRORLEVEL% equ 0 exit /b 0
echo [X] ssh nie jest dostepny. Wlacz OpenSSH Client:
echo Windows Settings -^> Apps -^> Optional Features -^> OpenSSH Client
exit /b 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment