{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["defaultOrg", "features"],
  "additionalProperties": true,
  "properties": {
    "projectName": { "type": "string" },
    "defaultOrg": { "type": "string", "minLength": 1, "pattern": "\\S" },
    "releaseNotesDir": { "type": "string" },
    "manifestDir": { "type": "string" },
    "changelogDir": { "type": "string" },
    "logDir": { "type": "string" },
    "logRetention": { "type": "integer", "minimum": 1 },
    "manifestLayout": { "type": "string", "enum": ["flat", "subpath"] },
    "defaultBranch": { "type": "string" },
    "smokeTests": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "testClasses": { "type": "array", "items": { "type": "string" } }
      }
    },
    "plugins": { "type": "array", "items": { "type": "string" } },
    "features": {
      "type": "object",
      "additionalProperties": { "type": "boolean" }
    },
    "ai": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "provider": { "type": "string", "enum": ["claude", "gemini", "openai", "http"] },
        "model": { "type": "string" },
        "apiKey": { "type": "string" },
        "baseURL": { "type": "string" },
        "apiKeyEnv": { "type": "string" },
        "headers": { "type": "object", "additionalProperties": { "type": "string" } },
        "headersEnv": { "type": "object", "additionalProperties": { "type": "string" } },
        "timeoutMs": { "type": "number" },
        "agent": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enabled": { "type": "boolean" },
            "maxTurns": { "type": "integer", "minimum": 1, "maximum": 20 },
            "allowWrite": { "type": "boolean" }
          }
        }
      }
    },
    "notifications": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": { "type": "boolean" },
        "summary": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enabled": { "type": "boolean" }
          }
        },
        "slack": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "webhookUrl": { "type": "string" },
            "webhookUrlEnv": { "type": "string" }
          }
        },
        "channels": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["type"],
            "properties": {
              "type": { "type": "string", "enum": ["slack", "teams", "email", "webhook", "googlechat"] },
              "name": { "type": "string" },
              "webhookUrl": { "type": "string" },
              "webhookUrlEnv": { "type": "string" },
              "url": { "type": "string" },
              "urlEnv": { "type": "string" },
              "format": { "type": "string", "enum": ["json", "loki"] },
              "headers": { "type": "object", "additionalProperties": { "type": "string" } },
              "headersEnv": { "type": "object", "additionalProperties": { "type": "string" } },
              "severityThreshold": { "type": "string", "enum": ["ok", "warn", "error", "fail"] },
              "events": { "type": "array", "items": { "type": "string" } },
              "from": { "type": "string" },
              "to": { "type": "array", "items": { "type": "string" } },
              "smtp": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "hostEnv": { "type": "string" },
                  "portEnv": { "type": "string" },
                  "userEnv": { "type": "string" },
                  "passwordEnv": { "type": "string" },
                  "secure": { "type": "boolean" }
                }
              }
            }
          }
        }
      }
    },
    "deployment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "coverageThreshold": { "type": "number", "minimum": 0, "maximum": 100 },
        "backupBeforeRollback": { "type": "boolean" },
        "keyClasses": { "type": "array", "items": { "type": "string" } },
        "preflight": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enforceTests": { "type": "boolean" },
            "enforceBranchNaming": { "type": "boolean" },
            "enforceChangelog": { "type": "boolean" },
            "enforceGitClean": { "type": "boolean" },
            "enforceSfdxProject": { "type": "boolean" },
            "enforceUntrackedFiles": { "type": "boolean" },
            "strict": { "type": "boolean" }
          }
        },
        "smart": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enabled": { "type": "boolean" },
            "deltaBase": { "type": "string" },
            "noOverwriteManifest": { "type": "string" },
            "impactingTypes": { "type": "array", "items": { "type": "string" } },
            "downgradeTestsOnNonProd": { "type": "boolean" },
            "useRelevantTests": { "type": "boolean" },
            "assumeProd": { "type": "boolean" }
          }
        }
      }
    },
    "pluginOptions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "autoDiscover": { "type": "boolean" }
      }
    },
    "pullCache": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": { "type": "boolean" },
        "parallelism": { "type": "integer", "minimum": 1 },
        "batchSize": { "type": "integer", "minimum": 1 },
        "retrieveTimeoutSeconds": { "type": "integer", "minimum": 1 }
      }
    },
    "mcp": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": { "type": "boolean" },
        "salesforce": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "transport": { "type": "string" },
            "command": { "type": "string" },
            "args": { "type": "array", "items": { "type": "string" } }
          }
        },
        "parking": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enabled": { "type": "boolean" },
            "thresholdBytes": { "type": "integer", "minimum": 0 },
            "ttlSeconds": { "type": "integer", "minimum": 0 },
            "cacheScope": { "type": "string" }
          }
        }
      }
    },
    "environments": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "default": { "type": "string" },
        "orgs": { "type": "array" }
      }
    },
    "audit": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "auditTrailLookbackDays": { "type": "integer", "minimum": 1 },
        "auditTrailMaxRows": { "type": "integer", "minimum": 1 },
        "auditTrailVelocityWindowHours": { "type": "integer", "minimum": 1 },
        "auditTrailVelocityFactor": { "type": "number", "minimum": 1 },
        "auditTrailVelocityMinEvents": { "type": "integer", "minimum": 1 },
        "licenseWarnThreshold": { "type": "number", "minimum": 0, "maximum": 1 },
        "inactiveUserDays": { "type": "integer", "minimum": 1 },
        "minApiVersion": { "type": "number", "minimum": 1 },
        "apiVersionWarnBehind": { "type": "integer", "minimum": 0 },
        "fieldDescriptionMaxMissing": { "type": "integer", "minimum": 0 },
        "connectedAppFlagPermissive": { "type": "boolean" },
        "soapLoginLookbackDays": { "type": "integer", "minimum": 1 }
      }
    },
    "monitoring": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "backupDir": { "type": "string" },
        "limitWarnThreshold": { "type": "number", "minimum": 0, "maximum": 1 },
        "errorLookbackDays": { "type": "integer", "minimum": 1 },
        "healthMinScore": { "type": "number", "minimum": 0, "maximum": 100 },
        "orgInfoTrialWarnDays": { "type": "integer", "minimum": 1 },
        "deployHistoryLookback": { "type": "integer", "minimum": 1 },
        "deprecatedApiLookbackDays": { "type": "integer", "minimum": 1 }
      }
    },
    "docs": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "outputDir": { "type": "string" },
        "ai": { "type": "boolean" },
        "diagrams": { "type": "boolean" },
        "roleGuides": { "type": "boolean" },
        "roles": { "type": "array", "items": { "type": "string", "enum": ["developer", "admin", "user", "devops"] } }
      }
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "dir": { "type": "string" },
        "bulk": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "waitMinutes": { "type": "integer", "minimum": 0 },
            "lineEnding": { "type": "string", "enum": ["LF", "CRLF"] }
          }
        }
      }
    },
    "soql": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "defaultLimit": { "type": "integer", "minimum": 1 },
        "maxLimit": { "type": "integer", "minimum": 1 }
      }
    },
    "scratch": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "definitionFile": { "type": "string" },
        "durationDays": { "type": "integer", "minimum": 1, "maximum": 30 },
        "poolSize": { "type": "integer", "minimum": 0 }
      }
    },
    "ci": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "authMethod": { "enum": ["sfdx-url", "jwt"] },
        "environment": { "type": "string" },
        "runner": { "enum": ["npx", "docker", "action"] }
      }
    }
  }
}
