Repository navigation
fix(grep): translate BRE \| alternation and strip -r flag for rg - #206
Merged
pszymkowiak merged 1 commit intoFeb 18, 2026
Merged
pszymkowiak merged 1 commit into
pszymkowiak merged 1 commit into
Conversation
Two bugs when passing grep-idiom arguments to rtk grep: 1. Pattern alternation `\|` (BRE syntax) returns 0 results because rg uses PCRE-style `|`, not BRE `\|`. Users coming from grep/awk muscle memory naturally write `rtk grep "fn foo\|fn bar" src/` and get empty output with no error. Fix: translate `\|` → `|` in pattern before passing to rg. 2. `-r`/`--recursive` flag (grep idiom) silently breaks the search. In rg, `-r` means `--replace` and requires an argument — passing it alone causes rg to exit with an error. The `.or_else(|_| ...)` fallback only catches IO errors (command not found), so the grep fallback never triggers; stdout is empty and rtk reports "0 for '<pattern>'". Fix: filter out `-r`/`--recursive` from extra_args before building the rg command (rg is recursive by default, flag is a no-op). Adds two regression tests documenting both behaviours. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
Thank you! Good catch on both issues — silent 0 results is a real pain for users coming from grep. |
heAdz0r
added a commit
to heAdz0r/rtk
that referenced
this pull request
Feb 28, 2026
Upstream 0.22.2 sync (all previously missing fixes verified applied): - fix(lint): propagate linter exit code (rtk-ai#207) — CI false-green fix - feat: add rtk wc command for compact word/line/byte counts (rtk-ai#175) - fix(playwright): JSON parser (specs layer) + binary resolution (rtk-ai#215) - fix(grep): propagate rg exit codes 1/2 (rtk-ai#227) - fix(git): branch creation not swallowed by list mode (rtk-ai#194) - fix(git): support multiple -m flags in git commit (rtk-ai#202) - fix(grep): BRE \| translation + strip -r flag (rtk-ai#206) - fix(gh): smart markdown body filter for issue/pr view (rtk-ai#214) - fix(gh): gh run view --log-failed flag passthrough (rtk-ai#159) - feat(docker): docker compose support (rtk-ai#110) - feat: hook audit mode (rtk-ai#151) - feat: tee raw output to file (rtk-ai#134) Version bump: 0.21.1-fork.19 → 0.22.2-fork.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
maxkulish
added a commit
to maxkulish/rtk
that referenced
this pull request
Mar 18, 2026
Implements 6 bug fixes from upstream rtk-ai/rtk (v0.29.0): P1.3a - playwright: JSON parser already matches real output format (rtk-ai#193) - Already uses proper suites → specs → tests → results structure - Handles float duration correctly (f64 type) - No changes needed P1.3b - cargo: `--` separator already preserved (rtk-ai#326) - Already uses trailing_var_arg + allow_hyphen_values - rtk cargo test -- --nocapture works correctly - No changes needed P1.3c - lint: strip npx/bunx/pnpm prefixes for linter detection (rtk-ai#186/rtk-ai#366) - Add strip_pm_prefix() to remove package manager prefixes - Add detect_linter() for accurate linter identification - Fixes: npx eslint, bunx biome, pnpm exec eslint - Tests: test_strip_pm_prefix(), test_detect_linter() P1.3d - grep: BRE alternation translation already implemented (rtk-ai#206) - Already translates \| (BRE) → | (PCRE) for rg - Already strips -r flag (rg recursive by default) - Comprehensive tests already exist - No changes needed P1.3e - filter: add Language::Data to prevent JSON/YAML/TOML corruption (rtk-ai#464/rtk-ai#479) - Add Language::Data variant for data files - Map 20 data file extensions (json, yaml, toml, xml, md, csv, etc.) - Data language has NO comment patterns (all None) - Fixes: packages/* in package.json no longer stripped as /* comment - Tests: test_data_language_no_comment_stripping() P1.3f - npm: fix routing to distinguish subcommands from scripts (rtk-ai#470) - Add NPM_SUBCOMMANDS constant (59 known npm commands) - Proper routing: npm install → npm install (not npm run install) - Proper routing: npm build → npm run build (script) - Tests: test_npm_subcommand_routing() validates all 59 subcommands Files modified: - src/lint_cmd.rs: Add PM prefix stripping - src/filter.rs: Add Language::Data variant - src/local_llm.rs: Add Language::Data match arm - src/npm_cmd.rs: Add NPM_SUBCOMMANDS routing Quality checks: ✅ cargo fmt --all ✅ cargo clippy --all-targets (0 errors) ✅ cargo test (514 passed; 0 failed) Improves RTK reliability across JS/TS, data files, and npm workflows.
thehoff
pushed a commit
to thehoff/contextcrawler
that referenced
this pull request
May 14, 2026
…-ai#206) Two bugs when passing grep-idiom arguments to rtk grep: 1. Pattern alternation `\|` (BRE syntax) returns 0 results because rg uses PCRE-style `|`, not BRE `\|`. Users coming from grep/awk muscle memory naturally write `rtk grep "fn foo\|fn bar" src/` and get empty output with no error. Fix: translate `\|` → `|` in pattern before passing to rg. 2. `-r`/`--recursive` flag (grep idiom) silently breaks the search. In rg, `-r` means `--replace` and requires an argument — passing it alone causes rg to exit with an error. The `.or_else(|_| ...)` fallback only catches IO errors (command not found), so the grep fallback never triggers; stdout is empty and rtk reports "0 for '<pattern>'". Fix: filter out `-r`/`--recursive` from extra_args before building the rg command (rg is recursive by default, flag is a no-op). Adds two regression tests documenting both behaviours. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
thehoff
added a commit
to thehoff/contextcrawler
that referenced
this pull request
Oct 12, 2026
Reproduced against the installed binary: `cat .env` was rewritten to
`contextcrawler read .env` AND returned with permissionDecision "allow",
printing the secrets in full. Installing contextcrawler therefore made the
read MORE permitted than not installing it, which is the one outcome a
filtering proxy must never produce.
Fixed in the permissions layer, not at the hook. A new
`FindingReason::SecretRead` is raised when a command names a
credential-bearing path, and `apply_policy` decides from there. That keeps
the security profile meaningful — `Unrestricted` is a deliberate opt-out and
is still honoured — and it reaches the legacy rewrite path for free.
Cursor needed a second fix: it hardcoded `permission: "allow"` on the
rewrite path regardless of verdict. It now withholds its opinion entirely on
an Ask, the same `{}` path an explicit Deny already takes. Losing the rewrite
on those commands is the right trade — a missed token saving costs nothing,
silently auto-allowing `cat .env` costs a secret.
The detector took three passes to get honest, each caught by a test:
- extracting the match anchored on the boundary character, so the token came
out empty and every suffix check silently passed
- `scp -i ~/.ssh/id_rsa file host:` flagged as a secret READ, when the key is
being used to authenticate and is never printed. Caught by the repo's own
existing scp/rsync test, which exists for exactly that distinction
- over-matching `/tmp/not_secret_but_has_.ssh/id_rsa_substring`; `.ssh` and
`.aws` must be whole path components, also caught by an existing fixture
Sample and public variants are deliberately excluded — `.env.example`,
`id_rsa.pub` and friends are committed to public repos on purpose, and
prompting on them would train the user to click through the prompt that
matters.
Verified against the real binary on all four host paths. Secret read:
claude ask, cursor no-opinion, gemini deny, copilot ask. Ordinary read:
all four still allow and still rewrite.
Refs: rtk-ai#206
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXCRs8F7G1fFqYczid9cu7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk grep "fn foo\|fn bar" src/returns 0 results silently — users coming from grep/awk muscle memory use BRE\|for alternation, butrguses PCRE-style|; rg receives the literal\|and finds nothing.rtk grep "pattern" src/ -rreturns 0 results silently — inrg,-rmeans--replace(requires an argument); passing it alone causes rg to exit with an error. The.or_else(|_| ...)IO-fallback never triggers on a non-zero exit, so stdout is empty.Reproduction
Fix
|alternationrgdoesn't understand BRE alternationpattern.replace(r"|", "|")before passing to rg (grep_cmd.rs:23)-rflagrg -r=--replace(needs arg), not recursive-r/--recursivefromextra_args; rg is recursive by default (grep_cmd.rs:33-36)Files Changed
src/grep_cmd.rsTest plan
cargo fmt --all --check— cleancargo clippy --all-targets— 0 errors (pre-existing warnings only)cargo test grep_cmd::— 8 passedrtk grep "fn run\|fn new" src/grep_cmd.rs— finds matchesrtk grep "pattern" src/ -r— no longer breaks🤖 Generated with Claude Code