DSH Hub

itr-del/dsh-cue-bank

dsh-cue-bank

UIWeb UI1 GitHub stars· updated 2026-08-20

Cross-session event-cue memory plugin for DeepSeek Harness: auto-builds a persistent cue bank from conversations and re-injects remembered context on topic switches.

Install

npx @deepseek-ai/dsh plugin --profile web add github:itr-del/dsh-cue-bank

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

dsh-cue-bank DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/dsh-cue-bank.svg)](https://dshhub.dev/plugins/dsh-cue-bank)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from itr-del/dsh-cue-bank, cleaned of badges and images.

dsh-cue-bank — 跨会话「事件触点记忆」插件

让 Agent 的记忆能力向人类靠拢:人脑可以在不同任务间随时切换,靠的是对事件建立多维触点(关键词、视角、触发物…),触点被当前情境激活后,从长期记忆快速拉取事件细节。本插件把这一机制在 dsh(DeepSeek Harness)上落地。

设计原理

人脑记忆模型                          本插件实现
─────────────────                    ─────────────────────────────
事件经历                              触点库中的 topic(带摘要+关键词+时间)
事件触点(关键词/视角/触发物)         topic.keywords + dimensions
情境激活触点 → 唤醒事件               用户新消息关键词 → 扫描触点库
话题切换 → 快速拉取细节                重合度低于阈值 → 注入记忆唤醒上下文
记忆渐进完善                          每次触碰更新 lastTouchedAt / 合并关键词

两层架构

┌─ 写入侧(建库,每轮 turn 结束时)─────────────────────┐
│ agent/status=idle → 读本 turn 文本                    │
│   ├─ 对话级触点:本轮关键词(2~4 字中文 gram + 英文词)│
│   ├─ 任务级触点:session 聚合关键词(合并更新)        │
│   └─ 用户惯用词:近 N 轮窗口的高频个人用词(第二类)    │
│ → upsert 进全局触点库(原子写 JSON)                   │
└───────────────────────────────────────────────────────┘
┌─ 唤醒侧(话题切换时,每步组装前)─────────────────────┐
│ systemPrompt.context() provider(同步契约)           │
│   → 提取新消息关键词 → 与上轮关键词算重合度           │
│   → 重合度 < 阈值 = 话题切换                          │
│   → 扫描触点库(关键词 TF 加权 / 向量余弦)           │
│   → 命中 top-N → 注入 <system-reminder> 记忆唤醒块    │
│   → 命中用户惯用词 → 追加「用户惯用词」提示行          │
└───────────────────────────────────────────────────────┘

关键设计决策

1. 动态组装注入(不污染持久历史)

使用 systemPrompt.context() 注册动态上下文:每次 prompt 组装时求值 provider,生成带来源的 runtime-context 快照,随请求发送但不写入持久 session 历史。话题不切换时不注入,保持上下文干净。这正是与 agent-instructions(持久注入)的关键区别。

2. 触发时机可配置

配置默认说明
topic.switchDetectiontrue开启话题切换检测
topic.switchThreshold0.25关键词重合度低于此值视为切换(0~1)
topic.scanEveryTurnfalse每轮都扫描(灵敏但开销大);false 时只在切换时扫描

3. 匹配算法:双模式可配置

模式成本/次唤醒效果适用
keyword(TF 加权穷举)0(纯本地)词面重合准确,语义弱无外部 key
vector(向量余弦)≈ ¥0.000025(见下)语义匹配强有 embedding key
auto(默认)有 key 用向量,否则降级关键词推荐

⚠️ DeepSeek 官方 API 不提供 embedding 端点(见 issue #806),向量模式走 OpenAI 兼容接口(默认 SiliconFlow BAAI/bge-m3)。库向量在写入时预计算并缓存,唤醒时只编码 1 条 query,不重复计费。

成本估算(bge-m3 / SiliconFlow,2026-08 行情):

  • 单次唤醒:编码 query ~50 tokens ≈ ¥0.000025(每 1 万次话题切换约 ¥0.25)
  • 写入时:每轮 1 次嵌入(可忽略)
  • 关键词模式:零外部成本

4. 通用插件(所有 agent 生效)

监听全局 agent/created,对每个 agent 挂载唤醒/写入钩子,不限于飞书。userId 从 session id 提取(feishu:ou_xxxou_xxx;其他 session 用完整 id),按用户分片存储。

5. 全局存储

触点库存于 $DSH_HOME/storages/cue-bank/users/<userId>.json(默认),跨 profile、跨会话共享;可用 storageRoot 覆盖。单用户触点上限 200 条(LRU 淘汰),惯用词上限 50 条。

安装

1. 一键安装(推荐)

dsh plugin --profile web add github:itr-del/dsh-cue-bank

安装器通过 package.json 的 dsh.bundle manifest 解析插件(cordis.patch.yml),挂载到指定 profile 后重启 dsh 即生效。

也可以从 npm 安装:dsh plugin --profile web add dsh-cue-bank(已发布到 npm,见 npmjs.com/package/dsh-cue-bank)。

2. 手动挂载到 profile(可选)

Related plugins