dsh-memory-metabolism 0.0.0-stage → 0.2.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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +8 -0
  3. package/README.md +130 -2
  4. package/README.zh.md +131 -0
  5. package/assets/icon-180.png +0 -0
  6. package/assets/icon.svg +36 -0
  7. package/assets/screenshots/01-dashboard.png +0 -0
  8. package/assets/screenshots/02-memory-detail.png +0 -0
  9. package/assets/screenshots/03-candidates.png +0 -0
  10. package/assets/screenshots/04-settings.png +0 -0
  11. package/assets/screenshots/05-memory-workbench.png +0 -0
  12. package/assets/screenshots/06-organizer.png +0 -0
  13. package/client.js +1048 -0
  14. package/cordis.patch.yml +4 -0
  15. package/docs/BENCHMARK.md +30 -0
  16. package/docs/DETAIL.md +148 -0
  17. package/docs/MIGRATION.md +71 -0
  18. package/index.js +65 -0
  19. package/lib/api.js +336 -0
  20. package/lib/chat/agent.js +199 -0
  21. package/lib/chat/model.js +52 -0
  22. package/lib/chat/ops.js +90 -0
  23. package/lib/chat/store.js +249 -0
  24. package/lib/chat/tools.js +163 -0
  25. package/lib/config.js +50 -0
  26. package/lib/context.js +172 -0
  27. package/lib/engines/bm25.js +69 -0
  28. package/lib/engines/consolidate.js +38 -0
  29. package/lib/engines/retrieve.js +74 -0
  30. package/lib/engines/write-gate.js +63 -0
  31. package/lib/meta.js +92 -0
  32. package/lib/migrate.js +76 -0
  33. package/lib/project.js +70 -0
  34. package/lib/service.js +351 -0
  35. package/lib/shared/fsrs.js +39 -0
  36. package/lib/shared/markdown.js +119 -0
  37. package/lib/shared/text.js +96 -0
  38. package/lib/store.js +259 -0
  39. package/lib/tools.js +216 -0
  40. package/locale/en.json +7 -0
  41. package/locale/zh.json +7 -0
  42. package/package.json +78 -3
  43. package/screenshots.json +8 -0
  44. package/templates/MEMORY.example.md +4 -0
  45. package/templates/conventions.example.md +8 -0
  46. package/templates/persona.example.md +8 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Venpor
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/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ dsh-memory-metabolism
2
+ Copyright (c) 2026 Venpor
3
+
4
+ Portions of the prompt-injection and projection architecture are derived from
5
+ dsh-memory-palace by lovezi0, released under the MIT License:
6
+ https://github.com/lovezi0/dsh-memory-palace
7
+
8
+ The memory dynamics, project scoping, storage schema and console are new work.
package/README.md CHANGED
@@ -1,3 +1,131 @@
1
- # Temporary Holding Version
1
+ # dsh-memory-metabolism
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
+ Local-first Markdown memory for DeepSeek Harness, with a full-page memory workbench and an independent memory assistant.
4
+
5
+ ![Memory workbench](assets/screenshots/05-memory-workbench.png)
6
+
7
+ *Screenshots use demo data.*
8
+
9
+ Status: 0.2.0. The Markdown store, workbench, chat and organizer are usable; retention/write thresholds remain tunable.
10
+
11
+ ## Why
12
+
13
+ DSH sessions change workspaces. Project memory should not disappear when the working directory changes, and a memory assistant should not need the main chat window or a separate agent session to edit it.
14
+
15
+ This plugin keeps memory as plain Markdown under one data directory shared by all profiles. Project memory is keyed by a stable project key, not by the current directory. The memory assistant runs inside the plugin with a fixed, restricted tool set.
16
+
17
+ ## Features
18
+
19
+ - Full-page workbench in the sidebar: overview cards, a metabolism flow, chat threads, organizer drawer and chat settings.
20
+ - Independent chat threads: new, switch, rename, fork and delete. Each thread has its own history and project.
21
+ - Restricted assistant: it can only call five memory tools (search, read, status, consolidate, apply). It cannot run commands, read files or touch the main chat.
22
+ - Streaming replies over SSE, with visible tool chips and a stop button.
23
+ - Global, project, reference and working scopes; project keys are stable across workspaces.
24
+ - Write gate, FSRS-style retention, BM25 + MMR retrieval and duplicate reports.
25
+ - Settings dashboard for memory entries, candidates, injection trace, import and thresholds.
26
+ - Theme-aware base surfaces. Progress bars and gauges use a fixed cyan/yellow/purple/green/red display palette so they stay legible on any DSH skin.
27
+ - No database, no cloud service, no telemetry.
28
+
29
+ ## Install
30
+
31
+ From npm:
32
+
33
+ dsh plugin add dsh-memory-metabolism
34
+
35
+ From a local checkout:
36
+
37
+ dsh plugin add D:/path/to/plugin-memory-metabolism
38
+
39
+ The plugin requires DSH 0.2.2-rc.5 or newer. Restart DSH after installing so the host routes and the sidebar entry load.
40
+
41
+ Do not enable this plugin together with dsh-memory-palace: both register memory_* host tools. Stop one before starting the other.
42
+
43
+ ## Quick start
44
+
45
+ 1. Open Settings -> Memory metabolism and check the data directory.
46
+ 2. Click the Memory metabolism entry in the left sidebar to open the workbench.
47
+ 3. Create a chat, send a decision or a text document, and review the tool chips.
48
+ 4. Use Organize to scan candidates and near-duplicates, then ask the assistant for a plan.
49
+ 5. Use the settings dashboard for entry edits, candidate approval and legacy import.
50
+
51
+ ## Scopes
52
+
53
+ - global: cross-project preferences, hard constraints and long-lived facts.
54
+ - project: decisions and pitfalls for one project key.
55
+ - reference: long documents and manuals; retrieval only.
56
+ - working: short-lived notes; not injected as long-term memory.
57
+
58
+ ## Project key
59
+
60
+ Resolution order:
61
+
62
+ 1. A .dsh-project or .memory-metabolism-project marker file.
63
+ 2. The first matching projectMap prefix or regular expression.
64
+ 3. The git root directory name.
65
+ 4. The current directory name.
66
+
67
+ The key is not tied to the directory path, so moving a project does not lose its memory. CJK directory names are preserved as project keys.
68
+
69
+ ## Data layout
70
+
71
+ ~/.dsh/memory-metabolism/
72
+ global/MEMORY.md
73
+ projects/<key>/MEMORY.md
74
+ reference/<name>.md
75
+ working/MEMORY.md
76
+ archive/
77
+ backups/
78
+ meta/index.json
79
+ chats/index.json
80
+ chats/<id>.json
81
+
82
+ Memory is human-editable Markdown. Entry ids live in hidden HTML comments. Chat logs are local JSON and are not injected into memory.
83
+
84
+ ## Configuration
85
+
86
+ | Key | Default | Meaning |
87
+ | --- | --- | --- |
88
+ | dataDir | ~/.dsh/memory-metabolism | Shared data directory |
89
+ | maxInjectionChars | 6000 | Per-file injection budget |
90
+ | retrieveTopK | 8 | Retrieval depth |
91
+ | writeThreshold | 0.65 | Direct-write threshold |
92
+ | candidateThreshold | 0.45 | Candidate threshold |
93
+ | staleDays | 30 | Fading window |
94
+ | archiveRetrievability | 0.2 | Archive threshold |
95
+ | assistantModel | empty | Chat provider/model; empty = last session model, then first available |
96
+ | assistantMaxInputChars | 120000 | Document limit for chat attachments |
97
+ | chatHistoryChars | 24000 | Prior chat text sent back to the model |
98
+ | chatMaxRounds | 6 | Tool-call rounds per chat turn |
99
+
100
+ The workbench settings drawer edits the chat-specific values. The settings dashboard edits memory thresholds.
101
+
102
+ ## Privacy and security
103
+
104
+ - Memory, chat logs and metadata stay under the data directory you choose.
105
+ - The workbench sends the current message, recent chat history, a compact memory summary and the attached text to the configured DSH model provider.
106
+ - The assistant's tool list is fixed at five memory operations. It has no filesystem, shell, network or main-session tools.
107
+ - HTTP routes require the x-memory-metabolism header and pass the host request gate when one exists.
108
+ - Do not paste credentials, tokens or passwords into memory or chat. The console does not redact them.
109
+
110
+ ## Migration from dsh-memory-palace
111
+
112
+ The plugin can import legacy user and workspace memory without modifying the source files. Use Settings -> Memory metabolism -> Legacy import. The import reads ~/.deepseek-harness/MEMORY.md and workspace .deepseek-harness, .workbuddy and .codebuddy memory files. It writes a dry-run report by default.
113
+
114
+ ## Development
115
+
116
+ node tests/core.mjs
117
+ node tests/api.mjs
118
+ node tests/chat-store.mjs
119
+ node tests/chat-tools.mjs
120
+ node tests/chat-agent.mjs
121
+ npm pack --dry-run
122
+
123
+ The chat agent test uses an injected host kit, so it does not need a live DSH process.
124
+
125
+ ## Credits
126
+
127
+ Architecture and projection approach informed by dsh-memory-palace (MIT). The full-page sidebar/main entry follows the dsh-github-flow slot pattern. See NOTICE.
128
+
129
+ ## License
130
+
131
+ MIT.
package/README.zh.md ADDED
@@ -0,0 +1,131 @@
1
+ # dsh-memory-metabolism / 记忆代谢
2
+
3
+ 面向 DeepSeek Harness 的本地 Markdown 记忆:全页记忆工作台 + 独立记忆助手。
4
+
5
+ ![记忆工作台](assets/screenshots/05-memory-workbench.png)
6
+
7
+ *截图为演示数据。*
8
+
9
+ 状态:0.2.0。记忆存储、工作台、聊天和整理已可用;写入阈值和留存参数仍可调整。
10
+
11
+ ## 为什么
12
+
13
+ DSH 会话会换工作区。项目记忆不应该跟着当前目录消失,记忆助手也不应该必须借用主聊天窗口或另开一个 DSH 会话。
14
+
15
+ 插件把记忆保存为同一数据目录下的纯 Markdown,所有 profile 共用。项目记忆按稳定的 project key 分片,不跟 cwd 绑定。记忆助手在插件内部运行,只有固定的记忆工具。
16
+
17
+ ## 功能
18
+
19
+ - 左侧边栏的全页工作台:概览卡片、代谢流程、对话线程、整理抽屉、聊天设置。
20
+ - 独立对话线程:新建、切换、重命名、Fork、删除;每线程独立历史与项目。
21
+ - 受限助手:只能调用 5 个记忆工具(搜索、读取、状态、重复检查、应用)。不能跑命令、读文件或碰主聊天。
22
+ - SSE 流式回复、工具 chip、停止生成。
23
+ - 全局、项目、reference、工作记忆四种作用域;项目 key 跨工作区稳定。
24
+ - 写入门、FSRS 风格留存、BM25 + MMR 召回、重复报告。
25
+ - 设置页记忆面板:条目、候选、注入 trace、导入、阈值。
26
+ - 底层颜色跟随 DSH 皮肤;进度条/仪表使用固定的青、黄、紫、绿、红显示色板,换皮肤也可读。
27
+ - 无数据库、无云服务、无遥测。
28
+
29
+ ## 安装
30
+
31
+ npm:
32
+
33
+ dsh plugin add dsh-memory-metabolism
34
+
35
+ 本地目录:
36
+
37
+ dsh plugin add D:/path/to/plugin-memory-metabolism
38
+
39
+ 需要 DSH 0.2.2-rc.5 或更新。安装后重启 DSH,宿主路由和侧边栏入口才会加载。
40
+
41
+ 不要和 dsh-memory-palace 同时启用:两者都注册 memory_* 宿主工具,先停用其中一个。
42
+
43
+ ## 快速开始
44
+
45
+ 1. 打开 设置 -> 记忆代谢,确认数据目录。
46
+ 2. 点左侧边栏「记忆代谢」打开工作台。
47
+ 3. 新建对话,发一条决策或一个文本文件,查看工具 chip。
48
+ 4. 点「整理」扫描候选和近似重复,再让助手给方案。
49
+ 5. 设置页的记忆面板用于编辑条目、批准候选和导入旧记忆。
50
+
51
+ ## 作用域
52
+
53
+ - global:跨项目偏好、硬约束、长期事实。
54
+ - project:某个项目 key 的决策和踩坑。
55
+ - reference:长文档和手册,只做检索。
56
+ - working:短期笔记,不进入长期注入。
57
+
58
+ ## 项目 key
59
+
60
+ 解析顺序:
61
+
62
+ 1. .dsh-project 或 .memory-metabolism-project 标记文件。
63
+ 2. projectMap 的 prefix / 正则。
64
+ 3. git 根目录名。
65
+ 4. 当前目录名。
66
+
67
+ 项目 key 不跟路径绑定,移动项目不会丢记忆。中文目录名会原样保留。
68
+
69
+ ## 数据目录
70
+
71
+ ~/.dsh/memory-metabolism/
72
+ global/MEMORY.md
73
+ projects/<key>/MEMORY.md
74
+ reference/<name>.md
75
+ working/MEMORY.md
76
+ archive/
77
+ backups/
78
+ meta/index.json
79
+ chats/index.json
80
+ chats/<id>.json
81
+
82
+ 记忆是可手改的 Markdown,条目 id 在隐藏 HTML 注释里。聊天日志是本地 JSON,不注入记忆。
83
+
84
+ ## 配置
85
+
86
+ | 键 | 默认 | 含义 |
87
+ | --- | --- | --- |
88
+ | dataDir | ~/.dsh/memory-metabolism | 共享数据目录 |
89
+ | maxInjectionChars | 6000 | 每个文件的注入预算 |
90
+ | retrieveTopK | 8 | 召回条数 |
91
+ | writeThreshold | 0.65 | 直接写入阈值 |
92
+ | candidateThreshold | 0.45 | 候选阈值 |
93
+ | staleDays | 30 | 淡忘窗口 |
94
+ | archiveRetrievability | 0.2 | 归档阈值 |
95
+ | assistantModel | 空 | 聊天模型;空=最近会话模型,再回落第一个可用 |
96
+ | assistantMaxInputChars | 120000 | 聊天文档上限 |
97
+ | chatHistoryChars | 24000 | 回喂给模型的历史字符 |
98
+ | chatMaxRounds | 6 | 每轮聊天最多工具轮数 |
99
+
100
+ 工作台设置抽屉改聊天项;设置页记忆面板改记忆阈值。
101
+
102
+ ## 隐私与安全
103
+
104
+ - 记忆、聊天日志和元数据都在你选择的数据目录。
105
+ - 工作台会把当前消息、最近历史、精简记忆摘要和附件文本发给你配置的 DSH 模型。
106
+ - 助手的工具白名单固定为 5 个记忆操作;没有文件、shell、网络或主会话工具。
107
+ - HTTP 路由要求 x-memory-metabolism 头,并经过宿主请求门。
108
+ - 不要把密钥、token、密码写进记忆或聊天;控制台不会自动脱敏。
109
+
110
+ ## 从 dsh-memory-palace 迁移
111
+
112
+ 在 设置 -> 记忆代谢 -> 从旧记忆导入 里先 dry run,再执行导入。插件会读取用户级和当前工作区的旧记忆文件,不修改源文件。
113
+
114
+ ## 开发
115
+
116
+ node tests/core.mjs
117
+ node tests/api.mjs
118
+ node tests/chat-store.mjs
119
+ node tests/chat-tools.mjs
120
+ node tests/chat-agent.mjs
121
+ npm pack --dry-run
122
+
123
+ 聊天 agent 测试使用注入的 host kit,不需要真实 DSH 进程。
124
+
125
+ ## 致谢
126
+
127
+ 架构和投影方式参考 dsh-memory-palace(MIT);全页 sidebar/main 入口参考 dsh-github-flow 的 slot 方式。见 NOTICE。
128
+
129
+ ## License
130
+
131
+ MIT。
Binary file
@@ -0,0 +1,36 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 180" width="180" height="180">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#0a1020"/>
5
+ <stop offset="1" stop-color="#111a30"/>
6
+ </linearGradient>
7
+ <linearGradient id="wave" x1="0" y1="0" x2="1" y2="0">
8
+ <stop offset="0" stop-color="#22d3ee"/>
9
+ <stop offset="1" stop-color="#818cf8"/>
10
+ </linearGradient>
11
+ <radialGradient id="glow" cx="50%" cy="50%" r="50%">
12
+ <stop offset="0" stop-color="#22d3ee" stop-opacity=".30"/>
13
+ <stop offset="1" stop-color="#22d3ee" stop-opacity="0"/>
14
+ </radialGradient>
15
+ </defs>
16
+ <rect x="6" y="6" width="168" height="168" rx="38" fill="url(#bg)" stroke="#3c5078" stroke-width="2"/>
17
+ <circle cx="38" cy="40" r="46" fill="url(#glow)"/>
18
+ <g stroke="#6366f1" stroke-opacity=".55" stroke-width="3">
19
+ <line x1="48" y1="112" x2="78" y2="72"/>
20
+ <line x1="78" y1="72" x2="112" y2="96"/>
21
+ <line x1="112" y1="96" x2="138" y2="54"/>
22
+ <line x1="112" y1="96" x2="104" y2="132"/>
23
+ <line x1="78" y1="72" x2="104" y2="132"/>
24
+ <line x1="48" y1="112" x2="104" y2="132"/>
25
+ </g>
26
+ <path d="M30 96 C45 70, 58 122, 76 94 S104 66, 122 96 S146 118, 150 92" fill="none" stroke="url(#wave)" stroke-width="3" stroke-linecap="round" opacity=".9"/>
27
+ <g fill="#22d3ee" stroke="#e6f0ff" stroke-width="2">
28
+ <circle cx="48" cy="112" r="6"/>
29
+ <circle cx="112" cy="96" r="8"/>
30
+ <circle cx="104" cy="132" r="6"/>
31
+ </g>
32
+ <g fill="#a855f7" stroke="#e6f0ff" stroke-width="2">
33
+ <circle cx="78" cy="72" r="8"/>
34
+ <circle cx="138" cy="54" r="6"/>
35
+ </g>
36
+ </svg>