alexiel-memory

Public

263 Downloads

1 star

README

alexiel-memory

An LM Studio plugin that gives Alexiel persistent memory, combining two mechanisms:

  • promptPreprocessor — runs automatically on every message, searches the memory store, and injects relevant matches into context before the model sees the prompt. No tool-call round trip, no dependency on the model deciding to look something up.
  • Tools (alexiel_remember, alexiel_recall, alexiel_list_memories, alexiel_forget) — explicit actions the model calls when it decides something is worth saving, or needs to search beyond what was auto-injected.

Storage is SQLite + FTS5 via Node's built-in node:sqlite module — no native addon, no compilation step, no Node-version/ABI matching ever needed, since it ships inside whatever Node binary runs the plugin. It shares the same database file as memory-mcp-server by default (~/.memory-mcp-server/memory.db) — anything saved through either path shows up in both. Override with MEMORY_DB_PATH if you want them separate.

Note: node:sqlite is still marked experimental by Node (as of Node 22–25), which normally prints an ExperimentalWarning to stderr on first use. src/store.ts imports src/suppressExperimentalWarnings.ts first specifically to silence that one warning — LM Studio's plugin log viewer labels all stderr output as "Error:", which made a harmless warning look like a failure. If a given Node build's bundled SQLite somehow lacks FTS5, the store automatically falls back to a plain LIKE-based search; save/list/get/delete are unaffected either way.

Why a plugin instead of just the MCP server

The MCP server needs the model to choose to call memory_search — reliable with bigger models, less so with a 9B model under load. The promptPreprocessor hook here removes that dependency entirely: retrieval happens on every message regardless of what the model decides. The MCP server is still useful on its own (e.g. from Claude Desktop or any other MCP client), and now reads/writes the same data as this plugin.

(memory-mcp-server itself still uses better-sqlite3, which is why it needed the Node-version/build-tools dance to install. This plugin deliberately avoids that by using node:sqlite instead — worth porting the MCP server over too if the native-compile fragility becomes annoying there as well.)

Setup

Requires the LM Studio CLI (lms) — comes bundled with LM Studio, or install separately per LM Studio's docs.

npm install
npm run dev   # runs `lms dev` — loads the plugin into LM Studio in dev/watch mode

lms dev bundles src/ via the .lmstudio/entry.ts bootstrap and hot-reloads on save. Once you're happy with it:

npm run push  # runs `lms push` — publishes/installs the plugin properly

Then enable alexiel-memory for your chat/agent session in LM Studio the same way you'd enable any other plugin or tool.

Config

Exposed in LM Studio's plugin settings panel:

  • Auto-inject relevant memories (default on) — toggle the promptPreprocessor search.
  • Retrieval Limit (default 5) — max memories injected per message.

Key naming convention

Same scheme as memory-mcp-server, since they share storage:

profile:<fact>
project:<name>:<aspect>
preference:<topic>

System prompt

Pair this with a system prompt that tells Alexiel how to use the explicit tools (the promptPreprocessor injection needs no prompting — it just happens). The save-path prompt from earlier still applies:

You have memory tools (alexiel_remember, alexiel_recall, alexiel_list_memories, alexiel_forget). When the user states a durable fact, decision, or project detail, call alexiel_remember with a "namespace:subject" key. Don't call alexiel_recall unless you need something beyond what's already been injected into context. Never fabricate memory contents.

Files

manifest.json          — plugin identity (owner/name/revision)
package.json           — deps: @lmstudio/sdk, better-sqlite3, zod
src/store.ts            — shared SQLite + FTS5 store (save/search/list/delete)
src/suppressExperimentalWarnings.ts — silences node:sqlite's stderr warning (imported first by store.ts)
src/config.ts            — user-tunable settings shown in LM Studio's UI
src/promptPreprocessor.ts — auto-injection on every message
src/tools.ts              — explicit save/search/list/forget tools
src/index.ts              — wires config + preprocessor + tools together
.lmstudio/entry.ts        — LM Studio's generic plugin bootstrap (don't edit)