All files / src/cli/init types.ts

100% Statements 3/3
50% Branches 2/4
100% Functions 0/0
100% Lines 3/3

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                                                                                                                                                                                      4x                       4x                       4x                                                                                                              
/**
 * Types for the init wizard
 */
 
/**
 * User role selection for preset mapping.
 *
 * IMPORTANT: These are wizard-facing role names that users see and select.
 * They differ from the actual GITLAB_MCP_PRESET values for better UX:
 *   - "reviewer" (wizard) → "code-reviewer" (preset)
 *   - "senior-developer" (wizard) → "senior-dev" (preset)
 *   - "tech-lead" (wizard) → "full-access" (preset)
 *
 * The mapping is defined in ROLE_PRESETS below.
 */
export type UserRole =
  | "developer"
  | "senior-developer"
  | "tech-lead"
  | "devops"
  | "reviewer" // Maps to "code-reviewer" preset
  | "readonly";
 
/**
 * GitLab instance type
 */
export type InstanceType = "saas" | "self-hosted";
 
/**
 * MCP client type for configuration generation
 */
export type McpClient =
  | "claude-desktop"
  | "claude-code"
  | "cursor"
  | "vscode-copilot"
  | "windsurf"
  | "cline"
  | "roo-code"
  | "generic";
 
/**
 * Configuration gathered during wizard
 */
export interface WizardConfig {
  /** GitLab instance URL */
  instanceUrl: string;
 
  /** Personal Access Token */
  token: string;
 
  /** User role for preset selection */
  role: UserRole;
 
  /** Target MCP client */
  client: McpClient;
 
  /** Whether to use read-only mode */
  readOnly: boolean;
 
  /** Detected preset name based on role */
  presetName?: string;
}
 
/**
 * Result of connection test
 */
export interface ConnectionTestResult {
  success: boolean;
  username?: string;
  email?: string;
  isAdmin?: boolean;
  gitlabVersion?: string;
  error?: string;
}
 
/**
 * Generated configuration for MCP client
 */
export interface McpServerConfig {
  command: string;
  args: string[];
  env: Record<string, string>;
}
 
/**
 * Role to preset mapping.
 * Maps wizard-facing UserRole values to actual GITLAB_MCP_PRESET names.
 * Some mappings differ (e.g., "reviewer" → "code-reviewer") to provide
 * simpler labels in the wizard UI while using correct preset identifiers.
 */
export const ROLE_PRESETS: Record<UserRole, string> = {
  developer: "developer",
  "senior-developer": "senior-dev",
  "tech-lead": "full-access",
  devops: "devops",
  reviewer: "code-reviewer", // Wizard uses "reviewer", preset is "code-reviewer"
  readonly: "readonly",
};
 
/**
 * Role descriptions for wizard selection
 */
export const ROLE_DESCRIPTIONS: Record<UserRole, string> = {
  developer: "Standard development workflow (issues, MRs, pipelines)",
  "senior-developer": "Extended access with wiki, snippets, variables",
  "tech-lead": "Full access to all features including admin tools",
  devops: "CI/CD focused (pipelines, variables, deployments)",
  reviewer: "Code review workflow (MRs, discussions, approvals)",
  readonly: "Read-only access for monitoring and viewing",
};
 
/**
 * MCP client display names and config paths
 */
export const MCP_CLIENT_INFO: Record<
  McpClient,
  {
    name: string;
    configPath: string;
    supportsCliInstall: boolean;
  }
> = {
  "claude-desktop": {
    name: "Claude Desktop",
    configPath:
      process.platform === "darwin"
        ? "~/Library/Application Support/Claude/claude_desktop_config.json"
        : process.platform === "win32"
          ? "%APPDATA%/Claude/claude_desktop_config.json"
          : "",
    supportsCliInstall: false,
  },
  "claude-code": {
    name: "Claude Code",
    configPath: "~/.claude.json",
    supportsCliInstall: true,
  },
  cursor: {
    name: "Cursor",
    configPath: "~/.cursor/mcp.json",
    supportsCliInstall: false,
  },
  "vscode-copilot": {
    name: "VS Code (GitHub Copilot)",
    configPath: ".vscode/mcp.json",
    supportsCliInstall: false,
  },
  windsurf: {
    name: "Windsurf",
    configPath: "~/.codeium/windsurf/mcp_config.json",
    supportsCliInstall: false,
  },
  cline: {
    name: "Cline",
    configPath:
      "~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json",
    supportsCliInstall: false,
  },
  "roo-code": {
    name: "Roo Code",
    configPath: "~/.roo/mcp.json",
    supportsCliInstall: false,
  },
  generic: {
    name: "Other / Generic",
    configPath: "",
    supportsCliInstall: false,
  },
};