{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.carmenlabs.com/mview/v1/schema.json",
  "title": "Carmen Labs MView Schema",
  "description": "Schema for a Carmen Labs Mutated View (MView).",
  "type": "object",
  "required": [
    "$schema",
    "id",
    "name",
    "version",
    "prompt",
    "runtime",
    "entry"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://schemas.carmenlabs.com/mview/v1/schema.json"
    },
    "id": {
      "type": "string",
      "description": "Unique identifier.",
      "pattern": "^[a-z0-9][a-z0-9._-]*$"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "prompt": {
      "type": "string",
      "description": "Prompt used to generate this MView mutation.",
      "minLength": 1
    },
    "runtime": {
      "type": "object",
      "description": "Rendering runtime required by this MView.",
      "required": [
        "environment",
        "renderer"
      ],
      "properties": {
        "environment": {
          "type": "string",
          "description": "Execution environment for the view.",
          "enum": [
            "web",
            "desktop",
            "terminal",
            "other"
          ]
        },
        "renderer": {
          "type": "string",
          "description": "Renderer adapter, framework, or output target required to render the component.",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "description": "Optional semver range for the renderer."
        }
      },
      "additionalProperties": false
    },
    "author": {
      "type": "string"
    },
    "license": {
      "type": "string"
    },
    "icon": {
      "type": "string"
    },
    "accepts": {
      "type": "array",
      "description": "Capabilities required by this MView.",
      "items": {
        "type": "string",
        "enum": [
          "text",
          "document",
          "markdown",
          "html",
          "table",
          "tree",
          "graph",
          "timeseries",
          "image",
          "binary",
          "structured",
          "key-value",
          "filesystem",
          "code",
          "log",
          "dataset",
          "geo",
          "audio",
          "video",
          "custom"
        ]
      },
      "uniqueItems": true
    },
    "source": {
      "type": "object",
      "description": "Optional source resource associated with this MView.",
      "required": [
        "path"
      ],
      "properties": {
        "path": {
          "type": "string",
          "description": "Relative path to the source file associated with this MView."
        },
        "contentHash": {
          "type": "string",
          "description": "Optional hash of the source file when this MView was created or last validated."
        }
      },
      "additionalProperties": false
    },
    "entry": {
      "type": "object",
      "required": [
        "parser",
        "component"
      ],
      "properties": {
        "parser": {
          "type": "string",
          "description": "Relative path to parser module."
        },
        "component": {
          "type": "string",
          "description": "Relative path to view component."
        }
      },
      "additionalProperties": false
    },
    "resources": {
      "type": "object",
      "description": "Optional resource paths required by this MView.",
      "properties": {
        "path": {
          "type": "string",
          "description": "Relative path to the resources directory.",
          "default": "./resources"
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "type": "object",
      "description": "Default settings exposed to the component.",
      "default": {}
    },
    "metadata": {
      "type": "object",
      "description": "Additional implementation-specific metadata.",
      "default": {}
    }
  },
  "additionalProperties": false
}
