feat: add Kimi CLI (Moonshot AI) support#888
Open
he-yufeng wants to merge 5 commits intoslopus:mainfrom
Open
Conversation
…tracking Adds initial integration for Kimi CLI (github.com/MoonshotAI/kimi-cli, 7k+ stars) so users can authenticate and run Kimi through Happy. Changes: - `happy connect kimi` — stores Moonshot API key in Happy cloud via the same vendor-token flow used by Codex/Claude/Gemini. Prompts for MOONSHOT_API_KEY (sk-...) and registers it under the 'moonshot' vendor key. Also shows in `happy connect status`. - `happy kimi` command — registered in the CLI entry point, delegates to the generic ACP runner with kimi-specific defaults. Requires kimi-cli to be installed and in PATH. - authenticateKimi.ts — interactive API key prompt with basic format validation (sk- prefix check). - KimiAuthTokens type added to connect/types.ts. - BackendFlavor union extended with 'kimi' for session metadata. - Help text updated to list kimi alongside codex/gemini. Full native kimi integration (dedicated runKimi module with ink UI, conversation history, permission handling) is left for a follow-up once the kimi-cli ACP protocol details are finalized.
Addresses gaps found in gap analysis — kimi was only registered in the CLI entry point and connect command, but missing from several internal subsystems: - daemon/run.ts: add 'kimi' to agent type union, command switch, tmux agent resolution, and MOONSHOT_API_KEY token handling - agent/acp/runAcp.ts: return 'kimi' flavor instead of generic 'acp' so sessions are properly tagged - persistence.ts: add kimi to ProfileCompatibilitySchema and validateProfileForAgent so profiles can enable/disable kimi - api/api.ts: add 'moonshot' to registerVendorToken/getVendorToken type signatures - index.ts: fetch Moonshot API key from Happy cloud on startup (mirrors how Gemini fetches its OAuth token)
Fills in the remaining integration gaps so kimi is a proper first-class provider rather than a thin ACP wrapper: CLI package: - kimi/constants.ts: MOONSHOT_API_KEY_ENV, KIMI_MODEL_ENV, defaults - kimi/types.ts: KimiMode interface (permission + model) - ui/ink/KimiDisplay.tsx: terminal UI component (based on Codex display pattern — message buffer, Ctrl-C double-tap exit, model label) - connect.ts: save API key to ~/.kimi/config.json on `happy connect kimi` (mirrors Gemini's local credential sync) Mobile app: - modelModeOptions.ts: add getKimiPermissionModes (default + yolo), getKimiModelModes (kimi-latest fallback), wire into getHardcodedPermissionModes / getHardcodedModelModes / getAvailablePermissionModes / getDefaultModelKey
Replace made-up 'kimi-latest' with actual model IDs from platform.moonshot.ai: kimi-k2.5 (default), kimi-k2-thinking, and kimi-k2-thinking-turbo.
- kimi-cli uses 'kimi acp' subcommand, not --experimental-acp (that's Gemini) - Fix comment: config.json is Happy's credential cache, not read by kimi-cli
|
Why not use kimi through opencode? |
Author
|
Good question! kimi-cli is Moonshot AI's first-party CLI agent (like Claude Code is to Anthropic, or Gemini CLI is to Google). It has features specific to the Kimi ecosystem — 256K native context, Kimi-specific tool integrations, and the ACP protocol. OpenCode is a great tool, but it's a third-party agent that connects to Kimi's API as one of many providers. Happy already has dedicated support for Claude Code, Codex, and Gemini CLI (all first-party tools), so adding kimi-cli follows the same pattern: native integration for each vendor's own agent. Users who already use kimi-cli in their workflow would want to manage it from Happy, the same way Claude Code users do today. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Kimi CLI (7k+ stars) from Moonshot AI as a first-class provider alongside Claude, Codex, and Gemini. This PR wires kimi through every layer of the system — authentication, daemon spawning, session tracking, mobile app modes, and terminal UI.
Changes by layer
CLI Authentication (
commands/connect/)happy connect kimi— interactive API key prompt withsk-prefix validationregisterVendorToken('moonshot', ...)~/.kimi/config.json(mirrors Gemini's local credential sync)happy connect statusauthenticateKimi.ts+KimiAuthTokenstypeCLI Entry Point (
index.ts)happy kimisubcommand → delegates to ACP runner with kimi-specific defaultsDaemon (
daemon/run.ts)'kimi'MOONSHOT_API_KEYtoken passthrough for daemon-spawned sessionsSession & Profile System
BackendFlavorunion includes'kimi'(createSessionMetadata.ts)resolveSessionFlavor()returns'kimi'instead of generic'acp'(runAcp.ts)validateProfileForAgentsupport kimi (persistence.ts)'moonshot'(api.ts)Kimi Module Skeleton (
kimi/)constants.ts—MOONSHOT_API_KEY_ENV,KIMI_MODEL_ENV,DEFAULT_KIMI_MODELtypes.ts—KimiModeinterface (permission mode + model)Terminal UI (
ui/ink/KimiDisplay.tsx)Mobile App (
happy-app/)getKimiPermissionModes()— default + yologetKimiModelModes()— kimi-latest fallbackgetHardcodedPermissionModes,getHardcodedModelModes,getAvailablePermissionModes,getDefaultModelKeyWhat's NOT in this PR
Full native agent integration (
runKimi.tswith conversation history, reasoning processor, diff tracking) requires kimi-cli to support the ACP protocol (--experimental-acp). This PR establishes the complete framework that the native module will plug into.Files changed (15 files, +428 lines)
commands/connect.tscommands/connect/authenticateKimi.tscommands/connect/types.tsKimiAuthTokensindex.tshappy kimi+ cloud token fetchdaemon/run.tsagent/acp/runAcp.tsapi/api.tspersistence.tsutils/createSessionMetadata.tskimi/constants.tskimi/types.tsui/ink/KimiDisplay.tsxcomponents/modelModeOptions.tsTest plan
happy connect kimi→ prompts for API key, stores in cloud + localhappy connect status→ shows Moonshot Kimi connection statushappy kimi→ attempts to launch kimi CLI via ACPhappy --help→ lists kimi in available commands