@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,406 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* figma_taxonomy_docs — Living concept taxonomy documentation
|
|
3
|
-
*
|
|
4
|
-
* Generates documentation for the semantic token naming convention by
|
|
5
|
-
* cross-referencing the concept taxonomy with actual Figma variables.
|
|
6
|
-
* Supports markdown, JSON, and Figma page output formats.
|
|
7
|
-
*
|
|
8
|
-
* The Figma page output supports auto-sync: when variables change in the
|
|
9
|
-
* file, the documentation page updates automatically.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
13
|
-
import {
|
|
14
|
-
CONCEPT_TAXONOMY,
|
|
15
|
-
GRAMMAR,
|
|
16
|
-
getConceptById,
|
|
17
|
-
getRequiredTokenPaths,
|
|
18
|
-
getAllTokenPaths,
|
|
19
|
-
type ConceptDefinition,
|
|
20
|
-
} from "../../../shared/concept-taxonomy.js";
|
|
21
|
-
import { renderMarkdown } from "./renderers/markdown.js";
|
|
22
|
-
import { renderJson } from "./renderers/json.js";
|
|
23
|
-
import { renderFigmaPage } from "./renderers/figma-page.js";
|
|
24
|
-
import { renderNamingGuide } from "./renderers/naming-guide.js";
|
|
25
|
-
|
|
26
|
-
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
export interface TaxonomyDocsArgs {
|
|
29
|
-
outputFormat: "markdown" | "json" | "figma" | "naming-guide";
|
|
30
|
-
concepts?: string[];
|
|
31
|
-
includeTokenAnatomy?: boolean;
|
|
32
|
-
showCoverage?: boolean;
|
|
33
|
-
autoSync?: boolean;
|
|
34
|
-
pageName?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface TaxonomyDocsResult {
|
|
38
|
-
ok: boolean;
|
|
39
|
-
format: TaxonomyDocsArgs["outputFormat"];
|
|
40
|
-
conceptCount: number;
|
|
41
|
-
tokenCount: number;
|
|
42
|
-
output: string | TaxonomyDocsJsonOutput;
|
|
43
|
-
coverage: ConceptCoverage[];
|
|
44
|
-
notes: string[];
|
|
45
|
-
autoSyncEnabled?: boolean;
|
|
46
|
-
pageId?: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface ConceptCoverage {
|
|
50
|
-
conceptId: string;
|
|
51
|
-
conceptName: string;
|
|
52
|
-
purpose: string;
|
|
53
|
-
status: "full" | "partial" | "missing";
|
|
54
|
-
expectedTokens: string[];
|
|
55
|
-
foundTokens: string[];
|
|
56
|
-
missingTokens: string[];
|
|
57
|
-
/** Maps expected token path → actual file token name that matched (for fuzzy matches) */
|
|
58
|
-
matchedFileTokens: Record<string, string>;
|
|
59
|
-
typicalForms: string[];
|
|
60
|
-
validStates: string[];
|
|
61
|
-
validVariants: string[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface TaxonomyDocsJsonOutput {
|
|
65
|
-
generatedAt: string;
|
|
66
|
-
grammar: typeof GRAMMAR;
|
|
67
|
-
concepts: ConceptCoverage[];
|
|
68
|
-
totalExpected: number;
|
|
69
|
-
totalFound: number;
|
|
70
|
-
totalMissing: number;
|
|
71
|
-
tokenValues: Record<string, TokenValueSnapshot>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface TokenValueSnapshot {
|
|
75
|
-
name: string;
|
|
76
|
-
type: string;
|
|
77
|
-
collection: string;
|
|
78
|
-
values: Record<string, unknown>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ─── Core Logic ─────────────────────────────────────────────────────────────
|
|
82
|
-
|
|
83
|
-
interface RawVariable {
|
|
84
|
-
id: string;
|
|
85
|
-
name: string;
|
|
86
|
-
type: string;
|
|
87
|
-
resolvedType?: string;
|
|
88
|
-
description?: string;
|
|
89
|
-
valuesByMode?: Record<string, unknown>;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
interface RawCollection {
|
|
93
|
-
id: string;
|
|
94
|
-
name: string;
|
|
95
|
-
modes: Array<{ modeId: string; name: string }>;
|
|
96
|
-
variables: RawVariable[];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Build a set of all token names present in the Figma file.
|
|
101
|
-
* Also builds a map of name → snapshot for value rendering.
|
|
102
|
-
*/
|
|
103
|
-
function indexFileTokens(collections: RawCollection[]): {
|
|
104
|
-
tokenNames: Set<string>;
|
|
105
|
-
snapshots: Record<string, TokenValueSnapshot>;
|
|
106
|
-
} {
|
|
107
|
-
const tokenNames = new Set<string>();
|
|
108
|
-
const snapshots: Record<string, TokenValueSnapshot> = {};
|
|
109
|
-
|
|
110
|
-
for (const coll of collections) {
|
|
111
|
-
for (const v of coll.variables) {
|
|
112
|
-
const name = v.name;
|
|
113
|
-
tokenNames.add(name);
|
|
114
|
-
|
|
115
|
-
// Also index with common prefix variations for fuzzy matching
|
|
116
|
-
const segments = name.split("/");
|
|
117
|
-
if (segments.length > 2) {
|
|
118
|
-
// Allow suffix matching: "actions/primary/bg/default" matches "color/semantic/actions/primary/bg/default"
|
|
119
|
-
tokenNames.add(segments.slice(1).join("/"));
|
|
120
|
-
tokenNames.add(segments.slice(2).join("/"));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
snapshots[name] = {
|
|
124
|
-
name,
|
|
125
|
-
type: v.resolvedType ?? v.type,
|
|
126
|
-
collection: coll.name,
|
|
127
|
-
values: v.valuesByMode ?? {},
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return { tokenNames, snapshots };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Check which expected tokens exist for each concept.
|
|
137
|
-
*/
|
|
138
|
-
function computeCoverage(
|
|
139
|
-
concepts: ConceptDefinition[],
|
|
140
|
-
tokenNames: Set<string>,
|
|
141
|
-
): ConceptCoverage[] {
|
|
142
|
-
return concepts.map((concept) => {
|
|
143
|
-
const allPaths = getAllTokenPaths(concept.id);
|
|
144
|
-
const requiredPaths = getRequiredTokenPaths(concept.id);
|
|
145
|
-
|
|
146
|
-
const foundTokens: string[] = [];
|
|
147
|
-
const missingTokens: string[] = [];
|
|
148
|
-
const matchedFileTokens: Record<string, string> = {};
|
|
149
|
-
|
|
150
|
-
for (const path of allPaths) {
|
|
151
|
-
const match = tokenNameMatch(path, tokenNames);
|
|
152
|
-
if (match) {
|
|
153
|
-
foundTokens.push(path);
|
|
154
|
-
if (match !== path) {
|
|
155
|
-
matchedFileTokens[path] = match;
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
missingTokens.push(path);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Coverage status based on required tokens
|
|
163
|
-
const requiredFound = requiredPaths.filter((p) => tokenNameMatch(p, tokenNames) !== null);
|
|
164
|
-
let status: ConceptCoverage["status"];
|
|
165
|
-
if (requiredFound.length === requiredPaths.length) {
|
|
166
|
-
status = "full";
|
|
167
|
-
} else if (requiredFound.length > 0 || foundTokens.length > 0) {
|
|
168
|
-
status = "partial";
|
|
169
|
-
} else {
|
|
170
|
-
status = "missing";
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
conceptId: concept.id,
|
|
175
|
-
conceptName: concept.id.charAt(0).toUpperCase() + concept.id.slice(1),
|
|
176
|
-
purpose: concept.purpose,
|
|
177
|
-
status,
|
|
178
|
-
expectedTokens: allPaths,
|
|
179
|
-
foundTokens,
|
|
180
|
-
missingTokens,
|
|
181
|
-
matchedFileTokens,
|
|
182
|
-
typicalForms: concept.typicalForms,
|
|
183
|
-
validStates: concept.validStates,
|
|
184
|
-
validVariants: concept.validVariants,
|
|
185
|
-
};
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ─── Semantic keyword synonyms for fuzzy role matching ────────────────────
|
|
190
|
-
// Maps each semantic keyword to a set of equivalent terms found in real
|
|
191
|
-
// design-system token names (Carbon, MUI, Ant, Fluent, Polaris, etc.).
|
|
192
|
-
|
|
193
|
-
const KEYWORD_SYNONYMS: Record<string, string[]> = {
|
|
194
|
-
// Concept synonyms
|
|
195
|
-
actions: ["action", "actions", "btn", "button", "cta", "link"],
|
|
196
|
-
field: ["field", "input", "text-input", "textfield", "form", "select", "textarea"],
|
|
197
|
-
surface: ["surface", "card", "panel", "container", "paper", "well", "layer", "bg"],
|
|
198
|
-
navigation: ["nav", "navigation", "tab", "tabs", "breadcrumb", "sidebar", "appbar", "navbar"],
|
|
199
|
-
feedback: ["feedback", "alert", "toast", "banner", "snackbar", "notification", "callout", "message"],
|
|
200
|
-
// Property synonyms
|
|
201
|
-
bg: ["bg", "background", "fill", "surface", "base"],
|
|
202
|
-
text: ["text", "label", "foreground", "fg", "content", "on"],
|
|
203
|
-
icon: ["icon", "glyph", "symbol"],
|
|
204
|
-
border: ["border", "stroke", "outline", "divider", "separator", "edge"],
|
|
205
|
-
ring: ["ring", "focus-ring", "outline", "focus"],
|
|
206
|
-
shadow: ["shadow", "elevation", "drop-shadow", "box-shadow"],
|
|
207
|
-
inset: ["inset", "padding", "pad", "spacing", "inner"],
|
|
208
|
-
gap: ["gap", "gutter", "stack", "spacing"],
|
|
209
|
-
// State synonyms
|
|
210
|
-
hover: ["hover", "hovered", "over"],
|
|
211
|
-
active: ["active", "pressed", "down", "tap"],
|
|
212
|
-
focus: ["focus", "focused", "keyboard"],
|
|
213
|
-
disabled: ["disabled", "inactive", "muted", "dimmed"],
|
|
214
|
-
// Variant synonyms
|
|
215
|
-
primary: ["primary", "main", "brand", "accent", "key"],
|
|
216
|
-
secondary: ["secondary", "subtle", "alt", "alternative"],
|
|
217
|
-
ghost: ["ghost", "text", "plain", "minimal", "bare", "link"],
|
|
218
|
-
destructive:["destructive", "danger", "error", "critical", "negative", "red"],
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Extract semantic keywords from a token path.
|
|
223
|
-
* E.g. "color/semantic/actions/primary/bg/default" → ["color","semantic","actions","primary","bg","default"]
|
|
224
|
-
*/
|
|
225
|
-
function extractKeywords(path: string): string[] {
|
|
226
|
-
return path
|
|
227
|
-
.toLowerCase()
|
|
228
|
-
.split(/[\/\-_.]+/)
|
|
229
|
-
.filter(Boolean);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Check if a candidate token matches the semantic role described by `path`
|
|
234
|
-
* by checking whether the candidate contains synonyms for the key segments.
|
|
235
|
-
*/
|
|
236
|
-
function semanticKeywordMatch(expectedPath: string, candidateName: string): boolean {
|
|
237
|
-
const expectedKw = extractKeywords(expectedPath);
|
|
238
|
-
const candidateNorm = candidateName.toLowerCase().replace(/[\/\-_.]+/g, " ");
|
|
239
|
-
|
|
240
|
-
// Identify the "meaningful" keywords from the expected path —
|
|
241
|
-
// skip structural words like "semantic", "default", "control"
|
|
242
|
-
const STRUCTURAL = new Set(["semantic", "default", "control", "md", "sm", "lg"]);
|
|
243
|
-
const meaningfulKw = expectedKw.filter((kw) => !STRUCTURAL.has(kw));
|
|
244
|
-
|
|
245
|
-
if (meaningfulKw.length === 0) return false;
|
|
246
|
-
|
|
247
|
-
// For each meaningful keyword, check if the candidate contains
|
|
248
|
-
// that keyword or any of its synonyms
|
|
249
|
-
let matchCount = 0;
|
|
250
|
-
for (const kw of meaningfulKw) {
|
|
251
|
-
const synonyms = KEYWORD_SYNONYMS[kw] ?? [kw];
|
|
252
|
-
const allTerms = [kw, ...synonyms];
|
|
253
|
-
if (allTerms.some((term) => candidateNorm.includes(term))) {
|
|
254
|
-
matchCount++;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Require at least 2 meaningful keyword matches (or all if fewer than 2)
|
|
259
|
-
const threshold = Math.min(2, meaningfulKw.length);
|
|
260
|
-
return matchCount >= threshold;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Check if a token name exists in the file tokens.
|
|
265
|
-
* Uses three strategies in order:
|
|
266
|
-
* 1. Exact match
|
|
267
|
-
* 2. Suffix / normalized match
|
|
268
|
-
* 3. Semantic keyword match (catches tokens named differently but serving the same role)
|
|
269
|
-
*
|
|
270
|
-
* Returns the matched file token name, or null if no match.
|
|
271
|
-
*/
|
|
272
|
-
function tokenNameMatch(path: string, tokenNames: Set<string>): string | null {
|
|
273
|
-
// 1. Exact match
|
|
274
|
-
if (tokenNames.has(path)) return path;
|
|
275
|
-
|
|
276
|
-
// 2. Suffix match — some files prefix with collection name
|
|
277
|
-
for (const existing of tokenNames) {
|
|
278
|
-
if (existing.endsWith(`/${path}`) || existing.endsWith(path)) return existing;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// 3. Normalized comparison
|
|
282
|
-
const normalized = path.toLowerCase().replace(/[\/\-_]/g, "");
|
|
283
|
-
for (const existing of tokenNames) {
|
|
284
|
-
const n = existing.toLowerCase().replace(/[\/\-_]/g, "");
|
|
285
|
-
if (n === normalized || n.endsWith(normalized)) return existing;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// 4. Semantic keyword matching — find a token that semantically serves the same role
|
|
289
|
-
for (const existing of tokenNames) {
|
|
290
|
-
if (semanticKeywordMatch(path, existing)) return existing;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Check if a token name exists in the file tokens, with fuzzy matching.
|
|
298
|
-
*/
|
|
299
|
-
function tokenNameExists(path: string, tokenNames: Set<string>): boolean {
|
|
300
|
-
return tokenNameMatch(path, tokenNames) !== null;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ─── Handler ────────────────────────────────────────────────────────────────
|
|
304
|
-
|
|
305
|
-
export async function taxonomyDocsHandler(args: TaxonomyDocsArgs): Promise<TaxonomyDocsResult> {
|
|
306
|
-
const bridge = await getBridge();
|
|
307
|
-
const notes: string[] = [];
|
|
308
|
-
|
|
309
|
-
// Fetch actual tokens from the Figma file
|
|
310
|
-
let collections: RawCollection[] = [];
|
|
311
|
-
try {
|
|
312
|
-
collections = (await bridge.getVariables(undefined, "full")) as unknown as RawCollection[];
|
|
313
|
-
} catch {
|
|
314
|
-
notes.push("Could not fetch Figma variables — coverage report will show all tokens as missing.");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const { tokenNames, snapshots } = indexFileTokens(collections);
|
|
318
|
-
notes.push(`Indexed ${tokenNames.size} token names from ${collections.length} collections.`);
|
|
319
|
-
|
|
320
|
-
// Filter concepts if requested
|
|
321
|
-
let concepts = CONCEPT_TAXONOMY;
|
|
322
|
-
if (args.concepts?.length) {
|
|
323
|
-
const filter = new Set(args.concepts.map((c) => c.toLowerCase()));
|
|
324
|
-
concepts = concepts.filter((c) => filter.has(c.id));
|
|
325
|
-
if (concepts.length === 0) {
|
|
326
|
-
return {
|
|
327
|
-
ok: false,
|
|
328
|
-
format: args.outputFormat,
|
|
329
|
-
conceptCount: 0,
|
|
330
|
-
tokenCount: 0,
|
|
331
|
-
output: "No matching concepts found. Available: " + CONCEPT_TAXONOMY.map((c) => c.id).join(", "),
|
|
332
|
-
coverage: [],
|
|
333
|
-
notes: ["Filter matched 0 concepts."],
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Compute coverage
|
|
339
|
-
const coverage = computeCoverage(concepts, tokenNames);
|
|
340
|
-
const totalExpected = coverage.reduce((sum, c) => sum + c.expectedTokens.length, 0);
|
|
341
|
-
const totalFound = coverage.reduce((sum, c) => sum + c.foundTokens.length, 0);
|
|
342
|
-
|
|
343
|
-
// Render based on format
|
|
344
|
-
let output: string | TaxonomyDocsJsonOutput;
|
|
345
|
-
let pageId: string | undefined;
|
|
346
|
-
let autoSyncEnabled = false;
|
|
347
|
-
|
|
348
|
-
switch (args.outputFormat) {
|
|
349
|
-
case "markdown":
|
|
350
|
-
output = renderMarkdown(coverage, snapshots, {
|
|
351
|
-
includeTokenAnatomy: args.includeTokenAnatomy ?? true,
|
|
352
|
-
showCoverage: args.showCoverage ?? true,
|
|
353
|
-
});
|
|
354
|
-
break;
|
|
355
|
-
|
|
356
|
-
case "json":
|
|
357
|
-
output = renderJson(coverage, snapshots, totalExpected, totalFound);
|
|
358
|
-
break;
|
|
359
|
-
|
|
360
|
-
case "naming-guide":
|
|
361
|
-
output = renderNamingGuide(coverage);
|
|
362
|
-
break;
|
|
363
|
-
|
|
364
|
-
case "figma": {
|
|
365
|
-
const figmaOpts = {
|
|
366
|
-
pageName: args.pageName ?? "Token Taxonomy",
|
|
367
|
-
includeTokenAnatomy: args.includeTokenAnatomy ?? true,
|
|
368
|
-
showCoverage: args.showCoverage ?? true,
|
|
369
|
-
autoSync: args.autoSync ?? false,
|
|
370
|
-
};
|
|
371
|
-
const result = await renderFigmaPage(bridge, coverage, snapshots, figmaOpts);
|
|
372
|
-
pageId = result.pageId;
|
|
373
|
-
autoSyncEnabled = result.autoSyncEnabled;
|
|
374
|
-
output = `Figma page "${figmaOpts.pageName}" created with ${concepts.length} concepts. Page ID: ${pageId}`;
|
|
375
|
-
|
|
376
|
-
// Register auto-sync handler on the bridge
|
|
377
|
-
if (autoSyncEnabled && "setTaxonomyAutoSyncHandler" in bridge) {
|
|
378
|
-
const syncBridge = bridge as unknown as { setTaxonomyAutoSyncHandler: (h: (() => Promise<void>) | null) => void };
|
|
379
|
-
syncBridge.setTaxonomyAutoSyncHandler(async () => {
|
|
380
|
-
// Re-fetch tokens, recompute coverage, re-render page
|
|
381
|
-
let freshCollections: RawCollection[] = [];
|
|
382
|
-
try {
|
|
383
|
-
freshCollections = (await bridge.getVariables(undefined, "full")) as unknown as RawCollection[];
|
|
384
|
-
} catch { /* ignore — page will show all missing */ }
|
|
385
|
-
const fresh = indexFileTokens(freshCollections);
|
|
386
|
-
const freshCoverage = computeCoverage(concepts, fresh.tokenNames);
|
|
387
|
-
await renderFigmaPage(bridge, freshCoverage, fresh.snapshots, figmaOpts);
|
|
388
|
-
});
|
|
389
|
-
notes.push("Auto-sync enabled: documentation will update when variables change.");
|
|
390
|
-
}
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return {
|
|
396
|
-
ok: true,
|
|
397
|
-
format: args.outputFormat,
|
|
398
|
-
conceptCount: concepts.length,
|
|
399
|
-
tokenCount: totalFound,
|
|
400
|
-
output,
|
|
401
|
-
coverage,
|
|
402
|
-
notes,
|
|
403
|
-
autoSyncEnabled,
|
|
404
|
-
pageId,
|
|
405
|
-
};
|
|
406
|
-
}
|
package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Figma page renderer for taxonomy documentation.
|
|
3
|
-
* Creates a visual documentation page with concept tables, token anatomy,
|
|
4
|
-
* coverage badges, and color swatches — all from live Figma data.
|
|
5
|
-
*
|
|
6
|
-
* Supports auto-sync: stores the page name so the variable-change event
|
|
7
|
-
* handler can trigger a lightweight re-render.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { ConceptCoverage, TokenValueSnapshot } from "../index.js";
|
|
11
|
-
|
|
12
|
-
interface FigmaPageOptions {
|
|
13
|
-
pageName: string;
|
|
14
|
-
includeTokenAnatomy: boolean;
|
|
15
|
-
showCoverage: boolean;
|
|
16
|
-
autoSync: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface FigmaPageResult {
|
|
20
|
-
pageId: string;
|
|
21
|
-
autoSyncEnabled: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Module-level state for auto-sync
|
|
25
|
-
let autoSyncPageName: string | null = null;
|
|
26
|
-
|
|
27
|
-
export function getAutoSyncPageName(): string | null {
|
|
28
|
-
return autoSyncPageName;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function clearAutoSync(): void {
|
|
32
|
-
autoSyncPageName = null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function escapeJs(s: string): string {
|
|
36
|
-
return JSON.stringify(s);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function statusColor(status: ConceptCoverage["status"]): string {
|
|
40
|
-
if (status === "full") return "{ r: 0.13, g: 0.73, b: 0.33 }";
|
|
41
|
-
if (status === "partial") return "{ r: 0.95, g: 0.77, b: 0.06 }";
|
|
42
|
-
return "{ r: 0.85, g: 0.12, b: 0.12 }";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function statusLabel(status: ConceptCoverage["status"]): string {
|
|
46
|
-
if (status === "full") return "Full";
|
|
47
|
-
if (status === "partial") return "Partial";
|
|
48
|
-
return "Missing";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function renderFigmaPage(
|
|
52
|
-
bridge: { execute: (code: string) => Promise<{ success: boolean; result?: unknown }> },
|
|
53
|
-
coverage: ConceptCoverage[],
|
|
54
|
-
snapshots: Record<string, TokenValueSnapshot>,
|
|
55
|
-
options: FigmaPageOptions,
|
|
56
|
-
): Promise<FigmaPageResult> {
|
|
57
|
-
const pageName = options.pageName;
|
|
58
|
-
|
|
59
|
-
// Track for auto-sync
|
|
60
|
-
if (options.autoSync) {
|
|
61
|
-
autoSyncPageName = pageName;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const lines: string[] = [];
|
|
65
|
-
lines.push(`(async () => {`);
|
|
66
|
-
|
|
67
|
-
// ── Create or find page ──
|
|
68
|
-
lines.push(` let page = figma.root.children.find(p => p.name === ${escapeJs(pageName)});`);
|
|
69
|
-
lines.push(` if (!page) {`);
|
|
70
|
-
lines.push(` page = figma.createPage();`);
|
|
71
|
-
lines.push(` page.name = ${escapeJs(pageName)};`);
|
|
72
|
-
lines.push(` }`);
|
|
73
|
-
lines.push(` figma.currentPage = page;`);
|
|
74
|
-
lines.push(``);
|
|
75
|
-
|
|
76
|
-
// Clear existing content
|
|
77
|
-
lines.push(` for (const child of [...page.children]) { child.remove(); }`);
|
|
78
|
-
lines.push(``);
|
|
79
|
-
|
|
80
|
-
// ── Layout constants ──
|
|
81
|
-
lines.push(` const COL_W = 260;`);
|
|
82
|
-
lines.push(` const ROW_H = 36;`);
|
|
83
|
-
lines.push(` const SECTION_GAP = 60;`);
|
|
84
|
-
lines.push(` const HEADER_H = 48;`);
|
|
85
|
-
lines.push(` let cursorY = 0;`);
|
|
86
|
-
lines.push(``);
|
|
87
|
-
|
|
88
|
-
// ── Helper: create text node ──
|
|
89
|
-
lines.push(` async function txt(x, y, text, size, bold, color) {`);
|
|
90
|
-
lines.push(` const t = figma.createText();`);
|
|
91
|
-
lines.push(` await figma.loadFontAsync({ family: "Inter", style: bold ? "Bold" : "Regular" });`);
|
|
92
|
-
lines.push(` t.fontName = { family: "Inter", style: bold ? "Bold" : "Regular" };`);
|
|
93
|
-
lines.push(` t.fontSize = size;`);
|
|
94
|
-
lines.push(` t.characters = String(text);`);
|
|
95
|
-
lines.push(` t.x = x;`);
|
|
96
|
-
lines.push(` t.y = y;`);
|
|
97
|
-
lines.push(` if (color) t.fills = [{ type: "SOLID", color: color }];`);
|
|
98
|
-
lines.push(` page.appendChild(t);`);
|
|
99
|
-
lines.push(` return t;`);
|
|
100
|
-
lines.push(` }`);
|
|
101
|
-
lines.push(``);
|
|
102
|
-
|
|
103
|
-
// ── Helper: create rectangle ──
|
|
104
|
-
lines.push(` function rect(x, y, w, h, color, radius) {`);
|
|
105
|
-
lines.push(` const r = figma.createRectangle();`);
|
|
106
|
-
lines.push(` r.x = x; r.y = y; r.resize(w, h);`);
|
|
107
|
-
lines.push(` r.fills = [{ type: "SOLID", color: color }];`);
|
|
108
|
-
lines.push(` if (radius) r.cornerRadius = radius;`);
|
|
109
|
-
lines.push(` page.appendChild(r);`);
|
|
110
|
-
lines.push(` return r;`);
|
|
111
|
-
lines.push(` }`);
|
|
112
|
-
lines.push(``);
|
|
113
|
-
|
|
114
|
-
// ── Title Section ──
|
|
115
|
-
lines.push(` await txt(0, cursorY, "Token Taxonomy", 32, true);`);
|
|
116
|
-
lines.push(` cursorY += 44;`);
|
|
117
|
-
lines.push(` await txt(0, cursorY, "Generated ${new Date().toISOString().split("T")[0]} — re-run figma_taxonomy_docs to refresh", 14, false, { r: 0.5, g: 0.5, b: 0.5 });`);
|
|
118
|
-
lines.push(` cursorY += 32;`);
|
|
119
|
-
lines.push(``);
|
|
120
|
-
|
|
121
|
-
// ── Naming Grammar Section ──
|
|
122
|
-
lines.push(` await txt(0, cursorY, "Naming Grammar", 24, true);`);
|
|
123
|
-
lines.push(` cursorY += 36;`);
|
|
124
|
-
lines.push(` rect(0, cursorY, 800, 70, { r: 0.96, g: 0.96, b: 0.97 }, 8);`);
|
|
125
|
-
lines.push(` await txt(16, cursorY + 12, "Semantic: <category>/<concept>/[<variant>]/<property>/[<state>]", 14, false, { r: 0.1, g: 0.1, b: 0.1 });`);
|
|
126
|
-
lines.push(` await txt(16, cursorY + 36, "Component: component/<component>/[<part>]/[<variant>]/<category>/<property>/[<state>]", 14, false, { r: 0.1, g: 0.1, b: 0.1 });`);
|
|
127
|
-
lines.push(` cursorY += 70 + SECTION_GAP;`);
|
|
128
|
-
lines.push(``);
|
|
129
|
-
|
|
130
|
-
// ── Coverage Summary ──
|
|
131
|
-
if (options.showCoverage) {
|
|
132
|
-
const full = coverage.filter((c) => c.status === "full").length;
|
|
133
|
-
const partial = coverage.filter((c) => c.status === "partial").length;
|
|
134
|
-
const missing = coverage.filter((c) => c.status === "missing").length;
|
|
135
|
-
|
|
136
|
-
lines.push(` await txt(0, cursorY, "Coverage Summary", 24, true);`);
|
|
137
|
-
lines.push(` cursorY += 36;`);
|
|
138
|
-
|
|
139
|
-
// Status badges
|
|
140
|
-
lines.push(` rect(0, cursorY, 120, 40, { r: 0.13, g: 0.73, b: 0.33 }, 8);`);
|
|
141
|
-
lines.push(` await txt(12, cursorY + 10, "Full: ${full}", 16, true, { r: 1, g: 1, b: 1 });`);
|
|
142
|
-
|
|
143
|
-
lines.push(` rect(136, cursorY, 120, 40, { r: 0.95, g: 0.77, b: 0.06 }, 8);`);
|
|
144
|
-
lines.push(` await txt(148, cursorY + 10, "Partial: ${partial}", 16, true, { r: 0.1, g: 0.1, b: 0.1 });`);
|
|
145
|
-
|
|
146
|
-
lines.push(` rect(272, cursorY, 120, 40, { r: 0.85, g: 0.12, b: 0.12 }, 8);`);
|
|
147
|
-
lines.push(` await txt(284, cursorY + 10, "Missing: ${missing}", 16, true, { r: 1, g: 1, b: 1 });`);
|
|
148
|
-
|
|
149
|
-
lines.push(` cursorY += 40 + SECTION_GAP;`);
|
|
150
|
-
lines.push(``);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// ── Concept Overview Table ──
|
|
154
|
-
lines.push(` await txt(0, cursorY, "Concept Taxonomy", 24, true);`);
|
|
155
|
-
lines.push(` cursorY += 36;`);
|
|
156
|
-
|
|
157
|
-
// Table header
|
|
158
|
-
const cols = [
|
|
159
|
-
{ label: "Concept", x: 0, w: 120 },
|
|
160
|
-
{ label: "Purpose", x: 130, w: 300 },
|
|
161
|
-
{ label: "Forms", x: 440, w: 200 },
|
|
162
|
-
{ label: "States", x: 650, w: 200 },
|
|
163
|
-
{ label: "Coverage", x: 860, w: 100 },
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
lines.push(` rect(0, cursorY, 960, 36, { r: 0.94, g: 0.94, b: 0.96 }, 4);`);
|
|
167
|
-
for (const col of cols) {
|
|
168
|
-
lines.push(` await txt(${col.x + 8}, cursorY + 9, ${escapeJs(col.label)}, 13, true);`);
|
|
169
|
-
}
|
|
170
|
-
lines.push(` cursorY += 36;`);
|
|
171
|
-
|
|
172
|
-
// Table rows
|
|
173
|
-
for (const c of coverage) {
|
|
174
|
-
const forms = c.typicalForms.slice(0, 3).join(", ") + (c.typicalForms.length > 3 ? "..." : "");
|
|
175
|
-
const states = c.validStates.slice(0, 4).join(", ") + (c.validStates.length > 4 ? "..." : "");
|
|
176
|
-
const covLabel = `${statusLabel(c.status)} ${c.foundTokens.length}/${c.expectedTokens.length}`;
|
|
177
|
-
|
|
178
|
-
// Alternating row background
|
|
179
|
-
lines.push(` rect(0, cursorY, 960, 36, { r: 0.99, g: 0.99, b: 1.0 }, 0);`);
|
|
180
|
-
lines.push(` await txt(8, cursorY + 9, ${escapeJs(c.conceptName)}, 12, true);`);
|
|
181
|
-
lines.push(` await txt(138, cursorY + 9, ${escapeJs(c.purpose.slice(0, 50) + (c.purpose.length > 50 ? "..." : ""))}, 11, false);`);
|
|
182
|
-
lines.push(` await txt(448, cursorY + 9, ${escapeJs(forms)}, 11, false);`);
|
|
183
|
-
lines.push(` await txt(658, cursorY + 9, ${escapeJs(states)}, 11, false);`);
|
|
184
|
-
|
|
185
|
-
// Coverage badge
|
|
186
|
-
lines.push(` rect(868, cursorY + 6, 84, 24, ${statusColor(c.status)}, 12);`);
|
|
187
|
-
lines.push(` await txt(878, cursorY + 10, ${escapeJs(covLabel)}, 10, true, { r: 1, g: 1, b: 1 });`);
|
|
188
|
-
|
|
189
|
-
lines.push(` cursorY += 36;`);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
lines.push(` cursorY += SECTION_GAP;`);
|
|
193
|
-
lines.push(``);
|
|
194
|
-
|
|
195
|
-
// ── Per-Concept Token Anatomy ──
|
|
196
|
-
if (options.includeTokenAnatomy) {
|
|
197
|
-
for (const c of coverage) {
|
|
198
|
-
if (c.expectedTokens.length === 0) continue;
|
|
199
|
-
|
|
200
|
-
lines.push(` // ── ${c.conceptName} anatomy ──`);
|
|
201
|
-
lines.push(` await txt(0, cursorY, ${escapeJs(c.conceptName + " Tokens")}, 20, true);`);
|
|
202
|
-
lines.push(` cursorY += 28;`);
|
|
203
|
-
lines.push(` await txt(0, cursorY, ${escapeJs(c.purpose)}, 12, false, { r: 0.5, g: 0.5, b: 0.5 });`);
|
|
204
|
-
lines.push(` cursorY += 24;`);
|
|
205
|
-
|
|
206
|
-
for (const token of c.expectedTokens) {
|
|
207
|
-
const found = c.foundTokens.includes(token);
|
|
208
|
-
const snap = snapshots[token];
|
|
209
|
-
|
|
210
|
-
// Token row with status indicator
|
|
211
|
-
const indicatorColor = found
|
|
212
|
-
? "{ r: 0.13, g: 0.73, b: 0.33 }"
|
|
213
|
-
: "{ r: 0.85, g: 0.12, b: 0.12 }";
|
|
214
|
-
|
|
215
|
-
lines.push(` rect(0, cursorY + 4, 8, 8, ${indicatorColor}, 4);`);
|
|
216
|
-
const fileToken = c.matchedFileTokens[token];
|
|
217
|
-
const displayLabel = fileToken ? `${token} → ${fileToken}` : token;
|
|
218
|
-
lines.push(` await txt(16, cursorY, ${escapeJs(displayLabel)}, 11, false);`);
|
|
219
|
-
|
|
220
|
-
// If it's a color token and we have the value, show a swatch
|
|
221
|
-
if (snap?.type === "COLOR" && snap.values) {
|
|
222
|
-
const firstValue = Object.values(snap.values)[0];
|
|
223
|
-
if (firstValue && typeof firstValue === "object" && "r" in (firstValue as Record<string, unknown>)) {
|
|
224
|
-
const cv = firstValue as { r: number; g: number; b: number };
|
|
225
|
-
lines.push(` rect(500, cursorY, 20, 16, { r: ${cv.r.toFixed(3)}, g: ${cv.g.toFixed(3)}, b: ${cv.b.toFixed(3)} }, 3);`);
|
|
226
|
-
const hex = `#${Math.round(cv.r * 255).toString(16).padStart(2, "0")}${Math.round(cv.g * 255).toString(16).padStart(2, "0")}${Math.round(cv.b * 255).toString(16).padStart(2, "0")}`.toUpperCase();
|
|
227
|
-
lines.push(` await txt(528, cursorY, ${escapeJs(hex)}, 11, false, { r: 0.4, g: 0.4, b: 0.4 });`);
|
|
228
|
-
}
|
|
229
|
-
} else if (snap?.values) {
|
|
230
|
-
const firstValue = Object.values(snap.values)[0];
|
|
231
|
-
if (firstValue !== undefined && firstValue !== null) {
|
|
232
|
-
lines.push(` await txt(500, cursorY, ${escapeJs(String(firstValue))}, 11, false, { r: 0.4, g: 0.4, b: 0.4 });`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
lines.push(` cursorY += 20;`);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
lines.push(` cursorY += 32;`);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// ── Timestamp footer ──
|
|
244
|
-
lines.push(` await txt(0, cursorY, "Last synced: ${new Date().toISOString()}", 11, false, { r: 0.6, g: 0.6, b: 0.6 });`);
|
|
245
|
-
lines.push(``);
|
|
246
|
-
|
|
247
|
-
lines.push(` return { pageId: page.id };`);
|
|
248
|
-
lines.push(`})();`);
|
|
249
|
-
|
|
250
|
-
const result = await bridge.execute(lines.join("\n"));
|
|
251
|
-
|
|
252
|
-
let pageId = "unknown";
|
|
253
|
-
if (result.success && result.result) {
|
|
254
|
-
try {
|
|
255
|
-
const parsed = typeof result.result === "string" ? JSON.parse(result.result) : result.result;
|
|
256
|
-
pageId = parsed.pageId ?? "unknown";
|
|
257
|
-
} catch {
|
|
258
|
-
// result may be the page ID string directly
|
|
259
|
-
pageId = String(result.result);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return {
|
|
264
|
-
pageId,
|
|
265
|
-
autoSyncEnabled: options.autoSync,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Build a lightweight re-render script that updates only dynamic content
|
|
271
|
-
* (coverage badges, swatches, timestamp) without recreating the full page.
|
|
272
|
-
* Used by the auto-sync handler.
|
|
273
|
-
*/
|
|
274
|
-
export function buildAutoSyncScript(
|
|
275
|
-
pageName: string,
|
|
276
|
-
coverage: ConceptCoverage[],
|
|
277
|
-
): string {
|
|
278
|
-
// For auto-sync, we regenerate the full page since Figma plugin API
|
|
279
|
-
// doesn't support efficient partial updates of text/fill properties
|
|
280
|
-
// across many unrelated nodes. The full re-render is fast enough
|
|
281
|
-
// (< 500ms for ~25 concepts) given the 2-second debounce.
|
|
282
|
-
//
|
|
283
|
-
// This function is called by the variable-change event handler
|
|
284
|
-
// in figma-bridge.ts — it re-computes coverage and rebuilds the page.
|
|
285
|
-
return `
|
|
286
|
-
(async () => {
|
|
287
|
-
const page = figma.root.children.find(p => p.name === ${escapeJs(pageName)});
|
|
288
|
-
if (!page) return { skipped: true, reason: "page not found" };
|
|
289
|
-
return { needsFullRerender: true, pageId: page.id };
|
|
290
|
-
})();
|
|
291
|
-
`;
|
|
292
|
-
}
|