Self Improvement Memory MCP
README.md
# Self Improvement Memory MCP
Local MCP server for an agent memory and self-improvement loop:
1. A harness calls `start_task` when work begins.
2. The server recalls relevant memories with a configured embedding provider.
3. The agent applies those memories while working.
4. The harness calls `finish_task` when work ends, fails, or is interrupted.
5. Durable learnings are stored as candidates, validated when evidence is strong,
promoted explicitly for recall, mirrored into Obsidian, and exported for Graphify.
This is not limited to failures. It stores preferences, workflows, decisions,
facts, insights, patterns, project notes, tool notes, user notes, sessions, and
failures.
## Requirements
- Node.js 24+
Ollama is optional: configure a local Ollama embedding provider or use Ollama
for extraction when that service suits your workflow; a standalone install can
instead enable local in-process embeddings after installation. See
[Local embeddings without Ollama](#local-embeddings-without-ollama).
## Install
```powershell
npm install
npm run build
```
A resident MCP server keeps running the old `dist/`. After every `npm run build`
(or a plugin reinstall), restart the MCP client / server so it loads the new build.
See `.env.example` for the full list of supported variables and their defaults.
Nothing loads a `.env` file — it is a name+default reference only — so set the
values you need in your MCP client config, harness config, or shell profile.
## Install from a tgz
To install without publishing to an npm registry, build a tarball from a clean
checkout. `npm run dist` runs the package `prepack` build and prints the generated
`.tgz` filename:
```powershell
npm install
npm run dist
```
Transfer that `.tgz` file to the target machine through your normal trusted file
transfer channel, then install it globally there:
```powershell
npm i -g .\self-improvement-memory-mcp-<version>.tgz
```
Register the installed server as a stdio MCP server. The global npm bin directory
must be on the MCP client's `PATH`; restart the client after changing its config.
Use the client's equivalent configuration shape when its format differs:
```json
{
"mcpServers": {
"self-improvement-memory": {
"command": "self-improvement-memory-mcp",
"args": []
}
}
}
```
This starts with the same zero-config behavior as a source checkout. Configure
providers and storage through the MCP client environment or persistent shell
profile as described in `.env.example`; then follow [Local embeddings without
Ollama](#local-embeddings-without-ollama) to explicitly enable the local embedding
model when desired. For optional, advanced lifecycle-hook capture, the global
install also provides `self-improvement-memory-hook`; follow
[`hooks/README.md`](hooks/README.md) from the source checkout to wire it into a
harness. MCP-only use does not require hooks.
## Local embeddings without Ollama
A new standalone installation does not need Ollama or an embedding model before
it can start: hooks continue to capture events fail-open, and the server can
boot. Memory operations that need embeddings instead return guidance until you
choose a provider. For the zero-config local path:
1. Install and build the server as above, then add the stdio MCP server to the
harness configuration.
2. On first use, call `enable_local_embedding` without `consent` to see the
model id, approximate download size, and cache location. This changes nothing
and does not download anything.
3. After reviewing that information, call
`enable_local_embedding({ consent: true })`. It downloads approximately 140 MB
of quantized `nomic-ai/nomic-embed-text-v1.5` weights into
`<data-dir>/models`, runs one local smoke embedding, then records
`embedProvider: "local"` and the model in `<data-dir>/settings.json`.
4. If you are configuring from a terminal instead of MCP, run
`npm run setup:local-embed`. Confirm the TTY prompt, or use
`npm run setup:local-embed -- --yes` only in a deliberate non-interactive
setup. Without `--yes`, a non-interactive invocation makes no changes.
The setup download contains model weights only; memory and prompt data do not
leave the machine. Runtime embedding never downloads models silently. If setup
or its smoke embedding fails, it leaves `settings.json` unchanged so retrying is
safe. `npm run status` reports the effective embedding state as `unconfigured`,
`local-ready`, `ollama`, or `openai`.
### Hook ceiling for local embeddings
The local provider is appropriate for MCP tools and CLIs, which keep one process
alive long enough to load the in-process ONNX model. Hooks are intentionally
short-lived, fail-open processes with a 3-second `SELF_IMPROVE_HOOK_BUDGET_MS`
deadline. A cold local-model load or inference can exceed that ceiling; in that
case recall injection is skipped quietly, while raw event capture remains
unaffected and the hook never blocks the agent turn. If hook recall injection is
required, select an already-running Ollama service or an OpenAI-compatible
provider instead. A resident hook worker is out of scope for this release.
### Choosing an embedding provider
- **`local`** — choose the consented in-process model for a standalone,
zero-config, no-daemon path. It keeps memory and prompt data local, but has the
hook cold-start ceiling above. `local` is embedding-only; extraction still uses
its own provider.
- **`ollama`** — choose a running local Ollama service when you want hook recall
without loading an ONNX model per hook, or when you already use Ollama for
extraction. Explicitly set `SELF_IMPROVE_EMBED_PROVIDER=ollama` (and the
relevant `OLLAMA_*` values) when selecting it rather than relying on an
unconfigured fresh install.
- **`openai`** — choose any OpenAI-compatible embedding endpoint when its model
or service characteristics are required. A non-loopback endpoint sends memory
text to that service and requires the explicit
`SELF_IMPROVE_ALLOW_REMOTE_LLM=true` opt-in; a loopback-compatible server needs
no remote opt-in.
Provider/model settings use `settings.json` first, then environment variables,
then the built-in fallback. See [External providers (OpenAI-compatible)](#external-providers-openai-compatible)
for the OpenAI-compatible configuration and [Local-only Ollama boundary](#local-only-ollama-boundary)
for Ollama's remote opt-in. Switching an embedding provider or model changes the
embedding identity; existing promoted memories require re-embedding before they
are recalled again.
## Codex Plugin Install
For Codex, install this as a plugin instead of only adding the MCP server. The
plugin bundles:
- MCP server config
- Codex lifecycle hooks
- local event capture
- task lifecycle tracking
- Graphify/Obsidian exports
```powershell
node scripts/install-codex-plugin.mjs
codex plugin add self-improvement-memory@personal
```
The installer builds the project, copies it to:
```text
~/plugins/self-improvement-memory
```
If the `graphify` CLI is missing, the installer installs `graphifyy` with `uv`
or `python -m pip install --user`.
Then it writes:
```text
~/.agents/plugins/marketplace.json
```
The installer copies a fresh build into the plugin directory, so restart any
resident Codex session (or MCP client) afterward to pick up the new server.
Codex hooks are security-sensitive. Codex may ask you to review and trust the
new command hooks with `/hooks` before they run. After that, new Codex sessions
record raw hook events, task lifecycle, and explicit tool failures in the
background. Durable preferences, facts, decisions, workflows, and tool notes
are stored only when the agent explicitly calls `remember`.
## opencode Plugin Install
opencode integration lives in the repo as a tracked template at
`integrations/opencode/plugin.ts` (parallel to `hooks/hooks.json` for codex and
`.mcp.json` for MCP). It is a thin adapter that wires opencode lifecycle events
to the same `dist/hook.js` with `harness="opencode"`. The template is **not**
compiled by the repo's tsconfig — it depends on `@opencode-ai/plugin`, an opencode
runtime type that is not a repo dependency; opencode loads it with its own toolchain,
like `hooks.json` is a JSON template artifact, not a repo build product.
Manual install (no installer for opencode yet — automation is a follow-up):
1. Build the server once so `dist/hook.js` exists:
```powershell
npm install
npm run build
```
2. Copy the template into opencode's plugins dir:
```powershell
Copy-Item integrations/opencode/plugin.ts `
"$HOME/.config/opencode/plugins/memory-manager.ts" -Force
```
3. Open the copy and replace the `<PLUGIN_DIR>` placeholder with the absolute path
to this repo's checkout (the directory containing `dist/hook.js`), e.g.
`C:/Users/you/project/memory-manager`. This mirrors the `<PLUGIN_DIR>`
placeholder in `hooks/hooks.json`.
4. (Optional) recall injection is on only when
`~/.config/opencode/memory-manager.json` contains `{"recall": true}`. With no
config file or `recall` unset, the plugin logs raw events only (safe default).
5. Add the MCP server to `~/.config/opencode/opencode.jsonc` with the command
only — **do not put config env in the MCP block**. opencode config is
single-sourced from the **persistent ambient environment**: opencode launches
both the MCP server and this plugin from it, and the plugin passes that same
env through to every hook child it spawns, so server and hooks always resolve
the same `loadConfig()` store/model. An env map inside the MCP block reaches
only the server process — hook children never see it — silently splitting the
two onto different stores (the split-brain class in
`docs/knowledge/installer-mcp-env-must-match-loadconfig-defaults.md`).
```jsonc
{
"mcp": {
"self-improvement-memory": {
"type": "local",
"command": ["node", "<repo>/dist/index.js"]
}
}
}
```
To override any `loadConfig()` var (`MEMORY_MANAGER_DATA_DIR`, `OLLAMA_*`,
`SELF_IMPROVE_*` — see `.env.example`), set it as **persistent** user env
(Windows: `[Environment]::SetEnvironmentVariable("VAR", "value", "User")`;
POSIX: export it from your shell profile) and restart opencode.
Migration from an MCP-block-only override: move each var from the MCP block's
env map into persistent user env as above, restart opencode, then delete the
env map from the MCP block. Leaving both in place keeps the server on the
MCP-block value while hooks resolve the ambient one — the exact split this
setup exists to prevent.
6. Restart opencode. Start a session and confirm the hooks fire by checking the
raw event log under the data dir (`harness="opencode"`, `UserPromptSubmit`
carrying `prompt` text, `session_id` in snake_case, `PostToolUse` recording the
tool call).
## Verification
For pure store/config/text changes that need no Ollama, run the offline gate
first — it spins up no mock HTTP server and exercises the store, sanitize,
config, checkpoint, and status helper contracts:
```powershell
npm run verify:offline
```
Run the full local verification suite (requires a local Ollama) before relying
on a change end to end:
```powershell
npm run verify
```
It checks:
- TypeScript build
- Ollama embedding endpoint
- MCP server startup and tool list
- `remember` write path
- RAG retrieval quality against a small known eval set
- `start_task` / `finish_task` session lifecycle
- Codex hook runner raw event capture
- Graphify node and edge export
- memory/session storage coherence
## Standalone structured evidence ingestion
MM can ingest a producer-neutral, append-only JSONL file without lifecycle hooks
or an orchestrator calling MM. Each line uses
`memory-manager.learning-evidence/v1`:
```json
{"schema":"memory-manager.learning-evidence/v1","id":"run-42/task-8","producer":"runner","occurredAt":"2026-07-27T00:00:00.000Z","project":"memory-manager","task":"verify import","summary":"retry passed","evidence":{"observations":[{"kind":"verification","text":"all checks passed"}]}}
```
Import it from a source checkout:
```powershell
npm run evidence-ingest -- C:\path\to\evidence.jsonl
```
Or from a global install:
```powershell
self-improvement-memory-ingest C:\path\to\evidence.jsonl
```
The importer validates the envelope, sanitizes the packet, deduplicates its
producer-scoped stable `id`, and appends a project-scoped `LearningEvidence`
checkpoint for the existing lazy candidate-extraction pipeline. It does not
promote extracted candidates. The path is explicit and no producer-specific
log location or filename is assumed.
The script uses a temporary data directory and prints that path so you can
inspect `memories.jsonl`, `sessions.jsonl`, `hook-events.jsonl`, and
`graphify/self-improvement-graph.json`.
For an installed Codex plugin, also check:
```powershell
codex plugin list
```
You should see:
```text
self-improvement-memory@personal installed, enabled
```
Then start a new Codex thread and run `/hooks` if Codex asks you to review and
trust the plugin-bundled command hooks.
## Status
Read-only live view of the pipeline — a sticky GPU/Ollama usage header over a
merged tail of the store's log files. It never writes a store file, drains, takes
a lock, or calls the LLM:
```powershell
npm run status
```
## Recall Ranking Evaluation (offline)
Offline, propose-only tooling to evaluate recall ranking without touching the
serving path. None of it runs in the hook, takes a lock, edits config, or calls
the LLM:
```powershell
npm run label-export # join the logged recall data into one artifact
npm run replay-eval # replay logged calls under a variant config -> scored report
```
`label-export` reads the events/checkpoints/echo logs and writes one
machine-readable artifact (`recall-labels.json`) to the data dir — no repo writes,
fail-open on missing inputs. `replay-eval` replays the logged recall calls against
that artifact and prints a scored report; an identity check pins that replaying the
incumbent config reproduces the logged rankings.
A proposal round (`node dist/propose.js`) sweeps ranking variants and renders a
human-gated proposal under `docs/proposals/` (`status: pending`). Deploying a
winning variant is a separate follow-up — this tooling never changes ranking on
its own.
## MCP Client Config
Use direct MCP config only for non-Codex harnesses or when you do not want
automatic hooks. Use the built `dist/index.js` over stdio.
### Claude Desktop
```json
{
"mcpServers": {
"self-improvement-memory": {
"command": "node",
"args": ["<repo>/dist/index.js"],
"env": {
"OLLAMA_HOST": "http://localhost:11434",
"OLLAMA_EMBED_MODEL": "nomic-embed-text",
"MEMORY_MANAGER_DATA_DIR": "<home>/.self-improvement-memory-mcp",
"SELF_IMPROVE_OBSIDIAN_VAULT": "C:/Users/you/Documents/ObsidianVault",
"SELF_IMPROVE_OBSIDIAN_FOLDER": "Self Improvement/Failures"
}
}
}
}
```
### Codex
Add the same stdio server in the MCP configuration for your Codex harness:
```json
{
"name": "self-improvement-memory",
"command": "node",
"args": ["<repo>/dist/index.js"],
"env": {
"OLLAMA_HOST": "http://localhost:11434",
"OLLAMA_EMBED_MODEL": "nomic-embed-text",
"MEMORY_MANAGER_DATA_DIR": "<home>/.self-improvement-memory-mcp"
}
}
```
Other harness agents can use the same command/args/env shape as long as they
support stdio MCP servers.
### Local-only Ollama boundary
`OLLAMA_HOST` must resolve to a loopback address (`localhost`, `127.0.0.1`, `[::1]`).
A non-loopback or unparseable host is blocked before any outbound request: the MCP
server and CLIs abort with an actionable config error, and hooks log the error to
`hook-errors.jsonl` and fail open (exit 0, never blocking the turn). To use a remote
Ollama anyway — sending memory/prompt data off this machine — set the explicit opt-in
`SELF_IMPROVE_ALLOW_REMOTE_OLLAMA=true` as a **persistent** user env (hooks carry no
baked env, so an MCP-config-only opt-in leaves them blocked). `npm run status` shows
`BLOCKED` or `[remote opt-in]` on its ollama line.
### External providers (OpenAI-compatible)
Either LLM role can be routed to any OpenAI-compatible endpoint (OpenAI, OpenRouter,
Groq, LM Studio, llama.cpp server, …) instead of local Ollama, per role:
```sh
SELF_IMPROVE_EXTRACT_PROVIDER=openai # candidate extraction / correction scans
SELF_IMPROVE_EMBED_PROVIDER=openai # embeddings (see the re-embed warning below)
SELF_IMPROVE_OPENAI_BASE_URL=https://api.openai.com/v1 # default; any compatible base works
SELF_IMPROVE_OPENAI_API_KEY=sk-... # falls back to OPENAI_API_KEY; omit for local servers
SELF_IMPROVE_EXTRACT_MODEL=gpt-4o-mini # provider-neutral model names;
SELF_IMPROVE_EMBED_MODEL=text-embedding-3-small # OLLAMA_*_MODEL stay as fallbacks
SELF_IMPROVE_ALLOW_REMOTE_LLM=true # required for a non-loopback base URL (data leaves this machine)
```
Unset (or any value other than `openai`) keeps a role on local Ollama — the fail-safe
direction. The same local-only boundary applies: a non-loopback base URL is blocked
until `SELF_IMPROVE_ALLOW_REMOTE_LLM=true` is set, because extraction prompts and
memory text are sent to the endpoint. A loopback base (e.g. LM Studio at
`http://127.0.0.1:1234/v1`) needs no opt-in.
**Switching the embed model/provider changes the embedding identity**: existing
promoted rows fall out of recall until re-embedded (see
`docs/knowledge/promoted-rows-fall-out-of-recall-after-embedding-version-bump.md`).
Prefer keeping embeddings local unless you re-embed the store.
### Igor provider (managed subscriptions)
`extractProvider=igor` launches the pinned Node 24 bundle with `igor rpc --stdio`.
The TypeScript `IgorClient` owns exact `igor.rpc/1` negotiation, framing,
cancellation, and typed errors; extraction code never constructs human CLI argv or
parses presentation JSONL.
Select an active Igor account ID in Settings and choose a catalog model owned by
that account's provider. MM sends the explicit account ID, absolute extraction
workspace, read-only authority, and `max_steps: 3` for every extraction. Missing or
stale selection fails before prompt transmission; there is no ambient/default
account or fallback. The dashboard exposes label, provider, and full ID for
selection/copy only—login, logout, relabel, and account ordering remain operator
actions outside MM.
MM never reads Igor credential files and cannot perform account lifecycle
operations. Prompts leave this machine through the selected provider, so the
remote-LLM opt-in remains required. Transport loss is retryable for MM's existing
durable queue, but the ambiguous operation is never replayed in the same process.
A `max_steps` terminal may salvage already-emitted JSON and latest usage without
changing the fixed cap.
## Dashboard
`npm run dashboard` serves a web dashboard at `http://127.0.0.1:4859/`
(port: `SELF_IMPROVE_DASHBOARD_PORT`; loopback only). It shows the pipeline backlog,
memory counts, provider/Ollama/GPU state, the open candidate review queue, and a
merged tail of the store logs — the browser sibling of `npm run status`. Store files
are never written and no lock is ever taken; the one thing the dashboard writes is
`settings.json` (below) via its Settings panel.
Actions: **Run drain** spawns `dist/drain.js` as a child process (one at a time; the
store's drain lock still guards cross-process overlap) and reports its result inline.
The review queue has per-candidate **Promote** / **Reject** buttons — the human-review
UI over the same explicit trust gate as the MCP tools: gate-failed candidates go
through `acceptCandidate` → promote, memory-backed ones through `transitionMemory`
(reject = `rejectCandidate`, or deprecation for memory-backed). Candidates whose
linked memory is already promoted/retired leave the queue automatically. These POSTs
sit behind the same loopback/same-origin/JSON guard as the settings write.
Token accounting: every LLM call (extract/embed, any provider) appends one row to
`llm-usage.jsonl` in the data dir — timestamp, role, provider, model, and the
prompt/completion token counts the provider reported. The dashboard shows 24h and
all-time aggregates per role+provider ("tokens 24h" / "tokens all"), so external
spend is visible separately from local Ollama burn. Purely local and best-effort:
a failed append never affects the call it measures.
### Settings panel (`settings.json`)
The dashboard's Settings panel edits `settings.json` in the data dir: provider and
model per role, the OpenAI-compatible base URL, the remote-LLM opt-in, and the
display timezone (IANA name; timestamps default to the system timezone). Precedence
is **settings.json > env > default** everywhere, so a UI choice actually wins.
The API key is deliberately env-only (`SELF_IMPROVE_OPENAI_API_KEY`) — it is never
stored in or served from `settings.json`. Changes apply to hooks and CLIs
immediately (fresh processes); a long-running MCP server applies provider/base/opt-in
flips live but picks **model** changes up on restart. The settings POST only accepts
same-origin loopback JSON requests — a cross-origin page must not be able to
redirect extraction traffic.
## Tools
- `start_task`: automation hook for task start. Creates a session and recalls relevant memories (each prefixed with its id so you can echo `usedMemoryIds` back to `finish_task`).
- `begin_turn`: recall a concise context block for injection. `cwd` (when no `project` is given) scopes recall to the project named by its last path segment; the block ends with a `Recalled Memory IDs` manifest to echo back via `finish_task`.
- `finish_task`: automation hook for task end. Updates the session and stores durable learnings. Pass `usedMemoryIds` to credit memories that actually helped.
- `remember`: store any general memory. Always creates a `candidate`; the state is not a caller input.
- `validate_memory`: move a candidate memory to `validated` after evidence review. It is still not recalled.
- `promote_memory`: explicitly move a validated memory into `promoted`, making it eligible for recall.
- `deprecate_memory`: retire a memory into a downward terminal state (`deprecated`/`superseded`) so it is excluded from recall.
- `list_candidates`: inspect extracted memory candidates and validation records awaiting review.
- `accept_candidate`: rescue a gate-failed candidate by creating a `validated` memory from it (still needs `promote_memory` before recall).
- `recall`: retrieve relevant memories for a query.
- `self_reflect`: generate a concise reminder block before starting work.
- `record_failure`: backward-compatible helper for failure memories. Always creates a `candidate`; the state is not a caller input.
- `search_lessons`: backward-compatible lesson search.
- `list_recent_memories`: inspect recent memories.
- `list_recent_failures`: inspect recent failure memories.
- `export_graphify`: regenerate graph JSON.
- `sync_graphify`: run Graphify over a repo with `.memory/agent` notes, optionally targeting an Obsidian vault; pass `initProject: false` to skip project init.
- `process_pending`: drain the lazy derivation pipeline on demand (candidate extraction from pending checkpoints + correction scanning). Runs automatically at the start of `start_task`/`begin_turn`/`finish_task`; call this to force it.
- `memory_stats`: show store paths and counts.
## Automation Contract
MCP servers are callable tools; they do not automatically receive every message
from every harness. Automation comes from connecting the harness lifecycle to
these tools:
```text
On task start:
call start_task(task, project, harness, tags)
inject returned memories into the agent context
During work:
call remember when a durable preference, fact, decision, workflow, or tool note appears
leave new memories as candidate unless they have been validated
call validate_memory after checking evidence
call promote_memory only when the memory should affect future agent behavior
On task end/failure/interruption:
call finish_task(sessionId, task, outcome, learned, nextAction, status, usedMemoryIds)
```
If a harness cannot run hooks, put this rule in its persistent instructions:
```text
At the start of every task, call start_task.
At the end of every task, call finish_task.
Whenever a durable learning appears, call remember.
```
For harnesses with command hooks, call the same hook runner and pass the harness
name:
```powershell
node "~/plugins/self-improvement-memory/dist/hook.js" UserPromptSubmit claude
node "~/plugins/self-improvement-memory/dist/hook.js" PostToolUse claude
node "~/plugins/self-improvement-memory/dist/hook.js" Stop claude
```
The event name is the first argument and the harness name is the second (Codex
uses `codex`; Claude Code can use the same commands in its hooks settings). Each
event's JSON payload is read from stdin.
For local LLM scripts, wrap the agent command and invoke `hook.js` with a harness
name like `ollama-agent`, piping the event JSON to stdin. On a `UserPromptSubmit`
the runner reads the prompt text from a `prompt`/`message`/`input`/`text`/`command`
field (falling back to the raw stdin), and reads the harness session id from a
`session_id` (or `sessionId`) field to bind the recall echo. A harness whose
payload carries none of these still logs the event but cannot be recall-injected —
for such harnesses, drive `start_task`/`finish_task` directly instead.
The hook runner is a fail-open logger that **pulls, not pushes**: it records raw
events, and in `smart` mode a `UserPromptSubmit` runs a recall over the union of
promoted personal memories and the per-project repo-knowledge index. Instead of
printing the recall block, it writes the block to a context file under the data dir
and prints only a one-line pointer for the harness to inject; the worker follows
the pointer and appends the ids it used to an echo file (bounded to 3s; on timeout
or error it prints nothing and exits 0). See [`hooks/README.md`](hooks/README.md)
for the pointer/context/echo format and the usefulness-credit rules. Hooks never
create sessions or durable memories — sessions are agent-owned via `start_task`,
and durable memories require an explicit `remember`.
Before any event is persisted, its payload is sanitized: strings over 4000 chars
are truncated (commands over 1000), `tool_response` is summarized, and values
matching common credential shapes (`key`/`token`/`secret`/`password`/`bearer`
assignments, AWS `AKIA…` keys, GitHub `ghp_…` tokens) are masked with `***`.
This applies to every event kind, not just `PostToolUse`. **Secret masking is
best-effort defense in depth, not a guarantee** — do not rely on it to scrub
secrets. The first line of defense is keeping secrets out of prompts and terminal
output in the first place.
## Example General Memory
```json
{
"title": "Verify MCP SDK types before implementing tools",
"kind": "workflow",
"summary": "MCP SDK APIs move over time.",
"content": "Before coding against the SDK, inspect installed examples and d.ts files.",
"lesson": "Local installed types are more reliable than remembered SDK shape.",
"action": "Run a quick SDK type/example check before adding MCP tools or resources.",
"project": "memory-manager",
"harness": "codex",
"tags": ["mcp", "typescript", "sdk"],
"importance": "high"
}
```
## Example Failure Memory
`record_failure` stores structured failure context so the next agent knows what
to check before repeating the mistake:
```json
{
"task": "Edit files from a PowerShell session",
"symptom": "A Unix heredoc command failed in PowerShell.",
"rootCause": "The agent assumed Bash syntax would work unchanged.",
"failedAssumption": "The shell accepted Unix heredocs.",
"preventionRule": "When cwd shell is PowerShell, use PowerShell-native syntax or apply_patch.",
"verification": "Run the edited command in PowerShell.",
"affectedFiles": ["scripts/verify.mjs"],
"project": "memory-manager",
"harness": "codex",
"tags": ["windows", "powershell"],
"severity": "medium"
}
```
## Storage
By default the server writes to:
```text
~/.self-improvement-memory-mcp/memories.jsonl
~/.self-improvement-memory-mcp/sessions.jsonl
~/.self-improvement-memory-mcp/graphify/self-improvement-graph.json
```
Set `MEMORY_MANAGER_DATA_DIR` to choose a different primary store. Keeping the
primary store outside repositories avoids dirty worktrees from automatic hooks.
Each memory stores `embeddingModel`, `embeddingVersion`, and `embeddingDim`; recall
only compares vectors from the current compatible embedding shape.
Only `promoted` memories are recalled. Automatic candidate extraction can create
`validated` memories, but promotion is explicit.
Derivation is lazy. Hooks only append raw events and checkpoint markers; the
LLM work (candidate extraction and correction scanning) is drained by the MCP
server on the next `start_task`/`begin_turn`/`finish_task` call, or on demand via
`process_pending`. Progress offsets persist atomically in `pipeline-state.json`,
so drains are idempotent and never re-derive already-processed markers. Extraction
windows are bounded to one checkpoint's originating harness and cwd, so a shared
data dir never attributes a memory to the wrong project.
Corrections are non-destructive. When a later utterance corrects a memory, the
original `summary`/`content` are never overwritten (kept as evidence, so stored
embeddings stay truthful): the correction text is saved in a `correctionNote`
field and appended to `evidence`. A correction can only move a memory's state
**downward** (for example `promoted → deprecated`), never upward — promotion
stays explicit through `validate_memory`/`promote_memory`.
## Obsidian
Set `SELF_IMPROVE_OBSIDIAN_VAULT` to mirror each memory as a Markdown note.
Notes include frontmatter, tags, and wiki-links for project and harness nodes.
## Graphify
`export_graphify` writes:
```text
<graphify-dir>/self-improvement-graph.json
```
The graph contains:
- `agent-memory` nodes
- `kind` nodes
- `tag` nodes
- `project` nodes
- `harness` nodes
- `IS_KIND`, `TAGGED`, `IN_PROJECT`, and `IN_HARNESS` edges
This is intentionally simple JSON so Graphify or a bridge script can transform
it into the exact graph format you prefer.
`sync_graphify` also runs project-scoped `graphify install --project --platform
codex` when `AGENTS.md` or the Graphify Codex skill is missing. If semantic
extraction needs an LLM key, it falls back to `graphify update` for an AST-only
graph. Pass `initProject: false` to skip project init.
Repo-local `.memory/agent` Markdown notes are only written when a tool call
explicitly passes `repoDir`, such as `sync_graphify` or `remember({ repoDir })`.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues