{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Agent Skill Workflow Definition",
  "description": "Schema for defining prerequisite workflows in Skill Manager",
  "type": "object",
  "properties": {
    "enabled": {
      "type": "boolean",
      "default": true,
      "description": "Whether this workflow is active"
    },
    "description": {
      "type": "string",
      "description": "Human-readable description of the workflow"
    },
    "triggers": {
      "type": "object",
      "description": "Conditions that activate this workflow (OR logic - any match triggers)",
      "properties": {
        "category": {
          "type": "string",
          "description": "Tool category that triggers this workflow"
        },
        "tools": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Specific tool names that trigger this workflow"
        },
        "keywords": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Keywords in task text that trigger this workflow"
        }
      }
    },
    "prerequisites": {
      "type": "array",
      "description": "Steps to execute before the main action",
      "items": {
        "type": "object",
        "required": ["step", "tool", "description"],
        "properties": {
          "step": {
            "type": "integer",
            "minimum": 1,
            "description": "Execution order (1-based)"
          },
          "tool": {
            "type": "string",
            "description": "Tool name to execute"
          },
          "description": {
            "type": "string",
            "description": "Why this prerequisite is needed"
          },
          "required": {
            "type": "boolean",
            "default": true,
            "description": "Whether this step can be skipped"
          },
          "params": {
            "type": "object",
            "description": "Default parameters for this tool"
          }
        }
      }
    },
    "mode": {
      "type": "string",
      "enum": ["enforce", "warn", "suggest"],
      "default": "enforce",
      "description": "How strictly to apply prerequisites: enforce (auto-run), warn (ask), suggest (mention only)"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "When this workflow was created"
    }
  },
  "required": ["description", "triggers", "prerequisites"]
}
