dsh-memory-eternal 0.4.2 → 0.4.4
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 +241 -253
- package/index.js +3 -2
- package/lib/capture.js +14 -0
- package/lib/vault.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,253 +1,241 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-3B82F6" alt="DSH plugin" />
|
|
5
|
-
<img src="https://img.shields.io/npm/v/dsh-memory-eternal" alt="npm version" />
|
|
6
|
-
<img src="https://img.shields.io/github/stars/EternalNight996/dsh-memory-eternal?style=flat" alt="GitHub stars" />
|
|
7
|
-
<img src="https://img.shields.io/github/license/EternalNight996/dsh-memory-eternal" alt="license" />
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<p align="center">
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
|
156
|
-
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
- [
|
|
214
|
-
- [
|
|
215
|
-
- [
|
|
216
|
-
- [
|
|
217
|
-
- [
|
|
218
|
-
- [
|
|
219
|
-
- [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
- **v0.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
- **v0.2.2**:放宽 `@deepseek-ai/dsh-tools` / `dsh-llm` peer 依赖至 `^0.1.0-rc.7`,同时兼容旧版与新版 DSH。
|
|
243
|
-
- **v0.2.1**:更新 `@deepseek-ai/dsh-tools` / `dsh-llm` peer 依赖至 `^0.1.1-rc.2`(对齐当前 DSH 运行时)。
|
|
244
|
-
- **v0.2.0**:新增侧边栏「记忆」入口 + 完整记忆库弹窗;增强知识图谱(力导向/径向布局、滚轮缩放、左键拖拽平移、左键凸显关联/右键打开卡片、大规模抗压:节点/连线上限 + 标签节流 + O(n) 径向布局);README 头部动态演示 GIF。
|
|
245
|
-
- **v0.1.0**:首个可用版本。对话自动沉淀(turn-stopping 钩子 + LLM 压缩 + 双层去重)、`memory_recall` 工具、system prompt 召回段、Markdown Vault(02-08 分类 + frontmatter)、CJK 检索、自研知识图谱、设置页图形化知识库。
|
|
246
|
-
|
|
247
|
-
## 📄 License
|
|
248
|
-
|
|
249
|
-
MIT
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
> 让 DSH 拥有第二大脑:**对话自动沉淀,知识随手可查。** 🧠
|
|
1
|
+
# 🧠 记忆核心 dsh-memory-eternal — 给 DeepSeek Harness 装上「第二大脑」
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-3B82F6" alt="DSH plugin" />
|
|
5
|
+
<img src="https://img.shields.io/npm/v/dsh-memory-eternal" alt="npm version" />
|
|
6
|
+
<img src="https://img.shields.io/github/stars/EternalNight996/dsh-memory-eternal?style=flat" alt="GitHub stars" />
|
|
7
|
+
<img src="https://img.shields.io/github/license/EternalNight996/dsh-memory-eternal" alt="license" />
|
|
8
|
+
<img src="https://img.shields.io/badge/自研内核-CJK检索-10B981" alt="self-built" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
> **对话结束自动沉淀,跨会话真实不失忆;召回只取相关小块,省 token、少噪音。**
|
|
12
|
+
> 全自研、零第三方记忆框架、不改 DSH 源码、一条命令安装——为你装一个「自己说了算」的、可 git 管理的本地记忆库。
|
|
13
|
+
|
|
14
|
+
<p align="center"><strong>⭐ 觉得好用就点个 Star</strong>,让更多被「AI 总忘事」困扰的人用上它。<br/><sub>一条命令:<code>dsh plugin --profile web add dsh-memory-eternal</code></sub></p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<img src="assets/screen/dsh-memory-eternal.gif" width="880" alt="记忆核心 · 对话自动沉淀 + 图形化知识库 + 增强知识图谱(动态演示)" />
|
|
20
|
+
<br/><em>对话自动沉淀 · 图形化知识库 · 交互式知识图谱(动态演示)</em>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🔥 先看痛点:AI 助手为什么「总让人失望」?
|
|
26
|
+
|
|
27
|
+
| # | 痛点(每个用 AGENT 的人都遇到过) | 没有记忆的后果 |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| 1 | **长对话就忘事** | 聊到第 10 轮,前面定的方案、改的口径全忘了,反复重来 |
|
|
30
|
+
| 2 | **跨会话失忆** | 换新会话 = 白纸一张,项目背景要重新讲一遍 |
|
|
31
|
+
| 3 | **长会话 token 暴涨** | 上下文越来越长,越聊越贵、越聊越慢,甚至爆窗 |
|
|
32
|
+
| 4 | **存了却找不到** | 就算有笔记,也搜不到、管不好,等于没存 |
|
|
33
|
+
| 5 | **数据被锁死** | 记忆存在私有库里,改不了、导不出、不敢用 |
|
|
34
|
+
|
|
35
|
+
> 这不是你的错觉,是**绝大多数 AI 产品共通的硬伤**。而解法,正是 Agent 记忆——**总结 → 存储 → 按需召回**。
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🚀 装上它之后:五道痛点逐一被解决
|
|
40
|
+
|
|
41
|
+
| 痛点 | 装上记忆核心后 | 靠什么实现 |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| ① 长对话忘事 | 保留「最近原文」,旧轮次自动总结成卡 | 自动沉淀 + 语义去重 |
|
|
44
|
+
| ② 跨会话失忆 | 新会话也能召回旧决策/方案 | `memory_recall` 按需召回 |
|
|
45
|
+
| ③ 长会话 token | **只召回相关小块**,不每轮全量塞 | 相关性阈值 + 片段截断 + 沉淀预筛 |
|
|
46
|
+
| ④ 存了找不到 | 中文整词+bigram 检索 + 可视化图谱 | CJK 感知检索 + 知识图谱 |
|
|
47
|
+
| ⑤ 数据被锁死 | 纯 Markdown,可读可改可 git 托管 | 本地 Markdown Vault |
|
|
48
|
+
|
|
49
|
+
```mermaid
|
|
50
|
+
flowchart LR
|
|
51
|
+
A["对话每一轮"] --> B{"turn-stopping<br/>有没有可复用信号?"}
|
|
52
|
+
B -- "无 → 跳过(省LLM)" --> X["❌ 不调模型"]
|
|
53
|
+
B -- "有" --> C["LLM 压缩成知识卡"]
|
|
54
|
+
C --> D{"去重核对"}
|
|
55
|
+
D -- "同一主题" --> E["追加更新到已有卡"]
|
|
56
|
+
D -- "新主题" --> F["写入 02-08 分类目录"]
|
|
57
|
+
F & E --> G["本地 Markdown Vault"]
|
|
58
|
+
G --> H["memory_recall 按需召回"]
|
|
59
|
+
H --> I["AI 下次不再失忆"]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🧬 核心内核设计:为什么要「全自研」
|
|
65
|
+
|
|
66
|
+
市面上记忆方案很多,但大多**依赖第三方框架 / 动不动就起一个 MCP 服务 / 把记忆锁进私有库**。本插件把「记忆骨架」整个自己搭出来,**零第三方运行时依赖**,逻辑能逐行看懂:
|
|
67
|
+
|
|
68
|
+
| 模块 | 自研实现 | 替代什么 |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| **去重** | 词法 Jaccard bigram(0.62)+ **语义去重**(把已有卡索引喂模型,让它决定「新建 vs 追加」) | 防重复、防 LLM 改写导致的垃圾卡 |
|
|
71
|
+
| **检索** | CJK 感知:中文整词 + 字符 bigram 命中 | 无需全文搜索引擎,短查询也能命中长文 |
|
|
72
|
+
| **图谱** | 力导向/径向布局 + `[[wikilink]]`/共享标签/相似度连边 | 让「知识之间怎么关联」一眼看清 |
|
|
73
|
+
| **存储** | 带 frontmatter 的普通 `.md`,落盘 `~/.dsh/memory-vault` | 不锁库、可读、可 git、可被任意工具读 |
|
|
74
|
+
|
|
75
|
+
> **与其他热门记忆项目的思路同向(总结→存储→按需召回),但定位不同。** 参考同类热门思路,本插件主打「**本地、自研、零依赖、可读可控**」:
|
|
76
|
+
|
|
77
|
+
| 热门项目 | 定位 | 本插件的差异 |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| [agentmemory](https://github.com/rohitg00/agentmemory) | 通用 Agent 记忆服务 | 本插件是 **DSH 原生插件**,不另起服务,直接进设置/侧边栏 |
|
|
80
|
+
| [mem0](https://github.com/mem0ai/mem0) | 记忆层(常配 MCP) | 本插件**无 MCP 依赖**,离线可跑,走本地 `memory_recall` 工具 |
|
|
81
|
+
| [MemGPT / Letta](https://github.com/letta-ai/letta) | 上下文内存管理 | 本插件承载「**持久记忆**」这一层;会话内实时压缩属 harness 层 |
|
|
82
|
+
| **[Zep](https://github.com/getzep/zep)** | 时间/图记忆 | 本插件零外部服务,图谱/检索纯本地 |
|
|
83
|
+
|
|
84
|
+
> 如果你已在用其中某一层,也完全能把本插件当「**本地持久记忆底座**」叠加使用——它只消费你已配置好的 provider,不抢模型、不改你的习惯。
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## ✨ 功能总览(交互全在这里)
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary><b>📇 知识卡:存得进、找得到、管得了</b></summary>
|
|
92
|
+
|
|
93
|
+
- **全自动沉淀**:每轮结束自动判定+压缩成 300-800 字知识卡,无需手动保存
|
|
94
|
+
- **双层去重**:Jaccard 词法 + 语义追加,不堆重复卡
|
|
95
|
+
- **`.md` 全文**:frontmatter 里带 `kind/title/tags/created/updated`,就是普通 Markdown
|
|
96
|
+
- **Markdown 渲染**、**长卡折叠**、**新卡「新」角标**、**搜索命中高亮**、**卡片行删除**
|
|
97
|
+
- **无限滚动懒加载**、自定义**滚动条**配色
|
|
98
|
+
- 排序:**最近 / 标题 / 热点(按连接数)**
|
|
99
|
+
|
|
100
|
+
</details>
|
|
101
|
+
|
|
102
|
+
<details>
|
|
103
|
+
<summary><b>🕸 知识图谱:秒级看懂「知识之间的关系」</b></summary>
|
|
104
|
+
|
|
105
|
+
- **力导向/径向混合布局**:按 kind 分扇区、枢纽在内圈、环间距不重叠,数量大也不乱;**几千节点不卡**
|
|
106
|
+
- 连线 = `[[wikilink]]` / 共享标签 / **相似度关联**;只保留**高影响力主干边**避免毛球
|
|
107
|
+
- 交互:**左键凸显关联**、**右键菜单**(打开/凸显/复制/删除)、**Shift 框选多选**(导出/删除/合并)、**图例过滤**、**时间维着色**(3天内绿/2周琥珀/1月橙/更早灰蓝)、**滚轮缩放**、**导图 PNG**(下载/另存为/复制/全屏)
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
|
|
111
|
+
<details>
|
|
112
|
+
<summary><b>💾 备份与控制:数据永远是你的</b></summary>
|
|
113
|
+
|
|
114
|
+
- 记忆库**导出 MD / JSON**、**导入**(自动去重)
|
|
115
|
+
- 导出可选**默认下载**或**自选位置**另存为
|
|
116
|
+
- 所有操作**顶部醒目 toast**:✓ 绿 = 成功、✕ 红 = 失败,并显示导出位置/文件名
|
|
117
|
+
- 可指向任意目录(如 Obsidian Vault)
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
<p align="center">
|
|
121
|
+
<img src="assets/screen/memory-settings.png" width="840" alt="设置 → 记忆:统计 + 检索 + 卡片/图谱 Tab" />
|
|
122
|
+
<br/><em>设置 → 记忆:统计概览、CJK 检索、知识卡网格、按 kind 分类</em>
|
|
123
|
+
</p>
|
|
124
|
+
<p align="center">
|
|
125
|
+
<img src="assets/screen/memory-popup.png" width="840" alt="侧边栏「记忆」一键打开完整记忆库弹窗" />
|
|
126
|
+
<br/><em>侧边栏底部「记忆」按钮 → 一键打开完整记忆库弹窗(含增强知识图谱)</em>
|
|
127
|
+
</p>
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 🚀 安装(一条命令)
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# 已发布后(npm)—— 跨平台通用
|
|
135
|
+
dsh plugin --profile web add dsh-memory-eternal
|
|
136
|
+
|
|
137
|
+
# 从 GitHub
|
|
138
|
+
dsh plugin --profile web add github:EternalNight996/dsh-memory-eternal
|
|
139
|
+
|
|
140
|
+
# 本地联调(改代码即时生效)
|
|
141
|
+
dsh plugin --profile web add F:/MyApp/eternal/dsh-memory-eternal
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
> 提示:
|
|
145
|
+
> - `dsh` 为 DSH CLI(`npm i -g @deepseek-ai/dsh`)。
|
|
146
|
+
> - 要**官方最新**(避免 npmmirror 滞后):`npm_config_registry=https://registry.npmjs.org/ dsh plugin --profile web add dsh-memory-eternal`。
|
|
147
|
+
> - **profile 是 pnpm workspace**:`cd ~/.dsh/profiles/web && pnpm add dsh-memory-eternal@latest`(`npm install` 会报 `EUNSUPPORTEDPROTOCOL`)。
|
|
148
|
+
|
|
149
|
+
装完**重启 dsh web**:设置 → 记忆 出现知识库;侧边栏底部出现「记忆」按钮。此后每轮对话自动沉淀。
|
|
150
|
+
|
|
151
|
+
### 🧭 插件发现 / 收录标准
|
|
152
|
+
|
|
153
|
+
仓库已打 **GitHub `dsh-plugin` topic** 并符合社区标准结构,**自动被以下机制发现**(无需手动 PR):
|
|
154
|
+
|
|
155
|
+
| 机制 | 收录方式 | 状态 |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| **dsh-marketplace**(ouyangyipeng) | 实时读 `topic:dsh-plugin` | ✅ topic 已打 |
|
|
158
|
+
| **dsh-find-plugin**(awesome-dsh-plugin) | 会话内按 topic+星数搜索 | ✅ |
|
|
159
|
+
| **dsh-plugin-marketplace**(YELEBAI) | 每 2h 自动扫描 + 静态验证进入 Registry | ✅ 已声明 `dsh.marketplace` 元数据 |
|
|
160
|
+
| **dsh-market**(2BingLing) | 提交 Issue | ✅ 已提 |
|
|
161
|
+
| **awesome-dsh-plugin** | 提交 PR | ✅ 已提 |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 🔧 设置
|
|
166
|
+
|
|
167
|
+
| 设置项 | 默认 | 说明 |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| 启用 | 开 | 总开关 |
|
|
170
|
+
| 自动沉淀 | 开 | 每轮对话结束自动捕获 |
|
|
171
|
+
| 自动召回 | 开 | 注入 system prompt + `memory_recall` 工具 |
|
|
172
|
+
| 记忆库目录 | 空 | 留空 = `~/.dsh/memory-vault`;可指向任意目录(如 Obsidian Vault) |
|
|
173
|
+
| 去重阈值 | 0.62 | 词法去重 Jaccard 相似度阈值 |
|
|
174
|
+
| 捕获最小长度 | 200 | 少于该字符数不触发捕获 |
|
|
175
|
+
| 日配额 | 60 | 每天最多自动写卡数,防止烧 token |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 🛠 开发 / 构建 / 测试
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npm i
|
|
183
|
+
npm test # 单元测试:vault 去重/检索/图谱 + capture 管线 + API 形状
|
|
184
|
+
npm run build # 打包 client(改 src/client 后需要;改 index.js / lib 无需构建)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
dsh-memory-eternal/
|
|
189
|
+
├── index.js # host:设置 + turn-stopping 钩子 + 工具 + JSON API
|
|
190
|
+
├── lib/
|
|
191
|
+
│ ├── vault.js # 存储层(frontmatter/去重/检索/图谱)
|
|
192
|
+
│ └── capture.js # 自动沉淀管线(LLM 压缩 + 语义去重 + 预筛)
|
|
193
|
+
├── src/client/index.tsx # client:设置页 + 侧边栏「记忆」+ 完整记忆库弹窗
|
|
194
|
+
├── build.mjs # esbuild 打包 client → lib/client.js
|
|
195
|
+
├── cordis.patch.yml # bundle 补丁层(自动挂载 host 行)
|
|
196
|
+
└── tests/ # node:test 单测
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 🗺 Roadmap / 待办(记忆侧核心优化)
|
|
202
|
+
|
|
203
|
+
**已实现**:
|
|
204
|
+
- 自动沉淀 + 双层去重 + 日配额
|
|
205
|
+
- CJK 检索 + 图谱 + 召回工具
|
|
206
|
+
- 交互图谱(图例/时间维/框选/删除合并/导出)
|
|
207
|
+
- 知识卡管理(MD渲染/折叠/新角标/搜索高亮/无限滚动)
|
|
208
|
+
- 备份导入导出(MD/JSON)
|
|
209
|
+
- **沉淀预筛**(skip LLM)+ **召回相关性/截断**(v0.4.3)
|
|
210
|
+
|
|
211
|
+
**待办(核心功能优化)**:
|
|
212
|
+
- [ ] **上下文压缩**:把「加法记忆」升级为「召回替代 + 会话内压缩」(需 harness 配合,记忆侧提供压缩产物接口)
|
|
213
|
+
- [ ] **会话级 token 预算**:逼近阈值触发压缩/轮换,而非每轮 LLM
|
|
214
|
+
- [ ] **语义召回升级**:可选 embedding(默认零依赖 bigram + LLM 判定兜底),召回更精
|
|
215
|
+
- [ ] **多 Vault / 多 Profile**:按项目/场景分库,互不干扰
|
|
216
|
+
- [ ] **自动归档整理**:低频大扫除,合并同类、标记陈旧(非破坏性,先预览)
|
|
217
|
+
- [ ] **注入体积可配置**:每卡摘要长度、召回条数、是否带正文,做成设置项
|
|
218
|
+
- [ ] **召回用户反馈**:对命中结果「有用/无关」打标,逐步调优相关性
|
|
219
|
+
- [ ] **每日记忆回顾**:一键回顾当天沉淀 + 用量统计
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 📦 发布记录
|
|
224
|
+
|
|
225
|
+
- **v0.4.3**:记忆侧**省 token/提质量**——沉淀预筛(无可复用信号直接跳过、不触发 LLM);召回按 `minScore` 过滤弱命中、注入片段截断到 130 字。
|
|
226
|
+
- **v0.4.2**:修复 GitHub/npm 顶部演示 GIF 无法显示(压缩至 README 10MB 阈值以下,8MB)。
|
|
227
|
+
- **v0.4.1**:Marketplace 收录标准落地(`dsh.marketplace` 元数据 + 自动扫描规则说明)。
|
|
228
|
+
- **v0.4.0**:图谱交互全面增强(图例过滤/时间维/右键菜单/框选/删除合并/导出PNG另存自选位置)+ 知识卡增强(MD渲染/长卡折叠/新角标/搜索高亮/删除/无限滚动)+ 相似度关联 + 导入导出 + 顶部绿红 toast。
|
|
229
|
+
- **v0.3.0**:知识图谱科学布局(多环径向/主干边/默认仅枢纽标签/大图关发光)。
|
|
230
|
+
- **v0.2.x**:GitHub 源安装修复、安装说明跨平台化/去 npx、分类扩展(工具/教训)、peer 依赖放宽。
|
|
231
|
+
- **v0.1.0**:首个可用版本(自动沉淀 + 召回工具 + Markdown Vault + CJK 检索 + 图谱 + 设置页)。
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 📄 License
|
|
236
|
+
|
|
237
|
+
MIT
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
> **让 DSH 真正记住你:对话自动沉淀,知识随手可查。** ⭐ 觉得有用就点个 Star,Let's make AI not forget.
|
package/index.js
CHANGED
|
@@ -188,11 +188,12 @@ export function apply(ctx, config) {
|
|
|
188
188
|
const query = String(args.query || '').trim()
|
|
189
189
|
if (!query) return '(未提供检索词)'
|
|
190
190
|
const limit = Math.min(Math.max(Number(args.limit) || 5, 1), 20)
|
|
191
|
-
const hits = await search(vaultDir(), query, { limit })
|
|
191
|
+
const hits = await search(vaultDir(), query, { limit, minScore: 2 })
|
|
192
192
|
if (hits.length === 0) return `记忆库中没有与「${query}」相关的内容。`
|
|
193
193
|
const lines = hits.map((h, i) => {
|
|
194
194
|
const tags = h.tags.length ? ` [${h.tags.join(', ')}]` : ''
|
|
195
|
-
|
|
195
|
+
const snippet = String(h.summary || '').replace(/\s+/g, ' ').trim().slice(0, 130)
|
|
196
|
+
return `### ${i + 1}. ${h.title}${tags}\n路径:${h.path}\n${snippet}`
|
|
196
197
|
})
|
|
197
198
|
return `从记忆核心检索到 ${hits.length} 条相关卡片:\n\n${lines.join('\n\n')}`
|
|
198
199
|
},
|
package/lib/capture.js
CHANGED
|
@@ -19,6 +19,19 @@ export const DEDUP_THRESHOLD = 0.62
|
|
|
19
19
|
/** 参与语义去重的近邻卡片数上限(控制 token)。 */
|
|
20
20
|
export const DEDUP_NEIGHBORS = 8
|
|
21
21
|
|
|
22
|
+
// 沉淀预筛:仅当对话含「可复用」信号时才调用 LLM,避免对纯闲聊/寒暄发起昂贵的 LLM 判定。
|
|
23
|
+
const DURABLE_SIGNALS = /(#{1,3}\s|```|\[\[|\]|\(https?:|\.(md|ts|js|py|json|yml|yaml|sh|sql)\b|`|\b\d{2,}\b|选择|决定|采用|方案|结论|原因|根因|问题|解决|修复|报错|错误|教训|架构|设计|配置|部署|流程|步骤|算法|原理|函数|接口|参数|命令|依赖|版本|坑|踩|优化|性能|数据库|索引|模型|token|推荐|偏好|约定|规范)/
|
|
24
|
+
|
|
25
|
+
/** 判断一段对话是否值得送 LLM 判定(省 token 的启发式预筛)。 */
|
|
26
|
+
export function looksDurable(text) {
|
|
27
|
+
const t = String(text || '')
|
|
28
|
+
if (t.trim().length < 120) return false
|
|
29
|
+
if (DURABLE_SIGNALS.test(t)) return true
|
|
30
|
+
// 列表/编号密度:≥2 个列表项且有一定长度 => 大概率是结构化知识
|
|
31
|
+
const items = (t.match(/(^|\n)\s*[-*]\s+/gm) || []).length + (t.match(/(^|\n)\s*\d+[.、)]\s+/gm) || []).length
|
|
32
|
+
return items >= 2 && t.trim().length >= 160
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
/**
|
|
23
36
|
* 用当前模型把一段对话压缩成知识卡(或判定不值得保存 / 应追加到已有卡)。
|
|
24
37
|
* @param llm - dsh 的 llm 服务(ctx.get('llm'))
|
|
@@ -30,6 +43,7 @@ export const DEDUP_NEIGHBORS = 8
|
|
|
30
43
|
export async function summarizeTurn(llm, route, conversation, opts = {}) {
|
|
31
44
|
const text = String(conversation || '').trim()
|
|
32
45
|
if (text.length < 120) return null // 太短,没有沉淀价值
|
|
46
|
+
if (!looksDurable(text)) return null // 启发式预筛:无可复用信号则跳过 LLM 判定(省 token)
|
|
33
47
|
|
|
34
48
|
const existing = Array.isArray(opts.existing) ? opts.existing.slice(0, DEDUP_NEIGHBORS) : []
|
|
35
49
|
const existingBlock = existing.length
|
package/lib/vault.js
CHANGED
|
@@ -270,8 +270,8 @@ export async function appendUpdate(root, rel, updateText, { threshold = 0.62 } =
|
|
|
270
270
|
return { ok: true, path: rel, kind: meta.kind || 'knowledge', updated: now }
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
/** 检索:整词/中文 bigram 命中 path + 正文。返回卡片摘要(带命中度)。 */
|
|
274
|
-
export async function search(root, query, { limit = 30 } = {}) {
|
|
273
|
+
/** 检索:整词/中文 bigram 命中 path + 正文。返回卡片摘要(带命中度)。minScore 过滤弱命中。 */
|
|
274
|
+
export async function search(root, query, { limit = 30, minScore = 0 } = {}) {
|
|
275
275
|
const q = String(query || '').trim()
|
|
276
276
|
if (!q) return []
|
|
277
277
|
const cards = await listCards(root)
|
|
@@ -290,7 +290,7 @@ export async function search(root, query, { limit = 30 } = {}) {
|
|
|
290
290
|
for (const term of wanted) {
|
|
291
291
|
if (haystack.includes(term.toLowerCase())) score += 1
|
|
292
292
|
}
|
|
293
|
-
if (score > 0) {
|
|
293
|
+
if (score > 0 && score >= minScore) {
|
|
294
294
|
out.push({ ...card, score })
|
|
295
295
|
}
|
|
296
296
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-memory-eternal",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|