Skip to content

About

No description, website, or topics provided.

Resources

Stars

143 stars

Watchers

2 watching

Forks

 
 

Latest commit

 

History

671 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memory Bank

Conversations → Knowledge Graph. Claude Code conversations become searchable, structured knowledge.

Memory Bank

What's New in v1.4.x

  • 🧾 Injection pipeline v2 — session dedup ledger (v1.4.0) — a fact is now injected at most once per session. Before: 74% inject rate × 5.5–8 facts × ~140 chars ≈ ~470 tokens per prompt, with the same facts re-injected across a session (~10k tokens per 30-prompt session). A bounded per-session ledger (400 ids, 7-day TTL, atomic writes, fail-open) filters already-injected facts; a repeated topic's 2nd occurrence injects 0 bytes (status:"deduped")
  • ✂️ Token budget — per-fact 160-char truncation + 1,000-char block budget (lowest-relevance facts dropped first), plus an elapsed-budget gate on repeated-prompt detection: its 313k-exchange vector search (p95 498ms) is synchronous and cannot be preempted mid-flight, so it is skipped entirely when injection has already spent >700ms
  • 📈 Savings are measured, not assumed — the inject log gains chars (block size) and deduped (facts saved) fields, so real-world token savings accumulate in observable JSONL
  • 🌌 Knowledge Galaxy (ui/relations/) — Three.js 3D visualization of the ontology: 32 domains / 4.2k categories / 24.7k facts / 27.8k typed relations as a navigable galaxy — fact search, per-type edge toggles (SUPPORTS/INFLUENCES/SUPERSEDES/CONTRADICTS), relation-navigating detail panel, adaptive performance (compositor-only labels, point-size cap, eco-mode DPR). node ui/relations/generate-data.mjs then serve statically — the data file stays local (personal facts, gitignored)
  • 🩹 Dependency self-heal (v1.4.2) — claude plugin update non-deterministically skips npm install for the new cache dir, and cc-sync ships plugin caches to other machines without node_modules. The dep-free injection thin client now detects ERR_MODULE_NOT_FOUND and spawns a one-shot detached npm install (atomic marker prevents loops), so a broken install heals itself on the first prompt
  • 📦 Packaging fix (v1.4.1) — v1.4.0 shipped a stale committed dist/; the release checklist now hard-checks git status dist/ is clean before tagging
  • Earlier releases: see CHANGELOG — v1.3.x added ontology backfill batching (~25×), headless LLM spawn isolation, the classification attempt ledger, vec-index self-heal, worker flood caps, and the warm inject daemon (~2.3s → ~0.07s per prompt)

Features

  • Knowledge Graph -- Ontology classification (Domain → Category) + typed relations (INFLUENCES, SUPPORTS, SUPERSEDES, CONTRADICTS)
  • RAG Search -- Search results auto-enriched with related facts and ontology context
  • Conversation Search -- Semantic vector search + FTS5 (BM25) full-text search across all past conversations
  • Full-History Analysis -- memory-bank analyze + analyzing-all-conversations skill: coverage-checked report over the entire conversation index (projects, facts, domains, timeline, backfill gaps) — run memory-bank sync first so new conversations are indexed
  • Context Injection -- Related past decisions are automatically prepended to every prompt (UserPromptSubmit hook): baseline-margin relevance gate + 1-hop ontology expansion + per-session dedup ledger and token budget (v1.4.0), with fail-loud JSONL observability logs
  • Fact Extraction -- Automatic extraction of decisions, preferences, patterns from conversations (trivial-exchange filtering, in-session dedup, confidence gating, LLM call budgeting)
  • Fact Consolidation -- Duplicate detection, contradiction handling, evolution tracking
  • Graph Traversal -- Multi-hop exploration (up to 3 hops) to trace decision chains
  • Cross-Project Insights -- Find similar decisions from other projects
  • Fact Provenance -- Trace any fact back to its source conversation
  • Scope Isolation -- Project facts stay in their project, global facts are shared
  • One shared server (v1.9.0) -- Sessions with the same settings use one MCP server process instead of one each (model, SQLite handle, injection daemon); every session keeps its own project scope — see Processes
  • User Tags -- The one labelling axis you control: free-form tags that the automatic pipeline never overwrites. Use them for review layers (verified), grouping that crosses project scope (billing), or case collection (bug-report). See the tagging guide
  • Compressed Archive Support -- Transparent .jsonl.zst reads across every path (parser, read tool, search, sync, stats, verify) using Node's built-in zstd (Node >= 22.15) — archives compressed out-of-band keep working
  • MCP Integration -- 11 tools: search, read, search_facts, search_ontology, ask_avatar, trace_fact, explore_graph, cross_project_insights, graph_stats, tag_fact, list_tags
  • 3D Visualization -- Interactive neon-style knowledge graph with data flow animation
  • Web UI -- Dark-theme web interface for browsing and searching conversations

