Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AGENTS.md

Guidance for AI agents and human contributors working in the Vix repository. This file is the entry point; see agents/ for topic guides and index.md for the full documentation map.

Specification Driven Development

The spec/ directory is the source of truth.

  • Before doing anything, read every file in the spec/ directory.
  • Treat all files inside spec/ as strict requirements. Where any file disagrees with the spec, the spec wins: fix the file, or change the spec on purpose and bring the other files into line in the same commit.
  • Do not improvise structure, style, or citation practice.

Governance

Read AI_STATEMENT.md before doing anything outward-facing or hard to reverse (a force-push, publishing a release, publishing a package). It says what an AI agent is and isn’t pre-authorized to do here without asking first — the default is to confirm; standing exceptions are listed there and nowhere else. Two exceptions stand today: cargo publish, and judging that a specific release is ready (version/CHANGELOG.md correct, scripts/check green, scope complete) — an agent may decide that on its own rather than asking first. Neither extends to cutting a tagged release or creating a GitHub/GitLab/Codeberg Release; that’s still confirmed first.

Found a security vulnerability? See SECURITY.md — report it privately, not as a public issue.

What Vix is

Vix is a keyboard-friendly terminal text editor (a “Simple Terminal Rust IDE”), built on ratatui. It is a Cargo workspace (edition 2024): a thin App shell (package vix-tui in tui/, which builds the vix command; sources in tui/src/) — CLI, event loop, App state, rendering, explorer — over 148 focused vix-* member crates under crates/, including the custom editor widget vix-editor-core. tui/src/lib.rs re-exports the member crates under short module names (pub use vix_git as git;), so crate::git, crate::menu, crate::db still name them. The App shell’s two largest files are themselves split into submodules: tui/src/app.rs delegates most of its logic to tui/src/app/*.rs (keymap.rs, git.rs, org.rs, lsp_dap.rs, and others, one per feature area), and tui/src/ui.rs delegates most of its drawing to tui/src/ui/*.rs (choosers.rs, db.rs, edit_surfaces.rs, menu_bar.rs, and others). See docs/architecture/index.md.

Source of truth

Specs are the specification and the source of truth, and development is specification-driven. Each member crate owns its spec at crates/<crate>/spec/index.md (multi-topic crates add spec/<topic>/index.md); the repo-root spec/ holds only cross-cutting / app-level and build/meta specs (index, navigation, overlay-priority, tools, test, ci, comparisons, emacs-menus, license, trademarks, rust-msrv-n-minus-2, rust-clippy-pedantic, dependabot, …). When behavior and spec disagree, decide which is correct, then make them match — update the spec when intent changes, update the code when the code drifted. Keep specs and implementation in sync.

Specs are living documentation, so they are checked like code: scripts/check-docs fails on a broken link or path, on a crate with no spec, on a crate missing from the crate map, and on a README.md that has drifted from its index.md twin. Some documentation directories carry both names — index.md is what the doc map links, README.md is what a forge renders when you browse to the directory — and where both exist they must stay identical. Make README.md a symlink to index.md (ln -s index.md README.md), so they can’t drift apart; scripts/check-docs also accepts a real byte-identical copy, but every one currently in the repo is a symlink.

Build, test, lint

cargo build                 # build the vix binary + library
cargo test                  # integration + unit + doc tests (no terminal needed)
cargo clippy --workspace --all-targets -- -D warnings   # lints; kept clean
cargo run                   # run the editor in the current directory
cargo run -- --locale fr    # run in a specific language
cargo bench                 # Criterion benchmarks over the hot paths
cargo +nightly fuzz run <target>   # fuzz a pure core (see fuzz/README.md)
cargo run --manifest-path gui/Cargo.toml -p vix-gpui   # desktop GUI on GPUI (or -p vix-egui, vix-iced, vix-gtk4, vix-slint, vix-bui, vix-zgui; gui/spec/index.md)
scripts/check-docs          # documentation integrity (links, twins, crate specs)

Edition 2024. The toolchain floor is rust-version in Cargo.toml; the policy is current stable minus two, verified by CI — see spec/rust-msrv-n-minus-2/index.md. Syntax grammars are feature-gated: --features syntax-all for every grammar, --no-default-features for none.

scripts/check (or make check) runs the whole gate locally — fmt, build, clippy, tests, cargo doc, and the documentation checks. CI enforces the same gate on all three forges Vix is pushed to (GitHub, GitLab, Codeberg); when the gate changes, change every forge’s config with it. See spec/ci/index.md. scripts/check runs in a clean room (T764): it strips kache/sccache from PATH and RUSTC_WRAPPER and sets HOST_CC=cc HOST_CXX=c++ itself (opt out with VIX_CLEAN_ROOM=0; never hand-strip them), prints which environment it ran in, and wants one private CARGO_TARGET_DIR per concurrent gate/worktree, never a shared one (see spec/local-ci “Build caching”). scripts/check --tier fast|push|full (T760) picks how much to run while you iterate (fast: fmt, clippy and tests of changed crates; push: the whole workspace plus docs; full, the default, is the landing bar). Only the full tier proves a change is ready; the others print their own distinct OK (tier …) line, and every step reports its wall-clock time. scripts/attest (T761) runs the full tier and records a signed git note (refs/notes/vix-gate) for the tree; make hooks installs a pre-push hook that refuses main and tags without one (see spec/local-ci).

Hard rules enforced by the build

The root Cargo.toml sets unsafe_code = "forbid" and missing_docs = "deny" in [workspace.lints.rust] (and clippy::pedantic in [workspace.lints.clippy]); every crate opts in with [lints] workspace = true, so the policy covers libs, bins, tests, benches, examples and build scripts (T599). Therefore:

  • Every public item needs a doc comment. A new pub fn/struct/field without /// fails the build.
  • No unsafe.
  • clippy::pedantic is on everywhere through [workspace.lints] – no per-file attribute is needed. A new crate must carry [lints] workspace = true. allow_attributes_without_reason, redundant_clone, clone_on_ref_ptr (write Arc::clone(&x)), dbg_macro and todo are on too, so every #[allow(..)] needs a reason = "..". unwrap_used and expect_used are on too (tests exempt): prefer let Some(x) = .. else { return } and ?; use #[expect(clippy::expect_used, reason = "..")] only for provably safe sites. There is no blanket #![allow(clippy::pedantic)] and no #![allow(missing_docs)]; fix findings in code. Sanctioned allows are only a handful of targeted #[allow(clippy::too_many_lines)] / too_many_arguments on specific functions that resist further extraction — there is no standing #[allow(clippy::struct_excessive_bools)] anywhere in the codebase: T149 converted every bool-cluster struct (SearchBar, WorkspaceSearch, DblockParams, both Editors, and finally App and Settings themselves) to a bitflags-based Flags field instead. Prefer that over a new allow for a struct whose bools are independent, freely-combinable toggles.
  • Keep the tree clean: cargo clippy --workspace --all-targets -- -D warnings.

Non-negotiable conventions

  • Internationalize all user-facing text. Never hard-code a display string; add a key to the right crates/vix-i18n/locales/*.yml file and render it with t!. Data modules store i18n keys; the host translates. See docs/internationalization/.
  • One action, one implementation. Menu items, palette commands, and shortcuts all dispatch through App::run_action using string action ids (file.save, view.theme, …). Add the behavior there once.
  • Built-in themes are monochrome. One fg, one bg; emphasis via dim and full intensity (no bold or italic); reversed video only for selections and the cursor. Color belongs only to custom JSON themes. See docs/themes/index.md.
  • Keep the logic terminal-independent. Editing/state logic lives in the library and is tested without a TTY. Rendering lives only in tui/src/ui.rs.
  • Input dispatch is keymap-aware. Raw keys route through the active keymap (Apple / VSCode macOS / VSCode Windows / Emacs / Vi / Spacemacs / IntelliJ macOS / IntelliJ Windows / Eclipse / Sublime / Zed / Fresh / ttt / Helix) in App::on_key; keymaps translate keys into the same run_action calls and editor motions rather than duplicating behavior. On macOS, Command is folded into Control first, so every keymap sees a chord it already knows. See crates/vix-keymap-model/spec.
  • One ratatui version. The whole widget stack must agree on ratatui 0.30 / crossterm 0.29. Don’t add a widget crate on a different version.

Where things live

You want to…Go to…
Add or reorder a modal overlaythe OVERLAYS table in tui/src/app/overlays.rs (+ ui::draw_overlay); see spec/overlay-priority/index.md
Return an error from a library fna small #[non_exhaustive] error enum, not Result<_, String> (agents/conventions.md, T610)
Spawn a child processlist the site in tui/tests/spawn_sites.rs (T595) and gate it behind a capability feature
Print to stdout/stderrdon’t, in library code: use the message drawer; a real CLI channel goes in tui/tests/code_lints.rs (T833)
Add/route a commandtui/src/app.rs (run_action, dispatching into tui/src/app/*.rs), crates/vix-menu/, crates/vix-palette/
Change renderingtui/src/ui.rs, usually via one of its tui/src/ui/*.rs submodules
Add/translate UI textcrates/vix-i18n/locales/*.yml (+ t! at the call site)
Add a settingcrates/vix-settings/
Change the editor widgetcrates/vix-editor-core/ (engine reused; widget is Vix’s)
Change soft-wrap / bracket renderingcrates/vix-editor-core/src/wrap.rs, .../brackets.rs
Change theme colors/modelcrates/vix-theme/, crates/vix-theme-model/
Change available UI languagescrates/vix-locale-model/, crates/vix-i18n/
Change keyboard navigation stylescrates/vix-keymap-model/ + keymap dispatch in tui/src/app/keymap.rs
Change the calendarcrates/vix-calendar-panel/
Change spell checkingcrates/vix-spellcheck/ + wiring in tui/src/app.rs / tui/src/ui.rs
Change git status/diff/stagingcrates/vix-git/ + wiring in tui/src/app/git.rs / tui/src/ui/choosers.rs
Change the find/replace enginecrates/vix-find-panel/ (matches/replace_all/unescape/PathFilter)
Change LSP supportcrates/vix-lsp/ (host) + crates/vix-lsp-core/ (protocol)
Change branch review / rebase editorcrates/vix-review/ + tui/src/app/git_review.rs; crates/vix-git/ + tui/src/app/git_rebase.rs
Change the integrated terminalcrates/vix-terminal/ + tui/src/app/terminal.rs
Change project env (direnv/mise/venv)crates/vix-project-env/ + tui/src/app/project_env.rs
Change ghost-text completioncrates/vix-lsp/ (ghost) + crates/vix-ai-core/ (fim) + tui/src/app/ghost.rs, tui/src/ui/ghost.rs
Change the database workbenchcrates/vix-db/ (module tree + crates/vix-db/spec)
Change clipboard accesscrates/vix-clipboard/ (opt-in platform pasteboard)
Change terminal input (paste, modifiers)tui/src/main.rs (terminal modes) + App::on_paste / App::on_key
Change Org tables / column viewcrates/vix-org-table/, crates/vix-org/src/columns.rs, crates/vix-column-view/
Change file access / process spawning / remote editingcrates/vix-authority/ (the Authority trait: local, SSH, fake, remote agent) + tui/src/remote.rs, tui/src/app/remote_session.rs
Gate a capability at build timetui/Cargo.toml [features] + tui/src/capability.rs (see spec/cargo-features/index.md)
Change vix --mcpcrates/vix-mcp-server/ (protocol) + tui/src/mcp.rs
Change Cowork / IMcrates/vix-cowork*/, crates/vix-im*/ + tui/src/app/cowork.rs, tui/src/app/im*.rs
Change the Large File Viewercrates/vix-large-file/ + tui/src/app/large_file.rs
Add a benchmark or fuzz targettui/benches/, fuzz/fuzz_targets/ (see spec/test/index.md)

