import { g as getTelemetry, a as getSmartRouter, b as getCapabilityName } from '../shared/ccjk.DuzJZlgj.mjs';
import 'node:fs';
import 'node:fs/promises';
import 'node:os';
import '../shared/ccjk.bQ7Dh1g4.mjs';

async function brainStatusCommand(options) {
  try {
    const telemetry = getTelemetry();
    const router = getSmartRouter();
    const stats = await telemetry.getStats();
    const config = router.getConfig();
    if (options.json) {
      console.log(JSON.stringify({ stats, config }, null, 2));
      return;
    }
    console.log("\n\u{1F4CA} Brain Status Report\n");
    console.log("\u2550".repeat(60));
    console.log("\n\u2699\uFE0F  Router Configuration:");
    console.log(`  \u80FD\u529B\u504F\u597D: ${config.capabilityPreference}/5 (${getPreferenceLabel(config.capabilityPreference)})`);
    console.log(`  \u81EA\u52A8Subagent\u9608\u503C: ${config.autoSubagentThreshold}/10`);
    console.log(`  \u6700\u5927\u5E76\u884CAgent: ${config.maxParallelAgents}`);
    console.log(`  \u9065\u6D4B: ${config.enableTelemetry ? "\u2705 \u542F\u7528" : "\u274C \u7981\u7528"}`);
    console.log(`  \u663E\u793A\u51B3\u7B56\u7406\u7531: ${config.showReasoning ? "\u2705 \u662F" : "\u274C \u5426"}`);
    console.log("\n\u{1F4C8} Overall Statistics:");
    console.log(`  \u603B\u4EFB\u52A1\u6570: ${stats.totalTasks}`);
    if (stats.totalTasks === 0) {
      console.log("\n  \u6682\u65E0\u4EFB\u52A1\u8BB0\u5F55");
      console.log("\n\u2550".repeat(60));
      return;
    }
    console.log("\n\u{1F3AF} By Capability Level:");
    for (const [level, levelStats] of Object.entries(stats.byLevel)) {
      const levelNum = Number(level);
      const name = getCapabilityName(levelNum);
      const successRate = (levelStats.successRate * 100).toFixed(1);
      const avgDuration = levelStats.avgDuration.toFixed(1);
      const avgScore = levelStats.avgEffectScore.toFixed(1);
      console.log(`
  Level ${level} - ${name}:`);
      console.log(`    \u4EFB\u52A1\u6570: ${levelStats.count}`);
      console.log(`    \u6210\u529F\u7387: ${successRate}% ${getSuccessEmoji(levelStats.successRate)}`);
      console.log(`    \u5E73\u5747\u8017\u65F6: ${avgDuration}s`);
      console.log(`    \u5E73\u5747\u8BC4\u5206: ${avgScore}/10 ${getScoreEmoji(levelStats.avgEffectScore)}`);
    }
    if (options.detailed && stats.recentTrend.length > 0) {
      console.log("\n\u{1F4C5} Recent Trend (Last 30 Days):");
      const recentDays = stats.recentTrend.slice(-7);
      for (const day of recentDays) {
        const successRate = (day.successRate * 100).toFixed(1);
        console.log(`  ${day.date}: ${day.count} tasks, ${successRate}% success`);
      }
    }
    if (stats.recommendations.length > 0) {
      console.log("\n\u{1F4A1} Recommendations:");
      for (const rec of stats.recommendations) {
        console.log(`  \u2022 ${rec}`);
      }
    }
    console.log("\n\u2550".repeat(60));
    console.log();
  } catch (error) {
    console.error("\u274C Error:", error instanceof Error ? error.message : String(error));
    process.exit(1);
  }
}
function getPreferenceLabel(pref) {
  if (pref <= 2)
    return "\u4F18\u5148\u7B80\u5355";
  if (pref >= 4)
    return "\u4F18\u5148\u590D\u6742";
  return "\u5E73\u8861";
}
function getSuccessEmoji(rate) {
  if (rate >= 0.9)
    return "\u{1F7E2}";
  if (rate >= 0.7)
    return "\u{1F7E1}";
  return "\u{1F534}";
}
function getScoreEmoji(score) {
  if (score >= 8)
    return "\u{1F31F}";
  if (score >= 6)
    return "\u{1F44D}";
  return "\u{1F44E}";
}

export { brainStatusCommand };
