{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getcloudwindow.com/plugins/manifest.schema.json",
  "title": "Cloud Window plugin manifest",
  "description": "cloudwindow-plugin.json, version 1. The desktop's own validator (shared/plugin-manifest.js) is the authority; this schema is for editors.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "id", "name", "version", "summary", "publisher"],
  "properties": {
    "$schema": { "type": "string" },
    "schemaVersion": { "const": 1 },
    "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,30}\\.[a-z0-9][a-z0-9-]{0,30}$", "description": "publisher.name in lower case. Permanent." },
    "name": { "type": "string", "maxLength": 40 },
    "version": { "type": "string", "pattern": "^\\d{1,4}\\.\\d{1,4}\\.\\d{1,6}(?:-[0-9A-Za-z.-]{1,20})?$" },
    "summary": { "type": "string", "maxLength": 120 },
    "description": { "type": "string", "maxLength": 1200 },
    "publisher": { "type": "object", "additionalProperties": false, "required": ["name"], "properties": { "name": { "type": "string", "maxLength": 60 }, "url": { "type": "string", "format": "uri", "pattern": "^https://" } } },
    "repository": { "type": "string", "format": "uri", "pattern": "^https://" },
    "homepage": { "type": "string", "format": "uri", "pattern": "^https://" },
    "license": { "type": "string", "maxLength": 40 },
    "categories": { "type": "array", "maxItems": 3, "items": { "enum": ["developer", "productivity", "agents", "system", "windows", "keys", "fun"] } },
    "icon": { "type": "string", "pattern": "^[A-Za-z0-9_-][A-Za-z0-9._-]{0,60}\\.svg$" },
    "grants": { "type": "array", "items": { "enum": ["desktop:read", "desktop:act", "extend:write", "browser:read", "files:read", "settings:write"] }, "uniqueItems": true },
    "provider": { "type": "object", "additionalProperties": false, "required": ["entry"], "properties": { "entry": { "type": "string", "pattern": "^[A-Za-z0-9_-][A-Za-z0-9._/-]{0,80}\\.m?js$" } } },
    "permissions": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "programs": {
          "type": "array", "maxItems": 8,
          "description": "Exact commands the desktop may run for the plugin, such as \"gh api graphql\". With fields: true the plugin may add -f name=value pairs after it; nothing else.",
          "items": { "oneOf": [
            { "type": "string", "pattern": "^[a-z0-9][a-z0-9._+-]{0,40}( +[^ ]+){1,5}$" },
            { "type": "object", "additionalProperties": false, "required": ["command"], "properties": { "command": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._+-]{0,40}( +[^ ]+){1,5}$" }, "fields": { "type": "boolean" } } }
          ] }
        },
        "network": { "type": "array", "maxItems": 12, "items": { "type": "string" }, "description": "Hosts the plugin says it connects to. Shown in the install dialog; not enforced." },
        "listening": { "type": "boolean", "description": "See which of the owner's programs are listening on ports (cloudwindow.listening())." }
      }
    },
    "settings": {
      "type": "array", "maxItems": 16,
      "items": {
        "type": "object", "additionalProperties": false, "required": ["key", "type", "label"],
        "properties": {
          "key": { "type": "string", "pattern": "^[a-z][a-zA-Z0-9]{0,31}$" },
          "type": { "enum": ["text", "number", "boolean", "select", "secret"] },
          "label": { "type": "string", "maxLength": 60 },
          "help": { "type": "string", "maxLength": 240 },
          "placeholder": { "type": "string", "maxLength": 80 },
          "default": {},
          "min": { "type": "number" }, "max": { "type": "number" },
          "options": { "type": "array", "maxItems": 20, "items": { "type": "object", "required": ["value", "label"], "properties": { "value": { "type": "string" }, "label": { "type": "string" } } } }
        }
      }
    },
    "contributes": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "actions": { "type": "array", "maxItems": 20, "items": { "type": "object", "additionalProperties": false, "required": ["id", "label", "action"], "properties": { "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,31}$" }, "label": { "type": "string", "maxLength": 40 }, "detail": { "type": "string", "maxLength": 80 }, "keywords": { "type": "array", "maxItems": 8, "items": { "type": "string", "maxLength": 24 } }, "action": { "type": "object", "required": ["tool"], "properties": { "tool": { "type": "string" }, "args": { "type": "object" } } } } } },
        "bindings": { "type": "array", "maxItems": 10, "items": { "type": "object", "additionalProperties": false, "required": ["id", "chord", "action"], "properties": { "id": { "type": "string" }, "chord": { "type": "string", "pattern": "^Alt\\+(?:Shift\\+)?.$" }, "action": { "type": "string" } } } }
      }
    }
  }
}
