/** * `peaks mut` — command builders and helper functions. * * Originally extracted from `mut-commands.ts` (file-size cap campaign). * It holds the stub-report factories, the summary emitter, the named-error * mapping, and — after the `max-lines-per-function` rule was measured at * 209 code lines for `createMutCommands` — the three subcommand builders * that drive the mutation pipeline (`run`, `mutants`, `asserts`). * The `report` subcommand — a pure reader of an already-written file — * lives with the CLI surface in `mut-commands.ts`. * * The named-error part exists for R7: a missing or unloadable mutation * toolchain must surface a MACHINE-READABLE error code (for example * `MUT_TOOLCHAIN_UNAVAILABLE`) plus an actionable message and a * non-zero exit code — never `UNHANDLED_ERROR` with a bare * "Cannot find package". The same rule now covers a missing `--test-files` * path (`MUT_TEST_FILE_NOT_FOUND`). */ import { Command } from 'commander'; import { type AssertionsReport, type MutationReport, type StrykerInvoker } from 'peaks-loop-mut'; import { type ProgramIO } from '../cli-helpers.js'; /** * Fallback code for a mutation failure that carries no named code of its * own. The production invoker raises the specific codes; anything that * escapes it without one still gets a stable, greppable name. */ export declare const MUT_CLI_ERROR_CODE = "MUT_FAILED"; /** * The IO the mut family writes to when the caller injects none. Same * shape as `src/cli/program.ts`'s default sinks: one trailing newline * per write. */ export declare const DEFAULT_MUT_IO: ProgramIO; /** The options every Stryker-backed subcommand receives. */ export interface MutCommandArgs { readonly project: string; readonly testFiles: string[]; readonly mutate?: string[]; readonly inputSig: string; readonly sessionId: string; readonly out: string; readonly json: boolean; } /** * Pure helper: a stub AssertionsReport used when only Stryker ran. * The mutants-only path does NOT touch the AST scanner; we still need * a structurally-valid `assertions` block so the Zod schema accepts * the assembled report. */ export declare function emptyAssertions(): AssertionsReport; /** * Pure helper: a stub MutationReport used when only the assertion * scan ran. Mirrors the asserts-only path's invariants (killRate = 0, * mutantsTotal = 0, tool = 'stryker' for forward compatibility). */ export declare function emptyMutation(): MutationReport; /** * Emit a one-line JSON envelope describing the run's outcome. Used by * both `--json` and the human-readable branches so the `passed` / * `sha256` shape stays consistent regardless of TTY mode. */ export declare function emitSummary(io: ProgramIO, json: boolean, payload: { ok: true; sha256: string; passed: boolean; path: string; }): void; /** * Read the machine-readable code off a failure. The production invoker * raises named codes (`MUT_TOOLCHAIN_UNAVAILABLE`, `MUT_NO_MUTANTS`, * `MUT_MUTATE_PATTERN_REQUIRED`, …) and `runMutation` preserves them * while wrapping. Anything without a recognised code falls back to * `MUT_FAILED` so the envelope is never anonymous. */ export declare function mutErrorCode(err: unknown): string; /** The human-readable half of the envelope. */ export declare function mutErrorMessage(err: unknown): string; /** * Emit the failure envelope on stderr and set a non-zero exit code. Its * `data` field carries the machine-readable detail — where an ABSOLUTE path * belongs; stdout stays reserved for the `--json` payload (R6). */ export declare function emitMutError(io: ProgramIO, err: unknown): void; /** * `peaks mut run` — the full mut pipeline (Stryker + assertion scan + * report). One-axis: --session-id required. */ export declare function buildMutRunCommand(invokeStryker: StrykerInvoker, io: ProgramIO): Command; /** * `peaks mut mutants` — Stryker only; writes a stub-assertions * mut-report.json. One-axis: --session-id required. */ export declare function buildMutMutantsCommand(invokeStryker: StrykerInvoker, io: ProgramIO): Command; /** * `peaks mut asserts` — the assertion scan only; writes a mut-report.json * with an empty mutation block. One-axis: --session-id required. */ export declare function buildMutAssertsCommand(io: ProgramIO): Command;