@salesforce/b2c-dx-mcp 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +15 -62
  2. package/dist/commands/mcp.d.ts +1 -0
  3. package/dist/commands/mcp.js +41 -9
  4. package/dist/registry.d.ts +3 -4
  5. package/dist/registry.js +7 -14
  6. package/dist/server.d.ts +1 -1
  7. package/dist/server.js +3 -1
  8. package/dist/services.d.ts +21 -1
  9. package/dist/services.js +39 -6
  10. package/dist/tools/adapter.d.ts +18 -2
  11. package/dist/tools/adapter.js +49 -10
  12. package/dist/tools/cartridges/index.js +16 -22
  13. package/dist/tools/diagnostics/config-inspect.js +4 -8
  14. package/dist/tools/diagnostics/debug-capture-at-breakpoint.js +3 -9
  15. package/dist/tools/diagnostics/debug-list-sessions.js +1 -0
  16. package/dist/tools/diagnostics/debug-start-session.js +16 -9
  17. package/dist/tools/diagnostics/debug-wait-for-stop.js +1 -3
  18. package/dist/tools/diagnostics/log-watch-registry.d.ts +3 -0
  19. package/dist/tools/diagnostics/log-watch-registry.js +1 -0
  20. package/dist/tools/diagnostics/logs-get-recent.js +2 -5
  21. package/dist/tools/diagnostics/logs-list-files.js +1 -1
  22. package/dist/tools/diagnostics/logs-watch-list.js +1 -0
  23. package/dist/tools/diagnostics/logs-watch-start.js +10 -10
  24. package/dist/tools/diagnostics/mrt-log-watch-registry.d.ts +3 -0
  25. package/dist/tools/diagnostics/mrt-log-watch-registry.js +0 -0
  26. package/dist/tools/diagnostics/mrt-logs-watch-list.js +1 -0
  27. package/dist/tools/diagnostics/mrt-logs-watch-poll.js +2 -5
  28. package/dist/tools/diagnostics/mrt-logs-watch-start.js +9 -8
  29. package/dist/tools/diagnostics/session-registry.d.ts +3 -0
  30. package/dist/tools/diagnostics/session-registry.js +2 -1
  31. package/dist/tools/docs/docs-list.js +4 -6
  32. package/dist/tools/docs/docs-read.js +2 -9
  33. package/dist/tools/docs/docs-schema-list.js +1 -1
  34. package/dist/tools/docs/docs-schema-read.js +2 -3
  35. package/dist/tools/docs/docs-schema-search.js +2 -2
  36. package/dist/tools/docs/docs-search.js +3 -9
  37. package/dist/tools/docs/storefront.js +3 -3
  38. package/dist/tools/docs/topics.js +3 -1
  39. package/dist/tools/index.d.ts +0 -1
  40. package/dist/tools/index.js +0 -1
  41. package/dist/tools/mrt/index.js +6 -2
  42. package/dist/tools/project-context.d.ts +38 -11
  43. package/dist/tools/project-context.js +32 -15
  44. package/dist/tools/pwav3/pwa-kit-development-guidelines.js +3 -43
  45. package/dist/tools/scapi/metrics-get.js +5 -23
  46. package/dist/tools/scapi/scapi-custom-api-generate-scaffold.d.ts +4 -0
  47. package/dist/tools/scapi/scapi-custom-api-generate-scaffold.js +29 -14
  48. package/dist/tools/scapi/scapi-custom-apis-get-status.js +3 -14
  49. package/dist/tools/scapi/scapi-schemas-list.js +11 -11
  50. package/dist/utils/constants.d.ts +2 -13
  51. package/dist/utils/constants.js +1 -20
  52. package/oclif.manifest.json +2 -2
  53. package/package.json +5 -5
  54. package/content/sfnext/auth.md +0 -62
  55. package/content/sfnext/components.md +0 -123
  56. package/content/sfnext/config.md +0 -180
  57. package/content/sfnext/data-fetching.md +0 -323
  58. package/content/sfnext/extensions.md +0 -80
  59. package/content/sfnext/i18n.md +0 -121
  60. package/content/sfnext/page-designer.md +0 -78
  61. package/content/sfnext/performance.md +0 -80
  62. package/content/sfnext/pitfalls.md +0 -141
  63. package/content/sfnext/quick-reference.md +0 -226
  64. package/content/sfnext/state-management.md +0 -75
  65. package/content/sfnext/styling.md +0 -51
  66. package/content/sfnext/testing.md +0 -232
  67. package/dist/tools/storefrontnext/figma/figma-to-component/figma-url-parser.d.ts +0 -24
  68. package/dist/tools/storefrontnext/figma/figma-to-component/figma-url-parser.js +0 -53
  69. package/dist/tools/storefrontnext/figma/figma-to-component/index.d.ts +0 -45
  70. package/dist/tools/storefrontnext/figma/figma-to-component/index.js +0 -332
  71. package/dist/tools/storefrontnext/figma/generate-component/decision.d.ts +0 -40
  72. package/dist/tools/storefrontnext/figma/generate-component/decision.js +0 -312
  73. package/dist/tools/storefrontnext/figma/generate-component/formatter.d.ts +0 -9
  74. package/dist/tools/storefrontnext/figma/generate-component/formatter.js +0 -92
  75. package/dist/tools/storefrontnext/figma/generate-component/index.d.ts +0 -117
  76. package/dist/tools/storefrontnext/figma/generate-component/index.js +0 -102
  77. package/dist/tools/storefrontnext/figma/map-tokens/css-parser.d.ts +0 -71
  78. package/dist/tools/storefrontnext/figma/map-tokens/css-parser.js +0 -260
  79. package/dist/tools/storefrontnext/figma/map-tokens/index.d.ts +0 -64
  80. package/dist/tools/storefrontnext/figma/map-tokens/index.js +0 -242
  81. package/dist/tools/storefrontnext/figma/map-tokens/token-matcher.d.ts +0 -65
  82. package/dist/tools/storefrontnext/figma/map-tokens/token-matcher.js +0 -268
  83. package/dist/tools/storefrontnext/index.d.ts +0 -30
  84. package/dist/tools/storefrontnext/index.js +0 -28
  85. package/dist/tools/storefrontnext/page-designer-decorator/analyzer.d.ts +0 -169
  86. package/dist/tools/storefrontnext/page-designer-decorator/analyzer.js +0 -567
  87. package/dist/tools/storefrontnext/page-designer-decorator/index.d.ts +0 -259
  88. package/dist/tools/storefrontnext/page-designer-decorator/index.js +0 -622
  89. package/dist/tools/storefrontnext/page-designer-decorator/rules/1-mode-selection.d.ts +0 -8
  90. package/dist/tools/storefrontnext/page-designer-decorator/rules/1-mode-selection.js +0 -65
  91. package/dist/tools/storefrontnext/page-designer-decorator/rules/2a-auto-mode.d.ts +0 -13
  92. package/dist/tools/storefrontnext/page-designer-decorator/rules/2a-auto-mode.js +0 -87
  93. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-0-interactive-overview.d.ts +0 -4
  94. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-0-interactive-overview.js +0 -55
  95. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-1-interactive-analyze.d.ts +0 -22
  96. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-1-interactive-analyze.js +0 -109
  97. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-2-interactive-select-props.d.ts +0 -21
  98. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-2-interactive-select-props.js +0 -60
  99. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-3-interactive-configure-attrs.d.ts +0 -27
  100. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-3-interactive-configure-attrs.js +0 -68
  101. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-4-interactive-configure-regions.d.ts +0 -4
  102. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-4-interactive-configure-regions.js +0 -65
  103. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-5-interactive-confirm-generation.d.ts +0 -11
  104. package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-5-interactive-confirm-generation.js +0 -92
  105. package/dist/tools/storefrontnext/page-designer-decorator/rules.d.ts +0 -51
  106. package/dist/tools/storefrontnext/page-designer-decorator/rules.js +0 -70
  107. package/dist/tools/storefrontnext/page-designer-decorator/templates/decorator-generator.d.ts +0 -116
  108. package/dist/tools/storefrontnext/page-designer-decorator/templates/decorator-generator.js +0 -350
  109. package/dist/tools/storefrontnext/sfnext-development-guidelines.d.ts +0 -9
  110. package/dist/tools/storefrontnext/sfnext-development-guidelines.js +0 -141
  111. package/dist/tools/storefrontnext/site-theming/color-contrast.d.ts +0 -92
  112. package/dist/tools/storefrontnext/site-theming/color-contrast.js +0 -186
  113. package/dist/tools/storefrontnext/site-theming/color-mapping.d.ts +0 -16
  114. package/dist/tools/storefrontnext/site-theming/color-mapping.js +0 -131
  115. package/dist/tools/storefrontnext/site-theming/guidance-merger.d.ts +0 -11
  116. package/dist/tools/storefrontnext/site-theming/guidance-merger.js +0 -78
  117. package/dist/tools/storefrontnext/site-theming/index.d.ts +0 -14
  118. package/dist/tools/storefrontnext/site-theming/index.js +0 -128
  119. package/dist/tools/storefrontnext/site-theming/response-builder.d.ts +0 -16
  120. package/dist/tools/storefrontnext/site-theming/response-builder.js +0 -316
  121. package/dist/tools/storefrontnext/site-theming/theming-store.d.ts +0 -64
  122. package/dist/tools/storefrontnext/site-theming/theming-store.js +0 -417
  123. package/dist/tools/storefrontnext/site-theming/types.d.ts +0 -36
  124. package/dist/tools/storefrontnext/site-theming/types.js +0 -7
