dsh-memory-bond 0.0.0-stage → 0.3.0-beta.0

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.
Files changed (120) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +21 -0
  3. package/README.md +147 -2
  4. package/README.zh-CN.md +150 -0
  5. package/client/index.js +1186 -0
  6. package/client/memory-icon.svg +21 -0
  7. package/cordis.patch.yml +3 -0
  8. package/design/dsh-memory-plugin-design.md +46 -0
  9. package/design/dsh-memory-plugin-evaluation.md +135 -0
  10. package/design/evaluations/locomo-conv-26-2026-12-03.json +252 -0
  11. package/design/evaluations/locomo-conv-26-paired-2026-12-03.json +549 -0
  12. package/design/evaluations/locomo-conv-26-write-replay-2026-12-03.json +289 -0
  13. package/design/evaluations/project-memory-tasks-2026-12-03.json +1059 -0
  14. package/design/memory-lifecycle-consolidation.excalidraw +1212 -0
  15. package/design/memory-lifecycle-consolidation.mobile.excalidraw +1083 -0
  16. package/design/memory-lifecycle-consolidation.mobile.svg +2 -0
  17. package/design/memory-lifecycle-consolidation.mobile.zh-CN.excalidraw +1083 -0
  18. package/design/memory-lifecycle-consolidation.mobile.zh-CN.svg +94 -0
  19. package/design/memory-lifecycle-consolidation.svg +2 -0
  20. package/design/memory-lifecycle-consolidation.zh-CN.excalidraw +1212 -0
  21. package/design/memory-lifecycle-consolidation.zh-CN.svg +94 -0
  22. package/design/memory-lifecycle.excalidraw +2105 -0
  23. package/design/memory-lifecycle.mobile.excalidraw +1896 -0
  24. package/design/memory-lifecycle.mobile.svg +95 -0
  25. package/design/memory-lifecycle.mobile.zh-CN.excalidraw +1896 -0
  26. package/design/memory-lifecycle.mobile.zh-CN.svg +97 -0
  27. package/design/memory-lifecycle.svg +95 -0
  28. package/design/memory-lifecycle.zh-CN.excalidraw +2105 -0
  29. package/design/memory-lifecycle.zh-CN.svg +97 -0
  30. package/dist/audit.js +211 -0
  31. package/dist/automatic.js +8 -0
  32. package/dist/cache.js +40 -0
  33. package/dist/command-scope.js +123 -0
  34. package/dist/commands.js +150 -0
  35. package/dist/consolidation-store.js +290 -0
  36. package/dist/consolidation.js +186 -0
  37. package/dist/domain.js +241 -0
  38. package/dist/encoder.js +97 -0
  39. package/dist/export-files.js +161 -0
  40. package/dist/guidance.js +201 -0
  41. package/dist/host.js +6 -0
  42. package/dist/index-policy.js +148 -0
  43. package/dist/index.js +287 -0
  44. package/dist/knowledge-hooks.js +355 -0
  45. package/dist/knowledge.js +360 -0
  46. package/dist/maintenance-episodes.js +73 -0
  47. package/dist/maintenance-import.js +92 -0
  48. package/dist/maintenance-store.js +704 -0
  49. package/dist/maintenance.js +352 -0
  50. package/dist/model-review.js +16 -0
  51. package/dist/personal.js +23 -0
  52. package/dist/policy.js +384 -0
  53. package/dist/propose-contract.js +42 -0
  54. package/dist/question-answers.js +119 -0
  55. package/dist/retrieval.js +109 -0
  56. package/dist/search-index.js +84 -0
  57. package/dist/search-words.js +5 -0
  58. package/dist/semantic.js +295 -0
  59. package/dist/service.js +1044 -0
  60. package/dist/sharing.js +295 -0
  61. package/dist/sources.js +124 -0
  62. package/dist/store.js +1242 -0
  63. package/dist/turn-review-store.js +92 -0
  64. package/dist/turn-review.js +363 -0
  65. package/dist/ui.js +244 -0
  66. package/dist/vector-index.js +196 -0
  67. package/locale/detail.en.md +9 -0
  68. package/locale/detail.zh.md +9 -0
  69. package/locale/en.json +7 -0
  70. package/locale/zh.json +7 -0
  71. package/native/embeddings/LICENSE +21 -0
  72. package/native/embeddings/NOTICE.md +12 -0
  73. package/native/embeddings/en/model.onnx +4 -0
  74. package/native/embeddings/en/vocab.txt +30522 -0
  75. package/native/embeddings/runtime/LICENSE +21 -0
  76. package/native/embeddings/runtime/ThirdPartyNotices.txt +6156 -0
  77. package/native/embeddings/runtime/ort-wasm-simd-threaded.mjs +70 -0
  78. package/native/embeddings/runtime/ort-wasm-simd-threaded.wasm +0 -0
  79. package/native/embeddings/runtime/ort.wasm.min.mjs +7 -0
  80. package/native/embeddings/worker.mjs +97 -0
  81. package/native/embeddings/zh/model.onnx +0 -0
  82. package/native/embeddings/zh/vocab.txt +21128 -0
  83. package/package.json +97 -4
  84. package/src/audit.ts +227 -0
  85. package/src/automatic.ts +11 -0
  86. package/src/cache.ts +38 -0
  87. package/src/command-scope.ts +125 -0
  88. package/src/commands.ts +155 -0
  89. package/src/consolidation-store.ts +288 -0
  90. package/src/consolidation.ts +180 -0
  91. package/src/domain.ts +249 -0
  92. package/src/encoder.ts +102 -0
  93. package/src/export-files.ts +178 -0
  94. package/src/guidance.ts +229 -0
  95. package/src/host.ts +99 -0
  96. package/src/index-policy.ts +184 -0
  97. package/src/index.ts +289 -0
  98. package/src/knowledge-hooks.ts +414 -0
  99. package/src/knowledge.ts +433 -0
  100. package/src/maintenance-episodes.ts +76 -0
  101. package/src/maintenance-import.ts +107 -0
  102. package/src/maintenance-store.ts +835 -0
  103. package/src/maintenance.ts +360 -0
  104. package/src/model-review.ts +27 -0
  105. package/src/personal.ts +32 -0
  106. package/src/policy.ts +505 -0
  107. package/src/propose-contract.ts +43 -0
  108. package/src/question-answers.ts +111 -0
  109. package/src/retrieval.ts +116 -0
  110. package/src/search-index.ts +97 -0
  111. package/src/search-words.ts +6 -0
  112. package/src/semantic.ts +299 -0
  113. package/src/service.ts +1103 -0
  114. package/src/sharing.ts +356 -0
  115. package/src/sources.ts +128 -0
  116. package/src/store.ts +1492 -0
  117. package/src/turn-review-store.ts +87 -0
  118. package/src/turn-review.ts +336 -0
  119. package/src/ui.ts +290 -0
  120. package/src/vector-index.ts +200 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0-beta.0 · 2026-12-03
