import type { Config } from '../types/config.js'; import type { Plugin } from '../types/plugin.js'; import type { CascadeAgentKind } from './chimera-plugin.js'; export interface AutoReviewConfig { enabled?: boolean | undefined; /** Provider for review subagents. Falls back to session provider. */ provider?: string | undefined; /** Model for review subagents. Falls back to session model. */ model?: string | undefined; /** * Named fallback profile from config.fallbackProfiles. * Resolved via FallbackProfileManager. The first valid entry * becomes the primary provider/model (when provider/model are * omitted), and the remaining entries form the fallback chain. */ fallbackProfile?: string | undefined; /** Debounce window in ms — wait for quiet before firing review (default 5000). */ debounceMs?: number | undefined; /** Max files per review batch (default 15). */ maxFilesPerBatch?: number | undefined; /** Max concurrent in-flight reviews (default 2). */ maxConcurrentReviews?: number | undefined; /** * Cascade severity threshold: when a review finds findings at or above this * level, spawn follow-up agents automatically. "off" disables cascading, * "high" cascades on High+, "critical" cascades only on Critical. * Default: "off". */ cascadeOn?: 'off' | 'critical' | 'high' | undefined; /** * Maximum cascade iterations (fix → re-review cycles) before the * self-correcting loop stops. Prevents infinite cycles. Default: 2. * 0 disables re-review (cascade agents investigate/fix once, no re-check). */ maxCascadeDepth?: number | undefined; } export interface ResolvedAutoReviewConfig { enabled: boolean; provider: string; model: string; fallbackModels: string[]; debounceMs: number; maxFilesPerBatch: number; maxConcurrentReviews: number; cascadeOn: 'off' | 'critical' | 'high'; maxCascadeDepth: number; } /** * Default reviewer rotation chain, used when the configured fallbackProfile is * absent, unknown, or resolves to an empty chain. Without this, the reviewer * would spawn against the bare session model with no fallback; if that model * returns an empty response the subagent dies at 1 iter / 0 tools (surfaced as * provider_auth). Kept in sync with the CLI-side default in * packages/cli/src/execution.ts so both spawn seams share one safety net. * Parsed downstream as `provider/model` refs. */ export declare const DEFAULT_REVIEW_FALLBACK_MODELS: readonly string[]; /** * Primary + fallback assignment for a single Chimera reviewer spawn. * Produced by {@link selectRoundRobinReviewerAssignment} so concurrent * reviewers start on different models and only share a provider after * their own in-place retries are exhausted. */ export interface ReviewerModelAssignment { provider: string; model: string; /** Remaining pool entries after the selected primary, wrap-around order. */ fallbackModels: string[]; /** Cursor to pass on the next spawn (`cursor + 1`). */ nextCursor: number; } /** * Build the deduped provider/model pool a reviewer can start on. * * Order is stable: configured primary first, then the fallback chain. * Entries must be `provider/model` (or parseable refs); bare blanks are dropped. */ export declare function buildReviewerModelPool(provider: string, model: string, fallbackModels?: readonly string[]): string[]; /** * Pick primary + fallback chain for the Nth concurrent reviewer via round-robin. * * Index `cursor % pool.length` becomes the primary; the rest of the pool is * rotated so the former primary lands last (still available after rate limits). * The pool must be pre-filtered by {@link buildReviewerModelPool} so every * non-empty entry contains both a provider and a model. * Pure: the caller owns the cursor (typically a process-local counter). */ export declare function selectRoundRobinReviewerAssignment(pool: readonly string[], cursor: number, /** Used only when the selected ref is somehow unparseable — defensive. */ fallbackProvider?: string, fallbackModel?: string): ReviewerModelAssignment; export declare function resolveAutoReviewConfig(cfg: AutoReviewConfig, sessionConfig: Config): ResolvedAutoReviewConfig; export interface ParsedSeverities { critical: number; high: number; medium: number; } /** * Extract Critical/High/Medium finding counts from a Chimera review report. * * The report format (from llm/chimera-review.md) uses section headers like * `### Critical (2)`, `### High (1)`, `### Medium (3)`. We match the count * in parentheses. Falls back to counting `1.`, `2.` list-item markers under * a severity heading when no `(N)` is present (defensive — the prompt asks * for both, but LLMs sometimes omit the count). * * Returns all-zero when the text doesn't match (clean report or unparseable). */ export declare function parseReviewSeverity(text: string): ParsedSeverities; /** * Decide which follow-up cascade agents to spawn based on the review text. * * - `security-scanner` is selected when any Critical/High finding mentions * a security keyword (injection, secret, XSS, etc.). * - `bug-hunter` is selected whenever the threshold is crossed at all — * any High+ finding warrants a focused bug hunt. * * Both may be returned in parallel when a finding is both severe and * security-related. */ export declare function decideCascadeAgents(text: string, severities: ParsedSeverities): CascadeAgentKind[]; /** * Determine whether a review result should trigger a cascade, given the * configured threshold and parsed severities. Returns the crossed * threshold, or `null` when the cascade should not fire. * * - `'high'` → fires on any High OR Critical finding * - `'critical'` → fires only on Critical findings * - `'off'` → never fires */ export declare function shouldCascade(cascadeOn: 'off' | 'critical' | 'high', severities: ParsedSeverities): 'high' | 'critical' | null; export declare function createAutoReviewPlugin(): Plugin; //# sourceMappingURL=auto-review-plugin.d.ts.map