{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "/schemas/chroma/chroma.plugin.schema.json",
  "title": "Chroma plugin manifest",
  "description": "Machine-readable contract for browser-side ESM plugins vendored under plugins/<id>/. Consumed by plugins/loader.js and documented in targ-apps-docs/content/docs/chroma/plugins.mdx.",
  "type": "object",
  "additionalProperties": false,
  "required": ["name", "package", "entry", "loadAs", "hooks"],
  "properties": {
    "name": {
      "type": "string",
      "description": "Plugin folder id (matches plugins/<name>/ and chroma.json plugins array entries)."
    },
    "package": {
      "type": "string",
      "pattern": "^@chroma/",
      "description": "npm-style package id (e.g. @chroma/style)."
    },
    "version": {
      "type": "string",
      "description": "Semver of the vendored plugin package."
    },
    "description": {
      "type": "string"
    },
    "entry": {
      "type": "string",
      "default": "index.js",
      "description": "Main module relative to the plugin root; imported by plugins/loader.js."
    },
    "loadAs": {
      "type": "string",
      "description": "Key on the object returned by loadPlugins().",
      "examples": ["style", "router", "t2t", "fs"]
    },
    "capabilities": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true,
      "description": "Tags for docs and generic loaders."
    },
    "hooks": {
      "$ref": "#/$defs/hooks"
    },
    "assets": {
      "$ref": "#/$defs/assets"
    },
    "routing": {
      "$ref": "#/$defs/routing"
    }
  },
  "$defs": {
    "hooks": {
      "type": "object",
      "description": "Hook point name to exported function name in the entry module.",
      "additionalProperties": false,
      "minProperties": 1,
      "properties": {
        "bootstrap": {
          "type": "string",
          "description": "Startup hook (e.g. bootstrapRouter, bootstrapT2t, bootstrapFs)."
        },
        "styles": {
          "type": "string",
          "description": "CSS injection hook before first paint (e.g. injectStyles)."
        }
      }
    },
    "assets": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "stylesheets": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 },
          "minItems": 1,
          "description": "Static CSS files served from the plugin root."
        }
      }
    },
    "routing": {
      "type": "object",
      "description": "Router-specific manifest metadata (@chroma/router).",
      "additionalProperties": false,
      "properties": {
        "reservedMethods": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["GET", "POST", "PUT", "DELETE", "CUSTOM"]
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "manifestPath": {
          "type": "string",
          "description": "Path to routes-manifest.json relative to the app root."
        },
        "pathConvention": {
          "type": "string",
          "description": "URL prefix for file-based API handlers (e.g. api/)."
        }
      }
    }
  }
}
