Skip to main content
Glama

wasurenagusa

教你的 AI 编程助手从错误中学习。

npm version License: MIT Node.js Ko-fi

wasurenagusa (勿忘草) — 一种日本花卉,其名字意为“别忘了我”。


问题所在

AI 编程助手功能强大但患有“健忘症”。每个会话都从零开始——你的项目规范、过去的决策和辛苦学到的教训在会话结束时就会消失。

现有的解决方案要么需要手动操作,要么只是存储原始记忆,直到它们堆积如山,撑爆上下文窗口。

Related MCP server: memory-bank-mcp

解决方案

wasurenagusa 是一个 MCP 服务器,它不仅仅是记住,它还会学习

  1. 自动检测错误 — 捕捉重试模式、用户挫败感和重复出现的失败。

  2. 将教训提炼为原则 — LLM 将数百条原始记录压缩为少数几条可操作的规则。

  3. 化负为正 — 在每条原则旁生成 positiveRule:将“不要做 X”转换为“改为做 Y”。研究表明,LLM 遵循肯定性指令的效果远好于禁止性指令(粉色大象问题)。

  4. 将配置压缩为主题 — LLM 将分散的设置归纳为连贯的摘要,保留端口和路径等事实。

  5. 仅注入关键信息 — 仅注入整合后的智慧和活跃设置。没有模板冗余,没有重复条目。

  6. 混合搜索(全文 + 语义) — 基于 SQLite 的存储,支持本地嵌入推理(无需外部 API)。支持日语的全文搜索 + 向量语义搜索,合并并去重。完全离线运行。

  7. 智能标签检索 — LLM 生成的加权标签 + 综合评分(新鲜度、标签权重、访问频率)优化了检索优先级,且不会丢弃任何数据。

  8. 记忆暂存/恢复 — 将记忆暂时从活跃上下文中移出以节省空间,并在需要时恢复。非常适合带有子代理的长会话。

通过 Claude Code 钩子完全自动化——设置后无需任何配置。

实际影响

作者在 8 个生产项目中的日常使用(并在项目间共享记忆):

1,581 "dont" entries   →  5-9 principles per project    (LLM consolidation)
  each with positiveRule  →  affirmative-only injection  (Pink Elephant fix)
29 config entries      →  4-5 thematic summaries        (LLM consolidation)
21,800 chars raw data  →  6,200 chars injected           (71% reduction)

演示

  1. 会话 1:Claude 使用了端口 3000 — 用户将其纠正为 8080

  2. 停止钩子:wasurenagusa 自动分析对话并记录该错误

  3. 会话 2:Claude 在未被提醒的情况下正确使用了端口 8080


为什么选择 wasurenagusa

大多数记忆工具存储的是“发生了什么”。wasurenagusa 教你的 AI “为什么会出错”——并确保它永远不会重蹈覆辙。

它不是一个记忆库。它是一个学习系统

wasurenagusa

claude-mem

mcp-memory-service

CLAUDE.md

自动检测错误

是(重试 + 情感)

自动整合 (LLM)

是(不要→原则,配置→主题)

是(基于衰减)

向量语义搜索

是(本地推理,离线)

是 (ChromaDB)

是 (SQLite-vec / ChromaDB)

记忆分层 (短/中/长)

是(余弦距离阈值)

自动提升 (强度)

是(访问计数 → 强度 5)

通过钩子零负担

部分

人类可读存储

否 (SQLite — 从 v1 Markdown 自动迁移)

否 (SQLite)

否 (SQLite-vec)

多 LLM 支持

Gemini / OpenAI / Anthropic (嵌入是本地的 — 无需 API 密钥)

仅 Claude

本地 (MiniLM-L6-v2)

N/A

Token 效率检索

是(索引 → 详情,节省 70-90%)

是 (3 层)

N/A

跨项目记忆

是(前 5 个活跃项目)

许可证

MIT

AGPL-3.0

Apache-2.0

N/A


工作原理

Session Start (Hook) — injection mode
  → Checks if consolidation is stale
  → Spawns background LLM worker if needed (non-blocking)
  → Spawns background embedding backfill worker (non-blocking)
  → Injects consolidated config + principles (layer 1) + recent 30-day entries (layer 2) + owner profile
  → Vector search injects semantically related short-term memories (layer 3)
  → Cross-project vector search injects related memories from other active projects (layer 4)
  → Only customized settings injected (defaults stripped)

Session Start (Hook) — agent mode
  → Injects dont summary + config index + owner profile (minimal footprint)
  → No vector search at startup (deferred to on-demand recall)

User Prompt (Hook) — agent mode
  → Injects 1-line reminder: "search memory if relevant"
  → Main agent spawns memory-recall sub-agent as needed
  → Sub-agent runs memory_search → returns summary only (no raw data in main context)
  → Survives compaction (re-injected on every user message)

During Session
  → memory_save auto-generates embedding via local inference (no API call)
  → memory_save enriches tags with LLM-assigned weights (0.0-1.0) (when API key available)
  → Theme shift triggers background re-tagging of related past entries
  → memory_search merges keyword + vector semantic + tag-weighted results
  → Vector hits increment access counts → auto-promote to intensity 5 at threshold

Session End (Hook)
  → LLM analyzes the conversation
  → Detects mistakes, frustration, retry patterns
  → Auto-saves lessons learned (with embedding)
  → Deduplicates against existing entries before saving
  → Updates active projects tracker (top 5 recent projects)

Background (async workers)
  → Consolidates "dont" entries → behavioral principles
  → Consolidates "config" entries → thematic summaries
  → Backfills embeddings for entries created before vector layer (20/run)
  → Results used in next session start

快速开始

💡 推荐: 将此 README 粘贴到 Claude Code 中,让它为你设置 wasurenagusa。它会自动处理以下所有内容。

前置要求

  • Node.js 18+

  • Claude Code (CLI)

  • 核心记忆功能无需外部 API 密钥(嵌入在本地运行)

  • 可选:用于 LLM 整合/分析的 API 密钥 — Gemini / OpenAI / Anthropic

1. 安装

npm install -g wasurenagusa-mcp

或从源码安装:

git clone https://github.com/tsutushi0628/wasurenagusa-mcp.git
cd wasurenagusa-mcp
npm install && npm run build
npm link

npm run build 会自动对 CLI 入口点运行 chmod +x。无需手动设置权限。

2. 配置

创建 ~/.wasurenagusa/.env

# Set at least one API key
GEMINI_API_KEY=your-key-here
# OPENAI_API_KEY=your-key-here
# ANTHROPIC_API_KEY=your-key-here

变量

必需

描述

GEMINI_API_KEY

三选一

Google Gemini API 密钥

OPENAI_API_KEY

三选一

OpenAI API 密钥

ANTHROPIC_API_KEY

三选一

Anthropic API 密钥

LLM_PROVIDER

gemini (默认), openai, 或 anthropic

LLM_MODEL

覆盖提供商的默认模型

MEMORY_DIR

记忆目录 (默认: .wasurenagusa)

MAX_ENTRIES_PER_CATEGORY

自动归档前的每类条目限制 (默认: 100)

LOG_RETENTION_DAYS

日志保留天数 (默认: 30)

SLACK_WEBHOOK_URL

自主任务的 Slack 通知

3. 注册 MCP 服务器

claude mcp add wasurenagusa -- wasurenagusa-mcp

4. 设置钩子

⚠️ 必需 — 如果没有这一步,记忆将不会在会话开始时注入。这是最容易被遗漏的设置步骤。

添加到 ~/.claude/settings.json(如果希望将钩子分开,也可以使用 settings.local.json):

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "wasurenagusa-context",
            "timeout": 5
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "wasurenagusa-context",
            "timeout": 5
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "wasurenagusa-analyze",
            "timeout": 30
          }
        ]
      }
    ],
    "PreCompact": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "wasurenagusa-context",
            "timeout": 15
          }
        ]
      }
    ]
  }
}

