{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kazokuai.dev/spec/1/manifest.schema.json",
  "title": "Game package manifest, contract 1",
  "description": "manifest.json at the root of a game package's zip. SPEC.md §2 is the text this schema follows, field for field.",
  "type": "object",
  "required": ["contract", "id", "name", "version", "entry", "icon", "aspect", "inputs", "save", "score", "music", "author"],
  "additionalProperties": false,
  "properties": {
    "contract": {
      "description": "The contract this package speaks.",
      "type": "integer",
      "const": 1
    },
    "id": {
      "description": "The package's identity and the scores key. It never changes.",
      "$ref": "#/$defs/slug"
    },
    "name": {
      "description": "The game's name, as the tile shows it.",
      "type": "string",
      "minLength": 1
    },
    "version": {
      "description": "This build's version, semver 2.0.",
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
    },
    "entry": {
      "description": "The page the host loads: always index.html at the root in contract 1.",
      "type": "string",
      "const": "index.html"
    },
    "icon": {
      "description": "The tile's image, a path inside the package.",
      "$ref": "#/$defs/path",
      "type": "string",
      "pattern": "\\.(png|svg|webp)$"
    },
    "aspect": {
      "description": "The shapes the game can lay out to.",
      "type": "array",
      "items": { "enum": ["portrait", "wide"] },
      "minItems": 1,
      "uniqueItems": true
    },
    "inputs": {
      "description": "What the game can be played with.",
      "type": "array",
      "items": { "enum": ["touch", "keys", "pad"] },
      "minItems": 1,
      "uniqueItems": true
    },
    "save": {
      "description": "The game keeps a save (the save message).",
      "type": "boolean"
    },
    "score": {
      "description": "high: the game sends score and higher is better; none: no scores.",
      "enum": ["high", "none"]
    },
    "music": {
      "description": "The game asks the host for music by playlist name.",
      "type": "boolean"
    },
    "audience": {
      "description": "Who the game is for; absent means all.",
      "enum": ["all", "adult"]
    },
    "songs": {
      "description": "The briefs the game's songs were made from, never the audio.",
      "type": "array",
      "items": { "$ref": "#/$defs/song" }
    },
    "story": {
      "description": "The game's story as markdown, a path inside the package.",
      "$ref": "#/$defs/path",
      "type": "string",
      "pattern": "\\.md$"
    },
    "author": {
      "description": "Who made it.",
      "type": "string",
      "minLength": 1
    }
  },
  "$defs": {
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "minLength": 1,
      "maxLength": 64
    },
    "path": {
      "description": "A relative path inside the package: '/' separators, no leading '/', no '..' segment, no scheme, no backslash.",
      "type": "string",
      "minLength": 1,
      "pattern": "^(?![A-Za-z][A-Za-z0-9+.-]*:)(?!/)(?!(?:.*/)?\\.\\.(?:/|$))[^\\\\\\u0000-\\u001f]+$"
    },
    "song": {
      "type": "object",
      "required": ["id", "playlist", "brief", "mood", "lyrics"],
      "additionalProperties": false,
      "properties": {
        "id": { "description": "The song's identity within the package.", "$ref": "#/$defs/slug" },
        "playlist": { "description": "The playlist it belongs to: the name the game asks for.", "type": "string", "minLength": 1 },
        "brief": { "description": "The text the song was made from.", "type": "string", "minLength": 1 },
        "mood": { "description": "Mood words for the music model.", "type": "array", "items": { "type": "string" } },
        "lyrics": { "description": "The song has words.", "type": "boolean" }
      }
    }
  }
}
