sqlite-graph-memory 0.3.8__tar.gz → 0.3.9__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.8 → sqlite_graph_memory-0.3.9}/.gitignore +1 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/CHANGELOG.md +13 -1
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/PKG-INFO +20 -6
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/README.md +19 -5
- sqlite_graph_memory-0.3.9/plugin/README.md +24 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/pyproject.toml +1 -1
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/__init__.py +1 -1
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/brain_ask.py +14 -4
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/doctor.py +61 -13
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/index_notes.py +3 -1
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/ppr.py +33 -1
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/vault_stats.py +121 -35
- sqlite_graph_memory-0.3.9/tests/test_doctor.py +189 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_llms_txt.py +17 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_ppr.py +17 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_vault_stats.py +111 -0
- sqlite_graph_memory-0.3.8/tests/test_doctor.py +0 -94
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/CITATION.cff +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/LICENSE +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/bench/README.md +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/bench/requirements.txt +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/docs/RELEASING.md +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/docs/bitemporal.md +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/docs/demo.gif +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/docs/demo.sh +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/docs/memory-compare-2026-11.md +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/eval/build_gold.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/eval/run_ablation.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/eval/run_eval.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/examples/README.md +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/examples/claude-code-stop-hook.json +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/examples/mcp-config.json +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/requirements.txt +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/mcp_server.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/onnx_backend.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/schema.sql +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/turnstate_hook.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/turnstate_show.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_bench.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_brain_ask.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_changelog_released.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_eval.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_feedback_link.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_incremental_index.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_index_notes.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_index_notes_dotfiles.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_mcp_script_mode.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_mcp_server.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_onnx_backend.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_optional_extra.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_rerank_default.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_rerank_flag_eval.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_star_prompt.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_turnstate_hook.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_turnstate_show.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_uvx_python_pin.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_version_consistent.py +0 -0
- {sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/tests/test_version_flag.py +0 -0
|
@@ -4,7 +4,19 @@ 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
|
-
##
|
|
7
|
+
## v0.3.9 - 2026-11-14
|
|
8
|
+
|
|
9
|
+
**Plugin moved to `plugin/` with a locked runtime.** The Claude plugin directory refuses a PyPI version as a pin, so the plugin now starts the server with `uv run --locked` from its own folder, where `uv.lock` pins `sqlite-graph-memory[lite]` and every dependency by hash, with Intel Mac, Apple Silicon, Linux and Windows resolved separately (onnxruntime 1.32 has no Intel Mac wheel). The directory now checks only that folder, not the whole repo. Install command unchanged; plugins need `uv`. The server starts as `uv run --locked ${CLAUDE_PLUGIN_ROOT}/server.py`, a launcher whose `server.py.lock` pins everything (Intel Macs held at onnxruntime 1.23.2) and which maps the plugin option `CLAUDE_PLUGIN_OPTION_INDEX_DIR` to `BRAIN_INDEX_DIR`.
|
|
10
|
+
|
|
11
|
+
**Claude Code plugin.** `.claude-plugin/plugin.json` and `marketplace.json` make the repo installable with `/plugin install sqlite-graph-memory --marketplace tonydzi/sqlite-graph-memory`. It registers the same stdio server on `[lite]` (ONNX, no torch), asks for the index folder once, and keeps telemetry in the plugin's data folder. Checked 2026-11-12: `claude plugin validate . --strict` passes; installed into an empty `CLAUDE_CONFIG_DIR`, `claude mcp list` reports the server connected and `memory_recall` answers over a five-note synthetic folder.
|
|
12
|
+
|
|
13
|
+
**`sgm-doctor`: four edge-case fixes from review.** Thanks @Kaap10 (#110): imports `brain_ask` lazily so a missing or broken NumPy prints a plain-words `[FAIL]` instead of an unhandled traceback; marks missing transitive dependencies of `sentence-transformers` as `[FAIL]` rather than a missing extra warning; isolates custom `HF_HUB_CACHE` / `HF_HOME` directories without mixing in default caches and respects `XDG_CACHE_HOME`; and validates index `.npy` array shape against metadata chunks so truncated or 0-byte index files report `[FAIL]` (closes #107).
|
|
14
|
+
|
|
15
|
+
**Credits that predate the credit gate.** `scripts/credit_gate.py` checks merges since 2026-10-19, so two earlier outside contributions were never named here: @HeaTTap wrote the first tests for `looks_like_entity()` and `_links_in()` (#6, shipped in bench-v0.1), and @Deva4287 corrected the README test status (#7, same release). Recorded now so the changelog names every outside author.
|
|
16
|
+
|
|
17
|
+
**Recall: the PPR lane resolves `[[folder/note]]` and `[[note.md]]` links.** `ppr.build()` now normalises a wikilink target the way the 1-hop lane does, so `SGM_PPR=1` and the graph hop count the same edges instead of the PageRank lane silently dropping folder-qualified and `.md` targets. Thanks @bfs2021 (#108), who picked up #103.
|
|
18
|
+
|
|
19
|
+
**Docs: the Stop-hook ledger is telemetry, not a recall input.** `README.md` and `FOR-ROBOTS.md` now say where the per-turn ledger is introduced that recall never reads it, so past turns do not change what `brain_ask.py` or the MCP server return, and the crash-safety note no longer implies the Stop-hook sits on the recall path. Thanks @dbdefault (#112), who picked up #105.
|
|
8
20
|
|
|
9
21
|
## v0.3.8 - 2026-11-10
|
|
10
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sqlite-graph-memory
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
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
|
|
@@ -64,6 +64,8 @@ Claude Code, Cursor, Codex or any other MCP client can recall from it.
|
|
|
64
64
|
|
|
65
65
|
It fits [Andrej Karpathy's LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) (April 2026), where an agent maintains an interlinked markdown wiki and a search tool over the pages is the first helper he suggests adding: sgm is that search layer, read-only, and it follows your `[[wikilinks]]` as a graph. Independent project, not affiliated with or endorsed by him.
|
|
66
66
|
|
|
67
|
+
This package is layers 4 and 5 of a larger memory design (always-loaded instructions, auto memory, curated vault, verbatim originals, retrieval, turn ledger). The whole picture and a step-by-step install for you or your agent: [MEMORY.md in the starter kit](https://github.com/tonydzi/second-brain-starter-kit/blob/master/MEMORY.md) ([по-русски](https://github.com/tonydzi/second-brain-starter-kit/blob/master/MEMORY.ru.md)).
|
|
68
|
+
|
|
67
69
|

|
|
68
70
|
|
|
69
71
|
**Your agent forgets everything between sessions, and plain vector search gives it back
|
|
@@ -93,6 +95,14 @@ Then point your client at the server. Use the absolute path of that index folder
|
|
|
93
95
|
|
|
94
96
|
**Claude Code**
|
|
95
97
|
|
|
98
|
+
As a plugin (asks for the index folder on install, Claude Code 2.1.275 or later):
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
/plugin install sqlite-graph-memory --marketplace tonydzi/sqlite-graph-memory
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Or register the server by hand:
|
|
105
|
+
|
|
96
106
|
```bash
|
|
97
107
|
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --python 3.12 --with 'sqlite-graph-memory[lite]' sqlite-graph-memory
|
|
98
108
|
```
|
|
@@ -227,7 +237,8 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
|
|
|
227
237
|
No extraction pass, and edge quality beats anything a model would mine.
|
|
228
238
|
- **SQLite is enough** — the only things worth persisting are derived state (a per-turn
|
|
229
239
|
ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
230
|
-
One file, stdlib driver, zero ops.
|
|
240
|
+
One file, stdlib driver, zero ops. The ledger is telemetry, not memory: recall never reads it,
|
|
241
|
+
so past turns do not change what `brain_ask.py` or the MCP server return.
|
|
231
242
|
- **Measure before adding a stage.** The pilot shipped a cross-encoder reranker from day one;
|
|
232
243
|
measured later, it lowered recall on long queries (our 184-question gold set: body nDCG@12
|
|
233
244
|
0.640 reranked vs 0.815 dense; DolphinBench Riley slice, 1000 sessions: R@5 0.48 vs 0.61).
|
|
@@ -259,6 +270,8 @@ markdown notes (with [[wikilinks]])
|
|
|
259
270
|
(ask, summary, files, tools, commands, decisions)
|
|
260
271
|
to SQLite (turns). 0 LLM tokens, pure stdlib.
|
|
261
272
|
turnstate_show.py = read-only viewer.
|
|
273
|
+
Off the recall path: nothing in recall
|
|
274
|
+
reads this table.
|
|
262
275
|
```
|
|
263
276
|
|
|
264
277
|
[`schema.sql`](src/sqlite_graph_memory/schema.sql) documents both tables. The graph is **not** materialized in SQL:
|
|
@@ -276,9 +289,9 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
276
289
|
lookups ("NotebookLM"): a name's card links to everything, so the hop pulls in noise.
|
|
277
290
|
The heuristic in `brain_ask.py` is deliberately conservative, and switches the graph off
|
|
278
291
|
only for name-shaped queries.
|
|
279
|
-
- **Crash-safety as a policy.** The graph hop (`brain_ask.py`)
|
|
280
|
-
(`turnstate_hook.py`)
|
|
281
|
-
|
|
292
|
+
- **Crash-safety as a policy.** The graph hop (`brain_ask.py`) is wrapped, so a failure
|
|
293
|
+
degrades recall to vector-only. The Stop-hook (`turnstate_hook.py`) is wrapped too, but it
|
|
294
|
+
sits off the recall path: a failure costs one ledger row and nothing else.
|
|
282
295
|
A memory layer must never make the agent worse than having no memory layer.
|
|
283
296
|
- **Measure, don't believe.** `--ab` runs both pipelines on every real query and logs how
|
|
284
297
|
many notes the graph promoted into the top-N, to `ab_recall` in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
@@ -321,7 +334,8 @@ Run any of them on a base install and they tell you which extra is missing rathe
|
|
|
321
334
|
raising `ModuleNotFoundError` — that path is covered by `tests/test_optional_extra.py`.
|
|
322
335
|
|
|
323
336
|
To enable the per-turn ledger in Claude Code, register the Stop hook (the exact block is
|
|
324
|
-
`examples/claude-code-stop-hook.json`, which calls `sgm-turnstate-hook`), then
|
|
337
|
+
`examples/claude-code-stop-hook.json`, which calls `sgm-turnstate-hook`), then read it back with
|
|
338
|
+
`sgm-turnstate-show`. The ledger records what each turn did; recall never reads it.
|
|
325
339
|
|
|
326
340
|
```bash
|
|
327
341
|
sgm-turnstate-show --stats
|
|
@@ -9,6 +9,8 @@ Claude Code, Cursor, Codex or any other MCP client can recall from it.
|
|
|
9
9
|
|
|
10
10
|
It fits [Andrej Karpathy's LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) (April 2026), where an agent maintains an interlinked markdown wiki and a search tool over the pages is the first helper he suggests adding: sgm is that search layer, read-only, and it follows your `[[wikilinks]]` as a graph. Independent project, not affiliated with or endorsed by him.
|
|
11
11
|
|
|
12
|
+
This package is layers 4 and 5 of a larger memory design (always-loaded instructions, auto memory, curated vault, verbatim originals, retrieval, turn ledger). The whole picture and a step-by-step install for you or your agent: [MEMORY.md in the starter kit](https://github.com/tonydzi/second-brain-starter-kit/blob/master/MEMORY.md) ([по-русски](https://github.com/tonydzi/second-brain-starter-kit/blob/master/MEMORY.ru.md)).
|
|
13
|
+
|
|
12
14
|

|
|
13
15
|
|
|
14
16
|
**Your agent forgets everything between sessions, and plain vector search gives it back
|
|
@@ -38,6 +40,14 @@ Then point your client at the server. Use the absolute path of that index folder
|
|
|
38
40
|
|
|
39
41
|
**Claude Code**
|
|
40
42
|
|
|
43
|
+
As a plugin (asks for the index folder on install, Claude Code 2.1.275 or later):
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
/plugin install sqlite-graph-memory --marketplace tonydzi/sqlite-graph-memory
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or register the server by hand:
|
|
50
|
+
|
|
41
51
|
```bash
|
|
42
52
|
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --python 3.12 --with 'sqlite-graph-memory[lite]' sqlite-graph-memory
|
|
43
53
|
```
|
|
@@ -172,7 +182,8 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
|
|
|
172
182
|
No extraction pass, and edge quality beats anything a model would mine.
|
|
173
183
|
- **SQLite is enough** — the only things worth persisting are derived state (a per-turn
|
|
174
184
|
ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
175
|
-
One file, stdlib driver, zero ops.
|
|
185
|
+
One file, stdlib driver, zero ops. The ledger is telemetry, not memory: recall never reads it,
|
|
186
|
+
so past turns do not change what `brain_ask.py` or the MCP server return.
|
|
176
187
|
- **Measure before adding a stage.** The pilot shipped a cross-encoder reranker from day one;
|
|
177
188
|
measured later, it lowered recall on long queries (our 184-question gold set: body nDCG@12
|
|
178
189
|
0.640 reranked vs 0.815 dense; DolphinBench Riley slice, 1000 sessions: R@5 0.48 vs 0.61).
|
|
@@ -204,6 +215,8 @@ markdown notes (with [[wikilinks]])
|
|
|
204
215
|
(ask, summary, files, tools, commands, decisions)
|
|
205
216
|
to SQLite (turns). 0 LLM tokens, pure stdlib.
|
|
206
217
|
turnstate_show.py = read-only viewer.
|
|
218
|
+
Off the recall path: nothing in recall
|
|
219
|
+
reads this table.
|
|
207
220
|
```
|
|
208
221
|
|
|
209
222
|
[`schema.sql`](src/sqlite_graph_memory/schema.sql) documents both tables. The graph is **not** materialized in SQL:
|
|
@@ -221,9 +234,9 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
221
234
|
lookups ("NotebookLM"): a name's card links to everything, so the hop pulls in noise.
|
|
222
235
|
The heuristic in `brain_ask.py` is deliberately conservative, and switches the graph off
|
|
223
236
|
only for name-shaped queries.
|
|
224
|
-
- **Crash-safety as a policy.** The graph hop (`brain_ask.py`)
|
|
225
|
-
(`turnstate_hook.py`)
|
|
226
|
-
|
|
237
|
+
- **Crash-safety as a policy.** The graph hop (`brain_ask.py`) is wrapped, so a failure
|
|
238
|
+
degrades recall to vector-only. The Stop-hook (`turnstate_hook.py`) is wrapped too, but it
|
|
239
|
+
sits off the recall path: a failure costs one ledger row and nothing else.
|
|
227
240
|
A memory layer must never make the agent worse than having no memory layer.
|
|
228
241
|
- **Measure, don't believe.** `--ab` runs both pipelines on every real query and logs how
|
|
229
242
|
many notes the graph promoted into the top-N, to `ab_recall` in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
@@ -266,7 +279,8 @@ Run any of them on a base install and they tell you which extra is missing rathe
|
|
|
266
279
|
raising `ModuleNotFoundError` — that path is covered by `tests/test_optional_extra.py`.
|
|
267
280
|
|
|
268
281
|
To enable the per-turn ledger in Claude Code, register the Stop hook (the exact block is
|
|
269
|
-
`examples/claude-code-stop-hook.json`, which calls `sgm-turnstate-hook`), then
|
|
282
|
+
`examples/claude-code-stop-hook.json`, which calls `sgm-turnstate-hook`), then read it back with
|
|
283
|
+
`sgm-turnstate-show`. The ledger records what each turn did; recall never reads it.
|
|
270
284
|
|
|
271
285
|
```bash
|
|
272
286
|
sgm-turnstate-show --stats
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# sqlite-graph-memory plugin for Claude Code
|
|
2
|
+
|
|
3
|
+
Recall over your markdown notes as a local stdio MCP server: vector search finds entry points,
|
|
4
|
+
your `[[wikilinks]]` are the graph. No graph database, no server to run.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
1. Install [uv](https://docs.astral.sh/uv/).
|
|
9
|
+
2. Build the index once over any folder of markdown notes:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --python 3.12 --from 'sqlite-graph-memory[lite]' sgm-index ~/notes
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. Install the plugin and give it that index folder when asked:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
/plugin install sqlite-graph-memory --marketplace tonydzi/sqlite-graph-memory
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The server exposes one tool, `memory_recall`. It is read-only: the agent recalls, you write the notes.
|
|
22
|
+
The runtime is pinned by `server.py.lock` in this folder (`uv run --locked server.py`).
|
|
23
|
+
|
|
24
|
+
Project, docs and issues: https://github.com/tonydzi/sqlite-graph-memory
|
|
@@ -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.9"
|
|
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"
|
{sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/brain_ask.py
RENAMED
|
@@ -143,15 +143,25 @@ FENCED_CODE_RX = re.compile(r'(?:```[\s\S]*?```|~~~[\s\S]*?~~~)')
|
|
|
143
143
|
INLINE_CODE_RX = re.compile(r'`+[^`\n]*`+')
|
|
144
144
|
WIKILINK_RX = re.compile(r'\[\[([^\]\|#]+)')
|
|
145
145
|
|
|
146
|
-
def
|
|
147
|
-
"""Outgoing wikilink TARGETS in
|
|
148
|
-
try: t = Path(path).read_text(encoding='utf-8', errors='ignore')
|
|
149
|
-
except Exception: return []
|
|
146
|
+
def links_in_text(t):
|
|
147
|
+
"""Outgoing wikilink TARGETS in note text (alias/heading stripped, code ignored)."""
|
|
150
148
|
t = FENCED_CODE_RX.sub('', t)
|
|
151
149
|
t = INLINE_CODE_RX.sub('', t)
|
|
152
150
|
return [m.strip() for m in WIKILINK_RX.findall(t)]
|
|
153
151
|
|
|
154
152
|
|
|
153
|
+
def read_for_links(path):
|
|
154
|
+
"""Note text exactly as the graph hop reads it, or None if unreadable."""
|
|
155
|
+
try: return Path(path).read_text(encoding='utf-8', errors='ignore')
|
|
156
|
+
except Exception: return None
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _links_in(path):
|
|
160
|
+
"""Outgoing wikilink TARGETS in a note (alias/heading stripped, code fences ignored)."""
|
|
161
|
+
t = read_for_links(path)
|
|
162
|
+
return links_in_text(t) if t is not None else []
|
|
163
|
+
|
|
164
|
+
|
|
155
165
|
FRONTMATTER_RX = re.compile(r'^---\r?\n(.*?)\r?\n---', re.DOTALL)
|
|
156
166
|
SUPERSEDED_BY_RX = re.compile(r'^superseded_by\s*:\s*"?(.+?)"?\s*$', re.MULTILINE)
|
|
157
167
|
|
|
@@ -12,11 +12,9 @@ import sqlite3
|
|
|
12
12
|
import sys
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
|
|
15
|
-
from sqlite_graph_memory import brain_ask
|
|
16
|
-
|
|
17
15
|
OK, WARN, FAIL = 'ok', 'warn', 'fail'
|
|
18
16
|
MARK = {OK: '[ok] ', WARN: '[warn]', FAIL: '[FAIL]'}
|
|
19
|
-
FEEDBACK =
|
|
17
|
+
FEEDBACK = 'https://github.com/tonydzi/sqlite-graph-memory/discussions/categories/ideas'
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
def check_python(version=None):
|
|
@@ -40,7 +38,12 @@ def _intel_mac(system=None, machine=None):
|
|
|
40
38
|
|
|
41
39
|
def check_embeddings(system=None, machine=None):
|
|
42
40
|
"""The heavy half. Without it the graph and the SQLite parts work, indexing and recall do not."""
|
|
43
|
-
|
|
41
|
+
try:
|
|
42
|
+
from sqlite_graph_memory import brain_ask
|
|
43
|
+
is_onnx = (brain_ask.backend() == 'onnx')
|
|
44
|
+
except Exception:
|
|
45
|
+
is_onnx = (os.getenv('SGM_BACKEND', '').strip().lower() == 'onnx')
|
|
46
|
+
if is_onnx:
|
|
44
47
|
try:
|
|
45
48
|
import onnxruntime
|
|
46
49
|
import tokenizers # noqa: F401
|
|
@@ -59,9 +62,13 @@ def check_embeddings(system=None, machine=None):
|
|
|
59
62
|
import torch
|
|
60
63
|
import sentence_transformers
|
|
61
64
|
except ModuleNotFoundError as exc:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if exc.name in ('torch', 'sentence_transformers'):
|
|
66
|
+
return (WARN, 'The embeddings extra is not installed (%s missing).' % exc.name,
|
|
67
|
+
'Only needed to index and recall. Install it with: pip install "sqlite-graph-memory[lite]"'
|
|
68
|
+
' (or [embeddings] for torch and a GPU)')
|
|
69
|
+
why = '%s: %s' % (type(exc).__name__, str(exc).splitlines()[0] if str(exc) else '')
|
|
70
|
+
return FAIL, 'torch or sentence-transformers fails to import (%s).' % why, \
|
|
71
|
+
'Reinstall in a fresh virtualenv: pip install --force-reinstall "sqlite-graph-memory[embeddings]"'
|
|
65
72
|
except Exception as exc: # torch dies at import on a numpy it was not built for
|
|
66
73
|
why = '%s: %s' % (type(exc).__name__, str(exc).splitlines()[0] if str(exc) else '')
|
|
67
74
|
if _intel_mac(system, machine) and np_major >= 2:
|
|
@@ -77,16 +84,31 @@ def check_embeddings(system=None, machine=None):
|
|
|
77
84
|
|
|
78
85
|
|
|
79
86
|
def _hf_cache_dirs():
|
|
80
|
-
roots = [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
roots = []
|
|
88
|
+
if os.getenv('HF_HUB_CACHE'):
|
|
89
|
+
roots.append(Path(os.environ['HF_HUB_CACHE']))
|
|
90
|
+
elif os.getenv('HF_HOME'):
|
|
91
|
+
roots.append(Path(os.environ['HF_HOME']) / 'hub')
|
|
92
|
+
else:
|
|
93
|
+
xdg = os.getenv('XDG_CACHE_HOME')
|
|
94
|
+
base = Path(xdg) if xdg else Path.home() / '.cache'
|
|
95
|
+
roots.append(base / 'huggingface' / 'hub')
|
|
96
|
+
|
|
97
|
+
if os.getenv('SENTENCE_TRANSFORMERS_HOME'):
|
|
98
|
+
roots.append(Path(os.environ['SENTENCE_TRANSFORMERS_HOME']))
|
|
99
|
+
|
|
100
|
+
return [r for r in roots if r]
|
|
84
101
|
|
|
85
102
|
|
|
86
103
|
def check_models():
|
|
87
104
|
"""Look for the two model folders in the local cache. Never downloads anything."""
|
|
105
|
+
try:
|
|
106
|
+
from sqlite_graph_memory import brain_ask
|
|
107
|
+
models = (brain_ask.E5_MODEL, brain_ask.RERANK_MODEL)
|
|
108
|
+
except Exception:
|
|
109
|
+
models = ('intfloat/multilingual-e5-base', 'cross-encoder/mmarco-mMiniLMv2-L12-H384-v1')
|
|
88
110
|
missing = []
|
|
89
|
-
for name in
|
|
111
|
+
for name in models:
|
|
90
112
|
folder = 'models--' + name.replace('/', '--')
|
|
91
113
|
if not any((d / folder).exists() for d in _hf_cache_dirs()):
|
|
92
114
|
missing.append(name)
|
|
@@ -97,7 +119,14 @@ def check_models():
|
|
|
97
119
|
|
|
98
120
|
|
|
99
121
|
def check_index(index_dir=None):
|
|
100
|
-
|
|
122
|
+
if index_dir:
|
|
123
|
+
d = Path(index_dir)
|
|
124
|
+
else:
|
|
125
|
+
try:
|
|
126
|
+
from sqlite_graph_memory import brain_ask
|
|
127
|
+
d = brain_ask.INDEX_DIR
|
|
128
|
+
except Exception:
|
|
129
|
+
d = Path(os.getenv('BRAIN_INDEX_DIR', 'index'))
|
|
101
130
|
emb, meta = d / '_brain_e5.npy', d / '_brain_e5_meta.pkl'
|
|
102
131
|
if not emb.exists() and not meta.exists():
|
|
103
132
|
return (WARN, 'No index in %s.' % d.resolve(),
|
|
@@ -105,6 +134,25 @@ def check_index(index_dir=None):
|
|
|
105
134
|
if emb.exists() != meta.exists():
|
|
106
135
|
left = meta.name if emb.exists() else emb.name
|
|
107
136
|
return FAIL, 'The index is half there: %s is missing.' % left, 'Rebuild it: sgm-index /path/to/your/notes'
|
|
137
|
+
try:
|
|
138
|
+
import pickle
|
|
139
|
+
import numpy as np
|
|
140
|
+
raw_meta = meta.read_bytes()
|
|
141
|
+
if not raw_meta:
|
|
142
|
+
return FAIL, 'The index is empty: %s is 0 bytes.' % meta.name, 'Rebuild it: sgm-index /path/to/your/notes'
|
|
143
|
+
m = pickle.loads(raw_meta)
|
|
144
|
+
if not isinstance(m, list):
|
|
145
|
+
return FAIL, 'The index is corrupt: %s is not a list.' % meta.name, 'Rebuild it: sgm-index /path/to/your/notes'
|
|
146
|
+
if emb.stat().st_size == 0:
|
|
147
|
+
return FAIL, 'The index is empty: %s is 0 bytes.' % emb.name, 'Rebuild it: sgm-index /path/to/your/notes'
|
|
148
|
+
e = np.load(emb)
|
|
149
|
+
if len(e.shape) != 2 or e.shape[0] != len(m):
|
|
150
|
+
rows = e.shape[0] if len(e.shape) > 0 else 0
|
|
151
|
+
return FAIL, 'The index is corrupt: %s rows (%d) != %s chunks (%d).' % (
|
|
152
|
+
emb.name, rows, meta.name, len(m)), 'Rebuild it: sgm-index /path/to/your/notes'
|
|
153
|
+
except Exception as exc:
|
|
154
|
+
why = str(exc).splitlines()[0] if str(exc) else type(exc).__name__
|
|
155
|
+
return FAIL, 'The index is unreadable or truncated (%s).' % why, 'Rebuild it: sgm-index /path/to/your/notes'
|
|
108
156
|
return OK, 'Index found in %s (%.1f MB).' % (d.resolve(), emb.stat().st_size / 1e6), ''
|
|
109
157
|
|
|
110
158
|
|
{sqlite_graph_memory-0.3.8 → sqlite_graph_memory-0.3.9}/src/sqlite_graph_memory/index_notes.py
RENAMED
|
@@ -32,7 +32,9 @@ CHUNK_CHARS = 1200
|
|
|
32
32
|
CHUNK_OVERLAP = 200
|
|
33
33
|
SNIPPET_CHARS = 600
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
# The closing fence may be the last line of the file: a note that is all frontmatter
|
|
36
|
+
# and has no final newline is still a note with frontmatter.
|
|
37
|
+
FM_RX = re.compile(r'^---\r?\n(.*?)\r?\n---[ \t]*(?:\r?\n|\Z)', re.S)
|
|
36
38
|
|
|
37
39
|
try:
|
|
38
40
|
from sqlite_graph_memory import brain_ask as _ba
|
|
@@ -62,6 +62,38 @@ def _links_in(path):
|
|
|
62
62
|
return f(path)
|
|
63
63
|
|
|
64
64
|
|
|
65
|
+
def _normalize_target(tgt):
|
|
66
|
+
# Same normalization as the graph hop's _resolve_target_chunks, so both lanes
|
|
67
|
+
# read [[note]], [[note.md]] and [[folder/note]] the same way.
|
|
68
|
+
try:
|
|
69
|
+
from sqlite_graph_memory.brain_ask import _normalize_target as f
|
|
70
|
+
except ImportError: # run as a loose script next to brain_ask.py
|
|
71
|
+
from brain_ask import _normalize_target as f
|
|
72
|
+
return f(tgt)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _resolve_target(tgt, idx, paths):
|
|
76
|
+
"""Node for a wikilink target; None when no note matches.
|
|
77
|
+
|
|
78
|
+
Bare targets are the stem. A folder-qualified target must also match a path suffix:
|
|
79
|
+
[[projects/alpha]] points at projects/alpha.md, not at every note named alpha.
|
|
80
|
+
"""
|
|
81
|
+
norm = _normalize_target(tgt)
|
|
82
|
+
if not norm:
|
|
83
|
+
return None
|
|
84
|
+
if '/' not in norm:
|
|
85
|
+
return idx.get(norm)
|
|
86
|
+
u = idx.get(norm.rsplit('/', 1)[-1])
|
|
87
|
+
if u is None:
|
|
88
|
+
return None
|
|
89
|
+
suffix = '/' + norm
|
|
90
|
+
for p in paths[u]:
|
|
91
|
+
rel = Path(p).with_suffix('').as_posix().lstrip('/').lower()
|
|
92
|
+
if rel == norm or ('/' + rel).endswith(suffix):
|
|
93
|
+
return u
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
|
|
65
97
|
class Graph:
|
|
66
98
|
"""File-level wikilink graph in CSR form: node = lowercase file stem."""
|
|
67
99
|
|
|
@@ -141,7 +173,7 @@ def build(meta):
|
|
|
141
173
|
seen = set()
|
|
142
174
|
for p in files:
|
|
143
175
|
for tgt in _links_in(p):
|
|
144
|
-
v =
|
|
176
|
+
v = _resolve_target(tgt, idx, paths)
|
|
145
177
|
if v is None or v == u or v in seen:
|
|
146
178
|
continue
|
|
147
179
|
seen.add(v)
|