import a from './index5.mjs';
import { c as consola, P as ProjectAnalyzer } from '../shared/ccjk.CoCHVXl3.mjs';
import { i18n, resolveSupportedLanguage } from './index2.mjs';
import { promises } from 'node:fs';
import { performance } from 'node:perf_hooks';
import { ccjkAgents } from './ccjk-agents.mjs';
import { ccjkHooks } from './ccjk-hooks.mjs';
import { ccjkMcp } from './ccjk-mcp.mjs';
import { ccjkSkills } from './ccjk-skills.mjs';
import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
import '../shared/ccjk.BAGoDD49.mjs';
import './index10.mjs';
import 'tinyglobby';
import '../shared/ccjk.BBtCGd_g.mjs';
import './constants.mjs';
import 'node:os';
import 'node:process';
import 'node:url';
import '../shared/ccjk.CfKKcvWy.mjs';
import '../shared/ccjk.C2jHOZVP.mjs';
import './index6.mjs';
import 'node:readline';
import 'stream';
import 'node:tty';
import 'node:async_hooks';
import '../shared/ccjk.Cjgrln_h.mjs';
import 'node:util';
import 'tty';
import 'fs';
import 'child_process';
import 'node:path';
import 'node:crypto';
import 'buffer';
import 'string_decoder';
import 'node:child_process';
import './claude-config.mjs';
import '../shared/ccjk.DDL-4C-k.mjs';
import './ccjk-config.mjs';
import './index3.mjs';
import './fs-operations.mjs';
import 'node:fs/promises';
import './json-config.mjs';
import './platform.mjs';
import './main.mjs';
import 'module';
import 'node:stream';
import '../shared/ccjk.i_vn-9C3.mjs';

async function createBackup(operation, options = {}) {
  const timestamp = dayjs().format("YYYYMMDD-HHmmss");
  const backupName = options.name || operation;
  const backupDir = join(process.cwd(), ".ccjk-backups", `${backupName}-${timestamp}`);
  try {
    await promises.mkdir(backupDir, { recursive: true });
    const filesToBackup = [
      ".claude.json",
      ".claude.md",
      ".claudeignore",
      "claude.config.json",
      "claude.config.toml",
      ".vscode/settings.json",
      ".github/workflows",
      ".git/hooks",
      "package.json",
      "pnpm-workspace.yaml",
      ".ccjk"
    ];
    for (const file of filesToBackup) {
      const sourcePath = join(process.cwd(), file);
      const destPath = join(backupDir, file);
      try {
        const stats = await promises.stat(sourcePath);
        if (stats.isDirectory()) {
          await copyDirectory(sourcePath, destPath);
        } else {
          await promises.mkdir(join(destPath, ".."), { recursive: true });
          await promises.copyFile(sourcePath, destPath);
        }
      } catch (_error) {
      }
    }
    const manifest = {
      timestamp: (/* @__PURE__ */ new Date()).toISOString(),
      operation,
      files: filesToBackup,
      cwd: process.cwd(),
      nodeVersion: process.version
    };
    await promises.writeFile(
      join(backupDir, "backup-manifest.json"),
      JSON.stringify(manifest, null, 2),
      "utf-8"
    );
    consola.success(i18n.t("backup.created", { path: backupDir }));
    return backupDir;
  } catch (error) {
    consola.error(i18n.t("backup.failed"), error);
    throw error;
  }
}
async function copyDirectory(src, dest) {
  await promises.mkdir(dest, { recursive: true });
  const entries = await promises.readdir(src, { withFileTypes: true });
  for (const entry of entries) {
    const srcPath = join(src, entry.name);
    const destPath = join(dest, entry.name);
    if (entry.isDirectory()) {
      await copyDirectory(srcPath, destPath);
    } else {
      await promises.copyFile(srcPath, destPath);
    }
  }
}

