dsh-plugin-xujie-memory 0.0.0-stage → 0.5.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 (75) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE +21 -0
  3. package/README.md +223 -2
  4. package/README_EN.md +92 -0
  5. package/cordis.patch.yml +49 -0
  6. package/lib/index.js +483 -0
  7. package/package.json +31 -4
  8. package/python/specs/characters/aloof.json +14 -0
  9. package/python/specs/characters/gentle.json +14 -0
  10. package/python/specs/characters/tsundere.json +14 -0
  11. package/python/specs/debt.v1.json +31 -0
  12. package/python/specs/nickname.v1.json +16 -0
  13. package/python/specs/preference.v1.json +16 -0
  14. package/python/xujie_memory/__init__.py +123 -0
  15. package/python/xujie_memory/admission.py +211 -0
  16. package/python/xujie_memory/audit.py +377 -0
  17. package/python/xujie_memory/benchmark.py +281 -0
  18. package/python/xujie_memory/character.py +199 -0
  19. package/python/xujie_memory/console.py +41 -0
  20. package/python/xujie_memory/consolidate.py +356 -0
  21. package/python/xujie_memory/decay.py +483 -0
  22. package/python/xujie_memory/detect.py +1280 -0
  23. package/python/xujie_memory/due.py +121 -0
  24. package/python/xujie_memory/emotion.py +573 -0
  25. package/python/xujie_memory/encoder.py +1205 -0
  26. package/python/xujie_memory/engine.py +1312 -0
  27. package/python/xujie_memory/errors.py +98 -0
  28. package/python/xujie_memory/gate.py +448 -0
  29. package/python/xujie_memory/importance.py +104 -0
  30. package/python/xujie_memory/ingest.py +2490 -0
  31. package/python/xujie_memory/judge.py +350 -0
  32. package/python/xujie_memory/memory.py +222 -0
  33. package/python/xujie_memory/orchestrator.py +666 -0
  34. package/python/xujie_memory/phrasing.py +292 -0
  35. package/python/xujie_memory/profile.py +689 -0
  36. package/python/xujie_memory/recall.py +431 -0
  37. package/python/xujie_memory/schema.sql +480 -0
  38. package/python/xujie_memory/server.py +560 -0
  39. package/python/xujie_memory/specs.py +170 -0
  40. package/python/xujie_memory/summary.py +238 -0
  41. package/runtime/win32-x64/LICENSE.txt +702 -0
  42. package/runtime/win32-x64/_asyncio.pyd +0 -0
  43. package/runtime/win32-x64/_bz2.pyd +0 -0
  44. package/runtime/win32-x64/_ctypes.pyd +0 -0
  45. package/runtime/win32-x64/_decimal.pyd +0 -0
  46. package/runtime/win32-x64/_elementtree.pyd +0 -0
  47. package/runtime/win32-x64/_hashlib.pyd +0 -0
  48. package/runtime/win32-x64/_lzma.pyd +0 -0
  49. package/runtime/win32-x64/_msi.pyd +0 -0
  50. package/runtime/win32-x64/_multiprocessing.pyd +0 -0
  51. package/runtime/win32-x64/_overlapped.pyd +0 -0
  52. package/runtime/win32-x64/_queue.pyd +0 -0
  53. package/runtime/win32-x64/_socket.pyd +0 -0
  54. package/runtime/win32-x64/_sqlite3.pyd +0 -0
  55. package/runtime/win32-x64/_ssl.pyd +0 -0
  56. package/runtime/win32-x64/_uuid.pyd +0 -0
  57. package/runtime/win32-x64/_wmi.pyd +0 -0
  58. package/runtime/win32-x64/_zoneinfo.pyd +0 -0
  59. package/runtime/win32-x64/libcrypto-3.dll +0 -0
  60. package/runtime/win32-x64/libffi-8.dll +0 -0
  61. package/runtime/win32-x64/libssl-3.dll +0 -0
  62. package/runtime/win32-x64/pyexpat.pyd +0 -0
  63. package/runtime/win32-x64/python.cat +0 -0
  64. package/runtime/win32-x64/python.exe +0 -0
  65. package/runtime/win32-x64/python3.dll +0 -0
  66. package/runtime/win32-x64/python312._pth +6 -0
  67. package/runtime/win32-x64/python312.dll +0 -0
  68. package/runtime/win32-x64/python312.zip +0 -0
  69. package/runtime/win32-x64/pythonw.exe +0 -0
  70. package/runtime/win32-x64/select.pyd +0 -0
  71. package/runtime/win32-x64/sqlite3.dll +0 -0
  72. package/runtime/win32-x64/unicodedata.pyd +0 -0
  73. package/runtime/win32-x64/vcruntime140.dll +0 -0
  74. package/runtime/win32-x64/vcruntime140_1.dll +0 -0
  75. package/runtime/win32-x64/winsound.pyd +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ ## 0.5.0(内核 0.52.0)
