dsh-plugin-memory 0.13.1 → 0.13.3
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 +34 -0
- package/README.md +3 -1
- package/README.zh.md +3 -1
- package/lib/boot.js +25 -9
- package/lib/client.js +11 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
|
|
4
4
|
|
|
5
|
+
## [0.13.3] - 2026-11-02
|
|
6
|
+
|
|
7
|
+
### Fixed(boot 预算单位:字节 vs 字符)
|
|
8
|
+
|
|
9
|
+
- **中文 / 日文 / 韩文记忆库的 boot 文件被系统性低估预算**:`allocateBootBudget()` 用 `statSync().size`(UTF-8 字节)判断文件大小,`readCapped()` 却按字符 `slice()` 截断。中文 1 字 = 3 字节,于是每个 CJK 文件都被判成「超过均分额度」,cap 被抬到 `total/3`,pool 提前耗尽、短文件退回的余量永远不回流,真正长的文件被无谓截断。实测(12000 预算、`字` 每字 3 字节):6000 字符的 SOUL 被截到 4000,而此时预算还有 2000 字符空闲。
|
|
10
|
+
- 修复:`sizeOf()` 改为读取内容取 `.length`(字符),与 `readCapped` 及全仓其它口径(insights / checkup / doctor 均按字符)统一;同一 `allocateBootBudget()` 调用内缓存尺寸,读盘次数不增加量级。
|
|
11
|
+
- 影响面:英文库 1 字节 ≈ 1 字符,行为不变;CJK 库恢复按字符分配,短文件退回的余量可以回流给真正长的文件。
|
|
12
|
+
- **不变的部分**:`readCapped` 的截断提示、`renderBootBlock` 的总量兜底、`readTailCapped`(log)本来就是字符口径,未改动。
|
|
13
|
+
|
|
14
|
+
### Tests
|
|
15
|
+
|
|
16
|
+
- `boot-budget` 新增 2 条 CJK 用例:`字` × 6000/1000/3000(长文件拿到回流、不截断);用户报告形状 `字` × 2141/3979/2744(短文件不再虚高吃 pool)。
|
|
17
|
+
- 全量 **262/262 通过**(0.13.2 基线 260 + 2);`node scripts/memory.mjs --self-test` PASS。
|
|
18
|
+
|
|
19
|
+
## [0.13.2] - 2026-10-30
|
|
20
|
+
|
|
21
|
+
### Fixed(reviewer 复核尾巴 + 结构修正)
|
|
22
|
+
|
|
23
|
+
- **「立即回顾」no-session / error 使用独立文案**:`no-session` → 新增「没有活跃会话可回顾」(`growthNowNoSession`);`error` / `agent-gone` / `disposed` → 新增「回顾失败」(`growthNowError`,**不带悬空冒号**);网络错误仍拼接 `growthNowFailed`(保留冒号并附具体错误)。
|
|
24
|
+
- **焦点环 marker 上移到面板外层 + 恢复三卡独立错误隔离**:`data-dsh-memory-panel` 从表单根 div 移到 `MemorySection` 外层(包住表单 + 健康卡 + 图谱卡),`:focus-visible` 规则真正覆盖整块面板;同时修正 reviewer 指出的 `SectionBoundary` 嵌套——表单 / 健康卡 / 图谱卡仍是三个独立边界,一张卡出错不会带崩整块面板。
|
|
25
|
+
- **结果提示 5 秒自动清除**(补齐 busy / no-session / error 三条新分支同样遵循)。
|
|
26
|
+
- **手动回顾后的节律与投递目标**:手动回顾成功会把自动追忆节律前移(不会紧接着再发一条);多 root 会话时按 `tracker.isActive` 优先投递当前活跃会话。
|
|
27
|
+
- **类型声明**:`types/index.d.ts` 补 `CONTROL_ROUTE_PATH` / `GRAPH_ROUTE_PATH` 常量。
|
|
28
|
+
- **README**:两语言嵌入真实设置面板截图 `assets/settings-panel.png`(含「立即回顾」按钮;`assets/` 不在 `files` 字段,不影响 npm 包体)。
|
|
29
|
+
|
|
30
|
+
### Notes
|
|
31
|
+
|
|
32
|
+
- **手动「立即回顾」有意绕过每会话追忆上限**(用户显式操作);但插件启用、agent idle、成长回顾开启、有内容、发言权仲裁仍然全部生效。
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
|
|
36
|
+
- `client-i18n` 新增 2 条:no-session / error 独立文案与去冒号、面板 marker 覆盖范围。
|
|
37
|
+
- 全量单测 **260/260 通过**(0.13.1 基线 258,新增 2 条);`node scripts/memory.mjs --self-test` PASS。
|
|
38
|
+
|
|
5
39
|
## [0.13.1] - 2026-10-30
|
|
6
40
|
|
|
7
41
|
### Fixed(面板可用性四连)
|
package/README.md
CHANGED
|
@@ -148,6 +148,8 @@ Fifteen settings are editable in the "Memory" section of the DSH settings page a
|
|
|
148
148
|
|
|
149
149
|
A **Review now** button sits beside them: it is a **control, not a setting** — it asks the plugin to send one growth recap immediately. It still respects the speech floor (it backs off if the other plugin is speaking), sends nothing when this week has no new material, works even while `recallEnabled` is off, and reports the outcome in the panel (sending / sent / deferred / session busy / no content / disabled / failed) — the result notice clears itself after 5 seconds.
|
|
150
150
|
|
|
151
|
+

