feat(rules): support <var:name> in command position and per-value type#208
feat(rules): support <var:name> in command position and per-value type#208
<var:name> in command position and per-value type#208Conversation
When the same tool can be invoked in multiple ways (e.g. `runok`,
`cargo run --`, `./target/debug/runok`), users previously had to
write separate rules for each variant. This change extends the
existing `definitions.vars` + `<var:name>` mechanism in two ways:
1. `<var:name>` can now be used as the command name in a pattern
(e.g. `'<var:runok> check'`). Multi-word var values like
`"cargo run --"` consume multiple leading tokens from the input.
2. Each value in `definitions.vars` can carry its own `type` override
via `{ type: path, value: target/debug/runok }` syntax, allowing
literal and path values to coexist in the same variable definition.
Plain string values inherit the definition-level type as before.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
==========================================
+ Coverage 89.70% 89.80% +0.09%
==========================================
Files 50 50
Lines 10186 10325 +139
==========================================
+ Hits 9137 9272 +135
- Misses 1049 1053 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the flexibility and power of command matching by introducing the ability to use variable references in the command position and allowing fine-grained control over variable value types. These changes address limitations in handling commands that can be invoked through various aliases or paths, providing a more robust and adaptable configuration system. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two powerful features: using <var:name> in the command position and allowing per-value type overrides for variables. The implementation is well-structured, with thorough updates to documentation, schema, and tests.
I have one main concern regarding a subtle correctness issue in how command-position variables are matched. The current implementation greedily matches the first value from the variable's definition, which can lead to incorrect behavior if multiple values could match the start of a command. I've provided suggestions to address this by collecting all possible matches, making the feature more robust and predictable.
…st match `match_var_ref_multi` returned only the first matching value's length, causing missed matches when a shorter value was listed before a longer one (e.g. values ["a", "a b"] with command "a b c" would match "a" and fail to match the remaining pattern). Return all possible consumption lengths and try each in the pattern matcher. Also switch from `split_whitespace` to `shlex::split` per project convention, and parameterize parser tests with `#[rstest]`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Why
runok,cargo run --,./target/debug/runok)"cargo run --"|runok) handles literal alternatives but cannot apply path normalization to specific values (target/debug/runokvs./target/debug/runok)What
<var:name>can now be used in the command position (first token) of a pattern"cargo run --") consume multiple leading tokens from the input commanddefinitions.varsvalues accept per-value type via{ type, value }object formtype; the object form overrides it per value