dsh-trivium 0.2.0 → 0.4.0
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 +122 -79
- package/lib/client.js +1443 -2
- package/lib/episode.js +278 -0
- package/lib/extract.js +39 -7
- package/lib/index.js +127 -39
- package/lib/markdown.js +359 -0
- package/lib/pins.js +155 -0
- package/lib/schema.js +5 -0
- package/lib/server.js +113 -0
- package/lib/settings.js +26 -0
- package/lib/store.js +36 -8
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,112 +1,155 @@
|
|
|
1
|
-
# dsh-trivium
|
|
1
|
+
# dsh-trivium — DSH 进程内图记忆
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness 的跨会话图记忆插件:按节点和边记,默认少注入,设置页可改可归档。会话标题栏多一个 **会话图**:compaction 收成方框,可从检查点 fork,可选记忆芯片钉进下一轮。每个工作区一个 `.dsh/trivium.tdb`,不另起服务。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **快速安装**:`dsh plugin --profile web add dsh-trivium` → 重启 **dsh web** → 打开工作区(设置里出现「Trivium 记忆」,对话旁出现「会话图」)。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 安装
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
> 前提:已安装 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 并至少启动过一次 `dsh web`。当前在 `@deepseek-ai/dsh@0.1.0-rc.6` 上测试。
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
```sh
|
|
14
|
+
dsh plugin --profile web add dsh-trivium
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
重启 **dsh web** 后生效。记忆文件在当前工作区:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
<workspace>/.dsh/trivium.tdb
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
用 [Dsh_BatStart](https://github.com/QWQcool/Dsh_BatStart) 的,双击启动就会装上,不必再执行上面这条。
|
|
24
|
+
|
|
25
|
+
本地跟源码联调:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install
|
|
29
|
+
node scripts/link-dsh.mjs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
然后重启 `dsh web`。
|
|
33
|
+
|
|
34
|
+
## 更新
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
dsh plugin --profile web add dsh-trivium
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
装完重启 **dsh web**。源码联调则在仓库里 `git pull` 后再跑一次 `node scripts/link-dsh.mjs`。
|
|
41
|
+
|
|
42
|
+
## AI 时代安装
|
|
43
|
+
|
|
44
|
+
把下面这句话复制给助手即可:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
请在 DeepSeek Harness 上执行:dsh plugin --profile web add dsh-trivium
|
|
48
|
+
然后重启 dsh web。设置里会出现「Trivium 记忆」,会话标题栏「对话 / 轨迹」旁会出现「会话图」。
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
14
52
|
|
|
15
|
-
|
|
53
|
+
## 做什么
|
|
54
|
+
|
|
55
|
+
- **跨会话** — 会话 A 记下「鉴权走 header X」,会话 B 调用 `ctx_find("鉴权")` 命中,并带上它连着谁(`about` / `decided` / `broke` / `fixed`)。
|
|
56
|
+
- **默认安静** — 新会话只注入一张短地图(≤400 token)。模型要用再调工具,不会每一步灌满。
|
|
57
|
+
- **会话图** — compaction 切一段就收成一个方框;点方框用 DSH 原生 fork 开分支;勾选的记忆芯片从当前这段的下一轮注入。
|
|
58
|
+
- **人能改错** — 设置 → Trivium 记忆:搜、看邻居、改名 / 正文、合并、归档或删除。
|
|
59
|
+
- **抽取偏严** — 闲聊、一次性改文件、密钥不入库。
|
|
60
|
+
- **可选 embedding** — 默认关。官方 DeepSeek 对话接口没有 embeddings;可填 OpenAI 兼容地址。
|
|
61
|
+
|
|
62
|
+
### 四个工具
|
|
63
|
+
|
|
64
|
+
| 工具 | 说明 |
|
|
16
65
|
|---|---|
|
|
17
|
-
| `ctx_find` |
|
|
18
|
-
| `ctx_read` |
|
|
19
|
-
| `ctx_remember` |
|
|
20
|
-
| `ctx_link` |
|
|
66
|
+
| `ctx_find` | 检索,返回摘要和图路径 |
|
|
67
|
+
| `ctx_read` | 按 id 读全文和入边 |
|
|
68
|
+
| `ctx_remember` | 手动写入 |
|
|
69
|
+
| `ctx_link` | 两点之间建有向边 |
|
|
21
70
|
|
|
22
|
-
|
|
71
|
+
内核仍是这四个。会话图不加第五个工具。
|
|
23
72
|
|
|
24
|
-
|
|
73
|
+
---
|
|
25
74
|
|
|
26
|
-
##
|
|
75
|
+
## 会话图
|
|
27
76
|
|
|
28
|
-
|
|
77
|
+
入口:当前会话标题栏 **对话 / 轨迹 / 会话图**。这是情节图,不是记忆编辑器;改错的节点仍走设置页。
|
|
29
78
|
|
|
30
|
-
|
|
31
|
-
|---|---|---|---|---|---|---|
|
|
32
|
-
| Extra process | No (napi `.tdb` in-process) | — | Usually no | Often Python / indexer | Often a service + richer stack | Heavier local stack |
|
|
33
|
-
| What is stored | Nodes + labelled edges (entity / preference / decision / experience) | Session only | Documents or snippets | Markdown + `[[links]]` | Layered memory schema | Rich items + UI |
|
|
34
|
-
| How it enters the window | Short map ≤400 tokens; tools to drill; recall **off** (optional auto / entity-name inject) | Prompt / tools | Often dump or search | Follow links | Pre-step / layered load | Sidebar + recall |
|
|
35
|
-
| Graph | Engine edges (`about` / `decided` / `broke` / `fixed`); find returns **path** | None | Rare | Scan `[[slug]]` | Depends on product | UI-first |
|
|
36
|
-
| Human correction | Settings: search, neighbors, edit/rename, merge, archive vs delete, JSON export/import | — | Varies | Edit files | Product UI | Full workbench |
|
|
37
|
-
| First-period non-goals | Graph canvas, fifth tool, default auto-recall, local embedding | — | Feature-list race | 9-tool Python vectors | LoCoMo / parse farm / Skill hub | UI completeness |
|
|
79
|
+
### 方框
|
|
38
80
|
|
|
39
|
-
|
|
81
|
+
- 没压过上下文:只有一个「后续」方框。
|
|
82
|
+
- 一次成功的 compaction 之后:左边历史检查点(摘要来自 DSH),右边仍是「后续」。
|
|
83
|
+
- 方框自己不压缩。质量来自 DSH 已经做的摘要替换;fork 时不会再总结一遍。
|
|
84
|
+
- 「改名」只改方框标题,不动 DSH 摘要。点方框可跳回对话里对应的检查点,或打开轨迹。
|
|
40
85
|
|
|
41
|
-
|
|
86
|
+
### 分叉
|
|
42
87
|
|
|
43
|
-
|
|
88
|
+
点方框上的分叉图标,会弹出「分叉为新会话」。这个名字会出现在左侧会话列表里(默认是源标题加 `(1)`)。
|
|
44
89
|
|
|
45
|
-
|
|
46
|
-
- Empty workspace: same queries, no durable preference (plugin still loaded).
|
|
47
|
-
- Extract whitelist: chitchat, one-shot “edit this file”, secrets, and the word `鉴权` as an entity stay out.
|
|
48
|
-
- Stale `until` hidden unless the query is about the deadline (`周五` / `下周`).
|
|
49
|
-
- Settings: filter by entity, stale toggle, archive then find misses; edit name/text, merge same-type nodes, export/import JSON.
|
|
50
|
-
- Optional remote embedding stays off until a URL is saved; no local model.
|
|
51
|
-
- Failure isolation: a broken `.tdb` path does not kill the agent loop.
|
|
90
|
+
确认后走宿主的 `session.fork`:子会话出现在侧边栏,前缀(含当时已经压过的摘要)由 DSH 拷过去。有检查点时从那个检查点切开;只有「后续」时就从你点的那个方框连出去。
|
|
52
91
|
|
|
53
|
-
|
|
92
|
+
对话页里用 DSH 自带 fork,切回会话图也能看到对应分支。侧边栏归档一个子会话后,图上的分叉方框会跟着消失;取消归档会再出现。
|
|
54
93
|
|
|
55
|
-
|
|
94
|
+
画布:空白处拖动平移,滚轮缩放。
|
|
56
95
|
|
|
57
|
-
|
|
58
|
-
- **Cheap by default.** Short map budget 400; no per-step recall; Trajectory shows `dsh-trivium` as plugin inject.
|
|
59
|
-
- **One file, one process.** Install is a profile junction / `dsh plugin add`; memory is `<workspace>/.dsh/trivium.tdb`.
|
|
60
|
-
- **Visible and reversible.** Settings can edit, merge, archive vs delete, and export/import JSON; find ignores archived nodes.
|
|
61
|
-
- **Honest degradation.** Keyword + graph walk by default. Optional remote embedding; extract / TDB / embed errors log and continue.
|
|
96
|
+
### 记忆芯片
|
|
62
97
|
|
|
63
|
-
|
|
98
|
+
会话图顶部可展开勾选。列出未归档的 preference / decision / entity(experience 不进芯片,避免太吵)。
|
|
64
99
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- **Old dirty rows stay.** Settings can edit or archive them; we do not auto-wipe a workspace library.
|
|
100
|
+
| 操作 | 生效时机 |
|
|
101
|
+
|---|---|
|
|
102
|
+
| 勾上某条 | 当前这段里你再发的**下一条**带上它(L0,≤300 token) |
|
|
103
|
+
| 取消勾选 | 再下一轮不再带 |
|
|
104
|
+
| 已经发出去的轮次 | 不回写 |
|
|
71
105
|
|
|
72
|
-
|
|
106
|
+
芯片按会话隔离。新开会话、fork 出的子会话默认都不勾;需要的话在分叉对话框旁打开「分叉时继承钉选」,或到子会话里重新勾。短地图仍在 session-start 自动带,不占芯片位。建议标记只是提示,不会自动勾上。
|
|
73
107
|
|
|
74
|
-
|
|
108
|
+
---
|
|
75
109
|
|
|
76
|
-
|
|
77
|
-
cd dsh-trivium
|
|
78
|
-
npm install
|
|
79
|
-
node scripts/link-dsh.mjs
|
|
80
|
-
```
|
|
110
|
+
## 界面截图
|
|
81
111
|
|
|
82
|
-
|
|
112
|
+
以下都是本机 DSH Web(rc.6)里的实测画面。
|
|
83
113
|
|
|
84
|
-
|
|
114
|
+
### 会话 — `ctx_find("鉴权")`
|
|
85
115
|
|
|
86
|
-
|
|
87
|
-
dsh plugin --profile web add /absolute/path/to/dsh-trivium
|
|
88
|
-
```
|
|
116
|
+

|
|
89
117
|
|
|
90
|
-
|
|
118
|
+
会话开头注入 `dsh-trivium` 短地图;模型调用 `ctx_find`,命中「本仓库鉴权走 header X」。
|
|
91
119
|
|
|
92
|
-
|
|
120
|
+
### 轨迹 — 上下文注入可见
|
|
93
121
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+

|
|
123
|
+
|
|
124
|
+
### 设置 — 注入策略
|
|
125
|
+
|
|
126
|
+

|
|
127
|
+
|
|
128
|
+
### 设置 — 记忆条目
|
|
129
|
+
|
|
130
|
+

|
|
131
|
+
|
|
132
|
+
### 会话图 — 对话 / 轨迹旁的第三标签
|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
136
|
+
标题栏出现「会话图」。没压过的会话只有一个「后续」方框;顶部是记忆芯片(默认不勾)。compaction 之后左边出现历史方框,分叉从方框连到子会话。
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 限制
|
|
141
|
+
|
|
142
|
+
- 模型不调 `ctx_find`、也不勾芯片时,窗口里主要是开场短地图。
|
|
143
|
+
- 抽取会漏;脏数据要在设置里改或归档。
|
|
144
|
+
- 同一个 `.tdb` 不要两个 Node 进程同时打开(正常只开一个 `dsh web` 即可)。
|
|
145
|
+
- Markdown 导出是给人看的,不能再解析回去。WorkBuddy 导入是一次性,不是双向同步。
|
|
146
|
+
- 会话图只投影 compaction 与 fork,不会按消息条数自己切方框。
|
|
147
|
+
- 改插件设置后需要重启 `dsh web`。
|
|
148
|
+
|
|
149
|
+
---
|
|
109
150
|
|
|
110
|
-
##
|
|
151
|
+
## 发布信息
|
|
111
152
|
|
|
112
|
-
|
|
153
|
+
- GitHub: https://github.com/QWQcool/dsh-trivium
|
|
154
|
+
- npm: [`dsh-trivium`](https://www.npmjs.com/package/dsh-trivium)
|
|
155
|
+
- License: MIT(依赖 [TriviumDB](https://github.com/TriviumDB/triviumdb) 为 Apache-2.0)
|