{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://extensions.sxnnysideproject.com/schemas/animoriarc.schema.json",
  "title": "Animoria configuration",
  "description": "Workspace-wide governance policy and analysis configuration for Animoria.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON schema URL for editor validation and autocompletion."
    },
    "extends": {
      "description": "Built-in preset to start from; the rules below override it. When an array is given, the first entry is used.",
      "oneOf": [
        {
          "$ref": "#/definitions/preset"
        },
        {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/preset"
          }
        }
      ]
    },
    "files": {
      "type": "object",
      "description": "Filesystem inclusion and ignore filters.",
      "properties": {
        "include": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of glob patterns for files or folders to include in scans."
        },
        "ignore": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of glob patterns for files or folders to ignore during scans. A leading / anchors a pattern to the workspace root; a leading ! re-includes a path (for example \"!/Library/Keep/\" in a Unity project)."
        },
        "ignoreDocs": {
          "type": "boolean",
          "description": "docs/ and doc/ are ignored by default. Set to false to scan them."
        },
        "includeDocs": {
          "type": "boolean",
          "description": "Set to true to scan docs/ and doc/ (same effect as ignoreDocs: false)."
        }
      },
      "additionalProperties": false
    },
    "tracing": {
      "type": "object",
      "description": "Multi-syntax code reference tracing options.",
      "properties": {
        "ignoreSourceExtensions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Source file extensions to exclude from reference detection (e.g. [\"md\", \"mdx\", \"vue\"])."
        },
        "includeSourceExtensions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Additional source file extensions to trace for references (e.g. [\"php\", \"blade\", \"twig\", \"htmx\"])."
        },
        "minStemLength": {
          "type": "integer",
          "minimum": 1,
          "description": "Minimum character length for asset stems matched in code (default: 3)."
        },
        "ignoreComments": {
          "type": "boolean",
          "description": "Not read by the engine today: comment lines are always skipped, in the languages where they are comments."
        },
        "dynamicCollections": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Names of collections whose keys are built at runtime (for example icon maps), so assets under them are treated as dynamically referenced."
        }
      },
      "additionalProperties": false
    },
    "ci": {
      "$ref": "#/definitions/ciGate"
    },
    "overrides": {
      "type": "array",
      "description": "Per-folder rule overrides for monorepos. Each entry applies its rules to assets matching its glob patterns.",
      "items": {
        "type": "object",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            },
            "description": "Glob patterns of the assets this override applies to (for example \"apps/marketing/**\")."
          },
          "rules": {
            "$ref": "#/properties/rules"
          }
        },
        "additionalProperties": false
      }
    },
    "governance": {
      "type": "object",
      "description": "Governance rules and repository policy enforcement.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Enable or disable governance policy evaluation globally."
        },
        "ci": {
          "$ref": "#/definitions/ciGate"
        },
        "rules": {
          "$ref": "#/properties/rules"
        }
      },
      "additionalProperties": false
    },
    "rules": {
      "type": "object",
      "description": "Rule configuration, keyed by rule id. Each value is either a bare severity, a [severity, options] tuple, or a rich rule configuration object.",
      "properties": {
        "no-gif": {
          "description": "Disallows GIF assets in favor of more efficient modern formats.",
          "$ref": "#/definitions/severityOnly"
        },
        "no-unreferenced-assets": {
          "description": "Disallows assets with no detected references in source code.",
          "$ref": "#/definitions/unreferencedRule"
        },
        "no-duplicate-content": {
          "description": "Disallows two assets with byte-identical contents.",
          "$ref": "#/definitions/duplicateRule"
        },
        "no-duplicate-names": {
          "description": "Has no effect: the engine has no filename-based duplicate rule. Use no-duplicate-content (byte-identical files).",
          "$ref": "#/definitions/duplicateRule"
        },
        "max-file-size-kb": {
          "$ref": "#/definitions/fileSizeRule"
        },
        "allowed-formats": {
          "$ref": "#/definitions/allowedFormatsRule"
        },
        "max-dimensions": {
          "$ref": "#/definitions/maxDimensionsRule"
        },
        "naming-convention": {
          "$ref": "#/definitions/namingConventionRule"
        },
        "svg-sanitization": {
          "description": "Flags SVGs containing scripts, XML entities, javascript: URIs, foreignObject, iframe, embed, or inline event handlers.",
          "$ref": "#/definitions/severityOnly"
        }
      },
      "additionalProperties": {
        "description": "A rule id this schema does not yet know about. Animoria's own config loader is the authority on whether it is valid."
      }
    }
  },
  "additionalProperties": false,
  "definitions": {
    "preset": {
      "type": "string",
      "enum": [
        "recommended",
        "strict",
        "relaxed",
        "animoria:recommended",
        "animoria:strict",
        "animoria:relaxed"
      ]
    },
    "ciGate": {
      "type": "object",
      "description": "CI quality gate for `animoria check`.",
      "properties": {
        "minScore": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "Fail when the workspace health score is below this value."
        },
        "maxWarnings": {
          "type": "integer",
          "minimum": 0,
          "description": "Fail (exit code 2) when the number of warnings exceeds this value."
        }
      },
      "additionalProperties": false
    },
    "namingCase": {
      "type": "string",
      "enum": [
        "kebab-case",
        "snake_case",
        "camelCase",
        "PascalCase",
        "lowercase"
      ]
    },
    "maxDimensionsRule": {
      "description": "Flags images larger than the given pixel dimensions.",
      "oneOf": [
        {
          "$ref": "#/definitions/severity"
        },
        {
          "type": "boolean"
        },
        {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "$ref": "#/definitions/severity"
            },
            {
              "type": "object",
              "properties": {
                "maxWidth": {
                  "type": "integer",
                  "minimum": 1
                },
                "maxHeight": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "additionalProperties": false
            }
          ],
          "description": "[severity, { maxWidth, maxHeight }]"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            },
            "maxWidth": {
              "type": "integer",
              "minimum": 1
            },
            "maxHeight": {
              "type": "integer",
              "minimum": 1
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "namingConventionRule": {
      "description": "Requires asset file names to follow a casing or a custom regular expression. Density suffixes such as @2x are stripped first.",
      "oneOf": [
        {
          "$ref": "#/definitions/severity"
        },
        {
          "type": "boolean"
        },
        {
          "$ref": "#/definitions/namingCase"
        },
        {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "$ref": "#/definitions/severity"
            },
            {
              "oneOf": [
                {
                  "$ref": "#/definitions/namingCase"
                },
                {
                  "type": "object",
                  "properties": {
                    "case": {
                      "$ref": "#/definitions/namingCase"
                    },
                    "pattern": {
                      "type": "string",
                      "description": "Regular expression the file name must match."
                    }
                  },
                  "additionalProperties": false
                }
              ]
            }
          ],
          "description": "[severity, casing] or [severity, { case, pattern }]"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            },
            "case": {
              "$ref": "#/definitions/namingCase"
            },
            "pattern": {
              "type": "string",
              "description": "Regular expression the file name must match."
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "severity": {
      "type": "string",
      "enum": [
        "error",
        "warning",
        "warn",
        "info",
        "off"
      ]
    },
    "severityOnly": {
      "oneOf": [
        {
          "$ref": "#/definitions/severity"
        },
        {
          "type": "boolean"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "unreferencedRule": {
      "oneOf": [
        {
          "$ref": "#/definitions/severity"
        },
        {
          "type": "boolean"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            },
            "ignoreAppIcons": {
              "type": "boolean",
              "description": "Ignore application icons across different resolutions (iOS AppIcon.appiconset, Android mipmaps, favicons, etc.)."
            },
            "ignore": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Glob patterns of assets to exempt from unreferenced asset checks."
            },
            "ignoreSourceExtensions": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Source file extensions whose references should NOT count towards marking the asset as used (e.g. [\"md\", \"vue\"])."
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "duplicateRule": {
      "oneOf": [
        {
          "$ref": "#/definitions/severity"
        },
        {
          "type": "boolean"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            },
            "ignoreAppIcons": {
              "type": "boolean",
              "description": "Ignore identical or multi-size app icons in platform catalog directories from being flagged as duplicates."
            },
            "ignore": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Glob patterns of assets to exempt from duplicate checks."
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "fileSizeRule": {
      "description": "Disallows assets larger than a configured size threshold, in kibibytes.",
      "oneOf": [
        {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "A bare limit in KB. Severity is implied \"error\"."
        },
        {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "$ref": "#/definitions/severity"
            },
            {
              "type": "number",
              "exclusiveMinimum": 0
            }
          ],
          "description": "[severity, limitKb]"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            },
            "threshold": {
              "type": "number",
              "exclusiveMinimum": 0,
              "description": "Maximum allowed size in kilobytes."
            },
            "maxKb": {
              "type": "number",
              "exclusiveMinimum": 0,
              "description": "Alias for threshold in kilobytes."
            }
          },
          "additionalProperties": false
        },
        {
          "const": "off"
        }
      ]
    },
    "allowedFormatsRule": {
      "description": "Restricts which visual asset formats are permitted in the workspace.",
      "oneOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/assetFormat"
          },
          "description": "A bare list of permitted formats. Severity is implied \"error\"."
        },
        {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "$ref": "#/definitions/severity"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/definitions/assetFormat"
              }
            }
          ],
          "description": "[severity, formats]"
        },
        {
          "type": "object",
          "properties": {
            "severity": {
              "$ref": "#/definitions/severity"
            },
            "enabled": {
              "type": "boolean"
            },
            "formats": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/assetFormat"
              },
              "description": "List of allowed asset formats."
            }
          },
          "additionalProperties": false
        },
        {
          "const": "off"
        }
      ]
    },
    "assetFormat": {
      "type": "string",
      "enum": [
        "lottie",
        "dotlottie",
        "rive",
        "gif",
        "apng",
        "animated-svg",
        "svg",
        "png",
        "jpg",
        "jpeg",
        "webp",
        "avif",
        "bmp",
        "eps",
        "icns",
        "ico",
        "odd",
        "ps",
        "psd",
        "tiff",
        "tif"
      ]
    }
  }
}