5. 开始使用

启动 Claude Code。就是这样。

  • 首次会话:自动创建 .wasurenagusa/ 目录

  • 首次对话后:停止钩子分析并保存重要上下文

  • 第二次会话起:积累的智慧会在开始时自动注入

.wasurenagusa/ 添加到你的 .gitignore — 它包含项目特定的记忆数据。


记忆类别

类别

存储内容

文件

config

API URL、端口、认证位置

memory.db

dont

错误、反模式、用户挫败感

memory.db

decision

架构决策、技术选择

memory.db

log

实现记录、已解决的错误

memory.db

snippet

常用命令和查询

memory.db


MCP 工具

工具

描述

memory_get_context

获取配置 + 整合后的原则(在会话开始时自动调用)

memory_search

轻量级索引搜索(仅限 ID、标题、标签)。使用 project: "active" 进行跨项目搜索

memory_get_detail

通过 ID 获取完整详情

memory_save

显式保存记忆条目

memory_stash

暂时暂存记忆以节省上下文窗口空间

memory_restore

将之前暂存的记忆恢复到活跃上下文中

memory_delete

按 ID 删除条目

task_submit

提交一个 24/7 执行的自主任务

task_status

检查任务执行状态

task_action_list

列出并管理待处理的人类操作

project_init

初始化项目质量标准


CLI 命令

命令

用途

调用者

wasurenagusa-context

将配置 + dont + 向量记忆输出到 stdout

SessionStart / UserPromptSubmit / PreCompact 钩子

wasurenagusa-analyze

LLM 分析对话并自动保存

停止钩子

wasurenagusa-backfill

为没有向量的条目生成嵌入

后台(自动生成)

wasurenagusa-rebuild

修复损坏的记忆数据(去重、重新排序日志)

手动

wasurenagusa-spec-update

自动更新规范文档

cron / systemd 定时器

wasurenagusa-consolidate-all

在所有活跃项目上运行整合

手动 / 调度器

wasurenagusa-scheduler

安装/卸载/查看夜间整合调度器状态

手动


输出模式

wasurenagusa 为 SessionStart 钩子支持两种输出模式,可通过每个项目的 .wasurenagusa/config.json 进行配置。

模式

描述

适用场景

injection (默认)

在会话开始时注入完整记忆文本

没有子代理的环境 (Cursor, Windsurf 等)

agent

在会话开始时注入最小索引 + 在每条用户消息上提醒记忆召回。详情通过子代理按需获取

Claude Code + 代理团队

配置

outputMode 添加到项目的 .wasurenagusa/config.json

{
  "outputMode": "agent"
}

如果文件不存在或未设置 outputMode,则默认为 "injection"(完全向后兼容)。

推荐用于代理模式的 CLAUDE.md 规则

当在 Claude Code 代理团队中使用 "agent" 模式时,请将以下规则添加到项目的 CLAUDE.md 中:

- Read/write memories via sub-agents (memory_search / memory_get_detail / memory_save)
- Do not bring raw memory data into the main context
- When system-reminder suggests memory recall, spawn a sub-agent to run memory_search and return summary only

高级功能

向量记忆分层

wasurenagusa 引入了一个由本地嵌入驱动的仿生记忆系统。每条记忆都被转换为 384 维向量,实现了超越关键词匹配的基于意义的检索。

具有余弦距离阈值的三层架构:

层级

阈值

用例

短期

≤ 0.2

高度相关 — 在会话开始时自动注入

中期

≤ 0.45

上下文相关 — 在 memory_search 期间显示

长期

≤ 0.7

松散相关 — 可发现但不会主动显示

自动提升: 每当通过向量搜索检索到一条记忆时,其访问计数就会增加。在 5 次检索后,该记忆会自动提升至 intensity: 5 — 确保经常需要的知识在整合中获得最大权重。长期休眠的记忆可以通过相关性被“唤醒”,并最终通过重复访问获得最高强度。

工作原理:

memory_save
  → Text → local inference (Hugging Face Transformers) → embedding → SQLite (sqlite-vec)

memory_search "authentication setup"
  → Full-text search (FTS5, Japanese support) ─┐
  → Embed query → vector similarity search     ─┤→ merge, deduplicate → results
                                                └→ increment access count
                                                   → auto-promote if threshold met

SessionStart Hook
  → Embed project name → short-tier search → inject related memories

无需外部 API — 嵌入通过 @huggingface/transformers 在本地生成。数据存储在带有 sqlite-vec 的 SQLite 中以进行向量索引。完全离线工作。

从 v1 自动迁移 — 现有的基于 Markdown 的记忆文件在首次运行时会自动迁移到 SQLite。无需手动步骤。

智能标签检索

智能标签检索通过三种机制提高了搜索精度,且永远不会删除或遗忘数据:

  1. 保存时的加权标签丰富 — 当你保存记忆时,LLM 会生成描述性标签并为每个标签分配权重 (0.0-1.0)。端口号或 API 端点等具体事实会获得高权重;通用类别获得低权重。

  2. 主题转换时的后台重新打标签 — 当检测到新主题时,后台工作进程会更新相关过去条目的标签,以便它们在新的上下文中保持可发现性。

  3. 综合评分 — 搜索结果根据新鲜度、标签权重和访问频率的混合进行排名 — 首先显示最相关的记忆。

所有记忆都以完整保真度保存。智能标签检索仅优化检索优先级,从不丢弃数据。

跨项目记忆

wasurenagusa 会自动跟踪你最近使用的 5 个项目,并跨它们的记忆搜索相关上下文。

工作原理:

  1. 停止钩子 将每个项目会话记录在 ~/.wasurenagusa/scheduler/active-projects.json

  2. SessionStart 搜索其他活跃项目的向量存储(仅限短期层 ≤ 0.2,高相关性)

  3. memory_search 配合 project: "active" 搜索所有活跃项目(关键词 + 向量)

示例: 你正在处理 project-a,之前在 project-b 中讨论过身份验证。当你在 project-a 中开始会话且主题相关时,wasurenagusa 会自动从 project-b 中提取相关的身份验证记忆。

无需配置 — 在使用两个或更多项目后自动生效。

LLM 整合

当记忆条目积累时,LLM 会自动将它们压缩为紧凑的摘要:

  • Dont 条目 → 5-9 条行为原则,按 sourceCount × maxIntensity 评分。每条原则都包含原始 rule (❌→💡→✅ 格式) 和 positiveRule (仅肯定性措辞)。默认注入 positiveRule — 关于 粉色大象问题 的研究表明,LLM 在指令中的否定句上表现不佳。

  • Config 条目 → 4-5 个主题摘要(例如,29 条条目 → 5 个保留所有端口、路径、URL 的主题)

整合作为会话开始时的分离后台进程运行,也可作为夜间定时任务(凌晨 2:00)运行。结果被缓存为 JSON,并从下一次会话开始使用。通过比较文件修改时间和条

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A self-hosted MCP server that provides AI assistants with a shared, persistent SQLite-backed memory for storing and retrieving project context, decisions, and discoveries. It enables cross-session continuity and team-wide knowledge sharing to keep AI coding tools aligned and informed.
    3
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    An MCP server that gives AI assistants persistent memory across sessions. It stores project context, decisions, and progress in structured markdown files as well as a knowledge graph and sequential thinking for better memory storage.
    36
    37
    1
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    A local MCP server that gives AI assistants a long-term memory by capturing sessions verbatim and surfacing relevant context automatically.
    14
    794
    MIT

View all related MCP servers

Related MCP Connectors

  • Cloud-hosted MCP server for durable AI memory

  • Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.

  • An MCP memory server. One memory your agents share — across models, devices and apps.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tsutushi0628/wasurenagusa-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server