← 返回
AI智能 Key 中文

Brain Memory System

Unified cognitive memory system inspired by human brain architecture. Provides episodic memory (hippocampus), semantic facts (neocortex), procedural memory w...
{"answer":"受大脑架构启发的统一认知记忆系统。提供情景记忆(海马体)、语义事实(新皮层)、程序性记忆……"}
mwmdeadpool
AI智能 clawhub v1.0.1 1 版本 100000 Key: 需要
★ 0
Stars
📥 665
下载
💾 19
安装
1
版本
#latest

概述

Cognitive Brain

Unified memory system modeled on human brain architecture. One CLI (brain) for all memory operations.

Architecture

SystemBrain RegionWhat it does
-----------------------------------
EpisodicHippocampusTime-stamped experiences with emotional tags
SemanticNeocortexStructured facts (entity/key/value with FTS5)
ProceduralCerebellumVersioned workflows that evolve from failures
AttentionThalamusScore incoming info → store/summarize/discard
ConsolidationSleep replayBatch-process episodes → extract facts
HealthSoul erosionDetect memory drift, conflicts, flatness

Installation

# 1. Initialize the database
sqlite3 brain.db < scripts/schema.sql

# 2. Link the CLI
ln -sf "$(pwd)/scripts/brain.sh" ~/.local/bin/brain
chmod +x scripts/brain.sh

# 3. (Optional) Migrate existing daily logs
python3 scripts/migrate-daily-logs.py --dir /path/to/memory/ --db brain.db

Environment Variables

VariableDefaultPurpose
----------------------------
BRAIN_DB/brain.dbPath to brain database
BRAIN_AGENTmargotAgent identity for scoping
BRAIN_FACTS_DBmemory/facts.dbLegacy facts database path
BRAIN_LLM_URLGoogle Gemini endpointOpenAI-compatible chat completions URL
BRAIN_LLM_KEY(none — must be set)API key for LLM provider (required for proc evolve)
BRAIN_LLM_MODELgemini-2.5-flashModel name for evolution reasoning

Credentials & Scope

Required for brain proc evolve only:

  • BRAIN_LLM_KEY — Your API key for the LLM provider. Set via env var or brain config set key .
  • No credentials are auto-discovered or read from platform stores.
  • Without a key, proc evolve falls back to local pattern-based evolution (no LLM needed).

Data scope:

  • All data stays in your brain.db file (local SQLite).
  • brain facts reads/writes BRAIN_FACTS_DB (default: facts.db in skill directory).
  • brain wm reads/writes SESSION_STATE (default: SESSION-STATE.md in workspace root).
  • No data is sent externally except LLM API calls during proc evolve.

Quick Reference

Store & Recall

brain store "Fixed the deploy pipeline" --title "Deploy Fix" --emotion relieved --importance 8
brain ingest "Docker OOM at 3 AM" --title "OOM Event" --source mqtt  # attention-gated
brain recall "deploy pipeline" --type all --limit 5
brain episodes 2026-03-15
brain emotions 7
brain important 8 14

Facts (Semantic Memory)

brain facts get Darian favorite_movie
brain facts set Mae birthday "September 12" --category date --permanent
brain facts search "SSH" --limit 5
brain facts list --entity Darian --limit 10
brain facts stats

Procedures (Cerebellum)

brain proc create deploy-api --title "Deploy API" --steps '["Pull latest","Run tests","Deploy"]'
brain proc success deploy-api
brain proc fail deploy-api --step 2 --error "Tests timed out" --fix "Increased timeout to 60s"
brain proc evolve deploy-api           # LLM rewrites steps from failure patterns
brain proc evolve deploy-api --dry-run # preview without applying
brain proc history deploy-api          # full evolution timeline
brain proc list

Attention Filter

brain filter "GPU temperature 72°C" --source mqtt    # → discard (routine)
brain filter "SSH brute force from new IP" --source security  # → store (novel threat)

Consolidation

brain consolidate --dry-run    # preview what would be processed
brain consolidate              # run sleep replay

Health (Soul Erosion Detection)

brain health           # 7-metric scored report
brain health -v        # verbose with all details
brain health --json    # machine-readable for crons

Configuration

brain config show              # current LLM config
brain config set model gpt-4o  # change model
brain config set url http://localhost:11434/v1/chat/completions  # switch to Ollama

Multi-Agent

brain --agent bud store "Patrol complete" --title "Bud Patrol" --importance 3
brain --agent bud proc list   # sees own + shared procedures
brain who                     # show all agents in the system

Procedure Evolution Flow

The core innovation — procedures that rewrite themselves from failure patterns:

  1. Record failures with step-level granularity: brain proc fail --step N --error "desc"
  2. At 3+ failures, brain suggests evolution
  3. brain proc evolve analyzes patterns:
    • Repeat offender steps (same step failing multiple times)
    • Brittle chains (consecutive step failures)
    • Error keyword clustering (timeout, auth, permission, etc.)
  4. LLM synthesizes and rewrites steps — adds pre-checks, reorders, annotates with [vN: reason]
  5. Local fallback if LLM unavailable — pattern-matching inserts defensive steps
  6. Full version history preserved: brain proc history

Health Metrics

Seven metrics, each scored 1-10:

MetricWhat it detects
------------------------
Memory FreshnessTime since last recorded episode
Consolidation DebtBacklog of unprocessed episodes
Importance CalibrationEverything rated 8+? Nothing is important
Emotional DiversityFlatlined to one emotion = loss of range
Fact ConsistencyContradictory facts = identity fragmentation
Procedure HealthSuccess rates dropping on learned behaviors
Recording CadenceSilent days creating memory gaps

Schema

Database: SQLite with WAL mode, FTS5 full-text search, foreign keys.

Tables: episodes, episodes_fts, facts, facts_fts, procedures, procedure_history, working_memory, consolidation_log, brain_meta.

Initialize with: sqlite3 brain.db < scripts/schema.sql

Files

FilePurpose
---------------
scripts/brain.shMain CLI dispatcher
scripts/schema.sqlDatabase schema
scripts/attention.pyThalamic attention filter (rule-based scoring)
scripts/consolidate.pySleep replay consolidation pipeline
scripts/erosion.pySoul erosion health metrics
scripts/evolve.pyProcedure evolution engine (LLM + local fallback)
scripts/facts.pySemantic fact storage wrapper
scripts/migrate-daily-logs.pyImport existing daily markdown logs

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-30 04:32 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,358 📥 318,419
ai-intelligence

Nano Banana Pro

steipete
使用 Nano Banana Pro (Gemini 3 Pro Image) 生成或编辑图像。支持文生图、图生图及 1K/2K/4K 分辨率,适用于图像创建、修改及编辑请求,使用 --input-image 指定输入图像。
★ 418 📥 115,231
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 712 📥 243,856