@a9i5k4/dsh-auto-memory 0.1.4 → 0.1.5
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/lib/client.js +6 -0
- package/lib/index.js +39 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -130,6 +130,7 @@ window.__ModuleLoader__.load({
|
|
|
130
130
|
connectHint: '把其他 AI 工具(CodeBuddy / Claude Code / Codex / 项目约定文件等)积累的记忆接入当前 DSH 工作。接入后内容写入本地记忆并自动标注来源,后续会随会话自动注入。',
|
|
131
131
|
importAll: '一键接入全部', rescan: '重新扫描',
|
|
132
132
|
styleAuto: '由内容决定', styleLife: '生活化', styleProfessional: '专业性',
|
|
133
|
+
todayGreetingTitle: '今日问候',
|
|
133
134
|
saved: '已保存',
|
|
134
135
|
settingsHeader: '记忆存储与行为设置(保存到 DSH 主目录 dsh-auto-memory.json):',
|
|
135
136
|
fUserDir: '用户记忆目录', fUserDirHint: '跨项目规则存放处,支持 ~ 开头;需有文件写权限。',
|
|
@@ -181,6 +182,7 @@ window.__ModuleLoader__.load({
|
|
|
181
182
|
connectHint: 'Import memories accumulated by other AI tools (CodeBuddy / Claude Code / Codex / project convention files) into the current DSH workspace. Imported content is written to local memory with its source noted, and is auto-injected in future sessions.',
|
|
182
183
|
importAll: 'Import all', rescan: 'Rescan',
|
|
183
184
|
styleAuto: 'Auto', styleLife: 'Life-style', styleProfessional: 'Professional',
|
|
185
|
+
todayGreetingTitle: 'Today\'s Greeting',
|
|
184
186
|
saved: 'Saved',
|
|
185
187
|
settingsHeader: 'Memory storage & behavior (saved to ~/.dsh/dsh-auto-memory.json):',
|
|
186
188
|
fUserDir: 'User memory dir', fUserDirHint: 'Cross-project rules; supports ~ prefix; needs write permission.',
|
|
@@ -360,6 +362,10 @@ window.__ModuleLoader__.load({
|
|
|
360
362
|
}).catch(function (e) { setActMsg(t('failed') + e.message); setReflectBusy(false) })
|
|
361
363
|
}
|
|
362
364
|
return h('div', null,
|
|
365
|
+
// 今日拟人化问候(每天首次生成后常驻显示)
|
|
366
|
+
state.todayGreeting
|
|
367
|
+
? h(Card, { title: t('todayGreetingTitle') }, h('div', { 'data-dam-content': '' }, state.todayGreeting))
|
|
368
|
+
: null,
|
|
363
369
|
state.pendingReflection
|
|
364
370
|
? h(Banner, null, t('pendingReflection') + state.pendingReflection + t('pendingReflectionHint'))
|
|
365
371
|
: null,
|
package/lib/index.js
CHANGED
|
@@ -106,6 +106,7 @@ class MemoryEngine {
|
|
|
106
106
|
latestReflection: '', latestReflectionDate: '',
|
|
107
107
|
pendingReflection: undefined, // {date, text}
|
|
108
108
|
reflectionShownSession: undefined,
|
|
109
|
+
todayGreeting: '', greetingShownSession: undefined,
|
|
109
110
|
loadedAt: 0, loading: undefined, configLoaded: false,
|
|
110
111
|
}
|
|
111
112
|
this._configPath = path.join(dshHome(), 'dsh-auto-memory.json')
|
|
@@ -168,6 +169,8 @@ class MemoryEngine {
|
|
|
168
169
|
notesPath: path.join(projectDir, 'MEMORY.md'),
|
|
169
170
|
logPath: path.join(projectDir, `${todayStr()}.md`),
|
|
170
171
|
reflectDir: path.join(projectDir, 'reflections'),
|
|
172
|
+
greetDir: path.join(projectDir, 'greetings'),
|
|
173
|
+
greetPath: path.join(projectDir, 'greetings', `${todayStr()}.md`),
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
|
|
@@ -275,6 +278,8 @@ class MemoryEngine {
|
|
|
275
278
|
const pending = await this.detectPendingReflection(p.projectDir, p.reflectDir)
|
|
276
279
|
if (pending) this.state.pendingReflection = pending
|
|
277
280
|
}
|
|
281
|
+
// 今日拟人化问候(每天首会话展示一次)
|
|
282
|
+
this.state.todayGreeting = await this.readTextSafe(p.greetPath)
|
|
278
283
|
// 外部记忆探测(后台,结果进缓存)
|
|
279
284
|
if (this.config.externalSources) void this.external.discover(true)
|
|
280
285
|
this.state.loadedAt = Date.now()
|
|
@@ -358,6 +363,26 @@ class MemoryEngine {
|
|
|
358
363
|
].join('\n')
|
|
359
364
|
}
|
|
360
365
|
|
|
366
|
+
/** 拟人化问候请求块:每天首次会话注入一次(用户一打开就能看到)。 */
|
|
367
|
+
renderGreetingRequest() {
|
|
368
|
+
if (this.state.todayGreeting) return ''
|
|
369
|
+
if (this.state.greetingShownSession === todayStr()) return ''
|
|
370
|
+
this.state.greetingShownSession = todayStr()
|
|
371
|
+
const lines = this.state.recentLogs[0] ? this.state.recentLogs[0].text : ''
|
|
372
|
+
const hour = new Date().getHours()
|
|
373
|
+
const period = hour < 6 ? '凌晨' : hour < 9 ? '早上好' : hour < 12 ? '上午好' : hour < 14 ? '中午好' : hour < 18 ? '下午好' : hour < 22 ? '晚上好' : '夜深了'
|
|
374
|
+
return [
|
|
375
|
+
'\n\n[晨间问候 — 拟人化,请生成]',
|
|
376
|
+
'请以' + period + '的拟人化口吻,在本轮回复开头向用户说一段简短温暖的问候(2-4 句,像朋友聊天,不要列条框、不要用"反思"字样)。内容应自然融合:',
|
|
377
|
+
'- 昨天/最近的经历:根据以下工作回顾,自然提起"昨天你做了..."(挑 1-2 件最值得说的,轻描淡写即可)',
|
|
378
|
+
lines ? '昨天回顾:\n' + lines : '(暂无昨日日志)',
|
|
379
|
+
'- 善意提醒:如果从回顾里看出可能遗漏的事(未完成的计划、埋的坑、待办),轻轻提醒一句;没有就不提。',
|
|
380
|
+
'- 日常关心:可以自然地带一句时间/作息/状态相关的关心(如"记得吃早饭""别熬太晚"),如果有用户习惯(从记忆里看)就贴合习惯。',
|
|
381
|
+
'- 语气:温暖、自然、像朋友,不要官方、不要严肃、不要长篇大论。',
|
|
382
|
+
'生成后调用 memory_greet(date="' + todayStr() + '", text=完整问候内容)保存,之后今天不再提示。',
|
|
383
|
+
].join('\n')
|
|
384
|
+
}
|
|
385
|
+
|
|
361
386
|
// ---------- 写操作 ----------
|
|
362
387
|
async appendText(p, text) {
|
|
363
388
|
const existing = await this.readTextSafe(p)
|
|
@@ -534,6 +559,7 @@ class MemoryEngine {
|
|
|
534
559
|
todayEntries,
|
|
535
560
|
latestReflectionDate: this.state.latestReflectionDate,
|
|
536
561
|
pendingReflection: this.state.pendingReflection ? this.state.pendingReflection.date : undefined,
|
|
562
|
+
todayGreeting: this.state.todayGreeting,
|
|
537
563
|
refreshedAt: this.state.loadedAt,
|
|
538
564
|
configReadError: this._readError,
|
|
539
565
|
}
|
|
@@ -908,7 +934,7 @@ export function apply(ctx, config) {
|
|
|
908
934
|
if (!engine.state.loadedAt || Date.now() - engine.state.loadedAt > 60000) {
|
|
909
935
|
void engine.refresh(agent)
|
|
910
936
|
}
|
|
911
|
-
return engine.renderMemory(context) + engine.renderReflectionRequest()
|
|
937
|
+
return engine.renderMemory(context) + engine.renderReflectionRequest() + engine.renderGreetingRequest()
|
|
912
938
|
} catch (e) { return '' }
|
|
913
939
|
},
|
|
914
940
|
})
|
|
@@ -990,6 +1016,18 @@ export function apply(ctx, config) {
|
|
|
990
1016
|
text: { type: 'string', required: true, description: '完整反思内容:成果回顾 / 教训改进 / 今日可延续要点。' },
|
|
991
1017
|
}, async (args, exec) => engine.saveReflection(args.date, args.text, exec.agent)),
|
|
992
1018
|
|
|
1019
|
+
defineTool('memory_greet', '保存今日拟人化晨间问候到 .dsh-memory/greetings/YYYY-MM-DD.md(每天首次会话收到「晨间问候」提示后调用)。问候内容为面向用户的拟人化短句(温暖自然、朋友口吻),不要写反思类结构化内容。', {
|
|
1020
|
+
date: { type: 'string', required: true, description: '问候日期 YYYY-MM-DD。' },
|
|
1021
|
+
text: { type: 'string', required: true, description: '完整问候内容。' },
|
|
1022
|
+
}, async (args, exec) => {
|
|
1023
|
+
const date = DATE_RE.test(args.date || '') ? args.date : todayStr()
|
|
1024
|
+
const p = await engine.resolvePaths(exec.agent)
|
|
1025
|
+
const file = path.join(p.greetDir, date + '.md')
|
|
1026
|
+
await engine.writeFull(file, args.text + '\n')
|
|
1027
|
+
if (date === todayStr()) { engine.state.todayGreeting = String(args.text).trim(); engine.state.loadedAt = Date.now() }
|
|
1028
|
+
return '已保存晨间问候 ' + file + '\n' + String(args.text).trim()
|
|
1029
|
+
}),
|
|
1030
|
+
|
|
993
1031
|
defineTool('memory_external', '查看/接入其他 AI 工具(CodeBuddy/Claude Code/Codex/项目约定文件等)的记忆。action=list 列出全部检测到的外部记忆源(路径/大小/预览/会话数);action=import 把某源内容整体接入本地记忆(source 为源 id,target=project 接进项目笔记 / user 接进用户级记忆,自动标注来源)。首次在新工作区工作、或用户提到其他软件里做过的事时调用。', {
|
|
994
1032
|
action: { type: 'string', enum: ['list', 'import'], required: true, description: 'list=列出外部记忆源; import=接入指定源。' },
|
|
995
1033
|
source: { type: 'string', description: '要接入的源 id(action=import 时必填,来自 list 结果)。' },
|