{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/figma-project-config.schema.json",
  "title": "Figma Project Configuration",
  "description": "Per-project Figma pipeline configuration. Stored at ~/.claude/projects/{slug}/figma-config.json. Never committed. v2.0.0 introduces platform-agnostic sections (github, jira, build, teams, wiki.mode) for the v5.0.0 generic rebuild; v1.0.0 docs live in the 3.x branch.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "project"],
  "properties": {
    "schemaVersion": {
      "type": "string",
      "const": "2.0.0"
    },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": ["slug"],
      "description": "Project identification.",
      "properties": {
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9\\-_]*$",
          "description": "Unique project slug."
        },
        "repoOwner": { "type": "string" },
        "repoName": { "type": "string" },
        "baseBranch": { "type": "string", "default": "develop" },
        "platform": {
          "type": "string",
          "enum": ["ios", "android", "web", "multiplatform"],
          "default": "ios",
          "description": "Target platform. Drives code-generation templates and test framework selection."
        }
      }
    },
    "figma": {
      "type": "object",
      "additionalProperties": false,
      "description": "Figma API configuration.",
      "properties": {
        "fileKey": { "type": "string" },
        "patKeychainKey": {
          "type": "string",
          "description": "macOS Keychain item name for Figma PAT. Resolved via `security find-generic-password -s <value> -w`."
        },
        "mcpEnabled": {
          "type": "boolean",
          "default": false,
          "description": "Whether Figma MCP server is available."
        }
      }
    },
    "annotations": {
      "type": "object",
      "additionalProperties": false,
      "description": "Figma Dev Mode annotation ingestion. When enabled, /multi-agent:analysis treats annotations as the authoritative copy for a node (the visible text layer is a placeholder). Absent or disabled = current behavior (visible text layers only).",
      "properties": {
        "enabled": { "type": "boolean", "default": false },
        "langPrefixes": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["TR", "EN"],
          "description": "Ordered language-code prefixes the annotation parser recognizes, e.g. [\"TR\",\"EN\"]. A `TR: ...\\nEN: ...` label parses by prefix; a two-line label with no prefix maps line 1 -> langPrefixes[0], line 2 -> langPrefixes[1]; a single line -> langPrefixes[0]."
        },
        "devModeCategory": {
          "type": ["string", "null"],
          "description": "Optional Dev Mode annotation category to filter on (e.g. a copy/UX-writing category). Null = accept all annotations on the node."
        }
      }
    },
    "localization": {
      "type": "object",
      "additionalProperties": false,
      "description": "How this project owns localization. Drives Section 10 of /multi-agent:analysis. Default `in-repo` keeps the historical hand-filled per-locale grid; `externally-owned` defers per-locale values to an authoring system (the analysis names key + status + copy source + base value only).",
      "properties": {
        "ownership": {
          "type": "string",
          "enum": ["in-repo", "externally-owned"],
          "default": "in-repo"
        },
        "authoringPipeline": {
          "type": ["string", "null"],
          "description": "Human-readable reference to the owning localization system when ownership = externally-owned (e.g. a workflow or resource-bot name). Rendered as the Ownership column value; never a secret."
        },
        "locales": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Supported locale codes for this project (e.g. [\"tr\",\"en\",\"ar\",\"de\",\"es\",\"fr\",\"it\",\"ru\"]). Overrides the built-in default locale set used by Section 10.",
          "minItems": 1
        },
        "baseLanguage": {
          "type": "string",
          "default": "en",
          "description": "Source/base language code. A key missing its base-language value is a defect (renders the raw key at runtime)."
        },
        "keyPattern": {
          "type": ["string", "null"],
          "description": "Key naming convention hint, e.g. `Namespace.Case`. Documentation only; not enforced."
        }
      }
    },
    "github": {
      "type": "object",
      "additionalProperties": false,
      "description": "GitHub configuration  -  repo handle + Projects V2 board metadata. Required for automatic issue + Jira triad.",
      "properties": {
        "repo": {
          "type": "string",
          "pattern": "^[^/]+/[^/]+$",
          "description": "`{owner}/{name}` handle."
        },
        "org": { "type": "string" },
        "projectV2Id": {
          "type": ["string", "null"],
          "description": "GitHub Projects V2 node ID (PVT_*)."
        },
        "projectV2Fields": {
          "type": "object",
          "additionalProperties": { "type": "string" },
          "description": "Logical name → Projects V2 field ID. Common keys: status, phase, figmaPage, jira."
        },
        "fieldOptions": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": { "type": "string" }
          },
          "description": "Single-select field option mapping. Key = field logical name, inner map = option label → option ID. Commonly used for figmaPage."
        }
      }
    },
    "jira": {
      "type": "object",
      "additionalProperties": false,
      "description": "Jira configuration. Required for the issue → jira → wiki triad.",
      "properties": {
        "baseUrl": {
          "type": "string",
          "format": "uri",
          "description": "Jira instance URL, e.g. https://jira.company.com."
        },
        "projectKey": {
          "type": "string",
          "pattern": "^[A-Z][A-Z0-9_]*$",
          "description": "Jira project key, e.g. ABC."
        },
        "defaultIssue": {
          "type": ["string", "null"],
          "description": "Fallback Jira issue key for rework or unassigned work."
        },
        "teamFieldId": {
          "type": ["string", "null"],
          "description": "Custom field ID for team assignment. Discovered via `/field` API; cached here."
        },
        "keychainKey": {
          "type": "string",
          "description": "Keychain item name for Jira token. Falls back to `prefs.global.keychainMapping.jira`."
        }
      }
    },
    "confluence": {
      "type": "object",
      "additionalProperties": false,
      "description": "Confluence sync. Optional.",
      "properties": {
        "enabled": { "type": "boolean", "default": false },
        "baseUrl": { "type": ["string", "null"], "format": "uri" },
        "spaceKey": { "type": ["string", "null"] },
        "parentPageId": { "type": ["string", "null"] },
        "dashboardPageId": {
          "type": ["string", "null"],
          "description": "Status dashboard page ID, updated by status-page generator."
        },
        "keychainKey": { "type": "string" }
      }
    },
    "repos": {
      "type": "object",
      "additionalProperties": false,
      "description": "Repository / submodule layout. Supersedes the v1 `submodules` field with role-based semantics. Paths relative to project root.",
      "properties": {
        "main": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "properties": {
            "path": { "type": "string", "default": "." },
            "branch": { "type": "string", "default": "develop" },
            "role": { "type": "string", "enum": ["main"], "default": "main" }
          }
        },
        "common": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "properties": {
            "path": { "type": "string" },
            "branch": { "type": "string", "default": "develop" },
            "role": { "type": "string", "enum": ["common"], "default": "common" }
          }
        },
        "components": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "description": "Components repo (iOS uicomponents, Android ui-components, etc).",
          "properties": {
            "path": { "type": "string" },
            "branch": { "type": "string", "default": "develop" },
            "role": { "type": "string", "enum": ["components"], "default": "components" }
          }
        },
        "wiki": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "description": "Wiki repo when `wiki.mode = separate-repo` or `submodule`.",
          "properties": {
            "path": { "type": "string" },
            "branch": { "type": "string", "default": "master" },
            "role": { "type": "string", "enum": ["wiki"], "default": "wiki" }
          }
        },
        "artifactsRepo": {
          "type": ["string", "null"],
          "description": "Relative path (inside packagesContainer or repo root) to the implementation-artifacts submodule/folder  -  holds IMPLEMENTATION_HISTORY.md and Figma/Confluence per-component trees. Null = feature disabled.",
          "examples": ["Packages/my-ios-implementation-artifacts", "artifacts"]
        },
        "packagesContainer": {
          "type": ["string", "null"],
          "description": "Root directory under which submodule packages (components, common, wiki, artifactsRepo) are nested. Null when repos are siblings of the main repo.",
          "examples": ["MyAppPackages", "Packages"]
        }
      }
    },
    "build": {
      "type": "object",
      "additionalProperties": false,
      "description": "Build configuration. Fields used depend on `project.platform`.",
      "properties": {
        "xcodeproj": { "type": "string", "description": "iOS only." },
        "scheme": { "type": "string", "description": "iOS only." },
        "destination": {
          "type": "string",
          "description": "iOS only. Default `generic/platform=iOS`."
        },
        "gradleModule": { "type": "string", "description": "Android only." },
        "variant": { "type": "string", "description": "Android only." },
        "buildType": { "type": "string", "description": "Android only." }
      }
    },
    "artifactBasePath": {
      "type": "string",
      "default": "ImplementationArtifacts/Figma/Components",
      "description": "Base path for per-component generated artifacts (specs, pass-N notes, screenshots)."
    },
    "tokens": {
      "type": "object",
      "additionalProperties": false,
      "description": "Design token mapping.",
      "properties": {
        "spacing": { "type": "string", "default": ".Spacing.spacing{value}" },
        "color": { "type": "string", "default": "Color.{semantic}" },
        "typography": { "type": "string", "default": ".typographyStyle(.{name})" },
        "radius": { "type": "string", "default": ".CornerRadius.radius{value}" },
        "registryPath": {
          "type": ["string", "null"],
          "description": "Path to token registry JSON (e.g. ui-token-registry.json)."
        },
        "colorsGlob": {
          "type": ["string", "null"],
          "description": "Glob pattern for color JSON files (e.g. Shared/UIAssets/Colors/*.json)."
        },
        "typographyPath": {
          "type": ["string", "null"],
          "description": "Path to typography JSON file."
        }
      }
    },
    "ui": {
      "type": "object",
      "additionalProperties": false,
      "description": "UI interaction systems. Consumed by the figma-navigation / figma-overlays / figma-bottom-sheets convention skills and by Phase 4 review. When a section is absent or its mode is 'native', the pipeline uses the platform's stock system (SwiftUI NavigationStack/.sheet on iOS, Compose Navigation/dialogs on Android). Set mode 'custom' to route to a project-supplied system by the type names below.",
      "properties": {
        "navigationSystem": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "mode": { "type": "string", "enum": ["native", "custom"], "default": "native" },
            "router": {
              "type": "string",
              "description": "Router type that dispatches routes (custom mode)."
            },
            "routeEnum": {
              "type": "string",
              "description": "Exhaustive cross-surface route enum (custom mode)."
            },
            "sceneType": {
              "type": "string",
              "description": "Headless screen container type (custom mode, optional)."
            },
            "navigatorProtocol": {
              "type": "string",
              "description": "DI'd selection/present API (custom mode, optional)."
            }
          }
        },
        "overlaySystem": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "mode": { "type": "string", "enum": ["native", "custom"], "default": "native" },
            "center": {
              "type": "string",
              "description": "DI'd overlay center protocol callable from VM/coordinator (custom mode)."
            },
            "surfaces": {
              "type": "array",
              "items": { "type": "string" },
              "description": "Independent render surfaces, e.g. root/currentScene (custom mode, optional)."
            }
          }
        },
        "sheetSystem": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "mode": { "type": "string", "enum": ["native", "custom"], "default": "native" },
            "brandedModifier": {
              "type": "string",
              "description": "Branded sheet entry modifier, e.g. bottomSheet (custom mode)."
            },
            "headlessModifiers": {
              "type": "array",
              "items": { "type": "string" },
              "description": "Headless sheet modifiers, e.g. modalSheet/dockedSheet/expandableSheet/detentNavigationSheet (custom mode)."
            },
            "detentType": { "type": "string", "description": "Detent enum type (custom mode)." },
            "backdropType": {
              "type": "string",
              "description": "Backdrop enum type (custom mode)."
            },
            "cornerRadiusToken": {
              "type": "string",
              "description": "Branded top-corner radius token (custom mode)."
            }
          }
        }
      }
    },
    "teams": {
      "type": "array",
      "description": "Team definitions. Each entry maps a logical team to a GitHub label and a Jira custom-field value.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["key", "label"],
        "properties": {
          "key": { "type": "string", "pattern": "^[a-z0-9][a-z0-9_\\-]*$" },
          "label": { "type": "string", "description": "GitHub label, e.g. team:core." },
          "jiraValue": { "type": ["string", "null"] }
        }
      }
    },
    "board": {
      "type": "object",
      "additionalProperties": false,
      "description": "Legacy board section. Superseded by `github.projectV2*` for Projects V2 users. Retained for backward-compat with `github-labels-only` and `none` providers.",
      "properties": {
        "enabled": { "type": "boolean", "default": false },
        "provider": {
          "type": "string",
          "enum": ["github-projects-v2", "github-labels-only", "none"],
          "default": "none"
        },
        "projectId": { "type": "string" },
        "columns": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "todo": { "type": "string", "default": "Todo" },
            "inDevelop": { "type": "string", "default": "In Develop" },
            "inReview": { "type": "string", "default": "In Review" },
            "done": { "type": "string", "default": "Done" },
            "blocked": { "type": "string", "default": "Blocked" },
            "bugfix": { "type": "string", "default": "Bugfix" },
            "stale": { "type": "string", "default": "Stale" }
          }
        },
        "customFields": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        }
      }
    },
    "registry": {
      "type": "object",
      "additionalProperties": false,
      "description": "Component registry configuration.",
      "properties": {
        "enabled": { "type": "boolean", "default": false },
        "type": {
          "type": "string",
          "enum": ["swift-cli", "json-file", "none"],
          "default": "none"
        },
        "cliName": { "type": "string" },
        "packagePath": { "type": "string" },
        "registryPath": { "type": "string" }
      }
    },
    "review": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "requiredApprovals": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10,
          "default": 0
        },
        "reviewers": {
          "type": "array",
          "items": { "type": "string" },
          "maxItems": 10
        },
        "autoAssign": { "type": "boolean", "default": false }
      }
    },
    "iteration": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "branch": { "type": "string", "default": "iteration/develop" },
        "batchSize": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "default": 5
        }
      }
    },
    "wiki": {
      "type": "object",
      "additionalProperties": false,
      "description": "Wiki generation settings. v2.0.0 introduces `mode` with four adapters; legacy v1 projects using `submodules.wiki` are migrated to `mode: submodule`.",
      "properties": {
        "enabled": { "type": "boolean", "default": false },
        "mode": {
          "type": "string",
          "enum": ["submodule", "in-repo", "github-wiki", "separate-repo"],
          "default": "in-repo",
          "description": "submodule: git submodule at repos.wiki.path. in-repo: folder inside main repo (relPath). github-wiki: GitHub's wiki feature on the components repo. separate-repo: standalone clone at url."
        },
        "relPath": {
          "type": ["string", "null"],
          "description": "Used by `in-repo` mode (default `.wiki/components/`) and as fallback for other modes."
        },
        "url": {
          "type": ["string", "null"],
          "description": "Used by `separate-repo` mode  -  clone URL."
        },
        "branch": {
          "type": ["string", "null"],
          "description": "Branch for submodule or separate-repo mode."
        },
        "categoryMapping": {
          "type": "string",
          "enum": ["auto", "flat"],
          "default": "auto"
        }
      }
    },
    "scripts": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pythonPath": { "type": "string", "default": "python3" },
        "preGather": { "type": ["string", "null"] },
        "postCommit": { "type": ["string", "null"] }
      }
    },
    "models": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "default": { "type": "string", "default": "sonnet" },
        "complex": { "type": "string", "default": "opus" },
        "overrides": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        }
      }
    }
  }
}
