Repository navigation
feat(hook): add support for Kimi AI agent - #1478
Conversation
📊 Automated PR Analysis
SummaryAdds Kimi AI as a new supported agent target, implementing Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Hi @williamkoller, can you point to the kimi-cli documentation about .kimirules? I don't think it follows such a convention. I was looking at implementing support via a hook but it seems kimi's preToolUse hooks only act as gates and do not allow rewrites (as we need for rtk). I think the old claude support referenced an RTK.md file in CLAUDE.md so we could investigate adding that to AGENTS.md for kimi-cli? |
kimi-cli has no .kimirules convention — that file is never read. It loads project instructions from AGENTS.md (same as Codex). Rewrite run_kimi_mode to inject the RTK instructions block into AGENTS.md via write_rtk_block, and thread InitContext through to match the other agent modes. - run_kimi_mode/run_kimi_mode_at now take InitContext (was verbose: u8) - remove dead .kimirules write path - drop duplicate run_codex_mode left by an earlier merge conflict - main.rs: call run_kimi_mode(ctx); remove spurious run_antigravity_mode - delete embedded hooks/kimi/rules.md (no longer used) - tests assert AGENTS.md is written and .kimirules is never created
pszymkowiak
left a comment
There was a problem hiding this comment.
Reviewed and verified locally: built the branch (cargo build), ran the Kimi unit tests (test_kimi_mode_writes_agents_md, test_kimi_mode_is_idempotent — both pass), and exercised rtk init --agent kimi end-to-end. It correctly writes the RTK block into project AGENTS.md, does not create .kimirules (unsupported by Kimi), and the global-scope guard rejects -g as expected.
The AGENTS.md approach is the right call — Kimi's PreToolUse hooks are gate-only and can't rewrite commands, so reusing the Codex-style instructions block is correct and keeps the diff minimal.
Follow-up (non-blocking): a dedicated uninstall_kimi for parity with Codex — tracking separately. LGTM.
Adds the missing half of Kimi CLI integration that rtk-ai#1478 did not cover: - rtk hook kimi: PreToolUse handler emitting permissionDecision=deny with a suggestion to retry using the rtk-prefixed form when an unprefixed shell command would be rewritten by the engine - HookCommands::Kimi variant and dispatch in main.rs - hooks/kimi/README.md documenting the deny-only protocol The init-side awareness (AGENTS.md + config.toml patch) was already merged in rtk-ai#1478. This completes the picture by adding the PreToolUse hook that enforces the rtk prefix at runtime. 9 unit tests for the hook handler: deny with suggestion, already-rtk passthrough, unknown command passthrough, non-shell tool passthrough, Bash alias, invalid JSON, empty input, missing command, heredoc bypass.
…y content rules.md was a file for ~/.kimi/rtk-rules.md, which is no longer needed now that rtk-ai#1478's AGENTS.md awareness replaces it. The README is trimmed to reference AGENTS.md awareness instead of the old rules file.
Summary
AgentTarget::Kimi).rtk init --agent kimiwhich creates a project-scoped.kimirulesconfiguration file containing the RTK usage rules.README.mdto advertise the new agent integration.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test.kimirulesis generated correctly.