Skip to main content
Glama
README.md
# Sill-Ensoul

English | [简体中文](README.zh-CN.md)

**Long-term memory that follows your agents across CLIs, projects, and sessions.**

Give your CLI agents experience that doesn't vanish when you switch projects, switch tools, or start a new session — it doesn't touch your workflow, just adds memory to the agents you already use.

> *ensoul* /ɪnˈsoʊl/ — verb. To give a CLI agent memory that carries across sessions, so it's more than a blank slate each time. An agent that's been ensouled is called an **ensouler**.

---

## What it does

- **Cross-CLI**: one memory, shared across Claude Code / Codex / zcode / Cursor / OpenCode. Use Claude today, switch to Codex tomorrow — your agents' memory follows.
- **Cross-project**: memory lives in a global KB, not bound to any project repo. The bug your algo agent hit in project A is recalled in project B.
- **Cross-session**: every new conversation, the agent `wiki_search`es its own past experience first and starts with memory, not from scratch.
- **Agent isolation**: spin up multiple ensoulers (algorithm engineer, backend, testing, UI...) — each has its own memory bundle, no cross-contamination. Wake one, work with its experience.
- **Memory is files**: plain markdown (following [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)) — git-able, diff-able, editable in Obsidian. Vector stores are just an index; md is always source of truth.
- **Zero external deps**: SQLite FTS5 full-text search (CJK char segmentation + BM25) — no OpenAI key, no Docker, no cloud service. Model-vendor-agnostic: inference always stays in your CLI.
- **Proactive distillation**: when an agent hits a non-trivial pitfall or makes a reusable decision, it **distills and writes it directly, then tells you what it wrote** (concept_id + one-line gist). You don't have to remember to write things down, and you keep after-the-fact veto (ask it to delete/edit).

---

## Quick Start

After cloning, do **one** of these in your CLI (Claude Code / Codex / zcode / OpenCode, etc.):

```text
# Option A: let the CLI's AI set it up (recommended — you send one message)
say: set up sill-ensoul from <repo>/SETUP.md

# Option B: more direct — paste SETUP.md contents into the chat, hit enter
```

The CLI's AI follows [SETUP.md](SETUP.md): installs the package → builds the KB → creates the default agent `alter-ego` → registers the MCP server → installs the shell. Restart the CLI, then say:

```text
wake up alter-ego      # the Chinese phrase 唤醒 alter-ego / 唤醒分身 works too
```

`alter-ego` is your digital twin (default agent, empty memory). Accumulate experience with it first; once a domain (algorithm/backend/ ...) has enough, tell the CLI "create an agent called algo-engineer" for a specialized role.

> **Recommended shape = remote MCP** (many people / many machines sharing one memory): run one `sill-ensoul-http` server; every CLI is just a client — **no repo clone, no Python package, no local KB**, just a URL and a token. The Quick Start above is the **single-machine** shape (offline / only yourself, zero service, zero token) — read it when you actually want that.
>
> **Onboarding a friend / teammate for the first time**: the owner runs `sill-ensoul-admin user create` on the server to mint an onboarding card, then hands them the card plus [`deploy/cli-setup/cli-remote.md`](deploy/cli-setup/cli-remote.md) — they paste one message into their CLI and they are connected (no repo access needed).

## Choose your deployment

