/** * Filesystem utilities for vibe-validate * * Provides shared filesystem operations used across the codebase: * - Directory creation with error handling * - Temp directory path generation * - File creation utilities */ /** * Ensure a directory exists (create if needed) * * Creates the directory and any necessary parent directories. * Ignores EEXIST errors if the directory already exists. * * @param dirPath - Path to directory to ensure exists * @throws Error if directory creation fails for reasons other than already existing * * @example * ```typescript * await ensureDir('/tmp/my-app/logs'); * // Directory now exists, ready to write files * ``` */ export declare function ensureDir(dirPath: string): Promise; /** * Get daily temp directory for a given base directory * * Creates a path structure like: * ${VV_TEMP_DIR}/vibe-validate/{baseDir}/{YYYY-MM-DD}/ * * Files in this directory use unique names generated by getTempFilename(). * This flat structure minimizes permission prompts (one approval per day). * * @param baseDir - Base directory name (e.g., 'runs', 'steps') * @returns Full path to daily temp directory * * @example * ```typescript * // For run output * const runDir = getTempDir('runs'); * // Returns: /tmp/vibe-validate/runs/2026-02-05/ * * // For step output * const stepDir = getTempDir('steps'); * // Returns: /tmp/vibe-validate/steps/2026-02-05/ * ``` */ export declare function getTempDir(baseDir: string): string; /** * Generate unique filename with tree hash and timestamp * * Format: {shortHash}-{HH-mm-ss}[-{suffix}].{ext} * * @param treeHash - Git tree hash or identifier * @param extension - File extension (without dot) * @param suffix - Optional suffix to append (e.g., step name) * @returns Unique filename * * @example * ```typescript * getTempFilename('abc123def456', 'log'); * // Returns: abc123-14-31-10.log * * getTempFilename('abc123def456', 'log', 'typecheck'); * // Returns: abc123-14-31-10-typecheck.log * ``` */ export declare function getTempFilename(treeHash: string, extension: string, suffix?: string): string; /** * Write a log file only if content is non-empty * * Helper to conditionally write log files, avoiding empty file creation. * * @param content - Content to write * @param outputDir - Directory to write file in * @param filename - Name of the log file * @returns Object with file path (if written) and write promise (if needed) * * @example * ```typescript * const writePromises: Promise[] = []; * * const { file: stdoutFile, promise: stdoutPromise } = * createLogFileWrite(stdout, outputDir, 'stdout.log'); * if (stdoutPromise) writePromises.push(stdoutPromise); * * await Promise.all(writePromises); * ``` */ export declare function createLogFileWrite(content: string, outputDir: string, filename: string): { file: string | undefined; promise: Promise | null; }; /** * Create timestamped combined.jsonl content * * Converts an array of timestamped output lines into JSONL format * for storage as combined.jsonl file. * * @param lines - Array of timestamped output lines * @returns JSONL string (one JSON object per line) * * @example * ```typescript * const lines = [ * { ts: '2025-11-10T17:30:45.123Z', stream: 'stdout', line: 'Starting...' }, * { ts: '2025-11-10T17:30:46.456Z', stream: 'stderr', line: 'Warning!' } * ]; * const jsonl = createCombinedJsonl(lines); * // Returns: * // {"ts":"2025-11-10T17:30:45.123Z","stream":"stdout","line":"Starting..."} * // {"ts":"2025-11-10T17:30:46.456Z","stream":"stderr","line":"Warning!"} * ``` */ export declare function createCombinedJsonl(lines: Array<{ ts: string; stream: 'stdout' | 'stderr'; line: string; }>): string; //# sourceMappingURL=fs-utils.d.ts.map