Long-term RAG memory for DSH agents with cloud, local Ollama, and offline BM25 keyword modes. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-memory-rag
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:Aonysen/dsh-memory-rag
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
Semantic memory for DeepSeek Harness: memories live in a local vector store and are retrieved on demand instead of being pasted into the system prompt.
Works with any OpenAI-compatible embeddings endpoint: Qwen (China/international), SiliconFlow, OpenAI, local Ollama, or a fully custom endpoint. A fully offline BM25 keyword mode is included for when you want no network and no model at all.
Features
rag_search— natural-language search over stored memories, returning snippets with ids and scores;rag_remember— store one reusable fact (embedded immediately, searchable right away);rag_ingest— chunk and import.md/.mdx/.txtfiles or directories (idempotent, skips duplicates);rag_forget/rag_stats— delete and inspect;- Session index injection — at session start the prompt gets a locally rendered index (pinned notes, recent project notes, file groups). No network call, stable across turns;
- Settings page — provider, API key, model/dimensions, retrieval parameters, connection test, model listing, memory browser;
- Memory insights page — first-level sidebar panel with KPIs, daily additions, composition, tags, recent writes, storage and a 56-day activity heatmap.
Install
From npm (after the npm release, recommended):
dsh plugin add dsh-memory-rag
From GitHub (works today; installs the main branch):
dsh plugin add github:Aonysen/dsh-memory-rag
From the DSH UI: sidebar → Plugins → Add plugin, then paste dsh-memory-rag or github:Aonysen/dsh-memory-rag (a local directory path also works while developing).
From the plugin market: sidebar → Plugins → Discover, search for memory, and use the install action on the card.
Restart the DSH desktop app after installing, reload the page, then open Settings → RAG Memory.
Upgrading from the pre-release
dsh-rag-memorypackage: remove it (dsh plugin --profile <name> remove dsh-rag-memory), installdsh-memory-rag, and restart. The data directory is unchanged, so memories and the API key carry over.
Providers
| id | Endpoint | Default model | Key env var |
|---|---|---|---|
qwen-cn |
https://dashscope.aliyuncs.com/compatible-mode/v1 |
text-embedding-v4 |
DASHSCOPE_API_KEY |
qwen-intl |
https://dashscope-intl.aliyuncs.com/compatible-mode/v1 |
text-embedding-v4 |
DASHSCOPE_API_KEY |
siliconflow |
https://api.siliconflow.cn/v1 |
BAAI/bge-m3 |
SILICONFLOW_API_KEY |
openai |
https://api.openai.com/v1 |
text-embedding-3-small |
OPENAI_API_KEY |
ollama |
http://127.0.0.1:11434/v1 |
nomic-embed-text |
optional |
custom |
your own | your own | EMBEDDING_API_KEY |
keyword |
no endpoint | bm25 (no vectors) |
none |
One store is bound to one model + dimension. Changing either requires an empty store (the settings page refuses otherwise).
Fully local (no cloud API)
Two options:
- Local Ollama (best recall, still local inference)
- Install Ollama and pull an embedding model:
ollama pull bge-m3(1024 dims) orollama pull nomic-embed-text(768 dims); - Pick the Ollama provider, keep
http://127.0.0.1:11434/v1, select the model; - No API key required (
keyOptional, no auth header is sent).
- Install Ollama and pull an embedding model:
- Local keyword (BM25) (zero dependencies, zero downloads, works offline)
- Pick the keyword provider; no endpoint, no model, no key;
- Great for proper nouns, exact phrases and code identifiers; weaker on paraphrase than vector mode.
Switching from vector to keyword mode does not require clearing the store (keyword mode reads text only); switching back does.
Settings
- Endpoint: provider preset, base URL, effective
/embeddingsURL. - API key: paste / clear / status and source; the API never reads the key back.
- Model: preset dropdowns, or free text plus "List models" for custom endpoints.
- Retrieval: topK, minimum score, index character cap, inject-index toggle.
- Status: mode, endpoint, notes/doc chunks/project/global/pinned distribution, storage sizes, revision, write lock, tokens, tags, last five writes; auto-refreshes every 10 seconds.
- Memory browser: keyword search, paging, pin/unpin, delete.
Values persist to <dataDir>/settings.json and take precedence over cordis.patch.yml; changes apply immediately.
Memory insights page
A first-level sidebar panel (sidebar.panellist entry backed by the main keyed slot) laid out like the dsh-context insights page:
- six KPI tiles: memories / notes / doc chunks / project / global / pinned;
- daily additions bar chart (7 / 30 / 90 days);
- composition donut (notes vs doc chunks);
- scope progress bars and tag distribution bars;
- last 10 writes, storage breakdown, 56-day activity heatmap.
Data comes from GET /dsh-memory-rag/api/dashboard?days=7|30|90, derived purely from local entry timestamps — no network, no API key required.
Key sources (resolved per request)
- Environment variable (provider default, e.g.
DASHSCOPE_API_KEY); - DSH credentials service, when the host provides one;
<dataDir>/api-key(written by the settings page; mode 600 on POSIX, best-efforticaclsrestriction on Windows).
Saving prefers the DSH credentials service (keyStorage: auto) and falls back to the file. The file is plaintext — use the environment variable or the credentials service where that matters.
Configuration
- id: dsh-memory-rag
name: dsh-memory-rag
config:
provider: qwen-cn
baseUrl: https://dashscope.aliyuncs.com/compatible-mode/v1
embeddingModel: text-embedding-v4
dimensions: 1024
topK: 5
minScore: 0.25
injectIndex: true
maxInjectChars: 1200
maxChunksPerIngest: 500
requestTimeoutMs: 20000
memoryDir: null # null → <DSH_HOME>/memories/dsh-rag-memory
lockWaitMs: 100 # sync wait before StoreBusyError (tool layer retries async)
ingestDeny: ['~/.ssh', '~/.aws', '~/.gnupg', '%APPDATA%', 'C:\\Windows']
ingestRoots: [] # when non-empty, only these roots may be ingested
ingestOutsideCwd: warn # warn | deny | allow
keyStorage: auto # auto (prefer credentials) | file | credentials
largeStoreWarning: 20000
Data and privacy
<DSH_HOME>/memories/dsh-rag-memory/:index.jsonl,meta.json,settings.json,api-key.- Only text you explicitly remember or ingest is sent to the embedding endpoint; retrieval and ranking stay local.
rag_ingestreads local files (.md/.mdx/.txtonly) and, in vector modes, sends those chunks to the embedding endpoint. Sensitive directories iningestDenyare refused by default; paths outside the working directory produce a warning (configurable todeny).- Upgrading from the old
dsh-qwen-ragcopies its data on first start (originals are kept).
Concurrency and multiple processes
Short version: use one writer per store, but concurrent writes no longer lose records.
- The write lock (
.write.lock) serialises writers; a lock older than 30s is reclaimed. - Every write re-stats and reloads the index first (
refreshIfChanged), and compaction does the same — so process A cannot overwrite process B's just-written records with a stale in-memory view. - Reads (search/list/stats) also check the file stamp, so the desktop sees CLI writes without a restart.
- The synchronous lock wait defaults to 100ms; on contention the tool layer retries asynchronously (~2.5s budget) before reporting "store busy".
- The lock prevents interleaved writes, not transactions. After a large CLI write, restarting the desktop gives the cleanest view.
Scale and limits
- Retrieval is an exact full scan (O(N × dimensions) dot products), no ANN index. Measured locally (1024 dims, average of 20 queries):
| Entries | Vector search | BM25 search | Extra heap |
|---|---|---|---|
| 1,000 | 3.5 ms | 0.9 ms | ≈2 MB |
| 5,000 | 16.3 ms | 2.8 ms | ≈39 MB |
| 20,000 | 55.8 ms | 17.6 ms | ≈94 MB |
- Recommended ceiling: ≤ 5,000 entries. Above
largeStoreWarning(default 20,000)rag_statswarns. For 100k+ chunks use a dedicated vector database. - Reproduce with
node --expose-gc scripts/bench-search.mjs.
Settings API (scripts / advanced)
GET /dsh-memory-rag/api/settings settings + key status + store stats
POST /dsh-memory-rag/api/settings apply a settings patch
POST /dsh-memory-rag/api/key write the key { key }
DELETE /dsh-memory-rag/api/key clear the key
POST /dsh-memory-rag/api/test verify the endpoint with a real request
GET /dsh-memory-rag/api/models list endpoint models
GET /dsh-memory-rag/api/status runtime snapshot (no network)
GET /dsh-memory-rag/api/memories memory list ?query=&limit=&offset=
POST /dsh-memory-rag/api/memories/update pin/unpin/delete { id, action }
GET /dsh-memory-rag/api/dashboard insights snapshot ?days=7|30|90
Troubleshooting
| Symptom | Fix |
|---|---|
| Missing API key | Paste it in Settings, or set the env var and restart |
| 401 | Wrong key, service not enabled, or key/site mismatch |
| 403 | Key lacks the model permission |
| 404 | Base URL is not OpenAI-compatible (usually ends with /v1) |
| 429 | Retried twice already; lower maxChunksPerIngest or retry later |
| Dimension mismatch | Clear the store and re-ingest after changing model/dimensions |
Failed to fetch in Settings |
Desktop pages load from dsh-app:// (cross-origin): restart the host after upgrading and reload |
| "Store busy" | Another DSH process is writing; the tool layer already retried for ~2.5s — retry shortly (lock expires after 30s) |
rag_ingest refuses the path |
It matched ingestDeny; adjust the list in cordis.patch.yml if you really need it |
| Insights panel missing | Restart the host and reload the page; the panel is a client module registered at boot |
Development
node --test # 104 offline unit tests
node scripts/smoke-embed.mjs # live smoke test (needs a key)
node --expose-gc scripts/bench-search.mjs # retrieval benchmark
npm pack --dry-run # verify published contents
License
Apache-2.0
Links
More in this category
vectorize-io/hindsight#coding-agents★ 63857
Hindsight, agent memory that learns: long-term project memory with auto recall and retain, knowledge pages, deep reflection, and per-repo memory banks.
volcengine/OpenViking#examples/dsh-memory-plugin★ 42946
OpenViking memory and context bundle for DeepSeek Harness: pre-step auto-recall and profile injection, session capture, `viking://` URI guarding, and recall/write memory tools backed by an OpenViking server.
MemTensor/MemOS#memos-local-plugin★ 12527
Local-first memory plugin for DeepSeek Harness: layered L1/L2/L3 memory with automatic capture, manual memos_* retrieval tools, and a built-in memory viewer.
agentscope-ai/ReMe#dsh★ 3860
Connects DeepSeek Harness to ReMe's local-first, self-evolving personal knowledge base: automatically captures completed main-agent conversations as user-owned Markdown memory, searches conversations and source material through reme_search with BM25, optional embeddings, and wikilink expansion, and schedules daily memory consolidation.
zilliztech/memsearch#MemSearch★ 2956
Shared Markdown memory for DSH and other coding agents, with automatic capture, pre-step context injection, searchable recall, and memory-to-skill self-evolution through a review panel.
vshulcz/deja-vu#extensions/dsh★ 1686
Cross-session memory and context recovery across forty-five other coding agents (45+) on this machine, reading session files they already wrote before install (Claude Code, Codex, Cursor, Windsurf, Trae, Antigravity, VS Code Copilot Chat, opencode, OpenClaw, Hermes, Kimi, Qoder, Cline, Zed, Magpie and more): six tools (deja_recall, deja_session, deja_blame, deja_fix, deja_how, deja_remember), a /deja command, and optional automatic recall injected into runtime context. Local BM25 CLI/MCP index, no LLM, no embeddings, no network (dsh plugin --profile web add dsh-deja).
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.