sqlite-graph-memory 0.3.2__tar.gz → 0.3.5__tar.gz
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.
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/CHANGELOG.md +53 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/PKG-INFO +99 -21
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/README.md +98 -20
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/bench/README.md +3 -2
- sqlite_graph_memory-0.3.5/docs/demo.gif +0 -0
- sqlite_graph_memory-0.3.5/docs/demo.sh +33 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/eval/build_gold.py +6 -3
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/examples/README.md +1 -1
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/pyproject.toml +2 -1
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/__init__.py +1 -1
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/brain_ask.py +3 -0
- sqlite_graph_memory-0.3.5/src/sqlite_graph_memory/doctor.py +133 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/index_notes.py +6 -6
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/mcp_server.py +10 -3
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_bench.py +43 -0
- sqlite_graph_memory-0.3.5/tests/test_changelog_released.py +146 -0
- sqlite_graph_memory-0.3.5/tests/test_doctor.py +70 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_eval.py +19 -0
- sqlite_graph_memory-0.3.5/tests/test_feedback_link.py +29 -0
- sqlite_graph_memory-0.3.5/tests/test_index_notes_dotfiles.py +81 -0
- sqlite_graph_memory-0.3.5/tests/test_mcp_script_mode.py +59 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_mcp_server.py +38 -2
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_star_prompt.py +3 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/.gitignore +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/CITATION.cff +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/LICENSE +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/bench/requirements.txt +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/docs/RELEASING.md +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/docs/bitemporal.md +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/eval/run_eval.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/examples/claude-code-stop-hook.json +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/examples/mcp-config.json +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/requirements.txt +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/ppr.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/schema.sql +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/turnstate_hook.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/turnstate_show.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/vault_stats.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_brain_ask.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_index_notes.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_llms_txt.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_optional_extra.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_ppr.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_turnstate_hook.py +0 -0
- {sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/tests/test_vault_stats.py +0 -0
|
@@ -4,6 +4,59 @@ What shipped, in plain words. Entries below v0.1.3 were written on 2026-09-05 fr
|
|
|
4
4
|
release notes that already existed — the file itself did not exist until then, so those three are
|
|
5
5
|
recorded after the fact rather than backdated to look contemporaneous.
|
|
6
6
|
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
## v0.3.5 - 2026-11-01
|
|
10
|
+
|
|
11
|
+
**Release fix.** v0.3.4 was tagged but never reached PyPI: the release commit changed only this file, and the publish job stopped on its version check (pyproject, `__init__`, server.json still said 0.3.3). v0.3.5 is the first PyPI build with everything listed under v0.3.4 plus the entries below, with the version set in all four places.
|
|
12
|
+
|
|
13
|
+
**MCP: recall no longer dies on the first cold call.** The default deadline is now 180 seconds (was a fixed 60): on a clean Windows install one CLI recall took 89 s, so the first MCP call timed out. `BRAIN_RECALL_TIMEOUT` overrides it; valid values are integer seconds from 1 to 600. Invalid values return a visible configuration error without starting recall. Timeout errors name the actual configured deadline. Reproduced during a clean Windows installation: CLI recall succeeded while the MCP child hit the previous fixed 60-second deadline.
|
|
14
|
+
|
|
15
|
+
**Tests: tilde expansion isolated on Windows.** The test sets the Windows home directory as well as the Unix home directory. It now checks the temporary profile on Windows instead of writing a marker into the real user's profile.
|
|
16
|
+
|
|
17
|
+
**Docs: preserve an existing agent setup.** README links to the existing-setup guide in second-brain-starter-kit, covering per-client memory installation and fresh-chat acceptance without replacing the owner's rules.
|
|
18
|
+
|
|
19
|
+
**`sgm-doctor`: one command that checks a fresh install in plain words.** Python, SQLite, numpy,
|
|
20
|
+
torch and sentence-transformers, the two models in the local cache, and your index, each with an
|
|
21
|
+
ok/warn/fail verdict and the fix printed next to it; exit 1 when anything fails. On an Intel Mac
|
|
22
|
+
with NumPy 2 it names the pairing that crashes indexing instead of a bare import error.
|
|
23
|
+
|
|
24
|
+
## v0.3.4 - 2026-10-31
|
|
25
|
+
|
|
26
|
+
**Credit, written down at last.** Four outside pull requests merged since 19.10 and none was named
|
|
27
|
+
here. Thanks to [@Kaap10](https://github.com/Kaap10): the MCP server now answers non-object JSON
|
|
28
|
+
payloads with `-32600 Invalid Request` instead of failing (#32, closes #22), and finds its
|
|
29
|
+
`brain_ask` sibling and passes a non-zero exit through in test mode (#33, closes #24). Thanks to
|
|
30
|
+
[@Vamsi-2581](https://github.com/Vamsi-2581): a missing embedding index is now reported as an error
|
|
31
|
+
instead of passing silently (#35). Thanks to [@Khushbu677](https://github.com/Khushbu677): tests for
|
|
32
|
+
the turnstate hook's ledger writes (#57). From now on `scripts/credit_gate.py` runs in CI and goes red
|
|
33
|
+
when a merged outside PR has no line here, or when a `@handle` here does not exist; the rules are in
|
|
34
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
35
|
+
|
|
36
|
+
**Also in this release.** Benchmark adapters for four external memory systems (fidelis, mem0 local, second-brain, SQLite FTS5) with CI reruns pinned to one Ollama build and one CPU kernel, and CI guards that freeze released CHANGELOG sections and fail on unreadable tags, pre-release tags and duplicate headers.
|
|
37
|
+
|
|
38
|
+
## v0.3.3 — 2026-10-26
|
|
39
|
+
|
|
40
|
+
**Hidden note files are skipped like hidden folders.** A note whose filename starts with a
|
|
41
|
+
dot, such as `.ideas.md` or `.draft.md`, used to be indexed when it sat in the vault root or a
|
|
42
|
+
visible folder, while the same file inside `.drafts/` was skipped. Now both are skipped, so
|
|
43
|
+
after re-indexing those notes stop showing up in answers. `BRAIN_INDEX_HIDDEN=1` brings back
|
|
44
|
+
the old behaviour and indexes hidden files and folders alike. `eval/build_gold.py` now walks the
|
|
45
|
+
vault with the indexer's own filter, so it follows the same rule and the same variable instead
|
|
46
|
+
of keeping its own copy (issue #25).
|
|
47
|
+
|
|
48
|
+
**The MCP server works from a source checkout and finds your index where you launch it**
|
|
49
|
+
(issue #24, reported by @Kaap10). `sgm-mcp` used to run the recall child with its working
|
|
50
|
+
directory set to the package folder, so a relative `BRAIN_INDEX_DIR=index` resolved inside
|
|
51
|
+
site-packages and your own index was never found; from a plain clone without `pip install -e`,
|
|
52
|
+
`python src/sqlite_graph_memory/mcp_server.py --test` failed with ModuleNotFoundError. Recall now
|
|
53
|
+
runs in the server's own working directory, and CI reproduces the user's launch: installed wheel,
|
|
54
|
+
relative index, started from another directory.
|
|
55
|
+
|
|
56
|
+
**A three-question feedback form.** "What were you trying to do, what broke, which machine": an
|
|
57
|
+
issue template, a README section, and a link printed next to the missing-index error, because
|
|
58
|
+
this project collects no telemetry and that form is how we learn what is missing.
|
|
59
|
+
|
|
7
60
|
## v0.3.2 — 2026-10-24
|
|
8
61
|
|
|
9
62
|
**The PageRank lane the README credits is now in the package** (#51). `ppr.py` runs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sqlite-graph-memory
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
4
4
|
Summary: Associative memory for LLM agents: Graph RAG over a folder of markdown notes, in one SQLite file, with no server to run.
|
|
5
5
|
Project-URL: Homepage, https://github.com/tonydzi/sqlite-graph-memory
|
|
6
6
|
Project-URL: Repository, https://github.com/tonydzi/sqlite-graph-memory
|
|
@@ -53,17 +53,86 @@ Description-Content-Type: text/markdown
|
|
|
53
53
|
|
|
54
54
|
<!-- mcp-name: io.github.tonydzi/sqlite-graph-memory -->
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Your coding agent remembers what you already wrote down, and reaches the note a plain search
|
|
57
|
+
misses by following the links between your notes. It is an MCP server and a CLI over any
|
|
58
|
+
folder of markdown, Obsidian vaults included: `pip install`, point it at the folder, and
|
|
59
|
+
Claude Code, Cursor, Codex or any other MCP client can recall from it.
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
and a CLI over any folder of markdown, Obsidian vaults included. `pip install`, point it at
|
|
60
|
-
the folder, and Claude Code, Cursor, Codex or any other MCP client can recall from it.
|
|
61
|
+

|
|
61
62
|
|
|
62
63
|
**Your agent forgets everything between sessions, and plain vector search gives it back
|
|
63
64
|
flat, unrelated chunks. This gives it associative recall over your own markdown notes:
|
|
64
65
|
vector search finds the entry points, the `[[wikilinks]]` you already wrote are the graph.
|
|
65
66
|
One SQLite file, no graph database, no ETL pass, no server.**
|
|
66
67
|
|
|
68
|
+
[](https://pypi.org/project/sqlite-graph-memory/) [](https://github.com/tonydzi/sqlite-graph-memory/actions/workflows/tests.yml) [](https://registry.modelcontextprotocol.io/v0/servers?search=sqlite-graph-memory) [](LICENSE)
|
|
69
|
+
|
|
70
|
+
## Install in your client
|
|
71
|
+
|
|
72
|
+
Already using your own agent rules and projects? The [Russian existing-setup guide (proposed revision)](https://github.com/tonydzi/second-brain-starter-kit/blob/codex/dima-brain-H55019/docs/EXISTING-SETUP.ru.md) combines this memory backend with the optional starter-kit method, preserves existing settings, and checks recall in a fresh chat. Install one memory connection per client; the starter-kit memory plugin and manual registration are alternatives.
|
|
73
|
+
|
|
74
|
+
Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[embeddings]' sgm-index ~/notes
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then point your client at the server. Use the absolute path of that index folder.
|
|
81
|
+
|
|
82
|
+
**Cold-start timeout (0.3.5 and later).** The MCP server starts recall in a separate process with a default deadline of 180 seconds; a first call on a clean Windows install took 89 s, which the old fixed 60 s always cut off. Override with `BRAIN_RECALL_TIMEOUT` (integer seconds, 1 to 600; invalid values return an error). Your MCP client's own tool timeout must also allow the longer call. On 0.3.3 and earlier the deadline is a fixed 60 s: upgrade, or use `sgm-ask --ask` directly, and do not report MCP recall as verified merely because the CLI works.
|
|
83
|
+
|
|
84
|
+
**Claude Code**
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"sqlite-graph-memory": {
|
|
96
|
+
"command": "uvx",
|
|
97
|
+
"args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
|
|
98
|
+
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**VS Code** (`.vscode/mcp.json` in the workspace)
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"servers": {
|
|
109
|
+
"sqlite-graph-memory": {
|
|
110
|
+
"type": "stdio",
|
|
111
|
+
"command": "uvx",
|
|
112
|
+
"args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
|
|
113
|
+
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Codex** (`~/.codex/config.toml`)
|
|
120
|
+
|
|
121
|
+
```toml
|
|
122
|
+
[mcp_servers.sqlite-graph-memory]
|
|
123
|
+
command = "uvx"
|
|
124
|
+
args = ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"]
|
|
125
|
+
env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
|
|
129
|
+
26 MB and has no torch (numpy only, enough for the graph half and the SQLite ledger);
|
|
130
|
+
with `[embeddings]`, which indexing and recall need, it is 879 MB, 540 MB of that torch 2.2.2
|
|
131
|
+
CPU. On Linux the default torch wheel brings CUDA libraries and is bigger; not measured here.
|
|
132
|
+
Already installed with pip? Replace `uvx --with ... sqlite-graph-memory` by `sgm-mcp`
|
|
133
|
+
([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
|
|
134
|
+
[`llms.txt`](llms.txt).
|
|
135
|
+
|
|
67
136
|
## Three commands
|
|
68
137
|
|
|
69
138
|
```bash
|
|
@@ -110,14 +179,6 @@ That is the idea in one query, and it is not a blanket win. On this same vault v
|
|
|
110
179
|
ranks ahead of graph mode overall; the numbers are in [`bench/`](bench/README.md). `--ab`
|
|
111
180
|
exists so you can measure which one wins on your own notes.
|
|
112
181
|
|
|
113
|
-
**From any MCP client** (Claude Desktop, Cursor, Zed, Windsurf): `sgm-mcp` after the install
|
|
114
|
-
above, or `uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory`. Set
|
|
115
|
-
`BRAIN_INDEX_DIR` to the `index` folder `sgm-index` wrote. Config:
|
|
116
|
-
[`examples/mcp-config.json`](examples/mcp-config.json). Claude Code:
|
|
117
|
-
`claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=/path/to/index -- sgm-mcp`.
|
|
118
|
-
Codex: a `[mcp_servers.sqlite-graph-memory]` table in `~/.codex/config.toml` with
|
|
119
|
-
`command = "sgm-mcp"`. Agents that read files first: [`llms.txt`](llms.txt).
|
|
120
|
-
|
|
121
182
|
## What it is
|
|
122
183
|
|
|
123
184
|
Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
|
|
@@ -126,7 +187,7 @@ points, the `[[wikilinks]]` you already wrote by hand are the graph, and a cross
|
|
|
126
187
|
reranks what the hop dragged in.
|
|
127
188
|
SQLite is the only database ([`schema.sql`](src/sqlite_graph_memory/schema.sql)).
|
|
128
189
|
|
|
129
|
-
Status: **pilot**, and the word is load-bearing: it runs daily in one real setup (a ~
|
|
190
|
+
Status: **pilot**, and the word is load-bearing: it runs daily in one real setup (an index of ~28k curated notes, ~93k chunks, rebuilt nightly from a ~270k-file
|
|
130
191
|
Obsidian vault driven by Claude Code), but it is deliberately minimal and makes no attempt
|
|
131
192
|
to be general — see [What's intentionally missing](#whats-intentionally-missing), which is
|
|
132
193
|
where the uneven test coverage is described.
|
|
@@ -144,7 +205,7 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
|
|
|
144
205
|
edges as `[[wikilinks]]`, and `brain_ask.py` just parses them.
|
|
145
206
|
No extraction pass, and edge quality beats anything a model would mine.
|
|
146
207
|
- **SQLite is enough** — the only things worth persisting are derived state (a per-turn
|
|
147
|
-
ledger) and telemetry, and both are defined in [`schema.sql`](schema.sql).
|
|
208
|
+
ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
148
209
|
One file, stdlib driver, zero ops.
|
|
149
210
|
- The expensive part of RAG quality is a **reranker**, not graph infrastructure — see the
|
|
150
211
|
rerank step in `brain_ask.py`.
|
|
@@ -176,7 +237,7 @@ markdown notes (with [[wikilinks]])
|
|
|
176
237
|
turnstate_show.py = read-only viewer.
|
|
177
238
|
```
|
|
178
239
|
|
|
179
|
-
[`schema.sql`](schema.sql) documents both tables. The graph is **not** materialized in SQL:
|
|
240
|
+
[`schema.sql`](src/sqlite_graph_memory/schema.sql) documents both tables. The graph is **not** materialized in SQL:
|
|
180
241
|
`brain_ask.py` parses edges from the notes at query time, bounded to 1 hop / 40 neighbours.
|
|
181
242
|
That keeps the graph permanently in sync with the notes at zero maintenance cost; materialize
|
|
182
243
|
an edge table only when hop depth or corpus size demands it.
|
|
@@ -196,7 +257,7 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
196
257
|
vector-only recall, no ledger row.
|
|
197
258
|
A memory layer must never make the agent worse than having no memory layer.
|
|
198
259
|
- **Measure, don't believe.** `--ab` runs both pipelines on every real query and logs how
|
|
199
|
-
many notes the graph promoted into the top-N, to `ab_recall` in [`schema.sql`](schema.sql).
|
|
260
|
+
many notes the graph promoted into the top-N, to `ab_recall` in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
200
261
|
Whether "associative memory" earns its keep is a weekly SQL query, not a vibe.
|
|
201
262
|
|
|
202
263
|
### What's intentionally missing
|
|
@@ -252,7 +313,7 @@ present, and CPU works fine for small corpora.
|
|
|
252
313
|
|
|
253
314
|
### What `--ab` looks like
|
|
254
315
|
|
|
255
|
-
Output of `brain_ask.py` with `--ab`, on a toy 4-note corpus (real runs use
|
|
316
|
+
Output of `brain_ask.py` with `--ab`, on a toy 4-note corpus (real runs use an index of ~28k notes / ~93k chunks):
|
|
256
317
|
|
|
257
318
|
```
|
|
258
319
|
A/B RECALL: how should agent memory work
|
|
@@ -273,7 +334,7 @@ A/B RECALL: how should agent memory work
|
|
|
273
334
|
|
|
274
335
|
On a corpus this small the graph adds nothing — every note is already in the candidate
|
|
275
336
|
pool. The interesting deltas appear at scale, and that is exactly what the `ab_recall`
|
|
276
|
-
table in [`schema.sql`](schema.sql) accumulates evidence for.
|
|
337
|
+
table in [`schema.sql`](src/sqlite_graph_memory/schema.sql) accumulates evidence for.
|
|
277
338
|
|
|
278
339
|
## Public benchmark — `bench/`
|
|
279
340
|
|
|
@@ -402,6 +463,11 @@ Seven other changes were rejected by the same ruler, under one rule fixed in adv
|
|
|
402
463
|
| `sqlite-vec` (vec0) | full scan 11.99 s vs 0.14 s for a plain SQLite table, and its ANN missed 1.2 hits of 60 -> vectors live in SQLite, **the extension does not** |
|
|
403
464
|
| bi-temporal demotion of superseded notes | temporal +0.130 nDCG on a 41-question temporal set, but title −0.012 -> **merged behind a flag, default off** (in the home pipeline, not in this package) |
|
|
404
465
|
|
|
466
|
+
The two rows marked "home pipeline" are not in this package: BM25 fusion and superseded-note
|
|
467
|
+
demotion exist only in the maintainer's home build. Check it yourself in a clone:
|
|
468
|
+
`grep -rniE 'bm25|superseded' src/` prints nothing. The PageRank lane above is the one
|
|
469
|
+
merged change that ships (`src/sqlite_graph_memory/ppr.py`).
|
|
470
|
+
|
|
405
471
|
None of those verdicts is a claim about the models. They are claims about *this corpus with
|
|
406
472
|
this ruler*, which is the only kind of claim a swap decision actually needs — and the reason
|
|
407
473
|
the module is here rather than in a blog post is that your corpus will disagree with ours.
|
|
@@ -422,7 +488,7 @@ while the metric is broken never tested the metric.
|
|
|
422
488
|
|
|
423
489
|
## Roadmap
|
|
424
490
|
|
|
425
|
-
**Now — [latest release](https://github.com/tonydzi/sqlite-graph-memory/releases/latest)** (
|
|
491
|
+
**Now — [latest release](https://github.com/tonydzi/sqlite-graph-memory/releases/latest)** (the version badge above is the one on PyPI; the same version is in the MCP Registry).
|
|
426
492
|
The pilot as it runs daily: retrieval pipeline, per-turn ledger and A/B telemetry, all in
|
|
427
493
|
`brain_ask.py` and `turnstate_hook.py`, plus the bi-temporal design note. Known defects live in
|
|
428
494
|
the [tracker](https://github.com/tonydzi/sqlite-graph-memory/issues) rather than in footnotes
|
|
@@ -441,7 +507,8 @@ does not notice, and that drift is the defect this paragraph used to carry twice
|
|
|
441
507
|
materialize the graph instead of parsing it at query time, give every edge a validity
|
|
442
508
|
window (`valid_from` / `valid_to` / `observed_at`) so a rebuild *closes* superseded facts
|
|
443
509
|
instead of deleting them: history is kept, recall prefers the present, and `as_of` queries
|
|
444
|
-
can reconstruct the past. Non-destructive aging by confidence decay.
|
|
510
|
+
can reconstruct the past. Non-destructive aging by confidence decay. None of this is in
|
|
511
|
+
the package yet: it is a design note plus a home-pipeline experiment. The day-1 A/B result
|
|
445
512
|
— context size ~unchanged, retrieved candidates ~60% fresher by mean age — is written up
|
|
446
513
|
with its caveats in `docs/bitemporal.md`: the volume win is longitudinal, so that is one
|
|
447
514
|
day on one corpus, not a benchmark.
|
|
@@ -491,6 +558,17 @@ Questions, war stories, or you want to run this on your own fleet:
|
|
|
491
558
|
- 🌐 [palo-alto.ai](https://palo-alto.ai) · [Palo Alto AI Research Lab](https://github.com/tonydzi)
|
|
492
559
|
- 🧪 **Engineers: want to test-drive this setup?** Message me — I hand out free starter seeds to engineers who test and report back.
|
|
493
560
|
|
|
561
|
+
## Tell us what is missing
|
|
562
|
+
|
|
563
|
+
You tried this on your own notes and something was missing or broke. That is the most useful
|
|
564
|
+
thing anyone can tell us.
|
|
565
|
+
|
|
566
|
+
- **Install or first run gone wrong:** run `sgm-doctor` first. It checks Python, numpy, torch, the models and your index in plain words and prints the fix for each.
|
|
567
|
+
- **You started and it did not work:** [open the 3-question form](https://github.com/tonydzi/sqlite-graph-memory/issues/new?template=feature_request.yml) (what you tried, what broke, which machine).
|
|
568
|
+
- **Not sure it is a bug, or just an idea:** [Discussions → Ideas](https://github.com/tonydzi/sqlite-graph-memory/discussions/categories/ideas).
|
|
569
|
+
|
|
570
|
+
Nothing in this package phones home. There is no telemetry, so we only know what you write to us.
|
|
571
|
+
|
|
494
572
|
## Contributors welcome — and there is a queue
|
|
495
573
|
|
|
496
574
|
Issues labelled [`accepted`](https://github.com/tonydzi/sqlite-graph-memory/issues?q=is%3Aissue+is%3Aopen+label%3Aaccepted)
|
|
@@ -2,17 +2,86 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- mcp-name: io.github.tonydzi/sqlite-graph-memory -->
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Your coding agent remembers what you already wrote down, and reaches the note a plain search
|
|
6
|
+
misses by following the links between your notes. It is an MCP server and a CLI over any
|
|
7
|
+
folder of markdown, Obsidian vaults included: `pip install`, point it at the folder, and
|
|
8
|
+
Claude Code, Cursor, Codex or any other MCP client can recall from it.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
and a CLI over any folder of markdown, Obsidian vaults included. `pip install`, point it at
|
|
9
|
-
the folder, and Claude Code, Cursor, Codex or any other MCP client can recall from it.
|
|
10
|
+

|
|
10
11
|
|
|
11
12
|
**Your agent forgets everything between sessions, and plain vector search gives it back
|
|
12
13
|
flat, unrelated chunks. This gives it associative recall over your own markdown notes:
|
|
13
14
|
vector search finds the entry points, the `[[wikilinks]]` you already wrote are the graph.
|
|
14
15
|
One SQLite file, no graph database, no ETL pass, no server.**
|
|
15
16
|
|
|
17
|
+
[](https://pypi.org/project/sqlite-graph-memory/) [](https://github.com/tonydzi/sqlite-graph-memory/actions/workflows/tests.yml) [](https://registry.modelcontextprotocol.io/v0/servers?search=sqlite-graph-memory) [](LICENSE)
|
|
18
|
+
|
|
19
|
+
## Install in your client
|
|
20
|
+
|
|
21
|
+
Already using your own agent rules and projects? The [Russian existing-setup guide (proposed revision)](https://github.com/tonydzi/second-brain-starter-kit/blob/codex/dima-brain-H55019/docs/EXISTING-SETUP.ru.md) combines this memory backend with the optional starter-kit method, preserves existing settings, and checks recall in a fresh chat. Install one memory connection per client; the starter-kit memory plugin and manual registration are alternatives.
|
|
22
|
+
|
|
23
|
+
Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[embeddings]' sgm-index ~/notes
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then point your client at the server. Use the absolute path of that index folder.
|
|
30
|
+
|
|
31
|
+
**Cold-start timeout (0.3.5 and later).** The MCP server starts recall in a separate process with a default deadline of 180 seconds; a first call on a clean Windows install took 89 s, which the old fixed 60 s always cut off. Override with `BRAIN_RECALL_TIMEOUT` (integer seconds, 1 to 600; invalid values return an error). Your MCP client's own tool timeout must also allow the longer call. On 0.3.3 and earlier the deadline is a fixed 60 s: upgrade, or use `sgm-ask --ask` directly, and do not report MCP recall as verified merely because the CLI works.
|
|
32
|
+
|
|
33
|
+
**Claude Code**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"sqlite-graph-memory": {
|
|
45
|
+
"command": "uvx",
|
|
46
|
+
"args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
|
|
47
|
+
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**VS Code** (`.vscode/mcp.json` in the workspace)
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"servers": {
|
|
58
|
+
"sqlite-graph-memory": {
|
|
59
|
+
"type": "stdio",
|
|
60
|
+
"command": "uvx",
|
|
61
|
+
"args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
|
|
62
|
+
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Codex** (`~/.codex/config.toml`)
|
|
69
|
+
|
|
70
|
+
```toml
|
|
71
|
+
[mcp_servers.sqlite-graph-memory]
|
|
72
|
+
command = "uvx"
|
|
73
|
+
args = ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"]
|
|
74
|
+
env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
|
|
78
|
+
26 MB and has no torch (numpy only, enough for the graph half and the SQLite ledger);
|
|
79
|
+
with `[embeddings]`, which indexing and recall need, it is 879 MB, 540 MB of that torch 2.2.2
|
|
80
|
+
CPU. On Linux the default torch wheel brings CUDA libraries and is bigger; not measured here.
|
|
81
|
+
Already installed with pip? Replace `uvx --with ... sqlite-graph-memory` by `sgm-mcp`
|
|
82
|
+
([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
|
|
83
|
+
[`llms.txt`](llms.txt).
|
|
84
|
+
|
|
16
85
|
## Three commands
|
|
17
86
|
|
|
18
87
|
```bash
|
|
@@ -59,14 +128,6 @@ That is the idea in one query, and it is not a blanket win. On this same vault v
|
|
|
59
128
|
ranks ahead of graph mode overall; the numbers are in [`bench/`](bench/README.md). `--ab`
|
|
60
129
|
exists so you can measure which one wins on your own notes.
|
|
61
130
|
|
|
62
|
-
**From any MCP client** (Claude Desktop, Cursor, Zed, Windsurf): `sgm-mcp` after the install
|
|
63
|
-
above, or `uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory`. Set
|
|
64
|
-
`BRAIN_INDEX_DIR` to the `index` folder `sgm-index` wrote. Config:
|
|
65
|
-
[`examples/mcp-config.json`](examples/mcp-config.json). Claude Code:
|
|
66
|
-
`claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=/path/to/index -- sgm-mcp`.
|
|
67
|
-
Codex: a `[mcp_servers.sqlite-graph-memory]` table in `~/.codex/config.toml` with
|
|
68
|
-
`command = "sgm-mcp"`. Agents that read files first: [`llms.txt`](llms.txt).
|
|
69
|
-
|
|
70
131
|
## What it is
|
|
71
132
|
|
|
72
133
|
Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
|
|
@@ -75,7 +136,7 @@ points, the `[[wikilinks]]` you already wrote by hand are the graph, and a cross
|
|
|
75
136
|
reranks what the hop dragged in.
|
|
76
137
|
SQLite is the only database ([`schema.sql`](src/sqlite_graph_memory/schema.sql)).
|
|
77
138
|
|
|
78
|
-
Status: **pilot**, and the word is load-bearing: it runs daily in one real setup (a ~
|
|
139
|
+
Status: **pilot**, and the word is load-bearing: it runs daily in one real setup (an index of ~28k curated notes, ~93k chunks, rebuilt nightly from a ~270k-file
|
|
79
140
|
Obsidian vault driven by Claude Code), but it is deliberately minimal and makes no attempt
|
|
80
141
|
to be general — see [What's intentionally missing](#whats-intentionally-missing), which is
|
|
81
142
|
where the uneven test coverage is described.
|
|
@@ -93,7 +154,7 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
|
|
|
93
154
|
edges as `[[wikilinks]]`, and `brain_ask.py` just parses them.
|
|
94
155
|
No extraction pass, and edge quality beats anything a model would mine.
|
|
95
156
|
- **SQLite is enough** — the only things worth persisting are derived state (a per-turn
|
|
96
|
-
ledger) and telemetry, and both are defined in [`schema.sql`](schema.sql).
|
|
157
|
+
ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
97
158
|
One file, stdlib driver, zero ops.
|
|
98
159
|
- The expensive part of RAG quality is a **reranker**, not graph infrastructure — see the
|
|
99
160
|
rerank step in `brain_ask.py`.
|
|
@@ -125,7 +186,7 @@ markdown notes (with [[wikilinks]])
|
|
|
125
186
|
turnstate_show.py = read-only viewer.
|
|
126
187
|
```
|
|
127
188
|
|
|
128
|
-
[`schema.sql`](schema.sql) documents both tables. The graph is **not** materialized in SQL:
|
|
189
|
+
[`schema.sql`](src/sqlite_graph_memory/schema.sql) documents both tables. The graph is **not** materialized in SQL:
|
|
129
190
|
`brain_ask.py` parses edges from the notes at query time, bounded to 1 hop / 40 neighbours.
|
|
130
191
|
That keeps the graph permanently in sync with the notes at zero maintenance cost; materialize
|
|
131
192
|
an edge table only when hop depth or corpus size demands it.
|
|
@@ -145,7 +206,7 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
145
206
|
vector-only recall, no ledger row.
|
|
146
207
|
A memory layer must never make the agent worse than having no memory layer.
|
|
147
208
|
- **Measure, don't believe.** `--ab` runs both pipelines on every real query and logs how
|
|
148
|
-
many notes the graph promoted into the top-N, to `ab_recall` in [`schema.sql`](schema.sql).
|
|
209
|
+
many notes the graph promoted into the top-N, to `ab_recall` in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
149
210
|
Whether "associative memory" earns its keep is a weekly SQL query, not a vibe.
|
|
150
211
|
|
|
151
212
|
### What's intentionally missing
|
|
@@ -201,7 +262,7 @@ present, and CPU works fine for small corpora.
|
|
|
201
262
|
|
|
202
263
|
### What `--ab` looks like
|
|
203
264
|
|
|
204
|
-
Output of `brain_ask.py` with `--ab`, on a toy 4-note corpus (real runs use
|
|
265
|
+
Output of `brain_ask.py` with `--ab`, on a toy 4-note corpus (real runs use an index of ~28k notes / ~93k chunks):
|
|
205
266
|
|
|
206
267
|
```
|
|
207
268
|
A/B RECALL: how should agent memory work
|
|
@@ -222,7 +283,7 @@ A/B RECALL: how should agent memory work
|
|
|
222
283
|
|
|
223
284
|
On a corpus this small the graph adds nothing — every note is already in the candidate
|
|
224
285
|
pool. The interesting deltas appear at scale, and that is exactly what the `ab_recall`
|
|
225
|
-
table in [`schema.sql`](schema.sql) accumulates evidence for.
|
|
286
|
+
table in [`schema.sql`](src/sqlite_graph_memory/schema.sql) accumulates evidence for.
|
|
226
287
|
|
|
227
288
|
## Public benchmark — `bench/`
|
|
228
289
|
|
|
@@ -351,6 +412,11 @@ Seven other changes were rejected by the same ruler, under one rule fixed in adv
|
|
|
351
412
|
| `sqlite-vec` (vec0) | full scan 11.99 s vs 0.14 s for a plain SQLite table, and its ANN missed 1.2 hits of 60 -> vectors live in SQLite, **the extension does not** |
|
|
352
413
|
| bi-temporal demotion of superseded notes | temporal +0.130 nDCG on a 41-question temporal set, but title −0.012 -> **merged behind a flag, default off** (in the home pipeline, not in this package) |
|
|
353
414
|
|
|
415
|
+
The two rows marked "home pipeline" are not in this package: BM25 fusion and superseded-note
|
|
416
|
+
demotion exist only in the maintainer's home build. Check it yourself in a clone:
|
|
417
|
+
`grep -rniE 'bm25|superseded' src/` prints nothing. The PageRank lane above is the one
|
|
418
|
+
merged change that ships (`src/sqlite_graph_memory/ppr.py`).
|
|
419
|
+
|
|
354
420
|
None of those verdicts is a claim about the models. They are claims about *this corpus with
|
|
355
421
|
this ruler*, which is the only kind of claim a swap decision actually needs — and the reason
|
|
356
422
|
the module is here rather than in a blog post is that your corpus will disagree with ours.
|
|
@@ -371,7 +437,7 @@ while the metric is broken never tested the metric.
|
|
|
371
437
|
|
|
372
438
|
## Roadmap
|
|
373
439
|
|
|
374
|
-
**Now — [latest release](https://github.com/tonydzi/sqlite-graph-memory/releases/latest)** (
|
|
440
|
+
**Now — [latest release](https://github.com/tonydzi/sqlite-graph-memory/releases/latest)** (the version badge above is the one on PyPI; the same version is in the MCP Registry).
|
|
375
441
|
The pilot as it runs daily: retrieval pipeline, per-turn ledger and A/B telemetry, all in
|
|
376
442
|
`brain_ask.py` and `turnstate_hook.py`, plus the bi-temporal design note. Known defects live in
|
|
377
443
|
the [tracker](https://github.com/tonydzi/sqlite-graph-memory/issues) rather than in footnotes
|
|
@@ -390,7 +456,8 @@ does not notice, and that drift is the defect this paragraph used to carry twice
|
|
|
390
456
|
materialize the graph instead of parsing it at query time, give every edge a validity
|
|
391
457
|
window (`valid_from` / `valid_to` / `observed_at`) so a rebuild *closes* superseded facts
|
|
392
458
|
instead of deleting them: history is kept, recall prefers the present, and `as_of` queries
|
|
393
|
-
can reconstruct the past. Non-destructive aging by confidence decay.
|
|
459
|
+
can reconstruct the past. Non-destructive aging by confidence decay. None of this is in
|
|
460
|
+
the package yet: it is a design note plus a home-pipeline experiment. The day-1 A/B result
|
|
394
461
|
— context size ~unchanged, retrieved candidates ~60% fresher by mean age — is written up
|
|
395
462
|
with its caveats in `docs/bitemporal.md`: the volume win is longitudinal, so that is one
|
|
396
463
|
day on one corpus, not a benchmark.
|
|
@@ -440,6 +507,17 @@ Questions, war stories, or you want to run this on your own fleet:
|
|
|
440
507
|
- 🌐 [palo-alto.ai](https://palo-alto.ai) · [Palo Alto AI Research Lab](https://github.com/tonydzi)
|
|
441
508
|
- 🧪 **Engineers: want to test-drive this setup?** Message me — I hand out free starter seeds to engineers who test and report back.
|
|
442
509
|
|
|
510
|
+
## Tell us what is missing
|
|
511
|
+
|
|
512
|
+
You tried this on your own notes and something was missing or broke. That is the most useful
|
|
513
|
+
thing anyone can tell us.
|
|
514
|
+
|
|
515
|
+
- **Install or first run gone wrong:** run `sgm-doctor` first. It checks Python, numpy, torch, the models and your index in plain words and prints the fix for each.
|
|
516
|
+
- **You started and it did not work:** [open the 3-question form](https://github.com/tonydzi/sqlite-graph-memory/issues/new?template=feature_request.yml) (what you tried, what broke, which machine).
|
|
517
|
+
- **Not sure it is a bug, or just an idea:** [Discussions → Ideas](https://github.com/tonydzi/sqlite-graph-memory/discussions/categories/ideas).
|
|
518
|
+
|
|
519
|
+
Nothing in this package phones home. There is no telemetry, so we only know what you write to us.
|
|
520
|
+
|
|
443
521
|
## Contributors welcome — and there is a queue
|
|
444
522
|
|
|
445
523
|
Issues labelled [`accepted`](https://github.com/tonydzi/sqlite-graph-memory/issues?q=is%3Aissue+is%3Aopen+label%3Aaccepted)
|
|
@@ -140,7 +140,7 @@ has seen.
|
|
|
140
140
|
|
|
141
141
|
## Limits, stated up front
|
|
142
142
|
|
|
143
|
-
- 202 notes is small. Dense retrieval at this size is easier than in
|
|
143
|
+
- 202 notes is small. Dense retrieval at this size is easier than in the ~28k-note production index,
|
|
144
144
|
so the bench measures failure modes, and it does not show how a system scales.
|
|
145
145
|
- The text is English only and comes from templates. The sentences are cleaner than real
|
|
146
146
|
notes, and that flatters extractive systems.
|
|
@@ -161,7 +161,8 @@ bench/
|
|
|
161
161
|
run.py run one system -> results/<name>.json
|
|
162
162
|
validate.py the CI gate (+ --selftest, --reproduce)
|
|
163
163
|
leaderboard.py results/*.json -> LEADERBOARD.md
|
|
164
|
-
adapters/ template.py, bm25.py, sgm.py
|
|
164
|
+
adapters/ template.py, bm25.py, sgm.py, sqlite_fts5.py, second_brain.py,
|
|
165
|
+
mem0_local.py, fidelis_memory.py (+ _extract.py, the shared answer floor)
|
|
165
166
|
results/ one JSON per system
|
|
166
167
|
```
|
|
167
168
|
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Renders docs/demo.gif, the clip at the top of the README. Real run, output not edited.
|
|
3
|
+
#
|
|
4
|
+
# pip install 'sqlite-graph-memory[embeddings]' # sgm-index and sgm-ask on PATH
|
|
5
|
+
# uvx --from 'asciinema<3' asciinema rec --cols 104 --rows 36 -c 'bash docs/demo.sh' demo.cast
|
|
6
|
+
# agg --idle-time-limit 2 --last-frame-duration 10 --font-size 16 --theme monokai demo.cast docs/demo.gif
|
|
7
|
+
#
|
|
8
|
+
# The only cut is agg's idle-time limit: on an x86_64 Mac CPU the embedding pass
|
|
9
|
+
# takes about a minute and prints nothing (the progress bar is off), so the gif
|
|
10
|
+
# skips that silence. The query is the one from "Three commands" in the README.
|
|
11
|
+
set -e
|
|
12
|
+
export TQDM_DISABLE=1 SGM_NO_STAR_PROMPT=1 TOKENIZERS_PARALLELISM=false
|
|
13
|
+
demo=$(mktemp -d)
|
|
14
|
+
cp -R "$(dirname "$0")/../bench/vault" "$demo/notes"
|
|
15
|
+
cd "$demo"
|
|
16
|
+
|
|
17
|
+
say() { # print a command as if typed, then run it
|
|
18
|
+
printf '\033[1;32m$\033[0m '
|
|
19
|
+
for ((i = 0; i < ${#1}; i++)); do printf '%s' "${1:i:1}"; sleep 0.045; done
|
|
20
|
+
echo; sleep 0.4
|
|
21
|
+
eval "$1" 2>/dev/null # model-loading warnings go to stderr
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
clear
|
|
25
|
+
printf '\033[2m# 202 markdown notes that link to each other with [[wikilinks]]\033[0m\n'
|
|
26
|
+
sleep 1.5
|
|
27
|
+
say 'sgm-index ./notes'
|
|
28
|
+
sleep 2
|
|
29
|
+
echo
|
|
30
|
+
say "sgm-ask --ab 'In which programming language is the tool behind Project Ouzel written?'"
|
|
31
|
+
sleep 1.5
|
|
32
|
+
printf '\n\033[2m# the answer is in tool-lanternfish; only the graph hop from project-ouzel reaches it\033[0m\n'
|
|
33
|
+
sleep 2
|
|
@@ -40,6 +40,9 @@ import sys
|
|
|
40
40
|
from collections import Counter
|
|
41
41
|
from pathlib import Path
|
|
42
42
|
|
|
43
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'src'))
|
|
44
|
+
from sqlite_graph_memory.index_notes import iter_notes # noqa: E402
|
|
45
|
+
|
|
43
46
|
WIKILINK_RX = re.compile(r'\[\[([^\]\|#]+)(?:[|#][^\]]*)?\]\]')
|
|
44
47
|
CYRILLIC_RX = re.compile(r'[а-яё]', re.I)
|
|
45
48
|
|
|
@@ -121,10 +124,10 @@ def read_notes(notes_dir, stems, folders=None):
|
|
|
121
124
|
"""Every indexed note, parsed into the fields the four classes need."""
|
|
122
125
|
root = Path(notes_dir)
|
|
123
126
|
paths = []
|
|
124
|
-
|
|
127
|
+
# The indexer's own walk: hidden files and dirs, conflict copies and BRAIN_INDEX_HIDDEN
|
|
128
|
+
# are decided in one place, so a gold answer is never a note the indexer would skip.
|
|
129
|
+
for p in iter_notes(root):
|
|
125
130
|
rel = p.relative_to(root)
|
|
126
|
-
if any(part.startswith('.') for part in rel.parts[:-1]): continue
|
|
127
|
-
if 'sync-conflict' in p.name: continue
|
|
128
131
|
if folders and (not rel.parts[:-1] or rel.parts[0] not in folders): continue
|
|
129
132
|
if p.stem.lower() not in stems: continue
|
|
130
133
|
paths.append(p)
|
|
@@ -109,7 +109,7 @@ All components share standard configuration variables:
|
|
|
109
109
|
| `BRAIN_INDEX_DIR` | `./index` | Directory where `index_notes.py` writes and `brain_ask.py` reads `_brain_e5.npy` and metadata. |
|
|
110
110
|
| `TURNSTATE_DB` | `./turnstate.db` | SQLite database holding per-turn ledger (`turns`) and A/B telemetry (`ab_recall`). |
|
|
111
111
|
| `BRAIN_ANSWER_OUT` | `./_brain_answer.txt` | File where the formatted context bundle or answer is mirrored. |
|
|
112
|
-
| `BRAIN_INDEX_HIDDEN` | `0` | If `1`, indexes hidden dot-directories too (by default skipped). |
|
|
112
|
+
| `BRAIN_INDEX_HIDDEN` | `0` | If `1`, indexes hidden dot-files (`.draft.md`) and dot-directories too (by default both are skipped). |
|
|
113
113
|
| `BRAIN_AB_JSON` | `None` | If set, `--ab` mode writes a structured JSON diff to this file path. |
|
|
114
114
|
| `AB_SOURCE` | `work` | Telemetry label written to `ab_recall.source` (`work`, `eval`, etc.). |
|
|
115
115
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sqlite-graph-memory"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.5"
|
|
8
8
|
description = "Associative memory for LLM agents: Graph RAG over a folder of markdown notes, in one SQLite file, with no server to run."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -72,6 +72,7 @@ sgm-stats = "sqlite_graph_memory.vault_stats:main"
|
|
|
72
72
|
sgm-turnstate-hook = "sqlite_graph_memory.turnstate_hook:main"
|
|
73
73
|
sgm-turnstate-show = "sqlite_graph_memory.turnstate_show:main"
|
|
74
74
|
sgm-mcp = "sqlite_graph_memory.mcp_server:main"
|
|
75
|
+
sgm-doctor = "sqlite_graph_memory.doctor:main"
|
|
75
76
|
# Same server under the package's own name, so `uvx sqlite-graph-memory` (what MCP
|
|
76
77
|
# registry clients run for a PyPI package) starts it without a --from flag.
|
|
77
78
|
sqlite-graph-memory = "sqlite_graph_memory.mcp_server:main"
|
{sqlite_graph_memory-0.3.2 → sqlite_graph_memory-0.3.5}/src/sqlite_graph_memory/brain_ask.py
RENAMED
|
@@ -31,6 +31,7 @@ for _s in (sys.stdout, sys.stderr):
|
|
|
31
31
|
try: _s.reconfigure(encoding='utf-8')
|
|
32
32
|
except Exception: pass
|
|
33
33
|
|
|
34
|
+
FEEDBACK_URL = 'https://github.com/tonydzi/sqlite-graph-memory/discussions/categories/ideas'
|
|
34
35
|
INDEX_DIR = Path(os.getenv('BRAIN_INDEX_DIR', 'index'))
|
|
35
36
|
AB_DB = Path(os.getenv('TURNSTATE_DB', 'turnstate.db'))
|
|
36
37
|
EMB = INDEX_DIR / '_brain_e5.npy'
|
|
@@ -299,6 +300,8 @@ def main():
|
|
|
299
300
|
query = ' '.join(a for a in args if a not in flags)
|
|
300
301
|
if not query or not EMB.exists():
|
|
301
302
|
sys.stderr.write('need an embedding index (%s) and a query — run index_notes.py first\n' % EMB)
|
|
303
|
+
if query and not EMB.exists():
|
|
304
|
+
print('Stuck? Tell us what you were trying to do: %s' % FEEDBACK_URL, file=sys.stderr)
|
|
302
305
|
raise SystemExit(1)
|
|
303
306
|
|
|
304
307
|
dev = pick_device()
|