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 f41fb6167d feat(kb-workflow): Add Git version control and cleanup
## Git Version Management
- Git repository in archive/ directory
- Environment variables for configuration (KB_GIT_ROOT, KB_GIT_REMOTE, etc.)
- Auto commit after archive with retry (3 attempts)
- Status command shows git status

## Subscription Management
- Subscriptions stored in archive/subscriptions/
- Track processed items to avoid duplicates
- Git tracked for history

## Automatic Cleanup
- Cleanup strategy based on file type and age
- video/frame retention: 7 days
- metadata/reports: permanent
- archive/: Git managed

## New Commands
- --trigger git-init: Initialize git repository
- --trigger git-status: Show git status
- --trigger cleanup: Clean expired temporary files
2026-02-10 16:09:50 +08:00

5.1 KiB
Raw Blame History

name, description, metadata
name description metadata
kb-workflow 知识库工作流编排技能,提供收件箱扫描、内容处理、归档、订阅检测、Git版本管理和自动清理功能。
short-description
知识库工作流编排

KB Workflow

Description

KB Workflow 是一个完整的知识库管理系统,包含:

核心功能:

  • 📥 收件箱扫描 - 扫描四个子目录 (pending, metadata, content, analyzed)
  • 🔄 内容处理 - 调用技能2-4处理内容
  • 📦 Git版本管理 - 归档后自动提交并推送
  • 🔔 订阅管理 - 跟踪订阅源更新
  • 🧹 自动清理 - 定期清理临时文件
  • 📊 汇报生成 - 生成处理统计

目录结构

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版本管理

配置

设置环境变量:

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状态

订阅管理

数据结构

{
  "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
    }
  ]
}

命令

# 添加订阅
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天

命令

# 清理30天前的临时文件
python kb_workflow.py --trigger cleanup --days 30

# 清理单个项目
python kb_workflow.py --trigger cleanup --project "项目名称"

Usage

命令行用法

# 查看状态
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)

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未初始化

# 检查配置
python kb_workflow.py --trigger git-status

# 初始化
export KB_GIT_ROOT="/path/to/archive"
python kb_workflow.py --trigger git-init

推送失败

  • 检查网络连接
  • 验证远程仓库权限
  • 查看错误日志

存储空间过大

# 清理过期文件
python kb_workflow.py --trigger cleanup --days 7

# 查看存储使用情况
python kb_workflow.py --trigger status
  • kb-link-parser - 链接解析
  • kb-bilibili-metadata - B站元数据
  • kb-bilibili-content - B站内容获取
  • kb-deep-analyzer - 深度分析