See agents/share/crate-map.md for the full map.

When to add a new crate (T151)

Vix is deliberately “crates, not modules” — but that doesn’t mean every new type earns its own crate. Before splitting something out (or leaving a recent split in place), it should clear a minimum-viable bar:

  • Own spec. crates/<crate>/spec/index.md, gated by scripts/check-docs.
  • Own tests, in some form. That can be #[cfg(test)] unit tests in the crate itself, or — for a crate whose only job is holding state the App shell drives via key/mouse events (a panel/dialog’s fields plus a few methods, no meaningful behavior outside that loop) — thorough coverage in tui/tests/integration/*.rs exercising the real App. The distinction is whether the crate has any logic worth testing in isolation; a bag of fields with no methods has none, no matter which layer tests it.
  • A consumer other than the App shell, or a clear reuse story. Either another crate already depends on it, or it is host-agnostic by design (no dependency on App or terminal I/O) even if only one host currently uses it — the same bar T152’s extractions were held to.

A crate that fails all three — no logic to test, no spec of its own worth maintaining, and no plausible consumer beyond the one struct field that holds it — should fold into its sole consumer instead (precedent: vix-projectile merged into vix-tasks the same day it was built, and T151 folding vix-query into tui/src/app.rs). A crate that’s merely small (under ~100 lines) but has real tests and a real reuse story is fine as is — vix-theme’s icon set and the single-format vix-convert-from-*-tool family are size-appropriate for what they do, not micro-crates in the guideline’s sense.

