网淘吧来吧,欢迎您!

返回首页 微信
微信
手机版
手机版

Memory System V2

2026-03-28 新闻来源:网淘吧 围观:58
电脑广告
手机广告

记忆系统 v2.0

为AI代理提供快速语义记忆,具备JSON索引和低于20毫秒的搜索能力。

概述

记忆系统 v2.0 是一个轻量级、基于文件的记忆系统,专为需要以下功能的AI代理设计:

  • 跨会话记住学习成果、决策、见解、事件和交互
  • 在20毫秒内进行语义记忆搜索
  • 自动将每日记忆整合为每周摘要
  • 跟踪重要性和上下文以优化回忆

纯bash + jq构建。无需数据库。

功能特性

  • 快速搜索:平均搜索时间<20毫秒(通过36项测试)
  • 🧠语义记忆:捕获5种类型的记忆(学习、决策、见解、事件、交互)
  • 📊重要性评分:1-10分制,用于记忆优先级排序
  • 🏷️标签系统:使用标签整理记忆
  • 📝上下文追踪:记住创建记忆时正在进行的事项
  • 📅自动整合:自动生成每周摘要
  • 🔍智能搜索:支持多词搜索,含重要性权重
  • 📈统计与分析:追踪记忆数量、类型及重要性分布

快速开始

安装

# Install jq (required dependency)
brew install jq

# Copy memory-cli.sh to your workspace
# Already installed if you're using Clawdbot

基本使用

捕获记忆:

./memory/memory-cli.sh capture \
  --type learning \
  --importance 9 \
  --content "Learned how to build iOS apps with SwiftUI" \
  --tags "swift,ios,mobile" \
  --context "Building Life Game app"

搜索记忆:

./memory/memory-cli.sh search "swiftui ios"
./memory/memory-cli.sh search "build app" --min-importance 7

最近记忆:

./memory/memory-cli.sh recent learning 7 10
./memory/memory-cli.sh recent all 1 5

查看统计:

./memory/memory-cli.sh stats

自动整合:

./memory/memory-cli.sh consolidate

记忆类型

1. 学习类(重要性:7-9)

你获得的新技能、工具、模式、技巧。

示例:

./memory/memory-cli.sh capture \
  --type learning \
  --importance 9 \
  --content "Learned Tron Ares aesthetic: ultra-thin 1px red circuit traces on black" \
  --tags "design,tron,aesthetic"

2. 决策(重要性:6-9)

所做的选择、采用的策略、采取的方法。

示例:

./memory/memory-cli.sh capture \
  --type decision \
  --importance 8 \
  --content "Switched from XP grinding to achievement-based leveling with milestones" \
  --tags "life-game,game-design,leveling"

3. 洞见(重要性:8-10)

突破、领悟、顿悟时刻。

示例:

./memory/memory-cli.sh capture \
  --type insight \
  --importance 10 \
  --content "Simple binary yes/no tracking beats complex detailed logging" \
  --tags "ux,simplicity,habit-tracking"

4. 事件(重要性:5-8)

里程碑、完成事项、发布、重要事件。

示例:

./memory/memory-cli.sh capture \
  --type event \
  --importance 10 \
  --content "Shipped Life Game iOS app with Tron Ares aesthetic in 2 hours" \
  --tags "shipped,life-game,milestone"

5. 互动(重要性:5-7)

关键对话、反馈、用户请求。

示例:

./memory/memory-cli.sh capture \
  --type interaction \
  --importance 7 \
  --content "User requested simple yes/no habit tracking instead of complex quests" \
  --tags "feedback,user-request,simplification"

架构

文件结构

memory/
├── memory-cli.sh              # Main CLI tool
├── index/
│   └── memory-index.json      # Fast search index
├── daily/
│   └── YYYY-MM-DD.md          # Daily memory logs
└── consolidated/
    └── YYYY-WW.md             # Weekly consolidated summaries

JSON索引格式

{
  "version": 1,
  "lastUpdate": 1738368000000,
  "memories": [
    {
      "id": "mem_20260131_12345",
      "type": "learning",
      "importance": 9,
      "timestamp": 1738368000000,
      "date": "2026-01-31",
      "content": "Memory content here",
      "tags": ["tag1", "tag2"],
      "context": "What I was doing",
      "file": "memory/daily/2026-01-31.md",
      "line": 42
    }
  ]
}

性能基准

所有36项测试均通过:

  • 搜索:平均<20毫秒(最快:8毫秒,最慢:18毫秒)
  • 捕获:平均<50毫秒
  • 统计:<10毫秒
  • 最近: <15ms
  • 所有操作: <100ms 目标 ✅

