/** * critique_prompt — LLM-as-judge for a prompt. * * Scores a candidate prompt across N dimensions (clarity, specificity, * intent-alignment, format-fitness, length-appropriateness, plain-language * by default; caller-customizable). Returns per-dimension 0–10 scores + rationales, * an overall score, a verdict (`accept`, `revise`, `reject`), and — when * the score is below `revise_threshold` — an improved rewrite the caller * can use as a drop-in replacement. * * Use cases: * - Pre-flight: "is this prompt good enough to send to the expensive model?" * - Postmortem: "this output was bad — was the prompt the cause?" * - A/B: pick the best of N candidate optimizations. * * The judge runs at `temperature: 0.1` for stable scores. The `improved` * pass runs at the intent-derived temperature so the rewrite still feels * appropriate for the category (creative bumps temp; data-extract drops it). */ import type { Category } from '../config/categories.js'; import type { AnalysisSignal } from '../context/types.js'; export interface CritiqueCriterion { name: string; description: string; } export interface CritiqueInputs { prompt: string; /** * If `prompt` is an optimized version, the original it came from. * The judge uses this for the intent-alignment dimension ("did the * rewrite preserve the user's actual ask?"). */ originalPrompt?: string; category?: Category; cwd?: string; filePath?: string; fileLanguage?: string; fileExcerpt?: string; userLocale?: string; /** Override the default 6 criteria. Leave undefined for the standard set. */ criteria?: CritiqueCriterion[]; /** * Overall score below this triggers the "improved" rewrite pass. * Default 7.0 / 10. Set to 0 to skip the rewrite always; 10 to always run it. */ reviseThreshold?: number; /** Skip the "improved" rewrite pass even if the score is below threshold. */ skipRewrite?: boolean; /** * Override the LLM model for the judge AND rewrite calls. When omitted, * uses LLM_MODEL from env. Per-stage routing in compose_prompt sets this. */ model?: string; /** Per-call cancellation signal (1.10.0) — aborts the judge + rewrite calls. */ signal?: AbortSignal; } export interface CritiqueDimensionResult { name: string; score: number; rationale: string; suggestions: string[]; } export type CritiqueVerdict = 'accept' | 'revise' | 'reject'; export interface CritiqueResult { overallScore: number; verdict: CritiqueVerdict; summary: string; dimensions: CritiqueDimensionResult[]; improvedPrompt?: string; /** When improvedPrompt is present, an explicit list of what the rewrite changed. */ improvements?: string[]; /** ms spent in this critique (analysis + judge LLM + optional rewrite LLM). */ latencyMs: number; judgeModel: string; analysis?: { category: AnalysisSignal['category']; intent: AnalysisSignal['intent']; confidence: AnalysisSignal['confidence']; }; } export declare function critiquePrompt(inputs: CritiqueInputs): Promise;