Skip to content

feat: add Kimi Code CLI support#190

Open
classicrob wants to merge 1 commit into
banteg:masterfrom
classicrob:feat/kimi-cli-support
Open

feat: add Kimi Code CLI support#190
classicrob wants to merge 1 commit into
banteg:masterfrom
classicrob:feat/kimi-cli-support

Conversation

@classicrob

Copy link
Copy Markdown

Summary

  • Add support for Kimi CLI as a new engine backend
  • Kimi CLI is similar to Claude Code, providing AI-assisted coding in the terminal
  • Follows the same architecture patterns as existing runners (Claude, Codex, OpenCode, Pi)

Changes

New files:

  • src/takopi/schemas/kimi.py - msgspec models for Kimi's stream-json output format
  • src/takopi/runners/kimi.py - KimiRunner implementation with full event translation
  • tests/test_kimi_schema.py - Schema parsing tests (6 tests)
  • tests/test_kimi_runner.py - Runner and translation tests (14 tests)
  • tests/fixtures/kimi_stream_json_session.jsonl - Test fixture

Modified:

  • pyproject.toml - Added entry point for kimi backend

Configuration

default_engine = "kimi"

[kimi]
model = "kimi-k2"  # optional
extra_args = ["--thinking"]  # optional

Key Implementation Details

Feature Claude Code Kimi CLI
Resume flag --resume <id> --session <id>
Output format Structured with system.init, result events Role-based messages (assistant, tool, user)
Tool calls In message.content array In tool_calls array with JSON arguments

Test plan

  • All 20 new Kimi tests pass
  • Full test suite passes (560 tests)
  • Coverage maintained at 81.5%

🤖 Generated with Claude Code

Add support for Kimi CLI (https://github.com/MoonshotAI/kimi-cli) as a new
engine backend, similar to the existing Claude Code and Codex integrations.

New files:
- src/takopi/schemas/kimi.py: msgspec models for Kimi's stream-json output
- src/takopi/runners/kimi.py: KimiRunner implementation
- tests/test_kimi_schema.py: schema parsing tests
- tests/test_kimi_runner.py: runner and translation tests
- tests/fixtures/kimi_stream_json_session.jsonl: test fixture

Features:
- Session resumption via --session flag
- Model selection via config
- Extra CLI args support
- Tool call translation (Shell, Write, Read, etc.)

Configuration example:
```toml
default_engine = "kimi"

[kimi]
model = "kimi-k2"
extra_args = ["--thinking"]
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@classicrob

Copy link
Copy Markdown
Author

Hey also if there's any way I can contribute PRs more effectively, lmk. This felt like a fairly straightforward one, I just added Kimi cli support personally bc I love the model and wanted to explore its parallel subagent capabilities and thought other people might also want it.

@asianviking

Copy link
Copy Markdown
Contributor

@classicrob heya, I think you can create a transport plugin instead called takopi-kimi for example and then open a pr to add it to the plugins list on the docs

@banteg banteg added the enhancement New feature or request label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants