{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://askthis.dev/protocol/targets.schema.json",
  "title": "Ask Targets registry",
  "description": "The canonical machine-readable registry of AI engines the Ask AI Protocol can hand a Cited Ask to. Released into the public domain (CC0).",
  "type": "object",
  "required": ["version", "targets"],
  "additionalProperties": true,
  "properties": {
    "$schema": { "type": "string" },
    "version": {
      "type": "string",
      "description": "Protocol major.minor this registry targets.",
      "pattern": "^[0-9]+\\.[0-9]+$"
    },
    "targets": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/target" }
    }
  },
  "$defs": {
    "target": {
      "type": "object",
      "required": ["id", "label", "method", "url"],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Stable lowercase engine key.",
          "pattern": "^[a-z0-9]+$"
        },
        "label": {
          "type": "string",
          "description": "The engine's own display name — neutral and factual.",
          "minLength": 1
        },
        "method": {
          "enum": ["direct", "copy"],
          "description": "direct = the url prefills the prompt; copy = copy the prompt and open the engine home."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "For method=direct, a template containing {q} (the URL-encoded prompt). For method=copy, the engine home URL."
        }
      },
      "allOf": [
        {
          "if": { "properties": { "method": { "const": "direct" } } },
          "then": {
            "properties": { "url": { "pattern": "\\{q\\}" } }
          }
        }
      ]
    }
  }
}
