| 78 | } |
| 79 | |
| 80 | export function registerSetupCommand(program: Command): void { |
| 81 | program |
| 82 | .command("setup") |
| 83 | .description("Set up Context7 for your AI coding agent") |
| 84 | .option("--claude", "Set up for Claude Code") |
| 85 | .option("--cursor", "Set up for Cursor") |
| 86 | .option("--antigravity", "Set up for Antigravity (.agent/skills)") |
| 87 | .option("--opencode", "Set up for OpenCode") |
| 88 | .option("--codex", "Set up for Codex") |
| 89 | .option("--gemini", "Set up for Gemini CLI") |
| 90 | .option("--mcp", "Set up MCP server mode") |
| 91 | .option("--cli", "Set up CLI + Skills mode (no MCP server)") |
| 92 | .option("-p, --project", "Configure for current project instead of globally") |
| 93 | .option("-y, --yes", "Skip confirmation prompts") |
| 94 | .option("--api-key <key>", "Use API key authentication") |
| 95 | .option("--oauth", "Use OAuth endpoint (IDE handles auth flow)") |
| 96 | .option("--stdio", "Configure the MCP server as a local stdio process (default: HTTP)") |
| 97 | .action(async (options: SetupOptions) => { |
| 98 | await setupCommand(options); |
| 99 | }); |
| 100 | } |
| 101 | |
| 102 | async function authenticateAndGenerateKey(): Promise<string | null> { |
| 103 | const accessToken = (await getValidAccessToken()) ?? (await performLogin()); |