{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://relgap.sasskovacs.dev/schemas/report-v1.json",
  "title": "relgap JSON output envelope",
  "description": "Every --format json output is wrapped in this envelope. data is command-specific; its schemas are added per command.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "tool", "version", "generated_at", "data", "errors"],
  "properties": {
    "schema_version": {
      "description": "Version of this envelope schema. Changes independently of the binary version.",
      "const": "1"
    },
    "tool": {
      "const": "relgap"
    },
    "version": {
      "description": "Version of the relgap binary that produced the output.",
      "type": "string",
      "minLength": 1
    },
    "generated_at": {
      "description": "RFC 3339 timestamp, UTC.",
      "type": "string",
      "format": "date-time"
    },
    "data": {
      "description": "Command-specific payload.",
      "type": "object"
    },
    "errors": {
      "description": "Per-target errors. A non-empty list means the run was partial.",
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["message"],
        "properties": {
          "target": {
            "description": "What failed, e.g. a tool or repo name.",
            "type": "string"
          },
          "message": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "page": {
      "description": "Present only in MCP tool results that were split to fit the size cap. The data holds the returned items; pass next_cursor back to the same tool for the rest.",
      "type": "object",
      "additionalProperties": false,
      "required": ["items", "returned", "total"],
      "properties": {
        "items": {
          "description": "Name of the list that was split, such as entries, pins or tools.",
          "type": "string",
          "minLength": 1
        },
        "returned": {
          "type": "integer",
          "minimum": 0
        },
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "next_cursor": {
          "description": "Opaque. Absent on the last page.",
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
