/** * CacheManager - Local cache management for watch-pr command * * Provides: * - Atomic writes (concurrent-safe) * - TTL-based cache freshness * - Separate logs (immutable) and extractions (mutable) directories * - Cross-platform path handling * * Cache structure: * ${os.tmpdir()}/vibe-validate/watch-pr-cache/// * ├── logs/ # Immutable log files * │ ├── 123.log * │ └── 456.log * ├── extractions/ # Mutable extraction results * │ ├── 123.json * │ └── 456.json * └── metadata.json # Complete WatchPRResult * * @packageDocumentation */ import type { ErrorExtractorResult } from '@vibe-validate/extractors'; import type { WatchPRResult } from '../schemas/watch-pr-result.schema.js'; /** * CacheManager - Manages local cache for watch-pr command * * Provides concurrent-safe caching with TTL support. */ export declare class CacheManager { /** Base cache directory */ private readonly cacheDir; /** Logs directory (immutable) */ private readonly logsDir; /** Extractions directory (mutable) */ private readonly extractionsDir; /** * Create a new CacheManager * * @param repoName - Repository name (e.g., "jdutton/vibe-validate") * @param prNumber - PR number * @param baseDir - Base directory for cache (defaults to OS temp) */ constructor(repoName: string, prNumber: number, baseDir?: string); /** * Initialize cache directories * * Creates directory structure if it doesn't exist. */ private initDirectories; /** * Atomic write - Write file atomically using temp file + rename * * Provides concurrent safety by writing to temp file first, then renaming. * * @param filePath - Target file path * @param content - Content to write */ private atomicWrite; /** * Check if a file is fresh (within TTL) * * @param filePath - File path to check * @param ttl - TTL in milliseconds * @returns true if file exists and is fresh, false otherwise */ private isFresh; /** * Save log file (immutable) * * Saves to both cache directory (for backward compatibility) and VV_TEMP_DIR (new location). * * @param runId - GitHub run ID * @param logs - Log content * @param jobName - Optional job name for VV_TEMP_DIR filename * @returns Path to saved log file (VV_TEMP_DIR if jobName provided, otherwise cache) */ saveLog(runId: number, logs: string, jobName?: string): Promise; /** * Save extraction result (mutable) * * @param runId - GitHub run ID * @param extraction - Extraction result */ saveExtraction(runId: number, extraction: ErrorExtractorResult): Promise; /** * Get extraction result * * @param runId - GitHub run ID * @returns Extraction result or null if not found */ getExtraction(runId: number): Promise; /** * Save metadata (complete WatchPRResult) * * @param data - WatchPRResult data */ saveMetadata(data: WatchPRResult): Promise; /** * Get metadata (complete WatchPRResult) * * @returns Metadata or null if not found */ getMetadata(): Promise; /** * Get or fetch data with caching * * Generic cache wrapper with TTL support. * * @param key - Cache key * @param fetcher - Function to fetch data if cache is stale/missing * @param ttl - TTL in milliseconds (default: 5 minutes) * @returns Cached or fetched data */ getOrFetch(key: string, fetcher: () => Promise, ttl?: number): Promise; } //# sourceMappingURL=cache-manager.d.ts.map