# Repository Briefing: yb-zhai/agent-memory
> Source: https://repoforai.com/repo/yb-zhai/agent-memory (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/yb-zhai/agent-memory
- **Category**: RAG, Data & Memory (知识库 / 爬虫 / 记忆层)
- **Primary Language**: JavaScript
- **License**: MIT
- **Engineering Health**: A+ (90/100 · Maintenance 35/35 · Adoption 15/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v2.8.1 (2026-12-01) — https://github.com/yb-zhai/agent-memory/releases
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: MCP, Self-Hosted, Local AI
- **Momentum**: 81 ★ total (+4 24h / +19 7d) · 16 forks
- **Topics**: `dsh-plugin`
- **When to Use**: Best for: Personal assistants and single-machine agent workflows that need cross-session text memory, offline recall, and a way to inspect why results ranked. Skip if: You need a transactional shared store, concurrent writers, cross-device sync, native multimodal indexing, or strong paraphrase recall without operating a semantic backend.

## Overview
```text
### Architecture & Core Mechanics
Nebula Memory is an embeddable agent memory engine, not a general-purpose database. Its core, exposed by `memory/index.mjs`, runs on Node.js without external runtime dependencies and persists text in local JSONL. Recall combines four signals: TF-IDF lexical matching, activation with time decay, graph propagation, and user profiles. The thin index stores metadata, term frequencies, and byte offsets, so the engine can defer reading full text until it needs it.

The standalone `server.js` and DeepSeek Harness (DSH) plugin expose the panel and can query an optional Hindsight HTTP backend alongside local recall. Reciprocal rank fusion (RRF) merges the two ranked lists. On those surfaces, local recall stays enabled and continues to serve queries if Hindsight becomes unavailable. The standalone MCP package exposes the local engine without the panel or Hindsight.

### Key Capabilities & Differentiators
Writes redact recognized secrets and personal identifiers before term counting and split text beyond the 2,000-character item limit into linked chunks that can be grouped by `docId`. Memories pinned with `importance=1.0` avoid time decay. Rule-based contradiction handling marks older claims as `superseded` on recognized polarity reversals and excludes them from default recall without deleting them. Background maintenance can prune edges, archive low-value chatter, and compact storage without model calls.

The 3D panel shows memory links and recall traces, updates via SSE, and lets users inspect ranking contributions. MCP also provides `explain_recall`. Optional pinyin indexing adds full-pinyin, initial-letter, and fuzzy pronunciation matches for Chinese text. On a compacted corpus of 23.8k nodes and 41.4k edges, the project benchmark measured about 13 ms median local recall and 31 ms median MCP end-to-end latency; the timings apply to that snapshot, not every corpus.

### Trade-offs & Limitations
The local engine trades semantic reach for a simple offline deployment: graph and profile signals can improve retrieval, but weak lexical overlap can still defeat queries. Hindsight targets paraphrases and older history at the cost of another service, PostgreSQL, and an LLM backend. In the scale test, median recall rose to 319 ms at 100,000 entries and 1.75 s at 500,000; candidate scoring was the bottleneck. Test against a representative corpus before relying on the smaller-bank latency figures.

Plaintext JSONL is easy to inspect and back up, but the local store is a single-writer design without transactions, tenant isolation, or cross-device conflict resolution. `watchExternalWrites` lets other local processes pick up fresh rows; it does not coordinate writers. LangChain Memory fits a Python-first application more naturally, while a managed offering such as Mem0 or Zep is worth evaluating when cross-device access and team controls matter. For sensitive deployments, restrict file access and review what leaves the machine through Hindsight or prompts sent to a remote model.

### Hardware & Deployment Guide
Start with Node.js and a writable data directory. Embed `NebulaMemory` for an application-controlled integration, run `node server.js` for the HTTP service and panel on port 8898, or use `npx nebula-memory-mcp` for a compatible client. DSH desktop users can install the full plugin with `dsh plugin --profile desktop add github:yb-zhai/agent-memory`; the profile must match the active installation. The engine can run offline once installed. The MCP package and DSH plugin have separate release lines.

For hybrid recall, provision Hindsight with PostgreSQL and an LLM backend, set `hindsightUrl` and a `hindsightKey` if needed, and check `/healthz` for `local` or `hybrid` mode. The plugin probes backend readiness every 30 seconds and falls back to local recall if checks fail. v2.7.1 bounded deduplication candidates and made snapshot writes tolerant of certain concurrent failures; v2.8.0 introduced optional pinyin search, and v2.8.1 reduced its persisted index footprint.
```

## Key Capabilities
```text
- Local ranking: TF-IDF, activation, graph propagation, and profile signals run without an LLM or vector database.
- Storage and startup: `index.thin.json` keeps metadata, term frequencies, and byte offsets so full text can be loaded on demand.
- Recall inspection: The panel offers live SSE updates and score breakdowns; MCP exposes `explain_recall`.
- Memory lifecycle: Writes support pattern-based redaction and linked text chunks; superseded facts remain available for historical recall.
- Chinese search: Optional `pinyinIndex` supports full pinyin, initials, and fuzzy pronunciation matches.
- Hybrid retrieval: Reciprocal rank fusion combines local and Hindsight candidates, with local recall retained on backend failure.
```

## Quick Start / Clone
```bash
npm run check:downstream          # 列出每个下游与上游的文件差异
npm run check:downstream:strict   # 有漂移就 exit 1（发版前务必跑）
```
