This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openclaw-skills/skills/kb-workflow/SKILL.md
T
OpenClaw Agent 173d7379cb feat: 添加自然语言触发支持
- 支持'保存到知识库'/'订阅到知识库'触发词
- 自动检测链接并处理
- 更新SKILL.md文档
2026-02-10 17:55:25 +08:00

249 lines
5.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: kb-workflow
description: 知识库工作流编排技能,提供收件箱扫描、内容处理、归档、订阅检测、Git版本管理和自动清理功能。
metadata:
short-description: 知识库工作流编排
---
# KB Workflow
## Description
KB Workflow 是一个完整的知识库管理系统,包含:
**核心功能**:
- 📥 **收件箱扫描** - 扫描四个子目录 (pending, metadata, content, analyzed)
- 🔄 **内容处理** - 调用技能2-4处理内容
- 📦 **Git版本管理** - 归档后自动提交并推送
- 🔔 **订阅管理** - 跟踪订阅源更新
- 🧹 **自动清理** - 定期清理临时文件
- 📊 **汇报生成** - 生成处理统计
## 触发方式
### 自然语言触发
当用户发送包含以下模式的消息时,技能会自动触发:
| 触发词 | 行为 | 示例 |
|--------|------|------|
| `保存到知识库` + 链接 | 添加到收件箱并处理 | "保存到知识库 https://www.bilibili.com/video/BVxxx" |
| `添加到知识库` + 链接 | 添加到收件箱并处理 | "添加到知识库 https://www.bilibili.com/video/BVxxx" |
| `订阅到知识库` + 链接 | 添加到订阅列表 | "订阅到知识库 https://www.bilibili.com/video/BVxxx" |
| `订阅知识库` + 链接 | 添加到订阅列表 | "订阅知识库 https://www.bilibili.com/video/BVxxx" |
### 支持的平台
| 平台 | 保存 | 订阅 |
|------|------|------|
| Bilibili | ✅ | ✅ |
| YouTube | ✅ | ❌ |
| 知乎 | ✅ | ❌ |
## 目录结构
```
knowledge-base/
├── kb.config.yaml # 配置文件
├── .gitignore # Git忽略规则
├── pending/ # 待处理内容 (*.md)
├── metadata/ # 链接解析结果 (*.link.json)
├── content/
│ ├── json/ # 元数据 (*.meta.json)
│ ├── downloads/ # 视频文件 (*.mp4/*.flv) - 7天后清理
│ └── subtitles/ # 字幕文件 (*.srt/*.lrc) - 7天后清理
├── frames/ # 视频截帧 (*.jpg) - 7天后清理
├── analyzed/ # 分析报告 (*.md)
└── archive/ # Git归档目录
├── YYYY-MM-DD/ # 按日期归档
└── subscriptions/ # 订阅数据
├── subscriptions.json # 订阅配置
└── processed.json # 已处理项目
```
## Git版本管理
### 配置
设置环境变量:
```bash
export KB_GIT_ROOT="/path/to/archive" # Git仓库目录
export KB_GIT_REMOTE="git@github.com:user/repo.git" # 远程仓库
export KB_GIT_USER="Username" # 用户名
export KB_GIT_EMAIL="user@example.com" # 邮箱
```
### 工作流程
```
归档项目 → Git add → Git commit → Git push → 清理临时文件
```
- 每次归档生成一个commit
- 自动推送到远程仓库(重试3次)
- 汇报中体现Git状态
## 订阅管理
### 数据结构
```json
{
"version": "1.0",
"subscriptions": [
{
"id": "sub_001",
"platform": "bilibili",
"type": "series",
"identifier": "123456",
"name": "UE5教程",
"subscribed_at": "2026-02-10T12:00:00",
"last_checked": null,
"last_update": null,
"status": "active"
}
],
"processed_items": [
{
"id": "BVxxx",
"title": "视频标题",
"processed_at": "2026-02-10T14:00:00",
"archived": true
}
]
}
```
### 命令
```bash
# 添加订阅
python kb_workflow.py --trigger subscriptions --add "bilibili" "series" "123456" "教程名称"
# 检查更新
python kb_workflow.py --trigger subscriptions --check
# 查看状态
python kb_workflow.py --trigger subscriptions --status
```
## 自动清理策略
### 清理规则
| 类型 | 保留 | 清理周期 |
|------|------|---------|
| 分析报告 | ✅ 永久 | - |
| 链接信息 | ✅ 永久 | - |
| 元数据 | ✅ 永久 | - |
| 订阅数据 | ✅ Git管理 | - |
| 视频文件 | ❌ | 7天 |
| 截帧文件 | ❌ | 7天 |
### 命令
```bash
# 清理30天前的临时文件
python kb_workflow.py --trigger cleanup --days 30
# 清理单个项目
python kb_workflow.py --trigger cleanup --project "项目名称"
```
## Usage
### 命令行用法
```bash
# 查看状态
python kb_workflow.py --trigger status
# 处理待处理内容
python kb_workflow.py --trigger manual --scope pending --limit 5
# 初始化Git
python kb_workflow.py --trigger git-init
# 查看Git状态
python kb_workflow.py --trigger git-status
# 清理过期文件
python kb_workflow.py --trigger cleanup --days 30
```
### 参数说明
| 参数 | 说明 | 默认值 |
|------|------|--------|
| `--trigger` | 触发类型 | `status` |
| `--scope` | 处理范围 | `pending` |
| `--limit` | 处理数量限制 | 无限制 |
| `--days` | 清理天数 | 30 |
## Integration
### 技能2-4 集成
KB Workflow 协调以下子技能:
1. **Skill 1: Link Parser** - 解析 URL/链接
2. **Skill 2: Metadata** - 提取元数据
3. **Skill 3: Content** - 获取内容
4. **Skill 4: Deep Analyzer** - 深度分析
## Configuration
### 配置文件 (kb.config.yaml)
```yaml
git:
enabled: true
remote: "git@github.com:user/repo.git"
user: "Username"
email: "user@example.com"
cleanup:
video_retention_days: 7
frame_retention_days: 7
auto_cleanup: true
subscriptions:
check_interval_hours: 24
```
## Troubleshooting
### Git未初始化
```bash
# 检查配置
python kb_workflow.py --trigger git-status
# 初始化
export KB_GIT_ROOT="/path/to/archive"
python kb_workflow.py --trigger git-init
```
### 推送失败
- 检查网络连接
- 验证远程仓库权限
- 查看错误日志
### 存储空间过大
```bash
# 清理过期文件
python kb_workflow.py --trigger cleanup --days 7
# 查看存储使用情况
python kb_workflow.py --trigger status
```
## Related Skills
- **kb-link-parser** - 链接解析
- **kb-bilibili-metadata** - B站元数据
- **kb-bilibili-content** - B站内容获取
- **kb-deep-analyzer** - 深度分析