4
+
5
+ - The npm package is now `dsh-memory-bond`. Install with `dsh plugin --profile desktop add dsh-memory-bond@beta`. Each profile starts with a fresh database under `memory-bond/`. If it has an earlier keeper plugin, remove the old package before adding Bond.
6
+ - The Memory settings entry and the plugin card now share the same heavier-weight icon, which inherits the current theme color.
7
+ - Saved agreements retain their ID across corrections. You can check the original wording, see which revision reached a conversation, and withdraw the agreement. First-save checks now cover explicit ownership, project scope, conditions, negation and one-time requests.
8
+ - Eligible user text can be reviewed after the foreground model exhausts its output budget. End-of-turn recovery observes the profile’s existing limits and skips portions already handled.
9
+ - When standing agreements exceed the prompt budget, the current task can bring relevant older agreements into view. Search accepts Chinese and English wording in the same call and stops offering repeated searches when every accessible scope is empty.
10
+
11
+ The package includes local models and the runtime for offline embeddings. [Installation and host compatibility](README.md#install-the-public-beta) · [中文安装说明](README.zh-CN.md#安装公开-beta)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PersistentJZH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,148 @@
1
- # Temporary Holding Version
1
+ # DSH Memory Bond
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English · [简体中文](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/README.zh-CN.md)
4
+
5
+ DSH Memory Bond carries your agreements into new DeepSeek Harness chats. Each profile keeps one local SQLite database. Global preferences can follow you across projects, while project rules apply only to matching checkouts. **Recall has three layers.** A chat gets applicable rules in its prompt, can look up details for the task, and can check the original wording when you ask for a source. Optional background consolidation checks for possible duplicates while a project chat is idle.
6
+
7
+ [Install](#install-the-public-beta) · [Quick start](#try-it-across-two-chats) · [How memory works](#how-memory-works) · [Assistant tools](#tools-and-controls) · [Evaluation results](#evaluation-results) · [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
8
+
9
+ ## Install the public beta
10
+
11
+ Open DSH Desktop once to initialize its profile, quit the app, then run the following command and restart DSH. For Web, replace `desktop` with `web`.
12
+
13
+ ```sh
14
+ dsh plugin --profile desktop add dsh-memory-bond@beta
15
+ ```
16
+
17
+ This release is `0.3.0-beta.0`. Replace `@beta` with `@0.3.0-beta.0` to pin it. On macOS, if the CLI is outside your `PATH`, use `"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh"`. The table lists the hosts verified for this release. [Public npm package](https://www.npmjs.com/package/dsh-memory-bond)
18
+
19
+ | Environment | Verified version |
20
+ | --- | --- |
21
+ | macOS DSH Desktop host | `0.2.2-rc.5` |
22
+ | Standalone DSH CLI on macOS (tested on Node.js 24.15.0, host requires ≥24.9.0) | `0.2.2-rc.3`, `0.2.2-rc.4` |
23
+
24
+ Bond starts with a fresh `memory-bond/` data directory in each profile. If the same profile already has `dsh-memory-keeper`, quit DSH and remove that package with `dsh plugin --profile desktop remove dsh-memory-keeper` before adding Bond. The previous package’s data stays in its original directory.
25
+
26
+ ## Try it across two chats
27
+
28
+ 1. Restart DSH and open a writable chat in a Git repository. Say **“For this project, always start release notes with user-visible changes and put dependency updates last.”** Look for the save receipt under the message.
29
+ 2. Start a **new chat in the same repository**. Say **“Draft release notes. We fixed the login loop and updated the HTTP library.”** Check which change leads.
30
+ 3. Open **Settings → Memory** (设置 → 记忆), select the project, and inspect the entry. You can see its current version, check its source, change when it is used, or withdraw it.
31
+
32
+ **Which command runs after you correct a project rule?** In the host test, both Make targets exist. Each task starts a fresh chat with the same request to run the integration checks. The user messages below are translated from the Chinese fixture.
33
+
34
+ | User message or action | Version received by the new chat | Target recorded by the Makefile |
35
+ | --- | --- | --- |
36
+ | “Use make river-suite for this project's integration checks from now on.” | Revision 1 in the first request | `make river-suite` |
37
+ | “Correction: use make lake-suite for this project's integration checks from now on.” | Revision 2 of the same agreement | `make lake-suite` |
38
+ | Switch the agreement to on-demand recall | Revision 3 retrieved before execution | `make lake-suite` |
39
+ | Withdraw the agreement and give `make check` as the fallback for this task | The withdrawn version is absent | `make check` |
40
+
41
+ From a source checkout, run `npm run verify:tasks` to reproduce the sequence. It checks the original user events, the versions included in model requests, and the targets recorded by the Makefile. [Host verification and results (Chinese)](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
42
+
43
+ <picture>
44
+ <source media="(max-width: 600px)" srcset="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.mobile.svg">
45
+ <img src="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.svg" alt="One local SQLite database per profile holds global and project memory. Layer 1 puts applicable rules in the prompt, such as the corrected just integration command at revision 2. Layer 2 retrieves current conclusions, conditions and exceptions on demand. Layer 3 checks an excerpt and its verification status when the user asks for a source. Optional consolidation checks roughly hourly while a project chat stays idle.">
46
+ </picture>
47
+
48
+ [Full-size diagram](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.svg) · Excalidraw sources ([desktop](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.excalidraw) / [mobile](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.mobile.excalidraw)) · [Cross-session test results (Chinese)](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
49
+
50
+ ## How memory works
51
+
52
+ **Saving a memory.** The assistant proposes a fact, preference or rule with a quote from the user. The plugin locates that quote in the session and checks write access, scope and repository constraints. A repeated agreement can reuse the same revision. An explicit correction to a uniquely identified entry keeps its ID and advances its version. For a test command, that means a fresh chat can receive the corrected command with its applicable conditions.
53
+
54
+ **The task determines which layer to read.** When the prompt already contains the applicable command, the assistant can use it directly.
55
+
56
+ | Recall layer | When it is used and what reaches the assistant |
57
+ | --- | --- |
58
+ | 1 · Prompt index | When DSH builds a model request, a ranked index supplies applicable standing rules with their actions, conditions, exceptions and versions. The default budget is **16 lines and 2,048 UTF-8 bytes**. |
59
+ | 2 · On-demand details | The assistant can read a current conclusion by ID or search by subject, topic, keywords, or similar wording. It can submit Chinese and English versions of a query in one call. SQLite FTS5 and each language’s BGE model run locally. Sensitive entries and on-demand facts stay out of the standing index. |
60
+ | 3 · Source verification | When you ask where a rule came from, a separate lookup can verify a project quote against one original session event. It distinguishes verified words, a retained excerpt, user-confirmed wording and a receipt with no quote. You can erase the excerpt and keep the conclusion. |
61
+
62
+ **Scope determines where a memory travels.** A global preference, such as how you write deadlines, can follow you across projects in the same profile. A project's test command belongs to that repository. Linked Git worktrees share project memory, with path, branch and repository instructions checked for applicability. The settings panel can also show whether a particular revision actually reached the model in the selected session.
63
+
64
+ ## What runs in the background?
65
+
66
+ **Periodic cross-session consolidation is off by default.** Once enabled, the first check is scheduled when a writable main chat in the project completes a turn and goes idle. Checks repeat roughly once an hour while the chat stays idle. Starting another turn in that chat pauses the schedule and cancels any comparison in progress.
67
+
68
+ <picture>
69
+ <source media="(max-width: 600px)" srcset="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.mobile.svg">
70
+ <img src="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.svg" alt="Once enabled, consolidation checks after a completed project turn, repeats about hourly while idle, and pauses for a new turn. SQLite scans existing entries in batches, then matches new or revised entries against older ones. An empty check makes zero model calls. For an eligible pair, the model compares two summaries. If it flags a duplicate, the user chooses which records to keep.">
71
+ </picture>
72
+
73
+ [Full-size diagram](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.svg) · Excalidraw sources ([desktop](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.excalidraw) / [mobile](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.mobile.excalidraw))
74
+
75
+ | Job | What it does | Default and cost |
76
+ | --- | --- | --- |
77
+ | End-of-turn review | When a writable main chat completes a turn or reaches its output limit, review eligible user excerpts the assistant has yet to handle. For a correction, check the exact revision before saving. | Up to **20 batches per profile per UTC day**, using the session’s model. Set `turnReviewBudget: 0` to turn this off. |
78
+ | Cross-session consolidation | SQLite scans existing entries in batches and saves its position. It then matches new and revised entries against older entries about the same subject from other chats in the same project. | A check with no eligible pair makes zero model calls. The model compares at most **one pair per project per hour**. |
79
+ | Historical review | Recheck a project proposal already present in an older session and prepare a review card when its user quote can be verified. | Automatic review is **off** (`historyBudget: 0`). It reuses recorded proposals locally. |
80
+ | Search indexing | Update local embeddings as entries change. Keyword search works while the vector index is building. | Runs locally on the CPU using the bundled models and WebAssembly runtime. |
81
+
82
+ With memory enabled, use the **跨会话整理** switch under **Settings → Memory** to turn consolidation on or off. Turning memory off pauses consolidation and disables its switch. Turning memory back on restores your previous choice. The model sees the candidate pair’s topics, conclusions and conditions, including relevant paths and exceptions. Source quotes, transcripts and sensitive entries are excluded. **You decide whether to keep both entries or keep one and withdraw the other.**
83
+
84
+ ## Tools and controls
85
+
86
+ DSH exposes five tools to the assistant while memory is enabled.
87
+
88
+ | Tool | Purpose |
89
+ | --- | --- |
90
+ | `project_memory_propose` | Propose a scoped memory or correction grounded in the user’s words. |
91
+ | `project_memory_search` | Find current records in the visible scope by ID, subject and topic, keywords, or semantic similarity. |
92
+ | `project_memory_read` | Read the current conclusion, conditions, exceptions and revision. |
93
+ | `project_memory_source` | Look up the retained wording and its verification status when the user asks for the source. |
94
+ | `project_memory_ticket` | Open a short-lived ticket offered by DSH for a matching project fact, reference or runbook. |
95
+
96
+ For direct control, open **Settings → Memory** or run `/project-memory help` in a client that supports slash commands. Use `/project-memory status` to inspect records and `/project-memory search release notes` to find an entry. Project commands also support file-backed facts, runbooks, command guards, backups, and a preview before exporting an agreement to `AGENTS.md` or a verified runbook to a skill.
97
+
98
+ ## Storage and configuration
99
+
100
+ The default desktop database is `~/.dsh/profiles/desktop/memory-bond/memory.sqlite`. Each profile has its own `memory-bond/` directory, including managed backups in `backups/projects.sqlite`. The plugin uses the runtime’s built-in SQLite and stores the database as an ordinary, unencrypted file. DSH manages the original chat history separately.
101
+
102
+ Search and embedding computation run on your machine. Your configured DSH model provider receives entries included in a model request, eligible excerpts used for end-of-turn review, and candidate summaries when you enable consolidation. You can pause assistant saving and recall from **Settings → Memory** and still manage existing records.
103
+
104
+ Set plugin options in the profile’s `cordis.patch.yml`. For example, this keeps foreground saving and turns off the extra end-of-turn model calls.
105
+
106
+ ```yaml
107
+ - id: dsh-memory-bond
108
+ config:
109
+ turnReviewBudget: 0
110
+ ```
111
+
112
+ Other options include `maxRows` and `maxTokens` for the index budget, `nonGitRoots` for explicit project directories, and `historyDays` for retaining superseded or withdrawn content (default **90 days**). By default, spare index space can hold up to two pointers to older agreements whose terms match the current task. Set `overflowHints: false` to disable pointers or `true` to also allow unmatched candidates.
113
+
114
+ ## Evaluation results
115
+
116
+ ### LoCoMo cross-session QA
117
+
118
+ **On the same 20 questions, enabling memory in a fresh chat raised mean F1 from 0.0 to 27.1 out of 100.** The plugin improved the score on 12 questions and tied on eight. Single-hop fact recall rose from 0.0 to 52.6. We used one LoCoMo conversation, `conv-26`, with five questions each for single-hop, multi-hop, temporal and open-domain reasoning. All three conditions used `deepseek-flash`, a fresh chat per question, the same short-answer instruction and the official token F1 scorer.
119
+
120
+ | Information available in the fresh chat | Mean F1 | QA model requests | QA input tokens | Estimated QA cost |
121
+ | --- | ---: | ---: | ---: | ---: |
122
+ | Plugin off, question only | 0.0 | 92 | 577,993 | CNY 0.22 |
123
+ | Plugin on, access to 118 saved memories | **27.1** | 54 | 1,031,787 | CNY 0.61 |
124
+ | Plugin off, all 19 session transcripts supplied with each question | 41.6 | 20 | 452,779 | CNY 0.12 |
125
+
126
+ For example, when asked how often Melanie took her kids to the beach, the question-only baseline answered `Unknown`. With the plugin enabled, the memory saved from session 10 ranked second in search. The model answered “Once or twice a year” for full credit. The full-transcript run also answered correctly. This conversation fits in the model’s context window, and supplying it in full gave the best overall score and the lowest QA cost in this run.
127
+
128
+ The comparison ran on December 3, 2026. Each ingestion prompt explicitly asked the assistant to save reusable facts. Fourteen sessions saved memories and five reached the output limit before saving. All three conditions blocked tools for reading files and searching the web. In the question-only condition, the model tried other tools on all 20 questions, adding model requests as it processed the denials. Costs use the measured cache usage and DeepSeek’s peak rates at the time. The one-time ingestion cost was about CNY 1.87, bringing the plugin condition to **CNY 2.48** for ingestion and QA together. An earlier pilot explicitly prompted the model to use project memory and scored 29.3. [Paired answers and usage](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/evaluations/locomo-conv-26-paired-2026-12-03.json) · [Earlier pilot](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/evaluations/locomo-conv-26-2026-12-03.json) · [LoCoMo dataset](https://github.com/snap-research/locomo) · [Setup and run details (Chinese)](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
129
+
130
+ ```sh
131
+ npm run eval:locomo -- --upstream ../locomo --compare
132
+ ```
133
+
134
+ ### How we test recall
135
+
136
+ In the latest DeepSeek run, the commands recorded by the Makefile and the response to the unrelated task matched expectations in all eight cases. Seven finished within nine model requests. After withdrawal the assistant searched once, ran `make check`, and finished. In the on-demand case it retrieved revision 3 and ran `make lake-suite`, then continued to inspect the repository until it reached the request limit. Total requests across the eight cases went from 44 to 39 in one run per version. [Per-task results](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/evaluations/project-memory-tasks-2026-12-03.json) · [Evaluation methods and limits (Chinese)](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
137
+
138
+ ```sh
139
+ npm test # Build and run the local tests
140
+ npm run verify:tasks # Isolated DSH host with a scripted model
141
+ npm run verify:tasks -- --live # Real model, using configured DeepSeek credentials
142
+ ```
143
+
144
+ The host checks use the installed macOS DSH app. You can also run `npm run verify:web` and `npm run verify:desktop` to exercise the settings and chat receipts in isolated profiles.
145
+
146
+ ## License
147
+
148
+ The plugin is MIT-licensed. The bundled embedding models and inference runtime include their own notices. [MIT license](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/LICENSE) · [Model and runtime notices](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/native/embeddings/NOTICE.md)
@@ -0,0 +1,150 @@
1
+ # DSH Memory Bond
2
+
3
+ [English](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/README.md) · 简体中文
4
+
5
+ DSH Memory Bond 让 DeepSeek Harness(DSH)跨会话记住你的约定。每个 profile 有一份本地 SQLite 记忆库,全局偏好可跨项目使用,项目约定只在匹配的仓库和条件下生效。**读取分三层**,请求中先给适用约定,任务需要时查详情,你追问出处时再核对原话。你也可以开启跨会话整理,让插件在项目会话空闲时定期检查疑似重复的记忆。
6
+
7
+ [安装](#安装公开-beta) · [快速开始](#用两个会话试一遍) · [记忆原理](#一条记忆怎样进入下一次会话) · [工具与命令](#工具与命令) · [评测结果](#评测结果) · [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
8
+
9
+ ## 安装公开 beta
10
+
11
+ 先打开 DSH 桌面应用一次以初始化 profile,完全退出后执行以下命令,再重启应用。Web 用户把 `desktop` 换成 `web`。
12
+
13
+ ```sh
14
+ dsh plugin --profile desktop add dsh-memory-bond@beta
15
+ ```
16
+
17
+ 本次版本为 `0.3.0-beta.0`。需要固定版本时,将 `@beta` 换成 `@0.3.0-beta.0`。在 macOS 上,若终端找不到 `dsh`,请使用 `"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh"`。已验证的宿主版本见下表。[公共 npm 包](https://www.npmjs.com/package/dsh-memory-bond)
18
+
19
+ | 环境 | 已验证版本 |
20
+ | --- | --- |
21
+ | macOS DSH 桌面宿主 | `0.2.2-rc.5` |
22
+ | macOS 独立 DSH CLI(实测 Node.js 24.15.0,宿主要求 ≥24.9.0) | `0.2.2-rc.3`、`0.2.2-rc.4` |
23
+
24
+ 本版使用独立的 `memory-bond/` 数据目录。若同一 profile 已装过 `dsh-memory-keeper`,先退出 DSH 并运行 `dsh plugin --profile desktop remove dsh-memory-keeper`,然后按上面的命令安装 Bond。旧数据保留在原目录,Bond 从新的记忆库开始。
25
+
26
+ ## 用两个会话试一遍
27
+
28
+ 1. 重启 DSH,在一个 Git 仓库中打开可写会话,告诉助手 **“以后这个项目写发布说明时,先列用户能感受到的变化,依赖升级放最后。”** 保存成功后,消息下方会出现记忆回执。
29
+ 2. 在**同一个仓库新开会话**,只说 **“帮我写发布说明。这次修好了登录后反复跳回首页的问题,还升级了 HTTP 客户端。”** 看看哪项排在前面。
30
+ 3. 打开 **设置 → 记忆**,选中这个项目。你可以核对这条约定的版本、查看来源、调整它是主动生效还是按需查阅,也可以撤回。
31
+
32
+ **改了测试命令,下个会话会跑什么?** 在两个测试目标都存在的仓库里,只给新会话一句“帮我跑一下这个改动的集成验证”。下面是宿主验证记录的结果。
33
+
34
+ | 用户原话或操作 | 新会话收到的约定 | Makefile 实际执行 |
35
+ | --- | --- | --- |
36
+ | “以后这个项目的集成验证用 make river-suite。” | 首次请求收到第 1 版 | `make river-suite` |
37
+ | “更正一下,以后这个项目的集成验证用 make lake-suite。” | 同一条约定的第 2 版 | `make lake-suite` |
38
+ | 改为按需查阅 | 执行前通过检索收到第 3 版 | `make lake-suite` |
39
+ | 撤回,并在本次任务中指定备用命令 `make check` | 查不到已撤回版本 | `make check` |
40
+
41
+ 在源码检出目录运行 `npm run verify:tasks` 可以复现。脚本回读原会话核验引文,检查发给模型的版本,并从 Makefile 留下的执行记录读取目标。[验证方法与实测结果](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
42
+
43
+ <picture>
44
+ <source media="(max-width: 600px)" srcset="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.mobile.zh-CN.svg">
45
+ <img src="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.zh-CN.svg" alt="每个 profile 的本地 SQLite 同时保存全局和项目记忆。第一层将适用约定放进提示词,例如更正后的第 2 版 just integration。第二层按需检索或读取现行结论、条件和例外。第三层在用户追问时查询短引文及核验状态。可选的后台整理在项目会话持续空闲时约每小时检查一次。">
46
+ </picture>
47
+
48
+ [查看原图](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.zh-CN.svg) · Excalidraw 源文件([桌面版](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.zh-CN.excalidraw) / [手机版](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle.mobile.zh-CN.excalidraw)) · [跨会话验证结果](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
49
+
50
+ ## 一条记忆怎样进入下一次会话
51
+
52
+ **保存时,先找到用户说过的那句话。** 助手可以提出值得保留的事实、偏好或约定,并附上支持它的用户原话。插件在会话中定位这段引文,检查写入权限、适用范围和仓库约束,再保存。重复陈述同一约定可以沿用现有版本。明确更正且能定位原条目时,保留原 ID,生成下一版。例如把集成测试命令从 `make integration` 改为 `just integration`,下一次执行任务时读到的就是经过核对的新命令和适用条件。
53
+
54
+ **读取时,任务决定需要哪一层。** 短索引里已经有完整命令时,助手就可以直接使用它。
55
+
56
+ | 读取层 | 何时使用,助手拿到什么 |
57
+ | --- | --- |
58
+ | 1 · 主动提示 | DSH 组装模型请求时,写入适用的主动约定,含动作、条件、例外和版本。置顶项优先,短索引默认最多 **16 行、2,048 个 UTF-8 字节**。 |
59
+ | 2 · 按需详情 | 助手需要更多信息时,可按 ID 读取现行结论,或按主体与主题、关键词、相近表述检索。关键词由 SQLite FTS5 检索。查中英文混用的约定时,助手可在一次调用中给出两种语言的等义问法,各自使用对应的本地 BGE 模型匹配。按需资料和标记为敏感的条目只在查阅时出现。 |
60
+ | 3 · 来源核验 | 你追问出处时,助手可单独查询短引文及其核验状态。项目引文可与原会话中的一个事件核对。结果区分已核验原话、留存引文、用户确认的表述和仅有回执。你可以单独清除引文,保留结论。 |
61
+
62
+ **作用域决定约定能跟到哪里。** 例如“给客户写截止时间时附上时区”可以是同一 profile 下跨项目使用的偏好,而测试命令可以只属于某个仓库。同一仓库的 Git worktree 共享项目记忆,插件仍会检查当前路径、分支和仓库指令。在设置页选中具体会话,还能查看某一版约定是否实际送达了模型。
63
+
64
+ ## 后台做什么,何时调用模型?
65
+
66
+ **跨会话定期整理默认关闭。** 开启后,可写项目主会话正常结束一轮并进入空闲时,插件安排首次检查。只要会话持续空闲,此后约每小时复查一次。该会话开始新一轮时,插件暂停整理,并取消正在进行的比较。
67
+
68
+ <picture>
69
+ <source media="(max-width: 600px)" srcset="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.mobile.zh-CN.svg">
70
+ <img src="https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.zh-CN.svg" alt="开启后,项目主会话完成一轮、进入空闲时首查,持续空闲时约每小时复查,新一轮开始时暂停。SQLite 先分批检查已有记忆,之后将新增或修订与旧条目匹配。没有候选时模型调用为零。符合条件时模型只比较两条摘要,判为疑似重复后由用户决定保留哪些记录。">
71
+ </picture>
72
+
73
+ [查看原图](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.zh-CN.svg) · Excalidraw 源文件([桌面版](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.zh-CN.excalidraw) / [手机版](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/memory-lifecycle-consolidation.mobile.zh-CN.excalidraw))
74
+
75
+ | 任务 | 何时运行、处理什么 | 默认设置与开销 |
76
+ | --- | --- | --- |
77
+ | 轮末补查 | 可写主会话正常结束或触及输出上限后,在每日预算内检查助手尚未处理的用户片段。遇到明确更正,会检索相关旧主题,并在写入前核对版本。 | 使用该会话的模型,每个 profile 每个 UTC 日最多 **20 批**。设 `turnReviewBudget: 0` 即可关闭。 |
78
+ | 跨会话整理 | SQLite 先分批检查已有项目记忆并保存进度,随后从上次位置继续,将新增或修订与同项目、同主体、来自其他会话的旧条目匹配。 | 没有合格候选时模型调用为零。每个项目每小时最多让模型比较**一对记忆**。 |
79
+ | 历史提议复核 | 从旧项目会话中找到助手当时提出的记忆,重新核对对应的用户引文,符合条件的生成待审卡。 | 自动复核默认关闭(`historyBudget: 0`)。在本地复用已有提议。 |
80
+ | 建立检索索引 | 记忆变化后,在本地更新文档向量。向量尚在生成时,关键词检索即可使用。 | 使用随包的模型和 WebAssembly 运行时,在本机 CPU 上计算。 |
81
+
82
+ 在 **设置 → 记忆** 中启用记忆后,即可切换「跨会话整理」。关闭记忆会暂停整理,此时开关不可用。重新启用记忆后,整理开关恢复为你上次的选择。比较重复项时,模型只看到两条候选的主题、结论及适用条件,包括相关路径和例外。原始会话、来源引文和标记为敏感的条目均排除在此次比较之外。模型给出建议后,**你可以保留两条,也可以保留其中一条并撤回另一条**。
83
+
84
+ ## 工具与命令
85
+
86
+ 启用记忆后,DSH 向助手提供五个工具。
87
+
88
+ | 工具 | 用途 |
89
+ | --- | --- |
90
+ | `project_memory_propose` | 根据用户原话提出新记忆或更正,并指定属于当前项目还是整个 profile。 |
91
+ | `project_memory_search` | 在可见范围内按 ID、主体与主题、关键词或语义相似度查找现行条目。 |
92
+ | `project_memory_read` | 读取现行结论、适用条件、例外和版本。 |
93
+ | `project_memory_source` | 用户追问出处时,查阅留存表述及其核验状态。 |
94
+ | `project_memory_ticket` | 任务命中预设触发条件时,凭 DSH 给出的短期票据读取对应的项目事实、参考资料或操作手册。 |
95
+
96
+ 你可以在 **设置 → 记忆** 中直接管理记录。在支持斜杠命令的客户端,输入 `/project-memory status` 查看状态,输入 `/project-memory search 发布说明` 查找记录,输入 `/project-memory help` 查阅全部命令。项目命令还支持登记带文件依据的事实、操作手册和命令约束,或建立备份。要把团队约定写入 `AGENTS.md`、把已验证的操作手册导出为技能文件,可以先预览改动再确认写入。
97
+
98
+ ## 数据存放与配置
99
+
100
+ 桌面版的默认主库路径是 `~/.dsh/profiles/desktop/memory-bond/memory.sqlite`。每个 profile 使用自己的 `memory-bond/` 目录,受管备份位于该目录的 `backups/projects.sqlite`。插件使用运行时内置的 SQLite,数据库文件未加密。原始聊天记录由 DSH 单独管理。
101
+
102
+ 检索和向量计算都在本机完成。配置给 DSH 的模型提供方会收到进入模型请求的记忆内容、轮末补查使用的用户片段,以及开启跨会话整理后送去比较的候选摘要。在 **设置 → 记忆** 中关闭「启用记忆」,可以暂停助手保存和查阅记忆,已有记录仍可管理。
103
+
104
+ 插件选项写在对应 profile 的 `cordis.patch.yml` 中。例如以下配置保留对话中的即时保存,关闭轮末额外的模型调用。
105
+
106
+ ```yaml
107
+ - id: dsh-memory-bond
108
+ config:
109
+ turnReviewBudget: 0
110
+ ```
111
+
112
+ 用 `maxRows` 和 `maxTokens` 调整索引的行数和字节上限,用 `nonGitRoots` 指定作为项目根目录的非 Git 目录。`historyDays` 控制被替换或撤回的版本内容保留多久,默认 **90 天**。索引写满后,默认从超出预算的主动约定里选取与当前任务用词相符的条目,利用剩余空间显示最多两条适用条件和版本号。`overflowHints: false` 关闭短线索,`true` 允许在没有词项匹配时也补充线索。
113
+
114
+ ## 评测结果
115
+
116
+ ### LoCoMo 跨会话问答
117
+
118
+ **同样的 20 道题,在空白新会话中启用记忆插件,平均 F1 从 0.0 提高到 27.1 分。** 逐题比较,12 题得分提高,8 题持平。单跳事实题从 0.0 提高到 52.6 分。评测使用 LoCoMo 的一组对话 `conv-26`,单跳、多跳、时间推理和开放域各 5 题。三组都让 `deepseek-flash` 在新会话回答同一批题,使用相同的简答指令和官方词级 F1,满分 100。
119
+
120
+ | 新会话能使用的信息 | 平均 F1 | 答题模型请求数 | 答题输入 token | 估算答题费用 |
121
+ | --- | ---: | ---: | ---: | ---: |
122
+ | 关闭插件,只给问题 | 0.0 | 92 | 577,993 | ¥0.22 |
123
+ | 开启插件,可查 118 条已保存记忆 | **27.1** | 54 | 1,031,787 | ¥0.61 |
124
+ | 关闭插件,每题附上 19 场对话全文 | 41.6 | 20 | 452,779 | ¥0.12 |
125
+
126
+ 例如,问「Melanie 多久带孩子去一次海滩?」时,关闭插件的回答是 `Unknown`。开启插件后,第 10 场保存的频率记录排在检索结果第 2 位,模型答出「一年一到两次」,获满分。附上全文也答对了这道题。这组对话能完整放入上下文,全文组在总分和答题费用上都占优。
127
+
128
+ 该次评测于 2026 年 12 月 3 日运行。每场写入时都明确要求保存可复用的事实,14 场成功、5 场在保存前触及输出上限。三组都限制文件和网络工具。只给问题的模型在 20 题中都尝试了其他工具,这些被拦截的调用增加了模型请求数。表中费用按当时 DeepSeek 高峰价和实际缓存用量估算。加上一次性写入约 ¥1.87,插件组写入和答题合计约 **¥2.48**。早先的试跑在问题中明确要求使用项目记忆,得到 29.3 分。[三组逐题对照与用量](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/evaluations/locomo-conv-26-paired-2026-12-03.json) · [早先的试跑结果](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/evaluations/locomo-conv-26-2026-12-03.json) · [LoCoMo 数据集](https://github.com/snap-research/locomo) · [环境与复现步骤](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
129
+
130
+ ```sh
131
+ npm run eval:locomo -- --upstream ../locomo --compare
132
+ ```
133
+
134
+ ### 怎样验证助手真的用上了记忆?
135
+
136
+ 跨会话评测新开一个聊天,只让助手“帮我跑一下这个改动的集成验证”,并记录首次请求、后续查到的版本以及 **Makefile 实际执行的目标**。用例覆盖换仓、临时例外、更正和撤回。
137
+
138
+ 真实 DeepSeek 复测中,八个场景的实际命令或静默行为均符合预期,七个在九次请求内结束。撤回后,助手只查空一次,运行备用命令 `make check` 并结束。按需读取场景找到了第 3 版并执行 `make lake-suite`,随后继续检查仓库,触及请求上限。与改动前的同组试跑相比,总请求数从 44 降到 39;每组各跑一次。[逐场原始结果](https://cdn.jsdelivr.net/npm/dsh-memory-bond@0.3.0-beta.0/design/evaluations/project-memory-tasks-2026-12-03.json) · [方法与已知局限](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/design/dsh-memory-plugin-evaluation.md)
139
+
140
+ ```sh
141
+ npm test # 编译插件并运行本地测试
142
+ npm run verify:tasks # 在隔离的 DSH 宿主中使用脚本化模型
143
+ npm run verify:tasks -- --live # 使用已配置的 DeepSeek 凭据运行真实模型
144
+ ```
145
+
146
+ 宿主验证使用本机安装的 macOS DSH 应用。`npm run verify:web` 和 `npm run verify:desktop` 会分别在隔离的 profile 中测试设置页和聊天回执。
147
+
148
+ ## 许可
149
+
150
+ 插件源码采用 MIT 许可证。随包分发的嵌入模型和推理运行时附有各自的许可说明。[MIT 许可证](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/LICENSE) · [模型与运行时许可](https://app.unpkg.com/dsh-memory-bond@0.3.0-beta.0/files/native/embeddings/NOTICE.md)