function generateReport(result) {
  const report = {
    date: dayjs().format("YYYY-MM-DD HH:mm:ss"),
    profile: result.installationPlan?.profile || "unknown",
    duration: result.duration,
    projectAnalysis: result.projectAnalysis,
    installationPlan: result.installationPlan,
    phases: result.phases,
    summary: {
      total: result.totalInstalled + result.totalSkipped + result.totalFailed,
      installed: result.totalInstalled,
      skipped: result.totalSkipped,
      failed: result.totalFailed
    },
    nextSteps: generateNextSteps(result)
  };
  return formatReport(report);
}
function formatReport(report) {
  const lines = [];
  lines.push("# CCJK Setup Report");
  lines.push("");
  lines.push(`**Date**: ${report.date}`);
  lines.push(`**Profile**: ${report.profile}`);
  lines.push(`**Duration**: ${(report.duration / 1e3).toFixed(1)}s`);
  lines.push("");
  if (report.projectAnalysis) {
    lines.push("## Project Analysis");
    lines.push("");
    lines.push(`- **Type**: ${report.projectAnalysis.type || "Unknown"}`);
    lines.push(`- **Complexity**: ${report.projectAnalysis.complexity || "Unknown"}`);
    if (report.projectAnalysis.teamSize) {
      lines.push(`- **Team Size**: ${report.projectAnalysis.teamSize}`);
    }
    if (report.projectAnalysis.languages?.length) {
      lines.push(`- **Languages**: ${report.projectAnalysis.languages.join(", ")}`);
    }
    if (report.projectAnalysis.frameworks?.length) {
      lines.push(`- **Frameworks**: ${report.projectAnalysis.frameworks.join(", ")}`);
    }
    lines.push("");
  }
  lines.push("## Installation Summary");
  lines.push("");
  lines.push(`\u2705 **Total Installed**: ${report.summary.installed}`);
  if (report.summary.skipped > 0) {
    lines.push(`\u26A0\uFE0F  **Total Skipped**: ${report.summary.skipped}`);
  }
  if (report.summary.failed > 0) {
    lines.push(`\u274C **Total Failed**: ${report.summary.failed}`);
  }
  lines.push("");
  for (const phase of report.phases) {
    if (phase.installed === 0 && phase.skipped === 0 && phase.failed === 0) {
      continue;
    }
    lines.push(`### ${phase.phase.charAt(0).toUpperCase() + phase.phase.slice(1)} Phase`);
    lines.push("");
    lines.push(`- **Status**: ${phase.success ? "\u2705 Success" : "\u274C Failed"}`);
    lines.push(`- **Installed**: ${phase.installed}`);
    if (phase.skipped > 0) {
      lines.push(`- **Skipped**: ${phase.skipped}`);
    }
    if (phase.failed > 0) {
      lines.push(`- **Failed**: ${phase.failed}`);
    }
    lines.push(`- **Duration**: ${(phase.duration / 1e3).toFixed(1)}s`);
    if (phase.details?.resources) {
      lines.push("");
      lines.push("**Installed Resources**:");
      for (const resource of phase.details.resources) {
        lines.push(`  - ${resource.id || resource.name} (${resource.priority || "unknown"})`);
      }
    }
    lines.push("");
  }
  if (report.nextSteps.length > 0) {
    lines.push("## Next Steps");
    lines.push("");
    for (let i = 0; i < report.nextSteps.length; i++) {
      lines.push(`${i + 1}. ${report.nextSteps[i]}`);
    }
    lines.push("");
  }
  if (report.installationPlan) {
    lines.push("## Configuration Details");
    lines.push("");
    lines.push("```json");
    lines.push(JSON.stringify(report.installationPlan, null, 2));
    lines.push("```");
    lines.push("");
  }
  return lines.join("\n");
}
function generateNextSteps(result) {
  const steps = [];
  if (result.totalInstalled > 0) {
    steps.push("Start coding: Your CCJK configuration is ready to use");
    const agentsPhase = result.phases.find((p) => p.phase === "agents");
    if (agentsPhase?.installed && agentsPhase.installed > 0) {
      steps.push("Run an agent: ccjk agent run <agent-name>");
    }
    const skillsPhase = result.phases.find((p) => p.phase === "skills");
    if (skillsPhase?.installed && skillsPhase.installed > 0) {
      steps.push("View available skills: ccjk skills list");
    }
    const mcpPhase = result.phases.find((p) => p.phase === "mcp");
    if (mcpPhase?.installed && mcpPhase.installed > 0) {
      steps.push("Check MCP services: ccjk mcp list");
    }
    const hooksPhase = result.phases.find((p) => p.phase === "hooks");
    if (hooksPhase?.installed && hooksPhase.installed > 0) {
      steps.push("Verify hooks: ccjk hooks list");
    }
  }
  if (result.totalFailed > 0) {
    steps.push("Review failed installations and try again with --verbose for details");
  }
  steps.push("Customize your setup anytime with: ccjk setup --profile custom");
  return steps;
}

