{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://synkra.dev/schemas/squad-design.json",
  "title": "Squad Design Blueprint",
  "description": "Schema for squad design blueprints generated by *design-squad",
  "type": "object",
  "required": ["squad", "recommendations", "metadata"],
  "properties": {
    "squad": {
      "type": "object",
      "description": "Basic squad information",
      "required": ["name", "domain"],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*[a-z0-9](-squad)?$",
          "minLength": 2,
          "maxLength": 64,
          "description": "Squad name in kebab-case"
        },
        "description": {
          "type": "string",
          "maxLength": 500,
          "description": "Human-readable description of the squad"
        },
        "domain": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
          "minLength": 2,
          "maxLength": 50,
          "description": "Domain identifier in kebab-case"
        }
      }
    },
    "analysis": {
      "type": "object",
      "description": "Domain analysis results",
      "properties": {
        "entities": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "maxItems": 50,
          "description": "Extracted domain entities"
        },
        "workflows": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
            "minLength": 2,
            "maxLength": 100
          },
          "maxItems": 50,
          "description": "Identified workflows in kebab-case"
        },
        "integrations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "maxItems": 30,
          "description": "External integrations detected"
        },
        "stakeholders": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "maxItems": 20,
          "description": "Stakeholder roles identified"
        }
      }
    },
    "recommendations": {
      "type": "object",
      "description": "Generated recommendations",
      "required": ["agents", "tasks"],
      "properties": {
        "agents": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/agentRecommendation"
          },
          "minItems": 0,
          "maxItems": 10,
          "description": "Recommended agents"
        },
        "tasks": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/taskRecommendation"
          },
          "minItems": 0,
          "maxItems": 50,
          "description": "Recommended tasks"
        },
        "template": {
          "type": "string",
          "enum": ["basic", "etl", "agent-only", "custom"],
          "default": "basic",
          "description": "Recommended squad template"
        },
        "config_mode": {
          "type": "string",
          "enum": ["extend", "override", "none"],
          "default": "extend",
          "description": "Configuration inheritance mode"
        }
      }
    },
    "metadata": {
      "type": "object",
      "description": "Blueprint metadata",
      "required": ["created_at"],
      "properties": {
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "ISO 8601 timestamp of blueprint creation"
        },
        "source_docs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Paths to source documentation files"
        },
        "user_adjustments": {
          "type": "integer",
          "minimum": 0,
          "default": 0,
          "description": "Number of user modifications made"
        },
        "overall_confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Overall confidence score (0-1)"
        }
      }
    }
  },
  "definitions": {
    "agentRecommendation": {
      "type": "object",
      "required": ["id", "role", "confidence"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
          "minLength": 2,
          "maxLength": 64,
          "description": "Agent identifier in kebab-case"
        },
        "role": {
          "type": "string",
          "minLength": 5,
          "maxLength": 200,
          "description": "Agent role description"
        },
        "commands": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
            "minLength": 2,
            "maxLength": 64
          },
          "maxItems": 20,
          "description": "Agent commands in kebab-case"
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Recommendation confidence score (0-1)"
        },
        "user_added": {
          "type": "boolean",
          "default": false,
          "description": "Whether this agent was added by user"
        },
        "user_modified": {
          "type": "boolean",
          "default": false,
          "description": "Whether this agent was modified by user"
        }
      }
    },
    "taskRecommendation": {
      "type": "object",
      "required": ["name", "agent", "confidence"],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
          "minLength": 2,
          "maxLength": 64,
          "description": "Task name in kebab-case (without .md extension)"
        },
        "agent": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
          "minLength": 2,
          "maxLength": 64,
          "description": "Owning agent identifier"
        },
        "entrada": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "maxItems": 20,
          "description": "Task input parameters"
        },
        "saida": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "maxItems": 20,
          "description": "Task output parameters"
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Recommendation confidence score (0-1)"
        },
        "checklist": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "maxItems": 20,
          "description": "Task checklist items"
        }
      }
    }
  },
  "examples": [
    {
      "squad": {
        "name": "order-management-squad",
        "description": "Squad for order management system",
        "domain": "order-management"
      },
      "analysis": {
        "entities": ["Order", "Customer", "Product", "Payment"],
        "workflows": ["create-order", "process-payment", "ship-order"],
        "integrations": ["Stripe API", "Inventory Service"],
        "stakeholders": ["Customer", "Admin", "Support"]
      },
      "recommendations": {
        "agents": [
          {
            "id": "order-manager",
            "role": "Manages order lifecycle from creation to fulfillment",
            "commands": ["create-order", "update-order", "cancel-order"],
            "confidence": 0.92,
            "user_added": false,
            "user_modified": false
          }
        ],
        "tasks": [
          {
            "name": "create-order",
            "agent": "order-manager",
            "entrada": ["customer_id", "items", "payment_method"],
            "saida": ["order_id", "status"],
            "confidence": 0.88
          }
        ],
        "template": "basic",
        "config_mode": "extend"
      },
      "metadata": {
        "created_at": "2025-12-18T00:00:00Z",
        "source_docs": ["./docs/prd/orders.md"],
        "user_adjustments": 2,
        "overall_confidence": 0.87
      }
    }
  ]
}
