Skip to content

Smart Memory System

Verified

Smart Memory System — software development tool with token support.

96 downloads
$ Add to .claude/skills/

About This Skill

Content available in Chinese

# 🧠 Smart Memory System - 检索增强智能记忆系统

概述 基于检索增强(RAG)技术的智能记忆系统,为 OpenClaw 提供语义搜索、记忆优化和对话增强能力。

功能特性

🔍 **智能检索** - 语义搜索取代关键词搜索 - 80% token 消耗减少 - 基于相关性的记忆提取

🏗️ **记忆优化** - 自动聚类相似记忆 - 重要性评分系统 - 过期记忆清理

⚡ **实时增强** - 对话上下文智能扩展 - 相关历史自动注入 - 个性化响应生成

技术架构

🛠️ **核心组件** 1. **向量化引擎**: BAAI/bge-m3 embedding 模型 (1024维向量) 2. **重排序模块**: bge-reranker-v2-m3 3. **向量存储**: 本地 JSON + 语义缓存 4. **相似度算法**: 余弦相似度 + 自定义权重

📁 **系统结构** ``` smart-memory-skill/ ├── SKILL.md # 技能文档 ├── config/ # 配置文件 │ ├── smart_memory.json # 主配置 │ └── models.json # 模型配置 ├── scripts/ # 核心脚本 │ ├── vectorizer.js # 向量化引擎 │ ├── retriever.js # 检索引擎 │ ├── integrator.js # OpenClaw集成 │ └── monitor.js # 进度监控 ├── templates/ # 模板文件 │ ├── memory_chunk.md # 记忆分块模板 │ └── progress_report.md # 进度报告模板 └── examples/ # 使用示例 ├── basic_usage.md # 基础用法 └── advanced_integration.md # 高级集成 ```

安装配置

1. 前置条件 - OpenClaw 已安装并运行 - Edgefn API 密钥(用于 BAAl/bge-m3 和 reranker 模型) - Node.js 环境

2. 安装步骤 ```bash # 使用 ClawHub 安装 clawhub install smart-memory-system

# 或手动安装 git clone <repository> cp -r smart-memory-skill ~/.openclaw/skills/ ```

3. 配置模型 确保在 OpenClaw 配置中添加: ```json { "models": { "providers": { "edgefn": { "models": [ { "id": "BAAI/bge-m3", "name": "BAAI bge-m3 Embedding", "api": "openai-completions", "embedding_dimensions": 1024 }, { "id": "bge-reranker-v2-m3", "name": "BGE Reranker v2 m3", "api": "openai-completions" } ] } } } } ```

使用方法

🔧 **基础命令** ```bash # 初始化系统 openclaw skill smart-memory init

# 加载现有记忆 openclaw skill smart-memory load

# 语义搜索 openclaw skill smart-memory search "OpenClaw配置优化"

# 对话增强 openclaw skill smart-memory enhance "如何设置模型?"

# 系统状态 openclaw skill smart-memory status ```

⚙️ **OpenClaw 集成** ```javascript // 在 OpenClaw 配置中启用 { "skills": { "entries": { "smart-memory": { "enabled": true, "autoEnhance": true, "maxContextTokens": 2000 } } } } ```

🚀 **高级功能** ```bash # 批量处理记忆文件 openclaw skill smart-memory batch-process ~/documents/

# 生成记忆报告 openclaw skill smart-memory report --format=html

# 优化索引 openclaw skill smart-memory optimize --aggressive

# 监控模式 openclaw skill smart-memory monitor --interval=5 ```

性能指标

智能记忆系统优化 | 指标 | 改进前 | 改进后 | 提升 | |------|--------|--------|------| | **Token 消耗** | 8k-16k | 1k-3k | **-80%** | | **检索准确率** | 60% | 95% | **+35%** | | **响应相关性** | 70% | 95% | **+25%** | | **记忆覆盖率** | 50% | 90% | **+40%** |

结合上下文压缩功能 系统已配置 OpenClaw 上下文压缩功能,提供双重优化:

#### 上下文压缩配置 ```json { "mode": "cache-ttl", "ttl": "5m", "keepLastAssistants": 3, "softTrimRatio": 0.3, "hardClearRatio": 0.5, "minPrunableToolChars": 50000, "softTrim": { "headChars": 1500, "tailChars": 1500 }, "hardClear": { "enabled": true, "placeholder": "[旧工具结果内容已清理]" }, "tools": { "deny": ["browser", "canvas"] } } ```

#### 双重优化效果 | 优化方式 | Token 节省 | 实现机制 | |---------|-----------|----------| | 智能记忆系统 | 80% | 语义检索替代完整历史 | | 上下文压缩 | 70% | 清理工具调用结果 | | 双重优化 | 90%+ | 两者结合,全面优化 |

  • #### 压缩触发条件
  • 软修剪: 上下文使用率 > 30% (保留头尾1500字符)
  • 硬清理: 上下文使用率 > 50% 且可修剪内容 > 50,000字符
  • 保护机制: 保留最近3次助手回复和重要工具结果

