@jokab1074/rememberme 0.22.0 → 0.22.1

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/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -55,8 +56,8 @@
55
56
  to the Licensor or its representatives, including but not limited to
56
57
  communication on electronic mailing lists, source code control systems,
57
58
  and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of tracking or otherwise improving the Work,
59
- but excludes communication that is conspicuously marked or otherwise
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
60
61
  designated in writing by the copyright owner as "Not a Contribution."
61
62
 
62
63
  "Contributor" shall mean Licensor and any individual or Legal Entity
@@ -68,7 +69,7 @@
68
69
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
70
  copyright license to reproduce, prepare Derivative Works of,
70
71
  publicly display, publicly perform, sublicense, and distribute the
71
- Work and Derivative Works in Source or Object form.
72
+ Work and such Derivative Works in Source or Object form.
72
73
 
73
74
  3. Grant of Patent License. Subject to the terms and conditions of
74
75
  this License, each Contributor hereby grants to You a perpetual,
@@ -116,7 +117,7 @@
116
117
  of the NOTICE file are for informational purposes only and
117
118
  do not modify the License. You may add Your own attribution
118
119
  notices within Derivative Works that You distribute, alongside
119
- or as an alternative to the NOTICE text from the Work, provided
120
+ or as an addendum to the NOTICE text from the Work, provided
120
121
  that such additional attribution notices cannot be construed
121
122
  as modifying the License.
122
123
 
@@ -137,8 +138,8 @@
137
138
 
138
139
  6. Trademarks. This License does not grant permission to use the trade
139
140
  names, trademarks, service marks, or product names of the Licensor,
140
- except as required for describing the origin of the Work and
141
- reproducing the content of the NOTICE file.
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
142
143
 
143
144
  7. Disclaimer of Warranty. Unless required by applicable law or
144
145
  agreed to in writing, Licensor provides the Work (and each
@@ -162,16 +163,16 @@
162
163
  other commercial damages or losses), even if such Contributor
163
164
  has been advised of the possibility of such damages.
164
165
 
165
- 9. Accepting Warranty or Support. While redistributing the Work or
166
- Derivative Works thereof, You may choose to offer, and charge a
167
- fee for, acceptance of support, warranty, indemnity, or other
168
- liability obligations and/or rights consistent with this License.
169
- However, in accepting such obligations, You may act only on Your
170
- own behalf and on Your sole responsibility, not on behalf of any
171
- other Contributor, and only if You agree to indemnify, defend,
172
- and hold each Contributor harmless for any liability incurred by,
173
- or claims asserted against, such Contributor by reason of your
174
- accepting any such warranty or support.
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
175
176
 
176
177
  END OF TERMS AND CONDITIONS
177
178
 
@@ -186,7 +187,7 @@
186
187
  same "printed page" as the copyright notice for easier
187
188
  identification within third-party archives.
188
189
 
189
- Copyright 2026 EmoTalk Contributors
190
+ Copyright 2026 RememberMe Contributors
190
191
 
191
192
  Licensed under the Apache License, Version 2.0 (the "License");
192
193
  you may not use this file except in compliance with the License.
@@ -198,4 +199,4 @@
198
199
  distributed under the License is distributed on an "AS IS" BASIS,
199
200
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
201
  See the License for the specific language governing permissions and
201
- limitations under the License.
202
+ limitations under the License.
package/README.en.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  [English](README.en.md) | [中文](README.md)
4
4
 
