feat: add Gemini CLI support via rtk init --gemini#174
feat: add Gemini CLI support via rtk init --gemini#174ousamabenyounes wants to merge 9 commits intortk-ai:masterfrom
Conversation
Introduce first-class support for Gemini CLI by adding a dedicated initialization mode. This allows Gemini users to benefit from RTK's token optimization with the same ease as Claude Code users. - Add --gemini flag to 'rtk init' command - Implement run_gemini_mode() in src/init.rs for global setup - Automated installation of the rewrite hook in ~/.gemini/hooks/ - Intelligent GEMINI.md patching using upsert_rtk_block (preserves user content) - Support for ~/.gemini/RTK.md slim instructions - Update 'rtk init --show' to display Gemini configuration status - Update 'rtk init -g --uninstall' to clean up Gemini artifacts - Add comprehensive automated test: scripts/test-gemini-init.sh - Update INSTALL.md and README.md with Gemini setup instructions Collaboration: - Vision & Prompt Architecture: Ousama Ben Younes - Technical Implementation: Gemini AI (Google) Co-authored-by: Gemini AI <assistant@google.com>
Introduce first-class support for Gemini CLI by adding a dedicated initialization mode. This allows Gemini users to benefit from RTK's token optimization with the same ease as Claude Code users. - Add --gemini flag to 'rtk init' command - Implement run_gemini_mode() in src/init.rs for global setup - Automated installation of the rewrite hook in ~/.gemini/hooks/ - Intelligent GEMINI.md patching using upsert_rtk_block (preserves user content) - Support for ~/.gemini/RTK.md slim instructions - Update 'rtk init --show' to display Gemini configuration status - Update 'rtk init -g --uninstall' to clean up Gemini artifacts - Add comprehensive automated test: scripts/test-gemini-init.sh - Update INSTALL.md and README.md with Gemini setup instructions Collaboration: - Vision & Prompt Architecture: Ousama Ben Younes - Technical Implementation: Gemini AI (Google) Co-authored-by: Gemini AI <assistant@google.com>
…ed functions - Convert all French comments in REWRITE_GEMINI_HOOK constant to English - Translate doc comments and inline comments in patch_gemini_settings_json - Maintain exact same functionality, only language changes
- Update ARCHITECTURE.md module count (30 → 48 modules) - Update rtk version references (0.18.1 → 0.20.1) in CLAUDE.md - Set last updated date to 2026-02-17 in ARCHITECTURE.md
- Fix grep pattern for cargo test output (add 'passed' detection) - Replace skip with skip_test for pytest, ruff, pip, go, golangci-lint - Skip learn test when Claude Code not installed - Result: 0 failures, 87 passed, 6 skipped
| # 2. Initialize for Claude Code (RECOMMENDED: hook-first mode) | ||
| rtk init --global | ||
| # 2. Initialize (RECOMMENDED: hook-first mode) | ||
| rtk init --global # For Claude Code |
There was a problem hiding this comment.
To keep it understandable/simple in six months, I will have taken this approach:
rtk init --claudertk init --geminirtk init --global-> auto CLIs detection (search for ~/.gemini and ~/.claude)
(By the way, Hey Ousama, I hope you are doing well 😄)
There was a problem hiding this comment.
There is a PR in progress similar to this one.
#158
There was a problem hiding this comment.
Hey! I’m doing great, hope you are too 🙂
I’m aligned with your approach and implementing it in a lightweight way.
There was #131, but it was considered too large and needed splitting.
So I decided to move forward with a lighter, more focused version instead.
I’ve also applied the requested fixes:
feat: auto-detect CLIs with rtk init --global, add --claude flag
I’m against duplicate work… just like I’m against copy-paste code 😄
Happy to align if #158 already covers it.
10d9c97 to
2c5a157
Compare
- Updated README.md, CLAUDE.md, and ARCHITECTURE.md to reference version 0.21.1 - Updated ARCHITECTURE.md module count to match actual module count (48)
6b2e23b to
c22f6d0
Compare
|
hey just a heads up I've had one version of gemini support available for a bit here: #158 |
Summary
Introduce first-class support for Gemini CLI by adding a dedicated initialization mode that provides token optimization with the same ease-of-use as Claude Code integration.
Key Features
Core Implementation
rtk init --global --geminifor one-command setup~/.gemini/settings.jsonrtk init -g --uninstallremoves all Gemini artifacts cleanlyHook Mechanism
run_shell_commandtool calls before executionUser Experience
GEMINI.mdupdates preserve user content (viaupsert_rtk_block)rtk init --showdisplays Gemini configuration state~/.gemini/RTK.mdprovides concise command documentationgemini /hooksconfirms hook registrationTechnical Details
Files Changed
Architecture Decisions
Separate hook implementation (
REWRITE_GEMINI_HOOK):BeforeToolmatcher)settings.jsonregistration (vs. auto-discovery)Reused core logic:
upsert_rtk_block(): Consistent update mechanism across AI toolsensure_hook_installed(): Parameterized for hook content injectionuninstall(): Extended to handle both Claude and Gemini artifactsRobust error handling:
Testing Strategy
Comprehensive test coverage via
scripts/test-gemini-init.sh:settings.jsonstructure and hook presenceAll tests use isolated
$HOMEto avoid pollution.Usage Example
Documentation Updates
Compatibility
jqfor JSON parsing in hook scriptMigration Path
Existing Gemini users can adopt RTK with zero config changes:
Checklist
cargo test)scripts/test-gemini-init.sh)Author: Ousama Ben Younes ([@ousamabenyounes](https://github.com/ousamabenyounes))
Implementation Notes:
This PR was developed using AI-assisted coding with Gemini AI. The architecture, testing strategy, and integration design were manually crafted; code generation was AI-assisted and manually reviewed.