fix: TOML dotted key bug + PowerShell fallback for all Windows scripts
- codex: add [notice.model_migrations] with quoted keys to prevent Codex from writing unquoted dotted keys (gpt-5.4 → gpt-5 → 4) which causes "invalid type: map, expected a string" TOML error - codex_patcher.py: add toml_key() to quote keys with dots, handle broken TOML gracefully in read_toml() - claude install: remove unnecessary Python requirement - claude update: rewrite as standalone (no git clone dependency) - gemini update: add Python check with fallback, auth headers - qwen install: add PowerShell fallback, auth headers, no exit on no Python - qwen update: add Python check with fallback, auth headers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,19 +32,23 @@ function Get-NodeMajor {
|
||||
|
||||
# ---- Check prerequisites ----
|
||||
|
||||
# Python3
|
||||
if (-not (Test-Command "python3") -and -not (Test-Command "python")) {
|
||||
Write-Host " Python not found. Installing..." -ForegroundColor Yellow
|
||||
if (Test-Command "winget") {
|
||||
winget install --id Python.Python.3.12 --accept-package-agreements --accept-source-agreements -e 2>$null
|
||||
Refresh-Path
|
||||
} else {
|
||||
Write-Host " Install Python manually: https://www.python.org/downloads/" -ForegroundColor Red
|
||||
exit 1
|
||||
# Python3 (optional — fallback to PowerShell patching)
|
||||
$pyCmd = $null
|
||||
foreach ($candidate in @("python3", "python")) {
|
||||
if (Test-Command $candidate) {
|
||||
try {
|
||||
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
|
||||
$parts = $pyVer -split '\.'
|
||||
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
|
||||
$pyCmd = $candidate
|
||||
break
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
$pyCmd = if (Test-Command "python3") { "python3" } else { "python" }
|
||||
Write-Host " Python OK" -ForegroundColor Green
|
||||
if (-not $pyCmd) {
|
||||
Write-Host " Python 3.11+ not found, will use PowerShell fallback for patching" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Node.js >= 20
|
||||
$MIN_NODE_MAJOR = 20
|
||||
@@ -153,33 +157,80 @@ if (-not $qwenBin) {
|
||||
|
||||
# ---- Download and apply patcher ----
|
||||
|
||||
Write-Host " Downloading patcher..." -ForegroundColor Cyan
|
||||
$tempDir = Join-Path $env:TEMP "qwen-patcher-$(Get-Random)"
|
||||
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
|
||||
if ($pyCmd) {
|
||||
Write-Host " Downloading patcher..." -ForegroundColor Cyan
|
||||
$tempDir = Join-Path $env:TEMP "qwen-patcher-$(Get-Random)"
|
||||
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
|
||||
|
||||
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
|
||||
Write-Host " Patcher downloaded" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " Download failed: $_" -ForegroundColor Red
|
||||
Write-Host " Trying with auth token..." -ForegroundColor Yellow
|
||||
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
|
||||
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
|
||||
$headers = @{ "Authorization" = "token $token" }
|
||||
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
|
||||
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing -Headers $headers
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing -Headers $headers
|
||||
} catch {
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
|
||||
} catch {
|
||||
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
|
||||
$pyCmd = $null
|
||||
}
|
||||
}
|
||||
|
||||
if ($pyCmd) {
|
||||
Write-Host " Applying patches..." -ForegroundColor Cyan
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " Settings-only failed, trying full patch..." -ForegroundColor Yellow
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
|
||||
$pyCmd = $null
|
||||
}
|
||||
}
|
||||
if ($pyCmd) { Write-Host " Patches applied" -ForegroundColor Green }
|
||||
}
|
||||
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host " Applying patches..." -ForegroundColor Cyan
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " Settings-only patch failed, trying full patch..." -ForegroundColor Yellow
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
|
||||
}
|
||||
Write-Host " Patches applied" -ForegroundColor Green
|
||||
if (-not $pyCmd) {
|
||||
# PowerShell fallback — generate settings directly
|
||||
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
|
||||
|
||||
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
|
||||
# Find qwen settings directory
|
||||
$qwenDir = "$env:USERPROFILE\.qwen"
|
||||
New-Item -ItemType Directory -Force -Path $qwenDir | Out-Null
|
||||
|
||||
$settingsFile = "$qwenDir\settings.json"
|
||||
$json = @'
|
||||
{
|
||||
"security": {
|
||||
"auth": {
|
||||
"selectedType": "api-key"
|
||||
},
|
||||
"folderTrust": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
"telemetry": {
|
||||
"enabled": false,
|
||||
"logPrompts": false
|
||||
},
|
||||
"general": {
|
||||
"defaultApprovalMode": "yolo"
|
||||
}
|
||||
}
|
||||
'@
|
||||
[System.IO.File]::WriteAllText($settingsFile, $json)
|
||||
|
||||
# Trusted folders
|
||||
$trustedFile = "$qwenDir\trustedFolders.json"
|
||||
$trustedJson = '{"C:\\":\"TRUST_PARENT\",\"C:\\Users\":\"TRUST_PARENT\"}'
|
||||
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
|
||||
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# ---- Configure environment variables ----
|
||||
|
||||
|
||||
@@ -33,8 +33,13 @@ npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" 2>$null
|
||||
Write-Host " Installing latest @qwen-code/qwen-code..." -ForegroundColor Cyan
|
||||
npm install -g @qwen-code/qwen-code 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " npm install failed." -ForegroundColor Red
|
||||
exit 1
|
||||
Write-Host " npm install failed. Retrying..." -ForegroundColor Yellow
|
||||
Start-Sleep -Seconds 3
|
||||
npm install -g @qwen-code/qwen-code 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " npm install failed." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Refresh-Path
|
||||
|
||||
@@ -46,23 +51,100 @@ Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
|
||||
|
||||
# ---- Download and apply patches ----
|
||||
|
||||
$pyCmd = if (Get-Command python3 -ErrorAction SilentlyContinue) { "python3" } else { "python" }
|
||||
$tempDir = Join-Path $env:TEMP "qwen-update-$(Get-Random)"
|
||||
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
|
||||
|
||||
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
|
||||
Write-Host " Downloading patcher..." -ForegroundColor Cyan
|
||||
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
|
||||
|
||||
Write-Host " Applying patches..." -ForegroundColor Cyan
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " Trying full patch..." -ForegroundColor Yellow
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
|
||||
$pyCmd = $null
|
||||
foreach ($candidate in @("python3", "python")) {
|
||||
if (Get-Command $candidate -ErrorAction SilentlyContinue) {
|
||||
try {
|
||||
$pyVer = & $candidate -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
|
||||
$parts = $pyVer -split '\.'
|
||||
if ([int]$parts[0] -ge 3 -and [int]$parts[1] -ge 11) {
|
||||
$pyCmd = $candidate
|
||||
break
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
|
||||
if ($pyCmd) {
|
||||
$tempDir = Join-Path $env:TEMP "qwen-update-$(Get-Random)"
|
||||
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
|
||||
|
||||
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
|
||||
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
|
||||
$headers = @{ "Authorization" = "token $token" }
|
||||
|
||||
Write-Host " Downloading patcher..." -ForegroundColor Cyan
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing -Headers $headers
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing -Headers $headers
|
||||
} catch {
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
|
||||
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
|
||||
} catch {
|
||||
Write-Host " Patcher download failed, using PowerShell fallback" -ForegroundColor Yellow
|
||||
$pyCmd = $null
|
||||
}
|
||||
}
|
||||
|
||||
if ($pyCmd) {
|
||||
Write-Host " Applying patches..." -ForegroundColor Cyan
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " Trying full patch..." -ForegroundColor Yellow
|
||||
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " Patcher failed, using PowerShell fallback" -ForegroundColor Yellow
|
||||
$pyCmd = $null
|
||||
}
|
||||
}
|
||||
if ($pyCmd) { Write-Host " Patches applied" -ForegroundColor Green }
|
||||
}
|
||||
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
if (-not $pyCmd) {
|
||||
# PowerShell fallback — generate settings directly
|
||||
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
|
||||
|
||||
# Environment variables
|
||||
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", "ClauderAPI", "User")
|
||||
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
|
||||
$env:QWEN_API_KEY = "ClauderAPI"
|
||||
$env:QWEN_BASE_URL = "https://ai.37-187-136-86.sslip.io"
|
||||
|
||||
# Settings
|
||||
$qwenDir = "$env:USERPROFILE\.qwen"
|
||||
New-Item -ItemType Directory -Force -Path $qwenDir | Out-Null
|
||||
|
||||
$settingsFile = "$qwenDir\settings.json"
|
||||
$json = @'
|
||||
{
|
||||
"security": {
|
||||
"auth": {
|
||||
"selectedType": "api-key"
|
||||
},
|
||||
"folderTrust": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
"telemetry": {
|
||||
"enabled": false,
|
||||
"logPrompts": false
|
||||
},
|
||||
"general": {
|
||||
"defaultApprovalMode": "yolo"
|
||||
}
|
||||
}
|
||||
'@
|
||||
[System.IO.File]::WriteAllText($settingsFile, $json)
|
||||
|
||||
# Trusted folders
|
||||
$trustedFile = "$qwenDir\trustedFolders.json"
|
||||
$trustedJson = '{"C:\\":\"TRUST_PARENT\",\"C:\\Users\":\"TRUST_PARENT\"}'
|
||||
[System.IO.File]::WriteAllText($trustedFile, $trustedJson)
|
||||
Write-Host " Patches applied (PowerShell fallback)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host " Update complete!" -ForegroundColor Green
|
||||
|
||||
Reference in New Issue
Block a user