@klarkxy/dsh-memory 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,41 @@
1
+ The Star And Thank Author License (SATA)
2
+ Version 2.1, September 2026
3
+
4
+ Copyright © 2026 Klarkxy(278370456@qq.com)
5
+
6
+ Project Url: https://github.com/klarkxy/dsh-editor
7
+ https://github.com/klarkxy/sata-license
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ And wait, one more thing — an invitation, not a condition: it would be best if
20
+ you star/+1/like the project(s) in the project url section above, and thank the
21
+ author(s) in the Copyright section. You may, and arguably you should — but the
22
+ permissions above hold either way, star or no star.
23
+
24
+ Here are some suggested ways:
25
+
26
+ - Email the authors a thank-you letter, and make friends with him/her/them.
27
+ - Report bugs or issues.
28
+ - Tell friends what a wonderful project this is.
29
+ - And, sure, you can just express thanks in your mind without telling the world.
30
+
31
+ Contributors of this project by forking have the option to add his/her name and
32
+ forked project url at copyright and project url sections, but shall not delete
33
+ or modify anything else in these two sections.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
41
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @klarkxy/dsh-memory
2
+
3
+ Default-enabled Memory with idle Dream consolidation. Stores long-term preferences, project facts, decisions, and lessons. Novel canon stays in author-confirmed worldbook files, not here.
4
+
5
+ [简体中文](https://github.com/klarkxy/dsh-editor/blob/main/packages/dsh-memory/docs/README.zh-CN.md)
6
+
7
+ ## Install
8
+
9
+ Requires Node.js ≥22 and DSH `0.1.7-alpha.1`. The bundle entry starts enabled, but loading it does not start inference or load `@klarkxy/dsh-ai-services`.
10
+
11
+ Standalone DSH must load the shared service explicitly before this feature can start:
12
+
13
+ ```sh
14
+ dsh plugin --profile web add @klarkxy/dsh-ai-services
15
+ dsh plugin --profile web add @klarkxy/dsh-memory
16
+ ```
17
+
18
+ Idle Dream is on by default and needs no confirmation: once a session has been idle for 15 minutes, at least 24 hours have passed since the last attempt, and at least 3 records were added or changed since then (deletions count), it runs once and applies automatically — at most once a day. Apply writes candidates only and never overwrites active records; failures back off for the same 24 hours. Turn it off under **Settings → 记忆**, or run the full flow manually via **Organize now**. Memory itself remains independently switchable in plugin settings.
19
+
20
+ ## Behaviour
21
+
22
+ `ctx.aiMemory` implements the frozen `MemoryService`. Project identity is the shared untruncated `projectIdFromCwd(session.meta.cwd)` (DSH also exposes it as `session.header.cwd`). RPC derives that path from the live session id; clients cannot submit an arbitrary directory. Record ids are UUID-backed and cannot reuse a tombstone after restart. Durable writes are one typed aggregate snapshot.
23
+
24
+ Recall injects at most 3–5 active records (~800 tokens) at Host `agent/pre-step`, exact project scope plus explicit global records. Lessons are not injected here (self-improvement owns them). Candidates, rejected, revoked, deleted, expired, and superseded records stay out of prompts.
25
+
26
+ Human preference and project-fact candidates need evidence or an explicit manual add. Global writes require the global checkbox. Dream produces merge/dedup candidates and applies them automatically under the idle gates above; apply writes candidates only, never overwrites active records or expands project scope to global. Corrections and deletions win over in-flight runs. Deleted ids cannot be resurrected.
27
+
28
+ Disabling the plugin or injection/Dream switches cancels pending results and injection. Stored records remain.
29
+
30
+ From the repository root:
31
+
32
+ ```sh
33
+ pnpm --filter @klarkxy/dsh-memory typecheck
34
+ pnpm exec vitest run packages/dsh-memory/src
35
+ pnpm --filter @klarkxy/dsh-memory build
36
+ ```
37
+
38
+ [Publishing](https://github.com/klarkxy/dsh-editor/blob/main/packages/PUBLISHING.md) · [License](https://github.com/klarkxy/dsh-editor/blob/main/packages/dsh-memory/LICENSE)
39
+
40
+ The Editor preinstalls this feature enabled. In the Editor, use Settings → Plugins to switch it without restarting. Standalone DSH must load `@klarkxy/dsh-ai-services` before this package; installation or removal may require a restart when the host asks for one.
@@ -0,0 +1,5 @@
1
+ # Enabled when installed. Memory still does not enable Dream idle processing or load ai-services.
2
+ - insert:
3
+ - id: memory
4
+ name: '@klarkxy/dsh-memory'
5
+ disabled: false
@@ -0,0 +1,9 @@
1
+ # @klarkxy/dsh-memory
2
+
3
+ 默认启用的记忆与闲时梦境整理。保存长期偏好、项目事实、决策和教训。小说设定仍只存在于作者确认的世界书,不写入本插件。
4
+
5
+ [English](https://github.com/klarkxy/dsh-editor/blob/main/packages/dsh-memory/README.md)
6
+
7
+ 需要 Node.js ≥22、DSH `0.1.7-alpha.1`。安装条目默认启用,但不会自行推理,也不会自动加载共享服务 bundle `@klarkxy/dsh-ai-services`。独立部署须先显式加载该共享服务。
8
+
9
+ 闲时梦境默认开启,无需确认:会话闲置 15 分钟、距上次整理尝试满 24 小时、且自上次以来新增或变更不少于 3 条记录(含删除)时,自动做一次整理并直接生效,每天至多一次;应用只写入候选条目,不覆盖已生效记录,失败同样计入 24 小时退避。可在「设置 → 记忆」关闭自动整理,或点击「立即整理」手动运行完整流程。关闭插件会取消进行中的整理和注入,已存数据保留。