{
  "name": "check_agent",
  "title": "智能体检查",
  "description": "检查智能体提示词是否符合格式规范、内容规范和安全规范，输出检查报告",
  "group": "agent",
  "version": "1.0.0",
  "input_schema": {
    "type": "object",
    "properties": {
      "task": {
        "type": "string",
        "description": "需要执行的任务描述"
      },
      "agent_name": {
        "type": "string",
        "description": "智能体名称（英文名，唯一标识）"
      },
      "agent_dir": {
        "type": "string",
        "description": "智能体目录路径，用于定位 agent.md 文件"
      }
    },
    "required": ["task", "agent_name", "agent_dir"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "content": {
        "type": "string",
        "description": "检查报告内容"
      }
    }
  },
  "steps": [
    {
      "id": "check_input",
      "description": "校验智能体名称非空",
      "operator": "validator",
      "handler": "required",
      "params": {
        "field": "agent_name",
        "value": "{{ $input.agent_name }}"
      }
    },
    {
      "id": "check_exists",
      "description": "检查 agent.md 文件是否存在",
      "operator": "manager",
      "handler": "file",
      "params": {
        "action": "exists",
        "file_path": "{{ $input.agent_dir }}/agent.md"
      }
    },
    {
      "id": "branch_exists",
      "description": "文件存在则读取检查，否则生成缺失报告",
      "operator": "dispatcher",
      "handler": "condition",
      "params": {
        "source": "{{ $steps.check_exists.result.obj }}",
        "operator": "truthy",
        "then_jump": "read_md",
        "else_jump": "gen_missing"
      }
    },
    {
      "id": "read_md",
      "description": "读取 agent.md 文件内容",
      "operator": "manager",
      "handler": "file",
      "on_error": "gen_missing",
      "params": {
        "action": "read",
        "file_path": "{{ $input.agent_dir }}/agent.md"
      }
    },
    {
      "id": "generate",
      "description": "逐项检查格式规范、内容规范、安全规范并计算得分",
      "operator": "executor",
      "handler": "llm",
      "on_error": {
        "retry": 2,
        "retry_delay": 500
      },
      "params": {
        "system_prompt": "{{ $meta.system_prompt }}",
        "user_prompt": "检查智能体：{{ $input.agent_name }}\n智能体目录：{{ $input.agent_dir }}\n任务说明：{{ $input.task }}\n\n以下是 agent.md 文件内容：\n\n{{ $steps.read_md.result.obj }}\n\n请按检查规范逐项检查格式规范、内容规范、安全规范，汇总各维度得分，生成检查报告和摘要。"
      }
    },
    {
      "id": "validate",
      "description": "校验检查结果非空",
      "operator": "validator",
      "handler": "required",
      "params": {
        "field": "content",
        "value": "{{ $steps.generate.content }}"
      }
    },
    {
      "id": "check_valid",
      "description": "校验失败则中止，成功则结束",
      "operator": "dispatcher",
      "handler": "condition",
      "params": {
        "source": "{{ $steps.validate.valid }}",
        "operator": "truthy",
        "then_jump": "end",
        "else_jump": "end"
      }
    },
    {
      "id": "gen_missing",
      "description": "agent.md 缺失时生成缺失记录报告",
      "operator": "executor",
      "handler": "llm",
      "on_error": {
        "retry": 2,
        "retry_delay": 500
      },
      "params": {
        "system_prompt": "{{ $meta.system_prompt }}",
        "user_prompt": "检查智能体：{{ $input.agent_name }}\n智能体目录：{{ $input.agent_dir }}\n任务说明：{{ $input.task }}\n\n检查结果：agent.md 文件不存在。\n请按检查规范记录该检查项为缺失，并生成检查报告和摘要。"
      }
    }
  ]
}
