dsh-plugin-memory 0.17.9 → 0.18.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 +19 -0
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/docs/CONFIGURATION.md +2 -1
- package/docs/market/index.json +4 -4
- package/lib/boot.js +22 -8
- package/lib/client.js +85 -3
- package/lib/config-store.js +4 -1
- package/lib/index.js +57 -3
- package/lib/schema.js +4 -0
- package/lib/types/index.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
|
|
4
4
|
|
|
5
|
+
## [0.18.1] - 2026-11-10
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **双击节点仍然回退 Finder**:客户端插件此前用 `ctx.get('sidebarRight')`/`ctx.sidebarRight` 读取侧栏服务,Cordis 下未在 `inject` 声明的服务访问会抛错、被 try/catch 吞掉 → 服务恒为 undefined。改用公开 API `ctx.reflect.get('sidebarRight', true)`(不要求 inject,旧宿主无该服务时同样安全返回 undefined)。
|
|
10
|
+
- **回退时给出具体原因**:侧栏打开失败会在面板提示具体阶段(`sidebar-unavailable` / `path-unresolved` / `no-session` / 打开异常信息),便于定位;Finder 回退行为不变。
|
|
11
|
+
|
|
12
|
+
## [0.18.0] - 2026-11-10
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **`bootSnapshot: session | live`(issue #8)**:`session` 在会话首次注入时固化 boot 文本,会话中途写记忆不再改变系统提示前缀;新会话重新读盘。默认 `live`(不改变现有体验)。配置项进入「设置 → 记忆」(第 17 个热改项),`/memory on|off`、配置变更、切换模式都会重置快照。
|
|
17
|
+
- **「最近动态」拆成独立 runtime-context 段**(order 900):boot 块只含 SOUL/MEMORY/index + 语气段,log 尾部单独注入;会话中途 digest 只让这段尾部变更,缓存失效范围从「整段前缀」缩到「尾部」。
|
|
18
|
+
- **双击记忆节点 → 在 DSH 右侧栏打开该 md 文件**(兼容 macOS / Windows / Linux):客户端调用 `ctx.sidebarRight.openResource` 打开 `file` 资源;服务不可用或失败时自动回退「在 Finder/资源管理器中显示」。
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- 图谱双击行为:由「直接 reveal」改为「优先侧栏打开、失败回退 reveal」;选中节点仍保留「在 Finder 中显示 / 复制路径」按钮。
|
|
23
|
+
|
|
5
24
|
## [0.17.9] - 2026-11-06
|
|
6
25
|
|
|
7
26
|
### Fixed
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ then install **Memory** from the list. (A JSON index in the official format, ser
|
|
|
43
43
|
- **You stay in control** — per-session switch (chip / `/memory on|off` / panel) and `disabledWorkspaces` defaults.
|
|
44
44
|
- **A companion** — digest nudge, proactive recall, weekly growth recap, context-sensitive tone; shared speech floor with other proactive plugins.
|
|
45
45
|
- **Portable** — plain markdown + git, `pack`/`unpack`, optional auto-commit.
|
|
46
|
-
- **Memory graph** — interactive 3D sphere: rotate / zoom / drag nodes, search-to-focus, hover or click to light up neighbours; select a node → **Reveal in Finder** or **Copy path
|
|
46
|
+
- **Memory graph** — interactive 3D sphere: rotate / zoom / drag nodes, search-to-focus, hover or click to light up neighbours; select a node → **Reveal in Finder** or **Copy path**; **double-click a node to open its file in the DSH sidebar** (falls back to the OS file manager).
|
|
47
47
|
- **Health tools** — dashboard, `checkup`, `lint`, `doctor`, automatic `last_access` stamping.
|
|
48
48
|
- **Zero build, bilingual panel, hot-editable config.**
|
|
49
49
|
|
|
@@ -67,7 +67,7 @@ then install **Memory** from the list. (A JSON index in the official format, ser
|
|
|
67
67
|
|
|
68
68
|
## Configuration
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Seventeen hot keys edit live under **Settings → Memory** — including `bootSnapshot` (`live` by default; `session` freezes the boot block for the session so mid-session writes can't invalidate the prompt-prefix cache). The full table, boot-budget rules and composition overrides are in [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
|
|
71
71
|
|
|
72
72
|
## CLI
|
|
73
73
|
|
package/README.zh.md
CHANGED
|
@@ -43,7 +43,7 @@ https://raw.githubusercontent.com/LittleBlackTong/dsh-plugin-memory/main/docs/ma
|
|
|
43
43
|
- **你说了算** —— 会话级开关(chip / `/memory on|off` / 面板)+ `disabledWorkspaces` 工作区默认。
|
|
44
44
|
- **像个搭子** —— digest 提醒、主动追忆、每周成长回顾、按语境调语气;与其它主动插件共享发言权仲裁。
|
|
45
45
|
- **可迁移** —— 纯 markdown + git,`pack`/`unpack` 搬家,可选自动提交。
|
|
46
|
-
- **记忆图谱** —— 可交互 3D 球面:旋转/缩放/拖节点整理、搜索定位、悬停或点击点亮邻居;选中节点可 **在 Finder 中显示** 或
|
|
46
|
+
- **记忆图谱** —— 可交互 3D 球面:旋转/缩放/拖节点整理、搜索定位、悬停或点击点亮邻居;选中节点可 **在 Finder 中显示** 或 **复制路径**;**双击节点直接在 DSH 侧栏打开该文件**(打不开时回退系统文件管理器)。
|
|
47
47
|
- **健康工具** —— 看板、`checkup`、`lint`、`doctor`、自动 `last_access`。
|
|
48
48
|
- **零构建、面板双语、配置热改。**
|
|
49
49
|
|
|
@@ -67,7 +67,7 @@ https://raw.githubusercontent.com/LittleBlackTong/dsh-plugin-memory/main/docs/ma
|
|
|
67
67
|
|
|
68
68
|
## 配置
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
十七个热改项在 **设置 → 记忆** 里即时生效——含 `bootSnapshot`(默认 `live`;设为 `session` 会在本会话固化 boot 块,会话中途写记忆不再让前缀缓存失效)。完整配置表、boot 预算规则与组合层覆盖示例见 [docs/CONFIGURATION.md](docs/CONFIGURATION.md)。
|
|
71
71
|
|
|
72
72
|
## CLI
|
|
73
73
|
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -20,6 +20,7 @@ All keys below are read from the composition layer (`cordis.patch.yml`) unless m
|
|
|
20
20
|
| `growthRecapEnabled` **hot** | `true` | Weekly growth recap on the recall channel |
|
|
21
21
|
| `growthRecapIntervalDays` **hot** | `7` | Days between growth recaps |
|
|
22
22
|
| `disabledWorkspaces` **hot** | `[]` | Session cwd patterns that default to memory off (`~` expanded, path-boundary match, case-insensitive on Windows) |
|
|
23
|
+
| `bootSnapshot` **hot** | `live` | `live` re-reads the store every turn; `session` freezes the boot block for the session (mid-session writes apply from the next session) so the prompt-prefix cache stays hit |
|
|
23
24
|
| `bootFiles` | `[SOUL.md, MEMORY.md, index.md]` | Files injected at session start |
|
|
24
25
|
| `bootMaxChars` | `12000` | Total boot-block character budget |
|
|
25
26
|
| `bootFileBudgets` | — | Per-file caps, e.g. `{ index.md: 3500 }` |
|
|
@@ -38,7 +39,7 @@ All keys below are read from the composition layer (`cordis.patch.yml`) unless m
|
|
|
38
39
|
|
|
39
40
|
## Settings panel
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
Seventeen **hot** keys are editable under **Settings → Memory** and apply immediately: `enabled`, `memoryDir`, `autoInject`, `bootSnapshot`, `deferUntilUserSpeaks`, `activeSessionOnly`, `registerSkill`, `recallEnabled`, `recallIntervalMinMinutes`, `recallIntervalMaxMinutes`, `recallMaxPerSession`, `proactiveCooldownSeconds`, `toneGuideEnabled`, `toneIntensity`, `growthRecapEnabled`, `growthRecapIntervalDays`, `disabledWorkspaces`. Changing `memoryDir` scaffolds the new store automatically (when `scaffold: true`). Everything else is composition-layer and needs a restart.
|
|
42
43
|
|
|
43
44
|
The panel also has a **Review now** button (a control, not a setting): it sends one growth recap immediately, still respecting the shared speech floor, and reports the outcome (sending / sent / deferred / session busy / no content / disabled / failed) for 5 seconds.
|
|
44
45
|
|
package/docs/market/index.json
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"zh": "记忆"
|
|
17
17
|
},
|
|
18
18
|
"description": {
|
|
19
|
-
"en": "Cross-session
|
|
20
|
-
"zh": "跨会话 markdown 记忆:SOUL 人格、会话级开关、快速铸魂、3D
|
|
19
|
+
"en": "Cross-session markdown memory with SOUL persona, session switch, quick soul setup, 3D memory graph (search / reveal / double-click opens the file in the sidebar), boot snapshot, health dashboard and portable pack/unpack.",
|
|
20
|
+
"zh": "跨会话 markdown 记忆:SOUL 人格、会话级开关、快速铸魂、3D 记忆图谱(搜索/打开文件/双击在侧栏打开)、boot 快照、健康看板与 pack/unpack 迁移。"
|
|
21
21
|
},
|
|
22
22
|
"author": "LittleBlackTong",
|
|
23
23
|
"homepage": "https://github.com/LittleBlackTong/dsh-plugin-memory#readme",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"versions": [
|
|
28
28
|
{
|
|
29
|
-
"version": "0.
|
|
30
|
-
"publishTimestamp":
|
|
29
|
+
"version": "0.18.0",
|
|
30
|
+
"publishTimestamp": 1794273767,
|
|
31
31
|
"source": {
|
|
32
32
|
"type": "npm"
|
|
33
33
|
},
|
package/lib/boot.js
CHANGED
|
@@ -25,6 +25,24 @@ export const DEFAULT_BOOT_FILES = ['SOUL.md', 'MEMORY.md', 'index.md']
|
|
|
25
25
|
* signal, and this block is injected on every request. */
|
|
26
26
|
export const RECENT_LOG_COUNT = 3
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Render the recent-activity section on its own.
|
|
30
|
+
*
|
|
31
|
+
* It moved out of `renderBootBlock` so a boot snapshot can stay frozen for a
|
|
32
|
+
* whole session while the volatile tail (new log entries) rides in a separate
|
|
33
|
+
* runtime-context segment later in the prompt (order 900 vs -200), keeping
|
|
34
|
+
* prompt-prefix cache misses small (issue #8).
|
|
35
|
+
*/
|
|
36
|
+
export function renderRecentActivity(memoryDir, options = {}) {
|
|
37
|
+
const count = Number.isInteger(options.count) && options.count > 0 ? options.count : RECENT_LOG_COUNT
|
|
38
|
+
const logPath = join(memoryDir, 'log.md')
|
|
39
|
+
const logEntries = existsSync(logPath)
|
|
40
|
+
? parseLogEntries(readTailCapped(logPath, 4096) ?? '', count)
|
|
41
|
+
: []
|
|
42
|
+
if (logEntries.length === 0) return ''
|
|
43
|
+
return `### 最近动态(log.md 末尾 ${logEntries.length} 条)\n\n${logEntries.map((e) => `- ${e}`).join('\n')}`
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
/** Separator joining the boot-block sections. */
|
|
29
47
|
const SECTION_SEPARATOR = '\n\n---\n\n'
|
|
30
48
|
|
|
@@ -293,14 +311,10 @@ export function renderBootBlock(memoryDir, options = {}) {
|
|
|
293
311
|
|
|
294
312
|
if (sections.length === 0) return ''
|
|
295
313
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
: []
|
|
301
|
-
if (logEntries.length > 0) {
|
|
302
|
-
sections.push(`### 最近动态(log.md 末尾 ${logEntries.length} 条)\n\n${logEntries.map((e) => `- ${e}`).join('\n')}`)
|
|
303
|
-
}
|
|
314
|
+
const recent = options.includeRecentActivity === false
|
|
315
|
+
? ''
|
|
316
|
+
: renderRecentActivity(memoryDir, { count: RECENT_LOG_COUNT })
|
|
317
|
+
if (recent.length > 0) sections.push(recent)
|
|
304
318
|
|
|
305
319
|
const body = sections.join(SECTION_SEPARATOR)
|
|
306
320
|
const header = `长期记忆(dsh-plugin-memory)。记忆库位于 ${memoryDir}。这是你跨会话的持久人格与记忆:以它为准,先读完再回复用户。若与当前对话冲突,优先相信用户的最新表述,并把差异写回记忆。**每次会话收尾前必须执行 memory digest:把本会话关键沉淀写回(更新页面 + index.md + 追加 log.md)。插件会注入 digest 提醒消息,收到后立即写回,不得拖延;若本会话确无值得持久化的内容,在 log.md 记一条「无新增」并说明原因。**`
|
package/lib/client.js
CHANGED
|
@@ -55,6 +55,8 @@ window.__ModuleLoader__.load({
|
|
|
55
55
|
deferUntilUserSpeaksHint: '开启后,新会话在你发出第一条消息前不会注入任何记忆 / 追忆 / digest 提醒',
|
|
56
56
|
activeSessionOnly: '仅当前激活会话注入',
|
|
57
57
|
activeSessionOnlyHint: '开启后,只有最近收到你消息的会话才会注入记忆(后台会话不打扰)',
|
|
58
|
+
bootSnapshot: '固化 boot 快照',
|
|
59
|
+
bootSnapshotHint: '开启后本会话内不再重读记忆库,会话中途写入的改动下个会话才生效(省前缀缓存);关闭=每轮实时重读',
|
|
58
60
|
registerSkill: '注册 memory 技能',
|
|
59
61
|
registerSkillHint: '让 agent 获得 remember / recall / consolidate / forget 操作协议',
|
|
60
62
|
recall: '主动追忆',
|
|
@@ -175,6 +177,7 @@ window.__ModuleLoader__.load({
|
|
|
175
177
|
graphCopied: '路径已复制',
|
|
176
178
|
graphCopyFailed: '复制路径失败',
|
|
177
179
|
graphRevealFallback: '打开失败,已复制路径;在 Finder 里按 ⌘⇧G 粘贴路径即可跳转',
|
|
180
|
+
graphSidebarFailed: '侧栏打开失败:',
|
|
178
181
|
graphStats: '{pages} 页 · {links} 条页间互链 · {tagEdges} 条共享 tag',
|
|
179
182
|
graphIndexRoutes: '{count} 条索引路由(虚线)',
|
|
180
183
|
graphIsolated: '{count} 页暂时孤立',
|
|
@@ -210,6 +213,8 @@ window.__ModuleLoader__.load({
|
|
|
210
213
|
deferUntilUserSpeaksHint: 'When on, a new session injects no memory / recall / digest reminder before your first message',
|
|
211
214
|
activeSessionOnly: 'Inject into the active session only',
|
|
212
215
|
activeSessionOnlyHint: 'When on, only the session that most recently received a message from you gets memory (background sessions are left alone)',
|
|
216
|
+
bootSnapshot: 'Pin boot snapshot',
|
|
217
|
+
bootSnapshotHint: 'On: freeze the boot block for this session — memory written mid-session applies from the next session (saves prompt-cache misses); off: re-read live every turn',
|
|
213
218
|
registerSkill: 'Register the memory skill',
|
|
214
219
|
registerSkillHint: 'Give the agent the remember / recall / consolidate / forget protocol',
|
|
215
220
|
recall: 'Proactive recall',
|
|
@@ -330,6 +335,7 @@ window.__ModuleLoader__.load({
|
|
|
330
335
|
graphCopied: 'Path copied',
|
|
331
336
|
graphCopyFailed: 'Could not copy the path',
|
|
332
337
|
graphRevealFallback: 'Reveal failed; the path was copied — paste it in your file manager to jump there',
|
|
338
|
+
graphSidebarFailed: 'Sidebar open failed: ',
|
|
333
339
|
graphStats: '{pages} pages · {links} page links · {tagEdges} shared tags',
|
|
334
340
|
graphIndexRoutes: '{count} index routes (dashed)',
|
|
335
341
|
graphIsolated: '{count} pages isolated',
|
|
@@ -1331,6 +1337,18 @@ window.__ModuleLoader__.load({
|
|
|
1331
1337
|
onChange: (next) => apply({ autoInject: next }),
|
|
1332
1338
|
}),
|
|
1333
1339
|
),
|
|
1340
|
+
React.createElement('div', { style: rowStyle },
|
|
1341
|
+
React.createElement('div', null,
|
|
1342
|
+
React.createElement('div', { style: labelStyle }, t('bootSnapshot')),
|
|
1343
|
+
React.createElement('div', { style: subStyle }, t('bootSnapshotHint')),
|
|
1344
|
+
),
|
|
1345
|
+
React.createElement(Toggle, {
|
|
1346
|
+
label: t('bootSnapshot'),
|
|
1347
|
+
checked: value.bootSnapshot === 'session',
|
|
1348
|
+
disabled,
|
|
1349
|
+
onChange: (next) => apply({ bootSnapshot: next ? 'session' : 'live' }),
|
|
1350
|
+
}),
|
|
1351
|
+
),
|
|
1334
1352
|
React.createElement('div', { style: rowStyle },
|
|
1335
1353
|
React.createElement('div', null,
|
|
1336
1354
|
React.createElement('div', { style: labelStyle }, t('deferUntilUserSpeaks')),
|
|
@@ -2003,7 +2021,7 @@ window.__ModuleLoader__.load({
|
|
|
2003
2021
|
}
|
|
2004
2022
|
|
|
2005
2023
|
/** 「在 Finder 中显示」按钮 + 双击节点;失败时自动复制路径兜底。 */
|
|
2006
|
-
const revealNode = (id) => {
|
|
2024
|
+
const revealNode = (id, noticeAfterSuccess) => {
|
|
2007
2025
|
fetch(GRAPH_REVEAL_URL, {
|
|
2008
2026
|
method: 'POST',
|
|
2009
2027
|
headers: { 'content-type': 'application/json' },
|
|
@@ -2014,7 +2032,7 @@ window.__ModuleLoader__.load({
|
|
|
2014
2032
|
if (!response.ok) throw new Error(body.error ?? `POST ${response.status}`)
|
|
2015
2033
|
return body
|
|
2016
2034
|
})
|
|
2017
|
-
.then(() => setNotice(
|
|
2035
|
+
.then(() => setNotice(noticeAfterSuccess))
|
|
2018
2036
|
.catch(async (error) => {
|
|
2019
2037
|
const message = error instanceof Error ? error.message : String(error)
|
|
2020
2038
|
const copied = await copyPathToClipboard(id)
|
|
@@ -2022,6 +2040,59 @@ window.__ModuleLoader__.load({
|
|
|
2022
2040
|
})
|
|
2023
2041
|
}
|
|
2024
2042
|
|
|
2043
|
+
/** 双击节点:优先在 DSH 右侧栏打开该 md 文件;不可用时回退系统文件管理器。 */
|
|
2044
|
+
const openInSidebar = async (id) => {
|
|
2045
|
+
const sidebar = sidebarRightService
|
|
2046
|
+
if (!sidebar || typeof sidebar.openResource !== 'function') return { ok: false, reason: 'sidebar-unavailable' }
|
|
2047
|
+
let pathInfo
|
|
2048
|
+
try {
|
|
2049
|
+
pathInfo = await fetch(`${GRAPH_PATH_URL}?id=${encodeURIComponent(id)}`).then((response) => response.json())
|
|
2050
|
+
} catch {
|
|
2051
|
+
return { ok: false, reason: 'path-fetch-failed' }
|
|
2052
|
+
}
|
|
2053
|
+
if (!pathInfo || pathInfo.ok !== true || typeof pathInfo.path !== 'string') return { ok: false, reason: 'path-unresolved' }
|
|
2054
|
+
const absolute = pathInfo.path.replace(/\\/g, '/')
|
|
2055
|
+
let session
|
|
2056
|
+
try {
|
|
2057
|
+
session = await fetch(SESSION_URL).then((response) => response.json())
|
|
2058
|
+
} catch {
|
|
2059
|
+
return { ok: false, reason: 'session-fetch-failed' }
|
|
2060
|
+
}
|
|
2061
|
+
if (!session || session.ok !== true || typeof session.sessionId !== 'string') return { ok: false, reason: 'no-session' }
|
|
2062
|
+
const root = typeof session.cwd === 'string' && session.cwd.length > 0
|
|
2063
|
+
? session.cwd.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
2064
|
+
: undefined
|
|
2065
|
+
const encodePath = (path) => path.split('/')
|
|
2066
|
+
.map((segment, index) => (index === 0 && /^[A-Za-z]:$/.test(segment) ? segment : encodeURIComponent(segment)))
|
|
2067
|
+
.join('/')
|
|
2068
|
+
let address
|
|
2069
|
+
if (root !== undefined && (absolute === root || absolute.startsWith(`${root}/`))) {
|
|
2070
|
+
const relative = absolute.slice(root.length).replace(/^\/+/, '')
|
|
2071
|
+
address = `dsh-resource://file/session/${encodeURIComponent(session.sessionId)}/${encodePath(relative)}`
|
|
2072
|
+
} else {
|
|
2073
|
+
address = `dsh-resource://file/absolute/${encodePath(absolute.replace(/^\/+/, ''))}`
|
|
2074
|
+
}
|
|
2075
|
+
try {
|
|
2076
|
+
await sidebar.openResource(address)
|
|
2077
|
+
} catch (error) {
|
|
2078
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) }
|
|
2079
|
+
}
|
|
2080
|
+
return { ok: true }
|
|
2081
|
+
}
|
|
2082
|
+
const openNode = (id) => {
|
|
2083
|
+
openInSidebar(id)
|
|
2084
|
+
.then((result) => {
|
|
2085
|
+
if (result.ok === true) return
|
|
2086
|
+
setNotice(`${t('graphSidebarFailed')}${result.reason}`)
|
|
2087
|
+
revealNode(id, `${t('graphSidebarFailed')}${result.reason}`)
|
|
2088
|
+
})
|
|
2089
|
+
.catch((error) => {
|
|
2090
|
+
const reason = error instanceof Error ? error.message : String(error)
|
|
2091
|
+
setNotice(`${t('graphSidebarFailed')}${reason}`)
|
|
2092
|
+
revealNode(id, `${t('graphSidebarFailed')}${reason}`)
|
|
2093
|
+
})
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2025
2096
|
React.useEffect(() => { stateRef.current.selected = selected }, [selected])
|
|
2026
2097
|
React.useEffect(() => { stateRef.current.spin = spin }, [spin])
|
|
2027
2098
|
|
|
@@ -2159,7 +2230,7 @@ window.__ModuleLoader__.load({
|
|
|
2159
2230
|
if (hit !== null) {
|
|
2160
2231
|
stateRef.current.selected = hit.id
|
|
2161
2232
|
setSelected(hit.id)
|
|
2162
|
-
|
|
2233
|
+
openNode(hit.id)
|
|
2163
2234
|
return
|
|
2164
2235
|
}
|
|
2165
2236
|
stateRef.current.view = { yaw: 0.55, pitch: -0.2, zoom: 1 }
|
|
@@ -2416,6 +2487,8 @@ window.__ModuleLoader__.load({
|
|
|
2416
2487
|
// 挂载后按 label 认出自己那一行,藏掉齿轮、用 mask 画自己的标记。
|
|
2417
2488
|
// 官方哪天给 settings.section 长出 icon 字段,这段即可删除。
|
|
2418
2489
|
const NAV_ROW_SELECTOR = '[role="dialog"] nav button'
|
|
2490
|
+
// Right-sidebar navigation service (0.18.0, DSH ≥ 0.2.2); undefined on older hosts.
|
|
2491
|
+
let sidebarRightService
|
|
2419
2492
|
const NAV_ICON_ATTR = 'data-dsh-memory-nav-icon'
|
|
2420
2493
|
// The label is resolved from DICTS by `sectionLabel(language)`: it is both the
|
|
2421
2494
|
// displayed text and the claim key, so both must come from that one function.
|
|
@@ -2482,6 +2555,15 @@ window.__ModuleLoader__.load({
|
|
|
2482
2555
|
}
|
|
2483
2556
|
|
|
2484
2557
|
function apply(ctx) {
|
|
2558
|
+
// Right-sidebar navigation (double-click a graph node opens the file in
|
|
2559
|
+
// the sidebar). Optional service: older hosts just fall back to reveal.
|
|
2560
|
+
// `ctx.reflect.get` reads a service without declaring it in `inject`, so
|
|
2561
|
+
// older hosts without the right sidebar simply fall back to reveal.
|
|
2562
|
+
try {
|
|
2563
|
+
sidebarRightService = ctx.reflect?.get?.('sidebarRight', true) ?? undefined
|
|
2564
|
+
} catch {
|
|
2565
|
+
sidebarRightService = undefined
|
|
2566
|
+
}
|
|
2485
2567
|
// Language packs ride DSH's own locale layer: the panel follows
|
|
2486
2568
|
// 设置 → 通用设置 → 语言 instead of guessing from navigator.language.
|
|
2487
2569
|
ctx.effect(() => ctx.locale.register(LOCALE_NS, DICTS), 'memory: dictionaries')
|
package/lib/config-store.js
CHANGED
|
@@ -23,7 +23,7 @@ export function defaultConfigPath() {
|
|
|
23
23
|
return join(process.env.DSH_HOME || join(homedir(), '.dsh'), MEMORY_CONFIG_FILENAME)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const FIELDS = ['enabled', 'memoryDir', 'autoInject', 'registerSkill', 'deferUntilUserSpeaks', 'activeSessionOnly', 'recallEnabled', 'recallIntervalMinMinutes', 'recallIntervalMaxMinutes', 'recallMaxPerSession', 'proactiveCooldownSeconds', 'toneGuideEnabled', 'toneIntensity', 'growthRecapEnabled', 'growthRecapIntervalDays', 'disabledWorkspaces']
|
|
26
|
+
const FIELDS = ['enabled', 'memoryDir', 'autoInject', 'registerSkill', 'deferUntilUserSpeaks', 'activeSessionOnly', 'recallEnabled', 'recallIntervalMinMinutes', 'recallIntervalMaxMinutes', 'recallMaxPerSession', 'proactiveCooldownSeconds', 'toneGuideEnabled', 'toneIntensity', 'growthRecapEnabled', 'growthRecapIntervalDays', 'disabledWorkspaces', 'bootSnapshot']
|
|
27
27
|
|
|
28
28
|
/** Tone intensity values the schema accepts; invalid composition input falls back to low. */
|
|
29
29
|
const TONE_INTENSITIES = ['low', 'medium', 'off']
|
|
@@ -72,6 +72,7 @@ export class MemoryConfigStore {
|
|
|
72
72
|
growthRecapEnabled: options.base?.growthRecapEnabled !== false,
|
|
73
73
|
growthRecapIntervalDays: options.base?.growthRecapIntervalDays ?? 7,
|
|
74
74
|
disabledWorkspaces: Array.isArray(options.base?.disabledWorkspaces) ? options.base.disabledWorkspaces : [],
|
|
75
|
+
bootSnapshot: options.base?.bootSnapshot === 'session' ? 'session' : 'live',
|
|
75
76
|
}
|
|
76
77
|
this.config = { ...this.base }
|
|
77
78
|
this.watchers = new Set()
|
|
@@ -109,6 +110,7 @@ export class MemoryConfigStore {
|
|
|
109
110
|
growthRecapEnabled: resolved.growthRecapEnabled,
|
|
110
111
|
growthRecapIntervalDays: resolved.growthRecapIntervalDays,
|
|
111
112
|
disabledWorkspaces: resolved.disabledWorkspaces,
|
|
113
|
+
bootSnapshot: resolved.bootSnapshot,
|
|
112
114
|
}
|
|
113
115
|
} catch {
|
|
114
116
|
// schema validation failed: keep last good config
|
|
@@ -154,6 +156,7 @@ export class MemoryConfigStore {
|
|
|
154
156
|
growthRecapEnabled: next.growthRecapEnabled,
|
|
155
157
|
growthRecapIntervalDays: next.growthRecapIntervalDays,
|
|
156
158
|
disabledWorkspaces: next.disabledWorkspaces,
|
|
159
|
+
bootSnapshot: next.bootSnapshot,
|
|
157
160
|
}
|
|
158
161
|
this.persist()
|
|
159
162
|
for (const watcher of this.watchers) {
|
package/lib/index.js
CHANGED
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
import { homedir } from 'node:os'
|
|
89
89
|
import { join, resolve } from 'node:path'
|
|
90
90
|
import z from '@deepseek-ai/schemastery'
|
|
91
|
-
import { renderBootBlock, DEFAULT_BOOT_FILES, needsSoulBootstrap, readBootstrapStatus } from './boot.js'
|
|
91
|
+
import { renderBootBlock, renderRecentActivity, DEFAULT_BOOT_FILES, needsSoulBootstrap, readBootstrapStatus } from './boot.js'
|
|
92
92
|
import {
|
|
93
93
|
accessSummary,
|
|
94
94
|
extractReferencedPages,
|
|
@@ -155,6 +155,9 @@ export const Config = z.object({
|
|
|
155
155
|
// file takes at most twice the even share (see allocateBootBudget).
|
|
156
156
|
bootFileBudgets: z.union([z.dict(z.number()), z.const(undefined)]),
|
|
157
157
|
autoInject: z.boolean().default(true),
|
|
158
|
+
// 0.18.0 (issue #8): `session` freezes the boot block until the session ends;
|
|
159
|
+
// `live` re-reads the store every turn (0.17 behaviour).
|
|
160
|
+
bootSnapshot: z.union([z.const('live'), z.const('session')]).default('live'),
|
|
158
161
|
registerSkill: z.boolean().default(true),
|
|
159
162
|
scaffold: z.boolean().default(true),
|
|
160
163
|
configFile: z.union([z.string(), z.const(undefined)]),
|
|
@@ -305,6 +308,7 @@ export function apply(ctx, config = {}) {
|
|
|
305
308
|
}
|
|
306
309
|
if (arg === 'on' || arg === 'off') {
|
|
307
310
|
sessionGate.setOverride(agent.id, arg === 'on', cwd)
|
|
311
|
+
bootSnapshots.delete(agent.id)
|
|
308
312
|
return { kind: 'success', text: `Memory is now ${arg.toUpperCase()} for this session.` }
|
|
309
313
|
}
|
|
310
314
|
if (arg === 'workspace-off' || arg === 'workspace-on') {
|
|
@@ -322,16 +326,34 @@ export function apply(ctx, config = {}) {
|
|
|
322
326
|
}
|
|
323
327
|
|
|
324
328
|
let bootDispose
|
|
329
|
+
let recentDispose
|
|
325
330
|
let skillDispose
|
|
326
331
|
let scaffoldedDir
|
|
327
332
|
let committer
|
|
328
333
|
let currentMemoryDir = resolveMemoryDir(store.get().memoryDir)
|
|
329
334
|
|
|
335
|
+
// 0.18.0 (issue #8): with `bootSnapshot: session` the rendered boot text is
|
|
336
|
+
// frozen per agent, so a mid-session digest cannot invalidate the prompt
|
|
337
|
+
// prefix. Cleared on config changes and on any /memory on|off toggle.
|
|
338
|
+
const bootSnapshots = new Map()
|
|
339
|
+
const clearBootSnapshots = () => bootSnapshots.clear()
|
|
340
|
+
const snapshotSignature = (resolved, dir) => [
|
|
341
|
+
dir,
|
|
342
|
+
JSON.stringify(bootFiles),
|
|
343
|
+
bootMaxChars,
|
|
344
|
+
JSON.stringify(bootFileBudgets ?? null),
|
|
345
|
+
resolved.toneGuideEnabled === false ? 'off' : String(resolved.toneIntensity ?? 'low'),
|
|
346
|
+
].join('|')
|
|
347
|
+
|
|
330
348
|
const disposeBoot = () => {
|
|
331
349
|
if (bootDispose !== undefined) {
|
|
332
350
|
bootDispose()
|
|
333
351
|
bootDispose = undefined
|
|
334
352
|
}
|
|
353
|
+
if (recentDispose !== undefined) {
|
|
354
|
+
recentDispose()
|
|
355
|
+
recentDispose = undefined
|
|
356
|
+
}
|
|
335
357
|
}
|
|
336
358
|
|
|
337
359
|
const disposeSkill = () => {
|
|
@@ -404,7 +426,37 @@ export function apply(ctx, config = {}) {
|
|
|
404
426
|
const toneGuide = resolved.toneGuideEnabled
|
|
405
427
|
? buildToneGuide({ intensity: resolved.toneIntensity, language: 'zh' })
|
|
406
428
|
: ''
|
|
407
|
-
|
|
429
|
+
const options = {
|
|
430
|
+
bootFiles,
|
|
431
|
+
bootMaxChars,
|
|
432
|
+
bootFileBudgets,
|
|
433
|
+
toneGuide,
|
|
434
|
+
// The volatile log tail is injected by `memory-recent` instead.
|
|
435
|
+
includeRecentActivity: false,
|
|
436
|
+
}
|
|
437
|
+
if (agent && resolved.bootSnapshot === 'session') {
|
|
438
|
+
const signature = snapshotSignature(resolved, memoryDir)
|
|
439
|
+
const hit = bootSnapshots.get(agent.id)
|
|
440
|
+
if (hit !== undefined && hit.signature === signature) return hit.text
|
|
441
|
+
const text = renderBootBlock(memoryDir, options)
|
|
442
|
+
bootSnapshots.set(agent.id, { text, signature })
|
|
443
|
+
if (bootSnapshots.size > 64) bootSnapshots.delete(bootSnapshots.keys().next().value)
|
|
444
|
+
return text
|
|
445
|
+
}
|
|
446
|
+
return renderBootBlock(memoryDir, options)
|
|
447
|
+
},
|
|
448
|
+
})
|
|
449
|
+
// The volatile tail (recent log entries) lives in its own segment with a
|
|
450
|
+
// late order, so a mid-session digest changes only that suffix.
|
|
451
|
+
recentDispose = ctx.systemPrompt.context({
|
|
452
|
+
name: 'memory-recent',
|
|
453
|
+
order: 900,
|
|
454
|
+
text: (context) => {
|
|
455
|
+
const resolved = store.get()
|
|
456
|
+
const agent = context?.agent
|
|
457
|
+
if (agent && !sessionEnabled(agent, resolved)) return ''
|
|
458
|
+
if (agent && !tracker.shouldInject(agent.id, resolved)) return ''
|
|
459
|
+
return renderRecentActivity(memoryDir)
|
|
408
460
|
},
|
|
409
461
|
})
|
|
410
462
|
} else {
|
|
@@ -604,7 +656,7 @@ export function apply(ctx, config = {}) {
|
|
|
604
656
|
|
|
605
657
|
// Settings-panel hot edits: any store change re-applies the config.
|
|
606
658
|
ctx.effect(() => {
|
|
607
|
-
const unwatch = store.watch(() => rebuild())
|
|
659
|
+
const unwatch = store.watch(() => { clearBootSnapshots(); rebuild() })
|
|
608
660
|
return () => {
|
|
609
661
|
unwatch()
|
|
610
662
|
}
|
|
@@ -743,6 +795,8 @@ export function apply(ctx, config = {}) {
|
|
|
743
795
|
sendJson(200, { ok: false, reason: 'no-session' })
|
|
744
796
|
return
|
|
745
797
|
}
|
|
798
|
+
// A gate change invalidates the frozen boot text for this agent.
|
|
799
|
+
bootSnapshots.delete(agent.id)
|
|
746
800
|
sendJson(200, { ok: true, ...describeSession(agent, store.get()) })
|
|
747
801
|
return
|
|
748
802
|
}
|
package/lib/schema.js
CHANGED
|
@@ -36,4 +36,8 @@ export const SettingsSchema = z.object({
|
|
|
36
36
|
// Workspaces that default to memory off (session gate layer 3). A session
|
|
37
37
|
// inside one of these roots starts muted until the user turns it back on.
|
|
38
38
|
disabledWorkspaces: z.array(z.string()).default([]),
|
|
39
|
+
// 0.18.0: freeze the boot block for the whole session so mid-session writes
|
|
40
|
+
// do not invalidate the prompt-prefix cache (issue #8). `live` keeps the
|
|
41
|
+
// 0.17 behaviour of re-reading the store on every turn.
|
|
42
|
+
bootSnapshot: z.union([z.const('live'), z.const('session')]).default('live'),
|
|
39
43
|
})
|
package/lib/types/index.d.ts
CHANGED
|
@@ -77,6 +77,12 @@ export interface MemoryConfig {
|
|
|
77
77
|
* Default `[]`.
|
|
78
78
|
*/
|
|
79
79
|
disabledWorkspaces?: string[]
|
|
80
|
+
/**
|
|
81
|
+
* `session` — freeze the rendered boot block for the whole session so a
|
|
82
|
+
* mid-session digest cannot invalidate the prompt-prefix cache (issue #8);
|
|
83
|
+
* `live` (default) — re-read the store on every turn.
|
|
84
|
+
*/
|
|
85
|
+
bootSnapshot?: 'live' | 'session'
|
|
80
86
|
/** Where per-session overrides live (default `<dshHome>/memory-sessions.json`). */
|
|
81
87
|
sessionStateFile?: string
|
|
82
88
|
/** Days a session override stays valid before it is pruned. Default `7`. */
|
|
@@ -134,6 +140,8 @@ export interface MemorySettings {
|
|
|
134
140
|
growthRecapEnabled?: boolean
|
|
135
141
|
growthRecapIntervalDays?: number
|
|
136
142
|
disabledWorkspaces?: string[]
|
|
143
|
+
/** `live` (default) re-reads every turn; `session` freezes the boot block. */
|
|
144
|
+
bootSnapshot?: 'live' | 'session'
|
|
137
145
|
}
|
|
138
146
|
|
|
139
147
|
/** Schemastery schema for {@link MemorySettings}. */
|
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.
|
|
4
|
+
"version": "0.18.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|