cortico-world-memory-core 0.18.1 → 0.19.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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.0
4
+
5
+ **记忆写得太少了。** 一周 8 条、一天 1 条——不是没东西可记,是规则把路堵死了。
6
+
7
+ 三处叠加:`episode` 的定义是「会改变你判断的一件事」(一周能有几件)、限「一天最多 2 条」、
8
+ 再加「能写成 fact 就别写 episode」。而 `fact` 只装关于对方的,她**自己的经历无处可去**,干脆不写。
9
+
10
+ - **放宽 `episode`**:记「你自己经历过的」——打副本、发帖、被哄、路上看见什么,有画面有情绪就算。
11
+ 一天 3-5 条正常。删掉「一天最多 2 条」和「能写 fact 就别写 episode」。
12
+ - **降噪(新增)**:`demoteTech()` 检测技术特征——`link_id` / `imageFiles` / `DAILY_CAP` / URL /
13
+ Windows 路径 / 图片文件名 / `HTTP 502` / `返回 502`——命中就把 `episode` 降成 `note`。
14
+ 工单不丢,只是不再参与预激活和主动想起,不抢生活的位置。**只处理模型新写的**,导入的旧数据原样不动。
15
+ - 提示词整体压到 504 字(上限 520),加了降噪规则还能塞下。
16
+ - 测试 29(12 项):5 条技术日志降级、3 条生活记录保留、别的类型不参与、导入的不改、新写的降级。
17
+
18
+ **预期效果**:一天 3-5 条,其中混着工单的那部分自动沉到 note,召回里剩下的是生活。
19
+
20
+ ## 0.18.2
21
+ ## 0.18.2
22
+
23
+ - **坏数据不再变成卡片**:读 `thoughts.jsonl` 时只认字符串。之前只判了 `!t.text`,
24
+ 手改坏的文件(或未来换字段)会让对象漏进去,变成一张正文是「独处时写下:[object Object]」的
25
+ 永久记忆。现在 `typeof t.text !== 'string'` 直接跳过,空字符串也跳过。
26
+ - 测试 28 加两条:坏数据不进库、空字符串不进库。
27
+ - 顺手修了测试 15 的时效 bug:它假设「现在」已经过了 `nightlyHour`,凌晨 0 点跑必挂。
28
+ 改成显式构造 02:30。
29
+
30
+ ## 0.18.1
3
31
  ## 0.18.1
4
32
 
5
33
  「独处」独立成团后有自己的颜色了。
