bibliotheque 0.1.27__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.
Files changed (56) hide show
  1. bibliotheque-0.1.27/LICENSE +21 -0
  2. bibliotheque-0.1.27/PKG-INFO +279 -0
  3. bibliotheque-0.1.27/README.md +254 -0
  4. bibliotheque-0.1.27/__init__.py +132 -0
  5. bibliotheque-0.1.27/adapters/__init__.py +0 -0
  6. bibliotheque-0.1.27/adapters/dropbox +48 -0
  7. bibliotheque-0.1.27/adapters/notion +203 -0
  8. bibliotheque-0.1.27/adapters/obsidian +53 -0
  9. bibliotheque-0.1.27/adapters/pcloud +42 -0
  10. bibliotheque-0.1.27/adapters/raindrop +64 -0
  11. bibliotheque-0.1.27/adapters/rclone +74 -0
  12. bibliotheque-0.1.27/bibliotheque-config.example.yaml +4 -0
  13. bibliotheque-0.1.27/bibliotheque.egg-info/PKG-INFO +279 -0
  14. bibliotheque-0.1.27/bibliotheque.egg-info/SOURCES.txt +79 -0
  15. bibliotheque-0.1.27/bibliotheque.egg-info/dependency_links.txt +1 -0
  16. bibliotheque-0.1.27/bibliotheque.egg-info/entry_points.txt +2 -0
  17. bibliotheque-0.1.27/bibliotheque.egg-info/requires.txt +8 -0
  18. bibliotheque-0.1.27/bibliotheque.egg-info/top_level.txt +1 -0
  19. bibliotheque-0.1.27/core/config_root.py +44 -0
  20. bibliotheque-0.1.27/core/engine.py +320 -0
  21. bibliotheque-0.1.27/core/ingest.py +491 -0
  22. bibliotheque-0.1.27/core/model_pin.py +11 -0
  23. bibliotheque-0.1.27/core/search.py +49 -0
  24. bibliotheque-0.1.27/core/store.py +261 -0
  25. bibliotheque-0.1.27/core/tools.py +332 -0
  26. bibliotheque-0.1.27/core/urlsafe.py +140 -0
  27. bibliotheque-0.1.27/mcp.json +9 -0
  28. bibliotheque-0.1.27/plugin.json +20 -0
  29. bibliotheque-0.1.27/plugin.yaml +30 -0
  30. bibliotheque-0.1.27/pyproject.toml +43 -0
  31. bibliotheque-0.1.27/requirements.txt +20 -0
  32. bibliotheque-0.1.27/scripts/fetch_model.py +22 -0
  33. bibliotheque-0.1.27/scripts/mcp_http_server.py +185 -0
  34. bibliotheque-0.1.27/scripts/mcp_launch.py +103 -0
  35. bibliotheque-0.1.27/scripts/mcp_server.py +195 -0
  36. bibliotheque-0.1.27/setup.cfg +4 -0
  37. bibliotheque-0.1.27/tests/test_adapter_resilience.py +115 -0
  38. bibliotheque-0.1.27/tests/test_adapter_sink_text.py +62 -0
  39. bibliotheque-0.1.27/tests/test_config_root.py +68 -0
  40. bibliotheque-0.1.27/tests/test_config_root_paths.py +65 -0
  41. bibliotheque-0.1.27/tests/test_contract.py +348 -0
  42. bibliotheque-0.1.27/tests/test_dashboard_api.py +204 -0
  43. bibliotheque-0.1.27/tests/test_dependency_sync.py +127 -0
  44. bibliotheque-0.1.27/tests/test_engine_deref.py +91 -0
  45. bibliotheque-0.1.27/tests/test_http_protocol.py +177 -0
  46. bibliotheque-0.1.27/tests/test_ingest_units.py +165 -0
  47. bibliotheque-0.1.27/tests/test_legacy_fts.py +74 -0
  48. bibliotheque-0.1.27/tests/test_materialize_race.py +103 -0
  49. bibliotheque-0.1.27/tests/test_notion_adapter.py +222 -0
  50. bibliotheque-0.1.27/tests/test_parity_slices.py +77 -0
  51. bibliotheque-0.1.27/tests/test_smoke_e2e.py +101 -0
  52. bibliotheque-0.1.27/tests/test_snapshot_pin.py +72 -0
  53. bibliotheque-0.1.27/tests/test_stale_rows.py +96 -0
  54. bibliotheque-0.1.27/tests/test_stdio_protocol.py +111 -0
  55. bibliotheque-0.1.27/tests/test_url_pinning.py +268 -0
  56. bibliotheque-0.1.27/tests/test_video_lane.py +161 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 D Yiapanis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,279 @@
