Prerequisites
Before building Enki from source, ensure you have the following installed:- Rust - Required for building the project (2024 edition)
- Git - For version control
- Node.js - Used to install and run the ACP agent
- Claude Code - The agent that Enki orchestrates
- just (optional) - Command runner for convenience
Getting Started
Workspace Structure
Enki is a Rust workspace with four crates following strict dependency direction:cli → tui, acp, core. No cycles.
| Crate | Path | Role |
|---|---|---|
core | crates/core | Pure synchronous state machines: Orchestrator, DAG scheduler, SQLite persistence, CoW copy manager, git merge refinery, roles, hashlines. Zero async, zero tokio. |
acp | crates/acp | Async ACP client. Spawns agent subprocesses, manages sessions, routes streaming updates. All internal state is Rc<RefCell<...>> — !Send, must run on a LocalSet. |
tui | crates/tui | Sync terminal UI library over raw crossterm (not ratatui). Chat framework via Handler<M> trait. Optional markdown feature for termimad+syntect rendering. |
cli | crates/cli | The enki binary. No args → TUI. enki mcp → JSON-RPC stdio server. Houses the coordinator loop (tokio::select! on a dedicated OS thread with current_thread runtime + LocalSet). |
Just Commands
The project includes ajustfile for common development tasks:
Running Tests
Core functionality has inline unit and integration tests:Development Workflow
Making Changes
-
Edit code in the appropriate crate based on what you’re changing:
- State machine logic →
crates/core - ACP client functionality →
crates/acp - Terminal rendering →
crates/tui - CLI commands or coordinator →
crates/cli
- State machine logic →
-
Run tests to verify your changes:
-
Test locally by running the binary:
Build Artifacts
Release builds are optimized with:- Symbol stripping (
strip = true) - Link-time optimization (
lto = true)
Cargo.toml profile settings for details.
Environment Variables
Enki uses several environment variables during operation:| Variable | Purpose |
|---|---|
ENKI_BIN | Path to own binary, injected into all subprocesses |
ENKI_DIR | Project .enki/ directory for DB + signal files |
ENKI_SESSION_ID | Scopes MCP tool results to current session |
CLAUDECODE | Cleared on agent spawn to prevent nested-session refusal |
Project Directory (.enki/)
When you run Enki in a project, it creates a .enki/ directory:
Logs
Development and debugging logs are stored in:-
Main log:
~/.enki/logs/enki.log- Sessions separated by
══════════════════ SESSION START ══════════════════ - Most recent session is at the bottom
- Sessions separated by
-
Per-agent logs:
~/.enki/logs/sessions/<label>.log- Timestamped JSON-RPC traffic
ERROR= failuresINFO= lifecycle eventsDEBUG= subprocess args, copy paths, prompt sizes, session kills
Next Steps
Testing
Learn about testing patterns and debugging strategies
Architecture Deep Dive
Understand the internal architecture and design patterns