| # | Your situation | Files to read (in order) | Notes |
|---|---|---|---|
| 1 | **Join an existing server** (most common: friend / teammate / your own multi-machine setup) | [`deploy/cli-setup/cli-remote.md`](deploy/cli-setup/cli-remote.md) | **No repo clone, no local install** — you only need URL + token. Ask the owner for the `SHELL.md` body too |
| 2 | **Self-host a server**: deploy on a server, then connect from your machine | (1) [`docs/deployment.md`](docs/deployment.md) then (2) [`deploy/cli-setup/cli-remote.md`](deploy/cli-setup/cli-remote.md) | Deploy the server first (including `sill-ensoul-admin user create` for accounts), then configure clients |
| 3 | **Single machine** (local, stdio) | [`SETUP.md`](SETUP.md) | Offline / only yourself; this is what the Quick Start above does |
| 4 | **Local → remote**: you already ran local stdio, now switch to an existing server | [`deploy/cli-setup/cli-remote.md`](deploy/cli-setup/cli-remote.md) | The old registration is backed up then replaced; the local KB goes idle (or migrate it per deployment.md) |
| Upgrade | Already installed (local or remote) | [`UPGRADE.md`](UPGRADE.md) or [`deploy/cli-setup/update-machine-id.md`](deploy/cli-setup/update-machine-id.md) | The latter is only for adding the `X-Machine-Id` machine header (SIL-9) |
| Multica | Binding a platform agent (requires MCP already configured) | [`deploy/cli-setup/multica.md`](deploy/cli-setup/multica.md) | Platform side only; it does not install MCP |

Not sure? The one question that settles it: **do you have a server URL + token?** Yes → scenario 1 (or 4); no, and it is just you → scenario 3; you want to give a teammate a shared memory → scenario 2.

<details>
<summary>Don't want the AI to install? Manual 3 steps</summary>

```bash
pip install -e <repo>          # or, once published: pip install sill-ensoul
sill-ensoul-init               # builds the global KB + default agent alter-ego
# then have the CLI's AI read SETUP.md to finish MCP registration + shell install
```

Requires **Python >= 3.10**.
</details>

<details>
<summary>Where is memory stored? Can I sync it via cloud?</summary>

Global KB, not inside any project repo (private memory never enters git):

| Platform | Default path |
|---|---|
| Windows | `%LOCALAPPDATA%\ensoul\knowledge` |
| macOS | `~/Library/Application Support/ensoul/knowledge` |
| Linux | `$XDG_DATA_HOME/ensoul/knowledge` (default `~/.local/share/ensoul/knowledge`) |

Set `ENSOUL_KB=<path>` to put it anywhere (e.g. a Dropbox / iCloud folder for multi-device sync). Open that folder in Obsidian — each agent is a subfolder, the `.md` files inside are the memory.
</details>

<details>
<summary>CLI maintenance commands</summary>

After install, `sill-ensoul-init` provides a few maintenance commands:

| Command | Purpose |
|---|---|
| `sill-ensoul-init` | Initialize the global KB + default `alter-ego` agent (idempotent). |
| `sill-ensoul-init --print-shell` | Print the CLI-agnostic shell for manual append to a CLI instruction file. |
| `sill-ensoul-init --sync-shell` | Auto-update sill-ensoul shell segments in supported CLI instruction files (Claude Code, Zcode, Codex, OpenCode, pi). |
| `sill-ensoul-admin user create \| list \| revoke \| reset` | Remote-only: create / list / revoke / reset tenant users and write a ready-to-paste onboarding card (URL + token + per-CLI section). |
| `sill-ensoul-init --rebuild-index` | Rebuild the SQLite FTS index for every agent from the `.md` source of truth. |
| `sill-ensoul-init --version` | Print the installed package version (for upgrade checks). |

Supported CLI instruction files are detected automatically; only the ones that exist and already contain sill-ensoul markers are updated.
</details>

---

## Upgrade

Upgrading an existing install is two parts, three commands — and your KB is
**never touched** (upgrades update the package code and re-sync the shell rules
only; your agents' memory stays put):

```bash
sill-ensoul-init --version                                   # what's installed now
pip install -U "git+https://github.com/sillogic/sill-ensoul.git"   # or: git pull && pip install -e <repo>
sill-ensoul-init --sync-shell                                # refresh shell rules in CLI instruction files
```

Restart your CLI. The full machine-readable intent for the CLI's AI (route
detection, verification, what-not-to-do) is [UPGRADE.md](UPGRADE.md) — say
*"upgrade sill-ensoul from `<repo>`/UPGRADE.md"* and the CLI handles it.

---

## How it works

