const fs = require('fs');
const file = 'src/modules/book-generator/langgraph-controller.ts';
let c = fs.readFileSync(file, 'utf8');
const lines = c.split('\n');

// 找到第548-555行并替换
for (let i = 547; i < 556; i++) {
  if (lines[i].includes('// 启动 LangGraph 生成')) {
    lines.splice(i, 8, 
      '    // 将生成任务加入队列',
      '    const jobId = await queueService.addBookGenerationTask({',
      '      bookId,',
      '      topic: book.description,',
      '      bookScale,',
      '    });',
      '    ',
      '    console.log(`[LangGraph] 重新生成任务已加入队列: bookId=${bookId}, jobId=${jobId}`);'
    );
    break;
  }
}

fs.writeFileSync(file, lines.join('\n'), 'utf8');
console.log('✅ 第2处已修复');
