{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://workspai.dev/schemas/cli-operation-result.v1.json",
  "title": "Workspai CLI Operation Result",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "operation",
    "status",
    "exitCode"
  ],
  "properties": {
    "schemaVersion": {
      "const": "workspai-cli-operation-result-v1"
    },
    "operation": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "enum": [
        "success",
        "error"
      ]
    },
    "exitCode": {
      "type": "integer",
      "minimum": 0
    },
    "artifact": {},
    "outputPath": {
      "type": "string",
      "minLength": 1
    },
    "error": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string",
          "minLength": 1
        },
        "message": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "context": {
      "type": "object",
      "additionalProperties": true
    },
    "examples": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "nextActions": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "success"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "required": [
          "artifact"
        ],
        "not": {
          "required": [
            "error"
          ]
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "error"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "required": [
          "error"
        ],
        "not": {
          "required": [
            "artifact"
          ]
        }
      }
    }
  ]
}