```
  Claude Code / Codex / zcode / Cursor   ← inference runs in each CLI's model vendor, not locked
           |  load persona + wiki slice (thin shell: AGENTS.md / CLAUDE.md)
        sill-ensoul-mcp (MCP server, 8 tools, read/write/search)
           |  read/write
  knowledge/agents/<id>/   ← one OKF bundle per ensouler (markdown files)
  knowledge/agents/<id>/.fts/index.db   ← local SQLite FTS5 index, derived from the .md files
```

**Three-layer separation** (design decisions D1/D2, see [docs/ROADMAP.md](docs/ROADMAP.md)):

- **Engine** (`ensoul/`) — CLI-agnostic, handles data/tools only, no inference. `server.py` is a thin MCP shell, pass-through only.
- **Shell** (`AGENTS.md` / `CLAUDE.md`) — one per CLI, defines "when to wake/search/distill", references the shared [WORKFLOW.md](WORKFLOW.md).
- **Memory** (`knowledge/agents/<id>/`) — OKF markdown files, git-able, diff-able, human-readable.

**About the `.fts/index.db` file**: Each agent bundle has a local SQLite FTS5 index that caches metadata and accelerates search. It is derived data — the `.md` files are always the source of truth. You can delete `.fts/` at any time; it will be rebuilt on demand. SQLite is part of Python's standard library, so there is no extra install and no separate database process.

Core loop: **wake** (load persona + knowledge map) → **recall** (search relevant experience) → **cite** (reference real memory with concept_id) → **distill** (new experience, written directly with a heads-up). Memory persists across projects and sessions.

---

## 8 Tools

| Tool | Purpose |
|---|---|
| `list_agents` | List all ensoulers |
| `create_agent` | Create an ensouler (dir + persona + index + log template) |
| `delete_agent` | Delete an ensouler (irreversible, confirm first) |
| `agent_index` | Wake/switch ensouler (persona + knowledge map) |
| `wiki_search` | Full-text search an ensouler's experience (FTS5 + BM25, with CJK segmentation) |
| `wiki_read` | Read a concept's details |
| `wiki_write_concept` | Distill new experience (type required) |
| `wiki_append_log` | Log a change |

> Multi-ensouler collaboration needs no dedicated tools: any agent can use `wiki_write_concept(agent_id=...)` to operate on **another** agent's memory — orchestrator reads/writes directly (see [docs/ROADMAP.md](docs/ROADMAP.md) D6).

---

## Remote deployment (HTTP server)

Run the **same 8 tools** as a Streamable HTTP MCP server on any machine (VPS / home server / tailnet) so multiple machines share **one** knowledge base. Every request is gated by a static **Bearer token** (SIL-7 / D11) — single-tenant today, with an identity→KB-root seam for future multi-tenancy.

```bash
pip install "sill-ensoul[http] @ git+https://github.com/sillogic/sill-ensoul.git"   # not on PyPI yet
# or clone then: pip install ".[http]"  (quote the bracket — `.[http]` unquoted is not valid bash)
ENSOUL_MCP_TOKEN=$(openssl rand -hex 32)   # or: python -c "import secrets;print(secrets.token_hex(32))"
ENSOUL_MCP_TOKEN=... sill-ensoul-http      # default bind 0.0.0.0:8930
```

> **Dependency pin**: the package requires `mcp>=1.2,<2` — mcp 2.x renamed `FastMCP` to
> `MCPServer` and removed the `mcp.server.fastmcp` module, which breaks both `sill-ensoul-mcp`
> and `sill-ensoul-http` at startup. The upper bound is baked into `pyproject.toml`, so a fresh
> install resolves mcp 1.x automatically (migration to mcp 2.x is tracked in D11).

- **Fail-closed**: the server **refuses to start without `ENSOUL_MCP_TOKEN`** — an unauthenticated remote server is exactly what this is for.
- Optional: `ENSOUL_MCP_HOST` / `ENSOUL_MCP_PORT` env overrides (or `--host` / `--port`). The KB root is still `ENSOUL_KB` / the platform default.

