{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://static-agent-marketplace.org/schemas/draft/entry.schema.json",
  "title": "Static Agent Marketplace entry document",
  "description": "One plugin or skill, published at <base>/entries/<name>.json or <base>/entries/skills/<name>.json. The body equals the matching item of catalog.json plus $schema, kind and specVersion; see sections 7.3, 7.4 and 7.6.",
  "type": "object",
  "required": ["$schema", "kind", "specVersion"],
  "properties": {
    "kind": {"enum": ["plugin", "skill"]}
  },
  "if": {"properties": {"kind": {"const": "plugin"}}},
  "then": {"$ref": "#/$defs/pluginDocument"},
  "else": {"$ref": "#/$defs/skillDocument"},
  "$defs": {
    "name": {
      "description": "Plugin and skill names: the intersection of what every supported host accepts.",
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "maxLength": 64
    },
    "version": {
      "description": "Semantic Versioning 2.0.0 without build metadata.",
      "type": "string",
      "maxLength": 64,
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024
    },
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "httpsUrl": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "relativePath": {
      "description": "A portable archive member path (section 10.3).",
      "type": "string",
      "maxLength": 240,
      "pattern": "^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$",
      "not": {"pattern": "(^|/)\\.{1,2}(/|$)"}
    },
    "file": {
      "type": "object",
      "required": ["path", "bytes", "sha256", "mode"],
      "properties": {
        "path": {"$ref": "#/$defs/relativePath"},
        "bytes": {"type": "integer", "minimum": 0, "maximum": 26214400},
        "sha256": {"$ref": "#/$defs/sha256"},
        "mode": {"enum": ["0644", "0755"]}
      },
      "additionalProperties": false
    },
    "files": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/file"}
    },
    "package": {
      "description": "One downloadable archive.",
      "type": "object",
      "required": ["url", "sha256", "bytes"],
      "properties": {
        "url": {"$ref": "#/$defs/httpsUrl"},
        "sha256": {"$ref": "#/$defs/sha256"},
        "bytes": {"type": "integer", "minimum": 22, "maximum": 104857600}
      },
      "additionalProperties": false
    },
    "author": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "email": {"type": "string"},
        "url": {"type": "string"}
      },
      "additionalProperties": false
    },
    "hook": {
      "type": "object",
      "required": ["event", "type"],
      "properties": {
        "event": {"type": "string", "pattern": "^[A-Z][A-Za-z]+$"},
        "matcher": {"type": "string"},
        "type": {"type": "string"},
        "command": {"type": "string"},
        "url": {"type": "string"},
        "timeout": {"type": "integer", "minimum": 1}
      },
      "additionalProperties": false
    },
    "mcpServer": {
      "description": "An MCP server the plugin starts or connects to. env lists variable names only, never values.",
      "type": "object",
      "required": ["name", "env"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "command": {"type": "string"},
        "url": {"type": "string"},
        "env": {"type": "array", "items": {"type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"}, "uniqueItems": true}
      },
      "additionalProperties": false
    },
    "components": {
      "type": "object",
      "required": ["skills", "agents", "commands", "hooks", "mcpServers"],
      "properties": {
        "skills": {"type": "array", "items": {"$ref": "#/$defs/name"}, "uniqueItems": true},
        "agents": {"type": "array", "items": {"$ref": "#/$defs/relativePath"}, "uniqueItems": true},
        "commands": {"type": "array", "items": {"$ref": "#/$defs/relativePath"}, "uniqueItems": true},
        "hooks": {"type": "array", "items": {"$ref": "#/$defs/hook"}},
        "mcpServers": {"type": "array", "items": {"$ref": "#/$defs/mcpServer"}}
      },
      "additionalProperties": false
    },
    "supportLevel": {"enum": ["native", "partial", "none"]},
    "hosts": {
      "type": "object",
      "required": ["claude", "codex", "grok", "antigravity", "gemini"],
      "properties": {
        "claude": {"$ref": "#/$defs/supportLevel"},
        "codex": {"$ref": "#/$defs/supportLevel"},
        "grok": {"$ref": "#/$defs/supportLevel"},
        "antigravity": {"$ref": "#/$defs/supportLevel"},
        "gemini": {"$ref": "#/$defs/supportLevel"}
      },
      "additionalProperties": false
    },
    "lifecycle": {
      "type": "object",
      "required": ["status"],
      "properties": {
        "status": {"const": "deprecated"},
        "replacedBy": {"$ref": "#/$defs/name"},
        "note": {"type": "string"}
      },
      "additionalProperties": false
    },
    "prompts": {
      "type": "object",
      "propertyNames": {"enum": ["claude", "agent-skills", "codex", "antigravity", "gemini", "grok"]},
      "additionalProperties": {"$ref": "install-prompt.schema.json"}
    },
    "plugin": {
      "description": "A plugin item of catalog.json (section 7.3).",
      "type": "object",
      "required": ["name", "version", "description", "license", "components", "hosts", "files", "packages", "install", "pageUrl", "entryUrl"],
      "properties": {
        "name": {"$ref": "#/$defs/name"},
        "version": {"$ref": "#/$defs/version"},
        "description": {"$ref": "#/$defs/description"},
        "license": {"description": "SPDX license expression.", "type": "string", "minLength": 1},
        "displayName": {"type": "string", "minLength": 1},
        "author": {"$ref": "#/$defs/author"},
        "homepage": {"type": "string"},
        "repository": {"type": "string"},
        "keywords": {"type": "array", "items": {"type": "string"}},
        "category": {"type": "string"},
        "tags": {"type": "array", "items": {"type": "string"}},
        "lifecycle": {"$ref": "#/$defs/lifecycle"},
        "components": {"$ref": "#/$defs/components"},
        "hosts": {"$ref": "#/$defs/hosts"},
        "files": {"$ref": "#/$defs/files"},
        "packages": {
          "type": "object",
          "required": ["claudeArchive"],
          "properties": {
            "claudeArchive": {"$ref": "#/$defs/package"},
            "antigravityArchive": {"$ref": "#/$defs/package"},
            "geminiArchive": {"$ref": "#/$defs/package"}
          },
          "additionalProperties": false
        },
        "install": {
          "type": "object",
          "required": ["prompts"],
          "properties": {
            "prompts": {
              "allOf": [{"$ref": "#/$defs/prompts"}],
              "required": ["claude"]
            }
          },
          "additionalProperties": false
        },
        "pageUrl": {"$ref": "#/$defs/httpsUrl"},
        "entryUrl": {"$ref": "#/$defs/httpsUrl"}
      }
    },
    "skill": {
      "description": "A skill item of catalog.json (section 7.4).",
      "type": "object",
      "required": ["name", "version", "description", "license", "plugin", "files", "packages", "install", "pageUrl", "entryUrl"],
      "properties": {
        "name": {"$ref": "#/$defs/name"},
        "version": {"$ref": "#/$defs/version"},
        "description": {"$ref": "#/$defs/description"},
        "license": {"type": "string", "minLength": 1},
        "plugin": {"$ref": "#/$defs/name"},
        "lifecycle": {"$ref": "#/$defs/lifecycle"},
        "files": {"$ref": "#/$defs/files"},
        "packages": {
          "type": "object",
          "required": ["skillArchive", "claudeAiUpload"],
          "properties": {
            "skillArchive": {"$ref": "#/$defs/package"},
            "claudeAiUpload": {"$ref": "#/$defs/package"}
          },
          "additionalProperties": false
        },
        "install": {
          "type": "object",
          "required": ["prompts"],
          "properties": {
            "prompts": {
              "allOf": [{"$ref": "#/$defs/prompts"}],
              "required": ["agent-skills"]
            }
          },
          "additionalProperties": false
        },
        "pageUrl": {"$ref": "#/$defs/httpsUrl"},
        "entryUrl": {"$ref": "#/$defs/httpsUrl"}
      }
    },
    "documentHeader": {
      "properties": {
        "$schema": {"const": "https://static-agent-marketplace.org/schemas/draft/entry.schema.json"},
        "specVersion": {"type": "string", "pattern": "^0\\.1\\.0(-draft)?$"},
        "kind": {"enum": ["plugin", "skill"]}
      }
    },
    "pluginDocument": {
      "allOf": [{"$ref": "#/$defs/documentHeader"}, {"$ref": "#/$defs/plugin"}],
      "unevaluatedProperties": false
    },
    "skillDocument": {
      "allOf": [{"$ref": "#/$defs/documentHeader"}, {"$ref": "#/$defs/skill"}],
      "unevaluatedProperties": false
    }
  }
}
