Skip to content
jesusalcaladevPublic

About

A powerful AI coding agent fasted & lightweight. Built for the terminal.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

zode

A terminal code agent written in pure Zig (no libc, no C dependencies; the only external one is libvaxis, also pure Zig).

  • ~1.3 MB stripped binary, ~6 MB RAM, all code in one directory.
  • Not a wrapper around another agent: it speaks HTTP with the provider, runs tools on your machine, and decides which tool to call next.
$ zode
######  ####  ####   ######
##  ## ##  ## ##   # ##
   ##  ##  ## ##   # ###
  ##   ##  ## ##   # ##
######  ####  ####   ######
────────────────────────────────────────

Install

The fastest way is the installer script, which downloads the latest release binary for your platform (Linux x86_64 / aarch64, macOS x86_64 / aarch64) and places it in ~/.local/bin:

curl -fsSL https://github.com/jesusalcaladev/zode/releases/latest/download/install.sh | bash

With options:

curl -fsSL https://github.com/jesusalcaladev/zode/releases/latest/download/install.sh | bash -s -- --version v0.1.0 --install-dir ~/.local/bin

The script is also shipped in the repo as install.sh and is attached to every GitHub release by CI. After installing, make sure ~/.local/bin is in your PATH:

export PATH="$HOME/.local/bin:$PATH"

Updating

zode checks for a newer release in the background and, when there is one, says so in the conversation:

zode v0.2.0 is available (minor) · /update installs it

/update downloads the release asset, runs it once to prove it works on this machine, verifies --version, refuses to go backwards, writes {exe}.new, then atomically renames over. Restart zode afterwards.

The check is cached in ~/.cache/zode/update.json for six hours. ZODE_NO_SELF_UPDATE=1 disables it; ZODE_AUTO_UPDATE=1 installs without asking.


Build from source

Requires Zig 0.17.0 (the only dependency besides libvaxis, fetched by build.zig.zon).

git clone https://github.com/jesusalcaladev/zode.git
cd zode
zig build -Doptimize=ReleaseSmall   # ~1.3 MB stripped binary
./zig-out/bin/zode                  # TUI
./zig-out/bin/zode --chat "your task"   # headless agent
./zig-out/bin/zode --models         # list available models

Build flags

Flag Default Meaning
-Doptimize=ReleaseSmall yes Optimized for size (~1.3 MB). Recommended for distribution.
-Doptimize=ReleaseSafe Optimized for safety (~2.2 MB).
-Doptimize=Debug No optimizations, symbols included (~6–8 MB).
-Dstrip=true yes Removes debug sections. Production builds.
-Dstrip=false Keeps symbols. Use only with -Doptimize=Debug.
-Dcpu=baseline Required for any binary you distribute. Without it the binary targets this machine's CPU and older hardware gets Illegal instruction.
-Dversion=v0.1.0 Embeds a version string (--version).

Common combinations:

# Production (recommended)
zig build -Doptimize=ReleaseSmall -Dcpu=baseline

# Production with debug symbols
zig build -Doptimize=ReleaseSafe -Dstrip=false -Dcpu=baseline

# Development
zig build -Doptimize=Debug -Dstrip=false

Quick start

Configure (optional — uses the OpenCode free tier by default):

export ZODE_API_KEY="your-key"
export ZODE_PROVIDER="openrouter"   # opencode | openrouter | anthropic | openai | groq | deepseek | …

Run:

./zig-out/bin/zode                  # TUI
./zig-out/bin/zode --chat "refactor the read cache to use a sliding window"   # headless
./zig-out/bin/zode --resume         # reopen the most recent session
./zig-out/bin/zode --models         # list available models
./zig-out/bin/zode --chat "/context" # headless with a slash command

Supported providers include opencode, openrouter, anthropic, openai, groq, deepseek, mistral, command-code, github-copilot, xai, zai, zai-coding, nvidia, and local (Ollama / LM Studio, no key). Keys are resolved in this order:

  1. ~/.config/zode/auth.json — what you typed in /connect (0600, wins over env).
  2. The provider's own variable (ZODE_OPENROUTER_KEY, ZODE_ANTHROPIC_KEY, …).
  3. ZODE_API_KEY — the generic fallback.

See docs/settings.md for the full provider table and config.json schema.


