UNPKG

@bobmatnyc/ai-code-review

Version:

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

70 lines (69 loc) 2.45 kB
/** * @fileoverview Prompt builder for constructing prompts from multiple components. * * This module provides functionality for building prompts from multiple components, * including templates, user-provided fragments, and model-specific optimizations. */ import { ReviewOptions, ReviewType } from '../types/review'; import { ProjectDocs } from '../utils/projectDocs'; import { PromptManager } from './PromptManager'; import { PromptCache } from './cache/PromptCache'; /** * Interface for a prompt component */ export interface PromptComponent { /** * Content of the component */ content: string; /** * Position of the component in the prompt (start, middle, end) */ position: 'start' | 'middle' | 'end'; /** * Priority of the component (higher priority components are included first) */ priority: number; } /** * Builder for constructing prompts */ export declare class PromptBuilder { private promptManager; private promptCache; private components; /** * Create a new prompt builder * @param promptManager Prompt manager instance * @param promptCache Prompt cache instance */ constructor(promptManager: PromptManager, promptCache: PromptCache); /** * Add a component to the prompt * @param component Prompt component to add * @returns This builder instance for chaining */ addComponent(component: PromptComponent): PromptBuilder; /** * Add a user-provided fragment to the prompt * @param content Content of the fragment * @param position Position of the fragment in the prompt * @param priority Priority of the fragment * @returns This builder instance for chaining */ addFragment(content: string, position?: 'start' | 'middle' | 'end', priority?: number): PromptBuilder; /** * Build a prompt for a review * @param reviewType Type of review * @param options Review options * @param projectDocs Project documentation * @param basePrompt Optional base prompt to use instead of fetching from the prompt manager * @returns Promise resolving to the built prompt */ buildPrompt(reviewType: ReviewType, options: ReviewOptions, projectDocs?: ProjectDocs | null, basePrompt?: string): Promise<string>; /** * Clear all components from the builder * @returns This builder instance for chaining */ clear(): PromptBuilder; }