Skip to content

Development & Coding Standards

Welcome! This guide covers what you need installed to build Hya locally and the engineering rules that keep the codebase clean and reliable.


1. Prerequisites & first build

  • Rust 1.100.1 (pinned in rust-toolchain.toml with rustfmt and clippy; workspace MSRV is 1.91, Rust edition 2024, Cargo resolver 3)
  • Bun 1.4.2+ (runs packages/hya-tui, packages/hya-tui-web, packages/hya-tui-sdk, and the Bun/Claude plugin adapters)
  • Git (plus standard C/OpenSSL build headers on Linux: build-essential pkg-config libssl-dev)

Clone and build a working local hya binary + TUI in four commands:

Terminal window
git clone https://github.com/chrono-foundry/hya.git
cd hya
(cd packages/hya-tui && bun install --frozen-lockfile)
(cd packages/hya-tui-web && bun install --frozen-lockfile)
cargo build-core
# Launch your local debug build!
./target/debug/hya

2. Developing against installed bundles

cargo build-core builds the core host binary (target/debug/hya). Official first-party bundles live in chrono-foundry/hya-bundles and are installed from the static registry into your user registry (~/.local/share/hya/bundles/registry.sqlite3).

With a matching host ABI, install the official profile and select the subset you need:

Terminal window
cargo build-core
./target/debug/hya abi info --json
./target/debug/hya bundle install --profile default -y
./target/debug/hya --bundles workflow,tui,provider-openai

CI runs cargo run -p xtask -- check-abi to check the Native ABI v2 contract against abi-contract.lock. For an intentional contract change, advance the ABI version and run cargo run -p xtask -- update-abi-lock, then commit the refreshed lockfile. See the release guide.

If your local branch changes the Native ABI v2 digest, generate a matching four-crate ABI SDK archive and build your native bundle against it in the bundle repository:

Terminal window
cargo run --locked -p xtask -- package-abi-sdk --out dist-sdk

See Developing, Installing & Publishing Bundles, Native Bundle Runtime ABI v2, and Open Static Registry Protocol v1.

  • Core binary only (--bare):
    Terminal window
    cargo build-core
    ./target/debug/hya --bare --model hya/offline exec "hello"
  • Reuse prebuilt same-ABI libraries from another worktree or directory (HYA_PREBUILT_BUNDLES_DIR):
    Terminal window
    # Fresh local Cargo outputs in `target/debug/` still take priority;
    # unbuilt bundles fall back to the `:`-separated directories below.
    # Every loaded library still passes `hya_native_abi_v2` digest checks.
    HYA_PREBUILT_BUNDLES_DIR=/path/to/prebuilt-bundles \
    ./target/debug/hya --bundles full
  • Dev-only opt-in to skip missing native libraries (HYA_DEV_SKIP_MISSING_BUNDLES=1): Default startup is strictly fail-closed when an enabled native bundle library is missing. In non-installed Cargo dev layouts (never honored when running from <prefix>/bin/hya), setting HYA_DEV_SKIP_MISSING_BUNDLES=1 logs a warning and skips missing native bundles individually while still failing hard on ABI mismatches or registration errors:
    Terminal window
    HYA_DEV_SKIP_MISSING_BUNDLES=1 ./target/debug/hya --model hya/offline exec "hello"
  • Dev build profiles ([profile.dev] vs --profile dev-full): The workspace [profile.dev] uses slim debuginfo (debug = "line-tables-only", split-debuginfo = "unpacked", debug = 0 for third-party dependencies and build-overrides, with opt-level = 2 for sha2, base64, sevenz-rust2, and lzma-rust2) for fast links and small target/ footprints while preserving full Rust backtraces. When you need full DWARF variable inspection in gdb/lldb, pass --profile dev-full:
    Terminal window
    cargo build --profile dev-full -p hya-backend --bin hya

Interface reference

