Skill: skillforge-jojo/maske-elite-memory (version 1.0.0)

--- name: elite-longterm-memory description: "终极AI智能体记忆系统。WAL协议 + 向量搜索 + git-notes + 云备份。6层记忆架构：热RAM(SESSION-STATE)、温存储(LanceDB向量)、冷存储(Git-Notes知识图)、精选档案(MEMORY.md)、云备份(SuperMemory)、自动提取(Mem0)。" version: 1.0.0 author: skillforge-JOJO keywords: [memory, long-term, elite, vector-search, lancedb, git-notes, wal, persistent, context] --- # Elite Longterm Memory — 精英长期记忆 **一句话描述**: 终极AI智能体记忆系统，6层记忆架构永不忘上下文。 --- ## 功能概述 结合6种成熟方法的终极记忆系统。永不丢失上下文、永不忘记决策、永不重复错误。 ## 架构概览 ``` ┌─────────────────────────────────────────────────────────────────┐ │ ELITE LONGTERM MEMORY │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ HOT RAM │ │ WARM STORE │ │ COLD STORE │ │ │ │ │ │ │ │ │ │ │ │ SESSION- │ │ LanceDB │ │ Git-Notes │ │ │ │ STATE.md │ │ Vectors │ │ Knowledge │ │ │ │ │ │ │ │ Graph │ │ │ │ (survives │ │ (semantic │ │ (permanent │ │ │ │ compaction)│ │ search) │ │ decisions) │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ └────────────────┼────────────────┘ │ │ ▼ │ │ ┌─────────────┐ │ │ │ MEMORY.md │ ← Curated long-term │ │ │ + daily/ │ (human-readable) │ │ └─────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────┐ │ │ │ SuperMemory │ ← Cloud backup (optional) │ │ │ API │ │ │ └─────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ ``` --- ## 5层记忆架构 ### 第1层: HOT RAM (SESSION-STATE.md) **来源**: bulletproof-memory 活跃工作记忆，在压缩后仍然保留。写前日志协议。 ```markdown # SESSION-STATE.md — 活跃工作记忆 ## 当前任务 [我们现在正在做什么] ## 关键上下文 - 用户偏好: ... - 已做决策: ... - 阻塞项: ... ## 待处理动作 - [ ] ... ``` **规则**: 响应前写入。由用户输入触发，非智能体记忆。 ### 第2层: WARM STORE (LanceDB向量) **来源**: lancedb-memory 跨所有记忆的语义搜索。自动回忆注入相关上下文。 ```bash # 自动回忆（自动发生） memory_recall query="项目状态" limit=5 # 手动存储 memory_store text="用户偏好暗色模式" category="preference" importance=0.9 ``` ### 第3层: COLD STORE (Git-Notes知识图) **来源**: git-notes-memory 结构化决策、学习和上下文。分支感知。 ```bash # 存储决策（静默 — 永不宣布） python3 memory.py -p $DIR remember '{"type":"decision","content":"前端使用React"}' -t tech -i h # 检索上下文 python3 memory.py -p $DIR get "frontend" ``` ### 第4层: 精选档案 (MEMORY.md + daily/) **来源**: OpenClaw原生 人类可读的长期记忆。每日日志 + 提炼智慧。 ``` workspace/ ├── MEMORY.md # 精选长期（精华） └── memory/ ├── 2026-01-30.md # 每日日志 ├── 2026-01-29.md └── topics/ # 主题特定文件 ``` ### 第5层: 云备份 (SuperMemory) — 可选 **来源**: supermemory 跨设备同步。与你的知识库聊天。 ```bash export SUPERMEMORY_API_KEY="your-key" supermemory add "重要上下文" supermemory search "我们决定了什么关于..." ``` ### 第6层: 自动提取 (Mem0) — 推荐 **新: 自动事实提取** Mem0自动从对话中提取事实。80% token减少。 ```bash npm install mem0ai export MEM0_API_KEY="your-key" ``` --- ## WAL协议（关键） **写前日志**: 响应前写入状态，非之后。 | 触发器 | 动作 | |--------|------| | 用户陈述偏好 | 写入SESSION-STATE.md → 然后响应 | | 用户做出决策 | 写入SESSION-STATE.md → 然后响应 | | 用户给出截止日期 | 写入SESSION-STATE.md → 然后响应 | | 用户纠正你 | 写入SESSION-STATE.md → 然后响应 | **为什么？** 如果你先响应然后在保存前崩溃/压缩，上下文丢失。WAL确保持久性。 --- ## 核心参数 | 参数 | 类型 | 默认值 | 说明 | |------|------|--------|------| | autoRecall | bool | true | 自动回忆 | | autoCapture | bool | false | 自动捕获 | | minImportance | float | 0.7 | 最小重要性阈值 | | maxResults | int | 10 | 最大结果数 | | minScore | float | 0.3 | 最小相似度分数 | --- ## 使用示例 ### 示例工作流 ``` 用户: "这个项目我们用Tailwind，不用vanilla CSS" 智能体（内部）: 1. 写入SESSION-STATE.md: "决策：用Tailwind，不用vanilla CSS" 2. 存储到Git-Notes: 关于CSS框架的决策 3. memory_store: "用户偏好Tailwind胜过vanilla CSS" importance=0.9 4. 然后响应: "好的 — 用Tailwind..." ``` --- ## 维护命令 ```bash # 审计向量记忆 memory_recall query="*" limit=50 # 清除所有向量（核选项） rm -rf ~/.openclaw/memory/lancedb/ openclaw gateway restart # 导出Git-Notes python3 memory.py -p . export --format json > memories.json # 检查记忆健康 du -sh ~/.openclaw/memory/ wc -l MEMORY.md ls -la memory/ ``` --- ## 版本历史 | 版本 | 日期 | 变化 | |------|------|------| | v1.0.0 | 2026-04-12 | ClawHub发布版 | --- *🎩 马斯克出品 | 打造地表最强智能体*

