跳转到内容

Modification

用于修补、删除、克隆和重新排列节点的工具

此分类共 4 个工具。

edit

Patch properties on nodes. Combines geometry (x/y/width/height), appearance (fill, stroke, cornerRadius, opacity, effects, constraints, exportSettings), layout (auto-layout), text (font props), and arbitrary properties in one call. Prefer styleName over hardcoded colors. Batch: pass multiple items.

ParameterTypeRequiredDescription
itemsobject[]Array of nodes to patch
nodeIdstringNode ID
xnumberX position
ynumberY position
widthnumberWidth (must provide height too)
heightnumberHeight (must provide width too)
fillobjectFill color, style, or clear
colorobjectHex "#FF0000" or {r,g,b,a?} with values 0-1.
rnumber
gnumber
bnumber
anumber
styleNamestringPaint style name (preferred over color)
clearbooleanSet true to remove all fills
strokeobjectStroke color/weight or style
colorobjectHex "#FF0000" or {r,g,b,a?} with values 0-1.
rnumber
gnumber
bnumber
anumber
weightnumberStroke weight
styleNamestringPaint style name (preferred over color)
cornerRadiusobjectCorner radius
radiusnumberCorner radius
cornersboolean[]Which corners [topLeft, topRight, bottomRight, bottomLeft]. Default: all.
opacitynumberOpacity (0-1)
effectsobjectEffects or effect style
effectsobject[]Effect objects
type"DROP_SHADOW" | "INNER_SHADOW" | "LAYER_BLUR" | "BACKGROUND_BLUR"
colorobjectHex "#FF0000" or {r,g,b,a?} with values 0-1.
rnumber
gnumber
bnumber
anumber
offsetobject
xnumber
ynumber
radiusnumber
spreadnumber
visibleboolean
blendModestring
styleNamestringEffect style name (preferred over raw effects)
constraintsobjectLayout constraints
horizontal"MIN" | "CENTER" | "MAX" | "STRETCH" | "SCALE"
vertical"MIN" | "CENTER" | "MAX" | "STRETCH" | "SCALE"
exportSettingsobject[]Export settings
format"PNG" | "JPG" | "SVG" | "PDF"
suffixstring
contentsOnlyboolean
constraintobject
type"SCALE" | "WIDTH" | "HEIGHT"
valuenumber
layoutobjectAuto-layout properties
layoutMode"NONE" | "HORIZONTAL" | "VERTICAL"
layoutWrap"NO_WRAP" | "WRAP"
paddingTopnumber
paddingRightnumber
paddingBottomnumber
paddingLeftnumber
primaryAxisAlignItems"MIN" | "MAX" | "CENTER" | "SPACE_BETWEEN"
counterAxisAlignItems"MIN" | "MAX" | "CENTER" | "BASELINE"
layoutSizingHorizontal"FIXED" | "HUG" | "FILL"
layoutSizingVertical"FIXED" | "HUG" | "FILL"
itemSpacingnumber
counterAxisSpacingnumber
textobjectText properties (font, alignment, sizing)
fontSizenumber
fontWeightnumber
fontColorobjectHex "#FF0000" or {r,g,b,a?} with values 0-1.
rnumber
gnumber
bnumber
anumber
textStyleIdstring
textStyleNamestring
textAlignHorizontal"LEFT" | "CENTER" | "RIGHT" | "JUSTIFIED"
textAlignVertical"TOP" | "CENTER" | "BOTTOM"
textAutoResize"NONE" | "WIDTH_AND_HEIGHT" | "HEIGHT" | "TRUNCATE"
layoutSizingHorizontal"FIXED" | "HUG" | "FILL"
layoutSizingVertical"FIXED" | "HUG" | "FILL"
propertiesobjectArbitrary key-value properties to set directly on the node
depthnumberResponse detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.
JSON Schema
{
  "type": "object",
  "properties": {
    "items": {
      "description": "Array of nodes to patch",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "nodeId": {
            "type": "string",
            "description": "Node ID"
          },
          "x": {
            "description": "X position",
            "type": "number"
          },
          "y": {
            "description": "Y position",
            "type": "number"
          },
          "width": {
            "description": "Width (must provide height too)",
            "type": "number",
            "exclusiveMinimum": 0
          },
          "height": {
            "description": "Height (must provide width too)",
            "type": "number",
            "exclusiveMinimum": 0
          },
          "fill": {
            "description": "Fill color, style, or clear",
            "type": "object",
            "properties": {
              "color": {
                "description": "Hex \"#FF0000\" or {r,g,b,a?} with values 0-1.",
                "type": "object",
                "properties": {
                  "r": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "g": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "b": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "a": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b"
                ]
              },
              "styleName": {
                "description": "Paint style name (preferred over color)",
                "type": "string"
              },
              "clear": {
                "description": "Set true to remove all fills",
                "type": "boolean"
              }
            }
          },
          "stroke": {
            "description": "Stroke color/weight or style",
            "type": "object",
            "properties": {
              "color": {
                "description": "Hex \"#FF0000\" or {r,g,b,a?} with values 0-1.",
                "type": "object",
                "properties": {
                  "r": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "g": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "b": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "a": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b"
                ]
              },
              "weight": {
                "description": "Stroke weight",
                "type": "number",
                "exclusiveMinimum": 0
              },
              "styleName": {
                "description": "Paint style name (preferred over color)",
                "type": "string"
              }
            }
          },
          "cornerRadius": {
            "description": "Corner radius",
            "type": "object",
            "properties": {
              "radius": {
                "type": "number",
                "minimum": 0,
                "description": "Corner radius"
              },
              "corners": {
                "description": "Which corners [topLeft, topRight, bottomRight, bottomLeft]. Default: all.",
                "minItems": 4,
                "maxItems": 4,
                "type": "array",
                "items": {
                  "type": "boolean"
                }
              }
            },
            "required": [
              "radius"
            ]
          },
          "opacity": {
            "description": "Opacity (0-1)",
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "effects": {
            "description": "Effects or effect style",
            "type": "object",
            "properties": {
              "effects": {
                "description": "Effect objects",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "DROP_SHADOW",
                        "INNER_SHADOW",
                        "LAYER_BLUR",
                        "BACKGROUND_BLUR"
                      ]
                    },
                    "color": {
                      "description": "Hex \"#FF0000\" or {r,g,b,a?} with values 0-1.",
                      "type": "object",
                      "properties": {
                        "r": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        },
                        "g": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        },
                        "b": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        },
                        "a": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        }
                      },
                      "required": [
                        "r",
                        "g",
                        "b"
                      ]
                    },
                    "offset": {
                      "type": "object",
                      "properties": {
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "x",
                        "y"
                      ]
                    },
                    "radius": {
                      "type": "number"
                    },
                    "spread": {
                      "type": "number"
                    },
                    "visible": {
                      "type": "boolean"
                    },
                    "blendMode": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "radius"
                  ]
                }
              },
              "styleName": {
                "description": "Effect style name (preferred over raw effects)",
                "type": "string"
              }
            }
          },
          "constraints": {
            "description": "Layout constraints",
            "type": "object",
            "properties": {
              "horizontal": {
                "type": "string",
                "enum": [
                  "MIN",
                  "CENTER",
                  "MAX",
                  "STRETCH",
                  "SCALE"
                ]
              },
              "vertical": {
                "type": "string",
                "enum": [
                  "MIN",
                  "CENTER",
                  "MAX",
                  "STRETCH",
                  "SCALE"
                ]
              }
            },
            "required": [
              "horizontal",
              "vertical"
            ]
          },
          "exportSettings": {
            "description": "Export settings",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "format": {
                  "type": "string",
                  "enum": [
                    "PNG",
                    "JPG",
                    "SVG",
                    "PDF"
                  ]
                },
                "suffix": {
                  "type": "string"
                },
                "contentsOnly": {
                  "type": "boolean"
                },
                "constraint": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "SCALE",
                        "WIDTH",
                        "HEIGHT"
                      ]
                    },
                    "value": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "type",
                    "value"
                  ]
                }
              },
              "required": [
                "format"
              ]
            }
          },
          "layout": {
            "description": "Auto-layout properties",
            "type": "object",
            "properties": {
              "layoutMode": {
                "type": "string",
                "enum": [
                  "NONE",
                  "HORIZONTAL",
                  "VERTICAL"
                ]
              },
              "layoutWrap": {
                "type": "string",
                "enum": [
                  "NO_WRAP",
                  "WRAP"
                ]
              },
              "paddingTop": {
                "type": "number"
              },
              "paddingRight": {
                "type": "number"
              },
              "paddingBottom": {
                "type": "number"
              },
              "paddingLeft": {
                "type": "number"
              },
              "primaryAxisAlignItems": {
                "type": "string",
                "enum": [
                  "MIN",
                  "MAX",
                  "CENTER",
                  "SPACE_BETWEEN"
                ]
              },
              "counterAxisAlignItems": {
                "type": "string",
                "enum": [
                  "MIN",
                  "MAX",
                  "CENTER",
                  "BASELINE"
                ]
              },
              "layoutSizingHorizontal": {
                "type": "string",
                "enum": [
                  "FIXED",
                  "HUG",
                  "FILL"
                ]
              },
              "layoutSizingVertical": {
                "type": "string",
                "enum": [
                  "FIXED",
                  "HUG",
                  "FILL"
                ]
              },
              "itemSpacing": {
                "type": "number"
              },
              "counterAxisSpacing": {
                "type": "number"
              }
            }
          },
          "text": {
            "description": "Text properties (font, alignment, sizing)",
            "type": "object",
            "properties": {
              "fontSize": {
                "type": "number"
              },
              "fontWeight": {
                "type": "number"
              },
              "fontColor": {
                "description": "Hex \"#FF0000\" or {r,g,b,a?} with values 0-1.",
                "type": "object",
                "properties": {
                  "r": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "g": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "b": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "a": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "r",
                  "g",
                  "b"
                ]
              },
              "textStyleId": {
                "type": "string"
              },
              "textStyleName": {
                "type": "string"
              },
              "textAlignHorizontal": {
                "type": "string",
                "enum": [
                  "LEFT",
                  "CENTER",
                  "RIGHT",
                  "JUSTIFIED"
                ]
              },
              "textAlignVertical": {
                "type": "string",
                "enum": [
                  "TOP",
                  "CENTER",
                  "BOTTOM"
                ]
              },
              "textAutoResize": {
                "type": "string",
                "enum": [
                  "NONE",
                  "WIDTH_AND_HEIGHT",
                  "HEIGHT",
                  "TRUNCATE"
                ]
              },
              "layoutSizingHorizontal": {
                "type": "string",
                "enum": [
                  "FIXED",
                  "HUG",
                  "FILL"
                ]
              },
              "layoutSizingVertical": {
                "type": "string",
                "enum": [
                  "FIXED",
                  "HUG",
                  "FILL"
                ]
              }
            }
          },
          "properties": {
            "description": "Arbitrary key-value properties to set directly on the node",
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "nodeId"
        ]
      }
    },
    "depth": {
      "description": "Response detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.",
      "type": "number"
    }
  },
  "required": [
    "items"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results("ok" | success | error)[]Per-item results.
matchedFillStylestringMatched fill paint style name
matchedStrokeStylestringMatched stroke paint style name
matchedEffectStylestringMatched effect style name
errorstringError message for this item
warningsstring[]Deduplicated warnings hoisted from individual results
示例返回
{
  "results": [
    "ok",
    {
      "matchedFillStyle": "Primary/Blue"
    }
  ],
  "warnings": [
    "Hardcoded color #ff0000 has no matching paint style or color variable."
  ]
}
返回值 JSON Schema
{
  "type": "object",
  "description": "Per-item is 'ok' (no style matches) or object with matched style names.",
  "properties": {
    "results": {
      "type": "array",
      "description": "Per-item results.",
      "items": {
        "oneOf": [
          {
            "type": "string",
            "const": "ok"
          },
          {
            "title": "success",
            "type": "object",
            "properties": {
              "matchedFillStyle": {
                "type": "string",
                "description": "Matched fill paint style name"
              },
              "matchedStrokeStyle": {
                "type": "string",
                "description": "Matched stroke paint style name"
              },
              "matchedEffectStyle": {
                "type": "string",
                "description": "Matched effect style name"
              }
            }
          },
          {
            "title": "error",
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Error message for this item"
              }
            },
            "required": [
              "error"
            ]
          }
        ]
      }
    },
    "warnings": {
      "type": "array",
      "description": "Deduplicated warnings hoisted from individual results",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "results"
  ]
}
edit

