text-to-design-mcp 0.13.9 → 0.13.10
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 +1 -1
- package/dist/index.js +19 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -235,7 +235,7 @@ Figma 用户不会再读到 jsDesign 的兜底细节;平台未探测时给「先
|
|
|
235
235
|
| `TEXT_TO_DESIGN_MCP_LOG` | `/tmp/text-to-design-mcp.log` | 日志文件路径(JSONL,与遥测上报同一形状) |
|
|
236
236
|
| `TEXT_TO_DESIGN_MCP_LOG_LEVEL` | `info` | 落盘级别:`debug`/`info`/`warn`/`error`/`fatal`;只约束日志文件,面板推送全量下发 |
|
|
237
237
|
| `TEXT_TO_DESIGN_TELEMETRY_URL` | 构建期注入 | 错误上报端点;**构建期**从**仓库根** `.env.local` 读取(见 `vite.config.ts`),运行时 env 可覆盖 |
|
|
238
|
-
| `
|
|
238
|
+
| `TELEMETRY_API_KEY` | 构建期注入 | 上报密钥,与服务端同一个变量名 —— 一份 `.env.local` 两端共用,不存在错位 |
|
|
239
239
|
|
|
240
240
|
本地开发:根 `.env.local`(模板根 `.env.local.example`)填好后 `pnpm build` —— URL/KEY 被烤进 `dist`。优先序:**真实环境变量(CI secret)> `.env.local`**;两者都没有 = 上报整体关闭(不再用 `dev-insecure-key` 去撞生产)。
|
|
241
241
|
|
package/dist/index.js
CHANGED
|
@@ -12,18 +12,18 @@ import{createRequire as e}from"node:module";import{core as t,z as n}from"zod";im
|
|
|
12
12
|
|
|
13
13
|
2. Then call jsd_ping — that wakes the background daemon (starting it if needed).
|
|
14
14
|
If it reports "plugin not connected", tell me to run the text-to-design plugin inside my design app.`,"panel.expand":`Expand`,"panel.collapse":`Collapse`,"panel.close":`Close`,"selection.title":`Selected nodes`,"selection.badge":`{count} nodes · {size} serialized`,"selection.copy":`Copy`,"selection.empty.title":`No nodes selected`,"selection.empty.hint":`Select nodes on the canvas and they show up here, ready to copy`,"capability.card.title":`Capabilities`,"capability.card.missing":`Capabilities unavailable (plugin not connected)`,"capability.card.badgeTitle":`Core capability count · platform-specific capabilities available · platform op count`,"capability.card.badge":`core {core} · platform {host}/{total} · op {ops}`,"capability.card.coreSection":`Core capabilities`,"capability.card.hostSection":`Platform differences`,"capability.card.opTitle":`{op}: supported on the current platform`,"capability.card.opTitleOff":`{op}: not supported on the current platform`,"capability.card.opsSection":`Platform-specific ops`,"capability.card.refresh":`Refresh`,"capability.card.noOps":`No platform-specific ops on this platform`,"log.trigger":`Log`,"log.trigger.title":`Log: MCP calls and connection events`,"log.trigger.unread":`Log, {count} new errors`,"log.trigger.unit":`errors`,"log.trigger.announce":`{count} new errors`,"log.drawer.title":`Log`,"log.drawer.count":`{shown} / {total}`,"log.drawer.clear":`Clear`,"log.drawer.close":`Close log`,"log.drawer.filter.all":`All`,"log.drawer.filter.info":`Info+`,"log.drawer.filter.warn":`Warn+`,"log.drawer.filter.error":`Error`,"log.drawer.empty":`No log yet. MCP calls and connection events are recorded here.`,"log.drawer.emptyFiltered":`Nothing at level "{filter}" — switch to "All" for the full record.`,"log.drawer.copy":`Copy`,"log.drawer.newCount":`↓ {count} new entries`,"bridge.log.superseded":`Another plugin panel took over the channel; auto-reconnect stopped (click "Reclaim" in the panel header to switch back)`,"bridge.log.confirmed":`Service confirmed the connection (version {version})`,"bridge.log.versionPush":`Latest npm versions received: plugin {ui}, service {mcp}`,"bridge.log.versionUnknown":`unknown`,"bridge.log.handshakeTimeout":`WS handshake timed out ({ms}ms), giving up on this connection: {port}`,"bridge.log.serverConnected":`MCP server connected, waiting for service confirmation: ws://localhost:{port}`,"bridge.log.confirmTimeout":`Service confirmation timed out, closing: {port}`,"bridge.log.closed":`Connection closed: {port}`,"bridge.log.stale":`Service confirmation expired (no heartbeat for {ms}ms), closing: {port}`,"bridge.log.wsFailed":`Failed to handle WS message: {message}`,"bridge.log.recvRequest":`Server request received: {method}`,"bridge.log.recvResponse":`Server response received (ignored): {id}`,"bridge.log.forwardTimeout":`Forwarding to plugin timed out: {method}`,"bridge.log.pluginTimeout":`Plugin response timed out`,"bridge.log.ignoreUnknown":`Ignoring unknown plugin message: {type}`,"bridge.log.codeFailed":`Failed to handle code message: {message}`,"bridge.log.sendFailed":`Failed to send response (server not connected): {id}`,"bridge.log.manualClose":`Disconnected manually`,"bridge.log.capabilityMissing":`Capability reply malformed (missing platform)`,"bridge.log.capabilityFailed":`Failed to fetch capabilities: {message}`,"bridge.log.pingOk":`Plugin ping succeeded: {data}`,"bridge.log.pingFailed":`Plugin ping failed: {message}`,"bridge.error.useBridge":`useBridge must be used inside <BridgeProvider>`,"schemaValue.color":`Color: hex (e.g. "#ff0000"; 8-digit hex becomes paint opacity) or {r,g,b} (0-1 channels, >1 = 0-255)`,"schemaValue.rgba":`Color: hex (e.g. "#ff000080") or {r,g,b,a} (0-1 channels, >1 = 0-255; default 1)`,"schemaValue.gradientStops":`Gradient stops, at least 2`,"schemaValue.constraint":`MIN = pin start | MAX = pin end | STRETCH = stretch | CENTER = center | SCALE = scale`,"schemaValue.strokeJoin":`Join style: MITER / BEVEL / ROUND`,"schemaValue.strokeCap":`Cap style; ARROW_* is Figma only`,"schemaValue.textDecoration":`Decoration line (default NONE)`,"schemaValue.textCase":`Case transform (default ORIGINAL)`,"schemaValue.scaleMode":`Scale mode: FILL / FIT / CROP / TILE`,"schemaValue.arcData":`Arc parameters, draws a ring`,"schema.base.r":`Red channel, 0-1 (0=none, 1=full), e.g. 1 for pure red; values >1 are treated as 0-255 and auto-normalized`,"schema.base.g":`Green channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.b":`Blue channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1; >1 treated as 0-255 and auto-normalized`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`2×3 affine; [[1,0,0],[0,1,0]] = identity`,"schema.base.type":`Fill type: solid`,"schema.base.opacity":`Opacity 0-1, default 1`,"schema.base.visible":`Whether visible, default true`,"schema.base.blendMode":`Blend mode, default NORMAL`,"schema.base.blendMode2":`Solid fill (SOLID): {color:{r,g,b}}`,"schema.base.type2":`Fill type: linear gradient`,"schema.base.gradientStops":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform":`Linear gradient (GRADIENT_LINEAR): transitions along a straight line`,"schema.base.type3":`Fill type: radial gradient`,"schema.base.gradientStops2":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform2":`Radial gradient (GRADIENT_RADIAL): radiating outwards from the centre`,"schema.base.type4":`Fill type: angular gradient`,"schema.base.gradientStops3":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform3":`Angular gradient (GRADIENT_ANGULAR): transitions around the circumference`,"schema.base.type5":`Fill type: image fill`,"schema.base.imageHash":`Image asset hash (injected by jsd_fill_image etc.)`,"schema.base.scaleMode":`Image scale mode: FIT | FILL | CROP | TILE`,"schema.base.scaleMode2":`Image fill (IMAGE): references the image by imageHash`,"schema.base.type6":`Effect type: drop shadow (cast outside the node)`,"schema.base.color2":`Shadow color (with alpha)`,"schema.base.x":`Horizontal offset (px), positive = right`,"schema.base.y":`Vertical offset (px), positive = down`,"schema.base.y2":`Shadow offset vector (px)`,"schema.base.radius":`Blur radius (px), >=0`,"schema.base.spread":`Spread (px), positive expands and negative shrinks the shadow, default 0`,"schema.base.visible2":`Whether visible, default true`,"schema.base.blendMode3":`Blend mode, default NORMAL`,"schema.base.showShadowBehindNode":`Whether the shadow is drawn behind the node (otherwise under its content), default true`,"schema.base.showShadowBehindNode2":`Drop shadow (DROP_SHADOW): a shadow cast outside the node`,"schema.base.type7":`Effect type: inner shadow (cast inside the node)`,"schema.base.color3":`Shadow color (with alpha)`,"schema.base.x2":`Horizontal offset (px), positive = right`,"schema.base.y3":`Vertical offset (px), positive = down`,"schema.base.y4":`Shadow offset vector (px)`,"schema.base.radius2":`Blur radius (px), >=0`,"schema.base.spread2":`Spread (px), positive expands and negative shrinks, default 0`,"schema.base.visible3":`Whether visible, default true`,"schema.base.blendMode4":`Blend mode, default NORMAL`,"schema.base.blendMode5":`Inner shadow (INNER_SHADOW): a shadow cast inside the node`,"schema.base.type8":`Effect type: layer blur (blurs the whole node itself)`,"schema.base.radius3":`Blur radius (px), >=0`,"schema.base.visible4":`Whether visible, default true`,"schema.base.visible5":`Layer blur (LAYER_BLUR): blurs the node itself`,"schema.base.type9":`Effect type: background blur (blurs what is behind the node)`,"schema.base.radius4":`Blur radius (px), >=0`,"schema.base.visible6":`Whether visible, default true`,"schema.base.visible7":`Background blur (BACKGROUND_BLUR): blurs the content behind the node`,"schema.base.pattern":`Grid type: ROWS | COLUMNS | GRID`,"schema.base.alignment":`Alignment: MIN | MAX | CENTER | STRETCH`,"schema.base.sectionSize":`Section size (px)`,"schema.base.gutterSize":`Gutter size (px)`,"schema.base.offset":`Offset (px)`,"schema.base.windingRule":`Winding rule: NONZERO | EVENODD | NONE, default NONZERO`,"schema.base.value":`Line height value (px)`,"schema.base.unit":`Unit: PIXELS = fixed pixels`,"schema.base.value2":`Line height value (percentage)`,"schema.base.unit2":`Unit: PERCENT = percentage`,"schema.base.unit3":`Unit: AUTO = automatic line height`,"schema.base.unit4":`Automatic line height: {unit: "AUTO"}, no value needed`,"schema.base.unit5":`Unit: PIXELS = pixels | PERCENT = percentage`,"schema.batch.calls":`Step list, executed in array order (mutually exclusive with callsFile)`,"schema.batch.callsFile":`Absolute path to a JSON file holding the step list (mutually exclusive with calls). Use it when the arguments are too large to fit in the context — the file holds {"calls":[…]}, or a bare array (equivalent), with the same shape as calls, and may also carry stopOnError / checkDrift. The file content is read and used as call arguments`,"schema.batch.ok":`True when every step ran and succeeded (executed < total means it stopped halfway)`,"schema.batch.executed":`Number of steps that actually produced a result`,"schema.batch.total":`Total number of planned steps`,"schema.batch.error":`Failure reason (human-readable text)`,"schema.batch.error2":`Id of the step that failed`,"schema.executeOp.depth":`Serialization depth`,"schema.executeSchemas.isMask":`Use as a mask (geometry unchanged)`,"schema.executeSchemas.childrenOf":`Child nodes, max 100 direct children; x/y are relative to the parent and default to (0,0). For bigger structures build in batches then regroup with jsd_reparent_nodes`,"schema.executeSchemas.fills":`Fills. FRAME defaults to white; other shapes with strokes drop the fill — pass fills for a background`,"schema.executeSchemas.layoutMode":`Auto-layout direction; set HORIZONTAL or VERTICAL before itemSpacing/padding*/primaryAxis*`,"schema.executeSchemas.itemSpacing":`Item spacing (px); needs layoutMode; ignored when primaryAxisAlignItems is SPACE_BETWEEN`,"schema.executeSchemas.primaryAxisAlignItems":`Main axis alignment; SPACE_BETWEEN ignores itemSpacing`,"schema.executeSchemas.frameNote":`FRAME = container (auto-layout capable). Without fills the engine paints white — pass fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}] for transparent`,"schema.executeSchemas.vectorNote":`VECTOR = vector (with vectorPaths as SVG path data). ⚠ vectorPaths is sometimes lost/distorted after creation; use LINE+rotation for short segments`,"schema.executeSchemas.characters":`Text content. Some emoji miss glyphs in the client font (render as ☒) — eyeball each one before shipping`,"schema.executeSchemas.fontName":`Font {family,style}, exact match; check jsd_list_fonts first (falls back silently)`,"schema.executeSchemas.textAutoResize":`Text auto resize: default WIDTH_AND_HEIGHT grows with content (width/height ignored) | HEIGHT = fixed width, auto height | NONE = fixed box | TRUNCATE`,"schema.executeSchemas.type":`Child node type`,"schema.executeSchemas.x":`X relative to the parent (px)`,"schema.executeSchemas.y":`Y relative to the parent (px)`,"schema.executeSchemas.x2":`X (px, relative to parent; roots follow placement)`,"schema.executeSchemas.y2":`Y (px, relative to parent; roots follow placement)`,"schema.executeSchemas.width":`Width (px)`,"schema.executeSchemas.height":`Height (px)`,"schema.executeSchemas.rotation":`Rotation angle (deg)`,"schema.executeSchemas.opacity":`Opacity 0-1`,"schema.executeSchemas.strokes":`Stroke list, replaced as a whole`,"schema.executeSchemas.strokeWeight":`Stroke weight (px); per-side fields win`,"schema.executeSchemas.strokeTopWeight":`Top border width (px); overrides strokeWeight`,"schema.executeSchemas.strokeBottomWeight":`Bottom border width (px); same as above`,"schema.executeSchemas.strokeLeftWeight":`Left border width (px); same as above`,"schema.executeSchemas.strokeRightWeight":`Right border width (px); same as above`,"schema.executeSchemas.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.executeSchemas.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.executeSchemas.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.executeSchemas.dashPattern":`Dash: segment lengths, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow / blur)`,"schema.executeSchemas.vertical":`Constraints when the parent resizes`,"schema.executeSchemas.clipsContent":`Whether overflowing content is clipped`,"schema.executeSchemas.cornerSmoothing":`Corner smoothing 0-1`,"schema.executeSchemas.layoutGrids":`Layout grids (guides)`,"schema.executeSchemas.cornerRadius":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.executeSchemas.paddingTop":`Top padding (px)`,"schema.executeSchemas.paddingRight":`Right padding (px)`,"schema.executeSchemas.paddingBottom":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems":`Cross axis alignment`,"schema.executeSchemas.layoutGrow":`Grow factor on the parent main axis (0 = no growth)`,"schema.executeSchemas.layoutAlign":`Self alignment on the parent cross axis`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.startingAngle":`Starting angle (rad)`,"schema.executeSchemas.endingAngle":`Ending angle (radians)`,"schema.executeSchemas.innerRadius":`Inner radius (0-1 ratio)`,"schema.executeSchemas.innerRadius2":`Arc path parameters, draws a ring`,"schema.executeSchemas.ellipseNote":`ELLIPSE = ellipse (use arcData to draw a ring)`,"schema.executeSchemas.type3":`LINE = line`,"schema.executeSchemas.pointCount":`Polygon corner count, e.g. 6 = hexagon`,"schema.executeSchemas.bottomRightRadius3":`POLYGON = polygon (use pointCount)`,"schema.executeSchemas.pointCount2":`Star point count, e.g. 5 = five-pointed star`,"schema.executeSchemas.innerRadius4":`Inner radius (0-1 ratio)`,"schema.executeSchemas.cornerRadius4":`Corner radius (px)`,"schema.executeSchemas.bottomRightRadius5":`STAR = star (with pointCount / innerRadius)`,"schema.executeSchemas.vectorPaths":`Vector path data`,"schema.executeSchemas.fontSize":`Font size (px), default 16`,"schema.executeSchemas.textAlignHorizontal":`Horizontal alignment (default LEFT)`,"schema.executeSchemas.textAlignVertical":`Vertical alignment (default TOP)`,"schema.executeSchemas.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.executeSchemas.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`Line height: {value, unit}`,"schema.executeSchemas.letterSpacing":`Letter spacing: {value, unit}`,"schema.executeSchemas.letterSpacing2":`TEXT = text (with characters / fontSize / fontName)`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.path":`GROUP = group (implemented as a frame internally)`,"schema.executeSchemas.children2":`Child nodes to merge (at least 2)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION = boolean operation (merges child nodes)`,"schema.execute.name":`Name of the generated layer, default svg-design`,"schema.execute.html":`HTML fragment, inline styles supported`,"schema.execute.name2":`Name of the generated layer, default html-design`,"schema.execute.size":`Icon edge length in px, default 24`,"schema.execute.color":`Stroke color (hex), default #000000`,"schema.execute.strokeWidth":`Stroke width, default 2`,"schema.execute.name3":`Name of the generated layer, default icon-<icon name>`,"schema.inputs.ids":`Find by node id, highest priority`,"schema.inputs.name":`Fuzzy match by name (contains)`,"schema.inputs.recursive":`Whether to search recursively (default true)`,"schema.inputs.depth":`Serialization depth: 0 = self only, 1 = with direct children; default 1`,"schema.inputs.name2":`Group only: group name`,"schema.inputs.paddingTop":`Group only. Top padding (px)`,"schema.inputs.paddingRight":`Group only. Right padding (px)`,"schema.inputs.paddingBottom":`Group only. Bottom padding (px)`,"schema.inputs.paddingLeft":`Group only. Left padding (px)`,"schema.inputs.primaryAxisSizingMode":`Group only. Main axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisSizingMode":`Group only. Cross axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisAlignItems":`Group only. Cross axis alignment: MIN | MAX | CENTER`,"schema.inputs.key":`Team library component key (required only for import_component)`,"schema.inputs.componentId":`Target component (COMPONENT) node id`,"schema.inputs.format":`Export format, default PNG`,"schema.inputs.scale":`Scale factor (PNG/JPG), default 1`,"schema.inputs.savePath":`Absolute path to write, e.g. /tmp/icon.png`,"schema.inputs.includeDataUrl":`Whether to also return the base64 dataURL, default false`,"schema.inputs.ids2":`Node ids to fill with the image`,"schema.inputs.sourcePath":`Absolute path of the local image, e.g. /tmp/poster.png`,"schema.inputs.params":`Operation parameters; the shape depends on the op`,"schema.inputs.family":`Filter by family name (case-insensitive substring), e.g. "Source"`,"schema.inputs.offset":`Paging start index (families to skip), default 0`,"schema.inputs.limit":`Max families per page, default 50, max 500; a font library can hold ~1900 families and dumping all of them blows up the context`,"schema.platform.name":`op name, pass it verbatim when calling jsd_platform_op`,"schema.platform.description":`Includes the params shape`,"schema.results.capabilities":`Platform-difference capabilities`,"schema.results.families":`Available font families`,"schema.results.family":`Font family`,"schema.results.styles":`Styles available in this family, e.g. ["Regular","Medium","Bold"]`,"schema.results.count":`Number of font families in this page`,"schema.results.total":`Total families after filtering (independent of paging)`,"schema.results.offset":`Start index of this page`,"schema.results.truncated":`true means more pages exist; continue with offset`,"schema.sharedProps.width":`Width (px)`,"schema.sharedProps.height":`Height (px)`,"schema.sharedProps.rotation":`Rotation angle (deg, around the node top-left origin; x/y unchanged)`,"schema.sharedProps.opacity":`Opacity 0-1`,"schema.sharedProps.pointCount":`Polygon/star corner count (POLYGON / STAR only)`,"schema.sharedProps.innerRadius":`Inner radius (0-1 ratio)`,"schema.sharedProps.strokes":`Stroke list (Paint array)`,"schema.sharedProps.strokeWeight":`Stroke weight (px); per-side fields win`,"schema.sharedProps.strokeTopWeight":`Top border width (px); overrides strokeWeight`,"schema.sharedProps.strokeBottomWeight":`Bottom border width (px); same as above`,"schema.sharedProps.strokeLeftWeight":`Left border width (px); same as above`,"schema.sharedProps.strokeRightWeight":`Right border width (px); same as above`,"schema.sharedProps.strokeAlign":`Stroke alignment (default INSIDE)`,"schema.sharedProps.strokeCap":`Stroke cap; ARROW_* is Figma only`,"schema.sharedProps.strokeJoin":`Stroke join style`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.cornerRadius":`Corner radius (px). LINE/TEXT have no corners; per-corner fields override it`,"schema.sharedProps.topLeftRadius":`schema.sharedProps.cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px)`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment (default LEFT)`,"schema.sharedProps.textAlignVertical":`Vertical alignment (default TOP)`,"schema.sharedProps.textCase":`Case transform (default ORIGINAL)`,"schema.sharedProps.textDecoration":`Decoration line (default NONE)`,"schema.sharedProps.lineHeight":`Line height: {unit:"AUTO"} or {value,unit:PIXELS|PERCENT}`,"schema.sharedProps.letterSpacing":`Letter spacing; unit is PIXELS|PERCENT`,"schema.sharedProps.textStyleId":`Local text style id`,"schema.sharedProps.textTruncation":`Text truncation: DISABLED | ENDING (Figma only)`,"schema.sharedProps.maxLines":`Maximum number of lines, Figma only`,"schema.sharedProps.paddingTop":`Top padding (px)`,"schema.sharedProps.paddingRight":`Right padding (px)`,"schema.sharedProps.paddingBottom":`Bottom padding (px)`,"schema.sharedProps.paddingLeft":`Left padding (px)`,"schema.sharedProps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisAlignItems":`Cross axis alignment`,"schema.sharedProps.layoutGrow":`Grow factor on the parent main axis (0 = no growth)`,"schema.sharedProps.layoutAlign":`Self alignment on the parent cross axis`,"schema.sharedProps.fillStyleId":`Local fill style id`,"schema.sharedProps.effectStyleId":`Local effect style id`,"schema.sharedProps.effects":`Effect list (shadow/blur, stackable)`,"schema.sharedProps.vertical":`Constraint inside auto-layout`,"schema.sharedProps.clipsContent":`Whether overflowing content is clipped`,"schema.sharedProps.cornerSmoothing":`Corner smoothing 0-1`,"schema.sharedProps.layoutGrids":`Layout grids (guides)`,"schema.sharedProps.startingAngle":`Starting angle (radians)`,"schema.sharedProps.endingAngle":`Ending angle (radians)`,"schema.sharedProps.innerRadius2":`Inner radius (0-1 ratio)`,"schema.sharedProps.innerRadius3":`Arc path parameters, ELLIPSE nodes only`,"schema.splitOps.ids":`Target node id list; defaults to the current selection`,"schema.splitOps.matchName":`Filter precisely by name`,"schema.splitOps.ids2":`Node ids to delete; defaults to the current selection`,"schema.splitOps.matchName2":`Delete only nodes whose name matches exactly`,"schema.splitOps.name":`Group name`,"schema.splitOps.paddingTop":`Top padding (px)`,"schema.splitOps.paddingRight":`Right padding (px)`,"schema.splitOps.paddingBottom":`Bottom padding (px)`,"schema.splitOps.paddingLeft":`Left padding (px)`,"schema.splitOps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.splitOps.ids3":`Ids of broken nodes to clean up; defaults to all broken nodes on the current page`,"schema.splitOps.name2":`Component name`,"schema.splitOps.key":`Team library component key`,"schema.splitOps.name3":`Name of the imported node`,"schema.splitOps.componentId":`Target component (COMPONENT) node id`,"schema.splitOps.name4":`Variant set name`,"schema.splitOps.sourceId":`Source instance id, i.e. the snapshotId returned by an earlier copy_overrides`,"schema.splitOps.name5":`New node name`,"batch.title":`Batch orchestration`,"batch.followUp":`Review the canvas result after the orchestrated run`,"createComponent.title":`Create component`,"createComponent.description":`Create a COMPONENT and return the new id. Pass children to build it with content in one call (same fields as jsd_create_frame children), optionally with width/height; without children you get an empty shell to fill via jsd_reparent_nodes. The source nodes are never converted or modified — a component is always created fresh. Name variants as "prop=value, prop=value"; set variant properties with jsd_set_instance_properties`,"createComponent.description2":`Resize the component / add fill, corner radius, shadow`,"createInstance.title":`Create component instance`,"createInstance.description":`Set the variant properties of the instance`,"detachInstance.title":`Detach instance`,"detachInstance.description":`Edit the detached node freely`,"importComponent.title":`Import component from team library`,"importComponent.description":`Create an instance of the imported component`,"swapComponent.title":`Swap component`,"swapComponent.description":`Set variant properties after the swap`,"setInstanceProperties.title":`Set variant properties`,"setInstanceProperties.description":`Sync overrides across other instances`,"combineAsVariants.title":`Combine as variant set`,"copyOverrides.title":`Copy instance overrides snapshot`,"copyOverrides.description":`Apply the snapshot to target instances`,"applyOverrides.title":`Apply instance overrides snapshot`,"applyOverrides.description":`Keep syncing other instances`,"syncOverrides.title":`Sync instance overrides`,"syncOverrides.description":`Review the synced instances`,"createFrame.title":`Create frame container`,"createFrame.description":`Create a single FRAME node; input holds only FRAME fields: width/height size, layoutMode auto-layout (itemSpacing/padding*/main and cross axis sizing and alignment) plus visual fields such as fills and strokes. Only one root FRAME is created; use children only for small structures (a container plus its direct children, child x/y relative to the parent) — never pass a whole screen tree in one children call. Build layer by layer with jsd_batch, then reparent each layer into its parent with jsd_reparent_nodes. Set layoutMode=HORIZONTAL or VERTICAL before auto-layout fields (otherwise they are ignored). **Siblings that sit evenly spaced on one axis must be built with auto-layout, never hand-computed coordinates** (tab bars, pill groups, KPI rows, card headers, list rows, whole-screen vertical sections; criterion and both landing paths in skill://canvas/references/auto-layout.md). **Get the sizing mode right**: on a layout container give only the width and let the other axis hug via AUTO — especially for content-sized containers such as dialogs and cards; only a screen root takes FIXED on both axes (a hardcoded height leaves dead space, or clips content when too small). Without explicit fills the engine defaults to a white background; pass fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}] for a transparent container. Always pass a semantic name (e.g. "Sidebar", "KPI-OEE"); unnamed nodes fall back to the engine default name node. Use jsd_batch to create multiple roots or complex trees`,"layoutHint.uniform":`Detected {count} children evenly spaced along {mode} (gap {gap}px) but the container declares no layoutMode. That is exactly the auto-layout criterion: set layoutMode:{mode} + itemSpacing:{gap} and the layout owns their positions — no coordinate recompute when copy or item count changes (advisory only, the create already succeeded; criterion and both landing paths in skill://canvas/references/auto-layout.md)`,"structureHint.flatBatch":`This batch moves {batchCount} nodes into the same parent ({parentId}) — the shape of "every section flattened onto one layer". Structural layering is universal: screen -> semantic sections (status bar / header / hero / list / promo / bottom nav) -> card-level primitives; every element belongs to a semantic container, never straight onto the screen root. Recipe: skill://canvas/references/design-strategy.md (advisory only, the moves already succeeded)`,"structureHint.svgNoGroups":`The SVG source carries no semantic <g id="..."> layers (counted {groupCount}) — after import the whole graphic lands as one un-splittable vector, so restyling a single layer means recomputing and re-importing. Cut one <g> per semantic layer with an ASCII semantic id (plot / grid / axis-x / series-<name> / legend); put a single transform on the outer plot group. Recipe: skill://canvas/references/chart-by-code.md section 5 (advisory only, the import already succeeded)`,"createRectangle.title":`Create rectangle`,"createRectangle.description":`Create a single RECTANGLE node; input holds only rectangle fields: width/height, cornerRadius per corner and visual fields such as fills and strokes. Only one root rectangle; use children only for small structures (child x/y relative to the parent). Always pass a semantic name (e.g. "Card base", "Chart gridlines"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createText.title":`Create text`,"createText.description":`Create a single TEXT node; input holds only text fields: characters (required), fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing and fills/strokes. Only one root text node. Resolve fonts with jsd_list_fonts first: use fonts[].family verbatim and the full name from the same entry's styles (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings will name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content). Always pass a semantic name (e.g. "Chart title", "KPI value"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createEllipse.title":`Create ellipse`,"createEllipse.description":`Create a single ELLIPSE node: width/height, arcData ring parameters (draws a ring) and visual fields such as fills and strokes. Only one root ellipse. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createLine.title":`Create line`,"createLine.description":`Create a single LINE node: width/height and stroke fields. For short straight segments LINE + rotation is more stable. One axis may be 0: the engine resize check demands >= 0.01 so the plugin lifts the zero axis to 0.01 (visually a straight line, serialization still reads 0); jsd_resize_node accepts a zero axis too. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createPolygon.title":`Create polygon`,"createPolygon.description":`Create a single POLYGON node: pointCount is required (e.g. 6 = hexagon), plus cornerRadius and visual fields. Only one root polygon. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createStar.title":`Create star`,"createStar.description":`Create a single STAR node: pointCount corner count, innerRadius ratio and visual fields such as fills and strokes. Only one root star. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createVector.title":`Create vector`,"createVector.description":`Create a single VECTOR node: vectorPaths/vectorNetwork geometry with fills and strokes. Prefer jsd_create_icon or SVG import for icon-like shapes. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createGroup.title":`Create group`,"createGroup.description":`Create a single GROUP node wrapping the given children: group first, then lay out. Only one root group. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createBooleanOperation.title":`Create boolean operation node`,"createSvg.title":`Import SVG`,"createSvg.description":"Import an SVG into the canvas as editable layers (native createNodeFromSvg parsing; paths/gradients/strokes preserved). Pick one source: svg (inline string) or svgPath (path to a local .svg file, read by the background service). **Charts and data visualisations must use svgPath** (line, bar, pie/donut, scatter, radar, area, gauge, dashboard, Sankey, …): there is no built-in chart tool — write a script that computes the SVG, write it to a local file, then pass the path. Engine hard constraints (violations fail silently): the root element needs xmlns plus explicit width/height/viewBox; colours as hex only; no external images/fonts/scripts; approximate curves with C/Q, never the A command; canvas ≤2000×2000; split semantic layers into `<g id>` (one wrapper group is no grouping), with a single transform on the outer group only. Before you start, ReadMcpResource the recipe skill://canvas/references/chart-by-code.md — it carries the zero-dependency example, the colour and type-scale conventions, and the post-import layer check plus visual acceptance checklist. Use jsd_batch to orchestrate multiple root nodes or complex trees","createIcon.title":`Insert built-in icon`,"htmlToDesign.title":`HTML to design nodes`,"htmlToDesign.description":`Convert an HTML fragment into canvas nodes. Default path is jsd_html_to_design (SVG fidelity, complex styles dropped); only use per-type create tools (jsd_create_frame etc.) when editable layers are required`,"manageNodes.title":`Node structure operations (aggregate)`,"manageNodes.followUp":`Set the container auto-layout after the structure change`,"manageComponents.title":`Component and instance operations (aggregate)`,"manageComponents.description":`Aggregate entrypoint dispatching by op: create_component / create_instance / detach_instance / import_component / combine_as_variants / swap_component / set_instance_properties / copy_overrides / apply_overrides / sync_overrides. Prefer the dedicated small tools for a single op`,"manageComponents.description2":`Set variant properties after the component/instance change`,"find.title":`Find nodes`,"find.description":`Set the matched nodes as the current selection for later edits/deletes`,"selectNodes.title":`Set canvas selection`,"selectNodes.description":`Move or resize the selected nodes`,"deleteNode.title":`Delete node`,"deleteNode.description":`Review the remaining nodes after deletion`,"cloneNode.title":`Clone node`,"cloneNode.description":`Move the copy to the target position`,"groupNodes.title":`Group nodes`,"groupNodes.description":`Set the auto-layout of the new group`,"ungroupNodes.title":`Ungroup nodes`,"ungroupNodes.description":`Adjust child positions after ungrouping`,"flattenNodes.title":`Flatten into vector`,"flattenNodes.description":`Set the fill of the flattened shape`,"outlineStroke.title":`Outline stroke`,"outlineStroke.description":`Adjust the stroke of the new outline`,"reparentNodes.title":`Move nodes under a parent`,"reparentNodes.description":`Fine-tune x/y under the new parent if needed (absolute position is preserved automatically)`,"repairNodes.title":`Repair broken nodes`,"repairNodes.description":`Review the page node state after repairing`,"platformOp.title":`Platform-specific operation`,"platformOp.description":`Run a platform-specific op (Figma: variables / local styles / component properties; MasterGo: variable read-write / component properties / set-level variant management). CRITICAL: never guess op names or parameters — read the platformOps list (each entry carries its parameter shape) and capabilities from jsd_ping first, then call by the listed names; an unsupported platform or a wrong op name returns an error listing the ops the current platform supports`,"platformOp.description2":`Review the effect of the platform op on the canvas`,"prompt.htmlToDesign.title":`HTML to design`,"prompt.htmlToDesign.description":`Convert an HTML fragment into canvas nodes, with fidelity trade-offs`,"prompt.iconGrid.title":`Icon grid`,"prompt.iconGrid.description":`Insert Lucide icons in bulk and lay them out in an auto-layout grid`,"prompt.scriptOps.title":`Scripted batch calls`,"prompt.chartByCode.title":`Charts / data visualization by code`,"prompt.chartByCode.description":`The primary path for charts and data visualization — line, bar, pie / donut, scatter, radar, area, gauge, dashboard or any other chart: write your own code to compute the geometry, save the SVG to a file, then import it via jsd_create_svg (dependency-free example plus engine-side hard constraints)`,"prompt.designStrategy.title":`Design strategy overview`,"prompt.autoLayout.title":`Auto layout`,"prompt.autoLayout.description":`Whether a container should use auto layout (criteria plus easily-missed sections), self-judged direction (child flow axis, do not hardcode HORIZONTAL/VERTICAL), the two adoption paths, platform hard constraints and verification pitfalls`,"prompt.textReplace.title":`Bulk text replacement strategy`,"prompt.variantSync.title":`Bulk sync styles across sibling instances`,"prompt.variableBinding.title":`Bind variables and apply in bulk`,"prompt.variantSet.title":`Build a variant set`,"prompt.componentProperty.title":`Define and set component properties`,"setFillColor.title":`Set fill`,"setFillColor.followUp":`Next set the stroke`,"setStroke.title":`Set stroke`,"setStroke.description":`Next set the fill`,"setCornerRadius.title":`Set corner radius`,"setCornerRadius.description":`Next set shadow/blur effects`,"setText.title":`Modify text`,"setText.followUp":`Give the text a semantic name`,"moveNode.title":`Move node`,"moveNode.description":`Next adjust the size`,"resizeNode.title":`Resize node`,"resizeNode.description":`Next set visibility/lock`,"setLayout.title":`Set auto-layout`,"setLayout.description":`Move child nodes into the container to finish the layout`,"setEffects.title":`Set effects and advanced properties`,"setEffects.description":`Next set visibility/lock`,"setVisibility.title":`Set visibility and lock`,"setVisibility.description":`Review the canvas selection after the change`,"renameNode.title":`Rename node`,"renameNode.description":`Next edit the text content/typography`,"setShape.title":`Set polygon/star shape`,"setShape.description":`Next set the fill`,"export.title":`Export nodes as images`,"export.description":`Export the given nodes to PNG files. Large base64 payloads are dropped from the result and written to disk instead; use jsd_export again with a smaller scale if you need inline data`,"export.description2":`Fill the exported image into a node`,"fillImage.title":`Fill node with a local image`,"fillImage.description":`Read a local image file and fill the given nodes with it (IMAGE fill)`,"fillImage.description2":`Review the image fill result`,"listFonts.title":`List available fonts`,"listFonts.description":`Set text with the listed fonts`,"createStyle.title":`Create a local style`,"createStyle.description":'Creates one local style **from an existing node** and returns its id and name. Eight categories — the union of the three engines’ `StyleType`: PAINT / TEXT / EFFECT / GRID exist on **all three**; STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING are **MasterGo only** — the other two have no factory, so asking for them is rejected before the request, listing the categories that platform does support (never silently built as some other kind). Copying from a layer is the only shape all three platforms share: MasterGo natively does `createFillStyle({name, id: layerId})` and the engine takes the style from that layer; Figma / jsDesign expose no-arg factories, so this tool fills the new style from the node’s fills / effects / layoutGrids / text layout fields. For PAINT, fills win and strokes are the fallback (so a node with neither raises an error instead of silently creating an empty style). Mixed values (e.g. a text node using two fonts) raise an error telling you to unify the font with jsd_set_text first; the four new categories follow the same rule — SPACING / PADDING need an auto-layout container and CORNER_RADIUS needs a real corner, and when the value cannot be read the request is never sent. Bind the result by id: `jsd_set_fill_color` fillStyleId / `jsd_set_stroke` strokeStyleId / `jsd_set_text` textStyleId / `jsd_set_effects` effectStyleId — afterwards editing the style updates everywhere it is used, which is the correct way to keep a palette consistent on platforms without a variable surface. Read the catalog from `jsd://styles` (read-only resource) — ⚠ on platforms that do not declare `styleEnumeration` that catalog is always empty (all three platforms declare it today; Instant Design has listed styles since 2026-10-15, see dec e1e66f0a): it means "cannot be listed", not "none exist", so read an existing style id off a node that uses it (`*StyleId`) and keep the id returned here **on your own ledger**',"createStyle.followUp":`Bind the new style id to nodes`,"deleteStyle.title":`Delete local styles`,"deleteStyle.description":'Deletes local styles by id (pass several ids at once), one at a time: a missing id lands in the result’s failed list with a reason and does not affect the others. Ids come from jsd://styles or assets.styles in jsd_get_page (⚠ on platforms without styleEnumeration both are always empty, so take the id from a node’s *StyleId or from your own ledger) — **by id, not by name**, because same-named styles can coexist and deleting by name means guessing which one was meant. The counterpart of `jsd_create_style` (a feature is only safe to try when it can also be undone); variables are deleted with the platform op `figma_variables_remove` (Figma) / `mg_variables_remove` (MasterGo). ⚠ Nodes still referencing a deleted style keep a dangling `*StyleId` — the engine does not clean them up, so rebind them to another style first; this repo does not expose a "who uses this style" query (Figma has `getStyleConsumersAsync`, unwired)',"deleteStyle.followUp":`Re-read the style list to confirm`,"resources.title":`Current canvas selection`,"resources.title2":`Available font list`,"resources.title3":`Local style list`,"resources.title4":`Current page overview: top-level nodes + reusable asset roster`,"resources.title5":`Node detail`,"resources.title6":`Platform state and capabilities`,"resources.title7":`Recipe index`,"resources.title8":`Recipe body`,"ping.followUp":`Read the current selection once the connection is confirmed. **Creation tasks: read the recipe at step 0** (hosts generally do not inject server instructions, so mcp.instructions is dropped; you must fetch it yourself): ReadMcpResource skill://canvas/SKILL.md for the index — charts/dataviz -> skill://canvas/references/chart-by-code.md, whole-page design -> skill://canvas/references/design-strategy.md + skill://canvas/references/auto-layout.md, bulk rework -> skill://canvas/references/script-ops.md. The cost of skipping is measurable: one full-screen task ran step by step with no recipe, flattened 38 nodes onto one layer, and needed multiple rounds of rework`,"getSelection.title":`Read canvas selection`,"getSelection.description":`Read the current selection of the canvas, serialized with direct children; equivalent to jsd_get_selection depth=2`,"getSelection.description2":`Find nodes precisely inside the selection`,"getPage.title":`Current page overview: top-level nodes + reusable asset roster`,"getPage.description":"Two read-only sections for the **current page**. (1) nodes: geometry of the current page **first-level** nodes (id/name/type/width/height/x/y, not recursive); (2) assets: the reusable roster — summary gives counts for all four faces; components; variants (with dimension -> allowed values); styles (PAINT/TEXT/EFFECT/GRID, each with its type); variables. Every entry carries id and name. Scope: **styles and variables are document-level** (the engine enumeration APIs are document-level by nature); components/variants are platform-dependent — platforms that can read beyond the current page cover the whole document, those that cannot (jsDesign / MasterGo) **cover the current page only**, named in note. **This is step one of any design task: read it first, and reuse any component / variant value / style / variable that matches by name or purpose — never create a duplicate**; only build something new when the roster does not have it. A face whose capability the platform does not declare comes back as an empty array (jsDesign has no variables and cannot list styles); the reason is named in note — **an empty array does not mean the document has none**. `variants[].properties` is omitted entirely when the platform cannot read that field (never an empty object). Drill into assets by id with jsd_find. Also carries pages: each page name and its top-level node count. On dynamic-page platforms the first read loads the whole document and names that cost in note (idempotent — later calls do not reload). On platforms that cannot read beyond the current page (jsDesign / MasterGo) the roster and pages cover the current page only, also named in note — that does not mean the document has one page","getPage.followUp":`Read a specific node serialized by id; pass scope=document to search across pages`,"mcp.instructions":`Before canvas work, read skill://canvas/SKILL.md and relevant references. If skills are unavailable, use jsd_list_prompts/jsd_get_prompt or jsd://recipes. For creation, read jsd_get_page and reuse existing components, variants, styles and variables. Use semantic containers, reusable components for repeated structures and auto-layout for evenly spaced rows/columns. Root coordinates follow placement; use manual for explicit coordinates. Child coordinates are parent-relative unless layout controls them. Serialize canvas requests. Use ids for identical edits and jsd_batch for dependent steps (50 maximum; references are batch-local). recursive affects descendants; includeSelf=true includes containers. Use exact font family/style pairs from jsd_list_fonts. Read warnings, independently read back critical fields and visually inspect exported changes. Writes may have landed after a timeout; verify before retrying. Keep edits within user scope.`,"ping.title":`Check {client} plugin connection`,"batch.description":`Run tool steps sequentially. Supply calls or callsFile (an absolute path readable by the server), at most 50 steps. Each step has id/tool/args; later args may reference paths such as {{step.created[0].id}}, valid only within this batch. Resolve existing assets with {{@comp:Name}} / {{@var:Name}}. Prefer one tool with ids for identical edits; use batch for different values or dependent tools. In compact mode, discover non-public capabilities with jsd_describe_tools before executing them here. Unknown tools are rejected. Execution errors stop by default; stopOnError/continueOnError control continuation, while plan errors still stop. A batch is not a transaction; earlier writes may remain. Read back after timeouts before replaying writes. Echoes trim subtrees and style fields; read spilled details via path/line. Verify fields with separate jsd_find and visual changes with export. checkDrift is enabled by default and reports sibling movement with original coordinates; false disables it for this call. See skill://canvas/references/script-ops.md; the recipe index is jsd://recipes.`,"manageNodes.description":`Aggregate entrypoint for node structure operations dispatched by op: select | remove | clone | group | ungroup | flatten | outline_stroke | reparent | repair. For a single operation prefer the matching small tool: jsd_select_nodes / jsd_delete_node / jsd_clone_node / jsd_group_nodes / jsd_ungroup_nodes / jsd_flatten_nodes / jsd_outline_stroke / jsd_reparent_nodes / jsd_repair_nodes (their descriptions carry platform caveats and the correct flow). Property edits belong to jsd_set_* (incl. jsd_set_shape); component/instance work belongs to jsd_manage_components or jsd_create_component / jsd_sync_overrides — ops are not interchangeable.
|
|
15
|
-
Result keys per op (needed to write correct jsd_batch placeholders; a wrong key aborts the batch): select -> selected[and remove -> removed[are id strings; clone/outline_stroke -> created[is an array of nodes; group/flatten -> created is a single node object; ungroup -> ungrouped[is id strings; reparent -> moved[(updated[mirrors it); repair -> cleaned[is id strings.`,"createBooleanOperation.description":`Create a single BOOLEAN_OPERATION node: the booleanOperation mode ({ops}) and children (at least 2 merged child nodes) are required. Only one root boolean node. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"setFillColor.description":`Set fill color/gradient (fills is a Paint array, replaced wholesale rather than merged — pass existing fills you want to keep), blend mode and team-library fill styles. {warn}`,"setText.description":`Modify text (TEXT nodes only): **content and typography** characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, **colour** fills/fillStyleId/blendMode, **size** width/height (pair with textAutoResize), plus Figma truncation and max lines; position x/y is not here — use jsd_move_node / jsd_resize_node. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content — for such text, setting characters again reflows it (measured: a fixed-width-200 text whose height read back 15 re-read 82). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`,"header.more":`More settings`,"menu.telemetry":`Error reporting`,"menu.cameraLock":`Camera lock`,"menu.theme":`Theme`,"menu.locale":`Language`,"telemetry.title":`Error reporting`,"telemetry.body":`To keep improving the product, enabling this records plugin and service errors.`,"telemetry.item.error":`Error messages and stacks`,"telemetry.item.identity":`Anonymous install ID (no document content or personal data)`,"telemetry.item.version":`Plugin and service versions`,"telemetry.state.on":`On`,"telemetry.state.off":`Off`,"telemetry.enable":`Enable reporting`,"telemetry.decline":`Not now`,"telemetry.disable":`Disable reporting`}},Ii=/\{(\w+)\}/g;function Li(e){let t=Fi[e]??Fi.en,n=Fi[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Ii,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Ri=/^zh([-_]|$)/i,zi=/^en([-_]|$)/i;function Bi(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Ri.test(t))return`zh-CN`;if(zi.test(t))return`en`}}var Vi={debug:0,info:1,warn:2,error:3,fatal:4},Hi=[`fatal`,`error`,`warn`];function Ui(e){return Hi.includes(e)}var Wi=[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`,`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_svg`,`jsd_create_icon`,`jsd_set_text`,`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_layout`,`jsd_resize_node`,`jsd_set_effects`,`jsd_delete_node`,`jsd_clone_node`,`jsd_reparent_nodes`,`jsd_create_component`,`jsd_create_instance`,`jsd_set_instance_properties`,`jsd_export`,`jsd_fill_image`,`jsd_batch`],Gi=[`jsd_manage_nodes`,`jsd_manage_components`],Ki={session:[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`],create:[`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_ellipse`,`jsd_create_line`,`jsd_create_polygon`,`jsd_create_star`,`jsd_create_vector`,`jsd_create_group`,`jsd_create_boolean_operation`],nodes:[`jsd_select_nodes`,`jsd_delete_node`,`jsd_clone_node`,`jsd_group_nodes`,`jsd_ungroup_nodes`,`jsd_flatten_nodes`,`jsd_outline_stroke`,`jsd_reparent_nodes`,`jsd_repair_nodes`,`jsd_manage_nodes`],components:[`jsd_create_component`,`jsd_create_instance`,`jsd_detach_instance`,`jsd_import_component`,`jsd_swap_component`,`jsd_set_instance_properties`,`jsd_combine_as_variants`,`jsd_copy_overrides`,`jsd_apply_overrides`,`jsd_sync_overrides`,`jsd_manage_components`],props:[`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_cornerRadius`,`jsd_set_text`,`jsd_move_node`,`jsd_resize_node`,`jsd_set_layout`,`jsd_set_effects`,`jsd_set_visibility`,`jsd_rename_node`,`jsd_set_shape`],media:[`jsd_create_svg`,`jsd_create_icon`,`jsd_html_to_design`,`jsd_export`,`jsd_fill_image`],styles:[`jsd_create_style`,`jsd_delete_style`],guidance:[`jsd_list_prompts`,`jsd_get_prompt`,`jsd_describe_tools`],platform:[`jsd_platform_op`],orchestration:[`jsd_batch`]},qi={"zh-CN":{full:`工具目录为兼容档,公开全部原有工具。`,compact:`工具目录为精简档。未公开的操作先用 jsd_describe_tools 按 group/query 查名称,再按 names 读取完整 schema,最后用 jsd_batch 执行;不要直接调用未公开的工具名。`,title:`查询可用工具与参数`,description:`按 group/query 分页查看内部能力摘要;按 names(最多 3 个)读取完整输入 schema、结果键和风险。未公开工具仅通过 jsd_batch 执行。只读、离线可用;查询不会改变公开目录。`},en:{full:`Compatibility catalog: all original tools are public.`,compact:`Compact catalog: use jsd_describe_tools with group/query to discover names, then names to read full schemas. Execute non-public tools through jsd_batch; do not call their names directly.`,title:`Discover tools and parameters`,description:`Page through capability summaries with group/query; pass names (up to 3) for full input schemas, result keys and risk hints. Execute non-public tools through jsd_batch. Read-only, available offline; discovery never changes the public catalog.`}},Ji={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},Yi=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,O=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,k=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,Xi={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:"两条路,都不是变量那种玩法:① **本地样式** —— `jsd_create_style` 从一个既有节点抄出样式(本平台四类:PAINT / TEXT / EFFECT / GRID;契约的类别是三家 `StyleType` 的八项并集,余下四类本平台没有工厂,传过去会被写前点名拒),回 id;绑上去用 jsd_set_fill_color 的 fillStyleId / jsd_set_text 的 textStyleId / jsd_set_effects 的 effectStyleId / jsd_set_stroke 的 strokeStyleId。**⚠ 本平台未声明 `styleEnumeration`,样式清单(`jsd://styles` / `assets.styles`)恒空、列不出来**:已有样式的 id 只能从正用着它的节点上读(`*StyleId` 字段),新建的 id 从 `jsd_create_style` 回包记账(建重复了用 `jsd_delete_style` 删)。一条样式改一次,全档跟随。② **结构继承** —— 抽成 COMPONENT 后改主件,实例自动继承(批量套覆盖走 variant-sync 配方)。",evidence:[`${Yi}(全文无 variable 声明:grep -in variable 零命中)`,`packages/ui/src/code/jsdesign/meta.ts capabilities=[styles](按 id 应用样式是有的;**不声明 styleEnumeration** —— 列不出样式,见 0043)`,`packages/shared/src/core/access.ts:174(listStylesAsync 在未声明 styleEnumeration 时直接返回空,四个 getter 一次都不调)`,"packages/ui/src/code/jsdesign/host.ts:48(createStyle 已接:`jsd_create_style` 走 jsDesign.createPaintStyle 等四工厂;四类样式的共同契约在 packages/shared/src/core/styles.ts)",`${Yi}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${Yi}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 团队库「组件集」导入入口,本仓只接了组件那半(:110);拿到集合节点是目前唯一的非画布来源`,`Page.createNodeFromJSXAsync(:119) —— JSX 建节点,是否支持组件/集合标签未验(typings 无声明,只有 any)`],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${Yi}:1093 setProperties 只收 string`,`${Yi}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:367-393 setProperties 签名只收字符串;真机 2026-10-14 的运行期行为:给**没有变体属性**的 INSTANCE 调它不是点名报错,而是挂到转发超时(25s)—— 没有变体集时别拿它当切状态的通道`,"packages/shared/src/core/component.ts setInstanceProperties 的属性面守卫 —— 2026-10-19 真机复现同一条(未知属性名 `Foo` → 25077ms 后失败、错误只有「插件响应超时」):能力位不含 componentProperties 且变体表 / variantProperties 都拿不到键时,写前点名拒,不再落到引擎空转","packages/shared/src/core/access.ts resolveMainComponent 的选路 —— 2026-10-19 真机隔离:typings 未声明的 `getMainComponentAsync` 在即时设计运行时**存在且永不 settle**(与 `*Async` 样式枚举同一模式),`?.` 探测让 `jsd_copy_overrides`(只读快照、不写属性)挂到 25109ms;改由 `mainComponentSync` 声明只问同步 `mainComponent`","packages/ui/src/code/jsdesign/ops.ts jsd_component_facts —— 2026-10-20 三页官方文档核对(js.design/developer-doc/plugin/api/node/{ComponentNode,InstanceNode,ComponentSetNode}):**成员与 typings 1.0.12 逐字一致,没有多出来的 API**;文档确认而契约缺的字段(ComponentNode.instances / key / remote / description / expanded / getPublishStatusAsync、InstanceNode.scaleFactor、ComponentSetNode.defaultVariant / variantGroupProperties / children)由本 op 透出。`getPublishStatusAsync` 单独可选:同族 async 成员有永不 settle 的先例(dec e1e66f0a)",`packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 真机(2026-10-20,重载后):COMPONENT 的 instances 可读且准确(建组件+2 实例 → instanceCount 2 / instanceIds 两条)、key 是空串、remote=false;description **可写**且回读一致(PublishableMixin :838);getPublishStatusAsync **21ms 返回、不永挂**(与 getMainComponentAsync 不同),但对非团队库节点回的是**错误串** "Failed to get node publish status" 而不是 PublishStatus 三值 ⇒ op 里三值才认,其余落 publishStatusError`,'packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 的 INSTANCE 分支 + core/assets.ts readVariantProperties —— 真机 2026-10-20 两条:① `variantGroupProperties.values` 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"}]),撞穿 assets.variants.properties 的 string[] 校验使 `get_page` **整条失败**,故 projection 与 op 都按名字归一;② 对真实变体实例调 setProperties **11~15ms 就抛** `in setProperties: i.setProperties is not a function`(typings :1093 与文档都声明了它)⇒ 符号是否真在由 op 的 `setPropertiesAvailable` 回报复核',"packages/ui/src/code/jsdesign/host.ts combineAsVariants 的显式绑定 —— 官方 API 参考页(js.design/developer-doc/plugin/api/reference/jsDesign)确认语义「将任意数量的组件合并为变体」、签名 (nodes, parent, index?);真机 2026-10-20 逐项排除:receiver 绑回全局后报错逐字相同、组件名改成 `状态=默认/禁用` 仍败、带子层仍败、先 reparent 进 FRAME 仍败 ⇒ **引擎实现缺陷,不是调用方式**",`packages/shared/src/core/component.ts combineAsVariantsNodes 的姿势顺序 —— 真机 2026-10-20:合并失败会**毁入参组件**(用户组件 13:100 变损坏节点、repair 直接删),故「原位合并」只在平台声明 inPlaceVariants 时才尝试(Figma 声明、顺序不变);jsDesign 只跑两条克隆姿势,失败也不伤原组件`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**单姿势隔离实验** —— 真机 2026-10-20(即时设计,干净画布,只跑原位姿势,传入真 COMPONENT、类型完全合规):仍抛 in get_booleanOperation: Value is not a string;后果是入参组件 13:332 被就地改成 BOOLEAN_OPERATION、13:333 幸存 ⇒ 坐实引擎实现缺陷,并排除两个替代解释:①「clone 返回 INSTANCE 导致参数类型不符才是根因」(原位传合规类型照样崩);②「被克隆两式弄脏画布才连带失败」(干净画布单跑照样崩)`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**裸调实验** —— 真机 2026-10-20(即时设计,画板 3 下 4 个真 COMPONENT,取消 core 的姿势选择 / clone 类型校验 / 父容器校验 / 跨父级校验 / 返回类型校验,直接 host.combineAsVariants(components, parent)):引擎**成功返回一个 type=BOOLEAN_OPERATION 的节点**(id 13:446),读它的 name 抛 in get_name: Value is not a string;四个原 COMPONENT **被搬进该布尔节点下**(parentId=13:446),画板 3 随即变空 ⇒ 坐实「引擎把合并路由成布尔运算」,并排除「core 的某个前置判断改变了入参」这一解释(裸调无任何判断,行为一致)。事后可用 jsd_reparent_nodes 把组件搬回原容器,损坏节点由 repair 清`,"packages/shared/src/core/access.ts resolveNodes 的返回身份 —— 真机 2026-10-20(即时设计,只读探针,未执行合并):四个 COMPONENT 逐个比对 `=== jsDesign.getNodeById(id)`,**全部 true**(即返回的是原生对象本身,不是包装或代理);成员核验 nodes 各有 createInstance(ComponentNode 独有)、无 setProperties(那是 InstanceNode 的),parent 有 children/appendChild/insertChild 且无 createInstance、且不等于 currentPage ⇒ 入参**完全满足** combineAsVariants(nodes: ReadonlyArray<ComponentNode>, parent: BaseNode & ChildrenMixin) 的签名。故「参数类型不满足」这一解释被排除:类型层面的 `as never` 只是掩盖了静态证明,运行时要传的对象是对的",`packages/shared/src/core/component.ts / jsd_reparent_nodes —— 真机 2026-10-20:RECTANGLE 可 reparent 进 COMPONENT(文档 ComponentNode 继承 BaseFrameMixin → appendChild :711),childCount 0→1,且**两个实例的 childCount 同步变 1**(主件加子层实时传播)`,`packages/shared/src/core/component.ts setInstanceProperties / swapComponents / detachInstanceNodes + packages/shared/src/core/nodes.ts cloneNodes + packages/shared/src/core/variant.ts —— 真机 2026-10-20(即时设计,逐条隔离):① **变体集成员**上 createInstance 必抛 in createInstance: The node with id undefined does not exist(集合内 8 个成员全复现;独立 COMPONENT 正常),clone() 返回 undefined;② swapComponent 必抛 in swapComponent: Cannot read properties of undefined (reading type)(独立组件之间 / 成员之间 / 克隆实例上全复现);③ detachInstance **原位返回同一个 INSTANCE**(type 仍 INSTANCE、mainComponentId 照旧)⇒ 静默 no-op;④ 集合维度键 状态 与成员键 分类1 **不是同一套**,只按集合键校验会把合法的成员键写入拒掉`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 未接;这是「不经画布拿到集合节点」的唯一路径`,`ComponentSetNode.appendChild / insertChild(:711-712,继承自 BaseFrameMixin)—— 类型上能追加成员,但没有创建入口 ⇒ 拿不到集合节点,这一面实际不可达`],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me);实例侧切值本平台运行期无入口(setProperties 不是函数、swapComponent 抛内部错误,真机 2026-10-20),变体取值只能在画布上手工切换`,evidence:[`${Yi}:899-900 VariantMixin.variantProperties(readonly)`,`${Yi}:1074-1079 ComponentSetNode 自身只多 clone / defaultVariant / variantGroupProperties;但 :1074 继承 BaseFrameMixin(:851)→ 带 appendChild / insertChild(:711-712)`,`packages/shared/src/core/variant.ts + core/serialize.ts + core/assets.ts —— 真机 2026-10-20:variantGroupProperties.values 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"},{"name":"禁用"}]),不归一会撞穿线格式 string[] 并让 get_page / jsd_find **整条失败**(不是少字段,是这次只读调用报废);variantProperties 同理。归一实现单点(两个投影点共用),serializeNode 另加一层「getter 抛也省略该字段」的保护`,"packages/ui/src/code/jsdesign/host.ts / core/component.ts combineAsVariants 兜底 —— 真机 2026-10-19 复核(即时设计,重载后):72ms 抛「三种姿势均失败…in get_booleanOperation: Value is not a string」**与 09-24/10-14 逐字一致**;残留形态这次是 **3 个 BOOLEAN_OPERATION(原 COMPONENT 被就地改成 BOOLEAN_OPERATION、id 保留)+ 1 个幸存 COMPONENT,没有 COMPONENT_SET**(10-14 那次是留下畸形 COMPONENT_SET),`assets.variants` 回到 0 ⇒ 残留形态不稳定,清理一律走 `jsd_repair_nodes`(实测 `cleaned: 3 个`)",`${Yi}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${O}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${O}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${O}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${O}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${O}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:11127 readonly componentProperties`,`${O}:11123 setProperties(string | boolean | VariableAlias)`,`${O}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${O}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${O}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${O}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${O}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${O}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${O}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${k}:1522 readonly variables: VariableAPI`,`${k}:1098-1108 VariableAPI(Collection / Mode)`,`${k}:1176 getVariables() / :1874 Variable{id,name,…}`,`${k}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${k}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${k}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/ops.ts removeVariables 的三档 —— 真机 2026-10-19(重载后两轮):单值变量的 deleteVariable **跨执行才生效**(同执行内删两遍 + 回读仍全失败,下一次调用立刻 removed),故同执行回读判失败会把成功报成失败(10-15 那 5 条 failed 即此形态);复合样式变量(PAINT)的 deleteVariable 是 **no-op**(跨多次执行仍在:列表 / assets.variables / 拿它绑图层三面都证明它还活着,同 id 走 jsd_delete_style 一次删掉)`,`packages/ui/src/code/mastergo/ops.ts createVariables 的 values —— 真机 2026-10-19:setVariableValue 的返回 modes **时有时无**(同批里有的带 bool / floatData,有的只有 {modeId},默认双模式集合回空对象);STRING 变量在列表 / 按 id / 写返回三个读面都只有 {modeId} ⇒ 值不可验证,values 只原样透传不作判据`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${k}:3096 readonly componentProperties: Array<ComponentProperties>`,`${k}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${k}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${k}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${k}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${k}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${k}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${k}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${k}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function A(e,t){return e==null?null:Xi[e][t]}var Zi={messageMax:8e3,stackMax:2e4,subjectMax:200,batchMax:50,idMax:100,contextMaxBytes:4096,bodyMaxBytes:262144},Qi={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},$i=`https://registry.npmjs.org`;function ea(e){return`${$i}/${e}/latest`}var ta=4e3;function na(e){let t=e;return t!=null&&t.type===`ui_version`&&typeof t.version==`string`}var j=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function ra(e){return e instanceof j?e.code:`plugin_error`}var ia=process.env.TEXT_TO_DESIGN_MCP_LOG??_(p(),`text-to-design-mcp.log`),aa=Vi,oa=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,sa=null;function ca(e){sa=e}function la(e){if(aa[e.level]>=aa[oa])try{r(ia,`${JSON.stringify({time:new Date().toISOString(),...e})}\n`)}catch{}try{sa?.(e)}catch{}}function M(e){la({level:`info`,scope:`daemon`,message:e})}function N(e){la({level:`debug`,scope:`daemon`,message:e})}function P(e,t){la({level:`warn`,scope:`daemon`,message:e,...t})}function F(e,t){la({level:`error`,scope:`daemon`,message:e,...t})}var ua=Re,da=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??ua,i=n.signal,a=`r${++this.seq}`,o=t&&typeof t==`object`&&`bytes`in t?t.bytes:null,s=o==null?{type:`request`,id:a,method:e,params:t}:{type:`request`,id:a,method:e,params:{...t,hasBinary:!0,bytes:void 0}};return new Promise((t,n)=>{let c=Date.now(),l={id:a,method:e,resolve:t,reject:n,timer:null,waitBinary:!1,binaryCount:0,buffers:[],startedAt:c};if(l.timer=setTimeout(()=>{this.pending.delete(a),this.detachAbort(l),P(`请求超时: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new j(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new j(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(clearTimeout(l.timer),this.detachAbort(l),M(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new j(`cancelled`,`请求已取消: ${e}`)))}},i.addEventListener(`abort`,l.abort.listener,{once:!0})}this.pending.set(a,l),M(`发出请求: ${a} ${e}${o==null?``:` +binary(${o.byteLength}B)`}`),this.sendFn(JSON.stringify(s),o==null?void 0:Buffer.from(o))})}detachAbort(e){e.abort&&=(e.abort.signal.removeEventListener(`abort`,e.abort.listener),void 0)}onText(e){let t;try{t=JSON.parse(e.toString())}catch(t){P(`WS 文本解析失败(${t instanceof Error?t.message:String(t)}): ${e.toString().slice(0,100)}`);return}if(t.type===`request`){t.method===`ping`?(M(`收到 ping 请求: ${t.id} (自动回 pong)`),this.sendFn(JSON.stringify({type:`response`,id:t.id,ok:!0,data:{pong:!0}}))):M(`收到未知请求: ${t.id} ${t.method} (忽略)`);return}if(t.type!==`response`){M(`收到非响应消息: type=${t.type}`);return}let n=this.pending.get(t.id);if(!n){P(`未匹配响应: id=${t.id}(客户端已取消回收,或来源不明)`);return}if(t.hasBinary&&(t.binaryCount??1)>0){if(M(`二进制响应开始: id=${t.id} count=${t.binaryCount??1}`),this.binaryTarget){let e=this.binaryTarget;this.binaryTarget=null,P(`二进制响应被覆盖: 旧 id=${e.id}(${e.buffers.length}/${e.binaryCount} 帧未收齐),新 id=${t.id}`)}n.waitBinary=!0,n.binaryCount=t.binaryCount??1,n.data=t.data,this.binaryTarget=n;return}this.pending.delete(t.id),clearTimeout(n.timer),this.detachAbort(n);let r=`响应: ${n.id} ${n.method} ok=${t.ok} 耗时=${Date.now()-n.startedAt}ms${t.ok?``:` error=${t.error?.code??``}`}`;t.ok?M(r):F(r,{scope:`bridge`,subject:n.method,code:t.error?.code??`plugin_error`}),t.ok?n.resolve(t.data):n.reject(t.error?new j(t.error.code,t.error.message):new j(`plugin_error`,`plugin error`))}onBinary(e){if(!this.binaryTarget){P(`孤儿二进制帧 len=${e.byteLength}(无待组装响应,已丢弃)`);return}if(this.binaryTarget.buffers.push(e),M(`二进制帧: id=${this.binaryTarget.id} ${this.binaryTarget.buffers.length}/${this.binaryTarget.binaryCount}`),this.binaryTarget.buffers.length>=this.binaryTarget.binaryCount){let e=this.binaryTarget;this.binaryTarget=null;let t=e.buffers.reduce((e,t)=>e+t.byteLength,0);M(`二进制组装完成: id=${e.id} ${e.buffers.length} 帧 ${t}B 耗时=${Date.now()-e.startedAt}ms`),this.settle(e)}}rejectAll(e){for(let[,t]of this.pending)clearTimeout(t.timer),this.detachAbort(t),t.reject(new j(`not_connected`,e.message));this.pending.clear()}clear(){for(let[,e]of this.pending)clearTimeout(e.timer),this.detachAbort(e);this.pending.clear(),this.binaryTarget=null}settle(e){this.pending.delete(e.id),clearTimeout(e.timer),this.detachAbort(e),e.resolve(fa(e.data,e.buffers))}};function fa(e,t){let n=t.length===1?t[0]:t;if(!e||typeof e!=`object`)return n;let r=e;if(r.exports&&typeof r.exports==`object`){let e=r.exports,n={};return Object.entries(e).forEach(([e,r],i)=>{n[e]={...r,bytes:t[i]}}),{...r,exports:n}}return{...r,bytes:n}}var pa=`0.13.9`,ma=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),ha=`text-to-design-mcp-server`,L=pa;function ga(e=process.env.TEXT_TO_DESIGN_TOOL_PROFILE){if(e==null||e===``||e===`full`)return`full`;if(e===`compact`)return`compact`;throw Error(`Invalid TEXT_TO_DESIGN_TOOL_PROFILE: ${e}; expected full or compact`)}var _a=Date.now(),va=15e3,ya=6e3,ba=5e3,xa=6e4,Sa=3e5,Ca=Number(process.env.TEXT_TO_DESIGN_RESOURCE_FONTS_TTL_MS??36e5),wa=Number(process.env.TEXT_TO_DESIGN_RESOURCE_DOCUMENT_TTL_MS??3e4),Ta=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),Ea=12e4,Da=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),Oa=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_BATCH_SPILL_BYTES??33554432),ka=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),Aa=(()=>{let e=process.env.TEXT_TO_DESIGN_MCP_MAX_TOOL_INPUT_ELEMENTS;if(e==null||e.trim()===``)return 2e4;if(e.trim().toLowerCase()===`off`)return;let t=Number(e);return Number.isFinite(t)&&t>=1?t:2e4})(),ja={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,Ma=null,Na=null;function Pa(){return R}function Fa(e){Ma=e}function Ia(){return Ma}function La(){let e=R?.platform;if(e==null)return{label:ja.label,runtime:ja.runtime};let t=En[e];return{label:`${t}客户端`,runtime:t}}function Ra(e){(R!=null||Ma!=null)&&(R=null,Ma=null,N(`平台状态已清空(${e})`))}function za(e){return Na??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:ba});if(t?.platform==null){N(`平台探测:回包缺 platform,保持未探测状态(判定 fail-open)`);return}R={platform:t.platform,capabilities:t.capabilities??[],coreCapabilities:t.coreCapabilities??[],platformOps:t.platformOps??[],at:Date.now()},M(`平台状态已缓存: ${En[R.platform]}(平台差异能力 ${R.capabilities.length} 项 / 特有操作 ${R.platformOps.length} 个)`)}catch(e){N(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{Na=null}})(),Na}function Ba(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function Va(e){if(Ba(e)!==!1)return null;let t=R?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>En[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${En[t]},已拒绝执行(未向插件发起请求)。`,e.descriptionSuffix??``,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Ha(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Ua=class{wss=null;http=null;client=null;heartbeat=null;_port=0;takeovers=0;onMessage=null;onConnect=null;onDisconnect=null;get port(){return this._port}async start(e){if(this.http=ne(),this.wss=new re({server:this.http}),this.wss.on(`error`,e=>{P(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),Ie),this.wss.on(`connection`,(e,t)=>this.attach(e,t)),!await this.tryListen(e))throw this.http.close(),Error(`插件 WS 端口 ${e} 已被占用。若确实是残留的 text-to-design-mcp,先 \`curl -X POST http://127.0.0.1:${I}/shutdown\` 收掉它;否则用 \`ss -tlnp | grep ${e}\` 找出占用者`);this._port=e}stop(){this.heartbeat&&clearInterval(this.heartbeat),this.heartbeat=null,this.client=null,this.wss?.close(),this.http?.close()}get isConnected(){return this.client!==null&&this.client.readyState===v.OPEN}send(e){this.client&&this.client.readyState===v.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===v.OPEN&&this.client.send(e)}attach(e,t){let n=`${t.socket.remoteAddress??`?`}:${t.socket.remotePort??`?`}`,r=this.client;r&&r!==e&&(this.takeovers+=1,P(`插件通道被新连接顶替(累计 ${this.takeovers} 次),关闭旧通道`),this.sendStatus(r,`superseded`),r.close(Le,`superseded`)),this.client=e,M(`插件已连接(peer=${n})`);try{this.onConnect?.()}catch(e){M(`onConnect 回调异常: ${e instanceof Error?e.message:String(e)}`)}this.sendStatus(e,`ready`),e.on(`message`,(e,t)=>{let n=Buffer.isBuffer(e)?e:Buffer.from(e);N(`收到 WS 消息 len=${n.length} bin=${t}`),this.onMessage?.(n,t)}),e.on(`close`,(t,r)=>{if(this.client!==e){N(`旧通道关闭(已被顶替),忽略`);return}this.client=null,M(`插件断开: code=${t}${r.length>0?` reason=${r.toString()}`:``} peer=${n} (${Ha(t)})`),this.onDisconnect?.(Error(`plugin disconnected (code=${t})`))}),e.on(`error`,t=>{this.client===e&&(this.client=null,M(`插件通道错误: ${t.message} peer=${n}`),this.onDisconnect?.(Error(`plugin connection error: ${t.message}`)))})}heartbeatTick(){let e=this.client;e&&e.readyState===v.OPEN&&(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==v.OPEN)return;let n={type:`status`,state:t,version:pa};try{e.send(JSON.stringify(n)),N(`已下发状态帧(${t})`)}catch(e){P(`状态帧下发失败(${t}): ${e instanceof Error?e.message:String(e)}`)}}tryListen(e){return new Promise(t=>{let n=()=>{i(),t(!1)},r=()=>{i(),t(!0)},i=()=>{this.http?.off(`error`,n),this.http?.off(`listening`,r)};this.http?.once(`error`,n),this.http?.once(`listening`,r),this.http?.listen(e)})}},Wa=200,Ga=class{transport=new Ua;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;onConsentSet=null;constructor(){this.pending=new da((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{if(t){this.pending.onBinary(e);return}try{let t=JSON.parse(e.toString());if(ze(t)){this.onConsentSet?.(t.granted);return}if(na(t)){Fa(t.version);return}}catch{}this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),this.onPluginConnect?.(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(P(`请求被拒(插件未连接): ${e}`),Promise.reject(new j(`not_connected`,`${La().runtime} 插件未连接。请先在${La().label}中运行该插件。`)))}notifyLog(e){let t={type:`log`,level:e.level,line:e.message,record:e};if(!this.transport.isConnected){this.logRing.length>=Wa&&this.logRing.shift(),this.logRing.push(t);return}this.sendLogPush(t)}pushVersion(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`版本推送失败: ${e instanceof Error?e.message:String(e)}`)}}notifyActivity(e,t){if(!this.transport.isConnected)return;let n=t==null?{type:`activity`,phase:e}:{type:`activity`,phase:e,tool:t};try{this.transport.sendPush(JSON.stringify(n))}catch(e){P(`活动推送失败: ${e instanceof Error?e.message:String(e)}`)}}pushConsent(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`同意状态推送失败: ${e instanceof Error?e.message:String(e)}`)}}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],M(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};function Ka(e){let t=oe(process.execPath,[...process.execArgv,...e??process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});t.unref(),t.on(`error`,e=>{F(`拉起 daemon 失败: ${e.message}`)})}async function z(){try{let e=await fetch(`http://127.0.0.1:${I}/health`,{signal:AbortSignal.timeout(800)});if(!e.ok)return null;let t=await e.json();return t.name&&t.version?{name:t.name,version:t.version,...typeof t.startedAt==`number`?{startedAt:t.startedAt}:{}}:null}catch{return null}}var qa=!1;function Ja(){let e=process.env.TEXT_TO_DESIGN_SELF_EXIT_MARKER;if(e!=null&&e.trim()!==``)return e;let t=process.env.XDG_STATE_HOME??_(f(),`.local`,`state`);try{let e=_(t,`text-to-design`);return a(e,{recursive:!0}),_(e,`daemon-self-exit`)}catch{return _(p(),`text-to-design-daemon-self-exit`)}}function Ya(){try{c(Ja(),{force:!0})}catch{}}function Xa(){let e=Ja();if(!i(e))return null;let t=Number(o(e,`utf8`).trim());return Number.isFinite(t)?t:null}async function Za(){if(qa)return;qa=!0;let e=process.argv[1];if(!e)return;let t;try{t=l(e).mtimeMs}catch{return}let n=await z();n?.startedAt==null||n.startedAt>=t||P(`常驻 daemon 跑在旧构建上(daemon 启动 ${new Date(n.startedAt).toISOString()} < 产物 ${new Date(t).toISOString()}),本次代码改动未生效。shim 启动会请它轮换;它自己不退时:curl -X POST http://127.0.0.1:${I}/shutdown`)}async function Qa(){let e=await z();if(e&&e.version!==L){M(`检测到旧版 daemon (${e.version} → ${L}),正在替换...`),await fetch(`http://127.0.0.1:${I}/shutdown`,{method:`POST`}).catch(()=>{});let t=Date.now()+ya;for(;Date.now()<t&&(await $a(250),await z()!==null););return await z()===null?{state:`none`}:(M(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new ie({name:`text-to-design-proxy`,version:L},{versionNegotiation:{mode:`auto`}});try{await t.connect(new ae(new URL(`http://127.0.0.1:${I}/mcp`)));let{tools:e}=await t.listTools();return e.length===0||!e.every(e=>e.name.startsWith(`jsd_`))?(await t.close(),{state:`foreign`}):{state:`proxy`,client:t}}catch{return await t.close().catch(()=>{}),await z()===null?{state:`none`}:{state:`starting`}}}function $a(e){return new Promise(t=>setTimeout(t,e))}async function eo(e={}){let t=Date.now()+va,n=e.first,r=!1;for(;;){let i=n??await Qa();if(n=void 0,i.state===`proxy`||i.state===`foreign`)return i;if(i.state===`none`&&e.spawnIfNone===!0&&!r&&(r=!0,Ka(e.argv)),Date.now()>=t)return null;await $a(250)}}var to=3,no=4,ro=240,io=16,ao=8;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oo(e,t){if(!e.startsWith(`#/`))return;let n={$defs:t};for(let t of e.slice(2).split(`/`)){let e=decodeURIComponent(t).replace(/~1/g,`/`).replace(/~0/g,`~`);if(!B(n))return;n=n[e]}return n}function so(e){let t=e.type;if(typeof t==`string`)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`&&e!==`object`&&e!==`array`);return e.length>0?e.join(`,`):void 0}}function co(e){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);if(!t.has(e)&&(t.add(e),n.push(r),n.length>=no))break}return n}function lo(e,t,n){if(!B(e))return{};if(typeof e.$ref==`string`){if(t>ao)return{};let r=oo(e.$ref,n.defs);return r===void 0?{}:lo(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>ro?`${t.slice(0,ro)}…`:t)}let i=so(e);i!=null&&(r.type=i);for(let i of[`anyOf`,`oneOf`,`allOf`]){let a=e[i];Array.isArray(a)&&a.length>0&&(r[i]=co(a.map(e=>lo(e,t,n))))}let a=t>=to&&B(e.properties);if(B(e.items)&&(r.items=a?{}:lo(e.items,t+1,n)),B(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,io),o={};for(let r of a)o[r]=lo(e.properties[r],t+1,n);if(r.properties=o,t===0&&Array.isArray(e.required)){let t=e.required.filter(e=>typeof e==`string`&&e in o);t.length>0&&(r.required=t)}}return(r.type===`object`||B(r.properties)||B(e.items)&&r.type!==`array`)&&(r.additionalProperties=!0),r}function uo(e){if(!B(e))return e;let t=lo(e,0,{defs:B(e.$defs)?e.$defs:{}});return B(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function fo(e){let t=e.properties;if(typeof t!=`object`||!t)return null;for(let e of Object.values(t))if(typeof e==`object`&&e){if(`const`in e&&e.const!=null)return String(e.const);if(Array.isArray(e.enum)&&e.enum.length>0)return String(e.enum[0])}return null}function po(e){let t=[e.oneOf,e.anyOf].find(e=>Array.isArray(e)&&e.length>0);return t==null?null:t.map((e,t)=>{let n=e??{},r=fo(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function mo(e){if(typeof e!=`object`||!e||Array.isArray(e))return JSON.stringify(e)??String(e);let t=Object.keys(e);return t.length>0?`字段 [${t.join(`, `)}]`:`空对象 {}`}function ho(e,t){if(t.oneOf!=null||t.anyOf!=null)return null;let n=t.properties;if(typeof n!=`object`||!n||typeof e!=`object`||!e||Array.isArray(e))return null;let r=new Set(Object.keys(n)),i=Object.keys(e).filter(e=>!r.has(e));return i.length>0?i:null}function go(e){let t=_e(e)[`~standard`],n=po(e);return{"~standard":{...t,validate(r){let i=t.validate(r);if(!(`issues`in i))return i;let a=``;if(typeof r==`object`&&r&&!Array.isArray(r)){let e=r.op;typeof e==`string`&&(a=`, op='${e}'`)}let o=i.issues.map(e=>typeof e?.message==`string`?e.message:``).filter(Boolean).join(`; `).slice(0,300),s=n==null?``:`该工具按判别字段分发,可选值: ${n}。`,c=ho(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${mo(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function _o(e){let t=Promise.resolve();return()=>{let n=t.catch(()=>{}).then(e);return t=n,n}}function vo(e){let t=e.mcpReq._meta?.progressToken;return{signal:e.mcpReq.signal,timeout:Ea+5e3,...t==null?{}:{onprogress:n=>{e.mcpReq.notify({method:`notifications/progress`,params:{...n,progressToken:t}}).catch(e=>P(`转发进度失败: ${String(e)}`))}}}}function yo(e){if(!e.params?._meta)return e;let{[pe]:t,[ue]:n,[fe]:r,...i}=e.params._meta;return{...e,params:{...e.params,_meta:i}}}function bo(e,t,r){let i=t.getServerCapabilities()?.extensions?.[ye];if(i==null)return;let a=n.looseObject({cursor:n.string().optional()}),o=n.looseObject({uri:n.string()}),s=n.looseObject({}),c=(e,t,n)=>r(r=>r.request({method:e,params:t},s,{signal:n}));e.server.setRequestHandler(xe,{params:a},(e,t)=>c(xe,e,t.mcpReq.signal)),e.server.setRequestHandler(be,{params:o},(e,t)=>c(be,e,t.mcpReq.signal)),i.directoryRead===!0&&e.server.setRequestHandler(ve,{params:o.extend({cursor:n.string().optional()})},(e,t)=>c(ve,e,t.mcpReq.signal)),e.server.registerCapabilities({extensions:{[ye]:i}})}var xo=5e5,So=5e3;function Co(e){if(e.length===0)return;let t=e.reduce((e,t)=>e+t.bytes,0),n=e.reduce((e,t)=>t.outputBytes>e.outputBytes?t:e);M(`目录体积: ${e.length} 个工具 / ${(t/1024).toFixed(0)} KB(出参最大 ${n.name} ${(n.outputBytes/1024).toFixed(1)} KB)`);let r=[...t>xo?[`合计 ${(t/1024).toFixed(0)} KB > ${xo/1024} KB`]:[],...e.filter(e=>e.outputBytes>So).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function wo(e){let t={};for(let r of e??[]){let e=n.string().describe(r.description??``);t[r.name]=r.required===!0?e:e.optional()}return n.object(t)}function To(e,t){let n=new le({name:ha,version:L},{supportedProtocolVersions:[`2026-07-28`,...me],...Aa==null?{}:{maxToolInputElements:Aa},...e.getInstructions()?{instructions:e.getInstructions()}:{},cacheHints:{"tools/list":{ttlMs:0,cacheScope:`private`},"prompts/list":{ttlMs:0,cacheScope:`private`},"resources/list":{ttlMs:0,cacheScope:`private`},"resources/templates/list":{ttlMs:0,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}}),r=new Map,i=new Map,a=new Map,o=new Map;function s(e,t,n){let r=new Set;for(let i of t){let t=n.keyOf(i);r.add(t);let a=JSON.stringify(i),o=e.get(t);if(o&&o.raw===a)continue;let s;try{s=n.register(i)}catch(e){P(`${n.kind}注册失败(${t}): ${e instanceof Error?e.message:String(e)}`);continue}o!=null&&(o.handle.remove(),e.delete(t)),e.set(t,{handle:s,raw:a})}for(let[t,n]of[...e])r.has(t)||(n.handle.remove(),e.delete(t))}async function c(){let{tools:e}=await t(e=>e.listTools(void 0,{cacheMode:`refresh`})),i=[],a=n.registerTool.bind(n);s(r,e,{keyOf:e=>e.name,kind:`工具`,register:e=>{let n=e.outputSchema?uo(e.outputSchema):void 0,r=JSON.stringify({title:e.title,description:e.description,annotations:e.annotations,icons:e.icons,_meta:e._meta,inputSchema:e.inputSchema,outputSchema:n});i.push({name:e.name,bytes:Buffer.byteLength(r,`utf8`),outputBytes:n===void 0?0:Buffer.byteLength(JSON.stringify(n),`utf8`)});let o={title:e.title,description:e.description,annotations:e.annotations,icons:e.icons,_meta:e._meta,...e.inputSchema?{inputSchema:go(e.inputSchema)}:{},...n===void 0?{}:{outputSchema:_e(n)}};return a(e.name,o,async(n,r)=>t(t=>t.callTool({name:e.name,arguments:n??{},_meta:r.mcpReq._meta},vo(r)),{replay:e.annotations?.readOnlyHint===!0||e.annotations?.idempotentHint===!0}))}}),Co(i)}async function l(){let{prompts:e}=await t(e=>e.listPrompts(void 0,{cacheMode:`refresh`}));s(i,e,{keyOf:e=>e.name,kind:`prompt`,register:e=>n.registerPrompt(e.name,{title:e.title,description:e.description,icons:e.icons,_meta:e._meta,argsSchema:wo(e.arguments)},(n,r)=>t(t=>t.getPrompt({name:e.name,...n?{arguments:n}:{},_meta:r.mcpReq._meta},vo(r))))})}async function u(){let[{resources:e},{resourceTemplates:r}]=await Promise.all([t(e=>e.listResources(void 0,{cacheMode:`refresh`})),t(e=>e.listResourceTemplates(void 0,{cacheMode:`refresh`}))]);s(a,e,{keyOf:e=>e.uri,kind:`资源`,register:e=>n.registerResource(e.name,e.uri,{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n)=>t(t=>t.readResource({uri:e.href,_meta:n.mcpReq._meta},{...vo(n),cacheMode:`bypass`})))}),s(o,r,{keyOf:e=>String(e.uriTemplate),kind:`资源模板`,register:e=>{let r=String(e.uriTemplate);return n.registerResource(e.name,new de(r,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n,r)=>t(t=>t.readResource({uri:e.href,_meta:r.mcpReq._meta},{...vo(r),cacheMode:`bypass`})))}})}let d=_o(c),f=_o(l),p=_o(u),m=async()=>{let e=await Promise.allSettled([d(),f(),p()]);for(let t of e)t.status===`rejected`&&P(`同步清单失败: ${String(t.reason).slice(0,120)}`)};bo(n,e,t),e.getServerCapabilities()?.completions&&(n.server.registerCapabilities({completions:{}}),n.server.setRequestHandler(`completion/complete`,(e,n)=>t(t=>t.complete(e.params,vo(n)))));function h(e){e.setNotificationHandler(`notifications/tools/list_changed`,async e=>{await d(),n.isConnected()&&await n.server.notification(yo(e))}),e.setNotificationHandler(`notifications/prompts/list_changed`,async e=>{await f(),n.isConnected()&&await n.server.notification(yo(e))}),e.setNotificationHandler(`notifications/resources/list_changed`,async e=>{await p(),n.isConnected()&&await n.server.notification(yo(e))}),e.setNotificationHandler(`notifications/resources/updated`,async e=>{n.isConnected()&&await n.server.notification(yo(e))})}return{server:n,syncAll:m,wireNotifications:h}}var Eo=1500,Do=2e4,Oo=6e4,ko=6e5;function Ao(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}async function jo(e){let t=e,n=!1,r=null,{server:i,syncAll:a,wireNotifications:o}=To(e,async(e,r)=>{try{return await e(t)}catch(i){if(n||!Ao(i)||(P(r?.replay===!1?`shim: 上游请求失败,恢复连接但不重放写操作`:`shim: 上游请求失败,触发重连后重放`),await s(),r?.replay===!1))throw i;return e(t)}}),s=()=>r||(r=(async()=>{let e=Date.now()+Do,n=null;for(;Date.now()<e;){try{let e=await Qa();if(e.state===`proxy`){let n=t;t=e.client,n.onclose=void 0,await n.close().catch(()=>{}),await c(t),M(`shim: 上游已恢复`),a().catch(e=>P(String(e)));return}e.state===`none`&&Ka()}catch(e){n=e}await $a(Eo)}throw n??Error(`上游重连超时(${Do}ms)`)})().finally(()=>{r=null}),r),c=async e=>{if(e.onclose=()=>{n||e!==t||(P(`shim: 上游断开,自动重连`),s().catch(e=>P(String(e))))},o(e),e.getProtocolEra()!==`modern`)return;let r=e.getServerCapabilities(),i={toolsListChanged:r?.tools?.listChanged===!0,promptsListChanged:r?.prompts?.listChanged===!0,resourcesListChanged:r?.resources?.listChanged===!0};if(Object.values(i).some(Boolean))try{(await e.listen(i)).closed.then(async r=>{r===`local`||n||e!==t||(await $a(Eo),!n&&e===t&&await s())}).catch(e=>P(String(e)))}catch(e){P(`shim: 目录变更订阅失败,由定期同步兜底: ${String(e)}`)}};await c(t);let l=ce(async()=>(await a(),i)),u=L,d=null,f=null,p=async()=>{let e=await z();e!=null&&e.version!==u&&(M(`上游版本变化(${u} → ${e.version}),全量重同步目录`),u=e.version,await a())},m=()=>{n||(d=setTimeout(()=>{n||p().finally(m)},Oo),d.unref())},h=()=>{n||(f=setTimeout(()=>{n||a().finally(h)},ko),f.unref())};m(),h(),M(`shim 模式: stdio → 动态同步,共享 daemon`);let g=async()=>{n||(n=!0,d&&clearTimeout(d),f&&clearTimeout(f),await l.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}))};process.stdin.once(`end`,()=>{g()}),process.stdin.once(`close`,()=>{g()}),process.on(`SIGINT`,()=>{g().finally(()=>process.exit(0))})}var Mo=_(f(),`.text-to-design`),No=_(Mo,`consent.json`),Po=!1,Fo=!1;async function Io(){try{let e=JSON.parse(await De(No,`utf8`));Po=e?.granted===!0,Fo=e?.asked===!0}catch{Po=!1,Fo=!1}}function Lo(){return Po}function Ro(){return Fo}async function zo(e){Po=e,Fo=!0;try{await Ee(Mo,{recursive:!0}),await ke(No,`${JSON.stringify({granted:e,asked:Fo,updatedAt:new Date().toISOString()},null,2)}\n`,`utf8`)}catch(e){P(`同意状态写盘失败: ${e instanceof Error?e.message:String(e)}`)}}var Bo=new WeakMap;function Vo(e){let t=Bo.get(e);return t??(t={profile:`full`,capabilities:new Map,executors:new Map},Bo.set(e,t)),t}function Ho(e,t){if(Vo(e).capabilities.size>0)throw Error(`Tool profile must be configured before registration`);Vo(e).profile=t}function Uo(e,t){return Vo(e).profile===`full`?t!==`jsd_describe_tools`:t===`jsd_describe_tools`||Wi.includes(t)}function Wo(e,t,r){let i=Vo(e);if(i.profile===`compact`&&Gi.includes(t.name)||(i.capabilities.set(t.name,t),i.executors.set(t.name,r),!Uo(e,t.name)))return{};let{name:a,outputSchema:o,...s}=t,c=o==null?void 0:_e(uo(n.toJSONSchema(o)));return e.registerTool.bind(e)(a,{...s,...c==null?{}:{outputSchema:c}},async(...e)=>{let n=t.inputSchema==null?e[0]:e[1];return r(t.inputSchema==null?{}:e[0]??{},n?.mcpReq?.signal??n?.signal)})}function Go(e=process.env.TEXT_TO_DESIGN_LANG){return Bi(e)??`zh-CN`}function Ko(e=Go()){return{locale:e,t:Li(e)}}function V(e){throw Error(e)}var qo=50;async function Jo(e){let t=e.trim();t===``&&V(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),g(t)||V(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await Oe(t).catch(e=>{V(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||V(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>Da&&V(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(Da/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await De(t,`utf8`).catch(e=>{V(`读 callsFile「${t}」失败:${e instanceof Error?e.message:String(e)}。`)}),i;try{i=JSON.parse(r)}catch(e){V(`callsFile「${t}」不是合法 JSON:${e instanceof Error?e.message:String(e)}。文件内容应为 {"calls":[…]} 或直接一个数组。`)}let a=Array.isArray(i)?{calls:i}:i;(typeof a!=`object`||!a||Array.isArray(i))&&V(`callsFile「${t}」的顶层既不是数组也不是对象。两种合法形状:直接给步骤数组,或给 {"calls":[…]}。`);let o=a.calls;Array.isArray(o)||V(`callsFile「${t}」里没有 calls 数组(实际类型 ${o===void 0?`undefined`:typeof o})。文件内容应为 {"calls":[…]} 或直接一个数组。`),o.length===0&&V(`callsFile「${t}」的 calls 是空数组,没有步骤可执行。`),o.length>qo&&V(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${qo} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=Gt.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);V(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return M(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function Yo(e,t={}){let n=new Map;for(let t of e){let e=t.parentId;typeof e==`string`&&e!==``&&n.set(e,(n.get(e)??0)+1)}let r=t.existingChildCount,i=typeof r==`number`&&r>=0?r:0,a=null;for(let[e,t]of n){let n=t+i;n<9||(a==null||n>a.batchCount)&&(a={parentId:e,batchCount:n})}return a}function Xo(e,t,n){let r=n.args.parentId;if(typeof r!=`string`||r===``)return 0;let i=0;for(let a=t+1;a<e.length;a++){let t=e[a];if(t.tool!==n.tool)continue;let o=t.args;typeof o==`object`&&o&&o.parentId===r&&i++}return i}function Zo(e){let t=new Set,n=/<g\b[^>]*\bid\s*=\s*["']([^"']+)["']/g;for(;;){let r=n.exec(e);if(r==null)break;t.add(r[1])}return t.size}function Qo(e){let t=e.def;if(typeof t==`object`&&t)return t;let n=e._def;return typeof n==`object`&&n?n:void 0}function $o(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Qo(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function es(e,n){t.globalRegistry.add(e,{description:n})}function ts(e){let t=[];for(let n of[`innerType`,`element`,`valueType`,`keyType`,`in`,`out`,`catchall`,`rest`]){let r=e[n];typeof r==`object`&&r&&t.push(r)}if(Array.isArray(e.options))for(let n of e.options)typeof n==`object`&&n&&t.push(n);if(Array.isArray(e.items))for(let n of e.items)typeof n==`object`&&n&&t.push(n);if(Array.isArray(e.type))for(let n of e.type)typeof n==`object`&&n&&t.push(n);let n=e.shape;if(typeof n==`object`&&n)for(let e of Object.values(n))typeof e==`object`&&e&&t.push(e);if(typeof e.getter==`function`)try{let n=e.getter();typeof n==`object`&&n&&t.push(n)}catch{}return t}function ns(e,t){let n=new Set,r=e=>{if(typeof e!=`object`||!e||n.has(e))return;n.add(e);let i=e;t(i);let a=Qo(i);if(a!=null)for(let e of ts(a))r(e)};r(e)}function rs(e,t){return ns(e,e=>{let n=$o(e);if(n==null)return;let r=t(n);r!==n&&es(e,r)}),e}function is(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function as(e){return e._def?.typeName}function os(e,t){return e._def?.[t]}function ss(e,t){return e._def?.[t]}function cs(e){switch(as(e)){case`ZodObject`:{let t=e.shape;if(typeof t!=`function`)return;let n={};for(let[e,r]of Object.entries(t()))n[e]=cs(r);return n}case`ZodArray`:return[];case`ZodBoolean`:return!1;case`ZodNumber`:return 0;case`ZodString`:return``;case`ZodLiteral`:return ss(e,`value`);case`ZodEnum`:return ss(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=os(e,`innerType`);return t?cs(t):void 0}case`ZodEffects`:{let t=os(e,`schema`);return t?cs(t):void 0}case`ZodUnion`:{let t=ss(e,`options`)??[],n=t.find(e=>as(e)===`ZodArray`);return n?cs(n):t[0]?cs(t[0]):void 0}case`ZodLazy`:{let t=e._def?.getter;return t?cs(t()):void 0}default:return}}var ls={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function us(e,t,n){let r=ra(e),i=ls[r]??n,a={content:[{type:`text`,text:`错误: ${e instanceof Error?e.message:String(e)}`}],isError:!0,code:r};return i!==void 0&&(a.followUp=i),t?{...a,structuredContent:cs(t)}:a}function ds(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...is(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:[{type:`text`,text:`错误: 结果未通过本工具的输出校验 —— ${i.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).slice(0,8).join(`; `)}\n原始返回:\n${JSON.stringify(e,null,2)}`}],structuredContent:cs(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...is(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}function fs(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function ps(e){return typeof e!=`object`||!e||Array.isArray(e)?null:e}function ms(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function hs(e,t,n,r){return`字段 [${e.slice(0,8).join(`, `)}]${e.length>8?` 等 ${e.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${t.length<=20?`该工具接受: [${t.join(`, `)}]。`:`该工具接受 ${t.length} 个字段(完整清单见其 schema),本次收到的 [${n.join(`, `)}] 里只有上述字段越界。`}原始校验: ${r}`}function gs(e,t,n){let r=fs(e),i=ps(t);if(r==null||i==null)return n;let a=Object.keys(i),o=ms(a,r);return o.length===0?n:hs(o,r,a,n)}var _s=e(import.meta.url);function vs(e){return o(_s.resolve(`lucide-static/icons/${e}.svg`),`utf8`).replace(/<!--[\s\S]*?-->/g,``).replace(/^[\s\S]*?<svg[^>]*>/i,``).replace(/<\/svg>\s*$/i,``).replace(/\s+/g,` `).trim()}function ys(e,t){let n=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${vs(e)}</svg>`;return{src:`data:image/svg+xml;utf8,${encodeURIComponent(n)}`,mimeType:`image/svg+xml`,sizes:[`24x24`]}}var bs={create:`#2563EB`,read:`#64748B`,modify:`#0EA5E9`,structure:`#7C3AED`,component:`#0891B2`,run:`#F59E0B`,output:`#059669`,meta:`#334155`},xs={create:`square-plus`,read:`search`,modify:`pencil`,structure:`network`,component:`component`,run:`zap`,output:`download`,meta:`plug`,recipe:`book-open`,canvas:`layers`},Ss=new Map;function Cs(e){let t=Ss.get(e);if(t!=null)return t;let n=e===`recipe`||e===`canvas`?bs.structure:bs[e],r=[ys(xs[e],n)];return Ss.set(e,r),r}var ws={jsd_ping:`meta`,jsd_export:`output`,jsd_batch:`run`},Ts=[[`jsd_create_`,`create`],[`jsd_set_`,`modify`],[`jsd_move_`,`modify`],[`jsd_resize_`,`modify`],[`jsd_rename_`,`modify`],[`jsd_fill_`,`modify`],[`jsd_delete_`,`modify`],[`jsd_find`,`read`],[`jsd_get_`,`read`],[`jsd_list_`,`read`],[`jsd_select_`,`read`],[`jsd_group_`,`structure`],[`jsd_ungroup_`,`structure`],[`jsd_reparent_`,`structure`],[`jsd_flatten_`,`structure`],[`jsd_outline_`,`structure`],[`jsd_repair_`,`structure`],[`jsd_combine_`,`component`],[`jsd_swap_`,`component`],[`jsd_detach_`,`component`],[`jsd_apply_`,`component`],[`jsd_copy_`,`component`],[`jsd_sync_`,`component`],[`jsd_import_`,`component`]],Es=`meta`;function Ds(e){let t=ws[e];if(t!=null)return t;for(let[t,n]of Ts)if(e.startsWith(t))return n;return Es}function Os(e){return Cs(Ds(e))}function ks(){return Cs(`recipe`)}function As(){return Cs(`canvas`)}function js(e,t){return Vo(t).executors.get(e)}function Ms(e){return[...Vo(e).executors.keys()].sort()}function H(e){return(t,n,r)=>{let i=e=>e==null||e.type!==`tool`?e:Uo(t,e.tool)?e.description==null?e:{...e,description:r.t(e.description)}:{type:`tool`,tool:`jsd_describe_tools`,description:e.tool},a=(e,t)=>{try{n.notifyActivity(e,t)}catch(e){P(`活动提醒推送失败(已忽略): ${e instanceof Error?e.message:String(e)}`)}},o=async(r,o,s)=>{try{let c=Va(e);if(c!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`,{scope:`tool`,subject:e.name,code:`platform_unsupported`}),us(new j(`platform_unsupported`,c),e.outputSchema,i(e.followUp));if(e.inputSchema!=null){let t=e.inputSchema.safeParse(r);if(!t.success){let n=t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new j(`invalid_args`,`参数校验失败(${e.name}): ${gs(e.inputSchema,r,n)}`)}r=t.data}let l={...o==null?{}:{signal:o},...e.timeout==null?{}:{timeout:e.timeout}};a(`running`,e.name);let u=s?.skipHooks===!0?void 0:e.hook?.(t);if(u?.before!=null)try{await u.before(r)}catch(t){P(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let d;d=e.run?await e.run(r,n,o??new AbortController().signal):await n.request(e.method,e.payload?e.payload(r):r,l);let f=e.extraContent?e.extraContent(d,r,s):[],p=[],m=d?.warnings;if(Array.isArray(m))for(let e of m)typeof e==`string`&&e!==``&&p.push(e);if(u?.after!=null)try{let e=await u.after(r,d)??[];for(let t of e)p.push(t),f.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;p.push(n),f.push({type:`text`,text:n})}let h=ds(d,e.outputSchema,f.length>0?f:void 0,i(e.followUp));return a(`success`,e.name),p.length>0?{...h,warnings:p}:h}catch(t){let n=t instanceof Error?t.message:String(t);return F(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`,{scope:`tool`,subject:e.name,code:ra(t)}),a(`error`,e.name),us(t,e.outputSchema,i(e.followUp))}},{t:s}=r;return Wo(t,{name:e.name,title:s(e.title),description:e.descriptionSuffix==null?s(e.description):s(e.description)+s(e.descriptionSuffix),...e.inputSchema==null?{}:{inputSchema:rs(e.inputSchema,s)},outputSchema:rs(e.outputSchema,s),annotations:e.annotations,icons:e.icons??Os(e.name)},o)}}function Ns(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(Array.isArray(n)&&n.length===1&&(n=n[0]),typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){let t=Number(e[1]);if(!Array.isArray(n)){if(t===0&&typeof n==`object`&&n)continue;return{ok:!1}}n=n[t]}}return{ok:!0,value:n}}var Ps=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}},Fs={not_connected:`插件未连接(本次步骤没有发到设计客户端)。先 jsd_ping / 确认面板显示「已连接」再重试。`,plugin_timeout:`请求超时(插件可能仍在执行)。先 jsd_ping 确认连接,再 jsd_find 复核该步是否已落地,别盲目重发。`,platform_unsupported:`当前设计客户端不支持该能力,见下方原始报错里的替代路径。`,invalid_args:`入参不合法,按下方原始报错点名要删/要补的字段后重试。`};function Is(e,t){let n=e==null?void 0:Fs[e],r=t.slice(0,300);return n==null?r:`${n} 原始报错: ${r}`}function Ls(e,t,n){let r=e.indexOf(`.`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r+1);if(!t.has(i)){let r=[...t.keys()].join(`, `)||`无`;throw n.has(i)?new Ps(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=Ns(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var Rs=/^@(comp|var):([\s\S]+)$/;function zs(e,t,n){let r=t.trim(),i=e===`comp`?`组件/变体集`:`变量`,a=n.filter(e=>e.name===r),o=a.length>0?a:n.filter(e=>e.name.trim().toLowerCase()===r.toLowerCase());if(o.length===1)return o[0].id;if(o.length>1)throw Error(`按名字取${i}「${t}」撞上 ${o.length} 个同名资源:${o.map(e=>`${e.name}(${e.id})`).join(`、`)}。名字不唯一时改用 id 直接写,或先重命名(0041:不确定就点名,绝不猜)。`);let s=n.slice(0,30).map(e=>e.name);throw Error(`按名字取${i}「${t}」没命中。${s.length===0?`这一面当前读不到任何${i}(两种原因都可能:本平台未声明该能力面,或本平台读不到非当前页 —— 到底哪种见 jsd_get_page 回包的 note)`:`现有${i}:${s.join(`、`)}${n.length>s.length?` …`:``}`};也可以直接写 id。`)}async function Bs(e,t,n){let r=await n();return zs(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var Vs=/\{\{\s*([^{}]+?)\s*\}\}/g,Hs=/^\{\{\s*([^{}]+?)\s*\}\}$/,Us=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],Ws=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),Gs=2e4;function Ks(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var qs=[`x`,`y`,`width`,`height`,`parentId`];function Js(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:qs.some(t=>e[t]!==void 0)}function Ys(e){if(Array.isArray(e))return e.map(Ys);if(typeof e!=`object`||!e)return e;let t=e;if(Js(t)){let e={};for(let n of Us)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))Ws.has(e)||(n[e]=Ys(r));return n}function Xs(e,t){if(Array.isArray(e)){for(let n of e)Xs(n,t);return}if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e)){if(n===`id`&&typeof r==`string`){t.push(r);continue}Xs(r,t)}}function Zs(e,t){let n=Ys(e),r=Ks(n);if(r<=Gs)return{data:n,trimmed:r!==Ks(e),omitted:!1};let i=[];return Xs(n,i),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${r} 字符,已省略明细;需要细节请把 ${t} 单独调用一次`,ids:[...new Set(i)]},trimmed:!0,omitted:!0}}function Qs(e,t,n){let r=[`回显已裁剪:${e.length} 步(${e.join(` / `)})的节点只保留 id/name/type/x/y/width/height/z/parentId`,` —— 子节点、characters、fills、*StyleId、vectorPaths 等字段不在回显里。`,`要读这些字段,请把对应工具**单独调用一次**;批内回显不是验收证据。`,"占位符 `{{步骤id.…}}` 不受影响,它取的是裁剪前的完整数据。"];return t.length>0&&r.push(n==null?`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,已降级为 id 清单,步骤内的 note 已点名工具名。`:`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,完整明细已落盘到 ${n.path}(${n.bytes} 字节,JSONL 一行一步),按各步 data 里的 line 读即可。`),r.join(``)}var $s=0;function ec(e,t){let n=[],r=new Map;for(let i of e)r.set(i.id,n.length+1),n.push(JSON.stringify(i.ok?{id:i.id,tool:i.tool,ok:!0,data:t.get(i.id)}:{id:i.id,tool:i.tool,ok:!1,error:i.error}));let i=`${n.join(`
|
|
16
|
-
`)}\n`,a=Buffer.byteLength(i,`utf8`);if(a>Oa)return{error:`明细 ${a} 字节 > 上限 ${Oa} 字节`};let o=_(p(),`jsd-batch-${Date.now().toString(36)}-${++$s}.jsonl`);try{d(o,i,`utf8`)}catch(e){return{error:`写盘失败:${e instanceof Error?e.message:String(e)}`}}return{path:o,bytes:a,line:r}}async function tc(e,t,n,r){let i=async e=>{let i=Rs.exec(e.trim());return i==null?Ls(e,t,r):Bs(i[1],i[2],n)};if(typeof e==`string`){let t=Hs.exec(e.trim());if(t!=null)return i(t[1]);let n=``,r=0;for(let t of e.matchAll(Vs)){n+=e.slice(r,t.index);let a=await i(t[1]);n+=typeof a==`string`?a:JSON.stringify(a),r=(t.index??0)+t[0].length}return r===0?e:n+e.slice(r)}if(Array.isArray(e)){let i=[];for(let a of e)i.push(await tc(a,t,n,r));return i}if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=await tc(o,t,n,r);return i}return e}function nc(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:Kt,outputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:Ea,run:async(t,n,r)=>{let{calls:i,callsFile:a,stopOnError:o,checkDrift:s}=t,c=a==null||a.trim()===``?null:await Jo(a);if(c!=null&&i!=null)throw Error(`calls 与 callsFile 只能给一个:calls 在本批内直接执行,callsFile 从文件读同一份清单。两个都给会让「哪份生效」变成猜。`);if(c==null&&i==null)throw Error(`需要 calls 或 callsFile 其中一个(都缺省时没有步骤可执行)。参数体大到写不进上下文时,把清单写进 JSON 文件、这里只传它的绝对路径。`);let l=c?.calls??i??[],u=c?.stopOnError??o,d=c?.checkDrift??s,f=new Map,p=[],m=!1,h=[],g=[],_=d===!1,ee=[],te,ne=()=>(te??=(async()=>{let e;try{e=await n.request(`get_page`,{},{...r==null?{}:{signal:r}})}catch(e){let t=e instanceof Error?e.message:String(e);throw new j(ra(e),`按名字取资源要先读一次 jsd_get_page,但这次资源清单没读到(${t})—— 这是「资源清单不可得」(插件未连接 / 请求失败),不是「画布上没有这个组件或变量」。先确认插件已连接(jsd_ping)后重试本批,或把要用的 id 直接写进 args。`)}return e?.assets??{}})(),te),v=new Set;for(let t=0;t<l.length;t++){let n=l[t],i=n.id==null||n.id.trim()===``?`step${t+1}`:n.id.trim(),a=e=>{v.add(i),p.push({id:i,tool:n.tool,ok:!1,error:e})};if(f.has(i)||p.some(e=>e.id===i)){a(`步骤 id "${i}" 重复`);break}let o=js(n.tool,e);if(o==null){a(`未知工具 ${n.tool},可用: ${Ms(e).join(`, `)}`);break}let s;try{s=await tc(n.args??{},f,ne,v)}catch(e){if(a(e instanceof Error?e.message:String(e)),e instanceof Ps&&(u===!1||n.continueOnError===!0))continue;break}let c=Xo(l,t,{tool:n.tool,args:s}),d=await o(s,r,{skipHooks:_,...c===0?{}:{batch:{siblingSteps:c}}});if(d.isError===!0){let e=d.content?.find(e=>e.type===`text`)?.text??`工具返回错误`;if(a(Is(d.code,e)),u!==!1&&n.continueOnError!==!0)break;continue}let te=Zs(d.structuredContent,n.tool);te.trimmed&&(m=!0,h.push(i)),te.omitted&&g.push(i),f.set(i,d.structuredContent),d.warnings!=null&&ee.push(...d.warnings),p.push({id:i,tool:n.tool,ok:!0,data:te.data})}let re=p.length===l.length,ie=ee,ae=g.length===0?void 0:ec(p,f),oe=ae!=null&&`error`in ae?void 0:ae;if(ae!=null&&`error`in ae&&ie.push(`本批有 ${g.length} 步回显超预算,但完整明细未落盘(${ae.error});已保留 id 清单,要明细请把对应工具单独调用一次。`),oe!=null)for(let e of p){if(!g.includes(e.id))continue;let t=e.data,n=oe.line.get(e.id);t!=null&&t.echoOmitted===!0&&n!=null&&(e.data={...t,path:oe.path,line:n,note:`本步明细已随整批落盘(第 ${n} 行);也可把 ${e.tool} 单独调用一次。`})}return{ok:re&&p.every(e=>e.ok),executed:p.length,total:l.length,results:p,...m?{echoTrimmed:!0}:{},...m?{echoNote:Qs(h,g,oe)}:{},...ie.length>0?{warnings:ie}:{}}}})(e,t,n)]}function rc(e){return e==null?x:[e]}function U(e){return En[e]}function ic(e,t){return A(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function ac(e,t){let n=e=>{let t=e==null?null:A(e,`variants`)?.setLevelOps;return t==null||t.length===0?``:`造新维度/新取值不用绕实例:本平台有集合级管理入口(${t.join(` / `)})—— 先 mg_list_variant_properties 看现状,再建维度/加成分/改取值,每个 op 都写完回读(各自的行为注意写在它的描述里,调用前读一眼);换绑(jsd_set_instance_properties)只负责切到**已有**成分。`};if(e!=null&&t!=null){let r=A(e,`variants`),i=r?.read,a=r?.write.includes(`jsd_set_instance_properties`)===!0,o=i==null?``:a?`文档里**已有**的变体集不受影响:\`${i}\` 与组件集上的维度取值照常读得到,已有取值照常用 jsd_set_instance_properties 切 —— 缺的只是「用脚本造一个新的」;`:`文档里**已有**的变体集读得到:\`${i}\` 与组件集上的维度取值照常可读,但**实例侧切值本平台运行期没有可用入口**(引擎声明了 setProperties / swapComponent,实测分别是「not a function」与内部错误)—— 变体取值只能在画布上手工切换;**读得到 ≠ 切得动**;`,s=t?`${U(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${U(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。${o}替代路径:${ic(e,`variants`)}。`,c=n(e);return c===``?s:`${s}${c}`}let r=x.filter(e=>A(e,`variants`)?.fallback!=null),i=x.filter(e=>!r.includes(e));return[`按能力位 ${Ji.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?ic(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function oc(e){if(e==null)return rc(null).map(e=>{let t=ct(e,`setProperties`),n=A(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${U(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=A(e,`components`),n=ct(e,`setProperties`),r=[n==null?`值形态未探测(先读 jsd://platform/state)`:`setProperties 签名收 ${n.join(` / `)}`];return t!=null&&(r.push(t.write.length>0?`写入口:${t.write.join(` / `)}`:`没有可用写入口`),r.push(t.read==null?`读侧无 componentProperties(能力位 ${Ji.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function sc(e){if(e!=null){let t=A(e,`variables`);if(t==null)return`${U(e)}的变量面未登记。`;if(t.write.length>0)return`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。替代路径:${ic(e,`variables`)}`}return`${U(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。替代路径:${ic(e,`variables`)}`}let t=x.filter(e=>(A(e,`variables`)?.write.length??0)>0),n=x.filter(e=>(A(e,`variables`)?.write.length??0)===0&&(A(e,`variables`)?.nativeUnwired.length??0)>0),r=x.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=A(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${U(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function cc(e){if(e==null){let e=x.filter(e=>A(e,`components`)?.read!=null),t=x.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(U).join(` / `)} 读得到;`,`${t.map(U).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return A(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function W(e,t){return{method:`component_op`,outputSchema:nr,payload:t=>({op:e,...t}),...t}}function lc(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`createComponent.description2`}}),W(`create_instance`,{name:`jsd_create_instance`,title:`createInstance.title`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:kr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`createInstance.description`}}),W(`detach_instance`,{name:`jsd_detach_instance`,title:`detachInstance.title`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:Ar,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`detachInstance.description`}}),W(`import_component`,{name:`jsd_import_component`,title:`importComponent.title`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:jr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`importComponent.description`}}),W(`swap_component`,{name:`jsd_swap_component`,title:`swapComponent.title`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:Mr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),W(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读:\`variantProperties\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。**变体属性传名字即可;组件属性(布尔/文本/换绑)必须传读到的完整键**(含 \`#32:0\` 后缀)—— 组件属性在引擎侧只认完整键,短名会报 \`Could not find a component property with name\`(真机实测,TEXT/BOOLEAN/INSTANCE_SWAP 三类都一样);core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选。**写前先读 \`componentPropertyReferences\`**(它标明哪个图层由哪个属性驱动 —— 属性成对存在时只有连着可见层的那一组会改画面,写错那组会「回包成功、画布不动」)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${oc(null)}`,inputSchema:Nr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`setInstanceProperties.description`}}),W(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`combineAsVariants.title`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。${ac(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:Pr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),W(`copy_overrides`,{name:`jsd_copy_overrides`,title:`copyOverrides.title`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:Lr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`copyOverrides.description`}}),W(`apply_overrides`,{name:`jsd_apply_overrides`,title:`applyOverrides.title`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:zr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`applyOverrides.description`}}),W(`sync_overrides`,{name:`jsd_sync_overrides`,title:`syncOverrides.title`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:Br,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>H(r)(e,t,n))}var uc=1.5;function dc(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function fc(e){if(!Array.isArray(e)||e.length<3)return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)return null;t.push(n)}return t}function pc(e,t){let n=t===`x`?`width`:`height`,r=[];for(let i of e){let e=dc(i[t]),a=dc(i[n]);if(e==null||a==null)return null;r.push({start:e,size:a})}r.sort((e,t)=>e.start-t.start);let i=[];for(let e=1;e<r.length;e+=1)i.push(r[e].start-(r[e-1].start+r[e-1].size));return i}function mc(e,t){let n=dc(e[0][t]);return n!=null&&e.every(e=>{let r=dc(e[t]);return r!=null&&Math.abs(r-n)<=uc})}function hc(e){let t=e.layoutMode;if(t===`HORIZONTAL`||t===`VERTICAL`)return null;let n=fc(e.children);if(n==null)return null;let r=mc(n,`x`);if(r===mc(n,`y`))return null;let i=pc(n,r?`y`:`x`);if(i==null||i.length<2)return null;let a=Math.min(...i),o=Math.max(...i);return a<0||o-a>uc?null:{count:n.length,mode:r?`VERTICAL`:`HORIZONTAL`,gap:Math.round(a)}}var gc=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),_c={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},vc=`#f3f4f6`;function yc(e){let t={};if(!e)return t;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&(t[r]=i)}return t}function G(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function bc(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:_c[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function xc(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`margin-top`])??n,r=G(e[`margin-right`])??r,i=G(e[`margin-bottom`])??i,a=G(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function Sc(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`padding-top`])??n,r=G(e[`padding-right`])??r,i=G(e[`padding-bottom`])??i,a=G(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function Cc(e){let t={width:0,color:`#000000`},n=e.border;if(n&&n!==`none`&&n!==`0`){let e=n.match(/([\d.]+)(?:px)?(?:\s+[^ ]+)?\s+(.+)$/);if(e)return{width:parseFloat(e[1])||1,color:bc(e[2])??`#000000`};let t=n.match(/([\d.]+)(?:px)?/);if(t)return{width:parseFloat(t[1]),color:`#000000`}}return e[`border-width`]&&e[`border-width`]!==`0`&&e[`border-width`]!==`none`?{width:G(e[`border-width`])??1,color:bc(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function wc(e){return G(e[`font-size`])??16}function Tc(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function Ec(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Dc(e){return(e.display??``).includes(`flex`)}function Oc(e){return e[`flex-direction`]===`row`?`row`:`column`}function kc(e){return G(e.gap)??G(e[`row-gap`])??0}function Ac(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function jc(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Mc(e){return e.type===`text`?e.data:Ae(e)?e.tagName===`br`?`
|
|
17
|
-
`:e.children.map(
|
|
18
|
-
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>
|
|
19
|
-
`).filter(e=>e.trim()).forEach((e,i)=>{t.push(`<text x="${f.toFixed(1)}" y="${(o+p*i+n).toFixed(1)}" font-size="${n}" font-family="${c}" font-weight="${l}" fill="${r}" text-anchor="${d}">${Bc(e)}</text>`)});return}let l=bc(i.background??i[`background-color`],e.tag===`img`?vc:void 0),u=Cc(i),d=G(i[`border-radius`])??0,f=l&&l!==`none`;if(e.tag===`img`||f||u.width>0){let e=[`x="${a.toFixed(1)}"`,`y="${o.toFixed(1)}"`,`width="${Math.max(0,s).toFixed(1)}"`,`height="${Math.max(0,c).toFixed(1)}"`];d>0&&e.push(`rx="${d}"`),f&&e.push(`fill="${l}"`),u.width>0&&e.push(`stroke="${u.color}" stroke-width="${u.width}"`),t.push(`<rect ${e.join(` `)} />`)}for(let n of e.children)Lc(n),zc(n,t,a,o)}function Bc(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Vc(e){let t=je(e,{decodeEntities:!0}).children.filter(e=>Ae(e)),n=t.find(e=>e.tagName===`body`)??t[0];if(!n)return`<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1" viewBox="0 0 1 1"></svg>`;let r=Pc(n,!0),i=yc(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=Ic(r,a??800),c=a??Math.min(s.width,1600),l=o??s.height;return r.x=0,r.y=0,a??(r.w=c),o??(r.h=l),Rc(r,c,l)}var Hc={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,album:`square-bookmark`,"alert-circle":`circle-alert`,"alert-octagon":`octagon-alert`,"alert-triangle":`triangle-alert`,"align-center":`text-align-center`,"align-justify":`text-align-justify`,"align-left":`text-align-start`,"align-right":`text-align-end`,angry:`face-angry`,annoyed:`face-expressionless`,"area-chart":`chart-area`,"arrow-down-01":`arrow-down-0-1`,"arrow-down-10":`arrow-down-1-0`,"arrow-down-az":`arrow-down-a-z`,"arrow-down-circle":`circle-arrow-down`,"arrow-down-left-from-circle":`circle-arrow-out-down-left`,"arrow-down-left-from-square":`square-arrow-out-down-left`,"arrow-down-left-square":`square-arrow-down-left`,"arrow-down-right-from-circle":`circle-arrow-out-down-right`,"arrow-down-right-from-square":`square-arrow-out-down-right`,"arrow-down-right-square":`square-arrow-down-right`,"arrow-down-square":`square-arrow-down`,"arrow-down-za":`arrow-down-z-a`,"arrow-left-circle":`circle-arrow-left`,"arrow-left-square":`square-arrow-left`,"arrow-right-circle":`circle-arrow-right`,"arrow-right-square":`square-arrow-right`,"arrow-up-01":`arrow-up-0-1`,"arrow-up-10":`arrow-up-1-0`,"arrow-up-az":`arrow-up-a-z`,"arrow-up-circle":`circle-arrow-up`,"arrow-up-left-from-circle":`circle-arrow-out-up-left`,"arrow-up-left-from-square":`square-arrow-out-up-left`,"arrow-up-left-square":`square-arrow-up-left`,"arrow-up-right-from-circle":`circle-arrow-out-up-right`,"arrow-up-right-from-square":`square-arrow-out-up-right`,"arrow-up-right-square":`square-arrow-up-right`,"arrow-up-square":`square-arrow-up`,"arrow-up-za":`arrow-up-z-a`,"asterisk-square":`square-asterisk`,"axis-3-d":`axis-3d`,"badge-help":`badge-question-mark`,"bar-chart":`chart-no-axes-column-increasing`,"bar-chart-2":`chart-no-axes-column`,"bar-chart-3":`chart-column`,"bar-chart-4":`chart-column-increasing`,"bar-chart-big":`chart-column-big`,"bar-chart-horizontal":`chart-bar`,"bar-chart-horizontal-big":`chart-bar-big`,"between-horizonal-end":`between-horizontal-end`,"between-horizonal-start":`between-horizontal-start`,"book-marked":`book-bookmark`,"book-template":`book-dashed`,"box-select":`square-dashed`,"building-2":`building-complex`,"candlestick-chart":`chart-candlestick`,"check-circle":`circle-check-big`,"check-circle-2":`circle-check`,"check-square":`square-check-big`,"check-square-2":`square-check`,"chevron-down-circle":`circle-chevron-down`,"chevron-down-square":`square-chevron-down`,"chevron-left-circle":`circle-chevron-left`,"chevron-left-square":`square-chevron-left`,"chevron-right-circle":`circle-chevron-right`,"chevron-right-square":`square-chevron-right`,"chevron-up-circle":`circle-chevron-up`,"chevron-up-square":`square-chevron-up`,"circle-help":`circle-question-mark`,"circle-slashed":`circle-slash-2`,"clipboard-edit":`clipboard-pen`,"clipboard-signature":`clipboard-pen-line`,"code-2":`code-xml`,"code-square":`square-code`,columns:`columns-2`,"columns-settings":`columns-3-cog`,"contact-2":`contact-round`,"curly-braces":`braces`,"divide-circle":`circle-divide`,"divide-square":`square-divide`,"dot-square":`square-dot`,"download-cloud":`cloud-download`,edit:`square-pen`,"edit-2":`pen`,"edit-3":`pen-line`,"equal-square":`square-equal`,"file-audio":`file-headphone`,"file-audio-2":`file-headphone`,"file-axis-3-d":`file-axis-3d`,"file-badge-2":`file-badge`,"file-bar-chart":`file-chart-column-increasing`,"file-bar-chart-2":`file-chart-column`,"file-check-2":`file-check-corner`,"file-code-2":`file-code-corner`,"file-cog-2":`file-cog`,"file-edit":`file-pen`,"file-json":`file-braces`,"file-json-2":`file-braces-corner`,"file-key-2":`file-key`,"file-line-chart":`file-chart-line`,"file-lock-2":`file-lock`,"file-minus-2":`file-minus-corner`,"file-pie-chart":`file-chart-pie`,"file-plus-2":`file-plus-corner`,"file-question":`file-question-mark`,"file-search-2":`file-search-corner`,"file-signature":`file-pen-line`,"file-type-2":`file-type-corner`,"file-video":`file-play`,"file-video-2":`file-video-camera`,"file-volume-2":`file-signal`,"file-warning":`file-exclamation-point`,"file-x-2":`file-x-corner`,filter:`funnel`,"filter-x":`funnel-x`,fingerprint:`fingerprint-pattern`,"flip-horizontal":`square-centerline-dashed-horizontal`,"flip-horizontal-2":`triangles-centerline-dashed-horizontal`,"flip-vertical":`square-centerline-dashed-vertical`,"flip-vertical-2":`triangles-centerline-dashed-vertical`,"folder-cog-2":`folder-cog`,"folder-edit":`folder-pen`,"fork-knife":`utensils`,"fork-knife-crossed":`utensils-crossed`,"form-input":`rectangle-ellipsis`,frown:`face-slightly-frowning`,"function-square":`square-function`,"gantt-chart":`chart-no-axes-gantt`,"gantt-chart-square":`square-chart-gantt`,"gauge-circle":`circle-gauge`,"git-commit":`git-commit-horizontal`,"globe-2":`earth`,grab:`hand-grab`,grid:`grid-3x3`,"grid-2-x-2":`grid-2x2`,"grid-2-x-2-check":`grid-2x2-check`,"grid-2-x-2-plus":`grid-2x2-plus`,"grid-2-x-2-x":`grid-2x2-x`,"grid-3-x-3":`grid-3x3`,"help-circle":`circle-question-mark`,"helping-hand":`hand-helping`,history:`rotate-ccw-clock`,home:`house`,"ice-cream":`ice-cream-cone`,"ice-cream-2":`ice-cream-bowl`,indent:`list-indent-increase`,"indent-decrease":`list-indent-decrease`,"indent-increase":`list-indent-increase`,inspect:`square-mouse-pointer`,"kanban-square":`square-kanban`,"kanban-square-dashed":`square-dashed-kanban`,"laptop-2":`laptop-minimal`,laugh:`face-grinning`,"layers-3":`layers`,layout:`panels-top-left`,"letter-text":`text-initial`,"library-square":`square-library`,"line-chart":`chart-line`,"loader-2":`loader-circle`,"location-edit":`map-pin-pen`,"m-square":`square-m`,"mail-question":`mail-question-mark`,meh:`face-neutral`,"menu-square":`square-menu`,"message-circle-question":`message-circle-question-mark`,"mic-2":`mic-vocal`,"minus-circle":`circle-minus`,"minus-square":`square-minus`,"more-horizontal":`ellipsis`,"more-vertical":`ellipsis-vertical`,"mouse-pointer-square-dashed":`square-dashed-mouse-pointer`,"move-3-d":`move-3d`,outdent:`list-indent-decrease`,"paintbrush-2":`paintbrush-vertical`,palmtree:`tree-palm`,"panel-bottom-inactive":`panel-bottom-dashed`,"panel-left-inactive":`panel-left-dashed`,"panel-right-inactive":`panel-right-dashed`,"panel-top-inactive":`panel-top-dashed`,"panels-left-right":`columns-3`,"panels-top-bottom":`rows-3`,"parking-circle":`circle-parking`,"parking-circle-off":`circle-parking-off`,"parking-square":`square-parking`,"parking-square-off":`square-parking-off`,"pause-circle":`circle-pause`,"pause-octagon":`octagon-pause`,"pen-box":`square-pen`,"pen-square":`square-pen`,"percent-circle":`circle-percent`,"percent-diamond":`diamond-percent`,"percent-square":`square-percent`,"pi-square":`square-pi`,"pie-chart":`chart-pie`,"pilcrow-square":`square-pilcrow`,"play-circle":`circle-play`,"play-square":`square-play`,"plug-zap-2":`plug-zap`,"plus-circle":`circle-plus`,"plus-square":`square-plus`,podcast:`mic-signal`,"power-circle":`circle-power`,"power-square":`square-power`,"rotate-3-d":`rotate-3d`,rows:`rows-2`,"scale-3-d":`scale-3d`,"scatter-chart":`chart-scatter`,"school-2":`university`,"scissors-square":`square-scissors`,"scissors-square-dashed-bottom":`square-bottom-dashed-scissors`,"send-horizonal":`send-horizontal`,"shield-close":`shield-x`,"shield-question":`shield-question-mark`,sidebar:`panel-left`,"sidebar-close":`panel-left-close`,"sidebar-open":`panel-left-open`,"sigma-square":`square-sigma`,"slash-square":`square-slash`,sliders:`sliders-vertical`,smile:`face-slightly-smiling`,"smile-plus":`face-slightly-smiling-plus`,"sort-asc":`arrow-up-narrow-wide`,"sort-desc":`arrow-down-wide-narrow`,"split-square-horizontal":`square-split-horizontal`,"split-square-vertical":`square-split-vertical`,"square-gantt-chart":`square-chart-gantt`,stars:`sparkles`,"stop-circle":`circle-stop`,subtitles:`captions`,"table-config":`columns-3-cog`,"terminal-square":`square-terminal`,"test-tube-2":`test-tube-diagonal`,text:`text-align-start`,"text-select":`square-dashed-text`,"text-selection":`square-dashed-text`,train:`tram-front`,"trash-2":`trash`,"tv-2":`tv-minimal`,unlock:`lock-open`,"unlock-keyhole":`lock-keyhole-open`,"upload-cloud":`cloud-upload`,"user-2":`user-round`,"user-check-2":`user-round-check`,"user-circle":`circle-user`,"user-circle-2":`circle-user-round`,"user-cog-2":`user-round-cog`,"user-minus-2":`user-round-minus`,"user-plus-2":`user-round-plus`,"user-square":`square-user`,"user-square-2":`square-user-round`,"user-x-2":`user-round-x`,"users-2":`users-round`,verified:`badge-check`,"wallet-2":`wallet-minimal`,"wand-2":`wand-sparkles`,waves:`waves-horizontal`,"wrap-text":`text-wrap`,"x-circle":`circle-x`,"x-octagon":`octagon-x`,"x-square":`square-x`},Uc=e(import.meta.url);function Wc(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Gc=JSON.parse(o(Uc.resolve(`lucide-static/icon-nodes.json`),`utf8`)),Kc=JSON.parse(o(Uc.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Gc))q.set(e,{name:e,nodes:t,keywords:Kc[e]??[]});q.size;var qc=new Map;for(let[e,t]of Object.entries(Kc))t.forEach((t,n)=>{let r=qc.get(t)??[];r.push({name:e,idx:n}),qc.set(t,r)});var Jc=new Me([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Yc(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Xc(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Hc[t];if(r){let e=q.get(r);if(e)return e}let i=Wc(t),a=Jc.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Yc(i,Wc(e.item.name))>=3});if(a.length)return a[0].item;let o=qc.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||Wc(e.name).length-Wc(t.name).length)[0];return q.get(e.name)??null}let s=Jc.search(t,{limit:8}).filter(e=>Yc(i,Wc(e.item.name))>=2)[0];return s?s.item:null}function Zc(e,t=20){let n=e.trim();if(!n)return[];let r=new Map,i=q.get(n);i&&r.set(n,i);let a=Hc[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of qc.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Jc.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function Qc(e,t=24,n=`#000000`,r=2){let i=e.nodes.map(([e,t])=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(`
|
|
15
|
+
Result keys per op (needed to write correct jsd_batch placeholders; a wrong key aborts the batch): select -> selected[and remove -> removed[are id strings; clone/outline_stroke -> created[is an array of nodes; group/flatten -> created is a single node object; ungroup -> ungrouped[is id strings; reparent -> moved[(updated[mirrors it); repair -> cleaned[is id strings.`,"createBooleanOperation.description":`Create a single BOOLEAN_OPERATION node: the booleanOperation mode ({ops}) and children (at least 2 merged child nodes) are required. Only one root boolean node. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"setFillColor.description":`Set fill color/gradient (fills is a Paint array, replaced wholesale rather than merged — pass existing fills you want to keep), blend mode and team-library fill styles. {warn}`,"setText.description":`Modify text (TEXT nodes only): **content and typography** characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, **colour** fills/fillStyleId/blendMode, **size** width/height (pair with textAutoResize), plus Figma truncation and max lines; position x/y is not here — use jsd_move_node / jsd_resize_node. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content — for such text, setting characters again reflows it (measured: a fixed-width-200 text whose height read back 15 re-read 82). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`,"header.more":`More settings`,"menu.telemetry":`Error reporting`,"menu.cameraLock":`Camera lock`,"menu.theme":`Theme`,"menu.locale":`Language`,"telemetry.title":`Error reporting`,"telemetry.body":`To keep improving the product, enabling this records plugin and service errors.`,"telemetry.item.error":`Error messages and stacks`,"telemetry.item.identity":`Anonymous install ID (no document content or personal data)`,"telemetry.item.version":`Plugin and service versions`,"telemetry.state.on":`On`,"telemetry.state.off":`Off`,"telemetry.enable":`Enable reporting`,"telemetry.decline":`Not now`,"telemetry.disable":`Disable reporting`}},Ii=/\{(\w+)\}/g;function Li(e){let t=Fi[e]??Fi.en,n=Fi[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Ii,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Ri=/^zh([-_]|$)/i,zi=/^en([-_]|$)/i;function Bi(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Ri.test(t))return`zh-CN`;if(zi.test(t))return`en`}}var Vi={debug:0,info:1,warn:2,error:3,fatal:4},Hi=[`fatal`,`error`,`warn`];function Ui(e){return Hi.includes(e)}var Wi=[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`,`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_svg`,`jsd_create_icon`,`jsd_set_text`,`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_layout`,`jsd_resize_node`,`jsd_set_effects`,`jsd_delete_node`,`jsd_clone_node`,`jsd_reparent_nodes`,`jsd_create_component`,`jsd_create_instance`,`jsd_set_instance_properties`,`jsd_export`,`jsd_fill_image`,`jsd_batch`],Gi=[`jsd_manage_nodes`,`jsd_manage_components`],Ki={session:[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`],create:[`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_ellipse`,`jsd_create_line`,`jsd_create_polygon`,`jsd_create_star`,`jsd_create_vector`,`jsd_create_group`,`jsd_create_boolean_operation`],nodes:[`jsd_select_nodes`,`jsd_delete_node`,`jsd_clone_node`,`jsd_group_nodes`,`jsd_ungroup_nodes`,`jsd_flatten_nodes`,`jsd_outline_stroke`,`jsd_reparent_nodes`,`jsd_repair_nodes`,`jsd_manage_nodes`],components:[`jsd_create_component`,`jsd_create_instance`,`jsd_detach_instance`,`jsd_import_component`,`jsd_swap_component`,`jsd_set_instance_properties`,`jsd_combine_as_variants`,`jsd_copy_overrides`,`jsd_apply_overrides`,`jsd_sync_overrides`,`jsd_manage_components`],props:[`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_cornerRadius`,`jsd_set_text`,`jsd_move_node`,`jsd_resize_node`,`jsd_set_layout`,`jsd_set_effects`,`jsd_set_visibility`,`jsd_rename_node`,`jsd_set_shape`],media:[`jsd_create_svg`,`jsd_create_icon`,`jsd_html_to_design`,`jsd_export`,`jsd_fill_image`],styles:[`jsd_create_style`,`jsd_delete_style`],guidance:[`jsd_list_prompts`,`jsd_get_prompt`,`jsd_describe_tools`],platform:[`jsd_platform_op`],orchestration:[`jsd_batch`]},qi={"zh-CN":{full:`工具目录为兼容档,公开全部原有工具。`,compact:`工具目录为精简档。未公开的操作先用 jsd_describe_tools 按 group/query 查名称,再按 names 读取完整 schema,最后用 jsd_batch 执行;不要直接调用未公开的工具名。`,title:`查询可用工具与参数`,description:`按 group/query 分页查看内部能力摘要;按 names(最多 3 个)读取完整输入 schema、结果键和风险。未公开工具仅通过 jsd_batch 执行。只读、离线可用;查询不会改变公开目录。`},en:{full:`Compatibility catalog: all original tools are public.`,compact:`Compact catalog: use jsd_describe_tools with group/query to discover names, then names to read full schemas. Execute non-public tools through jsd_batch; do not call their names directly.`,title:`Discover tools and parameters`,description:`Page through capability summaries with group/query; pass names (up to 3) for full input schemas, result keys and risk hints. Execute non-public tools through jsd_batch. Read-only, available offline; discovery never changes the public catalog.`}},Ji={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},Yi=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,O=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,k=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,Xi={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:"两条路,都不是变量那种玩法:① **本地样式** —— `jsd_create_style` 从一个既有节点抄出样式(本平台四类:PAINT / TEXT / EFFECT / GRID;契约的类别是三家 `StyleType` 的八项并集,余下四类本平台没有工厂,传过去会被写前点名拒),回 id;绑上去用 jsd_set_fill_color 的 fillStyleId / jsd_set_text 的 textStyleId / jsd_set_effects 的 effectStyleId / jsd_set_stroke 的 strokeStyleId。**⚠ 本平台未声明 `styleEnumeration`,样式清单(`jsd://styles` / `assets.styles`)恒空、列不出来**:已有样式的 id 只能从正用着它的节点上读(`*StyleId` 字段),新建的 id 从 `jsd_create_style` 回包记账(建重复了用 `jsd_delete_style` 删)。一条样式改一次,全档跟随。② **结构继承** —— 抽成 COMPONENT 后改主件,实例自动继承(批量套覆盖走 variant-sync 配方)。",evidence:[`${Yi}(全文无 variable 声明:grep -in variable 零命中)`,`packages/ui/src/code/jsdesign/meta.ts capabilities=[styles](按 id 应用样式是有的;**不声明 styleEnumeration** —— 列不出样式,见 0043)`,`packages/shared/src/core/access.ts:174(listStylesAsync 在未声明 styleEnumeration 时直接返回空,四个 getter 一次都不调)`,"packages/ui/src/code/jsdesign/host.ts:48(createStyle 已接:`jsd_create_style` 走 jsDesign.createPaintStyle 等四工厂;四类样式的共同契约在 packages/shared/src/core/styles.ts)",`${Yi}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${Yi}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 团队库「组件集」导入入口,本仓只接了组件那半(:110);拿到集合节点是目前唯一的非画布来源`,`Page.createNodeFromJSXAsync(:119) —— JSX 建节点,是否支持组件/集合标签未验(typings 无声明,只有 any)`],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${Yi}:1093 setProperties 只收 string`,`${Yi}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:367-393 setProperties 签名只收字符串;真机 2026-10-14 的运行期行为:给**没有变体属性**的 INSTANCE 调它不是点名报错,而是挂到转发超时(25s)—— 没有变体集时别拿它当切状态的通道`,"packages/shared/src/core/component.ts setInstanceProperties 的属性面守卫 —— 2026-10-19 真机复现同一条(未知属性名 `Foo` → 25077ms 后失败、错误只有「插件响应超时」):能力位不含 componentProperties 且变体表 / variantProperties 都拿不到键时,写前点名拒,不再落到引擎空转","packages/shared/src/core/access.ts resolveMainComponent 的选路 —— 2026-10-19 真机隔离:typings 未声明的 `getMainComponentAsync` 在即时设计运行时**存在且永不 settle**(与 `*Async` 样式枚举同一模式),`?.` 探测让 `jsd_copy_overrides`(只读快照、不写属性)挂到 25109ms;改由 `mainComponentSync` 声明只问同步 `mainComponent`","packages/ui/src/code/jsdesign/ops.ts jsd_component_facts —— 2026-10-20 三页官方文档核对(js.design/developer-doc/plugin/api/node/{ComponentNode,InstanceNode,ComponentSetNode}):**成员与 typings 1.0.12 逐字一致,没有多出来的 API**;文档确认而契约缺的字段(ComponentNode.instances / key / remote / description / expanded / getPublishStatusAsync、InstanceNode.scaleFactor、ComponentSetNode.defaultVariant / variantGroupProperties / children)由本 op 透出。`getPublishStatusAsync` 单独可选:同族 async 成员有永不 settle 的先例(dec e1e66f0a)",`packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 真机(2026-10-20,重载后):COMPONENT 的 instances 可读且准确(建组件+2 实例 → instanceCount 2 / instanceIds 两条)、key 是空串、remote=false;description **可写**且回读一致(PublishableMixin :838);getPublishStatusAsync **21ms 返回、不永挂**(与 getMainComponentAsync 不同),但对非团队库节点回的是**错误串** "Failed to get node publish status" 而不是 PublishStatus 三值 ⇒ op 里三值才认,其余落 publishStatusError`,'packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 的 INSTANCE 分支 + core/assets.ts readVariantProperties —— 真机 2026-10-20 两条:① `variantGroupProperties.values` 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"}]),撞穿 assets.variants.properties 的 string[] 校验使 `get_page` **整条失败**,故 projection 与 op 都按名字归一;② 对真实变体实例调 setProperties **11~15ms 就抛** `in setProperties: i.setProperties is not a function`(typings :1093 与文档都声明了它)⇒ 符号是否真在由 op 的 `setPropertiesAvailable` 回报复核',"packages/ui/src/code/jsdesign/host.ts combineAsVariants 的显式绑定 —— 官方 API 参考页(js.design/developer-doc/plugin/api/reference/jsDesign)确认语义「将任意数量的组件合并为变体」、签名 (nodes, parent, index?);真机 2026-10-20 逐项排除:receiver 绑回全局后报错逐字相同、组件名改成 `状态=默认/禁用` 仍败、带子层仍败、先 reparent 进 FRAME 仍败 ⇒ **引擎实现缺陷,不是调用方式**",`packages/shared/src/core/component.ts combineAsVariantsNodes 的姿势顺序 —— 真机 2026-10-20:合并失败会**毁入参组件**(用户组件 13:100 变损坏节点、repair 直接删),故「原位合并」只在平台声明 inPlaceVariants 时才尝试(Figma 声明、顺序不变);jsDesign 只跑两条克隆姿势,失败也不伤原组件`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**单姿势隔离实验** —— 真机 2026-10-20(即时设计,干净画布,只跑原位姿势,传入真 COMPONENT、类型完全合规):仍抛 in get_booleanOperation: Value is not a string;后果是入参组件 13:332 被就地改成 BOOLEAN_OPERATION、13:333 幸存 ⇒ 坐实引擎实现缺陷,并排除两个替代解释:①「clone 返回 INSTANCE 导致参数类型不符才是根因」(原位传合规类型照样崩);②「被克隆两式弄脏画布才连带失败」(干净画布单跑照样崩)`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**裸调实验** —— 真机 2026-10-20(即时设计,画板 3 下 4 个真 COMPONENT,取消 core 的姿势选择 / clone 类型校验 / 父容器校验 / 跨父级校验 / 返回类型校验,直接 host.combineAsVariants(components, parent)):引擎**成功返回一个 type=BOOLEAN_OPERATION 的节点**(id 13:446),读它的 name 抛 in get_name: Value is not a string;四个原 COMPONENT **被搬进该布尔节点下**(parentId=13:446),画板 3 随即变空 ⇒ 坐实「引擎把合并路由成布尔运算」,并排除「core 的某个前置判断改变了入参」这一解释(裸调无任何判断,行为一致)。事后可用 jsd_reparent_nodes 把组件搬回原容器,损坏节点由 repair 清`,"packages/shared/src/core/access.ts resolveNodes 的返回身份 —— 真机 2026-10-20(即时设计,只读探针,未执行合并):四个 COMPONENT 逐个比对 `=== jsDesign.getNodeById(id)`,**全部 true**(即返回的是原生对象本身,不是包装或代理);成员核验 nodes 各有 createInstance(ComponentNode 独有)、无 setProperties(那是 InstanceNode 的),parent 有 children/appendChild/insertChild 且无 createInstance、且不等于 currentPage ⇒ 入参**完全满足** combineAsVariants(nodes: ReadonlyArray<ComponentNode>, parent: BaseNode & ChildrenMixin) 的签名。故「参数类型不满足」这一解释被排除:类型层面的 `as never` 只是掩盖了静态证明,运行时要传的对象是对的",`packages/shared/src/core/component.ts / jsd_reparent_nodes —— 真机 2026-10-20:RECTANGLE 可 reparent 进 COMPONENT(文档 ComponentNode 继承 BaseFrameMixin → appendChild :711),childCount 0→1,且**两个实例的 childCount 同步变 1**(主件加子层实时传播)`,`packages/shared/src/core/component.ts setInstanceProperties / swapComponents / detachInstanceNodes + packages/shared/src/core/nodes.ts cloneNodes + packages/shared/src/core/variant.ts —— 真机 2026-10-20(即时设计,逐条隔离):① **变体集成员**上 createInstance 必抛 in createInstance: The node with id undefined does not exist(集合内 8 个成员全复现;独立 COMPONENT 正常),clone() 返回 undefined;② swapComponent 必抛 in swapComponent: Cannot read properties of undefined (reading type)(独立组件之间 / 成员之间 / 克隆实例上全复现);③ detachInstance **原位返回同一个 INSTANCE**(type 仍 INSTANCE、mainComponentId 照旧)⇒ 静默 no-op;④ 集合维度键 状态 与成员键 分类1 **不是同一套**,只按集合键校验会把合法的成员键写入拒掉`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 未接;这是「不经画布拿到集合节点」的唯一路径`,`ComponentSetNode.appendChild / insertChild(:711-712,继承自 BaseFrameMixin)—— 类型上能追加成员,但没有创建入口 ⇒ 拿不到集合节点,这一面实际不可达`],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me);实例侧切值本平台运行期无入口(setProperties 不是函数、swapComponent 抛内部错误,真机 2026-10-20),变体取值只能在画布上手工切换`,evidence:[`${Yi}:899-900 VariantMixin.variantProperties(readonly)`,`${Yi}:1074-1079 ComponentSetNode 自身只多 clone / defaultVariant / variantGroupProperties;但 :1074 继承 BaseFrameMixin(:851)→ 带 appendChild / insertChild(:711-712)`,`packages/shared/src/core/variant.ts + core/serialize.ts + core/assets.ts —— 真机 2026-10-20:variantGroupProperties.values 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"},{"name":"禁用"}]),不归一会撞穿线格式 string[] 并让 get_page / jsd_find **整条失败**(不是少字段,是这次只读调用报废);variantProperties 同理。归一实现单点(两个投影点共用),serializeNode 另加一层「getter 抛也省略该字段」的保护`,"packages/ui/src/code/jsdesign/host.ts / core/component.ts combineAsVariants 兜底 —— 真机 2026-10-19 复核(即时设计,重载后):72ms 抛「三种姿势均失败…in get_booleanOperation: Value is not a string」**与 09-24/10-14 逐字一致**;残留形态这次是 **3 个 BOOLEAN_OPERATION(原 COMPONENT 被就地改成 BOOLEAN_OPERATION、id 保留)+ 1 个幸存 COMPONENT,没有 COMPONENT_SET**(10-14 那次是留下畸形 COMPONENT_SET),`assets.variants` 回到 0 ⇒ 残留形态不稳定,清理一律走 `jsd_repair_nodes`(实测 `cleaned: 3 个`)",`${Yi}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${O}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${O}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${O}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${O}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${O}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:11127 readonly componentProperties`,`${O}:11123 setProperties(string | boolean | VariableAlias)`,`${O}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${O}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${O}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${O}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${O}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${O}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${O}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${k}:1522 readonly variables: VariableAPI`,`${k}:1098-1108 VariableAPI(Collection / Mode)`,`${k}:1176 getVariables() / :1874 Variable{id,name,…}`,`${k}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${k}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${k}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/ops.ts removeVariables 的三档 —— 真机 2026-10-19(重载后两轮):单值变量的 deleteVariable **跨执行才生效**(同执行内删两遍 + 回读仍全失败,下一次调用立刻 removed),故同执行回读判失败会把成功报成失败(10-15 那 5 条 failed 即此形态);复合样式变量(PAINT)的 deleteVariable 是 **no-op**(跨多次执行仍在:列表 / assets.variables / 拿它绑图层三面都证明它还活着,同 id 走 jsd_delete_style 一次删掉)`,`packages/ui/src/code/mastergo/ops.ts createVariables 的 values —— 真机 2026-10-19:setVariableValue 的返回 modes **时有时无**(同批里有的带 bool / floatData,有的只有 {modeId},默认双模式集合回空对象);STRING 变量在列表 / 按 id / 写返回三个读面都只有 {modeId} ⇒ 值不可验证,values 只原样透传不作判据`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${k}:3096 readonly componentProperties: Array<ComponentProperties>`,`${k}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${k}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${k}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${k}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${k}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${k}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${k}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${k}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function A(e,t){return e==null?null:Xi[e][t]}var Zi={messageMax:8e3,stackMax:2e4,subjectMax:200,batchMax:50,idMax:100,contextMaxBytes:4096,bodyMaxBytes:262144},Qi={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},$i=`https://registry.npmjs.org`;function ea(e){return`${$i}/${e}/latest`}var ta=4e3;function na(e){let t=e;return t!=null&&t.type===`ui_version`&&typeof t.version==`string`}var j=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function ra(e){return e instanceof j?e.code:`plugin_error`}var ia=process.env.TEXT_TO_DESIGN_MCP_LOG??_(p(),`text-to-design-mcp.log`),aa=Vi,oa=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,sa=null;function ca(e){sa=e}function la(e){if(aa[e.level]>=aa[oa])try{r(ia,`${JSON.stringify({time:new Date().toISOString(),...e})}\n`)}catch{}try{sa?.(e)}catch{}}function M(e){la({level:`info`,scope:`daemon`,message:e})}function N(e){la({level:`debug`,scope:`daemon`,message:e})}function P(e,t){la({level:`warn`,scope:`daemon`,message:e,...t})}function F(e,t){la({level:`error`,scope:`daemon`,message:e,...t})}var ua=Re,da=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??ua,i=n.signal,a=`r${++this.seq}`,o=t&&typeof t==`object`&&`bytes`in t?t.bytes:null,s=o==null?{type:`request`,id:a,method:e,params:t}:{type:`request`,id:a,method:e,params:{...t,hasBinary:!0,bytes:void 0}};return new Promise((t,n)=>{let c=Date.now(),l={id:a,method:e,resolve:t,reject:n,timer:null,waitBinary:!1,binaryCount:0,buffers:[],startedAt:c};if(l.timer=setTimeout(()=>{this.pending.delete(a),this.detachAbort(l),P(`请求超时: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new j(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new j(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(clearTimeout(l.timer),this.detachAbort(l),M(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new j(`cancelled`,`请求已取消: ${e}`)))}},i.addEventListener(`abort`,l.abort.listener,{once:!0})}this.pending.set(a,l),M(`发出请求: ${a} ${e}${o==null?``:` +binary(${o.byteLength}B)`}`),this.sendFn(JSON.stringify(s),o==null?void 0:Buffer.from(o))})}detachAbort(e){e.abort&&=(e.abort.signal.removeEventListener(`abort`,e.abort.listener),void 0)}onText(e){let t;try{t=JSON.parse(e.toString())}catch(t){P(`WS 文本解析失败(${t instanceof Error?t.message:String(t)}): ${e.toString().slice(0,100)}`);return}if(t.type===`request`){t.method===`ping`?(M(`收到 ping 请求: ${t.id} (自动回 pong)`),this.sendFn(JSON.stringify({type:`response`,id:t.id,ok:!0,data:{pong:!0}}))):M(`收到未知请求: ${t.id} ${t.method} (忽略)`);return}if(t.type!==`response`){M(`收到非响应消息: type=${t.type}`);return}let n=this.pending.get(t.id);if(!n){P(`未匹配响应: id=${t.id}(客户端已取消回收,或来源不明)`);return}if(t.hasBinary&&(t.binaryCount??1)>0){if(M(`二进制响应开始: id=${t.id} count=${t.binaryCount??1}`),this.binaryTarget){let e=this.binaryTarget;this.binaryTarget=null,P(`二进制响应被覆盖: 旧 id=${e.id}(${e.buffers.length}/${e.binaryCount} 帧未收齐),新 id=${t.id}`)}n.waitBinary=!0,n.binaryCount=t.binaryCount??1,n.data=t.data,this.binaryTarget=n;return}this.pending.delete(t.id),clearTimeout(n.timer),this.detachAbort(n);let r=`响应: ${n.id} ${n.method} ok=${t.ok} 耗时=${Date.now()-n.startedAt}ms${t.ok?``:` error=${t.error?.code??``}`}`;t.ok?M(r):F(r,{scope:`bridge`,subject:n.method,code:t.error?.code??`plugin_error`}),t.ok?n.resolve(t.data):n.reject(t.error?new j(t.error.code,t.error.message):new j(`plugin_error`,`plugin error`))}onBinary(e){if(!this.binaryTarget){P(`孤儿二进制帧 len=${e.byteLength}(无待组装响应,已丢弃)`);return}if(this.binaryTarget.buffers.push(e),M(`二进制帧: id=${this.binaryTarget.id} ${this.binaryTarget.buffers.length}/${this.binaryTarget.binaryCount}`),this.binaryTarget.buffers.length>=this.binaryTarget.binaryCount){let e=this.binaryTarget;this.binaryTarget=null;let t=e.buffers.reduce((e,t)=>e+t.byteLength,0);M(`二进制组装完成: id=${e.id} ${e.buffers.length} 帧 ${t}B 耗时=${Date.now()-e.startedAt}ms`),this.settle(e)}}rejectAll(e){for(let[,t]of this.pending)clearTimeout(t.timer),this.detachAbort(t),t.reject(new j(`not_connected`,e.message));this.pending.clear()}clear(){for(let[,e]of this.pending)clearTimeout(e.timer),this.detachAbort(e);this.pending.clear(),this.binaryTarget=null}settle(e){this.pending.delete(e.id),clearTimeout(e.timer),this.detachAbort(e),e.resolve(fa(e.data,e.buffers))}};function fa(e,t){let n=t.length===1?t[0]:t;if(!e||typeof e!=`object`)return n;let r=e;if(r.exports&&typeof r.exports==`object`){let e=r.exports,n={};return Object.entries(e).forEach(([e,r],i)=>{n[e]={...r,bytes:t[i]}}),{...r,exports:n}}return{...r,bytes:n}}var pa=`0.13.10`,ma=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),ha=`text-to-design-mcp-server`,L=pa;function ga(e=process.env.TEXT_TO_DESIGN_TOOL_PROFILE){if(e==null||e===``||e===`full`)return`full`;if(e===`compact`)return`compact`;throw Error(`Invalid TEXT_TO_DESIGN_TOOL_PROFILE: ${e}; expected full or compact`)}var _a=Date.now(),va=15e3,ya=6e3,ba=5e3,xa=6e4,Sa=3e5,Ca=Number(process.env.TEXT_TO_DESIGN_RESOURCE_FONTS_TTL_MS??36e5),wa=Number(process.env.TEXT_TO_DESIGN_RESOURCE_DOCUMENT_TTL_MS??3e4),Ta=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),Ea=12e4,Da=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),Oa=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_BATCH_SPILL_BYTES??33554432),ka=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),Aa=(()=>{let e=process.env.TEXT_TO_DESIGN_MCP_MAX_TOOL_INPUT_ELEMENTS;if(e==null||e.trim()===``)return 2e4;if(e.trim().toLowerCase()===`off`)return;let t=Number(e);return Number.isFinite(t)&&t>=1?t:2e4})(),ja={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,Ma=null,Na=null;function Pa(){return R}function Fa(e){Ma=e}function Ia(){return Ma}function La(){let e=R?.platform;if(e==null)return{label:ja.label,runtime:ja.runtime};let t=En[e];return{label:`${t}客户端`,runtime:t}}function Ra(e){(R!=null||Ma!=null)&&(R=null,Ma=null,N(`平台状态已清空(${e})`))}function za(e){return Na??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:ba});if(t?.platform==null){N(`平台探测:回包缺 platform,保持未探测状态(判定 fail-open)`);return}R={platform:t.platform,capabilities:t.capabilities??[],coreCapabilities:t.coreCapabilities??[],platformOps:t.platformOps??[],at:Date.now()},M(`平台状态已缓存: ${En[R.platform]}(平台差异能力 ${R.capabilities.length} 项 / 特有操作 ${R.platformOps.length} 个)`)}catch(e){N(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{Na=null}})(),Na}function Ba(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function Va(e){if(Ba(e)!==!1)return null;let t=R?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>En[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${En[t]},已拒绝执行(未向插件发起请求)。`,e.descriptionSuffix??``,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Ha(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Ua=class{wss=null;http=null;client=null;heartbeat=null;_port=0;takeovers=0;onMessage=null;onConnect=null;onDisconnect=null;get port(){return this._port}async start(e){if(this.http=ne(),this.wss=new re({server:this.http}),this.wss.on(`error`,e=>{P(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),Ie),this.wss.on(`connection`,(e,t)=>this.attach(e,t)),!await this.tryListen(e))throw this.http.close(),Error(`插件 WS 端口 ${e} 已被占用。若确实是残留的 text-to-design-mcp,先 \`curl -X POST http://127.0.0.1:${I}/shutdown\` 收掉它;否则用 \`ss -tlnp | grep ${e}\` 找出占用者`);this._port=e}stop(){this.heartbeat&&clearInterval(this.heartbeat),this.heartbeat=null,this.client=null,this.wss?.close(),this.http?.close()}get isConnected(){return this.client!==null&&this.client.readyState===v.OPEN}send(e){this.client&&this.client.readyState===v.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===v.OPEN&&this.client.send(e)}attach(e,t){let n=`${t.socket.remoteAddress??`?`}:${t.socket.remotePort??`?`}`,r=this.client;r&&r!==e&&(this.takeovers+=1,P(`插件通道被新连接顶替(累计 ${this.takeovers} 次),关闭旧通道`),this.sendStatus(r,`superseded`),r.close(Le,`superseded`)),this.client=e,M(`插件已连接(peer=${n})`);try{this.onConnect?.()}catch(e){M(`onConnect 回调异常: ${e instanceof Error?e.message:String(e)}`)}this.sendStatus(e,`ready`),e.on(`message`,(e,t)=>{let n=Buffer.isBuffer(e)?e:Buffer.from(e);N(`收到 WS 消息 len=${n.length} bin=${t}`),this.onMessage?.(n,t)}),e.on(`close`,(t,r)=>{if(this.client!==e){N(`旧通道关闭(已被顶替),忽略`);return}this.client=null,M(`插件断开: code=${t}${r.length>0?` reason=${r.toString()}`:``} peer=${n} (${Ha(t)})`),this.onDisconnect?.(Error(`plugin disconnected (code=${t})`))}),e.on(`error`,t=>{this.client===e&&(this.client=null,M(`插件通道错误: ${t.message} peer=${n}`),this.onDisconnect?.(Error(`plugin connection error: ${t.message}`)))})}heartbeatTick(){let e=this.client;e&&e.readyState===v.OPEN&&(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==v.OPEN)return;let n={type:`status`,state:t,version:pa};try{e.send(JSON.stringify(n)),N(`已下发状态帧(${t})`)}catch(e){P(`状态帧下发失败(${t}): ${e instanceof Error?e.message:String(e)}`)}}tryListen(e){return new Promise(t=>{let n=()=>{i(),t(!1)},r=()=>{i(),t(!0)},i=()=>{this.http?.off(`error`,n),this.http?.off(`listening`,r)};this.http?.once(`error`,n),this.http?.once(`listening`,r),this.http?.listen(e)})}},Wa=200,Ga=class{transport=new Ua;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;onConsentSet=null;constructor(){this.pending=new da((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{if(t){this.pending.onBinary(e);return}try{let t=JSON.parse(e.toString());if(ze(t)){this.onConsentSet?.(t.granted);return}if(na(t)){Fa(t.version);return}}catch{}this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),this.onPluginConnect?.(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(P(`请求被拒(插件未连接): ${e}`),Promise.reject(new j(`not_connected`,`${La().runtime} 插件未连接。请先在${La().label}中运行该插件。`)))}notifyLog(e){let t={type:`log`,level:e.level,line:e.message,record:e};if(!this.transport.isConnected){this.logRing.length>=Wa&&this.logRing.shift(),this.logRing.push(t);return}this.sendLogPush(t)}pushVersion(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`版本推送失败: ${e instanceof Error?e.message:String(e)}`)}}notifyActivity(e,t){if(!this.transport.isConnected)return;let n=t==null?{type:`activity`,phase:e}:{type:`activity`,phase:e,tool:t};try{this.transport.sendPush(JSON.stringify(n))}catch(e){P(`活动推送失败: ${e instanceof Error?e.message:String(e)}`)}}pushConsent(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`同意状态推送失败: ${e instanceof Error?e.message:String(e)}`)}}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],M(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};function Ka(e){let t=oe(process.execPath,[...process.execArgv,...e??process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});t.unref(),t.on(`error`,e=>{F(`拉起 daemon 失败: ${e.message}`)})}async function qa(){try{let e=await fetch(`http://127.0.0.1:${I}/health`,{signal:AbortSignal.timeout(800)});if(!e.ok)return null;let t=await e.json();return t.name&&t.version?{name:t.name,version:t.version,...typeof t.startedAt==`number`?{startedAt:t.startedAt}:{}}:null}catch{return null}}var Ja=!1;function Ya(){let e=process.env.TEXT_TO_DESIGN_SELF_EXIT_MARKER;if(e!=null&&e.trim()!==``)return e;let t=process.env.XDG_STATE_HOME??_(f(),`.local`,`state`);try{let e=_(t,`text-to-design`);return a(e,{recursive:!0}),_(e,`daemon-self-exit`)}catch{return _(p(),`text-to-design-daemon-self-exit`)}}function Xa(){try{c(Ya(),{force:!0})}catch{}}function Za(){let e=Ya();if(!i(e))return null;let t=Number(o(e,`utf8`).trim());return Number.isFinite(t)?t:null}async function Qa(e={}){let t;if(e.artifactMtime)t=e.artifactMtime();else{let e=process.argv[1];if(!e)return null;try{t=l(e).mtimeMs}catch{return null}}if(t==null)return null;let n=await(e.readHealth??qa)();return n?.startedAt==null||n.startedAt>=t?null:{mtime:t,startedAt:n.startedAt}}async function $a(){if(Ja)return;Ja=!0;let e=await Qa();if(!e)return;let{mtime:t,startedAt:n}=e;P(`常驻 daemon 跑在旧构建上(daemon 启动 ${new Date(n).toISOString()} < 产物 ${new Date(t).toISOString()}),本次代码改动未生效。shim 启动会请它轮换;它自己不退时:curl -X POST http://127.0.0.1:${I}/shutdown`)}async function eo(){let e=await qa();if(e&&e.version!==L){M(`检测到旧版 daemon (${e.version} → ${L}),正在替换...`),await fetch(`http://127.0.0.1:${I}/shutdown`,{method:`POST`}).catch(()=>{});let t=Date.now()+ya;for(;Date.now()<t&&(await to(250),await qa()!==null););return await qa()===null?{state:`none`}:(M(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new ie({name:`text-to-design-proxy`,version:L},{versionNegotiation:{mode:`auto`}});try{await t.connect(new ae(new URL(`http://127.0.0.1:${I}/mcp`)));let{tools:e}=await t.listTools();return e.length===0||!e.every(e=>e.name.startsWith(`jsd_`))?(await t.close(),{state:`foreign`}):{state:`proxy`,client:t}}catch{return await t.close().catch(()=>{}),await qa()===null?{state:`none`}:{state:`starting`}}}function to(e){return new Promise(t=>setTimeout(t,e))}async function no(e={}){let t=Date.now()+va,n=e.first,r=!1;for(;;){let i=n??await eo();if(n=void 0,i.state===`proxy`||i.state===`foreign`)return i;if(i.state===`none`&&e.spawnIfNone===!0&&!r&&(r=!0,Ka(e.argv)),Date.now()>=t)return null;await to(250)}}var ro=3,io=4,ao=240,oo=16,so=8;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function co(e,t){if(!e.startsWith(`#/`))return;let n={$defs:t};for(let t of e.slice(2).split(`/`)){let e=decodeURIComponent(t).replace(/~1/g,`/`).replace(/~0/g,`~`);if(!z(n))return;n=n[e]}return n}function lo(e){let t=e.type;if(typeof t==`string`)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`&&e!==`object`&&e!==`array`);return e.length>0?e.join(`,`):void 0}}function uo(e){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);if(!t.has(e)&&(t.add(e),n.push(r),n.length>=io))break}return n}function fo(e,t,n){if(!z(e))return{};if(typeof e.$ref==`string`){if(t>so)return{};let r=co(e.$ref,n.defs);return r===void 0?{}:fo(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>ao?`${t.slice(0,ao)}…`:t)}let i=lo(e);i!=null&&(r.type=i);for(let i of[`anyOf`,`oneOf`,`allOf`]){let a=e[i];Array.isArray(a)&&a.length>0&&(r[i]=uo(a.map(e=>fo(e,t,n))))}let a=t>=ro&&z(e.properties);if(z(e.items)&&(r.items=a?{}:fo(e.items,t+1,n)),z(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,oo),o={};for(let r of a)o[r]=fo(e.properties[r],t+1,n);if(r.properties=o,t===0&&Array.isArray(e.required)){let t=e.required.filter(e=>typeof e==`string`&&e in o);t.length>0&&(r.required=t)}}return(r.type===`object`||z(r.properties)||z(e.items)&&r.type!==`array`)&&(r.additionalProperties=!0),r}function po(e){if(!z(e))return e;let t=fo(e,0,{defs:z(e.$defs)?e.$defs:{}});return z(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function mo(e){let t=e.properties;if(typeof t!=`object`||!t)return null;for(let e of Object.values(t))if(typeof e==`object`&&e){if(`const`in e&&e.const!=null)return String(e.const);if(Array.isArray(e.enum)&&e.enum.length>0)return String(e.enum[0])}return null}function ho(e){let t=[e.oneOf,e.anyOf].find(e=>Array.isArray(e)&&e.length>0);return t==null?null:t.map((e,t)=>{let n=e??{},r=mo(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function go(e){if(typeof e!=`object`||!e||Array.isArray(e))return JSON.stringify(e)??String(e);let t=Object.keys(e);return t.length>0?`字段 [${t.join(`, `)}]`:`空对象 {}`}function _o(e,t){if(t.oneOf!=null||t.anyOf!=null)return null;let n=t.properties;if(typeof n!=`object`||!n||typeof e!=`object`||!e||Array.isArray(e))return null;let r=new Set(Object.keys(n)),i=Object.keys(e).filter(e=>!r.has(e));return i.length>0?i:null}function vo(e){let t=_e(e)[`~standard`],n=ho(e);return{"~standard":{...t,validate(r){let i=t.validate(r);if(!(`issues`in i))return i;let a=``;if(typeof r==`object`&&r&&!Array.isArray(r)){let e=r.op;typeof e==`string`&&(a=`, op='${e}'`)}let o=i.issues.map(e=>typeof e?.message==`string`?e.message:``).filter(Boolean).join(`; `).slice(0,300),s=n==null?``:`该工具按判别字段分发,可选值: ${n}。`,c=_o(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${go(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function yo(e){let t=Promise.resolve();return()=>{let n=t.catch(()=>{}).then(e);return t=n,n}}function bo(e){let t=e.mcpReq._meta?.progressToken;return{signal:e.mcpReq.signal,timeout:Ea+5e3,...t==null?{}:{onprogress:n=>{e.mcpReq.notify({method:`notifications/progress`,params:{...n,progressToken:t}}).catch(e=>P(`转发进度失败: ${String(e)}`))}}}}function xo(e){if(!e.params?._meta)return e;let{[pe]:t,[ue]:n,[fe]:r,...i}=e.params._meta;return{...e,params:{...e.params,_meta:i}}}function So(e,t,r){let i=t.getServerCapabilities()?.extensions?.[ye];if(i==null)return;let a=n.looseObject({cursor:n.string().optional()}),o=n.looseObject({uri:n.string()}),s=n.looseObject({}),c=(e,t,n)=>r(r=>r.request({method:e,params:t},s,{signal:n}));e.server.setRequestHandler(xe,{params:a},(e,t)=>c(xe,e,t.mcpReq.signal)),e.server.setRequestHandler(be,{params:o},(e,t)=>c(be,e,t.mcpReq.signal)),i.directoryRead===!0&&e.server.setRequestHandler(ve,{params:o.extend({cursor:n.string().optional()})},(e,t)=>c(ve,e,t.mcpReq.signal)),e.server.registerCapabilities({extensions:{[ye]:i}})}var Co=5e5,wo=5e3;function To(e){if(e.length===0)return;let t=e.reduce((e,t)=>e+t.bytes,0),n=e.reduce((e,t)=>t.outputBytes>e.outputBytes?t:e);M(`目录体积: ${e.length} 个工具 / ${(t/1024).toFixed(0)} KB(出参最大 ${n.name} ${(n.outputBytes/1024).toFixed(1)} KB)`);let r=[...t>Co?[`合计 ${(t/1024).toFixed(0)} KB > ${Co/1024} KB`]:[],...e.filter(e=>e.outputBytes>wo).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function Eo(e){let t={};for(let r of e??[]){let e=n.string().describe(r.description??``);t[r.name]=r.required===!0?e:e.optional()}return n.object(t)}function Do(e,t){let n=new le({name:ha,version:L},{supportedProtocolVersions:[`2026-07-28`,...me],...Aa==null?{}:{maxToolInputElements:Aa},...e.getInstructions()?{instructions:e.getInstructions()}:{},cacheHints:{"tools/list":{ttlMs:0,cacheScope:`private`},"prompts/list":{ttlMs:0,cacheScope:`private`},"resources/list":{ttlMs:0,cacheScope:`private`},"resources/templates/list":{ttlMs:0,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}}),r=new Map,i=new Map,a=new Map,o=new Map;function s(e,t,n){let r=new Set;for(let i of t){let t=n.keyOf(i);r.add(t);let a=JSON.stringify(i),o=e.get(t);if(o&&o.raw===a)continue;let s;try{s=n.register(i)}catch(e){P(`${n.kind}注册失败(${t}): ${e instanceof Error?e.message:String(e)}`);continue}o!=null&&(o.handle.remove(),e.delete(t)),e.set(t,{handle:s,raw:a})}for(let[t,n]of[...e])r.has(t)||(n.handle.remove(),e.delete(t))}async function c(){let{tools:e}=await t(e=>e.listTools(void 0,{cacheMode:`refresh`})),i=[],a=n.registerTool.bind(n);s(r,e,{keyOf:e=>e.name,kind:`工具`,register:e=>{let n=e.outputSchema?po(e.outputSchema):void 0,r=JSON.stringify({title:e.title,description:e.description,annotations:e.annotations,icons:e.icons,_meta:e._meta,inputSchema:e.inputSchema,outputSchema:n});i.push({name:e.name,bytes:Buffer.byteLength(r,`utf8`),outputBytes:n===void 0?0:Buffer.byteLength(JSON.stringify(n),`utf8`)});let o={title:e.title,description:e.description,annotations:e.annotations,icons:e.icons,_meta:e._meta,...e.inputSchema?{inputSchema:vo(e.inputSchema)}:{},...n===void 0?{}:{outputSchema:_e(n)}};return a(e.name,o,async(n,r)=>t(t=>t.callTool({name:e.name,arguments:n??{},_meta:r.mcpReq._meta},bo(r)),{replay:e.annotations?.readOnlyHint===!0||e.annotations?.idempotentHint===!0}))}}),To(i)}async function l(){let{prompts:e}=await t(e=>e.listPrompts(void 0,{cacheMode:`refresh`}));s(i,e,{keyOf:e=>e.name,kind:`prompt`,register:e=>n.registerPrompt(e.name,{title:e.title,description:e.description,icons:e.icons,_meta:e._meta,argsSchema:Eo(e.arguments)},(n,r)=>t(t=>t.getPrompt({name:e.name,...n?{arguments:n}:{},_meta:r.mcpReq._meta},bo(r))))})}async function u(){let[{resources:e},{resourceTemplates:r}]=await Promise.all([t(e=>e.listResources(void 0,{cacheMode:`refresh`})),t(e=>e.listResourceTemplates(void 0,{cacheMode:`refresh`}))]);s(a,e,{keyOf:e=>e.uri,kind:`资源`,register:e=>n.registerResource(e.name,e.uri,{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n)=>t(t=>t.readResource({uri:e.href,_meta:n.mcpReq._meta},{...bo(n),cacheMode:`bypass`})))}),s(o,r,{keyOf:e=>String(e.uriTemplate),kind:`资源模板`,register:e=>{let r=String(e.uriTemplate);return n.registerResource(e.name,new de(r,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n,r)=>t(t=>t.readResource({uri:e.href,_meta:r.mcpReq._meta},{...bo(r),cacheMode:`bypass`})))}})}let d=yo(c),f=yo(l),p=yo(u),m=async()=>{let e=await Promise.allSettled([d(),f(),p()]);for(let t of e)t.status===`rejected`&&P(`同步清单失败: ${String(t.reason).slice(0,120)}`)};So(n,e,t),e.getServerCapabilities()?.completions&&(n.server.registerCapabilities({completions:{}}),n.server.setRequestHandler(`completion/complete`,(e,n)=>t(t=>t.complete(e.params,bo(n)))));function h(e){e.setNotificationHandler(`notifications/tools/list_changed`,async e=>{await d(),n.isConnected()&&await n.server.notification(xo(e))}),e.setNotificationHandler(`notifications/prompts/list_changed`,async e=>{await f(),n.isConnected()&&await n.server.notification(xo(e))}),e.setNotificationHandler(`notifications/resources/list_changed`,async e=>{await p(),n.isConnected()&&await n.server.notification(xo(e))}),e.setNotificationHandler(`notifications/resources/updated`,async e=>{n.isConnected()&&await n.server.notification(xo(e))})}return{server:n,syncAll:m,wireNotifications:h}}var Oo=1500,ko=2e4,Ao=6e4,jo=6e5;function Mo(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}async function No(e){let t=e,n=!1,r=null,{server:i,syncAll:a,wireNotifications:o}=Do(e,async(e,r)=>{try{return await e(t)}catch(i){if(n||!Mo(i)||(P(r?.replay===!1?`shim: 上游请求失败,恢复连接但不重放写操作`:`shim: 上游请求失败,触发重连后重放`),await s(),r?.replay===!1))throw i;return e(t)}}),s=()=>r||(r=(async()=>{let e=Date.now()+ko,n=null;for(;Date.now()<e;){try{let e=await eo();if(e.state===`proxy`){let n=t;t=e.client,n.onclose=void 0,await n.close().catch(()=>{}),await c(t),M(`shim: 上游已恢复`),a().catch(e=>P(String(e)));return}e.state===`none`&&Ka()}catch(e){n=e}await to(Oo)}throw n??Error(`上游重连超时(${ko}ms)`)})().finally(()=>{r=null}),r),c=async e=>{if(e.onclose=()=>{n||e!==t||(P(`shim: 上游断开,自动重连`),s().catch(e=>P(String(e))))},o(e),e.getProtocolEra()!==`modern`)return;let r=e.getServerCapabilities(),i={toolsListChanged:r?.tools?.listChanged===!0,promptsListChanged:r?.prompts?.listChanged===!0,resourcesListChanged:r?.resources?.listChanged===!0};if(Object.values(i).some(Boolean))try{(await e.listen(i)).closed.then(async r=>{r===`local`||n||e!==t||(await to(Oo),!n&&e===t&&await s())}).catch(e=>P(String(e)))}catch(e){P(`shim: 目录变更订阅失败,由定期同步兜底: ${String(e)}`)}};await c(t);let l=ce(async()=>(await a(),i)),u=L,d=null,f=null,p=async()=>{let e=await qa();e!=null&&e.version!==u&&(M(`上游版本变化(${u} → ${e.version}),全量重同步目录`),u=e.version,await a())},m=()=>{n||(d=setTimeout(()=>{n||p().finally(m)},Ao),d.unref())},h=()=>{n||(f=setTimeout(()=>{n||a().finally(h)},jo),f.unref())};m(),h(),M(`shim 模式: stdio → 动态同步,共享 daemon`);let g=async()=>{n||(n=!0,d&&clearTimeout(d),f&&clearTimeout(f),await l.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}))};process.stdin.once(`end`,()=>{g()}),process.stdin.once(`close`,()=>{g()}),process.on(`SIGINT`,()=>{g().finally(()=>process.exit(0))})}var Po=_(f(),`.text-to-design`),Fo=_(Po,`consent.json`),Io=!1,Lo=!1;async function Ro(){try{let e=JSON.parse(await De(Fo,`utf8`));Io=e?.granted===!0,Lo=e?.asked===!0}catch{Io=!1,Lo=!1}}function zo(){return Io}function Bo(){return Lo}async function Vo(e){Io=e,Lo=!0;try{await Ee(Po,{recursive:!0}),await ke(Fo,`${JSON.stringify({granted:e,asked:Lo,updatedAt:new Date().toISOString()},null,2)}\n`,`utf8`)}catch(e){P(`同意状态写盘失败: ${e instanceof Error?e.message:String(e)}`)}}var Ho=new WeakMap;function Uo(e){let t=Ho.get(e);return t??(t={profile:`full`,capabilities:new Map,executors:new Map},Ho.set(e,t)),t}function Wo(e,t){if(Uo(e).capabilities.size>0)throw Error(`Tool profile must be configured before registration`);Uo(e).profile=t}function Go(e,t){return Uo(e).profile===`full`?t!==`jsd_describe_tools`:t===`jsd_describe_tools`||Wi.includes(t)}function Ko(e,t,r){let i=Uo(e);if(i.profile===`compact`&&Gi.includes(t.name)||(i.capabilities.set(t.name,t),i.executors.set(t.name,r),!Go(e,t.name)))return{};let{name:a,outputSchema:o,...s}=t,c=o==null?void 0:_e(po(n.toJSONSchema(o)));return e.registerTool.bind(e)(a,{...s,...c==null?{}:{outputSchema:c}},async(...e)=>{let n=t.inputSchema==null?e[0]:e[1];return r(t.inputSchema==null?{}:e[0]??{},n?.mcpReq?.signal??n?.signal)})}function qo(e=process.env.TEXT_TO_DESIGN_LANG){return Bi(e)??`zh-CN`}function Jo(e=qo()){return{locale:e,t:Li(e)}}function B(e){throw Error(e)}var Yo=50;async function Xo(e){let t=e.trim();t===``&&B(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),g(t)||B(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await Oe(t).catch(e=>{B(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||B(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>Da&&B(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(Da/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await De(t,`utf8`).catch(e=>{B(`读 callsFile「${t}」失败:${e instanceof Error?e.message:String(e)}。`)}),i;try{i=JSON.parse(r)}catch(e){B(`callsFile「${t}」不是合法 JSON:${e instanceof Error?e.message:String(e)}。文件内容应为 {"calls":[…]} 或直接一个数组。`)}let a=Array.isArray(i)?{calls:i}:i;(typeof a!=`object`||!a||Array.isArray(i))&&B(`callsFile「${t}」的顶层既不是数组也不是对象。两种合法形状:直接给步骤数组,或给 {"calls":[…]}。`);let o=a.calls;Array.isArray(o)||B(`callsFile「${t}」里没有 calls 数组(实际类型 ${o===void 0?`undefined`:typeof o})。文件内容应为 {"calls":[…]} 或直接一个数组。`),o.length===0&&B(`callsFile「${t}」的 calls 是空数组,没有步骤可执行。`),o.length>Yo&&B(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${Yo} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=Gt.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);B(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return M(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function Zo(e,t={}){let n=new Map;for(let t of e){let e=t.parentId;typeof e==`string`&&e!==``&&n.set(e,(n.get(e)??0)+1)}let r=t.existingChildCount,i=typeof r==`number`&&r>=0?r:0,a=null;for(let[e,t]of n){let n=t+i;n<9||(a==null||n>a.batchCount)&&(a={parentId:e,batchCount:n})}return a}function Qo(e,t,n){let r=n.args.parentId;if(typeof r!=`string`||r===``)return 0;let i=0;for(let a=t+1;a<e.length;a++){let t=e[a];if(t.tool!==n.tool)continue;let o=t.args;typeof o==`object`&&o&&o.parentId===r&&i++}return i}function $o(e){let t=new Set,n=/<g\b[^>]*\bid\s*=\s*["']([^"']+)["']/g;for(;;){let r=n.exec(e);if(r==null)break;t.add(r[1])}return t.size}function es(e){let t=e.def;if(typeof t==`object`&&t)return t;let n=e._def;return typeof n==`object`&&n?n:void 0}function ts(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=es(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function ns(e,n){t.globalRegistry.add(e,{description:n})}function rs(e){let t=[];for(let n of[`innerType`,`element`,`valueType`,`keyType`,`in`,`out`,`catchall`,`rest`]){let r=e[n];typeof r==`object`&&r&&t.push(r)}if(Array.isArray(e.options))for(let n of e.options)typeof n==`object`&&n&&t.push(n);if(Array.isArray(e.items))for(let n of e.items)typeof n==`object`&&n&&t.push(n);if(Array.isArray(e.type))for(let n of e.type)typeof n==`object`&&n&&t.push(n);let n=e.shape;if(typeof n==`object`&&n)for(let e of Object.values(n))typeof e==`object`&&e&&t.push(e);if(typeof e.getter==`function`)try{let n=e.getter();typeof n==`object`&&n&&t.push(n)}catch{}return t}function is(e,t){let n=new Set,r=e=>{if(typeof e!=`object`||!e||n.has(e))return;n.add(e);let i=e;t(i);let a=es(i);if(a!=null)for(let e of rs(a))r(e)};r(e)}function as(e,t){return is(e,e=>{let n=ts(e);if(n==null)return;let r=t(n);r!==n&&ns(e,r)}),e}function os(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function ss(e){return e._def?.typeName}function cs(e,t){return e._def?.[t]}function ls(e,t){return e._def?.[t]}function V(e){switch(ss(e)){case`ZodObject`:{let t=e.shape;if(typeof t!=`function`)return;let n={};for(let[e,r]of Object.entries(t()))n[e]=V(r);return n}case`ZodArray`:return[];case`ZodBoolean`:return!1;case`ZodNumber`:return 0;case`ZodString`:return``;case`ZodLiteral`:return ls(e,`value`);case`ZodEnum`:return ls(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=cs(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=cs(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=ls(e,`options`)??[],n=t.find(e=>ss(e)===`ZodArray`);return n?V(n):t[0]?V(t[0]):void 0}case`ZodLazy`:{let t=e._def?.getter;return t?V(t()):void 0}default:return}}var us={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function ds(e,t,n){let r=ra(e),i=us[r]??n,a={content:[{type:`text`,text:`错误: ${e instanceof Error?e.message:String(e)}`}],isError:!0,code:r};return i!==void 0&&(a.followUp=i),t?{...a,structuredContent:V(t)}:a}function fs(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...os(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:[{type:`text`,text:`错误: 结果未通过本工具的输出校验 —— ${i.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).slice(0,8).join(`; `)}\n原始返回:\n${JSON.stringify(e,null,2)}`}],structuredContent:V(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...os(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}function ps(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function ms(e){return typeof e!=`object`||!e||Array.isArray(e)?null:e}function hs(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function gs(e,t,n,r){return`字段 [${e.slice(0,8).join(`, `)}]${e.length>8?` 等 ${e.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${t.length<=20?`该工具接受: [${t.join(`, `)}]。`:`该工具接受 ${t.length} 个字段(完整清单见其 schema),本次收到的 [${n.join(`, `)}] 里只有上述字段越界。`}原始校验: ${r}`}function _s(e,t,n){let r=ps(e),i=ms(t);if(r==null||i==null)return n;let a=Object.keys(i),o=hs(a,r);return o.length===0?n:gs(o,r,a,n)}var vs=e(import.meta.url);function ys(e){return o(vs.resolve(`lucide-static/icons/${e}.svg`),`utf8`).replace(/<!--[\s\S]*?-->/g,``).replace(/^[\s\S]*?<svg[^>]*>/i,``).replace(/<\/svg>\s*$/i,``).replace(/\s+/g,` `).trim()}function bs(e,t){let n=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${ys(e)}</svg>`;return{src:`data:image/svg+xml;utf8,${encodeURIComponent(n)}`,mimeType:`image/svg+xml`,sizes:[`24x24`]}}var xs={create:`#2563EB`,read:`#64748B`,modify:`#0EA5E9`,structure:`#7C3AED`,component:`#0891B2`,run:`#F59E0B`,output:`#059669`,meta:`#334155`},Ss={create:`square-plus`,read:`search`,modify:`pencil`,structure:`network`,component:`component`,run:`zap`,output:`download`,meta:`plug`,recipe:`book-open`,canvas:`layers`},Cs=new Map;function ws(e){let t=Cs.get(e);if(t!=null)return t;let n=e===`recipe`||e===`canvas`?xs.structure:xs[e],r=[bs(Ss[e],n)];return Cs.set(e,r),r}var Ts={jsd_ping:`meta`,jsd_export:`output`,jsd_batch:`run`},Es=[[`jsd_create_`,`create`],[`jsd_set_`,`modify`],[`jsd_move_`,`modify`],[`jsd_resize_`,`modify`],[`jsd_rename_`,`modify`],[`jsd_fill_`,`modify`],[`jsd_delete_`,`modify`],[`jsd_find`,`read`],[`jsd_get_`,`read`],[`jsd_list_`,`read`],[`jsd_select_`,`read`],[`jsd_group_`,`structure`],[`jsd_ungroup_`,`structure`],[`jsd_reparent_`,`structure`],[`jsd_flatten_`,`structure`],[`jsd_outline_`,`structure`],[`jsd_repair_`,`structure`],[`jsd_combine_`,`component`],[`jsd_swap_`,`component`],[`jsd_detach_`,`component`],[`jsd_apply_`,`component`],[`jsd_copy_`,`component`],[`jsd_sync_`,`component`],[`jsd_import_`,`component`]],Ds=`meta`;function Os(e){let t=Ts[e];if(t!=null)return t;for(let[t,n]of Es)if(e.startsWith(t))return n;return Ds}function ks(e){return ws(Os(e))}function As(){return ws(`recipe`)}function js(){return ws(`canvas`)}function Ms(e,t){return Uo(t).executors.get(e)}function Ns(e){return[...Uo(e).executors.keys()].sort()}function H(e){return(t,n,r)=>{let i=e=>e==null||e.type!==`tool`?e:Go(t,e.tool)?e.description==null?e:{...e,description:r.t(e.description)}:{type:`tool`,tool:`jsd_describe_tools`,description:e.tool},a=(e,t)=>{try{n.notifyActivity(e,t)}catch(e){P(`活动提醒推送失败(已忽略): ${e instanceof Error?e.message:String(e)}`)}},o=async(r,o,s)=>{try{let c=Va(e);if(c!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`,{scope:`tool`,subject:e.name,code:`platform_unsupported`}),ds(new j(`platform_unsupported`,c),e.outputSchema,i(e.followUp));if(e.inputSchema!=null){let t=e.inputSchema.safeParse(r);if(!t.success){let n=t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new j(`invalid_args`,`参数校验失败(${e.name}): ${_s(e.inputSchema,r,n)}`)}r=t.data}let l={...o==null?{}:{signal:o},...e.timeout==null?{}:{timeout:e.timeout}};a(`running`,e.name);let u=s?.skipHooks===!0?void 0:e.hook?.(t);if(u?.before!=null)try{await u.before(r)}catch(t){P(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let d;d=e.run?await e.run(r,n,o??new AbortController().signal):await n.request(e.method,e.payload?e.payload(r):r,l);let f=e.extraContent?e.extraContent(d,r,s):[],p=[],m=d?.warnings;if(Array.isArray(m))for(let e of m)typeof e==`string`&&e!==``&&p.push(e);if(u?.after!=null)try{let e=await u.after(r,d)??[];for(let t of e)p.push(t),f.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;p.push(n),f.push({type:`text`,text:n})}let h=fs(d,e.outputSchema,f.length>0?f:void 0,i(e.followUp));return a(`success`,e.name),p.length>0?{...h,warnings:p}:h}catch(t){let n=t instanceof Error?t.message:String(t);return F(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`,{scope:`tool`,subject:e.name,code:ra(t)}),a(`error`,e.name),ds(t,e.outputSchema,i(e.followUp))}},{t:s}=r;return Ko(t,{name:e.name,title:s(e.title),description:e.descriptionSuffix==null?s(e.description):s(e.description)+s(e.descriptionSuffix),...e.inputSchema==null?{}:{inputSchema:as(e.inputSchema,s)},outputSchema:as(e.outputSchema,s),annotations:e.annotations,icons:e.icons??ks(e.name)},o)}}function Ps(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(Array.isArray(n)&&n.length===1&&(n=n[0]),typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){let t=Number(e[1]);if(!Array.isArray(n)){if(t===0&&typeof n==`object`&&n)continue;return{ok:!1}}n=n[t]}}return{ok:!0,value:n}}var Fs=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}},Is={not_connected:`插件未连接(本次步骤没有发到设计客户端)。先 jsd_ping / 确认面板显示「已连接」再重试。`,plugin_timeout:`请求超时(插件可能仍在执行)。先 jsd_ping 确认连接,再 jsd_find 复核该步是否已落地,别盲目重发。`,platform_unsupported:`当前设计客户端不支持该能力,见下方原始报错里的替代路径。`,invalid_args:`入参不合法,按下方原始报错点名要删/要补的字段后重试。`};function Ls(e,t){let n=e==null?void 0:Is[e],r=t.slice(0,300);return n==null?r:`${n} 原始报错: ${r}`}function Rs(e,t,n){let r=e.indexOf(`.`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r+1);if(!t.has(i)){let r=[...t.keys()].join(`, `)||`无`;throw n.has(i)?new Fs(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=Ps(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var zs=/^@(comp|var):([\s\S]+)$/;function Bs(e,t,n){let r=t.trim(),i=e===`comp`?`组件/变体集`:`变量`,a=n.filter(e=>e.name===r),o=a.length>0?a:n.filter(e=>e.name.trim().toLowerCase()===r.toLowerCase());if(o.length===1)return o[0].id;if(o.length>1)throw Error(`按名字取${i}「${t}」撞上 ${o.length} 个同名资源:${o.map(e=>`${e.name}(${e.id})`).join(`、`)}。名字不唯一时改用 id 直接写,或先重命名(0041:不确定就点名,绝不猜)。`);let s=n.slice(0,30).map(e=>e.name);throw Error(`按名字取${i}「${t}」没命中。${s.length===0?`这一面当前读不到任何${i}(两种原因都可能:本平台未声明该能力面,或本平台读不到非当前页 —— 到底哪种见 jsd_get_page 回包的 note)`:`现有${i}:${s.join(`、`)}${n.length>s.length?` …`:``}`};也可以直接写 id。`)}async function Vs(e,t,n){let r=await n();return Bs(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var Hs=/\{\{\s*([^{}]+?)\s*\}\}/g,Us=/^\{\{\s*([^{}]+?)\s*\}\}$/,Ws=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],Gs=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),Ks=2e4;function qs(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var Js=[`x`,`y`,`width`,`height`,`parentId`];function Ys(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:Js.some(t=>e[t]!==void 0)}function Xs(e){if(Array.isArray(e))return e.map(Xs);if(typeof e!=`object`||!e)return e;let t=e;if(Ys(t)){let e={};for(let n of Ws)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))Gs.has(e)||(n[e]=Xs(r));return n}function Zs(e,t){if(Array.isArray(e)){for(let n of e)Zs(n,t);return}if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e)){if(n===`id`&&typeof r==`string`){t.push(r);continue}Zs(r,t)}}function Qs(e,t){let n=Xs(e),r=qs(n);if(r<=Ks)return{data:n,trimmed:r!==qs(e),omitted:!1};let i=[];return Zs(n,i),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${r} 字符,已省略明细;需要细节请把 ${t} 单独调用一次`,ids:[...new Set(i)]},trimmed:!0,omitted:!0}}function $s(e,t,n){let r=[`回显已裁剪:${e.length} 步(${e.join(` / `)})的节点只保留 id/name/type/x/y/width/height/z/parentId`,` —— 子节点、characters、fills、*StyleId、vectorPaths 等字段不在回显里。`,`要读这些字段,请把对应工具**单独调用一次**;批内回显不是验收证据。`,"占位符 `{{步骤id.…}}` 不受影响,它取的是裁剪前的完整数据。"];return t.length>0&&r.push(n==null?`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,已降级为 id 清单,步骤内的 note 已点名工具名。`:`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,完整明细已落盘到 ${n.path}(${n.bytes} 字节,JSONL 一行一步),按各步 data 里的 line 读即可。`),r.join(``)}var ec=0;function tc(e,t){let n=[],r=new Map;for(let i of e)r.set(i.id,n.length+1),n.push(JSON.stringify(i.ok?{id:i.id,tool:i.tool,ok:!0,data:t.get(i.id)}:{id:i.id,tool:i.tool,ok:!1,error:i.error}));let i=`${n.join(`
|
|
16
|
+
`)}\n`,a=Buffer.byteLength(i,`utf8`);if(a>Oa)return{error:`明细 ${a} 字节 > 上限 ${Oa} 字节`};let o=_(p(),`jsd-batch-${Date.now().toString(36)}-${++ec}.jsonl`);try{d(o,i,`utf8`)}catch(e){return{error:`写盘失败:${e instanceof Error?e.message:String(e)}`}}return{path:o,bytes:a,line:r}}async function nc(e,t,n,r){let i=async e=>{let i=zs.exec(e.trim());return i==null?Rs(e,t,r):Vs(i[1],i[2],n)};if(typeof e==`string`){let t=Us.exec(e.trim());if(t!=null)return i(t[1]);let n=``,r=0;for(let t of e.matchAll(Hs)){n+=e.slice(r,t.index);let a=await i(t[1]);n+=typeof a==`string`?a:JSON.stringify(a),r=(t.index??0)+t[0].length}return r===0?e:n+e.slice(r)}if(Array.isArray(e)){let i=[];for(let a of e)i.push(await nc(a,t,n,r));return i}if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=await nc(o,t,n,r);return i}return e}function rc(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:Kt,outputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:Ea,run:async(t,n,r)=>{let{calls:i,callsFile:a,stopOnError:o,checkDrift:s}=t,c=a==null||a.trim()===``?null:await Xo(a);if(c!=null&&i!=null)throw Error(`calls 与 callsFile 只能给一个:calls 在本批内直接执行,callsFile 从文件读同一份清单。两个都给会让「哪份生效」变成猜。`);if(c==null&&i==null)throw Error(`需要 calls 或 callsFile 其中一个(都缺省时没有步骤可执行)。参数体大到写不进上下文时,把清单写进 JSON 文件、这里只传它的绝对路径。`);let l=c?.calls??i??[],u=c?.stopOnError??o,d=c?.checkDrift??s,f=new Map,p=[],m=!1,h=[],g=[],_=d===!1,ee=[],te,ne=()=>(te??=(async()=>{let e;try{e=await n.request(`get_page`,{},{...r==null?{}:{signal:r}})}catch(e){let t=e instanceof Error?e.message:String(e);throw new j(ra(e),`按名字取资源要先读一次 jsd_get_page,但这次资源清单没读到(${t})—— 这是「资源清单不可得」(插件未连接 / 请求失败),不是「画布上没有这个组件或变量」。先确认插件已连接(jsd_ping)后重试本批,或把要用的 id 直接写进 args。`)}return e?.assets??{}})(),te),v=new Set;for(let t=0;t<l.length;t++){let n=l[t],i=n.id==null||n.id.trim()===``?`step${t+1}`:n.id.trim(),a=e=>{v.add(i),p.push({id:i,tool:n.tool,ok:!1,error:e})};if(f.has(i)||p.some(e=>e.id===i)){a(`步骤 id "${i}" 重复`);break}let o=Ms(n.tool,e);if(o==null){a(`未知工具 ${n.tool},可用: ${Ns(e).join(`, `)}`);break}let s;try{s=await nc(n.args??{},f,ne,v)}catch(e){if(a(e instanceof Error?e.message:String(e)),e instanceof Fs&&(u===!1||n.continueOnError===!0))continue;break}let c=Qo(l,t,{tool:n.tool,args:s}),d=await o(s,r,{skipHooks:_,...c===0?{}:{batch:{siblingSteps:c}}});if(d.isError===!0){let e=d.content?.find(e=>e.type===`text`)?.text??`工具返回错误`;if(a(Ls(d.code,e)),u!==!1&&n.continueOnError!==!0)break;continue}let te=Qs(d.structuredContent,n.tool);te.trimmed&&(m=!0,h.push(i)),te.omitted&&g.push(i),f.set(i,d.structuredContent),d.warnings!=null&&ee.push(...d.warnings),p.push({id:i,tool:n.tool,ok:!0,data:te.data})}let re=p.length===l.length,ie=ee,ae=g.length===0?void 0:tc(p,f),oe=ae!=null&&`error`in ae?void 0:ae;if(ae!=null&&`error`in ae&&ie.push(`本批有 ${g.length} 步回显超预算,但完整明细未落盘(${ae.error});已保留 id 清单,要明细请把对应工具单独调用一次。`),oe!=null)for(let e of p){if(!g.includes(e.id))continue;let t=e.data,n=oe.line.get(e.id);t!=null&&t.echoOmitted===!0&&n!=null&&(e.data={...t,path:oe.path,line:n,note:`本步明细已随整批落盘(第 ${n} 行);也可把 ${e.tool} 单独调用一次。`})}return{ok:re&&p.every(e=>e.ok),executed:p.length,total:l.length,results:p,...m?{echoTrimmed:!0}:{},...m?{echoNote:$s(h,g,oe)}:{},...ie.length>0?{warnings:ie}:{}}}})(e,t,n)]}function ic(e){return e==null?x:[e]}function U(e){return En[e]}function ac(e,t){return A(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function oc(e,t){let n=e=>{let t=e==null?null:A(e,`variants`)?.setLevelOps;return t==null||t.length===0?``:`造新维度/新取值不用绕实例:本平台有集合级管理入口(${t.join(` / `)})—— 先 mg_list_variant_properties 看现状,再建维度/加成分/改取值,每个 op 都写完回读(各自的行为注意写在它的描述里,调用前读一眼);换绑(jsd_set_instance_properties)只负责切到**已有**成分。`};if(e!=null&&t!=null){let r=A(e,`variants`),i=r?.read,a=r?.write.includes(`jsd_set_instance_properties`)===!0,o=i==null?``:a?`文档里**已有**的变体集不受影响:\`${i}\` 与组件集上的维度取值照常读得到,已有取值照常用 jsd_set_instance_properties 切 —— 缺的只是「用脚本造一个新的」;`:`文档里**已有**的变体集读得到:\`${i}\` 与组件集上的维度取值照常可读,但**实例侧切值本平台运行期没有可用入口**(引擎声明了 setProperties / swapComponent,实测分别是「not a function」与内部错误)—— 变体取值只能在画布上手工切换;**读得到 ≠ 切得动**;`,s=t?`${U(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${U(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。${o}替代路径:${ac(e,`variants`)}。`,c=n(e);return c===``?s:`${s}${c}`}let r=x.filter(e=>A(e,`variants`)?.fallback!=null),i=x.filter(e=>!r.includes(e));return[`按能力位 ${Ji.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?ac(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function sc(e){if(e==null)return ic(null).map(e=>{let t=ct(e,`setProperties`),n=A(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${U(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=A(e,`components`),n=ct(e,`setProperties`),r=[n==null?`值形态未探测(先读 jsd://platform/state)`:`setProperties 签名收 ${n.join(` / `)}`];return t!=null&&(r.push(t.write.length>0?`写入口:${t.write.join(` / `)}`:`没有可用写入口`),r.push(t.read==null?`读侧无 componentProperties(能力位 ${Ji.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function cc(e){if(e!=null){let t=A(e,`variables`);if(t==null)return`${U(e)}的变量面未登记。`;if(t.write.length>0)return`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。替代路径:${ac(e,`variables`)}`}return`${U(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。替代路径:${ac(e,`variables`)}`}let t=x.filter(e=>(A(e,`variables`)?.write.length??0)>0),n=x.filter(e=>(A(e,`variables`)?.write.length??0)===0&&(A(e,`variables`)?.nativeUnwired.length??0)>0),r=x.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=A(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${U(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function lc(e){if(e==null){let e=x.filter(e=>A(e,`components`)?.read!=null),t=x.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(U).join(` / `)} 读得到;`,`${t.map(U).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return A(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function W(e,t){return{method:`component_op`,outputSchema:nr,payload:t=>({op:e,...t}),...t}}function uc(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`createComponent.description2`}}),W(`create_instance`,{name:`jsd_create_instance`,title:`createInstance.title`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:kr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`createInstance.description`}}),W(`detach_instance`,{name:`jsd_detach_instance`,title:`detachInstance.title`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:Ar,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`detachInstance.description`}}),W(`import_component`,{name:`jsd_import_component`,title:`importComponent.title`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:jr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`importComponent.description`}}),W(`swap_component`,{name:`jsd_swap_component`,title:`swapComponent.title`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:Mr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),W(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读:\`variantProperties\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。**变体属性传名字即可;组件属性(布尔/文本/换绑)必须传读到的完整键**(含 \`#32:0\` 后缀)—— 组件属性在引擎侧只认完整键,短名会报 \`Could not find a component property with name\`(真机实测,TEXT/BOOLEAN/INSTANCE_SWAP 三类都一样);core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选。**写前先读 \`componentPropertyReferences\`**(它标明哪个图层由哪个属性驱动 —— 属性成对存在时只有连着可见层的那一组会改画面,写错那组会「回包成功、画布不动」)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${sc(null)}`,inputSchema:Nr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`setInstanceProperties.description`}}),W(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`combineAsVariants.title`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。${oc(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:Pr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),W(`copy_overrides`,{name:`jsd_copy_overrides`,title:`copyOverrides.title`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:Lr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`copyOverrides.description`}}),W(`apply_overrides`,{name:`jsd_apply_overrides`,title:`applyOverrides.title`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:zr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`applyOverrides.description`}}),W(`sync_overrides`,{name:`jsd_sync_overrides`,title:`syncOverrides.title`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:Br,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>H(r)(e,t,n))}var dc=1.5;function fc(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function pc(e){if(!Array.isArray(e)||e.length<3)return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)return null;t.push(n)}return t}function mc(e,t){let n=t===`x`?`width`:`height`,r=[];for(let i of e){let e=fc(i[t]),a=fc(i[n]);if(e==null||a==null)return null;r.push({start:e,size:a})}r.sort((e,t)=>e.start-t.start);let i=[];for(let e=1;e<r.length;e+=1)i.push(r[e].start-(r[e-1].start+r[e-1].size));return i}function hc(e,t){let n=fc(e[0][t]);return n!=null&&e.every(e=>{let r=fc(e[t]);return r!=null&&Math.abs(r-n)<=dc})}function gc(e){let t=e.layoutMode;if(t===`HORIZONTAL`||t===`VERTICAL`)return null;let n=pc(e.children);if(n==null)return null;let r=hc(n,`x`);if(r===hc(n,`y`))return null;let i=mc(n,r?`y`:`x`);if(i==null||i.length<2)return null;let a=Math.min(...i),o=Math.max(...i);return a<0||o-a>dc?null:{count:n.length,mode:r?`VERTICAL`:`HORIZONTAL`,gap:Math.round(a)}}var _c=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),vc={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},yc=`#f3f4f6`;function bc(e){let t={};if(!e)return t;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&(t[r]=i)}return t}function G(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function xc(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:vc[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function Sc(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`margin-top`])??n,r=G(e[`margin-right`])??r,i=G(e[`margin-bottom`])??i,a=G(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function Cc(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`padding-top`])??n,r=G(e[`padding-right`])??r,i=G(e[`padding-bottom`])??i,a=G(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function wc(e){let t={width:0,color:`#000000`},n=e.border;if(n&&n!==`none`&&n!==`0`){let e=n.match(/([\d.]+)(?:px)?(?:\s+[^ ]+)?\s+(.+)$/);if(e)return{width:parseFloat(e[1])||1,color:xc(e[2])??`#000000`};let t=n.match(/([\d.]+)(?:px)?/);if(t)return{width:parseFloat(t[1]),color:`#000000`}}return e[`border-width`]&&e[`border-width`]!==`0`&&e[`border-width`]!==`none`?{width:G(e[`border-width`])??1,color:xc(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function Tc(e){return G(e[`font-size`])??16}function Ec(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function Dc(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Oc(e){return(e.display??``).includes(`flex`)}function kc(e){return e[`flex-direction`]===`row`?`row`:`column`}function Ac(e){return G(e.gap)??G(e[`row-gap`])??0}function jc(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function Mc(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Nc(e){return e.type===`text`?e.data:Ae(e)?e.tagName===`br`?`
|
|
17
|
+
`:e.children.map(Nc).join(``):``}function Pc(e){return e.replace(/\s+/g,` `).trim()}function Fc(e,t){let n=bc(e.attribs.style),r={tag:e.tagName,style:n,children:[],isText:!1,x:0,y:0,w:0,h:0};if(e.tagName===`img`)return r.w=K(n,`width`)??120,r.h=K(n,`height`)??120,r;for(let t of e.children){if(t.type===`text`){let e=Pc(t.data);if(!e)continue;let i=r.children[r.children.length-1];i?.isText?i.text=(i.text??``)+e:r.children.push({tag:`#text`,text:e,style:Ic(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}Ae(t)&&(_c.has(t.tagName)||t.tagName!==`br`&&r.children.push(Fc(t,!1)))}if(t&&r.children.length===0){let t=Pc(e.children.map(Nc).join(``));t&&r.children.push({tag:`#text`,text:t,style:Ic(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function Ic(e){let t={};for(let n of[`color`,`font-size`,`font-weight`,`font-family`,`line-height`,`text-align`,`letter-spacing`])e[n]!=null&&(t[n]=e[n]);return t}function Lc(e,t){let n=e.style,r=Cc(n),i=Sc(n),a=wc(n),o=Math.max(0,t-r.left-r.right-a.width*2);if(e.tag===`img`)return e.w=K(n,`width`)??120,e.h=K(n,`height`)??120,{width:e.w+i.left+i.right,height:e.h+i.top+i.bottom};let s=o,c=0;if(e.isText){let t=Tc(n),r=(e.text??``).split(`
|
|
18
|
+
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>Mc(e,t)),t)),e.h=r.length*Dc(n,t),c=e.h}else{let t=Oc(n),i=kc(n),o=Ac(n),l=K(n,`width`),u=K(n,`height`);if(l!=null&&(s=Math.max(0,l-r.left-r.right-a.width*2)),t&&i===`row`){let t=0,n=0;for(let i of e.children){let e=Lc(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&jc(i.style)!==`left`&&(i.w=s-t),t+=e.width,t+=o,n=Math.max(n,e.height)}c=n,e.w=t-(e.children.length?o:0)}else{let t=0,n=0;for(let i of e.children){let e=Lc(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&jc(i.style)!==`left`&&(i.w=s),t+=e.height,t+=o,n=Math.max(n,e.width)}c=t-(e.children.length?o:0),e.w=n}e.w=l??e.w,e.h=u??c,c=u??c}let l=r.left+r.right+a.width*2,u=r.top+r.bottom+a.width*2;return K(n,`width`)??(e.w+=l),K(n,`height`)==null&&!e.isText&&(e.h+=u),{width:e.w+i.left+i.right,height:e.h+i.top+i.bottom}}function Rc(e){let t=Sc(e.style);e.x+=t.left,e.y+=t.top}function zc(e,t,n){let r=[];return Bc(e,r,0,0),`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}">${r.join(``)}</svg>`}function Bc(e,t,n,r){let i=e.style,a=n+e.x,o=r+e.y,s=e.w,c=e.h;if(e.isText){let n=Tc(i),r=xc(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=Ec(i),u=jc(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=Dc(i,n);(e.text??``).split(`
|
|
19
|
+
`).filter(e=>e.trim()).forEach((e,i)=>{t.push(`<text x="${f.toFixed(1)}" y="${(o+p*i+n).toFixed(1)}" font-size="${n}" font-family="${c}" font-weight="${l}" fill="${r}" text-anchor="${d}">${Vc(e)}</text>`)});return}let l=xc(i.background??i[`background-color`],e.tag===`img`?yc:void 0),u=wc(i),d=G(i[`border-radius`])??0,f=l&&l!==`none`;if(e.tag===`img`||f||u.width>0){let e=[`x="${a.toFixed(1)}"`,`y="${o.toFixed(1)}"`,`width="${Math.max(0,s).toFixed(1)}"`,`height="${Math.max(0,c).toFixed(1)}"`];d>0&&e.push(`rx="${d}"`),f&&e.push(`fill="${l}"`),u.width>0&&e.push(`stroke="${u.color}" stroke-width="${u.width}"`),t.push(`<rect ${e.join(` `)} />`)}for(let n of e.children)Rc(n),Bc(n,t,a,o)}function Vc(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Hc(e){let t=je(e,{decodeEntities:!0}).children.filter(e=>Ae(e)),n=t.find(e=>e.tagName===`body`)??t[0];if(!n)return`<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1" viewBox="0 0 1 1"></svg>`;let r=Fc(n,!0),i=bc(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=Lc(r,a??800),c=a??Math.min(s.width,1600),l=o??s.height;return r.x=0,r.y=0,a??(r.w=c),o??(r.h=l),zc(r,c,l)}var Uc={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,album:`square-bookmark`,"alert-circle":`circle-alert`,"alert-octagon":`octagon-alert`,"alert-triangle":`triangle-alert`,"align-center":`text-align-center`,"align-justify":`text-align-justify`,"align-left":`text-align-start`,"align-right":`text-align-end`,angry:`face-angry`,annoyed:`face-expressionless`,"area-chart":`chart-area`,"arrow-down-01":`arrow-down-0-1`,"arrow-down-10":`arrow-down-1-0`,"arrow-down-az":`arrow-down-a-z`,"arrow-down-circle":`circle-arrow-down`,"arrow-down-left-from-circle":`circle-arrow-out-down-left`,"arrow-down-left-from-square":`square-arrow-out-down-left`,"arrow-down-left-square":`square-arrow-down-left`,"arrow-down-right-from-circle":`circle-arrow-out-down-right`,"arrow-down-right-from-square":`square-arrow-out-down-right`,"arrow-down-right-square":`square-arrow-down-right`,"arrow-down-square":`square-arrow-down`,"arrow-down-za":`arrow-down-z-a`,"arrow-left-circle":`circle-arrow-left`,"arrow-left-square":`square-arrow-left`,"arrow-right-circle":`circle-arrow-right`,"arrow-right-square":`square-arrow-right`,"arrow-up-01":`arrow-up-0-1`,"arrow-up-10":`arrow-up-1-0`,"arrow-up-az":`arrow-up-a-z`,"arrow-up-circle":`circle-arrow-up`,"arrow-up-left-from-circle":`circle-arrow-out-up-left`,"arrow-up-left-from-square":`square-arrow-out-up-left`,"arrow-up-left-square":`square-arrow-up-left`,"arrow-up-right-from-circle":`circle-arrow-out-up-right`,"arrow-up-right-from-square":`square-arrow-out-up-right`,"arrow-up-right-square":`square-arrow-up-right`,"arrow-up-square":`square-arrow-up`,"arrow-up-za":`arrow-up-z-a`,"asterisk-square":`square-asterisk`,"axis-3-d":`axis-3d`,"badge-help":`badge-question-mark`,"bar-chart":`chart-no-axes-column-increasing`,"bar-chart-2":`chart-no-axes-column`,"bar-chart-3":`chart-column`,"bar-chart-4":`chart-column-increasing`,"bar-chart-big":`chart-column-big`,"bar-chart-horizontal":`chart-bar`,"bar-chart-horizontal-big":`chart-bar-big`,"between-horizonal-end":`between-horizontal-end`,"between-horizonal-start":`between-horizontal-start`,"book-marked":`book-bookmark`,"book-template":`book-dashed`,"box-select":`square-dashed`,"building-2":`building-complex`,"candlestick-chart":`chart-candlestick`,"check-circle":`circle-check-big`,"check-circle-2":`circle-check`,"check-square":`square-check-big`,"check-square-2":`square-check`,"chevron-down-circle":`circle-chevron-down`,"chevron-down-square":`square-chevron-down`,"chevron-left-circle":`circle-chevron-left`,"chevron-left-square":`square-chevron-left`,"chevron-right-circle":`circle-chevron-right`,"chevron-right-square":`square-chevron-right`,"chevron-up-circle":`circle-chevron-up`,"chevron-up-square":`square-chevron-up`,"circle-help":`circle-question-mark`,"circle-slashed":`circle-slash-2`,"clipboard-edit":`clipboard-pen`,"clipboard-signature":`clipboard-pen-line`,"code-2":`code-xml`,"code-square":`square-code`,columns:`columns-2`,"columns-settings":`columns-3-cog`,"contact-2":`contact-round`,"curly-braces":`braces`,"divide-circle":`circle-divide`,"divide-square":`square-divide`,"dot-square":`square-dot`,"download-cloud":`cloud-download`,edit:`square-pen`,"edit-2":`pen`,"edit-3":`pen-line`,"equal-square":`square-equal`,"file-audio":`file-headphone`,"file-audio-2":`file-headphone`,"file-axis-3-d":`file-axis-3d`,"file-badge-2":`file-badge`,"file-bar-chart":`file-chart-column-increasing`,"file-bar-chart-2":`file-chart-column`,"file-check-2":`file-check-corner`,"file-code-2":`file-code-corner`,"file-cog-2":`file-cog`,"file-edit":`file-pen`,"file-json":`file-braces`,"file-json-2":`file-braces-corner`,"file-key-2":`file-key`,"file-line-chart":`file-chart-line`,"file-lock-2":`file-lock`,"file-minus-2":`file-minus-corner`,"file-pie-chart":`file-chart-pie`,"file-plus-2":`file-plus-corner`,"file-question":`file-question-mark`,"file-search-2":`file-search-corner`,"file-signature":`file-pen-line`,"file-type-2":`file-type-corner`,"file-video":`file-play`,"file-video-2":`file-video-camera`,"file-volume-2":`file-signal`,"file-warning":`file-exclamation-point`,"file-x-2":`file-x-corner`,filter:`funnel`,"filter-x":`funnel-x`,fingerprint:`fingerprint-pattern`,"flip-horizontal":`square-centerline-dashed-horizontal`,"flip-horizontal-2":`triangles-centerline-dashed-horizontal`,"flip-vertical":`square-centerline-dashed-vertical`,"flip-vertical-2":`triangles-centerline-dashed-vertical`,"folder-cog-2":`folder-cog`,"folder-edit":`folder-pen`,"fork-knife":`utensils`,"fork-knife-crossed":`utensils-crossed`,"form-input":`rectangle-ellipsis`,frown:`face-slightly-frowning`,"function-square":`square-function`,"gantt-chart":`chart-no-axes-gantt`,"gantt-chart-square":`square-chart-gantt`,"gauge-circle":`circle-gauge`,"git-commit":`git-commit-horizontal`,"globe-2":`earth`,grab:`hand-grab`,grid:`grid-3x3`,"grid-2-x-2":`grid-2x2`,"grid-2-x-2-check":`grid-2x2-check`,"grid-2-x-2-plus":`grid-2x2-plus`,"grid-2-x-2-x":`grid-2x2-x`,"grid-3-x-3":`grid-3x3`,"help-circle":`circle-question-mark`,"helping-hand":`hand-helping`,history:`rotate-ccw-clock`,home:`house`,"ice-cream":`ice-cream-cone`,"ice-cream-2":`ice-cream-bowl`,indent:`list-indent-increase`,"indent-decrease":`list-indent-decrease`,"indent-increase":`list-indent-increase`,inspect:`square-mouse-pointer`,"kanban-square":`square-kanban`,"kanban-square-dashed":`square-dashed-kanban`,"laptop-2":`laptop-minimal`,laugh:`face-grinning`,"layers-3":`layers`,layout:`panels-top-left`,"letter-text":`text-initial`,"library-square":`square-library`,"line-chart":`chart-line`,"loader-2":`loader-circle`,"location-edit":`map-pin-pen`,"m-square":`square-m`,"mail-question":`mail-question-mark`,meh:`face-neutral`,"menu-square":`square-menu`,"message-circle-question":`message-circle-question-mark`,"mic-2":`mic-vocal`,"minus-circle":`circle-minus`,"minus-square":`square-minus`,"more-horizontal":`ellipsis`,"more-vertical":`ellipsis-vertical`,"mouse-pointer-square-dashed":`square-dashed-mouse-pointer`,"move-3-d":`move-3d`,outdent:`list-indent-decrease`,"paintbrush-2":`paintbrush-vertical`,palmtree:`tree-palm`,"panel-bottom-inactive":`panel-bottom-dashed`,"panel-left-inactive":`panel-left-dashed`,"panel-right-inactive":`panel-right-dashed`,"panel-top-inactive":`panel-top-dashed`,"panels-left-right":`columns-3`,"panels-top-bottom":`rows-3`,"parking-circle":`circle-parking`,"parking-circle-off":`circle-parking-off`,"parking-square":`square-parking`,"parking-square-off":`square-parking-off`,"pause-circle":`circle-pause`,"pause-octagon":`octagon-pause`,"pen-box":`square-pen`,"pen-square":`square-pen`,"percent-circle":`circle-percent`,"percent-diamond":`diamond-percent`,"percent-square":`square-percent`,"pi-square":`square-pi`,"pie-chart":`chart-pie`,"pilcrow-square":`square-pilcrow`,"play-circle":`circle-play`,"play-square":`square-play`,"plug-zap-2":`plug-zap`,"plus-circle":`circle-plus`,"plus-square":`square-plus`,podcast:`mic-signal`,"power-circle":`circle-power`,"power-square":`square-power`,"rotate-3-d":`rotate-3d`,rows:`rows-2`,"scale-3-d":`scale-3d`,"scatter-chart":`chart-scatter`,"school-2":`university`,"scissors-square":`square-scissors`,"scissors-square-dashed-bottom":`square-bottom-dashed-scissors`,"send-horizonal":`send-horizontal`,"shield-close":`shield-x`,"shield-question":`shield-question-mark`,sidebar:`panel-left`,"sidebar-close":`panel-left-close`,"sidebar-open":`panel-left-open`,"sigma-square":`square-sigma`,"slash-square":`square-slash`,sliders:`sliders-vertical`,smile:`face-slightly-smiling`,"smile-plus":`face-slightly-smiling-plus`,"sort-asc":`arrow-up-narrow-wide`,"sort-desc":`arrow-down-wide-narrow`,"split-square-horizontal":`square-split-horizontal`,"split-square-vertical":`square-split-vertical`,"square-gantt-chart":`square-chart-gantt`,stars:`sparkles`,"stop-circle":`circle-stop`,subtitles:`captions`,"table-config":`columns-3-cog`,"terminal-square":`square-terminal`,"test-tube-2":`test-tube-diagonal`,text:`text-align-start`,"text-select":`square-dashed-text`,"text-selection":`square-dashed-text`,train:`tram-front`,"trash-2":`trash`,"tv-2":`tv-minimal`,unlock:`lock-open`,"unlock-keyhole":`lock-keyhole-open`,"upload-cloud":`cloud-upload`,"user-2":`user-round`,"user-check-2":`user-round-check`,"user-circle":`circle-user`,"user-circle-2":`circle-user-round`,"user-cog-2":`user-round-cog`,"user-minus-2":`user-round-minus`,"user-plus-2":`user-round-plus`,"user-square":`square-user`,"user-square-2":`square-user-round`,"user-x-2":`user-round-x`,"users-2":`users-round`,verified:`badge-check`,"wallet-2":`wallet-minimal`,"wand-2":`wand-sparkles`,waves:`waves-horizontal`,"wrap-text":`text-wrap`,"x-circle":`circle-x`,"x-octagon":`octagon-x`,"x-square":`square-x`},Wc=e(import.meta.url);function Gc(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Kc=JSON.parse(o(Wc.resolve(`lucide-static/icon-nodes.json`),`utf8`)),qc=JSON.parse(o(Wc.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Kc))q.set(e,{name:e,nodes:t,keywords:qc[e]??[]});q.size;var Jc=new Map;for(let[e,t]of Object.entries(qc))t.forEach((t,n)=>{let r=Jc.get(t)??[];r.push({name:e,idx:n}),Jc.set(t,r)});var Yc=new Me([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Xc(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Zc(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Uc[t];if(r){let e=q.get(r);if(e)return e}let i=Gc(t),a=Yc.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Xc(i,Gc(e.item.name))>=3});if(a.length)return a[0].item;let o=Jc.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||Gc(e.name).length-Gc(t.name).length)[0];return q.get(e.name)??null}let s=Yc.search(t,{limit:8}).filter(e=>Xc(i,Gc(e.item.name))>=2)[0];return s?s.item:null}function Qc(e,t=20){let n=e.trim();if(!n)return[];let r=new Map,i=q.get(n);i&&r.set(n,i);let a=Uc[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of Jc.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Yc.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function $c(e,t=24,n=`#000000`,r=2){let i=e.nodes.map(([e,t])=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(`
|
|
20
20
|
`);return[`<svg xmlns="http://www.w3.org/2000/svg"`,` width="${t}" height="${t}" viewBox="0 0 24 24"`,` fill="none" stroke="${n}" stroke-width="${r}"`,` stroke-linecap="round" stroke-linejoin="round">`,` ${i}`,`</svg>`].join(`
|
|
21
|
-
`)}var $c={FRAME:cn,RECTANGLE:ln,ELLIPSE:un,LINE:dn,POLYGON:fn,STAR:pn,VECTOR:mn,TEXT:hn,GROUP:gn,BOOLEAN_OPERATION:_n};function el(e){let t={...$c[e].shape,type:n.literal(e).optional()};return n.object({...t,placement:bn.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:el(e),outputSchema:Jn,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var Y={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function tl(e,t,n){let r=[J(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,extraContent:(e,t)=>{let r=hc(t);return r==null?[]:[{type:`text`,text:n.t(`layoutHint.uniform`,r)}]},followUp:Y}),J(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:Y}),J(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:Y}),J(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:Y}),J(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:Y}),J(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:Y}),J(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:Y}),J(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],descriptionSuffix:`(MasterGo 的矢量节点是 PenNode,路径为 penNetwork 顶点模型,与本工具的 vectorPaths(SVG path data)不同形;该平台暂不支持建矢量)`,followUp:Y}),J(`GROUP`,{name:`jsd_create_group`,title:`createGroup.title`,description:`createGroup.description`,followUp:Y}),J(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`createBooleanOperation.title`,description:n.t(`createBooleanOperation.description`,{ops:dt}),followUp:Y})],i=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:xn,outputSchema:Jn,extraContent:(e,t)=>{let{svg:r,svgPath:i}=t,a=r??``;if(a.trim()===``&&i!=null&&i.trim()!==``)try{a=o(i,`utf8`)}catch{return[]}if(a.trim()===``)return[];let s=Zo(a);return s>0?[]:[{type:`text`,text:n.t(`structureHint.svgNoGroups`,{groupCount:s})}]},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:xa,run:async(e,t,n)=>{let{svg:r,svgPath:i,name:a}=e,s;if(i!=null&&i.trim()!==``)try{s=o(i,`utf8`)}catch(e){throw Error(`读取 SVG 文件失败(${i}): ${e instanceof Error?e.message:String(e)}`)}else s=r??``;if(s.trim()===``)throw Error(i==null?`svg 为空字符串;要导入本地文件请改用 svgPath`:`SVG 文件是空的:${i}(脚本可能没写成功,或写到了另一个路径)`);if(s.length>ka)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${ka}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:a??`svg-design`},{signal:n,timeout:xa})},followUp:Y}),a=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Cn,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=Xc(r);if(!c){let e=Zc(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=Qc(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:Y}),s=H({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:Sn,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=Vc(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:Y});return[...r.map(r=>H(r)(e,t,n)),i(e,t,n),a(e,t,n),s(e,t,n)]}var nl=n.object({group:n.string().optional().describe(`Category: ${Object.keys(Ki).join(`, `)}`),query:n.string().max(200).optional().describe(`Name, title or description substring; spaces separate search terms`),names:n.array(n.string().min(1)).min(1).max(3).optional().describe(`Exact names to inspect full schemas, up to 3`),offset:n.number().int().min(0).default(0),limit:n.number().int().min(1).max(20).default(10)}).strict().refine(e=>e.names==null||e.group==null&&e.query==null&&e.offset===0,`names cannot be combined with group, query or offset`);function rl(e,t,r){let i=qi[r.locale];return[Wo(e,{name:`jsd_describe_tools`,title:i.title,description:i.description,inputSchema:nl,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},icons:ks()},async t=>{try{let r=nl.parse(t),i=Vo(e);if(r.group!=null&&!Object.hasOwn(Ki,r.group))throw Error(`Unknown group: ${r.group}`);let a=(r.query??``).trim().toLowerCase().split(/\s+/).filter(Boolean),o=[...i.capabilities.values()].sort((e,t)=>e.name.localeCompare(t.name)),s=r.names==null?o.filter(e=>(r.group==null||Ki[r.group]?.includes(e.name))&&a.every(t=>`${e.name} ${e.title??``} ${e.description??``}`.toLowerCase().includes(t))):r.names.map(e=>{let t=i.capabilities.get(e);if(t==null)throw Error(`Unknown tool: ${e}`);return t}),c=(r.names==null?s.slice(r.offset,r.offset+r.limit):s).map(t=>({name:t.name,title:t.title,description:r.names==null?t.description?.slice(0,240):t.description,annotations:t.annotations,public:Uo(e,t.name),execution:Uo(e,t.name)?`direct-or-batch`:`batch`,...r.names==null?{}:{inputSchema:t.inputSchema==null?{type:`object`,properties:{}}:n.toJSONSchema(t.inputSchema),outputSchema:t.outputSchema==null?void 0:uo(n.toJSONSchema(t.outputSchema))}})),l={profile:i.profile,groups:Object.keys(Ki),total:s.length,nextOffset:r.names==null&&r.offset+c.length<s.length?r.offset+c.length:null,tools:c};return{content:[{type:`text`,text:JSON.stringify(l)}],structuredContent:l}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}var il=`(page)`,al=8,ol=200,sl=5,cl=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function ll(e){return e.op===`reparent`}function ul(e,t){if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e)){if(n===`ids`&&Array.isArray(r)){for(let e of r)typeof e==`string`&&e!==``&&t.add(e);continue}(n===`parentId`||n===`nodeId`||n===`componentId`)&&typeof r==`string`&&r!==``&&t.add(r)}}function dl(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function fl(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.id!=`string`||typeof t.x!=`number`||typeof t.y!=`number`?null:{id:t.id,name:typeof t.name==`string`?t.name:t.id,x:t.x,y:t.y}}async function pl(e,t,n){let r=js(t,e);if(r==null)return null;let i=await r(n,void 0);if(i?.isError===!0)return null;let a=i?.structuredContent;return typeof a==`object`&&a?a:null}async function ml(e,t){let n=new Map;if(t===il){let t=await pl(e,`jsd_get_page`,{});if(t==null)return null;for(let e of dl(t.nodes).slice(0,ol)){let t=fl(e);t!=null&&n.set(t.id,t)}return n}let r=await pl(e,`jsd_find`,{ids:[t],depth:1});if(r==null)return null;let i=dl(r.nodes)[0];if(i==null)return null;for(let e of dl(i.children).slice(0,ol)){let t=fl(e);t!=null&&n.set(t.id,t)}return n}var hl=class{server;operation;constructor(e,t){this.server=e,this.operation=t}snapshots=new Map;dead=new Set;engaged=!1;async before(e){let t=this.operation??e.op;if(t===void 0||cl.has(String(t))){this.engaged=!0;try{let t=new Set;if(ul(e,t),t.size===0)return;let n=await pl(this.server,`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of dl(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}(this.operation===`reparent`||ll(e))&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(il);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=al){this.dead.add(e);continue}let t=await ml(this.server,e);if(t==null){this.dead.add(e);continue}this.snapshots.set(e,t)}}catch{}}}async after(){if(!this.engaged)return[];let e=[];for(let[t,n]of this.snapshots)try{let r=await ml(this.server,t);if(r==null)continue;let i=[];for(let[e,t]of n){let n=r.get(e);n!=null&&(n.x!==t.x||n.y!==t.y)&&i.push({from:t,to:n})}if(i.length===0)continue;let a=i.slice(0,sl).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>sl?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===il?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},gl=e=>new hl(e),_l=e=>t=>new hl(t,e);function vl(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Bn,outputSchema:$n,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:gl,followUp:{type:`tool`,tool:`jsd_set_layout`,description:`manageNodes.followUp`}}),i=H({name:`jsd_manage_components`,title:`manageComponents.title`,description:`manageComponents.description`,method:`component_op`,inputSchema:Vn,outputSchema:nr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`manageComponents.description2`}});return[r(e,t,n),i(e,t,n)]}function yl(e,t,n){return[H({name:`jsd_find`,title:`find.title`,description:'在当前页面查找节点:ids 精确匹配优先,name 模糊,type 过滤;返回序列化节点列表(最多 100 条)。scope:"document" 跨页全文档查找(触发一次全量页加载,大文档有一次性成本,结果 note 点名;默认 page 只查当前页)。⚠ 每个节点带 `z` = 它在父级 children 里的下标 = **绘制顺序**(0 = 最底层,越大越靠上);判断遮挡/层序读 z 即可,children 数组顺序与 z 一致。大区域查询先 depth:0 拿节点清单,再按 ids/name 定向小范围查,避免大响应被截断丢尾部节点 id',method:`find`,inputSchema:Rn,outputSchema:Qn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function X(e,t){return{method:`node_op`,outputSchema:$n,payload:t=>({op:e,...t}),...cl.has(e)?{tags:[`structural`],hook:_l(e)}:{},...t}}function bl(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:yr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`selectNodes.description`}}),X(`remove`,{name:`jsd_delete_node`,title:`deleteNode.title`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:br,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),X(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:xr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),X(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:Sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),X(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],descriptionSuffix:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:Cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),X(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:wr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`flattenNodes.description`}}),X(`outline_stroke`,{name:`jsd_outline_stroke`,title:`outlineStroke.title`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:Tr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),X(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,extraContent:(e,t,r)=>{let i=t.parentId,a=Yo(Array.from({length:1+(r?.batch?.siblingSteps??0)},()=>({parentId:i})));return a==null?[]:[{type:`text`,text:n.t(`structureHint.flatBatch`,{batchCount:a.batchCount,parentId:a.parentId})}]},description:"把节点移入 parentId 成为其子节点,可指定插入位置。⚠ **实例不能当 parentId**:引擎直接拒(`in insertChild: Cannot move node. New parent is an instance or is inside of an instance`),往实例里加东西请先 jsd_detach_instance 拆链接。⚠ **parentId 请显式传**:缺省值取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(会报「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。需要依赖缺省时的两种姿势:①先 jsd_select_nodes 选中目标容器;②只调层序 → 传 index 且 ids 里含被调整节点本身,此时缺省父级 = 该节点的原父级。⚠ 层序语义:index 是 children 数组下标(0 = 最底层),children 顺序即绘制顺序(末位 = 最上层),序列化里对应字段是 z —— 判断遮挡读 z,调层序就用本工具 + index。节点已在该父级下时本工具只调层序,x/y 不变;auto-layout 容器同样支持(index 会在内部临时关掉布局插入再恢复),若引擎没落位会明确报错并提示改 itemSpacing / 对齐。⚠ **跨父级移动保持节点绝对位置**:内部按页面系记账(移动前取绝对原点,移动后换算成新父下的 x/y),不要再按「相对系重新解释」手动摆回 —— 那会把节点推走。唯一例外是移入 auto-layout 容器:位置由布局接管,写 x/y 无效,想调排布改 itemSpacing / 对齐。确需手工定位(按坐标排布等)时用 jsd_resize_node 传 x/y(可与 width/height 一次改完)或 jsd_move_node",inputSchema:Er,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`reparentNodes.description`}}),X(`repair`,{name:`jsd_repair_nodes`,title:`repairNodes.title`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:Dr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>H(r)(e,t,n))}function xl(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`,`jsdesign`],descriptionSuffix:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${cc(null)}${oc(null)}。变量面:${sc(null)})`,method:`platform_op`,inputSchema:Kn,outputSchema:Jt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}var Sl=h(Ne(import.meta.url)),Cl=_(Sl,...m(Sl)===`dist`?[`skills`,`canvas`]:[`canvas`]),wl=Cl;_(Cl,`SKILL.md`);var Tl=`jsd://recipes`,El=`jsd://recipes/{id}`,Dl=_(wl,`references`);function Ol(e){if(!e.startsWith(`---`))return{meta:{},body:e};let t=e.indexOf(`
|
|
21
|
+
`)}var el={FRAME:cn,RECTANGLE:ln,ELLIPSE:un,LINE:dn,POLYGON:fn,STAR:pn,VECTOR:mn,TEXT:hn,GROUP:gn,BOOLEAN_OPERATION:_n};function tl(e){let t={...el[e].shape,type:n.literal(e).optional()};return n.object({...t,placement:bn.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:tl(e),outputSchema:Jn,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var Y={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function nl(e,t,n){let r=[J(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,extraContent:(e,t)=>{let r=gc(t);return r==null?[]:[{type:`text`,text:n.t(`layoutHint.uniform`,r)}]},followUp:Y}),J(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:Y}),J(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:Y}),J(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:Y}),J(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:Y}),J(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:Y}),J(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:Y}),J(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],descriptionSuffix:`(MasterGo 的矢量节点是 PenNode,路径为 penNetwork 顶点模型,与本工具的 vectorPaths(SVG path data)不同形;该平台暂不支持建矢量)`,followUp:Y}),J(`GROUP`,{name:`jsd_create_group`,title:`createGroup.title`,description:`createGroup.description`,followUp:Y}),J(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`createBooleanOperation.title`,description:n.t(`createBooleanOperation.description`,{ops:dt}),followUp:Y})],i=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:xn,outputSchema:Jn,extraContent:(e,t)=>{let{svg:r,svgPath:i}=t,a=r??``;if(a.trim()===``&&i!=null&&i.trim()!==``)try{a=o(i,`utf8`)}catch{return[]}if(a.trim()===``)return[];let s=$o(a);return s>0?[]:[{type:`text`,text:n.t(`structureHint.svgNoGroups`,{groupCount:s})}]},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:xa,run:async(e,t,n)=>{let{svg:r,svgPath:i,name:a}=e,s;if(i!=null&&i.trim()!==``)try{s=o(i,`utf8`)}catch(e){throw Error(`读取 SVG 文件失败(${i}): ${e instanceof Error?e.message:String(e)}`)}else s=r??``;if(s.trim()===``)throw Error(i==null?`svg 为空字符串;要导入本地文件请改用 svgPath`:`SVG 文件是空的:${i}(脚本可能没写成功,或写到了另一个路径)`);if(s.length>ka)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${ka}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:a??`svg-design`},{signal:n,timeout:xa})},followUp:Y}),a=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Cn,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=Zc(r);if(!c){let e=Qc(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=$c(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:Y}),s=H({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:Sn,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=Hc(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:Y});return[...r.map(r=>H(r)(e,t,n)),i(e,t,n),a(e,t,n),s(e,t,n)]}var rl=n.object({group:n.string().optional().describe(`Category: ${Object.keys(Ki).join(`, `)}`),query:n.string().max(200).optional().describe(`Name, title or description substring; spaces separate search terms`),names:n.array(n.string().min(1)).min(1).max(3).optional().describe(`Exact names to inspect full schemas, up to 3`),offset:n.number().int().min(0).default(0),limit:n.number().int().min(1).max(20).default(10)}).strict().refine(e=>e.names==null||e.group==null&&e.query==null&&e.offset===0,`names cannot be combined with group, query or offset`);function il(e,t,r){let i=qi[r.locale];return[Ko(e,{name:`jsd_describe_tools`,title:i.title,description:i.description,inputSchema:rl,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},icons:As()},async t=>{try{let r=rl.parse(t),i=Uo(e);if(r.group!=null&&!Object.hasOwn(Ki,r.group))throw Error(`Unknown group: ${r.group}`);let a=(r.query??``).trim().toLowerCase().split(/\s+/).filter(Boolean),o=[...i.capabilities.values()].sort((e,t)=>e.name.localeCompare(t.name)),s=r.names==null?o.filter(e=>(r.group==null||Ki[r.group]?.includes(e.name))&&a.every(t=>`${e.name} ${e.title??``} ${e.description??``}`.toLowerCase().includes(t))):r.names.map(e=>{let t=i.capabilities.get(e);if(t==null)throw Error(`Unknown tool: ${e}`);return t}),c=(r.names==null?s.slice(r.offset,r.offset+r.limit):s).map(t=>({name:t.name,title:t.title,description:r.names==null?t.description?.slice(0,240):t.description,annotations:t.annotations,public:Go(e,t.name),execution:Go(e,t.name)?`direct-or-batch`:`batch`,...r.names==null?{}:{inputSchema:t.inputSchema==null?{type:`object`,properties:{}}:n.toJSONSchema(t.inputSchema),outputSchema:t.outputSchema==null?void 0:po(n.toJSONSchema(t.outputSchema))}})),l={profile:i.profile,groups:Object.keys(Ki),total:s.length,nextOffset:r.names==null&&r.offset+c.length<s.length?r.offset+c.length:null,tools:c};return{content:[{type:`text`,text:JSON.stringify(l)}],structuredContent:l}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}var al=`(page)`,ol=8,sl=200,cl=5,ll=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function ul(e){return e.op===`reparent`}function dl(e,t){if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e)){if(n===`ids`&&Array.isArray(r)){for(let e of r)typeof e==`string`&&e!==``&&t.add(e);continue}(n===`parentId`||n===`nodeId`||n===`componentId`)&&typeof r==`string`&&r!==``&&t.add(r)}}function fl(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function pl(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.id!=`string`||typeof t.x!=`number`||typeof t.y!=`number`?null:{id:t.id,name:typeof t.name==`string`?t.name:t.id,x:t.x,y:t.y}}async function ml(e,t,n){let r=Ms(t,e);if(r==null)return null;let i=await r(n,void 0);if(i?.isError===!0)return null;let a=i?.structuredContent;return typeof a==`object`&&a?a:null}async function hl(e,t){let n=new Map;if(t===al){let t=await ml(e,`jsd_get_page`,{});if(t==null)return null;for(let e of fl(t.nodes).slice(0,sl)){let t=pl(e);t!=null&&n.set(t.id,t)}return n}let r=await ml(e,`jsd_find`,{ids:[t],depth:1});if(r==null)return null;let i=fl(r.nodes)[0];if(i==null)return null;for(let e of fl(i.children).slice(0,sl)){let t=pl(e);t!=null&&n.set(t.id,t)}return n}var gl=class{server;operation;constructor(e,t){this.server=e,this.operation=t}snapshots=new Map;dead=new Set;engaged=!1;async before(e){let t=this.operation??e.op;if(t===void 0||ll.has(String(t))){this.engaged=!0;try{let t=new Set;if(dl(e,t),t.size===0)return;let n=await ml(this.server,`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of fl(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}(this.operation===`reparent`||ul(e))&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(al);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=ol){this.dead.add(e);continue}let t=await hl(this.server,e);if(t==null){this.dead.add(e);continue}this.snapshots.set(e,t)}}catch{}}}async after(){if(!this.engaged)return[];let e=[];for(let[t,n]of this.snapshots)try{let r=await hl(this.server,t);if(r==null)continue;let i=[];for(let[e,t]of n){let n=r.get(e);n!=null&&(n.x!==t.x||n.y!==t.y)&&i.push({from:t,to:n})}if(i.length===0)continue;let a=i.slice(0,cl).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>cl?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===al?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},_l=e=>new gl(e),vl=e=>t=>new gl(t,e);function yl(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Bn,outputSchema:$n,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:_l,followUp:{type:`tool`,tool:`jsd_set_layout`,description:`manageNodes.followUp`}}),i=H({name:`jsd_manage_components`,title:`manageComponents.title`,description:`manageComponents.description`,method:`component_op`,inputSchema:Vn,outputSchema:nr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`manageComponents.description2`}});return[r(e,t,n),i(e,t,n)]}function bl(e,t,n){return[H({name:`jsd_find`,title:`find.title`,description:'在当前页面查找节点:ids 精确匹配优先,name 模糊,type 过滤;返回序列化节点列表(最多 100 条)。scope:"document" 跨页全文档查找(触发一次全量页加载,大文档有一次性成本,结果 note 点名;默认 page 只查当前页)。⚠ 每个节点带 `z` = 它在父级 children 里的下标 = **绘制顺序**(0 = 最底层,越大越靠上);判断遮挡/层序读 z 即可,children 数组顺序与 z 一致。大区域查询先 depth:0 拿节点清单,再按 ids/name 定向小范围查,避免大响应被截断丢尾部节点 id',method:`find`,inputSchema:Rn,outputSchema:Qn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function X(e,t){return{method:`node_op`,outputSchema:$n,payload:t=>({op:e,...t}),...ll.has(e)?{tags:[`structural`],hook:vl(e)}:{},...t}}function xl(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:yr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`selectNodes.description`}}),X(`remove`,{name:`jsd_delete_node`,title:`deleteNode.title`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:br,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),X(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:xr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),X(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:Sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),X(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],descriptionSuffix:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:Cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),X(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:wr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`flattenNodes.description`}}),X(`outline_stroke`,{name:`jsd_outline_stroke`,title:`outlineStroke.title`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:Tr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),X(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,extraContent:(e,t,r)=>{let i=t.parentId,a=Zo(Array.from({length:1+(r?.batch?.siblingSteps??0)},()=>({parentId:i})));return a==null?[]:[{type:`text`,text:n.t(`structureHint.flatBatch`,{batchCount:a.batchCount,parentId:a.parentId})}]},description:"把节点移入 parentId 成为其子节点,可指定插入位置。⚠ **实例不能当 parentId**:引擎直接拒(`in insertChild: Cannot move node. New parent is an instance or is inside of an instance`),往实例里加东西请先 jsd_detach_instance 拆链接。⚠ **parentId 请显式传**:缺省值取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(会报「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。需要依赖缺省时的两种姿势:①先 jsd_select_nodes 选中目标容器;②只调层序 → 传 index 且 ids 里含被调整节点本身,此时缺省父级 = 该节点的原父级。⚠ 层序语义:index 是 children 数组下标(0 = 最底层),children 顺序即绘制顺序(末位 = 最上层),序列化里对应字段是 z —— 判断遮挡读 z,调层序就用本工具 + index。节点已在该父级下时本工具只调层序,x/y 不变;auto-layout 容器同样支持(index 会在内部临时关掉布局插入再恢复),若引擎没落位会明确报错并提示改 itemSpacing / 对齐。⚠ **跨父级移动保持节点绝对位置**:内部按页面系记账(移动前取绝对原点,移动后换算成新父下的 x/y),不要再按「相对系重新解释」手动摆回 —— 那会把节点推走。唯一例外是移入 auto-layout 容器:位置由布局接管,写 x/y 无效,想调排布改 itemSpacing / 对齐。确需手工定位(按坐标排布等)时用 jsd_resize_node 传 x/y(可与 width/height 一次改完)或 jsd_move_node",inputSchema:Er,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`reparentNodes.description`}}),X(`repair`,{name:`jsd_repair_nodes`,title:`repairNodes.title`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:Dr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>H(r)(e,t,n))}function Sl(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`,`jsdesign`],descriptionSuffix:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${lc(null)}${sc(null)}。变量面:${cc(null)})`,method:`platform_op`,inputSchema:Kn,outputSchema:Jt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}var Cl=h(Ne(import.meta.url)),wl=_(Cl,...m(Cl)===`dist`?[`skills`,`canvas`]:[`canvas`]),Tl=wl;_(wl,`SKILL.md`);var El=`jsd://recipes`,Dl=`jsd://recipes/{id}`,Ol=_(Tl,`references`);function kl(e){if(!e.startsWith(`---`))return{meta:{},body:e};let t=e.indexOf(`
|
|
22
22
|
---`,3);if(t<0)return{meta:{},body:e};let n=e.slice(3,t),r=e.slice(e.indexOf(`
|
|
23
23
|
`,t+1)+1),i={};for(let e of n.split(`
|
|
24
|
-
`)){let t=/^([A-Za-z][\w-]*):\s*(.*)$/.exec(e);if(t==null)continue;let[,n,r]=t,a=r.trim(),o=a;if(a.startsWith(`"`)&&a.endsWith(`"`))try{o=JSON.parse(a)}catch{o=a.slice(1,-1)}else a.startsWith(`'`)&&a.endsWith(`'`)&&(o=a.slice(1,-1).replace(/''/g,`'`));i[n]=o}return{meta:i,body:r}}function
|
|
25
|
-
`);return`${n.trimEnd()}\n\n## 本次参数\n\n${i}\n`}function
|
|
26
|
-
`)}var Il=(e,t,n=20)=>{let r=t.trim().toLowerCase();return(r===``?e:e.filter(e=>e.toLowerCase().includes(r))).slice(0,n)};function Ll(e){return Il(Pl(),e)}function Rl(e,t){return he(e,e=>Il(t(),typeof e==`string`?e:``))}function zl(e,t){return Rl(e,t).optional()}var Bl=[`FRAME`,`GROUP`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`LINE`,`VECTOR`,`TEXT`,`BOOLEAN_OPERATION`,`SLICE`];function Vl(e){let t=new Map;function r(n,r,i){let a=e.registerPrompt(n,r,i);return t.set(n,{name:n,title:r.title,description:r.description,arguments:Object.entries(r.argsSchema.shape).map(([e,t])=>({name:e,description:t.description,required:!t.isOptional()})),get:e=>i(r.argsSchema.strict().parse(e))}),a}function i(){let r={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},i=Wo(e,{name:`jsd_list_prompts`,title:`列出设计配方提示词`,description:`列出 MCP 提示词名称、用途与参数;用 jsd_get_prompt 按名称和参数读取正文。插件离线也可用。`,inputSchema:n.object({}),annotations:r,icons:ks()},async()=>{let e={prompts:[...t.values()].map(({get:e,...t})=>t)};return{content:[{type:`text`,text:JSON.stringify(e)}],structuredContent:e}}),a=n.object({name:n.string().describe(`提示词名称,如 design-strategy`),arguments:n.record(n.string(),n.string()).optional().describe(`提示词参数,值均为字符串`)}).strict();return[i,Wo(e,{name:`jsd_get_prompt`,title:`读取设计配方提示词`,description:`按名称和字符串参数读取 MCP 提示词正文;仅提供操作指引,不执行画布操作。插件离线也可用。`,inputSchema:a,annotations:r,icons:ks()},async e=>{try{let{name:n,arguments:r}=a.parse(e),i=t.get(n);if(!i)throw Error(`未知提示词:${n};可用名称:${[...t.keys()].join(` / `)}`);let o=i.get(r??{});return{content:o.messages.map(e=>e.content),structuredContent:o}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}return{registerPrompt:r,registerTools:i}}var Hl={"html-to-design":{html:n.string().describe(`要转换的 HTML 片段`),name:n.string().optional().describe(`生成节点的名称,默认 html-design`)},"icon-grid":{icons:n.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:n.string().optional().describe(`单个图标边长 px,默认 "24"`),gap:n.string().optional().describe(`图标间距 px,默认 "16"`)},"script-ops":{task:n.string().optional().describe(`要完成的任务描述(可省略)`)},"design-strategy":{screen:n.string().optional().describe(`要设计的界面名称,如「登录页」`)},"text-replace-strategy":{rootId:n.string().optional().describe(`根节点 id;留空取当前选中`)},"variant-sync":{sourceId:n.string().optional().describe(`源实例 id;留空取当前选中`),targetType:zl(n.string().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`),()=>Bl)},"variable-binding":{target:n.string().optional().describe(`要绑定的节点或区域描述`)},"variant-set":{family:n.string().optional().describe(`组件族名,如 Nav`)},"component-property":{target:n.string().optional().describe(`组件或实例 id`)},"auto-layout":{target:n.string().optional().describe(`要上布局的容器 / 分区描述,如「标签栏」`)},"chart-by-code":{chart:n.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」`),svgPath:n.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)}};function Ul(e,t){let{registerPrompt:r,registerTools:i}=Vl(e),a=e=>{let t=Nl(e);if(t==null)throw Error(`未知配方:${e}`);let i=Hl[e]??{};return r(e,{title:t.title,icons:ks(),description:t.whenToUse,argsSchema:n.object(i)},n=>{let r={};for(let[e,t]of Object.entries(n))t!=null&&(r[e]=String(t));return{messages:[{role:t.role,content:{type:`text`,text:Al(e,r)}}]}})},o=[`design-strategy`,`auto-layout`,`chart-by-code`,`html-to-design`,`icon-grid`,`script-ops`,`text-replace-strategy`,`variant-sync`,`variable-binding`,`variant-set`,`component-property`];return[...Pl().sort((e,t)=>{let n=e=>o.includes(e)?o.indexOf(e):o.length;return n(e)-n(t)||e.localeCompare(t)}).map(a),...i()]}function Wl(e,t,n=[]){let r=e,i=r?.updated??[],a=[];i.length>0&&a.push({type:`text`,text:`已更新 ${i.length} 个节点`});let o=r?.warnings??[];for(let e of o)a.push({type:`text`,text:`⚠ ${e}`});if(i.length===0&&t.length===0&&a.push({type:`text`,text:`未传入任何属性,本次未修改`}),n.length>0){let e=new Set(i.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`以下节点未更新(可能已失效/被连坐删除): ${t.join(`, `)}。可用 jsd_find 复核后重试`})}return a}function Z(e){let t=li[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Ge[t]!==void 0),r=e=>{let t=e.ids??[];return e.recursive===!0&&e.includeSelf!==!0?[]:t};return{name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,outputSchema:Yn,annotations:e.annotations,method:e.method,payload:e=>{let{ids:t,matchName:n,recursive:r,includeSelf:i,...a}=e,o={props:a};return t!==void 0&&(o.ids=t),n!==void 0&&(o.matchName=n),r!==void 0&&(o.recursive=r),i!==void 0&&(o.includeSelf=i),o},...e.followUp===void 0?{}:{followUp:e.followUp},extraContent:(e,t)=>Wl(e,n(t),r(t))}}var Gl=Di();function Kl(e,t,n){return[Z({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Gl}),method:`set_fill`,inputSchema:Qr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),Z({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+Gl,method:`set_stroke`,inputSchema:$r,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),Z({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+Gl,method:`set_corner_radius`,inputSchema:ei,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),Z({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:Gl}),method:`set_text`,inputSchema:ti,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),Z({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:ni,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),Z({name:`jsd_resize_node`,title:`resizeNode.title`,description:`设置节点 width/height,并可同时传 x/y 一步完成「改尺寸 + 定位」(按坐标排布、批量摆位时常用,避免分两次调用让中间态被引擎自动尺寸/约束改写;reparent 已自动保持绝对位置,不需要用本工具摆回)。TEXT 默认自适应(WIDTH_AND_HEIGHT)时会覆盖显式尺寸,要固定文本框先 jsd_set_text 设 textAutoResize=NONE。横线/竖线用 LINE:零轴会被兜到 0.01 过引擎校验(存回读仍是 0);其他类型低于 0.01 会明确报错(引擎 resize 下限)`,method:`resize`,inputSchema:ri,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Z({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设;但⚠ 开布局会按内容重算容器尺寸(有子节点时主轴被翻成 AUTO:实测 400×300 的容器 + 一个 200×60 子节点 → 200×60,而 sizingMode 字段回读仍是 FIXED,只有结果 warnings 点名),要保住尺寸就把 layoutMode 与 primaryAxisSizingMode / counterAxisSizingMode **放同一次调用里一起传 FIXED**(实测保得住)。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:ii,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),Z({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+Gl,method:`set_effects`,inputSchema:ai,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),Z({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:oi,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Z({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:si,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Z({name:`jsd_set_shape`,title:`setShape.title`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:ci,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>H(r)(e,t,n))}function ql(e,t){let n=typeof t==`string`?t.toLowerCase():``;if(n===`png`||n===`svg`||n===`pdf`)return n;if(n===`jpg`||n===`jpeg`)return`jpg`;let r=(e??``).toLowerCase();return r.includes(`png`)?`png`:r.includes(`jpeg`)||r.includes(`jpg`)?`jpg`:r.includes(`svg`)?`svg`:r.includes(`pdf`)?`pdf`:`bin`}function Jl(e,t,n){let r=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:Hn,outputSchema:rr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:xa,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:o,savePath:s,includeDataUrl:c}=e;if(s&&r.length!==1)throw Error(`savePath 仅支持单节点导出;多节点请分别指定唯一文件路径`);let l=(await t.request(`export`,{ids:r,format:i,scale:o},{signal:n,timeout:6e4})).exports??{},u=[],f=[];for(let[e,t]of Object.entries(l)){let n=t.bytes,r=t.mimeType,i={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(a(h(s),{recursive:!0}),d(s,n),i.path=s),c){if(n.byteLength>Ta){let a=s??_(p(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${ql(r,t.format)}`);s||d(a,n),i.path=a,f.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${Ta} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:f}},extraContent:(e,t)=>{let n=t.ids??[],r=e.exports??[],i=e.dataUrlOverflow??[],a=[];r.length>0&&a.push({type:`text`,text:`已导出 ${r.length} 个节点`});for(let e of i)a.push({type:`text`,text:`⚠️ 图片超过内联上限,未返回 base64,${e}。需要图片内容请读取该文件路径,或调小 scale 后重试。`});if(n.length>0){let e=new Set(r.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`导出失败(节点可能已失效): ${t.join(`, `)}。可用 jsd_find 复核`})}return a}}),i=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:Gn,outputSchema:Yn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:xa,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`fillImage.description2`},run:async(e,t,n)=>{let{ids:r,sourcePath:i}=e,a;try{a=o(i)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:r,bytes:new Uint8Array(a)},{signal:n,timeout:xa})}}),s=H({name:`jsd_list_fonts`,title:`listFonts.title`,description:`按家族名过滤、分页列出可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。**默认只回第一页**(50 族,上限 500):字体库规模随平台差一个量级——MasterGo 实测约 1900 族 / 整表 322 KB,整表必然撑爆上下文。结果里的 total 是过滤后的家族总数、truncated 表示还有下一页;按名字找字体传 family(不区分大小写的子串),翻页传 offset/limit。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,inputSchema:Un,outputSchema:ir,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}}),c=H({name:`jsd_create_style`,title:`createStyle.title`,description:`createStyle.description`,method:`create_style`,inputSchema:Fr,outputSchema:ur,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`createStyle.followUp`}}),l=H({name:`jsd_delete_style`,title:`deleteStyle.title`,description:`deleteStyle.description`,method:`delete_style`,inputSchema:Ir,outputSchema:dr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_page`,description:`deleteStyle.followUp`}});return[r(e,t,n),i(e,t,n),s(e,t,n),c(e,t,n),l(e,t,n)]}function Yl(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function Xl(e,t,n){let r=Ml.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,Tl,{title:n.t(`resources.title7`),icons:ks(),description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${r}`,mimeType:`text/markdown`},async()=>Yl(Tl,Fl())),e.registerResource(`recipe`,new de(El,{list:void 0,complete:{id:e=>Ll(e)}}),{title:n.t(`resources.title8`),icons:ks(),description:`按 id 读取配方正文(markdown),如 ${El.replace(`{id}`,`chart-by-code`)}。可用 id:${r};索引与「何时用」见 ${Tl}`,mimeType:`text/markdown`},async(e,t)=>{let n=t.id,i=Array.isArray(n)?n[0]:n,a=i==null?void 0:Nl(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${r})`);return Yl(e,kl(a.id))})]}var Zl=(e,t)=>e(t);function Ql(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function $l(e,t,n){let{t:r}=n;return[e.registerResource(`canvas-selection`,`jsd://canvas/selection`,{title:Zl(r,`resources.title`),icons:As(),description:`当前选中节点的序列化树(含直接子节点),实时从插件读取;等价于 jsd_get_selection depth=2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上)`,mimeType:`application/json`},async()=>Ql(`jsd://canvas/selection`,await t.request(`get_selection`,{depth:2}))),e.registerResource(`fonts`,`jsd://fonts`,{title:Zl(r,`resources.title2`),icons:As(),cacheHint:{ttlMs:Ca,cacheScope:`private`},description:`当前环境可用的字体族与各族的可用字型(families / fonts:[{family,styles}]),实时从插件读取。**只回第一页**并给出 total/truncated —— 字体库实测可达约 1900 族,整表会撑爆上下文;要按名字找或翻页请用 jsd_list_fonts 的 family/offset/limit`,mimeType:`application/json`},async()=>Ql(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:Zl(r,`resources.title3`),icons:As(),cacheHint:{ttlMs:wa,cacheScope:`private`},description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名。⚠ 空清单不等于没有样式:本平台未声明样式枚举能力时恒空,回包会带 note 说明`,mimeType:`application/json`},async()=>Ql(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:Zl(r,`resources.title4`),icons:As(),cacheHint:{ttlMs:wa,cacheScope:`private`},description:`**当前页**概览:①第一层节点的几何(id/名称/类型/宽高/x/y,不递归);②可复用资源清单(assets.summary 给四类计数;组件、变体集(带维度→可选值)、样式(PAINT/TEXT/EFFECT/GRID)、变量,每项含 id+名称)。范围:样式与变量是文档级;组件与变体在只读得到当前页的平台(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前先读这里:命中的一律复用,禁止新建重复件**。等价于 jsd_get_page`,mimeType:`application/json`},async()=>Ql(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new de(`jsd://node/{id}`,{list:void 0}),{title:Zl(r,`resources.title5`),icons:As(),description:`按 id 读取节点的序列化结构,如 jsd://node/12:3;等价于 jsd_find ids 精确查找`,mimeType:`application/json`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r;if(!i)throw Error(`缺少节点 id: ${e.href}`);return Ql(e,await t.request(`find`,{ids:[i]}))}),e.registerResource(`platform-state`,`jsd://platform/state`,{title:Zl(r,`resources.title6`),icons:As(),description:`daemon 缓存的插件平台状态(platform / capabilities / coreCapabilities / platformOps),取自最近一次 jsd_ping 回包;插件离线或尚未探测到平台时为空(此时先调 jsd_ping)。读缓存不发插件请求 —— 用它判断「当前平台支持什么、有哪些特有 op」比每次 ping 便宜`,mimeType:`application/json`},async()=>Ql(`jsd://platform/state`,Pa()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}async function eu(){let e=h(wl);try{let t=await Pe(e);return N(`skills: ${t.entries.length} 条已发布(${e})`),nu(t.entries.length,null),t}catch(t){let n=t instanceof Error?t.message:String(t);return P(`skills 未发布(工具照常可用): ${n} (${e})`),nu(0,n),null}}var tu=null;function nu(e,t){tu={published:t==null&&e>0,count:e,...t==null?{}:{error:t}}}function ru(){return tu}function iu(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:ja.label}),description:n.t(`ping.description`,{client:ja.label}),outputSchema:Xn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:ba,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:ba});return{connected:!0,platform:e?.platform,capabilities:e?.capabilities,coreCapabilities:e?.coreCapabilities,platformOps:e?.platformOps,...ru()==null?{}:{skills:ru()}}}catch(e){return{connected:!1,error:e instanceof Error?e.message:String(e)}}}}),i=H({name:`jsd_get_selection`,title:`getSelection.title`,description:`getSelection.description`,method:`get_selection`,inputSchema:wn,outputSchema:Zn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getSelection.description2`}}),a=H({name:`jsd_get_page`,title:`getPage.title`,description:`getPage.description`,method:`get_page`,inputSchema:Wn,outputSchema:lr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getPage.followUp`}});return[r(e,t,n),i(e,t,n),a(e,t,n)]}var au=[iu,tl,yl,bl,lc,Kl,vl,Jl,nc,xl,$l,Xl,(e,t,n)=>Ul(e,n),rl];function ou(e,t=Ko(),n={}){let r=n.toolProfile??ga(),i=new le({name:ha,version:L},{supportedProtocolVersions:me,instructions:`${t.t(`mcp.instructions`)}\n${qi[t.locale][r]}`,cacheHints:{"tools/list":{ttlMs:Sa,cacheScope:`private`},"prompts/list":{ttlMs:Sa,cacheScope:`private`},"resources/list":{ttlMs:Sa,cacheScope:`private`},"resources/templates/list":{ttlMs:Sa,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}},...Aa==null?{}:{maxToolInputElements:Aa}});Ho(i,r);for(let n of au)n(i,e,t);return i}var su=``,cu=``,lu=process.env.TEXT_TO_DESIGN_TELEMETRY_URL??su,uu=process.env.TEXT_TO_DESIGN_TELEMETRY_KEY??cu,du=_(f(),`.text-to-design`),fu=_(du,`install-id`),pu=Zi.batchMax,mu=100,hu=1e4,gu=1e4,_u=3e5,Q=[],vu=``,yu=!1,bu=null,xu=0,Su=!1;async function Cu(){if(vu!==``)return vu;try{let e=(await De(fu,`utf8`)).trim();if(e.length>=8)return vu=e,e}catch{}vu=Fe();try{await Ee(du,{recursive:!0}),await ke(fu,`${vu}\n`,`utf8`)}catch{}return vu}function wu(e){Su||bu!=null||(bu=setTimeout(()=>{bu=null,Au()},e),bu.unref())}function Tu(){bu!=null&&(clearTimeout(bu),bu=null)}function Eu(){xu++;let e=Math.min(gu*2**(xu-1),_u),t=e/2+e/2*Math.random();Tu(),wu(t)}function Du(){let e=Q.length-mu;for(let t=0;t<Q.length&&e>0;){if(Q[t].inflight===!0){t++;continue}Q.splice(t,1),e--}}function Ou(e){if(!Ui(e.level)||lu===``||uu===``||!Lo())return;let{message:t,scope:n,code:r,subject:i}=e,a=Pi({scope:n,code:r,subject:i,message:t});for(let e=Q.length-1;e>=0;e--){let t=Q[e];if(t.inflight!==!0&&t.fingerprint===a){t.count=(t.count??1)+1,wu(hu);return}}let o=Pa()?.platform;if(Q.push({...e,level:e.level,id:Fe(),fingerprint:a,message:t.slice(0,Zi.messageMax),stack:e.stack?.slice(0,Zi.stackMax),context:o==null?e.context:{...e.context??{},platform:o}}),Du(),Q.length>=pu){Tu(),Au();return}wu(hu)}function ku(e){return{id:e.id,level:e.level,message:e.message,stack:e.stack,context:e.context,count:e.count,scope:e.scope,code:e.code,subject:e.subject}}async function Au(e=5e3){if(yu||Q.length===0||lu===``||uu===``||!Lo())return;yu=!0;let t=Q.slice(0,pu);for(let e of t)e.inflight=!0;try{let n=await Cu(),r=await fetch(lu,{method:`POST`,headers:{authorization:`Bearer ${uu}`,"content-type":`application/json`},body:JSON.stringify({user:{fingerprint:n,mcpVersion:L,clientVersion:Ia()??void 0},errors:t.map(ku)}),signal:AbortSignal.timeout(e)});if(!r.ok){N(`遥测上报失败: HTTP ${r.status}`),Eu();return}Q=Q.filter(e=>e.inflight!==!0),xu=0,Q.length>0&&wu(0)}catch(e){N(`遥测上报失败: ${e instanceof Error?e.message:String(e)}`),Eu()}finally{for(let e of t)e.inflight=!1;yu=!1}}function ju(){Su=!0,Tu()}var Mu=null;async function Nu(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ta);try{let n=await fetch(ea(e),{signal:t.signal});if(!n.ok)return P(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(P(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return P(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function Pu(){let e=Date.now();if(Mu!=null&&e-Mu.at<18e5)return Mu.latest;let[t,n]=await Promise.all([Nu(Qi.ui),Nu(Qi.mcp)]);return N(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),Mu={at:e,latest:{ui:t,mcp:n}},Mu.latest}function Fu(e,t={}){let n=Math.max(1,Math.trunc(t.size??4)),r=Math.max(n,Math.trunc(t.max??8)),i=[],a=t=>{let n=Math.min(Math.max(1,Math.trunc(t)),r);for(;i.length<n;)i.push({server:e(),busy:!1})};return a(n),{acquire(){let e=i.find(e=>!e.busy&&!e.server.isConnected());if(e==null&&i.length<r&&(a(i.length+1),e=i.at(-1)),e==null)return null;let t=e;t.busy=!0;let n=!1;return{server:t.server,release(){n||(n=!0,t.busy=!1)}}},warm(e=n){a(e)},get size(){return i.length}}}async function Iu(){let e=await Qa();if(e.state===`starting`){let t=await eo({first:e});return t?.state===`proxy`?(await t.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1):(t?.state===`foreign`&&zu(),t==null&&await z()!==null?(M(`已有 daemon 持有端口,本次启动跳过`),!1):!0)}return e.state===`proxy`?(await e.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1):(e.state===`foreign`&&zu(),!0)}async function Lu(e){if(!await Iu()){await Za();return}await Io(),e.start(ma),M(`daemon: 插件 WS ws://localhost:${e.port}`);let t=await eu(),n=(e,t)=>{if(t!=null)try{t.attach(e)}catch(e){P(`skills 挂载失败(该实例继续提供工具): ${e instanceof Error?e.message:String(e)}`)}},r=Fu(()=>{let r=ou(e);return n(r,t),r}),i=new Se,a=ge(()=>{let e=i.getStore();if(e==null)throw Error(`Missing MCP server lease`);return e.server},{legacy:`reject`}),o=Te({fetch:async(e,t)=>{let n=await a.fetch(e,t),r=i.getStore();return r!=null&&!r.server.isConnected()&&r.release(),n}});Ya();let s=Ce(),c=we(),l=null,d=null,f=null,p=()=>{Pu().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){M(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),M(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=()=>{e.pushConsent({type:`consent`,granted:Lo(),asked:Ro()}),p()},e.onConsentSet=t=>{zo(t),M(`错误上报同意: ${t?`开启`:`关闭`}`),e.pushConsent({type:`consent`,granted:t,asked:!0})},process.on(`uncaughtException`,e=>{Ou({level:`fatal`,message:e.message,stack:e.stack,scope:`daemon`}),Au(3e3).finally(()=>process.exit(1))}),process.on(`unhandledRejection`,e=>{Ou({level:`fatal`,message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0,scope:`daemon`}),Au(3e3).finally(()=>process.exit(1))});let g=t=>{M(`daemon 退出: ${t}`),d!=null&&clearInterval(d),f?.close(),ju(),Au(1500).finally(()=>{a.close().catch(e=>{N(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),l?.close(),process.exit(0)})};await new Promise((e,t)=>{l=ne((e,t)=>{if(!s(e,t)||!c(e,t))return;let n=Date.now(),a=e.url??``;if(t.on(`finish`,()=>{let r=`HTTP ${e.method} ${a} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?M(r):N(r)}),e.method===`GET`&&a===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:ha,version:L,pid:process.pid,startedAt:_a}));return}if(e.method===`POST`&&a===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>g(`收到 /shutdown 请求`),100);return}let l=r.acquire();if(l==null){t.writeHead(503,{"content-type":`application/json`,"retry-after":`1`}),t.end(JSON.stringify({jsonrpc:`2.0`,id:null,error:{code:-32603,message:`MCP server busy; retry later`}}));return}i.run(l,async()=>{try{await o(e,t)}catch(e){P(`HTTP handler failed: ${String(e)}`),t.destroy()}finally{l.release(),ee()}})}),l.once(`error`,t),l.listen(I,`127.0.0.1`,()=>e())}),M(`daemon: MCP HTTP http://127.0.0.1:${I}/mcp`),M(`daemon 就绪,常驻运行(shim 重启时轮换到新构建)`),d=setInterval(p,Ie),p();let _=!1,ee=()=>{if(!_)return;let e=r.acquire();e!=null&&(e.release(),_=!1,P(`shim 已换上当前构建,常驻 daemon 退出轮换`),g(`shim 请求轮换`))},te=()=>{Xa()!=null&&(_=!0,ee())},v=Ja();try{f=u(h(v),(e,t)=>{(t==null||t===m(v))&&te()}),f.on(`error`,e=>N(`退役标记监听失败(只剩 shim 下次启动时轮换): ${String(e)}`))}catch(e){N(`装不上退役标记监听: ${String(e)}`)}te(),process.on(`SIGINT`,()=>g(`SIGINT`))}async function Ru(){try{d(Ja(),String(_a))}catch{N(`自检标记写不进去(只读安装?),交给产物自检兜底`);return}let e=Date.now()+ya;for(;Date.now()<e;)if(await $a(250),await z()==null)return;P(`daemon 在 ${ya/1e3}s 内未退役,交给产物自检继续兜底`)}function zu(){F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)}function Bu(){F(`daemon 启动超时(${va/1e3}s),请检查残留进程后重试`),process.exit(1)}async function Vu(){await Za();let e=await Qa();if(e.state===`foreign`&&zu(),e.state===`proxy`){await e.client.close().catch(()=>{}),await Ru();let t=await eo();if(t?.state===`proxy`){await jo(t.client);return}t?.state===`foreign`&&zu(),t??Bu()}e.state===`none`?M(`未发现 daemon,自动拉起...`):M(`daemon 正在启动,等待就绪...`);let t=await eo({spawnIfNone:!0,first:e});if(t?.state===`proxy`){await jo(t.client);return}t?.state===`foreign`&&zu(),Bu()}var $=`text-to-design-mcp`;function Hu(e){return e.includes(` `)?`"${e}"`:e}function Uu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Wu(){let e=ee(process.argv[1]??``),t=process.execPath;return e?e.endsWith(`.ts`)?{problem:`当前是开发态(tsx 直接跑 TS 源码),不能注册自启。请改用构建产物(pnpm build 后 node dist/index.js install-service)或全局安装的 text-to-design-mcp`}:e.split(te).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Gu(e){return e===`linux`?_(f(),`.config/systemd/user`,`${$}.service`):_(f(),`Library/LaunchAgents`,`com.${$}.plist`)}function Ku(e,t){return[{kind:`write`,path:Gu(`linux`),content:`[Unit]
|
|
24
|
+
`)){let t=/^([A-Za-z][\w-]*):\s*(.*)$/.exec(e);if(t==null)continue;let[,n,r]=t,a=r.trim(),o=a;if(a.startsWith(`"`)&&a.endsWith(`"`))try{o=JSON.parse(a)}catch{o=a.slice(1,-1)}else a.startsWith(`'`)&&a.endsWith(`'`)&&(o=a.slice(1,-1).replace(/''/g,`'`));i[n]=o}return{meta:i,body:r}}function Al(e){return kl(o(_(Ol,`${e}.md`),`utf8`)).body}function jl(e,t={}){let n=Al(e),r=[];for(let[e,i]of Object.entries(t)){if(i==null)continue;let t=`{{${e}}}`;n.includes(t)?n=n.split(t).join(i):r.push([e,i])}if(r.length===0)return n;let i=r.map(([e,t])=>`- ${e}: ${t}`).join(`
|
|
25
|
+
`);return`${n.trimEnd()}\n\n## 本次参数\n\n${i}\n`}function Ml(e){let{meta:t}=kl(o(_(Ol,`${e}.md`),`utf8`)),n=t.when?.trim(),r=t.title?.trim();if(n==null||n===``)throw Error(`references/${e}.md 的 frontmatter 缺 when —— 索引里没有「何时用」的条目等于噪音`);if(r==null||r===``)throw Error(`references/${e}.md 的 frontmatter 缺 title`);let i=t.role===`assistant`?`assistant`:`user`;return{id:e,uri:`jsd://recipes/${e}`,title:r,whenToUse:n,...t.args?.trim()?{argsHint:t.args.trim()}:{},role:i}}var Nl=s(Ol).filter(e=>e.endsWith(`.md`)).map(e=>e.replace(/\.md$/,``)).sort().map(Ml);function Pl(e){return Nl.find(t=>t.id===e)}function Fl(){return Nl.map(e=>e.id)}function Il(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,"正文的唯一来源是技能目录 `skill://canvas/references/<id>.md`;这里的每条与它是一个文件。",``,...Nl.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`(与 `skill://canvas/references/design-strategy.md` 同一个文件)。"].join(`
|
|
26
|
+
`)}var Ll=(e,t,n=20)=>{let r=t.trim().toLowerCase();return(r===``?e:e.filter(e=>e.toLowerCase().includes(r))).slice(0,n)};function Rl(e){return Ll(Fl(),e)}function zl(e,t){return he(e,e=>Ll(t(),typeof e==`string`?e:``))}function Bl(e,t){return zl(e,t).optional()}var Vl=[`FRAME`,`GROUP`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`LINE`,`VECTOR`,`TEXT`,`BOOLEAN_OPERATION`,`SLICE`];function Hl(e){let t=new Map;function r(n,r,i){let a=e.registerPrompt(n,r,i);return t.set(n,{name:n,title:r.title,description:r.description,arguments:Object.entries(r.argsSchema.shape).map(([e,t])=>({name:e,description:t.description,required:!t.isOptional()})),get:e=>i(r.argsSchema.strict().parse(e))}),a}function i(){let r={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},i=Ko(e,{name:`jsd_list_prompts`,title:`列出设计配方提示词`,description:`列出 MCP 提示词名称、用途与参数;用 jsd_get_prompt 按名称和参数读取正文。插件离线也可用。`,inputSchema:n.object({}),annotations:r,icons:As()},async()=>{let e={prompts:[...t.values()].map(({get:e,...t})=>t)};return{content:[{type:`text`,text:JSON.stringify(e)}],structuredContent:e}}),a=n.object({name:n.string().describe(`提示词名称,如 design-strategy`),arguments:n.record(n.string(),n.string()).optional().describe(`提示词参数,值均为字符串`)}).strict();return[i,Ko(e,{name:`jsd_get_prompt`,title:`读取设计配方提示词`,description:`按名称和字符串参数读取 MCP 提示词正文;仅提供操作指引,不执行画布操作。插件离线也可用。`,inputSchema:a,annotations:r,icons:As()},async e=>{try{let{name:n,arguments:r}=a.parse(e),i=t.get(n);if(!i)throw Error(`未知提示词:${n};可用名称:${[...t.keys()].join(` / `)}`);let o=i.get(r??{});return{content:o.messages.map(e=>e.content),structuredContent:o}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}return{registerPrompt:r,registerTools:i}}var Ul={"html-to-design":{html:n.string().describe(`要转换的 HTML 片段`),name:n.string().optional().describe(`生成节点的名称,默认 html-design`)},"icon-grid":{icons:n.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:n.string().optional().describe(`单个图标边长 px,默认 "24"`),gap:n.string().optional().describe(`图标间距 px,默认 "16"`)},"script-ops":{task:n.string().optional().describe(`要完成的任务描述(可省略)`)},"design-strategy":{screen:n.string().optional().describe(`要设计的界面名称,如「登录页」`)},"text-replace-strategy":{rootId:n.string().optional().describe(`根节点 id;留空取当前选中`)},"variant-sync":{sourceId:n.string().optional().describe(`源实例 id;留空取当前选中`),targetType:Bl(n.string().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`),()=>Vl)},"variable-binding":{target:n.string().optional().describe(`要绑定的节点或区域描述`)},"variant-set":{family:n.string().optional().describe(`组件族名,如 Nav`)},"component-property":{target:n.string().optional().describe(`组件或实例 id`)},"auto-layout":{target:n.string().optional().describe(`要上布局的容器 / 分区描述,如「标签栏」`)},"chart-by-code":{chart:n.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」`),svgPath:n.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)}};function Wl(e,t){let{registerPrompt:r,registerTools:i}=Hl(e),a=e=>{let t=Pl(e);if(t==null)throw Error(`未知配方:${e}`);let i=Ul[e]??{};return r(e,{title:t.title,icons:As(),description:t.whenToUse,argsSchema:n.object(i)},n=>{let r={};for(let[e,t]of Object.entries(n))t!=null&&(r[e]=String(t));return{messages:[{role:t.role,content:{type:`text`,text:jl(e,r)}}]}})},o=[`design-strategy`,`auto-layout`,`chart-by-code`,`html-to-design`,`icon-grid`,`script-ops`,`text-replace-strategy`,`variant-sync`,`variable-binding`,`variant-set`,`component-property`];return[...Fl().sort((e,t)=>{let n=e=>o.includes(e)?o.indexOf(e):o.length;return n(e)-n(t)||e.localeCompare(t)}).map(a),...i()]}function Gl(e,t,n=[]){let r=e,i=r?.updated??[],a=[];i.length>0&&a.push({type:`text`,text:`已更新 ${i.length} 个节点`});let o=r?.warnings??[];for(let e of o)a.push({type:`text`,text:`⚠ ${e}`});if(i.length===0&&t.length===0&&a.push({type:`text`,text:`未传入任何属性,本次未修改`}),n.length>0){let e=new Set(i.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`以下节点未更新(可能已失效/被连坐删除): ${t.join(`, `)}。可用 jsd_find 复核后重试`})}return a}function Z(e){let t=li[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Ge[t]!==void 0),r=e=>{let t=e.ids??[];return e.recursive===!0&&e.includeSelf!==!0?[]:t};return{name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,outputSchema:Yn,annotations:e.annotations,method:e.method,payload:e=>{let{ids:t,matchName:n,recursive:r,includeSelf:i,...a}=e,o={props:a};return t!==void 0&&(o.ids=t),n!==void 0&&(o.matchName=n),r!==void 0&&(o.recursive=r),i!==void 0&&(o.includeSelf=i),o},...e.followUp===void 0?{}:{followUp:e.followUp},extraContent:(e,t)=>Gl(e,n(t),r(t))}}var Kl=Di();function ql(e,t,n){return[Z({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Kl}),method:`set_fill`,inputSchema:Qr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),Z({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+Kl,method:`set_stroke`,inputSchema:$r,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),Z({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+Kl,method:`set_corner_radius`,inputSchema:ei,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),Z({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:Kl}),method:`set_text`,inputSchema:ti,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),Z({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:ni,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),Z({name:`jsd_resize_node`,title:`resizeNode.title`,description:`设置节点 width/height,并可同时传 x/y 一步完成「改尺寸 + 定位」(按坐标排布、批量摆位时常用,避免分两次调用让中间态被引擎自动尺寸/约束改写;reparent 已自动保持绝对位置,不需要用本工具摆回)。TEXT 默认自适应(WIDTH_AND_HEIGHT)时会覆盖显式尺寸,要固定文本框先 jsd_set_text 设 textAutoResize=NONE。横线/竖线用 LINE:零轴会被兜到 0.01 过引擎校验(存回读仍是 0);其他类型低于 0.01 会明确报错(引擎 resize 下限)`,method:`resize`,inputSchema:ri,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Z({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设;但⚠ 开布局会按内容重算容器尺寸(有子节点时主轴被翻成 AUTO:实测 400×300 的容器 + 一个 200×60 子节点 → 200×60,而 sizingMode 字段回读仍是 FIXED,只有结果 warnings 点名),要保住尺寸就把 layoutMode 与 primaryAxisSizingMode / counterAxisSizingMode **放同一次调用里一起传 FIXED**(实测保得住)。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:ii,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),Z({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+Kl,method:`set_effects`,inputSchema:ai,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),Z({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:oi,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Z({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:si,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Z({name:`jsd_set_shape`,title:`setShape.title`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:ci,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>H(r)(e,t,n))}function Jl(e,t){let n=typeof t==`string`?t.toLowerCase():``;if(n===`png`||n===`svg`||n===`pdf`)return n;if(n===`jpg`||n===`jpeg`)return`jpg`;let r=(e??``).toLowerCase();return r.includes(`png`)?`png`:r.includes(`jpeg`)||r.includes(`jpg`)?`jpg`:r.includes(`svg`)?`svg`:r.includes(`pdf`)?`pdf`:`bin`}function Yl(e,t,n){let r=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:Hn,outputSchema:rr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:xa,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:o,savePath:s,includeDataUrl:c}=e;if(s&&r.length!==1)throw Error(`savePath 仅支持单节点导出;多节点请分别指定唯一文件路径`);let l=(await t.request(`export`,{ids:r,format:i,scale:o},{signal:n,timeout:6e4})).exports??{},u=[],f=[];for(let[e,t]of Object.entries(l)){let n=t.bytes,r=t.mimeType,i={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(a(h(s),{recursive:!0}),d(s,n),i.path=s),c){if(n.byteLength>Ta){let a=s??_(p(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${Jl(r,t.format)}`);s||d(a,n),i.path=a,f.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${Ta} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:f}},extraContent:(e,t)=>{let n=t.ids??[],r=e.exports??[],i=e.dataUrlOverflow??[],a=[];r.length>0&&a.push({type:`text`,text:`已导出 ${r.length} 个节点`});for(let e of i)a.push({type:`text`,text:`⚠️ 图片超过内联上限,未返回 base64,${e}。需要图片内容请读取该文件路径,或调小 scale 后重试。`});if(n.length>0){let e=new Set(r.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`导出失败(节点可能已失效): ${t.join(`, `)}。可用 jsd_find 复核`})}return a}}),i=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:Gn,outputSchema:Yn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:xa,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`fillImage.description2`},run:async(e,t,n)=>{let{ids:r,sourcePath:i}=e,a;try{a=o(i)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:r,bytes:new Uint8Array(a)},{signal:n,timeout:xa})}}),s=H({name:`jsd_list_fonts`,title:`listFonts.title`,description:`按家族名过滤、分页列出可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。**默认只回第一页**(50 族,上限 500):字体库规模随平台差一个量级——MasterGo 实测约 1900 族 / 整表 322 KB,整表必然撑爆上下文。结果里的 total 是过滤后的家族总数、truncated 表示还有下一页;按名字找字体传 family(不区分大小写的子串),翻页传 offset/limit。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,inputSchema:Un,outputSchema:ir,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}}),c=H({name:`jsd_create_style`,title:`createStyle.title`,description:`createStyle.description`,method:`create_style`,inputSchema:Fr,outputSchema:ur,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`createStyle.followUp`}}),l=H({name:`jsd_delete_style`,title:`deleteStyle.title`,description:`deleteStyle.description`,method:`delete_style`,inputSchema:Ir,outputSchema:dr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_page`,description:`deleteStyle.followUp`}});return[r(e,t,n),i(e,t,n),s(e,t,n),c(e,t,n),l(e,t,n)]}function Xl(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function Zl(e,t,n){let r=Nl.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,El,{title:n.t(`resources.title7`),icons:As(),description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${r}`,mimeType:`text/markdown`},async()=>Xl(El,Il())),e.registerResource(`recipe`,new de(Dl,{list:void 0,complete:{id:e=>Rl(e)}}),{title:n.t(`resources.title8`),icons:As(),description:`按 id 读取配方正文(markdown),如 ${Dl.replace(`{id}`,`chart-by-code`)}。可用 id:${r};索引与「何时用」见 ${El}`,mimeType:`text/markdown`},async(e,t)=>{let n=t.id,i=Array.isArray(n)?n[0]:n,a=i==null?void 0:Pl(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${r})`);return Xl(e,Al(a.id))})]}var Ql=(e,t)=>e(t);function $l(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function eu(e,t,n){let{t:r}=n;return[e.registerResource(`canvas-selection`,`jsd://canvas/selection`,{title:Ql(r,`resources.title`),icons:js(),description:`当前选中节点的序列化树(含直接子节点),实时从插件读取;等价于 jsd_get_selection depth=2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上)`,mimeType:`application/json`},async()=>$l(`jsd://canvas/selection`,await t.request(`get_selection`,{depth:2}))),e.registerResource(`fonts`,`jsd://fonts`,{title:Ql(r,`resources.title2`),icons:js(),cacheHint:{ttlMs:Ca,cacheScope:`private`},description:`当前环境可用的字体族与各族的可用字型(families / fonts:[{family,styles}]),实时从插件读取。**只回第一页**并给出 total/truncated —— 字体库实测可达约 1900 族,整表会撑爆上下文;要按名字找或翻页请用 jsd_list_fonts 的 family/offset/limit`,mimeType:`application/json`},async()=>$l(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:Ql(r,`resources.title3`),icons:js(),cacheHint:{ttlMs:wa,cacheScope:`private`},description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名。⚠ 空清单不等于没有样式:本平台未声明样式枚举能力时恒空,回包会带 note 说明`,mimeType:`application/json`},async()=>$l(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:Ql(r,`resources.title4`),icons:js(),cacheHint:{ttlMs:wa,cacheScope:`private`},description:`**当前页**概览:①第一层节点的几何(id/名称/类型/宽高/x/y,不递归);②可复用资源清单(assets.summary 给四类计数;组件、变体集(带维度→可选值)、样式(PAINT/TEXT/EFFECT/GRID)、变量,每项含 id+名称)。范围:样式与变量是文档级;组件与变体在只读得到当前页的平台(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前先读这里:命中的一律复用,禁止新建重复件**。等价于 jsd_get_page`,mimeType:`application/json`},async()=>$l(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new de(`jsd://node/{id}`,{list:void 0}),{title:Ql(r,`resources.title5`),icons:js(),description:`按 id 读取节点的序列化结构,如 jsd://node/12:3;等价于 jsd_find ids 精确查找`,mimeType:`application/json`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r;if(!i)throw Error(`缺少节点 id: ${e.href}`);return $l(e,await t.request(`find`,{ids:[i]}))}),e.registerResource(`platform-state`,`jsd://platform/state`,{title:Ql(r,`resources.title6`),icons:js(),description:`daemon 缓存的插件平台状态(platform / capabilities / coreCapabilities / platformOps),取自最近一次 jsd_ping 回包;插件离线或尚未探测到平台时为空(此时先调 jsd_ping)。读缓存不发插件请求 —— 用它判断「当前平台支持什么、有哪些特有 op」比每次 ping 便宜`,mimeType:`application/json`},async()=>$l(`jsd://platform/state`,Pa()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}async function tu(){let e=h(Tl);try{let t=await Pe(e);return N(`skills: ${t.entries.length} 条已发布(${e})`),ru(t.entries.length,null),t}catch(t){let n=t instanceof Error?t.message:String(t);return P(`skills 未发布(工具照常可用): ${n} (${e})`),ru(0,n),null}}var nu=null;function ru(e,t){nu={published:t==null&&e>0,count:e,...t==null?{}:{error:t}}}function iu(){return nu}function au(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:ja.label}),description:n.t(`ping.description`,{client:ja.label}),outputSchema:Xn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:ba,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:ba});return{connected:!0,platform:e?.platform,capabilities:e?.capabilities,coreCapabilities:e?.coreCapabilities,platformOps:e?.platformOps,...iu()==null?{}:{skills:iu()}}}catch(e){return{connected:!1,error:e instanceof Error?e.message:String(e)}}}}),i=H({name:`jsd_get_selection`,title:`getSelection.title`,description:`getSelection.description`,method:`get_selection`,inputSchema:wn,outputSchema:Zn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getSelection.description2`}}),a=H({name:`jsd_get_page`,title:`getPage.title`,description:`getPage.description`,method:`get_page`,inputSchema:Wn,outputSchema:lr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getPage.followUp`}});return[r(e,t,n),i(e,t,n),a(e,t,n)]}var ou=[au,nl,bl,xl,uc,ql,yl,Yl,rc,Sl,eu,Zl,(e,t,n)=>Wl(e,n),il];function su(e,t=Jo(),n={}){let r=n.toolProfile??ga(),i=new le({name:ha,version:L},{supportedProtocolVersions:me,instructions:`${t.t(`mcp.instructions`)}\n${qi[t.locale][r]}`,cacheHints:{"tools/list":{ttlMs:Sa,cacheScope:`private`},"prompts/list":{ttlMs:Sa,cacheScope:`private`},"resources/list":{ttlMs:Sa,cacheScope:`private`},"resources/templates/list":{ttlMs:Sa,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}},...Aa==null?{}:{maxToolInputElements:Aa}});Wo(i,r);for(let n of ou)n(i,e,t);return i}var cu=`https://telemetry.text-to-design.wzrove.com/v1/errors`,lu=`dev-insecure-key`,uu=process.env.TEXT_TO_DESIGN_TELEMETRY_URL??cu,du=process.env.TELEMETRY_API_KEY??lu,fu=_(f(),`.text-to-design`),pu=_(fu,`install-id`),mu=Zi.batchMax,hu=100,gu=1e4,_u=1e4,vu=3e5,Q=[],yu=``,bu=!1,xu=null,Su=0,Cu=!1;async function wu(){if(yu!==``)return yu;try{let e=(await De(pu,`utf8`)).trim();if(e.length>=8)return yu=e,e}catch{}yu=Fe();try{await Ee(fu,{recursive:!0}),await ke(pu,`${yu}\n`,`utf8`)}catch{}return yu}function Tu(e){Cu||xu!=null||(xu=setTimeout(()=>{xu=null,ju()},e),xu.unref())}function Eu(){xu!=null&&(clearTimeout(xu),xu=null)}function Du(){Su++;let e=Math.min(_u*2**(Su-1),vu),t=e/2+e/2*Math.random();Eu(),Tu(t)}function Ou(){let e=Q.length-hu;for(let t=0;t<Q.length&&e>0;){if(Q[t].inflight===!0){t++;continue}Q.splice(t,1),e--}}function ku(e){if(!Ui(e.level)||uu===``||du===``||!zo())return;let{message:t,scope:n,code:r,subject:i}=e,a=Pi({scope:n,code:r,subject:i,message:t});for(let e=Q.length-1;e>=0;e--){let t=Q[e];if(t.inflight!==!0&&t.fingerprint===a){t.count=(t.count??1)+1,Tu(gu);return}}let o=Pa()?.platform;if(Q.push({...e,level:e.level,id:Fe(),fingerprint:a,message:t.slice(0,Zi.messageMax),stack:e.stack?.slice(0,Zi.stackMax),context:o==null?e.context:{...e.context??{},platform:o}}),Ou(),Q.length>=mu){Eu(),ju();return}Tu(gu)}function Au(e){return{id:e.id,level:e.level,message:e.message,stack:e.stack,context:e.context,count:e.count,scope:e.scope,code:e.code,subject:e.subject}}async function ju(e=5e3){if(bu||Q.length===0||uu===``||du===``||!zo())return;bu=!0;let t=Q.slice(0,mu);for(let e of t)e.inflight=!0;try{let n=await wu(),r=await fetch(uu,{method:`POST`,headers:{authorization:`Bearer ${du}`,"content-type":`application/json`},body:JSON.stringify({user:{fingerprint:n,mcpVersion:L,clientVersion:Ia()??void 0},errors:t.map(Au)}),signal:AbortSignal.timeout(e)});if(!r.ok){N(`遥测上报失败: HTTP ${r.status}`),Du();return}Q=Q.filter(e=>e.inflight!==!0),Su=0,Q.length>0&&Tu(0)}catch(e){N(`遥测上报失败: ${e instanceof Error?e.message:String(e)}`),Du()}finally{for(let e of t)e.inflight=!1;bu=!1}}function Mu(){Cu=!0,Eu()}var Nu=null;async function Pu(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ta);try{let n=await fetch(ea(e),{signal:t.signal});if(!n.ok)return P(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(P(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return P(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function Fu(){let e=Date.now();if(Nu!=null&&e-Nu.at<18e5)return Nu.latest;let[t,n]=await Promise.all([Pu(Qi.ui),Pu(Qi.mcp)]);return N(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),Nu={at:e,latest:{ui:t,mcp:n}},Nu.latest}function Iu(e,t={}){let n=Math.max(1,Math.trunc(t.size??4)),r=Math.max(n,Math.trunc(t.max??8)),i=[],a=t=>{let n=Math.min(Math.max(1,Math.trunc(t)),r);for(;i.length<n;)i.push({server:e(),busy:!1})};return a(n),{acquire(){let e=i.find(e=>!e.busy&&!e.server.isConnected());if(e==null&&i.length<r&&(a(i.length+1),e=i.at(-1)),e==null)return null;let t=e;t.busy=!0;let n=!1;return{server:t.server,release(){n||(n=!0,t.busy=!1)}}},warm(e=n){a(e)},get size(){return i.length}}}async function Lu(){let e=await eo();if(e.state===`starting`){let t=await no({first:e});return t?.state===`proxy`?(await t.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1):(t?.state===`foreign`&&Bu(),t==null&&await qa()!==null?(M(`已有 daemon 持有端口,本次启动跳过`),!1):!0)}return e.state===`proxy`?(await e.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1):(e.state===`foreign`&&Bu(),!0)}async function Ru(e){if(!await Lu()){await $a();return}await Ro(),e.start(ma),M(`daemon: 插件 WS ws://localhost:${e.port}`);let t=await tu(),n=(e,t)=>{if(t!=null)try{t.attach(e)}catch(e){P(`skills 挂载失败(该实例继续提供工具): ${e instanceof Error?e.message:String(e)}`)}},r=Iu(()=>{let r=su(e);return n(r,t),r}),i=new Se,a=ge(()=>{let e=i.getStore();if(e==null)throw Error(`Missing MCP server lease`);return e.server},{legacy:`reject`}),o=Te({fetch:async(e,t)=>{let n=await a.fetch(e,t),r=i.getStore();return r!=null&&!r.server.isConnected()&&r.release(),n}});Xa();let s=Ce(),c=we(),l=null,d=null,f=null,p=()=>{Fu().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){M(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),M(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=()=>{e.pushConsent({type:`consent`,granted:zo(),asked:Bo()}),p()},e.onConsentSet=t=>{Vo(t),M(`错误上报同意: ${t?`开启`:`关闭`}`),e.pushConsent({type:`consent`,granted:t,asked:!0})},process.on(`uncaughtException`,e=>{ku({level:`fatal`,message:e.message,stack:e.stack,scope:`daemon`}),ju(3e3).finally(()=>process.exit(1))}),process.on(`unhandledRejection`,e=>{ku({level:`fatal`,message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0,scope:`daemon`}),ju(3e3).finally(()=>process.exit(1))});let g=t=>{M(`daemon 退出: ${t}`),d!=null&&clearInterval(d),f?.close(),Mu(),ju(1500).finally(()=>{a.close().catch(e=>{N(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),l?.close(),process.exit(0)})};await new Promise((e,t)=>{l=ne((e,t)=>{if(!s(e,t)||!c(e,t))return;let n=Date.now(),a=e.url??``;if(t.on(`finish`,()=>{let r=`HTTP ${e.method} ${a} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?M(r):N(r)}),e.method===`GET`&&a===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:ha,version:L,pid:process.pid,startedAt:_a}));return}if(e.method===`POST`&&a===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>g(`收到 /shutdown 请求`),100);return}let l=r.acquire();if(l==null){t.writeHead(503,{"content-type":`application/json`,"retry-after":`1`}),t.end(JSON.stringify({jsonrpc:`2.0`,id:null,error:{code:-32603,message:`MCP server busy; retry later`}}));return}i.run(l,async()=>{try{await o(e,t)}catch(e){P(`HTTP handler failed: ${String(e)}`),t.destroy()}finally{l.release(),ee()}})}),l.once(`error`,t),l.listen(I,`127.0.0.1`,()=>e())}),M(`daemon: MCP HTTP http://127.0.0.1:${I}/mcp`),M(`daemon 就绪,常驻运行(shim 重启时轮换到新构建)`),d=setInterval(p,Ie),p();let _=!1,ee=()=>{if(!_)return;let e=r.acquire();e!=null&&(e.release(),_=!1,P(`shim 已换上当前构建,常驻 daemon 退出轮换`),g(`shim 请求轮换`))},te=()=>{Za()!=null&&(_=!0,ee())},v=Ya();try{f=u(h(v),(e,t)=>{(t==null||t===m(v))&&te()}),f.on(`error`,e=>N(`退役标记监听失败(只剩 shim 下次启动时轮换): ${String(e)}`))}catch(e){N(`装不上退役标记监听: ${String(e)}`)}te(),process.on(`SIGINT`,()=>g(`SIGINT`))}async function zu(){try{d(Ya(),String(_a))}catch{N(`自检标记写不进去(只读安装?),交给产物自检兜底`);return}let e=Date.now()+ya;for(;Date.now()<e;)if(await to(250),await qa()==null)return;P(`daemon 在 ${ya/1e3}s 内未退役,交给产物自检继续兜底`)}function Bu(){F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)}function Vu(){F(`daemon 启动超时(${va/1e3}s),请检查残留进程后重试`),process.exit(1)}async function Hu(){await $a();let e=await eo();if(e.state===`foreign`&&Bu(),e.state===`proxy`){if(await Qa()==null){M(`复用常驻 daemon(已跑在当前构建上,不轮换)`),await No(e.client);return}await e.client.close().catch(()=>{}),await zu();let t=await no();if(t?.state===`proxy`){await No(t.client);return}t?.state===`foreign`&&Bu(),t??Vu()}e.state===`none`?M(`未发现 daemon,自动拉起...`):M(`daemon 正在启动,等待就绪...`);let t=await no({spawnIfNone:!0,first:e});if(t?.state===`proxy`){await No(t.client);return}t?.state===`foreign`&&Bu(),Vu()}var $=`text-to-design-mcp`;function Uu(e){return e.includes(` `)?`"${e}"`:e}function Wu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Gu(){let e=ee(process.argv[1]??``),t=process.execPath;return e?e.endsWith(`.ts`)?{problem:`当前是开发态(tsx 直接跑 TS 源码),不能注册自启。请改用构建产物(pnpm build 后 node dist/index.js install-service)或全局安装的 text-to-design-mcp`}:e.split(te).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Ku(e){return e===`linux`?_(f(),`.config/systemd/user`,`${$}.service`):_(f(),`Library/LaunchAgents`,`com.${$}.plist`)}function qu(e,t){return[{kind:`write`,path:Ku(`linux`),content:`[Unit]
|
|
27
27
|
Description=${ha} (design plugin bridge: WS ${ma} / MCP HTTP ${I})
|
|
28
28
|
Documentation=https://github.com/wzrove/text-to-design
|
|
29
29
|
After=network.target
|
|
@@ -31,13 +31,13 @@ After=network.target
|
|
|
31
31
|
[Service]
|
|
32
32
|
Type=simple
|
|
33
33
|
Environment=TEXT_TO_DESIGN_MCP_ROLE=daemon
|
|
34
|
-
ExecStart=${
|
|
34
|
+
ExecStart=${Uu(e)} ${Uu(t)} daemon
|
|
35
35
|
Restart=on-failure
|
|
36
36
|
RestartSec=2
|
|
37
37
|
|
|
38
38
|
[Install]
|
|
39
39
|
WantedBy=default.target
|
|
40
|
-
`},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]},{kind:`run`,cmd:`systemctl`,args:[`--user`,`enable`,`--now`,`${$}.service`]},{kind:`note`,line:`注销后仍要保持常驻:loginctl enable-linger ${process.env.USER??`$USER`}(否则只在登录会话内运行)`}]}function
|
|
40
|
+
`},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]},{kind:`run`,cmd:`systemctl`,args:[`--user`,`enable`,`--now`,`${$}.service`]},{kind:`note`,line:`注销后仍要保持常驻:loginctl enable-linger ${process.env.USER??`$USER`}(否则只在登录会话内运行)`}]}function Ju(e,t){let n=Ku(`darwin`),r=_(f(),`Library/Logs`,`${$}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
41
41
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
42
42
|
<plist version="1.0">
|
|
43
43
|
<dict>
|
|
@@ -45,8 +45,8 @@ WantedBy=default.target
|
|
|
45
45
|
<string>com.${$}</string>
|
|
46
46
|
<key>ProgramArguments</key>
|
|
47
47
|
<array>
|
|
48
|
-
<string>${
|
|
49
|
-
<string>${
|
|
48
|
+
<string>${Wu(e)}</string>
|
|
49
|
+
<string>${Wu(t)}</string>
|
|
50
50
|
<string>daemon</string>
|
|
51
51
|
</array>
|
|
52
52
|
<key>EnvironmentVariables</key>
|
|
@@ -62,12 +62,12 @@ WantedBy=default.target
|
|
|
62
62
|
<false/>
|
|
63
63
|
</dict>
|
|
64
64
|
<key>StandardOutPath</key>
|
|
65
|
-
<string>${
|
|
65
|
+
<string>${Wu(r)}</string>
|
|
66
66
|
<key>StandardErrorPath</key>
|
|
67
|
-
<string>${
|
|
67
|
+
<string>${Wu(r)}</string>
|
|
68
68
|
</dict>
|
|
69
69
|
</plist>
|
|
70
|
-
`;return[{kind:`run`,cmd:`launchctl`,args:[`unload`,n]},{kind:`write`,path:n,content:i},{kind:`run`,cmd:`launchctl`,args:[`load`,`-w`,n]},{kind:`note`,line:`输出日志:${r}`}]}function
|
|
71
|
-
`);return}let i=await
|
|
72
|
-
`);process.stderr.write(`\n${t}\n`)}}let a=e.structuredContent?.ok===!1;(e.isError===!0||a)&&(process.exitCode=1)}finally{await i.close().catch(()=>{})}}async function
|
|
73
|
-
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await
|
|
70
|
+
`;return[{kind:`run`,cmd:`launchctl`,args:[`unload`,n]},{kind:`write`,path:n,content:i},{kind:`run`,cmd:`launchctl`,args:[`load`,`-w`,n]},{kind:`note`,line:`输出日志:${r}`}]}function Yu(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,$,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${$}`}]}function Xu(e,t){return process.platform===`linux`?qu(e,t):process.platform===`darwin`?Ju(e,t):process.platform===`win32`?Yu(e,t):[]}function Zu(){if(process.platform===`linux`){let e=Ku(`linux`);return[{kind:`run`,cmd:`systemctl`,args:[`--user`,`disable`,`--now`,`${$}.service`]},{kind:`rm`,path:e},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]}]}if(process.platform===`darwin`){let e=Ku(`darwin`);return[{kind:`run`,cmd:`launchctl`,args:[`unload`,`-w`,e]},{kind:`rm`,path:e}]}return process.platform===`win32`?[{kind:`run`,cmd:`schtasks`,args:[`/Delete`,`/F`,`/TN`,$]}]:[]}function Qu(e,t){if(e.kind===`note`){M(`提示:${e.line}`);return}if(e.kind===`write`){if(t){M(`[dry-run] 写入 ${e.path}`),M(e.content.trimEnd());return}a(h(e.path),{recursive:!0}),d(e.path,e.content,`utf8`),M(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){M(`[dry-run] 删除 ${e.path}`);return}c(e.path,{force:!0}),M(`已删除 ${e.path}`);return}if(t){M(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let n=se(e.cmd,e.args,{encoding:`utf8`});if(n.error){P(`执行失败(${e.cmd}):${n.error.code??n.error.message} —— 定义文件已就位,可手动启用`);return}if(n.status!==0){P(`${e.cmd} 退出码 ${n.status}: ${(n.stderr??``).trim().slice(0,200)}`);return}M(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function $u(e,t){e.length===0&&(F(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)Qu(n,t)}function ed(e={}){let t=Gu(),n,r;`problem`in t?(e.force||(F(t.problem),process.exit(1)),P(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=ee(process.argv[1]??``)):(n=t.exe,r=t.script),M(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),$u(Xu(n,r),e.dryRun===!0),e.dryRun||M(`完成。校验:curl -s http://127.0.0.1:${I}/health(应返回 ${ha} ${L})`)}function td(e={}){M(`${e.dryRun?`[dry-run] `:``}注销自启`),$u(Zu(),e.dryRun===!0)}async function nd(){let e=await no({spawnIfNone:!0,argv:process.argv.slice(1,2)});if(e?.state===`proxy`)return e.client;throw e?.state===`foreign`?Error(`MCP 端口被**非本项目**的服务占用,exec 不会去猜它是什么。请先释放端口(见 daemon 启动日志里的排查提示)。`):Error(`等待 daemon 就绪超时(${va}ms)。若刚从旧版本升级,旧 daemon 可能还没释放端口,稍后重试即可。`)}function rd(e,t,n,r){let i=e=>{r?process.stderr.write(`${e}\n`):process.stdout.write(`${e}\n`)};i(`清单 ${e}`),i(`共 ${t.length} 步${n?`(任一步失败即停)`:`(失败继续,由单步 continueOnError 决定)`}`);for(let[e,n]of t.entries())i(` ${String(e+1).padStart(2)}. ${n.id==null||n.id===``?`step${e+1}`:n.id} → ${n.tool}`)}async function id(e,t){let n=await Xo(e),r=n.stopOnError??!0;if(rd(n.path,n.calls,r,t.json===!0),t.dryRun===!0){process.stdout.write(`--dry-run:只校验了清单,未连接 daemon,未执行任何步骤。
|
|
71
|
+
`);return}let i=await nd();try{let e=await i.callTool({name:`jsd_batch`,arguments:{calls:n.calls,stopOnError:r,checkDrift:n.checkDrift}},{timeout:Ea+3e4});if(t.json===!0)process.stdout.write(`${JSON.stringify(e.structuredContent??e,null,1)}\n`);else{let t=e.structuredContent;for(let e of t?.results??[])process.stdout.write(` ${e.ok?`ok `:`ERR`} ${e.id} (${e.tool})${e.ok?``:`: ${e.error??``}`}\n`);process.stdout.write(`\n执行 ${t?.executed??0}/${t?.total??n.calls.length}${t?.ok===!1?`,存在失败步骤`:`,全部成功`}\n`);for(let e of t?.warnings??[])process.stdout.write(`warn ${e}\n`);if(e.isError===!0){let t=(e.content??[]).map(e=>`text`in e&&typeof e.text==`string`?e.text:``).join(`
|
|
72
|
+
`);process.stderr.write(`\n${t}\n`)}}let a=e.structuredContent?.ok===!1;(e.isError===!0||a)&&(process.exitCode=1)}finally{await i.close().catch(()=>{})}}async function ad(e){let t=e.find(e=>!e.startsWith(`-`)),n={json:e.includes(`--json`),dryRun:e.includes(`--dry-run`)};if(t==null){F(`用法:text-to-design-mcp exec <calls.json> [--json] [--dry-run]
|
|
73
|
+
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await id(t,n)}catch(e){F(e instanceof Error?e.message:String(e)),process.exitCode=1}}var od=new Ga;od.onConnectionChange=e=>{if(M(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录不变)`),e){za(od);return}Ra(`插件断开`)},ca(e=>{e.level===`error`&&ku(e),od.notifyLog(e)});var sd=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),cd=process.argv.slice(2),ld=cd.find(e=>e===`install-service`||e===`uninstall-service`),ud=cd[0]===`exec`&&!sd;if(ld){ca(e=>{(e.level===`error`||e.level===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${e.message}\n`)});let e={dryRun:cd.includes(`--dry-run`),force:cd.includes(`--force`)};ld===`install-service`?ed(e):td(e)}else ud?(ca(e=>{process.stderr.write(`[text-to-design-mcp] ${e.message}\n`)}),ad(cd.slice(1))):sd?Ru(od).catch(e=>{od.stop(),F(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):Hu().catch(e=>{F(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
|