让AI记住你是谁 / Let AI remember who you are
跨会话AI记忆工具 — 每次对话都在前一次的基础上继续,而不是从零开始。 A cross-session memory tool for AI agents — each conversation builds on the last.
MBS 是一个运行在本地的记忆工具。它解决的问题很简单:
每次和AI对话结束后,AI不记得你。 你的偏好、你纠正过它的错误、你正在进行的项目——下一次对话全部丢失。
MBS 把这些信息结构化地存下来,下次对话开始前自动注入上下文,让AI知道你是谁、我们做过什么、你不喜欢什么。
| 功能 | 说明 |
|---|---|
| 结构化记忆 | 按类型(preference/correction/project)分类存储,支持facts和concepts标签 |
| 关键词搜索 | 快速查找过往记忆 |
| 语义搜索 | TF-IDF + 余弦相似度做跨词关联 |
| 自动捕获 | cron每30分钟扫描Hermes会话日志,自动提取关键信息 |
| 上下文注入 | 对话开始前自动编译注入文本 |
| 去重 | SHA256 content_hash 防止重复存储 |
| 零依赖 | 纯Python标准库,无需装任何第三方包 |
┌─────────────────────┐
│ 用户开始新对话 │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ [自动] mbs_start │
│ 加载历史记忆注入上下文 │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ AI拥有你的完整背景 │
│ 直接进入场景 │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ 对话进行中 │
└──────────┬──────────┘
│
┌─────────────────┼─────────────────┐
│ │ │
┌────────▼────────┐ ┌─────▼──────┐ ┌────────▼────────┐
│ cron每30分钟 │ │ 对话结束 │ │ 用户主动 │
│ 扫描会话日志 │ │ mbs auto │ │ mbs add │
└────────┬────────┘ └─────┬──────┘ └────────┬────────┘
│ │ │
└────────────────┼─────────────────┘
│
┌─────────▼──────────┐
│ MBS SQLite记忆库 │
│ observations+sessions│
└────────────────────┘
闭环: 对话产生记忆 → 自动捕获 → 注入下一轮对话 → AI不再从零开始
- 每次对话结束时自动提取关键信息 → 下次AI直接知道你的偏好
- 搜索之前的项目状态 → 不用重新描述
- 记住你纠正过的错误 → 同一个错误不会犯第二次
# 安装
ln -sf /path/to/mbs.py ~/.local/bin/mbs
# 查看所有命令
mbs
# 添加一条记忆
mbs add preference "用户喜欢简约风格,不要赛博朋克" --fact "UI偏好"
# 关键词搜索
mbs search 字数
# 语义搜索(跨词关联)
mbs search --semantic "界面风格"
# 自动从对话中提取(管道输入)
cat 对话记录.txt | mbs auto
# 生成可注入的上下文
mbs context
# 对话开始前加载记忆(启动器)
mbs-start
# 查看统计
mbs stats# 1. 部署自动捕获(cron每30分钟)
hermes cron update --job-id <id> --repeat forever --schedule "*/30 * * * *"
# 2. 对话开始时自动注入
# AI会在每次对话开始前自动运行 mbs-startpreference— 用户偏好/习惯(颜色、风格、语气等)correction— 纠正过的规则/错误("中文字数不是字节数")project— 项目状态/进展("XX已发布到GitHub")note— 普通笔记
所有数据存放在 ~/.memory-bridge/memory.db(SQLite文件)。
纯本地,不上传,不外泄。
MBS is a local memory persistence tool for AI agents. It solves one fundamental problem:
Every time you start a new conversation with an AI, it doesn't remember you. Your preferences, corrections you made, projects you're working on — all lost.
MBS stores this information in a structured SQLite database, and automatically injects relevant context into the next conversation.
New conversation starts → [Auto] mbs_start loads memories → AI has full context
↓
Conversation in progress → cron (every 30min) scans logs → SQLite memory store
↓
Next conversation ← mbs context auto-inject ← observations + summaries
Closed loop: Conversations produce memories → auto-captured → injected into next session → AI no longer starts from zero.
| Feature | Description |
|---|---|
| Structured Memory | Stored by type (preference/correction/project) with facts and concept tags |
| Keyword Search | Quick retrieval via SQLite LIKE |
| Semantic Search | TF-IDF + cosine similarity for cross-term matching |
| Auto Capture | Cron job scans Hermes session logs every 30 minutes |
| Context Injection | Auto-compiled at conversation start |
| Deduplication | SHA256 content_hash prevents duplicates |
| Zero Dependencies | Pure Python standard library |
# Install
ln -sf /path/to/mbs.py ~/.local/bin/mbs
# List commands
mbs
# Add memory
mbs add preference "User prefers minimalist, no cyberpunk" --fact "UI preference"
# Keyword search
mbs search GitHub
# Semantic search
mbs search --semantic "interface design"
# Auto-extract from conversation
cat conversation.log | mbs auto
# Generate injection context
mbs context
# Start-up injector
mbs-start
# Statistics
mbs statspreference— User preferences (colors, style, tone)correction— Rules, correctionsproject— Project state/progressnote— General notes
All data stored locally in ~/.memory-bridge/memory.db (SQLite).
Never uploaded. Never shared.
User Input → [mbs auto] → Observation (structured) → SQLite DB
↓
Next Session ← [mbs context] ← Session Summary + Recent Observations
Auto Capture (cron: */30 * * * *)
→ Hermes session logs → mbs auto → SQLite
Auto Inject (conversation start)
→ mbs start → mbs context → system prompt
Inspired by claude-mem (77.4k stars).
MIT