How It Works

Data Pipeline

▲ Prompt Input       User messages, tool calls, assistant responses
│                    → JSONL archiving → embedding (384-dim)
│
◎ User Scope         LLM extracts facts (decisions, preferences, patterns)
│                    → global facts shared across all projects
│
● Project Scope      Facts scoped per project, clustered by domain
│                    → cross-project insights available
│
◇ Ontology           Auto-classified into domains & categories
                     → typed relations: INFLUENCES / SUPPORTS / SUPERSEDES / CONTRADICTS
                     → multi-hop graph traversal (up to 3 hops)
graph LR
    A[Session End] -->|sync| B[Parse JSONL]
    B --> C[Generate Embeddings]
    C --> D[SQLite + sqlite-vec]

    A -->|extract| E[Haiku LLM]
    E --> F[Facts]
    F -->|classify| G[Ontology]
    G -->|detect| H[Relations]

    I[Session Start] -->|consolidate| J[Vector Search]
    J --> K[Haiku LLM]
    K -->|merge/replace/evolve| F

    L[Query] -->|search| D
    L -->|RAG| F
    L -->|traverse| H

    M[User Prompt] -->|inject related facts 📌| F
Loading

Architecture

Install

In Claude Code:

/plugin marketplace add https://github.com/jung-wan-kim/memory-bank
/plugin install memory-bank

Update

/plugin update memory-bank

Quick Start

memory-bank sync      # Sync & index conversations
memory-bank search "React auth"  # Semantic search
memory-bank stats     # Index statistics
memory-bank analyze   # Full-history analysis report (coverage, projects, facts)

Context Injection

Every user prompt (≥20 chars) triggers the UserPromptSubmit hook, which vector-searches your facts and prepends relevant past decisions to the prompt:

