{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/SetupUpdateResult",
  "definitions": {
    "SetupUpdateResult": {
      "type": "object",
      "properties": {
        "updated": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "skipped": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "staleFiles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StaleRuleFile"
          }
        },
        "availableActions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["check", "dry-run", "update"]
          }
        },
        "cwd": {
          "type": "string"
        },
        "docReference": {
          "$ref": "#/definitions/SetupAgentsUpdateDocReferenceResult"
        },
        "fetchRefs": {
          "$ref": "#/definitions/SetupAgentsUpdateFetchRefsResult"
        },
        "opencodeHealth": {
          "$ref": "#/definitions/OpenCodeHealth"
        },
        "setupHealth": {
          "$ref": "#/definitions/SetupHealth"
        },
        "referenceHealth": {
          "$ref": "#/definitions/ReferenceHealth"
        },
        "knowledgeReadiness": {
          "$ref": "#/definitions/KnowledgeReadiness"
        }
      },
      "required": ["updated", "skipped", "staleFiles", "availableActions", "cwd"],
      "additionalProperties": false
    },
    "StaleRuleFile": {
      "type": "object",
      "properties": {
        "file": {
          "type": "string"
        },
        "tool": {
          "$ref": "#/definitions/SupportedTool"
        },
        "version": {
          "type": ["string", "null"]
        },
        "managedBlocks": {
          "type": "boolean"
        },
        "updateMode": {
          "type": "string",
          "enum": ["managed-blocks", "full-file"]
        },
        "availableActions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["check", "dry-run", "update"]
          }
        }
      },
      "required": ["file", "tool", "version", "managedBlocks", "updateMode", "availableActions"],
      "additionalProperties": false
    },
    "SupportedTool": {
      "type": "string",
      "enum": ["cursor", "vscode", "codex", "claude", "agentforce", "windsurf", "jetbrains", "opencode"]
    },
    "SetupAgentsUpdateDocReferenceResult": {
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "profiles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "cwd": {
          "type": "string"
        }
      },
      "required": ["files", "profiles", "cwd"],
      "additionalProperties": false
    },
    "SetupAgentsUpdateFetchRefsResult": {
      "type": "object",
      "properties": {
        "downloaded": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "cached": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "failed": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "refsDir": {
          "type": "string"
        },
        "cwd": {
          "type": "string"
        },
        "manifestPath": {
          "type": "string"
        },
        "referenceHealth": {
          "$ref": "#/definitions/ReferenceHealth"
        }
      },
      "required": ["downloaded", "cached", "failed", "refsDir", "cwd", "manifestPath", "referenceHealth"],
      "additionalProperties": false
    },
    "ReferenceHealth": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": ["healthy", "unhealthy", "not-configured"]
        },
        "complete": {
          "type": "boolean"
        },
        "configuredProfiles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "issues": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ReferenceHealthIssue"
          }
        },
        "manifestPath": {
          "type": "string"
        }
      },
      "required": ["status", "complete", "configuredProfiles", "issues", "manifestPath"],
      "additionalProperties": false
    },
    "ReferenceHealthIssue": {
      "type": "object",
      "properties": {
        "filename": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": ["missing", "stale", "contaminated", "foreign", "mis-scoped", "source-missing"]
        },
        "action": {
          "type": "string"
        }
      },
      "required": ["filename", "kind", "action"],
      "additionalProperties": false
    },
    "OpenCodeHealth": {
      "type": "object",
      "properties": {
        "status": {
          "$ref": "#/definitions/OpenCodeHealthStatus"
        },
        "issues": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/OpenCodeHealthIssue"
          }
        },
        "remediation": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": ["status", "issues", "remediation"],
      "additionalProperties": false
    },
    "OpenCodeHealthStatus": {
      "type": "string",
      "enum": ["healthy", "stale", "partial", "blocked"]
    },
    "OpenCodeHealthIssue": {
      "type": "object",
      "properties": {
        "surface": {
          "type": "string",
          "enum": ["config", "instructions", "rules", "agents", "commands", "models", "permissions", "mcp"]
        },
        "path": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        },
        "remediation": {
          "type": "string"
        },
        "blocking": {
          "type": "boolean"
        }
      },
      "required": ["surface", "path", "reason", "remediation", "blocking"],
      "additionalProperties": false
    },
    "SetupHealth": {
      "type": "object",
      "properties": {
        "healthy": {
          "type": "boolean"
        },
        "completeness": {
          "anyOf": [
            {
              "$ref": "#/definitions/SetupCompleteness"
            },
            {
              "type": "string",
              "const": "unmanaged"
            }
          ]
        },
        "manifest": {
          "anyOf": [
            {
              "$ref": "#/definitions/SetupManifest"
            },
            {
              "type": "null"
            }
          ]
        },
        "artifacts": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SetupArtifact"
          }
        },
        "repairCommand": {
          "type": "string"
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "runtimeArtifacts": {
          "$ref": "#/definitions/RuntimeArtifactHealth"
        }
      },
      "required": ["healthy", "completeness", "manifest", "artifacts", "repairCommand", "reasons", "runtimeArtifacts"],
      "additionalProperties": false
    },
    "SetupCompleteness": {
      "type": "string",
      "enum": ["quick", "partial", "full"]
    },
    "SetupManifest": {
      "type": "object",
      "properties": {
        "schemaVersion": {
          "type": "number"
        },
        "completeness": {
          "$ref": "#/definitions/SetupCompleteness"
        },
        "requestedLevel": {
          "type": "string",
          "enum": ["quick", "full"]
        },
        "profiles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tools": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SupportedTool"
          }
        },
        "generator": {
          "type": "string",
          "const": "setup-agents:local"
        },
        "pluginVersion": {
          "type": "string"
        },
        "sourceDigest": {
          "type": "string"
        },
        "expectedArtifacts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string"
              },
              "owner": {
                "$ref": "#/definitions/SetupArtifactOwner"
              },
              "marker": {
                "type": ["string", "null"]
              },
              "expectedDigest": {
                "type": "string"
              }
            },
            "required": ["path", "owner", "marker", "expectedDigest"],
            "additionalProperties": false
          }
        },
        "producedArtifacts": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SetupArtifact"
          }
        },
        "failedReasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "skippedReasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "knowledgeManifest": {
          "type": "object",
          "properties": {
            "path": {
              "type": "string",
              "const": ".setup-agents/knowledge-manifest.json"
            },
            "status": {
              "type": "string",
              "enum": ["current", "missing"]
            }
          },
          "required": ["path", "status"],
          "additionalProperties": false
        },
        "generatedAt": {
          "type": "string"
        }
      },
      "required": [
        "schemaVersion",
        "completeness",
        "requestedLevel",
        "profiles",
        "tools",
        "generator",
        "pluginVersion",
        "sourceDigest",
        "expectedArtifacts",
        "producedArtifacts",
        "failedReasons",
        "skippedReasons",
        "knowledgeManifest"
      ],
      "additionalProperties": false
    },
    "SetupArtifactOwner": {
      "type": "string",
      "enum": ["setup-agents", "customer"]
    },
    "SetupArtifact": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string"
        },
        "owner": {
          "$ref": "#/definitions/SetupArtifactOwner"
        },
        "marker": {
          "type": ["string", "null"]
        },
        "expectedDigest": {
          "type": "string"
        },
        "digest": {
          "type": ["string", "null"]
        },
        "status": {
          "$ref": "#/definitions/SetupArtifactStatus"
        },
        "reason": {
          "type": "string"
        }
      },
      "required": ["path", "owner", "marker", "expectedDigest", "digest", "status"],
      "additionalProperties": false
    },
    "SetupArtifactStatus": {
      "type": "string",
      "enum": ["current", "missing", "stale", "drifted", "foreign", "failed", "skipped"]
    },
    "RuntimeArtifactHealth": {
      "type": "object",
      "properties": {
        "healthy": {
          "type": "boolean"
        },
        "missingCanonical": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "missingAdapters": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": ["healthy", "missingCanonical", "missingAdapters"],
      "additionalProperties": false
    },
    "KnowledgeReadiness": {
      "type": "object",
      "properties": {
        "ready": {
          "type": "boolean"
        },
        "artifacts": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/KnowledgeArtifactReadiness"
          }
        },
        "repairCommand": {
          "type": "string"
        }
      },
      "required": ["ready", "artifacts", "repairCommand"],
      "additionalProperties": false
    },
    "KnowledgeArtifactReadiness": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": ["ready", "missing", "template", "stale", "degraded", "partial"]
        },
        "reason": {
          "type": "string"
        }
      },
      "required": ["path", "status", "reason"],
      "additionalProperties": false
    }
  }
}
