@a9i5k4/dsh-auto-memory 0.1.10 → 0.1.12
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 +226 -288
- package/README.zh-CN.md +232 -286
- package/lib/client.js +101 -62
- package/lib/index.js +2 -2
- package/package.json +4 -1
package/lib/client.js
CHANGED
|
@@ -107,6 +107,12 @@ window.__ModuleLoader__.load({
|
|
|
107
107
|
fDayBoundary: '日界(分钟)', fDayBoundaryHint: '从 0 点起算:凌晨在此之前的活儿归前一天。默认 450=早上 7:30 进入新一天;改 480=8:00;0=按午夜切日。',
|
|
108
108
|
fVersion: '插件版本', checkUpdate: '检查更新', checking: '检查中…', upToDate: '(已是最新)', hasUpdate: '(有新版本)', versionError: '版本检查失败: ', versionCmdHint: '更新命令: cd ~/.dsh/profiles/web && pnpm up @a9i5k4/dsh-auto-memory,然后重启 dsh web 生效。',
|
|
109
109
|
updateNow: '一键更新', updating: '更新中…', updateDone: '更新完成,请重启 dsh web 生效。', updateFailed: '更新失败: ', devLinkHint: '(当前为本地开发链接,请直接同步开发源码)', noProfileHint: '(未找到 dsh profile,无法自动更新)',
|
|
110
|
+
kvVersion: '插件版本', kvUnreadable: '(读不到)', kvPid: 'PID / 启动', kvRestart: 'Host 需重启?', kvRestartYes: '是(代码比进程新)', kvRestartNo: '否',
|
|
111
|
+
kvHeartbeat: '轮询心跳', hbAliveAgo: '存活(上次 ', hbSecAgo: ' 秒前)', hbAlive: '存活', hbNone: '无心跳文件',
|
|
112
|
+
kvQueue: '沉淀重试队列', kvCountSuffix: ' 条', kvToday: '今日沉淀', kvRecentPrefix: ' 条 / 最近 ', kvBusy: '正在沉淀中', kvYes: '是', kvNo: '否',
|
|
113
|
+
kvAvail: '可用', kvUnavail: '不可用', kvDup: '项目笔记重复标题', kvDupCount: ' 个',
|
|
114
|
+
kvMem: '记忆文件', kvMemUser: '用户', kvMemNotes: '笔记', kvMemLog: '日志', kvMemMissing: '缺失',
|
|
115
|
+
kvWs: '当前工作区', kvWsUnknown: '(未取到)', kvApi: 'API 连通', unknown: '(未知)',
|
|
110
116
|
refresh: '刷新', refreshing: '刷新中…', close: '关闭', dragMove: '拖动移动', dragResize: '拖动调整大小', resetPos: '恢复默认位置',
|
|
111
117
|
generated: '已生成', failed: '失败: ',
|
|
112
118
|
generatedAt: '生成于 ',
|
|
@@ -156,7 +162,7 @@ window.__ModuleLoader__.load({
|
|
|
156
162
|
fDays: '注入最近日志天数', fDaysHint: '会话开始时注入最近 N 天的工作日志尾部。',
|
|
157
163
|
fReflect: '每日反思', fReflectHint: '昨天有工作日志时,会话首轮主动呈现昨日反思。',
|
|
158
164
|
fStyle: '反思风格', fStyleHint: '生活化 / 专业性 / 由内容决定。',
|
|
159
|
-
fLocale: '界面语言', fLocaleHint: '
|
|
165
|
+
fLocale: '界面语言', fLocaleHint: '默认跟随 DSH 系统语言;也可手动指定中文 / English。', followSystem: '跟随系统语言',
|
|
160
166
|
saveSettings: '保存设置',
|
|
161
167
|
zh: '中文', en: 'English',
|
|
162
168
|
calendar: '日历', addItem: '添加', save: '保存', cancel: '取消', needTitle: '请填写事项标题', itemTitle: '事项标题…',
|
|
@@ -182,6 +188,12 @@ window.__ModuleLoader__.load({
|
|
|
182
188
|
fDayBoundary: 'Day boundary (minutes)', fDayBoundaryHint: 'Minutes from midnight: work before it counts as the previous day. Default 450 = 7:30 AM starts the new day; 480 = 8:00; 0 = midnight cut.',
|
|
183
189
|
fVersion: 'Plugin version', checkUpdate: 'Check for updates', checking: 'Checking…', upToDate: '(up to date)', hasUpdate: '(update available)', versionError: 'Version check failed: ', versionCmdHint: 'Update: cd ~/.dsh/profiles/web && pnpm up @a9i5k4/dsh-auto-memory, then restart dsh web.',
|
|
184
190
|
updateNow: 'Update now', updating: 'Updating…', updateDone: 'Update finished, restart dsh web to apply.', updateFailed: 'Update failed: ', devLinkHint: '(local dev link, sync source instead)', noProfileHint: '(no dsh profile found, cannot auto-update)',
|
|
191
|
+
kvVersion: 'Plugin version', kvUnreadable: '(unreadable)', kvPid: 'PID / Started', kvRestart: 'Host restart needed?', kvRestartYes: 'yes (code newer than process)', kvRestartNo: 'no',
|
|
192
|
+
kvHeartbeat: 'Heartbeat', hbAliveAgo: 'alive (last ', hbSecAgo: ' s ago)', hbAlive: 'alive', hbNone: 'no heartbeat file',
|
|
193
|
+
kvQueue: 'Consolidation retry queue', kvCountSuffix: ' item(s)', kvToday: 'Consolidated today', kvRecentPrefix: ' item(s) / latest ', kvBusy: 'Consolidating now', kvYes: 'yes', kvNo: 'no',
|
|
194
|
+
kvAvail: 'available', kvUnavail: 'unavailable', kvDup: 'Duplicate note headings', kvDupCount: '',
|
|
195
|
+
kvMem: 'Memory files', kvMemUser: 'user', kvMemNotes: 'notes', kvMemLog: 'log', kvMemMissing: 'missing',
|
|
196
|
+
kvWs: 'Current workspace', kvWsUnknown: '(unknown)', kvApi: 'API probes', unknown: '(unknown)',
|
|
185
197
|
refresh: 'Refresh', refreshing: 'Refreshing…', close: 'Close', dragMove: 'Drag to move', dragResize: 'Drag to resize', resetPos: 'Reset position',
|
|
186
198
|
generated: 'Generated', failed: 'Failed: ',
|
|
187
199
|
generatedAt: 'Generated ',
|
|
@@ -231,7 +243,7 @@ window.__ModuleLoader__.load({
|
|
|
231
243
|
fDays: 'Recent days injected', fDaysHint: 'Inject tails of the last N days of work logs at session start.',
|
|
232
244
|
fReflect: 'Daily reflection', fReflectHint: 'When yesterday has logs, the agent presents the reflection at session start.',
|
|
233
245
|
fStyle: 'Reflection style', fStyleHint: 'Life-style / Professional / Auto.',
|
|
234
|
-
fLocale: 'UI language', fLocaleHint: '
|
|
246
|
+
fLocale: 'UI language', fLocaleHint: 'Follows the DSH system language by default; you can also pin Chinese / English.', followSystem: 'Follow system language',
|
|
235
247
|
saveSettings: 'Save settings',
|
|
236
248
|
zh: '中文', en: 'English',
|
|
237
249
|
calendar: 'Calendar', addItem: 'Add', save: 'Save', cancel: 'Cancel', needTitle: 'Title is required', itemTitle: 'Item title…',
|
|
@@ -245,6 +257,14 @@ window.__ModuleLoader__.load({
|
|
|
245
257
|
}
|
|
246
258
|
}
|
|
247
259
|
var locale = 'zh'
|
|
260
|
+
var localeMode = 'system' // 'system'=跟随 DSH 系统语言 | 'zh' | 'en'
|
|
261
|
+
var sysLocale = 'zh' // DSH 系统语言(跟随模式使用)
|
|
262
|
+
function applyLocalePref(m) {
|
|
263
|
+
if (m !== 'zh' && m !== 'en' && m !== 'system') m = 'system'
|
|
264
|
+
localeMode = m
|
|
265
|
+
var target = m === 'system' ? sysLocale : m
|
|
266
|
+
if (locale !== target) { locale = target; localeListeners.forEach(function (fn) { try { fn() } catch (e) {} }) }
|
|
267
|
+
}
|
|
248
268
|
var sessions = null
|
|
249
269
|
// 当前会话工作区(跟随 GUI 切换工作区):从 sessions 服务拿,供 state/summarize/greet 请求使用
|
|
250
270
|
function currentWs() {
|
|
@@ -437,7 +457,8 @@ window.__ModuleLoader__.load({
|
|
|
437
457
|
if (!seenSeg[sname]) continue
|
|
438
458
|
var items = (ps && ps.groups && ps.groups[sname]) || []
|
|
439
459
|
if (!items.length) continue
|
|
440
|
-
|
|
460
|
+
var segEn = { '早晨': 'morning', '上午': 'forenoon', '中午': 'noon', '下午': 'afternoon', '晚上': 'evening' }[sname] || sname
|
|
461
|
+
drawers.push({ key: 'seg-' + sname, label: t('segPrefix') + t('seg' + segEn.charAt(0).toUpperCase() + segEn.slice(1)), hint: '', items: items.map(function (x) { return { time: '', text: x } }), withTime: false, defaultOpen: sname === curSegName, period: sname })
|
|
441
462
|
}
|
|
442
463
|
// 外层:生活化问候
|
|
443
464
|
var totalCount = 0
|
|
@@ -838,12 +859,13 @@ window.__ModuleLoader__.load({
|
|
|
838
859
|
}
|
|
839
860
|
|
|
840
861
|
// ───────────────────────── 日历页签 ─────────────────────────
|
|
862
|
+
var QUADRANT_I18N = { '重要紧急': 'qUrgentImportant', '重要不紧急': 'qImportant', '紧急不重要': 'qUrgent', '不重要不紧急': 'qNone', '未分类': 'qUncategorized' }
|
|
841
863
|
var QUADRANT_STYLE = {
|
|
842
|
-
'重要紧急': { color: 'var(--dsw-alias-state-error-primary, #d64545)'
|
|
843
|
-
'重要不紧急': { color: 'var(--dsw-alias-brand-primary, #4f7cff)'
|
|
844
|
-
'紧急不重要': { color: 'var(--dsw-alias-state-warn-primary, #e6a23c)'
|
|
845
|
-
'不重要不紧急': { color: 'var(--dsw-alias-label-secondary, #8a94a6)'
|
|
846
|
-
'未分类': { color: 'var(--dsw-alias-label-secondary, #8a94a6)'
|
|
864
|
+
'重要紧急': { color: 'var(--dsw-alias-state-error-primary, #d64545)' },
|
|
865
|
+
'重要不紧急': { color: 'var(--dsw-alias-brand-primary, #4f7cff)' },
|
|
866
|
+
'紧急不重要': { color: 'var(--dsw-alias-state-warn-primary, #e6a23c)' },
|
|
867
|
+
'不重要不紧急': { color: 'var(--dsw-alias-label-secondary, #8a94a6)' },
|
|
868
|
+
'未分类': { color: 'var(--dsw-alias-label-secondary, #8a94a6)' },
|
|
847
869
|
}
|
|
848
870
|
function CalendarTab() {
|
|
849
871
|
var dataPair = useState(null)
|
|
@@ -897,7 +919,7 @@ window.__ModuleLoader__.load({
|
|
|
897
919
|
rows.push(h('div', { 'data-dam-row': '', style: { flexWrap: 'wrap' } },
|
|
898
920
|
Object.keys(QUADRANT_STYLE).map(function (q) {
|
|
899
921
|
return h('span', { key: q, style: { fontSize: 'calc(11px * var(--dam-scale))', opacity: 0.8, marginRight: '10px' } },
|
|
900
|
-
h('span', { style: { display: 'inline-block', width: 8, height: 8, borderRadius: 2, background: QUADRANT_STYLE[q].color, marginRight: 4 } }),
|
|
922
|
+
h('span', { style: { display: 'inline-block', width: 8, height: 8, borderRadius: 2, background: QUADRANT_STYLE[q].color, marginRight: 4 } }), t(QUADRANT_I18N[q]))
|
|
901
923
|
})))
|
|
902
924
|
// 星期表头
|
|
903
925
|
rows.push(h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: '3px', marginBottom: '4px' } },
|
|
@@ -970,7 +992,7 @@ window.__ModuleLoader__.load({
|
|
|
970
992
|
h('div', { 'data-dam-row': '' },
|
|
971
993
|
h('input', { 'data-dam-input': '', type: 'time', value: draft.time, onChange: function (e) { var n = Object.assign({}, draft); n.time = e.target.value || '09:00'; setDraft(n) } }),
|
|
972
994
|
h('select', { 'data-dam-select': '', value: draft.quadrant, onChange: function (e) { var n = Object.assign({}, draft); n.quadrant = e.target.value; setDraft(n) } },
|
|
973
|
-
['重要紧急', '重要不紧急', '紧急不重要', '不重要不紧急'].map(function (q) { return h('option', { key: q, value: q },
|
|
995
|
+
['重要紧急', '重要不紧急', '紧急不重要', '不重要不紧急'].map(function (q) { return h('option', { key: q, value: q }, t(QUADRANT_I18N[q])) }))),
|
|
974
996
|
h('div', { 'data-dam-row': '' },
|
|
975
997
|
h('button', { 'data-dam-btn': '', onClick: saveDraft }, t('save')),
|
|
976
998
|
h('button', { 'data-dam-btn': '', onClick: function () { setDraft(null) } }, t('cancel')))))
|
|
@@ -1175,23 +1197,23 @@ window.__ModuleLoader__.load({
|
|
|
1175
1197
|
h('div', { 'data-dam-row': '' },
|
|
1176
1198
|
h('button', { 'data-dam-btn': '', onClick: refresh, disabled: busy }, busy ? t('dbgRefreshing') : t('dbgRefresh')),
|
|
1177
1199
|
h('span', { 'data-dam-hint': '' }, data.host.indexPath || '')),
|
|
1178
|
-
kv('
|
|
1179
|
-
kv('
|
|
1180
|
-
kv('
|
|
1181
|
-
kv('
|
|
1182
|
-
kv('
|
|
1183
|
-
kv('
|
|
1184
|
-
kv('
|
|
1185
|
-
kv('subagents', data.subagents.available ? (data.subagents.providers.join(', ') || '
|
|
1186
|
-
kv('
|
|
1187
|
-
kv('
|
|
1188
|
-
kv('
|
|
1189
|
-
kv('
|
|
1200
|
+
kv(t('kvVersion'), data.host.version || t('kvUnreadable'), false),
|
|
1201
|
+
kv(t('kvPid'), data.host.pid + ' / ' + (data.host.startTime ? new Date(data.host.startTime).toLocaleTimeString() : ''), false),
|
|
1202
|
+
kv(t('kvRestart'), data.host.needsRestart ? t('kvRestartYes') : t('kvRestartNo'), data.host.needsRestart),
|
|
1203
|
+
kv(t('kvHeartbeat'), hb.exists ? (hbAge >= 0 ? t('hbAliveAgo') + hbAge + t('hbSecAgo') : t('hbAlive')) : t('hbNone'), !hb.exists || hbAge > 360),
|
|
1204
|
+
kv(t('kvQueue'), data.autoConsolidate.pendingQueue + t('kvCountSuffix'), data.autoConsolidate.pendingQueue > 0),
|
|
1205
|
+
kv(t('kvToday'), data.autoConsolidate.stats.count + t('kvRecentPrefix') + (data.autoConsolidate.stats.lastAt ? new Date(data.autoConsolidate.stats.lastAt).toLocaleTimeString() : '—'), false),
|
|
1206
|
+
kv(t('kvBusy'), data.autoConsolidate.consolidating ? t('kvYes') : t('kvNo'), data.autoConsolidate.consolidating),
|
|
1207
|
+
kv('subagents', data.subagents.available ? (data.subagents.providers.join(', ') || t('kvAvail')) : t('kvUnavail'), !data.subagents.available),
|
|
1208
|
+
kv(t('kvDup'), data.duplicateHeadings + t('kvDupCount'), data.duplicateHeadings > 0),
|
|
1209
|
+
kv(t('kvMem'), t('kvMemUser') + ' ' + (data.memoryFiles.user.exists ? fmtSize(data.memoryFiles.user.size) : t('kvMemMissing')) + ' · ' + t('kvMemNotes') + ' ' + (data.memoryFiles.notes.exists ? fmtSize(data.memoryFiles.notes.size) : t('kvMemMissing')) + ' · ' + t('kvMemLog') + ' ' + (data.memoryFiles.log.exists ? fmtSize(data.memoryFiles.log.size) : t('kvMemMissing')), !data.memoryFiles.log.exists),
|
|
1210
|
+
kv(t('kvWs'), currentWs() || t('kvWsUnknown'), false),
|
|
1211
|
+
kv(t('kvApi'), probes ? Object.keys(probes).map(function (k) { return k + '=' + (probes[k].status !== undefined ? probes[k].status : probes[k].error) }).join(' ') : '…', apiBad))
|
|
1190
1212
|
}
|
|
1191
1213
|
|
|
1192
1214
|
// ───────────────────────── 设置页 ─────────────────────────
|
|
1193
|
-
var
|
|
1194
|
-
var
|
|
1215
|
+
var STYLE_IDS = ['auto', 'life', 'professional']
|
|
1216
|
+
var LOCALE_IDS_LIST = ['system', 'zh', 'en']
|
|
1195
1217
|
function SettingsPage() {
|
|
1196
1218
|
var tickPair = useTick()
|
|
1197
1219
|
var cfgPair = useState(null)
|
|
@@ -1246,6 +1268,18 @@ window.__ModuleLoader__.load({
|
|
|
1246
1268
|
browseTo(cfg.memoryRoot || '')
|
|
1247
1269
|
})
|
|
1248
1270
|
}
|
|
1271
|
+
var verPair = useState(null)
|
|
1272
|
+
var verInfo = verPair[0]
|
|
1273
|
+
var setVerInfo = verPair[1]
|
|
1274
|
+
var checkingPair = useState(false)
|
|
1275
|
+
var checkingUpdate = checkingPair[0]
|
|
1276
|
+
var setCheckingUpdate = checkingPair[1]
|
|
1277
|
+
var upBusyPair = useState(false)
|
|
1278
|
+
var upBusy = upBusyPair[0]
|
|
1279
|
+
var setUpBusy = upBusyPair[1]
|
|
1280
|
+
var upMsgPair = useState('')
|
|
1281
|
+
var upMsg = upMsgPair[0]
|
|
1282
|
+
var setUpMsg = upMsgPair[1]
|
|
1249
1283
|
useEffect(function () { return controller.subscribe(tickPair[1]) }, [])
|
|
1250
1284
|
useEffect(function () {
|
|
1251
1285
|
var alive = true
|
|
@@ -1256,37 +1290,25 @@ window.__ModuleLoader__.load({
|
|
|
1256
1290
|
}, [])
|
|
1257
1291
|
if (!cfg) return err ? h('div', { 'data-dam-error': '' }, err) : h(Loading)
|
|
1258
1292
|
function set(key, value) { var next = Object.assign({}, cfg); next[key] = value; setCfg(next) }
|
|
1259
|
-
var verPair = useState(null)
|
|
1260
|
-
var verInfo = verPair[0]
|
|
1261
|
-
var setVerInfo = verPair[1]
|
|
1262
|
-
var checkingPair = useState(false)
|
|
1263
|
-
var checkingUpdate = checkingPair[0]
|
|
1264
|
-
var setCheckingUpdate = checkingPair[1]
|
|
1265
1293
|
function checkUpdate() {
|
|
1266
1294
|
if (checkingUpdate) return
|
|
1267
1295
|
setCheckingUpdate(true)
|
|
1268
1296
|
apiGet(API.updateCheck + '?force=1').then(function (d) { setVerInfo(d); setCheckingUpdate(false) })
|
|
1269
1297
|
.catch(function (e) { setVerInfo({ error: e.message }); setCheckingUpdate(false) })
|
|
1270
1298
|
}
|
|
1271
|
-
var upBusyPair = useState(false)
|
|
1272
|
-
var upBusy = upBusyPair[0]
|
|
1273
|
-
var setUpBusy = upBusyPair[1]
|
|
1274
|
-
var upMsgPair = useState('')
|
|
1275
|
-
var upMsg = upMsgPair[0]
|
|
1276
|
-
var setUpMsg = upMsgPair[1]
|
|
1277
1299
|
function doUpdate() {
|
|
1278
1300
|
if (upBusy) return
|
|
1279
1301
|
setUpBusy(true); setUpMsg('')
|
|
1280
1302
|
apiPost(API.update, {}).then(function (d) {
|
|
1281
1303
|
setUpBusy(false)
|
|
1282
1304
|
if (d && d.ok) { setUpMsg(t('updateDone')); setVerInfo(null); checkUpdate() }
|
|
1283
|
-
else setUpMsg(t('updateFailed') + (d && d.message ? d.message :
|
|
1305
|
+
else setUpMsg(t('updateFailed') + (d && d.message ? d.message : t('unknown')))
|
|
1284
1306
|
}).catch(function (e) { setUpBusy(false); setUpMsg(t('updateFailed') + e.message) })
|
|
1285
1307
|
}
|
|
1286
1308
|
function save() {
|
|
1287
1309
|
if (busy) return
|
|
1288
1310
|
setBusy(true); setMsg(''); setErr('')
|
|
1289
|
-
apiPost(API.config, cfg).then(function (d) { setCfg(d.config); setMsg(t('saved') + (d.migrated ? ' ' + d.migrated : '')); setBusy(false) })
|
|
1311
|
+
apiPost(API.config, cfg).then(function (d) { setCfg(d.config); setMsg(t('saved') + (d.migrated ? ' ' + d.migrated : '')); setBusy(false); if (d && d.config && d.config.locale) applyLocalePref(d.config.locale) })
|
|
1290
1312
|
.catch(function (e) { setErr(e.message); setBusy(false) })
|
|
1291
1313
|
}
|
|
1292
1314
|
function field(label, control, hint) {
|
|
@@ -1296,8 +1318,8 @@ window.__ModuleLoader__.load({
|
|
|
1296
1318
|
}
|
|
1297
1319
|
return h('div', null,
|
|
1298
1320
|
h('div', { 'data-dam-hint': '' }, t('settingsHeader')),
|
|
1299
|
-
field(t('fLocale'), h('select', { 'data-dam-select': '', value: cfg.locale || '
|
|
1300
|
-
|
|
1321
|
+
field(t('fLocale'), h('select', { 'data-dam-select': '', value: cfg.locale || 'system', onChange: function (e) { set('locale', e.target.value) } },
|
|
1322
|
+
LOCALE_IDS_LIST.map(function (id) { return h('option', { key: id, value: id }, id === 'system' ? t('followSystem') : t(id)) })), t('fLocaleHint')),
|
|
1301
1323
|
field(t('fFontSize'), h('select', { 'data-dam-select': '', value: fontScale, onChange: function (e) { fontScale = e.target.value; try { localStorage.setItem('dsh-auto-memory.fontScale.v2', fontScale) } catch (ee) {}; try { var pp = document.querySelector('[data-dam-panel]'); if (pp) pp.style.setProperty('--dam-scale', FONT_SCALE_VALUES[fontScale] || '1') } catch (ee2) {}; emit() } },
|
|
1302
1324
|
Object.keys(FONT_SCALES).map(function (k) { return h('option', { key: k, value: k }, t('fs' + k.charAt(0).toUpperCase() + k.slice(1))) })), t('fFontSizeHint')),
|
|
1303
1325
|
field(t('fUserDir'), h('input', { 'data-dam-input': '', value: cfg.userMemoryDir, onChange: function (e) { set('userMemoryDir', e.target.value) } }), t('fUserDirHint')),
|
|
@@ -1323,7 +1345,7 @@ window.__ModuleLoader__.load({
|
|
|
1323
1345
|
field(t('fDayBoundary'), h('input', { 'data-dam-input': '', type: 'number', min: 0, max: 1439, value: (cfg.dayBoundaryMinutes === undefined ? 450 : cfg.dayBoundaryMinutes), onChange: function (e) { set('dayBoundaryMinutes', parseInt(e.target.value || '0', 10)) } }), t('fDayBoundaryHint')),
|
|
1324
1346
|
field(t('fReflect'), h('input', { type: 'checkbox', checked: !!cfg.reflectEnabled, onChange: function (e) { set('reflectEnabled', e.target.checked) } }), t('fReflectHint')),
|
|
1325
1347
|
field(t('fStyle'), h('select', { 'data-dam-select': '', value: cfg.reflectStyle, onChange: function (e) { set('reflectStyle', e.target.value) } },
|
|
1326
|
-
|
|
1348
|
+
STYLE_IDS.map(function (id) { return h('option', { key: id, value: id }, t('style' + id.charAt(0).toUpperCase() + id.slice(1))) })), t('fStyleHint')),
|
|
1327
1349
|
field(t('fVersion'), h('div', { 'data-dam-row': '' },
|
|
1328
1350
|
h('span', { style: { flex: 1 } }, verInfo ? (verInfo.current || '?') + (verInfo.latest ? ' → ' + verInfo.latest + (verInfo.upToDate ? ' ' + t('upToDate') : ' ' + t('hasUpdate')) : '') : (checkingUpdate ? t('checking') : '—')),
|
|
1329
1351
|
h('button', { 'data-dam-btn': '', onClick: checkUpdate, disabled: checkingUpdate }, checkingUpdate ? t('checking') : t('checkUpdate')),
|
|
@@ -1360,33 +1382,50 @@ window.__ModuleLoader__.load({
|
|
|
1360
1382
|
var savedScale = localStorage.getItem('dsh-auto-memory.fontScale.v2')
|
|
1361
1383
|
if (savedScale in FONT_SCALES) fontScale = savedScale
|
|
1362
1384
|
} catch (e3) {}
|
|
1363
|
-
//
|
|
1385
|
+
// 界面语言:默认跟随 DSH 系统语言(config.locale 可手动指定 zh / en / system)
|
|
1364
1386
|
try {
|
|
1365
|
-
var
|
|
1366
|
-
if (
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1387
|
+
var sl0 = ctx.locale && ctx.locale.getLocale ? ctx.locale.getLocale() : null
|
|
1388
|
+
if (sl0 && sl0.active) sysLocale = sl0.active
|
|
1389
|
+
} catch (e) {}
|
|
1390
|
+
applyLocalePref('system')
|
|
1391
|
+
apiGet(API.config).then(function (d) {
|
|
1392
|
+
if (d && d.config && d.config.locale) applyLocalePref(d.config.locale)
|
|
1393
|
+
}).catch(function () {})
|
|
1394
|
+
// DSH 系统语言变化:跟随更新 + 重渲染 + 重注册入口 label
|
|
1395
|
+
ctx.on('locale/change', function (snap) {
|
|
1396
|
+
try {
|
|
1397
|
+
if (snap && snap.active && snap.active !== sysLocale) {
|
|
1398
|
+
sysLocale = snap.active
|
|
1399
|
+
if (localeMode !== 'zh' && localeMode !== 'en') { locale = sysLocale; emit() }
|
|
1400
|
+
refreshSurfaces()
|
|
1371
1401
|
}
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1402
|
+
} catch (e) {}
|
|
1403
|
+
})
|
|
1374
1404
|
// 语言切换时通知所有订阅者重渲染
|
|
1375
1405
|
onLocale(function () { emit() })
|
|
1376
1406
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1407
|
+
var surfaceDisposers = []
|
|
1408
|
+
function registerSurfaces() {
|
|
1409
|
+
try {
|
|
1410
|
+
surfaceDisposers.push(slots.inject('sidebar.footer.action', function () {
|
|
1411
|
+
return slots.register({ name: 'sidebar.footer.action', id: 'auto-memory', order: 5, label: t('memory') }, function () { return h(SidebarButton) })
|
|
1412
|
+
}))
|
|
1413
|
+
surfaceDisposers.push(slots.inject('shell.overlay', function () {
|
|
1414
|
+
return slots.register({ name: 'shell.overlay', id: 'auto-memory', order: 5 }, function () { return h(MemoryPanel) })
|
|
1415
|
+
}))
|
|
1416
|
+
surfaceDisposers.push(slots.inject('settings.section', function () {
|
|
1417
|
+
return slots.register({ name: 'settings.section', id: 'auto-memory', order: 25, label: t('autoMemory') }, function (props) { return h(SettingsPage, { close: props && props.close }) })
|
|
1418
|
+
}))
|
|
1419
|
+
} catch (e) {
|
|
1420
|
+
console.warn('[dsh-auto-memory] slot registration failed', e)
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
function refreshSurfaces() {
|
|
1424
|
+
for (var i = 0; i < surfaceDisposers.length; i++) { try { surfaceDisposers[i]() } catch (e) {} }
|
|
1425
|
+
surfaceDisposers = []
|
|
1426
|
+
registerSurfaces()
|
|
1389
1427
|
}
|
|
1428
|
+
registerSurfaces()
|
|
1390
1429
|
console.log('[dsh-auto-memory] client ready: sidebar entry + panel + settings page')
|
|
1391
1430
|
}
|
|
1392
1431
|
|
package/lib/index.js
CHANGED
|
@@ -85,8 +85,8 @@ const DEFAULT_CONFIG = {
|
|
|
85
85
|
reflectEnabled: true,
|
|
86
86
|
/** 反思风格: auto=由内容决定 / life=生活化 / professional=专业性。 */
|
|
87
87
|
reflectStyle: 'auto',
|
|
88
|
-
/** UI 语言: zh=中文 / en=English。 */
|
|
89
|
-
locale: '
|
|
88
|
+
/** UI 语言: system=跟随 DSH 系统语言(默认) / zh=中文 / en=English。 */
|
|
89
|
+
locale: 'system',
|
|
90
90
|
/** 外部记忆注入预算(字符)。 */
|
|
91
91
|
externalInjectionChars: 1400,
|
|
92
92
|
/** 外部记忆源开关(AI 助手/CodeBuddy/Claude Code/Codex/项目约定)。 */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a9i5k4/dsh-auto-memory",
|
|
3
3
|
"description": "DSH 自动记忆插件:三层记忆(用户级/项目笔记/每日日志)自动注入与检索、每轮对话自动沉淀、每日反思、可视化面板与设置页,支持继承其他 AI 工具的记忆。",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -39,5 +39,8 @@
|
|
|
39
39
|
"type": "git",
|
|
40
40
|
"url": "git+https://github.com/Aik358/dsh-auto-memory.git"
|
|
41
41
|
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
44
|
+
},
|
|
42
45
|
"license": "BSD-3-Clause"
|
|
43
46
|
}
|