{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://schemas.viable.works/AzureDevOpsCommandSchema/2/schema.json",
    "type": "object",
    "title": "Azure DevOps Swiss-Knife Command",
    "description": "Generic, AI-drivable, strongly typed command format for Azure DevOps (v9.1 - Structure First + Attributes Later philosophy using TreeNode + enhanced Work Item Type filtering)",
    "required": [
        "command"
    ],
    "oneOf": [
        {
            "$ref": "#/$defs/ReadPathCommand"
        },
        {
            "$ref": "#/$defs/CreatePathCommand"
        },
        {
            "$ref": "#/$defs/UpdatePathCommand"
        },
        {
            "$ref": "#/$defs/DeletePathCommand"
        },
        {
            "$ref": "#/$defs/ReadWorkItemsCommand"
        },
        {
            "$ref": "#/$defs/CreateWorkItemsCommand"
        },
        {
            "$ref": "#/$defs/UpdateWorkItemsCommand"
        },
        {
            "$ref": "#/$defs/DeleteWorkItemsCommand"
        },
        {
            "$ref": "#/$defs/RunWiqlCommand"
        },
        {
            "$ref": "#/$defs/ListProjectsCommand"
        },
        {
            "$ref": "#/$defs/ReadWikiPageListCommand"
        },
        {
            "$ref": "#/$defs/ReadWikiManifestCommand"
        },
        {
            "$ref": "#/$defs/ReadWikiPagesCommand"
        },
        {
            "$ref": "#/$defs/CreateWikiManifestCommand"
        },
        {
            "$ref": "#/$defs/CreateWikiPagesCommand"
        },
        {
            "$ref": "#/$defs/UpdateWikiPagesCommand"
        },
        {
            "$ref": "#/$defs/DeleteWikiPagesCommand"
        },
        {
            "$ref": "#/$defs/MoveWikiPagesCommand"
        },
        {
            "$ref": "#/$defs/ReadProcessesCommand"
        },
        {
            "$ref": "#/$defs/CreateInheritedProcessCommand"
        },
        {
            "$ref": "#/$defs/ReadWorkItemTypesCommand"
        },
        {
            "$ref": "#/$defs/CreateWorkItemTypesCommand"
        },
        {
            "$ref": "#/$defs/ReadFieldsCommand"
        },
        {
            "$ref": "#/$defs/CreateFieldsCommand"
        },
        {
            "$ref": "#/$defs/ReadBehaviorsCommand"
        },
        {
            "$ref": "#/$defs/CreateBehaviorsCommand"
        },
        {
            "$ref": "#/$defs/ReadRulesCommand"
        },
        {
            "$ref": "#/$defs/CreateRulesCommand"
        },
        {
            "$ref": "#/$defs/ReadWorkItemTypeLayoutCommand"
        },
        {
            "$ref": "#/$defs/UpdateWorkItemTypeLayoutCommand"
        },
        {
            "$ref": "#/$defs/ExportProcessTemplateCommand"
        },
        {
            "$ref": "#/$defs/ImportProcessTemplateCommand"
        }
    ],
    "$defs": {
        "BaseCommand": {
            "type": "object",
            "properties": {
                "command": {
                    "title": "Command Name",
                    "description": "The specific operation to execute."
                },
                "project": {
                    "title": "Project",
                    "description": "Azure DevOps project name or GUID. If omitted, falls back to the configured project."
                },
                "dryRun": {
                    "type": "boolean",
                    "title": "Dry Run Mode",
                    "description": "When true, only simulates the operation without making changes. Strongly recommended for safety.",
                    "default": true
                },
                "logLevel": {
                    "type": "string",
                    "title": "Log Level",
                    "description": "Controls verbosity of execution logs.",
                    "default": "INFO",
                    "enum": [
                        "DEBUG",
                        "INFO",
                        "WARN",
                        "ERROR"
                    ]
                },
                "sessionId": {
                    "type": "string",
                    "title": "Session ID",
                    "description": "Optional unique identifier for traceability across multiple commands."
                }
            }
        },
        "TreePath": {
            "type": "string",
            "description": "Full Azure DevOps Area or Iteration path. Each node name must NOT contain forbidden characters: \\ / : * ? \" < > | # $ & * + . \nRecommendation for legacy sync: Replace '&' with 'and', remove or replace other special chars with '_'. Paths begin without a leading separator.",
            "maxLength": 4000,
            "pattern": "^[^\\\\/:*?\"<>|#\\$&*+\\.]+(\\\\[^\\/:*?\"<>|#\\$&*+\\.]+)*$",
            "examples": [
                "OTA Toolchain",
                "OTA Toolchain\\Requirements and Architecture",
                "Platform\\Team A\\Subsystem X"
            ]
        },
        "TreeNodeName": {
            "type": "string",
            "description": "Single node name within an Area/Iteration path (no separators allowed). Forbidden characters: \\ / : * ? \" < > | # $ & * + .",
            "maxLength": 255,
            "pattern": "^[^\\\\/:*?\"<>|#\\$&*+\\.]+$",
            "examples": [
                "Requirements and Architecture",
                "Team A"
            ]
        },
        "TreeNode": {
            "type": "object",
            "title": "Tree Node (Structure Only)",
            "description": "Simple recursive node for hierarchy creation. Used in createPath. Attributes are applied later via updatePath (Structure First + Attributes Later philosophy).",
            "properties": {
                "name": {
                    "$ref": "#/$defs/TreeNodeName",
                    "title": "Node Name",
                    "description": "Display name of the area or iteration."
                },
                "children": {
                    "type": "array",
                    "title": "Child Nodes",
                    "description": "Recursive list of child nodes.",
                    "items": {
                        "$ref": "#/$defs/TreeNode"
                    }
                }
            },
            "required": [
                "name"
            ]
        },
        "WorkItemLink": {
            "type": "object",
            "title": "Work Item Link",
            "description": "Defines a link/relation to another work item or artifact.",
            "properties": {
                "rel": {
                    "type": "string",
                    "title": "Relation Type",
                    "description": "Link type. Common values: System.LinkTypes.Hierarchy-Reverse (Parent), System.LinkTypes.Related, System.LinkTypes.Dependency-Forward, etc."
                },
                "targetId": {
                    "type": "integer",
                    "title": "Target Work Item ID",
                    "description": "ID of the target work item to link to."
                },
                "comment": {
                    "type": "string",
                    "title": "Link Comment",
                    "description": "Optional comment for the link."
                }
            },
            "required": [
                "rel",
                "targetId"
            ]
        },
        "ReadPathCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readPath"
                        },
                        "type": {
                            "type": "string",
                            "title": "Path Type",
                            "description": "Whether to read Area Paths or Iteration Paths.",
                            "enum": [
                                "area",
                                "iteration"
                            ]
                        },
                        "rootPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Root Path",
                            "description": "Optional root path to read a subtree from (e.g. '\\Platform\\SDV'). If omitted, returns the full tree."
                        },
                        "depth": {
                            "type": "integer",
                            "title": "Maximum Depth",
                            "description": "Maximum depth of the tree to retrieve.",
                            "default": 10
                        }
                    },
                    "required": [
                        "type"
                    ]
                }
            ]
        },
        "CreatePathCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createPath"
                        },
                        "type": {
                            "type": "string",
                            "title": "Path Type",
                            "description": "Whether to create Area Paths or Iteration Paths.",
                            "enum": [
                                "area",
                                "iteration"
                            ]
                        },
                        "rootPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Root Path",
                            "description": "Optional parent path under which to create new nodes (e.g. '\\Platform\\Core'). If omitted, creates at project root."
                        },
                        "items": {
                            "type": "array",
                            "title": "Nodes to Create",
                            "description": "Array of TreeNode trees to create (supports multiple root nodes).",
                            "items": {
                                "$ref": "#/$defs/TreeNode"
                            }
                        }
                    },
                    "required": [
                        "type",
                        "items"
                    ]
                }
            ]
        },
        "UpdatePathCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "updatePath"
                        },
                        "type": {
                            "type": "string",
                            "title": "Path Type",
                            "description": "Whether to update Area Paths or Iteration Paths.",
                            "enum": [
                                "area",
                                "iteration"
                            ]
                        },
                        "rootPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Root Path",
                            "description": "Optional parent path context for updates (e.g. '\\Platform\\Core')."
                        },
                        "items": {
                            "type": "array",
                            "title": "Nodes to Update",
                            "description": "Array of nodes to update. Use 'path' (preferred) or 'id'.",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "path": {
                                        "$ref": "#/$defs/TreePath",
                                        "title": "Node Path",
                                        "description": "Full path of the node to update (e.g. '\\Platform\\Core')"
                                    },
                                    "name": {
                                        "$ref": "#/$defs/TreeNodeName",
                                        "title": "New Name",
                                        "description": "New name for the node"
                                    },
                                    "attributes": {
                                        "type": "object",
                                        "title": "Node Attributes",
                                        "description": "Additional attributes. For iterations: startDate and finishDate (ISO 8601).",
                                        "properties": {
                                            "startDate": {
                                                "type": "string",
                                                "title": "Start Date",
                                                "description": "Start date for iteration (ISO 8601, e.g. '2026-01-01T00:00:00Z')",
                                                "format": "date-time"
                                            },
                                            "finishDate": {
                                                "type": "string",
                                                "title": "Finish Date",
                                                "description": "Finish date for iteration (ISO 8601, e.g. '2026-01-15T00:00:00Z')",
                                                "format": "date-time"
                                            }
                                        }
                                    }
                                },
                                "required": [
                                    "path"
                                ]
                            }
                        }
                    },
                    "required": [
                        "type",
                        "items"
                    ]
                }
            ]
        },
        "DeletePathCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "deletePath"
                        },
                        "type": {
                            "type": "string",
                            "title": "Path Type",
                            "description": "Whether to delete Area Paths or Iteration Paths.",
                            "enum": [
                                "area",
                                "iteration"
                            ]
                        },
                        "rootPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Root Path",
                            "description": "Optional parent path context for deletion."
                        },
                        "items": {
                            "type": "array",
                            "title": "Nodes to Delete",
                            "description": "Array of paths to delete.",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "path": {
                                        "$ref": "#/$defs/TreePath",
                                        "title": "Full Path",
                                        "description": "Full path to delete (e.g. '\\Platform\\LegacyFeature')"
                                    }
                                },
                                "required": [
                                    "path"
                                ]
                            }
                        }
                    },
                    "required": [
                        "type",
                        "items"
                    ]
                }
            ]
        },
        "ReadWorkItemsCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readWorkItems"
                        },
                        "areaPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Area Path Filter",
                            "description": "Full area path to filter work items (e.g. '\\Platform\\Solutions'). Optional."
                        },
                        "iterationPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Iteration Path Filter",
                            "description": "Full iteration path to filter work items (e.g. '\\Platform\\2026\\Sprint 07'). Optional."
                        },
                        "includeSubAreas": {
                            "type": "boolean",
                            "title": "Include Sub Areas",
                            "description": "If true (default), includes work items from child/descendant Area Paths.",
                            "default": true
                        },
                        "includeSubIterations": {
                            "type": "boolean",
                            "title": "Include Sub Iterations",
                            "description": "If true (default), includes work items from child/descendant Iteration Paths.",
                            "default": true
                        },
                        "includedStates": {
                            "type": "array",
                            "title": "Included States",
                            "description": "Array of states to include (e.g. ['Active', 'Resolved']). Only one of includedStates or excludedStates should be used.",
                            "items": {
                                "type": "string"
                            }
                        },
                        "excludedStates": {
                            "type": "array",
                            "title": "Excluded States",
                            "description": "Array of states to exclude (e.g. ['Closed', 'Removed']). Only one of includedStates or excludedStates should be used.",
                            "items": {
                                "type": "string"
                            }
                        },
                        "includedWorkItemTypes": {
                            "type": "array",
                            "title": "Included Work Item Types",
                            "description": "Filter to only specific Work Item Types (e.g. ['User Story', 'Task', 'Bug']). If omitted, all types are returned. Use this OR excludedWorkItemTypes.",
                            "items": {
                                "type": "string"
                            },
                            "examples": [
                                [
                                    "User Story"
                                ],
                                [
                                    "Task",
                                    "Bug"
                                ],
                                [
                                    "Epic",
                                    "Feature",
                                    "User Story"
                                ]
                            ]
                        },
                        "excludedWorkItemTypes": {
                            "type": "array",
                            "title": "Excluded Work Item Types",
                            "description": "Exclude specific Work Item Types. Use this OR includedWorkItemTypes (not both).",
                            "items": {
                                "type": "string"
                            }
                        },
                        "limit": {
                            "type": "integer",
                            "title": "Result Limit",
                            "description": "Maximum number of work items to return.",
                            "default": 500
                        },
                        "fields": {
                            "type": "array",
                            "title": "Fields to Return",
                            "description": "Optional list of specific fields to include. If omitted or empty, returns complete work item objects.",
                            "items": {
                                "type": "string"
                            }
                        },
                        "includedIds": {
                            "type": "array",
                            "description": "Ids to be included in the work item list.",
                            "items": {
                                "type": "integer"
                            }
                        },
                        "excludedIds": {
                            "type": "array",
                            "description": "Ids to be excluded from the work item list.",
                            "items": {
                                "type": "integer"
                            }
                        },
                        "includeRelations": {
                            "type": "boolean"
                        }
                    },
                    "required": []
                }
            ]
        },
        "CreateWorkItemsCommand": {
            "properties": {
                "items": {
                    "type": "array",
                    "title": "Work Items to Create",
                    "description": "Array of work items to create in batch. Per-item 'type' overrides defaultType.",
                    "minItems": 1,
                    "items": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "title": "Work Item Type",
                                "description": "Work Item Type (overrides defaultType if provided)."
                            },
                            "title": {
                                "type": "string",
                                "title": "Title",
                                "description": "Title of the work item (required)."
                            },
                            "description": {
                                "type": "string",
                                "title": "Description",
                                "description": "HTML or plain text description."
                            },
                            "areaPath": {
                                "$ref": "#/$defs/TreePath",
                                "title": "Area Path",
                                "description": "Full area path (overrides defaultAreaPath)."
                            },
                            "iterationPath": {
                                "$ref": "#/$defs/TreePath",
                                "title": "Iteration Path",
                                "description": "Full iteration path (overrides defaultIterationPath)."
                            },
                            "assignedTo": {
                                "type": "string",
                                "title": "Assigned To",
                                "description": "Person to assign the work item to."
                            },
                            "effort": {
                                "type": "integer",
                                "title": "Effort"
                            },
                            "storyPoints": {
                                "type": "number",
                                "title": "Story Points"
                            },
                            "fields": {
                                "type": "object",
                                "title": "Additional Fields",
                                "description": "Custom or other System.* / custom fields as key-value pairs.",
                                "additionalProperties": true
                            },
                            "links": {
                                "type": "array",
                                "title": "Links / Relations",
                                "description": "Links to other work items (e.g. Parent, Related). Note: Only links to already existing work items are possible during creation.",
                                "items": {
                                    "$ref": "#/$defs/WorkItemLink"
                                }
                            }
                        },
                        "required": [
                            "title"
                        ]
                    }
                }
            },
            "required": [
                "items"
            ],
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createWorkItems"
                        },
                        "defaultType": {
                            "type": "string",
                            "title": "Default Work Item Type",
                            "description": "Default type applied to all items if no per-item 'type' is specified (e.g. 'UserStory', 'Task'). Per-item 'type' takes precedence.",
                            "examples": [
                                "UserStory",
                                "Task",
                                "Bug",
                                "Feature",
                                "Epic"
                            ]
                        },
                        "defaultAreaPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Default Area Path",
                            "description": "Default Area Path applied to all items unless overridden at item level."
                        },
                        "defaultIterationPath": {
                            "$ref": "#/$defs/TreePath",
                            "title": "Default Iteration Path",
                            "description": "Default Iteration Path applied to all items unless overridden at item level."
                        },
                        "validateOnly": {
                            "type": "boolean",
                            "title": "Validate Only",
                            "description": "If true, sends the request with Azure DevOps validation only (no actual creation).",
                            "default": false
                        }
                    }
                }
            ]
        },
        "UpdateWorkItemsCommand": {
            "properties": {
                "items": {
                    "type": "array",
                    "title": "Work Items to Update",
                    "description": "Array of work item updates. Identification is done exclusively by 'id' (integer).",
                    "minItems": 1,
                    "items": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "integer",
                                "title": "Work Item ID",
                                "description": "Numeric ID of the work item to update (must be integer)."
                            },
                            "fields": {
                                "type": "object",
                                "title": "Fields to Update",
                                "description": "Key-value pairs of fields to update. All standard fields (System.*, Microsoft.VSTS.*) and custom fields go here.",
                                "additionalProperties": true
                            },
                            "links": {
                                "type": "array",
                                "title": "Links / Relations",
                                "description": "Links to add to the work item.",
                                "items": {
                                    "$ref": "#/$defs/WorkItemLink"
                                }
                            }
                        },
                        "required": [
                            "id"
                        ]
                    }
                }
            },
            "required": [
                "items"
            ],
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "updateWorkItems"
                        },
                        "validateOnly": {
                            "type": "boolean",
                            "title": "Validate Only",
                            "description": "If true, only validates the updates without applying them to Azure DevOps.",
                            "default": false
                        }
                    }
                }
            ]
        },
        "DeleteWorkItemsCommand": {
            "properties": {
                "items": {
                    "type": "array",
                    "title": "Work Items to Delete",
                    "description": "Array of work item IDs to delete (moves to Recycle Bin by default).",
                    "items": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "integer",
                                "title": "Work Item ID",
                                "description": "Numeric ID of the work item"
                            },
                            "destroy": {
                                "type": "boolean",
                                "title": "Permanent Delete",
                                "description": "If true, permanently destroys the work item (bypasses Recycle Bin). Use with extreme caution.",
                                "default": false
                            }
                        },
                        "required": [
                            "id"
                        ]
                    }
                }
            },
            "required": [
                "items"
            ],
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "deleteWorkItems"
                        }
                    }
                }
            ]
        },
        "RunWiqlCommand": {
            "properties": {
                "wiql": {
                    "type": "string",
                    "title": "WIQL Query",
                    "description": "Work Item Query Language string to execute."
                },
                "limit": {
                    "type": "integer",
                    "title": "Result Limit",
                    "description": "Maximum number of results to return.",
                    "default": 200
                }
            },
            "required": [
                "wiql"
            ],
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "runWiql"
                        }
                    }
                }
            ]
        },
        "ListProjectsCommand": {
            "properties": {
                "stateFilter": {
                    "type": "string",
                    "title": "State Filter",
                    "description": "Filter projects by state.",
                    "enum": [
                        "all",
                        "wellFormed"
                    ]
                }
            },
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "listProjects"
                        }
                    }
                }
            ]
        },
        "WikiIdentifier": {
            "type": "string",
            "description": "Name or ID of the wiki. Can be the wiki name or its ID (GUID)."
        },
        "WikiPagePath": {
            "type": "string",
            "description": "Path of a wiki page. Must begin without any leading \"/\". Example: \"Architecture/Overview\""
        },
        "WikiPageReference": {
            "type": "object",
            "properties": {
                "path": {
                    "$ref": "#/$defs/WikiPagePath"
                },
                "title": {
                    "type": "string",
                    "description": "Title of the page (optional, mainly for display)"
                }
            },
            "required": [
                "path"
            ]
        },
        "WikiManifestEntry": {
            "type": "object",
            "description": "Entry in the wiki manifest containing metadata and the manifest section content.",
            "properties": {
                "path": {
                    "$ref": "#/$defs/WikiPagePath"
                },
                "title": {
                    "type": "string"
                },
                "url": {
                    "type": "string",
                    "format": "uri"
                },
                "lastModified": {
                    "type": "string",
                    "format": "date-time"
                },
                "manifestContent": {
                    "type": "string",
                    "description": "Markdown content found below the '## Manifest' headline. Empty string if section does not exist."
                }
            },
            "required": [
                "path",
                "title",
                "manifestContent"
            ]
        },
        "WikiPageContent": {
            "type": "object",
            "properties": {
                "path": {
                    "$ref": "#/$defs/WikiPagePath"
                },
                "content": {
                    "type": "string",
                    "description": "Full page content in Markdown format."
                }
            },
            "required": [
                "path",
                "content"
            ]
        },
        "ReadWikiPageListCommand": {
            "title": "Read Wiki Page List Command",
            "description": "Returns a flat, lightweight list of all page paths within a wiki (or a subtree). This command is intended for discovery and exploration when only the list of paths is needed, without manifest content or full page bodies. It works identically for both Project Wiki and Code Wiki.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "title": "Command Name",
                            "description": "The command identifier. Must be set to 'readWikiPageList'.",
                            "const": "readWikiPageList"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier",
                            "title": "Wiki Identifier",
                            "description": "Name or ID of the wiki to query. This can be the wiki name or its GUID."
                        },
                        "rootPath": {
                            "$ref": "#/$defs/WikiPagePath",
                            "title": "Root Path",
                            "description": "Optional path to limit the results to a specific subtree. If omitted, the entire wiki is scanned. Paths should not include a leading slash (e.g. 'Architecture' or 'Architecture/Decisions')."
                        },
                        "recurse": {
                            "type": "boolean",
                            "title": "Recurse into Subdirectories",
                            "description": "If true (default), includes all pages recursively under the rootPath. If false, only returns pages directly under the specified rootPath.",
                            "default": true
                        }
                    },
                    "additionalProperties": true,
                    "required": [
                        "wiki"
                    ]
                }
            ]
        },
        "ReadWikiManifestCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readWikiManifest"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "rootPath": {
                            "$ref": "#/$defs/WikiPagePath"
                        },
                        "recurse": {
                            "type": "boolean",
                            "default": true
                        }
                    },
                    "required": [
                        "wiki"
                    ]
                }
            ]
        },
        "ReadWikiPagesCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readWikiPages"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "paths": {
                            "type": "array",
                            "minItems": 1,
                            "items": {
                                "$ref": "#/$defs/WikiPagePath"
                            }
                        }
                    },
                    "required": [
                        "wiki",
                        "paths"
                    ]
                }
            ]
        },
        "CreateWikiManifestCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createWikiManifest"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "message": {
                            "$ref": "#/$defs/ChangeMessage",
                            "examples": [
                                "Added/updated manifest section"
                            ]
                        },
                        "pages": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "path": {
                                        "$ref": "#/$defs/WikiPagePath"
                                    },
                                    "manifestContent": {
                                        "type": "string",
                                        "description": "Markdown content to place under the ## Manifest headline"
                                    }
                                },
                                "required": [
                                    "path",
                                    "manifestContent"
                                ]
                            }
                        }
                    },
                    "required": [
                        "wiki",
                        "pages"
                    ]
                }
            ]
        },
        "CreateWikiPagesCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createWikiPages"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "message": {
                            "$ref": "#/$defs/ChangeMessage"
                        },
                        "pages": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "path": {
                                        "$ref": "#/$defs/WikiPagePath"
                                    },
                                    "content": {
                                        "type": "string"
                                    },
                                    "message": {
                                        "$ref": "#/$defs/ChangeMessage"
                                    }
                                },
                                "required": [
                                    "path",
                                    "content"
                                ]
                            }
                        }
                    },
                    "required": [
                        "wiki",
                        "pages"
                    ]
                }
            ]
        },
        "UpdateWikiPagesCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "updateWikiPages"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "message": {
                            "$ref": "#/$defs/ChangeMessage"
                        },
                        "pages": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "path": {
                                        "$ref": "#/$defs/WikiPagePath"
                                    },
                                    "content": {
                                        "type": "string"
                                    },
                                    "message": {
                                        "$ref": "#/$defs/ChangeMessage"
                                    }
                                },
                                "required": [
                                    "path",
                                    "content"
                                ]
                            }
                        }
                    },
                    "required": [
                        "wiki",
                        "pages"
                    ]
                }
            ]
        },
        "DeleteWikiPagesCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "deleteWikiPages"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "paths": {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/WikiPagePath"
                            }
                        }
                    },
                    "required": [
                        "wiki",
                        "paths"
                    ]
                }
            ]
        },
        "MoveWikiPagesCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "moveWikiPages"
                        },
                        "wiki": {
                            "$ref": "#/$defs/WikiIdentifier"
                        },
                        "moves": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "fromPath": {
                                        "$ref": "#/$defs/WikiPagePath"
                                    },
                                    "toPath": {
                                        "$ref": "#/$defs/WikiPagePath"
                                    },
                                    "message": {
                                        "$ref": "#/$defs/ChangeMessage"
                                    }
                                },
                                "required": [
                                    "fromPath",
                                    "toPath"
                                ]
                            }
                        },
                        "message": {
                            "$ref": "#/$defs/ChangeMessage"
                        }
                    },
                    "required": [
                        "wiki",
                        "moves"
                    ]
                }
            ]
        },
        "ChangeMessage": {
            "type": "string",
            "description": "Optional message describing the change. This message will appear in the history of wiki pages, as commit comment in git and as a comment in work items."
        },
        "ReadProcessesCommand": {
            "description": "Reads all processes (system and inherited) in the organization. Maps to GET /_apis/work/processes. Returns multiple process summaries.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readProcesses"
                        },
                        "includeSystemProcesses": {
                            "type": "boolean",
                            "description": "Whether to include Microsoft system processes (Agile, Scrum, etc.) in the result.",
                            "default": true
                        }
                    },
                    "required": [
                        "command"
                    ]
                }
            ]
        },
        "CreateInheritedProcessCommand": {
            "description": "Creates a new Inherited process from a system base. Maps to POST /_apis/work/processes.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createInheritedProcess"
                        },
                        "name": {
                            "type": "string",
                            "description": "Name of the new inherited process (readable, no IDs)."
                        },
                        "description": {
                            "type": "string"
                        },
                        "baseProcess": {
                            "type": "string",
                            "description": "The system process to inherit from.",
                            "enum": [
                                "Agile",
                                "Scrum",
                                "Basic",
                                "CMMI"
                            ]
                        }
                    },
                    "required": [
                        "command",
                        "name",
                        "baseProcess"
                    ]
                }
            ]
        },
        "ReadWorkItemTypesCommand": {
            "description": "Reads all work item types for a process. Maps to GET /_apis/work/processes/{processId}/workItemTypes.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readWorkItemTypes"
                        },
                        "processId": {
                            "type": "string",
                            "description": "The ID or referenceName of the process."
                        },
                        "expand": {
                            "type": "string",
                            "description": "What to expand in the response.",
                            "default": "none",
                            "enum": [
                                "none",
                                "fields",
                                "layout"
                            ]
                        }
                    },
                    "required": [
                        "command",
                        "processId"
                    ]
                }
            ]
        },
        "CreateWorkItemTypesCommand": {
            "description": "Creates one or more work item types in a process. Batch support.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createWorkItemTypes"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "items": {
                            "type": "array",
                            "minItems": 1,
                            "items": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "referenceName": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "color": {
                                        "type": "string"
                                    },
                                    "icon": {
                                        "type": "string"
                                    },
                                    "inheritsFrom": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "items"
                    ]
                }
            ]
        },
        "ReadFieldsCommand": {
            "description": "Reads all fields for a work item type. Maps to GET /_apis/work/processes/{processId}/workItemTypes/{witRefName}/fields.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readFields"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "workItemTypeRefName": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "workItemTypeRefName"
                    ]
                }
            ]
        },
        "CreateFieldsCommand": {
            "description": "Creates one or more fields for a work item type. Batch support.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createFields"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "workItemTypeRefName": {
                            "type": "string"
                        },
                        "items": {
                            "type": "array",
                            "minItems": 1,
                            "items": {
                                "type": "object",
                                "properties": {
                                    "referenceName": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "isRequired": {
                                        "type": "boolean"
                                    },
                                    "defaultValue": {}
                                }
                            }
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "workItemTypeRefName",
                        "items"
                    ]
                }
            ]
        },
        "ReadBehaviorsCommand": {
            "description": "Reads behaviors for a process. Maps to GET /_apis/work/processes/{processId}/behaviors.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readBehaviors"
                        },
                        "processId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "command",
                        "processId"
                    ]
                }
            ]
        },
        "CreateBehaviorsCommand": {
            "description": "Creates one or more behaviors for a process. Batch support.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createBehaviors"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "items": {
                            "type": "array",
                            "minItems": 1,
                            "items": {
                                "type": "object"
                            }
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "items"
                    ]
                }
            ]
        },
        "ReadRulesCommand": {
            "description": "Reads rules for a process (optionally filtered by work item type).",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readRules"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "workItemTypeRefName": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "command",
                        "processId"
                    ]
                }
            ]
        },
        "CreateRulesCommand": {
            "description": "Creates one or more rules. Batch support.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "createRules"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "items": {
                            "type": "array",
                            "minItems": 1,
                            "items": {
                                "type": "object"
                            }
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "items"
                    ]
                }
            ]
        },
        "ReadWorkItemTypeLayoutCommand": {
            "description": "Reads the full form layout for a work item type.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "readWorkItemTypeLayout"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "workItemTypeRefName": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "workItemTypeRefName"
                    ]
                }
            ]
        },
        "UpdateWorkItemTypeLayoutCommand": {
            "description": "Updates the form layout for a work item type.",
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "updateWorkItemTypeLayout"
                        },
                        "processId": {
                            "type": "string"
                        },
                        "workItemTypeRefName": {
                            "type": "string"
                        },
                        "layout": {
                            "type": "object"
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "workItemTypeRefName",
                        "layout"
                    ]
                }
            ]
        },
        "ExportProcessTemplateCommand": {
            "allOf": [
                {
                    "$ref": "#/$defs/BaseCommand"
                },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "exportProcessTemplate"
                        },
                        "processId": {
                            "type": "string",
                            "description": "Process ID or reference name to export"
                        },
                        "format": {
                            "type": "string",
                            "default": "richManifest",
                            "enum": [
                                "zip",
                                "richManifest"
                            ]
                        },
                        "tenantName": {
                            "type": "string",
                            "description": "Mandatory tenant identifier for safety (prevents accidental writes to wrong tenant)"
                        }
                    },
                    "required": [
                        "command",
                        "processId",
                        "format",
                        "tenantName"
                    ]
                }
            ]
        },
        "ImportProcessTemplateCommand": {
            "description": "Imports a process from a manifest or ZIP.",
            "allOf": [
                { "$ref": "#/$defs/BaseCommand" },
                {
                    "type": "object",
                    "properties": {
                        "command": {
                            "const": "importProcessTemplate"
                        },
                        "format": {
                            "type": "string",
                            "enum": ["richManifest", "zip"],
                            "default": "richManifest"
                        },
                        "manifest": {
                            "type": "object"
                        },
                        "zip": {
                            "type": "string",
                            "description": "Base64 URL-encoded ZIP file exported directly from Azure DevOps"
                        },
                        "replaceExisting": {
                            "type": "boolean",
                            "default": false
                        }
                    },
                    "required": ["command", "format"],
                    "oneOf": [
                        { "required": ["manifest"] },
                        { "required": ["zip"] }
                    ]
                }
            ]
        }
    },
    "discriminator": {
        "propertyName": "command",
        "mapping": {
            "readPath": "#/$defs/ReadPathCommand",
            "createPath": "#/$defs/CreatePathCommand",
            "updatePath": "#/$defs/UpdatePathCommand",
            "deletePath": "#/$defs/DeletePathCommand",
            "readWorkItems": "#/$defs/ReadWorkItemsCommand",
            "createWorkItems": "#/$defs/CreateWorkItemsCommand",
            "updateWorkItems": "#/$defs/UpdateWorkItemsCommand",
            "deleteWorkItems": "#/$defs/DeleteWorkItemsCommand",
            "runWiql": "#/$defs/RunWiqlCommand",
            "listProjects": "#/$defs/ListProjectsCommand",
            "readWikiPageList": "#/$defs/ReadWikiPageListCommand",
            "readWikiManifest": "#/$defs/ReadWikiManifestCommand",
            "readWikiPages": "#/$defs/ReadWikiPagesCommand",
            "createWikiManifest": "#/$defs/CreateWikiManifestCommand",
            "createWikiPages": "#/$defs/CreateWikiPagesCommand",
            "updateWikiPages": "#/$defs/UpdateWikiPagesCommand",
            "deleteWikiPages": "#/$defs/DeleteWikiPagesCommand",
            "moveWikiPages": "#/$defs/MoveWikiPagesCommand",
            "readProcesses": "#/$defs/ReadProcessesCommand",
            "createInheritedProcess": "#/$defs/CreateInheritedProcessCommand",
            "readWorkItemTypes": "#/$defs/ReadWorkItemTypesCommand",
            "createWorkItemTypes": "#/$defs/CreateWorkItemTypesCommand",
            "readFields": "#/$defs/ReadFieldsCommand",
            "createFields": "#/$defs/CreateFieldsCommand",
            "readBehaviors": "#/$defs/ReadBehaviorsCommand",
            "createBehaviors": "#/$defs/CreateBehaviorsCommand",
            "readRules": "#/$defs/ReadRulesCommand",
            "createRules": "#/$defs/CreateRulesCommand",
            "readWorkItemTypeLayout": "#/$defs/ReadWorkItemTypeLayoutCommand",
            "updateWorkItemTypeLayout": "#/$defs/UpdateWorkItemTypeLayoutCommand",
            "exportProcessTemplate": "#/$defs/ExportProcessTemplateCommand",
            "importProcessTemplate": "#/$defs/ImportProcessTemplateCommand"
        }
    },
    "version": "2.2.0"
}