@bsbofmusic/memos-memu-local-memory-tools-for-agent 1.3.2 → 1.3.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/SKILL.md +115 -0
- package/package.json +1 -1
- package/src/tools/install.js +22 -45
package/SKILL.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memory-triple-recall
|
|
3
|
+
description: |
|
|
4
|
+
三层记忆召回:File Brain → memos + memuK(MCP,同时查询)。
|
|
5
|
+
默认调用:mcporter call memos-memu-local-memory-tools-for-agent memos_memuk_query query="<关键词>"
|
|
6
|
+
Layer 2 强制并行,不允许串行分开查。
|
|
7
|
+
triggers: 回忆|回想|记得|原话|哪天|什么时候|答应过|之前|历史|进展|有没有说过|问过你
|
|
8
|
+
version: 2.2.0
|
|
9
|
+
updated: 2026-03-28
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# 三层记忆召回 — Memory Triple Recall
|
|
13
|
+
|
|
14
|
+
## 架构
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
Layer 1 File Brain → 稳定事实、规则、拍板决定
|
|
18
|
+
Layer 2 memos + memuK ← 必须同时触发,不用等
|
|
19
|
+
↓ memos(原话、原始内容)+ memuK(摘要、跨session)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 调用规则(强制)
|
|
25
|
+
|
|
26
|
+
### Layer 1:File Brain
|
|
27
|
+
- 直接读 `MEMORY.md` / `memory/*.md`
|
|
28
|
+
- 适用:系统规则、拍板结论、阶段总结、配置拍板
|
|
29
|
+
|
|
30
|
+
### Layer 2:memos + memuK(MCP,必须同时触发)
|
|
31
|
+
```
|
|
32
|
+
mcporter call memos-memu-local-memory-tools-for-agent memos_memuk_query query="<关键词>" limit=10
|
|
33
|
+
```
|
|
34
|
+
- **关键词提取规则(必须执行)**:
|
|
35
|
+
1. 先把问题拆成短句,去掉语气词(吗、呢、吧、啊、呀)、标点符号
|
|
36
|
+
2. 提取核心名词、动词短语、人名、地名、项目名
|
|
37
|
+
3. 多个关键词都要试,不要只试一个
|
|
38
|
+
4. 常见例子:
|
|
39
|
+
- "我喜欢的女星是谁" → 优先试"Leah Gotti",然后"喜欢的女星",然后"女星"
|
|
40
|
+
- "之前我们有没有聊过npm token的事" → 优先试"npm token",然后"npm",然后"token"
|
|
41
|
+
- "3月9日有什么重要的事" → 优先试"3月9日",然后"重要的事"
|
|
42
|
+
- "穿孔枕项目最近进展" → 优先试"穿孔枕",然后"piercing pillow",然后"项目进展"
|
|
43
|
+
- 适用:**所有个人事实类问题**,包括但不限于:
|
|
44
|
+
- 喜欢什么、最爱谁
|
|
45
|
+
- 女友、crush、女星
|
|
46
|
+
- 个人偏好、私人事实
|
|
47
|
+
- 具体承诺、时间点
|
|
48
|
+
- "之前说过"、"原话"
|
|
49
|
+
- **禁止**:凭记忆直接答,必须调 MCP 工具查
|
|
50
|
+
- 如果 Layer 1 已经明确记载,直接答;Layer 1 没有的,必须走 Layer 2(用合并的工具同时查两个数据库)
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 问题路由表
|
|
55
|
+
|
|
56
|
+
| 问题类型 | 示例 | 路由 |
|
|
57
|
+
|---------|------|------|
|
|
58
|
+
| 系统规则/配置 | "我的 MCP 有哪些工具" | Layer 1(MEMORY.md)|
|
|
59
|
+
| 个人偏好/事实 | "我喜欢什么"、"我女友是谁" | **Layer 2 必须** |
|
|
60
|
+
| 承诺/时间点 | "我什么时候答应过" | **Layer 2 必须** |
|
|
61
|
+
| 原话 | "我当时怎么说的" | **Layer 2 必须** |
|
|
62
|
+
| 模糊主题 | "我们聊过 XXX 吗" | Layer 2 → Layer 3 |
|
|
63
|
+
| 稳定结论 | "上次排障结论是什么" | Layer 1 已有则直接答 |
|
|
64
|
+
| 最新 session | 最近 15 分钟的对话 | Layer 2(还没被 ingest 则走 session)|
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 输出格式
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
已确认事实(来自 Layer X):
|
|
72
|
+
- ...
|
|
73
|
+
|
|
74
|
+
原话·证据(来自 memos id:xxx):
|
|
75
|
+
> ...
|
|
76
|
+
|
|
77
|
+
仍不确定点:
|
|
78
|
+
- ...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
三层全空时:
|
|
82
|
+
```
|
|
83
|
+
已确认事实 → [空]
|
|
84
|
+
原话·证据 → [空]
|
|
85
|
+
仍不确定点 → 此话题在三层记忆中均无记录。
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 强制执行约束
|
|
91
|
+
|
|
92
|
+
1. **Layer 2 必须并行**:任何个人事实类问题,第一动作必须是 `memos_memuk_query` 并行同时查两个库,不允许先查一个再查另一个
|
|
93
|
+
2. **不制造记忆**:memos + memuK 都查不到就说查不到,禁止编造
|
|
94
|
+
3. **证据要引用**:从返回结果里引用原文,不要自己总结
|
|
95
|
+
4. **版本时效**:memos ingest 延迟 ~15 分钟,超短窗口内的问题可标注"可能尚未 ingest"
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## MCP 工具参考
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Layer 2 查询(memos + memuK 同时并行,禁止分开)
|
|
103
|
+
mcporter call memos-memu-local-memory-tools-for-agent memos_memuk_query query="<关键词>" limit=10
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 零证据时的标准回复
|
|
109
|
+
|
|
110
|
+
当三层全空时,使用以下标准回复,不要自行发挥:
|
|
111
|
+
|
|
112
|
+
> 已确认事实 → [空]
|
|
113
|
+
> 原话·证据 → [空]
|
|
114
|
+
> 仍不确定点 → 此话题在三层记忆中均无记录。建议直接告诉我。
|
|
115
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsbofmusic/memos-memu-local-memory-tools-for-agent",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "MCP server — one-shot install + query for memos (PostgreSQL) and memuK (SQLite) local memory. Designed for OpenClaw agents.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
package/src/tools/install.js
CHANGED
|
@@ -163,50 +163,24 @@ INSERT OR IGNORE INTO memu_sync_checkpoint (key, value) VALUES ('last_memo_id',
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// ── SKILL ────────────────────────────────────────────────────────────────
|
|
166
|
-
const skillDir = path.join(env.
|
|
166
|
+
const skillDir = path.join(env.workspaceDir, 'skills', 'memory-triple-recall');
|
|
167
167
|
const skillFile = path.join(skillDir, 'SKILL.md');
|
|
168
|
-
|
|
168
|
+
// Copy bundled SKILL.md from the npm package (bundled at ../SKILL.md relative to this file)
|
|
169
|
+
const bundledSkill = path.join(__dirname, '..', '..', 'SKILL.md');
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
| Layer | Store | Access |
|
|
184
|
-
|-------|-------|--------|
|
|
185
|
-
| File brain | MEMORY.md / memory/*.md | File system |
|
|
186
|
-
| memos | PostgreSQL Docker | memos_query MCP tool |
|
|
187
|
-
| memuK | SQLite | memuk_search MCP tool |
|
|
188
|
-
|
|
189
|
-
## Fast path
|
|
190
|
-
Do NOT trigger layered recall for atomic facts in USER.md / IDENTITY.md / injected context.
|
|
191
|
-
|
|
192
|
-
## NEVER fast-path (always do Layer 1+2)
|
|
193
|
-
- 喜欢、最爱、最喜欢的X
|
|
194
|
-
- 女友、crush、个人偏好、私人事实
|
|
195
|
-
|
|
196
|
-
## Default order
|
|
197
|
-
1. File brain: stable facts, rules, decisions
|
|
198
|
-
2. memos: original wording, timing, commitments (memos_query)
|
|
199
|
-
3. memuK: fuzzy topic recall (memuk_search)
|
|
200
|
-
|
|
201
|
-
## Output shape
|
|
202
|
-
- 已确认事实
|
|
203
|
-
- 原话·证据
|
|
204
|
-
- 仍不确定点
|
|
205
|
-
|
|
206
|
-
## Zero-evidence fallback
|
|
207
|
-
已确认事实 → [空]
|
|
208
|
-
原话·证据 → [空]
|
|
209
|
-
仍不确定点 → 此话题在三层记忆中均无记录。
|
|
171
|
+
try {
|
|
172
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
173
|
+
if (fs.existsSync(bundledSkill)) {
|
|
174
|
+
fs.copyFileSync(bundledSkill, skillFile);
|
|
175
|
+
report.ok('memory-triple-recall SKILL', `Installed → ${skillFile}`);
|
|
176
|
+
} else if (!fs.existsSync(skillFile)) {
|
|
177
|
+
report.fail('memory-triple-recall SKILL', `Bundled SKILL.md not found at ${bundledSkill}`);
|
|
178
|
+
} else {
|
|
179
|
+
report.skip('memory-triple-recall SKILL', 'Bundled SKILL.md not found — preserving existing');
|
|
180
|
+
}
|
|
181
|
+
} catch (err) {
|
|
182
|
+
report.fail('memory-triple-recall SKILL', err.message);
|
|
183
|
+
}
|
|
210
184
|
`;
|
|
211
185
|
|
|
212
186
|
try {
|
|
@@ -222,9 +196,11 @@ Do NOT trigger layered recall for atomic facts in USER.md / IDENTITY.md / inject
|
|
|
222
196
|
}
|
|
223
197
|
|
|
224
198
|
// ── Cron ─────────────────────────────────────────────────────────────────
|
|
199
|
+
const syncScript = path.join(env.workspaceDir, 'scripts', 'sync_memos_to_memuk.py');
|
|
200
|
+
const syncLog = path.join(env.workspaceDir, 'logs', 'memuk-sync.log');
|
|
225
201
|
const cronContent = `\
|
|
226
202
|
# memos → memuK sync every 15 minutes
|
|
227
|
-
*/15 * * * * root
|
|
203
|
+
*/15 * * * * ${process.env.USER || 'root'} ${syncScript} >> ${syncLog} 2>&1
|
|
228
204
|
`.trim();
|
|
229
205
|
|
|
230
206
|
const cronPath = '/etc/cron.d/memuk-sync';
|
|
@@ -235,7 +211,7 @@ Do NOT trigger layered recall for atomic facts in USER.md / IDENTITY.md / inject
|
|
|
235
211
|
} catch {
|
|
236
212
|
try {
|
|
237
213
|
await sh(
|
|
238
|
-
`(crontab -l 2>/dev/null | grep -v "memuk-sync"; echo "*/15 * * * *
|
|
214
|
+
`(crontab -l 2>/dev/null | grep -v "memuk-sync"; echo "*/15 * * * * ${process.env.USER || 'root'} ${syncScript} >> ${syncLog} 2>&1") | crontab -`,
|
|
239
215
|
{ timeout: 5000 }
|
|
240
216
|
);
|
|
241
217
|
report.ok('Sync cron', 'Installed via user crontab');
|
|
@@ -246,7 +222,8 @@ Do NOT trigger layered recall for atomic facts in USER.md / IDENTITY.md / inject
|
|
|
246
222
|
|
|
247
223
|
// ── MCPorter config ────────────────────────────────────────────────────────
|
|
248
224
|
const pkgName = 'memos-memu-local-memory-tools-for-agent';
|
|
249
|
-
|
|
225
|
+
// mcporter.json lives in workspace/config/ (not workspace/ directly)
|
|
226
|
+
const mcporterConfigPath = path.join(env.workspaceDir, 'config', 'mcporter.json');
|
|
250
227
|
let existingConfig = {};
|
|
251
228
|
if (fs.existsSync(mcporterConfigPath)) {
|
|
252
229
|
try {
|