{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dicworkflowkit.local/schemas/capability-catalog.schema.json",
  "title": "QIHENG Capability Catalog",
  "type": "object",
  "required": [
    "schema",
    "product",
    "productVersion",
    "defaultPack",
    "hosts",
    "packs",
    "skills",
    "subagents"
  ],
  "properties": {
    "$schema": { "type": "string" },
    "schema": { "const": "qiheng.capability-catalog.v1" },
    "product": { "const": "QIHENG" },
    "productVersion": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$"
    },
    "defaultPack": { "type": "string", "minLength": 1 },
    "hosts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "supportLevel",
          "scopes",
          "subagentFormat",
          "notesZh"
        ],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "supportLevel": { "enum": ["supported", "compatible"] },
          "scopes": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": { "enum": ["user", "project"] }
          },
          "subagentFormat": {
            "enum": ["codex-plugin", "claude-code", "opencode", "bitfun-v1"]
          },
          "notesZh": { "type": "string", "minLength": 8 }
        },
        "additionalProperties": false
      }
    },
    "packs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "nameZh", "descriptionZh", "dependsOn"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "nameZh": { "type": "string", "minLength": 2 },
          "descriptionZh": { "type": "string", "minLength": 8 },
          "dependsOn": {
            "type": "array",
            "uniqueItems": true,
            "items": { "type": "string", "pattern": "^[a-z0-9-]+$" }
          }
        },
        "additionalProperties": false
      }
    },
    "skills": {
      "type": "array",
      "minItems": 1,
      "items": {
        "allOf": [
          { "$ref": "#/$defs/component" },
          {
            "type": "object",
            "required": ["agentPartners"],
            "properties": {
              "agentPartners": {
                "type": "array",
                "uniqueItems": true,
                "items": { "type": "string", "pattern": "^[a-z0-9-]+$" }
              }
            }
          }
        ],
        "unevaluatedProperties": false
      }
    },
    "subagents": {
      "type": "array",
      "minItems": 1,
      "items": {
        "allOf": [
          { "$ref": "#/$defs/component" },
          {
            "type": "object",
            "required": ["permissions"],
            "properties": {
              "permissions": {
                "type": "array",
                "minItems": 1,
                "uniqueItems": true,
                "items": { "enum": ["read", "write", "execute"] }
              }
            }
          }
        ],
        "unevaluatedProperties": false
      }
    }
  },
  "$defs": {
    "component": {
      "type": "object",
      "required": [
        "id",
        "pack",
        "order",
        "phase",
        "responsibilityZh"
      ],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "pack": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "order": { "type": "integer", "minimum": 0 },
        "phase": { "type": "string", "minLength": 2 },
        "responsibilityZh": { "type": "string", "minLength": 8 }
      }
    }
  },
  "additionalProperties": false
}
