import { readdir, stat, unlink } from 'node:fs/promises';
import { join } from 'node:path';
const LOG_FILE_PATTERN = /\.(log|json)$/;
export class FileSystemReviewLogFileGateway {
    async listLogFiles(projectPath) {
        const logsDirectory = this.getLogsDirectory(projectPath);
        const logFiles = [];
        try {
            const files = await readdir(logsDirectory);
            for (const filename of files) {
                if (!LOG_FILE_PATTERN.test(filename))
                    continue;
                try {
                    const filePath = join(logsDirectory, filename);
                    const fileStat = await stat(filePath);
                    logFiles.push({
                        filename,
                        path: filePath,
                        mtime: fileStat.mtime.toISOString(),
                        size: fileStat.size,
                    });
                }
                catch {
                    // Skip files we cannot stat
                }
            }
        }
        catch {
            // Directory does not exist or is not readable
        }
        return logFiles;
    }
    async deleteLogFile(projectPath, filename) {
        const filePath = join(this.getLogsDirectory(projectPath), filename);
        try {
            await unlink(filePath);
            return true;
        }
        catch {
            return false;
        }
    }
    getLogsDirectory(projectPath) {
        return join(projectPath, '.claude', 'reviews', 'logs');
    }
}
//# sourceMappingURL=reviewLogFile.fileSystem.gateway.js.map