dsh-plugin-memory 0.13.0 → 0.13.2

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 CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
4
4
 
5
+ ## [0.13.2] - 2026-10-30
6
+
7
+ ### Fixed(reviewer 复核尾巴 + 结构修正)
8
+
9
+ - **「立即回顾」no-session / error 使用独立文案**:`no-session` → 新增「没有活跃会话可回顾」(`growthNowNoSession`);`error` / `agent-gone` / `disposed` → 新增「回顾失败」(`growthNowError`,**不带悬空冒号**);网络错误仍拼接 `growthNowFailed`(保留冒号并附具体错误)。
10
+ - **焦点环 marker 上移到面板外层 + 恢复三卡独立错误隔离**:`data-dsh-memory-panel` 从表单根 div 移到 `MemorySection` 外层(包住表单 + 健康卡 + 图谱卡),`:focus-visible` 规则真正覆盖整块面板;同时修正 reviewer 指出的 `SectionBoundary` 嵌套——表单 / 健康卡 / 图谱卡仍是三个独立边界,一张卡出错不会带崩整块面板。
11
+ - **结果提示 5 秒自动清除**(补齐 busy / no-session / error 三条新分支同样遵循)。
12
+ - **手动回顾后的节律与投递目标**:手动回顾成功会把自动追忆节律前移(不会紧接着再发一条);多 root 会话时按 `tracker.isActive` 优先投递当前活跃会话。
13
+ - **类型声明**:`types/index.d.ts` 补 `CONTROL_ROUTE_PATH` / `GRAPH_ROUTE_PATH` 常量。
14
+ - **README**:两语言嵌入真实设置面板截图 `assets/settings-panel.png`(含「立即回顾」按钮;`assets/` 不在 `files` 字段,不影响 npm 包体)。
15
+
16
+ ### Notes
17
+
18
+ - **手动「立即回顾」有意绕过每会话追忆上限**(用户显式操作);但插件启用、agent idle、成长回顾开启、有内容、发言权仲裁仍然全部生效。
19
+
20
+ ### Tests
21
+
22
+ - `client-i18n` 新增 2 条:no-session / error 独立文案与去冒号、面板 marker 覆盖范围。
23
+ - 全量单测 **260/260 通过**(0.13.1 基线 258,新增 2 条);`node scripts/memory.mjs --self-test` PASS。
24
+
25
+ ## [0.13.1] - 2026-10-30
26
+
27
+ ### Fixed(面板可用性四连)
28
+
29
+ - **追忆间隔两个输入框缺可访问名**:`recallIntervalMinMinutes` / `recallIntervalMaxMinutes` 的 NumberInput 之前只有视觉标签;现在用新增的 `recallIntervalMin` / `recallIntervalMax` 文案作为 `aria-label`(中英),屏幕阅读器能读出「最短间隔 / 最长间隔」。
30
+ - **语气强度下拉缺可访问名**:`toneIntensity` 的 SelectInput 补 `aria-label`(复用「语气强度」文案)。
31
+ - **`:focus-visible` 焦点环实际从未生效**:原规则带了不存在的 `section` 祖先前缀,而设置面板并不在 `section` 元素内 → 规则永远不命中。改为在面板根 `div` 上打 `data-dsh-memory-panel` 标记,选择器直接命中该 marker(含根自身),键盘焦点环在表单与按钮上真正可见。
32
+ - **「立即回顾」结果提示错乱**:`busy` / `disabled` / `error` 之前全落到「没有新内容」;重写 reason 映射——`busy` → 新增「会话正忙,稍后再试」(`growthNowBusy`,中英)、`disabled` / `growth-disabled` → 「成长回顾已关闭」、`error` / `agent-gone` / `disposed` → 「回顾失败」、`no-content` 才显示「没有新内容」;并让提示 **5 秒后自动消失**。
33
+
34
+ ### Notes
35
+
36
+ - **手动「立即回顾」有意不受每会话追忆上限约束**:它是用户显式操作,不计入自动追忆的 `recallMaxPerSession`;但插件启用、agent idle、成长回顾开启、有内容、发言权仲裁仍然全部生效。
37
+ - 另:手动回顾成功后会把自动追忆节律前移(不会紧接着又发一条);多 root 会话时优先投递到当前活跃会话;`types/index.d.ts` 补 `CONTROL_ROUTE_PATH` / `GRAPH_ROUTE_PATH` 常量声明。
38
+
39
+ ### Tests
40
+
41
+ - `client-i18n` / `growth-now` 补 aria、reason 映射、5 秒自动清除、节律前移与多 root 选择用例。
42
+ - 全量单测 **258/258 通过**(0.13.0 基线 255,新增 3 条);`node scripts/memory.mjs --self-test` PASS。
43
+
5
44
  ## [0.13.0] - 2026-10-30
