Skip to content

feat(hook): extend Gemini BeforeTool hook to intercept read_file tool…#806

Open
Ross-cripto wants to merge 1 commit intortk-ai:masterfrom
Ross-cripto:feat/gemini-hook-read-file-intercept
Open

feat(hook): extend Gemini BeforeTool hook to intercept read_file tool…#806
Ross-cripto wants to merge 1 commit intortk-ai:masterfrom
Ross-cripto:feat/gemini-hook-read-file-intercept

Conversation

@Ross-cripto
Copy link

#796

  • Route read_file alongside run_shell_command in run_gemini()
  • Pre-apply start_line/end_line slice before filtering, then override both in the response to prevent Gemini's merge from re-applying original (now wrong) line numbers to the filtered file
  • Write filtered content to ~/.local/share/rtk/filtered/{ts}-{stem}.rtk (timestamp-first so lexicographic sort in rotation is chronological)
  • Rotate filtered dir to keep last 20 files, mirroring tee.rs pattern
  • Fallback to allow for unreadable/binary files, slices <500 chars, and slices with <10% savings

Closes #796

Summary

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

…tk-ai#796

- Route `read_file` alongside `run_shell_command` in `run_gemini()`
- Pre-apply `start_line`/`end_line` slice before filtering, then override both in the response to prevent Gemini's merge from re-applying original (now wrong) line numbers to the filtered file
- Write filtered content to `~/.local/share/rtk/filtered/{ts}-{stem}.rtk` (timestamp-first so lexicographic sort in rotation is chronological)
- Rotate filtered dir to keep last 20 files, mirroring tee.rs pattern
- Fallback to allow for unreadable/binary files, slices <500 chars, and slices with <10% savings

Closes rtk-ai#796
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini CLI --yolo to read files, it uses the read_file tool

2 participants