feat(hook): add Kimi Code CLI integration#1391
Open
zoorpha wants to merge 1 commit intortk-ai:developfrom
Open
feat(hook): add Kimi Code CLI integration#1391zoorpha wants to merge 1 commit intortk-ai:developfrom
zoorpha wants to merge 1 commit intortk-ai:developfrom
Conversation
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
|
|
Collaborator
📊 Automated PR Analysis
SummaryAdds Kimi Code CLI integration to RTK, including a native Rust hook processor ( Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
5 tasks
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
This PR adds full Kimi Code CLI integration to RTK, enabling transparent command rewriting via Kimi's
PreToolUsehook system (Beta).What's included
rtk hook kimi— Native Rust hook processor that reads Kimi's PreToolUse JSON from stdin and outputs structured rewrite responsesrtk init -g --kimi— Installs the hook by patching~/.kimi/config.tomlwith a TOML-safe[[hooks]]entryrtk init -g --kimi --uninstall— Removes KIMI.md and the hook entry from config.tomlrtk init --show --kimi— Displays Kimi-specific configuration statusHook 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
process_claude_payloadfunction since Kimi's JSON format is compatible with Claude Code'shookSpecificOutput.updatedInputstructuretomlcrate (already a dependency) to preserve existing user configurationrtk init -g --kimimultiple times won't duplicate the hookTests
src/hooks/hook_cmd.rsfor the Kimi hook processorsrc/hooks/init.rsfor config patching, idempotency, and uninstallDocumentation
README.md— Added Kimi to supported AI tools tableINSTALL.md— Added Kimi installation, uninstall, and checklist instructionshooks/README.md— Added Kimi JSON format and agent listinghooks/kimi/README.md— New dedicated Kimi hook documentationChecklist
cargo fmt --all --checkpassescargo clippy --all-targetspasses (no new warnings)cargo testpasses (1600 tests)rtk hook kimirewrites commands correctlyrtk init -g --kimi --auto-patchpatches config.toml correctly