fix(discover): expand rules coverage for git, kubectl, jq and ignore ln#895
fix(discover): expand rules coverage for git, kubectl, jq and ignore ln#895fkztw wants to merge 1 commit intortk-ai:developfrom
Conversation
- Expand git PATTERN to include checkout, switch, remote, config, ls-files, tag, merge, rebase, reset, clean, clone, init, submodule, cherry-pick, revert, rm, mv, bisect, blame, reflog, shortlog, describe, archive, bundle, notes — all already supported via external_subcommand passthrough - Expand kubectl PATTERN to include create, delete, edit, scale, rollout, top, port-forward, config, exec, run, patch, label, annotate, explain, auth — all already supported via external_subcommand passthrough - Add jq to PATTERNS and RULES — the TOML filter (src/filters/jq.toml) already existed but was missing from discover rules, preventing hook rewrite and discover reporting - Add ln to IGNORED_PREFIXES — trivial filesystem operation that should not appear in unhandled commands
| r"^trunk\s+build", | ||
| r"^uv\s+(sync|pip\s+install)\b", | ||
| r"^yamllint\b", | ||
| // jq — TOML filter exists (src/filters/jq.toml) but was missing from discover |
| "if ", | ||
| "case ", | ||
| "ln ", | ||
| "ln\t", |
There was a problem hiding this comment.
I'm not sure this should be added. Tab is a completion key in most terminals, it shouldn't be easy to use it in command lines and I'm not sure LLM would use it either.
If it's a real case however, this should be handled globally and not just for that particular command
| // Patterns ordered to match RULES indices exactly. | ||
| pub const PATTERNS: &[&str] = &[ | ||
| r"^git\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree)", | ||
| r"^git\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree|checkout|switch|remote|config|ls-files|tag|merge|rebase|reset|clean|clone|init|submodule|cherry-pick|revert|rm|mv|bisect|blame|reflog|shortlog|describe|archive|bundle|notes)", |
There was a problem hiding this comment.
Could you sort commands in alphabetical order to ease maintenance burden 🙏
|
Closing this PR after reviewing the feedback and checking open PRs. Overlaps found:
What isn't covered elsewhere: The kubectl expansion and Apologies for the noise — should have checked open PRs before submitting. Thank you for the clear review @KuSh. |
Description
This PR expands the token savings discovery coverage (
rtk discover) for several common command line patterns:git: Broadened matching criteria to accurately capture complex arguments includinggit clone,git commit -am, and strings wrapped in quotes.kubectl: Enhanced support to detect multi-flag statements typical in Kubernetes operational manifests.jq: Corrected the filter assignment to properly resolve coverage savings calculations forjqqueries.ln: Added the local link command to the global ignore list (IGNORED_PREFIXES), to prevent trivial commands from cluttering standard output optimization reports.