{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Astrumon/spovishun-skills/schema/manifest.schema.json",
  "title": "Spovishun Skills Manifest",
  "description": "Per-skill metadata declared alongside SKILL.md.",
  "type": "object",
  "required": ["id", "version", "category", "description"],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$",
      "minLength": 2,
      "maxLength": 64,
      "description": "Kebab-case unique identifier. Matches the containing directory name."
    },
    "version": {
      "type": "string",
      "format": "semver",
      "description": "Semantic version of this skill (independent from the package version)."
    },
    "category": {
      "type": "string",
      "enum": ["universal", "configurable", "stack-specific"]
    },
    "description": {
      "type": "string",
      "minLength": 10,
      "maxLength": 300
    },
    "requires": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["kotlin", "postgres", "telegram", "notion", "docker", "kmp"]
      },
      "uniqueItems": true,
      "description": "Stack flags that must all be active for this skill to be installed."
    },
    "provides": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true
    },
    "triggers": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "en": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "uk": { "type": "array", "items": { "type": "string", "minLength": 1 } }
      }
    },
    "user_invocable": {
      "type": "boolean",
      "description": "Whether the user can invoke this skill directly via /<id>. Synthesized into the SKILL.md frontmatter by the Claude adapter. Defaults to true when omitted (Claude Code's own default)."
    },
    "disable-model-invocation": {
      "type": "boolean",
      "description": "Set true to stop Claude from auto-loading this skill; only manual /<id> invocation. Synthesized into the SKILL.md frontmatter by the Claude adapter. Defaults to false when omitted."
    },
    "filename": {
      "type": "string",
      "minLength": 1,
      "description": "Output filename for template artifacts (required for kind=template)."
    },
    "placeholders": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["key"],
        "additionalProperties": false,
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]*$"
          },
          "description": { "type": "string" },
          "default": { "type": "string" }
        }
      },
      "uniqueItems": true
    },
    "source": {
      "description": "Upstream provenance for an artifact derived from a third-party repository. One entry, or an array of entries when the artifact was adapted from more than one upstream repo. Every artifact carrying this field must also appear in NOTICE.md — scripts/validate-all-manifests.js enforces the correspondence in both directions.",
      "oneOf": [
        { "$ref": "#/$defs/sourceEntry" },
        {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/sourceEntry" }
        }
      ]
    }
  },
  "$defs": {
    "sourceEntry": {
      "description": "One upstream repository this artifact was adapted from.",
      "type": "object",
      "additionalProperties": false,
      "required": ["repo", "files"],
      "properties": {
        "repo": {
          "type": "string",
          "pattern": "^[\\w.-]+/[\\w.-]+$",
          "description": "Upstream repository as owner/name."
        },
        "ref": {
          "type": "string",
          "minLength": 7,
          "description": "Upstream commit the SHAs below were read at."
        },
        "files": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "description": "Every upstream file this artifact was adapted from. Pinning all of them (not just the primary one) is what lets scripts/check-upstream-drift.js see the whole surface.",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["path", "sha"],
            "properties": {
              "path": { "type": "string", "minLength": 1 },
              "sha": {
                "type": "string",
                "pattern": "^[0-9a-f]{40}$",
                "description": "Git blob SHA of the upstream file at adaptation time."
              }
            }
          }
        }
      }
    }
  },
  "allOf": [
    {
      "if": { "properties": { "category": { "const": "stack-specific" } } },
      "then": {
        "required": ["requires"],
        "properties": { "requires": { "type": "array", "minItems": 1 } }
      }
    },
    {
      "if": { "properties": { "category": { "const": "universal" } } },
      "then": {
        "not": { "required": ["requires"] }
      }
    }
  ],
  "unevaluatedProperties": false
}
