mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-20 17:08:18 +00:00
docs: update README for OpenClaw with AI install guide
This commit is contained in:
152
README.md
152
README.md
@ -1,16 +1,61 @@
|
||||
# TrulyMEM - WaterFlow 适配版
|
||||
# TrulyMEM - OpenClaw 适配版
|
||||
|
||||
让 AI 拥有真正的长期记忆能力 - WaterFlow 框架适配版
|
||||
让 AI 拥有真正的长期记忆能力 - OpenClaw 框架适配版
|
||||
|
||||
[English Version](./README_EN.md)
|
||||
|
||||
---
|
||||
|
||||
## 🤖 AI 自行安装指南
|
||||
|
||||
> 本节面向 AI Agent,指导其如何自主安装此 Skill 到 OpenClaw 框架
|
||||
|
||||
### 安装步骤
|
||||
|
||||
#### 步骤 1:定位 Skill 目录
|
||||
|
||||
OpenClaw 的 Skill 优先级:`/.agents/skills/` > `~/.agents/skills/` > `~/.openclaw/skills/`
|
||||
|
||||
将本项目的 `skills/` 目录复制到高优先级位置:
|
||||
|
||||
```bash
|
||||
# 方式 1: 用户级安装 (推荐)
|
||||
cp -r skills/ ~/.agents/skills/graph_memory
|
||||
|
||||
# 方式 2: 系统级安装
|
||||
sudo cp -r skills/ /.agents/skills/graph_memory
|
||||
```
|
||||
|
||||
#### 步骤 2:验证安装
|
||||
|
||||
在 OpenClaw 中调用 Skill:
|
||||
|
||||
```
|
||||
记得: 我喜欢编程,正在学习 TypeScript
|
||||
```
|
||||
|
||||
AI 应收到确认消息。
|
||||
|
||||
#### 步骤 3:使用 Skill
|
||||
|
||||
安装成功后,AI 可以使用以下命令:
|
||||
|
||||
| 命令 | 功能 |
|
||||
|------|------|
|
||||
| `commit` | 写入记忆 |
|
||||
| `recall` | 检索记忆 |
|
||||
| `purge` | 删除记忆 |
|
||||
| `introspect` | 查看状态 |
|
||||
| `persona_update/clear` | 人设管理 |
|
||||
| `task_create/set_state/delete` | 任务管理 |
|
||||
|
||||
---
|
||||
|
||||
## 简介
|
||||
|
||||
本项目是将 TrulyMEM 的图记忆能力迁移到 WaterFlow 框架的 TypeScript 实现。
|
||||
本项目是将 TrulyMEM 的图记忆能力迁移到 OpenClaw 框架的 TypeScript 实现。
|
||||
|
||||
作为 WaterFlow 的内置模块,提供图记忆功能:
|
||||
作为 OpenClaw 的 Skill 模块,提供图记忆功能:
|
||||
- **recall**: 检索记忆
|
||||
- **commit**: 写入记忆
|
||||
- **purge**: 删除记忆
|
||||
@ -28,42 +73,38 @@ ts/
|
||||
│ ├── graph_memory/ # 图记忆核心模块
|
||||
│ │ ├── types.ts # 类型定义
|
||||
│ │ ├── graph_database.ts # 图数据库
|
||||
│ │ ├── memory_service.ts # 记忆服务
|
||||
│ │ └── index.ts # 模块导出
|
||||
│ │ ├── memory_service.ts # 记忆服务
|
||||
│ │ └── index.ts # 模块导出
|
||||
│ └── tools/
|
||||
│ └── builtin/
|
||||
│ └── graph_memory_tool.ts # Tool 实现
|
||||
│
|
||||
├── bundled-skills/ # Skill 定义
|
||||
│ └── graph_memory/
|
||||
│ ├── SKILL.md # 记忆操作
|
||||
│ ├── persona/SKILL.md # 人设管理
|
||||
│ └── task/SKILL.md # 任务管理
|
||||
│
|
||||
├── package.json # 项目配置
|
||||
└── tsconfig.json # TypeScript 配置
|
||||
├── package.json # 项目配置
|
||||
└── tsconfig.json # TypeScript 配置
|
||||
|
||||
skills/ # OpenClaw Skill 定义
|
||||
└── graph_memory/
|
||||
├── SKILL.md # 记忆操作
|
||||
├── persona/SKILL.md # 人设管理
|
||||
└── task/SKILL.md # 任务管理
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 在 WaterFlow 中使用
|
||||
|
||||
本模块支持两种使用方式:**作为模块直接引用** 或 **作为 Skill 调用**。
|
||||
## 在 OpenClaw 中使用
|
||||
|
||||
### 方式一:作为模块直接引用(适合开发者集成)
|
||||
|
||||
#### 步骤 1:复制源码
|
||||
|
||||
将本项目的 `ts/` 目录复制到你的 WaterFlow 项目中,例如:
|
||||
将本项目的 `ts/` 目录复制到你的 OpenClaw 项目中:
|
||||
|
||||
```
|
||||
你的WaterFlow项目/
|
||||
├── src/
|
||||
│ └── runtime/
|
||||
│ └── core/
|
||||
│ └── graph_memory/ # 从 ts/src/runtime/core/ 复制
|
||||
└── ts/ # 或直接放在项目根目录
|
||||
└── bundled-skills/ # Skill 文件
|
||||
你的OpenClaw项目/
|
||||
└── src/
|
||||
└── runtime/
|
||||
└── core/
|
||||
└── graph_memory/ # 从 ts/src/runtime/core/ 复制
|
||||
```
|
||||
|
||||
#### 步骤 2:编译 TypeScript
|
||||
@ -81,23 +122,9 @@ npm run build
|
||||
```typescript
|
||||
import { createGraphMemoryTool } from './runtime/core/tools/builtin/graph_memory_tool';
|
||||
|
||||
// 创建工具实例,可以传入 sessionId 来区分不同会话
|
||||
// 创建工具实例
|
||||
const tool = createGraphMemoryTool('my-session-id');
|
||||
|
||||
// 准备执行上下文
|
||||
const context = {
|
||||
toolCallId: 'call-123',
|
||||
workingDirectory: '/project',
|
||||
abortController: { signal: {} },
|
||||
config: { timeout: 30000 },
|
||||
logger: {
|
||||
info: console.log,
|
||||
warn: console.warn,
|
||||
error: console.error,
|
||||
debug: console.debug
|
||||
}
|
||||
};
|
||||
|
||||
// 写入记忆示例
|
||||
const commitResult = await tool.handler({
|
||||
action: 'commit',
|
||||
@ -109,9 +136,6 @@ const commitResult = await tool.handler({
|
||||
}
|
||||
}, context);
|
||||
|
||||
console.log(commitResult);
|
||||
// 输出: {"success":true,"data":{"createdEntities":4,"createdRelations":2}}
|
||||
|
||||
// 检索记忆示例
|
||||
const recallResult = await tool.handler({
|
||||
action: 'recall',
|
||||
@ -119,50 +143,24 @@ const recallResult = await tool.handler({
|
||||
queryIntent: '用户 编程'
|
||||
}
|
||||
}, context);
|
||||
|
||||
console.log(recallResult);
|
||||
// 输出: {"success":true,"data":{"entities":[...],"relations":[...],"message":"找到 X 个实体, Y 条关系"}}
|
||||
```
|
||||
|
||||
### 方式二:使用 Skill(推荐,适合 AI Agent 调用)
|
||||
|
||||
#### 步骤 1:配置 Skill 来源
|
||||
#### 步骤 1:放置 Skill 文件
|
||||
|
||||
在你的 WaterFlow 项目中,找到 Skill 配置文件,添加 bundled 来源指向本项目的 Skill 目录:
|
||||
将 `skills/` 目录复制到 OpenClaw 的 Skill 目录:
|
||||
|
||||
```typescript
|
||||
// skill_interface.ts 或配置文件中
|
||||
import { DEFAULT_SKILL_LOADER_CONFIG } from './skill_interface';
|
||||
|
||||
const config = {
|
||||
...DEFAULT_SKILL_LOADER_CONFIG,
|
||||
sources: {
|
||||
...DEFAULT_SKILL_LOADER_CONFIG.sources,
|
||||
bundled: './ts/bundled-skills' // 指向本项目的 Skill 目录
|
||||
},
|
||||
enabledSources: ['project', 'bundled']
|
||||
};
|
||||
```bash
|
||||
cp -r skills/ ~/.agents/skills/graph_memory
|
||||
```
|
||||
|
||||
#### 步骤 2:通过 Agent 调用 Skill
|
||||
|
||||
在你的 Agent 或 Workflow 中,通过 Tool 调用 Skill:
|
||||
在 OpenClaw 中直接调用:
|
||||
|
||||
```
|
||||
使用 skill:graph_memory 进行以下操作:
|
||||
|
||||
1. 写入记忆: 我喜欢编程,正在学习 TypeScript
|
||||
2. 检索记忆: 找出我和编程相关的记忆
|
||||
```
|
||||
|
||||
或者通过代码调用:
|
||||
|
||||
```typescript
|
||||
// 通过 SkillTool 调用
|
||||
const skillResult = await skillTool.handler({
|
||||
skill: 'graph_memory',
|
||||
args: 'recall - queryIntent: "用户 学习"'
|
||||
}, context);
|
||||
使用 graph_memory 记住: 我喜欢编程,正在学习 TypeScript
|
||||
```
|
||||
|
||||
#### 可用 Skill 列表
|
||||
@ -209,7 +207,7 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
"params": {
|
||||
"triplets": [
|
||||
{ "subject": "用户", "relation": "喜欢", "object": "TypeScript" },
|
||||
{ "subject": "用户", "relation": "正在学习", "object": "WaterFlow" }
|
||||
{ "subject": "用户", "relation": "正在学习", "object": "OpenClaw" }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -243,4 +241,4 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
|
||||
## 许可证
|
||||
|
||||
[GNU General Public License v3.0 (GPLv3)](LICENSE)
|
||||
[GNU General Public License v3.0 (GPLv3)](LICENSE)
|
||||
190
README_EN.md
190
README_EN.md
@ -1,16 +1,61 @@
|
||||
# TrulyMEM - WaterFlow Adapter
|
||||
# TrulyMEM - OpenClaw Adapter
|
||||
|
||||
Give AI true long-term memory capability - WaterFlow framework adapter version
|
||||
Give AI true long-term memory capability - OpenClaw framework adapter version
|
||||
|
||||
[中文版本](./README.md)
|
||||
|
||||
---
|
||||
|
||||
## 🤖 AI Self-Installation Guide
|
||||
|
||||
> This section is for AI Agents, guiding them how to self-install this Skill to OpenClaw
|
||||
|
||||
### Installation Steps
|
||||
|
||||
#### Step 1: Locate Skill Directory
|
||||
|
||||
OpenClaw Skill precedence: `/.agents/skills/` > `~/.agents/skills/` > `~/.openclaw/skills/`
|
||||
|
||||
Copy the `skills/` directory to a high-priority location:
|
||||
|
||||
```bash
|
||||
# Method 1: User-level installation (recommended)
|
||||
cp -r skills/ ~/.agents/skills/graph_memory
|
||||
|
||||
# Method 2: System-level installation
|
||||
sudo cp -r skills/ /.agents/skills/graph_memory
|
||||
```
|
||||
|
||||
#### Step 2: Verify Installation
|
||||
|
||||
Invoke Skill in OpenClaw:
|
||||
|
||||
```
|
||||
Remember: I like programming and am learning TypeScript
|
||||
```
|
||||
|
||||
AI should receive a confirmation message.
|
||||
|
||||
#### Step 3: Use the Skill
|
||||
|
||||
After installation, AI can use these commands:
|
||||
|
||||
| Command | Function |
|
||||
|---------|----------|
|
||||
| `commit` | Commit memories |
|
||||
| `recall` | Retrieve memories |
|
||||
| `purge` | Delete memories |
|
||||
| `introspect` | Inspect status |
|
||||
| `persona_update/clear` | Persona management |
|
||||
| `task_create/set_state/delete` | Task management |
|
||||
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
This project ports TrulyMEM's graph memory capability to TypeScript for the WaterFlow framework.
|
||||
This project ports TrulyMEM's graph memory capability to TypeScript for the OpenClaw framework.
|
||||
|
||||
As a built-in module for WaterFlow, it provides graph memory functionality:
|
||||
As an OpenClaw Skill module, it provides graph memory functionality:
|
||||
|
||||
- **recall**: Retrieve memories
|
||||
- **commit**: Commit memories
|
||||
@ -29,45 +74,41 @@ ts/
|
||||
│ ├── graph_memory/ # Graph memory core module
|
||||
│ │ ├── types.ts # Type definitions
|
||||
│ │ ├── graph_database.ts # Graph database
|
||||
│ │ ├── memory_service.ts # Memory service
|
||||
│ │ └── index.ts # Module exports
|
||||
│ │ ├── memory_service.ts # Memory service
|
||||
│ │ └── index.ts # Module exports
|
||||
│ └── tools/
|
||||
│ └── builtin/
|
||||
│ └── graph_memory_tool.ts # Tool implementation
|
||||
│
|
||||
├── bundled-skills/ # Skill definitions
|
||||
│ └── graph_memory/
|
||||
│ ├── SKILL.md # Memory operations
|
||||
│ ├── persona/SKILL.md # Persona management
|
||||
│ └── task/SKILL.md # Task management
|
||||
│
|
||||
├── package.json # Project config
|
||||
└── tsconfig.json # TypeScript config
|
||||
├── package.json # Project config
|
||||
└── tsconfig.json # TypeScript config
|
||||
|
||||
skills/ # OpenClaw Skill definitions
|
||||
└── graph_memory/
|
||||
├── SKILL.md # Memory operations
|
||||
├── persona/SKILL.md # Persona management
|
||||
└── task/SKILL.md # Task management
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage in WaterFlow
|
||||
## Using in OpenClaw
|
||||
|
||||
This module supports two usage methods: **import as module** or **use as Skill**.
|
||||
### Method 1: As Module (for Developer Integration)
|
||||
|
||||
### Method 1: Import as Module (for developer integration)
|
||||
#### Step 1: Copy Source Code
|
||||
|
||||
#### Step 1: Copy source files
|
||||
|
||||
Copy the `ts/` directory to your WaterFlow project, for example:
|
||||
Copy the `ts/` directory to your OpenClaw project:
|
||||
|
||||
```
|
||||
your-waterflow-project/
|
||||
├── src/
|
||||
│ └── runtime/
|
||||
│ └── core/
|
||||
│ └── graph_memory/ # Copy from ts/src/runtime/core/
|
||||
└── ts/ # Or place in project root
|
||||
└── bundled-skills/ # Skill files
|
||||
yourOpenClawProject/
|
||||
└── src/
|
||||
└── runtime/
|
||||
└── core/
|
||||
└── graph_memory/ # Copy from ts/src/runtime/core/
|
||||
```
|
||||
|
||||
#### Step 2: Build TypeScript
|
||||
#### Step 2: Compile TypeScript
|
||||
|
||||
```bash
|
||||
cd ts/
|
||||
@ -75,104 +116,61 @@ npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
Compiled files will be output to `ts/dist/`.
|
||||
Compiled files output to `ts/dist/` directory.
|
||||
|
||||
#### Step 3: Import in your code
|
||||
#### Step 3: Import in Code
|
||||
|
||||
```typescript
|
||||
import { createGraphMemoryTool } from './runtime/core/tools/builtin/graph_memory_tool';
|
||||
|
||||
// Create tool instance, can pass sessionId to distinguish different sessions
|
||||
// Create tool instance
|
||||
const tool = createGraphMemoryTool('my-session-id');
|
||||
|
||||
// Prepare execution context
|
||||
const context = {
|
||||
toolCallId: 'call-123',
|
||||
workingDirectory: '/project',
|
||||
abortController: { signal: {} },
|
||||
config: { timeout: 30000 },
|
||||
logger: {
|
||||
info: console.log,
|
||||
warn: console.warn,
|
||||
error: console.error,
|
||||
debug: console.debug
|
||||
}
|
||||
};
|
||||
|
||||
// Commit memory example
|
||||
const commitResult = await tool.handler({
|
||||
action: 'commit',
|
||||
params: {
|
||||
triplets: [
|
||||
{ subject: 'User', relation: 'likes', object: 'Programming' },
|
||||
{ subject: 'User', relation: 'is learning', object: 'TypeScript' }
|
||||
{ subject: '用户', relation: '喜欢', object: '编程' },
|
||||
{ subject: '用户', relation: '正在学习', object: 'TypeScript' }
|
||||
]
|
||||
}
|
||||
}, context);
|
||||
|
||||
console.log(commitResult);
|
||||
// Output: {"success":true,"data":{"createdEntities":4,"createdRelations":2}}
|
||||
|
||||
// Recall memory example
|
||||
const recallResult = await tool.handler({
|
||||
action: 'recall',
|
||||
params: {
|
||||
queryIntent: 'User Programming'
|
||||
queryIntent: '用户 编程'
|
||||
}
|
||||
}, context);
|
||||
|
||||
console.log(recallResult);
|
||||
// Output: {"success":true,"data":{"entities":[...],"relations":[...],"message":"Found X entities, Y relations"}}
|
||||
```
|
||||
|
||||
### Method 2: Use Skill (recommended for AI Agent)
|
||||
### Method 2: Use Skill (Recommended for AI Agent)
|
||||
|
||||
#### Step 1: Configure Skill source
|
||||
#### Step 1: Place Skill Files
|
||||
|
||||
In your WaterFlow project, find the Skill configuration file and add bundled source pointing to this project's Skill directory:
|
||||
Copy `skills/` directory to OpenClaw's Skill directory:
|
||||
|
||||
```typescript
|
||||
// skill_interface.ts or config file
|
||||
import { DEFAULT_SKILL_LOADER_CONFIG } from './skill_interface';
|
||||
|
||||
const config = {
|
||||
...DEFAULT_SKILL_LOADER_CONFIG,
|
||||
sources: {
|
||||
...DEFAULT_SKILL_LOADER_CONFIG.sources,
|
||||
bundled: './ts/bundled-skills' // Point to this project's Skill directory
|
||||
},
|
||||
enabledSources: ['project', 'bundled']
|
||||
};
|
||||
```bash
|
||||
cp -r skills/ ~/.agents/skills/graph_memory
|
||||
```
|
||||
|
||||
#### Step 2: Call Skill via Agent
|
||||
#### Step 2: Invoke Skill
|
||||
|
||||
In your Agent or Workflow, call Skill via Tool:
|
||||
Use directly in OpenClaw:
|
||||
|
||||
```
|
||||
Use skill:graph_memory for:
|
||||
|
||||
1. Commit memory: I like programming, learning TypeScript
|
||||
2. Recall memory: Find memories related to me and programming
|
||||
```
|
||||
|
||||
Or call via code:
|
||||
|
||||
```typescript
|
||||
// Call via SkillTool
|
||||
const skillResult = await skillTool.handler({
|
||||
skill: 'graph_memory',
|
||||
args: 'recall - queryIntent: "User learning"'
|
||||
}, context);
|
||||
Use graph_memory to remember: I like programming and am learning TypeScript
|
||||
```
|
||||
|
||||
#### Available Skills
|
||||
|
||||
| Skill Name | Function | Use Case |
|
||||
|------------|----------|----------|
|
||||
| `graph_memory` | Memory CRUD | Read/Write/Delete memories |
|
||||
| `graph_memory_persona` | Persona management | Set AI role/personality |
|
||||
| `graph_memory_task` | Task management | Create/update long-term tasks |
|
||||
| `graph_memory` | Memory CRUD | Read/write/delete memories |
|
||||
| `graph_memory_persona` | Persona management | Set AI persona |
|
||||
| `graph_memory_task` | Task management | Create/update tasks |
|
||||
|
||||
---
|
||||
|
||||
@ -195,7 +193,7 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
| `persona_update` | Update persona | `attributes`, `mode` |
|
||||
| `persona_clear` | Clear persona | `confirm` |
|
||||
| `task_create` | Create task | `task_id`, `description`, `info_nodes` |
|
||||
| `task_set_state` | Set state | `task_id`, `state` |
|
||||
| `task_set_state` | Set task state | `task_id`, `state` |
|
||||
| `task_delete` | Delete task | `task_id` |
|
||||
|
||||
---
|
||||
@ -209,8 +207,8 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
"action": "commit",
|
||||
"params": {
|
||||
"triplets": [
|
||||
{ "subject": "User", "relation": "likes", "object": "TypeScript" },
|
||||
{ "subject": "User", "relation": "is learning", "object": "WaterFlow" }
|
||||
{ "subject": "用户", "relation": "喜欢", "object": "TypeScript" },
|
||||
{ "subject": "用户", "relation": "正在学习", "object": "OpenClaw" }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -222,7 +220,7 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
{
|
||||
"action": "recall",
|
||||
"params": {
|
||||
"queryIntent": "User learning"
|
||||
"queryIntent": "用户 学习"
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -233,9 +231,9 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
{
|
||||
"action": "task_create",
|
||||
"params": {
|
||||
"task_id": "Task_LearnTypeScript",
|
||||
"description": "Learn TypeScript and complete project",
|
||||
"info_nodes": ["Documentation", "Tutorial"]
|
||||
"task_id": "Task_学习TypeScript",
|
||||
"description": "学习 TypeScript 并完成项目",
|
||||
"info_nodes": ["文档链接", "教程链接"]
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -244,4 +242,4 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
|
||||
## License
|
||||
|
||||
[GNU General Public License v3.0 (GPLv3)](LICENSE)
|
||||
[GNU General Public License v3.0 (GPLv3)](LICENSE)
|
||||
161
skills/graph_memory/SKILL.md
Normal file
161
skills/graph_memory/SKILL.md
Normal file
@ -0,0 +1,161 @@
|
||||
---
|
||||
name: graph_memory
|
||||
description: 让 AI 拥有真正的长期记忆能力 - 检索、写入、删除记忆,管理人设和任务
|
||||
when_to_use: 当需要 AI 记住持久信息、回忆过去交互、或管理长期任务时
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# GraphMemory 图记忆系统
|
||||
|
||||
让 AI 拥有真正的长期记忆能力。
|
||||
|
||||
## 这个技能做什么
|
||||
|
||||
这个技能教会 AI 如何使用图结构存储和检索记忆。AI 可以:
|
||||
- 记住重要的信息(实体)
|
||||
- 理解信息之间的关系(关系/三元组)
|
||||
- 回忆相关的记忆
|
||||
- 管理 AI 的人设(角色性格)
|
||||
- 追踪长期任务
|
||||
|
||||
## 核心概念
|
||||
|
||||
### 实体 (Entity)
|
||||
现实世界中的对象,如"用户"、"Python"、"WaterFlow"。每个实体有:
|
||||
- 名称 (name)
|
||||
- 类型 (type)
|
||||
- 提及次数 (mentionCount)
|
||||
|
||||
### 关系 (Relation)
|
||||
连接两个实体的关系,格式为三元组:
|
||||
- 主体 (subject) - 关系 - 客体 (object)
|
||||
- 例如:"用户" 喜欢 "编程"
|
||||
|
||||
## 可用命令
|
||||
|
||||
### 1. commit - 写入记忆
|
||||
|
||||
将信息写入记忆图。
|
||||
|
||||
**参数:**
|
||||
- `triplets`: 三元组数组,格式为 `[{subject, relation, object}, ...]`
|
||||
- `sessionId`: 会话 ID(可选)
|
||||
- `turnId`: 轮次 ID(可选)
|
||||
|
||||
**示例:**
|
||||
```
|
||||
请记住:我喜欢编程,正在学习 TypeScript
|
||||
```
|
||||
|
||||
AI 会执行:
|
||||
```json
|
||||
{
|
||||
"action": "commit",
|
||||
"params": {
|
||||
"triplets": [
|
||||
{"subject": "我", "relation": "喜欢", "object": "编程"},
|
||||
{"subject": "我", "relation": "正在学习", "object": "TypeScript"}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. recall - 检索记忆
|
||||
|
||||
从记忆图中检索相关信息。
|
||||
|
||||
**参数:**
|
||||
- `queryIntent`: 搜索关键词
|
||||
- `seedEntities`: 种子实体(可选)
|
||||
- `sessionFilter`: 会话过滤(可选)
|
||||
|
||||
**示例:**
|
||||
```
|
||||
我之前说过我喜欢什么?
|
||||
```
|
||||
|
||||
### 3. purge - 删除记忆
|
||||
|
||||
删除记忆图中的一些信息。
|
||||
|
||||
**参数:**
|
||||
- `criteria`: 删除条件 `{subject, target, relation, sessionId}`
|
||||
- `mode`: 删除模式 `soft`(标记删除)或 `hard`(彻底删除)
|
||||
|
||||
### 4. introspect - 查看状态
|
||||
|
||||
查看当前记忆状态统计。
|
||||
|
||||
**返回:**
|
||||
- entityCount: 实体数量
|
||||
- relationCount: 关系数量
|
||||
|
||||
### 5. persona_update - 更新人设
|
||||
|
||||
更新 AI 的角色/性格特征。
|
||||
|
||||
**参数:**
|
||||
- `attributes`: 属性数组 `[{attribute, value}, ...]`
|
||||
- `mode`: `merge`(合并)或 `replace`(替换)
|
||||
|
||||
**示例:**
|
||||
```
|
||||
我的角色是猫娘,性格活泼
|
||||
```
|
||||
|
||||
### 6. persona_clear - 清除人设
|
||||
|
||||
清除 AI 的所有角色设定。
|
||||
|
||||
**参数:**
|
||||
- `confirm`: 必须为 `true` 才能执行
|
||||
|
||||
### 7. task_create - 创建任务
|
||||
|
||||
创建长期任务节点。
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 唯一任务 ID
|
||||
- `description`: 任务描述
|
||||
- `info_nodes`: 相关信息节点(可选)
|
||||
|
||||
### 8. task_set_state - 设置任务状态
|
||||
|
||||
更新任务状态。
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 任务 ID
|
||||
- `state`: 新状态 (`进行中`/`已完成`/`已暂停`/`已取消`)
|
||||
|
||||
### 9. task_delete - 删除任务
|
||||
|
||||
删除任务。
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 任务 ID
|
||||
|
||||
## 使用原则
|
||||
|
||||
1. **选择性记忆**:只记住重要和持久的信息
|
||||
2. **结构化**:使用三元组格式存储关系
|
||||
3. **定期清理**:删除过时或错误的信息
|
||||
4. **关联思考**:利用关系进行联想记忆
|
||||
|
||||
## 关系类型参考
|
||||
|
||||
| 关系 | 含义 |
|
||||
|------|------|
|
||||
| 喜欢 | 偏好关系 |
|
||||
| 是 | 类型关系 |
|
||||
| 正在学习 | 进程关系 |
|
||||
| 属于 | 归属关系 |
|
||||
| 包含 | 组成关系 |
|
||||
| has_description | 描述关系 |
|
||||
| HAS_STATE | 状态关系 |
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 每次交互后,AI 应该决定是否需要 commit 重要信息
|
||||
- 使用 recall 来获取相关上下文,而不只是依赖当前对话
|
||||
- persona 信息应该谨慎修改
|
||||
- 任务可以跨会话追踪
|
||||
98
skills/graph_memory/persona/SKILL.md
Normal file
98
skills/graph_memory/persona/SKILL.md
Normal file
@ -0,0 +1,98 @@
|
||||
---
|
||||
name: graph_memory_persona
|
||||
description: 管理 AI 人设 - 更新或清除 AI 角色特征
|
||||
when_to_use: 当需要设置或修改 AI 的角色性格时
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# GraphMemory Persona 人设管理
|
||||
|
||||
管理 AI 的人设/角色特征。
|
||||
|
||||
## 这个技能做什么
|
||||
|
||||
这个技能让 AI 能够:
|
||||
- 设置自己的角色/性格
|
||||
- 更新人设信息
|
||||
- 清除人设
|
||||
|
||||
## 可用命令
|
||||
|
||||
### 1. persona_update - 更新人设
|
||||
|
||||
**参数:**
|
||||
- `attributes`: 属性数组 `[{attribute, value}, ...]`
|
||||
- `mode`:
|
||||
- `merge`: 合并到现有属性(默认)
|
||||
- `replace`: 替换所有现有属性
|
||||
|
||||
**示例:**
|
||||
```
|
||||
# 方式一:合并更新
|
||||
记住我的角色是猫娘
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "persona_update",
|
||||
"params": {
|
||||
"attributes": [
|
||||
{"attribute": "角色", "value": "猫娘"}
|
||||
],
|
||||
"mode": "merge"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
# 方式二:完全替换
|
||||
我是一个专业的技术作家
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "persona_update",
|
||||
"params": {
|
||||
"attributes": [
|
||||
{"attribute": "职业", "value": "技术作家"}
|
||||
],
|
||||
"mode": "replace"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. persona_clear - 清除人设
|
||||
|
||||
**参数:**
|
||||
- `confirm`: 必须为 `true` 才能执行
|
||||
|
||||
**示例:**
|
||||
```
|
||||
清除我的人设
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "persona_clear",
|
||||
"params": {
|
||||
"confirm": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 使用场景
|
||||
|
||||
- 初始化 AI 角色
|
||||
- 调整 AI 性格
|
||||
- 清除错误的人设
|
||||
- 角色切换
|
||||
- 设置专业领域
|
||||
|
||||
## 常见人设属性
|
||||
|
||||
| 属性 | 说明 | 示例值 |
|
||||
|------|------|--------|
|
||||
| 角色 | AI 的角色 | "猫娘"、"助手"、"专家" |
|
||||
| 性格 | 性格特征 | "活泼"、"严肃"、"幽默" |
|
||||
| 职业 | 专业领域 | "技术作家"、"程序员" |
|
||||
| 语言风格 | 说话方式 | "简洁"、"详细" |
|
||||
134
skills/graph_memory/task/SKILL.md
Normal file
134
skills/graph_memory/task/SKILL.md
Normal file
@ -0,0 +1,134 @@
|
||||
---
|
||||
name: graph_memory_task
|
||||
description: 管理连续性任务 - 创建、更新、删除任务节点
|
||||
when_to_use: 当需要创建或管理长期/跨会话任务时
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# GraphMemory Task 任务管理
|
||||
|
||||
管理长期/连续性任务。
|
||||
|
||||
## 这个技能做什么
|
||||
|
||||
这个技能让 AI 能够:
|
||||
- 创建新任务
|
||||
- 追踪任务进度
|
||||
- 更新任务状态
|
||||
- 关联任务相关信息
|
||||
- 删除任务
|
||||
|
||||
## 可用命令
|
||||
|
||||
### 1. task_create - 创建任务
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 唯一任务标识
|
||||
- `description`: 任务描述
|
||||
- `info_nodes`: 相关信息节点(可选)
|
||||
|
||||
**示例:**
|
||||
```
|
||||
帮我创建一个任务:学习 TypeScript
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "task_create",
|
||||
"params": {
|
||||
"task_id": "task_学习TypeScript",
|
||||
"description": "学习 TypeScript",
|
||||
"info_nodes": ["TypeScript文档", "教程链接"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. task_set_state - 设置状态
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 任务 ID
|
||||
- `state`: 新状态
|
||||
|
||||
**可用状态:**
|
||||
- `进行中`: 任务正在处理
|
||||
- `已完成`: 任务已完成
|
||||
- `已暂停`: 任务暂停
|
||||
- `已取消`: 任务取消
|
||||
|
||||
**示例:**
|
||||
```
|
||||
TypeScript 学习任务完成了
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "task_set_state",
|
||||
"params": {
|
||||
"task_id": "task_学习TypeScript",
|
||||
"state": "已完成"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. task_delete - 删除任务
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 任务 ID
|
||||
|
||||
**示例:**
|
||||
```
|
||||
删除那个 TypeScript 任务
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "task_delete",
|
||||
"params": {
|
||||
"task_id": "task_学习TypeScript"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4. task_link_info - 关联信息
|
||||
|
||||
**参数:**
|
||||
- `task_id`: 任务 ID
|
||||
- `info_node`: 信息节点
|
||||
|
||||
**示例:**
|
||||
```
|
||||
给任务添加一个新资源
|
||||
```
|
||||
会执行:
|
||||
```json
|
||||
{
|
||||
"action": "task_link_info",
|
||||
"params": {
|
||||
"task_id": "task_学习TypeScript",
|
||||
"info_node": "新发现的教程"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 使用场景
|
||||
|
||||
- 跨会话追踪任务进度
|
||||
- 记录任务相关信息
|
||||
- 管理复杂工作流
|
||||
- 任务状态持久化
|
||||
- 长期项目追踪
|
||||
|
||||
## 任务状态流转
|
||||
|
||||
```
|
||||
创建 (进行中) → 进行中 → 已完成
|
||||
↘ 已暂停
|
||||
↘ 已取消
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **具体描述**:任务描述要清晰具体
|
||||
2. **关联信息**:为任务添加相关资料链接
|
||||
3. **及时更新**:状态改变时立即更新
|
||||
4. **清理完成**:已完成的任务及时删除或归档
|
||||
Reference in New Issue
Block a user