{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://github.com/github/binmate/schema.json",
  "title": "binmate Configuration",
  "description": "Configuration schema for binmate CLI",
  "type": "object",
  "required": [
    "version",
    "binaries"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "version": {
      "type": "integer",
      "description": "Configuration schema version",
      "minimum": 1
    },
    "global": {
      "type": "object",
      "description": "Global configuration defaults that apply to all binaries",
      "properties": {
        "installPath": {
          "type": "string",
          "description": "Default installation path for all binaries (e.g., /usr/local/bin)"
        },
        "providers": {
          "type": "object",
          "description": "Provider-specific configuration defaults",
          "properties": {
            "github": {
              "$ref": "#/definitions/providerDefaults"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "tui": {
      "type": "object",
      "description": "Configuration for the interactive (TUI) mode",
      "properties": {
          "dateFormat": {
            "type": "string",
            "description": "Date format to use in the date displays (e.g., \"2006-01-02 15:04:05\")"
          },
          "askpassMode": {
            "type": "string",
            "enum": [
              "startup",
              "always"
            ],
            "default": "startup",
            "description": "Controls when the askpass script is invoked. \"startup\" (default) resolves the token once when binmate starts. \"always\" invokes the askpass script before each API call that requires authentication."
          }
      },
      "additionalProperties": false
    },
    "binaries": {
      "type": "array",
      "description": "List of binaries to install and manage",
      "items": {
        "$ref": "#/definitions/binary"
      },
      "minItems": 1
    },
    "logLevel": {
      "type": "string",
      "description": "Controls verbosity of application logging",
      "enum": [
        "debug",
        "info",
        "silent"
      ]
    }
  },
  "definitions": {
    "providerDefaults": {
      "type": "object",
      "description": "Provider-level configuration defaults",
      "properties": {
        "authenticated": {
          "type": "boolean",
          "description": "Whether to use authentication for API calls to this provider"
        }
      },
      "additionalProperties": false
    },
    "binary": {
      "type": "object",
      "required": [
        "id",
        "name",
        "provider",
        "path",
        "format"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for the binary",
          "pattern": "^[a-zA-Z0-9_-]+$",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "description": "Display name of the binary",
          "minLength": 1
        },
        "provider": {
          "type": "string",
          "description": "Source provider for the binary",
          "enum": [
            "github"
          ]
        },
        "path": {
          "type": "string",
          "description": "Provider-specific path (e.g., owner/repo for GitHub)",
          "pattern": "^[^/]+/[^/]+$"
        },
        "format": {
          "type": "string",
          "description": "Format of the binary asset",
          "enum": [
            ".tar.gz",
            ".zip",
            "raw"
          ]
        },
        "releaseRegex": {
          "type": "string",
          "description": "Optional regex pattern to filter release tags"
        },
        "assetRegex": {
          "type": "string",
          "description": "Optional regex pattern to filter release assets"
        },
        "installPath": {
          "type": "string",
          "description": "Optional custom installation path for this binary (overrides global.installPath)"
        },
        "authenticated": {
          "type": "boolean",
          "description": "Whether to use authentication for API calls (overrides provider default)"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
