const fs = require('fs');
const file = 'src/modules/book-generator/langgraph-generator.ts';
let content = fs.readFileSync(file, 'utf8');

// 在 callLLMWithMessages 后添加日志
const old = `              const response = await callLLMWithMessages(messages);
              parsed = parseSubsections(response);`;

const new_ = `              const response = await callLLMWithMessages(messages);
              console.log('[SubsectionParser] ===== AI原始响应 (前500字符) =====');
              console.log(response.substring(0, 500));
              console.log('[SubsectionParser] ===== AI原始响应 (完整) =====');
              console.log(response);
              console.log('[SubsectionParser] ===== 结束 =====');
              parsed = parseSubsections(response);`;

content = content.replace(old, new_);

fs.writeFileSync(file, content, 'utf8');
console.log('✅ 已添加原始响应日志');
