@biolab/talk-to-figma 0.4.0 → 0.5.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/dist/cli.js CHANGED
@@ -1490,6 +1490,67 @@ ${failedResults.map(
1490
1490
  }
1491
1491
  }
1492
1492
  );
1493
+ server.tool(
1494
+ "create_component",
1495
+ "Convert an existing node (typically a frame) into a reusable Figma Component. The node must not be nested inside another component, component set, or instance.",
1496
+ {
1497
+ nodeId: z.string().describe("ID of the node to convert into a component")
1498
+ },
1499
+ async ({ nodeId }) => {
1500
+ try {
1501
+ const result = await sendCommandToFigma("create_component", { nodeId });
1502
+ const typedResult = result;
1503
+ return {
1504
+ content: [
1505
+ {
1506
+ type: "text",
1507
+ text: `Created component "${typedResult.name}" with ID: ${typedResult.id}, key: ${typedResult.key}`
1508
+ }
1509
+ ]
1510
+ };
1511
+ } catch (error) {
1512
+ return {
1513
+ content: [
1514
+ {
1515
+ type: "text",
1516
+ text: `Error creating component: ${error instanceof Error ? error.message : String(error)}`
1517
+ }
1518
+ ]
1519
+ };
1520
+ }
1521
+ }
1522
+ );
1523
+ server.tool(
1524
+ "create_component_set",
1525
+ "Combine multiple Component nodes into a single ComponentSet (variant component). All provided nodes must already be Components (use create_component first). Components should use naming like 'property=value, property=value' for Figma to auto-detect variant properties.",
1526
+ {
1527
+ nodeIds: z.array(z.string()).min(1).describe("Array of Component node IDs to combine into a variant set"),
1528
+ parentId: z.string().optional().describe("Optional parent node ID. Defaults to the first component's parent.")
1529
+ },
1530
+ async ({ nodeIds, parentId }) => {
1531
+ try {
1532
+ const result = await sendCommandToFigma("create_component_set", { nodeIds, parentId });
1533
+ const typedResult = result;
1534
+ return {
1535
+ content: [
1536
+ {
1537
+ type: "text",
1538
+ text: `Created component set "${typedResult.name}" with ID: ${typedResult.id}, containing ${typedResult.childCount} variants`
1539
+ }
1540
+ ]
1541
+ };
1542
+ } catch (error) {
1543
+ return {
1544
+ content: [
1545
+ {
1546
+ type: "text",
1547
+ text: `Error creating component set: ${error instanceof Error ? error.message : String(error)}`
1548
+ }
1549
+ ]
1550
+ };
1551
+ }
1552
+ }
1553
+ );
1493
1554
  server.tool(
1494
1555
  "get_instance_overrides",
1495
1556
  "Get all override properties from a selected component instance. These overrides can be applied to other instances, which will swap them to match the source component.",