import * as fs from 'node:fs';
import { homedir } from 'node:os';
import process__default from 'node:process';
import a from './index5.mjs';
import { i as inquirer } from './index6.mjs';
import ora from './index8.mjs';
import { exec as q } from './main.mjs';
import { getCodeToolRuntimeCommand, CODE_TOOL_INFO, isClaudeFamilyCodeTool } from './constants.mjs';
import { ensureI18nInitialized, i18n } from './index2.mjs';
import { updateClaudeCode } from './auto-updater.mjs';
import { exists } from './fs-operations.mjs';
import { f as findCommandPath, a as getPlatform, b as getHomebrewCommandPaths, d as isTermux, e as getTermuxPrefix, w as wrapCommandWithSudo, h as isWSL, j as getWSLInfo, c as commandExists, k as getRecommendedInstallMethods } from './platform.mjs';
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
import '../shared/ccjk.BAGoDD49.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 '../shared/ccjk.DeWpAShp.mjs';
import 'module';
import 'node:child_process';
import 'node:stream';
import 'node:url';
import '../shared/ccjk.DZ2LLOa-.mjs';
import './version-checker.mjs';
import '../shared/ccjk.CxpGa6MC.mjs';
import 'node:fs/promises';

async function isClaudeCodeInstalled() {
  return await commandExists("claude");
}
async function installClaudeCode(skipMethodSelection = false) {
  ensureI18nInitialized();
  const codeType = "claude-code";
  const installed = await isClaudeCodeInstalled();
  if (installed) {
    console.log(a.green(`\u2714 ${i18n.t("installation:alreadyInstalled")}`));
    const version = await detectInstalledVersion(codeType);
    if (version) {
      console.log(a.gray(`  ${i18n.t("installation:detectedVersion", { version })}`));
    }
    const verification = await verifyInstallation(codeType);
    if (verification.symlinkCreated) {
      displayVerificationResult(verification, codeType);
    }
    await updateClaudeCode();
    return;
  }
  if (isTermux()) {
    console.log(a.yellow(`\u2139 ${i18n.t("installation:termuxDetected")}`));
    const termuxPrefix = getTermuxPrefix();
    console.log(a.gray(i18n.t("installation:termuxPathInfo", { path: termuxPrefix })));
    console.log(a.gray(`Node.js: ${termuxPrefix}/bin/node`));
    console.log(a.gray(`npm: ${termuxPrefix}/bin/npm`));
  }
  if (isWSL()) {
    const wslInfo = getWSLInfo();
    if (wslInfo?.distro) {
      console.log(a.yellow(`\u2139 ${i18n.t("installation:wslDetected", { distro: wslInfo.distro })}`));
    } else {
      console.log(a.yellow(`\u2139 ${i18n.t("installation:wslDetectedGeneric")}`));
    }
    console.log(a.gray(i18n.t("installation:wslPathInfo", { path: `${homedir()}/.claude/` })));
  }
  if (skipMethodSelection) {
    console.log(i18n.t("installation:installing"));
    try {
      const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["install", "-g", "@anthropic-ai/claude-code", "--force"]);
      if (usedSudo) {
        console.log(a.yellow(`\u2139 ${i18n.t("installation:usingSudo")}`));
      }
      await q(command, args);
      console.log(`\u2714 ${i18n.t("installation:installSuccess")}`);
      await setInstallMethod("npm");
      const verification = await verifyInstallation(codeType);
      displayVerificationResult(verification, codeType);
      if (isTermux()) {
        console.log(a.gray(`
Claude Code installed to: ${getTermuxPrefix()}/bin/claude`));
      }
      if (isWSL()) {
        console.log(a.gray(`
${i18n.t("installation:wslInstallSuccess")}`));
      }
    } catch (error) {
      console.error(`\u2716 ${i18n.t("installation:installFailed")}`);
      if (isTermux()) {
        console.error(a.yellow(`
${i18n.t("installation:termuxInstallHint")}
`));
      }
      throw error;
    }
    return;
  }
  const method = await selectInstallMethod(codeType);
  if (!method) {
    console.log(a.yellow(i18n.t("common:cancelled")));
    return;
  }
  const success = await executeInstallMethod(method, codeType);
  if (!success) {
    const retrySuccess = await handleInstallFailure(codeType, [method]);
    if (!retrySuccess) {
      console.error(a.red(`\u2716 ${i18n.t("installation:installFailed")}`));
      throw new Error(i18n.t("installation:installFailed"));
    }
  }
  if (isTermux()) {
    console.log(a.gray(`
Claude Code installed to: ${getTermuxPrefix()}/bin/claude`));
  }
  if (isWSL()) {
    console.log(a.gray(`
${i18n.t("installation:wslInstallSuccess")}`));
  }
}
async function isMyclaudeInstalled() {
  return await commandExists("clavue");
}
async function installMyclaude(skipMethodSelection = false) {
  ensureI18nInitialized();
  const codeType = "clavue";
  const codeTypeName = CODE_TOOL_INFO.clavue.name;
  const installed = await isMyclaudeInstalled();
  if (installed) {
    console.log(a.green(`\u2714 ${codeTypeName} ${i18n.t("installation:alreadyInstalled")}`));
    const version = await detectInstalledVersion(codeType);
    if (version) {
      console.log(a.gray(`  ${i18n.t("installation:detectedVersion", { version })}`));
    }
    const verification = await verifyInstallation(codeType);
    displayVerificationResult(verification, codeType);
    return;
  }
  if (skipMethodSelection) {
    console.log(i18n.t("installation:installingWith", { method: "npm", codeType: codeTypeName }));
    try {
      const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["install", "-g", "clavue", "--force"]);
      if (usedSudo) {
        console.log(a.yellow(`\u2139 ${i18n.t("installation:usingSudo")}`));
      }
      await q(command, args);
      await setInstallMethod("npm", codeType);
      console.log(a.green(`\u2714 ${codeTypeName} ${i18n.t("installation:installSuccess")}`));
      const verification = await verifyInstallation(codeType);
      displayVerificationResult(verification, codeType);
    } catch (error) {
      console.error(a.red(`\u2716 ${codeTypeName} ${i18n.t("installation:installFailed")}`));
      throw error;
    }
    return;
  }
  const success = await executeInstallMethod("npm", codeType);
  if (!success) {
    throw new Error(i18n.t("installation:installFailed"));
  }
}
async function isCodexInstalled() {
  return await commandExists("codex");
}
async function installCodex(skipMethodSelection = false) {
  ensureI18nInitialized();
  const codeType = "codex";
  const codeTypeName = i18n.t("common:codex");
  const installed = await isCodexInstalled();
  if (installed) {
    console.log(a.green(`\u2714 ${codeTypeName} ${i18n.t("installation:alreadyInstalled")}`));
    const version = await detectInstalledVersion(codeType);
    if (version) {
      console.log(a.gray(`  ${i18n.t("installation:detectedVersion", { version })}`));
    }
    return;
  }
  if (skipMethodSelection) {
    console.log(i18n.t("installation:installingWith", { method: "npm", codeType: codeTypeName }));
    try {
      const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["install", "-g", "@openai/codex", "--force"]);
      if (usedSudo) {
        console.log(a.yellow(`\u2139 ${i18n.t("installation:usingSudo")}`));
      }
      await q(command, args);
      console.log(a.green(`\u2714 ${codeTypeName} ${i18n.t("installation:installSuccess")}`));
      const verification = await verifyInstallation(codeType);
      displayVerificationResult(verification, codeType);
    } catch (error) {
      console.error(a.red(`\u2716 ${codeTypeName} ${i18n.t("installation:installFailed")}`));
      throw error;
    }
    return;
  }
  const method = await selectInstallMethod(codeType);
  if (!method) {
    console.log(a.yellow(i18n.t("common:cancelled")));
    return;
  }
  const success = await executeInstallMethod(method, codeType);
  if (!success) {
    const retrySuccess = await handleInstallFailure(codeType, [method]);
    if (!retrySuccess) {
      console.error(a.red(`\u2716 ${codeTypeName} ${i18n.t("installation:installFailed")}`));
      throw new Error(i18n.t("installation:installFailed"));
    }
  }
}
async function getInstallationStatus(codeType = "claude-code") {
  const hasGlobal = codeType === "claude-code" ? await isClaudeCodeInstalled() : codeType === "clavue" ? await isMyclaudeInstalled() : await isCodexInstalled();
  return {
    hasGlobal,
    hasLocal: false,
    localPath: ""
  };
}
async function getInstallMethodFromConfig(codeType) {
  try {
    if (isClaudeFamilyCodeTool(codeType)) {
      const { readMcpConfig } = await import('./claude-config.mjs').then(function (n) { return n.n; });
      const config = readMcpConfig();
      return config?.installMethod || null;
    }
  } catch {
  }
  return null;
}
async function uninstallCodeTool(codeType) {
  ensureI18nInitialized();
  const codeTypeName = CODE_TOOL_INFO[codeType]?.name || codeType;
  let method = await getInstallMethodFromConfig(codeType);
  if (!method) {
    if (codeType === "claude-code") {
      try {
        const result = await q("brew", ["list", "--cask", "claude-code"]);
        if (result.exitCode === 0) {
          method = "homebrew";
        }
      } catch {
      }
    } else if (codeType === "clavue") {
      try {
        const result = await q("brew", ["list", "--cask", "clavue"]);
        if (result.exitCode === 0) {
          method = "homebrew";
        }
      } catch {
      }
    } else if (codeType === "codex") {
      try {
        const result = await q("brew", ["list", "--cask", "codex"]);
        if (result.exitCode === 0) {
          method = "homebrew";
        }
      } catch {
      }
    }
    if (!method) {
      method = "npm";
    }
  }
  if (method === "native") {
    const platform = getPlatform();
    if (platform === "macos" || platform === "linux") {
      try {
        const testResult = codeType === "claude-code" ? await q("brew", ["list", "--cask", "claude-code"]) : codeType === "clavue" ? await q("brew", ["list", "--cask", "clavue"]) : await q("brew", ["list", "--cask", "codex"]);
        if (testResult.exitCode === 0) {
          method = "homebrew";
        }
      } catch {
        method = "manual";
      }
    } else {
      method = "manual";
    }
  }
  const spinner = ora(i18n.t("installation:uninstallingWith", { method, codeType: codeTypeName })).start();
  try {
    switch (method) {
      case "npm":
      case "npm-global": {
        const packageName = codeType === "claude-code" ? "@anthropic-ai/claude-code" : codeType === "clavue" ? "clavue" : "@openai/codex";
        const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["uninstall", "-g", packageName]);
        if (usedSudo) {
          spinner.info(i18n.t("installation:usingSudo"));
          spinner.start();
        }
        await q(command, args);
        break;
      }
      case "homebrew": {
        if (codeType === "claude-code") {
          await q("brew", ["uninstall", "--cask", "claude-code"]);
        } else if (codeType === "clavue") {
          await q("brew", ["uninstall", "--cask", "clavue"]);
        } else {
          await q("brew", ["uninstall", "--cask", "codex"]);
        }
        break;
      }
      case "manual":
      default: {
        spinner.warn(i18n.t("installation:manualUninstallRequired", { codeType: codeTypeName }));
        const command = getCodeToolRuntimeCommand(codeType);
        try {
          const whichCmd = getPlatform() === "windows" ? "where" : "which";
          const result = await q(whichCmd, [command]);
          if (result.stdout) {
            const binaryPath = result.stdout.trim().split("\n")[0];
            spinner.info(i18n.t("installation:binaryLocation", { path: binaryPath }));
            const platform = getPlatform();
            if (platform === "windows") {
              const quotedBinaryPath = `"${binaryPath}"`;
              await q("cmd", ["/c", "del", "/f", "/q", quotedBinaryPath]);
            } else {
              const { command: rmCmd, args: rmArgs } = wrapCommandWithSudo("rm", ["-f", binaryPath]);
              if (rmCmd === "sudo") {
                spinner.info(i18n.t("installation:usingSudo"));
                spinner.start();
              }
              await q(rmCmd, rmArgs);
            }
          }
        } catch {
          spinner.fail(i18n.t("installation:failedToLocateBinary", { command }));
          return false;
        }
        break;
      }
    }
    spinner.succeed(i18n.t("installation:uninstallSuccess", { method, codeType: codeTypeName }));
    return true;
  } catch (error) {
    spinner.fail(i18n.t("installation:uninstallFailed", { method, codeType: codeTypeName }));
    if (error instanceof Error) {
      console.error(a.gray(error.message));
    }
    return false;
  }
}
async function setInstallMethod(method, codeType = "claude-code") {
  try {
    if (isClaudeFamilyCodeTool(codeType)) {
      const {
        readMcpConfig,
        writeMcpConfig
      } = await import('./claude-config.mjs').then(function (n) { return n.n; });
      const {
        readClavueConfig,
        writeClavueConfig
      } = await import('./clavue-config.mjs').then(function (n) { return n.g; });
      const readConfig = codeType === "clavue" ? readClavueConfig : readMcpConfig;
      const writeConfig = codeType === "clavue" ? writeClavueConfig : writeMcpConfig;
      let config = readConfig();
      if (!config) {
        config = { mcpServers: {} };
      }
      config.installMethod = method === "npm" ? "npm-global" : method;
      writeConfig(config);
    }
  } catch (error) {
    console.error("Failed to set installMethod:", error);
  }
}
async function detectInstalledVersion(codeType) {
  try {
    const command = getCodeToolRuntimeCommand(codeType);
    const result = await q(command, ["--version"]);
    if (result.exitCode === 0 && result.stdout) {
      const versionMatch = result.stdout.match(/(\d+\.\d+\.\d+)/);
      return versionMatch ? versionMatch[1] : result.stdout.trim();
    }
  } catch {
  }
  return null;
}
function getInstallMethodLabel(method) {
  switch (method) {
    case "npm":
      return i18n.t("installation:installMethodNpm");
    case "homebrew":
      return i18n.t("installation:installMethodHomebrew");
    case "curl":
      return i18n.t("installation:installMethodCurl");
    case "powershell":
      return i18n.t("installation:installMethodPowershell");
    case "cmd":
      return i18n.t("installation:installMethodCmd");
    default:
      return method;
  }
}
function getInstallMethodOptions(codeType, recommendedMethods) {
  const allMethods = ["npm", "homebrew", "curl", "powershell", "cmd"];
  const platform = getPlatform();
  const availableMethods = allMethods.filter((method) => {
    if (codeType === "codex" && !["npm", "homebrew"].includes(method)) {
      return false;
    }
    if (codeType === "clavue" && method !== "npm") {
      return false;
    }
    if (method === "homebrew")
      return platform === "macos" || platform === "linux";
    if (method === "curl")
      return platform !== "windows" || isWSL();
    if (method === "powershell" || method === "cmd")
      return platform === "windows";
    return true;
  });
  const topRecommended = recommendedMethods.length > 0 ? recommendedMethods[0] : null;
  return availableMethods.map((method) => {
    const isTopRecommended = method === topRecommended;
    const methodLabel = getInstallMethodLabel(method);
    const title = isTopRecommended ? `${methodLabel} ${a.green(`[${i18n.t("installation:recommendedMethod")}]`)}` : methodLabel;
    return {
      title,
      value: method
    };
  });
}
async function selectInstallMethod(codeType, excludeMethods = []) {
  ensureI18nInitialized();
  const codeTypeName = CODE_TOOL_INFO[codeType]?.name || codeType;
  const recommendedMethods = getRecommendedInstallMethods(codeType);
  const methodOptions = getInstallMethodOptions(codeType, recommendedMethods).filter((option) => !excludeMethods.includes(option.value));
  if (methodOptions.length === 0) {
    console.log(a.yellow(i18n.t("installation:noMoreMethods")));
    return null;
  }
  const response = await inquirer.prompt({
    type: "list",
    name: "method",
    message: i18n.t("installation:selectInstallMethod", { codeType: codeTypeName }),
    choices: methodOptions.map((opt) => ({
      name: opt.title,
      value: opt.value
    }))
  });
  return response.method || null;
}
async function executeInstallMethod(method, codeType) {
  ensureI18nInitialized();
  const codeTypeName = CODE_TOOL_INFO[codeType]?.name || codeType;
  const spinner = ora(i18n.t("installation:installingWith", { method, codeType: codeTypeName })).start();
  try {
    switch (method) {
      case "npm": {
        const packageName = codeType === "claude-code" ? "@anthropic-ai/claude-code" : codeType === "clavue" ? "clavue" : "@openai/codex";
        const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["install", "-g", packageName, "--force"]);
        if (usedSudo) {
          spinner.info(i18n.t("installation:usingSudo"));
          spinner.start();
        }
        await q(command, args);
        await setInstallMethod("npm", codeType);
        break;
      }
      case "homebrew": {
        if (codeType === "claude-code") {
          await q("brew", ["install", "--cask", "claude-code"]);
        } else if (codeType === "clavue") {
          spinner.stop();
          return await executeInstallMethod("npm", codeType);
        } else {
          await q("brew", ["install", "--cask", "codex"]);
        }
        await setInstallMethod("homebrew", codeType);
        break;
      }
      case "curl": {
        if (codeType === "claude-code") {
          await q("bash", ["-c", "curl -fsSL https://claude.ai/install.sh | bash"]);
        } else {
          spinner.stop();
          return await executeInstallMethod("npm", codeType);
        }
        await setInstallMethod("curl", codeType);
        break;
      }
      case "powershell": {
        if (codeType === "claude-code") {
          await q("powershell", ["-Command", "irm https://claude.ai/install.ps1 | iex"]);
        } else {
          spinner.stop();
          return await executeInstallMethod("npm", codeType);
        }
        await setInstallMethod("powershell", codeType);
        break;
      }
      case "cmd": {
        if (codeType === "claude-code") {
          await q("cmd", ["/c", "curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd"]);
        } else {
          spinner.stop();
          return await executeInstallMethod("npm", codeType);
        }
        await setInstallMethod("cmd", codeType);
        break;
      }
      default:
        throw new Error(`Unsupported install method: ${method}`);
    }
    spinner.succeed(i18n.t("installation:installMethodSuccess", { method }));
    const verification = await verifyInstallation(codeType);
    displayVerificationResult(verification, codeType);
    return true;
  } catch (error) {
    spinner.fail(i18n.t("installation:installMethodFailed", { method }));
    if (error instanceof Error) {
      console.error(a.gray(error.message));
    }
    return false;
  }
}
async function handleInstallFailure(codeType, failedMethods) {
  ensureI18nInitialized();
  const response = await inquirer.prompt({
    type: "confirm",
    name: "retry",
    message: i18n.t("installation:tryAnotherMethod"),
    default: true
  });
  if (!response.retry) {
    return false;
  }
  const newMethod = await selectInstallMethod(codeType, failedMethods);
  if (!newMethod) {
    return false;
  }
  const success = await executeInstallMethod(newMethod, codeType);
  if (success) {
    return true;
  }
  return await handleInstallFailure(codeType, [...failedMethods, newMethod]);
}
async function isCommandInPath(command) {
  try {
    const cmd = getPlatform() === "windows" ? "where" : "which";
    const res = await q(cmd, [command]);
    return res.exitCode === 0;
  } catch {
    return false;
  }
}
async function verifyInstallation(codeType) {
  const command = getCodeToolRuntimeCommand(codeType);
  const commandInPath = await isCommandInPath(command);
  if (commandInPath) {
    const version = await detectInstalledVersion(codeType);
    return {
      success: true,
      commandPath: await findCommandPath(command),
      version,
      needsSymlink: false,
      symlinkCreated: false
    };
  }
  if (getPlatform() === "macos") {
    const homebrewPaths = await getHomebrewCommandPaths(command);
    let foundPath = null;
    for (const path of homebrewPaths) {
      if (exists(path)) {
        foundPath = path;
        break;
      }
    }
    if (foundPath) {
      const symlinkResult = await createHomebrewSymlink(command, foundPath);
      if (symlinkResult.success) {
        const version = await detectInstalledVersion(codeType);
        return {
          success: true,
          commandPath: symlinkResult.symlinkPath,
          version,
          needsSymlink: true,
          symlinkCreated: true
        };
      }
      return {
        success: false,
        commandPath: foundPath,
        version: null,
        needsSymlink: true,
        symlinkCreated: false,
        error: symlinkResult.error
      };
    }
  }
  if (isTermux()) {
    const termuxPrefix = getTermuxPrefix();
    const termuxPaths = [
      `${termuxPrefix}/bin/${command}`,
      `${termuxPrefix}/usr/bin/${command}`
    ];
    for (const path of termuxPaths) {
      if (exists(path)) {
        const version = await detectInstalledVersion(codeType);
        return {
          success: true,
          commandPath: path,
          version,
          needsSymlink: false,
          symlinkCreated: false
        };
      }
    }
  }
  if (getPlatform() === "linux") {
    const home = homedir();
    const linuxPaths = [
      `${home}/.local/bin/${command}`,
      // Standard XDG user bin (curl install default)
      `${home}/.claude/bin/${command}`,
      // Claude-specific bin directory
      `/usr/local/bin/${command}`,
      // System-wide installation
      `/usr/bin/${command}`
      // System package manager
    ];
    for (const path of linuxPaths) {
      if (exists(path)) {
        const version = await detectInstalledVersion(codeType);
        const needsPathUpdate = path.includes(".local/bin") && !process__default.env.PATH?.includes(".local/bin");
        return {
          success: true,
          commandPath: path,
          version,
          needsSymlink: false,
          symlinkCreated: false,
          error: needsPathUpdate ? "PATH_UPDATE_NEEDED" : void 0
        };
      }
    }
  }
  return {
    success: false,
    commandPath: null,
    version: null,
    needsSymlink: false,
    symlinkCreated: false,
    error: "Command not found in any known location"
  };
}
async function createHomebrewSymlink(command, sourcePath) {
  const homebrewBinPaths = [
    "/opt/homebrew/bin",
    // Apple Silicon (M1/M2)
    "/usr/local/bin"
    // Intel Mac
  ];
  let targetDir = null;
  for (const binPath of homebrewBinPaths) {
    if (fs.existsSync(binPath)) {
      targetDir = binPath;
      break;
    }
  }
  if (!targetDir) {
    return {
      success: false,
      symlinkPath: null,
      error: "No suitable Homebrew bin directory found"
    };
  }
  const symlinkPath = join(targetDir, command);
  try {
    const stats = fs.lstatSync(symlinkPath);
    if (stats.isSymbolicLink()) {
      const existingTarget = fs.readlinkSync(symlinkPath);
      if (existingTarget === sourcePath) {
        return {
          success: true,
          symlinkPath
        };
      }
      fs.unlinkSync(symlinkPath);
    } else {
      return {
        success: false,
        symlinkPath: null,
        error: `File already exists at ${symlinkPath} and is not a symlink`
      };
    }
  } catch (error) {
    if (error.code !== "ENOENT") {
      return {
        success: false,
        symlinkPath: null,
        error: `Failed to check existing file: ${error}`
      };
    }
  }
  try {
    fs.symlinkSync(sourcePath, symlinkPath);
    return {
      success: true,
      symlinkPath
    };
  } catch (error) {
    if (error.code === "EACCES") {
      return {
        success: false,
        symlinkPath: null,
        error: `Permission denied. Try running: sudo ln -sf ${sourcePath} ${symlinkPath}`
      };
    }
    return {
      success: false,
      symlinkPath: null,
      error: `Failed to create symlink: ${error.message}`
    };
  }
}
function displayVerificationResult(result, codeType) {
  ensureI18nInitialized();
  const codeTypeName = CODE_TOOL_INFO[codeType]?.name || codeType;
  if (result.success) {
    if (result.symlinkCreated) {
      console.log(a.green(`\u2714 ${codeTypeName} ${i18n.t("installation:verificationSuccess")}`));
      console.log(a.gray(`  ${i18n.t("installation:symlinkCreated", { path: result.commandPath })}`));
    } else if (result.commandPath) {
      console.log(a.green(`\u2714 ${codeTypeName} ${i18n.t("installation:verificationSuccess")}`));
      console.log(a.gray(`  ${i18n.t("installation:foundAtPath", { path: result.commandPath })}`));
    }
    if (result.version) {
      console.log(a.gray(`  ${i18n.t("installation:detectedVersion", { version: result.version })}`));
    }
    if (result.error === "PATH_UPDATE_NEEDED") {
      console.log(a.yellow(`
\u26A0 ${i18n.t("installation:pathUpdateNeeded")}`));
      console.log(a.gray(`  ${i18n.t("installation:pathUpdateHint")}`));
      console.log(a.green(`  export PATH="$HOME/.local/bin:$PATH"`));
      console.log(a.gray(`  ${i18n.t("installation:pathUpdatePermanent")}`));
      console.log(a.green(`  echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc`));
    }
  } else {
    console.log(a.yellow(`\u26A0 ${codeTypeName} ${i18n.t("installation:verificationFailed")}`));
    if (result.commandPath) {
      console.log(a.gray(`  ${i18n.t("installation:foundAtPath", { path: result.commandPath })}`));
    }
    if (result.error && result.error !== "PATH_UPDATE_NEEDED") {
      console.log(a.gray(`  ${result.error}`));
    }
    if (result.needsSymlink && !result.symlinkCreated) {
      console.log(a.yellow(`  ${i18n.t("installation:manualSymlinkHint")}`));
    }
  }
}

export { createHomebrewSymlink, detectInstalledVersion, displayVerificationResult, executeInstallMethod, getInstallationStatus, handleInstallFailure, installClaudeCode, installCodex, installMyclaude, isClaudeCodeInstalled, isCodexInstalled, isMyclaudeInstalled, selectInstallMethod, setInstallMethod, uninstallCodeTool, verifyInstallation };