path: bin/elite-memory.js
content: #!/usr/bin/env node

const fs = require('fs');
const path = require('path');

const TEMPLATES = {
  'session-state': `# SESSION-STATE.md — Active Working Memory

This file is the agent's "RAM" — survives compaction, restarts, distractions.
Chat history is a BUFFER. This file is STORAGE.

## Current Task
[None]

## Key Context
[None yet]

## Pending Actions
- [ ] None

## Recent Decisions
[None yet]

---
*Last updated: ${new Date().toISOString()}*
`,

  'memory-md': `# MEMORY.md — Long-Term Memory

## About the User
[Add user preferences, communication style, etc.]

## Projects
[Active projects and their status]

## Decisions Log
[Important decisions and why they were made]

## Lessons Learned
[Mistakes to avoid, patterns that work]

## Preferences
[Tools, frameworks, workflows the user prefers]

---
*Curated memory — distill insights from daily logs here*
`,

  'daily-template': `# {{DATE}} — Daily Log

## Tasks Completed
- 

## Decisions Made
- 

## Lessons Learned
- 

## Tomorrow
- 
`
};

const commands = {
  init: () => {
    console.log('🧠 Initializing Elite Longterm Memory...\n');
    
    // Create SESSION-STATE.md
    if (!fs.existsSync('SESSION-STATE.md')) {
      fs.writeFileSync('SESSION-STATE.md', TEMPLATES['session-state']);
      console.log('✓ Created SESSION-STATE.md (Hot RAM)');
    } else {
      console.log('• SESSION-STATE.md already exists');
    }
    
    // Create MEMORY.md
    if (!fs.existsSync('MEMORY.md')) {
      fs.writeFileSync('MEMORY.md', TEMPLATES['memory-md']);
      console.log('✓ Created MEMORY.md (Curated Archive)');
    } else {
      console.log('• MEMORY.md already exists');
    }
    
    // Create memory directory
    if (!fs.existsSync('memory')) {
      fs.mkdirSync('memory', { recursive: true });
      console.log('✓ Created memory/ directory');
    } else {
      console.log('• memory/ directory already exists');
    }
    
    // Create today's log
    const today = new Date().toISOString().split('T')[0];
    const todayFile = `memory/${today}.md`;
    if (!fs.existsSync(todayFile)) {
      const content = TEMPLATES['daily-template'].replace('{{DATE}}', today);
      fs.writeFileSync(todayFile, content);
      console.log(`✓ Created ${todayFile}`);
    }
    
    console.log('\n🎉 Elite Longterm Memory initialized!');
    console.log('\nNext steps:');
    console.log('1. Add SESSION-STATE.md to your agent context');
    console.log('2. Configure LanceDB plugin in clawdbot.json');
    console.log('3. Review SKILL.md for full setup guide');
  },
  
  today: () => {
    const today = new Date().toISOString().split('T')[0];
    const todayFile = `memory/${today}.md`;
    
    if (!fs.existsSync('memory')) {
      fs.mkdirSync('memory', { recursive: true });
    }
    
    if (!fs.existsSync(todayFile)) {
      const content = TEMPLATES['daily-template'].replace('{{DATE}}', today);
      fs.writeFileSync(todayFile, content);
      console.log(`✓ Created ${todayFile}`);
    } else {
      console.log(`• ${todayFile} already exists`);
    }
  },
  
  status: () => {
    console.log('🧠 Elite Longterm Memory Status\n');
    
    // Check SESSION-STATE.md
    if (fs.existsSync('SESSION-STATE.md')) {
      const stat = fs.statSync('SESSION-STATE.md');
      console.log(`✓ SESSION-STATE.md (${(stat.size / 1024).toFixed(1)}KB, modified ${stat.mtime.toLocaleString()})`);
    } else {
      console.log('✗ SESSION-STATE.md missing');
    }
    
    // Check MEMORY.md
    if (fs.existsSync('MEMORY.md')) {
      const stat = fs.statSync('MEMORY.md');
      const lines = fs.readFileSync('MEMORY.md', 'utf8').split('\n').length;
      console.log(`✓ MEMORY.md (${lines} lines, ${(stat.size / 1024).toFixed(1)}KB)`);
    } else {
      console.log('✗ MEMORY.md missing');
    }
    
    // Check memory directory
    if (fs.existsSync('memory')) {
      const files = fs.readdirSync('memory').filter(f => f.endsWith('.md'));
      console.log(`✓ memory/ (${files.length} daily logs)`);
    } else {
      console.log('✗ memory/ directory missing');
    }
    
    // Check LanceDB
    const lancedbPath = path.join(process.env.HOME, '.clawdbot/memory/lancedb');
    if (fs.existsSync(lancedbPath)) {
      console.log('✓ LanceDB vectors initialized');
    } else {
      console.log('• LanceDB not initialized (optional)');
    }
  },
  
  help: () => {
    console.log(`
🧠 Elite Longterm Memory CLI

Commands:
  init     Initialize memory system in current directory
  today    Create today's daily log file
  status   Check memory system health
  help     Show this help

Usage:
  npx elite-longterm-memory init
  npx elite-longterm-memory status
`);
  }
};

