UNPKG

@bobmatnyc/ai-code-review

Version:

A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter

65 lines (64 loc) 2.46 kB
/** * @fileoverview Abstract base class for review strategies. * * This module defines an abstract base class that encapsulates common functionality * across different review strategy implementations. It provides a unified interface * for executing reviews with different approaches and configurations. */ import { FileInfo, ReviewOptions, ReviewResult, ReviewType } from '../../types/review'; import { ProjectDocs } from '../../utils/projectDocs'; import { ApiClientConfig } from '../../core/ApiClientSelector'; /** * Abstract base class for review strategies */ export declare abstract class AbstractStrategy { /** * The review type (quick-fixes, architectural, security, etc.) */ protected reviewType: ReviewType; /** * Constructor * @param reviewType The type of review to perform */ constructor(reviewType: ReviewType); /** * Execute the review strategy * @param files Array of file information objects * @param projectName Name of the project * @param projectDocs Optional project documentation * @param options Review options * @param apiClientConfig API client configuration * @returns Promise resolving to the review result */ abstract execute(files: FileInfo[], projectName: string, projectDocs: ProjectDocs | null, options: ReviewOptions, apiClientConfig: ApiClientConfig): Promise<ReviewResult>; /** * Get the review type * @returns The review type */ getReviewType(): ReviewType; /** * Validate the input parameters * @param files Array of file information objects * @param projectName Name of the project * @returns Whether the input is valid */ protected validateInput(files: FileInfo[], projectName: string): boolean; /** * Log the review execution start * @param files Array of file information objects * @param projectName Name of the project */ protected logExecutionStart(files: FileInfo[], projectName: string): void; /** * Log the review execution completion * @param result The review result */ protected logExecutionCompletion(result: ReviewResult): void; /** * Handle errors during review execution * @param error The error that occurred * @param operation The operation that was being performed * @throws The processed error */ protected handleError(error: unknown, operation: string): never; }