import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { FileDetail } from "./file-selector.js"; /** * A single comment from a crit review. */ export interface CritComment { id: string; /** The comment body text */ body: string; /** The text the user selected when commenting (if any) */ quote?: string; /** The file path the comment is on (if applicable) */ file?: string; /** Whether the comment has been resolved */ resolved: boolean; } /** * Result of a completed crit review. */ export interface CritReviewResult { /** True when all comments are resolved */ approved: boolean; /** Review comments */ comments: CritComment[]; /** Free‑form instructions from the reviewer (set via the "prompt" field) */ prompt?: string; } /** * Input required to run the full crit review flow. */ export interface ReviewInput { /** Files selected for the commit. */ selectedFiles: string[]; /** Pre-fetched diff details per file (TUI mode only). */ fileDetails: Map | undefined; /** Combined staged diff passed to crit. */ stagedDiff: string; } /** * Result of the crit review flow. */ export interface ReviewFlowResult { /** Additional context to feed into the LLM commit-message prompt. */ reviewContext?: string; } /** * Base error for review-flow control flow. */ export declare class ReviewFlowError extends Error { constructor(message?: string); } /** * Thrown when the user cancels the review flow. */ export declare class ReviewCancelledError extends ReviewFlowError { constructor(message: string); } /** * Thrown when the user asks to send unresolved comments back to the agent * for fixing. The caller should dispatch the comments via `pi.sendUserMessage`. */ export declare class ReviewSendToAgentError extends ReviewFlowError { readonly reviewComments: string; constructor(reviewComments: string); } /** * Run the full crit review flow: build the review document, launch crit, * handle unresolved comments, and return any context for commit-message * generation. * * In TUI mode the user is asked what to do with unresolved comments. * In non-TUI mode unresolved comments are automatically included as context. * * @throws ReviewSendToAgentError when the user chooses to send comments back * to the agent for fixing. * @throws ReviewCancelledError when the user chooses to cancel. */ export declare function runReviewFlow(pi: ExtensionAPI, ctx: ExtensionContext, input: ReviewInput): Promise; /** * Check whether the `crit` CLI is available on the system. * * Should be called early in the review command handler, before any git state * is modified, so the user gets a clear message if crit is not installed. * * @throws If `crit` is not found on the system PATH. */ export declare function checkCritAvailable(pi: ExtensionAPI): Promise; /** * Write a review document and launch crit on it. * * Creates a temporary markdown file with the diff summary, opens crit in the * browser, and blocks until the user clicks "Finish Review". The temp file * is cleaned up when the function returns (even on error). * * @throws If `crit` is not installed or returns unparseable output. */ export declare function runCritReview(pi: ExtensionAPI, diffContent: string, fileEntries: { path: string; additions: number; deletions: number; }[]): Promise; /** * Extract a single top-level JSON object starting at `start`. * * Uses brace matching that respects strings and escapes, so nested * objects and arrays are handled correctly. * * @internal Exported for testing only. */ export declare function extractJsonObjectAt(text: string, start: number): { value: Record; end: number; } | null; /** * Parse crit's stdout JSON output. * * Crit may print startup messages or event lines before the final JSON * payload, and may emit multiple JSON objects during a comment rally. * We scan for all valid top-level JSON objects and use the last one that * looks like a crit review result. * * If no JSON is found, fall back to interpreting the raw text. * In some environments crit outputs the prompt message directly * (e.g. "Review approved with no comments — no changes requested.") * instead of the full JSON payload. * * @internal Exported for testing only. */ export declare function parseCritOutput(stdout: string): CritReviewResult; //# sourceMappingURL=reviewer.d.ts.map