Repository navigation
fix(pipe): support Windows drive paths and tee recovery hints in grep filter - #5066
Conversation
📊 Automated PR Analysis
SummaryFixes grep pipe filter parsing to support Windows absolute drive paths (e.g. C:... or D:/...) without misparsing the drive-letter colon as a line-number delimiter, via a new parse_pipe_grep_line helper used in both grep_wrapper and auto_detect_filter. Also adds truncation recovery hints (tee tail / rtk recall) when matches exceed MAX_PIPE_MATCHES, mirroring existing behavior in search.rs. Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
pszymkowiak
left a comment
There was a problem hiding this comment.
Thanks @larancibia. Tested natively on Windows (merged onto develop): the 54 pipe_cmd tests pass, including the new ones.
With real Git for Windows grep -rn output on an absolute path (2 files, 16 matches), rtk pipe and rtk pipe --filter grep now group by file (16 matches in 2F:), where develop passed the whole output through unfiltered. The file with 15 matches shows 10 plus +5 [+5 hidden: rtk recall <id>], and rtk recall <id> returns exactly lines 11 to 15.
One small note for later, not blocking: src/cmds/README.md asks for the recall blob to match what was displayed, and here it stores the raw file:line:content form. That's arguably more useful for the agent, since each line keeps its path.
Problem
While running
rtk pipe --filter grep(andrtk pipeauto-detection) in coding-agent workflows, we hit two silent failure modes where an agent loses search results without realizing it:Windows absolute paths are silently dropped:
When
rgorgrepemits paths with a drive letter (e.g.C:\proj\src\main.rs:42:fn main()orD:/repo/lib.rs:7:let x = 1;),pipe_cmdsplits on the first:(C:), treats\proj\src\main.rsas the line number, fails numeric parsing, and drops the line. Auto-detection fails to recognize the stream, and in mixed output (Windows absolute + relative paths), all drive-prefixed matches disappear silently.Truncated matches (
> 10per file) cannot be recovered in pipe mode:Direct
rtk grepappends a recovery hint when capping past 10 matches per file (matchingCONTRIBUTING.md: "capping output at N items is only acceptable if accompanied by a hint that lets the agent recover the hidden data"). In contrast,rtk pipe --filter grepprinted a bare+240with nortk recall/teehint, leaving the agent with no way to inspect the omitted matches.Before / After
Before:
After:
Fix
parse_pipe_grep_lineinsrc/cmds/system/pipe_cmd.rsto skip an initial Windows drive prefix (X:\orX:/) before splitting:line_num:content, and use it in bothgrep_wrapperandauto_detect_filter(preserving Unix paths and colons inside matched code).crate::core::tee::force_tee_tail_hintingrep_wrapperwhen a file exceedsMAX_PIPE_MATCHES(CAP_WARNINGS= 10), falling back to bare+Nwhen recovery is disabled (RTK_RECALL=0).Test plan
cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo testrtk pipe --filter grepand auto-detect output inspected onC:\...,D:/..., Unix paths, and >10 match truncation (rtk recall,RTK_TEE_DIR, andRTK_RECALL=0)src/cmds/system/pipe_cmd.rs