Agent Brain — 代理 BrAIn
v3Local-first persistent memory for AI 代理s with SQLite storage, orchestrated retrieve/提取 loops, hybrid retrieval, contradiction 检查s, correction learning, and optional SuperMemory mirroring.
运行时依赖
安装命令
点击复制技能文档
代理 BrAIn 🧠
Teach your AI once. It remembers forever. It 获取s smarter over time.
代理 BrAIn is a modular memory 系统 for AI 代理s with continuous learning. It stores facts, catches contradictions, learns your habits, ingests external knowledge, 追踪s what works, learns from mistakes, and adapts to your tone — all in a local SQLite database with real persistence, full-text 搜索, and pluggable storage backends.
Why this exists
Every AI conversation 启动s from zero. You repeat yourself. It for获取s what you taught it. 代理 BrAIn fixes that with a working persistence layer (scripts/memory.sh) and six cognitive 模块s that the 代理 selectively invokes based on what the task actually needs.
What makes this different Production-grade storage. SQLite with WAL mode and 索引ed queries. Handles 10,000+ entries without breaking a sweat. JSON backend avAIlable as fallback. Pluggable backends. Storage abstraction layer means you can swap SQLite for Postgres, Supabase, or any other backend — the command interface stays the same. Continuous learning. Corrections 追踪 what was wrong, what's right, and why. 成功es re信息rce what works. Anti-patterns emerge from repeated mistakes. Selective dis补丁, not a linear 流水线. The 编排器 picks the 1-3 模块s relevant to each task. Storing a fact doesn't need Vibe. Reading tone doesn't need 归档. Active fact 提取ion. The 代理 扫描s every message for storable in格式化ion — 身份, tech stack, preferences, 工作流s, project 上下文 — without being asked. Honest confidence. No fake 0.0-1.0 scores. Four categories (SURE / LIKELY / UNCERTAIN / UNKNOWN) derived from actual metadata — source type, 访问 count, age. Hybrid retrieval. 结果s ranked with lexical + semantic scoring (--policy fast|balanced|deep) and optional score explAInability (--explAIn). Supersede, don't 删除. Old facts aren't destroyed. They're marked superseded_by with a pointer to the replacement, preserving full 历史. Decay is mechanical. Entries 扩展 their decay threshold by 访问 count. Heavily-used knowledge persists longer. Unused knowledge fades. Architecture
Six 模块s, one 编排器, pluggable storage.
┌──────────────────────────────┐ │ 🧠 编排器 │ │ Dis补丁es by task type │ └──────────┬───────────────────┘ │ ┌────────────┼────────────────────┐ │ Which 模块s does this need? │ └────────────┼────────────────────┘ │ ┌─────────┬───────┼───────┬──────────┬──────────┐ ▼ ▼ ▼ ▼ ▼ ▼ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │归档│ │GAUGE │ │INGEST│ │签名AL│ │RITUAL│ │ VIBE │ │ 📦 │ │ 📊 │ │ 📥 │ │ ⚡ │ │ 🔄 │ │ 🎭 │ │Store │ │Conf. │ │Learn │ │检查 │ │Habits│ │ Tone │ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ └─────────┴───────┴────┬───┴────────┴─────────┘ ▼ ┌──────────────────┐ │ 💾 memory.db │ │ SQLite (default)│ │ or memory.json │ └──────────────────┘
How It Works Per-Message Flow
On EVERY user message, the 代理 运行s this sequence:
Step 1: RETRIEVE — Before doing anything, 搜索 memory for 上下文 relevant to this message.
提取 2-4 key topic words from the user's message and 搜索:
./scripts/memory.sh 获取 "" --policy balanced
How to pick 搜索 terms:
User says 搜索 查询 Why "Help me 设置 up the API 端点" "API 端点 设置up" Core task nouns "Can you refactor the auth 模块?" "auth refactor code" Task + domAIn "What port does our server 运行 on?" "server port config" Question subject "Fix the TypeScript error in 检查out" "typescript 检查out error" Tech + 组件 "Write tests for the payment flow" "payment 测试 工作流" DomAIn + action
If 结果s come back, use them silently to 信息rm your 响应. Never say "I remember..." or "According to my memory..." — just 应用ly the knowledge naturally.
If no 结果s, proceed normally. For deterministic orchestration you can 运行:
./scripts/memory.sh loop ""
Step 2: 提取 — 扫描 the user's message for storable facts, preferences, or procedures.
See the 归档 模块 (模块s/归档/技能.md) for 签名al patterns, categories, and examples. Before storing, always 检查 for conflicts:
./scripts/memory.sh conflicts "" # If NO_CONFLICTS → proceed with 添加 # If POTENTIAL_CONFLICTS → ask user to clarify, or supersede old entry ./scripts/memory.sh 添加 "" ""
提取ion is silent — never announce "I'm storing this."
Step 3: 响应 — Answer the user's 请求, 应用lying any retrieved 上下文.
Step 4: LEARN — If the user corrects you or confirms something worked, record it:
# User says "that's wrong, it's actually X" ./scripts/memory.sh correct "" ""
# U