text-to-design-mcp 0.13.4 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +45 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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{homedir as s,tmpdir as c}from"node:os";import{dirname as l,isAbsolute as u,join as d,resolve as f,sep as p}from"node:path";import{core as m,z as h}from"zod";import{createServer as ee}from"node:http";import{WebSocket as g,WebSocketServer as te}from"ws";import{Client as ne,StreamableHTTPClientTransport as re}from"@modelcontextprotocol/client";import{McpServer as ie,ResourceTemplate as ae,SUPPORTED_PROTOCOL_VERSIONS as _,createMcpHandler as oe,fromJsonSchema as se}from"@modelcontextprotocol/server";import{serveStdio as ce}from"@modelcontextprotocol/server/stdio";import{spawn as le,spawnSync as ue}from"node:child_process";import{localhostHostValidation as de,localhostOriginValidation as fe,toNodeHandler as pe}from"@modelcontextprotocol/node";import{readFile as me,stat as he}from"node:fs/promises";import{isTag as ge}from"domhandler";import{parseDocument as _e}from"htmlparser2";import ve from"fuse.js";var v=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function ye(e){return e instanceof v?e.code:`plugin_error`}var be=3e4,xe=4e3;2*be;var Se=3e4,Ce={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},styleEnumeration:{kind:`flow`,labelKey:`capability.host.styleEnumeration`},styleEnumerationSync:{kind:`flow`,labelKey:`capability.host.styleEnumerationSync`},mainComponentSync:{kind:`flow`,labelKey:`capability.host.mainComponentSync`},textTruncation:{kind:`propGate`,props:[`textTruncation`,`maxLines`],labelKey:`capability.host.textTruncation`},componentProperties:{kind:`propGate`,props:[`componentProperties`],labelKey:`capability.host.componentProperties`},variables:{kind:`channel`,labelKey:`capability.host.variables`},documentScopeRead:{kind:`flow`,labelKey:`capability.host.documentScopeRead`},inPlaceVariants:{kind:`flow`,labelKey:`capability.host.inPlaceVariants`}};function we(e){return Object.keys(e)}var Te=we(Ce);Object.fromEntries(Object.entries(Ce).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var Ee=Object.fromEntries(Object.entries(Ce).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),De=we({create:{labelKey:`capability.core.create`},modify:{labelKey:`capability.core.modify`},structure:{labelKey:`capability.core.structure`},component:{labelKey:`capability.core.component`},export:{labelKey:`capability.core.export`},image:{labelKey:`capability.core.image`}}),Oe={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 ke(e,t){let n=Oe[e];return n==null||n.some(e=>e===t)}var Ae=[`PAINT`,`TEXT`,`EFFECT`,`GRID`,`STROKE_WIDTH`,`CORNER_RADIUS`,`PADDING`,`SPACING`],je=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Me=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Ne=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Pe=[`MIN`,`CENTER`,`MAX`],Fe=[`mastergo`],Ie={blendMode:je,layoutAlign:Me,primaryAxisAlignItems:Ne,counterAxisAlignItems:Pe},Le={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},Re={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},ze={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 Be(e,t){if(e==null)return null;let n=ze[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=Le[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function Ve(e,t,n){let r=Be(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 He(e,t,n){if(e==null)return!0;let r=Re[e]?.[t];return r==null||!r.some(e=>e===n)}function Ue(e,t){let n=Be(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(Ie[t]??[]).filter(n=>Ve(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var We=[`string`,`boolean`,`variableAlias`],Ge={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function Ke(e,t){if(e==null)return null;let n=Ge[e]?.[t]?.deny??[];return We.filter(e=>!n.some(t=>t===e))}var qe=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],Je={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},Ye=qe.join(`/`),Xe=`布尔运算:${qe.map(e=>`${e}=${Je[e]}`).join(`,`)}`;function Ze(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 Qe=h.object({r:h.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.r`),g:h.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.g`),b:h.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.b`),a:h.number().min(0).max(255,`alpha 通道最大 255`).optional().describe(`schema.base.a`)}).strict(),$e=`颜色需为 {r,g,b[,a]} 对象(通道 0-1;任一路 >1 视为 0-255,自动整组 /255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,et=h.unknown().superRefine((e,t)=>{if(typeof e==`string`){Ze(e)??t.addIssue({code:h.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${$e})`});return}let n=Qe.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:h.ZodIssueCode.custom,path:e.path,message:e.message})}),tt=et.describe(`颜色:{r,g,b} 对象(通道 0-1,>1 视为 0-255 自动归一化)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),nt=et.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,>1 视为 0-255 自动归一化;a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),rt=h.object({color:nt.describe(`schema.base.color`),position:h.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}(终点蓝色)`),it=h.array(h.array(h.number()).length(3)).length(2).describe(`schema.base.transformSchema`),at=h.enum(je).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),ot=h.discriminatedUnion(`type`,[h.object({type:h.literal(`SOLID`).describe(`schema.base.type`),color:tt.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:h.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:h.boolean().optional().describe(`schema.base.visible`),blendMode:at.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),h.object({type:h.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:h.array(rt).describe(`schema.base.gradientStops`),gradientTransform:it}).strict().describe(`schema.base.gradientTransform`),h.object({type:h.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:h.array(rt).describe(`schema.base.gradientStops2`),gradientTransform:it}).strict().describe(`schema.base.gradientTransform2`),h.object({type:h.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:h.array(rt).describe(`schema.base.gradientStops3`),gradientTransform:it}).strict().describe(`schema.base.gradientTransform3`),h.object({type:h.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:h.string().describe(`schema.base.imageHash`),scaleMode:h.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schema.base.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),st=h.discriminatedUnion(`type`,[h.object({type:h.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:nt.describe(`schema.base.color2`),offset:h.object({x:h.number().describe(`schema.base.x`),y:h.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:h.number().min(0).describe(`schema.base.radius`),spread:h.number().optional().describe(`schema.base.spread`),visible:h.boolean().optional().describe(`schema.base.visible2`),blendMode:at.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:h.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),h.object({type:h.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:nt.describe(`schema.base.color3`),offset:h.object({x:h.number().describe(`schema.base.x2`),y:h.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:h.number().min(0).describe(`schema.base.radius2`),spread:h.number().optional().describe(`schema.base.spread2`),visible:h.boolean().optional().describe(`schema.base.visible3`),blendMode:at.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),h.object({type:h.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:h.number().min(0).describe(`schema.base.radius3`),visible:h.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),h.object({type:h.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:h.number().min(0).describe(`schema.base.radius4`),visible:h.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),ct=h.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),lt=h.object({pattern:h.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:h.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:h.number().optional().describe(`schema.base.sectionSize`),count:h.number().int().positive().optional(),gutterSize:h.number().optional().describe(`schema.base.gutterSize`),offset:h.number().optional().describe(`schema.base.offset`),visible:h.boolean().optional(),color:nt.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:h.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:h.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${n} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[n]})}),ut=h.object({data:h.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:h.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),dt=h.object({family:h.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:h.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),ft=h.union([h.object({value:h.number().describe(`schema.base.value`),unit:h.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),h.object({value:h.number().describe(`schema.base.value2`),unit:h.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),h.object({unit:h.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),pt=h.object({value:h.number(),unit:h.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),mt=h.object({id:h.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:h.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:h.record(h.string(),h.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符。两种来源:引用先前步骤结果(步骤id.字段路径),或按名字取文档里已有的资源 —— {{@comp:名称}} 给组件/变体集 id、{{@var:名称}} 给变量 id(读一次 jsd_get_page 的资源清单,同名多命中或零命中会点名中止整批)。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:h.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),ht=h.object({calls:h.array(mt).max(50).optional().describe(`schema.batch.calls`),callsFile:h.string().optional().describe(`schema.batch.callsFile`),stopOnError:h.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:h.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),gt=h.object({ok:h.boolean().describe(`schema.batch.ok`),executed:h.number().int().min(0).describe(`schema.batch.executed`),total:h.number().int().min(0).describe(`schema.batch.total`),results:h.array(h.object({id:h.string(),tool:h.string(),ok:h.boolean(),data:h.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:h.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:h.boolean().optional(),echoNote:h.string().optional(),warnings:h.array(h.string()).optional()}),_t=h.record(h.string(),h.unknown()),vt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],yt={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},bt=`节点类型:${vt.map(e=>`${e}=${yt[e]}`).join(` | `)}`,xt=[`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`],St=[`INTELLIGENT_CONTAINER`],Ct=[...vt,...xt,...St],wt=h.enum(vt).describe(bt),Tt=h.enum(Ct).describe(`${bt};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),Et=h.object({type:wt.describe(`schema.executeSchemas.type`),name:h.string().optional(),x:h.number().optional().describe(`schema.executeSchemas.x`),y:h.number().optional().describe(`schema.executeSchemas.y`),width:h.number().optional(),height:h.number().optional()}).catchall(h.unknown()),y={name:h.string().optional(),x:h.number().optional().describe(`schema.executeSchemas.x2`),y:h.number().optional().describe(`schema.executeSchemas.y2`),width:h.number().optional().describe(`schema.executeSchemas.width`),height:h.number().optional().describe(`schema.executeSchemas.height`),rotation:h.number().optional().describe(`schema.executeSchemas.rotation`),opacity:h.number().optional().describe(`schema.executeSchemas.opacity`),visible:h.boolean().optional(),locked:h.boolean().optional(),isMask:h.boolean().optional(),children:h.array(Et).max(100).optional().describe(`子节点数组(递归嵌套,最多 100 个直接子节点;更大的结构建议分批创建后用 jsd_manage_nodes op=reparent 归组)。子节点可使用的字段与顶层 create 入参一致(fills/strokes/cornerRadius/effects 等均可用);x/y 相对父节点,未传 x/y 会叠放在父节点原点(0,0)——非 auto-layout 容器需为每个子节点指定相对坐标`)},b={fills:h.array(ot).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:h.array(ot).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:h.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:h.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:h.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:h.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:h.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:h.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:h.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.executeSchemas.strokeCap`),strokeJoin:h.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.executeSchemas.strokeJoin`),dashPattern:h.array(h.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:at.optional(),effects:h.array(st).optional().describe(`schema.executeSchemas.effects`),constraints:h.object({horizontal:ct.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:ct.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:h.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:h.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:h.array(lt).optional().describe(`schema.executeSchemas.layoutGrids`),fillStyleId:h.string().optional().describe(`schema.sharedProps.fillStyleId`),strokeStyleId:h.string().optional().describe(`schema.sharedProps.strokeStyleId`),textStyleId:h.string().optional().describe(`schema.sharedProps.textStyleId`),effectStyleId:h.string().optional().describe(`schema.sharedProps.effectStyleId`)},Dt={cornerRadius:h.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:h.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:h.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:h.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:h.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)},Ot=h.object({type:h.literal(`FRAME`),...y,layoutMode:h.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:h.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:h.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:h.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:h.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:h.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:h.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:h.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`),...Dt,...b}).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:h.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}]`),kt=h.object({type:h.literal(`RECTANGLE`),...y,...Dt,...b}).strict().describe(`schema.executeSchemas.type2`),At=h.object({type:h.literal(`ELLIPSE`),...y,cornerRadius:h.number().optional().describe(`schema.executeSchemas.cornerRadius2`),arcData:h.object({startingAngle:h.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:h.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:h.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schema.executeSchemas.innerRadius2`),...b}).strict().describe(`schema.executeSchemas.innerRadius3`),jt=h.object({type:h.literal(`LINE`),...y,...b}).strict().describe(`schema.executeSchemas.type3`),Mt=h.object({type:h.literal(`POLYGON`),...y,pointCount:h.number().describe(`schema.executeSchemas.pointCount`),cornerRadius:h.number().optional().describe(`schema.executeSchemas.cornerRadius3`),topLeftRadius:h.number().optional().describe(`schema.executeSchemas.topLeftRadius2`),topRightRadius:h.number().optional().describe(`schema.executeSchemas.topRightRadius2`),bottomLeftRadius:h.number().optional().describe(`schema.executeSchemas.bottomLeftRadius2`),bottomRightRadius:h.number().optional().describe(`schema.executeSchemas.bottomRightRadius2`),...b}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),Nt=h.object({type:h.literal(`STAR`),...y,pointCount:h.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:h.number().describe(`schema.executeSchemas.innerRadius4`),cornerRadius:h.number().optional().describe(`schema.executeSchemas.cornerRadius4`),topLeftRadius:h.number().optional().describe(`schema.executeSchemas.topLeftRadius3`),topRightRadius:h.number().optional().describe(`schema.executeSchemas.topRightRadius3`),bottomLeftRadius:h.number().optional().describe(`schema.executeSchemas.bottomLeftRadius3`),bottomRightRadius:h.number().optional().describe(`schema.executeSchemas.bottomRightRadius4`),...b}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),Pt=h.object({type:h.literal(`VECTOR`),...y,vectorPaths:h.array(ut).describe(`schema.executeSchemas.vectorPaths`),...b}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),Ft=h.object({type:h.literal(`TEXT`),...y,characters:h.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:h.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:dt.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:h.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:h.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:h.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:h.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.executeSchemas.textCase`),textDecoration:h.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.executeSchemas.textDecoration`),lineHeight:ft.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:pt.optional().describe(`schema.executeSchemas.letterSpacing`),...b}).strict().describe(`schema.executeSchemas.letterSpacing2`),It=h.object({type:h.literal(`GROUP`),...y,children:h.array(Et).min(2).max(100).describe(`schema.executeSchemas.children`),layoutMode:h.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:h.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:h.number().optional().describe(`schema.executeSchemas.paddingTop2`),paddingRight:h.number().optional().describe(`schema.executeSchemas.paddingRight2`),paddingBottom:h.number().optional().describe(`schema.executeSchemas.paddingBottom2`),paddingLeft:h.number().optional().describe(`schema.executeSchemas.paddingLeft2`),primaryAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode2`),counterAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode2`),primaryAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems2`),...b}).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:h.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`schema.executeSchemas.path`),Lt=h.object({type:h.literal(`BOOLEAN_OPERATION`),...y,booleanOperation:h.enum(qe).describe(Xe),children:h.array(Et).min(2).describe(`schema.executeSchemas.children2`),...b}).strict().describe(`schema.executeSchemas.children3`),Rt=h.discriminatedUnion(`type`,[Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt]),zt=h.object({mode:h.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:h.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:h.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:h.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});h.object({ops:h.array(Rt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:zt.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),h.object({svg:h.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:h.string().optional().describe(`schema.execute.name`)});var Bt=h.object({svg:h.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:h.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:h.string().optional().describe(`schema.execute.name`)}).strict().superRefine((e,t)=>{let n=e=>typeof e==`string`&&e.trim()!==``;n(e.svg)===n(e.svgPath)&&t.addIssue({code:h.ZodIssueCode.custom,message:n(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),Vt=h.object({html:h.string().describe(`schema.execute.html`),name:h.string().optional().describe(`schema.execute.name2`)}),Ht=h.object({icon:h.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:h.number().optional().describe(`schema.execute.size`),color:h.string().optional().describe(`schema.execute.color`),strokeWidth:h.number().optional().describe(`schema.execute.strokeWidth`),name:h.string().optional().describe(`schema.execute.name3`)});h.object({});var Ut=h.object({depth:h.number().optional().describe(`schema.executeOp.depth`)}),Wt=[`page`,`document`],Gt={"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.styleEnumeration":`本地样式清单(能列出有哪些样式)`,"capability.host.styleEnumerationSync":`样式枚举走同步入口(运行时的 *Async 成员不可用)`,"capability.host.mainComponentSync":`主组件走同步字段(运行时的 getMainComponentAsync 永不返回)`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.documentScopeRead":`文档范围读(能读非当前页)`,"capability.host.variables":`变量`,"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.theme.toDark":`切换到暗色主题`,"header.theme.toLight":`切换到亮色主题`,"header.cameraLock.locked":`相机已锁定`,"header.cameraLock.unlocked":`相机跟随`,"header.cameraLock.title.locked":`相机已锁定:操作画布时不移动你的视口(点击改为跟随)`,"header.cameraLock.title.unlocked":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"header.minimize":`最小化`,"header.minimize.title":`最小化面板,只留 logo;双击 logo 恢复`,"header.restore.title":`双击 logo 恢复面板`,"upgrade.title":`有新版本可用(点击查看升级步骤)`,"upgrade.modal.title":`升级到最新版本`,"upgrade.current":`当前 {version}`,"upgrade.latest":`最新 {version}`,"upgrade.plugin.label":`插件`,"upgrade.service.label":`后台服务`,"upgrade.step.service":`① 后台服务,重启 AI 会话就行。它跑的是 npx -y text-to-design-mcp@latest,每次都是最新的`,"upgrade.step.plugin.head":`② 插件要手动换。下载`,"upgrade.step.plugin.tail":`最新版解压,在设计软件里导入对应平台的 manifest`,"upgrade.step.verify":`③ 重新运行插件,顶部的升级图标没了就是对齐了`,"upgrade.copy":`复制给 AI 助手`,"upgrade.prompt":`我在用 text-to-design,插件 text-to-design-ui 当前 {ui}、最新 {uiLatest},后台服务 text-to-design-mcp 当前 {mcp}、最新 {mcpLatest}。帮我升到最新:① 确认 MCP 配置里的命令带 latest,然后重启 AI 会话;② 下载 text-to-design-ui 最新版(npm pack 或 GitHub Releases 的 zip)解压,告诉我即时设计 / Figma / MasterGo 分别该导入 dist 下哪份 manifest.json;③ 完成后回报两个版本号。`,"toast.copy.done":`已复制`,"toast.copy.failed":`复制失败`,"conn.connected":`已连接。选中画布节点后点「复制」,把内容发给 AI 助手——例如:「按这个节点样式帮我再做一张卡片」`,"conn.superseded":`通道已被另一个插件面板接管(同一时刻只服务一个面板),自动重连已停止。点顶部状态徽章旁的「夺回」切回本面板。`,"conn.disconnected.title":`尚未连接后台服务`,"conn.disconnected.tutorial":`安装教程`,"conn.copyAi":`① 复制给 AI 助手`,"conn.copyDaemon":`② 复制启动命令`,"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 后台服务:
|
|
2
|
+
import{createRequire as e}from"node:module";import{core as t,z as n}from"zod";import{appendFileSync as r,mkdirSync as i,readFileSync as a,rmSync as o,statSync as s,writeFileSync as c}from"node:fs";import{homedir as l,tmpdir as u}from"node:os";import{dirname as d,isAbsolute as f,join as p,resolve as m,sep as h}from"node:path";import{createServer as ee}from"node:http";import{WebSocket as g,WebSocketServer as te}from"ws";import{Client as ne,StreamableHTTPClientTransport as re}from"@modelcontextprotocol/client";import{McpServer as ie,ResourceTemplate as ae,SUPPORTED_PROTOCOL_VERSIONS as _,createMcpHandler as oe,fromJsonSchema as se}from"@modelcontextprotocol/server";import{serveStdio as ce}from"@modelcontextprotocol/server/stdio";import{spawn as le,spawnSync as ue}from"node:child_process";import{localhostHostValidation as de,localhostOriginValidation as fe,toNodeHandler as pe}from"@modelcontextprotocol/node";import{mkdir as me,readFile as he,stat as ge,writeFile as _e}from"node:fs/promises";import{isTag as ve}from"domhandler";import{parseDocument as ye}from"htmlparser2";import be from"fuse.js";import{randomUUID as xe}from"node:crypto";var Se=3e4,Ce=4e3;2*Se;var we=3e4;function Te(e){let t=e;return t!=null&&t.type===`consent_set`&&typeof t.granted==`boolean`}var Ee={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},styleEnumeration:{kind:`flow`,labelKey:`capability.host.styleEnumeration`},styleEnumerationSync:{kind:`flow`,labelKey:`capability.host.styleEnumerationSync`},mainComponentSync:{kind:`flow`,labelKey:`capability.host.mainComponentSync`},textTruncation:{kind:`propGate`,props:[`textTruncation`,`maxLines`],labelKey:`capability.host.textTruncation`},componentProperties:{kind:`propGate`,props:[`componentProperties`],labelKey:`capability.host.componentProperties`},variables:{kind:`channel`,labelKey:`capability.host.variables`},documentScopeRead:{kind:`flow`,labelKey:`capability.host.documentScopeRead`},inPlaceVariants:{kind:`flow`,labelKey:`capability.host.inPlaceVariants`}};function De(e){return Object.keys(e)}var Oe=De(Ee);Object.fromEntries(Object.entries(Ee).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var ke=Object.fromEntries(Object.entries(Ee).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),Ae=De({create:{labelKey:`capability.core.create`},modify:{labelKey:`capability.core.modify`},structure:{labelKey:`capability.core.structure`},component:{labelKey:`capability.core.component`},export:{labelKey:`capability.core.export`},image:{labelKey:`capability.core.image`}}),je={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 Me(e,t){let n=je[e];return n==null||n.some(e=>e===t)}var Ne=[`PAINT`,`TEXT`,`EFFECT`,`GRID`,`STROKE_WIDTH`,`CORNER_RADIUS`,`PADDING`,`SPACING`],Pe=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Fe=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Ie=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Le=[`MIN`,`CENTER`,`MAX`],Re=[`mastergo`],ze={blendMode:Pe,layoutAlign:Fe,primaryAxisAlignItems:Ie,counterAxisAlignItems:Le},Be={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},Ve={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},He={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 Ue(e,t){if(e==null)return null;let n=He[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=Be[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function We(e,t,n){let r=Ue(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 Ge(e,t,n){if(e==null)return!0;let r=Ve[e]?.[t];return r==null||!r.some(e=>e===n)}function Ke(e,t){let n=Ue(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(ze[t]??[]).filter(n=>We(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var qe=[`string`,`boolean`,`variableAlias`],Je={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function Ye(e,t){if(e==null)return null;let n=Je[e]?.[t]?.deny??[];return qe.filter(e=>!n.some(t=>t===e))}var Xe=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],Ze={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},Qe=Xe.join(`/`),$e=`布尔运算:${Xe.map(e=>`${e}=${Ze[e]}`).join(`,`)}`;function et(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 tt=n.object({r:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.r`),g:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.g`),b:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.b`),a:n.number().min(0).max(255,`alpha 通道最大 255`).optional().describe(`schema.base.a`)}).strict(),nt=`颜色需为 {r,g,b[,a]} 对象(通道 0-1;任一路 >1 视为 0-255,自动整组 /255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,rt=n.unknown().superRefine((e,t)=>{if(typeof e==`string`){et(e)??t.addIssue({code:n.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${nt})`});return}let r=tt.safeParse(e);if(!r.success)for(let e of r.error.issues)t.addIssue({code:n.ZodIssueCode.custom,path:e.path,message:e.message})}),it=rt.describe(`颜色:{r,g,b} 对象(通道 0-1,>1 视为 0-255 自动归一化)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),at=rt.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,>1 视为 0-255 自动归一化;a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),ot=n.object({color:at.describe(`schema.base.color`),position:n.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}(终点蓝色)`),st=n.array(n.array(n.number()).length(3)).length(2).describe(`schema.base.transformSchema`),ct=n.enum(Pe).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),lt=n.discriminatedUnion(`type`,[n.object({type:n.literal(`SOLID`).describe(`schema.base.type`),color:it.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:n.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:n.boolean().optional().describe(`schema.base.visible`),blendMode:ct.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),n.object({type:n.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:n.array(ot).describe(`schema.base.gradientStops`),gradientTransform:st}).strict().describe(`schema.base.gradientTransform`),n.object({type:n.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:n.array(ot).describe(`schema.base.gradientStops2`),gradientTransform:st}).strict().describe(`schema.base.gradientTransform2`),n.object({type:n.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:n.array(ot).describe(`schema.base.gradientStops3`),gradientTransform:st}).strict().describe(`schema.base.gradientTransform3`),n.object({type:n.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:n.string().describe(`schema.base.imageHash`),scaleMode:n.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schema.base.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),ut=n.discriminatedUnion(`type`,[n.object({type:n.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:at.describe(`schema.base.color2`),offset:n.object({x:n.number().describe(`schema.base.x`),y:n.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:n.number().min(0).describe(`schema.base.radius`),spread:n.number().optional().describe(`schema.base.spread`),visible:n.boolean().optional().describe(`schema.base.visible2`),blendMode:ct.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:n.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),n.object({type:n.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:at.describe(`schema.base.color3`),offset:n.object({x:n.number().describe(`schema.base.x2`),y:n.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:n.number().min(0).describe(`schema.base.radius2`),spread:n.number().optional().describe(`schema.base.spread2`),visible:n.boolean().optional().describe(`schema.base.visible3`),blendMode:ct.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),n.object({type:n.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:n.number().min(0).describe(`schema.base.radius3`),visible:n.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),n.object({type:n.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:n.number().min(0).describe(`schema.base.radius4`),visible:n.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),dt=n.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),ft=n.object({pattern:n.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:n.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:n.number().optional().describe(`schema.base.sectionSize`),count:n.number().int().positive().optional(),gutterSize:n.number().optional().describe(`schema.base.gutterSize`),offset:n.number().optional().describe(`schema.base.offset`),visible:n.boolean().optional(),color:at.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:n.ZodIssueCode.custom,message:`pattern 为 GRID 时,sectionSize 为必填项`,path:[`sectionSize`]}),e.pattern===`ROWS`||e.pattern===`COLUMNS`)for(let r of[`count`,`gutterSize`])e[r]??t.addIssue({code:n.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${r} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[r]})}),pt=n.object({data:n.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:n.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),mt=n.object({family:n.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:n.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),ht=n.union([n.object({value:n.number().describe(`schema.base.value`),unit:n.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),n.object({value:n.number().describe(`schema.base.value2`),unit:n.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),n.object({unit:n.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),gt=n.object({value:n.number(),unit:n.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),_t=n.object({id:n.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:n.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:n.record(n.string(),n.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符。两种来源:引用先前步骤结果(步骤id.字段路径),或按名字取文档里已有的资源 —— {{@comp:名称}} 给组件/变体集 id、{{@var:名称}} 给变量 id(读一次 jsd_get_page 的资源清单,同名多命中或零命中会点名中止整批)。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:n.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),vt=n.object({calls:n.array(_t).max(50).optional().describe(`schema.batch.calls`),callsFile:n.string().optional().describe(`schema.batch.callsFile`),stopOnError:n.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:n.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),yt=n.object({ok:n.boolean().describe(`schema.batch.ok`),executed:n.number().int().min(0).describe(`schema.batch.executed`),total:n.number().int().min(0).describe(`schema.batch.total`),results:n.array(n.object({id:n.string(),tool:n.string(),ok:n.boolean(),data:n.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:n.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:n.boolean().optional(),echoNote:n.string().optional(),warnings:n.array(n.string()).optional()}),bt=n.record(n.string(),n.unknown()),xt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],St={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},Ct=`节点类型:${xt.map(e=>`${e}=${St[e]}`).join(` | `)}`,wt=[`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`],Tt=[`INTELLIGENT_CONTAINER`],Et=[...xt,...wt,...Tt],Dt=n.enum(xt).describe(Ct),Ot=n.enum(Et).describe(`${Ct};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),kt=n.object({type:Dt.describe(`schema.executeSchemas.type`),name:n.string().optional(),x:n.number().optional().describe(`schema.executeSchemas.x`),y:n.number().optional().describe(`schema.executeSchemas.y`),width:n.number().optional(),height:n.number().optional()}).catchall(n.unknown()),v={name:n.string().optional(),x:n.number().optional().describe(`schema.executeSchemas.x2`),y:n.number().optional().describe(`schema.executeSchemas.y2`),width:n.number().optional().describe(`schema.executeSchemas.width`),height:n.number().optional().describe(`schema.executeSchemas.height`),rotation:n.number().optional().describe(`schema.executeSchemas.rotation`),opacity:n.number().optional().describe(`schema.executeSchemas.opacity`),visible:n.boolean().optional(),locked:n.boolean().optional(),isMask:n.boolean().optional(),children:n.array(kt).max(100).optional().describe(`子节点数组(递归嵌套,最多 100 个直接子节点;更大的结构建议分批创建后用 jsd_manage_nodes op=reparent 归组)。子节点可使用的字段与顶层 create 入参一致(fills/strokes/cornerRadius/effects 等均可用);x/y 相对父节点,未传 x/y 会叠放在父节点原点(0,0)——非 auto-layout 容器需为每个子节点指定相对坐标`)},y={fills:n.array(lt).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:n.array(lt).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:n.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:n.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:n.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:n.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:n.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:n.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:n.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.executeSchemas.strokeCap`),strokeJoin:n.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.executeSchemas.strokeJoin`),dashPattern:n.array(n.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:ct.optional(),effects:n.array(ut).optional().describe(`schema.executeSchemas.effects`),constraints:n.object({horizontal:dt.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:dt.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:n.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:n.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:n.array(ft).optional().describe(`schema.executeSchemas.layoutGrids`),fillStyleId:n.string().optional().describe(`schema.sharedProps.fillStyleId`),strokeStyleId:n.string().optional().describe(`schema.sharedProps.strokeStyleId`),textStyleId:n.string().optional().describe(`schema.sharedProps.textStyleId`),effectStyleId:n.string().optional().describe(`schema.sharedProps.effectStyleId`)},At={cornerRadius:n.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:n.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:n.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:n.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:n.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)},jt=n.object({type:n.literal(`FRAME`),...v,layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:n.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:n.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:n.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:n.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:n.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`),...At,...y}).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:n.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}]`),Mt=n.object({type:n.literal(`RECTANGLE`),...v,...At,...y}).strict().describe(`schema.executeSchemas.type2`),Nt=n.object({type:n.literal(`ELLIPSE`),...v,cornerRadius:n.number().optional().describe(`schema.executeSchemas.cornerRadius2`),arcData:n.object({startingAngle:n.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:n.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:n.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schema.executeSchemas.innerRadius2`),...y}).strict().describe(`schema.executeSchemas.innerRadius3`),Pt=n.object({type:n.literal(`LINE`),...v,...y}).strict().describe(`schema.executeSchemas.type3`),Ft=n.object({type:n.literal(`POLYGON`),...v,pointCount:n.number().describe(`schema.executeSchemas.pointCount`),cornerRadius:n.number().optional().describe(`schema.executeSchemas.cornerRadius3`),topLeftRadius:n.number().optional().describe(`schema.executeSchemas.topLeftRadius2`),topRightRadius:n.number().optional().describe(`schema.executeSchemas.topRightRadius2`),bottomLeftRadius:n.number().optional().describe(`schema.executeSchemas.bottomLeftRadius2`),bottomRightRadius:n.number().optional().describe(`schema.executeSchemas.bottomRightRadius2`),...y}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),It=n.object({type:n.literal(`STAR`),...v,pointCount:n.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:n.number().describe(`schema.executeSchemas.innerRadius4`),cornerRadius:n.number().optional().describe(`schema.executeSchemas.cornerRadius4`),topLeftRadius:n.number().optional().describe(`schema.executeSchemas.topLeftRadius3`),topRightRadius:n.number().optional().describe(`schema.executeSchemas.topRightRadius3`),bottomLeftRadius:n.number().optional().describe(`schema.executeSchemas.bottomLeftRadius3`),bottomRightRadius:n.number().optional().describe(`schema.executeSchemas.bottomRightRadius4`),...y}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),Lt=n.object({type:n.literal(`VECTOR`),...v,vectorPaths:n.array(pt).describe(`schema.executeSchemas.vectorPaths`),...y}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),Rt=n.object({type:n.literal(`TEXT`),...v,characters:n.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:n.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:mt.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:n.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:n.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:n.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:n.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.executeSchemas.textCase`),textDecoration:n.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.executeSchemas.textDecoration`),lineHeight:ht.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:gt.optional().describe(`schema.executeSchemas.letterSpacing`),...y}).strict().describe(`schema.executeSchemas.letterSpacing2`),zt=n.object({type:n.literal(`GROUP`),...v,children:n.array(kt).min(2).max(100).describe(`schema.executeSchemas.children`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:n.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.executeSchemas.paddingTop2`),paddingRight:n.number().optional().describe(`schema.executeSchemas.paddingRight2`),paddingBottom:n.number().optional().describe(`schema.executeSchemas.paddingBottom2`),paddingLeft:n.number().optional().describe(`schema.executeSchemas.paddingLeft2`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode2`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode2`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems2`),...y}).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:n.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`schema.executeSchemas.path`),Bt=n.object({type:n.literal(`BOOLEAN_OPERATION`),...v,booleanOperation:n.enum(Xe).describe($e),children:n.array(kt).min(2).describe(`schema.executeSchemas.children2`),...y}).strict().describe(`schema.executeSchemas.children3`),Vt=n.discriminatedUnion(`type`,[jt,Mt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt]),Ht=n.object({mode:n.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:n.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:n.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:n.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});n.object({ops:n.array(Vt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:Ht.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),n.object({svg:n.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:n.string().optional().describe(`schema.execute.name`)});var Ut=n.object({svg:n.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:n.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:n.string().optional().describe(`schema.execute.name`)}).strict().superRefine((e,t)=>{let r=e=>typeof e==`string`&&e.trim()!==``;r(e.svg)===r(e.svgPath)&&t.addIssue({code:n.ZodIssueCode.custom,message:r(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),Wt=n.object({html:n.string().describe(`schema.execute.html`),name:n.string().optional().describe(`schema.execute.name2`)}),Gt=n.object({icon:n.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:n.number().optional().describe(`schema.execute.size`),color:n.string().optional().describe(`schema.execute.color`),strokeWidth:n.number().optional().describe(`schema.execute.strokeWidth`),name:n.string().optional().describe(`schema.execute.name3`)});n.object({});var Kt=n.object({depth:n.number().optional().describe(`schema.executeOp.depth`)}),qt=[`page`,`document`],Jt={"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.styleEnumeration":`本地样式清单(能列出有哪些样式)`,"capability.host.styleEnumerationSync":`样式枚举走同步入口(运行时的 *Async 成员不可用)`,"capability.host.mainComponentSync":`主组件走同步字段(运行时的 getMainComponentAsync 永不返回)`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.documentScopeRead":`文档范围读(能读非当前页)`,"capability.host.variables":`变量`,"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.theme.toDark":`切换到暗色主题`,"header.theme.toLight":`切换到亮色主题`,"header.cameraLock.locked":`相机已锁定`,"header.cameraLock.unlocked":`相机跟随`,"header.cameraLock.title.locked":`相机已锁定:操作画布时不移动你的视口(点击改为跟随)`,"header.cameraLock.title.unlocked":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"header.minimize":`最小化`,"header.minimize.title":`最小化面板,只留 logo;双击 logo 恢复`,"header.restore.title":`双击 logo 恢复面板`,"upgrade.title":`有新版本可用(点击查看升级步骤)`,"upgrade.modal.title":`升级到最新版本`,"upgrade.current":`当前 {version}`,"upgrade.latest":`最新 {version}`,"upgrade.plugin.label":`插件`,"upgrade.service.label":`后台服务`,"upgrade.step.service":`① 后台服务,重启 AI 会话就行。它跑的是 npx -y text-to-design-mcp@latest,每次都是最新的`,"upgrade.step.plugin.head":`② 插件要手动换。下载`,"upgrade.step.plugin.tail":`最新版解压,在设计软件里导入对应平台的 manifest`,"upgrade.step.verify":`③ 重新运行插件,顶部的升级图标没了就是对齐了`,"upgrade.copy":`复制给 AI 助手`,"upgrade.prompt":`我在用 text-to-design,插件 text-to-design-ui 当前 {ui}、最新 {uiLatest},后台服务 text-to-design-mcp 当前 {mcp}、最新 {mcpLatest}。帮我升到最新:① 确认 MCP 配置里的命令带 latest,然后重启 AI 会话;② 下载 text-to-design-ui 最新版(npm pack 或 GitHub Releases 的 zip)解压,告诉我即时设计 / Figma / MasterGo 分别该导入 dist 下哪份 manifest.json;③ 完成后回报两个版本号。`,"toast.copy.done":`已复制`,"toast.copy.failed":`复制失败`,"conn.connected":`已连接。选中画布节点后点「复制」,把内容发给 AI 助手——例如:「按这个节点样式帮我再做一张卡片」`,"conn.superseded":`通道已被另一个插件面板接管(同一时刻只服务一个面板),自动重连已停止。点顶部状态徽章旁的「夺回」切回本面板。`,"conn.disconnected.title":`尚未连接后台服务`,"conn.disconnected.tutorial":`安装教程`,"conn.copyAi":`① 复制给 AI 助手`,"conn.copyDaemon":`② 复制启动命令`,"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
3
|
|
|
4
4
|
1. 若尚未注册 MCP 服务:用你工具原生的方式注册一个 stdio MCP server,
|
|
5
5
|
命令 npx -y text-to-design-mcp@latest(无需手动安装,npx 会自动拉取运行)。
|
|
@@ -16,7 +16,7 @@ import{createRequire as e}from"node:module";import{appendFileSync as t,mkdirSync
|
|
|
16
16
|
- 结果 warnings 一律读:它点名的都是「回显成功但没生效」的事实(平台能力门控字段被忽略、字段回读与请求不一致如 root x/y 被 placement 覆盖 / TEXT 的 textAutoResize 未声明却被置 NONE、fontName 组合不存在被静默忽略、结构变更后的同层漂移),不要当成普通提示跳过。字体写法:family 用 jsd_list_fonts 的 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")。
|
|
17
17
|
- ok=false 或「没找到 X 节点」:先 jsd_find 复核 id 是否已失效(可能被连坐删除),必要时 jsd_repair_nodes 清理后重试。
|
|
18
18
|
- 产出含 ≥2 个结构一致的同级单元时:先提 COMPONENT 再用 INSTANCE 铺开;命名走「组件族/状态」。
|
|
19
|
-
- 多步套路先读配方 prompt(prompts/list 里,名字无 jsd_ 前缀;取一条即把完整流程与产出标准注入上下文),别临场拼工具:画图表 / 数据可视化 → chart-by-code(折线、柱状、饼图 / 环形、散点、雷达、面积、仪表盘;自己写脚本算几何、落盘 SVG,再经 jsd_create_svg 的 svgPath 导入);HTML 转设计稿 → html-to-design;界面从零设计 → design-strategy;界面排布 / 自动布局(容器该不该上布局、两条落地路径、最易漏的分区)→ auto-layout;批量改文案 → text-replace-strategy;图标网格 → icon-grid;多步画布操作合并成一次调用 → script-ops;同类实例批量同步样式 → variant-sync;变体集构建 → variant-set;变量绑定与批量套用 → variable-binding;组件属性的定义与设值 → component-property。同一批配方也作为 MCP 资源提供:宿主若不注入本段(实测多数客户端如此),以资源为准 —— 读 jsd://recipes 取索引(含每条的何时用),读 jsd://recipes/<id> 取正文。`,"ping.title":`检查{client}插件连接`,"batch.description":'批量编排器:一次请求内顺序执行多个 jsd_* 步骤,前一步结果经双花括号占位符(内容为 步骤id.字段路径)注入后一步 args,中间 id 不回传模型,显著减少往返与上下文。\\n占位符独占一个参数值时保留原类型(数组可直接作 ids 用),嵌在字符串中按 JSON 文本展开;**占位符只在同一次调用的本批次内有效**(步骤表随调用结束即销毁,引用上一批次的步骤必报「占位符引用的步骤不存在或未成功」并中止整批 —— 跨批次请硬编码上一步回显里的真实 id);名字寻址是另一条路:`{{@comp:按钮}}` 取组件/变体集的 id、`{{@var:accent/blue}}` 取变量的 id,取值来自 jsd_get_page 的资源清单(每批最多读一次,同批复用同一份快照;精确名优先,再退忽略大小写),名字一律照清单里的**原样**写 —— 即时设计实测会把带 `/` 的组件名拆成「集合 / 成分」,`assets.components[].name` 只剩叶子名,照创建时那个路径写会不命中);零命中或多命中同名都点名中止、绝不猜(该平台读不到非当前页时清单只覆盖当前页);刚在本批里建出来的资源不在这份快照内,照旧用 {{id.created[0].id}};id 重复/未知工具/引用失败立即中止,工具执行失败默认也中止(stopOnError=false 或单步 continueOnError=true 可走完)。**清单装不下时用 `callsFile`**:给一个 JSON 文件的绝对路径(内容为 {"calls":[…]}(可带 stopOnError / checkDrift)或直接一个数组,与 calls 同形),id 就不必写进上下文 —— 该文件也能用 CLI `text-to-design-mcp exec <文件> [--json] [--dry-run]` 直接跑。\\n回显已做摘要裁剪:节点对象只留 id/name/type/x/y/width/height/z/parentId,vectorPaths(单条 >10KB、16 位小数)与 constraints 等渲染无关字段整键丢弃;裁剪后仍超 20K 字符的步骤降级为 id 清单,并把**整批完整明细**写成 JSONL 落盘(临时目录,一行一步 `{id,tool,ok,data}`),该步回显给 path 与 line(结果里 echoTrimmed=true,并附 echoNote 逐步点名);落盘超上限或写盘失败才退回纯 id 清单,warnings 点名。⚠ **批内回显不含子节点**:节点是整对象摘要化,children 与 characters / fills / *StyleId / vectorPaths 都不在回显里 —— 要读子树请读那个 JSONL 或把该工具**单独调用一次**,别当成「子节点没了 / 字段没生效」。占位符解析不受影响(内部仍用完整数据)。含图标的批次(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 / jsd_create_style\\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}};jsd_delete_style → {{id.removed[0]}}(id 字符串数组)\\\\n· jsd_platform_op → 回包**就是该 op 自己的返回**(没有 .data 那一层信封):figma_variables_create 取 {{id.variables[0].id}}、figma_style_variables_list 取 {{id.styles[0].boundVariables}}、mg_list_variables 取 {{id.variables[0].id}};每个 op 的返回形状写在 jsd_ping 的 platformOps 描述里\\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}}(单对象与单元素数组互认:`{{id.created[0].id}}` 与 `{{id.created.id}}` 都能解析;多元素数组直接取 `.字段` 仍中止)\\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 回填即可;覆盖面仅限本次操作触及的父层(协议没有整树读法,别的层漂移查不到)。多步套路(画图表 / 从零设计整页 / HTML 转设计稿 / 批量改文案 / 组件与变体 / 变量绑定)先读配方索引 jsd://recipes(ReadMcpResource),别临场拼工具;整页/整档的批量改造(一次调用吃多组、id 不进上下文、回读复核、按块切批)读 jsd://recipes/script-ops。\'',"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}}(单对象与单元素数组互认:{{步骤id.created[0].id}} 与 {{步骤id.created.id}} 都能解析;多元素数组直接取 .字段 仍中止)。'`,"createBooleanOperation.description":`创建单个 BOOLEAN_OPERATION 布尔运算节点,booleanOperation 运算方式({ops})与 children 必填且至少 2 个合并子节点。本工具只建一个根布尔节点。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"setFillColor.description":`设置填充色/渐变(fills 为 Paint 数组,整体替换非合并,需保留的现有填充项要一并传入)、混合模式与团队库填充样式。{warn}`,"setText.description":`修改文本(仅 TEXT 节点生效):**内容与排版** characters/fontSize/fontName/对齐/自适应/大小写/装饰/行高/字距、**颜色** fills/fillStyleId/blendMode、**尺寸** width/height(与 textAutoResize 搭配),以及 Figma 的截断与最大行数;位置 x/y 不在此工具,走 jsd_move_node / jsd_resize_node。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算 —— 这类「高度没跟着内容走」的文本,**重设一次 characters 就触发重排**(实测固定宽 200、height 回读 15 的长文本,重设后回读 82)。{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)`},x=[`jsdesign`,`figma`,`mastergo`],Kt={jsdesign:Gt[`platform.jsdesign`],figma:Gt[`platform.figma`],mastergo:Gt[`platform.mastergo`]},qt=h.enum(x),Jt=h.enum(Te),Yt=h.enum(De),Xt=h.object({name:h.string().describe(`schema.platform.name`),title:h.string(),description:h.string().describe(`schema.platform.description`)}),Zt=h.object({type:h.literal(`VARIABLE_ALIAS`),id:h.string()}),Qt=h.object({type:h.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`,`SLOT`]),value:h.union([h.boolean(),h.string()]),preferredValues:h.array(h.object({type:h.enum([`COMPONENT`,`COMPONENT_SET`]),key:h.string()})).optional(),boundVariables:h.object({value:Zt.optional()}).optional(),variableId:h.string().optional()}),$t=h.object({type:h.enum([`BOOLEAN`,`TEXT`,`INSTANCE_SWAP`]),value:Zt}),en=h.object({visible:h.string().optional(),characters:h.string().optional(),mainComponent:h.string().optional()}),tn=h.union([h.string(),h.boolean(),Qt,$t]),nn=h.record(h.string(),h.union([Zt,h.array(Zt),h.record(h.string(),Zt)])),rn=Ct.slice(vt.length).join(`/`),an=h.object({ids:h.array(h.string()).optional().describe(`schema.inputs.ids`),name:h.string().optional().describe(`schema.inputs.name`),type:h.string().optional().describe(`节点类型过滤,支持:${vt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${rn}),这些类型能读不能建`),scope:h.enum(Wt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)。⚠ 读不到非当前页的平台(即时设计/MasterGo)会自动退回当前页并在 note 点名 —— 结果只含当前页,不是全文档`),recursive:h.boolean().optional().describe(`schema.inputs.recursive`),depth:h.number().optional().describe(`schema.inputs.depth`)}),on=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],sn=h.object({op:h.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return on.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:h.array(h.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:h.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:h.string().optional().describe(`schema.inputs.name2`),layoutMode:h.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:h.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:h.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:h.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:h.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:h.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:h.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:h.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`})}),cn=h.object({op:h.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:h.array(h.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:h.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:h.string().optional().describe(`schema.inputs.key`),componentId:h.string().optional().describe(`schema.inputs.componentId`),properties:h.record(h.string(),tn).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:h.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:h.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`)}),ln=h.object({ids:h.array(h.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:h.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:h.number().optional().describe(`schema.inputs.scale`),savePath:h.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:h.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),un=h.object({family:h.string().optional().describe(`schema.inputs.family`),offset:h.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:h.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});h.object({});var dn=h.object({}),fn=h.object({ids:h.array(h.string()).describe(`schema.inputs.ids2`),sourcePath:h.string().describe(`schema.inputs.sourcePath`)}),pn=h.object({op:h.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:h.record(h.string(),h.unknown()).optional().describe(`schema.inputs.params`)}),S=h.lazy(()=>h.object({id:h.string(),name:h.string(),type:Tt,x:h.number(),y:h.number(),width:h.number().optional(),height:h.number().optional(),rotation:h.number().optional(),opacity:h.number().optional(),visible:h.boolean().optional(),locked:h.boolean().optional(),parentId:h.string().optional(),z:h.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:h.array(ot).optional(),strokes:h.array(ot).optional(),strokeWeight:h.number().optional(),strokeTopWeight:h.number().optional(),strokeBottomWeight:h.number().optional(),strokeLeftWeight:h.number().optional(),strokeRightWeight:h.number().optional(),strokeAlign:h.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:h.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:h.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:h.array(h.number()).optional(),cornerSmoothing:h.number().optional(),blendMode:at.optional(),constraints:h.object({horizontal:ct,vertical:ct}).optional(),layoutGrids:h.array(lt).optional(),clipsContent:h.boolean().optional(),arcData:h.object({startingAngle:h.number(),endingAngle:h.number(),innerRadius:h.number()}).optional(),effects:h.array(st).optional(),cornerRadius:h.number().optional(),topLeftRadius:h.number().optional(),topRightRadius:h.number().optional(),bottomLeftRadius:h.number().optional(),bottomRightRadius:h.number().optional(),pointCount:h.number().optional(),innerRadius:h.number().optional(),layoutMode:h.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:h.number().optional(),paddingTop:h.number().optional(),paddingRight:h.number().optional(),paddingBottom:h.number().optional(),paddingLeft:h.number().optional(),primaryAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:h.number().optional(),layoutAlign:h.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:h.number().optional(),children:h.array(S).optional(),characters:h.string().optional(),fontSize:h.number().optional(),fontName:dt.optional(),textAlignHorizontal:h.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:h.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:h.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:h.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:h.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:ft.optional(),letterSpacing:pt.optional(),vectorPaths:h.array(ut).optional(),booleanOperation:h.enum(qe).optional(),isMask:h.boolean().optional(),variantProperties:h.record(h.string(),h.string()).optional(),mainComponentId:h.string().optional(),variantGroupProperties:h.record(h.string(),h.array(h.string())).optional(),textTruncation:h.enum([`DISABLED`,`ENDING`]).optional(),maxLines:h.number().optional(),fillStyleId:h.string().optional(),strokeStyleId:h.string().optional(),textStyleId:h.string().optional(),effectStyleId:h.string().optional(),componentProperties:h.record(h.string(),Qt).optional(),componentPropertyReferences:en.optional(),boundVariables:nn.optional()})),mn=h.object({created:h.union([S,h.array(S)]),warnings:h.array(h.string()).optional()}),hn=h.object({updated:h.array(S),warnings:h.array(h.string()).optional()}),gn=h.object({connected:h.boolean(),platform:qt.optional(),capabilities:h.array(Jt).optional().describe(`schema.results.capabilities`),coreCapabilities:h.array(Yt).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:h.array(Xt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:h.string().optional()}),_n=h.object({selection:h.array(S),pageName:h.string()}),vn=h.object({nodes:h.array(S),total:h.number(),scope:h.enum(Wt).optional(),note:h.string().optional()}),yn=h.object({selected:h.array(h.string()).optional(),removed:h.array(h.string()).optional(),ungrouped:h.array(h.string()).optional(),moved:h.array(S).optional(),updated:h.array(S).optional(),cleaned:h.array(h.string()).optional(),created:h.union([S,h.array(S)]).optional(),warnings:h.array(h.string()).optional()}),bn=h.object({variantProperties:h.record(h.string(),h.string()).optional(),componentProperties:h.record(h.string(),Qt).optional(),propsSummary:h.array(h.string()).optional()}),xn=h.object({instanceId:h.string(),instanceName:h.string(),ok:h.boolean(),message:h.string().optional()}),Sn=h.object({created:h.union([S,h.array(S)]).optional(),swapped:h.array(S).optional(),updated:h.array(S).optional(),snapshotId:h.string().optional(),sourceName:h.string().optional(),captured:bn.optional(),applied:h.array(xn).optional(),source:bn.optional(),failed:h.array(h.object({id:h.string(),message:h.string()})).optional(),warnings:h.array(h.string()).optional()}),Cn=h.object({exports:h.array(h.object({id:h.string(),name:h.string(),format:h.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:h.string(),size:h.number(),path:h.string().optional(),dataUrl:h.string().optional()}))}),wn=h.object({families:h.array(h.string()).describe(`schema.results.families`),fonts:h.array(h.object({family:h.string().describe(`schema.results.family`),styles:h.array(h.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:h.number().describe(`schema.results.count`),total:h.number().optional().describe(`schema.results.total`),offset:h.number().optional().describe(`schema.results.offset`),truncated:h.boolean().optional().describe(`schema.results.truncated`)}),Tn=h.object({id:h.string(),name:h.string()}),En=Tn.extend({properties:h.record(h.string(),h.array(h.string())).optional().describe(`维度 → 可选值,如 {"状态":["默认","禁用"]};平台读不到该字段时整个键省略`)}),Dn=Tn.extend({type:h.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])}),On=h.object({summary:h.object({components:h.number(),variants:h.number(),styles:h.number(),variables:h.number()}),components:h.array(Tn),variants:h.array(En),styles:h.array(Dn),variables:h.array(Tn)}),kn=h.object({pageName:h.string(),nodes:h.array(h.object({id:h.string(),name:h.string(),type:Tt,x:h.number(),y:h.number(),width:h.number().optional(),height:h.number().optional()})),count:h.number(),assets:On.optional(),pages:h.array(h.object({name:h.string(),childCount:h.number()})).optional(),note:h.string().optional()});h.object({styles:h.array(h.object({id:h.string(),name:h.string(),type:h.enum(Ae)})),count:h.number(),note:h.string().optional()});var An=h.object({created:h.object({id:h.string(),name:h.string(),type:h.enum(Ae)})}),jn=h.object({removed:h.array(h.string()),failed:h.array(h.object({id:h.string(),reason:h.string().describe(`这一条没删掉的原因(通常是样式 id 不存在)`)}))}),C=h.object({x:h.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:h.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:h.number().optional().describe(`schema.sharedProps.width`),height:h.number().optional().describe(`schema.sharedProps.height`),rotation:h.number().optional().describe(`schema.sharedProps.rotation`),opacity:h.number().optional().describe(`schema.sharedProps.opacity`),visible:h.boolean().optional(),locked:h.boolean().optional()}),Mn=h.object({width:h.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:h.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),Nn=h.object({pointCount:h.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:h.number().optional().describe(`schema.sharedProps.innerRadius`)}),Pn=h.object({strokes:h.array(ot).optional().describe(`schema.sharedProps.strokes`),strokeWeight:h.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:h.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:h.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:h.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:h.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:h.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:h.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.sharedProps.strokeCap`),strokeJoin:h.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.sharedProps.strokeJoin`),dashPattern:h.array(h.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:h.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),Fn=h.object({cornerRadius:h.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:h.number().optional().describe(`schema.sharedProps.topLeftRadius`),topRightRadius:h.number().optional().describe(`schema.sharedProps.topRightRadius`),bottomLeftRadius:h.number().optional().describe(`schema.sharedProps.bottomLeftRadius`),bottomRightRadius:h.number().optional().describe(`schema.sharedProps.bottomRightRadius`)}),In=h.object({characters:h.string().optional().describe(`schema.sharedProps.characters`),fontSize:h.number().optional().describe(`schema.sharedProps.fontSize`),fontName:dt.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:h.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:h.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:h.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:h.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.sharedProps.textCase`),textDecoration:h.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.sharedProps.textDecoration`),lineHeight:ft.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:pt.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:h.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:h.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:h.number().optional().describe(`schema.sharedProps.maxLines`)}),Ln=h.object({layoutMode:h.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:h.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:h.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:h.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:h.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:h.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:h.enum(Ne).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:h.enum(Pe).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:h.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:h.enum(Me).optional().describe(`schema.sharedProps.layoutAlign`)}),w=h.object({fills:h.array(ot).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:h.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:at.optional(),effectStyleId:h.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:h.array(st).optional().describe(`schema.sharedProps.effects`),constraints:h.object({horizontal:ct.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:ct.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:h.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:h.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:h.array(lt).optional().describe(`schema.sharedProps.layoutGrids`),arcData:h.object({startingAngle:h.number().describe(`schema.sharedProps.startingAngle`),endingAngle:h.number().describe(`schema.sharedProps.endingAngle`),innerRadius:h.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),Rn={ids:h.array(h.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:h.string().optional().describe(`schema.splitOps.matchName`),recursive:h.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:h.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},T=(e,t=1)=>h.array(h.string()).min(t).describe(e),zn=h.object({ids:T(`要设为当前选中的节点 id 列表`)}).strict(),Bn=h.object({ids:h.array(h.string()).optional().describe(`schema.splitOps.ids2`),matchName:h.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),Vn=h.object({ids:T(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),Hn=h.object({ids:T(`要编组的节点 id 列表,至少 2 个`,2),name:h.string().optional().describe(`schema.splitOps.name`),layoutMode:h.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:h.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:h.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:h.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:h.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:h.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:h.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:h.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),Un=h.object({ids:T(`要解组的节点 id 列表`)}).strict(),Wn=h.object({ids:T(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),Gn=h.object({ids:T(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),Kn=h.object({ids:T(`要移动的节点 id 列表`),parentId:h.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:h.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),qn=h.object({ids:h.array(h.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Jn=h.object({ids:h.array(h.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:h.string().optional().describe(`schema.splitOps.name2`),children:h.array(Et).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:h.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:h.number().optional().describe(`组件高度(px);同上`)}).strict(),Yn=h.object({ids:T(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),Xn=h.object({ids:T(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),Zn=h.object({key:h.string().describe(`schema.splitOps.key`),name:h.string().optional().describe(`schema.splitOps.name3`)}).strict(),Qn=h.object({ids:T(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:h.string().describe(`schema.splitOps.componentId`)}).strict(),$n=h.object({ids:T(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:h.record(h.string(),tn).describe('属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名取 jsd_find / jsd_get_selection 的 variantProperties(变体)与 componentProperties(布尔/文本/换绑):**变体属性传名字即可;组件属性传带 `#` 后缀的完整键**(如 `标题#32:0`)—— 组件属性在引擎侧只认完整键,短名会报 `Could not find a component property with name`(真机实测,三种类型都如此)。传短名时 core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选,不做猜测。**选哪个键之前先读 componentPropertyReferences**:它标明「哪个图层由哪个属性驱动」,属性成对存在时只有连着可见层的那一组会改画面')}).strict(),er=h.object({ids:T(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:h.string().optional().describe(`schema.splitOps.name4`)}).strict(),tr=h.object({kind:h.enum(Ae).describe("样式类别。八项是三家 `StyleType` 的并集:**PAINT / TEXT / EFFECT / GRID 三家都有**;`STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING` **只 MasterGo 能建**—— 在 Figma / 即时设计传这四类会被写前点名拒(不静默、不 fallthrough 建成别的类)。MG 上和另四类一样是「从取值节点抄」,所以间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值时前置检查就会拦下"),name:h.string().min(1).describe("样式名,建议用「分组/名称」两层(如 `色板/主色`)"),description:h.string().optional().describe(`样式说明,建后可在 jsd://styles 里回读`),fromNodeId:h.string().describe(`**取值来源节点**(必填):三平台唯一都成立的形状 —— MG 的原生入口就是「从这个图层抄」,Figma / jsDesign 由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进新样式。PAINT 类 fills 优先,节点只有描边时退到 strokes`)}).strict(),nr=h.object({ids:h.array(h.string().min(1)).min(1).describe(`要删的本地样式 id 列表(取自 jsd://styles 或 jsd_get_page 的 assets.styles);按 id 不按名 —— 同名样式可以并存,按名删等于猜`)}).strict(),rr=h.object({sourceId:h.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),ir={ids:T(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:h.string().describe(`schema.splitOps.sourceId`),swapToSource:h.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},ar=h.object(ir).strict(),or=h.object(ir).strict(),sr={fills:w.shape.fills,fillStyleId:w.shape.fillStyleId,blendMode:w.shape.blendMode},cr={...Pn.shape},lr={cornerRadius:Fn.shape.cornerRadius,topLeftRadius:Fn.shape.topLeftRadius,topRightRadius:Fn.shape.topRightRadius,bottomLeftRadius:Fn.shape.bottomLeftRadius,bottomRightRadius:Fn.shape.bottomRightRadius,cornerSmoothing:w.shape.cornerSmoothing},ur={...In.shape,fills:w.shape.fills,fillStyleId:w.shape.fillStyleId,blendMode:w.shape.blendMode,width:Mn.shape.width,height:Mn.shape.height},dr={x:C.shape.x,y:C.shape.y,rotation:C.shape.rotation},fr={...Mn.shape,x:C.shape.x,y:C.shape.y},pr={...Ln.shape,constraints:w.shape.constraints},mr={effects:w.shape.effects,effectStyleId:w.shape.effectStyleId,clipsContent:w.shape.clipsContent,layoutGrids:w.shape.layoutGrids,arcData:w.shape.arcData},hr={opacity:C.shape.opacity,visible:C.shape.visible,locked:C.shape.locked},gr={name:h.string().describe(`schema.splitOps.name5`)},_r={...Nn.shape};function E(e){return h.object({...Rn,...e}).strict()}var vr=E(sr),yr=E(cr),br=E(lr),xr=E(ur),Sr=E(dr),Cr=E(fr),wr=E(pr),Tr=E(mr),Er=E(hr),Dr=E(gr),Or=E(_r),kr={set_fill:Object.keys(sr),set_stroke:Object.keys(cr),set_corner_radius:Object.keys(lr),set_text:Object.keys(ur),move:Object.keys(dr),resize:Object.keys(fr),set_layout:Object.keys(pr),set_effects:Object.keys(mr),set_visibility:Object.keys(hr),rename:Object.keys(gr),set_shape:Object.keys(_r)};function D(e){return h.object({...Rn,props:h.object(e).strict()}).strict()}D(sr),D(cr),D(lr),D(ur),D(dr),D(fr),D(pr),D(mr),D(hr),D(gr),D(_r);function Ar(e,t,n){let r=e.ctx.platform;return r==null?null:He(r,t,e.node.type)?Ve(r,t,n)?null:`value`:`type`}function jr(e,t,n){let r=Ar(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=Ue(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function Mr(e,t){return e[t]}function Nr(e,t,n){e[t]=n}function Pr(e,t,n){return n==null||!(t in e)?!1:(Nr(e,t,n),!0)}function Fr(e,t,n,r){return Ir(e,t,n,r)?Pr(t,n,r):!1}function Ir(e,t,n,r){return!(r==null||!ke(n,t.type)||!jr(e,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(i!=null&&Br(t),r){if(i==null)return;Fr(e,t,`layoutMode`,i);let r=n;Fr(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])Fr(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])Fr(e,t,n,r[n]);Ur(e);return}for(let r of Lr.keys)Fr(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&&ke(r,t.type)&&Ar(e,r,i)==null&&(r in t&&t[r]!==i&&Nr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||t[r]===i}))}for(let r of[`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`]){let i=n[r],a=i;e.create&&(a=n.layoutMode==null?void 0:i??0),a!=null&&ke(r,t.type)&&Ar(e,r,a)==null&&(r in t&&Mr(t,r)!==a&&Nr(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||Mr(t,r)===a}))}for(let r of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let i=n[r];i!=null&&(e.create&&n.layoutMode==null||ke(r,t.type)&&Ar(e,r,i)==null&&(r in t&&Mr(t,r)!==i&&Nr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||Mr(t,r)===i})))}if(n.layoutMode==null||!ke(`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 Rr(e){try{let t=e.children;return Array.isArray(t)?t.map(e=>e.id):[]}catch{return[]}}var zr=new WeakMap;function Br(e){let t=e;zr.set(e,{order:Rr(e),width:typeof t.width==`number`?t.width:void 0,height:typeof t.height==`number`?t.height:void 0})}var Vr=new WeakMap;function Hr(e,t){let n=Vr.get(e)??new Set;n.add(t),Vr.set(e,n)}function Ur(e){let{node:t,src:n}=e;if(n.layoutMode==null)return;let r=Wr(n,e.outermost),i=n.layoutMode===`HORIZONTAL`;for(let e of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let a=r[e];a!=null&&n[e]==null&&e in t&&(Nr(t,e,a),a===`AUTO`&&Hr(t,e===`primaryAxisSizingMode`===i?`width`:`height`))}}function Wr(e,t){let n=e.layoutMode;if(n!==`HORIZONTAL`&&n!==`VERTICAL`)return{};let r=n===`HORIZONTAL`,i=e=>e===`height`&&!t?`AUTO`:`FIXED`,a={};return(r?e.width!=null:e.height!=null)&&(a.primaryAxisSizingMode=i(r?`width`:`height`)),(r?e.height!=null:e.width!=null)&&(a.counterAxisSizingMode=i(r?`height`:`width`)),a}Object.keys(Ee).filter(e=>e!==`componentProperties`);var Gr=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=>Gr.has(e)));function Kr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Gr].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var qr={"zh-CN":Gt,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.styleEnumeration":`Local style listing (can enumerate which styles exist)`,"capability.host.styleEnumerationSync":`Style enumeration uses the sync entry (runtime *Async members are unusable)`,"capability.host.mainComponentSync":`Main component read via the sync field (runtime getMainComponentAsync never settles)`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.documentScopeRead":`Document-scope read (can read pages other than the current one)`,"capability.host.variables":`Variables`,"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.theme.toDark":`Switch to dark theme`,"header.theme.toLight":`Switch to light theme`,"header.cameraLock.locked":`Camera locked`,"header.cameraLock.unlocked":`Camera follows`,"header.cameraLock.title.locked":`Camera locked: canvas operations do not move your viewport (click to follow)`,"header.cameraLock.title.unlocked":`Camera follows: canvas operations scroll and zoom to the result (click to lock)`,"header.minimize":`Minimize`,"header.minimize.title":`Minimize the panel to just the logo; double-click the logo to restore`,"header.restore.title":`Double-click the logo to restore the panel`,"upgrade.title":`A newer version is available (click for upgrade steps)`,"upgrade.modal.title":`Upgrade to the latest version`,"upgrade.current":`Current {version}`,"upgrade.latest":`Latest {version}`,"upgrade.plugin.label":`Plugin`,"upgrade.service.label":`Service`,"upgrade.step.service":`① Service, just restart the AI session. It runs npx -y text-to-design-mcp@latest, so it is always the newest`,"upgrade.step.plugin.head":`② Plugin is a manual swap. Download the latest`,"upgrade.step.plugin.tail":`, unzip it, then import the manifest for your platform`,"upgrade.step.verify":`③ Run the plugin again. No upgrade icon up top means both sides match`,"upgrade.copy":`Copy for AI assistant`,"upgrade.prompt":`I use text-to-design. Plugin text-to-design-ui is {ui}, latest {uiLatest}; service text-to-design-mcp is {mcp}, latest {mcpLatest}. Help me get both to the latest: ① check the MCP config command pins latest, then restart the AI session; ② download and unzip the latest text-to-design-ui (npm pack, or the zip from GitHub Releases), and tell me which manifest.json under dist/ to import for jsDesign / Figma / MasterGo; ③ report both version numbers when done.`,"toast.copy.done":`Copied`,"toast.copy.failed":`Copy failed`,"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.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:
|
|
19
|
+
- 多步套路先读配方 prompt(prompts/list 里,名字无 jsd_ 前缀;取一条即把完整流程与产出标准注入上下文),别临场拼工具:画图表 / 数据可视化 → chart-by-code(折线、柱状、饼图 / 环形、散点、雷达、面积、仪表盘;自己写脚本算几何、落盘 SVG,再经 jsd_create_svg 的 svgPath 导入);HTML 转设计稿 → html-to-design;界面从零设计 → design-strategy;界面排布 / 自动布局(容器该不该上布局、两条落地路径、最易漏的分区)→ auto-layout;批量改文案 → text-replace-strategy;图标网格 → icon-grid;多步画布操作合并成一次调用 → script-ops;同类实例批量同步样式 → variant-sync;变体集构建 → variant-set;变量绑定与批量套用 → variable-binding;组件属性的定义与设值 → component-property。同一批配方也作为 MCP 资源提供:宿主若不注入本段(实测多数客户端如此),以资源为准 —— 读 jsd://recipes 取索引(含每条的何时用),读 jsd://recipes/<id> 取正文。`,"ping.title":`检查{client}插件连接`,"batch.description":'批量编排器:一次请求内顺序执行多个 jsd_* 步骤,前一步结果经双花括号占位符(内容为 步骤id.字段路径)注入后一步 args,中间 id 不回传模型,显著减少往返与上下文。\\n占位符独占一个参数值时保留原类型(数组可直接作 ids 用),嵌在字符串中按 JSON 文本展开;**占位符只在同一次调用的本批次内有效**(步骤表随调用结束即销毁,引用上一批次的步骤必报「占位符引用的步骤不存在或未成功」并中止整批 —— 跨批次请硬编码上一步回显里的真实 id);名字寻址是另一条路:`{{@comp:按钮}}` 取组件/变体集的 id、`{{@var:accent/blue}}` 取变量的 id,取值来自 jsd_get_page 的资源清单(每批最多读一次,同批复用同一份快照;精确名优先,再退忽略大小写),名字一律照清单里的**原样**写 —— 即时设计实测会把带 `/` 的组件名拆成「集合 / 成分」,`assets.components[].name` 只剩叶子名,照创建时那个路径写会不命中);零命中或多命中同名都点名中止、绝不猜(该平台读不到非当前页时清单只覆盖当前页);刚在本批里建出来的资源不在这份快照内,照旧用 {{id.created[0].id}};id 重复/未知工具/引用失败立即中止,工具执行失败默认也中止(stopOnError=false 或单步 continueOnError=true 可走完)。**清单装不下时用 `callsFile`**:给一个 JSON 文件的绝对路径(内容为 {"calls":[…]}(可带 stopOnError / checkDrift)或直接一个数组,与 calls 同形),id 就不必写进上下文 —— 该文件也能用 CLI `text-to-design-mcp exec <文件> [--json] [--dry-run]` 直接跑。\\n回显已做摘要裁剪:节点对象只留 id/name/type/x/y/width/height/z/parentId,vectorPaths(单条 >10KB、16 位小数)与 constraints 等渲染无关字段整键丢弃;裁剪后仍超 20K 字符的步骤降级为 id 清单,并把**整批完整明细**写成 JSONL 落盘(临时目录,一行一步 `{id,tool,ok,data}`),该步回显给 path 与 line(结果里 echoTrimmed=true,并附 echoNote 逐步点名);落盘超上限或写盘失败才退回纯 id 清单,warnings 点名。⚠ **批内回显不含子节点**:节点是整对象摘要化,children 与 characters / fills / *StyleId / vectorPaths 都不在回显里 —— 要读子树请读那个 JSONL 或把该工具**单独调用一次**,别当成「子节点没了 / 字段没生效」。占位符解析不受影响(内部仍用完整数据)。含图标的批次(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 / jsd_create_style\\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}};jsd_delete_style → {{id.removed[0]}}(id 字符串数组)\\\\n· jsd_platform_op → 回包**就是该 op 自己的返回**(没有 .data 那一层信封):figma_variables_create 取 {{id.variables[0].id}}、figma_style_variables_list 取 {{id.styles[0].boundVariables}}、mg_list_variables 取 {{id.variables[0].id}};每个 op 的返回形状写在 jsd_ping 的 platformOps 描述里\\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}}(单对象与单元素数组互认:`{{id.created[0].id}}` 与 `{{id.created.id}}` 都能解析;多元素数组直接取 `.字段` 仍中止)\\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 回填即可;覆盖面仅限本次操作触及的父层(协议没有整树读法,别的层漂移查不到)。多步套路(画图表 / 从零设计整页 / HTML 转设计稿 / 批量改文案 / 组件与变体 / 变量绑定)先读配方索引 jsd://recipes(ReadMcpResource),别临场拼工具;整页/整档的批量改造(一次调用吃多组、id 不进上下文、回读复核、按块切批)读 jsd://recipes/script-ops。\'',"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}}(单对象与单元素数组互认:{{步骤id.created[0].id}} 与 {{步骤id.created.id}} 都能解析;多元素数组直接取 .字段 仍中止)。'`,"createBooleanOperation.description":`创建单个 BOOLEAN_OPERATION 布尔运算节点,booleanOperation 运算方式({ops})与 children 必填且至少 2 个合并子节点。本工具只建一个根布尔节点。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"setFillColor.description":`设置填充色/渐变(fills 为 Paint 数组,整体替换非合并,需保留的现有填充项要一并传入)、混合模式与团队库填充样式。{warn}`,"setText.description":`修改文本(仅 TEXT 节点生效):**内容与排版** characters/fontSize/fontName/对齐/自适应/大小写/装饰/行高/字距、**颜色** fills/fillStyleId/blendMode、**尺寸** width/height(与 textAutoResize 搭配),以及 Figma 的截断与最大行数;位置 x/y 不在此工具,走 jsd_move_node / jsd_resize_node。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算 —— 这类「高度没跟着内容走」的文本,**重设一次 characters 就触发重排**(实测固定宽 200、height 回读 15 的长文本,重设后回读 82)。{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)`,"header.more":`更多设置`,"menu.telemetry":`错误上报`,"menu.cameraLock":`相机锁`,"menu.theme":`主题`,"menu.locale":`语言`,"telemetry.title":`错误上报`,"telemetry.body":`为了更好地更新迭代产品,开启后会记录插件与服务的报错信息。`,"telemetry.item.error":`报错内容与堆栈`,"telemetry.item.identity":`匿名安装标识(不采集文档内容与个人信息)`,"telemetry.item.version":`插件与服务版本`,"telemetry.state.on":`已开启`,"telemetry.state.off":`未开启`,"telemetry.enable":`同意并开启`,"telemetry.decline":`暂不开启`,"telemetry.disable":`关闭上报`},b=[`jsdesign`,`figma`,`mastergo`],Yt={jsdesign:Jt[`platform.jsdesign`],figma:Jt[`platform.figma`],mastergo:Jt[`platform.mastergo`]},Xt=n.enum(b),Zt=n.enum(Oe),Qt=n.enum(Ae),$t=n.object({name:n.string().describe(`schema.platform.name`),title:n.string(),description:n.string().describe(`schema.platform.description`)}),en=n.object({type:n.literal(`VARIABLE_ALIAS`),id:n.string()}),tn=n.object({type:n.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`,`SLOT`]),value:n.union([n.boolean(),n.string()]),preferredValues:n.array(n.object({type:n.enum([`COMPONENT`,`COMPONENT_SET`]),key:n.string()})).optional(),boundVariables:n.object({value:en.optional()}).optional(),variableId:n.string().optional()}),nn=n.object({type:n.enum([`BOOLEAN`,`TEXT`,`INSTANCE_SWAP`]),value:en}),rn=n.object({visible:n.string().optional(),characters:n.string().optional(),mainComponent:n.string().optional()}),an=n.union([n.string(),n.boolean(),tn,nn]),on=n.record(n.string(),n.union([en,n.array(en),n.record(n.string(),en)])),sn=Et.slice(xt.length).join(`/`),cn=n.object({ids:n.array(n.string()).optional().describe(`schema.inputs.ids`),name:n.string().optional().describe(`schema.inputs.name`),type:n.string().optional().describe(`节点类型过滤,支持:${xt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${sn}),这些类型能读不能建`),scope:n.enum(qt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)。⚠ 读不到非当前页的平台(即时设计/MasterGo)会自动退回当前页并在 note 点名 —— 结果只含当前页,不是全文档`),recursive:n.boolean().optional().describe(`schema.inputs.recursive`),depth:n.number().optional().describe(`schema.inputs.depth`)}),ln=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],un=n.object({op:n.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return ln.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:n.array(n.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:n.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:n.string().optional().describe(`schema.inputs.name2`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:n.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:n.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:n.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:n.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:n.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`})}),dn=n.object({op:n.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:n.array(n.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:n.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:n.string().optional().describe(`schema.inputs.key`),componentId:n.string().optional().describe(`schema.inputs.componentId`),properties:n.record(n.string(),an).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:n.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:n.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`)}),fn=n.object({ids:n.array(n.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:n.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:n.number().optional().describe(`schema.inputs.scale`),savePath:n.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:n.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),pn=n.object({family:n.string().optional().describe(`schema.inputs.family`),offset:n.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:n.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});n.object({});var mn=n.object({}),hn=n.object({ids:n.array(n.string()).describe(`schema.inputs.ids2`),sourcePath:n.string().describe(`schema.inputs.sourcePath`)}),gn=n.object({op:n.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:n.record(n.string(),n.unknown()).optional().describe(`schema.inputs.params`)}),x=n.lazy(()=>n.object({id:n.string(),name:n.string(),type:Ot,x:n.number(),y:n.number(),width:n.number().optional(),height:n.number().optional(),rotation:n.number().optional(),opacity:n.number().optional(),visible:n.boolean().optional(),locked:n.boolean().optional(),parentId:n.string().optional(),z:n.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:n.array(lt).optional(),strokes:n.array(lt).optional(),strokeWeight:n.number().optional(),strokeTopWeight:n.number().optional(),strokeBottomWeight:n.number().optional(),strokeLeftWeight:n.number().optional(),strokeRightWeight:n.number().optional(),strokeAlign:n.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:n.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:n.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:n.array(n.number()).optional(),cornerSmoothing:n.number().optional(),blendMode:ct.optional(),constraints:n.object({horizontal:dt,vertical:dt}).optional(),layoutGrids:n.array(ft).optional(),clipsContent:n.boolean().optional(),arcData:n.object({startingAngle:n.number(),endingAngle:n.number(),innerRadius:n.number()}).optional(),effects:n.array(ut).optional(),cornerRadius:n.number().optional(),topLeftRadius:n.number().optional(),topRightRadius:n.number().optional(),bottomLeftRadius:n.number().optional(),bottomRightRadius:n.number().optional(),pointCount:n.number().optional(),innerRadius:n.number().optional(),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:n.number().optional(),paddingTop:n.number().optional(),paddingRight:n.number().optional(),paddingBottom:n.number().optional(),paddingLeft:n.number().optional(),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:n.number().optional(),layoutAlign:n.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:n.number().optional(),children:n.array(x).optional(),characters:n.string().optional(),fontSize:n.number().optional(),fontName:mt.optional(),textAlignHorizontal:n.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:n.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:n.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:n.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:n.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:ht.optional(),letterSpacing:gt.optional(),vectorPaths:n.array(pt).optional(),booleanOperation:n.enum(Xe).optional(),isMask:n.boolean().optional(),variantProperties:n.record(n.string(),n.string()).optional(),mainComponentId:n.string().optional(),variantGroupProperties:n.record(n.string(),n.array(n.string())).optional(),textTruncation:n.enum([`DISABLED`,`ENDING`]).optional(),maxLines:n.number().optional(),fillStyleId:n.string().optional(),strokeStyleId:n.string().optional(),textStyleId:n.string().optional(),effectStyleId:n.string().optional(),componentProperties:n.record(n.string(),tn).optional(),componentPropertyReferences:rn.optional(),boundVariables:on.optional()})),_n=n.object({created:n.union([x,n.array(x)]),warnings:n.array(n.string()).optional()}),vn=n.object({updated:n.array(x),warnings:n.array(n.string()).optional()}),yn=n.object({connected:n.boolean(),platform:Xt.optional(),capabilities:n.array(Zt).optional().describe(`schema.results.capabilities`),coreCapabilities:n.array(Qt).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:n.array($t).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:n.string().optional()}),bn=n.object({selection:n.array(x),pageName:n.string()}),xn=n.object({nodes:n.array(x),total:n.number(),scope:n.enum(qt).optional(),note:n.string().optional()}),Sn=n.object({selected:n.array(n.string()).optional(),removed:n.array(n.string()).optional(),ungrouped:n.array(n.string()).optional(),moved:n.array(x).optional(),updated:n.array(x).optional(),cleaned:n.array(n.string()).optional(),created:n.union([x,n.array(x)]).optional(),warnings:n.array(n.string()).optional()}),Cn=n.object({variantProperties:n.record(n.string(),n.string()).optional(),componentProperties:n.record(n.string(),tn).optional(),propsSummary:n.array(n.string()).optional()}),wn=n.object({instanceId:n.string(),instanceName:n.string(),ok:n.boolean(),message:n.string().optional()}),Tn=n.object({created:n.union([x,n.array(x)]).optional(),swapped:n.array(x).optional(),updated:n.array(x).optional(),snapshotId:n.string().optional(),sourceName:n.string().optional(),captured:Cn.optional(),applied:n.array(wn).optional(),source:Cn.optional(),failed:n.array(n.object({id:n.string(),message:n.string()})).optional(),warnings:n.array(n.string()).optional()}),En=n.object({exports:n.array(n.object({id:n.string(),name:n.string(),format:n.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:n.string(),size:n.number(),path:n.string().optional(),dataUrl:n.string().optional()}))}),Dn=n.object({families:n.array(n.string()).describe(`schema.results.families`),fonts:n.array(n.object({family:n.string().describe(`schema.results.family`),styles:n.array(n.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:n.number().describe(`schema.results.count`),total:n.number().optional().describe(`schema.results.total`),offset:n.number().optional().describe(`schema.results.offset`),truncated:n.boolean().optional().describe(`schema.results.truncated`)}),On=n.object({id:n.string(),name:n.string()}),kn=On.extend({properties:n.record(n.string(),n.array(n.string())).optional().describe(`维度 → 可选值,如 {"状态":["默认","禁用"]};平台读不到该字段时整个键省略`)}),An=On.extend({type:n.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])}),jn=n.object({summary:n.object({components:n.number(),variants:n.number(),styles:n.number(),variables:n.number()}),components:n.array(On),variants:n.array(kn),styles:n.array(An),variables:n.array(On)}),Mn=n.object({pageName:n.string(),nodes:n.array(n.object({id:n.string(),name:n.string(),type:Ot,x:n.number(),y:n.number(),width:n.number().optional(),height:n.number().optional()})),count:n.number(),assets:jn.optional(),pages:n.array(n.object({name:n.string(),childCount:n.number()})).optional(),note:n.string().optional()});n.object({styles:n.array(n.object({id:n.string(),name:n.string(),type:n.enum(Ne)})),count:n.number(),note:n.string().optional()});var Nn=n.object({created:n.object({id:n.string(),name:n.string(),type:n.enum(Ne)})}),Pn=n.object({removed:n.array(n.string()),failed:n.array(n.object({id:n.string(),reason:n.string().describe(`这一条没删掉的原因(通常是样式 id 不存在)`)}))}),Fn=n.object({x:n.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:n.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:n.number().optional().describe(`schema.sharedProps.width`),height:n.number().optional().describe(`schema.sharedProps.height`),rotation:n.number().optional().describe(`schema.sharedProps.rotation`),opacity:n.number().optional().describe(`schema.sharedProps.opacity`),visible:n.boolean().optional(),locked:n.boolean().optional()}),In=n.object({width:n.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:n.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),Ln=n.object({pointCount:n.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:n.number().optional().describe(`schema.sharedProps.innerRadius`)}),Rn=n.object({strokes:n.array(lt).optional().describe(`schema.sharedProps.strokes`),strokeWeight:n.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:n.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:n.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:n.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:n.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:n.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:n.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.sharedProps.strokeCap`),strokeJoin:n.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.sharedProps.strokeJoin`),dashPattern:n.array(n.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:n.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),zn=n.object({cornerRadius:n.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:n.number().optional().describe(`schema.sharedProps.topLeftRadius`),topRightRadius:n.number().optional().describe(`schema.sharedProps.topRightRadius`),bottomLeftRadius:n.number().optional().describe(`schema.sharedProps.bottomLeftRadius`),bottomRightRadius:n.number().optional().describe(`schema.sharedProps.bottomRightRadius`)}),Bn=n.object({characters:n.string().optional().describe(`schema.sharedProps.characters`),fontSize:n.number().optional().describe(`schema.sharedProps.fontSize`),fontName:mt.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:n.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:n.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:n.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:n.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.sharedProps.textCase`),textDecoration:n.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.sharedProps.textDecoration`),lineHeight:ht.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:gt.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:n.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:n.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:n.number().optional().describe(`schema.sharedProps.maxLines`)}),Vn=n.object({layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:n.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:n.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:n.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:n.enum(Ie).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum(Le).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:n.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:n.enum(Fe).optional().describe(`schema.sharedProps.layoutAlign`)}),S=n.object({fills:n.array(lt).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:n.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:ct.optional(),effectStyleId:n.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:n.array(ut).optional().describe(`schema.sharedProps.effects`),constraints:n.object({horizontal:dt.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:dt.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:n.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:n.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:n.array(ft).optional().describe(`schema.sharedProps.layoutGrids`),arcData:n.object({startingAngle:n.number().describe(`schema.sharedProps.startingAngle`),endingAngle:n.number().describe(`schema.sharedProps.endingAngle`),innerRadius:n.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),Hn={ids:n.array(n.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:n.string().optional().describe(`schema.splitOps.matchName`),recursive:n.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:n.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},C=(e,t=1)=>n.array(n.string()).min(t).describe(e),Un=n.object({ids:C(`要设为当前选中的节点 id 列表`)}).strict(),Wn=n.object({ids:n.array(n.string()).optional().describe(`schema.splitOps.ids2`),matchName:n.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),Gn=n.object({ids:C(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),Kn=n.object({ids:C(`要编组的节点 id 列表,至少 2 个`,2),name:n.string().optional().describe(`schema.splitOps.name`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:n.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:n.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:n.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),qn=n.object({ids:C(`要解组的节点 id 列表`)}).strict(),Jn=n.object({ids:C(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),Yn=n.object({ids:C(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),Xn=n.object({ids:C(`要移动的节点 id 列表`),parentId:n.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:n.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),Zn=n.object({ids:n.array(n.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Qn=n.object({ids:n.array(n.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:n.string().optional().describe(`schema.splitOps.name2`),children:n.array(kt).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:n.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:n.number().optional().describe(`组件高度(px);同上`)}).strict(),$n=n.object({ids:C(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),er=n.object({ids:C(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),tr=n.object({key:n.string().describe(`schema.splitOps.key`),name:n.string().optional().describe(`schema.splitOps.name3`)}).strict(),nr=n.object({ids:C(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:n.string().describe(`schema.splitOps.componentId`)}).strict(),rr=n.object({ids:C(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:n.record(n.string(),an).describe('属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名取 jsd_find / jsd_get_selection 的 variantProperties(变体)与 componentProperties(布尔/文本/换绑):**变体属性传名字即可;组件属性传带 `#` 后缀的完整键**(如 `标题#32:0`)—— 组件属性在引擎侧只认完整键,短名会报 `Could not find a component property with name`(真机实测,三种类型都如此)。传短名时 core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选,不做猜测。**选哪个键之前先读 componentPropertyReferences**:它标明「哪个图层由哪个属性驱动」,属性成对存在时只有连着可见层的那一组会改画面')}).strict(),ir=n.object({ids:C(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:n.string().optional().describe(`schema.splitOps.name4`)}).strict(),ar=n.object({kind:n.enum(Ne).describe("样式类别。八项是三家 `StyleType` 的并集:**PAINT / TEXT / EFFECT / GRID 三家都有**;`STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING` **只 MasterGo 能建**—— 在 Figma / 即时设计传这四类会被写前点名拒(不静默、不 fallthrough 建成别的类)。MG 上和另四类一样是「从取值节点抄」,所以间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值时前置检查就会拦下"),name:n.string().min(1).describe("样式名,建议用「分组/名称」两层(如 `色板/主色`)"),description:n.string().optional().describe(`样式说明,建后可在 jsd://styles 里回读`),fromNodeId:n.string().describe(`**取值来源节点**(必填):三平台唯一都成立的形状 —— MG 的原生入口就是「从这个图层抄」,Figma / jsDesign 由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进新样式。PAINT 类 fills 优先,节点只有描边时退到 strokes`)}).strict(),or=n.object({ids:n.array(n.string().min(1)).min(1).describe(`要删的本地样式 id 列表(取自 jsd://styles 或 jsd_get_page 的 assets.styles);按 id 不按名 —— 同名样式可以并存,按名删等于猜`)}).strict(),sr=n.object({sourceId:n.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),cr={ids:C(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:n.string().describe(`schema.splitOps.sourceId`),swapToSource:n.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},lr=n.object(cr).strict(),ur=n.object(cr).strict(),dr={fills:S.shape.fills,fillStyleId:S.shape.fillStyleId,blendMode:S.shape.blendMode},fr={...Rn.shape},pr={cornerRadius:zn.shape.cornerRadius,topLeftRadius:zn.shape.topLeftRadius,topRightRadius:zn.shape.topRightRadius,bottomLeftRadius:zn.shape.bottomLeftRadius,bottomRightRadius:zn.shape.bottomRightRadius,cornerSmoothing:S.shape.cornerSmoothing},mr={...Bn.shape,fills:S.shape.fills,fillStyleId:S.shape.fillStyleId,blendMode:S.shape.blendMode,width:In.shape.width,height:In.shape.height},hr={x:Fn.shape.x,y:Fn.shape.y,rotation:Fn.shape.rotation},gr={...In.shape,x:Fn.shape.x,y:Fn.shape.y},_r={...Vn.shape,constraints:S.shape.constraints},vr={effects:S.shape.effects,effectStyleId:S.shape.effectStyleId,clipsContent:S.shape.clipsContent,layoutGrids:S.shape.layoutGrids,arcData:S.shape.arcData},yr={opacity:Fn.shape.opacity,visible:Fn.shape.visible,locked:Fn.shape.locked},br={name:n.string().describe(`schema.splitOps.name5`)},xr={...Ln.shape};function w(e){return n.object({...Hn,...e}).strict()}var Sr=w(dr),Cr=w(fr),wr=w(pr),Tr=w(mr),Er=w(hr),Dr=w(gr),Or=w(_r),kr=w(vr),Ar=w(yr),jr=w(br),Mr=w(xr),Nr={set_fill:Object.keys(dr),set_stroke:Object.keys(fr),set_corner_radius:Object.keys(pr),set_text:Object.keys(mr),move:Object.keys(hr),resize:Object.keys(gr),set_layout:Object.keys(_r),set_effects:Object.keys(vr),set_visibility:Object.keys(yr),rename:Object.keys(br),set_shape:Object.keys(xr)};function T(e){return n.object({...Hn,props:n.object(e).strict()}).strict()}T(dr),T(fr),T(pr),T(mr),T(hr),T(gr),T(_r),T(vr),T(yr),T(br),T(xr);function Pr(e,t,n){let r=e.ctx.platform;return r==null?null:Ge(r,t,e.node.type)?We(r,t,n)?null:`value`:`type`}function Fr(e,t,n){let r=Pr(e,t,n);if(r==null)return!0;let i=e.ctx.platform;if(i==null)return!0;let a=Yt[i];if(e.outcome.ignored.add(t),r===`type`)return e.outcome.warnings.push(`${t} 在 ${a} 的「${e.node.type}」上没有对应字段(该平台的这类节点不含这个属性的 mixin),本次已跳过:不是写失败,是这种节点上不存在该属性。要用它就换本平台支持该属性的节点类型;不去写的话结果里不会再回显它。`),!1;let o=Ke(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function Ir(e,t){return e[t]}function Lr(e,t,n){e[t]=n}function Rr(e,t,n){return n==null||!(t in e)?!1:(Lr(e,t,n),!0)}function zr(e,t,n,r){return Br(e,t,n,r)?Rr(t,n,r):!1}function Br(e,t,n,r){return!(r==null||!Me(n,t.type)||!Fr(e,n,r))}var Vr={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(i!=null&&Wr(t),r){if(i==null)return;zr(e,t,`layoutMode`,i);let r=n;zr(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])zr(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])zr(e,t,n,r[n]);qr(e);return}for(let r of Vr.keys)zr(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&&Me(r,t.type)&&Pr(e,r,i)==null&&(r in t&&t[r]!==i&&Lr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||t[r]===i}))}for(let r of[`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`]){let i=n[r],a=i;e.create&&(a=n.layoutMode==null?void 0:i??0),a!=null&&Me(r,t.type)&&Pr(e,r,a)==null&&(r in t&&Ir(t,r)!==a&&Lr(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||Ir(t,r)===a}))}for(let r of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let i=n[r];i!=null&&(e.create&&n.layoutMode==null||Me(r,t.type)&&Pr(e,r,i)==null&&(r in t&&Ir(t,r)!==i&&Lr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||Ir(t,r)===i})))}if(n.layoutMode==null||!Me(`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 Hr(e){try{let t=e.children;return Array.isArray(t)?t.map(e=>e.id):[]}catch{return[]}}var Ur=new WeakMap;function Wr(e){let t=e;Ur.set(e,{order:Hr(e),width:typeof t.width==`number`?t.width:void 0,height:typeof t.height==`number`?t.height:void 0})}var Gr=new WeakMap;function Kr(e,t){let n=Gr.get(e)??new Set;n.add(t),Gr.set(e,n)}function qr(e){let{node:t,src:n}=e;if(n.layoutMode==null)return;let r=Jr(n,e.outermost),i=n.layoutMode===`HORIZONTAL`;for(let e of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let a=r[e];a!=null&&n[e]==null&&e in t&&(Lr(t,e,a),a===`AUTO`&&Kr(t,e===`primaryAxisSizingMode`===i?`width`:`height`))}}function Jr(e,t){let n=e.layoutMode;if(n!==`HORIZONTAL`&&n!==`VERTICAL`)return{};let r=n===`HORIZONTAL`,i=e=>e===`height`&&!t?`AUTO`:`FIXED`,a={};return(r?e.width!=null:e.height!=null)&&(a.primaryAxisSizingMode=i(r?`width`:`height`)),(r?e.height!=null:e.width!=null)&&(a.counterAxisSizingMode=i(r?`height`:`width`)),a}Object.keys(ke).filter(e=>e!==`componentProperties`);var Yr=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=>Yr.has(e)));function Xr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Yr].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var Zr={"zh-CN":Jt,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.styleEnumeration":`Local style listing (can enumerate which styles exist)`,"capability.host.styleEnumerationSync":`Style enumeration uses the sync entry (runtime *Async members are unusable)`,"capability.host.mainComponentSync":`Main component read via the sync field (runtime getMainComponentAsync never settles)`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.documentScopeRead":`Document-scope read (can read pages other than the current one)`,"capability.host.variables":`Variables`,"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.theme.toDark":`Switch to dark theme`,"header.theme.toLight":`Switch to light theme`,"header.cameraLock.locked":`Camera locked`,"header.cameraLock.unlocked":`Camera follows`,"header.cameraLock.title.locked":`Camera locked: canvas operations do not move your viewport (click to follow)`,"header.cameraLock.title.unlocked":`Camera follows: canvas operations scroll and zoom to the result (click to lock)`,"header.minimize":`Minimize`,"header.minimize.title":`Minimize the panel to just the logo; double-click the logo to restore`,"header.restore.title":`Double-click the logo to restore the panel`,"upgrade.title":`A newer version is available (click for upgrade steps)`,"upgrade.modal.title":`Upgrade to the latest version`,"upgrade.current":`Current {version}`,"upgrade.latest":`Latest {version}`,"upgrade.plugin.label":`Plugin`,"upgrade.service.label":`Service`,"upgrade.step.service":`① Service, just restart the AI session. It runs npx -y text-to-design-mcp@latest, so it is always the newest`,"upgrade.step.plugin.head":`② Plugin is a manual swap. Download the latest`,"upgrade.step.plugin.tail":`, unzip it, then import the manifest for your platform`,"upgrade.step.verify":`③ Run the plugin again. No upgrade icon up top means both sides match`,"upgrade.copy":`Copy for AI assistant`,"upgrade.prompt":`I use text-to-design. Plugin text-to-design-ui is {ui}, latest {uiLatest}; service text-to-design-mcp is {mcp}, latest {mcpLatest}. Help me get both to the latest: ① check the MCP config command pins latest, then restart the AI session; ② download and unzip the latest text-to-design-ui (npm pack, or the zip from GitHub Releases), and tell me which manifest.json under dist/ to import for jsDesign / Figma / MasterGo; ③ report both version numbers when done.`,"toast.copy.done":`Copied`,"toast.copy.failed":`Copy failed`,"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.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:
|
|
20
20
|
|
|
21
21
|
1. If the MCP server is not registered yet: register a stdio MCP server the native way for your tool,
|
|
22
22
|
with the command \`npx -y text-to-design-mcp@latest\` (no manual install; npx fetches and runs it).
|
|
@@ -34,28 +34,28 @@ import{createRequire as e}from"node:module";import{appendFileSync as t,mkdirSync
|
|
|
34
34
|
- 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.
|
|
35
35
|
- When producing ≥2 sibling units that share one structure: make a COMPONENT first, then spread it with INSTANCE; name them "component family/state".
|
|
36
36
|
- For multi-step work read the matching recipe prompt first (they live in prompts/list, names carry no jsd_ prefix; fetching one injects the full flow and acceptance criteria) instead of improvising with tools: charts / data visualization → chart-by-code (line, bar, pie / donut, scatter, radar, area, gauge — compute the geometry in a script, write the SVG to disk, import it via svgPath on jsd_create_svg); HTML to design → html-to-design; designing a screen from scratch → design-strategy; laying out screen sections / auto layout (should a container use it, the two adoption paths, the sections usually missed) → auto-layout; bulk text edits → text-replace-strategy; icon grid → icon-grid; merging multi-step canvas ops into one call → script-ops; syncing styles across sibling instances → variant-sync; variant set construction → variant-set; binding variables in bulk → variable-binding; defining and setting component properties → component-property. The same recipes are also exposed as MCP resources: when a host does not inject this section (observed on most clients), go by the resources instead — read jsd://recipes for the index (with when-to-use per entry) and jsd://recipes/<id> for the body.`,"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.\nA 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). Name addressing is a separate route: {{@comp:Button}} resolves to a component / variant-set id and {{@var:accent/blue}} to a variable id, both looked up in the jsd_get_page asset list (read at most once per batch and shared across the steps of that batch; exact names win, then case-insensitive), write the name exactly as the list stores it — on jsDesign a component named with "/" is split into set + member, so assets.components[].name keeps only the leaf and the creation-time path will not match) and a miss or a duplicate name aborts with the candidates named rather than guessing (platforms that cannot read other pages list only the current page). Resources created inside this batch are not in that snapshot — keep using {{id.created[0].id}} for them. 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). **When the list does not fit, use `callsFile`**: pass the absolute path of a JSON file holding {"calls":[…]}(optionally with stopOnError / checkDrift) or a bare array — same shape as calls — and the ids never enter the context. That file can also be run directly with the CLI: `text-to-design-mcp exec <file> [--json] [--dry-run]`.\nEchoes 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, and the full detail of the whole batch is spilled to a JSONL file (temp dir, one line per step `{id,tool,ok,data}`) with the step echo carrying path and line (echoTrimmed=true, plus an echoNote naming each affected step); only an over-limit or failed write falls back to a bare id list, named in warnings. Note: echoes never carry child nodes — a node is summarized as a whole, so children plus characters / fills / *StyleId / vectorPaths are absent; read the JSONL or call the tool alone to read a subtree instead of assuming the children are gone or the write failed. 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.\nResult keys and placeholder syntax per tool (a wrong key aborts the batch; a single object and a one-element array are interchangeable, so {{id.created[0].id}} and {{id.created.id}} both resolve — reading .field straight off a multi-element array still aborts): 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_create_style; jsd_find -> nodes; jsd_get_selection -> selection; jsd_set_* -> updated; jsd_swap_component -> swapped; jsd_delete_style -> removed[] (array of id strings, so {{id.removed[0]}})\\\\n· jsd_platform_op -> the step result IS the op payload (no .data envelope): {{id.variables[0].id}} for figma_variables_create, {{id.styles[0].boundVariables}} for figma_style_variables_list; each op documents its own shape in jsd_ping platformOps; jsd_manage_nodes ops: select/remove/ungroup/repair -> id string arrays, clone/outline_stroke -> created[group/flatten -> created (single object), reparent -> moved[].\nStructure 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. For multi-step recipes (charts, designing a screen from scratch, HTML to design, bulk copy edits, components and variants, variable binding) read the recipe index jsd://recipes first (ReadMcpResource) instead of improvising tool calls; for whole-page / whole-file bulk edits (many groups per call, ids kept out of the context, read-back verification, chunking by block) read jsd://recipes/script-ops.',"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.
|
|
37
|
-
Result keys per op (needed to write correct jsd_batch placeholders; a wrong key aborts the batch): select -> selected[and remove -> removed[are id strings; clone/outline_stroke -> created[is an array of nodes; group/flatten -> created is a single node object; ungroup -> ungrouped[is id strings; reparent -> moved[(updated[mirrors it); repair -> cleaned[is id strings.`,"createBooleanOperation.description":`Create a single BOOLEAN_OPERATION node: the booleanOperation mode ({ops}) and children (at least 2 merged child nodes) are required. Only one root boolean node. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"setFillColor.description":`Set fill color/gradient (fills is a Paint array, replaced wholesale rather than merged — pass existing fills you want to keep), blend mode and team-library fill styles. {warn}`,"setText.description":`Modify text (TEXT nodes only): **content and typography** characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, **colour** fills/fillStyleId/blendMode, **size** width/height (pair with textAutoResize), plus Figma truncation and max lines; position x/y is not here — use jsd_move_node / jsd_resize_node. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content — for such text, setting characters again reflows it (measured: a fixed-width-200 text whose height read back 15 re-read 82). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`}},Jr=/\{(\w+)\}/g;function Yr(e){let t=qr[e]??qr.en,n=qr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Jr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Xr=/^zh([-_]|$)/i,Zr=/^en([-_]|$)/i;function Qr(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Xr.test(t))return`zh-CN`;if(Zr.test(t))return`en`}}var $r={debug:0,info:1,warn:2,error:3},ei={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},O=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,k=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,A=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,ti={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:"两条路,都不是变量那种玩法:① **本地样式** —— `jsd_create_style` 从一个既有节点抄出样式(本平台四类:PAINT / TEXT / EFFECT / GRID;契约的类别是三家 `StyleType` 的八项并集,余下四类本平台没有工厂,传过去会被写前点名拒),回 id;绑上去用 jsd_set_fill_color 的 fillStyleId / jsd_set_text 的 textStyleId / jsd_set_effects 的 effectStyleId / jsd_set_stroke 的 strokeStyleId。**⚠ 本平台未声明 `styleEnumeration`,样式清单(`jsd://styles` / `assets.styles`)恒空、列不出来**:已有样式的 id 只能从正用着它的节点上读(`*StyleId` 字段),新建的 id 从 `jsd_create_style` 回包记账(建重复了用 `jsd_delete_style` 删)。一条样式改一次,全档跟随。② **结构继承** —— 抽成 COMPONENT 后改主件,实例自动继承(批量套覆盖走 variant-sync 配方)。",evidence:[`${O}(全文无 variable 声明:grep -in variable 零命中)`,`packages/ui/src/code/jsdesign/meta.ts capabilities=[styles](按 id 应用样式是有的;**不声明 styleEnumeration** —— 列不出样式,见 0043)`,`packages/shared/src/core/access.ts:174(listStylesAsync 在未声明 styleEnumeration 时直接返回空,四个 getter 一次都不调)`,"packages/ui/src/code/jsdesign/host.ts:48(createStyle 已接:`jsd_create_style` 走 jsDesign.createPaintStyle 等四工厂;四类样式的共同契约在 packages/shared/src/core/styles.ts)",`${O}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${O}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 团队库「组件集」导入入口,本仓只接了组件那半(:110);拿到集合节点是目前唯一的非画布来源`,`Page.createNodeFromJSXAsync(:119) —— JSX 建节点,是否支持组件/集合标签未验(typings 无声明,只有 any)`],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${O}:1093 setProperties 只收 string`,`${O}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:367-393 setProperties 签名只收字符串;真机 2026-10-14 的运行期行为:给**没有变体属性**的 INSTANCE 调它不是点名报错,而是挂到转发超时(25s)—— 没有变体集时别拿它当切状态的通道`,"packages/shared/src/core/component.ts setInstanceProperties 的属性面守卫 —— 2026-10-19 真机复现同一条(未知属性名 `Foo` → 25077ms 后失败、错误只有「插件响应超时」):能力位不含 componentProperties 且变体表 / variantProperties 都拿不到键时,写前点名拒,不再落到引擎空转","packages/shared/src/core/access.ts resolveMainComponent 的选路 —— 2026-10-19 真机隔离:typings 未声明的 `getMainComponentAsync` 在即时设计运行时**存在且永不 settle**(与 `*Async` 样式枚举同一模式),`?.` 探测让 `jsd_copy_overrides`(只读快照、不写属性)挂到 25109ms;改由 `mainComponentSync` 声明只问同步 `mainComponent`","packages/ui/src/code/jsdesign/ops.ts jsd_component_facts —— 2026-10-20 三页官方文档核对(js.design/developer-doc/plugin/api/node/{ComponentNode,InstanceNode,ComponentSetNode}):**成员与 typings 1.0.12 逐字一致,没有多出来的 API**;文档确认而契约缺的字段(ComponentNode.instances / key / remote / description / expanded / getPublishStatusAsync、InstanceNode.scaleFactor、ComponentSetNode.defaultVariant / variantGroupProperties / children)由本 op 透出。`getPublishStatusAsync` 单独可选:同族 async 成员有永不 settle 的先例(dec e1e66f0a)",`packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 真机(2026-10-20,重载后):COMPONENT 的 instances 可读且准确(建组件+2 实例 → instanceCount 2 / instanceIds 两条)、key 是空串、remote=false;description **可写**且回读一致(PublishableMixin :838);getPublishStatusAsync **21ms 返回、不永挂**(与 getMainComponentAsync 不同),但对非团队库节点回的是**错误串** "Failed to get node publish status" 而不是 PublishStatus 三值 ⇒ op 里三值才认,其余落 publishStatusError`,'packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 的 INSTANCE 分支 + core/assets.ts readVariantProperties —— 真机 2026-10-20 两条:① `variantGroupProperties.values` 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"}]),撞穿 assets.variants.properties 的 string[] 校验使 `get_page` **整条失败**,故 projection 与 op 都按名字归一;② 对真实变体实例调 setProperties **11~15ms 就抛** `in setProperties: i.setProperties is not a function`(typings :1093 与文档都声明了它)⇒ 符号是否真在由 op 的 `setPropertiesAvailable` 回报复核',"packages/ui/src/code/jsdesign/host.ts combineAsVariants 的显式绑定 —— 官方 API 参考页(js.design/developer-doc/plugin/api/reference/jsDesign)确认语义「将任意数量的组件合并为变体」、签名 (nodes, parent, index?);真机 2026-10-20 逐项排除:receiver 绑回全局后报错逐字相同、组件名改成 `状态=默认/禁用` 仍败、带子层仍败、先 reparent 进 FRAME 仍败 ⇒ **引擎实现缺陷,不是调用方式**",`packages/shared/src/core/component.ts combineAsVariantsNodes 的姿势顺序 —— 真机 2026-10-20:合并失败会**毁入参组件**(用户组件 13:100 变损坏节点、repair 直接删),故「原位合并」只在平台声明 inPlaceVariants 时才尝试(Figma 声明、顺序不变);jsDesign 只跑两条克隆姿势,失败也不伤原组件`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**单姿势隔离实验** —— 真机 2026-10-20(即时设计,干净画布,只跑原位姿势,传入真 COMPONENT、类型完全合规):仍抛 in get_booleanOperation: Value is not a string;后果是入参组件 13:332 被就地改成 BOOLEAN_OPERATION、13:333 幸存 ⇒ 坐实引擎实现缺陷,并排除两个替代解释:①「clone 返回 INSTANCE 导致参数类型不符才是根因」(原位传合规类型照样崩);②「被克隆两式弄脏画布才连带失败」(干净画布单跑照样崩)`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**裸调实验** —— 真机 2026-10-20(即时设计,画板 3 下 4 个真 COMPONENT,取消 core 的姿势选择 / clone 类型校验 / 父容器校验 / 跨父级校验 / 返回类型校验,直接 host.combineAsVariants(components, parent)):引擎**成功返回一个 type=BOOLEAN_OPERATION 的节点**(id 13:446),读它的 name 抛 in get_name: Value is not a string;四个原 COMPONENT **被搬进该布尔节点下**(parentId=13:446),画板 3 随即变空 ⇒ 坐实「引擎把合并路由成布尔运算」,并排除「core 的某个前置判断改变了入参」这一解释(裸调无任何判断,行为一致)。事后可用 jsd_reparent_nodes 把组件搬回原容器,损坏节点由 repair 清`,"packages/shared/src/core/access.ts resolveNodes 的返回身份 —— 真机 2026-10-20(即时设计,只读探针,未执行合并):四个 COMPONENT 逐个比对 `=== jsDesign.getNodeById(id)`,**全部 true**(即返回的是原生对象本身,不是包装或代理);成员核验 nodes 各有 createInstance(ComponentNode 独有)、无 setProperties(那是 InstanceNode 的),parent 有 children/appendChild/insertChild 且无 createInstance、且不等于 currentPage ⇒ 入参**完全满足** combineAsVariants(nodes: ReadonlyArray<ComponentNode>, parent: BaseNode & ChildrenMixin) 的签名。故「参数类型不满足」这一解释被排除:类型层面的 `as never` 只是掩盖了静态证明,运行时要传的对象是对的",`packages/shared/src/core/component.ts / jsd_reparent_nodes —— 真机 2026-10-20:RECTANGLE 可 reparent 进 COMPONENT(文档 ComponentNode 继承 BaseFrameMixin → appendChild :711),childCount 0→1,且**两个实例的 childCount 同步变 1**(主件加子层实时传播)`,`packages/shared/src/core/component.ts setInstanceProperties / swapComponents / detachInstanceNodes + packages/shared/src/core/nodes.ts cloneNodes + packages/shared/src/core/variant.ts —— 真机 2026-10-20(即时设计,逐条隔离):① **变体集成员**上 createInstance 必抛 in createInstance: The node with id undefined does not exist(集合内 8 个成员全复现;独立 COMPONENT 正常),clone() 返回 undefined;② swapComponent 必抛 in swapComponent: Cannot read properties of undefined (reading type)(独立组件之间 / 成员之间 / 克隆实例上全复现);③ detachInstance **原位返回同一个 INSTANCE**(type 仍 INSTANCE、mainComponentId 照旧)⇒ 静默 no-op;④ 集合维度键 状态 与成员键 分类1 **不是同一套**,只按集合键校验会把合法的成员键写入拒掉`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 未接;这是「不经画布拿到集合节点」的唯一路径`,`ComponentSetNode.appendChild / insertChild(:711-712,继承自 BaseFrameMixin)—— 类型上能追加成员,但没有创建入口 ⇒ 拿不到集合节点,这一面实际不可达`],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me);实例侧切值本平台运行期无入口(setProperties 不是函数、swapComponent 抛内部错误,真机 2026-10-20),变体取值只能在画布上手工切换`,evidence:[`${O}:899-900 VariantMixin.variantProperties(readonly)`,`${O}:1074-1079 ComponentSetNode 自身只多 clone / defaultVariant / variantGroupProperties;但 :1074 继承 BaseFrameMixin(:851)→ 带 appendChild / insertChild(:711-712)`,`packages/shared/src/core/variant.ts + core/serialize.ts + core/assets.ts —— 真机 2026-10-20:variantGroupProperties.values 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"},{"name":"禁用"}]),不归一会撞穿线格式 string[] 并让 get_page / jsd_find **整条失败**(不是少字段,是这次只读调用报废);variantProperties 同理。归一实现单点(两个投影点共用),serializeNode 另加一层「getter 抛也省略该字段」的保护`,"packages/ui/src/code/jsdesign/host.ts / core/component.ts combineAsVariants 兜底 —— 真机 2026-10-19 复核(即时设计,重载后):72ms 抛「三种姿势均失败…in get_booleanOperation: Value is not a string」**与 09-24/10-14 逐字一致**;残留形态这次是 **3 个 BOOLEAN_OPERATION(原 COMPONENT 被就地改成 BOOLEAN_OPERATION、id 保留)+ 1 个幸存 COMPONENT,没有 COMPONENT_SET**(10-14 那次是留下畸形 COMPONENT_SET),`assets.variants` 回到 0 ⇒ 残留形态不稳定,清理一律走 `jsd_manage_nodes op=repair`(实测 `cleaned: 3 个`)",`${O}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${k}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${k}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${k}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${k}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${k}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${k}:11127 readonly componentProperties`,`${k}:11123 setProperties(string | boolean | VariableAlias)`,`${k}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${k}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${k}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${k}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${k}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${k}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${k}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${k}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${A}:1522 readonly variables: VariableAPI`,`${A}:1098-1108 VariableAPI(Collection / Mode)`,`${A}:1176 getVariables() / :1874 Variable{id,name,…}`,`${A}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${A}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${A}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/ops.ts removeVariables 的三档 —— 真机 2026-10-19(重载后两轮):单值变量的 deleteVariable **跨执行才生效**(同执行内删两遍 + 回读仍全失败,下一次调用立刻 removed),故同执行回读判失败会把成功报成失败(10-15 那 5 条 failed 即此形态);复合样式变量(PAINT)的 deleteVariable 是 **no-op**(跨多次执行仍在:列表 / assets.variables / 拿它绑图层三面都证明它还活着,同 id 走 jsd_delete_style 一次删掉)`,`packages/ui/src/code/mastergo/ops.ts createVariables 的 values —— 真机 2026-10-19:setVariableValue 的返回 modes **时有时无**(同批里有的带 bool / floatData,有的只有 {modeId},默认双模式集合回空对象);STRING 变量在列表 / 按 id / 写返回三个读面都只有 {modeId} ⇒ 值不可验证,values 只原样透传不作判据`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${A}:3096 readonly componentProperties: Array<ComponentProperties>`,`${A}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${A}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${A}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${A}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${A}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${A}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${A}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${A}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function j(e,t){return e==null?null:ti[e][t]}var ni={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},ri=`https://registry.npmjs.org`;function ii(e){return`${ri}/${e}/latest`}var ai=4e3,oi=process.env.TEXT_TO_DESIGN_MCP_LOG??d(c(),`text-to-design-mcp.log`),si=$r,ci=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,li=null;function ui(e){li=e}function di(e,n){if(si[e]>=si[ci])try{t(oi,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{li?.(e,n)}catch{}}function M(e){di(`info`,e)}function N(e){di(`debug`,e)}function P(e){di(`warn`,e)}function F(e){di(`error`,e)}var fi=Se,pi=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??fi,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 v(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new v(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(clearTimeout(l.timer),this.detachAbort(l),M(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new v(`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 v(t.error.code,t.error.message):new v(`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 v(`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(mi(e.data,e.buffers))}};function mi(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 hi=`0.13.4`,gi=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),_i=`text-to-design-mcp-server`,L=hi,vi=Date.now(),yi=15e3,bi=6e3,xi=5e3,Si=6e4,Ci=3e5,wi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),Ti=12e4,Ei=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),Di=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_BATCH_SPILL_BYTES??33554432),Oi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),ki={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,Ai=null;function ji(){return R}function Mi(){let e=R?.platform;if(e==null)return{label:ki.label,runtime:ki.runtime};let t=Kt[e];return{label:`${t}客户端`,runtime:t}}function Ni(e){R!=null&&(R=null,N(`平台状态已清空(${e})`))}function Pi(e){return Ai??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:xi});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{Ai=null}})(),Ai}function Fi(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function Ii(e){if(Fi(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 Li(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Ri=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=ee(),this.wss=new te({server:this.http}),this.wss.on(`error`,e=>{P(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),be),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===g.OPEN}send(e){this.client&&this.client.readyState===g.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===g.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(xe,`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} (${Li(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===g.OPEN&&(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==g.OPEN)return;let n={type:`status`,state:t,version:hi};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)})}},zi=200,Bi=class{transport=new Ri;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;constructor(){this.pending=new pi((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.onPluginConnect?.(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(P(`请求被拒(插件未连接): ${e}`),Promise.reject(new v(`not_connected`,`${Mi().runtime} 插件未连接。请先在${Mi().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=zi&&this.logRing.shift(),this.logRing.push(n);return}this.sendLogPush(n)}pushVersion(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`版本推送失败: ${e instanceof Error?e.message:String(e)}`)}}notifyActivity(e,t){if(!this.transport.isConnected)return;let n=t==null?{type:`activity`,phase:e}:{type:`activity`,phase:e,tool:t};try{this.transport.sendPush(JSON.stringify(n))}catch(e){P(`活动推送失败: ${e instanceof Error?e.message:String(e)}`)}}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 Vi(){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 Hi=!1;async function Ui(){if(Hi)return;Hi=!0;let e=process.argv[1];if(!e)return;let t;try{t=a(e).mtimeMs}catch{return}let n=await Vi();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 Wi(){let e=await Vi();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()+bi;for(;Date.now()<t&&(await Gi(250),await Vi()!==null););return await Vi()===null?{state:`none`}:(M(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new ne({name:`text-to-design-proxy`,version:L},{versionNegotiation:{mode:`auto`}});try{await t.connect(new re(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 Vi()===null?{state:`none`}:{state:`starting`}}}function Gi(e){return new Promise(t=>setTimeout(t,e))}var Ki=3,qi=4,Ji=240,Yi=16,Xi=8;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Zi(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 Qi(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 $i(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>=qi))break}return n}function ea(e,t,n){if(!z(e))return{};if(typeof e.$ref==`string`){if(t>Xi)return{};let r=Zi(e.$ref,n.defs);return r===void 0?{}:ea(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>Ji?`${t.slice(0,Ji)}…`:t)}let i=Qi(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]=$i(a.map(e=>ea(e,t,n))))}let a=t>=Ki&&z(e.properties);if(z(e.items)&&(r.items=a?{}:ea(e.items,t+1,n)),z(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,Yi),o={};for(let r of a)o[r]=ea(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 ta(e){if(!z(e))return e;let t=ea(e,0,{defs:z(e.$defs)?e.$defs:{}});return z(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function na(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 ra(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=na(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function ia(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 aa(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 oa(e){let t=se(e)[`~standard`],n=ra(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=aa(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${ia(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function sa(e){let t=le(process.execPath,[...process.execArgv,...e??process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});t.unref(),t.on(`error`,e=>{F(`拉起 daemon 失败: ${e.message}`)})}var ca=1500,la=2e4,ua=6e4,da=6e5,fa=5e5,pa=5e3;function ma(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>fa?[`合计 ${(t/1024).toFixed(0)} KB > ${fa/1024} KB`]:[],...e.filter(e=>e.outputBytes>pa).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function ha(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}function ga(e){let t={};for(let n of e??[]){let e=h.string().describe(n.description??``);t[n.name]=n.required===!0?e:e.optional()}return h.object(t)}async function _a(e){let t=e,n=!1,r=null,i=new ie({name:_i,version:L},{supportedProtocolVersions:[`2026-07-28`,..._],...e.getInstructions()?{instructions:e.getInstructions()}:{},cacheHints:{"tools/list":{ttlMs:0,cacheScope:`private`},"prompts/list":{ttlMs:0,cacheScope:`private`},"resources/list":{ttlMs:0,cacheScope:`private`},"resources/templates/list":{ttlMs:0,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}}),a=new Map,o=new Map,s=new Map,c=new Map,l=async e=>{try{return await e(t)}catch(r){if(n||!ha(r))throw r;return P(`shim: 上游请求失败,触发重连后重放`),await m(),e(t)}};async function u(){let{tools:e}=await l(e=>e.listTools()),t=new Set,n=[];for(let r of e){t.add(r.name);let e=r.outputSchema?ta(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:oa(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:se(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 u=i.registerTool.bind(i);try{let e=u(r.name,o,async e=>l(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)}`)}}ma(n);for(let[e,n]of[...a])t.has(e)||(n.handle.remove(),a.delete(e))}async function d(){let{prompts:e}=await l(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=i.registerPrompt(n.name,{title:n.title,description:n.description,argsSchema:ga(n.arguments)},e=>l(t=>t.getPrompt({name:n.name,...e?{arguments:e}:{}})));o.set(n.name,{handle:a,raw:e})}for(let[e,n]of[...o])t.has(e)||(n.handle.remove(),o.delete(e))}async function f(){let[{resources:e},{resourceTemplates:t}]=await Promise.all([l(e=>e.listResources()),l(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=>l(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=c.get(t);if(a&&a.raw===n)continue;a?.handle.remove(),c.delete(t);let o=i.registerResource(e.name,new ae(t,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType},async(e,t)=>l(t=>t.readResource({uri:e.href})));c.set(t,{handle:o,raw:n})}for(let[e,t]of[...c])r.has(e)||(t.handle.remove(),c.delete(e))}let p=async()=>{let e=await Promise.allSettled([u(),d(),f()]);for(let t of e)t.status===`rejected`&&P(`同步清单失败: ${String(t.reason).slice(0,120)}`)},m=()=>r||(r=(async()=>{let e=Date.now()+la,n=null;for(;Date.now()<e;){try{let e=await Wi();if(e.state===`proxy`){t=e.client,h(t),M(`shim: 上游已恢复`),await p();return}e.state===`none`&&sa()}catch(e){n=e}await Gi(ca)}throw n??Error(`上游重连超时(${la}ms)`)})().finally(()=>{r=null}),r),h=e=>{e.onclose=()=>{n||(P(`shim: 上游断开,自动重连`),m().catch(()=>{}))},e.setNotificationHandler(`notifications/tools/list_changed`,async()=>u().catch(()=>{})),e.setNotificationHandler(`notifications/prompts/list_changed`,async()=>d().catch(()=>{})),e.setNotificationHandler(`notifications/resources/list_changed`,async()=>f().catch(()=>{})),e.setNotificationHandler(`notifications/resources/updated`,async e=>{let t=e.params;t?.uri!=null&&await i.server.sendResourceUpdated({uri:t.uri}).catch(()=>{})})};h(t);let ee=ce(async()=>(await p(),i)),g=L,te=null,ne=null,re=async()=>{let e=await Vi();e!=null&&e.version!==g&&(M(`上游版本变化(${g} → ${e.version}),全量重同步目录`),g=e.version,await p())},oe=()=>{n||(te=setTimeout(()=>{n||re().finally(oe)},ua),te.unref())},le=()=>{n||(ne=setTimeout(()=>{n||p().finally(le)},da),ne.unref())};oe(),le(),M(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,te&&clearTimeout(te),ne&&clearTimeout(ne),await ee.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}function va(e=process.env.TEXT_TO_DESIGN_LANG){return Qr(e)??`zh-CN`}function ya(e=va()){return{locale:e,t:Yr(e)}}function B(e){throw Error(e)}var ba=50;async function xa(e){let t=e.trim();t===``&&B(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),u(t)||B(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await he(t).catch(e=>{B(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||B(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>Ei&&B(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(Ei/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await me(t,`utf8`).catch(e=>{B(`读 callsFile「${t}」失败:${e instanceof Error?e.message:String(e)}。`)}),i;try{i=JSON.parse(r)}catch(e){B(`callsFile「${t}」不是合法 JSON:${e instanceof Error?e.message:String(e)}。文件内容应为 {"calls":[…]} 或直接一个数组。`)}let a=Array.isArray(i)?{calls:i}:i;(typeof a!=`object`||!a||Array.isArray(i))&&B(`callsFile「${t}」的顶层既不是数组也不是对象。两种合法形状:直接给步骤数组,或给 {"calls":[…]}。`);let o=a.calls;Array.isArray(o)||B(`callsFile「${t}」里没有 calls 数组(实际类型 ${o===void 0?`undefined`:typeof o})。文件内容应为 {"calls":[…]} 或直接一个数组。`),o.length===0&&B(`callsFile「${t}」的 calls 是空数组,没有步骤可执行。`),o.length>ba&&B(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${ba} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=mt.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);B(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return M(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function Sa(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 Ca(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Sa(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function wa(e,t){m.globalRegistry.add(e,{description:t})}function Ta(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 Ea(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=Sa(i);if(a!=null)for(let e of Ta(a))r(e)};r(e)}function Da(e,t){return Ea(e,e=>{let n=Ca(e);if(n==null)return;let r=t(n);r!==n&&wa(e,r)}),e}function Oa(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function ka(e){return e._def?.typeName}function Aa(e,t){return e._def?.[t]}function ja(e,t){return e._def?.[t]}function V(e){switch(ka(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 ja(e,`value`);case`ZodEnum`:return ja(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=Aa(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=Aa(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=ja(e,`options`)??[],n=t.find(e=>ka(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 Ma={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function Na(e,t,n){let r=Ma[ye(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 Pa(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...Oa(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:[{type:`text`,text:`错误: 结果未通过本工具的输出校验 —— ${i.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).slice(0,8).join(`; `)}\n原始返回:\n${JSON.stringify(e,null,2)}`}],structuredContent:V(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...Oa(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var Fa=new Map;function Ia(e){return Fa.get(e)}function La(){return[...Fa.keys()].sort()}var Ra=8,za=20;function Ba(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function Va(e,t,n){let r=Ba(e);if(r==null||typeof t!=`object`||!t||Array.isArray(t))return n;let i=Object.keys(t),a=new Set(r),o=i.filter(e=>!a.has(e));return o.length===0?n:`字段 [${o.slice(0,Ra).join(`, `)}]${o.length>Ra?` 等 ${o.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${r.length<=za?`该工具接受: [${r.join(`, `)}]。`:`该工具接受 ${r.length} 个字段(完整清单见其 schema),本次收到的 [${i.join(`, `)}] 里只有上述字段越界。`}原始校验: ${n}`}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=(e,t)=>{try{n.notifyActivity(e,t)}catch(e){P(`活动提醒推送失败(已忽略): ${e instanceof Error?e.message:String(e)}`)}},s=async(t,r,i)=>{try{let s=Ii(e);if(s!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`),Na(new v(`platform_unsupported`,s),e.outputSchema,a(e.followUp));if(e.inputSchema!=null){let n=e.inputSchema.safeParse(t);if(!n.success){let r=n.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new v(`invalid_args`,`参数校验失败(${e.name}): ${Va(e.inputSchema,t,r)}`)}t=n.data}let c={...r==null?{}:{signal:r},...e.timeout==null?{}:{timeout:e.timeout}};o(`running`,e.name);let l=i?.skipHooks===!0?void 0:e.hook?.();if(l?.before!=null)try{await l.before(t)}catch(t){P(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let u;u=e.run?await e.run(t,n,r??new AbortController().signal):await n.request(e.method,e.payload?e.payload(t):t,c);let d=e.extraContent?e.extraContent(u,t):[],f=[],p=u?.warnings;if(Array.isArray(p))for(let e of p)typeof e==`string`&&e!==``&&f.push(e);if(l?.after!=null)try{let e=await l.after(t,u)??[];for(let t of e)f.push(t),d.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;f.push(n),d.push({type:`text`,text:n})}let m=Pa(u,e.outputSchema,d.length>0?d:void 0,a(e.followUp));return o(`success`,e.name),f.length>0?{...m,warnings:f}:m}catch(t){let n=t instanceof Error?t.message:String(t);return F(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`),o(`error`,e.name),Na(t,e.outputSchema,a(e.followUp))}};Fa.set(e.name,s);let{t:c}=r,l=i(e.name,{title:c(e.title),description:e.platformNote==null?c(e.description):`${c(e.description)}${c(e.platformNote)}`,...e.inputSchema?{inputSchema:Da(e.inputSchema,c)}:{},outputSchema:Da(e.outputSchema,c),annotations:e.annotations},async(...t)=>{let n=e.inputSchema!=null,r=t[0],i=t[1],a=n?r??{}:{},o=n?i:r,c=o?.mcpReq?.signal??o?.signal;return s(a,c)});return l.alwaysEnabled=e.alwaysEnabled??!1,l}}function Ha(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(Array.isArray(n)&&n.length===1&&(n=n[0]),typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){let t=Number(e[1]);if(!Array.isArray(n)){if(t===0&&typeof n==`object`&&n)continue;return{ok:!1}}n=n[t]}}return{ok:!0,value:n}}var Ua=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}};function Wa(e,t,n){let r=e.indexOf(`.`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r+1);if(!t.has(i)){let r=[...t.keys()].join(`, `)||`无`;throw n.has(i)?new Ua(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=Ha(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var Ga=/^@(comp|var):([\s\S]+)$/;function Ka(e,t,n){let r=t.trim(),i=e===`comp`?`组件/变体集`:`变量`,a=n.filter(e=>e.name===r),o=a.length>0?a:n.filter(e=>e.name.trim().toLowerCase()===r.toLowerCase());if(o.length===1)return o[0].id;if(o.length>1)throw Error(`按名字取${i}「${t}」撞上 ${o.length} 个同名资源:${o.map(e=>`${e.name}(${e.id})`).join(`、`)}。名字不唯一时改用 id 直接写,或先重命名(0041:不确定就点名,绝不猜)。`);let s=n.slice(0,30).map(e=>e.name);throw Error(`按名字取${i}「${t}」没命中。${s.length===0?`这一面当前读不到任何${i}(两种原因都可能:本平台未声明该能力面,或本平台读不到非当前页 —— 到底哪种见 jsd_get_page 回包的 note)`:`现有${i}:${s.join(`、`)}${n.length>s.length?` …`:``}`};也可以直接写 id。`)}async function qa(e,t,n){let r=await n();return Ka(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var Ja=/\{\{\s*([^{}]+?)\s*\}\}/g,Ya=/^\{\{\s*([^{}]+?)\s*\}\}$/,Xa=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],Za=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),Qa=2e4;function $a(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var eo=[`x`,`y`,`width`,`height`,`parentId`];function to(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:eo.some(t=>e[t]!==void 0)}function no(e){if(Array.isArray(e))return e.map(no);if(typeof e!=`object`||!e)return e;let t=e;if(to(t)){let e={};for(let n of Xa)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))Za.has(e)||(n[e]=no(r));return n}function ro(e,t){if(Array.isArray(e)){for(let n of e)ro(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}ro(r,t)}}function io(e,t){let n=no(e),r=$a(n);if(r<=Qa)return{data:n,trimmed:r!==$a(e),omitted:!1};let i=[];return ro(n,i),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${r} 字符,已省略明细;需要细节请把 ${t} 单独调用一次`,ids:[...new Set(i)]},trimmed:!0,omitted:!0}}function ao(e,t,n){let r=[`回显已裁剪:${e.length} 步(${e.join(` / `)})的节点只保留 id/name/type/x/y/width/height/z/parentId`,` —— 子节点、characters、fills、*StyleId、vectorPaths 等字段不在回显里。`,`要读这些字段,请把对应工具**单独调用一次**;批内回显不是验收证据。`,"占位符 `{{步骤id.…}}` 不受影响,它取的是裁剪前的完整数据。"];return t.length>0&&r.push(n==null?`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,已降级为 id 清单,步骤内的 note 已点名工具名。`:`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,完整明细已落盘到 ${n.path}(${n.bytes} 字节,JSONL 一行一步),按各步 data 里的 line 读即可。`),r.join(``)}var oo=0;function so(e,t){let n=[],r=new Map;for(let i of e)r.set(i.id,n.length+1),n.push(JSON.stringify(i.ok?{id:i.id,tool:i.tool,ok:!0,data:t.get(i.id)}:{id:i.id,tool:i.tool,ok:!1,error:i.error}));let i=`${n.join(`
|
|
38
|
-
`)}\n`,a=Buffer.byteLength(i,`utf8`);if(a>
|
|
37
|
+
Result keys per op (needed to write correct jsd_batch placeholders; a wrong key aborts the batch): select -> selected[and remove -> removed[are id strings; clone/outline_stroke -> created[is an array of nodes; group/flatten -> created is a single node object; ungroup -> ungrouped[is id strings; reparent -> moved[(updated[mirrors it); repair -> cleaned[is id strings.`,"createBooleanOperation.description":`Create a single BOOLEAN_OPERATION node: the booleanOperation mode ({ops}) and children (at least 2 merged child nodes) are required. Only one root boolean node. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"setFillColor.description":`Set fill color/gradient (fills is a Paint array, replaced wholesale rather than merged — pass existing fills you want to keep), blend mode and team-library fill styles. {warn}`,"setText.description":`Modify text (TEXT nodes only): **content and typography** characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, **colour** fills/fillStyleId/blendMode, **size** width/height (pair with textAutoResize), plus Figma truncation and max lines; position x/y is not here — use jsd_move_node / jsd_resize_node. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content — for such text, setting characters again reflows it (measured: a fixed-width-200 text whose height read back 15 re-read 82). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`,"header.more":`More settings`,"menu.telemetry":`Error reporting`,"menu.cameraLock":`Camera lock`,"menu.theme":`Theme`,"menu.locale":`Language`,"telemetry.title":`Error reporting`,"telemetry.body":`To keep improving the product, enabling this records plugin and service errors.`,"telemetry.item.error":`Error messages and stacks`,"telemetry.item.identity":`Anonymous install ID (no document content or personal data)`,"telemetry.item.version":`Plugin and service versions`,"telemetry.state.on":`On`,"telemetry.state.off":`Off`,"telemetry.enable":`Enable reporting`,"telemetry.decline":`Not now`,"telemetry.disable":`Disable reporting`}},Qr=/\{(\w+)\}/g;function $r(e){let t=Zr[e]??Zr.en,n=Zr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Qr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var ei=/^zh([-_]|$)/i,ti=/^en([-_]|$)/i;function ni(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(ei.test(t))return`zh-CN`;if(ti.test(t))return`en`}}var ri={debug:0,info:1,warn:2,error:3},ii={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},E=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,D=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,O=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,ai={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:"两条路,都不是变量那种玩法:① **本地样式** —— `jsd_create_style` 从一个既有节点抄出样式(本平台四类:PAINT / TEXT / EFFECT / GRID;契约的类别是三家 `StyleType` 的八项并集,余下四类本平台没有工厂,传过去会被写前点名拒),回 id;绑上去用 jsd_set_fill_color 的 fillStyleId / jsd_set_text 的 textStyleId / jsd_set_effects 的 effectStyleId / jsd_set_stroke 的 strokeStyleId。**⚠ 本平台未声明 `styleEnumeration`,样式清单(`jsd://styles` / `assets.styles`)恒空、列不出来**:已有样式的 id 只能从正用着它的节点上读(`*StyleId` 字段),新建的 id 从 `jsd_create_style` 回包记账(建重复了用 `jsd_delete_style` 删)。一条样式改一次,全档跟随。② **结构继承** —— 抽成 COMPONENT 后改主件,实例自动继承(批量套覆盖走 variant-sync 配方)。",evidence:[`${E}(全文无 variable 声明:grep -in variable 零命中)`,`packages/ui/src/code/jsdesign/meta.ts capabilities=[styles](按 id 应用样式是有的;**不声明 styleEnumeration** —— 列不出样式,见 0043)`,`packages/shared/src/core/access.ts:174(listStylesAsync 在未声明 styleEnumeration 时直接返回空,四个 getter 一次都不调)`,"packages/ui/src/code/jsdesign/host.ts:48(createStyle 已接:`jsd_create_style` 走 jsDesign.createPaintStyle 等四工厂;四类样式的共同契约在 packages/shared/src/core/styles.ts)",`${E}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${E}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 团队库「组件集」导入入口,本仓只接了组件那半(:110);拿到集合节点是目前唯一的非画布来源`,`Page.createNodeFromJSXAsync(:119) —— JSX 建节点,是否支持组件/集合标签未验(typings 无声明,只有 any)`],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${E}:1093 setProperties 只收 string`,`${E}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:367-393 setProperties 签名只收字符串;真机 2026-10-14 的运行期行为:给**没有变体属性**的 INSTANCE 调它不是点名报错,而是挂到转发超时(25s)—— 没有变体集时别拿它当切状态的通道`,"packages/shared/src/core/component.ts setInstanceProperties 的属性面守卫 —— 2026-10-19 真机复现同一条(未知属性名 `Foo` → 25077ms 后失败、错误只有「插件响应超时」):能力位不含 componentProperties 且变体表 / variantProperties 都拿不到键时,写前点名拒,不再落到引擎空转","packages/shared/src/core/access.ts resolveMainComponent 的选路 —— 2026-10-19 真机隔离:typings 未声明的 `getMainComponentAsync` 在即时设计运行时**存在且永不 settle**(与 `*Async` 样式枚举同一模式),`?.` 探测让 `jsd_copy_overrides`(只读快照、不写属性)挂到 25109ms;改由 `mainComponentSync` 声明只问同步 `mainComponent`","packages/ui/src/code/jsdesign/ops.ts jsd_component_facts —— 2026-10-20 三页官方文档核对(js.design/developer-doc/plugin/api/node/{ComponentNode,InstanceNode,ComponentSetNode}):**成员与 typings 1.0.12 逐字一致,没有多出来的 API**;文档确认而契约缺的字段(ComponentNode.instances / key / remote / description / expanded / getPublishStatusAsync、InstanceNode.scaleFactor、ComponentSetNode.defaultVariant / variantGroupProperties / children)由本 op 透出。`getPublishStatusAsync` 单独可选:同族 async 成员有永不 settle 的先例(dec e1e66f0a)",`packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 真机(2026-10-20,重载后):COMPONENT 的 instances 可读且准确(建组件+2 实例 → instanceCount 2 / instanceIds 两条)、key 是空串、remote=false;description **可写**且回读一致(PublishableMixin :838);getPublishStatusAsync **21ms 返回、不永挂**(与 getMainComponentAsync 不同),但对非团队库节点回的是**错误串** "Failed to get node publish status" 而不是 PublishStatus 三值 ⇒ op 里三值才认,其余落 publishStatusError`,'packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 的 INSTANCE 分支 + core/assets.ts readVariantProperties —— 真机 2026-10-20 两条:① `variantGroupProperties.values` 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"}]),撞穿 assets.variants.properties 的 string[] 校验使 `get_page` **整条失败**,故 projection 与 op 都按名字归一;② 对真实变体实例调 setProperties **11~15ms 就抛** `in setProperties: i.setProperties is not a function`(typings :1093 与文档都声明了它)⇒ 符号是否真在由 op 的 `setPropertiesAvailable` 回报复核',"packages/ui/src/code/jsdesign/host.ts combineAsVariants 的显式绑定 —— 官方 API 参考页(js.design/developer-doc/plugin/api/reference/jsDesign)确认语义「将任意数量的组件合并为变体」、签名 (nodes, parent, index?);真机 2026-10-20 逐项排除:receiver 绑回全局后报错逐字相同、组件名改成 `状态=默认/禁用` 仍败、带子层仍败、先 reparent 进 FRAME 仍败 ⇒ **引擎实现缺陷,不是调用方式**",`packages/shared/src/core/component.ts combineAsVariantsNodes 的姿势顺序 —— 真机 2026-10-20:合并失败会**毁入参组件**(用户组件 13:100 变损坏节点、repair 直接删),故「原位合并」只在平台声明 inPlaceVariants 时才尝试(Figma 声明、顺序不变);jsDesign 只跑两条克隆姿势,失败也不伤原组件`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**单姿势隔离实验** —— 真机 2026-10-20(即时设计,干净画布,只跑原位姿势,传入真 COMPONENT、类型完全合规):仍抛 in get_booleanOperation: Value is not a string;后果是入参组件 13:332 被就地改成 BOOLEAN_OPERATION、13:333 幸存 ⇒ 坐实引擎实现缺陷,并排除两个替代解释:①「clone 返回 INSTANCE 导致参数类型不符才是根因」(原位传合规类型照样崩);②「被克隆两式弄脏画布才连带失败」(干净画布单跑照样崩)`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**裸调实验** —— 真机 2026-10-20(即时设计,画板 3 下 4 个真 COMPONENT,取消 core 的姿势选择 / clone 类型校验 / 父容器校验 / 跨父级校验 / 返回类型校验,直接 host.combineAsVariants(components, parent)):引擎**成功返回一个 type=BOOLEAN_OPERATION 的节点**(id 13:446),读它的 name 抛 in get_name: Value is not a string;四个原 COMPONENT **被搬进该布尔节点下**(parentId=13:446),画板 3 随即变空 ⇒ 坐实「引擎把合并路由成布尔运算」,并排除「core 的某个前置判断改变了入参」这一解释(裸调无任何判断,行为一致)。事后可用 jsd_reparent_nodes 把组件搬回原容器,损坏节点由 repair 清`,"packages/shared/src/core/access.ts resolveNodes 的返回身份 —— 真机 2026-10-20(即时设计,只读探针,未执行合并):四个 COMPONENT 逐个比对 `=== jsDesign.getNodeById(id)`,**全部 true**(即返回的是原生对象本身,不是包装或代理);成员核验 nodes 各有 createInstance(ComponentNode 独有)、无 setProperties(那是 InstanceNode 的),parent 有 children/appendChild/insertChild 且无 createInstance、且不等于 currentPage ⇒ 入参**完全满足** combineAsVariants(nodes: ReadonlyArray<ComponentNode>, parent: BaseNode & ChildrenMixin) 的签名。故「参数类型不满足」这一解释被排除:类型层面的 `as never` 只是掩盖了静态证明,运行时要传的对象是对的",`packages/shared/src/core/component.ts / jsd_reparent_nodes —— 真机 2026-10-20:RECTANGLE 可 reparent 进 COMPONENT(文档 ComponentNode 继承 BaseFrameMixin → appendChild :711),childCount 0→1,且**两个实例的 childCount 同步变 1**(主件加子层实时传播)`,`packages/shared/src/core/component.ts setInstanceProperties / swapComponents / detachInstanceNodes + packages/shared/src/core/nodes.ts cloneNodes + packages/shared/src/core/variant.ts —— 真机 2026-10-20(即时设计,逐条隔离):① **变体集成员**上 createInstance 必抛 in createInstance: The node with id undefined does not exist(集合内 8 个成员全复现;独立 COMPONENT 正常),clone() 返回 undefined;② swapComponent 必抛 in swapComponent: Cannot read properties of undefined (reading type)(独立组件之间 / 成员之间 / 克隆实例上全复现);③ detachInstance **原位返回同一个 INSTANCE**(type 仍 INSTANCE、mainComponentId 照旧)⇒ 静默 no-op;④ 集合维度键 状态 与成员键 分类1 **不是同一套**,只按集合键校验会把合法的成员键写入拒掉`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 未接;这是「不经画布拿到集合节点」的唯一路径`,`ComponentSetNode.appendChild / insertChild(:711-712,继承自 BaseFrameMixin)—— 类型上能追加成员,但没有创建入口 ⇒ 拿不到集合节点,这一面实际不可达`],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me);实例侧切值本平台运行期无入口(setProperties 不是函数、swapComponent 抛内部错误,真机 2026-10-20),变体取值只能在画布上手工切换`,evidence:[`${E}:899-900 VariantMixin.variantProperties(readonly)`,`${E}:1074-1079 ComponentSetNode 自身只多 clone / defaultVariant / variantGroupProperties;但 :1074 继承 BaseFrameMixin(:851)→ 带 appendChild / insertChild(:711-712)`,`packages/shared/src/core/variant.ts + core/serialize.ts + core/assets.ts —— 真机 2026-10-20:variantGroupProperties.values 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"},{"name":"禁用"}]),不归一会撞穿线格式 string[] 并让 get_page / jsd_find **整条失败**(不是少字段,是这次只读调用报废);variantProperties 同理。归一实现单点(两个投影点共用),serializeNode 另加一层「getter 抛也省略该字段」的保护`,"packages/ui/src/code/jsdesign/host.ts / core/component.ts combineAsVariants 兜底 —— 真机 2026-10-19 复核(即时设计,重载后):72ms 抛「三种姿势均失败…in get_booleanOperation: Value is not a string」**与 09-24/10-14 逐字一致**;残留形态这次是 **3 个 BOOLEAN_OPERATION(原 COMPONENT 被就地改成 BOOLEAN_OPERATION、id 保留)+ 1 个幸存 COMPONENT,没有 COMPONENT_SET**(10-14 那次是留下畸形 COMPONENT_SET),`assets.variants` 回到 0 ⇒ 残留形态不稳定,清理一律走 `jsd_manage_nodes op=repair`(实测 `cleaned: 3 个`)",`${E}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${D}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${D}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${D}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${D}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${D}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${D}:11127 readonly componentProperties`,`${D}:11123 setProperties(string | boolean | VariableAlias)`,`${D}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${D}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${D}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${D}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${D}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${D}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${D}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${D}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${O}:1522 readonly variables: VariableAPI`,`${O}:1098-1108 VariableAPI(Collection / Mode)`,`${O}:1176 getVariables() / :1874 Variable{id,name,…}`,`${O}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${O}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${O}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/ops.ts removeVariables 的三档 —— 真机 2026-10-19(重载后两轮):单值变量的 deleteVariable **跨执行才生效**(同执行内删两遍 + 回读仍全失败,下一次调用立刻 removed),故同执行回读判失败会把成功报成失败(10-15 那 5 条 failed 即此形态);复合样式变量(PAINT)的 deleteVariable 是 **no-op**(跨多次执行仍在:列表 / assets.variables / 拿它绑图层三面都证明它还活着,同 id 走 jsd_delete_style 一次删掉)`,`packages/ui/src/code/mastergo/ops.ts createVariables 的 values —— 真机 2026-10-19:setVariableValue 的返回 modes **时有时无**(同批里有的带 bool / floatData,有的只有 {modeId},默认双模式集合回空对象);STRING 变量在列表 / 按 id / 写返回三个读面都只有 {modeId} ⇒ 值不可验证,values 只原样透传不作判据`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${O}:3096 readonly componentProperties: Array<ComponentProperties>`,`${O}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${O}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${O}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${O}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${O}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${O}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${O}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${O}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function k(e,t){return e==null?null:ai[e][t]}var oi={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},si=`https://registry.npmjs.org`;function ci(e){return`${si}/${e}/latest`}var li=4e3;function ui(e){let t=e;return t!=null&&t.type===`ui_version`&&typeof t.version==`string`}var A=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function di(e){return e instanceof A?e.code:`plugin_error`}var fi=process.env.TEXT_TO_DESIGN_MCP_LOG??p(u(),`text-to-design-mcp.log`),pi=ri,mi=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,hi=null;function gi(e){hi=e}function _i(e,t){if(pi[e]>=pi[mi])try{r(fi,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${t}\n`)}catch{}try{hi?.(e,t)}catch{}}function j(e){_i(`info`,e)}function M(e){_i(`debug`,e)}function N(e){_i(`warn`,e)}function P(e){_i(`error`,e)}var vi=we,yi=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??vi,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(new A(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new A(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(clearTimeout(l.timer),this.detachAbort(l),j(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new A(`cancelled`,`请求已取消: ${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?.code??``}`}`;t.ok?j(r):P(r),t.ok?n.resolve(t.data):n.reject(t.error?new A(t.error.code,t.error.message):new A(`plugin_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(new A(`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(bi(e.data,e.buffers))}};function bi(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 xi=`0.13.5`,Si=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),F=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),Ci=`text-to-design-mcp-server`,I=xi,wi=Date.now(),Ti=15e3,Ei=6e3,Di=5e3,Oi=6e4,ki=3e5,Ai=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),ji=12e4,Mi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),Ni=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_BATCH_SPILL_BYTES??33554432),Pi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),Fi={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},L=null,Ii=null,Li=null;function Ri(){return L}function zi(e){Ii=e}function Bi(){return Ii}function Vi(){let e=L?.platform;if(e==null)return{label:Fi.label,runtime:Fi.runtime};let t=Yt[e];return{label:`${t}客户端`,runtime:t}}function Hi(e){(L!=null||Ii!=null)&&(L=null,Ii=null,M(`平台状态已清空(${e})`))}function Ui(e){return Li??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:Di});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(`平台状态已缓存: ${Yt[L.platform]}(平台差异能力 ${L.capabilities.length} 项 / 特有操作 ${L.platformOps.length} 个)`)}catch(e){M(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{Li=null}})(),Li}function Wi(e){if(e.platforms==null)return!0;let t=L?.platform;return t==null?null:e.platforms.includes(t)}function Gi(e){if(Wi(e)!==!1)return null;let t=L?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>Yt[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${Yt[t]},已拒绝执行(未向插件发起请求)。`,e.platformNote==null?``:`${e.platformNote}`,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Ki(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var qi=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=ee(),this.wss=new te({server:this.http}),this.wss.on(`error`,e=>{N(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),Se),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===g.OPEN}send(e){this.client&&this.client.readyState===g.OPEN?(this.client.send(e),M(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):N(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===g.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(Ce,`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} (${Ki(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===g.OPEN&&(this.sendStatus(e,`ready`),M(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==g.OPEN)return;let n={type:`status`,state:t,version:xi};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)})}},Ji=200,Yi=class{transport=new qi;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;onConsentSet=null;constructor(){this.pending=new yi((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{if(t){this.pending.onBinary(e);return}try{let t=JSON.parse(e.toString());if(Te(t)){this.onConsentSet?.(t.granted);return}if(ui(t)){zi(t.version);return}}catch{}this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),this.onPluginConnect?.(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(N(`请求被拒(插件未连接): ${e}`),Promise.reject(new A(`not_connected`,`${Vi().runtime} 插件未连接。请先在${Vi().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=Ji&&this.logRing.shift(),this.logRing.push(n);return}this.sendLogPush(n)}pushVersion(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`版本推送失败: ${e instanceof Error?e.message:String(e)}`)}}notifyActivity(e,t){if(!this.transport.isConnected)return;let n=t==null?{type:`activity`,phase:e}:{type:`activity`,phase:e,tool:t};try{this.transport.sendPush(JSON.stringify(n))}catch(e){N(`活动推送失败: ${e instanceof Error?e.message:String(e)}`)}}pushConsent(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`同意状态推送失败: ${e instanceof Error?e.message:String(e)}`)}}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 Xi(){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 Zi=!1;async function Qi(){if(Zi)return;Zi=!0;let e=process.argv[1];if(!e)return;let t;try{t=s(e).mtimeMs}catch{return}let n=await Xi();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 $i(){let e=await Xi();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()+Ei;for(;Date.now()<t&&(await ea(250),await Xi()!==null););return await Xi()===null?{state:`none`}:(j(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new ne({name:`text-to-design-proxy`,version:I},{versionNegotiation:{mode:`auto`}});try{await t.connect(new re(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 Xi()===null?{state:`none`}:{state:`starting`}}}function ea(e){return new Promise(t=>setTimeout(t,e))}var ta=3,na=4,ra=240,ia=16,aa=8;function R(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oa(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(!R(n))return;n=n[e]}return n}function sa(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 ca(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>=na))break}return n}function la(e,t,n){if(!R(e))return{};if(typeof e.$ref==`string`){if(t>aa)return{};let r=oa(e.$ref,n.defs);return r===void 0?{}:la(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>ra?`${t.slice(0,ra)}…`:t)}let i=sa(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]=ca(a.map(e=>la(e,t,n))))}let a=t>=ta&&R(e.properties);if(R(e.items)&&(r.items=a?{}:la(e.items,t+1,n)),R(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,ia),o={};for(let r of a)o[r]=la(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`||R(r.properties)||R(e.items)&&r.type!==`array`)&&(r.additionalProperties=!0),r}function ua(e){if(!R(e))return e;let t=la(e,0,{defs:R(e.$defs)?e.$defs:{}});return R(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function da(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 fa(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=da(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function pa(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 ma(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 ha(e){let t=se(e)[`~standard`],n=fa(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=ma(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${pa(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function ga(e){let t=le(process.execPath,[...process.execArgv,...e??process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});t.unref(),t.on(`error`,e=>{P(`拉起 daemon 失败: ${e.message}`)})}var _a=1500,va=2e4,ya=6e4,ba=6e5,xa=5e5,Sa=5e3;function Ca(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>xa?[`合计 ${(t/1024).toFixed(0)} KB > ${xa/1024} KB`]:[],...e.filter(e=>e.outputBytes>Sa).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&N(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function wa(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}function Ta(e){let t={};for(let r of e??[]){let e=n.string().describe(r.description??``);t[r.name]=r.required===!0?e:e.optional()}return n.object(t)}async function Ea(e){let t=e,n=!1,r=null,i=new ie({name:Ci,version:I},{supportedProtocolVersions:[`2026-07-28`,..._],...e.getInstructions()?{instructions:e.getInstructions()}:{},cacheHints:{"tools/list":{ttlMs:0,cacheScope:`private`},"prompts/list":{ttlMs:0,cacheScope:`private`},"resources/list":{ttlMs:0,cacheScope:`private`},"resources/templates/list":{ttlMs:0,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}}),a=new Map,o=new Map,s=new Map,c=new Map,l=async e=>{try{return await e(t)}catch(r){if(n||!wa(r))throw r;return N(`shim: 上游请求失败,触发重连后重放`),await m(),e(t)}};async function u(){let{tools:e}=await l(e=>e.listTools()),t=new Set,n=[];for(let r of e){t.add(r.name);let e=r.outputSchema?ua(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:ha(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:se(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 u=i.registerTool.bind(i);try{let e=u(r.name,o,async e=>l(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)}`)}}Ca(n);for(let[e,n]of[...a])t.has(e)||(n.handle.remove(),a.delete(e))}async function d(){let{prompts:e}=await l(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=i.registerPrompt(n.name,{title:n.title,description:n.description,argsSchema:Ta(n.arguments)},e=>l(t=>t.getPrompt({name:n.name,...e?{arguments:e}:{}})));o.set(n.name,{handle:a,raw:e})}for(let[e,n]of[...o])t.has(e)||(n.handle.remove(),o.delete(e))}async function f(){let[{resources:e},{resourceTemplates:t}]=await Promise.all([l(e=>e.listResources()),l(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=>l(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=c.get(t);if(a&&a.raw===n)continue;a?.handle.remove(),c.delete(t);let o=i.registerResource(e.name,new ae(t,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType},async(e,t)=>l(t=>t.readResource({uri:e.href})));c.set(t,{handle:o,raw:n})}for(let[e,t]of[...c])r.has(e)||(t.handle.remove(),c.delete(e))}let p=async()=>{let e=await Promise.allSettled([u(),d(),f()]);for(let t of e)t.status===`rejected`&&N(`同步清单失败: ${String(t.reason).slice(0,120)}`)},m=()=>r||(r=(async()=>{let e=Date.now()+va,n=null;for(;Date.now()<e;){try{let e=await $i();if(e.state===`proxy`){t=e.client,h(t),j(`shim: 上游已恢复`),await p();return}e.state===`none`&&ga()}catch(e){n=e}await ea(_a)}throw n??Error(`上游重连超时(${va}ms)`)})().finally(()=>{r=null}),r),h=e=>{e.onclose=()=>{n||(N(`shim: 上游断开,自动重连`),m().catch(()=>{}))},e.setNotificationHandler(`notifications/tools/list_changed`,async()=>u().catch(()=>{})),e.setNotificationHandler(`notifications/prompts/list_changed`,async()=>d().catch(()=>{})),e.setNotificationHandler(`notifications/resources/list_changed`,async()=>f().catch(()=>{})),e.setNotificationHandler(`notifications/resources/updated`,async e=>{let t=e.params;t?.uri!=null&&await i.server.sendResourceUpdated({uri:t.uri}).catch(()=>{})})};h(t);let ee=ce(async()=>(await p(),i)),g=I,te=null,ne=null,re=async()=>{let e=await Xi();e!=null&&e.version!==g&&(j(`上游版本变化(${g} → ${e.version}),全量重同步目录`),g=e.version,await p())},oe=()=>{n||(te=setTimeout(()=>{n||re().finally(oe)},ya),te.unref())},le=()=>{n||(ne=setTimeout(()=>{n||p().finally(le)},ba),ne.unref())};oe(),le(),j(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,te&&clearTimeout(te),ne&&clearTimeout(ne),await ee.close().catch(e=>{N(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}var Da=p(l(),`.text-to-design`),Oa=p(Da,`consent.json`),ka=!1,Aa=!1;async function ja(){try{let e=JSON.parse(await he(Oa,`utf8`));ka=e?.granted===!0,Aa=e?.asked===!0}catch{ka=!1,Aa=!1}}function Ma(){return ka}function Na(){return Aa}async function Pa(e){ka=e,Aa=!0;try{await me(Da,{recursive:!0}),await _e(Oa,`${JSON.stringify({granted:e,asked:Aa,updatedAt:new Date().toISOString()},null,2)}\n`,`utf8`)}catch(e){N(`同意状态写盘失败: ${e instanceof Error?e.message:String(e)}`)}}function Fa(e=process.env.TEXT_TO_DESIGN_LANG){return ni(e)??`zh-CN`}function Ia(e=Fa()){return{locale:e,t:$r(e)}}function z(e){throw Error(e)}var La=50;async function Ra(e){let t=e.trim();t===``&&z(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),f(t)||z(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await ge(t).catch(e=>{z(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||z(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>Mi&&z(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(Mi/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await he(t,`utf8`).catch(e=>{z(`读 callsFile「${t}」失败:${e instanceof Error?e.message:String(e)}。`)}),i;try{i=JSON.parse(r)}catch(e){z(`callsFile「${t}」不是合法 JSON:${e instanceof Error?e.message:String(e)}。文件内容应为 {"calls":[…]} 或直接一个数组。`)}let a=Array.isArray(i)?{calls:i}:i;(typeof a!=`object`||!a||Array.isArray(i))&&z(`callsFile「${t}」的顶层既不是数组也不是对象。两种合法形状:直接给步骤数组,或给 {"calls":[…]}。`);let o=a.calls;Array.isArray(o)||z(`callsFile「${t}」里没有 calls 数组(实际类型 ${o===void 0?`undefined`:typeof o})。文件内容应为 {"calls":[…]} 或直接一个数组。`),o.length===0&&z(`callsFile「${t}」的 calls 是空数组,没有步骤可执行。`),o.length>La&&z(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${La} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=_t.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);z(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return j(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function za(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 Ba(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=za(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function Va(e,n){t.globalRegistry.add(e,{description:n})}function Ha(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 Ua(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=za(i);if(a!=null)for(let e of Ha(a))r(e)};r(e)}function Wa(e,t){return Ua(e,e=>{let n=Ba(e);if(n==null)return;let r=t(n);r!==n&&Va(e,r)}),e}function Ga(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function Ka(e){return e._def?.typeName}function qa(e,t){return e._def?.[t]}function Ja(e,t){return e._def?.[t]}function B(e){switch(Ka(e)){case`ZodObject`:{let t=e.shape;if(typeof t!=`function`)return;let n={};for(let[e,r]of Object.entries(t()))n[e]=B(r);return n}case`ZodArray`:return[];case`ZodBoolean`:return!1;case`ZodNumber`:return 0;case`ZodString`:return``;case`ZodLiteral`:return Ja(e,`value`);case`ZodEnum`:return Ja(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=qa(e,`innerType`);return t?B(t):void 0}case`ZodEffects`:{let t=qa(e,`schema`);return t?B(t):void 0}case`ZodUnion`:{let t=Ja(e,`options`)??[],n=t.find(e=>Ka(e)===`ZodArray`);return n?B(n):t[0]?B(t[0]):void 0}case`ZodLazy`:{let t=e._def?.getter;return t?B(t()):void 0}default:return}}var Ya={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function Xa(e,t,n){let r=Ya[di(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:B(t)}:i}function Za(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...Ga(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:[{type:`text`,text:`错误: 结果未通过本工具的输出校验 —— ${i.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).slice(0,8).join(`; `)}\n原始返回:\n${JSON.stringify(e,null,2)}`}],structuredContent:B(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...Ga(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var Qa=new Map;function $a(e){return Qa.get(e)}function eo(){return[...Qa.keys()].sort()}var to=8,no=20;function ro(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function io(e,t,n){let r=ro(e);if(r==null||typeof t!=`object`||!t||Array.isArray(t))return n;let i=Object.keys(t),a=new Set(r),o=i.filter(e=>!a.has(e));return o.length===0?n:`字段 [${o.slice(0,to).join(`, `)}]${o.length>to?` 等 ${o.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${r.length<=no?`该工具接受: [${r.join(`, `)}]。`:`该工具接受 ${r.length} 个字段(完整清单见其 schema),本次收到的 [${i.join(`, `)}] 里只有上述字段越界。`}原始校验: ${n}`}function V(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=(e,t)=>{try{n.notifyActivity(e,t)}catch(e){N(`活动提醒推送失败(已忽略): ${e instanceof Error?e.message:String(e)}`)}},s=async(t,r,i)=>{try{let s=Gi(e);if(s!=null)return P(`工具 ${e.name} 在当前平台不可用,已拦截`),Xa(new A(`platform_unsupported`,s),e.outputSchema,a(e.followUp));if(e.inputSchema!=null){let n=e.inputSchema.safeParse(t);if(!n.success){let r=n.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new A(`invalid_args`,`参数校验失败(${e.name}): ${io(e.inputSchema,t,r)}`)}t=n.data}let c={...r==null?{}:{signal:r},...e.timeout==null?{}:{timeout:e.timeout}};o(`running`,e.name);let l=i?.skipHooks===!0?void 0:e.hook?.();if(l?.before!=null)try{await l.before(t)}catch(t){N(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let u;u=e.run?await e.run(t,n,r??new AbortController().signal):await n.request(e.method,e.payload?e.payload(t):t,c);let d=e.extraContent?e.extraContent(u,t):[],f=[],p=u?.warnings;if(Array.isArray(p))for(let e of p)typeof e==`string`&&e!==``&&f.push(e);if(l?.after!=null)try{let e=await l.after(t,u)??[];for(let t of e)f.push(t),d.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;f.push(n),d.push({type:`text`,text:n})}let m=Za(u,e.outputSchema,d.length>0?d:void 0,a(e.followUp));return o(`success`,e.name),f.length>0?{...m,warnings:f}:m}catch(t){let n=t instanceof Error?t.message:String(t);return P(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`),o(`error`,e.name),Xa(t,e.outputSchema,a(e.followUp))}};Qa.set(e.name,s);let{t:c}=r,l=i(e.name,{title:c(e.title),description:e.platformNote==null?c(e.description):`${c(e.description)}${c(e.platformNote)}`,...e.inputSchema?{inputSchema:Wa(e.inputSchema,c)}:{},outputSchema:Wa(e.outputSchema,c),annotations:e.annotations},async(...t)=>{let n=e.inputSchema!=null,r=t[0],i=t[1],a=n?r??{}:{},o=n?i:r,c=o?.mcpReq?.signal??o?.signal;return s(a,c)});return l.alwaysEnabled=e.alwaysEnabled??!1,l}}function ao(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(Array.isArray(n)&&n.length===1&&(n=n[0]),typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){let t=Number(e[1]);if(!Array.isArray(n)){if(t===0&&typeof n==`object`&&n)continue;return{ok:!1}}n=n[t]}}return{ok:!0,value:n}}var oo=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}};function so(e,t,n){let r=e.indexOf(`.`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r+1);if(!t.has(i)){let r=[...t.keys()].join(`, `)||`无`;throw n.has(i)?new oo(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=ao(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var co=/^@(comp|var):([\s\S]+)$/;function lo(e,t,n){let r=t.trim(),i=e===`comp`?`组件/变体集`:`变量`,a=n.filter(e=>e.name===r),o=a.length>0?a:n.filter(e=>e.name.trim().toLowerCase()===r.toLowerCase());if(o.length===1)return o[0].id;if(o.length>1)throw Error(`按名字取${i}「${t}」撞上 ${o.length} 个同名资源:${o.map(e=>`${e.name}(${e.id})`).join(`、`)}。名字不唯一时改用 id 直接写,或先重命名(0041:不确定就点名,绝不猜)。`);let s=n.slice(0,30).map(e=>e.name);throw Error(`按名字取${i}「${t}」没命中。${s.length===0?`这一面当前读不到任何${i}(两种原因都可能:本平台未声明该能力面,或本平台读不到非当前页 —— 到底哪种见 jsd_get_page 回包的 note)`:`现有${i}:${s.join(`、`)}${n.length>s.length?` …`:``}`};也可以直接写 id。`)}async function uo(e,t,n){let r=await n();return lo(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var fo=/\{\{\s*([^{}]+?)\s*\}\}/g,po=/^\{\{\s*([^{}]+?)\s*\}\}$/,mo=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],ho=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),go=2e4;function _o(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var vo=[`x`,`y`,`width`,`height`,`parentId`];function yo(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:vo.some(t=>e[t]!==void 0)}function bo(e){if(Array.isArray(e))return e.map(bo);if(typeof e!=`object`||!e)return e;let t=e;if(yo(t)){let e={};for(let n of mo)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))ho.has(e)||(n[e]=bo(r));return n}function xo(e,t){if(Array.isArray(e)){for(let n of e)xo(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}xo(r,t)}}function So(e,t){let n=bo(e),r=_o(n);if(r<=go)return{data:n,trimmed:r!==_o(e),omitted:!1};let i=[];return xo(n,i),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${r} 字符,已省略明细;需要细节请把 ${t} 单独调用一次`,ids:[...new Set(i)]},trimmed:!0,omitted:!0}}function Co(e,t,n){let r=[`回显已裁剪:${e.length} 步(${e.join(` / `)})的节点只保留 id/name/type/x/y/width/height/z/parentId`,` —— 子节点、characters、fills、*StyleId、vectorPaths 等字段不在回显里。`,`要读这些字段,请把对应工具**单独调用一次**;批内回显不是验收证据。`,"占位符 `{{步骤id.…}}` 不受影响,它取的是裁剪前的完整数据。"];return t.length>0&&r.push(n==null?`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,已降级为 id 清单,步骤内的 note 已点名工具名。`:`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,完整明细已落盘到 ${n.path}(${n.bytes} 字节,JSONL 一行一步),按各步 data 里的 line 读即可。`),r.join(``)}var wo=0;function To(e,t){let n=[],r=new Map;for(let i of e)r.set(i.id,n.length+1),n.push(JSON.stringify(i.ok?{id:i.id,tool:i.tool,ok:!0,data:t.get(i.id)}:{id:i.id,tool:i.tool,ok:!1,error:i.error}));let i=`${n.join(`
|
|
38
|
+
`)}\n`,a=Buffer.byteLength(i,`utf8`);if(a>Ni)return{error:`明细 ${a} 字节 > 上限 ${Ni} 字节`};let o=p(u(),`jsd-batch-${Date.now().toString(36)}-${++wo}.jsonl`);try{c(o,i,`utf8`)}catch(e){return{error:`写盘失败:${e instanceof Error?e.message:String(e)}`}}return{path:o,bytes:a,line:r}}async function Eo(e,t,n,r){let i=async e=>{let i=co.exec(e.trim());return i==null?so(e,t,r):uo(i[1],i[2],n)};if(typeof e==`string`){let t=po.exec(e.trim());if(t!=null)return i(t[1]);let n=``,r=0;for(let t of e.matchAll(fo)){n+=e.slice(r,t.index);let a=await i(t[1]);n+=typeof a==`string`?a:JSON.stringify(a),r=(t.index??0)+t[0].length}return r===0?e:n+e.slice(r)}if(Array.isArray(e)){let i=[];for(let a of e)i.push(await Eo(a,t,n,r));return i}if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=await Eo(o,t,n,r);return i}return e}function Do(e,t,n){return[V({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:vt,outputSchema:yt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:ji,run:async(e,t,n)=>{let{calls:r,callsFile:i,stopOnError:a,checkDrift:o}=e,s=i==null||i.trim()===``?null:await Ra(i);if(s!=null&&r!=null)throw Error(`calls 与 callsFile 只能给一个:calls 在本批内直接执行,callsFile 从文件读同一份清单。两个都给会让「哪份生效」变成猜。`);if(s==null&&r==null)throw Error(`需要 calls 或 callsFile 其中一个(都缺省时没有步骤可执行)。参数体大到写不进上下文时,把清单写进 JSON 文件、这里只传它的绝对路径。`);let c=s?.calls??r??[],l=s?.stopOnError??a,u=s?.checkDrift??o,d=new Map,f=[],p=!1,m=[],h=[],ee=u===!1,g=[],te,ne=()=>(te??=(async()=>(await t.request(`get_page`,{},{...n==null?{}:{signal:n}}))?.assets??{})(),te),re=new Set;for(let e=0;e<c.length;e++){let t=c[e],r=t.id==null||t.id.trim()===``?`step${e+1}`:t.id.trim(),i=e=>{re.add(r),f.push({id:r,tool:t.tool,ok:!1,error:e})};if(d.has(r)||f.some(e=>e.id===r)){i(`步骤 id "${r}" 重复`);break}let a=$a(t.tool);if(a==null){i(`未知工具 ${t.tool},可用: ${eo().join(`, `)}`);break}let o;try{o=await Eo(t.args??{},d,ne,re)}catch(e){if(i(e instanceof Error?e.message:String(e)),e instanceof oo&&(l===!1||t.continueOnError===!0))continue;break}let s=await a(o,n,{skipHooks:ee});if(s.isError===!0){if(i((s.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),l!==!1&&t.continueOnError!==!0)break;continue}let u=So(s.structuredContent,t.tool);u.trimmed&&(p=!0,m.push(r)),u.omitted&&h.push(r),d.set(r,s.structuredContent),s.warnings!=null&&g.push(...s.warnings),f.push({id:r,tool:t.tool,ok:!0,data:u.data})}let ie=f.length===c.length,ae=g,_=h.length===0?void 0:To(f,d),oe=_!=null&&`error`in _?void 0:_;if(_!=null&&`error`in _&&ae.push(`本批有 ${h.length} 步回显超预算,但完整明细未落盘(${_.error});已保留 id 清单,要明细请把对应工具单独调用一次。`),oe!=null)for(let e of f){if(!h.includes(e.id))continue;let t=e.data,n=oe.line.get(e.id);t!=null&&t.echoOmitted===!0&&n!=null&&(e.data={...t,path:oe.path,line:n,note:`本步明细已随整批落盘(第 ${n} 行);也可把 ${e.tool} 单独调用一次。`})}return{ok:ie&&f.every(e=>e.ok),executed:f.length,total:c.length,results:f,...p?{echoTrimmed:!0}:{},...p?{echoNote:Co(m,h,oe)}:{},...ae.length>0?{warnings:ae}:{}}}})(e,t,n)]}function Oo(e){return e==null?b:[e]}function H(e){return Yt[e]}function ko(e,t){return k(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function Ao(e,t){let n=e=>{let t=e==null?null:k(e,`variants`)?.setLevelOps;return t==null||t.length===0?``:`造新维度/新取值不用绕实例:本平台有集合级管理入口(${t.join(` / `)})—— 先 mg_list_variant_properties 看现状,再建维度/加成分/改取值,每个 op 都写完回读(各自的行为注意写在它的描述里,调用前读一眼);换绑(jsd_set_instance_properties)只负责切到**已有**成分。`};if(e!=null&&t!=null){let r=k(e,`variants`),i=r?.read,a=r?.write.includes(`jsd_set_instance_properties`)===!0,o=i==null?``:a?`文档里**已有**的变体集不受影响:\`${i}\` 与组件集上的维度取值照常读得到,已有取值照常用 jsd_set_instance_properties 切 —— 缺的只是「用脚本造一个新的」;`:`文档里**已有**的变体集读得到:\`${i}\` 与组件集上的维度取值照常可读,但**实例侧切值本平台运行期没有可用入口**(引擎声明了 setProperties / swapComponent,实测分别是「not a function」与内部错误)—— 变体取值只能在画布上手工切换;**读得到 ≠ 切得动**;`,s=t?`${H(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${H(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。${o}替代路径:${ko(e,`variants`)}。`,c=n(e);return c===``?s:`${s}${c}`}let r=b.filter(e=>k(e,`variants`)?.fallback!=null),i=b.filter(e=>!r.includes(e));return[`按能力位 ${ii.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(H).join(` / `)});`,`未声明的平台(如 ${r.map(H).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?ko(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function jo(e){if(e==null)return Oo(null).map(e=>{let t=Ye(e,`setProperties`),n=k(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${H(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=k(e,`components`),n=Ye(e,`setProperties`),r=[n==null?`值形态未探测(先读 jsd://platform/state)`:`setProperties 签名收 ${n.join(` / `)}`];return t!=null&&(r.push(t.write.length>0?`写入口:${t.write.join(` / `)}`:`没有可用写入口`),r.push(t.read==null?`读侧无 componentProperties(能力位 ${ii.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function Mo(e){if(e!=null){let t=k(e,`variables`);if(t==null)return`${H(e)}的变量面未登记。`;if(t.write.length>0)return`${H(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${H(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。替代路径:${ko(e,`variables`)}`}return`${H(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。替代路径:${ko(e,`variables`)}`}let t=b.filter(e=>(k(e,`variables`)?.write.length??0)>0),n=b.filter(e=>(k(e,`variables`)?.write.length??0)===0&&(k(e,`variables`)?.nativeUnwired.length??0)>0),r=b.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=k(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${H(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(H).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(H).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function No(e){return e===`mastergo`?"- 一次调用带多组:`bindings: [{ nodeIds, property, value, variableId?, index?, unbind? }]`,一组 = 一个变量 × 一个槽位 × 一批节点;槽位取值见 `mg_variables_apply` 的描述,传错会在入参校验就点名,数组型属性另给 `index`,不要一个节点一次调用;":e===`figma`?"- 一次调用带多组:`bindings: [{ nodeIds, boundProperty, variableId?, subField?, index?, unbind? }]`,一组 = 一个变量 × 一个字段 × 一批节点,不要一个节点一次调用;节点级字段直接写字段名,fills / strokes 绑在 paint 上,index 省略即该数组全部 SOLID 项,effects / layoutGrids 另给 `subField` + `index`;":"- 绑定一次传多个 `nodeIds`,参数词汇以本平台变量面给的为准,不要一个节点一次调用;"}function Po(e){return e===`mastergo`?["- ⚠ MG **没有**「图层属性 ↔ 变量」的反读接口:回读只能拿到该图层用到的集合与模式(见 `mg_list_variables`),它证明「集合挂上了」、证不了「挂在该属性上」;","- 所以绑数组属性(fills / effects / grids)**必须**自己给 `index`,并 jsd_export({ids:[节点id], scale=0.5}) 目视确认渲染真的变了 —— 这一条别省。"].join(`
|
|
39
39
|
`):e===`figma`?[`- 回读节点上的绑定,比对里面的 variableId 与你要绑的是同一个 —— **回显成功不等于绑上了**;`,`- 涉及视觉的改动再 jsd_export({ids:[节点id], scale=0.5}) 导小图目检一次;`].join(`
|
|
40
|
-
`):`- 回读本平台提供的绑定读面,比对里面的 variableId 与你要绑的是同一个 —— **回显成功不等于绑上了**;`}function
|
|
40
|
+
`):`- 回读本平台提供的绑定读面,比对里面的 variableId 与你要绑的是同一个 —— **回显成功不等于绑上了**;`}function Fo(e){return e===`mastergo`?["- MG 的节点上**没有**绑定字段可读:`mg_list_variables` 给出集合 / 模式 / 变量及它们的值,某图层用了哪些集合看 `getLayerVariableModes`;","- 变量 id 取自 `mg_list_variables` 或 `jsd_get_page` 的 `assets.variables`,**可直接回喂**写入口,不用改名、不用补名称。"].join(`
|
|
41
41
|
`):e===`figma`?[`- 读节点上的变量绑定(字段名见上一节):键是引擎的可绑定字段名,值的三态由引擎决定 —— 标量字段是单个别名;fills / strokes / effects / layoutGrids / textRangeFills 是别名数组;componentProperties 是按属性名索引的别名表。**键在 = 至少有一条绑定**(无绑定或平台不提供该字段时整个键省略)。`,"- 库存与模式走 `figma_variables_list`(集合 / 模式 / 各变量的值);读路径就是写侧的 `boundProperty` 词汇,值里的 id **可直接回喂**写入口,不用改名、不用补名称。",`- 引擎口径原样保留:有**独立圆角**的节点上,圆角绑定会表现为 topLeftRadius / topRightRadius / bottomLeftRadius / bottomRightRadius 四条(不归一成 cornerRadius)。`].join(`
|
|
42
42
|
`):[`- 以本平台变量面给出的读路径为准:**键在 = 至少有一条绑定**(平台不提供该字段时整个键省略)。`,`- 值里的 id **可直接回喂**写入口,不用改名、不用补名称。`].join(`
|
|
43
|
-
`)}function
|
|
43
|
+
`)}function Io(e){return e===`mastergo`?["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。","- 变体集:切到**已有**取值用 `jsd_set_instance_properties`(取值清单看 `assets.variants[].properties`;MG 原生读不到该字段时用 `mg_list_variant_properties` 看)。要造新值用集合级 op,不要靠改主件名字。","- 样式:节点字段 `fillStyleId` / `strokeStyleId` / `textStyleId` / `effectStyleId` 直接引用样式 id;`assets.styles` 与 `jsd://styles` **列得出来**(2026-10-14 真机已验),按 id / 名复用即可。⚠ 别拿「哪份清单里有它」当判据 —— `assets.styles` 与 `assets.variables` 是同一批资源的两个视角(后四类复合样式建出来进 `assets.variables`),详见下面「四类件之间怎么连」。","- 变量:`mg_variables_apply` 绑到图层属性,变量 id 从 `mg_list_variables` 或 `assets.variables` 取。要的是「一组值一起复用」(间距 / 圆角 / 描边宽度 / 填色这套)就建 **复合样式变量**:`mg_variables_create` 的 type 有 PAINT / TEXT / EFFECT / GRID / STROKE_WIDTH / CORNER_RADIUS / PADDING(11 项,**SPACING 引擎不收**)—— 建出来本身就是一条样式,只进 `assets.variables`。"].join(`
|
|
44
44
|
`):e===`figma`?["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。","- 变体集:切到**已有**取值用 `jsd_set_instance_properties`(取值清单看 `assets.variants[].properties`)。","- 样式:平台 op `figma_style_apply_by_name` 按名应用,或直接写节点字段 `fillStyleId` / `strokeStyleId` / `textStyleId` / `effectStyleId`;**清单里没有就建一条** —— `jsd_create_style` 从指定节点抄。","- 变量:`figma_variables_apply` 绑到节点(变量 id 先 `figma_variables_list` 或从 `assets.variables` 取);**绑进样式里**用 `figma_style_variables_apply`(改一次,所有引用该样式的节点都跟),回读走 `figma_style_variables_list`。"].join(`
|
|
45
45
|
`):e===`jsdesign`?["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。⚠ 本平台把带 `/` 的组件名拆成「集合 / 成分」—— `assets.components[].name` 是**叶子名**(建 `组/主件` 后清单里叫 `主件`,集合名在 `assets.variants` 上),按名字取组件(`{{@comp:…}}`)时一律照清单里的原样写。","- 变体集:取值清单读得到(`assets.variants[].properties`),但**切值本平台运行期没有入口** —— 引擎声明了 `setProperties` / `swapComponent`,实测分别是「not a function」与内部错误(2026-10-20),变体取值只能在画布上手工切换。需要脚本可切的多状态请改「每个状态一个独立 COMPONENT」。","- 样式:节点字段 `fillStyleId` / `strokeStyleId` / `textStyleId` / `effectStyleId` 直接引用样式 id;`assets.styles` 与 `jsd://styles` **列得出来**(2026-10-15 真机:7 条 = 6 PAINT + 1 TEXT),按 id / 名复用即可。⚠ 枚举走**同步**入口(能力位 `styleEnumerationSync`):运行时的 `getLocal*StylesAsync` 是引擎透出的未声明成员,`await` 它**永不 resolve**(0043 / dec e1e66f0a)—— 别想着「换 async 更快」。色板与字体**一律落样式**(PAINT / TEXT / EFFECT / GRID 本平台有工厂,实测可建可绑、可从节点 `*StyleId` 回读);间距与圆角没有样式工厂,只能落节点字段(`jsd_set_layout` / `jsd_set_cornerRadius`)。","- 变量:本平台没有变量面(`assets.variables` 恒空),别去找变量入口;统一色板走上一条的样式路。"].join(`
|
|
46
46
|
`):["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。","- 变体集:切到**已有**取值用 `jsd_set_instance_properties`(取值清单看 `assets.variants[].properties`)。","- 样式:节点上的 `*StyleId` 字段引用样式 id(`jsd_create_style` 能从既有节点建出一条),或本平台提供的按名应用入口(清单见 `jsd://platform/state` 的 platformOps)。","- 变量:本平台的变量入口见 `jsd://platform/state` 的 platformOps(`assets.variables` 恒空即本平台没有变量面)。"].join(`
|
|
47
|
-
`)}function
|
|
47
|
+
`)}function Lo(e,t){let n=["- **三平台一致的三条**:① 分层是「变量(一个值)→ 样式(一组固定视觉)→ 组件(一组节点)→ 变体(组件的多态维度)」,越往下越贵也越难改;② 「改一处影响全部」有**三种源头** —— 改值(变量)/ 改一组值(样式)/ 改结构(主组件),按差异落在哪一层选,别一律抽组件;③ **变体取值绑变量三家都做不到**:三平台的变量类型表里都没有 `VARIANT`(行号见 `dicts/platform-knowledge.ts` 三家的 evidence)——「切到禁用态时颜色跟着主题变」得拆成两件事:变体只管**结构态**,颜色/间距仍由变量或样式扛。","- **三套词汇别混用**:组件属性走 `jsd_set_instance_properties`,节点字段走 `jsd_set_*`,变量绑定走本平台的变量 op —— 拿错入口的典型症状是「回包成功、画布没变」。"],r=t===!1?["- ⚠ **样式这一面列不出来**:本平台声明了 `styles`(按 id 应用是通的)但没声明 `styleEnumeration`,故 `assets.styles` / `jsd://styles` **恒空**(0043)。已有样式的 id 只能从**正用着它的节点**上读 `fillStyleId` / `strokeStyleId` / `textStyleId` / `effectStyleId`,新建的必须把 `jsd_create_style` 回包的 id **记账** —— 丢了找不回(重复建了按 id 走 `jsd_delete_style`)。⚠ **本仓没有「改样式」的入口**(样式面只有建 `jsd_create_style` 与删 `jsd_delete_style`):样式一旦建成就**改不了值** —— 要换值只有两条路,删了重建(引用它的节点要重新绑 `*StyleId`),或在设计器里手动改。⇒ 所以「改一处全档跟随」这条卖点**在本仓 MCP 侧验证不了**,建样式时就得一次给对(要改就去设计器里手动改,或删了重建)。这是**仓库级缺口**,不分平台。"]:[];return e===`figma`?['- **Figma:三层链(变量 → 样式 → 节点)三端都通,但一套链一套词汇**,别把三档的字段名混着传:① **节点档** `figma_variables_apply`(width / cornerRadius / opacity… 与 fills / strokes / effects / layoutGrids);② **样式档** `figma_style_variables_apply`(数组档叫 **paints** / effects / layoutGrids —— 节点上的 fills / strokes 在样式上叫 paints,子字段固定 color;排版档 fontFamily / fontSize / … 仅 TEXT 样式);③ **组件属性档** `figma_component_properties_set`(值传 `{type, value:{type:"VARIABLE_ALIAS", id}}`,**只此一家**能这么写)。选哪档就一个问句:**改一次要带动多大一片** —— 一个节点(①)/ 所有引用这条样式的节点(②)/ 所有实例的这个属性(③)。',"- **验证走各自的读面,别拿一端的证据宣布另一端生效**:①回读节点 `boundVariables`;②回读 `figma_style_variables_list`(样式档的绑定**只有这里能看到** —— `assets.styles` 只给 id + 名称,节点上的 `boundVariables` 不含样式内部的绑定;`figma_style_variables_apply` 的回包已带写完立刻回读的 `styles[].boundVariables`);③回读 `componentProperties[].boundVariables.value`。","- ⚠ **两类东西绑不了**:变体属性(`VARIANT` —— 变量类型表里没有它)与 `SLOT` 组件属性(读得到、写侧引擎抛 `cannotSetSlotProperty`);样式档里也没有节点字段(圆角、宽高、透明度绑不到样式上,它们本来就属于节点)。","- **改值与删除的口子**:同名同类型再调一次 `figma_variables_create` 就是就地更新(没有独立的改值 op);变量删除走 `figma_variables_remove`(删完空集合会留着,集合与模式的生命周期未接),样式删除走 `jsd_delete_style`。",...r,...n].join(`
|
|
48
48
|
`):e===`mastergo`?["- **MG:变量**包含**样式** —— 不是「变量喂样式」。`mg_variables_create` 的 type 里有八项复合样式(PAINT / TEXT / EFFECT / GRID / STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING),建出来**本身就是一条样式**。⇒「一组固定视觉,还要随模式切」在 MG 上是**一条变量**、不是一条样式;两条路都通,选错的症状是**在另一半清单里找不到它**:复合样式变量只进 `assets.variables`,不进 `assets.styles`。","- ⚠ **样式与变量共用一套 id 空间,类别词汇还逐字重名**(它的 `getStyleById` 连变量都查得出来)。删除**必须分入口**:变量走 `mg_variables_remove`,样式走 `jsd_delete_style` —— 拿样式入口删变量会**回包成功、变量真没了**(真机 2026-10-14)。名字在两份清单里撞车时,先确认它在哪一面再动。","- **样式面八类都通,但落点分两面**:本平台的 `StyleType` 就是那八项(`:1810`),`jsd_create_style` 全收(后四类 STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING **只此一家**有工厂 —— 另两家没有,传过去会被写前点名拒)。⚠ 真机 2026-10-14:**`assets.styles` 与 `assets.variables` 是同一批资源的两个视角,列出来的内容不互补、也不可预测** —— 后四类走 `jsd_create_style` 建出来进了 `assets.variables`;而 `mg_variables_create type=PAINT` 建的复合样式变量反过来只出现在 `assets.styles`,`mg_list_variables` 按集合筛、按类型筛都列不出它。⇒ **别拿「哪份清单里有它」当判据**:要确认就用回包的 id 直接读(`getVariableById` / `getStyleById` 共用同一套 id,都解析得出来),要删就按错误提示换入口(两边都会点名拒,不会误删)。","- ⚠ `mg_variables_create` 的 type 只有 **11 项**:typings 的 `VariableType` 列了 SPACING,引擎实建抛 `Unsupported variable type: SPACING`(官方文档也没有它)—— 要 SPACING 走 `jsd_create_style kind=SPACING`。","- ⚠ 复合样式类型的变量**不进 `mg.variables.getVariables()` 列表**(按集合筛、按类型筛都列不出;`getVariableById(id)` 读得到)。op 的回读因此按 id 查,两条都读不到才落 `pendingReadback` —— 看到它**不要重试**,拿 id 走样式侧确认即可。","- ⚠ 这四类的**样式侧枚举面没接**(`getLocalStrokeWidthStyles` 等 MG:1517-1520 未投影成契约成员)—— 但它们会出现在 `assets.variables` 里,所以不是找不到,是**在另一份清单里找**。",'- **组件属性 ↔ 变量:读得到、写不了**。`componentProperties[].variableId` 是 MG 给的绑定证据(仅**组件侧**那张表、仅 TEXT/BOOLEAN 属性可能存在),但 `setProperties` 只收 `string|boolean`,平台没有任何写入口 ⇒ 别在这里传 `{type,value:{type:"VARIABLE_ALIAS",…}}`,core 按方法参数登记表点名中止;要绑只能在设计器里手动做,插件这一侧只能验证它存不存在。',"- **模式切换没有入口**:`setVariableMode` / `setPageVariableMode` 未接 ⇒ 换主题要么在设计器里手动切模式,要么每个主题各建一套变量 —— 别拿「建了多个 mode」当它已经会跟着切。",...r,...n].join(`
|
|
49
49
|
`):e===`jsdesign`?["- **jsDesign:只有样式一层** —— typings 全文没有任何 variable 声明(`grep -in variable` 零命中),这是**平台没有这个面**,不是「本仓还没接」。⇒ 变量能做的「一个语义 token 随模式/主题变」在这里没有对应物:色板、间距、排版一律落**样式**;深浅两套主题只能建成两套样式族按名字批量重刷(`jsd_find` 定位 → `jsd_batch` 改写),或抽成两个组件族 —— 别去试变量 op(daemon 拦成 `platform_unsupported`,白跑一趟往返)。","- **实例属性写入在本平台运行期不可用**:typings 与官方文档都声明了 `InstanceNode.setProperties`(`plugin-api.d.ts:1093`),实测调它立刻抛 `in setProperties: i.setProperties is not a function`(真机 2026-10-20,真实变体实例上 11~15ms 就失败)⇒ 布尔 / 文本 / 换绑 / 变体取值**一概写不了**。`jsd_component_facts` 的 `setPropertiesAvailable` 直接回报符号在不在,别拿一次失败去试探;`jsd_set_instance_properties` 会在写前点名拒。状态差异走「族名 / 状态」命名的多主件。","- ⚠ 契约的样式类别是三家 `StyleType` 的**八项并集**,本平台只有四类(PAINT / TEXT / EFFECT / GRID,`plugin-api.d.ts:1137`)⇒ 传 STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING 会在写前被点名拒(不静默、不会建成别的类);间距与圆角要统一就落节点字段(`jsd_set_layout` / `jsd_set_cornerRadius`),或按「族 / 值」命名后 `jsd_find` + `jsd_batch` 批量刷。","- **变体集:造不出来、也切不动**。`combineAsVariants` 是唯一产出路径且真机必崩,失败还会留下畸形集合与布尔运算残骸(用 `jsd_repair_nodes` 清)。**已有的变体集读得到**(维度取值看 `assets.variants[].properties`、成员看 `jsd_component_facts` 的 `members`),但实例侧切值**没有可用入口** —— `setProperties` 不是函数、`swapComponent` 抛内部错误(读不到目标节点的 type,原文见 `jsd_component_facts` 的 `swapComponentAvailable`;真机 2026-10-20,独立组件 / 成员 / 克隆实例上全复现)。⚠ 别把「读得到」写成「能切」;要脚本可切的多状态请改「每个状态一个独立 COMPONENT」。",'- **PAINT 这条链是通的,也是本平台做统一色板的唯一正路**(真机 2026-10-15,6 条样式绑 23 个节点):①先**归一化** —— 同名用途却差一两度的色(分割线 `#EDEDEB` / 侧栏边框 `#EAEAE8` / 卡片描边 `#E8E8E6`)必须先收敛成一套值,不收就建样式,建出来只套得住一半节点;②`jsd_create_style({kind:"PAINT", name:"色板/主色", fromNodeId:样板节点})` 从样板抄,回包 id 记账;③绑回 `jsd_set_fill_color` 的 `fillStyleId` / `jsd_set_stroke` 的 `strokeStyleId` —— **创建入参与这两个 set 工具的顶层都收这四个 `*StyleId` 键**,不必「建完再绑」两趟。两个坑(其一是过去式):`jsd_set_text` **原先不收 `fills`**(文字颜色得另跑一趟 `jsd_set_fill_color`),2026-10-15 已放开 —— 现在 `fills` 与排版一趟写入;`strokeStyleId` 的写入**回包会报「插件响应超时」但写入已落**(真机:批量内一次、单发一次都超时,事后 `jsd_find` 回读 `strokeStyleId` 已绑上)⇒ 不要重试,回读一次确认。','- ⚠ **TEXT 样式:排版能跟,但绑完必须补一次宽度修复,而且不带颜色**(真机 2026-10-15,隔一次独立读 + 导图目检):① 绑 `textStyleId` 后排版**确实跟源** —— fontSize 14 → 20、fontName Regular → Bold、lineHeight AUTO → 32px(全部回读确认);② **但引擎同时把宽度钉成 0**(`textAutoResize` 仍是 WIDTH_AND_HEIGHT、`width=0`)⇒ 画面**完全不可见**(导出 167 字节空白 vs 同尺寸样板 4281 字节);⚠ **写入同 tick 的回显看不到这条** —— 它仍报 112 / 84 / 101 原值,**必须隔一次调用独立读**才现形(这条曾把我误导成「绑定无损」);③ **修法:`jsd_set_text({width: N, textAutoResize:"HEIGHT"})` 两个字段同批传**(你的实测:回读 240 / 32 恢复正常)。只传 `width` 不行、解绑 `textStyleId` 不行、重设 characters 也不行 —— 三种都试过,只有这一种组合有效;④ **样式不带颜色**:`TextStyle` 只有排版字段(typings `:1151-1161`,没有 `fills`),绑完节点 `fills` 保持原色 ⇒ 颜色**一律走 PAINT 样式 + `fillStyleId`**,别指望文本样式带色。⇒ 文字排版**可以用** TEXT 样式,代价是「绑一条补一次宽」;要零成本就用**样板节点当事实来源**(读它的 fontSize / fontName / lineHeight / fills,逐条写进同类文本)。','- ⚠ **TEXT 宽度被钉成 0 是另一回事,不要归因到样式绑定**:2026-10-15 出现过 26 个文本节点宽度归零、画面全空(导出体积 108KB → 43KB 是这个信号),而那次现场**同一会话里先有两次 25s 超时**(挂死的 `strokeStyleId` 写)且发生在多步批次内;隔离复现三种姿势都不出现 ⇒ 归因未定,别写成「某个字段导致的」。症状的修法走已知那条链:`jsd_resize_node` 传 `width` 把宽度钉回去(要高度随内容走再同时设 `textAutoResize:"HEIGHT"`),`core/props/writers.ts` 的 `warnTinyFixedText` 会点名这种「写进去了但看不见」。⇒ 真正的规矩是:**超时之后必须复核受影响的子树**(单独 `jsd_find` 读几何 + 导图目检),别接着往下写。',...r,...n].join(`
|
|
50
50
|
`):["- **三平台的连线方式不同,先探平台再选路**(`jsd_ping` 的 capabilities / `jsd://platform/state`):Figma 是「变量 → 样式 → 节点」三层链,三端都有入口(样式档的绑定靠 `figma_style_variables_list` 才看得见);MasterGo 把样式塌进变量(八项复合样式类型,且与样式共用一套 id 空间、类别词汇逐字重名);即时设计只有样式一层(typings 里没有任何变量声明)。照搬别家做法的典型症状:去找本平台没有的入口,或在另一份清单里找已经建好的那一条。",...t==null?["- 样式能不能列清单同样按能力位判(`styleEnumeration`):未声明的平台上 `assets.styles` 恒空 —— **别把「列不出来」当「文档里没有」**,已有样式的 id 从节点上的 `*StyleId` 读。"]:[],...n].join(`
|
|
51
|
-
`)}function xo(e){if(e==null){let e=x.filter(e=>j(e,`components`)?.read!=null),t=x.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(U).join(` / `)} 读得到;`,`${t.map(U).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return j(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function So(e){let t=Oe.layoutGrids.join(` / `),n=e=>Fe.includes(e)?`${U(e)}:\`layoutGrids\` 实测不收(节点级网格不落盘)—— 别重试,要栅格请在设计器里手动加`:`${U(e)}:\`layoutGrids\` 可写,写后走双读回读校验,没生效会在结果 warnings 里点名`;return["排布有两条路,都可用:① **自动布局** —— `layoutMode=HORIZONTAL|VERTICAL` 配 ","`itemSpacing/padding*/primary|counterAxisSizingMode|primary|counterAxisAlignItems`","(节奏按上一条:归组摆好后用 jsd_set_layout);② **栅格参考线** —— `layoutGrids`(仅 "+t+`)。`,...e===`jsdesign`?["⚠ **开布局会按内容重算容器尺寸,但声明了 FIXED 的轴会被写路径自动钉回**(真机 2026-10-15):① 建容器那一次带上 `layoutMode` + 两轴 FIXED → 尺寸原样保住(实测 400×300 建出来还是 400×300);② **事后**用 `jsd_set_layout` 开布局,引擎那一瞬间仍会把 400×300 按内容 hug 成 112×176(内容 80 + padding 32)—— **但写路径随后按该轴 sizingMode 的回读值判定:即时设计两轴都回读 FIXED,于是两轴都 `resizeContainer` 钉回开布局前的尺寸**,并在 warnings 里点名「已按声明钉回」、回显尺寸同步为真值;③ ⇒ **要固定就声明该轴 FIXED,不必再手工补 `jsd_resize_node`**;**要按内容撑开就显式传该轴 `AUTO`**(传了 AUTO 就不会钉回);不声明时按引擎自己的回读值走,别靠猜。",'✅ **其余自动布局能力真机全部生效**(2026-10-15,同一组容器实测):`itemSpacing` 与 `padding*`(纵向 3 个子项 y = 16 / 68 / 120,恰好 40+12 递推)、`primaryAxisAlignItems:"SPACE_BETWEEN"`(横向 3 个子项 x = 16 / 160 / 304,此时 `itemSpacing` 按文档被忽略)、`counterAxisAlignItems:"CENTER"`(子项 y = 130 =(300-40)/2)、`layoutGrow`(纵向主轴 40 → 164,吃满剩余空间)、`layoutAlign:"STRETCH"`(交叉轴 80 → 368 = 400-32)、`constraints`(子项 STRETCH 后容器加宽 100,子项宽 80 → 180=16 左距 + 304 右距)、`layoutGrids`(创建入参可写,普通容器与**自动布局容器**上回读都落盘)。⇒ 布局这一面用得起来,别拿绝对坐标绕开。',"⚠ **别传本平台没有的布局字段**:typings(`@jsdesigndeveloper/plugin-typings@1.0.12`)里 `layoutWrap` / `layoutPositioning` / `counterAxisSpacing` / `itemReverseZIndex` / `strokesIncludedInLayout` **一个都没有**(grep 零命中)—— 那是 Figma 的字段,换行与「布局内绝对定位」在这里做不到,别按 Figma 的习惯试。",'⚠ TEXT 要固定宽 / 固定框,先显式传 `textAutoResize`(`"NONE"` 固定框、`"HEIGHT"` 固定宽自动高)再开布局;只给 width 时引擎会把缺省的 WIDTH_AND_HEIGHT 改成 NONE,高度不再随内容重算(实测固定宽 200 的长文本 height 回读仍是 15)—— 这类「高度没跟着内容走」的文本,**重设一次 characters 就触发重排**(同一节点重设后回读 82),别急着改尺寸。⚠ 更狠的一档是**宽度被钉在最小值**:建 TEXT 时 characters 为空(或只给一维尺寸),引擎把缺省的 WIDTH_AND_HEIGHT 置成 NONE 并把宽度钉到 1px(实测只给 height:60 → 宽度 1),之后填 characters **不会重算宽度** —— 21 个字挤在 1px 框里,回读 characters 完整、零告警、画面空白。这跟开不开布局无关;修法是 jsd_resize_node 传 width 钉回去,或建时一次给全 characters 与 width/height。',`**别拿「绝对坐标、最后补布局」回避这套顺序**:布局容器接管子节点 x/y,手摆的坐标在布局里根本不显形 —— 该走的是上面的顺序,不是不开布局。`]:[],...e===`figma`?["⚠ **主轴默认按内容撑开(引擎自称 hug),交叉轴保得住**(真机 2026-10-15,400×300 容器 + 3 个 80×40 子节点):不声明 sizingMode 时,开纵向布局后 → **400×176**,回读 `primaryAxisSizingMode: **AUTO**`、`counterAxisSizingMode: FIXED` —— 字段与行为一致,**AUTO 那条不钉回**(保留 hug 语义)。**显式声明 FIXED 的轴会被自动钉回请求值**(同一判据:该轴回读 FIXED 而尺寸不符 → `resizeContainer` + warnings 点名「已按声明钉回」),所以「建容器时同批给 `layoutMode` + 两轴 FIXED + `height:300`」现在**真的会得到 300**(此前停在 176,只发一条 warning)。⇒ 要固定就声明该轴 FIXED,要 hug 就不声明或显式传 AUTO。","✅ 实测可用的部分:`layoutMode` / `itemSpacing` / `padding*` 落库且生效(纵向 3 子项 y = 16 / 68 / 120),交叉轴尺寸开布局时保得住,`primaryAxisSizingMode` **如实回读**(AUTO 就是 AUTO,不被请求值污染 —— 这点比即时设计可信)。"]:[],`两者互斥:引擎只在**非自动布局**的容器上收网格。`,uo(e).map(n).join(`;`)].join(``)}function W(e,t){return{method:`component_op`,outputSchema:Sn,payload:t=>({op:e,...t}),...t}}function Co(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`createComponent.description2`}}),W(`create_instance`,{name:`jsd_create_instance`,title:`createInstance.title`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:Yn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`createInstance.description`}}),W(`detach_instance`,{name:`jsd_detach_instance`,title:`detachInstance.title`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:Xn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`detachInstance.description`}}),W(`import_component`,{name:`jsd_import_component`,title:`importComponent.title`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:Zn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`importComponent.description`}}),W(`swap_component`,{name:`jsd_swap_component`,title:`swapComponent.title`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:Qn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),W(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读:\`variantProperties\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。**变体属性传名字即可;组件属性(布尔/文本/换绑)必须传读到的完整键**(含 \`#32:0\` 后缀)—— 组件属性在引擎侧只认完整键,短名会报 \`Could not find a component property with name\`(真机实测,TEXT/BOOLEAN/INSTANCE_SWAP 三类都一样);core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选。**写前先读 \`componentPropertyReferences\`**(它标明哪个图层由哪个属性驱动 —— 属性成对存在时只有连着可见层的那一组会改画面,写错那组会「回包成功、画布不动」)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${mo(null)}`,inputSchema:$n,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`setInstanceProperties.description`}}),W(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`combineAsVariants.title`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。${po(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:er,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),W(`copy_overrides`,{name:`jsd_copy_overrides`,title:`copyOverrides.title`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:rr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`copyOverrides.description`}}),W(`apply_overrides`,{name:`jsd_apply_overrides`,title:`applyOverrides.title`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:ar,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`applyOverrides.description`}}),W(`sync_overrides`,{name:`jsd_sync_overrides`,title:`syncOverrides.title`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>H(r)(e,t,n))}var wo=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),To={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},Eo=`#f3f4f6`;function Do(e){let t={};if(!e)return t;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&(t[r]=i)}return t}function G(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function Oo(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:To[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function ko(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`margin-top`])??n,r=G(e[`margin-right`])??r,i=G(e[`margin-bottom`])??i,a=G(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function Ao(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`padding-top`])??n,r=G(e[`padding-right`])??r,i=G(e[`padding-bottom`])??i,a=G(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function jo(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:Oo(e[2])??`#000000`};let t=n.match(/([\d.]+)(?:px)?/);if(t)return{width:parseFloat(t[1]),color:`#000000`}}return e[`border-width`]&&e[`border-width`]!==`0`&&e[`border-width`]!==`none`?{width:G(e[`border-width`])??1,color:Oo(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function Mo(e){return G(e[`font-size`])??16}function No(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function Po(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Fo(e){return(e.display??``).includes(`flex`)}function Io(e){return e[`flex-direction`]===`row`?`row`:`column`}function Lo(e){return G(e.gap)??G(e[`row-gap`])??0}function Ro(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function zo(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Bo(e){return e.type===`text`?e.data:ge(e)?e.tagName===`br`?`
|
|
52
|
-
`:e.children.map(
|
|
53
|
-
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>
|
|
54
|
-
`).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}">${Jo(e)}</text>`)});return}let l=Oo(i.background??i[`background-color`],e.tag===`img`?Eo:void 0),u=jo(i),d=G(i[`border-radius`])??0,f=l&&l!==`none`;if(e.tag===`img`||f||u.width>0){let e=[`x="${a.toFixed(1)}"`,`y="${o.toFixed(1)}"`,`width="${Math.max(0,s).toFixed(1)}"`,`height="${Math.max(0,c).toFixed(1)}"`];d>0&&e.push(`rx="${d}"`),f&&e.push(`fill="${l}"`),u.width>0&&e.push(`stroke="${u.color}" stroke-width="${u.width}"`),t.push(`<rect ${e.join(` `)} />`)}for(let n of e.children)Go(n),qo(n,t,a,o)}function Jo(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Yo(e){let t=_e(e,{decodeEntities:!0}).children.filter(e=>ge(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=Ho(n,!0),i=Do(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=Wo(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),Ko(r,c,l)}var Xo={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,album:`square-bookmark`,"alert-circle":`circle-alert`,"alert-octagon":`octagon-alert`,"alert-triangle":`triangle-alert`,"align-center":`text-align-center`,"align-justify":`text-align-justify`,"align-left":`text-align-start`,"align-right":`text-align-end`,angry:`face-angry`,annoyed:`face-expressionless`,"area-chart":`chart-area`,"arrow-down-01":`arrow-down-0-1`,"arrow-down-10":`arrow-down-1-0`,"arrow-down-az":`arrow-down-a-z`,"arrow-down-circle":`circle-arrow-down`,"arrow-down-left-from-circle":`circle-arrow-out-down-left`,"arrow-down-left-from-square":`square-arrow-out-down-left`,"arrow-down-left-square":`square-arrow-down-left`,"arrow-down-right-from-circle":`circle-arrow-out-down-right`,"arrow-down-right-from-square":`square-arrow-out-down-right`,"arrow-down-right-square":`square-arrow-down-right`,"arrow-down-square":`square-arrow-down`,"arrow-down-za":`arrow-down-z-a`,"arrow-left-circle":`circle-arrow-left`,"arrow-left-square":`square-arrow-left`,"arrow-right-circle":`circle-arrow-right`,"arrow-right-square":`square-arrow-right`,"arrow-up-01":`arrow-up-0-1`,"arrow-up-10":`arrow-up-1-0`,"arrow-up-az":`arrow-up-a-z`,"arrow-up-circle":`circle-arrow-up`,"arrow-up-left-from-circle":`circle-arrow-out-up-left`,"arrow-up-left-from-square":`square-arrow-out-up-left`,"arrow-up-left-square":`square-arrow-up-left`,"arrow-up-right-from-circle":`circle-arrow-out-up-right`,"arrow-up-right-from-square":`square-arrow-out-up-right`,"arrow-up-right-square":`square-arrow-up-right`,"arrow-up-square":`square-arrow-up`,"arrow-up-za":`arrow-up-z-a`,"asterisk-square":`square-asterisk`,"axis-3-d":`axis-3d`,"badge-help":`badge-question-mark`,"bar-chart":`chart-no-axes-column-increasing`,"bar-chart-2":`chart-no-axes-column`,"bar-chart-3":`chart-column`,"bar-chart-4":`chart-column-increasing`,"bar-chart-big":`chart-column-big`,"bar-chart-horizontal":`chart-bar`,"bar-chart-horizontal-big":`chart-bar-big`,"between-horizonal-end":`between-horizontal-end`,"between-horizonal-start":`between-horizontal-start`,"book-marked":`book-bookmark`,"book-template":`book-dashed`,"box-select":`square-dashed`,"building-2":`building-complex`,"candlestick-chart":`chart-candlestick`,"check-circle":`circle-check-big`,"check-circle-2":`circle-check`,"check-square":`square-check-big`,"check-square-2":`square-check`,"chevron-down-circle":`circle-chevron-down`,"chevron-down-square":`square-chevron-down`,"chevron-left-circle":`circle-chevron-left`,"chevron-left-square":`square-chevron-left`,"chevron-right-circle":`circle-chevron-right`,"chevron-right-square":`square-chevron-right`,"chevron-up-circle":`circle-chevron-up`,"chevron-up-square":`square-chevron-up`,"circle-help":`circle-question-mark`,"circle-slashed":`circle-slash-2`,"clipboard-edit":`clipboard-pen`,"clipboard-signature":`clipboard-pen-line`,"code-2":`code-xml`,"code-square":`square-code`,columns:`columns-2`,"columns-settings":`columns-3-cog`,"contact-2":`contact-round`,"curly-braces":`braces`,"divide-circle":`circle-divide`,"divide-square":`square-divide`,"dot-square":`square-dot`,"download-cloud":`cloud-download`,edit:`square-pen`,"edit-2":`pen`,"edit-3":`pen-line`,"equal-square":`square-equal`,"file-audio":`file-headphone`,"file-audio-2":`file-headphone`,"file-axis-3-d":`file-axis-3d`,"file-badge-2":`file-badge`,"file-bar-chart":`file-chart-column-increasing`,"file-bar-chart-2":`file-chart-column`,"file-check-2":`file-check-corner`,"file-code-2":`file-code-corner`,"file-cog-2":`file-cog`,"file-edit":`file-pen`,"file-json":`file-braces`,"file-json-2":`file-braces-corner`,"file-key-2":`file-key`,"file-line-chart":`file-chart-line`,"file-lock-2":`file-lock`,"file-minus-2":`file-minus-corner`,"file-pie-chart":`file-chart-pie`,"file-plus-2":`file-plus-corner`,"file-question":`file-question-mark`,"file-search-2":`file-search-corner`,"file-signature":`file-pen-line`,"file-type-2":`file-type-corner`,"file-video":`file-play`,"file-video-2":`file-video-camera`,"file-volume-2":`file-signal`,"file-warning":`file-exclamation-point`,"file-x-2":`file-x-corner`,filter:`funnel`,"filter-x":`funnel-x`,fingerprint:`fingerprint-pattern`,"flip-horizontal":`square-centerline-dashed-horizontal`,"flip-horizontal-2":`triangles-centerline-dashed-horizontal`,"flip-vertical":`square-centerline-dashed-vertical`,"flip-vertical-2":`triangles-centerline-dashed-vertical`,"folder-cog-2":`folder-cog`,"folder-edit":`folder-pen`,"fork-knife":`utensils`,"fork-knife-crossed":`utensils-crossed`,"form-input":`rectangle-ellipsis`,frown:`face-slightly-frowning`,"function-square":`square-function`,"gantt-chart":`chart-no-axes-gantt`,"gantt-chart-square":`square-chart-gantt`,"gauge-circle":`circle-gauge`,"git-commit":`git-commit-horizontal`,"globe-2":`earth`,grab:`hand-grab`,grid:`grid-3x3`,"grid-2-x-2":`grid-2x2`,"grid-2-x-2-check":`grid-2x2-check`,"grid-2-x-2-plus":`grid-2x2-plus`,"grid-2-x-2-x":`grid-2x2-x`,"grid-3-x-3":`grid-3x3`,"help-circle":`circle-question-mark`,"helping-hand":`hand-helping`,history:`rotate-ccw-clock`,home:`house`,"ice-cream":`ice-cream-cone`,"ice-cream-2":`ice-cream-bowl`,indent:`list-indent-increase`,"indent-decrease":`list-indent-decrease`,"indent-increase":`list-indent-increase`,inspect:`square-mouse-pointer`,"kanban-square":`square-kanban`,"kanban-square-dashed":`square-dashed-kanban`,"laptop-2":`laptop-minimal`,laugh:`face-grinning`,"layers-3":`layers`,layout:`panels-top-left`,"letter-text":`text-initial`,"library-square":`square-library`,"line-chart":`chart-line`,"loader-2":`loader-circle`,"location-edit":`map-pin-pen`,"m-square":`square-m`,"mail-question":`mail-question-mark`,meh:`face-neutral`,"menu-square":`square-menu`,"message-circle-question":`message-circle-question-mark`,"mic-2":`mic-vocal`,"minus-circle":`circle-minus`,"minus-square":`square-minus`,"more-horizontal":`ellipsis`,"more-vertical":`ellipsis-vertical`,"mouse-pointer-square-dashed":`square-dashed-mouse-pointer`,"move-3-d":`move-3d`,outdent:`list-indent-decrease`,"paintbrush-2":`paintbrush-vertical`,palmtree:`tree-palm`,"panel-bottom-inactive":`panel-bottom-dashed`,"panel-left-inactive":`panel-left-dashed`,"panel-right-inactive":`panel-right-dashed`,"panel-top-inactive":`panel-top-dashed`,"panels-left-right":`columns-3`,"panels-top-bottom":`rows-3`,"parking-circle":`circle-parking`,"parking-circle-off":`circle-parking-off`,"parking-square":`square-parking`,"parking-square-off":`square-parking-off`,"pause-circle":`circle-pause`,"pause-octagon":`octagon-pause`,"pen-box":`square-pen`,"pen-square":`square-pen`,"percent-circle":`circle-percent`,"percent-diamond":`diamond-percent`,"percent-square":`square-percent`,"pi-square":`square-pi`,"pie-chart":`chart-pie`,"pilcrow-square":`square-pilcrow`,"play-circle":`circle-play`,"play-square":`square-play`,"plug-zap-2":`plug-zap`,"plus-circle":`circle-plus`,"plus-square":`square-plus`,podcast:`mic-signal`,"power-circle":`circle-power`,"power-square":`square-power`,"rotate-3-d":`rotate-3d`,rows:`rows-2`,"scale-3-d":`scale-3d`,"scatter-chart":`chart-scatter`,"school-2":`university`,"scissors-square":`square-scissors`,"scissors-square-dashed-bottom":`square-bottom-dashed-scissors`,"send-horizonal":`send-horizontal`,"shield-close":`shield-x`,"shield-question":`shield-question-mark`,sidebar:`panel-left`,"sidebar-close":`panel-left-close`,"sidebar-open":`panel-left-open`,"sigma-square":`square-sigma`,"slash-square":`square-slash`,sliders:`sliders-vertical`,smile:`face-slightly-smiling`,"smile-plus":`face-slightly-smiling-plus`,"sort-asc":`arrow-up-narrow-wide`,"sort-desc":`arrow-down-wide-narrow`,"split-square-horizontal":`square-split-horizontal`,"split-square-vertical":`square-split-vertical`,"square-gantt-chart":`square-chart-gantt`,stars:`sparkles`,"stop-circle":`circle-stop`,subtitles:`captions`,"table-config":`columns-3-cog`,"terminal-square":`square-terminal`,"test-tube-2":`test-tube-diagonal`,text:`text-align-start`,"text-select":`square-dashed-text`,"text-selection":`square-dashed-text`,train:`tram-front`,"trash-2":`trash`,"tv-2":`tv-minimal`,unlock:`lock-open`,"unlock-keyhole":`lock-keyhole-open`,"upload-cloud":`cloud-upload`,"user-2":`user-round`,"user-check-2":`user-round-check`,"user-circle":`circle-user`,"user-circle-2":`circle-user-round`,"user-cog-2":`user-round-cog`,"user-minus-2":`user-round-minus`,"user-plus-2":`user-round-plus`,"user-square":`square-user`,"user-square-2":`square-user-round`,"user-x-2":`user-round-x`,"users-2":`users-round`,verified:`badge-check`,"wallet-2":`wallet-minimal`,"wand-2":`wand-sparkles`,waves:`waves-horizontal`,"wrap-text":`text-wrap`,"x-circle":`circle-x`,"x-octagon":`octagon-x`,"x-square":`square-x`},Zo=e(import.meta.url);function Qo(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var $o=JSON.parse(r(Zo.resolve(`lucide-static/icon-nodes.json`),`utf8`)),es=JSON.parse(r(Zo.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries($o))q.set(e,{name:e,nodes:t,keywords:es[e]??[]});q.size;var ts=new Map;for(let[e,t]of Object.entries(es))t.forEach((t,n)=>{let r=ts.get(t)??[];r.push({name:e,idx:n}),ts.set(t,r)});var ns=new ve([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function rs(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function is(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Xo[t];if(r){let e=q.get(r);if(e)return e}let i=Qo(t),a=ns.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&rs(i,Qo(e.item.name))>=3});if(a.length)return a[0].item;let o=ts.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||Qo(e.name).length-Qo(t.name).length)[0];return q.get(e.name)??null}let s=ns.search(t,{limit:8}).filter(e=>rs(i,Qo(e.item.name))>=2)[0];return s?s.item:null}function as(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=Xo[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of ts.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of ns.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function os(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(`
|
|
51
|
+
`)}function Ro(e){if(e==null){let e=b.filter(e=>k(e,`components`)?.read!=null),t=b.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(H).join(` / `)} 读得到;`,`${t.map(H).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return k(e,`components`)?.read==null?`${H(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${H(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function zo(e){let t=je.layoutGrids.join(` / `),n=e=>Re.includes(e)?`${H(e)}:\`layoutGrids\` 实测不收(节点级网格不落盘)—— 别重试,要栅格请在设计器里手动加`:`${H(e)}:\`layoutGrids\` 可写,写后走双读回读校验,没生效会在结果 warnings 里点名`;return["排布有两条路,都可用:① **自动布局** —— `layoutMode=HORIZONTAL|VERTICAL` 配 ","`itemSpacing/padding*/primary|counterAxisSizingMode|primary|counterAxisAlignItems`","(节奏按上一条:归组摆好后用 jsd_set_layout);② **栅格参考线** —— `layoutGrids`(仅 "+t+`)。`,...e===`jsdesign`?["⚠ **开布局会按内容重算容器尺寸,但声明了 FIXED 的轴会被写路径自动钉回**(真机 2026-10-15):① 建容器那一次带上 `layoutMode` + 两轴 FIXED → 尺寸原样保住(实测 400×300 建出来还是 400×300);② **事后**用 `jsd_set_layout` 开布局,引擎那一瞬间仍会把 400×300 按内容 hug 成 112×176(内容 80 + padding 32)—— **但写路径随后按该轴 sizingMode 的回读值判定:即时设计两轴都回读 FIXED,于是两轴都 `resizeContainer` 钉回开布局前的尺寸**,并在 warnings 里点名「已按声明钉回」、回显尺寸同步为真值;③ ⇒ **要固定就声明该轴 FIXED,不必再手工补 `jsd_resize_node`**;**要按内容撑开就显式传该轴 `AUTO`**(传了 AUTO 就不会钉回);不声明时按引擎自己的回读值走,别靠猜。",'✅ **其余自动布局能力真机全部生效**(2026-10-15,同一组容器实测):`itemSpacing` 与 `padding*`(纵向 3 个子项 y = 16 / 68 / 120,恰好 40+12 递推)、`primaryAxisAlignItems:"SPACE_BETWEEN"`(横向 3 个子项 x = 16 / 160 / 304,此时 `itemSpacing` 按文档被忽略)、`counterAxisAlignItems:"CENTER"`(子项 y = 130 =(300-40)/2)、`layoutGrow`(纵向主轴 40 → 164,吃满剩余空间)、`layoutAlign:"STRETCH"`(交叉轴 80 → 368 = 400-32)、`constraints`(子项 STRETCH 后容器加宽 100,子项宽 80 → 180=16 左距 + 304 右距)、`layoutGrids`(创建入参可写,普通容器与**自动布局容器**上回读都落盘)。⇒ 布局这一面用得起来,别拿绝对坐标绕开。',"⚠ **别传本平台没有的布局字段**:typings(`@jsdesigndeveloper/plugin-typings@1.0.12`)里 `layoutWrap` / `layoutPositioning` / `counterAxisSpacing` / `itemReverseZIndex` / `strokesIncludedInLayout` **一个都没有**(grep 零命中)—— 那是 Figma 的字段,换行与「布局内绝对定位」在这里做不到,别按 Figma 的习惯试。",'⚠ TEXT 要固定宽 / 固定框,先显式传 `textAutoResize`(`"NONE"` 固定框、`"HEIGHT"` 固定宽自动高)再开布局;只给 width 时引擎会把缺省的 WIDTH_AND_HEIGHT 改成 NONE,高度不再随内容重算(实测固定宽 200 的长文本 height 回读仍是 15)—— 这类「高度没跟着内容走」的文本,**重设一次 characters 就触发重排**(同一节点重设后回读 82),别急着改尺寸。⚠ 更狠的一档是**宽度被钉在最小值**:建 TEXT 时 characters 为空(或只给一维尺寸),引擎把缺省的 WIDTH_AND_HEIGHT 置成 NONE 并把宽度钉到 1px(实测只给 height:60 → 宽度 1),之后填 characters **不会重算宽度** —— 21 个字挤在 1px 框里,回读 characters 完整、零告警、画面空白。这跟开不开布局无关;修法是 jsd_resize_node 传 width 钉回去,或建时一次给全 characters 与 width/height。',`**别拿「绝对坐标、最后补布局」回避这套顺序**:布局容器接管子节点 x/y,手摆的坐标在布局里根本不显形 —— 该走的是上面的顺序,不是不开布局。`]:[],...e===`figma`?["⚠ **主轴默认按内容撑开(引擎自称 hug),交叉轴保得住**(真机 2026-10-15,400×300 容器 + 3 个 80×40 子节点):不声明 sizingMode 时,开纵向布局后 → **400×176**,回读 `primaryAxisSizingMode: **AUTO**`、`counterAxisSizingMode: FIXED` —— 字段与行为一致,**AUTO 那条不钉回**(保留 hug 语义)。**显式声明 FIXED 的轴会被自动钉回请求值**(同一判据:该轴回读 FIXED 而尺寸不符 → `resizeContainer` + warnings 点名「已按声明钉回」),所以「建容器时同批给 `layoutMode` + 两轴 FIXED + `height:300`」现在**真的会得到 300**(此前停在 176,只发一条 warning)。⇒ 要固定就声明该轴 FIXED,要 hug 就不声明或显式传 AUTO。","✅ 实测可用的部分:`layoutMode` / `itemSpacing` / `padding*` 落库且生效(纵向 3 子项 y = 16 / 68 / 120),交叉轴尺寸开布局时保得住,`primaryAxisSizingMode` **如实回读**(AUTO 就是 AUTO,不被请求值污染 —— 这点比即时设计可信)。"]:[],`两者互斥:引擎只在**非自动布局**的容器上收网格。`,Oo(e).map(n).join(`;`)].join(``)}function U(e,t){return{method:`component_op`,outputSchema:Tn,payload:t=>({op:e,...t}),...t}}function Bo(e,t,n){return[U(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Qn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!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:$n,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!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:er,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},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:tr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!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:nr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},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\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。**变体属性传名字即可;组件属性(布尔/文本/换绑)必须传读到的完整键**(含 \`#32:0\` 后缀)—— 组件属性在引擎侧只认完整键,短名会报 \`Could not find a component property with name\`(真机实测,TEXT/BOOLEAN/INSTANCE_SWAP 三类都一样);core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选。**写前先读 \`componentPropertyReferences\`**(它标明哪个图层由哪个属性驱动 —— 属性成对存在时只有连着可见层的那一组会改画面,写错那组会「回包成功、画布不动」)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${jo(null)}`,inputSchema:rr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!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 节点,实例不能直接合成。${Ao(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:ir,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},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:sr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!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:lr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!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:ur,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>V(r)(e,t,n))}var Vo=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),Ho={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},Uo=`#f3f4f6`;function Wo(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 Go(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:Ho[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function Ko(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 qo(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 Jo(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:Go(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:Go(e[`border-color`])??`#000000`}:t}function G(e,t){return W(e[t])}function Yo(e){return W(e[`font-size`])??16}function Xo(e){let t=e[`font-weight`];return t===`bold`?700:W(t)??400}function Zo(e,t){let n=e[`line-height`];return W(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Qo(e){return(e.display??``).includes(`flex`)}function $o(e){return e[`flex-direction`]===`row`?`row`:`column`}function es(e){return W(e.gap)??W(e[`row-gap`])??0}function ts(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function ns(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function rs(e){return e.type===`text`?e.data:ve(e)?e.tagName===`br`?`
|
|
52
|
+
`:e.children.map(rs).join(``):``}function is(e){return e.replace(/\s+/g,` `).trim()}function as(e,t){let n=Wo(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=is(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:os(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}ve(t)&&(Vo.has(t.tagName)||t.tagName!==`br`&&r.children.push(as(t,!1)))}if(t&&r.children.length===0){let t=is(e.children.map(rs).join(``));t&&r.children.push({tag:`#text`,text:t,style:os(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function os(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 ss(e,t){let n=e.style,r=qo(n),i=Ko(n),a=Jo(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=Yo(n),r=(e.text??``).split(`
|
|
53
|
+
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>ns(e,t)),t)),e.h=r.length*Zo(n,t),c=e.h}else{let t=Qo(n),i=$o(n),o=es(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=ss(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&ts(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=ss(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&ts(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 cs(e){let t=Ko(e.style);e.x+=t.left,e.y+=t.top}function ls(e,t,n){let r=[];return us(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 us(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=Yo(i),r=Go(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=Xo(i),u=ts(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=Zo(i,n);(e.text??``).split(`
|
|
54
|
+
`).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}">${ds(e)}</text>`)});return}let l=Go(i.background??i[`background-color`],e.tag===`img`?Uo:void 0),u=Jo(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)cs(n),us(n,t,a,o)}function ds(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function fs(e){let t=ye(e,{decodeEntities:!0}).children.filter(e=>ve(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=as(n,!0),i=Wo(n.attribs.style),a=G(i,`width`),o=G(i,`height`),s=ss(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),ls(r,c,l)}var ps={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,album:`square-bookmark`,"alert-circle":`circle-alert`,"alert-octagon":`octagon-alert`,"alert-triangle":`triangle-alert`,"align-center":`text-align-center`,"align-justify":`text-align-justify`,"align-left":`text-align-start`,"align-right":`text-align-end`,angry:`face-angry`,annoyed:`face-expressionless`,"area-chart":`chart-area`,"arrow-down-01":`arrow-down-0-1`,"arrow-down-10":`arrow-down-1-0`,"arrow-down-az":`arrow-down-a-z`,"arrow-down-circle":`circle-arrow-down`,"arrow-down-left-from-circle":`circle-arrow-out-down-left`,"arrow-down-left-from-square":`square-arrow-out-down-left`,"arrow-down-left-square":`square-arrow-down-left`,"arrow-down-right-from-circle":`circle-arrow-out-down-right`,"arrow-down-right-from-square":`square-arrow-out-down-right`,"arrow-down-right-square":`square-arrow-down-right`,"arrow-down-square":`square-arrow-down`,"arrow-down-za":`arrow-down-z-a`,"arrow-left-circle":`circle-arrow-left`,"arrow-left-square":`square-arrow-left`,"arrow-right-circle":`circle-arrow-right`,"arrow-right-square":`square-arrow-right`,"arrow-up-01":`arrow-up-0-1`,"arrow-up-10":`arrow-up-1-0`,"arrow-up-az":`arrow-up-a-z`,"arrow-up-circle":`circle-arrow-up`,"arrow-up-left-from-circle":`circle-arrow-out-up-left`,"arrow-up-left-from-square":`square-arrow-out-up-left`,"arrow-up-left-square":`square-arrow-up-left`,"arrow-up-right-from-circle":`circle-arrow-out-up-right`,"arrow-up-right-from-square":`square-arrow-out-up-right`,"arrow-up-right-square":`square-arrow-up-right`,"arrow-up-square":`square-arrow-up`,"arrow-up-za":`arrow-up-z-a`,"asterisk-square":`square-asterisk`,"axis-3-d":`axis-3d`,"badge-help":`badge-question-mark`,"bar-chart":`chart-no-axes-column-increasing`,"bar-chart-2":`chart-no-axes-column`,"bar-chart-3":`chart-column`,"bar-chart-4":`chart-column-increasing`,"bar-chart-big":`chart-column-big`,"bar-chart-horizontal":`chart-bar`,"bar-chart-horizontal-big":`chart-bar-big`,"between-horizonal-end":`between-horizontal-end`,"between-horizonal-start":`between-horizontal-start`,"book-marked":`book-bookmark`,"book-template":`book-dashed`,"box-select":`square-dashed`,"building-2":`building-complex`,"candlestick-chart":`chart-candlestick`,"check-circle":`circle-check-big`,"check-circle-2":`circle-check`,"check-square":`square-check-big`,"check-square-2":`square-check`,"chevron-down-circle":`circle-chevron-down`,"chevron-down-square":`square-chevron-down`,"chevron-left-circle":`circle-chevron-left`,"chevron-left-square":`square-chevron-left`,"chevron-right-circle":`circle-chevron-right`,"chevron-right-square":`square-chevron-right`,"chevron-up-circle":`circle-chevron-up`,"chevron-up-square":`square-chevron-up`,"circle-help":`circle-question-mark`,"circle-slashed":`circle-slash-2`,"clipboard-edit":`clipboard-pen`,"clipboard-signature":`clipboard-pen-line`,"code-2":`code-xml`,"code-square":`square-code`,columns:`columns-2`,"columns-settings":`columns-3-cog`,"contact-2":`contact-round`,"curly-braces":`braces`,"divide-circle":`circle-divide`,"divide-square":`square-divide`,"dot-square":`square-dot`,"download-cloud":`cloud-download`,edit:`square-pen`,"edit-2":`pen`,"edit-3":`pen-line`,"equal-square":`square-equal`,"file-audio":`file-headphone`,"file-audio-2":`file-headphone`,"file-axis-3-d":`file-axis-3d`,"file-badge-2":`file-badge`,"file-bar-chart":`file-chart-column-increasing`,"file-bar-chart-2":`file-chart-column`,"file-check-2":`file-check-corner`,"file-code-2":`file-code-corner`,"file-cog-2":`file-cog`,"file-edit":`file-pen`,"file-json":`file-braces`,"file-json-2":`file-braces-corner`,"file-key-2":`file-key`,"file-line-chart":`file-chart-line`,"file-lock-2":`file-lock`,"file-minus-2":`file-minus-corner`,"file-pie-chart":`file-chart-pie`,"file-plus-2":`file-plus-corner`,"file-question":`file-question-mark`,"file-search-2":`file-search-corner`,"file-signature":`file-pen-line`,"file-type-2":`file-type-corner`,"file-video":`file-play`,"file-video-2":`file-video-camera`,"file-volume-2":`file-signal`,"file-warning":`file-exclamation-point`,"file-x-2":`file-x-corner`,filter:`funnel`,"filter-x":`funnel-x`,fingerprint:`fingerprint-pattern`,"flip-horizontal":`square-centerline-dashed-horizontal`,"flip-horizontal-2":`triangles-centerline-dashed-horizontal`,"flip-vertical":`square-centerline-dashed-vertical`,"flip-vertical-2":`triangles-centerline-dashed-vertical`,"folder-cog-2":`folder-cog`,"folder-edit":`folder-pen`,"fork-knife":`utensils`,"fork-knife-crossed":`utensils-crossed`,"form-input":`rectangle-ellipsis`,frown:`face-slightly-frowning`,"function-square":`square-function`,"gantt-chart":`chart-no-axes-gantt`,"gantt-chart-square":`square-chart-gantt`,"gauge-circle":`circle-gauge`,"git-commit":`git-commit-horizontal`,"globe-2":`earth`,grab:`hand-grab`,grid:`grid-3x3`,"grid-2-x-2":`grid-2x2`,"grid-2-x-2-check":`grid-2x2-check`,"grid-2-x-2-plus":`grid-2x2-plus`,"grid-2-x-2-x":`grid-2x2-x`,"grid-3-x-3":`grid-3x3`,"help-circle":`circle-question-mark`,"helping-hand":`hand-helping`,history:`rotate-ccw-clock`,home:`house`,"ice-cream":`ice-cream-cone`,"ice-cream-2":`ice-cream-bowl`,indent:`list-indent-increase`,"indent-decrease":`list-indent-decrease`,"indent-increase":`list-indent-increase`,inspect:`square-mouse-pointer`,"kanban-square":`square-kanban`,"kanban-square-dashed":`square-dashed-kanban`,"laptop-2":`laptop-minimal`,laugh:`face-grinning`,"layers-3":`layers`,layout:`panels-top-left`,"letter-text":`text-initial`,"library-square":`square-library`,"line-chart":`chart-line`,"loader-2":`loader-circle`,"location-edit":`map-pin-pen`,"m-square":`square-m`,"mail-question":`mail-question-mark`,meh:`face-neutral`,"menu-square":`square-menu`,"message-circle-question":`message-circle-question-mark`,"mic-2":`mic-vocal`,"minus-circle":`circle-minus`,"minus-square":`square-minus`,"more-horizontal":`ellipsis`,"more-vertical":`ellipsis-vertical`,"mouse-pointer-square-dashed":`square-dashed-mouse-pointer`,"move-3-d":`move-3d`,outdent:`list-indent-decrease`,"paintbrush-2":`paintbrush-vertical`,palmtree:`tree-palm`,"panel-bottom-inactive":`panel-bottom-dashed`,"panel-left-inactive":`panel-left-dashed`,"panel-right-inactive":`panel-right-dashed`,"panel-top-inactive":`panel-top-dashed`,"panels-left-right":`columns-3`,"panels-top-bottom":`rows-3`,"parking-circle":`circle-parking`,"parking-circle-off":`circle-parking-off`,"parking-square":`square-parking`,"parking-square-off":`square-parking-off`,"pause-circle":`circle-pause`,"pause-octagon":`octagon-pause`,"pen-box":`square-pen`,"pen-square":`square-pen`,"percent-circle":`circle-percent`,"percent-diamond":`diamond-percent`,"percent-square":`square-percent`,"pi-square":`square-pi`,"pie-chart":`chart-pie`,"pilcrow-square":`square-pilcrow`,"play-circle":`circle-play`,"play-square":`square-play`,"plug-zap-2":`plug-zap`,"plus-circle":`circle-plus`,"plus-square":`square-plus`,podcast:`mic-signal`,"power-circle":`circle-power`,"power-square":`square-power`,"rotate-3-d":`rotate-3d`,rows:`rows-2`,"scale-3-d":`scale-3d`,"scatter-chart":`chart-scatter`,"school-2":`university`,"scissors-square":`square-scissors`,"scissors-square-dashed-bottom":`square-bottom-dashed-scissors`,"send-horizonal":`send-horizontal`,"shield-close":`shield-x`,"shield-question":`shield-question-mark`,sidebar:`panel-left`,"sidebar-close":`panel-left-close`,"sidebar-open":`panel-left-open`,"sigma-square":`square-sigma`,"slash-square":`square-slash`,sliders:`sliders-vertical`,smile:`face-slightly-smiling`,"smile-plus":`face-slightly-smiling-plus`,"sort-asc":`arrow-up-narrow-wide`,"sort-desc":`arrow-down-wide-narrow`,"split-square-horizontal":`square-split-horizontal`,"split-square-vertical":`square-split-vertical`,"square-gantt-chart":`square-chart-gantt`,stars:`sparkles`,"stop-circle":`circle-stop`,subtitles:`captions`,"table-config":`columns-3-cog`,"terminal-square":`square-terminal`,"test-tube-2":`test-tube-diagonal`,text:`text-align-start`,"text-select":`square-dashed-text`,"text-selection":`square-dashed-text`,train:`tram-front`,"trash-2":`trash`,"tv-2":`tv-minimal`,unlock:`lock-open`,"unlock-keyhole":`lock-keyhole-open`,"upload-cloud":`cloud-upload`,"user-2":`user-round`,"user-check-2":`user-round-check`,"user-circle":`circle-user`,"user-circle-2":`circle-user-round`,"user-cog-2":`user-round-cog`,"user-minus-2":`user-round-minus`,"user-plus-2":`user-round-plus`,"user-square":`square-user`,"user-square-2":`square-user-round`,"user-x-2":`user-round-x`,"users-2":`users-round`,verified:`badge-check`,"wallet-2":`wallet-minimal`,"wand-2":`wand-sparkles`,waves:`waves-horizontal`,"wrap-text":`text-wrap`,"x-circle":`circle-x`,"x-octagon":`octagon-x`,"x-square":`square-x`},ms=e(import.meta.url);function hs(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var gs=JSON.parse(a(ms.resolve(`lucide-static/icon-nodes.json`),`utf8`)),_s=JSON.parse(a(ms.resolve(`lucide-static/tags.json`),`utf8`)),K=new Map;for(let[e,t]of Object.entries(gs))K.set(e,{name:e,nodes:t,keywords:_s[e]??[]});K.size;var vs=new Map;for(let[e,t]of Object.entries(_s))t.forEach((t,n)=>{let r=vs.get(t)??[];r.push({name:e,idx:n}),vs.set(t,r)});var ys=new be([...K.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function bs(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function xs(e){let t=e.trim().toLowerCase();if(!t)return null;let n=K.get(t);if(n)return n;let r=ps[t];if(r){let e=K.get(r);if(e)return e}let i=hs(t),a=ys.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&bs(i,hs(e.item.name))>=3});if(a.length)return a[0].item;let o=vs.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||hs(e.name).length-hs(t.name).length)[0];return K.get(e.name)??null}let s=ys.search(t,{limit:8}).filter(e=>bs(i,hs(e.item.name))>=2)[0];return s?s.item:null}function Ss(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=ps[n];if(a&&!r.has(a)){let e=K.get(a);e&&r.set(e.name,e)}for(let{name:e}of vs.get(n)??[]){let n=K.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of ys.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function Cs(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(`
|
|
55
55
|
`);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(`
|
|
56
|
-
`)}var ss={FRAME:Ot,RECTANGLE:kt,ELLIPSE:At,LINE:jt,POLYGON:Mt,STAR:Nt,VECTOR:Pt,TEXT:Ft,GROUP:It,BOOLEAN_OPERATION:Lt};function cs(e){let t={...ss[e].shape,type:h.literal(e).optional()};return h.object({...t,placement:zt.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:cs(e),outputSchema:mn,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var Y={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function ls(e,t,n){let i=[J(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,followUp:Y}),J(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:Y}),J(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:Y}),J(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:Y}),J(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:Y}),J(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:Y}),J(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:Y}),J(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 的矢量节点是 PenNode,路径为 penNetwork 顶点模型,与本工具的 vectorPaths(SVG path data)不同形;该平台暂不支持建矢量)`,followUp:Y}),J(`GROUP`,{name:`jsd_create_group`,title:`createGroup.title`,description:`createGroup.description`,followUp:Y}),J(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`createBooleanOperation.title`,description:n.t(`createBooleanOperation.description`,{ops:Ye}),followUp:Y})],a=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:Bt,outputSchema:mn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:Si,run:async(e,t,n)=>{let{svg:i,svgPath:a,name:o}=e,s;if(a!=null&&a.trim()!==``)try{s=r(a,`utf8`)}catch(e){throw Error(`读取 SVG 文件失败(${a}): ${e instanceof Error?e.message:String(e)}`)}else s=i??``;if(s.trim()===``)throw Error(a==null?`svg 为空字符串;要导入本地文件请改用 svgPath`:`SVG 文件是空的:${a}(脚本可能没写成功,或写到了另一个路径)`);if(s.length>Oi)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${Oi}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:o??`svg-design`},{signal:n,timeout:Si})},followUp:Y}),o=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Ht,outputSchema:mn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=is(r);if(!c){let e=as(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=os(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:Y}),s=H({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:Vt,outputSchema:mn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=Yo(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:Y});return[...i.map(r=>H(r)(e,t,n)),a(e,t,n),o(e,t,n),s(e,t,n)]}var us=`(page)`,ds=8,fs=200,ps=5,ms=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function hs(e){let t=e.op;return typeof t==`string`&&ms.has(t)}function gs(e){return e.op===`reparent`}function _s(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 vs(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function ys(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 bs(e,t){let n=Ia(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 xs(e){let t=new Map;if(e===us){let e=await bs(`jsd_get_page`,{});if(e==null)return null;for(let n of vs(e.nodes).slice(0,fs)){let e=ys(n);e!=null&&t.set(e.id,e)}return t}let n=await bs(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=vs(n.nodes)[0];if(r==null)return null;for(let e of vs(r.children).slice(0,fs)){let n=ys(e);n!=null&&t.set(n.id,n)}return t}var Ss=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(e.op===void 0||hs(e)){this.engaged=!0;try{let t=new Set;if(_s(e,t),t.size===0)return;let n=await bs(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of vs(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}gs(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(us);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=ds){this.dead.add(e);continue}let t=await xs(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 xs(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,ps).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>ps?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===us?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},Cs=()=>new Ss;function ws(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:sn,outputSchema:yn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:Cs,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:cn,outputSchema:Sn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`manageComponents.description2`}});return[r(e,t,n),i(e,t,n)]}function Ts(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:an,outputSchema:vn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function X(e,t){return{method:`node_op`,outputSchema:yn,payload:t=>({op:e,...t}),...ms.has(e)?{tags:[`structural`],hook:Cs}:{},...t}}function Es(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:zn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`selectNodes.description`}}),X(`remove`,{name:`jsd_delete_node`,title:`deleteNode.title`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:Bn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),X(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:Vn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),X(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:Hn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),X(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:Un,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),X(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:Wn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`flattenNodes.description`}}),X(`outline_stroke`,{name:`jsd_outline_stroke`,title:`outlineStroke.title`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:Gn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),X(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,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:Kn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`reparentNodes.description`}}),X(`repair`,{name:`jsd_repair_nodes`,title:`repairNodes.title`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:qn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>H(r)(e,t,n))}function Ds(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`,`jsdesign`],platformNote:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${xo(null)}${mo(null)}。变量面:${ho(null)})`,method:`platform_op`,inputSchema:pn,outputSchema:_t,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function Os(e,t){let n=e.registerPrompt(`html-to-design`,{title:t.t(`prompt.htmlToDesign.title`),description:t.t(`prompt.htmlToDesign.description`),argsSchema:h.object({html:h.string().describe(`要转换的 HTML 片段`),name:h.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:js(String(e),t==null?void 0:String(t))}}]})),r=e.registerPrompt(`icon-grid`,{title:t.t(`prompt.iconGrid.title`),description:t.t(`prompt.iconGrid.description`),argsSchema:h.object({icons:h.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:h.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:h.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:Ms(String(e),Number(t)||24,Number(n)||16)}}]})),i=e.registerPrompt(`script-ops`,{title:t.t(`prompt.scriptOps.title`),description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:h.object({task:h.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:Ns(e==null?void 0:String(e))}}]})),a=e.registerPrompt(`design-strategy`,{title:t.t(`prompt.designStrategy.title`),description:`画布创作的通用纪律:先查可复用件(组件/变体/样式/变量怎么选、怎么复用)、再摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局(auto-layout 判据 + 最容易漏掉的分区清单)、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:h.object({screen:h.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ps(e==null?void 0:String(e),Z())}}]})),o=e.registerPrompt(`text-replace-strategy`,{title:t.t(`prompt.textReplace.title`),description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:h.object({rootId:h.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Is(e==null?void 0:String(e))}}]})),s=e.registerPrompt(`variant-sync`,{title:t.t(`prompt.variantSync.title`),description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:h.object({sourceId:h.string().optional().describe(`源实例 id;留空取当前选中`),targetType:h.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ls(e==null?void 0:String(e),t==null?void 0:String(t))}}]})),c=e.registerPrompt(`variable-binding`,{title:t.t(`prompt.variableBinding.title`),description:`变量绑定与批量套用:先看本平台有没有变量能力面,再读绑定、建变量、批量绑定;没有变量面的平台给替代路径`,argsSchema:h.object({target:h.string().optional().describe(`要绑定的节点或范围描述;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Rs(e==null?void 0:String(e),Z())}}]})),l=e.registerPrompt(`variant-set`,{title:t.t(`prompt.variantSet.title`),description:`变体集构建:按能力位 inPlaceVariants 分流(原位合并 / 多主件兜底),含命名与建后回读复核`,argsSchema:h.object({family:h.string().optional().describe(`组件族名,如 Nav;留空只返回做法与分流`)})},({family:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:zs(e==null?void 0:String(e),Z())}}]})),u=e.registerPrompt(`component-property`,{title:t.t(`prompt.componentProperty.title`),description:`组件属性的定义与设值:定义走平台 op、设值走 jsd_set_instance_properties,并按当前平台给出能收的值形态`,argsSchema:h.object({target:h.string().optional().describe(`组件或实例 id;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Bs(e==null?void 0:String(e),Z())}}]}));return[n,r,i,a,e.registerPrompt(`auto-layout`,{title:t.t(`prompt.autoLayout.title`),description:t.t(`prompt.autoLayout.description`),argsSchema:h.object({target:h.string().optional().describe(`要上布局的容器 / 分区描述,如「标签栏」「参数行」;留空返回通用纪律`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Fs(e==null?void 0:String(e),Z())}}]})),o,s,c,l,u,e.registerPrompt(`chart-by-code`,{title:t.t(`prompt.chartByCode.title`),description:t.t(`prompt.chartByCode.description`),argsSchema:h.object({chart:h.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」「各地区销售额占比环形图」「日活趋势面积图」`),svgPath:h.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)})},({chart:e,svgPath:t})=>({messages:[{role:`user`,content:{type:`text`,text:Hs(String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function Z(){return ji()?.platform??null}function ks(e,t){return e.split(`
|
|
56
|
+
`)}var ws={FRAME:jt,RECTANGLE:Mt,ELLIPSE:Nt,LINE:Pt,POLYGON:Ft,STAR:It,VECTOR:Lt,TEXT:Rt,GROUP:zt,BOOLEAN_OPERATION:Bt};function Ts(e){let t={...ws[e].shape,type:n.literal(e).optional()};return n.object({...t,placement:Ht.optional()}).strict()}function q(e,t){return{method:`execute`,inputSchema:Ts(e),outputSchema:_n,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var J={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function Es(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:Qe}),followUp:J})],i=V({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:Ut,outputSchema:_n,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:Oi,run:async(e,t,n)=>{let{svg:r,svgPath:i,name:o}=e,s;if(i!=null&&i.trim()!==``)try{s=a(i,`utf8`)}catch(e){throw Error(`读取 SVG 文件失败(${i}): ${e instanceof Error?e.message:String(e)}`)}else s=r??``;if(s.trim()===``)throw Error(i==null?`svg 为空字符串;要导入本地文件请改用 svgPath`:`SVG 文件是空的:${i}(脚本可能没写成功,或写到了另一个路径)`);if(s.length>Pi)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${Pi}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:o??`svg-design`},{signal:n,timeout:Oi})},followUp:J}),o=V({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Gt,outputSchema:_n,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=xs(r);if(!c){let e=Ss(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=Cs(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:J}),s=V({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:Wt,outputSchema:_n,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=fs(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:J});return[...r.map(r=>V(r)(e,t,n)),i(e,t,n),o(e,t,n),s(e,t,n)]}var Ds=`(page)`,Os=8,ks=200,As=5,js=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function Ms(e){let t=e.op;return typeof t==`string`&&js.has(t)}function Ns(e){return e.op===`reparent`}function Ps(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 Fs(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function Is(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 Ls(e,t){let n=$a(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 Rs(e){let t=new Map;if(e===Ds){let e=await Ls(`jsd_get_page`,{});if(e==null)return null;for(let n of Fs(e.nodes).slice(0,ks)){let e=Is(n);e!=null&&t.set(e.id,e)}return t}let n=await Ls(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=Fs(n.nodes)[0];if(r==null)return null;for(let e of Fs(r.children).slice(0,ks)){let n=Is(e);n!=null&&t.set(n.id,n)}return t}var zs=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(e.op===void 0||Ms(e)){this.engaged=!0;try{let t=new Set;if(Ps(e,t),t.size===0)return;let n=await Ls(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of Fs(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}Ns(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(Ds);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=Os){this.dead.add(e);continue}let t=await Rs(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 Rs(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,As).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>As?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===Ds?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},Bs=()=>new zs;function Vs(e,t,n){let r=V({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:un,outputSchema:Sn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:Bs,followUp:{type:`tool`,tool:`jsd_set_layout`,description:`manageNodes.followUp`}}),i=V({name:`jsd_manage_components`,title:`manageComponents.title`,description:`manageComponents.description`,method:`component_op`,inputSchema:dn,outputSchema:Tn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`manageComponents.description2`}});return[r(e,t,n),i(e,t,n)]}function Hs(e,t,n){return[V({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:cn,outputSchema:xn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function Y(e,t){return{method:`node_op`,outputSchema:Sn,payload:t=>({op:e,...t}),...js.has(e)?{tags:[`structural`],hook:Bs}:{},...t}}function Us(e,t,n){return[Y(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:Un,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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:Wn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),Y(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:Gn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!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:Kn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!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:qn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),Y(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},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:Yn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},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:Xn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!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:Zn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>V(r)(e,t,n))}function Ws(e,t,n){return[V({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`,`jsdesign`],platformNote:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${Ro(null)}${jo(null)}。变量面:${Mo(null)})`,method:`platform_op`,inputSchema:gn,outputSchema:bt,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function Gs(e,t){let r=e.registerPrompt(`html-to-design`,{title:t.t(`prompt.htmlToDesign.title`),description:t.t(`prompt.htmlToDesign.description`),argsSchema:n.object({html:n.string().describe(`要转换的 HTML 片段`),name:n.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:Js(String(e),t==null?void 0:String(t))}}]})),i=e.registerPrompt(`icon-grid`,{title:t.t(`prompt.iconGrid.title`),description:t.t(`prompt.iconGrid.description`),argsSchema:n.object({icons:n.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:n.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:n.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:Ys(String(e),Number(t)||24,Number(n)||16)}}]})),a=e.registerPrompt(`script-ops`,{title:t.t(`prompt.scriptOps.title`),description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:n.object({task:n.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:Xs(e==null?void 0:String(e))}}]})),o=e.registerPrompt(`design-strategy`,{title:t.t(`prompt.designStrategy.title`),description:`画布创作的通用纪律:先查可复用件(组件/变体/样式/变量怎么选、怎么复用)、再摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局(auto-layout 判据 + 最容易漏掉的分区清单)、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:n.object({screen:n.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Zs(e==null?void 0:String(e),X())}}]})),s=e.registerPrompt(`text-replace-strategy`,{title:t.t(`prompt.textReplace.title`),description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:n.object({rootId:n.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:$s(e==null?void 0:String(e))}}]})),c=e.registerPrompt(`variant-sync`,{title:t.t(`prompt.variantSync.title`),description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:n.object({sourceId:n.string().optional().describe(`源实例 id;留空取当前选中`),targetType:n.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:ec(e==null?void 0:String(e),t==null?void 0:String(t))}}]})),l=e.registerPrompt(`variable-binding`,{title:t.t(`prompt.variableBinding.title`),description:`变量绑定与批量套用:先看本平台有没有变量能力面,再读绑定、建变量、批量绑定;没有变量面的平台给替代路径`,argsSchema:n.object({target:n.string().optional().describe(`要绑定的节点或范围描述;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:tc(e==null?void 0:String(e),X())}}]})),u=e.registerPrompt(`variant-set`,{title:t.t(`prompt.variantSet.title`),description:`变体集构建:按能力位 inPlaceVariants 分流(原位合并 / 多主件兜底),含命名与建后回读复核`,argsSchema:n.object({family:n.string().optional().describe(`组件族名,如 Nav;留空只返回做法与分流`)})},({family:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:nc(e==null?void 0:String(e),X())}}]})),d=e.registerPrompt(`component-property`,{title:t.t(`prompt.componentProperty.title`),description:`组件属性的定义与设值:定义走平台 op、设值走 jsd_set_instance_properties,并按当前平台给出能收的值形态`,argsSchema:n.object({target:n.string().optional().describe(`组件或实例 id;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:rc(e==null?void 0:String(e),X())}}]}));return[r,i,a,o,e.registerPrompt(`auto-layout`,{title:t.t(`prompt.autoLayout.title`),description:t.t(`prompt.autoLayout.description`),argsSchema:n.object({target:n.string().optional().describe(`要上布局的容器 / 分区描述,如「标签栏」「参数行」;留空返回通用纪律`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Qs(e==null?void 0:String(e),X())}}]})),s,c,l,u,d,e.registerPrompt(`chart-by-code`,{title:t.t(`prompt.chartByCode.title`),description:t.t(`prompt.chartByCode.description`),argsSchema:n.object({chart:n.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」「各地区销售额占比环形图」「日活趋势面积图」`),svgPath:n.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)})},({chart:e,svgPath:t})=>({messages:[{role:`user`,content:{type:`text`,text:ac(String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function X(){return Ri()?.platform??null}function Ks(e,t){return e.split(`
|
|
57
57
|
`).map(e=>e===``?e:t+e).join(`
|
|
58
|
-
`)}function
|
|
58
|
+
`)}function qs(e){return Ri()?.capabilities.includes(e)===!0}function Js(e,t){return`请把下面的 HTML 转成设计稿。默认走 jsd_html_to_design(SVG 保真,忽略复杂样式);需要可编辑图层时才改用 per-type create 工具(jsd_create_frame 等)手工映射(容器→FRAME、文本→TEXT、图形→VECTOR)后 reparent 归组。\n\nHTML:\n\`\`\`\n${e}\n\`\`\`${t==null?``:`\n节点名:${t}`}`}function Ys(e,t=24,n=16){return`请插入图标网格:1) jsd_create_frame 建一个 FRAME 容器;2) 每个图标各调一次 jsd_create_icon(size=${t});3) jsd_reparent_nodes 把全部图标移入容器;4) jsd_set_layout 给容器设 auto-layout(layoutMode=HORIZONTAL,itemSpacing=${n},counterAxisAlignItems=CENTER)。\n图标列表: ${e}`}function Xs(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
|
|
59
59
|
1) 多步流程一次成型:优先 jsd_batch 编排(create→reparent→update、find→批量修改、图标×N 等);宿主有代码执行工具时也可写一段脚本连续 await 多个 tools.jsd_*。
|
|
60
60
|
⚠ **同一轮里不要并发发多个 MCP 调用** —— 每次转发上限 \`UI_FORWARD_TIMEOUT_MS = 25s\`(\`shared/src/connection.ts\`),它从「UI 发出请求」起算;而插件侧是一条单线程 + 单文档:真正碰画布的那次引擎调用会占住线程,谁在排队,谁的 25s 计时照样在走,到点就被判成「插件响应超时」。实测(即时设计 2026-10-15):单发 8 次全部成功;同一轮并发发 ≥2 个调用时 3/3 出现超时。而**把并发收进 jsd_batch 的多个步骤(批内本来就是顺序执行)后,同一条查询 1.82s 就跑完了**(含进程启动,量法:\`text-to-design-mcp exec <calls.json> --json\`)⇒ 超时几乎总是**排队**,不是查询本身慢;先怀疑「我是不是并发发了」,而不是去拆查询。
|
|
61
61
|
另一类是真的挂死(写入已落、回包永不返回,症状同样是 25s 超时,但重试无用):\`jsd_set_stroke\` 传 \`strokeStyleId\`、给**没有变体属性**的实例调 \`jsd_set_instance_properties\`、\`scope:"document"\` 触发的 \`loadAllPagesAsync\`(即时设计上它永不返回)。这类**别重试**,单独 \`jsd_find\` 回读一次确认是否已经落上(见第 8 条)。
|
|
@@ -78,7 +78,7 @@ Result keys per op (needed to write correct jsd_batch placeholders; a wrong key
|
|
|
78
78
|
|
|
79
79
|
9) **清单装不下就走文件,别把 id 搬进上下文**。jsd_batch 支持 callsFile(一个 JSON 文件的绝对路径,内容 {"calls":[…]} 或直接一个数组,可带 stopOnError / checkDrift);同一个文件也能用 CLI 直接跑 —— \`text-to-design-mcp exec <calls.json> [--json] [--dry-run]\`(dry-run 只校验清单;--json 把结果打成 JSON 供管道消费;任一步失败退出码为 1)。**不要**改去连 daemon 的本地端口或 import 本仓内部模块 —— 那是内部传输契约,不是给调用方用的接口。
|
|
80
80
|
|
|
81
|
-
10) **点名类错误不要重试**:字段不可绑 / 名字不唯一 / 平台签名不收 / 引用的步骤不存在,都是策略问题,重试只会同样失败。只有连接类抖动才值得重试。`}function
|
|
81
|
+
10) **点名类错误不要重试**:字段不可绑 / 名字不唯一 / 平台签名不收 / 引用的步骤不存在,都是策略问题,重试只会同样失败。只有连接类抖动才值得重试。`}function Zs(e,t){let n=e==null?`当前设计`:`「${e}」`,r=Ao(t,t==null?null:qs(ii.variants)),i=Io(t),a=Lo(t,t==null?null:Ri()?.capabilities.includes(`styleEnumeration`)===!0),o=zo(t);return`# 画布创作纪律
|
|
82
82
|
|
|
83
83
|
0) **先查可复用件,再动手**(设计类任务的第一步,别跳)。\`jsd_get_page\`(等价资源 \`jsd://page\`)给的是**设计系统资源清单** —— 看 \`assets.summary\` 一眼判断这文档有没有现成的件,再按类取 id 复用;样式另有一份清单 \`jsd://styles\`(\`styleEnumeration\` 未声明的平台上它与 \`assets.styles\` 一样恒空,见下面「看不到」那条)。这一条里只有两件事:**选对件类** 与 **走对入口**。
|
|
84
84
|
- **先判「要复用的是什么」,再选件类** —— 件类拿错,后面的动作全白做:
|
|
@@ -87,9 +87,9 @@ Result keys per op (needed to write correct jsd_batch placeholders; a wrong key
|
|
|
87
87
|
- **一组固定视觉**(色 / 字号字重 / 阴影效果)→ **样式**。
|
|
88
88
|
- **一个语义 token**(主色 / 间距 / 圆角,且要随模式或主题变)→ **变量**;本平台没有变量面就退回上一条的样式。
|
|
89
89
|
- 复用入口(按当前平台):
|
|
90
|
-
${
|
|
90
|
+
${Ks(i,` `)}
|
|
91
91
|
- **它们之间怎么连(三平台的接法完全不同,别照搬别家)**:
|
|
92
|
-
${
|
|
92
|
+
${Ks(a,` `)}
|
|
93
93
|
- **命中就复用,禁止新建重复件**:同名/同用途的组件、已有的变体取值、已有的颜色/文字/效果样式、已有的变量,一律先用现成的;清单里确实没有才新建,并按「组件族/状态」命名 —— 命名是它下一次能被命中的唯一依据。反向也一样别做过头:只出现一次的结构不必提组件(提了也没有第二次可复用),一次性装饰不必建样式。
|
|
94
94
|
- **清单是空的,先分清两种「看不到」** —— 判错就会白建一堆重复件:① **本平台读不出来**:样式与变量是能力门控面,平台未声明时 \`assets.styles\` / \`assets.variables\` **恒空**,回包 note 会点名「恒空:本平台未声明对应能力,这一面清单读不出来(不等于文档里没有)」;组件/变体集则可能因某页枚举失败而不全,note 里点名的是具体页名。别拿「看不到」当「没有」 —— 先用 \`jsd_find\` 按名字/类型再确认一遍;名字寻址(\`{{@comp:…}}\` / \`{{@var:…}}\`)读的是同一份清单,同样会不命中。② **确实没有** → 按下面从零建。
|
|
95
95
|
- **从零建的落点顺序:先做样板 → 抄成件 → 再铺开**,别先铺十个同样的再回头提炼(那时每个都要改一遍):
|
|
@@ -146,7 +146,7 @@ ${ks(a,` `)}
|
|
|
146
146
|
- 主按钮(FRAME + TEXT)
|
|
147
147
|
- 辅助链接(FRAME:忘记密码 TEXT + 注册 TEXT)
|
|
148
148
|
|
|
149
|
-
${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function
|
|
149
|
+
${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function Qs(e,t){let n=e==null?`目标分区`:`「${e}」`;return`# 自动布局(auto-layout)
|
|
150
150
|
|
|
151
151
|
**结论先行:同类子项沿一条轴排的容器,一律上 auto-layout。** 用绝对坐标钉同类子项是**欠账**,不是「先这样,以后再改」—— 间距散在 N 个节点上,改一次要改 N 遍,中间插一项要挪后面全部;而漏掉的那些容器,恰恰是间距唯一靠手调坐标凑的地方。
|
|
152
152
|
|
|
@@ -200,7 +200,7 @@ ${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回
|
|
|
200
200
|
|
|
201
201
|
## 3) 本平台可落性
|
|
202
202
|
|
|
203
|
-
${
|
|
203
|
+
${zo(t)}
|
|
204
204
|
|
|
205
205
|
## 4) 验收判据(四条,缺一条就是没落上)
|
|
206
206
|
|
|
@@ -230,7 +230,7 @@ ${So(t)}
|
|
|
230
230
|
- [ ] 没把「垂直居中」写成 layoutMode:VERTICAL
|
|
231
231
|
- [ ] 每个分区都能说出它的间距是哪条 \`itemSpacing\`;靠手调坐标凑的就是欠账
|
|
232
232
|
|
|
233
|
-
${n}按这条走;判据(该不该上、哪类容器最容易漏)见 \`jsd://recipes/design-strategy\` 第 4 条。`}function
|
|
233
|
+
${n}按这条走;判据(该不该上、哪类容器最容易漏)见 \`jsd://recipes/design-strategy\` 第 4 条。`}function $s(e){return`# 文本批量替换
|
|
234
234
|
|
|
235
235
|
## 1. 摸底与分块
|
|
236
236
|
- 对 ${e==null?`当前选中(先用 jsd_get_selection 拿到根 id)`:`节点 ${e}`} 先 jsd_get_selection 看结构,按语义把文本分成几块:表格按行或列、卡片按「同名字段一组」、表单按「标签 + 输入」一组、导航按菜单项一组。
|
|
@@ -248,7 +248,7 @@ ${n}按这条走;判据(该不该上、哪类容器最容易漏)见 \`jsd://reci
|
|
|
248
248
|
- 有问题先修当前块再继续下一块,不要把所有错误攒到最后。
|
|
249
249
|
|
|
250
250
|
## 5. 收尾
|
|
251
|
-
- 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function
|
|
251
|
+
- 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function ec(e,t){return`# 同类实例样式批量同步
|
|
252
252
|
|
|
253
253
|
## 适用场景
|
|
254
254
|
把一个实例的样式/文案套用到多个同类实例(卡片组、列表项、表单组……),避免逐个手改。
|
|
@@ -266,16 +266,16 @@ ${n}按这条走;判据(该不该上、哪类容器最容易漏)见 \`jsd://reci
|
|
|
266
266
|
- 引擎不支持时再退化为手工:jsd_set_fill_color / jsd_set_text 等 ids=[目标] 填字段 + jsd_set_instance_properties 设变体值。
|
|
267
267
|
|
|
268
268
|
## 4. 复核
|
|
269
|
-
- jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function
|
|
269
|
+
- jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function tc(e,t){let n=e??`目标节点`,r=Mo(t),i=(k(t,`variables`)?.write??[]).length>0,a=i?`## 3. 批量绑定别逐个往返
|
|
270
270
|
- 建变量时**一次传完**变量列表(失败整体回滚),拿到 collectionId 与 variables[].id;
|
|
271
|
-
${
|
|
271
|
+
${No(t)}
|
|
272
272
|
- 整条链(建变量 → 绑定 → 回读复核)合并进 jsd_batch:本批新建的中间 id 用 {{步骤id.字段路径}} 占位符(不回传模型),**已存在的组件 / 变量按名字取**用 {{@comp:名称}} / {{@var:名称}} —— 它读一次 jsd_get_page 的资源清单,省掉「先查 id 再拼批」那一趟往返;名字不唯一或没命中都会点名中止。
|
|
273
273
|
- ⚠ 名字一律按 assets 里**原样**写,不要照搬创建时用的路径:即时设计会把带斜杠的组件名拆成「集合 / 成分」,assets.components[].name 存的是叶子名(真机 2026-10-14:建「探针/组件」之后清单里叫「组件」,而「探针」落在 assets.variants 的集合名上)—— 按创建时那个路径写会不命中,没命中时错误里会给出现有名字。
|
|
274
274
|
- ⚠ 可建 / 可绑的变量类型:Figma 是 VariableResolvedDataType 六种(BOOLEAN / COLOR / EASING / FLOAT / STRING / TIMING),MG 是那 12 项(单值 STRING / BOOLEAN / COLOR / NUMBER + 复合样式 PAINT / TEXT / EFFECT / GRID / STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING)—— **两家都没有 VARIANT 类型** —— 「把变体属性绑到变量」在这两个平台上都不存在,别去试;切变体取值走 jsd_set_instance_properties。另两条容易混成一件事的:Figma 能把**组件属性值**(BOOLEAN / TEXT / INSTANCE_SWAP)绑变量,properties 的值传 {type, value:{type:'VARIABLE_ALIAS', id}};而「一个变量的值引用另一个变量」是**值形态**(把 {type:'VARIABLE_ALIAS', id} 作为 value 传给 figma_variables_create),不是第五种可建类型 —— EXPRESSION 与 VARIABLE_ALIAS 只出现在原型交互的 VariableData 表里,createVariable 的第三参收不了它们。
|
|
275
275
|
- ⚠ MG 那八项**复合样式类型建出来就是一条样式**(它自己带 paints / 排版子项),所以它只进 \`assets.variables\`、**不进** \`assets.styles\`;而 MG 的样式与变量**共用一套 id 空间且类别词汇重名** —— 删除时分入口:变量走 \`mg_variables_remove\`,样式走 \`jsd_delete_style\`,拿样式入口删变量会回包成功、变量真没了(真机 2026-10-14)。Figma 反过来:样式是**独立资源**,变量可以绑进样式里(改一次,所有引用该样式的节点都跟)—— 写用 \`figma_style_variables_apply\`、回读用 \`figma_style_variables_list\`,**词汇与节点档不同**:样式上那份填充叫 paints(不是 fills / strokes)、子字段固定 color,排版档(fontSize / lineHeight / …)只有 TEXT 样式能绑;要「这一个节点的某个字段跟变量」仍走 \`figma_variables_apply\`,两档别混。
|
|
276
276
|
|
|
277
277
|
## 4. 复核(写后必须回读)
|
|
278
|
-
${
|
|
278
|
+
${Po(t)}
|
|
279
279
|
- 结果的 warnings 一律读:绑定类字段被忽略时会在这里点名。`:`## 3. 本平台没有可用的变量入口,本节跳过
|
|
280
280
|
- 别去试变量 op(daemon 会拦成 platform_unsupported,白跑一趟往返)。
|
|
281
281
|
- 统一色板 / 间距照第 1 节末尾的替代路径做(那半句就是从事实表 \`variables.fallback\` 投影出来的,不在这里重写);要批量复用样式走 variant-sync 配方(COMPONENT + jsd_sync_overrides)。
|
|
@@ -288,12 +288,12 @@ ${_o(t)}
|
|
|
288
288
|
- 先确认这道题**该由变量来答**:只要一组固定视觉就够(不随模式/主题变)时走样式更轻,判据见 \`jsd://recipes/design-strategy\` 第 0 条。
|
|
289
289
|
|
|
290
290
|
## 2. 摸清现状再动手
|
|
291
|
-
${i?
|
|
291
|
+
${i?Fo(t):`- 本平台的读侧也不提供绑定字段,所以下面讲的字段形状只在有变量面的平台上成立 —— 看一眼知道有这回事即可,别在本平台找它。`}
|
|
292
292
|
|
|
293
|
-
${a}`}function
|
|
293
|
+
${a}`}function nc(e,t){return`# ${e==null?`组件族`:`组件族「${e}」`}的变体集构建
|
|
294
294
|
|
|
295
295
|
## 1. 先分流(判据是能力位,不是平台名)
|
|
296
|
-
- ${
|
|
296
|
+
- ${Ao(t,t==null?null:qs(ii.variants))}
|
|
297
297
|
|
|
298
298
|
## 2. 前置
|
|
299
299
|
- 先确认这道题**该由变体来答**:只是几处颜色/字号不同 → 样式;只是同一结构的几种状态 → 才是变体(判据见 \`jsd://recipes/design-strategy\` 第 0 条)。
|
|
@@ -303,14 +303,14 @@ ${a}`}function zs(e,t){return`# ${e==null?`组件族`:`组件族「${e}」`}的
|
|
|
303
303
|
|
|
304
304
|
## 3. 维度与取值怎么定
|
|
305
305
|
- 按第 1 节选定的路子走:**有**集合级管理入口的平台(名单见 jsd_ping 的 platformOps)直接建维度 / 改取值,**别**靠名字;**没有**的平台:变体属性由主件的**名字**承载,对不上就改名字后重新合并,别绕过名字硬塞属性值 —— 名字是引擎的入口,属性值是它的投影。
|
|
306
|
-
- 两条路子共同的验收:动完手立刻回读一次 —— 维度与**可选值**读组件集上的 \`variantGroupProperties\`(该平台没有这个字段时用平台提供的查看 op),单个节点的当前取值读 \`${
|
|
306
|
+
- 两条路子共同的验收:动完手立刻回读一次 —— 维度与**可选值**读组件集上的 \`variantGroupProperties\`(该平台没有这个字段时用平台提供的查看 op),单个节点的当前取值读 \`${k(t,`variants`)?.read??`variantProperties`}\`;确认引擎认的就是你要的那组再往下走。
|
|
307
307
|
|
|
308
308
|
## 4. 取用
|
|
309
309
|
- jsd_create_instance 按 COMPONENT 生成实例;切换状态用 jsd_set_instance_properties(变体属性传字符串,如 {"状态":"禁用"})。
|
|
310
310
|
|
|
311
311
|
## 5. 复核
|
|
312
312
|
- jsd_find 回读每个成员/实例的取值,确认属性与取值集合完整;
|
|
313
|
-
- jsd_export({ids:[集合id], scale:0.5}) 导小图确认成员排布与间距,回显不算验收。`}function
|
|
313
|
+
- jsd_export({ids:[集合id], scale:0.5}) 导小图确认成员排布与间距,回显不算验收。`}function rc(e,t){let n=e??`目标组件/实例`,r=jo(t),i=Ye(t,`setProperties`),a=i==null||i.includes(`boolean`),o=i==null||i.includes(`variableAlias`),s=[`- 变体属性传字符串(如 {"状态":"禁用"})。`,a?`- 布尔属性传布尔(如 {"显示图标":false});文本属性传字符串。`:`- **布尔 / 文本这类非字符串值不在本平台签名里**(见上一节)⇒ 没有签名支撑,传过去不算数。要这类效果就换设计:jsd_detach_instance 后直接改子节点,或改主组件让所有实例继承。`,o?'- 需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"};\n- 要让**组件属性的值跟随变量**(BOOLEAN / TEXT / INSTANCE_SWAP 三类)时,value 传 {"type":"VARIABLE_ALIAS","id":"VariableID:23:114"} —— 这是 Figma `setProperties` 签名里的一档(plugin-api.d.ts:11123),id 取自 figma_variables_list 或 {{@var:名称}}。⚠ **变体属性(VARIANT)不能这样绑**:变量类型表里没有 VARIANT,变体取值只能给字符串。':`- 换绑属性(INSTANCE_SWAP):本平台签名收**字符串**,所以直接传组件 id/键就行;**对象形态**({"type":"INSTANCE_SWAP",...})只有能收变量别名的签名才认(见上一节)。要整组件换绑用 jsd_swap_component。`,"- 值形态以本平台 `setProperties` 签名为准(见上一节),不在签名里的形态不是「会被忽略」而是「本就没这个入口」。"].join(`
|
|
314
314
|
`);return`# 组件属性的定义与设值(${n})
|
|
315
315
|
|
|
316
316
|
## 1. 分清两件事(混起来是最常见的错)
|
|
@@ -318,7 +318,7 @@ ${a}`}function zs(e,t){return`# ${e==null?`组件族`:`组件族「${e}」`}的
|
|
|
318
318
|
- **定义**:在 COMPONENT / COMPONENT_SET 上建属性。入口是平台 op,名单先经 jsd_ping 的 platformOps 确认(不同平台各自一套,没有统一入口)。
|
|
319
319
|
- **设值**:在 INSTANCE 上给值,三平台同名入口 \`jsd_set_instance_properties\`(不在组件本体上设值)。
|
|
320
320
|
|
|
321
|
-
## 2. 本平台的事实${t==null?`(未探测到平台 —— 下面按平台分别列出)`:`(${
|
|
321
|
+
## 2. 本平台的事实${t==null?`(未探测到平台 —— 下面按平台分别列出)`:`(${Yt[t]})`}
|
|
322
322
|
- ${r}
|
|
323
323
|
|
|
324
324
|
## 3. 值怎么传
|
|
@@ -338,8 +338,8 @@ ${s}
|
|
|
338
338
|
- 回读 componentProperties / variantProperties 的 value 与期望比对 —— 写后回读才算验收;
|
|
339
339
|
- ⚠ **回读通过 ≠ 画面变了**:属性可能成对存在(\`摘要\`/\`摘要2\`、\`显示铃铛\`/\`显示铃铛2\`),只有**连着可见图层**的那一组会改画面 —— 写错那组时\`componentProperties\` 全部回读为新值、回包 \`ok=true\`,画布却纹丝不动(Figma 真机实测)。所以第 4 节要先读 \`componentPropertyReferences\` 认准连着可见层的是哪一组,写完再用 jsd_find **深度读节点的实际内容 / 可见性**复核,别只看 \`componentProperties\` 的回显;
|
|
340
340
|
- 实例子节点(INSTANCE 内)的样式覆盖不保证渲染生效:命中时结果 warnings 会给出主组件里对应子节点的 id,改主组件即全实例继承;
|
|
341
|
-
- warnings 一律读:被忽略的字段、回读不一致(fontName 字重降级等)都在那里点名。`}var
|
|
342
|
-
`);function
|
|
341
|
+
- warnings 一律读:被忽略的字段、回读不一致(fontName 字重降级等)都在那里点名。`}var ic=[`// /tmp/chart.mjs —— 跑:node /tmp/chart.mjs`,`import { writeFileSync } from 'node:fs';`,``,`const data = [12, 18, 15, 26, 31, 28, 36];`,`const labels = ['一','二','三','四','五','六','日'];`,`const W = 640, H = 360, PAD = 24, YW = 44, XH = 20, TITLE = 22, GAP = 16;`,`const px = PAD + YW, py = PAD + TITLE + GAP; // 绘图区原点`,`const pw = W - PAD - px, ph = H - PAD - XH - py; // 绘图区尺寸`,`const half = pw / data.length / 2;`,``,`// 比例自己算:值域 → 像素区间,就这两行`,`const x = (i) => half + ((pw - half * 2) * i) / (data.length - 1);`,`const y = (v) => ph - (ph * v) / Math.max(...data);`,``,`// 折线:M 起点,其余逐段 L`,`const d = data`,` .map((v, i) => (i === 0 ? 'M' : 'L') + x(i).toFixed(1) + ' ' + y(v).toFixed(1))`,` .join(' ');`,``,`const parts = [];`,`parts.push('<svg xmlns="http://www.w3.org/2000/svg" width="' + W + '" height="' + H + '" viewBox="0 0 ' + W + ' ' + H + '">');`,`// 一个语义层一个 <g id>:导入后对得上,手改只进这一层(见第 5 节)`,`parts.push('<g id="title">');`,`parts.push('<text x="' + PAD + '" y="' + (PAD + 16) + '" font-family="-apple-system, PingFang SC, sans-serif" font-size="16" fill="#111827">周活跃</text>');`,`parts.push('</g>');`,`// 绘图区的 translate 只在最外层这一处,层内坐标从 0 起 —— 挪图只改这一个数`,`parts.push('<g id="plot" transform="translate(' + px + ',' + py + ')">');`,`parts.push('<g id="axis">');`,`parts.push('<rect x="0" y="' + (ph - 1) + '" width="' + pw + '" height="1" fill="#D1D5DB"/>');`,`parts.push('</g>');`,`parts.push('<g id="series-active">');`,`parts.push('<path d="' + d + '" fill="none" stroke="#3B82F6" stroke-width="2" stroke-linejoin="round"/>');`,`for (const [i, v] of data.entries()) {`,` parts.push('<circle cx="' + x(i).toFixed(1) + '" cy="' + y(v).toFixed(1) + '" r="3" fill="#3B82F6"/>');`,`}`,`parts.push('</g>');`,`parts.push('<g id="axis-labels">');`,`for (const [i, t] of labels.entries()) {`,` parts.push('<text x="' + x(i).toFixed(1) + '" y="' + (ph + 14) + '" font-size="11" fill="#6B7280" text-anchor="middle" font-family="-apple-system, sans-serif">' + t + '</text>');`,`}`,`parts.push('</g>');`,`parts.push('</g></svg>');`,``,`const svg = parts.join('');`,`writeFileSync('/tmp/chart.svg', svg);`,`console.log('bytes', Buffer.byteLength(svg));`].join(`
|
|
342
|
+
`);function ac(e,t){return`# 用代码画图表 / 数据可视化:算出 SVG → 落盘 → 导入画布
|
|
343
343
|
|
|
344
344
|
## 0. 前提:没有内置图表工具,这条路就是主路径
|
|
345
345
|
- **先判该不该用 SVG**:本配方适合「几何由数据算出来」的图(折线 / 面积 / 圆环 / 弧 / 热力条 / 带刻度坐标轴)—— 用矩形手拼这些要多几十倍节点还拼不准,换数据时回源重导也比在画布上挪一串节点便宜。**不适合**的三类:要排进 auto-layout 行列的、要绑变量/样式或要做成组件复用的、表格单元格与卡片骨架这类结构件 —— 这些必须原生节点(SVG **不吃布局**,\`vectorPaths.data\` 也不回读)。完整判据见 \`jsd://recipes/design-strategy\` 第 6 条。
|
|
@@ -401,7 +401,7 @@ ${s}
|
|
|
401
401
|
|
|
402
402
|
## 7. 最小可跑示例(零依赖:只用 \`Math\` 与数组;改 \`data\` 即可)
|
|
403
403
|
\`\`\`js
|
|
404
|
-
${
|
|
404
|
+
${ic}
|
|
405
405
|
\`\`\`
|
|
406
406
|
|
|
407
407
|
## 8. 复核清单
|
|
@@ -410,22 +410,22 @@ ${Vs}
|
|
|
410
410
|
- [ ] \`jsd_create_svg\` 结果里有 \`created.id\`(没有=没真导入);
|
|
411
411
|
- [ ] 导入后 \`jsd_find({ ids:[created.id], depth:2 })\` 看过层级:有子层就用,只有一层就按第 6 节另建要改的原生节点;
|
|
412
412
|
- [ ] \`jsd_export\` 出的图肉眼过一遍:轴、刻度、文字都在,没有元素跑到画布外;
|
|
413
|
-
- [ ] 文字要不要可编辑(见第 6 节)—— 要就把标题/图例另建原生节点,别全塞进 SVG 图层。`}function Us(e,t,n=[]){let r=e,i=r?.updated??[],a=[];i.length>0&&a.push({type:`text`,text:`已更新 ${i.length} 个节点`});let o=r?.warnings??[];for(let e of o)a.push({type:`text`,text:`⚠ ${e}`});if(i.length===0&&t.length===0&&a.push({type:`text`,text:`未传入任何属性,本次未修改`}),n.length>0){let e=new Set(i.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`以下节点未更新(可能已失效/被连坐删除): ${t.join(`, `)}。可用 jsd_find 复核后重试`})}return a}var Ws=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Q(e){let t=kr[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Oe[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+Ws,inputSchema:e.inputSchema,outputSchema:hn,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)=>Us(e,n(t),r(t))}}var Gs=Kr();function Ks(e,t,n){return[Q({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Gs}),method:`set_fill`,inputSchema:vr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),Q({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+Gs,method:`set_stroke`,inputSchema:yr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),Q({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+Gs,method:`set_corner_radius`,inputSchema:br,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),Q({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:Gs}),method:`set_text`,inputSchema:xr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),Q({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:Sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),Q({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:Cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Q({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设;但⚠ 开布局会按内容重算容器尺寸(有子节点时主轴被翻成 AUTO:实测 400×300 的容器 + 一个 200×60 子节点 → 200×60,而 sizingMode 字段回读仍是 FIXED,只有结果 warnings 点名),要保住尺寸就把 layoutMode 与 primaryAxisSizingMode / counterAxisSizingMode **放同一次调用里一起传 FIXED**(实测保得住)。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:wr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),Q({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+Gs,method:`set_effects`,inputSchema:Tr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),Q({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:Er,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Q({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:Dr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Q({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:Or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>H(r)(e,t,n))}function qs(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 Js(e,t,i){let a=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:ln,outputSchema:Cn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:Si,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,r)=>{let{ids:i,format:a,scale:s,savePath:u,includeDataUrl:f}=e,p=(await t.request(`export`,{ids:i,format:a,scale:s},{signal:r,timeout:6e4})).exports??{},m=[],h=[];for(let[e,t]of Object.entries(p)){let r=t.bytes,i=t.mimeType,a={id:e,name:t.name,format:t.format,mimeType:i,size:r.byteLength};if(u&&(n(l(u),{recursive:!0}),o(u,r),a.path=u),f){if(r.byteLength>wi){let n=u??d(c(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${qs(i,t.format)}`);u||o(n,r),a.path=n,h.push(`${e}(实际 ${r.byteLength} 字节 > 上限 ${wi} 字节)已落盘:${n}`)}else a.dataUrl=`data:${i};base64,${r.toString(`base64`)}`}m.push(a)}return{exports:m,dataUrlOverflow:h}},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}}),s=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:fn,outputSchema:hn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:Si,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:Si})}}),u=H({name:`jsd_list_fonts`,title:`listFonts.title`,description:`按家族名过滤、分页列出可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。**默认只回第一页**(50 族,上限 500):字体库规模随平台差一个量级——MasterGo 实测约 1900 族 / 整表 322 KB,整表必然撑爆上下文。结果里的 total 是过滤后的家族总数、truncated 表示还有下一页;按名字找字体传 family(不区分大小写的子串),翻页传 offset/limit。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,inputSchema:un,outputSchema:wn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}}),f=H({name:`jsd_create_style`,title:`createStyle.title`,description:`createStyle.description`,method:`create_style`,inputSchema:tr,outputSchema:An,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`createStyle.followUp`}}),p=H({name:`jsd_delete_style`,title:`deleteStyle.title`,description:`deleteStyle.description`,method:`delete_style`,inputSchema:nr,outputSchema:jn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_page`,description:`deleteStyle.followUp`}});return[a(e,t,i),s(e,t,i),u(e,t,i),f(e,t,i),p(e,t,i)]}var Ys=`jsd://recipes`,Xs=`jsd://recipes/{id}`,Zs=[{id:`design-strategy`,uri:`jsd://recipes/design-strategy`,titleKey:`prompt.designStrategy.title`,whenToUse:"画布创作的通用纪律。**从零设计整页 / 界面之前先读这一条**:先查可复用件(按「要复用的是什么」选件类 —— 结构走组件、状态走变体、固定视觉走样式、语义 token 走变量,含各平台复用入口与「命中就复用 / 改源头不逐个改实例」的纪律,以及**什么时候别抽组件**:差异落在实例子节点上、平台未声明 inPlaceVariants、往返预算压不住)、**样式落地流程**(归一化 → 建样式 → 绑 `*StyleId`,含即时设计的样式 id 记账与文本宽度归零的复核纪律),再摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局(**auto-layout 判据 + 最容易漏掉的分区清单**,机制见 `jsd://recipes/auto-layout`)、图形区走 SVG 还是原生图元的分流、间距与字号阶梯、层序与遮挡、出错回滚,附示例结构树",render:()=>Ps(void 0,Z())},{id:`auto-layout`,uri:`jsd://recipes/auto-layout`,titleKey:`prompt.autoLayout.title`,whenToUse:`**屏内分区排布一律先读这一条**。容器该不该上 auto-layout(判据 + 复核清单:标签栏 / 胶囊组 / 卡片头 / 列表行 / 整屏纵向分区 —— 这些恰是间距唯一靠手调坐标凑的地方)、两条落地路径(建容器时带 sizingMode=推荐 / 事后 set_layout 再用 resize 钉回尺寸)、执行顺序、平台硬约束(layoutWrap 等 Figma 字段本平台没有)、验收四条判据与常见坑(容器被 hug、TEXT 宽度被钉成 1px、手摆坐标在布局里不显形)`,argsHint:`参数 target(要上布局的容器 / 分区描述,如「标签栏」;留空返回通用纪律)`,render:()=>Fs(void 0,Z())},{id:`chart-by-code`,uri:`jsd://recipes/chart-by-code`,titleKey:`prompt.chartByCode.title`,whenToUse:`画图表 / 数据可视化(折线、柱状、饼图 / 环形、散点、雷达、面积、桑基、仪表盘、看板……)。自己写脚本算几何、落盘 SVG,再经 jsd_create_svg 的 svgPath 导入;含零依赖示例与引擎侧硬约束。不适合三类:要吃 auto-layout、要绑变量/样式、要复用成组件 —— 那些用原生节点`,argsHint:`参数 chart(要画什么图:种类 + 数据 + 口径)、svgPath(落盘路径,缺省 /tmp/chart.svg)`,render:()=>Hs(`<在此写明图表种类 + 数据 + 口径>`,void 0)},{id:`html-to-design`,uri:`jsd://recipes/html-to-design`,titleKey:`prompt.htmlToDesign.title`,whenToUse:`把 HTML 片段转成设计稿。默认走 jsd_html_to_design(SVG 保真、忽略复杂样式);要可编辑图层才改 per-type create 手工映射后 reparent 归组`,argsHint:`参数 html(完整 HTML 片段)、name(生成节点名,可省)`,render:()=>js(`<在此粘贴完整 HTML 片段>`)},{id:`icon-grid`,uri:`jsd://recipes/icon-grid`,titleKey:`prompt.iconGrid.title`,whenToUse:`批量插入 Lucide 图标并排成 auto-layout 网格`,argsHint:`参数 icons(逗号分隔的图标名)、size(默认 24)、gap(默认 16)`,render:()=>Ms(`<图标名1,图标名2,…>`)},{id:`script-ops`,uri:`jsd://recipes/script-ops`,titleKey:`prompt.scriptOps.title`,whenToUse:`把多步画布操作合并成一次 jsd_batch 编排或一段宿主脚本;步骤多、往返多、上下文吃紧时读它。也覆盖**整页/整档批量改造**(先摸底、确认现状形态、id 的三种来源、按块切批、清单装不下时用 callsFile 或 CLI exec、回读复核与点名类错误不重试)`,argsHint:`参数 task(要完成的任务,留空只返回脚本化调用纪律)`,render:()=>Ns(void 0)},{id:`text-replace-strategy`,uri:`jsd://recipes/text-replace-strategy`,titleKey:`prompt.textReplace.title`,whenToUse:`批量改文案:在一棵子树里定位并替换文本,含命中范围、命名与回显复核纪律`,argsHint:`参数 rootId(子树根节点 id,留空用当前选中)`,render:()=>Is(void 0)},{id:`variant-sync`,uri:`jsd://recipes/variant-sync`,titleKey:`prompt.variantSync.title`,whenToUse:`同类实例的样式批量同步。改一处要影响全部实例时走它 —— 改主组件而不是逐个改实例(含实例子节点覆盖不生效的处置)`,argsHint:`参数 sourceId(样板节点 id)、targetType(目标节点类型)`,render:()=>Ls(void 0,void 0)},{id:`variable-binding`,uri:`jsd://recipes/variable-binding`,titleKey:`prompt.variableBinding.title`,whenToUse:`变量绑定与批量套用(按当前平台变量面分流)`,argsHint:`参数 target(目标节点 id,留空用当前选中)`,render:()=>Rs(void 0,Z())},{id:`variant-set`,uri:`jsd://recipes/variant-set`,titleKey:`prompt.variantSet.title`,whenToUse:`变体集构建:把同族组件合成 COMPONENT_SET 并设变体属性(按平台能力位分流)`,argsHint:`参数 family(组件族名)`,render:()=>zs(void 0,Z())},{id:`component-property`,uri:`jsd://recipes/component-property`,titleKey:`prompt.componentProperty.title`,whenToUse:`组件属性的定义与设值(值形态 / 写入口 / 读侧 / 替代路径四件套,按平台分流)`,argsHint:`参数 target(组件或实例 id,留空只返回做法与分流)`,render:()=>Bs(void 0,Z())}];function Qs(e){return Zs.find(t=>t.id===e)}function $s(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,...Zs.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`。"].join(`
|
|
414
|
-
`)}function ec(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function tc(e){let t=Zs.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,Ys,{title:`resources.title7`,description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${t}`,mimeType:`text/markdown`},async()=>ec(Ys,$s())),e.registerResource(`recipe`,new ae(Xs,{list:void 0}),{title:`resources.title8`,description:`按 id 读取配方正文(markdown),如 ${Xs.replace(`{id}`,`chart-by-code`)}。可用 id:${t};索引与「何时用」见 ${Ys}`,mimeType:`text/markdown`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r,a=i==null?void 0:Qs(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${t})`);return ec(e,a.render())})]}function nc(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function rc(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()=>nc(`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()=>nc(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:`resources.title3`,description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名。⚠ 空清单不等于没有样式:本平台未声明样式枚举能力时恒空,回包会带 note 说明`,mimeType:`application/json`},async()=>nc(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:`resources.title4`,description:`**当前页**概览:①第一层节点的几何(id/名称/类型/宽高/x/y,不递归);②可复用资源清单(assets.summary 给四类计数;组件、变体集(带维度→可选值)、样式(PAINT/TEXT/EFFECT/GRID)、变量,每项含 id+名称)。范围:样式与变量是文档级;组件与变体在只读得到当前页的平台(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前先读这里:命中的一律复用,禁止新建重复件**。等价于 jsd_get_page`,mimeType:`application/json`},async()=>nc(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new ae(`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 nc(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()=>nc(`jsd://platform/state`,ji()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}function ic(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:ki.label}),description:n.t(`ping.description`,{client:ki.label}),outputSchema:gn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},alwaysEnabled:!0,timeout:xi,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:xi});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:Ut,outputSchema:_n,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getSelection.description2`}}),a=H({name:`jsd_get_page`,title:`getPage.title`,description:`getPage.description`,method:`get_page`,inputSchema:dn,outputSchema:kn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getPage.followUp`}});return[r(e,t,n),i(e,t,n),a(e,t,n)]}var ac=[ic,ls,Ts,Es,Co,Ks,ws,Js,lo,Ds,rc,tc,(e,t,n)=>Os(e,n)];function oc(e,t=ya()){let n=new ie({name:_i,version:L},{supportedProtocolVersions:[`2026-07-28`,..._],instructions:t.t(`mcp.instructions`),cacheHints:{"tools/list":{ttlMs:Ci,cacheScope:`private`},"prompts/list":{ttlMs:Ci,cacheScope:`private`},"resources/list":{ttlMs:Ci,cacheScope:`private`},"resources/templates/list":{ttlMs:Ci,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}});for(let r of ac)r(n,e,t);return n}var sc=null;async function cc(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ai);try{let n=await fetch(ii(e),{signal:t.signal});if(!n.ok)return P(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(P(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return P(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function lc(){let e=Date.now();if(sc!=null&&e-sc.at<18e5)return sc.latest;let[t,n]=await Promise.all([cc(ni.ui),cc(ni.mcp)]);return N(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),sc={at:e,latest:{ui:t,mcp:n}},sc.latest}async function uc(){let e=Date.now()+yi;do{let e=await Wi();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 Gi(250)}while(Date.now()<e);return await Vi()===null||(M(`已有 daemon 持有端口,本次启动跳过`),!1)}async function dc(e){if(!await uc()){await Ui();return}await e.start(gi),M(`daemon: 插件 WS ws://localhost:${e.port}`);let t=null,n=oe(()=>t??=oc(e),{legacy:`reject`}),r=pe(n),i=de(),a=fe(),o=null,s=null,c=()=>{lc().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){M(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),M(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=c;let l=t=>{M(`daemon 退出: ${t}`),s!=null&&clearInterval(s),n.close().catch(e=>{N(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),o?.close(),process.exit(0)};await new Promise((e,t)=>{o=ee((e,t)=>{if(!i(e,t)||!a(e,t))return;let n=Date.now(),o=e.url??``;if(t.on(`finish`,()=>{let r=`HTTP ${e.method} ${o} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?M(r):N(r)}),e.method===`GET`&&o===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:_i,version:L,pid:process.pid,startedAt:vi}));return}if(e.method===`POST`&&o===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>l(`收到 /shutdown 请求`),100);return}r(e,t)}),o.once(`error`,t),o.listen(I,`127.0.0.1`,()=>e())}),M(`daemon: MCP HTTP http://127.0.0.1:${I}/mcp`),M(`daemon 就绪,常驻运行(更新时由版本自检自动替换)`),s=setInterval(c,be),c(),process.on(`SIGINT`,()=>l(`SIGINT`))}async function fc(){await Ui();let e=await Wi();if(e.state===`foreign`)F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1);else if(e.state===`proxy`){await _a(e.client);return}e.state===`none`?(M(`未发现 daemon,自动拉起...`),sa()):M(`daemon 正在启动,等待就绪...`);let t=Date.now()+yi;for(;Date.now()<t;){await Gi(250);let e=await Wi();if(e.state===`proxy`){await _a(e.client);return}e.state===`foreign`&&(F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}F(`daemon 启动超时(${yi/1e3}s),请检查残留进程后重试`),process.exit(1)}var $=`text-to-design-mcp`;function pc(e){return e.includes(` `)?`"${e}"`:e}function mc(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function hc(){let e=f(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(p).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function gc(e,t){return[{kind:`write`,path:d(s(),`.config/systemd/user`,`${$}.service`),content:`[Unit]
|
|
415
|
-
Description=${
|
|
413
|
+
- [ ] 文字要不要可编辑(见第 6 节)—— 要就把标题/图例另建原生节点,别全塞进 SVG 图层。`}function oc(e,t,n=[]){let r=e,i=r?.updated??[],a=[];i.length>0&&a.push({type:`text`,text:`已更新 ${i.length} 个节点`});let o=r?.warnings??[];for(let e of o)a.push({type:`text`,text:`⚠ ${e}`});if(i.length===0&&t.length===0&&a.push({type:`text`,text:`未传入任何属性,本次未修改`}),n.length>0){let e=new Set(i.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`以下节点未更新(可能已失效/被连坐删除): ${t.join(`, `)}。可用 jsd_find 复核后重试`})}return a}var sc=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Z(e){let t=Nr[e.method],n=e=>t.filter(t=>e[t]!==void 0&&je[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+sc,inputSchema:e.inputSchema,outputSchema:vn,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)=>oc(e,n(t),r(t))}}var cc=Xr();function lc(e,t,n){return[Z({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:cc}),method:`set_fill`,inputSchema:Sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),Z({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+cc,method:`set_stroke`,inputSchema:Cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),Z({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+cc,method:`set_corner_radius`,inputSchema:wr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),Z({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:cc}),method:`set_text`,inputSchema:Tr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),Z({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:Er,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),Z({name:`jsd_resize_node`,title:`resizeNode.title`,description:`设置节点 width/height,并可同时传 x/y 一步完成「改尺寸 + 定位」(按坐标排布、批量摆位时常用,避免分两次调用让中间态被引擎自动尺寸/约束改写;reparent 已自动保持绝对位置,不需要用本工具摆回)。TEXT 默认自适应(WIDTH_AND_HEIGHT)时会覆盖显式尺寸,要固定文本框先 jsd_set_text 设 textAutoResize=NONE。横线/竖线用 LINE:零轴会被兜到 0.01 过引擎校验(存回读仍是 0);其他类型低于 0.01 会明确报错(引擎 resize 下限)`,method:`resize`,inputSchema:Dr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Z({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设;但⚠ 开布局会按内容重算容器尺寸(有子节点时主轴被翻成 AUTO:实测 400×300 的容器 + 一个 200×60 子节点 → 200×60,而 sizingMode 字段回读仍是 FIXED,只有结果 warnings 点名),要保住尺寸就把 layoutMode 与 primaryAxisSizingMode / counterAxisSizingMode **放同一次调用里一起传 FIXED**(实测保得住)。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:Or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),Z({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+cc,method:`set_effects`,inputSchema:kr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),Z({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:Ar,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Z({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:jr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Z({name:`jsd_set_shape`,title:`setShape.title`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:Mr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>V(r)(e,t,n))}function uc(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 dc(e,t,n){let r=V({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:fn,outputSchema:En,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:Oi,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:a,scale:o,savePath:s,includeDataUrl:l}=e,f=(await t.request(`export`,{ids:r,format:a,scale:o},{signal:n,timeout:6e4})).exports??{},m=[],h=[];for(let[e,t]of Object.entries(f)){let n=t.bytes,r=t.mimeType,a={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(i(d(s),{recursive:!0}),c(s,n),a.path=s),l){if(n.byteLength>Ai){let i=s??p(u(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${uc(r,t.format)}`);s||c(i,n),a.path=i,h.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${Ai} 字节)已落盘:${i}`)}else a.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}m.push(a)}return{exports:m,dataUrlOverflow:h}},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}}),o=V({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:hn,outputSchema:vn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:Oi,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`fillImage.description2`},run:async(e,t,n)=>{let{ids:r,sourcePath:i}=e,o;try{o=a(i)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:r,bytes:new Uint8Array(o)},{signal:n,timeout:Oi})}}),s=V({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:pn,outputSchema:Dn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}}),l=V({name:`jsd_create_style`,title:`createStyle.title`,description:`createStyle.description`,method:`create_style`,inputSchema:ar,outputSchema:Nn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`createStyle.followUp`}}),f=V({name:`jsd_delete_style`,title:`deleteStyle.title`,description:`deleteStyle.description`,method:`delete_style`,inputSchema:or,outputSchema:Pn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_page`,description:`deleteStyle.followUp`}});return[r(e,t,n),o(e,t,n),s(e,t,n),l(e,t,n),f(e,t,n)]}var fc=`jsd://recipes`,pc=`jsd://recipes/{id}`,mc=[{id:`design-strategy`,uri:`jsd://recipes/design-strategy`,titleKey:`prompt.designStrategy.title`,whenToUse:"画布创作的通用纪律。**从零设计整页 / 界面之前先读这一条**:先查可复用件(按「要复用的是什么」选件类 —— 结构走组件、状态走变体、固定视觉走样式、语义 token 走变量,含各平台复用入口与「命中就复用 / 改源头不逐个改实例」的纪律,以及**什么时候别抽组件**:差异落在实例子节点上、平台未声明 inPlaceVariants、往返预算压不住)、**样式落地流程**(归一化 → 建样式 → 绑 `*StyleId`,含即时设计的样式 id 记账与文本宽度归零的复核纪律),再摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局(**auto-layout 判据 + 最容易漏掉的分区清单**,机制见 `jsd://recipes/auto-layout`)、图形区走 SVG 还是原生图元的分流、间距与字号阶梯、层序与遮挡、出错回滚,附示例结构树",render:()=>Zs(void 0,X())},{id:`auto-layout`,uri:`jsd://recipes/auto-layout`,titleKey:`prompt.autoLayout.title`,whenToUse:`**屏内分区排布一律先读这一条**。容器该不该上 auto-layout(判据 + 复核清单:标签栏 / 胶囊组 / 卡片头 / 列表行 / 整屏纵向分区 —— 这些恰是间距唯一靠手调坐标凑的地方)、两条落地路径(建容器时带 sizingMode=推荐 / 事后 set_layout 再用 resize 钉回尺寸)、执行顺序、平台硬约束(layoutWrap 等 Figma 字段本平台没有)、验收四条判据与常见坑(容器被 hug、TEXT 宽度被钉成 1px、手摆坐标在布局里不显形)`,argsHint:`参数 target(要上布局的容器 / 分区描述,如「标签栏」;留空返回通用纪律)`,render:()=>Qs(void 0,X())},{id:`chart-by-code`,uri:`jsd://recipes/chart-by-code`,titleKey:`prompt.chartByCode.title`,whenToUse:`画图表 / 数据可视化(折线、柱状、饼图 / 环形、散点、雷达、面积、桑基、仪表盘、看板……)。自己写脚本算几何、落盘 SVG,再经 jsd_create_svg 的 svgPath 导入;含零依赖示例与引擎侧硬约束。不适合三类:要吃 auto-layout、要绑变量/样式、要复用成组件 —— 那些用原生节点`,argsHint:`参数 chart(要画什么图:种类 + 数据 + 口径)、svgPath(落盘路径,缺省 /tmp/chart.svg)`,render:()=>ac(`<在此写明图表种类 + 数据 + 口径>`,void 0)},{id:`html-to-design`,uri:`jsd://recipes/html-to-design`,titleKey:`prompt.htmlToDesign.title`,whenToUse:`把 HTML 片段转成设计稿。默认走 jsd_html_to_design(SVG 保真、忽略复杂样式);要可编辑图层才改 per-type create 手工映射后 reparent 归组`,argsHint:`参数 html(完整 HTML 片段)、name(生成节点名,可省)`,render:()=>Js(`<在此粘贴完整 HTML 片段>`)},{id:`icon-grid`,uri:`jsd://recipes/icon-grid`,titleKey:`prompt.iconGrid.title`,whenToUse:`批量插入 Lucide 图标并排成 auto-layout 网格`,argsHint:`参数 icons(逗号分隔的图标名)、size(默认 24)、gap(默认 16)`,render:()=>Ys(`<图标名1,图标名2,…>`)},{id:`script-ops`,uri:`jsd://recipes/script-ops`,titleKey:`prompt.scriptOps.title`,whenToUse:`把多步画布操作合并成一次 jsd_batch 编排或一段宿主脚本;步骤多、往返多、上下文吃紧时读它。也覆盖**整页/整档批量改造**(先摸底、确认现状形态、id 的三种来源、按块切批、清单装不下时用 callsFile 或 CLI exec、回读复核与点名类错误不重试)`,argsHint:`参数 task(要完成的任务,留空只返回脚本化调用纪律)`,render:()=>Xs(void 0)},{id:`text-replace-strategy`,uri:`jsd://recipes/text-replace-strategy`,titleKey:`prompt.textReplace.title`,whenToUse:`批量改文案:在一棵子树里定位并替换文本,含命中范围、命名与回显复核纪律`,argsHint:`参数 rootId(子树根节点 id,留空用当前选中)`,render:()=>$s(void 0)},{id:`variant-sync`,uri:`jsd://recipes/variant-sync`,titleKey:`prompt.variantSync.title`,whenToUse:`同类实例的样式批量同步。改一处要影响全部实例时走它 —— 改主组件而不是逐个改实例(含实例子节点覆盖不生效的处置)`,argsHint:`参数 sourceId(样板节点 id)、targetType(目标节点类型)`,render:()=>ec(void 0,void 0)},{id:`variable-binding`,uri:`jsd://recipes/variable-binding`,titleKey:`prompt.variableBinding.title`,whenToUse:`变量绑定与批量套用(按当前平台变量面分流)`,argsHint:`参数 target(目标节点 id,留空用当前选中)`,render:()=>tc(void 0,X())},{id:`variant-set`,uri:`jsd://recipes/variant-set`,titleKey:`prompt.variantSet.title`,whenToUse:`变体集构建:把同族组件合成 COMPONENT_SET 并设变体属性(按平台能力位分流)`,argsHint:`参数 family(组件族名)`,render:()=>nc(void 0,X())},{id:`component-property`,uri:`jsd://recipes/component-property`,titleKey:`prompt.componentProperty.title`,whenToUse:`组件属性的定义与设值(值形态 / 写入口 / 读侧 / 替代路径四件套,按平台分流)`,argsHint:`参数 target(组件或实例 id,留空只返回做法与分流)`,render:()=>rc(void 0,X())}];function hc(e){return mc.find(t=>t.id===e)}function gc(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,...mc.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`。"].join(`
|
|
414
|
+
`)}function _c(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function vc(e){let t=mc.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,fc,{title:`resources.title7`,description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${t}`,mimeType:`text/markdown`},async()=>_c(fc,gc())),e.registerResource(`recipe`,new ae(pc,{list:void 0}),{title:`resources.title8`,description:`按 id 读取配方正文(markdown),如 ${pc.replace(`{id}`,`chart-by-code`)}。可用 id:${t};索引与「何时用」见 ${fc}`,mimeType:`text/markdown`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r,a=i==null?void 0:hc(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${t})`);return _c(e,a.render())})]}function yc(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function bc(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()=>yc(`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()=>yc(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:`resources.title3`,description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名。⚠ 空清单不等于没有样式:本平台未声明样式枚举能力时恒空,回包会带 note 说明`,mimeType:`application/json`},async()=>yc(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:`resources.title4`,description:`**当前页**概览:①第一层节点的几何(id/名称/类型/宽高/x/y,不递归);②可复用资源清单(assets.summary 给四类计数;组件、变体集(带维度→可选值)、样式(PAINT/TEXT/EFFECT/GRID)、变量,每项含 id+名称)。范围:样式与变量是文档级;组件与变体在只读得到当前页的平台(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前先读这里:命中的一律复用,禁止新建重复件**。等价于 jsd_get_page`,mimeType:`application/json`},async()=>yc(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new ae(`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 yc(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()=>yc(`jsd://platform/state`,Ri()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}function xc(e,t,n){let r=V({name:`jsd_ping`,title:n.t(`ping.title`,{client:Fi.label}),description:n.t(`ping.description`,{client:Fi.label}),outputSchema:yn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},alwaysEnabled:!0,timeout:Di,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:Di});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=V({name:`jsd_get_selection`,title:`getSelection.title`,description:`getSelection.description`,method:`get_selection`,inputSchema:Kt,outputSchema:bn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getSelection.description2`}}),a=V({name:`jsd_get_page`,title:`getPage.title`,description:`getPage.description`,method:`get_page`,inputSchema:mn,outputSchema:Mn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getPage.followUp`}});return[r(e,t,n),i(e,t,n),a(e,t,n)]}var Sc=[xc,Es,Hs,Us,Bo,lc,Vs,dc,Do,Ws,bc,vc,(e,t,n)=>Gs(e,n)];function Cc(e,t=Ia()){let n=new ie({name:Ci,version:I},{supportedProtocolVersions:[`2026-07-28`,..._],instructions:t.t(`mcp.instructions`),cacheHints:{"tools/list":{ttlMs:ki,cacheScope:`private`},"prompts/list":{ttlMs:ki,cacheScope:`private`},"resources/list":{ttlMs:ki,cacheScope:`private`},"resources/templates/list":{ttlMs:ki,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}});for(let r of Sc)r(n,e,t);return n}var wc=`https://telemetry.text-to-design.wzrove.com/v1/errors`,Tc=`dev-insecure-key`,Ec=process.env.TEXT_TO_DESIGN_TELEMETRY_URL??wc,Dc=process.env.TEXT_TO_DESIGN_TELEMETRY_KEY??Tc,Oc=p(l(),`.text-to-design`),kc=p(Oc,`install-id`),Ac=50,jc=100,Mc=12e4,Q=[],Nc=``,Pc=!1;async function Fc(){if(Nc!==``)return Nc;try{let e=(await he(kc,`utf8`)).trim();if(e.length>=8)return Nc=e,e}catch{}Nc=xe();try{await me(Oc,{recursive:!0}),await _e(kc,`${Nc}\n`,`utf8`)}catch{}return Nc}function Ic(e,t,n,r){if(Ec===``||Dc===``||!Ma())return;for(let e=Q.length-1;e>=0;e--){let n=Q[e];if(n.message===t){n.count=(n.count??1)+1;return}}let i=Ri()?.platform;Q.push({level:e,message:t.slice(0,8e3),stack:n?.slice(0,2e4),context:i==null?r:{...r??{},platform:i}}),Q.length>jc&&Q.splice(0,Q.length-jc)}async function Lc(e=5e3){if(Pc||Q.length===0||Ec===``||Dc===``||!Ma())return;Pc=!0;let t=Q.slice(0,Ac);try{let n=await Fc(),r=await fetch(Ec,{method:`POST`,headers:{authorization:`Bearer ${Dc}`,"content-type":`application/json`},body:JSON.stringify({user:{fingerprint:n,mcpVersion:I,clientVersion:Bi()??void 0},errors:t}),signal:AbortSignal.timeout(e)});if(!r.ok){M(`遥测上报失败: HTTP ${r.status}`);return}Q=Q.slice(t.length)}catch(e){M(`遥测上报失败: ${e instanceof Error?e.message:String(e)}`)}finally{Pc=!1}}function Rc(){if(Ec===``||Dc===``)return null;let e=setInterval(()=>void Lc(),Mc);return e.unref(),()=>clearInterval(e)}var zc=null;async function Bc(e){let t=new AbortController,n=setTimeout(()=>t.abort(),li);try{let n=await fetch(ci(e),{signal:t.signal});if(!n.ok)return N(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(N(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return N(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function Vc(){let e=Date.now();if(zc!=null&&e-zc.at<18e5)return zc.latest;let[t,n]=await Promise.all([Bc(oi.ui),Bc(oi.mcp)]);return M(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),zc={at:e,latest:{ui:t,mcp:n}},zc.latest}async function Hc(){let e=Date.now()+Ti;do{let e=await $i();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 ea(250)}while(Date.now()<e);return await Xi()===null||(j(`已有 daemon 持有端口,本次启动跳过`),!1)}async function Uc(e){if(!await Hc()){await Qi();return}await ja(),await e.start(Si),j(`daemon: 插件 WS ws://localhost:${e.port}`);let t=Rc(),n=null,r=oe(()=>n??=Cc(e),{legacy:`reject`}),i=pe(r),a=de(),o=fe(),s=null,c=null,l=()=>{Vc().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){j(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),j(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=()=>{e.pushConsent({type:`consent`,granted:Ma(),asked:Na()}),l()},e.onConsentSet=t=>{Pa(t),j(`错误上报同意: ${t?`开启`:`关闭`}`),e.pushConsent({type:`consent`,granted:t,asked:!0})},process.on(`uncaughtException`,e=>{Ic(`fatal`,e.message,e.stack),Lc(3e3).finally(()=>process.exit(1))}),process.on(`unhandledRejection`,e=>{Ic(`fatal`,e instanceof Error?e.message:String(e),e instanceof Error?e.stack:void 0),Lc(3e3).finally(()=>process.exit(1))});let u=n=>{j(`daemon 退出: ${n}`),c!=null&&clearInterval(c),t?.(),Lc(1500).finally(()=>{r.close().catch(e=>{M(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),s?.close(),process.exit(0)})};await new Promise((e,t)=>{s=ee((e,t)=>{if(!a(e,t)||!o(e,t))return;let n=Date.now(),r=e.url??``;if(t.on(`finish`,()=>{let i=`HTTP ${e.method} ${r} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?j(i):M(i)}),e.method===`GET`&&r===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:Ci,version:I,pid:process.pid,startedAt:wi}));return}if(e.method===`POST`&&r===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>u(`收到 /shutdown 请求`),100);return}i(e,t)}),s.once(`error`,t),s.listen(F,`127.0.0.1`,()=>e())}),j(`daemon: MCP HTTP http://127.0.0.1:${F}/mcp`),j(`daemon 就绪,常驻运行(更新时由版本自检自动替换)`),c=setInterval(l,Se),l(),process.on(`SIGINT`,()=>u(`SIGINT`))}async function Wc(){await Qi();let e=await $i();if(e.state===`foreign`)P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1);else if(e.state===`proxy`){await Ea(e.client);return}e.state===`none`?(j(`未发现 daemon,自动拉起...`),ga()):j(`daemon 正在启动,等待就绪...`);let t=Date.now()+Ti;for(;Date.now()<t;){await ea(250);let e=await $i();if(e.state===`proxy`){await Ea(e.client);return}e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}P(`daemon 启动超时(${Ti/1e3}s),请检查残留进程后重试`),process.exit(1)}var $=`text-to-design-mcp`;function Gc(e){return e.includes(` `)?`"${e}"`:e}function Kc(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function qc(){let e=m(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(h).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Jc(e,t){return[{kind:`write`,path:p(l(),`.config/systemd/user`,`${$}.service`),content:`[Unit]
|
|
415
|
+
Description=${Ci} (design plugin bridge: WS ${Si} / MCP HTTP ${F})
|
|
416
416
|
Documentation=https://github.com/wzrove/text-to-design
|
|
417
417
|
After=network.target
|
|
418
418
|
|
|
419
419
|
[Service]
|
|
420
420
|
Type=simple
|
|
421
421
|
Environment=TEXT_TO_DESIGN_MCP_ROLE=daemon
|
|
422
|
-
ExecStart=${
|
|
422
|
+
ExecStart=${Gc(e)} ${Gc(t)} daemon
|
|
423
423
|
Restart=on-failure
|
|
424
424
|
RestartSec=2
|
|
425
425
|
|
|
426
426
|
[Install]
|
|
427
427
|
WantedBy=default.target
|
|
428
|
-
`},{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
|
|
428
|
+
`},{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 Yc(e,t){let n=p(l(),`Library/LaunchAgents`,`com.${$}.plist`),r=p(l(),`Library/Logs`,`${$}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
429
429
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
430
430
|
<plist version="1.0">
|
|
431
431
|
<dict>
|
|
@@ -433,8 +433,8 @@ WantedBy=default.target
|
|
|
433
433
|
<string>com.${$}</string>
|
|
434
434
|
<key>ProgramArguments</key>
|
|
435
435
|
<array>
|
|
436
|
-
<string>${
|
|
437
|
-
<string>${
|
|
436
|
+
<string>${Kc(e)}</string>
|
|
437
|
+
<string>${Kc(t)}</string>
|
|
438
438
|
<string>daemon</string>
|
|
439
439
|
</array>
|
|
440
440
|
<key>EnvironmentVariables</key>
|
|
@@ -450,12 +450,12 @@ WantedBy=default.target
|
|
|
450
450
|
<false/>
|
|
451
451
|
</dict>
|
|
452
452
|
<key>StandardOutPath</key>
|
|
453
|
-
<string>${
|
|
453
|
+
<string>${Kc(r)}</string>
|
|
454
454
|
<key>StandardErrorPath</key>
|
|
455
|
-
<string>${
|
|
455
|
+
<string>${Kc(r)}</string>
|
|
456
456
|
</dict>
|
|
457
457
|
</plist>
|
|
458
|
-
`;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
|
|
459
|
-
`);return}let i=await
|
|
460
|
-
`);process.stderr.write(`\n${t}\n`)}}let a=e.structuredContent?.ok===!1;(e.isError===!0||a)&&(process.exitCode=1)}finally{await i.close().catch(()=>{})}}async function
|
|
461
|
-
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await
|
|
458
|
+
`;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 Xc(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,$,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${$}`}]}function Zc(e,t){return process.platform===`linux`?Jc(e,t):process.platform===`darwin`?Yc(e,t):process.platform===`win32`?Xc(e,t):[]}function Qc(){if(process.platform===`linux`){let e=p(l(),`.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=p(l(),`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 $c(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}i(d(e.path),{recursive:!0}),c(e.path,e.content,`utf8`),j(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){j(`[dry-run] 删除 ${e.path}`);return}o(e.path,{force:!0}),j(`已删除 ${e.path}`);return}if(t){j(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let n=ue(e.cmd,e.args,{encoding:`utf8`});if(n.error){N(`执行失败(${e.cmd}):${n.error.code??n.error.message} —— 定义文件已就位,可手动启用`);return}if(n.status!==0){N(`${e.cmd} 退出码 ${n.status}: ${(n.stderr??``).trim().slice(0,200)}`);return}j(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function el(e,t){e.length===0&&(P(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)$c(n,t)}function tl(e={}){let t=qc(),n,r;`problem`in t?(e.force||(P(t.problem),process.exit(1)),N(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=m(process.argv[1]??``)):(n=t.exe,r=t.script),j(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),el(Zc(n,r),e.dryRun===!0),e.dryRun||j(`完成。校验:curl -s http://127.0.0.1:${F}/health(应返回 ${Ci} ${I})`)}function nl(e={}){j(`${e.dryRun?`[dry-run] `:``}注销自启`),el(Qc(),e.dryRun===!0)}async function rl(){let e=Date.now()+Ti;for(;Date.now()<e;){let e=await $i();if(e.state===`proxy`)return e.client;if(e.state===`foreign`)throw Error(`MCP 端口被**非本项目**的服务占用,exec 不会去猜它是什么。请先释放端口(见 daemon 启动日志里的排查提示)。`);e.state===`none`&&ga(process.argv.slice(1,2)),await ea(250)}throw Error(`等待 daemon 就绪超时(${Ti}ms)。若刚从旧版本升级,旧 daemon 可能还没释放端口,稍后重试即可。`)}function il(e,t,n,r){let i=e=>{r?process.stderr.write(`${e}\n`):process.stdout.write(`${e}\n`)};i(`清单 ${e}`),i(`共 ${t.length} 步${n?`(任一步失败即停)`:`(失败继续,由单步 continueOnError 决定)`}`);for(let[e,n]of t.entries())i(` ${String(e+1).padStart(2)}. ${n.id==null||n.id===``?`step${e+1}`:n.id} → ${n.tool}`)}async function al(e,t){let n=await Ra(e),r=n.stopOnError??!0;if(il(n.path,n.calls,r,t.json===!0),t.dryRun===!0){process.stdout.write(`--dry-run:只校验了清单,未连接 daemon,未执行任何步骤。
|
|
459
|
+
`);return}let i=await rl();try{let e=await i.callTool({name:`jsd_batch`,arguments:{calls:n.calls,stopOnError:r,checkDrift:n.checkDrift}},{timeout:ji+3e4});if(t.json===!0)process.stdout.write(`${JSON.stringify(e.structuredContent??e,null,1)}\n`);else{let t=e.structuredContent;for(let e of t?.results??[])process.stdout.write(` ${e.ok?`ok `:`ERR`} ${e.id} (${e.tool})${e.ok?``:`: ${e.error??``}`}\n`);process.stdout.write(`\n执行 ${t?.executed??0}/${t?.total??n.calls.length}${t?.ok===!1?`,存在失败步骤`:`,全部成功`}\n`);for(let e of t?.warnings??[])process.stdout.write(`warn ${e}\n`);if(e.isError===!0){let t=(e.content??[]).map(e=>`text`in e&&typeof e.text==`string`?e.text:``).join(`
|
|
460
|
+
`);process.stderr.write(`\n${t}\n`)}}let a=e.structuredContent?.ok===!1;(e.isError===!0||a)&&(process.exitCode=1)}finally{await i.close().catch(()=>{})}}async function ol(e){let t=e.find(e=>!e.startsWith(`-`)),n={json:e.includes(`--json`),dryRun:e.includes(`--dry-run`)};if(t==null){P(`用法:text-to-design-mcp exec <calls.json> [--json] [--dry-run]
|
|
461
|
+
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await al(t,n)}catch(e){P(e instanceof Error?e.message:String(e)),process.exitCode=1}}var sl=new Yi;sl.onConnectionChange=e=>{if(j(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录不变)`),e){Ui(sl);return}Hi(`插件断开`)},gi((e,t)=>{e===`error`&&Ic(`error`,t),sl.notifyLog(e,t)});var cl=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),ll=process.argv.slice(2),ul=ll.find(e=>e===`install-service`||e===`uninstall-service`),dl=ll[0]===`exec`&&!cl;if(ul){gi((e,t)=>{(e===`error`||e===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${t}\n`)});let e={dryRun:ll.includes(`--dry-run`),force:ll.includes(`--force`)};ul===`install-service`?tl(e):nl(e)}else dl?(gi((e,t)=>{process.stderr.write(`[text-to-design-mcp] ${t}\n`)}),ol(ll.slice(1))):cl?Uc(sl).catch(e=>{sl.stop(),P(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):Wc().catch(e=>{P(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
|