Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/discover/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct RtkRule {

// 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
Collaborator

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 🙏

r"^gh\s+(pr|issue|run|repo|api|release)",
r"^cargo\s+(build|test|clippy|check|fmt|install)",
r"^pnpm\s+(list|ls|outdated|install)",
Expand All @@ -33,7 +33,7 @@ pub const PATTERNS: &[&str] = &[
r"^(npx\s+|pnpm\s+)?playwright",
r"^(npx\s+|pnpm\s+)?prisma",
r"^docker\s+(ps|images|logs|run|exec|build|compose\s+(ps|logs|build))",
r"^kubectl\s+(get|logs|describe|apply)",
r"^kubectl\s+(get|logs|describe|apply|create|delete|edit|scale|rollout|top|port-forward|config|exec|run|patch|label|annotate|explain|auth)",
r"^tree(\s|$)",
r"^diff\s+",
r"^curl\s+",
Expand Down Expand Up @@ -88,6 +88,8 @@ pub const PATTERNS: &[&str] = &[
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
Collaborator

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

r"^jq\b",
];

pub const RULES: &[RtkRule] = &[
Expand Down Expand Up @@ -653,6 +655,15 @@ pub const RULES: &[RtkRule] = &[
subcmd_savings: &[],
subcmd_status: &[],
},
// jq — TOML filter exists (src/filters/jq.toml) but was missing from discover
RtkRule {
rtk_cmd: "rtk jq",
rewrite_prefixes: &["jq"],
category: "System",
savings_pct: 60.0,
subcmd_savings: &[],
subcmd_status: &[],
},
];

/// Commands to ignore (shell builtins, trivial, already rtk).
Expand Down Expand Up @@ -706,6 +717,8 @@ pub const IGNORED_PREFIXES: &[&str] = &[
"while ",
"if ",
"case ",
"ln ",
"ln\t",
Copy link
Copy Markdown
Collaborator

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

];

pub const IGNORED_EXACT: &[&str] = &[
Expand Down