1
+ Metadata-Version: 2.4
2
+ Name: bibliotheque
3
+ Version: 0.1.27
4
+ Summary: Multimodal local search over documents and media — pdf, office files, notes, images, audio and subtitles — from any MCP-capable agent.
5
+ Author: D Yiapanis
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/dyiapanis/bibliotheque
8
+ Project-URL: Issues, https://github.com/dyiapanis/bibliotheque/issues
9
+ Keywords: rag,mcp,search,embeddings,onnx,multimodal
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Text Processing :: Indexing
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: onnxruntime==1.29.0
17
+ Requires-Dist: numpy<3,>=2.0
18
+ Requires-Dist: pillow<14,>=11.0
19
+ Requires-Dist: tokenizers<1,>=0.20
20
+ Requires-Dist: transformers==5.19.0
21
+ Requires-Dist: torch<3,>=2.2
22
+ Requires-Dist: torchvision<1,>=0.17
23
+ Requires-Dist: huggingface_hub<3,>=0.26
24
+ Dynamic: license-file
25
+
26
+ <!-- mcp-name: io.github.dyiapanis/bibliotheque -->
27
+
28
+ > **Deprecation notice:** Bibliothèque is being renamed to **Bibliothèque**. This package name stops advancing at 0.1.26 — future releases ship as `bibliotheque` at https://github.com/dyiapanis/bibliotheque . Existing corpora and stdio installs keep working.
29
+
30
+
31
+ ![Bibliothèque — one semantic index over documents, images, audio and video](assets/banner.jpg)
32
+
33
+ <h2 align="center">Bibliothèque</h2>
34
+
35
+ <p align="center"><strong>Local, multimodal retrieval augmented generation across your documents and media.</strong></p>
36
+
37
+ <p align="center">
38
+ <a href="https://github.com/dyiapanis/bibliotheque/actions/workflows/tests.yml"><img src="https://github.com/dyiapanis/bibliotheque/actions/workflows/tests.yml/badge.svg" alt="tests" valign="middle"></a>&nbsp;
39
+ <a href="https://github.com/dyiapanis/bibliotheque/blob/main/LICENSE"><img src="https://img.shields.io/github/license/dyiapanis/bibliotheque" alt="license" valign="middle"></a>&nbsp;
40
+ <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.11%2B-blue" alt="python" valign="middle"></a>&nbsp;
41
+ <a href="https://github.com/dyiapanis/bibliotheque/actions/workflows/tests.yml"><img src="https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20Windows-informational" alt="platforms" valign="middle"></a>&nbsp;
42
+ <a href="https://agent-plugins.org/"><img src="https://img.shields.io/badge/agent--plugins-1.0%20compatible-8A2BE2" alt="agent plugins" valign="middle"></a>&nbsp;
43
+ <a href="https://hermes-agent.nousresearch.com/marketplace/bibliotheque"><img src="https://img.shields.io/badge/hermes-plugin%20marketplace-8A2BE2" alt="hermes" valign="middle"></a>
44
+ </p>
45
+
46
+ ---
47
+
48
+ Bibliothèque indexes documents (pdf, office files, notes, html) and media (images, audio, video) into a local SQLite corpus and offers semantic search from any MCP-capable agent. Video files are indexed natively: frames sampled at
49
+ 0.5 fps (each frame carries its timestamp and a thumbnail — picture content is
50
+ searchable) plus the full audio track (spoken content, 11.2 s windows), so
51
+ "which file mentions the landing", "where did I talk about it", and "find the
52
+ frame with the logo" are all the same kind of question.
53
+
54
+ How it runs:
55
+
56
+ - In-gateway: five native tools (`bibliotheque_search`, `bibliotheque_add_source`,
57
+ `bibliotheque_ingest_dir`, `bibliotheque_add_note`, `bibliotheque_status`) register once,
58
+ so one gateway serves all agents and the embedding model loads once.
59
+ - Cross-client: `mcp.json` declares a stdio MCP server, so Claude Desktop,
60
+ Cursor, and other Agent Plugins compliant clients load the same package.
61
+ An optional streamable-HTTP server (MCP 2026-07-28) serves the same tools:
62
+ `python3 scripts/mcp_http_server.py` binds loopback :8601 (stateless POST
63
+ `/mcp`; `BIBLIOTHEQUE_HTTP_HOST`/`BIBLIOTHEQUE_HTTP_PORT` override; non-loopback
64
+ binds require `BIBLIOTHEQUE_HTTP_TOKEN`).
65
+ Per the spec the entry uses a plugin-relative `command`
66
+ (`./scripts/mcp_launch.py`), never a bare `python3`: portable plugins must not
67
+ depend on `PATH` or ambient variables for resolution. That launcher is
68
+ stdlib-only and finds an interpreter that can import the engine
69
+ (numpy/onnxruntime/transformers/torch, ~500 MB), which Agent Plugins 1.0 has
70
+ no field to declare — so a client without a provisioned interpreter needs one
71
+ command, once:
72
+
73
+ ```bash
74
+ python3 -m venv .venv && .venv/bin/python -m pip install -r requirements.txt
75
+ ```
76
+
77
+ Order of preference: `$BIBLIOTHEQUE_PYTHON`, the package's own `.venv/`, the
78
+ client's `$PLUGIN_DATA/venv`, then the interpreter that started it. With none
79
+ present it exits 3 naming what's missing instead of vanishing mid-handshake.
80
+
81
+ If `uv` is installed, it can own the environment instead — same
82
+ `requirements.txt`, resolved and cached by the installer:
83
+
84
+ ```bash
85
+ uv run --with-requirements requirements.txt -- python -c pass # once
86
+ ```
87
+
88
+ Set `BIBLIOTHEQUE_AUTO_BOOTSTRAP=1` to have the launcher run that on start. It is
89
+ off by default: a first run pulls ~1.7 GB, longer than most clients wait.
90
+ - Local-only: no cloud services. The corpus lives at `<root>/.corpus/store.db`.
91
+
92
+ Documents and media are embedded by the same model into the same vector space
93
+ (see [Embedding model](#embedding-model)), which is why one index answers both
94
+ kinds of question.
95
+
96
+ ## System Requirements
97
+
98
+ | | |
99
+ |---|---|
100
+ | **Python** | 3.11 or newer (`requires-python >=3.11`) |
101
+ | **OS** | Linux x86_64 · Windows 10+ x86_64 · macOS 14+ on Apple Silicon |
102
+ | **Memory** | ~1.5 GB resident once everything is loaded — measured 834 MB after the text trunk, 1.06 GB with vision and audio added, 1.5 GB with the processor |
103
+ | **Disk** | ~480 MB of q4 towers on first run (measured 505 MB: 174 MB text + 109 MB vision + 189 MB audio + a 32 MB tokenizer), and up to ~450 MB more if the cache stores them as symlinks and they are materialised into `~/.cache/bibliotheque`; the corpus then grows with whatever you index |
104
+
105
+ **macOS is Apple Silicon only.** `onnxruntime` and `torch` publish no x86_64
106
+ macOS wheels, and their arm64 wheels require macOS 14.0 — an Intel Mac or a
107
+ macOS 13 machine cannot install this engine. CI runs the real engine on macOS
108
+ (arm64), Windows and Linux, ingest to search, on every commit.
109
+
110
+ System tools are needed only by the lanes that use them:
111
+
112
+ | Tool | Used for | Install |
113
+ |---|---|---|
114
+ | `ffmpeg` | audio + video | `apt install ffmpeg` · `winget install Gyan.FFmpeg` · `brew install ffmpeg` |
115
+ | `pandoc` | docx, odt, epub, rst, html, csv, rtf | `apt install pandoc` · `winget install JohnMacFarlane.Pandoc` · `brew install pandoc` |
116
+ | `pdftotext` | pdf | `apt install poppler-utils` · `winget install oschwartz10612.Poppler` · `brew install poppler` |
117
+ | `curl` | `add_source` on an http(s) URL | preinstalled on all three |
118
+
119
+ `curl` ships with Linux and macOS and is present on Windows 10+ (a built-in
120
+ `curl.exe`); `ffmpeg`, `pandoc` and `pdftotext` are not installed by default
121
+ anywhere. Everything else — numpy, onnxruntime, transformers, torch — is
122
+ pip-installed from the declared dependencies.
123
+
124
+ ## Install
125
+
126
+ Two ways in; both end at the same `bibliotheque-mcp` stdio server.
127
+
128
+ **As a Python package** — any MCP client, no clone:
129
+
130
+ ```bash
131
+ uvx --from git+https://github.com/dyiapanis/bibliotheque bibliotheque-mcp # runs it
132
+ pipx install git+https://github.com/dyiapanis/bibliotheque # or: bibliotheque-mcp on PATH
133
+ ```
134
+
135
+ **As a plugin** — for hosts that provision dependencies from the package manifest:
136
+
137
+ ```bash
138
+ hermes plugins install dyiapanis/bibliotheque # Hermes reads python_dependencies
139
+ ```
140
+
141
+ The engine needs numpy, onnxruntime, transformers and torch (~1.7 GB with the
142
+ model weights); `pipx`/`uvx`/`hermes` install that for you. Running from a bare
143
+ checkout instead, see the MCP section below.
144
+
145
+ Python dependencies: `pip install -r requirements.txt`.
146
+
147
+ Runs on Linux, Windows and macOS 14+ on Apple Silicon — see [System
148
+ Requirements](#system-requirements) for memory, disk and the system-tool table.
149
+ On Windows and macOS those tools are not preinstalled; the table has the
150
+ `winget`/`brew` commands. The corpus cache lives at `~/.cache/bibliotheque`
151
+ (`%USERPROFILE%\.cache\bibliotheque` on Windows); adapters are python scripts run
152
+ through the current interpreter, so they need neither the executable bit nor a
153
+ shebang.
154
+
155
+ The embedding weights are not downloaded on startup. Once, before first search:
156
+
157
+ ```bash
158
+ python scripts/fetch_model.py
159
+ ```
160
+
161
+ That is about 480MB into the Hugging Face cache; what is in it, and why, is
162
+ covered under [Embedding model](#embedding-model). After the download everything
163
+ runs offline (`HF_HUB_OFFLINE=1`).
164
+
165
+ ## Features
166
+
167
+ - Hybrid retrieval: semantic vectors plus an FTS5/BM25 keyword lane, fused with
168
+ reciprocal rank fusion. Exact-string lookups and meaning searches both work.
169
+ - Documents and media in one index: pdf via `pdftotext`, docx/odt/epub/rst/html/csv/rtf
170
+ via `pandoc`, plus images, audio, subtitles, and video (mp4/mov/mkv/webm/avi/m4v —
171
+ frames at 0.5 fps + the audio track; >8 min of footage is sampled to the first 240
172
+ frames and reports `frame_cap`).
173
+ - Incremental re-indexing: unchanged files are skipped on an mtime+size
174
+ fingerprint.
175
+ - Source adapters: external collections through `sources.d` executables (see
176
+ below).
177
+ ## Embedding model
178
+
179
+ One model embeds everything: [EmbeddingGemma
180
+ 2](https://huggingface.co/onnx-community/embeddinggemma-2-ONNX) in its ONNX q4
181
+ build, on onnxruntime, on the CPU. It ships three towers — the text trunk, a
182
+ vision encoder and an audio encoder — and all three write into the same
183
+ 768-dimensional space, so a pdf, a photograph and a clip of you talking about
184
+ both are directly comparable.
185
+
186
+ - **Snapshot** `daa72c51243991dfcaf9f9137d2c573d8f7790c0` of
187
+ `onnx-community/embeddinggemma-2-ONNX`. `scripts/fetch_model.py` pulls only the
188
+ q4 towers plus the tokenizer and processor configs — 174 MB text, 109 MB
189
+ vision, 189 MB audio, 32 MB tokenizer, about 505 MB — and never at startup. A
190
+ cache that has also seen other quantisations of this model will be larger
191
+ still, because those blobs are not evicted.
192
+ - **768 dimensions**, L2-normalised, stored as f32 blobs (3,072 bytes per row).
193
+ Retrieval is exact cosine over the whole corpus; there is no approximate index.
194
+ - **1024-token cap** on the text trunk. Attention is quadratic in sequence
195
+ length, so tool input is sliced at that boundary rather than trusted.
196
+ - **Chunking**: documents and notes at 1,500 characters, subtitles at 600,
197
+ audio in 11.2-second windows, video frames at 0.5 fps (one vector per frame
198
+ plus a 256 px thumbnail — indexing runs ~3 s of embed CPU per frame).
199
+ - If the Hugging Face cache stores the ONNX shards as symlinks, they are
200
+ materialised once into `~/.cache/bibliotheque/onnx-real`: onnxruntime will not
201
+ load external-data blobs out of a sharded cache.
202
+
203
+ The three embedders are parity-locked against the reference model — 12/12 golden
204
+ vectors at cosine 1.000000 (`tests/fixtures/golden.json`, enforced by
205
+ `tests/test_parity_slices.py`).
206
+
207
+ ## What it touches
208
+
209
+ No telemetry. It shells out to `curl` (http sources), `ffmpeg`, `pandoc`,
210
+ `pdftotext`, and `rclone` when those lanes are used, and to whatever adapter
211
+ you drop in `sources.d/`. It reads the paths you pass plus the corpus at `root`
212
+ (`bibliotheque-config.yaml` `root:`, else `BIBLIOTHEQUE_ROOT`, else `~/.bibliotheque`). The Raindrop adapter calls
213
+ `api.raindrop.io` with `RAINDROP_API_TOKEN` — optional; inside Hermes the token
214
+ is resolved through the profile secret scope, and a missing scope does not
215
+ inherit another profile's value.
216
+
217
+ To run it as a Hermes plugin, point the plugin loader at this directory (or at
218
+ the agent plugin catalog entry). The manifests (`mcp.json`, `plugin.yaml`,
219
+ `plugin.json`) describe both the stdio MCP server (`scripts/mcp_server.py`,
220
+ spawned by the client) and the in-gateway native tools. Neither mode opens a
221
+ network listener.
222
+
223
+ ## Configuration
224
+
225
+ Everything is optional and set through the environment:
226
+
227
+ - `bibliotheque-config.yaml` — named corpus config in the plugin dir (`root:` key); wins over env and the default (see `bibliotheque-config.example.yaml`)
228
+ - `BIBLIOTHEQUE_ROOT` — corpus root (default: `~/.bibliotheque`)
229
+ - `BIBLIOTHEQUE_ALLOW_PRIVATE_URLS=1` — let `add_source` fetch loopback/private-network URLs (standalone; inside Hermes the host's `security.allow_private_urls` applies). Link-local and cloud-metadata addresses are always refused.
230
+ - `RAINDROP_API_TOKEN`, `NOTION_TOKEN`, `PCLOUD_MOUNT`, `OBSIDIAN_VAULT` — adapter inputs
231
+
232
+ ## Adapters
233
+
234
+ `add_source` accepts public `http(s)://` URLs (fetched with curl, capped at 256MB;
235
+ every redirect hop is checked and loopback/private/link-local/metadata hosts are refused)
236
+ and source-scheme URIs (`<scheme>://...`) handled by adapters. Six ship in the
237
+ box:
238
+
239
+ - `dropbox://` — Dropbox through the desktop client's local folder, or any mirror
240
+ (`DROPBOX_DIR` env). Skips Dropbox's own `.dropbox/` bookkeeping.
241
+ - `rclone://remote:path` — any [rclone](https://rclone.org/) remote. Files copy
242
+ into a persistent cache at `~/.cache/bibliotheque/rclone` and index from there.
243
+ - `pcloud://` — walks a locally mounted pCloud drive (`PCLOUD_MOUNT` env).
244
+ - `obsidian://` — an Obsidian vault; skips `.obsidian/`, `.trash/`, `.git/`.
245
+ - `raindrop://` — Raindrop.io bookmarks through the REST API
246
+ (`RAINDROP_API_TOKEN` env).
247
+ - `notion://<page-or-database-id>` — Notion pages through the REST API
248
+ (`NOTION_TOKEN` env, an integration secret). Text only: Notion-hosted files
249
+ carry signed URLs that expire within an hour, so they are not indexed.
250
+
251
+ To write your own adapter, drop an executable at `sources.d/<scheme>` under the
252
+ configured corpus root (`bibliotheque-config.yaml` / `BIBLIOTHEQUE_ROOT` / `~/.bibliotheque`; a
253
+ per-call `root` argument never adds adapters) that
254
+ accepts `fetch <rest>` and prints one JSON object per line, either
255
+ `{"uri","title","text"}` or `{"uri","path"}`. `status` reports the adapters it
256
+ found; an unknown scheme fails with the list of what is available.
257
+
258
+ ## Development
259
+
260
+ Tests are direct-run scripts, not pytest-collectable:
261
+
262
+ - `python tests/test_contract.py` — tool/store/adapter contracts (no model)
263
+ - `python tests/test_ingest_units.py` — chunking, subtitle timings, store integrity
264
+ - `python tests/test_engine_deref.py` — sharded-cache materialisation (no model)
265
+ - `python tests/test_config_root.py` — corpus-root precedence (no model)
266
+ - `python tests/test_parity_slices.py` — FTS lane, RRF fusion, doc bridge (needs the model)
267
+
268
+ The fixtures under `tests/fixtures/` are synthetic and deterministic, and nothing
269
+ contacts the network. `tests/bench_engine.py` and `scripts/bench.sh` are the
270
+ local benchmark harness. CI runs the model-free suites on Linux and Windows,
271
+ plus the full parity lane on Linux.
272
+
273
+ ## License
274
+
275
+ MIT. For security reports, see `SECURITY.md`.
276
+
277
+ ## Acknowledgements
278
+
279
+ This project was developed with AI assistance using [Hermes Agent](https://github.com/NousResearch/hermes-agent).
@@ -0,0 +1,254 @@
1
+ <!-- mcp-name: io.github.dyiapanis/bibliotheque -->
2
+
3
+ > **Deprecation notice:** Bibliothèque is being renamed to **Bibliothèque**. This package name stops advancing at 0.1.26 — future releases ship as `bibliotheque` at https://github.com/dyiapanis/bibliotheque . Existing corpora and stdio installs keep working.
4
+
5
+
6
+ ![Bibliothèque — one semantic index over documents, images, audio and video](assets/banner.jpg)
7
+
8
+ <h2 align="center">Bibliothèque</h2>
9
+
10
+ <p align="center"><strong>Local, multimodal retrieval augmented generation across your documents and media.</strong></p>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/dyiapanis/bibliotheque/actions/workflows/tests.yml"><img src="https://github.com/dyiapanis/bibliotheque/actions/workflows/tests.yml/badge.svg" alt="tests" valign="middle"></a>&nbsp;
14
+ <a href="https://github.com/dyiapanis/bibliotheque/blob/main/LICENSE"><img src="https://img.shields.io/github/license/dyiapanis/bibliotheque" alt="license" valign="middle"></a>&nbsp;
15
+ <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.11%2B-blue" alt="python" valign="middle"></a>&nbsp;
16
+ <a href="https://github.com/dyiapanis/bibliotheque/actions/workflows/tests.yml"><img src="https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20Windows-informational" alt="platforms" valign="middle"></a>&nbsp;
17
+ <a href="https://agent-plugins.org/"><img src="https://img.shields.io/badge/agent--plugins-1.0%20compatible-8A2BE2" alt="agent plugins" valign="middle"></a>&nbsp;
18
+ <a href="https://hermes-agent.nousresearch.com/marketplace/bibliotheque"><img src="https://img.shields.io/badge/hermes-plugin%20marketplace-8A2BE2" alt="hermes" valign="middle"></a>
19
+ </p>
20
+
21
+ ---
22
+
23
+ Bibliothèque indexes documents (pdf, office files, notes, html) and media (images, audio, video) into a local SQLite corpus and offers semantic search from any MCP-capable agent. Video files are indexed natively: frames sampled at
24
+ 0.5 fps (each frame carries its timestamp and a thumbnail — picture content is
25
+ searchable) plus the full audio track (spoken content, 11.2 s windows), so
26
+ "which file mentions the landing", "where did I talk about it", and "find the
27
+ frame with the logo" are all the same kind of question.
28
+
29
+ How it runs:
30
+
31
+ - In-gateway: five native tools (`bibliotheque_search`, `bibliotheque_add_source`,
32
+ `bibliotheque_ingest_dir`, `bibliotheque_add_note`, `bibliotheque_status`) register once,
33
+ so one gateway serves all agents and the embedding model loads once.
34
+ - Cross-client: `mcp.json` declares a stdio MCP server, so Claude Desktop,
35
+ Cursor, and other Agent Plugins compliant clients load the same package.
36
+ An optional streamable-HTTP server (MCP 2026-07-28) serves the same tools:
37
+ `python3 scripts/mcp_http_server.py` binds loopback :8601 (stateless POST
38
+ `/mcp`; `BIBLIOTHEQUE_HTTP_HOST`/`BIBLIOTHEQUE_HTTP_PORT` override; non-loopback
39
+ binds require `BIBLIOTHEQUE_HTTP_TOKEN`).
40
+ Per the spec the entry uses a plugin-relative `command`
41
+ (`./scripts/mcp_launch.py`), never a bare `python3`: portable plugins must not
42
+ depend on `PATH` or ambient variables for resolution. That launcher is
43
+ stdlib-only and finds an interpreter that can import the engine
44
+ (numpy/onnxruntime/transformers/torch, ~500 MB), which Agent Plugins 1.0 has
45
+ no field to declare — so a client without a provisioned interpreter needs one
46
+ command, once:
47
+
48
+ ```bash
49
+ python3 -m venv .venv && .venv/bin/python -m pip install -r requirements.txt
50
+ ```
51
+
52
+ Order of preference: `$BIBLIOTHEQUE_PYTHON`, the package's own `.venv/`, the
53
+ client's `$PLUGIN_DATA/venv`, then the interpreter that started it. With none
54
+ present it exits 3 naming what's missing instead of vanishing mid-handshake.
55
+
56
+ If `uv` is installed, it can own the environment instead — same
57
+ `requirements.txt`, resolved and cached by the installer:
58
+
59
+ ```bash
60
+ uv run --with-requirements requirements.txt -- python -c pass # once
61
+ ```
62
+
63
+ Set `BIBLIOTHEQUE_AUTO_BOOTSTRAP=1` to have the launcher run that on start. It is
64
+ off by default: a first run pulls ~1.7 GB, longer than most clients wait.
65
+ - Local-only: no cloud services. The corpus lives at `<root>/.corpus/store.db`.
66
+
67
+ Documents and media are embedded by the same model into the same vector space
68
+ (see [Embedding model](#embedding-model)), which is why one index answers both
69
+ kinds of question.
70
+
71
+ ## System Requirements
72
+
73
+ | | |
74
+ |---|---|
75
+ | **Python** | 3.11 or newer (`requires-python >=3.11`) |
76
+ | **OS** | Linux x86_64 · Windows 10+ x86_64 · macOS 14+ on Apple Silicon |
77
+ | **Memory** | ~1.5 GB resident once everything is loaded — measured 834 MB after the text trunk, 1.06 GB with vision and audio added, 1.5 GB with the processor |
78
+ | **Disk** | ~480 MB of q4 towers on first run (measured 505 MB: 174 MB text + 109 MB vision + 189 MB audio + a 32 MB tokenizer), and up to ~450 MB more if the cache stores them as symlinks and they are materialised into `~/.cache/bibliotheque`; the corpus then grows with whatever you index |
79
+
80
+ **macOS is Apple Silicon only.** `onnxruntime` and `torch` publish no x86_64
81
+ macOS wheels, and their arm64 wheels require macOS 14.0 — an Intel Mac or a
82
+ macOS 13 machine cannot install this engine. CI runs the real engine on macOS
83
+ (arm64), Windows and Linux, ingest to search, on every commit.
84
+
85
+ System tools are needed only by the lanes that use them:
86
+
87
+ | Tool | Used for | Install |
88
+ |---|---|---|
89
+ | `ffmpeg` | audio + video | `apt install ffmpeg` · `winget install Gyan.FFmpeg` · `brew install ffmpeg` |
90
+ | `pandoc` | docx, odt, epub, rst, html, csv, rtf | `apt install pandoc` · `winget install JohnMacFarlane.Pandoc` · `brew install pandoc` |
91
+ | `pdftotext` | pdf | `apt install poppler-utils` · `winget install oschwartz10612.Poppler` · `brew install poppler` |
92
+ | `curl` | `add_source` on an http(s) URL | preinstalled on all three |
93
+
94
+ `curl` ships with Linux and macOS and is present on Windows 10+ (a built-in
95
+ `curl.exe`); `ffmpeg`, `pandoc` and `pdftotext` are not installed by default
96
+ anywhere. Everything else — numpy, onnxruntime, transformers, torch — is
97
+ pip-installed from the declared dependencies.
98
+
99
+ ## Install
100
+
101
+ Two ways in; both end at the same `bibliotheque-mcp` stdio server.
102
+
103
+ **As a Python package** — any MCP client, no clone:
104
+
105
+ ```bash
106
+ uvx --from git+https://github.com/dyiapanis/bibliotheque bibliotheque-mcp # runs it
107
+ pipx install git+https://github.com/dyiapanis/bibliotheque # or: bibliotheque-mcp on PATH
108
+ ```
109
+
110
+ **As a plugin** — for hosts that provision dependencies from the package manifest:
111
+
112
+ ```bash
113
+ hermes plugins install dyiapanis/bibliotheque # Hermes reads python_dependencies
114
+ ```
115
+
116
+ The engine needs numpy, onnxruntime, transformers and torch (~1.7 GB with the
117
+ model weights); `pipx`/`uvx`/`hermes` install that for you. Running from a bare
118
+ checkout instead, see the MCP section below.
119
+
120
+ Python dependencies: `pip install -r requirements.txt`.
121
+
122
+ Runs on Linux, Windows and macOS 14+ on Apple Silicon — see [System
123
+ Requirements](#system-requirements) for memory, disk and the system-tool table.
124
+ On Windows and macOS those tools are not preinstalled; the table has the
125
+ `winget`/`brew` commands. The corpus cache lives at `~/.cache/bibliotheque`
126
+ (`%USERPROFILE%\.cache\bibliotheque` on Windows); adapters are python scripts run
127
+ through the current interpreter, so they need neither the executable bit nor a
128
+ shebang.
129
+
130
+ The embedding weights are not downloaded on startup. Once, before first search:
131
+
132
+ ```bash
133
+ python scripts/fetch_model.py
134
+ ```
135
+
136
+ That is about 480MB into the Hugging Face cache; what is in it, and why, is
137
+ covered under [Embedding model](#embedding-model). After the download everything
138
+ runs offline (`HF_HUB_OFFLINE=1`).
139
+
140
+ ## Features
141
+
142
+ - Hybrid retrieval: semantic vectors plus an FTS5/BM25 keyword lane, fused with
143
+ reciprocal rank fusion. Exact-string lookups and meaning searches both work.
144
+ - Documents and media in one index: pdf via `pdftotext`, docx/odt/epub/rst/html/csv/rtf
145
+ via `pandoc`, plus images, audio, subtitles, and video (mp4/mov/mkv/webm/avi/m4v —
146
+ frames at 0.5 fps + the audio track; >8 min of footage is sampled to the first 240
147
+ frames and reports `frame_cap`).
148
+ - Incremental re-indexing: unchanged files are skipped on an mtime+size
149
+ fingerprint.
150
+ - Source adapters: external collections through `sources.d` executables (see
151
+ below).
152
+ ## Embedding model
153
+
154
+ One model embeds everything: [EmbeddingGemma
155
+ 2](https://huggingface.co/onnx-community/embeddinggemma-2-ONNX) in its ONNX q4
156
+ build, on onnxruntime, on the CPU. It ships three towers — the text trunk, a
157
+ vision encoder and an audio encoder — and all three write into the same
158
+ 768-dimensional space, so a pdf, a photograph and a clip of you talking about
159
+ both are directly comparable.
160
+
161
+ - **Snapshot** `daa72c51243991dfcaf9f9137d2c573d8f7790c0` of
162
+ `onnx-community/embeddinggemma-2-ONNX`. `scripts/fetch_model.py` pulls only the
163
+ q4 towers plus the tokenizer and processor configs — 174 MB text, 109 MB
164
+ vision, 189 MB audio, 32 MB tokenizer, about 505 MB — and never at startup. A
165
+ cache that has also seen other quantisations of this model will be larger
166
+ still, because those blobs are not evicted.
167
+ - **768 dimensions**, L2-normalised, stored as f32 blobs (3,072 bytes per row).
168
+ Retrieval is exact cosine over the whole corpus; there is no approximate index.
169
+ - **1024-token cap** on the text trunk. Attention is quadratic in sequence
170
+ length, so tool input is sliced at that boundary rather than trusted.
171
+ - **Chunking**: documents and notes at 1,500 characters, subtitles at 600,
172
+ audio in 11.2-second windows, video frames at 0.5 fps (one vector per frame
173
+ plus a 256 px thumbnail — indexing runs ~3 s of embed CPU per frame).
174
+ - If the Hugging Face cache stores the ONNX shards as symlinks, they are
175
+ materialised once into `~/.cache/bibliotheque/onnx-real`: onnxruntime will not
176
+ load external-data blobs out of a sharded cache.
177
+
178
+ The three embedders are parity-locked against the reference model — 12/12 golden
179
+ vectors at cosine 1.000000 (`tests/fixtures/golden.json`, enforced by
180
+ `tests/test_parity_slices.py`).
181
+
182
+ ## What it touches
183
+
184
+ No telemetry. It shells out to `curl` (http sources), `ffmpeg`, `pandoc`,
185
+ `pdftotext`, and `rclone` when those lanes are used, and to whatever adapter
186
+ you drop in `sources.d/`. It reads the paths you pass plus the corpus at `root`
187
+ (`bibliotheque-config.yaml` `root:`, else `BIBLIOTHEQUE_ROOT`, else `~/.bibliotheque`). The Raindrop adapter calls
188
+ `api.raindrop.io` with `RAINDROP_API_TOKEN` — optional; inside Hermes the token
189
+ is resolved through the profile secret scope, and a missing scope does not
190
+ inherit another profile's value.
191
+
192
+ To run it as a Hermes plugin, point the plugin loader at this directory (or at
193
+ the agent plugin catalog entry). The manifests (`mcp.json`, `plugin.yaml`,
194
+ `plugin.json`) describe both the stdio MCP server (`scripts/mcp_server.py`,
195
+ spawned by the client) and the in-gateway native tools. Neither mode opens a
196
+ network listener.
197
+
198
+ ## Configuration
199
+
200
+ Everything is optional and set through the environment:
201
+
202
+ - `bibliotheque-config.yaml` — named corpus config in the plugin dir (`root:` key); wins over env and the default (see `bibliotheque-config.example.yaml`)
203
+ - `BIBLIOTHEQUE_ROOT` — corpus root (default: `~/.bibliotheque`)
204
+ - `BIBLIOTHEQUE_ALLOW_PRIVATE_URLS=1` — let `add_source` fetch loopback/private-network URLs (standalone; inside Hermes the host's `security.allow_private_urls` applies). Link-local and cloud-metadata addresses are always refused.
205
+ - `RAINDROP_API_TOKEN`, `NOTION_TOKEN`, `PCLOUD_MOUNT`, `OBSIDIAN_VAULT` — adapter inputs
206
+
207
+ ## Adapters
208
+
209
+ `add_source` accepts public `http(s)://` URLs (fetched with curl, capped at 256MB;
210
+ every redirect hop is checked and loopback/private/link-local/metadata hosts are refused)
211
+ and source-scheme URIs (`<scheme>://...`) handled by adapters. Six ship in the
212
+ box:
213
+
214
+ - `dropbox://` — Dropbox through the desktop client's local folder, or any mirror
215
+ (`DROPBOX_DIR` env). Skips Dropbox's own `.dropbox/` bookkeeping.
216
+ - `rclone://remote:path` — any [rclone](https://rclone.org/) remote. Files copy
217
+ into a persistent cache at `~/.cache/bibliotheque/rclone` and index from there.
218
+ - `pcloud://` — walks a locally mounted pCloud drive (`PCLOUD_MOUNT` env).
219
+ - `obsidian://` — an Obsidian vault; skips `.obsidian/`, `.trash/`, `.git/`.
220
+ - `raindrop://` — Raindrop.io bookmarks through the REST API
221
+ (`RAINDROP_API_TOKEN` env).
222
+ - `notion://<page-or-database-id>` — Notion pages through the REST API
223
+ (`NOTION_TOKEN` env, an integration secret). Text only: Notion-hosted files
224
+ carry signed URLs that expire within an hour, so they are not indexed.
225
+
226
+ To write your own adapter, drop an executable at `sources.d/<scheme>` under the
227
+ configured corpus root (`bibliotheque-config.yaml` / `BIBLIOTHEQUE_ROOT` / `~/.bibliotheque`; a
228
+ per-call `root` argument never adds adapters) that
229
+ accepts `fetch <rest>` and prints one JSON object per line, either
230
+ `{"uri","title","text"}` or `{"uri","path"}`. `status` reports the adapters it
231
+ found; an unknown scheme fails with the list of what is available.
232
+
233
+ ## Development
234
+
235
+ Tests are direct-run scripts, not pytest-collectable:
236
+
237
+ - `python tests/test_contract.py` — tool/store/adapter contracts (no model)
238
+ - `python tests/test_ingest_units.py` — chunking, subtitle timings, store integrity
239
+ - `python tests/test_engine_deref.py` — sharded-cache materialisation (no model)
240
+ - `python tests/test_config_root.py` — corpus-root precedence (no model)
241
+ - `python tests/test_parity_slices.py` — FTS lane, RRF fusion, doc bridge (needs the model)
242
+
243
+ The fixtures under `tests/fixtures/` are synthetic and deterministic, and nothing
244
+ contacts the network. `tests/bench_engine.py` and `scripts/bench.sh` are the
245
+ local benchmark harness. CI runs the model-free suites on Linux and Windows,
246
+ plus the full parity lane on Linux.
247
+
248
+ ## License
249
+
250
+ MIT. For security reports, see `SECURITY.md`.
251
+
252
+ ## Acknowledgements
253
+
254
+ This project was developed with AI assistance using [Hermes Agent](https://github.com/NousResearch/hermes-agent).