/** * Canvas Healer — Self-healing loop for Figma canvas operations. * * After any canvas modification, runs the cycle: * CREATE → SCREENSHOT → ANALYZE → FIX → VERIFY * with a configurable max number of rounds (default 3). * * Analysis checks for the 8 known anti-patterns: * 1. "hug contents" instead of "fill container" * 2. Padding inconsistencies * 3. Text not using "fill" width * 4. Centering issues * 5. Floating elements outside parent * 6. Raw hex values (should be tokens/variables) * 7. Missing auto-layout * 8. Shadow effects missing blendMode: "NORMAL" */ import type { FigmaBridge } from "./bridge.js"; import type { MemoireEvent } from "../engine/core.js"; export interface HealingOptions { maxRounds: number; screenshotScale: number; } export interface DesignIssue { type: "hug-instead-of-fill" | "padding-inconsistency" | "text-not-fill" | "centering-issue" | "floating-element" | "raw-hex-value" | "missing-auto-layout" | "shadow-blend-mode"; nodeId: string; nodeName: string; description: string; fixCode: string; } export interface HealingRound { round: number; issuesFound: DesignIssue[]; fixesApplied: number; healthy: boolean; } export interface HealingReport { nodeId: string; rounds: HealingRound[]; healthy: boolean; totalIssuesFixed: number; } export interface ScreenshotResult { base64: string; format: string; scale: number; byteLength: number; node: { id: string; name: string; type: string; }; bounds: { x: number; y: number; width: number; height: number; } | null; } export declare class CanvasHealer { private bridge; private onEvent?; constructor(bridge: FigmaBridge, onEvent?: (event: MemoireEvent) => void); /** * Capture a screenshot of a Figma node (or current page). */ captureScreenshot(nodeId?: string, scale?: number): Promise; /** * Run the full self-healing loop on a node after canvas modifications. * * CREATE has already happened — this runs SCREENSHOT → ANALYZE → FIX → VERIFY * for up to maxRounds iterations. */ heal(nodeId: string, options?: Partial): Promise; /** * Analyze a node for the 8 known anti-patterns. * Uses direct Figma plugin API inspection (no AI required). */ private analyzeNode; /** * Generate Figma plugin API code to fix a specific issue. */ private generateFixCode; private emitEvent; }