Skip to content

fix(discover): expand rules coverage for git, kubectl, jq and ignore ln#895

Closed
fkztw wants to merge 1 commit intortk-ai:developfrom
fkztw:fix/discover-rules-coverage
Closed

fix(discover): expand rules coverage for git, kubectl, jq and ignore ln#895
fkztw wants to merge 1 commit intortk-ai:developfrom
fkztw:fix/discover-rules-coverage

Conversation

@fkztw
Copy link
Copy Markdown

@fkztw fkztw commented Mar 28, 2026

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 including git 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 for jq queries.
  • ln: Added the local link command to the global ignore list (IGNORED_PREFIXES), to prevent trivial commands from cluttering standard output optimization reports.

- 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be handled by #894

"if ",
"case ",
"ln ",
"ln\t",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you sort commands in alphabetical order to ease maintenance burden 🙏

@fkztw
Copy link
Copy Markdown
Author

fkztw commented Mar 29, 2026

Closing this PR after reviewing the feedback and checking open PRs.

Overlaps found:

What isn't covered elsewhere: The kubectl expansion and ln ignore entry. These could be submitted as a separate, focused PR if still considered valuable.

Apologies for the noise — should have checked open PRs before submitting. Thank you for the clear review @KuSh.

@fkztw fkztw closed this Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants