{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Astrumon/spovishun-skills/schema/config.schema.json",
  "title": "Spovishun Skills Consumer Config",
  "description": "Schema for spovishun-skills.config.yaml placed in the consumer project root.",
  "type": "object",
  "required": ["project", "stack", "git"],
  "properties": {
    "project": {
      "type": "object",
      "required": ["name", "language"],
      "properties": {
        "name":     { "type": "string", "minLength": 1, "maxLength": 100 },
        "language": { "type": "string", "enum": ["uk", "en"] }
      },
      "unevaluatedProperties": false
    },
    "stack": {
      "type": "object",
      "required": ["kotlin", "postgres", "telegram", "notion"],
      "properties": {
        "kotlin":   { "type": "boolean" },
        "postgres": { "type": "boolean" },
        "telegram": { "type": "boolean" },
        "notion":   { "type": "boolean" },
        "docker":   { "type": "boolean" },
        "kmp":      { "type": "boolean" }
      },
      "unevaluatedProperties": false
    },
    "git": {
      "type": "object",
      "required": ["branch_prefix", "main_branch", "dev_branch"],
      "properties": {
        "branch_prefix": { "type": "string", "pattern": "^[a-z][a-z0-9/_-]*$" },
        "main_branch":   { "type": "string", "minLength": 1 },
        "dev_branch":    { "type": "string", "minLength": 1 }
      },
      "unevaluatedProperties": false
    },
    "notion": {
      "type": "object",
      "properties": {
        "token_env":           { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" },
        "database_id":         { "type": "string", "pattern": "^[0-9a-f]{32}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
        "root_page_id":        { "type": "string", "minLength": 1 },
        "docs_root_id":        { "type": "string", "minLength": 1 },
        "claude_md_page_id":   { "type": "string", "minLength": 1 },
        "epics_database_id":   { "type": "string", "minLength": 1 },
        "epics_group_page_id": { "type": "string", "minLength": 1 },
        "categories": {
          "type": "object",
          "description": "Notion documentation category page IDs. Each maps to NOTION_CATEGORY_<KEY>_ID and NOTION_ZONE_<KEY>_URL placeholders (zone URL derived as https://www.notion.so/<id>). Used by notion-navigator and doc-updater.",
          "propertyNames": { "enum": ["architecture", "database", "testing", "cicd", "features", "aitools", "epics"] },
          "additionalProperties": { "type": "string", "pattern": "^[0-9a-f]{32}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }
        },
        "picker": {
          "type": "object",
          "description": "Task picker configuration. Optional — picker is backward-compatible with boards that have no Stage field.",
          "properties": {
            "stage_filter": {
              "type": "string",
              "minLength": 1,
              "description": "If set, picker queries filter by Stage select value (e.g. 'Sprint' for Board v2). When unset, no Stage filter is applied (Board v1 behavior)."
            }
          },
          "unevaluatedProperties": false
        }
      },
      "unevaluatedProperties": false
    }
  },
  "allOf": [
    {
      "$comment": "A KMP project is by definition a Kotlin project — kmp: true without kotlin: true would silently drop every kotlin-flagged artifact the KMP track builds on.",
      "if": {
        "type": "object",
        "properties": {
          "stack": {
            "type": "object",
            "properties": { "kmp": { "const": true } },
            "required": ["kmp"]
          }
        },
        "required": ["stack"]
      },
      "then": {
        "type": "object",
        "properties": {
          "stack": {
            "type": "object",
            "properties": { "kotlin": { "const": true } },
            "required": ["kotlin"]
          }
        }
      }
    },
    {
      "if": {
        "type": "object",
        "properties": {
          "stack": {
            "type": "object",
            "properties": { "notion": { "const": true } },
            "required": ["notion"]
          }
        },
        "required": ["stack"]
      },
      "then": {
        "type": "object",
        "required": ["notion"],
        "properties": {
          "notion": {
            "type": "object",
            "required": ["token_env", "database_id", "epics_database_id"],
            "properties": {
              "token_env":         true,
              "database_id":       true,
              "epics_database_id": true
            }
          }
        }
      }
    }
  ],
  "unevaluatedProperties": false
}
