dsh-dot-life 0.19.0 → 0.20.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.en.md +3 -2
- package/README.md +6 -5
- package/docs/DESIGN.md +24 -0
- package/docs/SETTINGS.md +10 -4
- package/docs/interlude.md +1 -1
- package/docs/memory.md +94 -102
- package/docs/prompts.md +3 -1
- package/package.json +1 -1
- package/scripts/prompts.mjs +14 -9
- package/src/computer/backends/microsandbox.js +4 -4
- package/src/computer/subprocess.js +32 -8
- package/src/computer/vm.js +8 -3
- package/src/dot/core.js +76 -4
- package/src/dot/doctor.js +186 -0
- package/src/dot/panel.js +9 -5
- package/src/memory/memory.js +253 -218
- package/src/memory/recall.js +149 -126
- package/src/memory/store.js +195 -203
- package/src/memory/when.js +75 -0
- package/src/phone/phone.js +65 -13
- package/src/prompts/dot.approval-timeout.txt +1 -1
- package/src/prompts/dot.rules.txt +2 -2
- package/src/prompts/dot.setup-done.txt +1 -0
- package/src/prompts/dot.setup.txt +2 -0
- package/src/prompts/interlude.play.txt +1 -1
- package/src/prompts/interlude.round.phase.follow-up.txt +1 -1
- package/src/prompts/interlude.round.refresh.txt +1 -1
- package/src/prompts/interlude.round.txt +1 -1
- package/src/prompts/memory.diary.txt +6 -0
- package/src/prompts/memory.extract.input.txt +7 -12
- package/src/prompts/memory.extract.txt +13 -19
- package/src/prompts/memory.handoff.txt +1 -5
- package/src/prompts/memory.recall.header.txt +1 -1
- package/src/prompts/memory.standing.txt +2 -2
- package/src/prompts/phone.device.number.txt +1 -1
- package/src/prompts/memory.extract.diary-no.txt +0 -1
- package/src/prompts/memory.extract.diary-yes.txt +0 -1
- package/src/prompts/memory.extract.earlier.txt +0 -1
- package/src/prompts/memory.extract.handoff-no.txt +0 -1
- package/src/prompts/memory.extract.handoff-yes.txt +0 -1
package/README.en.md
CHANGED
|
@@ -28,7 +28,7 @@ Between your conversations, she keeps living.
|
|
|
28
28
|
- 📱 **A real phone** — the plugin downloads, builds and boots an Android emulator (no Java / Android Studio). No app store: **she installs her own apps**.
|
|
29
29
|
- 💬 **Her own QQ** — NapCat or SnowLuma (OneBot 11), same account as on her phone. Your message wakes her in **1–2 s**; she replies in several short messages and sends stickers.
|
|
30
30
|
- 🌙 **A life between conversations** — the interlude, ported from [HDS-Interlude](https://github.com/REcklessNOLOve117/HDS-Interlude): she writes down her days, keeps intents, goes to look at what she's curious about, and sometimes has a real reason to message you.
|
|
31
|
-
- 🧠 **Memory** —
|
|
31
|
+
- 🧠 **Memory** — the words are the evidence, three short notes hold what stays true: every time she wakes, the past turns that bear on it (vector + BM25 candidates, reranked on your machine) come back to her by date; what she knows about you, about herself and what is not over yet is a small note; one card per person. Handoff at 150k tokens, a diary every night at 23:30.
|
|
32
32
|
- 🎮 **She browses and plays** — likes, comments and follows in the apps she installed herself. How much is her own habit, not a quota.
|
|
33
33
|
- 🖥️ **An optional computer** — a bundled microVM (no Docker): shell, browser, desktop, live view, approval gates, audit log.
|
|
34
34
|
|
|
@@ -56,6 +56,7 @@ Web: `dsh plugin --profile web add dsh-dot-life`. From source: use `github:Kevin
|
|
|
56
56
|
Then, in dsh:
|
|
57
57
|
|
|
58
58
|
```text
|
|
59
|
+
/dot doctor # check this machine first: virtualization, disk, memory, ports, downloads (with fixes)
|
|
59
60
|
/phone accept # accept the Android SDK license; the phone installs itself (~2 GB)
|
|
60
61
|
/interlude preset 6QA0-1PD6 # import an HDSI persona from typ0.space
|
|
61
62
|
/qq install → /qq account <alt account> → /qq start → /qq qr
|
|
@@ -111,7 +112,7 @@ flowchart LR
|
|
|
111
112
|
| **`phone`** | Android emulator exposed as `mcp__dot-phone__*` via [mobile-mcp](https://github.com/mobile-next/mobile-mcp) · [docs](docs/phone.md) | `DSH_DOT_PHONE=off` |
|
|
112
113
|
| **`interlude`** | Canon persona, script, continuity, intents, read-only looking, optional proactive contact · [docs](docs/interlude.md) | `DSH_DOT_INTERLUDE=off` |
|
|
113
114
|
| **`qq`** | Her QQ inside the computer VM, same account as her phone · [docs](docs/qq.md) | `DSH_DOT_QQ=off` |
|
|
114
|
-
| **`memory`** |
|
|
115
|
+
| **`memory`** | Transcript + auto-recall (local multilingual-e5-small + bge-reranker-base; SiliconFlow / DashScope optional), three notes (about you / herself / not over yet), people cards, diary, handoff · [docs](docs/memory.md) | `DSH_DOT_MEMORY=off` |
|
|
115
116
|
| **`dot`** | Scheduled results → IM, approval and device notices, working rules, sidebar status panel | `DSH_DOT_CONTACT=off` |
|
|
116
117
|
| **`computer`** | Bundled microVM ([microsandbox](https://github.com/zerocore-ai/microsandbox)) or Docker · [docs](docs/computer.md) | `DSH_DOT_COMPUTER=off` |
|
|
117
118
|
|
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ NapCat / SnowLuma(OneBot 11)和她手机上同一个账号。你发消息 **
|
|
|
50
50
|
<td valign="top">
|
|
51
51
|
|
|
52
52
|
### 🧠 记得你,也记得她遇到的人
|
|
53
|
-
|
|
53
|
+
原话负责证据,三栏笔记负责长期状态:每次被叫醒,相关的旧原话(向量 + BM25 候选,本机重排)按日期翻到她面前;关于你、她自己、还没了的事记在一份小笔记里;每个人一张卡。15 万 token 交班,每天 23:30 写日记。
|
|
54
54
|
|
|
55
55
|
</td>
|
|
56
56
|
</tr>
|
|
@@ -108,6 +108,7 @@ dsh plugin --profile desktop add github:Kevinwu901113/dsh-dot # 源码
|
|
|
108
108
|
然后在 dsh 里:
|
|
109
109
|
|
|
110
110
|
```text
|
|
111
|
+
/dot doctor # 先体检这台电脑:虚拟化、磁盘、内存、端口、下载源,有问题直接给修复命令
|
|
111
112
|
/phone accept # 接受 Android SDK 许可,手机开始自己装(约 2 GB;/phone accept 32 给 32 GB 存储)
|
|
112
113
|
/interlude preset 6QA0-1PD6 # 从 typ0.space 导入一份 HDSI 人设,换成你喜欢的分享码
|
|
113
114
|
/qq install → /qq account <小号> → /qq start → /qq qr # 她用手机摄像头扫码登录电脑 QQ
|
|
@@ -116,7 +117,7 @@ dsh plugin --profile desktop add github:Kevinwu901113/dsh-dot # 源码
|
|
|
116
117
|
<details>
|
|
117
118
|
<summary><b>第一次设置的完整说明</b></summary>
|
|
118
119
|
|
|
119
|
-
1. **手机**:`/phone accept` 后插件下载模拟器、platform-tools
|
|
120
|
+
1. **手机**:`/phone accept` 后插件下载模拟器、platform-tools、系统镜像(约 2 GB,常见 10–30 分钟;进度在 `/phone` 和 dsh-dot 面板里),装完自动开机,桌面出现手机窗口,她会自己跟你说一声。装的过程中照常聊天,她不会等。存储大小建好后不能再改。`/phone` 看状态。
|
|
120
121
|
2. **装 App、登录**:在手机窗口里像真手机一样操作,或者让她自己装(`mobile_install_app` 会弹审批)。登录、验证码、人脸由你亲手过,她遇到会停下来叫你。**用小号**,各平台条款都不允许自动化。
|
|
121
122
|
3. **人设**:`/interlude preset <分享码>`,或把 [`examples/canon.minase-style.json`](examples/canon.minase-style.json) 放到 `~/dot/interlude/canon.json`。
|
|
122
123
|
4. **她逛什么**:不用配。常见社区 App 的站点 → 包名表是内置的,只对她**自己装了**的 App 生效。其他 App 在 `cordis.patch.yml` 里给 `dot-interlude` 加 `phoneApps` / `playApps`。
|
|
@@ -165,7 +166,7 @@ flowchart LR
|
|
|
165
166
|
phone -->|通知叫醒| session
|
|
166
167
|
qq -->|1–2 s 叫醒| session
|
|
167
168
|
interlude -->|去看 · 玩 · 主动联系| session
|
|
168
|
-
memory
|
|
169
|
+
memory -->|笔记 + 召回注入| session
|
|
169
170
|
session -->|mcp__dot-phone__*| phone
|
|
170
171
|
session -->|mcp__dot-vm__*| computer
|
|
171
172
|
qq -.运行在.-> computer
|
|
@@ -176,7 +177,7 @@ flowchart LR
|
|
|
176
177
|
| **`phone`** 📱 | Android 模拟器,以 `mcp__dot-phone__*` 暴露([mobile-mcp](https://github.com/mobile-next/mobile-mcp) 走 adb);任何 App 的通知都能叫醒她 · [文档](docs/phone.md) | 硬件虚拟化 | `DSH_DOT_PHONE=off` |
|
|
177
178
|
| **`interlude`** 🌙 | 幕间:Canon 人设、剧本、连续性、打算、只读的「去看」、可选的主动联系 · [文档](docs/interlude.md) | — | `DSH_DOT_INTERLUDE=off` |
|
|
178
179
|
| **`qq`** 💬 | 她电脑 VM 里的 QQ,和手机同号;`qq_send` 回复、表情包 · [文档](docs/qq.md) | computer | `DSH_DOT_QQ=off` |
|
|
179
|
-
| **`memory`** 🧠 |
|
|
180
|
+
| **`memory`** 🧠 | 原话库 + 自动召回(本机 multilingual-e5-small + bge-reranker-base,可切 SiliconFlow / DashScope);三栏笔记(关于你 / 她自己 / 还没了的事);人物卡;日记;15 万 token 交班 · [文档](docs/memory.md) | — | `DSH_DOT_MEMORY=off` |
|
|
180
181
|
| **`dot`** ◎ | 定时结果 → IM、审批与设备提醒、工作规则、右侧栏状态面板 | [dsh-im](https://github.com/xmanrui/dsh-im) | `DSH_DOT_CONTACT=off` |
|
|
181
182
|
| **`computer`** 🖥️ | 自带 microVM:shell、浏览器、桌面、实时画面、审批、审计 · [文档](docs/computer.md) | [microsandbox](https://github.com/zerocore-ai/microsandbox)(自带)或 Docker | `DSH_DOT_COMPUTER=off` |
|
|
182
183
|
|
|
@@ -236,7 +237,7 @@ flowchart LR
|
|
|
236
237
|
|
|
237
238
|
- **电脑组件开着时会改全局设置**:subprocess provider 换成虚拟机里的、`sandbox-policy` 设为 `danger-full-access`(虚拟机才是隔离边界)、权限预设改写成 `computer` / `computer-auto`。所以不要同时装别的沙箱 / subprocess / 权限预设插件;要用就 `DSH_DOT_COMPUTER=off`。
|
|
238
239
|
- **MCP 工具名有命名空间**:`mcp__dot-vm__*`、`mcp__dot-phone__*`,前缀定义在 `src/tool-prefixes.js`。
|
|
239
|
-
- **记忆共存**:`DSH_DOT_MEMORY_COEXIST` 默认 `auto`,发现 `hermesMemory` / `autoMemory` / `dshMemory` / `memoryBank` 等就切到 `people-only
|
|
240
|
+
- **记忆共存**:`DSH_DOT_MEMORY_COEXIST` 默认 `auto`,发现 `hermesMemory` / `autoMemory` / `dshMemory` / `memoryBank` 等就切到 `people-only`,只保留人物卡、还没了的事、日记和召回,免得两个插件一起"讲记忆"。`full` / `people-only` 可强制。
|
|
240
241
|
- **一个 QQ 号只能有一个应答者**:不要在她的号上再跑别的 OneBot 机器人。
|
|
241
242
|
- **`bash` 也过电脑闸门**:别的插件再给 `bash` 加审批,同一条命令会弹两次。
|
|
242
243
|
- **上下文压缩插件**:dsh-dot 注入的消息带固定 `source`,压缩时请保留、别当成用户原话:
|
package/docs/DESIGN.md
CHANGED
|
@@ -253,3 +253,27 @@ Kevin:"感觉现在很难给他长任务。他很容易直接结束然后就
|
|
|
253
253
|
- **记忆**:BM25 + 人名两路检索用 RRF 融合;改动的碎片替换旧的,日期写成绝对日期;使用记忆的规则(只答所问、不补细节、按记录时的状态说、不猜动机)。附 chat-memory-benchmark 适配器(`bench/`)。
|
|
254
254
|
- **提示词覆盖**记下它基于哪一版内置,内置更新后面板和 `/dot prompts` 标出,`/dot prompts rebase` 对齐。
|
|
255
255
|
- 小黑盒推广通知按通知正文(来自《…》,点击查看>>)识别。
|
|
256
|
+
|
|
257
|
+
## 0.19.1:把覆盖里修好的提示词收回内置
|
|
258
|
+
|
|
259
|
+
一位用户(作者本人)的 `~/dot/prompts` 里有 10 个覆盖,其中 6 个修的是内置本身的毛病,收回内置后覆盖可以删掉:
|
|
260
|
+
- `dot.approval-timeout`、`interlude.play`、`dot.rules`(审批那条):被拒或超时就停下这一步,只做不依赖它的事,不换渠道绕过(原来的"换别的办法"读起来像去绕审批)。
|
|
261
|
+
- `interlude.round.phase.follow-up`:给用户的追发消息写 `<contact/>`、原话进 contact 字段(原来让她在 script 里写原话,和 `interlude.round` 的约定矛盾);`interlude.round.refresh` 说清 `<contact/>` 只是标记。
|
|
262
|
+
- `interlude.round`:区分消息到达和她注意到消息。
|
|
263
|
+
- `phone.device.number`:注册用这个号,已有账号按 `account get` 的记录登录。
|
|
264
|
+
- `memory.standing`:记忆可能过时,和他现在说的冲突时以现在为准。
|
|
265
|
+
- `dot.rules`:问的是现在就能查的未来信息(天气、安排)就现在查,不建定时任务。
|
|
266
|
+
|
|
267
|
+
## 0.20.0:记忆大整理
|
|
268
|
+
|
|
269
|
+
起因:chat-memory-benchmark 上 0.19 比 0.18 多了 BM25、人名通道、取代、还没了的事、日历换算,花费从 ¥18.5 翻到 ¥37.8,分数 621 → 622(两轮各有约 50 题对错互换,差 1 题是噪声)。假模型回放量出来,整理调用占全部输入 token 的 88%,每次整理里新记录只占 2.8%,其余是每次重发的规则、碎片清单和画像;288 次里 272 次新记录不到 4 行(安静 30 分钟就触发)。外部调研(`reports/各家 agent 记忆系统设计.md`,不在仓库里)的结论相同:带时间戳的原话 + 检索(含重排)打平或超过模型抽取式记忆,抽取的 UPDATE/DELETE 基本没有收益;有证据的增益是强制检索、重排、时间锚。
|
|
270
|
+
|
|
271
|
+
一句话:原话负责证据,三栏笔记负责长期状态。
|
|
272
|
+
|
|
273
|
+
- **删**:碎片层(重要度、tag、次数、钉住、老化、300 上限、取代、`who`、`open`/`closed`);整理时附的日历和碎片清单;召回的人名通道和 RRF;交接文本(新会话只带最后 12 句原话);「安静 30 分钟就整理」;每天那次空跑的整理;人物卡上的事实和待核实队列;跑腿会话里的常驻记忆;共存检测里扫描 `node_modules`。
|
|
274
|
+
- **召回**:向量、BM25 各出 20 条候选,合并后交给重排(本机默认 `Xenova/bge-reranker-base`,向量模型之后下载;云端照旧),最多 10 条、可以更少、不凑数(`recallRerankMin` 可选门槛);没有重排时每路用对比度、交替合并。结果按日期分组(`— 06-22 周一 · 15 天前`),原话里的「明天、下周三」由代码换算(`src/memory/when.js`;月底、X 号、引号、转述、假设都不换)。`recall` 工具查同一套索引。
|
|
275
|
+
- **三栏笔记**:关于他 / 她自己 / 还没了的事。第三栏一事一条(`due`、`owed`),只在原话显示办完时 `done`;超过 800 字不截断,最不紧的挪进「先搁着的」(没答应过、没日子的先挪),栏尾常驻一行列出它们,整理时可 `restore`,`recall` 工具搜得到。
|
|
276
|
+
- **整理**:只在攒满 40 行或交班前;提示词改成规则在前(每次相同,命中缓存)、已有内容其次、新记录最后;记录里的相对日期同样由代码先换算好。
|
|
277
|
+
- **日记**:独立的一次小调用,只读当天记录,当天没记录就不调用。
|
|
278
|
+
- **迁移**:读到 0.19 的 `memory.json` 自动迁移;没进第三栏的事挪到先搁着的,其余(碎片、卡上事实、待核实)原样存 `memory.v019.json`,`memory-migration.md` 写明去向。
|
|
279
|
+
- **测量工具**:`bench/recall-coverage.py` 按基准的证据标注算召回覆盖(候选池覆盖 / 注入覆盖,按考点、多证据题、字面重合低的题分组),不调模型;bench 的 `--save-prompts` 记下每题的候选和命中时间,`DSH_BENCH_EMBED` / `DSH_BENCH_RERANK` / `DSH_BENCH_MEMORY` 选变体。
|
package/docs/SETTINGS.md
CHANGED
|
@@ -106,6 +106,8 @@ setx DSH_DOT_COMPUTER off
|
|
|
106
106
|
| `number` | `""` | 她的手机号,注册登录 App 用(也可用 `/phone number`;账号密码另存 `~/.dsh/dsh-dot-accounts.json`,见 [phone.md](phone.md)) |
|
|
107
107
|
| `window` | `true` | 显示模拟器窗口 |
|
|
108
108
|
| `gpu` | `"auto"` | 模拟器 GPU 模式。`auto` 在 API 35 上可能被强制成 CPU 软件渲染(`emulator.log` 里有 `forcing software rendering`),长时间跑会被模拟器的卡死检测杀掉;Mac 上可试 `"host"`(用 Mac 显卡),见 [phone.md](phone.md) |
|
|
109
|
+
| `quickBoot` | `false` | Quick Boot 快照(退出存、启动读)。默认关:每次冷启动,慢一些,但被强杀后不会读到写了一半的快照 |
|
|
110
|
+
| `adbPort` | `5137` | 插件自己的 adb server 端口,避开 MuMu、雷电、手机助手等自带旧 adb 占用的 5037;`0` = 用 5037 |
|
|
109
111
|
| `notifyMuted` | `[]` | 不叫醒她的包名(也可用 `/phone notify mute`) |
|
|
110
112
|
| `notifyCatchUpMs` | `43200000`(12 小时) | dsh 没开时到的通知,重启后这么久以内的照样叫醒她;更早的不叫 |
|
|
111
113
|
| `leaseIdleMs` | `120000` | 同一时间只有一件事在用手机:占着的那件事这么久没碰手机(或它这一轮结束)就让出来 |
|
|
@@ -159,13 +161,17 @@ setx DSH_DOT_COMPUTER off
|
|
|
159
161
|
| `enabled` | `true` | `false` 关掉 |
|
|
160
162
|
| `home` | `~/dot` | 和 `dot.home`、`interlude.home` 保持一致 |
|
|
161
163
|
| `handoffTokens` | `150000` | 对话多长换新会话 |
|
|
162
|
-
| `
|
|
164
|
+
| `consolidateEveryLines` | `40` | 新记录攒满多少行整理一次(交班前也整理一次) |
|
|
165
|
+
| `dailyAt` | `"23:30"` | 每天写日记的时间(当天有记录才写) |
|
|
166
|
+
| `limits` | `{ owner: 1375, self: 2200, open: 800, impression: 80, shelved: 200 }` | 三栏笔记各多少字、人物印象多少字、先搁着的最多几件 |
|
|
163
167
|
| `coexist` | `"auto"` | `auto` / `people-only` / `full` |
|
|
164
168
|
| `recallBackend` | `"local"` | `local` / `siliconflow` / `dashscope` / `off`(建议用 `/dot memory recall backend`,命令设的值优先) |
|
|
165
169
|
| `recallModel` | `""` | 本机默认 `Xenova/multilingual-e5-small`;只用中文可填 `BAAI/bge-small-zh-v1.5`(更轻,23 MB / 约 0.13 GB)。建议用 `/dot memory recall model` |
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
168
|
-
| `
|
|
170
|
+
| `recallRerankModel` | `""` | 本机默认 `Xenova/bge-reranker-base`(279 MB);`BAAI/bge-reranker-v2-m3` 更强更慢(571 MB);`none` 不重排。建议用 `/dot memory recall rerank` |
|
|
171
|
+
| `recallCandidates` / `recallTopK` / `recallMaxTokens` | `20` / `10` / `1500` | 向量、BM25 各出多少候选;重排后最多注入几条、多少 token(可以更少,不凑数) |
|
|
172
|
+
| `recallRerankMin` | `0` | 重排分(0–1)的可选门槛;0 = 只看重排的顺序 |
|
|
173
|
+
| `recallMinQueryLength` / `recallContrast` / `recallMinScore` | `4` / `0.35` / `0` | 话太少不查;不重排时,命中要比整个索引的中位数高出一截;不重排时可选的余弦下限。见 [memory.md](memory.md) |
|
|
174
|
+
| `recallLexical` | `true` | BM25 那一路候选(汉字 + 两字);`false` 只用向量 |
|
|
169
175
|
| `recallMirror` | `""` | 本机模型下载镜像,默认 hf-mirror |
|
|
170
176
|
|
|
171
177
|
### `interlude`
|
package/docs/interlude.md
CHANGED
|
@@ -40,7 +40,7 @@ dsh 这边不需要重做一个对话系统——对话由 dsh 自己跑,IM
|
|
|
40
40
|
|
|
41
41
|
0. **Canon(人设)由插件管理,不用 AGENTS.md**:`/interlude preset <分享码>` 从 HDSI 官方预设站 [typ0.space](https://typ0.space) 拉一份 `storyDefaults`(角色设定、视角、关系、配角、世界、文风、回复规则)存到 `~/dot/interlude/canon.json`,立即作为系统提示的一段注入 `~/dot` 里的每个会话(紧跟 dsh 的 persona 之后,静态,不破坏提示前缀缓存)。也可以在 `cordis.patch.yml` 的 `canon` 配置里直接写。`/interlude canon` 查看当前人设。HDSI 社区分享的任何人设因此都能直接用在 dsh 上。
|
|
42
42
|
1. **看着幕前**:记录 `~/dot` 里每一轮对话的梗概(谁发起的、用户说了什么、它最后答了什么、有没有审批)。定时任务触发的轮次也算。
|
|
43
|
-
2. **幕间一轮**:一次模型调用。模型看到:身份文件(Canon)、当前状态、最近两段剧本、她自己的笔记(`herLife`,来自 dsh-dot/memory 的 self
|
|
43
|
+
2. **幕间一轮**:一次模型调用。模型看到:身份文件(Canon)、当前状态、最近两段剧本、她自己的笔记(`herLife`,来自 dsh-dot/memory 的 self 栏:她现在真实在做的事、会的事、习惯——这段生活围着它展开,虚构只填空隙,不发明学业/工作背景)、记忆里关于他的事(memory 的"关于他"一栏)、待办的打算、这段时间幕前发生了什么、现在是星期几什么时段、距上一次幕间多久。它以**一次 `interval` 工具调用**交出这些字段(参数由 API 保证是 JSON;只写了散文的回复也收,由第二次小调用把其余字段补齐):
|
|
44
44
|
- `script`:从上次故事光标到现在,它过的日子(≤150 字,第一人称,可以和用户无关);
|
|
45
45
|
- `state`:`mood` 一句话、`now` 在做什么、`next` 接下来打算、`threads` 挂念的事;
|
|
46
46
|
- `intents`:确实要在未来某个时刻处理的事,带时间、类型(提醒 / 答应的回复 / 想联系)和意愿值;
|
package/docs/memory.md
CHANGED
|
@@ -1,148 +1,140 @@
|
|
|
1
1
|
# dsh-dot/memory:她记得的
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
一句话:**原话负责证据,三栏笔记负责长期状态。** 聊过的每一轮原样存着、带时间;她每次被叫醒,就用叫醒她的那句话把相关的原话翻出来给她看。一直要用的事(关于你、她自己、还没了的事)记在一份很小的常驻笔记里;认识的人记在一张身份表里。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## 不记的东西
|
|
5
|
+
```
|
|
6
|
+
真实事件 ──► 原话库 transcript.jsonl(每轮一条,带时间)
|
|
7
|
+
│
|
|
8
|
+
├─ 每轮建索引 ─► 向量 + BM25 ─(每次叫醒)─► 合并候选 → 重排 → ≤10 条原话(按日期分组)
|
|
9
|
+
│
|
|
10
|
+
└─ 攒满 40 行 / 交班 ─► 一次整理 ─► 三栏笔记 + 人物卡 ─(她对话的每一轮)─► <memory>
|
|
11
|
+
```
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
| | 是什么 | 谁写 | 怎么到她面前 |
|
|
14
|
+
|---|---|---|---|
|
|
15
|
+
| **原话库** | 她对话里真实发生的每一行:你的话、她真正发出去的 QQ、手机通知、跑腿的结论、定时任务 | 代码,入库不调模型 | 不直接给,召回从这里找 |
|
|
16
|
+
| **自动召回** | 每轮一块(叫醒她的话 + 她回的话 + 日期);向量和 BM25 各出候选,重排后最多 10 条 | 代码,每轮结束增量建索引 | 每次被叫醒,「你记得的相关原话」,按日期分组 |
|
|
17
|
+
| **三栏笔记** | 关于他(1375 字以内)· 她自己(2200 字以内)· 还没了的事(800 字以内,外加「先搁着的」) | 整理时由模型写;她自己用 `memory` 工具改 | 她对话的每一轮,`<memory>` |
|
|
18
|
+
| **人物卡** | 一张身份表,所有 App 共用;每人多个把手、档位、次数、一句印象 | 次数、时间、把手由代码按真实事件记;印象由模型写 | 这个人叫醒她时,跟在那条消息后面 |
|
|
19
|
+
| **日记** | 每天一篇,她的口吻,40–120 字 | 每天 `dailyAt`(23:30)单独一次调用,当天有记录才写 | 不给她,给你看(面板、`diary.md`) |
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
0.20 起删掉了:碎片层(重要度、tag、老化、钉住、取代、`who`)、整理时附的日历和碎片清单、召回的人名通道和 RRF、交接文本、「安静 30 分钟就整理」。为什么删,见文末「数据」。
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
## 原话库
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
- **模型**(整理时):记录里有证据说两张卡是同一个人,就写 `same`。不涉及你的直接合并;**涉及你的先进「待确认的合并」**,你 `/dot people approve m…` 才合(被认成你等于拿到最高信任)。
|
|
23
|
-
- **你**:`/dot people merge <a> <b>`。
|
|
25
|
+
`~/dot/memory/transcript.jsonl` 只记她对话里真实发生的:你说的话、她真正用 `qq_send` 发出去的话(发给谁;按工具结果记,记在调用的时刻:被拦下的一句不记,发到一半被他打断的只记发出去的几条,图片没发成的只记文字)、手机通知、跑腿留下的结论、定时任务。幕间写的虚构剧本不进这里,所以虚构的事不会变成「记忆」。叫醒她的消息开头带时间戳(`[11-04 04:51] …`,见 prompts.md),记进来时去掉——每行本来就有自己的时间。她对话里「现在」那行(`dot:now`)的「距上一条消息」也从这里算。
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
图:她发出去的图记成它的 ref,写法本身就能再发——`[表情包 sticker:<id>]`、`[图 phone:latest]`、`[图 <网址>]`。别人发来的图是消息里的文字:`[图片 <网址>]`。图本身(附件 id、字节)从不进原话库和索引。
|
|
26
28
|
|
|
27
|
-
##
|
|
29
|
+
## 自动召回
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
她每次被叫醒(你的消息、QQ 消息、手机通知、定时任务),在模型看到之前:
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
1. **话太少不查**(`recallMinQueryLength` 4):去掉标点后不同的汉字 / 假名 / 谚文个数 + 其他文字里不同的词数,少于 4 就不召回。`好的`、`哈哈哈哈`、`在吗?` 不查。
|
|
34
|
+
2. **两路候选**:按余弦取前 `recallCandidates`(20)轮,再按 BM25 取前 20 轮(汉字和相邻两字、其他文字按词,不用分词器;一个少见的名字、数字在 BM25 里分量很重,一句话的向量里却会被冲淡)。她当前会话里的轮次本来就在上下文里,不取。
|
|
35
|
+
3. **重排决定**:重排模型把每条候选和那句话一起读一遍打分,按分数取,最多 `recallTopK`(10)条、`recallMaxTokens`(1500)token。**可以少于 10 条,不凑数**;`recallRerankMin`(0–1,默认 0)是可选的门槛。没有重排模型(设成 `none`,或还在下载)时,两路各自只留「比大多数高出一截」的(对比度 `recallContrast` 0.35:分数 ≥ 中位数 + 0.35 ×(最高 − 中位数)),交替合并。
|
|
36
|
+
4. **按日期给她看**:每天一个标题 `— 06-22 周一 · 15 天前`,下面是那天的原话;开头写明今天是哪天。原话里「明天、后天、昨天、前天、这周X、下周X、上周X」由**代码**按那句话说的日子换算,附在后面:`下周三(=07-15)`。「月底」「X 号」「周末」、单说「周三」不换算;在引号里的、转述的(他说…、听说…)、假设的(如果…、要是…)也不换算——算错的确定日期比原话更误导。
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
只给她的对话(动态 context,dsh 放在历史之后,不破坏前缀缓存);跑腿会话看不到。密码 / key 那行不入索引、不发云端、不注入。
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
**后端**
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
| 后端 | 模型 | 要什么 | 说明 |
|
|
43
|
+
|---|---|---|---|
|
|
44
|
+
| `local`(默认) | 向量 `Xenova/multilingual-e5-small`(129 MB)+ 重排 `Xenova/bge-reranker-base`(279 MB),ONNX q8 | 不要 key | transformers.js 在 CPU 上跑。推理库 300–480 MB 不打进插件包,第一次用时装到 `$DSH_HOME/dsh-dot-recall/`;模型从 `https://hf-mirror.com` 下(`recallMirror`,也认 `HF_ENDPOINT`)。重排模型在向量模型之后下载,下好之前不重排 |
|
|
45
|
+
| `local` + 别的模型 | `recall model BAAI/bge-small-zh-v1.5`(只用中文、更轻);`recall rerank BAAI/bge-reranker-v2-m3`(571 MB,更强也更慢)或 `none` | 不要 key | BAAI 的名字自动换成它的 ONNX 版 |
|
|
46
|
+
| `siliconflow` | `BAAI/bge-m3` + `BAAI/bge-reranker-v2-m3` | key(免费档够用) | `SILICONFLOW_API_KEY` 或 `/dot memory recall key siliconflow <key>` |
|
|
47
|
+
| `dashscope` | `qwen3.7-text-embedding` + `qwen3.7-text-rerank` | key | `DASHSCOPE_API_KEY` 或 `/dot memory recall key dashscope <key>` |
|
|
48
|
+
| `off` | — | — | 不自动召回 |
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
每个后端 + 向量模型各存一份索引(`~/dot/memory/recall/<后端>-<模型>/`),来回切换不重算;换重排模型不动索引。
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
**命令**(写进 `$DSH_HOME/dsh-memory.json`,0600,优先于插件配置,不用重启):`/dot memory recall`(状态)· `backend <local|siliconflow|dashscope|off>` · `key <后端> <key>`(`-` 删掉)· `model <名字|default>` · `rerank <名字|none|default>` · `mirror <url|default>` · `rebuild` · `test <一句话>`(看会翻出什么、从几条候选里挑的)。
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
## 三栏笔记
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
- **关于他**:长期有效的事(他是谁、在做什么、喜好、雷点、称呼、长期计划)。
|
|
57
|
+
- **她自己**:学会了什么、在做的事、习惯、看法。人设不在这里(在 Canon)。幕间拿这一栏作为她的生活(`herLife`)。
|
|
58
|
+
- **还没了的事**:说过要做的、答应了的、说好先搁着的、在等别人回的。一事一条:谁、什么事、哪天说的;有明确日子就带 `due`;有人答应了别人就标「答应过」。
|
|
59
|
+
- **只在办完时删**:原话里看到办完了、取消了、对方说不用了,整理时 `done`;只是没再提不算。
|
|
60
|
+
- **满了不截断**:先由模型合并、压缩;还超出 800 字,就把最不紧的挪到**先搁着的**(没答应过、没日子的先挪,同等的先挪最早的)。答应过的、有日子的留到最后。
|
|
61
|
+
- **先搁着的不会被忘**:栏尾常驻一行「另有 N 件先搁着的:…」(最近 8 件的前几个字);整理时模型能看到它们、可以 `restore`;`recall` 工具也搜得到;相关的话一提起,原话会被召回。搁着的最多留 200 件。
|
|
48
62
|
|
|
49
|
-
|
|
63
|
+
笔记每轮都在她面前,所以要小:只记一直要用的和还没了的;一次性的事不记,原话会留着。
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
2. 整理一次,并让模型写交接:她此刻在做什么、手上没做完的、答应过的、还没问清的;
|
|
53
|
-
3. **先归档**旧会话(归档后的会话收到消息会静默丢弃,所以必须先归档、再切换);
|
|
54
|
-
4. 在 `~/dot` 里开新会话「dot · 第 N 段」,交接文本加最后 12 句原话注入进去(不叫醒她);
|
|
55
|
-
5. 解冻,排队的消息投进新会话。
|
|
65
|
+
## 认识的人
|
|
56
66
|
|
|
57
|
-
|
|
67
|
+
一张身份表:每个人一张卡,卡上有多个「把手」——`qq:919231551`(有号码时)、`qq:name:宽`(手机通知只显示名字时)、`xiaoheihe:name:暮看云`……不管从哪个 App 来,都先在这张表里认人。档位:你 / 聊过 / 只在帖子里打过交道 / 好友列表里没说过话。卡上只有:名字、把手、档位、各类互动次数、上次出现、**一句印象**(80 字以内:她怎么认识的、对方是什么样的人)。对方说过什么、做过什么不抄在卡上——原话里有,提到时召回。
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
认出是同一个人就合并:**QQ 好友列表**每 6 小时同步一次(她给好友的备注就是手机通知里的名字,「宽」就此和号码连上);**模型**整理时有证据就写 `same`,不涉及你的直接合并,**涉及你的要你 `/dot people approve m…`**(被认成你等于拿到最高信任);**你** `/dot people merge <a> <b>`。
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
## 整理
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
一次模型调用,读上次整理之后的记录(一次最多 `chunkLines` 80 行、`inputChars` 40000 字;积压更多就从最旧的分几次读,游标只走到真正读过的位置),输出三栏笔记的增删改、人物的印象和合并。只在两种时候发生:**新记录攒满 `consolidateEveryLines`(40)行**,或**交班**之前。`/dot memory now` 立刻整理。
|
|
64
74
|
|
|
65
|
-
|
|
66
|
-
- **不重复**:她当前会话里的轮次本来就在上下文里,不再取(`recallWindowTurns`);取 top 8(`recallTopK`),最多 1500 token(`recallMaxTokens`,超了先丢最不像的)。
|
|
67
|
-
- **哪些值得给她看**(两道过滤,都不看某个模型的分数刻度):
|
|
68
|
-
- **话太少不查**(`recallMinQueryLength` 4):叫醒她的那句话去掉标点后,不同的汉字 / 假名 / 谚文个数 + 其他文字里不同的词数,少于 4 就不召回(连关键词也不翻)。`好的`、`哈哈哈哈`、`在吗?`、`ok thanks` 都不查;`我回来了`、`阿岑会修什么?`、`What did Caroline research?` 照查。
|
|
69
|
-
- **要比大多数高出一截**(`recallContrast` 0.35):一条命中的余弦要 ≥ 中位数 + 0.35 ×(最高分 − 中位数),中位数和最高分按她整个索引(当前会话之外)算。真问题总有几轮明显高出其他;含糊的话和什么都差不多像,留不下几条。索引不到 20 轮时不用这条。云端重排之后不用这条(重排分本身就是相关度)。
|
|
70
|
-
- `recallMinScore`:可选的绝对下限,默认 0(不用)。它和模型绑死:bge-small-zh 的 0.45 到 e5 上等于不过滤,e5 上要 0.87 才有同样效果,可那样英文问题一条都留不下。
|
|
71
|
-
- **三条通道,按名次合并**(0.19):向量之外再查两次字面——
|
|
72
|
-
- **BM25**(`recallLexical`):同一批块按汉字和相邻两字(其他文字按词)算 BM25,不用分词器,生造的名字也切得开。一个少见的名字(阿兰、签名牌)在 BM25 里分量很重,一句话的向量里却会被其他字冲淡。同样用「高出一截」那条过滤(对 BM25 分数算),取前 20。
|
|
73
|
-
- **人名**(`recallNames`):她认识的人的名字(人物卡,别名算一组)和碎片 `who` 里记下的名字,消息里提到哪个(2 个字起),就把提到这一组任何一个名字的轮次拉进来,提到的组越多、越新越靠前,取前 20。问"小秦"也能找到写着"秦渡"的那轮。
|
|
74
|
-
- 三张名单用 **RRF**(每条得 1/(`recallRrfK` 60 + 名次),各通道相加)合成一张,取前 `recallTopK`,不用把余弦和 BM25 分数换成同一个刻度。云端重排时,三条通道的候选一起交给重排模型打分。两个开关都关掉就和 0.18 一样只看向量。
|
|
75
|
-
- **只给她的对话**:作为动态 context 注入(dsh 放在历史之后,不破坏前缀缓存);跑腿会话看不到。
|
|
76
|
-
- **密码 / key 不进**:和碎片同一个过滤,含密码、API key 的那行不入索引、不发给云端、不注入;问话本身像密钥时不查。
|
|
77
|
-
- **后端**:
|
|
75
|
+
**失败了不连环重试**:一次整理没拿到 JSON(例如推理模型把输出额度全用在思考上,正文是空的),游标不动,下一次的批量减半(最少 `minChunkLines` 10 行),而且要再攒满一批新记录才重试,不会每一轮都带着越积越多的记录再试一遍。成功一次就恢复原来的批量。
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|---|---|---|---|
|
|
81
|
-
| `local`(默认) | `intfloat/multilingual-e5-small`(ONNX q8,即 `Xenova/multilingual-e5-small`),不重排;中英文和约 100 种语言 | 不要 key | transformers.js 在 CPU 上跑;模型 129 MB,常驻约 0.4 GB 内存(实测 0.39–0.50 GB),一次查询约 2 ms。推理库 `@huggingface/transformers` 有 300–480 MB,不打进插件包:第一次用时装到 `$DSH_HOME/dsh-dot-recall/`(像 QQ / 手机按需 `npx` 拉 MCP 一样),模型从 `https://hf-mirror.com` 下(`recallMirror`,也认 `HF_ENDPOINT`),缓存在 `$DSH_HOME/dsh-dot-recall/models/`。第一次下模型时日志里有一行 `recall: downloading Xenova/multilingual-e5-small (~129 MB, once) from …`,`/dot memory recall` 显示 `downloading (~129 MB) 40%`;装好、下好之前按关键词找 |
|
|
82
|
-
| `local` + `BAAI/bge-small-zh-v1.5` | `Xenova/bge-small-zh-v1.5`(ONNX q8),不重排;只用中文时更轻 | 不要 key | `/dot memory recall model BAAI/bge-small-zh-v1.5`(`default` 换回 e5)。模型 23 MB,常驻约 0.13 GB,一次查询约 1.5–1.9 ms;中文基准和 e5 同分。0.15.2 之前的默认 |
|
|
83
|
-
| `siliconflow` | `BAAI/bge-m3` + `BAAI/bge-reranker-v2-m3` 重排 | key(免费档够用) | `SILICONFLOW_API_KEY` 或 `/dot memory recall key siliconflow <key>` |
|
|
84
|
-
| `dashscope` | `qwen3.7-text-embedding` + `qwen3.7-text-rerank` 重排 | key | `DASHSCOPE_API_KEY` 或 `/dot memory recall key dashscope <key>`;工作空间域名填 `recallDashscopeUrl` |
|
|
85
|
-
| `off` | — | — | 不自动召回 |
|
|
77
|
+
提示词的顺序是:规则(每次一字不差,命中服务商的前缀缓存)→ 她已有的三栏和认识的人 → 这段时间的记录。记录每行带时间(今年 `MM-DD HH:MM`,往年 `YYYY-MM-DD HH:MM`),「明天」「下周三」同样由代码换算好日期写在后面,模型照抄,不自己推算。
|
|
86
78
|
|
|
87
|
-
|
|
88
|
-
- `/dot memory recall`:后端、模型、是否就绪、索引了几轮、上次查询耗时和条数、镜像、key 来源(打码)
|
|
89
|
-
- `/dot memory recall backend <local|siliconflow|dashscope|off>`
|
|
90
|
-
- `/dot memory recall key <siliconflow|dashscope> <key>`(`-` 删掉)
|
|
91
|
-
- `/dot memory recall model <名字|default>`、`/dot memory recall rerank <名字|none|default>`(云端)
|
|
92
|
-
- `/dot memory recall mirror <url|default>`
|
|
93
|
-
- `/dot memory recall rebuild`:清掉当前后端的索引重建
|
|
94
|
-
- `/dot memory recall test <一句话>`:看这句话会翻出什么(带分数)
|
|
95
|
-
- 右侧 dot 面板「记忆」卡片里有一行「自动召回」。
|
|
79
|
+
## 日记
|
|
96
80
|
|
|
97
|
-
|
|
81
|
+
`~/dot/memory/diary.md`:每天 `dailyAt`(23:30)一篇,单独一次小调用,只读当天的记录;当天什么都没有就不写、不调用。她的口吻、第一人称、40–120 字,只写真实发生的。`/dot memory diary` 立刻写一篇。日记是给你看的,不进她的提示词,也不进召回。
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
|---|---|
|
|
101
|
-
| 0.11 现状(画像 + 碎片 + 交班 + `recall` 工具) | 74 / 108 |
|
|
102
|
-
| 纯检索:本机 bge-small-zh,不重排 | 85 / 108 |
|
|
103
|
-
| 纯检索:本机 multilingual-e5-small,不重排(0.15.2 起默认) | 85 / 108 |
|
|
104
|
-
| 纯检索:云端 bge-m3 + bge-reranker-v2-m3(SiliconFlow) | 90 / 108 |
|
|
105
|
-
| 纯检索:云端 qwen3.7 embedding + rerank(DashScope) | 89 / 108 |
|
|
106
|
-
| 0.12:现状 + 自动召回(本机 bge-small-zh,真实代码路径) | 93 / 108(`recallMinScore` 0)· 95 / 108(0.45,当时的默认) |
|
|
107
|
-
| **0.15.2:现状 + 自动召回(本机 multilingual-e5-small,真实代码路径,默认过滤:话太少不查 4 + 对比度 0.35)** | **96 / 108** |
|
|
108
|
-
| 0.15.2:同上,换成 bge-small-zh | 91 / 108 |
|
|
83
|
+
## 交班
|
|
109
84
|
|
|
110
|
-
|
|
85
|
+
她的对话会话每轮结束量一次 token。超过 `handoffTokens`(15 万)且这一段至少涨了 4 万:
|
|
111
86
|
|
|
112
|
-
|
|
87
|
+
1. 冻结投递(这期间来的消息排队);
|
|
88
|
+
2. 把还没整理的记录整理掉(三栏笔记先是最新的);
|
|
89
|
+
3. **先归档**旧会话(归档后的会话收到消息会静默丢弃);
|
|
90
|
+
4. 在 `~/dot` 里开新会话「dot · 第 N 段」,注入上一段最后 12 句原话(不叫醒她);她的笔记照常在 `<memory>` 里,更早的原话提到时召回;
|
|
91
|
+
5. 解冻,排队的消息投进新会话。
|
|
113
92
|
|
|
114
|
-
|
|
93
|
+
dsh 自己的压缩要到窗口的 80% 才发生,而且摘要模板是给编程助手写的;交班让这件事不会发生在她身上。dsh-im 机器人开的会话不交班。
|
|
115
94
|
|
|
116
|
-
|
|
117
|
-
|---|---|---|---|
|
|
118
|
-
| 不过滤 | 8 / 8 | 8(100%)/ 8 | 8 / 8 |
|
|
119
|
-
| `recallMinScore` 0.45(0.12–0.15.1) | 8 / 8 | 8(100%)/ 8 | 6.4 / 2.3 |
|
|
120
|
-
| `recallMinScore` 0.87 | 6.3 / 2.4 | 0.4(15%)/ 0 | 0 / 0 |
|
|
121
|
-
| **话太少不查(4)+ 对比度 0.35(0.15.2 默认)** | **6.2 / 0.3** | **7.8(100%)/ 0** | **7.0 / 0.3** |
|
|
95
|
+
## 从 0.19 升级
|
|
122
96
|
|
|
123
|
-
|
|
97
|
+
第一次加载旧的 `memory.json` 时自动迁移:
|
|
124
98
|
|
|
125
|
-
|
|
99
|
+
- 「还没了」的碎片 → 第三栏(`promise` 记为答应过);放不下的挪到先搁着的。
|
|
100
|
+
- 钉住的碎片 → 「关于他」,放得下的话。
|
|
101
|
+
- 其余碎片、人物卡上的事实、待核实 → 不再保留,原样存进 `~/dot/memory/memory.v019.json`(只写一次,不覆盖)。它们来自的原话都还在原话库里,提到时会被召回。
|
|
102
|
+
- `~/dot/memory/memory-migration.md` 写明每样去了哪里,尤其是**没放进第三栏、被搁着的事**。
|
|
126
103
|
|
|
127
|
-
|
|
128
|
-
|---|---|---|---|---|
|
|
129
|
-
| `multilingual-e5-small`(默认) | 129 MB | 0.39–0.50 GB | 1.0–1.4 s | 1.8–2.3 ms |
|
|
130
|
-
| `bge-small-zh-v1.5` | 23 MB | 0.12–0.13 GB | 0.55–0.68 s | 1.5–1.9 ms |
|
|
131
|
-
| `bge-m3` | 560 MB | 0.9–1.25 GB | 7–11 s | 12–24 ms |
|
|
104
|
+
召回索引不用重建。
|
|
132
105
|
|
|
133
106
|
## 文件和命令
|
|
134
107
|
|
|
135
|
-
- `~/dot/memory/memory.md`:给你看的版本;`diary.md
|
|
136
|
-
- `/dot memory
|
|
137
|
-
- `/dot
|
|
138
|
-
- `/dot people`:认识的人、待核实、待确认的合并;`approve <p…|m…>` / `drop <p…>`:处理待核实和合并;`merge <a> <b>`:手动合并两张卡;`forget <名字>`:删掉一个人。
|
|
108
|
+
- `~/dot/memory/memory.md`:给你看的版本;`memory.json`:数据;`diary.md`:日记;`transcript.jsonl`:原话库;`recall/`:索引;`handoffs.jsonl`:每次交班;`calls.jsonl`:每次整理 / 日记的原始回复和 token 用量。
|
|
109
|
+
- `/dot memory`:状态;`now`:立刻整理;`diary`:立刻写日记;`handoff`:立刻交班;`recall …`:自动召回。
|
|
110
|
+
- `/dot people`:认识的人、待确认的合并;`approve <m…>` · `merge <a> <b>` · `forget <名字>`。
|
|
139
111
|
|
|
140
112
|
## 配置(`dot-memory`)
|
|
141
113
|
|
|
142
|
-
`handoffTokens` 150000 · `minTokensBetweenHandoffs` 40000 · `consolidateEveryLines`
|
|
114
|
+
`handoffTokens` 150000 · `minTokensBetweenHandoffs` 40000 · `consolidateEveryLines` 40 · `chunkLines` 80 · `minChunkLines` 10 · `handoffTailLines` 12 · `inputChars` 40000 · `dailyAt` 23:30 · `maxTokens` 16384 · `limits: { owner: 1375, self: 2200, open: 800, impression: 80, shelved: 200 }` · `coexist` auto · `otherMemoryServices` [hermesMemory, autoMemory, dshMemory, memoryBank]
|
|
143
115
|
|
|
144
|
-
自动召回:`recallBackend` local · `recallModel` ''
|
|
116
|
+
自动召回:`recallBackend` local · `recallModel` ''(后端默认)· `recallRerankModel` ''(后端默认;`none` 不重排)· `recallMirror` '' · `recallInstall` true · `recallTransformersVersion` 4.3.2 · `recallCandidates` 20(每路)· `recallTopK` 10 · `recallMaxTokens` 1500 · `recallRerankMin` 0 · `recallMinQueryLength` 4 · `recallContrast` 0.35(不重排时)· `recallMinScore` 0(不重排时的余弦下限)· `recallLexical` true(BM25 那一路)· `recallWindowTurns` 0 · `recallChunkChars` 1200 · `recallWaitMs` 3000 · `recallSiliconflowUrl` · `recallDashscopeUrl`。命令改的值存在 `$DSH_HOME/dsh-memory.json`,优先于这里。0.19 的 `consolidateIdleMinutes`、`fragmentBudgetTokens`、`openBudgetTokens`、`agingEveryGens`、`maxFragments`、`recallNames`、`recallRrfK` 不再使用,写着也没关系。
|
|
145
117
|
|
|
146
118
|
`DSH_DOT_MEMORY=off` 整个组件不加载。
|
|
147
119
|
|
|
148
|
-
**和别的记忆插件共存**(`coexist`,环境变量 `DSH_DOT_MEMORY_COEXIST`):`auto` 时,`otherMemoryServices`
|
|
120
|
+
**和别的记忆插件共存**(`coexist`,环境变量 `DSH_DOT_MEMORY_COEXIST`):`auto` 时,`otherMemoryServices` 里任何一个服务存在(用到时用 `ctx.get` 查)就进入 `people-only`:人物卡、还没了的事、日记、交班、召回照旧,「关于他」「她自己」两栏不进系统提示,整理时这两栏的改动也丢掉,交给那个插件。`full` 强制全开;`people-only` 强制只留人物。
|
|
121
|
+
|
|
122
|
+
## 数据
|
|
123
|
+
|
|
124
|
+
**为什么整理(0.19 → 0.20)**:chat-memory-benchmark 正式卷(6 人、714 题),0.18 → 0.19 多了 BM25、人名通道、取代、还没了的事、日历换算,花费 ¥18.5 → ¥37.8,分数 621 → 622(两轮各约 50 题对错互换,差 1 题是噪声)。用假模型回放(不调模型,`--fake-llm`)量 0.19 的整理调用:占全部输入 token 的 88%;每次新记录中位数 2 行,只占整理输入的 2.8%,其余是每次重发的规则、碎片清单和画像。
|
|
125
|
+
|
|
126
|
+
**0.20 的离线测量**(同一张卷、假模型回放,只看检索,不答题;`bench/recall-coverage.py` 按基准的证据标注算:证据所在那一轮有没有进她看到的上下文。「窗口外」= 不在最后 6 轮里、只能靠召回的证据,734 条):
|
|
127
|
+
|
|
128
|
+
| | 0.19 | 0.20 不重排 | **0.20 本机重排(默认)** |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| 窗口外证据进了上下文 | 82.8% | 85.3% | **86.1%** |
|
|
131
|
+
| 候选池里有(重排能达到的上限) | — | 92.8% | 92.8% |
|
|
132
|
+
| 每条证据都在的题 | 86.1% | 88.0% | **88.5%** |
|
|
133
|
+
| 字面重合低的证据(别名、换说法) | 47.7% | 48.3% | **54.0%** |
|
|
134
|
+
| 整理调用 | 1617 次 | 110 次 + 699 次日记(每次只读当天几行) | 同左 |
|
|
135
|
+
| 整理侧输入(估算 token) | 714 万 | 77 万 | 同左 |
|
|
136
|
+
| 答题输入(估算 token) | 205 万 | 152 万 | 168 万 |
|
|
137
|
+
|
|
138
|
+
分考点(窗口外,0.19 → 0.20 默认):偏好 66 → 78%、约定和欠账 80 → 93%、没说完要跟进的事 79 → 84%、计划 78 → 80%、时间题 79 → 85%;第三方事实 84 → 85%、转述 89 → 87%(不重排时这两项是 89% / 100%,重排砍掉了一部分);改口 68 → 68%(证据根本没进候选池,问题在候选,不在重排)。
|
|
139
|
+
|
|
140
|
+
这些只说明证据有没有到她面前,不说明她答得对不对;答题要在正式卷上真跑一次(估计 ¥5–7)。
|
package/docs/prompts.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
| | 电脑上的 QQ | `qq.channel` `qq.channel.owner` `qq.channel.score` `qq.stickers` `qq.channel.no-stickers` `qq.faces` |
|
|
26
26
|
| | 现在几点(每一轮,在对话历史之后) | `dot.now` |
|
|
27
27
|
| | 定时任务那一轮 | `dot.scheduled` |
|
|
28
|
+
| | 手机/电脑还在装(只在第一次装、开机没好时) / 装好那一刻 | `dot.setup` / `dot.setup-done` |
|
|
28
29
|
| | 记忆 / 想起的原话 | `memory.standing` / `memory.recall.header` |
|
|
29
30
|
| 叫醒她的消息 | 他的 QQ 消息 | `dot.owner-words`(她这轮进行中插进来时多一行 `dot.owner-words.busy`) |
|
|
30
31
|
| | 他插话了 | `dot.owner-interrupt`(发给他的 `qq_send` 被拦下的理由)/ `qq.send-interrupted`(气泡发到一半他说话) |
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
| | 交接 | `memory.handoff` |
|
|
35
36
|
| | 幕间:去看一眼 | `interlude.observation` `.where` `.vm` `.phone` |
|
|
36
37
|
| | 幕间:玩一会儿 | `interlude.play` `interlude.play.collect` `.verbs` `.parts` `interlude.play-rules` |
|
|
37
|
-
| 独立模型调用 | 整理记忆 | `memory.extract
|
|
38
|
+
| 独立模型调用 | 整理记忆 | `memory.extract`(规则,放在最前面)`memory.extract.input` `.banks` `.banks.off` |
|
|
39
|
+
| | 日记 | `memory.diary` |
|
|
38
40
|
| | 幕间一轮 | `interlude.round`(整段系统提示词,HDS-Interlude 的规则译成中文后合并);按情况填进去的:`.canon` `.length` `.length.deepseek` `.length.claude` `.length.gemini-flash` `.length.gpt` `.phase.advance` `.phase.follow-up` `.phase.intent` `.her-life` `.contact-rule` `.contact-rule.off` `.browsing.deferred` `.browsing.disabled` `.agency` `.play` `.play.collect` `.glm` `.style.none` `.seed` `.play-intents` `.play-intents.off` `.contact` `.contact.off`;补全那一次:`.refresh` |
|
|
39
41
|
| | 群消息打分 | `qq.score.system` `qq.score.who` `qq.score.user` |
|
|
40
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dot-life",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "dot — a character who lives on her own phone, for DeepSeek Harness (dsh): an Android phone the plugin installs and runs, her own QQ, memory and a diary from real events, a life between conversations (幕间, after HDS-Interlude), an optional microVM computer with approval gates. One plugin, six components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
package/scripts/prompts.mjs
CHANGED
|
@@ -53,9 +53,10 @@ function sampleMemory() {
|
|
|
53
53
|
const m = S.emptyMemory();
|
|
54
54
|
m.owner = ['他叫宽,在广州做 AI agent 开发', '不喜欢被叫"亲"'];
|
|
55
55
|
m.self = ['装了小黑盒,常在晚上逛', '学会了在 B 站发弹幕'];
|
|
56
|
-
m
|
|
57
|
-
S.
|
|
58
|
-
S.
|
|
56
|
+
S.openOp(m, { action: 'add', content: '10-31 他说这周要赶一个 benchmark,周五前交', due: '11-01' }, { now: T0 });
|
|
57
|
+
S.openOp(m, { action: 'add', content: '10-29 她答应周末陪他看新番', owed: true }, { now: T0 + 1 });
|
|
58
|
+
S.openOp(m, { action: 'add', content: '10-20 他说想换个机械键盘,先搁着' }, { now: T0 - 9 * 864e5 });
|
|
59
|
+
S.openOp(m, { action: 'shelve', oldText: '机械键盘' }, { now: T0 });
|
|
59
60
|
return m;
|
|
60
61
|
}
|
|
61
62
|
let recallDir = '';
|
|
@@ -64,7 +65,7 @@ async function recallText() {
|
|
|
64
65
|
const r = createRecall({ cfg: { recallBackend: 'local', recallTopK: 3, recallChunkChars: 1200, recallMaxTokens: 800, recallWindowTurns: 0 }, dir: recallDir, lines: () => LINES, logger: { info() {}, warn() {} }, embedder: () => Promise.reject(new Error('preview')) });
|
|
65
66
|
return (await r.query('你 benchmark 跑完了吗', { session: 's1', record: false })).text;
|
|
66
67
|
}
|
|
67
|
-
const standing = () => S.renderStanding(sampleMemory()
|
|
68
|
+
const standing = () => S.renderStanding(sampleMemory());
|
|
68
69
|
const context = () => I.renderContext({ state: STATE, entries: ['11-03 14:00:她把窗帘拉开一半,靠在床头改简历,咖啡放凉了。'], intents: [{ at: new Date(Date.now() + 3 * 36e5).toISOString(), kind: 'contact', text: '问他感冒好点没' }], cursor: Date.now() - 90 * 6e4, restarted: false });
|
|
69
70
|
|
|
70
71
|
// ── what she sees, in order: each entry is one thing she is given, made of these files ──
|
|
@@ -79,8 +80,8 @@ export const entries = [
|
|
|
79
80
|
{ id: 'now', group: 'system', name: '现在几点', note: '每一轮都带着(在对话历史之后):现在的时间,和离上一句话多久', files: ['dot.now'],
|
|
80
81
|
render: () => variant([['隔了一阵', D.nowText(Date.now(), Date.now() - (3 * 60 + 12) * 6e4)], ['刚说过话(不到一分钟,或者从没说过)', D.nowText(Date.now(), 0)]]) },
|
|
81
82
|
{ id: 'scheduled', group: 'system', name: '定时任务那一轮', note: '只在定时任务叫醒她时出现', files: ['dot.scheduled'], render: () => D.scheduledRule() },
|
|
82
|
-
{ id: 'memory', group: 'system', name: '记忆', note: '
|
|
83
|
-
{ id: 'recall', group: 'system', name: '想起的原话', note: '
|
|
83
|
+
{ id: 'memory', group: 'system', name: '记忆', note: '她对话的每一轮都带着:关于他、她自己记下的、还没了的事(加一行先搁着的)', files: ['memory.standing'], render: standing },
|
|
84
|
+
{ id: 'recall', group: 'system', name: '想起的原话', note: '叫醒她时从旧聊天里翻出来的,按日期分组、相对日期由程序换算(样例用的是关键词匹配)', files: ['memory.recall.header'], render: recallText },
|
|
84
85
|
|
|
85
86
|
{ id: 'owner', group: 'wake', name: '他的 QQ 消息', note: '他从电脑端 QQ 发来的话:等他停下(1.5 秒没新消息,最多 6 秒)一批盖一个时间戳,后面是他打的原话;她这轮还没做完时插进这一轮,多一行 dot.owner-words.busy', files: ['dot.owner-words', 'dot.owner-words.busy'],
|
|
86
87
|
render: () => variant([['她空闲', D.ownerWords([{ text: '在吗' }, { text: '帮我看个东西' }])], ['她这轮进行中', D.ownerWords([{ text: '算了' }, { text: '先别弄了' }], Date.now(), { whileBusy: true })]]) },
|
|
@@ -100,17 +101,20 @@ export const entries = [
|
|
|
100
101
|
{ id: 'onevoice', group: 'wake', name: '跑腿只汇报', note: '跑腿那一轮带着 dot.errand-report;跑腿给他发 qq_send 被拦下时的工具结果;跑腿还在做时她对话里的一行;一轮里同一个调用重复 dot.loopRepeat 次后被拦下的工具结果', files: ['dot.errand-report', 'dot.errand-no-owner', 'dot.errand-inflight', 'dot.loop-stopped'],
|
|
101
102
|
render: () => { const t = P.table('dot.errand-inflight'); return variant([['跑腿那一轮', P.prompt('dot.errand-report', { silent: D.SILENT })], ['跑腿找他被拦', P.prompt('dot.errand-no-owner')], ['她对话里:还在做的', P.fill(t.line, { doing: `${P.fill(t.thread, { app: '小黑盒', source: '《耳机测评》', count: 3 })};${t.other}` })], ['重复调用被拦', P.prompt('dot.loop-stopped', { times: 5 })]]); } },
|
|
102
103
|
{ id: 'handoff', group: 'wake', name: '交接', note: '对话太长换新会话时,新会话的开头', files: ['memory.handoff'],
|
|
103
|
-
render: () => M.renderHandoff(
|
|
104
|
+
render: () => M.renderHandoff(LINES.slice(-2), 3) },
|
|
104
105
|
{ id: 'observation', group: 'wake', name: '幕间:去看一眼', note: '她自己想去看看的时候,只看不动', files: ['interlude.observation', 'interlude.observation.where', 'interlude.observation.vm', 'interlude.observation.phone'],
|
|
105
106
|
render: () => variant([['电脑浏览器里搜', I.observationPrompt({ mode: 'search', query: '广州 本周 降温', purpose: '他感冒了,看看天气' }, 'vm')], ['手机 App', I.observationPrompt({ mode: 'search', query: '新番', purpose: '看看有没有新番' }, 'phone', 'tv.danmaku.bili')]]) },
|
|
106
107
|
{ id: 'play', group: 'wake', name: '幕间:玩一会儿', note: '去 App 里点赞、评论、攒表情包', files: ['interlude.play', 'interlude.play.collect', 'interlude.play.verbs', 'interlude.play.parts', 'interlude.play-rules'],
|
|
107
108
|
render: () => variant([['评论', I.playPrompt({ app: '小黑盒', action: 'comment', target: '那篇耳机测评', text: '低频确实糊', why: '她也用这副耳机' }, 'com.max.xiaoheihe')], ['攒表情包', I.playPrompt({ app: 'B站', action: 'collect', target: '表情包', why: '表情包太少了' }, 'tv.danmaku.bili')]]) },
|
|
108
109
|
|
|
109
|
-
{ id: 'extract', group: 'call', name: '整理记忆', note: '
|
|
110
|
+
{ id: 'extract', group: 'call', name: '整理记忆', note: '攒够一批记录(或交班前)时,把它们整理进三栏笔记和人物卡:规则在前(每次一样,命中缓存),已有的在中间,新记录在最后', files: ['memory.extract', 'memory.extract.input', 'memory.extract.banks', 'memory.extract.banks.off'],
|
|
110
111
|
render: () => {
|
|
111
112
|
const m = sampleMemory();
|
|
112
|
-
|
|
113
|
+
const item = (x) => `- ${S.renderItem(x)}${x.owed ? '(答应过)' : ''}`;
|
|
114
|
+
return M.extractPrompt({ text: LINES.map(M.transcriptLine).join('\n'), owner: m.owner, self: m.self, known: 'u0002 · 阿满 · qq:42 · talked · 大学室友,爱打瓦', open: m.open.map(item).join('\n'), shelved: m.shelved.map(item).join('\n') });
|
|
113
115
|
} },
|
|
116
|
+
{ id: 'diary', group: 'call', name: '日记', note: '每天 dailyAt(23:30),当天有记录才写,单独一次调用', files: ['memory.diary'],
|
|
117
|
+
render: () => M.diaryPrompt({ day: M.dayLabel(new Date(T0)), text: LINES.slice(0, 2).map(M.transcriptLine).join('\n') }) },
|
|
114
118
|
{ id: 'round', group: 'call', name: '幕间一轮', note: '写她这段时间的生活:interlude.round 是整段系统提示词(HDS-Interlude 的规则,译成中文),后面是按情况填进去的小段', files: ['interlude.round', 'interlude.round.canon', 'interlude.round.length', 'interlude.round.length.deepseek', 'interlude.round.length.claude', 'interlude.round.length.gemini-flash', 'interlude.round.length.gpt', 'interlude.round.phase.advance', 'interlude.round.phase.follow-up', 'interlude.round.phase.intent', 'interlude.round.her-life', 'interlude.round.returned', 'interlude.round.contact-rule', 'interlude.round.contact-rule.off', 'interlude.round.browsing.deferred', 'interlude.round.browsing.disabled', 'interlude.round.agency', 'interlude.round.play', 'interlude.round.play.collect', 'interlude.round.glm', 'interlude.round.style.none', 'interlude.round.seed', 'interlude.round.play-intents', 'interlude.round.play-intents.off', 'interlude.round.contact', 'interlude.round.contact.off', 'interlude.round.refresh'],
|
|
115
119
|
render: () => {
|
|
116
120
|
const r = I.buildPrompt({ phase: 'advance', identity: I.renderCanon(CANON), state: STATE, script: '11-03 14:00:她把窗帘拉开一半,靠在床头改简历。', cursor: Date.now() - 90 * 6e4, now: new Date(), speak: true, model: 'deepseek-chat', entries: [{ owner: 'user', at: '11-03 15:10', content: '在吗' }], browser: 'deferred', play: true, playApps: ['小黑盒', 'B站'], playActions: ['like', 'comment', 'follow', 'collect'], stickers: 2, memories: ['他叫宽,在广州做 AI agent 开发'], herLife: ['装了小黑盒,常在晚上逛'], returned: [{ kind: 'play', wanted: '小黑盒 like:那篇耳机测评', status: 'done', queuedAt: '2026-11-03 15:20 星期二 下午', busyWith: '看小黑盒《帖子A》的 3 条', startedAt: '2026-11-03 15:41 星期二 下午', doneAt: '2026-11-03 15:43 星期二 下午', report: '做了:点了赞\n结果:成了\n找他:不用' }] });
|
|
@@ -118,6 +122,7 @@ export const entries = [
|
|
|
118
122
|
} },
|
|
119
123
|
{ id: 'score', group: 'call', name: '群消息打分', note: '群消息值不值得她插一句(群消息设成打分时)', files: ['qq.score.system', 'qq.score.who', 'qq.score.user'],
|
|
120
124
|
render: () => { const r = Q.scorePrompt({ who: '小点:二十三岁,话少、直接', recent: '阿满:今晚谁打瓦\n老王:我', message: '小点你上次说的那个耳机多少钱', group: '123456' }); return variant([['system', r.system], ['user', r.user]]); } },
|
|
125
|
+
{ id: 'setup', group: 'system', name: '手机/电脑还在装', note: '只在第一次安装、开机还没好时带着(装好就消失);装好那一刻用 dot.setup-done 叫她自己说一声', files: ['dot.setup', 'dot.setup-done'], render: () => `${D.setupText({ state: 'downloading', progress: { text: '下载系统镜像 820/1450 MB,约 6 分钟' } }, { state: 'starting', stage: 'downloading' })}\n\n${P.prompt('dot.setup-done', { device: '手机' })}` },
|
|
121
126
|
];
|
|
122
127
|
const entryOf = (id) => entries.find((e) => e.files.includes(id));
|
|
123
128
|
|