Skip to content

Development

For contributors working on uh. To install a released binary, see Install.

Bazel is the primary build, test, lint, format and release system. Cargo builds the same workspace for IDE and rust-analyzer use.

Prerequisites

Tool Needed for Notes
Bazelisk Bazel builds Run it as bazel. It downloads the Bazel version pinned in .bazelversion (9.2.0).
python3 //:boundary_test, //:bench The scripts in scripts/ run on the host Python.
git Tests that build synthetic repositories Used by scripts/test_boundary.py and the UI snapshot harness.
rustup + a C compiler Cargo builds only rust-toolchain.toml pins Rust 1.100.0 with clippy and rustfmt. The tree-sitter grammar crates compile C sources through the cc crate.

bazel build needs only Bazelisk and network access for the first fetch. bazel test //... also needs python3 and git. The Bazel build uses no host Rust toolchain, C/C++ compiler, Xcode or sysroot:

  • Rust: tools/rust_toolchain.bzl registers a hermetic Rust toolchain from [workspace.package] in Cargo.toml (edition = "2024", rust-version = "1.100.0"). Cargo.toml is the single source for both values.
  • C/C++: MODULE.bazel registers the hermetic @llvm toolchain for every exec/target pair. It supplies its own libc (glibc stubs, musl) and downloads the macOS SDK. Rust and the tree-sitter C grammars build through it.
  • Third-party crates: resolved from Cargo.toml and Cargo.lock by rules_rs (@crates).
  • Formatters: Biome, ruff, shfmt, yamlfmt, rustfmt and buildifier are fetched by Bazel.
  • Chromium: the UI snapshot tests use a pinned Chrome for Testing chrome-headless-shell, fetched only when those targets are built.

Build

bazel build -c opt //:uh

The binary is written to bazel-bin/crates/uhdiff/uh. //:uh and //:uhdiff are aliases for //crates/uhdiff:uh.

cargo build --release

The binary is written to target/release/uh.

Test

bazel test //...

.bazelrc sets --test_output=errors, so failures print at once.

cargo test --workspace

bazel test //... includes:

Target What it checks
rust_test targets in each crates/*/BUILD.bazel Unit and integration tests per crate.
//:boundary_test Black-box CLI test: scripts/test_boundary.py --milestone all builds synthetic multi-file Go repositories, runs uh as a subprocess, and checks DAG invariants.
//crates/uhdiff:ui_ux_snapshots_test Renders the 13 UI screens in headless Chromium and checks DOM assertions and PNG output. See UI snapshots.
//tools/lint:buildifier_check Starlark formatting and lint warnings in every BUILD, .bzl and MODULE.bazel file.
Clippy and rustfmt checks Run as build aspects on every Rust target. See Lints.

To run the boundary script directly against a Cargo build:

python3 scripts/test_boundary.py --bin ./target/debug/uh --verbose

//:bench runs scripts/bench_profile.py on the Bazel-built binary. Arguments after -- pass to the script:

bazel run -c opt //:bench -- <args>

Lints

Every normal bazel build and bazel test runs Clippy and rustfmt on all Rust targets through rules_rust aspects. Clippy runs with -Dwarnings, using the workspace lints in Cargo.toml and clippy.toml; rustfmt uses rustfmt.toml.

Workspace lint levels ([workspace.lints] in Cargo.toml; every crate opts in with [lints] workspace = true):

  • rustc lints are forbid, including unsafe_code and missing_docs.
  • Clippy lints are deny. Code may opt out locally only with #[expect(lint, reason = "...")].

Skip Clippy and rustfmt for quick local iteration:

bazel test //... --config=nolint

--config=nolint removes the clippy_checks and rustfmt_checks output groups. It does not skip //tools/lint:buildifier_check, which is a test target.

Buildifier targets:

bazel test //tools/lint:buildifier_check   # verify BUILD/.bzl/MODULE files
bazel run //tools/lint:buildifier_fix      # format and auto-fix Starlark lints

Formatting

//:format is an alias for //tools/format, a format_multirun from aspect_rules_lint.

bazel run //:format         # format the repo in place
bazel run //:format.check   # verify formatting without editing
Language Formatter
Rust rustfmt (rules_rust)
Starlark buildifier
JavaScript Biome (biome.json)
CSS Biome (biome.json)
Python ruff
Shell shfmt
YAML yamlfmt

Biome's pinned version is in tools/format/multitool.lock.json. biome.json excludes examples/.

UI snapshots

The UI snapshot harness is crates/uhdiff/tests/ui_ux_snapshots.rs. It starts the built uh binary for uh queue, uh review and uh explore, drives a pinned chrome-headless-shell, and captures 13 screens at 1440x920 (2x device pixel ratio).

Target Kind Effect
//crates/uhdiff:ui_ux_snapshots_test rust_test Captures all 13 screens into a temporary directory and fails on a DOM assertion, a missing screen or an invalid PNG. Writes nothing to the repo.
//crates/uhdiff:ui_ux_snapshots_update rust_binary Captures all 13 screens into docs/ui_snapshots/ in the workspace and prints a JSON summary.
bazel test //crates/uhdiff:ui_ux_snapshots_test
bazel run //crates/uhdiff:ui_ux_snapshots_update

Write to another directory with --screenshots-dir:

bazel run //crates/uhdiff:ui_ux_snapshots_update -- --screenshots-dir /path/to/dir

Chromium exec platforms

//tools/chrome registers chrome-headless-shell toolchains for macOS arm64, macOS x86_64 and Linux x86_64 only.

The PNGs in docs/ui_snapshots/ appear throughout these docs. Regenerate them after a UI change and commit the result.

Cross-compiling

Target platforms are defined in bazel/platforms/BUILD.bazel. Each has a --config in .bazelrc:

--config Platform Binary
darwin_arm64 //bazel/platforms:darwin_arm64 macOS arm64, linked against the hermetic @llvm macOS SDK.
darwin_amd64 //bazel/platforms:darwin_amd64 macOS x86_64, same as above.
linux_amd64 //bazel/platforms:linux_amd64 Linux x86_64, dynamically linked against glibc 2.35 version stubs (Ubuntu 22.04+, Debian 12+). libc++ and Rust std are static.
linux_arm64 //bazel/platforms:linux_arm64 Linux arm64, same as above.
linux_amd64_musl //bazel/platforms:linux_amd64_musl Linux x86_64, fully static musl.
linux_arm64_musl //bazel/platforms:linux_arm64_musl Linux arm64, fully static musl.

Build one platform from any host:

bazel build -c opt --config=linux_arm64_musl //:uh

Build all release tarballs in one command:

bazel build -c opt //release:dist

//release:dist builds darwin_arm64, linux_amd64 and linux_arm64. Each tarball holds the uh binary (mode 0755) and is written to bazel-bin/release/uh-<platform>.tar.gz. The per-platform targets are //release:uh_<platform>_tar. All //release targets are tagged manual, so bazel build //... skips them.

Releases

.github/workflows/release.yml builds and publishes releases on ubuntu-latest. The version is resolved per trigger:

Trigger Tag
Push to main Latest vX.Y.Z tag with the patch number incremented. Skipped when every changed file is under docs/ or is one of README.md, examples/README.md, mkdocs.yml, .gitignore, .github/dependabot.yml or .github/workflows/docs.yml.
Merged PR to main labelled release, release:patch, release:minor or release:major Latest tag bumped by the label: release:major and release:minor bump those parts; release and release:patch bump the patch.
Push of a v* tag That tag.
Manual run (workflow_dispatch) with tag That tag.
Manual run with an empty tag v0.0.0-<short sha>, built and uploaded as a workflow artifact but not published.

Each run that is not skipped:

  1. Runs bazel test //... and bazel run //:format.check.
  2. Runs bazel build -c opt //release:dist and copies the tarballs to dist/uh-<tag>-<platform>.tar.gz, with a SHA256SUMS file.
  3. Uploads dist/ as a workflow artifact.
  4. When publishing, creates the GitHub release uh <tag> with generated notes.
  5. When publishing, rewrites Formula/uh.rb in uhvesta/homebrew-tap with the new version, URLs and checksums, and pushes it. Skipped when the HOMEBREW_TAP_DEPLOY_KEY secret is unset.

Continuous integration

.github/workflows/ci.yml runs on every push to main and every pull request, on ubuntu-latest only (Linux x86_64):

bazel test //...
bazel run //:format.check

A passing CI run means tests, Clippy, rustfmt, buildifier and the all-language format check all passed. CI does not test macOS builds; the darwin_arm64 release binary is cross-compiled from Linux.

Docs site

The docs are a MkDocs Material site. mkdocs.yml sits at the repo root; pages are in docs/.

Preview locally:

pip install -r docs/requirements.txt
mkdocs serve

Check the build before sending a docs change. --strict turns warnings, such as broken links, into errors:

mkdocs build --strict

.github/workflows/docs.yml deploys the site and live demos to GitHub Pages. The docs are served under https://uh.uhvesta.com/docs/; the demos keep their root URLs (for example https://uh.uhvesta.com/pr1.html). See Examples.

Workspace crates

The Cargo workspace includes every directory under crates/.

Crate Purpose
crates/uhdiff The uh CLI binary (review, queue, explore, graph, parse, config, install).
crates/uhdiff-review Diff extraction, move detection, local HTTP server, review queue, GitHub integration, config, CLI progress, and the embedded web UI (ui/).
crates/uhdiff-pipeline Parallel discovery, parse and resolution caching (.uhdm packfiles and shards), incremental diff slicing, DAG condensation, and cross-language bridges.
crates/uhdiff-hir Language-agnostic high-level IR (FileHir, symbols, calls, types, imports), IDs, string interner, parse and discovery primitives, and the adapter trait.
crates/uhdiff-index Workspace symbol table and lookup indexes, type and trait hierarchy, module and package resolution.
crates/uhdiff-resolve Static type propagation, call resolution, CSR/SCC primitives, topological layering, and the type DAG builder.
crates/uhdiff-report Serializable DAG report types and the compact JSON serializer.
crates/uhdiff-mmap Zero-copy memory-mapped flat binary archive (.uhdm) and POD table views.
crates/uhdiff-ast-diff Opt-in scoped structural AST diff (Patience/LCS anchor splitting and Dijkstra tree edit search).
crates/seated-tree Non-incremental flat-arena tree-sitter runtime with SIMD line indexing and fallback to upstream tree-sitter. See crates/seated-tree/README.md.
crates/uhdiff-rust Rust extractor.
crates/uhdiff-go Go extractor (including manifests).
crates/uhdiff-java Java extractor.
crates/uhdiff-python Python extractor.
crates/uhdiff-ts TypeScript and JavaScript extractor.
crates/uhdiff-cpp C and C++ extractor.
crates/uhdiff-swift Swift extractor.
crates/uhdiff-zig Zig extractor.
crates/uhdiff-starlark Starlark (.bzl, BUILD) extractor.
crates/uhdiff-proto Protocol Buffers (.proto) extractor.
crates/uhdiff-test-harness Shared synthetic multi-file fixture runner and DAG assertion helpers for language adapter tests.
crates/uhdiff-snapshot-runner Internal Bazel runner for DAG snapshot and invariant validation, benchmarks, and CPU profiling.

Each language crate holds its tree-sitter grammar binding and its tree-sitter-to-HIR extractor. See Languages for extensions and per-language behavior.