使用场景

💼 **个人助手** - 智能记住用户偏好和习惯 - 跨会话记忆延续 - 个性化建议生成

🏢 **团队协作** - 共享知识库检索 - 项目历史追溯 - 决策依据存档

🔬 **研究分析** - 文献智能检索 - 研究笔记整理 - 洞察发现支持

💻 **开发支持** - 代码库语义搜索 - 技术文档检索 - 错误解决方案匹配

配置选项

主配置 (`config/smart_memory.json`) ```json { "embedding_model": "edgefn/BAAI/bge-m3", "reranker_model": "edgefn/bge-reranker-v2-m3", "chunk_size": 500, "overlap": 50, "top_k_results": 5, "min_similarity": 0.6, "cache_ttl_hours": 168, "auto_enhance": true, "max_context_tokens": 2000, "importance_scoring": { "age_weight": 0.2, "frequency_weight": 0.3, "relevance_weight": 0.5 } } ```

扩展开发

🔌 **插件系统** ```javascript // 自定义记忆处理器 class CustomMemoryProcessor { async process(memory) { // 自定义处理逻辑 return enhancedMemory; } }

// 注册插件 smartMemorySystem.registerPlugin('custom-processor', new CustomMemoryProcessor()); ```

🎨 **主题模板** ```markdown // 自定义记忆模板 --- title: "{{title}}" date: "{{date}}" tags: ["{{tags}}"] importance: {{importance}} summary: "{{summary}}" --- ```

🔄 **数据导出** 支持多种格式导出: - JSON(结构化数据) - Markdown(可读文档) - CSV(数据分析) - HTML(可视化报告)

故障排除

🐛 **常见问题** 1. **向量化失败**: 检查 Edgefn API 密钥和网络连接 2. **检索慢**: 调整 chunk_size 和 top_k_results 参数 3. **内存占用高**: 启用缓存清理或减少索引大小 4. **集成问题**: 检查 OpenClaw 配置和权限

📋 **日志查看** ```bash # 查看系统日志 tail -f ~/.openclaw/logs/smart-memory.log

# 查看调试信息 openclaw skill smart-memory debug --verbose ```

🛠️ **维护命令** ```bash # 清理缓存 openclaw skill smart-memory cleanup

# 重建索引 openclaw skill smart-memory reindex

# 备份数据 openclaw skill smart-memory backup ~/backup/

# 恢复系统 openclaw skill smart-memory restore ~/backup/latest/ ```

路线图

🎯 **近期计划** - [ ] 多语言支持 - [ ] 实时协作功能 - [ ] 移动端适配 - [ ] 更多导出格式

🔮 **长期愿景** - [ ] 分布式记忆网络 - [ ] 预测性记忆推送 - [ ] 情感分析集成 - [ ] 跨平台同步

贡献指南

👥 **开发贡献** 1. Fork 项目仓库 2. 创建功能分支 (`git checkout -b feature/amazing-feature`) 3. 提交更改 (`git commit -m 'Add amazing feature'`) 4. 推送到分支 (`git push origin feature/amazing-feature`) 5. 创建 Pull Request

📝 **文档贡献** - 完善使用示例 - 添加多语言文档 - 创建教程视频 - 翻译文档内容

🐛 **问题反馈** 在 GitHub Issues 中报告问题,包括: 1. 问题描述 2. 重现步骤 3. 预期行为 4. 实际行为 5. 环境信息

许可证 MIT License - 详见 LICENSE 文件

支持 - 📧 邮箱: [email protected] - 💬 Discord: [加入社区](https://discord.gg/smart-memory) - 📖 文档: [在线文档](https://docs.smart-memory.dev) - 🐛 Issues: [GitHub Issues](https://github.com/org/smart-memory-system/issues)

---

🎉 欢迎使用检索增强智能记忆系统,让您的 OpenClaw 更智能、更高效!

Use Cases

  • Analyze data and content to extract actionable insights
  • Generate structured output from specifications or requirements
  • Automate repetitive workflows to save time and reduce errors
  • Monitor systems and processes for anomalies and performance issues
  • Search and retrieve information from various data sources

Pros & Cons

Pros

  • +Supports batch processing for efficient high-volume operations
  • +Integrates into existing development workflows without disruption
  • +Improves development velocity through automation and best practices

Cons

  • -Adds another tool to the development stack that needs maintenance
  • -May overlap with functionality already provided by IDE or other tools

FAQ

What does Smart Memory System do?
Smart Memory System — software development tool with token support.
What platforms support Smart Memory System?
Smart Memory System is available on Claude Code, OpenClaw.
What are the use cases for Smart Memory System?
Analyze data and content to extract actionable insights. Generate structured output from specifications or requirements. Automate repetitive workflows to save time and reduce errors.

100+ free AI tools

Writing, PDF, image, and developer tools — all in your browser.

Next Step

Use the skill detail page to evaluate fit and install steps. For a direct browser workflow, move into a focused tool route instead of staying in broader support surfaces.