dsh-xuyi-memory 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,15 +3,17 @@
3
3
  [![npm](https://img.shields.io/npm/v/dsh-xuyi-memory)](https://www.npmjs.com/package/dsh-xuyi-memory)
4
4
  [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/joymitu/xuyi-memory-release/blob/main/LICENSE)
5
5
 
6
- 你在 QQ 上跟她说过的话,她会记着。
6
+ 续忆是一个 DeepSeek Harness(DSH)插件,作用是给 QQ 陪伴助手加上长期记忆和日记本。DSH 能把 DeepSeek 接到 QQ 上,变成一个陪你聊天的 QQ 好友,续忆让这个好友记得住你说过的话。
7
7
 
8
- 上个月随口提了一句家里的猫,今天问起来,她还叫得出名字。你说奶茶戒了,她就不会再劝你来一杯。到了晚上,她会把你们这一天写进日记里。
8
+ 不装的话,开个新对话,或者聊久了,她就把你之前说的忘了。装上续忆以后:上个月随口提了一句家里的猫,今天问起来,她还叫得出名字;你说奶茶戒了,她就不会再劝你来一杯。到了晚上,她还会把你们这一天写进日记里。
9
9
 
10
- 续忆是给 DeepSeek Harness(DSH)QQ 陪伴助手用的记忆插件。在 DSH 左边「插件 → 添加插件」里填 `dsh-xuyi-memory`,装好点「立即启用」,跟着它扫个码,就能去 QQ 上找她了。
10
+ ![事已至此,先吃饭吧](https://cdn.jsdelivr.net/npm/dsh-xuyi-memory@1.0.2/images/eat.png)
11
+
12
+ 怎么装:在 DSH 左边「插件 → 添加插件」里填 `dsh-xuyi-memory`,装好点「立即启用」,跟着它扫个码,就能去 QQ 上找她了。
11
13
 
12
14
  ## 她的日记本
13
15
 
14
- ![续忆日记本](https://cdn.jsdelivr.net/npm/dsh-xuyi-memory@1.0.1/images/diary.png)
16
+ ![续忆日记本](https://cdn.jsdelivr.net/npm/dsh-xuyi-memory@1.0.2/images/diary.png)
15
17
 
16
18
  <sub>图里的内容是编的。</sub>
17
19
 
@@ -25,7 +27,7 @@
25
27
 
26
28
  在「TA的记忆」这一页,能看到她记住了你哪些事。点开一条,是你当时说的那句话,还有日期。
27
29
 
28
- ![TA的记忆](https://cdn.jsdelivr.net/npm/dsh-xuyi-memory@1.0.1/images/memory.png)
30
+ ![TA的记忆](https://cdn.jsdelivr.net/npm/dsh-xuyi-memory@1.0.2/images/memory.png)
29
31
 
30
32
  <sub>图里的内容是编的。</sub>
31
33
 
@@ -98,7 +100,7 @@
98
100
  新版本刚发出来的 24 小时里,DSH 会先装上旧版本(这是 pnpm 的安全设置)。想马上用最新版,在包名后面加上版本号:
99
101
 
100
102
  ```
101
- dsh-xuyi-memory@1.0.1
103
+ dsh-xuyi-memory@1.0.2
102
104
  ```
103
105
 
104
106
  装完引导没有自己弹出来,就点左侧栏的「续忆」,或者插件详情页上的「打开续忆」。
package/images/diary.png CHANGED
Binary file
package/images/eat.png ADDED
Binary file
package/index.js CHANGED
@@ -19,8 +19,13 @@ export const inject = ['tools', 'systemPrompt'];
19
19
  const packageDir = dirname(fileURLToPath(import.meta.url));
20
20
 
21
21
  // 开发时用项目里的行为文件,其它情况用包里的(用户机器上不会变)。
22
+ // 装好的包自带核心时,包里的行为文件优先:早年登记过开发目录(~/.xuyi/project.json)的电脑,
23
+ // 以前会去加载那里的旧 logic.js,新外壳配旧行为,新功能都不生效(1.0.2 装上后发现)。
24
+ // 只有明确指定的开发目录(插件配置 projectDir 或环境变量 XUYI_PROJECT_DIR)才热更开发目录里的。
22
25
  export function logicFileOf(config = {}, { home = homedir(), exists = existsSync,
23
- fallback = packageDir, platform = process.platform } = {}) {
26
+ fallback = packageDir, platform = process.platform, env = process.env } = {}) {
27
+ const explicit = [config.projectDir, env.XUYI_PROJECT_DIR].some(dir => typeof dir === 'string' && dir.trim());
28
+ if (!explicit && exists(join(fallback, 'py', 'xuyi', '__init__.py'))) return join(fallback, 'logic.js');
24
29
  const dir = findProjectDir(config, { home, platform });
25
30
  const candidate = join(dir, 'dsh-adapter', 'logic.js');
26
31
  return exists(candidate) ? candidate : join(fallback, 'logic.js');
package/logic.js CHANGED
@@ -11,16 +11,42 @@ import { installRhythm } from './rhythm.js';
11
11
  const PEER = /^qqbot:[^:]+:c2c:[^:]+$/;
12
12
  const toolBudget = 1600;
13
13
  const autoBudget = 900;
14
+ const groupBudget = 700; // 群里一次最多递这么多字节(大约两条原话,一个汉字 3 字节)
14
15
  // Windows 上启动 Python 约 2 倍于 macOS(实测单次自动召回约 230ms),给足余量。
15
16
  const defaultAutoDeadline = process.platform === 'win32' ? 900 : 450;
16
17
  const writeWait = 1500;
17
18
  const snapshotBudget = 800;
18
19
  // Keep in sync with the family QUERY regexes in xuyi/highlights.py: name, preference, appointment.
19
20
  // Diet (allergies/restrictions) fires on any eating or drinking turn; mirrors _DietFamily.QUERY.
20
- const dietQuestion = /过敏|忌口|(?:能|可以)不?(?:能)?(?:吃|喝)|不能(?:吃|喝)|(?:吃|喝)(?:点|些)?(?:什么|啥)|推荐.{0,6}(?:吃|喝|菜|外卖|餐|饭|零食|水果|甜品)|外卖|(?:早|午|晚)(?:饭|餐)|早点|夜宵|做(?:什么|啥)菜/;
21
- const memoryQuestion = /叫(?:我)?(?:什么|啥|哪个)|(?:名字|昵称|称呼)(?:是)?(?:什么|啥|哪个)|记得.*(?:名字|昵称|称呼)|(?:怎么|如何)(?:叫|称呼)我|最(?:爱|喜欢|讨厌)(?:[^。?!?]*?)?(?:什么|啥)|(?:爱|喜欢|讨厌)(?:[喝吃玩看听用穿去])(?:[^。?!?]{0,6})?(?:什么|啥)|还(?:在|再)?(?:[喝吃玩用去])(?:[^。?!?]{0,8})?(?:吗|么)|戒了(?:吗|没有)|(?:有什么|啥)(?:约定|安排|计划)|(?:约定|安排|赴约|约会|邀约|见面|碰面)(?:[^。?!?]{0,12})?(?:吗|么|啥|什么|哪)|还(?:要|得)?(?:去|见|来)(?:不)?(?:吗|么)|见不见|去不去|(?:最近|接下来)?(?:有什么|啥)(?:打算|计划)|(?:要|想|打算|准备)(?:做|干|办)的?什么(?:来着)?|准备得?(?:怎么样|如何|咋样)|我(?:今天|昨天|这几天|最近)?(?:心情|感觉)(?:怎么样|如何|咋样)|我(?:开不开心|难不难过|累不累|烦不烦)|你还?记得我(?:今天|昨天)?(?:心情|感觉|状态)吗/;
21
+ const dietQuestion = /过敏|忌口|(?:能|可以)不?(?:能)?(?:吃|喝)|不能(?:吃|喝)|(?:吃|喝)(?:点|些)?(?:什么|啥)|推荐.{0,6}(?:吃|喝|菜|外卖|餐|饭|零食|水果|甜品)|外卖|(?:早|午|晚)(?:饭|餐)|早点|夜宵|做(?:什么|啥)菜|(?:买|挑|选|点|订)(?:点|些|个|杯|份)?.{0,4}(?:水果|零食|吃的|喝的|甜品|蛋糕|奶茶|饮料|咖啡|夜宵)|想吃(?:东西|点)/;
22
+ const memoryQuestion = /叫(?:我)?(?:什么|啥|哪个)|(?:名字|昵称|称呼)(?:是)?(?:什么|啥|哪个)|记得.*(?:名字|昵称|称呼)|(?:怎么|如何)(?:叫|称呼)我|最(?:爱|喜欢|讨厌)(?:[^。?!?]*?)?(?:什么|啥)|(?:爱|喜欢|讨厌)(?:[喝吃玩看听用穿去])(?:[^。?!?]{0,6})?(?:什么|啥)|还(?:在|再)?(?:[喝吃玩用去])(?:[^。?!?]{0,8})?(?:吗|么)|戒了(?:吗|没有)|(?:有什么|啥)(?:约定|安排|计划)|(?:约定|安排|赴约|约会|邀约|见面|碰面)(?:[^。?!?]{0,12})?(?:吗|么|啥|什么|哪)|还(?:要|得)?(?:去|见|来)(?:不)?(?:吗|么)|见不见|去不去|(?:最近|接下来)?(?:有什么|啥)(?:打算|计划)|(?:要|想|打算|准备)(?:做|干|办)的?什么(?:来着)?|准备得?(?:怎么样|如何|咋样)|我(?:今天|昨天|这几天|最近)?(?:心情|感觉)(?:怎么样|如何|咋样)|我(?:开不开心|难不难过|累不累|烦不烦)|你还?记得我(?:今天|昨天)?(?:心情|感觉|状态)吗|最(?:爱|喜欢|讨厌)[^。?!?,,]{0,8}?(?:是谁|是哪|哪(?:个|位|首|部|本|种|款|家|样|一))|最(?:爱|喜欢|讨厌)的[^。?!?,,]{1,6}是\s*[??]|(?:记得|知道|猜猜?)[^。?!?,,]{0,4}最(?:爱|喜欢|讨厌)的?[^。?!?,,]{1,8}?(?:吗|么|没|不)|我(?:平时)?(?:爱|喜欢)(?:什么|啥|哪个|哪种)(?:饮料|饮品|食物|零食|水果|游戏|电影|音乐|歌|书|颜色|运动|花|动物|季节|歌手|明星|城市|菜|电视剧|剧|动漫)/;
22
23
  const nameChange = /别叫|不要叫|改叫|改名|取个名字|起个名字/;
23
24
 
25
+ // 和 Python 侧家族问句(xuyi/highlights.py 各 QUERY)要一起改:这里不放行,自动召回就不会发生。
26
+ // tests/fixtures/memory_questions.json 两边共用,Node 和 Python 测试都会检查。
27
+ // 问的是用户自己的事(「我老公叫啥」「我多高」「我还抽烟吗」):六类重点不管的,也自动带上有共同词的原话。
28
+ // 求助/求推荐(「我该怎么办」「给我推荐…」)不算:那是要建议,不是问记忆。
29
+ const aboutMeQuestion = /^[^。!!??,,]{0,8}?(?:我(?!们)|俺(?!们)|咱(?!们))[^。!!??你]{0,16}?(?:(?:什么|啥|哪|谁|多少|几|多(?:高|重|大|久|远)|怎么样|怎么了|咋样|咋了|干嘛)[^。!!??,,你]{0,6}|吗|么|没有?|了没|呢)[??]?\s*$/;
30
+ const notAboutMe = /怎么办|该|要不要|帮我|给我|推荐|建议|你觉得|你说我|教我|可以吗|行吗|好吗|对吧|是吧|好看吗|对吗|对不对|来得及|好呢|刚刚|刚才|^我是谁[??]?$|^我在哪[??]?$|在想什么/;
31
+
32
+ // 问某个有名字的人/宠物近况(「泡泡还好吗」「阿花最近怎么样」)。名字是不是档案里的专名,由核心再查一遍。
33
+ const howIsIt = /^[^你我俺咱。!!??,,\s]{1,6}(?:还好吗|还好不|怎么样了|最近怎么样|最近还好吗|现在怎么样)[??]?\s*$/;
34
+
35
+ export function isAboutMe(text) {
36
+ return (aboutMeQuestion.test(text) && !notAboutMe.test(text)) || howIsIt.test(text);
37
+ }
38
+
39
+ // 问她自己的喜好(「你最喜欢什么零食」「你爱听谁的歌」):带上她以前对同一问题的回答,前后说法一致。
40
+ const asksHerTaste = /你(?:最|平时|一般|自己)?(?:喜欢|爱|讨厌|爱吃|爱喝|爱看|爱听|爱玩)[^。!!??你]{0,10}?(?:什么|啥|哪|谁|干嘛|干啥|吗|么|呢|没)|你最(?:爱|喜欢|讨厌)的[^。!!??]{1,8}是/;
41
+
42
+ export function isAboutHer(text) {
43
+ return asksHerTaste.test(text) && !/我最|我(?:喜欢|爱)/.test(text);
44
+ }
45
+
46
+ export function isMemoryQuestion(text) {
47
+ return memoryQuestion.test(text) || dietQuestion.test(text);
48
+ }
49
+
24
50
  function userText(message, acceptAny = false) {
25
51
  if (message?.role !== 'user' || message.source?.kind !== 'user'
26
52
  || message.content?.length !== 1 || message.content[0]?.type !== 'text') return '';
@@ -29,7 +55,7 @@ function userText(message, acceptAny = false) {
29
55
  const query = raw.trim();
30
56
  if (Array.from(query).length > 120 || nameChange.test(query)) return '';
31
57
  return acceptAny ? query
32
- : (memoryQuestion.test(query) || dietQuestion.test(query) ? query : '');
58
+ : (isMemoryQuestion(query) || isAboutMe(query) || isAboutHer(query) ? query : '');
33
59
  }
34
60
 
35
61
  // How many chat bubbles to send this turn. Language models are poor dice: left alone they settle on
@@ -58,7 +84,7 @@ export function pickBubbleCount(text, recent = [], random = Math.random) {
58
84
 
59
85
  export function bubbleHint(count) {
60
86
  const words = { 1: '这一轮只发一条', 2: '这一轮发两条', 3: '这一轮发三条' };
61
- return `${words[count]},每条一行。他问的事要是一条说不清,就按需要来。`;
87
+ return `${words[count]},每条一行。对方问的事要是一条说不清,就按需要来。`;
62
88
  }
63
89
 
64
90
  function checkedContext(result, budget) {
@@ -119,6 +145,26 @@ export function parseGroupLines(text) {
119
145
  return out;
120
146
  }
121
147
 
148
+ // 群里这一轮是谁在说话(整段群消息最后一行的成员编号)。
149
+ export function groupSpeaker(message) {
150
+ const text = (Array.isArray(message?.content) ? message.content : [])
151
+ .filter(block => block?.type === 'text' && typeof block.text === 'string').map(block => block.text).join('\n');
152
+ return parseGroupLines(text).at(-1)?.sender_id ?? null;
153
+ }
154
+
155
+ // 群里这一轮要回的那句:整段群消息的最后一行(当前消息),谁说的、说了什么;不像在问记忆就不查。
156
+ export function groupQuestion(message) {
157
+ if (message?.role !== 'user' || message.source?.kind !== 'user' || !Array.isArray(message.content)) return null;
158
+ const text = message.content.filter(block => block?.type === 'text' && typeof block.text === 'string')
159
+ .map(block => block.text).join('\n');
160
+ const current = parseGroupLines(text).at(-1);
161
+ if (!current) return null;
162
+ const said = current.text.replace(/[\r\n]+/g, ' ').trim();
163
+ if (!said || Array.from(said).length > 120 || /[[\]]/.test(said)) return null;
164
+ if (!(isMemoryQuestion(said) || isAboutMe(said) || isAboutHer(said))) return null;
165
+ return { speaker: current.sender_id, name: current.sender_name, text: said };
166
+ }
167
+
122
168
  export function archiveGroupEvents(hash, sessionId, event) {
123
169
  if (!hash || !Number.isSafeInteger(event?.seq) || event.seq < 0
124
170
  || !Number.isFinite(event.time) || Math.abs(event.time) > 8.64e15) return [];
@@ -152,6 +198,8 @@ export function archiveGroupEvents(hash, sessionId, event) {
152
198
  scope: 'qq:group:' + hash,
153
199
  event_id: 'dsh:' + sessionId + ':' + event.seq + ':' + index,
154
200
  sender_id: line.sender_id,
201
+ // 群昵称进成员表(不进消息本身):提醒她时写「[小王] 我养了只柯基」,不再只有一串编号。
202
+ ...(line.sender_name ? { sender_name: line.sender_name } : {}),
155
203
  role: 'user',
156
204
  origin: 'quoted',
157
205
  recorded_at: new Date(event.time).toISOString(),
@@ -221,10 +269,17 @@ export function resolveRuntime(config = {}, { env = process.env, home = homedir(
221
269
  join(home, 'Documents', 'Codex', 'xuyi-memory')].filter(dir => typeof dir === 'string' && dir.trim());
222
270
  const found = candidates.find(dir => exists(venvPython(resolve(dir), platform)));
223
271
  const codeDir = join(pkg, 'py');
224
- if (!found && exists(join(codeDir, 'xuyi', '__init__.py'))) {
272
+ // 装进 DSH 的包自带核心时用包里的:早年登记的开发目录(~/.xuyi/project.json)里是旧代码,
273
+ // 新插件配旧核心会认不得新参数、自动提醒全部失效(1.0.2 模拟测试发现)。只有明确指定的开发目录
274
+ // (插件配置 projectDir 或环境变量 XUYI_PROJECT_DIR)才连代码一起用开发目录的。
275
+ const explicit = [config.projectDir, env.XUYI_PROJECT_DIR].filter(dir => typeof dir === 'string' && dir.trim())
276
+ .find(dir => exists(venvPython(resolve(dir), platform)));
277
+ if (!explicit && exists(join(codeDir, 'xuyi', '__init__.py'))) {
225
278
  const python = [config.python, env.XUYI_PYTHON].find(p => typeof p === 'string' && p.trim())
226
279
  ?? (exists(dshPython(home, platform)) ? dshPython(home, platform) : null);
227
- const dataDir = resolve(config.dataDir ?? join(home, '.xuyi', 'data'));
280
+ // 数据接着用原来的:以前在开发目录里聊的,档案在那儿,换成包里的核心也不能「忘了」。
281
+ const earlier = found && exists(join(resolve(found), 'data', 'dsh-qq.sqlite')) ? join(resolve(found), 'data') : null;
282
+ const dataDir = resolve(config.dataDir ?? earlier ?? join(home, '.xuyi', 'data'));
228
283
  // 语义依赖由 `xuyi prepare` 装进 ~/.xuyi/py-site,量化模型下到 ~/.xuyi/models(见 xuyi/prepare.py)。
229
284
  const siteDir = join(home, '.xuyi', 'py-site');
230
285
  const macArch = { arm64: 'arm64', x64: 'x86_64' }[arch];
@@ -379,7 +434,7 @@ export function notePrompt(request) {
379
434
  const facts = noteFacts(request);
380
435
  const lines = facts.map((fact, i) => `${i + 1}. ${fact.fact.trim()}`).join('\n');
381
436
  return `现在请你写便利贴。下面 ${facts.length} 条是你刚想起来的事。用你平时说话的口吻,一条写成一张便利贴上的短句。\n`
382
- + '规矩:一条一张,一张一行。每张 15 到 35 个字——写清「他说的哪件事」加上「你的反应或答案」,'
437
+ + '规矩:一条一张,一张一行。每张 15 到 35 个字——写清「对方说的哪件事」加上「你的反应或答案」,'
383
438
  + '别只写一个词、一个名字或半句话;便利贴不是发消息,可以比聊天时多说几个字。'
384
439
  + '只写纸条上的话,不编号、不加引号、不解释、不寒暄。\n\n'
385
440
  + lines;
@@ -719,11 +774,13 @@ export function prepareStateOf(runtime) {
719
774
  : { stage: 'waiting', percent: 0, ready: false };
720
775
  }
721
776
 
722
- async function toolRecall(runtime, dbPath, scope, budget, query, signal) {
777
+ async function toolRecall(runtime, dbPath, scope, budget, query, signal, speaker = null) {
723
778
  const progress = prepareStateOf(runtime);
724
779
  const verified = !runtime.prepareRun || progress.ready;
725
780
  const model = verified && existsSync(join(runtime.modelDir, 'model.onnx')) ? ['--model', runtime.modelDir] : [];
726
- const args = ['recall', scope, '--budget', String(budget), '--focus'];
781
+ // 群里:带上这一轮是谁在说话(别人的私事不翻给别人看,提醒里写昵称)。
782
+ const args = ['recall', scope, '--budget', String(budget), '--focus',
783
+ ...(speaker && /^[0-9A-Fa-f]{16,}$/.test(speaker) ? ['--speaker', speaker] : [])];
727
784
  if (model.length && progress.backend === 'mac-standalone') {
728
785
  const alternate = runtime.macSemantic;
729
786
  if (alternate && existsSync(alternate.python)) {
@@ -794,6 +851,10 @@ export function createSetup({ profileDir, getPluginManager, core, prefsPath, pre
794
851
  if (!/^[a-z0-9_-]{1,40}$/i.test(body.name)) throw new Error('人设名不对');
795
852
  return core(['persona', body.name, ...tail]);
796
853
  }
854
+ if (typeof body?.own === 'string') {
855
+ if (!/^[0-9a-f]{12}$/.test(body.own)) throw new Error('人设编号不对');
856
+ return core(['persona', '--own', body.own, ...tail]);
857
+ }
797
858
  const text = typeof body?.text === 'string' ? body.text.trim() : '';
798
859
  if (!text || text.length > 4000) throw new Error('人设要写 1 到 4000 字');
799
860
  const folder = mkdtempSync(join(tmpdir(), 'xuyi-persona-'));
@@ -803,6 +864,10 @@ export function createSetup({ profileDir, getPluginManager, core, prefsPath, pre
803
864
  return await core(['persona', '--file', file, ...tail]);
804
865
  } finally { rmSync(folder, { recursive: true, force: true }); }
805
866
  },
867
+ async forgetOwn(body) {
868
+ if (typeof body?.own !== 'string' || !/^[0-9a-f]{12}$/.test(body.own)) throw new Error('人设编号不对');
869
+ return core(['persona', '--forget-own', body.own]);
870
+ },
806
871
  async diaryHour(body) {
807
872
  const hour = body?.hour;
808
873
  if (!Number.isInteger(hour) || hour < 18 || hour > 23) throw new Error('写日记时间只能选 18–23 点');
@@ -819,7 +884,7 @@ export function createSetup({ profileDir, getPluginManager, core, prefsPath, pre
819
884
  };
820
885
  }
821
886
 
822
- const setupWrites = new Set(['/setup/persona', '/setup/install-qq', '/setup/diary-hour']);
887
+ const setupWrites = new Set(['/setup/persona', '/setup/forget-own', '/setup/install-qq', '/setup/diary-hour']);
823
888
 
824
889
  // ---- 到点写日记:DSH 开着时每隔几分钟问一次 Python(xuyi diary-due),该不该写、几点写由它按用户设置判断 ----
825
890
  export function startDiaryClock(run, { firstDelay = 15000, interval = 5 * 60 * 1000 } = {}) {
@@ -856,6 +921,7 @@ export function createBoardRoute(getBoard, setup = null) {
856
921
  try {
857
922
  const body = JSON.parse((await readBody(req)) || '{}');
858
923
  const action = rest === '/setup/persona' ? setup.persona(body)
924
+ : rest === '/setup/forget-own' ? setup.forgetOwn(body)
859
925
  : rest === '/setup/diary-hour' ? setup.diaryHour(body) : setup.installQq();
860
926
  return json(200, await action);
861
927
  } catch (error) {
@@ -1022,8 +1088,8 @@ export function create(ctx, config = {}, host) {
1022
1088
  const turn = state.turns.get(sessionId);
1023
1089
  if (decision.kind !== 'enter' || !turn || turn.toolCalls > 0 || turn.autoUsed || turn.autoContext
1024
1090
  || lifetime.signal.aborted || signal.aborted) return decision;
1025
- // L1:群里多人说话,自动重点/开场快照容易串;群聊只保留「查得到」(工具),不自动注入。
1026
- if (turn.peer.startsWith('qq:group:')) return decision;
1091
+ // 群聊:只在她要回话、且这句像在问记忆时,查本群的记忆(不碰私聊);没有开场快照。
1092
+ const group = turn.peer.startsWith('qq:group:');
1027
1093
  // The host enters this hook right after emitting the user message, so its own write is
1028
1094
  // usually still in flight. Wait for it (bounded); skipping here meant never auto-recalling.
1029
1095
  if (state.queueSize > 0) {
@@ -1038,6 +1104,23 @@ export function create(ctx, config = {}, host) {
1038
1104
  if (!scope || turn.peer !== scope) return decision;
1039
1105
  const users = messages.filter(message => message.source?.kind === 'user');
1040
1106
  if (users.length !== 1 || !decision.messages.includes(users[0])) return decision;
1107
+ if (group) {
1108
+ turn.speaker = groupSpeaker(users[0]);
1109
+ const asked = groupQuestion(users[0]);
1110
+ if (!asked) return decision;
1111
+ const groupSignal = AbortSignal.any([signal, lifetime.signal, AbortSignal.timeout(autoDeadline)]);
1112
+ try {
1113
+ const result = await callCore(runtime, dbPath, ['recall', scope, '--group', '--speaker', asked.speaker,
1114
+ '--budget', String(groupBudget), ...(isAboutHer(asked.text) ? ['--her'] : []), '--', asked.text],
1115
+ undefined, groupSignal);
1116
+ if (!groupSignal.aborted && state.turns.get(sessionId) === turn && scopeOf(sessionId) === scope) {
1117
+ turn.autoContext = checkedContext(result, groupBudget);
1118
+ }
1119
+ } catch {
1120
+ // 查不到就照常回话,工具还能用。
1121
+ }
1122
+ return decision;
1123
+ }
1041
1124
  const query = userText(users[0], config.autoRelated === true);
1042
1125
  if (!query && !turn.snapshot) return decision;
1043
1126
  turn.snapshot = false;
@@ -1046,7 +1129,8 @@ export function create(ctx, config = {}, host) {
1046
1129
  try {
1047
1130
  const args = query
1048
1131
  ? ['recall', scope, '--highlight-only', '--budget', String(autoBudget),
1049
- ...(config.autoRelated === true ? ['--related'] : []), '--', query]
1132
+ ...(config.autoRelated === true ? ['--related'] : []),
1133
+ ...(isAboutMe(query) ? ['--about-me'] : []), ...(isAboutHer(query) ? ['--her'] : []), '--', query]
1050
1134
  : ['snapshot', scope, '--budget', String(snapshotBudget), '--session', String(sessionId)];
1051
1135
  const budget = query ? autoBudget : snapshotBudget;
1052
1136
  const result = await callCore(runtime, dbPath, args, undefined, lookupSignal);
@@ -1081,7 +1165,7 @@ export function create(ctx, config = {}, host) {
1081
1165
  try {
1082
1166
  await state.pending;
1083
1167
  if (state.turns.get(sessionId) !== turn || scopeOf(sessionId) !== scope || signal.aborted) return '会话已切换或查询已取消。';
1084
- const result = await toolRecall(runtime, dbPath, scope, toolBudget, query, signal);
1168
+ const result = await toolRecall(runtime, dbPath, scope, toolBudget, query, signal, turn.speaker);
1085
1169
  if (state.turns.get(sessionId) !== turn || scopeOf(sessionId) !== scope || signal.aborted) return '会话已切换或查询已取消。';
1086
1170
  return checkedContext(result, toolBudget) || '这次查询没有找到可用原文。';
1087
1171
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-xuyi-memory",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "续忆 · 让 DeepSeek Harness 的 QQ 陪伴助手记得你说过的话,并写一本日记",
5
5
  "icon": "./icon.png",
6
6
  "type": "module",