Surface Contract
Cargo alias cargo build-core cargo build -p hya-backend --bin hya (defined in .cargo/config.toml).
Global flag --bundles <SPEC> Supported on runtime-composing hya commands whose FlagCaps allow bundle selection, and propagated to auto-started daemons. Install the official default profile, then select from installed bundles using names, presets (static/presets, tui, providers), and negation (-<name>). Use --bare for zero bundles. See the CLI reference for prerequisite closure and precedence.
HYA_BUILTIN_BUNDLES Same <SPEC> grammar as --bundles. Precedence: --bare / --bundles > HYA_BUILTIN_BUNDLES > config.toml bundles.builtin.
HYA_PREBUILT_BUNDLES_DIR :-separated directories searched after fresh local Cargo outputs (deps/, <exe-dir>/, build/<pkg>/*/out/) and before staged .hyabundle packages. Subject to lockstep abi_digest_v2() verification.
HYA_DEV_SKIP_MISSING_BUNDLES 1 or true (non-installed Cargo dev layouts only; ignored in <prefix>/bin/). Skips AbiError::DisabledOrMissing per engine native bundle with a WARN log.

3. Core codebase rules

  1. No panics and complete doc comments in library crates (unwrap_used, expect_used, and missing_docs denied): Workspace lints forbid .unwrap(), .expect(), and undocumented public items in library code. Return typed errors (StoreError, CoreError, ToolError, ProviderError, HostError) instead of crashing the daemon. Binaries and tests may allow unwrap_used/expect_used locally where appropriate.
  2. Preserve single-source event sourcing: Never invent a second mutable read model in the server or TUI that can drift from event_log. Append durable events in hya-store and fold them through hya_proto::Projection (and bundle ProjectionReducers).
  3. Respect ring and core/bundle boundaries: Core crates (crates/) must stay free of bundle domain identifiers and outer-ring dependencies (enforced by cargo run -p xtask -- boundary-check and cargo test -p xtask via crates/xtask/boundary.toml). Keep hya-proto free of async runtimes, SQLite, or HTTP libraries, and keep hya-updater and hya-relay free of runtime crates (hya-engine, hya-app, hya-server).
  4. Reuse core planes & HostRuntime: Route core permissions, user prompts, skills, and URI handles through hya-tool’s core planes (PermissionPlane, InteractionPlane, SkillPlane, HandleRouter / UriSchemaPlane, and ExtensionPlanes), and route all native bundle storage, session, turn, model, event, and API operations exclusively through Arc<dyn HostRuntime> (crates/hya-runtime-abi). Never link hya-store, sqlx, hya-engine, hya-server, axum, or tonic inside a native cdylib bundle.
  5. One interactive frontend (packages/hya-tui): Never add a second terminal UI or move UI rendering into hya-server. Both the terminal TUI and browser WebUI share packages/hya-tui, packages/hya-tui-web remains a generic PTY host, and core shortcuts must stay browser-safe (never bind a core action only to Ctrl/Cmd+W, T, N, L, Tab, or Ctrl+Tab, which browsers intercept).

4. Multi-step task plans

For multi-step work, run python3 scripts/new-plan.py from the repository root to scaffold the shared Plan Template into the next git-ignored .plan/pN/task_plan.md Kanban board, and consult .agents/spec/ before editing backend layers.


5. Shipping features with documentation

Every new or changed user- or developer-facing feature ships with updated documentation in the same atomic change, covering an introduction, usage (with a short worked example), and exact interface definitions:

  • User-facing behavior & workflows: Update the matching short guide under docs/guide/ and exact flags/fields/keys in docs/reference/.
  • Bundle, Native ABI, Hook, TUI SDK, or /v2 API changes: Update docs/extend/ or docs/protocol/ (run cargo run -p xtask -- gen-api if proto/hya/v2/ changed, gen-schemas if Config v3 schemas changed, or gen-plugin if plugin hook wire types changed).
  • Internal engine, storage, or crate boundary changes: Update docs/architecture/ (and docs/architecture/codebase-map.md if crate roles or rings changed).

Keep user guides short, plain-spoken, and focused on tasks; put exhaustive schemas and flag tables in docs/reference/, docs/extend/, or docs/protocol/.


6. Formatting & quick local check

Before opening a PR or committing, check formatting across the Rust workspace and run Clippy + tests only for the crates/packages you touched (see Testing & Verification):

Terminal window
cargo fmt --all --check
cargo clippy -p <changed-crate> --all-targets -- -D warnings
cargo test -p <changed-crate>
cargo build-core