{
  "markdown": "# Daimonos\n\n[![CI](https://github.com/beardfaceguy/daimonos/actions/workflows/ci.yml/badge.svg)](https://github.com/beardfaceguy/daimonos/actions/workflows/ci.yml)\n[![Latest Release](https://img.shields.io/github/v/release/beardfaceguy/daimonos?display_name=tag)](https://github.com/beardfaceguy/daimonos/releases)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![MCP Registry](https://img.shields.io/badge/MCP-Registry-blue)](https://github.com/modelcontextprotocol/registry)\n\n**An agent-optimized OS layer that makes AI coding agents faster and cheaper.**\n\nDaimonos replaces the built-in file, search, exec, and git tools in your AI\ncoding agent with structured equivalents that return compact JSON instead of\nraw terminal output. The result: fewer tokens consumed, fewer round-trips, and\nlower API costs — with zero changes to your workflow.\n\n**Platforms:** Linux (x86_64, aarch64) and macOS (Apple Silicon, Intel).\nWindows support is [planned](https://linear.app/clawcorp/issue/CLA-302).\n\nFor repository agent/operator conventions, see `AGENTS.md` (especially\n**Daimonos tool usage policy**).\n\nThe name comes from Greek *daimon* (agent/spirit), the etymological root of\n\"daemon.\"\n\n## The problem\n\nWhen an AI agent runs `cargo test`, it gets back hundreds of lines of terminal\noutput — progress bars, compile messages, passing test names — when all it\nneeds is \"47 passed, 0 failed.\" The agent pays for every token of that noise:\nreading it, reasoning about it, and carrying it in context for the rest of the\nsession.\n\nThe same waste happens with `git status`, `docker ps`, `ls -la`, and every\nother shell command. Agents spend 30-50% of their token budget on verbose,\nunstructured tool output.\n\n## How it works\n\nDaimonos runs as an [MCP server](https://modelcontextprotocol.io/) that your\nIDE or CLI spawns automatically. It provides the same operations agents already\nuse — read files, write files, search, execute commands, git operations — but\nreturns compact, structured JSON instead of raw text.\n\nThe single binary also provides ACP, one-shot agent, interactive chat, and\nsocket-daemon runtimes — a full coding-agent harness in its own right; see\n[Agent harness features](#agent-harness-features) below and\n[Runtime modes](docs/runtime-modes.md) for the explicit subcommands and\ncompatibility aliases.\n\n```\nAgent: exec(\"cargo test\")\n\nWithout Daimonos (raw terminal output):\n   Compiling inventory v0.1.0 (/workspace)\n    Finished `test` profile [unoptimized + debuginfo] target(s) in 2.31s\n     Running unittests src/main.rs (target/debug/deps/inventory-abc123)\nrunning 47 tests\ntest config::tests::test_default ... ok\ntest config::tests::test_load ... ok\n... (200+ more lines)\ntest result: ok. 47 passed; 0 failed; 0 ignored\n\nWith Daimonos (structured JSON):\n{\"ok\":true,\"tests\":47,\"passed\":47,\"failed\":0,\"failures\":[]}\n```\n\n### Four layers of optimization\n\n1. **Native tool plugins** — `git`, `cargo`, `gh`, and `docker` are exposed as\n   first-class MCP tools with structured JSON output. When agents call\n   `exec(\"cargo test\")`, Daimonos intercepts it and routes through the native\n   plugin instead.\n\n2. **Semantic output filters** — For commands without native plugins (pytest,\n   make, pip install, eslint, etc.), Daimonos applies semantic compression:\n   test runners return summary + failures only, build commands return \"ok\" or\n   just the errors, install commands return success/failure.\n\n3. **Protocol-level efficiency** — Read deduplication (re-reading an unchanged\n   file returns `{\"unchanged\":true}` instead of the full content), compact\n   field names, lazy tool exposure, batch operations, and a terse output\n   directive that cuts LLM prose by ~30%.\n\n4. **Managed subprocess execution** — Command output is bounded while it is\n   read instead of after full buffering. Daimonos owns Unix process groups,\n   retires descendants on cancellation or session shutdown, isolates child\n   environments through an explicit allowlist, and stores background output\n   in private bounded artifacts.\n\n## Benchmark results\n\nTested with Claude Opus 4.6 on identical coding tasks (read files, search code,\nedit, run tests, git operations):\n\n| Metric | Baseline | Daimonos | Savings |\n|--------|----------|----------|---------|\n| Output tokens | 5,842 | 3,198 | **-45.3%** |\n| Total tokens | 41,239 | 33,847 | **-17.9%** |\n| Tool calls | 17 avg | 14 avg | **-17.6%** |\n| Wall time | 42.1s avg | 35.2s avg | **-16.4%** |\n\nRemote benchmarks on AWS (same hardware, same model, same tasks) showed\n**20.3% cost reduction** and **14.0% faster** task completion.\n\n### SWE-bench Verified (mini) — three-way harness comparison\n\nFive instances from [swe-bench-verified-mini](https://huggingface.co/datasets/MariusHobbhahn/swe-bench-verified-mini),\nsame model (Claude Opus 4.8) across all three harnesses, each agent running\ninside the official SWE-bench Docker image for its instance (real test\nenvironment), scored with the official `swebench` evaluation harness:\n\n| Instance | daimonos tokens (LLM calls) | mini-swe-agent tokens (LLM calls) | cursor-agent tokens |\n|---|---:|---:|---:|\n| django__django-11815 | 54,755 (4) | 38,305 (9) | 113,242 |\n| django__django-12155 | 53,773 (4) | 33,095 (9) | 348,425 |\n| django__django-12708 | 88,765 (6) | 196,492 (22) | 451,349 |\n| sphinx-doc__sphinx-8035 | 172,729 (10) | 342,108 (30) | 930,495 |\n| sphinx-doc__sphinx-9367 | 66,812 (5) | 18,611 (6) | 230,223 |\n| **Total tokens** | **436,834** | **628,611** | **2,073,734** |\n| **Total wall time** | **84 s** | **247 s** | **279 s** |\n| **Resolved** | **5/5** | **5/5** | **5/5** |\n\nConclusions:\n\n- **Correctness parity**: all three harnesses resolved 5/5 at this sample\n  size, so daimonos's token savings did not cost any resolutions.\n- **daimonos was cheapest and fastest**: ~30% fewer tokens than\n  mini-swe-agent (the minimal open-source baseline) and ~4.8x fewer than\n  cursor-agent, with ~3x less wall time than either.\n- **Caveats**: n=5, and run-to-run variance is real (daimonos spent 503k\n  tokens on sphinx-8035 in an earlier identical-config run vs 173k here).\n  cursor-agent's total is mostly cache-read tokens billed at a fraction of\n  input price, so its raw token count overstates its relative cost.\n  Measured API spend for the batch (OpenRouter): daimonos $1.53,\n  mini-swe-agent $1.66; cursor-agent bills via Cursor's backend.\n\nSee [benchmarks/swebench/](benchmarks/swebench/) for the runners and\nmethodology.\n\n## 60-second demo\n\nUse this script for README readers, release notes, and social posts:\n\n```bash\n# 1) Install daimonos\ncargo build --release\nsudo cp target/release/daimonos /usr/local/bin/\n\n# 2) Configure your MCP client (example: Cursor)\n# .cursor/mcp.json -> command: daimonos, args: [\"--mcp\", \"-w\", \"/path/to/project\"]\n\n# 3) Ask your agent to run:\n# \"Run cargo test and summarize failures only.\"\n# \"Show git status as structured output.\"\n```\n\nWhat to highlight in the demo:\n- same workflows, less tool-output noise\n- structured responses instead of raw terminal spam\n- fewer tokens and fewer round-trips for common coding tasks\n\n## Quick start\n\n### Install\n\n**Pre-built binaries** (Linux and macOS):\n\n```bash\n# Linux x86_64\ncurl -L https://github.com/beardfaceguy/daimonos/releases/latest/download/daimonos-x86_64-linux.tar.gz | tar xz\nsudo mv daimonos /usr/local/bin/\n\n# macOS Apple Silicon\ncurl -L https://github.com/beardfaceguy/daimonos/releases/latest/download/daimonos-aarch64-macos.tar.gz | tar xz\nsudo mv daimonos /usr/local/bin/\n```\n\n**From source:**\n\n```bash\ngit clone https://github.com/beardfaceguy/daimonos.git\ncd daimonos\ncargo build --release\nsudo cp target/release/daimonos /usr/local/bin/\n```\n\nSee [docs/install.md](docs/install.md) for all platforms (ARM Linux, Intel Mac,\nmusl static builds).\n\n### Configure your IDE\n\nFor most users, start with one of these:\n\n- **Cursor**: [Cursor IDE setup](docs/cursor-setup.md)\n- **Zed**: [Zed setup](docs/zed-setup.md)\n- **Claude Code**: [Claude Code setup](docs/claude-code-setup.md)\n\nAdd Daimonos as an MCP server. For **Cursor**, add to your project's\n`.cursor/mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"daimonos\": {\n      \"command\": \"daimonos\",\n      \"args\": [\"--mcp\", \"-w\", \"/path/to/your/project\"]\n    }\n  }\n}\n```\n\nThat's it. Daimonos starts when your IDE opens the project and exits when you\nclose it. No daemon to manage, no background service.\n\n### Setup guides for other tools\n\n- [Cursor IDE](docs/cursor-setup.md)\n- [GitHub Copilot](docs/copilot-setup.md) (VS Code, Visual Studio, JetBrains, Xcode, Eclipse)\n- [Claude Code](docs/claude-code-setup.md) (CLI + macOS Desktop app)\n- [Windsurf](docs/windsurf-setup.md)\n- [Cline](docs/cline-setup.md) (VS Code extension)\n- [Gemini CLI](docs/gemini-cli-setup.md)\n- [Zed Editor](docs/zed-setup.md)\n- [Discord integration](docs/discord-setup.md) (bot token, allowlists, read-only tools)\n- [Other tools](docs/other-tools-setup.md) (Claude Desktop, ChatGPT, Continue.dev, BoltAI, etc.)\n\n## What's included\n\n### Core tools (always available)\n\n| Tool | What it does |\n|------|-------------|\n| `read_file` | Read with optional offset/limit, content-hash deduplication |\n| `write_file` | Write with auto-mkdir |\n| `edit_file` | String replacement with diff confirmation |\n| `search` | Regex search (content mode) or file discovery (file mode) |\n| `exec` | Run commands with semantic filtering, bounded capture, and owned teardown |\n| `batch` | Multiple operations in a single round-trip |\n| `workspace_info` | Project type, git status, directory listing, analytics |\n\n### Native tool plugins (auto-detected)\n\nThese appear automatically when the corresponding CLI tool is found on PATH:\n\n| Plugin | Commands | Detected by |\n|--------|----------|-------------|\n| `git` | status, log, diff, branch, add, commit, push, pull, checkout | `.git` directory |\n| `cargo` | test, build, check, clippy, fmt, add | `Cargo.toml` |\n| `gh` | pr_view, pr_list, pr_create, pr_diff, pr_checks, api | `gh` on PATH |\n| `docker` | ps, logs, exec, images, inspect, stop, compose_up/down/ps | `docker` on PATH |\n\n### Additional capabilities\n\n- **Workspace snapshots** — Checkpoint before risky edits, rollback on failure\n- **Starlark scripting** — Bundle multiple tool calls into a single script\n- **Token analytics** — Per-tool-call tracking with cross-session history (`daimonos --stats`)\n- **Background processes** — Start, poll, and stop long-running commands with\n  admission limits, private bounded logs, and descendant cleanup\n- **Configurable** — All tunables in a single [TOML config file](docs/configuration.md)\n\n### Managed process lifecycle\n\nRaw `exec`, background jobs, and CLI plugins (`cargo`, `git`, `gh`, `docker`,\n`npm`, `pytest`, `curl`, and `shellcheck`) share one managed execution layer:\n\n- **Streaming-time bounds** — stdout and stderr retain UTF-8-safe head/tail\n  previews without first allocating the complete output\n- **Process-group ownership on Unix** — cancellation and shutdown send TERM,\n  wait a configurable grace period, then escalate to KILL and reap descendants\n- **Secure background artifacts** — random exclusive `0600` files under a\n  private `0700` directory, with configurable byte and job-count limits\n- **Environment isolation** — children inherit only configured parent\n  variables plus explicit session, tool, and per-call overrides; provider and\n  MCP credentials are not ambiently leaked\n- **Structured-output integrity** — plugins reject truncated JSON rather than\n  reporting an incomplete result as valid\n\n## Agent harness features\n\nBeyond the MCP server, the same binary is a complete coding-agent harness:\nan interactive terminal UI (`daimonos agent`), an ACP backend for Zed, a\none-shot CLI, and a session daemon with attach/detach and remote control.\n\nMany of its recent features come from a systematic study of 60+ open-source\nagent harnesses (Aider, OpenHands, SWE-agent, Goose, OpenCode, Forge, Pi,\nthe Cline family, and others) — mining the ecosystem for proven techniques\nand adapting the best ones.\n\n### Provider resilience — a hiccup never kills the turn\n\n- **Bounded provider retries** with backoff for transient failures (429/5xx/\n  network), classified at the provider boundary — fatal auth/validation\n  errors surface immediately\n- **Automatic model failover** — on a sustained overload the turn continues\n  on the next model in the chain, then returns to your preferred model on\n  the next turn\n- **Turn-level error resume** — when retries and failover are spent, the\n  agent pauses, repairs the conversation (keeping partial streamed output),\n  and continues where it left off; recovery actions surface in the UI\n- **Retry-storm detection** — fingerprints repeated identical tool calls and\n  steers the model out of loops\n- **Orphan tool-call repair** — max-token truncation mid-tool-call is\n  repaired instead of poisoning the session\n\n### Multi-provider sessions\n\n- **Several providers, one session** — configure Anthropic, OpenAI, and\n  OpenRouter side by side (`DAIMONOS_AGENT_<NAME>_API_KEY`); every call is\n  routed to the right provider by model, with an explicit `provider:slug`\n  override\n- **Live model discovery** — at startup the configured provider(s) are\n  queried for their full model catalogs; the model picker and failover\n  chain always reflect what is actually served, newest first\n- **Cross-provider failover** — with more than one provider configured, an\n  outage at one can fail over to models at another, mid-turn\n- **Provider-reported context windows** — compaction thresholds derive from\n  the live model metadata instead of hardcoded numbers\n\n### Context economy at the harness level\n\n- **Conversation compaction** — summarize-and-continue with high/low\n  water-mark thresholds and provider-honest token accounting\n- **Bounded tool results** — oversized tool output is capped at the dispatch\n  boundary and offloaded to files the agent can re-read selectively\n- **Reverse-budget pruning** — old tool results shrink before new ones, so a\n  long turn keeps its recent working set sharp\n- **Distilled working memory** — durable facts/snippets/notes that survive\n  compaction, separate from the transcript\n- **Resilient edit matching** (mined from Aider) — whitespace-tolerant\n  search/replace cuts failed-edit retry costs\n- **Batched scripting** — the agent is steered to bundle multi-step tool\n  work into single Starlark scripts (~2.2x cost lever, benchmarked)\n\n### Session durability and control\n\n- **Per-turn workspace checkpoints** — automatic snapshots with diff/compare\n  and code-only restore\n- **Daemon-owned sessions** — detach from a running agent, reattach later\n  (or from another terminal), with a reconnect event ring and canonical\n  snapshot recovery\n- **Persistent terminal UI** — streaming output, tool-lifecycle cards,\n  approval modal, model/usage status bar, and vim-style scrollback\n- **Remote control** — paired Android controller over an authenticated WSS\n  gateway\n- **Subagent delegation** — drive external ACP agents (cursor-agent,\n  codex-acp, …) as delegated workers\n- **Thought capture** — opt-in local persistence of streamed model reasoning\n  for later inspection\n\nAgent-mode configuration lives in a dotenv-style `agent.env`\n(`~/.config/daimonos/agent.env`); see [Runtime modes](docs/runtime-modes.md).\n\n## Architecture\n\nDaimonos is a single Rust binary with two planes that share one tool\nimplementation, one opcode protocol, one config, and one analytics store:\n\n1. **Tool server** — speaks [MCP](https://modelcontextprotocol.io/) over\n   stdio (or a Unix socket) to an external agent. Your IDE spawns it as a\n   subprocess — no network, no containers, no setup beyond a JSON config\n   entry.\n2. **Agent harness** — runs the agent loop itself, dispatching those same\n   tools in-process (no MCP hop) and talking to LLM providers directly.\n\n### Tool-server plane\n\n```\n┌──────────────┐     MCP (JSON-RPC over stdio)     ┌─────────────────┐\n│  AI Agent    │ ◄──────────────────────────────► │   Daimonos      │\n│  (Cursor,    │                                    │                 │\n│   Copilot,   │     Structured JSON responses      │  ┌───────────┐ │\n│   Claude,    │ ◄──────────────────────────────── │  │ File ops  │ │\n│   etc.)      │                                    │  │ Search    │ │\n│              │                                    │  │ Exec      │ │\n│              │                                    │  │ Git       │ │\n│              │                                    │  │ Cargo     │ │\n│              │                                    │  │ Docker    │ │\n│              │                                    │  │ GitHub    │ │\n│              │                                    │  │ Snapshots │ │\n│              │                                    │  │ Analytics │ │\n└──────────────┘                                    │  └───────────┘ │\n                                                    └─────────────────┘\n```\n\nUnder the hood, Daimonos uses an opcode-based protocol where each operation\nhas a numeric identifier and compact field names (`c`, `p`, `s`, `n`) to\nminimize token overhead. The MCP layer translates between standard JSON-RPC\nand the internal opcode format.\n\n### Agent-harness plane\n\n```\n┌────────────────────────────────────────────────────────┐\n│  Frontends: TUI · ACP (Zed) · one-shot CLI · chat REPL │\n│             session daemon (attach/detach, Android)    │\n├────────────────────────────────────────────────────────┤\n│  Shared session core: agent loop · canonical events    │\n│  compaction · tool-result bounding · working memory    │\n│  checkpoints · approvals/safety policy                 │\n├────────────────────────────────────────────────────────┤\n│  Provider layer: retries · model failover · resume     │\n│  multi-provider router (routes each call by model)     │\n│     ├─ Anthropic adapter                               │\n│     ├─ OpenAI adapter                                  │\n│     └─ OpenRouter adapter                              │\n└────────────────────────────────────────────────────────┘\n```\n\nEvery frontend drives the same transport-independent session core, so a\nconversation started in the TUI can detach to the daemon and be reattached\nfrom another terminal or a paired phone. Provider adapters own all\nprovider-specific wire format and error classification; everything above\nthem sees one `LlmProvider` interface and plain model strings — which is\nwhat makes failover, live model discovery, and multi-provider routing\ncomposable rather than special-cased.\n\n## Project vision\n\nDaimonos is being built in three phases:\n\n### Phase 1: User-space MCP server + agent harness (current)\n\nA Rust binary that runs on any Linux or macOS machine, in two roles that\nprove out the same protocol design and structured I/O patterns:\n\n- **Tool server** for third-party agents (Cursor, Copilot, Claude Code,\n  Zed, …) via MCP — the original phase-1 deliverable.\n- **Agent harness** in its own right: interactive TUI, ACP backend for\n  Zed, one-shot CLI, and daemon-owned sessions with remote attach — with\n  multi-provider routing, model failover, compaction, and per-turn\n  checkpoints built in (see [Agent harness\n  features](#agent-harness-features)).\n\n**Status: Production-ready.** Both roles are used daily for real development\nwork — including developing Daimonos itself. Pre-built binaries available\nfor Linux (x86_64, aarch64, musl) and macOS (Apple Silicon, Intel).\n\n### Phase 2: Minimal Linux distro\n\nA purpose-built Buildroot Linux image with Daimonos as the primary user-space\napplication. Designed for cloud deployment where AI agents need a clean,\nminimal environment. The distro boots in seconds, has no shell or human-facing\nUI, and runs the Daimonos daemon as PID 1's direct child. The session daemon\nand remote-control gateway from phase 1 are the intended tenants: headless\nagent sessions in the cloud, attached to from a terminal or phone.\n\n**Status: Working prototype.** Boots in QEMU, deployable to AWS EC2. Used for\nremote benchmarking.\n\n### Phase 3: Custom microkernel\n\nThe long-term vision: a microkernel where Daimonos opcodes become native\nsyscalls. StructFS (a filesystem that stores and returns structured data\nnatively), capability-based security, and a process model designed for agent\nworkloads from the ground up.\n\n**Status: Design phase.**\n\n## Development\n\n### Prerequisites\n\n| Dependency | Required | Install |\n|-----------|----------|---------|\n| Rust (stable 1.75+) | Build | [rustup.rs](https://rustup.rs) |\n| Python 3 + pytest | Tests | `pip install -r tests/requirements.txt` |\n\n### Running tests\n\n```bash\n# Rust unit tests (350+ tests, parallel-safe)\ncargo test\n\n# End-to-end MCP protocol tests (150+ pytest cases)\npython3 -m pytest tests/ -v\n```\n\n### Running benchmarks\n\n```bash\ncd benchmarks\n./setup-mcp.sh\n./run-benchmark.sh baseline   # IDE built-in tools\n./run-benchmark.sh daimonos   # routed through daimonos MCP\npython3 analyze-results.py results/\n```\n\nSee [benchmarks/README.md](benchmarks/README.md) for details.\n\n## Configuration\n\nAll behavior is tunable via a TOML config file. See\n[docs/configuration.md](docs/configuration.md) for the full reference, or\n[daimonos.default.toml](daimonos.default.toml) for annotated defaults.\n\nKey sections:\n- `[index]` — Trigram indexer tuning (max depth, file size limits)\n- `[search]` — Search result limits\n- `[process]` — Process timeouts, in-memory/artifact bounds, background\n  admission, termination grace, inherited environment, semantic filters, and\n  max concurrent Starlark script threads\n- `[pipeline_cache]` — Subprocess result cache size, inotify watch cap, extra ignored directories\n- `[analytics]` — Token tracking (SQLite storage, retention)\n- `[tools.*]` — Per-tool plugin configuration\n\n## Contributing\n\nDaimonos is in active development. If you're interested in contributing, start\nwith the [AGENTS.md](AGENTS.md) file for coding conventions, architecture\ndecisions, and the review checklist.\n\nSee also:\n- [CONTRIBUTING.md](CONTRIBUTING.md)\n- [SECURITY.md](SECURITY.md)\n- [CHANGELOG.md](CHANGELOG.md)\n- [LICENSE](LICENSE)\n\n## License\n\nMIT\n",
  "bytes": 22066,
  "sha": "c348f6623af3b9ffd9d2fb7813de5ac52b4677217f84f3943143d8caaf77c74d",
  "repo_slug": "beardfaceguy/daimonos",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_beardfaceguy_daimonos_c078b657/readme"
}