sage-mem 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  记忆存在**本地 markdown 文件**里(frontmatter + 正文),不是数据库。透明、可检查、防膨胀。
6
6
 
7
+ > **DSH 版本兼容性(0.5.3 核对于 `0.1.7-rc.1`)**
8
+ > `session.deriveMessages()`(仍是同步)、`system-prompt/assemble` 事件、以及 `context.agent.session` 这条链,在 0.1.6 → 0.1.7 之间**均未改变**,本插件在 0.1.7 上无需改动即可工作。
9
+ > 0.5.3 另加了一层防御:`deriveMessages()` 若哪天被改成异步,或 `Session` 上的历史读取接口被改名(0.1.7 起 `snapshotEvents` / `eventAt` / `ownEvents` 已标记弃用),插件会在**日志里报警**,而不是像以前那样静默地不再注入记忆。0.1.6 上的行为与 0.5.2 完全一致。
10
+
7
11
  ## 从 Claude Code 无损迁移
8
12
 
9
13
  你已经在 Claude Code(CC)里养了一个 agent,舍不得它的记忆和人格?sage-mem 是「CC → DSH」迁移方案的一部分,**记忆与人格都能无损搬过来**:
package/lib/index.js CHANGED
@@ -36,7 +36,7 @@ const MAX_BASELINE = 5
36
36
  * frontmatter 里的 originSessionId / birthday 等字段一并抹掉。
37
37
  *
38
38
  * 判定依据是「丢了能不能从别处重建」:memory 目录**不在任何版本控制下**
39
- * (在 E:\shengdian 下 `git rev-parse` 直接报 not a git repository),
39
+ * (该目录里没有 .git,`git rev-parse` 直接报 not a git repository),
40
40
  * deleteFile 是 unlink、没有回收站,所以宁严勿松。
41
41
  * 这几个文件要改,用文件工具直接编辑。
42
42
  */
@@ -246,8 +246,17 @@ export class MemoryGateway extends TypertRemoteService {
246
246
  try {
247
247
  const agent = context?.agent
248
248
  const session = agent?.session
249
- if (!session || typeof session.deriveMessages !== 'function') return assembled
250
- const messages = [...session.deriveMessages()]
249
+ if (!session) return assembled
250
+ // DSH 0.1.7 起 Session 的历史读取接口在陆续调整(snapshotEvents / eventAt /
251
+ // ownEvents 已弃用)。deriveMessages 在 0.1.7-rc.1 实测仍在且仍同步,但这三行
252
+ // 不是白写的:方法一旦被改名或改成异步,老写法要么静默不注入、要么把 Promise
253
+ // 当数组展开成空。宁可日志里响一声,也不要"记忆不注入但日志一字没有"。
254
+ if (typeof session.deriveMessages !== 'function') {
255
+ warnLog(ctx, 'session.deriveMessages() 不可用 —— 记忆召回已跳过(DSH session API 变了?)', sessionId)
256
+ return assembled
257
+ }
258
+ const derived = session.deriveMessages()
259
+ const messages = [...(derived && typeof derived.then === 'function' ? await derived : derived)]
251
260
 
252
261
  // 关键:DSH 0.1.5 把工具结果(source.kind === 'tool')和注入内容
253
262
  // (source.kind === 'plugin')也存成 role: 'user' 的消息。只按 role 取
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sage-mem",
3
3
  "description": "File-based memory plugin for DeepSeek Harness (DSH) — cross-session memory in transparent markdown files, with a memory star-map view",
4
- "version": "0.5.2",
4
+ "version": "0.5.3",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {