All-in-one memory and context compression for DSH: a cross-session memory client (fork of ArvinQi/dsh-octop-memory, atom-only recall against octop-memory) bundled with in-session context compression (mounts billion-context). Ships its own recall/capture behaviour with recallCorpus defaulting to atom so raw-conversation noise stays out, and composes both layers in one patch — one install restores the whole stack on a new device.
Install
# from a prebuilt release tarball
dsh plugin --profile web add -w "https://github.com/zhou200310/dsh-memory/releases/download/v0.1.0/dsh-memory-0.1.0.tgz"
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:zhou200310/dsh-memory
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
This plugin publishes its README in Chinese only.
DSH 的「记忆 + 上下文压缩」all-in-one 插件:一个包装齐跨会话长期记忆(octop-memory)与会话内上下文压缩(billion-context)。换设备后从插件市场一条命令下载,再跑一次后端安装脚本即可恢复全部能力。
记忆客户端 fork 自 ArvinQi/dsh-octop-memory(MIT),默认召回改为
atom;压缩层通过挂载 ranxianglei/billion-context(MIT)的 entry 实现。
一句话原理
| 层 | 干什么 | 实现 |
|---|---|---|
| 记忆 | 跨会话长期记忆:每轮开始前召回相关原子记忆注入,轮末把对话增量上报 | dsh-memory entry(fork dsh-octop-memory)调 octop-memory serve |
| 压缩 | 会话内上下文压缩:上下文超限时自动折叠已消费的历史 | 挂载 billion-context 的 bili-native + bili-compaction-gate |
| 后端 | 记忆后端 + 压缩 proxy | octop-memory serve(systemd)+ bili proxy(自动 spawn) |
安装
dsh plugin --profile web add https://github.com/zhou200310/dsh-memory/releases/download/v0.1.0/dsh-memory-0.1.0.tgz
装完在 profile 的 cordis.patch.yml 里补上后端地址与 token(同 id 覆盖):
- id: dsh-memory
config:
endpoint: http://127.0.0.1:8790/mcp/
token: omcp_xxx
tokenHeader: Authorization
记忆和压缩都是 profile 级注册,对所有 preset 生效,不需要再去 patch 那个手抄的「记忆共享模式」preset。
换设备 / 全新部署(三步)
1. 装插件(上面那条 install 命令)。
2. 装记忆后端(octop-memory serve):
bash scripts/install-backend.sh
脚本会:装 uv → 装 CPython 3.12 → 建 venv → 装 octop-memory[server] → 注册 octop-memory.service(127.0.0.1:8790)→ 写 ~/.octop-memory/config.json 模板。幂等,可重跑。
3. 配 LLM(提炼用,不配则记忆只存不提炼):编辑 ~/.octop-memory/config.json 的 llm 块,填 endpoint / model / api_key。提炼推荐 reasoning 模型并加 "extra_body": {"thinking": {"type": "disabled"}}(否则 reasoning 会吃掉 max_tokens 导致 JSON 截断)。
建空间 + 签 token(一次):
octop-memory auth code --all --ttl 3600 # 生成 mcode_
# 用 mcode_ 换 session 后:
# POST /api/admin/spaces {"space_id":"dsh"}
# POST /api/admin/spaces/dsh/tokens {"client_name":"dsh","scopes":["read","write"]}
把返回的 omcp_ token 填进第 1 步的 config 即可。
记忆层(fork dsh-octop-memory)
- 召回:
agent/pre-step,每轮第一个 step 拿到新 user message 后关键词扇出查memory_search,命中则作为带 source 的 user message 注入本轮(与内置 time-context 同构)。 - 上报:
session/event的turn/end,收集该轮 user/assistant 文本 POSTmemory_capture,按 turn 去重、按 session 幂等。 - 认证:用户级 token,随
Authorization: Bearer <token>发送;token 在服务端已绑专家,客户端不传任何身份头。
配置
| 键 | 默认 | 说明 |
|---|---|---|
endpoint |
'' |
octop-memory serve 地址(要带 /mcp/,如 http://127.0.0.1:8790/mcp/) |
token |
'' |
omcp_ 开头的用户级 token |
recallCorpus |
atom |
召回范围:atom 只召回精炼原子记忆(推荐),all 含原始对话(噪声大) |
recallMaxHits |
4 |
每次注入最多几条 |
recallMaxChars |
1200 |
注入文本预算 |
captureEnabled |
true |
是否上报对话增量 |
sessionPrefix |
dsh: |
上报时 session 前缀 |
压缩层(挂载 billion-context)
无需单独配置。装好后:DSH 原生自动压缩被接管(compaction-basic auto:false),改由 billion-context 在上下文超限时折叠已消费历史;各 Web preset 注入 biliBasicCompactionPolicy;DSH 默认 retry 白名单补上 MALFORMED_RESPONSE。
压缩 proxy 由
bili-nativeentry 在 DSH 进程内自动 spawn(127.0.0.1:18787),无需手动起。
部署踩坑(重要)
- endpoint 必须带
/mcp/后缀:octop-memory serve 的 MCP 端点 mount 在/mcp,裸 host 会 404、/mcp会 307。 - 中文检索是「按字分段 + 连续子串」:查询词必须是记忆正文的连续子串(顺序一致),不支持同义/近义。整句当 query 会 0 命中,插件已做关键词扇出。
- reasoning 模型做提炼要
thinking: disabled:否则 reasoning 吃满 max_tokens,输出 JSON 被截断 → parse 失败("unbalanced braces"/"empty string")。 - systemd 起 serve 要显式
Environment=HOME=<用户家目录>:否则~展开成/home/<user>报 PermissionError。 - uv 的
uv tool install "pkg[extra]"会静默失败(EXIT=0 但没装),装octop-memory[server]用uv venv+pip install即可。
许可
MIT。记忆客户端 © ArvinQi(上游)+ zhou200310(fork);压缩层 © ranxianglei(billion-context);整合 © zhou200310。
Links
More in this category
vectorize-io/hindsight#coding-agents★ 64488
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★ 43111
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★ 12554
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★ 3880
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★ 2977
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★ 1717
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.