Making a change (checklist)

  1. Read the owning crate’s spec/index.md (or the cross-cutting root spec/); update it if intent is changing.
  2. Implement in the owning crate; keep editing logic out of tui/src/ui.rs.
  3. Internationalize any new text (YAML key + t!). Worldwide target: no feature may favor the US/UK; standards, locales and conventions must serve every country, region and federation equitably (spec/worldwide/index.md).
  4. Document every new public item (deny(missing_docs)).
  5. Add/extend tests (tui/tests/integration/main.rs or a module’s unit tests).
  6. Run the whole scripts/check gate (the local CI-parity gate; it ends with OK: … all passed, or OK (scope changed, …) when cargo doc and semver ran only on the changed crates and their dependents, which is the local default; CI runs the whole workspace with --scope all) before every commit you intend to land — not a hand-picked subset: cargo doc, the generated-reference diff and scripts/check-docs catch what clippy and the tests don’t.
  7. Note user-visible changes in CHANGELOG.md.
  8. Spelling: prose/docs are checked with CSpell (cspell.json); add project terms to the external dictionary project-words.txt.
  9. Land it on its own branch, merged --no-ff, from your own git worktree (several agents share this checkout); commits are SSH-signed and carry a Co-Authored-By: trailer. Details: agents/workflow.md.

Topic guides

The guides live in agents/ — lowercase, like every other directory here; only this entry-point file is uppercase, because agent tooling looks for that name (see spec/agents-directory-name-is-lowercase/index.md).