1837458003-ctrl / dsh-memory-starmap
记忆星图:把 DeepSeek Harness 的会话记忆渲染成可旋转的 3D 星云(本地 embedding + UMAP + Three.js)
About this plugin
Written by the registry from verified metadata, not from the README.
dsh-memory-starmap is a DSH plugin published from the 1837458003-ctrl/dsh-memory-starmap repository.
Capabilities and topics
记忆星图 · dsh-memory-starmap
把 DeepSeek Harness 里聊过的每一句话,变成一颗可以旋转的星星。

一个 DSH 插件 + 本地小服务:读取 ~/.dsh/sessions 里的会话记录 → 用 bge-small-zh-v1.5 算语义向量 → UMAP 降到 3D 铺进球里 → Three.js 渲染成星云。
白点是普通对话,蓝点是重要记忆,金点是人格核心;连线表示语义相近。全部在本机跑,不联网、不上传任何数据。
实验性项目。数据管道依赖 Python;插件部分只负责浮层入口和保活。
特性
- 真语义向量:bge-small-zh-v1.5(ONNX Runtime,CPU),不是关键词匹配
- 3D 球状布局:UMAP 保局部距离,按 UMAP 方向铺球面,核心记忆收在里层
- 交互:拖拽旋转、滚轮缩放、悬停看全文、点击看详情、统计栏、暂停/重置/刷新
- 本地优先:模型、推理、服务全在你自己的机器上跑
- 零配置启动:一条命令起服务,插件里点 ✦ 打开
快速开始
0. 前置
- Python 3.10+
- DSH(DeepSeek Harness)桌面端或 web 端
- 磁盘:模型约 95MB,依赖约 300MB
1. 装依赖 + 下模型
git clone https://github.com/1837458003-ctrl/dsh-memory-starmap.git
cd dsh-memory-starmap
python -m pip install -r requirements.txt
python download_model.py # 默认走 hf-mirror.com,可 --mirror 换源
2. 生成第一张星图
python extract.py # 从 ~/.dsh/sessions 抽取记忆 -> memories.json
python build.py # embedding + UMAP + 连线 -> graph.json
python server.py 8126 # 起本地服务
浏览器打开 http://127.0.0.1:8126/ 就能看到。
之后数据变了,跑 python rebuild.py(extract + embed + build 串起来),或者让插件每小时自动重建。
3. 装插件(浮层入口)
dsh plugin add link:C:/path/to/dsh-memory-starmap
然后在 DSH 设置里确认 dsh-memory-starmap 已启用,重启 DSH。
Web UI 右下角会出现一个 ✦ 按钮,点开就是星图浮层。
插件需要知道仓库在哪:设置环境变量 STARMAP_HOME 指向克隆目录(否则只显示入口、不自动起服务)。
Windows 下也可以在系统环境变量里加一项:
STARMAP_HOME = C:\path\to\dsh-memory-starmap
配置
| 环境变量 | 默认 | 说明 |
|---|---|---|
STARMAP_HOME | 空 | 仓库目录。插件用它启动/重建服务;不设则插件不自动起服务 |
STARMAP_PYTHON | python / python3 | Python 可执行文件 |
STARMAP_PORT | 8126 | 本地服务端口 |
STARMAP_AI_NAME | 小鱼 | 星图中心显示的名字 |
STARMAP_MODEL_DIR | ./models/bge-small-zh-v1.5 | 模型目录 |
DSH_SESSIONS | ~/.dsh/sessions | DSH 会话目录 |
工作原理
~/.dsh/sessions/*/session.v4.jsonl.zstd
│ extract.py:解压、跳过 subagent、抽 user/assistant 文本
▼
memories.json(每条:文本/角色/时间/重要性/是否核心)
│ embed.py:bge-small-zh-v1.5 ONNX,512 维,L2 归一化
▼
(N, 512) 向量
│ build.py:余弦相似度 → 每点 top1 连线(阈值 0.70)
│ UMAP 3D → 白化 → 球面方向 + 球内半径填充
▼
graph.json(nodes + links + stats)
│ server.py(本地 http.server)
▼
web/index.html(Three.js:Points + LineSegments + 星空 + 拾取)
为什么用 UMAP 而不是直接 PCA:PCA 投出来的方向天然集中(实测轴比约 2~5 倍),点会压成一条斜带,没有球感。UMAP 保局部邻域,方向分布更均匀;再按白化 + 球面投影落位。
为什么核心点在内圈:is_core 的节点半径乘 0.62,is_longterm 乘 0.85,普通点在外围。视觉上一眼能看出哪些是"人格核心"。
已知限制
- 依赖 Python 运行时。没有 Node 原生版;不想装 Python 的话这个插件暂时用不了。
- 模型 95MB。首次需要下载,之后完全离线。
- 首次建图慢:几百条记忆约 10~30 秒(UMAP + ONNX CPU)。
- 中文优化。bge-small-zh 是中文模型,中英混排能用,纯英文效果一般。
- iframe 本地服务。浮层里嵌的是
http://127.0.0.1:8126,端口被占用或服务没起时会提示启动命令。 - 只读了 user/assistant 正文。工具调用、思考过程、系统注入都不算记忆。
目录结构
dsh-memory-starmap/
├── extract.py # 会话 -> memories.json
├── embed.py # bge ONNX embedding
├── build.py # UMAP + 连线 -> graph.json
├── rebuild.py # 一键重建
├── server.py # 本地静态服务 + /ping
├── download_model.py # 下载 bge 模型
├── requirements.txt
├── web/
│ ├── index.html # 星图 UI(Three.js)
│ ├── three.module.js
│ └── OrbitControls.js
├── plugin/ # DSH 插件包
│ ├── index.js # host:保活 + 每小时重建
│ ├── client.js # client:右下角 ✦ + 浮层 iframe
│ ├── cordis.patch.yml
│ └── icon.svg
└── docs/screenshot.png
License
MIT。bge-small-zh-v1.5 模型版权归北京智源研究院(BAAI),本项目只是下载器。
Badge
Listed here? Link back with this badge — paste the snippet into your repository README.
[](https://dsh-plugin.com/plugins/1837458003-ctrl/dsh-memory-starmap)