Skip to content

feat(init): add support for kilocode and antigravity agents#802

Merged
aeppling merged 1 commit intortk-ai:developfrom
Yosoyepa:feat/add-new-agents
Apr 9, 2026
Merged

feat(init): add support for kilocode and antigravity agents#802
aeppling merged 1 commit intortk-ai:developfrom
Yosoyepa:feat/add-new-agents

Conversation

@Yosoyepa
Copy link
Copy Markdown
Contributor

Add support for generating rules for Kilo Code and Google Antigravity via rtk init.

Summary

  • Added CLI Flags: Extended AgentTarget to support --agent kilocode and --agent antigravity.
  • Injected Agent Rules: Created specific markdown instruction files matching the original token-loss guidelines for both assistants (.kilocode/rules/rtk-rules.md and .agent/rules/antigravity-rtk-rules.md).
  • Maintained Code Style: Kept the new init::run console outputs consistent and free of emojis to strictly follow the project's formatting conventions.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected (Successfully tested rtk gain, rtk git status locally to ensure the new settings inject and reduce token usage without issues).

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-small Quelques heures, 1 fichier enhancement New feature or request labels Mar 25, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟢 Risk low

Summary

Adds support for two new agent targets (Kilo Code and Google Antigravity) to the rtk init command. This includes new CLI flags, markdown rule files for each agent, and corresponding init mode functions that write rules to agent-specific directories.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

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

@aeppling
Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch from f16400e to f3f4993 Compare March 27, 2026 04:46
@Yosoyepa
Copy link
Copy Markdown
Contributor Author

Hi @aeppling, thanks for the heads up!

I've successfully fetched the latest develop branch, rebased my branch, and resolved all conflicts to align with the new src/hooks/ subfolder structure. The rebase has been force-pushed and the new structure is perfectly integrated!

Let me know if everything looks good on your end or if there's anything else needed. Thanks!

Comment thread README.md Outdated
@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch from f3f4993 to f72f7c5 Compare April 1, 2026 00:22
@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 3, 2026

Hello, currently focusing on some priority fix, we will come back to this asap for implementation

Just a quick insight but from docs https://antigravity.google/docs/rules-workflows the path for antigravity rules is .agents/ not agent/

@aeppling aeppling self-assigned this Apr 3, 2026
@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch from f72f7c5 to be70468 Compare April 6, 2026 05:43
@Yosoyepa
Copy link
Copy Markdown
Contributor Author

Yosoyepa commented Apr 6, 2026

Hey @aeppling, thanks for the insight on the .agents/ path , That's already fixed in this latest push (.agent/ → .agents/ to match the official docs). Also rebased on latest develop and verified locally: cargo fmt, cargo clippy --all-targets, and cargo test --all (1350 passed) all green.

@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 8, 2026

Hey @Yosoyepa , here is the full review to be addressed before going further, this is mostly for conformity with others integrations.

Code Review Issues

1. Routing pattern mismatch

Issue: Routing goes through run() boolean flags instead of early return before run() like Gemini/Copilot
Location: src/main.rs:1634,1651 and src/hooks/init.rs:275-283

Gemini and Copilot are routed before the run() call in main.rs via early if/else if branches. They never touch run()'s parameter list. Kilo Code and Antigravity are simple rules-file integrations (same tier as Cline/Windsurf), but the PR threads them as two new booleans through run(), growing an already-too-long signature from 11 to 13 positional parameters. They should follow the Gemini/Copilot pattern instead.


2. Missing verbose: u8 parameter

Issue: run_kilocode_mode() and run_antigravity_mode() missing verbose: u8 parameter
Location: src/hooks/init.rs:1261,1274


3. Missing .context() on fallible operations

Issue: create_dir_all and write use bare ? without .context()
Location: src/hooks/init.rs:1262-1265,1275-1278

RTK uses .context("description")? on fallible operations.

PR code:

std::fs::create_dir_all(&target_dir)?; // no .context()
std::fs::write(&rules_path, KILOCODE_RULES)?; // no .context()

Every existing integration uses .context():

fs::write(&rules_path, &new_content).context("Failed to write .clinerules")?; // existing

4. Missing idempotency check

Issue: No idempotency check (no existing.contains("RTK") guard before writing)
Location: src/hooks/init.rs:1261-1270,1274-1283

Every existing rules-based integration checks if RTK is already installed. PR code just overwrites blindly:

std::fs::write(&rules_path, KILOCODE_RULES)?; // always overwrites

This means running rtk init --agent kilocode twice will silently overwrite any user customizations to the rules file.

5. Missing append-to-existing pattern

Issue: No append-to-existing logic (overwrites entire file instead of appending below existing content)
Location: src/hooks/init.rs:1265,1278

If .kilocode/rules/rtk-rules.md or .agents/rules/antigravity-rtk-rules.md already has non-RTK content, the existing integrations append rather than overwrite:

let new_content = if existing.trim().is_empty() {
    CLINE_RULES.to_string()
} else {
    format!("{}\n\n{}", existing.trim(), CLINE_RULES)
};

This PR is missing this logic.

6. Missing --global flag guard

Issue: No --global flag guard (project-scoped agents should reject -g with anyhow::bail!)
Location: src/hooks/init.rs:275-283 (missing validation block)

7. No tests for new modes

Issue: No tests for new modes (only false, false inserted into existing test signatures)
Location: src/hooks/init.rs:2686-2687,2710-2711

8. README entries lack detail

Issue: README entries lack detail compared to other agents (no mechanism description, no reload instructions)
Location: README.md:410-425

@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 8, 2026

Also waiting for #1029 to be merge, so we can add the user documentation for the new integration :)

@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 8, 2026

Hey, #1029 merged, could you also add those new integration to supported-agent.md in docs/guide/ please ? (also need resolve conflict with develop)

