How ilearn-lab/evoharness works
1. What this repo is
EvoHarness is a Python-based terminal agent harness with an optional React/Ink TUI. It is not just a model wrapper: the repo centers on a workspace-native control system for commands, skills, agents, plugins, MCP servers, approvals, and long-horizon session state.
2. Startup and entrypoints
The runtime enters through evo_harness/__main__.py and src/evo_harness/cli.py, with utility scripts in scripts/ for specialized workbench modes. At launch, the harness resolves the current workspace, loads local settings, discovers registered surfaces, and then opens either the TUI or a text session fallback.
3. Core runtime control plane
The main orchestration layer lives under src/evo_harness/harness/. Modules such as session.py, conversation.py, commands.py, tasks.py, workflows.py, tools.py, and stream_events.py coordinate the live interaction loop: user input, tool calls, command dispatch, task execution, and streaming model output.
4. Provider boundary
Model access is isolated behind adapter modules in src/evo_harness/adapters/, especially claude_code.py and openharness.py. This is the boundary to external LLM backends and gateway styles; provider selection, base URL, and API-key handling are part of the runtime configuration rather than hardcoded app logic.
5. Workspace as product surface
The repository treats workspace files as first-class architecture. .claude/ contains commands, agents, skills, and agent workflows; .evo-harness/ contains runtime registries like settings.json, mcp.json, and marketplace.json; and plugins/ contains installable workflow bundles. Discovery and rendering of these surfaces are handled by harness/plugins.py, harness/skills.py, harness/agents.py, harness/slash_commands.py, and related registry modules.
6. Plugin ecosystem boundary
Each plugin under plugins/* is a self-contained bundle with its own .claude-plugin/plugin.json, optional .mcp.json, and local agents/, commands/, skills/, and hooks/ folders. Architecturally, plugins add new workflow families without changing the core harness. Examples include docs-foundry, workspace-ops, session-lab, safe-inspector, and delivery-lab.
7. MCP as an externalized service layer
The repo also ships local MCP servers in src/evo_harness/*_mcp_server.py and runtime support in harness/mcp.py, harness/mcp_runtime.py, and harness/web_research.py. These expose tools/resources/prompts for workspace docs, workspace intelligence, quality gates, session analysis, document automation, and web research. This is the main boundary for reusable external capabilities.
8. Approvals, permissions, and safety
Mutating actions are mediated by harness/permissions.py, harness/approvals.py, harness/hooks.py, and the approval-related command surfaces in the workspace. The runtime supports modes like read-only planning versus auto-execution, so safety is a first-class control path rather than an afterthought.
9. Memory, state, and persistence
Long-lived state is split across runtime memory and storage. harness/memory.py, harness/environment.py, harness/settings.py, and storage/ledger.py capture session context, workspace configuration, and historical records used for later review, promotion, or rollback. This is what makes the harness “long-horizon” rather than purely chat-session based.
10. Controlled self-evolution pipeline
The self-evolution subsystem is explicit in src/evo_harness/autonomous_evolution.py, core/analyzer.py, core/policy.py, core/validator.py, and the operator modules under src/evo_harness/operators/. The flow is evidence-driven: session traces or workspace state are analyzed, a policy chooses an operator such as revise-command, revise-skill, distill-memory, or grow-ecosystem, candidate changes are validated, and then they are promoted, held, or rolled back.
11. Frontend composition
The terminal UI in frontend/terminal/ is a thin presentation layer over the backend session. Components like ConversationView, PromptInput, StatusBar, ToolCallDisplay, and ModalHost, plus the useBackendSession hook, render the live harness state and stream events; they do not own the business logic.
12. How to think about the architecture diagram
A clean diagram for this repo should show three main zones: the runtime/control plane in src/evo_harness/harness and cli.py, the workspace surface in .claude/, .evo-harness/, and plugins/, and the execution/extensibility plane made of provider adapters, MCP servers, and evolution operators. Data flows from workspace discovery and user input into the session runtime, out to LLM providers and MCP services, and back through approvals, memory, and validation.
Main entry points: runtime.py Runtime · session.py Session · App.tsx Terminal UI · mcp_runtime.py MCP runtime
Components 34
Runtime control plane
Entrypoints and live session orchestration
- __main__ · Python package entrypoint for launching the harness
src/evo_harness/__main__.py - CLI · Command-line startup and mode selection
src/evo_harness/cli.py - Runtime · Coordinates session startup, workspace resolution, and backend wiring
src/evo_harness/harness/runtime.py - Session · Owns the live interaction lifecycle
src/evo_harness/harness/session.py - Conversation · Tracks message exchange and turn structure
src/evo_harness/harness/conversation.py - Commands · Resolves and executes slash commands and command surfaces
src/evo_harness/harness/commands.py - Tasks · Coordinates task execution and job flow
src/evo_harness/harness/tasks.py - Tools · Tool invocation and workspace actions exposed to the agent
src/evo_harness/harness/tools.py - Stream events · Streaming model and session events for the UI
src/evo_harness/harness/stream_events.py - Permissions · Checks whether actions are allowed
src/evo_harness/harness/permissions.py - Approvals · Manages approval workflows for mutating actions
src/evo_harness/harness/approvals.py
Workspace surfaces
Repo-local commands, agents, skills, and registries
- Plugins · Discovers installed plugin bundles and their surfaces
src/evo_harness/harness/plugins.py - Skills · Loads workspace and plugin skills
src/evo_harness/harness/skills.py - Agents · Loads agent definitions from workspace surfaces
src/evo_harness/harness/agents.py - Slash commands · Discovers command surfaces from workspace and plugins
src/evo_harness/harness/slash_commands.py - Workflows · Coordinates reusable workflow bundles
src/evo_harness/harness/workflows.py
Extensibility layer
LLM adapters, MCP services, and evolution pipeline
- Adapters · Provider abstraction for external model backends
src/evo_harness/adapters/__init__.py - Claude code · Adapter for Claude-style backend integration
src/evo_harness/adapters/claude_code.py - OpenHarness · Adapter for gateway-style or alternate backend integration
src/evo_harness/adapters/openharness.py - MCP runtime · Loads and serves MCP capabilities at runtime
src/evo_harness/harness/mcp_runtime.py - Workspace MCP · Workspace documentation and intelligence surfaces
src/evo_harness/workspace_docs_mcp_server.py - Quality gates · Quality and validation-oriented MCP surface
src/evo_harness/quality_gate_mcp_server.py - Web research · External research MCP surface
src/evo_harness/web_research_mcp_server.py - Evolution · Analyzes traces and proposes self-improvements
src/evo_harness/autonomous_evolution.py - Analyzer · Extracts evidence from traces and workspace state
src/evo_harness/core/analyzer.py - Policy · Selects the next operator or action
src/evo_harness/core/policy.py - Validator · Validates candidate changes before promotion
src/evo_harness/core/validator.py - Operators · Revision, growth, memory, and stop operators
src/evo_harness/operators/__init__.py
Terminal UI
React/Ink presentation over backend session state
- Terminal UI · Ink-based terminal application shell
frontend/terminal/src/App.tsx - Conversation view · Renders the live transcript
frontend/terminal/src/components/ConversationView.tsx - Prompt input · Captures user input and command entry
frontend/terminal/src/components/PromptInput.tsx - Status bar · Shows session and runtime status
frontend/terminal/src/components/StatusBar.tsx - Tool calls · Displays tool invocations and results
frontend/terminal/src/components/ToolCallDisplay.tsx - Backend hook · Connects UI to backend session state
frontend/terminal/src/hooks/useBackendSession.ts
Connections 35
- __main__ → CLI: start · Package entrypoint delegates to CLI startup
- CLI → Runtime: boot · CLI resolves workspace and launches runtime
- Runtime → Session: open · Runtime creates the active session
- Session → Conversation: manage · Session owns conversation state and turn flow
- Session → Commands: dispatch · Session routes command surfaces
- Session → Tasks: run · Session schedules task execution
- Session → Tools: invoke · Session exposes tools to the agent loop
- Session → Stream events: stream · Session emits live events to consumers
- Tools → Permissions: check · Tool actions pass through permission checks
- Tools → Approvals: approve · Mutating actions may require human approval
- Runtime → Plugins: discover · Runtime discovers plugin bundles and workspace surfaces
- Runtime → Skills: load · Runtime loads available skills
- Runtime → Agents: load · Runtime loads agent definitions
- Runtime → Slash commands: load · Runtime loads command surfaces
- Runtime → Workflows: load · Runtime loads workflow bundles
- Runtime → Adapters: provider · Runtime selects an LLM adapter boundary
- Adapters → Claude code: impl · Claude-style backend adapter
- Adapters → OpenHarness: impl · Alternate backend adapter
- Runtime → MCP runtime: serve · Runtime wires MCP services into the session
- MCP runtime → Workspace MCP: host · Serves workspace intelligence capabilities
- MCP runtime → Quality gates: host · Serves validation and quality capabilities
- MCP runtime → Web research: host · Serves web research capabilities
- Runtime → Evolution: evolve · Runtime can trigger the self-evolution pipeline
- Evolution → Analyzer: analyze · Pipeline inspects traces and workspace state
- Evolution → Policy: decide · Policy selects the next operator
- Evolution → Validator: validate · Candidate changes are validated before promotion
- Policy → Operators: choose · Policy routes work to evolution operators
- Validator → Approvals: gate · Validation results can feed approval decisions
- Stream events → Backend hook: bind · UI hook consumes backend events
- Backend hook → Terminal UI: render · UI shell consumes backend session state
- Terminal UI → Conversation view: show · Renders conversation transcript
- Terminal UI → Prompt input: capture · Accepts user prompts and commands
- Terminal UI → Status bar: status · Shows runtime state
- Terminal UI → Tool calls: inspect · Shows tool activity
- Runtime → CLI: fallback · CLI can choose terminal or text-session modes