{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://uc.surf/data/tools/schema.json",
  "title": "uc.surf tool",
  "description": "A public program or rule pack published by uc.surf. The page, the JSON record and the Markdown copy are built from this file plus the optional write-up next to it.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "name",
    "summary",
    "category",
    "language",
    "license",
    "repository",
    "version",
    "released_at",
    "published_at",
    "release_url",
    "distribution",
    "install",
    "usage",
    "updated_at",
    "public"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
      "description": "Stable id. It equals the file name without .json and the page slug."
    },
    "name": { "type": "string", "minLength": 1, "maxLength": 80 },
    "summary": {
      "type": "string",
      "minLength": 20,
      "maxLength": 500,
      "description": "One or two plain sentences: what the tool does."
    },
    "category": {
      "type": "string",
      "enum": ["scanner", "disclosure", "rules"],
      "description": "scanner: a static scanner. disclosure: finds a reporting channel. rules: detection rules for another tool."
    },
    "language": {
      "type": "string",
      "enum": ["go", "semgrep"],
      "description": "go: a Go program. semgrep: a Semgrep rule pack."
    },
    "license": { "type": "string", "enum": ["MIT", "Apache-2.0"] },
    "repository": { "type": "string", "format": "uri" },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
      "description": "Latest published release, without the leading v."
    },
    "released_at": {
      "type": "string",
      "format": "date-time",
      "description": "When that release was published."
    },
    "published_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the first release was published."
    },
    "release_url": { "type": "string", "format": "uri" },
    "distribution": {
      "type": "string",
      "enum": ["binaries", "git-tag"],
      "description": "binaries: the release has prebuilt archives. git-tag: the tag has no release archives."
    },
    "platforms": {
      "type": "array",
      "minItems": 1,
      "description": "Required when distribution is binaries. Absent when it is git-tag.",
      "items": { "type": "string", "minLength": 1, "maxLength": 40 }
    },
    "install": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1, "maxLength": 500 }
    },
    "usage": {
      "type": "array",
      "minItems": 1,
      "description": "Commands and snippets copied from the repository README at this release.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["label", "command"],
        "properties": {
          "label": { "type": "string", "minLength": 1, "maxLength": 160 },
          "command": { "type": "string", "minLength": 1, "maxLength": 4000 },
          "lang": { "type": "string", "enum": ["sh", "yaml", "console", "text"] },
          "note": { "type": "string", "minLength": 1, "maxLength": 500 }
        }
      }
    },
    "links": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["label", "url"],
        "properties": {
          "label": { "type": "string", "minLength": 1, "maxLength": 80 },
          "url": { "type": "string", "format": "uri" }
        }
      }
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "When this record was last checked against the repository."
    },
    "public": { "const": true }
  }
}