@@ -1,332 +0,0 @@
1
- /*
2
- * Copyright (c) 2025, Salesforce, Inc.
3
- * SPDX-License-Identifier: Apache-2
4
- * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
- */
6
- /**
7
- * Figma-to-component workflow orchestrator tool.
8
- *
9
- * Parses Figma URLs, loads workflow instructions, and returns step-by-step guidance
10
- * for converting Figma designs to Storefront Next components.
11
- *
12
- * @module tools/storefrontnext/figma/figma-to-component
13
- */
14
- import { z } from 'zod';
15
- import { readFileSync, existsSync } from 'node:fs';
16
- import { createToolAdapter, textResult } from '../../../adapter.js';
17
- import { projectDirectoryInput } from '../../../project-context.js';
18
- import { parseFigmaUrl } from './figma-url-parser.js';
19
- // prettier-ignore
20
- const DEFAULT_WORKFLOW_CONTENT = `---
21
- description: Figma to StorefrontNext component conversion workflow
22
- taskType: component
23
- ---
24
- # Figma to StorefrontNext Component Workflow
25
-
26
- IMPORTANT: The figma_to_component tool is a WORKFLOW ORCHESTRATOR that provides instructions only. It does NOT fetch design data or generate components.
27
-
28
- After calling figma_to_component, you MUST:
29
- 1. Call Figma MCP tools to fetch design data
30
- 2. Discover similar components using Glob/Grep/Read
31
- 3. Call generate-component tool for REUSE/EXTEND/CREATE recommendation
32
- 4. Call map-tokens tool for token mapping
33
- 5. Implement the recommended approach
34
-
35
- DO NOT STOP after receiving workflow instructions. Execute all steps to complete the conversion.
36
-
37
- ## WORKFLOW_GUIDELINES
38
-
39
- ### Overview
40
- This workflow guides through converting a Figma design into a StorefrontNext-compliant component.
41
-
42
- ### Key Principles
43
- 1. Review workflow plan and list out todos to user before fetching designs
44
- 2. ALWAYS fetch design context and visual reference from Figma MCP tools first. Do not attempt to generate code without retrieving at minimum the design context and screenshot. Metadata is optional
45
- 2a. **NEVER pass dirForAssetWrites on the initial get_design_context call.** Call it first WITHOUT that parameter to inspect the response. Only pass dirForAssetWrites after the user has explicitly approved image export.
46
- 2b. **MANDATORY GATE - Image export requires user approval:** Do NOT call get_design_context with dirForAssetWrites for ANY node until you have: (1) identified all image-containing nodes, (2) presented the list to the user, (3) asked "Should I export these N image assets now? (yes/no)", and (4) received an explicit "yes". Do NOT export images automatically.
47
- 2c. **Single prompt per batch:** Ask ONCE for the entire batch of image nodes. After the user says "yes", export all of them (via one or more get_design_context calls with dirForAssetWrites). Do NOT prompt again for each individual image.
48
- 3. Only call the Figma MCP tools listed in this workflow. If a tool is not available or not enabled, inform the user
49
- 4. ALWAYS discover similar components before creating new ones. Use Glob/Grep/Read to search the codebase
50
- 5. ALWAYS call generate-component tool with discovered components to get REUSE/EXTEND/CREATE recommendation
51
- 6. ALWAYS call map-tokens tool to map Figma tokens to existing theme variables rather than hardcoding values
52
- 7. Follow StorefrontNext patterns. All components must adhere to StorefrontNext architecture
53
- 8. Present a detailed plan to the user and wait for approval before implementing
54
- 9. Validate thoroughly. Always run validation checks before presenting the final component to the developer
55
-
56
- ### Figma MCP Tools
57
- When calling these tools, always include: clientLanguages="typescript", clientFrameworks="react"
58
- - mcp__figma__get_design_context (REQUIRED): Generates UI code and returns asset URLs. **Initial call: do NOT pass dirForAssetWrites.** Call first without it to inspect the response. Only pass dirForAssetWrites after user has approved export (see Image and Asset Export below).
59
- - mcp__figma__get_screenshot (REQUIRED): Provides visual reference of the design
60
- - mcp__figma__get_metadata (REQUIRED when node is a section): Retrieves node hierarchy, layer types, names, positions, and sizes. Use when get_design_context returns sparse metadata (section nodes do not export assets)
61
-
62
- ### Image and Asset Export (REQUIRED)
63
- **MANDATORY GATE: Do not call get_design_context with dirForAssetWrites until the user has approved. You MUST ask ONCE for the entire batch—never prompt per image.**
64
-
65
- Section nodes return sparse metadata and do NOT export images. You MUST:
66
-
67
- 1. **Initial probe (no export)**: Call get_design_context WITHOUT dirForAssetWrites first. Never pass dirForAssetWrites on the first call.
68
- 2. **Detect sparse response**: If get_design_context returns "sparse metadata" or "section node", call get_metadata with the same nodeId to retrieve the XML with child node IDs
69
- 3. **Identify image-containing nodes**: From the metadata XML (or from the initial response if it's a leaf with images), find nodes that contain images. Include: RECTANGLE with fills; nodes named with image-like names (e.g., photo, image, banner, hero); logos and brand assets (nodes named "logo", "Logo", "brand", "icon", "header", "footer", or similar); vector/component instances that represent logos or icons; frames that visually contain photos/illustrations; any node the screenshot suggests contains a logo or brand asset
70
- 4. **STOP and ask for approval (MANDATORY)**: Present the list of identified nodes (names and node IDs) to the user. Ask explicitly: "I found N image-containing nodes. Should I export these assets now? (yes/no)". STOP and wait for the user to respond. Do NOT call get_design_context with dirForAssetWrites for any node until the user confirms "yes". If you proceed without user confirmation, you have violated this workflow
71
- 5. **Download image nodes** (ONLY after user says "yes"): For each identified image-containing node, call get_design_context with:
72
- - nodeId: the node ID from metadata or initial selection (e.g., "3351:1234")
73
- - dirForAssetWrites: absolute path to the project's public images folder (e.g., \`{workspace}/packages/template-retail-rsc-app/public/images/figma-exports\`)
74
- 6. **Track downloaded assets**: Note which exported file path corresponds to which node/component (e.g., hero banner → hero-banner.webp, logo → nettle-logo.webp, category card 1 → infused-beverages.webp)
75
- 7. **Set image URLs in implementation**: When implementing the component, use the downloaded file paths for any img src or imageUrl props. Replace placeholder paths with the actual exported asset paths (e.g., \`/images/figma-exports/hero-banner.webp\`)
76
-
77
- ### StorefrontNext MCP Tools (REQUIRED)
78
- - generate-component: Analyzes Figma design and discovered components, recommends REUSE/EXTEND/CREATE strategy. MUST be called with discoveredComponents parameter
79
- - map-tokens: Maps Figma design tokens to existing theme tokens. MUST be called to avoid hardcoded values
80
- - validate_component: Validates component against StorefrontNext patterns (optional, not yet implemented)
81
-
82
- ### AI-Driven Component Discovery (Before calling generate-component)
83
- Before calling generate-component, you must discover similar components using your tools:
84
-
85
- **Discovery Strategy:**
86
- 1. **Name-Based Search (Primary):**
87
- - Use Glob to find component files: \`**/components/**/*.tsx\`, \`**/src/**/*.tsx\`
88
- - Exclude: \`**/node_modules/**\`, \`**/dist/**\`, \`**/*.test.tsx\`, \`**/*.stories.tsx\`
89
- - Use Grep to search for component names similar to the Figma component name
90
- - Look in: export statements, function names, interface names
91
-
92
- 2. **Structure-Based Search (Secondary):**
93
- - If name search yields poor results, search by code structure
94
- - Look for similar hooks (useState, useEffect, etc.)
95
- - Look for similar element patterns (buttons, forms, layouts)
96
- - Search for 'use client' directive if Figma code is client-side
97
-
98
- 3. **Read and Score Components:**
99
- - Read each promising match
100
- - Score similarity (0-100) based on:
101
- * Name similarity: How close is the name?
102
- * Purpose similarity: Does it serve the same function?
103
- * Structure similarity: Similar JSX structure, hooks, props?
104
- * Styling similarity: Similar Tailwind classes or theme usage?
105
- - Assign match type: 'name', 'structure', or 'visual'
106
-
107
- 4. **Select Top Matches:**
108
- - Select top 1-3 matches with similarity >= 50%
109
- - Sort by similarity score (highest first)
110
- - If no matches found, pass empty array to generate-component
111
-
112
- **Discovery Tips:**
113
- - Be semantic: "PrimaryButton" and "CallToAction" might serve the same purpose
114
- - Consider component purpose and context, not just file names
115
- - Check common directories first: components/ui/, components/shared/
116
- - Read component code to understand structure, props, and behavior
117
- - Trust your judgment using React patterns knowledge
118
-
119
- ### Component Requirements
120
- - Use React Server Components (RSC) pattern by default
121
- - Use Tailwind CSS classes with theme tokens, no inline styles or hardcoded values
122
- - Follow TypeScript strict mode conventions
123
- - Include proper accessibility attributes
124
- - Follow existing file naming conventions
125
- - Use absolute imports from '@/components', '@/lib', etc.
126
-
127
- ## General Development Guidelines
128
-
129
- ### Core Principles
130
- - Thoroughly analyze requests and the existing project for successful implementation
131
- - Promptly clarify ambiguous requirements
132
-
133
- ### Development Workflow
134
- - **Analyze Requirements** - Clearly define the objectives and functionalities required
135
- - **Review Existing Code** - Examine the current codebase to identify similar solutions and potentially reusable components
136
- - **Understand Existing Hooks and Utilities** - Familiarize with hooks and utility functions available within the project
137
- - **Plan Implementation** - Design component structure before coding
138
- - **Implement Incrementally** - Develop and test the service in small, manageable steps
139
- - **Test Thoroughly** - Ensure comprehensive testing
140
-
141
- ### After Generation
142
- - Present the component code to the developer for review
143
- - Provide file path suggestions based on component type
144
- - Highlight any design tokens that don't have existing mappings
145
- - List any validation warnings or suggestions
146
-
147
- ## WORKFLOW_STEPS
148
-
149
- **Create and present to the user a task plan that reflects these steps while keeping the Workflow Guidelines in mind. Wait for approval before proceeding.**
150
-
151
- 1. REQUIRED: Retrieve design context using mcp__figma__get_design_context with fileKey and nodeId. **Do NOT pass dirForAssetWrites on this initial call.** If the response is sparse (section node): call get_metadata, identify image-containing nodes, then STOP and ask the user "Should I export these N image assets now? (yes/no)". WAIT for user to respond. Only after user says "yes", call get_design_context for each image-containing node with dirForAssetWrites
152
- 2. REQUIRED: Retrieve visual reference using mcp__figma__get_screenshot with the provided fileKey and nodeId
153
- 3. REQUIRED when sparse: If get_design_context returns sparse metadata (section node), call mcp__figma__get_metadata to get child node IDs, identify image-containing nodes, then STOP and ask user for approval. Do NOT call get_design_context with dirForAssetWrites until user confirms "yes"
154
- 4. REQUIRED: Discover similar components in the codebase:
155
- - Use Glob to find component files in common directories
156
- - Use Grep to search for components with similar names or structure
157
- - Use Read to examine promising matches
158
- - Score similarity (0-100) and select top 1-3 matches
159
- - Prepare discoveredComponents array for next step
160
- 5. REQUIRED: Analyze component generation strategy using generate-component tool with discovered components. This provides REUSE/EXTEND/CREATE recommendation. Wait for user approval of strategy before code changes
161
- 6. REQUIRED: Map Figma design tokens to existing StorefrontNext theme tokens using the map-tokens tool. Extract color, spacing, and other design tokens from Figma data and pass them to this tool for matching
162
- 7. OPTIONAL (not implemented): Validate the generated component against StorefrontNext patterns using the validate_component tool
163
- 8. REQUIRED: Implement the recommended approach and present the final component code to the developer for review`;
164
- export const figmaToComponentSchema = z
165
- .object({
166
- figmaUrl: z
167
- .string()
168
- .url()
169
- .describe('The Figma design URL to convert to a StorefrontNext component. Must include node-id parameter.'),
170
- workflowFilePath: z
171
- .string()
172
- .optional()
173
- .describe('Optional path to a custom workflow .md file, resolved relative to projectDirectory when needed. If omitted, uses the default built-in workflow.'),
174
- projectDirectory: projectDirectoryInput,
175
- })
176
- .strict();
177
- function extractWorkflowContent(content) {
178
- const metadata = {};
179
- let body = content;
180
- const metadataMatch = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/);
181
- if (metadataMatch) {
182
- const metadataText = metadataMatch[1];
183
- body = metadataMatch[2];
184
- for (const line of metadataText.split('\n')) {
185
- const match = line.match(/^(.+?):\s*(.+)$/);
186
- if (match) {
187
- metadata[match[1].trim()] = match[2].trim();
188
- }
189
- }
190
- }
191
- return { metadata, body: body.trim() };
192
- }
193
- function parseWorkflowFile(filePath) {
194
- let fileContent;
195
- if (filePath) {
196
- if (!existsSync(filePath)) {
197
- throw new Error(`Workflow file not found: ${filePath}`);
198
- }
199
- fileContent = readFileSync(filePath, 'utf8');
200
- }
201
- else {
202
- fileContent = DEFAULT_WORKFLOW_CONTENT;
203
- }
204
- const { metadata, body } = extractWorkflowContent(fileContent);
205
- return { metadata, content: body };
206
- }
207
- function formatFigmaParams(params, originalUrl) {
208
- let section = '## Figma Design Parameters\n\n';
209
- section += '```json\n';
210
- section += JSON.stringify({
211
- fileKey: params.fileKey,
212
- nodeId: params.nodeId,
213
- originalUrl,
214
- }, null, 2);
215
- section += '\n```\n\n';
216
- section +=
217
- 'IMPORTANT: Use these exact parameters when calling Figma MCP tools. The `clientLanguages` parameter should be set to "typescript" and `clientFrameworks` should be set to "react".\n\n';
218
- return section;
219
- }
220
- function formatWorkflowContent(content) {
221
- return `${content}\n\n`;
222
- }
223
- function formatNextStepsReminder() {
224
- return `---
225
- ## CRITICAL: Next Steps Required
226
-
227
- This tool has provided workflow instructions only. You MUST now execute ALL steps below.
228
-
229
- **EXPECTED FINAL OUTPUT:** A recommendation with confidence score from sfnext_analyze_component tool AND a token mapping summary from sfnext_match_tokens_to_theme tool.
230
-
231
- ### Step 1: Fetch Figma Design Data (Parallel Calls)
232
- Call these Figma MCP tools with the parameters above:
233
- - \`mcp__figma__get_design_context\` (REQUIRED) - **Do NOT pass dirForAssetWrites on the initial call.** Call first without it to inspect the response. If response is sparse (section node): call get_metadata to get child node IDs, identify image-containing nodes, then STOP and present the list to the user. Ask "Should I export these N image assets now? (yes/no)" and WAIT for user response. Only after user says "yes", call get_design_context per image-containing node with dirForAssetWrites
234
- - \`mcp__figma__get_screenshot\` (REQUIRED) - Get visual reference
235
- - \`mcp__figma__get_metadata\` (REQUIRED when sparse) - Use when get_design_context returns sparse metadata. After identifying image nodes: STOP, present list to user, wait for "yes" before exporting
236
-
237
- ### Step 2: Discover Similar Components
238
- Use your tools to find existing components:
239
- - Use \`Glob\` to find component files: \`**/components/**/*.tsx\`
240
- - Use \`Grep\` to search for similar names or patterns
241
- - Use \`Read\` to examine promising matches
242
- - Score each match (0-100) based on similarity
243
-
244
- ### Step 3: Analyze Component Strategy (CRITICAL - DO NOT SKIP)
245
- You MUST call \`sfnext_analyze_component\` tool with:
246
- - figmaMetadata (from step 1, or empty string if not fetched)
247
- - figmaCode (from step 1)
248
- - componentName (extracted from Figma)
249
- - discoveredComponents (from step 2)
250
-
251
- This tool returns the recommendation with confidence score that MUST be shown to the user.
252
-
253
- ### Step 4: Map Design Tokens (CRITICAL - DO NOT SKIP)
254
- You MUST call \`sfnext_match_tokens_to_theme\` tool with tokens extracted from Figma design.
255
-
256
- This tool returns the token mapping summary that MUST be shown to the user.
257
-
258
- ### Step 5: Implement
259
- After showing the recommendation and token mapping to the user, wait for approval then implement the code changes. Use the downloaded asset paths from Step 1 for any img src or imageUrl props—do not use placeholder paths.
260
-
261
- **DO NOT STOP until you have called sfnext_analyze_component AND sfnext_match_tokens_to_theme and shown their outputs to the user.**
262
- `;
263
- }
264
- function formatErrorResponse(details) {
265
- let response = `# Error: Invalid Figma URL\n\n${details}\n\n`;
266
- response += 'Please provide a valid Figma URL in the format:\n';
267
- response += 'https://figma.com/design/:fileKey/:fileName?node-id=1-2\n\n';
268
- response += 'Example:\nhttps://figma.com/design/abc123/MyDesign?node-id=1-2\n';
269
- return response;
270
- }
271
- /**
272
- * Generates the workflow guide for Figma-to-component conversion.
273
- *
274
- * @param figmaUrl - Figma design URL with node-id query parameter
275
- * @param workflowFilePath - Optional absolute path to custom workflow .md file; uses built-in default if omitted
276
- * @returns Formatted workflow guide string with Figma parameters and step-by-step instructions, or error message if URL or workflow file is invalid
277
- */
278
- export function generateWorkflowResponse(figmaUrl, workflowFilePath) {
279
- let figmaParams;
280
- try {
281
- figmaParams = parseFigmaUrl(figmaUrl);
282
- }
283
- catch (error) {
284
- const errorMessage = error instanceof Error ? error.message : String(error);
285
- return formatErrorResponse(errorMessage);
286
- }
287
- let workflowConfig;
288
- try {
289
- workflowConfig = parseWorkflowFile(workflowFilePath);
290
- }
291
- catch (error) {
292
- const errorMessage = error instanceof Error ? error.message : String(error);
293
- return `# Error: Workflow File Not Found\n\n${errorMessage}\n\nPlease provide a valid workflow file path or omit the parameter to use the default workflow.\n`;
294
- }
295
- let response = '# Figma to StorefrontNext Workflow Guide\n\n';
296
- response += formatFigmaParams(figmaParams, figmaUrl);
297
- response += formatWorkflowContent(workflowConfig.content);
298
- response += formatNextStepsReminder();
299
- return response;
300
- }
301
- /**
302
- * Creates the sfnext_start_figma_workflow MCP tool.
303
- *
304
- * @param loadServices - Function that loads configuration and returns Services instance
305
- * @returns MCP tool for workflow orchestration
306
- */
307
- export function createFigmaToComponentTool(loadServices) {
308
- return createToolAdapter({
309
- name: 'sfnext_start_figma_workflow',
310
- description: '[DEPRECATED] Superseded by the storefront-next and storefront-next-figma agent-skills plugins and NOT compatible with the Storefront Next 1.0 GA release. Will be removed in a future release. ' +
311
- 'WORKFLOW ORCHESTRATOR: Call this tool FIRST when converting Figma designs. ' +
312
- 'Parses Figma URL to extract fileKey and nodeId, returns step-by-step workflow instructions ' +
313
- 'and parameters for subsequent tool calls. ' +
314
- 'CRITICAL: This is only the FIRST step. After calling this tool, you MUST continue executing ' +
315
- 'the complete workflow: 1) Call Figma MCP tools, 2) Discover similar components, ' +
316
- '3) Call sfnext_analyze_component tool, 4) Call sfnext_match_tokens_to_theme tool, ' +
317
- '5) Show both outputs to the user then implement the recommended approach.',
318
- toolsets: ['STOREFRONTNEXT_DEPRECATED'],
319
- isGA: false,
320
- requiresInstance: false,
321
- usesProjectContext: true,
322
- inputSchema: figmaToComponentSchema.shape,
323
- async execute(args, context) {
324
- const workflowFilePath = args.workflowFilePath
325
- ? context.services.resolveWithProjectDirectory(args.workflowFilePath, args.projectDirectory)
326
- : undefined;
327
- return generateWorkflowResponse(args.figmaUrl, workflowFilePath);
328
- },
329
- formatOutput: (output) => textResult(output),
330
- }, loadServices);
331
- }
332
- //# sourceMappingURL=index.js.map
@@ -1,40 +0,0 @@
1
- import type { SimilarComponent, ComponentAnalysisResult } from './index.js';
2
- /**
3
- * Categorized differences between a matched component and Figma design
4
- * @property {DifferenceDetail[]} styling - Visual differences (Tailwind classes, inline styles, theme tokens)
5
- * @property {DifferenceDetail[]} structural - JSX hierarchy differences (elements, nesting, root element changes)
6
- * @property {DifferenceDetail[]} behavioral - Interaction differences (hooks, event handlers, client/server rendering)
7
- * @property {DifferenceDetail[]} props - Interface/prop definition differences (new props, type changes)
8
- */
9
- export interface ComponentDifferences {
10
- styling: DifferenceDetail[];
11
- structural: DifferenceDetail[];
12
- behavioral: DifferenceDetail[];
13
- props: DifferenceDetail[];
14
- }
15
- /**
16
- * Details about a specific difference between components
17
- * @property {string} description - Explanation of the difference
18
- * @property {'major'|'minor'|'moderate'} severity - Impact level: 'minor' (1pt), 'moderate' (3pts), 'major' (5pts)
19
- * @property {boolean} isBackwardCompatible - Whether existing code using the component would still work after this change
20
- */
21
- export interface DifferenceDetail {
22
- description: string;
23
- severity: 'major' | 'minor' | 'moderate';
24
- isBackwardCompatible: boolean;
25
- }
26
- /**
27
- * Analyzes differences between matched component and Figma design.
28
- *
29
- * @param matchedComponent - The existing component to compare against
30
- * @param figmaCode - The Figma-generated React code
31
- * @param _figmaMetadata - Reserved for future use (e.g., component hierarchy analysis).
32
- * Currently unused but kept in the signature to avoid a breaking change once metadata
33
- * analysis is implemented.
34
- */
35
- export declare function analyzeComponentDifferences(matchedComponent: SimilarComponent, figmaCode: string, _figmaMetadata: string): ComponentDifferences;
36
- /**
37
- * Determines the appropriate action based on differences
38
- * Uses type of difference + impact assessment
39
- */
40
- export declare function determineAction(matchedComponent: SimilarComponent, differences: ComponentDifferences): ComponentAnalysisResult;