54 lines
2.3 KiB
PowerShell
54 lines
2.3 KiB
PowerShell
# ============================================================
|
||
# Liars-Bar-LLM 專案環境載入腳本(僅影響當前 session)
|
||
# 用途:把 Codex 桌面自帶的既有工具鏈掛進「本次 session」的 PATH。
|
||
# 不做任何系統層級變更(不寫註冊表、不寫系統環境變數、不安裝任何東西)。
|
||
# 用法:在專案根目錄執行 .\scripts\env.ps1
|
||
# ============================================================
|
||
|
||
# Codex 桌面 runtime 根目錄(若 Codex 更新版本、路徑改變,可改這裡或改指向 hermes)
|
||
$runtimeRoot = 'C:\Users\ckliu\.cache\codex-runtimes\codex-primary-runtime\dependencies'
|
||
|
||
$toolDirs = @(
|
||
(Join-Path $runtimeRoot 'native\git\cmd'), # git
|
||
(Join-Path $runtimeRoot 'node\bin'), # node / npm
|
||
(Join-Path $runtimeRoot 'python'), # python
|
||
(Join-Path $runtimeRoot 'bin\fallback') # pnpm 等
|
||
)
|
||
|
||
$missing = @()
|
||
foreach ($dir in $toolDirs) {
|
||
if (Test-Path -LiteralPath $dir) {
|
||
if (($env:PATH -split ';') -notcontains $dir) {
|
||
$env:PATH = "$dir;$env:PATH"
|
||
}
|
||
} else {
|
||
$missing += $dir
|
||
}
|
||
}
|
||
|
||
if ($missing.Count -gt 0) {
|
||
Write-Host "警告:以下工具目錄不存在(Codex 可能已更新路徑):" -ForegroundColor Yellow
|
||
foreach ($m in $missing) { Write-Host " $m" -ForegroundColor Yellow }
|
||
Write-Host "替代方案:改用 hermes 工具鏈(C:\Users\ckliu\AppData\Local\hermes\git 與 ...\node)。" -ForegroundColor Yellow
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "環境載入完成(session 限定,未變更系統設定):" -ForegroundColor Green
|
||
foreach ($cmd in @('git','node','python','pnpm')) {
|
||
$bin = Get-Command $cmd -ErrorAction SilentlyContinue
|
||
if ($bin) {
|
||
$ver = try { & $cmd --version 2>&1 | Select-Object -First 1 } catch { '?' }
|
||
Write-Host (" {0,-8} {1}" -f $cmd, $ver)
|
||
} else {
|
||
Write-Host (" {0,-8} <找不到>" -f $cmd) -ForegroundColor Yellow
|
||
}
|
||
}
|
||
|
||
# 專案 venv 提示
|
||
$venvPython = Join-Path (Get-Location) '.venv\Scripts\python.exe'
|
||
if (Test-Path -LiteralPath $venvPython) {
|
||
$pyVer = & $venvPython --version 2>$null
|
||
Write-Host (" 專案 venv {0} ({1})" -f $venvPython, $pyVer) -ForegroundColor Green
|
||
} else {
|
||
Write-Host " 專案 venv 尚未建立(可用 .\scripts\env.ps1 掛載後執行 python -m venv .venv)" -ForegroundColor Yellow
|
||
} |