Payload/scripts/harness/run-agent-eval.ps1

#Requires -Version 5.1
<#
.SYNOPSIS
    Score agent eval fixtures (Windows-first entry point).

.DESCRIPTION
    Forwards to scripts/run-agent-eval.mjs with correct argument passing on Windows.
    Prefer this over `npm run agent:eval -- --suite ...` - npm 11 may consume `--suite` as its own config.

.EXAMPLE
    .\scripts\run-agent-eval.ps1 -List

.EXAMPLE
    .\scripts\run-agent-eval.ps1 -Suite skills/evidence-first-work-ethic -Fixture 01-worktree-setup-no-guess `
        -Output .github/evals/captures/01-worktree-setup-no-guess.output.md -WriteResults
#>

[CmdletBinding()]
param(
    [switch]$List,

    [switch]$All,

    [string]$Suite = '',

    [string]$Fixture = '',

    [string]$Output = '',

    [string]$OutputDir = '',

    [string]$EvalsRoot = '',

    [switch]$WriteResults,

    [string]$RepoRoot = ''
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$scriptDir = if ($PSScriptRoot) { $PSScriptRoot } else { Split-Path -Parent $MyInvocation.MyCommand.Path }
if ([string]::IsNullOrWhiteSpace($RepoRoot)) {
    $RepoRoot = (Resolve-Path (Join-Path $scriptDir '..\..')).Path
}

$modulePath = Join-Path $PSScriptRoot 'lib\RepoRuntime.psm1'
Import-Module $modulePath -Force
Initialize-RepoShellEnvironment -LogPrefix 'agent-eval' | Out-Null

$runner = Join-Path $PSScriptRoot 'run-agent-eval.mjs'
if (-not (Test-Path -LiteralPath $runner)) {
    throw "Runner not found: $runner"
}

$nodeArgs = [System.Collections.Generic.List[string]]::new()
if ($List.IsPresent) {
    [void]$nodeArgs.Add('--list')
}
if ($All.IsPresent) {
    [void]$nodeArgs.Add('--all')
}
if (-not [string]::IsNullOrWhiteSpace($Suite)) {
    [void]$nodeArgs.Add('--suite')
    [void]$nodeArgs.Add($Suite)
}
if (-not [string]::IsNullOrWhiteSpace($Fixture)) {
    [void]$nodeArgs.Add('--fixture')
    [void]$nodeArgs.Add($Fixture)
}
if (-not [string]::IsNullOrWhiteSpace($Output)) {
    [void]$nodeArgs.Add('--output')
    [void]$nodeArgs.Add($Output)
}
if (-not [string]::IsNullOrWhiteSpace($OutputDir)) {
    [void]$nodeArgs.Add('--output-dir')
    [void]$nodeArgs.Add($OutputDir)
}
if (-not [string]::IsNullOrWhiteSpace($EvalsRoot)) {
    [void]$nodeArgs.Add('--evals-root')
    [void]$nodeArgs.Add($EvalsRoot)
}
if ($WriteResults.IsPresent) {
    [void]$nodeArgs.Add('--write-results')
}

Push-Location $RepoRoot
try {
    & node $runner @nodeArgs
    exit $LASTEXITCODE
}
finally {
    Pop-Location
}