Delete nodes. Batch: pass multiple items.

ParameterTypeRequiredDescription
itemsobject[]Array of {nodeId}
nodeIdstringNode ID to delete
JSON Schema
{
  "type": "object",
  "properties": {
    "items": {
      "description": "Array of {nodeId}",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "nodeId": {
            "type": "string",
            "description": "Node ID to delete"
          }
        },
        "required": [
          "nodeId"
        ]
      }
    }
  },
  "required": [
    "items"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results("ok" | error)[]Per-item results.
errorstringError message for this item
warningsstring[]Deduplicated warnings hoisted from individual results
示例返回
{
  "results": [
    "ok",
    "ok"
  ]
}
返回值 JSON Schema
{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "description": "Per-item results.",
      "items": {
        "oneOf": [
          {
            "type": "string",
            "const": "ok"
          },
          {
            "title": "error",
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Error message for this item"
              }
            },
            "required": [
              "error"
            ]
          }
        ]
      }
    },
    "warnings": {
      "type": "array",
      "description": "Deduplicated warnings hoisted from individual results",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "results"
  ]
}
create

Clone nodes. Batch: pass multiple items.

ParameterTypeRequiredDescription
itemsobject[]Array of {nodeId, x?, y?}
nodeIdstringNode ID to clone
parentIdstringParent for the clone (e.g. a page ID). Defaults to same parent as original.
xnumberNew X for clone. Omit to keep original position.
ynumberNew Y for clone. Omit to keep original position.
depthnumberResponse detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.
JSON Schema
{
  "type": "object",
  "properties": {
    "items": {
      "description": "Array of {nodeId, x?, y?}",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "nodeId": {
            "type": "string",
            "description": "Node ID to clone"
          },
          "parentId": {
            "description": "Parent for the clone (e.g. a page ID). Defaults to same parent as original.",
            "type": "string"
          },
          "x": {
            "description": "New X for clone. Omit to keep original position.",
            "type": "number"
          },
          "y": {
            "description": "New Y for clone. Omit to keep original position.",
            "type": "number"
          }
        },
        "required": [
          "nodeId"
        ]
      }
    },
    "depth": {
      "description": "Response detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.",
      "type": "number"
    }
  },
  "required": [
    "items"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results(success | error)[]Per-item results.
idstringCloned node ID
errorstringError message for this item
warningsstring[]Deduplicated warnings hoisted from individual results
示例返回
{
  "results": [
    {
      "id": "11:1"
    }
  ]
}
返回值 JSON Schema
{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "description": "Per-item results.",
      "items": {
        "oneOf": [
          {
            "title": "success",
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Cloned node ID"
              }
            }
          },
          {
            "title": "error",
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Error message for this item"
              }
            },
            "required": [
              "error"
            ]
          }
        ]
      }
    },
    "warnings": {
      "type": "array",
      "description": "Deduplicated warnings hoisted from individual results",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "results"
  ]
}
edit

