All files / src/cli/install types.ts

100% Statements 17/17
100% Branches 8/8
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248                                                                                                                                                                                                                                                        9x         14x 14x 8x 6x 5x 5x 1x     9x                                                                                                                                           4x     3x     7x                                             9x                    
/**
 * Types for MCP client installation module
 */
 
import { McpClient, McpServerConfig } from '../init/types';
 
/**
 * Supported MCP clients for installation
 */
export type InstallableClient = Exclude<McpClient, 'generic'>;
 
/**
 * Detection result for an MCP client
 */
export interface ClientDetectionResult {
  /** Client type */
  client: InstallableClient;
  /** Whether the client is installed/detected */
  detected: boolean;
  /** Config file path (if applicable) */
  configPath?: string;
  /** Whether config file exists */
  configExists?: boolean;
  /** Whether gitlab-mcp is already configured */
  alreadyConfigured?: boolean;
  /** Detection method used */
  method: 'config-file' | 'cli-command' | 'app-bundle';
}
 
/**
 * Installation options
 */
export interface InstallOptions {
  /** Target clients to install */
  clients?: InstallableClient[];
  /** Install to all detected clients */
  all?: boolean;
  /** Only show config, don't write */
  showOnly?: boolean;
  /** Force overwrite existing config */
  force?: boolean;
  /** Server configuration to install */
  serverConfig: McpServerConfig;
  /** GitLab instance URL */
  instanceUrl: string;
  /** Whether using read-only mode */
  readOnly?: boolean;
  /** Preset name */
  presetName?: string;
}
 
/**
 * Installation result for a single client
 */
export interface InstallResult {
  /** Client type */
  client: InstallableClient;
  /** Whether installation succeeded */
  success: boolean;
  /** Error message if failed */
  error?: string;
  /** Path to backup file (if created) */
  backupPath?: string;
  /** Path to config file (if written) */
  configPath?: string;
  /** Whether config was already present */
  wasAlreadyConfigured?: boolean;
  /** Facts the user must act on, e.g. a duplicate registration or a pending sign-in */
  notes?: string[];
}
 
/**
 * Backup options
 */
export interface BackupOptions {
  /** Path to the config file to backup */
  configPath: string;
  /** Custom backup directory (default: same dir as config) */
  backupDir?: string;
}
 
/**
 * Backup result
 */
export interface BackupResult {
  /** Whether backup was created */
  created: boolean;
  /** Path to backup file */
  backupPath?: string;
  /** Error message if failed */
  error?: string;
}
 
/**
 * Client config paths by platform
 */
export interface ClientConfigPaths {
  darwin?: string;
  win32?: string;
  linux?: string;
}
 
/**
 * Client configuration metadata
 */
export interface ClientMetadata {
  /** Display name */
  name: string;
  /** Config paths by platform */
  configPaths: ClientConfigPaths;
  /** Whether client supports CLI installation */
  supportsCliInstall: boolean;
  /** CLI command for installation (if supported) */
  cliCommand?: string;
  /** Detection method */
  detectionMethod: 'config-file' | 'cli-command' | 'app-bundle';
  /** App bundle identifier (macOS) */
  appBundleId?: string;
}
 
/**
 * Client metadata registry
 */
const ROO_SETTINGS_SUFFIX =
  'Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json';
 
function rooConfigPath(platform: 'darwin' | 'win32' | 'linux'): string {
  // Match VS Code's application-data precedence for the default profile.
  // https://github.com/microsoft/vscode/blob/main/src/vs/platform/environment/node/userDataPath.ts
  const appData = process.env.VSCODE_APPDATA;
  if (appData) return `${appData}/${ROO_SETTINGS_SUFFIX}`;
  if (platform === 'darwin') return `~/Library/Application Support/${ROO_SETTINGS_SUFFIX}`;
  if (platform === 'win32') return `%APPDATA%/${ROO_SETTINGS_SUFFIX}`;
  const configHome = process.env.XDG_CONFIG_HOME;
  if (configHome) return `${configHome}/${ROO_SETTINGS_SUFFIX}`;
  return `~/.config/${ROO_SETTINGS_SUFFIX}`;
}
 
export const CLIENT_METADATA: Record<InstallableClient, ClientMetadata> = {
  'claude-desktop': {
    name: 'Claude Desktop',
    configPaths: {
      darwin: '~/Library/Application Support/Claude/claude_desktop_config.json',
      win32: '%APPDATA%/Claude/claude_desktop_config.json',
      linux: '~/.config/claude/claude_desktop_config.json',
    },
    supportsCliInstall: false,
    detectionMethod: 'app-bundle',
    appBundleId: 'com.anthropic.claudefordesktop',
  },
  'claude-code': {
    name: 'Claude Code',
    configPaths: {
      darwin: '~/.claude.json',
      win32: '%USERPROFILE%/.claude.json',
      linux: '~/.claude.json',
    },
    supportsCliInstall: true,
    cliCommand: 'claude',
    detectionMethod: 'cli-command',
  },
  cursor: {
    name: 'Cursor',
    configPaths: {
      darwin: '~/.cursor/mcp.json',
      win32: '%USERPROFILE%/.cursor/mcp.json',
      linux: '~/.cursor/mcp.json',
    },
    supportsCliInstall: false,
    detectionMethod: 'config-file',
  },
  'vscode-copilot': {
    name: 'VS Code (GitHub Copilot)',
    configPaths: {
      darwin: '.vscode/mcp.json',
      win32: '.vscode/mcp.json',
      linux: '.vscode/mcp.json',
    },
    supportsCliInstall: false,
    detectionMethod: 'config-file',
  },
  windsurf: {
    name: 'Windsurf',
    configPaths: {
      darwin: '~/.codeium/windsurf/mcp_config.json',
      win32: '%USERPROFILE%/.codeium/windsurf/mcp_config.json',
      linux: '~/.codeium/windsurf/mcp_config.json',
    },
    supportsCliInstall: false,
    detectionMethod: 'config-file',
  },
  cline: {
    name: 'Cline',
    configPaths: {
      darwin:
        '~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json',
      win32:
        '%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json',
      linux:
        '~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json',
    },
    supportsCliInstall: false,
    detectionMethod: 'config-file',
  },
  'roo-code': {
    name: 'Roo Code',
    configPaths: {
      get darwin(): string {
        return rooConfigPath('darwin');
      },
      get win32(): string {
        return rooConfigPath('win32');
      },
      get linux(): string {
        return rooConfigPath('linux');
      },
    },
    supportsCliInstall: false,
    detectionMethod: 'config-file',
  },
  codex: {
    name: 'Codex',
    // CODEX_HOME relocates it; the Codex CLI edits it, see codex.ts.
    configPaths: {
      darwin: '~/.codex/config.toml',
      win32: '%USERPROFILE%/.codex/config.toml',
      linux: '~/.codex/config.toml',
    },
    supportsCliInstall: true,
    cliCommand: 'codex',
    detectionMethod: 'cli-command',
  },
};
 
/**
 * List of all installable clients
 */
export const INSTALLABLE_CLIENTS: InstallableClient[] = [
  'claude-desktop',
  'claude-code',
  'cursor',
  'vscode-copilot',
  'windsurf',
  'cline',
  'roo-code',
  'codex',
];