6
45
 
7
46
  ### Added(兼容声明 + 立即回顾 + 可访问性 + 工程化)
package/README.md CHANGED
@@ -146,7 +146,9 @@ The section is registered as **"Memory"** in the English UI and **「记忆」**
146
146
 
147
147
  Fifteen settings are editable in the "Memory" section of the DSH settings page and take effect **immediately**: `enabled` / `memoryDir` / `autoInject` / `deferUntilUserSpeaks` / `activeSessionOnly` / `registerSkill` / `recallEnabled` / `recallIntervalMinMinutes` / `recallIntervalMaxMinutes` / `recallMaxPerSession` / `proactiveCooldownSeconds` / `toneGuideEnabled` / `toneIntensity` / `growthRecapEnabled` / `growthRecapIntervalDays` — boot injection, the two polite gates, skill registration, proactive recall (including its random interval and cap), speech-right arbitration, the tone section and the weekly growth recap all follow the change at once; switching the store directory scaffolds the new one automatically (when `scaffold: true`). The remaining keys (`bootFiles` / `bootMaxChars` / `bootFileBudgets` / `trackPageAccess` / `scaffold` / `configFile` / `digestNudge*` / `autoCommit*`) only apply at the composition layer and need a restart.
148
148
 
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 / no content / disabled / failed).
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
+
151
+ ![Memory settings panel](assets/settings-panel.png)
150
152
 
151
153
  ### Language
152
154
 
@@ -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 **255 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).
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
@@ -152,7 +152,9 @@ dsh plugin --profile <profile> add dsh-plugin-memory
152
152
 
153
153
  `enabled` / `memoryDir` / `autoInject` / `deferUntilUserSpeaks` / `activeSessionOnly` / `registerSkill` / `recallEnabled` / `recallIntervalMinMinutes` / `recallIntervalMaxMinutes` / `recallMaxPerSession` / `proactiveCooldownSeconds` / `toneGuideEnabled` / `toneIntensity` / `growthRecapEnabled` / `growthRecapIntervalDays` 十五项在 DSH 设置页的「记忆 / Memory」区块中可改(跟随语言),**即时生效**:boot 注入、两道礼貌闸门、技能注册、主动追忆(含随机间隔与次数)、发言权仲裁、语气段与每周成长回顾随修改立即生效;记忆目录切换时自动为新目录初始化脚手架(`scaffold: true` 时)。其余键(`bootFiles` / `bootMaxChars` / `bootFileBudgets` / `trackPageAccess` / `scaffold` / `configFile` / `digestNudge*` / `autoCommit*`)只在 composition 配置层生效,改完需重启。
154
154
 
155
- 旁边还有一个 **「立即回顾」按钮**:它是**控制动作,不是配置项**——让插件立刻发一次成长回顾。仍尊重发言权仲裁(别的插件在说话就让位)、本周没有新内容就不发、即使 `recallEnabled` 关闭也能用,并在面板里给出结果(回顾中 / 已发送 / 让位 / 没有新内容 / 已关闭 / 失败)。
155
+ 旁边还有一个 **「立即回顾」按钮**:它是**控制动作,不是配置项**——让插件立刻发一次成长回顾。仍尊重发言权仲裁(别的插件在说话就让位)、本周没有新内容就不发、即使 `recallEnabled` 关闭也能用,并在面板里给出结果(回顾中 / 已发送 / 让位 / 会话正忙 / 没有新内容 / 已关闭 / 失败),结果提示 5 秒后自动消失。
156
+
157
+ ![记忆设置面板](assets/settings-panel.png)
156
158
 
157
159
  ### 语言 / Language
158
160
 
