import { BaseOptimizer, type BaseOptimizerDeps } from "../baseOptimizer.js"; import type { Input } from "../grading/types.js"; import { type ProposeMutationArgs } from "../mutator.js"; import type { BaseOptimizerConfig } from "../optimizer.js"; import { type OptimizeMutationOperation, type OptimizeMutationPreview } from "../sourceMutator.js"; import { type OptimizeTargetSet } from "../targets.js"; import type { MutationProposal, OptimizeResult } from "../types.js"; /** * Optional injection points, so the optimizer can be unit-tested without an LLM * or real file edits. The registry constructs it with none — `new ExampleOptimizer(config)`. */ export type ExampleDeps = BaseOptimizerDeps & { propose?: (args: ProposeMutationArgs) => Promise; preview?: (targetSet: OptimizeTargetSet, operations: OptimizeMutationOperation[]) => OptimizeMutationPreview; }; /** * The smallest useful optimizer — a copy-paste template for writing your own. * * Every optimizer extends {@link BaseOptimizer} and implements * {@link optimizeTargets}. By the time it runs, the base class has already * resolved the agent file and discovered its `optimize` targets; your job is to * search for better target values and return the best candidate. * * This one runs a single round: score the agent as-is, ask the built-in mutator * for one new set of values, score those, and keep the candidate if it beats the * baseline. The real optimizers (greedy, gepa) loop and search more cleverly, but * they all follow the same shape — fork → apply → evaluate → compare → report → return. * * Protected helpers available from BaseOptimizer: * - `this.scoreFiles(source, files, inputs)` — fork + apply + grade, returns a Scorecard * - `this.finishPointwise(source, candidates, trainChampion, attempts, startedAt)` — * pick the writeback champion (by validation when configured), write it back, * and build the OptimizeResult with train/validation objectives + breakdown * - `this.reporter` — progress output (silent unless the CLI sets verbosity) * - `this.config` — graders, runId, writeback, mutatorModel, … * * Register it (see registry.ts): * registerOptimizer("example", (config) => new ExampleOptimizer(config)); */ export declare class ExampleOptimizer extends BaseOptimizer { private readonly exampleDeps; readonly name = "example"; constructor(config: BaseOptimizerConfig, exampleDeps?: ExampleDeps); protected optimizeTargets(source: OptimizeTargetSet, inputs: Input[]): Promise; /** Apply a candidate file set into a fresh workspace, run + grade it. The * `targetSet` reflects this candidate's targets (the baseline's for the * baseline candidate, `outcome.preview.targetSet` for an accepted mutation), * so `finalTargets` in the reporter accurately describes the champion. */ private makeCandidate; }