|
| 1 | +# hindsight-zed |
| 2 | + |
| 3 | +Long-term memory for the [Zed](https://zed.dev) editor's AI assistant, powered by |
| 4 | +[Hindsight](https://github.com/vectorize-io/hindsight). |
| 5 | + |
| 6 | +`hindsight-zed init` wires Zed's Agent Panel to the Hindsight **MCP server** and |
| 7 | +adds a rule telling the agent to use it — so it recalls relevant memory at the |
| 8 | +start of a task and retains durable facts as it goes. Recall happens at query |
| 9 | +time against your actual message (no lag), and from your seat it's automatic. |
| 10 | + |
| 11 | +## How it works |
| 12 | + |
| 13 | +Zed has no pre-prompt hook, but it does support two things this integration uses: |
| 14 | + |
| 15 | +- **MCP context servers** — Zed runs MCP servers configured under |
| 16 | + `context_servers` in `settings.json` and exposes their tools in the Agent |
| 17 | + Panel. We register the Hindsight MCP server there, giving the agent |
| 18 | + `recall` / `retain` / `reflect` tools. |
| 19 | +- **A global instructions file** (`~/.config/zed/AGENTS.md`) that Zed includes in |
| 20 | + every conversation. We add a small rule there telling the agent to recall |
| 21 | + first and retain what it learns. |
| 22 | + |
| 23 | +Zed doesn't yet have native HTTP-MCP transport, so the server is connected |
| 24 | +through the [`mcp-remote`](https://www.npmjs.com/package/mcp-remote) stdio bridge |
| 25 | +(run via `npx`) — that means you need Node.js installed. |
| 26 | + |
| 27 | +## Install |
| 28 | + |
| 29 | +```bash |
| 30 | +pip install hindsight-zed |
| 31 | +hindsight-zed init --api-token YOUR_HINDSIGHT_API_KEY --bank-id my-memory |
| 32 | +``` |
| 33 | + |
| 34 | +`init` adds the `hindsight` MCP server to `~/.config/zed/settings.json` and the |
| 35 | +recall/retain rule to `~/.config/zed/AGENTS.md`. Restart Zed, open the Agent |
| 36 | +Panel, and the `hindsight` server should show a green dot. |
| 37 | + |
| 38 | +Use a [Hindsight Cloud](https://hindsight.vectorize.io) key, or point at a |
| 39 | +self-hosted server with `--api-url http://localhost:8888` (no token needed for an |
| 40 | +open local server). |
| 41 | + |
| 42 | +> If your `settings.json` contains comments (JSONC), `init` won't rewrite it — |
| 43 | +> it prints the exact `context_servers` entry for you to paste instead. Use |
| 44 | +> `hindsight-zed init --print-only` any time to see the snippet without writing. |
| 45 | +
|
| 46 | +## Commands |
| 47 | + |
| 48 | +| Command | Description | |
| 49 | +| --- | --- | |
| 50 | +| `hindsight-zed init` | Add the MCP server + recall/retain rule | |
| 51 | +| `hindsight-zed status` | Show whether the server + rule are configured | |
| 52 | +| `hindsight-zed uninstall` | Remove the server + rule | |
| 53 | +| `hindsight-zed init --print-only` | Print the config to add manually | |
| 54 | + |
| 55 | +## What gets written |
| 56 | + |
| 57 | +`~/.config/zed/settings.json`: |
| 58 | + |
| 59 | +```jsonc |
| 60 | +{ |
| 61 | + "context_servers": { |
| 62 | + "hindsight": { |
| 63 | + "source": "custom", |
| 64 | + "command": "npx", |
| 65 | + "args": [ |
| 66 | + "-y", "mcp-remote", |
| 67 | + "https://api.hindsight.vectorize.io/mcp/my-memory/", |
| 68 | + "--header", "Authorization: Bearer YOUR_HINDSIGHT_API_KEY" |
| 69 | + ] |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +`~/.config/zed/AGENTS.md` (inside a fenced `<!-- HINDSIGHT -->` block that leaves |
| 76 | +the rest of the file untouched): a short rule telling the agent to `recall` at |
| 77 | +the start of each task and `retain` durable facts. |
| 78 | + |
| 79 | +## Configuration |
| 80 | + |
| 81 | +| Setting | Env var | Default | |
| 82 | +| --- | --- | --- | |
| 83 | +| API URL | `HINDSIGHT_API_URL` | `https://api.hindsight.vectorize.io` | |
| 84 | +| API token | `HINDSIGHT_API_TOKEN` | _(none; required for Cloud)_ | |
| 85 | +| Bank id | `HINDSIGHT_ZED_BANK_ID` | `zed` | |
| 86 | + |
| 87 | +These can also live in `~/.hindsight/zed.json` (written by `init`). |
| 88 | + |
| 89 | +## Development |
| 90 | + |
| 91 | +```bash |
| 92 | +uv sync |
| 93 | +uv run pytest tests -v -m 'not requires_real_llm' # deterministic suite |
| 94 | +uv run pytest tests -v -m requires_real_llm # gated MCP-endpoint check |
| 95 | +``` |
| 96 | + |
| 97 | +## License |
| 98 | + |
| 99 | +MIT |
0 commit comments