Development
This document covers everything a contributor needs to build, test, lint, and ship Ulmi.
Prerequisites
- Go 1.26.11 or newer (the version is pinned in
go.mod). make.- For end-to-end tests with a real model: an
Ollama installation. The mock-provider variant
(
make e2e-mock) does not require Ollama. - Optional:
golangci-lint(make lintinstalls the pin in.golangci-version). - Optional:
govulncheck(make govulncheckruns the pin in.govulncheck-version).
Building
make build # → bin/ulmi
make install # → $(go env GOPATH)/bin/ulmi
make build-check # compile every package without producing binariesThe Makefile injects git describe --tags --always --dirty into
internal/cli.Version via -ldflags, so ulmi version reports a
meaningful identifier even for development builds.
Cross-compilation
GOOS=linux GOARCH=amd64 make build
GOOS=darwin GOARCH=arm64 make build
GOOS=windows GOARCH=amd64 make buildA stripped, size-checked release binary:
make binary-size # also enforces the 30 MB ceiling enforced in CIGoReleaser
Cross-platform release artefacts are produced by
GoReleaser using
.goreleaser.yaml.
goreleaser release --snapshot --clean --skip=publish # local dry run (requires Syft)
goreleaser release --clean # tag-based real releaseThe release workflow runs the full CI workflow on the tagged commit before
publishing. GoReleaser and Syft versions are pinned in that workflow.
Archives include LICENSE.md and Go/dependency notices under licenses/;
generate a starter configuration with ulmi config init.
Homebrew publishing is skipped unless HOMEBREW_TAP_GITHUB_TOKEN is configured.
Archives ship with a SHA-256 checksums.txt and an SPDX SBOM (*.sbom.json).
GitHub records a build provenance attestation (no container image; this
project does not publish Docker). Verify a downloaded archive:
sha256sum -c checksums.txt
gh attestation verify --repo daniilperestoronin/ulmi ./ulmi_linux_x86_64.tar.gzA Homebrew tap (daniilperestoronin/tap) is updated automatically.
Vendor directory
Dependencies are vendored under vendor/. The Makefile
auto-detects the vendor directory and adds -mod=vendor to every Go
command when present.
make vendor # tidy + vendor
make vendor-verify # read-only checksum verification (CI-safe)
make vendor-sync # fail when vendor/ is out of sync with go.mod/go.sumRun make vendor whenever you change go.mod so CI does not flag a
mismatched tree.
Dependency updates
Dependabot is
configured in .github/dependabot.yml:
weekly gomod and github-actions PRs. golang.org/x/* is grouped so
the x/ tree does not open a PR per module.
Dependabot does not refresh vendor/. The
dependabot-vendor
workflow runs make vendor on Dependabot PRs that touch go.mod /
go.sum and pushes the tree to the same branch so vendor-sync stays
green. If that job cannot push, run make vendor locally on the PR.
make govulncheck still gates reachable CVEs. Do not enable auto-merge
to main without a green govulncheck job. Do not commit bot binaries.
Tests
New tests should use t.Context() rather than context.Background().
Independent table-driven cases may use t.Parallel() unless they touch
theme.Active(). Tests that only call View(th) / Highlight(pal)
with an explicit palette may run in parallel. Do not enable the
tparallel linter, and do not mass-rewrite existing Background() calls.
make test # full suite with -race, including snapshot
make test-integration # cross-package integration workflows only
make test TEST_TIMEOUT=10m
make cover # local: HTML report → coverage.html
make cover-ci # CI line: total %% of listed packages
make bench # PTY startup benchmarks + binary sizesmake cover-ci is not whole-module coverage. It excludes cmd/ulmi
(no tests) and every internal/snapshot package: those tests spawn
subprocesses whose coverage would need GOCOVERDIR / covdata, which
is not wired in CI. Use make cover locally if you need snapshot
numbers; do not treat the CI tail line as a snapshot-inclusive summary.
The total: percentage is compared to .cover-threshold
(a little below the measured line so noise does not fail CI). If coverage
honestly rose and you want a tighter floor, run make cover-ci, subtract
0.5 percentage points from total:, and write that value into
.cover-threshold. Do not include snapshot packages until subprocess
coverage is collected with GOCOVERDIR.
Cross-package integration tests live in
test/integration/ and run as part of make test.
They exercise real package boundaries and local resources without launching
the CLI binary or requiring an LLM.
Fuzz targets (FuzzParse, FuzzDecodeJSONRPC, FuzzMatchPattern,
FuzzParseAndMerge, FuzzDoubleStarMatch) live next to the parsers they
cover. make test compiles them. CI runs make fuzz-ci on Ubuntu (no
race detector): each existing target with -fuzztime=20s (about two and
a half minutes total):
| Target | Package |
|---|---|
FuzzDecodeJSONRPC | internal/mcp |
FuzzParse | internal/mention |
FuzzParse | internal/tool/tools/patch |
FuzzParseAndMerge | internal/config |
FuzzDoubleStarMatch | internal/tool/tools/glob |
FuzzMatchPattern | internal/permission |
FuzzParse | internal/slash |
A local run is:
go test -fuzz=FuzzParse -fuzztime=30s ./internal/tool/tools/patch/
go test -fuzz=FuzzParseAndMerge -fuzztime=10s ./internal/config/
go test -fuzz=FuzzDoubleStarMatch -fuzztime=10s ./internal/tool/tools/glob/End-to-end tests live in test/e2e/:
make e2e-setup # one-off: install Ollama + pull model
make test-e2e # full E2E with real model
make e2e-mock # mock-provider E2E (no Ollama)
make e2e-mock-pty # CI-safe PTY/TUI subset with mock providersMock-provider E2E tests are guarded by the e2e build tag. CI runs both
the non-interactive suite and the Unix PTY subset on every push.
Lint and formatting
make lint # golangci-lint run
make fmt # gofmt + goimportsThe lint configuration in .golangci.yml enables
bodyclose, misspell, unconvert, unparam, nakedret, noctx,
copyloopvar, contextcheck, errorlint, errname, revive, gocritic,
gosec, cyclop, gocyclo, funlen, wrapcheck, sloglint,
forcetypeassert, nilnil, rowserrcheck, and sqlclosecheck.
goimports enforces github.com/daniilperestoronin/ulmi as the local-prefix
group. sloglint requires err as the error key and InfoContext /
WarnContext / ErrorContext when a context.Context is in scope.
Optional high-bar linters (exhaustive, thelper) stay off. Enabling any of
them is a dedicated PR with the matching code fixes — not a config-only
change. Do not enable exhaustruct or prealloc. The tparallel linter
stays off (too many false positives on TUI tests).
Security checks
make security
make govulncheckmake security is a CI gate. It runs Gitleaks pinned
in .gitleaks-version against current files and all reachable Git history,
including merge commits. A shallow checkout is rejected; CI fetches full
history. Findings are redacted and scan failures fail the target. Tests are
scanned too; any fixture exceptions must be narrowly documented in
.gitleaks.toml. Gitleaks retains its standard exclusions for dependency
lockfiles, common vendor trees, and binary assets. Inline gitleaks:allow
comments do not bypass the scan.
The target also verifies that every non-test exec.Command(...) is
exec.CommandContext(...) (exit 1; not a warning).
Do not use @latest for govulncheck; the Makefile reads
.govulncheck-version.
make govulncheck runs govulncheck
at the version in .govulncheck-version (same
pin scheme as golangci-lint; never @latest). CI runs this on Ubuntu.
A failing scan means a reachable vulnerability in the module graph, not
advisory-only noise.
Coding conventions
The engineering contract — style, tests, package boundaries — is
AGENTS.md. Do not restate it here.
One extra note that needs the surrounding code to make sense: avoid
import cycles by introducing a third package or pushing the shared type
up to the closest common ancestor (see
internal/snapshot and the
snapshotfactory wiring trick).
Project layout cheatsheet
See Architecture → Repository layout for the directory tree and ownership of each package.
Adding a feature
A typical end-to-end change touches multiple packages. Use this checklist:
- Specify the change. Update the relevant pages in this
docs/tree as the design evolves; significant features should also be reflected inCHANGELOG.mdunder[Unreleased]. - Tests first. Lean on the per-package
_test.gofiles as templates. - Implement in the smallest scope possible — a single internal package when possible.
- Wire up in
internal/cliif the feature needs a new subcommand or manager. - Document:
- User-facing concepts →
docs/. - Public Go API → doc comments.
- User-visible changes →
CHANGELOG.md.
- User-facing concepts →
- Run
make fmt test lintbefore pushing.
Constructing the TUI
internal/cli is the composition root. tui.New takes the LLM provider,
model ID, model registry, and zero or more tui.Option values. With*
names are constructor options, not methods on the live tea.Model.
app := tui.New(provider, modelID, llmRegistry,
tui.WithSlashRegistry(slashReg),
tui.WithTools(tools),
tui.WithTheme("catppuccin-mocha"),
)Runtime switches (/agent, /themes, session mode) use handlers on the
live App, not a second With* after New. Resume injects a session
with tui.WithSession. See internal/cli/tui.go.
Adding a new provider
- Create
internal/llm/providers/<name>/provider.goimplementingllm.Provider. Usellm.PostJSON/llm.DoOK/llm.CloseBodyfor HTTP so status handling and body close stay consistent. - Register it in
internal/cli/registry.go(buildRegistry). - Add optional metadata (pricing + context window) for known model IDs to
internal/llm/registry.go(builtinCatalog) — used only for display enrichment when those IDs appear in the user’s config. - List example models under
models:in the Full reference indocs/configuration.md. - If the API supports prompt caching, wire it in the provider (Anthropic
cache_control, OpenAIprompt_cache_key, Gemini implicit/cachedContent) and keep the request prefix byte-stable. - Wire token-counter ratios in
internal/tokencounter/counter.goif the provider’s tokenisation differs significantly.
Adding a new tool
See Tools → Adding a new tool.
Adding a new MCP transport
The Client interface in
internal/mcp/client.go is the contract.
Place a new transport under internal/mcp/ and add a type case in the
manager’s dial switch. Document the YAML type string and aliases on
MCP (canonical). Current types: local/stdio, remote/http,
sse, streamable-http/streamable. HTTP request/response transports
must use requestClient(); SSE and streamable HTTP must use
streamClient() (no whole-exchange Timeout). Do not share one
http.Client across servers. Tests inject WithHTTPClient.
Keeping docs fresh
When a user-facing contract changes, update one canonical page and
link from the rest (docs/README.md lists them). Architecture diagrams
in docs/architecture.md use Mermaid fenced blocks
(GitHub and the Hextra site both render them). Before finishing a PR
that touches CLI, TUI, config, or tools, grep these sources of truth:
| Source of truth | Check against |
|---|---|
docs/cli.md | internal/cli/root.go (AddCommand) and each new*Cmd flag set |
docs/tui.md slash table | internal/slash/slash_builtins.go (all) |
docs/tui.md keybindings | internal/tui/keymap/keymap.go (defaults) — do not document unbound chords |
docs/configuration.md YAML | internal/config/config.go exported fields + detectUnknownFields known keys |
docs/mcp.md transports | internal/mcp/manager.go dial switch |
docs/tools.md built-ins | internal/tool/builtin/registry.go plus runtime tools in internal/cli |
Also bump [Unreleased] in CHANGELOG.md for
user-visible doc or behaviour changes.
CI
The GitHub Actions workflow in
.github/workflows/ci.yml runs:
- Lint:
make lint(installs the version in.golangci-version). - govulncheck:
make govulncheck(pin in.govulncheck-version). - Test (Linux + macOS + Windows matrix):
make vendor-verify,make vendor-sync(Ubuntu only),make build-check,make test(includesinternal/snapshotwith-race; no extra snapshot job),make cover-ci(Ubuntu only; snapshot packages omitted). Windows runs the same unit/integration suite; PTY/creack/ptye2e (make e2e-mock-pty) stays Unix-only, and bash-tool tests that need/bin/shskip on Windows. - E2E (mock provider):
make e2e-mock. - Binary size check:
make binary-size VERSION=ci, fails if the stripped binary exceeds 30 MB. This usesCGO_ENABLED=0, matching releases.
PRs that fail any job are blocked.
A second workflow,
.github/workflows/pages.yml, builds
and publishes the documentation site (see below) to GitHub Pages on
every push to main that touches README.md, docs/, website/,
or any of the root meta-files.
.github/workflows/scorecard.yml
runs OpenSSF Scorecard on main
(and weekly). Results go to GitHub code scanning. Checks this
repository does not treat as merge gates: Branch-Protection
(optional for a single maintainer; enable GitHub branch protection when
you want the check) and any Scorecard probe that needs org-level
settings this project does not control. SHA-pinned Actions, SECURITY.md,
and CODEOWNERS are the checks we do control.
Documentation site
The website at
daniilperestoronin.github.io/ulmi
is a Hugo static site that consumes the canonical
Markdown stored at the repository root — README.md becomes the
homepage, docs/ becomes the documentation tree, and LICENSE.md,
CHANGELOG.md, and CONTRIBUTING.md are exposed at their own routes.
There is no duplicated content: the site uses Hugo Modules mounts to pull those files into the build, and the Hextra theme renders them.
Local development:
# One-time: fetch the Hextra theme module.
cd website && hugo mod get -u && cd -
make site-serve # http://localhost:1313/ulmi/
make site-build # writes website/public/
make site-clean # remove generated artifactsHugo Extended ≥ 0.140 is required (the macOS Homebrew formula hugo
ships an extended build by default; on Linux use the _extended_
release asset). The CI workflow pins the version via the
HUGO_VERSION env var in pages.yml.
To change the order of pages in the docs sidebar, adjust the weight
field in the frontmatter of docs/*.md. To change the navigation bar,
edit [menu] in website/hugo.toml.
Contributing
The contributor workflow — branching, commit style, PR expectations — is
documented in CONTRIBUTING.md. Report
security-sensitive bugs privately via SECURITY.md,
not a public issue. Coding standards for humans and coding agents are in
AGENTS.md. This page focuses on the technical setup.
License
The project is MIT-licensed. See LICENSE.md.