class SetupOrchestrator {
  analyzer;
  logger = consola;
  startTime;
  backupPath;
  constructor(analyzer) {
    this.analyzer = analyzer;
    this.startTime = performance.now();
  }
  async execute(options) {
    this.startTime = performance.now();
    const result = {
      success: false,
      totalInstalled: 0,
      totalSkipped: 0,
      totalFailed: 0,
      duration: 0,
      phases: [],
      errors: []
    };
    try {
      if (options.showProgress) {
        this.logger.info(i18n.t("setup.analyzingProject"));
      }
      const projectAnalysis = await this.analyzer.analyze(options.projectPath || process.cwd());
      result.projectAnalysis = projectAnalysis;
      const installationPlan = await this.generateInstallationPlan(projectAnalysis, options);
      result.installationPlan = installationPlan;
      if (options.backup && !options.dryRun) {
        if (options.showProgress) {
          this.logger.info(i18n.t("setup.creatingBackup"));
        }
        this.backupPath = await createBackup("ccjk-setup");
        result.backupPath = this.backupPath;
      }
      if (options.interactive && !options.autoConfirm && !options.dryRun) {
        const confirmed = await this.showPlanAndConfirm(installationPlan, options);
        if (!confirmed) {
          this.logger.info(i18n.t("setup.cancelled"));
          return {
            ...result,
            success: true,
            duration: performance.now() - this.startTime
          };
        }
      }
      if (!options.dryRun) {
        const phases = await this.executePhases(installationPlan, options);
        result.phases = phases;
        result.totalInstalled = phases.reduce((sum, p) => sum + p.installed, 0);
        result.totalSkipped = phases.reduce((sum, p) => sum + p.skipped, 0);
        result.totalFailed = phases.reduce((sum, p) => sum + p.failed, 0);
        result.errors = phases.flatMap((p) => p.errors);
        result.success = result.totalFailed === 0 || !options.rollbackOnError;
      } else {
        result.success = true;
      }
      if (options.report && !options.dryRun) {
        const reportPath = await this.generateReport(result);
        result.reportPath = reportPath;
      }
      result.duration = performance.now() - this.startTime;
      if (!result.success && options.rollbackOnError) {
        await this.rollback(result);
      }
      return result;
    } catch (error) {
      result.errors.push(error);
      result.duration = performance.now() - this.startTime;
      if (options.rollbackOnError) {
        await this.rollback(result);
      }
      return result;
    }
  }
  async generateInstallationPlan(projectAnalysis, options) {
    const { profile = "recommended", resources = ["skills", "mcp", "agents", "hooks"] } = options;
    const plan = {
      profile,
      projectType: projectAnalysis.type,
      complexity: projectAnalysis.complexity,
      estimatedTime: 0,
      phases: {
        skills: {
          enabled: resources.includes("skills"),
          resources: []
        },
        mcp: {
          enabled: resources.includes("mcp"),
          resources: []
        },
        agents: {
          enabled: resources.includes("agents"),
          resources: []
        },
        hooks: {
          enabled: resources.includes("hooks"),
          resources: []
        }
      }
    };
    if (plan.phases.skills.enabled) {
      plan.phases.skills.resources = await this.selectSkills(profile, projectAnalysis);
    }
    if (plan.phases.mcp.enabled) {
      plan.phases.mcp.resources = await this.selectMcpServices(profile, projectAnalysis);
    }
    if (plan.phases.agents.enabled) {
      plan.phases.agents.resources = await this.selectAgents(profile, projectAnalysis);
    }
    if (plan.phases.hooks.enabled) {
      plan.phases.hooks.resources = await this.selectHooks(profile, projectAnalysis);
    }
    const totalResources = plan.phases.skills.resources.length + plan.phases.mcp.resources.length + plan.phases.agents.resources.length + plan.phases.hooks.resources.length;
    plan.estimatedTime = Math.max(1, Math.ceil(totalResources / 4));
    return plan;
  }
  async selectSkills(profile, projectAnalysis) {
    const skills = [];
    if (profile !== "minimal") {
      skills.push({ id: "git-workflow", priority: "essential" });
    }
    if (projectAnalysis.languages?.includes("typescript")) {
      skills.push({ id: "ts-best-practices", priority: "essential" });
      if (profile === "full") {
        skills.push({ id: "ts-advanced-patterns", priority: "high" });
      }
    }
    if (projectAnalysis.languages?.includes("javascript")) {
      skills.push({ id: "js-best-practices", priority: "essential" });
    }
    if (projectAnalysis.frameworks?.includes("react")) {
      skills.push({ id: "react-patterns", priority: "high" });
      if (profile === "full") {
        skills.push({ id: "react-performance", priority: "medium" });
        skills.push({ id: "react-testing", priority: "medium" });
      }
    }
    if (projectAnalysis.frameworks?.includes("nextjs")) {
      skills.push({ id: "nextjs-optimization", priority: "high" });
    }
    if (projectAnalysis.hasTesting) {
      skills.push({ id: "testing-best-practices", priority: "recommended" });
      if (profile === "full") {
        skills.push({ id: "tdd-workflow", priority: "medium" });
      }
    }
    if (profile === "full") {
      skills.push({ id: "performance-optimization", priority: "medium" });
      skills.push({ id: "security-best-practices", priority: "medium" });
      skills.push({ id: "api-design", priority: "low" });
    }
    return skills;
  }
  async selectMcpServices(profile, projectAnalysis) {
    const services = [];
    if (projectAnalysis.languages?.includes("typescript") || projectAnalysis.languages?.includes("javascript")) {
      services.push({ id: "typescript-language-server", priority: "essential" });
    }
    if (projectAnalysis.hasLinting) {
      services.push({ id: "eslint-mcp", priority: "essential" });
    }
    services.push({ id: "git-mcp", priority: "essential" });
    if (profile !== "minimal") {
      if (projectAnalysis.hasTesting) {
        services.push({ id: "test-mcp", priority: "recommended" });
      }
      if (projectAnalysis.packageManager === "npm" || projectAnalysis.packageManager === "pnpm") {
        services.push({ id: "package-json-mcp", priority: "recommended" });
      }
    }
    if (profile === "full") {
      services.push({ id: "file-system-mcp", priority: "medium" });
      services.push({ id: "search-mcp", priority: "medium" });
      if (projectAnalysis.hasDocker) {
        services.push({ id: "docker-mcp", priority: "low" });
      }
    }
    return services;
  }
  async selectAgents(profile, projectAnalysis) {
    const agents = [];
    if (projectAnalysis.languages?.includes("typescript")) {
      agents.push({ id: "typescript-architect", priority: "essential" });
    }
    if (projectAnalysis.frameworks?.includes("react")) {
      agents.push({ id: "react-specialist", priority: "high" });
    }
    if (projectAnalysis.frameworks?.includes("nextjs")) {
      agents.push({ id: "nextjs-specialist", priority: "high" });
    }
    if (projectAnalysis.hasTesting && profile !== "minimal") {
      agents.push({ id: "testing-automation-expert", priority: "recommended" });
    }
    if (profile === "full") {
      agents.push({ id: "code-reviewer", priority: "medium" });
      agents.push({ id: "performance-optimizer", priority: "medium" });
      agents.push({ id: "security-expert", priority: "low" });
    }
    return agents;
  }
  async selectHooks(profile, projectAnalysis) {
    const hooks = [];
    if (projectAnalysis.hasLinting) {
      hooks.push({ id: "pre-commit-eslint", priority: "essential" });
    }
    if (projectAnalysis.hasFormatting) {
      hooks.push({ id: "pre-commit-prettier", priority: "essential" });
    }
    hooks.push({ id: "git-workflow-hooks", priority: "essential" });
    if (profile !== "minimal") {
      if (projectAnalysis.hasTesting) {
        hooks.push({ id: "pre-push-tests", priority: "recommended" });
        hooks.push({ id: "post-test-coverage", priority: "recommended" });
      }
      hooks.push({ id: "commit-message-validator", priority: "recommended" });
    }
    if (profile === "full") {
      hooks.push({ id: "dependency-check", priority: "medium" });
      hooks.push({ id: "security-audit", priority: "low" });
    }
    return hooks;
  }
  async showPlanAndConfirm(_plan, _options) {
    return true;
  }
  async executePhases(plan, options) {
    const phases = [];
    const { parallel = true } = options;
    if (parallel) {
      const [skillsResult, mcpResult] = await Promise.all([
        this.executeSkillsPhase(plan.phases.skills, options),
        this.executeMcpPhase(plan.phases.mcp, options)
      ]);
      phases.push(skillsResult, mcpResult);
      const [agentsResult, hooksResult] = await Promise.all([
        this.executeAgentsPhase(plan.phases.agents, options),
        this.executeHooksPhase(plan.phases.hooks, options)
      ]);
      phases.push(agentsResult, hooksResult);
    } else {
      phases.push(await this.executeSkillsPhase(plan.phases.skills, options));
      phases.push(await this.executeMcpPhase(plan.phases.mcp, options));
      phases.push(await this.executeAgentsPhase(plan.phases.agents, options));
      phases.push(await this.executeHooksPhase(plan.phases.hooks, options));
    }
    return phases;
  }
  async executeSkillsPhase(phaseConfig, options) {
    const startTime = performance.now();
    const result = {
      phase: "skills",
      success: true,
      installed: 0,
      skipped: 0,
      failed: 0,
      duration: 0,
      errors: [],
      details: {}
    };
    if (!phaseConfig.enabled || phaseConfig.resources.length === 0) {
      result.duration = performance.now() - startTime;
      return result;
    }
    try {
      const skillIds = phaseConfig.resources.map((r) => r.id);
      const skillsOptions = {
        lang: options.lang || "en",
        interactive: false,
        dryRun: false,
        force: false,
        targetDir: options.projectPath || process.cwd()
      };
      await ccjkSkills(skillsOptions);
      result.installed = skillIds.length;
      result.skipped = 0;
      result.failed = 0;
      result.details = { skillIds };
      if (result.failed > 0) {
        result.success = false;
        result.errors.push(new Error(`Failed to install ${result.failed} skills`));
      }
    } catch (error) {
      result.success = false;
      result.errors.push(error);
      result.failed = phaseConfig.resources.length;
    }
    result.duration = performance.now() - startTime;
    return result;
  }
  async executeMcpPhase(phaseConfig, options) {
    const startTime = performance.now();
    const result = {
      phase: "mcp",
      success: true,
      installed: 0,
      skipped: 0,
      failed: 0,
      duration: 0,
      errors: [],
      details: {}
    };
    if (!phaseConfig.enabled || phaseConfig.resources.length === 0) {
      result.duration = performance.now() - startTime;
      return result;
    }
    try {
      const mcpIds = phaseConfig.resources.map((r) => r.id);
      const mcpOptions = {
        services: mcpIds,
        interactive: false,
        lang: options.lang || "en",
        dryRun: false,
        force: false
      };
      const mcpResult = await ccjkMcp(mcpOptions);
      result.installed = mcpResult.installed.length;
      result.skipped = mcpResult.skipped.length;
      result.failed = mcpResult.failed.length;
      result.details = mcpResult;
      if (result.failed > 0) {
        result.success = false;
        result.errors.push(new Error(`Failed to install ${result.failed} MCP services`));
      }
    } catch (error) {
      result.success = false;
      result.errors.push(error);
      result.failed = phaseConfig.resources.length;
    }
    result.duration = performance.now() - startTime;
    return result;
  }
  async executeAgentsPhase(phaseConfig, options) {
    const startTime = performance.now();
    const result = {
      phase: "agents",
      success: true,
      installed: 0,
      skipped: 0,
      failed: 0,
      duration: 0,
      errors: [],
      details: {}
    };
    if (!phaseConfig.enabled || phaseConfig.resources.length === 0) {
      result.duration = performance.now() - startTime;
      return result;
    }
    try {
      const agentIds = phaseConfig.resources.map((r) => r.id);
      const agentsOptions = {
        lang: options.lang || "en",
        dryRun: false,
        json: false
      };
      await ccjkAgents(agentsOptions);
      result.installed = agentIds.length;
      result.skipped = 0;
      result.failed = 0;
      result.details = { agentIds };
      if (result.failed > 0) {
        result.success = false;
        result.errors.push(new Error(`Failed to create ${result.failed} agents`));
      }
    } catch (error) {
      result.success = false;
      result.errors.push(error);
      result.failed = phaseConfig.resources.length;
    }
    result.duration = performance.now() - startTime;
    return result;
  }
  async executeHooksPhase(phaseConfig, options) {
    const startTime = performance.now();
    const result = {
      phase: "hooks",
      success: true,
      installed: 0,
      skipped: 0,
      failed: 0,
      duration: 0,
      errors: [],
      details: {}
    };
    if (!phaseConfig.enabled || phaseConfig.resources.length === 0) {
      result.duration = performance.now() - startTime;
      return result;
    }
    try {
      const hookIds = phaseConfig.resources.map((r) => r.id);
      const hooksOptions = {
        dryRun: false,
        json: false,
        verbose: options.verbose || false
      };
      const hooksResult = await ccjkHooks(hooksOptions);
      if (hooksResult && "installed" in hooksResult && hooksResult.installed) {
        result.installed = hooksResult.installed.length;
        result.skipped = 0;
        result.failed = hooksResult.errors?.length || 0;
        result.details = hooksResult;
      } else {
        result.installed = hookIds.length;
        result.skipped = 0;
        result.failed = 0;
        result.details = { hookIds };
      }
      if (result.failed > 0) {
        result.success = false;
        result.errors.push(new Error(`Failed to install ${result.failed} hooks`));
      }
    } catch (error) {
      result.success = false;
      result.errors.push(error);
      result.failed = phaseConfig.resources.length;
    }
    result.duration = performance.now() - startTime;
    return result;
  }
  async generateReport(result) {
    const report = generateReport(result);
    const reportPath = join(process.cwd(), `setup-report-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "")}.md`);
    await promises.writeFile(reportPath, report, "utf-8");
    return reportPath;
  }
  async rollback(result) {
    this.logger.warn(i18n.t("setup.rollbackStarting"));
    try {
      for (const phase of ["hooks", "agents", "mcp", "skills"]) {
        const phaseResult = result.phases.find((p) => p.phase === phase);
        if (phaseResult && phaseResult.installed > 0) {
          this.logger.info(i18n.t("setup.rollbackPhase", { phase }));
          await this.rollbackPhase(phase, phaseResult);
        }
      }
      if (this.backupPath) {
        this.logger.info(i18n.t("setup.restoringBackup"));
      }
      this.logger.info(i18n.t("setup.rollbackComplete"));
    } catch (error) {
      this.logger.error(i18n.t("setup.rollbackFailed"), error);
    }
  }
  async rollbackPhase(phase, _phaseResult) {
  }
}

