openmemory-plus 1.2.0 → 1.2.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/dist/index.js +49 -50
- package/package.json +1 -1
- package/templates/augment/AGENTS.md +22 -15
- package/templates/claude/CLAUDE.md +15 -2
- package/templates/cursor/.cursorrules +57 -33
- package/templates/gemini/gemini.md +22 -15
- package/templates/shared/{commands → _omp/commands}/memory.md +3 -3
- package/templates/shared/{skills → _omp/skills}/memory-extraction/SKILL.md +92 -51
- package/templates/shared/_omp/skills/memory-extraction/scripts/validate.sh +94 -0
- package/templates/shared/_omp/skills/memory-extraction/templates/decision.yaml.tmpl +32 -0
- package/templates/shared/_omp/skills/memory-extraction/templates/session.yaml.tmpl +35 -0
- package/templates/shared/memory/activeContext.md +0 -34
- package/templates/shared/memory/productContext.md +0 -30
- package/templates/shared/memory/progress.md +0 -41
- package/templates/shared/memory/projectbrief.md +0 -36
- package/templates/shared/memory/systemPatterns.md +0 -39
- package/templates/shared/memory/techContext.md +0 -51
- package/templates/shared/rules/classification.md +0 -108
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/clean.md +0 -0
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/decay.md +0 -0
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/graph.md +0 -0
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/search.md +0 -0
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/status.md +0 -0
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/store.md +0 -0
- /package/templates/shared/{memory-actions → _omp/commands/memory-actions}/sync.md +0 -0
package/dist/index.js
CHANGED
|
@@ -107,17 +107,17 @@ async function checkAllDependencies() {
|
|
|
107
107
|
return { docker, ollama, qdrant, openmemory, bgeM3 };
|
|
108
108
|
}
|
|
109
109
|
function isSystemReady(status) {
|
|
110
|
-
return status.docker.installed && status.docker.running && status.ollama.installed && status.ollama.running && status.qdrant.running && status.bgeM3.installed;
|
|
110
|
+
return status.docker.installed === true && status.docker.running === true && status.ollama.installed === true && status.ollama.running === true && status.qdrant.running === true && status.bgeM3.installed === true;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// src/commands/install.ts
|
|
114
114
|
var execAsync2 = promisify2(exec2);
|
|
115
115
|
var IDE_CONFIGS = {
|
|
116
|
-
augment: { dir: ".augment", configFile: "AGENTS.md", commandsDir: "commands", skillsDir: "skills"
|
|
117
|
-
claude: { dir: ".", configFile: "CLAUDE.md", commandsDir: ".claude/commands", skillsDir: ".claude/skills"
|
|
118
|
-
cursor: { dir: ".cursor", configFile: ".cursorrules", commandsDir: "commands", skillsDir: "skills"
|
|
119
|
-
gemini: { dir: ".", configFile: "gemini.md", commandsDir: ".gemini/commands", skillsDir: ".gemini/skills"
|
|
120
|
-
common: { dir: ".", configFile: "AGENTS.md", commandsDir: ".agents/commands", skillsDir: ".agents/skills"
|
|
116
|
+
augment: { dir: ".augment", configFile: "AGENTS.md", commandsDir: "commands", skillsDir: "skills" },
|
|
117
|
+
claude: { dir: ".", configFile: "CLAUDE.md", commandsDir: ".claude/commands", skillsDir: ".claude/skills" },
|
|
118
|
+
cursor: { dir: ".cursor", configFile: ".cursorrules", commandsDir: "commands", skillsDir: "skills" },
|
|
119
|
+
gemini: { dir: ".", configFile: "gemini.md", commandsDir: ".gemini/commands", skillsDir: ".gemini/skills" },
|
|
120
|
+
common: { dir: ".", configFile: "AGENTS.md", commandsDir: ".agents/commands", skillsDir: ".agents/skills" }
|
|
121
121
|
};
|
|
122
122
|
var BANNER = `
|
|
123
123
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
@@ -202,15 +202,22 @@ function getTemplatesDir() {
|
|
|
202
202
|
return possiblePaths[0];
|
|
203
203
|
}
|
|
204
204
|
function copyDir(src, dest) {
|
|
205
|
-
if (!existsSync(src))
|
|
205
|
+
if (!existsSync(src)) {
|
|
206
|
+
console.warn(chalk.yellow(` \u26A0 \u6E90\u76EE\u5F55\u4E0D\u5B58\u5728: ${src}`));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
206
209
|
mkdirSync(dest, { recursive: true });
|
|
207
210
|
for (const file of readdirSync(src, { withFileTypes: true })) {
|
|
208
211
|
const srcPath = join(src, file.name);
|
|
209
212
|
const destPath = join(dest, file.name);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
try {
|
|
214
|
+
if (file.isDirectory()) {
|
|
215
|
+
copyDir(srcPath, destPath);
|
|
216
|
+
} else {
|
|
217
|
+
copyFileSync(srcPath, destPath);
|
|
218
|
+
}
|
|
219
|
+
} catch (err) {
|
|
220
|
+
console.warn(chalk.yellow(` \u26A0 \u590D\u5236\u5931\u8D25: ${srcPath}`));
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
223
|
}
|
|
@@ -224,7 +231,7 @@ project:
|
|
|
224
231
|
description: ""
|
|
225
232
|
|
|
226
233
|
memory:
|
|
227
|
-
project_store: "
|
|
234
|
+
project_store: "_omp/.memory/"
|
|
228
235
|
user_store: "openmemory"
|
|
229
236
|
|
|
230
237
|
classification:
|
|
@@ -373,49 +380,41 @@ async function phase2_initProject(options) {
|
|
|
373
380
|
}
|
|
374
381
|
const config = IDE_CONFIGS[ide];
|
|
375
382
|
console.log(chalk.bold("\n\u{1F4C1} \u521B\u5EFA\u914D\u7F6E\u6587\u4EF6...\n"));
|
|
376
|
-
const memoryDir = join(cwd, ".memory");
|
|
377
|
-
if (!existsSync(memoryDir)) {
|
|
378
|
-
mkdirSync(memoryDir, { recursive: true });
|
|
379
|
-
}
|
|
380
|
-
console.log(chalk.green(" \u2713 \u521B\u5EFA .memory/"));
|
|
381
|
-
const projectYaml = join(memoryDir, "project.yaml");
|
|
382
|
-
writeFileSync(projectYaml, generateProjectYaml(projectName));
|
|
383
|
-
console.log(chalk.green(" \u2713 \u521B\u5EFA .memory/project.yaml"));
|
|
384
383
|
const templatesDir = getTemplatesDir();
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
384
|
+
const ompTemplates = join(templatesDir, "shared", "_omp");
|
|
385
|
+
const ideTemplates = join(templatesDir, ide === "common" ? "common" : ide);
|
|
386
|
+
const ompDir = join(cwd, "_omp");
|
|
387
|
+
mkdirSync(ompDir, { recursive: true });
|
|
388
|
+
copyDir(ompTemplates, ompDir);
|
|
389
|
+
console.log(chalk.green(" \u2713 \u521B\u5EFA _omp/ (\u6838\u5FC3\u76EE\u5F55)"));
|
|
390
|
+
const ompMemoryDir = join(ompDir, ".memory");
|
|
391
|
+
mkdirSync(ompMemoryDir, { recursive: true });
|
|
392
|
+
if (existsSync(ompMemoryDir)) {
|
|
393
|
+
const memoryFiles = readdirSync(ompMemoryDir);
|
|
388
394
|
for (const file of memoryFiles) {
|
|
389
|
-
const
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
writeFileSync(destPath, processTemplate(content, projectName));
|
|
395
|
+
const filePath = join(ompMemoryDir, file);
|
|
396
|
+
const content = readFileSync(filePath, "utf-8");
|
|
397
|
+
writeFileSync(filePath, processTemplate(content, projectName));
|
|
393
398
|
}
|
|
394
|
-
console.log(chalk.green(` \u2713 \u521B\u5EFA .memory/ (${memoryFiles.length} \u4E2A\u6838\u5FC3\u6587\u4EF6)`));
|
|
395
399
|
}
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
console.log(chalk.green(` \u2713 \u521B\u5EFA ${
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
console.log(chalk.green(` \u2713 \u521B\u5EFA ${config.dir}/${config.skillsDir}/ (memory-extraction)`));
|
|
413
|
-
const rulesDir = join(cwd, config.rulesDir);
|
|
414
|
-
mkdirSync(rulesDir, { recursive: true });
|
|
415
|
-
copyDir(join(sharedTemplates, "rules"), rulesDir);
|
|
416
|
-
console.log(chalk.green(` \u2713 \u521B\u5EFA ${config.rulesDir}/ (classification.md)`));
|
|
400
|
+
const projectYaml = join(ompMemoryDir, "project.yaml");
|
|
401
|
+
writeFileSync(projectYaml, generateProjectYaml(projectName));
|
|
402
|
+
console.log(chalk.green(" \u2713 \u521B\u5EFA _omp/.memory/project.yaml"));
|
|
403
|
+
const commandsCount = existsSync(join(ompDir, "commands")) ? readdirSync(join(ompDir, "commands")).filter((f) => f.endsWith(".md")).length : 0;
|
|
404
|
+
const actionsCount = existsSync(join(ompDir, "commands", "memory-actions")) ? readdirSync(join(ompDir, "commands", "memory-actions")).length : 0;
|
|
405
|
+
console.log(chalk.green(` \u2713 \u521B\u5EFA _omp/commands/ (${commandsCount} \u547D\u4EE4, ${actionsCount} \u5B50\u52A8\u4F5C)`));
|
|
406
|
+
console.log(chalk.green(" \u2713 \u521B\u5EFA _omp/skills/ (memory-extraction)"));
|
|
407
|
+
const ideDir = join(cwd, config.dir);
|
|
408
|
+
const ideCommandsDir = join(cwd, config.dir, config.commandsDir);
|
|
409
|
+
mkdirSync(ideCommandsDir, { recursive: true });
|
|
410
|
+
copyDir(join(ompDir, "commands"), ideCommandsDir);
|
|
411
|
+
console.log(chalk.green(` \u2713 \u590D\u5236\u5230 ${config.dir}/${config.commandsDir}/`));
|
|
412
|
+
const ideSkillsDir = join(cwd, config.dir, config.skillsDir);
|
|
413
|
+
mkdirSync(ideSkillsDir, { recursive: true });
|
|
414
|
+
copyDir(join(ompDir, "skills"), ideSkillsDir);
|
|
415
|
+
console.log(chalk.green(` \u2713 \u590D\u5236\u5230 ${config.dir}/${config.skillsDir}/`));
|
|
417
416
|
if (existsSync(ideTemplates)) {
|
|
418
|
-
copyDir(ideTemplates,
|
|
417
|
+
copyDir(ideTemplates, ideDir);
|
|
419
418
|
console.log(chalk.green(` \u2713 \u590D\u5236 ${config.configFile}`));
|
|
420
419
|
}
|
|
421
420
|
return ide;
|
package/package.json
CHANGED
|
@@ -26,31 +26,38 @@
|
|
|
26
26
|
- 输入 `2` 或 "搜索部署配置"
|
|
27
27
|
- 输入 `4` 或 "清理过期的记忆"
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## 核心目录
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
|
|
33
|
-
├──
|
|
34
|
-
│ ├──
|
|
35
|
-
│
|
|
36
|
-
|
|
37
|
-
└──
|
|
38
|
-
|
|
39
|
-
├──
|
|
40
|
-
└──
|
|
32
|
+
_omp/ # OpenMemory Plus 核心目录
|
|
33
|
+
├── commands/
|
|
34
|
+
│ ├── memory.md # 主命令入口
|
|
35
|
+
│ └── memory-actions/ # 7 个子动作
|
|
36
|
+
├── skills/
|
|
37
|
+
│ └── memory-extraction/ # 自动提取 Skill
|
|
38
|
+
└── .memory/ # 项目级记忆
|
|
39
|
+
├── project.yaml # 项目配置 (SSOT)
|
|
40
|
+
└── *.md # 上下文文件
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
## 双层记忆架构
|
|
44
|
+
|
|
45
|
+
| 系统 | 存储位置 | 用途 |
|
|
46
|
+
|------|----------|------|
|
|
47
|
+
| 项目级 | `_omp/.memory/` | 项目配置、技术决策、变更记录 |
|
|
48
|
+
| 用户级 | `openmemory` MCP | 用户偏好、技能、跨项目上下文 |
|
|
49
|
+
|
|
43
50
|
## 自动行为
|
|
44
51
|
|
|
45
52
|
### 对话开始时
|
|
46
53
|
1. 搜索 `openmemory` 获取用户上下文
|
|
47
|
-
2. 加载
|
|
54
|
+
2. 加载 `_omp/.memory/project.yaml` 获取项目配置
|
|
48
55
|
3. 融合上下文提供个性化响应
|
|
49
56
|
|
|
50
57
|
### 对话结束时
|
|
51
58
|
1. 检测有价值信息
|
|
52
59
|
2. 按分类规则路由存储
|
|
53
|
-
3. 项目级 →
|
|
60
|
+
3. 项目级 → `_omp/.memory/`
|
|
54
61
|
4. 用户级 → `openmemory`
|
|
55
62
|
|
|
56
63
|
## MCP 工具
|
|
@@ -66,12 +73,12 @@ Agent 记忆系统
|
|
|
66
73
|
|
|
67
74
|
| 信息类型 | 存储位置 | 示例 |
|
|
68
75
|
|----------|----------|------|
|
|
69
|
-
| 项目配置 |
|
|
70
|
-
| 技术决策 |
|
|
76
|
+
| 项目配置 | `_omp/.memory/` | 部署 URL、路径 |
|
|
77
|
+
| 技术决策 | `_omp/.memory/` | 框架选择、架构 |
|
|
71
78
|
| 用户偏好 | `openmemory` | 语言、风格 |
|
|
72
79
|
| 用户技能 | `openmemory` | 熟悉的技术栈 |
|
|
73
80
|
|
|
74
|
-
详细规则见 `.
|
|
81
|
+
详细规则见 `.augment/skills/memory-extraction/SKILL.md`
|
|
75
82
|
|
|
76
83
|
---
|
|
77
84
|
*由 OpenMemory Plus CLI 生成 | https://github.com/Alenryuichi/openmemory-plus*
|
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
本项目已启用 OpenMemory Plus 双层记忆管理。
|
|
6
6
|
|
|
7
|
+
### 核心目录
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
_omp/ # OpenMemory Plus 核心目录
|
|
11
|
+
├── commands/
|
|
12
|
+
│ ├── memory.md # 主命令入口
|
|
13
|
+
│ └── memory-actions/ # 7 个子动作
|
|
14
|
+
├── skills/
|
|
15
|
+
│ └── memory-extraction/ # 自动提取 Skill
|
|
16
|
+
└── .memory/ # 项目级记忆
|
|
17
|
+
└── project.yaml # 项目配置 (SSOT)
|
|
18
|
+
```
|
|
19
|
+
|
|
7
20
|
### 命令入口
|
|
8
21
|
|
|
9
22
|
**只需记住一个命令:**
|
|
@@ -28,7 +41,7 @@
|
|
|
28
41
|
|
|
29
42
|
| 系统 | 存储位置 | 用途 |
|
|
30
43
|
|------|----------|------|
|
|
31
|
-
| 项目级 |
|
|
44
|
+
| 项目级 | `_omp/.memory/` | 项目配置、技术决策、变更记录 |
|
|
32
45
|
| 用户级 | `openmemory` MCP | 用户偏好、技能、跨项目上下文 |
|
|
33
46
|
|
|
34
47
|
### 自动提取 (Memory Extraction)
|
|
@@ -36,7 +49,7 @@
|
|
|
36
49
|
对话结束时自动执行:
|
|
37
50
|
1. 检测有价值信息
|
|
38
51
|
2. 智能分类路由
|
|
39
|
-
3. 项目级 →
|
|
52
|
+
3. 项目级 → `_omp/.memory/`
|
|
40
53
|
4. 用户级 → `openmemory`
|
|
41
54
|
|
|
42
55
|
### MCP 工具
|
|
@@ -2,56 +2,80 @@
|
|
|
2
2
|
|
|
3
3
|
本项目已启用 OpenMemory Plus 双层记忆管理系统。
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
## 快速使用
|
|
6
|
+
|
|
7
|
+
**只需记住一个命令:**
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
/memory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
输入后会显示菜单,选择数字或用自然语言描述需求:
|
|
14
|
+
|
|
15
|
+
| 选项 | 说明 |
|
|
16
|
+
|------|------|
|
|
17
|
+
| 1 | 📋 查看状态 - 详细记忆状态 |
|
|
18
|
+
| 2 | 🔍 搜索记忆 - 语义搜索 |
|
|
19
|
+
| 3 | 💾 存储记忆 - 手动添加 |
|
|
20
|
+
| 4 | 🧹 清理记忆 - 清理 ROT |
|
|
21
|
+
| 5 | 🔄 同步检查 - 冲突检测 |
|
|
22
|
+
| 6 | ⏰ 衰减分析 - 时间衰减 |
|
|
23
|
+
| 7 | 🔗 知识图谱 - 实体关系 |
|
|
24
|
+
|
|
25
|
+
## 核心目录
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
_omp/ # OpenMemory Plus 核心目录
|
|
29
|
+
├── commands/
|
|
30
|
+
│ ├── memory.md # 主命令入口
|
|
31
|
+
│ └── memory-actions/ # 7 个子动作
|
|
32
|
+
├── skills/
|
|
33
|
+
│ └── memory-extraction/ # 自动提取 Skill
|
|
34
|
+
└── .memory/ # 项目级记忆
|
|
35
|
+
├── project.yaml # 项目配置 (SSOT)
|
|
36
|
+
└── *.md # 上下文文件
|
|
37
|
+
```
|
|
13
38
|
|
|
14
39
|
## 双层记忆架构
|
|
15
40
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
用户级 (openmemory MCP):
|
|
22
|
-
- 用户偏好 - 跨项目通用
|
|
23
|
-
- 用户技能 - 个人能力
|
|
24
|
-
- 对话上下文 - 历史记忆
|
|
41
|
+
| 系统 | 存储位置 | 用途 |
|
|
42
|
+
|------|----------|------|
|
|
43
|
+
| 项目级 | `_omp/.memory/` | 项目配置、技术决策、变更记录 |
|
|
44
|
+
| 用户级 | `openmemory` MCP | 用户偏好、技能、跨项目上下文 |
|
|
25
45
|
|
|
26
46
|
## 自动行为
|
|
27
47
|
|
|
28
|
-
|
|
29
|
-
1. 搜索 openmemory 获取用户上下文
|
|
30
|
-
2. 加载
|
|
48
|
+
### 对话开始时
|
|
49
|
+
1. 搜索 `openmemory` 获取用户上下文
|
|
50
|
+
2. 加载 `_omp/.memory/project.yaml` 获取项目配置
|
|
31
51
|
3. 融合上下文提供个性化响应
|
|
32
52
|
|
|
33
|
-
|
|
53
|
+
### 对话结束时
|
|
34
54
|
1. 检测有价值信息
|
|
35
55
|
2. 按分类规则路由存储
|
|
36
|
-
3. 项目级 →
|
|
37
|
-
4. 用户级 → openmemory
|
|
56
|
+
3. 项目级 → `_omp/.memory/`
|
|
57
|
+
4. 用户级 → `openmemory`
|
|
38
58
|
|
|
39
59
|
## MCP 工具
|
|
40
60
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
| 工具 | 用途 |
|
|
62
|
+
|------|------|
|
|
63
|
+
| `add_memories_openmemory` | 添加用户级记忆 |
|
|
64
|
+
| `search_memory_openmemory` | 语义搜索记忆 |
|
|
65
|
+
| `list_memories_openmemory` | 列出所有记忆 |
|
|
66
|
+
| `delete_memories_openmemory` | 删除指定记忆 |
|
|
45
67
|
|
|
46
68
|
## 分类规则
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
| 信息类型 | 存储位置 | 示例 |
|
|
71
|
+
|----------|----------|------|
|
|
72
|
+
| 项目配置 | `_omp/.memory/` | 部署 URL、路径 |
|
|
73
|
+
| 技术决策 | `_omp/.memory/` | 框架选择、架构 |
|
|
74
|
+
| 用户偏好 | `openmemory` | 语言、风格 |
|
|
75
|
+
| 用户技能 | `openmemory` | 熟悉的技术栈 |
|
|
52
76
|
|
|
53
|
-
详细规则见
|
|
77
|
+
详细规则见 `.cursor/skills/memory-extraction/SKILL.md`
|
|
54
78
|
|
|
55
79
|
---
|
|
56
|
-
|
|
80
|
+
*由 OpenMemory Plus CLI 生成 | https://github.com/Alenryuichi/openmemory-plus*
|
|
57
81
|
|
|
@@ -26,31 +26,38 @@
|
|
|
26
26
|
- 输入 `2` 或 "搜索部署配置"
|
|
27
27
|
- 输入 `4` 或 "清理过期的记忆"
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## 核心目录
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
|
|
33
|
-
├──
|
|
34
|
-
│ ├──
|
|
35
|
-
│
|
|
36
|
-
|
|
37
|
-
└──
|
|
38
|
-
|
|
39
|
-
├──
|
|
40
|
-
└──
|
|
32
|
+
_omp/ # OpenMemory Plus 核心目录
|
|
33
|
+
├── commands/
|
|
34
|
+
│ ├── memory.md # 主命令入口
|
|
35
|
+
│ └── memory-actions/ # 7 个子动作
|
|
36
|
+
├── skills/
|
|
37
|
+
│ └── memory-extraction/ # 自动提取 Skill
|
|
38
|
+
└── .memory/ # 项目级记忆
|
|
39
|
+
├── project.yaml # 项目配置 (SSOT)
|
|
40
|
+
└── *.md # 上下文文件
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
## 双层记忆架构
|
|
44
|
+
|
|
45
|
+
| 系统 | 存储位置 | 用途 |
|
|
46
|
+
|------|----------|------|
|
|
47
|
+
| 项目级 | `_omp/.memory/` | 项目配置、技术决策、变更记录 |
|
|
48
|
+
| 用户级 | `openmemory` MCP | 用户偏好、技能、跨项目上下文 |
|
|
49
|
+
|
|
43
50
|
## 自动行为
|
|
44
51
|
|
|
45
52
|
### 对话开始时
|
|
46
53
|
1. 搜索 `openmemory` 获取用户上下文
|
|
47
|
-
2. 加载
|
|
54
|
+
2. 加载 `_omp/.memory/project.yaml` 获取项目配置
|
|
48
55
|
3. 融合上下文提供个性化响应
|
|
49
56
|
|
|
50
57
|
### 对话结束时
|
|
51
58
|
1. 检测有价值信息
|
|
52
59
|
2. 按分类规则路由存储
|
|
53
|
-
3. 项目级 →
|
|
60
|
+
3. 项目级 → `_omp/.memory/`
|
|
54
61
|
4. 用户级 → `openmemory`
|
|
55
62
|
|
|
56
63
|
## MCP 工具
|
|
@@ -66,12 +73,12 @@ Agent 记忆系统
|
|
|
66
73
|
|
|
67
74
|
| 信息类型 | 存储位置 | 示例 |
|
|
68
75
|
|----------|----------|------|
|
|
69
|
-
| 项目配置 |
|
|
70
|
-
| 技术决策 |
|
|
76
|
+
| 项目配置 | `_omp/.memory/` | 部署 URL、路径 |
|
|
77
|
+
| 技术决策 | `_omp/.memory/` | 框架选择、架构 |
|
|
71
78
|
| 用户偏好 | `openmemory` | 语言、风格 |
|
|
72
79
|
| 用户技能 | `openmemory` | 熟悉的技术栈 |
|
|
73
80
|
|
|
74
|
-
详细规则见 `.
|
|
81
|
+
详细规则见 `.gemini/skills/memory-extraction/SKILL.md`
|
|
75
82
|
|
|
76
83
|
---
|
|
77
84
|
*由 OpenMemory Plus CLI 生成 | https://github.com/Alenryuichi/openmemory-plus*
|
|
@@ -11,7 +11,7 @@ OpenMemory Plus 记忆管理统一入口。
|
|
|
11
11
|
当用户输入 `/memory` 时:
|
|
12
12
|
|
|
13
13
|
1. **快速状态检测**
|
|
14
|
-
- 读取
|
|
14
|
+
- 读取 `_omp/.memory/` 目录状态
|
|
15
15
|
- 调用 `list_memories_openmemory` 获取用户记忆数量
|
|
16
16
|
|
|
17
17
|
2. **显示菜单**
|
|
@@ -20,7 +20,7 @@ OpenMemory Plus 记忆管理统一入口。
|
|
|
20
20
|
📊 记忆管理系统
|
|
21
21
|
|
|
22
22
|
当前状态快览:
|
|
23
|
-
├── 项目级 (
|
|
23
|
+
├── 项目级 (_omp/.memory/): {n} 个文件
|
|
24
24
|
└── 用户级 (openmemory): {n} 条记忆
|
|
25
25
|
|
|
26
26
|
选择操作:
|
|
@@ -74,7 +74,7 @@ Agent 可使用以下工具:
|
|
|
74
74
|
|
|
75
75
|
## 项目级记忆
|
|
76
76
|
|
|
77
|
-
直接读写
|
|
77
|
+
直接读写 `_omp/.memory/` 目录下的 YAML 文件:
|
|
78
78
|
|
|
79
79
|
- `project.yaml` - 项目配置
|
|
80
80
|
- `decisions.yaml` - 技术决策
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
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
|
|
3
|
+
description: Agent-only workflow for extracting key information from conversations, code changes, and deployments into structured memory files. Automatically updates `_omp/.memory/` directory and notifies other agents. Triggered automatically at conversation end or when valuable information is detected.
|
|
4
4
|
metadata:
|
|
5
5
|
author: Wendy (Workflow Builder)
|
|
6
|
-
version: "2.
|
|
6
|
+
version: "2.1"
|
|
7
7
|
language: zh-CN
|
|
8
8
|
audience: agent-only
|
|
9
9
|
---
|
|
@@ -13,41 +13,81 @@ metadata:
|
|
|
13
13
|
## 目的
|
|
14
14
|
|
|
15
15
|
**自动提取对话中的关键信息**,智能路由到正确的存储系统:
|
|
16
|
-
- **项目级信息** →
|
|
16
|
+
- **项目级信息** → `_omp/.memory/` 目录 (Git 版本控制)
|
|
17
17
|
- **用户级信息** → `openmemory` MCP (跨项目共享)
|
|
18
18
|
|
|
19
19
|
> **Agent-Only 原则**:
|
|
20
20
|
> - **自动触发**:对话结束时或检测到有价值信息时自动运行
|
|
21
21
|
> - **智能分类**:根据信息类型自动选择存储位置
|
|
22
22
|
> - **零人工干预**:无需用户确认,静默执行
|
|
23
|
-
> - **双系统同步**:同时管理
|
|
23
|
+
> - **双系统同步**:同时管理 `_omp/.memory/` 和 `openmemory`
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## 核心目录结构
|
|
26
26
|
|
|
27
27
|
```
|
|
28
|
-
|
|
29
|
-
├──
|
|
30
|
-
│ ├──
|
|
31
|
-
│
|
|
32
|
-
|
|
33
|
-
└──
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
_omp/ # OpenMemory Plus 核心目录
|
|
29
|
+
├── commands/
|
|
30
|
+
│ ├── memory.md # 主命令入口
|
|
31
|
+
│ └── memory-actions/ # 7 个子动作
|
|
32
|
+
├── skills/
|
|
33
|
+
│ └── memory-extraction/ # 本 Skill
|
|
34
|
+
│ ├── SKILL.md
|
|
35
|
+
│ ├── scripts/validate.sh
|
|
36
|
+
│ └── templates/*.tmpl
|
|
37
|
+
└── .memory/ # 项目级记忆
|
|
38
|
+
├── project.yaml # 项目配置 (SSOT)
|
|
39
|
+
├── decisions.yaml # 技术决策记录
|
|
40
|
+
├── changelog.yaml # 变更历史
|
|
41
|
+
└── sessions/ # 会话记录
|
|
37
42
|
```
|
|
38
43
|
|
|
44
|
+
## 双层记忆架构
|
|
45
|
+
|
|
46
|
+
| 系统 | 存储位置 | 用途 |
|
|
47
|
+
|------|----------|------|
|
|
48
|
+
| 项目级 | `_omp/.memory/` | 项目配置、技术决策、变更记录 |
|
|
49
|
+
| 用户级 | `openmemory` MCP | 用户偏好、技能、跨项目上下文 |
|
|
50
|
+
|
|
39
51
|
## 分类规则
|
|
40
52
|
|
|
41
|
-
|
|
53
|
+
### 存储位置决策表
|
|
54
|
+
|
|
55
|
+
| 信息类型 | 存储位置 | 识别关键词 |
|
|
56
|
+
|----------|----------|------------|
|
|
57
|
+
| 项目配置 | `_omp/.memory/project.yaml` | url, domain, deploy, vercel, config, path |
|
|
58
|
+
| 技术决策 | `_omp/.memory/decisions.yaml` | 决定, 选择, 采用, 架构, decision, choose |
|
|
59
|
+
| 变更记录 | `_omp/.memory/changelog.yaml` | 更新, 修改, 发布, update, change, release |
|
|
60
|
+
| 用户偏好 | `openmemory` | 偏好, 喜欢, 习惯, prefer, style, always |
|
|
61
|
+
| 用户技能 | `openmemory` | 会, 熟悉, 经验, skill, experience, know |
|
|
62
|
+
| 对话上下文 | `openmemory` | 之前, 上次, 记得, remember, last time |
|
|
63
|
+
|
|
64
|
+
### 分类优先级
|
|
65
|
+
|
|
66
|
+
1. **项目相关** → `_omp/.memory/` (Git 版本控制)
|
|
67
|
+
2. **用户相关** → `openmemory` (跨项目共享)
|
|
68
|
+
3. **混合信息** → 拆分存储到两个系统
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
|
48
|
-
|
|
49
|
-
|
|
|
50
|
-
|
|
|
70
|
+
### 敏感信息过滤
|
|
71
|
+
|
|
72
|
+
**禁止存储**(检测后阻止):
|
|
73
|
+
|
|
74
|
+
| 类型 | 检测模式 |
|
|
75
|
+
|------|----------|
|
|
76
|
+
| API Key | `sk-`, `api_key`, `token=`, `bearer` |
|
|
77
|
+
| 密码 | `password`, `secret`, `credential` |
|
|
78
|
+
| 私钥 | `-----BEGIN`, `PRIVATE KEY` |
|
|
79
|
+
| 个人信息 | 身份证号, 银行卡号, 手机号 |
|
|
80
|
+
|
|
81
|
+
### ROT 过滤规则
|
|
82
|
+
|
|
83
|
+
**不存储的信息**:
|
|
84
|
+
|
|
85
|
+
| 类型 | 示例 |
|
|
86
|
+
|------|------|
|
|
87
|
+
| 琐碎确认 | "好的", "OK", "明白了" |
|
|
88
|
+
| 临时状态 | "正在处理...", "稍等" |
|
|
89
|
+
| 重复信息 | 已存在的相同内容 |
|
|
90
|
+
| 过期信息 | 被明确否定或更新的旧信息 |
|
|
51
91
|
|
|
52
92
|
## 触发条件
|
|
53
93
|
|
|
@@ -83,20 +123,20 @@ Agent 记忆系统
|
|
|
83
123
|
| P0 | 服务配置 | `config`, `secret`, `token`, API 密钥 | 更新 VERCEL_TOKEN |
|
|
84
124
|
| P1 | 技术决策 | `决定`, `选择`, `采用`, 架构变更 | 选择 YAML 格式 |
|
|
85
125
|
| P1 | 项目里程碑 | `完成`, `上线`, `发布`, 版本号 | v1.0 发布 |
|
|
86
|
-
| P2 | 路径变更 | 目录创建/移动, 文件重组 | 创建
|
|
126
|
+
| P2 | 路径变更 | 目录创建/移动, 文件重组 | 创建 _omp/.memory/ |
|
|
87
127
|
| P2 | 工具配置 | CLI 安装, 依赖更新 | 安装 resumes-cli |
|
|
88
128
|
|
|
89
129
|
### Phase 2: 信息分类与路由
|
|
90
130
|
|
|
91
131
|
根据检测结果,**智能路由**到正确的存储系统:
|
|
92
132
|
|
|
93
|
-
#### 项目级 →
|
|
133
|
+
#### 项目级 → `_omp/.memory/`
|
|
94
134
|
|
|
95
135
|
| 分类 | 目标文件 | 内容类型 |
|
|
96
136
|
|------|----------|----------|
|
|
97
|
-
| `project` |
|
|
98
|
-
| `decisions` |
|
|
99
|
-
| `changelog` |
|
|
137
|
+
| `project` | `_omp/.memory/project.yaml` | 项目常量、部署信息、路径 |
|
|
138
|
+
| `decisions` | `_omp/.memory/decisions.yaml` | 重要技术决策记录 |
|
|
139
|
+
| `changelog` | `_omp/.memory/changelog.yaml` | 变更历史 |
|
|
100
140
|
|
|
101
141
|
#### 用户级 → `openmemory`
|
|
102
142
|
|
|
@@ -158,7 +198,7 @@ paths:
|
|
|
158
198
|
|
|
159
199
|
**示例写入**:
|
|
160
200
|
```yaml
|
|
161
|
-
#
|
|
201
|
+
# _omp/.memory/project.yaml
|
|
162
202
|
deployment:
|
|
163
203
|
vercel:
|
|
164
204
|
url: https://web-zeta-six-79.vercel.app
|
|
@@ -171,7 +211,7 @@ deployment:
|
|
|
171
211
|
更新完成后,在以下位置添加通知标记:
|
|
172
212
|
|
|
173
213
|
```yaml
|
|
174
|
-
#
|
|
214
|
+
# _omp/.memory/project.yaml (底部)
|
|
175
215
|
_meta:
|
|
176
216
|
last_updated: 2026-02-02T10:30:00Z
|
|
177
217
|
updated_by: memory-extraction-skill
|
|
@@ -183,10 +223,10 @@ _meta:
|
|
|
183
223
|
|
|
184
224
|
## 输出格式
|
|
185
225
|
|
|
186
|
-
###
|
|
226
|
+
### `_omp/.memory/project.yaml` (主配置)
|
|
187
227
|
见现有文件结构,本 Skill 负责自动更新。
|
|
188
228
|
|
|
189
|
-
###
|
|
229
|
+
### `_omp/.memory/sessions/{date}.yaml` (会话记录)
|
|
190
230
|
```yaml
|
|
191
231
|
date: 2026-02-02
|
|
192
232
|
sessions:
|
|
@@ -196,12 +236,12 @@ sessions:
|
|
|
196
236
|
summary: "部署 Vercel 并配置 Cloudflare Worker"
|
|
197
237
|
key_actions:
|
|
198
238
|
- "更新 VERCEL_TOKEN GitHub Secret"
|
|
199
|
-
- "创建
|
|
239
|
+
- "创建 _omp/.memory/ 目录结构"
|
|
200
240
|
decisions:
|
|
201
241
|
- "采用 YAML 格式作为 memory 存储格式"
|
|
202
242
|
```
|
|
203
243
|
|
|
204
|
-
###
|
|
244
|
+
### `_omp/.memory/decisions.yaml` (决策记录)
|
|
205
245
|
```yaml
|
|
206
246
|
decisions:
|
|
207
247
|
- id: dec-2026-02-02-001
|
|
@@ -219,16 +259,16 @@ decisions:
|
|
|
219
259
|
|
|
220
260
|
### 读取方(其他 Agent)
|
|
221
261
|
|
|
222
|
-
其他 Agent 应在启动时读取
|
|
262
|
+
其他 Agent 应在启动时读取 `_omp/.memory/project.yaml`:
|
|
223
263
|
|
|
224
264
|
```markdown
|
|
225
265
|
<!-- 在 CLAUDE.md 或 Agent 配置中 -->
|
|
226
|
-
> 📌 **配置中心**: 项目常量统一存储在
|
|
266
|
+
> 📌 **配置中心**: 项目常量统一存储在 `_omp/.memory/project.yaml`
|
|
227
267
|
```
|
|
228
268
|
|
|
229
269
|
### 写入方(本 Skill)
|
|
230
270
|
|
|
231
|
-
本 Skill 是
|
|
271
|
+
本 Skill 是 `_omp/.memory/` 的唯一写入者,确保:
|
|
232
272
|
- 格式一致性
|
|
233
273
|
- 无冲突写入
|
|
234
274
|
- 变更可追溯
|
|
@@ -248,15 +288,15 @@ decisions:
|
|
|
248
288
|
|
|
249
289
|
### 回退机制
|
|
250
290
|
|
|
251
|
-
1. **写入前备份**: 修改前复制到
|
|
291
|
+
1. **写入前备份**: 修改前复制到 `_omp/.memory/.backup/`
|
|
252
292
|
2. **原子写入**: 写入临时文件,验证后重命名
|
|
253
|
-
3. **错误日志**: 记录到
|
|
293
|
+
3. **错误日志**: 记录到 `_omp/.memory/sessions/{date}.yaml` 的 `errors` 字段
|
|
254
294
|
|
|
255
295
|
### 验证脚本
|
|
256
296
|
|
|
257
297
|
```bash
|
|
258
298
|
# 验证所有 YAML 文件
|
|
259
|
-
|
|
299
|
+
_omp/skills/memory-extraction/scripts/validate.sh
|
|
260
300
|
```
|
|
261
301
|
|
|
262
302
|
---
|
|
@@ -270,7 +310,7 @@ decisions:
|
|
|
270
310
|
| 用户结束对话 | 用户说 "bye", "结束", "exit", "谢谢" | `用户: 好的,先这样` |
|
|
271
311
|
| 部署完成 | 检测到 deploy/vercel/wrangler 输出 | `vercel --prod` 成功 |
|
|
272
312
|
| 配置变更 | 修改了 env/secret/config 文件 | 更新 `.env` |
|
|
273
|
-
| 创建新目录 | 创建了项目级目录 | `mkdir
|
|
313
|
+
| 创建新目录 | 创建了项目级目录 | `mkdir _omp/.memory/` |
|
|
274
314
|
| 重要决策 | 对话中明确了技术选型 | `决定使用 YAML 格式` |
|
|
275
315
|
|
|
276
316
|
### 不触发的场景
|
|
@@ -290,9 +330,9 @@ decisions:
|
|
|
290
330
|
|
|
291
331
|
### Schema 验证
|
|
292
332
|
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
333
|
+
- `_omp/.memory/schema/project.schema.json`
|
|
334
|
+
- `_omp/.memory/schema/decisions.schema.json`
|
|
335
|
+
- `_omp/.memory/schema/session.schema.json`
|
|
296
336
|
|
|
297
337
|
---
|
|
298
338
|
|
|
@@ -327,7 +367,7 @@ Agent 在查询记忆时应检测两系统数据一致性:
|
|
|
327
367
|
↓
|
|
328
368
|
提取关键实体 (URL, 配置值, 技术选型)
|
|
329
369
|
↓
|
|
330
|
-
比对
|
|
370
|
+
比对 _omp/.memory/ vs openmemory
|
|
331
371
|
↓
|
|
332
372
|
发现差异 → 提示用户确认
|
|
333
373
|
↓
|
|
@@ -338,7 +378,7 @@ Agent 在查询记忆时应检测两系统数据一致性:
|
|
|
338
378
|
|
|
339
379
|
| 场景 | 处理方式 |
|
|
340
380
|
|------|----------|
|
|
341
|
-
| URL 不一致 | 提示用户,优先
|
|
381
|
+
| URL 不一致 | 提示用户,优先 `_omp/.memory/` |
|
|
342
382
|
| 技术选型冲突 | 展示两边,请求决策 |
|
|
343
383
|
| 时间戳可判断 | 自动保留较新版本 |
|
|
344
384
|
|
|
@@ -352,7 +392,7 @@ Agent 在对话开始时应**并行查询**两个系统:
|
|
|
352
392
|
对话开始
|
|
353
393
|
↓
|
|
354
394
|
┌─────────────────┐ ┌─────────────────┐
|
|
355
|
-
│
|
|
395
|
+
│ _omp/.memory/ │ │ openmemory │
|
|
356
396
|
│ (读取 YAML) │ │ (search_memory) │
|
|
357
397
|
└────────┬────────┘ └────────┬────────┘
|
|
358
398
|
│ │
|
|
@@ -362,7 +402,7 @@ Agent 在对话开始时应**并行查询**两个系统:
|
|
|
362
402
|
```
|
|
363
403
|
|
|
364
404
|
**加载步骤**:
|
|
365
|
-
1. 读取
|
|
405
|
+
1. 读取 `_omp/.memory/project.yaml` 获取项目配置
|
|
366
406
|
2. 调用 `search_memory_openmemory` 查询相关用户记忆
|
|
367
407
|
3. 融合两边信息作为对话上下文
|
|
368
408
|
|
|
@@ -371,12 +411,12 @@ Agent 在对话开始时应**并行查询**两个系统:
|
|
|
371
411
|
**当 openmemory MCP 不可用时**:
|
|
372
412
|
|
|
373
413
|
1. 检测 MCP 连接状态(调用失败或超时)
|
|
374
|
-
2. 降级到仅
|
|
375
|
-
3. 用户级信息临时存入
|
|
414
|
+
2. 降级到仅 `_omp/.memory/` 存储
|
|
415
|
+
3. 用户级信息临时存入 `_omp/.memory/user-context.yaml`
|
|
376
416
|
4. 服务恢复后提示用户同步
|
|
377
417
|
|
|
378
418
|
```yaml
|
|
379
|
-
#
|
|
419
|
+
# _omp/.memory/user-context.yaml (降级时使用)
|
|
380
420
|
_degraded: true
|
|
381
421
|
_reason: "openmemory MCP unavailable"
|
|
382
422
|
pending_memories:
|
|
@@ -388,6 +428,7 @@ pending_memories:
|
|
|
388
428
|
|
|
389
429
|
| 版本 | 变更 |
|
|
390
430
|
|------|------|
|
|
431
|
+
| v2.1 | 目录重构:_omp/ 统一目录,移除 rules/,分类规则内嵌 |
|
|
391
432
|
| v2.0 | 双层记忆架构:整合 openmemory MCP,智能分类路由 |
|
|
392
433
|
| v1.1 | 添加错误处理、Schema 验证、模板文件、触发条件详解 |
|
|
393
434
|
| v1.0 | 初始版本:自动提取、YAML 存储、多 Agent 通知 |
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Memory YAML Validation Script
|
|
4
|
+
# Usage: ./validate.sh [file|all]
|
|
5
|
+
# Validates _omp/.memory/*.yaml files against JSON Schema
|
|
6
|
+
#
|
|
7
|
+
# Dependencies (optional, for full schema validation):
|
|
8
|
+
# npm install -g ajv-cli
|
|
9
|
+
#
|
|
10
|
+
# Without ajv-cli, only YAML syntax is validated.
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
+
# Navigate up to project root: scripts -> memory-extraction -> skills -> _omp -> project_root
|
|
16
|
+
PROJECT_ROOT="${SCRIPT_DIR}/../../../../"
|
|
17
|
+
MEMORY_DIR="${PROJECT_ROOT}/_omp/.memory"
|
|
18
|
+
SCHEMA_DIR="${MEMORY_DIR}/schema"
|
|
19
|
+
|
|
20
|
+
# Colors
|
|
21
|
+
RED='\033[0;31m'
|
|
22
|
+
GREEN='\033[0;32m'
|
|
23
|
+
YELLOW='\033[1;33m'
|
|
24
|
+
NC='\033[0m'
|
|
25
|
+
|
|
26
|
+
validate_yaml() {
|
|
27
|
+
local file="$1"
|
|
28
|
+
local schema="$2"
|
|
29
|
+
|
|
30
|
+
echo -n " Validating $(basename "$file")... "
|
|
31
|
+
|
|
32
|
+
# Check if file exists
|
|
33
|
+
if [ ! -f "$file" ]; then
|
|
34
|
+
echo -e "${RED}NOT FOUND${NC}"
|
|
35
|
+
return 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Check YAML syntax using ruby (built-in on macOS)
|
|
39
|
+
if command -v ruby &> /dev/null; then
|
|
40
|
+
if ! ruby -e "require 'yaml'; YAML.load_file('$file')" 2>/dev/null; then
|
|
41
|
+
echo -e "${RED}YAML SYNTAX ERROR${NC}"
|
|
42
|
+
return 1
|
|
43
|
+
fi
|
|
44
|
+
# Fallback: basic structure check
|
|
45
|
+
elif ! grep -q "^[a-z_]*:" "$file" 2>/dev/null; then
|
|
46
|
+
echo -e "${YELLOW}COULD NOT VALIDATE${NC}"
|
|
47
|
+
return 0
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# Validate against schema (if ajv or similar is available)
|
|
51
|
+
if command -v ajv &> /dev/null && [ -f "$schema" ]; then
|
|
52
|
+
if ajv validate -s "$schema" -d "$file" --spec=draft7 2>/dev/null; then
|
|
53
|
+
echo -e "${GREEN}VALID${NC}"
|
|
54
|
+
return 0
|
|
55
|
+
else
|
|
56
|
+
echo -e "${YELLOW}SCHEMA MISMATCH${NC}"
|
|
57
|
+
return 1
|
|
58
|
+
fi
|
|
59
|
+
else
|
|
60
|
+
echo -e "${GREEN}YAML OK${NC} (schema validation skipped)"
|
|
61
|
+
return 0
|
|
62
|
+
fi
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
echo "🔍 Memory YAML Validation"
|
|
66
|
+
echo "========================="
|
|
67
|
+
echo ""
|
|
68
|
+
|
|
69
|
+
ERRORS=0
|
|
70
|
+
|
|
71
|
+
# Validate project.yaml
|
|
72
|
+
echo "📁 _omp/.memory/"
|
|
73
|
+
validate_yaml "${MEMORY_DIR}/project.yaml" "${SCHEMA_DIR}/project.schema.json" || ERRORS=$((ERRORS + 1))
|
|
74
|
+
validate_yaml "${MEMORY_DIR}/decisions.yaml" "${SCHEMA_DIR}/decisions.schema.json" || ERRORS=$((ERRORS + 1))
|
|
75
|
+
validate_yaml "${MEMORY_DIR}/changelog.yaml" "" || ERRORS=$((ERRORS + 1))
|
|
76
|
+
|
|
77
|
+
# Validate session files
|
|
78
|
+
echo ""
|
|
79
|
+
echo "📁 _omp/.memory/sessions/"
|
|
80
|
+
for session_file in "${MEMORY_DIR}"/sessions/*.yaml; do
|
|
81
|
+
if [ -f "$session_file" ]; then
|
|
82
|
+
validate_yaml "$session_file" "${SCHEMA_DIR}/session.schema.json" || ERRORS=$((ERRORS + 1))
|
|
83
|
+
fi
|
|
84
|
+
done
|
|
85
|
+
|
|
86
|
+
echo ""
|
|
87
|
+
if [ $ERRORS -eq 0 ]; then
|
|
88
|
+
echo -e "${GREEN}✅ All validations passed!${NC}"
|
|
89
|
+
exit 0
|
|
90
|
+
else
|
|
91
|
+
echo -e "${RED}❌ $ERRORS validation error(s) found${NC}"
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Decision Template
|
|
2
|
+
# 追加到 .memory/decisions.yaml 的 decisions 数组中
|
|
3
|
+
#
|
|
4
|
+
# ============================================
|
|
5
|
+
# 使用说明 (Agent 参考)
|
|
6
|
+
# ============================================
|
|
7
|
+
# 变量占位符:
|
|
8
|
+
# {{date}} - 日期 (YYYY-MM-DD)
|
|
9
|
+
# {{seq}} - 当日序号 (001, 002, 003...)
|
|
10
|
+
# {{title}} - 决策标题
|
|
11
|
+
# {{context}} - 决策背景/问题描述
|
|
12
|
+
# {{choice}} - 最终选择
|
|
13
|
+
# {{alt_1}} - 备选方案 (可多个: alt_2, alt_3...)
|
|
14
|
+
# {{rationale}} - 选择理由
|
|
15
|
+
# {{impact_1}} - 影响范围 (可多个: impact_2, impact_3...)
|
|
16
|
+
# ============================================
|
|
17
|
+
|
|
18
|
+
- id: dec-{{date}}-{{seq}}
|
|
19
|
+
date: {{date}}
|
|
20
|
+
title: "{{title}}"
|
|
21
|
+
context: |
|
|
22
|
+
{{context}}
|
|
23
|
+
choice: "{{choice}}"
|
|
24
|
+
alternatives:
|
|
25
|
+
- "{{alt_1}}"
|
|
26
|
+
- "{{alt_2}}"
|
|
27
|
+
rationale: |
|
|
28
|
+
{{rationale}}
|
|
29
|
+
impact:
|
|
30
|
+
- "{{impact_1}}"
|
|
31
|
+
status: active
|
|
32
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# .memory/sessions/{{date}}.yaml - 会话记录
|
|
2
|
+
# 由 memory-extraction skill 自动维护
|
|
3
|
+
#
|
|
4
|
+
# ============================================
|
|
5
|
+
# 使用说明 (Agent 参考)
|
|
6
|
+
# ============================================
|
|
7
|
+
# 变量占位符:
|
|
8
|
+
# {{date}} - 日期 (YYYY-MM-DD)
|
|
9
|
+
# {{timestamp}} - ISO 8601 时间戳 (2026-02-02T14:30:00+08:00)
|
|
10
|
+
# {{summary}} - 会话摘要
|
|
11
|
+
# {{action_1}} - 关键操作 (可多个: action_2, action_3...)
|
|
12
|
+
# {{decision_id}} - 决策 ID (dec-YYYY-MM-DD-NNN)
|
|
13
|
+
# {{decision_title}} - 决策标题
|
|
14
|
+
# {{outcome_1}} - 成果 (可多个: outcome_2, outcome_3...)
|
|
15
|
+
# ============================================
|
|
16
|
+
|
|
17
|
+
date: {{date}}
|
|
18
|
+
|
|
19
|
+
sessions:
|
|
20
|
+
- id: session-001
|
|
21
|
+
summary: "{{summary}}"
|
|
22
|
+
key_actions:
|
|
23
|
+
- "{{action_1}}"
|
|
24
|
+
decisions:
|
|
25
|
+
- id: "{{decision_id}}"
|
|
26
|
+
title: "{{decision_title}}"
|
|
27
|
+
outcomes:
|
|
28
|
+
- "{{outcome_1}}"
|
|
29
|
+
|
|
30
|
+
# 元数据
|
|
31
|
+
_meta:
|
|
32
|
+
last_updated: {{timestamp}}
|
|
33
|
+
updated_by: memory-extraction-skill
|
|
34
|
+
total_sessions: 1
|
|
35
|
+
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Active Context
|
|
2
|
-
|
|
3
|
-
> ⚡ This file is updated frequently - captures current work state
|
|
4
|
-
|
|
5
|
-
## Current Focus
|
|
6
|
-
<!-- 当前正在进行的工作 -->
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
## Recent Changes
|
|
11
|
-
<!-- 最近的重要变更 -->
|
|
12
|
-
|
|
13
|
-
| Date | Change | Impact |
|
|
14
|
-
|------|--------|--------|
|
|
15
|
-
| {{CREATED_AT}} | Project initialized | - |
|
|
16
|
-
|
|
17
|
-
## Active Decisions
|
|
18
|
-
<!-- 当前生效的决策 -->
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
## Open Questions
|
|
23
|
-
<!-- 待解决的问题 -->
|
|
24
|
-
|
|
25
|
-
- [ ]
|
|
26
|
-
|
|
27
|
-
## Next Steps
|
|
28
|
-
<!-- 接下来要做的事 -->
|
|
29
|
-
|
|
30
|
-
1.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
*Last updated: {{CREATED_AT}}*
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Product Context
|
|
2
|
-
|
|
3
|
-
## Why This Project Exists
|
|
4
|
-
<!-- 项目存在的原因,解决什么问题 -->
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## Problems Solved
|
|
9
|
-
<!-- 用户面临的具体问题 -->
|
|
10
|
-
|
|
11
|
-
1.
|
|
12
|
-
|
|
13
|
-
## User Experience Goals
|
|
14
|
-
<!-- 期望的用户体验 -->
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
## Target Users
|
|
19
|
-
<!-- 目标用户群体 -->
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
## How It Should Work
|
|
24
|
-
<!-- 产品应该如何运作 -->
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
*Updated when product direction or user needs change.*
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Progress
|
|
2
|
-
|
|
3
|
-
## What Works ✅
|
|
4
|
-
<!-- 已完成且正常工作的功能 -->
|
|
5
|
-
|
|
6
|
-
- [ ] Project initialized
|
|
7
|
-
|
|
8
|
-
## What's Left 📋
|
|
9
|
-
<!-- 还需要完成的工作 -->
|
|
10
|
-
|
|
11
|
-
- [ ]
|
|
12
|
-
|
|
13
|
-
## Current Status
|
|
14
|
-
<!-- 当前状态概览 -->
|
|
15
|
-
|
|
16
|
-
| Milestone | Status | ETA |
|
|
17
|
-
|-----------|--------|-----|
|
|
18
|
-
| Setup | 🟡 In Progress | - |
|
|
19
|
-
| MVP | ⚪ Not Started | - |
|
|
20
|
-
| Launch | ⚪ Not Started | - |
|
|
21
|
-
|
|
22
|
-
## Known Issues 🐛
|
|
23
|
-
<!-- 已知问题 -->
|
|
24
|
-
|
|
25
|
-
| Issue | Severity | Workaround |
|
|
26
|
-
|-------|----------|------------|
|
|
27
|
-
| | | |
|
|
28
|
-
|
|
29
|
-
## Blockers 🚧
|
|
30
|
-
<!-- 阻塞项 -->
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
## Recent Wins 🎉
|
|
35
|
-
<!-- 最近的成就 -->
|
|
36
|
-
|
|
37
|
-
- {{CREATED_AT}}: Project created
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
*Last updated: {{CREATED_AT}}*
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Project Brief
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
<!-- 项目的核心定义,所有其他文档的基础 -->
|
|
5
|
-
|
|
6
|
-
**项目名称**: {{PROJECT_NAME}}
|
|
7
|
-
|
|
8
|
-
**创建时间**: {{CREATED_AT}}
|
|
9
|
-
|
|
10
|
-
## Core Requirements
|
|
11
|
-
<!-- 项目必须实现的核心功能 -->
|
|
12
|
-
|
|
13
|
-
1.
|
|
14
|
-
|
|
15
|
-
## Goals
|
|
16
|
-
<!-- 项目的主要目标 -->
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
## Scope
|
|
21
|
-
<!-- 项目范围边界 -->
|
|
22
|
-
|
|
23
|
-
### In Scope
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
### Out of Scope
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
## Success Criteria
|
|
30
|
-
<!-- 如何判断项目成功 -->
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
*This is the foundation document. All other memory files build upon this.*
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# System Patterns
|
|
2
|
-
|
|
3
|
-
## Architecture Overview
|
|
4
|
-
<!-- 系统整体架构 -->
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
[Diagram or description]
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## Key Technical Decisions
|
|
11
|
-
<!-- 重要的技术决策及原因 -->
|
|
12
|
-
|
|
13
|
-
| Decision | Rationale | Date |
|
|
14
|
-
|----------|-----------|------|
|
|
15
|
-
| | | |
|
|
16
|
-
|
|
17
|
-
## Design Patterns
|
|
18
|
-
<!-- 项目中使用的设计模式 -->
|
|
19
|
-
|
|
20
|
-
### Pattern 1
|
|
21
|
-
- **Name**:
|
|
22
|
-
- **Usage**:
|
|
23
|
-
- **Example**:
|
|
24
|
-
|
|
25
|
-
## Component Relationships
|
|
26
|
-
<!-- 组件之间的关系 -->
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
ComponentA → ComponentB → ComponentC
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Coding Conventions
|
|
33
|
-
<!-- 代码规范 -->
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
*Updated when architecture or patterns change.*
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Tech Context
|
|
2
|
-
|
|
3
|
-
## Tech Stack
|
|
4
|
-
<!-- 技术栈 -->
|
|
5
|
-
|
|
6
|
-
| Category | Technology | Version |
|
|
7
|
-
|----------|------------|---------|
|
|
8
|
-
| Language | | |
|
|
9
|
-
| Framework | | |
|
|
10
|
-
| Database | | |
|
|
11
|
-
| Deployment | | |
|
|
12
|
-
|
|
13
|
-
## Development Setup
|
|
14
|
-
<!-- 开发环境配置 -->
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# Clone and setup
|
|
18
|
-
git clone <repo>
|
|
19
|
-
cd {{PROJECT_NAME}}
|
|
20
|
-
|
|
21
|
-
# Install dependencies
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# Run development server
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Dependencies
|
|
29
|
-
<!-- 主要依赖 -->
|
|
30
|
-
|
|
31
|
-
### Production
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
### Development
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
## Technical Constraints
|
|
38
|
-
<!-- 技术限制 -->
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
## Environment Variables
|
|
43
|
-
<!-- 环境变量 -->
|
|
44
|
-
|
|
45
|
-
| Variable | Description | Required |
|
|
46
|
-
|----------|-------------|----------|
|
|
47
|
-
| | | |
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
*Updated when tech stack or constraints change.*
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# Memory Classification Rules
|
|
2
|
-
|
|
3
|
-
记忆分类规则,定义信息存储位置决策逻辑。
|
|
4
|
-
|
|
5
|
-
## 存储位置决策表
|
|
6
|
-
|
|
7
|
-
| 信息类型 | 存储位置 | 识别关键词 |
|
|
8
|
-
|----------|----------|------------|
|
|
9
|
-
| 项目配置 | `.memory/project.yaml` | url, domain, deploy, vercel, config, path |
|
|
10
|
-
| 技术决策 | `.memory/decisions.yaml` | 决定, 选择, 采用, 架构, decision, choose |
|
|
11
|
-
| 变更记录 | `.memory/changelog.yaml` | 更新, 修改, 发布, update, change, release |
|
|
12
|
-
| 用户偏好 | `openmemory` | 偏好, 喜欢, 习惯, prefer, style, always |
|
|
13
|
-
| 用户技能 | `openmemory` | 会, 熟悉, 经验, skill, experience, know |
|
|
14
|
-
| 对话上下文 | `openmemory` | 之前, 上次, 记得, remember, last time |
|
|
15
|
-
|
|
16
|
-
## 分类优先级
|
|
17
|
-
|
|
18
|
-
1. **项目相关** → `.memory/` (Git 版本控制)
|
|
19
|
-
2. **用户相关** → `openmemory` (跨项目共享)
|
|
20
|
-
3. **混合信息** → 拆分存储到两个系统
|
|
21
|
-
|
|
22
|
-
## 敏感信息过滤
|
|
23
|
-
|
|
24
|
-
**禁止存储**(检测后阻止):
|
|
25
|
-
|
|
26
|
-
| 类型 | 检测模式 |
|
|
27
|
-
|------|----------|
|
|
28
|
-
| API Key | `sk-`, `api_key`, `token=`, `bearer` |
|
|
29
|
-
| 密码 | `password`, `secret`, `credential` |
|
|
30
|
-
| 私钥 | `-----BEGIN`, `PRIVATE KEY` |
|
|
31
|
-
| 个人信息 | 身份证号, 银行卡号, 手机号 |
|
|
32
|
-
|
|
33
|
-
## 分类决策流程
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
信息输入
|
|
37
|
-
↓
|
|
38
|
-
敏感信息检测 → 是 → 阻止存储,提示用户
|
|
39
|
-
↓ 否
|
|
40
|
-
项目相关判断 → 是 → .memory/{category}.yaml
|
|
41
|
-
↓ 否
|
|
42
|
-
用户相关判断 → 是 → openmemory (add_memories)
|
|
43
|
-
↓ 否
|
|
44
|
-
丢弃 (琐碎信息)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## 项目相关信息判断
|
|
48
|
-
|
|
49
|
-
**存入 `.memory/` 的条件**:
|
|
50
|
-
- 包含项目路径、URL、域名
|
|
51
|
-
- 涉及部署配置、环境变量名(非值)
|
|
52
|
-
- 技术架构决策
|
|
53
|
-
- 项目里程碑、版本信息
|
|
54
|
-
|
|
55
|
-
## 用户相关信息判断
|
|
56
|
-
|
|
57
|
-
**存入 `openmemory` 的条件**:
|
|
58
|
-
- 用户表达偏好 ("我喜欢...", "以后都用...")
|
|
59
|
-
- 用户技能声明 ("我会...", "我熟悉...")
|
|
60
|
-
- 跨项目通用的习惯
|
|
61
|
-
- 用户个人经历、背景
|
|
62
|
-
|
|
63
|
-
## ROT 过滤规则
|
|
64
|
-
|
|
65
|
-
**不存储的信息**:
|
|
66
|
-
|
|
67
|
-
| 类型 | 示例 |
|
|
68
|
-
|------|------|
|
|
69
|
-
| 琐碎确认 | "好的", "OK", "明白了" |
|
|
70
|
-
| 临时状态 | "正在处理...", "稍等" |
|
|
71
|
-
| 重复信息 | 已存在的相同内容 |
|
|
72
|
-
| 过期信息 | 被明确否定或更新的旧信息 |
|
|
73
|
-
|
|
74
|
-
## MCP 工具调用
|
|
75
|
-
|
|
76
|
-
### 写入 openmemory
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
Tool: add_memories_openmemory
|
|
80
|
-
Parameter: text = "{提取的用户信息}"
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### 搜索 openmemory
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
Tool: search_memory_openmemory
|
|
87
|
-
Parameter: query = "{搜索关键词}"
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 列出所有记忆
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
Tool: list_memories_openmemory
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## 降级策略
|
|
97
|
-
|
|
98
|
-
**当 openmemory 不可用时**:
|
|
99
|
-
1. 检测 MCP 连接状态
|
|
100
|
-
2. 降级到仅 `.memory/` 存储
|
|
101
|
-
3. 用户相关信息临时存入 `.memory/user-context.yaml`
|
|
102
|
-
4. 服务恢复后提示同步
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
**版本**: v1.0
|
|
107
|
-
**更新日期**: 2026-02-02
|
|
108
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|