@sarjallab09/figma-intelligence 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -36
- package/dist/bin/cli.js +2 -0
- package/dist/design-bridge/bridge.js +2 -0
- package/dist/figma-bridge-plugin/bridge-relay.js +2 -0
- package/dist/figma-bridge-plugin/code.js +1 -0
- package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package-lock.json +0 -3
- package/dist/figma-bridge-plugin/ui.html +4970 -0
- package/dist/figma-intelligence-layer/dist/index.js +2 -0
- package/dist/scripts/clean-existing-chunks.js +2 -0
- package/dist/scripts/connect-ai-tool.js +2 -0
- package/dist/scripts/convert-hub-pdfs.js +2 -0
- package/dist/scripts/figma-mcp-status.js +2 -0
- package/dist/scripts/register-codex-mcp.js +2 -0
- package/dist/scripts/test-copilot-chat.js +2 -0
- package/package.json +11 -8
- package/bin/cli.js +0 -859
- package/design-bridge/bridge.js +0 -196
- package/design-bridge/lib/assets.js +0 -367
- package/design-bridge/lib/prompt.js +0 -85
- package/design-bridge/lib/server.js +0 -66
- package/design-bridge/lib/stitch.js +0 -37
- package/design-bridge/lib/tokens.js +0 -82
- package/design-bridge/package-lock.json +0 -579
- package/figma-bridge-plugin/README.md +0 -97
- package/figma-bridge-plugin/anthropic-chat-runner.js +0 -192
- package/figma-bridge-plugin/bridge-relay.js +0 -2363
- package/figma-bridge-plugin/chat-runner.js +0 -459
- package/figma-bridge-plugin/code.js +0 -1528
- package/figma-bridge-plugin/codex-runner.js +0 -505
- package/figma-bridge-plugin/component-schemas.js +0 -110
- package/figma-bridge-plugin/content-context.js +0 -869
- package/figma-bridge-plugin/create-button.js +0 -216
- package/figma-bridge-plugin/gemini-cli-runner.js +0 -291
- package/figma-bridge-plugin/gemini-runner.js +0 -187
- package/figma-bridge-plugin/html-to-figma.js +0 -927
- package/figma-bridge-plugin/knowledge-hub/.gitkeep +0 -0
- package/figma-bridge-plugin/knowledge-hub/uspec-references/anatomy-spec.md +0 -159
- package/figma-bridge-plugin/knowledge-hub/uspec-references/api-spec.md +0 -162
- package/figma-bridge-plugin/knowledge-hub/uspec-references/color-spec.md +0 -148
- package/figma-bridge-plugin/knowledge-hub/uspec-references/full-spec-template.md +0 -314
- package/figma-bridge-plugin/knowledge-hub/uspec-references/property-spec.md +0 -175
- package/figma-bridge-plugin/knowledge-hub/uspec-references/screen-reader-spec.md +0 -180
- package/figma-bridge-plugin/knowledge-hub/uspec-references/structure-spec.md +0 -165
- package/figma-bridge-plugin/perplexity-runner.js +0 -188
- package/figma-bridge-plugin/references/SKILL.md +0 -178
- package/figma-bridge-plugin/references/anatomy-spec.md +0 -159
- package/figma-bridge-plugin/references/api-spec.md +0 -162
- package/figma-bridge-plugin/references/color-spec.md +0 -148
- package/figma-bridge-plugin/references/full-spec-template.md +0 -314
- package/figma-bridge-plugin/references/property-spec.md +0 -175
- package/figma-bridge-plugin/references/screen-reader-spec.md +0 -180
- package/figma-bridge-plugin/references/structure-spec.md +0 -165
- package/figma-bridge-plugin/shared-prompt-config.js +0 -604
- package/figma-bridge-plugin/spec-helpers/build-table.js +0 -269
- package/figma-bridge-plugin/spec-helpers/classify-elements.js +0 -189
- package/figma-bridge-plugin/spec-helpers/index.js +0 -35
- package/figma-bridge-plugin/spec-helpers/parse-figma-link.js +0 -49
- package/figma-bridge-plugin/spec-helpers/position-markers.js +0 -158
- package/figma-bridge-plugin/stitch-auth.js +0 -322
- package/figma-bridge-plugin/stitch-runner.js +0 -1427
- package/figma-bridge-plugin/token-resolver.js +0 -107
- package/figma-bridge-plugin/ui.html +0 -4467
- package/figma-intelligence-layer/.env.example +0 -39
- package/figma-intelligence-layer/docs/local-image-generation.md +0 -60
- package/figma-intelligence-layer/examples/comfyui-workflow-template.example.json +0 -101
- package/figma-intelligence-layer/jest.config.js +0 -14
- package/figma-intelligence-layer/mcp-config.json +0 -19
- package/figma-intelligence-layer/package-lock.json +0 -5892
- package/figma-intelligence-layer/scripts/setup-comfyui-local.sh +0 -67
- package/figma-intelligence-layer/scripts/start-comfyui.sh +0 -33
- package/figma-intelligence-layer/src/index.ts +0 -2233
- package/figma-intelligence-layer/src/shared/auto-layout-validator.ts +0 -404
- package/figma-intelligence-layer/src/shared/cache.ts +0 -187
- package/figma-intelligence-layer/src/shared/color-operations.ts +0 -533
- package/figma-intelligence-layer/src/shared/color-utils.ts +0 -138
- package/figma-intelligence-layer/src/shared/component-script-builder.ts +0 -413
- package/figma-intelligence-layer/src/shared/component-templates.ts +0 -2767
- package/figma-intelligence-layer/src/shared/concept-taxonomy.ts +0 -694
- package/figma-intelligence-layer/src/shared/decision-log.ts +0 -128
- package/figma-intelligence-layer/src/shared/design-system-context.ts +0 -568
- package/figma-intelligence-layer/src/shared/design-system-intelligence.ts +0 -131
- package/figma-intelligence-layer/src/shared/design-system-matcher.ts +0 -184
- package/figma-intelligence-layer/src/shared/design-system-normalizers.ts +0 -196
- package/figma-intelligence-layer/src/shared/design-system-tokens.ts +0 -295
- package/figma-intelligence-layer/src/shared/dtcg-validator.ts +0 -530
- package/figma-intelligence-layer/src/shared/enrichment-pipeline.ts +0 -671
- package/figma-intelligence-layer/src/shared/figma-bridge.ts +0 -1408
- package/figma-intelligence-layer/src/shared/font-config.ts +0 -126
- package/figma-intelligence-layer/src/shared/icon-catalog.ts +0 -360
- package/figma-intelligence-layer/src/shared/icon-fetch.ts +0 -80
- package/figma-intelligence-layer/src/shared/prototype-script-builder.ts +0 -162
- package/figma-intelligence-layer/src/shared/response-compression.ts +0 -440
- package/figma-intelligence-layer/src/shared/semantic-token-catalog.ts +0 -324
- package/figma-intelligence-layer/src/shared/token-binder.ts +0 -505
- package/figma-intelligence-layer/src/shared/token-math.ts +0 -427
- package/figma-intelligence-layer/src/shared/token-naming.ts +0 -468
- package/figma-intelligence-layer/src/shared/token-utils.ts +0 -420
- package/figma-intelligence-layer/src/shared/types.ts +0 -346
- package/figma-intelligence-layer/src/shared/typography-presets.ts +0 -94
- package/figma-intelligence-layer/src/shared/unsplash.ts +0 -165
- package/figma-intelligence-layer/src/shared/vision-client.ts +0 -607
- package/figma-intelligence-layer/src/shared/vision-provider-anthropic.ts +0 -334
- package/figma-intelligence-layer/src/shared/vision-provider-openai.ts +0 -446
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-handler.ts +0 -782
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-renderer.ts +0 -496
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotation-kit.ts +0 -230
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/colorblind-sim.ts +0 -66
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/index.ts +0 -810
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-analyzer.ts +0 -1191
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-figma-page.ts +0 -1346
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-handler.ts +0 -148
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-figma-page.ts +0 -499
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-report.ts +0 -910
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-checker.ts +0 -989
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-criteria.ts +0 -1160
- package/figma-intelligence-layer/src/tools/phase1-vision/design-from-ref/index.ts +0 -424
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/component-recognizer.ts +0 -38
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/ds-matcher.ts +0 -111
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/font-matcher.ts +0 -114
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/icon-resolver.ts +0 -103
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/index.ts +0 -1060
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/layout-segmenter.ts +0 -18
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/token-inferencer.ts +0 -39
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/vision-pipeline.ts +0 -58
- package/figma-intelligence-layer/src/tools/phase1-vision/sketch-to-design/index.ts +0 -298
- package/figma-intelligence-layer/src/tools/phase1-vision/visual-audit/index.ts +0 -197
- package/figma-intelligence-layer/src/tools/phase2-accuracy/component-audit/index.ts +0 -494
- package/figma-intelligence-layer/src/tools/phase2-accuracy/intent-translator/index.ts +0 -356
- package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/container-patterns.ts +0 -123
- package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/index.ts +0 -663
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/built-in-rules.yaml +0 -56
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/index.ts +0 -614
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/rule-engine.ts +0 -113
- package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/color-theory.ts +0 -178
- package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/index.ts +0 -470
- package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/index.ts +0 -429
- package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/token-override-maps.ts +0 -226
- package/figma-intelligence-layer/src/tools/phase3-generation/ai-image-insert/index.ts +0 -535
- package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts +0 -660
- package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/pattern-fingerprints.ts +0 -209
- package/figma-intelligence-layer/src/tools/phase3-generation/composition-builder/index.ts +0 -540
- package/figma-intelligence-layer/src/tools/phase3-generation/figma-animated-build.ts +0 -391
- package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/index.ts +0 -2019
- package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts +0 -131
- package/figma-intelligence-layer/src/tools/phase3-generation/prototype-map/index.ts +0 -381
- package/figma-intelligence-layer/src/tools/phase3-generation/prototype-wire/index.ts +0 -565
- package/figma-intelligence-layer/src/tools/phase3-generation/swarm-build/index.ts +0 -764
- package/figma-intelligence-layer/src/tools/phase3-generation/system-drift/index.ts +0 -535
- package/figma-intelligence-layer/src/tools/phase3-generation/unsplash-search/index.ts +0 -84
- package/figma-intelligence-layer/src/tools/phase3-generation/url-to-frame/index.ts +0 -401
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/css-animations.ts +0 -68
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/framer-motion.ts +0 -78
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/swift-animations.ts +0 -93
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/index.ts +0 -596
- package/figma-intelligence-layer/src/tools/phase4-sync/ci-check/index.ts +0 -462
- package/figma-intelligence-layer/src/tools/phase4-sync/export-tokens/index.ts +0 -1470
- package/figma-intelligence-layer/src/tools/phase4-sync/generate-component-code/index.ts +0 -829
- package/figma-intelligence-layer/src/tools/phase4-sync/handoff-spec/index.ts +0 -702
- package/figma-intelligence-layer/src/tools/phase4-sync/icon-library-sync/index.ts +0 -483
- package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/index.ts +0 -501
- package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/storybook-parser.ts +0 -106
- package/figma-intelligence-layer/src/tools/phase4-sync/watch-docs/index.ts +0 -676
- package/figma-intelligence-layer/src/tools/phase4-sync/webhook-listener/index.ts +0 -560
- package/figma-intelligence-layer/src/tools/phase5-governance/apg-doc/index.ts +0 -1043
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/component-detection.ts +0 -620
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/anatomy.ts +0 -331
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/color-tokens.ts +0 -77
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/properties.ts +0 -54
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/snapshot.ts +0 -287
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/spacing.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/states.ts +0 -43
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/typography.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/index.ts +0 -221
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/_default.ts +0 -166
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/accordion.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/alert.ts +0 -234
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar-group.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar.ts +0 -249
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/badge.ts +0 -231
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/banner.ts +0 -293
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/breadcrumb.ts +0 -240
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/button.ts +0 -243
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/calendar.ts +0 -307
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/card.ts +0 -143
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/checkbox.ts +0 -227
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/chip.ts +0 -233
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/combobox.ts +0 -282
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/datepicker.ts +0 -276
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/divider.ts +0 -223
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/drawer.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/dropdown-menu.ts +0 -289
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/empty-state.ts +0 -261
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/file-uploader.ts +0 -290
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/form.ts +0 -265
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/grid.ts +0 -238
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/icon.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/index.ts +0 -128
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-edit.ts +0 -286
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-message.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/input.ts +0 -330
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/link.ts +0 -247
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/list.ts +0 -250
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/menu.ts +0 -247
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/modal.ts +0 -144
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navbar.ts +0 -264
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navigation.ts +0 -251
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/number-input.ts +0 -261
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/pagination.ts +0 -248
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/popover.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/progress.ts +0 -251
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/radio.ts +0 -142
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/range-slider.ts +0 -282
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/rating.ts +0 -250
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/search.ts +0 -258
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/segmented-control.ts +0 -265
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/select.ts +0 -319
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/skeleton.ts +0 -256
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/slider.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/spinner.ts +0 -239
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/status-dot.ts +0 -252
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/stepper.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/table.ts +0 -244
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tabs.ts +0 -143
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tag.ts +0 -243
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/textarea.ts +0 -259
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/time-picker.ts +0 -293
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toast.ts +0 -144
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toggle.ts +0 -289
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toolbar.ts +0 -267
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tooltip.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/treeview.ts +0 -257
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/typography.ts +0 -319
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/legacy-compat.ts +0 -121
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/anatomy-diagram.ts +0 -430
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/figma-page.ts +0 -312
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/json.ts +0 -129
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/markdown.ts +0 -78
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/visual-doc.ts +0 -2333
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/accessibility.ts +0 -100
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/anatomy.ts +0 -32
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/color-tokens.ts +0 -59
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/content-guidance.ts +0 -18
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/design-tokens.ts +0 -53
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/interaction-rules.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/overview.ts +0 -91
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/properties-api.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/qa-criteria.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/related-components.ts +0 -110
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/responsive.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/size-specs.ts +0 -67
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/spacing-structure.ts +0 -58
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/state-specs.ts +0 -79
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/states.ts +0 -50
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/type-hierarchy.ts +0 -33
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/typography.ts +0 -55
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/usage-guidelines.ts +0 -73
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/variants.ts +0 -81
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/types.ts +0 -409
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/index.ts +0 -198
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/renderer.ts +0 -701
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/types.ts +0 -88
- package/figma-intelligence-layer/src/tools/phase5-governance/decision-log/index.ts +0 -135
- package/figma-intelligence-layer/src/tools/phase5-governance/design-decision-log/index.ts +0 -491
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-primitives/index.ts +0 -416
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-scaffolder/index.ts +0 -722
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-variables/index.ts +0 -449
- package/figma-intelligence-layer/src/tools/phase5-governance/health-report/index.ts +0 -393
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/index.ts +0 -406
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts +0 -292
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/json.ts +0 -24
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/markdown.ts +0 -172
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/naming-guide.ts +0 -409
- package/figma-intelligence-layer/src/tools/phase5-governance/token-analytics/index.ts +0 -594
- package/figma-intelligence-layer/src/tools/phase5-governance/token-docs/index.ts +0 -710
- package/figma-intelligence-layer/src/tools/phase5-governance/token-migrate/index.ts +0 -458
- package/figma-intelligence-layer/src/tools/phase5-governance/token-naming/index.ts +0 -134
- package/figma-intelligence-layer/tests/apg-doc.test.ts +0 -101
- package/figma-intelligence-layer/tests/design-system-context.test.ts +0 -152
- package/figma-intelligence-layer/tests/design-system-matcher.test.ts +0 -144
- package/figma-intelligence-layer/tests/figma-bridge.test.ts +0 -83
- package/figma-intelligence-layer/tests/generate-image-and-insert.test.ts +0 -56
- package/figma-intelligence-layer/tests/screen-cloner-regression.test.ts +0 -69
- package/figma-intelligence-layer/tests/smoke.test.ts +0 -174
- package/figma-intelligence-layer/tests/spec-generator.test.ts +0 -127
- package/figma-intelligence-layer/tests/token-migrate.test.ts +0 -21
- package/figma-intelligence-layer/tests/token-naming.test.ts +0 -30
- package/figma-intelligence-layer/tsconfig.json +0 -19
- package/scripts/clean-existing-chunks.js +0 -179
- package/scripts/connect-ai-tool.js +0 -490
- package/scripts/convert-hub-pdfs.js +0 -425
- package/scripts/figma-mcp-status.js +0 -349
- package/scripts/register-codex-mcp.js +0 -96
- /package/{design-bridge → dist/design-bridge}/.env.example +0 -0
- /package/{design-bridge → dist/design-bridge}/package.json +0 -0
- /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/manifest.json +0 -0
- /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package.json +0 -0
- /package/{figma-intelligence-layer → dist/figma-intelligence-layer}/package.json +0 -0
package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// Screen Templates
|
|
3
|
-
// Built-in screen template definitions used by the page-architect tool.
|
|
4
|
-
// Each template maps a screen category to required DS components,
|
|
5
|
-
// layout patterns, and keywords for auto-detection.
|
|
6
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
-
|
|
8
|
-
export type ScreenTemplate =
|
|
9
|
-
| "auth"
|
|
10
|
-
| "dashboard"
|
|
11
|
-
| "list"
|
|
12
|
-
| "detail"
|
|
13
|
-
| "settings"
|
|
14
|
-
| "onboarding"
|
|
15
|
-
| "checkout-cart"
|
|
16
|
-
| "checkout-address"
|
|
17
|
-
| "checkout-shipping"
|
|
18
|
-
| "checkout-payment"
|
|
19
|
-
| "checkout-review"
|
|
20
|
-
| "checkout-success"
|
|
21
|
-
| "generic";
|
|
22
|
-
|
|
23
|
-
export interface TemplateDefinition {
|
|
24
|
-
template: ScreenTemplate;
|
|
25
|
-
keywords: string[];
|
|
26
|
-
components: string[];
|
|
27
|
-
layoutPattern: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Built-in screen templates (from plan):
|
|
32
|
-
* Auth: Login, Register, Forgot Password, OTP, Reset Password
|
|
33
|
-
* Onboarding: Welcome, Feature Tour, Permissions, Profile Setup, Success
|
|
34
|
-
* Core App: Dashboard, List View, Detail View, Settings, Profile, Notifications
|
|
35
|
-
* E-commerce: PLP, PDP, Cart, Checkout, Order Confirmation
|
|
36
|
-
* Data: Table View, Chart Dashboard, Empty State, Filter Panel
|
|
37
|
-
* SaaS: Pricing, Trial Signup, Team Invite, Workspace, Billing
|
|
38
|
-
*/
|
|
39
|
-
export const SCREEN_TEMPLATES: TemplateDefinition[] = [
|
|
40
|
-
{
|
|
41
|
-
template: "auth",
|
|
42
|
-
keywords: ["login", "sign in", "signup", "register", "auth", "password", "email", "forgot", "otp", "reset"],
|
|
43
|
-
components: ["TextInput", "Button", "Heading", "Link"],
|
|
44
|
-
layoutPattern: "Centered single-column with email + password inputs and primary CTA",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
template: "dashboard",
|
|
48
|
-
keywords: ["dashboard", "home", "overview", "main", "hub", "analytics", "stats"],
|
|
49
|
-
components: ["Navigation", "Header", "Card", "Chart", "Badge"],
|
|
50
|
-
layoutPattern: "Sidebar nav + top header + main content grid",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
template: "list",
|
|
54
|
-
keywords: ["list", "feed", "search", "browse", "explore", "results", "index", "directory", "catalog"],
|
|
55
|
-
components: ["SearchBar", "Filter", "ListItem", "Pagination"],
|
|
56
|
-
layoutPattern: "Search/filter header + scrollable list of items",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
template: "detail",
|
|
60
|
-
keywords: ["detail", "view", "show", "profile", "product", "article", "post", "item"],
|
|
61
|
-
components: ["Image", "Heading", "Body", "Button", "ActionBar"],
|
|
62
|
-
layoutPattern: "Hero image + content area + sticky action bar",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
template: "settings",
|
|
66
|
-
keywords: ["settings", "preferences", "account", "profile edit", "configuration", "options", "billing"],
|
|
67
|
-
components: ["SectionHeader", "FormField", "Toggle", "Button"],
|
|
68
|
-
layoutPattern: "Grouped form sections with labels and inputs",
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
template: "onboarding",
|
|
72
|
-
keywords: ["onboarding", "welcome", "intro", "get started", "tutorial", "step", "walkthrough", "tour"],
|
|
73
|
-
components: ["Illustration", "Heading", "Body", "Button", "StepIndicator"],
|
|
74
|
-
layoutPattern: "Full-bleed illustration + centered heading + body + next button",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
template: "checkout-cart",
|
|
78
|
-
keywords: ["cart", "bag", "basket"],
|
|
79
|
-
components: ["Navigation", "ProductCard", "QuantityStepper", "PromoCode", "OrderSummary", "Button"],
|
|
80
|
-
layoutPattern: "Product list with summary card and bottom CTA",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
template: "checkout-address",
|
|
84
|
-
keywords: ["address", "delivery address", "shipping address"],
|
|
85
|
-
components: ["Navigation", "AddressCard", "TextInput", "Button"],
|
|
86
|
-
layoutPattern: "Saved address selection with editable delivery form",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
template: "checkout-shipping",
|
|
90
|
-
keywords: ["shipping", "delivery", "method"],
|
|
91
|
-
components: ["Navigation", "RadioOption", "OrderSummary", "Button"],
|
|
92
|
-
layoutPattern: "Shipping method options with delivery ETA and summary",
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
template: "checkout-payment",
|
|
96
|
-
keywords: ["payment", "card", "billing", "wallet"],
|
|
97
|
-
components: ["Navigation", "PaymentMethodRow", "TextInput", "Button"],
|
|
98
|
-
layoutPattern: "Saved payment methods, billing fields, and trust messaging",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
template: "checkout-review",
|
|
102
|
-
keywords: ["review", "confirm", "place order", "order review"],
|
|
103
|
-
components: ["Navigation", "OrderSummary", "AddressCard", "PaymentMethodRow", "Button"],
|
|
104
|
-
layoutPattern: "Sectioned review screen with final totals and place-order CTA",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
template: "checkout-success",
|
|
108
|
-
keywords: ["success", "confirmation", "complete", "thank you"],
|
|
109
|
-
components: ["Illustration", "Heading", "OrderSummary", "Button"],
|
|
110
|
-
layoutPattern: "Confirmation state with receipt summary and next steps",
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Detect which template best matches a screen name/description.
|
|
116
|
-
* Returns the matching TemplateDefinition or null.
|
|
117
|
-
*/
|
|
118
|
-
export function detectTemplate(nameOrDescription: string): TemplateDefinition | null {
|
|
119
|
-
const text = nameOrDescription.toLowerCase();
|
|
120
|
-
return (
|
|
121
|
-
SCREEN_TEMPLATES.find((t) =>
|
|
122
|
-
t.keywords.some((kw) => text.includes(kw))
|
|
123
|
-
) ?? null
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** Get the default components list for a screen template. */
|
|
128
|
-
export function componentsForTemplate(template: ScreenTemplate): string[] {
|
|
129
|
-
const def = SCREEN_TEMPLATES.find((t) => t.template === template);
|
|
130
|
-
return def?.components ?? ["Heading", "Button"];
|
|
131
|
-
}
|
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// Prototype Map
|
|
3
|
-
// Extracts all prototype transitions from a Figma file and builds a state-
|
|
4
|
-
// machine model. Supports BFS reachability filtering from a start frame,
|
|
5
|
-
// detailed animation-spec extraction, and output as structured JSON,
|
|
6
|
-
// Mermaid stateDiagram-v2 syntax, or both.
|
|
7
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
10
|
-
import { decisionLog } from "../../../shared/decision-log.js";
|
|
11
|
-
import { PrototypeTransition } from "../../../shared/types.js";
|
|
12
|
-
|
|
13
|
-
// ─── Public types ─────────────────────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
export interface PrototypeMapArgs {
|
|
16
|
-
fileKey?: string;
|
|
17
|
-
startFrameId?: string;
|
|
18
|
-
includeAnimationSpecs?: boolean;
|
|
19
|
-
outputFormat: "json" | "mermaid" | "both";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface StateNode {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
isStart: boolean;
|
|
26
|
-
outgoingCount: number;
|
|
27
|
-
incomingCount: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface StateMachine {
|
|
31
|
-
states: StateNode[];
|
|
32
|
-
transitions: PrototypeTransition[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface PrototypeMapResult {
|
|
36
|
-
stateMachine: StateMachine;
|
|
37
|
-
mermaidDiagram: string | null;
|
|
38
|
-
totalStates: number;
|
|
39
|
-
totalTransitions: number;
|
|
40
|
-
reachableStates: number;
|
|
41
|
-
logEntryId: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ─── Raw connection type from bridge ─────────────────────────────────────────
|
|
45
|
-
|
|
46
|
-
interface RawConnection {
|
|
47
|
-
fromId: string;
|
|
48
|
-
fromName: string;
|
|
49
|
-
toId: string;
|
|
50
|
-
toName: string;
|
|
51
|
-
trigger: Record<string, unknown>;
|
|
52
|
-
action: Record<string, unknown>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ─── Trigger normalisation ────────────────────────────────────────────────────
|
|
56
|
-
|
|
57
|
-
function normaliseTrigger(trigger: Record<string, unknown>): PrototypeTransition["trigger"] {
|
|
58
|
-
const type = typeof trigger["type"] === "string" ? trigger["type"] : "ON_CLICK";
|
|
59
|
-
const delay = typeof trigger["delay"] === "number" ? trigger["delay"] : undefined;
|
|
60
|
-
|
|
61
|
-
const nodeName =
|
|
62
|
-
type === "AFTER_DELAY" && delay !== undefined
|
|
63
|
-
? `${delay}ms`
|
|
64
|
-
: typeof trigger["name"] === "string"
|
|
65
|
-
? trigger["name"]
|
|
66
|
-
: undefined;
|
|
67
|
-
|
|
68
|
-
return { type, nodeName };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ─── Animation extraction ─────────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
function normaliseAnimation(
|
|
74
|
-
action: Record<string, unknown>,
|
|
75
|
-
includeSpecs: boolean
|
|
76
|
-
): PrototypeTransition["animation"] {
|
|
77
|
-
const transition = (action["transition"] as Record<string, unknown> | undefined) ?? {};
|
|
78
|
-
const rawType = transition["type"];
|
|
79
|
-
|
|
80
|
-
let type = "INSTANT";
|
|
81
|
-
if (typeof rawType === "string" && rawType.length > 0) {
|
|
82
|
-
type = rawType;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const direction =
|
|
86
|
-
typeof transition["direction"] === "string" ? transition["direction"] : undefined;
|
|
87
|
-
|
|
88
|
-
// Figma stores duration in seconds; convert to milliseconds
|
|
89
|
-
const rawDuration = transition["duration"];
|
|
90
|
-
const duration =
|
|
91
|
-
typeof rawDuration === "number"
|
|
92
|
-
? Math.round(rawDuration * 1000)
|
|
93
|
-
: 300;
|
|
94
|
-
|
|
95
|
-
let easing: number[] | undefined;
|
|
96
|
-
if (includeSpecs) {
|
|
97
|
-
const rawEasing = transition["easing"] as Record<string, unknown> | undefined;
|
|
98
|
-
if (rawEasing) {
|
|
99
|
-
const easingType = rawEasing["type"] as string | undefined;
|
|
100
|
-
switch (easingType) {
|
|
101
|
-
case "LINEAR":
|
|
102
|
-
easing = [0, 0, 1, 1];
|
|
103
|
-
break;
|
|
104
|
-
case "EASE_IN":
|
|
105
|
-
easing = [0.4, 0, 1, 1];
|
|
106
|
-
break;
|
|
107
|
-
case "EASE_OUT":
|
|
108
|
-
easing = [0, 0, 0.2, 1];
|
|
109
|
-
break;
|
|
110
|
-
case "EASE_IN_AND_OUT":
|
|
111
|
-
easing = [0.4, 0, 0.2, 1];
|
|
112
|
-
break;
|
|
113
|
-
case "CUSTOM_CUBIC_BEZIER": {
|
|
114
|
-
const cb = rawEasing["easingFunctionCubicBezier"] as Record<string, number> | undefined;
|
|
115
|
-
if (cb) {
|
|
116
|
-
easing = [
|
|
117
|
-
cb["x1"] ?? 0.4,
|
|
118
|
-
cb["y1"] ?? 0,
|
|
119
|
-
cb["x2"] ?? 0.2,
|
|
120
|
-
cb["y2"] ?? 1,
|
|
121
|
-
];
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
default:
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return { type, direction, duration, easing };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ─── Raw connections → typed transitions ──────────────────────────────────────
|
|
135
|
-
|
|
136
|
-
function rawToTransition(
|
|
137
|
-
raw: RawConnection,
|
|
138
|
-
includeAnimationSpecs: boolean
|
|
139
|
-
): PrototypeTransition {
|
|
140
|
-
return {
|
|
141
|
-
from: raw.fromId,
|
|
142
|
-
fromName: raw.fromName,
|
|
143
|
-
to: raw.toId,
|
|
144
|
-
toName: raw.toName,
|
|
145
|
-
trigger: normaliseTrigger(raw.trigger),
|
|
146
|
-
animation: normaliseAnimation(raw.action, includeAnimationSpecs),
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ─── BFS reachability ─────────────────────────────────────────────────────────
|
|
151
|
-
|
|
152
|
-
function bfsReachable(startId: string, transitions: PrototypeTransition[]): Set<string> {
|
|
153
|
-
const reachable = new Set<string>();
|
|
154
|
-
const queue: string[] = [startId];
|
|
155
|
-
|
|
156
|
-
while (queue.length > 0) {
|
|
157
|
-
const current = queue.shift()!;
|
|
158
|
-
if (reachable.has(current)) continue;
|
|
159
|
-
reachable.add(current);
|
|
160
|
-
|
|
161
|
-
for (const t of transitions) {
|
|
162
|
-
if (t.from === current && !reachable.has(t.to)) {
|
|
163
|
-
queue.push(t.to);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return reachable;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// ─── State machine builder ────────────────────────────────────────────────────
|
|
172
|
-
|
|
173
|
-
function buildStateMachine(
|
|
174
|
-
transitions: PrototypeTransition[],
|
|
175
|
-
startFrameId: string | undefined
|
|
176
|
-
): StateMachine {
|
|
177
|
-
const frameMap = new Map<string, string>();
|
|
178
|
-
for (const t of transitions) {
|
|
179
|
-
frameMap.set(t.from, t.fromName);
|
|
180
|
-
frameMap.set(t.to, t.toName);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const states: StateNode[] = [];
|
|
184
|
-
for (const [id, name] of frameMap) {
|
|
185
|
-
states.push({
|
|
186
|
-
id,
|
|
187
|
-
name,
|
|
188
|
-
isStart: id === startFrameId,
|
|
189
|
-
outgoingCount: transitions.filter((t) => t.from === id).length,
|
|
190
|
-
incomingCount: transitions.filter((t) => t.to === id).length,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return { states, transitions };
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// ─── Mermaid generation ───────────────────────────────────────────────────────
|
|
198
|
-
|
|
199
|
-
function sanitiseMermaidId(name: string): string {
|
|
200
|
-
return name
|
|
201
|
-
.replace(/[^a-zA-Z0-9_]/g, "_")
|
|
202
|
-
.replace(/^_+|_+$/g, "")
|
|
203
|
-
.replace(/__+/g, "_")
|
|
204
|
-
.slice(0, 40) || "State";
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function buildTransitionLabel(
|
|
208
|
-
transition: PrototypeTransition,
|
|
209
|
-
includeAnimSpecs: boolean
|
|
210
|
-
): string {
|
|
211
|
-
const triggerLabel = transition.trigger.type
|
|
212
|
-
.replace(/^ON_/, "")
|
|
213
|
-
.toLowerCase()
|
|
214
|
-
.replace(/_/g, " ");
|
|
215
|
-
|
|
216
|
-
const nodePart = transition.trigger.nodeName
|
|
217
|
-
? ` "${transition.trigger.nodeName}"`
|
|
218
|
-
: "";
|
|
219
|
-
|
|
220
|
-
if (!includeAnimSpecs) return `${triggerLabel}${nodePart}`;
|
|
221
|
-
|
|
222
|
-
const anim = transition.animation;
|
|
223
|
-
const typePart = anim.type.toLowerCase().replace(/_/g, "-");
|
|
224
|
-
const dirPart = anim.direction ? `-${anim.direction.toLowerCase()}` : "";
|
|
225
|
-
const animLabel = `${typePart}${dirPart} ${anim.duration}ms`;
|
|
226
|
-
|
|
227
|
-
return `${triggerLabel}${nodePart} [${animLabel}]`;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function generateMermaid(
|
|
231
|
-
stateMachine: StateMachine,
|
|
232
|
-
startFrameId: string | undefined,
|
|
233
|
-
includeAnimationSpecs: boolean
|
|
234
|
-
): string {
|
|
235
|
-
const lines: string[] = ["stateDiagram-v2"];
|
|
236
|
-
|
|
237
|
-
// Build stable ID map, deduplicating collisions
|
|
238
|
-
const idToMermaid = new Map<string, string>();
|
|
239
|
-
const usedIds = new Set<string>();
|
|
240
|
-
|
|
241
|
-
for (const state of stateMachine.states) {
|
|
242
|
-
let safe = sanitiseMermaidId(state.name);
|
|
243
|
-
let candidate = safe;
|
|
244
|
-
let counter = 1;
|
|
245
|
-
while (usedIds.has(candidate)) {
|
|
246
|
-
candidate = `${safe}_${counter++}`;
|
|
247
|
-
}
|
|
248
|
-
idToMermaid.set(state.id, candidate);
|
|
249
|
-
usedIds.add(candidate);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// State declarations with display names
|
|
253
|
-
for (const state of stateMachine.states) {
|
|
254
|
-
const mid = idToMermaid.get(state.id)!;
|
|
255
|
-
const displayName = state.name.replace(/"/g, "'");
|
|
256
|
-
lines.push(` ${mid} : ${displayName}`);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
lines.push("");
|
|
260
|
-
|
|
261
|
-
// Initial state arrow
|
|
262
|
-
if (startFrameId && idToMermaid.has(startFrameId)) {
|
|
263
|
-
lines.push(` [*] --> ${idToMermaid.get(startFrameId)}`);
|
|
264
|
-
} else {
|
|
265
|
-
const noIncoming = stateMachine.states.find((s) => s.incomingCount === 0);
|
|
266
|
-
if (noIncoming) {
|
|
267
|
-
lines.push(` [*] --> ${idToMermaid.get(noIncoming.id)}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Transition edges — deduplicate identical edges
|
|
272
|
-
const seen = new Set<string>();
|
|
273
|
-
for (const t of stateMachine.transitions) {
|
|
274
|
-
const from = idToMermaid.get(t.from);
|
|
275
|
-
const to = idToMermaid.get(t.to);
|
|
276
|
-
if (!from || !to) continue;
|
|
277
|
-
|
|
278
|
-
const label = buildTransitionLabel(t, includeAnimationSpecs);
|
|
279
|
-
const key = `${from}|${to}|${label}`;
|
|
280
|
-
if (!seen.has(key)) {
|
|
281
|
-
seen.add(key);
|
|
282
|
-
lines.push(` ${from} --> ${to} : ${label}`);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return lines.join("\n");
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// ─── Main handler ─────────────────────────────────────────────────────────────
|
|
290
|
-
|
|
291
|
-
export async function prototypeMapHandler(
|
|
292
|
-
args: PrototypeMapArgs
|
|
293
|
-
): Promise<PrototypeMapResult> {
|
|
294
|
-
const {
|
|
295
|
-
startFrameId,
|
|
296
|
-
includeAnimationSpecs = false,
|
|
297
|
-
outputFormat,
|
|
298
|
-
} = args;
|
|
299
|
-
|
|
300
|
-
const bridge = await getBridge();
|
|
301
|
-
|
|
302
|
-
// 1. Fetch all prototype connections from Figma
|
|
303
|
-
const rawConnections = await bridge.getPrototypeConnections();
|
|
304
|
-
|
|
305
|
-
if (rawConnections.length === 0) {
|
|
306
|
-
const emptyMachine: StateMachine = { states: [], transitions: [] };
|
|
307
|
-
const logEntry = await decisionLog.log({
|
|
308
|
-
tool: "prototype-map",
|
|
309
|
-
nodeIds: [],
|
|
310
|
-
rationale: "No prototype connections found in the current Figma file.",
|
|
311
|
-
reversible: false,
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
return {
|
|
315
|
-
stateMachine: emptyMachine,
|
|
316
|
-
mermaidDiagram:
|
|
317
|
-
outputFormat !== "json"
|
|
318
|
-
? "stateDiagram-v2\n %% No prototype connections found"
|
|
319
|
-
: null,
|
|
320
|
-
totalStates: 0,
|
|
321
|
-
totalTransitions: 0,
|
|
322
|
-
reachableStates: 0,
|
|
323
|
-
logEntryId: logEntry.id,
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// 2. Convert raw connections to typed PrototypeTransition objects
|
|
328
|
-
let allTransitions: PrototypeTransition[] = rawConnections.map((c) =>
|
|
329
|
-
rawToTransition(c, includeAnimationSpecs)
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
// 3. BFS filter if startFrameId provided
|
|
333
|
-
let reachableCount = 0;
|
|
334
|
-
|
|
335
|
-
if (startFrameId) {
|
|
336
|
-
const reachable = bfsReachable(startFrameId, allTransitions);
|
|
337
|
-
reachableCount = reachable.size;
|
|
338
|
-
allTransitions = allTransitions.filter(
|
|
339
|
-
(t) => reachable.has(t.from) && reachable.has(t.to)
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// 4. Build typed state machine
|
|
344
|
-
const stateMachine = buildStateMachine(allTransitions, startFrameId);
|
|
345
|
-
|
|
346
|
-
if (!startFrameId) {
|
|
347
|
-
reachableCount = stateMachine.states.length;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// 5. Generate Mermaid diagram when requested
|
|
351
|
-
let mermaidDiagram: string | null = null;
|
|
352
|
-
if (outputFormat === "mermaid" || outputFormat === "both") {
|
|
353
|
-
mermaidDiagram = generateMermaid(stateMachine, startFrameId, includeAnimationSpecs);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// 6. Log the decision
|
|
357
|
-
const logEntry = await decisionLog.log({
|
|
358
|
-
tool: "prototype-map",
|
|
359
|
-
nodeIds: stateMachine.states.map((s) => s.id),
|
|
360
|
-
rationale: `Extracted prototype map: ${stateMachine.states.length} states, ${stateMachine.transitions.length} transitions. Start frame: ${startFrameId ?? "all (no filter)"}. Reachable: ${reachableCount}. Output: ${outputFormat}. Animation specs: ${includeAnimationSpecs}.`,
|
|
361
|
-
tokens: [],
|
|
362
|
-
reversible: false,
|
|
363
|
-
metadata: {
|
|
364
|
-
startFrameId,
|
|
365
|
-
includeAnimationSpecs,
|
|
366
|
-
outputFormat,
|
|
367
|
-
totalStates: stateMachine.states.length,
|
|
368
|
-
totalTransitions: stateMachine.transitions.length,
|
|
369
|
-
reachableStates: reachableCount,
|
|
370
|
-
},
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
return {
|
|
374
|
-
stateMachine,
|
|
375
|
-
mermaidDiagram,
|
|
376
|
-
totalStates: stateMachine.states.length,
|
|
377
|
-
totalTransitions: stateMachine.transitions.length,
|
|
378
|
-
reachableStates: reachableCount,
|
|
379
|
-
logEntryId: logEntry.id,
|
|
380
|
-
};
|
|
381
|
-
}
|