cortico-world-memory-core 0.13.0 → 0.15.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/CHANGELOG.md +46 -0
- package/ENV_PROMPT.md +17 -15
- package/README.md +6 -5
- package/describe.json +4 -3
- package/package.json +1 -1
- package/src/config.ts +69 -13
- package/src/tools.ts +1 -1
- package/src/world.ts +55 -2
- package/webui/app.js +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
一个用户反馈:「它记的是事实和承诺,那些零碎的口气,还得我自己往本子上写。」
|
|
6
|
+
|
|
7
|
+
这戳到的是设计盲区:五种类型都是按「Agent 需要什么」分的,没有位置放「她怎么说话」。
|
|
8
|
+
|
|
9
|
+
- **卡片写人话**:提示词加了一条——「她点奶茶永远三分糖」比「用户偏好:低糖」像人。卡片正文会原样进上下文,写法直接决定观感。
|
|
10
|
+
- **`self` 扩成「关系」**:从「对自己的认知」扩到「他说话的习惯、什么语气让他舒服、你们之间的称呼和内部梗」。你库里 `self` 只有 2 张,就是因为定义太窄。
|
|
11
|
+
- **注入措辞**:预激活从「以前记下的,不是对方刚说的」改成「你想起几件事(不是对方刚说的),合适就用,别当清单念」。同一份数据,前者像日志,后者像人。
|
|
12
|
+
- **新 `mode=voice`**:返回对方最近 3-5 句原话,让模型自己听语气。优先挑像人话的(10-60 字、有标点、不是「选了第 2 项」这种界面回执),不够才用短的凑。**口气是样本,不是结论**——硬写成卡片只会得到「他很爱用嘛字结尾」这种伪精确。
|
|
13
|
+
- 提示词 473 → 498 字,守门从 480 放宽到 520。
|
|
14
|
+
- **体检页多一行「近 7 天新增了什么」**:事实 / 自己·关系 / 经历 / 承诺 分开数。事实和自己都是 0 时标红,并提示「这周没记下任何『她是谁』」。total 看不出「记的全是流水账」,分开才看得出来。
|
|
15
|
+
|
|
16
|
+
## 0.14.0
|
|
17
|
+
## 0.14.0
|
|
18
|
+
|
|
19
|
+
装完就能用,不用先去调 35 个开关。
|
|
20
|
+
|
|
21
|
+
- **顶部指标加「24 小时新写入」**:这是最高频的疑问(「她怎么不写记忆了」),现在打开设置页第一眼就能看到。0 会标红。
|
|
22
|
+
- **默认值按大众场景调了 4 个**:
|
|
23
|
+
|
|
24
|
+
| 项 | 旧默认 | 新默认 | 为什么 |
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
| `nightlyConsolidate` | 关 | **开** | 它已经不发额外请求(夜里备料、下次开口交付),关着等于放弃唯一一次「提醒它整理」的机会 |
|
|
27
|
+
| `requireRecentUserHours` | 8 小时 | **5 小时** | 8 小时太保守,早上第一条几乎不会触发主动 |
|
|
28
|
+
| `rawRetentionDays` | 7 天 | **14 天** | 7 天后原文进归档,日常问「上周说的那个」就搜不到了 |
|
|
29
|
+
| `rawArchiveDays` | 90 天 | **365 天** | 原话是证据,一年才几 MB,不该省 |
|
|
30
|
+
|
|
31
|
+
- 说明里去掉了一处 `**` 标记(设置页不渲染 markdown,会原样显示)。
|
|
32
|
+
- **注意**:这些只影响「没存过这个键」的新配置。已经在 `config.json` 里存了旧值的,需要手动改。
|
|
33
|
+
|
|
34
|
+
## 0.13.1
|
|
35
|
+
## 0.13.1
|
|
36
|
+
|
|
37
|
+
设置页文案有几处是**错的**,不是过时——按它们做决定会被误导。
|
|
38
|
+
|
|
39
|
+
- **夜间整理**:原来写「会多一次完整请求(约 8-10 万 token)」。0.6.0 之后它压根不发额外请求(夜里只备料,等下次开口才交付),而且 8-10 万这个量级也不对。改成如实描述。
|
|
40
|
+
- **每天主动上限**:原来写「3 次约等于 30 万 token」,实际一次主动 1-2 万。
|
|
41
|
+
- **存对话原文**:原来写「不存你自己说的话」,但默认白名单里就有 `desktop-pet.answer`,打开 `captureAll` 更是全存。
|
|
42
|
+
- **重扫历史补录**:原来写「做完自动关掉自己」——开关不会自己关,只是状态标记让它不再跑。改成「补完就不会再跑,开关留着不用管」。
|
|
43
|
+
- **组描述**还停在「四套记忆合成的一套」,改回它现在的样子。
|
|
44
|
+
- 补上「睡觉结束」「免打扰结束」两处空说明,并讲清**免打扰和睡觉不是一回事**。
|
|
45
|
+
- **设置项重排**:记忆总开关、站点、每轮想起几条提到最前;主动开口和作息收到后面。用显式顺序表实现,缺项会自动追加到末尾,不会漏。
|
|
46
|
+
- 顺手修掉 `captureAll` 标题显示成原始 key 的问题(写了 `label`,宿主读的是 `title`)。
|
|
47
|
+
|
|
48
|
+
## 0.13.0
|
|
3
49
|
## 0.13.0
|
|
4
50
|
|
|
5
51
|
补地基的三件(对照海马体:保真、自动捕获、召回质量)。
|
package/ENV_PROMPT.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
【记忆核心】
|
|
2
|
-
|
|
3
|
-
你只有这一套记忆:`mcore_write` 写,`mcore_recall`
|
|
4
|
-
|
|
5
|
-
写的时候:
|
|
6
|
-
-
|
|
7
|
-
- `
|
|
8
|
-
-
|
|
9
|
-
- `
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
【记忆核心】
|
|
2
|
+
|
|
3
|
+
你只有这一套记忆:`mcore_write` 写,`mcore_recall` 查。不要再提别的记忆系统,也不要问「记在哪」。
|
|
4
|
+
|
|
5
|
+
写的时候:
|
|
6
|
+
- 用你记得的样子写,别写字段:「她点奶茶永远三分糖」比「用户偏好:低糖」像人。
|
|
7
|
+
- 能写成 `fact` 就别写 `episode`;`episode` 一天最多 2 条,只写会改变你怎么看她的事。
|
|
8
|
+
- `self` 也装关系:他说话的习惯、什么语气让他舒服、你们之间的称呼和内部梗。
|
|
9
|
+
- `promise` 没定时间先问;确实没有就写 `dueAt:"none"`。做完或改口传 `closes`(行首 8 位)。
|
|
10
|
+
- 一条一件事,写清谁、何时、怎么了;同一件事不写两遍。
|
|
11
|
+
- `tags` 两个词:主题 + 对方可能换的说法(「小黑盒」「发帖」),别写「日常」。
|
|
12
|
+
|
|
13
|
+
查的时候:提到旧事、问「你还记得吗」,先查再答,别硬猜。
|
|
14
|
+
|
|
15
|
+
状态和日程用 `mcore_state` / `mcore_plan`,别写进 `mcore_write`。
|
|
16
|
+
|
|
17
|
+
分寸:记忆是记得的东西,不是拿来念的清单。可以自然地说「我记得你说过……」;不确定就问,别编。
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ pnpm add cortico-world-memory-core
|
|
|
30
30
|
| 工具 | 作用 |
|
|
31
31
|
|---|---|
|
|
32
32
|
| `mcore_write` | 写一条记忆。`kind` 五选一,可带 `weight` / `tags` / `dueAt`;**`promise` 必须带 `dueAt`**,不知道时间会被拒绝并提示先问,确实没有截止时间就写 `dueAt: "none"`;传 `closes` 表示「这条替代了某条旧的」 |
|
|
33
|
-
| `mcore_recall` | 查记忆。不传 `query` 就是最近几条;传了就按内容搜,同时搜最近 7 天的对话原文和工作区笔记;结果分两档:「对得上」和「可能沾边,别当准」;带 `↩` 的是改写过的记忆 + 当时那句原话的日期;给 `id` 可以看这条记忆的出处(当时那句原话 + 前后文);`mode=open` 看没做完的承诺和今天的安排;`mode=archive` 翻更早的归档原文 |
|
|
33
|
+
| `mcore_recall` | 查记忆。不传 `query` 就是最近几条;传了就按内容搜,同时搜最近 7 天的对话原文和工作区笔记;结果分两档:「对得上」和「可能沾边,别当准」;带 `↩` 的是改写过的记忆 + 当时那句原话的日期;给 `id` 可以看这条记忆的出处(当时那句原话 + 前后文);`mode=voice` 返回几句对方的原话,用来听语气(卡片记不住口气,样本才行);`mode=open` 看没做完的承诺和今天的安排;`mode=archive` 翻更早的归档原文 |
|
|
34
34
|
| `mcore_state` | 角色自己的精力 / 心情 / 正在做什么 / 在哪 / 睡没睡 |
|
|
35
35
|
| `mcore_plan` | 今天的日程(增、勾、清空) |
|
|
36
36
|
|
|
@@ -103,17 +103,18 @@ pnpm add cortico-world-memory-core
|
|
|
103
103
|
| `captureTurns` | `true` | 存对方最近的对话原文,供「搜最近聊过什么」 |
|
|
104
104
|
| `captureSenders` | `^(desktop-pet\.(chat\|message\|answer\|voice)\|private:\|qq\.private\.\|starpost\.private\.)` | 哪些来源算对话(正则匹配 senderKey)。真实 key 长这样:`private:1940008084`、`desktop-pet.chat`;群聊不算 |
|
|
105
105
|
| `captureMinLength` | `4` | 短于这个字数的消息不进原文库 |
|
|
106
|
-
| `rawRetentionDays` | `
|
|
107
|
-
| `rawArchiveDays` | `
|
|
108
|
-
| `captureBackfill` | `false` |
|
|
106
|
+
| `rawRetentionDays` | `14` | 热数据天数,超过就按天挪进 `archive/`(不再直接删) |
|
|
107
|
+
| `rawArchiveDays` | `365` | 归档保留天数,`0` = 永久 |
|
|
108
|
+
| `captureBackfill` | `false` | 打开后重启一次:把宿主还留着的历史消息补扫进原文库,只补没扫过的,补完就不会再跑 |
|
|
109
109
|
| `recallLimit` | `5` | 一次召回给几条 |
|
|
110
110
|
| `recallMaxChars` | `600` | 召回结果总字数上限 |
|
|
111
111
|
| `recallUseAging` | `true` | 排序参考「上次被想起的时间」:久不用的旧卡让位;关掉退回只看关键词、标签、权重 |
|
|
112
112
|
| `preactivateLines` | `2` | 每轮按对方刚说的话自动带出几条旧记忆(预激活),不用模型自己去查;`0` = 关,最多 3 条 |
|
|
113
113
|
| `promiseRepeatDays` | `1` | 到期还没做的承诺隔几天再提一次,直到做完或退休;`0` = 只提醒一次 |
|
|
114
114
|
| `proactiveEnabled` | `true` | 主动开口 |
|
|
115
|
+
| `requireRecentUserHours` | `5` | 对方超过这么久没说话就不主动,免得对着空房间说话白花钱 |
|
|
115
116
|
| `proactiveMinGapMin` / `proactiveDailyCap` | `100` / `3` | 主动间隔与每日上限 |
|
|
116
|
-
| `nightlyConsolidate` | `
|
|
117
|
+
| `nightlyConsolidate` | `true` | 夜间整理。夜里把当天原文备成一份材料,**下次开口时**才交付(不占额外请求,是一次普通的工具调用) |
|
|
117
118
|
| `captureAll` | `false` | 关着只记白名单里那个人的话;打开后群里其他人、以及自己发的消息也落盘。只影响原文库,不增加每轮成本 |
|
|
118
119
|
| `chillAfterDays` | `30` | 多久没被想起就沉到冷层(只沉低权重的「经历 / 临时」,事实、自我、未完成的承诺不动)。每天最多沉 4 条,最多占 25%。冷层不参与预激活和「最近」,搜索仍能找到,可一键回暖;`0` = 关闭 |
|
|
119
120
|
| `siteEnabled` / `sitePort` | `true` / `7801` | 记忆地图 |
|
package/describe.json
CHANGED
|
@@ -84,9 +84,10 @@
|
|
|
84
84
|
"search",
|
|
85
85
|
"recent",
|
|
86
86
|
"open",
|
|
87
|
-
"archive"
|
|
87
|
+
"archive",
|
|
88
|
+
"voice"
|
|
88
89
|
],
|
|
89
|
-
"description": "默认 search"
|
|
90
|
+
"description": "默认 search;voice = 给几句对方原话听语气"
|
|
90
91
|
},
|
|
91
92
|
"days": {
|
|
92
93
|
"type": "integer",
|
|
@@ -239,7 +240,7 @@
|
|
|
239
240
|
"key": "worlds.memory-core.envPrompt",
|
|
240
241
|
"title": "记忆核心 · 环境提示词",
|
|
241
242
|
"role": "envPrompt",
|
|
242
|
-
"content": "【记忆核心】\n\n你只有这一套记忆:`mcore_write` 写,`mcore_recall`
|
|
243
|
+
"content": "【记忆核心】\n\n你只有这一套记忆:`mcore_write` 写,`mcore_recall` 查。不要再提别的记忆系统,也不要问「记在哪」。\n\n写的时候:\n- 用你记得的样子写,别写字段:「她点奶茶永远三分糖」比「用户偏好:低糖」像人。\n- 能写成 `fact` 就别写 `episode`;`episode` 一天最多 2 条,只写会改变你怎么看她的事。\n- `self` 也装关系:他说话的习惯、什么语气让他舒服、你们之间的称呼和内部梗。\n- `promise` 没定时间先问;确实没有就写 `dueAt:\"none\"`。做完或改口传 `closes`(行首 8 位)。\n- 一条一件事,写清谁、何时、怎么了;同一件事不写两遍。\n- `tags` 两个词:主题 + 对方可能换的说法(「小黑盒」「发帖」),别写「日常」。\n\n查的时候:提到旧事、问「你还记得吗」,先查再答,别硬猜。\n\n状态和日程用 `mcore_state` / `mcore_plan`,别写进 `mcore_write`。\n\n分寸:记忆是记得的东西,不是拿来念的清单。可以自然地说「我记得你说过……」;不确定就问,别编。"
|
|
243
244
|
}
|
|
244
245
|
]
|
|
245
246
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-memory-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "四个工具写卡、查卡、改状态、排日程,改口不覆盖。每轮自动把 2 条相关旧记忆推到眼前,不用模型自己查;搜索分「对得上 / 可能沾边」两档。冷层收走三个月没想起的流水账,不删、可回暖。3D 星图一眼看完整个库。常驻约 1,000 token,本地不联网,MIT。\n\nQQ 交流群:745879632",
|
|
6
6
|
"keywords": [
|
package/src/config.ts
CHANGED
|
@@ -84,7 +84,7 @@ export const MEMORY_CORE_DEFAULTS: MemoryCoreConfig = {
|
|
|
84
84
|
proactiveJitterMin: 25,
|
|
85
85
|
proactiveDailyCap: 3,
|
|
86
86
|
idleGateMin: 20,
|
|
87
|
-
requireRecentUserHours:
|
|
87
|
+
requireRecentUserHours: 5,
|
|
88
88
|
promiseRepeatDays: 1,
|
|
89
89
|
quietStart: '23:30',
|
|
90
90
|
quietEnd: '08:00',
|
|
@@ -97,8 +97,8 @@ export const MEMORY_CORE_DEFAULTS: MemoryCoreConfig = {
|
|
|
97
97
|
captureSenders: '^(desktop-pet\\.(chat|message|answer|voice)|private:|qq\\.private\\.|starpost\\.private\\.)',
|
|
98
98
|
captureAll: false,
|
|
99
99
|
captureMinLength: 4,
|
|
100
|
-
rawRetentionDays:
|
|
101
|
-
rawArchiveDays:
|
|
100
|
+
rawRetentionDays: 14,
|
|
101
|
+
rawArchiveDays: 365,
|
|
102
102
|
captureBackfill: false,
|
|
103
103
|
recallLimit: 5,
|
|
104
104
|
recallMaxChars: 600,
|
|
@@ -106,7 +106,7 @@ export const MEMORY_CORE_DEFAULTS: MemoryCoreConfig = {
|
|
|
106
106
|
preactivateLines: 2,
|
|
107
107
|
chillAfterDays: 30,
|
|
108
108
|
contextEveryMin: 0,
|
|
109
|
-
nightlyConsolidate:
|
|
109
|
+
nightlyConsolidate: true,
|
|
110
110
|
nightlyHour: 3,
|
|
111
111
|
energyDecayPerHour: 2.2,
|
|
112
112
|
workspaceScanEnabled: true,
|
|
@@ -135,13 +135,13 @@ const num = (
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
/** 设置页表单:键是 cfg 里的点分路径。全部热更新,改完不用重启。 */
|
|
138
|
-
|
|
138
|
+
const RAW_GROUP: ConfigGroup = {
|
|
139
139
|
id: 'world:memory-core',
|
|
140
140
|
owner: 'world:memory-core',
|
|
141
141
|
schema: {
|
|
142
142
|
type: 'object',
|
|
143
143
|
title: '记忆核心',
|
|
144
|
-
description: '
|
|
144
|
+
description: '卡片 + 4 个工具 + 一段提示词。装好后角色会自己往里写,也在你开口时自动带出几条旧的。第一次启动会把旧插件的记忆只读导入一次,原文件不动。',
|
|
145
145
|
properties: {
|
|
146
146
|
'worlds.memory-core.proactiveEnabled': {
|
|
147
147
|
type: 'boolean',
|
|
@@ -151,7 +151,7 @@ export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = {
|
|
|
151
151
|
},
|
|
152
152
|
'worlds.memory-core.proactiveMinGapMin': num('两次主动的最小间隔', '默认 100 分钟。太短会显得粘人,也费 token。', 15, 720, '分钟'),
|
|
153
153
|
'worlds.memory-core.proactiveJitterMin': num('随机抖动', '在最小间隔上加 0 到这么多分钟的随机量,避免每天准点开口。', 0, 120, '分钟'),
|
|
154
|
-
'worlds.memory-core.proactiveDailyCap': num('每天主动上限', '
|
|
154
|
+
'worlds.memory-core.proactiveDailyCap': num('每天主动上限', '一次主动约 1-2 万 token(看上下文长度),3 次大概 5 万。0 = 不限。', 0, 12, '次'),
|
|
155
155
|
'worlds.memory-core.idleGateMin': num('对方刚说话后的静默', '窗口内不主动,免得打断。', 0, 240, '分钟'),
|
|
156
156
|
'worlds.memory-core.requireRecentUserHours': num('对方多久没说话就不主动', '超过这个时长就当没人在,主动会对着空房间说话、白花钱。0 = 不限制。', 0, 72, '小时'),
|
|
157
157
|
'worlds.memory-core.promiseRepeatDays': num('承诺隔几天再提一次', '到期还没做的承诺,隔这么多天再提一次,直到做完或退休。默认 1(每天最多一次);0 = 只提醒一次。', 0, 30, '天'),
|
|
@@ -164,13 +164,13 @@ export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = {
|
|
|
164
164
|
'worlds.memory-core.quietEnd': {
|
|
165
165
|
type: 'string',
|
|
166
166
|
title: '免打扰结束',
|
|
167
|
-
description: '24 小时制 HH:MM
|
|
167
|
+
description: '24 小时制 HH:MM。起止相同等于不启用。',
|
|
168
168
|
'x-hot': true,
|
|
169
169
|
},
|
|
170
170
|
'worlds.memory-core.sleepStart': {
|
|
171
171
|
type: 'string',
|
|
172
172
|
title: '睡觉开始',
|
|
173
|
-
description: '
|
|
173
|
+
description: '这个时段里状态显示「在睡觉」,精力按「睡觉」逻辑回升;和免打扰不是一回事——免打扰只是不主动开口。',
|
|
174
174
|
'x-hot': true,
|
|
175
175
|
},
|
|
176
176
|
'worlds.memory-core.sleepEnd': {
|
|
@@ -187,12 +187,12 @@ export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = {
|
|
|
187
187
|
'worlds.memory-core.captureTurns': {
|
|
188
188
|
type: 'boolean',
|
|
189
189
|
title: '存对话原文',
|
|
190
|
-
description: '
|
|
190
|
+
description: '把最近的对话存成一行行本地文本,供「搜最近聊过什么」。默认只存白名单里的人;打开下面那项后,群里其他人和你自己说的也会存。',
|
|
191
191
|
'x-hot': true,
|
|
192
192
|
},
|
|
193
193
|
'worlds.memory-core.captureAll': {
|
|
194
194
|
type: 'boolean',
|
|
195
|
-
|
|
195
|
+
title: '所有人说的话都记',
|
|
196
196
|
description: '关着只记白名单里的人(默认),打开后群里其他人、以及你自己发的也会落盘。落盘只影响原文库,不增加每轮成本。',
|
|
197
197
|
default: false,
|
|
198
198
|
},
|
|
@@ -208,7 +208,7 @@ export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = {
|
|
|
208
208
|
'worlds.memory-core.captureBackfill': {
|
|
209
209
|
type: 'boolean',
|
|
210
210
|
title: '重扫历史补录',
|
|
211
|
-
description: '
|
|
211
|
+
description: '打开后重启一次:把宿主还留着的历史消息补扫进原文库。只补没扫过的;补完就不会再跑,开关留着不用管。',
|
|
212
212
|
'x-hot': false,
|
|
213
213
|
},
|
|
214
214
|
'worlds.memory-core.recallLimit': num('一次召回给几条', '默认 5 条。给多了挤占上下文。', 1, 12, '条'),
|
|
@@ -224,7 +224,7 @@ export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = {
|
|
|
224
224
|
'worlds.memory-core.nightlyConsolidate': {
|
|
225
225
|
type: 'boolean',
|
|
226
226
|
title: '夜间整理',
|
|
227
|
-
description: '
|
|
227
|
+
description: '夜里把当天的原文收成一份材料,等你下次开口时交给它整理(最多 3 条,能写成 fact 就不写 episode)。不额外发请求。默认开。',
|
|
228
228
|
'x-hot': true,
|
|
229
229
|
},
|
|
230
230
|
'worlds.memory-core.nightlyHour': num('夜间整理时间', '24 小时制的小时数。', 0, 23, '点'),
|
|
@@ -273,3 +273,59 @@ export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = {
|
|
|
273
273
|
},
|
|
274
274
|
},
|
|
275
275
|
};
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 设置页的显示顺序:把「总开关 / 看记忆 / 每轮想起几条」放最前,
|
|
280
|
+
* 主动开口和作息往后——那些是角色行为,不是记忆本身。
|
|
281
|
+
* 用显式顺序表而不是直接调换定义位置,改起来不容易漏项。
|
|
282
|
+
*/
|
|
283
|
+
const SETTINGS_ORDER = [
|
|
284
|
+
'worlds.memory-core.memoryEnabled',
|
|
285
|
+
'worlds.memory-core.siteEnabled',
|
|
286
|
+
'worlds.memory-core.sitePort',
|
|
287
|
+
'worlds.memory-core.preactivateLines',
|
|
288
|
+
'worlds.memory-core.captureTurns',
|
|
289
|
+
'worlds.memory-core.captureAll',
|
|
290
|
+
'worlds.memory-core.captureSenders',
|
|
291
|
+
'worlds.memory-core.captureMinLength',
|
|
292
|
+
'worlds.memory-core.recallLimit',
|
|
293
|
+
'worlds.memory-core.recallMaxChars',
|
|
294
|
+
'worlds.memory-core.recallUseAging',
|
|
295
|
+
'worlds.memory-core.chillAfterDays',
|
|
296
|
+
'worlds.memory-core.rawRetentionDays',
|
|
297
|
+
'worlds.memory-core.rawArchiveDays',
|
|
298
|
+
'worlds.memory-core.captureBackfill',
|
|
299
|
+
'worlds.memory-core.nightlyConsolidate',
|
|
300
|
+
'worlds.memory-core.nightlyHour',
|
|
301
|
+
'worlds.memory-core.workspaceScanEnabled',
|
|
302
|
+
'worlds.memory-core.workspaceDirs',
|
|
303
|
+
'worlds.memory-core.workspaceExts',
|
|
304
|
+
'worlds.memory-core.workspaceMaxFiles',
|
|
305
|
+
'worlds.memory-core.workspaceMaxFileKB',
|
|
306
|
+
'worlds.memory-core.proactiveEnabled',
|
|
307
|
+
'worlds.memory-core.proactiveMinGapMin',
|
|
308
|
+
'worlds.memory-core.proactiveJitterMin',
|
|
309
|
+
'worlds.memory-core.proactiveDailyCap',
|
|
310
|
+
'worlds.memory-core.idleGateMin',
|
|
311
|
+
'worlds.memory-core.requireRecentUserHours',
|
|
312
|
+
'worlds.memory-core.promiseRepeatDays',
|
|
313
|
+
'worlds.memory-core.quietStart',
|
|
314
|
+
'worlds.memory-core.quietEnd',
|
|
315
|
+
'worlds.memory-core.sleepStart',
|
|
316
|
+
'worlds.memory-core.sleepEnd',
|
|
317
|
+
'worlds.memory-core.energyDecayPerHour',
|
|
318
|
+
'worlds.memory-core.contextEveryMin',
|
|
319
|
+
];
|
|
320
|
+
|
|
321
|
+
export const MEMORY_CORE_CONFIG_GROUP: ConfigGroup = (() => {
|
|
322
|
+
const props = (RAW_GROUP.schema.properties ?? {}) as Record<string, unknown>;
|
|
323
|
+
const known = SETTINGS_ORDER.filter((k) => k in props);
|
|
324
|
+
// 顺序表里没写到的项也不能丢:追加到末尾,宁可顺序难看也别少一个开关
|
|
325
|
+
const rest = Object.keys(props).filter((k) => !known.includes(k));
|
|
326
|
+
const ordered = [...known, ...rest].map((k) => [k, props[k]] as const);
|
|
327
|
+
return {
|
|
328
|
+
...RAW_GROUP,
|
|
329
|
+
schema: { ...RAW_GROUP.schema, properties: Object.fromEntries(ordered) },
|
|
330
|
+
};
|
|
331
|
+
})();
|
package/src/tools.ts
CHANGED
|
@@ -48,7 +48,7 @@ export const TOOL_SPECS: ToolSpec[] = [
|
|
|
48
48
|
query: { type: 'string', description: '关键词就够' },
|
|
49
49
|
id: { type: 'string', description: '看某条记忆的出处(传行首 8 位),会给出当时的原话和前后文' },
|
|
50
50
|
kind: { type: 'string', enum: ['fact', 'self', 'episode', 'promise', 'note'], description: '只看某一类' },
|
|
51
|
-
mode: { type: 'string', enum: ['search', 'recent', 'open', 'archive'], description: '默认 search' },
|
|
51
|
+
mode: { type: 'string', enum: ['search', 'recent', 'open', 'archive', 'voice'], description: '默认 search;voice = 给几句对方原话听语气' },
|
|
52
52
|
days: { type: 'integer', description: '只看最近这么多天' },
|
|
53
53
|
limit: { type: 'integer', description: '最多几条,默认 5' },
|
|
54
54
|
},
|
package/src/world.ts
CHANGED
|
@@ -229,6 +229,13 @@ export class MemoryCoreWorld implements World {
|
|
|
229
229
|
const cfg = this.cfg();
|
|
230
230
|
const stats = this.store.stats();
|
|
231
231
|
const count = this.countToday();
|
|
232
|
+
const dayAgo = Date.now() - 86_400_000;
|
|
233
|
+
const fresh = this.store
|
|
234
|
+
.active()
|
|
235
|
+
.filter((c) => {
|
|
236
|
+
const at = Date.parse(c.createdAt);
|
|
237
|
+
return Number.isFinite(at) && at >= dayAgo;
|
|
238
|
+
}).length;
|
|
232
239
|
return {
|
|
233
240
|
label: '记忆核心',
|
|
234
241
|
lamps: [
|
|
@@ -255,9 +262,15 @@ export class MemoryCoreWorld implements World {
|
|
|
255
262
|
},
|
|
256
263
|
],
|
|
257
264
|
badges: [
|
|
265
|
+
{ label: '记忆', value: stats.total },
|
|
266
|
+
// 「为什么没有新记忆」是最高频的疑问,所以把 24 小时写入量放到第一屏
|
|
267
|
+
{
|
|
268
|
+
label: '24 小时新写入',
|
|
269
|
+
value: fresh,
|
|
270
|
+
tone: fresh > 0 ? 'on' : 'off',
|
|
271
|
+
},
|
|
258
272
|
{ label: '今日主动', value: `${count}/${cfg.proactiveDailyCap || '∞'}` },
|
|
259
273
|
{ label: '精力', value: Math.round(this.state.energy), tone: this.state.energy < 35 ? 'off' : 'on' },
|
|
260
|
-
{ label: '记忆', value: stats.total },
|
|
261
274
|
],
|
|
262
275
|
promptDocs: [
|
|
263
276
|
{
|
|
@@ -605,6 +618,13 @@ export class MemoryCoreWorld implements World {
|
|
|
605
618
|
const d = formatLocal(new Date(now - i * 86_400_000), this.tz()).slice(0, 10);
|
|
606
619
|
perDay.push({ day: d, n: count.get(d) || 0 });
|
|
607
620
|
}
|
|
621
|
+
// 近 7 天按类型分开数:total 看不出「记的全是流水账」
|
|
622
|
+
const weekAgo = now - 7 * 86_400_000;
|
|
623
|
+
const byKind: Record<string, number> = {};
|
|
624
|
+
for (const c of live) {
|
|
625
|
+
if ((Date.parse(c.createdAt) || 0) < weekAgo) continue;
|
|
626
|
+
byKind[c.kind] = (byKind[c.kind] || 0) + 1;
|
|
627
|
+
}
|
|
608
628
|
const open = live.filter((c) => c.kind === 'promise' && !c.done);
|
|
609
629
|
const rawStats = this.raw.stats();
|
|
610
630
|
return {
|
|
@@ -616,6 +636,7 @@ export class MemoryCoreWorld implements World {
|
|
|
616
636
|
primed: live.reduce((n, c) => n + (c.primedCount || 0), 0),
|
|
617
637
|
},
|
|
618
638
|
perDay,
|
|
639
|
+
recent: { days: 7, byKind },
|
|
619
640
|
promises: {
|
|
620
641
|
open: open.length,
|
|
621
642
|
overdue: open.filter((c) => c.dueAt && Date.parse(c.dueAt) <= now).length,
|
|
@@ -872,6 +893,9 @@ export class MemoryCoreWorld implements World {
|
|
|
872
893
|
return lines.length ? lines.join('\n') : '没有未完成的事。';
|
|
873
894
|
}
|
|
874
895
|
|
|
896
|
+
if (mode === 'voice') {
|
|
897
|
+
return this.handleVoice(limit);
|
|
898
|
+
}
|
|
875
899
|
if (mode === 'archive') {
|
|
876
900
|
if (!query) return '翻归档要带 query,给几个关键词。';
|
|
877
901
|
const span = num(args.days, 30, 1, 3650);
|
|
@@ -975,6 +999,35 @@ export class MemoryCoreWorld implements World {
|
|
|
975
999
|
].join('\n');
|
|
976
1000
|
}
|
|
977
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* 听语气:把对方最近说的几句原话原样给出来。
|
|
1004
|
+
* 卡片记不住「口气」——那是样本,不是结论,所以这里直接给样本。
|
|
1005
|
+
*/
|
|
1006
|
+
private handleVoice(limit: number): string {
|
|
1007
|
+
const re = this.senderRe(this.cfg());
|
|
1008
|
+
const all = this.raw.all();
|
|
1009
|
+
// 界面回执、菜单选择这类「不是人话」的句子,听不出语气还占位置
|
|
1010
|
+
const junk = /^(选了|点了|返回|打开|关闭|确认|取消|已)/;
|
|
1011
|
+
const natural = (t: string) => t.length >= 10 && t.length <= 60 && /[,。!?…]/.test(t) && !junk.test(t);
|
|
1012
|
+
const seen = new Set<string>();
|
|
1013
|
+
const pick = (test: (t: string) => boolean, bag: string[]) => {
|
|
1014
|
+
for (let i = all.length - 1; i >= 0 && bag.length < limit; i -= 1) {
|
|
1015
|
+
const e = all[i];
|
|
1016
|
+
if (!re.test(e.sender ?? '')) continue;
|
|
1017
|
+
const text = String(e.text ?? '').replace(/\s+/g, ' ').trim();
|
|
1018
|
+
if (text.length < 6 || text.length > 80 || seen.has(text) || !test(text)) continue;
|
|
1019
|
+
seen.add(text);
|
|
1020
|
+
bag.push(`· ${text}`);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
const out: string[] = [];
|
|
1024
|
+
// 先挑像人话的(有标点、长度适中),不够再用短的凑
|
|
1025
|
+
pick(natural, out);
|
|
1026
|
+
if (out.length < limit) pick((t) => t.length >= 6, out);
|
|
1027
|
+
if (!out.length) return '最近没有能听语气的原话(原文库可能是空的,或者都被过滤了)。';
|
|
1028
|
+
return `(这几句是对方最近说的原话,用来听语气。别复述、别总结,用你自己的话说:\n${out.join('\n')})`;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
978
1031
|
/**
|
|
979
1032
|
* 看一条记忆的出处:卡片原文 + 写它时那句原话 + 前后文。
|
|
980
1033
|
* 卡片是改写的,只有这里能回到证据。
|
|
@@ -1357,7 +1410,7 @@ export class MemoryCoreWorld implements World {
|
|
|
1357
1410
|
const body = picked.map((c) => `· ${clip(c.text, 60)}(${formatLocal(c.createdAt, tz).slice(5, 10)})`).join('\n');
|
|
1358
1411
|
const ok = await this.push(
|
|
1359
1412
|
'mcore.prime',
|
|
1360
|
-
|
|
1413
|
+
`(你想起几件事(不是对方刚说的),合适就用,别当清单念:\n${body})`,
|
|
1361
1414
|
'piggyback',
|
|
1362
1415
|
);
|
|
1363
1416
|
if (!ok) return;
|
package/webui/app.js
CHANGED
|
@@ -2587,6 +2587,13 @@ function renderHealth() {
|
|
|
2587
2587
|
</div>`,
|
|
2588
2588
|
)
|
|
2589
2589
|
.join('');
|
|
2590
|
+
const wk = h.recent?.byKind ?? {};
|
|
2591
|
+
const week = {
|
|
2592
|
+
fact: wk.fact ?? 0,
|
|
2593
|
+
self: wk.self ?? 0,
|
|
2594
|
+
episode: wk.episode ?? 0,
|
|
2595
|
+
promise: wk.promise ?? 0,
|
|
2596
|
+
};
|
|
2590
2597
|
const dead = h.deadIds.map((id) => cards().find((c) => c.id === id)).filter(Boolean);
|
|
2591
2598
|
const deadRows = dead
|
|
2592
2599
|
.slice(0, 20)
|
|
@@ -2613,6 +2620,21 @@ function renderHealth() {
|
|
|
2613
2620
|
<div class="h-chart">${bars}</div>
|
|
2614
2621
|
</section>
|
|
2615
2622
|
|
|
2623
|
+
<section class="h-block">
|
|
2624
|
+
<h3>近 7 天新增了什么</h3>
|
|
2625
|
+
<div class="h-line">
|
|
2626
|
+
<span class="${(week.fact + week.self) === 0 ? 'warn' : ''}">事实 <b>${week.fact}</b></span>
|
|
2627
|
+
<span>自己 / 关系 <b>${week.self}</b></span>
|
|
2628
|
+
<span>经历 <b>${week.episode}</b></span>
|
|
2629
|
+
<span class="${week.promise ? '' : 'dim'}">承诺 <b>${week.promise}</b></span>
|
|
2630
|
+
<span class="dim">${
|
|
2631
|
+
week.fact + week.self === 0
|
|
2632
|
+
? '这周没记下任何「她是谁」——聊天时可以直接说「记一下」'
|
|
2633
|
+
: '事实和自我比经历更该沉淀;全是经历说明在记流水账'
|
|
2634
|
+
}</span>
|
|
2635
|
+
</div>
|
|
2636
|
+
</section>
|
|
2637
|
+
|
|
2616
2638
|
<section class="h-block">
|
|
2617
2639
|
<h3>承诺</h3>
|
|
2618
2640
|
<div class="h-line">
|