@bobmatnyc/ai-code-review
Version:
A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter
94 lines (93 loc) • 2.54 kB
TypeScript
/**
* @fileoverview Prompt cache for storing and retrieving optimized prompts.
*
* This module provides functionality for caching optimized prompts and retrieving
* them for future use. It supports both memory-based and file-based caching.
*/
import { ReviewType } from '../../types/review';
/**
* Interface for a cached prompt
*/
export interface CachedPrompt {
/**
* Content of the prompt
*/
content: string;
/**
* Rating of the prompt (1-5)
*/
rating: number;
/**
* Timestamp when the prompt was cached
*/
timestamp: string;
/**
* Number of times the prompt has been used
*/
usageCount: number;
}
/**
* Cache for optimized prompts
*/
export declare class PromptCache {
private static instance;
private memoryCache;
private cacheDir;
/**
* Create a new prompt cache
* @param cacheDir Directory for storing cached prompts
*/
private constructor();
/**
* Get the singleton instance
* @param cacheDir Directory for storing cached prompts
* @returns The prompt cache instance
*/
static getInstance(cacheDir?: string): PromptCache;
/**
* Initialize the prompt cache
*/
private initialize;
/**
* Load cached prompts from disk
*/
private loadCachedPrompts;
/**
* Save the memory cache to disk
*/
private saveCacheToDisk;
/**
* Cache a prompt for future use
* @param reviewType Type of review
* @param promptContent Content of the prompt
* @param rating Rating of the prompt (1-5)
*/
cachePrompt(reviewType: ReviewType, promptContent: string, rating: number): Promise<void>;
/**
* Get the best cached prompt for a review type
* @param reviewType Type of review
* @returns The best cached prompt, or undefined if none exists
*/
getBestPrompt(reviewType: ReviewType): CachedPrompt | undefined;
/**
* Get all cached prompts for a review type
* @param reviewType Type of review
* @returns Array of cached prompts
*/
getAllPrompts(reviewType: ReviewType): CachedPrompt[];
/**
* Clear the cache for a review type
* @param reviewType Type of review
*/
clearCache(reviewType: ReviewType): Promise<void>;
/**
* Clear the entire cache
*/
clearAllCaches(): Promise<void>;
/**
* Get the cache key for a review type
* @param reviewType Type of review
* @returns Cache key
*/
private getCacheKey;
}