param( [Parameter(Mandatory = $true)] [string]$TaskFile, [Parameter(Mandatory = $true)] [string]$ReportFile, [Parameter(Mandatory = $true)] [string]$ProjectRoot, [Parameter(Mandatory = $true)] [string]$OutputFile, [string]$CodexModel = "" ) $ErrorActionPreference = "Stop" function Resolve-CodexCommand() { $cmd = Get-Command "codex.cmd" -ErrorAction SilentlyContinue if ($cmd) { return $cmd.Source } $fallback = Get-Command "codex" -ErrorAction SilentlyContinue if ($fallback) { return $fallback.Source } throw "Command not found: codex" } $taskPath = (Resolve-Path -LiteralPath $TaskFile).Path $reportPath = (Resolve-Path -LiteralPath $ReportFile).Path $projectPath = (Resolve-Path -LiteralPath $ProjectRoot).Path $outputPath = [System.IO.Path]::GetFullPath($OutputFile) $codexCommand = Resolve-CodexCommand $reviewPrompt = @" Read this worker task file: $taskPath Read this GLM report: $reportPath Your job: 1. Inspect the real diff in the repository. 2. Verify whether GLM actually implemented what the report claims. 3. Fix anything incorrect, incomplete, or unsafe. 4. Run the relevant validations mentioned by the task/report. 5. Leave the repository in the best corrected state you can reach in one pass. 6. Write a concise final summary to the output file configured by the CLI. Be strict about overclaims. The code is the source of truth, not the report. "@ $codexArgs = @( "exec", "--dangerously-bypass-approvals-and-sandbox", "-C", $projectPath, "-o", $outputPath ) if (-not [string]::IsNullOrWhiteSpace($CodexModel)) { $codexArgs += @("-m", $CodexModel) } $codexArgs += $reviewPrompt $stdoutPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($outputPath), "codex_review_stdout.tmp.txt") $stderrPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($outputPath), "codex_review_stderr.tmp.txt") if (Test-Path -LiteralPath $stdoutPath) { Remove-Item -LiteralPath $stdoutPath -Force } if (Test-Path -LiteralPath $stderrPath) { Remove-Item -LiteralPath $stderrPath -Force } Push-Location $projectPath try { & $codexCommand @codexArgs 1> $stdoutPath 2> $stderrPath $exitCode = $LASTEXITCODE } finally { Pop-Location } if (Test-Path -LiteralPath $stdoutPath) { Get-Content -LiteralPath $stdoutPath } if (Test-Path -LiteralPath $stderrPath) { Get-Content -LiteralPath $stderrPath } if ($exitCode -ne 0) { throw "Codex exited with code $exitCode" }