dsh-memoir 0.8.2 → 0.9.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/README.en.md +58 -14
- package/README.md +59 -15
- package/SESSION_RECOVERY.md +70 -0
- package/cordis.patch.yml +4 -4
- package/lib/activity.d.ts +10 -1
- package/lib/activity.js +21 -4
- package/lib/autodistill.js +8 -3
- package/lib/client.js +258 -113
- package/lib/client.js.map +4 -4
- package/lib/i18n-de.d.ts +3 -0
- package/lib/i18n-de.js +98 -0
- package/lib/i18n-ru.d.ts +3 -0
- package/lib/i18n-ru.js +96 -0
- package/lib/i18n.d.ts +4 -5
- package/lib/i18n.js +9 -8
- package/lib/index.js +14 -5
- package/lib/languages.d.ts +6 -0
- package/lib/languages.js +9 -0
- package/lib/retrieval.d.ts +1 -1
- package/lib/retrieval.js +4 -3
- package/lib/routes.d.ts +2 -1
- package/lib/selector.js +1 -1
- package/lib/settings.js +2 -1
- package/lib/snapshot-store.d.ts +2 -1
- package/lib/snapshot-store.js +2 -1
- package/lib/tools.d.ts +1 -1
- package/lib/tools.js +12 -5
- package/package.json +30 -22
- package/scripts/repair-session-receipts.mjs +498 -0
package/README.en.md
CHANGED
|
@@ -11,14 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
No embeddings, vector database, or cloud memory service. The npm package has zero bundled runtime dependencies; DSH and Zod 4 peers are supplied by the host environment; Zod validates session projections and is not bundled.
|
|
13
13
|
|
|
14
|
+
> [!WARNING]
|
|
15
|
+
> **0.9.1 fixes session recovery issue #14 affecting receipts written by 0.8.1–0.9.0.** Upgrading prevents new invalid receipts but does not rewrite old logs. The npm package includes `dsh-memoir-repair`. If an old session still fails, follow the [recovery guide](./SESSION_RECOVERY.md#english): audit first, stop every host and back up, then explicitly apply repair. Preserve the logs; do not downgrade their format. Stop old plugin writes before recovery; disabling auto-distillation alone does not stop manual write tools.
|
|
16
|
+
> The fix covers official DSH `0.2.0-rc.1` / `0.2.0-rc.2`; upgrading DSH alone does not fix the old plugin or repair affected logs.
|
|
17
|
+
|
|
14
18
|
> [!IMPORTANT]
|
|
15
|
-
> **0.
|
|
19
|
+
> **0.9.1 requires DSH `>=0.2.0-rc.1 <0.3.0-0`**, verified with official `0.2.0-rc.1` / `rc.2` (not an unqualified final 0.2.0). Retains the visible guide, native settings, four agent languages, separate distillation turns and frozen snapshots. **The DSH 0.1.7 line is Memoir `0.8.2`, but it remains affected by #14; upgrade the host before installing this 0.9.1 fix.**
|
|
16
20
|
>
|
|
17
21
|
> `dsh-memoir@0.7.1` fixes lost session snapshots after restart or RAM eviction (#10), supporting DSH **0.1.5-rc.1 / rc.2**. It requires `>=0.1.5-rc.1 <0.1.6-0`; check your host first. Keep `0.6.2` on DSH 0.1.2, or `0.5.6` on DSH 0.1.1-rc.2; those older lines do not include this fix.
|
|
18
22
|
|
|
19
23
|
```bash
|
|
20
|
-
npm install --global @deepseek-ai/dsh@0.
|
|
21
|
-
dsh plugin --profile web add dsh-memoir@0.
|
|
24
|
+
npm install --global @deepseek-ai/dsh@0.2.0-rc.2
|
|
25
|
+
dsh plugin --profile web add dsh-memoir@0.9.1
|
|
22
26
|
```
|
|
23
27
|
|
|
24
28
|
Restart `dsh web`. Memory remains local and is not automatically deleted when the plugin is updated or removed.
|
|
@@ -37,7 +41,11 @@ Restart `dsh web`. Memory remains local and is not automatically deleted when th
|
|
|
37
41
|
|
|
38
42
|
It fits personal and local development workflows where a new agent should continue understanding a project. It is not a raw chat backup, multi-user cloud sync service, or vector-semantic knowledge base.
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
### UI preview
|
|
45
|
+
|
|
46
|
+
**0.9.0 component preview with demonstration data.** Plugin identity, GitHub, documentation and memory settings stay at the top, before long lists.
|
|
47
|
+
|
|
48
|
+

|
|
41
49
|
|
|
42
50
|
## How it works
|
|
43
51
|
|
|
@@ -100,7 +108,9 @@ Automatic distillation is an observable agent turn-end reminder, not silent back
|
|
|
100
108
|
|
|
101
109
|
`autoDistillEvery`, `autoDistillCooldownMin`, and `autoDistillMinTools` are AND conditions isolated per agent. Idle, aborted, subagent, and already-recorded turns do not trigger. Cooldown advances only after a successful reminder. All cadence parameters are live-editable in the GUI.
|
|
102
110
|
|
|
103
|
-
`language` independently controls agent-visible tool descriptions and parameters, the distillation prompt, tool results, Hot Memory / `PROJECT_MEMORY.md` headings, and validation or governance errors.
|
|
111
|
+
`language` independently controls agent-visible tool descriptions and parameters, the distillation prompt, tool results, Hot Memory / `PROJECT_MEMORY.md` headings, and validation or governance errors. Released 0.8.2 supports `zh` / `en`, defaulting to `zh`. Tool descriptions and subsequent prompts update live without restarting DSH.
|
|
112
|
+
|
|
113
|
+
**0.9.0 adds `de` (Deutsch) and `ru` (Русский)**, explicitly selected in Memory settings rather than inferred from the agent or user messages. Tool names, parameter keys and enums remain unchanged. The GUI remains Chinese/English and existing memory content is not automatically translated. Switching language alone does not rewrite JSON or Markdown; projection headings use the current language on subsequent normal writes. Each of the four languages has its own frozen-snapshot namespace; switching back reuses the previous baseline. Select `zh` or `en` before downgrading to 0.8.2.
|
|
104
114
|
|
|
105
115
|
## Local recall and caching
|
|
106
116
|
|
|
@@ -111,11 +121,13 @@ Automatic distillation is an observable agent turn-end reminder, not silent back
|
|
|
111
121
|
- epoch-aware LRU query cache with one-hour time buckets; `limit` and output detail stay outside the key so output shapes share rankings;
|
|
112
122
|
- the GUI and `memoir_read` use the same RetrievalEngine and expose hits, misses, evictions, hit rate, and last-query latency.
|
|
113
123
|
|
|
124
|
+
0.9.0 extends word splitting to Unicode letters, combining marks and numbers with NFC normalization, preserving German umlauts and Russian Cyrillic. Original content and existing Chinese/code-identifier rules are preserved. This remains lexical retrieval, not automatic translation, stemming or cross-language semantic search.
|
|
125
|
+
|
|
114
126
|
Top-5 recall on the fixed quality set is 100%; the repository gate requires at least 90%.
|
|
115
127
|
|
|
116
128
|
## Web GUI
|
|
117
129
|
|
|
118
|
-
Installing into a DSH
|
|
130
|
+
Installing into a compatible DSH `web` profile registers a native Memory Conversation view and Memory Settings section through official slots. The DSH shell owns layout, navigation, and unload lifecycle; Memoir no longer takes over the legacy sidebar through DOM selectors.
|
|
119
131
|
|
|
120
132
|
- Project memory and all-project global memory, with project groups collapsed by default and complete lifecycle totals;
|
|
121
133
|
- status, section, and keyword filters with BM25 scores;
|
|
@@ -130,7 +142,22 @@ Installing into a DSH-alpha `web` profile registers a native Memory Conversation
|
|
|
130
142
|
- live GUI Chinese/English switching from `<html lang>`, with a separate `language` setting for agent-facing copy.
|
|
131
143
|
|
|
132
144
|
<details>
|
|
133
|
-
<summary>
|
|
145
|
+
<summary>0.9.0 UI previews: native plugin configuration and language settings</summary>
|
|
146
|
+
|
|
147
|
+
The native plugin detail page reuses Memory settings directly, without opening the memory list. Shown below is the native plugin detail page in DSH 0.2.0-rc.1.
|
|
148
|
+
|
|
149
|
+

|
|
150
|
+
|
|
151
|
+
Choose German agent-facing copy independently of the English GUI; settings and memory browsing scroll separately.
|
|
152
|
+
|
|
153
|
+

|
|
154
|
+
|
|
155
|
+
</details>
|
|
156
|
+
|
|
157
|
+
<details>
|
|
158
|
+
<summary>GUI screenshots from previous releases</summary>
|
|
159
|
+
|
|
160
|
+

|
|
134
161
|
|
|
135
162
|

|
|
136
163
|
|
|
@@ -156,25 +183,26 @@ Installing into a DSH-alpha `web` profile registers a native Memory Conversation
|
|
|
156
183
|
|
|
157
184
|
| Channel | DSH baseline | Installation | Status |
|
|
158
185
|
| --- | --- | --- | --- |
|
|
159
|
-
| npm `latest` (`0.
|
|
186
|
+
| npm `latest` (`0.9.1`) | `>=0.2.0-rc.1 <0.3.0-0` | `dsh plugin --profile web add dsh-memoir@0.9.1` | Tested on 0.2.0-rc.1 / rc.2; fixes #14 |
|
|
187
|
+
| pinned npm `0.8.2` | `>=0.1.7-rc.1 <0.1.8-0` | `dsh plugin --profile web add dsh-memoir@0.8.2` | Legacy 0.1.7 line; still affected by #14 |
|
|
160
188
|
| pinned npm `0.7.1` | `>=0.1.5-rc.1 <0.1.6-0` | `dsh plugin --profile web add dsh-memoir@0.7.1` | Legacy 0.1.5 line |
|
|
161
189
|
| pinned npm `0.6.2` | `>=0.1.2-alpha.2 <0.1.3` | `dsh plugin --profile web add dsh-memoir@0.6.2` | Legacy 0.1.2 line |
|
|
162
190
|
| pinned npm `0.5.6` | `0.1.1-rc.2` | `dsh plugin --profile web add dsh-memoir@0.5.6` | rc2 compatibility line |
|
|
163
|
-
| Source `v0.
|
|
191
|
+
| Source `v0.9.1` | `>=0.2.0-rc.1 <0.3.0-0` | local build + `link:` | Development; not compatible with legacy 0.1.x |
|
|
164
192
|
|
|
165
193
|
Node.js `^22.19.0 || >=24.0.0` is required. 0.7.1 keeps the native `conversation.view` / `settings.section` slots and `snapshotEvents()`. DSH 0.1.5 uses Session log V3, independent of Memoir store v4 / settings v3. Back up DSH_HOME before upgrading DSH; migrated sessions are not guaranteed readable by older hosts. This Memoir release neither migrates nor resets memory and retains frozen session snapshots without enabling new dynamic-prompt behavior.
|
|
166
194
|
|
|
167
195
|
<details>
|
|
168
196
|
<summary>Install from source</summary>
|
|
169
197
|
|
|
170
|
-
|
|
198
|
+
0.9.1 source (DSH 0.2.0-rc.1 / rc.2):
|
|
171
199
|
|
|
172
200
|
```bash
|
|
173
|
-
git clone --branch v0.
|
|
201
|
+
git clone --branch v0.9.1 https://github.com/Qinling-Melon-Farmers/dsh-memoir.git
|
|
174
202
|
cd dsh-memoir
|
|
175
203
|
pnpm install --frozen-lockfile
|
|
176
204
|
pnpm run build
|
|
177
|
-
npm install --global @deepseek-ai/dsh@0.
|
|
205
|
+
npm install --global @deepseek-ai/dsh@0.2.0-rc.2
|
|
178
206
|
dsh plugin --profile web add "link:/absolute/path/dsh-memoir"
|
|
179
207
|
```
|
|
180
208
|
|
|
@@ -184,11 +212,27 @@ dsh plugin --profile web add "link:/absolute/path/dsh-memoir"
|
|
|
184
212
|
|
|
185
213
|
## Native sidebar and help
|
|
186
214
|
|
|
215
|
+
**Released 0.8.2:**
|
|
216
|
+
|
|
187
217
|
- Existing Conversation and Settings entries stay unchanged. The right-sidebar guide now offers Memory for browsing project memory, Hot Memory and diagnostics alongside chat; it never opens automatically or replaces another panel.
|
|
188
218
|
- Each sidebar instance follows its own session workspace and reuses the same data layer, with independent active surfaces and scroll state. Conversation and Settings remain available when the optional sidebar service is absent.
|
|
189
219
|
- Under Memory settings, the collapsed About & help card shows the plugin version, host range, SDK baseline, maintainer, repository, bilingual documentation, releases and issue links. The plugin repository is explicitly distinct from the current workspace.
|
|
190
220
|
- No background update requests, workspace Git-remote inspection or path/memory uploads. Use the host plugin manager to update, after checking the target package’s DSH requirements and prerelease channel. The panel does not auto-upgrade.
|
|
191
221
|
|
|
222
|
+
**0.9.0:**
|
|
223
|
+
|
|
224
|
+
- Plugin identity, version, GitHub project, documentation and Open memory settings move to the top of Conversation, Settings and sidebar panels, before any long memory or configuration list. Detailed compatibility information stays collapsed; no forced navigation or Star prompt.
|
|
225
|
+
- Open `dsh-memoir` on the native Plugins page to use the same memory-settings form. No duplicate configuration store or registration pretending to be an official plugin; existing entries still work without this host page.
|
|
226
|
+
- Develop and validate against official npm `0.2.0-rc.1`. Check the host version before installation. Memoir 0.8.2 for DSH 0.1.7 is also affected by #14; back up and upgrade both host and plugin, following the compatibility and recovery warning above.
|
|
227
|
+
|
|
228
|
+
## Offline release highlights
|
|
229
|
+
|
|
230
|
+
The first Memory Conversation opening shows the 0.9.1 write fix and old-log recovery boundary without blocking chat. Choose “Got it” to stop automatic display for this version in the same browser origin. Reopen anytime from “About & help → View release highlights”. Settings and sidebar panels never open the notice automatically. The image below is explicitly retained as a historical 0.9.0 preview.
|
|
231
|
+
|
|
232
|
+
The Chinese/English notice is offline: no network requests, uploads, memory changes or conversation edits. Only the acknowledged version is stored locally by the UI. If storage is unavailable, acknowledgment lasts for the current page; Web/Desktop and different origins are not guaranteed to share it.
|
|
233
|
+
|
|
234
|
+

|
|
235
|
+
|
|
192
236
|
## Storage, privacy, and security boundaries
|
|
193
237
|
|
|
194
238
|
```text
|
|
@@ -213,7 +257,7 @@ Every field below can be set in the memoir `config` row in `cordis.patch.yml`. E
|
|
|
213
257
|
| Field | Default | Purpose |
|
|
214
258
|
| --- | ---: | --- |
|
|
215
259
|
| `enabled` | `true` | master switch for tools, routes, and prompt injection |
|
|
216
|
-
| `language` | `zh` | agent-facing
|
|
260
|
+
| `language` | `zh` | agent-facing copy; `zh` / `en` in 0.8.2, plus `de` / `ru` in 0.9.0; independent of GUI language |
|
|
217
261
|
| `announceToAgent` | `true` | announce memory tools and rules to the agent |
|
|
218
262
|
| `autoDistill` | `true` | enable top-level worked-turn reminders |
|
|
219
263
|
| `autoDistillEvery` | `1` | remind at most once per N worked turns |
|
|
@@ -269,6 +313,6 @@ pnpm test
|
|
|
269
313
|
npm run bench
|
|
270
314
|
```
|
|
271
315
|
|
|
272
|
-
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before submitting changes. See [CHANGELOG.md](./CHANGELOG.md) for version history. Formal packages are published by the tag workflow through npm OIDC. The current version is [v0.
|
|
316
|
+
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before submitting changes. See [CHANGELOG.md](./CHANGELOG.md) for version history. Formal packages are published by the tag workflow through npm OIDC. The current version is [v0.9.1](https://github.com/Qinling-Melon-Farmers/dsh-memoir/releases/tag/v0.9.1), targeting DSH 0.2.0-rc.1 / rc.2. See the compatibility table above for legacy lines and their risks.
|
|
273
317
|
|
|
274
318
|
Apache-2.0
|
package/README.md
CHANGED
|
@@ -10,14 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
无需 embedding、向量数据库或云端记忆服务;npm 包零捆绑运行时依赖,DSH 与 Zod 4 peer 由宿主环境提供;Zod 用于验证宿主会话投影,不捆绑进插件。
|
|
12
12
|
|
|
13
|
+
> [!WARNING]
|
|
14
|
+
> **0.9.1 修复会话恢复问题 #14:0.8.1–0.9.0 写入的旧回执可能导致会话重新打开失败。** 升级阻止新增异常,但不自动重写旧日志;npm 包已内置 `dsh-memoir-repair` 命令。旧会话仍打不开时,按[恢复说明](./SESSION_RECOVERY.md)先只读检查、停机备份后再显式恢复;不要删除日志或降级数据格式。恢复前停止旧插件写入,仅关闭自动蒸馏不能阻止手动工具写入。
|
|
15
|
+
> 修复已覆盖官方 DSH `0.2.0-rc.1` / `0.2.0-rc.2`;仅升级 DSH 不会修复旧插件或已有异常日志。
|
|
16
|
+
|
|
13
17
|
> [!IMPORTANT]
|
|
14
|
-
> **0.
|
|
18
|
+
> **0.9.1 要求 DSH `>=0.2.0-rc.1 <0.3.0-0`**,已验证官方 `0.2.0-rc.1` / `rc.2`(不是无后缀正式 0.2.0)。保留首屏导引、原生设置、四种 Agent 语言、独立蒸馏回合与冻结快照。**DSH 0.1.7 兼容线为 `0.8.2`,但仍受 #14 影响;使用本修复须先升级宿主,再安装 0.9.1。**
|
|
15
19
|
>
|
|
16
20
|
> `dsh-memoir@0.7.1` 修复重启和内存淘汰后旧会话快照丢失(#10),支持 DSH **0.1.5-rc.1 / rc.2**。要求 `>=0.1.5-rc.1 <0.1.6-0`;请先核对宿主版本。旧 DSH 0.1.2 用户固定使用 `0.6.2`,0.1.1-rc.2 用户固定使用 `0.5.6`;这些旧版未包含本次修复。
|
|
17
21
|
|
|
18
22
|
```bash
|
|
19
|
-
npm install --global @deepseek-ai/dsh@0.
|
|
20
|
-
dsh plugin --profile web add dsh-memoir@0.
|
|
23
|
+
npm install --global @deepseek-ai/dsh@0.2.0-rc.2
|
|
24
|
+
dsh plugin --profile web add dsh-memoir@0.9.1
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
重启 `dsh web` 即可。记忆保存在本机,不会随插件升级或卸载自动删除。
|
|
@@ -32,11 +36,15 @@ dsh plugin --profile web add dsh-memoir@0.8.2
|
|
|
32
36
|
| BM25 排序召回 | 中文短语、英文关键词、代码标识符和路径都可检索;跨项目 Top-K 与查询 LRU 缓存共用同一引擎 |
|
|
33
37
|
| 可治理的记忆 | 重要度、置顶、标签、归档、恢复和 supersede 生命周期;相似写入必须显式更新、替代或并存 |
|
|
34
38
|
| 可追溯 | Agent 写入记录可信 session/turn 来源,Web 面板可复制并尽力跳回原会话 |
|
|
35
|
-
| 完整 Web GUI | 中英双语项目/全局浏览、排序搜索、编辑、Hot Memory 预览、诊断和实时设置;可独立选择 Agent
|
|
39
|
+
| 完整 Web GUI | 中英双语项目/全局浏览、排序搜索、编辑、Hot Memory 预览、诊断和实时设置;可独立选择 Agent 侧中文、英文、德语或俄语 |
|
|
36
40
|
|
|
37
41
|
适合需要“新 Agent 接手时继续理解项目”的个人或本地开发工作流。它不是原始聊天记录备份、多人云同步服务或向量语义知识库。
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
### 界面预览
|
|
44
|
+
|
|
45
|
+
**0.9.0 组件界面预览,使用演示数据。** 顶部常驻插件身份、GitHub、文档与记忆设置入口,无需滚过长列表。
|
|
46
|
+
|
|
47
|
+

|
|
40
48
|
|
|
41
49
|
## 工作原理
|
|
42
50
|
|
|
@@ -99,7 +107,9 @@ memoir_record / memoir_update
|
|
|
99
107
|
|
|
100
108
|
`autoDistillEvery`、`autoDistillCooldownMin`、`autoDistillMinTools` 三个条件按 AND 判定并按 Agent 隔离。idle、aborted、subagent 和已成功保存记忆的回合不会触发;冷却只在提醒成功后更新。所有频率参数都可在 GUI 中即时修改。
|
|
101
109
|
|
|
102
|
-
`language` 独立控制 Agent 可见的工具描述、参数说明、蒸馏提示、工具结果、Hot Memory / `PROJECT_MEMORY.md`
|
|
110
|
+
`language` 独立控制 Agent 可见的工具描述、参数说明、蒸馏提示、工具结果、Hot Memory / `PROJECT_MEMORY.md` 标题以及校验与治理错误。已发布 0.8.2 支持 `zh` / `en`,默认 `zh`;切换后工具描述与后续提示即时更新,不要求重启 DSH。
|
|
111
|
+
|
|
112
|
+
**0.9.0新增 `de`(Deutsch)和 `ru`(Русский)**,可在记忆设置中明确选择;不是根据 Agent 或用户消息自动猜测语言。工具名、参数名与枚举不变,GUI 仍为中英双语,既有记忆正文不会自动翻译。切换语言本身不重写 JSON 或 Markdown;后续正常写入时投影标题使用当前语言。四种语言各有独立冻结快照空间,切回原语言可继续复用旧基线。降级到 0.8.2 前请先改回 `zh` 或 `en`。
|
|
103
113
|
|
|
104
114
|
## 本地召回与缓存
|
|
105
115
|
|
|
@@ -110,11 +120,13 @@ memoir_record / memoir_update
|
|
|
110
120
|
- epoch 感知、1 小时时间桶的 LRU 查询缓存;`limit` 与输出详略不进入缓存键,因此不同输出形态共享排序结果;
|
|
111
121
|
- GUI 和 `memoir_read` 使用同一个 RetrievalEngine,并暴露 hits、misses、evictions、命中率与最近查询耗时。
|
|
112
122
|
|
|
123
|
+
0.9.0将词项分割扩展为 Unicode 字母/组合标记/数字并做 NFC 归一化,保留德语变音字符与俄语西里尔字母;不修改原始正文,保留中文和代码标识符规则。它仍是词项检索,不提供自动翻译、词形还原或跨语言语义搜索。
|
|
124
|
+
|
|
113
125
|
固定质量集的 Top-5 命中率为 100%,仓库门禁要求不低于 90%。
|
|
114
126
|
|
|
115
127
|
## Web GUI
|
|
116
128
|
|
|
117
|
-
|
|
129
|
+
安装到兼容 DSH 的 `web` profile 后,Memoir 通过官方 slot 注册原生「记忆」会话视图和「记忆」Settings 分区;布局、导航与卸载生命周期均由 DSH shell 管理,不再通过 DOM 选择器接管旧侧边栏。
|
|
118
130
|
|
|
119
131
|
- 项目记忆与所有项目的全局记忆;全局视图按项目默认折叠并显示完整生命周期计数;
|
|
120
132
|
- 状态、分类和关键词筛选,BM25 分数展示;
|
|
@@ -129,7 +141,22 @@ memoir_record / memoir_update
|
|
|
129
141
|
- GUI 跟随 `<html lang>` 在中文和英文间即时切换;Agent 侧语言由独立的 `language` 设置控制。
|
|
130
142
|
|
|
131
143
|
<details>
|
|
132
|
-
<summary
|
|
144
|
+
<summary>0.9.0 界面预览:原生插件配置入口与多语言设置</summary>
|
|
145
|
+
|
|
146
|
+
原生插件详情页直接复用记忆设置,不必先打开记忆列表。下图为 DSH 0.2.0-rc.1 的原生插件详情页。
|
|
147
|
+
|
|
148
|
+

|
|
149
|
+
|
|
150
|
+
英文 GUI 中也可独立选择德语 Agent 文案;设置与记忆浏览分别滚动。
|
|
151
|
+
|
|
152
|
+

|
|
153
|
+
|
|
154
|
+
</details>
|
|
155
|
+
|
|
156
|
+
<details>
|
|
157
|
+
<summary>已发布历史版本 GUI 截图</summary>
|
|
158
|
+
|
|
159
|
+

|
|
133
160
|
|
|
134
161
|

|
|
135
162
|
|
|
@@ -155,25 +182,26 @@ memoir_record / memoir_update
|
|
|
155
182
|
|
|
156
183
|
| 渠道 | DSH 基线 | 安装方式 | 状态 |
|
|
157
184
|
| --- | --- | --- | --- |
|
|
158
|
-
| npm `latest`(`0.
|
|
185
|
+
| npm `latest`(`0.9.1`) | `>=0.2.0-rc.1 <0.3.0-0` | `dsh plugin --profile web add dsh-memoir@0.9.1` | 实测 0.2.0-rc.1 / rc.2;修复 #14 |
|
|
186
|
+
| npm 固定版 `0.8.2` | `>=0.1.7-rc.1 <0.1.8-0` | `dsh plugin --profile web add dsh-memoir@0.8.2` | 旧 0.1.7 兼容线,仍受 #14 影响 |
|
|
159
187
|
| npm 固定版 `0.7.1` | `>=0.1.5-rc.1 <0.1.6-0` | `dsh plugin --profile web add dsh-memoir@0.7.1` | 旧 0.1.5 维护线 |
|
|
160
188
|
| npm 固定版 `0.6.2` | `>=0.1.2-alpha.2 <0.1.3` | `dsh plugin --profile web add dsh-memoir@0.6.2` | 旧 0.1.2 兼容线 |
|
|
161
189
|
| npm 固定版 `0.5.6` | `0.1.1-rc.2` | `dsh plugin --profile web add dsh-memoir@0.5.6` | rc2 兼容线 |
|
|
162
|
-
| 源码 `v0.
|
|
190
|
+
| 源码 `v0.9.1` | `>=0.2.0-rc.1 <0.3.0-0` | 本地构建 + `link:` | 开发调试,不兼容旧 0.1.x |
|
|
163
191
|
|
|
164
192
|
需要 Node.js `^22.19.0 || >=24.0.0`。0.7.1 继续使用原生 `conversation.view` / `settings.section` 与 `snapshotEvents()`。DSH 0.1.5 的会话日志升级至 V3;其迁移与 Memoir 的 store v4 / settings v3 是独立格式。升级 DSH 前备份 DSH_HOME,迁移后的 DSH 会话不能承诺被旧宿主读取。Memoir 本次不迁移或清空记忆,也不启用新动态提示词行为;既有会话快照语义保持不变。
|
|
165
193
|
|
|
166
194
|
<details>
|
|
167
195
|
<summary>从源码安装</summary>
|
|
168
196
|
|
|
169
|
-
|
|
197
|
+
0.9.1 源码(DSH 0.2.0-rc.1 / rc.2):
|
|
170
198
|
|
|
171
199
|
```bash
|
|
172
|
-
git clone --branch v0.
|
|
200
|
+
git clone --branch v0.9.1 https://github.com/Qinling-Melon-Farmers/dsh-memoir.git
|
|
173
201
|
cd dsh-memoir
|
|
174
202
|
pnpm install --frozen-lockfile
|
|
175
203
|
pnpm run build
|
|
176
|
-
npm install --global @deepseek-ai/dsh@0.
|
|
204
|
+
npm install --global @deepseek-ai/dsh@0.2.0-rc.2
|
|
177
205
|
dsh plugin --profile web add "link:/absolute/path/dsh-memoir"
|
|
178
206
|
```
|
|
179
207
|
|
|
@@ -183,11 +211,27 @@ dsh plugin --profile web add "link:/absolute/path/dsh-memoir"
|
|
|
183
211
|
|
|
184
212
|
## 原生侧栏与帮助入口
|
|
185
213
|
|
|
214
|
+
**已发布 0.8.2:**
|
|
215
|
+
|
|
186
216
|
- 会话“记忆”和设置页入口保持不变;右侧栏引导页新增“记忆”,可边对话边看项目记忆、Hot Memory 和诊断,不会自动打开或抢占其它面板。
|
|
187
217
|
- 侧栏读取所属会话的工作区,复用同一数据层;每个实例独立保存当前功能区和滚动状态。缺少侧栏服务时,会话页和设置页仍可用。
|
|
188
218
|
- 任一记忆面板的“记忆设置”底部提供默认折叠的“关于与帮助”:显示插件版本、宿主范围、SDK 基线、维护者,以及仓库、双语文档、Release、反馈链接。插件仓库与当前工作区明确区分。
|
|
189
219
|
- 关于区不后台联网、不探测工作区 Git remote、不上传路径或记忆内容。更新通过宿主插件管理器操作,先核对目标包要求的 DSH 版本和预发布通道;本面板不自动升级。
|
|
190
220
|
|
|
221
|
+
**0.9.0:**
|
|
222
|
+
|
|
223
|
+
- 插件名、版本、GitHub 项目、文档和“打开记忆设置”前移到面板顶部,打开会话、设置或右侧记忆面板即可看到,无须先滚过记忆或设置列表。详细兼容信息保持折叠,不强制跳转或请求 Star。
|
|
224
|
+
- 原生“插件”页面中打开 `dsh-memoir` 详情,即可使用同一套记忆设置表单;不另建一份配置,不向官方插件分组冒充注册。宿主没有此页面时,原有记忆入口仍可用。
|
|
225
|
+
- 开发 SDK 与兼容性基线升级到官方 npm `0.2.0-rc.1`;安装前核对宿主版本。旧 DSH 0.1.7 的 Memoir 0.8.2 也受 #14 影响,建议备份后一起升级宿主和插件,参见顶部兼容与恢复提示。
|
|
226
|
+
|
|
227
|
+
## 离线更新公告
|
|
228
|
+
|
|
229
|
+
首次打开记忆会话页时展示 0.9.1 更新摘要,提示会话写入修复与旧日志恢复边界,不阻塞对话;点击“知道了”后,同一浏览器 origin 的本版本不再自动展示。“关于与帮助 → 查看本版更新”可随时重看。设置页和右侧栏不会自动弹出公告。下图保留为已标注版本的 0.9.0 历史预览。
|
|
230
|
+
|
|
231
|
+
公告随包内置、中英双语,不联网、不上传信息、不改变记忆或对话。仅在 UI 本地存储记录已确认版本;存储不可用时退化为当前页面去重,Web/桌面端或不同 origin 的确认状态不承诺同步。
|
|
232
|
+
|
|
233
|
+

|
|
234
|
+
|
|
191
235
|
## 存储、隐私与安全边界
|
|
192
236
|
|
|
193
237
|
```text
|
|
@@ -212,7 +256,7 @@ dsh plugin --profile web add "link:/absolute/path/dsh-memoir"
|
|
|
212
256
|
| 字段 | 默认值 | 作用 |
|
|
213
257
|
| --- | ---: | --- |
|
|
214
258
|
| `enabled` | `true` | 工具、路由和 prompt 注入总开关 |
|
|
215
|
-
| `language` | `zh` | Agent
|
|
259
|
+
| `language` | `zh` | Agent 文案语言;0.8.2 为 `zh` / `en`,0.9.0 新增 `de` / `ru`;与 GUI 语言独立 |
|
|
216
260
|
| `announceToAgent` | `true` | 向 Agent 公告记忆工具与规则 |
|
|
217
261
|
| `autoDistill` | `true` | 启用顶层有效回合收尾提醒 |
|
|
218
262
|
| `autoDistillEvery` | `1` | 每 N 个 worked turn 最多提醒一次 |
|
|
@@ -268,6 +312,6 @@ pnpm test
|
|
|
268
312
|
npm run bench
|
|
269
313
|
```
|
|
270
314
|
|
|
271
|
-
提交前请阅读 [CONTRIBUTING.md](./CONTRIBUTING.md)。版本变化见 [CHANGELOG.md](./CHANGELOG.md),正式包由 tag 工作流通过 npm OIDC 发布。当前版本是 [v0.
|
|
315
|
+
提交前请阅读 [CONTRIBUTING.md](./CONTRIBUTING.md)。版本变化见 [CHANGELOG.md](./CHANGELOG.md),正式包由 tag 工作流通过 npm OIDC 发布。当前版本是 [v0.9.1](https://github.com/Qinling-Melon-Farmers/dsh-memoir/releases/tag/v0.9.1),面向 DSH 0.2.0-rc.1 / rc.2;旧兼容线与风险见上方兼容性表。
|
|
272
316
|
|
|
273
317
|
Apache-2.0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# 会话恢复 / Session recovery (#14)
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
### 原因与边界
|
|
6
|
+
|
|
7
|
+
Memoir 0.8.1–0.9.0 的实际写入回执使用了没有 `ignorable` 标记的 `dsh-memoir/written` 自定义事件。DSH 能追加它,但重新读取持久化日志时会拒绝整份历史。这不等于会话正文或 `dsh-memoir.json` 记忆数据已被删除。
|
|
8
|
+
|
|
9
|
+
**0.9.1 同时包含预防修复和独立恢复工具**。新版不再生成该事件,直接工具调用使用官方 `tool/result.meta`;升级插件不会自动重写旧日志。**恢复前先停止受影响插件的写入并升级至 0.9.1**,否则旧版仍会生成坏回执;只关闭自动蒸馏不够,手动 `memoir_record` / `memoir_update` 也会触发。
|
|
10
|
+
|
|
11
|
+
### 只读检查
|
|
12
|
+
|
|
13
|
+
无需 Git 或源码安装:npm 包已包含 `dsh-memoir-repair` 命令、原始脚本和本文。用 Node 24,传入官方 DSH 安装目录和**一个具体会话文件**,不要传记忆 JSON、目录或通配符:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm exec --yes --package=dsh-memoir@0.9.1 -- dsh-memoir-repair --dsh-package "/path/to/node_modules/@deepseek-ai/dsh" "/path/to/session.v4.jsonl.zstd"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- Windows 全局路径可用 `npm root -g` 查出,再附加 `@deepseek-ai/dsh`;WSL 使用自己的 Linux 安装。桌面内置依赖不可直接供 Node 加载时,使用单独安装的官方 npm DSH 作为校验器,不修改桌面文件。
|
|
20
|
+
- 已审计的校验器/锁协议为官方 JSONL backend `0.2.0-rc.1` / `0.2.0-rc.2`,其它版本拒绝执行。它可以检查符合该校验器的原生 v4 旧日志,不运行宿主、不迁移历史格式。
|
|
21
|
+
- 支持 `session.v4.jsonl` / `session.v4.jsonl.zstd`,存储和解压后均最多 128 MiB;Zstandard 每帧必须带校验和。日志截断、损坏、其它未知且不可忽略事件、符号链接/目录联接、硬链接等均拒绝修改。
|
|
22
|
+
- 默认不改文件,不递归扫描用户目录;输出只有路径、计数和固定错误码,不输出正文或密钥。`candidates` 是待修复回执数量。
|
|
23
|
+
- 上述 `npm exec` 可能联网下载 npm 包;恢复脚本本身只在本地运行,不上传日志。若插件已通过 npm 安装,也可完全离线执行 `node "/path/to/profile/node_modules/dsh-memoir/scripts/repair-session-receipts.mjs"`,后接相同参数。
|
|
24
|
+
- 在完整源码开发环境中,也可省略 `--dsh-package`,使用已安装且版本匹配的官方 SDK devDependencies;脚本不自动下载依赖。
|
|
25
|
+
|
|
26
|
+
### 备份后执行
|
|
27
|
+
|
|
28
|
+
完全退出使用这份日志的 Web、CLI、桌面和后台宿主,独立备份会话目录。确认只读检查成功,再执行:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm exec --yes --package=dsh-memoir@0.9.1 -- dsh-memoir-repair --dsh-package "/path/to/node_modules/@deepseek-ai/dsh" --apply --host-stopped "/path/to/session.v4.jsonl.zstd"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
脚本取得官方会话写锁,逐项校验原始日志,仅在旧回执最外层补 `ignorable: true`;不删事件、不重排 seq、不改正文/时间/工具数据。受影响压缩帧会重压缩,其它帧原样保留。原始字节写入同目录唯一 `.memoir-repair-<id>.bak`,验证后才以同目录原子替换安装结果。再次执行是无操作;备份不会自动删除。
|
|
35
|
+
|
|
36
|
+
应用期间必须持续停机,仅使用可信本地文件系统;锁防止遵循同一协议的 DSH 写者,不能对抗任意外部程序绕过锁写文件。检测到并发修改会停止。失败可能保留 `.tmp` 与 `.bak`,请按报告路径人工检查,不批量删除。若错误报告 `committed: true`,替换已经发生,先保存现场和备份再排查。
|
|
37
|
+
|
|
38
|
+
权限边界:POSIX 要求原文件 uid/gid 与当前进程有效身份匹配,否则拒绝替换。Windows 新建备份、暂存与替换文件继承目录 ACL,**不会保留原文件专属 ACL**;只有目录继承权限已经足以保护全部日志数据时才可执行,否则先单独审查权限。Windows 会话锁在同一登录会话内生效,不支持跨登录会话共享或网络盘。
|
|
39
|
+
|
|
40
|
+
修复后用**已修复的插件构建**重启并打开原会话。此脚本不修其它损坏,不保证宿主派生索引/缓存的所有故障均随之恢复;不要删除未知缓存或原始日志来掩盖剩余错误。需要回退时先停机,保留修复后文件,再从明确对应的 `.bak` 恢复原始文件。
|
|
41
|
+
|
|
42
|
+
## English
|
|
43
|
+
|
|
44
|
+
Memoir 0.8.1–0.9.0 appends a custom `dsh-memoir/written` receipt without `ignorable`. DSH can write it but refuses the whole persisted history on reopen. This does not itself delete the raw conversation or the memory store. **0.9.1 includes both prevention and a standalone recovery tool**. It uses official `tool/result.meta`; upgrading never rewrites old sessions automatically.
|
|
45
|
+
|
|
46
|
+
Stop memory writes from affected builds and upgrade to 0.9.1 first: disabling auto-distillation alone does not prevent manual write tools from producing another invalid receipt. The npm package includes the `dsh-memoir-repair` command, its script and this guide; no Git checkout is needed. Use Node 24 and audit one explicitly named file:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm exec --yes --package=dsh-memoir@0.9.1 -- dsh-memoir-repair --dsh-package "/path/to/node_modules/@deepseek-ai/dsh" "/path/to/session.v4.jsonl.zstd"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The official DSH directory supplies the reviewed v4 validators and native lease dependencies (JSONL backends **0.2.0-rc.1 / 0.2.0-rc.2 only**). `npm root -g` locates global packages; Windows and WSL have separate installations. An independently installed official npm DSH can validate desktop logs without editing the desktop installation.
|
|
53
|
+
|
|
54
|
+
`npm exec` may download the package from npm, but the recovery script runs locally and never uploads logs. For an entirely offline invocation of an already installed npm copy, use `node "/path/to/profile/node_modules/dsh-memoir/scripts/repair-session-receipts.mjs"` with the same arguments. In a source checkout with the pinned official SDK devDependencies installed, `--dsh-package` may be omitted. The script never downloads dependencies itself.
|
|
55
|
+
|
|
56
|
+
Default operation is read-only: no home scan, no host startup, no migration, and no content or credentials in diagnostics. It accepts only `session.v4.jsonl` / `session.v4.jsonl.zstd`, capped at 128 MiB both stored and expanded. It refuses torn/corrupt/unsupported logs, unknown required events, nonchecksummed frames, links and ambiguous receipts.
|
|
57
|
+
|
|
58
|
+
Exit **every** Web/CLI/desktop/background host using the file and independently back up the session directory. After a successful audit, apply explicitly:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npm exec --yes --package=dsh-memoir@0.9.1 -- dsh-memoir-repair --dsh-package "/path/to/node_modules/@deepseek-ai/dsh" --apply --host-stopped "/path/to/session.v4.jsonl.zstd"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The script takes the official session lease and adds only `ignorable: true` to exact legacy receipt envelopes, preserving event order, seq, timestamps, payloads and untouched compressed frames. A unique adjacent `.memoir-repair-<id>.bak` stores the verified original bytes before atomic replacement. Backups are retained; a second run makes no change.
|
|
65
|
+
|
|
66
|
+
Keep all hosts stopped throughout; use a trusted local filesystem. The lease excludes cooperating DSH writers, not arbitrary external writers. Observed changes abort replacement. Failures can leave `.tmp`/`.bak` files for manual inspection; do not bulk-delete them. `committed: true` means replacement already happened: preserve the current file and backup before troubleshooting.
|
|
67
|
+
|
|
68
|
+
Permissions: POSIX requires source uid/gid to match the effective process identity. On Windows, backup/staging/replacement files inherit directory ACLs; **custom source-file ACLs are not retained**. Apply only where inherited directory permissions already protect all log data; otherwise review permissions separately first. The Windows lease is scoped to the same login session, not cross-login sharing or network filesystems.
|
|
69
|
+
|
|
70
|
+
Reopen with a **fixed plugin build**. The tool does not repair unrelated corruption or promise recovery of every derived index/cache failure. To roll back, stop all hosts, retain the repaired file, and restore the exact matching `.bak`; never delete the raw conversation to silence errors.
|
package/cordis.patch.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# dsh-memoir bundle patch: inserts the host-half plugin row into the web
|
|
2
2
|
# profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
|
|
3
|
-
# manifest field) over dsh-base. dsh-memoir v0.
|
|
4
|
-
# line >=0.
|
|
3
|
+
# manifest field) over dsh-base. dsh-memoir v0.9.0 targets the DSH
|
|
4
|
+
# line >=0.2.0-rc.1 <0.3.0-0. Keep Memoir 0.8.2 on older DSH 0.1.7.
|
|
5
5
|
#
|
|
6
6
|
# The row is a bare plugin by package name: the node half (exports ".")
|
|
7
7
|
# registers the memoir_record / memoir_read tools, the /api/dsh-memoir panel
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
# Optional config (all default true):
|
|
13
13
|
# config:
|
|
14
14
|
# enabled: true # master switch (tools, routes, prompt section)
|
|
15
|
-
# language: zh # agent-facing copy: zh (default)
|
|
15
|
+
# language: zh # agent-facing copy: zh (default), en, de, ru
|
|
16
16
|
# announceToAgent: true # system-prompt announcement
|
|
17
|
-
# autoDistill: true #
|
|
17
|
+
# autoDistill: true # queue a separate wrap-up after each worked turn
|
|
18
18
|
# autoDistillEvery: 1 # remind at most once per N worked turns
|
|
19
19
|
# autoDistillCooldownMin: 0 # minimum minutes between successful reminders
|
|
20
20
|
# autoDistillMinTools: 1 # minimum tool calls on the triggering turn
|
package/lib/activity.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare const schema: z.ZodObject<{
|
|
|
7
7
|
turn: z.ZodNumber;
|
|
8
8
|
toolCalls: z.ZodNumber;
|
|
9
9
|
calls: z.ZodArray<z.ZodString>;
|
|
10
|
+
memoirCalls: z.ZodArray<z.ZodString>;
|
|
10
11
|
recorded: z.ZodBoolean;
|
|
11
12
|
reminded: z.ZodBoolean;
|
|
12
13
|
distilling: z.ZodBoolean;
|
|
@@ -14,6 +15,14 @@ declare const schema: z.ZodObject<{
|
|
|
14
15
|
}, z.core.$strip>;
|
|
15
16
|
export type MemoirActivity = z.infer<typeof schema>;
|
|
16
17
|
export declare const emptyActivity: () => MemoirActivity;
|
|
18
|
+
/** Opaque metadata on the host-owned tool/result event, never a new event type. */
|
|
19
|
+
export declare function writeReceiptMeta(persisted: boolean): {
|
|
20
|
+
memoir: {
|
|
21
|
+
version: number;
|
|
22
|
+
persisted: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function hasWriteReceipt(meta: unknown): boolean;
|
|
17
26
|
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
18
27
|
interface SessionProjectionStateMap {
|
|
19
28
|
'dsh-memoir/activity': MemoirActivity;
|
|
@@ -21,7 +30,7 @@ declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
|
21
30
|
}
|
|
22
31
|
declare module '@deepseek-ai/dsh-session/types' {
|
|
23
32
|
interface SessionEventMap {
|
|
24
|
-
/**
|
|
33
|
+
/** Legacy READ ONLY: repaired 0.8.1–0.9.0 logs. Never append this event. */
|
|
25
34
|
'dsh-memoir/written': {
|
|
26
35
|
turn: number;
|
|
27
36
|
callId: string;
|
package/lib/activity.js
CHANGED
|
@@ -6,19 +6,28 @@ const schema = z.object({
|
|
|
6
6
|
turn: z.number().int().nonnegative(),
|
|
7
7
|
toolCalls: z.number().int().nonnegative(),
|
|
8
8
|
calls: z.array(z.string()).max(CALL_LIMIT),
|
|
9
|
+
memoirCalls: z.array(z.string()).max(CALL_LIMIT),
|
|
9
10
|
recorded: z.boolean(),
|
|
10
11
|
reminded: z.boolean(),
|
|
11
12
|
distilling: z.boolean(),
|
|
12
13
|
originTurn: z.number().int().positive().nullable(),
|
|
13
14
|
});
|
|
14
|
-
export const emptyActivity = () => ({ turn: 0, toolCalls: 0, calls: [], recorded: false, reminded: false, distilling: false, originTurn: null });
|
|
15
|
+
export const emptyActivity = () => ({ turn: 0, toolCalls: 0, calls: [], memoirCalls: [], recorded: false, reminded: false, distilling: false, originTurn: null });
|
|
16
|
+
/** Opaque metadata on the host-owned tool/result event, never a new event type. */
|
|
17
|
+
export function writeReceiptMeta(persisted) { return { memoir: { version: 1, persisted } }; }
|
|
18
|
+
export function hasWriteReceipt(meta) {
|
|
19
|
+
if (typeof meta !== 'object' || meta === null || !('memoir' in meta))
|
|
20
|
+
return false;
|
|
21
|
+
const receipt = meta.memoir;
|
|
22
|
+
return typeof receipt === 'object' && receipt !== null && 'version' in receipt && receipt.version === 1 && 'persisted' in receipt && receipt.persisted === true;
|
|
23
|
+
}
|
|
15
24
|
export const activityProjection = {
|
|
16
25
|
key: ACTIVITY_KEY,
|
|
17
|
-
stateVersion:
|
|
26
|
+
stateVersion: 3,
|
|
18
27
|
stateSchema: schema,
|
|
19
28
|
init: emptyActivity,
|
|
20
29
|
apply(previous, event) {
|
|
21
|
-
if (event.type === 'turn/start' || event.type === 'tool/call' || event.type === 'dsh-memoir/written') {
|
|
30
|
+
if (event.type === 'turn/start' || event.type === 'tool/call' || event.type === 'tool/result' || event.type === 'dsh-memoir/written') {
|
|
22
31
|
const turn = event.data.turn;
|
|
23
32
|
if (turn < previous.turn)
|
|
24
33
|
return previous;
|
|
@@ -27,9 +36,17 @@ export const activityProjection = {
|
|
|
27
36
|
return state;
|
|
28
37
|
if (event.type === 'dsh-memoir/written')
|
|
29
38
|
return state.recorded ? state : { ...state, recorded: true };
|
|
39
|
+
if (event.type === 'tool/result') {
|
|
40
|
+
// A successful dispatch alone is not a commit: needs-resolution can
|
|
41
|
+
// also succeed. Only our explicit receipt on a correlated write counts.
|
|
42
|
+
return !state.recorded && !event.data.message.isError && state.memoirCalls.includes(event.data.message.source.callId) && hasWriteReceipt(event.data.meta)
|
|
43
|
+
? { ...state, recorded: true } : state;
|
|
44
|
+
}
|
|
30
45
|
if (state.calls.includes(event.data.callId))
|
|
31
46
|
return state;
|
|
32
|
-
return { ...state, toolCalls: state.toolCalls + 1, calls: [...state.calls, event.data.callId].slice(-CALL_LIMIT)
|
|
47
|
+
return { ...state, toolCalls: state.toolCalls + 1, calls: [...state.calls, event.data.callId].slice(-CALL_LIMIT),
|
|
48
|
+
memoirCalls: event.data.name === 'memoir_record' || event.data.name === 'memoir_update'
|
|
49
|
+
? [...state.memoirCalls, event.data.callId].slice(-CALL_LIMIT) : state.memoirCalls };
|
|
33
50
|
}
|
|
34
51
|
// next-step is retained for replay of pre-0.8.2 sessions. New reminders
|
|
35
52
|
// use next-turn, protecting the original turn's compact answer boundary.
|
package/lib/autodistill.js
CHANGED
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
14
14
|
import { DEFAULT_MEMOIR_LANGUAGE, hostCopy } from './i18n.js';
|
|
15
|
+
import { hasWriteReceipt } from './activity.js';
|
|
15
16
|
/** The follow-up instruction; the originating work turn is not rewritten. */
|
|
16
17
|
export function distillPrompt(language = DEFAULT_MEMOIR_LANGUAGE, originTurn) {
|
|
17
|
-
const origin = originTurn === undefined ? '' : language
|
|
18
|
-
? `Source work turn: ${originTurn}. This is a separate memory-only follow-up, not a new user task.\n`
|
|
19
|
-
: `来源工作回合:${originTurn}。这是独立的记忆收尾回合,不是新的用户任务。\n`;
|
|
18
|
+
const origin = originTurn === undefined ? '' : hostCopy(language).distillOrigin(originTurn);
|
|
20
19
|
return origin + hostCopy(language).distillPrompt;
|
|
21
20
|
}
|
|
22
21
|
/** Backwards-compatible Chinese prompt constant. */
|
|
@@ -27,6 +26,7 @@ export const AUTO_DISTILL_PLUGIN = 'dsh-memoir';
|
|
|
27
26
|
export function turnActivity(events, turn) {
|
|
28
27
|
let recorded = false;
|
|
29
28
|
let toolCalls = 0;
|
|
29
|
+
const completedWrites = new Set();
|
|
30
30
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
31
31
|
const event = events[i];
|
|
32
32
|
const data = event.data;
|
|
@@ -38,7 +38,12 @@ export function turnActivity(events, turn) {
|
|
|
38
38
|
continue;
|
|
39
39
|
if (event.type === 'tool/call') {
|
|
40
40
|
toolCalls += 1;
|
|
41
|
+
if ((data.name === 'memoir_record' || data.name === 'memoir_update') && typeof data.callId === 'string' && completedWrites.has(data.callId))
|
|
42
|
+
recorded = true;
|
|
41
43
|
}
|
|
44
|
+
if (event.type === 'tool/result' && data.message?.isError !== true && typeof data.message?.source?.callId === 'string' && hasWriteReceipt(data.meta))
|
|
45
|
+
completedWrites.add(data.message.source.callId);
|
|
46
|
+
// Read-only support for legacy logs after the explicit recovery tool.
|
|
42
47
|
if (event.type === 'dsh-memoir/written')
|
|
43
48
|
recorded = true;
|
|
44
49
|
}
|