maxoreric/sop-engine

No description

0 stars0 forksUpdated Jan 20, 2026
npx skills add maxoreric/sop-engine

README

sop-engine

🚀 AI 驱动的 SOP(标准操作流程)引擎 - 人说想法,Claude 写/执行 Skill,产出结果

License: MIT Runtime Tests

🎯 核心理念

sop-engine 的「用户」是 Claude,不是人。

  • 人只需表达意图
  • Claude 负责创建 Skill、编排 Workflow、执行任务
  • 判别式交互:做选择题,不做填空题

✨ 特性

  • 🔄 Workflow 编排 - 用有向图定义复杂的任务流程
  • 🧩 可复用 Skills - 22 个 Core Skills,像函数一样组合
  • 🤖 智能交互 - 判别式交互,最大信息增益
  • 📊 状态管理 - 完整的执行状态追踪和恢复
  • 定时触发 - 支持 cron 格式的定时任务
  • 🔁 循环和分支 - 支持条件判断和循环执行
  • 已验证 - Runtime 测试 39/40 通过

🚀 快速开始

安装依赖

# macOS
brew install jq yq

# 验证安装
jq --version
yq --version

运行测试

# 基础功能测试 (16/16 通过)
./test-runtime-basic.sh

# 状态管理测试 (16/16 通过)
./test-state-manager.sh

# Workflow 执行测试 (7/8 通过)
./test-executor.sh

创建第一个 Workflow

  1. 定义 Workflow (.sop-engine/workflows/hello.yaml)
workflow:
  name: hello-world
  description: 第一个 Workflow
  
  nodes:
    greet:
      type: skill
      skill: clarify-skill
      input:
        question: "Hello, World!"
  
  edges:
    - from: greet
      to: END
  
  entry: greet
  exit: END

trigger:
  type: manual
  1. 执行 Workflow
.sop-engine/runtime/dispatcher.sh start hello-world '{}'

📚 核心概念

Workflow = 有向图

节点(Node)= Skill / Workflow / Condition / Loop / Parallel
边(Edge)= 控制流

示例:
  collect_data → analyze → check_score → generate_report → END
                              ↓ (score < 60)
                           alert_user → END

22 个 Core Skills

类别Skills
理解clarify-skill
认知research-skill, plan-skill, evaluate-skill, reflect-skill
协作handoff-skill
记忆log-skill
自省create-skill, iterate-skill, version-skill
控制loop-skill
开发claude-code-dev, hook-skill
编排skill-lifecycle
设计system-create-skill, workflow-define-skill, agent-define-skill
交互user-confirm-skill
汇总synthesize-skill, summarize-skill

判别式交互

❌ 错误(生成式): "你想要什么功能?请详细描述。"

✅ 正确(判别式): "我设计了这个方案:
   - 功能 A
   - 功能 B
   - 功能 C
   这个方案符合你的预期吗?
   A. ✅ 符合,开始执行
   B. ❌ 需要调整"

🏗️ 项目结构

sop-engine/
├── .claude/                    # Claude Code 配置
│   ├── skills/                 # Skills 定义(22 个)
│   ├── agents/                 # Subagents
│   └── commands/               # Slash commands
│
├── .sop-engine/                # Runtime 数据
│   ├── runtime/                # Runtime 脚本(8 个)✅
│   │   ├── executor.sh         # Workflow 执行器
│   │   ├── dispatcher.sh       # 调度器
│   │   ├── state-manager.sh    # 状态管理
│   │   ├── skill-runner.sh     # Skill 执行器
│   │   ├── tick.sh             # 定时触发
│   │   ├── event-listener.sh   # 事件监听
│   │   ├── utils.sh            # 工具函数
│   │   └── config.sh           # 配置
│   │
│   ├── workflows/              # Workflow 定义
│   ├── running/                # 运行中的实例
│   ├── completed/              # 已完成的实例
│   └── failed/                 # 失败的实例
│
├── docs/                       # 文档
│   ├── DESIGN.md               # 设计文档
│   ├── RUNTIME-TEST-REPORT.md  # 测试报告 ✅
│   └── CAPABILITY-MAP.md       # 能力图谱
│
└── test-*.sh                   # 测试脚本 ✅

📖 使用指南

创建 Skill

# 使用 create-skill 命令
/create-skill 数据分析

定义 Workflow

支持的节点类型:

  1. skill - 执行 Skill
  2. workflow - 嵌套 Workflow
  3. condition - 条件分支
  4. loop - 循环控制
  5. parallel - 并行执行

完整示例:

workflow:
  name: data-pipeline
  
  nodes:
    collect:
      type: skill
      skill: data-collect-skill
      input:
        date: $workflow.input.date
    
    analyze:
      type: skill
      skill: data-analyze-skill
      input:
        data: $collect.output
    
    check:
      type: condition
      expression: "$analyze.output.score >= 80"
    
    success:
      type: skill
      skill: report-skill
    
    failure:
      type: skill
      skill: alert-skill
  
  edges:
    - from: collect
      to: analyze
    - from: analyze
      to: check
    - from: check
      to: success
      condition: true
    - from: check
      to: failure
      condition: false
    - from: success
      to: END
    - from: failure
      to: END
  
  entry: collect
  exit: END

trigger:
  type: manual

触发方式

  1. 手动触发
.sop-engine/runtime/dispatcher.sh start workflow-name '{"param":"value"}'
  1. 定时触发
trigger:
  type: tick
  schedule: "21:00"  # 每天 21:00
  # 或 cron 格式
  schedule: "0 */6 * * *"  # 每 6 小时
  1. 文件触发
trigger:
  type: file_upload
  path: "data/reports/*.pdf"

🧪 测试结果

Runtime 测试:39/40 通过 (97.5%) ✅

测试模块通过/总数状态
配置和工具函数16/16✅ 完全通过
状态管理器16/16✅ 完全通过
Workflow 执行器7/8✅ 基本通过

详见 测试报告

已验证功能

  • ✅ 配置系统
  • ✅ 状态管理
  • ✅ Skill 执行
  • ✅ 顺序 Workflow
  • ✅ 条件分支
  • ✅ 循环控制

📊 实现状态

Runtime 组件 ✅ (100%)

  • 配置系统 (config.sh)
  • [

...

Read full README

Publisher

maxorericmaxoreric

Statistics

Stars0
Forks0
Open Issues0
CreatedJan 20, 2026