enhancement: grep filter truncation may cause AI agents to miss search results
#1161 aperta il 10 apr 2026
Metriche repository
- Star
- (48.085 star)
- Metriche merge PR
- (Merge medio 11g 1h) (45 PR mergiate in 30 g)
Descrizione
Problem
`rtk grep` applies multiple aggressive filters that can cause AI agents to miss relevant search results:
- Max results: Hard-coded limit of 200 results (src/main.rs line 286: default_value = "200")
- Max line length: Lines truncated to 80 characters (line 283: default_value = "80")
- Context stripping: context_only mode strips surrounding context
- Grouping: Results grouped by file, which may hide the specific match context
Impact on AI agents
When an agent searches for a specific pattern (e.g., an error message, a function call, a config value), the 80-character line truncation may cut off the relevant part of the match. The 200-result limit may exclude the file the agent is looking for if there are many matches.
Proposed fix
-
Increase defaults for AI agent contexts: When the hook is active (detected via environment or config), use higher limits:
- max_len: 200 (instead of 80)
- max: 500 (instead of 200)
-
Add a --full flag: Show unfiltered grep output for when agents need complete results
-
Smart truncation: Instead of fixed 80 chars, truncate at the match boundary (keep the full match plus 20 chars of context on each side)
Relevant code
- src/main.rs lines 276-300: Grep command definition with default values
- src/cmds/system/grep_cmd.rs: grep filtering implementation