Skip to content

feat: add uv and uvx completions - #496

Closed
taf (tashifkhan) wants to merge 1 commit into
microsoft:mainfrom
tashifkhan:feat/uv-completions
Closed

taf (tashifkhan) wants to merge 1 commit into
microsoft:mainfrom
tashifkhan:feat/uv-completions

Conversation

@tashifkhan

@tashifkhan taf (tashifkhan) commented Nov 1, 2026 •

Copy link
Copy Markdown

Closes #495

Adds bundled uv and uvx completion specs. They load through the same spec set as the @withfig/autocomplete specs, and a spec of the same name in specs.path still takes precedence.

Changes

  • src/specs/uv.ts and src/specs/uvx.ts are Fig specs covering uv 0.13.6. They cover 61 command nodes, flags, documented choice values, and file or directory arguments. Option groups that uv repeats across commands (index, resolver, build, installer, cache and Python options) are shared constants. Global options are declared once on the root with isPersistent: true.
  • src/specs/pyproject.ts has the generators:
    • At uv run , entry points from [project.scripts] in the nearest pyproject.toml come first, then Python files, then other files. --project and --directory change where it looks. --no-project, --script/-s, --gui-script and --module/-m turn script suggestions off. Scripts are hidden while a path is being typed.
    • At uv remove , dependencies declared in project.dependencies, project.optional-dependencies and dependency-groups.
    • Neither imports project code or runs uv. Files over 1 MB are skipped.
  • src/specs/index.ts maps spec names to lazy imports. runtime.ts adds them to the spec set and accepts a loader function as well as a path.
  • smol-toml parses pyproject.toml. The existing toml dependency only supports TOML 0.4 and rejects mixed arrays such as dev = ["pytest", { include-group = "lint" }], which are common in uv projects.

Why not use the uv spec from newer @withfig/autocomplete

Version 2.692.3 includes uv.js, but it is missing current commands (auth, format, check, audit, workspace) and has no uvx spec. Its uv run generator also runs a bare uv run, which creates .venv and uv.lock in a new project. Details are in #495.

Testing

  • npm run lint, npm run build and npm test pass locally on macOS (217 passed, 10 skipped).
  • New tests cover the spec structure (no persistent option repeated on a subcommand, no duplicate option names), completion through the runtime alongside poetry, the pyproject.toml generators, and specs.path taking precedence over a bundled spec.
  • I haven't run the tests on Windows or Linux.

Open questions

  • The bundled spec does not follow uv upgrades on its own. New uv commands need to be added to src/specs/uv.ts, the same way the Fig specs are updated.
  • If you'd rather this live in withfig/autocomplete, I can move the spec there instead.

@tashifkhan

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Bundle uv and uvx specs covering uv 0.13.6. The runtime registers them alongside the @withfig/autocomplete specs, and specs in specs.path still take precedence.

uv run suggests [project.scripts] entry points from the nearest pyproject.toml, then Python files, then other files. uv remove suggests declared dependencies. pyproject.toml is parsed with smol-toml because the existing toml dependency does not support TOML 1.0 mixed arrays.

Closes microsoft#495
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 uv and uvx completions

1 participant