@anmol-srv/sigil 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +417 -0
- package/dist/cli.js +1019 -0
- package/dist/hooks/post-tool-use.js +70 -0
- package/dist/hooks/session-end.js +222 -0
- package/dist/hooks/stop.js +259 -0
- package/dist/hooks/user-prompt-submit.js +279 -0
- package/dist/server.js +573 -0
- package/integrations/hermes/README.md +41 -0
- package/integrations/hermes/plugin/README.md +72 -0
- package/integrations/hermes/plugin/__init__.py +353 -0
- package/integrations/hermes/plugin/plugin.yaml +10 -0
- package/knexfile.js +15 -0
- package/package.json +100 -0
- package/prompts/audm-decision.md +31 -0
- package/prompts/chunk-context.md +23 -0
- package/prompts/default-extraction.md +35 -0
- package/prompts/entity-extraction.md +37 -0
- package/prompts/input-classifier.md +23 -0
- package/prompts/query-router.md +18 -0
- package/src/db/migrations/20260310120000_create-cortex-document-table.cjs +21 -0
- package/src/db/migrations/20260310120001_create-cortex-chunk-table.cjs +37 -0
- package/src/db/migrations/20260310120002_create-cortex-fact-table.cjs +37 -0
- package/src/db/migrations/20260310120003_create-cortex-entity-table.cjs +26 -0
- package/src/db/migrations/20260310120004_create-cortex-relation-table.cjs +27 -0
- package/src/db/migrations/20260310120005_create-cortex-history-table.cjs +16 -0
- package/src/db/migrations/20260311120000_add-entity-namespace-and-relation-indexes.cjs +32 -0
- package/src/db/migrations/20260312120000_add-fact-entity-linking.cjs +22 -0
- package/src/db/migrations/20260313093130_create-api-key-table.cjs +15 -0
- package/src/db/migrations/20260313120000_add-entity-dedup-support.cjs +13 -0
- package/src/db/migrations/20260313150000_create-connector-tables.cjs +46 -0
- package/src/db/migrations/20260318120000_add-contextual-chunk-prefix.cjs +11 -0
- package/src/db/migrations/20260318120001_add-fact-temporal-validity.cjs +15 -0
- package/src/db/migrations/20260318120002_add-fact-importance.cjs +11 -0
- package/src/db/migrations/20260318120003_add-fact-access-tracking.cjs +13 -0
- package/src/db/migrations/20260405120000_add-unique-constraints.cjs +58 -0
- package/src/db/migrations/20260405140000_create-llm-log-table.cjs +21 -0
- package/src/db/migrations/20260424120000_split-fact-lifecycle.cjs +86 -0
- package/src/db/migrations/20260424120002_create-embedding-cache.cjs +26 -0
- package/src/db/migrations/20260429120000_halfvec-index-compression.cjs +34 -0
- package/src/db/migrations/20260429120100_create-hebbian-edge-table.cjs +37 -0
- package/src/db/migrations/20260429120200_upgrade-embedding-dim-1024.cjs +68 -0
- package/src/db/migrations/20260504120000_scope-document-source-path-uniqueness.cjs +45 -0
- package/src/db/migrations/20260508001733_add-entity-aliases.cjs +42 -0
- package/src/db/migrations/20260512120000_create-entity-hebbian-edge.cjs +42 -0
- package/src/db/migrations/20260512120000_create-pod-tables.cjs +71 -0
- package/src/db/migrations/20260512120100_create-pod-membership.cjs +50 -0
- package/src/db/migrations/20260512120200_add-document-source-metadata.cjs +32 -0
- package/src/db/migrations/20260514023428_rewrite-session-pods-and-add-fact-attribution-columns.cjs +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anmol Srivastava
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="./assets/sigil.svg" alt="Sigil" width="100" height="100" />
|
|
4
|
+
|
|
5
|
+
# Sigil
|
|
6
|
+
|
|
7
|
+
### One brain. Every agent. Your machine.
|
|
8
|
+
|
|
9
|
+
Local-first memory shared across Claude Code, Codex CLI, Cursor, Kiro, and any agent that can run a shell command or speak [MCP](https://modelcontextprotocol.io/). Stored in your own Postgres. No cloud, no telemetry.
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
docker run -d --name sigil-pg -p 5432:5432 \
|
|
15
|
+
-e POSTGRES_PASSWORD=sigil_dev pgvector/pgvector:pg15
|
|
16
|
+
npm install -g @anmol-srv/sigil
|
|
17
|
+
sigil init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
<div align="center">
|
|
21
|
+
|
|
22
|
+
Open Claude Code — memory is already wired in.
|
|
23
|
+
|
|
24
|
+
[](https://www.npmjs.com/package/@anmol-srv/sigil)
|
|
25
|
+
[](https://modelcontextprotocol.io/)
|
|
26
|
+
[](./eval/longmemeval/RESULTS.md)
|
|
27
|
+
[](https://opensource.org/licenses/ISC)
|
|
28
|
+
|
|
29
|
+
[**Quickstart**](#quickstart) · [Every agent](#works-with-every-agent-on-your-machine) · [How it works](#how-its-structured) · [Capabilities](#key-capabilities) · [Benchmarks](#benchmarks) · [FAQ](#faq)
|
|
30
|
+
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Why this exists
|
|
36
|
+
|
|
37
|
+
Every memory tool for AI agents ships as someone else's cloud. Your code context, your team's decisions, your preferences — sitting in a vendor's database. That's the wrong default for the most intimate context your agents touch.
|
|
38
|
+
|
|
39
|
+
And every agent has its own walled memory. Claude doesn't see what you told Codex. Cursor doesn't know what Kiro learned this morning. You re-explain the same architecture, watch the same mistakes happen, lose hours to context-loading every session.
|
|
40
|
+
|
|
41
|
+
Sigil fixes both problems with the same primitive: a local memory layer every agent connects to.
|
|
42
|
+
|
|
43
|
+
- **In Claude Code:** four hooks (`UserPromptSubmit`, `PostToolUse`, `Stop`, `SessionEnd`) auto-capture decisions, preferences, and observations as you work. Relevant memory is injected into every new prompt before Claude sees it. You write zero `sigil remember` calls.
|
|
44
|
+
- **Everywhere else, the `sigil` CLI is the universal interface.** Any agent that can run a shell command — Codex CLI, terminal-based assistants, CI runners, Hermes, your own scripts — can call `sigil search "..."` or `sigil remember "..."` directly. No client integration required: if the agent can shell out, it can read and write memory.
|
|
45
|
+
- **For MCP-aware clients** (Cursor, Continue, Cline, Windsurf, Claude Desktop, Kiro): the same memory is also exposed as a 9-tool MCP server. Same brain, structured surface for clients that prefer it.
|
|
46
|
+
- **Across machines:** point multiple installs at the same Postgres. A fact captured on your laptop surfaces in the agent running on your home server. No daemon, no sync protocol — Postgres handles consistency.
|
|
47
|
+
|
|
48
|
+
The pod model (sessions, projects, people, playbooks, vitals — and any pluggable kind you add) is the foundation. It's how the next layers — write-attributed multi-agent workflows, ACLs, custom integrations — will land on top of the same brain.
|
|
49
|
+
|
|
50
|
+
**What changes in practice:** Tuesday in Claude Code, you decide to route webhooks through Postgres `LISTEN/NOTIFY` instead of Redis pubsub. Thursday you open Cursor in the same repo and ask for an event handler — it already knows. Friday you spin up a Hermes agent on your home server and ask *"what's our event delivery setup?"* — same answer, no copy-paste. The brain travels with you.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Works with every agent on your machine
|
|
55
|
+
|
|
56
|
+
Sigil's wedge is one memory layer underneath everything. `sigil init` detects every coding agent on your machine and wires Sigil into each one automatically — hooks for Claude Code, MCP server registration plus client-native steering rules for the rest.
|
|
57
|
+
|
|
58
|
+
| Agent | Integration depth | Auto-wired |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| **Claude Code** | Native plugin · 4 hooks (`UserPromptSubmit`, `PostToolUse`, `Stop`, `SessionEnd`) · MCP server · `@~/.sigil/CLAUDE.md` hot-context import | ✓ |
|
|
61
|
+
| **Codex CLI** | `~/.codex/config.toml` MCP entry · `~/.codex/AGENTS.md` steering · MCP server | ✓ |
|
|
62
|
+
| **Cursor** | `~/.cursor/mcp.json` MCP entry · MCP server | ✓ |
|
|
63
|
+
| **Kiro** | `~/.kiro/settings/mcp.json` MCP entry · `~/.kiro/steering/sigil.md` steering rule · MCP server | ✓ |
|
|
64
|
+
| **Continue / Cline / Windsurf** | MCP server (one-line config from `sigil register --print`) | — |
|
|
65
|
+
| **Hermes / OpenClaw / any custom agent** | MCP server, REST, or `sigil` CLI directly | — |
|
|
66
|
+
| **Any MCP-spec client** | MCP server | — |
|
|
67
|
+
|
|
68
|
+
Works with **any** agent that speaks MCP or can run a shell command. One brain on your machine — every agent reads and writes to it.
|
|
69
|
+
|
|
70
|
+
### Two interfaces: CLI first, MCP when it fits
|
|
71
|
+
|
|
72
|
+
The `sigil` CLI is the universal interface. If your agent has a `Bash` tool, a terminal, or any way to shell out, it can use Sigil — no client-specific integration required:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
sigil search "JWT auth setup" # what does the brain know?
|
|
76
|
+
sigil remember "we use jose, not jsonwebtoken" # save a fact
|
|
77
|
+
sigil facts --limit=20 # list recent facts
|
|
78
|
+
sigil why "auth setup" # explain the search
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
That's exactly how Claude Code (via Bash tool), Codex CLI, terminal-based agents, Hermes, and your own CI scripts use Sigil today. The CLI is auto-detected on `PATH` after `npm install -g @anmol-srv/sigil` — agents discover it the same way they discover `git` or `node`.
|
|
82
|
+
|
|
83
|
+
For clients that prefer structured tool calls (Cursor, Continue, Cline, Claude Desktop, Kiro, any MCP-spec agent), Sigil also exposes the same memory as a 9-tool MCP server — `sigil register --print` generates the config. MCP is the second interface, not the only one.
|
|
84
|
+
|
|
85
|
+
### vs your agent's built-in memory
|
|
86
|
+
|
|
87
|
+
Every coding agent ships with a hand-edited memory file: `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, Kiro steering. They're per-agent, capped in size, manually maintained, and reloaded in full on every prompt. Sigil is the searchable brain behind them.
|
|
88
|
+
|
|
89
|
+
| | Built-in (`CLAUDE.md`, `AGENTS.md`, etc.) | **Sigil** |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| Capture | Manual — you write and edit the file | Automatic via Claude Code hooks |
|
|
92
|
+
| Scale | Loaded fully into context every prompt | Top-K retrieved from unlimited corpus |
|
|
93
|
+
| Token cost | Linear in file size (caps how much you can store) | ~1.5K injected per prompt regardless of corpus size |
|
|
94
|
+
| Search | None — the model reads the whole file | Hybrid (pgvector + tsvector BM25 + RRF) |
|
|
95
|
+
| Cross-agent | Per-agent files, no sharing | One shared brain across every wired agent |
|
|
96
|
+
| Cross-machine | Manual sync (git, scp) | Point installs at the same Postgres |
|
|
97
|
+
| Freshness | Stale until you rewrite | Auto-decay, supersession, importance reweighting |
|
|
98
|
+
| Provenance | None | Every fact links to source + confidence + temporal validity |
|
|
99
|
+
|
|
100
|
+
You can keep using `CLAUDE.md` for hard-coded project rules. Sigil handles everything else.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## How it's structured
|
|
105
|
+
|
|
106
|
+
Memory lives in **pods** — typed containers with declared retrieval behaviour. Five built-in kinds today:
|
|
107
|
+
|
|
108
|
+
| Kind | Identity | Decay | Hot-context budget |
|
|
109
|
+
|---|---|---|---|
|
|
110
|
+
| `claude_session` | one per Claude Code session | 90 days | 6 slots |
|
|
111
|
+
| `project` | one per git root (or cwd) | never | 4 slots |
|
|
112
|
+
| `person` | one per contact you mention | never | 4 slots (rolling 24h active) |
|
|
113
|
+
| `playbook` | your user-authored runbooks | never | 3 slots (active for matching project) |
|
|
114
|
+
| `vital` | virtual; facts marked `importance=5` | never | 6 slots (global) |
|
|
115
|
+
|
|
116
|
+
Pods are pluggable. Adding a new kind (`codex_session`, `slack_channel`, `github_pr`, ...) means writing a contract file — no schema migrations. Retrieval is pod-aware: hot-context blends facts from your active session + project + relevant people + vital, weighted by importance × decay.
|
|
117
|
+
|
|
118
|
+
Three storage layers underneath:
|
|
119
|
+
|
|
120
|
+
1. **Chunks** — raw 512-token blocks of ingested docs, embedded via your chosen provider (Ollama / OpenAI / Voyage)
|
|
121
|
+
2. **Facts** — atomic statements with confidence, importance, temporal validity, supersession links
|
|
122
|
+
3. **Entity graph** — typed nodes (person, project, service, ...) + relations, traversed via recursive CTEs
|
|
123
|
+
|
|
124
|
+
Retrieval is hybrid: pgvector cosine + tsvector keyword fused via Reciprocal Rank Fusion, then re-ranked by ACT-R activation (recency × frequency) and Hebbian co-retrieval boosts. The full pipeline is in `src/memory/`.
|
|
125
|
+
|
|
126
|
+
### What each hook does
|
|
127
|
+
|
|
128
|
+
| Hook | What runs |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `UserPromptSubmit` | Hybrid search on your prompt → top-K facts injected as `additionalContext` before Claude sees it |
|
|
131
|
+
| `PostToolUse` | Capture observations from `Edit` / `Write` / `Bash`; SHA-256 dedup against a 5-minute window |
|
|
132
|
+
| `Stop` | Classify the user's last message (preference / decision / constraint / claim), extract atomic facts + entities, AUDM (Add / Update / Delete / Merge) against existing memory to prevent duplicates |
|
|
133
|
+
| `SessionEnd` | Summarize the session into its `claude_session` pod; promote sticky facts to higher importance |
|
|
134
|
+
|
|
135
|
+
### Key capabilities
|
|
136
|
+
|
|
137
|
+
| Capability | What it gives you |
|
|
138
|
+
|---|---|
|
|
139
|
+
| **Universal CLI interface** | Any agent with shell access can call `sigil search` / `sigil remember` directly — works in Claude Code (Bash tool), Codex CLI, terminal agents, Hermes, CI scripts. No client integration required |
|
|
140
|
+
| **Auto-capture via hooks** | Zero manual `sigil remember` calls in Claude Code — the Stop hook handles routine saves |
|
|
141
|
+
| **Cross-agent shared memory** | Claude Code, Codex CLI, Cursor, Kiro all read and write the same brain |
|
|
142
|
+
| **Cross-machine via shared DB** | Laptop + home server + cloud agent on one Postgres = one memory |
|
|
143
|
+
| **Hybrid search** | pgvector cosine + tsvector BM25 fused via Reciprocal Rank Fusion (one SQL query) |
|
|
144
|
+
| **ACT-R + Hebbian re-ranking** | Recency × frequency activation + co-retrieval boosts (cognitive-science model, not vibes) |
|
|
145
|
+
| **Pluggable pods** | Five built-in kinds; add `slack_channel`, `github_pr`, `codex_session`, etc. as contract files — no schema migrations |
|
|
146
|
+
| **AUDM dedup** | Add / Update / Delete / Merge intelligence stops fact pile-up across thousands of saves |
|
|
147
|
+
| **Fully air-gappable** | Pick Ollama for both LLM and embeddings — zero data leaves your network |
|
|
148
|
+
| **No vendor account** | `npm install` + your Postgres = working brain. No signup, no API key required to start |
|
|
149
|
+
| **Hot-context snapshot** | Top-20 facts always loaded via `@~/.sigil/CLAUDE.md` import — instant context with zero latency |
|
|
150
|
+
| **9-tool MCP server** | `search`, `search_entity`, `traverse_graph`, `get_fact_context`, `get_entity_context`, `get_pod`, `list_pods`, `status`, `ingest` |
|
|
151
|
+
| **Honest benchmarks** | Public LongMemEval oracle: R@10 = 100%, 33ms p50 search. Reproducible — not in-house corpus theater |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Quickstart
|
|
156
|
+
|
|
157
|
+
Sigil needs **Postgres 13+ with the `pgvector` extension** running somewhere reachable. You bring the server; `sigil init` does everything else.
|
|
158
|
+
|
|
159
|
+
### 1. Have Postgres running
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Recommended — pgvector image includes the extension out of the box
|
|
163
|
+
docker run -d --name sigil-pg -p 5432:5432 \
|
|
164
|
+
-e POSTGRES_PASSWORD=sigil_dev pgvector/pgvector:pg15
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Alternatives: `brew install postgresql@15 pgvector && brew services start postgresql@15`, or any managed Postgres with the `vector` extension enabled (RDS, Neon, Supabase, Crunchy, …).
|
|
168
|
+
|
|
169
|
+
### 2. Install + setup
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm install -g @anmol-srv/sigil
|
|
173
|
+
sigil init
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`sigil init`:
|
|
177
|
+
|
|
178
|
+
1. Asks for your LLM provider (OpenRouter, OpenAI, Anthropic, Ollama, or Claude Code subscription).
|
|
179
|
+
2. Asks for your embedding provider (OpenAI, Voyage, or Ollama).
|
|
180
|
+
3. Asks for your Postgres connection. **If the `sigil` database doesn't exist yet, it asks once for Postgres admin credentials and auto-creates the database, the `sigil_app` user, and the `vector` extension.** Admin creds are used once and never written to disk; only `sigil_app` credentials land in `~/.sigil/.env`.
|
|
181
|
+
4. Runs schema migrations.
|
|
182
|
+
5. Auto-detects every AI client on your machine (Claude Code, Codex CLI, Cursor, Kiro) and wires Sigil into each one — hooks for Claude Code, MCP server registration + steering rules for the rest. Adds `@~/.sigil/CLAUDE.md` to your global Claude config so hot-context is always loaded.
|
|
183
|
+
|
|
184
|
+
Re-running `sigil init` is idempotent. Existing `~/.sigil/.env` keys are preserved — only prompted values are updated.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
sigil doctor # verify everything's wired
|
|
188
|
+
```
|
|
189
|
+
```
|
|
190
|
+
Sigil diagnostic
|
|
191
|
+
|
|
192
|
+
✓ Config file — ~/.sigil/.env
|
|
193
|
+
✓ Config validation — no provider/model mismatches
|
|
194
|
+
✓ Database — Postgres @ localhost:5432/sigil
|
|
195
|
+
✓ Stored data — 0 docs, 0 chunks, 0 facts
|
|
196
|
+
✓ LLM provider — openrouter (model=google/gemini-flash-latest)
|
|
197
|
+
✓ Embedding provider — openai / text-embedding-3-large
|
|
198
|
+
✓ UserPromptSubmit hook — registered
|
|
199
|
+
✓ PostToolUse hook — registered
|
|
200
|
+
✓ Stop hook — registered
|
|
201
|
+
✓ SessionEnd hook — registered
|
|
202
|
+
✓ Sigil CLAUDE.md
|
|
203
|
+
✓ Hook errors — none
|
|
204
|
+
|
|
205
|
+
All checks passed.
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 3. Use it
|
|
209
|
+
|
|
210
|
+
Tell Sigil something once:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
sigil remember "Project uses Postgres LISTEN/NOTIFY for events, not Redis pubsub"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Open Claude Code in any project tomorrow. Ask "what's our event delivery setup?" — Claude answers correctly. The `UserPromptSubmit` hook injected the fact before Claude saw your prompt.
|
|
217
|
+
|
|
218
|
+
In practice you rarely call `sigil remember` directly. The `Stop` hook runs a classifier on every user message and auto-saves anything memorable (preferences, decisions, constraints, factual claims). The `PostToolUse` hook captures observations from Edit/Write/Bash.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Use with other MCP clients
|
|
223
|
+
|
|
224
|
+
`sigil init` auto-wires Codex CLI, Cursor, and Kiro on first run if it detects them — no manual config needed. For everything else (Continue, Cline, Windsurf, your custom MCP-spec agent), `sigil register --print` outputs the standard MCP config JSON:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"mcpServers": {
|
|
229
|
+
"sigil": {
|
|
230
|
+
"command": "/usr/local/bin/node",
|
|
231
|
+
"args": ["/path/to/sigil/dist/server.js", "--mcp"],
|
|
232
|
+
"env": { "DOTENV_CONFIG_PATH": "/Users/you/.sigil/.env" }
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Drop the inner `sigil: {...}` object into your client's MCP config:
|
|
239
|
+
|
|
240
|
+
| Client | Config file | Auto-wired by `sigil init`? |
|
|
241
|
+
|---|---|---|
|
|
242
|
+
| Codex CLI | `~/.codex/config.toml` | ✓ |
|
|
243
|
+
| Cursor | `~/.cursor/mcp.json` (or Settings → MCP) | ✓ |
|
|
244
|
+
| Kiro | `~/.kiro/settings/mcp.json` | ✓ |
|
|
245
|
+
| Continue.dev | `~/.continue/config.json` | — |
|
|
246
|
+
| Cline (VS Code) | `cline_mcp_settings.json` in your VS Code user dir | — |
|
|
247
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | — |
|
|
248
|
+
| Any other MCP-spec client | client's MCP config | — |
|
|
249
|
+
|
|
250
|
+
The agent now sees nine tools: `search`, `search_entity`, `traverse_graph`, `get_fact_context`, `get_entity_context`, `get_pod`, `list_pods`, `status`, `ingest`. Most agents use them well if their system prompt mentions Sigil; if not, a short nudge helps:
|
|
251
|
+
|
|
252
|
+
> "You have access to a persistent memory system called Sigil. Before answering about projects, preferences, or past decisions, call `sigil_search`. When the user shares preferences, decisions, or constraints, call `sigil_ingest` to save them."
|
|
253
|
+
|
|
254
|
+
Unlike Claude Code there's no hook layer — the agent decides when to call. Capture relies on the agent or on you running `sigil remember` from the CLI.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Cross-machine memory
|
|
259
|
+
|
|
260
|
+
Point multiple installs at the same Postgres and they share one brain:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Machine 1 (laptop)
|
|
264
|
+
SIGIL_DB_HOST=postgres.your-network.local sigil init
|
|
265
|
+
|
|
266
|
+
# Machine 2 (home server, different OS, doesn't matter)
|
|
267
|
+
SIGIL_DB_HOST=postgres.your-network.local sigil init
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Both machines now share memory. A fact captured on machine 1 surfaces on machine 2's next prompt. Reads and writes go directly to Postgres; consistency is whatever Postgres gives you (which is plenty for personal memory).
|
|
271
|
+
|
|
272
|
+
Use cases this unlocks:
|
|
273
|
+
|
|
274
|
+
- **Laptop + desktop.** Same memory across both, no manual sync.
|
|
275
|
+
- **Local dev + cloud agent.** Your laptop's Claude Code and a Sentry-triage agent running on a VPS share one brain. The agent writes "fixed prod issue X by patching Y"; your morning prompt sees it.
|
|
276
|
+
- **Multi-agent workflows.** Claude Code + Hermes + Codex all hitting the same memory. Each pod kind keeps writes attributed; agents in 0.11.0+ get their own `agent:<name>` pod for write attribution.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Benchmarks
|
|
281
|
+
|
|
282
|
+
### Retrieval — LongMemEval oracle split
|
|
283
|
+
|
|
284
|
+
| Metric | Sigil | Notes |
|
|
285
|
+
|---|---|---|
|
|
286
|
+
| R@1 / R@3 / R@10 | **100% / 100% / 100%** | n=100, oracle split, OpenAI top-quality stack |
|
|
287
|
+
| Answer correctness (LLM-judged) | **43%** | Bottlenecked by gpt-4o's temporal reasoning, not Sigil retrieval |
|
|
288
|
+
| Cost / Wall time | $0.21 / 37 min | Single n=100 run end-to-end |
|
|
289
|
+
|
|
290
|
+
Honest caveats in [`eval/longmemeval/RESULTS.md`](./eval/longmemeval/RESULTS.md): oracle is the easy split, n=100 is small, per-question haystack is ~25 chunks. Numbers aren't directly comparable to Mem0 / Zep / Letta runs without identical methodology. The retrieval ceiling is essentially the embedding model's quality at this scale; Sigil's architectural work (Hebbian, ACT-R, pod-aware blending) shows more at 10K+ chunks.
|
|
291
|
+
|
|
292
|
+
### Local latency
|
|
293
|
+
|
|
294
|
+
| Metric | Sigil (local Postgres) |
|
|
295
|
+
|---|---|
|
|
296
|
+
| Search latency (avg / p95) | 33ms / 61ms |
|
|
297
|
+
| Embedding latency | 26ms |
|
|
298
|
+
| Tokens injected per prompt | ~1.5K |
|
|
299
|
+
|
|
300
|
+
Hook hot-path latency (cold Node start + Postgres connect + search) is higher — 200-400ms on first invocation, then warm. If that's unacceptable, comment the `UserPromptSubmit` hook out of `~/.claude/settings.json` and rely on the hot-context `CLAUDE.md` snapshot + on-demand MCP `search`.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Commands
|
|
305
|
+
|
|
306
|
+
| Command | Description |
|
|
307
|
+
|---|---|
|
|
308
|
+
| `sigil init` | Interactive setup — providers, Postgres, hooks |
|
|
309
|
+
| `sigil doctor` | Diagnose config, DB, providers, hook registration, error budget |
|
|
310
|
+
| `sigil remember "text" [--bg]` | Save fact(s) directly. `--bg` returns immediately |
|
|
311
|
+
| `sigil ingest <file\|url\|glob>` | Ingest one or many documents |
|
|
312
|
+
| `sigil search "query" [--pod-scope=auto\|global\|<name>]` | Search the brain |
|
|
313
|
+
| `sigil why "query"` | Explain a search — per-fact RRF / pod / kind / importance breakdown |
|
|
314
|
+
| `sigil kind list` / `sigil kind show <name>` | Inspect registered pod kinds |
|
|
315
|
+
| `sigil pod list / show / create / archive / delete` | Manage pods |
|
|
316
|
+
| `sigil session list / current / show <uid>` | Inspect Claude Code session pods |
|
|
317
|
+
| `sigil facts [--limit=N]` | List stored facts with IDs |
|
|
318
|
+
| `sigil forget <id>` | Delete a fact |
|
|
319
|
+
| `sigil context [--explain]` | Refresh / explain the hot-context snapshot |
|
|
320
|
+
| `sigil status` | KB statistics |
|
|
321
|
+
| `sigil namespace list / delete <ns> --confirm` | Manage namespaces |
|
|
322
|
+
| `sigil export [--format=json\|markdown]` | Export everything |
|
|
323
|
+
| `sigil migrate` | Run pending DB migrations |
|
|
324
|
+
| `sigil reset --confirm` | Drop all data (destructive) |
|
|
325
|
+
| `sigil register [--print]` | (Re)register the MCP server |
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Providers
|
|
330
|
+
|
|
331
|
+
Sigil supports five LLM providers and three embedding providers with automatic detection.
|
|
332
|
+
|
|
333
|
+
### LLM
|
|
334
|
+
|
|
335
|
+
| Provider | API key | Notes |
|
|
336
|
+
|---|---|---|
|
|
337
|
+
| **OpenRouter** | `OPENROUTER_API_KEY` | One key, namespaced models (Anthropic / OpenAI / Meta / Google / ...). Default model: `google/gemini-flash-latest`. |
|
|
338
|
+
| **Anthropic** | `ANTHROPIC_API_KEY` | Direct Claude access; pinned model defaults |
|
|
339
|
+
| **OpenAI** | `OPENAI_API_KEY` | Cheapest API option (gpt-4o-mini) |
|
|
340
|
+
| **Ollama** | none | Fully local, runs on your machine |
|
|
341
|
+
| **Claude Code** (`claude-cli`) | none | Uses your existing Claude Code subscription |
|
|
342
|
+
|
|
343
|
+
OpenRouter init has an opt-in "Advanced overrides" step that pre-fills a smart split: cheap model for high-volume extraction, Sonnet for AUDM decisions and read-time synthesis.
|
|
344
|
+
|
|
345
|
+
### Embeddings
|
|
346
|
+
|
|
347
|
+
| Provider | API key | Default model | Dim | Notes |
|
|
348
|
+
|---|---|---|---|---|
|
|
349
|
+
| **OpenAI** | `OPENAI_API_KEY` | `text-embedding-3-large` | 1024 (truncated) | Best quality/cost |
|
|
350
|
+
| **Voyage** | `VOYAGE_API_KEY` | `voyage-3-large` | 1024 | MTEB ~76, Anthropic-recommended |
|
|
351
|
+
| **Ollama** | none | `nomic-embed-text` | 768 | Free, local |
|
|
352
|
+
|
|
353
|
+
### Auto-detection waterfall
|
|
354
|
+
|
|
355
|
+
**LLM:** `LLM_PROVIDER` env > OpenRouter key > Anthropic key > OpenAI key > Ollama reachable > `claude` CLI installed.
|
|
356
|
+
|
|
357
|
+
**Embeddings:** `EMBEDDING_PROVIDER` env > Voyage key > Ollama reachable > OpenAI key.
|
|
358
|
+
|
|
359
|
+
### Per-task overrides
|
|
360
|
+
|
|
361
|
+
Route specific tasks through different models via the `provider:model` syntax:
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
LLM_OPENROUTER_MODEL=google/gemini-flash-latest # default everywhere
|
|
365
|
+
LLM_EXTRACTION_MODEL=openrouter:qwen/qwen3.5-flash # cheap, called per chunk
|
|
366
|
+
LLM_DECISION_MODEL=openrouter:anthropic/claude-sonnet-latest # smart AUDM
|
|
367
|
+
SIGIL_SYNTH_MODEL=openrouter:anthropic/claude-sonnet-latest # smart synthesis
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Files Sigil owns
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
~/.sigil/
|
|
376
|
+
├── .env # Config, API keys, Postgres connection
|
|
377
|
+
├── CLAUDE.md # Instructions + hot-context snapshot
|
|
378
|
+
├── .hook-errors.log # Append-only diagnostic log
|
|
379
|
+
└── .last-clean-doctor # Ack timestamp for proactive warnings
|
|
380
|
+
|
|
381
|
+
~/.claude/
|
|
382
|
+
├── CLAUDE.md # @import line to ~/.sigil/CLAUDE.md (one line added)
|
|
383
|
+
└── settings.json # 4 hook entries (merged, not overwritten)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Memory itself lives in your Postgres. Embeddings stay local if you use Ollama; otherwise text leaves your machine only when calling your chosen LLM / embedding API.
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## FAQ
|
|
391
|
+
|
|
392
|
+
**Q: Does it work with Cursor / Codex / Windsurf / Continue / Cline?**
|
|
393
|
+
A: Yes — anything that speaks MCP can use Sigil. See [Use with other MCP clients](#use-with-other-mcp-clients). You lose Claude Code's auto-injection and auto-saving (the four hooks); your agent calls the MCP tools when it decides to. The memory engine is identical.
|
|
394
|
+
|
|
395
|
+
**Q: Does my data leave my machine?**
|
|
396
|
+
A: It depends on your providers. Memory storage is your own Postgres. Embeddings with Ollama stay local. The LLM call (for fact extraction, AUDM decisions, synthesis) sends text to whichever provider you picked — OpenRouter, OpenAI, Anthropic, or Ollama-local. Pick all-local (Ollama LLM + Ollama embeddings) for zero data egress.
|
|
397
|
+
|
|
398
|
+
**Q: Can I back up the brain?**
|
|
399
|
+
A: `sigil export --format=json --output=backup.json` exports facts, entities, pods, and documents. Or take a Postgres dump (`pg_dump sigil > sigil.sql`). To restore on a new machine: `pg_restore` then `sigil migrate` then `sigil init` (to set up the env).
|
|
400
|
+
|
|
401
|
+
**Q: Multi-user / team support?**
|
|
402
|
+
A: Single-user for now. Multiple installs sharing one Postgres works (see [Cross-machine memory](#cross-machine-memory)) but write attribution and ACLs (each pod is private / shared / public) land in 0.11.0+ along with the `agent` kind.
|
|
403
|
+
|
|
404
|
+
**Q: What happens if a hook crashes?**
|
|
405
|
+
A: Your prompt still goes through. Every hook wraps in a top-level try/catch that fails silently — Sigil's invariant is **a broken memory layer must never block a working prompt.** Errors append to `~/.sigil/.hook-errors.log`; `sigil doctor` surfaces them. After 5 unacked errors in 24h, `sigil doctor` exits with code 1 so CI / scripts can catch it.
|
|
406
|
+
|
|
407
|
+
**Q: How do I uninstall cleanly?**
|
|
408
|
+
A: `npm uninstall -g @anmol-srv/sigil` removes the binary. `rm -rf ~/.sigil` removes data and config. Unwire from Claude Code by removing the sigil hook entries from `~/.claude/settings.json` and the `@~/.sigil/CLAUDE.md` line from `~/.claude/CLAUDE.md`. The Postgres database (`sigil`) and user (`sigil_app`) survive — drop them yourself if you want them gone.
|
|
409
|
+
|
|
410
|
+
**Q: Where can I see how the retrieval pipeline actually works?**
|
|
411
|
+
A: Read `src/memory/search/hybrid.js` (entry point) and `src/memory/search/hybrid-sql.js` (the single-SQL RRF + ACT-R activation query). The pod kind registry contracts are in `src/memory/pods/kinds/`. Hooks are in `src/hooks/`.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## License
|
|
416
|
+
|
|
417
|
+
ISC. See [LICENSE](./LICENSE).
|