{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "@bedrock-core project configuration",
  "description": "Minecraft Bedrock project metadata and @bedrock-core profiles.",
  "type": "object",
  "not": {
    "required": [
      "namespace"
    ]
  },
  "required": [
    "targetVersion",
    "name",
    "authors",
    "packs",
    "bedrockCore"
  ],
  "additionalProperties": true,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "targetVersion": {
      "$ref": "#/definitions/nonempty"
    },
    "name": {
      "$ref": "#/definitions/nonempty"
    },
    "description": {
      "type": "string"
    },
    "authors": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "logo": {
                "type": "string"
              }
            }
          }
        ]
      }
    },
    "experimentalGameplay": {
      "type": "object",
      "additionalProperties": {
        "type": "boolean"
      }
    },
    "packs": {
      "type": "object",
      "minProperties": 1,
      "description": "Named pack paths. Manifest modules determine pack type, not names.",
      "propertyNames": {
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
      },
      "additionalProperties": {
        "$ref": "#/definitions/nonempty"
      }
    },
    "packDefinitions": {
      "type": "object",
      "properties": {
        "families": {
          "$ref": "#/definitions/packDefinition"
        },
        "tags": {
          "$ref": "#/definitions/packDefinition"
        },
        "scoreboardObjectives": {
          "$ref": "#/definitions/packDefinition"
        },
        "names": {
          "$ref": "#/definitions/packDefinition"
        }
      }
    },
    "bedrockCore": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "formatVersion",
        "profiles"
      ],
      "properties": {
        "formatVersion": {
          "const": "1.0.0"
        },
        "plugins": {
          "type": "object",
          "propertyNames": {
            "$ref": "#/definitions/nonempty"
          },
          "additionalProperties": {
            "$ref": "#/definitions/plugin"
          }
        },
        "profiles": {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "$ref": "#/definitions/nonempty"
          },
          "additionalProperties": {
            "$ref": "#/definitions/profile"
          }
        },
        "staging": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "include": {
              "type": "array",
              "uniqueItems": true,
              "items": { "$ref": "#/definitions/nonempty" },
              "description": "Additional literal project-relative files or directories copied into staging and observed by watch mode, including plugin data read without imports."
            },
            "exclude": {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "$ref": "#/definitions/nonempty"
              },
              "description": "Literal project-relative files or directories omitted from staging and watch mode. Configuration files and complete pack sources cannot be excluded."
            }
          }
        }
      }
    }
  },
  "definitions": {
    "pretty": {
      "anyOf": [
        {
          "const": false
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "indent": {
              "enum": [
                "tab",
                "space"
              ]
            },
            "size": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      ]
    },
    "nonempty": {
      "type": "string",
      "pattern": "\\S"
    },
    "plugin": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "module"
          ],
          "properties": {
            "module": {
              "$ref": "#/definitions/nonempty",
              "description": "Local TS/JS module or npm package exporting run(context, settings)."
            },
            "scope": {
              "enum": [
                "pack",
                "project"
              ],
              "description": "Plugins declaring requirements run per owner unless project scope is selected."
            },
            "packs": {
              "$ref": "#/definitions/packIds",
              "description": "Restrict eligible owners to these configured pack IDs."
            },
            "links": {
              "$ref": "#/definitions/packLinks",
              "description": "Owner pack IDs and named plugin requirements mapped to direct dependencies."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "script"
          ],
          "properties": {
            "script": {
              "$ref": "#/definitions/nonempty",
              "description": "Standalone Node entry point, relative to filterDir, using the Regolith BP/RP/data contract."
            },
            "filterDir": {
              "$ref": "#/definitions/nonempty",
              "description": "Script definition directory, relative to config.json. Defaults to the project root and sets FILTER_DIR."
            },
            "dataPath": {
              "$ref": "#/definitions/nonempty",
              "description": "Project-relative authored data source. Steps using the same source share its working copy; distinct sources remain independent. Defaults to ./data when present."
            },
            "nodeArguments": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Node flags before the script, such as loader flags."
            },
            "folders": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "BP": {
                  "$ref": "#/definitions/nonempty"
                },
                "RP": {
                  "$ref": "#/definitions/nonempty"
                }
              },
              "description": "Temporary BP/RP folders mapped to configured pack IDs. Omission infers one behavior and one resource pack; an empty map selects data-only processing."
            },
            "persistData": {
              "type": "boolean",
              "description": "Write an explicit dataPath back after successful pack validation and publication. Defaults to false."
            }
          }
        }
      ]
    },
    "packDefinition": {
      "type": "object",
      "required": [
        "include",
        "exclude"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "include": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "exclude": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "stage": {
      "anyOf": [
        {
          "const": "auto"
        },
        {
          "type": "boolean"
        },
        {
          "type": "object"
        }
      ],
      "description": "Omission or auto detects inputs; false disables; true or settings enables the stage even without detected inputs."
    },
    "profile": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pretty": {
          "$ref": "#/definitions/pretty",
          "description": "Generated JSON formatting inherited by stages; an explicit stage value replaces it."
        },
        "debug": {
          "type": "boolean",
          "description": "Debug output inherited by stages that use it; an explicit stage value replaces it."
        },
        "export": {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
          },
          "additionalProperties": {
            "$ref": "#/definitions/nonempty"
          },
          "description": "Map each configured pack ID to its exact destination folder. Paths resolve relative to config.json; absolute paths and environment variables (%VAR%, $VAR, ${VAR}) are supported. Unset or empty variables fail before plugins execute."
        },
        "stages": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "manifest": {
              "anyOf": [
                {
                  "const": "auto"
                },
                {
                  "type": "boolean"
                },
                {
                  "$ref": "./manifest.schema.json"
                }
              ],
              "description": "Omission or auto detects inputs; false disables; true or settings enables the stage even without detected inputs."
            },
            "generator": {
              "anyOf": [
                {
                  "const": "auto"
                },
                {
                  "type": "boolean"
                },
                {
                  "$ref": "./generator.schema.json"
                }
              ],
              "description": "Omission or auto detects inputs; false disables; true or settings enables the stage even without detected inputs."
            },
            "guides": {
              "anyOf": [
                {
                  "const": "auto"
                },
                {
                  "type": "boolean"
                },
                {
                  "$ref": "./guides.schema.json"
                }
              ]
            },
            "i18n": {
              "anyOf": [
                {
                  "const": "auto"
                },
                {
                  "type": "boolean"
                },
                {
                  "$ref": "./i18n.schema.json"
                }
              ],
              "description": "Omission or auto detects inputs; false disables; true or settings enables the stage even without detected inputs."
            },
            "ui-compiler": {
              "anyOf": [
                {
                  "const": "auto"
                },
                {
                  "type": "boolean"
                },
                {
                  "$ref": "./ui-compiler.schema.json"
                }
              ]
            },
            "bundler": {
              "anyOf": [
                {
                  "const": "auto"
                },
                {
                  "type": "boolean"
                },
                {
                  "$ref": "./bundler.schema.json"
                }
              ],
              "description": "Omission or auto detects inputs; false disables; true or settings enables the stage even without detected inputs."
            }
          }
        },
        "steps": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/step"
          }
        },
        "watch": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "debounceMs": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000
            },
            "paths": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/nonempty"
              }
            }
          }
        },
        "cache": {
          "type": "boolean",
          "default": true,
          "description": "Reuse deterministic compiler output when its inputs match. Set false to rebuild it."
        },
        "validation": {
          "enum": ["strict", "warn", "skip"],
          "default": "warn",
          "description": "Content schema validation mode. JSON syntax and pack manifests are always checked."
        },
        "api": {
          "description": "Portable addon API package output; defaults to dist/api when public addon exports are declared. Set false to disable.",
          "anyOf": [
            {
              "const": false
            },
            {
              "type": "string",
              "pattern": "\\S"
            }
          ]
        }
      }
    },
    "step": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "plugin"
      ],
      "oneOf": [
        {
          "required": [
            "before"
          ]
        },
        {
          "required": [
            "after"
          ]
        }
      ],
      "properties": {
        "mode": {
          "enum": [
            "auto",
            "always"
          ],
          "description": "Module plugins use their optional detect(context, settings) in auto mode. Omission always runs the step."
        },
        "plugin": {
          "$ref": "#/definitions/nonempty"
        },
        "before": {
          "enum": [
            "manifest",
            "generator",
            "guides",
            "i18n",
            "ui-compiler",
            "bundler",
            "export"
          ]
        },
        "after": {
          "enum": [
            "prepare",
            "manifest",
            "generator",
            "guides",
            "i18n",
            "ui-compiler",
            "bundler"
          ]
        },
        "settings": {
          "type": "object"
        },
        "arguments": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Script arguments following nonempty JSON settings. With empty settings, they start at argv[2]."
        },
        "packs": {
          "$ref": "#/definitions/packIds"
        },
        "links": {
          "$ref": "#/definitions/packLinks"
        },
        "folders": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "BP": {
              "$ref": "#/definitions/nonempty"
            },
            "RP": {
              "$ref": "#/definitions/nonempty"
            }
          },
          "description": "Temporary BP/RP folders mapped to configured pack IDs. Omission infers one behavior and one resource pack; an empty map selects data-only processing."
        },
        "dataPath": {
          "$ref": "#/definitions/nonempty"
        },
        "persistData": {
          "type": "boolean"
        }
      }
    },
    "packIds": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "#/definitions/nonempty"
      }
    },
    "packLinks": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": {
          "anyOf": [
            {
              "$ref": "#/definitions/nonempty"
            },
            {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "$ref": "#/definitions/nonempty"
              }
            }
          ]
        }
      }
    }
  }
}
