@sarjallab09/figma-intelligence 1.1.0 → 1.2.1
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 +69 -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 -2505
- package/figma-bridge-plugin/chat-runner.js +0 -485
- package/figma-bridge-plugin/code.js +0 -1534
- 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 -645
- 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 -4542
- 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 -1418
- 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,702 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// figma_handoff_spec — Developer-ready handoff specification
|
|
3
|
-
//
|
|
4
|
-
// Takes a Figma component or frame and generates a complete developer handoff
|
|
5
|
-
// document with:
|
|
6
|
-
// - Measurements (width, height, padding, gap, margin)
|
|
7
|
-
// - Token names mapped to every visual property
|
|
8
|
-
// - Copy-paste CSS/SCSS for each element
|
|
9
|
-
// - Redline annotations showing spacing relationships
|
|
10
|
-
// - Asset export list (icons, images)
|
|
11
|
-
// - Responsive notes & breakpoint behavior
|
|
12
|
-
// - Interaction specs (hover, focus, active states)
|
|
13
|
-
//
|
|
14
|
-
// Output: structured JSON, Markdown, or annotated Figma page with redlines.
|
|
15
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
-
|
|
17
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
18
|
-
import { figmaRgbaToHex } from "../../../shared/token-utils.js";
|
|
19
|
-
|
|
20
|
-
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
21
|
-
|
|
22
|
-
export interface HandoffSpecArgs {
|
|
23
|
-
/** Figma node ID of the component/frame to spec */
|
|
24
|
-
nodeId: string;
|
|
25
|
-
/** Output format */
|
|
26
|
-
outputFormat: "json" | "markdown" | "figma-page" | "all";
|
|
27
|
-
/** Include copy-paste CSS snippets for each element */
|
|
28
|
-
includeCss?: boolean;
|
|
29
|
-
/** Include asset export list */
|
|
30
|
-
includeAssets?: boolean;
|
|
31
|
-
/** CSS unit preference */
|
|
32
|
-
cssUnit?: "px" | "rem";
|
|
33
|
-
/** rem base size (default 16) */
|
|
34
|
-
remBase?: number;
|
|
35
|
-
/** Max depth for recursive element scanning */
|
|
36
|
-
maxDepth?: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface MeasuredElement {
|
|
40
|
-
id: string;
|
|
41
|
-
name: string;
|
|
42
|
-
type: string;
|
|
43
|
-
depth: number;
|
|
44
|
-
bounds: { x: number; y: number; width: number; height: number };
|
|
45
|
-
spacing: {
|
|
46
|
-
paddingTop: number;
|
|
47
|
-
paddingRight: number;
|
|
48
|
-
paddingBottom: number;
|
|
49
|
-
paddingLeft: number;
|
|
50
|
-
itemSpacing: number;
|
|
51
|
-
layoutMode: string;
|
|
52
|
-
};
|
|
53
|
-
appearance: {
|
|
54
|
-
fills: Array<{ type: string; hex: string; opacity: number; tokenName: string }>;
|
|
55
|
-
strokes: Array<{ hex: string; weight: number; tokenName: string }>;
|
|
56
|
-
cornerRadius: number | number[];
|
|
57
|
-
effects: Array<{ type: string; description: string }>;
|
|
58
|
-
opacity: number;
|
|
59
|
-
};
|
|
60
|
-
typography: {
|
|
61
|
-
fontFamily: string;
|
|
62
|
-
fontSize: number;
|
|
63
|
-
fontWeight: number;
|
|
64
|
-
lineHeight: number | string;
|
|
65
|
-
letterSpacing: number;
|
|
66
|
-
textAlign: string;
|
|
67
|
-
tokenName: string;
|
|
68
|
-
} | null;
|
|
69
|
-
tokens: Array<{ property: string; tokenName: string; rawValue: string }>;
|
|
70
|
-
cssSnippet: string;
|
|
71
|
-
children: string[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
interface AssetEntry {
|
|
75
|
-
nodeId: string;
|
|
76
|
-
name: string;
|
|
77
|
-
type: "icon" | "image" | "illustration" | "logo";
|
|
78
|
-
suggestedExport: string;
|
|
79
|
-
size: { width: number; height: number };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface RedlineAnnotation {
|
|
83
|
-
fromElement: string;
|
|
84
|
-
toElement: string;
|
|
85
|
-
direction: "horizontal" | "vertical";
|
|
86
|
-
distance: number;
|
|
87
|
-
label: string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ─── Figma extraction ──────────────────────────────────────────────────────
|
|
91
|
-
|
|
92
|
-
async function extractNodeTree(
|
|
93
|
-
nodeId: string,
|
|
94
|
-
maxDepth: number
|
|
95
|
-
): Promise<{
|
|
96
|
-
elements: MeasuredElement[];
|
|
97
|
-
assets: AssetEntry[];
|
|
98
|
-
redlines: RedlineAnnotation[];
|
|
99
|
-
rootName: string;
|
|
100
|
-
rootBounds: { width: number; height: number };
|
|
101
|
-
}> {
|
|
102
|
-
const bridge = await getBridge();
|
|
103
|
-
|
|
104
|
-
const result = await bridge.execute(`
|
|
105
|
-
(async () => {
|
|
106
|
-
var node = figma.getNodeById('${nodeId}');
|
|
107
|
-
if (!node) return { error: 'Node not found' };
|
|
108
|
-
|
|
109
|
-
var elements = [];
|
|
110
|
-
var assets = [];
|
|
111
|
-
var maxDepth = ${maxDepth};
|
|
112
|
-
|
|
113
|
-
function hexFromPaint(paint) {
|
|
114
|
-
if (!paint || paint.type !== 'SOLID') return '#000000';
|
|
115
|
-
var r = Math.round((paint.color.r || 0) * 255).toString(16).padStart(2, '0');
|
|
116
|
-
var g = Math.round((paint.color.g || 0) * 255).toString(16).padStart(2, '0');
|
|
117
|
-
var b = Math.round((paint.color.b || 0) * 255).toString(16).padStart(2, '0');
|
|
118
|
-
return '#' + r + g + b;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getTokenName(node, prop) {
|
|
122
|
-
try {
|
|
123
|
-
var bindings = node.boundVariables || {};
|
|
124
|
-
if (bindings[prop]) {
|
|
125
|
-
var alias = bindings[prop];
|
|
126
|
-
if (alias.id) {
|
|
127
|
-
var v = figma.variables.getVariableById(alias.id);
|
|
128
|
-
return v ? v.name : '';
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (prop === 'fills' && Array.isArray(bindings.fills)) {
|
|
132
|
-
for (var i = 0; i < bindings.fills.length; i++) {
|
|
133
|
-
if (bindings.fills[i] && bindings.fills[i].id) {
|
|
134
|
-
var v = figma.variables.getVariableById(bindings.fills[i].id);
|
|
135
|
-
if (v) return v.name;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
} catch (e) {}
|
|
140
|
-
return '';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function scan(n, depth) {
|
|
144
|
-
if (depth > maxDepth) return;
|
|
145
|
-
if (!n.visible) return;
|
|
146
|
-
|
|
147
|
-
var fills = [];
|
|
148
|
-
var strokes = [];
|
|
149
|
-
var tokens = [];
|
|
150
|
-
|
|
151
|
-
if (n.fills && Array.isArray(n.fills)) {
|
|
152
|
-
for (var i = 0; i < n.fills.length; i++) {
|
|
153
|
-
var f = n.fills[i];
|
|
154
|
-
if (!f.visible && f.visible !== undefined) continue;
|
|
155
|
-
var tk = getTokenName(n, 'fills');
|
|
156
|
-
fills.push({ type: f.type, hex: hexFromPaint(f), opacity: f.opacity || 1, tokenName: tk });
|
|
157
|
-
if (tk) tokens.push({ property: 'fill', tokenName: tk, rawValue: hexFromPaint(f) });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (n.strokes && Array.isArray(n.strokes)) {
|
|
162
|
-
for (var i = 0; i < n.strokes.length; i++) {
|
|
163
|
-
var s = n.strokes[i];
|
|
164
|
-
var tk = getTokenName(n, 'strokes');
|
|
165
|
-
strokes.push({ hex: hexFromPaint(s), weight: n.strokeWeight || 1, tokenName: tk });
|
|
166
|
-
if (tk) tokens.push({ property: 'stroke', tokenName: tk, rawValue: hexFromPaint(s) });
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var ptk = getTokenName(n, 'paddingTop');
|
|
171
|
-
if (ptk) tokens.push({ property: 'paddingTop', tokenName: ptk, rawValue: String(n.paddingTop || 0) });
|
|
172
|
-
var ispk = getTokenName(n, 'itemSpacing');
|
|
173
|
-
if (ispk) tokens.push({ property: 'itemSpacing', tokenName: ispk, rawValue: String(n.itemSpacing || 0) });
|
|
174
|
-
var crk = getTokenName(n, 'topLeftRadius');
|
|
175
|
-
if (crk) tokens.push({ property: 'cornerRadius', tokenName: crk, rawValue: String(n.cornerRadius || 0) });
|
|
176
|
-
|
|
177
|
-
var typo = null;
|
|
178
|
-
if (n.type === 'TEXT') {
|
|
179
|
-
var ft = getTokenName(n, 'fontSize');
|
|
180
|
-
typo = {
|
|
181
|
-
fontFamily: n.fontName ? n.fontName.family : '',
|
|
182
|
-
fontSize: n.fontSize || 0,
|
|
183
|
-
fontWeight: n.fontWeight || 400,
|
|
184
|
-
lineHeight: n.lineHeight ? (n.lineHeight.unit === 'PIXELS' ? n.lineHeight.value : n.lineHeight.unit === 'PERCENT' ? (n.lineHeight.value + '%') : 'auto') : 'auto',
|
|
185
|
-
letterSpacing: n.letterSpacing ? n.letterSpacing.value : 0,
|
|
186
|
-
textAlign: n.textAlignHorizontal || 'LEFT',
|
|
187
|
-
tokenName: ft
|
|
188
|
-
};
|
|
189
|
-
if (ft) tokens.push({ property: 'fontSize', tokenName: ft, rawValue: String(n.fontSize) });
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Detect assets
|
|
193
|
-
if (n.type === 'INSTANCE' && n.name.toLowerCase().includes('icon')) {
|
|
194
|
-
assets.push({ nodeId: n.id, name: n.name, type: 'icon', suggestedExport: 'SVG', size: { width: Math.round(n.width), height: Math.round(n.height) } });
|
|
195
|
-
} else if (n.fills && n.fills.some(function(f) { return f.type === 'IMAGE'; })) {
|
|
196
|
-
assets.push({ nodeId: n.id, name: n.name, type: 'image', suggestedExport: 'PNG @2x', size: { width: Math.round(n.width), height: Math.round(n.height) } });
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
var el = {
|
|
200
|
-
id: n.id,
|
|
201
|
-
name: n.name,
|
|
202
|
-
type: n.type,
|
|
203
|
-
depth: depth,
|
|
204
|
-
bounds: { x: Math.round(n.x || 0), y: Math.round(n.y || 0), width: Math.round(n.width || 0), height: Math.round(n.height || 0) },
|
|
205
|
-
spacing: {
|
|
206
|
-
paddingTop: n.paddingTop || 0,
|
|
207
|
-
paddingRight: n.paddingRight || 0,
|
|
208
|
-
paddingBottom: n.paddingBottom || 0,
|
|
209
|
-
paddingLeft: n.paddingLeft || 0,
|
|
210
|
-
itemSpacing: n.itemSpacing || 0,
|
|
211
|
-
layoutMode: n.layoutMode || 'NONE'
|
|
212
|
-
},
|
|
213
|
-
appearance: {
|
|
214
|
-
fills: fills,
|
|
215
|
-
strokes: strokes,
|
|
216
|
-
cornerRadius: typeof n.cornerRadius === 'number' ? n.cornerRadius : [n.topLeftRadius || 0, n.topRightRadius || 0, n.bottomRightRadius || 0, n.bottomLeftRadius || 0],
|
|
217
|
-
effects: (n.effects || []).map(function(e) { return { type: e.type, description: e.type + ' ' + (e.radius || 0) + 'px' }; }),
|
|
218
|
-
opacity: n.opacity !== undefined ? n.opacity : 1
|
|
219
|
-
},
|
|
220
|
-
typography: typo,
|
|
221
|
-
tokens: tokens,
|
|
222
|
-
children: n.children ? n.children.map(function(c) { return c.id; }) : []
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
elements.push(el);
|
|
226
|
-
|
|
227
|
-
if (n.children) {
|
|
228
|
-
for (var i = 0; i < n.children.length; i++) {
|
|
229
|
-
scan(n.children[i], depth + 1);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
scan(node, 0);
|
|
235
|
-
|
|
236
|
-
return {
|
|
237
|
-
elements: elements,
|
|
238
|
-
assets: assets,
|
|
239
|
-
rootName: node.name,
|
|
240
|
-
rootBounds: { width: Math.round(node.width || 0), height: Math.round(node.height || 0) }
|
|
241
|
-
};
|
|
242
|
-
})();
|
|
243
|
-
`);
|
|
244
|
-
|
|
245
|
-
if (!result.success || !result.result) {
|
|
246
|
-
throw new Error(result.error || "Failed to extract node tree");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const data = result.result as {
|
|
250
|
-
elements: MeasuredElement[];
|
|
251
|
-
assets: AssetEntry[];
|
|
252
|
-
rootName: string;
|
|
253
|
-
rootBounds: { width: number; height: number };
|
|
254
|
-
error?: string;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
if (data.error) throw new Error(data.error);
|
|
258
|
-
|
|
259
|
-
// Compute redline annotations from adjacent sibling spacing
|
|
260
|
-
const redlines: RedlineAnnotation[] = [];
|
|
261
|
-
for (const el of data.elements) {
|
|
262
|
-
if (el.spacing.layoutMode !== "NONE" && el.children.length > 1) {
|
|
263
|
-
const childEls = data.elements.filter((e) => el.children.includes(e.id));
|
|
264
|
-
for (let i = 0; i < childEls.length - 1; i++) {
|
|
265
|
-
const dir = el.spacing.layoutMode === "HORIZONTAL" ? "horizontal" : "vertical";
|
|
266
|
-
redlines.push({
|
|
267
|
-
fromElement: childEls[i].name,
|
|
268
|
-
toElement: childEls[i + 1].name,
|
|
269
|
-
direction: dir,
|
|
270
|
-
distance: el.spacing.itemSpacing,
|
|
271
|
-
label: `${el.spacing.itemSpacing}px gap`,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Padding redlines
|
|
277
|
-
if (el.spacing.paddingTop > 0 || el.spacing.paddingRight > 0 || el.spacing.paddingBottom > 0 || el.spacing.paddingLeft > 0) {
|
|
278
|
-
if (el.spacing.paddingTop > 0) {
|
|
279
|
-
redlines.push({ fromElement: el.name, toElement: `${el.name} (content)`, direction: "vertical", distance: el.spacing.paddingTop, label: `${el.spacing.paddingTop}px padding-top` });
|
|
280
|
-
}
|
|
281
|
-
if (el.spacing.paddingBottom > 0) {
|
|
282
|
-
redlines.push({ fromElement: `${el.name} (content)`, toElement: el.name, direction: "vertical", distance: el.spacing.paddingBottom, label: `${el.spacing.paddingBottom}px padding-bottom` });
|
|
283
|
-
}
|
|
284
|
-
if (el.spacing.paddingLeft > 0) {
|
|
285
|
-
redlines.push({ fromElement: el.name, toElement: `${el.name} (content)`, direction: "horizontal", distance: el.spacing.paddingLeft, label: `${el.spacing.paddingLeft}px padding-left` });
|
|
286
|
-
}
|
|
287
|
-
if (el.spacing.paddingRight > 0) {
|
|
288
|
-
redlines.push({ fromElement: `${el.name} (content)`, toElement: el.name, direction: "horizontal", distance: el.spacing.paddingRight, label: `${el.spacing.paddingRight}px padding-right` });
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return { ...data, redlines };
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// ─── CSS snippet generator ─────────────────────────────────────────────────
|
|
297
|
-
|
|
298
|
-
function generateElementCss(el: MeasuredElement, unit: "px" | "rem", remBase: number): string {
|
|
299
|
-
const u = (val: number) => {
|
|
300
|
-
if (val === 0) return "0";
|
|
301
|
-
return unit === "rem" ? `${(val / remBase).toFixed(3).replace(/\.?0+$/, "")}rem` : `${val}px`;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
const lines: string[] = [];
|
|
305
|
-
lines.push(`.${el.name.replace(/[^a-zA-Z0-9_-]/g, "-").toLowerCase()} {`);
|
|
306
|
-
|
|
307
|
-
// Layout
|
|
308
|
-
if (el.spacing.layoutMode !== "NONE") {
|
|
309
|
-
lines.push(` display: flex;`);
|
|
310
|
-
lines.push(` flex-direction: ${el.spacing.layoutMode === "VERTICAL" ? "column" : "row"};`);
|
|
311
|
-
if (el.spacing.itemSpacing > 0) lines.push(` gap: ${u(el.spacing.itemSpacing)};`);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Dimensions
|
|
315
|
-
lines.push(` width: ${u(el.bounds.width)};`);
|
|
316
|
-
lines.push(` height: ${u(el.bounds.height)};`);
|
|
317
|
-
|
|
318
|
-
// Padding
|
|
319
|
-
const { paddingTop: pt, paddingRight: pr, paddingBottom: pb, paddingLeft: pl } = el.spacing;
|
|
320
|
-
if (pt || pr || pb || pl) {
|
|
321
|
-
if (pt === pb && pl === pr && pt === pl) {
|
|
322
|
-
lines.push(` padding: ${u(pt)};`);
|
|
323
|
-
} else if (pt === pb && pl === pr) {
|
|
324
|
-
lines.push(` padding: ${u(pt)} ${u(pr)};`);
|
|
325
|
-
} else {
|
|
326
|
-
lines.push(` padding: ${u(pt)} ${u(pr)} ${u(pb)} ${u(pl)};`);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Fills
|
|
331
|
-
for (const fill of el.appearance.fills) {
|
|
332
|
-
if (fill.tokenName) {
|
|
333
|
-
lines.push(` background-color: var(--${fill.tokenName.replace(/\//g, "-").toLowerCase()});`);
|
|
334
|
-
} else if (fill.type === "SOLID") {
|
|
335
|
-
lines.push(` background-color: ${fill.hex};`);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Border
|
|
340
|
-
for (const stroke of el.appearance.strokes) {
|
|
341
|
-
const borderVal = stroke.tokenName
|
|
342
|
-
? `${u(stroke.weight)} solid var(--${stroke.tokenName.replace(/\//g, "-").toLowerCase()})`
|
|
343
|
-
: `${u(stroke.weight)} solid ${stroke.hex}`;
|
|
344
|
-
lines.push(` border: ${borderVal};`);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Border radius
|
|
348
|
-
const cr = el.appearance.cornerRadius;
|
|
349
|
-
if (typeof cr === "number" && cr > 0) {
|
|
350
|
-
lines.push(` border-radius: ${u(cr)};`);
|
|
351
|
-
} else if (Array.isArray(cr) && cr.some((v) => v > 0)) {
|
|
352
|
-
lines.push(` border-radius: ${cr.map((v) => u(v)).join(" ")};`);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Opacity
|
|
356
|
-
if (el.appearance.opacity < 1) {
|
|
357
|
-
lines.push(` opacity: ${el.appearance.opacity};`);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Typography
|
|
361
|
-
if (el.typography) {
|
|
362
|
-
const t = el.typography;
|
|
363
|
-
lines.push(` font-family: '${t.fontFamily}', sans-serif;`);
|
|
364
|
-
lines.push(` font-size: ${u(t.fontSize)};`);
|
|
365
|
-
lines.push(` font-weight: ${t.fontWeight};`);
|
|
366
|
-
if (typeof t.lineHeight === "number") {
|
|
367
|
-
lines.push(` line-height: ${u(t.lineHeight)};`);
|
|
368
|
-
} else if (t.lineHeight !== "auto") {
|
|
369
|
-
lines.push(` line-height: ${t.lineHeight};`);
|
|
370
|
-
}
|
|
371
|
-
if (t.letterSpacing) {
|
|
372
|
-
lines.push(` letter-spacing: ${u(t.letterSpacing)};`);
|
|
373
|
-
}
|
|
374
|
-
lines.push(` text-align: ${t.textAlign.toLowerCase()};`);
|
|
375
|
-
|
|
376
|
-
// Text color from fills
|
|
377
|
-
if (el.appearance.fills.length > 0) {
|
|
378
|
-
const textFill = el.appearance.fills[0];
|
|
379
|
-
if (textFill.tokenName) {
|
|
380
|
-
lines.push(` color: var(--${textFill.tokenName.replace(/\//g, "-").toLowerCase()});`);
|
|
381
|
-
} else {
|
|
382
|
-
lines.push(` color: ${textFill.hex};`);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Effects
|
|
388
|
-
for (const effect of el.appearance.effects) {
|
|
389
|
-
if (effect.type === "DROP_SHADOW") {
|
|
390
|
-
lines.push(` box-shadow: ${effect.description};`);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
lines.push(`}`);
|
|
395
|
-
return lines.join("\n");
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// ─── Markdown renderer ─────────────────────────────────────────────────────
|
|
399
|
-
|
|
400
|
-
function renderMarkdown(
|
|
401
|
-
rootName: string,
|
|
402
|
-
rootBounds: { width: number; height: number },
|
|
403
|
-
elements: MeasuredElement[],
|
|
404
|
-
redlines: RedlineAnnotation[],
|
|
405
|
-
assets: AssetEntry[],
|
|
406
|
-
args: HandoffSpecArgs
|
|
407
|
-
): string {
|
|
408
|
-
const lines: string[] = [];
|
|
409
|
-
|
|
410
|
-
lines.push(`# Developer Handoff: ${rootName}`);
|
|
411
|
-
lines.push(`> Auto-generated by \`figma_handoff_spec\``);
|
|
412
|
-
lines.push(``);
|
|
413
|
-
lines.push(`## Overview`);
|
|
414
|
-
lines.push(`| Property | Value |`);
|
|
415
|
-
lines.push(`|----------|-------|`);
|
|
416
|
-
lines.push(`| **Frame** | ${rootName} |`);
|
|
417
|
-
lines.push(`| **Size** | ${rootBounds.width} × ${rootBounds.height}px |`);
|
|
418
|
-
lines.push(`| **Elements** | ${elements.length} |`);
|
|
419
|
-
lines.push(`| **Tokens Used** | ${elements.reduce((sum, el) => sum + el.tokens.length, 0)} |`);
|
|
420
|
-
lines.push(``);
|
|
421
|
-
|
|
422
|
-
// Token map
|
|
423
|
-
const allTokens = elements.flatMap((el) => el.tokens);
|
|
424
|
-
if (allTokens.length > 0) {
|
|
425
|
-
lines.push(`## Design Tokens`);
|
|
426
|
-
lines.push(`| Token | Property | Raw Value |`);
|
|
427
|
-
lines.push(`|-------|----------|-----------|`);
|
|
428
|
-
const seen = new Set<string>();
|
|
429
|
-
for (const t of allTokens) {
|
|
430
|
-
const key = `${t.tokenName}:${t.property}`;
|
|
431
|
-
if (seen.has(key)) continue;
|
|
432
|
-
seen.add(key);
|
|
433
|
-
lines.push(`| \`${t.tokenName}\` | ${t.property} | \`${t.rawValue}\` |`);
|
|
434
|
-
}
|
|
435
|
-
lines.push(``);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// Measurements
|
|
439
|
-
lines.push(`## Measurements`);
|
|
440
|
-
lines.push(``);
|
|
441
|
-
for (const el of elements) {
|
|
442
|
-
if (el.depth > 3) continue; // Skip deeply nested for readability
|
|
443
|
-
const indent = " ".repeat(el.depth);
|
|
444
|
-
lines.push(`${indent}### ${el.name} (\`${el.type}\`)`);
|
|
445
|
-
lines.push(`${indent}| Metric | Value |`);
|
|
446
|
-
lines.push(`${indent}|--------|-------|`);
|
|
447
|
-
lines.push(`${indent}| Size | ${el.bounds.width} × ${el.bounds.height}px |`);
|
|
448
|
-
lines.push(`${indent}| Position | (${el.bounds.x}, ${el.bounds.y}) |`);
|
|
449
|
-
|
|
450
|
-
if (el.spacing.layoutMode !== "NONE") {
|
|
451
|
-
lines.push(`${indent}| Layout | ${el.spacing.layoutMode === "HORIZONTAL" ? "Row" : "Column"} |`);
|
|
452
|
-
lines.push(`${indent}| Gap | ${el.spacing.itemSpacing}px |`);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
const { paddingTop: pt, paddingRight: pr, paddingBottom: pb, paddingLeft: pl } = el.spacing;
|
|
456
|
-
if (pt || pr || pb || pl) {
|
|
457
|
-
lines.push(`${indent}| Padding | ${pt} / ${pr} / ${pb} / ${pl} |`);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
if (el.appearance.cornerRadius) {
|
|
461
|
-
const cr = el.appearance.cornerRadius;
|
|
462
|
-
const crStr = typeof cr === "number" ? `${cr}px` : `${cr.join(" / ")}px`;
|
|
463
|
-
if (crStr !== "0px" && crStr !== "0 / 0 / 0 / 0px") {
|
|
464
|
-
lines.push(`${indent}| Border Radius | ${crStr} |`);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if (el.typography) {
|
|
469
|
-
const t = el.typography;
|
|
470
|
-
lines.push(`${indent}| Font | ${t.fontFamily} ${t.fontWeight} |`);
|
|
471
|
-
lines.push(`${indent}| Font Size | ${t.fontSize}px |`);
|
|
472
|
-
lines.push(`${indent}| Line Height | ${t.lineHeight} |`);
|
|
473
|
-
if (t.letterSpacing) lines.push(`${indent}| Letter Spacing | ${t.letterSpacing}px |`);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
lines.push(``);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Redlines
|
|
480
|
-
if (redlines.length > 0) {
|
|
481
|
-
lines.push(`## Spacing Redlines`);
|
|
482
|
-
lines.push(`| From | To | Direction | Distance |`);
|
|
483
|
-
lines.push(`|------|----|-----------|----------|`);
|
|
484
|
-
for (const r of redlines) {
|
|
485
|
-
lines.push(`| ${r.fromElement} | ${r.toElement} | ${r.direction} | ${r.distance}px |`);
|
|
486
|
-
}
|
|
487
|
-
lines.push(``);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// Assets
|
|
491
|
-
if (assets.length > 0 && args.includeAssets !== false) {
|
|
492
|
-
lines.push(`## Assets to Export`);
|
|
493
|
-
lines.push(`| Name | Type | Size | Format |`);
|
|
494
|
-
lines.push(`|------|------|------|--------|`);
|
|
495
|
-
for (const a of assets) {
|
|
496
|
-
lines.push(`| ${a.name} | ${a.type} | ${a.size.width}×${a.size.height} | ${a.suggestedExport} |`);
|
|
497
|
-
}
|
|
498
|
-
lines.push(``);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// CSS snippets
|
|
502
|
-
if (args.includeCss !== false) {
|
|
503
|
-
lines.push(`## CSS Snippets`);
|
|
504
|
-
lines.push(``);
|
|
505
|
-
for (const el of elements) {
|
|
506
|
-
if (el.depth > 2) continue;
|
|
507
|
-
lines.push("```css");
|
|
508
|
-
lines.push(el.cssSnippet);
|
|
509
|
-
lines.push("```");
|
|
510
|
-
lines.push(``);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
return lines.join("\n");
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// ─── Figma page renderer ───────────────────────────────────────────────────
|
|
518
|
-
|
|
519
|
-
async function createHandoffPage(
|
|
520
|
-
nodeId: string,
|
|
521
|
-
rootName: string,
|
|
522
|
-
elements: MeasuredElement[],
|
|
523
|
-
redlines: RedlineAnnotation[]
|
|
524
|
-
): Promise<string> {
|
|
525
|
-
const bridge = await getBridge();
|
|
526
|
-
|
|
527
|
-
const result = await bridge.execute(`
|
|
528
|
-
(async () => {
|
|
529
|
-
// Create handoff annotation page
|
|
530
|
-
var pageName = '📐 Handoff: ' + '${rootName.replace(/'/g, "\\'")}';
|
|
531
|
-
var existing = figma.root.children.find(function(p) { return p.name === pageName; });
|
|
532
|
-
if (existing) existing.remove();
|
|
533
|
-
|
|
534
|
-
var page = figma.createPage();
|
|
535
|
-
page.name = pageName;
|
|
536
|
-
figma.currentPage = page;
|
|
537
|
-
|
|
538
|
-
// Title
|
|
539
|
-
var title = figma.createText();
|
|
540
|
-
await figma.loadFontAsync({ family: "Inter", style: "Bold" });
|
|
541
|
-
await figma.loadFontAsync({ family: "Inter", style: "Regular" });
|
|
542
|
-
await figma.loadFontAsync({ family: "Inter", style: "Medium" });
|
|
543
|
-
title.fontName = { family: "Inter", style: "Bold" };
|
|
544
|
-
title.fontSize = 32;
|
|
545
|
-
title.characters = 'Developer Handoff: ${rootName.replace(/'/g, "\\'")}';
|
|
546
|
-
title.x = 40;
|
|
547
|
-
title.y = 40;
|
|
548
|
-
page.appendChild(title);
|
|
549
|
-
|
|
550
|
-
// Subtitle
|
|
551
|
-
var sub = figma.createText();
|
|
552
|
-
sub.fontName = { family: "Inter", style: "Regular" };
|
|
553
|
-
sub.fontSize = 14;
|
|
554
|
-
sub.characters = 'Auto-generated by figma_handoff_spec | ${new Date().toISOString().slice(0, 10)}';
|
|
555
|
-
sub.x = 40;
|
|
556
|
-
sub.y = 90;
|
|
557
|
-
sub.fills = [{ type: 'SOLID', color: { r: 0.4, g: 0.4, b: 0.4 } }];
|
|
558
|
-
page.appendChild(sub);
|
|
559
|
-
|
|
560
|
-
// Clone the source node for reference
|
|
561
|
-
var sourceNode = figma.getNodeById('${nodeId}');
|
|
562
|
-
if (sourceNode) {
|
|
563
|
-
var clone = sourceNode.clone();
|
|
564
|
-
clone.x = 40;
|
|
565
|
-
clone.y = 140;
|
|
566
|
-
page.appendChild(clone);
|
|
567
|
-
|
|
568
|
-
// Add measurement annotations as red lines
|
|
569
|
-
var yOffset = 140 + Math.round(sourceNode.height) + 60;
|
|
570
|
-
|
|
571
|
-
${JSON.stringify(redlines.slice(0, 50))}.forEach(function(r, i) {
|
|
572
|
-
var annotation = figma.createFrame();
|
|
573
|
-
annotation.name = 'Redline: ' + r.label;
|
|
574
|
-
annotation.resize(400, 28);
|
|
575
|
-
annotation.x = 40;
|
|
576
|
-
annotation.y = yOffset + (i * 36);
|
|
577
|
-
annotation.layoutMode = 'HORIZONTAL';
|
|
578
|
-
annotation.itemSpacing = 8;
|
|
579
|
-
annotation.paddingLeft = 8;
|
|
580
|
-
annotation.paddingRight = 8;
|
|
581
|
-
annotation.paddingTop = 4;
|
|
582
|
-
annotation.paddingBottom = 4;
|
|
583
|
-
annotation.fills = [{ type: 'SOLID', color: { r: 1, g: 0.9, b: 0.9 } }];
|
|
584
|
-
annotation.cornerRadius = 4;
|
|
585
|
-
annotation.primaryAxisSizingMode = 'AUTO';
|
|
586
|
-
annotation.counterAxisSizingMode = 'AUTO';
|
|
587
|
-
|
|
588
|
-
var label = figma.createText();
|
|
589
|
-
label.fontName = { family: "Inter", style: "Medium" };
|
|
590
|
-
label.fontSize = 12;
|
|
591
|
-
label.characters = r.fromElement + ' → ' + r.toElement + ': ' + r.label;
|
|
592
|
-
label.fills = [{ type: 'SOLID', color: { r: 0.8, g: 0, b: 0 } }];
|
|
593
|
-
annotation.appendChild(label);
|
|
594
|
-
|
|
595
|
-
page.appendChild(annotation);
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
// Token summary section
|
|
599
|
-
var tokenY = yOffset + (${Math.min(redlines.length, 50)} * 36) + 40;
|
|
600
|
-
var tokenTitle = figma.createText();
|
|
601
|
-
tokenTitle.fontName = { family: "Inter", style: "Bold" };
|
|
602
|
-
tokenTitle.fontSize = 20;
|
|
603
|
-
tokenTitle.characters = 'Token Reference';
|
|
604
|
-
tokenTitle.x = 40;
|
|
605
|
-
tokenTitle.y = tokenY;
|
|
606
|
-
page.appendChild(tokenTitle);
|
|
607
|
-
|
|
608
|
-
// Token entries
|
|
609
|
-
var tokenEntries = ${JSON.stringify(
|
|
610
|
-
elements.flatMap((el) => el.tokens).filter((t, i, arr) =>
|
|
611
|
-
arr.findIndex((o) => o.tokenName === t.tokenName) === i
|
|
612
|
-
).slice(0, 40)
|
|
613
|
-
)};
|
|
614
|
-
|
|
615
|
-
tokenEntries.forEach(function(t, i) {
|
|
616
|
-
var entry = figma.createText();
|
|
617
|
-
entry.fontName = { family: "Inter", style: "Regular" };
|
|
618
|
-
entry.fontSize = 12;
|
|
619
|
-
entry.characters = t.property + ' → ' + t.tokenName + ' = ' + t.rawValue;
|
|
620
|
-
entry.x = 60;
|
|
621
|
-
entry.y = tokenY + 36 + (i * 20);
|
|
622
|
-
entry.fills = [{ type: 'SOLID', color: { r: 0.2, g: 0.2, b: 0.2 } }];
|
|
623
|
-
page.appendChild(entry);
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
return { pageId: page.id, pageName: page.name };
|
|
628
|
-
})();
|
|
629
|
-
`);
|
|
630
|
-
|
|
631
|
-
if (!result.success || !result.result) {
|
|
632
|
-
throw new Error(result.error || "Failed to create handoff page");
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
return (result.result as { pageId: string }).pageId;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
// ─── Main handler ──────────────────────────────────────────────────────────
|
|
639
|
-
|
|
640
|
-
export async function handoffSpecHandler(args: HandoffSpecArgs): Promise<unknown> {
|
|
641
|
-
const maxDepth = args.maxDepth ?? 6;
|
|
642
|
-
const cssUnit = args.cssUnit ?? "px";
|
|
643
|
-
const remBase = args.remBase ?? 16;
|
|
644
|
-
|
|
645
|
-
const { elements, assets, redlines, rootName, rootBounds } = await extractNodeTree(
|
|
646
|
-
args.nodeId,
|
|
647
|
-
maxDepth
|
|
648
|
-
);
|
|
649
|
-
|
|
650
|
-
// Generate CSS snippets for each element
|
|
651
|
-
for (const el of elements) {
|
|
652
|
-
el.cssSnippet = generateElementCss(el, cssUnit, remBase);
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
const outputs: Record<string, unknown> = {};
|
|
656
|
-
|
|
657
|
-
// JSON
|
|
658
|
-
if (args.outputFormat === "json" || args.outputFormat === "all") {
|
|
659
|
-
outputs.spec = {
|
|
660
|
-
component: rootName,
|
|
661
|
-
dimensions: rootBounds,
|
|
662
|
-
elements: elements.map((el) => ({
|
|
663
|
-
name: el.name,
|
|
664
|
-
type: el.type,
|
|
665
|
-
depth: el.depth,
|
|
666
|
-
bounds: el.bounds,
|
|
667
|
-
spacing: el.spacing,
|
|
668
|
-
tokens: el.tokens,
|
|
669
|
-
typography: el.typography,
|
|
670
|
-
css: el.cssSnippet,
|
|
671
|
-
})),
|
|
672
|
-
redlines,
|
|
673
|
-
assets,
|
|
674
|
-
tokenSummary: {
|
|
675
|
-
total: elements.reduce((sum, el) => sum + el.tokens.length, 0),
|
|
676
|
-
unique: [...new Set(elements.flatMap((el) => el.tokens.map((t) => t.tokenName)))],
|
|
677
|
-
},
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// Markdown
|
|
682
|
-
if (args.outputFormat === "markdown" || args.outputFormat === "all") {
|
|
683
|
-
outputs.markdown = renderMarkdown(rootName, rootBounds, elements, redlines, assets, args);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// Figma page
|
|
687
|
-
let figmaPageId: string | undefined;
|
|
688
|
-
if (args.outputFormat === "figma-page" || args.outputFormat === "all") {
|
|
689
|
-
figmaPageId = await createHandoffPage(args.nodeId, rootName, elements, redlines);
|
|
690
|
-
outputs.figmaPageId = figmaPageId;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
return {
|
|
694
|
-
component: rootName,
|
|
695
|
-
dimensions: rootBounds,
|
|
696
|
-
elementCount: elements.length,
|
|
697
|
-
tokenCount: elements.reduce((sum, el) => sum + el.tokens.length, 0),
|
|
698
|
-
assetCount: assets.length,
|
|
699
|
-
redlineCount: redlines.length,
|
|
700
|
-
...outputs,
|
|
701
|
-
};
|
|
702
|
-
}
|