{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://skillcatalog.dev/schemas/skillcatalog-local-yml.schema.json",
  "title": "SkillCatalog Local Project Manifest",
  "description": "The optional .skillcatalog/skillcatalog.local.yml file, a checkout-local sibling of .skillcatalog/skillcatalog.yml. SkillCatalog adds it to the checkout's .gitignore. Holds a user's personal, machine-local additions and removals for a project-backed profile. Never the profile's identity authority (that stays in the committed manifest), so profile is optional here. All top-level fields are optional. A legacy root-level skillcatalog.local.yml is readable but must be moved into .skillcatalog/ before any mutation.",
  "type": "object",
  "required": [],
  "additionalProperties": false,
  "properties": {
    "profile": {
      "type": "object",
      "required": [
        "id",
        "display_name"
      ],
      "additionalProperties": false,
      "description": "Optional profile identity. Advisory only; the committed .skillcatalog/skillcatalog.yml remains the identity authority.",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,127}$",
          "not": {
            "const": "home"
          },
          "description": "Stable profile slug. Must not be 'home' (reserved for the global home profile)."
        },
        "display_name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500,
          "description": "Human-readable profile name."
        }
      }
    },
    "catalogs": {
      "type": [
        "object",
        "null"
      ],
      "description": "Local catalog sources and optional revisions, keyed by catalog id. Each local entry requires its catalog in this local catalogs block. A catalog id declared in the team manifest requires identical source text. An omitted revision can be refined locally; unequal explicit revisions conflict.",
      "propertyNames": {
        "minLength": 2,
        "maxLength": 64,
        "pattern": "^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,127}$"
      },
      "additionalProperties": {
        "type": "object",
        "required": [
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "source": {
            "type": "string",
            "minLength": 1,
            "anyOf": [
              {
                "pattern": "^git@[^\\s?#]*$"
              },
              {
                "pattern": "^[Ss][Ss][Hh]://(?![^\\s?#/]*:[^\\s?#/]*@)[^\\s?#]*$"
              },
              {
                "pattern": "^[Hh][Tt][Tt][Pp][Ss]?://[^/?#\\s@]+(?:/[^\\s?#]*)?$"
              }
            ],
            "description": "Remote Git catalog source. Accepts git@host:path, ssh:// (scheme case-insensitive; user, port, IPv6 literal and colon-path forms all allowed, but no password in the userinfo), and HTTP(S) with a non-empty authority and no userinfo. Query strings, fragments, embedded whitespace, local filesystem paths and file:// URLs are rejected."
          },
          "revision": {
            "$ref": "#/$defs/catalogRevision"
          }
        }
      }
    },
    "entries": {
      "type": "array",
      "description": "Optional ordered list of personal, machine-local skills, stacks, or bundles to add to the delivered profile. Merged before the committed team entries; a local entry shadows an identically-keyed team entry.",
      "items": {
        "type": "object",
        "required": [
          "catalog_id",
          "kind",
          "slug"
        ],
        "additionalProperties": false,
        "properties": {
          "catalog_id": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64,
            "pattern": "^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,127}$",
            "description": "Intrinsic catalog id this entry resolves against."
          },
          "kind": {
            "type": "string",
            "enum": [
              "skill",
              "stack",
              "bundle"
            ],
            "description": "Type of catalog entry."
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,127}$",
            "description": "Slug of the entry in the referenced catalog."
          }
        }
      },
      "uniqueItems": true
    },
    "excludes": {
      "type": "array",
      "description": "Exact entries to leave out of team content or any consumer import, including local imports. Direct local entries remain selected. An unmatched exclusion changes nothing; validation warns about it.",
      "items": {
        "type": "object",
        "required": [
          "catalog_id",
          "kind",
          "slug"
        ],
        "additionalProperties": false,
        "properties": {
          "catalog_id": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64,
            "pattern": "^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,127}$",
            "description": "Intrinsic catalog id this exclude resolves against."
          },
          "kind": {
            "type": "string",
            "enum": [
              "skill",
              "stack",
              "bundle"
            ],
            "description": "Type of catalog entry to exclude."
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,127}$",
            "description": "Slug of the team entry to exclude from delivery."
          }
        }
      },
      "uniqueItems": true
    },
    "imports": {
      "type": "array",
      "items": {
        "$ref": "consumer-profile.schema.json#/$defs/profileImport"
      },
      "description": "Ordered consumer imports contributing to this installed profile. Every import requires a source, revision, and repository-relative path. Imported files never set identity or delivery destinations."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "entries": {
            "type": "array",
            "minItems": 1
          }
        },
        "required": [
          "entries"
        ]
      },
      "then": {
        "required": [
          "catalogs"
        ],
        "properties": {
          "catalogs": {
            "type": "object",
            "minProperties": 1
          }
        }
      }
    }
  ],
  "$defs": {
    "catalogRevision": {
      "description": "Exactly one literal Git branch, tag, or full commit id. Profiles save the resolved commit; delivery reads that saved content offline.",
      "oneOf": [
        {
          "type": "object",
          "required": [
            "branch"
          ],
          "additionalProperties": false,
          "properties": {
            "branch": {
              "type": "string",
              "pattern": "^(?![-/])(?!@(?![\\s\\S]))(?![\\s\\S]*(?:\\.\\.|@\\{|//))(?![\\s\\S]*(?:^|/)\\.)(?![\\s\\S]*(?:^|/)[^/]*\\.lock(?:/|(?![\\s\\S])))(?![\\s\\S]*[./](?![\\s\\S]))[^\\u0000-\\u0020\\u007f~^:?*\\[\\\\]+(?![\\s\\S])"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "tag"
          ],
          "additionalProperties": false,
          "properties": {
            "tag": {
              "type": "string",
              "pattern": "^(?![-/])(?!@(?![\\s\\S]))(?![\\s\\S]*(?:\\.\\.|@\\{|//))(?![\\s\\S]*(?:^|/)\\.)(?![\\s\\S]*(?:^|/)[^/]*\\.lock(?:/|(?![\\s\\S])))(?![\\s\\S]*[./](?![\\s\\S]))[^\\u0000-\\u0020\\u007f~^:?*\\[\\\\]+(?![\\s\\S])"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "commit"
          ],
          "additionalProperties": false,
          "properties": {
            "commit": {
              "type": "string",
              "pattern": "^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$(?![\\s\\S])"
            }
          }
        }
      ]
    }
  }
}
