Towzai/dsh-memory

DeepSeek Harness(dsh)的跨会话记忆插件:嵌入搜索 + 自动系统提示注入

Project Overview项目介绍

dsh-memory is a cross-session memory plugin for DeepSeek Harness, backed by YAML storage and exposing six tools: remember, recall, view, list, forget, and pin. It combines keyword and embedding hybrid search, prefers title-first injection, and injects fixed memories only on the first turn to keep prompts compact and preserve LLM prefix caching. Use it when an agent needs durable preferences, project facts, or pinned rules across sessions. It depends on a local Ollama instance for embeddings, falling back to keyword-only search otherwise, and switching embedding models invalidates stored vectors.

dsh-memory 是 DeepSeek Harness 的跨会话记忆插件,基于 YAML 存储提供 remember/recall/view/list/forget/pin 六种工具,支持 embedding 混合检索、标题优先注入与会话首轮一次性自动注入,能让智能体自然跨会话携带记忆而不破坏 LLM 前缀缓存。适合需要长期偏好、项目事实或行为铁则常驻上下文的场景。注意:依赖本地 ollama 生成 embedding,无 ollama 时降级为纯关键词检索;更换嵌入模型会使已有向量失效。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add @towzai/dsh-memory

把 Towzai/dsh-memory 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-memory 🧠

为 DeepSeek Harness(dsh)开发的跨会话记忆插件。

基于 YAML 存储的 remember / recall / view / list / forget / pin 工具,支持 embedding 语义检索、标题优先注入与两级(session/auto)自动注入——智能体"天生带着"记忆,无需记得调用工具。

English | 中文

🎯 注入策略:精准、克制、缓存友好

设计原则 说明
首轮注入,后续复用 固定记忆只在会话第一步注入一次,之后随对话历史自然携带——不再每轮重复渲染
标题优先,按需展开 注入的是精简标题(带 id),全文细节通过 view 工具按需展开——prompt 紧凑
动态记忆独立于固定集 auto 级别记忆按话题检索,不污染固定记忆的注入集,避免重复
不破坏前缀缓存 记忆注入后进入历史消息,后续轮次的 system prompt + 历史前缀不变——LLM 的 KV cache 命中率不受影响
来源隔离标注 注入记忆带前缀 Retrieved memories from the memory store (not conversation history),模型不会误认为对话历史

📊 与其他方案对比

方案 每轮注入 缓存影响 Token 消耗
每轮全量注入 ❌ 每轮重复 ❌ 破坏缓存 高
本插件 ✅ 首轮一次 ✅ 零影响 低

✨ 特性

特性 说明
六个工具 remember(写)/ recall(语义检索)/ view(按 id 展开全文)/ list(标题列表)/ forget(软删除)/ pin(强制注入)
标题优先注入 记忆以总结标题(带 id)注入而非全文——prompt 精简;细节用 view 工具按需展开
两级注入 injectLevel: session 的记忆会话级常驻(首轮注入一次);auto 记忆按话题动态检索
首轮一次注入 固定记忆只在会话第一步注入一次,之后随历史携带——不再每轮重复渲染(省 token、前缀缓存友好)
Embedding 检索 HybridSearch(关键词 2-gram + 本地 ollama embedding,RRF 融合)——能命中关键词检索漏掉的口语化表达
匹配调优 泛词降权(文件/测试/文档…)、关键词至少 2 词命中、检索门控跳过测试性话语("别管/只是测试")
来源标注 注入记忆带前缀 "Retrieved memories from the memory store (not conversation history)",模型不会误认为是对话历史
数据安全 串行写入队列(无丢失更新)、损坏文件隔离备份、原子写入、mtime 缓存失效

📦 安装

# 方式一:从 GitHub 安装(源码,需 prepare 构建)
dsh plugin --profile <name> add github:towzai/dsh-memory

# 方式二:本地路径安装
dsh plugin --profile <name> add ./dsh-memory

# 方式三:npm 包(如已发布)
dsh plugin --profile <name> add @towzai/dsh-memory

首次 git 安装若被 pnpm 拒绝运行 prepare,按提示把包键加入该 profile 的 pnpm-workspace.yaml:

allowBuilds:
  '@towzai/dsh-memory': true

依赖:本地 ollama 实例 + embedding 模型(默认 qwen3-embedding:0.6b,可用环境变量 DSH_MEMORY_EMBED_MODEL 覆盖)。没有 ollama 时自动降级为纯关键词检索。

⚙️ 配置

- id: dsh-memory
  config:
    file: /path/to/memory.yaml   # 记忆文件位置
    injectLimit: 8               # 会话级注入条数上限
    embedProvider: ollama        # ollama(本地,默认)| nous(OpenAI 兼容云端)
    embedApiKeyFile: ''          # 从文件里读第一个 sk-… 当密钥(密钥不进配置/仓库)
    embedApiKey: ''              # 或直接给密钥(优先级最高)
    embedBaseUrl: ''             # 云端 base URL(默认 https://inference-api.nousresearch.com/v1)
    embedModel: ''               # 云端模型(默认 qwen/qwen3-embedding-8b,4096 维)
    minSimilarity: 0.65          # 语义召回相似度门槛

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-agent-notify 下一个 Next dsh-plugin-terminal →