> ## Documentation Index
> Fetch the complete documentation index at: https://eispatch.framewire.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> How EISPATCH is organized around a shared host-independent core, thin per-host adapters, and a single shared UI.

EISPATCH is built as a portable prompt-interception layer. The goal is to keep host-specific code small and isolated, so the same visual composer, recommender, compiler, and library work across every supported agent.

## Design at a glance

A short prompt flow looks like this:

```mermaid theme={null}
flowchart LR
    A[User prompt] --> B[Host hook or plugin]
    B --> C{Composer}
    C --> D[Recommender]
    C --> E[Compiler]
    E --> F[Approve]
    F --> G[Dispatch]
```

1. You start a prompt with `/eispatch` (or it is auto-intercepted).
2. The host hook or plugin blocks the agent and opens the composer.
3. You review capabilities, optionally break the prompt into tasks, edit the final text, and click **Approve**.
4. The compiler produces a marked, structured prompt.
5. The approved prompt is dispatched to the agent.

## Shared host-independent core

Everything in `core/` is meant to work with every supported host.

| File | Responsibility |
| - | - |
| `core/compiler.mjs` | Builds the final compiled prompt from the graph, selected capabilities, tasks, and optional manual edits. Returns the prompt string, manifest, and summary. |
| `core/discovery.mjs` | Reads the local host environment and returns available MCP servers, skills, plugins, and subagents. |
| `core/graph.mjs` | Manages the interactive canvas model: nodes, edges, tasks, and layout state used by the composer. |
| `core/launch-local-composer.mjs` | Detached launcher used by the Codex and Claude Code hooks. Starts the Local Composer (default idle timeout 30 minutes) and writes a ready-file with its URL. The OpenCode plugin starts the server in-process instead. |
| `core/library.mjs` | Reads and writes the local Prompt Library at `~/.eispatch/library.json`. Handles locking, capability validation, import (keeps unused IDs, generates new ones on collisions), and export. |
| `core/local-composer.mjs` | Runs the `127.0.0.1` HTTP server that serves the composer UI and exposes the `/api/*` endpoints. |
| `core/recommender.mjs` | Scores discovered capabilities against the prompt using a deterministic, local-only algorithm. No external AI. |
| `core/schema.mjs` | Shared data structures and validation used across `core/`. |

## Thin host adapters

Each adapter lives under `adapters/<host>/` and contains only what that host needs: hooks, plugin manifests, MCP server wrappers, and discovery helpers.

| Adapter | What it provides |
| - | - |
| `adapters/antigravity/` | Workspace plugin (`.agents/plugins/eispatch/`), SEP-1865 MCP App, and `PreInvocation` hook for native `app.sendMessage()` dispatch. |
| `adapters/codex/` | `UserPromptSubmit` hook, `plugin.json`, `SKILL.md`, discovery adapter, MCP stdio server, and Local Composer invocation. |
| `adapters/opencode/` | `plugin.mjs` (`chat.message` and `experimental.chat.system.transform` hooks), discovery adapter, `SKILL.md`, and in-process Local Composer. Experimental. |
| `adapters/claude-code/` | `.claude-plugin/plugin.json`, `SKILL.md`, `UserPromptSubmit` hook, MCP stdio server, discovery adapter, and Local Composer invocation. |

Dispatch differs by host:

* **Antigravity**: native same-session dispatch via `app.sendMessage()`.
* **Codex and Claude Code**: clipboard fallback. The Local Composer copies the approved prompt and you paste it back into the agent.
* **OpenCode (experimental)**: tries `client.session.prompt()`, then the OpenCode HTTP session API, then clipboard fallback. Verified with the adapter harness; native end-to-end verification is pending.

EISPATCH is a composition layer, not a centralized execution controller. After dispatch, the host agent decides how the prompt runs and which tools it uses.

## Single shared UI

`ui/composer.html` is one file used by every host path. Antigravity renders it inside an aux\_pane and inline as an MCP App; the Local Composer serves it directly for the other hosts. The same pan, zoom, drag, capability drawer, and final-prompt drawer behavior apply everywhere.

## Demo and scripts

* `demo/verify-e2e.mjs`: end-to-end verification harness.
* `demo/server.mjs`: preview server for the composer (`npm run preview`).
* `scripts/install-*.mjs`: per-host installers that support `--check` and `--uninstall`.

## Repository layout

```text theme={null}
eispatch/
├── .agents/plugins/eispatch/       # Antigravity workspace plugin
├── adapters/
│   ├── antigravity/
│   ├── claude-code/
│   ├── codex/
│   └── opencode/
├── assets/
│   ├── eispatch-logo.svg
│   └── eispatch-launch.webp
├── core/
│   ├── compiler.mjs
│   ├── discovery.mjs
│   ├── graph.mjs
│   ├── launch-local-composer.mjs
│   ├── library.mjs
│   ├── local-composer.mjs
│   ├── recommender.mjs
│   └── schema.mjs
├── demo/
│   ├── verify-e2e.mjs
│   └── server.mjs
├── scripts/
│   ├── install-antigravity.mjs
│   ├── install-claude-code.mjs
│   ├── install-codex.mjs
│   └── install-opencode.mjs
├── ui/
│   └── composer.html
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── package.json
```

## Design principles

* **Host independence**: keep `core/` free of host-specific protocols or UI frameworks.
* **Local discovery**: discovery inspects local config, and capability metadata passes through pattern-based redaction of URLs and common credential formats.
* **Clear labels**: capabilities are labeled advisory unless the node is flagged `enforceable`.
* **Zero dependencies**: the entire runtime is plain Node.js ESM.
* **Deterministic blocking**: hooks behave the same way every time, with no external round-trips.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.