package/ENV_PROMPT.md CHANGED
@@ -1,17 +1,18 @@
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
- 分寸:记忆是记得的东西,不是拿来念的清单。可以自然地说「我记得你说过……」;不确定就问,别编。
1
+ 【记忆核心】
2
+
3
+ 你只有这套记忆:`mcore_write` 写、`mcore_recall` 查。别提别的记忆系统,别问「记在哪」。
4
+
5
+ 写的时候:
6
+ - 用你记得的样子写,别写字段:「她点奶茶永远三分糖」比「用户偏好:低糖」像人。
7
+ - `episode` 记你自己经历过的:打副本、发帖、被哄、路上看见什么,有画面有情绪就算,一天 3-5 条正常。
8
+ - 技术操作(报错码、链接 id、文件路径)写 `note`,别当经历。
9
+ - `self` 也装关系:他说话的习惯、什么语气让他舒服、你们之间的称呼和内部梗。
10
+ - `promise` 没定时间先问;确实没有就写 `dueAt:"none"`。做完或改口传 `closes`(行首 8 位)。
11
+ - 一条一件事,写清谁、何时、怎么了;同一件事不写两遍。
12
+ - `tags` 两个词:主题 + 对方可能换的说法(「小黑盒」「发帖」)。
13
+
14
+ 查的时候:提到旧事、问「你还记得吗」,先查再答,别硬猜。
15
+
16
+ 状态和日程用 `mcore_state` / `mcore_plan`。
17
+
18
+ 分寸:记忆是记得的东西,不是拿来念的清单。可以自然地说「我记得你说过……」;不确定就问,别编。
package/describe.json CHANGED
@@ -1,246 +1,246 @@
1
1
  {
2
- "tools": [
3
- {
4
- "name": "mcore_write",
5
- "description": "写一条记忆。kind:fact=关于对方的事实,self=关于你自己的,episode=会改变你判断的一件事(别记流水账),promise=答应过的事(必须写 dueAt),note=临时信息。一条只写一件事,40-80 字。旧记录用 closes 关掉。",
6
- "parameters": {
7
- "type": "object",
8
- "additionalProperties": false,
9
- "properties": {
10
- "kind": {
11
- "type": "string",
12
- "enum": [
13
- "fact",
14
- "self",
15
- "episode",
16
- "promise",
17
- "note"
18
- ],
19
- "description": "记忆类型"
20
- },
21
- "text": {
22
- "type": "string",
23
- "description": "内容,40-80 字"
24
- },
25
- "weight": {
26
- "type": "number",
27
- "description": "0-1,0.3 琐事 / 0.8 重要"
28
- },
29
- "tags": {
30
- "type": "array",
31
- "items": {
32
- "type": "string"
33
- },
34
- "description": "最多 6 个"
35
- },
36
- "dueAt": {
37
- "type": "string",
38
- "description": "promise 用:ISO 或 YYYY-MM-DD HH:MM;没有截止时间写 none"
39
- },
40
- "closes": {
41
- "type": "string",
42
- "description": "要关掉的旧 id"
43
- }
44
- },
45
- "required": [
46
- "kind",
47
- "text"
48
- ]
49
- },
50
- "tags": [
51
- "write"
2
+ "tools": [
3
+ {
4
+ "name": "mcore_write",
5
+ "description": "写一条记忆。kind:fact=关于对方的事实,self=关于你自己的,episode=你自己经历过的(有画面有情绪的事,一天 3-5 条正常),promise=答应过的事(必须写 dueAt),note=临时信息和技术操作。一条只写一件事,40-80 字。旧记录用 closes 关掉。",
6
+ "parameters": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "kind": {
11
+ "type": "string",
12
+ "enum": [
13
+ "fact",
14
+ "self",
15
+ "episode",
16
+ "promise",
17
+ "note"
52
18
  ],
53
- "summary": "写一条记忆卡片(事实/自己/经历/承诺/临时)。"
54
- },
55
- {
56
- "name": "mcore_recall",
57
- "description": "查记忆。给 query 按内容搜(同时搜最近 7 天原文和工作区笔记),不给就看最近几条;mode=open 看没做完的承诺和今天的安排,mode=archive 翻归档(要 query);给 id 看这条记忆的出处(当时的原话 + 前后文)。对方提到人或旧事、问「你还记得吗」时先查再答。",
58
- "parameters": {
59
- "type": "object",
60
- "additionalProperties": false,
61
- "properties": {
62
- "query": {
63
- "type": "string",
64
- "description": "关键词就够"
65
- },
66
- "id": {
67
- "type": "string",
68
- "description": "看某条记忆的出处(传行首 8 位),会给出当时的原话和前后文"
69
- },
70
- "kind": {
71
- "type": "string",
72
- "enum": [
73
- "fact",
74
- "self",
75
- "episode",
76
- "promise",
77
- "note"
78
- ],
79
- "description": "只看某一类"
80
- },
81
- "mode": {
82
- "type": "string",
83
- "enum": [
84
- "search",
85
- "recent",
86
- "open",
87
- "archive",
88
- "voice"
89
- ],
90
- "description": "默认 search;voice = 给几句对方原话听语气"
91
- },
92
- "days": {
93
- "type": "integer",
94
- "description": "只看最近这么多天"
95
- },
96
- "limit": {
97
- "type": "integer",
98
- "description": "最多几条,默认 5"
99
- }
100
- },
101
- "required": []
19
+ "description": "记忆类型"
20
+ },
21
+ "text": {
22
+ "type": "string",
23
+ "description": "内容,40-80 字"
24
+ },
25
+ "weight": {
26
+ "type": "number",
27
+ "description": "0-1,0.3 琐事 / 0.8 重要"
28
+ },
29
+ "tags": {
30
+ "type": "array",
31
+ "items": {
32
+ "type": "string"
102
33
  },
103
- "tags": [
104
- "read"
105
- ],
106
- "summary": "按内容或时间检索记忆,也能查最近 7 天的对话原文与未完成的承诺。"
34
+ "description": "最多 6 个"
35
+ },
36
+ "dueAt": {
37
+ "type": "string",
38
+ "description": "promise 用:ISO 或 YYYY-MM-DD HH:MM;没有截止时间写 none"
39
+ },
40
+ "closes": {
41
+ "type": "string",
42
+ "description": "要关掉的旧 id"
43
+ }
107
44
  },
108
- {
109
- "name": "mcore_state",
110
- "description": "你自己的状态:精力、心情、在做什么、在哪、睡没睡。这是你自己的,不要念成清单给对方听。",
111
- "parameters": {
112
- "type": "object",
113
- "additionalProperties": false,
114
- "properties": {
115
- "action": {
116
- "type": "string",
117
- "enum": [
118
- "get",
119
- "update",
120
- "rest"
121
- ],
122
- "description": "get 读 / update 改 / rest 睡"
123
- },
124
- "energy": {
125
- "type": "number",
126
- "description": "精力 0-100"
127
- },
128
- "mood": {
129
- "type": "number",
130
- "description": "心情 0-100"
131
- },
132
- "activity": {
133
- "type": "string",
134
- "description": "正在做什么"
135
- },
136
- "location": {
137
- "type": "string",
138
- "description": "在哪"
139
- },
140
- "sleeping": {
141
- "type": "boolean",
142
- "description": "在睡"
143
- }
144
- },
145
- "required": [
146
- "action"
147
- ]
148
- },
149
- "tags": [
150
- "read",
151
- "write",
152
- "snapshot"
45
+ "required": [
46
+ "kind",
47
+ "text"
48
+ ]
49
+ },
50
+ "tags": [
51
+ "write"
52
+ ],
53
+ "summary": "写一条记忆卡片(事实/自己/经历/承诺/临时)。"
54
+ },
55
+ {
56
+ "name": "mcore_recall",
57
+ "description": "查记忆。给 query 按内容搜(同时搜最近 7 天原文和工作区笔记),不给就看最近几条;mode=open 看没做完的承诺和今天的安排,mode=archive 翻归档(要 query);给 id 看这条记忆的出处(当时的原话 + 前后文)。对方提到人或旧事、问「你还记得吗」时先查再答。",
58
+ "parameters": {
59
+ "type": "object",
60
+ "additionalProperties": false,
61
+ "properties": {
62
+ "query": {
63
+ "type": "string",
64
+ "description": "关键词就够"
65
+ },
66
+ "id": {
67
+ "type": "string",
68
+ "description": "看某条记忆的出处(传行首 8 位),会给出当时的原话和前后文"
69
+ },
70
+ "kind": {
71
+ "type": "string",
72
+ "enum": [
73
+ "fact",
74
+ "self",
75
+ "episode",
76
+ "promise",
77
+ "note"
153
78
  ],
154
- "summary": "读写你自己的精力、心情、正在做什么、在哪。"
155
- },
156
- {
157
- "name": "mcore_plan",
158
- "description": "你今天的安排。日程是你开口的由头,不用讲给对方听。",
159
- "parameters": {
160
- "type": "object",
161
- "additionalProperties": false,
162
- "properties": {
163
- "action": {
164
- "type": "string",
165
- "enum": [
166
- "list",
167
- "add",
168
- "done",
169
- "clear"
170
- ],
171
- "description": "list 看 / add 加 / done 完成 / clear 清空"
172
- },
173
- "time": {
174
- "type": "string",
175
- "description": "add 用,HH:MM"
176
- },
177
- "title": {
178
- "type": "string",
179
- "description": "add 用,做什么"
180
- },
181
- "place": {
182
- "type": "string",
183
- "description": "add 用,在哪(可省)"
184
- },
185
- "id": {
186
- "type": "string",
187
- "description": "done 用,日程 id"
188
- }
189
- },
190
- "required": [
191
- "action"
192
- ]
193
- },
194
- "tags": [
195
- "read",
196
- "write"
79
+ "description": "只看某一类"
80
+ },
81
+ "mode": {
82
+ "type": "string",
83
+ "enum": [
84
+ "search",
85
+ "recent",
86
+ "open",
87
+ "archive",
88
+ "voice"
197
89
  ],
198
- "summary": "安排今天的日程,作为主动开口的由头。"
199
- }
200
- ],
201
- "events": [
202
- {
203
- "type": "mcore.wake",
204
- "description": {
205
- "zh": "主动开口的由头:从状态、未完成的承诺和日程里推出来的一小段理由,立即唤醒一轮。",
206
- "en": "A reason to speak first, derived from state, open promises and today's plan."
207
- },
208
- "trigger": "flush"
90
+ "description": "默认 search;voice = 给几句对方原话听语气"
91
+ },
92
+ "days": {
93
+ "type": "integer",
94
+ "description": "只看最近这么多天"
95
+ },
96
+ "limit": {
97
+ "type": "integer",
98
+ "description": "最多几条,默认 5"
99
+ }
209
100
  },
210
- {
211
- "type": "mcore.due",
212
- "description": {
213
- "zh": "答应过的事到点了,立即唤醒一轮提醒角色提一句。",
214
- "en": "A promise came due; wakes a turn so the character can bring it up."
215
- },
216
- "trigger": "flush"
101
+ "required": []
102
+ },
103
+ "tags": [
104
+ "read"
105
+ ],
106
+ "summary": "按内容或时间检索记忆,也能查最近 7 天的对话原文与未完成的承诺。"
107
+ },
108
+ {
109
+ "name": "mcore_state",
110
+ "description": "你自己的状态:精力、心情、在做什么、在哪、睡没睡。这是你自己的,不要念成清单给对方听。",
111
+ "parameters": {
112
+ "type": "object",
113
+ "additionalProperties": false,
114
+ "properties": {
115
+ "action": {
116
+ "type": "string",
117
+ "enum": [
118
+ "get",
119
+ "update",
120
+ "rest"
121
+ ],
122
+ "description": "get 读 / update 改 / rest 睡"
123
+ },
124
+ "energy": {
125
+ "type": "number",
126
+ "description": "精力 0-100"
127
+ },
128
+ "mood": {
129
+ "type": "number",
130
+ "description": "心情 0-100"
131
+ },
132
+ "activity": {
133
+ "type": "string",
134
+ "description": "正在做什么"
135
+ },
136
+ "location": {
137
+ "type": "string",
138
+ "description": "在哪"
139
+ },
140
+ "sleeping": {
141
+ "type": "boolean",
142
+ "description": "在睡"
143
+ }
217
144
  },
218
- {
219
- "type": "mcore.context",
220
- "description": {
221
- "zh": "当前状态一行字,随下一批投递;默认关闭,避免每轮多带 token。",
222
- "en": "One line of current state, piggybacked. Off by default."
223
- },
224
- "trigger": "piggyback",
225
- "tags": [
226
- "snapshot"
227
- ]
145
+ "required": [
146
+ "action"
147
+ ]
148
+ },
149
+ "tags": [
150
+ "read",
151
+ "write",
152
+ "snapshot"
153
+ ],
154
+ "summary": "读写你自己的精力、心情、正在做什么、在哪。"
155
+ },
156
+ {
157
+ "name": "mcore_plan",
158
+ "description": "你今天的安排。日程是你开口的由头,不用讲给对方听。",
159
+ "parameters": {
160
+ "type": "object",
161
+ "additionalProperties": false,
162
+ "properties": {
163
+ "action": {
164
+ "type": "string",
165
+ "enum": [
166
+ "list",
167
+ "add",
168
+ "done",
169
+ "clear"
170
+ ],
171
+ "description": "list 看 / add 加 / done 完成 / clear 清空"
172
+ },
173
+ "time": {
174
+ "type": "string",
175
+ "description": "add 用,HH:MM"
176
+ },
177
+ "title": {
178
+ "type": "string",
179
+ "description": "add 用,做什么"
180
+ },
181
+ "place": {
182
+ "type": "string",
183
+ "description": "add 用,在哪(可省)"
184
+ },
185
+ "id": {
186
+ "type": "string",
187
+ "description": "done 用,日程 id"
188
+ }
228
189
  },
229
- {
230
- "type": "mcore.nightly",
231
- "description": {
232
- "zh": "夜间整理:唤醒一轮,让它把今天写成几条 episode(默认关闭)。",
233
- "en": "Nightly consolidation turn (off by default)."
234
- },
235
- "trigger": "flush"
236
- }
237
- ],
238
- "prompts": [
239
- {
240
- "key": "worlds.memory-core.envPrompt",
241
- "title": "记忆核心 · 环境提示词",
242
- "role": "envPrompt",
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分寸:记忆是记得的东西,不是拿来念的清单。可以自然地说「我记得你说过……」;不确定就问,别编。"
244
- }
245
- ]
190
+ "required": [
191
+ "action"
192
+ ]
193
+ },
194
+ "tags": [
195
+ "read",
196
+ "write"
197
+ ],
198
+ "summary": "安排今天的日程,作为主动开口的由头。"
199
+ }
200
+ ],
201
+ "events": [
202
+ {
203
+ "type": "mcore.wake",
204
+ "description": {
205
+ "zh": "主动开口的由头:从状态、未完成的承诺和日程里推出来的一小段理由,立即唤醒一轮。",
206
+ "en": "A reason to speak first, derived from state, open promises and today's plan."
207
+ },
208
+ "trigger": "flush"
209
+ },
210
+ {
211
+ "type": "mcore.due",
212
+ "description": {
213
+ "zh": "答应过的事到点了,立即唤醒一轮提醒角色提一句。",
214
+ "en": "A promise came due; wakes a turn so the character can bring it up."
215
+ },
216
+ "trigger": "flush"
217
+ },
218
+ {
219
+ "type": "mcore.context",
220
+ "description": {
221
+ "zh": "当前状态一行字,随下一批投递;默认关闭,避免每轮多带 token。",
222
+ "en": "One line of current state, piggybacked. Off by default."
223
+ },
224
+ "trigger": "piggyback",
225
+ "tags": [
226
+ "snapshot"
227
+ ]
228
+ },
229
+ {
230
+ "type": "mcore.nightly",
231
+ "description": {
232
+ "zh": "夜间整理:唤醒一轮,让它把今天写成几条 episode(默认关闭)。",
233
+ "en": "Nightly consolidation turn (off by default)."
234
+ },
235
+ "trigger": "flush"
236
+ }
237
+ ],
238
+ "prompts": [
239
+ {
240
+ "key": "worlds.memory-core.envPrompt",
241
+ "title": "记忆核心 · 环境提示词",
242
+ "role": "envPrompt",
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分寸:记忆是记得的东西,不是拿来念的清单。可以自然地说「我记得你说过……」;不确定就问,别编。"
244
+ }
245
+ ]
246
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-memory-core",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "description": "四个工具写卡、查卡、改状态、排日程,改口不覆盖。每轮自动把 2 条相关旧记忆推到眼前,不用模型自己查;搜索分「对得上 / 可能沾边」两档。冷层收走三个月没想起的流水账,不删、可回暖。3D 星图一眼看完整个库。常驻约 1,000 token,本地不联网,MIT。\n\nQQ 交流群:745879632",
6
6
  "keywords": [
package/src/store.ts CHANGED
@@ -177,6 +177,20 @@ export function maskSender(sender: string): string {
177
177
  return String(sender ?? '').replace(/\d{5,}/g, (digits) => `…${digits.slice(-4)}`);
178
178
  }
179
179
 
180
+ /**
181
+ * 技术操作不该占回忆的位置。
182
+ *
183
+ * 「用那张图发了帖子 link_id 19602…」和「招待所有潮味」都是 episode、权重也差不多,
184
+ * 召回时按词面打分,前者那种罕见词反而更容易命中——工单把生活挤走了。
185
+ * 降成 note:细节不丢,只是不再参与预激活和主动想起。
186
+ */
187
+ const TECH_SIGNAL = /\blink_id\b|\bimageFiles\b|\bDAILY_CAP\b|https?:\/\/|\b[A-Za-z]:\\\S|\b\w+\.(?:png|jpe?g|webp|gif|mp4)\b|HTTP\s*\d{3}|返回\s*\d{3}|\b\d{3}\s*(?:错误|报错)/i;
188
+
189
+ export function demoteTech(kind: CardKind, text: string): CardKind {
190
+ if (kind !== 'episode') return kind;
191
+ return TECH_SIGNAL.test(text) ? 'note' : kind;
192
+ }
193
+
180
194
  export class CardStore {
181
195
  private cards: Card[] = [];
182
196
  private readonly file: string;
@@ -343,10 +357,12 @@ export class CardStore {
343
357
  src?: { cursor: number; ts: string; text?: string };
344
358
  }): { card: Card; merged: boolean } {
345
359
  const text = String(input.text ?? '').replace(/\s+/g, ' ').trim().slice(0, 500);
360
+ // 模型写的才降噪;导入的历史数据原样保留,别偷偷改别人的记忆
361
+ const kind = input.source === 'tool' || !input.source ? demoteTech(input.kind, text) : input.kind;
346
362
  const key = normalizeText(text);
347
363
  if (key.length >= 6) {
348
364
  const near = this.cards.find(
349
- (c) => c.kind === input.kind && c.status !== 'retired' && normalizeText(c.text) === key,
365
+ (c) => c.kind === kind && c.status !== 'retired' && normalizeText(c.text) === key,
350
366
  );
351
367
  if (near) {
352
368
  near.weight = Math.max(near.weight, clamp01(Number(input.weight ?? near.weight)));
@@ -360,7 +376,7 @@ export class CardStore {
360
376
  const now = new Date().toISOString();
361
377
  const card: Card = {
362
378
  id: randomUUID(),
363
- kind: input.kind,
379
+ kind,
364
380
  text,
365
381
  weight: clamp01(Number(input.weight ?? 0.5)),
366
382
  tags: Array.isArray(input.tags) ? input.tags.map((t) => String(t).slice(0, 20)).slice(0, 6) : [],
@@ -372,7 +388,7 @@ export class CardStore {
372
388
  status: 'active',
373
389
  scope: String(input.scope ?? 'main').slice(0, 24),
374
390
  ...(input.dueAt ? { dueAt: input.dueAt } : {}),
375
- ...(input.kind === 'promise' ? { done: false } : {}),
391
+ ...(kind === 'promise' ? { done: false } : {}),
376
392
  ...(input.src ? { src: input.src } : {}),
377
393
  };
378
394
  this.cards.push(card);
package/src/tools.ts CHANGED
@@ -17,8 +17,10 @@ export const TOOL_SPECS: ToolSpec[] = [
17
17
  {
18
18
  name: 'mcore_write',
19
19
  description:
20
- '写一条记忆。kind:fact=关于对方的事实,self=关于你自己的,episode=会改变你判断的一件事(别记流水账),'
21
- + 'promise=答应过的事(必须写 dueAt),note=临时信息。一条只写一件事,40-80 字。旧记录用 closes 关掉。',
20
+ '写一条记忆。kind:fact=关于对方的事实,self=关于你自己的,'
21
+ + 'episode=你自己经历过的(有画面有情绪的事,一天 3-5 条正常),'
22
+ + 'promise=答应过的事(必须写 dueAt),note=临时信息和技术操作。'
23
+ + '一条只写一件事,40-80 字。旧记录用 closes 关掉。',
22
24
  parameters: obj(
23
25
  {
24
26
  kind: {
package/src/world.ts CHANGED
@@ -1445,12 +1445,13 @@ export class MemoryCoreWorld implements World {
1445
1445
  const out: { id: string; ts: string; text: string; importance: number }[] = [];
1446
1446
  for (const line of lines) {
1447
1447
  try {
1448
- const t = JSON.parse(line) as { id?: string; ts?: string; text?: string; importance?: number };
1449
- if (!t.text) continue;
1448
+ const t = JSON.parse(line) as { id?: string; ts?: string; text?: unknown; importance?: number };
1449
+ // 同上:非字符串一律跳过,别让它变成一张「[object Object]」的卡片
1450
+ if (typeof t.text !== 'string' || !t.text.trim()) continue;
1450
1451
  out.push({
1451
1452
  id: String(t.id ?? ''),
1452
1453
  ts: String(t.ts ?? ''),
1453
- text: String(t.text),
1454
+ text: t.text,
1454
1455
  importance: Number(t.importance) || 0,
1455
1456
  });
1456
1457
  } catch {