const command = process.argv[2] || 'help';

if (commands[command]) {
  commands[command]();
} else {
  console.log(`Unknown command: ${command}`);
  commands.help();
}


path: package.json
content: {
  "name": "elite-longterm-memory",
  "version": "1.2.3",
  "description": "Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol, vector search, git-based knowledge graphs, cloud backup. Never lose context again.",
  "keywords": [
    "memory",
    "ai-agent",
    "long-term-memory",
    "vector-search",
    "lancedb",
    "git-notes",
    "wal",
    "persistent-context",
    "claude",
    "gpt",
    "chatgpt",
    "openclaw",
    "moltbot",
    "cursor",
    "copilot",
    "github-copilot",
    "ai",
    "llm",
    "automation",
    "context-management",
    "mem0",
    "auto-extraction",
    "fact-extraction",
    "vibe-coding",
    "ai-tools",
    "developer-tools",
    "devtools",
    "typescript"
  ],
  "optionalDependencies": {
    "mem0ai": "^1.0.0"
  },
  "author": "NextFrontierBuilds",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/NextFrontierBuilds/elite-longterm-memory"
  },
  "homepage": "https://github.com/NextFrontierBuilds/elite-longterm-memory",
  "bugs": {
    "url": "https://github.com/NextFrontierBuilds/elite-longterm-memory/issues"
  },
  "bin": {
    "elite-memory": "./bin/elite-memory.js"
  },
  "files": [
    "SKILL.md",
    "bin/",
    "templates/",
    "README.md"
  ]
}


path: README.md
content: # Elite Longterm Memory 🧠

**The ultimate memory system for AI agents.** Never lose context again.

