Documentation

Building from Source

Clone, build, and run Nyzhi from source with standard Rust tooling.

Edit on GitHub

Nyzhi is a standard Rust project. Build it with cargo. Use this when you want to contribute, test unreleased changes, or run custom builds. For production installs, use the official installer or self-update.


Prerequisites

  • Rust 1.75+ — install via rustup.rs
  • A C linker — usually already present on macOS and Linux
  • No other dependencies. All Rust crates are fetched from crates.io.

Build

git clone https://github.com/nyzhi-com/code.git
cd code
cargo build --release

The binary is at target/release/nyz.

Debug build

cargo build
# Binary: target/debug/nyz

Debug builds are faster to compile but significantly slower at runtime.


Run

# Run directly
./target/release/nyz

# Or install to PATH
cargo install --path crates/cli

# Or copy to your nyzhi install directory
cp target/release/nyz ~/.nyzhi/bin/nyz

Workspace structure

The project is a Cargo workspace with six crates:

Cargo.toml              # workspace root
crates/
  cli/                  # nyzhi (binary: nyz)
  core/                 # nyzhi-core (agent, tools, sessions, etc.)
  provider/             # nyzhi-provider (LLM abstraction)
  auth/                 # nyzhi-auth (OAuth, API keys)
  tui/                  # nyzhi-tui (terminal UI)
  config/               # nyzhi-config (configuration loading)

Build a specific crate:

cargo build --release -p nyzhi        # just the CLI binary
cargo build --release -p nyzhi-core   # just the core library

Tests

# Run all tests
cargo test

# Run tests for a specific crate
cargo test -p nyzhi-core
cargo test -p nyzhi-tui
cargo test -p nyzhi-config

# Run a specific test
cargo test -p nyzhi-core -- commands::tests::expand_template

Test coverage

Tests exist in:

  • nyzhi-core: commands, workspace, context, hooks, keywords, memory, skills
  • nyzhi-tui: completion, export, theme, highlight
  • nyzhi-config: config loading and parsing

Some tests use tempfile for filesystem operations.


Linting

cargo clippy --all -- -D warnings

Formatting

cargo fmt --all
cargo fmt --all -- --check   # check without modifying

Cross-compilation

For cross-compiling to other targets:

# Install the target
rustup target add aarch64-apple-darwin

# Build
cargo build --release --target aarch64-apple-darwin -p nyzhi

For Linux cross-compilation from macOS (or vice versa), use cross:

cargo install cross --version 0.2.5
cross build --release --target aarch64-unknown-linux-gnu -p nyzhi

Supported targets

TargetOSArchitecture
x86_64-unknown-linux-gnuLinuxx86_64
aarch64-unknown-linux-gnuLinuxARM64
x86_64-apple-darwinmacOSx86_64 (Intel)
aarch64-apple-darwinmacOSARM64 (Apple Silicon)

Same targets as the official releasing pipeline.


Key dependencies

DependencyVersionPurpose
tokio1.xAsync runtime
reqwest0.12HTTP client (rustls-tls)
ratatui0.29Terminal UI framework
crossterm0.28Terminal input/output
clap4.xCLI argument parsing
serde1.xSerialization
syntect5.xSyntax highlighting
rmcp0.16MCP client
oauth25.xOAuth2 flows

See Cargo.toml for the complete dependency list.