Repository navigation
Conversation
Aliases are configured in `[aliases]` sections of user config or project
config and invoked via `wt step <name>`. They support the same template
variables as hooks ({{ branch }}, {{ worktree_path }}, etc.), --dry-run
to preview expanded commands, and --var KEY=VALUE for extra variables.
User config overrides project config on name collision. Feature is marked
experimental in documentation.
Co-Authored-By: Claude <[email protected]>
Aliases named after built-in subcommands (commit, push, rebase, etc.) are silently ignored because clap dispatches built-ins first. Now emits a warning so users know the alias will never run. Co-Authored-By: Claude <[email protected]>
The merge_alias_maps function in sections.rs was uncovered, causing codecov/patch to report below-target coverage on changed lines. Co-Authored-By: Claude <[email protected]>
Project-config aliases now require the same approval flow as project hooks. User-config aliases remain trusted and skip approval. When a user overrides a project alias, the user version is trusted. Adds --yes/-y flag to bypass approval in CI/CD environments. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
Clean feature addition. The alias system integrates well with the existing hook infrastructure — reusing template expansion, the approval flow, and run_command_streaming. Test coverage is thorough across all the important scenarios (approval matrix, user/project merge, shadowing, exit codes, dry-run).
A few observations:
Observations (3 items)
-
phase_overrideonHookCommand— TheHookCommandstruct now carries aphase_override: Option<String>and a dummyhook_type: HookType::PostCreatethat's documented as "unused for display." This works but makesHookCommandaware of a concept (alias) that's outside its original domain. An alternative would be a small enum (Phase { Hook(HookType), Alias }) that replaces both fields, though that's a larger refactor and probably not worth it for a single use case today. Fine as-is with the comment. -
Shadowing check runs on every alias invocation —
step_aliasiterates all aliases to check for built-in shadows every time, even when the user is running a non-shadowed alias. The warning is useful, but it means someone withtest = "cargo test"in their config will see the warning on everywt step deployinvocation — not just when they try to runtest. This could become noisy. Worth considering whether to only warn when the requested alias itself is shadowed, or at config-load time. -
--yeson alias-only approval doesn't save — This is intentional and tested (test_alias_approval_yes_bypasses), matching the hook behavior. Just noting it's consistent.
CI is green across all platforms (lint, test linux/macOS/windows, code-coverage, codecov/patch all pass).
Looks good to merge.
…ation Shadowed aliases (names matching built-in step commands) are now filtered from the "available" list in error messages rather than emitting a warning on every alias invocation. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
CI is failing due to a rustfmt formatting issue introduced by removing warning_message from the import. The remaining imports are short enough for a single line. The test failures cascade from the same pre-commit lint check — cargo fmt fixes it.
Co-Authored-By: Claude <[email protected]>
…eCommand Replace the `hook_type` + `phase_override: Option<String>` pair with a `Phase` enum (`Hook(HookType)` | `Alias`). Eliminates the dummy `HookType::PostCreate` value and the stringly-typed override. Rename `HookCommand` to `ApprovableCommand` to reflect its broader role. Co-Authored-By: Claude <[email protected]>
- Simplify approve_alias: let approve_command_batch handle the is_command_approved check instead of duplicating it - Skip approval for --dry-run (read-only preview doesn't need permission) - Reject empty --var keys (e.g., --var =value) - Fix error message: "Unexpected argument" instead of "Unknown flag" for positional args - Add BUILTIN_STEP_COMMANDS sync test to catch drift from StepCommand enum - Document --yes, approval requirement, and shadowing in alias help text - Add [aliases] section to wt.example.toml project config template Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The Phase enum refactor is a clean improvement — ApprovableCommand with Phase::Hook(HookType) | Phase::Alias is much better than the old hook_type + phase_override pattern. The rename from HookCommand to ApprovableCommand accurately reflects its expanded scope.
The rest of the incremental changes (project config aliases field, user config merge logic, merge_alias_maps, approval flow integration) are straightforward and well-tested.
Summary
wt step <alias-name>for running user-defined command templates configured in[aliases]sections of user or project config{{ branch }},{{ worktree }}, etc.) plus custom--var KEY=VALUEvariables--dry-runskips approval since it's a read-only previewPhaseenum (Hook(HookType)|Alias) replacing the oldhook_type+phase_overridepattern in the approval systemHookCommandtoApprovableCommandsince it now covers both hooks and aliasesTest plan
AliasOptions::parse(name-only, --dry-run, --yes, --var, empty key rejection, positional arg rejection)merge_alias_mapscoverageBUILTIN_STEP_COMMANDSmatches actualStepCommandclap variants