fix(ps1): strip all non-ASCII Unicode from PowerShell scripts

Windows PowerShell 5.1 reads .ps1 files without BOM as Windows-1251 by
default. Em-dashes (-) and other Unicode chars in string literals get
mangled into invalid bytes (e.g. "session - no" becomes garbage that
breaks the parser with "Unexpected token" errors.

Replaced em-dash, en-dash, smart quotes, ellipsis, NBSP and arrows with
their ASCII equivalents across all 12 .ps1 scripts (install/update/
uninstall for claude/gemini/codex/qwen).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-04-21 10:53:15 +00:00
parent cb088c4e9a
commit 3381797148
12 changed files with 1653 additions and 1653 deletions

View File

@@ -1,238 +1,238 @@
# Claude Code Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_install.ps1
#
# Installs Node.js (if needed), Claude Code via npm registry, configures env vars and settings.
$ErrorActionPreference = "Continue"
# Fix PS execution policy so claude.ps1 wrapper works
try {
Set-ExecutionPolicy Bypass -Scope CurrentUser -Force 2>$null
} catch {}
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Claude Code -- Windows Installer |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Helpers ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Get-NodeMajor {
if (Test-Command "node") {
try { return [int](((node --version 2>$null) -replace '^v', '') -split '\.')[0] }
catch { return 0 }
}
return 0
}
# ---- Check prerequisites ----
# Node.js >= 20
$MIN_NODE_MAJOR = 20
$nodeMajor = Get-NodeMajor
if ($nodeMajor -ge $MIN_NODE_MAJOR) {
Write-Host " Node.js v$nodeMajor.x OK" -ForegroundColor Green
} else {
if ($nodeMajor -gt 0) {
Write-Host " Node.js v$nodeMajor found, need v$MIN_NODE_MAJOR+. Upgrading..." -ForegroundColor Yellow
} else {
Write-Host " Node.js not found. Installing..." -ForegroundColor Yellow
}
$installed = $false
# 1. Try winget LTS
if (-not $installed -and (Test-Command "winget")) {
Write-Host " Trying winget (Node.js LTS)..." -ForegroundColor Yellow
winget install --id OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements -e 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 2. Try Chocolatey
if (-not $installed -and (Test-Command "choco")) {
Write-Host " Trying Chocolatey (nodejs-lts)..." -ForegroundColor Yellow
choco install nodejs-lts -y 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 3. Direct MSI download
if (-not $installed) {
Write-Host " Downloading Node.js v24 MSI..." -ForegroundColor Yellow
try {
$latestForMajor = "v24.0.0"
try {
$releases = Invoke-RestMethod -Uri "https://nodejs.org/dist/index.json" -UseBasicParsing -TimeoutSec 10
$match = $releases | Where-Object { $_.version -match "^v24\." } | Select-Object -First 1
if ($match) { $latestForMajor = $match.version }
} catch {}
$msiUrl = "https://nodejs.org/dist/$latestForMajor/node-$latestForMajor-x64.msi"
$msiFile = Join-Path $env:TEMP "node-v24.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiFile -UseBasicParsing
Start-Process msiexec.exe -ArgumentList "/i `"$msiFile`" /quiet /norestart" -Wait
Refresh-Path
Remove-Item $msiFile -Force -ErrorAction SilentlyContinue
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
} catch {
Write-Host " Download failed: $_" -ForegroundColor Red
}
}
if (-not $installed) {
Write-Host ""
Write-Host " Could not install Node.js automatically." -ForegroundColor Red
Write-Host " Install manually: https://nodejs.org/en/download/ (v$MIN_NODE_MAJOR+)" -ForegroundColor Yellow
exit 1
}
Write-Host " Node.js v$(Get-NodeMajor).x installed OK" -ForegroundColor Green
}
# ---- Configure npm registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@anthropic-ai:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Install Claude Code ----
if (-not (Test-Command "claude")) {
Write-Host " Installing @anthropic-ai/claude-code..." -ForegroundColor Cyan
$attempt = 1
$maxAttempts = 3
$ok = $false
while ($attempt -le $maxAttempts -and -not $ok) {
Write-Host " Attempt $attempt/$maxAttempts..." -ForegroundColor Yellow
npm install -g @anthropic-ai/claude-code 2>&1
if ($LASTEXITCODE -eq 0) { $ok = $true }
else {
$attempt++
if ($attempt -le $maxAttempts) { Start-Sleep -Seconds 3 }
}
}
if (-not $ok) {
Write-Host ""
Write-Host " npm install failed after $maxAttempts attempts." -ForegroundColor Red
Write-Host " Try: npm config set `"@anthropic-ai:registry`" `"http://npm.sensey24.ru/`"" -ForegroundColor Yellow
Write-Host " Then: npm install -g @anthropic-ai/claude-code" -ForegroundColor Yellow
exit 1
}
Refresh-Path
Write-Host " Claude Code installed" -ForegroundColor Green
} else {
Write-Host " Claude Code already installed" -ForegroundColor Green
}
# ---- Configure environment variables ----
Write-Host " Setting environment variables..." -ForegroundColor Cyan
$envVars = @{
"ANTHROPIC_API_KEY" = "ClauderAPI2"
"ANTHROPIC_AUTH_TOKEN" = "ClauderAPI2"
"ANTHROPIC_BASE_URL" = "https://ai.37-187-136-86.sslip.io"
"ANTHROPIC_DEFAULT_OPUS_MODEL" = "claude-opus-4-7"
"ANTHROPIC_DEFAULT_SONNET_MODEL" = "claude-sonnet-4-6"
"CLAUDE_CUSTOM_MODELS" = "claude-opus-4-7,claude-opus-4-6,claude-sonnet-4-6,gpt-5.4,gpt-5.3-codex,gpt-5.2-codex,claude-opus-4-5-20251101,claude-sonnet-4-5-20250929,gemini-3.1-pro-preview,gemini-3-flash-preview,qwen3-coder-plus,qwen3-coder-flash,glm-5,glm-4.7"
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" = "1"
"CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY" = "1"
"DISABLE_TELEMETRY" = "1"
"DISABLE_ERROR_REPORTING" = "1"
"DISABLE_AUTOUPDATER" = "1"
"CLAUDE_CODE_EFFORT_LEVEL" = "high"
}
foreach ($k in $envVars.Keys) {
[System.Environment]::SetEnvironmentVariable($k, $envVars[$k], "User")
Set-Item -Path "Env:\$k" -Value $envVars[$k]
}
Write-Host " Env vars set ($($envVars.Count) variables)" -ForegroundColor Green
# ---- Configure settings ----
Write-Host " Configuring settings..." -ForegroundColor Cyan
$claudeDir = "$env:USERPROFILE\.claude"
New-Item -ItemType Directory -Force -Path $claudeDir | Out-Null
$settingsFile = "$claudeDir\settings.json"
$json = @'
{
"permissions": {
"allow": [
"Bash(*)",
"Read(*)",
"Write(*)",
"Edit(*)",
"Glob(*)",
"Grep(*)",
"WebFetch(*)",
"WebSearch(*)",
"mcp__*"
],
"deny": []
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
Write-Host " Settings: $settingsFile" -ForegroundColor Green
# ---- Configure .claude.json (onboarding + theme) ----
$claudeJson = "$env:USERPROFILE\.claude.json"
if (-not (Test-Path $claudeJson)) {
$cj = @'
{"hasCompletedOnboarding":true,"theme":"dark"}
'@
[System.IO.File]::WriteAllText($claudeJson, $cj)
Write-Host " Onboarding: pre-configured (dark theme)" -ForegroundColor Green
} else {
Write-Host " Onboarding: already configured" -ForegroundColor Green
}
# ---- Remove .ps1 wrapper (prevents ExecutionPolicy errors) ----
$npmPrefix = (npm prefix -g 2>$null)
if ($npmPrefix) {
$ps1Wrapper = Join-Path $npmPrefix "claude.ps1"
if (Test-Path $ps1Wrapper) {
Remove-Item $ps1Wrapper -Force -ErrorAction SilentlyContinue
Write-Host " Removed claude.ps1 wrapper (using .cmd instead)" -ForegroundColor Green
}
}
# ---- Verify ----
Write-Host ""
Write-Host " Verifying..." -ForegroundColor Cyan
Refresh-Path
try {
$result = & claude -p "Reply with just OK" 2>&1 | Out-String
if ($result -match "OK") {
Write-Host ""
Write-Host " Claude Code installed and configured!" -ForegroundColor Green
Write-Host ""
Write-Host " Usage:"
Write-Host " claude # interactive mode"
Write-Host " claude -p `"Your prompt`" # single prompt"
Write-Host ""
} else {
Write-Host " Installed but test prompt did not return OK." -ForegroundColor Yellow
Write-Host " Try: claude -p `"Hello`"" -ForegroundColor Yellow
}
} catch {
Write-Host " Could not run test. Try: claude -p `"Hello`"" -ForegroundColor Yellow
}
Write-Host ""
# Claude Code - Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_install.ps1
#
# Installs Node.js (if needed), Claude Code via npm registry, configures env vars and settings.
$ErrorActionPreference = "Continue"
# Fix PS execution policy so claude.ps1 wrapper works
try {
Set-ExecutionPolicy Bypass -Scope CurrentUser -Force 2>$null
} catch {}
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Claude Code -- Windows Installer |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Helpers ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Get-NodeMajor {
if (Test-Command "node") {
try { return [int](((node --version 2>$null) -replace '^v', '') -split '\.')[0] }
catch { return 0 }
}
return 0
}
# ---- Check prerequisites ----
# Node.js >= 20
$MIN_NODE_MAJOR = 20
$nodeMajor = Get-NodeMajor
if ($nodeMajor -ge $MIN_NODE_MAJOR) {
Write-Host " Node.js v$nodeMajor.x OK" -ForegroundColor Green
} else {
if ($nodeMajor -gt 0) {
Write-Host " Node.js v$nodeMajor found, need v$MIN_NODE_MAJOR+. Upgrading..." -ForegroundColor Yellow
} else {
Write-Host " Node.js not found. Installing..." -ForegroundColor Yellow
}
$installed = $false
# 1. Try winget LTS
if (-not $installed -and (Test-Command "winget")) {
Write-Host " Trying winget (Node.js LTS)..." -ForegroundColor Yellow
winget install --id OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements -e 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 2. Try Chocolatey
if (-not $installed -and (Test-Command "choco")) {
Write-Host " Trying Chocolatey (nodejs-lts)..." -ForegroundColor Yellow
choco install nodejs-lts -y 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 3. Direct MSI download
if (-not $installed) {
Write-Host " Downloading Node.js v24 MSI..." -ForegroundColor Yellow
try {
$latestForMajor = "v24.0.0"
try {
$releases = Invoke-RestMethod -Uri "https://nodejs.org/dist/index.json" -UseBasicParsing -TimeoutSec 10
$match = $releases | Where-Object { $_.version -match "^v24\." } | Select-Object -First 1
if ($match) { $latestForMajor = $match.version }
} catch {}
$msiUrl = "https://nodejs.org/dist/$latestForMajor/node-$latestForMajor-x64.msi"
$msiFile = Join-Path $env:TEMP "node-v24.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiFile -UseBasicParsing
Start-Process msiexec.exe -ArgumentList "/i `"$msiFile`" /quiet /norestart" -Wait
Refresh-Path
Remove-Item $msiFile -Force -ErrorAction SilentlyContinue
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
} catch {
Write-Host " Download failed: $_" -ForegroundColor Red
}
}
if (-not $installed) {
Write-Host ""
Write-Host " Could not install Node.js automatically." -ForegroundColor Red
Write-Host " Install manually: https://nodejs.org/en/download/ (v$MIN_NODE_MAJOR+)" -ForegroundColor Yellow
exit 1
}
Write-Host " Node.js v$(Get-NodeMajor).x installed OK" -ForegroundColor Green
}
# ---- Configure npm registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@anthropic-ai:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Install Claude Code ----
if (-not (Test-Command "claude")) {
Write-Host " Installing @anthropic-ai/claude-code..." -ForegroundColor Cyan
$attempt = 1
$maxAttempts = 3
$ok = $false
while ($attempt -le $maxAttempts -and -not $ok) {
Write-Host " Attempt $attempt/$maxAttempts..." -ForegroundColor Yellow
npm install -g @anthropic-ai/claude-code 2>&1
if ($LASTEXITCODE -eq 0) { $ok = $true }
else {
$attempt++
if ($attempt -le $maxAttempts) { Start-Sleep -Seconds 3 }
}
}
if (-not $ok) {
Write-Host ""
Write-Host " npm install failed after $maxAttempts attempts." -ForegroundColor Red
Write-Host " Try: npm config set `"@anthropic-ai:registry`" `"http://npm.sensey24.ru/`"" -ForegroundColor Yellow
Write-Host " Then: npm install -g @anthropic-ai/claude-code" -ForegroundColor Yellow
exit 1
}
Refresh-Path
Write-Host " Claude Code installed" -ForegroundColor Green
} else {
Write-Host " Claude Code already installed" -ForegroundColor Green
}
# ---- Configure environment variables ----
Write-Host " Setting environment variables..." -ForegroundColor Cyan
$envVars = @{
"ANTHROPIC_API_KEY" = "ClauderAPI2"
"ANTHROPIC_AUTH_TOKEN" = "ClauderAPI2"
"ANTHROPIC_BASE_URL" = "https://ai.37-187-136-86.sslip.io"
"ANTHROPIC_DEFAULT_OPUS_MODEL" = "claude-opus-4-7"
"ANTHROPIC_DEFAULT_SONNET_MODEL" = "claude-sonnet-4-6"
"CLAUDE_CUSTOM_MODELS" = "claude-opus-4-7,claude-opus-4-6,claude-sonnet-4-6,gpt-5.4,gpt-5.3-codex,gpt-5.2-codex,claude-opus-4-5-20251101,claude-sonnet-4-5-20250929,gemini-3.1-pro-preview,gemini-3-flash-preview,qwen3-coder-plus,qwen3-coder-flash,glm-5,glm-4.7"
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" = "1"
"CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY" = "1"
"DISABLE_TELEMETRY" = "1"
"DISABLE_ERROR_REPORTING" = "1"
"DISABLE_AUTOUPDATER" = "1"
"CLAUDE_CODE_EFFORT_LEVEL" = "high"
}
foreach ($k in $envVars.Keys) {
[System.Environment]::SetEnvironmentVariable($k, $envVars[$k], "User")
Set-Item -Path "Env:\$k" -Value $envVars[$k]
}
Write-Host " Env vars set ($($envVars.Count) variables)" -ForegroundColor Green
# ---- Configure settings ----
Write-Host " Configuring settings..." -ForegroundColor Cyan
$claudeDir = "$env:USERPROFILE\.claude"
New-Item -ItemType Directory -Force -Path $claudeDir | Out-Null
$settingsFile = "$claudeDir\settings.json"
$json = @'
{
"permissions": {
"allow": [
"Bash(*)",
"Read(*)",
"Write(*)",
"Edit(*)",
"Glob(*)",
"Grep(*)",
"WebFetch(*)",
"WebSearch(*)",
"mcp__*"
],
"deny": []
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
Write-Host " Settings: $settingsFile" -ForegroundColor Green
# ---- Configure .claude.json (onboarding + theme) ----
$claudeJson = "$env:USERPROFILE\.claude.json"
if (-not (Test-Path $claudeJson)) {
$cj = @'
{"hasCompletedOnboarding":true,"theme":"dark"}
'@
[System.IO.File]::WriteAllText($claudeJson, $cj)
Write-Host " Onboarding: pre-configured (dark theme)" -ForegroundColor Green
} else {
Write-Host " Onboarding: already configured" -ForegroundColor Green
}
# ---- Remove .ps1 wrapper (prevents ExecutionPolicy errors) ----
$npmPrefix = (npm prefix -g 2>$null)
if ($npmPrefix) {
$ps1Wrapper = Join-Path $npmPrefix "claude.ps1"
if (Test-Path $ps1Wrapper) {
Remove-Item $ps1Wrapper -Force -ErrorAction SilentlyContinue
Write-Host " Removed claude.ps1 wrapper (using .cmd instead)" -ForegroundColor Green
}
}
# ---- Verify ----
Write-Host ""
Write-Host " Verifying..." -ForegroundColor Cyan
Refresh-Path
try {
$result = & claude -p "Reply with just OK" 2>&1 | Out-String
if ($result -match "OK") {
Write-Host ""
Write-Host " Claude Code installed and configured!" -ForegroundColor Green
Write-Host ""
Write-Host " Usage:"
Write-Host " claude # interactive mode"
Write-Host " claude -p `"Your prompt`" # single prompt"
Write-Host ""
} else {
Write-Host " Installed but test prompt did not return OK." -ForegroundColor Yellow
Write-Host " Try: claude -p `"Hello`"" -ForegroundColor Yellow
}
} catch {
Write-Host " Could not run test. Try: claude -p `"Hello`"" -ForegroundColor Yellow
}
Write-Host ""

View File

@@ -1,51 +1,51 @@
# Claude Code Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Claude Code -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @anthropic-ai/claude-code..." -ForegroundColor Cyan
npm uninstall -g @anthropic-ai/claude-code 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$claudeDir = "$env:USERPROFILE\.claude"
if (Test-Path $claudeDir) {
Write-Host " Removing $claudeDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $claudeDir
Write-Host " Settings removed" -ForegroundColor Green
}
$claudeJson = "$env:USERPROFILE\.claude.json"
if (Test-Path $claudeJson) {
Remove-Item -Force $claudeJson
Write-Host " Removed .claude.json" -ForegroundColor Green
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", $null, "User")
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_USE_BEDROCK", $null, "User")
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@anthropic-ai:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Claude Code fully uninstalled!" -ForegroundColor Green
Write-Host ""
# Claude Code - Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Claude Code -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @anthropic-ai/claude-code..." -ForegroundColor Cyan
npm uninstall -g @anthropic-ai/claude-code 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$claudeDir = "$env:USERPROFILE\.claude"
if (Test-Path $claudeDir) {
Write-Host " Removing $claudeDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $claudeDir
Write-Host " Settings removed" -ForegroundColor Green
}
$claudeJson = "$env:USERPROFILE\.claude.json"
if (Test-Path $claudeJson) {
Remove-Item -Force $claudeJson
Write-Host " Removed .claude.json" -ForegroundColor Green
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", $null, "User")
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_USE_BEDROCK", $null, "User")
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@anthropic-ai:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Claude Code fully uninstalled!" -ForegroundColor Green
Write-Host ""

View File

@@ -1,4 +1,4 @@
# Claude Code Windows Updater
# Claude Code - Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_update.ps1
#
# Updates Claude Code via npm registry + re-applies config patches.

View File

@@ -1,363 +1,363 @@
# Codex CLI Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_install.ps1
#
# Downloads Codex CLI binary from GitHub, applies config patches.
# Codex is a compiled Rust binary (not npm).
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Installer |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Helpers ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check prerequisites ----
# Python 3.11+ (for tomllib) optional, fallback to PowerShell patching
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Test-Command $candidate) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if (-not $pyCmd) {
Write-Host " Python 3.11+ not found, will use PowerShell fallback for patching" -ForegroundColor Yellow
}
# curl (usually built into Windows 10+)
if (-not (Test-Command "curl.exe") -and -not (Test-Command "curl")) {
Write-Host " curl not found. Using Invoke-WebRequest fallback." -ForegroundColor Yellow
}
# ---- Download Codex binary ----
Write-Host " Checking latest Codex version..." -ForegroundColor Cyan
$githubApi = "https://api.github.com/repos/openai/codex/releases/latest"
try {
$release = Invoke-RestMethod -Uri $githubApi -UseBasicParsing -TimeoutSec 15
$tagName = $release.tag_name
$latestVersion = ($tagName -replace '^rust-v', '')
Write-Host " Latest version: $latestVersion" -ForegroundColor Green
} catch {
Write-Host " Could not fetch latest version from GitHub." -ForegroundColor Red
Write-Host " Check: https://github.com/openai/codex/releases" -ForegroundColor Yellow
exit 1
}
# Check if already installed and up to date
$currentVersion = ""
if (Test-Command "codex") {
try {
$verOut = codex --version 2>$null
$currentVersion = [regex]::Match($verOut, '\d+\.\d+\.\d+').Value
} catch {}
}
if ($currentVersion -eq $latestVersion) {
Write-Host " Codex v$currentVersion already installed and up to date" -ForegroundColor Green
} else {
if ($currentVersion) {
Write-Host " Updating: $currentVersion -> $latestVersion" -ForegroundColor Yellow
} else {
Write-Host " Installing Codex v$latestVersion..." -ForegroundColor Cyan
}
# Determine architecture
$arch = if ([System.Environment]::Is64BitOperatingSystem) { "x86_64" } else { "aarch64" }
$binarySuffix = "$arch-pc-windows-msvc"
$downloadUrl = "https://github.com/openai/codex/releases/download/rust-v$latestVersion/codex-$binarySuffix.exe"
Write-Host " Downloading: codex-$binarySuffix.exe" -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "codex-install-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$exeFile = Join-Path $tempDir "codex.exe"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $exeFile -UseBasicParsing
} catch {
Write-Host " Direct exe download failed, trying zip..." -ForegroundColor Yellow
$zipUrl = "$downloadUrl.zip"
$zipFile = Join-Path $tempDir "codex.zip"
try {
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFile -UseBasicParsing
Expand-Archive -Path $zipFile -DestinationPath $tempDir -Force
$found = Get-ChildItem -Path $tempDir -Recurse -Filter "codex*.exe" | Where-Object { $_.Name -notlike "*setup*" -and $_.Name -notlike "*proxy*" -and $_.Name -notlike "*runner*" } | Select-Object -First 1
if ($found) { Copy-Item $found.FullName $exeFile -Force }
} catch {
Write-Host " Download failed. Check https://github.com/openai/codex/releases" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
}
if (-not (Test-Path $exeFile)) {
Write-Host " Binary not found after download" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
# Install to user-accessible location
$installDir = "$env:LOCALAPPDATA\Programs\codex"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
$destPath = Join-Path $installDir "codex.exe"
# Kill running codex processes
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
Copy-Item -Path $exeFile -Destination $destPath -Force
Write-Host " Installed: $destPath" -ForegroundColor Green
# Add to PATH if not already there
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User")
$env:Path = "$env:Path;$installDir"
Write-Host " Added to PATH: $installDir" -ForegroundColor Green
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Refresh-Path
# Verify
try {
$newVer = codex --version 2>$null
Write-Host " Codex installed: $newVer" -ForegroundColor Green
} catch {
Write-Host " Binary installed but could not verify version" -ForegroundColor Yellow
}
}
# ---- Clean up broken config from previous runs ----
# Codex stores config in ~/.codex/ (= %USERPROFILE%\.codex\)
$codexConfigDir = "$env:USERPROFILE\.codex"
$codexConfigFile = "$codexConfigDir\config.toml"
if (Test-Path $codexConfigFile) {
$existingContent = Get-Content $codexConfigFile -Raw -ErrorAction SilentlyContinue
$needsCleanup = $false
# Check 1: broken TOML with dotted model keys (gpt-5.4 parsed as gpt-5 -> 4)
if ($existingContent -match "gpt-5\s*=" -and $existingContent -match "\{.*:") {
Write-Host " Detected broken TOML (dotted key bug)" -ForegroundColor Yellow
$needsCleanup = $true
}
# Check 2: config will be regenerated anyway by patcher below
if ($needsCleanup) {
Write-Host " Removing broken config.toml..." -ForegroundColor Yellow
Remove-Item $codexConfigFile -Force -ErrorAction SilentlyContinue
}
}
# Clean up old-format model_catalog.json (bare array instead of {models:[...]})
$staleCatalog = "$codexConfigDir\model_catalog.json"
if (Test-Path $staleCatalog) {
$catContent = Get-Content $staleCatalog -Raw -ErrorAction SilentlyContinue
if ($catContent -and $catContent.TrimStart().StartsWith("[")) {
Remove-Item $staleCatalog -Force -ErrorAction SilentlyContinue
Write-Host " Removed old-format model_catalog.json (wrong structure)" -ForegroundColor Yellow
}
}
# ---- Apply patches ----
if ($pyCmd) {
# Python available use full patcher
Write-Host " Downloading patcher..." -ForegroundColor Cyan
$patchDir = Join-Path $env:TEMP "codex-patcher-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $patchDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
try {
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing -Headers $headers
Write-Host " Patcher downloaded" -ForegroundColor Green
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing
Write-Host " Patcher downloaded (no auth)" -ForegroundColor Green
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$patchDir\codex_patcher.py" --apply --config "$patchDir\codex_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher returned exit code $LASTEXITCODE, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
} else {
Write-Host " Patches applied" -ForegroundColor Green
}
}
Remove-Item -Recurse -Force $patchDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback generate config.toml directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Codex reads config from ~/.codex/ (NOT %APPDATA%\codex\)
$configDir = "$env:USERPROFILE\.codex"
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
$configToml = Join-Path $configDir "config.toml"
# Remove old broken config if exists
if (Test-Path $configToml) {
Remove-Item $configToml -Force -ErrorAction SilentlyContinue
}
# Generate model catalog (Codex internal format)
$catalogFile = Join-Path $configDir "model_catalog.json"
$catalogPath = $catalogFile -replace '\\', '/'
$modelTemplate = @{
prefer_websockets = $false
support_verbosity = $true
default_verbosity = "low"
apply_patch_tool_type = "freeform"
input_modalities = @("text", "image")
supports_image_detail_original = $true
truncation_policy = @{ mode = "tokens"; limit = 10000 }
supports_parallel_tool_calls = $true
context_window = 272000
default_reasoning_summary = "none"
shell_type = "shell_command"
visibility = "list"
supported_in_api = $true
availability_nux = $null
upgrade = $null
base_instructions = ""
model_messages = $null
experimental_supported_tools = @()
supports_reasoning_summaries = $true
supported_reasoning_levels = @(
@{ effort = "low"; description = "Fast responses with lighter reasoning" }
@{ effort = "medium"; description = "Balances speed and reasoning depth" }
@{ effort = "high"; description = "Greater reasoning depth for complex problems" }
@{ effort = "xhigh"; description = "Extra high reasoning depth" }
)
default_reasoning_level = "medium"
}
$modelSlugs = @("gpt-5.4", "gpt-5.3-codex-spark", "gpt-5.3-codex", "gpt-5.3", "gpt-5.2-codex")
$catalogModels = @()
$pri = 0
foreach ($slug in $modelSlugs) {
$entry = $modelTemplate.Clone()
$entry["slug"] = $slug
$entry["display_name"] = $slug
$entry["description"] = "Model $slug"
$entry["priority"] = $pri
$catalogModels += $entry
$pri++
}
$catalog = @{ models = $catalogModels }
$catalogJsonStr = $catalog | ConvertTo-Json -Depth 5 -Compress
[System.IO.File]::WriteAllText($catalogFile, $catalogJsonStr)
Write-Host " model_catalog.json created ($($modelSlugs.Count) models)" -ForegroundColor Green
$tomlContent = @"
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
model_provider = "custom"
model_catalog_json = "$catalogPath"
approval_policy = "never"
sandbox_mode = "danger-full-access"
check_for_update_on_startup = false
forced_login_method = "api"
[analytics]
enabled = false
[model_providers.custom]
name = "custom"
base_url = "https://ai.37-187-136-86.sslip.io/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
[notice]
[notice.model_migrations]
"gpt-5.4" = "done"
"gpt-5.3-codex-spark" = "done"
"gpt-5.3-codex" = "done"
"gpt-5.3" = "done"
"gpt-5.2-codex" = "done"
"@
[System.IO.File]::WriteAllText($configToml, $tomlContent)
Write-Host " config.toml created: $configToml" -ForegroundColor Green
# Set env vars via setx
& setx OPENAI_API_KEY "ClauderAPI2" 2>$null | Out-Null
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
Write-Host " Env vars set via setx" -ForegroundColor Green
}
# ---- Configure environment variables ----
Write-Host " Setting environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", "https://ai.37-187-136-86.sslip.io/v1", "User")
$env:OPENAI_API_KEY = "ClauderAPI2"
$env:OPENAI_BASE_URL = "https://ai.37-187-136-86.sslip.io/v1"
Write-Host " Env vars set (OPENAI_API_KEY, OPENAI_BASE_URL)" -ForegroundColor Green
# ---- Verify ----
Write-Host ""
Write-Host " Verifying..." -ForegroundColor Cyan
Refresh-Path
try {
$result = & codex exec "Reply with just the number 42" 2>&1 | Out-String
if ($result -match "42") {
Write-Host ""
Write-Host " Codex CLI installed and patched!" -ForegroundColor Green
Write-Host ""
Write-Host " Usage:"
Write-Host " codex # interactive mode"
Write-Host " codex exec `"Your prompt`" # single prompt"
Write-Host ""
Write-Host " Models:"
Write-Host " gpt-5.4, gpt-5.3-codex-spark"
Write-Host " gpt-5.3-codex, gpt-5.2-codex"
} else {
Write-Host " Patches applied but test prompt did not return expected result." -ForegroundColor Yellow
Write-Host " Try: codex exec `"Hello`"" -ForegroundColor Yellow
}
} catch {
Write-Host " Could not run test. Try: codex exec `"Hello`"" -ForegroundColor Yellow
}
Write-Host ""
Write-Host " NOTE: If 'codex' is not recognized, restart PowerShell or run:" -ForegroundColor Yellow
Write-Host ' $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")' -ForegroundColor Yellow
Write-Host ""
# Codex CLI - Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_install.ps1
#
# Downloads Codex CLI binary from GitHub, applies config patches.
# Codex is a compiled Rust binary (not npm).
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Installer |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Helpers ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check prerequisites ----
# Python 3.11+ (for tomllib) - optional, fallback to PowerShell patching
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Test-Command $candidate) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if (-not $pyCmd) {
Write-Host " Python 3.11+ not found, will use PowerShell fallback for patching" -ForegroundColor Yellow
}
# curl (usually built into Windows 10+)
if (-not (Test-Command "curl.exe") -and -not (Test-Command "curl")) {
Write-Host " curl not found. Using Invoke-WebRequest fallback." -ForegroundColor Yellow
}
# ---- Download Codex binary ----
Write-Host " Checking latest Codex version..." -ForegroundColor Cyan
$githubApi = "https://api.github.com/repos/openai/codex/releases/latest"
try {
$release = Invoke-RestMethod -Uri $githubApi -UseBasicParsing -TimeoutSec 15
$tagName = $release.tag_name
$latestVersion = ($tagName -replace '^rust-v', '')
Write-Host " Latest version: $latestVersion" -ForegroundColor Green
} catch {
Write-Host " Could not fetch latest version from GitHub." -ForegroundColor Red
Write-Host " Check: https://github.com/openai/codex/releases" -ForegroundColor Yellow
exit 1
}
# Check if already installed and up to date
$currentVersion = ""
if (Test-Command "codex") {
try {
$verOut = codex --version 2>$null
$currentVersion = [regex]::Match($verOut, '\d+\.\d+\.\d+').Value
} catch {}
}
if ($currentVersion -eq $latestVersion) {
Write-Host " Codex v$currentVersion already installed and up to date" -ForegroundColor Green
} else {
if ($currentVersion) {
Write-Host " Updating: $currentVersion -> $latestVersion" -ForegroundColor Yellow
} else {
Write-Host " Installing Codex v$latestVersion..." -ForegroundColor Cyan
}
# Determine architecture
$arch = if ([System.Environment]::Is64BitOperatingSystem) { "x86_64" } else { "aarch64" }
$binarySuffix = "$arch-pc-windows-msvc"
$downloadUrl = "https://github.com/openai/codex/releases/download/rust-v$latestVersion/codex-$binarySuffix.exe"
Write-Host " Downloading: codex-$binarySuffix.exe" -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "codex-install-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$exeFile = Join-Path $tempDir "codex.exe"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $exeFile -UseBasicParsing
} catch {
Write-Host " Direct exe download failed, trying zip..." -ForegroundColor Yellow
$zipUrl = "$downloadUrl.zip"
$zipFile = Join-Path $tempDir "codex.zip"
try {
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFile -UseBasicParsing
Expand-Archive -Path $zipFile -DestinationPath $tempDir -Force
$found = Get-ChildItem -Path $tempDir -Recurse -Filter "codex*.exe" | Where-Object { $_.Name -notlike "*setup*" -and $_.Name -notlike "*proxy*" -and $_.Name -notlike "*runner*" } | Select-Object -First 1
if ($found) { Copy-Item $found.FullName $exeFile -Force }
} catch {
Write-Host " Download failed. Check https://github.com/openai/codex/releases" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
}
if (-not (Test-Path $exeFile)) {
Write-Host " Binary not found after download" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
# Install to user-accessible location
$installDir = "$env:LOCALAPPDATA\Programs\codex"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
$destPath = Join-Path $installDir "codex.exe"
# Kill running codex processes
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
Copy-Item -Path $exeFile -Destination $destPath -Force
Write-Host " Installed: $destPath" -ForegroundColor Green
# Add to PATH if not already there
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User")
$env:Path = "$env:Path;$installDir"
Write-Host " Added to PATH: $installDir" -ForegroundColor Green
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Refresh-Path
# Verify
try {
$newVer = codex --version 2>$null
Write-Host " Codex installed: $newVer" -ForegroundColor Green
} catch {
Write-Host " Binary installed but could not verify version" -ForegroundColor Yellow
}
}
# ---- Clean up broken config from previous runs ----
# Codex stores config in ~/.codex/ (= %USERPROFILE%\.codex\)
$codexConfigDir = "$env:USERPROFILE\.codex"
$codexConfigFile = "$codexConfigDir\config.toml"
if (Test-Path $codexConfigFile) {
$existingContent = Get-Content $codexConfigFile -Raw -ErrorAction SilentlyContinue
$needsCleanup = $false
# Check 1: broken TOML with dotted model keys (gpt-5.4 parsed as gpt-5 -> 4)
if ($existingContent -match "gpt-5\s*=" -and $existingContent -match "\{.*:") {
Write-Host " Detected broken TOML (dotted key bug)" -ForegroundColor Yellow
$needsCleanup = $true
}
# Check 2: config will be regenerated anyway by patcher below
if ($needsCleanup) {
Write-Host " Removing broken config.toml..." -ForegroundColor Yellow
Remove-Item $codexConfigFile -Force -ErrorAction SilentlyContinue
}
}
# Clean up old-format model_catalog.json (bare array instead of {models:[...]})
$staleCatalog = "$codexConfigDir\model_catalog.json"
if (Test-Path $staleCatalog) {
$catContent = Get-Content $staleCatalog -Raw -ErrorAction SilentlyContinue
if ($catContent -and $catContent.TrimStart().StartsWith("[")) {
Remove-Item $staleCatalog -Force -ErrorAction SilentlyContinue
Write-Host " Removed old-format model_catalog.json (wrong structure)" -ForegroundColor Yellow
}
}
# ---- Apply patches ----
if ($pyCmd) {
# Python available - use full patcher
Write-Host " Downloading patcher..." -ForegroundColor Cyan
$patchDir = Join-Path $env:TEMP "codex-patcher-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $patchDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
try {
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing -Headers $headers
Write-Host " Patcher downloaded" -ForegroundColor Green
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing
Write-Host " Patcher downloaded (no auth)" -ForegroundColor Green
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$patchDir\codex_patcher.py" --apply --config "$patchDir\codex_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher returned exit code $LASTEXITCODE, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
} else {
Write-Host " Patches applied" -ForegroundColor Green
}
}
Remove-Item -Recurse -Force $patchDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback - generate config.toml directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Codex reads config from ~/.codex/ (NOT %APPDATA%\codex\)
$configDir = "$env:USERPROFILE\.codex"
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
$configToml = Join-Path $configDir "config.toml"
# Remove old broken config if exists
if (Test-Path $configToml) {
Remove-Item $configToml -Force -ErrorAction SilentlyContinue
}
# Generate model catalog (Codex internal format)
$catalogFile = Join-Path $configDir "model_catalog.json"
$catalogPath = $catalogFile -replace '\\', '/'
$modelTemplate = @{
prefer_websockets = $false
support_verbosity = $true
default_verbosity = "low"
apply_patch_tool_type = "freeform"
input_modalities = @("text", "image")
supports_image_detail_original = $true
truncation_policy = @{ mode = "tokens"; limit = 10000 }
supports_parallel_tool_calls = $true
context_window = 272000
default_reasoning_summary = "none"
shell_type = "shell_command"
visibility = "list"
supported_in_api = $true
availability_nux = $null
upgrade = $null
base_instructions = ""
model_messages = $null
experimental_supported_tools = @()
supports_reasoning_summaries = $true
supported_reasoning_levels = @(
@{ effort = "low"; description = "Fast responses with lighter reasoning" }
@{ effort = "medium"; description = "Balances speed and reasoning depth" }
@{ effort = "high"; description = "Greater reasoning depth for complex problems" }
@{ effort = "xhigh"; description = "Extra high reasoning depth" }
)
default_reasoning_level = "medium"
}
$modelSlugs = @("gpt-5.4", "gpt-5.3-codex-spark", "gpt-5.3-codex", "gpt-5.3", "gpt-5.2-codex")
$catalogModels = @()
$pri = 0
foreach ($slug in $modelSlugs) {
$entry = $modelTemplate.Clone()
$entry["slug"] = $slug
$entry["display_name"] = $slug
$entry["description"] = "Model $slug"
$entry["priority"] = $pri
$catalogModels += $entry
$pri++
}
$catalog = @{ models = $catalogModels }
$catalogJsonStr = $catalog | ConvertTo-Json -Depth 5 -Compress
[System.IO.File]::WriteAllText($catalogFile, $catalogJsonStr)
Write-Host " model_catalog.json created ($($modelSlugs.Count) models)" -ForegroundColor Green
$tomlContent = @"
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
model_provider = "custom"
model_catalog_json = "$catalogPath"
approval_policy = "never"
sandbox_mode = "danger-full-access"
check_for_update_on_startup = false
forced_login_method = "api"
[analytics]
enabled = false
[model_providers.custom]
name = "custom"
base_url = "https://ai.37-187-136-86.sslip.io/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
[notice]
[notice.model_migrations]
"gpt-5.4" = "done"
"gpt-5.3-codex-spark" = "done"
"gpt-5.3-codex" = "done"
"gpt-5.3" = "done"
"gpt-5.2-codex" = "done"
"@
[System.IO.File]::WriteAllText($configToml, $tomlContent)
Write-Host " config.toml created: $configToml" -ForegroundColor Green
# Set env vars via setx
& setx OPENAI_API_KEY "ClauderAPI2" 2>$null | Out-Null
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
Write-Host " Env vars set via setx" -ForegroundColor Green
}
# ---- Configure environment variables ----
Write-Host " Setting environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", "https://ai.37-187-136-86.sslip.io/v1", "User")
$env:OPENAI_API_KEY = "ClauderAPI2"
$env:OPENAI_BASE_URL = "https://ai.37-187-136-86.sslip.io/v1"
Write-Host " Env vars set (OPENAI_API_KEY, OPENAI_BASE_URL)" -ForegroundColor Green
# ---- Verify ----
Write-Host ""
Write-Host " Verifying..." -ForegroundColor Cyan
Refresh-Path
try {
$result = & codex exec "Reply with just the number 42" 2>&1 | Out-String
if ($result -match "42") {
Write-Host ""
Write-Host " Codex CLI installed and patched!" -ForegroundColor Green
Write-Host ""
Write-Host " Usage:"
Write-Host " codex # interactive mode"
Write-Host " codex exec `"Your prompt`" # single prompt"
Write-Host ""
Write-Host " Models:"
Write-Host " gpt-5.4, gpt-5.3-codex-spark"
Write-Host " gpt-5.3-codex, gpt-5.2-codex"
} else {
Write-Host " Patches applied but test prompt did not return expected result." -ForegroundColor Yellow
Write-Host " Try: codex exec `"Hello`"" -ForegroundColor Yellow
}
} catch {
Write-Host " Could not run test. Try: codex exec `"Hello`"" -ForegroundColor Yellow
}
Write-Host ""
Write-Host " NOTE: If 'codex' is not recognized, restart PowerShell or run:" -ForegroundColor Yellow
Write-Host ' $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")' -ForegroundColor Yellow
Write-Host ""

View File

@@ -1,60 +1,60 @@
# Codex CLI Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Remove binary ----
$installDir = "$env:LOCALAPPDATA\Programs\codex"
if (Test-Path "$installDir\codex.exe") {
Write-Host " Stopping codex processes..." -ForegroundColor Cyan
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Host " Removing $installDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $installDir
Write-Host " Binary removed" -ForegroundColor Green
# Remove from PATH
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -like "*$installDir*") {
$newPath = ($userPath -split ";" | Where-Object { $_ -ne $installDir }) -join ";"
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host " Removed from PATH" -ForegroundColor Green
}
} else {
Write-Host " Codex binary not found at $installDir" -ForegroundColor Yellow
# Check other common locations
$altPath = (Get-Command codex -ErrorAction SilentlyContinue).Source
if ($altPath) {
Write-Host " Found at: $altPath remove manually" -ForegroundColor Yellow
}
}
# ---- Remove config ----
$codexDir = "$env:USERPROFILE\.codex"
if (Test-Path $codexDir) {
Write-Host " Removing $codexDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $codexDir
Write-Host " Config removed" -ForegroundColor Green
} else {
Write-Host " No config directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", $null, "User")
Remove-Item Env:OPENAI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:OPENAI_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
Write-Host ""
Write-Host " Codex CLI fully uninstalled!" -ForegroundColor Green
Write-Host ""
# Codex CLI - Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Remove binary ----
$installDir = "$env:LOCALAPPDATA\Programs\codex"
if (Test-Path "$installDir\codex.exe") {
Write-Host " Stopping codex processes..." -ForegroundColor Cyan
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Host " Removing $installDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $installDir
Write-Host " Binary removed" -ForegroundColor Green
# Remove from PATH
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -like "*$installDir*") {
$newPath = ($userPath -split ";" | Where-Object { $_ -ne $installDir }) -join ";"
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host " Removed from PATH" -ForegroundColor Green
}
} else {
Write-Host " Codex binary not found at $installDir" -ForegroundColor Yellow
# Check other common locations
$altPath = (Get-Command codex -ErrorAction SilentlyContinue).Source
if ($altPath) {
Write-Host " Found at: $altPath - remove manually" -ForegroundColor Yellow
}
}
# ---- Remove config ----
$codexDir = "$env:USERPROFILE\.codex"
if (Test-Path $codexDir) {
Write-Host " Removing $codexDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $codexDir
Write-Host " Config removed" -ForegroundColor Green
} else {
Write-Host " No config directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", $null, "User")
Remove-Item Env:OPENAI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:OPENAI_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
Write-Host ""
Write-Host " Codex CLI fully uninstalled!" -ForegroundColor Green
Write-Host ""

View File

@@ -1,264 +1,264 @@
# Codex CLI Windows Updater
# Downloads latest binary from GitHub + re-applies config patches.
#
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$oldVer = "not installed"
if (Get-Command codex -ErrorAction SilentlyContinue) {
$oldVer = [regex]::Match((codex --version 2>$null), '\d+\.\d+\.\d+').Value
}
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Get latest version ----
Write-Host " Checking latest version..." -ForegroundColor Cyan
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/openai/codex/releases/latest" -UseBasicParsing -TimeoutSec 15
$latestVer = ($release.tag_name -replace '^rust-v', '')
Write-Host " Latest: $latestVer" -ForegroundColor Green
} catch {
Write-Host " Could not fetch latest version from GitHub." -ForegroundColor Red
exit 1
}
if ($oldVer -eq $latestVer) {
Write-Host " Already up to date ($latestVer)" -ForegroundColor Green
} else {
# ---- Download binary ----
$arch = if ([System.Environment]::Is64BitOperatingSystem) { "x86_64" } else { "aarch64" }
$binarySuffix = "$arch-pc-windows-msvc"
$downloadUrl = "https://github.com/openai/codex/releases/download/rust-v$latestVer/codex-$binarySuffix.exe"
Write-Host " Downloading codex-$binarySuffix.exe..." -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "codex-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$exeFile = Join-Path $tempDir "codex.exe"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $exeFile -UseBasicParsing
} catch {
Write-Host " Direct exe download failed, trying zip..." -ForegroundColor Yellow
$zipUrl = "$downloadUrl.zip"
$zipFile = Join-Path $tempDir "codex.zip"
try {
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFile -UseBasicParsing
Expand-Archive -Path $zipFile -DestinationPath $tempDir -Force
$found = Get-ChildItem -Path $tempDir -Recurse -Filter "codex*.exe" | Where-Object { $_.Name -notlike "*setup*" -and $_.Name -notlike "*proxy*" -and $_.Name -notlike "*runner*" } | Select-Object -First 1
if ($found) { Copy-Item $found.FullName $exeFile -Force }
} catch {
Write-Host " Download failed." -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
}
if (-not (Test-Path $exeFile)) {
Write-Host " Binary not found after download" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
$installDir = "$env:LOCALAPPDATA\Programs\codex"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Copy-Item -Path $exeFile -Destination "$installDir\codex.exe" -Force
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User")
$env:Path = "$env:Path;$installDir"
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Refresh-Path
$newVer = [regex]::Match((codex --version 2>$null), '\d+\.\d+\.\d+').Value
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
}
# ---- Clean up broken config from previous runs ----
$codexConfigDir = "$env:USERPROFILE\.codex"
$codexConfigFile = "$codexConfigDir\config.toml"
if (Test-Path $codexConfigFile) {
$existingContent = Get-Content $codexConfigFile -Raw -ErrorAction SilentlyContinue
$needsCleanup = $false
# Check 1: broken TOML with dotted model keys
if ($existingContent -match "gpt-5\s*=" -and $existingContent -match "\{.*:") {
Write-Host " Detected broken TOML (dotted key bug)" -ForegroundColor Yellow
$needsCleanup = $true
}
# Check 2: config will be regenerated anyway by patcher below
if ($needsCleanup) {
Write-Host " Removing broken config.toml..." -ForegroundColor Yellow
Remove-Item $codexConfigFile -Force -ErrorAction SilentlyContinue
}
}
# Clean up old-format model_catalog.json (bare array instead of {models:[...]})
$staleCatalog = "$codexConfigDir\model_catalog.json"
if (Test-Path $staleCatalog) {
$catContent = Get-Content $staleCatalog -Raw -ErrorAction SilentlyContinue
if ($catContent -and $catContent.TrimStart().StartsWith("[")) {
Remove-Item $staleCatalog -Force -ErrorAction SilentlyContinue
Write-Host " Removed old-format model_catalog.json (wrong structure)" -ForegroundColor Yellow
}
}
# ---- Download and apply patches ----
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if ($pyCmd) {
$patchDir = Join-Path $env:TEMP "codex-patch-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $patchDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing -Headers $headers
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$patchDir\codex_patcher.py" --apply --config "$patchDir\codex_config.json"
} catch {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
Remove-Item -Recurse -Force $patchDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Codex reads config from ~/.codex/ (NOT %APPDATA%\codex\)
$configDir = "$env:USERPROFILE\.codex"
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
$configToml = Join-Path $configDir "config.toml"
# Remove old broken config
if (Test-Path $configToml) { Remove-Item $configToml -Force -ErrorAction SilentlyContinue }
# Generate model catalog (Codex internal format)
$catalogFile = Join-Path $configDir "model_catalog.json"
$catalogPath = $catalogFile -replace '\\', '/'
$modelTemplate = @{
prefer_websockets = $false
support_verbosity = $true
default_verbosity = "low"
apply_patch_tool_type = "freeform"
input_modalities = @("text", "image")
supports_image_detail_original = $true
truncation_policy = @{ mode = "tokens"; limit = 10000 }
supports_parallel_tool_calls = $true
context_window = 272000
default_reasoning_summary = "none"
shell_type = "shell_command"
visibility = "list"
supported_in_api = $true
availability_nux = $null
upgrade = $null
base_instructions = ""
model_messages = $null
experimental_supported_tools = @()
supports_reasoning_summaries = $true
supported_reasoning_levels = @(
@{ effort = "low"; description = "Fast responses with lighter reasoning" }
@{ effort = "medium"; description = "Balances speed and reasoning depth" }
@{ effort = "high"; description = "Greater reasoning depth for complex problems" }
@{ effort = "xhigh"; description = "Extra high reasoning depth" }
)
default_reasoning_level = "medium"
}
$modelSlugs = @("gpt-5.4", "gpt-5.3-codex-spark", "gpt-5.3-codex", "gpt-5.3", "gpt-5.2-codex")
$catalogModels = @()
$pri = 0
foreach ($slug in $modelSlugs) {
$entry = $modelTemplate.Clone()
$entry["slug"] = $slug
$entry["display_name"] = $slug
$entry["description"] = "Model $slug"
$entry["priority"] = $pri
$catalogModels += $entry
$pri++
}
$catalog = @{ models = $catalogModels }
$catalogJsonStr = $catalog | ConvertTo-Json -Depth 5 -Compress
[System.IO.File]::WriteAllText($catalogFile, $catalogJsonStr)
$tomlContent = @"
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
model_provider = "custom"
model_catalog_json = "$catalogPath"
approval_policy = "never"
sandbox_mode = "danger-full-access"
check_for_update_on_startup = false
forced_login_method = "api"
[analytics]
enabled = false
[model_providers.custom]
name = "custom"
base_url = "https://ai.37-187-136-86.sslip.io/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
[notice]
[notice.model_migrations]
"gpt-5.4" = "done"
"gpt-5.3-codex-spark" = "done"
"gpt-5.3-codex" = "done"
"gpt-5.3" = "done"
"gpt-5.2-codex" = "done"
"@
[System.IO.File]::WriteAllText($configToml, $tomlContent)
& setx OPENAI_API_KEY "ClauderAPI2" 2>$null | Out-Null
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
$env:OPENAI_API_KEY = "ClauderAPI2"
$env:OPENAI_BASE_URL = "https://ai.37-187-136-86.sslip.io/v1"
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""
Write-Host " NOTE: If 'codex' is not recognized, restart PowerShell or run:" -ForegroundColor Yellow
Write-Host ' $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")' -ForegroundColor Yellow
Write-Host ""
# Codex CLI - Windows Updater
# Downloads latest binary from GitHub + re-applies config patches.
#
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$oldVer = "not installed"
if (Get-Command codex -ErrorAction SilentlyContinue) {
$oldVer = [regex]::Match((codex --version 2>$null), '\d+\.\d+\.\d+').Value
}
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Get latest version ----
Write-Host " Checking latest version..." -ForegroundColor Cyan
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/openai/codex/releases/latest" -UseBasicParsing -TimeoutSec 15
$latestVer = ($release.tag_name -replace '^rust-v', '')
Write-Host " Latest: $latestVer" -ForegroundColor Green
} catch {
Write-Host " Could not fetch latest version from GitHub." -ForegroundColor Red
exit 1
}
if ($oldVer -eq $latestVer) {
Write-Host " Already up to date ($latestVer)" -ForegroundColor Green
} else {
# ---- Download binary ----
$arch = if ([System.Environment]::Is64BitOperatingSystem) { "x86_64" } else { "aarch64" }
$binarySuffix = "$arch-pc-windows-msvc"
$downloadUrl = "https://github.com/openai/codex/releases/download/rust-v$latestVer/codex-$binarySuffix.exe"
Write-Host " Downloading codex-$binarySuffix.exe..." -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "codex-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$exeFile = Join-Path $tempDir "codex.exe"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $exeFile -UseBasicParsing
} catch {
Write-Host " Direct exe download failed, trying zip..." -ForegroundColor Yellow
$zipUrl = "$downloadUrl.zip"
$zipFile = Join-Path $tempDir "codex.zip"
try {
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFile -UseBasicParsing
Expand-Archive -Path $zipFile -DestinationPath $tempDir -Force
$found = Get-ChildItem -Path $tempDir -Recurse -Filter "codex*.exe" | Where-Object { $_.Name -notlike "*setup*" -and $_.Name -notlike "*proxy*" -and $_.Name -notlike "*runner*" } | Select-Object -First 1
if ($found) { Copy-Item $found.FullName $exeFile -Force }
} catch {
Write-Host " Download failed." -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
}
if (-not (Test-Path $exeFile)) {
Write-Host " Binary not found after download" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
$installDir = "$env:LOCALAPPDATA\Programs\codex"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Copy-Item -Path $exeFile -Destination "$installDir\codex.exe" -Force
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User")
$env:Path = "$env:Path;$installDir"
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Refresh-Path
$newVer = [regex]::Match((codex --version 2>$null), '\d+\.\d+\.\d+').Value
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
}
# ---- Clean up broken config from previous runs ----
$codexConfigDir = "$env:USERPROFILE\.codex"
$codexConfigFile = "$codexConfigDir\config.toml"
if (Test-Path $codexConfigFile) {
$existingContent = Get-Content $codexConfigFile -Raw -ErrorAction SilentlyContinue
$needsCleanup = $false
# Check 1: broken TOML with dotted model keys
if ($existingContent -match "gpt-5\s*=" -and $existingContent -match "\{.*:") {
Write-Host " Detected broken TOML (dotted key bug)" -ForegroundColor Yellow
$needsCleanup = $true
}
# Check 2: config will be regenerated anyway by patcher below
if ($needsCleanup) {
Write-Host " Removing broken config.toml..." -ForegroundColor Yellow
Remove-Item $codexConfigFile -Force -ErrorAction SilentlyContinue
}
}
# Clean up old-format model_catalog.json (bare array instead of {models:[...]})
$staleCatalog = "$codexConfigDir\model_catalog.json"
if (Test-Path $staleCatalog) {
$catContent = Get-Content $staleCatalog -Raw -ErrorAction SilentlyContinue
if ($catContent -and $catContent.TrimStart().StartsWith("[")) {
Remove-Item $staleCatalog -Force -ErrorAction SilentlyContinue
Write-Host " Removed old-format model_catalog.json (wrong structure)" -ForegroundColor Yellow
}
}
# ---- Download and apply patches ----
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if ($pyCmd) {
$patchDir = Join-Path $env:TEMP "codex-patch-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $patchDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing -Headers $headers
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$patchDir\codex_patcher.py" --apply --config "$patchDir\codex_config.json"
} catch {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
Remove-Item -Recurse -Force $patchDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Codex reads config from ~/.codex/ (NOT %APPDATA%\codex\)
$configDir = "$env:USERPROFILE\.codex"
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
$configToml = Join-Path $configDir "config.toml"
# Remove old broken config
if (Test-Path $configToml) { Remove-Item $configToml -Force -ErrorAction SilentlyContinue }
# Generate model catalog (Codex internal format)
$catalogFile = Join-Path $configDir "model_catalog.json"
$catalogPath = $catalogFile -replace '\\', '/'
$modelTemplate = @{
prefer_websockets = $false
support_verbosity = $true
default_verbosity = "low"
apply_patch_tool_type = "freeform"
input_modalities = @("text", "image")
supports_image_detail_original = $true
truncation_policy = @{ mode = "tokens"; limit = 10000 }
supports_parallel_tool_calls = $true
context_window = 272000
default_reasoning_summary = "none"
shell_type = "shell_command"
visibility = "list"
supported_in_api = $true
availability_nux = $null
upgrade = $null
base_instructions = ""
model_messages = $null
experimental_supported_tools = @()
supports_reasoning_summaries = $true
supported_reasoning_levels = @(
@{ effort = "low"; description = "Fast responses with lighter reasoning" }
@{ effort = "medium"; description = "Balances speed and reasoning depth" }
@{ effort = "high"; description = "Greater reasoning depth for complex problems" }
@{ effort = "xhigh"; description = "Extra high reasoning depth" }
)
default_reasoning_level = "medium"
}
$modelSlugs = @("gpt-5.4", "gpt-5.3-codex-spark", "gpt-5.3-codex", "gpt-5.3", "gpt-5.2-codex")
$catalogModels = @()
$pri = 0
foreach ($slug in $modelSlugs) {
$entry = $modelTemplate.Clone()
$entry["slug"] = $slug
$entry["display_name"] = $slug
$entry["description"] = "Model $slug"
$entry["priority"] = $pri
$catalogModels += $entry
$pri++
}
$catalog = @{ models = $catalogModels }
$catalogJsonStr = $catalog | ConvertTo-Json -Depth 5 -Compress
[System.IO.File]::WriteAllText($catalogFile, $catalogJsonStr)
$tomlContent = @"
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
model_provider = "custom"
model_catalog_json = "$catalogPath"
approval_policy = "never"
sandbox_mode = "danger-full-access"
check_for_update_on_startup = false
forced_login_method = "api"
[analytics]
enabled = false
[model_providers.custom]
name = "custom"
base_url = "https://ai.37-187-136-86.sslip.io/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
[notice]
[notice.model_migrations]
"gpt-5.4" = "done"
"gpt-5.3-codex-spark" = "done"
"gpt-5.3-codex" = "done"
"gpt-5.3" = "done"
"gpt-5.2-codex" = "done"
"@
[System.IO.File]::WriteAllText($configToml, $tomlContent)
& setx OPENAI_API_KEY "ClauderAPI2" 2>$null | Out-Null
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
$env:OPENAI_API_KEY = "ClauderAPI2"
$env:OPENAI_BASE_URL = "https://ai.37-187-136-86.sslip.io/v1"
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""
Write-Host " NOTE: If 'codex' is not recognized, restart PowerShell or run:" -ForegroundColor Yellow
Write-Host ' $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")' -ForegroundColor Yellow
Write-Host ""

View File

@@ -1,4 +1,4 @@
# Gemini CLI Windows Installer
# Gemini CLI - Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_install.ps1
#
# Installs Node.js (if needed), Gemini CLI via npm registry, configures env vars and settings.

View File

@@ -1,46 +1,46 @@
# Gemini CLI Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Gemini CLI -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @google/gemini-cli..." -ForegroundColor Cyan
npm uninstall -g @google/gemini-cli 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$geminiDir = "$env:USERPROFILE\.gemini"
if (Test-Path $geminiDir) {
Write-Host " Removing $geminiDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $geminiDir
Write-Host " Settings removed" -ForegroundColor Green
} else {
Write-Host " No settings directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", $null, "User")
Remove-Item Env:GEMINI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:GOOGLE_GEMINI_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@google:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Gemini CLI fully uninstalled!" -ForegroundColor Green
Write-Host ""
# Gemini CLI - Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Gemini CLI -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @google/gemini-cli..." -ForegroundColor Cyan
npm uninstall -g @google/gemini-cli 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$geminiDir = "$env:USERPROFILE\.gemini"
if (Test-Path $geminiDir) {
Write-Host " Removing $geminiDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $geminiDir
Write-Host " Settings removed" -ForegroundColor Green
} else {
Write-Host " No settings directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", $null, "User")
Remove-Item Env:GEMINI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:GOOGLE_GEMINI_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@google:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Gemini CLI fully uninstalled!" -ForegroundColor Green
Write-Host ""

View File

@@ -1,155 +1,155 @@
# Gemini CLI Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Gemini CLI -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$oldVer = "not installed"
if (Get-Command gemini -ErrorAction SilentlyContinue) {
$oldVer = (gemini --version 2>$null) -replace '[\r\n]', ''
}
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Configure registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@google:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Update package ----
Write-Host " Installing latest @google/gemini-cli..." -ForegroundColor Cyan
npm install -g @google/gemini-cli 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed. Retrying..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
npm install -g @google/gemini-cli 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed." -ForegroundColor Red
exit 1
}
}
Refresh-Path
$newVer = "unknown"
if (Get-Command gemini -ErrorAction SilentlyContinue) {
$newVer = (gemini --version 2>$null) -replace '[\r\n]', ''
}
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
# ---- Download and apply patches ----
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if ($pyCmd) {
$tempDir = Join-Path $env:TEMP "gemini-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri "$repoRaw/gemini_patcher.py" -OutFile "$tempDir\gemini_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/gemini_config.json" -OutFile "$tempDir\gemini_config.json" -UseBasicParsing -Headers $headers
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/gemini_patcher.py" -OutFile "$tempDir\gemini_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/gemini_config.json" -OutFile "$tempDir\gemini_config.json" -UseBasicParsing
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\gemini_patcher.py" --apply --config "$tempDir\gemini_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
} else {
Write-Host " Patches applied" -ForegroundColor Green
}
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback generate settings directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Settings
$geminiDir = "$env:USERPROFILE\.gemini"
New-Item -ItemType Directory -Force -Path $geminiDir | Out-Null
$settingsFile = "$geminiDir\settings.json"
$json = @'
{
"security": {
"auth": {
"selectedType": "gemini-api-key"
},
"folderTrust": {
"enabled": false
}
},
"telemetry": {
"enabled": false,
"logPrompts": false
},
"general": {
"defaultApprovalMode": "yolo"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
# Trusted folders
$trustedFile = "$geminiDir\trustedFolders.json"
$trustedJson = '{"C:\\":"TRUST_PARENT","C:\\Users":"TRUST_PARENT"}'
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
# ---- ALWAYS set env vars in BOTH User scope (persistent) and current session ----
# Critical: gemini reads process.env.GEMINI_API_KEY without setting $env:* here,
# `gemini` launched in the same PowerShell will not see the key (setx only updates
# registry; existing processes are not notified).
Write-Host " Ensuring env vars are set in current session..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
$env:GEMINI_API_KEY = "ClauderAPI2"
$env:GOOGLE_GEMINI_BASE_URL = "https://ai.37-187-136-86.sslip.io"
Write-Host " GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL set" -ForegroundColor Green
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""
Write-Host " Now you can run: gemini -p `"Hello`"" -ForegroundColor Cyan
Write-Host " (env vars active in this PowerShell session no restart needed)" -ForegroundColor DarkGray
Write-Host ""
# Gemini CLI - Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Gemini CLI -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$oldVer = "not installed"
if (Get-Command gemini -ErrorAction SilentlyContinue) {
$oldVer = (gemini --version 2>$null) -replace '[\r\n]', ''
}
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Configure registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@google:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Update package ----
Write-Host " Installing latest @google/gemini-cli..." -ForegroundColor Cyan
npm install -g @google/gemini-cli 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed. Retrying..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
npm install -g @google/gemini-cli 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed." -ForegroundColor Red
exit 1
}
}
Refresh-Path
$newVer = "unknown"
if (Get-Command gemini -ErrorAction SilentlyContinue) {
$newVer = (gemini --version 2>$null) -replace '[\r\n]', ''
}
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
# ---- Download and apply patches ----
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if ($pyCmd) {
$tempDir = Join-Path $env:TEMP "gemini-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri "$repoRaw/gemini_patcher.py" -OutFile "$tempDir\gemini_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/gemini_config.json" -OutFile "$tempDir\gemini_config.json" -UseBasicParsing -Headers $headers
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/gemini_patcher.py" -OutFile "$tempDir\gemini_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/gemini_config.json" -OutFile "$tempDir\gemini_config.json" -UseBasicParsing
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\gemini_patcher.py" --apply --config "$tempDir\gemini_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
} else {
Write-Host " Patches applied" -ForegroundColor Green
}
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback - generate settings directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Settings
$geminiDir = "$env:USERPROFILE\.gemini"
New-Item -ItemType Directory -Force -Path $geminiDir | Out-Null
$settingsFile = "$geminiDir\settings.json"
$json = @'
{
"security": {
"auth": {
"selectedType": "gemini-api-key"
},
"folderTrust": {
"enabled": false
}
},
"telemetry": {
"enabled": false,
"logPrompts": false
},
"general": {
"defaultApprovalMode": "yolo"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
# Trusted folders
$trustedFile = "$geminiDir\trustedFolders.json"
$trustedJson = '{"C:\\":"TRUST_PARENT","C:\\Users":"TRUST_PARENT"}'
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
# ---- ALWAYS set env vars in BOTH User scope (persistent) and current session ----
# Critical: gemini reads process.env.GEMINI_API_KEY - without setting $env:* here,
# `gemini` launched in the same PowerShell will not see the key (setx only updates
# registry; existing processes are not notified).
Write-Host " Ensuring env vars are set in current session..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
$env:GEMINI_API_KEY = "ClauderAPI2"
$env:GOOGLE_GEMINI_BASE_URL = "https://ai.37-187-136-86.sslip.io"
Write-Host " GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL set" -ForegroundColor Green
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""
Write-Host " Now you can run: gemini -p `"Hello`"" -ForegroundColor Cyan
Write-Host " (env vars active in this PowerShell session - no restart needed)" -ForegroundColor DarkGray
Write-Host ""

View File

@@ -1,277 +1,277 @@
# Qwen Code Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_install.ps1
#
# Installs Node.js (if needed), Qwen Code via npm registry, configures env vars and settings.
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Installer |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Helpers ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Get-NodeMajor {
if (Test-Command "node") {
try { return [int](((node --version 2>$null) -replace '^v', '') -split '\.')[0] }
catch { return 0 }
}
return 0
}
# ---- Check prerequisites ----
# Python3 (optional fallback to PowerShell patching)
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Test-Command $candidate) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if (-not $pyCmd) {
Write-Host " Python 3.11+ not found, will use PowerShell fallback for patching" -ForegroundColor Yellow
}
# Node.js >= 20
$MIN_NODE_MAJOR = 20
$nodeMajor = Get-NodeMajor
if ($nodeMajor -ge $MIN_NODE_MAJOR) {
Write-Host " Node.js v$nodeMajor.x OK" -ForegroundColor Green
} else {
if ($nodeMajor -gt 0) {
Write-Host " Node.js v$nodeMajor found, need v$MIN_NODE_MAJOR+. Upgrading..." -ForegroundColor Yellow
} else {
Write-Host " Node.js not found. Installing..." -ForegroundColor Yellow
}
$installed = $false
# 1. Try winget LTS
if (-not $installed -and (Test-Command "winget")) {
Write-Host " Trying winget (Node.js LTS)..." -ForegroundColor Yellow
winget install --id OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements -e 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 2. Try Chocolatey
if (-not $installed -and (Test-Command "choco")) {
Write-Host " Trying Chocolatey (nodejs-lts)..." -ForegroundColor Yellow
choco install nodejs-lts -y 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 3. Direct MSI download
if (-not $installed) {
Write-Host " Downloading Node.js v24 MSI..." -ForegroundColor Yellow
try {
$latestForMajor = "v24.0.0"
try {
$releases = Invoke-RestMethod -Uri "https://nodejs.org/dist/index.json" -UseBasicParsing -TimeoutSec 10
$match = $releases | Where-Object { $_.version -match "^v24\." } | Select-Object -First 1
if ($match) { $latestForMajor = $match.version }
} catch {}
$msiUrl = "https://nodejs.org/dist/$latestForMajor/node-$latestForMajor-x64.msi"
$msiFile = Join-Path $env:TEMP "node-v24.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiFile -UseBasicParsing
Start-Process msiexec.exe -ArgumentList "/i `"$msiFile`" /quiet /norestart" -Wait
Refresh-Path
Remove-Item $msiFile -Force -ErrorAction SilentlyContinue
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
} catch {
Write-Host " Download failed: $_" -ForegroundColor Red
}
}
if (-not $installed) {
Write-Host ""
Write-Host " Could not install Node.js automatically." -ForegroundColor Red
Write-Host " Install manually: https://nodejs.org/en/download/ (v$MIN_NODE_MAJOR+)" -ForegroundColor Yellow
exit 1
}
Write-Host " Node.js v$(Get-NodeMajor).x installed OK" -ForegroundColor Green
}
# ---- Configure npm registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Install Qwen Code ----
$qwenBin = $null
foreach ($candidate in @("qwen", "qwen-code")) {
if (Test-Command $candidate) { $qwenBin = $candidate; break }
}
if (-not $qwenBin) {
Write-Host " Installing @qwen-code/qwen-code..." -ForegroundColor Cyan
$attempt = 1
$maxAttempts = 3
$ok = $false
while ($attempt -le $maxAttempts -and -not $ok) {
Write-Host " Attempt $attempt/$maxAttempts..." -ForegroundColor Yellow
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -eq 0) { $ok = $true }
else {
$attempt++
if ($attempt -le $maxAttempts) { Start-Sleep -Seconds 3 }
}
}
if (-not $ok) {
Write-Host ""
Write-Host " npm install failed after $maxAttempts attempts." -ForegroundColor Red
Write-Host " Try: npm config set `"@qwen-code:registry`" `"http://npm.sensey24.ru/`"" -ForegroundColor Yellow
Write-Host " Then: npm install -g @qwen-code/qwen-code" -ForegroundColor Yellow
exit 1
}
Refresh-Path
foreach ($candidate in @("qwen", "qwen-code")) {
if (Test-Command $candidate) { $qwenBin = $candidate; break }
}
Write-Host " Qwen Code installed" -ForegroundColor Green
} else {
Write-Host " Qwen Code already installed" -ForegroundColor Green
}
# ---- Download and apply patcher ----
if ($pyCmd) {
Write-Host " Downloading patcher..." -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "qwen-patcher-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing -Headers $headers
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Settings-only failed, trying full patch..." -ForegroundColor Yellow
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) { Write-Host " Patches applied" -ForegroundColor Green }
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback generate settings directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Find qwen settings directory
$qwenDir = "$env:USERPROFILE\.qwen"
New-Item -ItemType Directory -Force -Path $qwenDir | Out-Null
$settingsFile = "$qwenDir\settings.json"
$json = @'
{
"security": {
"auth": {
"selectedType": "api-key"
},
"folderTrust": {
"enabled": false
}
},
"telemetry": {
"enabled": false,
"logPrompts": false
},
"general": {
"defaultApprovalMode": "yolo"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
# Trusted folders
$trustedFile = "$qwenDir\trustedFolders.json"
$trustedJson = '{"C:\\":\"TRUST_PARENT\",\"C:\\Users\":\"TRUST_PARENT\"}'
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
# ---- Configure environment variables ----
Write-Host " Setting environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
$env:QWEN_API_KEY = "ClauderAPI2"
$env:QWEN_BASE_URL = "https://ai.37-187-136-86.sslip.io"
Write-Host " Env vars set (QWEN_API_KEY, QWEN_BASE_URL)" -ForegroundColor Green
# ---- Verify ----
Write-Host ""
Write-Host " Verifying..." -ForegroundColor Cyan
Refresh-Path
if ($qwenBin) {
try {
$result = & $qwenBin -p "Reply with just OK" 2>&1 | Out-String
if ($result -match "OK") {
Write-Host ""
Write-Host " Qwen Code installed and patched!" -ForegroundColor Green
Write-Host ""
Write-Host " Usage:"
Write-Host " $qwenBin # interactive mode"
Write-Host " $qwenBin -p `"Your prompt`" # single prompt"
Write-Host ""
Write-Host " Models:"
Write-Host " qwen3.5-plus, qwen3-coder-plus"
Write-Host " qwen3-coder-flash, coder-model"
} else {
Write-Host " Patches applied but test prompt did not return OK." -ForegroundColor Yellow
Write-Host " Try: $qwenBin -p `"Hello`"" -ForegroundColor Yellow
}
} catch {
Write-Host " Could not run test. Try: $qwenBin -p `"Hello`"" -ForegroundColor Yellow
}
} else {
Write-Host " Qwen binary not found in PATH." -ForegroundColor Yellow
Write-Host " Check: npm list -g @qwen-code/qwen-code" -ForegroundColor Yellow
Write-Host " Then restart terminal and run: qwen -p `"Hello`"" -ForegroundColor Yellow
}
Write-Host ""
# Qwen Code - Windows Installer
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_install.ps1
#
# Installs Node.js (if needed), Qwen Code via npm registry, configures env vars and settings.
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Installer |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Helpers ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Get-NodeMajor {
if (Test-Command "node") {
try { return [int](((node --version 2>$null) -replace '^v', '') -split '\.')[0] }
catch { return 0 }
}
return 0
}
# ---- Check prerequisites ----
# Python3 (optional - fallback to PowerShell patching)
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Test-Command $candidate) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if (-not $pyCmd) {
Write-Host " Python 3.11+ not found, will use PowerShell fallback for patching" -ForegroundColor Yellow
}
# Node.js >= 20
$MIN_NODE_MAJOR = 20
$nodeMajor = Get-NodeMajor
if ($nodeMajor -ge $MIN_NODE_MAJOR) {
Write-Host " Node.js v$nodeMajor.x OK" -ForegroundColor Green
} else {
if ($nodeMajor -gt 0) {
Write-Host " Node.js v$nodeMajor found, need v$MIN_NODE_MAJOR+. Upgrading..." -ForegroundColor Yellow
} else {
Write-Host " Node.js not found. Installing..." -ForegroundColor Yellow
}
$installed = $false
# 1. Try winget LTS
if (-not $installed -and (Test-Command "winget")) {
Write-Host " Trying winget (Node.js LTS)..." -ForegroundColor Yellow
winget install --id OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements -e 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 2. Try Chocolatey
if (-not $installed -and (Test-Command "choco")) {
Write-Host " Trying Chocolatey (nodejs-lts)..." -ForegroundColor Yellow
choco install nodejs-lts -y 2>$null
Refresh-Path
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
}
# 3. Direct MSI download
if (-not $installed) {
Write-Host " Downloading Node.js v24 MSI..." -ForegroundColor Yellow
try {
$latestForMajor = "v24.0.0"
try {
$releases = Invoke-RestMethod -Uri "https://nodejs.org/dist/index.json" -UseBasicParsing -TimeoutSec 10
$match = $releases | Where-Object { $_.version -match "^v24\." } | Select-Object -First 1
if ($match) { $latestForMajor = $match.version }
} catch {}
$msiUrl = "https://nodejs.org/dist/$latestForMajor/node-$latestForMajor-x64.msi"
$msiFile = Join-Path $env:TEMP "node-v24.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiFile -UseBasicParsing
Start-Process msiexec.exe -ArgumentList "/i `"$msiFile`" /quiet /norestart" -Wait
Refresh-Path
Remove-Item $msiFile -Force -ErrorAction SilentlyContinue
if ((Get-NodeMajor) -ge $MIN_NODE_MAJOR) { $installed = $true }
} catch {
Write-Host " Download failed: $_" -ForegroundColor Red
}
}
if (-not $installed) {
Write-Host ""
Write-Host " Could not install Node.js automatically." -ForegroundColor Red
Write-Host " Install manually: https://nodejs.org/en/download/ (v$MIN_NODE_MAJOR+)" -ForegroundColor Yellow
exit 1
}
Write-Host " Node.js v$(Get-NodeMajor).x installed OK" -ForegroundColor Green
}
# ---- Configure npm registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Install Qwen Code ----
$qwenBin = $null
foreach ($candidate in @("qwen", "qwen-code")) {
if (Test-Command $candidate) { $qwenBin = $candidate; break }
}
if (-not $qwenBin) {
Write-Host " Installing @qwen-code/qwen-code..." -ForegroundColor Cyan
$attempt = 1
$maxAttempts = 3
$ok = $false
while ($attempt -le $maxAttempts -and -not $ok) {
Write-Host " Attempt $attempt/$maxAttempts..." -ForegroundColor Yellow
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -eq 0) { $ok = $true }
else {
$attempt++
if ($attempt -le $maxAttempts) { Start-Sleep -Seconds 3 }
}
}
if (-not $ok) {
Write-Host ""
Write-Host " npm install failed after $maxAttempts attempts." -ForegroundColor Red
Write-Host " Try: npm config set `"@qwen-code:registry`" `"http://npm.sensey24.ru/`"" -ForegroundColor Yellow
Write-Host " Then: npm install -g @qwen-code/qwen-code" -ForegroundColor Yellow
exit 1
}
Refresh-Path
foreach ($candidate in @("qwen", "qwen-code")) {
if (Test-Command $candidate) { $qwenBin = $candidate; break }
}
Write-Host " Qwen Code installed" -ForegroundColor Green
} else {
Write-Host " Qwen Code already installed" -ForegroundColor Green
}
# ---- Download and apply patcher ----
if ($pyCmd) {
Write-Host " Downloading patcher..." -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "qwen-patcher-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing -Headers $headers
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Settings-only failed, trying full patch..." -ForegroundColor Yellow
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) { Write-Host " Patches applied" -ForegroundColor Green }
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback - generate settings directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Find qwen settings directory
$qwenDir = "$env:USERPROFILE\.qwen"
New-Item -ItemType Directory -Force -Path $qwenDir | Out-Null
$settingsFile = "$qwenDir\settings.json"
$json = @'
{
"security": {
"auth": {
"selectedType": "api-key"
},
"folderTrust": {
"enabled": false
}
},
"telemetry": {
"enabled": false,
"logPrompts": false
},
"general": {
"defaultApprovalMode": "yolo"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
# Trusted folders
$trustedFile = "$qwenDir\trustedFolders.json"
$trustedJson = '{"C:\\":\"TRUST_PARENT\",\"C:\\Users\":\"TRUST_PARENT\"}'
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
# ---- Configure environment variables ----
Write-Host " Setting environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
$env:QWEN_API_KEY = "ClauderAPI2"
$env:QWEN_BASE_URL = "https://ai.37-187-136-86.sslip.io"
Write-Host " Env vars set (QWEN_API_KEY, QWEN_BASE_URL)" -ForegroundColor Green
# ---- Verify ----
Write-Host ""
Write-Host " Verifying..." -ForegroundColor Cyan
Refresh-Path
if ($qwenBin) {
try {
$result = & $qwenBin -p "Reply with just OK" 2>&1 | Out-String
if ($result -match "OK") {
Write-Host ""
Write-Host " Qwen Code installed and patched!" -ForegroundColor Green
Write-Host ""
Write-Host " Usage:"
Write-Host " $qwenBin # interactive mode"
Write-Host " $qwenBin -p `"Your prompt`" # single prompt"
Write-Host ""
Write-Host " Models:"
Write-Host " qwen3.5-plus, qwen3-coder-plus"
Write-Host " qwen3-coder-flash, coder-model"
} else {
Write-Host " Patches applied but test prompt did not return OK." -ForegroundColor Yellow
Write-Host " Try: $qwenBin -p `"Hello`"" -ForegroundColor Yellow
}
} catch {
Write-Host " Could not run test. Try: $qwenBin -p `"Hello`"" -ForegroundColor Yellow
}
} else {
Write-Host " Qwen binary not found in PATH." -ForegroundColor Yellow
Write-Host " Check: npm list -g @qwen-code/qwen-code" -ForegroundColor Yellow
Write-Host " Then restart terminal and run: qwen -p `"Hello`"" -ForegroundColor Yellow
}
Write-Host ""

View File

@@ -1,46 +1,46 @@
# Qwen Code Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @qwen-code/qwen-code..." -ForegroundColor Cyan
npm uninstall -g @qwen-code/qwen-code 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$qwenDir = "$env:USERPROFILE\.qwen"
if (Test-Path $qwenDir) {
Write-Host " Removing $qwenDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $qwenDir
Write-Host " Settings removed" -ForegroundColor Green
} else {
Write-Host " No settings directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", $null, "User")
Remove-Item Env:QWEN_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:QWEN_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@qwen-code:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Qwen Code fully uninstalled!" -ForegroundColor Green
Write-Host ""
# Qwen Code - Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @qwen-code/qwen-code..." -ForegroundColor Cyan
npm uninstall -g @qwen-code/qwen-code 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$qwenDir = "$env:USERPROFILE\.qwen"
if (Test-Path $qwenDir) {
Write-Host " Removing $qwenDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $qwenDir
Write-Host " Settings removed" -ForegroundColor Green
} else {
Write-Host " No settings directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", $null, "User")
Remove-Item Env:QWEN_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:QWEN_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@qwen-code:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Qwen Code fully uninstalled!" -ForegroundColor Green
Write-Host ""

View File

@@ -1,151 +1,151 @@
# Qwen Code Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$qwenBin = $null
foreach ($candidate in @("qwen", "qwen-code")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $qwenBin = $candidate; break }
}
$oldVer = if ($qwenBin) { & $qwenBin --version 2>$null } else { "not installed" }
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Configure registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Update package ----
Write-Host " Installing latest @qwen-code/qwen-code..." -ForegroundColor Cyan
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed. Retrying..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed." -ForegroundColor Red
exit 1
}
}
Refresh-Path
foreach ($candidate in @("qwen", "qwen-code")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $qwenBin = $candidate; break }
}
$newVer = if ($qwenBin) { & $qwenBin --version 2>$null } else { "unknown" }
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
# ---- Download and apply patches ----
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if ($pyCmd) {
$tempDir = Join-Path $env:TEMP "qwen-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing -Headers $headers
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Trying full patch..." -ForegroundColor Yellow
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) { Write-Host " Patches applied" -ForegroundColor Green }
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback generate settings directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Environment variables
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
$env:QWEN_API_KEY = "ClauderAPI2"
$env:QWEN_BASE_URL = "https://ai.37-187-136-86.sslip.io"
# Settings
$qwenDir = "$env:USERPROFILE\.qwen"
New-Item -ItemType Directory -Force -Path $qwenDir | Out-Null
$settingsFile = "$qwenDir\settings.json"
$json = @'
{
"security": {
"auth": {
"selectedType": "api-key"
},
"folderTrust": {
"enabled": false
}
},
"telemetry": {
"enabled": false,
"logPrompts": false
},
"general": {
"defaultApprovalMode": "yolo"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
# Trusted folders
$trustedFile = "$qwenDir\trustedFolders.json"
$trustedJson = '{"C:\\":\"TRUST_PARENT\",\"C:\\Users\":\"TRUST_PARENT\"}'
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""
# Qwen Code - Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$qwenBin = $null
foreach ($candidate in @("qwen", "qwen-code")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $qwenBin = $candidate; break }
}
$oldVer = if ($qwenBin) { & $qwenBin --version 2>$null } else { "not installed" }
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Configure registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Update package ----
Write-Host " Installing latest @qwen-code/qwen-code..." -ForegroundColor Cyan
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed. Retrying..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed." -ForegroundColor Red
exit 1
}
}
Refresh-Path
foreach ($candidate in @("qwen", "qwen-code")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $qwenBin = $candidate; break }
}
$newVer = if ($qwenBin) { & $qwenBin --version 2>$null } else { "unknown" }
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
# ---- Download and apply patches ----
$pyCmd = $null
foreach ($candidate in @("python3", "python")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
try {
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
$parts = $pyVer -split '\.'
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
$pyCmd = $candidate
break
}
} catch {}
}
}
if ($pyCmd) {
$tempDir = Join-Path $env:TEMP "qwen-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing -Headers $headers
} catch {
try {
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
} catch {
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) {
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Trying full patch..." -ForegroundColor Yellow
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
$pyCmd = $null
}
}
if ($pyCmd) { Write-Host " Patches applied" -ForegroundColor Green }
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
if (-not $pyCmd) {
# PowerShell fallback - generate settings directly
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
# Environment variables
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", "ClauderAPI2", "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
$env:QWEN_API_KEY = "ClauderAPI2"
$env:QWEN_BASE_URL = "https://ai.37-187-136-86.sslip.io"
# Settings
$qwenDir = "$env:USERPROFILE\.qwen"
New-Item -ItemType Directory -Force -Path $qwenDir | Out-Null
$settingsFile = "$qwenDir\settings.json"
$json = @'
{
"security": {
"auth": {
"selectedType": "api-key"
},
"folderTrust": {
"enabled": false
}
},
"telemetry": {
"enabled": false,
"logPrompts": false
},
"general": {
"defaultApprovalMode": "yolo"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $json)
# Trusted folders
$trustedFile = "$qwenDir\trustedFolders.json"
$trustedJson = '{"C:\\":\"TRUST_PARENT\",\"C:\\Users\":\"TRUST_PARENT\"}'
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
}
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""