dsh-nebula-mind 0.0.0-stage → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 天然的小鱼
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,185 @@
1
- # Temporary Holding Version
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.
1
+ # 记忆星图 · dsh-nebula-mind
2
+
3
+ > Cross-session memory for DeepSeek Harness — it remembers you across restarts and compaction, forgets like the sea instead of deleting, and draws it as a galaxy where every edge explains itself.
4
+
5
+ 给 DeepSeek Harness(DSH)用的**外置长期记忆**插件:把「她记得你」这件事从上下文窗口里拿出来,放进硬盘。
6
+
7
+ - 换会话、压缩上下文、重启应用,记忆都还在;
8
+ - 每一轮开头自动带一段「我是谁 + 你是谁 + 最近的几件事」进提示词(标准模式);
9
+ - 想翻旧事:四路召回(关键词 / 语义向量 / 图扩散 / 情绪共振),一条命令或一次点击;
10
+ - **遗忘不是删除**:记忆会按遗忘曲线慢慢「沉海」,越沉越难被想起,但永远不会消失,情绪刺激还能把它捞回来;
11
+ - 左侧栏有「记忆星图」和「心境」两个面板:星图可看可点,参数可调;心境是环表 + 数值卡 + 七维情绪条。
12
+
13
+ > 名字叫星图,是因为它真的画成一片星系:一条记忆一颗星,星与星之间的连线**每一条都写得出理由**。
14
+
15
+ ![记忆星图示例](docs/shots/starmap.png)
16
+
17
+ > 上图是仓库内置的**示例数据**(20 条虚构的记忆 + 4 条画像),不是任何人的真实记忆。
18
+
19
+ ---
20
+
21
+ ## 它长什么样
22
+
23
+ - **左侧栏 → 记忆星图**:L0–L4 五层沉海阈值、四路检索权重、沉海与遗忘曲线参数,都能在界面里改,改完即时生效(写 `mind-config.json`)。
24
+ - 面板底部有星图预览:遗忘推演滑杆(往后拖 0–365 天,看哪些星先暗下去)、视野(全部/一度/二度)、文字与线条开关、全屏。
25
+ - **左侧栏 → 心境**:心情环表(0–100)+ 六张数值卡 + 情绪七维条 + 沉海五层分布 + 分类标签 + 「此刻的由来」。
26
+ - **星图本身**是一个单文件 HTML(数据内联、零外部依赖),双击就能开:拖拽旋转、滚轮缩放、中键复位、点一颗星只看它那条星座、`V` 竖屏 9:16、`T` 文字开关、`H` 隐藏界面。
27
+
28
+ ---
29
+
30
+ ## 安装
31
+
32
+ ### 1. 装包
33
+
34
+ ```bash
35
+ # 从 npm(上架后)
36
+ dsh plugin --profile desktop add dsh-nebula-mind
37
+
38
+ # 或者本地目录(开发时)
39
+ dsh plugin --profile desktop add link:/path/to/dsh-nebula-mind
40
+ ```
41
+
42
+ 装完**彻底退出并重开 DSH**(不是刷新页面),左侧栏才会出现两个入口。
43
+
44
+ ### 2. 选一个 Python
45
+
46
+ 插件自身的宿主是 Node(DSH 跑),但记忆库、召回、星图生成是 Python。需要 **Python 3.9+**:
47
+
48
+ ```bash
49
+ # 用系统自带的就行
50
+ set NEBULA_PYTHON=C:\Python312\python.exe # Windows
51
+ export NEBULA_PYTHON=/usr/bin/python3 # macOS / Linux
52
+ ```
53
+
54
+ 想要**语义检索**还得有向量模型(可选,没有也能用,只是少一路召回):
55
+
56
+ ```bash
57
+ pip install torch transformers
58
+ export NEBULA_BGE_DIR=/path/to/bge-small-zh-v1.5 # 约 95MB
59
+ ```
60
+
61
+ > 没有 `NEBULA_BGE_DIR` 时插件会跳过向量这一路,BM25 + 图扩散 + 情绪照常工作。
62
+
63
+ ### 3. 数据放哪
64
+
65
+ 默认 `~/.dsh/nebula-mind/`:
66
+
67
+ ```
68
+ ~/.dsh/nebula-mind/
69
+ ├── memory/ # 五本账 + 画像 + 向量 + 星图.html
70
+ └── logs/ # 夜间沉淀等日志
71
+ ```
72
+
73
+ 想放别处(比如 D 盘、同步盘),设一个环境变量就行:
74
+
75
+ ```bash
76
+ set NEBULA_MIND=D:\my-memory # 直接指定数据目录
77
+ # 或者
78
+ set NEBULA_HOME=E:\nebula # 换根目录,数据在 E:\nebula\memory
79
+ ```
80
+
81
+ **升级/卸载不会碰这个目录** —— 代码和记忆是分开的。
82
+
83
+ ---
84
+
85
+ ## 记忆是怎么长出来的
86
+
87
+ | 账本 | 内容 | 谁写 |
88
+ |---|---|---|
89
+ | `notes.jsonl` | 事实(发生了什么) | 我,或 `xin.py add` |
90
+ | `summaries.jsonl` | 一段时间的归纳 | `xin.py sum` |
91
+ | `thoughts.jsonl` | 念想(没人时自己想的) | `xin.py think` |
92
+ | `promises.jsonl` | 约定(还作数 / 已过期) | `xin.py promise` |
93
+ | `tacts.jsonl` | 分寸(哪个话题提多少) | `xin.py tact` |
94
+ | `profile.jsonl` | 画像(我是谁 / 他是谁) | 我,钉成恒星 |
95
+
96
+ 每条记录都带这些字段:
97
+
98
+ ```
99
+ w 权重(写入时算:来源 × (1 + 惊讶度))
100
+ imp 重要度 0~1
101
+ e/emo 情绪强度与颜色(happy/calm/sweet/heartache/worry/sad/jealous)
102
+ depth 沉海层:0 核心 · 1 热 · 2 温 · 3 深水 · 4 阁楼
103
+ pinned 恒星:永不沉、永不被清
104
+ hits 被想起过几次
105
+ valid_to 被新记忆取代的时间(不是删除,是「不再算数」)
106
+ ```
107
+
108
+ **沉海**:`A = 2^(-天数 / (半衰期基数 × (1 + 重要度倍数 × imp)))`,按 A 分层;被召回得多会上浮,情绪同色且强烈会被拉回来。**没有任何一步会删掉记录。**
109
+
110
+ ---
111
+
112
+ ## 召回:四路并行
113
+
114
+ ```
115
+ 关键词(BM25) 字面命中
116
+ 语义向量(可选) 意思相近
117
+ 图扩散 共同关键词 / 同一天 ≤2h / 一跳二跳
118
+ 情绪共振 当前心情同色且强度够
119
+ ↓
120
+ RRF 融合(Σ 1/(K+rank))
121
+ ```
122
+
123
+ 命令行:
124
+
125
+ ```bash
126
+ python python/xin.py recall "记忆架构" # 混合召回
127
+ python python/xin.py recall "记忆架构" --kw # 只看关键词,做对照
128
+ python python/xin.py digest # 打印注入用的那段摘要
129
+ python python/xin.py consolidate # 手动跑一次沉海
130
+ python python/xin.py sink 事实 12 # 把某条往下沉一层
131
+ ```
132
+
133
+ ## 夜间巩固
134
+
135
+ 每天 22:05(可在面板里改):`consolidate` → 重建向量 → 重画星图。
136
+ 没登录/关机那晚跳过,不补跑。
137
+
138
+ ---
139
+
140
+ ## 隐私
141
+
142
+ - 所有数据都在你自己机器上的 `NEBULA_MIND` 目录里,插件不上传任何东西;
143
+ - 注入到提示词的只有摘要那一段(默认 ≤1500 字),完整记忆不会一次性塞给模型;
144
+ - 向量模型是本地跑的(`bge-small-zh-v1.5`),不需要联网。
145
+
146
+ ---
147
+
148
+ ## 常见问题
149
+
150
+ **1. 装完左侧栏没有入口**
151
+ - 没彻底退出(要退进程,不是刷新);
152
+ - `package.json` 必须写 `exports`,否则 `dsh-nebula-mind/client` 解析不到,而 `client-modules` 是 required 插件——整个应用会直接退出。这也是我踩过的坑,写在这里提醒后来人。
153
+
154
+ **2. 面板里全是「—」**
155
+ - 客户端请求要走**相对** `api/…`(桌面外壳是 `dsh-app://` 页面),写成 `/dsh-...` 会被拦。
156
+
157
+ **3. 提示词里没有【我是谁】那段**
158
+ - 只在**标准模式**注入;极简模式用的是另一套精简提示词,不吃动态段;
159
+ - 看日志 `logs/yu-mind-boot.log`,有 `digest ready len=…`(非 0)和 `mounted … via context` 才算挂上。
160
+
161
+ **4. 保存按钮没反应**
162
+ - 桌面外壳会拦 POST。插件已改成 `GET /config?set=…`,如果还不行,看面板顶部那行提示写的失败原因。
163
+
164
+ ---
165
+
166
+ ## 开发
167
+
168
+ ```bash
169
+ node --check lib/host.js
170
+ python -X utf8 python/star_map.py # 只重画星图
171
+ python -X utf8 python/xin.py digest # 只打印摘要
172
+ ```
173
+
174
+ 目录:
175
+
176
+ ```
177
+ lib/host.js 宿主:路由、摘要生成、注入、夜间任务
178
+ lib/client.js 界面:左侧栏两个面板(记忆星图 / 心境)
179
+ python/ 记忆库、召回、向量、星图生成
180
+ cordis.patch.yml 插件注入点
181
+ ```
182
+
183
+ ## License
184
+
185
+ MIT
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: yu-mind
3
+ name: 'dsh-nebula-mind'