fix(install): preserve codex plugin registrations during sync

This commit is contained in:
fraujulian committed 2026-09-16 19:18:22 +02:00
1 parent c6c8bf7105
commit c749fcd792
4 files changed
+71

No files matched your search

+12
View File
@@ -77,6 +77,18 @@ function Sync-ManagedDestination {
} else {
$newBytes = [System.IO.File]::ReadAllBytes($_.FullName)
}
if ($relative -eq 'config.toml' -and (Test-Path -LiteralPath $target)) {
$localConfig = [System.IO.File]::ReadAllText($target)
$pluginTables = [regex]::Matches($localConfig, '(?m)^[ \t]*\[(?:plugins|marketplaces)(?:\.|\])[\s\S]*?(?=^[ \t]*\[|\z)')
if ($pluginTables.Count -gt 0) {
$content = [System.Text.Encoding]::UTF8.GetString($newBytes).TrimEnd([char[]]"`r`n")
if ($content -match '(?m)^[ \t]*\[(?:plugins|marketplaces)(?:\.|\])') {
throw 'Cannot overwrite local plugin configuration with generated plugin tables.'
}
$preserved = ($pluginTables | ForEach-Object { $_.Value.TrimEnd([char[]]"`r`n") }) -join "`n"
$newBytes = [System.Text.Encoding]::UTF8.GetBytes("$content`n`n$preserved`n")
}
}
$newHash = Get-Sha256HashOfBytes $newBytes
$newManifest[$relative] = $newHash