@@ -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`,当前共 **255 个用例**;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)。
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/client.js CHANGED
@@ -58,6 +58,8 @@ window.__ModuleLoader__.load({
58
58
  recall: '主动追忆',
59
59
  recallHint: '对话空闲时,以第一人称主动提起一件关于你的往事(拟人化),可随时关闭',
60
60
  recallInterval: '追忆间隔(分钟)',
61
+ recallIntervalMin: '最短间隔',
62
+ recallIntervalMax: '最长间隔',
61
63
  recallIntervalHint: '每次随机在最短 ~ 最长之间取一个间隔,避免固定节奏',
62
64
  recallMaxPerSession: '每会话追忆次数',
63
65
  recallMaxPerSessionHint: '一个会话内最多主动追忆几次,避免打扰',
@@ -75,9 +77,12 @@ window.__ModuleLoader__.load({
75
77
  growthNowRunning: '回顾中…',
76
78
  growthNowOk: '已发送成长回顾',
77
79
  growthNowDeferred: '另一插件正在说话,稍后再试',
80
+ growthNowBusy: '会话正忙,稍后再试',
78
81
  growthNowEmpty: '这一周没有可回顾的新内容',
79
82
  growthNowDisabled: '成长回顾已关闭',
80
83
  growthNowFailed: '回顾失败:',
84
+ growthNowError: '回顾失败',
85
+ growthNowNoSession: '没有活跃会话可回顾',
81
86
  minutesPlaceholder: '30',
82
87
  maxMinutesPlaceholder: '240',
83
88
  maxPerSessionPlaceholder: '3',
@@ -163,6 +168,8 @@ window.__ModuleLoader__.load({
163
168
  recall: 'Proactive recall',
164
169
  recallHint: 'When the conversation is idle, bring up a memory about you in first person (personified); can be turned off anytime',
165
170
  recallInterval: 'Recall interval (minutes)',
171
+ recallIntervalMin: 'min interval',
172
+ recallIntervalMax: 'max interval',
166
173
  recallIntervalHint: 'A random interval between min and max each time, so the rhythm never feels fixed',
167
174
  recallMaxPerSession: 'Recalls per session',
168
175
  recallMaxPerSessionHint: 'Maximum proactive recalls in one session, to stay unobtrusive',
@@ -180,9 +187,12 @@ window.__ModuleLoader__.load({
180
187
  growthNowRunning: 'Reviewing…',
181
188
  growthNowOk: 'Growth recap sent',
182
189
  growthNowDeferred: 'Another plugin holds the floor; try again later',
190
+ growthNowBusy: 'Session busy; try again shortly',
183
191
  growthNowEmpty: 'Nothing new to recap this week',
184
192
  growthNowDisabled: 'Weekly recap is off',
185
193
  growthNowFailed: 'Recap failed: ',
194
+ growthNowError: 'Recap failed',
195
+ growthNowNoSession: 'No active session to recap',
186
196
  minutesPlaceholder: '30',
187
197
  maxMinutesPlaceholder: '240',
188
198
  maxPerSessionPlaceholder: '3',
@@ -437,8 +447,10 @@ window.__ModuleLoader__.load({
437
447
  const [gen, setGen] = React.useState(0)
438
448
  const t = useT(props)
439
449
  return React.createElement(LocaleContext.Provider, { value: t },
440
- React.createElement(SectionBoundary, null,
441
- React.createElement(MemoryForm, { onSaved: () => setGen((value) => value + 1) }),
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
+ ),
442
454
  React.createElement(SectionBoundary, { key: gen },
443
455
  React.createElement(InsightsCard),
444
456
  ),
@@ -691,11 +703,17 @@ window.__ModuleLoader__.load({
691
703
  if (typeof document === 'undefined') return undefined
692
704
  const tag = document.createElement('style')
693
705
  tag.setAttribute('data-dsh-memory-focus', '')
694
- tag.textContent = 'section [role="switch"]:focus-visible, section input:focus-visible, section select:focus-visible, section button:focus-visible, section a:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4c8bf5); outline-offset: 2px; }'
706
+ tag.textContent = '[data-dsh-memory-panel] :focus-visible, [data-dsh-memory-panel]:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4c8bf5); outline-offset: 2px; }'
695
707
  document.head.appendChild(tag)
696
708
  return () => tag.remove()
697
709
  }, [])
698
710
 
711
+ React.useEffect(() => {
712
+ if (growthNotice === undefined || typeof setTimeout !== 'function') return undefined
713
+ const timer = setTimeout(() => setGrowthNotice(undefined), 5000)
714
+ return () => clearTimeout(timer)
715
+ }, [growthNotice])
716
+
699
717
  const reviewNow = () => {
700
718
  setGrowthBusy(true)
701
719
  setGrowthNotice(undefined)
@@ -710,8 +728,11 @@ window.__ModuleLoader__.load({
710
728
  if (body.delivered === true) { setGrowthNotice(t('growthNowOk')); return }
711
729
  const reason = body.reason
712
730
  if (reason === 'deferred') { setGrowthNotice(t('growthNowDeferred')); return }
713
- if (reason === 'empty') { setGrowthNotice(t('growthNowEmpty')); return }
714
- if (reason === 'growth-disabled') { setGrowthNotice(t('growthNowDisabled')); return }
731
+ if (reason === 'no-content') { setGrowthNotice(t('growthNowEmpty')); return }
732
+ if (reason === 'disabled' || reason === 'growth-disabled') { setGrowthNotice(t('growthNowDisabled')); return }
733
+ if (reason === 'busy') { setGrowthNotice(t('growthNowBusy')); return }
734
+ if (reason === 'no-session') { setGrowthNotice(t('growthNowNoSession')); return }
735
+ if (reason === 'error' || reason === 'agent-gone' || reason === 'disposed') { setGrowthNotice(t('growthNowError')); return }
715
736
  setGrowthNotice(t('growthNowEmpty'))
716
737
  })
717
738
  .catch((err) => {
@@ -862,6 +883,7 @@ window.__ModuleLoader__.load({
862
883
  ),
863
884
  React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
864
885
  React.createElement(NumberInput, {
886
+ label: t('recallIntervalMin'),
865
887
  value: value.recallIntervalMinMinutes,
866
888
  disabled,
867
889
  placeholder: t('minutesPlaceholder'),
@@ -869,6 +891,7 @@ window.__ModuleLoader__.load({
869
891
  }),
870
892
  React.createElement('span', { style: { color: 'var(--dsw-alias-label-secondary, #999)' } }, '~'),
871
893
  React.createElement(NumberInput, {
894
+ label: t('recallIntervalMax'),
872
895
  value: value.recallIntervalMaxMinutes,
873
896
  disabled,
874
897
  placeholder: t('maxMinutesPlaceholder'),
@@ -907,6 +930,7 @@ window.__ModuleLoader__.load({
907
930
  React.createElement('div', { style: subStyle }, t('toneIntensityHint')),
908
931
  ),
909
932
  React.createElement(SelectInput, {
933
+ label: t('toneIntensity'),
910
934
  value: value.toneIntensity ?? 'low',
911
935
  disabled: disabled || value.toneGuideEnabled === false,
912
936
  options: [
package/lib/index.js CHANGED
@@ -570,7 +570,15 @@ export function apply(ctx, config = {}) {
570
570
  const wanted = typeof body?.sessionId === 'string' ? body.sessionId : undefined
571
571
  const candidates = [...nudges.entries()]
572
572
  .filter(([id]) => wanted === undefined || id === wanted)
573
- .map(([, nudge]) => nudge)
573
+ .map(([id, nudge]) => ({ id, nudge }))
574
+ // Prefer the session the user most recently spoke in; the settings
575
+ // panel has no session id of its own, so without this a recap could
576
+ // land in a background conversation.
577
+ .sort((a, b) => {
578
+ const rank = (entry) => (typeof tracker?.isActive === 'function' && tracker.isActive(entry.id) ? 1 : 0)
579
+ return rank(b) - rank(a)
580
+ })
581
+ .map((entry) => entry.nudge)
574
582
  if (candidates.length === 0) {
575
583
  res.writeHead(200, { 'content-type': 'application/json; charset=utf-8' })
576
584
  res.end(JSON.stringify({ ok: true, delivered: false, reason: 'no-session' }))
@@ -246,6 +246,11 @@ export class RecallNudge {
246
246
  }
247
247
  this.agent.followup(buildGrowthRecapNudgeMessage(recap))
248
248
  this.recalls += 1
249
+ // A manual recap counts as this cycle's proactive message: push the
250
+ // automatic cadence forward so the user never gets two proactive
251
+ // messages back to back. (The per-session recall cap is intentionally
252
+ // NOT consulted here — the user explicitly asked for this one.)
253
+ this.nextRecallAt = now + randomIntervalMs(config.minMinutes, config.maxMinutes)
249
254
  return { delivered: true, reason: 'delivered' }
250
255
  } catch (error) {
251
256
  this.logger?.warn?.(`memory: growth-now failed: ${error instanceof Error ? error.message : String(error)}`)
@@ -88,6 +88,12 @@ export const CONFIG_ROUTE_PATH: '/api/memory/config'
88
88
  /** Read-only HTTP route serving the memory-health dashboard payload. */
89
89
  export const INSIGHTS_ROUTE_PATH: '/api/memory/insights'
90
90
 
91
+ /** Read-only HTTP route serving the memory graph payload. */
92
+ export const GRAPH_ROUTE_PATH: '/api/memory/graph'
93
+
94
+ /** Manual control route (`growth-now`): deliver one recap on demand. */
95
+ export const CONTROL_ROUTE_PATH: '/api/memory/control'
96
+
91
97
  /** User-editable settings (composition config is the base layer). */
92
98
  export interface MemorySettings {
93
99
  enabled?: boolean
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.0",
4
+ "version": "0.13.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",