@yottameta/yotta-memory 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/NOTICE +11 -0
- package/README.md +161 -188
- package/README.zh-CN.md +304 -0
- package/SKILL.md +2 -2
- package/bin/yotta-memory.js +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# 更新日志
|
|
2
|
+
|
|
3
|
+
## v0.8.3 (2026-08-28)
|
|
4
|
+
|
|
5
|
+
中英双语 README 对齐(老张拍板「英文门面 + 中文全档」):
|
|
6
|
+
|
|
7
|
+
- **README.md 改为英文**:作为 GitHub / npm / ClawHub 首页的英文门面(翻译 + 精简,覆盖定位 / 核心价值 / 四类型 / 权限隔离 / 身份 / 语义检索 / 生命周期 / 对比 / 安装(CLI+技能双装)/ 升级 / CLI 用法 / 局域网共享 / 开发校验全流程)。
|
|
8
|
+
- **新增 README.zh-CN.md**:原中文完整主文档整体平移,顶部加语言切换链接。
|
|
9
|
+
- **新增 NOTICE + .npmignore + CHANGELOG.md**:对齐 YottaMeta 技能家族标准(品牌声明 + npm 打包排除 + 更新日志)。
|
|
10
|
+
- **package.json**:description 改英文;files 加 README.zh-CN.md / NOTICE / CHANGELOG.md;版本 0.8.2 → 0.8.3。
|
|
11
|
+
- 版本四处对齐:package.json / SKILL frontmatter / 引擎 VERSION / 文档。
|
|
12
|
+
- 边界(B 方案):references / USER_GUIDE / 测试注释不翻译;SKILL 触发描述保持中文。
|
|
13
|
+
|
|
14
|
+
## 历史版本
|
|
15
|
+
|
|
16
|
+
- **v0.8.2 (2026-08-27)**:发布元数据修复——ClawHub 重发带 `--name 元忆 yotta-memory`,修复展示名缺失中文;无功能变更。
|
|
17
|
+
- **v0.8.1 (2026-08-27)**:view 用户查看平台服务端分页 + recall 候选预过滤 + 公共 index.json 超 5000 条按年份分片。
|
|
18
|
+
- **v0.8.0 (2026-08-27)**:自我学习/自我进化/自我提升——语义检索(同义词/拼音/字段加权/模糊)+ 效用分融合排序 + feedback 反馈闭环 + maintain 规则层自组织 + distill 心理日志蒸馏 + explain;索引 version 3 旧库自动重建。
|
|
19
|
+
- **v0.7.0 (2026-08-27)**:私密区机制级加密(AES-256-GCM 信封加密 + 口令派生主密钥 + 恢复钥匙 + 每 owner 加密索引)+ view 用户查看平台 + migrate + reset-password + key 授权 + context 收工纪律。
|
|
20
|
+
- **v0.6.5**:recall/context 根位置去重。
|
|
21
|
+
- **v0.6.4**:lan enable Linux 开机自启(systemd 用户单元 / 用户 crontab @reboot 降级)。
|
|
22
|
+
- **v0.6.3**:开机自启 VBS 自愈(内联启动命令,根治 80070002)。
|
|
23
|
+
- **v0.6.2**:remember --verify 写后回读确定性判定。
|
|
24
|
+
- **v0.6.1**:context --budget 字符预算 + 多智能体接入铁律 + remember --source/--weight + 近期记忆排序融合。
|
|
25
|
+
- **v0.6.0**:灵魂盘核心——profile 用户画像 + context 开工上下文包 + iam 扩展 + remember --verify + SKILL 记忆守则。
|
|
26
|
+
- **v0.5.4**:lan enable 非管理员自动降级用户级 Startup 静默自启。
|
|
27
|
+
- **v0.5.3**:CLI 选项可前置。
|
|
28
|
+
- **v0.5.2**:schtasks /tr 引号写法修复。
|
package/NOTICE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# NOTICE — YottaMeta 品牌声明
|
|
2
|
+
|
|
3
|
+
「YottaMeta」「元忆」「yotta-memory」以及本家族各技能名称(yotta-* 前缀)是 YottaMeta 的品牌与标识。
|
|
4
|
+
|
|
5
|
+
本软件以 MIT 许可证开源,任何人均可自由使用、修改与分发。若你在其基础上制作派生作品:
|
|
6
|
+
|
|
7
|
+
1. 不得继续使用 YottaMeta 或本家族名称(yotta-*、元忆 等)作为派生作品的名称;
|
|
8
|
+
2. 不得暗示派生作品由 YottaMeta 官方维护、认可或与之存在关联;
|
|
9
|
+
3. 建议在派生作品中明确声明「与 YottaMeta 官方无关联」。
|
|
10
|
+
|
|
11
|
+
上游来源致谢:本技能由 YottaMeta 全新实现,无上游代码。
|
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
<p align="center"><b>Language</b>: English · <a href="./README.zh-CN.md">中文</a></p>
|
|
2
|
+
|
|
1
3
|
<p align="center">
|
|
2
4
|
<img src="assets/banner.png" alt="yotta-memory banner" width="100%" />
|
|
3
5
|
</p>
|
|
4
6
|
|
|
5
|
-
<h1 align="center"
|
|
7
|
+
<h1 align="center">元忆 (Yuanyi / yotta-memory)</h1>
|
|
6
8
|
|
|
7
|
-
<p align="center"
|
|
8
|
-
<p align="center"
|
|
9
|
-
<p align="center">FACT
|
|
10
|
-
<p align="center"
|
|
11
|
-
<p align="center"><b
|
|
9
|
+
<p align="center">Boundary-aware, file-based memory for AI agents: let any agent live across sessions instead of a single conversation.</p>
|
|
10
|
+
<p align="center">Start work with <code>recall</code> to restore context, <code>remember</code> important facts as you go, and archive at wrap-up; memories are Markdown files in the user's own directory — <b>readable, editable, auditable, rollback-able</b>, zero-dependency and ready to use.</p>
|
|
11
|
+
<p align="center">FACT is shared, PREF / BOUND / COMMIT are privately isolated — <b>who may read what is decided by mechanism, not by AI self-discipline</b>; one memory store can be shared across agents, travels with the disk, and can be shared over LAN.</p>
|
|
12
|
+
<p align="center">"Grows smarter the more you use it": <code>profile</code> aggregates a user profile (zero inference) + <code>context</code> builds a one-shot start-of-work package (identity + profile + recent memory + boundaries + commitments + wrap-up discipline), turning memory from "storage" into "a memory system that grows".</p>
|
|
13
|
+
<p align="center"><b>Mechanism-level encryption for the private zone</b>: AES-256-GCM envelope encryption + passphrase-derived master key + recovery key; <code>yotta-memory view</code> is a user-facing review platform (unlock with passphrase to see all AI memory); <code>migrate</code> converts plaintext → encrypted; <code>--no-encrypt</code> can downgrade. Cross-agent privacy upgrades from "discipline-level isolation" to "mechanism-level unreadable".</p>
|
|
12
14
|
|
|
13
15
|
<p align="center">
|
|
14
16
|
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
|
@@ -19,202 +21,166 @@
|
|
|
19
21
|
<a href="https://github.com/YottaMeta/yotta-memory"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen" /></a>
|
|
20
22
|
</p>
|
|
21
23
|
|
|
22
|
-
> 📖
|
|
23
|
-
|
|
24
|
-
> 🆕 **v0.8.1**:`view` 用户查看平台改为服务端分页(记忆多了一次只渲染当前页,页码上下页);`recall` 增加候选预过滤(语义检索前先粗筛候选集,命中集不变,记忆量大时不再逐条全量语义 / 模糊 / 编辑距离);公共 `index.json` 超过 5000 条时按年份分片(`index-<year>.json`),避免单文件膨胀。
|
|
25
|
-
|
|
26
|
-
## 核心价值
|
|
24
|
+
> 📖 The user-facing operations manual lives in [USER_GUIDE.md](USER_GUIDE.md).
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
> 🆕 **v0.8.3**: bilingual README alignment — README.md becomes the English facade (GitHub / npm / ClawHub homepage) and README.zh-CN.md carries the full Chinese doc; no functional changes.
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
- **隔离由机制保证**:FACT 进公共区共享,PREF / BOUND / COMMIT 进私密区、按 owner 物理分目录(`private/<owner>/<type>/`)。读取按 scope/owner 分区过滤,越界内容由 CLI 拦截、永不返回(默认静默跳过;显式跨读无授权报错拒绝);读写一律走 CLI / MCP,禁止 shell 直读写库文件——权限由机制把关,不依赖 AI 的「自觉」。
|
|
32
|
-
- **零依赖、即装即用**:无守护进程、无数据库、无向量库,只需 Node.js。安装即用,数据留在本机,任何机器都能部署。
|
|
33
|
-
- **越用越懂(v0.6.0)**:`profile` 聚合用户画像(引擎零推断,只归组原文)+ `context` 一键生成开工上下文包(身份 + 画像 + 近期记忆 + 边界 + 承诺);SKILL「记忆守则」注入规则层(类型红线 / 触发信号 / 了解用户 / 底线 / 宿主隔离),只注入规则与机制、不注入人格数据,出厂零数据。
|
|
34
|
-
- **自我学习 / 自我进化 / 自我提升(v0.8.0)**:`recall` 语义检索(同义词 / 拼音全拼+首字母 / 字段加权 / 模糊匹配,零依赖)+ 效用分融合排序;`feedback` 显式使用反馈闭环(useful / useless 调整 weight / confidence / feedback_net,越用越懂);`maintain` 规则层自组织(统一效用分 + 年龄自动归档 / 遗忘候选 / 去重,默认 dry-run,immutable / BOUND 豁免);`distill` 心理日志蒸馏(统计摘要 / 主题画像 / 知识地图,可选 `--model` 外部模型增强)。
|
|
35
|
-
- **私密区加密(v0.7.0)**:私密区文件 AES-256-GCM 信封加密(口令派生主密钥 + 恢复钥匙 + 每 owner 加密索引);`yotta-memory view` 用户查看平台(口令解锁看全部 AI 记忆);`migrate` 明文→密文迁移;`--no-encrypt` 可降级。跨 AI 私密从「纪律层隔离」升级为「机制层不可解」。
|
|
36
|
-
- **便携记忆盘**:记忆库本身就是记忆引擎——装在硬盘或主机上随盘走,局域网内其它主机上的智能体可远程读写;本地零进程与局域网常驻两种模式可并存,插上硬盘即恢复全部记忆。
|
|
28
|
+
## Core value
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
| 优势 | 说明 |
|
|
41
|
-
|---|---|
|
|
42
|
-
| **数据主权在用户** | 公共 FACT 明文、可读可改可审计;私密区 AES-256-GCM 加密(用户经 `yotta-memory view` 口令解密查看);git 可版本化,回滚 / 团队同步都走标准工具 |
|
|
43
|
-
| **真正的权限边界** | 公共 / 私密分区 + 按 owner 物理分目录(`private/<owner>/<type>/`)+ scope/owner 过滤 + 授权机制(grant / identity=user / `--unsafe`),越界内容由 CLI 过滤、永不返回(默认静默;显式跨读 `--all`/`--owner <其它>` 无授权时 exit 3);`--agent <其它>` 仅作身份声明、不授予跨读。读写走 CLI / MCP,禁 shell 直读写,不靠 AI 自律 |
|
|
44
|
-
| **私密区机制级加密** | 私密区(PREF/BOUND/COMMIT)文件 AES-256-GCM 信封加密(口令派生主密钥 + 恢复钥匙 + 每 owner 加密索引);没有对应 owner 密钥的 AI 即使读到密文也解不开;`yotta-memory view` 用户查看平台:口令解锁后浏览 / 搜索 / 导出全部 AI 记忆(含各 AI 私密明文) |
|
|
45
|
-
| **跨智能体标准** | 符合 Agent Skills 开放标准(agentskills.io);装一次,Claude Code / Codex / Cursor / OpenCode 等 78+ 智能体可共用同一份记忆 |
|
|
46
|
-
| **轻量零依赖** | 无 daemon / 无数据库 / 无向量库;Node.js 自带即跑,任何机器可部署 |
|
|
47
|
-
| **双级存储** | 用户级 `~/.yottamemory/`(跨项目)+ 项目级 `.yottamemory/`(随项目共享 / 交接)|
|
|
48
|
-
| **检索与生命周期** | 语义检索(v0.8.0:同义词 / 拼音 / 字段加权 / 模糊,零依赖)+ 效用分融合排序;统一效用分(盖棺分)规则层自动归档 / 遗忘候选 / 去重(`maintain`,默认 dry-run),记忆库越用越精简 |
|
|
49
|
-
| **越用越懂(v0.6.0)** | `profile` 画像聚合(零推断)+ `context` 开工上下文包(身份 / 画像 / 近期记忆 / 边界 / 承诺)+ SKILL「记忆守则」规则层,记忆随使用成长 |
|
|
50
|
-
| **生态分发** | GitHub + npm 双源同步发布;npx skills / npm / install.sh 三种方式,覆盖 17+ 类智能体目录 |
|
|
51
|
-
| **便携记忆盘(随盘走)** | 记忆库即引擎:装在硬盘 / 主机上,插上即恢复全部记忆;引擎主机只需装 CLI 当存放点,无需装任何 AI 智能体 |
|
|
52
|
-
| **局域网共享与自启** | 每智能体独立 token(Bearer + X-Agent-Id)鉴权、可吊销;`lan enable` 注册开机自启(Windows:优先计划任务,非管理员自动降级用户级 Startup 静默自启;Linux:systemd 用户单元,不可用时自动降级用户 crontab @reboot);MCP 工具集与 CLI 一致(8 个工具),管理动作不远程暴露 |
|
|
53
|
-
| **本地 / 局域网双模式** | 本地 `serve --stdio` 零进程、按需拉起(无常驻);局域网 streamable HTTP 常驻——两种模式可并存、按需选用 |
|
|
54
|
-
|
|
55
|
-
## 功能详解
|
|
56
|
-
|
|
57
|
-
### 记忆模型:四分类 + 双级存储
|
|
58
|
-
|
|
59
|
-
记忆按内容性质分为四类,类别决定可见范围:
|
|
60
|
-
|
|
61
|
-
| 类型 | 含义 | 可见范围 |
|
|
62
|
-
|---|---|---|
|
|
63
|
-
| `FACT` | 事实 / 知识 / 经验(可验证、可共享)| 公共区,所有智能体可读 |
|
|
64
|
-
| `PREF` | 偏好 / 习惯 / 喜好 | 私密区,默认仅所属 agent 可读 |
|
|
65
|
-
| `BOUND` | 边界 / 规则 / 底线 | 私密区,默认仅所属 agent 可读 |
|
|
66
|
-
| `COMMIT` | 承诺 / 锚定 / 约定 | 私密区,默认仅所属 agent 可读 |
|
|
30
|
+
Most memory solutions treat "remembering" as a black box: data goes into a database or the cloud, where users can see it but cannot change or audit it, let alone control "which agent sees what". Yuanyi takes a different path — restoring memory to visible, manageable files (public FACT is plaintext and auditable; the private zone is mechanically encrypted and user-unlockable with a passphrase):
|
|
67
31
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
32
|
+
- **Memory is files** — each memory is a Markdown file with YAML frontmatter in the user's own directory. Any editor can view / edit / delete; git handles versioning and rollback; team sync and handoff use the same standard toolchain.
|
|
33
|
+
- **Isolation is guaranteed by mechanism** — FACT goes to the public zone and is shared; PREF / BOUND / COMMIT go to the private zone, physically split per owner (`private/<owner>/<type>/`). Reads are partitioned by scope/owner; out-of-bound content is intercepted by the CLI and never returned (silently skipped by default; explicit unauthorized cross-read is denied with an error); all reads/writes go through CLI / MCP — direct shell access to library files is forbidden. Permissions are enforced by mechanism, not by AI "self-discipline".
|
|
34
|
+
- **Zero dependency, ready to use** — no daemon, no database, no vector store; just Node.js. Install and use; data stays on the machine; deployable anywhere.
|
|
35
|
+
- **Grows smarter (v0.6.0)** — `profile` aggregates a user profile (the engine infers nothing; it only groups verbatim text) + `context` generates a one-shot start-of-work package (identity + profile + recent memory + boundaries + commitments); the SKILL "memory discipline" injects rule layers (type red lines / trigger signals / know the user / bottom lines / host isolation) — rules and mechanisms only, no personality data; zero data out of the box.
|
|
36
|
+
- **Self-learning / self-evolving / self-improving (v0.8.0)** — `recall` semantic search (synonyms / pinyin full + initials / field weighting / fuzzy match, zero-dependency) with utility-score blended ranking; `feedback` explicit usage feedback loop (useful / useless adjusts weight / confidence / feedback_net); `maintain` rule-layer self-organization (unified utility score + age-based auto-archive / forget candidates / dedup, dry-run by default, immutable / BOUND exempt); `distill` psychological-log distillation (statistical summary / topic profile / knowledge map, optional `--model` external model enhancement).
|
|
37
|
+
- **Private-zone encryption (v0.7.0)** — private files AES-256-GCM envelope encrypted (passphrase-derived master key + recovery key + per-owner encrypted index); `yotta-memory view` user review platform (unlock with passphrase to see all AI memory).
|
|
71
38
|
|
|
72
|
-
###
|
|
39
|
+
### Memory types
|
|
73
40
|
|
|
74
|
-
|
|
75
|
-
- **物理隔离目录**:私密记忆按 owner 存放于 `private/<owner>/<type>/`,不同智能体的私密文件物理分离;旧版根下平铺的 `prefs/` `bounds/` `commits/` 在 `reindex` 时自动迁移。
|
|
76
|
-
- **三种授权入口(满足任一即可读他人私密)**:
|
|
77
|
-
1. `grants.json` 显式授权:`{"<userAgent>": ["<ownerAgent>", ...]}`;
|
|
78
|
-
2. identity=user:`--agent user` / `--owner user` / 环境变量 `YOTTA_AGENT_ID=user`;
|
|
79
|
-
3. 显式 `--unsafe`(用户显式授权)。
|
|
80
|
-
- **默认静默、显式跨读才报错**:默认 recall 遇其它 agent 私密静默跳过(不泄露「存在 N 条私密不可见」);仅当显式跨智能体读取(`--all` / `--owner <其它>`)且无授权命中时才报错 / 警告。
|
|
81
|
-
- **`--agent <其它>` 不越界**:`--agent <其它agent>` 仅作身份声明 / 展示用,不授予读取他人私密;读其它智能体私密仍需 grant / identity=user / `--unsafe`。
|
|
82
|
-
- **隔离定位**:scope: private 保证的是 AI 之间的语义隔离(正常 recall 不会被搜到、不会主动去读)。v0.7 起私密区为机制级机密保护——文件 AES-256-GCM 信封加密,没有对应 owner 密钥的 AI 即使读到密文文件也解不开;数据主权仍在用户,作为所有者可用 `yotta-memory view` 口令解锁查看 / 导出任何记忆文件。
|
|
83
|
-
- **禁止 shell 直读写**:记忆读写一律走 CLI / MCP 工具;用 shell(`Get-ChildItem` / `Get-Content` / `cat` / `ls` / `type` 等)直接读改库文件会绕过 scope/owner 权限边界,读到其它智能体私密内容。
|
|
41
|
+
Memory is classified into four types; the type decides visibility:
|
|
84
42
|
|
|
85
|
-
|
|
43
|
+
| Type | Meaning | Visibility |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `FACT` | facts / knowledge / experience (verifiable, shareable) | public zone, readable by all agents |
|
|
46
|
+
| `PREF` | preferences / habits / likes | private zone, readable only by the owning agent by default |
|
|
47
|
+
| `BOUND` | boundaries / rules / bottom lines | private zone, readable only by the owning agent by default |
|
|
48
|
+
| `COMMIT` | commitments / anchors / agreements | private zone, readable only by the owning agent by default |
|
|
86
49
|
|
|
87
|
-
|
|
50
|
+
- **Two-level storage**: user-level `~/.yottamemory/` shares personal memory across projects; project-level `.yottamemory/` travels with the project — natural for handoff and team collaboration. recall prefers project-level.
|
|
51
|
+
- **Same-key auto-update**: rewriting the same subject + statement only updates `updated`, no duplicates.
|
|
52
|
+
- **Rich metadata**: each memory carries `confidence`, `tags`, `immutable`, `created/updated`, `access_count` and more for retrieval and lifecycle management.
|
|
88
53
|
|
|
89
|
-
|
|
90
|
-
- **确认身份**:`yotta-memory whoami`(远端 MCP 工具 `agent_info`)读「当次声明身份」(本机 `YOTTA_AGENT_ID` / CLI `--agent`;远端 `X-Agent-Id`),不猜不默认。
|
|
91
|
-
- **自我档案(强制落盘)**:`iam` 自动写一条 PREF `subject=自我接入档案`(owner=自己),statement 为 `; ` 分隔的 key:value:`agent_id / host / memory_home / mcp_mode(stdio|http)/ engine_url(仅远端)/ token(仅远端;本机不存 token)`。开工先 `recall "自我接入档案"` 找回身份与接入信息。
|
|
92
|
-
- **本机免 token**:本机 CLI / stdio 直连不经网络、不校验 token;身份经该智能体 MCP 配置的 `env.YOTTA_AGENT_ID` 声明。本机多个智能体各自声明唯一 ID,互不撞。
|
|
93
|
-
- **私密记忆必须有 owner**:写 PREF / BOUND / COMMIT 时未声明身份会被拒绝(公共 FACT 不受影响),从机制上防止「抄别人的 ID」。
|
|
54
|
+
### Permissions & isolation
|
|
94
55
|
|
|
95
|
-
|
|
56
|
+
- **Three read states**: public FACT always readable; own private always readable; other agents' private is denied by default (content not returned).
|
|
57
|
+
- **Physically isolated directories**: private memory lives at `private/<owner>/<type>/`; different agents' private files are physically separated; legacy flat `prefs/` `bounds/` `commits/` auto-migrate on `reindex`.
|
|
58
|
+
- **Three authorization gates** (any one grants reading another's private): 1. explicit grant in `grants.json`; 2. identity=user (`--agent user` / `--owner user` / `YOTTA_AGENT_ID=user`); 3. explicit `--unsafe` (user explicitly authorized).
|
|
59
|
+
- **Silent by default, explicit cross-read errors**: default recall silently skips other agents' private (no "there are N invisible private entries" leak); only explicit cross-agent reads (`--all` / `--owner <other>`) without authorization error / warn.
|
|
60
|
+
- **`--agent <other>` does not cross**: it only declares identity for display; reading other agents' private still needs grant / identity=user / `--unsafe`.
|
|
61
|
+
- **Isolation positioning**: scope: private guarantees semantic isolation between AIs; since v0.7 the private zone is mechanism-level confidentiality — files are AES-256-GCM envelope encrypted, so an AI without the owner key cannot decrypt them even if it reads the ciphertext; data sovereignty remains with the user, who can use `yotta-memory view` to unlock and view / export any memory file.
|
|
62
|
+
- **No direct shell reads/writes**: all memory reads/writes go through CLI / MCP tools; directly reading or editing library files with shell commands bypasses scope/owner boundaries.
|
|
96
63
|
|
|
97
|
-
|
|
98
|
-
- **context**:一键生成开工上下文包——多智能体接入铁律 + 身份 + 用户画像摘要 + 近期记忆(按 importance 排序)+ 边界提醒 + 承诺 / 锚点;支持 `--budget` 字符预算(token 恒定,不随记忆膨胀)。
|
|
99
|
-
- **记忆守则**:SKILL.md 内置规则层(类型红线 / 主动捕获触发信号 / 了解用户三阶段四手法 / 心理学底座与对齐 / 底线与边界 / 宿主隔离 / 反模式),让 AI「越用越懂」有章法。
|
|
64
|
+
### Agent identity (unique ID + self profile)
|
|
100
65
|
|
|
101
|
-
|
|
66
|
+
Each agent has a globally unique agent ID: it is the ownership key for private memory (PREF / BOUND / COMMIT) and the identity declaration for remote access (`X-Agent-Id`).
|
|
102
67
|
|
|
103
|
-
- `
|
|
104
|
-
- `
|
|
105
|
-
- **
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
- 支持关键词、`--type` 过滤、`--limit` 截断、项目级优先。
|
|
109
|
-
- **根位置去重(v0.6.5)**:当项目级与用户级记忆库指向同一目录(如 cwd = home 或其父)时,`recall` / `context` 自动唯一化根,同一文件只展示一次。
|
|
110
|
-
- 命中展示会累加 `access_count` / `last_accessed`,为生命周期管理提供依据。
|
|
68
|
+
- **Register (must be unique)**: `yotta-memory iam <id>` writes `agents.json` at the memory root, **enforcing uniqueness** — denied if the ID is already used by another host / source (including remote token registration); `--force` only when you confirm it is the same agent.
|
|
69
|
+
- **Confirm identity**: `yotta-memory whoami` (remote MCP tool `agent_info`) reads the "declared identity of this session" — it never guesses or assumes.
|
|
70
|
+
- **Self profile (forced to disk)**: `iam` auto-writes a PREF `subject=自我接入档案` (owner=self) with `; `-separated key:value: `agent_id / host / memory_home / mcp_mode / engine_url / token` (token not stored locally). Start work with `recall "自我接入档案"` to recover identity and connection info.
|
|
71
|
+
- **No token locally**: local CLI / stdio direct connection bypasses the network and does not validate tokens; identity is declared via the agent's MCP `env.YOTTA_AGENT_ID`.
|
|
72
|
+
- **Private memory requires an owner**: writing PREF / BOUND / COMMIT without declaring identity is rejected (public FACT is unaffected), mechanically preventing ID spoofing.
|
|
111
73
|
|
|
112
|
-
###
|
|
74
|
+
### Profile & start-of-work context (v0.6.0)
|
|
113
75
|
|
|
114
|
-
- `
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
- `distill`(v0.8.0):心理日志蒸馏——统计摘要(类型 / 年龄 / 热度 / 反馈)+ 主题画像(按 subject 聚类合并)+ 知识地图(type → tags);可选 `--model <cmd>` 外部模型 stdin→stdout 提炼;产物入 `private/<owner>/distills/` 或 `facts/distills/`。
|
|
118
|
-
- `explain`(v0.8.0):查看单条记忆效用分项与归档 / 遗忘状态判定。
|
|
119
|
-
- `forget`:删除单条记忆(按类型目录路径或文件名)。
|
|
120
|
-
- `reindex`:手动改过 `.md` 后重建索引。
|
|
121
|
-
- `export` / `import`:整库导出为 JSON / 从 JSON 导入,可作迁移与备份中间格式。
|
|
122
|
-
- git:整个记忆库可纳入版本控制,回滚 / 审计 / 团队同步。
|
|
76
|
+
- **profile**: aggregates `private/<owner>/` PREF / BOUND / COMMIT verbatim, grouped by type + subject + tags, written to `profile.md`; the engine infers nothing — profile conclusions are formed internally by the AI per the "memory discipline", never pasted as labels.
|
|
77
|
+
- **context**: one-shot start-of-work package — multi-agent integration rules + identity + user profile digest + recent memory (importance-sorted) + boundary reminders + commitments/anchors; supports `--budget` character budget (constant tokens, does not grow with memory).
|
|
78
|
+
- **Memory discipline**: SKILL.md embeds a rule layer (type red lines / proactive trigger capture / know-the-user three stages / psychological grounding & alignment / bottom lines / host isolation / anti-patterns).
|
|
123
79
|
|
|
124
|
-
###
|
|
80
|
+
### Retrieval: semantic search (v0.8.0) + Chinese tokenization scoring
|
|
125
81
|
|
|
126
|
-
|
|
82
|
+
- `remember` auto-builds the `index.json` index (version 4 since v0.8.1 with field weighting and pinyin tokens; public indexes over 5000 entries shard by year `index-<year>.json`; old indexes rebuild on first recall); recall defaults to semantic search — exact (field weighting: subject×3 / tags×2 / statement×1) + synonyms (built-in wordlist, extensible) + pinyin (full / initials, built-in 3755 common characters) + fuzzy (edit distance ≤ 2) + substring fallback, blended with utility score (0.65 × semantic + 0.35 × utility), zero-dependency.
|
|
83
|
+
- `recall --explain`: shows each hit's reason (exact / synonym / pinyin / fuzzy + field) and utility components.
|
|
84
|
+
- **Candidate pre-filtering (v0.8.1)**: before semantic scoring, index tokens coarsely filter the candidate set (exact / synonym / pinyin / substring / fuzzy length gate) — hit set identical to v0.8.0; the `view` platform paginates by offset, fetching only the current page.
|
|
85
|
+
- Optional embedding plugin: protocol reserved (implemented in v0.9); without a plugin it degrades to zero-dependency automatically.
|
|
86
|
+
- The `tokens` field of `index.json` is a Chinese-tokenization term-frequency table (for TF scoring), **not** an access credential; auth tokens live at `.server/tokens.json`.
|
|
87
|
+
- Supports keywords, `--type` filter, `--limit` truncation, project-level priority.
|
|
88
|
+
- **Root de-duplication (v0.6.5)**: when project and user roots point at the same directory, recall / context uniquify roots so a file shows once.
|
|
89
|
+
- Hits accumulate `access_count` / `last_accessed` for lifecycle management.
|
|
127
90
|
|
|
128
|
-
###
|
|
91
|
+
### Lifecycle management (v0.8.0 rule-layer self-organization)
|
|
129
92
|
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
93
|
+
- `maintain`: unified utility score (final score = confidence + usage + recency + type + structure) × weight; low-utility + over-age auto-archive; extreme low value listed as forget candidates (not really deleted by default; `--purge` deletes); `--dedup` dedup candidates; `--merge A,B` manual merge. Dry-run preview by default, `--apply` to execute; immutable / BOUND exempt; audit writes `.archive/audit-<date>.jsonl`.
|
|
94
|
+
- `archive`: moves low-value old memory into `.archive/` by "unified utility score + age" (immutable excluded) so the store never grows without bound.
|
|
95
|
+
- `feedback`: explicit usage feedback loop — useful → weight ×1.2 (cap 3.0) + confidence +0.05 + feedback_net +1; useless → weight ×0.8 (floor 0.2) + confidence −0.05 + feedback_net −1; `--undo` rolls back; audit writes `.archive/feedback-<date>.jsonl`.
|
|
96
|
+
- `distill`: psychological-log distillation — statistical summary (type / age / heat / feedback) + topic profile (clustered by subject) + knowledge map (type → tags); optional `--model <cmd>` external model stdin→stdout refinement; output to `private/<owner>/distills/` or `facts/distills/`.
|
|
97
|
+
- `explain`: view a single memory's utility components and archive / forget status decision.
|
|
98
|
+
- `forget`: delete a single memory (by type-dir path or file name).
|
|
99
|
+
- `reindex`: rebuild the index after manually editing `.md` files.
|
|
100
|
+
- `export` / `import`: export the whole store to JSON / import from JSON; an intermediate format for migration and backup.
|
|
101
|
+
- git: the whole store can be version-controlled — rollback / audit / team sync.
|
|
135
102
|
|
|
136
|
-
##
|
|
103
|
+
## Comparison with other approaches
|
|
137
104
|
|
|
138
|
-
>
|
|
105
|
+
> Compared by solution type, not product names. Criteria: data sovereignty, deployment cost, permission boundaries, auditability, cross-agent ability.
|
|
139
106
|
|
|
140
|
-
|
|
|
107
|
+
| Dimension | Yuanyi (yotta-memory) | Database / embedded storage | Vector store / semantic retrieval | Cloud-hosted memory service |
|
|
141
108
|
|---|---|---|---|---|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
109
|
+
| Storage form | Public FACT plaintext files; private zone encrypted (.md.enc); git-versionable | binary / structured database files | vector index + model dependency | vendor servers |
|
|
110
|
+
| Data sovereignty | fully local, readable/editable/deletable (private zone via view platform) | local, but needs dedicated tools | local or self-hosted; model extra | not in user's hands; TOS-bound |
|
|
111
|
+
| Permission boundaries | built-in: public/private zones + scope/owner + grants | usually none, DIY | usually none, DIY | account-level only, no memory-level granularity |
|
|
112
|
+
| Audit / rollback | public FACT plaintext auditable; private encrypted but user-decryptable via view; git rollback | needs export toolchain; complex rollback | snapshot/export dependent | platform export dependent |
|
|
113
|
+
| Deployment & deps | zero-dependency, runs on Node.js | needs database runtime / embedded dep | vector store + model, heavier | online + account, data leaves local |
|
|
114
|
+
| Cross-agent | Agent Skills standard; write once, multiple agents read | per-agent integration, no standard | per-agent integration, costly | platform coverage dependent |
|
|
148
115
|
|
|
149
|
-
|
|
116
|
+
**Conclusion**: Yuanyi's core differentiator is combining "data sovereignty + permission boundaries + zero dependency" — auditable files, mechanism-level read isolation, and no heavy dependencies. For "local-first, multi-agent collaboration, long-term accumulation", it is the lightest path.
|
|
150
117
|
|
|
151
|
-
##
|
|
118
|
+
## Install
|
|
152
119
|
|
|
153
|
-
|
|
120
|
+
Yuanyi ships as **CLI + skill** — the `yotta-memory` command reads/writes memory, and the skill teaches agents the workflow. Pick any method; skill files come from **npm**.
|
|
154
121
|
|
|
155
|
-
###
|
|
122
|
+
### Method 1: npx skills (recommended, ecosystem-standard entry)
|
|
156
123
|
```bash
|
|
157
124
|
npx skills add YottaMeta/yotta-memory
|
|
158
125
|
```
|
|
159
|
-
>
|
|
126
|
+
> Auto-installs the skill files into detected agents (Claude Code / Codex / Cursor / OpenCode and 78+ more). This installs only the skill instructions (SKILL.md etc.); to use the `yotta-memory` read/write commands you also need the CLI: `npm install -g @yottameta/yotta-memory` (see method 2).
|
|
160
127
|
|
|
161
|
-
###
|
|
128
|
+
### Method 2: npm direct install (CLI + skill)
|
|
162
129
|
```bash
|
|
163
|
-
#
|
|
130
|
+
# domestic mirror (optional): npm config set registry https://registry.npmmirror.com
|
|
164
131
|
npm install -g @yottameta/yotta-memory
|
|
165
|
-
yotta-memory init #
|
|
166
|
-
yotta-memory-install -g #
|
|
167
|
-
yotta-memory-install --agent codex #
|
|
132
|
+
yotta-memory init # initialize the memory store
|
|
133
|
+
yotta-memory-install -g # install the skill into all recognized agents (user level)
|
|
134
|
+
yotta-memory-install --agent codex # install into one specific agent
|
|
168
135
|
```
|
|
169
136
|
|
|
170
|
-
>
|
|
137
|
+
> After global install both `yotta-memory` (read/write) and `yotta-memory-install` (installer) are on PATH. Prefer not to install globally? Run the installer one-shot: `npx -y --package @yottameta/yotta-memory yotta-memory-install -g`.
|
|
171
138
|
|
|
172
|
-
###
|
|
173
|
-
|
|
139
|
+
### Method 3: install.sh / manual copy
|
|
140
|
+
After obtaining the skill folder (`npm pack` unpack or `git clone`), enter the folder:
|
|
174
141
|
```bash
|
|
175
|
-
bash install.sh -g #
|
|
176
|
-
bash install.sh --agent codex #
|
|
142
|
+
bash install.sh -g # user level; bash install.sh --list shows all directories
|
|
143
|
+
bash install.sh --agent codex # specific agent
|
|
177
144
|
bash install.sh --dir /path/to/skills
|
|
178
145
|
```
|
|
179
|
-
|
|
146
|
+
You can also copy the whole `yotta-memory` folder into the target agent's skills directory (common locations via install.sh --list).
|
|
180
147
|
|
|
181
|
-
##
|
|
148
|
+
## Upgrade
|
|
182
149
|
|
|
183
|
-
|
|
150
|
+
Two upgrade paths match the two install paths:
|
|
184
151
|
|
|
185
|
-
|
|
152
|
+
**Upgrade the CLI** (rerun the install command; no version tag defaults to latest):
|
|
186
153
|
```bash
|
|
187
154
|
npm i -g @yottameta/yotta-memory
|
|
188
155
|
```
|
|
189
156
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
> 升级只影响命令与技能文件,**不会动你已存的记忆**(记忆是独立于安装的文件,保留在原目录)。
|
|
157
|
+
**Upgrade the skill**: rerun the install command you used originally (`npx skills add YottaMeta/yotta-memory` or `yotta-memory-install -g`) to overwrite the old skill folder.
|
|
193
158
|
|
|
194
|
-
|
|
159
|
+
> Upgrades only affect commands and skill files — **they never touch your stored memories** (memory is independent of the install, kept in its own directory).
|
|
195
160
|
|
|
161
|
+
## CLI usage
|
|
196
162
|
|
|
197
|
-
|
|
|
163
|
+
| Command | What it does |
|
|
198
164
|
|---|---|
|
|
199
|
-
| `yotta-memory init [--project] [--dir
|
|
200
|
-
| `yotta-memory remember <type> <subject> <statement> [--owner <id>] [--source
|
|
201
|
-
| `yotta-memory recall [
|
|
202
|
-
| `yotta-memory profile [--owner <id>]` |
|
|
203
|
-
| `yotta-memory context [--limit N] [--owner <id>] [--budget N]` |
|
|
204
|
-
| `yotta-memory forget
|
|
205
|
-
| `yotta-memory archive [--days 180] [--threshold 0.4]` |
|
|
206
|
-
| `yotta-memory reindex` |
|
|
207
|
-
| `yotta-memory export [--out f.json]` / `import <f.json>` |
|
|
208
|
-
| `yotta-memory config set memory_home
|
|
209
|
-
| `yotta-memory whoami` |
|
|
210
|
-
| `yotta-memory iam <id> [--name
|
|
211
|
-
| `yotta-memory token new --agent <id> [--force]` / `token list` / `token revoke --agent <id>` |
|
|
212
|
-
| `yotta-memory serve [--host 0.0.0.0] [--port 8787] [--no-auth] [--stdio]` |
|
|
213
|
-
| `yotta-memory lan enable [--onstart] / disable / status` |
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
165
|
+
| `yotta-memory init [--project] [--dir <dir>]` | Initialize the store (default user-level `~/.yottamemory/`; --dir sets an explicit location) |
|
|
166
|
+
| `yotta-memory remember <type> <subject> <statement> [--owner <id>] [--source <src>] [--weight <0..>] [--verify] [--no-hint]` | Write a memory (same subject+statement auto-updates; --owner marks ownership; --source records origin; --weight importance, dedup takes max; --verify read-back; --no-hint disables type hints) |
|
|
167
|
+
| `yotta-memory recall [keywords] [--type T] [--limit N] [--agent <id>] [--owner <id>] [--all] [--unsafe]` | Search memory (index + TF scoring, partitioned reads; cross-reading other agents' private is denied by default, needs grant / identity=user / `--unsafe`; project-level priority) |
|
|
168
|
+
| `yotta-memory profile [--owner <id>]` | Generate a user profile (aggregates `private/<owner>` verbatim, zero inference, writes `profile.md`; cross-owner denied by default) |
|
|
169
|
+
| `yotta-memory context [--limit N] [--owner <id>] [--budget N]` | Generate the start-of-work package (identity + multi-agent rules + profile + recent memory + boundaries + commitments; --budget budgets recent-memory chars, constant tokens) |
|
|
170
|
+
| `yotta-memory forget <file>` | Delete a memory (by type-dir path or file name) |
|
|
171
|
+
| `yotta-memory archive [--days 180] [--threshold 0.4]` | Archive old memory (final score + age; immutable excluded) |
|
|
172
|
+
| `yotta-memory reindex` | Rebuild the index (after manually editing .md) |
|
|
173
|
+
| `yotta-memory export [--out f.json]` / `import <f.json>` | Export / import |
|
|
174
|
+
| `yotta-memory config set memory_home <dir>` / `config get` | Persist / view the store location (`~/.yottamemory/config.json`) |
|
|
175
|
+
| `yotta-memory whoami` | Show the current agent identity and registration status |
|
|
176
|
+
| `yotta-memory iam <id> [--name <name>] [--user <user>] [--relationship <rel>] [--force]` | Register this agent's unique identity and auto-write the self profile (`agents.json`, ID must be unique) |
|
|
177
|
+
| `yotta-memory token new --agent <id> [--force]` / `token list` / `token revoke --agent <id>` | Create / list / revoke access tokens for agents (registered at `.server/tokens.json`) |
|
|
178
|
+
| `yotta-memory serve [--host 0.0.0.0] [--port 8787] [--no-auth] [--stdio]` | Start the MCP memory engine (streamable HTTP LAN / --stdio local zero-process mode; Bearer token + X-Agent-Id auth) |
|
|
179
|
+
| `yotta-memory lan enable [--onstart] / disable / status` | Autostart management (Windows: scheduled task, default ONLOGON, --onstart needs admin, non-admin auto-degrades to user-level Startup; Linux: systemd user unit, falls back to user crontab @reboot) |
|
|
180
|
+
|
|
181
|
+
Types: `FACT` (fact, public shared) / `PREF` (preference) / `BOUND` (boundary) / `COMMIT` (commitment).
|
|
182
|
+
|
|
183
|
+
Example:
|
|
218
184
|
```bash
|
|
219
185
|
yotta-memory init
|
|
220
186
|
yotta-memory remember PREF 用户 偏好短回复,不要用表情
|
|
@@ -224,77 +190,84 @@ yotta-memory context --limit 10
|
|
|
224
190
|
yotta-memory recall --type FACT --limit 10
|
|
225
191
|
```
|
|
226
192
|
|
|
227
|
-
|
|
228
|
-
- `YOTTA_MEMORY_HOME
|
|
229
|
-
- `YOTTA_AGENT_ID` / `AGENT_ID
|
|
193
|
+
Environment variables:
|
|
194
|
+
- `YOTTA_MEMORY_HOME`: overrides the user-level store directory (default `~/.yottamemory/`).
|
|
195
|
+
- `YOTTA_AGENT_ID` / `AGENT_ID`: current agent ID (local identity declaration; participates in read-partition decisions; private memory requires an owner, undeclared is rejected).
|
|
230
196
|
|
|
231
|
-
##
|
|
197
|
+
## After the agent is wired up
|
|
232
198
|
|
|
233
|
-
|
|
199
|
+
Once the skill is installed into an agent, SKILL.md teaches it the workflow automatically: start work with `recall` to restore context → `remember` important info as you go → archive at wrap-up. You can also just say "记住 XXX" / "上次说到哪了" in conversation.
|
|
234
200
|
|
|
235
|
-
##
|
|
201
|
+
## LAN multi-machine sharing (portable memory disk mode)
|
|
236
202
|
|
|
237
|
-
|
|
203
|
+
The store can live on any host or disk (= the memory engine) and be reached by agents on other LAN hosts:
|
|
238
204
|
|
|
239
|
-
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
205
|
+
- **Local direct**: CLI reads/writes directly, no token;
|
|
206
|
+
- **Remote**: the engine host runs `yotta-memory serve` (or registers `lan enable` autostart); remote agents connect via MCP with `url + token`.
|
|
207
|
+
- **Local zero-process**: local MCP clients can use `serve --stdio` to launch the CLI on demand (no resident process).
|
|
242
208
|
|
|
243
|
-
###
|
|
209
|
+
### Engine side (the host where memory lives)
|
|
244
210
|
|
|
245
|
-
1.
|
|
246
|
-
2.
|
|
211
|
+
1. Initialize or attach to the store (see CLI usage).
|
|
212
|
+
2. Generate an independent token for each agent that needs access:
|
|
247
213
|
```bash
|
|
248
|
-
yotta-memory token new --agent
|
|
249
|
-
yotta-memory token list #
|
|
250
|
-
yotta-memory token revoke --agent
|
|
214
|
+
yotta-memory token new --agent <agent-id> # printed once, e.g. ytm_... (--force if the ID is taken by another source)
|
|
215
|
+
yotta-memory token list # list registered agents
|
|
216
|
+
yotta-memory token revoke --agent <agent-id> # revoke
|
|
251
217
|
```
|
|
252
|
-
>
|
|
253
|
-
3.
|
|
218
|
+
> New tokens take effect immediately; no service restart needed.
|
|
219
|
+
3. Start the service (default listens on 0.0.0.0:8787, Bearer token + X-Agent-Id auth) — temporary run or register autostart:
|
|
254
220
|
```bash
|
|
255
|
-
yotta-memory serve #
|
|
256
|
-
yotta-memory lan enable #
|
|
257
|
-
yotta-memory lan status #
|
|
221
|
+
yotta-memory serve # temporary foreground
|
|
222
|
+
yotta-memory lan enable # register autostart (Windows: scheduled task / user-level Startup; Linux: systemd user unit / user crontab)
|
|
223
|
+
yotta-memory lan status # autostart status
|
|
258
224
|
```
|
|
259
|
-
> `lan enable --onstart`
|
|
225
|
+
> `lan enable --onstart` switches to start-at-boot (needs admin); non-admin `lan enable` auto-degrades to user-level silent Startup; `lan disable` removes it.
|
|
260
226
|
|
|
261
|
-
>
|
|
227
|
+
> On first listen on 0.0.0.0, Windows / the system firewall may ask to allow it — allow it, or other LAN hosts cannot reach it; `--no-auth` disables auth for trusted intranets only.
|
|
262
228
|
|
|
263
|
-
###
|
|
229
|
+
### Client side (remote agent)
|
|
264
230
|
|
|
265
|
-
|
|
231
|
+
Register the connection in the agent's MCP config (`url` + two headers):
|
|
266
232
|
|
|
267
233
|
```json
|
|
268
234
|
{
|
|
269
235
|
"mcpServers": {
|
|
270
236
|
"yotta-memory": {
|
|
271
|
-
"url": "http
|
|
237
|
+
"url": "http://<engine-host-ip>:8787/mcp",
|
|
272
238
|
"headers": {
|
|
273
239
|
"Authorization": "Bearer <TOKEN>",
|
|
274
|
-
"X-Agent-Id": "
|
|
240
|
+
"X-Agent-Id": "<this-agent-id>"
|
|
275
241
|
}
|
|
276
242
|
}
|
|
277
243
|
}
|
|
278
244
|
}
|
|
279
245
|
```
|
|
280
246
|
|
|
281
|
-
|
|
247
|
+
Once connected, MCP tools (remember / recall / search / forget / archive / reindex / export / import / agent_info) read/write memory and confirm identity; management actions (init / config / token / lan / serve) are not exposed via MCP, and token management is never exposed remotely. `X-Agent-Id` must match the token's registered agent; read-partition rules are the same as the CLI (FACT public-readable, PREF / BOUND / COMMIT private).
|
|
282
248
|
|
|
283
|
-
###
|
|
249
|
+
### Location persistence
|
|
284
250
|
|
|
285
|
-
CLI
|
|
251
|
+
The CLI persists the store location (`~/.yottamemory/config.json`), so agents on the same host use the right location on later `recall` without re-specifying:
|
|
286
252
|
|
|
287
253
|
```bash
|
|
288
|
-
yotta-memory config set memory_home
|
|
254
|
+
yotta-memory config set memory_home <store-dir>
|
|
289
255
|
yotta-memory config get
|
|
290
256
|
```
|
|
291
257
|
|
|
292
|
-
|
|
258
|
+
Resolution priority: `YOTTA_MEMORY_HOME` (temporary override) > `config.json#memory_home` (persistent) > default `~/.yottamemory`. Put the store on a disk, plug it into any host, run `config set memory_home` once (or `yotta-memory init --dir <dir>` to initialize directly to a location) and all memory is restored on that host.
|
|
259
|
+
|
|
260
|
+
## Development & validation
|
|
261
|
+
|
|
262
|
+
- Run at the project root: python tools/validate-skill.py yotta-memory
|
|
263
|
+
- Engine self-test: node --check bin/yotta-memory.js; node bin/yotta-memory.js --version
|
|
264
|
+
|
|
265
|
+
Keep tests green and bump the version before releasing changes.
|
|
293
266
|
|
|
294
|
-
##
|
|
267
|
+
## Changelog
|
|
295
268
|
|
|
296
|
-
|
|
269
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
|
297
270
|
|
|
298
|
-
##
|
|
271
|
+
## License
|
|
299
272
|
|
|
300
|
-
MIT © YottaMeta
|
|
273
|
+
[MIT](./LICENSE) © YottaMeta. "Yuanyi" / "yotta-memory" and the YottaMeta family names (yotta-* prefix) are YottaMeta brand identifiers; derived works must not reuse them, see [NOTICE](./NOTICE).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
<p align="center"><b>Language</b>: <a href="./README.md">English</a> · 中文</p>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/banner.png" alt="yotta-memory banner" width="100%" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">元忆(yotta-memory)</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">元忆 —— 有权限边界的文件式智能体记忆:让任何 AI 智能体活过会话,而不是只活在单次对话里。</p>
|
|
10
|
+
<p align="center">开工 <code>recall</code> 恢复上下文、重要信息 <code>remember</code> 落盘、收工归档;记忆是落在用户自己目录里的 Markdown 文件——<b>可读、可改、可审计、可回滚</b>,零依赖、即装即用。</p>
|
|
11
|
+
<p align="center">FACT 共享、PREF / BOUND / COMMIT 私密隔离——<b>谁该读、谁不该读,由机制而非 AI 自觉决定</b>;一份记忆可跨智能体共用,记忆库随盘走、局域网可共享。</p>
|
|
12
|
+
<p align="center">「越用越懂」:<code>profile</code> 聚合用户画像(零推断)+ <code>context</code> 一键开工上下文包(身份 + 画像 + 近期记忆 + 边界 + 承诺 + 收工纪律),记忆从「存储」成长为「会成长的记忆系统」。</p>
|
|
13
|
+
<p align="center"><b>私密区机制级加密</b>:AES-256-GCM 信封加密 + 口令派生主密钥 + 恢复钥匙;<code>yotta-memory view</code> 用户查看平台(口令解锁看全部 AI 记忆);<code>migrate</code> 明文→密文迁移;<code>--no-encrypt</code> 可降级。跨 AI 私密从「纪律层隔离」升级为「机制层不可解」。</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
|
17
|
+
<a href="https://agentskills.io/"><img alt="Standard: agentskills.io" src="https://img.shields.io/badge/standard-agentskills.io-orange" /></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@yottameta/yotta-memory"><img alt="npm package" src="https://img.shields.io/npm/v/@yottameta/yotta-memory" /></a>
|
|
19
|
+
<a href="https://github.com/YottaMeta/yotta-memory"><img alt="GitHub stars" src="https://img.shields.io/github/stars/YottaMeta/yotta-memory" /></a>
|
|
20
|
+
<a href="https://github.com/YottaMeta/yotta-memory/commits/main"><img alt="last commit" src="https://img.shields.io/github/last-commit/YottaMeta/yotta-memory" /></a>
|
|
21
|
+
<a href="https://github.com/YottaMeta/yotta-memory"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen" /></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
> 📖 面向用户的操作手册见 [USER_GUIDE.md](USER_GUIDE.md)。
|
|
25
|
+
|
|
26
|
+
> 🆕 **v0.8.2**:发布元数据修复——三次源重发带 `--name 元忆 yotta-memory`,修复 ClawHub 展示名缺失中文(原为裸 `yotta-memory`);无功能变更。
|
|
27
|
+
|
|
28
|
+
> 🆕 **v0.8.1**:`view` 用户查看平台改为服务端分页(记忆多了一次只渲染当前页,页码上下页);`recall` 增加候选预过滤(语义检索前先粗筛候选集,命中集不变,记忆量大时不再逐条全量语义 / 模糊 / 编辑距离);公共 `index.json` 超过 5000 条时按年份分片(`index-<year>.json`),避免单文件膨胀。
|
|
29
|
+
|
|
30
|
+
## 核心价值
|
|
31
|
+
|
|
32
|
+
多数记忆方案把「记住」做成了黑盒:数据进了数据库或云端,用户看得到内容却改不动、难以审计,更控制不了「哪个智能体能看到什么」。元忆换了一条路——把记忆还原成看得见、管得着的文件(公共 FACT 明文可审计,私密区机制级加密、用户可口令解锁):
|
|
33
|
+
|
|
34
|
+
- **记忆就是文件**:每条记忆是一个带 YAML frontmatter 的 Markdown 文件,放在用户自己的目录里。任何编辑器都能看、能改、能删;git 直接做版本管理与回滚,团队同步与交接走同一条标准工具链。
|
|
35
|
+
- **隔离由机制保证**:FACT 进公共区共享,PREF / BOUND / COMMIT 进私密区、按 owner 物理分目录(`private/<owner>/<type>/`)。读取按 scope/owner 分区过滤,越界内容由 CLI 拦截、永不返回(默认静默跳过;显式跨读无授权报错拒绝);读写一律走 CLI / MCP,禁止 shell 直读写库文件——权限由机制把关,不依赖 AI 的「自觉」。
|
|
36
|
+
- **零依赖、即装即用**:无守护进程、无数据库、无向量库,只需 Node.js。安装即用,数据留在本机,任何机器都能部署。
|
|
37
|
+
- **越用越懂(v0.6.0)**:`profile` 聚合用户画像(引擎零推断,只归组原文)+ `context` 一键生成开工上下文包(身份 + 画像 + 近期记忆 + 边界 + 承诺);SKILL「记忆守则」注入规则层(类型红线 / 触发信号 / 了解用户 / 底线 / 宿主隔离),只注入规则与机制、不注入人格数据,出厂零数据。
|
|
38
|
+
- **自我学习 / 自我进化 / 自我提升(v0.8.0)**:`recall` 语义检索(同义词 / 拼音全拼+首字母 / 字段加权 / 模糊匹配,零依赖)+ 效用分融合排序;`feedback` 显式使用反馈闭环(useful / useless 调整 weight / confidence / feedback_net,越用越懂);`maintain` 规则层自组织(统一效用分 + 年龄自动归档 / 遗忘候选 / 去重,默认 dry-run,immutable / BOUND 豁免);`distill` 心理日志蒸馏(统计摘要 / 主题画像 / 知识地图,可选 `--model` 外部模型增强)。
|
|
39
|
+
- **私密区加密(v0.7.0)**:私密区文件 AES-256-GCM 信封加密(口令派生主密钥 + 恢复钥匙 + 每 owner 加密索引);`yotta-memory view` 用户查看平台(口令解锁看全部 AI 记忆);`migrate` 明文→密文迁移;`--no-encrypt` 可降级。跨 AI 私密从「纪律层隔离」升级为「机制层不可解」。
|
|
40
|
+
- **便携记忆盘**:记忆库本身就是记忆引擎——装在硬盘或主机上随盘走,局域网内其它主机上的智能体可远程读写;本地零进程与局域网常驻两种模式可并存,插上硬盘即恢复全部记忆。
|
|
41
|
+
|
|
42
|
+
## 核心优势
|
|
43
|
+
|
|
44
|
+
| 优势 | 说明 |
|
|
45
|
+
|---|---|
|
|
46
|
+
| **数据主权在用户** | 公共 FACT 明文、可读可改可审计;私密区 AES-256-GCM 加密(用户经 `yotta-memory view` 口令解密查看);git 可版本化,回滚 / 团队同步都走标准工具 |
|
|
47
|
+
| **真正的权限边界** | 公共 / 私密分区 + 按 owner 物理分目录(`private/<owner>/<type>/`)+ scope/owner 过滤 + 授权机制(grant / identity=user / `--unsafe`),越界内容由 CLI 过滤、永不返回(默认静默;显式跨读 `--all`/`--owner <其它>` 无授权时 exit 3);`--agent <其它>` 仅作身份声明、不授予跨读。读写走 CLI / MCP,禁 shell 直读写,不靠 AI 自律 |
|
|
48
|
+
| **私密区机制级加密** | 私密区(PREF/BOUND/COMMIT)文件 AES-256-GCM 信封加密(口令派生主密钥 + 恢复钥匙 + 每 owner 加密索引);没有对应 owner 密钥的 AI 即使读到密文也解不开;`yotta-memory view` 用户查看平台:口令解锁后浏览 / 搜索 / 导出全部 AI 记忆(含各 AI 私密明文) |
|
|
49
|
+
| **跨智能体标准** | 符合 Agent Skills 开放标准(agentskills.io);装一次,Claude Code / Codex / Cursor / OpenCode 等 78+ 智能体可共用同一份记忆 |
|
|
50
|
+
| **轻量零依赖** | 无 daemon / 无数据库 / 无向量库;Node.js 自带即跑,任何机器可部署 |
|
|
51
|
+
| **双级存储** | 用户级 `~/.yottamemory/`(跨项目)+ 项目级 `.yottamemory/`(随项目共享 / 交接)|
|
|
52
|
+
| **检索与生命周期** | 语义检索(v0.8.0:同义词 / 拼音 / 字段加权 / 模糊,零依赖)+ 效用分融合排序;统一效用分(盖棺分)规则层自动归档 / 遗忘候选 / 去重(`maintain`,默认 dry-run),记忆库越用越精简 |
|
|
53
|
+
| **越用越懂(v0.6.0)** | `profile` 画像聚合(零推断)+ `context` 开工上下文包(身份 / 画像 / 近期记忆 / 边界 / 承诺)+ SKILL「记忆守则」规则层,记忆随使用成长 |
|
|
54
|
+
| **生态分发** | GitHub + npm 双源同步发布;npx skills / npm / install.sh 三种方式,覆盖 17+ 类智能体目录 |
|
|
55
|
+
| **便携记忆盘(随盘走)** | 记忆库即引擎:装在硬盘 / 主机上,插上即恢复全部记忆;引擎主机只需装 CLI 当存放点,无需装任何 AI 智能体 |
|
|
56
|
+
| **局域网共享与自启** | 每智能体独立 token(Bearer + X-Agent-Id)鉴权、可吊销;`lan enable` 注册开机自启(Windows:优先计划任务,非管理员自动降级用户级 Startup 静默自启;Linux:systemd 用户单元,不可用时自动降级用户 crontab @reboot);MCP 工具集与 CLI 一致(8 个工具),管理动作不远程暴露 |
|
|
57
|
+
| **本地 / 局域网双模式** | 本地 `serve --stdio` 零进程、按需拉起(无常驻);局域网 streamable HTTP 常驻——两种模式可并存、按需选用 |
|
|
58
|
+
|
|
59
|
+
## 功能详解
|
|
60
|
+
|
|
61
|
+
### 记忆模型:四分类 + 双级存储
|
|
62
|
+
|
|
63
|
+
记忆按内容性质分为四类,类别决定可见范围:
|
|
64
|
+
|
|
65
|
+
| 类型 | 含义 | 可见范围 |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `FACT` | 事实 / 知识 / 经验(可验证、可共享)| 公共区,所有智能体可读 |
|
|
68
|
+
| `PREF` | 偏好 / 习惯 / 喜好 | 私密区,默认仅所属 agent 可读 |
|
|
69
|
+
| `BOUND` | 边界 / 规则 / 底线 | 私密区,默认仅所属 agent 可读 |
|
|
70
|
+
| `COMMIT` | 承诺 / 锚定 / 约定 | 私密区,默认仅所属 agent 可读 |
|
|
71
|
+
|
|
72
|
+
- **双级存储**:用户级 `~/.yottamemory/` 跨项目共享个人记忆;项目级 `.yottamemory/` 随项目一起走,天然适合交接与团队协作。recall 时项目级优先。
|
|
73
|
+
- **同 key 自动更新**:同一 subject + statement 重复写入只更新 `updated`,不产生重复记录。
|
|
74
|
+
- **元数据丰富**:每条记忆带 `confidence`(置信度)、`tags`(标签)、`immutable`(锁定不可变)、`created/updated`、`access_count` 等,供检索与生命周期管理使用。
|
|
75
|
+
|
|
76
|
+
### 权限与隔离
|
|
77
|
+
|
|
78
|
+
- **读取三态**:公共 FACT 始终可读;自身私密始终可读;其它 agent 私密默认拒绝(不返回内容)。
|
|
79
|
+
- **物理隔离目录**:私密记忆按 owner 存放于 `private/<owner>/<type>/`,不同智能体的私密文件物理分离;旧版根下平铺的 `prefs/` `bounds/` `commits/` 在 `reindex` 时自动迁移。
|
|
80
|
+
- **三种授权入口(满足任一即可读他人私密)**:
|
|
81
|
+
1. `grants.json` 显式授权:`{"<userAgent>": ["<ownerAgent>", ...]}`;
|
|
82
|
+
2. identity=user:`--agent user` / `--owner user` / 环境变量 `YOTTA_AGENT_ID=user`;
|
|
83
|
+
3. 显式 `--unsafe`(用户显式授权)。
|
|
84
|
+
- **默认静默、显式跨读才报错**:默认 recall 遇其它 agent 私密静默跳过(不泄露「存在 N 条私密不可见」);仅当显式跨智能体读取(`--all` / `--owner <其它>`)且无授权命中时才报错 / 警告。
|
|
85
|
+
- **`--agent <其它>` 不越界**:`--agent <其它agent>` 仅作身份声明 / 展示用,不授予读取他人私密;读其它智能体私密仍需 grant / identity=user / `--unsafe`。
|
|
86
|
+
- **隔离定位**:scope: private 保证的是 AI 之间的语义隔离(正常 recall 不会被搜到、不会主动去读)。v0.7 起私密区为机制级机密保护——文件 AES-256-GCM 信封加密,没有对应 owner 密钥的 AI 即使读到密文文件也解不开;数据主权仍在用户,作为所有者可用 `yotta-memory view` 口令解锁查看 / 导出任何记忆文件。
|
|
87
|
+
- **禁止 shell 直读写**:记忆读写一律走 CLI / MCP 工具;用 shell(`Get-ChildItem` / `Get-Content` / `cat` / `ls` / `type` 等)直接读改库文件会绕过 scope/owner 权限边界,读到其它智能体私密内容。
|
|
88
|
+
|
|
89
|
+
### 智能体身份(唯一 ID + 自我档案)
|
|
90
|
+
|
|
91
|
+
每个智能体有一个**全局唯一的 agent ID**:它是私密记忆(PREF / BOUND / COMMIT)的归属键,也是远端接入的身份声明(`X-Agent-Id`)。
|
|
92
|
+
|
|
93
|
+
- **登记(必须唯一)**:`yotta-memory iam <id>` 写入记忆库根目录 `agents.json`,**强制唯一性**——ID 已被其它主机 / 来源(含远端 token 登记)占用时拒绝,确认是同一智能体才 `--force`。
|
|
94
|
+
- **确认身份**:`yotta-memory whoami`(远端 MCP 工具 `agent_info`)读「当次声明身份」(本机 `YOTTA_AGENT_ID` / CLI `--agent`;远端 `X-Agent-Id`),不猜不默认。
|
|
95
|
+
- **自我档案(强制落盘)**:`iam` 自动写一条 PREF `subject=自我接入档案`(owner=自己),statement 为 `; ` 分隔的 key:value:`agent_id / host / memory_home / mcp_mode(stdio|http)/ engine_url(仅远端)/ token(仅远端;本机不存 token)`。开工先 `recall "自我接入档案"` 找回身份与接入信息。
|
|
96
|
+
- **本机免 token**:本机 CLI / stdio 直连不经网络、不校验 token;身份经该智能体 MCP 配置的 `env.YOTTA_AGENT_ID` 声明。本机多个智能体各自声明唯一 ID,互不撞。
|
|
97
|
+
- **私密记忆必须有 owner**:写 PREF / BOUND / COMMIT 时未声明身份会被拒绝(公共 FACT 不受影响),从机制上防止「抄别人的 ID」。
|
|
98
|
+
|
|
99
|
+
### 画像与开工上下文(v0.6.0)
|
|
100
|
+
|
|
101
|
+
- **profile**:聚合 `private/<owner>/` 下 PREF / BOUND / COMMIT 原文,按 type + subject + tags 归组,写 `profile.md`;引擎零推断,画像结论由 AI 依据「记忆守则」内部形成,不当面贴标签。
|
|
102
|
+
- **context**:一键生成开工上下文包——多智能体接入铁律 + 身份 + 用户画像摘要 + 近期记忆(按 importance 排序)+ 边界提醒 + 承诺 / 锚点;支持 `--budget` 字符预算(token 恒定,不随记忆膨胀)。
|
|
103
|
+
- **记忆守则**:SKILL.md 内置规则层(类型红线 / 主动捕获触发信号 / 了解用户三阶段四手法 / 心理学底座与对齐 / 底线与边界 / 宿主隔离 / 反模式),让 AI「越用越懂」有章法。
|
|
104
|
+
|
|
105
|
+
### 检索:语义检索(v0.8.0)+ 中文分词打分
|
|
106
|
+
|
|
107
|
+
- `remember` 时自动构建 `index.json` 索引(v0.8.1 起 version=4,含字段加权与拼音 token;公共索引超过 5000 条按年份分片 `index-<year>.json`;旧索引首次 recall 自动重建);recall 默认语义检索——精确(字段加权:subject×3 / tags×2 / statement×1)+ 同义词(内置词表,可扩展)+ 拼音(全拼 / 首字母,内置 3755 常用字表)+ 模糊(编辑距离 ≤ 2)+ 子串兜底,并与效用分融合排序(0.65 × 语义 + 0.35 × 效用),零依赖。
|
|
108
|
+
- `recall --explain`:展示每条命中理由(精确 / 同义 / 拼音 / 模糊 + 字段)与效用分项。
|
|
109
|
+
- **recall 候选预过滤(v0.8.1)**:语义打分前先用索引 token 粗筛候选集(精确 / 同义 / 拼音 / 子串 / 模糊长度门槛),命中集与 v0.8.0 完全一致;`view` 查看平台按偏移分页返回,一次只取当前页。
|
|
110
|
+
- 可选 embedding 插件:协议预留(v0.9 实装),无插件自动零依赖降级。
|
|
111
|
+
- `index.json` 的 `tokens` 字段是中文分词的词频表(TF 打分用),**不是**访问凭证;鉴权令牌在记忆目录下 `.server/tokens.json`。
|
|
112
|
+
- 支持关键词、`--type` 过滤、`--limit` 截断、项目级优先。
|
|
113
|
+
- **根位置去重(v0.6.5)**:当项目级与用户级记忆库指向同一目录(如 cwd = home 或其父)时,`recall` / `context` 自动唯一化根,同一文件只展示一次。
|
|
114
|
+
- 命中展示会累加 `access_count` / `last_accessed`,为生命周期管理提供依据。
|
|
115
|
+
|
|
116
|
+
### 生命周期管理(v0.8.0 规则层自组织)
|
|
117
|
+
|
|
118
|
+
- `maintain`(v0.8.0):规则层自组织——统一效用分(盖棺分 = confidence + 使用 + 时效 + 类型 + 结构)× weight,低效用 + 超龄自动归档;极端低价值列为遗忘候选(默认不真删,`--purge` 才删);`--dedup` 去重候选;`--merge A,B` 手动合并。默认 dry-run 预览,`--apply` 才执行;immutable / BOUND 豁免;审计写 `.archive/audit-<日期>.jsonl`。
|
|
119
|
+
- `archive`:按「统一效用分 + 年龄」把低价值旧记忆移入 `.archive/`(`immutable` 除外),记忆库不会无限膨胀(v0.8.0 起底层用统一效用分)。
|
|
120
|
+
- `feedback`(v0.8.0):显式使用反馈闭环——useful → weight ×1.2(上限 3.0)+ confidence +0.05 + feedback_net +1;useless → weight ×0.8(下限 0.2)+ confidence −0.05 + feedback_net −1;`--undo` 回滚;审计写 `.archive/feedback-<日期>.jsonl`。
|
|
121
|
+
- `distill`(v0.8.0):心理日志蒸馏——统计摘要(类型 / 年龄 / 热度 / 反馈)+ 主题画像(按 subject 聚类合并)+ 知识地图(type → tags);可选 `--model <cmd>` 外部模型 stdin→stdout 提炼;产物入 `private/<owner>/distills/` 或 `facts/distills/`。
|
|
122
|
+
- `explain`(v0.8.0):查看单条记忆效用分项与归档 / 遗忘状态判定。
|
|
123
|
+
- `forget`:删除单条记忆(按类型目录路径或文件名)。
|
|
124
|
+
- `reindex`:手动改过 `.md` 后重建索引。
|
|
125
|
+
- `export` / `import`:整库导出为 JSON / 从 JSON 导入,可作迁移与备份中间格式。
|
|
126
|
+
- git:整个记忆库可纳入版本控制,回滚 / 审计 / 团队同步。
|
|
127
|
+
|
|
128
|
+
### 智能体接入
|
|
129
|
+
|
|
130
|
+
把技能装进智能体后,SKILL.md 会自动教会智能体一套工作流:**开工 `context` 主注入(身份 + 画像 + 近期记忆 + 边界 + 承诺)→ 重要信息 `remember` 落盘 → 收工归档**,并遵循「记忆守则」(类型红线 / 触发信号 / 底线 / 宿主隔离)。也可在对话中直接说「记住 XXX」「上次说到哪了」「记一笔」触发。
|
|
131
|
+
|
|
132
|
+
### 便携记忆盘(记忆库即引擎)
|
|
133
|
+
|
|
134
|
+
- **记忆库即引擎**:`serve` 把记忆目录挂成 MCP 服务,目录随盘走;引擎主机只需装 CLI 当存放点,无需装任何 AI 智能体。
|
|
135
|
+
- **双模式可并存**:本地 `serve --stdio` 零进程(客户端按需拉起);局域网 streamable HTTP(默认 `0.0.0.0:8787`)+ 每智能体 token 鉴权。
|
|
136
|
+
- **开机自启**:`lan enable` 注册开机自启——Windows 优先计划任务(默认登录自启,`--onstart` 开机即启需管理员),非管理员自动降级为**用户级 Startup 静默自启**(免管理员,启动脚本内联启动命令、被清理也会在开机时自动重建,v0.6.3 起不再弹 80070002);Linux 优先 **systemd 用户单元**(`systemctl --user`,登录自启;`--onstart` 附加 `loginctl enable-linger` 开机即启),systemd 不可用时自动降级**用户 crontab @reboot**(v0.6.4);`lan disable` 移除,`lan status` 查询。
|
|
137
|
+
- **安全边界**:管理动作(init / config / token / lan / serve)不进 MCP,token 不远程暴露;远程智能体只能读写记忆,不能改配置、不能管 token。
|
|
138
|
+
- 完整操作步骤见上文「局域网多机共享」章节与 [USER_GUIDE.md](USER_GUIDE.md)。
|
|
139
|
+
|
|
140
|
+
## 与其他方案对比
|
|
141
|
+
|
|
142
|
+
> 以下按方案类型对比,不涉及具体产品名称。判断标准:数据主权、部署成本、权限边界、可审计性、跨智能体能力。
|
|
143
|
+
|
|
144
|
+
| 维度 | 元忆(yotta-memory) | 数据库 / 嵌入式存储类 | 向量库 / 语义检索类 | 云端托管记忆服务 |
|
|
145
|
+
|---|---|---|---|---|
|
|
146
|
+
| 存储形态 | 公共 FACT 明文文件;私密区加密(.md.enc),git 可版本化 | 二进制 / 结构化数据库文件 | 向量索引 + 模型依赖 | 厂商服务器 |
|
|
147
|
+
| 数据主权 | 完全在用户本地,可读可改可删(私密区经 view 平台口令解锁) | 本地,但需专用工具读写 | 本地或自托管,模型需额外部署 | 不在用户手中,受服务条款约束 |
|
|
148
|
+
| 权限边界 | 内置:公共 / 私密分区 + scope/owner + 授权 | 通常无内置,需自行实现 | 通常无内置,需自行实现 | 通常只有账号级权限,无记忆级细粒度 |
|
|
149
|
+
| 可审计 / 回滚 | 公共 FACT 明文可审计;私密区加密但用户可用 view 平台解密,git 可回滚 | 需导出工具链,回滚复杂 | 依赖快照 / 导出机制 | 依赖平台导出能力 |
|
|
150
|
+
| 部署与依赖 | 零依赖,Node.js 即跑 | 需数据库运行 / 嵌入式依赖 | 需向量库 + 模型,较重 | 联网 + 账号,数据出本地 |
|
|
151
|
+
| 跨智能体 | 符合 Agent Skills 标准,一次写入多智能体可读 | 各智能体各自接入,无统一标准 | 需各自接入,成本高 | 取决于平台支持范围 |
|
|
152
|
+
|
|
153
|
+
**结论**:元忆的核心差异点在于把「数据主权 + 权限边界 + 零依赖」三者合一——既是可审计的文件,又有机制级的读取隔离,还不引入任何重型依赖。对「本地优先、多智能体协作、长期沉淀」的场景,这是最轻的一条路。
|
|
154
|
+
|
|
155
|
+
## 安装
|
|
156
|
+
|
|
157
|
+
三种方式任选其一,技能文件统一从 **npm** 获取(GitHub 无代理时较慢,npm 可配国内镜像加速)。
|
|
158
|
+
|
|
159
|
+
### 方式一:npx skills(推荐,生态标准入口)
|
|
160
|
+
```bash
|
|
161
|
+
npx skills add YottaMeta/yotta-memory
|
|
162
|
+
```
|
|
163
|
+
> 自动把技能文件装到已检测到的智能体(Claude Code / Codex / Cursor / OpenCode 等 78+ 智能体)。此方式只装「技能指令」(SKILL.md 等);要使用 `yotta-memory` 读写命令,需另装 CLI:`npm install -g @yottameta/yotta-memory`(见方式二)。
|
|
164
|
+
|
|
165
|
+
### 方式二:npm 直接安装(CLI + 技能)
|
|
166
|
+
```bash
|
|
167
|
+
# 国内加速(可选):npm config set registry https://registry.npmmirror.com
|
|
168
|
+
npm install -g @yottameta/yotta-memory
|
|
169
|
+
yotta-memory init # 初始化记忆库
|
|
170
|
+
yotta-memory-install -g # 装进所有已识别智能体(用户级)
|
|
171
|
+
yotta-memory-install --agent codex # 只装进指定智能体
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
> 全局安装后 `yotta-memory`(读写下)与 `yotta-memory-install`(安装器)两个命令均已加入 PATH。若不想全局安装,可一行运行安装器:`npx -y --package @yottameta/yotta-memory yotta-memory-install -g`。
|
|
175
|
+
|
|
176
|
+
### 方式三:install.sh / 手动复制
|
|
177
|
+
获取技能文件夹后(`npm pack` 解包或 `git clone`),进入技能文件夹:
|
|
178
|
+
```bash
|
|
179
|
+
bash install.sh -g # 用户级;bash install.sh --list 查看全部目录
|
|
180
|
+
bash install.sh --agent codex # 指定智能体
|
|
181
|
+
bash install.sh --dir /path/to/skills
|
|
182
|
+
```
|
|
183
|
+
也可把整个 `yotta-memory` 文件夹复制到目标智能体的 skills 目录(常见位置见 install.sh --list)。
|
|
184
|
+
|
|
185
|
+
## 升级
|
|
186
|
+
|
|
187
|
+
两种升级方式对应两种安装方式:
|
|
188
|
+
|
|
189
|
+
**升级 CLI**(重新执行一次安装命令即可,不带版本号默认装最新):
|
|
190
|
+
```bash
|
|
191
|
+
npm i -g @yottameta/yotta-memory
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**升级技能**:重新执行你当初的安装命令即可(`npx skills add YottaMeta/yotta-memory` 或 `yotta-memory-install -g`),覆盖旧版本技能文件夹。
|
|
195
|
+
|
|
196
|
+
> 升级只影响命令与技能文件,**不会动你已存的记忆**(记忆是独立于安装的文件,保留在原目录)。
|
|
197
|
+
|
|
198
|
+
## CLI 用法
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
| 命令 | 作用 |
|
|
202
|
+
|---|---|
|
|
203
|
+
| `yotta-memory init [--project] [--dir <目录>]` | 初始化记忆库(默认用户级 `~/.yottamemory/`;--dir 显式指定位置)|
|
|
204
|
+
| `yotta-memory remember <type> <subject> <statement> [--owner <id>] [--source <来源>] [--weight <0..>] [--verify] [--no-hint]` | 写入记忆(同 subject+statement 自动更新;--owner 标注归属;--source 记录来源;--weight 重要性权重、去重取 max;--verify 写后回读;--no-hint 关闭类型提示)|
|
|
205
|
+
| `yotta-memory recall [关键词] [--type T] [--limit N] [--agent <id>] [--owner <id>] [--all] [--unsafe]` | 检索记忆(索引+TF 打分,读取分区过滤;越界读其它智能体私密默认拒绝,需 grant / identity=user / `--unsafe`;`--agent <其它>` 仅作身份声明、不授予跨读;项目级优先)|
|
|
206
|
+
| `yotta-memory profile [--owner <id>]` | 生成用户画像(聚合 `private/<owner>/` 原文,零推断,写 `profile.md`;跨 owner 默认拒绝)|
|
|
207
|
+
| `yotta-memory context [--limit N] [--owner <id>] [--budget N]` | 生成开工上下文包(身份 + 多智能体铁律 + 画像 + 近期记忆 + 边界 + 承诺;--budget 近期记忆字符预算,token 恒定)|
|
|
208
|
+
| `yotta-memory forget <文件>` | 删除一条记忆(按类型目录路径或文件名)|
|
|
209
|
+
| `yotta-memory archive [--days 180] [--threshold 0.4]` | 归档旧记忆(盖棺分+年龄,immutable 除外)|
|
|
210
|
+
| `yotta-memory reindex` | 重建索引(手动改 .md 后校正)|
|
|
211
|
+
| `yotta-memory export [--out f.json]` / `import <f.json>` | 导出 / 导入 |
|
|
212
|
+
| `yotta-memory config set memory_home <目录>` / `config get` | 持久记住 / 查看记忆库位置(`~/.yottamemory/config.json`)|
|
|
213
|
+
| `yotta-memory whoami` | 查看当前智能体身份与登记状态(读 `YOTTA_AGENT_ID` / `X-Agent-Id`,不猜不默认)|
|
|
214
|
+
| `yotta-memory iam <id> [--name <显示名>] [--user <用户名>] [--relationship <关系>] [--force]` | 登记本智能体唯一身份并自动落自我档案(`agents.json`,ID 必须唯一;可选扩展显示名 / 用户 / 关系)|
|
|
215
|
+
| `yotta-memory token new --agent <id> [--force]` / `token list` / `token revoke --agent <id>` | 为智能体生成 / 列出 / 吊销访问 token(登记于记忆库 `.server/tokens.json`;同 ID 已被其它来源占用需 `--force` 覆盖,防不同智能体合流)|
|
|
216
|
+
| `yotta-memory serve [--host 0.0.0.0] [--port 8787] [--no-auth] [--stdio]` | 启动 MCP 记忆引擎(streamable HTTP 局域网 / --stdio 本地零进程模式;Bearer token + X-Agent-Id 鉴权)|
|
|
217
|
+
| `yotta-memory lan enable [--onstart] / disable / status` | 开机自启管理(Windows:计划任务,默认 ONLOGON、--onstart 开机即启需管理员,非管理员自动降级用户级 Startup 静默自启;Linux:systemd 用户单元,不可用时自动降级用户 crontab @reboot)|
|
|
218
|
+
|
|
219
|
+
类型:`FACT`(事实,公共共享)/ `PREF`(偏好)/ `BOUND`(边界)/ `COMMIT`(承诺)。
|
|
220
|
+
|
|
221
|
+
示例:
|
|
222
|
+
```bash
|
|
223
|
+
yotta-memory init
|
|
224
|
+
yotta-memory remember PREF 用户 偏好短回复,不要用表情
|
|
225
|
+
yotta-memory recall 偏好
|
|
226
|
+
yotta-memory profile
|
|
227
|
+
yotta-memory context --limit 10
|
|
228
|
+
yotta-memory recall --type FACT --limit 10
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
环境变量:
|
|
232
|
+
- `YOTTA_MEMORY_HOME`:覆盖用户级记忆库目录(默认 `~/.yottamemory/`)。
|
|
233
|
+
- `YOTTA_AGENT_ID` / `AGENT_ID`:当前 agent 标识(本机声明身份用,参与读取分区判定;私密记忆必须有 owner,未声明会被拒绝)。
|
|
234
|
+
|
|
235
|
+
## 智能体接入后怎么用
|
|
236
|
+
|
|
237
|
+
把技能装进智能体后,SKILL.md 会自动教会智能体:开工 `recall` 恢复上下文 → 重要信息 `remember` 落盘 → 收工归档。也可在对话中直接说「记住 XXX」「上次说到哪了」。
|
|
238
|
+
|
|
239
|
+
## 局域网多机共享(便携记忆盘模式)
|
|
240
|
+
|
|
241
|
+
记忆库可以装在任何主机或硬盘上(= 记忆引擎),供局域网内其它主机上的智能体远程接入:
|
|
242
|
+
|
|
243
|
+
- **本机直连**:CLI 直接读写,无需 token;
|
|
244
|
+
- **远程接入**:引擎主机运行 `yotta-memory serve` 常驻(或 `lan enable` 注册开机自启),远程智能体通过 MCP 以 `url + token` 连接。
|
|
245
|
+
- **本地零进程**:本机 MCP 客户端可用 `serve --stdio` 按需拉起 CLI(无常驻进程)。
|
|
246
|
+
|
|
247
|
+
### 引擎侧(记忆所在主机)
|
|
248
|
+
|
|
249
|
+
1. 初始化或接入记忆库(见 CLI 用法)。
|
|
250
|
+
2. 为需要访问的每个智能体生成独立 token:
|
|
251
|
+
```bash
|
|
252
|
+
yotta-memory token new --agent <智能体ID> # 打印一次,如 ytm_...(同 ID 已被其它来源占用需加 --force)
|
|
253
|
+
yotta-memory token list # 查看已登记智能体
|
|
254
|
+
yotta-memory token revoke --agent <智能体ID> # 吊销
|
|
255
|
+
```
|
|
256
|
+
> 新生成的 token 即时生效,无需重启服务。
|
|
257
|
+
3. 启动服务(默认监听 0.0.0.0:8787,Bearer token + X-Agent-Id 鉴权)——临时运行或注册开机自启二选一:
|
|
258
|
+
```bash
|
|
259
|
+
yotta-memory serve # 临时前台运行
|
|
260
|
+
yotta-memory lan enable # 注册开机自启(Windows:计划任务/用户级 Startup;Linux:systemd 用户单元/用户 crontab)
|
|
261
|
+
yotta-memory lan status # 查看自启状态
|
|
262
|
+
```
|
|
263
|
+
> `lan enable --onstart` 改为开机即启(需管理员);非管理员时 `lan enable` 自动改用用户级 Startup 静默自启(无需管理员);`lan disable` 移除自启。
|
|
264
|
+
|
|
265
|
+
> 首次监听 0.0.0.0 时,Windows / 系统防火墙可能询问是否放行,需允许放行,否则局域网内其它主机无法访问;`--no-auth` 会关闭鉴权,仅限可信内网使用。
|
|
266
|
+
|
|
267
|
+
### 客户端侧(远程智能体)
|
|
268
|
+
|
|
269
|
+
在智能体 MCP 配置中登记连接(`url` + 两个请求头):
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"mcpServers": {
|
|
274
|
+
"yotta-memory": {
|
|
275
|
+
"url": "http://<引擎主机IP>:8787/mcp",
|
|
276
|
+
"headers": {
|
|
277
|
+
"Authorization": "Bearer <TOKEN>",
|
|
278
|
+
"X-Agent-Id": "<本智能体ID>"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
连接后可通过 MCP tools(remember / recall / search / forget / archive / reindex / export / import / agent_info)读写记忆与确认身份;管理动作(init / config / token / lan / serve)不进 MCP,token 管理不远程暴露。`X-Agent-Id` 必须与 token 登记的智能体一致;读取分区规则与 CLI 相同(FACT 公共可读,PREF / BOUND / COMMIT 私密隔离)。
|
|
286
|
+
|
|
287
|
+
### 位置持久化
|
|
288
|
+
|
|
289
|
+
CLI 会持久记住记忆库位置(`~/.yottamemory/config.json`),同一主机上的智能体此后开工 `recall` 自动使用正确位置,无需每次指定:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
yotta-memory config set memory_home <记忆库目录>
|
|
293
|
+
yotta-memory config get
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
位置解析优先级:`YOTTA_MEMORY_HOME`(临时覆盖)> `config.json#memory_home`(持久)> 默认 `~/.yottamemory`。把记忆库放在硬盘上、插到任意主机后执行一次 `config set memory_home`(或用 `yotta-memory init --dir <目录>` 一步初始化到指定位置),即可在该主机恢复全部记忆。
|
|
297
|
+
|
|
298
|
+
## 开发与校验
|
|
299
|
+
|
|
300
|
+
本项目内运行:`python tools/validate-skill.py yotta-memory`。
|
|
301
|
+
|
|
302
|
+
## 许可证
|
|
303
|
+
|
|
304
|
+
MIT © YottaMeta —— 详见 [LICENSE](./LICENSE)。
|
package/SKILL.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yotta-memory
|
|
3
3
|
description: "元忆 —— 有权限边界的文件式智能体记忆。文件式、零依赖、可 diff/回滚:让任何 AI 智能体活过会话,开工 recall 恢复上下文、重要信息 remember 落盘、收工归档。类型体系 FACT(公共共享)/ PREF / BOUND / COMMIT(私密隔离)。触发:记住、别忘了、记一笔、记忆、remember、recall、跨会话、上次说到、续测、交接、归档、记忆盘、共享记忆、局域网记忆、画像、开工上下文、记忆守则、profile、context、越用越懂、语义检索、反馈、维护、蒸馏、feedback、maintain、distill、explain、自我学习、自我进化、自我提升、查看平台分页、recall 候选预过滤"
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.3
|
|
5
5
|
license: MIT
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# yotta-memory(元忆)— 有权限边界的文件式智能体记忆
|
|
9
9
|
|
|
10
10
|
> 一句话:元忆 —— 有权限边界的文件式智能体记忆(不注入、可 diff、能回滚;FACT 共享、PREF / BOUND / COMMIT 私密隔离)。
|
|
11
|
-
> 版本:0.8.
|
|
11
|
+
> 版本:0.8.2 | 最后更新:2026-08-27
|
|
12
12
|
|
|
13
13
|
## 这是什么
|
|
14
14
|
|
package/bin/yotta-memory.js
CHANGED
|
@@ -22,7 +22,7 @@ const crypto = require('crypto');
|
|
|
22
22
|
const http = require('http');
|
|
23
23
|
const child_process = require('child_process');
|
|
24
24
|
|
|
25
|
-
const VERSION = '0.8.
|
|
25
|
+
const VERSION = '0.8.3';
|
|
26
26
|
const TYPES = ['FACT', 'PREF', 'BOUND', 'COMMIT'];
|
|
27
27
|
const TYPE_DIRS = { FACT: 'facts', PREF: 'prefs', BOUND: 'bounds', COMMIT: 'commits' };
|
|
28
28
|
const PUBLIC_DIR = 'facts';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yottameta/yotta-memory",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "元忆
|
|
3
|
+
"version": "0.8.3",
|
|
4
|
+
"description": "Yuanyi (元忆) — boundary-aware, file-based memory for AI agents. File-based, zero-dependency, diff/rollback-able; FACT/PREF/BOUND/COMMIT four types (public shared / private isolated), user-level + project-level storage; v0.8 semantic search + usage feedback loop + rule-layer self-organization + psychological-log distillation (self-learning/self-evolving/self-improving).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"agent-skills",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"references",
|
|
21
21
|
"scripts",
|
|
22
22
|
"assets",
|
|
23
|
-
"bin"
|
|
23
|
+
"bin",
|
|
24
|
+
"README.zh-CN.md",
|
|
25
|
+
"NOTICE",
|
|
26
|
+
"CHANGELOG.md"
|
|
24
27
|
],
|
|
25
28
|
"repository": {
|
|
26
29
|
"type": "git",
|