{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openship.dev/schemas/discovery.schema.json",
  "title": "OpenShip v1 discovery",
  "type": "object",
  "required": ["openship", "capability", "project", "agent", "capabilities"],
  "properties": {
    "openship": { "const": "1.0" },
    "capability": { "const": "discovery" },
    "project": {
      "type": "object",
      "required": ["name", "description"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "description": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": true
    },
    "agent": {
      "type": "object",
      "required": ["summary", "instructions", "skill"],
      "properties": {
        "summary": { "type": "string", "minLength": 1 },
        "instructions": { "type": "string", "minLength": 1 },
        "skill": { "$ref": "#/$defs/httpsUrl" }
      },
      "additionalProperties": true
    },
    "page": { "$ref": "#/$defs/httpsUrl" },
    "capabilities": {
      "type": "object",
      "required": ["sources"],
      "properties": {
        "sources": {
          "type": "object",
          "required": ["description", "manifest", "bundle"],
          "properties": {
            "description": { "type": "string", "minLength": 1 },
            "manifest": { "$ref": "#/$defs/httpsUrl" },
            "bundle": { "$ref": "#/$defs/httpsUrl" },
            "mcp": { "$ref": "#/$defs/httpsUrl" },
            "file": { "type": "string", "pattern": "^https://.+\\{path\\}.+$|^https://.+/\\{path\\}$" },
            "archive": { "$ref": "#/$defs/httpsUrl" },
            "instructions": { "$ref": "#/$defs/httpsUrl" }
          },
          "additionalProperties": true
        },
        "changes": {
          "type": "object",
          "required": ["description", "policy", "submit", "status"],
          "properties": {
            "description": { "type": "string", "minLength": 1 },
            "policy": { "$ref": "#/$defs/httpsUrl" },
            "submit": { "$ref": "#/$defs/httpsUrl" },
            "status": { "type": "string", "pattern": "^https://.+\\{changeId\\}.+$|^https://.+/\\{changeId\\}$" }
          },
          "additionalProperties": true
        },
        "systems": {
          "type": "object",
          "required": ["description", "document"],
          "properties": {
            "description": { "type": "string", "minLength": 1 },
            "document": { "$ref": "#/$defs/httpsUrl" }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    }
  },
  "$defs": {
    "httpsUrl": { "type": "string", "format": "uri", "pattern": "^https://" }
  },
  "additionalProperties": true
}
