{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://get-fable.dev/schemas/eco/capability-manifest.schema.json",
  "title": "Fable Eco Capability Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "id",
    "name",
    "description",
    "kind",
    "classes",
    "source",
    "version",
    "install",
    "platforms",
    "dependencies",
    "conflicts",
    "provides",
    "permissions",
    "health",
    "hosts",
    "runtime",
    "governance"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]*/[a-z0-9][a-z0-9._-]*$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500
    },
    "kind": {
      "enum": [
        "skill",
        "tool",
        "plugin",
        "agent",
        "service",
        "library",
        "bundle"
      ]
    },
    "classes": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "repository"
      ],
      "properties": {
        "type": {
          "enum": [
            "github-release",
            "registry",
            "git-tag",
            "git-revision",
            "bundled",
            "binary-archive"
          ]
        },
        "repository": {
          "type": "string",
          "minLength": 1
        },
        "registry": {
          "type": [
            "string",
            "null"
          ]
        },
        "package": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "version": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "strategy",
        "channel"
      ],
      "properties": {
        "strategy": {
          "enum": [
            "github-release",
            "registry",
            "git-tag",
            "git-revision",
            "bundled"
          ]
        },
        "channel": {
          "enum": [
            "stable",
            "beta",
            "experimental"
          ]
        },
        "constraint": {
          "type": [
            "string",
            "null"
          ]
        },
        "revision": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "install": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "driver"
      ],
      "properties": {
        "driver": {
          "enum": [
            "github_release",
            "binary_archive",
            "git_checkout",
            "bun_package",
            "npm_package",
            "cargo_package",
            "uv_tool",
            "copy_skill",
            "bundled"
          ]
        },
        "target_scope": {
          "enum": [
            "eco-managed",
            "host-managed",
            "project-managed"
          ]
        },
        "artifact_pattern": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "platforms": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^(macos|linux|windows)/(arm64|x86_64)$"
      }
    },
    "dependencies": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "target"
        ],
        "properties": {
          "type": {
            "enum": [
              "required",
              "runtime",
              "install",
              "optional",
              "host"
            ]
          },
          "target": {
            "type": "string",
            "minLength": 1
          },
          "constraint": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "conflicts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "target",
          "reason_code"
        ],
        "properties": {
          "kind": {
            "enum": [
              "hard",
              "primary-provider",
              "context-overlap",
              "hook-order",
              "version"
            ]
          },
          "target": {
            "type": "string",
            "minLength": 1
          },
          "reason_code": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "provides": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "permissions": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "enum": [
          "filesystem.read:workspace",
          "filesystem.write:workspace",
          "filesystem.read:user-config",
          "filesystem.write:user-config",
          "filesystem.write:host-config",
          "network:public-internet",
          "network:scoped-target",
          "process:spawn",
          "browser:control",
          "git:read",
          "git:write",
          "credentials:host-provided",
          "security:active-testing"
        ]
      }
    },
    "health": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "timeout_ms"
      ],
      "properties": {
        "kind": {
          "enum": [
            "command",
            "file",
            "host-binding",
            "none"
          ]
        },
        "command": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "timeout_ms": {
          "type": "integer",
          "minimum": 100,
          "maximum": 120000
        }
      }
    },
    "hosts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "mode"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "mode": {
            "enum": [
              "skill",
              "mcp",
              "plugin",
              "wrapper",
              "instructions",
              "none"
            ]
          },
          "minimum_grade": {
            "enum": [
              "A",
              "B",
              "C",
              "N"
            ]
          }
        }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "intents",
        "task_shapes",
        "mutates_workspace",
        "parallel_safe",
        "network_required",
        "interactive",
        "expected_cost",
        "fallbacks"
      ],
      "properties": {
        "intents": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "task_shapes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "mutates_workspace": {
          "type": "boolean"
        },
        "parallel_safe": {
          "type": "boolean"
        },
        "network_required": {
          "type": "boolean"
        },
        "interactive": {
          "type": "boolean"
        },
        "expected_cost": {
          "enum": [
            "free-local",
            "network-free",
            "provider-billed",
            "unknown"
          ]
        },
        "fallbacks": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "governance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "support_tier",
        "license",
        "adapter_owner",
        "security_sensitive"
      ],
      "properties": {
        "support_tier": {
          "enum": [
            "stable",
            "optional",
            "experimental",
            "compatibility",
            "blocked"
          ]
        },
        "license": {
          "type": "string",
          "minLength": 1
        },
        "adapter_owner": {
          "type": "string",
          "minLength": 1
        },
        "security_sensitive": {
          "type": "boolean"
        },
        "qualification_record": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}
