Fork of ArvinQi/dsh-octop-memory: a native DSH memory-sharing plugin that recalls octop shared memory before each turn (keyword fan-out → memory_search) and reports the turn delta afterwards (memory_capture), all in-process — replacing the hooks approach that silently breaks. Default recall is atom-only (refined atomic memories, no raw conversation noise), with Chinese recall via octop per-character segmentation. Requires an octop-memory serve backend (MCP; endpoint must end with /mcp/). Deployment gotchas documented in the README.
Install
# from a prebuilt release tarball
dsh plugin --profile web add -w "https://github.com/zhou200310/dsh-octop-memory/releases/download/v0.2.0/dsh-octop-memory-0.2.0.tgz"
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:zhou200310/dsh-octop-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.
本仓库是 ArvinQi/dsh-octop-memory 的 fork:默认召回改为
atom(只召回精炼原子记忆),并补充了部署踩坑记录。上游 MIT 许可,原作者 ArvinQi。
DSH(DeepSeek Harness)原生「记忆共享」插件:每轮开始前自动召回 octop 共享记忆并注入上下文,轮末把本轮的对话增量上报回 octop,全程在 DSH 进程内完成。
它是「记忆共享模式」的 hooks 实现(~/.dsh/hooks/dsh/*.mjs + Claude Code hook 桥)的替代品:hooks 方案要背 5 个外部依赖(外部 Node 子进程、会话沙箱写权限、--use-system-ca、hook 方言映射、以及和 harness 版本锁死的 hook 桥包),任意一个变化都会让它静默失效。本插件只用 harness 的一等公民接缝。
为什么更稳
| hooks 方案 | 本插件 | |
|---|---|---|
| 执行位置 | 外部 shell 子进程(Claude Code hook 方言) | 进程内 Cordis 插件 |
| 版本耦合 | 依赖 @deepseek-ai/dsh-hooks-claude-code 精确版本,harness 升级即被闸门 deny |
无 @deepseek-ai/* 依赖声明,不进版本闸门 |
| 抓取/写日志 | 受会话沙箱限制,~/.dsh/hooks 不可写时静默降级到 $TMPDIR |
用 ctx.logger,失败可见 |
| CA/代理 | 需要 NODE_OPTIONS=--use-system-ca |
host 进程已由 dsh-mcp 做进程级 CA 合并 |
| 召回质量 | 整句当 query,服务端短语匹配 → 0 命中 | 关键词扇出(多路单 token 查询 + 合并去重) |
| 状态 | 外部 json offset 文件 | 进程内按 session 去重 + turn 幂等 |
接缝
- 召回:
agent/pre-step(waterfall,per-agent ctx)。每轮第一个 step、拿到新 user message 后,用关键词扇出查memory_search,命中则以createUserMessage({ source: { kind: 'dsh-octop-memory', form: 'snapshot', sections } })注入本轮。做法与内置的time-context插件同构。 - 上报:
session/event的turn/end(durable、post-commit)。收集该轮 user/assistant 文本,POSTmemory_capture(text 模式,user/assistant 分字段),按 turn 去重、按 session 幂等。 上报/召回前都会先剥掉 Harness 自动注入的运行时长文(Current runtime context…、<system-reminder>…、子会话 delegate 前言),避免把技能清单/工作目录等噪声写进记忆、也避免它们污染召回关键词。 - 没有新事件类型、不写 session 日志,因此不影响 fork / resume / replay。
认证
认证是用户级 token:token 随 Authorization: Bearer <token> 发送(tokenHeader 可改名,非 Authorization 的头名按原样写入)。token 在服务端已经绑定一个专家,所以客户端不需要也不发送任何身份头(用户标识或专家标识都不传)。
配置
行 id:dsh-octop-memory。可在 profile 的 cordis.patch.yml 用同 id 覆盖(octop 的 DSH 安装器会自动写):
- id: dsh-octop-memory
config:
endpoint: https://<your-octop-host>/mcp/memory/
token: omcp_xxxxxxxx
tokenHeader: Authorization
token 留空时会回退读 ~/.dsh/hooks/config.json(octop 安装器写的那个),方便从 hooks 方案平滑迁移。
主要开关:recallEnabled / captureEnabled / recallMaxHits / recallMaxChars / recallTimeoutMs / recallMaxQueries / recallCorpus / recallDedupeTtlMs / captureMaxChars / captureTimeoutMs / sessionPrefix / source。
兼容性
- 插件版本:
0.1.7 - 支持的 DSH:
>= 0.2.0(dsh.engines.dsh/peerDependencies已声明,已在0.2.2-rc.1上验证) - Node:
>= 20
安装
本目录就是插件源码(src/octop/infra/agents/dsh_native_plugin/),包名是 dsh-octop-memory。
# 1) 装成 profile 的 bundle(本地目录用 link:)
dsh plugin --profile desktop add link:/path/to/octop/src/octop/infra/agents/dsh_native_plugin
# 2) 把 bundle 名加进该 profile package.json 的 dsh.profile.bundles,然后重启 DSH
octop 的 DSH 安装器会自动完成上面两步并写入 config。
验证
- 新会话问一句命中历史记忆的话 → 本轮 request 里能看到
[octop memory] …注入块(source.kind = dsh-octop-memory); - 轮末在 octop 记忆库(
memory_search/memory_raws)能看到本轮session_id = dsh:<sessionId>的记录; - 插件日志(host 日志):
dsh-octop-memory: recall turn=… hits=… fresh=…; - 「装了却没生效」先分清是哪一类:加载探针
/tmp/dsh-octop-memory.log在每次模块 import /apply()时写一行 pid。- 日志里没有当前 DSH 进程的 pid → 插件没被 loader 导入(查 profile
dsh.profile.bundles、cordis.patch.yml里有没有disabled: true、版本闸门); - 有 pid 但 host 日志出现
loaded but NOT configured→ 加载正常、配置缺失(重跑 octop 的 DSH 安装器,或补 profile patch 里的 config 块)。
- 日志里没有当前 DSH 进程的 pid → 插件没被 loader 导入(查 profile
回滚
从 profile 的 dsh.profile.bundles 移除 dsh-octop-memory(或 dsh plugin --profile desktop remove dsh-octop-memory)并重启即可;hooks 方案可随时切回。
安装
npm install dsh-octop-memory
或从 GitHub 直接装:
npm install github:zhou200310/dsh-octop-memory
然后在 DSH profile 的 cordis.patch.yml 里按本仓库同名文件挂载(详见上文「配置」)。
部署提示(fork 补充踩坑)
- endpoint 必须带
/mcp/后缀:octop-memory serve 的 MCP 端点 mount 在/mcp(FastMCPstreamable_http_path="/"),所以配http://<host>:8790/mcp/;裸 host 会 404,/mcp会 307。 - 召回范围:默认
recallCorpus: atom(只搜精炼原子记忆,无命中返回空、不回退 raw),避免「原始对话流水账」和「重要记忆」捏在一起。需要连同原始对话一起搜时改回all。 - 中文检索:octop-memory 用
segment_cjk按字分段(不是分词/trigram),查询词必须是原子事实的连续子串(顺序一致、相邻),不支持同义/近义(「手机」≠「电话」)。 - 后端 LLM 提炼用 reasoning 模型(如 deepseek-v4.1-flash)会截断 JSON:reasoning 内容与 content 一起算进
max_tokens,reasoning 吃掉 80%+ 导致输出 JSON 被截断、parse 失败。解法是给 octop-memory 的OpenAICompatClient打extra_body补丁(config.json 里llm.extra_body = {"thinking":{"type":"disabled"}}),禁用 reasoning 后输出纯 JSON。重装 octop-memory 会覆盖该补丁,需重打。 - 认证 token:
omcp_开头,服务端已绑专家,客户端不传任何身份头。token 由 octop 的 DSH 安装器写入,或手动用 admin API 建(auth code换 session →POST /api/admin/spaces/{space}/tokens)。
发布
- 版本号遵循 semver,改
package.json的version - 推送
vX.Y.Ztag 会触发.github/workflows/release.yml:npm publish --access public+ 创建 GitHub Release - 需要在仓库 Secrets 里配置
NPM_TOKEN(npm Automation token,只发布这个包)
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.