Move nodes into a parent at a specific index (reorder/reparent). Batch: pass multiple items.

ParameterTypeRequiredDescription
itemsobject[]Array of {parentId, childId, index?}
parentIdstringParent node ID
childIdstringChild node ID to move
indexnumberIndex to insert at (0=first). Omit to append.
depthnumberResponse detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.
JSON Schema
{
  "type": "object",
  "properties": {
    "items": {
      "description": "Array of {parentId, childId, index?}",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "parentId": {
            "type": "string",
            "description": "Parent node ID"
          },
          "childId": {
            "type": "string",
            "description": "Child node ID to move"
          },
          "index": {
            "description": "Index to insert at (0=first). Omit to append.",
            "type": "number"
          }
        },
        "required": [
          "parentId",
          "childId"
        ]
      }
    },
    "depth": {
      "description": "Response detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.",
      "type": "number"
    }
  },
  "required": [
    "items"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results("ok" | error)[]Per-item results.
errorstringError message for this item
warningsstring[]Deduplicated warnings hoisted from individual results
示例返回
{
  "results": [
    "ok"
  ]
}
返回值 JSON Schema
{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "description": "Per-item results.",
      "items": {
        "oneOf": [
          {
            "type": "string",
            "const": "ok"
          },
          {
            "title": "error",
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Error message for this item"
              }
            },
            "required": [
              "error"
            ]
          }
        ]
      }
    },
    "warnings": {
      "type": "array",
      "description": "Deduplicated warnings hoisted from individual results",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "results"
  ]
}