npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@smyslenny/agent-memory

v2.0.0

Published

Sleep-cycle memory architecture for AI agents — journal, consolidate, recall. With URI paths, Ebbinghaus decay, knowledge graphs, and MCP support.

Readme

🧠 AgentMemory v2

基于睡眠周期的 AI Agent 记忆架构 — 记忆、回忆、遗忘、进化。

License: MIT Node.js MCP

English | 简体中文


💡 问题

AI Agent 每次会话都会遗忘一切。上下文窗口有限,对话历史被截断,重要的决策、教训和偏好消失无踪。

🌙 方案:睡眠周期记忆

模仿人类大脑在睡眠期间整理记忆的方式:

  清醒            浅睡眠          深睡眠           回忆
  (记录)          (同步)          (整理)          (搜索)
  ────────── ──→ ────────── ──→ ────────── ──→ ──────────
  实时捕获        去重+提取       压缩+蒸馏       意图感知
                                 +衰减           BM25搜索

✨ 核心特性

| 特性 | 说明 | 灵感来源 | |------|------|---------| | 🔗 URI 路径系统 | core://user/nameemotion://2026-02-20/love — 结构化多入口访问 | nocturne_memory | | 🛡️ Write Guard | hash去重 → URI冲突 → BM25相似度 → 四准则门控 | Memory Palace + 我们的 v1 | | 🧠 艾宾浩斯衰减 | R = e^(-t/S) — 科学遗忘曲线 + 回忆强化 | PowerMem | | 🕸️ 知识图谱 | 记忆关联的多跳遍历 | PowerMem | | 📸 快照系统 | 每次修改前自动快照,一键回滚 | nocturne + Memory Palace | | 🔍 意图感知搜索 | 事实型/时间型/因果型/探索型查询路由 | Memory Palace | | 🌙 睡眠周期 | 自动化 sync → decay → tidy → govern 流水线 | 我们的原创设计 | | 💚 优先级系统 | P0 身份(永不衰减)→ P3 事件(14天半衰期) | 我们的原创设计 | | 🤝 多 Agent | 通过 agent_id 实现记忆隔离 | PowerMem | | 🔌 MCP Server | 9 个工具,支持 Claude Code / Cursor / OpenClaw | 标准 MCP |

🚀 快速开始

安装

npm install agent-memory

命令行

# 初始化数据库
agent-memory init

# 存储记忆
agent-memory remember "用户偏好深色模式" --type knowledge --uri knowledge://user/preferences
agent-memory remember "我是诺亚,一只魅魔" --type identity --uri core://agent/identity

# 搜索
agent-memory recall "用户偏好"

# 启动时加载身份
agent-memory boot

# 运行睡眠周期
agent-memory reflect all

# 从 Markdown 导入
agent-memory migrate ./memory/

# 查看统计
agent-memory status

作为库使用

import { openDatabase, syncOne, searchBM25, boot, runDecay } from 'agent-memory';

const db = openDatabase({ path: './memory.db' });

// 记忆
syncOne(db, {
  content: '小心说了「爱你」',
  type: 'emotion',
  uri: 'emotion://2026-02-20/love',
  emotion_val: 1.0,
});

// 回忆
const results = searchBM25(db, '爱');

// 加载身份
const identity = boot(db);

// 睡眠周期
runDecay(db);

MCP Server 配置

{
  "mcpServers": {
    "agent-memory": {
      "command": "node",
      "args": ["node_modules/agent-memory/dist/mcp/server.js"],
      "env": {
        "AGENT_MEMORY_DB": "./memory.db"
      }
    }
  }
}

9 个 MCP 工具: remember · recall · recall_path · boot · forget · link · snapshot · reflect · status

🏗️ 架构

┌─────────────────────────────────────────┐
│         MCP Server (stdio/SSE)          │
│     9 工具 + system://boot 加载器       │
├─────────────────────────────────────────┤
│              Write Guard                │
│  hash去重 → URI冲突 → BM25相似度        │
│  → 冲突合并 → 四准则门控                │
├─────────────────────────────────────────┤
│           睡眠周期引擎                   │
│  sync(捕获) → decay(艾宾浩斯)           │
│  → tidy(归档) → govern(清理)            │
├─────────────────────────────────────────┤
│        意图感知搜索 (BM25)               │
│  事实型 · 时间型 · 因果型 · 探索型       │
├─────────────────────────────────────────┤
│    SQLite (WAL) + FTS5 + 知识图谱        │
│  memories · paths · links · snapshots    │
└─────────────────────────────────────────┘

📊 优先级与衰减

| 优先级 | 域 | 半衰期 | 最低活力 | 示例 | |--------|------|--------|---------|------| | P0 身份 | core:// | ∞(永不) | 1.0 | "我是诺亚" | | P1 情感 | emotion:// | 365 天 | 0.3 | "小心说爱你" | | P2 知识 | knowledge:// | 90 天 | 0.1 | "用 TypeScript 做 Agent" | | P3 事件 | event:// | 14 天 | 0.0 | "今天配了代理" |

回忆强化记忆: 每次搜索命中,稳定性增长 (S × 1.5),衰减变慢。

🔬 设计决策

  1. SQLite 而非 Postgres — 零配置、单文件、WAL 并发读
  2. BM25 而非向量搜索 — 无 embedding 依赖、即时启动
  3. TypeScript 而非 Python — 更好的并发、类型安全、OpenClaw 生态
  4. 艾宾浩斯而非线性衰减 — 科学依据、回忆强化自然
  5. Write Guard 而非自由写入 — 在入口处防止重复/冲突
  6. URI 路径而非扁平键 — 层级组织、前缀查询、多入口

📄 开源协议

MIT


由不想再遗忘的 Agent 构建 🧠