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

whale-memory-core

v0.34.0

Published

Self-layer autobiographical memory core: then / later, append-only. Vault, evidence and consolidation live in the QQ Agent plugin.

Readme

whale-memory/core

自传层内核:只管"她自己的经历"这一层,不是完整的记忆系统。纯 ESM、只用 Node 内置模块。

import * as exp from 'whale-memory-core/self-experience'

npm 包版本见本包的 package.json。宿主可依赖的 API、字段、文件格式和错误形状列在随包分发的 v1 契约 §0.1。exports 列出可导入的路径,兼容承诺以契约点名的接口为准。

包含什么、不包含什么

包含:

  • then / later 两层经历,改主意不覆盖旧想法
  • 分层来源:每段文字带自己的来源字段与记录时间;封存沿出处生效(原经历封存,引用它的后记与未完事项一起退出)
  • 双通道回想 recallDual(BM25 + 语料共现向量)与按提问时点取想法(「当时」引 then.*,「后来」才引 later[*])
  • 召回(相关度 × 重要度)、想起计数、两段式渲染
  • 醒来块、她自己的提示词 overlay、她自己的设置

不包含(完整引擎与具体宿主部署耦合,不随本仓库分发):

  • vault 存储与索引、evidence-policy 取证、consolidator 合并、注入预算
  • 跨会话可见性判断、宿主工具注册(分层读取可传 allows(row) 由宿主过滤)

如果你要的是"一个 agent 的自传记忆",这个包够用;如果你要的是"完整记忆系统",看 docs/architecture.md 与 docs/porting.md。

包名 whale-memory-core,入口:whale-memory-core(命名导出),以及 package.json exports 里列出的若干子路径(如 /self-experience、/self-memory、/waking、/self-prompt、/self-settings、/hybrid-recall、/seal-events)。

| 模块 | 作用 | |---|---| | self-experience.js | 经历两层(then / later)、重要度、两段式回想 | | self-memory.js | 经历 + 日记的统一读取与渲染 | | waking.js | 醒来块:每天第一次唤醒给昨天的时间线(是否注入由调用方决定) | | self-prompt.js | 提示词 overlay:版本只追加、可回退 | | self-settings.js | 她自己的设置(软限制归她),改动写进她的经历 | | memory-layers.js | 分层读取与出处:visibleEvents / readLayers,封存沿出处,allows 由宿主传入 | | dual-recall.js | 双通道回想:BM25 + 语料共现向量,事件级 RRF,层内引用 | | local-recall.js | 本机模型核对:候选、前提核对、独立动作复核;premise 模式与 deep 第二机会 | | context-vectors.js | 语料共现向量(零依赖,进程内) |

安装

npm install whale-memory-core

已发布在 npm:whale-memory-core(npmjs.com,最新版本以 npm 为准)。也可以从仓库本地安装:npm install ./packages/core。

包名带 -core。npm 上不带 -core 的 whale-memory 是别人的包,和本项目无关,别装错。

从零开始接一个角色,看 30 分钟教程。

当 MCP 服务用

包里带一个 MCP 服务(stdio、只在本机、零依赖),接到 Claude Desktop、Claude Code、Cursor 等客户端:

npx -y -p whale-memory-core whale-memory-mcp --data /path/to/data

抽屉默认不开(--owner true 才开),--readonly true 只给读的工具。工具表与配置写法见仓库里的 adapters/mcp/README.md。

体检、备份和本机服务(0.33.0 起)

统一入口 whale-memory 把记忆命令和运维工具收在一起,装了包不用克隆仓库:

npx -y -p whale-memory-core whale-memory doctor /path/to/data/plugin-data/biomimetic-memory --json   # 六项体检,只读
npx -y -p whale-memory-core whale-memory backup --data /path/to/data --out /path/to/backups
npx -y -p whale-memory-core whale-memory restore-check --from /path/to/backups/<备份包>

常驻进程(比如 Python)可以走本机 HTTP 服务:只听回环、必须带令牌,工具表与 MCP 同一张,不提供导入、导出、删除。令牌文件要放在数据根之外:

npx -y -p whale-memory-core whale-memory-serve --data /path/to/data --token-file /path/outside/data/serve.token

参数与安全边界见仓库里的 adapters/http/README.md。

运行示例

node demo.mjs

不需要配置文件、不需要 API key、不联网。演示会在临时目录里建一份数据,结束时会输出目录位置,方便检查记录。

路径约定(容易踩)

不同模块接受的目录不一样:

| 传什么 | 模块 | | --- | --- | | 记忆目录 <data>/plugin-data/biomimetic-memory | self-experience(addExperience / loadAll / recall)、self-memory、recall-events、later-events | | 数据根目录 <data> | waking、self-prompt、self-settings |

传错不会报错,只会写到另一个位置。CLI 已经替你处理好了:exp.* 收 MEM_DIR,其余收 DATA。

数据

一条经历一行 JSON,格式见 docs/schema.md。三条虚构样本在 examples/samples/。

移植说明见仓库根目录 docs/porting.md。 | 模块 | 作用 | |---|---| | self-experience.js | 经历两层(then / later)、重要度、两段式回想 | | self-memory.js | 经历 + 日记的统一读取与渲染 | | waking.js | 醒来块:每天第一次唤醒给昨天的时间线 | | self-prompt.js | 提示词 overlay:版本只追加、可回退 | | self-settings.js | 她自己的设置(软限制归她) | | time-sense.js | 人话时间:刚刚 / 昨天 20:30 / 上周三 / 2 个月前 | | relative-window.js | 把「前几天 / 上周三 / 两周前」翻成时间窗口 | | person-card.js | 把「这个人是谁」压成一行;匹配不到就不写 | | scope-key.js | 会话作用域键:会话级与人设级的不对称规则 | | conversation-privacy.js | 跨窗口可见性判定 + 确定性脱敏 | | fact-card.js | 规则抽事实:项目、预算、喜恶、所在地、关系 | | fact-store.js | 事实卡存储与相关性挑选(宁可不说,不乱说) | | fact-judge.js | 模型抽事实的封装,引文必须能在原文找到 |