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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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