Skip to content

feat(hook): add Kimi Code CLI integration#1391

Open
zoorpha wants to merge 1 commit intortk-ai:developfrom
zoorpha:feat/hook-add-kimi-code-cli-integration
Open

feat(hook): add Kimi Code CLI integration#1391
zoorpha wants to merge 1 commit intortk-ai:developfrom
zoorpha:feat/hook-add-kimi-code-cli-integration

Conversation

@zoorpha
Copy link
Copy Markdown

@zoorpha zoorpha commented Apr 18, 2026

Summary

This PR adds full Kimi Code CLI integration to RTK, enabling transparent command rewriting via Kimi's PreToolUse hook system (Beta).

What's included

  • rtk hook kimi — Native Rust hook processor that reads Kimi's PreToolUse JSON from stdin and outputs structured rewrite responses
  • rtk init -g --kimi — Installs the hook by patching ~/.kimi/config.toml with a TOML-safe [[hooks]] entry
  • rtk init -g --kimi --uninstall — Removes KIMI.md and the hook entry from config.toml
  • rtk init --show --kimi — Displays Kimi-specific configuration status

Hook mechanism

Kimi's hook system receives JSON via stdin:

{"tool_name":"Shell","tool_input":{"command":"git status"}}

And supports structured output to modify commands:

{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk git status"}}}

Technical details

  • Reuses the existing process_claude_payload function since Kimi's JSON format is compatible with Claude Code's hookSpecificOutput.updatedInput structure
  • TOML patching uses the toml crate (already a dependency) to preserve existing user configuration
  • Idempotent: running rtk init -g --kimi multiple times won't duplicate the hook
  • Follows RTK's "Never Block" principle — all error paths exit 0 so Kimi always runs the original command on failure

Tests

  • 5 new unit tests in src/hooks/hook_cmd.rs for the Kimi hook processor
  • 5 new unit tests in src/hooks/init.rs for config patching, idempotency, and uninstall
  • All 1600 tests pass

Documentation

  • README.md — Added Kimi to supported AI tools table
  • INSTALL.md — Added Kimi installation, uninstall, and checklist instructions
  • hooks/README.md — Added Kimi JSON format and agent listing
  • hooks/kimi/README.md — New dedicated Kimi hook documentation

Checklist

  • Unit tests added/updated
  • Documentation updated
  • cargo fmt --all --check passes
  • cargo clippy --all-targets passes (no new warnings)
  • cargo test passes (1600 tests)
  • Manual test: rtk hook kimi rewrites commands correctly
  • Manual test: rtk init -g --kimi --auto-patch patches config.toml correctly

Add full PreToolUse hook support for Kimi Code CLI:
- rtk hook kimi: native Rust hook processor (reuses Claude payload format)
- rtk init -g --kimi: patches ~/.kimi/config.toml with TOML-safe hook entry
- rtk init -g --kimi --uninstall: removes KIMI.md and config.toml hook entry
- rtk init --show --kimi: displays Kimi-specific configuration status
- TOML patching preserves existing hooks and settings
- 10 unit tests covering hook processor and init flow

Updates documentation:
- README.md: Kimi in supported agents table
- INSTALL.md: Kimi installation/uninstall instructions
- hooks/README.md: Kimi JSON format and agent listing
- hooks/kimi/README.md: dedicated Kimi hook documentation
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pszymkowiak pszymkowiak added effort-medium 1-2 jours, quelques fichiers enhancement New feature or request labels Apr 18, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟢 Risk low

Summary

Adds Kimi Code CLI integration to RTK, including a native Rust hook processor (rtk hook kimi), config.toml patching via rtk init -g --kimi, uninstall support, and dedicated documentation. The implementation reuses the existing Claude Code hook processor since Kimi's PreToolUse JSON format is compatible.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-medium 1-2 jours, quelques fichiers enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants