Persistent memory for DeepSeek Harness: memory read/write/retrieve tools, per-turn auto-recording, project-scoped recall injection and a management UI, with non-destructive Claude Code memory import.
Install
# from a prebuilt release tarball
dsh plugin --profile web add "https://github.com/yihefeikong-rgb/dsh-cc-haha-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:yihefeikong-rgb/dsh-cc-haha-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.
一个面向 DeepSeek Harness(DSH) 的第三方持久记忆插件,参考并复刻 CC-HAHA 的项目记忆使用体验。
[!IMPORTANT] 本项目不是 CC-HAHA 官方组件,也不隶属于 CC-HAHA 或 DeepSeek。记忆理念与交互流程参考 CC-HAHA,插件代码使用 DSH 原生事件、工具、LLM 和 Web UI 接口独立实现。
能做什么
- 真实记住:用户明确说“记住”时,DSH 会先读取记忆索引,再显示
memory_remember工具调用;只有返回saved: true后才确认已记住。 - 独立文件:每条记忆保存为单独的 Markdown 文件,并由
MEMORY.md维护简洁索引。 - 项目隔离:每次只注入“通用 + 当前项目”,不会把所有项目记忆一次性塞进上下文。
- 逐轮召回 + 会话预算:每条提示词按当前问题选择最多 5 条相关记忆正文注入;同一会话内已注入过的记忆不重复注入,整会话累计超过
sessionMaxBytes(默认 60KB)后只保留索引——对齐 CC-HAHA 的alreadySurfaced+MAX_SESSION_BYTES。 - 自动记录:按回合评审值得长期保存的信息,失败时保留缓冲,不把模型错误伪装成“没有记忆”。
- 安全更新:同主题通过明确记忆 ID 更新;禁止模糊标题猜测覆盖,更新和删除前保存历史版本。
- 管理界面:会话页上方提供“记忆”标签、项目文件夹、搜索、新建、编辑和删除。
- Claude 记忆导入:可非破坏地导入现有 Claude Code 记忆;重复启动只跳过,不覆盖 DSH 中已更新的内容。
DSH 插件标识
仓库根目录的 package.json 包含 DSH 原生插件声明:
{
"dsh": {
"bundle": { "patch": "./cordis.patch.yml" },
"client": {
"platform": "web",
"inject": ["@deepseek-ai/dsh-client-runtime"]
}
}
}
cordis.patch.yml 负责挂载 host 插件,lib/client.js 负责加载会话页记忆 UI。
安装
要求:已经安装并能正常启动 DSH。
dsh plugin --profile web add github:yihefeikong-rgb/dsh-cc-haha-memory
安装后重启 DSH Web:
dsh web
进入任意会话后,顶部应出现“记忆”标签。首次验证可以发送:
请记住:这个项目使用 Rust 和 Tauri。
正常轨迹应包含:
Read MEMORY.md → memory_remember → saved: true
记忆文件默认位于:
~/.dsh/memory/
├── MEMORY.md
├── 通用/
└── <当前项目>/
└── <主题>.md
配置
默认配置位于 cordis.patch.yml:
- insert:
- id: dsh-memory
name: dsh-memory
config:
reviewEnabled: true
reviewInterval: 5
主要选项:
| 选项 | 默认值 | 说明 |
|---|---|---|
reviewEnabled |
true |
是否启用回合后自动评审 |
reviewInterval |
1(schema)/ 5(本包 patch) |
每多少回合评审一次 |
reviewTimeoutMs |
120000 |
后台评审总超时 |
recallOrder |
117 |
索引 context 的注入顺序 |
recallMaxBytes |
25000 |
注入索引最大字节数(另有 200 行硬上限) |
recallRelevantMaxBytes |
16000 |
单次相关正文最大字节数 |
sessionMaxBytes |
61440 |
本会话相关正文累计上限(0=不限) |
dedupeRelevant |
true |
同一会话内已注入过的正文不再重复注入 |
relevantBodiesEnabled |
true |
是否按当前查询注入相关正文。设 false = 每会话只在开场注入一次:索引冻结 + 无正文 → 记忆块在会话内恒定,harness 不再逐轮追加注入;细节改用 memory_search/memory_read 取(这正是上游 cc-haha 的默认形态) |
freezeIndexPerSession |
true |
索引片段每会话只渲染一次(对齐上游 getUserContext 的 memoize)。否则会话中途写记忆会让索引变化 → 多一次注入 |
selectEnabled |
true |
LLM 语义相关性选择(失败/关闭时回落关键词评分) |
selectTimeoutMs |
12000 |
相关性选择超时 |
guidanceEnabled |
true |
把「引用记忆前的核验」指南注册成系统提示词的静态 section(内容不变 → 走前缀缓存) |
recentToolsEnabled |
true |
把「最近使用过的工具」交给选择器,避免注入正在使用的工具的参考类记忆 |
recentToolsWindow |
8 |
「最近使用过的工具」保留个数 |
skipReviewAfterAgentWrite |
true |
本回合主 agent 自己写过记忆时跳过该回合的后台评审(对齐上游 hasMemoryWritesSince) |
索引(
MEMORY.md)每次被重写前会先备份上一版到~/.dsh/memory/.history/_index/,只保留最近 20 份。 「引用记忆前的核验」指南与「最近用过的工具」排除规则对齐上游 cc-haha 的TRUSTING_RECALL_SECTION/MEMORY_DRIFT_CAVEAT(src/memdir/memoryTypes.ts)与findRelevantMemories的选择器提示词;上游选择器用json_schema强制结构化输出, DSH 的llm.stream无此能力,故改为把同一约束写进提示词。
记忆工具
插件注册 8 个工具:
memory_remember:显式“记住”的单次可见入口。memory_write:新建记忆。memory_read:读取完整记忆。memory_update:按 ID 更新并保存历史版本。memory_delete:删除并保存历史版本。memory_search:当前作用域全文搜索。memory_list:列出当前作用域索引。memory_suggest_tags:推荐已有标签。
隐私与安全边界
- 仓库和安装包不包含任何用户记忆、会话、日志、API Key 或本机 profile。
- 项目写入无法确认当前工作区时会失败,不会静默写进“通用”。
- Web API 运行在 DSH 本地同源信任边界内,不应把 DSH Web 端口暴露到不可信网络。
- 当前实现是单 DSH 进程内串行写入;不建议多个 DSH 实例同时共享同一个记忆目录。
本地开发
pnpm install --frozen-lockfile
pnpm test
pnpm run build
构建输出:
lib/index.js:DSH host 插件。lib/client.js:DSH Web UI 插件。
与 CC-HAHA 的关系
本项目重点参考了 CC-HAHA 的以下记忆设计:
- 每条记忆使用独立文件,
MEMORY.md只保存短索引。 - 用户明确要求记住时必须真实访问记忆系统。
- 写入前检查已有记忆,优先更新而不是制造重复项。
- 记忆只保存跨会话仍有价值的信息,计划和一次性任务不应写入长期记忆。
- 用户要求忽略记忆时,本轮按空记忆处理。
参考基线:NanmiCoder/cc-haha,本地审查提交 d52bbec707246f807416c2bc6b1cd67445cfe622,相关设计位于其 src/memdir/。
感谢 CC-HAHA 作者与贡献者提供优秀的记忆交互设计。完整署名与许可证见 THIRD_PARTY_NOTICES.md。
验证状态
- 自动化测试:50 项。
- 已验证:显式写入、真实文件路径、重复更新、新会话召回、跨项目隔离、后台评审终态、非破坏导入与连续重启幂等。
- 已验证平台:Windows + DSH Web。
License
English summary
An unofficial persistent-memory plugin for DeepSeek Harness, inspired by the project-memory workflow of CC-HAHA. It stores memories as project-scoped Markdown files, exposes visible memory tool calls, injects only global plus current-project context, and includes a Web UI memory tab.
Links
More in this category
vectorize-io/hindsight#coding-agents★ 61856
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★ 42434
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★ 12444
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★ 3822
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★ 2900
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★ 1621
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.