{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://docs.phyware.io/phyware/catalog/v1/catalog-schema.json",
  "title": "PhyWare CLI Command Catalog",
  "type": "object",
  "required": [
    "$schema",
    "version",
    "cli",
    "description",
    "commands"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
    "version": {
      "type": "string"
    },
    "cli": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "commands": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/CommandDescriptor"
      }
    }
  },
  "definitions": {
    "CatalogOption": {
      "type": "object",
      "required": [
        "flag",
        "type",
        "required",
        "description"
      ],
      "properties": {
        "flag": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "default": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": "string"
        },
        "env": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "CatalogArgument": {
      "type": "object",
      "required": [
        "name",
        "required",
        "description"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "description": {
          "type": "string"
        }
      }
    },
    "ExitCode": {
      "type": "object",
      "required": [
        "code",
        "meaning"
      ],
      "properties": {
        "code": {
          "type": "integer"
        },
        "meaning": {
          "type": "string"
        }
      }
    },
    "Example": {
      "type": "object",
      "required": [
        "description",
        "command"
      ],
      "properties": {
        "description": {
          "type": "string"
        },
        "command": {
          "type": "string"
        }
      }
    },
    "CatalogError": {
      "type": "object",
      "required": [
        "code",
        "message",
        "remediation"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "remediation": {
          "type": "string"
        }
      }
    },
    "CommandDescriptor": {
      "type": "object",
      "required": [
        "name",
        "group",
        "synopsis",
        "description",
        "options",
        "arguments",
        "exit_codes",
        "examples",
        "agent_notes",
        "see_also",
        "errors"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "group": {
          "type": "string"
        },
        "synopsis": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "options": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CatalogOption"
          }
        },
        "arguments": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CatalogArgument"
          }
        },
        "input_schema": {},
        "output_schema": {},
        "exit_codes": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ExitCode"
          }
        },
        "examples": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Example"
          },
          "minItems": 1
        },
        "agent_notes": {
          "type": "string"
        },
        "see_also": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "errors": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CatalogError"
          }
        }
      }
    }
  }
}