@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
package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts
DELETED
|
@@ -1,660 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// Component Archaeologist
|
|
3
|
-
// Reverse-engineers an arbitrary Figma node into a named component pattern.
|
|
4
|
-
// Fingerprints the layer tree, snaps hardcoded values to design tokens, and
|
|
5
|
-
// optionally promotes the node to a library component with variable bindings.
|
|
6
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
-
|
|
8
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
9
|
-
import { decisionLog } from "../../../shared/decision-log.js";
|
|
10
|
-
import {
|
|
11
|
-
snapToColorToken,
|
|
12
|
-
snapToSpacingToken,
|
|
13
|
-
figmaRgbaToHex,
|
|
14
|
-
} from "../../../shared/token-utils.js";
|
|
15
|
-
import { resolveTokenId } from "../../../shared/token-binder.js";
|
|
16
|
-
import { getConceptForComponent, getAllTokenPaths } from "../../../shared/concept-taxonomy.js";
|
|
17
|
-
import { FigmaNode, Token, TokenRef } from "../../../shared/types.js";
|
|
18
|
-
|
|
19
|
-
// ─── Public types ─────────────────────────────────────────────────────────────
|
|
20
|
-
|
|
21
|
-
export interface ComponentArchaeologistArgs {
|
|
22
|
-
nodeId: string;
|
|
23
|
-
outputAs: "analysis" | "component" | "both";
|
|
24
|
-
bindToExisting?: boolean;
|
|
25
|
-
createLibraryComponent?: boolean;
|
|
26
|
-
generateDocStub?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface PatternMatch {
|
|
30
|
-
pattern: string;
|
|
31
|
-
candidates: string[];
|
|
32
|
-
confidence: number;
|
|
33
|
-
rationale: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface TokenMapping {
|
|
37
|
-
property: string;
|
|
38
|
-
hardcodedValue: string;
|
|
39
|
-
suggestedToken: string;
|
|
40
|
-
tokenValue: string | number;
|
|
41
|
-
delta: number | undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface ComponentArchaeologistResult {
|
|
45
|
-
nodeId: string;
|
|
46
|
-
nodeName: string;
|
|
47
|
-
patternMatches: PatternMatch[];
|
|
48
|
-
bestMatch: string;
|
|
49
|
-
/** Concept from the taxonomy (e.g. "action", "surface", "field") */
|
|
50
|
-
concept: string | null;
|
|
51
|
-
/** Expected token paths for this concept from the taxonomy */
|
|
52
|
-
expectedTokens: string[];
|
|
53
|
-
tokenMappings: TokenMapping[];
|
|
54
|
-
promotedComponentId: string | null;
|
|
55
|
-
docStub: string | null;
|
|
56
|
-
layerSummary: LayerSummary;
|
|
57
|
-
logEntryId: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface LayerSummary {
|
|
61
|
-
totalLayers: number;
|
|
62
|
-
depth: number;
|
|
63
|
-
hasImage: boolean;
|
|
64
|
-
hasIcon: boolean;
|
|
65
|
-
hasText: boolean;
|
|
66
|
-
hasInput: boolean;
|
|
67
|
-
hasAvatar: boolean;
|
|
68
|
-
textCount: number;
|
|
69
|
-
rectangleCount: number;
|
|
70
|
-
frameCount: number;
|
|
71
|
-
vectorCount: number;
|
|
72
|
-
layoutMode: "HORIZONTAL" | "VERTICAL" | "NONE" | undefined;
|
|
73
|
-
childCount: number;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ─── Layer fingerprinting ─────────────────────────────────────────────────────
|
|
77
|
-
|
|
78
|
-
type LayerSignal =
|
|
79
|
-
| "icon"
|
|
80
|
-
| "text"
|
|
81
|
-
| "image"
|
|
82
|
-
| "input"
|
|
83
|
-
| "avatar"
|
|
84
|
-
| "chevron"
|
|
85
|
-
| "cta"
|
|
86
|
-
| "title"
|
|
87
|
-
| "body"
|
|
88
|
-
| "label"
|
|
89
|
-
| "subtitle";
|
|
90
|
-
|
|
91
|
-
function inferSignal(node: FigmaNode): LayerSignal[] {
|
|
92
|
-
const signals: LayerSignal[] = [];
|
|
93
|
-
const nameLower = node.name.toLowerCase();
|
|
94
|
-
|
|
95
|
-
if (node.type === "TEXT") {
|
|
96
|
-
signals.push("text");
|
|
97
|
-
if (/heading|title|h[1-6]/.test(nameLower)) signals.push("title");
|
|
98
|
-
if (/body|paragraph|description|content/.test(nameLower)) signals.push("body");
|
|
99
|
-
if (/label|caption|eyebrow|overline/.test(nameLower)) signals.push("label");
|
|
100
|
-
if (/subtitle|secondary|sub/.test(nameLower)) signals.push("subtitle");
|
|
101
|
-
if (/button|cta|action|submit|primary/.test(nameLower)) signals.push("cta");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (node.type === "VECTOR" || /icon|ico|glyph|symbol/.test(nameLower)) {
|
|
105
|
-
signals.push("icon");
|
|
106
|
-
if (/chevron|arrow|caret/.test(nameLower)) signals.push("chevron");
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (node.fills?.some((f) => f.type === "IMAGE")) {
|
|
110
|
-
signals.push("image");
|
|
111
|
-
if (/avatar|profile|photo|user|face/.test(nameLower)) signals.push("avatar");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (/input|field|textfield|text-field|textarea/.test(nameLower)) {
|
|
115
|
-
signals.push("input");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return signals;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function collectSignals(node: FigmaNode, depth = 0): LayerSignal[] {
|
|
122
|
-
const signals = inferSignal(node);
|
|
123
|
-
if (depth < 6 && node.children) {
|
|
124
|
-
for (const child of node.children) {
|
|
125
|
-
signals.push(...collectSignals(child, depth + 1));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return signals;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function countLayerTypes(node: FigmaNode): LayerSummary {
|
|
132
|
-
let totalLayers = 0;
|
|
133
|
-
let maxDepth = 0;
|
|
134
|
-
let hasImage = false;
|
|
135
|
-
let hasIcon = false;
|
|
136
|
-
let hasText = false;
|
|
137
|
-
let hasInput = false;
|
|
138
|
-
let hasAvatar = false;
|
|
139
|
-
let textCount = 0;
|
|
140
|
-
let rectangleCount = 0;
|
|
141
|
-
let frameCount = 0;
|
|
142
|
-
let vectorCount = 0;
|
|
143
|
-
|
|
144
|
-
function walk(n: FigmaNode, depth: number) {
|
|
145
|
-
totalLayers++;
|
|
146
|
-
if (depth > maxDepth) maxDepth = depth;
|
|
147
|
-
const nameLower = n.name.toLowerCase();
|
|
148
|
-
|
|
149
|
-
if (n.type === "TEXT") {
|
|
150
|
-
hasText = true;
|
|
151
|
-
textCount++;
|
|
152
|
-
}
|
|
153
|
-
if (n.type === "RECTANGLE") rectangleCount++;
|
|
154
|
-
if (n.type === "FRAME" || n.type === "GROUP") frameCount++;
|
|
155
|
-
if (n.type === "VECTOR" || /icon/.test(nameLower)) {
|
|
156
|
-
hasIcon = true;
|
|
157
|
-
vectorCount++;
|
|
158
|
-
}
|
|
159
|
-
if (n.fills?.some((f) => f.type === "IMAGE")) {
|
|
160
|
-
hasImage = true;
|
|
161
|
-
if (/avatar|profile/.test(nameLower)) hasAvatar = true;
|
|
162
|
-
}
|
|
163
|
-
if (/input|field/.test(nameLower)) hasInput = true;
|
|
164
|
-
|
|
165
|
-
if (n.children) {
|
|
166
|
-
for (const child of n.children) walk(child, depth + 1);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
walk(node, 0);
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
totalLayers,
|
|
174
|
-
depth: maxDepth,
|
|
175
|
-
hasImage,
|
|
176
|
-
hasIcon,
|
|
177
|
-
hasText,
|
|
178
|
-
hasInput,
|
|
179
|
-
hasAvatar,
|
|
180
|
-
textCount,
|
|
181
|
-
rectangleCount,
|
|
182
|
-
frameCount,
|
|
183
|
-
vectorCount,
|
|
184
|
-
layoutMode: node.layoutMode,
|
|
185
|
-
childCount: node.children?.length ?? 0,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ─── Pattern matching ─────────────────────────────────────────────────────────
|
|
190
|
-
|
|
191
|
-
interface PatternRule {
|
|
192
|
-
pattern: string;
|
|
193
|
-
candidates: string[];
|
|
194
|
-
test: (signals: LayerSignal[], summary: LayerSummary) => boolean;
|
|
195
|
-
confidence: (signals: LayerSignal[], summary: LayerSummary) => number;
|
|
196
|
-
rationale: (signals: LayerSignal[], summary: LayerSummary) => string;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const PATTERN_RULES: PatternRule[] = [
|
|
200
|
-
{
|
|
201
|
-
pattern: "Icon + Text (horizontal)",
|
|
202
|
-
candidates: ["Button", "MenuItem", "Breadcrumb", "Tab"],
|
|
203
|
-
test: (s, summary) =>
|
|
204
|
-
s.includes("icon") &&
|
|
205
|
-
s.includes("text") &&
|
|
206
|
-
summary.layoutMode === "HORIZONTAL" &&
|
|
207
|
-
!s.includes("chevron"),
|
|
208
|
-
confidence: (s) => (s.includes("cta") ? 0.92 : 0.78),
|
|
209
|
-
rationale: (s) =>
|
|
210
|
-
`Horizontal auto-layout with icon + text signal. ${s.includes("cta") ? "CTA text found — likely Button." : "No CTA signal — could be MenuItem or Tab."}`,
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
pattern: "Image + Title + Body + CTA",
|
|
214
|
-
candidates: ["Card", "FeatureTile"],
|
|
215
|
-
test: (s) =>
|
|
216
|
-
s.includes("image") &&
|
|
217
|
-
s.includes("title") &&
|
|
218
|
-
s.includes("body") &&
|
|
219
|
-
s.includes("cta"),
|
|
220
|
-
confidence: () => 0.89,
|
|
221
|
-
rationale: () =>
|
|
222
|
-
"Classic card anatomy: image hero, title heading, body copy, and a call-to-action.",
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
pattern: "Label above + Input below",
|
|
226
|
-
candidates: ["FormField", "TextInput"],
|
|
227
|
-
test: (s) => s.includes("label") && s.includes("input"),
|
|
228
|
-
confidence: () => 0.91,
|
|
229
|
-
rationale: () =>
|
|
230
|
-
"Label node above an input container — canonical form field pattern.",
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
pattern: "Avatar + Name + Subtitle",
|
|
234
|
-
candidates: ["UserProfile", "CommentHeader"],
|
|
235
|
-
test: (s) => s.includes("avatar") && s.includes("text") && s.includes("subtitle"),
|
|
236
|
-
confidence: (s) => (s.includes("subtitle") ? 0.88 : 0.72),
|
|
237
|
-
rationale: (s) =>
|
|
238
|
-
`Avatar image with ${s.includes("subtitle") ? "name and subtitle text layers" : "name text layer"} — user identity pattern.`,
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
pattern: "Icon + Title + Chevron",
|
|
242
|
-
candidates: ["ListItem", "NavigationRow"],
|
|
243
|
-
test: (s) => s.includes("icon") && s.includes("title") && s.includes("chevron"),
|
|
244
|
-
confidence: () => 0.9,
|
|
245
|
-
rationale: () =>
|
|
246
|
-
"Leading icon, title text, and trailing chevron — list item or navigation row.",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
pattern: "N equal-width columns",
|
|
250
|
-
candidates: ["DataTable", "ComparisonCard"],
|
|
251
|
-
test: (_, summary) =>
|
|
252
|
-
summary.layoutMode === "HORIZONTAL" &&
|
|
253
|
-
summary.childCount >= 3 &&
|
|
254
|
-
summary.textCount >= 3,
|
|
255
|
-
confidence: (_, summary) => (summary.childCount >= 4 ? 0.82 : 0.68),
|
|
256
|
-
rationale: (_, summary) =>
|
|
257
|
-
`${summary.childCount} equal-width children in horizontal layout — data table or comparison grid.`,
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
pattern: "Image + Title",
|
|
261
|
-
candidates: ["Card", "MediaCard", "ThumbnailItem"],
|
|
262
|
-
test: (s) => s.includes("image") && s.includes("title") && !s.includes("body"),
|
|
263
|
-
confidence: () => 0.74,
|
|
264
|
-
rationale: () =>
|
|
265
|
-
"Image with title but no body copy — compact media card or thumbnail.",
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
pattern: "Text only",
|
|
269
|
-
candidates: ["Heading", "Paragraph", "Badge", "Label"],
|
|
270
|
-
test: (s, summary) =>
|
|
271
|
-
s.includes("text") &&
|
|
272
|
-
!s.includes("icon") &&
|
|
273
|
-
!s.includes("image") &&
|
|
274
|
-
summary.textCount <= 2,
|
|
275
|
-
confidence: () => 0.6,
|
|
276
|
-
rationale: () =>
|
|
277
|
-
"Text-only node — standalone heading, label, badge, or paragraph.",
|
|
278
|
-
},
|
|
279
|
-
];
|
|
280
|
-
|
|
281
|
-
function fingerprintPatterns(
|
|
282
|
-
signals: LayerSignal[],
|
|
283
|
-
summary: LayerSummary
|
|
284
|
-
): PatternMatch[] {
|
|
285
|
-
const matches: PatternMatch[] = [];
|
|
286
|
-
|
|
287
|
-
for (const rule of PATTERN_RULES) {
|
|
288
|
-
if (rule.test(signals, summary)) {
|
|
289
|
-
matches.push({
|
|
290
|
-
pattern: rule.pattern,
|
|
291
|
-
candidates: rule.candidates,
|
|
292
|
-
confidence: rule.confidence(signals, summary),
|
|
293
|
-
rationale: rule.rationale(signals, summary),
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// Sort descending by confidence
|
|
299
|
-
matches.sort((a, b) => b.confidence - a.confidence);
|
|
300
|
-
return matches;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ─── Token mapping ────────────────────────────────────────────────────────────
|
|
304
|
-
|
|
305
|
-
function extractTokenMappings(node: FigmaNode, tokens: Token[]): TokenMapping[] {
|
|
306
|
-
const mappings: TokenMapping[] = [];
|
|
307
|
-
|
|
308
|
-
function walkFills(n: FigmaNode, propertyPath: string) {
|
|
309
|
-
if (n.fills) {
|
|
310
|
-
for (let i = 0; i < n.fills.length; i++) {
|
|
311
|
-
const fill = n.fills[i];
|
|
312
|
-
if (fill.type === "SOLID" && fill.color && !fill.variableId) {
|
|
313
|
-
const hex = figmaRgbaToHex(fill.color.r, fill.color.g, fill.color.b);
|
|
314
|
-
const ref: TokenRef = snapToColorToken(hex, tokens);
|
|
315
|
-
mappings.push({
|
|
316
|
-
property: `${propertyPath}.fills[${i}]`,
|
|
317
|
-
hardcodedValue: hex,
|
|
318
|
-
suggestedToken: ref.tokenName,
|
|
319
|
-
tokenValue: ref.tokenValue,
|
|
320
|
-
delta: typeof ref.delta === "number" ? ref.delta : undefined,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (n.strokes) {
|
|
327
|
-
for (let i = 0; i < n.strokes.length; i++) {
|
|
328
|
-
const stroke = n.strokes[i];
|
|
329
|
-
if (stroke.type === "SOLID" && stroke.color && !stroke.variableId) {
|
|
330
|
-
const hex = figmaRgbaToHex(stroke.color.r, stroke.color.g, stroke.color.b);
|
|
331
|
-
const ref: TokenRef = snapToColorToken(hex, tokens);
|
|
332
|
-
mappings.push({
|
|
333
|
-
property: `${propertyPath}.strokes[${i}]`,
|
|
334
|
-
hardcodedValue: hex,
|
|
335
|
-
suggestedToken: ref.tokenName,
|
|
336
|
-
tokenValue: ref.tokenValue,
|
|
337
|
-
delta: typeof ref.delta === "number" ? ref.delta : undefined,
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// Spacing
|
|
344
|
-
const spacingProps: Array<keyof FigmaNode> = [
|
|
345
|
-
"paddingLeft",
|
|
346
|
-
"paddingRight",
|
|
347
|
-
"paddingTop",
|
|
348
|
-
"paddingBottom",
|
|
349
|
-
"itemSpacing",
|
|
350
|
-
];
|
|
351
|
-
for (const prop of spacingProps) {
|
|
352
|
-
const val = n[prop];
|
|
353
|
-
if (typeof val === "number" && val > 0) {
|
|
354
|
-
const ref = snapToSpacingToken(val);
|
|
355
|
-
if (ref.delta !== 0) {
|
|
356
|
-
mappings.push({
|
|
357
|
-
property: `${propertyPath}.${prop}`,
|
|
358
|
-
hardcodedValue: `${val}px`,
|
|
359
|
-
suggestedToken: ref.tokenName,
|
|
360
|
-
tokenValue: ref.tokenValue,
|
|
361
|
-
delta: ref.delta,
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (n.children) {
|
|
368
|
-
for (const child of n.children) {
|
|
369
|
-
walkFills(child, `${propertyPath}/${child.name}`);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
walkFills(node, node.name);
|
|
375
|
-
return mappings;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// ─── Figma script: promote to component + bind variables ─────────────────────
|
|
379
|
-
|
|
380
|
-
function buildPromoteScript(
|
|
381
|
-
nodeId: string,
|
|
382
|
-
componentName: string,
|
|
383
|
-
mappings: TokenMapping[],
|
|
384
|
-
tokens: Token[]
|
|
385
|
-
): string {
|
|
386
|
-
// Resolve actual variable IDs for fill/stroke bindings
|
|
387
|
-
const resolvedBindings = mappings
|
|
388
|
-
.filter((m) => m.property.includes("fills") || m.property.includes("strokes"))
|
|
389
|
-
.slice(0, 20)
|
|
390
|
-
.map((m) => {
|
|
391
|
-
const variableId = resolveTokenId(m.suggestedToken, tokens);
|
|
392
|
-
return { ...m, variableId };
|
|
393
|
-
})
|
|
394
|
-
.filter((m) => m.variableId !== null);
|
|
395
|
-
|
|
396
|
-
// Generate actual setBoundVariable calls for resolved tokens
|
|
397
|
-
const bindingLines = resolvedBindings.length > 0
|
|
398
|
-
? `
|
|
399
|
-
// Bind resolved design-system variables
|
|
400
|
-
const bindNode = async (n) => {
|
|
401
|
-
if (n.fills) {
|
|
402
|
-
for (let i = 0; i < n.fills.length; i++) {
|
|
403
|
-
if (n.fills[i].type === 'SOLID' && !n.fills[i].boundVariables?.color) {
|
|
404
|
-
const hex = (() => {
|
|
405
|
-
const c = n.fills[i].color;
|
|
406
|
-
const toHex = (v) => Math.round(v * 255).toString(16).padStart(2, '0');
|
|
407
|
-
return '#' + toHex(c.r) + toHex(c.g) + toHex(c.b);
|
|
408
|
-
})();
|
|
409
|
-
const mapping = ${JSON.stringify(resolvedBindings.map((m) => ({
|
|
410
|
-
hex: m.hardcodedValue.toLowerCase(),
|
|
411
|
-
variableId: m.variableId,
|
|
412
|
-
})))};
|
|
413
|
-
const match = mapping.find(m => m.hex === hex.toLowerCase());
|
|
414
|
-
if (match) {
|
|
415
|
-
const v = await figma.variables.getVariableByIdAsync(match.variableId);
|
|
416
|
-
if (v) {
|
|
417
|
-
const paints = [...n.fills];
|
|
418
|
-
paints[i] = figma.variables.setBoundVariableForPaint(paints[i], 'color', v);
|
|
419
|
-
n.fills = paints;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
if (n.children) {
|
|
426
|
-
for (const child of n.children) await bindNode(child);
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
await bindNode(component);`
|
|
430
|
-
: mappings
|
|
431
|
-
.filter((m) => m.property.includes("fills"))
|
|
432
|
-
.slice(0, 20)
|
|
433
|
-
.map((m) => ` /* bind ${m.property} → ${m.suggestedToken} (${m.hardcodedValue}) — no matching variable found */`)
|
|
434
|
-
.join("\n");
|
|
435
|
-
|
|
436
|
-
return `
|
|
437
|
-
(async () => {
|
|
438
|
-
const node = await figma.getNodeByIdAsync(${JSON.stringify(nodeId)});
|
|
439
|
-
if (!node) throw new Error('Node not found: ${nodeId}');
|
|
440
|
-
|
|
441
|
-
// Clone to preserve original, then promote clone
|
|
442
|
-
const clone = node.clone();
|
|
443
|
-
clone.name = ${JSON.stringify(componentName)};
|
|
444
|
-
node.parent.appendChild(clone);
|
|
445
|
-
|
|
446
|
-
// Promote to main component if not already
|
|
447
|
-
let component;
|
|
448
|
-
if (clone.type === 'COMPONENT') {
|
|
449
|
-
component = clone;
|
|
450
|
-
} else if (typeof clone.createComponent === 'function') {
|
|
451
|
-
component = clone.createComponent();
|
|
452
|
-
} else {
|
|
453
|
-
// Wrap in a frame-component approach
|
|
454
|
-
component = figma.createComponent();
|
|
455
|
-
component.name = ${JSON.stringify(componentName)};
|
|
456
|
-
component.resize(clone.width || 100, clone.height || 40);
|
|
457
|
-
node.parent.appendChild(component);
|
|
458
|
-
const inst = clone;
|
|
459
|
-
inst.x = 0;
|
|
460
|
-
inst.y = 0;
|
|
461
|
-
component.appendChild(inst);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// Rename layers to semantic names based on type
|
|
465
|
-
const renameByType = (n) => {
|
|
466
|
-
if (n.type === 'TEXT') {
|
|
467
|
-
const lc = n.name.toLowerCase();
|
|
468
|
-
if (!lc.includes('title') && !lc.includes('label') && !lc.includes('body')) {
|
|
469
|
-
if (n.fontSize >= 20) n.name = 'title';
|
|
470
|
-
else if (n.fontSize >= 14) n.name = 'body';
|
|
471
|
-
else n.name = 'label';
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (n.type === 'VECTOR' && !n.name.toLowerCase().includes('icon')) {
|
|
475
|
-
n.name = 'icon';
|
|
476
|
-
}
|
|
477
|
-
if (n.children) n.children.forEach(renameByType);
|
|
478
|
-
};
|
|
479
|
-
renameByType(component);
|
|
480
|
-
|
|
481
|
-
${bindingLines}
|
|
482
|
-
|
|
483
|
-
figma.viewport.scrollAndZoomIntoView([component]);
|
|
484
|
-
return { componentId: component.id, name: component.name };
|
|
485
|
-
})();
|
|
486
|
-
`.trim();
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// ─── Doc stub generator ───────────────────────────────────────────────────────
|
|
490
|
-
|
|
491
|
-
function buildDocStub(
|
|
492
|
-
nodeName: string,
|
|
493
|
-
bestMatch: string,
|
|
494
|
-
candidates: string[],
|
|
495
|
-
mappings: TokenMapping[]
|
|
496
|
-
): string {
|
|
497
|
-
const tokenLines = mappings
|
|
498
|
-
.slice(0, 10)
|
|
499
|
-
.map((m) => `| \`${m.suggestedToken}\` | \`${m.hardcodedValue}\` | ${m.property} |`)
|
|
500
|
-
.join("\n");
|
|
501
|
-
|
|
502
|
-
return `# ${nodeName}
|
|
503
|
-
|
|
504
|
-
**Detected pattern:** ${bestMatch}
|
|
505
|
-
**Probable component types:** ${candidates.join(", ")}
|
|
506
|
-
|
|
507
|
-
## Overview
|
|
508
|
-
Auto-generated documentation stub from Component Archaeologist analysis.
|
|
509
|
-
Review and update the description below to accurately reflect this component's purpose.
|
|
510
|
-
|
|
511
|
-
> [TODO: Describe what this component does, when to use it, and any important usage notes.]
|
|
512
|
-
|
|
513
|
-
## Token Bindings
|
|
514
|
-
|
|
515
|
-
| Token | Hardcoded Value | Property |
|
|
516
|
-
|-------|----------------|----------|
|
|
517
|
-
${tokenLines || "| — | — | No hardcoded values found |"}
|
|
518
|
-
|
|
519
|
-
## Props
|
|
520
|
-
|
|
521
|
-
| Prop | Type | Default | Description |
|
|
522
|
-
|------|------|---------|-------------|
|
|
523
|
-
| — | — | — | [TODO: Document props] |
|
|
524
|
-
|
|
525
|
-
## Usage
|
|
526
|
-
|
|
527
|
-
\`\`\`tsx
|
|
528
|
-
// [TODO: Add usage example]
|
|
529
|
-
import { ${bestMatch.replace(/\s+/g, "")} } from "@ds/components";
|
|
530
|
-
\`\`\`
|
|
531
|
-
|
|
532
|
-
## Variants
|
|
533
|
-
|
|
534
|
-
[TODO: Document available variants]
|
|
535
|
-
|
|
536
|
-
## Accessibility
|
|
537
|
-
|
|
538
|
-
[TODO: Document keyboard navigation, ARIA roles, and screen reader behaviour]
|
|
539
|
-
|
|
540
|
-
---
|
|
541
|
-
*Generated by Component Archaeologist on ${new Date().toISOString().split("T")[0]}*
|
|
542
|
-
`;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// ─── Main handler ─────────────────────────────────────────────────────────────
|
|
546
|
-
|
|
547
|
-
export async function componentArchaeologistHandler(
|
|
548
|
-
args: ComponentArchaeologistArgs
|
|
549
|
-
): Promise<ComponentArchaeologistResult> {
|
|
550
|
-
const {
|
|
551
|
-
nodeId,
|
|
552
|
-
outputAs,
|
|
553
|
-
createLibraryComponent = false,
|
|
554
|
-
generateDocStub = false,
|
|
555
|
-
} = args;
|
|
556
|
-
|
|
557
|
-
if (!nodeId) throw new Error("componentArchaeologist: `nodeId` is required.");
|
|
558
|
-
|
|
559
|
-
const bridge = await getBridge();
|
|
560
|
-
|
|
561
|
-
// 1. Fetch node tree from Figma
|
|
562
|
-
const node = await bridge.getNode(nodeId);
|
|
563
|
-
if (!node) throw new Error(`componentArchaeologist: Node "${nodeId}" not found.`);
|
|
564
|
-
|
|
565
|
-
// 2. Fetch tokens for snapping — DS tokens are authoritative when selected
|
|
566
|
-
const dsId = bridge.getActiveDesignSystemId();
|
|
567
|
-
let tokens: Token[];
|
|
568
|
-
if (dsId) {
|
|
569
|
-
const { getDesignSystemTokens } = await import("../../../shared/design-system-tokens.js");
|
|
570
|
-
tokens = getDesignSystemTokens(dsId);
|
|
571
|
-
} else {
|
|
572
|
-
tokens = await bridge.getTokens();
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
// 3. Summarize layers
|
|
576
|
-
const layerSummary = countLayerTypes(node);
|
|
577
|
-
|
|
578
|
-
// 4. Collect signals and fingerprint
|
|
579
|
-
const signals = collectSignals(node);
|
|
580
|
-
const patternMatches = fingerprintPatterns(signals, layerSummary);
|
|
581
|
-
|
|
582
|
-
const topMatch = patternMatches[0] ?? {
|
|
583
|
-
pattern: "Unknown",
|
|
584
|
-
candidates: ["Component"],
|
|
585
|
-
confidence: 0,
|
|
586
|
-
rationale: "No pattern matched. Layer structure does not fit known templates.",
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
const bestMatch = topMatch.candidates[0] ?? "Component";
|
|
590
|
-
|
|
591
|
-
// 5. Map hardcoded values to tokens
|
|
592
|
-
const tokenMappings = extractTokenMappings(node, tokens);
|
|
593
|
-
|
|
594
|
-
// 6. Optionally promote to component
|
|
595
|
-
let promotedComponentId: string | null = null;
|
|
596
|
-
if (
|
|
597
|
-
(outputAs === "component" || outputAs === "both") &&
|
|
598
|
-
createLibraryComponent
|
|
599
|
-
) {
|
|
600
|
-
const componentName = `[DS] ${bestMatch} / ${node.name}`;
|
|
601
|
-
const script = buildPromoteScript(nodeId, componentName, tokenMappings, tokens);
|
|
602
|
-
const execResult = await bridge.execute(script);
|
|
603
|
-
if (execResult.success && execResult.result) {
|
|
604
|
-
const res = execResult.result as { componentId: string };
|
|
605
|
-
promotedComponentId = res.componentId;
|
|
606
|
-
} else {
|
|
607
|
-
console.error(
|
|
608
|
-
"componentArchaeologist: Promotion failed —",
|
|
609
|
-
execResult.error
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// 7. Generate doc stub
|
|
615
|
-
const docStub = generateDocStub
|
|
616
|
-
? buildDocStub(
|
|
617
|
-
node.name,
|
|
618
|
-
topMatch.pattern,
|
|
619
|
-
topMatch.candidates,
|
|
620
|
-
tokenMappings
|
|
621
|
-
)
|
|
622
|
-
: null;
|
|
623
|
-
|
|
624
|
-
// 8. Log the decision
|
|
625
|
-
const logEntry = await decisionLog.log({
|
|
626
|
-
tool: "component-archaeologist",
|
|
627
|
-
nodeIds: [nodeId, ...(promotedComponentId ? [promotedComponentId] : [])],
|
|
628
|
-
rationale: `Analysed "${node.name}" (${layerSummary.totalLayers} layers, depth ${layerSummary.depth}). Top pattern: "${topMatch.pattern}" → ${topMatch.candidates.join(", ")} (confidence ${(topMatch.confidence * 100).toFixed(0)}%). Mapped ${tokenMappings.length} hardcoded values to tokens. Promoted: ${!!promotedComponentId}.`,
|
|
629
|
-
tokens: tokenMappings.map((m) => m.suggestedToken),
|
|
630
|
-
reversible: true,
|
|
631
|
-
metadata: {
|
|
632
|
-
outputAs,
|
|
633
|
-
createLibraryComponent,
|
|
634
|
-
generateDocStub,
|
|
635
|
-
patternCount: patternMatches.length,
|
|
636
|
-
bestMatch,
|
|
637
|
-
tokenMappingCount: tokenMappings.length,
|
|
638
|
-
promotedComponentId,
|
|
639
|
-
},
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
// Enrich with concept taxonomy metadata
|
|
643
|
-
const conceptDef = getConceptForComponent(bestMatch);
|
|
644
|
-
const concept = conceptDef?.id ?? null;
|
|
645
|
-
const expectedTokens = concept ? getAllTokenPaths(concept) : [];
|
|
646
|
-
|
|
647
|
-
return {
|
|
648
|
-
nodeId,
|
|
649
|
-
nodeName: node.name,
|
|
650
|
-
patternMatches,
|
|
651
|
-
bestMatch,
|
|
652
|
-
concept,
|
|
653
|
-
expectedTokens,
|
|
654
|
-
tokenMappings,
|
|
655
|
-
promotedComponentId,
|
|
656
|
-
docStub,
|
|
657
|
-
layerSummary,
|
|
658
|
-
logEntryId: logEntry.id,
|
|
659
|
-
};
|
|
660
|
-
}
|