CodeVetter · Repo Unpack · Extension points
astral-sh/uv
uv does not load third-party Rust plugins. Extension is by adding a clap command variant, a settings field, a cache bucket, a preview flag, or a build-backend hook. Indexes, find-links directories, and keyring providers are the user-facing plugin surface. New resolver behavior plugs in through ResolverProvider and the PubGrub dependency provider. Documentation and the JSON schema are generated from the same types, so a new flag is incomplete until uv-dev regenerates the references.
- New CLI commands are added as variants on Commands or on the nested enums ProjectCommand, PipCommand, ToolCommand, PythonCommand, AuthCommand, CacheCommand, and WorkspaceCommand in crates/uv-cli/src/lib.rs, then matched in crates/uv/src/lib.rs. Help is data-driven from clap, not a separate route table.
- User indexes are the main external integration point. CLI and config accept UV_INDEX, UV_DEFAULT_INDEX, UV_EXTRA_INDEX_URL, and UV_FIND_LINKS. RegistryClient::simple_detail walks those indexes using IndexStrategy. uv publish looks up a named index and uses its publish_url.
- Authentication providers plug in through AuthBackend (system keyring or TextCredentialStore), KeyringProvider on AuthMiddleware, and netrc or URL credentials via Credentials::from_url and Credentials::from_env. The Bazel auth helper is a separate protocol enum with a single variant.
- Build backends are an external plugin surface. uv-build-frontend speaks PEP 517. The in-tree backend is uv_build_backend::build_source_dist, build_wheel, and build_editable, invoked either by the hidden uv build-backend command or by the uv-build Python entrypoint's build-sdist command.
- Resolver extension is Resolver::new plus the provider passed into it. uv-resolver re-exports DefaultResolverProvider, ResolverProvider, InMemoryIndex, and OptionsBuilder. A new dependency kind has to be represented in the manifest, the PubGrub package model, and Lock::from_resolution or it will not round-trip through uv.lock.
- PreviewFeature is the feature-flag registry. Adding a variant to the enumflags2 enum requires a display name via PreviewMetadata, and docs are regenerated by uv-dev generate-preview-features-reference. UV_PREVIEW enables every flag; UV_PREVIEW_FEATURES takes an explicit list.
- Cache layout is a closed CacheBucket enum. New persistent data needs a new variant and a versioned directory name (the comment says bumps must also update references in cache_prune.rs, cache_clean.rs, or lock tests). Atomic directory replacement is done by storing blobs in Archive and symlinking them into other buckets.
- Settings fields are added on Options and FilesystemOptions and merged by the Combine trait. The JSON schema for uv.toml is generated by uv-dev generate-json-schema, and the settings reference by generate-options-reference. check-generated-files.yml fails CI if those outputs drift.
- Python discovery request syntax is itself an extension point documented on the Python command: version specifiers, implementation names, freethreaded and debug variants, target triples, executable paths, and install directories. New interpreter kinds have to be recognized by uv-python or they are skipped as unsupported.
- Workspace membership is discovered by Workspace::discover and VirtualProject::discover in uv-workspace, with a WorkspaceCache. New project layouts have to be found there before lock, sync, or run will see them. DiscoveryOptions controls member discovery, including MemberDiscovery::Existing in frozen sync.
- The uv-dev CLI is the internal extension tool, not a user plugin host. Its subcommands generate schema, CLI reference, env-var reference, preview-feature docs, Packse scenario tests, and sysconfig mappings. ROOT_DIR is the repository root computed from CARGO_MANIFEST_DIR.