{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://commonagents.io/schema/caf-1.0.schema.json",
  "title": "Common Agent Format 1.0 frontmatter",
  "description": "Frontmatter of an AGENT.md file. Does not check that name matches the directory name or that bundled skills exist.",
  "type": "object",
  "required": ["name", "description"],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "description": { "type": "string", "minLength": 1, "maxLength": 1024 },
    "caf": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+$" },
    "version": { "type": "string", "minLength": 1 },
    "license": { "type": "string", "minLength": 1 },
    "model": { "type": "string", "minLength": 1 },
    "effort": { "enum": ["low", "medium", "high"] },
    "tools": { "$ref": "#/$defs/toolList" },
    "disallowed-tools": { "$ref": "#/$defs/toolList" },
    "max-turns": { "type": "integer", "minimum": 1 },
    "skills": {
      "type": "array",
      "items": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "maxLength": 64 },
      "uniqueItems": true
    },
    "mcp-servers": {
      "type": "object",
      "additionalProperties": { "$ref": "#/$defs/mcpServer" }
    },
    "invocation": {
      "type": "object",
      "properties": {
        "user": { "type": "boolean" },
        "model": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "compatibility": { "type": "string", "minLength": 1, "maxLength": 500 },
    "metadata": {
      "type": "object",
      "additionalProperties": { "type": "string" }
    },
    "harness": {
      "type": "object",
      "propertyNames": { "pattern": "^[a-z0-9]+([.-][a-z0-9]+)*$" },
      "additionalProperties": { "$ref": "#/$defs/harnessEntry" }
    }
  },
  "$defs": {
    "toolList": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^(\\*|read|search|edit|execute|web|agent|todo|mcp:[A-Za-z0-9_.-]+(/[A-Za-z0-9_.*-]+)?)$"
      }
    },
    "stringMap": {
      "type": "object",
      "additionalProperties": { "type": "string" }
    },
    "mcpServer": {
      "type": "object",
      "properties": {
        "command": { "type": "string", "minLength": 1 },
        "args": { "type": "array", "items": { "type": "string" } },
        "env": { "$ref": "#/$defs/stringMap" },
        "url": { "type": "string", "format": "uri" },
        "headers": { "$ref": "#/$defs/stringMap" }
      },
      "oneOf": [
        { "required": ["command"], "not": { "required": ["url"] } },
        { "required": ["url"], "not": { "required": ["command"] } }
      ]
    },
    "harnessEntry": {
      "type": "object",
      "properties": {
        "enabled": { "type": "boolean" },
        "settings": { "type": "object" },
        "path": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    }
  }
}
