text-to-design-mcp 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -2
  2. package/dist/index.js +51 -38
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -145,9 +145,8 @@ pkill -f text-to-design-mcp
145
145
  | `jsd_batch` | 批量编排器:一次请求顺序执行多个 jsd_* 步骤,双花括号占位符串起中间值;步骤回显做摘要裁剪(节点只留 id/name/type/x/y,丢 vectorPaths 等大字段,超预算降级为 id 清单),占位符解析用完整数据;含图标的批次另配一次 `jsd_export` 目视验收;含删除/移父的步骤自动复核同层几何漂移(结果 `warnings`,`checkDrift:false` 可关;单工具调用同样会复核) |
146
146
  | `jsd_export` | 导出节点为 PNG/JPG/SVG/PDF(导出失败的 id 在文本里点名) |
147
147
  | `jsd_list_fonts` | 列出可用字体:families 与各族的可用字型 `fonts:[{family,styles}]`(写 fontName 前照这份取组合,family+style 需精确匹配,猜错会静默退回默认字重) |
148
- | `jsd_list_styles` | 列出本地样式(PAINT/TEXT/EFFECT/GRID) |
149
148
  | `jsd_fill_image` | 用本地图片填充节点 |
150
- | `jsd_platform_op` | 平台特有能力的通用通道(Figma 变量/本地样式/组件属性)。先读 `jsd_ping` 的 `platformOps` 名单再传 op 名;插件平台不适用(如即时设计)时由 daemon 直接拦截并给出替代路径,不发插件往返 |
149
+ | `jsd_platform_op` | 平台特有能力的通用通道(Figma 变量/本地样式/组件属性**定义与设值**)。先读 `jsd_ping` 的 `platformOps` 名单再传 op 名;插件平台不适用(如即时设计)时由 daemon 直接拦截并给出替代路径,不发插件往返 |
151
150
 
152
151
  ### 配方 prompt(`prompts/list`)
153
152
 