📌 관련 과거 결정:
- [decision] Use keyset pagination for PostgREST list reads (2026-06-23)
- [SUPPORTS] [constraint] All tables require RLS policies, no exceptions (2026-05-18)
  • Relevance gate — a fact is injected only when its similarity to the query exceeds the query's own background baseline by a margin (absolute thresholds cannot separate relevant from irrelevant on compressed e5 scores)

  • 1-hop expansion — top matches pull in related facts via typed ontology relations (max 8 facts total)

  • Repository family scope (v1.7.8) — a prompt in a worktree (<repo>/.auto-issue-worktrees/…) or a sub-folder (<repo>/docs) also sees the project facts of the same repository, and the repository sees what was learned in worktrees placed inside its folder (a worktree placed outside it sees the repository, not the other way round). A path that no longer exists (a cwd or a fact's path) has no family — which repository a deleted path belonged to cannot be told from the disk — so facts learned in a worktree that has since been deleted no longer reach the family (a loss taken for isolation: none of the 83 lines the family added in the replay sample came from a deleted path). Inside a worktree container (<repo>/.claude/worktrees/, <repo>/.auto-issue-worktrees/) only the root's own linked worktrees count, for a fact's path and a cwd alike — a container can hold other repositories' worktrees, so a session opened in a plain folder there has no family; the container is that of the repository or worktree the path is in, its name compared case-insensitively on macOS (so on a case-sensitive volume a look-alike folder is left out — never pulled in). A Windows path has no family: the exact-path scope. A cwd that is a symbolic link or a file, or that has a symbolic link between it and its repository root (the root itself included), has no family (links above the root are not looked at — the scope is a path, as the exact-path scope always was), and a fact path through a symbolic link under a root is left out (facts are left out, never pulled in); a linked worktree whose main repository is named through a symbolic link joins nothing but itself. A slug-form project resolves to a path through the conversation index (the matching cwd, else the most used one) on both the vector search and the relation path, and gets that path's family; an unresolved slug has none. Worktrees of a bare repository kept in .bare/ (.bare/worktrees/…) are not grouped — each is its own family (a bare repository kept as <dir>/.git looks like any repository and is grouped). Roots come from .git on disk and must be a real repository (a .git folder holding HEAD, or a .git file naming an existing git dir; a linked worktree joins its main repository only when its gitdir back-reference matches); a home directory ($HOME or the account's own) and its ancestors never become a root; matching is on a / boundary, so <repo> never sees <repo>-extra, and never reaches into another repository nested under a root (a separate clone or a submodule). Chosen by the replay bench below; the SessionStart key-facts block uses the same predicate for its project facts

  • Session dedup ledger (v1.4.0) — a fact already injected in this session is never re-injected (it is already in the conversation context); repeated topics cost 0 extra tokens. Ledger is per-session, bounded (400 ids), TTL-pruned (7 days), and fail-open A context compaction clears that session's ledger (SessionStart compact hook → a "status":"ledger-reset" log line): the summary dropped those facts from the context, so they can be injected again.

  • Token budget (v1.4.0) — each fact is truncated to 160 chars and the whole block capped at 1,000 chars (lowest-relevance dropped first); repeated-prompt detection is skipped when injection has already spent >700ms (the sync sqlite search cannot be preempted once started)

  • Observability (v1.2.1, extended v1.4.0) — every run appends one JSONL line to ~/.config/superpowers/conversation-index/logs/inject-context.jsonl:

    {"ts":"2026-07-12T07:36:35Z","status":"injected","prompt_len":67,"candidates":5,"injected":8,"deduped":0,"chars":969,"duration_ms":528,"via":"fallback"}
    {"ts":"2026-07-12T07:36:41Z","status":"deduped","prompt_len":67,"candidates":5,"injected":0,"deduped":8,"duration_ms":476,"via":"fallback"}

    Since v1.7.8 a line also carries top_margins (each candidate's similarity minus the baseline), gated_ids (ids that cleared the gate before the session ledger), injected_ids, session_key (sha256 prefix of the session id) and plugin_version, and the SessionStart key-facts block writes its own "via":"session-start" line (count, chars, ids, source).

    Node-level crashes (missing node_modules, import failures) land in logs/inject-context.err.log instead of being discarded — the client's lines there carry the time and the plugin version, a cold fallback that dies while importing also writes a "status":"error" line to the JSONL log, and the file is rotated to .old at 1MB.

  • Native thin client (v1.7.9, optional) — when cargo is installed, SessionStart builds native/inject-client (Rust) once into ~/.config/superpowers/conversation-index/bin/ and the hook wrapper runs it instead of the node script whenever its recorded source hash equals the plugin's native/inject-client/SRC_HASH. It is the warm path of scripts/inject-context.js field for field (same stdout bytes, ledger, request keys and skipped-log fields). Measured on one machine: against an instantly answering fake daemon the client itself costs ~3.4ms where the node client needs ~75ms to start; against the real daemon the hook's end-to-end median was 32.5ms native vs 112ms node, of which the daemon's own search is ~17ms in both. When the daemon does not answer it hands the prompt to the node client with the reason in MEMORY_BANK_INJECT_DAEMON_FAILED and the same MEMORY_BANK_INJECT_REQ_ID. Without cargo nothing changes. Each log line now says which client asked (client_impl: native | node).

  • Deep config directory (v1.8.0) — the warm daemon listens on a unix socket inside conversation-index/, and a unix socket path is at most 103 bytes on macOS and 107 on Linux. When no socket name fits (the path of the folder that holds conversation-index/ is longer than 65 bytes on macOS or 69 on Linux — a deep MEMORY_BANK_CONFIG_DIR / XDG_CONFIG_HOME, a temp dir), the daemon is not started: the MCP server says inject daemon off: … once on stderr, and every prompt is injected by the hook's own computation — the slow path, which loads the embedding model in the hook process each time. Those log lines read "via":"fallback","fallback_reason":"socket-path-too-long". A shorter config directory turns the fast path back on.

Injection replay bench (v1.7.8) — replays prompts the hook really saw (inject log ∩ indexed conversation, as of each prompt's moment) through selection variants and has an isolated LLM judge score each injected line 0/1/2 against random-fact controls:

npm run build
node bench/inject-replay.mjs --build && node bench/inject-replay.mjs --replay && node bench/inject-replay.mjs --check-determinism
node bench/inject-judge.mjs --smoke && node bench/inject-judge.mjs --judge   # retires rows judged on other text first (--retire-stale), binds every row to its call at the end (--bind-legacy)
node bench/inject-judge.mjs --report --doc docs/bench/<date>-inject-replay.md && node bench/inject-judge.mjs --leak-check docs/bench/<date>-inject-replay.md

Prompt and fact text stay in .bench-out/; the report holds aggregates only. 2026-10-19 result (docs/bench/2026-10-19-inject-replay.md, 303 prompts): 55.4% of injected lines judged at least related, 20.5% directly useful; repository family scope kept (+0.126 directly useful lines per affected prompt, 95% CI 0.047–0.228), a query gate on relation neighbours rejected. The family gain came entirely from one repository (its main folder and linked worktrees) — by where the prompt's cwd was (not where the useful facts came from): prompts in worktrees placed inside the repository folder gained +12 directly useful lines, prompts in linked worktrees placed outside it +4, prompts in the repository folder itself 0; the other repositories' 22 affected prompts gained nothing and are too few to judge on their own.

Troubleshooting: if injection never fires, check those two files — an empty/absent JSONL log means the hook isn't running at all (stale plugin install, restart pending), while "status":"error" entries or err.log content pinpoint the failure.

Full-History Analysis

memory-bank analyze aggregates the entire conversation index into one report — deterministic, read-only, no LLM calls. It reports on what has been indexed into SQLite: archive files that were never synced are not visible to it. The SessionStart hook syncs in the background, but that runs asynchronously — when freshness matters, run memory-bank sync (foreground) and let it finish before analyzing.

memory-bank analyze                    # Markdown report to stdout
memory-bank analyze --json             # Raw JSON for scripting
memory-bank analyze --top 30 --out ~/report.md   # Top 30 projects, saved to file

The report covers:

Section Contents
Coverage Conversations (main sessions vs agent transcripts), sessions, exchanges, date range
Pipeline coverage Fact extraction done/pending %, summary done/missing %
Facts Active/inactive counts, by category, by scope
Knowledge domains Top ontology domains by fact count
Projects Per-project rollups: conversations, sessions, exchanges, facts, activity range
Timeline Monthly session/exchange activity
Recommendations Which backfills to run to close analysis gaps

The analyzing-all-conversations skill builds on this: it runs the analysis, kicks off backfill for unanalyzed sessions (scripts/backfill-extract-worker.js — lock-protected and resumable), then enriches the numbers with fact/ontology search into an organized report. Trigger it with requests like "모든 대화 분석", "analyze all my conversations".

Fact System

Facts are automatically extracted at session end and consolidated at session start.

Extraction quality/cost controls (v1.2.0):

  • Trivial exchanges (bare slash commands, harness artifacts, short acknowledgements) are filtered before any LLM call
  • Duplicate facts within a session are dropped across batches (normalized comparison)
  • Facts without a valid numeric confidence ≥ 0.7 are rejected
  • Long sessions cap the extraction batches with evenly-spread sampling (MEMORY_BANK_MAX_EXTRACT_CALLS, default 12, at most 60 — a larger value is read as 60). It bounds the batches, not every LLM call of a session: a batch whose call fails for a transient reason is tried again (3 attempts by default), and the ontology classification (one call per 20 stored facts) and relation check (one call per stored fact) come on top
Category Example
decision "Using Riverpod for state management"
preference "Named exports only"
pattern "Bug-fixer retries 3 times on error"
knowledge "API endpoints at /api/v2/"
constraint "No localStorage usage"

Consolidation Rules

Fact Lifecycle

Relation Action
DUPLICATE Keep the older fact; it takes the other's confirmation count and sources
CONTRADICTION The later fact replaces the older one + revision history
EVOLUTION The older fact takes the updated sentence (re-embedded) + revision history
INDEPENDENT Keep both

Each new fact is compared with its nearest fact in the same scope (similarity ≥ 0.95), at most 10 comparisons per session start. "Older" and "later" follow creation time, whichever of the two triggered the comparison.

When a run fails, the reason is appended to fact-consolidate.log in ~/.config/superpowers/conversation-index/ (worker: ERROR fact=… kind=… msg=…) and state/fact-consolidate-health.json there counts the failed runs in a row; after five, the next attempts are spaced out (5 minutes, doubling, up to 6 hours) until a run gets through. Three other lines in that log are not failures of a comparison: worker: WARN no_content_time=<n> … (the content-time column could not be created yet, so n pairs were ordered by creation time), worker: lock unavailable (…) — not started (the single-run lock could not be set up) and worker: fact_kr restore failed (…), which ends with whether the Korean-sentence restore is tried again on the next run or not repeated for this version.

Scope Isolation

graph TB
    subgraph "Project A"
        FA1[Fact: Use Riverpod]
        FA2[Fact: Flutter arch]
    end
    subgraph "Project B"
        FB1[Fact: Use Redux]
        FB2[Fact: React arch]
    end
    subgraph "Global"
        FG1[Fact: Named exports]
        FG2[Fact: Korean responses]
    end

    FG1 -.->|shared| FA1
    FG1 -.->|shared| FB1
    FA1 x--x FB1
Loading

Project A sees: Project A facts + Global facts (never Project B). Since v1.7.8 the per-prompt injection widens to Project A's repository family (see Context Injection): a worktree or sub-folder sees the repository's facts, and the repository sees what was learned in worktrees placed inside its folder — not those placed outside it (one-way); a different repository stays out.

MCP Tools

Tool Description
search Semantic + keyword search (at most limit results; date/agent filters; machine-generated turns left out unless include_noise) + related facts attached. An array of 2-5 concepts returns the conversations matching all of them, keyword and semantic matches in one ranking
read Read a conversation or a line range of it (streamed — any file size; 40,000 characters per call — the closing line names the values to continue with: startLine, and inside one long message also startChar (pass every value it names — startLine alone repeats that message); full: true shows tool inputs/results over 2,000 characters whole)
search_facts Query facts with ontology context + graph relations (category/agent/tag filters; identical sentences folded)
search_ontology Browse the ontology level by level: domains and category counts first, facts with a category filter (bounded output; category_offset lists a domain's categories past the first 200)
ask_avatar Ask your technical alter ego — answers grounded in past decisions (calls an LLM; a failed call — no login, a refusal, an outage — comes back as an error, isError)
trace_fact Trace a fact back to its source conversations
explore_graph Multi-hop graph traversal (1-3 hops) from any fact
cross_project_insights Find similar decisions from other projects
graph_stats Knowledge graph statistics and health
tag_fact Add, remove or replace the user tags of a fact
list_tags Browse user tags, or the facts carrying them

Parameters, limits and what each answer says when it is cut short: skills/remembering-conversations/MCP-TOOLS.md.

A search result's N% match is the cosine similarity of the embeddings, not a confidence: with this model even unrelated text scores about 85-89% and a strong hit about 90%. Compare the hits of one answer with each other; do not read "88%" as "relevant".

Knowledge Graph Tools

# Trace why a decision was made
trace_fact --query "state management" --limit 3

# Find how other projects solved auth
cross_project_insights --query "authentication" --current_project ./my-app

# Explore decision chains
explore_graph --query "database choice" --hops 3

Skills

Installed automatically with the plugin:

Skill When it triggers What it does
remembering-conversations "how should I...", "last time we...", stuck on a problem Dispatches the search agent over past conversations and returns synthesized findings
analyzing-all-conversations (new in v1.2.0) "모든 대화 분석", "대화내역 정리", "analyze all conversations" Runs memory-bank analyze, starts backfill for unanalyzed sessions, and produces an organized full-history report

Web UI

A cinematic dark-theme web interface for browsing and searching your conversation history.

Web UI

Features

  • Projects View -- Browse all projects grouped by category, sorted by latest/most/A-Z
  • Search -- Full-text search across all conversations
  • User Prompts -- Browse and search only user messages
  • Exchange Detail -- View full user/assistant messages with tool call history
  • Hue OS Publication -- Q&A-only personal mirror chat backed by the personal mirror artifacts in ~/.codex/personal-mirror

Run

node ui/server.cjs
# Listening on 127.0.0.1:3847 (this machine only)
# Memory Bank UI: http://localhost:3847
# Hue OS: http://localhost:3847/hue-os

Custom port:

PORT=8080 node ui/server.cjs

Local only. The dashboard serves whole conversations, tool inputs and facts with no login, so it listens on 127.0.0.1 and answers only same-origin requests made directly by a browser on this machine: it sends no CORS headers, and a request with another Host, another Origin, or proxy headers (X-Forwarded-For, …) gets 403. limit is capped at 200 rows per request and request bodies at 1 MB. To listen on another address set both MEMORY_BANK_UI_HOST and MEMORY_BANK_UI_TOKEN (16+ characters — without the token the server refuses to start). Every page and API then needs the token: Authorization: Bearer <token>, or open /?token=<token> once per browser (it becomes an HttpOnly cookie). Never point a tunnel or reverse proxy at this port — see the Hue OS public listener below. The Hue OS login limit and daily chat quota are counted per client address. On this port that is the address of the connection itself; with a token and a reverse proxy of your own in front, that is the proxy for everyone. MEMORY_BANK_UI_TRUST_PROXY=1 makes this port take the address from X-Forwarded-For instead — set it only when a proxy you run writes that header (otherwise the caller types it). The Hue OS public listener always reads it.

Note: Requires memory-bank sync to have been run at least once to populate the database. The Hue OS publication route (/hue-os, with /replacement-os kept as a compatibility alias) can still load from local Personal Mirror artifacts when the conversation database is unavailable. Chat defaults to local terminal CLIs instead of API keys: Claude via claude --print --model sonnet, GPT via codex exec --model gpt-5.5. Override with REPLACEMENT_OS_CLAUDE_COMMAND, REPLACEMENT_OS_CLAUDE_ARGS_JSON, REPLACEMENT_OS_GPT_COMMAND, or REPLACEMENT_OS_GPT_ARGS_JSON. If local terminal providers are unavailable, the route falls back to a deterministic safety-preserving response mode. Public sharing guardrails: /hue-os requires password login. Set REPLACEMENT_OS_ACCESS_PASSWORD yourself — there is no default; without it the login is off and the page says so. The login UI takes 4 digits and auto-submits; logins are refused after 5 wrong passwords per client address per minute, or 30 overall per 10 minutes (a 4-digit password is still only 10,000 values — the limit slows guessing, it does not make a public deployment strong). Each client IP gets 200 chat requests per local day (REPLACEMENT_OS_DAILY_LIMIT, reset at 00:00). The chat UI hides provider selection, disables Send during responses, shows an in-chat loading bar while Hue OS answers, and uses Esc to cancel an in-flight answer. Hue OS answer boundary: it refuses access/security-sensitive questions, including passwords, tokens, cookies, env values, server/tunnel URLs, auth bypasses, quota bypasses, and security-weakening instructions. Vercel sharing bridge: vercel/hue-os/ is a standalone Vercel project that proxies /api/hue-os/* to a public HTTPS tunnel for the Hue OS public listener of this server. Start the server with HUE_OS_PUBLIC_PORT=3848 (needs REPLACEMENT_OS_ACCESS_PASSWORD): that second loopback port serves the Hue OS chat routes only — no dashboard page and no conversation API exists on it. Point the tunnel at that port, never at the dashboard port, and set HUE_OS_LOCAL_ORIGIN to the tunnel origin so Claude/Codex subscription CLI auth stays local.

Claude Desktop Integration

Share Claude Code's memory with Claude Desktop by adding the MCP server:

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "memory-bank": {
      "command": "node",
      "args": ["/path/to/memory-bank/cli/mcp-server-wrapper.js"]
    }
  }
}

Replace /path/to/memory-bank with the actual plugin path (check ~/.claude/plugins/).

Claude Desktop will then have access to all your Claude Code conversations and extracted facts via the same search, read, and search_facts tools.

Configuration

# Fact extraction model (default: claude-haiku-5-5)
export MEMORY_BANK_FACT_MODEL=claude-haiku-5-5
export ANTHROPIC_API_KEY=your-key

# Summarization model
export MEMORY_BANK_API_MODEL=opus

# One MCP server shared by the sessions with the same server settings (default since 1.9.0).
# 0 / false / off / no = every session runs a server of its own, as before 1.9.0.
# An empty file conversation-index/shared-server.off does the same without touching
# the environment (see Architecture → Processes).
# export MEMORY_BANK_SHARED_SERVER=0
# How long a shared server with no session connected stays up (ms, default 600000).
# A server setting like any other: sessions that set it differently use different servers.
# export MEMORY_BANK_SHARED_IDLE_MS=600000

# Fact extraction batches per session (default 12, evenly spread; at most 60 — a
# larger value is read as 60, anything that is not a positive integer as 12).
# This is the number of batches, not of LLM calls: a batch that fails for a
# transient reason is retried (3 attempts by default), and the ontology
# classification and relation calls for the facts it stores are separate.
export MEMORY_BANK_MAX_EXTRACT_CALLS=12

# Decompression cap for .zst archives (bytes; lowering only, default 256 MiB)
export MEMORY_BANK_MAX_DECOMPRESSED_BYTES=268435456

# Ontology backfill worker (per-run caps; absolute ceilings apply regardless)
export BACKFILL_ONTOLOGY_MAX=200      # facts per run (ceiling 1000; 0 disables)
export BACKFILL_EXTRACT_MAX=40        # sessions per run (ceiling 200; 0 disables)
export BACKFILL_BATCH_SIZE=20         # facts per LLM call (ceiling 50)
export BACKFILL_CONCURRENCY=4         # concurrent batch calls (clamped to [1, 8])
export BACKFILL_RELATIONS=0           # 1 = also detect relations during backfill

# Backfill extraction waits for a session to go quiet: a session is picked up only
# when its last exchange is at least this many minutes old (default 60; 0 = no wait;
# above 10080 = 7 days, or not a number, means the default). Without the wait the
# backfill extracted sessions that were still in progress and marked them done.
# The price: a session that ended without its SessionEnd hook (killed) is
# extracted that much later.
export BACKFILL_QUIET_MINUTES=60

# Deterministic category-reuse gate (DISABLED by default — live measurement
# showed only 72% top-1 agreement at sim>=0.93; opt in after re-measuring
# with scripts/measure-det-gate.mjs)
# export MEMORY_BANK_ONTOLOGY_DET_GATE=0.94

# Session-start maintenance (pending-work probes + fact-vector compaction):
# at most once per this many minutes (default 360; 0 = every session start).
# A run where a step failed retries after 60 minutes instead.
# Each run is logged to ~/.config/superpowers/conversation-index/logs/maintenance.jsonl
export MEMORY_BANK_MAINTENANCE_INTERVAL_MIN=360

# Node binary for hooks when the default `node` was built for a different ABI
# than the installed better-sqlite3 (error: "NODE_MODULE_VERSION … requires …").
# Hooks find a matching node on PATH / Homebrew / nvm / volta / fnm / asdf on their own;
# set this only when none is found.
# export MEMORY_BANK_NODE=/opt/homebrew/opt/node@22/bin/node

# Time budget (ms) of the UserPromptSubmit injection hook, used to bound that
# re-run. Default 30000 = Claude Code's default for this hook; set it to match
# if you give the hook a different timeout. hooks.json states the same 30s as the
# hook's `timeout`. A cold fallback is started only when enough of the budget is
# left, and stops itself (one log line) when it runs out.
# export MEMORY_BANK_INJECT_HOOK_BUDGET_MS=30000

# Injection switches — unset (the default) nothing changes. The hook reads them
# itself, before it asks the daemon, so the hook's environment is enough:
# settings.json "env", the shell the session starts from, or one run only
# (`MEMORY_BANK_INJECT_HEADLESS=0 claude -p …`). They do not have to be visible
# to the MCP server (the daemon that answers may belong to another session).
#   no injection for `claude -p` / Agent SDK sessions (CLAUDE_CODE_ENTRYPOINT sdk-*):
# export MEMORY_BANK_INJECT_HEADLESS=0
#   no injection for Codex prompts (Codex sends no interactive/headless marker — all or none):
# export MEMORY_BANK_INJECT_CODEX=0
#   when the warm daemon is there but has not answered in 3s, skip the cold
#   recomputation (the prompt goes on without injected context; logged as skipped):
# export MEMORY_BANK_INJECT_COLD_ON_TIMEOUT=0

# Session-start "Project Key Facts": project facts come first, then at most this
# many global facts (default 3; 0 = project facts only).
# export MEMORY_BANK_KEY_FACTS_GLOBAL_MAX=3

# Session-start version check: besides the plugin cache and the marketplace clone it
# asks the upstream repository for release tags (git ls-remote, at most once a day,
# 3s limit; a failed check is logged as unknown, never as "up to date").
# `off` = never ask; any other value = the repository to ask instead.
# export MEMORY_BANK_DRIFT_REMOTE=off

# Native inject client (v1.7.9): binary path the hook wrapper runs when its .srchash
# matches the plugin's SRC_HASH (default below); mmap window of the search connection
# in bytes (used only for reads; 0 = off; default 256MB).
# export MEMORY_BANK_NATIVE_CLIENT=~/.config/superpowers/conversation-index/bin/memory-bank-inject-client
# export MEMORY_BANK_SQLITE_MMAP_BYTES=268435456

Maintenance scripts (run by hand, never automatically):

node scripts/compact-vec-tables.mjs [--db PATH] [--min-ratio 0.8] [--dry-run]   # drop deleted slots from the fact vector tables
node scripts/migrate-vec-facts-int8.mjs --dry-run                              # fact vectors float32 → int8 (scale 600); see the script header
node scripts/migrate-vec-facts-int8.mjs --restore BACKUP.jsonl.gz              # back to float32 from its verified backup
node scripts/reembed-rewritten-facts.mjs [--db PATH]                           # dry run: facts whose vector still describes a sentence consolidation rewrote (≤1.7.9); see the script header for --apply
node scripts/dedupe-exact-facts.mjs [--db PATH] [--list]                       # dry run: same-scope facts with the same sentence; see the script header for --apply
node scripts/redact-secret-facts.mjs [--db PATH]                               # dry run: stored facts that carry a credential-shaped string (id and kind only) — run once after upgrading from ≤1.7.9
node scripts/requeue-zero-markers.mjs [--db PATH]                              # dry run: sessions marked "done, 0 facts" before they were indexed; --apply --limit N puts them back in the extraction queue (LLM calls)

The cleanup scripts default to a dry run, change rows only with --apply, and can be put back (--undo FILE / --restore TABLE): docs/index-maintenance.md.

3D Knowledge Graph

Interactive visualization of the full knowledge graph with neon-style nodes and data flow animation.

Knowledge Graph

open docs/graph-3d.html   # Interactive 3D graph (local)

4 layers: Prompt Input → User Scope → Project Scope → Ontology, with animated particles showing data flow direction.

Architecture

~/.config/superpowers/
├── conversation-archive/       # Archived JSONL files (plain or .jsonl.zst — read transparently)
└── conversation-index/
    └── db.sqlite               # SQLite + sqlite-vec
        ├── exchanges           # Conversation data + embeddings
        ├── tool_calls          # Tool usage records
        ├── facts               # Extracted facts + embeddings
        ├── fact_revisions      # Change history
        ├── ontology_domains    # Domain hierarchy
        ├── ontology_categories # Category classification
        ├── ontology_relations  # Typed fact relations
        ├── vec_exchanges       # Vector index (384-dim)
        └── vec_facts           # Vector index (384-dim)

conversation-index/sync/ is the cross-device sync folder (facts and the knowledge graph as JSONL files, written when a session ends and imported when one starts): whoever can write to it can decide sentences that are later injected into your prompts as your own past decisions, so do not share that folder with a device, account or cloud location you do not trust.

Processes (v1.9.0)

A session starts cli/mcp-server-wrapper.js, and that starts dist/mcp-server.js — a small relay that loads no database and no model. The tools run in one shared server (dist/shared-server.js) that every session with the same server settings uses together, over a unix socket in conversation-index/ (mb-shared-<version>-<id>.sock, owner-only). Before 1.9.0 every session ran a whole server of its own; with N sessions open that was N embedding models and N injection daemons.

Claude Code ⇄ wrapper ⇄ relay (dist/mcp-server.js) ─┐
Claude Code ⇄ wrapper ⇄ relay                       ─┼─ unix socket ─ shared server (dist/shared-server.js) ─ db.sqlite
Claude Code ⇄ wrapper ⇄ relay                       ─┘                 one per (version, code, server settings)
  • Nothing of one session reaches another. A connection states its working directory before anything else, and a tool's default project is the directory of the session that calls — the server never reads its own. A session that cannot tell its directory still connects; a call that needs the default then fails with a message asking for project, it is never answered for "every project". A relative path given to read is resolved against the calling session's directory as well.
  • A server is named by its own settings. A server's name is a hash of the plugin version, the compiled code and the settings the server code itself reads (config dir, database path, embedding model, time zone, proxy, …), and it is started with those settings only — no session id, no messaging socket, nothing else from the shell that started the first session. A session whose server settings differ gets a server of its own.
  • What belongs to one session travels with its connection. The account, endpoint, model and client options of the LLM call ask_avatar makes, and the locale that dates, numbers and name order are written in, are not part of the server's name and never enter the server's own environment. A session declares them when it connects, and the server uses them for that session's calls only. So sessions that are logged in differently, or run under different locales, still share one server — and each gets its own account and its own formatting.
  • Lifetime. A server no session is connected to ends after 10 minutes (MEMORY_BANK_SHARED_IDLE_MS; prompt-injection requests do not keep it alive). After a plugin update it serves the sessions it has and then ends, while those sessions move to the new version's server on their own. When a server dies, every relay reconnects — starting a new server if there is none — and the session goes on; only a call that was in flight is answered with an error. A server that keeps ending right after it starts is not restarted in a tight loop: from the second such loss in a row a relay waits 2 s, 4 s, … up to 30 s before the next start, and answers the calls that arrive meanwhile with the reason at once.
  • When a server cannot be started nothing is done quietly instead: a relay that has just begun exits non-zero (the wrapper then repairs the install, as it always did for a server that dies at once), and a relay that has been serving answers each call with an error that names conversation-index/logs/shared-server.log, and keeps trying, less and less often. The same holds when some other process answers on the server's socket name, and for an install that lacks the compiled server or a readable version: the session exits non-zero and says what is missing — it does not quietly run a server of its own.
  • Turning it off. MEMORY_BANK_SHARED_SERVER=0, or an empty file conversation-index/shared-server.off, makes a session run a server of its own again, exactly as before 1.9.0. The file is for sessions that are already open: it is read when a session's relay starts, so it applies to new sessions and to an open one the next time the wrapper restarts its child. The same happens by itself in four cases: on Windows, in a run from source (tsx — there is no compiled server to start), where the config dir path is too long for a unix socket, and in a session that cannot read its own working directory while a path setting is relative. The session says which, in one line on stderr.

Development

npm install
npm test            # works on a fresh clone: dist/ is committed (the first run downloads the embedding model, ~130 MB)

# after changing anything under src/
npm run build       # tsc + the MCP server bundle — commit the regenerated dist/
npm test

npm test does not build. Its first step (pretest, scripts/check-dist-fresh.mjs) fails with "dist is stale — run npm run build first" when dist/ is not a build of the current sources, and writes nothing. Compiled files are compared byte for byte. The bundle dist/mcp-server.js inlines third-party packages whose versions differ from one npm install to the next (there is no lock file), so it is judged by the stamp npm run build writes on its last line — a digest of the sources, bundle arguments and dependency ranges it was built from — not by its bytes.

Build the dist/ you commit in a checkout that has its own node_modules. Where node_modules is a symlink to another directory (a git worktree sharing the main checkout's install), the bundle names every inlined module by a path outside the project and so carries that machine's directory names: the build warns, and npm test refuses that bundle. npx vitest run still runs the tests on it.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

143 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages