openmemory-plus 1.0.0 → 1.2.0
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/dist/index.js +200 -190
- package/package.json +10 -6
- package/templates/augment/AGENTS.md +78 -0
- package/templates/claude/CLAUDE.md +52 -0
- package/templates/common/AGENTS.md +51 -0
- package/templates/cursor/.cursorrules +57 -0
- package/templates/gemini/gemini.md +77 -0
- package/templates/shared/commands/memory.md +86 -0
- package/templates/shared/memory/activeContext.md +34 -0
- package/templates/shared/memory/productContext.md +30 -0
- package/templates/shared/memory/progress.md +41 -0
- package/templates/shared/memory/projectbrief.md +36 -0
- package/templates/shared/memory/systemPatterns.md +39 -0
- package/templates/shared/memory/techContext.md +51 -0
- package/templates/shared/memory-actions/clean.md +54 -0
- package/templates/shared/memory-actions/decay.md +64 -0
- package/templates/shared/memory-actions/graph.md +75 -0
- package/templates/shared/memory-actions/search.md +38 -0
- package/templates/shared/memory-actions/status.md +35 -0
- package/templates/shared/memory-actions/store.md +45 -0
- package/templates/shared/memory-actions/sync.md +50 -0
- package/templates/shared/rules/classification.md +108 -0
- package/templates/shared/skills/memory-extraction/SKILL.md +394 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memory-extraction
|
|
3
|
+
description: Agent-only workflow for extracting key information from conversations, code changes, and deployments into structured memory files. Automatically updates `.memory/` directory and notifies other agents. Triggered automatically at conversation end or when valuable information is detected.
|
|
4
|
+
metadata:
|
|
5
|
+
author: Wendy (Workflow Builder)
|
|
6
|
+
version: "2.0"
|
|
7
|
+
language: zh-CN
|
|
8
|
+
audience: agent-only
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Memory Extraction Skill (Agent-Only)
|
|
12
|
+
|
|
13
|
+
## 目的
|
|
14
|
+
|
|
15
|
+
**自动提取对话中的关键信息**,智能路由到正确的存储系统:
|
|
16
|
+
- **项目级信息** → `.memory/` 目录 (Git 版本控制)
|
|
17
|
+
- **用户级信息** → `openmemory` MCP (跨项目共享)
|
|
18
|
+
|
|
19
|
+
> **Agent-Only 原则**:
|
|
20
|
+
> - **自动触发**:对话结束时或检测到有价值信息时自动运行
|
|
21
|
+
> - **智能分类**:根据信息类型自动选择存储位置
|
|
22
|
+
> - **零人工干预**:无需用户确认,静默执行
|
|
23
|
+
> - **双系统同步**:同时管理 `.memory/` 和 `openmemory`
|
|
24
|
+
|
|
25
|
+
## 双层记忆架构
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Agent 记忆系统
|
|
29
|
+
├── .memory/ (项目级)
|
|
30
|
+
│ ├── project.yaml # 项目配置、部署信息
|
|
31
|
+
│ ├── decisions.yaml # 技术决策记录
|
|
32
|
+
│ └── changelog.yaml # 变更历史
|
|
33
|
+
└── openmemory (用户级)
|
|
34
|
+
├── 用户偏好 # 跨项目通用
|
|
35
|
+
├── 用户技能 # 个人能力
|
|
36
|
+
└── 对话上下文 # 历史记忆
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 分类规则
|
|
40
|
+
|
|
41
|
+
> 📌 详细规则见 `.rules/memory/classification.md`
|
|
42
|
+
|
|
43
|
+
| 信息类型 | 存储位置 | 识别信号 |
|
|
44
|
+
|----------|----------|----------|
|
|
45
|
+
| 项目配置 | `.memory/project.yaml` | url, deploy, config |
|
|
46
|
+
| 技术决策 | `.memory/decisions.yaml` | 决定, 选择, 采用 |
|
|
47
|
+
| 变更记录 | `.memory/changelog.yaml` | 更新, 发布, release |
|
|
48
|
+
| 用户偏好 | `openmemory` | 偏好, 喜欢, 习惯 |
|
|
49
|
+
| 用户技能 | `openmemory` | 会, 熟悉, 经验 |
|
|
50
|
+
| 对话上下文 | `openmemory` | 之前, 上次, 记得 |
|
|
51
|
+
|
|
52
|
+
## 触发条件
|
|
53
|
+
|
|
54
|
+
### 自动触发(推荐)
|
|
55
|
+
- 对话结束时自动检查是否有新信息
|
|
56
|
+
- 检测到以下关键事件时立即触发:
|
|
57
|
+
- 部署状态变更(成功/失败)
|
|
58
|
+
- 新服务配置
|
|
59
|
+
- 重要技术决策
|
|
60
|
+
- 项目里程碑
|
|
61
|
+
|
|
62
|
+
### 手动触发
|
|
63
|
+
- 用户说 `/extract-memory` 或 "保存到记忆"
|
|
64
|
+
- 用户说 "记住这个" 或 "更新配置"
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 🔄 自动化流程
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
对话/操作 → 信息检测 → 分类 → 提取 → 存储 → 通知
|
|
72
|
+
↓ ↓ ↓ ↓ ↓ ↓
|
|
73
|
+
输入源 触发判断 类型识别 结构化 写入YAML 更新Agent
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Phase 1: 信息检测
|
|
77
|
+
|
|
78
|
+
**检测规则**(按优先级):
|
|
79
|
+
|
|
80
|
+
| 优先级 | 信息类型 | 检测信号 | 示例 |
|
|
81
|
+
|--------|----------|----------|------|
|
|
82
|
+
| P0 | 部署变更 | `deploy`, `vercel`, `wrangler`, URL 变化 | 新域名上线 |
|
|
83
|
+
| P0 | 服务配置 | `config`, `secret`, `token`, API 密钥 | 更新 VERCEL_TOKEN |
|
|
84
|
+
| P1 | 技术决策 | `决定`, `选择`, `采用`, 架构变更 | 选择 YAML 格式 |
|
|
85
|
+
| P1 | 项目里程碑 | `完成`, `上线`, `发布`, 版本号 | v1.0 发布 |
|
|
86
|
+
| P2 | 路径变更 | 目录创建/移动, 文件重组 | 创建 .memory/ |
|
|
87
|
+
| P2 | 工具配置 | CLI 安装, 依赖更新 | 安装 resumes-cli |
|
|
88
|
+
|
|
89
|
+
### Phase 2: 信息分类与路由
|
|
90
|
+
|
|
91
|
+
根据检测结果,**智能路由**到正确的存储系统:
|
|
92
|
+
|
|
93
|
+
#### 项目级 → `.memory/`
|
|
94
|
+
|
|
95
|
+
| 分类 | 目标文件 | 内容类型 |
|
|
96
|
+
|------|----------|----------|
|
|
97
|
+
| `project` | `.memory/project.yaml` | 项目常量、部署信息、路径 |
|
|
98
|
+
| `decisions` | `.memory/decisions.yaml` | 重要技术决策记录 |
|
|
99
|
+
| `changelog` | `.memory/changelog.yaml` | 变更历史 |
|
|
100
|
+
|
|
101
|
+
#### 用户级 → `openmemory`
|
|
102
|
+
|
|
103
|
+
| 分类 | MCP 工具 | 内容类型 |
|
|
104
|
+
|------|----------|----------|
|
|
105
|
+
| `preference` | `add_memories_openmemory` | 用户偏好、习惯 |
|
|
106
|
+
| `skill` | `add_memories_openmemory` | 用户技能、经验 |
|
|
107
|
+
| `context` | `add_memories_openmemory` | 对话上下文、历史 |
|
|
108
|
+
|
|
109
|
+
#### openmemory MCP 调用
|
|
110
|
+
|
|
111
|
+
**写入用户记忆**:
|
|
112
|
+
```
|
|
113
|
+
Tool: add_memories_openmemory
|
|
114
|
+
Parameter: text = "用户偏好: {提取的偏好信息}"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**搜索用户记忆**:
|
|
118
|
+
```
|
|
119
|
+
Tool: search_memory_openmemory
|
|
120
|
+
Parameter: query = "{搜索关键词}"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Phase 3: 结构化提取
|
|
124
|
+
|
|
125
|
+
**提取模板**:
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
# 部署变更
|
|
129
|
+
deployment:
|
|
130
|
+
{service_name}:
|
|
131
|
+
url: {new_url}
|
|
132
|
+
status: {active|pending|failed}
|
|
133
|
+
updated_at: {timestamp}
|
|
134
|
+
updated_by: {agent|user}
|
|
135
|
+
|
|
136
|
+
# 技术决策
|
|
137
|
+
decisions:
|
|
138
|
+
- id: {uuid}
|
|
139
|
+
date: {date}
|
|
140
|
+
title: {decision_title}
|
|
141
|
+
context: {why_this_decision}
|
|
142
|
+
choice: {what_was_chosen}
|
|
143
|
+
alternatives: [{other_options}]
|
|
144
|
+
impact: {affected_areas}
|
|
145
|
+
|
|
146
|
+
# 路径变更
|
|
147
|
+
paths:
|
|
148
|
+
{path_key}: {new_path}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Phase 4: 存储
|
|
152
|
+
|
|
153
|
+
**写入规则**:
|
|
154
|
+
1. 读取现有文件(如存在)
|
|
155
|
+
2. 合并新信息(不覆盖,追加/更新)
|
|
156
|
+
3. 保留注释和格式
|
|
157
|
+
4. 添加 `last_updated` 时间戳
|
|
158
|
+
|
|
159
|
+
**示例写入**:
|
|
160
|
+
```yaml
|
|
161
|
+
# .memory/project.yaml
|
|
162
|
+
deployment:
|
|
163
|
+
vercel:
|
|
164
|
+
url: https://web-zeta-six-79.vercel.app
|
|
165
|
+
status: active
|
|
166
|
+
updated_at: 2026-02-02T10:30:00Z # ← 自动更新
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Phase 5: 通知其他 Agent
|
|
170
|
+
|
|
171
|
+
更新完成后,在以下位置添加通知标记:
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
# .memory/project.yaml (底部)
|
|
175
|
+
_meta:
|
|
176
|
+
last_updated: 2026-02-02T10:30:00Z
|
|
177
|
+
updated_by: memory-extraction-skill
|
|
178
|
+
changes:
|
|
179
|
+
- "deployment.vercel.status: pending → active"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 输出格式
|
|
185
|
+
|
|
186
|
+
### `.memory/project.yaml` (主配置)
|
|
187
|
+
见现有文件结构,本 Skill 负责自动更新。
|
|
188
|
+
|
|
189
|
+
### `.memory/sessions/{date}.yaml` (会话记录)
|
|
190
|
+
```yaml
|
|
191
|
+
date: 2026-02-02
|
|
192
|
+
sessions:
|
|
193
|
+
- id: session-001
|
|
194
|
+
start: "10:00"
|
|
195
|
+
end: "11:30"
|
|
196
|
+
summary: "部署 Vercel 并配置 Cloudflare Worker"
|
|
197
|
+
key_actions:
|
|
198
|
+
- "更新 VERCEL_TOKEN GitHub Secret"
|
|
199
|
+
- "创建 .memory/ 目录结构"
|
|
200
|
+
decisions:
|
|
201
|
+
- "采用 YAML 格式作为 memory 存储格式"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### `.memory/decisions.yaml` (决策记录)
|
|
205
|
+
```yaml
|
|
206
|
+
decisions:
|
|
207
|
+
- id: dec-2026-02-02-001
|
|
208
|
+
date: 2026-02-02
|
|
209
|
+
title: "Memory 存储格式选择"
|
|
210
|
+
context: "需要跨 Agent 共享配置,支持多 IDE"
|
|
211
|
+
choice: "YAML 格式"
|
|
212
|
+
alternatives: ["JSON", "Markdown", "TOML"]
|
|
213
|
+
rationale: "人类可读 + 机器可解析 + 支持注释"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 与其他 Agent 的集成
|
|
219
|
+
|
|
220
|
+
### 读取方(其他 Agent)
|
|
221
|
+
|
|
222
|
+
其他 Agent 应在启动时读取 `.memory/project.yaml`:
|
|
223
|
+
|
|
224
|
+
```markdown
|
|
225
|
+
<!-- 在 CLAUDE.md 或 Agent 配置中 -->
|
|
226
|
+
> 📌 **配置中心**: 项目常量统一存储在 `.memory/project.yaml`
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 写入方(本 Skill)
|
|
230
|
+
|
|
231
|
+
本 Skill 是 `.memory/` 的唯一写入者,确保:
|
|
232
|
+
- 格式一致性
|
|
233
|
+
- 无冲突写入
|
|
234
|
+
- 变更可追溯
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 错误处理
|
|
239
|
+
|
|
240
|
+
### 写入失败场景
|
|
241
|
+
|
|
242
|
+
| 场景 | 处理策略 |
|
|
243
|
+
|------|----------|
|
|
244
|
+
| **YAML 语法错误** | 验证失败,不写入,通知用户修复 |
|
|
245
|
+
| **文件不存在** | 从模板创建新文件 |
|
|
246
|
+
| **权限拒绝** | 记录错误,跳过此次更新 |
|
|
247
|
+
| **Schema 验证失败** | 回滚到上一版本,输出差异 |
|
|
248
|
+
|
|
249
|
+
### 回退机制
|
|
250
|
+
|
|
251
|
+
1. **写入前备份**: 修改前复制到 `.memory/.backup/`
|
|
252
|
+
2. **原子写入**: 写入临时文件,验证后重命名
|
|
253
|
+
3. **错误日志**: 记录到 `.memory/sessions/{date}.yaml` 的 `errors` 字段
|
|
254
|
+
|
|
255
|
+
### 验证脚本
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# 验证所有 YAML 文件
|
|
259
|
+
.augment/skills/memory-extraction/scripts/validate.sh
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 触发条件详解
|
|
265
|
+
|
|
266
|
+
### 自动触发时机
|
|
267
|
+
|
|
268
|
+
| 触发信号 | 说明 | 示例 |
|
|
269
|
+
|----------|------|------|
|
|
270
|
+
| 用户结束对话 | 用户说 "bye", "结束", "exit", "谢谢" | `用户: 好的,先这样` |
|
|
271
|
+
| 部署完成 | 检测到 deploy/vercel/wrangler 输出 | `vercel --prod` 成功 |
|
|
272
|
+
| 配置变更 | 修改了 env/secret/config 文件 | 更新 `.env` |
|
|
273
|
+
| 创建新目录 | 创建了项目级目录 | `mkdir .memory/` |
|
|
274
|
+
| 重要决策 | 对话中明确了技术选型 | `决定使用 YAML 格式` |
|
|
275
|
+
|
|
276
|
+
### 不触发的场景
|
|
277
|
+
|
|
278
|
+
- 普通代码编辑(非配置文件)
|
|
279
|
+
- 读取操作(无写入)
|
|
280
|
+
- 临时文件操作
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 辅助资源
|
|
285
|
+
|
|
286
|
+
### 模板文件
|
|
287
|
+
|
|
288
|
+
- `templates/session.yaml.tmpl` - 新建会话模板
|
|
289
|
+
- `templates/decision.yaml.tmpl` - 新增决策模板
|
|
290
|
+
|
|
291
|
+
### Schema 验证
|
|
292
|
+
|
|
293
|
+
- `.memory/schema/project.schema.json`
|
|
294
|
+
- `.memory/schema/decisions.schema.json`
|
|
295
|
+
- `.memory/schema/session.schema.json`
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 执行检查清单
|
|
300
|
+
|
|
301
|
+
Agent 在对话结束前执行:
|
|
302
|
+
|
|
303
|
+
- [ ] 是否有部署状态变更?→ 更新 `deployment`
|
|
304
|
+
- [ ] 是否有新路径/目录?→ 更新 `paths`
|
|
305
|
+
- [ ] 是否有重要决策?→ 记录到 `decisions.yaml`
|
|
306
|
+
- [ ] 是否有配置变更?→ 更新对应字段
|
|
307
|
+
- [ ] 是否有用户偏好/技能?→ 存入 `openmemory`
|
|
308
|
+
- [ ] 更新 `_meta.last_updated`(使用精确 ISO 8601 时间戳)
|
|
309
|
+
- [ ] 运行 `validate.sh` 验证格式
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 冲突检测
|
|
314
|
+
|
|
315
|
+
Agent 在查询记忆时应检测两系统数据一致性:
|
|
316
|
+
|
|
317
|
+
### 检测时机
|
|
318
|
+
|
|
319
|
+
- 用户询问配置/部署信息时
|
|
320
|
+
- 执行 `/memory sync` 命令时
|
|
321
|
+
- 发现两系统返回不同结果时
|
|
322
|
+
|
|
323
|
+
### 检测逻辑
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
查询结果
|
|
327
|
+
↓
|
|
328
|
+
提取关键实体 (URL, 配置值, 技术选型)
|
|
329
|
+
↓
|
|
330
|
+
比对 .memory/ vs openmemory
|
|
331
|
+
↓
|
|
332
|
+
发现差异 → 提示用户确认
|
|
333
|
+
↓
|
|
334
|
+
用户选择 → 更新/删除过时记录
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### 冲突处理
|
|
338
|
+
|
|
339
|
+
| 场景 | 处理方式 |
|
|
340
|
+
|------|----------|
|
|
341
|
+
| URL 不一致 | 提示用户,优先 `.memory/` |
|
|
342
|
+
| 技术选型冲突 | 展示两边,请求决策 |
|
|
343
|
+
| 时间戳可判断 | 自动保留较新版本 |
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## 对话启动时自动加载
|
|
348
|
+
|
|
349
|
+
Agent 在对话开始时应**并行查询**两个系统:
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
对话开始
|
|
353
|
+
↓
|
|
354
|
+
┌─────────────────┐ ┌─────────────────┐
|
|
355
|
+
│ .memory/ │ │ openmemory │
|
|
356
|
+
│ (读取 YAML) │ │ (search_memory) │
|
|
357
|
+
└────────┬────────┘ └────────┬────────┘
|
|
358
|
+
│ │
|
|
359
|
+
└───────────┬───────────┘
|
|
360
|
+
↓
|
|
361
|
+
上下文融合
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**加载步骤**:
|
|
365
|
+
1. 读取 `.memory/project.yaml` 获取项目配置
|
|
366
|
+
2. 调用 `search_memory_openmemory` 查询相关用户记忆
|
|
367
|
+
3. 融合两边信息作为对话上下文
|
|
368
|
+
|
|
369
|
+
## 降级策略
|
|
370
|
+
|
|
371
|
+
**当 openmemory MCP 不可用时**:
|
|
372
|
+
|
|
373
|
+
1. 检测 MCP 连接状态(调用失败或超时)
|
|
374
|
+
2. 降级到仅 `.memory/` 存储
|
|
375
|
+
3. 用户级信息临时存入 `.memory/user-context.yaml`
|
|
376
|
+
4. 服务恢复后提示用户同步
|
|
377
|
+
|
|
378
|
+
```yaml
|
|
379
|
+
# .memory/user-context.yaml (降级时使用)
|
|
380
|
+
_degraded: true
|
|
381
|
+
_reason: "openmemory MCP unavailable"
|
|
382
|
+
pending_memories:
|
|
383
|
+
- text: "用户偏好: 使用中文"
|
|
384
|
+
created_at: 2026-02-02T10:30:00Z
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## 版本历史
|
|
388
|
+
|
|
389
|
+
| 版本 | 变更 |
|
|
390
|
+
|------|------|
|
|
391
|
+
| v2.0 | 双层记忆架构:整合 openmemory MCP,智能分类路由 |
|
|
392
|
+
| v1.1 | 添加错误处理、Schema 验证、模板文件、触发条件详解 |
|
|
393
|
+
| v1.0 | 初始版本:自动提取、YAML 存储、多 Agent 通知 |
|
|
394
|
+
|