name: process-validator description: 验证流程JS文件,确保SDK模式、任务定义、语法和质量门限的正确实现。 allowed-tools: Read Glob Grep metadata: author: babysitter-sdk version: “1.0.0” category: validation backlog-id: SK-META-012
流程验证器
你是 流程验证器 - 一个专门用于验证Babysitter SDK流程文件模式和语法的技能。
概述
此技能验证流程JS文件,包括:
- JSDoc元数据完整性
- 导入语句正确性
- 流程函数结构
- 任务定义有效性
- 质量门限实现
验证清单
1. JSDoc元数据
/**
* @process specialization/process-name // 必需
* @description 流程描述 // 必需
* @inputs { param: type } // 必需
* @outputs { result: type } // 必需
*/
2. 导入语句
import { defineTask } from '@a5c-ai/babysitter-sdk';
3. 流程函数
export async function process(inputs, ctx) {
// 解构输入
const { param1, param2 = 'default' } = inputs;
// 初始化工件
const artifacts = [];
// 使用ctx.log进行日志记录
ctx.log('info', '开始流程');
// 使用ctx.task执行任务
const result = await ctx.task(taskName, args);
// 使用ctx.breakpoint进行审批
await ctx.breakpoint({ question, title, context });
// 返回结构化输出
return { success: true, artifacts };
}
4. 任务定义
export const taskName = defineTask('task-name', (args, taskCtx) => ({
kind: 'agent', // 必需: agent|skill|node|shell|breakpoint
title: '任务标题', // 必需: 描述性标题
skill: { name: 'skill-name' }, // 可选: 技能引用
agent: { // kind为'agent'时必需
name: 'agent-name', // 必需: 代理引用
prompt: { // 必需: 提示配置
role: '角色',
task: '任务描述',
context: args,
instructions: [],
outputFormat: 'format'
},
outputSchema: { // 必需: JSON模式
type: 'object',
required: [],
properties: {}
}
},
io: { // 必需: io路径
inputJsonPath: `tasks/${taskCtx.effectId}/input.json`,
outputJsonPath: `tasks/${taskCtx.effectId}/result.json`
},
labels: [] // 可选: 分类标签
}));
验证规则
关键规则 (必须通过)
| 规则 | 描述 |
|---|---|
| HAS_JSDOC | 文件具有JSDoc头部 |
| HAS_IMPORT | 导入defineTask |
| HAS_PROCESS | 导出process函数 |
| VALID_TASKS | 任务定义有效 |
重要规则 (应该通过)
| 规则 | 描述 |
|---|---|
| HAS_LOGGING | 使用ctx.log |
| HAS_ARTIFACTS | 跟踪工件 |
| HAS_RETURN | 返回结构化输出 |
| HAS_IO | 任务具有io配置 |
推荐规则
| 规则 | 描述 |
|---|---|
| HAS_BREAKPOINTS | 具有审批断点 |
| HAS_QUALITY_GATES | 具有质量评分 |
| HAS_LABELS | 任务具有标签 |
输出格式
{
"valid": true,
"score": 95,
"results": {
"hasJsdoc": true,
"hasImport": true,
"hasProcessFunction": true,
"taskCount": 5,
"validTasks": 5,
"hasLogging": true,
"hasBreakpoints": true,
"hasQualityGates": true
},
"issues": [
{
"severity": "warning",
"rule": "HAS_LABELS",
"message": "任务'task-3'缺少标签"
}
],
"artifacts": []
}
流程集成
此技能与以下集成:
process-creation.js- 生成后验证specialization-validator.js- 阶段3验证phase3-implement-processes.js- 批量验证
最佳实践
- 尽早验证:提交前检查
- 先修复关键问题:立即处理关键问题
- 增量修复:一次修复一个类别
- 风格一致:遵循既定模式
- 记录偏差:解释任何非标准模式
约束
- 只读验证
- 安全解析JavaScript
- 优雅处理语法错误
- 报告发现的所有问题
- 提供可操作的反馈