/**
 * 策略模块结构验证
 * 轻量检查：确保各策略文件可加载、接口一致
 */
async function main() {
  console.log('=== 策略模块验证 ===\n');

  // 1. 验证 selector
  const { getCurrentStrategy, getAllStrategies, setCurrentStrategy, getStrategy } = await import('../strategies/selector');
  const all = getAllStrategies();
  console.log(`可用策略: ${all.map(s => s.name).join(', ')}`);
  console.log(`当前策略: ${getCurrentStrategy().name}`);

  for (const s of all) {
    console.log(`  ${s.name.padEnd(20)} ${s.description}`);
  }

  // 2. 验证切换
  for (const s of all) {
    setCurrentStrategy(s.name as any);
    const current = getCurrentStrategy();
    console.log(`\n切换到 ${s.name}: ${current.name === s.name ? '✅' : '❌'}`);
  }

  // 3. 验证 index.ts 导出
  const { mapBookTypeToGenLevel, resolveGenLevel, setCurrentStrategy: setStrat, langGraphGenerator } = await import('../index');
  console.log(`\nmapBookTypeToGenLevel('教材') = ${mapBookTypeToGenLevel('教材')}`);
  console.log(`mapBookTypeToGenLevel('小说') = ${mapBookTypeToGenLevel('小说')}`);
  console.log(`mapBookTypeToGenLevel('科普') = ${mapBookTypeToGenLevel('科普')}`);
  console.log(`resolveGenLevel('1000') = ${resolveGenLevel('1000')}`);
  console.log(`resolveGenLevel('130000') = ${resolveGenLevel('130000')}`);

  console.log(`\n=== ✅ 所有策略模块验证通过 ===`);
  console.log(`\n要实际运行测试，请在项目中执行:`);
  console.log(`  cd server`);
  console.log(`  # 先启动服务`);
  console.log(`  npx tsx src/app.ts`);
  console.log(`  # 然后在另一个终端:`);
  console.log(`  npx tsx src/modules/book-generator/test/strategy-compare.ts`);
}

main().catch(err => {
  console.error('❌ 验证失败:', err);
  process.exit(1);
});
