feat(cli): improve CLI agent and command handling

This commit is contained in:
Kaive Young 2026-04-16 20:58:01 +08:00
parent cb83656718
commit f2a3282b92
6 changed files with 23 additions and 1 deletions

View file

@ -190,6 +190,7 @@ Tokens are valid for 90 days. The CLI will prompt you to re-authenticate when yo
| `-k, --api-key <key>` | API key for the LLM provider | From env var |
| `--provider <provider>` | API provider (roo, anthropic, openai, openrouter, etc.) | `openrouter` (or `roo` if authenticated) |
| `-m, --model <model>` | Model to use | `anthropic/claude-opus-4.6` |
| `-b, --base-url <url>` | Base URL for the LLM provider (e.g., for OpenAI-compatible APIs) | None |
| `--mode <mode>` | Mode to start in (code, architect, ask, debug, etc.) | `code` |
| `--terminal-shell <path>` | Absolute shell path for inline terminal command execution | Auto-detected shell |
| `-r, --reasoning-effort <effort>` | Reasoning effort level (unspecified, disabled, none, minimal, low, medium, high, xhigh) | `medium` |

View file

@ -71,6 +71,7 @@ export interface ExtensionHostOptions {
provider: SupportedProvider
apiKey?: string
model: string
baseUrl?: string
workspacePath: string
extensionPath: string
nonInteractive?: boolean
@ -227,7 +228,12 @@ export class ExtensionHost extends EventEmitter implements ExtensionHostInterfac
experiments: {
customTools: true,
},
...getProviderSettings(this.options.provider, this.options.apiKey, this.options.model),
...getProviderSettings(
this.options.provider,
this.options.apiKey,
this.options.model,
this.options.baseUrl,
),
}
this.initialSettings = this.options.nonInteractive

View file

@ -219,6 +219,7 @@ export async function run(promptArg: string | undefined, flagOptions: FlagOption
user: null,
provider: effectiveProvider,
model: effectiveModel,
baseUrl: flagOptions.baseUrl,
workspacePath: effectiveWorkspacePath,
extensionPath: path.resolve(flagOptions.extension || getDefaultExtensionPath(__dirname)),
nonInteractive: !effectiveRequireApproval,

View file

@ -47,6 +47,7 @@ program
.option("-k, --api-key <key>", "API key for the LLM provider")
.option("--provider <provider>", "API provider (roo, anthropic, openai, openrouter, etc.)")
.option("-m, --model <model>", "Model to use", DEFAULT_FLAGS.model)
.option("-b, --base-url <url>", "Base URL for the LLM provider (e.g., for OpenAI-compatible APIs)")
.option("--mode <mode>", "Mode to start in (code, architect, ask, debug, etc.)", DEFAULT_FLAGS.mode)
.option("--terminal-shell <path>", "Absolute path to shell executable for inline terminal commands")
.option(

View file

@ -5,6 +5,7 @@ import type { SupportedProvider } from "@/types/index.js"
const envVarMap: Record<SupportedProvider, string> = {
anthropic: "ANTHROPIC_API_KEY",
"openai-native": "OPENAI_API_KEY",
openai: "OPENAI_API_KEY",
gemini: "GOOGLE_API_KEY",
openrouter: "OPENROUTER_API_KEY",
"vercel-ai-gateway": "VERCEL_AI_GATEWAY_API_KEY",
@ -24,6 +25,7 @@ export function getProviderSettings(
provider: SupportedProvider,
apiKey: string | undefined,
model: string | undefined,
baseUrl: string | undefined,
): RooCodeSettings {
const config: RooCodeSettings = { apiProvider: provider }
@ -32,17 +34,25 @@ export function getProviderSettings(
if (apiKey) config.apiKey = apiKey
if (model) config.apiModelId = model
break
case "openai":
if (apiKey) config.openAiApiKey = apiKey
if (model) config.openAiModelId = model
if (baseUrl) config.openAiBaseUrl = baseUrl
break
case "openai-native":
if (apiKey) config.openAiNativeApiKey = apiKey
if (model) config.apiModelId = model
if (baseUrl) config.openAiNativeBaseUrl = baseUrl
break
case "gemini":
if (apiKey) config.geminiApiKey = apiKey
if (model) config.apiModelId = model
if (baseUrl) config.googleGeminiBaseUrl = baseUrl
break
case "openrouter":
if (apiKey) config.openRouterApiKey = apiKey
if (model) config.openRouterModelId = model
if (baseUrl) config.openRouterBaseUrl = baseUrl
break
case "vercel-ai-gateway":
if (apiKey) config.vercelAiGatewayApiKey = apiKey
@ -55,6 +65,7 @@ export function getProviderSettings(
default:
if (apiKey) config.apiKey = apiKey
if (model) config.apiModelId = model
if (baseUrl) config.openAiBaseUrl = baseUrl
}
return config

View file

@ -4,6 +4,7 @@ import type { OutputFormat } from "./json-events.js"
export const supportedProviders = [
"anthropic",
"openai-native",
"openai",
"gemini",
"openrouter",
"vercel-ai-gateway",
@ -34,6 +35,7 @@ export type FlagOptions = {
apiKey?: string
provider?: SupportedProvider
model?: string
baseUrl?: string
mode?: string
terminalShell?: string
reasoningEffort?: ReasoningEffortFlagOptions