mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-02-05 18:41:10 +08:00
feat: integrate Kimi CLI into Code Tools (#12511)
* feat: integrate Kimi CLI into Code Tools - Add Kimi CLI as a new code tool option in Code Tools page - Support OpenAI-compatible models for Kimi CLI - Use uvx to automatically download and run kimi-cli (Python package) - Configure environment variables (OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL) - Skip installation check as uvx handles package management automatically Changes: - Add kimiCli to codeTools enum - Add Kimi CLI to CLI_TOOLS list with label - Add provider filter for OpenAI-compatible providers - Add environment variable generation logic - Add model filtering logic in UI - Special handling in CodeToolsService to use uvx instead of bun - Skip installation process for kimi-cli as uvx auto-downloads This integration allows users to launch Kimi CLI directly from Cherry Studio without manual installation, leveraging uvx for seamless Python package management. * Update src/renderer/src/pages/code/index.ts Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com> * Update src/main/services/CodeToolsService.ts Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com> * Update src/renderer/src/pages/code/CodeToolsPage.tsx Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com> * fix: remove extra blank line in CodeToolsPage.tsx for biome format compliance --------- Co-authored-by: xiaoju111a <xiaoju111a@users.noreply.github.com> Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com>
This commit is contained in:
parent
a477b54234
commit
dc3cee978a
@ -233,7 +233,8 @@ export enum codeTools {
|
||||
geminiCli = 'gemini-cli',
|
||||
openaiCodex = 'openai-codex',
|
||||
iFlowCli = 'iflow-cli',
|
||||
githubCopilotCli = 'github-copilot-cli'
|
||||
githubCopilotCli = 'github-copilot-cli',
|
||||
kimiCli = 'kimi-cli'
|
||||
}
|
||||
|
||||
export enum terminalApps {
|
||||
|
||||
@ -87,6 +87,8 @@ class CodeToolsService {
|
||||
return '@iflow-ai/iflow-cli'
|
||||
case codeTools.githubCopilotCli:
|
||||
return '@github/copilot'
|
||||
case codeTools.kimiCli:
|
||||
return 'kimi-cli' // Python package
|
||||
default:
|
||||
throw new Error(`Unsupported CLI tool: ${cliTool}`)
|
||||
}
|
||||
@ -106,6 +108,8 @@ class CodeToolsService {
|
||||
return 'iflow'
|
||||
case codeTools.githubCopilotCli:
|
||||
return 'copilot'
|
||||
case codeTools.kimiCli:
|
||||
return 'kimi'
|
||||
default:
|
||||
throw new Error(`Unsupported CLI tool: ${cliTool}`)
|
||||
}
|
||||
@ -647,6 +651,12 @@ class CodeToolsService {
|
||||
|
||||
let baseCommand = isWin ? `"${executablePath}"` : `"${bunPath}" "${executablePath}"`
|
||||
|
||||
// Special handling for kimi-cli: use uvx instead of bun
|
||||
if (cliTool === codeTools.kimiCli) {
|
||||
const uvPath = path.join(os.homedir(), HOME_CHERRY_DIR, 'bin', await getBinaryName('uv'))
|
||||
baseCommand = `${uvPath} tool run ${packageName}`
|
||||
}
|
||||
|
||||
// Add configuration parameters for OpenAI Codex
|
||||
if (cliTool === codeTools.openaiCodex && env.OPENAI_MODEL_PROVIDER && env.OPENAI_MODEL_PROVIDER != 'openai') {
|
||||
const provider = env.OPENAI_MODEL_PROVIDER
|
||||
@ -666,7 +676,11 @@ class CodeToolsService {
|
||||
|
||||
const bunInstallPath = path.join(os.homedir(), HOME_CHERRY_DIR)
|
||||
|
||||
if (isInstalled) {
|
||||
// Special handling for kimi-cli: uvx handles installation automatically
|
||||
if (cliTool === codeTools.kimiCli) {
|
||||
// uvx will automatically download and run kimi-cli, no need to install
|
||||
// Just use the base command directly
|
||||
} else if (isInstalled) {
|
||||
// If already installed, run executable directly (with optional update message)
|
||||
if (updateMessage) {
|
||||
baseCommand = `echo "Checking ${cliTool} version..."${updateMessage} && ${baseCommand}`
|
||||
|
||||
@ -22,7 +22,8 @@ export const CLI_TOOLS = [
|
||||
{ value: codeTools.geminiCli, label: 'Gemini CLI' },
|
||||
{ value: codeTools.openaiCodex, label: 'OpenAI Codex' },
|
||||
{ value: codeTools.iFlowCli, label: 'iFlow CLI' },
|
||||
{ value: codeTools.githubCopilotCli, label: 'GitHub Copilot CLI' }
|
||||
{ value: codeTools.githubCopilotCli, label: 'GitHub Copilot CLI' },
|
||||
{ value: codeTools.kimiCli, label: 'Kimi CLI' }
|
||||
]
|
||||
|
||||
export const GEMINI_SUPPORTED_PROVIDERS = ['aihubmix', 'dmxapi', 'new-api', 'cherryin']
|
||||
@ -59,7 +60,8 @@ export const CLI_TOOL_PROVIDER_MAP: Record<string, (providers: Provider[]) => Pr
|
||||
[codeTools.openaiCodex]: (providers) =>
|
||||
providers.filter((p) => p.id === 'openai' || OPENAI_CODEX_SUPPORTED_PROVIDERS.includes(p.id)),
|
||||
[codeTools.iFlowCli]: (providers) => providers.filter((p) => p.type.includes('openai')),
|
||||
[codeTools.githubCopilotCli]: () => []
|
||||
[codeTools.githubCopilotCli]: () => [],
|
||||
[codeTools.kimiCli]: (providers) => providers.filter((p) => p.type.includes('openai'))
|
||||
}
|
||||
|
||||
export const getCodeToolsApiBaseUrl = (model: Model, type: EndpointType) => {
|
||||
@ -190,6 +192,12 @@ export const generateToolEnvironment = ({
|
||||
case codeTools.githubCopilotCli:
|
||||
env.GITHUB_TOKEN = apiKey || ''
|
||||
break
|
||||
|
||||
case codeTools.kimiCli:
|
||||
env.KIMI_API_KEY = apiKey
|
||||
env.KIMI_BASE_URL = formattedBaseUrl
|
||||
env.KIMI_MODEL_NAME = model.id
|
||||
break
|
||||
}
|
||||
|
||||
return env
|
||||
|
||||
Loading…
Reference in New Issue
Block a user