{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "screenshotDir": {
      "description": "Directory for storing screenshots (default: .screenshots)",
      "type": "string"
    },
    "sessions": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Unique session name"
          },
          "source": {
            "description": "Source configuration (default: current working tree)",
            "type": "object",
            "properties": {
              "worktree": {
                "type": "object",
                "properties": {
                  "ref": {
                    "type": "string",
                    "description": "Git ref to check out (branch, tag, commit, or \"INDEX\" for the git staging area)"
                  },
                  "install": {
                    "description": "Dependency install strategy override for this session",
                    "anyOf": [
                      {
                        "type": "string",
                        "const": "auto"
                      },
                      {
                        "type": "string",
                        "const": "npm"
                      },
                      {
                        "type": "string",
                        "const": "pnpm"
                      },
                      {
                        "type": "string",
                        "const": "yarn"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "command": {
                            "type": "string",
                            "description": "Custom install command to run in the worktree"
                          }
                        },
                        "required": [
                          "command"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "boolean",
                        "const": false
                      }
                    ]
                  }
                },
                "required": [
                  "ref"
                ],
                "additionalProperties": false,
                "description": "Worktree source configuration"
              }
            },
            "required": [
              "worktree"
            ],
            "additionalProperties": false
          },
          "server": {
            "description": "Server configuration for this session (overrides top-level)",
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "vite"
                  },
                  "viteConfig": {
                    "description": "Path to vite config file, relative to this config",
                    "type": "string"
                  },
                  "hmr": {
                    "type": "object",
                    "properties": {
                      "allowedPaths": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Glob patterns for files that keep HMR; everything else triggers a full reload"
                      }
                    },
                    "required": [
                      "allowedPaths"
                    ],
                    "additionalProperties": false,
                    "description": "Vite HMR configuration"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false,
                "description": "Vite dev server configuration"
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "http"
                  },
                  "url": {
                    "type": "string",
                    "description": "URL of the HTTP server. Use ${var:name} to reference named capture groups from wait patterns"
                  },
                  "cmd": {
                    "description": "Command to start the HTTP server (e.g. \"npx rspack serve\")",
                    "type": "string"
                  },
                  "cwd": {
                    "description": "Working directory for cmd, relative to this config file (default: config file directory)",
                    "type": "string"
                  },
                  "wait": {
                    "description": "Wait for the server to be ready before connecting",
                    "type": "object",
                    "properties": {
                      "stdout": {
                        "description": "Regex pattern to wait for on stdout. Named capture groups become variables for the url field",
                        "type": "string"
                      },
                      "stderr": {
                        "description": "Regex pattern to wait for on stderr. Named capture groups become variables for the url field",
                        "type": "string"
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": [
                  "type",
                  "url"
                ],
                "additionalProperties": false,
                "description": "External HTTP server configuration"
              }
            ]
          },
          "viteConfig": {
            "description": "Path to vite config file, relative to this config (overrides top-level viteConfig)",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "description": "A component explorer session"
      },
      "description": "List of explorer sessions (currently only \"current\" working tree sessions)"
    },
    "worktree": {
      "description": "Dynamic worktree session pool configuration",
      "type": "object",
      "properties": {
        "setup": {
          "description": "Dependency install strategy for dynamic worktree sessions (default: auto)",
          "anyOf": [
            {
              "type": "string",
              "const": "auto"
            },
            {
              "type": "string",
              "const": "npm"
            },
            {
              "type": "string",
              "const": "pnpm"
            },
            {
              "type": "string",
              "const": "yarn"
            },
            {
              "type": "object",
              "properties": {
                "command": {
                  "type": "string",
                  "description": "Custom install command to run in the worktree"
                }
              },
              "required": [
                "command"
              ],
              "additionalProperties": false
            },
            {
              "type": "boolean",
              "const": false
            }
          ]
        },
        "maxSlots": {
          "description": "Maximum number of simultaneous worktree sessions (default: 2, max: 3)",
          "type": "integer",
          "minimum": 1,
          "maximum": 3
        }
      },
      "additionalProperties": false
    },
    "compare": {
      "type": "object",
      "properties": {
        "baseline": {
          "type": "string",
          "description": "Session name to use as the baseline for comparisons"
        },
        "current": {
          "type": "string",
          "description": "Session name to use as the current version for comparisons"
        }
      },
      "required": [
        "baseline",
        "current"
      ],
      "additionalProperties": false,
      "description": "Screenshot comparison configuration"
    },
    "server": {
      "description": "Default server configuration",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "vite"
            },
            "viteConfig": {
              "description": "Path to vite config file, relative to this config",
              "type": "string"
            },
            "hmr": {
              "type": "object",
              "properties": {
                "allowedPaths": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Glob patterns for files that keep HMR; everything else triggers a full reload"
                }
              },
              "required": [
                "allowedPaths"
              ],
              "additionalProperties": false,
              "description": "Vite HMR configuration"
            }
          },
          "required": [
            "type"
          ],
          "additionalProperties": false,
          "description": "Vite dev server configuration"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "http"
            },
            "url": {
              "type": "string",
              "description": "URL of the HTTP server. Use ${var:name} to reference named capture groups from wait patterns"
            },
            "cmd": {
              "description": "Command to start the HTTP server (e.g. \"npx rspack serve\")",
              "type": "string"
            },
            "cwd": {
              "description": "Working directory for cmd, relative to this config file (default: config file directory)",
              "type": "string"
            },
            "wait": {
              "description": "Wait for the server to be ready before connecting",
              "type": "object",
              "properties": {
                "stdout": {
                  "description": "Regex pattern to wait for on stdout. Named capture groups become variables for the url field",
                  "type": "string"
                },
                "stderr": {
                  "description": "Regex pattern to wait for on stderr. Named capture groups become variables for the url field",
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "required": [
            "type",
            "url"
          ],
          "additionalProperties": false,
          "description": "External HTTP server configuration"
        }
      ]
    },
    "viteConfig": {
      "description": "Default vite config file path, relative to this config (default: vite.config.ts)",
      "deprecated": true,
      "type": "string"
    },
    "vite": {
      "deprecated": true,
      "type": "object",
      "properties": {
        "hmr": {
          "type": "object",
          "properties": {
            "allowedPaths": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Glob patterns for files that keep HMR; everything else triggers a full reload"
            }
          },
          "required": [
            "allowedPaths"
          ],
          "additionalProperties": false,
          "description": "Vite HMR configuration"
        }
      },
      "additionalProperties": false,
      "description": "Vite configuration overrides"
    },
    "redirection": {
      "type": "object",
      "properties": {
        "port": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535,
          "description": "Port for the redirection HTTP server"
        },
        "host": {
          "description": "Host to bind the redirection server to (default: localhost)",
          "type": "string"
        }
      },
      "required": [
        "port"
      ],
      "additionalProperties": false,
      "description": "HTTP redirection server that redirects to the session URL"
    },
    "$schema": {
      "type": "string",
      "description": "URL of the JSON Schema for this config file"
    }
  },
  "required": [
    "sessions"
  ],
  "additionalProperties": false,
  "description": "Component Explorer configuration"
}
