{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://capp.local/schemas/capp.project-layout.v1.schema.json",
  "title": "cApp Project Layout v1",
  "description": "Portable, agent-editable composition of independently compilable application components and their local source roots under one cApp project. Import is host-bound to the currently open project and never modifies source files.",
  "type": "object",
  "additionalProperties": false,
  "required": ["protocol", "project", "activeComponentId", "components"],
  "properties": {
    "protocol": { "const": "capp.project-layout.v1" },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name"],
      "properties": {
        "id": { "type": "string", "minLength": 1, "maxLength": 96, "pattern": "^[A-Za-z0-9_.-]+$" },
        "name": { "type": "string", "minLength": 1, "maxLength": 200 }
      }
    },
    "activeComponentId": { "type": "string", "minLength": 1, "maxLength": 96, "pattern": "^[A-Za-z0-9_.-]+$" },
    "components": {
      "type": "array",
      "minItems": 1,
      "maxItems": 128,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "name", "kind", "roots"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 96, "pattern": "^[A-Za-z0-9_.-]+$" },
          "name": { "type": "string", "minLength": 1, "maxLength": 200 },
          "kind": { "const": "application" },
          "roots": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["role", "path"],
              "properties": {
                "role": { "enum": ["all", "frontend", "backend", "shared"] },
                "path": { "type": "string", "minLength": 1, "maxLength": 4096 }
              }
            }
          }
        }
      }
    },
    "help": {
      "type": "object",
      "description": "Optional human/agent guidance used by downloadable shells. Import ignores this field.",
      "additionalProperties": true
    }
  }
}
