@korrlabs/mnemospi 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Korrnals
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.
package/README.md ADDED
@@ -0,0 +1,384 @@
1
+ <!-- markdownlint-disable MD041 MD033 -->
2
+ <p align="center">
3
+ <img src="docs/assets/mnemos-banner.svg" alt="Mnemos β€” memory &amp; knowledge server for AI agents" width="100%">
4
+ </p>
5
+
6
+ <h1 align="center">Mnemos</h1>
7
+
8
+ <p align="center">
9
+ <strong>A memory &amp; knowledge server for AI agents</strong><br>
10
+ <em>named after the Titaness of memory, built for AI agents that need to remember</em>
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="pyproject.toml"><img src="https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-3776ab" alt="Python"></a>
15
+ <a href="pyproject.toml"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License: MIT"></a>
16
+ <a href="https://github.com/Korrnals/mnemos/releases"><img src="https://img.shields.io/github/v/release/Korrnals/mnemos?label=version&color=blueviolet" alt="Version"></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <strong>πŸ‡¬πŸ‡§ English</strong> Β· <a href="README.ru.md">πŸ‡·πŸ‡Ί Русский</a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="#-features">Features</a> Β·
25
+ <a href="#-quick-start">Quick start</a> Β·
26
+ <a href="#-what-mnemos-is">What it is</a> Β·
27
+ <a href="#%EF%B8%8F-architecture">Architecture</a> Β·
28
+ <a href="#%EF%B8%8F-three-surfaces-one-core">Surfaces</a> Β·
29
+ <a href="#-documentation">Docs</a>
30
+ </p>
31
+
32
+ ---
33
+
34
+ ## ✨ Features
35
+
36
+ One local server β€” and a connected agent harness gets the full memory stack.
37
+
38
+ | Area | What you get |
39
+ |------|--------------|
40
+ | **Universal connectivity** | MCP server (26 tools, stdio) + REST API β€” any MCP-capable harness connects in one line ([tools](docs/en/user/mcp-tools.md) Β· [HTTP](docs/en/user/http-api.md)) |
41
+ | **Ready integrations** | zcode, the `~/.agents` standard (Claude / Codex / Continue / Qwen and more), pi β€” via [`mnemos integration`](docs/en/user/integration-guide.md): deploy targets, one-line MCP presets, multi-harness doctor |
42
+ | **Skill pack** | 14+ memory skills deployed into your harnesses |
43
+ | **Flexible memory** | Hybrid search (full-text + vector, rank fusion), [tag contract](docs/en/user/tag-contract.md), per-agent / per-project memory, [context-filter](docs/en/user/context-filter.md) profiles, CCR compression β€” 70–90% token savings, originals kept |
44
+ | **Context assembly** | `assemble_context`: search β†’ compress β†’ filter β†’ secret scan β†’ cache align β†’ token budget, per-block provenance |
45
+ | **Context bridge** | `on_context_rewrite` β€” when the harness compacts history, the lossless original stays available on demand |
46
+ | **Lifecycle hooks** | `pre_llm_call` context injection, `on_session_start`, `post_tool_call` auto-compression of tool outputs |
47
+ | **Publication v3.0.0** | Entries visible immediately after save, background refinement with seamless swap, quarantine with neutral retraction |
48
+ | **Self-protection** | Injection / secret detectors on input and publication, every output scanned, full per-entry audit |
49
+ | **Auto-pipeline** | Background processor: clustering, deduplication, quality gate, publication |
50
+
51
+ Autonomy for an arbitrary harness, LLM-driven enrichment, and package
52
+ publishing (PyPI / npm) are partial β€” the full, honest map lives in
53
+ [docs/en/features.md](docs/en/features.md).
54
+
55
+ ---
56
+
57
+ ## πŸš€ Quick start
58
+
59
+ Four steps to a working memory store, wired into VS Code Copilot.
60
+
61
+ ### 1 Β· Install
62
+
63
+ ```bash
64
+ curl -fsSL https://raw.githubusercontent.com/Korrnals/mnemos/main/scripts/install.sh | bash
65
+ ```
66
+
67
+ The installer does everything for you β€” no Python or venv knowledge required:
68
+
69
+ - creates an isolated environment at `~/.mnemos/venv`;
70
+ - drops a `mnemos` launcher into `~/.local/bin`, so the CLI just works in any shell (**no venv activation needed**);
71
+ - offers to wire up VS Code MCP integration right there (or run it later β€” see step 3).
72
+
73
+ > Prefer a non-interactive run? Add `--mcp` / `--no-mcp` to decide up front, e.g.
74
+ > `… | bash -s -- --mcp`.
75
+
76
+ ### 2 Β· Write &amp; recall
77
+
78
+ ```bash
79
+ mnemos add "First memory β€” Mnemos remembers across sessions" \
80
+ --tags project:mnemos,agent:tech-writer,mnemos:learning
81
+
82
+ mnemos search "remembers across sessions"
83
+ ```
84
+
85
+ That's the whole loop: **write, find, never lose it.** Every entry carries a
86
+ [tag contract](docs/en/user/tag-contract.md) (`project:` / `agent:` / `mnemos:`) so memories stay organised.
87
+
88
+ ### 3 Β· Connect VS Code (MCP)
89
+
90
+ If you answered **yes** during install, you're already done β€” just reload your VS Code window.
91
+ To set it up manually, or on another machine:
92
+
93
+ ```bash
94
+ curl -fsSL https://raw.githubusercontent.com/Korrnals/mnemos/main/scripts/mcp-setup.sh | bash
95
+ ```
96
+
97
+ Then **reload the VS Code window** (`Ctrl+Shift+P β†’ Reload Window`). The `mnemos_*` tools appear in
98
+ Copilot's tool picker, and your agents can call `mnemos_add` / `mnemos_search` directly.
99
+
100
+ ### 4 Β· Deploy behavioral instructions
101
+
102
+ ```bash
103
+ mnemos integration setup
104
+ ```
105
+
106
+ This deploys memory-usage instructions, skills, and a prompt mode to your
107
+ agent harness (Copilot `~/.copilot/`, generic Copilot, Cursor, and Hermes Agent
108
+ `~/.hermes/`), plus two universal targets: `zcode` (native `~/.zcode/` skills +
109
+ MCP config) and `agents` (the AGENTS.md standard `~/.agents/` β€” read natively
110
+ by ZCode, Claude Code, Codex, Cursor and friends). Agents will now *know when
111
+ and how* to use Mnemos memory β€” not just have the tools available. Use
112
+ `--home <dir>` to install into another environment's home (e.g. a container).
113
+
114
+ Add `--wire-agents --all` to also grant `mnemos/*` tools to Copilot agent
115
+ frontmatter in the same pass. See the
116
+ [integration guide](docs/en/user/integration-guide.md#agent-mcp-wiring)
117
+ for wiring flags and the [context filter guide](docs/en/user/context-filter.md)
118
+ for the five-stage noise stripper that runs automatically on every `mnemos_add`.
119
+
120
+ <details>
121
+ <summary><strong>πŸ› οΈ Other ways to install</strong> β€” from source, released wheel, or container one-liner</summary>
122
+
123
+ <br>
124
+
125
+ **From source** (for development):
126
+
127
+ ```bash
128
+ git clone https://github.com/Korrnals/mnemos.git
129
+ cd mnemos
130
+ uv venv && source .venv/bin/activate
131
+ uv pip install -e ".[dev]"
132
+ ```
133
+
134
+ **Released wheel** (pin a specific version):
135
+
136
+ <!-- version:pip -->
137
+ ```bash
138
+ pip install https://github.com/Korrnals/mnemos/releases/download/v3.0.0/mnemos-3.0.0-py3-none-any.whl
139
+ ```
140
+ <!-- /version:pip -->
141
+
142
+ **Container one-liner** β€” pulls the image, creates volumes, starts on port 8787:
143
+
144
+ ```bash
145
+ export MNEMOS_API__TOTP_MASTER_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
146
+ curl -fsSL https://raw.githubusercontent.com/Korrnals/mnemos/main/scripts/install.sh | bash -s -- --container
147
+ ```
148
+
149
+ See the full [container deployment guide](docs/en/admin/runbooks/container-deployment.md).
150
+
151
+ </details>
152
+
153
+ <details>
154
+ <summary><strong>🐳 Run the pre-built image directly (GHCR)</strong></summary>
155
+
156
+ <br>
157
+
158
+ Published to `ghcr.io/korrnals/mnemos` on every release tag.
159
+
160
+ ```bash
161
+ # Generate a TOTP master key (required β€” the container binds 0.0.0.0)
162
+ export MNEMOS_API__TOTP_MASTER_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
163
+
164
+ podman run -d --name mnemos \
165
+ -p 8787:8787 \
166
+ -v mnemos-data:/data \
167
+ -v mnemos-vault:/vault \
168
+ -e MNEMOS_API__TOTP_MASTER_KEY="${MNEMOS_API__TOTP_MASTER_KEY}" \
169
+ <!-- version:image -->
170
+ ghcr.io/korrnals/mnemos:3.0.0
171
+ <!-- /version:image -->
172
+
173
+ curl -s http://localhost:8787/health | jq
174
+ ```
175
+
176
+ <!-- version:tags -->
177
+ Tags: `:3.0.0` (pinned) Β· `:latest` (rolling). Works with `docker` too β€” swap `podman` for `docker`.
178
+ <!-- /version:tags -->
179
+
180
+ </details>
181
+
182
+ > πŸ“˜ For a guided first run covering the MCP and HTTP servers, see
183
+ > [getting-started.md](docs/en/user/getting-started.md).
184
+
185
+ ---
186
+
187
+ ## 🧩 What Mnemos is
188
+
189
+ A **single-tenant, local-first memory server** for AI agents. One in-process core, three equivalent
190
+ control surfaces, and a storage layer you can read with your own eyes.
191
+
192
+ | | Capability | What it gives you |
193
+ |---|------------|-------------------|
194
+ | πŸ”Ž | **Hybrid search** | Vector similarity + SQLite FTS5 full-text over every memory |
195
+ | πŸ§ͺ | **Knowledge pipeline** | `raw β†’ processing β†’ processed β†’ published` lifecycle with a state machine |
196
+ | 🧠 | **Per-agent recall** | A focused recall surface scoped to each agent's project context |
197
+ | βš™οΈ | **Policy engine** | Schedule and trigger automation over the memory store |
198
+ | 🧹 | **Context filter** | Five-stage noise stripper for logs / stdout before anything hits a model |
199
+ | πŸ—œοΈ | **Reversible compression (CCR)** | Compress large content with zero data loss β€” originals cached in SQLite, retrievable via hash marker |
200
+ | 🧷 | **CacheAligner (P1-5)** | Relocate dynamic content (timestamps, UUIDs, session ids, tokens) to the tail so provider KV caches (Anthropic `cache_control`, OpenAI prefix caching) hit across requests |
201
+ | πŸͺΆ | **Output token reduction (P1-7)** | Optional `verbosity` / `effort` params on `mnemos_add` / `mnemos_search` / `mnemos_recall_context` steer the caller's output style β€” backward compatible, defaults are a no-op |
202
+ | πŸ“‚ | **Path-scoped rules** | Ingest project rules and apply them by file path |
203
+ | πŸ—‚οΈ | **Obsidian vault** | A markdown mirror humans can browse, edit, and grep |
204
+
205
+ SQLite for metadata, a local numpy + SQLite vector index for recall, and an Obsidian-compatible vault
206
+ for the humans in the loop.
207
+
208
+ ---
209
+
210
+ ## πŸ—οΈ Architecture
211
+
212
+ <details open>
213
+ <summary><strong>System diagram</strong> β€” clients β†’ interfaces β†’ core β†’ storage</summary>
214
+
215
+ <br>
216
+
217
+ ```mermaid
218
+ flowchart TB
219
+ subgraph CLIENTS["Clients"]
220
+ C1(["VS Code Β· Copilot\nstdio MCP"])
221
+ C2(["CLI β€” mnemos …"])
222
+ C3(["HTTP API client"])
223
+ end
224
+
225
+ subgraph IFACE["Interface Layer"]
226
+ MCP["mcp_server.py"]
227
+ FAPI["api/main.py Β· FastAPI"]
228
+ TYPER["cli/main.py Β· Typer"]
229
+ end
230
+
231
+ MGR(["MemoryManager\nmanager.py"])
232
+
233
+ subgraph PROC["Processing Subsystems"]
234
+ CF["Context Filter\nfilter/"]
235
+ PP["Knowledge Pipeline\npipeline/"]
236
+ RE["Recall Engine\nrecall/"]
237
+ PE["Policy Engine\npolicy/"]
238
+ end
239
+
240
+ subgraph BG["Background Services"]
241
+ WA["Watchers\nwatchers/"]
242
+ AC["Auto-collect\nauto_collect.py"]
243
+ end
244
+
245
+ subgraph STORE["Storage Layer"]
246
+ SQ[("SQLite\nFTS5 Β· traces Β· projects")]
247
+ VS[("Vector Store\nnumpy + SQLite")]
248
+ VLT[("Obsidian Vault\nmarkdown mirror")]
249
+ end
250
+
251
+ C1 -->|"stdio"| MCP
252
+ C2 --> TYPER
253
+ C3 --> FAPI
254
+ MCP --> MGR
255
+ TYPER --> MGR
256
+ FAPI --> MGR
257
+ MGR --> CF
258
+ MGR --> PP
259
+ MGR --> RE
260
+ MGR --> SQ
261
+ MGR --> VS
262
+ MGR --> VLT
263
+ CF -.->|"raw + clean"| SQ
264
+ PP -->|"status transitions"| SQ
265
+ PP -->|"published upsert"| VS
266
+ RE -->|"FTS5 MATCH"| SQ
267
+ RE -->|"cosine search"| VS
268
+ PE -->|"schedule / trigger"| MGR
269
+ WA -->|"file events"| MGR
270
+ AC -.->|"checkpoint reminder"| MCP
271
+ ```
272
+
273
+ </details>
274
+
275
+ A deeper walkthrough β€” data model, state machines, security boundaries, operational concerns β€” lives in
276
+ [architecture/overview.md](docs/en/architecture/overview.md).
277
+
278
+ ---
279
+
280
+ ## πŸŽ›οΈ Three surfaces, one core
281
+
282
+ The same `MemoryManager` powers all three interfaces. Pick the one that fits your client.
283
+
284
+ | Surface | Use it when… | Reference |
285
+ |---------|--------------|-----------|
286
+ | **CLI** β€” `mnemos …` | You live in a shell, want fast ad-hoc add / search, or are scripting cron jobs | [cli-reference.md](docs/en/user/cli-reference.md) |
287
+ | **HTTP** β€” `mnemos serve` | You have a non-MCP client β€” a web dashboard, a mobile app, a CI runner | [http-api.md](docs/en/user/http-api.md) |
288
+ | **MCP** β€” `mnemos mcp-server` | You are VS Code Copilot or any MCP-aware agent β€” the path Copilot agents take | [mcp-tools.md](docs/en/user/mcp-tools.md) |
289
+
290
+ The MCP surface also exposes the **A2A Sessions API** (M16) β€” a persistent backend for multi-step agent
291
+ conversations. Five endpoints (`POST /v1/sessions`, append-turn, range-load, …) let agents survive restarts
292
+ without losing context. See [a2a-sessions.md](docs/en/architecture/a2a-sessions.md).
293
+
294
+ ---
295
+
296
+ ## πŸ“– The lore
297
+
298
+ > In Hesiod's *Theogony*, **Mnemosyne** (ΞœΞ½Ξ·ΞΌΞΏΟƒΟΞ½Ξ·) is the Titaness of memory β€” she who, by Zeus, gave
299
+ > birth to the nine Muses and through them made the world's remembering possible. Her name is the root of
300
+ > *mnemonic*, and she is what every singer, poet, and philosopher prays to before they begin.
301
+
302
+ This software carries her name because it is built for the same task: **to make remembering possible for
303
+ the things that think.** AI agents, unmoored from any single conversation, lose everything that came
304
+ before. Mnemos gives them a place to lay it down β€” structured, searchable, governed by contract β€” so that
305
+ what they learn does not vanish with the closing of a session. The Muses, after all, were not for the
306
+ gods' benefit. They were for the songs.
307
+
308
+ ---
309
+
310
+ ## πŸ“š Documentation
311
+
312
+ | Page | What it covers |
313
+ |------|----------------|
314
+ | [docs/README.md](docs/README.md) | Documentation landing β€” language picker (EN / RU) |
315
+ | [getting-started.md](docs/en/user/getting-started.md) | First run: install β†’ first memory β†’ first search β†’ MCP / HTTP |
316
+ | [architecture/overview.md](docs/en/architecture/overview.md) | System shape, data model, state machines, security boundaries |
317
+ | [cli-reference.md](docs/en/user/cli-reference.md) | Every `mnemos` subcommand with flags, defaults, examples |
318
+ | [mcp-tools.md](docs/en/user/mcp-tools.md) | Every `mnemos_*` tool exposed to VS Code Copilot |
319
+ | [http-api.md](docs/en/user/http-api.md) | Every HTTP endpoint (memory CRUD + A2A Sessions, M16) |
320
+ | [a2a-sessions.md](docs/en/architecture/a2a-sessions.md) | Agent-to-agent conversation contract (M16) |
321
+ | [tag-contract.md](docs/en/user/tag-contract.md) | The `project:` / `agent:` / `mnemos:` schema enforced on every memory |
322
+ | [security.md](docs/en/admin/security.md) | Threat model, SSRF guard, FTS5 escape, HF Hub pinning |
323
+ | [runbooks/](docs/en/admin/runbooks/) | Install, migrate, backup / restore, dependency updates |
324
+ | [container-deployment.md](docs/en/admin/runbooks/container-deployment.md) | Build, push, compose, podman, Kubernetes, quadlet |
325
+ | [adr/](docs/project/adr/) | Architectural decision records β€” the *why* behind the design |
326
+ | [milestones.md](docs/project/milestones.md) | Milestone ledger with status legend |
327
+ | [reports/](docs/project/reports/) | Phase completion reports β€” final report per completed roadmap phase |
328
+ | [CHANGELOG.md](CHANGELOG.md) | Release notes β€” Keep a Changelog format |
329
+
330
+ ---
331
+
332
+ ## 🀝 Integrations
333
+
334
+ Mnemos works with every MCP-capable agent harness. Three integration levels β€”
335
+ pick the strongest one your harness supports:
336
+
337
+ | Harness | Native deploy target | One-line MCP preset | Adapter template |
338
+ |---------|----------------------|---------------------|------------------|
339
+ | VS Code Copilot | `copilot` (+ prompts via `generic-copilot`) | [mcp-setup.sh](scripts/mcp-setup.sh) | βœ“ |
340
+ | Claude Code | via `agents` | [preset](integrations/mcp-presets.md#claude-code) | βœ“ |
341
+ | Cursor | `cursor` | [preset](integrations/mcp-presets.md#cursor) | βœ“ |
342
+ | Codex | via `agents` | [preset](integrations/mcp-presets.md#codex) | βœ“ |
343
+ | Windsurf | β€” | [preset](integrations/mcp-presets.md#windsurf) | βœ“ |
344
+ | ZCode | `zcode` | β€” | βœ“ |
345
+ | Any AGENTS.md-standard harness | `agents` | β€” | βœ“ |
346
+ | [Hermes Agent](https://hermes-agent.nousresearch.com/) | `hermes` (native `MemoryProvider` plugin) | β€” | β€” |
347
+
348
+ - **[Hermes Agent](https://hermes-agent.nousresearch.com/)** β€” native `MemoryProvider` plugin
349
+ (`integrations/hermes/`): automatic prefetch, sync-turn, built-in memory mirroring.
350
+ Since plugin **3.0.0** (ADR-0017 D1) the plugin runs **in-process** β€” it needs `pip install mnemos`
351
+ in the Hermes Python environment, and the legacy `base_url` / `api_key` / `totp_secret` config keys are gone.
352
+ See the [integration guide](docs/en/user/integration-guide.md#hermes-agent).
353
+ - **Native targets** β€” `mnemos integration setup --target <name>` deploys the
354
+ behavioral pack and registers the MCP server in one pass. See the
355
+ [integration guide](docs/en/user/integration-guide.md).
356
+ - **One-line MCP presets** β€” [`integrations/mcp-presets.md`](integrations/mcp-presets.md):
357
+ connect Cursor, Claude Code, Codex, or Windsurf by pasting one line.
358
+ - **Adapter template** β€” [`integrations/adapter-template.md`](integrations/adapter-template.md):
359
+ Connect / Expose / Configure + acceptance checklist for any harness that
360
+ speaks MCP stdio.
361
+
362
+ The shared contract is the [tag schema](docs/en/user/tag-contract.md) β€” `project:<slug>`, `agent:<slug>`,
363
+ and at least one `mnemos:<subtype>` β€” that every memory entry must carry.
364
+
365
+ ---
366
+
367
+ ## βš–οΈ Source &amp; license
368
+
369
+ - **Source** β€” this repository, [github.com/Korrnals/mnemos](https://github.com/Korrnals/mnemos).
370
+ - **License** β€” MIT (see [pyproject.toml](pyproject.toml)).
371
+
372
+ ## 🌱 Contributing
373
+
374
+ PRs welcome. Read [PLAN.md](PLAN.md) for the roadmap and follow the conventions in the [docs/](docs/) set.
375
+
376
+ Git workflow: `feat/*` β†’ `dev-<stage>` β†’ `release/X.Y.Z` β†’ `main`; `main` accepts only `release/*` and
377
+ `hotfix/*` PRs. Conventional Commits required. Run `make verify` before opening a PR.
378
+
379
+ ---
380
+
381
+ <p align="center">
382
+ <sub><strong>Reproduce the green state:</strong> <code>make verify</code> runs the full quality gate
383
+ β€” ruff + mypy --strict + bandit + pip-audit + 867 tests. If it's green, the change is good to ship.</sub>
384
+ </p>