5
+ [![CI](https://github.com/SoHardToMakeAName/RememberMe/actions/workflows/ci.yml/badge.svg)](https://github.com/SoHardToMakeAName/RememberMe/actions/workflows/ci.yml)
6
+ [![npm](https://img.shields.io/npm/v/@jokab1074/rememberme.svg)](https://www.npmjs.com/package/@jokab1074/rememberme)
7
+
5
8
  > **RememberMe MCP is live** — see the [MCP server (as a memory backend)](#mcp-server-as-a-memory-backend) section.
6
9
 
7
10
  > An AI companion that **actually remembers you**. Switch models, switch platforms, close and reopen — it still knows who you are, what you like, and what you've been through.
@@ -49,6 +52,21 @@ Every entry is a **plain text file** — you can open it in any editor, read it,
49
52
  - ✅ **Local data**: your profile, memories, reflections, and feedback-learned observations only live in `data/`, covered by `.gitignore`. RememberMe does not upload them to any RememberMe-controlled server.
50
53
  - ⚠️ **LLM calls**: to work, RememberMe has to send conversation content to the LLM provider you configured (Anthropic / DeepSeek / OpenAI / etc.). RememberMe itself does not store conversations outside your local disk, but **you have to trust your LLM provider** — this is a constraint shared by every LLM-based application.
51
54
 
55
+ ### 🌐 The web UI binds to localhost only
56
+
57
+ The web server binds **127.0.0.1** by default, so other devices on the same WiFi / LAN **cannot reach it**.
58
+ (Earlier versions omitted `hostname`, and Bun defaults to `0.0.0.0` — reachable from the LAN, where `/api/send` spends your API key on whoever asks. Tightened in v0.22.0.)
59
+
60
+ | What you want | How |
61
+ |---|---|
62
+ | Local use only (default) | nothing to set |
63
+ | Use it from another device on your LAN | `HOST=0.0.0.0 EC_WEB_TOKEN=your-token bun run start` |
64
+ | Genuinely open with no auth (not recommended) | `HOST=0.0.0.0 EC_WEB_ALLOW_UNAUTHENTICATED=1 bun run start` |
65
+
66
+ - With `EC_WEB_TOKEN` set, every `/api/*` route requires `Authorization: Bearer <token>`; the browser asks for the token once and keeps it in `localStorage`
67
+ - **Listening on a non-loopback address without a token → the server refuses to start** (better to fail than to silently hand your key away)
68
+ - Every `/api/*` route also checks the `Origin` header, blocking browser-originated cross-site requests (CSRF)
69
+
52
70
  ---
53
71
 
54
72
  ## Core Features
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  [English](README.en.md) | [中文](README.md)
4
4
 
5
+ [![CI](https://github.com/SoHardToMakeAName/RememberMe/actions/workflows/ci.yml/badge.svg)](https://github.com/SoHardToMakeAName/RememberMe/actions/workflows/ci.yml)
6
+ [![npm](https://img.shields.io/npm/v/@jokab1074/rememberme.svg)](https://www.npmjs.com/package/@jokab1074/rememberme)
7
+
5
8
  > **RememberMe MCP 已经上线** —— 详见 [MCP Server(记忆后端形态)](#mcp-server记忆后端形态) 一节。
6
9
 
7
10
  > 一个**真的记得你**的 AI 陪伴。换模型、换平台、关掉再开,它依然知道你是谁、你喜欢什么、你经历过什么。
@@ -52,6 +55,21 @@
52
55
  - ✅ **本地数据**:你的画像、记忆、反思、反馈学习记录都只在 `data/` 目录下,`.gitignore` 已经覆盖,RememberMe 不主动上传到任何 RememberMe 控制的服务器
53
56
  - ⚠️ **LLM 调用**:要工作就必须把对话内容发到你配置的 LLM provider(Anthropic / DeepSeek / OpenAI 等)。RememberMe 本身不存储这些对话之外的位置,但**你信任你的 LLM provider 这一点是前提** —— 这是所有基于 LLM 的应用都共有的限制
54
57
 
58
+ ### 🌐 网页版默认只监听本机
59
+
60
+ 网页版默认绑定 **127.0.0.1**,同一个 WiFi / 局域网里的其他设备**访问不到**。
61
+ (早期版本不写 `hostname`,Bun 默认绑 `0.0.0.0` —— 局域网可见,而 `/api/send` 会直接用你的 API key 调 LLM,等于把额度送人。v0.22.0 起默认已收紧。)
62
+
63
+ | 需求 | 怎么做 |
64
+ |---|---|
65
+ | 只在本机用(默认) | 什么都不用设 |
66
+ | 要在局域网的其他设备上用 | `HOST=0.0.0.0 EC_WEB_TOKEN=你的令牌 bun run start` |
67
+ | 确实要裸奔(不建议) | `HOST=0.0.0.0 EC_WEB_ALLOW_UNAUTHENTICATED=1 bun run start` |
68
+
69
+ - 设了 `EC_WEB_TOKEN` 后,所有 `/api/*` 都要求 `Authorization: Bearer <token>`;浏览器第一次访问会弹窗要一次令牌,之后存在 `localStorage`
70
+ - **对外监听却没有令牌 → 服务器拒绝启动**(宁可起不来,也不默默把 key 送人)
71
+ - 所有 `/api/*` 还会检查 `Origin`,挡掉浏览器发起的跨站请求(CSRF)
72
+
55
73
  ---
56
74
 
57
75
  ## 核心特性
package/dist/mcp/index.js CHANGED
@@ -27445,11 +27445,14 @@ async function syncFromSources(profile, dataDir, options) {
27445
27445
  `);
27446
27446
  }
27447
27447
  if (summary.recentChanges.length > 0) {
27448
- profile.sections["近期变化"] = [
27448
+ const { text, changed: recentChanged } = refreshRecentTrends(profile.sections["近期变化"] ?? "", [
27449
27449
  "**最近变化趋势:**",
27450
27450
  ...summary.recentChanges.map((c) => `- ${c}`)
27451
27451
  ].join(`
27452
- `);
27452
+ `));
27453
+ if (recentChanged) {
27454
+ profile.sections["近期变化"] = text;
27455
+ }
27453
27456
  }
27454
27457
  return;
27455
27458
  } catch {}
@@ -27497,7 +27500,10 @@ async function syncFromSourcesFallback(profile, memories, learner, timelineSumma
27497
27500
  `);
27498
27501
  }
27499
27502
  if (timelineSummary) {
27500
- profile.sections["近期变化"] = timelineSummary;
27503
+ const { text, changed: recentChanged } = refreshRecentTrends(profile.sections["近期变化"] ?? "", timelineSummary);
27504
+ if (recentChanged) {
27505
+ profile.sections["近期变化"] = text;
27506
+ }
27501
27507
  }
27502
27508
  }
27503
27509
  var PROFILE_EXTRACT_PROMPT = `你是用户画像更新助手。下面是一段对话历史。
@@ -27646,6 +27652,32 @@ function mergeBasicSection(current, incoming) {
27646
27652
  return { text: lines.join(`
27647
27653
  `), changed };
27648
27654
  }
27655
+ var DATED_LINE_RE = /^\s*-\s*\(\d{4}-\d{2}-\d{2}\)/;
27656
+ function mergeRecentSection(current, incoming, dateStr) {
27657
+ const isEmpty = !current.trim() || current === "(暂无)" || current.startsWith("(暂无");
27658
+ const lines = isEmpty ? [] : current.split(`
27659
+ `).filter((l) => l.trim());
27660
+ const content = incoming.trim();
27661
+ if (!content)
27662
+ return { text: current, changed: false };
27663
+ const norm = (s) => s.replace(/\s+/g, "");
27664
+ const key = norm(content).slice(0, 30);
27665
+ if (key && lines.some((l) => norm(l).includes(key))) {
27666
+ return { text: current, changed: false };
27667
+ }
27668
+ lines.push(`- (${dateStr}) ${content}`);
27669
+ return { text: lines.slice(-40).join(`
27670
+ `), changed: true };
27671
+ }
27672
+ function refreshRecentTrends(current, newBody) {
27673
+ const dated = current.split(`
27674
+ `).filter((l) => DATED_LINE_RE.test(l));
27675
+ const body = newBody.split(`
27676
+ `).filter((l) => l.trim());
27677
+ const next = [...body, ...dated].join(`
27678
+ `);
27679
+ return { text: next, changed: next !== current };
27680
+ }
27649
27681
  function mergeProfileUpdate(profile, update, now = new Date) {
27650
27682
  let changed = false;
27651
27683
  const dateStr = now.toISOString().slice(0, 10);
@@ -27676,15 +27708,9 @@ function mergeProfileUpdate(profile, update, now = new Date) {
27676
27708
  const recentIncoming = update["近期变化"];
27677
27709
  if (recentIncoming && recentIncoming.trim()) {
27678
27710
  const current = profile.sections["近期变化"] ?? "";
27679
- const incoming = recentIncoming.trim();
27680
- const isEmpty = !current.trim() || current === "(暂无)" || current.startsWith("(暂无");
27681
- const isDup = current.replace(/\s+/g, "").includes(incoming.replace(/\s+/g, "").slice(0, 30));
27682
- if (!isEmpty && isDup) {} else {
27683
- const lines = isEmpty ? [] : current.split(`
27684
- `).filter((l) => l.trim());
27685
- lines.push(`- (${dateStr}) ${incoming}`);
27686
- profile.sections["近期变化"] = lines.slice(-30).join(`
27687
- `);
27711
+ const { text, changed: recentChanged } = mergeRecentSection(current, recentIncoming, dateStr);
27712
+ if (recentChanged) {
27713
+ profile.sections["近期变化"] = text;
27688
27714
  changed = true;
27689
27715
  }
27690
27716
  }
@@ -27702,7 +27728,6 @@ async function maybeUpdateProfile(dataDir, provider, recentMessages, options) {
27702
27728
  if (Object.keys(update).length > 0) {
27703
27729
  changed = mergeProfileUpdate(profile, update);
27704
27730
  }
27705
- await syncFromSources(profile, dataDir, { ...options, provider });
27706
27731
  await saveProfile(profile);
27707
27732
  const changes = [];
27708
27733
  for (const s of ["基本信息", "沟通风格", "近期变化"]) {
@@ -37081,6 +37106,33 @@ function providerStatus() {
37081
37106
  // src/mcp/tools/record-turn.ts
37082
37107
  var EXTRACT_BUFFER_THRESHOLD = 2;
37083
37108
  var MAX_BUFFER = 10;
37109
+ function formatEmotionHints(p2) {
37110
+ const parts = [];
37111
+ if (p2.emotion?.trim())
37112
+ parts.push(`情绪=${p2.emotion.trim()}`);
37113
+ if (typeof p2.intensity === "number" && Number.isFinite(p2.intensity)) {
37114
+ parts.push(`强度=${p2.intensity.toFixed(1)}`);
37115
+ }
37116
+ if (p2.trigger?.trim())
37117
+ parts.push(`触发=${p2.trigger.trim()}`);
37118
+ if (parts.length === 0)
37119
+ return null;
37120
+ return `[宿主已判断本轮情绪] ${parts.join(",")}`;
37121
+ }
37122
+ function buildExtractionConvo(pending) {
37123
+ const convo = [];
37124
+ for (const p2 of pending) {
37125
+ const hints = formatEmotionHints(p2);
37126
+ if (hints) {
37127
+ convo.push({ role: "system", content: hints });
37128
+ }
37129
+ convo.push({ role: "user", content: p2.userMessage });
37130
+ if (p2.assistantReply) {
37131
+ convo.push({ role: "assistant", content: p2.assistantReply });
37132
+ }
37133
+ }
37134
+ return convo;
37135
+ }
37084
37136
  function registerRecordTurnTool(server) {
37085
37137
  const pending = [];
37086
37138
  server.registerTool("record_turn", {
@@ -37089,9 +37141,9 @@ function registerRecordTurnTool(server) {
37089
37141
  inputSchema: {
37090
37142
  user_message: exports_external.string().describe("用户这轮说的话(原文)"),
37091
37143
  assistant_reply: exports_external.string().optional().describe("你这轮的回复(如果有)"),
37092
- emotion: exports_external.string().optional().describe("你这轮判断出的用户情绪类别(可选)"),
37093
- intensity: exports_external.number().min(0).max(1).optional().describe("情绪强度 0-1(可选)"),
37094
- trigger: exports_external.string().optional().describe("情绪触发原因(可选)"),
37144
+ emotion: exports_external.string().optional().describe("你这轮判断出的用户情绪类别(可选)。记忆系统会直接用它来写情绪模式的表现字段,不用再从原文猜一遍"),
37145
+ intensity: exports_external.number().min(0).max(1).optional().describe("情绪强度 0-1(可选)。同上,会被直接采用"),
37146
+ trigger: exports_external.string().optional().describe("情绪触发原因(可选)。会直接写进情绪模式的「触发条件」字段"),
37095
37147
  definite: exports_external.boolean().optional().describe("true = 用户明确要求记住,或发生了明确的重大事件(立即抽取并落盘);" + "false 或不填 = 只是又一次出现同类情绪(先攒着,攒够了再归纳成模式)。")
37096
37148
  }
37097
37149
  }, async (args) => {
@@ -37138,13 +37190,7 @@ ${status.error ?? ""}
37138
37190
  };
37139
37191
  }
37140
37192
  const existing = await scanMemory(paths.memory);
37141
- const convo = [];
37142
- for (const p2 of pending) {
37143
- convo.push({ role: "user", content: p2.userMessage });
37144
- if (p2.assistantReply) {
37145
- convo.push({ role: "assistant", content: p2.assistantReply });
37146
- }
37147
- }
37193
+ const convo = buildExtractionConvo(pending);
37148
37194
  let candidates = [];
37149
37195
  try {
37150
37196
  candidates = await extractMemoryCandidates(provider, convo, existing);
@@ -37234,7 +37280,8 @@ var INSTRUCTIONS = `你连接着 RememberMe —— 一个长期记忆系统。
37234
37280
  调用时如实传:
37235
37281
  - user_message:用户这轮说的话(原文)
37236
37282
  - assistant_reply:你这轮的回复(如果有)
37237
- - emotion / intensity / trigger:如果你已经判断出用户这轮的情绪,一并带上
37283
+ - emotion / intensity / trigger:**只要你判断出了这轮的情绪,就带上** ——
37284
+ 它们会被直接写进记忆的「触发条件」和「表现」字段,不用记忆系统再从原文猜一遍
37238
37285
  - definite:① ② → true;③ → false
37239
37286
 
37240
37287
  **不要为了"显得有用"而记录。** 无关紧要的话(寒暄、闲聊、情绪细节)不需要调用。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jokab1074/rememberme",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "一个真的记得你的 AI 陪伴。上下文编排器,把画像/记忆/情绪/历史整合成更适合当下的 system prompt。也提供 MCP server 形态的记忆后端。",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/index.js",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.SoHardToMakeAName/RememberMe",
4
4
  "title": "RememberMe",
5
5
  "description": "长期记忆 MCP server:记住用户是谁、经历过什么、情绪模式如何,跨会话不丢。",
6
- "version": "0.22.0",
6
+ "version": "0.22.1",
7
7
  "websiteUrl": "https://github.com/SoHardToMakeAName/RememberMe",
8
8
  "repository": {
9
9
  "url": "https://github.com/SoHardToMakeAName/RememberMe",
@@ -14,7 +14,7 @@
14
14
  "registryType": "npm",
15
15
  "registryBaseUrl": "https://registry.npmjs.org",
16
16
  "identifier": "@jokab1074/rememberme",
17
- "version": "0.22.0",
17
+ "version": "0.22.1",
18
18
  "runtimeHint": "npx",
19
19
  "transport": {
20
20
  "type": "stdio"
@@ -31,7 +31,8 @@ export const INSTRUCTIONS = `你连接着 RememberMe —— 一个长期记忆
31
31
  调用时如实传:
32
32
  - user_message:用户这轮说的话(原文)
33
33
  - assistant_reply:你这轮的回复(如果有)
34
- - emotion / intensity / trigger:如果你已经判断出用户这轮的情绪,一并带上
34
+ - emotion / intensity / trigger:**只要你判断出了这轮的情绪,就带上** ——
35
+ 它们会被直接写进记忆的「触发条件」和「表现」字段,不用记忆系统再从原文猜一遍
35
36
  - definite:① ② → true;③ → false
36
37
 
37
38
  **不要为了"显得有用"而记录。** 无关紧要的话(寒暄、闲聊、情绪细节)不需要调用。
@@ -23,10 +23,10 @@ import { z } from "zod";
23
23
  import {
24
24
  extractMemoryCandidates,
25
25
  saveMemoryCandidate,
26
- type AnyMemoryCandidate,
27
26
  } from "../../memory-extract.ts";
28
27
  import { maybeUpdateProfile } from "../../profile.ts";
29
- import { scanMemory } from "../../memory.ts";
28
+ // AnyMemoryCandidate 定义在 memory.ts(memory-extract.ts 只是 import 它,没有再导出)
29
+ import { scanMemory, type AnyMemoryCandidate } from "../../memory.ts";
30
30
  import { paths } from "../config.ts";
31
31
  import { getProvider, providerStatus } from "../provider.ts";
32
32
  import { log } from "../logger.ts";
@@ -36,7 +36,7 @@ const EXTRACT_BUFFER_THRESHOLD = 2;
36
36
  /** 缓冲上限(没写出时保留,防止无限增长) */
37
37
  const MAX_BUFFER = 10;
38
38
 
39
- type PendingTurn = {
39
+ export type PendingTurn = {
40
40
  userMessage: string;
41
41
  assistantReply?: string;
42
42
  emotion?: string;
@@ -44,6 +44,54 @@ type PendingTurn = {
44
44
  trigger?: string;
45
45
  };
46
46
 
47
+ /**
48
+ * 把宿主已经判断过的情绪信息格式化成一行上下文。
49
+ *
50
+ * 这三个字段原本收了却**从头到尾没被用过** —— 抽取器完全不知道宿主已经判断过一次
51
+ * 情绪,只能自己从原文重新猜一遍。而抽取 rubric 要的字段恰好就是它们:
52
+ * - emotion → emotion 条目的「manifestation」(情绪类型 + 强度描述)
53
+ * - trigger → emotion 条目的「trigger」(触发条件)
54
+ * - intensity → 强度描述
55
+ * 宿主判断一次、抽取器直接用,不用重复劳动(v0.22.1)。
56
+ *
57
+ * 单独放一条 [system] 消息,而不是拼进用户原话 ——
58
+ * 用户原话要保持原样,抽取 rubric 要求「保留用户原话片段」当证据,
59
+ * 拼进去容易被当成用户说的话。
60
+ */
61
+ export function formatEmotionHints(p: PendingTurn): string | null {
62
+ const parts: string[] = [];
63
+ if (p.emotion?.trim()) parts.push(`情绪=${p.emotion.trim()}`);
64
+ if (typeof p.intensity === "number" && Number.isFinite(p.intensity)) {
65
+ parts.push(`强度=${p.intensity.toFixed(1)}`);
66
+ }
67
+ if (p.trigger?.trim()) parts.push(`触发=${p.trigger.trim()}`);
68
+ if (parts.length === 0) return null;
69
+ return `[宿主已判断本轮情绪] ${parts.join(",")}`;
70
+ }
71
+
72
+ /**
73
+ * 把缓冲里的轮次拼成抽取用的对话。
74
+ *
75
+ * 宿主判断过的情绪信息作为独立的 [system] 一行插在对应用户消息之前,
76
+ * 用户原话保持原样。
77
+ */
78
+ export function buildExtractionConvo(
79
+ pending: PendingTurn[],
80
+ ): { role: string; content: string }[] {
81
+ const convo: { role: string; content: string }[] = [];
82
+ for (const p of pending) {
83
+ const hints = formatEmotionHints(p);
84
+ if (hints) {
85
+ convo.push({ role: "system", content: hints });
86
+ }
87
+ convo.push({ role: "user", content: p.userMessage });
88
+ if (p.assistantReply) {
89
+ convo.push({ role: "assistant", content: p.assistantReply });
90
+ }
91
+ }
92
+ return convo;
93
+ }
94
+
47
95
  export function registerRecordTurnTool(server: McpServer): void {
48
96
  const pending: PendingTurn[] = [];
49
97
 
@@ -65,14 +113,17 @@ export function registerRecordTurnTool(server: McpServer): void {
65
113
  emotion: z
66
114
  .string()
67
115
  .optional()
68
- .describe("你这轮判断出的用户情绪类别(可选)"),
116
+ .describe("你这轮判断出的用户情绪类别(可选)。记忆系统会直接用它来写情绪模式的表现字段,不用再从原文猜一遍"),
69
117
  intensity: z
70
118
  .number()
71
119
  .min(0)
72
120
  .max(1)
73
121
  .optional()
74
- .describe("情绪强度 0-1(可选)"),
75
- trigger: z.string().optional().describe("情绪触发原因(可选)"),
122
+ .describe("情绪强度 0-1(可选)。同上,会被直接采用"),
123
+ trigger: z
124
+ .string()
125
+ .optional()
126
+ .describe("情绪触发原因(可选)。会直接写进情绪模式的「触发条件」字段"),
76
127
  definite: z
77
128
  .boolean()
78
129
  .optional()
@@ -140,13 +191,7 @@ export function registerRecordTurnTool(server: McpServer): void {
140
191
  }
141
192
 
142
193
  const existing = await scanMemory(paths.memory);
143
- const convo: { role: "user" | "assistant"; content: string }[] = [];
144
- for (const p of pending) {
145
- convo.push({ role: "user", content: p.userMessage });
146
- if (p.assistantReply) {
147
- convo.push({ role: "assistant", content: p.assistantReply });
148
- }
149
- }
194
+ const convo = buildExtractionConvo(pending);
150
195
 
151
196
  let candidates: AnyMemoryCandidate[] = [];
152
197
  try {