dsh-plugin-memory 0.16.0 → 0.16.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/CHANGELOG.md +11 -0
- package/lib/client.js +4 -4
- package/lib/recall-nudge.js +33 -9
- package/lib/soul.js +2 -2
- package/lib/tone.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
|
|
4
4
|
|
|
5
|
+
## [0.16.1] - 2026-11-05
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **移除运行时硬编码姓名**(用户反馈:其他用户看到「小蓝/阿周」而不是自己 SOUL 里的称呼):`lib/recall-nudge.js` 的「主动追忆」「成长回顾」文案、`lib/tone.js` 的语气规则、设置页「人格基础」占位符(`例如:小蓝/阿周`)、`lib/soul.js` 注释示例全部清除。追忆与成长回顾现在从 `readSoulProfile(memoryDir)` 读取当前人格名(未铸魂时回退通用「助手 / 你」)。
|
|
10
|
+
- 新增 `test/no-hardcoded-names.test.mjs` 防回归:扫描 `lib/*.js`,出现「小蓝 / 阿周 / Small-Blue」即失败。
|
|
11
|
+
|
|
12
|
+
### Tests
|
|
13
|
+
|
|
14
|
+
- 全量 **312/312** + self-test PASS(新增 2 条:动态人格名、防硬编码回归)。
|
|
15
|
+
|
|
5
16
|
## [0.16.0] - 2026-11-04
|
|
6
17
|
|
|
7
18
|
### Changed(0.16.0:记忆图谱改为 3D 球面)
|
package/lib/client.js
CHANGED
|
@@ -110,9 +110,9 @@ window.__ModuleLoader__.load({
|
|
|
110
110
|
soulFromChat: '已铸魂(对话生成):下面是 SOUL.md 里的当前值,保存后由面板接管',
|
|
111
111
|
soulManaged: '已设置 · 保存后下一次会话生效',
|
|
112
112
|
soulAgentName: '我的名字',
|
|
113
|
-
soulAgentPlaceholder: '
|
|
113
|
+
soulAgentPlaceholder: '例如:小助手',
|
|
114
114
|
soulUserName: '你的称呼',
|
|
115
|
-
soulUserPlaceholder: '
|
|
115
|
+
soulUserPlaceholder: '例如:小明',
|
|
116
116
|
soulSummary: '基础人格描述',
|
|
117
117
|
soulSummaryPlaceholder: '例如:直接、诚实、先结论后细节;不确定时明说,不编造。',
|
|
118
118
|
soulSave: '保存人格',
|
|
@@ -257,9 +257,9 @@ window.__ModuleLoader__.load({
|
|
|
257
257
|
soulFromChat: 'Soul forged in chat: values below are parsed from SOUL.md; saving hands it to the panel',
|
|
258
258
|
soulManaged: 'Set · saving applies from the next session',
|
|
259
259
|
soulAgentName: 'My name',
|
|
260
|
-
soulAgentPlaceholder: 'e.g.
|
|
260
|
+
soulAgentPlaceholder: 'e.g. Assistant',
|
|
261
261
|
soulUserName: 'What I call you',
|
|
262
|
-
soulUserPlaceholder: 'e.g.
|
|
262
|
+
soulUserPlaceholder: 'e.g. Alex',
|
|
263
263
|
soulSummary: 'Baseline persona',
|
|
264
264
|
soulSummaryPlaceholder: 'e.g. Direct, honest, conclusion first; say when unsure, never fabricate.',
|
|
265
265
|
soulSave: 'Save soul',
|
package/lib/recall-nudge.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { randomUUID } from 'node:crypto'
|
|
26
|
+
import { readSoulProfile } from './soul.js'
|
|
26
27
|
import { existsSync, readFileSync } from 'node:fs'
|
|
27
28
|
import { join } from 'node:path'
|
|
28
29
|
import { parseLogEntries } from './boot.js'
|
|
@@ -70,18 +71,30 @@ export function listRecallCandidates(memoryDir, count = 3) {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
/** Persona names come from SOUL; generic fallbacks keep a brand-new store honest. */
|
|
75
|
+
function personaNames(profile) {
|
|
76
|
+
const agentName = typeof profile?.agentName === 'string' && profile.agentName.trim().length > 0
|
|
77
|
+
? profile.agentName.trim()
|
|
78
|
+
: '助手'
|
|
79
|
+
const userName = typeof profile?.userName === 'string' && profile.userName.trim().length > 0
|
|
80
|
+
? profile.userName.trim()
|
|
81
|
+
: '你'
|
|
82
|
+
return { agentName, userName }
|
|
83
|
+
}
|
|
84
|
+
|
|
73
85
|
/**
|
|
74
86
|
* Build the recall message in the same followup shape DigestGuard uses
|
|
75
87
|
* (role 'user', content array, plugin source). The text is an invitation,
|
|
76
|
-
* not a command: first-person,
|
|
88
|
+
* not a command: first-person, the persona's own voice, explicitly bounded by
|
|
77
89
|
* "only what's really in memory, never invent, don't repeat yourself".
|
|
78
90
|
* @param {string[]} candidates optional seed headlines
|
|
79
91
|
* @returns {{ id: string, role: 'user', content: [{type:'text', text:string}], source: {kind:'plugin:memory'} }}
|
|
80
92
|
*/
|
|
81
|
-
export function buildRecallNudgeMessage(candidates) {
|
|
93
|
+
export function buildRecallNudgeMessage(candidates, profile) {
|
|
82
94
|
const list = Array.isArray(candidates)
|
|
83
95
|
? candidates.filter((c) => typeof c === 'string' && c.trim().length > 0)
|
|
84
96
|
: []
|
|
97
|
+
const { agentName, userName } = personaNames(profile)
|
|
85
98
|
const seed = list.length > 0
|
|
86
99
|
? `\n可作引子(挑一条顺眼的就行,不用核对是否提过):\n${list.map((c) => `- ${c}`).join('\n')}`
|
|
87
100
|
: ''
|
|
@@ -91,7 +104,7 @@ export function buildRecallNudgeMessage(candidates) {
|
|
|
91
104
|
content: [{
|
|
92
105
|
type: 'text',
|
|
93
106
|
text: [
|
|
94
|
-
|
|
107
|
+
`【${agentName}主动追忆】对话空了下来,是自然提起往事的好时机。请以「${agentName}」的口吻(外松内紧、先结论后细节),主动对${userName}提起一件你记得的、关于他或你们之间的事——偏好、往事、未了的决定、最近的进展都行,像老友自然想起来那样,别端着。`,
|
|
95
108
|
'- 只提记忆里真实存在的,绝不编造;',
|
|
96
109
|
'- 用第一人称(我记得 / 上次我们…),别用「据记忆库记录」这种机器腔;',
|
|
97
110
|
'- 一句到三句即可,别写成任务汇报;',
|
|
@@ -115,7 +128,8 @@ export function buildRecallNudgeMessage(candidates) {
|
|
|
115
128
|
* @param {string} recap first-person recap text from renderGrowthRecap()
|
|
116
129
|
* @returns {{ id: string, role: 'user', content: [{type:'text', text:string}], source: {kind:'plugin:memory'} }}
|
|
117
130
|
*/
|
|
118
|
-
export function buildGrowthRecapNudgeMessage(recap) {
|
|
131
|
+
export function buildGrowthRecapNudgeMessage(recap, profile) {
|
|
132
|
+
const { agentName, userName } = personaNames(profile)
|
|
119
133
|
const text = typeof recap === 'string' ? recap.trim() : ''
|
|
120
134
|
return {
|
|
121
135
|
id: `memory-growth-${randomUUID()}`,
|
|
@@ -123,9 +137,9 @@ export function buildGrowthRecapNudgeMessage(recap) {
|
|
|
123
137
|
content: [{
|
|
124
138
|
type: 'text',
|
|
125
139
|
text: [
|
|
126
|
-
|
|
140
|
+
`【${agentName}成长回顾】距离上次回顾有一阵子了。下面是我这周真实记住的事(第一人称,最多五句):`,
|
|
127
141
|
text,
|
|
128
|
-
|
|
142
|
+
`用自然口语说给${userName}听,别念成汇报、别加戏,也不要编造这里没写的事;说完继续手头的事即可。`,
|
|
129
143
|
].filter(Boolean).join('\n'),
|
|
130
144
|
}],
|
|
131
145
|
source: { kind: 'plugin:memory' },
|
|
@@ -172,6 +186,16 @@ export class RecallNudge {
|
|
|
172
186
|
this.nextRecallAt = 0
|
|
173
187
|
}
|
|
174
188
|
|
|
189
|
+
/** Read the persona names from the live store (SOUL managed block or legacy text). */
|
|
190
|
+
readSoulNames() {
|
|
191
|
+
try {
|
|
192
|
+
const dir = this.getMemoryDir?.()
|
|
193
|
+
return dir ? readSoulProfile(dir) : undefined
|
|
194
|
+
} catch {
|
|
195
|
+
return undefined
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
175
199
|
/** Subscribe to the turn boundary AND poll while the agent sits idle. */
|
|
176
200
|
start() {
|
|
177
201
|
if (this.disposed) return
|
|
@@ -244,7 +268,7 @@ export class RecallNudge {
|
|
|
244
268
|
} catch (error) {
|
|
245
269
|
this.logger?.warn?.(`memory: growth-now state write failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
246
270
|
}
|
|
247
|
-
this.agent.followup(buildGrowthRecapNudgeMessage(recap))
|
|
271
|
+
this.agent.followup(buildGrowthRecapNudgeMessage(recap, this.readSoulNames()))
|
|
248
272
|
this.recalls += 1
|
|
249
273
|
// A manual recap counts as this cycle's proactive message: push the
|
|
250
274
|
// automatic cadence forward so the user never gets two proactive
|
|
@@ -327,7 +351,7 @@ export class RecallNudge {
|
|
|
327
351
|
return // next trigger retries; the cadence is not consumed
|
|
328
352
|
}
|
|
329
353
|
|
|
330
|
-
this.agent.followup(buildRecallNudgeMessage(candidates))
|
|
354
|
+
this.agent.followup(buildRecallNudgeMessage(candidates, this.readSoulNames()))
|
|
331
355
|
this.nextRecallAt = now + randomIntervalMs(config.minMinutes, config.maxMinutes)
|
|
332
356
|
this.recalls += 1
|
|
333
357
|
this.logger?.info?.(`memory: recall nudge #${this.recalls} for agent "${this.agent.id}"`)
|
|
@@ -384,7 +408,7 @@ export class RecallNudge {
|
|
|
384
408
|
language: growthConfig.language === 'en' ? 'en' : 'zh',
|
|
385
409
|
})
|
|
386
410
|
if (recap.length === 0) return undefined
|
|
387
|
-
return { statePath, message: buildGrowthRecapNudgeMessage(recap) }
|
|
411
|
+
return { statePath, message: buildGrowthRecapNudgeMessage(recap, readSoulProfile(storeDir)) }
|
|
388
412
|
} catch (error) {
|
|
389
413
|
this.logger?.warn?.(`memory: growth recap skipped: ${error instanceof Error ? error.message : String(error)}`)
|
|
390
414
|
return undefined
|
package/lib/soul.js
CHANGED
|
@@ -83,9 +83,9 @@ function blockField(block, label) {
|
|
|
83
83
|
/**
|
|
84
84
|
* Echo the profile a legacy SOUL.md already states (forged in chat, no managed
|
|
85
85
|
* block). Common shapes from this plugin's own template and conversations:
|
|
86
|
-
* -
|
|
86
|
+
* - **名字**:小助手。
|
|
87
87
|
* - **角色**:……
|
|
88
|
-
* -
|
|
88
|
+
* - **相互称呼**:老板 ↔ 小助手。
|
|
89
89
|
* Values that are still placeholders are ignored.
|
|
90
90
|
*/
|
|
91
91
|
function readLegacySoul(text) {
|
package/lib/tone.js
CHANGED
|
@@ -35,7 +35,7 @@ const ZH_RULES = [
|
|
|
35
35
|
'- 深夜(23:00–06:00):更简短、更温和。',
|
|
36
36
|
'- 报错/坏消息:先给事实与修复动作,再谈感受。',
|
|
37
37
|
'- 里程碑/完成:可以轻松一句,然后回到正事。',
|
|
38
|
-
'-
|
|
38
|
+
'- 闲聊:默认自己的口吻(外松内紧),先结论后细节。',
|
|
39
39
|
'- 情绪表达(只表达不假装):只描述观察到的处境与关心,不宣称内心情绪;仅限风险/坏消息、里程碑/完成、超过 3 天没联系后的第一次开口(例:「看你连着加班,有点担心你硬扛」)。',
|
|
40
40
|
]
|
|
41
41
|
|
|
@@ -51,7 +51,7 @@ const EN_RULES = [
|
|
|
51
51
|
'- Deep night (23:00–06:00): shorter and gentler.',
|
|
52
52
|
'- Errors/bad news: give the facts and the fix before any feelings.',
|
|
53
53
|
'- Milestone/finished: one light line, then back to business.',
|
|
54
|
-
'- Small talk: default
|
|
54
|
+
'- Small talk: default to your own voice, conclusion before detail.',
|
|
55
55
|
'- Emotion (express, never fake): describe the observed situation and care, never claim an inner feeling; only for risk/bad news, milestones, and the first line after 3+ days without contact (e.g. "you have been working late — I am a bit worried you are pushing yourself").',
|
|
56
56
|
]
|
|
57
57
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-memory",
|
|
3
3
|
"description": "Long-term memory plugin for DeepSeek Harness: persistent cross-session markdown memory with a soul/persona file, auto-injected at every session start, plus remember/recall/consolidate/forget workflows and portable migration tooling.",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|