/**
 * Shared option groups for the AILF CLI.
 *
 * Each function adds a group of related options to a Commander command.
 * This eliminates copy-paste across commands that share common flags
 * (e.g., debug options, Sanity source options, output options).
 */
/**
 * Add agentic options on `ailf run`: `--url` and `--search`. Both are
 * per-run overrides.
 *
 * **`--header` and `--allowed-origin` retired in W0077 Phase 6f** —
 * configure them in `.ailf/config.yaml`'s `agentic` block instead. The
 * `DOC_HEADERS` and `DOC_ALLOWED_ORIGIN(S)` env vars still apply.
 */
export function addAgenticOptions(cmd) {
    return cmd
        .option("--url <url>", "Documentation URL (repeatable)", collect, [])
        .option("-S, --search <mode>", "Web search mode: open, origin-only, off");
}
/**
 * Add debug + filter options.
 *
 * `-d, --debug` is a shortcut that runs only the first 2 tests for fast
 * feedback. `--filter-first-n`, `--filter-pattern`, and `--filter-sample`
 * narrow the test set explicitly and mirror the same-named flags on
 * `ailf eval` so the pipeline surface matches the underlying Promptfoo
 * passthrough.
 */
export function addDebugOptions(cmd) {
    return cmd
        .option("-d, --debug", "Run subset of tests for fast feedback", false)
        .option("--filter-first-n <n>", "Run only first N tests", parseInt)
        .option("--filter-pattern <regex>", "Filter tests by description regex")
        .option("--filter-sample <n>", "Random sample of N tests", parseInt);
}
/**
 * Add output options: --output, --format
 */
export function addOutputOptions(cmd) {
    return cmd
        .option("-o, --output <path>", "Write output to a specific file path")
        .option("-f, --format <fmt>", "Output format (e.g., table, json, md)");
}
/**
 * Add --output-dir option for commands that write pipeline artifacts.
 *
 * Pair with `resolveOutputDir()` from `./resolve-output-dir.js` to resolve
 * the value. When omitted, `resolveOutputDir()` defaults to
 * `$CWD/.ailf/results/latest/`.
 */
export function addOutputDirOption(cmd) {
    return cmd.option("--output-dir <path>", "Base directory for output artifacts (default: .ailf/results/latest/)");
}
/**
 * Add the full Sanity-source CLI surface — dataset, project, perspective,
 * studio origin, document. Used by `ailf fetch-docs`, which is invoked
 * directly with explicit Sanity targeting per run.
 *
 * **Not used by `ailf run`** post-W0077 Phase 6d. The dataset, project, and
 * studio-origin trio moved to `.ailf/config.yaml`'s `source` block (with
 * `SANITY_DATASET` / `SANITY_PROJECT_ID` / `SANITY_STUDIO_ORIGIN` env-var
 * fallbacks). `ailf run` uses `addSanityScopeOptions` instead, which keeps
 * only the per-run flags (`--sanity-perspective`, `--sanity-document`).
 */
export function addSanitySourceOptions(cmd) {
    return cmd
        .option("--sanity-dataset <name>", "Override Sanity dataset")
        .option("--sanity-project <id>", "Override Sanity project ID")
        .option("--sanity-perspective <id>", "Sanity release perspective ID")
        .option("--sanity-studio-origin <url>", "Sanity Studio base URL")
        .option("--sanity-document <id>", "Evaluate specific Sanity document(s) (repeatable)", collect, []);
}
/**
 * Add the per-run Sanity-scope CLI surface — `--sanity-perspective` and
 * `--sanity-document`. Used by `ailf run`. The per-environment trio
 * (dataset, project, studio origin) lives in `.ailf/config.yaml`'s
 * `source` block instead (W0077 Phase 6d).
 */
export function addSanityScopeOptions(cmd) {
    return cmd
        .option("--sanity-perspective <id>", "Sanity release perspective ID")
        .option("--sanity-document <id>", "Evaluate specific Sanity document(s) (repeatable)", collect, []);
}
/**
 * Collect repeatable string options into an array.
 * Used as a Commander argParser for options like --url, --header, --allowed-origin.
 */
export function collect(value, previous) {
    return [...previous, value];
}