4
+
5
+ ### 性能
6
+ - 画像派生改为增量:旧版每轮全量重算、并且被调用两次,会话攒到约 1500 条后单轮要 1.5–2 秒,超过宿主 4 秒超时就静默失效。现在 2000 条时 p50 约 10ms,3000 条只做全量派生时 p50 约 6ms。
7
+ - 补了 4 个索引;WAL 下 `synchronous=NORMAL`、`busy_timeout=30s`。
8
+ - 模糊检索只预处理一次查询,内容侧加缓存。
9
+
10
+ ### 稳定性
11
+ - 插件加看门狗:内核崩溃或被别的实例带走后,按 2s/4s/8s… 退避自动拉起。
12
+ - `/health` 返回版本、库路径、范围模式;端口上是旧版或别人的服务就自动换端口(最多 10 个)。
13
+ - 内核带 `--parent-pid`,宿主崩溃后 3 秒内自动退出,不留占端口的孤儿进程。
14
+ - 内核日志写到 `kernel.log`(旧版 `stdio:'ignore'` 全部丢失)。
15
+ - 同一会话的请求串行,快速连发不会乱序;内核正被重拉时连不上会重试一次,超时不重试(避免重复记录)。
16
+ - 换人嫌疑会自动解除:用户明确改称呼时直接解除,超过 30 分钟也会解除。旧版一句「以后叫我老王」就会让画像永久冻结。
17
+ - 内核改为 HTTP/1.1 keep-alive;提前拒绝的请求会主动断开连接,避免未读的请求体污染同一连接上的下一次请求。
18
+ - FTS 查询转义双引号:旧版用户消息里带 `"` 时整轮返回 500。
19
+
20
+ ### 长期记忆
21
+ - 默认 `scope: user`:画像、偏好、锚点、账跨会话共享;追问熔断仍然按会话计算。`scope: session` 可恢复旧行为。
22
+ - 去掉 session 模式下的跨会话 `lastContext` 兜底。
23
+
24
+ ### 准确率(回归集 `test/kernel_regression.py`,31/31)
25
+ - 问句不再生成事实(「你还记得我欠谁钱吗」)。
26
+ - 「还/本/书/瓶」等单字不再触发记账;日期里的数字(周五、四月)不再当成数量。
27
+ - 无领域词的闲聊(「哈哈」「我女朋友叫小美」)不再落成偏好。
28
+ - 偏好极性:识别「不讨厌/能吃/开始喜欢/过敏」;对象会清理多余字(「辣了」记成「辣」),改口时覆盖旧值,旧标签标成已纠正。
29
+ - 称呼明说即生效(宿主没有确认交互,旧版会永远挂起)。
30
+ - 第三方债主:「我欠老李500」「老李的钱还了300」能正确记账;材料新增「账目(已确认)」一节,直接给出余额。
31
+ - 锚点去掉「这个:」之类的指令前缀;待确认项会附上原话。
32
+ - 检索修复:当前这句不再挡住模糊兜底,相关旧事能召回。
33
+ - 插件 `peer_id` 改成 `assistant`(旧版是 `user`,「我欠你」会记成自己欠自己)。
34
+
35
+ ### 安全
36
+ - 请求必须带 `X-Xujie-Token`(token 文件权限为 0600),且只接受 `application/json`,本机网页无法再往记忆里写东西。
37
+ - 请求体上限 256KB,正文截断到 2000 字;参数类型错误返回 400,不再返回 500。
38
+
39
+ ### 打包
40
+ - 删除了无用的 cpython-313 `__pycache__`(内置运行时是 3.12)。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shoren-Syi
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,224 @@
1
- # Temporary Holding Version
1
+ # dsh-plugin-xujie-memory
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](README_EN.md) | 简体中文
4
+
5
+ 为 DeepSeek Harness(DSH)打造的无感长期记忆插件。
6
+
7
+ **记忆的价值在于不用想。** Xujie-Memory 自动记录相关信息,并在对话中组装记忆材料、注入提示词,无需模型决定是否调用记忆工具。Windows x64 包含运行时,按安装说明接入后一般无需额外配置。
8
+
9
+ ## 工作流程
10
+
11
+ ```mermaid
12
+ flowchart LR
13
+ A[会话事件] --> B[过滤用户消息与注入内容]
14
+ B --> C[语义提取与准入闸门]
15
+ C --> D[SQLite 事件记录与状态投影]
16
+ D --> E[权重衰减与相关记忆召回]
17
+ E --> F[精确检索及模糊匹配]
18
+ F --> G[组装三层记忆材料]
19
+ G --> H[通过 Prompt section 自动注入]
20
+ ```
21
+
22
+ 事件记录与状态投影支持追溯和重放;情节记忆、人物卡等也有各自的存储结构。默认同步 section 读取缓存,宿主时序可能使本轮看到上一轮材料,详见下方「记忆范围」。
23
+
24
+ ## 与工具调用式记忆对比
25
+
26
+ | 维度 | 常见工具调用式记忆 | Xujie-Memory |
27
+ |---|---|---|
28
+ | 模型是否需要决定检索 | 通常需要主动调用工具 | 自动组装并注入,无需模型决定是否调用 |
29
+ | 记忆组织 | 取决于具体实现 | 语义、情节、工作三层 |
30
+ | 延迟 | 取决于工具调用和实现 | 内核请求有开销;默认同步读取缓存,异步模式会等待材料 |
31
+ | 追问控制 | 取决于实现和提示词 | 同一条只问一次,每轮最多一件,默认每会话最多六次 |
32
+ | 衰减与模糊召回 | 取决于具体实现 | 支持权重衰减与模糊搜索 |
33
+
34
+ 此表比较常见设计方式,具体工具调用方案的功能和性能可能不同。
35
+
36
+ 装上去之后,DSH 会**在每轮对话里自动**做三件事:
37
+
38
+ 1. 把你说的话判定成事实(欠账 / 偏好 / 称呼 / 承诺),写进本地库
39
+ 2. 把"这个人是谁、我现在记得什么、他专门交代过要记住什么"注入提示词
40
+ 3. 你没说清楚的地方,**最多问一次**,问过就不再提
41
+
42
+ 它不是"给模型一个 `memory_search` 工具"——工具要模型自己想起来用,
43
+ 而记忆的价值恰恰在于**不用想**。
44
+
45
+ ### 三层记忆(当前版本 0.5.0)
46
+
47
+ | 层 | 内容 | 你怎么用 |
48
+ |---|---|---|
49
+ | 语义 | 人物卡、事实、锚点 | 自动注入「关于这个人 / 重要的事」 |
50
+ | 情节 | 原话、摘要 | 相关旧事自动浮上来;可模糊搜(错字也能中) |
51
+ | 工作 | 最近几句、未确认项 | 自动注入「最近说过的话 / 还没确定的事」 |
52
+
53
+ **重点标注**:AI 会先自动判断一句话值不值得记——身份、强偏好、承诺、健康/钱/
54
+ 关系、情绪强度会提高权重(1–5),寒暄天气降低;聊天里说「记住这个」才会
55
+ 钉成锚点。自动分只决定「淡得慢一点」,5.0 和锚点留给用户明说。
56
+
57
+ 代码/后台也可以用 `POST /memory/mark` 手动标 1–5 级重要性。
58
+
59
+ **遗忘曲线**:`POST /memory/curve` 看重放出来的权重历史;检索命中不会重置衰减。
60
+
61
+ **模糊搜索**:`POST /memory/search`,两字词、错一个字都能捞;
62
+ 精确检索落空时,自动注入也会降级到模糊匹配。
63
+
64
+ 本仓库保留 0.5.0 发布包中的内核;上表概括了三层记忆。
65
+
66
+ ---
67
+
68
+ ## 装上就能用(用户零动作)
69
+
70
+ | | |
71
+ |---|---|
72
+ | DSH | 0.2 预览版(`dsh.bundle` 机制) |
73
+ | Node | `^22.19 \|\| >=24` |
74
+ | Python | **不用装**:Windows x64 包里自带解释器 |
75
+ | 内核 | **不用装**:Python 内核(`python/xujie_memory`)在包里 |
76
+
77
+ ```bash
78
+ dsh plugin --profile <你的profile> add <解压后的 dsh-plugin-xujie-memory 目录>
79
+ # 新开一个会话即可
80
+ ```
81
+
82
+ 仓库公开后,也可以从 GitHub 安装指定版本:
83
+
84
+ ```bash
85
+ dsh plugin --profile <你的profile> add github:Shoren-Syi/dsh-plugin-xujie-memory#v0.5.0
86
+ ```
87
+
88
+ 不需要 `pip install`,不需要填 `repoPath`,不需要另外起服务:
89
+
90
+ - 插件用**包内解释器**(`runtime/win32-x64/python.exe`)拉起**包内内核**
91
+ (`python/xujie_memory`),数据默认落在 `~/.xujie-memory/memory.db`。
92
+ - 内核路径 / 解释器路径都在 `lib/index.js` 里按 `import.meta.url` 自解析;
93
+ 只有开发时才需要 `repoPath` / `pythonPath` 覆盖。
94
+ - 内核挂了只影响"这一轮没有记忆",**不影响对话**。
95
+
96
+ > 平台说明:当前包内自带 **Windows x64** 解释器。macOS / Linux 会回退到
97
+ > 系统 `python3`(内核零第三方依赖,3.10+ 即可);要完全零依赖,需要给
98
+ > 对应平台补 `runtime/<平台>-<架构>/`。
99
+
100
+ 可选配置(写在 profile 的 `cordis.patch.yml`,一般不用动):
101
+
102
+ ```yaml
103
+ - id: xujie-memory
104
+ config:
105
+ endpoint: "http://127.0.0.1:8765" # 内核端口
106
+ autoStart: true # 由插件拉起内核
107
+ dbPath: "" # 留空 = ~/.xujie-memory/memory.db
108
+ statusFile: "" # 填文件路径可把挂载/就绪状态写进去(排查用)
109
+ maxAskedTotal: 6 # 一个会话最多主动追问几次
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 你会看到什么
115
+
116
+ 材料会变成提示词里的一段:
117
+
118
+ ```
119
+ ## 关于这个人
120
+ - 他说过:偏好不吃辣
121
+
122
+ ## 重要的事(他专门说过要记住,不会随时间淡去)
123
+ - 四月十二号那天项目上线,我们熬到凌晨四点。
124
+
125
+ ## 还没确定的事
126
+ - 需要确认这句话是不是这个意思
127
+ (如果用户当前这句其实已经说清楚了,就当它确认了;否则最多挑一件顺带问一句,别追问)
128
+ ```
129
+
130
+ ---
131
+
132
+ ## 追问有熔断
133
+
134
+ | 闸 | 行为 |
135
+ |---|---|
136
+ | 同一条只念一次 | 念过就标 `asked_at`,第二遍不再进材料 |
137
+ | 一轮最多一件 | `TurnBudget.max_questions = 1` |
138
+ | 一个会话最多 6 次 | 超过之后材料里只剩一句总数,**不再引导追问** |
139
+
140
+ 熔断之后那些记录还在库里,用户主动提起来时照样能用——**不问 ≠ 忘了**。
141
+
142
+ ---
143
+
144
+ ## 记忆范围
145
+
146
+ 默认 `scope: user`:人物卡、偏好、锚点、账**跨会话有效**——新开会话也认识你。
147
+ 「最多追问几次」的熔断仍按会话算。
148
+
149
+ 想要 0.4 的行为(每个会话一份、互不相通)就设 `scope: session`;
150
+ 这种模式下没有会话上下文的组装返回空,绝不串会话。
151
+
152
+ 插件按会话缓存材料(最多 32 个)。注意:`section.text` 是同步读缓存的,
153
+ 宿主如果在 `/turn` 返回前就拼提示词,本轮用的是上一轮的材料(单轮内核耗时通常 <15ms)。
154
+ 宿主支持异步 section 时可开 `asyncSection: true`。
155
+
156
+ ## 可靠性
157
+
158
+ - 看门狗每 5 秒查一次内核,挂了按退避自动拉起;日志在 `~/.xujie-memory/kernel.log`。
159
+ - `/health` 返回版本、库路径;端口上是旧版或别的服务就自动换端口。
160
+ - 内核跟随宿主进程退出,不留孤儿进程。
161
+ - 请求要带 `X-Xujie-Token`(`~/.xujie-memory/token`),并且只收 `application/json`。
162
+
163
+ ---
164
+
165
+ ## 事件(已按真机核对)
166
+
167
+ `session/event` 里只有 `user/message` 会写记忆:
168
+
169
+ | 类型 | 插件行为 |
170
+ |---|---|
171
+ | `user/message` | **写记忆**,正文在 `event.data.content[]` 的 `text` 块里 |
172
+ | `assistant/message` | 跳过 |
173
+ | `tool/call` / `tool/result` / `step/end` / `turn/start` | 跳过 |
174
+
175
+ 两个容易踩的点,插件里已经处理:
176
+
177
+ 1. **正文在 `data.content` 数组里**,不是 `event.content`。
178
+ 2. **注入消息也是 `user/message`**(`source.kind = runtime-context` /
179
+ `agent-instructions` 等),它们不是用户说的,会被跳过——否则提示词
180
+ 会被当成"用户说的事实"记进库里。
181
+
182
+ ---
183
+
184
+ ## 排查
185
+
186
+ ```bash
187
+ # 只想确认插件挂上了、内核起来了:在 profile 配置里设 statusFile,
188
+ # 启动后看文件里有没有这两行:
189
+ # info 已挂载,内核在 http://127.0.0.1:8765
190
+ # info 内核就绪(xxxms):http://127.0.0.1:8765
191
+
192
+ # 手动跑内核(诊断用;用插件包内的解释器)
193
+ runtime/win32-x64/python.exe -m xujie_memory.server --port 8765 --token-file %USERPROFILE%\.xujie-memory\token
194
+
195
+ # 直接打一轮,看材料长什么样
196
+ curl -s --noproxy '*' -X POST http://127.0.0.1:8765/turn \
197
+ -H "Content-Type: application/json" \
198
+ -H "X-Xujie-Token: $(cat ~/.xujie-memory/token)" \
199
+ -d '{"session":"t1","user":"owner","text":"我不吃辣"}'
200
+ ```
201
+
202
+ **记忆服务挂了不该让人没法说话。**
203
+
204
+ ---
205
+
206
+ ## 结构
207
+
208
+ ```
209
+ dsh-plugin-xujie-memory/
210
+ ├── lib/index.js # 薄壳:挂 section / 收事件 / 起内核
211
+ ├── python/xujie_memory # Python 内核(零第三方依赖)
212
+ ├── python/specs # 判定规则
213
+ ├── runtime/win32-x64/ # 自带解释器(Windows)
214
+ └── cordis.patch.yml # bundle patch(DSH 0.2 顶层数组格式)
215
+ ```
216
+
217
+ 逻辑全在 Python 侧,插件只是个薄壳——DSH 还是预览版,API 会变,
218
+ 把不稳定的部分做薄。
219
+
220
+ ## 开发验证
221
+
222
+ `npm test` 运行插件与内核的集成冒烟测试,覆盖会话隔离和注入消息过滤;Windows x64 默认使用包内 Python,其他平台需要 Python 3.10+,也可通过 `PYTHON` 环境变量指定解释器。执行 `npm pack` 可打包当前仓库自带的内核。
223
+
224
+ 本仓库由 0.5.0 发布包恢复。原先的回归测试集因之前的沙箱重置而丢失,发布包中也没有包含原来的 `test/kernel_regression.py` 和内核同步脚本。CHANGELOG 中的 31/31 是历史记录,当前仓库无法复现该回归集;冒烟测试不代表这 31 项回归已通过。
package/README_EN.md ADDED
@@ -0,0 +1,92 @@
1
+ # dsh-plugin-xujie-memory
2
+
3
+ [简体中文](README.md) | English
4
+
5
+ Seamless long-term memory built for DeepSeek Harness (DSH).
6
+
7
+ **The value of memory is not having to think about it.** Xujie-Memory records relevant information locally, assembles memory context, and injects it into the prompt without asking the model to decide whether to call a memory tool. The Windows x64 package includes a runtime and generally requires no extra configuration after installation.
8
+
9
+ ## Architecture
10
+
11
+ ```mermaid
12
+ flowchart LR
13
+ A[Session events] --> B[Filter user messages and injected content]
14
+ B --> C[Semantic extraction and admission gates]
15
+ C --> D[SQLite event records and state projections]
16
+ D --> E[Weight decay and relevant memory recall]
17
+ E --> F[Exact and fuzzy matching]
18
+ F --> G[Assemble three memory layers]
19
+ G --> H[Inject through a prompt section]
20
+ ```
21
+
22
+ Events and projections support traceability and replay; episodic memory and person profiles also have their own storage structures. The default synchronous prompt section reads a cache, so host timing can make the current turn use the previous turn's material. See **Timing and scope** below.
23
+
24
+ | Feature | Typical tool-calling memory | Xujie-Memory |
25
+ |---|---|---|
26
+ | Retrieval decision | The model usually decides when to call a tool | Context is assembled and injected automatically |
27
+ | Organization | Depends on the implementation | Semantic, episodic, and working memory |
28
+ | Latency | Depends on the tool and implementation | Kernel requests have a cost; the default section reads a cache, while asynchronous mode waits for material |
29
+ | Follow-up limits | Depends on the implementation and prompt | Each item is asked once; at most one per turn and six per session by default |
30
+ | Decay and fuzzy recall | Depends on the implementation | Supports weight decay and fuzzy search |
31
+
32
+ This compares common design approaches; individual tool-based systems can differ in features and performance.
33
+
34
+ ## Memory layers
35
+
36
+ - **Semantic:** person card, facts, and explicitly pinned anchors.
37
+ - **Episodic:** original wording and summaries, with fuzzy search for related past events.
38
+ - **Working:** recent messages and unresolved items.
39
+
40
+ Importance scoring affects how slowly memories fade. Explicit requests such as “remember this” pin an anchor. Retrieval does not reset decay. The kernel also exposes `/memory/mark`, `/memory/curve`, and `/memory/search` endpoints.
41
+
42
+ ## Installation
43
+
44
+ The package targets the DSH 0.2 preview bundle mechanism and Node.js `^22.19 || >=24`. Windows x64 includes Python and the kernel; no separate Python installation or pip dependencies are needed. On macOS and Linux it falls back to system Python 3.10 or newer.
45
+
46
+ ```bash
47
+ dsh plugin --profile <your-profile> add <path-to-extracted-dsh-plugin-xujie-memory>
48
+ ```
49
+
50
+ When the repository is public, install the tagged version directly from GitHub:
51
+
52
+ ```bash
53
+ dsh plugin --profile <your-profile> add github:Shoren-Syi/dsh-plugin-xujie-memory#v0.5.0
54
+ ```
55
+
56
+ Start a new session. The plugin starts the bundled kernel automatically. By default the database is stored at `~/.xujie-memory/memory.db`. Kernel failure skips memory for that turn rather than blocking the conversation.
57
+
58
+ Optional profile configuration:
59
+
60
+ ```yaml
61
+ - id: xujie-memory
62
+ config:
63
+ endpoint: "http://127.0.0.1:8765"
64
+ autoStart: true
65
+ dbPath: ""
66
+ statusFile: ""
67
+ maxAskedTotal: 6
68
+ ```
69
+
70
+ Set `statusFile` to a path to record mounting and readiness status. The kernel watchdog checks every five seconds and restarts with backoff; logs are written to `~/.xujie-memory/kernel.log`. Requests require JSON and the `X-Xujie-Token` stored at `~/.xujie-memory/token`.
71
+
72
+ ## Timing and scope
73
+
74
+ The default `scope: user` shares facts, preferences, anchors, and the person card across sessions. Set `scope: session` for session isolation. The follow-up limit is per session in either mode.
75
+
76
+ The plugin caches material for up to 32 sessions. The default synchronous `section.text` reads the cache; if the host assembles the prompt before `/turn` completes, it uses the previous turn's material. Set `asyncSection: true` only when the host supports an asynchronous section.
77
+
78
+ Only `user/message` events are ingested. Runtime context and agent-instruction messages are filtered out, as are assistant and tool events. Each unresolved item is asked at most once; the default session limit is six follow-ups. Reaching the limit does not delete the records.
79
+
80
+ ## Package contents
81
+
82
+ ```text
83
+ lib/index.js DSH integration and kernel lifecycle
84
+ python/xujie_memory/ Python memory kernel
85
+ python/specs/ Interpretation rules
86
+ runtime/win32-x64/ Bundled Windows x64 Python runtime
87
+ cordis.patch.yml DSH bundle patch
88
+ ```
89
+
90
+ This repository was reconstructed from the distributed 0.5.0 package. Run `npm test` for the integration smoke test and `npm pack` to package the bundled kernel. Windows x64 uses the bundled Python runtime; other platforms need Python 3.10 or newer. Set `PYTHON` to use a specific interpreter for the smoke test.
91
+
92
+ The original regression suite was lost when the previous sandbox was reset. The distribution did not include `test/kernel_regression.py` or the kernel synchronization script. The 31/31 result in the changelog is historical and cannot be reproduced from this repository; the smoke test does not replace that regression suite.
@@ -0,0 +1,49 @@
1
+ # 这个 bundle 往配置树里插的一行。
2
+ #
3
+ # `name` 必须是包的**名字**(和 package.json 的 name 一致),
4
+ # `id` 是用户之后覆盖配置时的定位锚点——要稳定,不要和别的插件重名。
5
+ #
6
+ # 注意:DSH 0.2.1-rc.2 要求 patch 文件是**顶层数组**,所以整份内容放在
7
+ # 一个 `- insert:` 列表项里(映射形式会被插件安装校验拒绝)。
8
+ - insert:
9
+ - id: xujie-memory
10
+ name: dsh-plugin-xujie-memory
11
+ config:
12
+ # Python 内核监听地址;宿主的 section 注入和写记忆都走这条本地 HTTP。
13
+ endpoint: "http://127.0.0.1:8765"
14
+
15
+ # 留空 = 用插件包内自带的 python/ 内核(推荐,装上即用)。
16
+ # 只有开发时想指向仓库才填绝对路径。
17
+ repoPath: ""
18
+
19
+ # 由插件拉起内核进程。设成 false 就要求你另外手动起服务。
20
+ autoStart: true
21
+
22
+ # 留空 = 用插件包内自带的解释器(runtime/<平台>-<架构>/)。
23
+ # 只有想换成本机 Python 时才填。
24
+ pythonPath: ""
25
+
26
+ # 留空 = ~/.xujie-memory/memory.db;想换位置或跑测试时填绝对路径。
27
+ dbPath: ""
28
+
29
+ # 一个会话最多主动追问几次。超过之后材料里只剩一句总数。
30
+ maxAskedTotal: 6
31
+
32
+ # 记忆范围(v0.5):
33
+ # user 人物卡/偏好/锚点/账跨会话有效(默认,长期记忆)
34
+ # session 每个会话一份、互不相通(0.4 的旧行为)
35
+ scope: "user"
36
+
37
+ # 内核日志;留空 = 与记忆库同目录的 kernel.log(超过 2MB 自动轮转)。
38
+ logFile: ""
39
+
40
+ # 插件与内核共享的鉴权 token 文件;留空 = 与记忆库同目录的 token。
41
+ tokenFile: ""
42
+
43
+ # 宿主若会 await section.text 返回的 Promise,可设为 true:
44
+ # 组装提示词时最多等 waitMs 毫秒拿这一轮的记忆。宿主不支持就别开。
45
+ asyncSection: false
46
+ waitMs: 400
47
+
48
+ # 可选诊断文件:宿主 logger 把 info 过滤掉时,用它确认插件挂载/内核就绪。
49
+ statusFile: ""