What's new / key behavior

  • Staged task pipeline (/pipeline <task>): a fixed, harness-owned flow — evidence → (investigator when needed) → implement → tester → verify → review — so the model cannot skip verification stages. The harness detects and runs the project's test suite, and refuses to weaken or delete existing tests (Zig inline tests are re-hashed and enforced). /code-review [paths] runs the read-only review stage on the diff or specific files. Control with ZODE_PIPELINE=auto|off|always; artifacts land in .zode/pipeline/<id>/. Say "omit tests" or "omit review" in the task to skip those stages.
  • Long sessions stay usable (recoverable results + compaction v2): oversized tool results spill to session-isolated files with recoverable read path= notices and per-tool/aggregate caps. Compaction defaults to elide (Tier 1) and supports v2 guarantees: recoverable microcompaction markers, resume boundaries (trimToBoundary), preserved skills/read context and critical markers, and a summarizer circuit breaker. full summarization is opt-in (never at 256k+ windows). Check /context for the live budget/state.
  • Permissions, hooks, and bash safety: Tool(pattern) rules (project .zode/permissions.json / user rules) decide allow/deny/ask with clear precedence; project command hooks in .zode/hooks.json (PreToolUse/PostToolUse/UserPromptSubmit/Stop, matcher/if/timeout/once) can block or annotate tool flow; bash is classified before asking, with sandbox offers for flagged commands when available.
  • Background tasks that notify on completion: long commands run in the unified background task registry with session-isolated file-backed output and incremental bash_output polling. When a task finishes or is killed, the harness injects a one-time system event so the model learns without polling.
  • Mascot (Zo): the footer mascot reflects real harness state and, during a pipeline, the active stage (exploring/investigating/implementing/testing/verifying/reviewing) so progress is visible instead of ambiguous.

Documentation

File For
README.md Install, quick start, key behavior, verification, contributing
docs/settings.md All environment variables, config.json, key precedence, token budget
docs/commands.md Every slash command and what it does
docs/usage.md How to use zode, end to end (run → model → task → verify)
docs/architecture.md How streaming, compaction, permissions, subagents, MCP, self-update work
docs/releasing.md Release/beta runbook: tag, publish, install pinned builds
docs/RULES-ZODE-TUI.md TUI/runtime invariants (required reading before changing the TUI)
AGENTS.md Code conventions for contributors and AI coding agents

Load a .env without exporting every line by hand:

set -a && source .env && set +a

Session file format

Sessions are append-only JSONL in ./sessions/zode-<id>.jsonl. Lines of 512 bytes or more are compressed with raw DEFLATE level 9 and base64-encoded (z prefix marker). Compaction never touches session files: what the context window drops, the file keeps.

A <session>.meta.json sidecar holds structural title keys:

  • custom_title — set by /rename; never overwritten by the AI.
  • ai_title — generated by the AI at turn 3; ephemeral, safe to regenerate.

Title resolution order: custom_title > ai_title > name > session id.


ACP (Agent Client Protocol)

zode can run as a general ACP agent over stdio (JSON-RPC 2.0, one message per line):

zode acp
# or
zode --acp
  • stdout is reserved for ACP protocol messages; logs go to stderr.
  • Supports v1 initialization, session/new, session/load (replays history), session/resume, session/list/close/delete (best-effort), session/prompt with streaming session/update chunks, tool call updates, agent→client session/request_permission, and cancellation.
  • allow_always / reject_always permission decisions are persisted as scoped user rules in ~/.config/zode/permissions.json (dangerously broad allow patterns are refused).

Example editor/client config (generic ACP stdio agent):

{
  "agent": {
    "command": "zode",
    "args": ["acp"]
  }
}

Configure provider/model the same way as normal zode usage (ZODE_PROVIDER, ZODE_API_KEY/provider key env, ZODE_MODEL, or ~/.config/zode/config.json).


Verification workflow

  • zig build test — the primary gate (2000+ tests).
  • tools/pty_smoke.py — real pty smoke test (startup, banner, input, scroll, no panic).
  • zig build ui-frame — design harness: renders scenes with real drawFn + Model.
  • zig build debug — must produce symbolized binary (.symtab, .debug_info).
  • zig build roster-probe — verifies free model pool before rotation.

Contributing / public repo files

This repo is under MIT (LICENSE). If you open a PR, confirm zig build test passes and that the change respects the pure Zig std rule.

About

A powerful AI coding agent fasted & lightweight. Built for the terminal.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages