Overview
/docs/architecture
Architecture
Yoke (Yoke) — Architecture & Design
Yoke is an autonomous, agentic CLI coding framework written in Elixir on Erlang/OTP. It pairs powerful LLM reasoning (DeepSeek-V3 and DeepSeek-R1) with BEAM actor concurrency, hot-code reloading, distributed execution, and spatiotemporal state checkpoints.
High-Level Architecture Diagram
flowchart TD
User([User TTY Terminal]) <--> REPL[CLI.Repl / LineEditor / QuestionPrompt]
REPL <--> Brain[Brain.Session GenServer]
subgraph Brain Layer
Brain <--> Compressor[Brain.ContextCompressor]
Brain <--> Store[Brain.SessionStore]
Brain <--> Sup[Brain.SessionSupervisor]
Sup --> Subagent[Brain.Session Subagent Actor]
end
subgraph Hands Layer
Brain <--> HandsExec[Hands.Executor]
HandsExec --> Local[Local OS Execution]
HandsExec --> Remote[Remote Erlang Node via RPC]
HandsExec --> Docker[Docker Sandbox Container]
end
subgraph Knowledge Graph & MCP
Brain <--> MCPSrv[MCP.ServerManager]
MCPSrv <--> Ragex[Ragex Knowledge Graph Engine]
MCPSrv <--> ExtMCP[External MCP Servers over stdio]
end
Brain <--> APIClient[Client.DeepSeekAPI with Exponential Backoff Retry]
APIClient <--> API[DeepSeek API Endpoint]
subgraph Workflow Engine
Workflow[Workflow.Engine] --> WDef[Workflow.Definition]
Workflow --> WStore[Workflow.Store]
Workflow --> WSteps[Workflow.Steps.*]
WSteps --> Sup
WSteps --> GitMod[Git worktrees/branches]
end
REPL <--> Workflow
Core Components
-
Brain Layer (
lib/yoke/brain/
)
lib/yoke/brain/
)
-
Session(GenServer) : Manages conversation context state, model selection, permission authorization gates, temporal state snapshots, and turn execution loops. -
SessionSupervisor(DynamicSupervisor) : Dynamically spawns and monitors interactive user sessions and subagent worker actors. -
ContextCompressor: Summarizes long context histories when token limits or/compactcommands are triggered.
-
Hands Layer (
lib/yoke/hands/
)
lib/yoke/hands/
)
-
Executor: Dispatches tool calls across execution targets (:local,:remoteErlang nodes,:dockercontainer sandboxes). Enforces workspace sandbox bounds when/sandboxis enabled.
-
Knowledge Graph & MCP (
lib/yoke/mcp/
)
lib/yoke/mcp/
)
-
ServerManager: First-class supervisor for theRagexcode intelligence engine and external Model Context Protocol (MCP) servers over stdio JSON-RPC. Automatically builds dynamic Elixir tool modules for live hot-code tool access.
-
Client Layer (
lib/yoke/client/
)
lib/yoke/client/
)
-
DeepSeekAPI: Handles REST communications withdeepseek-chat(V3) anddeepseek-reasoner(R1) API endpoints with automatic exponential backoff retry for transient network and rate-limit HTTP errors.
-
CLI & TUI Layer (
lib/yoke/cli/
)
lib/yoke/cli/
)
-
LineEditor: Fixed bottom command bar TUI with horizontal ruler, grapheme-aware Unicode cursor navigation, and persistent history. -
QuestionPrompt: In-place interactive terminal modal for single-choice and multi-choice questions with multi-line text wrapping and pixel-perfect border alignment.
-
Workflow Engine (
lib/yoke/workflow/
)
lib/yoke/workflow/
)
-
Definition: Parses/validates customizable, JSON-defined multi-step workflows; two-tier discovery (workspace + global) plus bundled defaults (elixir), materialized on first use. -
Store: Disk persistence for workflow runs under.yoke/workflows/runs/-- resumable/ state.jsoncheckpoint plus an append-onlytranscript.jsonlof every prompt, response, confirmation, and command. -
Engine: Drives step execution/resume; a plain module (not aGenServer) that blocks the caller synchronously like a regular agent turn, delegating genuine parallelism to realBrain.Sessionprocesses for accepted subtasks. -
Steps.*: One module per step type (Branch,TaskDescription,TaskSplit,TestsAndDocs,Lint,Commit,Prompt) behind a commonWorkflow.Stepbehaviour.TaskSplitisolates parallel subtasks in their owngit worktreeso concurrent agents can never clash on disk. Seedocs/WORKFLOW_ENGINE.mdfor the full reference.