# 창진 에이전트(cjagent) 설치 스크립트 — Windows PowerShell # irm https://cjsoft.bonzaworld.live/download/install.ps1 | iex # 다른 서버에서 호스팅 시: $env:CJAGENT_BASE_URL 로 오버라이드. $ErrorActionPreference = "Stop" $Base = if ($env:CJAGENT_BASE_URL) { $env:CJAGENT_BASE_URL.TrimEnd('/') } else { "https://cjsoft.bonzaworld.live" } Write-Host "" Write-Host " 창진 에이전트(cjagent) 설치" -ForegroundColor Cyan Write-Host " ---------------------------" -ForegroundColor DarkGray # ── 1) Python 3.10+ 탐지 ── function Test-Py($exe, $pre) { try { $v = & $exe @pre --version 2>&1 if ($v -match 'Python (\d+)\.(\d+)') { $maj = [int]$Matches[1]; $min = [int]$Matches[2] if ($maj -gt 3 -or ($maj -eq 3 -and $min -ge 10)) { return $true } } } catch {} return $false } $PyExe = $null; $PyArgs = @() if ((Get-Command py -ErrorAction SilentlyContinue) -and (Test-Py 'py' @('-3'))) { $PyExe = 'py'; $PyArgs = @('-3') } elseif ((Get-Command python -ErrorAction SilentlyContinue) -and (Test-Py 'python' @())) { $PyExe = 'python' } elseif ((Get-Command python3 -ErrorAction SilentlyContinue) -and (Test-Py 'python3' @())) { $PyExe = 'python3' } if (-not $PyExe) { Write-Host " [오류] Python 3.10+ 가 필요합니다." -ForegroundColor Red Write-Host " https://www.python.org/downloads/ 에서 설치 후 다시 실행하세요." -ForegroundColor Yellow exit 1 } Write-Host (" Python : " + (& $PyExe @PyArgs --version 2>&1)) -ForegroundColor Gray # ── 2) 최신 버전 메타 (content-type/BOM에 견고하게 파싱) ── $Wheel = "cjagent-0.71.0-py3-none-any.whl" try { $raw = (Invoke-WebRequest "$Base/download/latest.json" -UseBasicParsing -TimeoutSec 10).Content if ($raw) { $raw = $raw.TrimStart([char]0xFEFF); $meta = $raw | ConvertFrom-Json; if ($meta.wheel) { $Wheel = $meta.wheel } } } catch {} $Url = "$Base/download/$Wheel" Write-Host " 패키지 : $Wheel" -ForegroundColor Gray # ── 3) 설치 (pipx 우선 → pip --user 폴백) ── if (Get-Command pipx -ErrorAction SilentlyContinue) { Write-Host " 방법 : pipx (격리 설치)" -ForegroundColor Gray Write-Host "" pipx install --force $Url if ($LASTEXITCODE -ne 0) { Write-Host " [오류] 설치 실패 (위 메시지를 확인하세요)." -ForegroundColor Red; exit 1 } } else { # pipx가 없으면 전용 가상환경(격리·안전) + 사용자 PATH 등록 Write-Host " 방법 : 전용 가상환경 (pipx 미설치)" -ForegroundColor Gray Write-Host "" $venv = Join-Path $env:LOCALAPPDATA "cjagent\venv" & $PyExe @PyArgs -m venv $venv if ($LASTEXITCODE -ne 0) { Write-Host " [오류] 가상환경 생성 실패." -ForegroundColor Red; exit 1 } & (Join-Path $venv "Scripts\python.exe") -m pip install --upgrade $Url if ($LASTEXITCODE -ne 0) { Write-Host " [오류] 설치 실패 (위 메시지를 확인하세요)." -ForegroundColor Red; exit 1 } $scripts = Join-Path $venv "Scripts" $userPath = [Environment]::GetEnvironmentVariable("Path", "User") if (-not $userPath) { $userPath = "" } if ($userPath -notlike "*$scripts*") { [Environment]::SetEnvironmentVariable("Path", ($userPath.TrimEnd(';') + ";" + $scripts), "User") Write-Host " PATH에 추가됨: $scripts (새 터미널부터 적용)" -ForegroundColor Gray } Write-Host " 실행 파일: $scripts\cjagent.exe" -ForegroundColor Gray } Write-Host "" Write-Host " 설치 완료!" -ForegroundColor Green Write-Host " 다음을 실행해 보세요:" -ForegroundColor White Write-Host " cjagent doctor # 환경 진단(모델 서버·PATH 확인)" -ForegroundColor Cyan Write-Host " cjagent web # 웹 UI 실행" -ForegroundColor Cyan Write-Host "" Write-Host " * 'cjagent' 명령을 못 찾으면 새 터미널을 열거나 PATH(사용자 Scripts 폴더)를 확인하세요." -ForegroundColor DarkGray