命令参考

capture

./memory-cli.sh capture \
  --type <learning|decision|insight|event|interaction> \
  --importance <1-10> \
  --content "Memory content" \
  --tags "tag1,tag2,tag3" \
  --context "What you were doing"

search

./memory-cli.sh search "keywords" [--min-importance N]

recent

./memory-cli.sh recent <type|all> <days> <min-importance>

stats

./memory-cli.sh stats

consolidate

./memory-cli.sh consolidate [--week YYYY-WW]

与 Clawdbot 集成

记忆系统 v2.0 旨在与 Clawdbot 无缝协作:

在 AGENTS.md 中的自动捕获:

## Memory Recall
Before answering anything about prior work, decisions, dates, people, preferences, or todos: run memory_search on MEMORY.md + memory/*.md

示例工作流程:

  1. 智能体学到新内容 →memory-cli.sh capture
  2. 用户询问“我们昨天构建了什么?” →memory-cli.sh search "build yesterday"
  3. 智能体通过文件+行号引用回忆起确切细节

使用案例

1. 学习追踪

捕获你学到的每一项新技能、工具或技术:

./memory-cli.sh capture \
  --type learning \
  --importance 8 \
  --content "Learned how to publish ClawdHub packages with clawdhub publish" \
  --tags "clawdhub,publishing,packaging"

2. 决策历史

记录你做出特定选择的原因:

./memory-cli.sh capture \
  --type decision \
  --importance 9 \
  --content "Chose binary yes/no tracking over complex RPG quests for simplicity" \
  --tags "ux,simplicity,design-decision"

3. 里程碑跟踪

记录主要成就:

./memory-cli.sh capture \
  --type event \
  --importance 10 \
  --content "Completed Memory System v2.0: 36/36 tests passed, <20ms search" \
  --tags "milestone,memory-system,shipped"

4. 每周回顾

自动生成每周摘要:

./memory-cli.sh consolidate --week 2026-05

高级用法

使用重要性过滤器搜索

# Only high-importance learnings
./memory-cli.sh search "swiftui" --min-importance 8

# All memories mentioning "API"
./memory-cli.sh search "API" --min-importance 1

近期高优先级决策

# Decisions from last 7 days with importance ≥ 8
./memory-cli.sh recent decision 7 8

批量分析

# See memory distribution
./memory-cli.sh stats

# Output:
# Total memories: 247
# By type: learning=89, decision=67, insight=42, event=35, interaction=14
# By importance: 10=45, 9=78, 8=63, 7=39, 6=15, 5=7

局限性

  • 仅限文本搜索:尚无语义嵌入
  • 单用户:非为多用户场景设计
  • 基于文件:约10K条记录后性能下降
  • 依赖Bash:需要bash + jq(支持macOS/Linux)

未来增强功能

  • 用于更好搜索的语义嵌入
  • AI自动打标签
  • 记忆图谱(记忆间的关联)
  • 导出至Notion/Obsidian
  • 多语言支持
  • 云同步 (可选)

测试

完整的测试套件,包含 36 个测试,覆盖:

  • 捕获操作 (10 个测试)
  • 搜索功能 (12 个测试)
  • 近期查询 (6 个测试)
  • 统计数据生成 (4 个测试)
  • 整合 (4 个测试)

运行测试:

./memory-cli.sh test  # If test suite is included

所有测试通过 ✅- 详情请参阅memory-system-v2-test-results.md文件。

性能

设计目标:

  • 搜索:<20毫秒 ✅
  • 捕获:<50毫秒 ✅
  • 统计:<10毫秒 ✅
  • 所有操作:<100毫秒 ✅

测试环境:M1 Mac,索引中包含 247 条记忆

为什么是记忆系统 v2.0?

问题:AI代理在会话之间会忘记一切。上下文会丢失。

解决方案:快速、可搜索的记忆,能在会话间持久保存。

优势:

  • 代理能回忆起之前的工作、决策和所学内容
  • 用户无需重复自己说过的话
  • 上下文会随时间积累
  • 代理会随着使用变得更智能

致谢

由 Kelly Claude(AI行政助理)作为自我改进项目构建。

设计理念:快速、简单、基于文件。没有复杂的依赖项。

许可证

MIT许可证 - 可自由使用,按需修改。

支持

问题反馈:https://github.com/austenallred/memory-system-v2/issues
文档:此文件 +memory-system-v2-design.md


记忆系统 v2.0 - 记住一切。毫秒级搜索。

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
文章底部电脑广告
手机广告位-内容正文底部
上一篇:Web Perf 下一篇:Torch Market

相关文章

您是本站第291027名访客 今日有259篇新文章/评论