fix(codex): auto-cleanup broken model_catalog_json on install/update
All scripts now detect and fix leftover damage from previous installs: - Remove model_catalog_json from config.toml (crashes Codex on startup) - Delete stale model_catalog.json file - Detect broken TOML with dotted key bug Both PS1 scripts and Python patcher handle cleanup before patching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,39 @@ if ($oldVer -eq $latestVer) {
|
||||
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# ---- Clean up broken config from previous runs ----
|
||||
|
||||
$codexConfigDir = "$env:USERPROFILE\.codex"
|
||||
$codexConfigFile = "$codexConfigDir\config.toml"
|
||||
if (Test-Path $codexConfigFile) {
|
||||
$existingContent = Get-Content $codexConfigFile -Raw -ErrorAction SilentlyContinue
|
||||
$needsCleanup = $false
|
||||
|
||||
# Check 1: broken TOML with dotted model keys
|
||||
if ($existingContent -match "gpt-5\s*=" -and $existingContent -match "\{.*:") {
|
||||
Write-Host " Detected broken TOML (dotted key bug)" -ForegroundColor Yellow
|
||||
$needsCleanup = $true
|
||||
}
|
||||
|
||||
# Check 2: model_catalog_json with wrong format (crashes Codex)
|
||||
if ($existingContent -match "model_catalog_json") {
|
||||
Write-Host " Detected model_catalog_json (unsupported, removing)" -ForegroundColor Yellow
|
||||
$needsCleanup = $true
|
||||
}
|
||||
|
||||
if ($needsCleanup) {
|
||||
Write-Host " Removing broken config.toml..." -ForegroundColor Yellow
|
||||
Remove-Item $codexConfigFile -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
# Clean up stale model_catalog.json
|
||||
$staleCatalog = "$codexConfigDir\model_catalog.json"
|
||||
if (Test-Path $staleCatalog) {
|
||||
Remove-Item $staleCatalog -Force -ErrorAction SilentlyContinue
|
||||
Write-Host " Removed stale model_catalog.json" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# ---- Download and apply patches ----
|
||||
|
||||
$pyCmd = $null
|
||||
|
||||
Reference in New Issue
Block a user