package/dist/index.js CHANGED
@@ -1,25 +1,46 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import{appendFileSync as t,mkdirSync as n,readFileSync as r,rmSync as i,statSync as a,writeFileSync as o}from"node:fs";import{z as s}from"zod";import{createServer as c}from"node:http";import{WebSocket as l,WebSocketServer as u}from"ws";import{Client as d,StreamableHTTPClientTransport as f}from"@modelcontextprotocol/client";import{McpServer as p,ResourceTemplate as m,SUPPORTED_PROTOCOL_VERSIONS as ee,createMcpHandler as te,fromJsonSchema as ne}from"@modelcontextprotocol/server";import{serveStdio as re}from"@modelcontextprotocol/server/stdio";import{spawn as ie,spawnSync as ae}from"node:child_process";import{localhostHostValidation as oe,localhostOriginValidation as se,toNodeHandler as ce}from"@modelcontextprotocol/node";import{isTag as h}from"domhandler";import{parseDocument as le}from"htmlparser2";import ue from"fuse.js";import{homedir as g,tmpdir as de}from"node:os";import{dirname as fe,join as _,resolve as pe,sep as me}from"node:path";var he=3e4,ge=4e3,_e=3e4,ve=[`styles`,`textTruncation`,`componentProperties`,`variables`,`platformOps`,`inPlaceVariants`],ye=[`create`,`modify`,`structure`,`component`,`export`,`image`];Object.fromEntries(Object.entries({styles:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],textTruncation:[`textTruncation`,`maxLines`],componentProperties:[`componentProperties`],variables:[],platformOps:[],inPlaceVariants:[]}).flatMap(([e,t])=>t.map(t=>[t,e])));var be=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],xe={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},Se=be.join(`/`),Ce=`布尔运算:${be.map(e=>`${e}=${xe[e]}`).join(`,`)}`;function we(e){let t=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());if(t==null)return null;let n=t[1];(n.length===3||n.length===4)&&(n=[...n].map(e=>e+e).join(``));let r=e=>Number.parseInt(e,16)/255,i={r:r(n.slice(0,2)),g:r(n.slice(2,4)),b:r(n.slice(4,6))};return n.length===8&&(i.a=r(n.slice(6,8))),i}var Te=s.object({r:s.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`红色通道,范围 0-1(0=无,1=满),如纯红为 1`),g:s.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`绿色通道,范围 0-1`),b:s.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`蓝色通道,范围 0-1`),a:s.number().min(0).max(1,`alpha 通道最大 1(0-255 请先归一化)`).optional().describe(`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理`)}).strict(),Ee=`颜色需为 {r,g,b[,a]} 对象(通道 0-1,0-255 色值请先除以 255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,De=s.unknown().superRefine((e,t)=>{if(typeof e==`string`){we(e)??t.addIssue({code:s.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${Ee})`});return}let n=Te.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:s.ZodIssueCode.custom,path:e.path,message:e.message})}),Oe=De.describe(`颜色:{r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),ke=De.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),Ae=s.object({color:ke.describe(`该停止点的颜色(带 alpha)`),position:s.number().min(0).max(1).describe(`停止点位置,范围 0-1(0=起点,1=终点)`)}).describe(`渐变停止点,如 {color:{r:1,g:0,b:0,a:1}, position:0}(起点红色)和 {color:{r:0,g:0,b:1,a:1}, position:1}(终点蓝色)`),je=s.array(s.array(s.number()).length(3)).length(2).describe(`变换矩阵,如 [[1,0,0],[0,1,0]] 表示无变换(Identity)`),v=s.enum([`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`]).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),y=s.discriminatedUnion(`type`,[s.object({type:s.literal(`SOLID`).describe(`填充类型:纯色`),color:Oe.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:s.number().min(0).max(1).optional().describe(`不透明度 0-1,缺省 1`),visible:s.boolean().optional().describe(`是否可见,缺省 true`),blendMode:v.optional().describe(`混合模式,缺省 NORMAL`)}).strict().describe(`纯色填充(SOLID):{color:{r,g,b}}`),s.object({type:s.literal(`GRADIENT_LINEAR`).describe(`填充类型:线性渐变`),gradientStops:s.array(Ae).describe(`渐变停止点数组(至少 2 个,定义颜色与位置)`),gradientTransform:je}).strict().describe(`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`),s.object({type:s.literal(`GRADIENT_RADIAL`).describe(`填充类型:径向渐变`),gradientStops:s.array(Ae).describe(`渐变停止点数组(至少 2 个,定义颜色与位置)`),gradientTransform:je}).strict().describe(`径向渐变(GRADIENT_RADIAL):从中心向外辐射`),s.object({type:s.literal(`GRADIENT_ANGULAR`).describe(`填充类型:角度渐变`),gradientStops:s.array(Ae).describe(`渐变停止点数组(至少 2 个,定义颜色与位置)`),gradientTransform:je}).strict().describe(`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`),s.object({type:s.literal(`IMAGE`).describe(`填充类型:图片填充`),imageHash:s.string().describe(`图片资源哈希(由 jsd_fill_image 等注入)`),scaleMode:s.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`)}).strict().describe(`图片填充(IMAGE):以 imageHash 引用图片`)]),Me=s.discriminatedUnion(`type`,[s.object({type:s.literal(`DROP_SHADOW`).describe(`效果类型:外阴影(投影到节点外侧)`),color:ke.describe(`阴影颜色(带 alpha 透明度)`),offset:s.object({x:s.number().describe(`水平偏移(px),正值向右`),y:s.number().describe(`垂直偏移(px),正值向下`)}).describe(`阴影偏移向量(px)`),radius:s.number().min(0).describe(`模糊半径(px),>=0`),spread:s.number().optional().describe(`扩散(px),正值扩大阴影、负值收缩,默认 0`),visible:s.boolean().optional().describe(`是否可见,默认 true`),blendMode:v.default(`NORMAL`).describe(`混合模式,默认 NORMAL`),showShadowBehindNode:s.boolean().optional().describe(`是否在节点后方显示阴影(即便节点不透明也透出)`)}).strict().describe(`外阴影(DROP_SHADOW):投影到节点外侧的阴影`),s.object({type:s.literal(`INNER_SHADOW`).describe(`效果类型:内阴影(投影到节点内侧)`),color:ke.describe(`阴影颜色(带 alpha 透明度)`),offset:s.object({x:s.number().describe(`水平偏移(px),正值向右`),y:s.number().describe(`垂直偏移(px),正值向下`)}).describe(`阴影偏移向量(px)`),radius:s.number().min(0).describe(`模糊半径(px),>=0`),spread:s.number().optional().describe(`扩散(px),正值扩大、负值收缩,默认 0`),visible:s.boolean().optional().describe(`是否可见,默认 true`),blendMode:v.default(`NORMAL`).describe(`混合模式,默认 NORMAL`)}).strict().describe(`内阴影(INNER_SHADOW):投影到节点内侧的阴影`),s.object({type:s.literal(`LAYER_BLUR`).describe(`效果类型:图层模糊(模糊整个节点本身)`),radius:s.number().min(0).describe(`模糊半径(px),>=0`),visible:s.boolean().optional().describe(`是否可见,默认 true`)}).strict().describe(`图层模糊(LAYER_BLUR):模糊节点自身`),s.object({type:s.literal(`BACKGROUND_BLUR`).describe(`效果类型:背景模糊(模糊节点背后的内容)`),radius:s.number().min(0).describe(`模糊半径(px),>=0`),visible:s.boolean().optional().describe(`是否可见,默认 true`)}).strict().describe(`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`)]),b=s.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),Ne=s.object({pattern:s.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`网格类型:ROWS|COLUMNS|GRID`),alignment:s.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`对齐:MIN|MAX|CENTER|STRETCH`),sectionSize:s.number().optional().describe(`分节尺寸(px)`),count:s.number().int().positive().optional(),gutterSize:s.number().optional().describe(`沟槽尺寸(px)`),offset:s.number().optional().describe(`偏移(px)`),visible:s.boolean().optional(),color:ke.optional()}).superRefine((e,t)=>{e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:s.ZodIssueCode.custom,message:`pattern 为 GRID 时,sectionSize 为必填项`,path:[`sectionSize`]})}),Pe=s.object({data:s.string().describe(`SVG path data,如 "M0 0 L100 0 L100 100 Z"(M=移动到,L=画线到,Z=闭合)。仅支持 M/L/Q/C/Z 指令(SVG 子集,不支持 A 圆弧等);完整 SVG 请改用 jsd_create_svg`),windingRule:s.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`)}),Fe=s.object({family:s.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:s.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),Ie=s.union([s.object({value:s.number().describe(`行高数值(px)`),unit:s.literal(`PIXELS`).describe(`单位:PIXELS=固定像素`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),s.object({value:s.number().describe(`行高数值(百分比)`),unit:s.literal(`PERCENT`).describe(`单位:PERCENT=百分比`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),s.object({unit:s.literal(`AUTO`).describe(`单位:AUTO=自动行高`)}).describe(`自动行高:{unit: "AUTO"},无需传 value`)]),Le=s.object({value:s.number(),unit:s.enum([`PIXELS`,`PERCENT`]).describe(`单位:PIXELS=像素 | PERCENT=百分比`)}),Re=s.object({id:s.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:s.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:s.record(s.string(),s.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符(步骤id.字段路径)引用先前步骤结果`),continueOnError:s.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),ze=s.object({calls:s.array(Re).min(1).max(50).describe(`按数组顺序执行的步骤列表`),stopOnError:s.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:s.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),Be=s.object({ok:s.boolean().describe(`全部步骤均执行且成功(executed 小于 total 即为中途停止)`),executed:s.number().int().min(0).describe(`实际产生结果的步骤数`),total:s.number().int().min(0).describe(`计划的步骤总数`),results:s.array(s.object({id:s.string(),tool:s.string(),ok:s.boolean(),data:s.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:s.string().optional().describe(`失败原因(人读文本)`)})).describe(`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`),echoTrimmed:s.boolean().optional(),warnings:s.array(s.string()).optional()}),Ve=s.object({ok:s.boolean(),data:s.unknown().optional()}),x=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],He={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},Ue=`节点类型:${x.map(e=>`${e}=${He[e]}`).join(` | `)}`,We=[`TEXT_PATH`,`TRANSFORM_GROUP`,`STICKY`,`CONNECTOR`,`SHAPE_WITH_TEXT`,`CODE_BLOCK`,`STAMP`,`WIDGET`,`EMBED`,`LINK_UNFURL`,`MEDIA`,`SECTION`,`HIGHLIGHT`,`WASHI_TAPE`,`TABLE`,`SLIDE`,`SLIDE_ROW`,`SLIDE_GRID`,`SLOT`,`INTERACTIVE_SLIDE_ELEMENT`],Ge=[...x,...We],Ke=s.enum(x).describe(Ue),qe=s.enum(Ge).describe(`${Ue};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),Je=s.object({type:Ke.describe(`子节点类型`),name:s.string().optional(),x:s.number().optional().describe(`相对父节点的 X(px)`),y:s.number().optional().describe(`相对父节点的 Y(px)`),width:s.number().optional(),height:s.number().optional()}).catchall(s.unknown()),S={name:s.string().optional(),x:s.number().optional().describe(`X 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`),y:s.number().optional().describe(`Y 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`),width:s.number().optional().describe(`宽度(px)`),height:s.number().optional().describe(`高度(px)`),rotation:s.number().optional().describe(`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`),opacity:s.number().optional().describe(`不透明度 0-1`),visible:s.boolean().optional(),locked:s.boolean().optional(),isMask:s.boolean().optional(),children:s.array(Je).max(100).optional().describe(`子节点数组(递归嵌套,最多 100 个直接子节点;更大的结构建议分批创建后用 jsd_manage_nodes op=reparent 归组)。子节点可使用的字段与顶层 create 入参一致(fills/strokes/cornerRadius/effects 等均可用);x/y 相对父节点,未传 x/y 会叠放在父节点原点(0,0)——非 auto-layout 容器需为每个子节点指定相对坐标`)},C={fills:s.array(y).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:s.array(y).optional().describe(`描边列表(Paint 数组)`),strokeWeight:s.number().optional().describe(`描边宽度(px)`),strokeTopWeight:s.number().optional().describe(`描边顶部宽(px)`),strokeBottomWeight:s.number().optional().describe(`描边底部宽(px)`),strokeLeftWeight:s.number().optional().describe(`描边左侧宽(px)`),strokeRightWeight:s.number().optional().describe(`描边右侧宽(px)`),strokeAlign:s.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`描边对齐:CENTER|INSIDE|OUTSIDE`),strokeCap:s.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`),strokeJoin:s.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`描边连接:MITER|BEVEL|ROUND`),dashPattern:s.array(s.number()).optional().describe(`虚线段数组,如 [4,4]`),blendMode:v.optional(),effects:s.array(Me).optional().describe(`效果列表(阴影/模糊,可多层叠加)`),constraints:s.object({horizontal:b.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:b.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`自动布局中的约束`),clipsContent:s.boolean().optional().describe(`是否裁剪溢出内容`),cornerSmoothing:s.number().optional().describe(`圆角平滑度 0-1`),layoutGrids:s.array(Ne).optional().describe(`布局网格(参考线)`)},Ye={cornerRadius:s.number().optional().describe(`圆角半径(px),四角统一`),topLeftRadius:s.number().optional().describe(`左上圆角(px)`),topRightRadius:s.number().optional().describe(`右上圆角(px)`),bottomLeftRadius:s.number().optional().describe(`左下圆角(px)`),bottomRightRadius:s.number().optional().describe(`右下圆角(px)`)},Xe=s.object({type:s.literal(`FRAME`),...S,layoutMode:s.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:s.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:s.number().optional().describe(`上内边距(px)`),paddingRight:s.number().optional().describe(`右内边距(px)`),paddingBottom:s.number().optional().describe(`下内边距(px)`),paddingLeft:s.number().optional().describe(`左内边距(px)`),primaryAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`主轴尺寸模式:FIXED|AUTO`),counterAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`交叉轴尺寸模式:FIXED|AUTO`),primaryAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`交叉轴对齐:MIN|MAX|CENTER`),layoutGrow:s.number().optional().describe(`自动布局内伸缩系数`),layoutAlign:s.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`),...Ye,...C}).strict().superRefine((e,t)=>{(e.itemSpacing!=null||e.paddingTop!=null||e.paddingRight!=null||e.paddingBottom!=null||e.paddingLeft!=null||e.primaryAxisSizingMode!=null||e.counterAxisSizingMode!=null||e.primaryAxisAlignItems!=null||e.counterAxisAlignItems!=null)&&(e.layoutMode==null||e.layoutMode===`NONE`)&&t.addIssue({code:s.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).strict().describe(`FRAME=容器(可 auto-layout)。注意:未显式传 fills 时引擎默认白底,透明容器请显式传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]`),Ze=s.object({type:s.literal(`RECTANGLE`),...S,...Ye,...C}).strict().describe(`RECTANGLE=矩形`),Qe=s.object({type:s.literal(`ELLIPSE`),...S,cornerRadius:s.number().optional().describe(`圆角半径(px)`),arcData:s.object({startingAngle:s.number().describe(`起始角度(radians)`),endingAngle:s.number().describe(`结束角度(radians)`),innerRadius:s.number().describe(`内半径(0-1 ratio)`)}).optional().describe(`环形路径参数(弧线),可画圆环`),...C}).strict().describe(`ELLIPSE=椭圆(配合 arcData 可画环)`),$e=s.object({type:s.literal(`LINE`),...S,...C}).strict().describe(`LINE=线段`),et=s.object({type:s.literal(`POLYGON`),...S,pointCount:s.number().describe(`多边形角点数,如 6=六边形`),cornerRadius:s.number().optional().describe(`圆角半径(px)`),topLeftRadius:s.number().optional().describe(`左上圆角(px)`),topRightRadius:s.number().optional().describe(`右上圆角(px)`),bottomLeftRadius:s.number().optional().describe(`左下圆角(px)`),bottomRightRadius:s.number().optional().describe(`右下圆角(px)`),...C}).strict().describe(`POLYGON=多边形(配合 pointCount)`),tt=s.object({type:s.literal(`STAR`),...S,pointCount:s.number().describe(`星形角点数,如 5=五角星`),innerRadius:s.number().describe(`星形内半径比例(0-1,相对外半径),值越小角越尖锐`),cornerRadius:s.number().optional().describe(`圆角半径(px)`),topLeftRadius:s.number().optional().describe(`左上圆角(px)`),topRightRadius:s.number().optional().describe(`右上圆角(px)`),bottomLeftRadius:s.number().optional().describe(`左下圆角(px)`),bottomRightRadius:s.number().optional().describe(`右下圆角(px)`),...C}).strict().describe(`STAR=星形(配合 pointCount + innerRadius)`),nt=s.object({type:s.literal(`VECTOR`),...S,vectorPaths:s.array(Pe).describe(`矢量路径数组,每项含 SVG path data(如 "M0 0 L100 100")`),...C}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),rt=s.object({type:s.literal(`TEXT`),...S,characters:s.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:s.number().optional().describe(`字号(px),默认 16`),fontName:Fe.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:s.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`),textAlignVertical:s.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`垂直对齐:TOP|CENTER|BOTTOM`),textAutoResize:s.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:s.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`),textDecoration:s.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`),lineHeight:Ie.optional().describe(`行高:{value,unit},unit 为 PIXELS|PERCENT;或 {unit:"AUTO"}`),letterSpacing:Le.optional().describe(`字距:{value,unit},unit 为 PIXELS|PERCENT`),...C}).strict().describe(`TEXT=文本(配合 characters/fontSize/fontName 等)`),it=s.object({type:s.literal(`GROUP`),...S,children:s.array(Je).min(2).max(100).describe(`子节点数组,至少 2 个;递归嵌套,最多 100 个直接子节点`),layoutMode:s.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:s.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:s.number().optional().describe(`上内边距(px)`),paddingRight:s.number().optional().describe(`右内边距(px)`),paddingBottom:s.number().optional().describe(`下内边距(px)`),paddingLeft:s.number().optional().describe(`左内边距(px)`),primaryAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`主轴尺寸模式:FIXED|AUTO`),counterAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`交叉轴尺寸模式:FIXED|AUTO`),primaryAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`交叉轴对齐`),...C}).strict().superRefine((e,t)=>{(e.itemSpacing!=null||e.paddingTop!=null||e.paddingRight!=null||e.paddingBottom!=null||e.paddingLeft!=null||e.primaryAxisSizingMode!=null||e.counterAxisSizingMode!=null||e.primaryAxisAlignItems!=null||e.counterAxisAlignItems!=null)&&(e.layoutMode==null||e.layoutMode===`NONE`)&&t.addIssue({code:s.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`GROUP=分组(内部用 Frame 实现)`),at=s.object({type:s.literal(`BOOLEAN_OPERATION`),...S,booleanOperation:s.enum(be).describe(Ce),children:s.array(Je).min(2).describe(`要合并的子节点数组(至少 2 个)`),...C}).strict().describe(`BOOLEAN_OPERATION=布尔运算(合并子节点)`),ot=s.discriminatedUnion(`type`,[Xe,Ze,Qe,$e,et,tt,nt,rt,it,at]),st=s.object({mode:s.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:s.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:s.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:s.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});s.object({ops:s.array(ot).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:st.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict();var ct=s.object({svg:s.string().describe(`完整 SVG 字符串,如 <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M0 0 L100 0 L100 100 Z" fill="#ff0000"/></svg>`),name:s.string().optional().describe(`生成的图层名,默认 svg-design`)}),lt=s.object({html:s.string().describe(`HTML 片段,支持内联 style`),name:s.string().optional().describe(`生成的图层名,默认 html-design`)}),ut=s.object({icon:s.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:s.number().optional().describe(`图标边长 px,默认 24`),color:s.string().optional().describe(`描边颜色(十六进制),默认 #000000`),strokeWidth:s.number().optional().describe(`描边宽度,默认 2`),name:s.string().optional().describe(`生成的图层名,默认 icon-<图标名>`)});s.object({}),s.object({depth:s.number().optional().describe(`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`)});var dt=[`page`,`document`],ft=Ge.slice(x.length).join(`/`),pt=s.object({ids:s.array(s.string()).optional().describe(`按节点 id 精确查找,优先级最高`),name:s.string().optional().describe(`按名称模糊匹配(包含)`),type:s.string().optional().describe(`节点类型过滤,支持:${x.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${ft}),这些类型能读不能建`),scope:s.enum(dt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)`),recursive:s.boolean().optional().describe(`是否递归查找(默认 true)`),depth:s.number().optional().describe(`序列化深度:0=仅自身,1=含直接子节点;缺省 1`)}),mt=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],ht=s.object({op:s.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return mt.includes(n)?`"${n}" 是组件/实例操作,应使用 jsd_manage_components;本工具仅支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair`:`无效 op${n===``?`(缺省)`:` "${n}"`},本工具支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair(组件/实例操作在 jsd_manage_components)`}}).describe(`节点结构操作类型:select 设当前选中 | remove 删除(matchName 可再过滤) | clone 复制(右下偏移) | group 编组(可带 layoutMode/itemSpacing/padding* 参数) | ungroup 解组 | flatten 合并为矢量(至少 2 节点) | outline_stroke 描边转轮廓 | reparent 移到 parentId 下(缺省当前选中第一个) | repair 清理已损坏节点`),ids:s.array(s.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:s.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:s.string().optional().describe(`仅 group:组名`),layoutMode:s.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:s.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:s.number().optional().describe(`仅 group。上内边距(px)`),paddingRight:s.number().optional().describe(`仅 group。右内边距(px)`),paddingBottom:s.number().optional().describe(`仅 group。下内边距(px)`),paddingLeft:s.number().optional().describe(`仅 group。左内边距(px)`),primaryAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`仅 group。主轴尺寸模式:FIXED|AUTO`),counterAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`仅 group。交叉轴尺寸模式:FIXED|AUTO`),primaryAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`仅 group。交叉轴对齐:MIN|MAX|CENTER`),parentId:s.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:s.number().optional().describe(`仅 reparent:插入位置 = children 下标(0 = 最底层,末位 = 最上层,即序列化里的 z);缺省追加到末尾(最上层)。节点已在该父级下时用它调层序;auto-layout 容器同样支持`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`select`:case`clone`:case`group`:case`ungroup`:case`flatten`:case`outline_stroke`:case`reparent`:r||n(`ids`)}e.op===`flatten`&&r&&Array.isArray(e.ids)&&e.ids.length<2&&t.addIssue({code:`custom`,path:[`ids`],message:`op=flatten 至少需要 2 个节点 id`})}),gt=s.object({op:s.enum([`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`]).describe(`组件操作类型;注意 combine_as_variants/detach_instance 在当前即时设计引擎有内部崩溃,已内置多姿势/副本兜底,仍失败时详见 jsd_manage_components 工具描述`),ids:s.array(s.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:s.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:s.string().optional().describe(`团队库组件唯一标识 Key(仅 import_component 必填)`),componentId:s.string().optional().describe(`目标组件(COMPONENT)节点 id(仅 swap_component 必填)`),properties:s.record(s.string(),s.string()).optional().describe(`变体属性名→值,如 {"状态":"禁用"}(仅 set_instance_properties 必填);可调属性需从 jsd_find/jsd_get_selection 返回的 variantGroupProperties 获取,属性名必须完全匹配`),sourceId:s.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:s.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`create_component`:case`create_instance`:case`detach_instance`:case`swap_component`:case`set_instance_properties`:case`combine_as_variants`:r||n(`ids`);break;case`import_component`:(typeof e.key!=`string`||e.key.length===0)&&n(`key`);break;case`copy_overrides`:(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`apply_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`sync_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`)}e.op===`swap_component`&&typeof e.componentId!=`string`&&n(`componentId`),e.op===`set_instance_properties`&&(e.properties==null||typeof e.properties!=`object`)&&n(`properties`)}),_t=s.object({ids:s.array(s.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:s.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`导出格式,默认 PNG`),scale:s.number().optional().describe(`缩放倍率(PNG/JPG),默认 1`),savePath:s.string().optional().describe(`落盘文件绝对路径,如 /tmp/icon.png`),includeDataUrl:s.boolean().optional().describe(`是否同时返回 base64 dataURL,默认 false`)});s.object({}),s.object({}),s.object({});var vt=s.object({ids:s.array(s.string()).describe(`要填充图片的节点 id 列表`),sourcePath:s.string().describe(`本地图片文件绝对路径,如 /tmp/poster.png`)}),yt=s.object({op:s.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:s.record(s.string(),s.unknown()).optional().describe(`操作参数,结构随 op 而定`)}),bt=[`jsdesign`,`figma`],xt={jsdesign:`即时设计`,figma:`Figma`},St=s.enum(bt),Ct=s.enum(ve),wt=s.enum(ye),Tt=s.object({name:s.string().describe(`op 名,调用 jsd_platform_op 时原样传`),title:s.string(),description:s.string().describe(`含 params 形状说明`)}),Et=s.object({type:s.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`]),value:s.union([s.boolean(),s.string()]),preferredValues:s.array(s.object({type:s.enum([`COMPONENT`,`COMPONENT_SET`]),key:s.string()})).optional()}),w=s.lazy(()=>s.object({id:s.string(),name:s.string(),type:qe,x:s.number(),y:s.number(),width:s.number().optional(),height:s.number().optional(),rotation:s.number().optional(),opacity:s.number().optional(),visible:s.boolean().optional(),locked:s.boolean().optional(),parentId:s.string().optional(),z:s.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:s.array(y).optional(),strokes:s.array(y).optional(),strokeWeight:s.number().optional(),strokeTopWeight:s.number().optional(),strokeBottomWeight:s.number().optional(),strokeLeftWeight:s.number().optional(),strokeRightWeight:s.number().optional(),strokeAlign:s.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:s.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:s.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:s.array(s.number()).optional(),cornerSmoothing:s.number().optional(),blendMode:v.optional(),constraints:s.object({horizontal:b,vertical:b}).optional(),layoutGrids:s.array(Ne).optional(),clipsContent:s.boolean().optional(),arcData:s.object({startingAngle:s.number(),endingAngle:s.number(),innerRadius:s.number()}).optional(),effects:s.array(Me).optional(),cornerRadius:s.number().optional(),topLeftRadius:s.number().optional(),topRightRadius:s.number().optional(),bottomLeftRadius:s.number().optional(),bottomRightRadius:s.number().optional(),pointCount:s.number().optional(),innerRadius:s.number().optional(),layoutMode:s.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:s.number().optional(),paddingTop:s.number().optional(),paddingRight:s.number().optional(),paddingBottom:s.number().optional(),paddingLeft:s.number().optional(),primaryAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:s.number().optional(),layoutAlign:s.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:s.number().optional(),children:s.array(w).optional(),characters:s.string().optional(),fontSize:s.number().optional(),fontName:Fe.optional(),textAlignHorizontal:s.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:s.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:s.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:s.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:s.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:Ie.optional(),letterSpacing:Le.optional(),vectorPaths:s.array(Pe).optional(),booleanOperation:s.enum(be).optional(),isMask:s.boolean().optional(),variantProperties:s.record(s.string(),s.string()).optional(),mainComponentId:s.string().optional(),variantGroupProperties:s.record(s.string(),s.array(s.string())).optional(),textTruncation:s.enum([`DISABLED`,`ENDING`]).optional(),maxLines:s.number().optional(),fillStyleId:s.string().optional(),strokeStyleId:s.string().optional(),textStyleId:s.string().optional(),effectStyleId:s.string().optional(),componentProperties:s.record(s.string(),Et).optional()})),Dt=s.object({created:s.union([w,s.array(w)]),warnings:s.array(s.string()).optional()}),Ot=s.object({updated:s.array(w),warnings:s.array(s.string()).optional()}),kt=s.object({connected:s.boolean(),platform:St.optional(),capabilities:s.array(Ct).optional().describe(`当前平台支持的能力列表(先查此字段再决定能否调用平台特有操作)`),coreCapabilities:s.array(wt).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:s.array(Tt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:s.string().optional()}),At=s.object({selection:s.array(w),pageName:s.string()}),jt=s.object({nodes:s.array(w),total:s.number(),scope:s.enum(dt).optional(),note:s.string().optional()}),Mt=s.object({selected:s.array(s.string()).optional(),removed:s.array(s.string()).optional(),ungrouped:s.array(s.string()).optional(),moved:s.array(w).optional(),updated:s.array(w).optional(),cleaned:s.array(s.string()).optional(),created:s.union([w,s.array(w)]).optional()}),Nt=s.object({variantProperties:s.record(s.string(),s.string()).optional(),componentProperties:s.record(s.string(),Et).optional(),propsSummary:s.array(s.string()).optional()}),Pt=s.object({instanceId:s.string(),instanceName:s.string(),ok:s.boolean(),message:s.string().optional()}),Ft=s.object({created:s.union([w,s.array(w)]).optional(),swapped:s.array(w).optional(),updated:s.array(w).optional(),snapshotId:s.string().optional(),sourceName:s.string().optional(),captured:Nt.optional(),applied:s.array(Pt).optional(),source:Nt.optional(),failed:s.array(s.object({id:s.string(),message:s.string()})).optional()}),It=s.object({exports:s.array(s.object({id:s.string(),name:s.string(),format:s.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:s.string(),size:s.number(),path:s.string().optional(),dataUrl:s.string().optional()}))}),Lt=s.object({families:s.array(s.string()).describe(`可用字体族(family)列表`),fonts:s.array(s.object({family:s.string().describe(`字体族`),styles:s.array(s.string()).describe(`该族可用字型,如 ["Regular","Medium","Bold"]`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:s.number().describe(`字体族数量`)});s.object({pageName:s.string(),nodes:s.array(s.object({id:s.string(),name:s.string(),type:qe,x:s.number(),y:s.number(),z:s.number().optional(),width:s.number().optional(),height:s.number().optional(),childCount:s.number().optional()})),count:s.number(),pages:s.array(s.object({name:s.string(),childCount:s.number()})).optional(),note:s.string().optional()}),s.object({styles:s.array(s.object({id:s.string(),name:s.string(),type:s.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])})),count:s.number()});var T=s.object({x:s.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:s.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:s.number().optional().describe(`宽度(px)`),height:s.number().optional().describe(`高度(px)`),rotation:s.number().optional().describe(`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`),opacity:s.number().optional().describe(`不透明度 0-1`),visible:s.boolean().optional(),locked:s.boolean().optional()}),Rt=s.object({width:s.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:s.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),zt=s.object({pointCount:s.number().optional().describe(`多边形/星形角点数(仅 POLYGON/STAR 生效)`),innerRadius:s.number().optional().describe(`星形内半径比例(0-1,相对外半径;仅 STAR 生效)`)}),Bt=s.object({strokes:s.array(y).optional().describe(`描边列表(Paint 数组;整体替换,非合并,需保留的描边要一并传入)`),strokeWeight:s.number().optional().describe(`描边宽度(px)`),strokeTopWeight:s.number().optional().describe(`描边顶部宽(px)`),strokeBottomWeight:s.number().optional().describe(`描边底部宽(px)`),strokeLeftWeight:s.number().optional().describe(`描边左侧宽(px)`),strokeRightWeight:s.number().optional().describe(`描边右侧宽(px)`),strokeAlign:s.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`描边对齐:CENTER|INSIDE|OUTSIDE`),strokeCap:s.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`),strokeJoin:s.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`描边连接:MITER|BEVEL|ROUND`),dashPattern:s.array(s.number()).optional().describe(`虚线段数组,如 [4,4]`),strokeStyleId:s.string().optional().describe(`描边样式 id(团队库样式;平台无此能力时被忽略)`)}),Vt=s.object({cornerRadius:s.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:s.number().optional().describe(`左上圆角(px),适用类型同 cornerRadius`),topRightRadius:s.number().optional().describe(`右上圆角(px),适用类型同 cornerRadius`),bottomLeftRadius:s.number().optional().describe(`左下圆角(px),适用类型同 cornerRadius`),bottomRightRadius:s.number().optional().describe(`右下圆角(px),适用类型同 cornerRadius`)}),Ht=s.object({characters:s.string().optional().describe(`文本内容(仅 TEXT 节点生效)`),fontSize:s.number().optional().describe(`字号(px)`),fontName:Fe.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:s.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`),textAlignVertical:s.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`垂直对齐:TOP|CENTER|BOTTOM`),textAutoResize:s.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:s.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`),textDecoration:s.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`),lineHeight:Ie.optional().describe(`行高:{value,unit}`),letterSpacing:Le.optional().describe(`字距:{value,unit}`),textStyleId:s.string().optional().describe(`文本样式 id(团队库样式;平台无此能力时被忽略)`),textTruncation:s.enum([`DISABLED`,`ENDING`]).optional().describe(`文本截断(DISABLED=不截断,ENDING=末尾省略号截断),仅 Figma 生效`),maxLines:s.number().optional().describe(`文本最大行数,仅 Figma 生效`)}),Ut=s.object({layoutMode:s.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,仅 FRAME 节点生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:s.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:s.number().optional().describe(`上内边距(px)`),paddingRight:s.number().optional().describe(`右内边距(px)`),paddingBottom:s.number().optional().describe(`下内边距(px)`),paddingLeft:s.number().optional().describe(`左内边距(px)`),primaryAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`主轴尺寸模式:FIXED|AUTO`),counterAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`交叉轴尺寸模式:FIXED|AUTO`),primaryAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`交叉轴对齐:MIN|MAX|CENTER`),layoutGrow:s.number().optional().describe(`自动布局内伸缩系数`),layoutAlign:s.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`)}),E=s.object({fills:s.array(y).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:s.string().optional().describe(`填充样式 id(团队库样式;平台无此能力时被忽略)`),blendMode:v.optional(),effectStyleId:s.string().optional().describe(`效果样式 id(团队库样式;平台无此能力时被忽略)`),effects:s.array(Me).optional().describe(`效果列表(阴影/模糊,可多层叠加;整体替换,非合并)`),constraints:s.object({horizontal:b.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:b.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`自动布局中的约束`),clipsContent:s.boolean().optional().describe(`是否裁剪溢出内容`),cornerSmoothing:s.number().optional().describe(`圆角平滑度 0-1`),layoutGrids:s.array(Ne).optional().describe(`布局网格(参考线)`),arcData:s.object({startingAngle:s.number().describe(`起始角度(radians)`),endingAngle:s.number().describe(`结束角度(radians)`),innerRadius:s.number().describe(`内半径(0-1 ratio)`)}).optional().describe(`环形路径参数(弧线),仅 ELLIPSE 节点生效`)}),Wt={ids:s.array(s.string()).min(1).optional().describe(`目标节点 id 列表;缺省时作用于当前选中节点`),matchName:s.string().optional().describe(`按节点 name 精确过滤(精确等值,非模糊/包含),仅命中节点被修改`),recursive:s.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:s.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},D=(e,t=1)=>s.array(s.string()).min(t).describe(e),Gt=s.object({ids:D(`要设为当前选中的节点 id 列表`)}).strict(),Kt=s.object({ids:s.array(s.string()).optional().describe(`要删除的节点 id 列表;缺省时删除当前选中节点`),matchName:s.string().optional().describe(`在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`)}).strict(),qt=s.object({ids:D(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),Jt=s.object({ids:D(`要编组的节点 id 列表,至少 2 个`,2),name:s.string().optional().describe(`组名`),layoutMode:s.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:s.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:s.number().optional().describe(`上内边距(px)`),paddingRight:s.number().optional().describe(`右内边距(px)`),paddingBottom:s.number().optional().describe(`下内边距(px)`),paddingLeft:s.number().optional().describe(`左内边距(px)`),primaryAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`主轴尺寸模式:FIXED|AUTO`),counterAxisSizingMode:s.enum([`FIXED`,`AUTO`]).optional().describe(`交叉轴尺寸模式:FIXED|AUTO`),primaryAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:s.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`交叉轴对齐:MIN|MAX|CENTER`)}).strict(),Yt=s.object({ids:D(`要解组的节点 id 列表`)}).strict(),Xt=s.object({ids:D(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),Zt=s.object({ids:D(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),Qt=s.object({ids:D(`要移动的节点 id 列表`),parentId:s.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:s.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),$t=s.object({ids:s.array(s.string()).optional().describe(`要清理的已损坏节点 id 列表;缺省时清理当前页全部损坏节点`)}).strict(),en=s.object({ids:D(`要固化为组件的节点 id 列表`),name:s.string().optional().describe(`组件名称`)}).strict(),tn=s.object({ids:D(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),nn=s.object({ids:D(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),rn=s.object({key:s.string().describe(`团队库组件唯一标识 Key`),name:s.string().optional().describe(`导入后的节点名称`)}).strict(),an=s.object({ids:D(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:s.string().describe(`目标组件(COMPONENT)节点 id`)}).strict(),on=s.object({ids:D(`要设置变体属性的实例(INSTANCE)节点 id 列表`),properties:s.record(s.string(),s.string()).describe(`变体属性名→值,如 {"状态":"禁用"};可调属性需从 jsd_find / jsd_get_selection 返回的 variantGroupProperties 获取,属性名必须完全匹配`)}).strict(),sn=s.object({ids:D(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:s.string().optional().describe(`变体集名称`)}).strict(),cn=s.object({sourceId:s.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),ln={ids:D(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:s.string().describe(`源实例 id,即先前 copy_overrides 返回的 snapshotId`),swapToSource:s.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},un=s.object(ln).strict(),dn=s.object(ln).strict(),fn={fills:E.shape.fills,fillStyleId:E.shape.fillStyleId,blendMode:E.shape.blendMode},pn={...Bt.shape},mn={cornerRadius:Vt.shape.cornerRadius,topLeftRadius:Vt.shape.topLeftRadius,topRightRadius:Vt.shape.topRightRadius,bottomLeftRadius:Vt.shape.bottomLeftRadius,bottomRightRadius:Vt.shape.bottomRightRadius,cornerSmoothing:E.shape.cornerSmoothing},hn={...Ht.shape},gn={x:T.shape.x,y:T.shape.y,rotation:T.shape.rotation},_n={...Rt.shape,x:T.shape.x,y:T.shape.y},vn={...Ut.shape,constraints:E.shape.constraints},yn={effects:E.shape.effects,effectStyleId:E.shape.effectStyleId,clipsContent:E.shape.clipsContent,layoutGrids:E.shape.layoutGrids,arcData:E.shape.arcData},bn={opacity:T.shape.opacity,visible:T.shape.visible,locked:T.shape.locked},xn={name:s.string().describe(`节点新名称`)},Sn={...zt.shape};function O(e){return s.object({...Wt,...e}).strict()}var Cn=O(fn),wn=O(pn),Tn=O(mn),En=O(hn),Dn=O(gn),On=O(_n),kn=O(vn),An=O(yn),jn=O(bn),Mn=O(xn),Nn=O(Sn),Pn={set_fill:Object.keys(fn),set_stroke:Object.keys(pn),set_corner_radius:Object.keys(mn),set_text:Object.keys(hn),move:Object.keys(gn),resize:Object.keys(_n),set_layout:Object.keys(vn),set_effects:Object.keys(yn),set_visibility:Object.keys(bn),rename:Object.keys(xn),set_shape:Object.keys(Sn)};function k(e){return s.object({...Wt,props:s.object(e).strict()}).strict()}k(fn),k(pn),k(mn),k(hn),k(gn),k(_n),k(vn),k(yn),k(bn),k(xn),k(Sn);function A(e,t,n){e[t]=n}function Fn(e,t,n){return n==null||!(t in e)?!1:(A(e,t,n),!0)}var In={pointCount:[`POLYGON`,`STAR`],innerRadius:[`STAR`],arcData:[`ELLIPSE`],characters:[`TEXT`],fontSize:[`TEXT`],fontName:[`TEXT`],textAlignHorizontal:[`TEXT`],textAlignVertical:[`TEXT`],textAutoResize:[`TEXT`],textCase:[`TEXT`],textDecoration:[`TEXT`],lineHeight:[`TEXT`],letterSpacing:[`TEXT`],textTruncation:[`TEXT`],maxLines:[`TEXT`],layoutMode:[`FRAME`],itemSpacing:[`FRAME`],paddingTop:[`FRAME`],paddingRight:[`FRAME`],paddingBottom:[`FRAME`],paddingLeft:[`FRAME`],primaryAxisSizingMode:[`FRAME`],counterAxisSizingMode:[`FRAME`],primaryAxisAlignItems:[`FRAME`],counterAxisAlignItems:[`FRAME`],cornerRadius:[`FRAME`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`VECTOR`,`BOOLEAN_OPERATION`],cornerSmoothing:[`FRAME`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`VECTOR`,`BOOLEAN_OPERATION`],topLeftRadius:[`FRAME`,`RECTANGLE`],topRightRadius:[`FRAME`,`RECTANGLE`],bottomLeftRadius:[`FRAME`,`RECTANGLE`],bottomRightRadius:[`FRAME`,`RECTANGLE`]};function Ln(e,t){let n=In[e];return n==null||n.some(e=>e===t)}var Rn={id:`layout`,keys:[`layoutMode`,`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`],write(e){let{node:t,src:n,create:r}=e,i=n.layoutMode;if(r){if(i==null)return;`layoutMode`in t&&(t.layoutMode=i);let r=n;`itemSpacing`in t&&(t.itemSpacing=r.itemSpacing??0);for(let e of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])e in t&&A(t,e,r[e]??0);for(let e of[`primaryAxisAlignItems`,`counterAxisAlignItems`])r[e]!=null&&e in t&&A(t,e,r[e]);zn(e);return}for(let e of Rn.keys)n[e]!=null&&Ln(e,t.type)&&Fn(t,e,n[e])},settle(e){let{node:t,src:n}=e;if(n.layoutMode==null||!Ln(`layoutMode`,t.type))return;let r=n.layoutMode;`layoutMode`in t&&t.layoutMode!==r&&(t.layoutMode=r);let i=!(`layoutMode`in t)||t.layoutMode===r;e.outcome.readback.push({key:`layoutMode`,ok:i});for(let r of[`primaryAxisAlignItems`,`counterAxisAlignItems`]){let i=n[r];i!=null&&(r in t&&t[r]!==i&&A(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||t[r]===i}))}}};function zn(e){let{node:t,src:n}=e,r=n.layoutMode===`HORIZONTAL`,i=[[`primaryAxisSizingMode`,r?n.width!=null:n.height!=null],[`counterAxisSizingMode`,r?n.height!=null:n.width!=null]];for(let[e,r]of i)r&&n[e]==null&&e in t&&A(t,e,`FIXED`)}var Bn=new Set(`fills.strokes.strokeWeight.strokeTopWeight.strokeBottomWeight.strokeLeftWeight.strokeRightWeight.strokeAlign.strokeCap.strokeJoin.dashPattern.blendMode.effects.cornerRadius.topLeftRadius.topRightRadius.bottomLeftRadius.bottomRightRadius.cornerSmoothing.fontName.fontSize.lineHeight.letterSpacing.textCase.textDecoration.textAlignHorizontal.textAlignVertical`.split(`.`));new Set([...new Set([`fills`,`strokes`,`strokeWeight`,`strokeTopWeight`,`strokeBottomWeight`,`strokeLeftWeight`,`strokeRightWeight`,`strokeAlign`,`strokeCap`,`strokeJoin`,`dashPattern`,`blendMode`,`effects`,`cornerRadius`,`topLeftRadius`,`topRightRadius`,`bottomLeftRadius`,`bottomRightRadius`,`cornerSmoothing`,`clipsContent`,`layoutGrids`,`arcData`])].filter(e=>Bn.has(e)));function Vn(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Bn].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var Hn={debug:0,info:1,warn:2,error:3},Un=process.env.TEXT_TO_DESIGN_MCP_LOG??`/tmp/text-to-design-mcp.log`,Wn=Hn,Gn=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,Kn=null;function qn(e){Kn=e}function Jn(e,n){if(Wn[e]>=Wn[Gn])try{t(Un,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{Kn?.(e,n)}catch{}}function j(e){Jn(`info`,e)}function M(e){Jn(`debug`,e)}function N(e){Jn(`warn`,e)}function P(e){Jn(`error`,e)}var Yn=_e,Xn=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??Yn,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),N(`请求超时: ${a} ${e} 耗时=${Date.now()-c}ms`),n(Error(`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(Error(`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(this.detachAbort(l),j(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(Error(`请求已取消: ${e}`)))}},i.addEventListener(`abort`,l.abort.listener,{once:!0})}this.pending.set(a,l),j(`发出请求: ${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){N(`WS 文本解析失败(${t instanceof Error?t.message:String(t)}): ${e.toString().slice(0,100)}`);return}if(t.type===`request`){t.method===`ping`?(j(`收到 ping 请求: ${t.id} (自动回 pong)`),this.sendFn(JSON.stringify({type:`response`,id:t.id,ok:!0,data:{pong:!0}}))):j(`收到未知请求: ${t.id} ${t.method} (忽略)`);return}if(t.type!==`response`){j(`收到非响应消息: type=${t.type}`);return}let n=this.pending.get(t.id);if(!n){N(`未匹配响应: id=${t.id}(可能已超时或来源不明)`);return}if(t.hasBinary&&(t.binaryCount??1)>0){if(j(`二进制响应开始: id=${t.id} count=${t.binaryCount??1}`),this.binaryTarget){let e=this.binaryTarget;this.binaryTarget=null,N(`二进制响应被覆盖: 旧 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??``}`}`;t.ok?j(r):P(r),t.ok?n.resolve(t.data):n.reject(Error(t.error??`plugin error`))}onBinary(e){if(!this.binaryTarget){N(`孤儿二进制帧 len=${e.byteLength}(无待组装响应,已丢弃)`);return}if(this.binaryTarget.buffers.push(e),j(`二进制帧: 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);j(`二进制组装完成: 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(e);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(Zn(e.data,e.buffers))}};function Zn(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 Qn=`0.8.2`,$n=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),F=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),er=`text-to-design-mcp-server`,I=Qn,tr=Date.now(),nr=15e3,rr=6e3,ir=5e3,ar=6e4,or=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),sr=12e4,cr={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},L=null,lr=null;function ur(){return L}function dr(){let e=L?.platform;if(e==null)return{label:cr.label,runtime:cr.runtime};let t=xt[e];return{label:`${t}客户端`,runtime:t}}function fr(e){L!=null&&(L=null,M(`平台状态已清空(${e})`))}function pr(e){return lr??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:ir});if(t?.platform==null){M(`平台探测:回包缺 platform,保持未探测状态(判定 fail-open)`);return}L={platform:t.platform,capabilities:t.capabilities??[],coreCapabilities:t.coreCapabilities??[],platformOps:t.platformOps??[],at:Date.now()},j(`平台状态已缓存: ${xt[L.platform]}(平台差异能力 ${L.capabilities.length} 项 / 特有操作 ${L.platformOps.length} 个)`)}catch(e){M(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{lr=null}})(),lr}function mr(e){if(e.platforms==null)return!0;let t=L?.platform;return t==null?null:e.platforms.includes(t)}function hr(e){if(mr(e)!==!1)return null;let t=L?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>xt[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${xt[t]},已拒绝执行(未向插件发起请求)。`,e.platformNote==null?``:`${e.platformNote}`,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function gr(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var _r=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=c(),this.wss=new u({server:this.http}),this.wss.on(`error`,e=>{N(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),he),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:${F}/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===l.OPEN}send(e){this.client&&this.client.readyState===l.OPEN?(this.client.send(e),M(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):N(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===l.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,N(`插件通道被新连接顶替(累计 ${this.takeovers} 次),关闭旧通道`),this.sendStatus(r,`superseded`),r.close(ge,`superseded`)),this.client=e,j(`插件已连接(peer=${n})`);try{this.onConnect?.()}catch(e){j(`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);M(`收到 WS 消息 len=${n.length} bin=${t}`),this.onMessage?.(n,t)}),e.on(`close`,(t,r)=>{if(this.client!==e){M(`旧通道关闭(已被顶替),忽略`);return}this.client=null,j(`插件断开: code=${t}${r.length>0?` reason=${r.toString()}`:``} peer=${n} (${gr(t)})`),this.onDisconnect?.(Error(`plugin disconnected (code=${t})`))}),e.on(`error`,t=>{this.client===e&&(this.client=null,j(`插件通道错误: ${t.message} peer=${n}`),this.onDisconnect?.(Error(`plugin connection error: ${t.message}`)))})}heartbeatTick(){let e=this.client;!e||e.readyState!==l.OPEN||(this.sendStatus(e,`ready`),M(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==l.OPEN)return;let n={type:`status`,state:t,version:Qn};try{e.send(JSON.stringify(n)),M(`已下发状态帧(${t})`)}catch(e){N(`状态帧下发失败(${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)})}},vr=200,yr=class{transport=new _r;pending;logRing=[];onConnectionChange=null;constructor(){this.pending=new Xn((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{t?this.pending.onBinary(e):this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),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):(N(`请求被拒(插件未连接): ${e}`),Promise.reject(Error(`${dr().runtime} 插件未连接。请先在${dr().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=vr&&this.logRing.shift(),this.logRing.push(n);return}this.sendLogPush(n)}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],j(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};async function R(){try{let e=await fetch(`http://127.0.0.1:${F}/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 br=!1;async function xr(){if(br)return;br=!0;let e=process.argv[1];if(!e)return;let t;try{t=a(e).mtimeMs}catch{return}let n=await R();n?.startedAt==null||n.startedAt>=t||N(`常驻 daemon 跑在旧构建上(daemon 启动 ${new Date(n.startedAt).toISOString()} < 产物 ${new Date(t).toISOString()}),本次代码改动未生效。收掉它:curl -X POST http://127.0.0.1:${F}/shutdown,再重新拉起`)}async function Sr(){let e=await R();if(e&&e.version!==I){j(`检测到旧版 daemon (${e.version} → ${I}),正在替换...`),await fetch(`http://127.0.0.1:${F}/shutdown`,{method:`POST`}).catch(()=>{});let t=Date.now()+rr;for(;Date.now()<t&&(await Cr(250),await R()!==null););return await R()===null?{state:`none`}:(j(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new d({name:`text-to-design-proxy`,version:I},{versionNegotiation:{mode:`auto`}});try{await t.connect(new f(new URL(`http://127.0.0.1:${F}/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 R()===null?{state:`none`}:{state:`starting`}}}function Cr(e){return new Promise(t=>setTimeout(t,e))}var wr=3,Tr=4,Er=240,Dr=16,Or=8;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kr(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 Ar(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 jr(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>=Tr))break}return n}function B(e,t,n){if(!z(e))return{};if(typeof e.$ref==`string`){if(t>Or)return{};let r=kr(e.$ref,n.defs);return r===void 0?{}:B(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>Er?`${t.slice(0,Er)}…`:t)}let i=Ar(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]=jr(a.map(e=>B(e,t,n))))}let a=t>=wr&&z(e.properties);if(z(e.items)&&(r.items=a?{}:B(e.items,t+1,n)),z(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,Dr),o={};for(let r of a)o[r]=B(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 Mr(e){if(!z(e))return e;let t=B(e,0,{defs:z(e.$defs)?e.$defs:{}});return z(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function Nr(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 Pr(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=Nr(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function Fr(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 Ir(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 Lr(e){let t=ne(e)[`~standard`],n=Pr(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=Ir(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${Fr(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function Rr(){let e=ie(process.execPath,[...process.execArgv,...process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});e.unref(),e.on(`error`,e=>{P(`拉起 daemon 失败: ${e.message}`)})}var zr=1500,Br=2e4,Vr=6e4,Hr=6e5,Ur=5e5,Wr=5e3;function Gr(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);j(`目录体积: ${e.length} 个工具 / ${(t/1024).toFixed(0)} KB(出参最大 ${n.name} ${(n.outputBytes/1024).toFixed(1)} KB)`);let r=[...t>Ur?[`合计 ${(t/1024).toFixed(0)} KB > ${Ur/1024} KB`]:[],...e.filter(e=>e.outputBytes>Wr).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&N(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function Kr(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 qr(e){let t=e,n=!1,r=null,i=new p({name:er,version:I},{supportedProtocolVersions:[`2026-07-28`,...ee],...e.getInstructions()?{instructions:e.getInstructions()}:{}}),a=new Map,o=new Map,c=new Map,l=new Map,u=async e=>{try{return await e(t)}catch(r){if(n||!Kr(r))throw r;return N(`shim: 上游请求失败,触发重连后重放`),await ae(),e(t)}};async function d(){let{tools:e}=await u(e=>e.listTools()),t=new Set,n=[];for(let r of e){t.add(r.name);let e=r.outputSchema?Mr(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:Lr(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:ne(e)}},s=JSON.stringify({title:r.title,description:r.description,annotations:r.annotations,inputSchema:r.inputSchema,outputSchema:e});n.push({name:r.name,bytes:s.length,outputBytes:e===void 0?0:JSON.stringify(e).length});let c=a.get(r.name);if(c&&c.raw===s)continue;c?.handle.remove(),a.delete(r.name);let l=i.registerTool.bind(i);try{let e=l(r.name,o,async e=>u(t=>t.callTool({name:r.name,arguments:e??{}})));a.set(r.name,{handle:e,raw:s})}catch(e){N(`工具注册失败(${r.name}): ${e instanceof Error?e.message:String(e)}`)}}Gr(n);for(let[e,n]of[...a])t.has(e)||(n.handle.remove(),a.delete(e))}async function f(){let{prompts:e}=await u(e=>e.listPrompts()),t=new Set;for(let n of e){t.add(n.name);let e=JSON.stringify(n),r=o.get(n.name);if(r&&r.raw===e)continue;r?.handle.remove(),o.delete(n.name);let a={};for(let e of n.arguments??[])a[e.name]=s.string().describe(e.description??``);let c=i.registerPrompt(n.name,{title:n.title,description:n.description,argsSchema:s.object(a)},e=>u(t=>t.getPrompt({name:n.name,...e?{arguments:e}:{}})));o.set(n.name,{handle:c,raw:e})}for(let[e,n]of[...o])t.has(e)||(n.handle.remove(),o.delete(e))}async function te(){let[{resources:e},{resourceTemplates:t}]=await Promise.all([u(e=>e.listResources()),u(e=>e.listResourceTemplates())]),n=new Set;for(let t of e){let e=t.uri;n.add(e);let r=JSON.stringify(t),a=c.get(e);if(a&&a.raw===r)continue;a?.handle.remove(),c.delete(e);let o=i.registerResource(t.name,e,{title:t.title,description:t.description,mimeType:t.mimeType},async e=>u(t=>t.readResource({uri:e.href})));c.set(e,{handle:o,raw:r})}for(let[e,t]of[...c])n.has(e)||(t.handle.remove(),c.delete(e));let r=new Set;for(let e of t){let t=String(e.uriTemplate);r.add(t);let n=JSON.stringify(e),a=l.get(t);if(a&&a.raw===n)continue;a?.handle.remove(),l.delete(t);let o=i.registerResource(e.name,new m(t,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType},async(e,t)=>u(t=>t.readResource({uri:e.href})));l.set(t,{handle:o,raw:n})}for(let[e,t]of[...l])r.has(e)||(t.handle.remove(),l.delete(e))}let ie=async()=>{let e=await Promise.allSettled([d(),f(),te()]);for(let t of e)t.status===`rejected`&&N(`同步清单失败: ${String(t.reason).slice(0,120)}`)},ae=()=>r||(r=(async()=>{let e=Date.now()+Br,n=null;for(;Date.now()<e;){try{let e=await Sr();if(e.state===`proxy`){t=e.client,oe(t),j(`shim: 上游已恢复`),await ie();return}e.state===`none`&&Rr()}catch(e){n=e}await Cr(zr)}throw n??Error(`上游重连超时(${Br}ms)`)})().finally(()=>{r=null}),r),oe=e=>{e.onclose=()=>{n||(N(`shim: 上游断开,自动重连`),ae().catch(()=>{}))},e.setNotificationHandler(`notifications/tools/list_changed`,async()=>d().catch(()=>{})),e.setNotificationHandler(`notifications/prompts/list_changed`,async()=>f().catch(()=>{})),e.setNotificationHandler(`notifications/resources/list_changed`,async()=>te().catch(()=>{})),e.setNotificationHandler(`notifications/resources/updated`,async e=>{let t=e.params;t?.uri!=null&&await i.server.sendResourceUpdated({uri:t.uri}).catch(()=>{})})};oe(t);let se=re(async()=>(await ie(),i)),ce=I,h=null,le=null,ue=async()=>{let e=await R();e!=null&&e.version!==ce&&(j(`上游版本变化(${ce} → ${e.version}),全量重同步目录`),ce=e.version,await ie())},g=()=>{n||(h=setTimeout(()=>{n||ue().finally(g)},Vr),h.unref())},de=()=>{n||(le=setTimeout(()=>{n||ie().finally(de)},Hr),le.unref())};g(),de(),j(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,h&&clearTimeout(h),le&&clearTimeout(le),await se.close(),await t.close().catch(()=>{}),process.exit(0)})}function Jr(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function Yr(e){return e._def?.typeName}function Xr(e,t){return e._def?.[t]}function Zr(e,t){return e._def?.[t]}function V(e){switch(Yr(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 Zr(e,`value`);case`ZodEnum`:return Zr(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=Xr(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=Xr(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=Zr(e,`options`)??[],n=t.find(e=>Yr(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}}function Qr(e,t,n){let r={content:[{type:`text`,text:`错误: ${e instanceof Error?e.message:String(e)}`}],isError:!0};return n!==void 0&&(r.followUp=n),t?{...r,structuredContent:V(t)}:r}function $r(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...Jr(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:Jr(e).content,structuredContent:V(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...Jr(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var ei=new Map;function ti(e){return ei.get(e)}function ni(){return[...ei.keys()].sort()}function H(e){return(t,n)=>{let r=t.registerTool.bind(t),i=async(t,r,i)=>{try{let a=hr(e);if(a!=null)return P(`工具 ${e.name} 在当前平台不可用,已拦截`),Qr(Error(a),e.outputSchema,e.followUp);if(e.inputSchema!=null){let n=e.inputSchema.safeParse(t);if(!n.success){let t=n.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw Error(`参数校验失败(${e.name}): ${t}`)}t=n.data}let o={...r==null?{}:{signal:r},...e.timeout==null?{}:{timeout:e.timeout}},s=i?.skipHooks===!0?void 0:e.hook?.();if(s?.before!=null)try{await s.before(t)}catch(t){N(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let c;c=e.run?await e.run(t,n,r??new AbortController().signal):await n.request(e.method,e.payload?e.payload(t):t,o);let l=e.extraContent?e.extraContent(c,t):[],u=[];if(s?.after!=null)try{let e=await s.after(t,c)??[];for(let t of e)u.push(t),l.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;u.push(n),l.push({type:`text`,text:n})}let d=$r(c,e.outputSchema,l.length>0?l:void 0,e.followUp);return u.length>0?{...d,warnings:u}:d}catch(t){let n=t instanceof Error?t.message:String(t);return P(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`),Qr(t,e.outputSchema,e.followUp)}};ei.set(e.name,i);let a=r(e.name,{title:e.title,description:e.platformNote==null?e.description:`${e.description}${e.platformNote}`,...e.inputSchema?{inputSchema:e.inputSchema}:{},outputSchema:e.outputSchema,...e.annotations?{annotations:e.annotations}:{}},async(...t)=>{let n=e.inputSchema!=null,r=t[0],a=t[1],o=n?r??{}:{},s=n?a:r,c=s?.mcpReq?.signal??s?.signal;return i(o,c)});return a.alwaysEnabled=e.alwaysEnabled??!1,a}}function ri(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(typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){if(!Array.isArray(n))return{ok:!1};n=n[Number(e[1])]}}return{ok:!0,value:n}}function ii(e,t){let n=e.indexOf(`.`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);if(!t.has(r)){let n=[...t.keys()].join(`, `)||`无`;throw Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${n})`)}let a=t.get(r);if(i===``)return a;let o=ri(a,i);if(!o.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${r} 的返回结构`);return o.value}var ai=/\{\{\s*([^{}]+?)\s*\}\}/g,oi=/^\{\{\s*([^{}]+?)\s*\}\}$/,si=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],ci=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),li=2e4;function ui(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}function di(e){if(Array.isArray(e))return e.map(di);if(typeof e!=`object`||!e)return e;let t=e;if(typeof t.id==`string`&&typeof t.type==`string`&&typeof t.name==`string`){let e={};for(let n of si)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))ci.has(e)||(n[e]=di(r));return n}function fi(e,t){if(Array.isArray(e)){for(let n of e)fi(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}fi(r,t)}}function pi(e){let t=di(e),n=ui(t);if(n<=li)return{data:t,trimmed:n!==ui(e)};let r=[];return fi(t,r),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${n} 字符,已省略明细;需要细节请把该工具单独调用一次`,ids:[...new Set(r)]},trimmed:!0}}function mi(e,t){if(typeof e==`string`){let n=oi.exec(e.trim());return n==null?e.replace(ai,(e,n)=>{let r=ii(n,t);return typeof r==`string`?r:JSON.stringify(r)}):ii(n[1],t)}if(Array.isArray(e))return e.map(e=>mi(e,t));if(typeof e==`object`&&e){let n={};for(let[r,i]of Object.entries(e))n[r]=mi(i,t);return n}return e}function hi(e,t){return[H({name:`jsd_batch`,title:`批量编排执行`,description:`批量编排器:一次请求内顺序执行多个 jsd_* 步骤,前一步结果经双花括号占位符(内容为 步骤id.字段路径)注入后一步 args,中间 id 不回传模型,显著减少往返与上下文。
3
- 占位符独占一个参数值时保留原类型(数组可直接作 ids 用),嵌在字符串中按 JSON 文本展开;**占位符只在同一次调用的本批次内有效**(步骤表随调用结束即销毁,引用上一批次的步骤必报「占位符引用的步骤不存在或未成功」并中止整批 —— 跨批次请硬编码上一步回显里的真实 id);id 重复/未知工具/引用失败立即中止,工具执行失败默认也中止(stopOnError=false 或单步 continueOnError=true 可走完)。
4
- 回显已做摘要裁剪:节点对象只留 id/name/type/x/y/width/height/z/parentId,vectorPaths(单条 >10KB、16 位小数)与 constraints 等渲染无关字段整键丢弃;裁剪后仍超 20K 字符的步骤降级为 id 清单(结果里 echoTrimmed=true)。占位符解析不受影响(内部仍用完整数据)。含图标的批次(jsd_create_icon / jsd_clone_node / jsd_create_vector)务必配一次 jsd_export 目视验收,别只看回显。
5
- 各工具返回键与占位符写法(键写错会报「无法解析占位符引用」并中止整批):
6
- · created 为数组 → {{id.created[0].id}}:per-type create(jsd_create_rectangle / jsd_create_frame 等)、jsd_clone_node、jsd_outline_stroke、jsd_create_instance、jsd_detach_instance
7
- · created 为单对象 → {{id.created.id}}:jsd_create_svg / jsd_create_icon / jsd_flatten_nodes / jsd_group_nodes / jsd_create_component / jsd_import_component / jsd_combine_as_variants
8
- · jsd_find → {{id.nodes[0].id}};jsd_get_selection → {{id.selection[0].id}}
9
- · 属性类 jsd_set_* → {{id.updated[0].id}};jsd_swap_component → {{id.swapped[0].id}}
10
- · jsd_manage_nodes 各 op:select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**,与 jsd_group_nodes / jsd_flatten_nodes 同形)、ungroup→ungrouped[](id 字符串)、reparent→moved[](与 updated[] 同义,两个键都回)、repair→cleaned[](id 字符串)—— id 字符串数组取 {{id.selected[0]}},节点数组取 {{id.created[0].id}},节点单对象取 {{id.created.id}}(写成 [0] 会报无法解析)
11
- · jsd_manage_components 各 op:create_component/create_instance/detach_instance/import_component/combine_as_variants→created(detach_instance 是数组,不是 updated)、swap_component→swapped[]、set_instance_properties→updated[]、copy_overrides→snapshotId、apply_overrides/sync_overrides→applied[]
12
- · 拿不准某步的返回结构时,先单独调它一次看回显再拼进 batch —— 猜错会连带整批中止。
13
- 结构变更复核(默认开,checkDrift=false 可关):步骤里含 remove/reparent/group/ungroup/flatten/repair 时,变更前记下受影响父层(含 reparent 的目标父级与当前页顶层)的子节点坐标,收尾再读一次比对 —— 引擎在删改结构后会把**没碰到**的兄弟节点静默挪走(实测 (24,720)→(28,618):无报错、回显正常,渲染上像样式问题,极易走错排查方向)。漂移写进结果 warnings 并给出原值,照原值用 jsd_move_node 回填即可;覆盖面仅限本次操作触及的父层(协议没有整树读法,别的层漂移查不到)。`,inputSchema:ze,outputSchema:Be,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`编排执行后复核画布结果`},timeout:sr,run:async(e,t,n)=>{let{calls:r,stopOnError:i,checkDrift:a}=e,o=new Map,s=[],c=!1,l=a===!1,u=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.id==null||t.id.trim()===``?`step${e+1}`:t.id.trim(),d=e=>{s.push({id:a,tool:t.tool,ok:!1,error:e})};if(o.has(a)||s.some(e=>e.id===a)){d(`步骤 id "${a}" 重复`);break}let f=ti(t.tool);if(f==null){d(`未知工具 ${t.tool},可用: ${ni().join(`, `)}`);break}let p;try{p=mi(t.args??{},o)}catch(e){d(e instanceof Error?e.message:String(e));break}let m=await f(p,n,{skipHooks:l});if(m.isError===!0){if(d((m.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),i!==!1&&t.continueOnError!==!0)break;continue}let ee=pi(m.structuredContent);ee.trimmed&&(c=!0),o.set(a,m.structuredContent),m.warnings!=null&&u.push(...m.warnings),s.push({id:a,tool:t.tool,ok:!0,data:ee.data})}let d=s.length===r.length,f=u;return{ok:d&&s.every(e=>e.ok),executed:s.length,total:r.length,results:s,...c?{echoTrimmed:!0}:{},...f.length>0?{warnings:f}:{}}}})(e,t)]}function U(e,t){return{method:`component_op`,outputSchema:Ft,payload:t=>({op:e,...t}),...t}}function gi(e,t){return[U(`create_component`,{name:`jsd_create_component`,title:`建组件`,description:`建「空壳」组件——不会固化传入节点,返回全新 100×100 空组件,原节点不动。正确流程:1) jsd_resize_node 把空壳改成目标尺寸 → 2) jsd_reparent_nodes 把原 Frame 的子节点移进空壳 → 3) jsd_delete_node 删原 Frame → 4) 需要填充/圆角/阴影时再 jsd_set_fill_color / jsd_set_cornerRadius / jsd_set_effects 补。顺序必须先 resize 后 reparent,否则子节点默认 SCALE 约束会被拉伸到错位(或先给子节点 constraints:{horizontal:"MIN",vertical:"MIN"})`,inputSchema:en,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`把空壳组件调到目标尺寸`}}),U(`create_instance`,{name:`jsd_create_instance`,title:`生成组件实例`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:tn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`设置实例的变体属性`}}),U(`detach_instance`,{name:`jsd_detach_instance`,title:`取消实例链接`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:nn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`解链后自由编辑新节点样式`}}),U(`import_component`,{name:`jsd_import_component`,title:`从团队库导入组件`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:rn,annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`为导入的组件生成实例`}}),U(`swap_component`,{name:`jsd_swap_component`,title:`换绑组件`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:an,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`换绑后设置变体属性`}}),U(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`设置变体属性`,description:`设置实例的变体属性(如 {"状态":"禁用"})。可调属性与可选值需先 jsd_find / jsd_get_selection 读 variantGroupProperties,属性名必须完全匹配。componentProperties 仅 Figma 生效,jsDesign 自动降级为变体属性+可见样式`,inputSchema:on,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`批量同步其他实例的覆盖`}}),U(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`合并为变体集`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。**两平台行为不同,按能力位 inPlaceVariants 分流**:①声明该能力的平台(如 Figma,原生 combineAsVariants 即原位合并)—— 并入集合的就是实例所指的 COMPONENT 本身,**已有实例链接不断、页面不残留冗余原件**,这是首选姿势,直接调即可;②未声明的平台(jsDesign,平台缺陷:引擎内部把节点按 BOOLEAN_OPERATION 取属性 → get_booleanOperation: Value is not a string,与组件结构无关)会退化为「克隆并入 / 克隆移入后合并」兜底 —— 兜底成功时页面上会同时留下**原件与集合内克隆**,已有实例仍指向原件,需自行 swap 到克隆变体后再删原件;全败时返回可执行出口,别重试、也别去改组件结构。jsDesign 上变体集的替代做法:每个状态各做一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me),调用方按名字取用。「一个主件 + 每屏改子节点颜色」这条捷径同样不通(实例子节点样式 override 不保证渲染生效)`,inputSchema:sn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),U(`copy_overrides`,{name:`jsd_copy_overrides`,title:`复制实例覆盖快照`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:cn,annotations:{readOnlyHint:!0,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`把快照套用到目标实例`}}),U(`apply_overrides`,{name:`jsd_apply_overrides`,title:`套用实例覆盖快照`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:un,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`继续同步其他实例的覆盖`}}),U(`sync_overrides`,{name:`jsd_sync_overrides`,title:`同步实例覆盖`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:dn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`复核同步后的实例`}})].map(n=>H(n)(e,t))}var _i=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),vi={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},yi=`#f3f4f6`;function bi(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 W(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function xi(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:vi[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function Si(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>W(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=W(e[`margin-top`])??n,r=W(e[`margin-right`])??r,i=W(e[`margin-bottom`])??i,a=W(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function Ci(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>W(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=W(e[`padding-top`])??n,r=W(e[`padding-right`])??r,i=W(e[`padding-bottom`])??i,a=W(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function wi(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:xi(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:W(e[`border-width`])??1,color:xi(e[`border-color`])??`#000000`}:t}function G(e,t){return W(e[t])}function Ti(e){return W(e[`font-size`])??16}function Ei(e){let t=e[`font-weight`];return t===`bold`?700:W(t)??400}function Di(e,t){let n=e[`line-height`];return W(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Oi(e){return(e.display??``).includes(`flex`)}function ki(e){return e[`flex-direction`]===`row`?`row`:`column`}function Ai(e){return W(e.gap)??W(e[`row-gap`])??0}function ji(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function Mi(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Ni(e){return e.type===`text`?e.data:h(e)?e.tagName===`br`?`
14
- `:e.children.map(Ni).join(``):``}function Pi(e){return e.replace(/\s+/g,` `).trim()}function Fi(e,t){let n=bi(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=G(n,`width`)??120,r.h=G(n,`height`)??120,r;for(let t of e.children){if(t.type===`text`){let e=Pi(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:Ii(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}h(t)&&(_i.has(t.tagName)||t.tagName!==`br`&&r.children.push(Fi(t,!1)))}if(t&&r.children.length===0){let t=Pi(e.children.map(Ni).join(``));t&&r.children.push({tag:`#text`,text:t,style:Ii(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function Ii(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 Li(e,t){let n=e.style,r=Ci(n),i=Si(n),a=wi(n),o=Math.max(0,t-r.left-r.right-a.width*2);if(e.tag===`img`)return e.w=G(n,`width`)??120,e.h=G(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=Ti(n),r=(e.text??``).split(`
15
- `).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>Mi(e,t)),t)),e.h=r.length*Di(n,t),c=e.h}else{let t=Oi(n),i=ki(n),o=Ai(n),l=G(n,`width`),u=G(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=Li(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&ji(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=Li(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&ji(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 G(n,`width`)??(e.w+=l),G(n,`height`)==null&&!e.isText&&(e.h+=u),{width:e.w+i.left+i.right,height:e.h+i.top+i.bottom}}function Ri(e){let t=Si(e.style);e.x+=t.left,e.y+=t.top}function zi(e,t,n){let r=[];return Bi(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 Bi(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=Ti(i),r=xi(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=Ei(i),u=ji(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=Di(i,n);(e.text??``).split(`
16
- `).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}">${Vi(e)}</text>`)});return}let l=xi(i.background??i[`background-color`],e.tag===`img`?yi:void 0),u=wi(i),d=W(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)Ri(n),Bi(n,t,a,o)}function Vi(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function Hi(e){let t=le(e,{decodeEntities:!0}).children.filter(e=>h(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=Fi(n,!0),i=bi(n.attribs.style),a=G(i,`width`),o=G(i,`height`),s=Li(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),zi(r,c,l)}var Ui={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,"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-template":`book-dashed`,"box-select":`square-dashed`,"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-vertical":`square-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`,"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`},Wi=e(import.meta.url);function K(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Gi=JSON.parse(r(Wi.resolve(`lucide-static/icon-nodes.json`),`utf8`)),Ki=JSON.parse(r(Wi.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Gi))q.set(e,{name:e,nodes:t,keywords:Ki[e]??[]});q.size;var qi=new Map;for(let[e,t]of Object.entries(Ki))t.forEach((t,n)=>{let r=qi.get(t)??[];r.push({name:e,idx:n}),qi.set(t,r)});var Ji=new ue([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Yi(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Xi(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Ui[t];if(r){let e=q.get(r);if(e)return e}let i=K(t),a=Ji.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Yi(i,K(e.item.name))>=3});if(a.length)return a[0].item;let o=qi.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||K(e.name).length-K(t.name).length)[0];return q.get(e.name)??null}let s=Ji.search(t,{limit:8}).filter(e=>Yi(i,K(e.item.name))>=2)[0];return s?s.item:null}function Zi(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=Ui[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of qi.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Ji.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function Qi(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(`
2
+ import{createRequire as e}from"node:module";import{appendFileSync as t,mkdirSync as n,readFileSync as r,rmSync as i,statSync as a,writeFileSync as o}from"node:fs";import{core as s,z as c}from"zod";import{createServer as l}from"node:http";import{WebSocket as u,WebSocketServer as d}from"ws";import{Client as f,StreamableHTTPClientTransport as p}from"@modelcontextprotocol/client";import{McpServer as m,ResourceTemplate as ee,SUPPORTED_PROTOCOL_VERSIONS as te,createMcpHandler as h,fromJsonSchema as ne}from"@modelcontextprotocol/server";import{serveStdio as re}from"@modelcontextprotocol/server/stdio";import{spawn as ie,spawnSync as ae}from"node:child_process";import{localhostHostValidation as oe,localhostOriginValidation as se,toNodeHandler as ce}from"@modelcontextprotocol/node";import{isTag as g}from"domhandler";import{parseDocument as le}from"htmlparser2";import ue from"fuse.js";import{homedir as _,tmpdir as de}from"node:os";import{dirname as fe,join as v,resolve as pe,sep as me}from"node:path";var y=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function he(e){return e instanceof y?e.code:`plugin_error`}var ge=3e4,_e=4e3;2*ge;var ve=3e4,b={"platform.jsdesign":`即时设计`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`创建`,"capability.core.modify":`修改`,"capability.core.structure":`结构操作`,"capability.core.component":`组件`,"capability.core.export":`导出`,"capability.core.image":`图片填充`,"capability.host.styles":`本地样式`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.variables":`变量`,"capability.host.platformOps":`平台特有操作`,"capability.host.inPlaceVariants":`原位合并变体`,"locale.system":`跟随系统`,"locale.zh-CN":`中文`,"locale.en":`English`,"locale.abbr.zh-CN":`中`,"locale.abbr.en":`EN`,"locale.menu":`界面语言`,"locale.title.followSystem":`界面语言:跟随系统(当前 {locale})`,"locale.title.fixed":`界面语言:{locale}`,"status.connected.label":`已连接`,"status.connected.title":`服务在线,插件与 AI 会话已连通`,"status.connecting.label":`连接中…`,"status.connecting.title":`已连上后台服务,等待它确认这条通道`,"status.waiting.label":`等待服务`,"status.waiting.title":`服务离线时无需手动操作,AI 调用会自动拉起`,"status.superseded.label":`已被接管`,"status.superseded.title":`另一个插件面板占用了通道;点「夺回」可切回本面板`,"header.retry":`重试`,"header.retry.title":`立即重连后台服务,不必等自动重连的退避间隔`,"header.reclaim":`夺回`,"header.reclaim.title":`夺回被另一个插件面板占用的通道`,"header.meta":`{platform} · :{port}`,"header.meta.portOnly":`:{port}`,"header.meta.title":`运行平台 {platform} · MCP 桥接端口 {port}(可用环境变量 TEXT_TO_DESIGN_MCP_PORT 修改)`,"header.meta.titleUnknown":`运行平台未知 · MCP 桥接端口 {port}(可用环境变量 TEXT_TO_DESIGN_MCP_PORT 修改)`,"conn.connected":`已连接。选中画布节点后点「复制」,把内容发给 AI 助手——例如:「按这个节点样式帮我再做一张卡片」`,"conn.superseded":`通道已被另一个插件面板接管(同一时刻只服务一个面板),自动重连已停止。点顶部状态徽章旁的「夺回」切回本面板。`,"conn.disconnected.title":`尚未连接后台服务`,"conn.disconnected.tutorial":`安装教程`,"conn.copyAi":`① 复制给 AI 助手`,"conn.copyDaemon":`② 复制启动命令`,"conn.copied":`✓ 已复制`,"conn.copyAi.hint":`发给 AI,让它调用 jsd_ping 唤醒后台服务`,"conn.daemon.note":`在本机终端执行即常驻到下次重启;重复执行安全(已有实例会自动跳过)。`,"conn.announce.connected":`已连接后台服务`,"conn.announce.connecting":`正在连接后台服务`,"conn.announce.superseded":`通道已被另一个插件面板接管`,"conn.announce.disconnected":`尚未连接后台服务`,"conn.wakeCmd":`请帮我连接 text-to-design 后台服务:
3
+
4
+ 1. 若尚未注册 MCP 服务:用你工具原生的方式注册一个 stdio MCP server,
5
+ 命令 npx -y text-to-design-mcp@latest(无需手动安装,npx 会自动拉取运行)。
6
+
7
+ 2. 注册后调用 jsd_ping —— 这一步会唤醒(必要时自动拉起)后台常驻服务。
8
+ 若返回「插件未连接」,请提示我在设计软件里运行 text-to-design 插件。`,"selection.title":`选中节点`,"selection.badge":`{count} 个 · 序列化 {size}`,"selection.copy":`复制`,"selection.copied":`✓`,"selection.expand":`展开节点列表`,"selection.collapse":`收起节点列表`,"selection.empty.title":`未选中节点`,"selection.empty.hint":`在画布中点选节点后,这里会实时显示并支持复制`,"capability.card.title":`能力`,"capability.card.missing":`能力表未获取(插件未连接)`,"capability.card.badgeTitle":`核心能力项数 · 当前平台可用的差异能力 · 平台特有操作个数`,"capability.card.badge":`核心 {core} · 平台 {host}/{total} · op {ops}`,"capability.card.expand":`展开`,"capability.card.collapse":`收起`,"capability.card.coreSection":`核心能力(两平台一致)`,"capability.card.hostSection":`平台差异能力`,"capability.card.opTitle":`{op}:当前平台支持`,"capability.card.opTitleOff":`{op}:当前平台不支持`,"capability.card.opsSection":`平台特有操作`,"capability.card.refresh":`刷新`,"capability.card.noOps":`当前平台无特有操作`,"log.trigger":`日志`,"log.trigger.title":`日志:MCP 调用与连接事件`,"log.trigger.unread":`日志,有 {count} 条新错误`,"log.trigger.unit":`条错误`,"log.trigger.announce":`有 {count} 条新错误`,"log.drawer.title":`日志`,"log.drawer.count":`{shown} / {total} 条`,"log.drawer.clear":`清空`,"log.drawer.close":`关闭日志`,"log.drawer.filter.all":`全部`,"log.drawer.filter.info":`信息+`,"log.drawer.filter.warn":`警告+`,"log.drawer.filter.error":`错误`,"log.drawer.empty":`暂无日志。MCP 调用与连接事件会记录在这里。`,"log.drawer.emptyFiltered":`当前档位「{filter}」下没有日志,切到「全部」看完整记录。`,"log.drawer.copy":`复制`,"log.drawer.newCount":`↓ {count} 条新日志`,"bridge.log.superseded":`通道已被另一个插件面板接管,自动重连已停止(点面板顶部的「夺回」可切回)`,"bridge.log.confirmed":`服务已确认连接(版本 {version})`,"bridge.log.handshakeTimeout":`WS 握手超时({ms}ms),放弃本次连接: {port}`,"bridge.log.serverConnected":`MCP server 已连接,等待服务确认: ws://localhost:{port}`,"bridge.log.confirmTimeout":`服务确认超时,关闭重连: {port}`,"bridge.log.closed":`连接断开: {port}`,"bridge.log.stale":`服务确认过期({ms}ms 未收到心跳),关闭重连: {port}`,"bridge.log.wsFailed":`WS 消息处理失败: {message}`,"bridge.log.recvRequest":`收到服务器请求: {method}`,"bridge.log.recvResponse":`收到服务器响应(忽略): {id}`,"bridge.log.forwardTimeout":`转发到插件超时: {method}`,"bridge.log.pluginTimeout":`插件响应超时`,"bridge.log.ignoreUnknown":`忽略未知插件消息: {type}`,"bridge.log.codeFailed":`code 消息处理失败: {message}`,"bridge.log.sendFailed":`发送响应失败(server 未连接): {id}`,"bridge.log.manualClose":`手动断开连接`,"bridge.log.capabilityMissing":`能力表回包异常(缺 platform)`,"bridge.log.capabilityFailed":`能力表获取失败: {message}`,"bridge.log.pingOk":`ping 插件成功: {data}`,"bridge.log.pingFailed":`ping 插件失败: {message}`,"bridge.error.useBridge":`useBridge 必须在 <BridgeProvider> 内使用`,"schema.base.r":`红色通道,范围 0-1(0=无,1=满),如纯红为 1`,"schema.base.g":`绿色通道,范围 0-1`,"schema.base.b":`蓝色通道,范围 0-1`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`变换矩阵,如 [[1,0,0],[0,1,0]] 表示无变换(Identity)`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.type":`子节点类型`,"schema.executeSchemas.x":`相对父节点的 X(px)`,"schema.executeSchemas.y":`相对父节点的 Y(px)`,"schema.executeSchemas.x2":`X 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.y2":`Y 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.width":`宽度(px)`,"schema.executeSchemas.height":`高度(px)`,"schema.executeSchemas.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表(Paint 数组)`,"schema.executeSchemas.strokeWeight":`描边宽度(px)`,"schema.executeSchemas.strokeTopWeight":`描边顶部宽(px)`,"schema.executeSchemas.strokeBottomWeight":`描边底部宽(px)`,"schema.executeSchemas.strokeLeftWeight":`描边左侧宽(px)`,"schema.executeSchemas.strokeRightWeight":`描边右侧宽(px)`,"schema.executeSchemas.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.executeSchemas.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.executeSchemas.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.executeSchemas.dashPattern":`虚线段数组,如 [4,4]`,"schema.executeSchemas.effects":`效果列表(阴影/模糊,可多层叠加)`,"schema.executeSchemas.vertical":`自动布局中的约束`,"schema.executeSchemas.clipsContent":`是否裁剪溢出内容`,"schema.executeSchemas.cornerSmoothing":`圆角平滑度 0-1`,"schema.executeSchemas.layoutGrids":`布局网格(参考线)`,"schema.executeSchemas.cornerRadius":`圆角半径(px),四角统一`,"schema.executeSchemas.topLeftRadius":`左上圆角(px)`,"schema.executeSchemas.topRightRadius":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius":`右下圆角(px)`,"schema.executeSchemas.paddingTop":`上内边距(px)`,"schema.executeSchemas.paddingRight":`右内边距(px)`,"schema.executeSchemas.paddingBottom":`下内边距(px)`,"schema.executeSchemas.paddingLeft":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.executeSchemas.layoutGrow":`自动布局内伸缩系数`,"schema.executeSchemas.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.cornerRadius2":`圆角半径(px)`,"schema.executeSchemas.startingAngle":`起始角度(radians)`,"schema.executeSchemas.endingAngle":`结束角度(radians)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.innerRadius3":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.cornerRadius3":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius2":`左上圆角(px)`,"schema.executeSchemas.topRightRadius2":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius2":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius2":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),值越小角越尖锐`,"schema.executeSchemas.cornerRadius4":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius3":`左上圆角(px)`,"schema.executeSchemas.topRightRadius3":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius3":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius4":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius5":`STAR=星形(配合 pointCount + innerRadius)`,"schema.executeSchemas.vectorPaths":`矢量路径数组,每项含 SVG path data(如 "M0 0 L100 100")`,"schema.executeSchemas.fontSize":`字号(px),默认 16`,"schema.executeSchemas.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.executeSchemas.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.executeSchemas.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`行高:{value,unit},unit 为 PIXELS|PERCENT;或 {unit:"AUTO"}`,"schema.executeSchemas.letterSpacing":`字距:{value,unit},unit 为 PIXELS|PERCENT`,"schema.executeSchemas.letterSpacing2":`TEXT=文本(配合 characters/fontSize/fontName 等)`,"schema.executeSchemas.children":`子节点数组,至少 2 个;递归嵌套,最多 100 个直接子节点`,"schema.executeSchemas.paddingTop2":`上内边距(px)`,"schema.executeSchemas.paddingRight2":`右内边距(px)`,"schema.executeSchemas.paddingBottom2":`下内边距(px)`,"schema.executeSchemas.paddingLeft2":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode2":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`交叉轴对齐`,"schema.executeSchemas.path":`GROUP=分组(内部用 Frame 实现)`,"schema.executeSchemas.children2":`要合并的子节点数组(至少 2 个)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION=布尔运算(合并子节点)`,"schema.execute.name":`生成的图层名,默认 svg-design`,"schema.execute.html":`HTML 片段,支持内联 style`,"schema.execute.name2":`生成的图层名,默认 html-design`,"schema.execute.size":`图标边长 px,默认 24`,"schema.execute.color":`描边颜色(十六进制),默认 #000000`,"schema.execute.strokeWidth":`描边宽度,默认 2`,"schema.execute.name3":`生成的图层名,默认 icon-<图标名>`,"schema.inputs.ids":`按节点 id 精确查找,优先级最高`,"schema.inputs.name":`按名称模糊匹配(包含)`,"schema.inputs.recursive":`是否递归查找(默认 true)`,"schema.inputs.depth":`序列化深度:0=仅自身,1=含直接子节点;缺省 1`,"schema.inputs.name2":`仅 group:组名`,"schema.inputs.paddingTop":`仅 group。上内边距(px)`,"schema.inputs.paddingRight":`仅 group。右内边距(px)`,"schema.inputs.paddingBottom":`仅 group。下内边距(px)`,"schema.inputs.paddingLeft":`仅 group。左内边距(px)`,"schema.inputs.primaryAxisSizingMode":`仅 group。主轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisSizingMode":`仅 group。交叉轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisAlignItems":`仅 group。交叉轴对齐:MIN|MAX|CENTER`,"schema.inputs.key":`团队库组件唯一标识 Key(仅 import_component 必填)`,"schema.inputs.componentId":`目标组件(COMPONENT)节点 id(仅 swap_component 必填)`,"schema.inputs.format":`导出格式,默认 PNG`,"schema.inputs.scale":`缩放倍率(PNG/JPG),默认 1`,"schema.inputs.savePath":`落盘文件绝对路径,如 /tmp/icon.png`,"schema.inputs.includeDataUrl":`是否同时返回 base64 dataURL,默认 false`,"schema.inputs.ids2":`要填充图片的节点 id 列表`,"schema.inputs.sourcePath":`本地图片文件绝对路径,如 /tmp/poster.png`,"schema.inputs.params":`操作参数,结构随 op 而定`,"schema.inputs.family":`按家族名过滤(不区分大小写的子串),如 "Source" 或 "思源"`,"schema.inputs.offset":`分页起始序号(跳过多少族),默认 0`,"schema.inputs.limit":`本页最多返回多少族,默认 50、上限 500;字体库可达约 1900 族,整表会撑爆上下文`,"schema.platform.name":`op 名,调用 jsd_platform_op 时原样传`,"schema.platform.description":`含 params 形状说明`,"schema.results.capabilities":`当前平台支持的能力列表(先查此字段再决定能否调用平台特有操作)`,"schema.results.families":`可用字体族(family)列表`,"schema.results.family":`字体族`,"schema.results.styles":`该族可用字型,如 ["Regular","Medium","Bold"]`,"schema.results.count":`本页返回的字体族数量`,"schema.results.total":`过滤后的字体族总数(不受分页影响)`,"schema.results.offset":`本页起始序号`,"schema.results.truncated":`为 true 表示还有下一页,用 offset 继续取`,"schema.sharedProps.width":`宽度(px)`,"schema.sharedProps.height":`高度(px)`,"schema.sharedProps.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.sharedProps.opacity":`不透明度 0-1`,"schema.sharedProps.pointCount":`多边形/星形角点数(仅 POLYGON/STAR 生效)`,"schema.sharedProps.innerRadius":`星形内半径比例(0-1,相对外半径;仅 STAR 生效)`,"schema.sharedProps.strokes":`描边列表(Paint 数组;整体替换,非合并,需保留的描边要一并传入)`,"schema.sharedProps.strokeWeight":`描边宽度(px)`,"schema.sharedProps.strokeTopWeight":`描边顶部宽(px)`,"schema.sharedProps.strokeBottomWeight":`描边底部宽(px)`,"schema.sharedProps.strokeLeftWeight":`描边左侧宽(px)`,"schema.sharedProps.strokeRightWeight":`描边右侧宽(px)`,"schema.sharedProps.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.sharedProps.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.sharedProps.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.sharedProps.dashPattern":`虚线段数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.topLeftRadius":`左上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.topRightRadius":`右上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomLeftRadius":`左下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomRightRadius":`右下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.characters":`文本内容(仅 TEXT 节点生效)`,"schema.sharedProps.fontSize":`字号(px)`,"schema.sharedProps.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.sharedProps.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.sharedProps.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.sharedProps.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.sharedProps.lineHeight":`行高:{value,unit}`,"schema.sharedProps.letterSpacing":`字距:{value,unit}`,"schema.sharedProps.textStyleId":`文本样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.textTruncation":`文本截断(DISABLED=不截断,ENDING=末尾省略号截断),仅 Figma 生效`,"schema.sharedProps.maxLines":`文本最大行数,仅 Figma 生效`,"schema.sharedProps.paddingTop":`上内边距(px)`,"schema.sharedProps.paddingRight":`右内边距(px)`,"schema.sharedProps.paddingBottom":`下内边距(px)`,"schema.sharedProps.paddingLeft":`左内边距(px)`,"schema.sharedProps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.sharedProps.layoutGrow":`自动布局内伸缩系数`,"schema.sharedProps.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.sharedProps.fillStyleId":`填充样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effectStyleId":`效果样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effects":`效果列表(阴影/模糊,可多层叠加;整体替换,非合并)`,"schema.sharedProps.vertical":`自动布局中的约束`,"schema.sharedProps.clipsContent":`是否裁剪溢出内容`,"schema.sharedProps.cornerSmoothing":`圆角平滑度 0-1`,"schema.sharedProps.layoutGrids":`布局网格(参考线)`,"schema.sharedProps.startingAngle":`起始角度(radians)`,"schema.sharedProps.endingAngle":`结束角度(radians)`,"schema.sharedProps.innerRadius2":`内半径(0-1 ratio)`,"schema.sharedProps.innerRadius3":`环形路径参数(弧线),仅 ELLIPSE 节点生效`,"schema.splitOps.ids":`目标节点 id 列表;缺省时作用于当前选中节点`,"schema.splitOps.matchName":`按节点 name 精确过滤(精确等值,非模糊/包含),仅命中节点被修改`,"schema.splitOps.ids2":`要删除的节点 id 列表;缺省时删除当前选中节点`,"schema.splitOps.matchName2":`在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`,"schema.splitOps.name":`组名`,"schema.splitOps.paddingTop":`上内边距(px)`,"schema.splitOps.paddingRight":`右内边距(px)`,"schema.splitOps.paddingBottom":`下内边距(px)`,"schema.splitOps.paddingLeft":`左内边距(px)`,"schema.splitOps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.splitOps.ids3":`要清理的已损坏节点 id 列表;缺省时清理当前页全部损坏节点`,"schema.splitOps.name2":`组件名称`,"schema.splitOps.key":`团队库组件唯一标识 Key`,"schema.splitOps.name3":`导入后的节点名称`,"schema.splitOps.componentId":`目标组件(COMPONENT)节点 id`,"schema.splitOps.name4":`变体集名称`,"schema.splitOps.sourceId":`源实例 id,即先前 copy_overrides 返回的 snapshotId`,"schema.splitOps.name5":`节点新名称`,"batch.title":`批量编排执行`,"batch.followUp":`编排执行后复核画布结果`,"createComponent.title":`建组件`,"createComponent.description":`建组件(COMPONENT)并返回新 id。传 children 时一次建成带内容的组件(字段同 jsd_create_frame 的 children),可再传 width/height 定尺寸,不必再手工 reparent 搬子节点;不传 children 则是空壳,后续用 jsd_reparent_nodes 归组。原节点不会被固化也不会被改动 —— 组件一律新建(避免把已有节点卷进 wrapper)。变体命名用「属性=值, 属性=值」,变体属性用 jsd_set_instance_properties`,"createComponent.description2":`调整组件尺寸 / 补齐填充、圆角、阴影`,"createInstance.title":`生成组件实例`,"createInstance.description":`设置实例的变体属性`,"detachInstance.title":`取消实例链接`,"detachInstance.description":`解链后自由编辑新节点样式`,"importComponent.title":`从团队库导入组件`,"importComponent.description":`为导入的组件生成实例`,"swapComponent.title":`换绑组件`,"swapComponent.description":`换绑后设置变体属性`,"setInstanceProperties.title":`设置变体属性`,"setInstanceProperties.description":`批量同步其他实例的覆盖`,"combineAsVariants.title":`合并为变体集`,"copyOverrides.title":`复制实例覆盖快照`,"copyOverrides.description":`把快照套用到目标实例`,"applyOverrides.title":`套用实例覆盖快照`,"applyOverrides.description":`继续同步其他实例的覆盖`,"syncOverrides.title":`同步实例覆盖`,"syncOverrides.description":`复核同步后的实例`,"createFrame.title":`创建 Frame 容器`,"createFrame.description":`创建单个 FRAME 容器节点,入参只含 FRAME 字段:width/height 尺寸、layoutMode 自动布局(itemSpacing/padding*/主轴交叉轴尺寸对齐)与填充描边等视觉字段。本工具只建一个根 FRAME;层级结构用 children 递归嵌套,子节点 x/y 相对父节点。auto-layout 前必须设 layoutMode=HORIZONTAL 或 VERTICAL(否则布局字段被忽略)。未显式传 fills 时引擎默认白底,透明容器传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]。建多个根节点/复杂树用 jsd_batch 编排`,"createRectangle.title":`创建矩形`,"createRectangle.description":`创建单个 RECTANGLE 矩形节点,入参只含矩形字段:width/height 尺寸、cornerRadius 四角圆角与填充描边等视觉字段。本工具只建一个根矩形;层级结构用 children 递归嵌套,子节点 x/y 相对父节点。建多个根节点/复杂树用 jsd_batch 编排`,"createText.title":`创建文本`,"createText.description":`创建单个 TEXT 文本节点,入参只含文本字段:characters 必填内容、fontSize/fontName 字号字体、对齐/自适应/大小写/装饰/行高/字距与填充描边。本工具只建一个根文本;层级结构用 children 递归嵌套,子节点 x/y 相对父节点。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样(如 SourceHanSansCN_family),style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,命中时结果 warnings 点名。长段落要换行:TEXT 缺省按内容撑开,显式 width 会被覆盖 —— 传 width + textAutoResize:"HEIGHT";要固定框尺寸传 "NONE"。建多个根节点/复杂树用 jsd_batch 编排`,"createEllipse.title":`创建椭圆`,"createEllipse.description":`创建单个 ELLIPSE 椭圆节点,width/height 尺寸、arcData 环形参数(可画环)与填充描边等视觉字段。本工具只建一个根椭圆;建多个根节点/复杂树用 jsd_batch 编排`,"createLine.title":`创建线段`,"createLine.description":`创建单个 LINE 线段节点,width/height 尺寸与描边等视觉字段。本工具只建一个根线段;短直线段建议 LINE+rotation 布局更稳定。横线/竖线可把一维传 0:引擎 resize 校验要求 >= 0.01,插件创建时把零轴抬到 0.01 过校验(视觉是直线,序列化回读该轴仍是 0);jsd_resize_node 改尺寸同样支持零轴。建多个根节点/复杂树用 jsd_batch 编排`,"createPolygon.title":`创建多边形`,"createPolygon.description":`创建单个 POLYGON 多边形节点,pointCount 角点数必填(如 6=六边形)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根多边形;建多个根节点/复杂树用 jsd_batch 编排`,"createStar.title":`创建星形`,"createStar.description":`创建单个 STAR 星形节点,pointCount 角点数与 innerRadius 内半径比例必填(如 5 角、0.5)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根星形;建多个根节点/复杂树用 jsd_batch 编排`,"createVector.title":`创建矢量`,"createVector.description":`创建单个 VECTOR 矢量节点,vectorPaths 必填(每项含 SVG path data,如 "M0 0 L100 100")与填充描边等视觉字段。本工具只建一个根矢量。⚠ 已知平台缺陷:创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定。建多个根节点/复杂树用 jsd_batch 编排`,"createGroup.title":`创建编组`,"createGroup.description":`创建单个 GROUP 编组节点,children 必填且至少 2 个子节点(内部用 Frame 实现),可带 auto-layout 布局字段(layoutMode/itemSpacing/padding*)。本工具只建一个根编组;要固定坐标的根层级用 placement 控制。建多个根节点/复杂树用 jsd_batch 编排`,"createBooleanOperation.title":`创建布尔运算节点`,"createSvg.title":`导入 SVG`,"createIcon.title":`插入内置图标`,"htmlToDesign.title":`HTML 转设计节点`,"htmlToDesign.description":`将 HTML 片段转成矢量图层(SVG 保真,忽略复杂样式);需要逐节点可编辑的结构时改用 jsd_create_rectangle / jsd_create_text 等手工搭建后再 jsd_batch 编排`,"manageNodes.title":`节点结构操作(聚合)`,"manageNodes.followUp":`结构改完后设置容器自动布局`,"manageComponents.title":`组件与实例操作(聚合)`,"manageComponents.description":`按 op 分发的组件/实例操作聚合入口:create_component|create_instance|detach_instance|import_component|swap_component|set_instance_properties|combine_as_variants|copy_overrides|apply_overrides|sync_overrides。单次单操作请优先用对应小工具: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_nodes,两工具 op 不通用`,"manageComponents.description2":`组件/实例改完后设置变体属性`,"find.title":`查找节点`,"find.description":`把查到的节点设为当前选中,便于后续修改/删除`,"selectNodes.title":`设置画布选中`,"selectNodes.description":`选中后移动/调整选中节点`,"deleteNode.title":`删除节点`,"deleteNode.description":`删除后复核剩余节点`,"cloneNode.title":`复制节点`,"cloneNode.description":`把副本移到目标位置`,"groupNodes.title":`编组节点`,"groupNodes.description":`编组后设置组内自动布局`,"ungroupNodes.title":`解组节点`,"ungroupNodes.description":`解组后调整子节点位置`,"flattenNodes.title":`合并为矢量`,"flattenNodes.description":`烘焙后设置合并图形的填充`,"outlineStroke.title":`描边转轮廓`,"outlineStroke.description":`调整新轮廓的描边`,"reparentNodes.title":`移动节点到父节点下`,"reparentNodes.description":`移动后按需微调新父下的 x/y(绝对位置已自动保持)`,"repairNodes.title":`清理损坏节点`,"repairNodes.description":`清理后复核页面节点状态`,"platformOp.title":`平台特有操作`,"platformOp.description":`执行平台特有能力(Figma 变量/本地样式/组件属性等)。CRITICAL: 不要凭空猜测 op 名与参数——先 jsd_ping 读 platformOps 名单(含每个 op 的参数形状说明)与 capabilities,再按名单里的名字调用;平台不支持或 op 名写错时返回错误并列出当前平台支持的 op`,"platformOp.description2":`复核平台操作在画布上的效果`,"prompt.htmlToDesign.title":`HTML 转设计稿`,"prompt.htmlToDesign.description":`把一段 HTML 转为画布节点,含保真度取舍说明`,"prompt.iconGrid.title":`图标网格`,"prompt.iconGrid.description":`批量插入 Lucide 图标并排成自动布局网格`,"prompt.scriptOps.title":`脚本化批量调用`,"prompt.designStrategy.title":`设计策略总纲`,"prompt.textReplace.title":`文本批量替换策略`,"prompt.variantSync.title":`同类实例样式批量同步`,"setFillColor.title":`设置填充`,"setFillColor.followUp":`接着设置描边`,"setStroke.title":`设置描边`,"setStroke.description":`接着设置填充`,"setCornerRadius.title":`设置圆角`,"setCornerRadius.description":`接着设置阴影/模糊效果`,"setText.title":`修改文本`,"setText.followUp":`给文本起个语义名称`,"moveNode.title":`移动节点`,"moveNode.description":`接着调整尺寸`,"resizeNode.title":`调整节点尺寸`,"resizeNode.description":`接着设置可见性/锁定`,"setLayout.title":`设置自动布局`,"setLayout.description":`把子节点移入容器完成排布`,"setEffects.title":`设置效果与高级属性`,"setEffects.description":`接着设置可见性/锁定`,"setVisibility.title":`设置可见性与锁定`,"setVisibility.description":`复核改动后的画布选中`,"renameNode.title":`重命名节点`,"renameNode.description":`接着改文本内容/排版`,"setShape.title":`设置多边形/星形形状`,"setShape.description":`接着设置填充`,"export.title":`导出节点为图片`,"export.description":`导出节点为 PNG/JPG/SVG/PDF;ids 为必填数组(单节点也写成 ids:["123:456"],不是 nodeId),savePath 落盘与 includeDataUrl 返回 base64 可并存。注意:单张图片超过内联上限(默认 512KB)时不返回 base64,自动落盘并返回路径引用,避免撑爆会话内存。完整字段见 inputSchema。`,"export.description2":`导出后用该图片填充到节点`,"fillImage.title":`本地图片填充节点`,"fillImage.description":`读取本地图片文件填充到指定节点(IMAGE fill)`,"fillImage.description2":`复核图片填充效果`,"listFonts.title":`列出可用字体`,"listFonts.description":`用列出的字体设置文本`,"resources.title":`画布当前选中`,"resources.title2":`可用字体列表`,"resources.title3":`本地样式列表`,"resources.title4":`当前页结构总览`,"resources.title5":`节点详情`,"resources.title6":`平台状态与能力表`,"ping.followUp":`连接确认后读取当前选中`,"getSelection.title":`读取画布选中`,"getSelection.description":`获取画布当前选中节点的序列化树(名称/类型/尺寸/位置/填充/子结构);depth 控制层级深度,默认 2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上),判断遮挡读 z 即可`,"getSelection.description2":`在选中范围内继续精确查找节点`,"mcp.instructions":`操作设计画布的工具集。一个操作对应一个 jsd_* 工具,无 op 分发;聚合入口 jsd_manage_nodes / jsd_manage_components 仅用于批量/混合结构操作。调用纪律:
9
+ - 建节点用 per-type 工具:jsd_create_frame / jsd_create_rectangle / jsd_create_text 等,每个工具只建一类节点;多根/复杂嵌套树用 jsd_batch 编排多个建节点步骤。**根节点的 x/y 由 placement 决定**(缺省 center 用视口中心覆盖根节点自身的 x/y;要按坐标排布传 placement:{mode:"manual"},或 mode:"absolute"+x/y 统一坐标),层级结构用 children 嵌套(子节点 x/y 相对父节点)。建完再 jsd_reparent_nodes 归组(**parentId 显式传目标容器 id**;跨父级移动会保持节点绝对位置,内部自动换算新父下的 x/y,不用手动摆回,移入 auto-layout 容器时位置由布局接管);auto-layout(layoutMode/itemSpacing/padding* 等)最后用 jsd_set_layout 单独设置。
10
+ - 改属性用专责工具:填充 jsd_set_fill_color、描边 jsd_set_stroke、圆角 jsd_set_cornerRadius、文本 jsd_set_text、位置 jsd_move_node、尺寸 jsd_resize_node(可同时传 x/y)、布局 jsd_set_layout、效果 jsd_set_effects、显隐 jsd_set_visibility、改名 jsd_rename_node、形状 jsd_set_shape。
11
+ - 跨工具多步流程用 jsd_batch 编排:双花括号占位符(步骤id.字段路径)引用上步结果,中间 id 不回传模型;**占位符只在同一次调用的本批次内有效** —— 跨批次引用必报「占位符引用的步骤不存在或未成功」并中止整批,跨批次要硬编码上一步回显里的真实 id;步骤回显已做摘要裁剪(节点只留 id/name/type/x/y),含图标/矢量的批次(jsd_create_icon / jsd_clone_node)另配一次 jsd_export 目视验收 —— 回显不等于生效。
12
+ - 批量刷样式用 ids 一次下发:recursive=true 只作用于**后代**,不含目标节点自身(给一组图标容器刷描边,容器自己不会被套上方框);要连容器自身一起改才传 includeSelf=true。
13
+ - 实例子节点(位于 INSTANCE 内)的样式覆盖平台不保证渲染生效,命中时结果 warnings 直接给出主组件里对应子节点的 id —— 改主组件即所有实例继承。
14
+ - 结果键约定(写 jsd_batch 占位符靠这份,不靠 outputSchema —— 出参 schema 只投影到「键名+类型」级,见 daemon/compact-schema.ts):节点类结果 created 是单对象或数组(per-type create / jsd_clone_node / jsd_outline_stroke / jsd_create_instance / jsd_detach_instance 是**数组**,jsd_create_svg / jsd_create_icon / jsd_group_nodes / jsd_flatten_nodes / jsd_create_component / jsd_import_component 是**单对象**;jsd_manage_nodes 的 clone/outline_stroke 是数组,group/flatten 是单对象),updated / moved / swapped 是对象数组(键:id/name/type/x/y/width/height/z/parentId);id 清单类 selected / removed / ungrouped / cleaned 是字符串数组;jsd_find 回 nodes + total,jsd_get_selection 回 selection + pageName,jsd_export 回 exports(含 path / dataUrl)。占位符形如 {{上一步id.updated[0].id}},单对象写 {{id.created.id}}(多了 [0] 反而解析失败)。
15
+ - 结果 warnings 一律读:它点名的都是「回显成功但没生效」的事实(平台能力门控字段被忽略、字段回读与请求不一致如 root x/y 被 placement 覆盖 / TEXT 的 textAutoResize 未声明却被置 NONE、fontName 组合不存在被静默忽略、结构变更后的同层漂移),不要当成普通提示跳过。字体写法:family 用 jsd_list_fonts 的 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")。
16
+ - ok=false 或「没找到 X 节点」:先 jsd_find 复核 id 是否已失效(可能被连坐删除),必要时 jsd_repair_nodes 清理后重试。`,"ping.title":`检查{client}插件连接`,"batch.description":`批量编排器:一次请求内顺序执行多个 jsd_* 步骤,前一步结果经双花括号占位符(内容为 步骤id.字段路径)注入后一步 args,中间 id 不回传模型,显著减少往返与上下文。\\n占位符独占一个参数值时保留原类型(数组可直接作 ids 用),嵌在字符串中按 JSON 文本展开;**占位符只在同一次调用的本批次内有效**(步骤表随调用结束即销毁,引用上一批次的步骤必报「占位符引用的步骤不存在或未成功」并中止整批 —— 跨批次请硬编码上一步回显里的真实 id);id 重复/未知工具/引用失败立即中止,工具执行失败默认也中止(stopOnError=false 或单步 continueOnError=true 可走完)。\\n回显已做摘要裁剪:节点对象只留 id/name/type/x/y/width/height/z/parentId,vectorPaths(单条 >10KB、16 位小数)与 constraints 等渲染无关字段整键丢弃;裁剪后仍超 20K 字符的步骤降级为 id 清单(结果里 echoTrimmed=true)。占位符解析不受影响(内部仍用完整数据)。含图标的批次(jsd_create_icon / jsd_clone_node / jsd_create_vector)务必配一次 jsd_export 目视验收,别只看回显。\\n各工具返回键与占位符写法(键写错会报「无法解析占位符引用」并中止整批):\\n· created 为数组 → {{id.created[0].id}}:per-type create(jsd_create_rectangle / jsd_create_frame 等)、jsd_clone_node、jsd_outline_stroke、jsd_create_instance、jsd_detach_instance\\n· created 为单对象 → {{id.created.id}}:jsd_create_svg / jsd_create_icon / jsd_flatten_nodes / jsd_group_nodes / jsd_create_component / jsd_import_component / jsd_combine_as_variants\\n· jsd_find → {{id.nodes[0].id}};jsd_get_selection → {{id.selection[0].id}}\\n· 属性类 jsd_set_* → {{id.updated[0].id}};jsd_swap_component → {{id.swapped[0].id}}\\n· jsd_manage_nodes 各 op:select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**,与 jsd_group_nodes / jsd_flatten_nodes 同形)、ungroup→ungrouped[](id 字符串)、reparent→moved[](与 updated[] 同义,两个键都回)、repair→cleaned[](id 字符串)—— id 字符串数组取 {{id.selected[0]}},节点数组取 {{id.created[0].id}},节点单对象取 {{id.created.id}}(写成 [0] 会报无法解析)\\n· jsd_manage_components 各 op:create_component/create_instance/detach_instance/import_component/combine_as_variants→created(detach_instance 是数组,不是 updated)、swap_component→swapped[]、set_instance_properties→updated[]、copy_overrides→snapshotId、apply_overrides/sync_overrides→applied[]\\n· 拿不准某步的返回结构时,先单独调它一次看回显再拼进 batch —— 猜错会连带整批中止。\\n结构变更复核(默认开,checkDrift=false 可关):步骤里含 remove/reparent/group/ungroup/flatten/repair 时,变更前记下受影响父层(含 reparent 的目标父级与当前页顶层)的子节点坐标,收尾再读一次比对 —— 引擎在删改结构后会把**没碰到**的兄弟节点静默挪走(实测 (24,720)→(28,618):无报错、回显正常,渲染上像样式问题,极易走错排查方向)。漂移写进结果 warnings 并给出原值,照原值用 jsd_move_node 回填即可;覆盖面仅限本次操作触及的父层(协议没有整树读法,别的层漂移查不到)。'`,"manageNodes.description":`按 op 分发的节点结构操作聚合入口:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair。单次单操作请优先用对应小工具: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_set_* 系列(含 jsd_set_shape);组件/实例操作用 jsd_manage_components 或 jsd_create_component / jsd_sync_overrides 等,两工具 op 不通用。\\n各 op 的返回键(在 jsd_batch 里用占位符引用时才不会写错,写错会中止整批):select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**:这两个 op 内部走的就是 jsd_group_nodes / jsd_flatten_nodes 那条路)、ungroup→ungrouped[](id 字符串)、reparent→moved[](同时附 updated[],两者同一份数组)、repair→cleaned[](id 字符串)。id 字符串数组取 {{步骤id.selected[0]}},节点数组取 {{步骤id.created[0].id}},节点单对象取 {{步骤id.created.id}}(写成 [0] 会报无法解析)。'`,"createBooleanOperation.description":`创建单个 BOOLEAN_OPERATION 布尔运算节点,booleanOperation 运算方式({ops})与 children 必填且至少 2 个合并子节点。本工具只建一个根布尔节点;建多个根节点/复杂树用 jsd_batch 编排`,"setFillColor.description":`设置填充色/渐变(fills 为 Paint 数组,整体替换非合并,需保留的现有填充项要一并传入)、混合模式与团队库填充样式。{warn}`,"setText.description":`修改文本内容与排版(仅 TEXT 节点生效):characters/fontSize/fontName/对齐/自适应/大小写/装饰/行高/字距,以及 Figma 的截断与最大行数。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算)。{warn};characters 内容覆盖在实例内也是正常生效的`,"ping.description":`检查插件是否在线(需先在{client}(即时设计或 Figma)中运行该插件并保持运行)。返回三个能力表:coreCapabilities 为核心能力(create/modify/structure/component/export/image,两平台一致);capabilities 只列平台差异超集(如 variables/componentProperties/textTruncation),即时设计通常只有 styles,Figma 还会有 variables/componentProperties 等;platformOps 列当前平台可用的特有操作(名/标题/参数说明),调 jsd_platform_op 前先读它。回包会被 daemon 缓存,后续可直接读 jsd://platform/state(不必重复 ping)`},ye=[`styles`,`textTruncation`,`componentProperties`,`variables`,`platformOps`,`inPlaceVariants`],be=[`create`,`modify`,`structure`,`component`,`export`,`image`];b[`capability.host.styles`],b[`capability.host.textTruncation`],b[`capability.host.componentProperties`],b[`capability.host.variables`],b[`capability.host.platformOps`],b[`capability.host.inPlaceVariants`],b[`capability.core.create`],b[`capability.core.modify`],b[`capability.core.structure`],b[`capability.core.component`],b[`capability.core.export`],b[`capability.core.image`],Object.fromEntries(Object.entries({styles:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],textTruncation:[`textTruncation`,`maxLines`],componentProperties:[`componentProperties`],variables:[],platformOps:[],inPlaceVariants:[]}).flatMap(([e,t])=>t.map(t=>[t,e])));var xe=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],Se={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},Ce=xe.join(`/`),we=`布尔运算:${xe.map(e=>`${e}=${Se[e]}`).join(`,`)}`,Te=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Ee=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],De=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Oe=[`MIN`,`CENTER`,`MAX`],ke={blendMode:Te,layoutAlign:Ee,primaryAxisAlignItems:De,counterAxisAlignItems:Oe},Ae={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},je={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},Me={figma:{layoutGrow:{allow:[0,1]}},jsdesign:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}},mastergo:{primaryAxisAlignItems:{deny:[`MAX`,`SPACE_BETWEEN`]},counterAxisAlignItems:{deny:[`MAX`]}}};function Ne(e,t){if(e==null)return null;let n=Me[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=Ae[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function Pe(e,t,n){let r=Ne(e,t);if(r==null)return!0;let{rule:i}=r;return i.allow==null?!(i.deny??[]).some(e=>e===n):i.allow.some(e=>e===n)}function Fe(e,t,n){if(e==null)return!0;let r=je[e]?.[t];return r==null||!r.some(e=>e===n)}function Ie(e,t){let n=Ne(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(ke[t]??[]).filter(n=>Pe(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}function Le(e){let t=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());if(t==null)return null;let n=t[1];(n.length===3||n.length===4)&&(n=[...n].map(e=>e+e).join(``));let r=e=>Number.parseInt(e,16)/255,i={r:r(n.slice(0,2)),g:r(n.slice(2,4)),b:r(n.slice(4,6))};return n.length===8&&(i.a=r(n.slice(6,8))),i}var Re=c.object({r:c.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.r`),g:c.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.g`),b:c.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.b`),a:c.number().min(0).max(1,`alpha 通道最大 1(0-255 请先归一化)`).optional().describe(`schema.base.a`)}).strict(),ze=`颜色需为 {r,g,b[,a]} 对象(通道 0-1,0-255 色值请先除以 255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,Be=c.unknown().superRefine((e,t)=>{if(typeof e==`string`){Le(e)??t.addIssue({code:c.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${ze})`});return}let n=Re.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:c.ZodIssueCode.custom,path:e.path,message:e.message})}),Ve=Be.describe(`颜色:{r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),He=Be.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),Ue=c.object({color:He.describe(`schema.base.color`),position:c.number().min(0).max(1).describe(`schema.base.position`)}).describe(`渐变停止点,如 {color:{r:1,g:0,b:0,a:1}, position:0}(起点红色)和 {color:{r:0,g:0,b:1,a:1}, position:1}(终点蓝色)`),We=c.array(c.array(c.number()).length(3)).length(2).describe(`schema.base.transformSchema`),x=c.enum(Te).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),S=c.discriminatedUnion(`type`,[c.object({type:c.literal(`SOLID`).describe(`schema.base.type`),color:Ve.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:c.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:c.boolean().optional().describe(`schema.base.visible`),blendMode:x.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),c.object({type:c.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:c.array(Ue).describe(`schema.base.gradientStops`),gradientTransform:We}).strict().describe(`schema.base.gradientTransform`),c.object({type:c.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:c.array(Ue).describe(`schema.base.gradientStops2`),gradientTransform:We}).strict().describe(`schema.base.gradientTransform2`),c.object({type:c.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:c.array(Ue).describe(`schema.base.gradientStops3`),gradientTransform:We}).strict().describe(`schema.base.gradientTransform3`),c.object({type:c.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:c.string().describe(`schema.base.imageHash`),scaleMode:c.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schema.base.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),Ge=c.discriminatedUnion(`type`,[c.object({type:c.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:He.describe(`schema.base.color2`),offset:c.object({x:c.number().describe(`schema.base.x`),y:c.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:c.number().min(0).describe(`schema.base.radius`),spread:c.number().optional().describe(`schema.base.spread`),visible:c.boolean().optional().describe(`schema.base.visible2`),blendMode:x.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:c.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),c.object({type:c.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:He.describe(`schema.base.color3`),offset:c.object({x:c.number().describe(`schema.base.x2`),y:c.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:c.number().min(0).describe(`schema.base.radius2`),spread:c.number().optional().describe(`schema.base.spread2`),visible:c.boolean().optional().describe(`schema.base.visible3`),blendMode:x.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),c.object({type:c.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:c.number().min(0).describe(`schema.base.radius3`),visible:c.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),c.object({type:c.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:c.number().min(0).describe(`schema.base.radius4`),visible:c.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),C=c.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),Ke=c.object({pattern:c.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:c.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:c.number().optional().describe(`schema.base.sectionSize`),count:c.number().int().positive().optional(),gutterSize:c.number().optional().describe(`schema.base.gutterSize`),offset:c.number().optional().describe(`schema.base.offset`),visible:c.boolean().optional(),color:He.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:c.ZodIssueCode.custom,message:`pattern 为 GRID 时,sectionSize 为必填项`,path:[`sectionSize`]}),e.pattern===`ROWS`||e.pattern===`COLUMNS`)for(let n of[`count`,`gutterSize`])e[n]??t.addIssue({code:c.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${n} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[n]})}),qe=c.object({data:c.string().describe(`SVG path data,如 "M0 0 L100 0 L100 100 Z"(M=移动到,L=画线到,Z=闭合)。仅支持 M/L/Q/C/Z 指令(SVG 子集,不支持 A 圆弧等);完整 SVG 请改用 jsd_create_svg`),windingRule:c.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),Je=c.object({family:c.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:c.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),Ye=c.union([c.object({value:c.number().describe(`schema.base.value`),unit:c.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),c.object({value:c.number().describe(`schema.base.value2`),unit:c.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),c.object({unit:c.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),Xe=c.object({value:c.number(),unit:c.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),Ze=c.object({id:c.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:c.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:c.record(c.string(),c.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符(步骤id.字段路径)引用先前步骤结果`),continueOnError:c.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),Qe=c.object({calls:c.array(Ze).min(1).max(50).describe(`schema.batch.calls`),stopOnError:c.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:c.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),$e=c.object({ok:c.boolean().describe(`schema.batch.ok`),executed:c.number().int().min(0).describe(`schema.batch.executed`),total:c.number().int().min(0).describe(`schema.batch.total`),results:c.array(c.object({id:c.string(),tool:c.string(),ok:c.boolean(),data:c.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:c.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:c.boolean().optional(),warnings:c.array(c.string()).optional()}),et=c.object({ok:c.boolean(),data:c.unknown().optional()}),tt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],nt={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},rt=`节点类型:${tt.map(e=>`${e}=${nt[e]}`).join(` | `)}`,it=[`TEXT_PATH`,`TRANSFORM_GROUP`,`STICKY`,`CONNECTOR`,`SHAPE_WITH_TEXT`,`CODE_BLOCK`,`STAMP`,`WIDGET`,`EMBED`,`LINK_UNFURL`,`MEDIA`,`SECTION`,`HIGHLIGHT`,`WASHI_TAPE`,`TABLE`,`SLIDE`,`SLIDE_ROW`,`SLIDE_GRID`,`SLOT`,`INTERACTIVE_SLIDE_ELEMENT`],at=[`INTELLIGENT_CONTAINER`],ot=[...tt,...it,...at],st=c.enum(tt).describe(rt),ct=c.enum(ot).describe(`${rt};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),lt=c.object({type:st.describe(`schema.executeSchemas.type`),name:c.string().optional(),x:c.number().optional().describe(`schema.executeSchemas.x`),y:c.number().optional().describe(`schema.executeSchemas.y`),width:c.number().optional(),height:c.number().optional()}).catchall(c.unknown()),w={name:c.string().optional(),x:c.number().optional().describe(`schema.executeSchemas.x2`),y:c.number().optional().describe(`schema.executeSchemas.y2`),width:c.number().optional().describe(`schema.executeSchemas.width`),height:c.number().optional().describe(`schema.executeSchemas.height`),rotation:c.number().optional().describe(`schema.executeSchemas.rotation`),opacity:c.number().optional().describe(`schema.executeSchemas.opacity`),visible:c.boolean().optional(),locked:c.boolean().optional(),isMask:c.boolean().optional(),children:c.array(lt).max(100).optional().describe(`子节点数组(递归嵌套,最多 100 个直接子节点;更大的结构建议分批创建后用 jsd_manage_nodes op=reparent 归组)。子节点可使用的字段与顶层 create 入参一致(fills/strokes/cornerRadius/effects 等均可用);x/y 相对父节点,未传 x/y 会叠放在父节点原点(0,0)——非 auto-layout 容器需为每个子节点指定相对坐标`)},T={fills:c.array(S).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:c.array(S).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:c.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:c.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:c.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:c.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:c.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:c.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:c.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.executeSchemas.strokeCap`),strokeJoin:c.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.executeSchemas.strokeJoin`),dashPattern:c.array(c.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:x.optional(),effects:c.array(Ge).optional().describe(`schema.executeSchemas.effects`),constraints:c.object({horizontal:C.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:C.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:c.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:c.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:c.array(Ke).optional().describe(`schema.executeSchemas.layoutGrids`)},ut={cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:c.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:c.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:c.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:c.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)},dt=c.object({type:c.literal(`FRAME`),...w,layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:c.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:c.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:c.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:c.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:c.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`),...ut,...T}).strict().superRefine((e,t)=>{(e.itemSpacing!=null||e.paddingTop!=null||e.paddingRight!=null||e.paddingBottom!=null||e.paddingLeft!=null||e.primaryAxisSizingMode!=null||e.counterAxisSizingMode!=null||e.primaryAxisAlignItems!=null||e.counterAxisAlignItems!=null)&&(e.layoutMode==null||e.layoutMode===`NONE`)&&t.addIssue({code:c.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).strict().describe(`FRAME=容器(可 auto-layout)。注意:未显式传 fills 时引擎默认白底,透明容器请显式传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]`),ft=c.object({type:c.literal(`RECTANGLE`),...w,...ut,...T}).strict().describe(`schema.executeSchemas.type2`),pt=c.object({type:c.literal(`ELLIPSE`),...w,cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius2`),arcData:c.object({startingAngle:c.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:c.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:c.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schema.executeSchemas.innerRadius2`),...T}).strict().describe(`schema.executeSchemas.innerRadius3`),mt=c.object({type:c.literal(`LINE`),...w,...T}).strict().describe(`schema.executeSchemas.type3`),ht=c.object({type:c.literal(`POLYGON`),...w,pointCount:c.number().describe(`schema.executeSchemas.pointCount`),cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius3`),topLeftRadius:c.number().optional().describe(`schema.executeSchemas.topLeftRadius2`),topRightRadius:c.number().optional().describe(`schema.executeSchemas.topRightRadius2`),bottomLeftRadius:c.number().optional().describe(`schema.executeSchemas.bottomLeftRadius2`),bottomRightRadius:c.number().optional().describe(`schema.executeSchemas.bottomRightRadius2`),...T}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),gt=c.object({type:c.literal(`STAR`),...w,pointCount:c.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:c.number().describe(`schema.executeSchemas.innerRadius4`),cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius4`),topLeftRadius:c.number().optional().describe(`schema.executeSchemas.topLeftRadius3`),topRightRadius:c.number().optional().describe(`schema.executeSchemas.topRightRadius3`),bottomLeftRadius:c.number().optional().describe(`schema.executeSchemas.bottomLeftRadius3`),bottomRightRadius:c.number().optional().describe(`schema.executeSchemas.bottomRightRadius4`),...T}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),_t=c.object({type:c.literal(`VECTOR`),...w,vectorPaths:c.array(qe).describe(`schema.executeSchemas.vectorPaths`),...T}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),vt=c.object({type:c.literal(`TEXT`),...w,characters:c.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:c.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:Je.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:c.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:c.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:c.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:c.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.executeSchemas.textCase`),textDecoration:c.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.executeSchemas.textDecoration`),lineHeight:Ye.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:Xe.optional().describe(`schema.executeSchemas.letterSpacing`),...T}).strict().describe(`schema.executeSchemas.letterSpacing2`),yt=c.object({type:c.literal(`GROUP`),...w,children:c.array(lt).min(2).max(100).describe(`schema.executeSchemas.children`),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:c.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.executeSchemas.paddingTop2`),paddingRight:c.number().optional().describe(`schema.executeSchemas.paddingRight2`),paddingBottom:c.number().optional().describe(`schema.executeSchemas.paddingBottom2`),paddingLeft:c.number().optional().describe(`schema.executeSchemas.paddingLeft2`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode2`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode2`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems2`),...T}).strict().superRefine((e,t)=>{(e.itemSpacing!=null||e.paddingTop!=null||e.paddingRight!=null||e.paddingBottom!=null||e.paddingLeft!=null||e.primaryAxisSizingMode!=null||e.counterAxisSizingMode!=null||e.primaryAxisAlignItems!=null||e.counterAxisAlignItems!=null)&&(e.layoutMode==null||e.layoutMode===`NONE`)&&t.addIssue({code:c.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`schema.executeSchemas.path`),bt=c.object({type:c.literal(`BOOLEAN_OPERATION`),...w,booleanOperation:c.enum(xe).describe(we),children:c.array(lt).min(2).describe(`schema.executeSchemas.children2`),...T}).strict().describe(`schema.executeSchemas.children3`),xt=c.discriminatedUnion(`type`,[dt,ft,pt,mt,ht,gt,_t,vt,yt,bt]),St=c.object({mode:c.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:c.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:c.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:c.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});c.object({ops:c.array(xt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:St.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict();var Ct=c.object({svg:c.string().describe(`完整 SVG 字符串,如 <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M0 0 L100 0 L100 100 Z" fill="#ff0000"/></svg>`),name:c.string().optional().describe(`schema.execute.name`)}),wt=c.object({html:c.string().describe(`schema.execute.html`),name:c.string().optional().describe(`schema.execute.name2`)}),Tt=c.object({icon:c.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:c.number().optional().describe(`schema.execute.size`),color:c.string().optional().describe(`schema.execute.color`),strokeWidth:c.number().optional().describe(`schema.execute.strokeWidth`),name:c.string().optional().describe(`schema.execute.name3`)});c.object({});var Et=c.object({depth:c.number().optional().describe(`schema.executeOp.depth`)}),Dt=[`page`,`document`],Ot=[`jsdesign`,`figma`,`mastergo`],kt={jsdesign:b[`platform.jsdesign`],figma:b[`platform.figma`],mastergo:b[`platform.mastergo`]},At=c.enum(Ot),jt=c.enum(ye),Mt=c.enum(be),Nt=c.object({name:c.string().describe(`schema.platform.name`),title:c.string(),description:c.string().describe(`schema.platform.description`)}),Pt=c.object({type:c.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`]),value:c.union([c.boolean(),c.string()]),preferredValues:c.array(c.object({type:c.enum([`COMPONENT`,`COMPONENT_SET`]),key:c.string()})).optional()}),Ft=c.union([c.string(),c.boolean(),Pt]),It=c.object({type:c.literal(`VARIABLE_ALIAS`),id:c.string()}),Lt=c.record(c.string(),c.union([It,c.array(It),c.record(c.string(),It)])),Rt=ot.slice(tt.length).join(`/`),zt=c.object({ids:c.array(c.string()).optional().describe(`schema.inputs.ids`),name:c.string().optional().describe(`schema.inputs.name`),type:c.string().optional().describe(`节点类型过滤,支持:${tt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${Rt}),这些类型能读不能建`),scope:c.enum(Dt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)`),recursive:c.boolean().optional().describe(`schema.inputs.recursive`),depth:c.number().optional().describe(`schema.inputs.depth`)}),Bt=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],Vt=c.object({op:c.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return Bt.includes(n)?`"${n}" 是组件/实例操作,应使用 jsd_manage_components;本工具仅支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair`:`无效 op${n===``?`(缺省)`:` "${n}"`},本工具支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair(组件/实例操作在 jsd_manage_components)`}}).describe(`节点结构操作类型:select 设当前选中 | remove 删除(matchName 可再过滤) | clone 复制(右下偏移) | group 编组(可带 layoutMode/itemSpacing/padding* 参数) | ungroup 解组 | flatten 合并为矢量(至少 2 节点) | outline_stroke 描边转轮廓 | reparent 移到 parentId 下(缺省当前选中第一个) | repair 清理已损坏节点`),ids:c.array(c.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:c.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:c.string().optional().describe(`schema.inputs.name2`),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:c.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:c.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:c.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:c.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:c.number().optional().describe(`仅 reparent:插入位置 = children 下标(0 = 最底层,末位 = 最上层,即序列化里的 z);缺省追加到末尾(最上层)。节点已在该父级下时用它调层序;auto-layout 容器同样支持`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`select`:case`clone`:case`group`:case`ungroup`:case`flatten`:case`outline_stroke`:case`reparent`:r||n(`ids`)}e.op===`flatten`&&r&&Array.isArray(e.ids)&&e.ids.length<2&&t.addIssue({code:`custom`,path:[`ids`],message:`op=flatten 至少需要 2 个节点 id`})}),Ht=c.object({op:c.enum([`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`]).describe(`组件操作类型;注意 combine_as_variants/detach_instance 在当前即时设计引擎有内部崩溃,已内置多姿势/副本兜底,仍失败时详见 jsd_manage_components 工具描述`),ids:c.array(c.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:c.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:c.string().optional().describe(`schema.inputs.key`),componentId:c.string().optional().describe(`schema.inputs.componentId`),properties:c.record(c.string(),Ft).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:c.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:c.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`create_component`:case`create_instance`:case`detach_instance`:case`swap_component`:case`set_instance_properties`:case`combine_as_variants`:r||n(`ids`);break;case`import_component`:(typeof e.key!=`string`||e.key.length===0)&&n(`key`);break;case`copy_overrides`:(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`apply_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`sync_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`)}e.op===`swap_component`&&typeof e.componentId!=`string`&&n(`componentId`),e.op===`set_instance_properties`&&(e.properties==null||typeof e.properties!=`object`)&&n(`properties`)}),Ut=c.object({ids:c.array(c.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:c.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:c.number().optional().describe(`schema.inputs.scale`),savePath:c.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:c.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),Wt=c.object({family:c.string().optional().describe(`schema.inputs.family`),offset:c.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:c.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});c.object({}),c.object({});var Gt=c.object({ids:c.array(c.string()).describe(`schema.inputs.ids2`),sourcePath:c.string().describe(`schema.inputs.sourcePath`)}),Kt=c.object({op:c.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:c.record(c.string(),c.unknown()).optional().describe(`schema.inputs.params`)}),E=c.lazy(()=>c.object({id:c.string(),name:c.string(),type:ct,x:c.number(),y:c.number(),width:c.number().optional(),height:c.number().optional(),rotation:c.number().optional(),opacity:c.number().optional(),visible:c.boolean().optional(),locked:c.boolean().optional(),parentId:c.string().optional(),z:c.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:c.array(S).optional(),strokes:c.array(S).optional(),strokeWeight:c.number().optional(),strokeTopWeight:c.number().optional(),strokeBottomWeight:c.number().optional(),strokeLeftWeight:c.number().optional(),strokeRightWeight:c.number().optional(),strokeAlign:c.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:c.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:c.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:c.array(c.number()).optional(),cornerSmoothing:c.number().optional(),blendMode:x.optional(),constraints:c.object({horizontal:C,vertical:C}).optional(),layoutGrids:c.array(Ke).optional(),clipsContent:c.boolean().optional(),arcData:c.object({startingAngle:c.number(),endingAngle:c.number(),innerRadius:c.number()}).optional(),effects:c.array(Ge).optional(),cornerRadius:c.number().optional(),topLeftRadius:c.number().optional(),topRightRadius:c.number().optional(),bottomLeftRadius:c.number().optional(),bottomRightRadius:c.number().optional(),pointCount:c.number().optional(),innerRadius:c.number().optional(),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:c.number().optional(),paddingTop:c.number().optional(),paddingRight:c.number().optional(),paddingBottom:c.number().optional(),paddingLeft:c.number().optional(),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:c.number().optional(),layoutAlign:c.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:c.number().optional(),children:c.array(E).optional(),characters:c.string().optional(),fontSize:c.number().optional(),fontName:Je.optional(),textAlignHorizontal:c.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:c.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:c.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:c.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:c.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:Ye.optional(),letterSpacing:Xe.optional(),vectorPaths:c.array(qe).optional(),booleanOperation:c.enum(xe).optional(),isMask:c.boolean().optional(),variantProperties:c.record(c.string(),c.string()).optional(),mainComponentId:c.string().optional(),variantGroupProperties:c.record(c.string(),c.array(c.string())).optional(),textTruncation:c.enum([`DISABLED`,`ENDING`]).optional(),maxLines:c.number().optional(),fillStyleId:c.string().optional(),strokeStyleId:c.string().optional(),textStyleId:c.string().optional(),effectStyleId:c.string().optional(),componentProperties:c.record(c.string(),Pt).optional(),boundVariables:Lt.optional()})),qt=c.object({created:c.union([E,c.array(E)]),warnings:c.array(c.string()).optional()}),Jt=c.object({updated:c.array(E),warnings:c.array(c.string()).optional()}),Yt=c.object({connected:c.boolean(),platform:At.optional(),capabilities:c.array(jt).optional().describe(`schema.results.capabilities`),coreCapabilities:c.array(Mt).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:c.array(Nt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:c.string().optional()}),Xt=c.object({selection:c.array(E),pageName:c.string()}),Zt=c.object({nodes:c.array(E),total:c.number(),scope:c.enum(Dt).optional(),note:c.string().optional()}),Qt=c.object({selected:c.array(c.string()).optional(),removed:c.array(c.string()).optional(),ungrouped:c.array(c.string()).optional(),moved:c.array(E).optional(),updated:c.array(E).optional(),cleaned:c.array(c.string()).optional(),created:c.union([E,c.array(E)]).optional()}),$t=c.object({variantProperties:c.record(c.string(),c.string()).optional(),componentProperties:c.record(c.string(),Pt).optional(),propsSummary:c.array(c.string()).optional()}),en=c.object({instanceId:c.string(),instanceName:c.string(),ok:c.boolean(),message:c.string().optional()}),tn=c.object({created:c.union([E,c.array(E)]).optional(),swapped:c.array(E).optional(),updated:c.array(E).optional(),snapshotId:c.string().optional(),sourceName:c.string().optional(),captured:$t.optional(),applied:c.array(en).optional(),source:$t.optional(),failed:c.array(c.object({id:c.string(),message:c.string()})).optional(),warnings:c.array(c.string()).optional()}),nn=c.object({exports:c.array(c.object({id:c.string(),name:c.string(),format:c.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:c.string(),size:c.number(),path:c.string().optional(),dataUrl:c.string().optional()}))}),rn=c.object({families:c.array(c.string()).describe(`schema.results.families`),fonts:c.array(c.object({family:c.string().describe(`schema.results.family`),styles:c.array(c.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:c.number().describe(`schema.results.count`),total:c.number().optional().describe(`schema.results.total`),offset:c.number().optional().describe(`schema.results.offset`),truncated:c.boolean().optional().describe(`schema.results.truncated`)});c.object({pageName:c.string(),nodes:c.array(c.object({id:c.string(),name:c.string(),type:ct,x:c.number(),y:c.number(),z:c.number().optional(),width:c.number().optional(),height:c.number().optional(),childCount:c.number().optional()})),count:c.number(),pages:c.array(c.object({name:c.string(),childCount:c.number()})).optional(),note:c.string().optional()}),c.object({styles:c.array(c.object({id:c.string(),name:c.string(),type:c.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])})),count:c.number()});var D=c.object({x:c.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:c.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:c.number().optional().describe(`schema.sharedProps.width`),height:c.number().optional().describe(`schema.sharedProps.height`),rotation:c.number().optional().describe(`schema.sharedProps.rotation`),opacity:c.number().optional().describe(`schema.sharedProps.opacity`),visible:c.boolean().optional(),locked:c.boolean().optional()}),an=c.object({width:c.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:c.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),on=c.object({pointCount:c.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:c.number().optional().describe(`schema.sharedProps.innerRadius`)}),sn=c.object({strokes:c.array(S).optional().describe(`schema.sharedProps.strokes`),strokeWeight:c.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:c.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:c.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:c.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:c.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:c.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:c.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.sharedProps.strokeCap`),strokeJoin:c.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.sharedProps.strokeJoin`),dashPattern:c.array(c.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:c.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),cn=c.object({cornerRadius:c.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:c.number().optional().describe(`schema.sharedProps.topLeftRadius`),topRightRadius:c.number().optional().describe(`schema.sharedProps.topRightRadius`),bottomLeftRadius:c.number().optional().describe(`schema.sharedProps.bottomLeftRadius`),bottomRightRadius:c.number().optional().describe(`schema.sharedProps.bottomRightRadius`)}),ln=c.object({characters:c.string().optional().describe(`schema.sharedProps.characters`),fontSize:c.number().optional().describe(`schema.sharedProps.fontSize`),fontName:Je.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:c.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:c.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:c.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:c.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.sharedProps.textCase`),textDecoration:c.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.sharedProps.textDecoration`),lineHeight:Ye.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:Xe.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:c.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:c.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:c.number().optional().describe(`schema.sharedProps.maxLines`)}),un=c.object({layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:c.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:c.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:c.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:c.enum(De).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum(Oe).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:c.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:c.enum(Ee).optional().describe(`schema.sharedProps.layoutAlign`)}),O=c.object({fills:c.array(S).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:c.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:x.optional(),effectStyleId:c.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:c.array(Ge).optional().describe(`schema.sharedProps.effects`),constraints:c.object({horizontal:C.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:C.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:c.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:c.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:c.array(Ke).optional().describe(`schema.sharedProps.layoutGrids`),arcData:c.object({startingAngle:c.number().describe(`schema.sharedProps.startingAngle`),endingAngle:c.number().describe(`schema.sharedProps.endingAngle`),innerRadius:c.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),dn={ids:c.array(c.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:c.string().optional().describe(`schema.splitOps.matchName`),recursive:c.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:c.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},k=(e,t=1)=>c.array(c.string()).min(t).describe(e),fn=c.object({ids:k(`要设为当前选中的节点 id 列表`)}).strict(),pn=c.object({ids:c.array(c.string()).optional().describe(`schema.splitOps.ids2`),matchName:c.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),mn=c.object({ids:k(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),hn=c.object({ids:k(`要编组的节点 id 列表,至少 2 个`,2),name:c.string().optional().describe(`schema.splitOps.name`),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:c.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:c.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:c.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),gn=c.object({ids:k(`要解组的节点 id 列表`)}).strict(),_n=c.object({ids:k(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),vn=c.object({ids:k(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),yn=c.object({ids:k(`要移动的节点 id 列表`),parentId:c.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:c.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),bn=c.object({ids:c.array(c.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),xn=c.object({ids:c.array(c.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:c.string().optional().describe(`schema.splitOps.name2`),children:c.array(lt).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:c.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:c.number().optional().describe(`组件高度(px);同上`)}).strict(),Sn=c.object({ids:k(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),Cn=c.object({ids:k(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),wn=c.object({key:c.string().describe(`schema.splitOps.key`),name:c.string().optional().describe(`schema.splitOps.name3`)}).strict(),Tn=c.object({ids:k(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:c.string().describe(`schema.splitOps.componentId`)}).strict(),En=c.object({ids:k(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:c.record(c.string(),Ft).describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名从 jsd_find / jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配;宿主侧键可能是属性 id(如 Property 1#1:0),名字也能用 —— 门面会自动归一`)}).strict(),Dn=c.object({ids:k(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:c.string().optional().describe(`schema.splitOps.name4`)}).strict(),On=c.object({sourceId:c.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),kn={ids:k(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:c.string().describe(`schema.splitOps.sourceId`),swapToSource:c.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},An=c.object(kn).strict(),jn=c.object(kn).strict(),Mn={fills:O.shape.fills,fillStyleId:O.shape.fillStyleId,blendMode:O.shape.blendMode},Nn={...sn.shape},Pn={cornerRadius:cn.shape.cornerRadius,topLeftRadius:cn.shape.topLeftRadius,topRightRadius:cn.shape.topRightRadius,bottomLeftRadius:cn.shape.bottomLeftRadius,bottomRightRadius:cn.shape.bottomRightRadius,cornerSmoothing:O.shape.cornerSmoothing},Fn={...ln.shape},In={x:D.shape.x,y:D.shape.y,rotation:D.shape.rotation},Ln={...an.shape,x:D.shape.x,y:D.shape.y},Rn={...un.shape,constraints:O.shape.constraints},zn={effects:O.shape.effects,effectStyleId:O.shape.effectStyleId,clipsContent:O.shape.clipsContent,layoutGrids:O.shape.layoutGrids,arcData:O.shape.arcData},Bn={opacity:D.shape.opacity,visible:D.shape.visible,locked:D.shape.locked},Vn={name:c.string().describe(`schema.splitOps.name5`)},Hn={...on.shape};function A(e){return c.object({...dn,...e}).strict()}var Un=A(Mn),Wn=A(Nn),Gn=A(Pn),Kn=A(Fn),qn=A(In),Jn=A(Ln),Yn=A(Rn),Xn=A(zn),Zn=A(Bn),Qn=A(Vn),$n=A(Hn),er={set_fill:Object.keys(Mn),set_stroke:Object.keys(Nn),set_corner_radius:Object.keys(Pn),set_text:Object.keys(Fn),move:Object.keys(In),resize:Object.keys(Ln),set_layout:Object.keys(Rn),set_effects:Object.keys(zn),set_visibility:Object.keys(Bn),rename:Object.keys(Vn),set_shape:Object.keys(Hn)};function j(e){return c.object({...dn,props:c.object(e).strict()}).strict()}j(Mn),j(Nn),j(Pn),j(Fn),j(In),j(Ln),j(Rn),j(zn),j(Bn),j(Vn),j(Hn);var tr={pointCount:[`POLYGON`,`STAR`],innerRadius:[`STAR`],arcData:[`ELLIPSE`],characters:[`TEXT`],fontSize:[`TEXT`],fontName:[`TEXT`],textAlignHorizontal:[`TEXT`],textAlignVertical:[`TEXT`],textAutoResize:[`TEXT`],textCase:[`TEXT`],textDecoration:[`TEXT`],lineHeight:[`TEXT`],letterSpacing:[`TEXT`],textTruncation:[`TEXT`],maxLines:[`TEXT`],layoutMode:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],itemSpacing:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingTop:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingRight:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingBottom:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingLeft:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],primaryAxisSizingMode:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],counterAxisSizingMode:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],primaryAxisAlignItems:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],counterAxisAlignItems:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],cornerRadius:[`FRAME`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`VECTOR`,`BOOLEAN_OPERATION`],cornerSmoothing:[`FRAME`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`VECTOR`,`BOOLEAN_OPERATION`],layoutGrids:[`FRAME`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`],clipsContent:[`FRAME`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`],topLeftRadius:[`FRAME`,`RECTANGLE`],topRightRadius:[`FRAME`,`RECTANGLE`],bottomLeftRadius:[`FRAME`,`RECTANGLE`],bottomRightRadius:[`FRAME`,`RECTANGLE`]};function nr(e,t){let n=tr[e];return n==null||n.some(e=>e===t)}function rr(e){let t=e.filter(e=>tr[e]!=null);return t.length===0?null:`以下属性与目标节点类型不匹配,已被忽略:${t.map(e=>`${e}(仅适用于 ${tr[e].join(`/`)})`).join(`、`)}`}function ir(e,t,n){let r=e.ctx.platform;return r==null?null:Fe(r,t,e.node.type)?Pe(r,t,n)?null:`value`:`type`}function ar(e,t,n){let r=ir(e,t,n);if(r==null)return!0;let i=e.ctx.platform;if(i==null)return!0;let a=kt[i];if(e.outcome.ignored.add(t),r===`type`)return e.outcome.warnings.push(`${t} 在 ${a} 的「${e.node.type}」上没有对应字段(该平台的这类节点不含这个属性的 mixin),本次已跳过:不是写失败,是这种节点上不存在该属性。要用它就换本平台支持该属性的节点类型;不去写的话结果里不会再回显它。`),!1;let o=Ie(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function or(e,t,n){e[t]=n}function sr(e,t,n){return n==null||!(t in e)?!1:(or(e,t,n),!0)}function cr(e,t,n,r){return r==null||!nr(n,t.type)||!ar(e,n,r)?!1:sr(t,n,r)}var lr={id:`layout`,keys:[`layoutMode`,`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`],write(e){let{node:t,src:n,create:r}=e,i=n.layoutMode;if(r){if(i==null)return;cr(e,t,`layoutMode`,i);let r=n;cr(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])cr(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])cr(e,t,n,r[n]);ur(e);return}for(let r of lr.keys)cr(e,t,r,n[r])},settle(e){let{node:t,src:n}=e;for(let r of[`primaryAxisAlignItems`,`counterAxisAlignItems`]){let i=n[r];i!=null&&nr(r,t.type)&&ir(e,r,i)==null&&(r in t&&t[r]!==i&&or(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||t[r]===i}))}if(n.layoutMode==null||!nr(`layoutMode`,t.type))return;let r=n.layoutMode;`layoutMode`in t&&t.layoutMode!==r&&(t.layoutMode=r);let i=!(`layoutMode`in t)||t.layoutMode===r;e.outcome.readback.push({key:`layoutMode`,ok:i})}};function ur(e){let{node:t,src:n}=e,r=n.layoutMode===`HORIZONTAL`,i=[[`primaryAxisSizingMode`,r?n.width!=null:n.height!=null],[`counterAxisSizingMode`,r?n.height!=null:n.width!=null]];for(let[e,r]of i)r&&n[e]==null&&e in t&&or(t,e,`FIXED`)}var dr=new Set(`fills.strokes.strokeWeight.strokeTopWeight.strokeBottomWeight.strokeLeftWeight.strokeRightWeight.strokeAlign.strokeCap.strokeJoin.dashPattern.blendMode.effects.cornerRadius.topLeftRadius.topRightRadius.bottomLeftRadius.bottomRightRadius.cornerSmoothing.fontName.fontSize.lineHeight.letterSpacing.textCase.textDecoration.textAlignHorizontal.textAlignVertical`.split(`.`));new Set([...new Set([`fills`,`strokes`,`strokeWeight`,`strokeTopWeight`,`strokeBottomWeight`,`strokeLeftWeight`,`strokeRightWeight`,`strokeAlign`,`strokeCap`,`strokeJoin`,`dashPattern`,`blendMode`,`effects`,`cornerRadius`,`topLeftRadius`,`topRightRadius`,`bottomLeftRadius`,`bottomRightRadius`,`cornerSmoothing`,`clipsContent`,`layoutGrids`,`arcData`])].filter(e=>dr.has(e)));function fr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...dr].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var pr={"zh-CN":b,en:{"platform.jsdesign":`jsDesign`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`Create`,"capability.core.modify":`Modify`,"capability.core.structure":`Structure`,"capability.core.component":`Component`,"capability.core.export":`Export`,"capability.core.image":`Image fill`,"capability.host.styles":`Local styles`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.variables":`Variables`,"capability.host.platformOps":`Platform-specific ops`,"capability.host.inPlaceVariants":`In-place variants`,"locale.system":`System`,"locale.zh-CN":`中文`,"locale.en":`English`,"locale.abbr.zh-CN":`中`,"locale.abbr.en":`EN`,"locale.menu":`Language`,"locale.title.followSystem":`Language: follow system (currently {locale})`,"locale.title.fixed":`Language: {locale}`,"status.connected.label":`Connected`,"status.connected.title":`Service is online; plugin and AI session are connected`,"status.connecting.label":`Connecting…`,"status.connecting.title":`Connected to the background service; waiting for it to confirm this channel`,"status.waiting.label":`Waiting`,"status.waiting.title":`No manual action needed while the service is offline — an AI call starts it`,"status.superseded.label":`Taken over`,"status.superseded.title":`Another plugin panel holds the channel; click "Reclaim" to switch back to this panel`,"header.retry":`Retry`,"header.retry.title":`Reconnect to the background service now instead of waiting for the backoff`,"header.reclaim":`Reclaim`,"header.reclaim.title":`Reclaim the channel from the other plugin panel`,"header.meta":`{platform} · :{port}`,"header.meta.portOnly":`:{port}`,"header.meta.title":`Platform {platform} · MCP bridge port {port} (override with TEXT_TO_DESIGN_MCP_PORT)`,"header.meta.titleUnknown":`Platform unknown · MCP bridge port {port} (override with TEXT_TO_DESIGN_MCP_PORT)`,"conn.connected":`Connected. Select nodes on the canvas, click "Copy", then paste into your AI assistant — e.g. "make me another card in this node style"`,"conn.superseded":`Another plugin panel has taken over this channel (only one panel is served at a time), so auto-reconnect has stopped. Click "Reclaim" next to the status badge to switch back to this panel.`,"conn.disconnected.title":`Not connected to the background service`,"conn.disconnected.tutorial":`Install guide`,"conn.copyAi":`① Copy prompt for AI`,"conn.copyDaemon":`② Copy start command`,"conn.copied":`✓ Copied`,"conn.copyAi.hint":`Send it to your AI so it calls jsd_ping to wake the service`,"conn.daemon.note":`Running it in a local terminal keeps the service alive until the next reboot; running it again is safe (an existing instance is skipped).`,"conn.announce.connected":`Connected to the background service`,"conn.announce.connecting":`Connecting to the background service`,"conn.announce.superseded":`Another plugin panel took over the channel`,"conn.announce.disconnected":`Not connected to the background service`,"conn.wakeCmd":`Please connect me to the text-to-design background service:
17
+
18
+ 1. If the MCP server is not registered yet: register a stdio MCP server the native way for your tool,
19
+ with the command \`npx -y text-to-design-mcp@latest\` (no manual install; npx fetches and runs it).
20
+
21
+ 2. Then call jsd_ping — that wakes the background daemon (starting it if needed).
22
+ If it reports "plugin not connected", tell me to run the text-to-design plugin inside my design app.`,"selection.title":`Selected nodes`,"selection.badge":`{count} nodes · {size} serialized`,"selection.copy":`Copy`,"selection.copied":`✓`,"selection.expand":`Expand node list`,"selection.collapse":`Collapse node list`,"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.expand":`Expand`,"capability.card.collapse":`Collapse`,"capability.card.coreSection":`Core capabilities (same on both platforms)`,"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.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>`,"schema.base.r":`Red channel, 0-1 (0=none, 1=full), e.g. 1 for pure red`,"schema.base.g":`Green channel, 0-1`,"schema.base.b":`Blue channel, 0-1`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`Transform matrix [[a,b,tx],[c,d,ty]]`,"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`,"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.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 relative to the parent (px)`,"schema.executeSchemas.y2":`Y relative to the parent (px)`,"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 (Paint array)`,"schema.executeSchemas.strokeWeight":`Stroke weight (px)`,"schema.executeSchemas.strokeTopWeight":`Top stroke weight (px)`,"schema.executeSchemas.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.executeSchemas.strokeLeftWeight":`Left stroke weight (px)`,"schema.executeSchemas.strokeRightWeight":`Right stroke weight (px)`,"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 array, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow/blur, stackable)`,"schema.executeSchemas.vertical":`Constraint inside auto-layout`,"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), same on all four corners`,"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: MIN | MAX | CENTER`,"schema.executeSchemas.layoutGrow":`Grow factor inside auto-layout`,"schema.executeSchemas.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.cornerRadius2":`Corner radius (px)`,"schema.executeSchemas.startingAngle":`Starting angle (radians)`,"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.innerRadius3":`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.cornerRadius3":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius2":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius2":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius2":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius2":`Bottom-right corner radius (px)`,"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.topLeftRadius3":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius3":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius3":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius4":`Bottom-right 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: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"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":`Letter spacing: {value, unit}, unit is PIXELS | PERCENT`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.paddingTop2":`Top padding (px)`,"schema.executeSchemas.paddingRight2":`Right padding (px)`,"schema.executeSchemas.paddingBottom2":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft2":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode2":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`Cross axis alignment: MIN | MAX | CENTER`,"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)`,"schema.sharedProps.strokeTopWeight":`Top stroke weight (px)`,"schema.sharedProps.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.sharedProps.strokeLeftWeight":`Left stroke weight (px)`,"schema.sharedProps.strokeRightWeight":`Right stroke weight (px)`,"schema.sharedProps.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.sharedProps.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.sharedProps.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.topLeftRadius":`Top-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.sharedProps.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.sharedProps.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.sharedProps.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.sharedProps.lineHeight":`Line height: {value, unit}`,"schema.sharedProps.letterSpacing":`Letter spacing: {value, unit}`,"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: MIN | MAX | CENTER`,"schema.sharedProps.layoutGrow":`Grow factor inside auto-layout`,"schema.sharedProps.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"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; nest children recursively with `children` (child x/y is relative to the parent). Set layoutMode=HORIZONTAL or VERTICAL before auto-layout fields (otherwise they are ignored). 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. Use jsd_batch to create multiple roots or complex trees',"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; nest children recursively with `children`. 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). 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; 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. 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; 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; 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; 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; use jsd_batch for multiple roots`,"createBooleanOperation.title":`Create boolean operation node`,"createSvg.title":`Import SVG`,"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 by name (only Figma has them; jsDesign has no equivalent — read the jsd://styles resource for local styles (no same-named tool), jsd_set_instance_properties for component properties). Read platformOps from jsd_ping or jsd://platform/state first`,"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.designStrategy.title":`Design strategy overview`,"prompt.textReplace.title":`Bulk text replacement strategy`,"prompt.variantSync.title":`Bulk sync styles across sibling instances`,"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`,"resources.title":`Current canvas selection`,"resources.title2":`Available font list`,"resources.title3":`Local style list`,"resources.title4":`Current page structure overview`,"resources.title5":`Node detail`,"resources.title6":`Platform state and capabilities`,"ping.followUp":`Read the current selection once the connection is confirmed`,"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`,"mcp.instructions":`Tools for operating the design canvas. One operation per jsd_* tool, no op dispatch; the aggregate entrypoints jsd_manage_nodes / jsd_manage_components are only for batch or mixed structure operations. Discipline:
23
+ - Create nodes with per-type tools: jsd_create_frame / jsd_create_rectangle / jsd_create_text etc., one node type each; use jsd_batch for multi-root or deeply nested trees. The root x/y comes from placement (default center overwrites the root x/y with the viewport centre; pass placement:{mode:"manual"} to lay out by coordinates, or mode:"absolute" with x/y). Nest hierarchy with children (child x/y is relative to the parent), then jsd_reparent_nodes to group (pass parentId explicitly; cross-parent moves preserve absolute position and recompute x/y under the new parent, and auto-layout containers take over the position). Set auto-layout (layoutMode/itemSpacing/padding* …) last with jsd_set_layout.
24
+ - Modify properties with the dedicated tools: fills jsd_set_fill_color, stroke jsd_set_stroke, radius jsd_set_cornerRadius, text jsd_set_text, position jsd_move_node, size jsd_resize_node (x/y too), layout jsd_set_layout, effects jsd_set_effects, visibility jsd_set_visibility, rename jsd_rename_node, shape jsd_set_shape.
25
+ - Orchestrate multi-step flows with jsd_batch: reference earlier results with double-brace placeholders (step id + field path); intermediate ids never reach the model. Placeholders are valid only inside the same call. Step echoes are trimmed (nodes keep id/name/type/x/y), and batches with icons/vectors need a separate jsd_export for visual acceptance — an echo is not proof it worked.
26
+ - Batch styling with ids: recursive=true applies to descendants only, not the target itself (styling a group of icon containers does not frame the container); add includeSelf=true to include it.
27
+ - Style overrides on children inside an INSTANCE are not guaranteed to render; when hit, the result warnings name the matching child in the main component — fix the main component and every instance inherits it.
28
+ - Result key contract (needed to write jsd_batch placeholders; not from outputSchema, which is projected to key names + types only, see daemon/compact-schema.ts): node results created is a single object or an array (per-type create / jsd_clone_node / jsd_outline_stroke / jsd_create_instance / jsd_detach_instance are arrays; jsd_create_svg / jsd_create_icon / jsd_group_nodes / jsd_flatten_nodes / jsd_create_component / jsd_import_component are single objects), updated / moved / swapped are arrays of objects (keys id/name/type/x/y/width/height/z/parentId), id lists selected / removed / ungrouped / cleaned are string arrays, jsd_find returns nodes + total, jsd_get_selection returns selection + pageName, jsd_export returns exports (with path / dataUrl). Placeholders look like {{id.updated[0].id}}; for a single object write {{id.created.id}} (adding [0] breaks it).
29
+ - Always read the result warnings: they name facts that "echoed success but did not take effect" (fields ignored by platform capability gating, read-back mismatches such as root x/y overwritten by placement, TEXT textAutoResize silently set to NONE, unknown fontName combinations, sibling drift after structure changes). Font resolution: family from jsd_list_fonts fonts[].family verbatim, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not "Bold").
30
+ - ok=false or "node X not found": first jsd_find to check whether the id is gone (it may have been deleted as collateral), then jsd_repair_nodes if needed and retry.`,"ping.title":`Check {client} plugin connection`,"batch.description":`Batch orchestrator: runs several jsd_* steps in order inside one request. Earlier results are injected into later args through double-brace placeholders (content = step id + field path); intermediate ids never reach the model, which cuts round-trips and context a lot.
31
+ A placeholder that occupies a whole argument keeps its type (an array can be used directly as ids); embedded in a string it is expanded as JSON text. Placeholders are valid only inside the same call (the step table is destroyed when the call ends; referencing a previous batch aborts the whole batch). Duplicate ids, unknown tools or unresolvable references abort immediately; a failing step aborts by default (stopOnError=false, or per-step continueOnError=true, lets it finish).
32
+ Echoes are trimmed: node objects keep id/name/type/x/y/width/height/z/parentId; vectorPaths and constraints are dropped entirely. Steps still over 20K chars after trimming degrade to an id list (echoTrimmed=true). Resolution is unaffected (the full data is used internally). Batches containing icons must be verified visually with one jsd_export — an echo is not proof.
33
+ Result keys and placeholder syntax per tool (a wrong key aborts the batch): created is an array for per-type create / jsd_clone_node / jsd_outline_stroke / jsd_create_instance / jsd_detach_instance and a single object for jsd_create_svg / jsd_create_icon / jsd_flatten_nodes / jsd_group_nodes / jsd_create_component / jsd_import_component / jsd_combine_as_variants; jsd_find -> nodes; jsd_get_selection -> selection; jsd_set_* -> updated; jsd_swap_component -> swapped; jsd_manage_nodes ops: select/remove/ungroup/repair -> id string arrays, clone/outline_stroke -> created[group/flatten -> created (single object), reparent -> moved[].
34
+ Structure drift review is on by default (checkDrift=false disables it): steps containing remove/reparent/group/ungroup/flatten/repair record sibling coordinates before the change and report any node that moved on its own.`,"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.
35
+ 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; 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 content and typography (TEXT nodes only): characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, plus Figma truncation and max lines. 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). {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`}},mr=/\{(\w+)\}/g;function hr(e){let t=pr[e]??pr.en,n=pr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(mr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var gr=/^zh([-_]|$)/i,_r=/^en([-_]|$)/i;function vr(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(gr.test(t))return`zh-CN`;if(_r.test(t))return`en`}}var yr={debug:0,info:1,warn:2,error:3},br=process.env.TEXT_TO_DESIGN_MCP_LOG??`/tmp/text-to-design-mcp.log`,xr=yr,Sr=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,Cr=null;function wr(e){Cr=e}function Tr(e,n){if(xr[e]>=xr[Sr])try{t(br,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{Cr?.(e,n)}catch{}}function M(e){Tr(`info`,e)}function N(e){Tr(`debug`,e)}function P(e){Tr(`warn`,e)}function F(e){Tr(`error`,e)}var Er=ve,Dr=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??Er,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 y(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new y(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(this.detachAbort(l),M(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new y(`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),t.ok?n.resolve(t.data):n.reject(t.error?new y(t.error.code,t.error.message):new y(`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 y(`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(Or(e.data,e.buffers))}};function Or(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 kr=`0.8.3`,Ar=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),jr=`text-to-design-mcp-server`,L=kr,Mr=Date.now(),Nr=15e3,Pr=6e3,Fr=5e3,Ir=6e4,Lr=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),Rr=12e4,zr={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,Br=null;function Vr(){return R}function Hr(){let e=R?.platform;if(e==null)return{label:zr.label,runtime:zr.runtime};let t=kt[e];return{label:`${t}客户端`,runtime:t}}function Ur(e){R!=null&&(R=null,N(`平台状态已清空(${e})`))}function Wr(e){return Br??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:Fr});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(`平台状态已缓存: ${kt[R.platform]}(平台差异能力 ${R.capabilities.length} 项 / 特有操作 ${R.platformOps.length} 个)`)}catch(e){N(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{Br=null}})(),Br}function Gr(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function Kr(e){if(Gr(e)!==!1)return null;let t=R?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>kt[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${kt[t]},已拒绝执行(未向插件发起请求)。`,e.platformNote==null?``:`${e.platformNote}`,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function qr(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Jr=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=l(),this.wss=new d({server:this.http}),this.wss.on(`error`,e=>{P(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),ge),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===u.OPEN}send(e){this.client&&this.client.readyState===u.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===u.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(_e,`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} (${qr(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!==u.OPEN||(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==u.OPEN)return;let n={type:`status`,state:t,version:kr};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)})}},Yr=200,Xr=class{transport=new Jr;pending;logRing=[];onConnectionChange=null;constructor(){this.pending=new Dr((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{t?this.pending.onBinary(e):this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),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 y(`not_connected`,`${Hr().runtime} 插件未连接。请先在${Hr().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=Yr&&this.logRing.shift(),this.logRing.push(n);return}this.sendLogPush(n)}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)}`)}}};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 Zr=!1;async function Qr(){if(Zr)return;Zr=!0;let e=process.argv[1];if(!e)return;let t;try{t=a(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()}),本次代码改动未生效。收掉它:curl -X POST http://127.0.0.1:${I}/shutdown,再重新拉起`)}async function $r(){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()+Pr;for(;Date.now()<t&&(await ei(250),await z()!==null););return await z()===null?{state:`none`}:(M(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new f({name:`text-to-design-proxy`,version:L},{versionNegotiation:{mode:`auto`}});try{await t.connect(new p(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 ei(e){return new Promise(t=>setTimeout(t,e))}var ti=3,ni=4,ri=240,ii=16,ai=8;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oi(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 si(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 ci(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>=ni))break}return n}function li(e,t,n){if(!B(e))return{};if(typeof e.$ref==`string`){if(t>ai)return{};let r=oi(e.$ref,n.defs);return r===void 0?{}:li(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>ri?`${t.slice(0,ri)}…`:t)}let i=si(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]=ci(a.map(e=>li(e,t,n))))}let a=t>=ti&&B(e.properties);if(B(e.items)&&(r.items=a?{}:li(e.items,t+1,n)),B(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,ii),o={};for(let r of a)o[r]=li(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 ui(e){if(!B(e))return e;let t=li(e,0,{defs:B(e.$defs)?e.$defs:{}});return B(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function di(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 fi(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=di(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function pi(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 mi(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 hi(e){let t=ne(e)[`~standard`],n=fi(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=mi(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${pi(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function gi(){let e=ie(process.execPath,[...process.execArgv,...process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});e.unref(),e.on(`error`,e=>{F(`拉起 daemon 失败: ${e.message}`)})}var _i=1500,vi=2e4,yi=6e4,bi=6e5,xi=5e5,Si=5e3;function Ci(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>xi?[`合计 ${(t/1024).toFixed(0)} KB > ${xi/1024} KB`]:[],...e.filter(e=>e.outputBytes>Si).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function wi(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 Ti(e){let t=e,n=!1,r=null,i=new m({name:jr,version:L},{supportedProtocolVersions:[`2026-07-28`,...te],...e.getInstructions()?{instructions:e.getInstructions()}:{}}),a=new Map,o=new Map,s=new Map,l=new Map,u=async e=>{try{return await e(t)}catch(r){if(n||!wi(r))throw r;return P(`shim: 上游请求失败,触发重连后重放`),await ie(),e(t)}};async function d(){let{tools:e}=await u(e=>e.listTools()),t=new Set,n=[];for(let r of e){t.add(r.name);let e=r.outputSchema?ui(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:hi(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:ne(e)}},s=JSON.stringify({title:r.title,description:r.description,annotations:r.annotations,inputSchema:r.inputSchema,outputSchema:e});n.push({name:r.name,bytes:s.length,outputBytes:e===void 0?0:JSON.stringify(e).length});let c=a.get(r.name);if(c&&c.raw===s)continue;c?.handle.remove(),a.delete(r.name);let l=i.registerTool.bind(i);try{let e=l(r.name,o,async e=>u(t=>t.callTool({name:r.name,arguments:e??{}})));a.set(r.name,{handle:e,raw:s})}catch(e){P(`工具注册失败(${r.name}): ${e instanceof Error?e.message:String(e)}`)}}Ci(n);for(let[e,n]of[...a])t.has(e)||(n.handle.remove(),a.delete(e))}async function f(){let{prompts:e}=await u(e=>e.listPrompts()),t=new Set;for(let n of e){t.add(n.name);let e=JSON.stringify(n),r=o.get(n.name);if(r&&r.raw===e)continue;r?.handle.remove(),o.delete(n.name);let a={};for(let e of n.arguments??[])a[e.name]=c.string().describe(e.description??``);let s=i.registerPrompt(n.name,{title:n.title,description:n.description,argsSchema:c.object(a)},e=>u(t=>t.getPrompt({name:n.name,...e?{arguments:e}:{}})));o.set(n.name,{handle:s,raw:e})}for(let[e,n]of[...o])t.has(e)||(n.handle.remove(),o.delete(e))}async function p(){let[{resources:e},{resourceTemplates:t}]=await Promise.all([u(e=>e.listResources()),u(e=>e.listResourceTemplates())]),n=new Set;for(let t of e){let e=t.uri;n.add(e);let r=JSON.stringify(t),a=s.get(e);if(a&&a.raw===r)continue;a?.handle.remove(),s.delete(e);let o=i.registerResource(t.name,e,{title:t.title,description:t.description,mimeType:t.mimeType},async e=>u(t=>t.readResource({uri:e.href})));s.set(e,{handle:o,raw:r})}for(let[e,t]of[...s])n.has(e)||(t.handle.remove(),s.delete(e));let r=new Set;for(let e of t){let t=String(e.uriTemplate);r.add(t);let n=JSON.stringify(e),a=l.get(t);if(a&&a.raw===n)continue;a?.handle.remove(),l.delete(t);let o=i.registerResource(e.name,new ee(t,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType},async(e,t)=>u(t=>t.readResource({uri:e.href})));l.set(t,{handle:o,raw:n})}for(let[e,t]of[...l])r.has(e)||(t.handle.remove(),l.delete(e))}let h=async()=>{let e=await Promise.allSettled([d(),f(),p()]);for(let t of e)t.status===`rejected`&&P(`同步清单失败: ${String(t.reason).slice(0,120)}`)},ie=()=>r||(r=(async()=>{let e=Date.now()+vi,n=null;for(;Date.now()<e;){try{let e=await $r();if(e.state===`proxy`){t=e.client,ae(t),M(`shim: 上游已恢复`),await h();return}e.state===`none`&&gi()}catch(e){n=e}await ei(_i)}throw n??Error(`上游重连超时(${vi}ms)`)})().finally(()=>{r=null}),r),ae=e=>{e.onclose=()=>{n||(P(`shim: 上游断开,自动重连`),ie().catch(()=>{}))},e.setNotificationHandler(`notifications/tools/list_changed`,async()=>d().catch(()=>{})),e.setNotificationHandler(`notifications/prompts/list_changed`,async()=>f().catch(()=>{})),e.setNotificationHandler(`notifications/resources/list_changed`,async()=>p().catch(()=>{})),e.setNotificationHandler(`notifications/resources/updated`,async e=>{let t=e.params;t?.uri!=null&&await i.server.sendResourceUpdated({uri:t.uri}).catch(()=>{})})};ae(t);let oe=re(async()=>(await h(),i)),se=L,ce=null,g=null,le=async()=>{let e=await z();e!=null&&e.version!==se&&(M(`上游版本变化(${se} → ${e.version}),全量重同步目录`),se=e.version,await h())},ue=()=>{n||(ce=setTimeout(()=>{n||le().finally(ue)},yi),ce.unref())},_=()=>{n||(g=setTimeout(()=>{n||h().finally(_)},bi),g.unref())};ue(),_(),M(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,ce&&clearTimeout(ce),g&&clearTimeout(g),await oe.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}function Ei(e=process.env.TEXT_TO_DESIGN_LANG){return vr(e)??`zh-CN`}function Di(e=Ei()){return{locale:e,t:hr(e)}}function Oi(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 ki(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Oi(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function Ai(e,t){s.globalRegistry.add(e,{description:t})}function ji(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 Mi(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=Oi(i);if(a!=null)for(let e of ji(a))r(e)};r(e)}function Ni(e,t){return Mi(e,e=>{let n=ki(e);if(n==null)return;let r=t(n);r!==n&&Ai(e,r)}),e}function Pi(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function Fi(e){return e._def?.typeName}function Ii(e,t){return e._def?.[t]}function Li(e,t){return e._def?.[t]}function V(e){switch(Fi(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 Li(e,`value`);case`ZodEnum`:return Li(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=Ii(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=Ii(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=Li(e,`options`)??[],n=t.find(e=>Fi(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 Ri={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function zi(e,t,n){let r=Ri[he(e)]??n,i={content:[{type:`text`,text:`错误: ${e instanceof Error?e.message:String(e)}`}],isError:!0};return r!==void 0&&(i.followUp=r),t?{...i,structuredContent:V(t)}:i}function Bi(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...Pi(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:Pi(e).content,structuredContent:V(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...Pi(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var Vi=new Map;function Hi(e){return Vi.get(e)}function Ui(){return[...Vi.keys()].sort()}function H(e){return(t,n,r)=>{let i=t.registerTool.bind(t),a=e=>e==null||e.type!==`tool`||e.description==null?e:{...e,description:r.t(e.description)},o=async(t,r,i)=>{try{let o=Kr(e);if(o!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`),zi(new y(`platform_unsupported`,o),e.outputSchema,a(e.followUp));if(e.inputSchema!=null){let n=e.inputSchema.safeParse(t);if(!n.success){let t=n.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new y(`invalid_args`,`参数校验失败(${e.name}): ${t}`)}t=n.data}let s={...r==null?{}:{signal:r},...e.timeout==null?{}:{timeout:e.timeout}},c=i?.skipHooks===!0?void 0:e.hook?.();if(c?.before!=null)try{await c.before(t)}catch(t){P(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let l;l=e.run?await e.run(t,n,r??new AbortController().signal):await n.request(e.method,e.payload?e.payload(t):t,s);let u=e.extraContent?e.extraContent(l,t):[],d=[];if(c?.after!=null)try{let e=await c.after(t,l)??[];for(let t of e)d.push(t),u.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;d.push(n),u.push({type:`text`,text:n})}let f=Bi(l,e.outputSchema,u.length>0?u:void 0,a(e.followUp));return d.length>0?{...f,warnings:d}:f}catch(t){let n=t instanceof Error?t.message:String(t);return F(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`),zi(t,e.outputSchema,a(e.followUp))}};Vi.set(e.name,o);let{t:s}=r,c=i(e.name,{title:s(e.title),description:e.platformNote==null?s(e.description):`${s(e.description)}${s(e.platformNote)}`,...e.inputSchema?{inputSchema:Ni(e.inputSchema,s)}:{},outputSchema:Ni(e.outputSchema,s),...e.annotations?{annotations:e.annotations}:{}},async(...t)=>{let n=e.inputSchema!=null,r=t[0],i=t[1],a=n?r??{}:{},s=n?i:r,c=s?.mcpReq?.signal??s?.signal;return o(a,c)});return c.alwaysEnabled=e.alwaysEnabled??!1,c}}function Wi(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(typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){if(!Array.isArray(n))return{ok:!1};n=n[Number(e[1])]}}return{ok:!0,value:n}}function Gi(e,t){let n=e.indexOf(`.`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);if(!t.has(r)){let n=[...t.keys()].join(`, `)||`无`;throw Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${n})`)}let a=t.get(r);if(i===``)return a;let o=Wi(a,i);if(!o.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${r} 的返回结构`);return o.value}var Ki=/\{\{\s*([^{}]+?)\s*\}\}/g,qi=/^\{\{\s*([^{}]+?)\s*\}\}$/,Ji=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],Yi=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),Xi=2e4;function Zi(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}function Qi(e){if(Array.isArray(e))return e.map(Qi);if(typeof e!=`object`||!e)return e;let t=e;if(typeof t.id==`string`&&typeof t.type==`string`&&typeof t.name==`string`){let e={};for(let n of Ji)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))Yi.has(e)||(n[e]=Qi(r));return n}function $i(e,t){if(Array.isArray(e)){for(let n of e)$i(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}$i(r,t)}}function ea(e){let t=Qi(e),n=Zi(t);if(n<=Xi)return{data:t,trimmed:n!==Zi(e)};let r=[];return $i(t,r),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${n} 字符,已省略明细;需要细节请把该工具单独调用一次`,ids:[...new Set(r)]},trimmed:!0}}function ta(e,t){if(typeof e==`string`){let n=qi.exec(e.trim());return n==null?e.replace(Ki,(e,n)=>{let r=Gi(n,t);return typeof r==`string`?r:JSON.stringify(r)}):Gi(n[1],t)}if(Array.isArray(e))return e.map(e=>ta(e,t));if(typeof e==`object`&&e){let n={};for(let[r,i]of Object.entries(e))n[r]=ta(i,t);return n}return e}function na(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:Qe,outputSchema:$e,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:Rr,run:async(e,t,n)=>{let{calls:r,stopOnError:i,checkDrift:a}=e,o=new Map,s=[],c=!1,l=a===!1,u=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.id==null||t.id.trim()===``?`step${e+1}`:t.id.trim(),d=e=>{s.push({id:a,tool:t.tool,ok:!1,error:e})};if(o.has(a)||s.some(e=>e.id===a)){d(`步骤 id "${a}" 重复`);break}let f=Hi(t.tool);if(f==null){d(`未知工具 ${t.tool},可用: ${Ui().join(`, `)}`);break}let p;try{p=ta(t.args??{},o)}catch(e){d(e instanceof Error?e.message:String(e));break}let m=await f(p,n,{skipHooks:l});if(m.isError===!0){if(d((m.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),i!==!1&&t.continueOnError!==!0)break;continue}let ee=ea(m.structuredContent);ee.trimmed&&(c=!0),o.set(a,m.structuredContent),m.warnings!=null&&u.push(...m.warnings),s.push({id:a,tool:t.tool,ok:!0,data:ee.data})}let d=s.length===r.length,f=u;return{ok:d&&s.every(e=>e.ok),executed:s.length,total:r.length,results:s,...c?{echoTrimmed:!0}:{},...f.length>0?{warnings:f}:{}}}})(e,t,n)]}function U(e,t){return{method:`component_op`,outputSchema:tn,payload:t=>({op:e,...t}),...t}}function ra(e,t,n){return[U(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:xn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`createComponent.description2`}}),U(`create_instance`,{name:`jsd_create_instance`,title:`createInstance.title`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:Sn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`createInstance.description`}}),U(`detach_instance`,{name:`jsd_detach_instance`,title:`detachInstance.title`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:Cn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`detachInstance.description`}}),U(`import_component`,{name:`jsd_import_component`,title:`importComponent.title`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:wn,annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`importComponent.description`}}),U(`swap_component`,{name:`jsd_swap_component`,title:`swapComponent.title`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:Tn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),U(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读 variantProperties(变体,如 {"状态":["a0","a1"]})与 componentProperties(布尔/文本/换绑),名字必须完全匹配(宿主侧键可能是属性 id 如 Property 1#1:0,传名字即可,adapter/门面会自动归一)。值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔({"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。平台差异:变体属性三平台都走同名入口(jsDesign 缺专用入口时由引擎降级为变体属性+可见样式);布尔/文本/换绑属性在 Figma 与 MasterGo 生效(两端原生 setProperties 都收 string|boolean),jsDesign 无对应能力`,inputSchema:En,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`setInstanceProperties.description`}}),U(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`combineAsVariants.title`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。**两平台行为不同,按能力位 inPlaceVariants 分流**:①声明该能力的平台(如 Figma,原生 combineAsVariants 即原位合并)—— 并入集合的就是实例所指的 COMPONENT 本身,**已有实例链接不断、页面不残留冗余原件**,这是首选姿势,直接调即可;②未声明的平台(jsDesign,平台缺陷:引擎内部把节点按 BOOLEAN_OPERATION 取属性 → get_booleanOperation: Value is not a string,与组件结构无关)会退化为「克隆并入 / 克隆移入后合并」兜底 —— 兜底成功时页面上会同时留下**原件与集合内克隆**,已有实例仍指向原件,需自行 swap 到克隆变体后再删原件;全败时返回可执行出口,别重试、也别去改组件结构。jsDesign 上变体集的替代做法:每个状态各做一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me),调用方按名字取用。「一个主件 + 每屏改子节点颜色」这条捷径同样不通(实例子节点样式 override 不保证渲染生效)`,inputSchema:Dn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),U(`copy_overrides`,{name:`jsd_copy_overrides`,title:`copyOverrides.title`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:On,annotations:{readOnlyHint:!0,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`copyOverrides.description`}}),U(`apply_overrides`,{name:`jsd_apply_overrides`,title:`applyOverrides.title`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:An,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`applyOverrides.description`}}),U(`sync_overrides`,{name:`jsd_sync_overrides`,title:`syncOverrides.title`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:jn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>H(r)(e,t,n))}var ia=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),aa={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},oa=`#f3f4f6`;function sa(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 W(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function ca(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:aa[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function la(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>W(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=W(e[`margin-top`])??n,r=W(e[`margin-right`])??r,i=W(e[`margin-bottom`])??i,a=W(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function ua(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>W(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=W(e[`padding-top`])??n,r=W(e[`padding-right`])??r,i=W(e[`padding-bottom`])??i,a=W(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function da(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:ca(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:W(e[`border-width`])??1,color:ca(e[`border-color`])??`#000000`}:t}function G(e,t){return W(e[t])}function fa(e){return W(e[`font-size`])??16}function pa(e){let t=e[`font-weight`];return t===`bold`?700:W(t)??400}function ma(e,t){let n=e[`line-height`];return W(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function ha(e){return(e.display??``).includes(`flex`)}function ga(e){return e[`flex-direction`]===`row`?`row`:`column`}function _a(e){return W(e.gap)??W(e[`row-gap`])??0}function va(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function ya(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function ba(e){return e.type===`text`?e.data:g(e)?e.tagName===`br`?`
36
+ `:e.children.map(ba).join(``):``}function xa(e){return e.replace(/\s+/g,` `).trim()}function Sa(e,t){let n=sa(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=G(n,`width`)??120,r.h=G(n,`height`)??120,r;for(let t of e.children){if(t.type===`text`){let e=xa(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:Ca(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}g(t)&&(ia.has(t.tagName)||t.tagName!==`br`&&r.children.push(Sa(t,!1)))}if(t&&r.children.length===0){let t=xa(e.children.map(ba).join(``));t&&r.children.push({tag:`#text`,text:t,style:Ca(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function Ca(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 wa(e,t){let n=e.style,r=ua(n),i=la(n),a=da(n),o=Math.max(0,t-r.left-r.right-a.width*2);if(e.tag===`img`)return e.w=G(n,`width`)??120,e.h=G(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=fa(n),r=(e.text??``).split(`
37
+ `).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>ya(e,t)),t)),e.h=r.length*ma(n,t),c=e.h}else{let t=ha(n),i=ga(n),o=_a(n),l=G(n,`width`),u=G(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=wa(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&va(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=wa(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&va(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 G(n,`width`)??(e.w+=l),G(n,`height`)==null&&!e.isText&&(e.h+=u),{width:e.w+i.left+i.right,height:e.h+i.top+i.bottom}}function Ta(e){let t=la(e.style);e.x+=t.left,e.y+=t.top}function Ea(e,t,n){let r=[];return Da(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 Da(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=fa(i),r=ca(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=pa(i),u=va(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=ma(i,n);(e.text??``).split(`
38
+ `).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}">${Oa(e)}</text>`)});return}let l=ca(i.background??i[`background-color`],e.tag===`img`?oa:void 0),u=da(i),d=W(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)Ta(n),Da(n,t,a,o)}function Oa(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function ka(e){let t=le(e,{decodeEntities:!0}).children.filter(e=>g(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=Sa(n,!0),i=sa(n.attribs.style),a=G(i,`width`),o=G(i,`height`),s=wa(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),Ea(r,c,l)}var Aa={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,"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-template":`book-dashed`,"box-select":`square-dashed`,"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-vertical":`square-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`,"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`},ja=e(import.meta.url);function Ma(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Na=JSON.parse(r(ja.resolve(`lucide-static/icon-nodes.json`),`utf8`)),Pa=JSON.parse(r(ja.resolve(`lucide-static/tags.json`),`utf8`)),K=new Map;for(let[e,t]of Object.entries(Na))K.set(e,{name:e,nodes:t,keywords:Pa[e]??[]});K.size;var Fa=new Map;for(let[e,t]of Object.entries(Pa))t.forEach((t,n)=>{let r=Fa.get(t)??[];r.push({name:e,idx:n}),Fa.set(t,r)});var Ia=new ue([...K.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function La(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Ra(e){let t=e.trim().toLowerCase();if(!t)return null;let n=K.get(t);if(n)return n;let r=Aa[t];if(r){let e=K.get(r);if(e)return e}let i=Ma(t),a=Ia.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&La(i,Ma(e.item.name))>=3});if(a.length)return a[0].item;let o=Fa.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||Ma(e.name).length-Ma(t.name).length)[0];return K.get(e.name)??null}let s=Ia.search(t,{limit:8}).filter(e=>La(i,Ma(e.item.name))>=2)[0];return s?s.item:null}function za(e,t=20){let n=e.trim();if(!n)return[];let r=new Map,i=K.get(n);i&&r.set(n,i);let a=Aa[n];if(a&&!r.has(a)){let e=K.get(a);e&&r.set(e.name,e)}for(let{name:e}of Fa.get(n)??[]){let n=K.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Ia.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function Ba(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(`
17
39
  `);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(`
18
- `)}var $i={FRAME:Xe,RECTANGLE:Ze,ELLIPSE:Qe,LINE:$e,POLYGON:et,STAR:tt,VECTOR:nt,TEXT:rt,GROUP:it,BOOLEAN_OPERATION:at};function ea(e){let t={...$i[e].shape};return delete t.type,s.object({...t,placement:st.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:ea(e),outputSchema:Dt,payload:t=>{let{placement:n,...r}=t,i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,...t.annotations},...t}}var Y={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function ta(e,t){let n=[J(`FRAME`,{name:`jsd_create_frame`,title:`创建 Frame 容器`,description:`创建单个 FRAME 容器节点,入参只含 FRAME 字段:width/height 尺寸、layoutMode 自动布局(itemSpacing/padding*/主轴交叉轴尺寸对齐)与填充描边等视觉字段。本工具只建一个根 FRAME;层级结构用 children 递归嵌套,子节点 x/y 相对父节点。auto-layout 前必须设 layoutMode=HORIZONTAL 或 VERTICAL(否则布局字段被忽略)。未显式传 fills 时引擎默认白底,透明容器传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]。建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`创建矩形`,description:`创建单个 RECTANGLE 矩形节点,入参只含矩形字段:width/height 尺寸、cornerRadius 四角圆角与填充描边等视觉字段。本工具只建一个根矩形;层级结构用 children 递归嵌套,子节点 x/y 相对父节点。建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`TEXT`,{name:`jsd_create_text`,title:`创建文本`,description:`创建单个 TEXT 文本节点,入参只含文本字段:characters 必填内容、fontSize/fontName 字号字体、对齐/自适应/大小写/装饰/行高/字距与填充描边。本工具只建一个根文本;层级结构用 children 递归嵌套,子节点 x/y 相对父节点。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样(如 SourceHanSansCN_family),style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,命中时结果 warnings 点名。长段落要换行:TEXT 缺省按内容撑开,显式 width 会被覆盖 —— 传 width + textAutoResize:"HEIGHT";要固定框尺寸传 "NONE"。建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`创建椭圆`,description:`创建单个 ELLIPSE 椭圆节点,width/height 尺寸、arcData 环形参数(可画环)与填充描边等视觉字段。本工具只建一个根椭圆;建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`LINE`,{name:`jsd_create_line`,title:`创建线段`,description:`创建单个 LINE 线段节点,width/height 尺寸与描边等视觉字段。本工具只建一个根线段;短直线段建议 LINE+rotation 布局更稳定。横线/竖线可把一维传 0:引擎 resize 校验要求 >= 0.01,插件创建时把零轴抬到 0.01 过校验(视觉是直线,序列化回读该轴仍是 0);jsd_resize_node 改尺寸同样支持零轴。建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`POLYGON`,{name:`jsd_create_polygon`,title:`创建多边形`,description:`创建单个 POLYGON 多边形节点,pointCount 角点数必填(如 6=六边形)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根多边形;建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`STAR`,{name:`jsd_create_star`,title:`创建星形`,description:`创建单个 STAR 星形节点,pointCount 角点数与 innerRadius 内半径比例必填(如 5 角、0.5)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根星形;建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`VECTOR`,{name:`jsd_create_vector`,title:`创建矢量`,description:`创建单个 VECTOR 矢量节点,vectorPaths 必填(每项含 SVG path data,如 "M0 0 L100 100")与填充描边等视觉字段。本工具只建一个根矢量。⚠ 已知平台缺陷:创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定。建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`GROUP`,{name:`jsd_create_group`,title:`创建编组`,description:`创建单个 GROUP 编组节点,children 必填且至少 2 个子节点(内部用 Frame 实现),可带 auto-layout 布局字段(layoutMode/itemSpacing/padding*)。本工具只建一个根编组;要固定坐标的根层级用 placement 控制。建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y}),J(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`创建布尔运算节点`,description:`创建单个 BOOLEAN_OPERATION 布尔运算节点,booleanOperation 运算方式(${Se})与 children 必填且至少 2 个合并子节点。本工具只建一个根布尔节点;建多个根节点/复杂树用 jsd_batch 编排`,followUp:Y})],r=H({name:`jsd_create_svg`,title:`导入 SVG`,description:`将 SVG 字符串直接导入画布为可编辑图层(createNodeFromSvg 原生解析,保留路径/渐变/描边)。建多个根节点/复杂树用 jsd_batch 编排`,method:`create_svg`,inputSchema:ct,outputSchema:Dt,annotations:{readOnlyHint:!1,destructiveHint:!1},payload:({svg:e,name:t})=>({svg:e,name:t??`svg-design`}),followUp:Y}),i=H({name:`jsd_create_icon`,title:`插入内置图标`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:ut,outputSchema:Dt,annotations:{readOnlyHint:!1,destructiveHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=Xi(r);if(!c){let e=Zi(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=Qi(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:Y}),a=H({name:`jsd_html_to_design`,title:`HTML 转设计节点`,description:`将 HTML 片段转成矢量图层(SVG 保真,忽略复杂样式);需要逐节点可编辑的结构时改用 jsd_create_rectangle / jsd_create_text 等手工搭建后再 jsd_batch 编排`,inputSchema:lt,outputSchema:Dt,annotations:{readOnlyHint:!1,destructiveHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=Hi(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:Y});return[...n.map(n=>H(n)(e,t)),r(e,t),i(e,t),a(e,t)]}var na=`(page)`,ra=8,ia=200,aa=5,oa=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function sa(e){let t=e.op;return typeof t==`string`&&oa.has(t)}function ca(e){return e.op===`reparent`}function la(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 ua(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function da(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 fa(e,t){let n=ti(e);if(n==null)return null;let r=await n(t,void 0);if(r?.isError===!0)return null;let i=r?.structuredContent;return typeof i==`object`&&i?i:null}async function pa(e){let t=new Map;if(e===na){let e=await fa(`jsd_get_page`,{});if(e==null)return null;for(let n of ua(e.nodes).slice(0,ia)){let e=da(n);e!=null&&t.set(e.id,e)}return t}let n=await fa(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=ua(n.nodes)[0];if(r==null)return null;for(let e of ua(r.children).slice(0,ia)){let n=da(e);n!=null&&t.set(n.id,n)}return t}var ma=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(!(e.op!==void 0&&!sa(e))){this.engaged=!0;try{let t=new Set;if(la(e,t),t.size===0)return;let n=await fa(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of ua(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}ca(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(na);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=ra){this.dead.add(e);continue}let t=await pa(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 pa(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,aa).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>aa?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===na?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},ha=()=>new ma;function ga(e,t){let n=H({name:`jsd_manage_nodes`,title:`节点结构操作(聚合)`,description:`按 op 分发的节点结构操作聚合入口:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair。单次单操作请优先用对应小工具: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_set_* 系列(含 jsd_set_shape);组件/实例操作用 jsd_manage_components 或 jsd_create_component / jsd_sync_overrides 等,两工具 op 不通用。
19
- 各 op 的返回键(在 jsd_batch 里用占位符引用时才不会写错,写错会中止整批):select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**:这两个 op 内部走的就是 jsd_group_nodes / jsd_flatten_nodes 那条路)、ungroup→ungrouped[](id 字符串)、reparent→moved[](同时附 updated[],两者同一份数组)、repair→cleaned[](id 字符串)。id 字符串数组取 {{步骤id.selected[0]}},节点数组取 {{步骤id.created[0].id}},节点单对象取 {{步骤id.created.id}}(写成 [0] 会报无法解析)。`,method:`node_op`,inputSchema:ht,outputSchema:Mt,annotations:{readOnlyHint:!1,destructiveHint:!0},hook:ha,followUp:{type:`tool`,tool:`jsd_set_layout`,description:`结构改完后设置容器自动布局`}}),r=H({name:`jsd_manage_components`,title:`组件与实例操作(聚合)`,description:`按 op 分发的组件/实例操作聚合入口:create_component|create_instance|detach_instance|import_component|swap_component|set_instance_properties|combine_as_variants|copy_overrides|apply_overrides|sync_overrides。单次单操作请优先用对应小工具: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_nodes,两工具 op 不通用`,method:`component_op`,inputSchema:gt,outputSchema:Ft,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`组件/实例改完后设置变体属性`}});return[n(e,t),r(e,t)]}function _a(e,t){return[H({name:`jsd_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:pt,outputSchema:jt,annotations:{readOnlyHint:!0},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`把查到的节点设为当前选中,便于后续修改/删除`}})(e,t)]}function X(e,t){return{method:`node_op`,outputSchema:Mt,payload:t=>({op:e,...t}),...oa.has(e)?{tags:[`structural`],hook:ha}:{},...t}}function va(e,t){return[X(`select`,{name:`jsd_select_nodes`,title:`设置画布选中`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:Gt,followUp:{type:`tool`,tool:`jsd_move_node`,description:`选中后移动/调整选中节点`}}),X(`remove`,{name:`jsd_delete_node`,title:`删除节点`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:Kt,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_find`,description:`删除后复核剩余节点`}}),X(`clone`,{name:`jsd_clone_node`,title:`复制节点`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`把副本移到目标位置`}}),X(`group`,{name:`jsd_group_nodes`,title:`编组节点`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:Jt,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`编组后设置组内自动布局`}}),X(`ungroup`,{name:`jsd_ungroup_nodes`,title:`解组节点`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,inputSchema:Yt,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`解组后调整子节点位置`}}),X(`flatten`,{name:`jsd_flatten_nodes`,title:`合并为矢量`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:Xt,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`烘焙后设置合并图形的填充`}}),X(`outline_stroke`,{name:`jsd_outline_stroke`,title:`描边转轮廓`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:Zt,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`调整新轮廓的描边`}}),X(`reparent`,{name:`jsd_reparent_nodes`,title:`移动节点到父节点下`,description:`把节点移入 parentId 成为其子节点,可指定插入位置。⚠ **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:Qt,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`移动后按需微调新父下的 x/y(绝对位置已自动保持)`}}),X(`repair`,{name:`jsd_repair_nodes`,title:`清理损坏节点`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:$t,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_find`,description:`清理后复核页面节点状态`}})].map(n=>H(n)(e,t))}function ya(e,t){return[H({name:`jsd_platform_op`,title:`平台特有操作`,description:`执行平台特有能力(Figma 变量/本地样式/组件属性等)。CRITICAL: 不要凭空猜测 op 名与参数——先 jsd_ping 读 platformOps 名单(含每个 op 的参数形状说明)与 capabilities,再按名单里的名字调用;平台不支持或 op 名写错时返回错误并列出当前平台支持的 op`,platforms:[`figma`],platformNote:`(仅 Figma 有平台特有操作;jsDesign 没有对应 op,本地样式改用 jsd_list_styles 或读 jsd://styles,组件属性用 jsd_set_instance_properties)`,method:`platform_op`,inputSchema:yt,outputSchema:Ve,annotations:{readOnlyHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`复核平台操作在画布上的效果`}})(e,t)]}function ba(e){return[e.registerPrompt(`html-to-design`,{title:`HTML 转设计稿`,description:`把一段 HTML 转为画布节点,含保真度取舍说明`,argsSchema:s.object({html:s.string().describe(`要转换的 HTML 片段`),name:s.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:`请把下面的 HTML 转成设计稿。默认走 jsd_html_to_design(SVG 保真,忽略复杂样式);需要可编辑图层时才改用 per-type create 工具(jsd_create_frame 等)手工映射(容器→FRAME、文本→TEXT、图形→VECTOR)后 reparent 归组。\n\nHTML:\n\`\`\`\n${String(e)}\n\`\`\`${t==null?``:`\n节点名:${String(t)}`}`}}]})),e.registerPrompt(`icon-grid`,{title:`图标网格`,description:`批量插入 Lucide 图标并排成自动布局网格`,argsSchema:s.object({icons:s.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:s.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:s.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:`请插入图标网格:1) jsd_create_frame 建一个 FRAME 容器;2) 每个图标各调一次 jsd_create_icon(size=${Number(t)||24});3) jsd_reparent_nodes 把全部图标移入容器;4) jsd_set_layout 给容器设 auto-layout(layoutMode=HORIZONTAL,itemSpacing=${Number(n)||16},counterAxisAlignItems=CENTER)。\n图标列表: ${String(e)}`}}]})),e.registerPrompt(`script-ops`,{title:`脚本化批量调用`,description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:s.object({task:s.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:xa(e==null?void 0:String(e))}}]})),e.registerPrompt(`design-strategy`,{title:`设计策略总纲`,description:`画布创作的通用纪律:先摸底、一层只建一层、语义化命名、归组后再布局、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:s.object({screen:s.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Sa(e==null?void 0:String(e))}}]})),e.registerPrompt(`text-replace-strategy`,{title:`文本批量替换策略`,description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:s.object({rootId:s.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ca(e==null?void 0:String(e))}}]})),e.registerPrompt(`variant-sync`,{title:`同类实例样式批量同步`,description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:s.object({sourceId:s.string().optional().describe(`源实例 id;留空取当前选中`),targetType:s.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:wa(e==null?void 0:String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function xa(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
40
+ `)}var Va={FRAME:dt,RECTANGLE:ft,ELLIPSE:pt,LINE:mt,POLYGON:ht,STAR:gt,VECTOR:_t,TEXT:vt,GROUP:yt,BOOLEAN_OPERATION:bt};function Ha(e){let t={...Va[e].shape};return delete t.type,c.object({...t,placement:St.optional()}).strict()}function q(e,t){return{method:`execute`,inputSchema:Ha(e),outputSchema:qt,payload:t=>{let{placement:n,...r}=t,i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,...t.annotations},...t}}var J={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function Ua(e,t,n){let r=[q(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,followUp:J}),q(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:J}),q(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:J}),q(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:J}),q(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:J}),q(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:J}),q(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:J}),q(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 的矢量节点是 PenNode,路径为 penNetwork 顶点模型,与本工具的 vectorPaths(SVG path data)不同形;该平台暂不支持建矢量)`,followUp:J}),q(`GROUP`,{name:`jsd_create_group`,title:`createGroup.title`,description:`createGroup.description`,followUp:J}),q(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`createBooleanOperation.title`,description:n.t(`createBooleanOperation.description`,{ops:Ce}),followUp:J})],i=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`将 SVG 字符串直接导入画布为可编辑图层(createNodeFromSvg 原生解析,保留路径/渐变/描边)。建多个根节点/复杂树用 jsd_batch 编排`,method:`create_svg`,inputSchema:Ct,outputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!1},payload:({svg:e,name:t})=>({svg:e,name:t??`svg-design`}),followUp:J}),a=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Tt,outputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=Ra(r);if(!c){let e=za(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=Ba(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:J}),o=H({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:wt,outputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=ka(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:J});return[...r.map(r=>H(r)(e,t,n)),i(e,t,n),a(e,t,n),o(e,t,n)]}var Wa=`(page)`,Ga=8,Ka=200,qa=5,Ja=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function Ya(e){let t=e.op;return typeof t==`string`&&Ja.has(t)}function Xa(e){return e.op===`reparent`}function Za(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 Qa(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function $a(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 eo(e,t){let n=Hi(e);if(n==null)return null;let r=await n(t,void 0);if(r?.isError===!0)return null;let i=r?.structuredContent;return typeof i==`object`&&i?i:null}async function to(e){let t=new Map;if(e===Wa){let e=await eo(`jsd_get_page`,{});if(e==null)return null;for(let n of Qa(e.nodes).slice(0,Ka)){let e=$a(n);e!=null&&t.set(e.id,e)}return t}let n=await eo(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=Qa(n.nodes)[0];if(r==null)return null;for(let e of Qa(r.children).slice(0,Ka)){let n=$a(e);n!=null&&t.set(n.id,n)}return t}var no=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(!(e.op!==void 0&&!Ya(e))){this.engaged=!0;try{let t=new Set;if(Za(e,t),t.size===0)return;let n=await eo(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of Qa(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}Xa(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(Wa);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=Ga){this.dead.add(e);continue}let t=await to(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 to(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,qa).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>qa?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===Wa?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},ro=()=>new no;function io(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Vt,outputSchema:Qt,annotations:{readOnlyHint:!1,destructiveHint:!0},hook:ro,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:Ht,outputSchema:tn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`manageComponents.description2`}});return[r(e,t,n),i(e,t,n)]}function ao(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:zt,outputSchema:Zt,annotations:{readOnlyHint:!0},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function Y(e,t){return{method:`node_op`,outputSchema:Qt,payload:t=>({op:e,...t}),...Ja.has(e)?{tags:[`structural`],hook:ro}:{},...t}}function oo(e,t,n){return[Y(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:fn,followUp:{type:`tool`,tool:`jsd_move_node`,description:`selectNodes.description`}}),Y(`remove`,{name:`jsd_delete_node`,title:`deleteNode.title`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:pn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),Y(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:mn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),Y(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:hn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),Y(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:gn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),Y(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:_n,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`flattenNodes.description`}}),Y(`outline_stroke`,{name:`jsd_outline_stroke`,title:`outlineStroke.title`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:vn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),Y(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,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:yn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`reparentNodes.description`}}),Y(`repair`,{name:`jsd_repair_nodes`,title:`repairNodes.title`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:bn,annotations:{readOnlyHint:!1,destructiveHint:!0},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>H(r)(e,t,n))}function so(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`],platformNote:`(仅 Figma / MasterGo 有平台特有操作,名单见 jsd_ping 的 platformOps;jsDesign 没有对应 op —— 本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、写用 jsd_set_instance_properties;**组件的布尔/文本/换绑属性(componentProperties)在 jsDesign 上不存在**,别去找该字段;MG 上新增组件属性用 mg_add_component_property,Figma 上用 figma_component_property_add)`,method:`platform_op`,inputSchema:Kt,outputSchema:et,annotations:{readOnlyHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function co(e,t){return[e.registerPrompt(`html-to-design`,{title:t.t(`prompt.htmlToDesign.title`),description:t.t(`prompt.htmlToDesign.description`),argsSchema:c.object({html:c.string().describe(`要转换的 HTML 片段`),name:c.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:`请把下面的 HTML 转成设计稿。默认走 jsd_html_to_design(SVG 保真,忽略复杂样式);需要可编辑图层时才改用 per-type create 工具(jsd_create_frame 等)手工映射(容器→FRAME、文本→TEXT、图形→VECTOR)后 reparent 归组。\n\nHTML:\n\`\`\`\n${String(e)}\n\`\`\`${t==null?``:`\n节点名:${String(t)}`}`}}]})),e.registerPrompt(`icon-grid`,{title:t.t(`prompt.iconGrid.title`),description:t.t(`prompt.iconGrid.description`),argsSchema:c.object({icons:c.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:c.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:c.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:`请插入图标网格:1) jsd_create_frame 建一个 FRAME 容器;2) 每个图标各调一次 jsd_create_icon(size=${Number(t)||24});3) jsd_reparent_nodes 把全部图标移入容器;4) jsd_set_layout 给容器设 auto-layout(layoutMode=HORIZONTAL,itemSpacing=${Number(n)||16},counterAxisAlignItems=CENTER)。\n图标列表: ${String(e)}`}}]})),e.registerPrompt(`script-ops`,{title:t.t(`prompt.scriptOps.title`),description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:c.object({task:c.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:lo(e==null?void 0:String(e))}}]})),e.registerPrompt(`design-strategy`,{title:t.t(`prompt.designStrategy.title`),description:`画布创作的通用纪律:先摸底、一层只建一层、语义化命名、归组后再布局、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:c.object({screen:c.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:uo(e==null?void 0:String(e))}}]})),e.registerPrompt(`text-replace-strategy`,{title:t.t(`prompt.textReplace.title`),description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:c.object({rootId:c.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:fo(e==null?void 0:String(e))}}]})),e.registerPrompt(`variant-sync`,{title:t.t(`prompt.variantSync.title`),description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:c.object({sourceId:c.string().optional().describe(`源实例 id;留空取当前选中`),targetType:c.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:po(e==null?void 0:String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function lo(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
20
41
  1) 多步流程一次成型:优先 jsd_batch 编排(create→reparent→update、find→批量修改、图标×N 等);宿主有代码执行工具时也可写一段脚本连续 await 多个 tools.jsd_*。
21
42
  2) 中间值只在管道内流动:上游结果用双花括号占位符(步骤id.字段路径)注入下游参数(脚本内用变量传递);每步只提取后续需要的字段,不回传完整序列化结果。**占位符只在同一次调用的本批次内有效** —— 跨批次引用会报「占位符引用的步骤不存在或未成功」并中止整批,跨批次请硬编码上一步回显里的真实 id。
22
- 3) 收敛:最后只做一次 jsd_get_selection(depth=1) 总复核,不要每步都复核。`}function Sa(e){return`# 画布创作纪律
43
+ 3) 收敛:最后只做一次 jsd_get_selection(depth=1) 总复核,不要每步都复核。`}function uo(e){return`# 画布创作纪律
23
44
 
24
45
  1) 先摸底再动手:jsd_get_selection(depth=2) 看现状(名称/类型/尺寸/填充/子结构),已有节点用 jsd_find 精确定位,不要重复创建同名元素。
25
46
  2) 一层只建一层:每个界面先建主容器 FRAME,再分区放内容。复杂结构用 jsd_batch 编排多个 per-type create 步骤一次建完,不要用 children 深嵌套(易整体失败)。
@@ -43,7 +64,7 @@ import{createRequire as e}from"node:module";import{appendFileSync as t,mkdirSync
43
64
  - 主按钮(FRAME + TEXT)
44
65
  - 辅助链接(FRAME:忘记密码 TEXT + 注册 TEXT)
45
66
 
46
- ${e==null?`当前设计`:`「${e}」`}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function Ca(e){return`# 文本批量替换
67
+ ${e==null?`当前设计`:`「${e}」`}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function fo(e){return`# 文本批量替换
47
68
 
48
69
  ## 1. 摸底与分块
49
70
  - 对 ${e==null?`当前选中(先用 jsd_get_selection 拿到根 id)`:`节点 ${e}`} 先 jsd_get_selection 看结构,按语义把文本分成几块:表格按行或列、卡片按「同名字段一组」、表单按「标签 + 输入」一组、导航按菜单项一组。
@@ -61,7 +82,7 @@ ${e==null?`当前设计`:`「${e}」`}按这条链走;多步合并时优先用 j
61
82
  - 有问题先修当前块再继续下一块,不要把所有错误攒到最后。
62
83
 
63
84
  ## 5. 收尾
64
- - 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function wa(e,t){return`# 同类实例样式批量同步
85
+ - 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function po(e,t){return`# 同类实例样式批量同步
65
86
 
66
87
  ## 适用场景
67
88
  把一个实例的样式/文案套用到多个同类实例(卡片组、列表项、表单组……),避免逐个手改。
@@ -78,38 +99,30 @@ ${e==null?`当前设计`:`「${e}」`}按这条链走;多步合并时优先用 j
78
99
  - 引擎不支持时再退化为手工:jsd_set_fill_color / jsd_set_text 等 ids=[目标] 填字段 + jsd_set_instance_properties 设变体值。
79
100
 
80
101
  ## 4. 复核
81
- - jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function Ta(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:`未传入任何属性,本次未修改`});else if(i.length>0&&t.length>0){let e=t.filter(e=>{let t=In[e];return t!=null&&!i.some(e=>e.type!=null&&t.some(t=>t===e.type))});e.length>0&&a.push({type:`text`,text:`以下属性与目标节点类型不匹配,已被忽略:${e.map(e=>`${e}(仅适用于 ${In[e].join(`/`)})`).join(`、`)}`})}if(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}var Ea=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Z(e){let t=Pn[e.method],n=e=>t.filter(t=>e[t]!==void 0&&In[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+Ea,inputSchema:e.inputSchema,outputSchema:Ot,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)=>Ta(e,n(t),r(t))}}var Da=Vn();function Oa(e,t){return[Z({name:`jsd_set_fill_color`,title:`设置填充`,description:`设置填充色/渐变(fills 为 Paint 数组,整体替换非合并,需保留的现有填充项要一并传入)、混合模式与团队库填充样式。${Da}`,method:`set_fill`,inputSchema:Cn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`接着设置描边`}}),Z({name:`jsd_set_stroke`,title:`设置描边`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+Da,method:`set_stroke`,inputSchema:wn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`接着设置填充`}}),Z({name:`jsd_set_cornerRadius`,title:`设置圆角`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+Da,method:`set_corner_radius`,inputSchema:Tn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`接着设置阴影/模糊效果`}}),Z({name:`jsd_set_text`,title:`修改文本`,description:`修改文本内容与排版(仅 TEXT 节点生效):characters/fontSize/fontName/对齐/自适应/大小写/装饰/行高/字距,以及 Figma 的截断与最大行数。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算)。${Da};characters 内容覆盖在实例内也是正常生效的`,method:`set_text`,inputSchema:En,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`给文本起个语义名称`}}),Z({name:`jsd_move_node`,title:`移动节点`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:Dn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`接着调整尺寸`}}),Z({name:`jsd_resize_node`,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:On,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`接着设置可见性/锁定`}}),Z({name:`jsd_set_layout`,title:`设置自动布局`,description:`设置 FRAME 的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。建议建节点时不要混着传,归组并摆好后再单独设`,method:`set_layout`,inputSchema:kn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`把子节点移入容器完成排布`}}),Z({name:`jsd_set_effects`,title:`设置效果与高级属性`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+Da,method:`set_effects`,inputSchema:An,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`接着设置可见性/锁定`}}),Z({name:`jsd_set_visibility`,title:`设置可见性与锁定`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:jn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`复核改动后的画布选中`}}),Z({name:`jsd_rename_node`,title:`重命名节点`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:Mn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`接着改文本内容/排版`}}),Z({name:`jsd_set_shape`,title:`设置多边形/星形形状`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:Nn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`接着设置填充`}})].map(n=>H(n)(e,t))}function ka(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 Aa(e,t){let n=H({name:`jsd_export`,title:`导出节点为图片`,description:`导出节点为 PNG/JPG/SVG/PDF;ids 为必填数组(单节点也写成 ids:["123:456"],不是 nodeId),savePath 落盘与 includeDataUrl 返回 base64 可并存。注意:单张图片超过内联上限(默认 512KB)时不返回 base64,自动落盘并返回路径引用,避免撑爆会话内存。完整字段见 inputSchema。`,inputSchema:_t,outputSchema:It,annotations:{readOnlyHint:!1,destructiveHint:!1},timeout:ar,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`导出后用该图片填充到节点`},run:async(e,t,n)=>{let{ids:r,format:i,scale:a,savePath:s,includeDataUrl:c}=e,l=(await t.request(`export`,{ids:r,format:i,scale:a},{signal:n,timeout:6e4})).exports??{},u=[],d=[];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&&(o(s,n),i.path=s),c){if(n.byteLength>or){let a=s??_(de(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${ka(r,t.format)}`);s||o(a,n),i.path=a,d.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${or} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:d}},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:`本地图片填充节点`,description:`读取本地图片文件填充到指定节点(IMAGE fill)`,inputSchema:vt,outputSchema:Ot,annotations:{readOnlyHint:!1,destructiveHint:!1},timeout:ar,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`复核图片填充效果`},run:async(e,t,n)=>{let{ids:i,sourcePath:a}=e,o;try{o=r(a)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:i,bytes:new Uint8Array(o)},{signal:n,timeout:ar})}}),a=H({name:`jsd_list_fonts`,title:`列出可用字体`,description:`列出当前环境可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,outputSchema:Lt,annotations:{readOnlyHint:!0},followUp:{type:`tool`,tool:`jsd_set_text`,description:`用列出的字体设置文本`}});return[n(e,t),i(e,t),a(e,t)]}function Q(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function ja(e,t){return[e.registerResource(`canvas-selection`,`jsd://canvas/selection`,{title:`画布当前选中`,description:`当前选中节点的序列化树(含直接子节点),实时从插件读取;等价于 jsd_get_selection depth=2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上)`,mimeType:`application/json`},async()=>Q(`jsd://canvas/selection`,await t.request(`get_selection`,{depth:2}))),e.registerResource(`fonts`,`jsd://fonts`,{title:`可用字体列表`,description:`当前环境可用的字体族与各族的可用字型(families / fonts:[{family,styles}]),实时从插件读取`,mimeType:`application/json`},async()=>Q(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:`本地样式列表`,description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名`,mimeType:`application/json`},async()=>Q(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:`当前页结构总览`,description:`当前页顶层节点的轻量摘要(名称/类型/位置/尺寸/子节点数),不递归;另附文档级页面总览(pages:各页名与顶层节点数,动态页文档首次读取会全量加载并在 note 点名成本)。从头设计整页前先读这里看页面已有内容`,mimeType:`application/json`},async()=>Q(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new m(`jsd://node/{id}`,{list:void 0}),{title:`节点详情`,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 Q(e,await t.request(`find`,{ids:[i]}))}),e.registerResource(`platform-state`,`jsd://platform/state`,{title:`平台状态与能力表`,description:`daemon 缓存的插件平台状态(platform / capabilities / coreCapabilities / platformOps),取自最近一次 jsd_ping 回包;插件离线或尚未探测到平台时为空(此时先调 jsd_ping)。读缓存不发插件请求 —— 用它判断「当前平台支持什么、有哪些特有 op」比每次 ping 便宜`,mimeType:`application/json`},async()=>Q(`jsd://platform/state`,ur()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}function Ma(e,t){let n=H({name:`jsd_ping`,title:`检查${cr.label}插件连接`,description:`检查插件是否在线(需先在${cr.label}(即时设计或 Figma)中运行该插件并保持运行)。返回三个能力表:coreCapabilities 为核心能力(create/modify/structure/component/export/image,两平台一致);capabilities 只列平台差异超集(如 variables/componentProperties/textTruncation),即时设计通常只有 styles,Figma 还会有 variables/componentProperties 等;platformOps 列当前平台可用的特有操作(名/标题/参数说明),调 jsd_platform_op 前先读它。回包会被 daemon 缓存,后续可直接读 jsd://platform/state(不必重复 ping)`,outputSchema:kt,annotations:{readOnlyHint:!0},alwaysEnabled:!0,timeout:ir,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`连接确认后读取当前选中`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:ir});return{connected:!0,platform:e?.platform,capabilities:e?.capabilities,coreCapabilities:e?.coreCapabilities,platformOps:e?.platformOps}}catch(e){return{connected:!1,error:e instanceof Error?e.message:String(e)}}}}),r=H({name:`jsd_get_selection`,title:`读取画布选中`,description:`获取画布当前选中节点的序列化树(名称/类型/尺寸/位置/填充/子结构);depth 控制层级深度,默认 2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上),判断遮挡读 z 即可`,method:`get_selection`,outputSchema:At,annotations:{readOnlyHint:!0},followUp:{type:`tool`,tool:`jsd_find`,description:`在选中范围内继续精确查找节点`}});return[n(e,t),r(e,t)]}var Na=[Ma,ta,_a,va,gi,Oa,ga,Aa,hi,ya,ja,e=>ba(e)],Pa=`操作设计画布的工具集。一个操作对应一个 jsd_* 工具,无 op 分发;聚合入口 jsd_manage_nodes / jsd_manage_components 仅用于批量/混合结构操作。调用纪律:
82
- - 建节点用 per-type 工具:jsd_create_frame / jsd_create_rectangle / jsd_create_text 等,每个工具只建一类节点;多根/复杂嵌套树用 jsd_batch 编排多个建节点步骤。**根节点的 x/y 由 placement 决定**(缺省 center 用视口中心覆盖根节点自身的 x/y;要按坐标排布传 placement:{mode:"manual"},或 mode:"absolute"+x/y 统一坐标),层级结构用 children 嵌套(子节点 x/y 相对父节点)。建完再 jsd_reparent_nodes 归组(**parentId 显式传目标容器 id**;跨父级移动会保持节点绝对位置,内部自动换算新父下的 x/y,不用手动摆回,移入 auto-layout 容器时位置由布局接管);auto-layout(layoutMode/itemSpacing/padding* 等)最后用 jsd_set_layout 单独设置。
83
- - 改属性用专责工具:填充 jsd_set_fill_color、描边 jsd_set_stroke、圆角 jsd_set_cornerRadius、文本 jsd_set_text、位置 jsd_move_node、尺寸 jsd_resize_node(可同时传 x/y)、布局 jsd_set_layout、效果 jsd_set_effects、显隐 jsd_set_visibility、改名 jsd_rename_node、形状 jsd_set_shape。
84
- - 跨工具多步流程用 jsd_batch 编排:双花括号占位符(步骤id.字段路径)引用上步结果,中间 id 不回传模型;**占位符只在同一次调用的本批次内有效** —— 跨批次引用必报「占位符引用的步骤不存在或未成功」并中止整批,跨批次要硬编码上一步回显里的真实 id;步骤回显已做摘要裁剪(节点只留 id/name/type/x/y),含图标/矢量的批次(jsd_create_icon / jsd_clone_node)另配一次 jsd_export 目视验收 —— 回显不等于生效。
85
- - 批量刷样式用 ids 一次下发:recursive=true 只作用于**后代**,不含目标节点自身(给一组图标容器刷描边,容器自己不会被套上方框);要连容器自身一起改才传 includeSelf=true。
86
- - 实例子节点(位于 INSTANCE 内)的样式覆盖平台不保证渲染生效,命中时结果 warnings 直接给出主组件里对应子节点的 id —— 改主组件即所有实例继承。
87
- - 结果键约定(写 jsd_batch 占位符靠这份,不靠 outputSchema —— 出参 schema 只投影到「键名+类型」级,见 daemon/compact-schema.ts):节点类结果 created 是单对象或数组(per-type create / jsd_clone_node / jsd_outline_stroke / jsd_create_instance / jsd_detach_instance 是**数组**,jsd_create_svg / jsd_create_icon / jsd_group_nodes / jsd_flatten_nodes / jsd_create_component / jsd_import_component 是**单对象**;jsd_manage_nodes 的 clone/outline_stroke 是数组,group/flatten 是单对象),updated / moved / swapped 是对象数组(键:id/name/type/x/y/width/height/z/parentId);id 清单类 selected / removed / ungrouped / cleaned 是字符串数组;jsd_find 回 nodes + total,jsd_get_selection 回 selection + pageName,jsd_export 回 exports(含 path / dataUrl)。占位符形如 {{上一步id.updated[0].id}},单对象写 {{id.created.id}}(多了 [0] 反而解析失败)。
88
- - 结果 warnings 一律读:它点名的都是「回显成功但没生效」的事实(平台能力门控字段被忽略、字段回读与请求不一致如 root x/y 被 placement 覆盖 / TEXT 的 textAutoResize 未声明却被置 NONE、fontName 组合不存在被静默忽略、结构变更后的同层漂移),不要当成普通提示跳过。字体写法:family 用 jsd_list_fonts 的 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")。
89
- - ok=false 或「没找到 X 节点」:先 jsd_find 复核 id 是否已失效(可能被连坐删除),必要时 jsd_repair_nodes 清理后重试。`,Fa=new Set;function Ia(e){for(let e of Fa)try{e.sendToolListChanged()}catch{}j(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录保持不变,会话数 ${Fa.size})`)}function La(e){let t=new p({name:er,version:I},{supportedProtocolVersions:[`2026-07-28`,...ee],instructions:Pa});for(let n of Na)n(t,e);Fa.add(t);let n=t.server,r=n.onclose;return n.onclose=()=>{Fa.delete(t),r?.()},t}async function Ra(){let e=Date.now()+nr;do{let e=await Sr();if(e.state===`proxy`)return await e.client.close().catch(()=>{}),j(`已有 daemon 在运行,本次启动跳过`),!1;if(e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)),e.state===`none`)return!0;await Cr(250)}while(Date.now()<e);return await R()===null||(j(`已有 daemon 持有端口,本次启动跳过`),!1)}async function za(e){if(!await Ra()){await xr();return}await e.start($n),j(`daemon: 插件 WS ws://localhost:${e.port}`);let t=te(()=>La(e)),n=ce(t),r=oe(),i=se(),a=null,o=n=>{j(`daemon 退出: ${n}`),t.close(),e.stop(),a?.close(),process.exit(0)};await new Promise((e,t)=>{a=c((e,t)=>{if(!r(e,t)||!i(e,t))return;let a=Date.now(),s=e.url??``;if(t.on(`finish`,()=>{let n=`HTTP ${e.method} ${s} → ${t.statusCode} (${Date.now()-a}ms)`;t.statusCode>=400?j(n):M(n)}),e.method===`GET`&&s===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:er,version:I,pid:process.pid,startedAt:tr}));return}if(e.method===`POST`&&s===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>o(`收到 /shutdown 请求`),100);return}n(e,t)}),a.once(`error`,t),a.listen(F,`127.0.0.1`,()=>e())}),j(`daemon: MCP HTTP http://127.0.0.1:${F}/mcp`),j(`daemon 就绪,常驻运行(更新时由版本自检自动替换)`),process.on(`SIGINT`,()=>o(`SIGINT`))}async function Ba(){await xr();let e=await Sr();if(e.state===`foreign`)P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1);else if(e.state===`proxy`){await qr(e.client);return}e.state===`none`?(j(`未发现 daemon,自动拉起...`),Rr()):j(`daemon 正在启动,等待就绪...`);let t=Date.now()+nr;for(;Date.now()<t;){await Cr(250);let e=await Sr();if(e.state===`proxy`){await qr(e.client);return}e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}P(`daemon 启动超时(${nr/1e3}s),请检查残留进程后重试`),process.exit(1)}var $=`text-to-design-mcp`;function Va(e){return e.includes(` `)?`"${e}"`:e}function Ha(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Ua(){let e=pe(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(me).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Wa(e,t){return[{kind:`write`,path:_(g(),`.config/systemd/user`,`${$}.service`),content:`[Unit]
90
- Description=${er} (design plugin bridge: WS ${$n} / MCP HTTP ${F})
102
+ - jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function mo(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:`未传入任何属性,本次未修改`});else if(i.length>0&&t.length>0){let e=t.filter(e=>{let t=tr[e];return t!=null&&!i.some(e=>e.type!=null&&t.some(t=>t===e.type))});if(e.length>0){let t=rr(e);t!=null&&a.push({type:`text`,text:t})}}if(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}var ho=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function X(e){let t=er[e.method],n=e=>t.filter(t=>e[t]!==void 0&&tr[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+ho,inputSchema:e.inputSchema,outputSchema:Jt,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)=>mo(e,n(t),r(t))}}var go=fr();function _o(e,t,n){return[X({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:go}),method:`set_fill`,inputSchema:Un,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),X({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+go,method:`set_stroke`,inputSchema:Wn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),X({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+go,method:`set_corner_radius`,inputSchema:Gn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),X({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:go}),method:`set_text`,inputSchema:Kn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),X({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:qn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),X({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:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),X({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设`,method:`set_layout`,inputSchema:Yn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),X({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+go,method:`set_effects`,inputSchema:Xn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),X({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:Zn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),X({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:Qn,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),X({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:$n,annotations:{readOnlyHint:!1,destructiveHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>H(r)(e,t,n))}function vo(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 yo(e,t,n){let i=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:Ut,outputSchema:nn,annotations:{readOnlyHint:!1,destructiveHint:!1},timeout:Ir,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:a,savePath:s,includeDataUrl:c}=e,l=(await t.request(`export`,{ids:r,format:i,scale:a},{signal:n,timeout:6e4})).exports??{},u=[],d=[];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&&(o(s,n),i.path=s),c){if(n.byteLength>Lr){let a=s??v(de(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${vo(r,t.format)}`);s||o(a,n),i.path=a,d.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${Lr} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:d}},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}}),a=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:Gt,outputSchema:Jt,annotations:{readOnlyHint:!1,destructiveHint:!1},timeout:Ir,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`fillImage.description2`},run:async(e,t,n)=>{let{ids:i,sourcePath:a}=e,o;try{o=r(a)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:i,bytes:new Uint8Array(o)},{signal:n,timeout:Ir})}}),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:Wt,outputSchema:rn,annotations:{readOnlyHint:!0},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}});return[i(e,t,n),a(e,t,n),s(e,t,n)]}function Z(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function bo(e,t){return[e.registerResource(`canvas-selection`,`jsd://canvas/selection`,{title:`resources.title`,description:`当前选中节点的序列化树(含直接子节点),实时从插件读取;等价于 jsd_get_selection depth=2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上)`,mimeType:`application/json`},async()=>Z(`jsd://canvas/selection`,await t.request(`get_selection`,{depth:2}))),e.registerResource(`fonts`,`jsd://fonts`,{title:`resources.title2`,description:`当前环境可用的字体族与各族的可用字型(families / fonts:[{family,styles}]),实时从插件读取。**只回第一页**并给出 total/truncated —— 字体库实测可达约 1900 族,整表会撑爆上下文;要按名字找或翻页请用 jsd_list_fonts 的 family/offset/limit`,mimeType:`application/json`},async()=>Z(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:`resources.title3`,description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名`,mimeType:`application/json`},async()=>Z(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:`resources.title4`,description:`当前页顶层节点的轻量摘要(名称/类型/位置/尺寸/子节点数),不递归;另附文档级页面总览(pages:各页名与顶层节点数,动态页文档首次读取会全量加载并在 note 点名成本)。从头设计整页前先读这里看页面已有内容`,mimeType:`application/json`},async()=>Z(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new ee(`jsd://node/{id}`,{list:void 0}),{title:`resources.title5`,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 Z(e,await t.request(`find`,{ids:[i]}))}),e.registerResource(`platform-state`,`jsd://platform/state`,{title:`resources.title6`,description:`daemon 缓存的插件平台状态(platform / capabilities / coreCapabilities / platformOps),取自最近一次 jsd_ping 回包;插件离线或尚未探测到平台时为空(此时先调 jsd_ping)。读缓存不发插件请求 —— 用它判断「当前平台支持什么、有哪些特有 op」比每次 ping 便宜`,mimeType:`application/json`},async()=>Z(`jsd://platform/state`,Vr()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}function xo(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:zr.label}),description:n.t(`ping.description`,{client:zr.label}),outputSchema:Yt,annotations:{readOnlyHint:!0},alwaysEnabled:!0,timeout:Fr,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:Fr});return{connected:!0,platform:e?.platform,capabilities:e?.capabilities,coreCapabilities:e?.coreCapabilities,platformOps:e?.platformOps}}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:Et,outputSchema:Xt,annotations:{readOnlyHint:!0},followUp:{type:`tool`,tool:`jsd_find`,description:`getSelection.description2`}});return[r(e,t,n),i(e,t,n)]}var So=[xo,Ua,ao,oo,ra,_o,io,yo,na,so,bo,(e,t,n)=>co(e,n)],Co=new Set;function wo(e){for(let e of Co)try{e.sendToolListChanged()}catch{}M(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录保持不变,会话数 ${Co.size})`)}function To(e,t=Di()){let n=new m({name:jr,version:L},{supportedProtocolVersions:[`2026-07-28`,...te],instructions:t.t(`mcp.instructions`)});for(let r of So)r(n,e,t);Co.add(n);let r=n.server,i=r.onclose;return r.onclose=()=>{Co.delete(n),i?.()},n}async function Eo(){let e=Date.now()+Nr;do{let e=await $r();if(e.state===`proxy`)return await e.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1;if(e.state===`foreign`&&(F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)),e.state===`none`)return!0;await ei(250)}while(Date.now()<e);return await z()===null||(M(`已有 daemon 持有端口,本次启动跳过`),!1)}async function Do(e){if(!await Eo()){await Qr();return}await e.start(Ar),M(`daemon: 插件 WS ws://localhost:${e.port}`);let t=h(()=>To(e)),n=ce(t),r=oe(),i=se(),a=null,o=n=>{M(`daemon 退出: ${n}`),t.close().catch(e=>{N(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),a?.close(),process.exit(0)};await new Promise((e,t)=>{a=l((e,t)=>{if(!r(e,t)||!i(e,t))return;let a=Date.now(),s=e.url??``;if(t.on(`finish`,()=>{let n=`HTTP ${e.method} ${s} → ${t.statusCode} (${Date.now()-a}ms)`;t.statusCode>=400?M(n):N(n)}),e.method===`GET`&&s===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:jr,version:L,pid:process.pid,startedAt:Mr}));return}if(e.method===`POST`&&s===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>o(`收到 /shutdown 请求`),100);return}n(e,t)}),a.once(`error`,t),a.listen(I,`127.0.0.1`,()=>e())}),M(`daemon: MCP HTTP http://127.0.0.1:${I}/mcp`),M(`daemon 就绪,常驻运行(更新时由版本自检自动替换)`),process.on(`SIGINT`,()=>o(`SIGINT`))}async function Oo(){await Qr();let e=await $r();if(e.state===`foreign`)F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1);else if(e.state===`proxy`){await Ti(e.client);return}e.state===`none`?(M(`未发现 daemon,自动拉起...`),gi()):M(`daemon 正在启动,等待就绪...`);let t=Date.now()+Nr;for(;Date.now()<t;){await ei(250);let e=await $r();if(e.state===`proxy`){await Ti(e.client);return}e.state===`foreign`&&(F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}F(`daemon 启动超时(${Nr/1e3}s),请检查残留进程后重试`),process.exit(1)}var Q=`text-to-design-mcp`;function ko(e){return e.includes(` `)?`"${e}"`:e}function Ao(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function jo(){let e=pe(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(me).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Mo(e,t){return[{kind:`write`,path:v(_(),`.config/systemd/user`,`${Q}.service`),content:`[Unit]
103
+ Description=${jr} (design plugin bridge: WS ${Ar} / MCP HTTP ${I})
91
104
  Documentation=https://github.com/wzrove/text-to-design
92
105
  After=network.target
93
106
 
94
107
  [Service]
95
108
  Type=simple
96
109
  Environment=TEXT_TO_DESIGN_MCP_ROLE=daemon
97
- ExecStart=${Va(e)} ${Va(t)} daemon
110
+ ExecStart=${ko(e)} ${ko(t)} daemon
98
111
  Restart=on-failure
99
112
  RestartSec=2
100
113
 
101
114
  [Install]
102
115
  WantedBy=default.target
103
- `},{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 Ga(e,t){let n=_(g(),`Library/LaunchAgents`,`com.${$}.plist`),r=_(g(),`Library/Logs`,`${$}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
116
+ `},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]},{kind:`run`,cmd:`systemctl`,args:[`--user`,`enable`,`--now`,`${Q}.service`]},{kind:`note`,line:`注销后仍要保持常驻:loginctl enable-linger ${process.env.USER??`$USER`}(否则只在登录会话内运行)`}]}function No(e,t){let n=v(_(),`Library/LaunchAgents`,`com.${Q}.plist`),r=v(_(),`Library/Logs`,`${Q}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
104
117
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
105
118
  <plist version="1.0">
106
119
  <dict>
107
120
  <key>Label</key>
108
- <string>com.${$}</string>
121
+ <string>com.${Q}</string>
109
122
  <key>ProgramArguments</key>
110
123
  <array>
111
- <string>${Ha(e)}</string>
112
- <string>${Ha(t)}</string>
124
+ <string>${Ao(e)}</string>
125
+ <string>${Ao(t)}</string>
113
126
  <string>daemon</string>
114
127
  </array>
115
128
  <key>EnvironmentVariables</key>
@@ -125,9 +138,9 @@ WantedBy=default.target
125
138
  <false/>
126
139
  </dict>
127
140
  <key>StandardOutPath</key>
128
- <string>${Ha(r)}</string>
141
+ <string>${Ao(r)}</string>
129
142
  <key>StandardErrorPath</key>
130
- <string>${Ha(r)}</string>
143
+ <string>${Ao(r)}</string>
131
144
  </dict>
132
145
  </plist>
133
- `;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 Ka(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,$,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${$}`}]}function qa(e,t){return process.platform===`linux`?Wa(e,t):process.platform===`darwin`?Ga(e,t):process.platform===`win32`?Ka(e,t):[]}function Ja(){if(process.platform===`linux`){let e=_(g(),`.config/systemd/user`,`${$}.service`);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=_(g(),`Library/LaunchAgents`,`com.${$}.plist`);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 Ya(e,t){if(e.kind===`note`){j(`提示:${e.line}`);return}if(e.kind===`write`){if(t){j(`[dry-run] 写入 ${e.path}`),j(e.content.trimEnd());return}n(fe(e.path),{recursive:!0}),o(e.path,e.content,`utf8`),j(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){j(`[dry-run] 删除 ${e.path}`);return}i(e.path,{force:!0}),j(`已删除 ${e.path}`);return}if(t){j(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let r=ae(e.cmd,e.args,{encoding:`utf8`});if(r.error){N(`执行失败(${e.cmd}):${r.error.code??r.error.message} —— 定义文件已就位,可手动启用`);return}if(r.status!==0){N(`${e.cmd} 退出码 ${r.status}: ${(r.stderr??``).trim().slice(0,200)}`);return}j(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function Xa(e,t){e.length===0&&(P(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)Ya(n,t)}function Za(e={}){let t=Ua(),n,r;`problem`in t?(e.force||(P(t.problem),process.exit(1)),N(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=pe(process.argv[1]??``)):(n=t.exe,r=t.script),j(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),Xa(qa(n,r),e.dryRun===!0),e.dryRun||j(`完成。校验:curl -s http://127.0.0.1:${F}/health(应返回 ${er} ${I})`)}function Qa(e={}){j(`${e.dryRun?`[dry-run] `:``}注销自启`),Xa(Ja(),e.dryRun===!0)}var $a=new yr;$a.onConnectionChange=e=>{if(Ia(e),e){pr($a);return}fr(`插件断开`)},qn((e,t)=>$a.notifyLog(e,t));var eo=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),to=process.argv.slice(2),no=to.find(e=>e===`install-service`||e===`uninstall-service`);if(no){qn((e,t)=>{(e===`error`||e===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${t}\n`)});let e={dryRun:to.includes(`--dry-run`),force:to.includes(`--force`)};no===`install-service`?Za(e):Qa(e)}else eo?za($a).catch(e=>{$a.stop(),P(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):Ba().catch(e=>{P(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
146
+ `;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 Po(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,Q,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${Q}`}]}function Fo(e,t){return process.platform===`linux`?Mo(e,t):process.platform===`darwin`?No(e,t):process.platform===`win32`?Po(e,t):[]}function Io(){if(process.platform===`linux`){let e=v(_(),`.config/systemd/user`,`${Q}.service`);return[{kind:`run`,cmd:`systemctl`,args:[`--user`,`disable`,`--now`,`${Q}.service`]},{kind:`rm`,path:e},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]}]}if(process.platform===`darwin`){let e=v(_(),`Library/LaunchAgents`,`com.${Q}.plist`);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`,Q]}]:[]}function Lo(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}n(fe(e.path),{recursive:!0}),o(e.path,e.content,`utf8`),M(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){M(`[dry-run] 删除 ${e.path}`);return}i(e.path,{force:!0}),M(`已删除 ${e.path}`);return}if(t){M(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let r=ae(e.cmd,e.args,{encoding:`utf8`});if(r.error){P(`执行失败(${e.cmd}):${r.error.code??r.error.message} —— 定义文件已就位,可手动启用`);return}if(r.status!==0){P(`${e.cmd} 退出码 ${r.status}: ${(r.stderr??``).trim().slice(0,200)}`);return}M(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function Ro(e,t){e.length===0&&(F(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)Lo(n,t)}function zo(e={}){let t=jo(),n,r;`problem`in t?(e.force||(F(t.problem),process.exit(1)),P(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=pe(process.argv[1]??``)):(n=t.exe,r=t.script),M(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),Ro(Fo(n,r),e.dryRun===!0),e.dryRun||M(`完成。校验:curl -s http://127.0.0.1:${I}/health(应返回 ${jr} ${L})`)}function Bo(e={}){M(`${e.dryRun?`[dry-run] `:``}注销自启`),Ro(Io(),e.dryRun===!0)}var $=new Xr;$.onConnectionChange=e=>{if(wo(e),e){Wr($);return}Ur(`插件断开`)},wr((e,t)=>$.notifyLog(e,t));var Vo=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),Ho=process.argv.slice(2),Uo=Ho.find(e=>e===`install-service`||e===`uninstall-service`);if(Uo){wr((e,t)=>{(e===`error`||e===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${t}\n`)});let e={dryRun:Ho.includes(`--dry-run`),force:Ho.includes(`--force`)};Uo===`install-service`?zo(e):Bo(e)}else Vo?Do($).catch(e=>{$.stop(),F(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):Oo().catch(e=>{F(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "text-to-design-mcp",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "MCP server bridging AI clients to the jsDesign (即时设计) desktop plugin via a local WebSocket",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "zod": "^4.5.4"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "^24.13.3",
33
+ "@types/node": "^26.6.1",
34
34
  "@types/ws": "^8.18.1",
35
35
  "text-to-design-shared": "0.1.0",
36
36
  "tsx": "^4.20.0",