@sarjallab09/figma-intelligence 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -36
- package/dist/bin/cli.js +2 -0
- package/dist/design-bridge/bridge.js +2 -0
- package/dist/figma-bridge-plugin/bridge-relay.js +2 -0
- package/dist/figma-bridge-plugin/code.js +1 -0
- package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package-lock.json +0 -3
- package/dist/figma-bridge-plugin/ui.html +4970 -0
- package/dist/figma-intelligence-layer/dist/index.js +2 -0
- package/dist/scripts/clean-existing-chunks.js +2 -0
- package/dist/scripts/connect-ai-tool.js +2 -0
- package/dist/scripts/convert-hub-pdfs.js +2 -0
- package/dist/scripts/figma-mcp-status.js +2 -0
- package/dist/scripts/register-codex-mcp.js +2 -0
- package/dist/scripts/test-copilot-chat.js +2 -0
- package/package.json +11 -8
- package/bin/cli.js +0 -859
- package/design-bridge/bridge.js +0 -196
- package/design-bridge/lib/assets.js +0 -367
- package/design-bridge/lib/prompt.js +0 -85
- package/design-bridge/lib/server.js +0 -66
- package/design-bridge/lib/stitch.js +0 -37
- package/design-bridge/lib/tokens.js +0 -82
- package/design-bridge/package-lock.json +0 -579
- package/figma-bridge-plugin/README.md +0 -97
- package/figma-bridge-plugin/anthropic-chat-runner.js +0 -192
- package/figma-bridge-plugin/bridge-relay.js +0 -2363
- package/figma-bridge-plugin/chat-runner.js +0 -459
- package/figma-bridge-plugin/code.js +0 -1528
- package/figma-bridge-plugin/codex-runner.js +0 -505
- package/figma-bridge-plugin/component-schemas.js +0 -110
- package/figma-bridge-plugin/content-context.js +0 -869
- package/figma-bridge-plugin/create-button.js +0 -216
- package/figma-bridge-plugin/gemini-cli-runner.js +0 -291
- package/figma-bridge-plugin/gemini-runner.js +0 -187
- package/figma-bridge-plugin/html-to-figma.js +0 -927
- package/figma-bridge-plugin/knowledge-hub/.gitkeep +0 -0
- package/figma-bridge-plugin/knowledge-hub/uspec-references/anatomy-spec.md +0 -159
- package/figma-bridge-plugin/knowledge-hub/uspec-references/api-spec.md +0 -162
- package/figma-bridge-plugin/knowledge-hub/uspec-references/color-spec.md +0 -148
- package/figma-bridge-plugin/knowledge-hub/uspec-references/full-spec-template.md +0 -314
- package/figma-bridge-plugin/knowledge-hub/uspec-references/property-spec.md +0 -175
- package/figma-bridge-plugin/knowledge-hub/uspec-references/screen-reader-spec.md +0 -180
- package/figma-bridge-plugin/knowledge-hub/uspec-references/structure-spec.md +0 -165
- package/figma-bridge-plugin/perplexity-runner.js +0 -188
- package/figma-bridge-plugin/references/SKILL.md +0 -178
- package/figma-bridge-plugin/references/anatomy-spec.md +0 -159
- package/figma-bridge-plugin/references/api-spec.md +0 -162
- package/figma-bridge-plugin/references/color-spec.md +0 -148
- package/figma-bridge-plugin/references/full-spec-template.md +0 -314
- package/figma-bridge-plugin/references/property-spec.md +0 -175
- package/figma-bridge-plugin/references/screen-reader-spec.md +0 -180
- package/figma-bridge-plugin/references/structure-spec.md +0 -165
- package/figma-bridge-plugin/shared-prompt-config.js +0 -604
- package/figma-bridge-plugin/spec-helpers/build-table.js +0 -269
- package/figma-bridge-plugin/spec-helpers/classify-elements.js +0 -189
- package/figma-bridge-plugin/spec-helpers/index.js +0 -35
- package/figma-bridge-plugin/spec-helpers/parse-figma-link.js +0 -49
- package/figma-bridge-plugin/spec-helpers/position-markers.js +0 -158
- package/figma-bridge-plugin/stitch-auth.js +0 -322
- package/figma-bridge-plugin/stitch-runner.js +0 -1427
- package/figma-bridge-plugin/token-resolver.js +0 -107
- package/figma-bridge-plugin/ui.html +0 -4467
- package/figma-intelligence-layer/.env.example +0 -39
- package/figma-intelligence-layer/docs/local-image-generation.md +0 -60
- package/figma-intelligence-layer/examples/comfyui-workflow-template.example.json +0 -101
- package/figma-intelligence-layer/jest.config.js +0 -14
- package/figma-intelligence-layer/mcp-config.json +0 -19
- package/figma-intelligence-layer/package-lock.json +0 -5892
- package/figma-intelligence-layer/scripts/setup-comfyui-local.sh +0 -67
- package/figma-intelligence-layer/scripts/start-comfyui.sh +0 -33
- package/figma-intelligence-layer/src/index.ts +0 -2233
- package/figma-intelligence-layer/src/shared/auto-layout-validator.ts +0 -404
- package/figma-intelligence-layer/src/shared/cache.ts +0 -187
- package/figma-intelligence-layer/src/shared/color-operations.ts +0 -533
- package/figma-intelligence-layer/src/shared/color-utils.ts +0 -138
- package/figma-intelligence-layer/src/shared/component-script-builder.ts +0 -413
- package/figma-intelligence-layer/src/shared/component-templates.ts +0 -2767
- package/figma-intelligence-layer/src/shared/concept-taxonomy.ts +0 -694
- package/figma-intelligence-layer/src/shared/decision-log.ts +0 -128
- package/figma-intelligence-layer/src/shared/design-system-context.ts +0 -568
- package/figma-intelligence-layer/src/shared/design-system-intelligence.ts +0 -131
- package/figma-intelligence-layer/src/shared/design-system-matcher.ts +0 -184
- package/figma-intelligence-layer/src/shared/design-system-normalizers.ts +0 -196
- package/figma-intelligence-layer/src/shared/design-system-tokens.ts +0 -295
- package/figma-intelligence-layer/src/shared/dtcg-validator.ts +0 -530
- package/figma-intelligence-layer/src/shared/enrichment-pipeline.ts +0 -671
- package/figma-intelligence-layer/src/shared/figma-bridge.ts +0 -1408
- package/figma-intelligence-layer/src/shared/font-config.ts +0 -126
- package/figma-intelligence-layer/src/shared/icon-catalog.ts +0 -360
- package/figma-intelligence-layer/src/shared/icon-fetch.ts +0 -80
- package/figma-intelligence-layer/src/shared/prototype-script-builder.ts +0 -162
- package/figma-intelligence-layer/src/shared/response-compression.ts +0 -440
- package/figma-intelligence-layer/src/shared/semantic-token-catalog.ts +0 -324
- package/figma-intelligence-layer/src/shared/token-binder.ts +0 -505
- package/figma-intelligence-layer/src/shared/token-math.ts +0 -427
- package/figma-intelligence-layer/src/shared/token-naming.ts +0 -468
- package/figma-intelligence-layer/src/shared/token-utils.ts +0 -420
- package/figma-intelligence-layer/src/shared/types.ts +0 -346
- package/figma-intelligence-layer/src/shared/typography-presets.ts +0 -94
- package/figma-intelligence-layer/src/shared/unsplash.ts +0 -165
- package/figma-intelligence-layer/src/shared/vision-client.ts +0 -607
- package/figma-intelligence-layer/src/shared/vision-provider-anthropic.ts +0 -334
- package/figma-intelligence-layer/src/shared/vision-provider-openai.ts +0 -446
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-handler.ts +0 -782
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-renderer.ts +0 -496
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotation-kit.ts +0 -230
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/colorblind-sim.ts +0 -66
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/index.ts +0 -810
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-analyzer.ts +0 -1191
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-figma-page.ts +0 -1346
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-handler.ts +0 -148
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-figma-page.ts +0 -499
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-report.ts +0 -910
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-checker.ts +0 -989
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-criteria.ts +0 -1160
- package/figma-intelligence-layer/src/tools/phase1-vision/design-from-ref/index.ts +0 -424
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/component-recognizer.ts +0 -38
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/ds-matcher.ts +0 -111
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/font-matcher.ts +0 -114
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/icon-resolver.ts +0 -103
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/index.ts +0 -1060
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/layout-segmenter.ts +0 -18
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/token-inferencer.ts +0 -39
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/vision-pipeline.ts +0 -58
- package/figma-intelligence-layer/src/tools/phase1-vision/sketch-to-design/index.ts +0 -298
- package/figma-intelligence-layer/src/tools/phase1-vision/visual-audit/index.ts +0 -197
- package/figma-intelligence-layer/src/tools/phase2-accuracy/component-audit/index.ts +0 -494
- package/figma-intelligence-layer/src/tools/phase2-accuracy/intent-translator/index.ts +0 -356
- package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/container-patterns.ts +0 -123
- package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/index.ts +0 -663
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/built-in-rules.yaml +0 -56
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/index.ts +0 -614
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/rule-engine.ts +0 -113
- package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/color-theory.ts +0 -178
- package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/index.ts +0 -470
- package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/index.ts +0 -429
- package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/token-override-maps.ts +0 -226
- package/figma-intelligence-layer/src/tools/phase3-generation/ai-image-insert/index.ts +0 -535
- package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts +0 -660
- package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/pattern-fingerprints.ts +0 -209
- package/figma-intelligence-layer/src/tools/phase3-generation/composition-builder/index.ts +0 -540
- package/figma-intelligence-layer/src/tools/phase3-generation/figma-animated-build.ts +0 -391
- package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/index.ts +0 -2019
- package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts +0 -131
- package/figma-intelligence-layer/src/tools/phase3-generation/prototype-map/index.ts +0 -381
- package/figma-intelligence-layer/src/tools/phase3-generation/prototype-wire/index.ts +0 -565
- package/figma-intelligence-layer/src/tools/phase3-generation/swarm-build/index.ts +0 -764
- package/figma-intelligence-layer/src/tools/phase3-generation/system-drift/index.ts +0 -535
- package/figma-intelligence-layer/src/tools/phase3-generation/unsplash-search/index.ts +0 -84
- package/figma-intelligence-layer/src/tools/phase3-generation/url-to-frame/index.ts +0 -401
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/css-animations.ts +0 -68
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/framer-motion.ts +0 -78
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/swift-animations.ts +0 -93
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/index.ts +0 -596
- package/figma-intelligence-layer/src/tools/phase4-sync/ci-check/index.ts +0 -462
- package/figma-intelligence-layer/src/tools/phase4-sync/export-tokens/index.ts +0 -1470
- package/figma-intelligence-layer/src/tools/phase4-sync/generate-component-code/index.ts +0 -829
- package/figma-intelligence-layer/src/tools/phase4-sync/handoff-spec/index.ts +0 -702
- package/figma-intelligence-layer/src/tools/phase4-sync/icon-library-sync/index.ts +0 -483
- package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/index.ts +0 -501
- package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/storybook-parser.ts +0 -106
- package/figma-intelligence-layer/src/tools/phase4-sync/watch-docs/index.ts +0 -676
- package/figma-intelligence-layer/src/tools/phase4-sync/webhook-listener/index.ts +0 -560
- package/figma-intelligence-layer/src/tools/phase5-governance/apg-doc/index.ts +0 -1043
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/component-detection.ts +0 -620
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/anatomy.ts +0 -331
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/color-tokens.ts +0 -77
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/properties.ts +0 -54
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/snapshot.ts +0 -287
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/spacing.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/states.ts +0 -43
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/typography.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/index.ts +0 -221
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/_default.ts +0 -166
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/accordion.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/alert.ts +0 -234
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar-group.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar.ts +0 -249
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/badge.ts +0 -231
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/banner.ts +0 -293
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/breadcrumb.ts +0 -240
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/button.ts +0 -243
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/calendar.ts +0 -307
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/card.ts +0 -143
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/checkbox.ts +0 -227
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/chip.ts +0 -233
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/combobox.ts +0 -282
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/datepicker.ts +0 -276
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/divider.ts +0 -223
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/drawer.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/dropdown-menu.ts +0 -289
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/empty-state.ts +0 -261
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/file-uploader.ts +0 -290
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/form.ts +0 -265
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/grid.ts +0 -238
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/icon.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/index.ts +0 -128
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-edit.ts +0 -286
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-message.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/input.ts +0 -330
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/link.ts +0 -247
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/list.ts +0 -250
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/menu.ts +0 -247
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/modal.ts +0 -144
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navbar.ts +0 -264
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navigation.ts +0 -251
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/number-input.ts +0 -261
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/pagination.ts +0 -248
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/popover.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/progress.ts +0 -251
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/radio.ts +0 -142
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/range-slider.ts +0 -282
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/rating.ts +0 -250
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/search.ts +0 -258
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/segmented-control.ts +0 -265
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/select.ts +0 -319
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/skeleton.ts +0 -256
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/slider.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/spinner.ts +0 -239
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/status-dot.ts +0 -252
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/stepper.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/table.ts +0 -244
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tabs.ts +0 -143
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tag.ts +0 -243
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/textarea.ts +0 -259
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/time-picker.ts +0 -293
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toast.ts +0 -144
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toggle.ts +0 -289
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toolbar.ts +0 -267
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tooltip.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/treeview.ts +0 -257
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/typography.ts +0 -319
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/legacy-compat.ts +0 -121
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/anatomy-diagram.ts +0 -430
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/figma-page.ts +0 -312
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/json.ts +0 -129
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/markdown.ts +0 -78
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/visual-doc.ts +0 -2333
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/accessibility.ts +0 -100
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/anatomy.ts +0 -32
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/color-tokens.ts +0 -59
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/content-guidance.ts +0 -18
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/design-tokens.ts +0 -53
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/interaction-rules.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/overview.ts +0 -91
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/properties-api.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/qa-criteria.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/related-components.ts +0 -110
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/responsive.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/size-specs.ts +0 -67
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/spacing-structure.ts +0 -58
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/state-specs.ts +0 -79
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/states.ts +0 -50
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/type-hierarchy.ts +0 -33
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/typography.ts +0 -55
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/usage-guidelines.ts +0 -73
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/variants.ts +0 -81
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/types.ts +0 -409
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/index.ts +0 -198
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/renderer.ts +0 -701
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/types.ts +0 -88
- package/figma-intelligence-layer/src/tools/phase5-governance/decision-log/index.ts +0 -135
- package/figma-intelligence-layer/src/tools/phase5-governance/design-decision-log/index.ts +0 -491
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-primitives/index.ts +0 -416
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-scaffolder/index.ts +0 -722
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-variables/index.ts +0 -449
- package/figma-intelligence-layer/src/tools/phase5-governance/health-report/index.ts +0 -393
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/index.ts +0 -406
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts +0 -292
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/json.ts +0 -24
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/markdown.ts +0 -172
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/naming-guide.ts +0 -409
- package/figma-intelligence-layer/src/tools/phase5-governance/token-analytics/index.ts +0 -594
- package/figma-intelligence-layer/src/tools/phase5-governance/token-docs/index.ts +0 -710
- package/figma-intelligence-layer/src/tools/phase5-governance/token-migrate/index.ts +0 -458
- package/figma-intelligence-layer/src/tools/phase5-governance/token-naming/index.ts +0 -134
- package/figma-intelligence-layer/tests/apg-doc.test.ts +0 -101
- package/figma-intelligence-layer/tests/design-system-context.test.ts +0 -152
- package/figma-intelligence-layer/tests/design-system-matcher.test.ts +0 -144
- package/figma-intelligence-layer/tests/figma-bridge.test.ts +0 -83
- package/figma-intelligence-layer/tests/generate-image-and-insert.test.ts +0 -56
- package/figma-intelligence-layer/tests/screen-cloner-regression.test.ts +0 -69
- package/figma-intelligence-layer/tests/smoke.test.ts +0 -174
- package/figma-intelligence-layer/tests/spec-generator.test.ts +0 -127
- package/figma-intelligence-layer/tests/token-migrate.test.ts +0 -21
- package/figma-intelligence-layer/tests/token-naming.test.ts +0 -30
- package/figma-intelligence-layer/tsconfig.json +0 -19
- package/scripts/clean-existing-chunks.js +0 -179
- package/scripts/connect-ai-tool.js +0 -490
- package/scripts/convert-hub-pdfs.js +0 -425
- package/scripts/figma-mcp-status.js +0 -349
- package/scripts/register-codex-mcp.js +0 -96
- /package/{design-bridge → dist/design-bridge}/.env.example +0 -0
- /package/{design-bridge → dist/design-bridge}/package.json +0 -0
- /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/manifest.json +0 -0
- /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package.json +0 -0
- /package/{figma-intelligence-layer → dist/figma-intelligence-layer}/package.json +0 -0
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// Auto-Layout Safety Validator
|
|
3
|
-
// Generates a self-contained Figma Plugin API script that performs DFS
|
|
4
|
-
// validation and repair of auto-layout sizing on a node tree.
|
|
5
|
-
// Enforces Figma's sizing rules: FILL only inside auto-layout parents,
|
|
6
|
-
// HUG only on auto-layout frames and text, no parent HUG + child FILL conflicts.
|
|
7
|
-
// Also enforces document layout rules: sections FILL width, text FILL horizontal,
|
|
8
|
-
// dividers FILL width / FIXED height, spacing snapped to token scale.
|
|
9
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Returns a JavaScript function definition string for `validateAutoLayout(root)`.
|
|
13
|
-
* This function is meant to be inlined into a bridge.execute() script.
|
|
14
|
-
* It performs a depth-first walk of the node tree and repairs invalid
|
|
15
|
-
* auto-layout sizing combinations.
|
|
16
|
-
*/
|
|
17
|
-
export function generateValidatorScript(): string {
|
|
18
|
-
return `
|
|
19
|
-
function validateAutoLayout(root) {
|
|
20
|
-
let fixes = 0;
|
|
21
|
-
const details = [];
|
|
22
|
-
const isMobile = root.width && root.width <= 430;
|
|
23
|
-
|
|
24
|
-
// ── Document spacing token scale ──
|
|
25
|
-
const DOC_SPACING_TOKENS = [4, 8, 12, 16, 20, 24, 32, 40, 48, 56, 64];
|
|
26
|
-
|
|
27
|
-
function snapToToken(value) {
|
|
28
|
-
if (DOC_SPACING_TOKENS.indexOf(value) >= 0) return value;
|
|
29
|
-
let closest = DOC_SPACING_TOKENS[0];
|
|
30
|
-
let minDist = Math.abs(value - closest);
|
|
31
|
-
for (let i = 1; i < DOC_SPACING_TOKENS.length; i++) {
|
|
32
|
-
const dist = Math.abs(value - DOC_SPACING_TOKENS[i]);
|
|
33
|
-
if (dist < minDist) { closest = DOC_SPACING_TOKENS[i]; minDist = dist; }
|
|
34
|
-
}
|
|
35
|
-
return closest;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isAutoLayout(node) {
|
|
39
|
-
return node.layoutMode === 'HORIZONTAL' || node.layoutMode === 'VERTICAL';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function canHug(node) {
|
|
43
|
-
return node.type === 'TEXT' || (isAutoLayout(node));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function classifyNode(node) {
|
|
47
|
-
const n = (node.name || '').toLowerCase();
|
|
48
|
-
if (/btn|button|cta/.test(n)) return 'button';
|
|
49
|
-
if (/icon|chevron|arrow/.test(n)) return 'icon';
|
|
50
|
-
if (/avatar|profile.?pic|thumbnail/.test(n)) return 'avatar';
|
|
51
|
-
if (/badge|tag|chip|pill/.test(n)) return 'badge';
|
|
52
|
-
if (/input|field|textfield|textarea|search.?bar/.test(n)) return 'input';
|
|
53
|
-
if (/card|tile|panel/.test(n)) return 'card';
|
|
54
|
-
if (/label|caption/.test(n)) return 'label';
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function classifyDocNode(node) {
|
|
59
|
-
const n = (node.name || '').toLowerCase();
|
|
60
|
-
if (/doc(ument)?[\\s_-]?page|spec[\\s_-]?page|guide(line)?[\\s_-]?page/.test(n)) return 'document_page';
|
|
61
|
-
if (/header[\\s_-]?block|doc[\\s_-]?header|page[\\s_-]?title[\\s_-]?block/.test(n)) return 'header_block';
|
|
62
|
-
if (/section[\\s_-]?block|content[\\s_-]?section/.test(n)) return 'section_block';
|
|
63
|
-
if (/toc[\\s_-]?row/.test(n)) return 'toc_row';
|
|
64
|
-
if (/paragraph[\\s_-]?group|body[\\s_-]?text[\\s_-]?block|text[\\s_-]?block/.test(n)) return 'paragraph_group';
|
|
65
|
-
if (/\\bdivider\\b|\\bseparator\\b|\\bhr\\b/.test(n)) return 'divider';
|
|
66
|
-
if (/footer[\\s_-]?block|doc[\\s_-]?footer/.test(n)) return 'footer_block';
|
|
67
|
-
if (/table[\\s_-]?block|spec[\\s_-]?table|data[\\s_-]?table/.test(n)) return 'table_block';
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function isDocumentContainer(docRole) {
|
|
72
|
-
return docRole === 'document_page' || docRole === 'section_block' ||
|
|
73
|
-
docRole === 'header_block' || docRole === 'paragraph_group' ||
|
|
74
|
-
docRole === 'footer_block' || docRole === 'table_block';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function fix(node, prop, from, to, reason) {
|
|
78
|
-
if (prop in node) {
|
|
79
|
-
node[prop] = to;
|
|
80
|
-
fixes++;
|
|
81
|
-
details.push(reason + ' (' + node.name + ': ' + prop + ' ' + from + ' -> ' + to + ')');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function walk(node) {
|
|
86
|
-
if (!('children' in node)) return;
|
|
87
|
-
const parentIsAL = isAutoLayout(node);
|
|
88
|
-
const parentDir = node.layoutMode;
|
|
89
|
-
const parentDocRole = classifyDocNode(node);
|
|
90
|
-
|
|
91
|
-
// ── Rule H: Document page root must be FIXED width, HUG height ──
|
|
92
|
-
if (parentDocRole === 'document_page' && isAutoLayout(node)) {
|
|
93
|
-
if (node.counterAxisSizingMode !== 'FIXED') {
|
|
94
|
-
fix(node, 'counterAxisSizingMode', node.counterAxisSizingMode, 'FIXED', 'Rule H: Document page must be FIXED width');
|
|
95
|
-
}
|
|
96
|
-
if (node.primaryAxisSizingMode !== 'AUTO') {
|
|
97
|
-
fix(node, 'primaryAxisSizingMode', node.primaryAxisSizingMode, 'AUTO', 'Rule H: Document page must HUG height');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ── Rule K: Spacing snap for document containers ──
|
|
102
|
-
if (parentDocRole && isDocumentContainer(parentDocRole) && isAutoLayout(node)) {
|
|
103
|
-
if ('itemSpacing' in node && node.itemSpacing > 0) {
|
|
104
|
-
const snapped = snapToToken(node.itemSpacing);
|
|
105
|
-
if (snapped !== node.itemSpacing) {
|
|
106
|
-
fix(node, 'itemSpacing', node.itemSpacing, snapped, 'Rule K: Snap spacing to token scale');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
for (const child of node.children) {
|
|
112
|
-
const role = classifyNode(child);
|
|
113
|
-
const docRole = classifyDocNode(child);
|
|
114
|
-
const hSizing = ('layoutSizingHorizontal' in child) ? child.layoutSizingHorizontal : null;
|
|
115
|
-
const vSizing = ('layoutSizingVertical' in child) ? child.layoutSizingVertical : null;
|
|
116
|
-
|
|
117
|
-
// ── Rule A: No FILL outside auto-layout ──
|
|
118
|
-
if (!parentIsAL) {
|
|
119
|
-
if (hSizing === 'FILL') {
|
|
120
|
-
fix(child, 'layoutSizingHorizontal', 'FILL', 'FIXED', 'Rule A: FILL outside auto-layout');
|
|
121
|
-
}
|
|
122
|
-
if (vSizing === 'FILL') {
|
|
123
|
-
fix(child, 'layoutSizingVertical', 'FILL', 'FIXED', 'Rule A: FILL outside auto-layout');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ── Rule B: TEXT nodes default HUG; only FILL if parent is auto-layout ──
|
|
128
|
-
if (child.type === 'TEXT') {
|
|
129
|
-
if (hSizing === 'FILL' && !parentIsAL) {
|
|
130
|
-
fix(child, 'layoutSizingHorizontal', 'FILL', 'HUG', 'Rule B: TEXT FILL outside auto-layout');
|
|
131
|
-
}
|
|
132
|
-
if (vSizing === 'FILL') {
|
|
133
|
-
fix(child, 'layoutSizingVertical', 'FILL', 'HUG', 'Rule B: TEXT should HUG vertically');
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// ── Rule C: Button → HUG/HUG (unless mobile primary CTA) ──
|
|
138
|
-
if (role === 'button') {
|
|
139
|
-
const isMobilePrimary = isMobile && /primary|cta|submit|continue|next/.test((child.name || '').toLowerCase());
|
|
140
|
-
if (!isMobilePrimary) {
|
|
141
|
-
if (hSizing === 'FILL' && parentDir === 'HORIZONTAL') {
|
|
142
|
-
fix(child, 'layoutSizingHorizontal', 'FILL', 'HUG', 'Rule C: Button should HUG in horizontal parent');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (vSizing === 'FILL') {
|
|
146
|
-
fix(child, 'layoutSizingVertical', 'FILL', 'HUG', 'Rule C: Button should HUG vertically');
|
|
147
|
-
}
|
|
148
|
-
// Icon children inside button → FIXED
|
|
149
|
-
if ('children' in child) {
|
|
150
|
-
for (const gc of child.children) {
|
|
151
|
-
const gcRole = classifyNode(gc);
|
|
152
|
-
if (gcRole === 'icon' || gc.type === 'VECTOR') {
|
|
153
|
-
if ('layoutSizingHorizontal' in gc && gc.layoutSizingHorizontal !== 'FIXED') {
|
|
154
|
-
fix(gc, 'layoutSizingHorizontal', gc.layoutSizingHorizontal, 'FIXED', 'Rule C: Icon in button must be FIXED');
|
|
155
|
-
}
|
|
156
|
-
if ('layoutSizingVertical' in gc && gc.layoutSizingVertical !== 'FIXED') {
|
|
157
|
-
fix(gc, 'layoutSizingVertical', gc.layoutSizingVertical, 'FIXED', 'Rule C: Icon in button must be FIXED');
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// ── Rule D: Input in vertical form → FILL horizontal, HUG vertical ──
|
|
165
|
-
if (role === 'input' && parentIsAL && parentDir === 'VERTICAL') {
|
|
166
|
-
if (hSizing !== 'FILL' && 'layoutSizingHorizontal' in child) {
|
|
167
|
-
fix(child, 'layoutSizingHorizontal', hSizing, 'FILL', 'Rule D: Input in vertical parent should FILL horizontally');
|
|
168
|
-
}
|
|
169
|
-
if (vSizing === 'FILL') {
|
|
170
|
-
fix(child, 'layoutSizingVertical', 'FILL', 'HUG', 'Rule D: Input should HUG vertically');
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// ── Rule E: Card in vertical feed → FILL horizontal, HUG vertical ──
|
|
175
|
-
if (role === 'card' && parentIsAL && parentDir === 'VERTICAL') {
|
|
176
|
-
if (hSizing !== 'FILL' && 'layoutSizingHorizontal' in child) {
|
|
177
|
-
fix(child, 'layoutSizingHorizontal', hSizing, 'FILL', 'Rule E: Card in vertical parent should FILL horizontally');
|
|
178
|
-
}
|
|
179
|
-
if (vSizing === 'FILL') {
|
|
180
|
-
fix(child, 'layoutSizingVertical', 'FILL', 'HUG', 'Rule E: Card should HUG vertically');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// ── Icon / Avatar → always FIXED ──
|
|
185
|
-
if (role === 'icon' || role === 'avatar') {
|
|
186
|
-
if (hSizing === 'FILL') {
|
|
187
|
-
fix(child, 'layoutSizingHorizontal', 'FILL', 'FIXED', 'Icon/Avatar must be FIXED');
|
|
188
|
-
}
|
|
189
|
-
if (vSizing === 'FILL') {
|
|
190
|
-
fix(child, 'layoutSizingVertical', 'FILL', 'FIXED', 'Icon/Avatar must be FIXED');
|
|
191
|
-
}
|
|
192
|
-
if (hSizing === 'HUG' && child.type !== 'TEXT' && !isAutoLayout(child)) {
|
|
193
|
-
fix(child, 'layoutSizingHorizontal', 'HUG', 'FIXED', 'Icon/Avatar: HUG not valid on non-AL non-text');
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// ── Rule F: HUG + parent stretch conflict ──
|
|
198
|
-
if (parentIsAL && 'layoutSizingHorizontal' in child) {
|
|
199
|
-
if (parentDir === 'VERTICAL' && isAutoLayout(child)) {
|
|
200
|
-
if (child.layoutSizingHorizontal === 'FILL' && child.primaryAxisSizingMode === 'AUTO' && child.layoutMode === 'HORIZONTAL') {
|
|
201
|
-
// Fine — FILL is cross-axis, primary hug is content-based
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (parentDir === 'HORIZONTAL' && isAutoLayout(child)) {
|
|
205
|
-
if (child.layoutGrow > 0 && child.layoutSizingHorizontal === 'HUG') {
|
|
206
|
-
fix(child, 'layoutSizingHorizontal', 'HUG', 'FIXED', 'Rule F: Cannot HUG and grow in same axis');
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// ── Rule G: Document section frames must FILL width in vertical parent ──
|
|
212
|
-
if (docRole && parentIsAL && parentDir === 'VERTICAL') {
|
|
213
|
-
const shouldFillWidth = docRole === 'section_block' || docRole === 'header_block' ||
|
|
214
|
-
docRole === 'paragraph_group' || docRole === 'footer_block' ||
|
|
215
|
-
docRole === 'table_block' || docRole === 'toc_row';
|
|
216
|
-
if (shouldFillWidth && hSizing !== 'FILL' && 'layoutSizingHorizontal' in child) {
|
|
217
|
-
fix(child, 'layoutSizingHorizontal', hSizing, 'FILL', 'Rule G: Document section must FILL width');
|
|
218
|
-
if ('layoutAlign' in child) child.layoutAlign = 'STRETCH';
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// ── Rule I: Divider must FILL width, FIXED height ──
|
|
223
|
-
if (docRole === 'divider' && parentIsAL) {
|
|
224
|
-
if (hSizing !== 'FILL' && 'layoutSizingHorizontal' in child) {
|
|
225
|
-
fix(child, 'layoutSizingHorizontal', hSizing, 'FILL', 'Rule I: Divider must FILL width');
|
|
226
|
-
if ('layoutAlign' in child) child.layoutAlign = 'STRETCH';
|
|
227
|
-
}
|
|
228
|
-
if (vSizing !== 'FIXED' && 'layoutSizingVertical' in child) {
|
|
229
|
-
fix(child, 'layoutSizingVertical', vSizing, 'FIXED', 'Rule I: Divider must be FIXED height');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// ── Rule J: Text inside document sections must FILL horizontally ──
|
|
234
|
-
if (child.type === 'TEXT' && parentIsAL && parentDir === 'VERTICAL' && parentDocRole && isDocumentContainer(parentDocRole)) {
|
|
235
|
-
if (hSizing !== 'FILL' && 'layoutSizingHorizontal' in child) {
|
|
236
|
-
fix(child, 'layoutSizingHorizontal', hSizing, 'FILL', 'Rule J: Text in document section must FILL width');
|
|
237
|
-
if ('layoutAlign' in child) child.layoutAlign = 'STRETCH';
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// ── General: HUG on non-eligible node ──
|
|
242
|
-
if (hSizing === 'HUG' && !canHug(child)) {
|
|
243
|
-
fix(child, 'layoutSizingHorizontal', 'HUG', 'FIXED', 'HUG not valid on ' + child.type);
|
|
244
|
-
}
|
|
245
|
-
if (vSizing === 'HUG' && !canHug(child)) {
|
|
246
|
-
fix(child, 'layoutSizingVertical', 'HUG', 'FIXED', 'HUG not valid on ' + child.type);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Recurse
|
|
250
|
-
walk(child);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
walk(root);
|
|
255
|
-
return { fixes: fixes, details: details };
|
|
256
|
-
}
|
|
257
|
-
`.trim();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Returns a JS statement that invokes the validator on the given variable.
|
|
262
|
-
* Must be used after `generateValidatorScript()` has been inlined.
|
|
263
|
-
*/
|
|
264
|
-
export function generateValidatorCall(varName: string): string {
|
|
265
|
-
return `const _alv = validateAutoLayout(${varName});`;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Generates a document-specific repair pass that fixes structural layout issues.
|
|
270
|
-
* This should be called AFTER the main validator pass.
|
|
271
|
-
* Returns a JS function definition for `repairDocumentLayout(root)`.
|
|
272
|
-
*/
|
|
273
|
-
export function generateDocumentRepairScript(): string {
|
|
274
|
-
return `
|
|
275
|
-
function repairDocumentLayout(root) {
|
|
276
|
-
let repairs = 0;
|
|
277
|
-
const details = [];
|
|
278
|
-
|
|
279
|
-
function isAutoLayout(node) {
|
|
280
|
-
return node.layoutMode === 'HORIZONTAL' || node.layoutMode === 'VERTICAL';
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function isDocPage(node) {
|
|
284
|
-
const n = (node.name || '').toLowerCase();
|
|
285
|
-
return /doc(ument)?[\\s_-]?page|spec[\\s_-]?page|documentation/.test(n);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const DOC_SPACING_TOKENS = [4, 8, 12, 16, 20, 24, 32, 40, 48, 56, 64];
|
|
289
|
-
function snapToToken(value) {
|
|
290
|
-
if (DOC_SPACING_TOKENS.indexOf(value) >= 0) return value;
|
|
291
|
-
let closest = DOC_SPACING_TOKENS[0];
|
|
292
|
-
let minDist = Math.abs(value - closest);
|
|
293
|
-
for (let i = 1; i < DOC_SPACING_TOKENS.length; i++) {
|
|
294
|
-
const dist = Math.abs(value - DOC_SPACING_TOKENS[i]);
|
|
295
|
-
if (dist < minDist) { closest = DOC_SPACING_TOKENS[i]; minDist = dist; }
|
|
296
|
-
}
|
|
297
|
-
return closest;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Only run on document pages
|
|
301
|
-
if (!isDocPage(root) && !(root.width >= 1000 && root.width <= 1400 && root.layoutMode === 'VERTICAL')) {
|
|
302
|
-
return { repairs: 0, details: ['Not a document page — skipped repair pass'] };
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// ── Repair 1: Width normalization for direct children ──
|
|
306
|
-
if (isAutoLayout(root) && root.layoutMode === 'VERTICAL' && 'children' in root) {
|
|
307
|
-
for (const child of root.children) {
|
|
308
|
-
if (!('layoutSizingHorizontal' in child)) continue;
|
|
309
|
-
// Skip small fixed elements (markers, icons)
|
|
310
|
-
if (child.width && child.width <= 48 && child.height && child.height <= 48) continue;
|
|
311
|
-
|
|
312
|
-
if (child.layoutSizingHorizontal !== 'FILL') {
|
|
313
|
-
child.layoutSizingHorizontal = 'FILL';
|
|
314
|
-
if ('layoutAlign' in child) child.layoutAlign = 'STRETCH';
|
|
315
|
-
repairs++;
|
|
316
|
-
details.push('Repair 1: Forced FILL width on root child: ' + child.name);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// ── Repair 2: Redundant wrapper removal ──
|
|
322
|
-
function removeRedundantWrappers(node) {
|
|
323
|
-
if (!('children' in node) || !isAutoLayout(node)) return;
|
|
324
|
-
const childrenCopy = [...node.children];
|
|
325
|
-
for (const child of childrenCopy) {
|
|
326
|
-
if (!('children' in child) || !isAutoLayout(child)) continue;
|
|
327
|
-
// If child has exactly 1 child frame with same layout mode and no semantic name
|
|
328
|
-
if (child.children.length === 1 && isAutoLayout(child.children[0]) &&
|
|
329
|
-
child.layoutMode === child.children[0].layoutMode &&
|
|
330
|
-
!child.name.match(/section|header|footer|block|group|toc|table/i) &&
|
|
331
|
-
child.name.match(/^(Frame|Group|Auto|Container)\\s*\\d*$/i)) {
|
|
332
|
-
// Flatten: move inner child's children to the wrapper's parent position
|
|
333
|
-
// (Only flag it — actual DOM manipulation is risky in bulk repair)
|
|
334
|
-
repairs++;
|
|
335
|
-
details.push('Repair 2: Redundant wrapper detected: ' + child.name + ' (contains single ' + child.children[0].name + ')');
|
|
336
|
-
}
|
|
337
|
-
removeRedundantWrappers(child);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
removeRedundantWrappers(root);
|
|
341
|
-
|
|
342
|
-
// ── Repair 3: Snap all spacing in document tree ──
|
|
343
|
-
function snapSpacing(node) {
|
|
344
|
-
if (!('children' in node) || !isAutoLayout(node)) return;
|
|
345
|
-
if ('itemSpacing' in node && node.itemSpacing > 0) {
|
|
346
|
-
const snapped = snapToToken(node.itemSpacing);
|
|
347
|
-
if (snapped !== node.itemSpacing) {
|
|
348
|
-
node.itemSpacing = snapped;
|
|
349
|
-
repairs++;
|
|
350
|
-
details.push('Repair 3: Snapped spacing ' + node.itemSpacing + ' -> ' + snapped + ' on ' + node.name);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
// Snap padding
|
|
354
|
-
var padProps = ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight'];
|
|
355
|
-
for (var pp of padProps) {
|
|
356
|
-
if (pp in node && node[pp] > 0) {
|
|
357
|
-
var snappedPad = snapToToken(node[pp]);
|
|
358
|
-
if (snappedPad !== node[pp]) {
|
|
359
|
-
var oldPad = node[pp];
|
|
360
|
-
node[pp] = snappedPad;
|
|
361
|
-
repairs++;
|
|
362
|
-
details.push('Repair 3: Snapped ' + pp + ' ' + oldPad + ' -> ' + snappedPad + ' on ' + node.name);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
for (const child of node.children) {
|
|
367
|
-
snapSpacing(child);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
snapSpacing(root);
|
|
371
|
-
|
|
372
|
-
// ── Repair 4: Force text in document sections to FILL horizontally ──
|
|
373
|
-
function fixDocText(node) {
|
|
374
|
-
if (!('children' in node)) return;
|
|
375
|
-
const n = (node.name || '').toLowerCase();
|
|
376
|
-
const isDocSection = /section|header|overview|anatomy|paragraph|content|footer/i.test(n);
|
|
377
|
-
if (isDocSection && isAutoLayout(node) && node.layoutMode === 'VERTICAL') {
|
|
378
|
-
for (const child of node.children) {
|
|
379
|
-
if (child.type === 'TEXT' && 'layoutSizingHorizontal' in child && child.layoutSizingHorizontal !== 'FILL') {
|
|
380
|
-
child.layoutSizingHorizontal = 'FILL';
|
|
381
|
-
if ('layoutAlign' in child) child.layoutAlign = 'STRETCH';
|
|
382
|
-
repairs++;
|
|
383
|
-
details.push('Repair 4: Text FILL in doc section: ' + child.name + ' inside ' + node.name);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
for (const child of node.children) {
|
|
388
|
-
fixDocText(child);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
fixDocText(root);
|
|
392
|
-
|
|
393
|
-
return { repairs: repairs, details: details };
|
|
394
|
-
}
|
|
395
|
-
`.trim();
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Returns a JS statement that invokes the document repair pass.
|
|
400
|
-
* Must be used after `generateDocumentRepairScript()` has been inlined.
|
|
401
|
-
*/
|
|
402
|
-
export function generateDocumentRepairCall(varName: string): string {
|
|
403
|
-
return `const _docRepair = repairDocumentLayout(${varName});`;
|
|
404
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// P1: Intelligent Caching Layer — TTL-based caching for Figma API responses
|
|
3
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
-
|
|
5
|
-
import { FigmaBridge } from "./figma-bridge.js";
|
|
6
|
-
import { FigmaNode, Token, ComponentSet } from "./types.js";
|
|
7
|
-
import { enrichDesignSystem, EnrichedDesignSystem } from "./enrichment-pipeline.js";
|
|
8
|
-
|
|
9
|
-
// ─── Core cache types ────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export interface CacheEntry<T> {
|
|
12
|
-
data: T;
|
|
13
|
-
timestamp: number;
|
|
14
|
-
expiresAt: number;
|
|
15
|
-
hits: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface CacheStats {
|
|
19
|
-
size: number;
|
|
20
|
-
hits: number;
|
|
21
|
-
misses: number;
|
|
22
|
-
evictions: number;
|
|
23
|
-
hitRate: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// ─── ResponseCache ───────────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
export class ResponseCache {
|
|
29
|
-
private cache = new Map<string, CacheEntry<unknown>>();
|
|
30
|
-
private maxEntries: number;
|
|
31
|
-
private defaultTTL: number;
|
|
32
|
-
private stats = { hits: 0, misses: 0, evictions: 0 };
|
|
33
|
-
|
|
34
|
-
constructor(options?: { maxEntries?: number; defaultTTL?: number }) {
|
|
35
|
-
this.maxEntries = options?.maxEntries ?? 200;
|
|
36
|
-
this.defaultTTL = options?.defaultTTL ?? 5 * 60 * 1000; // 5 minutes
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get<T>(key: string): T | undefined {
|
|
40
|
-
const entry = this.cache.get(key);
|
|
41
|
-
if (!entry) {
|
|
42
|
-
this.stats.misses++;
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
if (Date.now() > entry.expiresAt) {
|
|
46
|
-
this.cache.delete(key);
|
|
47
|
-
this.stats.misses++;
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
entry.hits++;
|
|
51
|
-
this.stats.hits++;
|
|
52
|
-
return entry.data as T;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
set<T>(key: string, data: T, ttl?: number): void {
|
|
56
|
-
// LRU eviction when at capacity
|
|
57
|
-
if (this.cache.size >= this.maxEntries && !this.cache.has(key)) {
|
|
58
|
-
this.evictLRU();
|
|
59
|
-
}
|
|
60
|
-
this.cache.set(key, {
|
|
61
|
-
data,
|
|
62
|
-
timestamp: Date.now(),
|
|
63
|
-
expiresAt: Date.now() + (ttl ?? this.defaultTTL),
|
|
64
|
-
hits: 0,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
invalidate(key: string): boolean;
|
|
69
|
-
invalidate(pattern: RegExp): number;
|
|
70
|
-
invalidate(keyOrPattern: string | RegExp): boolean | number {
|
|
71
|
-
if (typeof keyOrPattern === "string") {
|
|
72
|
-
return this.cache.delete(keyOrPattern);
|
|
73
|
-
}
|
|
74
|
-
let count = 0;
|
|
75
|
-
for (const key of [...this.cache.keys()]) {
|
|
76
|
-
if (keyOrPattern.test(key)) {
|
|
77
|
-
this.cache.delete(key);
|
|
78
|
-
count++;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return count;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
invalidateAll(): void {
|
|
85
|
-
this.cache.clear();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getStats(): CacheStats {
|
|
89
|
-
const total = this.stats.hits + this.stats.misses;
|
|
90
|
-
return {
|
|
91
|
-
size: this.cache.size,
|
|
92
|
-
hits: this.stats.hits,
|
|
93
|
-
misses: this.stats.misses,
|
|
94
|
-
evictions: this.stats.evictions,
|
|
95
|
-
hitRate: total === 0 ? 0 : this.stats.hits / total,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private evictLRU(): void {
|
|
100
|
-
// Find the entry with fewest hits; break ties by oldest timestamp.
|
|
101
|
-
let victimKey: string | undefined;
|
|
102
|
-
let victimHits = Infinity;
|
|
103
|
-
let victimTimestamp = Infinity;
|
|
104
|
-
|
|
105
|
-
for (const [key, entry] of this.cache) {
|
|
106
|
-
if (
|
|
107
|
-
entry.hits < victimHits ||
|
|
108
|
-
(entry.hits === victimHits && entry.timestamp < victimTimestamp)
|
|
109
|
-
) {
|
|
110
|
-
victimKey = key;
|
|
111
|
-
victimHits = entry.hits;
|
|
112
|
-
victimTimestamp = entry.timestamp;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (victimKey !== undefined) {
|
|
117
|
-
this.cache.delete(victimKey);
|
|
118
|
-
this.stats.evictions++;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ─── BridgeCache ─────────────────────────────────────────────────────────────
|
|
124
|
-
|
|
125
|
-
export class BridgeCache {
|
|
126
|
-
private cache: ResponseCache;
|
|
127
|
-
private bridge: FigmaBridge;
|
|
128
|
-
|
|
129
|
-
constructor(bridge: FigmaBridge) {
|
|
130
|
-
this.cache = new ResponseCache();
|
|
131
|
-
this.bridge = bridge;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** Cache node lookups (2-min TTL — nodes change more frequently). */
|
|
135
|
-
async getNode(nodeId: string): Promise<FigmaNode> {
|
|
136
|
-
const key = `node:${nodeId}`;
|
|
137
|
-
const cached = this.cache.get<FigmaNode>(key);
|
|
138
|
-
if (cached) return cached;
|
|
139
|
-
const node = await this.bridge.getNode(nodeId);
|
|
140
|
-
this.cache.set(key, node, 2 * 60 * 1000);
|
|
141
|
-
return node;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** Cache tokens with longer TTL (5 min). */
|
|
145
|
-
async getTokens(collectionId?: string): Promise<Token[]> {
|
|
146
|
-
const key = `tokens:${collectionId || "all"}`;
|
|
147
|
-
const cached = this.cache.get<Token[]>(key);
|
|
148
|
-
if (cached) return cached;
|
|
149
|
-
const tokens = await this.bridge.getTokens(collectionId);
|
|
150
|
-
this.cache.set(key, tokens, 5 * 60 * 1000);
|
|
151
|
-
return tokens;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** Cache component sets (5 min TTL). */
|
|
155
|
-
async getComponentSets(): Promise<ComponentSet[]> {
|
|
156
|
-
const key = "componentSets";
|
|
157
|
-
const cached = this.cache.get<ComponentSet[]>(key);
|
|
158
|
-
if (cached) return cached;
|
|
159
|
-
const sets = await this.bridge.getComponentSets();
|
|
160
|
-
this.cache.set(key, sets, 5 * 60 * 1000);
|
|
161
|
-
return sets;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** Cache + enrich design system data (tokens + components combined). */
|
|
165
|
-
async getEnrichedDesignSystem(): Promise<EnrichedDesignSystem> {
|
|
166
|
-
const key = "enrichedDS";
|
|
167
|
-
const cached = this.cache.get<EnrichedDesignSystem>(key);
|
|
168
|
-
if (cached) return cached;
|
|
169
|
-
|
|
170
|
-
const [tokens, componentSets] = await Promise.all([
|
|
171
|
-
this.getTokens(),
|
|
172
|
-
this.getComponentSets(),
|
|
173
|
-
]);
|
|
174
|
-
const enriched = enrichDesignSystem(tokens, componentSets);
|
|
175
|
-
this.cache.set(key, enriched, 5 * 60 * 1000);
|
|
176
|
-
return enriched;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/** Invalidate all cached data on document changes. */
|
|
180
|
-
onDocumentChange(): void {
|
|
181
|
-
this.cache.invalidate(/^(node|tokens|componentSets|enrichedDS)/);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
getStats(): CacheStats {
|
|
185
|
-
return this.cache.getStats();
|
|
186
|
-
}
|
|
187
|
-
}
|