|
|
152
|
+
|
|
151
153
|
### Language
|
|
152
154
|
|
|
153
155
|
The settings panel and its sidebar label follow DSH's own language setting (**Settings → General → Language**) and switch live — no restart: Chinese shows 「记忆」, English shows "Memory". Panel copy is registered as the `memory` locale namespace through `ctx.locale`, so the renderer re-renders the whole panel (form, health dashboard, graph card) in the active language and injects a `t(key)` seat into the section. The sidebar icon claim key is derived from that same label, so a language switch re-claims the right row. The dashboard's health-check labels **and details** are rebuilt client-side from locale-neutral `data` the insights route ships (`lib/insights.js` keeps the Chinese `label`/`detail` strings for the CLI); an older host payload without `data` falls back to those Chinese strings. User content (page titles, `log.md` headlines) and the CLI's own Chinese output are content, not UI copy, and stay as-is.
|
|
@@ -251,7 +253,7 @@ node scripts/memory.mjs --self-test # smoke test (no dependencies to install)
|
|
|
251
253
|
|
|
252
254
|
Zero build: `lib/` is runtime code as-is, and `lib/types/index.d.ts` serves TypeScript consumers. `boot.js` / `scaffold.js` depend only on `node:*` built-ins and can be reused standalone.
|
|
253
255
|
|
|
254
|
-
The test suite (`node --test`) currently holds **
|
|
256
|
+
The test suite (`node --test`) currently holds **260 tests**, and CI (`.github/workflows/ci.yml`) runs it together with `node scripts/memory.mjs --self-test`. Contribution and security policies live in [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md); the cross-plugin speech-floor protocol is documented in [docs/PROACTIVE-PROTOCOL.md](docs/PROACTIVE-PROTOCOL.md).
|
|
255
257
|
|
|
256
258
|
## Roadmap
|
|
257
259
|
|
package/README.zh.md
CHANGED
|
@@ -154,6 +154,8 @@ dsh plugin --profile <profile> add dsh-plugin-memory
|
|
|
154
154
|
|
|
155
155
|
旁边还有一个 **「立即回顾」按钮**:它是**控制动作,不是配置项**——让插件立刻发一次成长回顾。仍尊重发言权仲裁(别的插件在说话就让位)、本周没有新内容就不发、即使 `recallEnabled` 关闭也能用,并在面板里给出结果(回顾中 / 已发送 / 让位 / 会话正忙 / 没有新内容 / 已关闭 / 失败),结果提示 5 秒后自动消失。
|
|
156
156
|
|
|
157
|
+

