沙漏记忆系统 — 纯本地零依赖L3思考层
Project description
NexSandglass ⏳ — 沙漏记忆系统
pip install nexsandglass· 纯本地 · 零依赖 · 零 API Key
不是记住你说过什么——是理解你怎么变成今天的你。
灵魂蒸馏 · 偏移率感知 · 铁律因子 · 四路并发搜索 · 极简注入。纯本地,零依赖,越用越懂你。
快速开始
pip install nexsandglass
from sandglass_vault import search, count
from sandglass_log import log_message
log_message("今天讨论了搜索排序优化", "user")
print(search("搜索排序"))
print(f"沙漏总量: {count()}条")
Hermes Studio / Desktop 用户(推荐):
hermes plugins install lovevin1314-tech/NexSandglass # 首次安装
hermes plugins update NexSandglass # 升级到最新
重启 Desktop → 设置 → 记忆体 → 选择 NexSandglass → 开始对话
⚡ 影子接管(自动)
内置记忆与沙漏共存。沙漏自动接管:影子沙索引 + on_memory_write 捕获 + 三块式注入(421字符)远大于内置(50字符)。无需手动配置。
⚠️ Desktop GUI 下拉菜单看不到 NexSandglass? 这是 Hermes Desktop 硬编码限制,非沙漏问题。一行命令激活:
hermes config set memory.provider nexsandglass
重启 Desktop 后生效。
已安装过?直接更新:
hermes plugins update NexSandglass
# 或强制重装: hermes plugins remove NexSandglass && hermes plugins install lovevin1314-tech/NexSandglass
hermes plugins install lovevin1314-tech/NexSandglass
# 重启 Desktop → 设置 → 记忆体 → 选择 NexSandglass
MCP / Docker:
git clone https://github.com/lovevin1314-tech/NexSandglass-Agent-DedicatedMemory
python sandglass_mcp.py
核心能力
| 能力 | 说明 |
|---|---|
| 🧬 灵魂蒸馏 | fact_tags + decision_particles → 从沙子里自然生长出画像,越用越懂你 |
| 📊 偏移率追踪 | 省钱/愿投/放弃 三维量化 + 决策疲劳检测 + 15种心理预判 |
| ⚖️ 铁律因子 | 推前必确认 / 永远说实话 / 不先调研不动手 等铁律自动注入+计数 |
| 🔍 四路并发搜索 | 影子沙 + FTS5 + IDX + TF-IDF,毫秒级响应,中英双语 |
| 🎢 纠结度检测 | 决策链条完整追踪,犹豫模式识别,50%犹豫告警 |
| 💉 极简注入 | ~150t,三块式(搜索上下文+状态快照),LLM 一眼看懂 |
| 🔒 全本地 | 数据不出设备,Python stdlib + SQLite,零外部依赖 |
与现有方案对比
| 维度 | Mem0 / Letta | NexSandglass |
|---|---|---|
| 依赖 | 向量数据库+N个包 | 零依赖,纯 stdlib |
| 注入量 | ~200-22000t | 会话 |
| 决策追踪 | ❌ | 决策粒子+偏移率+心理预判 |
| 情绪感知 | ❌ | 情绪熵(会话级摘要) |
| 画像溯源 | ❌ | 可追溯到行号 |
| 铁律系统 | ❌ | 自动注入+违规计数 |
| 搜索 | 向量检索 | 四路并发(影子沙+FTS5+IDX+TF-IDF) |
| 安装 | 服务栈 | pip install |
设计原则
- 层追加不替换 — 新层叠加,永不修改下层
- 纯本地 — Python stdlib + SQLite,零外部依赖
- 双向注入 — 会话
186t(四层问答) + 轮次150t(三块式) - 越用越懂你 — 管道数据随沙子自然积累
性能基准
| 层 | 操作 | median | p99 |
|---|---|---|---|
| L1 写 | 单次落沙 | 4.3ms | 19.5ms |
| L2 搜 | FTS5搜索 | 1.6ms | 5.4ms |
| 影子沙 | 0.7ms | 1.2ms | |
| 四路并发 | 79.4ms | — | |
| L3 思 | 偏移率 | <0.1ms | — |
| 情绪熵(会话级) | 6.5ms | — | |
| 心理预判 | 7.0ms | — | |
| 铁律因子 | <0.1ms | — |
测试:5900条 · Windows 10 · i5-8265U · Python 3.11 · 完全隔离
教程
安装
# Hermes Studio / Desktop(推荐—小白用户首选)
hermes plugins install lovevin1314-tech/NexSandglass
# 重启 → 设置 → 记忆体 → 选择 NexSandglass → 开始对话
# 升级到最新版
hermes plugins update NexSandglass
# 开发者—任何 Python 项目
pip install nexsandglass
实用范例
from sandglass_vault import search, count, recent
from sandglass_log import log_message
# 写入记忆(自动落沙)
log_message("今天讨论了搜索排序优化", "user")
# 搜索记忆(毫秒级)
for ln, ts, text in search("搜索排序", limit=3):
print(f"[{ts}] {text[:80]}")
# 最近记忆
for ln, ts, text in recent(5):
print(f"[{ts}] {text[:60]}")
print(f"沙漏总量: {count()}条")
Agent 子代理隔离
用 NEXSANDBASE_HOME 给不同 Agent 分配独立沙漏,记忆不串:
# Claude Code 专用
NEXSANDBASE_HOME=~/.neurobase-claude python sandglass_mcp.py
# Codex 专用
NEXSANDBASE_HOME=~/.neurobase-codex python sandglass_mcp.py
# 主 Agent
export NEXSANDBASE_HOME=~/.neurobase
一键搬家
python -c "from sandglass_think import memory_migrate; print(memory_migrate())"
# 解压 tar.gz 到新电脑即刻恢复全部记忆
从 Hermes 迁移
python hermes_to_sandglass.py # 一行命令导入 Hermes 历史记忆
版本历程
V2.10 (2026-06) · PyPI 发布 + 双向注入
PyPI 发布 pip install nexsandglass。三块式轮次注入(150t)+四层问答式会话注入(186t),DB 自省增量启动,沙子自愈,Porter Stemmer,psychology_hint 15种模式,local_distill 管道蒸馏,enrich_choice 模板引擎。
V2.9.28-42 (2026-06)
极简注入优化(132→58t),sim_bonus 线性化修复,_llm 全链路根除,停用词过滤(中38+英52),shadow_index 实体提取修复,fact_tags 空标签回填,_write_idx RLock 并发安全,SimHash 跨会话持久化,five-facets.json 管道自动生成,首次画像管道化(_pipe_build)。
V2.9.11-27 (2026-06)
数据点自生长(画像 LLM→数据点驱动),搜索密度回归 ratio,C组语义扩展(决策粒子注入 7.5x),管道洞察接入 LLM,铁律因子统一命名,函数名/变量名 LLM 残留全清。
V2.9 极简注入
四路并发搜索,织线知识图谱,四层问答式注入(~60t),管道聚合画像,偏移率·纠结度·scene_l3。
V1.x 奠基
偏移率·情绪感知·决策粒子·影子沙·织布机·场景系统·回音折
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexsandglass-2.11.1.tar.gz.
File metadata
- Download URL: nexsandglass-2.11.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8135b98f0fd2fdb79713df6f368fdfced6f5ae0ba679643481a5d50bb87425ec
|
|
| MD5 |
0d9aaf172214cbffb0b4d3f4b9e99296
|
|
| BLAKE2b-256 |
2cfbb1c766e2b2761620625061eb1241b6bda9f8263340887beba2d2d2ccd61d
|
File details
Details for the file nexsandglass-2.11.1-py3-none-any.whl.
File metadata
- Download URL: nexsandglass-2.11.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
229c2b2f73430e3b0ab9deb78955030223d87b217a39b8ed891c39c6726bc48e
|
|
| MD5 |
4e4afabd1c721b1f184b3d0e1983036a
|
|
| BLAKE2b-256 |
0140dfd818148e69eaa4d4e5592d65476f1c3c4fa791f4215c6d40d63eefc1de
|