{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cursorbuddy.app/standards/cursorbuddy-guide/1.0/schema.json",
  "title": "CursorBuddy Guide",
  "description": "An open, portable guide that teaches a compatible assistant how to help on matching web pages.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "version",
    "name",
    "match",
    "appearance",
    "skills",
    "important",
    "avoid",
    "actions",
    "tour",
    "pages"
  ],
  "properties": {
    "$schema": {
      "const": "https://cursorbuddy.app/standards/cursorbuddy-guide/1.0/schema.json"
    },
    "version": {
      "const": "1.0"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "summary": {
      "type": "string",
      "maxLength": 420
    },
    "match": {
      "$ref": "#/$defs/match"
    },
    "appearance": {
      "$ref": "#/$defs/appearance"
    },
    "skills": {
      "$ref": "#/$defs/guidanceList"
    },
    "important": {
      "$ref": "#/$defs/guidanceList"
    },
    "avoid": {
      "$ref": "#/$defs/guidanceList"
    },
    "actions": {
      "type": "array",
      "maxItems": 6,
      "items": {
        "$ref": "#/$defs/action"
      }
    },
    "tour": {
      "type": "array",
      "maxItems": 10,
      "items": {
        "$ref": "#/$defs/tourStep"
      }
    },
    "pages": {
      "type": "object",
      "maxProperties": 50,
      "propertyNames": {
        "pattern": "^/[^*?#]*$"
      },
      "additionalProperties": {
        "$ref": "#/$defs/pageGuide"
      }
    }
  },
  "$defs": {
    "match": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "hosts",
        "paths"
      ],
      "properties": {
        "hosts": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 253,
            "pattern": "^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))*$"
          }
        },
        "paths": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1,
          "items": {
            "type": "string",
            "maxLength": 500,
            "pattern": "^/[^?#*]*(?:\\*)?$"
          }
        }
      }
    },
    "appearance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "activation"
      ],
      "properties": {
        "activation": {
          "enum": [
            "hover",
            "immediate",
            "message",
            "manual"
          ]
        },
        "greeting": {
          "type": "string",
          "maxLength": 160
        }
      }
    },
    "guidanceList": {
      "type": "array",
      "maxItems": 12,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 240
      }
    },
    "action": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 40
        },
        "task": {
          "type": "string",
          "minLength": 1,
          "maxLength": 300
        },
        "href": {
          "type": "string",
          "pattern": "^/(?!/)",
          "maxLength": 500
        },
        "tour": {
          "const": true
        }
      },
      "oneOf": [
        {
          "required": [
            "task"
          ]
        },
        {
          "required": [
            "href"
          ]
        },
        {
          "required": [
            "tour"
          ]
        }
      ]
    },
    "tourStep": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "selector",
        "text"
      ],
      "properties": {
        "selector": {
          "type": "string",
          "minLength": 1,
          "maxLength": 140
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 260
        },
        "shape": {
          "enum": [
            "rect",
            "circle",
            "ellipse"
          ]
        },
        "pad": {
          "type": "number",
          "minimum": 0,
          "maximum": 48
        },
        "holdMs": {
          "type": "number",
          "minimum": 1000,
          "maximum": 12000
        },
        "waitMs": {
          "type": "number",
          "minimum": 1000,
          "maximum": 14000
        }
      }
    },
    "pageGuide": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "appearance",
        "skills",
        "important",
        "avoid",
        "actions",
        "tour"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 80
        },
        "summary": {
          "type": "string",
          "maxLength": 420
        },
        "appearance": {
          "$ref": "#/$defs/appearance"
        },
        "skills": {
          "$ref": "#/$defs/guidanceList"
        },
        "important": {
          "$ref": "#/$defs/guidanceList"
        },
        "avoid": {
          "$ref": "#/$defs/guidanceList"
        },
        "actions": {
          "type": "array",
          "maxItems": 6,
          "items": {
            "$ref": "#/$defs/action"
          }
        },
        "tour": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "$ref": "#/$defs/tourStep"
          }
        }
      }
    }
  }
}
