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 5507b1d986 feat: Add KB knowledge base series skills
- kb-link-parser: Multi-platform URL parser (Bilibili, YouTube, Zhihu)
- kb-bilibili-metadata: Bilibili video/article/up主 metadata extractor
- kb-zhihu-metadata: Zhihu question/answer/user metadata extractor
- kb-bilibili-content: Bilibili video download and content extraction
- kb-ocr-processor: OCR text extraction from video frames
- kb-deep-analyzer: AI-powered deep content analysis
- kb-workflow: Workflow orchestration (inbox, archive, subscriptions, report)

Also add:
- ARCHITECTURE_FLOWCHART.md: System architecture diagrams
- DETAILED_DESIGN.md: Complete design documentation
2026-02-10 12:18:52 +08:00

286 lines
7.0 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: 知识库工作流编排技能,提供收件箱扫描、内容处理、归档、订阅检测和汇报生成功能。
metadata:
short-description: 知识库工作流编排
---
# KB Workflow
## Description
KB Workflow 是一个知识库工作流编排技能,负责协调和管理知识库内容的完整生命周期:
**核心功能**:
- 📥 **收件箱扫描** - 扫描四个子目录 (pending, metadata, content, analyzed)
- 🔄 **内容处理** - 调用技能2-4处理内容
- 📦 **智能归档** - 将处理完成的内容归档到 archive/
- 🔔 **订阅检测** - 检测订阅源的更新
- 📊 **汇报生成** - 生成处理统计和推荐
## Workflow Stages
```
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌──────────┐
│ pending │ → │ metadata│ → │ content │ → │ analyzed│ → │ archive/ │
└─────────┘ └─────────┘ └─────────┘ └─────────┘ └──────────┘
↓ ↓ ↓ ↓
Skill 2 Skill 3 Skill 4 ↓
(Link解析) (元数据提取) (内容分析) 最终归档
```
## Installation
KB Workflow 作为 OpenClaw 技能套件的一部分,无需额外安装。
确保以下依赖已配置:
- Python 3.8+
- 知识库目录结构 (knowledge-base/)
## Directory Structure
```
knowledge-base/
├── pending/ # 待处理的新内容
├── metadata/ # 已提取元数据
├── content/ # 已提取内容
├── analyzed/ # 已完成分析
├── archive/ # 归档内容
│ └── YYYY-MM-DD/ # 按日期归档
└── reports/ # 生成的汇报
```
## Usage
### 命令行用法
```bash
# 查看工作流状态
python kb_workflow.py --trigger status
# 手动处理待处理内容
python kb_workflow.py --trigger manual --scope pending
# 处理所有新内容(限制5个)
python kb_workflow.py --trigger manual --limit 5
# 生成日报
python kb_workflow.py --trigger scheduled --report
# 检查订阅更新
python kb_workflow.py --trigger subscriptions
```
### 参数说明
| 参数 | 说明 | 默认值 |
|------|------|--------|
| `--trigger` | 触发类型 | `manual` |
| `--scope` | 处理范围 | `all` |
| `--limit` | 处理数量限制 | 无限制 |
| `--report` | 生成汇报 | False |
| `--output` | 输出格式 | `json` |
### 触发类型
- `manual` - 手动触发,立即处理
- `scheduled` - 定时任务触发
- `webhook` - Webhook 触发
- `status` - 仅查看状态
- `report` - 生成汇报
- `subscriptions` - 检查订阅
### 作用域
- `all` - 所有目录
- `pending` - 仅待处理
- `metadata` - 仅元数据阶段
- `content` - 仅内容阶段
- `analyzed` - 仅已完成分析
- `archive` - 归档目录
## Integration
### 技能2-4 集成
KB Workflow 协调以下子技能:
1. **Skill 2: Link Parser** - 解析 URL/链接
2. **Skill 3: Zhihu Metadata** - 提取元数据
3. **Skill 4: Bilibili Analyzer** - 内容分析
### 调用示例
```python
from kb_workflow import KBWorkflow
# 初始化
workflow = KBWorkflow(base_path="/path/to/knowledge-base")
# 扫描收件箱
inbox = workflow.scan_inbox(scope="pending")
print(f"待处理: {len(inbox['pending'])} 项")
# 处理项目
for item in inbox['pending'][:5]:
result = workflow.process_item(item)
print(f"处理结果: {result['success']}")
# 查看状态
status = workflow.get_status()
print(json.dumps(status, indent=2))
# 生成汇报
report = workflow.generate_report(period="daily")
```
## Input/Output Formats
### Input
#### 扫描收件箱输入
```json
{
"scope": "all", // 或 "pending", "metadata", "content", "analyzed"
"limit": 10 // 可选,限制返回数量
}
```
#### 处理项目输入
```json
{
"name": "example.md",
"path": "/path/to/knowledge-base/pending/example.md",
"extension": ".md",
"size": 1024,
"modified": "2026-02-10T12:00:00"
}
```
### Output
#### 状态输出
```json
{
"status": "ready",
"timestamp": "2026-02-10T12:00:00",
"inbox": {
"pending": {"count": 5, "path": "/path/pending"},
"metadata": {"count": 3, "path": "/path/metadata"},
"content": {"count": 2, "path": "/path/content"},
"analyzed": {"count": 8, "path": "/path/analyzed"}
},
"archive": {
"count": 120,
"path": "/path/archive"
},
"total_items": 18
}
```
#### 处理结果输出
```json
{
"item": {"name": "example.md", ...},
"success": true,
"stages_completed": ["link_parsing", "metadata_extraction", "content_analysis"],
"output_path": "/path/analyzed/example.md",
"error": null
}
```
#### 汇报输出
```json
{
"generated_at": "2026-02-10T12:00:00",
"period": "daily",
"summary": {
"total_items_inbox": 18,
"total_archived": 120,
"items_by_stage": {...}
},
"processing_stats": {...},
"recommendations": [
"⚠️ 待处理内容较多 (15 项),建议优先处理",
"📦 已分析内容较多 (25 项),建议归档"
]
}
```
## Configuration
KB Workflow 无需额外配置,自动使用以下路径:
- 知识库根目录: `skills/kb-workflow/knowledge-base/`
- 归档目录: `skills/kb-workflow/knowledge-base/archive/`
- 汇报目录: `skills/kb-workflow/knowledge-base/reports/`
### 自定义路径
```python
from kb_workflow import KBWorkflow
# 使用自定义路径
workflow = KBWorkflow(
base_path="/custom/knowledge-base",
archive_path="/custom/archive",
output_format="json"
)
```
## Workflow Steps
### 完整处理流程
1. **扫描收件箱**
- 扫描 `pending/` 目录获取新内容
- 扫描其他阶段目录获取待继续处理的内容
2. **分类处理**
- 新内容 → 提取链接/URL (Skill 2)
- 待提取元数据 → 提取元数据 (Skill 3)
- 待分析内容 → 深度分析 (Skill 4)
3. **自动流转**
- 处理完成后自动移动到下一阶段目录
4. **归档**
- 分析完成后可归档到 `archive/YYYY-MM-DD/`
5. **汇报**
- 生成处理统计
- 提供处理建议
### 定时任务示例
```bash
# 每天早上9点检查并处理新内容
0 9 * * * cd /path/to/skills/kb-workflow && python kb_workflow.py --trigger scheduled --scope pending --report
# 每小时检查订阅更新
0 * * * * cd /path/to/skills/kb-workflow && python kb_workflow.py --trigger subscriptions
```
## Troubleshooting
### 常见问题
**Q: 扫描不到内容?**
A: 确保知识库目录存在且包含正确的子目录 (pending, metadata, content, analyzed)
**Q: 处理失败?**
A: 检查日志输出,使用 `--verbose` 参数获取详细调试信息
**Q: 如何查看处理进度?**
A: 使用 `--trigger status` 查看各阶段的项目数量
## Related Skills
- **obsidian-kb** - Obsidian 知识库管理
- **link-parser** - 链接解析
- **zhihu-metadata** - 知乎元数据提取
- **bilibili-analyzer** - B站视频分析
---
*KB Workflow v1.0 - Knowledge Base Workflow Orchestration*