{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/SubagentManifest",
  "definitions": {
    "ExtensionVisibility": {
      "type": "string",
      "enum": ["public", "private"],
      "title": "Extension Visibility",
      "description": "Intended whole-Extension Registry visibility. Establishes new Extensions and must match established Extensions."
    },
    "PublishOptions": {
      "type": "object",
      "properties": {
        "visibility": {
          "anyOf": [{ "$ref": "#/definitions/ExtensionVisibility" }, { "type": "null" }]
        },
        "ignore": {
          "anyOf": [
            {
              "type": "array",
              "uniqueItems": true,
              "description": "Registry-only archive exclusions matched against package-relative POSIX paths. Matching files are omitted only from published archives; local, Git, workspace, import, fork, and agent projection behavior is unchanged. `*` is the only wildcard, is case-sensitive, and spans `/`. An explicit empty array records a reviewed publish-all decision.",
              "examples": [[], ["evals/*"]],
              "items": { "type": "string", "minLength": 1 }
            },
            { "type": "null" }
          ]
        }
      },
      "additionalProperties": false,
      "title": "Publish Options",
      "description": "Publication policy and archive options for this extension."
    },
    "Handle": {
      "type": "string",
      "pattern": "^@[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?$",
      "title": "Handle",
      "description": "A unique username or organization name starting with @, like @my-org.",
      "examples": ["@my-org", "@username"]
    },
    "Version": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
      "title": "Version",
      "description": "A semver version like 1.0.0. Ranges are not allowed here.",
      "examples": ["1.0.0", "2.3.1", "0.1.0-beta.1"]
    },
    "Repository": {
      "anyOf": [
        {
          "type": "string",
          "examples": ["https://github.com/acme/code-review", "github:acme/code-review"],
          "format": "uri-reference"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "description": "Version control system (e.g., `git`).",
                  "examples": ["git"]
                },
                { "type": "null" }
              ]
            },
            "url": {
              "type": "string",
              "allOf": [
                {
                  "minLength": 1,
                  "description": "Repository URL.",
                  "examples": ["https://github.com/acme/code-review"],
                  "format": "uri"
                }
              ]
            },
            "directory": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "description": "Subdirectory within the repository, for monorepo publishers.",
                  "examples": ["packages/code-review"]
                },
                { "type": "null" }
              ]
            }
          },
          "required": ["url"],
          "additionalProperties": false
        }
      ],
      "title": "Repository",
      "description": "Source repository for this extension. Accepts a URL string (or `host:owner/repo` shorthand) or an object with `type`, `url`, and optional `directory`."
    },
    "Bugs": {
      "anyOf": [
        {
          "type": "string",
          "examples": ["https://github.com/acme/code-review/issues"],
          "format": "uri"
        },
        {
          "type": "object",
          "properties": {
            "url": {
              "anyOf": [
                {
                  "type": "string",
                  "allOf": [
                    {
                      "minLength": 1,
                      "description": "Issue tracker URL.",
                      "examples": ["https://github.com/acme/code-review/issues"],
                      "format": "uri"
                    }
                  ]
                },
                { "type": "null" }
              ]
            },
            "email": {
              "anyOf": [
                {
                  "type": "string",
                  "allOf": [
                    {
                      "minLength": 1,
                      "description": "Contact email for bug reports.",
                      "examples": ["bugs@acme.dev"],
                      "format": "email"
                    }
                  ]
                },
                { "type": "null" }
              ]
            }
          },
          "additionalProperties": false
        }
      ],
      "title": "Bugs",
      "description": "Where to report bugs against this extension. Accepts a URL string or an object with optional `url` and `email`."
    },
    "Author": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "email": { "anyOf": [{ "type": "string" }, { "type": "null" }] },
        "url": { "anyOf": [{ "type": "string" }, { "type": "null" }] }
      },
      "required": ["name"],
      "additionalProperties": false,
      "title": "Author",
      "description": "A person credited as a creator or maintainer of this extension."
    },
    "PackageIdentityPurl": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[Pp][Kk][Gg]:[a-zA-Z][a-zA-Z0-9.+-]*\\/.+$",
      "title": "Package Identity Purl",
      "description": "A Package URL (purl) identity for a companion package. Companion package purls are identities, not pins: omit the purl @version segment and put compatibility constraints in versionRange.",
      "examples": ["pkg:npm/react", "pkg:pypi/requests", "pkg:cargo/serde"]
    },
    "VersRangeEncoded": {
      "type": "string",
      "minLength": 1,
      "examples": ["vers:npm/>=18.0.0|<19.0.0", "vers:pypi/>=2.31.0", "vers:cargo/>=1.0.0"]
    },
    "CompanionPackage": {
      "type": "object",
      "properties": {
        "purl": { "$ref": "#/definitions/PackageIdentityPurl" },
        "versionRange": {
          "anyOf": [{ "$ref": "#/definitions/VersRangeEncoded" }, { "type": "null" }]
        }
      },
      "required": ["purl"],
      "additionalProperties": false,
      "title": "Companion Package",
      "description": "A companion package purl identity with an optional VERS compatibility range."
    },
    "PackSpec": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(@[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?)\\/packs\\/([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)(?:@.+)?$",
      "title": "Pack Spec",
      "description": "Pack reference with an optional version constraint suffix.",
      "examples": ["@acme/packs/typescript", "@acme/packs/typescript@^1.0.0"]
    },
    "ExtensionName": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$",
      "title": "Extension Name",
      "description": "Short name for this subagent within its owner namespace. Combined with owner, forms the FQN @owner/subagents/<name>.",
      "examples": ["my-skill", "code-review", "prettier"]
    },
    "AgentId": {
      "type": "string",
      "enum": [
        "adal",
        "fx",
        "muse-code",
        "mimo-code",
        "coder-agents",
        "aider-desk",
        "amp",
        "antigravity",
        "antigravity-cli",
        "augment",
        "claude-code",
        "cline",
        "codearts-agent",
        "codebuddy",
        "codemaker",
        "codestudio",
        "codex",
        "command-code",
        "continue",
        "cortex",
        "crush",
        "cursor",
        "deepagents",
        "devin",
        "dexto",
        "droid",
        "firebender",
        "forgecode",
        "gemini-cli",
        "github-copilot-cli",
        "goose",
        "grok-cli",
        "hermes",
        "ibm-bob",
        "iflow-cli",
        "junie",
        "lingma",
        "kilo",
        "kimi-cli",
        "kiro-cli",
        "kode",
        "mcpjam",
        "minimax-code",
        "mistral-vibe",
        "mux",
        "neovate",
        "openclaw",
        "opencode",
        "openhands",
        "ona",
        "pi",
        "vscode",
        "pochi",
        "qoder",
        "qoder-cn",
        "qwen-code",
        "replit",
        "roo",
        "rovodev",
        "tabnine-cli",
        "trae-cn",
        "trae",
        "warp",
        "windsurf",
        "zencoder",
        "zed",
        "zenflow",
        "chatgpt",
        "claude-ai",
        "cowork",
        "gemini-app"
      ],
      "title": "Agent ID",
      "description": "Verified coding agent identifier in the capability catalog.",
      "examples": ["claude-code", "codex", "cursor"]
    },
    "SubagentManifest": {
      "type": "object",
      "properties": {
        "$schema": { "anyOf": [{ "type": "string" }, { "type": "null" }] },
        "publish": { "anyOf": [{ "$ref": "#/definitions/PublishOptions" }, { "type": "null" }] },
        "metadata": {
          "anyOf": [
            {
              "type": "object",
              "title": "Extension Metadata",
              "description": "Opaque consumer-defined JSON metadata. The compact UTF-8 JSON representation is limited to 65,536 bytes and container depth 16."
            },
            { "type": "null" }
          ]
        },
        "owner": { "$ref": "#/definitions/Handle" },
        "version": { "$ref": "#/definitions/Version" },
        "description": {
          "anyOf": [
            {
              "type": "string",
              "description": "Short, registry-facing summary of this extension shown in listings and search results."
            },
            { "type": "null" }
          ]
        },
        "keywords": {
          "anyOf": [
            {
              "type": "array",
              "examples": [["lint", "typescript", "review"]],
              "items": { "type": "string", "minLength": 1 }
            },
            { "type": "null" }
          ]
        },
        "repository": { "anyOf": [{ "$ref": "#/definitions/Repository" }, { "type": "null" }] },
        "homepage": {
          "anyOf": [
            { "type": "string", "examples": ["https://acme.dev/code-review"], "format": "uri" },
            { "type": "null" }
          ]
        },
        "license": {
          "anyOf": [
            {
              "type": "string",
              "title": "License",
              "description": "SPDX license expression, or `UNLICENSED` for proprietary code.",
              "examples": ["MIT", "Apache-2.0", "MIT OR Apache-2.0", "UNLICENSED"],
              "format": "spdx-expression"
            },
            { "type": "null" }
          ]
        },
        "bugs": { "anyOf": [{ "$ref": "#/definitions/Bugs" }, { "type": "null" }] },
        "authors": {
          "anyOf": [
            { "type": "array", "items": { "$ref": "#/definitions/Author" } },
            { "type": "null" }
          ]
        },
        "packages": {
          "anyOf": [
            {
              "type": "array",
              "description": "External ecosystem packages this extension is designed to work with, declared as identity Package URLs with optional VERS compatibility ranges.",
              "items": { "$ref": "#/definitions/CompanionPackage" }
            },
            { "type": "null" }
          ]
        },
        "enhances": {
          "anyOf": [
            {
              "type": "array",
              "uniqueItems": true,
              "description": "Soft capability enhancements used by the source. These never block installation.",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?::[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)?$"
              }
            },
            { "type": "null" }
          ]
        },
        "requires": {
          "anyOf": [
            {
              "type": "array",
              "uniqueItems": true,
              "description": "Hard capabilities without which the extension cannot operate.",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?::[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)?$"
              }
            },
            { "type": "null" }
          ]
        },
        "recommendedPacks": {
          "anyOf": [
            {
              "type": "array",
              "description": "Pack recommendations and same-pack composition metadata. Entries do not install or guarantee the pack or its members.",
              "items": { "$ref": "#/definitions/PackSpec" }
            },
            { "type": "null" }
          ]
        },
        "standalone": {
          "anyOf": [
            {
              "type": "boolean",
              "description": "False means the extension requires sibling extensions that are direct members of a pack named in recommendedPacks, resolved by extension identity rather than by path; it does not create dependencies.",
              "default": true
            },
            { "type": "null" }
          ]
        },
        "type": { "type": "string", "enum": ["subagent"] },
        "name": { "$ref": "#/definitions/ExtensionName" },
        "core": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "instructions": {
                  "type": "string",
                  "pattern": "^(?!\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*\\/\\/)[^\\\\\\p{Cc}:]+$",
                  "allOf": [
                    {
                      "not": { "pattern": "/$" },
                      "description": "Package-relative regular file path; traversal and host paths are forbidden."
                    }
                  ]
                },
                "name": {
                  "anyOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                      "description": "Native agent name, independent of the AXM package name."
                    },
                    { "type": "null" }
                  ]
                }
              },
              "required": ["instructions"],
              "additionalProperties": false
            },
            { "type": "null" }
          ]
        },
        "implementations": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": { "type": "string", "enum": ["customized"] },
                      "source": { "anyOf": [{ "not": {} }, { "type": "null" }] },
                      "configuration": {
                        "anyOf": [
                          {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "pattern": "^(?!(?:name|description|instructions|developer_instructions|prompt|systemPrompt|system_prompt|roleDefinition|agentOverrides|fallback|__proto__|prototype|constructor)$).+$"
                            },
                            "description": "Opaque native configuration; identity and instruction fields belong to the core or a complete native implementation."
                          },
                          { "type": "null" }
                        ]
                      },
                      "instructions": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "mode": { "type": "string", "enum": ["append", "replace"] },
                              "source": {
                                "type": "string",
                                "pattern": "^(?!\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*\\/\\/)[^\\\\\\p{Cc}:]+$",
                                "allOf": [
                                  {
                                    "not": { "pattern": "/$" },
                                    "description": "Package-relative regular file path; traversal and host paths are forbidden."
                                  }
                                ]
                              }
                            },
                            "required": ["mode", "source"],
                            "additionalProperties": false
                          },
                          { "type": "null" }
                        ]
                      }
                    },
                    "required": ["kind"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": { "type": "string", "enum": ["native"] },
                      "source": {
                        "type": "string",
                        "pattern": "^(?!\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*\\/\\/)[^\\\\\\p{Cc}:]+$",
                        "allOf": [
                          {
                            "not": { "pattern": "/$" },
                            "description": "Package-relative regular file path; traversal and host paths are forbidden."
                          }
                        ]
                      },
                      "configuration": { "anyOf": [{ "not": {} }, { "type": "null" }] },
                      "instructions": { "anyOf": [{ "not": {} }, { "type": "null" }] }
                    },
                    "required": ["kind", "source"],
                    "additionalProperties": false
                  }
                ]
              },
              "propertyNames": { "$ref": "#/definitions/AgentId" }
            },
            { "type": "null" }
          ]
        },
        "fallback": { "anyOf": [{ "not": {} }, { "type": "null" }] },
        "agentOverrides": { "anyOf": [{ "not": {} }, { "type": "null" }] },
        "agents": { "anyOf": [{ "not": {} }, { "type": "null" }] }
      },
      "required": ["owner", "version", "type", "name"],
      "additionalProperties": false,
      "allOf": [
        {
          "anyOf": [
            {
              "required": ["core", "description"],
              "properties": { "description": { "type": "string", "pattern": "\\S" } }
            },
            {
              "not": { "required": ["core"] },
              "required": ["implementations"],
              "properties": {
                "implementations": {
                  "minProperties": 1,
                  "additionalProperties": { "properties": { "kind": { "const": "native" } } }
                }
              }
            }
          ],
          "title": "Subagent Manifest",
          "description": "One subagent package with portable instructions, explicit per-agent customization, or complete native implementations."
        }
      ]
    }
  }
}
