@asherliner/dsh-memory-connect:为 DSH 增加跨会话记忆

前言

DSH 的理念是「一切皆插件」,插件可以加入指定 profile,用于扩展 agent 行为。DSH 社区目录是独立站点,不与 DeepSeek 或幻方构成官方从属关系。对于需要跨会话保留信息的使用者,单个会话结束后的信息不会自动进入后续会话。

@asherliner/dsh-memory-connect 是一个面向 DSH 的跨会话记忆插件,覆盖 auto-extraction、semantic recall、scheduled maintenance、LLM-powered consolidation 等能力。该插件 package.json 版本为 0.6.1,许可证为 MIT,Node.js 要求为 >=18

这是什么

@asherliner/dsh-memory-connect 提供跨会话记忆与全局身份能力。它列出的能力包括:

  • Global Soul
  • Auto Extraction
  • Cross-Session Recall
  • Context Explosion Prevention
  • Scheduled Maintenance
  • LLM Consolidation
  • Memory Decay
  • Smart Prioritization
  • Memory Compression
  • Temporal Context Graph
  • Trust Model
  • Turn-End Summarization
  • Semantic Recall
  • Zero-config
  • SQLite FTS5

仓库地址:

https://github.com/Asher-2000/dsh-memory-connect

核心功能

  • Global Soul:通过 ~/.dsh/soul.md 提供 persistent global identity。
  • Auto Extraction:从会话中提取信息。
  • Cross-Session Recall:跨会话召回记忆,并列出 SQLite FTS5 能力。
  • Context Explosion Prevention:控制记忆上下文膨胀。
  • Scheduled Maintenance:提供 scheduled maintenance。
  • LLM Consolidation:提供 LLM-powered consolidation。
  • Memory Decay、Smart Prioritization、Memory Compression:分别用于记忆衰减、优先级处理和压缩。
  • Temporal Context Graph:列出的记忆能力之一。
  • Trust Model:recalled history 作为 untrusted reference 注入,current instruction always wins。
  • Turn-End Summarization:列出的 turn-end summary 能力。
  • Semantic Recall:可选语义召回;如果本地 embedding server 不可用,会退化为 keyword-only recall。

安装与启用

先安装到 DSH profile:

dsh plugin --profile <你的profile> add @asherliner/dsh-memory-connect

这条命令会把 @asherliner/dsh-memory-connect 加入指定 profile。

也可以用 npm 直接安装:

npm install @asherliner/dsh-memory-connect

如果使用本地源码调试,先克隆仓库,再用 link: 方式加入 profile:

git clone https://github.com/Asher-2000/dsh-memory-connect.git
cd dsh-memory-connect
dsh plugin --profile <你的profile> add link:/path/to/dsh-memory-connect

在 DSH composition 中,path 是 required 配置项。可以写成:

config:
  path: ~/.dsh/memory.db
  enableSoul: true

这里配置了 SQLite 数据库路径,并开启 Soul 注入。

插件会注入 systemPrompt,所以加载该插件的 profile 需要 systemPrompt service 可用。

典型用法

创建全局身份

创建 ~/.dsh/soul.md,用于提供 persistent global identity:

~/.dsh/soul.md

如果插件配置中启用 Soul,可以在 DSH composition 中设置:

enableSoul: true

查询记忆

插件暴露的 API 示例如下:

ctx.crossSessionMemory.searchMemories({
  query: 'TypeScript configuration',
  types: ['fact', 'decision'],
  limit: 5
})

这个调用会按查询词和记忆类型召回记忆,并限制返回数量。

可选语义召回

语义召回是可选能力。先启动本地 embedding server:

pip install sentence-transformers
python3 node_modules/@asherliner/dsh-memory-connect/scripts/embed_server.py --port 8765

这两条命令用于安装 Python 模型依赖,并在 8765 端口启动 embedding server。

然后开启语义召回:

embeddingEnabled: true

如果 embedding server 不可达,插件会退化为 keyword-only recall。

适用场景与注意

适合需要 DSH agent 跨会话记忆、全局身份、定时维护、LLM consolidation 或可选语义召回的场景。

使用前注意:

  • 插件以当前 dsh 进程权限运行,安装前应检查源码与许可证。
  • Node.js 要求为 >=18
  • 插件配置中 path 必填。
  • 插件会注入 systemPrompt,profile 需要 systemPrompt service 可用。
  • semantic recall 是 optional,需要本地 embedding server。
  • recalled history 以 untrusted reference 形式注入,current instruction always wins。
  • peerDependencies include @deepseek-ai/cordis ^4.0.1 and several @deepseek-ai/dsh-* rc packages;@deepseek-ai/dsh-session-query and @deepseek-ai/dsh-scope are optional。

结尾

经过上面的安装、配置和用法,@asherliner/dsh-memory-connect 可以把 auto-extraction、cross-session recall、scheduled maintenance、LLM consolidation 和可选 semantic recall 接入 DSH。

仓库地址:

https://github.com/Asher-2000/dsh-memory-connect
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye