Skip to content

fix(task): resolve bare aliases in monorepo with config_roots#8819

Merged
jdx merged 2 commits intojdx:mainfrom
nkakouros:worktree-fix-task-alias-resolution
Mar 31, 2026
Merged

fix(task): resolve bare aliases in monorepo with config_roots#8819
jdx merged 2 commits intojdx:mainfrom
nkakouros:worktree-fix-task-alias-resolution

Conversation

@nkakouros
Copy link
Copy Markdown
Contributor

@nkakouros nkakouros commented Mar 29, 2026

Summary

  • When a bare alias like prl is used in a monorepo, expand_colon_task_syntax expands it to //:prl. TaskLoadContext::from_pattern was then setting load_all=false, which skipped config root task discovery entirely, so the actual task (e.g., //:pr:list) was never loaded and the alias couldn't resolve.
  • Tab completion for monorepo-prefixed aliases (e.g., //:prl<Tab>) also failed because the usage spec only registered bare aliases, not their //-prefixed forms.

Before

$ mise r prl         # ❌ no task //:prl found
$ mise r //:prl      # ✅ works
$ mise r //:prl # ❌ no completions
$ mise r prl    # ✅ works

After

All four variants work.

Test plan

  • New e2e test test_task_file_alias_run: monorepo with config_roots=["."], bare/prefixed alias execution,
    multiple aliases, subproject aliases, usage spec verification
  • New unit tests for get_matching with alias and monorepo alias resolution
  • Existing test_task_monorepo_aliases and all monorepo e2e tests still pass
  • cargo clippy --all-features --all-targets -- -D warnings clean
  • mise run lint clean

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements file-based task alias resolution for monorepo mode, updates the usage spec to include prefixed aliases for completion, and ensures tasks are loaded correctly when no path hint is provided. A review comment suggests adding an E2E test case to verify that bare aliases also resolve correctly from the monorepo root.

@nkakouros nkakouros force-pushed the worktree-fix-task-alias-resolution branch from 85a0135 to 4b36bbf Compare March 29, 2026 23:52
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR fixes two related bugs for monorepo alias resolution in mise:

  1. Core logic fix (task_load_context.rs): TaskLoadContext::from_pattern was always setting load_all: false even when extract_path_hint returned None (root-level patterns like //:prl or bare names like prl). This caused config-root task discovery to be skipped entirely, so aliases registered in those roots were never found. The one-line change — returning load_all: true in the None arm — makes the function consistent with its sibling from_patterns, which already handled this case correctly.

  2. Tab-completion fix (ls.rs): The usage spec only registered bare aliases (prl), not their //-prefixed forms (//:prl). The new block in display_usage uses extract_monorepo_path to detect monorepo tasks and appends the prefixed form to task_spec.cmd.aliases before the spec is serialised, so both forms are available for shell completion.

Key changes:

  • TaskLoadContext::from_pattern: When extract_path_hint is None (empty path or bare name), set load_all: true instead of false.
  • TasksLs::display_usage: For each monorepo task, extend its usage-spec aliases with the //path:alias form.
  • New unit tests in task_load_context.rs pin the fixed from_pattern behavior for //:prl and bare patterns.
  • New unit tests in task/mod.rs verify get_matching resolves both plain and monorepo-prefixed aliases.
  • New e2e test covers root-level alias execution, subproject alias resolution, and usage-spec completions.

Confidence Score: 5/5

Safe to merge; the fix is targeted, consistent with existing patterns, and backed by both unit tests and e2e coverage.

All remaining findings are P2 style/test-quality suggestions. The core logic change is a single-branch correction that brings from_pattern into alignment with from_patterns (which already did the right thing). No regressions are introduced; existing monorepo e2e tests continue to pass.

No files require special attention — the e2e test's grep pattern (line 51) is the only minor point worth a follow-up.

Important Files Changed

Filename Overview
src/task/task_load_context.rs Core fix: from_pattern now sets load_all: true when extract_path_hint returns None (e.g. //:alias or bare names), making it consistent with from_patterns; two new unit tests pin the corrected behavior.
src/cli/tasks/ls.rs Adds prefixed aliases (e.g. //:prl, //projects/backend:d) to the usage spec for tab-completion; relies on extract_monorepo_path which correctly returns "" for root-level tasks, producing the right //:alias format.
src/task/mod.rs New unit tests for get_matching covering alias resolution and monorepo alias resolution (both bare and //: prefixed forms); no logic changes to existing code.
e2e/tasks/test_task_file_alias_run New e2e test covering root-level alias execution, subproject alias resolution, and usage spec completions; Test 3's grep pattern relies on the exact quoted-alias format of the usage spec output.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["mise run prl"] --> B["expand_colon_task_syntax('prl')"]
    B -->|"monorepo root"| C["'//:prl'"]
    C --> D["TaskLoadContext::from_pattern('//:prl')"]
    D --> E["extract_path_hint('//:prl')"]
    E -->|"empty path → None"| F{"BEFORE fix"}
    E -->|"empty path → None"| G{"AFTER fix"}
    F -->|"load_all: false ❌"| H["config_roots skipped\nAlias never resolved"]
    G -->|"load_all: true ✅"| I["All config_roots scanned"]
    I --> J["Task '//:pr:list'\nwith alias 'prl' found"]
    J --> K["build_task_ref_map creates\n'//:prl' → task\n'prl' → task"]
    K --> L["get_matching('//:prl')\nfinds task ✅"]

    subgraph Completion Fix
        M["mise tasks --usage"] --> N["display_usage()"]
        N --> O["extract_monorepo_path('//:pr:list')\n→ Some('')"]
        O --> P["Append '//:prl' to aliases"]
        P --> Q["usage spec contains '//:prl'\nfor shell completion ✅"]
    end
Loading

Reviews (2): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

When a bare alias like `prl` is used in a monorepo context, it gets
expanded to `//:prl` via `expand_colon_task_syntax`. The resulting
`TaskLoadContext::from_pattern` was setting `load_all=false`, which
skipped config root task discovery — so the actual task was never loaded.

Also adds monorepo-prefixed aliases to the usage spec so that tab
completion works for patterns like `//:prl`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nkakouros nkakouros force-pushed the worktree-fix-task-alias-resolution branch from 71b7ecc to 1e1f870 Compare March 30, 2026 00:09
@jdx jdx merged commit ef3156b into jdx:main Mar 31, 2026
32 of 34 checks passed
mise-en-dev added a commit that referenced this pull request Apr 1, 2026
### 🚀 Features

- add azd (Azure Developer CLI) to registry by @rajeshkamal5050 in
[#8828](#8828)

### 🐛 Bug Fixes

- **(aqua)** skip registry lookup for linked versions in list_bin_paths
by @nikobockerman in [#8801](#8801)
- **(rust)** handle rustup check exit code 100 as non-error by @shalk in
[#8832](#8832)
- **(task)** resolve bare aliases in monorepo with config_roots by
@nkakouros in [#8819](#8819)
- show usage help when long_about is defined w/o args/flags by
@nkakouros in [#8824](#8824)

### 📚 Documentation

- fix serif font in sidebar and increase heading sizes by @jdx in
[#8831](#8831)
- fix #vscode link in ide integration page by @jedymatt in
[#8833](#8833)
- fix nested Markdown code fences by @muzimuzhi in
[#8835](#8835)

### New Contributors

- @shalk made their first contribution in
[#8832](#8832)
- @jedymatt made their first contribution in
[#8833](#8833)
- @nikobockerman made their first contribution in
[#8801](#8801)
- @rajeshkamal5050 made their first contribution in
[#8828](#8828)

## 📦 Aqua Registry Updates

#### New Packages (2)

- [`gastownhall/beads`](https://github.com/gastownhall/beads)
- [`getdbt.com/dbt-fusion`](https://github.com/getdbt.com/dbt-fusion)

#### Updated Packages (2)

- [`Azure/azure-dev`](https://github.com/Azure/azure-dev)
- [`magefile/mage`](https://github.com/magefile/mage)
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.

3 participants