Skip to content

feat(cli/completion): add support for unstable_dynamic - #6899

Open
baka-gourd wants to merge 2 commits into
prefix-dev:mainfrom
baka-gourd:feat/clap-dynamic
Open

feat(cli/completion): add support for unstable_dynamic#6899
baka-gourd wants to merge 2 commits into
prefix-dev:mainfrom
baka-gourd:feat/clap-dynamic

Conversation

@baka-gourd

Copy link
Copy Markdown

Description

Fixes #6898

for I have made corresponding changes to the documentation:

There are currently no documents related to shell completion, so I haven't added any. If needed, I can add some.

How Has This Been Tested?

Tested all unit tests, and pass all lints. Works on my pwsh(Windows) and Bash(Git Bash for Windows)

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: {e.g., Claude, Codex, GitHub Copilot, ChatGPT, etc.}

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@baka-gourd

Copy link
Copy Markdown
Author

The CI error does not appear to be related to this change

@Hofer-Julian

Hofer-Julian commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution!

I am a bit hesitant to use unstable clap features, especially now that epage's work isn't funded anymore.

We also have pretty decent completions these days thanks to @hunger

@baka-gourd

Copy link
Copy Markdown
Author

I think this is an optional solution rather than a replacement for the current static generator.

The core issue is that Pixi’s completion scripts are simply too long right now—707 KB for pwsh and 398 KB for bash. Evaluating such long shell commands slows down startup, and using this unstable solution can resolve that issue.

@baka-gourd

Copy link
Copy Markdown
Author

Furthermore, this feature would enable more autocompletion options, such as autocompletion for “task-name” (which has already been added), and so on. In short, I think this is a “harmless” feature that could be useful to many people (especially PowerShell users), so I hope you'll consider it.

@ruben-arts

Copy link
Copy Markdown
Contributor

@Hofer-Julian Let's discuss this in more detail. We've been wishing for this feature since Pixi was created. I would say if it works it would be such a big UX improvement that I would be willing to give it a go. In the worst case we would have to remove these UX features later when it shows to not be a decent feature in the end.

@baka-gourd did you have experience with it in other projects?

@baka-gourd

Copy link
Copy Markdown
Author

@ruben-arts in other projects as I have said in issue, cargo and rust-lang/rustup#5033 have this feature to complete toolchains; in the Python ecosystem, at least uv hasn't implemented this feature; for Git, there are already many third-party modules that provide context-aware autocompletion, such as the PS Module I use; for winget, this.

The features mentioned above work great in practice, providing quick and intelligent suggestions for what you need.
As far as my development experience goes, I don’t have much practical experience with large CLI repositories (I mainly work on GUIs), but the unstable_dynamic feature works very well with my CLI tools. That said, this isn’t strong evidence, it’s just my personal experience.

two key advantages:

  • It completely eliminates the need for static autocomplete commands—which can be as large as several hundred KB—thereby speeding up shell startup
  • It dynamically generates available completion commands based on the project context, which is a very powerful feature for task; this feature can even be used with pixi add for real-time search

one drawback:

  • Some older shells do not support this type of completion; older shells can continue to use statically generated completions

Overall, I think this is definitely a “decent” solution, it provides a progressive enhancement effect.

@Hofer-Julian

Copy link
Copy Markdown
Contributor

I am just as excited about this feature as you all are, but has there actually been progress to stabilize this? Because this feature is in a limbo for a long time now.

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.

Add support for clap unstable-dynamic feature

3 participants