dsh-plugin-memory 0.19.1 → 0.19.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/CHANGELOG.md +14 -0
- package/README.md +2 -0
- package/README.zh.md +2 -0
- package/docs/market/index.json +2 -2
- package/lib/index.js +135 -90
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
|
|
4
4
|
|
|
5
|
+
## [0.19.3] - 2026-11-12
|
|
6
|
+
|
|
7
|
+
### Docs
|
|
8
|
+
|
|
9
|
+
- **README 重点标注 DSH 0.2.2-rc.2 的升级要求**:使用 rc.2 的用户必须升级到 **0.19.2+**——早期 0.19.x 调用已被移除的 `ctx.agents.roots()`,抛错发生在 serial 的 `agent/created` 监听器里会让 **agent 注册被拒绝**,表现为「开启插件后无法新建会话」;升级后需完全重启 DSH。
|
|
10
|
+
- 同时把 0.19.x 的兼容性变更写进 README 顶部提示:engines 显式覆盖 rc.2、prompt 回调容错、chip 在 rc.2 空 props 下的活跃会话兜底。
|
|
11
|
+
|
|
12
|
+
## [0.19.2] - 2026-11-12
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **rc.2 下开启插件后会话不可用(根因)**:DSH 0.2.2-rc.2 把 `ctx.agents.roots()` 换成了 `ctx.agents.list()`,而 `agent/created` 是 **serial 事件**——监听器抛错会**拒绝 agent 注册**,于是每个新会话都建不起来。现在注册表读取改为兼容实现(`list()` → `roots()` → 空数组,绝不抛错),并且四个 `agent/created` 监听器整体 try/catch;另加 rc.2 形状的单测(list-only / legacy-roots / 注册表抛错三种)。
|
|
17
|
+
- 侧栏会话兜底同步改用兼容注册表 `list()`,rc.2 下双击节点的 session 解析不会退回 no-session。
|
|
18
|
+
|
|
5
19
|
## [0.19.1] - 2026-11-11
|
|
6
20
|
|
|
7
21
|
### Fixed
|
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
**macOS · Windows · Linux** · Node ≥ 18 · DSH `^0.2.1-rc.5` / `0.2.2-rc.2` · MIT
|
|
16
16
|
|
|
17
|
+
> **⚠️ Using DSH 0.2.2-rc.2 or newer? Upgrade the plugin to 0.19.2+ first.** Early 0.19.x reads `ctx.agents.roots()`, which rc.2 replaced with `list()`; the resulting throw happens inside the **serial** `agent/created` listener, which rejects agent registration — the visible symptom is **sessions can no longer be created while the plugin is enabled**. 0.19.2 reads the registry compatibly (never throws) and the change needs a **full DSH restart** to take effect `/memory` and the panel stay offline-safe meanwhile.
|
|
18
|
+
|
|
17
19
|
## What it does
|
|
18
20
|
|
|
19
21
|
A Cordis plugin that gives DSH agents **persistent, cross-session, migratable memory**: plain markdown + git (the *LLM Wiki* pattern), a `SOUL.md` persona, and a boot block **auto-injected through runtime context** — a hard guarantee, not a hope that the model decides to call a skill.
|
package/README.zh.md
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
**macOS · Windows · Linux** 全平台支持 · Node ≥ 18 · DSH `^0.2.1-rc.5` / `0.2.2-rc.2` · MIT
|
|
16
16
|
|
|
17
|
+
> **⚠️ 如果你在用 DSH 0.2.2-rc.2 或更高版本,请务必先把插件升级到 0.19.2+。** 早期 0.19.x 调用了 `ctx.agents.roots()`,而 rc.2 已换成 `list()`;这次抛错发生在 **serial** 的 `agent/created` 监听器里,会**拒绝 agent 注册**——表现就是**开启插件后无法新建会话**。0.19.2 改为兼容读取(绝不抛错),升级后需要**完全重启 DSH** 才生效。
|
|
18
|
+
|
|
17
19
|
## 它是干什么的
|
|
18
20
|
|
|
19
21
|
一个 Cordis 插件,给 DSH 的 agent 装上**跨会话、可迁移的持久记忆**:纯 markdown + git(*LLM Wiki* 模式)、一份 `SOUL.md` 人格,以及通过 runtime context **自动注入的 boot 块**——硬保证,不靠模型自觉去调 skill。
|
package/docs/market/index.json
CHANGED
package/lib/index.js
CHANGED
|
@@ -267,6 +267,31 @@ export function apply(ctx, config = {}) {
|
|
|
267
267
|
ttlDays: config.sessionTtlDays,
|
|
268
268
|
})
|
|
269
269
|
const sessionCwd = (agent) => agent?.session?.header?.cwd
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* DSH 0.2.2-rc.2 replaced `ctx.agents.roots()` with `ctx.agents.list()`.
|
|
273
|
+
* Reading `roots()` on rc.2 throws; inside a serial `agent/created` listener
|
|
274
|
+
* that rejects the agent registration and makes every session unusable.
|
|
275
|
+
* Read the registry compatibly and never throw.
|
|
276
|
+
*/
|
|
277
|
+
const rootAgents = () => {
|
|
278
|
+
try {
|
|
279
|
+
const service = ctx.agents
|
|
280
|
+
if (service === undefined) return []
|
|
281
|
+
if (typeof service.list === 'function') return service.list()
|
|
282
|
+
if (typeof service.roots === 'function') return service.roots()
|
|
283
|
+
} catch {
|
|
284
|
+
// registry not ready yet
|
|
285
|
+
}
|
|
286
|
+
return []
|
|
287
|
+
}
|
|
288
|
+
const isRootAgent = (agent) => {
|
|
289
|
+
if (agent === undefined) return false
|
|
290
|
+
const header = agent.session?.header
|
|
291
|
+
if (header !== undefined && (header.parent !== undefined || header.parentSessionId !== undefined)) return false
|
|
292
|
+
const all = rootAgents()
|
|
293
|
+
return all.length === 0 || all.includes(agent)
|
|
294
|
+
}
|
|
270
295
|
const sessionEnabled = (agent, resolved) => sessionGate.effectiveEnabled(
|
|
271
296
|
agent.id,
|
|
272
297
|
sessionCwd(agent),
|
|
@@ -519,14 +544,19 @@ export function apply(ctx, config = {}) {
|
|
|
519
544
|
// (has-user-spoken + active-session) see real user messages as they land.
|
|
520
545
|
ctx.effect(() => {
|
|
521
546
|
const stopCreated = ctx.on('agent/created', ({ agent }) => {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
547
|
+
try {
|
|
548
|
+
if (!isRootAgent(agent)) return
|
|
549
|
+
agent.ctx.effect(() => {
|
|
550
|
+
tracker.attach(agent)
|
|
551
|
+
return () => {
|
|
552
|
+
tracker.detach(agent.id)
|
|
553
|
+
}
|
|
554
|
+
})
|
|
555
|
+
|
|
556
|
+
} catch (error) {
|
|
557
|
+
ctx.logger?.warn?.(`memory: agent/created listener failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
527
558
|
}
|
|
528
559
|
})
|
|
529
|
-
})
|
|
530
560
|
return () => stopCreated()
|
|
531
561
|
}, 'memory.activity-tracker()')
|
|
532
562
|
|
|
@@ -541,30 +571,35 @@ export function apply(ctx, config = {}) {
|
|
|
541
571
|
const stamped = new Set()
|
|
542
572
|
ctx.effect(() => {
|
|
543
573
|
const stopCreated = ctx.on('agent/created', ({ agent }) => {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
574
|
+
try {
|
|
575
|
+
if (!isRootAgent(agent)) return
|
|
576
|
+
agent.ctx.effect(() => {
|
|
577
|
+
const stopInserted = ctx.on('agent/inbox/inserted', ({ agent: target, message }) => {
|
|
578
|
+
if (target?.id !== agent.id) return
|
|
579
|
+
if (message?.source?.kind !== 'user') return
|
|
580
|
+
if (stamped.has(agent.id)) return
|
|
581
|
+
const resolved = store.get()
|
|
582
|
+
if (!sessionEnabled(agent, resolved)) return
|
|
583
|
+
if (!tracker.shouldInject(agent.id, resolved)) return
|
|
584
|
+
stamped.add(agent.id)
|
|
585
|
+
try {
|
|
586
|
+
const memoryDir = currentMemoryDir
|
|
587
|
+
const block = renderBootBlock(memoryDir, { bootFiles, bootMaxChars, bootFileBudgets })
|
|
588
|
+
const referenced = extractReferencedPages(block, memoryDir)
|
|
589
|
+
const touched = touchPages(memoryDir, [...bootFiles, ...referenced])
|
|
590
|
+
if (touched.length > 0) {
|
|
591
|
+
ctx.logger?.info?.(`memory: last_access stamped on ${touched.length} page(s)`)
|
|
592
|
+
}
|
|
593
|
+
} catch (error) {
|
|
594
|
+
ctx.logger?.warn?.(`memory: last_access stamp failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
561
595
|
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
}
|
|
596
|
+
})
|
|
597
|
+
return () => stopInserted?.()
|
|
565
598
|
})
|
|
566
|
-
|
|
567
|
-
})
|
|
599
|
+
|
|
600
|
+
} catch (error) {
|
|
601
|
+
ctx.logger?.warn?.(`memory: agent/created listener failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
602
|
+
}
|
|
568
603
|
})
|
|
569
604
|
return () => stopCreated()
|
|
570
605
|
}, 'memory.page-access()')
|
|
@@ -585,32 +620,37 @@ export function apply(ctx, config = {}) {
|
|
|
585
620
|
if (config.digestNudgeEnabled !== false) {
|
|
586
621
|
ctx.effect(() => {
|
|
587
622
|
const stopCreated = ctx.on('agent/created', ({ agent }) => {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
623
|
+
try {
|
|
624
|
+
if (!isRootAgent(agent)) return
|
|
625
|
+
const guard = new DigestGuard(agent, {
|
|
626
|
+
readConfig: () => {
|
|
627
|
+
const resolved = store.get()
|
|
628
|
+
return {
|
|
629
|
+
enabled: resolved.enabled && sessionEnabled(agent, resolved),
|
|
630
|
+
afterMinutes: config.digestNudgeAfterMinutes,
|
|
631
|
+
cooldownMinutes: config.digestNudgeCooldownMinutes,
|
|
632
|
+
maxPerSession: config.digestNudgeMaxPerSession,
|
|
633
|
+
deferUntilUserSpeaks: resolved.deferUntilUserSpeaks,
|
|
634
|
+
activeSessionOnly: resolved.activeSessionOnly,
|
|
635
|
+
proactiveCooldownSeconds: resolved.proactiveCooldownSeconds,
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
getMemoryDir: () => currentMemoryDir,
|
|
639
|
+
agents: ctx.agents,
|
|
640
|
+
tracker,
|
|
641
|
+
logger: ctx.logger,
|
|
642
|
+
claimLock: claimSharedProactiveLock,
|
|
643
|
+
})
|
|
644
|
+
agent.ctx.effect(() => {
|
|
645
|
+
guard.start()
|
|
646
|
+
return () => {
|
|
647
|
+
guard.dispose()
|
|
600
648
|
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
claimLock: claimSharedProactiveLock,
|
|
607
|
-
})
|
|
608
|
-
agent.ctx.effect(() => {
|
|
609
|
-
guard.start()
|
|
610
|
-
return () => {
|
|
611
|
-
guard.dispose()
|
|
612
|
-
}
|
|
613
|
-
})
|
|
649
|
+
})
|
|
650
|
+
|
|
651
|
+
} catch (error) {
|
|
652
|
+
ctx.logger?.warn?.(`memory: agent/created listener failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
653
|
+
}
|
|
614
654
|
})
|
|
615
655
|
return () => stopCreated()
|
|
616
656
|
}, 'memory.digest-guard()')
|
|
@@ -625,43 +665,48 @@ export function apply(ctx, config = {}) {
|
|
|
625
665
|
{
|
|
626
666
|
ctx.effect(() => {
|
|
627
667
|
const stopCreated = ctx.on('agent/created', ({ agent }) => {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
668
|
+
try {
|
|
669
|
+
if (!isRootAgent(agent)) return
|
|
670
|
+
const nudge = new RecallNudge(agent, {
|
|
671
|
+
readConfig: () => {
|
|
672
|
+
const resolved = store.get()
|
|
673
|
+
return {
|
|
674
|
+
enabled: resolved.enabled && sessionEnabled(agent, resolved),
|
|
675
|
+
recallEnabled: resolved.recallEnabled !== false,
|
|
676
|
+
minMinutes: resolved.recallIntervalMinMinutes,
|
|
677
|
+
maxMinutes: resolved.recallIntervalMaxMinutes,
|
|
678
|
+
maxPerSession: resolved.recallMaxPerSession,
|
|
679
|
+
deferUntilUserSpeaks: resolved.deferUntilUserSpeaks,
|
|
680
|
+
activeSessionOnly: resolved.activeSessionOnly,
|
|
681
|
+
proactiveCooldownSeconds: resolved.proactiveCooldownSeconds,
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
readGrowthConfig: () => {
|
|
685
|
+
const resolved = store.get()
|
|
686
|
+
return {
|
|
687
|
+
enabled: resolved.growthRecapEnabled !== false,
|
|
688
|
+
intervalDays: resolved.growthRecapIntervalDays,
|
|
689
|
+
language: 'zh',
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
getMemoryDir: () => currentMemoryDir,
|
|
693
|
+
agents: ctx.agents,
|
|
694
|
+
tracker,
|
|
695
|
+
logger: ctx.logger,
|
|
696
|
+
claimLock: claimSharedProactiveLock,
|
|
697
|
+
})
|
|
698
|
+
nudges.set(agent.id, nudge)
|
|
699
|
+
agent.ctx.effect(() => {
|
|
700
|
+
nudge.start()
|
|
701
|
+
return () => {
|
|
702
|
+
nudges.delete(agent.id)
|
|
703
|
+
nudge.dispose()
|
|
649
704
|
}
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
claimLock: claimSharedProactiveLock,
|
|
656
|
-
})
|
|
657
|
-
nudges.set(agent.id, nudge)
|
|
658
|
-
agent.ctx.effect(() => {
|
|
659
|
-
nudge.start()
|
|
660
|
-
return () => {
|
|
661
|
-
nudges.delete(agent.id)
|
|
662
|
-
nudge.dispose()
|
|
663
|
-
}
|
|
664
|
-
})
|
|
705
|
+
})
|
|
706
|
+
|
|
707
|
+
} catch (error) {
|
|
708
|
+
ctx.logger?.warn?.(`memory: agent/created listener failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
709
|
+
}
|
|
665
710
|
})
|
|
666
711
|
return () => stopCreated()
|
|
667
712
|
}, 'memory.recall-nudge()')
|
|
@@ -788,7 +833,7 @@ export function apply(ctx, config = {}) {
|
|
|
788
833
|
const url = new URL(req.url ?? '/', 'http://localhost')
|
|
789
834
|
const resolveAgent = (sessionId) => {
|
|
790
835
|
const id = typeof sessionId === 'string' && sessionId.length > 0 ? sessionId : tracker.activeId()
|
|
791
|
-
const roots =
|
|
836
|
+
const roots = rootAgents()
|
|
792
837
|
if (id !== undefined) {
|
|
793
838
|
const direct = ctx.agents.get?.(id)
|
|
794
839
|
if (direct !== undefined) return direct
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-memory",
|
|
3
3
|
"description": "Long-term memory plugin for DeepSeek Harness: persistent cross-session markdown memory with a soul/persona file, auto-injected at every session start, plus remember/recall/consolidate/forget workflows and portable migration tooling.",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|