You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ux(grep): -c/-l/-L/-o/-Z format flags error-then-fallback; should silently passthrough #13
518 parse_failures recorded over recent usage, dominated by grep -c / grep -ci / grep -cE invocations. CONTEXTCRAWLER.md documents that grep format flags -c, -l, -L, -o, -Z should run raw — but the CLI currently rejects them with a clap error, then succeeds via the fallback_succeeded=1 path.
Reproduction
grep -c ^fix /tmp/up_subjects.txt
Result: error message logged to stderr, retry via fallback, correct output eventually.
Database evidence:
sqlite3 ~/Library/Application\ Support/rtk/history.db \
"SELECT COUNT(*) FROM parse_failures WHERE raw_command LIKE 'grep -%'; "
Hundreds of these accumulated.
Root cause
src/cmds/system/grep.rs (or equivalent) uses clap's strict arg parsing. The documented-raw format flags hit clap before any routing logic.
Fix (proposed)
In the grep subcommand entry, pre-scan args for any of -c, -l, -L, -o, -Z (and their long forms --count, --files-with-matches, --files-without-match, --only-matching, --null). If present, route directly to proxy grep <args> without invoking clap. No error, no parse_failure log entry.
Side benefit
Each parse-failure path costs ~50 tokens of error text per call. 518 failures × ~50 = ~26K wasted tokens on this single pattern.
Test plan
Unit test: grep -c pattern file routes to passthrough silently (no error written, no parse_failure recorded)
Each long-form variant tested similarly
Verify combined short flags (-ci, -cE) handled
Verify normal grep -rn pattern dir still uses the filtered path
Activity
ux(grep): pre-clap intercept routes documented format flags to passth…