/**
 * eval command — run promptfoo evaluation directly (passthrough).
 *
 * This is a convenience command that forwards to `promptfoo eval`.
 * For most use cases, prefer `ailf run` which handles the full
 * lifecycle (fetch → generate → eval → score → report).
 */
import { Command } from "commander";
export function createEvalCommand() {
    return new Command("eval")
        .description("Run Promptfoo evaluation directly (passthrough to promptfoo)")
        .option("--config <path>", "Promptfoo config file", "promptfooconfig.yaml")
        .option("--no-cache", "Disable Promptfoo caching")
        .option("--filter-description <text>", "Filter tests by description")
        .option("--filter-pattern <regex>", "Filter tests by regex")
        .option("--filter-first-n <n>", "Run only first N tests")
        .option("--filter-sample <n>", "Random sample of N tests")
        .allowUnknownOption(true)
        .allowExcessArguments(true)
        .action(async () => {
        const { execSync } = await import("child_process");
        // Pass through all raw arguments after "eval" to promptfoo
        const evalIdx = process.argv.indexOf("eval");
        const passthroughArgs = evalIdx !== -1 ? process.argv.slice(evalIdx + 1) : [];
        try {
            execSync(`dotenv -e ../../.env -o -- promptfoo eval ${passthroughArgs.join(" ")}`, { stdio: "inherit" });
        }
        catch (err) {
            const code = err !== null && typeof err === "object" && "status" in err
                ? err.status
                : 1;
            process.exit(code);
        }
    });
}
