{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.bullpen.fi/reference/schemas/bullpen.commands.schema.json",
  "title": "Bullpen CLI command manifest",
  "description": "Schema for docs/public/reference/bullpen.commands.json.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generator",
    "cli_version",
    "source",
    "global_flags",
    "commands"
  ],
  "properties": {
    "schema_version": {
      "const": "bullpen.commands/1"
    },
    "generator": {
      "const": "scripts/generate_public_command_manifest.py"
    },
    "cli_version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"
    },
    "source": {
      "const": "live clap --help output"
    },
    "global_flags": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/global_flag"
      },
      "minItems": 1
    },
    "commands": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/command"
      },
      "minItems": 1
    }
  },
  "$defs": {
    "string_array": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "path": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9-]+$"
      }
    },
    "global_flag": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^--[a-z0-9-]+$"
        },
        "values": {
          "$ref": "#/$defs/string_array"
        },
        "value": {
          "type": "string"
        }
      }
    },
    "option": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "names",
        "value",
        "description",
        "enum_values"
      ],
      "properties": {
        "names": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(?:-[A-Za-z]|--[A-Za-z0-9][A-Za-z0-9-]*)$"
          },
          "minItems": 1
        },
        "value": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": "string"
        },
        "enum_values": {
          "$ref": "#/$defs/string_array"
        }
      }
    },
    "positional": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "required"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9_]+$"
        },
        "required": {
          "type": "boolean"
        }
      }
    },
    "subcommand": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "aliases",
        "description"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "aliases": {
          "$ref": "#/$defs/string_array"
        },
        "description": {
          "type": "string"
        }
      }
    },
    "output": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "supports_json",
        "supports_table"
      ],
      "properties": {
        "supports_json": {
          "type": "boolean"
        },
        "supports_table": {
          "type": "boolean"
        }
      }
    },
    "command": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path",
        "canonical_path",
        "command",
        "description",
        "usage",
        "page",
        "aliases",
        "has_subcommands",
        "subcommands",
        "positionals",
        "options",
        "output",
        "safety_class",
        "experimental",
        "destructive",
        "support_gated",
        "fixture_gated"
      ],
      "properties": {
        "path": {
          "$ref": "#/$defs/path"
        },
        "canonical_path": {
          "$ref": "#/$defs/path"
        },
        "command": {
          "type": "string",
          "pattern": "^bullpen(?: [a-z0-9-]+)*$"
        },
        "description": {
          "type": "string"
        },
        "usage": {
          "type": "string",
          "pattern": "^bullpen(?:\\s|$)"
        },
        "page": {
          "type": "string",
          "pattern": "^commands/(?:[a-z0-9-]+/)*[a-z0-9-]+(?:/index)?\\.md$"
        },
        "aliases": {
          "$ref": "#/$defs/string_array"
        },
        "has_subcommands": {
          "type": "boolean"
        },
        "subcommands": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/subcommand"
          }
        },
        "positionals": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/positional"
          }
        },
        "options": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/option"
          }
        },
        "output": {
          "$ref": "#/$defs/output"
        },
        "safety_class": {
          "enum": [
            "command-group",
            "read-only",
            "dry-run-or-preview",
            "mutation-with-preview",
            "mutation",
            "unclassified"
          ]
        },
        "experimental": {
          "type": "boolean"
        },
        "destructive": {
          "type": "boolean"
        },
        "support_gated": {
          "type": "boolean"
        },
        "fixture_gated": {
          "type": "boolean"
        }
      }
    }
  }
}