@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch from be70468 to cd36f1a Compare April 8, 2026 19:15
@Yosoyepa
Copy link
Copy Markdown
Contributor Author

Yosoyepa commented Apr 8, 2026

Hey @aeppling, done! Rebased on latest develop, resolved the README conflict, and added both Kilo Code and Antigravity to docs/guide/getting-started/supported-agents.md as requested. Let me know if there's anything else you'd like me to adjust. :D

@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch 2 times, most recently from d7f8280 to 19d336f Compare April 8, 2026 19:48
@Yosoyepa
Copy link
Copy Markdown
Contributor Author

Yosoyepa commented Apr 8, 2026

Also, just got through the full code review you left — thanks for the thoroughness! I've gone ahead and addressed all 8 points in this latest push:

  1. Routing pattern: Moved Kilo Code and Antigravity out of the run() signature. They are now routed via early else if returns directly in main.rs, matching the Gemini/Copilot pattern.
  2. Missing verbose: u8: Added the parameter to both run_kilocode_mode and run_antigravity_mode.
  3. Missing .context(): Added properly to all fs::create_dir_all and fs::write operations gracefully.
  4. Missing idempotency check: Added the existing.contains("RTK") || existing.contains("rtk") guard to prevent repetitive writes (matching Cline/Windsurf).
  5. Missing append-to-existing: Proper append logic implemented via format!("{}\n\n{}", existing.trim(), RULES).
  6. Missing --global flag guard: Added anyhow::bail! in the main routing when -g is used improperly, mirroring the project's exact style (e.g., "Kilo Code is project-scoped. Use: rtk init --agent kilocode").
  7. No tests for new modes: Added 4 new tests covering creation and idempotency for both agents (test_kilocode_mode_creates_rules_file, etc.).
  8. README lacks detail: As mentioned above, matched the simplified table formatting in README.md and added the full detailed installation commands into docs/guide/getting-started/supported-agents.md instead.

All local checks (cargo fmt, clippy, and 1362 tests) are still completely green. Thanks again for the pointers, let me know if everything looks good now!


@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch 2 times, most recently from 7a2495d to b036ffa Compare April 8, 2026 20:08
@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 8, 2026

https://github.com/rtk-ai/rtk/actions/runs/24155946709

failures from ci tests: (MACOS test)

---- hooks::init::tests::test_antigravity_mode_creates_rules_file stdout ----

thread 'hooks::init::tests::test_antigravity_mode_creates_rules_file' (17539) panicked at src/hooks/init.rs:2776:33:
called Result::unwrap() on an Err value: Failed to create .agents/rules directory

Caused by:
No such file or directory (os error 2)
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

---- hooks::init::tests::test_kilocode_mode_creates_rules_file stdout ----

RTK configured for Kilo Code.

Rules: .kilocode/rules/rtk-rules.md (installed)
Kilo Code will now use rtk commands for token savings.
Test with: git status

thread 'hooks::init::tests::test_kilocode_mode_creates_rules_file' (17566) panicked at src/hooks/init.rs:2752:9:
Rules file should be created

failures:
hooks::init::tests::test_antigravity_mode_creates_rules_file
hooks::init::tests::test_kilocode_mode_creates_rules_file

test result: FAILED. 1360 passed; 2 failed; 6 ignored; 0 measured; 0 filtered out; finished in 0.52s

error: test failed, to rerun pass --bin rtk
Error: Process completed with exit code 101.

@Yosoyepa
Copy link
Copy Markdown
Contributor Author

Yosoyepa commented Apr 8, 2026

Thanks for flagging that, @aeppling! That macOS failure was caused by the tests using std::env::set_current_dir() which mutates the process-wide working directory — a problem when cargo test runs tests in parallel threads. On macOS specifically, TempDir creates under /var/folders/ (a symlink to /private/var/), which made the race condition more likely to surface there.

Already fixed in the latest push (b036ffa). I extracted private _at(base_dir) helpers so the tests can pass an explicit TempDir path instead of mutating global state. The public API (run_kilocode_mode / run_antigravity_mode) is unchanged — they still resolve from current_dir() at runtime, same as Cline and Windsurf.

I noticed Cline and Windsurf don't currently have unit tests, so there wasn't an existing pattern to follow here. Does this _at() approach look reasonable to you, or would you prefer a different strategy for testing these modes?

Add rtk init --agent kilocode and rtk init --agent antigravity commands.

Kilo Code: installs .kilocode/rules/rtk-rules.md (project-scoped)
Google Antigravity: installs .agents/rules/antigravity-rtk-rules.md (project-scoped)

Both follow the same prompt-level guidance pattern as Cline and Windsurf,
using rules files that instruct the agent to prefix shell commands with rtk.
@Yosoyepa Yosoyepa force-pushed the feat/add-new-agents branch from b036ffa to d0a3797 Compare April 8, 2026 20:37
@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 9, 2026

Hey,

Indeed those does not currently have unit test, my bad, i'm ok with this approach, we'll need to update others
This is good for me we can merge this for next release

Thanks for contributing @Yosoyepa

@aeppling aeppling merged commit 66b90f1 into rtk-ai:develop Apr 9, 2026
10 checks passed
@Yosoyepa
Copy link
Copy Markdown
Contributor Author

Yosoyepa commented Apr 9, 2026

Awesome, thanks for the merge and for the detailed review! I really appreciate the time you took to guide me and help align the code with the project's standards. It was a fantastic first contribution experience for me.
Saludos desde Colombia! 🇨🇴 :)

@AntarusDragon
Copy link
Copy Markdown

Hi guys, is it worth waiting for Antigravity support to be added in new RTK versions so that everything works without errors?

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.

7 participants