Skip to content

feat(hook): add support for Kimi AI agent - #1478

Merged
pszymkowiak merged 7 commits into
rtk-ai:developfrom
williamkoller:feat/hook-kimi-ai-dev
Jul 18, 2026
Merged

pszymkowiak merged 7 commits into
rtk-ai:developfrom
williamkoller:feat/hook-kimi-ai-dev

Conversation

@williamkoller

Copy link
Copy Markdown
Contributor

Summary

  • Adds Kimi AI to the list of supported agents (AgentTarget::Kimi).
  • Implements rtk init --agent kimi which creates a project-scoped .kimirules configuration file containing the RTK usage rules.
  • Adds tests to ensure the Kimi initialization logic is idempotent and functioning correctly.
  • Updates the README.md to advertise the new agent integration.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: Ran the hook initialization to ensure .kimirules is generated correctly.

@CLAassistant

CLAassistant commented Apr 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-small Quelques heures, 1 fichier enhancement New feature or request labels Apr 23, 2026
@pszymkowiak

Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

✨ Type feature
🟢 Risk low

Summary

Adds Kimi AI as a new supported agent target, implementing rtk init --agent kimi which generates a project-scoped .kimirules configuration file with RTK usage rules. Includes idempotency tests and README updates documenting the new integration.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

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

@williamkoller williamkoller mentioned this pull request Apr 24, 2026
@shwoop

shwoop commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

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?

@williamkoller
williamkoller requested a review from Ri087 June 30, 2026 15:00
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 pszymkowiak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pszymkowiak
pszymkowiak merged commit 7624c43 into rtk-ai:develop Jul 18, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
shwoop added a commit to shwoop/rtk that referenced this pull request Sep 28, 2026
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.
shwoop added a commit to shwoop/rtk that referenced this pull request Sep 28, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-small Quelques heures, 1 fichier enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants