{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/SetupAgentsStatusResult",
  "definitions": {
    "SetupAgentsStatusResult": {
      "type": "object",
      "properties": {
        "openTasks": {
          "type": "number"
        },
        "claimedTasks": {
          "type": "number"
        },
        "doneTasks": {
          "type": "number"
        },
        "pendingReviews": {
          "type": "number"
        },
        "blockedHandoffs": {
          "type": "number"
        },
        "missingEvidence": {
          "type": "number"
        },
        "configFile": {
          "type": ["string", "null"]
        },
        "mode": {
          "anyOf": [
            {
              "$ref": "#/definitions/SetupAgentsWorkspaceMode"
            },
            {
              "type": "null"
            }
          ]
        },
        "profiles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "cwd": {
          "type": "string"
        },
        "rulesHealth": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RulesHealthEntry"
          }
        },
        "playbookHealth": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PlaybookHealthEntry"
          }
        },
        "dependencyHealth": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/DependencyHealthEntry"
          }
        },
        "setupHealth": {
          "$ref": "#/definitions/SetupHealth"
        },
        "reconciliation": {
          "type": "object",
          "properties": {
            "healthy": {
              "type": "boolean"
            },
            "findings": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/TaskReconciliationFinding"
              }
            },
            "repaired": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/TaskReconciliationCode"
              }
            }
          },
          "required": ["healthy", "findings", "repaired"],
          "additionalProperties": false
        }
      },
      "required": [
        "openTasks",
        "claimedTasks",
        "doneTasks",
        "pendingReviews",
        "blockedHandoffs",
        "missingEvidence",
        "configFile",
        "mode",
        "profiles",
        "cwd",
        "rulesHealth",
        "playbookHealth",
        "dependencyHealth",
        "setupHealth",
        "reconciliation"
      ],
      "additionalProperties": false
    },
    "SetupAgentsWorkspaceMode": {
      "type": "string",
      "enum": ["project", "advisory"]
    },
    "RulesHealthEntry": {
      "type": "object",
      "properties": {
        "profile": {
          "type": "string"
        },
        "file": {
          "type": "string"
        },
        "embeddedVersion": {
          "type": ["string", "null"]
        },
        "pluginVersion": {
          "type": "string"
        },
        "stale": {
          "type": "boolean"
        }
      },
      "required": ["profile", "file", "embeddedVersion", "pluginVersion", "stale"],
      "additionalProperties": false
    },
    "PlaybookHealthEntry": {
      "type": "object",
      "properties": {
        "phase": {
          "type": "string"
        },
        "file": {
          "type": "string"
        },
        "exists": {
          "type": "boolean"
        }
      },
      "required": ["phase", "file", "exists"],
      "additionalProperties": false
    },
    "DependencyHealthEntry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "installed": {
          "type": "boolean"
        },
        "version": {
          "type": "string"
        },
        "optional": {
          "type": "boolean"
        }
      },
      "required": ["id", "label", "installed", "optional"],
      "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
    },
    "SupportedTool": {
      "type": "string",
      "enum": ["cursor", "vscode", "codex", "claude", "agentforce", "windsurf", "jetbrains", "opencode"]
    },
    "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
    },
    "TaskReconciliationFinding": {
      "type": "object",
      "properties": {
        "code": {
          "$ref": "#/definitions/TaskReconciliationCode"
        },
        "severity": {
          "type": "string",
          "enum": ["info", "warning", "error"]
        },
        "message": {
          "type": "string"
        },
        "repairable": {
          "type": "boolean"
        }
      },
      "required": ["code", "severity", "message", "repairable"],
      "additionalProperties": false
    },
    "TaskReconciliationCode": {
      "type": "string",
      "enum": [
        "legacy-no-workflow",
        "active-workflow",
        "failed-workflow",
        "blocked-phase",
        "pending-review",
        "rejected-review",
        "incomplete-required-phase",
        "run-terminal-conflict",
        "task-terminal-conflict",
        "orphan-phase-task",
        "missing-phase-linkage"
      ]
    }
  }
}