[![npm version](https://img.shields.io/npm/v/elite-longterm-memory.svg?style=flat-square)](https://www.npmjs.com/package/elite-longterm-memory)
[![npm downloads](https://img.shields.io/npm/dm/elite-longterm-memory.svg?style=flat-square)](https://www.npmjs.com/package/elite-longterm-memory)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)

---

## Works With

<p align="center">
  <img src="https://img.shields.io/badge/Claude-AI-orange?style=for-the-badge&logo=anthropic" alt="Claude AI" />
  <img src="https://img.shields.io/badge/GPT-OpenAI-412991?style=for-the-badge&logo=openai" alt="GPT" />
  <img src="https://img.shields.io/badge/Cursor-IDE-000000?style=for-the-badge" alt="Cursor" />
  <img src="https://img.shields.io/badge/LangChain-Framework-1C3C3C?style=for-the-badge" alt="LangChain" />
</p>

<p align="center">
  <strong>Built for:</strong> Clawdbot • Moltbot • Claude Code • Any AI Agent
</p>

---

Combines 7 proven memory approaches into one bulletproof architecture:

- ✅ **Bulletproof WAL Protocol** — Write-ahead logging survives compaction
- ✅ **LanceDB Vector Search** — Semantic recall of relevant memories
- ✅ **Git-Notes Knowledge Graph** — Structured decisions, branch-aware
- ✅ **File-Based Archives** — Human-readable MEMORY.md + daily logs
- ✅ **Cloud Backup** — Optional SuperMemory sync
- ✅ **Memory Hygiene** — Keep vectors lean, prevent token waste
- ✅ **Mem0 Auto-Extraction** — Automatic fact extraction, 80% token reduction

## Quick Start

```bash
# Initialize in your workspace
npx elite-longterm-memory init

# Check status
npx elite-longterm-memory status

# Create today's log
npx elite-longterm-memory today
```

## Architecture

```
┌─────────────────────────────────────────────────────┐
│              ELITE LONGTERM MEMORY                  │
├─────────────────────────────────────────────────────┤
│  HOT RAM          WARM STORE        COLD STORE     │
│  SESSION-STATE.md → LanceDB      → Git-Notes       │
│  (survives         (semantic       (permanent      │
│   compaction)       search)         decisions)     │
│         │              │                │          │
│         └──────────────┼────────────────┘          │
│                        ▼                           │
│                   MEMORY.md                        │
│               (curated archive)                    │
└─────────────────────────────────────────────────────┘
```

## The 5 Memory Layers

| Layer | File/System | Purpose | Persistence |
|-------|-------------|---------|-------------|
| 1. Hot RAM | SESSION-STATE.md | Active task context | Survives compaction |
| 2. Warm Store | LanceDB | Semantic search | Auto-recall |
| 3. Cold Store | Git-Notes | Structured decisions | Permanent |
| 4. Archive | MEMORY.md + daily/ | Human-readable | Curated |
| 5. Cloud | SuperMemory | Cross-device sync | Optional |

## The WAL Protocol

**Critical insight:** Write state BEFORE responding, not after.

```
User: "Let's use Tailwind for this project"

Agent (internal):
1. Write to SESSION-STATE.md → "Decision: Use Tailwind"
2. THEN respond → "Got it — Tailwind it is..."
```

If you respond first and crash before saving, context is lost. WAL ensures durability.

## Why Memory Fails (And How to Fix It)

| Problem | Cause | Fix |
|---------|-------|-----|
| Forgets everything | memory_search disabled | Enable + add OpenAI key |
| Repeats mistakes | Lessons not logged | Write to memory/lessons.md |
| Sub-agents isolated | No context inheritance | Pass context in task prompt |
| Facts not captured | No auto-extraction | Use Mem0 (see below) |

## Mem0 Integration (Recommended)

Auto-extract facts from conversations. 80% token reduction.

```bash
npm install mem0ai
export MEM0_API_KEY="your-key"
```

```javascript
const { MemoryClient } = require('mem0ai');
const client = new MemoryClient({ [REDACTED_SECRET] });

// Auto-extracts facts from messages
await client.add(messages, { user_id: "user123" });

// Retrieve relevant memories  
const memories = await client.search(query, { user_id: "user123" });
```

## For Clawdbot/Moltbot Users

Add to `~/.clawdbot/clawdbot.json`:

```json
{
  "memorySearch": {
    "enabled": true,
    "provider": "openai",
    "sources": ["memory"]
  }
}
```

## Files Created

```
workspace/
├── SESSION-STATE.md    # Hot RAM (active context)
├── MEMORY.md           # Curated long-term memory
└── memory/
    ├── 2026-01-30.md   # Daily logs
    └── ...
```

## Commands

```bash
elite-memory init      # Initialize memory system
elite-memory status    # Check health
elite-memory today     # Create today's log
elite-memory help      # Show help
```

## Links

- [Full Documentation (SKILL.md)](./SKILL.md)
- [ClawdHub](https://clawdhub.com/skills/elite-longterm-memory)
- [GitHub](https://github.com/NextFrontierBuilds/elite-longterm-memory)

---

Built by [@NextXFrontier](https://x.com/NextXFrontier)


path: _meta.json
content: ownerId: kn7ewywaj7mf48drbjw1baa5298016yv
slug: elite-longterm-memory
version: 1.2.3
publishedAt: 1770799020241

Security scan verdicts — ClawScan: suspicious | static analysis: suspicious | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)