|
|
158
|
+
|
|
157
159
|
### 语言 / Language
|
|
158
160
|
|
|
159
161
|
设置面板与侧栏 label 跟随 DSH 自己的语言设置(**设置 → 通用设置 → 语言**),切换即时生效、无需重启:中文显示「记忆」,英文显示 "Memory"。面板文案通过 `ctx.locale` 注册在 `memory` 命名空间,renderer 会给区块注入 `t(key)` 座位,于是表单、健康看板、图谱卡片整体重渲染为当前语言;侧栏图标的认领键取自同一个 label 解析函数,语言切换后自动重新认领正确的那一行。健康看板的四项体检 **label 与 detail** 由 insights 路由新增的结构化 `data` 在客户端按语言重建(`lib/insights.js` 仍保留中文 `label`/`detail` 供 CLI 使用);旧版本宿主 payload 没有 `data` 时回退中文串。用户内容(页面标题、`log.md` 动态)与 CLI 自身的中文输出属于内容而非界面文案,不在翻译范围内。
|
|
@@ -257,7 +259,7 @@ node scripts/memory.mjs --self-test # 冒烟测试(无需安装依赖)
|
|
|
257
259
|
|
|
258
260
|
零构建:`lib/` 直接是运行时代码,`lib/types/index.d.ts` 供 TS 消费方使用。`boot.js` / `scaffold.js` 只依赖 `node:*` 内置模块,可独立复用。
|
|
259
261
|
|
|
260
|
-
测试用 `node --test`,当前共 **
|
|
262
|
+
测试用 `node --test`,当前共 **260 个用例**;CI(`.github/workflows/ci.yml`)会连同 `node scripts/memory.mjs --self-test` 一起跑。贡献与安全策略见 [CONTRIBUTING.md](CONTRIBUTING.md)、[SECURITY.md](SECURITY.md);跨插件发言协议见 [docs/PROACTIVE-PROTOCOL.md](docs/PROACTIVE-PROTOCOL.md)。
|
|
261
263
|
|
|
262
264
|
## 路线图
|
|
263
265
|
|
package/lib/boot.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @module dsh-plugin-memory/boot
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { existsSync, readFileSync
|
|
14
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
15
15
|
import { join } from 'node:path'
|
|
16
16
|
|
|
17
17
|
/** Files injected at session start when the config does not override them. */
|
|
@@ -92,8 +92,14 @@ export function parseLogEntries(logText, count = 5) {
|
|
|
92
92
|
* twice the even share each): `index.md` first, then by size, so
|
|
93
93
|
* truncation lands on bulky files no matter their order in `bootFiles`.
|
|
94
94
|
*
|
|
95
|
-
* While every file fits inside its even share this is
|
|
96
|
-
* behaviour; it only starts to differ once the store outgrows its share.
|
|
95
|
+
* While every file fits inside its even share this is character-for-character
|
|
96
|
+
* the old behaviour; it only starts to differ once the store outgrows its share.
|
|
97
|
+
*
|
|
98
|
+
* Budgets are expressed in **characters**, matching `readCapped` (`String.slice`)
|
|
99
|
+
* and every other size in the plugin. Sizing the files by `statSync().size` was
|
|
100
|
+
* a unit mismatch: a CJK file is ~3 UTF-8 bytes per character, so it looked 3x
|
|
101
|
+
* longer than it is, got capped at the even share, and the pool was spent before
|
|
102
|
+
* the surplus could flow back to the file that was actually long.
|
|
97
103
|
*
|
|
98
104
|
* @param {string} memoryDir absolute path of the memory store
|
|
99
105
|
* @param {{ files?: string[], total?: number, perFile?: Record<string, number> }} [options]
|
|
@@ -102,13 +108,23 @@ export function parseLogEntries(logText, count = 5) {
|
|
|
102
108
|
export function allocateBootBudget(memoryDir, options = {}) {
|
|
103
109
|
const files = (options.files ?? []).filter((f) => typeof f === 'string' && f.length > 0)
|
|
104
110
|
const total = Math.max(512, Number(options.total) || 6000)
|
|
105
|
-
const sizeOf = (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
const sizeOf = (() => {
|
|
112
|
+
const sizes = new Map()
|
|
113
|
+
return (fileName) => {
|
|
114
|
+
if (sizes.has(fileName)) return sizes.get(fileName)
|
|
115
|
+
let chars = 0
|
|
116
|
+
try {
|
|
117
|
+
// Characters, not bytes: caps are consumed by readCapped, which slices
|
|
118
|
+
// a UTF-16 string. A CJK file is ~3 bytes per character, so counting
|
|
119
|
+
// bytes would overstate it ~3x and starve the leftover pool.
|
|
120
|
+
chars = readFileSync(join(memoryDir, fileName), 'utf8').length
|
|
121
|
+
} catch {
|
|
122
|
+
chars = 0
|
|
123
|
+
}
|
|
124
|
+
sizes.set(fileName, chars)
|
|
125
|
+
return chars
|
|
110
126
|
}
|
|
111
|
-
}
|
|
127
|
+
})()
|
|
112
128
|
|
|
113
129
|
const caps = new Map(files.map((f) => [f, 0]))
|
|
114
130
|
const explicit = options.perFile ?? {}
|
package/lib/client.js
CHANGED
|
@@ -81,6 +81,8 @@ window.__ModuleLoader__.load({
|
|
|
81
81
|
growthNowEmpty: '这一周没有可回顾的新内容',
|
|
82
82
|
growthNowDisabled: '成长回顾已关闭',
|
|
83
83
|
growthNowFailed: '回顾失败:',
|
|
84
|
+
growthNowError: '回顾失败',
|
|
85
|
+
growthNowNoSession: '没有活跃会话可回顾',
|
|
84
86
|
minutesPlaceholder: '30',
|
|
85
87
|
maxMinutesPlaceholder: '240',
|
|
86
88
|
maxPerSessionPlaceholder: '3',
|
|
@@ -189,6 +191,8 @@ window.__ModuleLoader__.load({
|
|
|
189
191
|
growthNowEmpty: 'Nothing new to recap this week',
|
|
190
192
|
growthNowDisabled: 'Weekly recap is off',
|
|
191
193
|
growthNowFailed: 'Recap failed: ',
|
|
194
|
+
growthNowError: 'Recap failed',
|
|
195
|
+
growthNowNoSession: 'No active session to recap',
|
|
192
196
|
minutesPlaceholder: '30',
|
|
193
197
|
maxMinutesPlaceholder: '240',
|
|
194
198
|
maxPerSessionPlaceholder: '3',
|
|
@@ -443,8 +447,10 @@ window.__ModuleLoader__.load({
|
|
|
443
447
|
const [gen, setGen] = React.useState(0)
|
|
444
448
|
const t = useT(props)
|
|
445
449
|
return React.createElement(LocaleContext.Provider, { value: t },
|
|
446
|
-
React.createElement(
|
|
447
|
-
React.createElement(
|
|
450
|
+
React.createElement('div', { 'data-dsh-memory-panel': '', style: { padding: '8px 0' } },
|
|
451
|
+
React.createElement(SectionBoundary, null,
|
|
452
|
+
React.createElement(MemoryForm, { onSaved: () => setGen((value) => value + 1) }),
|
|
453
|
+
),
|
|
448
454
|
React.createElement(SectionBoundary, { key: gen },
|
|
449
455
|
React.createElement(InsightsCard),
|
|
450
456
|
),
|
|
@@ -725,7 +731,8 @@ window.__ModuleLoader__.load({
|
|
|
725
731
|
if (reason === 'no-content') { setGrowthNotice(t('growthNowEmpty')); return }
|
|
726
732
|
if (reason === 'disabled' || reason === 'growth-disabled') { setGrowthNotice(t('growthNowDisabled')); return }
|
|
727
733
|
if (reason === 'busy') { setGrowthNotice(t('growthNowBusy')); return }
|
|
728
|
-
if (reason === '
|
|
734
|
+
if (reason === 'no-session') { setGrowthNotice(t('growthNowNoSession')); return }
|
|
735
|
+
if (reason === 'error' || reason === 'agent-gone' || reason === 'disposed') { setGrowthNotice(t('growthNowError')); return }
|
|
729
736
|
setGrowthNotice(t('growthNowEmpty'))
|
|
730
737
|
})
|
|
731
738
|
.catch((err) => {
|
|
@@ -784,7 +791,7 @@ window.__ModuleLoader__.load({
|
|
|
784
791
|
const value = config ?? {}
|
|
785
792
|
const disabled = saving
|
|
786
793
|
|
|
787
|
-
return React.createElement('div', { style: { padding: '8px 0' }
|
|
794
|
+
return React.createElement('div', { style: { padding: '8px 0' } },
|
|
788
795
|
React.createElement('div', { style: rowStyle },
|
|
789
796
|
React.createElement('div', null,
|
|
790
797
|
React.createElement('div', { style: labelStyle }, t('enabled')),
|
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.13.
|
|
4
|
+
"version": "0.13.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|