Repository navigation
feat(task): inherit usage flags from task templates - #13310
Conversation
A task extending a template replaced the template's `usage` spec with its own instead of adding to it, so declaring one task-specific flag silently dropped every shared flag the template defined. The template's spec is now prepended to the task's, letting a template hold the flags and arguments several tasks have in common while each task adds its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughChangesNamed task templates prepend their Task template usage
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant resolve_task_template
participant Task
participant TaskTemplate
resolve_task_template->>Task: resolve task with extends
Task->>TaskTemplate: merge_extended_template
TaskTemplate-->>Task: compose template usage before task usage
Merge Risk: ⚪ Minimal · up to The named-template and workspace-default merge paths are separated as intended, with coverage for the documented usage behavior. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Workspace-root task defaults go through the same merge, where they are meant to fill only what a task left unset. Composing there could prepend a required positional argument to a task that declared its own spec, breaking a command line that parsed fine before. Composition is now limited to a template the task named with `extends`; a workspace default's `usage` is still used only when the task has none. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The merge-semantics list still claimed `usage` is concatenated, which is true only of `merge_extended_template` since the two were split. Each method now states which merge it is and points at the other. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…emplate-usage-merge # Conflicts: # src/task/task_template.rs
A task template can hold a
usagespec, but a task that extended it and declared any flag of its own lost every flag the template defined —usagewas the one field where the template's value was used only when the task had none. Tasks that share a set of flags had to copy the whole spec into each one and keep the copies in sync, which is especially painful forchoiceflags.The template's spec is now prepended to the task's:
Shared flags come first so
--helpreads shared-then-specific, and so a template's positional args stay ahead of the task's. Both halves are joined before rendering, so Tera in either still resolves. A task with nousageof its own inherits the template's unchanged, as before.Only for a template named with
extendsWorkspace-root task defaults go through the same merge, where their job is to fill what a task left unset. Composing there could prepend a required positional argument to a task that has its own spec and break a command line that parsed fine before, so a workspace default's
usageis still used only when the task has none.Compatibility
A task that sets both
usageandextendsnow also accepts the template's flags, where before it accepted only its own. Nothing that parsed before stops parsing, but a flag declared in both places is two declarations and is listed twice in--help— declare each flag in one place. For the case where a task genuinely needs to replace an inherited flag, usage flagsets are the better tool: put the shared declarations in a.usage.kdlfile andusethem where they belong.Validation
e2e/tasks/test_task_template_usagecovers composition,--helpordering, a task with no spec of its own, unset inherited flags,choicesenforced through a template, and Tera in both halves. The ordering check compares the three flags as one ordered list; I confirmed it fails when the concatenation is reversed.e2e/tasks/test_task_templates,cargo test --bin mise task::andconfig::,mise run lint, andcargo clippy --workspace --all-features --all-targets -- -D warningsall passCloses the main ask in #9637.
AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5; version: unavailable.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Note
Medium Risk
Changes CLI parsing and
--helpfor tasks with bothextendsand localusage(more flags accepted; duplicate declarations if the same flag appears in template and task).Overview
Tasks that
extendsa template now mergeusagespecs instead of treating localusageas a full replacement. The template’s declarations are prepended to the task’s (template first in--help), then Tera runs on the combined string; tasks with no localusagestill take the template’s spec unchanged.Workspace-root task defaults keep the old fill-only rule via
merge_templatevsmerge_extended_templatefor explicitextends, so defaults don’t inject extra required args into tasks that already define their own flags.Docs add the
usagerow to the merge table and a shared-arguments example; e2e and unit tests cover composition, ordering, choices, and Tera.Reviewed by Cursor Bugbot for commit 3e7546e. Bugbot is set up for automated code reviews on this repo. Configure here.