@sarjallab09/figma-intelligence 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -36
- package/dist/bin/cli.js +2 -0
- package/dist/design-bridge/bridge.js +2 -0
- package/dist/figma-bridge-plugin/bridge-relay.js +2 -0
- package/dist/figma-bridge-plugin/code.js +1 -0
- package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package-lock.json +0 -3
- package/dist/figma-bridge-plugin/ui.html +4970 -0
- package/dist/figma-intelligence-layer/dist/index.js +2 -0
- package/dist/scripts/clean-existing-chunks.js +2 -0
- package/dist/scripts/connect-ai-tool.js +2 -0
- package/dist/scripts/convert-hub-pdfs.js +2 -0
- package/dist/scripts/figma-mcp-status.js +2 -0
- package/dist/scripts/register-codex-mcp.js +2 -0
- package/dist/scripts/test-copilot-chat.js +2 -0
- package/package.json +11 -8
- package/bin/cli.js +0 -859
- package/design-bridge/bridge.js +0 -196
- package/design-bridge/lib/assets.js +0 -367
- package/design-bridge/lib/prompt.js +0 -85
- package/design-bridge/lib/server.js +0 -66
- package/design-bridge/lib/stitch.js +0 -37
- package/design-bridge/lib/tokens.js +0 -82
- package/design-bridge/package-lock.json +0 -579
- package/figma-bridge-plugin/README.md +0 -97
- package/figma-bridge-plugin/anthropic-chat-runner.js +0 -192
- package/figma-bridge-plugin/bridge-relay.js +0 -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,710 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* figma_token_docs — Living token documentation generator
|
|
3
|
-
*
|
|
4
|
-
* Fetches all design tokens from the Figma bridge, organizes them by category,
|
|
5
|
-
* and generates documentation in multiple output formats (Figma, Markdown, JSON, HTML).
|
|
6
|
-
* Token data is never fabricated — all values come from actual Figma variables.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
10
|
-
|
|
11
|
-
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
12
|
-
|
|
13
|
-
export interface TokenDocsArgs {
|
|
14
|
-
outputFormat: "figma" | "markdown" | "json" | "html";
|
|
15
|
-
categories?: string[];
|
|
16
|
-
collectionFilter?: string;
|
|
17
|
-
includeVisualSwatches?: boolean;
|
|
18
|
-
includeUsageExamples?: boolean;
|
|
19
|
-
includeAliasChains?: boolean;
|
|
20
|
-
pageName?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface TokenDocsResult {
|
|
24
|
-
ok: boolean;
|
|
25
|
-
format: TokenDocsArgs["outputFormat"];
|
|
26
|
-
tokenCount: number;
|
|
27
|
-
collectionCount: number;
|
|
28
|
-
categoryCount: number;
|
|
29
|
-
output: string | TokenDocsJsonOutput;
|
|
30
|
-
notes: string[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface RawVariable {
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
type: string;
|
|
37
|
-
resolvedType?: string;
|
|
38
|
-
description?: string;
|
|
39
|
-
valuesByMode?: Record<string, unknown>;
|
|
40
|
-
aliasOf?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface RawCollection {
|
|
44
|
-
id: string;
|
|
45
|
-
name: string;
|
|
46
|
-
modes: Array<{ modeId: string; name: string }>;
|
|
47
|
-
variables: RawVariable[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface CategorizedToken {
|
|
51
|
-
name: string;
|
|
52
|
-
id: string;
|
|
53
|
-
collection: string;
|
|
54
|
-
resolvedType: string;
|
|
55
|
-
description: string;
|
|
56
|
-
values: Record<string, unknown>;
|
|
57
|
-
aliasOf?: string;
|
|
58
|
-
aliasChain?: string[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface TokenCategory {
|
|
62
|
-
label: string;
|
|
63
|
-
tokens: CategorizedToken[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface TokenDocsJsonOutput {
|
|
67
|
-
generatedAt: string;
|
|
68
|
-
totalTokens: number;
|
|
69
|
-
collections: string[];
|
|
70
|
-
categories: Record<string, {
|
|
71
|
-
count: number;
|
|
72
|
-
tokens: Array<{
|
|
73
|
-
name: string;
|
|
74
|
-
resolvedType: string;
|
|
75
|
-
description: string;
|
|
76
|
-
values: Record<string, unknown>;
|
|
77
|
-
aliasOf?: string;
|
|
78
|
-
aliasChain?: string[];
|
|
79
|
-
}>;
|
|
80
|
-
}>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ─── Category Definitions ───────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
const CATEGORY_MATCHERS: Array<{ label: string; test: (name: string, type: string) => boolean }> = [
|
|
86
|
-
{ label: "Colors", test: (n, t) => t === "COLOR" || /color|fill|stroke|bg|background|foreground/i.test(n) },
|
|
87
|
-
{ label: "Spacing", test: (n, t) => t === "FLOAT" && /spacing|space|gap|padding|margin|inset/i.test(n) },
|
|
88
|
-
{ label: "Typography", test: (n, _) => /font|type|typography|text|letter-spacing|line-height/i.test(n) },
|
|
89
|
-
{ label: "Radius", test: (n, t) => t === "FLOAT" && /radius|corner|rounded/i.test(n) },
|
|
90
|
-
{ label: "Elevation", test: (n, _) => /elevation|shadow|box-shadow|drop-shadow/i.test(n) },
|
|
91
|
-
{ label: "Motion", test: (n, _) => /motion|animation|duration|easing|transition|delay/i.test(n) },
|
|
92
|
-
{ label: "Z-Index", test: (n, t) => t === "FLOAT" && /z-index|z-layer|layer/i.test(n) },
|
|
93
|
-
{ label: "Opacity", test: (n, t) => t === "FLOAT" && /opacity|alpha|transparency/i.test(n) },
|
|
94
|
-
{ label: "Border Width", test: (n, t) => t === "FLOAT" && /border-width|border-size|stroke-width/i.test(n) },
|
|
95
|
-
{ label: "Breakpoints", test: (n, t) => t === "FLOAT" && /breakpoint|screen|viewport/i.test(n) },
|
|
96
|
-
{ label: "Grid", test: (n, _) => /grid|column|gutter/i.test(n) },
|
|
97
|
-
{ label: "Density", test: (n, _) => /density|compact|comfortable|spacious/i.test(n) },
|
|
98
|
-
{ label: "Icon Sizes", test: (n, t) => t === "FLOAT" && /icon-size|icon-width|icon-height/i.test(n) },
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
const UNCATEGORIZED_LABEL = "Other";
|
|
102
|
-
|
|
103
|
-
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
104
|
-
|
|
105
|
-
function categorizeToken(name: string, type: string): string {
|
|
106
|
-
for (const matcher of CATEGORY_MATCHERS) {
|
|
107
|
-
if (matcher.test(name, type)) return matcher.label;
|
|
108
|
-
}
|
|
109
|
-
return UNCATEGORIZED_LABEL;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function formatColorValue(value: unknown): string {
|
|
113
|
-
if (typeof value === "string") return value;
|
|
114
|
-
if (value && typeof value === "object" && "r" in value) {
|
|
115
|
-
const c = value as { r: number; g: number; b: number; a?: number };
|
|
116
|
-
const r = Math.round(c.r * 255);
|
|
117
|
-
const g = Math.round(c.g * 255);
|
|
118
|
-
const b = Math.round(c.b * 255);
|
|
119
|
-
if (c.a !== undefined && c.a < 1) {
|
|
120
|
-
return `rgba(${r}, ${g}, ${b}, ${c.a.toFixed(2)})`;
|
|
121
|
-
}
|
|
122
|
-
return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`.toUpperCase();
|
|
123
|
-
}
|
|
124
|
-
return String(value);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function formatValue(value: unknown, type: string): string {
|
|
128
|
-
if (value === null || value === undefined) return "—";
|
|
129
|
-
if (type === "COLOR") return formatColorValue(value);
|
|
130
|
-
if (typeof value === "object" && value !== null && "type" in value && (value as Record<string, unknown>).type === "VARIABLE_ALIAS") {
|
|
131
|
-
return `-> ${(value as unknown as { variableId: string }).variableId}`;
|
|
132
|
-
}
|
|
133
|
-
return String(value);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function resolveAliasChain(
|
|
137
|
-
variable: RawVariable,
|
|
138
|
-
allVariablesById: Map<string, RawVariable>,
|
|
139
|
-
maxDepth = 10
|
|
140
|
-
): string[] {
|
|
141
|
-
const chain: string[] = [];
|
|
142
|
-
let current = variable;
|
|
143
|
-
let depth = 0;
|
|
144
|
-
|
|
145
|
-
while (depth < maxDepth) {
|
|
146
|
-
const firstModeValue = current.valuesByMode
|
|
147
|
-
? Object.values(current.valuesByMode)[0]
|
|
148
|
-
: undefined;
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
firstModeValue &&
|
|
152
|
-
typeof firstModeValue === "object" &&
|
|
153
|
-
firstModeValue !== null &&
|
|
154
|
-
"type" in firstModeValue &&
|
|
155
|
-
(firstModeValue as Record<string, unknown>).type === "VARIABLE_ALIAS"
|
|
156
|
-
) {
|
|
157
|
-
const aliasId = (firstModeValue as unknown as { variableId: string }).variableId;
|
|
158
|
-
const target = allVariablesById.get(aliasId);
|
|
159
|
-
if (target) {
|
|
160
|
-
chain.push(target.name);
|
|
161
|
-
current = target;
|
|
162
|
-
depth++;
|
|
163
|
-
} else {
|
|
164
|
-
chain.push(`[unresolved: ${aliasId}]`);
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return chain;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function todayStamp(): string {
|
|
176
|
-
const d = new Date();
|
|
177
|
-
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// ─── Data Fetching & Organizing ─────────────────────────────────────────────
|
|
181
|
-
|
|
182
|
-
async function fetchAndOrganizeTokens(
|
|
183
|
-
args: TokenDocsArgs
|
|
184
|
-
): Promise<{ categories: Map<string, TokenCategory>; collections: RawCollection[]; allTokenCount: number }> {
|
|
185
|
-
const bridge = await getBridge();
|
|
186
|
-
const raw = await bridge.getVariables(undefined, "full") as RawCollection[];
|
|
187
|
-
|
|
188
|
-
// Filter collections if requested
|
|
189
|
-
const collections = args.collectionFilter
|
|
190
|
-
? raw.filter((c) => c.name.toLowerCase().includes(args.collectionFilter!.toLowerCase()))
|
|
191
|
-
: raw;
|
|
192
|
-
|
|
193
|
-
// Build variable-by-id index for alias resolution
|
|
194
|
-
const allVariablesById = new Map<string, RawVariable>();
|
|
195
|
-
for (const col of raw) {
|
|
196
|
-
for (const v of col.variables) {
|
|
197
|
-
allVariablesById.set(v.id, v);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Organize tokens into categories
|
|
202
|
-
const categoryMap = new Map<string, TokenCategory>();
|
|
203
|
-
let allTokenCount = 0;
|
|
204
|
-
|
|
205
|
-
for (const collection of collections) {
|
|
206
|
-
const modeNames = collection.modes.map((m) => m.name);
|
|
207
|
-
|
|
208
|
-
for (const variable of collection.variables) {
|
|
209
|
-
const type = variable.resolvedType || variable.type || "STRING";
|
|
210
|
-
const category = categorizeToken(variable.name, type);
|
|
211
|
-
|
|
212
|
-
// Apply category filter if specified
|
|
213
|
-
if (args.categories && args.categories.length > 0) {
|
|
214
|
-
if (!args.categories.some((c) => c.toLowerCase() === category.toLowerCase())) {
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (!categoryMap.has(category)) {
|
|
220
|
-
categoryMap.set(category, { label: category, tokens: [] });
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Build mode values
|
|
224
|
-
const values: Record<string, unknown> = {};
|
|
225
|
-
if (variable.valuesByMode) {
|
|
226
|
-
const modeEntries = Object.entries(variable.valuesByMode);
|
|
227
|
-
for (let i = 0; i < modeEntries.length; i++) {
|
|
228
|
-
const modeName = modeNames[i] || modeEntries[i][0];
|
|
229
|
-
values[modeName] = modeEntries[i][1];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Resolve alias
|
|
234
|
-
let aliasOf: string | undefined;
|
|
235
|
-
let aliasChain: string[] | undefined;
|
|
236
|
-
const firstValue = variable.valuesByMode ? Object.values(variable.valuesByMode)[0] : undefined;
|
|
237
|
-
if (
|
|
238
|
-
firstValue &&
|
|
239
|
-
typeof firstValue === "object" &&
|
|
240
|
-
firstValue !== null &&
|
|
241
|
-
"type" in firstValue &&
|
|
242
|
-
(firstValue as Record<string, unknown>).type === "VARIABLE_ALIAS"
|
|
243
|
-
) {
|
|
244
|
-
const target = allVariablesById.get((firstValue as unknown as { variableId: string }).variableId);
|
|
245
|
-
aliasOf = target?.name || (firstValue as unknown as { variableId: string }).variableId;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (args.includeAliasChains) {
|
|
249
|
-
aliasChain = resolveAliasChain(variable, allVariablesById);
|
|
250
|
-
if (aliasChain.length === 0) aliasChain = undefined;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
categoryMap.get(category)!.tokens.push({
|
|
254
|
-
name: variable.name,
|
|
255
|
-
id: variable.id,
|
|
256
|
-
collection: collection.name,
|
|
257
|
-
resolvedType: type,
|
|
258
|
-
description: variable.description || "",
|
|
259
|
-
values,
|
|
260
|
-
aliasOf,
|
|
261
|
-
aliasChain,
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
allTokenCount++;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return { categories: categoryMap, collections, allTokenCount };
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// ─── Renderers ──────────────────────────────────────────────────────────────
|
|
272
|
-
|
|
273
|
-
function renderMarkdown(
|
|
274
|
-
categories: Map<string, TokenCategory>,
|
|
275
|
-
collections: RawCollection[],
|
|
276
|
-
allTokenCount: number,
|
|
277
|
-
args: TokenDocsArgs
|
|
278
|
-
): string {
|
|
279
|
-
const lines: string[] = [];
|
|
280
|
-
const date = todayStamp();
|
|
281
|
-
|
|
282
|
-
lines.push(`# Design Token Documentation`);
|
|
283
|
-
lines.push(`Generated: ${date} | Tokens: ${allTokenCount} | Collections: ${collections.length}`);
|
|
284
|
-
lines.push("");
|
|
285
|
-
|
|
286
|
-
for (const [, category] of categories) {
|
|
287
|
-
lines.push(`## ${category.label}`);
|
|
288
|
-
lines.push("");
|
|
289
|
-
|
|
290
|
-
if (category.tokens.length === 0) {
|
|
291
|
-
lines.push("_No tokens in this category._");
|
|
292
|
-
lines.push("");
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Determine mode columns from first token
|
|
297
|
-
const modeNames = Object.keys(category.tokens[0].values);
|
|
298
|
-
const isColor = category.label === "Colors";
|
|
299
|
-
const hasAlias = category.tokens.some((t) => t.aliasOf);
|
|
300
|
-
|
|
301
|
-
// Build header
|
|
302
|
-
const headerCols = ["Token"];
|
|
303
|
-
for (const mode of modeNames) headerCols.push(mode);
|
|
304
|
-
if (hasAlias) headerCols.push("Alias Of");
|
|
305
|
-
if (args.includeAliasChains) headerCols.push("Alias Chain");
|
|
306
|
-
headerCols.push("Description");
|
|
307
|
-
|
|
308
|
-
lines.push(`| ${headerCols.join(" | ")} |`);
|
|
309
|
-
lines.push(`| ${headerCols.map(() => "---").join(" | ")} |`);
|
|
310
|
-
|
|
311
|
-
for (const token of category.tokens) {
|
|
312
|
-
const row: string[] = [`\`${token.name}\``];
|
|
313
|
-
for (const mode of modeNames) {
|
|
314
|
-
row.push(formatValue(token.values[mode], token.resolvedType));
|
|
315
|
-
}
|
|
316
|
-
if (hasAlias) row.push(token.aliasOf ? `\`${token.aliasOf}\`` : "—");
|
|
317
|
-
if (args.includeAliasChains) {
|
|
318
|
-
row.push(token.aliasChain ? token.aliasChain.map((a) => `\`${a}\``).join(" -> ") : "—");
|
|
319
|
-
}
|
|
320
|
-
row.push(token.description || "—");
|
|
321
|
-
lines.push(`| ${row.join(" | ")} |`);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
lines.push("");
|
|
325
|
-
|
|
326
|
-
if (args.includeUsageExamples && isColor) {
|
|
327
|
-
lines.push("### Usage Examples");
|
|
328
|
-
lines.push("```css");
|
|
329
|
-
for (const token of category.tokens.slice(0, 3)) {
|
|
330
|
-
const cssVar = token.name.replace(/\//g, "-");
|
|
331
|
-
lines.push(`.element { color: var(--${cssVar}); }`);
|
|
332
|
-
}
|
|
333
|
-
lines.push("```");
|
|
334
|
-
lines.push("");
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return lines.join("\n");
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function renderJson(
|
|
342
|
-
categories: Map<string, TokenCategory>,
|
|
343
|
-
collections: RawCollection[],
|
|
344
|
-
allTokenCount: number,
|
|
345
|
-
_args: TokenDocsArgs
|
|
346
|
-
): TokenDocsJsonOutput {
|
|
347
|
-
const output: TokenDocsJsonOutput = {
|
|
348
|
-
generatedAt: todayStamp(),
|
|
349
|
-
totalTokens: allTokenCount,
|
|
350
|
-
collections: collections.map((c) => c.name),
|
|
351
|
-
categories: {},
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
for (const [key, category] of categories) {
|
|
355
|
-
output.categories[key] = {
|
|
356
|
-
count: category.tokens.length,
|
|
357
|
-
tokens: category.tokens.map((t) => ({
|
|
358
|
-
name: t.name,
|
|
359
|
-
resolvedType: t.resolvedType,
|
|
360
|
-
description: t.description,
|
|
361
|
-
values: t.values,
|
|
362
|
-
...(t.aliasOf ? { aliasOf: t.aliasOf } : {}),
|
|
363
|
-
...(t.aliasChain ? { aliasChain: t.aliasChain } : {}),
|
|
364
|
-
})),
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
return output;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function renderHtml(
|
|
372
|
-
categories: Map<string, TokenCategory>,
|
|
373
|
-
collections: RawCollection[],
|
|
374
|
-
allTokenCount: number,
|
|
375
|
-
args: TokenDocsArgs
|
|
376
|
-
): string {
|
|
377
|
-
const date = todayStamp();
|
|
378
|
-
const categoryEntries = Array.from(categories.entries());
|
|
379
|
-
|
|
380
|
-
return `<!DOCTYPE html>
|
|
381
|
-
<html lang="en">
|
|
382
|
-
<head>
|
|
383
|
-
<meta charset="UTF-8">
|
|
384
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
385
|
-
<title>Design Token Documentation</title>
|
|
386
|
-
<style>
|
|
387
|
-
:root { --bg: #ffffff; --fg: #1a1a1a; --muted: #6b7280; --border: #e5e7eb; --card-bg: #f9fafb; --accent: #2563eb; }
|
|
388
|
-
[data-theme="dark"] { --bg: #111827; --fg: #f3f4f6; --muted: #9ca3af; --border: #374151; --card-bg: #1f2937; --accent: #60a5fa; }
|
|
389
|
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
390
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); padding: 2rem; max-width: 1200px; margin: 0 auto; transition: background 0.2s, color 0.2s; }
|
|
391
|
-
h1 { font-size: 2rem; margin-bottom: 0.25rem; }
|
|
392
|
-
.meta { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.875rem; }
|
|
393
|
-
.controls { display: flex; gap: 1rem; margin-bottom: 2rem; align-items: center; flex-wrap: wrap; }
|
|
394
|
-
.controls input { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.875rem; background: var(--card-bg); color: var(--fg); min-width: 250px; }
|
|
395
|
-
.controls button { padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; background: var(--card-bg); color: var(--fg); font-size: 0.875rem; }
|
|
396
|
-
.controls button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
|
|
397
|
-
.category { margin-bottom: 2.5rem; }
|
|
398
|
-
.category h2 { font-size: 1.4rem; margin-bottom: 1rem; border-bottom: 2px solid var(--accent); padding-bottom: 0.25rem; }
|
|
399
|
-
.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
|
|
400
|
-
.token-card { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; background: var(--card-bg); }
|
|
401
|
-
.token-name { font-family: 'SF Mono', Monaco, monospace; font-size: 0.8rem; color: var(--accent); cursor: pointer; word-break: break-all; }
|
|
402
|
-
.token-name:hover { text-decoration: underline; }
|
|
403
|
-
.token-values { margin-top: 0.5rem; font-size: 0.85rem; }
|
|
404
|
-
.token-values .mode { display: flex; justify-content: space-between; padding: 0.15rem 0; }
|
|
405
|
-
.token-values .mode-label { color: var(--muted); }
|
|
406
|
-
.token-desc { margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }
|
|
407
|
-
.color-swatch { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border); display: inline-block; vertical-align: middle; margin-right: 0.5rem; }
|
|
408
|
-
.spacing-bar { height: 8px; background: var(--accent); border-radius: 4px; margin-top: 0.25rem; min-width: 2px; }
|
|
409
|
-
.alias-chain { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }
|
|
410
|
-
.shadow-preview { width: 60px; height: 40px; background: var(--bg); border-radius: 6px; margin-top: 0.5rem; }
|
|
411
|
-
.type-specimen { margin-top: 0.5rem; }
|
|
412
|
-
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; padding: 0.5rem 1rem; background: #10b981; color: #fff; border-radius: 6px; font-size: 0.85rem; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
|
|
413
|
-
.toast.show { opacity: 1; }
|
|
414
|
-
.nav-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
|
|
415
|
-
.nav-links a { font-size: 0.85rem; color: var(--accent); text-decoration: none; padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; }
|
|
416
|
-
.nav-links a:hover { background: var(--accent); color: #fff; }
|
|
417
|
-
</style>
|
|
418
|
-
</head>
|
|
419
|
-
<body>
|
|
420
|
-
<h1>Design Token Documentation</h1>
|
|
421
|
-
<p class="meta">Generated: ${date} | Tokens: ${allTokenCount} | Collections: ${collections.length}</p>
|
|
422
|
-
|
|
423
|
-
<div class="controls">
|
|
424
|
-
<input type="text" id="search" placeholder="Search tokens..." oninput="filterTokens()">
|
|
425
|
-
<button onclick="toggleTheme()">Toggle Dark Mode</button>
|
|
426
|
-
</div>
|
|
427
|
-
|
|
428
|
-
<nav class="nav-links">
|
|
429
|
-
${categoryEntries.map(([key, cat]) => ` <a href="#cat-${encodeURIComponent(key)}">${cat.label} (${cat.tokens.length})</a>`).join("\n")}
|
|
430
|
-
</nav>
|
|
431
|
-
|
|
432
|
-
${categoryEntries.map(([key, category]) => {
|
|
433
|
-
const modeNames = category.tokens.length > 0 ? Object.keys(category.tokens[0].values) : [];
|
|
434
|
-
return `<section class="category" id="cat-${encodeURIComponent(key)}">
|
|
435
|
-
<h2>${category.label}</h2>
|
|
436
|
-
<div class="token-grid">
|
|
437
|
-
${category.tokens.map((token) => {
|
|
438
|
-
const isColor = token.resolvedType === "COLOR";
|
|
439
|
-
const isSpacing = /spacing|space|gap|padding|margin/i.test(token.name);
|
|
440
|
-
const isShadow = /shadow|elevation/i.test(token.name);
|
|
441
|
-
const isTypo = /font-size|font-weight|line-height|letter-spacing/i.test(token.name);
|
|
442
|
-
|
|
443
|
-
let extras = "";
|
|
444
|
-
if (isColor && args.includeVisualSwatches !== false) {
|
|
445
|
-
const val = formatValue(Object.values(token.values)[0], "COLOR");
|
|
446
|
-
extras += `<div class="color-swatch" style="background:${val};" title="${val}"></div>`;
|
|
447
|
-
}
|
|
448
|
-
if (isSpacing) {
|
|
449
|
-
const val = Object.values(token.values)[0];
|
|
450
|
-
const px = typeof val === "number" ? val : parseInt(String(val), 10) || 0;
|
|
451
|
-
extras += `<div class="spacing-bar" style="width:${Math.min(px, 200)}px;" title="${px}px"></div>`;
|
|
452
|
-
}
|
|
453
|
-
if (isShadow) {
|
|
454
|
-
extras += `<div class="shadow-preview" style="box-shadow: 0 2px 8px rgba(0,0,0,0.15);"></div>`;
|
|
455
|
-
}
|
|
456
|
-
if (isTypo) {
|
|
457
|
-
const val = Object.values(token.values)[0];
|
|
458
|
-
extras += `<div class="type-specimen" style="font-size:${typeof val === "number" ? val + "px" : val};">Aa Bb Cc 123</div>`;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
const aliasHtml = token.aliasOf ? `<div class="alias-chain">Alias of: ${token.aliasOf}</div>` : "";
|
|
462
|
-
const chainHtml = token.aliasChain ? `<div class="alias-chain">Chain: ${token.aliasChain.join(" -> ")}</div>` : "";
|
|
463
|
-
|
|
464
|
-
return ` <div class="token-card" data-name="${token.name.toLowerCase()}">
|
|
465
|
-
<div class="token-name" onclick="copyToken('${token.name}')">${token.name}</div>
|
|
466
|
-
${extras}
|
|
467
|
-
<div class="token-values">
|
|
468
|
-
${modeNames.map((mode) => ` <div class="mode"><span class="mode-label">${mode}:</span> <span>${formatValue(token.values[mode], token.resolvedType)}</span></div>`).join("\n")}
|
|
469
|
-
</div>
|
|
470
|
-
${aliasHtml}${chainHtml}
|
|
471
|
-
${token.description ? `<div class="token-desc">${token.description}</div>` : ""}
|
|
472
|
-
</div>`;
|
|
473
|
-
}).join("\n")}
|
|
474
|
-
</div>
|
|
475
|
-
</section>`;
|
|
476
|
-
}).join("\n\n")}
|
|
477
|
-
|
|
478
|
-
<div class="toast" id="toast">Copied!</div>
|
|
479
|
-
|
|
480
|
-
<script>
|
|
481
|
-
function toggleTheme() {
|
|
482
|
-
const current = document.documentElement.getAttribute('data-theme');
|
|
483
|
-
document.documentElement.setAttribute('data-theme', current === 'dark' ? '' : 'dark');
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function filterTokens() {
|
|
487
|
-
const q = document.getElementById('search').value.toLowerCase();
|
|
488
|
-
document.querySelectorAll('.token-card').forEach(card => {
|
|
489
|
-
const name = card.getAttribute('data-name') || '';
|
|
490
|
-
card.style.display = name.includes(q) ? '' : 'none';
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function copyToken(name) {
|
|
495
|
-
navigator.clipboard.writeText(name).then(() => {
|
|
496
|
-
const toast = document.getElementById('toast');
|
|
497
|
-
toast.classList.add('show');
|
|
498
|
-
setTimeout(() => toast.classList.remove('show'), 1500);
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
</script>
|
|
502
|
-
</body>
|
|
503
|
-
</html>`;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function renderFigmaPluginCode(
|
|
507
|
-
categories: Map<string, TokenCategory>,
|
|
508
|
-
_collections: RawCollection[],
|
|
509
|
-
_allTokenCount: number,
|
|
510
|
-
args: TokenDocsArgs
|
|
511
|
-
): string {
|
|
512
|
-
const pageName = args.pageName || "Token Documentation";
|
|
513
|
-
const categoryEntries = Array.from(categories.entries());
|
|
514
|
-
|
|
515
|
-
// Build Plugin API code string to be executed via bridge.execute()
|
|
516
|
-
const lines: string[] = [];
|
|
517
|
-
lines.push(`(async () => {`);
|
|
518
|
-
lines.push(` // Create or find documentation page`);
|
|
519
|
-
lines.push(` let page = figma.root.children.find(p => p.name === ${JSON.stringify(pageName)});`);
|
|
520
|
-
lines.push(` if (!page) {`);
|
|
521
|
-
lines.push(` page = figma.createPage();`);
|
|
522
|
-
lines.push(` page.name = ${JSON.stringify(pageName)};`);
|
|
523
|
-
lines.push(` }`);
|
|
524
|
-
lines.push(` figma.currentPage = page;`);
|
|
525
|
-
lines.push(``);
|
|
526
|
-
lines.push(` // Clear existing content on the page`);
|
|
527
|
-
lines.push(` for (const child of [...page.children]) child.remove();`);
|
|
528
|
-
lines.push(``);
|
|
529
|
-
lines.push(` // Root frame with auto layout`);
|
|
530
|
-
lines.push(` const root = figma.createFrame();`);
|
|
531
|
-
lines.push(` root.name = "Token Documentation";`);
|
|
532
|
-
lines.push(` root.layoutMode = "VERTICAL";`);
|
|
533
|
-
lines.push(` root.primaryAxisSizingMode = "AUTO";`);
|
|
534
|
-
lines.push(` root.counterAxisSizingMode = "AUTO";`);
|
|
535
|
-
lines.push(` root.itemSpacing = 48;`);
|
|
536
|
-
lines.push(` root.paddingTop = 40;`);
|
|
537
|
-
lines.push(` root.paddingBottom = 40;`);
|
|
538
|
-
lines.push(` root.paddingLeft = 40;`);
|
|
539
|
-
lines.push(` root.paddingRight = 40;`);
|
|
540
|
-
lines.push(` root.fills = [{ type: "SOLID", color: { r: 1, g: 1, b: 1 } }];`);
|
|
541
|
-
lines.push(` page.appendChild(root);`);
|
|
542
|
-
lines.push(``);
|
|
543
|
-
lines.push(` // Helper: create text node`);
|
|
544
|
-
lines.push(` async function makeText(content, fontSize, isBold) {`);
|
|
545
|
-
lines.push(` const t = figma.createText();`);
|
|
546
|
-
lines.push(` await figma.loadFontAsync({ family: "Inter", style: isBold ? "Bold" : "Regular" });`);
|
|
547
|
-
lines.push(` t.fontName = { family: "Inter", style: isBold ? "Bold" : "Regular" };`);
|
|
548
|
-
lines.push(` t.fontSize = fontSize;`);
|
|
549
|
-
lines.push(` t.characters = content;`);
|
|
550
|
-
lines.push(` return t;`);
|
|
551
|
-
lines.push(` }`);
|
|
552
|
-
lines.push(``);
|
|
553
|
-
lines.push(` // Title`);
|
|
554
|
-
lines.push(` const title = await makeText("Design Token Documentation", 32, true);`);
|
|
555
|
-
lines.push(` root.appendChild(title);`);
|
|
556
|
-
lines.push(``);
|
|
557
|
-
|
|
558
|
-
for (const [key, category] of categoryEntries) {
|
|
559
|
-
const safeKey = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
560
|
-
lines.push(` // ── ${category.label} ──`);
|
|
561
|
-
lines.push(` const section_${safeKey} = figma.createFrame();`);
|
|
562
|
-
lines.push(` section_${safeKey}.name = "Section: ${category.label}";`);
|
|
563
|
-
lines.push(` section_${safeKey}.layoutMode = "VERTICAL";`);
|
|
564
|
-
lines.push(` section_${safeKey}.primaryAxisSizingMode = "AUTO";`);
|
|
565
|
-
lines.push(` section_${safeKey}.counterAxisSizingMode = "AUTO";`);
|
|
566
|
-
lines.push(` section_${safeKey}.itemSpacing = 16;`);
|
|
567
|
-
lines.push(` section_${safeKey}.fills = [];`);
|
|
568
|
-
lines.push(` root.appendChild(section_${safeKey});`);
|
|
569
|
-
lines.push(``);
|
|
570
|
-
lines.push(` const header_${safeKey} = await makeText(${JSON.stringify(category.label)}, 24, true);`);
|
|
571
|
-
lines.push(` section_${safeKey}.appendChild(header_${safeKey});`);
|
|
572
|
-
lines.push(``);
|
|
573
|
-
|
|
574
|
-
// Token grid frame
|
|
575
|
-
lines.push(` const grid_${safeKey} = figma.createFrame();`);
|
|
576
|
-
lines.push(` grid_${safeKey}.name = "Tokens: ${category.label}";`);
|
|
577
|
-
lines.push(` grid_${safeKey}.layoutMode = "HORIZONTAL";`);
|
|
578
|
-
lines.push(` grid_${safeKey}.layoutWrap = "WRAP";`);
|
|
579
|
-
lines.push(` grid_${safeKey}.primaryAxisSizingMode = "FIXED";`);
|
|
580
|
-
lines.push(` grid_${safeKey}.resize(1000, 10);`);
|
|
581
|
-
lines.push(` grid_${safeKey}.counterAxisSizingMode = "AUTO";`);
|
|
582
|
-
lines.push(` grid_${safeKey}.itemSpacing = 12;`);
|
|
583
|
-
lines.push(` grid_${safeKey}.counterAxisSpacing = 12;`);
|
|
584
|
-
lines.push(` grid_${safeKey}.fills = [];`);
|
|
585
|
-
lines.push(` section_${safeKey}.appendChild(grid_${safeKey});`);
|
|
586
|
-
lines.push(``);
|
|
587
|
-
|
|
588
|
-
for (let i = 0; i < category.tokens.length; i++) {
|
|
589
|
-
const token = category.tokens[i];
|
|
590
|
-
const isColor = token.resolvedType === "COLOR";
|
|
591
|
-
const firstModeValue = Object.values(token.values)[0];
|
|
592
|
-
const modeNames = Object.keys(token.values);
|
|
593
|
-
const tId = `${safeKey}_t${i}`;
|
|
594
|
-
|
|
595
|
-
lines.push(` {`);
|
|
596
|
-
lines.push(` const card = figma.createFrame();`);
|
|
597
|
-
lines.push(` card.name = ${JSON.stringify(token.name)};`);
|
|
598
|
-
lines.push(` card.layoutMode = "VERTICAL";`);
|
|
599
|
-
lines.push(` card.primaryAxisSizingMode = "AUTO";`);
|
|
600
|
-
lines.push(` card.counterAxisSizingMode = "FIXED";`);
|
|
601
|
-
lines.push(` card.resize(200, 10);`);
|
|
602
|
-
lines.push(` card.itemSpacing = 4;`);
|
|
603
|
-
lines.push(` card.paddingTop = 8; card.paddingBottom = 8; card.paddingLeft = 8; card.paddingRight = 8;`);
|
|
604
|
-
lines.push(` card.cornerRadius = 8;`);
|
|
605
|
-
lines.push(` card.fills = [{ type: "SOLID", color: { r: 0.96, g: 0.96, b: 0.97 } }];`);
|
|
606
|
-
|
|
607
|
-
// Color swatch
|
|
608
|
-
if (isColor && args.includeVisualSwatches !== false) {
|
|
609
|
-
const colorVal = firstModeValue as { r?: number; g?: number; b?: number } | undefined;
|
|
610
|
-
if (colorVal && typeof colorVal === "object" && "r" in colorVal) {
|
|
611
|
-
lines.push(` const swatch = figma.createRectangle();`);
|
|
612
|
-
lines.push(` swatch.resize(184, 40);`);
|
|
613
|
-
lines.push(` swatch.cornerRadius = 4;`);
|
|
614
|
-
lines.push(` swatch.fills = [{ type: "SOLID", color: { r: ${colorVal.r}, g: ${colorVal.g}, b: ${colorVal.b} } }];`);
|
|
615
|
-
lines.push(` card.appendChild(swatch);`);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
lines.push(` const label = await makeText(${JSON.stringify(token.name)}, 11, true);`);
|
|
620
|
-
lines.push(` card.appendChild(label);`);
|
|
621
|
-
|
|
622
|
-
// Show values per mode
|
|
623
|
-
for (const mode of modeNames) {
|
|
624
|
-
const val = formatValue(token.values[mode], token.resolvedType);
|
|
625
|
-
lines.push(` const val_${mode.replace(/[^a-zA-Z0-9]/g, "_")} = await makeText("${mode}: ${val.replace(/"/g, '\\"')}", 10, false);`);
|
|
626
|
-
lines.push(` card.appendChild(val_${mode.replace(/[^a-zA-Z0-9]/g, "_")});`);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
lines.push(` grid_${safeKey}.appendChild(card);`);
|
|
630
|
-
lines.push(` }`);
|
|
631
|
-
lines.push(``);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
lines.push(` figma.viewport.scrollAndZoomIntoView([root]);`);
|
|
636
|
-
lines.push(` return { success: true, page: page.name, nodeId: root.id };`);
|
|
637
|
-
lines.push(`})();`);
|
|
638
|
-
|
|
639
|
-
return lines.join("\n");
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// ─── Main Handler ───────────────────────────────────────────────────────────
|
|
643
|
-
|
|
644
|
-
export async function tokenDocsHandler(args: TokenDocsArgs): Promise<unknown> {
|
|
645
|
-
const notes: string[] = [];
|
|
646
|
-
const { categories, collections, allTokenCount } = await fetchAndOrganizeTokens(args);
|
|
647
|
-
|
|
648
|
-
if (allTokenCount === 0) {
|
|
649
|
-
return {
|
|
650
|
-
ok: true,
|
|
651
|
-
format: args.outputFormat,
|
|
652
|
-
tokenCount: 0,
|
|
653
|
-
collectionCount: collections.length,
|
|
654
|
-
categoryCount: 0,
|
|
655
|
-
output: args.outputFormat === "json" ? { generatedAt: todayStamp(), totalTokens: 0, collections: [], categories: {} } : "No tokens found.",
|
|
656
|
-
notes: ["No variables found in the current Figma file. Ensure variables exist and the bridge plugin is running."],
|
|
657
|
-
} satisfies TokenDocsResult;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
notes.push(`Found ${allTokenCount} tokens across ${collections.length} collection(s) in ${categories.size} categor${categories.size === 1 ? "y" : "ies"}.`);
|
|
661
|
-
|
|
662
|
-
let output: string | TokenDocsJsonOutput;
|
|
663
|
-
|
|
664
|
-
switch (args.outputFormat) {
|
|
665
|
-
case "markdown":
|
|
666
|
-
output = renderMarkdown(categories, collections, allTokenCount, args);
|
|
667
|
-
break;
|
|
668
|
-
|
|
669
|
-
case "json":
|
|
670
|
-
output = renderJson(categories, collections, allTokenCount, args);
|
|
671
|
-
break;
|
|
672
|
-
|
|
673
|
-
case "html":
|
|
674
|
-
output = renderHtml(categories, collections, allTokenCount, args);
|
|
675
|
-
break;
|
|
676
|
-
|
|
677
|
-
case "figma": {
|
|
678
|
-
const pluginCode = renderFigmaPluginCode(categories, collections, allTokenCount, args);
|
|
679
|
-
const bridge = await getBridge();
|
|
680
|
-
const result = await bridge.execute(pluginCode);
|
|
681
|
-
if (!result.success) {
|
|
682
|
-
return {
|
|
683
|
-
ok: false,
|
|
684
|
-
format: "figma",
|
|
685
|
-
tokenCount: allTokenCount,
|
|
686
|
-
collectionCount: collections.length,
|
|
687
|
-
categoryCount: categories.size,
|
|
688
|
-
output: `Figma plugin execution failed: ${JSON.stringify(result)}`,
|
|
689
|
-
notes: ["The Plugin API code failed to execute. Check that Figma is open and the bridge plugin is active."],
|
|
690
|
-
} satisfies TokenDocsResult;
|
|
691
|
-
}
|
|
692
|
-
output = `Documentation page created in Figma. ${JSON.stringify(result.result)}`;
|
|
693
|
-
notes.push("Created Figma documentation page with token swatches, labels, and values.");
|
|
694
|
-
break;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
default:
|
|
698
|
-
throw new Error(`Unsupported output format: ${args.outputFormat}`);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
return {
|
|
702
|
-
ok: true,
|
|
703
|
-
format: args.outputFormat,
|
|
704
|
-
tokenCount: allTokenCount,
|
|
705
|
-
collectionCount: collections.length,
|
|
706
|
-
categoryCount: categories.size,
|
|
707
|
-
output,
|
|
708
|
-
notes,
|
|
709
|
-
} satisfies TokenDocsResult;
|
|
710
|
-
}
|