dsh-memory:基於 DSH 會話日誌的帶引用記憶

前言

智能體在多輪會話中會積累用戶偏好、項目決定、環境差異和用戶糾正。如果只把這些信息壓縮成摘要,摘要可能失真,後續也說不清某條記憶從何而來。DSH 已有無損會話日誌,dsh-memory 在此基礎上做帶引用記憶:會話結束後把蒸餾出的事實寫成人類可審計的 Markdown,並讓每條記憶可回追到精確原始日誌事件。

下面介紹 dsh-memory 的定位、能力、安裝方式和典型用法。

這是什麼

dsh-memory 是 Jesse-njx 維護的 DeepSeek Harness(DSH)bundle,倉庫名爲 Jesse-njx/dsh-memory。

它的核心價值是:

  • 基於 DSH 無損會話日誌;
  • 將蒸餾事實寫成 Markdown memory 文件;
  • 每條 memory 帶 citation,可指向精確 sessionId 與日誌事件範圍;
  • 提供緊湊 recall index、memory_read、memory_expand、dsh-memory CLI 和會話內 /memory 命令。

許可證爲 MIT。standalone dsh-memory binary 是純 Node 實現,要求 Node >=20。

核心功能

會話結束後蒸餾事實

會話結束後,dsh-memory 會通過後臺 distillation 異步抽取持久事實,並寫入 Markdown memory 文件。

默認路徑爲:

~/.dsh/memory/

項目記憶位於:

~/.dsh/memory/<project>/*.md

user 記憶位於:

~/.dsh/memory/_user/*.md

蒸餾 pass 會更新或反駁既有 memory,並記錄到:

<project>/_distill.log

該日誌文件爲 JSONL。

每次 prompt assembly 提供 recall index

每次 prompt assembly 時,dsh-memory 會渲染一個緊湊、token 受限的 recall index。

maxIndexTokens 是注入 recall index 的硬 token 上限。

從記憶回追原始日誌

每條 memory 帶 citation,可指向精確 sessionId 與日誌事件範圍。

它提供兩個工具:

memory_read(name)
memory_expand(name, [citation_index])

memory_read(name) 用於讀取完整 memory 文件。

memory_expand(name, [citation_index]) 用於返回被引用的原始日誌摘錄。

maxExpandBytes 是單次 memory_expand 輸出的字節上限。

維護、類型與遮蔽

dsh-memory 支持三種 memory 類型:

  • user
  • project
  • feedback

同名 project memory 會遮蔽 user memory。

它還提供:

dsh-memory list
dsh-memory show
dsh-memory edit
dsh-memory delete
dsh-memory distill-log

會話內也提供:

/memory
/memory <name>

安裝與啓用

安裝命令如下:

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

配置字段均爲可選。下面是一個配置示例:

plugins:
  dsh-memory:
    enabled: true
    home: ~/.dsh/memory
    maxIndexTokens: 800
    maxExpandBytes: 8192
    distill:
      provider: deepseek-official
      model: deepseek-v4-flash
      maxTranscriptTokens: 16000

字段含義:

  • enabled:是否啓用;
  • home:memory root 路徑;
  • maxIndexTokens:recall index 的硬 token 上限;
  • maxExpandBytes:單次 memory_expand 輸出的字節上限;
  • distill.provider:蒸餾使用的 provider;
  • distill.model:蒸餾使用的 model;
  • maxTranscriptTokens:限制進入蒸餾的 transcript 長度,超限時最舊事件被丟棄。

distill 默認複用當前會話 provider/model,也可以用 distill.provider 和 distill.model 覆蓋。

典型用法

會話內查看

在會話中使用:

/memory

查看列表。

使用:

/memory <name>

查看指定 memory。

工具調用

讀取完整 memory:

memory_read(name)

返回被引用的原始日誌摘錄:

memory_expand(name, [citation_index])

citation_index 用於指定 memory 中某條 citation。

CLI 管理

dsh-memory CLI 支持以下命令:

dsh-memory list [--project P] [--json]
dsh-memory show <name> [--project P]
dsh-memory edit <name> [--project P]
dsh-memory delete <name> [--project P]
dsh-memory distill-log [--project P]

也可以使用 --home 覆蓋 memory root:

dsh-memory list --home /path/to/memory

覆蓋蒸餾路由

如果需要指定蒸餾使用的 provider 和 model,可以這樣配置:

plugins:
  dsh-memory:
    distill:
      provider: deepseek-official
      model: deepseek-v4-flash

適用場景與注意

適合以下場景:

  • 希望記住用戶偏好、項目決定、環境差異和用戶糾正;
  • 希望 memory 是 Markdown 文件,便於人工查看、編輯和刪除;
  • 希望每條記憶可回追到原始日誌事件;
  • 希望避免自動注入完整 memory 正文。

需要注意:

  • v0.1 明確不做向量數據庫、知識圖譜、超出 user 類型的跨項目全局記憶、記憶共享/同步、自動注入完整 memory 正文;
  • 同名 project memory 會遮蔽 user memory;
  • maxIndexTokens、maxExpandBytes、maxTranscriptTokens 會限制 recall index、memory_expand 輸出和蒸餾 transcript 長度;
  • peerDependencies 包含 @deepseek-ai/cordis ^4.0.1、@deepseek-ai/schemastery ^3.18.1 等版本範圍;
  • 插件以當前 dsh 進程權限運行,安裝前應檢查源碼與許可證。

結尾

dsh-memory 的價值在於把蒸餾事實寫成可審計 Markdown,並保留到原始會話日誌的引用。它不是自動注入完整記憶,而是在 recall index、memory_read 和 memory_expand 之間提供一層可回追的記憶索引。

GitHub:https://github.com/Jesse-njx/dsh-memory

目錄頁:本次資料未提供可確認的目錄頁 URL,請以實際 DSH 社區目錄爲準。

羽毛球分组比赛记分
小程序二维码

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

小夜