@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,540 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// figma_composition_builder — Compose multi-component patterns
|
|
3
|
-
//
|
|
4
|
-
// Builds composed UI patterns from natural language:
|
|
5
|
-
// - "Login form" → Modal + 2 Inputs + Button + Link, wired with layout/tokens
|
|
6
|
-
// - "Data table with filters" → Table + Search + Select + Pagination
|
|
7
|
-
// - "Card with actions" → Card + Image + Text + Button Group
|
|
8
|
-
//
|
|
9
|
-
// Uses the component template catalog + design system tokens to wire up
|
|
10
|
-
// proper Auto Layout, spacing, and token bindings between components.
|
|
11
|
-
// Outputs a single frame containing all composed children.
|
|
12
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
-
|
|
14
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
15
|
-
import { COMPONENT_BLUEPRINTS, ComponentBlueprint } from "../../../shared/component-templates.js";
|
|
16
|
-
import { SEMANTIC_TOKEN_CATALOG } from "../../../shared/semantic-token-catalog.js";
|
|
17
|
-
import { resolveDesignPalette, ResolvedPalette } from "../../../shared/token-binder.js";
|
|
18
|
-
import { getDesignSystemFontFamily } from "../../../shared/design-system-tokens.js";
|
|
19
|
-
|
|
20
|
-
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
21
|
-
|
|
22
|
-
export interface CompositionBuilderArgs {
|
|
23
|
-
/** Natural language description of the pattern to build */
|
|
24
|
-
pattern: string;
|
|
25
|
-
/** Explicit list of components to compose (overrides AI pattern matching) */
|
|
26
|
-
components?: Array<{
|
|
27
|
-
name: string;
|
|
28
|
-
props?: Record<string, string>;
|
|
29
|
-
count?: number;
|
|
30
|
-
}>;
|
|
31
|
-
/** Target frame width (default 400) */
|
|
32
|
-
frameWidth?: number;
|
|
33
|
-
/** Layout direction (default auto-detected from pattern) */
|
|
34
|
-
layoutDirection?: "VERTICAL" | "HORIZONTAL";
|
|
35
|
-
/** Spacing between components in px (default: from DS tokens or 16) */
|
|
36
|
-
spacing?: number;
|
|
37
|
-
/** Padding inside the container frame (default: 24) */
|
|
38
|
-
padding?: number;
|
|
39
|
-
/** Include a background fill */
|
|
40
|
-
includeBackground?: boolean;
|
|
41
|
-
/** Place result on a specific Figma page */
|
|
42
|
-
targetPage?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface CompositionPlan {
|
|
46
|
-
name: string;
|
|
47
|
-
description: string;
|
|
48
|
-
direction: "VERTICAL" | "HORIZONTAL";
|
|
49
|
-
spacing: number;
|
|
50
|
-
padding: number;
|
|
51
|
-
width: number;
|
|
52
|
-
children: Array<{
|
|
53
|
-
blueprint: ComponentBlueprint;
|
|
54
|
-
label: string;
|
|
55
|
-
variant?: Record<string, string>;
|
|
56
|
-
count: number;
|
|
57
|
-
customText?: string;
|
|
58
|
-
}>;
|
|
59
|
-
wrapperStyle?: {
|
|
60
|
-
cornerRadius?: number;
|
|
61
|
-
fill?: string;
|
|
62
|
-
stroke?: string;
|
|
63
|
-
shadow?: boolean;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ─── Pattern Recognition ──────────────────────────────────────────────────
|
|
68
|
-
|
|
69
|
-
const PATTERN_RECIPES: Array<{
|
|
70
|
-
keywords: RegExp;
|
|
71
|
-
name: string;
|
|
72
|
-
description: string;
|
|
73
|
-
direction: "VERTICAL" | "HORIZONTAL";
|
|
74
|
-
components: Array<{ name: string; label: string; variant?: Record<string, string>; count?: number; text?: string }>;
|
|
75
|
-
wrapper?: CompositionPlan["wrapperStyle"];
|
|
76
|
-
}> = [
|
|
77
|
-
{
|
|
78
|
-
keywords: /login\s*form|sign\s*in|auth/i,
|
|
79
|
-
name: "Login Form",
|
|
80
|
-
description: "Email/password login form with submit button",
|
|
81
|
-
direction: "VERTICAL",
|
|
82
|
-
components: [
|
|
83
|
-
{ name: "Input", label: "Email Input", variant: { Type: "Default" }, text: "Email address" },
|
|
84
|
-
{ name: "Input", label: "Password Input", variant: { Type: "Default" }, text: "Password" },
|
|
85
|
-
{ name: "Button", label: "Submit Button", variant: { Type: "Primary", Size: "lg" }, text: "Sign In" },
|
|
86
|
-
{ name: "Link", label: "Forgot Password", text: "Forgot password?" },
|
|
87
|
-
],
|
|
88
|
-
wrapper: { cornerRadius: 12, fill: "color/surface/default", shadow: true },
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
keywords: /sign\s*up|register|create\s*account/i,
|
|
92
|
-
name: "Registration Form",
|
|
93
|
-
description: "Account registration form with name, email, password fields",
|
|
94
|
-
direction: "VERTICAL",
|
|
95
|
-
components: [
|
|
96
|
-
{ name: "Input", label: "Name Input", text: "Full name" },
|
|
97
|
-
{ name: "Input", label: "Email Input", text: "Email address" },
|
|
98
|
-
{ name: "Input", label: "Password Input", text: "Password" },
|
|
99
|
-
{ name: "Input", label: "Confirm Password Input", text: "Confirm password" },
|
|
100
|
-
{ name: "Checkbox", label: "Terms Checkbox", text: "I agree to the Terms of Service" },
|
|
101
|
-
{ name: "Button", label: "Register Button", variant: { Type: "Primary", Size: "lg" }, text: "Create Account" },
|
|
102
|
-
],
|
|
103
|
-
wrapper: { cornerRadius: 12, fill: "color/surface/default", shadow: true },
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
keywords: /search\s*bar|search\s*(?:with|and)\s*filter|filter\s*bar/i,
|
|
107
|
-
name: "Search with Filters",
|
|
108
|
-
description: "Search input with filter controls",
|
|
109
|
-
direction: "HORIZONTAL",
|
|
110
|
-
components: [
|
|
111
|
-
{ name: "Input", label: "Search Input", variant: { Type: "Default" }, text: "Search..." },
|
|
112
|
-
{ name: "Select", label: "Category Filter", text: "All categories" },
|
|
113
|
-
{ name: "Button", label: "Search Button", variant: { Type: "Primary" }, text: "Search" },
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
keywords: /card\s*(?:with|and)\s*action|action\s*card|product\s*card/i,
|
|
118
|
-
name: "Card with Actions",
|
|
119
|
-
description: "Content card with image, text, and action buttons",
|
|
120
|
-
direction: "VERTICAL",
|
|
121
|
-
components: [
|
|
122
|
-
{ name: "Card", label: "Card Container" },
|
|
123
|
-
{ name: "Badge", label: "Status Badge", text: "New" },
|
|
124
|
-
{ name: "Button", label: "Primary Action", variant: { Type: "Primary" }, text: "View Details" },
|
|
125
|
-
{ name: "Button", label: "Secondary Action", variant: { Type: "Secondary" }, text: "Save" },
|
|
126
|
-
],
|
|
127
|
-
wrapper: { cornerRadius: 8, stroke: "color/border/default", shadow: true },
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
keywords: /nav\s*bar|navigation\s*bar|header|top\s*bar|app\s*bar/i,
|
|
131
|
-
name: "Navigation Bar",
|
|
132
|
-
description: "Top navigation with logo, links, and user actions",
|
|
133
|
-
direction: "HORIZONTAL",
|
|
134
|
-
components: [
|
|
135
|
-
{ name: "Badge", label: "Logo", text: "Logo" },
|
|
136
|
-
{ name: "Link", label: "Nav Link 1", text: "Home" },
|
|
137
|
-
{ name: "Link", label: "Nav Link 2", text: "Products" },
|
|
138
|
-
{ name: "Link", label: "Nav Link 3", text: "About" },
|
|
139
|
-
{ name: "Input", label: "Search", text: "Search..." },
|
|
140
|
-
{ name: "Avatar", label: "User Avatar" },
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
keywords: /modal|dialog|popup\s*(?:with|and)\s*form/i,
|
|
145
|
-
name: "Modal Dialog",
|
|
146
|
-
description: "Modal with header, form content, and action buttons",
|
|
147
|
-
direction: "VERTICAL",
|
|
148
|
-
components: [
|
|
149
|
-
{ name: "Input", label: "Form Field 1", text: "Name" },
|
|
150
|
-
{ name: "Input", label: "Form Field 2", text: "Description" },
|
|
151
|
-
{ name: "Textarea", label: "Long Text Field", text: "Additional details..." },
|
|
152
|
-
{ name: "Button", label: "Cancel", variant: { Type: "Secondary" }, text: "Cancel" },
|
|
153
|
-
{ name: "Button", label: "Submit", variant: { Type: "Primary" }, text: "Save" },
|
|
154
|
-
],
|
|
155
|
-
wrapper: { cornerRadius: 12, fill: "color/surface/default", shadow: true },
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
keywords: /settings|preferences|config/i,
|
|
159
|
-
name: "Settings Panel",
|
|
160
|
-
description: "Settings panel with toggles and inputs",
|
|
161
|
-
direction: "VERTICAL",
|
|
162
|
-
components: [
|
|
163
|
-
{ name: "Toggle", label: "Notifications Toggle", text: "Enable notifications" },
|
|
164
|
-
{ name: "Toggle", label: "Dark Mode Toggle", text: "Dark mode" },
|
|
165
|
-
{ name: "Select", label: "Language Select", text: "English" },
|
|
166
|
-
{ name: "Input", label: "Display Name", text: "Display name" },
|
|
167
|
-
{ name: "Button", label: "Save Settings", variant: { Type: "Primary" }, text: "Save Changes" },
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
keywords: /empty\s*state|no\s*(?:data|results|items)|zero\s*state/i,
|
|
172
|
-
name: "Empty State",
|
|
173
|
-
description: "Empty state with illustration placeholder and CTA",
|
|
174
|
-
direction: "VERTICAL",
|
|
175
|
-
components: [
|
|
176
|
-
{ name: "Badge", label: "Icon Placeholder", text: "📭" },
|
|
177
|
-
{ name: "Badge", label: "Title", text: "No results found" },
|
|
178
|
-
{ name: "Badge", label: "Description", text: "Try adjusting your search or filters" },
|
|
179
|
-
{ name: "Button", label: "CTA Button", variant: { Type: "Primary" }, text: "Clear Filters" },
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
keywords: /pagination|page\s*nav|pager/i,
|
|
184
|
-
name: "Pagination Bar",
|
|
185
|
-
description: "Page navigation with prev/next and page numbers",
|
|
186
|
-
direction: "HORIZONTAL",
|
|
187
|
-
components: [
|
|
188
|
-
{ name: "Button", label: "Previous", variant: { Type: "Secondary", Size: "sm" }, text: "← Previous" },
|
|
189
|
-
{ name: "Badge", label: "Page 1", text: "1" },
|
|
190
|
-
{ name: "Badge", label: "Page 2", text: "2" },
|
|
191
|
-
{ name: "Badge", label: "Page 3", text: "3" },
|
|
192
|
-
{ name: "Button", label: "Next", variant: { Type: "Secondary", Size: "sm" }, text: "Next →" },
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
keywords: /toolbar|action\s*bar|button\s*group|button\s*bar/i,
|
|
197
|
-
name: "Toolbar",
|
|
198
|
-
description: "Horizontal toolbar with grouped actions",
|
|
199
|
-
direction: "HORIZONTAL",
|
|
200
|
-
components: [
|
|
201
|
-
{ name: "Button", label: "Action 1", variant: { Type: "Secondary", Size: "sm" }, text: "Edit" },
|
|
202
|
-
{ name: "Button", label: "Action 2", variant: { Type: "Secondary", Size: "sm" }, text: "Duplicate" },
|
|
203
|
-
{ name: "Button", label: "Action 3", variant: { Type: "Secondary", Size: "sm" }, text: "Delete" },
|
|
204
|
-
{ name: "Button", label: "Primary Action", variant: { Type: "Primary", Size: "sm" }, text: "Publish" },
|
|
205
|
-
],
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
keywords: /footer|page\s*footer/i,
|
|
209
|
-
name: "Footer",
|
|
210
|
-
description: "Page footer with links and copyright",
|
|
211
|
-
direction: "HORIZONTAL",
|
|
212
|
-
components: [
|
|
213
|
-
{ name: "Link", label: "Link 1", text: "Privacy Policy" },
|
|
214
|
-
{ name: "Link", label: "Link 2", text: "Terms of Service" },
|
|
215
|
-
{ name: "Link", label: "Link 3", text: "Contact Us" },
|
|
216
|
-
{ name: "Badge", label: "Copyright", text: "© 2024 Company" },
|
|
217
|
-
],
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
keywords: /notification|toast|alert\s*banner|announcement/i,
|
|
221
|
-
name: "Notification Banner",
|
|
222
|
-
description: "Dismissible notification with icon, message, and close button",
|
|
223
|
-
direction: "HORIZONTAL",
|
|
224
|
-
components: [
|
|
225
|
-
{ name: "Badge", label: "Icon", text: "ℹ️" },
|
|
226
|
-
{ name: "Badge", label: "Message", text: "Your changes have been saved successfully." },
|
|
227
|
-
{ name: "Button", label: "Dismiss", variant: { Type: "Ghost", Size: "sm" }, text: "✕" },
|
|
228
|
-
],
|
|
229
|
-
wrapper: { cornerRadius: 8, fill: "color/surface/info" },
|
|
230
|
-
},
|
|
231
|
-
];
|
|
232
|
-
|
|
233
|
-
function matchPattern(patternText: string): typeof PATTERN_RECIPES[number] | null {
|
|
234
|
-
for (const recipe of PATTERN_RECIPES) {
|
|
235
|
-
if (recipe.keywords.test(patternText)) {
|
|
236
|
-
return recipe;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// ─── Plan builder ──────────────────────────────────────────────────────────
|
|
243
|
-
|
|
244
|
-
function buildPlan(args: CompositionBuilderArgs): CompositionPlan {
|
|
245
|
-
const width = args.frameWidth ?? 400;
|
|
246
|
-
const spacing = args.spacing ?? 16;
|
|
247
|
-
const padding = args.padding ?? 24;
|
|
248
|
-
|
|
249
|
-
// Explicit component list
|
|
250
|
-
if (args.components?.length) {
|
|
251
|
-
const children = args.components.map((comp) => {
|
|
252
|
-
const blueprint = COMPONENT_BLUEPRINTS.find(
|
|
253
|
-
(b) => b.name.toLowerCase() === comp.name.toLowerCase()
|
|
254
|
-
);
|
|
255
|
-
if (!blueprint) {
|
|
256
|
-
// Fall back to a generic frame blueprint
|
|
257
|
-
return {
|
|
258
|
-
blueprint: COMPONENT_BLUEPRINTS.find((b) => b.name === "Button")!, // fallback
|
|
259
|
-
label: comp.name,
|
|
260
|
-
variant: comp.props,
|
|
261
|
-
count: comp.count ?? 1,
|
|
262
|
-
customText: comp.name,
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
blueprint,
|
|
267
|
-
label: comp.name,
|
|
268
|
-
variant: comp.props,
|
|
269
|
-
count: comp.count ?? 1,
|
|
270
|
-
};
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
name: "Custom Composition",
|
|
275
|
-
description: `Custom composition: ${args.components.map((c) => c.name).join(" + ")}`,
|
|
276
|
-
direction: args.layoutDirection ?? "VERTICAL",
|
|
277
|
-
spacing,
|
|
278
|
-
padding,
|
|
279
|
-
width,
|
|
280
|
-
children,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Pattern matching
|
|
285
|
-
const recipe = matchPattern(args.pattern);
|
|
286
|
-
if (recipe) {
|
|
287
|
-
const children = recipe.components.map((comp) => {
|
|
288
|
-
const blueprint = COMPONENT_BLUEPRINTS.find(
|
|
289
|
-
(b) => b.name.toLowerCase() === comp.name.toLowerCase()
|
|
290
|
-
) ?? COMPONENT_BLUEPRINTS[0]; // fallback to first blueprint
|
|
291
|
-
|
|
292
|
-
return {
|
|
293
|
-
blueprint,
|
|
294
|
-
label: comp.label,
|
|
295
|
-
variant: comp.variant,
|
|
296
|
-
count: comp.count ?? 1,
|
|
297
|
-
customText: comp.text,
|
|
298
|
-
};
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
return {
|
|
302
|
-
name: recipe.name,
|
|
303
|
-
description: recipe.description,
|
|
304
|
-
direction: args.layoutDirection ?? recipe.direction,
|
|
305
|
-
spacing,
|
|
306
|
-
padding,
|
|
307
|
-
width,
|
|
308
|
-
children,
|
|
309
|
-
wrapperStyle: recipe.wrapper,
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Fallback: try to extract component names from the pattern text
|
|
314
|
-
const words = args.pattern.toLowerCase().split(/[\s,+&]+/);
|
|
315
|
-
const matched: CompositionPlan["children"] = [];
|
|
316
|
-
|
|
317
|
-
for (const word of words) {
|
|
318
|
-
const blueprint = COMPONENT_BLUEPRINTS.find(
|
|
319
|
-
(b) => b.name.toLowerCase() === word || b.name.toLowerCase().includes(word)
|
|
320
|
-
);
|
|
321
|
-
if (blueprint && !matched.find((m) => m.blueprint.name === blueprint.name)) {
|
|
322
|
-
matched.push({ blueprint, label: blueprint.name, count: 1 });
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (matched.length > 0) {
|
|
327
|
-
return {
|
|
328
|
-
name: "Auto-detected Composition",
|
|
329
|
-
description: `Composed from: ${matched.map((m) => m.blueprint.name).join(", ")}`,
|
|
330
|
-
direction: args.layoutDirection ?? "VERTICAL",
|
|
331
|
-
spacing,
|
|
332
|
-
padding,
|
|
333
|
-
width,
|
|
334
|
-
children: matched,
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Ultimate fallback — empty container
|
|
339
|
-
return {
|
|
340
|
-
name: "Empty Container",
|
|
341
|
-
description: `Could not match pattern "${args.pattern}" to known recipes or components.`,
|
|
342
|
-
direction: "VERTICAL",
|
|
343
|
-
spacing,
|
|
344
|
-
padding,
|
|
345
|
-
width,
|
|
346
|
-
children: [],
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// ─── Figma builder ─────────────────────────────────────────────────────────
|
|
351
|
-
|
|
352
|
-
async function buildInFigma(plan: CompositionPlan, args: CompositionBuilderArgs): Promise<{ frameId: string; pageName?: string }> {
|
|
353
|
-
const bridge = await getBridge();
|
|
354
|
-
|
|
355
|
-
// Resolve DS palette — selected DS is authoritative
|
|
356
|
-
const dsId = bridge.getActiveDesignSystemId();
|
|
357
|
-
let palette: ResolvedPalette | undefined;
|
|
358
|
-
try {
|
|
359
|
-
const tokens = await bridge.getTokens();
|
|
360
|
-
if (dsId || tokens.length > 0) palette = resolveDesignPalette(tokens, dsId);
|
|
361
|
-
} catch {
|
|
362
|
-
if (dsId) palette = resolveDesignPalette([], dsId);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Color helpers — use DS palette when available, else hardcoded defaults
|
|
366
|
-
const surfaceColor = palette?.surface.rgb ?? "{ r: 0.95, g: 0.95, b: 0.97 }";
|
|
367
|
-
const borderColor = palette?.border.rgb ?? "{ r: 0.85, g: 0.85, b: 0.85 }";
|
|
368
|
-
const textColor = palette ? (palette.muted.rgb !== palette.primary.rgb ? palette.muted.rgb : "{ r: 0.1, g: 0.1, b: 0.1 }") : "{ r: 0.1, g: 0.1, b: 0.1 }";
|
|
369
|
-
const accentColor = palette?.accent.rgb ?? "{ r: 0.4, g: 0.5, b: 0.9 }";
|
|
370
|
-
const bgColor = palette?.surface.rgb ?? "{ r: 1, g: 1, b: 1 }";
|
|
371
|
-
const fontFamily = (dsId ? getDesignSystemFontFamily(dsId) : null) ?? "Inter";
|
|
372
|
-
|
|
373
|
-
// Build the script to create the composition in Figma
|
|
374
|
-
const childScripts: string[] = [];
|
|
375
|
-
|
|
376
|
-
for (const child of plan.children) {
|
|
377
|
-
const bp = child.blueprint;
|
|
378
|
-
const rootNode = bp.root;
|
|
379
|
-
|
|
380
|
-
for (let i = 0; i < child.count; i++) {
|
|
381
|
-
const label = child.count > 1 ? `${child.label} ${i + 1}` : child.label;
|
|
382
|
-
|
|
383
|
-
childScripts.push(`
|
|
384
|
-
// ── ${label} ──
|
|
385
|
-
(function() {
|
|
386
|
-
var comp = figma.createFrame();
|
|
387
|
-
comp.name = '${label.replace(/'/g, "\\'")}';
|
|
388
|
-
comp.layoutMode = '${rootNode.layoutMode ?? "HORIZONTAL"}';
|
|
389
|
-
comp.primaryAxisSizingMode = 'AUTO';
|
|
390
|
-
comp.counterAxisSizingMode = 'AUTO';
|
|
391
|
-
comp.paddingLeft = ${rootNode.paddingX ?? 16};
|
|
392
|
-
comp.paddingRight = ${rootNode.paddingX ?? 16};
|
|
393
|
-
comp.paddingTop = ${rootNode.paddingY ?? 8};
|
|
394
|
-
comp.paddingBottom = ${rootNode.paddingY ?? 8};
|
|
395
|
-
comp.itemSpacing = ${rootNode.itemSpacing ?? 8};
|
|
396
|
-
comp.cornerRadius = ${rootNode.cornerRadius ?? 0};
|
|
397
|
-
${rootNode.fillSemantic ? `comp.fills = [{ type: 'SOLID', color: ${surfaceColor} }];` : `comp.fills = [];`}
|
|
398
|
-
${rootNode.strokeSemantic ? `comp.strokes = [{ type: 'SOLID', color: ${borderColor} }]; comp.strokeWeight = ${rootNode.strokeWeight ?? 1};` : ""}
|
|
399
|
-
|
|
400
|
-
${rootNode.children?.map((childNode) => {
|
|
401
|
-
if (childNode.kind === "text") {
|
|
402
|
-
const text = child.customText ?? childNode.textContent ?? label;
|
|
403
|
-
return `
|
|
404
|
-
var txt = figma.createText();
|
|
405
|
-
txt.name = '${childNode.name.replace(/'/g, "\\'")}';
|
|
406
|
-
txt.characters = '${text.replace(/'/g, "\\'")}';
|
|
407
|
-
txt.fontSize = ${childNode.textContent?.includes("label") || childNode.name.includes("label") ? 14 : 14};
|
|
408
|
-
txt.fills = [{ type: 'SOLID', color: ${textColor} }];
|
|
409
|
-
comp.appendChild(txt);
|
|
410
|
-
`;
|
|
411
|
-
}
|
|
412
|
-
if (childNode.kind === "rect" || childNode.kind === "frame") {
|
|
413
|
-
return `
|
|
414
|
-
var rect = figma.createFrame();
|
|
415
|
-
rect.name = '${childNode.name.replace(/'/g, "\\'")}';
|
|
416
|
-
rect.resize(${childNode.width ?? 16}, ${childNode.height ?? 16});
|
|
417
|
-
${childNode.cornerRadius ? `rect.cornerRadius = ${childNode.cornerRadius};` : ""}
|
|
418
|
-
${childNode.fillSemantic ? `rect.fills = [{ type: 'SOLID', color: ${accentColor} }];` : `rect.fills = [{ type: 'SOLID', color: ${surfaceColor} }];`}
|
|
419
|
-
comp.appendChild(rect);
|
|
420
|
-
`;
|
|
421
|
-
}
|
|
422
|
-
return "";
|
|
423
|
-
}).join("\n") ?? ""}
|
|
424
|
-
|
|
425
|
-
container.appendChild(comp);
|
|
426
|
-
})();
|
|
427
|
-
`);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const wrapperFill = plan.wrapperStyle?.fill
|
|
432
|
-
? `container.fills = [{ type: 'SOLID', color: ${bgColor} }];`
|
|
433
|
-
: args.includeBackground
|
|
434
|
-
? `container.fills = [{ type: 'SOLID', color: ${bgColor} }];`
|
|
435
|
-
: `container.fills = [];`;
|
|
436
|
-
|
|
437
|
-
const script = `
|
|
438
|
-
(async () => {
|
|
439
|
-
await figma.loadFontAsync({ family: ${JSON.stringify(fontFamily)}, style: "Regular" }).catch(function() { return figma.loadFontAsync({ family: "Inter", style: "Regular" }); });
|
|
440
|
-
await figma.loadFontAsync({ family: ${JSON.stringify(fontFamily)}, style: "Medium" }).catch(function() { return figma.loadFontAsync({ family: "Inter", style: "Medium" }); });
|
|
441
|
-
await figma.loadFontAsync({ family: ${JSON.stringify(fontFamily)}, style: "Bold" }).catch(function() { return figma.loadFontAsync({ family: "Inter", style: "Bold" }); });
|
|
442
|
-
|
|
443
|
-
${args.targetPage ? `
|
|
444
|
-
var targetPage = figma.root.children.find(function(p) { return p.name === '${args.targetPage.replace(/'/g, "\\'")}'; });
|
|
445
|
-
if (!targetPage) {
|
|
446
|
-
targetPage = figma.createPage();
|
|
447
|
-
targetPage.name = '${args.targetPage.replace(/'/g, "\\'")}';
|
|
448
|
-
}
|
|
449
|
-
figma.currentPage = targetPage;
|
|
450
|
-
` : ""}
|
|
451
|
-
|
|
452
|
-
// Create container frame
|
|
453
|
-
var container = figma.createFrame();
|
|
454
|
-
container.name = '${plan.name.replace(/'/g, "\\'")}';
|
|
455
|
-
container.layoutMode = '${plan.direction}';
|
|
456
|
-
container.primaryAxisSizingMode = 'AUTO';
|
|
457
|
-
container.counterAxisSizingMode = 'FIXED';
|
|
458
|
-
container.resize(${plan.width}, 100);
|
|
459
|
-
container.paddingLeft = ${plan.padding};
|
|
460
|
-
container.paddingRight = ${plan.padding};
|
|
461
|
-
container.paddingTop = ${plan.padding};
|
|
462
|
-
container.paddingBottom = ${plan.padding};
|
|
463
|
-
container.itemSpacing = ${plan.spacing};
|
|
464
|
-
${plan.wrapperStyle?.cornerRadius ? `container.cornerRadius = ${plan.wrapperStyle.cornerRadius};` : ""}
|
|
465
|
-
${wrapperFill}
|
|
466
|
-
${plan.wrapperStyle?.stroke ? `container.strokes = [{ type: 'SOLID', color: ${borderColor} }]; container.strokeWeight = 1;` : ""}
|
|
467
|
-
${plan.wrapperStyle?.shadow ? `container.effects = [{ type: 'DROP_SHADOW', color: { r: 0, g: 0, b: 0, a: 0.1 }, offset: { x: 0, y: 4 }, radius: 12, spread: 0, visible: true }];` : ""}
|
|
468
|
-
|
|
469
|
-
// Title label
|
|
470
|
-
var titleLabel = figma.createText();
|
|
471
|
-
titleLabel.name = 'Composition Title';
|
|
472
|
-
titleLabel.fontName = { family: ${JSON.stringify(fontFamily)}, style: "Bold" };
|
|
473
|
-
titleLabel.fontSize = 18;
|
|
474
|
-
titleLabel.characters = '${plan.name.replace(/'/g, "\\'")}';
|
|
475
|
-
titleLabel.fills = [{ type: 'SOLID', color: ${textColor} }];
|
|
476
|
-
container.appendChild(titleLabel);
|
|
477
|
-
|
|
478
|
-
${childScripts.join("\n")}
|
|
479
|
-
|
|
480
|
-
// Position on canvas
|
|
481
|
-
container.x = 100;
|
|
482
|
-
container.y = 100;
|
|
483
|
-
|
|
484
|
-
figma.currentPage.selection = [container];
|
|
485
|
-
figma.viewport.scrollAndZoomIntoView([container]);
|
|
486
|
-
|
|
487
|
-
return { frameId: container.id, pageName: figma.currentPage.name };
|
|
488
|
-
})();
|
|
489
|
-
`;
|
|
490
|
-
|
|
491
|
-
const result = await bridge.execute(script);
|
|
492
|
-
if (!result.success || !result.result) {
|
|
493
|
-
throw new Error(result.error || "Failed to build composition in Figma");
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
return result.result as { frameId: string; pageName: string };
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// ─── Main handler ──────────────────────────────────────────────────────────
|
|
500
|
-
|
|
501
|
-
export async function compositionBuilderHandler(args: CompositionBuilderArgs): Promise<unknown> {
|
|
502
|
-
const plan = buildPlan(args);
|
|
503
|
-
|
|
504
|
-
if (plan.children.length === 0) {
|
|
505
|
-
return {
|
|
506
|
-
error: `Could not match pattern "${args.pattern}" to any known recipe or component.`,
|
|
507
|
-
availablePatterns: PATTERN_RECIPES.map((r) => ({
|
|
508
|
-
pattern: r.name,
|
|
509
|
-
keywords: r.keywords.source,
|
|
510
|
-
components: r.components.map((c) => c.name),
|
|
511
|
-
})),
|
|
512
|
-
availableComponents: COMPONENT_BLUEPRINTS.map((b) => b.name),
|
|
513
|
-
hint: "Try a specific pattern like 'login form', 'search with filters', or 'card with actions'. Or provide explicit components via the 'components' parameter.",
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// Build in Figma
|
|
518
|
-
const { frameId, pageName } = await buildInFigma(plan, args);
|
|
519
|
-
|
|
520
|
-
return {
|
|
521
|
-
composition: plan.name,
|
|
522
|
-
description: plan.description,
|
|
523
|
-
frameId,
|
|
524
|
-
pageName,
|
|
525
|
-
layout: {
|
|
526
|
-
direction: plan.direction,
|
|
527
|
-
spacing: plan.spacing,
|
|
528
|
-
padding: plan.padding,
|
|
529
|
-
width: plan.width,
|
|
530
|
-
},
|
|
531
|
-
components: plan.children.map((c) => ({
|
|
532
|
-
name: c.blueprint.name,
|
|
533
|
-
label: c.label,
|
|
534
|
-
count: c.count,
|
|
535
|
-
variant: c.variant,
|
|
536
|
-
})),
|
|
537
|
-
totalComponents: plan.children.reduce((sum, c) => sum + c.count, 0),
|
|
538
|
-
availablePatterns: PATTERN_RECIPES.map((r) => r.name),
|
|
539
|
-
};
|
|
540
|
-
}
|