# Laesst Codex einen Stand pruefen, nur lesend und in einer sauberen Kopie ohne .env. # Die Datei bleibt reines ASCII, weil Windows PowerShell 5.1 sonst Umlaute falsch liest. # .\scripts\codex-review.ps1 alles seit dem letzten Release-Tag # .\scripts\codex-review.ps1 -Seit v1.42.0 alles seit einem Tag oder Commit # .\scripts\codex-review.ps1 -Commit einen einzelnen Commit # .\scripts\codex-review.ps1 -Offen die noch nicht committeten Aenderungen # .\scripts\codex-review.ps1 -Alles den gesamten Code param( [string]$Seit = "", [string]$Commit = "", [switch]$Offen, [switch]$Alles ) $utf8 = New-Object System.Text.UTF8Encoding $false $OutputEncoding = $utf8 [Console]::OutputEncoding = $utf8 $repo = (git rev-parse --show-toplevel).Trim() $regeln = Get-Content -Raw -Encoding UTF8 (Join-Path $repo "scripts\codex-review-prompt.md") $ziel = if ($Commit) { $Commit } else { "HEAD" } if ($Alles) { $umfang = "Scope: the whole code under src/, templates/, public/assets/ (without build/ and fonts/), plugins/, migrations/, config/ and zentrale/." } elseif ($Commit) { $umfang = "Scope: the changes from: git show $Commit" } elseif ($Offen) { $umfang = "Scope: the uncommitted changes, visible with: git diff HEAD (new untracked files are not included)." } else { if (-not $Seit) { $Seit = (git -C $repo describe --tags --abbrev=0 HEAD).Trim() } if ($LASTEXITCODE -ne 0 -or -not $Seit) { Write-Error "Kein Release-Tag gefunden, bitte -Seit angeben."; exit 1 } $umfang = "Scope: the changes from: git diff $Seit..HEAD" } Write-Host $umfang $kopie = Join-Path $env:TEMP ("kantsites-review-" + [guid]::NewGuid().ToString("N").Substring(0, 8)) git -C $repo worktree add --quiet --detach $kopie $ziel if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } try { if ($Offen) { $patch = Join-Path $env:TEMP ("kantsites-review-" + [guid]::NewGuid().ToString("N").Substring(0, 8) + ".patch") git -C $repo diff HEAD --binary --output="$patch" if ((Get-Item $patch).Length -eq 0) { Write-Host "Keine offenen Aenderungen."; Remove-Item $patch; exit 0 } git -C $kopie apply --whitespace=nowarn "$patch" $angewendet = $LASTEXITCODE Remove-Item $patch if ($angewendet -ne 0) { Write-Error "Offene Aenderungen liessen sich nicht in die Kopie uebernehmen."; exit $angewendet } } $berichte = Join-Path $repo "reports" if (-not (Test-Path $berichte)) { New-Item -ItemType Directory $berichte | Out-Null } $bericht = Join-Path $berichte ("codex-review-" + (Get-Date -Format "yyyy-MM-dd-HHmm") + ".md") "$umfang`n`n$regeln" | codex exec --sandbox read-only --ephemeral --cd $kopie --output-last-message $bericht - $status = $LASTEXITCODE if (Test-Path $bericht) { Write-Host "`n===== Ergebnis (auch in $bericht) =====" Get-Content -Raw -Encoding UTF8 $bericht | Write-Host } } finally { git -C $repo worktree remove --force $kopie } exit $status