@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,764 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// Swarm Build — Multi-Agent Orchestrated Page Builder
|
|
3
|
-
//
|
|
4
|
-
// Decomposes a high-level task into spatial sub-tasks, assigns each to a named
|
|
5
|
-
// "agent" with its own colored cursor, runs preparation in parallel, and
|
|
6
|
-
// executes canvas writes with multi-cursor visual theatre.
|
|
7
|
-
//
|
|
8
|
-
// Architecture:
|
|
9
|
-
// 1. Parse user intent into spatial zones (hero, nav, features, footer, etc.)
|
|
10
|
-
// 2. Spawn agent cursors for each role (Layouter, Styler, Copywriter, Matcher)
|
|
11
|
-
// 3. Run all agent preparation in parallel via Promise.all()
|
|
12
|
-
// 4. Execute canvas writes sequentially (Figma Plugin API constraint) with
|
|
13
|
-
// each agent's cursor animating to its zone as its work is committed
|
|
14
|
-
// 5. Post agent chat notes showing collaboration between agents
|
|
15
|
-
// 6. Clean up cursors, leave chat notes as visible collaboration log
|
|
16
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
import Fuse from "fuse.js";
|
|
19
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
20
|
-
import { decisionLog } from "../../../shared/decision-log.js";
|
|
21
|
-
import { ComponentSet, Token } from "../../../shared/types.js";
|
|
22
|
-
import {
|
|
23
|
-
resolveDesignPalette,
|
|
24
|
-
ResolvedPalette,
|
|
25
|
-
} from "../../../shared/token-binder.js";
|
|
26
|
-
import { FontConfig, resolveFontConfig, generateFontLoadScript, fontNameLiteral } from "../../../shared/font-config.js";
|
|
27
|
-
|
|
28
|
-
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
29
|
-
|
|
30
|
-
export interface SwarmBuildArgs {
|
|
31
|
-
brief: string;
|
|
32
|
-
platform?: "web" | "mobile";
|
|
33
|
-
width?: number;
|
|
34
|
-
showAgentChat?: boolean;
|
|
35
|
-
fonts?: Partial<FontConfig>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface SwarmBuildResult {
|
|
39
|
-
zones: ZoneResult[];
|
|
40
|
-
frameIds: string[];
|
|
41
|
-
agentsUsed: string[];
|
|
42
|
-
parallelPrepMs: number;
|
|
43
|
-
totalBuildMs: number;
|
|
44
|
-
chatNoteIds: string[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface SpatialZone {
|
|
48
|
-
name: string;
|
|
49
|
-
role: string;
|
|
50
|
-
yOrder: number;
|
|
51
|
-
components: string[];
|
|
52
|
-
description: string;
|
|
53
|
-
content: ZoneContent;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface ZoneContent {
|
|
57
|
-
heading?: string;
|
|
58
|
-
subheading?: string;
|
|
59
|
-
bodyText?: string;
|
|
60
|
-
ctaLabel?: string;
|
|
61
|
-
listItems?: string[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface ZoneResult {
|
|
65
|
-
zoneName: string;
|
|
66
|
-
agent: string;
|
|
67
|
-
frameId: string;
|
|
68
|
-
componentsMatched: number;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ─── Agent Definitions ──────────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
const AGENTS = {
|
|
74
|
-
Layouter: {
|
|
75
|
-
role: "Determines spatial layout, Auto Layout config, frame dimensions, and spacing",
|
|
76
|
-
chatPrefix: "Layout ready",
|
|
77
|
-
},
|
|
78
|
-
Styler: {
|
|
79
|
-
role: "Resolves design tokens, color palette, typography, and visual styles",
|
|
80
|
-
chatPrefix: "Tokens bound",
|
|
81
|
-
},
|
|
82
|
-
Copywriter: {
|
|
83
|
-
role: "Generates realistic UI text: headings, body copy, CTAs, list items",
|
|
84
|
-
chatPrefix: "Copy written",
|
|
85
|
-
},
|
|
86
|
-
Matcher: {
|
|
87
|
-
role: "Finds matching design system components for each zone",
|
|
88
|
-
chatPrefix: "Components matched",
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// ─── Zone Decomposition ─────────────────────────────────────────────────────
|
|
93
|
-
|
|
94
|
-
const ZONE_PATTERNS: Array<{
|
|
95
|
-
keywords: string[];
|
|
96
|
-
name: string;
|
|
97
|
-
components: string[];
|
|
98
|
-
description: string;
|
|
99
|
-
}> = [
|
|
100
|
-
{
|
|
101
|
-
keywords: ["nav", "navigation", "header", "top bar", "app bar", "menu"],
|
|
102
|
-
name: "Navigation",
|
|
103
|
-
components: ["Navigation", "Logo", "Avatar", "Button", "SearchBar"],
|
|
104
|
-
description: "Top navigation bar with logo, links, and actions",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
keywords: ["hero", "banner", "splash", "above the fold", "intro", "welcome"],
|
|
108
|
-
name: "Hero",
|
|
109
|
-
components: ["Heading", "Body", "Button", "Image"],
|
|
110
|
-
description: "Full-width hero section with headline, subtext, and CTA",
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
keywords: ["feature", "benefit", "service", "capability", "offering", "what we do"],
|
|
114
|
-
name: "Features",
|
|
115
|
-
components: ["Card", "Heading", "Body", "Icon", "Badge"],
|
|
116
|
-
description: "Multi-column feature cards with icons and descriptions",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
keywords: ["pricing", "plan", "tier", "subscription", "package"],
|
|
120
|
-
name: "Pricing",
|
|
121
|
-
components: ["Card", "Heading", "Body", "Button", "Badge", "Divider"],
|
|
122
|
-
description: "Pricing comparison cards with tiers and CTAs",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
keywords: ["testimonial", "review", "quote", "social proof", "customer"],
|
|
126
|
-
name: "Testimonials",
|
|
127
|
-
components: ["Card", "Avatar", "Body", "Rating"],
|
|
128
|
-
description: "Customer testimonials with avatars and quotes",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
keywords: ["cta", "call to action", "signup", "get started", "join", "subscribe"],
|
|
132
|
-
name: "CTA Section",
|
|
133
|
-
components: ["Heading", "Body", "Button", "TextInput"],
|
|
134
|
-
description: "Call-to-action section with headline and primary action",
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
keywords: ["footer", "bottom", "links", "copyright", "sitemap"],
|
|
138
|
-
name: "Footer",
|
|
139
|
-
components: ["Body", "Link", "Logo", "Divider"],
|
|
140
|
-
description: "Page footer with links, copyright, and brand",
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
keywords: ["form", "input", "contact", "feedback"],
|
|
144
|
-
name: "Form Section",
|
|
145
|
-
components: ["TextInput", "Button", "Heading", "Body", "Select", "Checkbox"],
|
|
146
|
-
description: "Form section with inputs and submit action",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
keywords: ["gallery", "portfolio", "showcase", "grid", "image"],
|
|
150
|
-
name: "Gallery",
|
|
151
|
-
components: ["Image", "Card", "Heading"],
|
|
152
|
-
description: "Image gallery or portfolio grid",
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
keywords: ["stat", "metric", "number", "counter", "achievement"],
|
|
156
|
-
name: "Stats",
|
|
157
|
-
components: ["Heading", "Body", "Card"],
|
|
158
|
-
description: "Key metrics or statistics display",
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
keywords: ["faq", "question", "answer", "help"],
|
|
162
|
-
name: "FAQ",
|
|
163
|
-
components: ["Heading", "Body", "Divider"],
|
|
164
|
-
description: "Frequently asked questions accordion",
|
|
165
|
-
},
|
|
166
|
-
];
|
|
167
|
-
|
|
168
|
-
function decomposeToZones(brief: string): SpatialZone[] {
|
|
169
|
-
const lowerBrief = brief.toLowerCase();
|
|
170
|
-
const zones: SpatialZone[] = [];
|
|
171
|
-
let yOrder = 0;
|
|
172
|
-
|
|
173
|
-
// Always start with navigation if it's a page/landing page
|
|
174
|
-
const isPage = /(page|landing|website|site|home|app)/.test(lowerBrief);
|
|
175
|
-
|
|
176
|
-
if (isPage) {
|
|
177
|
-
zones.push({
|
|
178
|
-
name: "Navigation",
|
|
179
|
-
role: "Layouter",
|
|
180
|
-
yOrder: yOrder++,
|
|
181
|
-
components: ["Navigation", "Logo", "Avatar", "Button"],
|
|
182
|
-
description: "Top navigation bar",
|
|
183
|
-
content: {},
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Match zones from brief
|
|
188
|
-
for (const pattern of ZONE_PATTERNS) {
|
|
189
|
-
if (pattern.name === "Navigation" && isPage) continue; // already added
|
|
190
|
-
const matches = pattern.keywords.some((kw) => lowerBrief.includes(kw));
|
|
191
|
-
if (matches) {
|
|
192
|
-
zones.push({
|
|
193
|
-
name: pattern.name,
|
|
194
|
-
role: yOrder % 2 === 0 ? "Layouter" : "Builder",
|
|
195
|
-
yOrder: yOrder++,
|
|
196
|
-
components: pattern.components,
|
|
197
|
-
description: pattern.description,
|
|
198
|
-
content: {},
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// If no specific zones matched, generate default page sections
|
|
204
|
-
if (zones.length <= 1) {
|
|
205
|
-
const defaultZones = ["Hero", "Features", "CTA Section", "Footer"];
|
|
206
|
-
for (const zoneName of defaultZones) {
|
|
207
|
-
const pattern = ZONE_PATTERNS.find((p) => p.name === zoneName);
|
|
208
|
-
if (pattern) {
|
|
209
|
-
zones.push({
|
|
210
|
-
name: pattern.name,
|
|
211
|
-
role: yOrder % 2 === 0 ? "Layouter" : "Builder",
|
|
212
|
-
yOrder: yOrder++,
|
|
213
|
-
components: pattern.components,
|
|
214
|
-
description: pattern.description,
|
|
215
|
-
content: {},
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Always end with footer if it's a page and not already added
|
|
222
|
-
if (isPage && !zones.find((z) => z.name === "Footer")) {
|
|
223
|
-
const footerPattern = ZONE_PATTERNS.find((p) => p.name === "Footer")!;
|
|
224
|
-
zones.push({
|
|
225
|
-
name: "Footer",
|
|
226
|
-
role: "Layouter",
|
|
227
|
-
yOrder: yOrder++,
|
|
228
|
-
components: footerPattern.components,
|
|
229
|
-
description: footerPattern.description,
|
|
230
|
-
content: {},
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return zones;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// ─── Parallel Agent Work ────────────────────────────────────────────────────
|
|
238
|
-
|
|
239
|
-
async function agentCopywriter(
|
|
240
|
-
brief: string,
|
|
241
|
-
zones: SpatialZone[],
|
|
242
|
-
): Promise<Map<string, ZoneContent>> {
|
|
243
|
-
const contentMap = new Map<string, ZoneContent>();
|
|
244
|
-
|
|
245
|
-
// Try AI content generation, fall back to smart defaults
|
|
246
|
-
const apiKey = process.env.ANTHROPIC_API_KEY?.trim();
|
|
247
|
-
if (apiKey) {
|
|
248
|
-
try {
|
|
249
|
-
const prompt = `You are a UI copywriter. Generate concise, realistic content for a "${brief}" page.
|
|
250
|
-
|
|
251
|
-
Zones: ${zones.map((z) => z.name).join(", ")}
|
|
252
|
-
|
|
253
|
-
Return ONLY valid JSON (no markdown):
|
|
254
|
-
{
|
|
255
|
-
"zones": [
|
|
256
|
-
{
|
|
257
|
-
"zoneName": "string",
|
|
258
|
-
"heading": "string (max 8 words)",
|
|
259
|
-
"subheading": "string (max 20 words)",
|
|
260
|
-
"ctaLabel": "string (max 3 words)",
|
|
261
|
-
"listItems": ["string"],
|
|
262
|
-
"bodyText": "string (max 30 words)"
|
|
263
|
-
}
|
|
264
|
-
]
|
|
265
|
-
}`;
|
|
266
|
-
|
|
267
|
-
const response = await fetch("https://api.anthropic.com/v1/messages", {
|
|
268
|
-
method: "POST",
|
|
269
|
-
headers: {
|
|
270
|
-
"Content-Type": "application/json",
|
|
271
|
-
"x-api-key": apiKey,
|
|
272
|
-
"anthropic-version": "2023-06-01",
|
|
273
|
-
},
|
|
274
|
-
body: JSON.stringify({
|
|
275
|
-
model: "claude-haiku-4-5-20251001",
|
|
276
|
-
max_tokens: 1024,
|
|
277
|
-
messages: [{ role: "user", content: prompt }],
|
|
278
|
-
}),
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
if (response.ok) {
|
|
282
|
-
const data = (await response.json()) as { content: Array<{ type: string; text: string }> };
|
|
283
|
-
const text = data.content?.[0]?.text ?? "";
|
|
284
|
-
const jsonMatch = text.match(/\{[\s\S]*\}/);
|
|
285
|
-
if (jsonMatch) {
|
|
286
|
-
const parsed = JSON.parse(jsonMatch[0]) as { zones: Array<ZoneContent & { zoneName: string }> };
|
|
287
|
-
for (const z of parsed.zones) {
|
|
288
|
-
contentMap.set(z.zoneName, z);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
} catch {
|
|
293
|
-
// Fall through to defaults
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Fill in defaults for any zones without AI content
|
|
298
|
-
for (const zone of zones) {
|
|
299
|
-
if (!contentMap.has(zone.name)) {
|
|
300
|
-
contentMap.set(zone.name, buildDefaultContent(zone.name, brief));
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return contentMap;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function buildDefaultContent(zoneName: string, brief: string): ZoneContent {
|
|
308
|
-
const brand = brief.split(/\s+/).slice(0, 2).join(" ");
|
|
309
|
-
switch (zoneName) {
|
|
310
|
-
case "Navigation":
|
|
311
|
-
return { heading: brand };
|
|
312
|
-
case "Hero":
|
|
313
|
-
return {
|
|
314
|
-
heading: `Build something amazing with ${brand}`,
|
|
315
|
-
subheading: "The modern platform designed to help you move faster and build better.",
|
|
316
|
-
ctaLabel: "Get Started",
|
|
317
|
-
};
|
|
318
|
-
case "Features":
|
|
319
|
-
return {
|
|
320
|
-
heading: "Why choose us",
|
|
321
|
-
listItems: ["Lightning fast performance", "Enterprise-grade security", "Beautiful by default"],
|
|
322
|
-
};
|
|
323
|
-
case "Pricing":
|
|
324
|
-
return {
|
|
325
|
-
heading: "Simple, transparent pricing",
|
|
326
|
-
subheading: "No hidden fees. Cancel anytime.",
|
|
327
|
-
listItems: ["Starter — Free", "Pro — $19/mo", "Enterprise — Custom"],
|
|
328
|
-
};
|
|
329
|
-
case "Testimonials":
|
|
330
|
-
return {
|
|
331
|
-
heading: "Loved by teams worldwide",
|
|
332
|
-
listItems: ['"This changed how we work" — Sarah K.', '"Best tool we\'ve adopted" — Mike L.'],
|
|
333
|
-
};
|
|
334
|
-
case "CTA Section":
|
|
335
|
-
return {
|
|
336
|
-
heading: "Ready to get started?",
|
|
337
|
-
subheading: "Join thousands of teams already using our platform.",
|
|
338
|
-
ctaLabel: "Start free trial",
|
|
339
|
-
};
|
|
340
|
-
case "Footer":
|
|
341
|
-
return {
|
|
342
|
-
heading: brand,
|
|
343
|
-
bodyText: `© ${new Date().getFullYear()} ${brand}. All rights reserved.`,
|
|
344
|
-
listItems: ["About", "Blog", "Careers", "Contact", "Privacy", "Terms"],
|
|
345
|
-
};
|
|
346
|
-
case "Stats":
|
|
347
|
-
return {
|
|
348
|
-
listItems: ["10K+ Users", "99.9% Uptime", "150+ Countries"],
|
|
349
|
-
};
|
|
350
|
-
case "FAQ":
|
|
351
|
-
return {
|
|
352
|
-
heading: "Frequently asked questions",
|
|
353
|
-
listItems: ["How does it work?", "Is there a free trial?", "Can I cancel anytime?"],
|
|
354
|
-
};
|
|
355
|
-
default:
|
|
356
|
-
return {
|
|
357
|
-
heading: zoneName,
|
|
358
|
-
bodyText: `Content for ${zoneName} section`,
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
async function agentMatcher(
|
|
364
|
-
zones: SpatialZone[],
|
|
365
|
-
componentSets: ComponentSet[],
|
|
366
|
-
): Promise<Map<string, Array<{ name: string; nodeId: string | null }>>> {
|
|
367
|
-
const fuse = new Fuse(componentSets, {
|
|
368
|
-
keys: ["name", "description"],
|
|
369
|
-
threshold: 0.45,
|
|
370
|
-
includeScore: true,
|
|
371
|
-
minMatchCharLength: 2,
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
const matchMap = new Map<string, Array<{ name: string; nodeId: string | null }>>();
|
|
375
|
-
|
|
376
|
-
for (const zone of zones) {
|
|
377
|
-
const matches = zone.components.map((compName) => {
|
|
378
|
-
const results = fuse.search(compName);
|
|
379
|
-
if (results.length === 0) return { name: compName, nodeId: null };
|
|
380
|
-
const best = results[0];
|
|
381
|
-
const firstChild = best.item.children[0];
|
|
382
|
-
return { name: best.item.name, nodeId: firstChild?.id ?? null };
|
|
383
|
-
});
|
|
384
|
-
matchMap.set(zone.name, matches);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return matchMap;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
async function agentStyler(
|
|
391
|
-
tokens: Token[],
|
|
392
|
-
dsId?: string | null,
|
|
393
|
-
): Promise<ResolvedPalette | undefined> {
|
|
394
|
-
// When a DS is selected, its tokens are authoritative (ignore file tokens)
|
|
395
|
-
if (!dsId && tokens.length === 0) return undefined;
|
|
396
|
-
try {
|
|
397
|
-
return resolveDesignPalette(tokens, dsId);
|
|
398
|
-
} catch {
|
|
399
|
-
return undefined;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// ─── Zone Build Script ──────────────────────────────────────────────────────
|
|
404
|
-
|
|
405
|
-
function buildZoneScript(
|
|
406
|
-
zone: SpatialZone,
|
|
407
|
-
content: ZoneContent,
|
|
408
|
-
matches: Array<{ name: string; nodeId: string | null }>,
|
|
409
|
-
palette: ResolvedPalette | undefined,
|
|
410
|
-
frameWidth: number,
|
|
411
|
-
parentFrameId: string,
|
|
412
|
-
fc: FontConfig,
|
|
413
|
-
): string {
|
|
414
|
-
const fontLoadBlock = generateFontLoadScript(fc);
|
|
415
|
-
const headingFont = fontNameLiteral("heading", "Bold", fc);
|
|
416
|
-
const bodyFont = fontNameLiteral("body", "Regular", fc);
|
|
417
|
-
const uiFont = fontNameLiteral("ui", "Medium", fc);
|
|
418
|
-
|
|
419
|
-
const heading = content.heading || zone.name;
|
|
420
|
-
const sub = content.subheading || "";
|
|
421
|
-
const cta = content.ctaLabel || "";
|
|
422
|
-
const body = content.bodyText || "";
|
|
423
|
-
const items = content.listItems || [];
|
|
424
|
-
|
|
425
|
-
const bgFill = zone.name === "Hero"
|
|
426
|
-
? "{ r: 0.96, g: 0.96, b: 0.99 }"
|
|
427
|
-
: zone.name === "Footer"
|
|
428
|
-
? "{ r: 0.12, g: 0.12, b: 0.15 }"
|
|
429
|
-
: zone.name === "CTA Section"
|
|
430
|
-
? "{ r: 0.26, g: 0.52, b: 0.96 }"
|
|
431
|
-
: "{ r: 1, g: 1, b: 1 }";
|
|
432
|
-
|
|
433
|
-
const textColor = (zone.name === "Footer" || zone.name === "CTA Section")
|
|
434
|
-
? "{ r: 1, g: 1, b: 1 }"
|
|
435
|
-
: "{ r: 0.1, g: 0.1, b: 0.12 }";
|
|
436
|
-
|
|
437
|
-
const subColor = (zone.name === "Footer" || zone.name === "CTA Section")
|
|
438
|
-
? "{ r: 0.8, g: 0.8, b: 0.85 }"
|
|
439
|
-
: "{ r: 0.4, g: 0.4, b: 0.45 }";
|
|
440
|
-
|
|
441
|
-
// Build list items script
|
|
442
|
-
const listScript = items.length > 0 ? `
|
|
443
|
-
// List items
|
|
444
|
-
${items.map((item, i) => `
|
|
445
|
-
{
|
|
446
|
-
const li = figma.createText();
|
|
447
|
-
await figma.loadFontAsync(${bodyFont});
|
|
448
|
-
li.fontName = ${bodyFont};
|
|
449
|
-
li.characters = ${JSON.stringify(item)};
|
|
450
|
-
li.fontSize = 16;
|
|
451
|
-
li.fills = [{ type: 'SOLID', color: ${subColor} }];
|
|
452
|
-
li.name = 'ListItem_${i}';
|
|
453
|
-
zone.appendChild(li);
|
|
454
|
-
if ('layoutSizingHorizontal' in li) li.layoutSizingHorizontal = 'FILL';
|
|
455
|
-
}
|
|
456
|
-
`).join("\n")}
|
|
457
|
-
` : "";
|
|
458
|
-
|
|
459
|
-
// CTA button
|
|
460
|
-
const ctaScript = cta ? `
|
|
461
|
-
// CTA Button
|
|
462
|
-
const ctaFrame = figma.createFrame();
|
|
463
|
-
ctaFrame.name = 'CTA';
|
|
464
|
-
ctaFrame.layoutMode = 'HORIZONTAL';
|
|
465
|
-
ctaFrame.primaryAxisSizingMode = 'AUTO';
|
|
466
|
-
ctaFrame.counterAxisSizingMode = 'AUTO';
|
|
467
|
-
ctaFrame.paddingLeft = 24; ctaFrame.paddingRight = 24;
|
|
468
|
-
ctaFrame.paddingTop = 12; ctaFrame.paddingBottom = 12;
|
|
469
|
-
ctaFrame.cornerRadius = 8;
|
|
470
|
-
ctaFrame.fills = [{ type: 'SOLID', color: ${zone.name === "CTA Section" ? "{ r: 1, g: 1, b: 1 }" : "{ r: 0.26, g: 0.52, b: 0.96 }"} }];
|
|
471
|
-
const ctaText = figma.createText();
|
|
472
|
-
await figma.loadFontAsync(${uiFont});
|
|
473
|
-
ctaText.fontName = ${uiFont};
|
|
474
|
-
ctaText.characters = ${JSON.stringify(cta)};
|
|
475
|
-
ctaText.fontSize = 16;
|
|
476
|
-
ctaText.fills = [{ type: 'SOLID', color: ${zone.name === "CTA Section" ? "{ r: 0.26, g: 0.52, b: 0.96 }" : "{ r: 1, g: 1, b: 1 }"} }];
|
|
477
|
-
ctaFrame.appendChild(ctaText);
|
|
478
|
-
zone.appendChild(ctaFrame);
|
|
479
|
-
` : "";
|
|
480
|
-
|
|
481
|
-
return `
|
|
482
|
-
(async () => {
|
|
483
|
-
${fontLoadBlock}
|
|
484
|
-
|
|
485
|
-
const parent = await figma.getNodeByIdAsync(${JSON.stringify(parentFrameId)});
|
|
486
|
-
if (!parent || !('appendChild' in parent)) throw new Error('Parent frame not found');
|
|
487
|
-
|
|
488
|
-
const zone = figma.createFrame();
|
|
489
|
-
zone.name = ${JSON.stringify(zone.name)};
|
|
490
|
-
zone.layoutMode = 'VERTICAL';
|
|
491
|
-
zone.primaryAxisSizingMode = 'AUTO';
|
|
492
|
-
zone.counterAxisSizingMode = 'FIXED';
|
|
493
|
-
zone.resize(${frameWidth}, 100);
|
|
494
|
-
zone.itemSpacing = ${zone.name === "Navigation" ? 0 : 16};
|
|
495
|
-
zone.paddingLeft = ${zone.name === "Navigation" ? 24 : 48};
|
|
496
|
-
zone.paddingRight = ${zone.name === "Navigation" ? 24 : 48};
|
|
497
|
-
zone.paddingTop = ${zone.name === "Navigation" ? 12 : 48};
|
|
498
|
-
zone.paddingBottom = ${zone.name === "Navigation" ? 12 : 48};
|
|
499
|
-
zone.fills = [{ type: 'SOLID', color: ${bgFill} }];
|
|
500
|
-
if ('layoutSizingHorizontal' in zone) zone.layoutSizingHorizontal = 'FILL';
|
|
501
|
-
parent.appendChild(zone);
|
|
502
|
-
|
|
503
|
-
// Heading
|
|
504
|
-
${heading ? `
|
|
505
|
-
const h = figma.createText();
|
|
506
|
-
await figma.loadFontAsync(${headingFont});
|
|
507
|
-
h.fontName = ${headingFont};
|
|
508
|
-
h.characters = ${JSON.stringify(heading)};
|
|
509
|
-
h.fontSize = ${zone.name === "Hero" ? 48 : zone.name === "Navigation" ? 16 : 32};
|
|
510
|
-
h.fills = [{ type: 'SOLID', color: ${textColor} }];
|
|
511
|
-
h.name = 'Heading';
|
|
512
|
-
zone.appendChild(h);
|
|
513
|
-
if ('layoutSizingHorizontal' in h) h.layoutSizingHorizontal = 'FILL';
|
|
514
|
-
` : ""}
|
|
515
|
-
|
|
516
|
-
// Subheading
|
|
517
|
-
${sub ? `
|
|
518
|
-
const sub = figma.createText();
|
|
519
|
-
await figma.loadFontAsync(${bodyFont});
|
|
520
|
-
sub.fontName = ${bodyFont};
|
|
521
|
-
sub.characters = ${JSON.stringify(sub)};
|
|
522
|
-
sub.fontSize = 18;
|
|
523
|
-
sub.fills = [{ type: 'SOLID', color: ${subColor} }];
|
|
524
|
-
sub.name = 'Subheading';
|
|
525
|
-
zone.appendChild(sub);
|
|
526
|
-
if ('layoutSizingHorizontal' in sub) sub.layoutSizingHorizontal = 'FILL';
|
|
527
|
-
` : ""}
|
|
528
|
-
|
|
529
|
-
// Body text
|
|
530
|
-
${body ? `
|
|
531
|
-
const bodyEl = figma.createText();
|
|
532
|
-
await figma.loadFontAsync(${bodyFont});
|
|
533
|
-
bodyEl.fontName = ${bodyFont};
|
|
534
|
-
bodyEl.characters = ${JSON.stringify(body)};
|
|
535
|
-
bodyEl.fontSize = 14;
|
|
536
|
-
bodyEl.fills = [{ type: 'SOLID', color: ${subColor} }];
|
|
537
|
-
bodyEl.name = 'Body';
|
|
538
|
-
zone.appendChild(bodyEl);
|
|
539
|
-
if ('layoutSizingHorizontal' in bodyEl) bodyEl.layoutSizingHorizontal = 'FILL';
|
|
540
|
-
` : ""}
|
|
541
|
-
|
|
542
|
-
${listScript}
|
|
543
|
-
|
|
544
|
-
${ctaScript}
|
|
545
|
-
|
|
546
|
-
return { zoneId: zone.id, zoneName: ${JSON.stringify(zone.name)} };
|
|
547
|
-
})();
|
|
548
|
-
`.trim();
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// ─── Main Handler ───────────────────────────────────────────────────────────
|
|
552
|
-
|
|
553
|
-
export async function swarmBuildHandler(
|
|
554
|
-
args: SwarmBuildArgs,
|
|
555
|
-
): Promise<SwarmBuildResult> {
|
|
556
|
-
const {
|
|
557
|
-
brief,
|
|
558
|
-
platform = "web",
|
|
559
|
-
width: userWidth,
|
|
560
|
-
showAgentChat = true,
|
|
561
|
-
} = args;
|
|
562
|
-
|
|
563
|
-
if (!brief) throw new Error("swarmBuild: `brief` is required.");
|
|
564
|
-
|
|
565
|
-
const startTime = Date.now();
|
|
566
|
-
const bridge = await getBridge();
|
|
567
|
-
const fontConfig = resolveFontConfig(args.fonts, bridge.getActiveDesignSystemId());
|
|
568
|
-
const frameWidth = userWidth || (platform === "mobile" ? 390 : 1440);
|
|
569
|
-
|
|
570
|
-
// 1. Decompose brief into spatial zones
|
|
571
|
-
const zones = decomposeToZones(brief);
|
|
572
|
-
|
|
573
|
-
// 2. Find rightmost existing frame to avoid overlap
|
|
574
|
-
let xOffset = 0;
|
|
575
|
-
try {
|
|
576
|
-
const posResult = await bridge.execute(`(async () => {
|
|
577
|
-
const frames = figma.currentPage.children.filter(n =>
|
|
578
|
-
n.type === 'FRAME' && !n.name.startsWith('__agent_')
|
|
579
|
-
);
|
|
580
|
-
const maxX = frames.reduce((max, f) => Math.max(max, f.x + f.width), 0);
|
|
581
|
-
return { maxX };
|
|
582
|
-
})();`);
|
|
583
|
-
const posMax = (posResult.result as { maxX?: number })?.maxX ?? 0;
|
|
584
|
-
if (posResult.success && posMax > 0) {
|
|
585
|
-
xOffset = posMax + 80;
|
|
586
|
-
}
|
|
587
|
-
} catch { /* start at 0 */ }
|
|
588
|
-
|
|
589
|
-
// 3. Spawn agent cursors across the workspace
|
|
590
|
-
const agentNames = Object.keys(AGENTS) as Array<keyof typeof AGENTS>;
|
|
591
|
-
const cursorSpacing = 200;
|
|
592
|
-
for (let i = 0; i < agentNames.length; i++) {
|
|
593
|
-
try {
|
|
594
|
-
await bridge.spawnAgentCursor(agentNames[i], xOffset + i * cursorSpacing, -60);
|
|
595
|
-
} catch { /* cursor spawn is best-effort */ }
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// 4. Run all agent preparation in TRUE PARALLEL
|
|
599
|
-
const prepStart = Date.now();
|
|
600
|
-
|
|
601
|
-
const [contentMap, componentSets, tokens] = await Promise.all([
|
|
602
|
-
// Agent: Copywriter — generate content for all zones
|
|
603
|
-
(async () => {
|
|
604
|
-
try { await bridge.updateAgentLabel("Copywriter", "Copywriter: generating content..."); } catch {}
|
|
605
|
-
const result = await agentCopywriter(brief, zones);
|
|
606
|
-
try { await bridge.updateAgentLabel("Copywriter", "Copywriter: content ready ✓"); } catch {}
|
|
607
|
-
return result;
|
|
608
|
-
})(),
|
|
609
|
-
|
|
610
|
-
// Agent: Matcher — fetch component sets for matching
|
|
611
|
-
(async () => {
|
|
612
|
-
try { await bridge.updateAgentLabel("Matcher", "Matcher: scanning components..."); } catch {}
|
|
613
|
-
const sets = await bridge.getComponentSets();
|
|
614
|
-
try { await bridge.updateAgentLabel("Matcher", `Matcher: ${sets.length} components found ✓`); } catch {}
|
|
615
|
-
return sets;
|
|
616
|
-
})(),
|
|
617
|
-
|
|
618
|
-
// Agent: Styler — fetch and resolve design tokens
|
|
619
|
-
(async () => {
|
|
620
|
-
try { await bridge.updateAgentLabel("Styler", "Styler: resolving tokens..."); } catch {}
|
|
621
|
-
let tkns: Token[] = [];
|
|
622
|
-
try { tkns = await bridge.getTokens(); } catch {}
|
|
623
|
-
try { await bridge.updateAgentLabel("Styler", `Styler: ${tkns.length} tokens resolved ✓`); } catch {}
|
|
624
|
-
return tkns;
|
|
625
|
-
})(),
|
|
626
|
-
]);
|
|
627
|
-
|
|
628
|
-
// Get the active design system — its tokens are authoritative when set
|
|
629
|
-
const dsId = bridge.getActiveDesignSystemId();
|
|
630
|
-
|
|
631
|
-
// Run dependent preparation
|
|
632
|
-
const [matchMap, palette] = await Promise.all([
|
|
633
|
-
agentMatcher(zones, componentSets),
|
|
634
|
-
agentStyler(tokens, dsId),
|
|
635
|
-
]);
|
|
636
|
-
|
|
637
|
-
const parallelPrepMs = Date.now() - prepStart;
|
|
638
|
-
|
|
639
|
-
// Apply content to zones
|
|
640
|
-
for (const zone of zones) {
|
|
641
|
-
const content = contentMap.get(zone.name);
|
|
642
|
-
if (content) zone.content = content;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
// 5. Create the main page frame
|
|
646
|
-
try { await bridge.updateAgentLabel("Layouter", "Layouter: creating page frame..."); } catch {}
|
|
647
|
-
const pageFrameResult = await bridge.execute(`(async () => {
|
|
648
|
-
const frame = figma.createFrame();
|
|
649
|
-
frame.name = ${JSON.stringify(`Swarm: ${brief.slice(0, 50)}`)};
|
|
650
|
-
frame.resize(${frameWidth}, 100);
|
|
651
|
-
frame.layoutMode = 'VERTICAL';
|
|
652
|
-
frame.primaryAxisSizingMode = 'AUTO';
|
|
653
|
-
frame.counterAxisSizingMode = 'FIXED';
|
|
654
|
-
frame.itemSpacing = 0;
|
|
655
|
-
frame.fills = [{ type: 'SOLID', color: { r: 1, g: 1, b: 1 } }];
|
|
656
|
-
frame.x = ${xOffset};
|
|
657
|
-
frame.y = 0;
|
|
658
|
-
figma.currentPage.appendChild(frame);
|
|
659
|
-
figma.viewport.scrollAndZoomIntoView([frame]);
|
|
660
|
-
return { frameId: frame.id };
|
|
661
|
-
})();`);
|
|
662
|
-
|
|
663
|
-
if (!pageFrameResult.success) {
|
|
664
|
-
throw new Error(`Failed to create page frame: ${pageFrameResult.error}`);
|
|
665
|
-
}
|
|
666
|
-
const parentFrameId = (pageFrameResult.result as { frameId: string }).frameId;
|
|
667
|
-
|
|
668
|
-
// 6. Build each zone with cursor animation
|
|
669
|
-
const zoneResults: ZoneResult[] = [];
|
|
670
|
-
const chatNoteIds: string[] = [];
|
|
671
|
-
|
|
672
|
-
for (const zone of zones) {
|
|
673
|
-
const matches = matchMap.get(zone.name) || [];
|
|
674
|
-
const agentName = zone.yOrder % 2 === 0 ? "Layouter" : "Builder";
|
|
675
|
-
|
|
676
|
-
// Move the agent's cursor to this zone's approximate position
|
|
677
|
-
try {
|
|
678
|
-
await bridge.moveAgentCursor(agentName, xOffset - 20, zone.yOrder * 300, true, 300);
|
|
679
|
-
await bridge.updateAgentLabel(agentName, `${agentName}: building ${zone.name}...`);
|
|
680
|
-
} catch {}
|
|
681
|
-
|
|
682
|
-
// Post agent chat note
|
|
683
|
-
if (showAgentChat) {
|
|
684
|
-
try {
|
|
685
|
-
const chatMsg = `${AGENTS[agentName as keyof typeof AGENTS]?.chatPrefix || "Working on"} → ${zone.name}`;
|
|
686
|
-
const noteId = await bridge.postAgentChat(
|
|
687
|
-
agentName,
|
|
688
|
-
chatMsg,
|
|
689
|
-
xOffset + frameWidth + 20,
|
|
690
|
-
zone.yOrder * 300,
|
|
691
|
-
);
|
|
692
|
-
chatNoteIds.push(noteId);
|
|
693
|
-
} catch {}
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
// Execute zone build
|
|
697
|
-
const script = buildZoneScript(zone, zone.content, matches, palette, frameWidth, parentFrameId, fontConfig);
|
|
698
|
-
const result = await bridge.execute(script);
|
|
699
|
-
|
|
700
|
-
if (result.success && result.result) {
|
|
701
|
-
const res = result.result as { zoneId: string; zoneName: string };
|
|
702
|
-
zoneResults.push({
|
|
703
|
-
zoneName: res.zoneName,
|
|
704
|
-
agent: agentName,
|
|
705
|
-
frameId: res.zoneId,
|
|
706
|
-
componentsMatched: matches.filter((m) => m.nodeId !== null).length,
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
// Update cursor label to show completion
|
|
711
|
-
try {
|
|
712
|
-
await bridge.updateAgentLabel(agentName, `${agentName}: ${zone.name} done ✓`);
|
|
713
|
-
} catch {}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
// 7. Post cross-agent collaboration chat notes
|
|
717
|
-
if (showAgentChat && zoneResults.length > 1) {
|
|
718
|
-
try {
|
|
719
|
-
const noteId = await bridge.postAgentChat(
|
|
720
|
-
"Styler",
|
|
721
|
-
`Applied ${tokens.length} tokens across ${zoneResults.length} zones`,
|
|
722
|
-
xOffset + frameWidth + 20,
|
|
723
|
-
-30,
|
|
724
|
-
);
|
|
725
|
-
chatNoteIds.push(noteId);
|
|
726
|
-
} catch {}
|
|
727
|
-
try {
|
|
728
|
-
const noteId = await bridge.postAgentChat(
|
|
729
|
-
"Copywriter",
|
|
730
|
-
`Generated copy for ${zoneResults.length} sections`,
|
|
731
|
-
xOffset + frameWidth + 180,
|
|
732
|
-
-30,
|
|
733
|
-
);
|
|
734
|
-
chatNoteIds.push(noteId);
|
|
735
|
-
} catch {}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// 8. Clean up agent cursors (leave chat notes as collaboration log)
|
|
739
|
-
await new Promise((resolve) => setTimeout(resolve, 1500)); // let user see cursors for a moment
|
|
740
|
-
for (const agentName of agentNames) {
|
|
741
|
-
try { await bridge.removeAgentCursor(agentName); } catch {}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
const totalBuildMs = Date.now() - startTime;
|
|
745
|
-
|
|
746
|
-
// Log decision
|
|
747
|
-
try {
|
|
748
|
-
decisionLog.log({
|
|
749
|
-
tool: "figma_swarm_build",
|
|
750
|
-
rationale: `Built ${zoneResults.length} zones in parallel-prep mode (${parallelPrepMs}ms prep, ${totalBuildMs}ms total) for: ${brief}`,
|
|
751
|
-
nodeIds: zoneResults.map((z) => z.frameId),
|
|
752
|
-
tokens: tokens.length > 0 ? [`${tokens.length} tokens resolved`] : [],
|
|
753
|
-
});
|
|
754
|
-
} catch {}
|
|
755
|
-
|
|
756
|
-
return {
|
|
757
|
-
zones: zoneResults,
|
|
758
|
-
frameIds: [parentFrameId, ...zoneResults.map((z) => z.frameId)],
|
|
759
|
-
agentsUsed: [...new Set(zoneResults.map((z) => z.agent))],
|
|
760
|
-
parallelPrepMs,
|
|
761
|
-
totalBuildMs,
|
|
762
|
-
chatNoteIds,
|
|
763
|
-
};
|
|
764
|
-
}
|