**Environment variables** — a ready template lives in [`.env.example`](.env.example) (token / KB root / host / port). For systemd, copy it to a root-only file and load it with `EnvironmentFile`; a ready-to-edit unit is at [`deploy/sill-ensoul-http.service`](deploy/sill-ensoul-http.service):

```bash
sudo mkdir -p /etc/sill-ensoul
sudo cp .env.example /etc/sill-ensoul/env && sudo chmod 600 /etc/sill-ensoul/env
sudo vi /etc/sill-ensoul/env                  # fill in ENSOUL_MCP_TOKEN / ENSOUL_KB
sudo cp deploy/sill-ensoul-http.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now sill-ensoul-http
systemctl status sill-ensoul-http             # an env change needs a restart to take effect
```

**Migrate the KB** — memory is plain files under the local KB root (`knowledge/`); copy the whole tree to the server's `ENSOUL_KB` (exclude per-agent `.fts/` caches — they rebuild automatically):

```bash
# local (Windows PowerShell, in %LOCALAPPDATA%\ensoul):
tar -cf knowledge.tar --exclude=.fts knowledge
scp knowledge.tar root@<server>:/opt/sill-ensoul/
# server:
cd /opt/sill-ensoul && tar -xf knowledge.tar && ls knowledge/agents/
```

> If multiple machines each have a KB, pick ONE as baseline first — do not blindly overwrite; merge the stragglers' unique content by hand.

Point a CLI's MCP config at it (streamable-http clients send the header on every request):

```jsonc
{ "type": "streamable-http", "url": "http://<server>:8930/mcp",
  "headers": { "Authorization": "Bearer <token>",
                "X-Machine-Id": "<your-hostname>" } }
```

or via a stdio↔HTTP bridge (works for any CLI):
`npx mcp-remote http://<server>:8930/mcp --allow-http --transport http-only --header "Authorization: Bearer <token>" --header "X-Machine-Id: <your-hostname>"`.
`--allow-http` is required because mcp-remote refuses plain-HTTP URLs by default; `--transport http-only` avoids mcp-remote's SSE-fallback probe (its default `http-first` strategy), which conflicts with FastMCP's streamable-HTTP session handling and fails every call with `400 Bad Request: Missing session ID`. The `X-Machine-Id` header is the machine identity (SIL-9): the server stamps it into every concept's frontmatter `machine:` field, so readers of a shared remote KB can tell "which machine wrote this" from "which machine am I on".

> **Security notes**: the token is the auth boundary — never commit it; prefer a private network (Tailscale / VPN / firewall) for transport security; the stdio server (`sill-ensoul-mcp`) stays local-only and needs no token. On a public network, front the server with TLS (Caddy/nginx reverse proxy) so the token is not sent in clear text.

