mema

TotalClaw 作者 totalclaw

Mema 的个人大脑 - SQLite 文档元数据索引和 Redis 短期上下文缓冲区。用于组织工作区知识路径和管理临时会话状态。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~1999azzar-mema
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~1999azzar-mema/file -o 1999azzar-mema.md
# Mema Brain (Centralized Memory)

Standardized memory system providing a Metadata Index (SQLite) and Short-Term Context (Redis).

## Core Components

### 1. Document Index (SQLite)
- **Primary Path:** `~/.openclaw/memory/main.sqlite`
- **Capability:** Stores file paths, titles, and tags. 
- **Note:** This is a **Metadata Index only**. It does not ingest or provide full-text search of file contents.

### 2. Short-Term Memory (Redis)
- **Key Prefix:** `mema:mental:*`
- **Purpose:** Ephemeral state management and cross-session context passing.
- **TTL:** Default 6 hours (21600 seconds).

## Core Workflows

### Indexing Knowledge
Record a file's location and tags in the local database.
- **Usage**: `python3 $WORKSPACE/skills/mema/scripts/mema.py index <path> [--tag <tag>]`

### Searching Index
List indexed paths filtered by tag or recency.
- **Usage**: `python3 $WORKSPACE/skills/mema/scripts/mema.py list [--tag <tag>]`

### Mental State (Redis)
Manage key-value pairs in the `mema:mental` namespace.
- **Set**: `python3 $WORKSPACE/skills/mema/scripts/mema.py mental set <key> <value> [--ttl N]`
- **Get**: `python3 $WORKSPACE/skills/mema/scripts/mema.py mental get <key>`

## Setup
1. Copy `env.example.txt` to `.env`.
2. Configure `REDIS_HOST` and `REDIS_PORT` (defaults: localhost:6379).
3. Initialize the SQLite schema:
   `python3 $WORKSPACE/skills/mema/scripts/mema.py init`

## Reliability & Security
- **Data Privacy**: All data is stored locally.
- **Network Safety**: Only point `REDIS_HOST` to trusted instances.
- **Path Isolation**: Database operations are confined to the `~/.openclaw/memory` directory.

---

## 中文说明

# Mema Brain(集中式记忆)

标准化记忆系统,提供元数据索引(SQLite)和短期上下文(Redis)。

## 核心组件

### 1. 文档索引(SQLite)
- **主路径:** `~/.openclaw/memory/main.sqlite`
- **能力:** 存储文件路径、标题和标签。
- **注意:** 这**仅是一个元数据索引**。它不会摄取文件内容,也不提供文件内容的全文搜索。

### 2. 短期记忆(Redis)
- **键前缀:** `mema:mental:*`
- **用途:** 临时状态管理和跨会话上下文传递。
- **TTL:** 默认 6 小时(21600 秒)。

## 核心工作流

### 索引知识
将文件的位置和标签记录到本地数据库中。
- **用法**:`python3 $WORKSPACE/skills/mema/scripts/mema.py index <path> [--tag <tag>]`

### 搜索索引
按标签或最近程度筛选并列出已索引的路径。
- **用法**:`python3 $WORKSPACE/skills/mema/scripts/mema.py list [--tag <tag>]`

### 心智状态(Redis)
管理 `mema:mental` 命名空间中的键值对。
- **设置**:`python3 $WORKSPACE/skills/mema/scripts/mema.py mental set <key> <value> [--ttl N]`
- **获取**:`python3 $WORKSPACE/skills/mema/scripts/mema.py mental get <key>`

## 设置
1. 将 `env.example.txt` 复制为 `.env`。
2. 配置 `REDIS_HOST` 和 `REDIS_PORT`(默认值:localhost:6379)。
3. 初始化 SQLite 模式:
   `python3 $WORKSPACE/skills/mema/scripts/mema.py init`

## 可靠性与安全
- **数据隐私**:所有数据均存储在本地。
- **网络安全**:仅将 `REDIS_HOST` 指向受信任的实例。
- **路径隔离**:数据库操作被限制在 `~/.openclaw/memory` 目录内。