@lotargo/memory_plugin 1.5.3 → 1.6.1

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 (35) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.md +406 -352
  3. package/mcp-server/admin/auth.js +13 -4
  4. package/mcp-server/admin/snapshot.js +24 -7
  5. package/mcp-server/boot.js +43 -0
  6. package/mcp-server/cli/direct_commands.js +334 -313
  7. package/mcp-server/cli/handlers/engine_actions.js +41 -0
  8. package/mcp-server/cli/handlers/storage_actions.js +58 -0
  9. package/mcp-server/cli/secret_input.js +44 -0
  10. package/mcp-server/cli/ui.js +564 -565
  11. package/mcp-server/cli.js +356 -324
  12. package/mcp-server/cli_boot.js +37 -0
  13. package/mcp-server/config/auth_store.js +74 -16
  14. package/mcp-server/config/config_manager.js +4 -0
  15. package/mcp-server/db/database.js +33 -14
  16. package/mcp-server/db/sync_queue.js +9 -19
  17. package/mcp-server/index.js +112 -42
  18. package/mcp-server/ingest/normalizer.js +116 -29
  19. package/mcp-server/ingest/pipeline.js +94 -6
  20. package/mcp-server/logger.js +49 -0
  21. package/mcp-server/memory.js +6 -9
  22. package/mcp-server/ml/gpu_monitor.js +169 -166
  23. package/mcp-server/ml/model_manager.js +17 -4
  24. package/mcp-server/preinstall.js +23 -2
  25. package/mcp-server/retrieval/retriever.js +35 -15
  26. package/mcp-server/security/path_guard.js +67 -0
  27. package/mcp-server/setup.js +10 -2
  28. package/mcp-server/storage/blob_store.js +15 -2
  29. package/mcp-server/tools/core/memory_core.js +393 -0
  30. package/mcp-server/tools/helpers.js +59 -39
  31. package/mcp-server/tools/memory_tools.js +123 -516
  32. package/mcp-server/tools/rag_tools.js +49 -1
  33. package/opencode-plugin/index.js +94 -397
  34. package/package.json +13 -4
  35. package/skills/using-memory/SKILL.md +7 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,138 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@lotargo/memory_plugin` are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.6.1] - 2026-08-10
9
+
10
+ ### Fixed
11
+
12
+ - **Cryptic crash on Node.js < 22.5.0** (`No such built-in module: node:sqlite`).
13
+ ESM static imports are hoisted, so the `node:sqlite` import in `database.js`
14
+ crashed before any user code could run. Three layers of protection are now in
15
+ place:
16
+ 1. **Boot guard** (`boot.js` / `cli_boot.js`): new lightweight entry points
17
+ that check `process.versions.node` *before* loading the ESM module graph.
18
+ On incompatible versions they print a clear boxed error with upgrade
19
+ instructions (`nvm install 22` / `brew install node@22`) and exit.
20
+ 2. **`engine-strict`** (`.npmrc`): `npm install` now **fails** instead of
21
+ merely warning when `engines.node >= 22.5.0` is not satisfied.
22
+ 3. **Preinstall warning** (`preinstall.js`): a prominent `stderr` message is
23
+ printed during installation on unsupported Node versions, explaining that
24
+ the server will not start.
25
+ - Process-kill patterns in `preinstall.js` now match the new `boot.js` entry
26
+ point in addition to `index.js`, so global updates correctly terminate running
27
+ server instances.
28
+
29
+ ### Changed
30
+
31
+ - All `bin` entry points (`memory_plugin`, `memory-agent`, `memory-cli`) now
32
+ route through `boot.js` / `cli_boot.js` instead of directly to `index.js` /
33
+ `cli.js`.
34
+ - `.npmrc` is no longer git-ignored; it contains only the project-level
35
+ `engine-strict=true` setting (npm never publishes `.npmrc` to the tarball).
36
+
37
+ ## [1.6.0] - 2026-08-10
38
+
39
+ This release is the outcome of a full five-part audit (publishing, security, code
40
+ quality, tests, documentation): 92 checklist items across 8 stages. It also fixes
41
+ a critical retrieval regression introduced after `v1.5.3`.
42
+
43
+ ### Breaking
44
+
45
+ - **Node.js 22.5.0 or newer is now required.** The engine is built on the built-in
46
+ `node:sqlite` module, which only exists from Node 22.5.0. Previously `engines`
47
+ was absent and the README claimed `>=18.0.0`, so installs on Node 18/20/21 failed
48
+ at runtime with `ERR_UNKNOWN_BUILTIN_MODULE` instead of at install time.
49
+ - **`ingest_document({ type: "file" })` no longer reads arbitrary paths.** Reads are
50
+ restricted to the current working directory and the plugin data directory. Widen
51
+ the allowlist with `ingestAllowedPaths`, or set `ingestAllowAnyPath: true` to
52
+ restore the old behaviour.
53
+
54
+ ### Fixed
55
+
56
+ - **Vector search returned zero results (critical).** A `Buffer.isBuffer()` guard
57
+ added after `v1.5.3` discarded every stored vector, because `node:sqlite` returns
58
+ BLOB columns as `Uint8Array`, not `Buffer`. Vector and hybrid retrieval silently
59
+ degraded to BM25-only. The same bug pushed **empty** vectors to the cloud in
60
+ `hybrid-sync` and wrote empty vectors into exported snapshots.
61
+ - `update_fact` in the OpenCode plugin never parsed `**Title** body`: its regex was
62
+ double-escaped. The title was stored verbatim as part of the body.
63
+ - `SQLITE_BUSY` ("database is locked") under concurrency — `PRAGMA busy_timeout`
64
+ is now set to 5000 ms (it defaulted to 0).
65
+ - Switching storage mode leaked the previous SQLite handle and Turso client; the
66
+ old connection is now closed before it is replaced.
67
+ - A database-init failure no longer blocks reopening the **local** database: the
68
+ retry cooldown applies to cloud modes only.
69
+ - `runWithRetry` leaked an `abort` listener on every attempt.
70
+ - Optional numeric tool arguments (`offset`, `limit`, `startLine`, `endLine`,
71
+ `dimension`) rejected empty strings with "Expected number"; they are now coerced.
72
+ - `link`, `unlink`, `relink`, `identity`, `migrate_titles`, `enable-prompt` and
73
+ `disable-prompt` were unreachable through the `memory_plugin` binary — the process
74
+ started an MCP server and blocked on stdin instead of running the command.
75
+ - GPU trace reports were written to stdout, which is the MCP JSON-RPC channel.
76
+
77
+ ### Security
78
+
79
+ - Secrets are encrypted with PBKDF2 raised from 10,000 to **600,000** iterations
80
+ (OWASP guidance); existing files are transparently re-encrypted on first read.
81
+ - `auth_secrets.enc` is written with owner-only permissions (`0600`).
82
+ - The machine fingerprint no longer includes the volatile hostname and username,
83
+ which could permanently lock a user out of their own secrets after a rename.
84
+ - SSRF filtering rewritten: IPv6 literals are unwrapped from their brackets,
85
+ IPv4-mapped forms (`::ffff:127.0.0.1`, `::ffff:7f00:1`), link-local, unique-local,
86
+ multicast and CGNAT ranges are blocked, and the resolved address is re-checked
87
+ before the request to defend against DNS rebinding — on the initial request and
88
+ on every redirect hop.
89
+ - Cloud tokens are no longer taken from `argv` by default: environment variables
90
+ are preferred, then a hidden stdin prompt. Passing a token as a flag now warns.
91
+ - Snapshot paths are resolved with `realpath`, so a symlink or junction can no
92
+ longer escape the allowlisted directories.
93
+ - Snapshot and blob decompression is capped at 512 MB to prevent zip bombs.
94
+
95
+ ### Added
96
+
97
+ - `CHANGELOG.md` (this file).
98
+ - `--help` and `--version` for both `memory_plugin` and `memory-cli`.
99
+ - Config keys `ingestAllowedPaths` and `ingestAllowAnyPath`.
100
+ - `mcp-server/logger.js`: a central logger with levels (`MEMORY_LOG_LEVEL`), an
101
+ stderr sink and a swappable transport.
102
+ - Two regression test suites — vector BLOB round-trip and benchmark report
103
+ labelling. The suite is now 12 files, all green.
104
+
105
+ ### Changed
106
+
107
+ - The six Notebook tools live in a single implementation
108
+ (`mcp-server/tools/core/memory_core.js`) shared by the MCP server and the
109
+ OpenCode plugin. They previously carried separate copies, so fixes reached only
110
+ one surface. `opencode-plugin/index.js` shrank from 1161 to 825 lines and
111
+ `memory_tools.js` from 516 to 124.
112
+ - The OpenCode plugin uses static ESM imports instead of top-level
113
+ `await import(...)`, and registers its `exit` hook once per instance rather than
114
+ on every module import.
115
+ - Importing `run_benchmarks.js` no longer launches a full benchmark run; the report
116
+ renderer is exported as the pure function `buildMarkdownReport()`.
117
+ - `npm audit`: 5 advisories (1 moderate, 4 high) down to 3. The remaining
118
+ unfixable ones (`xlsx`, `sharp` via `@huggingface/transformers`) are documented
119
+ in the README with their reachability.
120
+ - Removed the stale nested `mcp-server/package.json`, a version-drift source.
121
+
122
+ ### Documentation
123
+
124
+ - Corrected claims that did not match the code: the "DPAPI / OS Secret Store"
125
+ credential storage, the circuit breaker failing over to a "local database cache",
126
+ a non-existent GitHub mirror for model weights, the tool count, the TUI
127
+ diagnostics menu, and the GraphRAG language coverage.
128
+ - Documented the `MEMORY_DIR` → `OPENCODE_CONFIG_DIR` → legacy `~/.config` →
129
+ `%LOCALAPPDATA%` resolution order, the previously undocumented config keys, and
130
+ the `update_fact` `title` parameter.
131
+ - Benchmark reports labelled the headline RRF/RSF rows with the grid-search winner
132
+ (`k=10`) while the numbers were computed with the runtime default (`k=60`). The
133
+ generator and every published table now state the parameters actually used.
134
+ - `BENCHMARKS.md` tables were re-derived from the stored JSON artifacts; the
135
+ bge-m3 section had carried e5-small numbers shifted by a column.
136
+
137
+ [1.6.1]: https://github.com/Lotargo/memory_pugin/releases/tag/v1.6.1
138
+ [1.6.0]: https://github.com/Lotargo/memory_pugin/releases/tag/v1.6.0