> **Full runbook**: step-by-step deployment, restart / upgrade / KB-migration / troubleshooting lives in [`docs/deployment.md`](docs/deployment.md).
> **Client install (remote)**: to point a CLI at the remote server **without hand-editing configs**, paste the single prompt file [`deploy/cli-setup/cli-remote.md`](deploy/cli-setup/cli-remote.md) into that CLI — it identifies which CLI it is, applies the matching section, and registers the remote MCP endpoint itself (see `docs/deployment.md` §4).
> **Not sure which file fits you?** See [Choose your deployment](#choose-your-deployment) above — pick your scenario (local / self-hosted / join existing server / switch local→remote), it tells you the file order.

---

## Tests

```bash
pip install -e .
python -m tests.run_tests
```

Four release tests, all green = core loop works (each builds its own temp KB, runs straight after clone):

| Test | Verifies |
|---|---|
| `test_search` | FTS5 search + persona exclusion (11 regressions) |
| `test_mcp_live` | MCP shell layer (8 tools, real stdio) |
| `test_http_live` | HTTP transport + Bearer auth (fail-closed, 401 gate, real uvicorn e2e) |
| `test_cross_project` | Cross-project memory retention (end-to-end) |

---

## Status

- ✅ Core loop works: wake → recall → cite → distill → cross-project retention
- ✅ Installable: `pip install` + `sill-ensoul-init` self-boots CLI setup
- ✅ Cross-CLI verified: zcode + Claude Code both adapted
- ✅ Design final: auto-distill + notify-after (not pre-write confirmation, not full-auto). Multi-agent collaboration via orchestrator model (D6).
- See [docs/ROADMAP.md](docs/ROADMAP.md)

---

## Documentation map (which file, for whom, covering what)

| File | Reader | Covers |
|---|---|---|
| [`README.md`](README.md) | Humans | Product overview + Quick Start (two shapes: remote as recommended, single-machine as optional) + deployment decision table |
| [`SETUP.md`](SETUP.md) | The CLI's AI | **Local** first install (install package → build KB → register stdio → shell → verify) |
| [`UPGRADE.md`](UPGRADE.md) | The CLI's AI | **Upgrading** an existing install (package + shell; never touches the KB) |
| [`docs/deployment.md`](docs/deployment.md) | Humans (server admin) | **Server-side remote** deployment runbook (git install / env / systemd / KB migration / ops / troubleshooting) |
| [`deploy/sill-ensoul-http.service`](deploy/sill-ensoul-http.service) | Humans (server admin) | **systemd unit template** (copy to `/etc/systemd/system/` on the server; not a runtime component) |
| [`deploy/cli-setup/README.md`](deploy/cli-setup/README.md) | Humans | Index of the client-setup prompt files (4 files + scenario routing) |
| [`deploy/cli-setup/cli-remote.md`](deploy/cli-setup/cli-remote.md) | The CLI's AI | **Remote client** setup (first connect / local→remote switch) |
| [`deploy/cli-setup/update-machine-id.md`](deploy/cli-setup/update-machine-id.md) | The CLI's AI | Adding the **`X-Machine-Id` machine header** to an already-connected client (SIL-9 upgrade) |
| [`deploy/cli-setup/multica.md`](deploy/cli-setup/multica.md) | The CLI's AI | **Multica platform** agent binding (requires MCP already configured) |
| [`WORKFLOW.md`](WORKFLOW.md) | Humans | The CLI-agnostic workflow (wake / recall / distill / skill dispatch) — authoritative source |
| [`ensoul/SHELL.md`](ensoul/SHELL.md) | The CLI's AI (via the shell) | The **shell rules** injected into each CLI's instruction file (includes the machine banner) |
| [`docs/ROADMAP.md`](docs/ROADMAP.md) | Humans | Progress + design decisions D1-D13 + historical pitfalls H1-H21 |
| [`docs/DESIGN.md`](docs/DESIGN.md) | Humans | Design rationale: why OKF / MCP, and how it compares with mem0 / letta / graphiti |
| [`docs/multica.md`](docs/multica.md) | Humans | Multica platform integration guide (design-facing; complements the `deploy/cli-setup/multica.md` prompt file) |
| [`CHANGELOG.md`](CHANGELOG.md) | Humans | Release notes per version (0.3.0 onward) |

## License

Released under the [MIT License](LICENSE) © 2026 sillogic.

TDQS

A3.5/5.0

Scored across 8 tools

Disambiguation4/5

Each tool targets a distinct action (create/list/delete agent, read/search/write wiki, append log), and descriptions clarify the one potentially confusing pair (agent_index vs wiki_read). The name agent_index could be misread as an agent list, but its description removes that ambiguity.

Naming Consistency3/5

Most wiki operations use a wiki_<verb> pattern, while agent lifecycle operations use <verb>_agent; this mixed ordering is readable but not uniform. agent_index is a noun-noun exception, and wiki_read vs wiki_write_concept is asymmetric. All names are snake_case and semantically clear.

Tool Count5/5

Eight tools is a well-scoped set for managing agent bundles and their knowledge wikis. Each tool covers a distinct need without redundancy, and the count is within the ideal range.

Completeness4/5

Core workflows are covered: create/list/delete agents, open/search/read concepts, write concepts, and append log entries. There is no direct way to update an agent's persona/index or delete an individual concept, but these are minor gaps that can be worked around via concept writes or log entries.

Maintenance

ActivityNo data
ResponsivenessOutdated data