import * as fs from 'fs';

const file = '/Users/haruncan/Documents/GitHub/ContentGenerator/ContentGen_BE/src/modules/gemini/gemini.service.ts';
let content = fs.readFileSync(file, 'utf8');

// Update tryGenerateContentImage signature to return finishReason
content = content.replace(
  /Promise<\{ buffer: Buffer; mimeType: string \} \| null>/g,
  'Promise<{ buffer: Buffer; mimeType: string; finishReason?: string } | null>'
);

// Update tryGenerateContentImage return
content = content.replace(
  /return null;\s*}\s*const imagePart/g,
  'return { buffer: Buffer.from([]), mimeType: "", finishReason };\n    }\n\n    const imagePart'
);

// In tryGenerateContentImage, we need to return the finish reason when buffer is empty so we know it's a safety block.
// Let's just use replace_file_content tool, it's safer than regex.