async function ccjkSetup(options = {}) {
  const lang = resolveSupportedLanguage(options.lang);
  if (lang !== i18n.language) {
    await i18n.changeLanguage(lang);
  }
  const isZh = i18n.language === "zh-CN";
  const logger = options.verbose ? consola : consola.create({ level: 1 });
  const analyzer = new ProjectAnalyzer();
  const orchestrator = new SetupOrchestrator(analyzer);
  if (options.json) {
    const result = await orchestrator.execute({
      ...options,
      showProgress: false,
      interactive: false,
      lang
    });
    console.log(JSON.stringify(result, null, 2));
    return result.success ? 0 : 1;
  }
  logger.log("");
  logger.log(a.cyan(a.bold(`\u{1F680} ${isZh ? "CCJK \u5B8C\u6574\u672C\u5730\u8BBE\u7F6E" : "CCJK Complete Local Setup"}`)));
  logger.log(a.gray(isZh ? "\u57FA\u4E8E\u9879\u76EE\u5206\u6790\u7684\u667A\u80FD\u914D\u7F6E" : "Project-based intelligent setup"));
  logger.log("");
  try {
    const result = await orchestrator.execute({
      ...options,
      lang
    });
    await showResults(result, options, logger);
    return result.success ? 0 : 1;
  } catch (error) {
    logger.error(isZh ? "\u8BBE\u7F6E\u5931\u8D25" : "Setup failed");
    if (options.verbose) {
      logger.error(error);
    }
    return 1;
  }
}
async function showResults(result, options, logger) {
  const isZh = i18n.language === "zh-CN";
  logger.log("");
  if (result.success) {
    logger.log(a.green(a.bold(isZh ? "\u2705 \u8BBE\u7F6E\u5B8C\u6210\uFF01" : "\u2705 Setup Complete!")));
    logger.log("");
    const skillsPhase = result.phases.find((p) => p.phase === "skills");
    const mcpPhase = result.phases.find((p) => p.phase === "mcp");
    const agentsPhase = result.phases.find((p) => p.phase === "agents");
    const hooksPhase = result.phases.find((p) => p.phase === "hooks");
    const summary = [
      `${isZh ? "\u6280\u80FD" : "Skills"}: ${skillsPhase?.installed || 0} ${isZh ? "\u5DF2\u5B89\u88C5" : "installed"}`,
      `${isZh ? "MCP" : "MCP"}: ${mcpPhase?.installed || 0} ${isZh ? "\u5DF2\u5B89\u88C5" : "installed"}`,
      `${isZh ? "\u4EE3\u7406" : "Agents"}: ${agentsPhase?.installed || 0} ${isZh ? "\u5DF2\u521B\u5EFA" : "created"}`,
      `${isZh ? "\u94A9\u5B50" : "Hooks"}: ${hooksPhase?.installed || 0} ${isZh ? "\u5DF2\u914D\u7F6E" : "configured"}`
    ];
    logger.log(a.bold(isZh ? "\u6458\u8981:" : "Summary:"));
    summary.forEach((line) => logger.log(`  ${line}`));
    logger.log("");
    logger.log(a.bold(isZh ? "\u4E0B\u4E00\u6B65:" : "Next steps:"));
    logger.log(`  \u2022 ${isZh ? "\u4F7F\u7528 /ccjk:all \u83B7\u53D6\u4E91AI\u63A8\u8350" : "Use /ccjk:all for cloud AI recommendations"}`);
    logger.log(`  \u2022 ${isZh ? "\u91CD\u542F Claude Code \u4EE5\u5E94\u7528\u66F4\u6539" : "Restart Claude Code to apply changes"}`);
    logger.log("");
  } else {
    logger.log(a.yellow(a.bold(isZh ? "\u26A0\uFE0F \u8BBE\u7F6E\u90E8\u5206\u5931\u8D25" : "\u26A0\uFE0F Setup Partially Failed")));
    logger.log("");
    if (result.errors && result.errors.length > 0) {
      logger.log(a.bold(isZh ? "\u9519\u8BEF:" : "Errors:"));
      result.errors.forEach((err) => logger.log(`  \u2022 ${err}`));
      logger.log("");
    }
    if (options.rollbackOnError) {
      logger.log(isZh ? "\u{1F4A1} \u63D0\u793A: \u4F7F\u7528 --no-rollback \u4FDD\u7559\u5DF2\u5B89\u88C5\u7684\u8D44\u6E90" : "\u{1F4A1} Tip: Use --no-rollback to keep installed resources");
    }
  }
  if (options.report && result.reportPath) {
    logger.log(a.bold(isZh ? "\u{1F4CA} \u8BE6\u7EC6\u62A5\u544A:" : "\u{1F4CA} Detailed Report:"));
    logger.log("");
    logger.log(a.gray(`Report saved to: ${result.reportPath}`));
  }
}

export { ccjkSetup };
