text-to-design-mcp 0.12.1 → 0.13.1
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 +116 -60
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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,join as u,resolve as d,sep as f}from"node:path";import{core as p,z as m}from"zod";import{createServer as h}from"node:http";import{WebSocket as ee,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 oe,createMcpHandler as se,fromJsonSchema as ce}from"@modelcontextprotocol/server";import{serveStdio as le}from"@modelcontextprotocol/server/stdio";import{spawn as ue,spawnSync as de}from"node:child_process";import{localhostHostValidation as fe,localhostOriginValidation as pe,toNodeHandler as me}from"@modelcontextprotocol/node";import{isTag as he}from"domhandler";import{parseDocument as ge}from"htmlparser2";import _e from"fuse.js";var g=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function ve(e){return e instanceof g?e.code:`plugin_error`}var ye=3e4,be=4e3;2*ye;var xe=3e4,Se={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},styleEnumeration:{kind:`flow`,labelKey:`capability.host.styleEnumeration`},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 Ce(e){return Object.keys(e)}var we=Ce(Se);Object.fromEntries(Object.entries(Se).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var Te=Object.fromEntries(Object.entries(Se).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),Ee=Ce({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`}}),De={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 Oe(e,t){let n=De[e];return n==null||n.some(e=>e===t)}var ke=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],Ae={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},je=ke.join(`/`),Me=`布尔运算:${ke.map(e=>`${e}=${Ae[e]}`).join(`,`)}`,Ne=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Pe=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Fe=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Ie=[`MIN`,`CENTER`,`MAX`],Le=[`mastergo`],Re={blendMode:Ne,layoutAlign:Pe,primaryAxisAlignItems:Fe,counterAxisAlignItems:Ie},ze={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},Be={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},Ve={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 He(e,t){if(e==null)return null;let n=Ve[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=ze[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function Ue(e,t,n){let r=He(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 We(e,t,n){if(e==null)return!0;let r=Be[e]?.[t];return r==null||!r.some(e=>e===n)}function Ge(e,t){let n=He(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(Re[t]??[]).filter(n=>Ue(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var Ke=[`string`,`boolean`,`variableAlias`],qe={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function Je(e,t){if(e==null)return null;let n=qe[e]?.[t]?.deny??[];return Ke.filter(e=>!n.some(t=>t===e))}function Ye(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 Xe=m.object({r:m.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.r`),g:m.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.g`),b:m.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.b`),a:m.number().min(0).max(255,`alpha 通道最大 255`).optional().describe(`schema.base.a`)}).strict(),Ze=`颜色需为 {r,g,b[,a]} 对象(通道 0-1;任一路 >1 视为 0-255,自动整组 /255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,Qe=m.unknown().superRefine((e,t)=>{if(typeof e==`string`){Ye(e)??t.addIssue({code:m.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${Ze})`});return}let n=Xe.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:m.ZodIssueCode.custom,path:e.path,message:e.message})}),$e=Qe.describe(`颜色:{r,g,b} 对象(通道 0-1,>1 视为 0-255 自动归一化)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),et=Qe.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,>1 视为 0-255 自动归一化;a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),tt=m.object({color:et.describe(`schema.base.color`),position:m.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}(终点蓝色)`),nt=m.array(m.array(m.number()).length(3)).length(2).describe(`schema.base.transformSchema`),_=m.enum(Ne).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),v=m.discriminatedUnion(`type`,[m.object({type:m.literal(`SOLID`).describe(`schema.base.type`),color:$e.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:m.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:m.boolean().optional().describe(`schema.base.visible`),blendMode:_.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),m.object({type:m.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:m.array(tt).describe(`schema.base.gradientStops`),gradientTransform:nt}).strict().describe(`schema.base.gradientTransform`),m.object({type:m.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:m.array(tt).describe(`schema.base.gradientStops2`),gradientTransform:nt}).strict().describe(`schema.base.gradientTransform2`),m.object({type:m.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:m.array(tt).describe(`schema.base.gradientStops3`),gradientTransform:nt}).strict().describe(`schema.base.gradientTransform3`),m.object({type:m.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:m.string().describe(`schema.base.imageHash`),scaleMode:m.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schema.base.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),rt=m.discriminatedUnion(`type`,[m.object({type:m.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:et.describe(`schema.base.color2`),offset:m.object({x:m.number().describe(`schema.base.x`),y:m.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:m.number().min(0).describe(`schema.base.radius`),spread:m.number().optional().describe(`schema.base.spread`),visible:m.boolean().optional().describe(`schema.base.visible2`),blendMode:_.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:m.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),m.object({type:m.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:et.describe(`schema.base.color3`),offset:m.object({x:m.number().describe(`schema.base.x2`),y:m.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:m.number().min(0).describe(`schema.base.radius2`),spread:m.number().optional().describe(`schema.base.spread2`),visible:m.boolean().optional().describe(`schema.base.visible3`),blendMode:_.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),m.object({type:m.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:m.number().min(0).describe(`schema.base.radius3`),visible:m.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),m.object({type:m.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:m.number().min(0).describe(`schema.base.radius4`),visible:m.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),it=m.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),at=m.object({pattern:m.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:m.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:m.number().optional().describe(`schema.base.sectionSize`),count:m.number().int().positive().optional(),gutterSize:m.number().optional().describe(`schema.base.gutterSize`),offset:m.number().optional().describe(`schema.base.offset`),visible:m.boolean().optional(),color:et.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:m.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:m.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${n} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[n]})}),ot=m.object({data:m.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:m.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),st=m.object({family:m.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:m.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),ct=m.union([m.object({value:m.number().describe(`schema.base.value`),unit:m.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),m.object({value:m.number().describe(`schema.base.value2`),unit:m.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),m.object({unit:m.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),lt=m.object({value:m.number(),unit:m.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),ut=m.object({id:m.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:m.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:m.record(m.string(),m.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符(步骤id.字段路径)引用先前步骤结果。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:m.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),dt=m.object({calls:m.array(ut).min(1).max(50).describe(`schema.batch.calls`),stopOnError:m.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:m.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),ft=m.object({ok:m.boolean().describe(`schema.batch.ok`),executed:m.number().int().min(0).describe(`schema.batch.executed`),total:m.number().int().min(0).describe(`schema.batch.total`),results:m.array(m.object({id:m.string(),tool:m.string(),ok:m.boolean(),data:m.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:m.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:m.boolean().optional(),warnings:m.array(m.string()).optional()}),pt=m.object({ok:m.boolean(),data:m.unknown().optional()}),mt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],ht={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},gt=`节点类型:${mt.map(e=>`${e}=${ht[e]}`).join(` | `)}`,_t=[`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`],vt=[`INTELLIGENT_CONTAINER`],yt=[...mt,..._t,...vt],bt=m.enum(mt).describe(gt),xt=m.enum(yt).describe(`${gt};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),St=m.object({type:bt.describe(`schema.executeSchemas.type`),name:m.string().optional(),x:m.number().optional().describe(`schema.executeSchemas.x`),y:m.number().optional().describe(`schema.executeSchemas.y`),width:m.number().optional(),height:m.number().optional()}).catchall(m.unknown()),y={name:m.string().optional(),x:m.number().optional().describe(`schema.executeSchemas.x2`),y:m.number().optional().describe(`schema.executeSchemas.y2`),width:m.number().optional().describe(`schema.executeSchemas.width`),height:m.number().optional().describe(`schema.executeSchemas.height`),rotation:m.number().optional().describe(`schema.executeSchemas.rotation`),opacity:m.number().optional().describe(`schema.executeSchemas.opacity`),visible:m.boolean().optional(),locked:m.boolean().optional(),isMask:m.boolean().optional(),children:m.array(St).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:m.array(v).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:m.array(v).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:m.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:m.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:m.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:m.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:m.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:m.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:m.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.executeSchemas.strokeCap`),strokeJoin:m.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.executeSchemas.strokeJoin`),dashPattern:m.array(m.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:_.optional(),effects:m.array(rt).optional().describe(`schema.executeSchemas.effects`),constraints:m.object({horizontal:it.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:it.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:m.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:m.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:m.array(at).optional().describe(`schema.executeSchemas.layoutGrids`)},Ct={cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:m.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:m.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:m.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:m.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)},wt=m.object({type:m.literal(`FRAME`),...y,layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:m.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:m.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:m.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:m.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:m.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`),...Ct,...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:m.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}]`),Tt=m.object({type:m.literal(`RECTANGLE`),...y,...Ct,...b}).strict().describe(`schema.executeSchemas.type2`),Et=m.object({type:m.literal(`ELLIPSE`),...y,cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius2`),arcData:m.object({startingAngle:m.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:m.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:m.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schema.executeSchemas.innerRadius2`),...b}).strict().describe(`schema.executeSchemas.innerRadius3`),Dt=m.object({type:m.literal(`LINE`),...y,...b}).strict().describe(`schema.executeSchemas.type3`),Ot=m.object({type:m.literal(`POLYGON`),...y,pointCount:m.number().describe(`schema.executeSchemas.pointCount`),cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius3`),topLeftRadius:m.number().optional().describe(`schema.executeSchemas.topLeftRadius2`),topRightRadius:m.number().optional().describe(`schema.executeSchemas.topRightRadius2`),bottomLeftRadius:m.number().optional().describe(`schema.executeSchemas.bottomLeftRadius2`),bottomRightRadius:m.number().optional().describe(`schema.executeSchemas.bottomRightRadius2`),...b}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),kt=m.object({type:m.literal(`STAR`),...y,pointCount:m.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:m.number().describe(`schema.executeSchemas.innerRadius4`),cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius4`),topLeftRadius:m.number().optional().describe(`schema.executeSchemas.topLeftRadius3`),topRightRadius:m.number().optional().describe(`schema.executeSchemas.topRightRadius3`),bottomLeftRadius:m.number().optional().describe(`schema.executeSchemas.bottomLeftRadius3`),bottomRightRadius:m.number().optional().describe(`schema.executeSchemas.bottomRightRadius4`),...b}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),At=m.object({type:m.literal(`VECTOR`),...y,vectorPaths:m.array(ot).describe(`schema.executeSchemas.vectorPaths`),...b}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),jt=m.object({type:m.literal(`TEXT`),...y,characters:m.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:m.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:st.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:m.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:m.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:m.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:m.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.executeSchemas.textCase`),textDecoration:m.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.executeSchemas.textDecoration`),lineHeight:ct.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:lt.optional().describe(`schema.executeSchemas.letterSpacing`),...b}).strict().describe(`schema.executeSchemas.letterSpacing2`),Mt=m.object({type:m.literal(`GROUP`),...y,children:m.array(St).min(2).max(100).describe(`schema.executeSchemas.children`),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:m.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.executeSchemas.paddingTop2`),paddingRight:m.number().optional().describe(`schema.executeSchemas.paddingRight2`),paddingBottom:m.number().optional().describe(`schema.executeSchemas.paddingBottom2`),paddingLeft:m.number().optional().describe(`schema.executeSchemas.paddingLeft2`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode2`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode2`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.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:m.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`schema.executeSchemas.path`),Nt=m.object({type:m.literal(`BOOLEAN_OPERATION`),...y,booleanOperation:m.enum(ke).describe(Me),children:m.array(St).min(2).describe(`schema.executeSchemas.children2`),...b}).strict().describe(`schema.executeSchemas.children3`),Pt=m.discriminatedUnion(`type`,[wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt]),Ft=m.object({mode:m.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:m.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:m.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:m.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});m.object({ops:m.array(Pt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:Ft.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),m.object({svg:m.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:m.string().optional().describe(`schema.execute.name`)});var It=m.object({svg:m.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:m.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:m.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:m.ZodIssueCode.custom,message:n(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),Lt=m.object({html:m.string().describe(`schema.execute.html`),name:m.string().optional().describe(`schema.execute.name2`)}),Rt=m.object({icon:m.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:m.number().optional().describe(`schema.execute.size`),color:m.string().optional().describe(`schema.execute.color`),strokeWidth:m.number().optional().describe(`schema.execute.strokeWidth`),name:m.string().optional().describe(`schema.execute.name3`)});m.object({});var zt=m.object({depth:m.number().optional().describe(`schema.executeOp.depth`)}),Bt=[`page`,`document`],Vt={"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.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":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"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{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 ee,z as m}from"zod";import{createServer as te}from"node:http";import{WebSocket as h,WebSocketServer as ne}from"ws";import{Client as re,StreamableHTTPClientTransport as ie}from"@modelcontextprotocol/client";import{McpServer as ae,ResourceTemplate as oe,SUPPORTED_PROTOCOL_VERSIONS as se,createMcpHandler as ce,fromJsonSchema as le}from"@modelcontextprotocol/server";import{serveStdio as ue}from"@modelcontextprotocol/server/stdio";import{spawn as de,spawnSync as fe}from"node:child_process";import{localhostHostValidation as pe,localhostOriginValidation as me,toNodeHandler as he}from"@modelcontextprotocol/node";import{readFile as ge,stat as _e}from"node:fs/promises";import{isTag as ve}from"domhandler";import{parseDocument as ye}from"htmlparser2";import be from"fuse.js";var g=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function xe(e){return e instanceof g?e.code:`plugin_error`}var Se=3e4,Ce=4e3;2*Se;var we=3e4,Te={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},styleEnumeration:{kind:`flow`,labelKey:`capability.host.styleEnumeration`},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 Ee(e){return Object.keys(e)}var De=Ee(Te);Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var Oe=Object.fromEntries(Object.entries(Te).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),ke=Ee({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`}}),Ae={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 je(e,t){let n=Ae[e];return n==null||n.some(e=>e===t)}var Me=[`PAINT`,`TEXT`,`EFFECT`,`GRID`,`STROKE_WIDTH`,`CORNER_RADIUS`,`PADDING`,`SPACING`],Ne=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Pe=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Fe=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Ie=[`MIN`,`CENTER`,`MAX`],Le=[`mastergo`],Re={blendMode:Ne,layoutAlign:Pe,primaryAxisAlignItems:Fe,counterAxisAlignItems:Ie},ze={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},Be={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},Ve={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 He(e,t){if(e==null)return null;let n=Ve[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=ze[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function Ue(e,t,n){let r=He(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 We(e,t,n){if(e==null)return!0;let r=Be[e]?.[t];return r==null||!r.some(e=>e===n)}function Ge(e,t){let n=He(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(Re[t]??[]).filter(n=>Ue(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var Ke=[`string`,`boolean`,`variableAlias`],qe={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function Je(e,t){if(e==null)return null;let n=qe[e]?.[t]?.deny??[];return Ke.filter(e=>!n.some(t=>t===e))}var Ye=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],Xe={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},Ze=Ye.join(`/`),Qe=`布尔运算:${Ye.map(e=>`${e}=${Xe[e]}`).join(`,`)}`;function $e(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 et=m.object({r:m.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.r`),g:m.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.g`),b:m.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.b`),a:m.number().min(0).max(255,`alpha 通道最大 255`).optional().describe(`schema.base.a`)}).strict(),tt=`颜色需为 {r,g,b[,a]} 对象(通道 0-1;任一路 >1 视为 0-255,自动整组 /255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,nt=m.unknown().superRefine((e,t)=>{if(typeof e==`string`){$e(e)??t.addIssue({code:m.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${tt})`});return}let n=et.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:m.ZodIssueCode.custom,path:e.path,message:e.message})}),rt=nt.describe(`颜色:{r,g,b} 对象(通道 0-1,>1 视为 0-255 自动归一化)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),it=nt.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,>1 视为 0-255 自动归一化;a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),at=m.object({color:it.describe(`schema.base.color`),position:m.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}(终点蓝色)`),ot=m.array(m.array(m.number()).length(3)).length(2).describe(`schema.base.transformSchema`),st=m.enum(Ne).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),ct=m.discriminatedUnion(`type`,[m.object({type:m.literal(`SOLID`).describe(`schema.base.type`),color:rt.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:m.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:m.boolean().optional().describe(`schema.base.visible`),blendMode:st.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),m.object({type:m.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:m.array(at).describe(`schema.base.gradientStops`),gradientTransform:ot}).strict().describe(`schema.base.gradientTransform`),m.object({type:m.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:m.array(at).describe(`schema.base.gradientStops2`),gradientTransform:ot}).strict().describe(`schema.base.gradientTransform2`),m.object({type:m.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:m.array(at).describe(`schema.base.gradientStops3`),gradientTransform:ot}).strict().describe(`schema.base.gradientTransform3`),m.object({type:m.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:m.string().describe(`schema.base.imageHash`),scaleMode:m.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schema.base.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),lt=m.discriminatedUnion(`type`,[m.object({type:m.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:it.describe(`schema.base.color2`),offset:m.object({x:m.number().describe(`schema.base.x`),y:m.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:m.number().min(0).describe(`schema.base.radius`),spread:m.number().optional().describe(`schema.base.spread`),visible:m.boolean().optional().describe(`schema.base.visible2`),blendMode:st.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:m.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),m.object({type:m.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:it.describe(`schema.base.color3`),offset:m.object({x:m.number().describe(`schema.base.x2`),y:m.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:m.number().min(0).describe(`schema.base.radius2`),spread:m.number().optional().describe(`schema.base.spread2`),visible:m.boolean().optional().describe(`schema.base.visible3`),blendMode:st.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),m.object({type:m.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:m.number().min(0).describe(`schema.base.radius3`),visible:m.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),m.object({type:m.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:m.number().min(0).describe(`schema.base.radius4`),visible:m.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),ut=m.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),dt=m.object({pattern:m.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:m.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:m.number().optional().describe(`schema.base.sectionSize`),count:m.number().int().positive().optional(),gutterSize:m.number().optional().describe(`schema.base.gutterSize`),offset:m.number().optional().describe(`schema.base.offset`),visible:m.boolean().optional(),color:it.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:m.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:m.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${n} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[n]})}),ft=m.object({data:m.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:m.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),pt=m.object({family:m.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:m.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),mt=m.union([m.object({value:m.number().describe(`schema.base.value`),unit:m.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),m.object({value:m.number().describe(`schema.base.value2`),unit:m.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),m.object({unit:m.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),ht=m.object({value:m.number(),unit:m.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),gt=m.object({id:m.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:m.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:m.record(m.string(),m.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符。两种来源:引用先前步骤结果(步骤id.字段路径),或按名字取文档里已有的资源 —— {{@comp:名称}} 给组件/变体集 id、{{@var:名称}} 给变量 id(读一次 jsd_get_page 的资源清单,同名多命中或零命中会点名中止整批)。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:m.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),_t=m.object({calls:m.array(gt).max(50).optional().describe(`schema.batch.calls`),callsFile:m.string().optional().describe(`schema.batch.callsFile`),stopOnError:m.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:m.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),vt=m.object({ok:m.boolean().describe(`schema.batch.ok`),executed:m.number().int().min(0).describe(`schema.batch.executed`),total:m.number().int().min(0).describe(`schema.batch.total`),results:m.array(m.object({id:m.string(),tool:m.string(),ok:m.boolean(),data:m.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:m.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:m.boolean().optional(),warnings:m.array(m.string()).optional()}),yt=m.record(m.string(),m.unknown()),bt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],xt={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},St=`节点类型:${bt.map(e=>`${e}=${xt[e]}`).join(` | `)}`,Ct=[`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`],wt=[`INTELLIGENT_CONTAINER`],Tt=[...bt,...Ct,...wt],Et=m.enum(bt).describe(St),Dt=m.enum(Tt).describe(`${St};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),Ot=m.object({type:Et.describe(`schema.executeSchemas.type`),name:m.string().optional(),x:m.number().optional().describe(`schema.executeSchemas.x`),y:m.number().optional().describe(`schema.executeSchemas.y`),width:m.number().optional(),height:m.number().optional()}).catchall(m.unknown()),_={name:m.string().optional(),x:m.number().optional().describe(`schema.executeSchemas.x2`),y:m.number().optional().describe(`schema.executeSchemas.y2`),width:m.number().optional().describe(`schema.executeSchemas.width`),height:m.number().optional().describe(`schema.executeSchemas.height`),rotation:m.number().optional().describe(`schema.executeSchemas.rotation`),opacity:m.number().optional().describe(`schema.executeSchemas.opacity`),visible:m.boolean().optional(),locked:m.boolean().optional(),isMask:m.boolean().optional(),children:m.array(Ot).max(100).optional().describe(`子节点数组(递归嵌套,最多 100 个直接子节点;更大的结构建议分批创建后用 jsd_manage_nodes op=reparent 归组)。子节点可使用的字段与顶层 create 入参一致(fills/strokes/cornerRadius/effects 等均可用);x/y 相对父节点,未传 x/y 会叠放在父节点原点(0,0)——非 auto-layout 容器需为每个子节点指定相对坐标`)},v={fills:m.array(ct).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:m.array(ct).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:m.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:m.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:m.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:m.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:m.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:m.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:m.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.executeSchemas.strokeCap`),strokeJoin:m.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.executeSchemas.strokeJoin`),dashPattern:m.array(m.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:st.optional(),effects:m.array(lt).optional().describe(`schema.executeSchemas.effects`),constraints:m.object({horizontal:ut.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:ut.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:m.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:m.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:m.array(dt).optional().describe(`schema.executeSchemas.layoutGrids`),fillStyleId:m.string().optional().describe(`schema.sharedProps.fillStyleId`),strokeStyleId:m.string().optional().describe(`schema.sharedProps.strokeStyleId`),textStyleId:m.string().optional().describe(`schema.sharedProps.textStyleId`),effectStyleId:m.string().optional().describe(`schema.sharedProps.effectStyleId`)},kt={cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:m.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:m.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:m.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:m.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)},At=m.object({type:m.literal(`FRAME`),..._,layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:m.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:m.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:m.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:m.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:m.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`),...kt,...v}).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:m.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}]`),jt=m.object({type:m.literal(`RECTANGLE`),..._,...kt,...v}).strict().describe(`schema.executeSchemas.type2`),Mt=m.object({type:m.literal(`ELLIPSE`),..._,cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius2`),arcData:m.object({startingAngle:m.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:m.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:m.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schema.executeSchemas.innerRadius2`),...v}).strict().describe(`schema.executeSchemas.innerRadius3`),Nt=m.object({type:m.literal(`LINE`),..._,...v}).strict().describe(`schema.executeSchemas.type3`),Pt=m.object({type:m.literal(`POLYGON`),..._,pointCount:m.number().describe(`schema.executeSchemas.pointCount`),cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius3`),topLeftRadius:m.number().optional().describe(`schema.executeSchemas.topLeftRadius2`),topRightRadius:m.number().optional().describe(`schema.executeSchemas.topRightRadius2`),bottomLeftRadius:m.number().optional().describe(`schema.executeSchemas.bottomLeftRadius2`),bottomRightRadius:m.number().optional().describe(`schema.executeSchemas.bottomRightRadius2`),...v}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),Ft=m.object({type:m.literal(`STAR`),..._,pointCount:m.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:m.number().describe(`schema.executeSchemas.innerRadius4`),cornerRadius:m.number().optional().describe(`schema.executeSchemas.cornerRadius4`),topLeftRadius:m.number().optional().describe(`schema.executeSchemas.topLeftRadius3`),topRightRadius:m.number().optional().describe(`schema.executeSchemas.topRightRadius3`),bottomLeftRadius:m.number().optional().describe(`schema.executeSchemas.bottomLeftRadius3`),bottomRightRadius:m.number().optional().describe(`schema.executeSchemas.bottomRightRadius4`),...v}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),It=m.object({type:m.literal(`VECTOR`),..._,vectorPaths:m.array(ft).describe(`schema.executeSchemas.vectorPaths`),...v}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),Lt=m.object({type:m.literal(`TEXT`),..._,characters:m.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:m.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:pt.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:m.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:m.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:m.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:m.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.executeSchemas.textCase`),textDecoration:m.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.executeSchemas.textDecoration`),lineHeight:mt.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:ht.optional().describe(`schema.executeSchemas.letterSpacing`),...v}).strict().describe(`schema.executeSchemas.letterSpacing2`),Rt=m.object({type:m.literal(`GROUP`),..._,children:m.array(Ot).min(2).max(100).describe(`schema.executeSchemas.children`),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:m.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.executeSchemas.paddingTop2`),paddingRight:m.number().optional().describe(`schema.executeSchemas.paddingRight2`),paddingBottom:m.number().optional().describe(`schema.executeSchemas.paddingBottom2`),paddingLeft:m.number().optional().describe(`schema.executeSchemas.paddingLeft2`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode2`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode2`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems2`),...v}).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:m.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`schema.executeSchemas.path`),zt=m.object({type:m.literal(`BOOLEAN_OPERATION`),..._,booleanOperation:m.enum(Ye).describe(Qe),children:m.array(Ot).min(2).describe(`schema.executeSchemas.children2`),...v}).strict().describe(`schema.executeSchemas.children3`),Bt=m.discriminatedUnion(`type`,[At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt,zt]),Vt=m.object({mode:m.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:m.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:m.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:m.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});m.object({ops:m.array(Bt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:Vt.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),m.object({svg:m.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:m.string().optional().describe(`schema.execute.name`)});var Ht=m.object({svg:m.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:m.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:m.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:m.ZodIssueCode.custom,message:n(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),Ut=m.object({html:m.string().describe(`schema.execute.html`),name:m.string().optional().describe(`schema.execute.name2`)}),Wt=m.object({icon:m.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:m.number().optional().describe(`schema.execute.size`),color:m.string().optional().describe(`schema.execute.color`),strokeWidth:m.number().optional().describe(`schema.execute.strokeWidth`),name:m.string().optional().describe(`schema.execute.name3`)});m.object({});var Gt=m.object({depth:m.number().optional().describe(`schema.executeOp.depth`)}),Kt=[`page`,`document`],qt={"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.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":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"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 会自动拉取运行)。
|
|
6
6
|
|
|
7
7
|
2. 注册后调用 jsd_ping —— 这一步会唤醒(必要时自动拉起)后台常驻服务。
|
|
8
|
-
若返回「插件未连接」,请提示我在设计软件里运行 text-to-design 插件。`,"panel.expand":`展开`,"panel.collapse":`收起`,"panel.close":`关闭`,"selection.title":`选中节点`,"selection.badge":`{count} 个 · 序列化 {size}`,"selection.copy":`复制`,"selection.empty.title":`未选中节点`,"selection.empty.hint":`在画布中点选节点后,这里会实时显示并支持复制`,"capability.card.title":`能力`,"capability.card.missing":`能力表未获取(插件未连接)`,"capability.card.badgeTitle":`核心能力项数 · 当前平台可用的差异能力 · 平台特有操作个数`,"capability.card.badge":`核心 {core} · 平台 {host}/{total} · op {ops}`,"capability.card.coreSection":`核心能力`,"capability.card.hostSection":`平台差异能力`,"capability.card.opTitle":`{op}:当前平台支持`,"capability.card.opTitleOff":`{op}:当前平台不支持`,"capability.card.opsSection":`平台特有操作`,"capability.card.refresh":`刷新`,"capability.card.noOps":`当前平台无特有操作`,"log.trigger":`日志`,"log.trigger.title":`日志:MCP 调用与连接事件`,"log.trigger.unread":`日志,有 {count} 条新错误`,"log.trigger.unit":`条错误`,"log.trigger.announce":`有 {count} 条新错误`,"log.drawer.title":`日志`,"log.drawer.count":`{shown} / {total} 条`,"log.drawer.clear":`清空`,"log.drawer.close":`关闭日志`,"log.drawer.filter.all":`全部`,"log.drawer.filter.info":`信息+`,"log.drawer.filter.warn":`警告+`,"log.drawer.filter.error":`错误`,"log.drawer.empty":`暂无日志。MCP 调用与连接事件会记录在这里。`,"log.drawer.emptyFiltered":`当前档位「{filter}」下没有日志,切到「全部」看完整记录。`,"log.drawer.copy":`复制`,"log.drawer.newCount":`↓ {count} 条新日志`,"bridge.log.superseded":`通道已被另一个插件面板接管,自动重连已停止(点面板顶部的「夺回」可切回)`,"bridge.log.confirmed":`服务已确认连接(版本 {version})`,"bridge.log.versionPush":`收到 npm 最新版本: 插件 {ui}、服务 {mcp}`,"bridge.log.versionUnknown":`未查到`,"bridge.log.handshakeTimeout":`WS 握手超时({ms}ms),放弃本次连接: {port}`,"bridge.log.serverConnected":`MCP server 已连接,等待服务确认: ws://localhost:{port}`,"bridge.log.confirmTimeout":`服务确认超时,关闭重连: {port}`,"bridge.log.closed":`连接断开: {port}`,"bridge.log.stale":`服务确认过期({ms}ms 未收到心跳),关闭重连: {port}`,"bridge.log.wsFailed":`WS 消息处理失败: {message}`,"bridge.log.recvRequest":`收到服务器请求: {method}`,"bridge.log.recvResponse":`收到服务器响应(忽略): {id}`,"bridge.log.forwardTimeout":`转发到插件超时: {method}`,"bridge.log.pluginTimeout":`插件响应超时`,"bridge.log.ignoreUnknown":`忽略未知插件消息: {type}`,"bridge.log.codeFailed":`code 消息处理失败: {message}`,"bridge.log.sendFailed":`发送响应失败(server 未连接): {id}`,"bridge.log.manualClose":`手动断开连接`,"bridge.log.capabilityMissing":`能力表回包异常(缺 platform)`,"bridge.log.capabilityFailed":`能力表获取失败: {message}`,"bridge.log.pingOk":`ping 插件成功: {data}`,"bridge.log.pingFailed":`ping 插件失败: {message}`,"bridge.error.useBridge":`useBridge 必须在 <BridgeProvider> 内使用`,"schema.base.r":`红色通道,范围 0-1(0=无,1=满),如纯红为 1;>1 视为 0-255,自动整组归一化`,"schema.base.g":`绿色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.b":`蓝色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理;>1 视为 0-255 自动归一化`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`变换矩阵,如 [[1,0,0],[0,1,0]] 表示无变换(Identity)`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.type":`子节点类型`,"schema.executeSchemas.x":`相对父节点的 X(px)`,"schema.executeSchemas.y":`相对父节点的 Y(px)`,"schema.executeSchemas.x2":`X 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.y2":`Y 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.width":`宽度(px)`,"schema.executeSchemas.height":`高度(px)`,"schema.executeSchemas.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表(Paint 数组)`,"schema.executeSchemas.strokeWeight":`描边宽度(px)`,"schema.executeSchemas.strokeTopWeight":`描边顶部宽(px)`,"schema.executeSchemas.strokeBottomWeight":`描边底部宽(px)`,"schema.executeSchemas.strokeLeftWeight":`描边左侧宽(px)`,"schema.executeSchemas.strokeRightWeight":`描边右侧宽(px)`,"schema.executeSchemas.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.executeSchemas.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.executeSchemas.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.executeSchemas.dashPattern":`虚线段数组,如 [4,4]`,"schema.executeSchemas.effects":`效果列表(阴影/模糊,可多层叠加)`,"schema.executeSchemas.vertical":`自动布局中的约束`,"schema.executeSchemas.clipsContent":`是否裁剪溢出内容`,"schema.executeSchemas.cornerSmoothing":`圆角平滑度 0-1`,"schema.executeSchemas.layoutGrids":`布局网格(参考线)`,"schema.executeSchemas.cornerRadius":`圆角半径(px),四角统一`,"schema.executeSchemas.topLeftRadius":`左上圆角(px)`,"schema.executeSchemas.topRightRadius":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius":`右下圆角(px)`,"schema.executeSchemas.paddingTop":`上内边距(px)`,"schema.executeSchemas.paddingRight":`右内边距(px)`,"schema.executeSchemas.paddingBottom":`下内边距(px)`,"schema.executeSchemas.paddingLeft":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.executeSchemas.layoutGrow":`自动布局内伸缩系数`,"schema.executeSchemas.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.cornerRadius2":`圆角半径(px)`,"schema.executeSchemas.startingAngle":`起始角度(radians)`,"schema.executeSchemas.endingAngle":`结束角度(radians)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.innerRadius3":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.cornerRadius3":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius2":`左上圆角(px)`,"schema.executeSchemas.topRightRadius2":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius2":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius2":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),值越小角越尖锐`,"schema.executeSchemas.cornerRadius4":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius3":`左上圆角(px)`,"schema.executeSchemas.topRightRadius3":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius3":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius4":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius5":`STAR=星形(配合 pointCount + innerRadius)`,"schema.executeSchemas.vectorPaths":`矢量路径数组,每项含 SVG path data(如 "M0 0 L100 100")`,"schema.executeSchemas.fontSize":`字号(px),默认 16`,"schema.executeSchemas.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.executeSchemas.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.executeSchemas.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`行高:{value,unit},unit 为 PIXELS|PERCENT;或 {unit:"AUTO"}`,"schema.executeSchemas.letterSpacing":`字距:{value,unit},unit 为 PIXELS|PERCENT`,"schema.executeSchemas.letterSpacing2":`TEXT=文本(配合 characters/fontSize/fontName 等)`,"schema.executeSchemas.children":`子节点数组,至少 2 个;递归嵌套,最多 100 个直接子节点`,"schema.executeSchemas.paddingTop2":`上内边距(px)`,"schema.executeSchemas.paddingRight2":`右内边距(px)`,"schema.executeSchemas.paddingBottom2":`下内边距(px)`,"schema.executeSchemas.paddingLeft2":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode2":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`交叉轴对齐`,"schema.executeSchemas.path":`GROUP=分组(内部用 Frame 实现)`,"schema.executeSchemas.children2":`要合并的子节点数组(至少 2 个)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION=布尔运算(合并子节点)`,"schema.execute.name":`生成的图层名,默认 svg-design`,"schema.execute.html":`HTML 片段,支持内联 style`,"schema.execute.name2":`生成的图层名,默认 html-design`,"schema.execute.size":`图标边长 px,默认 24`,"schema.execute.color":`描边颜色(十六进制),默认 #000000`,"schema.execute.strokeWidth":`描边宽度,默认 2`,"schema.execute.name3":`生成的图层名,默认 icon-<图标名>`,"schema.inputs.ids":`按节点 id 精确查找,优先级最高`,"schema.inputs.name":`按名称模糊匹配(包含)`,"schema.inputs.recursive":`是否递归查找(默认 true)`,"schema.inputs.depth":`序列化深度:0=仅自身,1=含直接子节点;缺省 1`,"schema.inputs.name2":`仅 group:组名`,"schema.inputs.paddingTop":`仅 group。上内边距(px)`,"schema.inputs.paddingRight":`仅 group。右内边距(px)`,"schema.inputs.paddingBottom":`仅 group。下内边距(px)`,"schema.inputs.paddingLeft":`仅 group。左内边距(px)`,"schema.inputs.primaryAxisSizingMode":`仅 group。主轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisSizingMode":`仅 group。交叉轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisAlignItems":`仅 group。交叉轴对齐:MIN|MAX|CENTER`,"schema.inputs.key":`团队库组件唯一标识 Key(仅 import_component 必填)`,"schema.inputs.componentId":`目标组件(COMPONENT)节点 id(仅 swap_component 必填)`,"schema.inputs.format":`导出格式,默认 PNG`,"schema.inputs.scale":`缩放倍率(PNG/JPG),默认 1`,"schema.inputs.savePath":`落盘文件绝对路径,如 /tmp/icon.png`,"schema.inputs.includeDataUrl":`是否同时返回 base64 dataURL,默认 false`,"schema.inputs.ids2":`要填充图片的节点 id 列表`,"schema.inputs.sourcePath":`本地图片文件绝对路径,如 /tmp/poster.png`,"schema.inputs.params":`操作参数,结构随 op 而定`,"schema.inputs.family":`按家族名过滤(不区分大小写的子串),如 "Source" 或 "思源"`,"schema.inputs.offset":`分页起始序号(跳过多少族),默认 0`,"schema.inputs.limit":`本页最多返回多少族,默认 50、上限 500;字体库可达约 1900 族,整表会撑爆上下文`,"schema.platform.name":`op 名,调用 jsd_platform_op 时原样传`,"schema.platform.description":`含 params 形状说明`,"schema.results.capabilities":`当前平台支持的能力列表(先查此字段再决定能否调用平台特有操作)`,"schema.results.families":`可用字体族(family)列表`,"schema.results.family":`字体族`,"schema.results.styles":`该族可用字型,如 ["Regular","Medium","Bold"]`,"schema.results.count":`本页返回的字体族数量`,"schema.results.total":`过滤后的字体族总数(不受分页影响)`,"schema.results.offset":`本页起始序号`,"schema.results.truncated":`为 true 表示还有下一页,用 offset 继续取`,"schema.sharedProps.width":`宽度(px)`,"schema.sharedProps.height":`高度(px)`,"schema.sharedProps.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.sharedProps.opacity":`不透明度 0-1`,"schema.sharedProps.pointCount":`多边形/星形角点数(仅 POLYGON/STAR 生效)`,"schema.sharedProps.innerRadius":`星形内半径比例(0-1,相对外半径;仅 STAR 生效)`,"schema.sharedProps.strokes":`描边列表(Paint 数组;整体替换,非合并,需保留的描边要一并传入)`,"schema.sharedProps.strokeWeight":`描边宽度(px)`,"schema.sharedProps.strokeTopWeight":`描边顶部宽(px)`,"schema.sharedProps.strokeBottomWeight":`描边底部宽(px)`,"schema.sharedProps.strokeLeftWeight":`描边左侧宽(px)`,"schema.sharedProps.strokeRightWeight":`描边右侧宽(px)`,"schema.sharedProps.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.sharedProps.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.sharedProps.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.sharedProps.dashPattern":`虚线段数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.topLeftRadius":`左上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.topRightRadius":`右上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomLeftRadius":`左下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomRightRadius":`右下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.characters":`文本内容(仅 TEXT 节点生效)`,"schema.sharedProps.fontSize":`字号(px)`,"schema.sharedProps.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.sharedProps.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.sharedProps.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.sharedProps.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.sharedProps.lineHeight":`行高:{value,unit}`,"schema.sharedProps.letterSpacing":`字距:{value,unit}`,"schema.sharedProps.textStyleId":`文本样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.textTruncation":`文本截断(DISABLED=不截断,ENDING=末尾省略号截断),仅 Figma 生效`,"schema.sharedProps.maxLines":`文本最大行数,仅 Figma 生效`,"schema.sharedProps.paddingTop":`上内边距(px)`,"schema.sharedProps.paddingRight":`右内边距(px)`,"schema.sharedProps.paddingBottom":`下内边距(px)`,"schema.sharedProps.paddingLeft":`左内边距(px)`,"schema.sharedProps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.sharedProps.layoutGrow":`自动布局内伸缩系数`,"schema.sharedProps.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.sharedProps.fillStyleId":`填充样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effectStyleId":`效果样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effects":`效果列表(阴影/模糊,可多层叠加;整体替换,非合并)`,"schema.sharedProps.vertical":`自动布局中的约束`,"schema.sharedProps.clipsContent":`是否裁剪溢出内容`,"schema.sharedProps.cornerSmoothing":`圆角平滑度 0-1`,"schema.sharedProps.layoutGrids":`布局网格(参考线)`,"schema.sharedProps.startingAngle":`起始角度(radians)`,"schema.sharedProps.endingAngle":`结束角度(radians)`,"schema.sharedProps.innerRadius2":`内半径(0-1 ratio)`,"schema.sharedProps.innerRadius3":`环形路径参数(弧线),仅 ELLIPSE 节点生效`,"schema.splitOps.ids":`目标节点 id 列表;缺省时作用于当前选中节点`,"schema.splitOps.matchName":`按节点 name 精确过滤(精确等值,非模糊/包含),仅命中节点被修改`,"schema.splitOps.ids2":`要删除的节点 id 列表;缺省时删除当前选中节点`,"schema.splitOps.matchName2":`在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`,"schema.splitOps.name":`组名`,"schema.splitOps.paddingTop":`上内边距(px)`,"schema.splitOps.paddingRight":`右内边距(px)`,"schema.splitOps.paddingBottom":`下内边距(px)`,"schema.splitOps.paddingLeft":`左内边距(px)`,"schema.splitOps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.splitOps.ids3":`要清理的已损坏节点 id 列表;缺省时清理当前页全部损坏节点`,"schema.splitOps.name2":`组件名称`,"schema.splitOps.key":`团队库组件唯一标识 Key`,"schema.splitOps.name3":`导入后的节点名称`,"schema.splitOps.componentId":`目标组件(COMPONENT)节点 id`,"schema.splitOps.name4":`变体集名称`,"schema.splitOps.sourceId":`源实例 id,即先前 copy_overrides 返回的 snapshotId`,"schema.splitOps.name5":`节点新名称`,"batch.title":`批量编排执行`,"batch.followUp":`编排执行后复核画布结果`,"createComponent.title":`建组件`,"createComponent.description":`建组件(COMPONENT)并返回新 id。传 children 时一次建成带内容的组件(字段同 jsd_create_frame 的 children),可再传 width/height 定尺寸,不必再手工 reparent 搬子节点;不传 children 则是空壳,后续用 jsd_reparent_nodes 归组。原节点不会被固化也不会被改动 —— 组件一律新建(避免把已有节点卷进 wrapper)。变体命名用「属性=值, 属性=值」,变体属性用 jsd_set_instance_properties`,"createComponent.description2":`调整组件尺寸 / 补齐填充、圆角、阴影`,"createInstance.title":`生成组件实例`,"createInstance.description":`设置实例的变体属性`,"detachInstance.title":`取消实例链接`,"detachInstance.description":`解链后自由编辑新节点样式`,"importComponent.title":`从团队库导入组件`,"importComponent.description":`为导入的组件生成实例`,"swapComponent.title":`换绑组件`,"swapComponent.description":`换绑后设置变体属性`,"setInstanceProperties.title":`设置变体属性`,"setInstanceProperties.description":`批量同步其他实例的覆盖`,"combineAsVariants.title":`合并为变体集`,"copyOverrides.title":`复制实例覆盖快照`,"copyOverrides.description":`把快照套用到目标实例`,"applyOverrides.title":`套用实例覆盖快照`,"applyOverrides.description":`继续同步其他实例的覆盖`,"syncOverrides.title":`同步实例覆盖`,"syncOverrides.description":`复核同步后的实例`,"createFrame.title":`创建 Frame 容器`,"createFrame.description":`创建单个 FRAME 容器节点,入参只含 FRAME 字段:width/height 尺寸、layoutMode 自动布局(itemSpacing/padding*/主轴交叉轴尺寸对齐)与填充描边等视觉字段。本工具只建一个根 FRAME;children 只用于「容器 + 其直属子节点」这类小结构(子节点 x/y 相对父节点),**别把整屏的整棵树塞进一次 children**(易整批失败)—— 分层分批用 jsd_batch 编排,再用 jsd_reparent_nodes 逐层归组。auto-layout 前必须设 layoutMode=HORIZONTAL 或 VERTICAL(否则布局字段被忽略)。未显式传 fills 时引擎默认白底,透明容器传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]。**name 必传且语义化**(如「侧栏」「KPI-设备综合效率」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createRectangle.title":`创建矩形`,"createRectangle.description":`创建单个 RECTANGLE 矩形节点,入参只含矩形字段:width/height 尺寸、cornerRadius 四角圆角与填充描边等视觉字段。本工具只建一个根矩形;children 只用于小结构(子节点 x/y 相对父节点)。**name 必传且语义化**(如「卡片底板」「图表-网格线」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createText.title":`创建文本`,"createText.description":`创建单个 TEXT 文本节点,入参只含文本字段:characters 必填内容、fontSize/fontName 字号字体、对齐/自适应/大小写/装饰/行高/字距与填充描边。本工具只建一个根文本;children 只用于小结构(子节点 x/y 相对父节点)。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样(如 SourceHanSansCN_family),style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,命中时结果 warnings 点名。长段落要换行:TEXT 缺省按内容撑开,显式 width 会被覆盖 —— 传 width + textAutoResize:"HEIGHT";要固定框尺寸传 "NONE"。**name 必传且语义化**(如「标题-近30天产出」「KPI 数值」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createEllipse.title":`创建椭圆`,"createEllipse.description":`创建单个 ELLIPSE 椭圆节点,width/height 尺寸、arcData 环形参数(可画环)与填充描边等视觉字段。本工具只建一个根椭圆。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createLine.title":`创建线段`,"createLine.description":`创建单个 LINE 线段节点,width/height 尺寸与描边等视觉字段。本工具只建一个根线段;短直线段建议 LINE+rotation 布局更稳定。横线/竖线可把一维传 0:引擎 resize 校验要求 >= 0.01,插件创建时把零轴抬到 0.01 过校验(视觉是直线,序列化回读该轴仍是 0);jsd_resize_node 改尺寸同样支持零轴。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createPolygon.title":`创建多边形`,"createPolygon.description":`创建单个 POLYGON 多边形节点,pointCount 角点数必填(如 6=六边形)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根多边形。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createStar.title":`创建星形`,"createStar.description":`创建单个 STAR 星形节点,pointCount 角点数与 innerRadius 内半径比例必填(如 5 角、0.5)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根星形。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createVector.title":`创建矢量`,"createVector.description":`创建单个 VECTOR 矢量节点,vectorPaths 必填(每项含 SVG path data,如 "M0 0 L100 100")与填充描边等视觉字段。本工具只建一个根矢量。⚠ 已知平台缺陷:创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createGroup.title":`创建编组`,"createGroup.description":`创建单个 GROUP 编组节点,children 必填且至少 2 个子节点(内部用 Frame 实现),可带 auto-layout 布局字段(layoutMode/itemSpacing/padding*)。本工具只建一个根编组;要固定坐标的根层级用 placement 控制。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createBooleanOperation.title":`创建布尔运算节点`,"createSvg.title":`导入 SVG`,"createSvg.description":"将 SVG 直接导入画布为可编辑图层(createNodeFromSvg 原生解析,保留路径/渐变/描边)。来源二选一:svg(内联字符串)或 svgPath(本地 .svg 文件路径,由后台服务读盘)。**图表 / 数据可视化一律走 svgPath**(折线图、柱状图、饼图 / 环形图、散点图、雷达图、面积图、仪表盘、看板、桑基图……):没有内置图表工具 —— 先自己写脚本把 SVG 算好、落到本地文件,再传路径。引擎硬约束(违反会静默画不出来):根元素必须带 xmlns 与显式 width/height/viewBox;颜色只写 hex;不引外链图片/字体/script;曲线用 C/Q 自己近似,不要用 A 指令;画布 ≤2000×2000;按语义层切 `<g id>`(一层不套等于没分组),绘图区只在外层写一个 transform。动手前先 ReadMcpResource 读配方 jsd://recipes/chart-by-code —— 内含零依赖示例、配色字号口径、导入后回读层级与导图验收清单。建多个根节点/复杂树用 jsd_batch 编排","createIcon.title":`插入内置图标`,"htmlToDesign.title":`HTML 转设计节点`,"htmlToDesign.description":`将 HTML 片段转成矢量图层(SVG 保真,忽略复杂样式);需要逐节点可编辑的结构时改用 jsd_create_rectangle / jsd_create_text 等手工搭建后再 jsd_batch 编排`,"manageNodes.title":`节点结构操作(聚合)`,"manageNodes.followUp":`结构改完后设置容器自动布局`,"manageComponents.title":`组件与实例操作(聚合)`,"manageComponents.description":`按 op 分发的组件/实例操作聚合入口:create_component|create_instance|detach_instance|import_component|swap_component|set_instance_properties|combine_as_variants|copy_overrides|apply_overrides|sync_overrides。单次单操作请优先用对应小工具:jsd_create_component / jsd_create_instance / jsd_detach_instance / jsd_import_component / jsd_swap_component / jsd_set_instance_properties / jsd_combine_as_variants / jsd_copy_overrides / jsd_apply_overrides / jsd_sync_overrides(描述含平台缺陷与正确流程)。节点结构操作用 jsd_manage_nodes,两工具 op 不通用`,"manageComponents.description2":`组件/实例改完后设置变体属性`,"find.title":`查找节点`,"find.description":`把查到的节点设为当前选中,便于后续修改/删除`,"selectNodes.title":`设置画布选中`,"selectNodes.description":`选中后移动/调整选中节点`,"deleteNode.title":`删除节点`,"deleteNode.description":`删除后复核剩余节点`,"cloneNode.title":`复制节点`,"cloneNode.description":`把副本移到目标位置`,"groupNodes.title":`编组节点`,"groupNodes.description":`编组后设置组内自动布局`,"ungroupNodes.title":`解组节点`,"ungroupNodes.description":`解组后调整子节点位置`,"flattenNodes.title":`合并为矢量`,"flattenNodes.description":`烘焙后设置合并图形的填充`,"outlineStroke.title":`描边转轮廓`,"outlineStroke.description":`调整新轮廓的描边`,"reparentNodes.title":`移动节点到父节点下`,"reparentNodes.description":`移动后按需微调新父下的 x/y(绝对位置已自动保持)`,"repairNodes.title":`清理损坏节点`,"repairNodes.description":`清理后复核页面节点状态`,"platformOp.title":`平台特有操作`,"platformOp.description":`执行平台特有能力(Figma:变量/本地样式/组件属性;MasterGo:变量读写/组件属性/集合级变体管理等)。CRITICAL: 不要凭空猜测 op 名与参数——先 jsd_ping 读 platformOps 名单(含每个 op 的参数形状说明)与 capabilities,再按名单里的名字调用;平台不支持或 op 名写错时返回错误并列出当前平台支持的 op`,"platformOp.description2":`复核平台操作在画布上的效果`,"prompt.htmlToDesign.title":`HTML 转设计稿`,"prompt.htmlToDesign.description":`把一段 HTML 转为画布节点,含保真度取舍说明`,"prompt.iconGrid.title":`图标网格`,"prompt.iconGrid.description":`批量插入 Lucide 图标并排成自动布局网格`,"prompt.scriptOps.title":`脚本化批量调用`,"prompt.chartByCode.title":`代码画图表 / 数据可视化`,"prompt.chartByCode.description":`画图表 / 数据可视化的主路径:折线图、柱状图、饼图 / 环形图、散点图、雷达图、面积图、仪表盘、看板等任意图表,都由自己写代码算几何、落盘 SVG,再经 jsd_create_svg 导入(含零依赖示例与引擎侧硬约束)`,"prompt.designStrategy.title":`设计策略总纲`,"prompt.textReplace.title":`文本批量替换策略`,"prompt.variantSync.title":`同类实例样式批量同步`,"prompt.variableBinding.title":`变量绑定与批量套用`,"prompt.variantSet.title":`变体集构建`,"prompt.componentProperty.title":`组件属性定义与设值`,"setFillColor.title":`设置填充`,"setFillColor.followUp":`接着设置描边`,"setStroke.title":`设置描边`,"setStroke.description":`接着设置填充`,"setCornerRadius.title":`设置圆角`,"setCornerRadius.description":`接着设置阴影/模糊效果`,"setText.title":`修改文本`,"setText.followUp":`给文本起个语义名称`,"moveNode.title":`移动节点`,"moveNode.description":`接着调整尺寸`,"resizeNode.title":`调整节点尺寸`,"resizeNode.description":`接着设置可见性/锁定`,"setLayout.title":`设置自动布局`,"setLayout.description":`把子节点移入容器完成排布`,"setEffects.title":`设置效果与高级属性`,"setEffects.description":`接着设置可见性/锁定`,"setVisibility.title":`设置可见性与锁定`,"setVisibility.description":`复核改动后的画布选中`,"renameNode.title":`重命名节点`,"renameNode.description":`接着改文本内容/排版`,"setShape.title":`设置多边形/星形形状`,"setShape.description":`接着设置填充`,"export.title":`导出节点为图片`,"export.description":`导出节点为 PNG/JPG/SVG/PDF;ids 为必填数组(单节点也写成 ids:["123:456"],不是 nodeId),savePath 落盘与 includeDataUrl 返回 base64 可并存。注意:单张图片超过内联上限(默认 512KB)时不返回 base64,自动落盘并返回路径引用,避免撑爆会话内存。完整字段见 inputSchema。`,"export.description2":`导出后用该图片填充到节点`,"fillImage.title":`本地图片填充节点`,"fillImage.description":`读取本地图片文件填充到指定节点(IMAGE fill)`,"fillImage.description2":`复核图片填充效果`,"listFonts.title":`列出可用字体`,"listFonts.description":`用列出的字体设置文本`,"resources.title":`画布当前选中`,"resources.title2":`可用字体列表`,"resources.title3":`本地样式列表`,"resources.title4":`当前页概览:第一层节点 + 可复用资源清单`,"resources.title5":`节点详情`,"resources.title6":`平台状态与能力表`,"resources.title7":`配方索引`,"resources.title8":`配方正文`,"ping.followUp":`连接确认后读取当前选中;创作类任务先读 design-strategy 配方`,"getSelection.title":`读取画布选中`,"getSelection.description":`获取画布当前选中节点的序列化树(名称/类型/尺寸/位置/填充/子结构);depth 控制层级深度,默认 2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上),判断遮挡读 z 即可`,"getSelection.description2":`在选中范围内继续精确查找节点`,"getPage.title":`当前页概览:第一层节点 + 可复用资源清单`,"getPage.description":`**当前页**的两段只读概览。①nodes:**当前页第一层**节点的几何(id/名称/类型/宽高/x/y,不递归);②assets:可复用资源清单 —— summary 给四类计数,components 组件、variants 变体集(带「维度→可选值」)、styles 样式(PAINT/TEXT/EFFECT/GRID,带 type)、variables 变量,每项含 id 与名称。范围说明:**样式与变量是文档级**(引擎的枚举 API 本身就是文档级,与页面无关);组件与变体按平台 —— 能读非当前页的平台覆盖全文档,读不到的(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前的第一步就是读这里:命中同名/同用途的组件、变体取值、样式、变量一律复用,禁止新建重复件**;清单里没有才允许新建。某个面在本平台未声明对应能力时该项为空数组,不报错(即时设计无变量面、列不出样式清单);成因写在 note 里 —— **空数组 ≠ 文档里没有**;变体的 properties 键在平台读不到该字段时整体省略(不写成空对象)。从头设计整页前先读这里,看页面已有内容与能复用的件;资源的细节按 id 走 jsd_find。另附 pages:各页名与顶层节点数;dynamic-page 平台首次读取会全量加载文档并在 note 点名成本(幂等,再次调用不再加载)。读不到非当前页的平台(即时设计/MasterGo)资源清单与 pages 只覆盖当前页,note 同样点名 —— 那不等于文档只有一页`,"getPage.followUp":`按 id 读取具体节点的序列化结构;要跨页查找传 scope=document`,"mcp.instructions":`操作设计画布的工具集。一个操作对应一个 jsd_* 工具,无 op 分发;聚合入口 jsd_manage_nodes / jsd_manage_components 仅用于批量/混合结构操作。调用纪律:
|
|
8
|
+
若返回「插件未连接」,请提示我在设计软件里运行 text-to-design 插件。`,"panel.expand":`展开`,"panel.collapse":`收起`,"panel.close":`关闭`,"selection.title":`选中节点`,"selection.badge":`{count} 个 · 序列化 {size}`,"selection.copy":`复制`,"selection.empty.title":`未选中节点`,"selection.empty.hint":`在画布中点选节点后,这里会实时显示并支持复制`,"capability.card.title":`能力`,"capability.card.missing":`能力表未获取(插件未连接)`,"capability.card.badgeTitle":`核心能力项数 · 当前平台可用的差异能力 · 平台特有操作个数`,"capability.card.badge":`核心 {core} · 平台 {host}/{total} · op {ops}`,"capability.card.coreSection":`核心能力`,"capability.card.hostSection":`平台差异能力`,"capability.card.opTitle":`{op}:当前平台支持`,"capability.card.opTitleOff":`{op}:当前平台不支持`,"capability.card.opsSection":`平台特有操作`,"capability.card.refresh":`刷新`,"capability.card.noOps":`当前平台无特有操作`,"log.trigger":`日志`,"log.trigger.title":`日志:MCP 调用与连接事件`,"log.trigger.unread":`日志,有 {count} 条新错误`,"log.trigger.unit":`条错误`,"log.trigger.announce":`有 {count} 条新错误`,"log.drawer.title":`日志`,"log.drawer.count":`{shown} / {total} 条`,"log.drawer.clear":`清空`,"log.drawer.close":`关闭日志`,"log.drawer.filter.all":`全部`,"log.drawer.filter.info":`信息+`,"log.drawer.filter.warn":`警告+`,"log.drawer.filter.error":`错误`,"log.drawer.empty":`暂无日志。MCP 调用与连接事件会记录在这里。`,"log.drawer.emptyFiltered":`当前档位「{filter}」下没有日志,切到「全部」看完整记录。`,"log.drawer.copy":`复制`,"log.drawer.newCount":`↓ {count} 条新日志`,"bridge.log.superseded":`通道已被另一个插件面板接管,自动重连已停止(点面板顶部的「夺回」可切回)`,"bridge.log.confirmed":`服务已确认连接(版本 {version})`,"bridge.log.versionPush":`收到 npm 最新版本: 插件 {ui}、服务 {mcp}`,"bridge.log.versionUnknown":`未查到`,"bridge.log.handshakeTimeout":`WS 握手超时({ms}ms),放弃本次连接: {port}`,"bridge.log.serverConnected":`MCP server 已连接,等待服务确认: ws://localhost:{port}`,"bridge.log.confirmTimeout":`服务确认超时,关闭重连: {port}`,"bridge.log.closed":`连接断开: {port}`,"bridge.log.stale":`服务确认过期({ms}ms 未收到心跳),关闭重连: {port}`,"bridge.log.wsFailed":`WS 消息处理失败: {message}`,"bridge.log.recvRequest":`收到服务器请求: {method}`,"bridge.log.recvResponse":`收到服务器响应(忽略): {id}`,"bridge.log.forwardTimeout":`转发到插件超时: {method}`,"bridge.log.pluginTimeout":`插件响应超时`,"bridge.log.ignoreUnknown":`忽略未知插件消息: {type}`,"bridge.log.codeFailed":`code 消息处理失败: {message}`,"bridge.log.sendFailed":`发送响应失败(server 未连接): {id}`,"bridge.log.manualClose":`手动断开连接`,"bridge.log.capabilityMissing":`能力表回包异常(缺 platform)`,"bridge.log.capabilityFailed":`能力表获取失败: {message}`,"bridge.log.pingOk":`ping 插件成功: {data}`,"bridge.log.pingFailed":`ping 插件失败: {message}`,"bridge.error.useBridge":`useBridge 必须在 <BridgeProvider> 内使用`,"schema.base.r":`红色通道,范围 0-1(0=无,1=满),如纯红为 1;>1 视为 0-255,自动整组归一化`,"schema.base.g":`绿色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.b":`蓝色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理;>1 视为 0-255 自动归一化`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`变换矩阵,如 [[1,0,0],[0,1,0]] 表示无变换(Identity)`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表(与 callsFile 二选一)`,"schema.batch.callsFile":`步骤清单所在的 JSON 文件(绝对路径,与 calls 二选一)。参数体大到写不进上下文时用它 —— 文件内容为 {"calls":[…]}(或直接给一个数组,两种形状等价),形状与 calls 一致,可含 stopOnError / checkDrift。文件内容会被当作调用参数读入`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.type":`子节点类型`,"schema.executeSchemas.x":`相对父节点的 X(px)`,"schema.executeSchemas.y":`相对父节点的 Y(px)`,"schema.executeSchemas.x2":`X 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.y2":`Y 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.width":`宽度(px)`,"schema.executeSchemas.height":`高度(px)`,"schema.executeSchemas.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表(Paint 数组)`,"schema.executeSchemas.strokeWeight":`描边宽度(px)`,"schema.executeSchemas.strokeTopWeight":`描边顶部宽(px)`,"schema.executeSchemas.strokeBottomWeight":`描边底部宽(px)`,"schema.executeSchemas.strokeLeftWeight":`描边左侧宽(px)`,"schema.executeSchemas.strokeRightWeight":`描边右侧宽(px)`,"schema.executeSchemas.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.executeSchemas.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.executeSchemas.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.executeSchemas.dashPattern":`虚线段数组,如 [4,4]`,"schema.executeSchemas.effects":`效果列表(阴影/模糊,可多层叠加)`,"schema.executeSchemas.vertical":`自动布局中的约束`,"schema.executeSchemas.clipsContent":`是否裁剪溢出内容`,"schema.executeSchemas.cornerSmoothing":`圆角平滑度 0-1`,"schema.executeSchemas.layoutGrids":`布局网格(参考线)`,"schema.executeSchemas.cornerRadius":`圆角半径(px),四角统一`,"schema.executeSchemas.topLeftRadius":`左上圆角(px)`,"schema.executeSchemas.topRightRadius":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius":`右下圆角(px)`,"schema.executeSchemas.paddingTop":`上内边距(px)`,"schema.executeSchemas.paddingRight":`右内边距(px)`,"schema.executeSchemas.paddingBottom":`下内边距(px)`,"schema.executeSchemas.paddingLeft":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.executeSchemas.layoutGrow":`自动布局内伸缩系数`,"schema.executeSchemas.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.cornerRadius2":`圆角半径(px)`,"schema.executeSchemas.startingAngle":`起始角度(radians)`,"schema.executeSchemas.endingAngle":`结束角度(radians)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.innerRadius3":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.cornerRadius3":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius2":`左上圆角(px)`,"schema.executeSchemas.topRightRadius2":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius2":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius2":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),值越小角越尖锐`,"schema.executeSchemas.cornerRadius4":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius3":`左上圆角(px)`,"schema.executeSchemas.topRightRadius3":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius3":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius4":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius5":`STAR=星形(配合 pointCount + innerRadius)`,"schema.executeSchemas.vectorPaths":`矢量路径数组,每项含 SVG path data(如 "M0 0 L100 100")`,"schema.executeSchemas.fontSize":`字号(px),默认 16`,"schema.executeSchemas.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.executeSchemas.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.executeSchemas.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`行高:{value,unit},unit 为 PIXELS|PERCENT;或 {unit:"AUTO"}`,"schema.executeSchemas.letterSpacing":`字距:{value,unit},unit 为 PIXELS|PERCENT`,"schema.executeSchemas.letterSpacing2":`TEXT=文本(配合 characters/fontSize/fontName 等)`,"schema.executeSchemas.children":`子节点数组,至少 2 个;递归嵌套,最多 100 个直接子节点`,"schema.executeSchemas.paddingTop2":`上内边距(px)`,"schema.executeSchemas.paddingRight2":`右内边距(px)`,"schema.executeSchemas.paddingBottom2":`下内边距(px)`,"schema.executeSchemas.paddingLeft2":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode2":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`交叉轴对齐`,"schema.executeSchemas.path":`GROUP=分组(内部用 Frame 实现)`,"schema.executeSchemas.children2":`要合并的子节点数组(至少 2 个)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION=布尔运算(合并子节点)`,"schema.execute.name":`生成的图层名,默认 svg-design`,"schema.execute.html":`HTML 片段,支持内联 style`,"schema.execute.name2":`生成的图层名,默认 html-design`,"schema.execute.size":`图标边长 px,默认 24`,"schema.execute.color":`描边颜色(十六进制),默认 #000000`,"schema.execute.strokeWidth":`描边宽度,默认 2`,"schema.execute.name3":`生成的图层名,默认 icon-<图标名>`,"schema.inputs.ids":`按节点 id 精确查找,优先级最高`,"schema.inputs.name":`按名称模糊匹配(包含)`,"schema.inputs.recursive":`是否递归查找(默认 true)`,"schema.inputs.depth":`序列化深度:0=仅自身,1=含直接子节点;缺省 1`,"schema.inputs.name2":`仅 group:组名`,"schema.inputs.paddingTop":`仅 group。上内边距(px)`,"schema.inputs.paddingRight":`仅 group。右内边距(px)`,"schema.inputs.paddingBottom":`仅 group。下内边距(px)`,"schema.inputs.paddingLeft":`仅 group。左内边距(px)`,"schema.inputs.primaryAxisSizingMode":`仅 group。主轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisSizingMode":`仅 group。交叉轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisAlignItems":`仅 group。交叉轴对齐:MIN|MAX|CENTER`,"schema.inputs.key":`团队库组件唯一标识 Key(仅 import_component 必填)`,"schema.inputs.componentId":`目标组件(COMPONENT)节点 id(仅 swap_component 必填)`,"schema.inputs.format":`导出格式,默认 PNG`,"schema.inputs.scale":`缩放倍率(PNG/JPG),默认 1`,"schema.inputs.savePath":`落盘文件绝对路径,如 /tmp/icon.png`,"schema.inputs.includeDataUrl":`是否同时返回 base64 dataURL,默认 false`,"schema.inputs.ids2":`要填充图片的节点 id 列表`,"schema.inputs.sourcePath":`本地图片文件绝对路径,如 /tmp/poster.png`,"schema.inputs.params":`操作参数,结构随 op 而定`,"schema.inputs.family":`按家族名过滤(不区分大小写的子串),如 "Source" 或 "思源"`,"schema.inputs.offset":`分页起始序号(跳过多少族),默认 0`,"schema.inputs.limit":`本页最多返回多少族,默认 50、上限 500;字体库可达约 1900 族,整表会撑爆上下文`,"schema.platform.name":`op 名,调用 jsd_platform_op 时原样传`,"schema.platform.description":`含 params 形状说明`,"schema.results.capabilities":`当前平台支持的能力列表(先查此字段再决定能否调用平台特有操作)`,"schema.results.families":`可用字体族(family)列表`,"schema.results.family":`字体族`,"schema.results.styles":`该族可用字型,如 ["Regular","Medium","Bold"]`,"schema.results.count":`本页返回的字体族数量`,"schema.results.total":`过滤后的字体族总数(不受分页影响)`,"schema.results.offset":`本页起始序号`,"schema.results.truncated":`为 true 表示还有下一页,用 offset 继续取`,"schema.sharedProps.width":`宽度(px)`,"schema.sharedProps.height":`高度(px)`,"schema.sharedProps.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.sharedProps.opacity":`不透明度 0-1`,"schema.sharedProps.pointCount":`多边形/星形角点数(仅 POLYGON/STAR 生效)`,"schema.sharedProps.innerRadius":`星形内半径比例(0-1,相对外半径;仅 STAR 生效)`,"schema.sharedProps.strokes":`描边列表(Paint 数组;整体替换,非合并,需保留的描边要一并传入)`,"schema.sharedProps.strokeWeight":`描边宽度(px)`,"schema.sharedProps.strokeTopWeight":`描边顶部宽(px)`,"schema.sharedProps.strokeBottomWeight":`描边底部宽(px)`,"schema.sharedProps.strokeLeftWeight":`描边左侧宽(px)`,"schema.sharedProps.strokeRightWeight":`描边右侧宽(px)`,"schema.sharedProps.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.sharedProps.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.sharedProps.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.sharedProps.dashPattern":`虚线段数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.topLeftRadius":`左上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.topRightRadius":`右上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomLeftRadius":`左下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomRightRadius":`右下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.characters":`文本内容(仅 TEXT 节点生效)`,"schema.sharedProps.fontSize":`字号(px)`,"schema.sharedProps.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.sharedProps.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.sharedProps.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.sharedProps.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.sharedProps.lineHeight":`行高:{value,unit}`,"schema.sharedProps.letterSpacing":`字距:{value,unit}`,"schema.sharedProps.textStyleId":`文本样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.textTruncation":`文本截断(DISABLED=不截断,ENDING=末尾省略号截断),仅 Figma 生效`,"schema.sharedProps.maxLines":`文本最大行数,仅 Figma 生效`,"schema.sharedProps.paddingTop":`上内边距(px)`,"schema.sharedProps.paddingRight":`右内边距(px)`,"schema.sharedProps.paddingBottom":`下内边距(px)`,"schema.sharedProps.paddingLeft":`左内边距(px)`,"schema.sharedProps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.sharedProps.layoutGrow":`自动布局内伸缩系数`,"schema.sharedProps.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.sharedProps.fillStyleId":`填充样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effectStyleId":`效果样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effects":`效果列表(阴影/模糊,可多层叠加;整体替换,非合并)`,"schema.sharedProps.vertical":`自动布局中的约束`,"schema.sharedProps.clipsContent":`是否裁剪溢出内容`,"schema.sharedProps.cornerSmoothing":`圆角平滑度 0-1`,"schema.sharedProps.layoutGrids":`布局网格(参考线)`,"schema.sharedProps.startingAngle":`起始角度(radians)`,"schema.sharedProps.endingAngle":`结束角度(radians)`,"schema.sharedProps.innerRadius2":`内半径(0-1 ratio)`,"schema.sharedProps.innerRadius3":`环形路径参数(弧线),仅 ELLIPSE 节点生效`,"schema.splitOps.ids":`目标节点 id 列表;缺省时作用于当前选中节点`,"schema.splitOps.matchName":`按节点 name 精确过滤(精确等值,非模糊/包含),仅命中节点被修改`,"schema.splitOps.ids2":`要删除的节点 id 列表;缺省时删除当前选中节点`,"schema.splitOps.matchName2":`在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`,"schema.splitOps.name":`组名`,"schema.splitOps.paddingTop":`上内边距(px)`,"schema.splitOps.paddingRight":`右内边距(px)`,"schema.splitOps.paddingBottom":`下内边距(px)`,"schema.splitOps.paddingLeft":`左内边距(px)`,"schema.splitOps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.splitOps.ids3":`要清理的已损坏节点 id 列表;缺省时清理当前页全部损坏节点`,"schema.splitOps.name2":`组件名称`,"schema.splitOps.key":`团队库组件唯一标识 Key`,"schema.splitOps.name3":`导入后的节点名称`,"schema.splitOps.componentId":`目标组件(COMPONENT)节点 id`,"schema.splitOps.name4":`变体集名称`,"schema.splitOps.sourceId":`源实例 id,即先前 copy_overrides 返回的 snapshotId`,"schema.splitOps.name5":`节点新名称`,"batch.title":`批量编排执行`,"batch.followUp":`编排执行后复核画布结果`,"createComponent.title":`建组件`,"createComponent.description":`建组件(COMPONENT)并返回新 id。传 children 时一次建成带内容的组件(字段同 jsd_create_frame 的 children),可再传 width/height 定尺寸,不必再手工 reparent 搬子节点;不传 children 则是空壳,后续用 jsd_reparent_nodes 归组。原节点不会被固化也不会被改动 —— 组件一律新建(避免把已有节点卷进 wrapper)。变体命名用「属性=值, 属性=值」,变体属性用 jsd_set_instance_properties`,"createComponent.description2":`调整组件尺寸 / 补齐填充、圆角、阴影`,"createInstance.title":`生成组件实例`,"createInstance.description":`设置实例的变体属性`,"detachInstance.title":`取消实例链接`,"detachInstance.description":`解链后自由编辑新节点样式`,"importComponent.title":`从团队库导入组件`,"importComponent.description":`为导入的组件生成实例`,"swapComponent.title":`换绑组件`,"swapComponent.description":`换绑后设置变体属性`,"setInstanceProperties.title":`设置变体属性`,"setInstanceProperties.description":`批量同步其他实例的覆盖`,"combineAsVariants.title":`合并为变体集`,"copyOverrides.title":`复制实例覆盖快照`,"copyOverrides.description":`把快照套用到目标实例`,"applyOverrides.title":`套用实例覆盖快照`,"applyOverrides.description":`继续同步其他实例的覆盖`,"syncOverrides.title":`同步实例覆盖`,"syncOverrides.description":`复核同步后的实例`,"createFrame.title":`创建 Frame 容器`,"createFrame.description":`创建单个 FRAME 容器节点,入参只含 FRAME 字段:width/height 尺寸、layoutMode 自动布局(itemSpacing/padding*/主轴交叉轴尺寸对齐)与填充描边等视觉字段。本工具只建一个根 FRAME;children 只用于「容器 + 其直属子节点」这类小结构(子节点 x/y 相对父节点),**别把整屏的整棵树塞进一次 children**(易整批失败)—— 分层分批用 jsd_batch 编排,再用 jsd_reparent_nodes 逐层归组。auto-layout 前必须设 layoutMode=HORIZONTAL 或 VERTICAL(否则布局字段被忽略)。未显式传 fills 时引擎默认白底,透明容器传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]。**name 必传且语义化**(如「侧栏」「KPI-设备综合效率」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createRectangle.title":`创建矩形`,"createRectangle.description":`创建单个 RECTANGLE 矩形节点,入参只含矩形字段:width/height 尺寸、cornerRadius 四角圆角与填充描边等视觉字段。本工具只建一个根矩形;children 只用于小结构(子节点 x/y 相对父节点)。**name 必传且语义化**(如「卡片底板」「图表-网格线」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createText.title":`创建文本`,"createText.description":`创建单个 TEXT 文本节点,入参只含文本字段:characters 必填内容、fontSize/fontName 字号字体、对齐/自适应/大小写/装饰/行高/字距与填充描边。本工具只建一个根文本;children 只用于小结构(子节点 x/y 相对父节点)。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样(如 SourceHanSansCN_family),style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,命中时结果 warnings 点名。长段落要换行:TEXT 缺省按内容撑开,显式 width 会被覆盖 —— 传 width + textAutoResize:"HEIGHT";要固定框尺寸传 "NONE"。**name 必传且语义化**(如「标题-近30天产出」「KPI 数值」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createEllipse.title":`创建椭圆`,"createEllipse.description":`创建单个 ELLIPSE 椭圆节点,width/height 尺寸、arcData 环形参数(可画环)与填充描边等视觉字段。本工具只建一个根椭圆。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createLine.title":`创建线段`,"createLine.description":`创建单个 LINE 线段节点,width/height 尺寸与描边等视觉字段。本工具只建一个根线段;短直线段建议 LINE+rotation 布局更稳定。横线/竖线可把一维传 0:引擎 resize 校验要求 >= 0.01,插件创建时把零轴抬到 0.01 过校验(视觉是直线,序列化回读该轴仍是 0);jsd_resize_node 改尺寸同样支持零轴。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createPolygon.title":`创建多边形`,"createPolygon.description":`创建单个 POLYGON 多边形节点,pointCount 角点数必填(如 6=六边形)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根多边形。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createStar.title":`创建星形`,"createStar.description":`创建单个 STAR 星形节点,pointCount 角点数与 innerRadius 内半径比例必填(如 5 角、0.5)、cornerRadius 圆角与填充描边等视觉字段。本工具只建一个根星形。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createVector.title":`创建矢量`,"createVector.description":`创建单个 VECTOR 矢量节点,vectorPaths 必填(每项含 SVG path data,如 "M0 0 L100 100")与填充描边等视觉字段。本工具只建一个根矢量。⚠ 已知平台缺陷:创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createGroup.title":`创建编组`,"createGroup.description":`创建单个 GROUP 编组节点,children 必填且至少 2 个子节点(内部用 Frame 实现),可带 auto-layout 布局字段(layoutMode/itemSpacing/padding*)。本工具只建一个根编组;要固定坐标的根层级用 placement 控制。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"createBooleanOperation.title":`创建布尔运算节点`,"createSvg.title":`导入 SVG`,"createSvg.description":"将 SVG 直接导入画布为可编辑图层(createNodeFromSvg 原生解析,保留路径/渐变/描边)。来源二选一:svg(内联字符串)或 svgPath(本地 .svg 文件路径,由后台服务读盘)。**图表 / 数据可视化一律走 svgPath**(折线图、柱状图、饼图 / 环形图、散点图、雷达图、面积图、仪表盘、看板、桑基图……):没有内置图表工具 —— 先自己写脚本把 SVG 算好、落到本地文件,再传路径。引擎硬约束(违反会静默画不出来):根元素必须带 xmlns 与显式 width/height/viewBox;颜色只写 hex;不引外链图片/字体/script;曲线用 C/Q 自己近似,不要用 A 指令;画布 ≤2000×2000;按语义层切 `<g id>`(一层不套等于没分组),绘图区只在外层写一个 transform。动手前先 ReadMcpResource 读配方 jsd://recipes/chart-by-code —— 内含零依赖示例、配色字号口径、导入后回读层级与导图验收清单。建多个根节点/复杂树用 jsd_batch 编排","createIcon.title":`插入内置图标`,"htmlToDesign.title":`HTML 转设计节点`,"htmlToDesign.description":`将 HTML 片段转成矢量图层(SVG 保真,忽略复杂样式);需要逐节点可编辑的结构时改用 jsd_create_rectangle / jsd_create_text 等手工搭建后再 jsd_batch 编排`,"manageNodes.title":`节点结构操作(聚合)`,"manageNodes.followUp":`结构改完后设置容器自动布局`,"manageComponents.title":`组件与实例操作(聚合)`,"manageComponents.description":`按 op 分发的组件/实例操作聚合入口:create_component|create_instance|detach_instance|import_component|swap_component|set_instance_properties|combine_as_variants|copy_overrides|apply_overrides|sync_overrides。单次单操作请优先用对应小工具:jsd_create_component / jsd_create_instance / jsd_detach_instance / jsd_import_component / jsd_swap_component / jsd_set_instance_properties / jsd_combine_as_variants / jsd_copy_overrides / jsd_apply_overrides / jsd_sync_overrides(描述含平台缺陷与正确流程)。节点结构操作用 jsd_manage_nodes,两工具 op 不通用`,"manageComponents.description2":`组件/实例改完后设置变体属性`,"find.title":`查找节点`,"find.description":`把查到的节点设为当前选中,便于后续修改/删除`,"selectNodes.title":`设置画布选中`,"selectNodes.description":`选中后移动/调整选中节点`,"deleteNode.title":`删除节点`,"deleteNode.description":`删除后复核剩余节点`,"cloneNode.title":`复制节点`,"cloneNode.description":`把副本移到目标位置`,"groupNodes.title":`编组节点`,"groupNodes.description":`编组后设置组内自动布局`,"ungroupNodes.title":`解组节点`,"ungroupNodes.description":`解组后调整子节点位置`,"flattenNodes.title":`合并为矢量`,"flattenNodes.description":`烘焙后设置合并图形的填充`,"outlineStroke.title":`描边转轮廓`,"outlineStroke.description":`调整新轮廓的描边`,"reparentNodes.title":`移动节点到父节点下`,"reparentNodes.description":`移动后按需微调新父下的 x/y(绝对位置已自动保持)`,"repairNodes.title":`清理损坏节点`,"repairNodes.description":`清理后复核页面节点状态`,"platformOp.title":`平台特有操作`,"platformOp.description":`执行平台特有能力(Figma:变量/本地样式/组件属性;MasterGo:变量读写/组件属性/集合级变体管理等)。CRITICAL: 不要凭空猜测 op 名与参数——先 jsd_ping 读 platformOps 名单(含每个 op 的参数形状说明)与 capabilities,再按名单里的名字调用;平台不支持或 op 名写错时返回错误并列出当前平台支持的 op`,"platformOp.description2":`复核平台操作在画布上的效果`,"prompt.htmlToDesign.title":`HTML 转设计稿`,"prompt.htmlToDesign.description":`把一段 HTML 转为画布节点,含保真度取舍说明`,"prompt.iconGrid.title":`图标网格`,"prompt.iconGrid.description":`批量插入 Lucide 图标并排成自动布局网格`,"prompt.scriptOps.title":`脚本化批量调用`,"prompt.chartByCode.title":`代码画图表 / 数据可视化`,"prompt.chartByCode.description":`画图表 / 数据可视化的主路径:折线图、柱状图、饼图 / 环形图、散点图、雷达图、面积图、仪表盘、看板等任意图表,都由自己写代码算几何、落盘 SVG,再经 jsd_create_svg 导入(含零依赖示例与引擎侧硬约束)`,"prompt.designStrategy.title":`设计策略总纲`,"prompt.textReplace.title":`文本批量替换策略`,"prompt.variantSync.title":`同类实例样式批量同步`,"prompt.variableBinding.title":`变量绑定与批量套用`,"prompt.variantSet.title":`变体集构建`,"prompt.componentProperty.title":`组件属性定义与设值`,"setFillColor.title":`设置填充`,"setFillColor.followUp":`接着设置描边`,"setStroke.title":`设置描边`,"setStroke.description":`接着设置填充`,"setCornerRadius.title":`设置圆角`,"setCornerRadius.description":`接着设置阴影/模糊效果`,"setText.title":`修改文本`,"setText.followUp":`给文本起个语义名称`,"moveNode.title":`移动节点`,"moveNode.description":`接着调整尺寸`,"resizeNode.title":`调整节点尺寸`,"resizeNode.description":`接着设置可见性/锁定`,"setLayout.title":`设置自动布局`,"setLayout.description":`把子节点移入容器完成排布`,"setEffects.title":`设置效果与高级属性`,"setEffects.description":`接着设置可见性/锁定`,"setVisibility.title":`设置可见性与锁定`,"setVisibility.description":`复核改动后的画布选中`,"renameNode.title":`重命名节点`,"renameNode.description":`接着改文本内容/排版`,"setShape.title":`设置多边形/星形形状`,"setShape.description":`接着设置填充`,"export.title":`导出节点为图片`,"export.description":`导出节点为 PNG/JPG/SVG/PDF;ids 为必填数组(单节点也写成 ids:["123:456"],不是 nodeId),savePath 落盘与 includeDataUrl 返回 base64 可并存。注意:单张图片超过内联上限(默认 512KB)时不返回 base64,自动落盘并返回路径引用,避免撑爆会话内存。完整字段见 inputSchema。`,"export.description2":`导出后用该图片填充到节点`,"fillImage.title":`本地图片填充节点`,"fillImage.description":`读取本地图片文件填充到指定节点(IMAGE fill)`,"fillImage.description2":`复核图片填充效果`,"listFonts.title":`列出可用字体`,"listFonts.description":`用列出的字体设置文本`,"createStyle.title":`建本地样式`,"createStyle.description":"从**某个既有节点**建一条本地样式,回它的 id 与名称。类别取八项(三家 `StyleType` 的并集):PAINT / TEXT / EFFECT / GRID **三家都有**;STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING **只 MasterGo 能建**—— 另两家没有对应工厂,传过去会被写前点名拒并列出本平台可建的类别(不会静默建成别的类)。三平台唯一都成立的形状是「从这个图层抄」:MG 原生即 `createFillStyle({name, id: 图层id})` 由引擎取该图层样式;Figma / jsDesign 是无参工厂建空样式后由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进去。PAINT 类 fills 优先,节点只有描边时退到 strokes(所以一个既无填充又无描边的节点会直接报错,而不是建出一条空样式)。取值字段为混值(mixed,如一段文字用了两个字体)时报错并说明先用 jsd_set_text 统一;新那四类同此纪律 —— 间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值就在发起请求前拦下。建完就用 id 绑:`jsd_set_fill_color` 的 fillStyleId / `jsd_set_stroke` 的 strokeStyleId / `jsd_set_text` 的 textStyleId / `jsd_set_effects` 的 effectStyleId —— 之后改这条样式全档跟随,这是没有变量面的平台(即时设计)上做统一色板的正路。清单读 `jsd://styles`(只读资源)","createStyle.followUp":`把新建的样式 id 绑到节点上`,"deleteStyle.title":`删本地样式`,"deleteStyle.description":"按 id 删本地样式(ids 一次传多个),逐条删:单条 id 不存在只进结果的 failed 并给原因,不影响其余条。id 取自 jsd://styles 或 jsd_get_page 的 assets.styles —— **按 id 不按名**,同名样式可以并存,按名删等于猜要删哪一条。与 `jsd_create_style` 成对(建 / 撤都有入口才谈得上试错),变量的删除在平台 op `figma_variables_remove`(Figma)/ `mg_variables_remove`(MasterGo)。⚠ 被节点引用中的样式删掉后,那些节点的 `*StyleId` 会指向不存在的样式(引擎不级联清理),要一起改就先把它们重绑到别的样式;本仓没有「谁在用这条样式」的反查入口(Figma 有 `getStyleConsumersAsync`,未接)","deleteStyle.followUp":`删完读一次样式清单确认`,"resources.title":`画布当前选中`,"resources.title2":`可用字体列表`,"resources.title3":`本地样式列表`,"resources.title4":`当前页概览:第一层节点 + 可复用资源清单`,"resources.title5":`节点详情`,"resources.title6":`平台状态与能力表`,"resources.title7":`配方索引`,"resources.title8":`配方正文`,"ping.followUp":`连接确认后读取当前选中;创作类任务先读 design-strategy 配方`,"getSelection.title":`读取画布选中`,"getSelection.description":`获取画布当前选中节点的序列化树(名称/类型/尺寸/位置/填充/子结构);depth 控制层级深度,默认 2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上),判断遮挡读 z 即可`,"getSelection.description2":`在选中范围内继续精确查找节点`,"getPage.title":`当前页概览:第一层节点 + 可复用资源清单`,"getPage.description":`**当前页**的两段只读概览。①nodes:**当前页第一层**节点的几何(id/名称/类型/宽高/x/y,不递归);②assets:可复用资源清单 —— summary 给四类计数,components 组件、variants 变体集(带「维度→可选值」)、styles 样式(PAINT/TEXT/EFFECT/GRID,带 type)、variables 变量,每项含 id 与名称。范围说明:**样式与变量是文档级**(引擎的枚举 API 本身就是文档级,与页面无关);组件与变体按平台 —— 能读非当前页的平台覆盖全文档,读不到的(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前的第一步就是读这里:命中同名/同用途的组件、变体取值、样式、变量一律复用,禁止新建重复件**;清单里没有才允许新建。某个面在本平台未声明对应能力时该项为空数组,不报错(即时设计无变量面、列不出样式清单);成因写在 note 里 —— **空数组 ≠ 文档里没有**;变体的 properties 键在平台读不到该字段时整体省略(不写成空对象)。从头设计整页前先读这里,看页面已有内容与能复用的件;资源的细节按 id 走 jsd_find。另附 pages:各页名与顶层节点数;dynamic-page 平台首次读取会全量加载文档并在 note 点名成本(幂等,再次调用不再加载)。读不到非当前页的平台(即时设计/MasterGo)资源清单与 pages 只覆盖当前页,note 同样点名 —— 那不等于文档只有一页`,"getPage.followUp":`按 id 读取具体节点的序列化结构;要跨页查找传 scope=document`,"mcp.instructions":`操作设计画布的工具集。一个操作对应一个 jsd_* 工具,无 op 分发;聚合入口 jsd_manage_nodes / jsd_manage_components 仅用于批量/混合结构操作。调用纪律:
|
|
9
9
|
- **设计/创作类任务的第一步是读 jsd_get_page 的资源清单**(assets.summary 给组件/变体/样式/变量四类计数):命中的一律复用 —— 组件用 jsd_create_instance、变体切到已有取值用 jsd_set_instance_properties、样式与变量按本平台 platformOps 的入口;只有清单里确实没有,才允许新建同名/同用途的件(新建时按「组件族/状态」命名,方便下次复用)。
|
|
10
10
|
- 建节点用 per-type 工具:jsd_create_frame / jsd_create_rectangle / jsd_create_text 等,每个工具只建一类节点;多根/复杂嵌套树用 jsd_batch 编排多个建节点步骤。**根节点的 x/y 由 placement 决定**(缺省 center 用视口中心覆盖根节点自身的 x/y;要按坐标排布传 placement:{mode:"manual"},或 mode:"absolute"+x/y 统一坐标),**层级结构要建够,别只做到一层**:children 只用于「容器 + 其直属子节点」这类小结构(子节点 x/y 相对父节点),整屏的整棵树别塞进一次 children;每个元素都要归到语义容器里,不许直挂屏根 —— 屏 → 语义分区(侧栏 / 顶栏 / 筛选条 / KPI 行 / 每张卡片)→ 卡片内图元按语义编组。name 必传且语义化(不传会落成引擎默认名 node)。建完再 jsd_reparent_nodes 归组(**parentId 显式传目标容器 id**;跨父级移动会保持节点绝对位置,内部自动换算新父下的 x/y,不用手动摆回,移入 auto-layout 容器时位置由布局接管);auto-layout(layoutMode/itemSpacing/padding* 等)最后用 jsd_set_layout 单独设置。
|
|
11
11
|
- 改属性用专责工具:填充 jsd_set_fill_color、描边 jsd_set_stroke、圆角 jsd_set_cornerRadius、文本 jsd_set_text、位置 jsd_move_node、尺寸 jsd_resize_node(可同时传 x/y)、布局 jsd_set_layout、效果 jsd_set_effects、显隐 jsd_set_visibility、改名 jsd_rename_node、形状 jsd_set_shape。
|
|
@@ -16,13 +16,13 @@ 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;批量改文案 → 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);id 重复/未知工具/引用失败立即中止,工具执行失败默认也中止(stopOnError=false 或单步 continueOnError=true 可走完)。\\n回显已做摘要裁剪:节点对象只留 id/name/type/x/y/width/height/z/parentId,vectorPaths(单条 >10KB、16 位小数)与 constraints 等渲染无关字段整键丢弃;裁剪后仍超 20K 字符的步骤降级为 id 清单(结果里 echoTrimmed=true)。占位符解析不受影响(内部仍用完整数据)。含图标的批次(jsd_create_icon / jsd_clone_node / jsd_create_vector)务必配一次 jsd_export 目视验收,别只看回显。\\n各工具返回键与占位符写法(键写错会报「无法解析占位符引用」并中止整批):\\n· created 为数组 → {{id.created[0].id}}:per-type create(jsd_create_rectangle / jsd_create_frame 等)、jsd_clone_node、jsd_outline_stroke、jsd_create_instance、jsd_detach_instance\\n· created 为单对象 → {{id.created.id}}:jsd_create_svg / jsd_create_icon / jsd_flatten_nodes / jsd_group_nodes / jsd_create_component / jsd_import_component / jsd_combine_as_variants\\n· jsd_find → {{id.nodes[0].id}};jsd_get_selection → {{id.selection[0].id}}\\n· 属性类 jsd_set_* → {{id.updated[0].id}};jsd_swap_component → {{id.swapped[0].id}}\\n· jsd_manage_nodes 各 op:select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**,与 jsd_group_nodes / jsd_flatten_nodes 同形)、ungroup→ungrouped[](id 字符串)、reparent→moved[](与 updated[] 同义,两个键都回)、repair→cleaned[](id 字符串)—— id 字符串数组取 {{id.selected[0]}},节点数组取 {{id.created[0].id}},节点单对象取 {{id.created.id}}(单对象与单元素数组互认:`{{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),别临场拼工具。'","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/对齐/自适应/大小写/装饰/行高/字距,以及 Figma 的截断与最大行数。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算)。{warn};characters 内容覆盖在实例内也是正常生效的`,"ping.description":`检查插件是否在线(需先在{client}(即时设计或 Figma)中运行该插件并保持运行)。返回三个能力表:coreCapabilities 为核心能力(create/modify/structure/component/export/image,两平台一致);capabilities 只列平台差异超集(如 variables/componentProperties/textTruncation),即时设计通常只有 styles,Figma 还会有 variables/componentProperties 等;platformOps 列当前平台可用的特有操作(名/标题/参数说明),调 jsd_platform_op 前先读它。回包会被 daemon 缓存,后续可直接读 jsd://platform/state(不必重复 ping)`},x=[`jsdesign`,`figma`,`mastergo`],S={jsdesign:Vt[`platform.jsdesign`],figma:Vt[`platform.figma`],mastergo:Vt[`platform.mastergo`]},Ht=m.enum(x),Ut=m.enum(we),Wt=m.enum(Ee),Gt=m.object({name:m.string().describe(`schema.platform.name`),title:m.string(),description:m.string().describe(`schema.platform.description`)}),Kt=m.object({type:m.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`]),value:m.union([m.boolean(),m.string()]),preferredValues:m.array(m.object({type:m.enum([`COMPONENT`,`COMPONENT_SET`]),key:m.string()})).optional()}),qt=m.object({visible:m.string().optional(),characters:m.string().optional(),mainComponent:m.string().optional()}),Jt=m.union([m.string(),m.boolean(),Kt]),Yt=m.object({type:m.literal(`VARIABLE_ALIAS`),id:m.string()}),Xt=m.record(m.string(),m.union([Yt,m.array(Yt),m.record(m.string(),Yt)])),Zt=yt.slice(mt.length).join(`/`),Qt=m.object({ids:m.array(m.string()).optional().describe(`schema.inputs.ids`),name:m.string().optional().describe(`schema.inputs.name`),type:m.string().optional().describe(`节点类型过滤,支持:${mt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${Zt}),这些类型能读不能建`),scope:m.enum(Bt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)。⚠ 读不到非当前页的平台(即时设计/MasterGo)会自动退回当前页并在 note 点名 —— 结果只含当前页,不是全文档`),recursive:m.boolean().optional().describe(`schema.inputs.recursive`),depth:m.number().optional().describe(`schema.inputs.depth`)}),$t=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],en=m.object({op:m.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return $t.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:m.array(m.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:m.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:m.string().optional().describe(`schema.inputs.name2`),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:m.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:m.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:m.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:m.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:m.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`})}),tn=m.object({op:m.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:m.array(m.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:m.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:m.string().optional().describe(`schema.inputs.key`),componentId:m.string().optional().describe(`schema.inputs.componentId`),properties:m.record(m.string(),Jt).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:m.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:m.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`)}),nn=m.object({ids:m.array(m.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:m.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:m.number().optional().describe(`schema.inputs.scale`),savePath:m.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:m.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),rn=m.object({family:m.string().optional().describe(`schema.inputs.family`),offset:m.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:m.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});m.object({});var an=m.object({}),on=m.object({ids:m.array(m.string()).describe(`schema.inputs.ids2`),sourcePath:m.string().describe(`schema.inputs.sourcePath`)}),sn=m.object({op:m.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:m.record(m.string(),m.unknown()).optional().describe(`schema.inputs.params`)}),cn=[`PAINT`,`TEXT`,`EFFECT`,`GRID`],C=m.lazy(()=>m.object({id:m.string(),name:m.string(),type:xt,x:m.number(),y:m.number(),width:m.number().optional(),height:m.number().optional(),rotation:m.number().optional(),opacity:m.number().optional(),visible:m.boolean().optional(),locked:m.boolean().optional(),parentId:m.string().optional(),z:m.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:m.array(v).optional(),strokes:m.array(v).optional(),strokeWeight:m.number().optional(),strokeTopWeight:m.number().optional(),strokeBottomWeight:m.number().optional(),strokeLeftWeight:m.number().optional(),strokeRightWeight:m.number().optional(),strokeAlign:m.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:m.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:m.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:m.array(m.number()).optional(),cornerSmoothing:m.number().optional(),blendMode:_.optional(),constraints:m.object({horizontal:it,vertical:it}).optional(),layoutGrids:m.array(at).optional(),clipsContent:m.boolean().optional(),arcData:m.object({startingAngle:m.number(),endingAngle:m.number(),innerRadius:m.number()}).optional(),effects:m.array(rt).optional(),cornerRadius:m.number().optional(),topLeftRadius:m.number().optional(),topRightRadius:m.number().optional(),bottomLeftRadius:m.number().optional(),bottomRightRadius:m.number().optional(),pointCount:m.number().optional(),innerRadius:m.number().optional(),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:m.number().optional(),paddingTop:m.number().optional(),paddingRight:m.number().optional(),paddingBottom:m.number().optional(),paddingLeft:m.number().optional(),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:m.number().optional(),layoutAlign:m.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:m.number().optional(),children:m.array(C).optional(),characters:m.string().optional(),fontSize:m.number().optional(),fontName:st.optional(),textAlignHorizontal:m.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:m.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:m.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:m.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:m.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:ct.optional(),letterSpacing:lt.optional(),vectorPaths:m.array(ot).optional(),booleanOperation:m.enum(ke).optional(),isMask:m.boolean().optional(),variantProperties:m.record(m.string(),m.string()).optional(),mainComponentId:m.string().optional(),variantGroupProperties:m.record(m.string(),m.array(m.string())).optional(),textTruncation:m.enum([`DISABLED`,`ENDING`]).optional(),maxLines:m.number().optional(),fillStyleId:m.string().optional(),strokeStyleId:m.string().optional(),textStyleId:m.string().optional(),effectStyleId:m.string().optional(),componentProperties:m.record(m.string(),Kt).optional(),componentPropertyReferences:qt.optional(),boundVariables:Xt.optional()})),ln=m.object({created:m.union([C,m.array(C)]),warnings:m.array(m.string()).optional()}),un=m.object({updated:m.array(C),warnings:m.array(m.string()).optional()}),dn=m.object({connected:m.boolean(),platform:Ht.optional(),capabilities:m.array(Ut).optional().describe(`schema.results.capabilities`),coreCapabilities:m.array(Wt).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:m.array(Gt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:m.string().optional()}),fn=m.object({selection:m.array(C),pageName:m.string()}),pn=m.object({nodes:m.array(C),total:m.number(),scope:m.enum(Bt).optional(),note:m.string().optional()}),mn=m.object({selected:m.array(m.string()).optional(),removed:m.array(m.string()).optional(),ungrouped:m.array(m.string()).optional(),moved:m.array(C).optional(),updated:m.array(C).optional(),cleaned:m.array(m.string()).optional(),created:m.union([C,m.array(C)]).optional()}),hn=m.object({variantProperties:m.record(m.string(),m.string()).optional(),componentProperties:m.record(m.string(),Kt).optional(),propsSummary:m.array(m.string()).optional()}),gn=m.object({instanceId:m.string(),instanceName:m.string(),ok:m.boolean(),message:m.string().optional()}),_n=m.object({created:m.union([C,m.array(C)]).optional(),swapped:m.array(C).optional(),updated:m.array(C).optional(),snapshotId:m.string().optional(),sourceName:m.string().optional(),captured:hn.optional(),applied:m.array(gn).optional(),source:hn.optional(),failed:m.array(m.object({id:m.string(),message:m.string()})).optional(),warnings:m.array(m.string()).optional()}),vn=m.object({exports:m.array(m.object({id:m.string(),name:m.string(),format:m.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:m.string(),size:m.number(),path:m.string().optional(),dataUrl:m.string().optional()}))}),yn=m.object({families:m.array(m.string()).describe(`schema.results.families`),fonts:m.array(m.object({family:m.string().describe(`schema.results.family`),styles:m.array(m.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:m.number().describe(`schema.results.count`),total:m.number().optional().describe(`schema.results.total`),offset:m.number().optional().describe(`schema.results.offset`),truncated:m.boolean().optional().describe(`schema.results.truncated`)}),bn=m.object({id:m.string(),name:m.string()}),xn=bn.extend({properties:m.record(m.string(),m.array(m.string())).optional().describe(`维度 → 可选值,如 {"状态":["默认","禁用"]};平台读不到该字段时整个键省略`)}),Sn=bn.extend({type:m.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])}),Cn=m.object({summary:m.object({components:m.number(),variants:m.number(),styles:m.number(),variables:m.number()}),components:m.array(bn),variants:m.array(xn),styles:m.array(Sn),variables:m.array(bn)}),wn=m.object({pageName:m.string(),nodes:m.array(m.object({id:m.string(),name:m.string(),type:xt,x:m.number(),y:m.number(),width:m.number().optional(),height:m.number().optional()})),count:m.number(),assets:Cn.optional(),pages:m.array(m.object({name:m.string(),childCount:m.number()})).optional(),note:m.string().optional()});m.object({styles:m.array(m.object({id:m.string(),name:m.string(),type:m.enum(cn)})),count:m.number(),note:m.string().optional()});var w=m.object({x:m.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:m.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:m.number().optional().describe(`schema.sharedProps.width`),height:m.number().optional().describe(`schema.sharedProps.height`),rotation:m.number().optional().describe(`schema.sharedProps.rotation`),opacity:m.number().optional().describe(`schema.sharedProps.opacity`),visible:m.boolean().optional(),locked:m.boolean().optional()}),Tn=m.object({width:m.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:m.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),En=m.object({pointCount:m.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:m.number().optional().describe(`schema.sharedProps.innerRadius`)}),Dn=m.object({strokes:m.array(v).optional().describe(`schema.sharedProps.strokes`),strokeWeight:m.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:m.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:m.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:m.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:m.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:m.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:m.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.sharedProps.strokeCap`),strokeJoin:m.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.sharedProps.strokeJoin`),dashPattern:m.array(m.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:m.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),On=m.object({cornerRadius:m.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:m.number().optional().describe(`schema.sharedProps.topLeftRadius`),topRightRadius:m.number().optional().describe(`schema.sharedProps.topRightRadius`),bottomLeftRadius:m.number().optional().describe(`schema.sharedProps.bottomLeftRadius`),bottomRightRadius:m.number().optional().describe(`schema.sharedProps.bottomRightRadius`)}),kn=m.object({characters:m.string().optional().describe(`schema.sharedProps.characters`),fontSize:m.number().optional().describe(`schema.sharedProps.fontSize`),fontName:st.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:m.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:m.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:m.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:m.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.sharedProps.textCase`),textDecoration:m.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.sharedProps.textDecoration`),lineHeight:ct.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:lt.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:m.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:m.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:m.number().optional().describe(`schema.sharedProps.maxLines`)}),An=m.object({layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:m.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:m.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:m.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:m.enum(Fe).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum(Ie).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:m.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:m.enum(Pe).optional().describe(`schema.sharedProps.layoutAlign`)}),T=m.object({fills:m.array(v).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:m.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:_.optional(),effectStyleId:m.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:m.array(rt).optional().describe(`schema.sharedProps.effects`),constraints:m.object({horizontal:it.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:it.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:m.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:m.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:m.array(at).optional().describe(`schema.sharedProps.layoutGrids`),arcData:m.object({startingAngle:m.number().describe(`schema.sharedProps.startingAngle`),endingAngle:m.number().describe(`schema.sharedProps.endingAngle`),innerRadius:m.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),jn={ids:m.array(m.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:m.string().optional().describe(`schema.splitOps.matchName`),recursive:m.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:m.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},E=(e,t=1)=>m.array(m.string()).min(t).describe(e),Mn=m.object({ids:E(`要设为当前选中的节点 id 列表`)}).strict(),Nn=m.object({ids:m.array(m.string()).optional().describe(`schema.splitOps.ids2`),matchName:m.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),Pn=m.object({ids:E(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),Fn=m.object({ids:E(`要编组的节点 id 列表,至少 2 个`,2),name:m.string().optional().describe(`schema.splitOps.name`),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:m.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:m.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:m.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),In=m.object({ids:E(`要解组的节点 id 列表`)}).strict(),Ln=m.object({ids:E(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),Rn=m.object({ids:E(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),zn=m.object({ids:E(`要移动的节点 id 列表`),parentId:m.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:m.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),Bn=m.object({ids:m.array(m.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Vn=m.object({ids:m.array(m.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:m.string().optional().describe(`schema.splitOps.name2`),children:m.array(St).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:m.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:m.number().optional().describe(`组件高度(px);同上`)}).strict(),Hn=m.object({ids:E(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),Un=m.object({ids:E(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),Wn=m.object({key:m.string().describe(`schema.splitOps.key`),name:m.string().optional().describe(`schema.splitOps.name3`)}).strict(),Gn=m.object({ids:E(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:m.string().describe(`schema.splitOps.componentId`)}).strict(),Kn=m.object({ids:E(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:m.record(m.string(),Jt).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(),qn=m.object({ids:E(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:m.string().optional().describe(`schema.splitOps.name4`)}).strict(),Jn=m.object({sourceId:m.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),Yn={ids:E(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:m.string().describe(`schema.splitOps.sourceId`),swapToSource:m.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},Xn=m.object(Yn).strict(),Zn=m.object(Yn).strict(),Qn={fills:T.shape.fills,fillStyleId:T.shape.fillStyleId,blendMode:T.shape.blendMode},$n={...Dn.shape},er={cornerRadius:On.shape.cornerRadius,topLeftRadius:On.shape.topLeftRadius,topRightRadius:On.shape.topRightRadius,bottomLeftRadius:On.shape.bottomLeftRadius,bottomRightRadius:On.shape.bottomRightRadius,cornerSmoothing:T.shape.cornerSmoothing},tr={...kn.shape},nr={x:w.shape.x,y:w.shape.y,rotation:w.shape.rotation},rr={...Tn.shape,x:w.shape.x,y:w.shape.y},ir={...An.shape,constraints:T.shape.constraints},ar={effects:T.shape.effects,effectStyleId:T.shape.effectStyleId,clipsContent:T.shape.clipsContent,layoutGrids:T.shape.layoutGrids,arcData:T.shape.arcData},or={opacity:w.shape.opacity,visible:w.shape.visible,locked:w.shape.locked},sr={name:m.string().describe(`schema.splitOps.name5`)},cr={...En.shape};function D(e){return m.object({...jn,...e}).strict()}var lr=D(Qn),ur=D($n),dr=D(er),fr=D(tr),pr=D(nr),mr=D(rr),hr=D(ir),gr=D(ar),_r=D(or),vr=D(sr),yr=D(cr),br={set_fill:Object.keys(Qn),set_stroke:Object.keys($n),set_corner_radius:Object.keys(er),set_text:Object.keys(tr),move:Object.keys(nr),resize:Object.keys(rr),set_layout:Object.keys(ir),set_effects:Object.keys(ar),set_visibility:Object.keys(or),rename:Object.keys(sr),set_shape:Object.keys(cr)};function O(e){return m.object({...jn,props:m.object(e).strict()}).strict()}O(Qn),O($n),O(er),O(tr),O(nr),O(rr),O(ir),O(ar),O(or),O(sr),O(cr);function xr(e,t,n){let r=e.ctx.platform;return r==null?null:We(r,t,e.node.type)?Ue(r,t,n)?null:`value`:`type`}function Sr(e,t,n){let r=xr(e,t,n);if(r==null)return!0;let i=e.ctx.platform;if(i==null)return!0;let a=S[i];if(e.outcome.ignored.add(t),r===`type`)return e.outcome.warnings.push(`${t} 在 ${a} 的「${e.node.type}」上没有对应字段(该平台的这类节点不含这个属性的 mixin),本次已跳过:不是写失败,是这种节点上不存在该属性。要用它就换本平台支持该属性的节点类型;不去写的话结果里不会再回显它。`),!1;let o=Ge(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function Cr(e,t){return e[t]}function wr(e,t,n){e[t]=n}function Tr(e,t,n){return n==null||!(t in e)?!1:(wr(e,t,n),!0)}function Er(e,t,n,r){return r==null||!Oe(n,t.type)||!Sr(e,n,r)?!1:Tr(t,n,r)}var Dr={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&&Ar(t),r){if(i==null)return;Er(e,t,`layoutMode`,i);let r=n;Er(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])Er(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])Er(e,t,n,r[n]);jr(e);return}for(let r of Dr.keys)Er(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&&Oe(r,t.type)&&xr(e,r,i)==null&&(r in t&&t[r]!==i&&wr(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&&Oe(r,t.type)&&xr(e,r,a)==null&&(r in t&&Cr(t,r)!==a&&wr(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||Cr(t,r)===a}))}for(let r of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let i=n[r];i!=null&&(e.create&&n.layoutMode==null||Oe(r,t.type)&&xr(e,r,i)==null&&(r in t&&Cr(t,r)!==i&&wr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||Cr(t,r)===i})))}if(n.layoutMode==null||!Oe(`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 Or(e){try{let t=e.children;return Array.isArray(t)?t.map(e=>e.id):[]}catch{return[]}}var kr=new WeakMap;function Ar(e){let t=e;kr.set(e,{order:Or(e),width:typeof t.width==`number`?t.width:void 0,height:typeof t.height==`number`?t.height:void 0})}function jr(e){let{node:t,src:n}=e,r=n.layoutMode===`HORIZONTAL`,i=[[`primaryAxisSizingMode`,r?n.width!=null:n.height!=null],[`counterAxisSizingMode`,r?n.height!=null:n.width!=null]];for(let[e,r]of i)r&&n[e]==null&&e in t&&wr(t,e,`FIXED`)}Object.keys(Te).filter(e=>e!==`componentProperties`);var Mr=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=>Mr.has(e)));function Nr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Mr].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var Pr={"zh-CN":Vt,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.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)`,"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;批量改文案 → 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 清单(结果里 echoTrimmed=true)。占位符解析不受影响(内部仍用完整数据)。含图标的批次(jsd_create_icon / jsd_clone_node / jsd_create_vector)务必配一次 jsd_export 目视验收,别只看回显。\\n各工具返回键与占位符写法(键写错会报「无法解析占位符引用」并中止整批):\\n· created 为数组 → {{id.created[0].id}}:per-type create(jsd_create_rectangle / jsd_create_frame 等)、jsd_clone_node、jsd_outline_stroke、jsd_create_instance、jsd_detach_instance\\n· created 为单对象 → {{id.created.id}}:jsd_create_svg / jsd_create_icon / jsd_flatten_nodes / jsd_group_nodes / jsd_create_component / jsd_import_component / jsd_combine_as_variants / 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/对齐/自适应/大小写/装饰/行高/字距,以及 Figma 的截断与最大行数。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算)。{warn};characters 内容覆盖在实例内也是正常生效的`,"ping.description":`检查插件是否在线(需先在{client}(即时设计或 Figma)中运行该插件并保持运行)。返回三个能力表:coreCapabilities 为核心能力(create/modify/structure/component/export/image,两平台一致);capabilities 只列平台差异超集(如 variables/componentProperties/textTruncation),即时设计通常只有 styles,Figma 还会有 variables/componentProperties 等;platformOps 列当前平台可用的特有操作(名/标题/参数说明),调 jsd_platform_op 前先读它。回包会被 daemon 缓存,后续可直接读 jsd://platform/state(不必重复 ping)`},y=[`jsdesign`,`figma`,`mastergo`],b={jsdesign:qt[`platform.jsdesign`],figma:qt[`platform.figma`],mastergo:qt[`platform.mastergo`]},Jt=m.enum(y),Yt=m.enum(De),Xt=m.enum(ke),Zt=m.object({name:m.string().describe(`schema.platform.name`),title:m.string(),description:m.string().describe(`schema.platform.description`)}),Qt=m.object({type:m.literal(`VARIABLE_ALIAS`),id:m.string()}),$t=m.object({type:m.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`,`SLOT`]),value:m.union([m.boolean(),m.string()]),preferredValues:m.array(m.object({type:m.enum([`COMPONENT`,`COMPONENT_SET`]),key:m.string()})).optional(),boundVariables:m.object({value:Qt.optional()}).optional(),variableId:m.string().optional()}),en=m.object({type:m.enum([`BOOLEAN`,`TEXT`,`INSTANCE_SWAP`]),value:Qt}),tn=m.object({visible:m.string().optional(),characters:m.string().optional(),mainComponent:m.string().optional()}),nn=m.union([m.string(),m.boolean(),$t,en]),rn=m.record(m.string(),m.union([Qt,m.array(Qt),m.record(m.string(),Qt)])),an=Tt.slice(bt.length).join(`/`),on=m.object({ids:m.array(m.string()).optional().describe(`schema.inputs.ids`),name:m.string().optional().describe(`schema.inputs.name`),type:m.string().optional().describe(`节点类型过滤,支持:${bt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${an}),这些类型能读不能建`),scope:m.enum(Kt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)。⚠ 读不到非当前页的平台(即时设计/MasterGo)会自动退回当前页并在 note 点名 —— 结果只含当前页,不是全文档`),recursive:m.boolean().optional().describe(`schema.inputs.recursive`),depth:m.number().optional().describe(`schema.inputs.depth`)}),sn=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],cn=m.object({op:m.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return sn.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:m.array(m.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:m.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:m.string().optional().describe(`schema.inputs.name2`),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:m.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:m.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:m.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:m.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:m.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`})}),ln=m.object({op:m.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:m.array(m.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:m.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:m.string().optional().describe(`schema.inputs.key`),componentId:m.string().optional().describe(`schema.inputs.componentId`),properties:m.record(m.string(),nn).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:m.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:m.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`)}),un=m.object({ids:m.array(m.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:m.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:m.number().optional().describe(`schema.inputs.scale`),savePath:m.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:m.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),dn=m.object({family:m.string().optional().describe(`schema.inputs.family`),offset:m.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:m.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});m.object({});var fn=m.object({}),pn=m.object({ids:m.array(m.string()).describe(`schema.inputs.ids2`),sourcePath:m.string().describe(`schema.inputs.sourcePath`)}),mn=m.object({op:m.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:m.record(m.string(),m.unknown()).optional().describe(`schema.inputs.params`)}),x=m.lazy(()=>m.object({id:m.string(),name:m.string(),type:Dt,x:m.number(),y:m.number(),width:m.number().optional(),height:m.number().optional(),rotation:m.number().optional(),opacity:m.number().optional(),visible:m.boolean().optional(),locked:m.boolean().optional(),parentId:m.string().optional(),z:m.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:m.array(ct).optional(),strokes:m.array(ct).optional(),strokeWeight:m.number().optional(),strokeTopWeight:m.number().optional(),strokeBottomWeight:m.number().optional(),strokeLeftWeight:m.number().optional(),strokeRightWeight:m.number().optional(),strokeAlign:m.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:m.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:m.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:m.array(m.number()).optional(),cornerSmoothing:m.number().optional(),blendMode:st.optional(),constraints:m.object({horizontal:ut,vertical:ut}).optional(),layoutGrids:m.array(dt).optional(),clipsContent:m.boolean().optional(),arcData:m.object({startingAngle:m.number(),endingAngle:m.number(),innerRadius:m.number()}).optional(),effects:m.array(lt).optional(),cornerRadius:m.number().optional(),topLeftRadius:m.number().optional(),topRightRadius:m.number().optional(),bottomLeftRadius:m.number().optional(),bottomRightRadius:m.number().optional(),pointCount:m.number().optional(),innerRadius:m.number().optional(),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:m.number().optional(),paddingTop:m.number().optional(),paddingRight:m.number().optional(),paddingBottom:m.number().optional(),paddingLeft:m.number().optional(),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:m.number().optional(),layoutAlign:m.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:m.number().optional(),children:m.array(x).optional(),characters:m.string().optional(),fontSize:m.number().optional(),fontName:pt.optional(),textAlignHorizontal:m.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:m.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:m.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:m.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:m.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:mt.optional(),letterSpacing:ht.optional(),vectorPaths:m.array(ft).optional(),booleanOperation:m.enum(Ye).optional(),isMask:m.boolean().optional(),variantProperties:m.record(m.string(),m.string()).optional(),mainComponentId:m.string().optional(),variantGroupProperties:m.record(m.string(),m.array(m.string())).optional(),textTruncation:m.enum([`DISABLED`,`ENDING`]).optional(),maxLines:m.number().optional(),fillStyleId:m.string().optional(),strokeStyleId:m.string().optional(),textStyleId:m.string().optional(),effectStyleId:m.string().optional(),componentProperties:m.record(m.string(),$t).optional(),componentPropertyReferences:tn.optional(),boundVariables:rn.optional()})),hn=m.object({created:m.union([x,m.array(x)]),warnings:m.array(m.string()).optional()}),gn=m.object({updated:m.array(x),warnings:m.array(m.string()).optional()}),_n=m.object({connected:m.boolean(),platform:Jt.optional(),capabilities:m.array(Yt).optional().describe(`schema.results.capabilities`),coreCapabilities:m.array(Xt).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:m.array(Zt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:m.string().optional()}),vn=m.object({selection:m.array(x),pageName:m.string()}),yn=m.object({nodes:m.array(x),total:m.number(),scope:m.enum(Kt).optional(),note:m.string().optional()}),bn=m.object({selected:m.array(m.string()).optional(),removed:m.array(m.string()).optional(),ungrouped:m.array(m.string()).optional(),moved:m.array(x).optional(),updated:m.array(x).optional(),cleaned:m.array(m.string()).optional(),created:m.union([x,m.array(x)]).optional()}),xn=m.object({variantProperties:m.record(m.string(),m.string()).optional(),componentProperties:m.record(m.string(),$t).optional(),propsSummary:m.array(m.string()).optional()}),Sn=m.object({instanceId:m.string(),instanceName:m.string(),ok:m.boolean(),message:m.string().optional()}),Cn=m.object({created:m.union([x,m.array(x)]).optional(),swapped:m.array(x).optional(),updated:m.array(x).optional(),snapshotId:m.string().optional(),sourceName:m.string().optional(),captured:xn.optional(),applied:m.array(Sn).optional(),source:xn.optional(),failed:m.array(m.object({id:m.string(),message:m.string()})).optional(),warnings:m.array(m.string()).optional()}),wn=m.object({exports:m.array(m.object({id:m.string(),name:m.string(),format:m.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:m.string(),size:m.number(),path:m.string().optional(),dataUrl:m.string().optional()}))}),Tn=m.object({families:m.array(m.string()).describe(`schema.results.families`),fonts:m.array(m.object({family:m.string().describe(`schema.results.family`),styles:m.array(m.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:m.number().describe(`schema.results.count`),total:m.number().optional().describe(`schema.results.total`),offset:m.number().optional().describe(`schema.results.offset`),truncated:m.boolean().optional().describe(`schema.results.truncated`)}),En=m.object({id:m.string(),name:m.string()}),Dn=En.extend({properties:m.record(m.string(),m.array(m.string())).optional().describe(`维度 → 可选值,如 {"状态":["默认","禁用"]};平台读不到该字段时整个键省略`)}),On=En.extend({type:m.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])}),kn=m.object({summary:m.object({components:m.number(),variants:m.number(),styles:m.number(),variables:m.number()}),components:m.array(En),variants:m.array(Dn),styles:m.array(On),variables:m.array(En)}),An=m.object({pageName:m.string(),nodes:m.array(m.object({id:m.string(),name:m.string(),type:Dt,x:m.number(),y:m.number(),width:m.number().optional(),height:m.number().optional()})),count:m.number(),assets:kn.optional(),pages:m.array(m.object({name:m.string(),childCount:m.number()})).optional(),note:m.string().optional()});m.object({styles:m.array(m.object({id:m.string(),name:m.string(),type:m.enum(Me)})),count:m.number(),note:m.string().optional()});var jn=m.object({created:m.object({id:m.string(),name:m.string(),type:m.enum(Me)})}),Mn=m.object({removed:m.array(m.string()),failed:m.array(m.object({id:m.string(),reason:m.string().describe(`这一条没删掉的原因(通常是样式 id 不存在)`)}))}),S=m.object({x:m.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:m.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:m.number().optional().describe(`schema.sharedProps.width`),height:m.number().optional().describe(`schema.sharedProps.height`),rotation:m.number().optional().describe(`schema.sharedProps.rotation`),opacity:m.number().optional().describe(`schema.sharedProps.opacity`),visible:m.boolean().optional(),locked:m.boolean().optional()}),Nn=m.object({width:m.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:m.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),Pn=m.object({pointCount:m.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:m.number().optional().describe(`schema.sharedProps.innerRadius`)}),Fn=m.object({strokes:m.array(ct).optional().describe(`schema.sharedProps.strokes`),strokeWeight:m.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:m.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:m.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:m.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:m.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:m.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:m.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.sharedProps.strokeCap`),strokeJoin:m.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.sharedProps.strokeJoin`),dashPattern:m.array(m.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:m.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),In=m.object({cornerRadius:m.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:m.number().optional().describe(`schema.sharedProps.topLeftRadius`),topRightRadius:m.number().optional().describe(`schema.sharedProps.topRightRadius`),bottomLeftRadius:m.number().optional().describe(`schema.sharedProps.bottomLeftRadius`),bottomRightRadius:m.number().optional().describe(`schema.sharedProps.bottomRightRadius`)}),Ln=m.object({characters:m.string().optional().describe(`schema.sharedProps.characters`),fontSize:m.number().optional().describe(`schema.sharedProps.fontSize`),fontName:pt.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:m.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:m.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:m.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:m.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.sharedProps.textCase`),textDecoration:m.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.sharedProps.textDecoration`),lineHeight:mt.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:ht.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:m.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:m.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:m.number().optional().describe(`schema.sharedProps.maxLines`)}),Rn=m.object({layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:m.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:m.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:m.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:m.enum(Fe).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum(Ie).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:m.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:m.enum(Pe).optional().describe(`schema.sharedProps.layoutAlign`)}),C=m.object({fills:m.array(ct).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:m.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:st.optional(),effectStyleId:m.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:m.array(lt).optional().describe(`schema.sharedProps.effects`),constraints:m.object({horizontal:ut.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:ut.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:m.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:m.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:m.array(dt).optional().describe(`schema.sharedProps.layoutGrids`),arcData:m.object({startingAngle:m.number().describe(`schema.sharedProps.startingAngle`),endingAngle:m.number().describe(`schema.sharedProps.endingAngle`),innerRadius:m.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),zn={ids:m.array(m.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:m.string().optional().describe(`schema.splitOps.matchName`),recursive:m.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:m.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},w=(e,t=1)=>m.array(m.string()).min(t).describe(e),Bn=m.object({ids:w(`要设为当前选中的节点 id 列表`)}).strict(),Vn=m.object({ids:m.array(m.string()).optional().describe(`schema.splitOps.ids2`),matchName:m.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),Hn=m.object({ids:w(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),Un=m.object({ids:w(`要编组的节点 id 列表,至少 2 个`,2),name:m.string().optional().describe(`schema.splitOps.name`),layoutMode:m.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:m.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:m.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:m.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:m.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:m.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:m.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:m.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),Wn=m.object({ids:w(`要解组的节点 id 列表`)}).strict(),Gn=m.object({ids:w(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),Kn=m.object({ids:w(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),qn=m.object({ids:w(`要移动的节点 id 列表`),parentId:m.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:m.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),Jn=m.object({ids:m.array(m.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Yn=m.object({ids:m.array(m.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:m.string().optional().describe(`schema.splitOps.name2`),children:m.array(Ot).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:m.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:m.number().optional().describe(`组件高度(px);同上`)}).strict(),Xn=m.object({ids:w(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),Zn=m.object({ids:w(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),Qn=m.object({key:m.string().describe(`schema.splitOps.key`),name:m.string().optional().describe(`schema.splitOps.name3`)}).strict(),$n=m.object({ids:w(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:m.string().describe(`schema.splitOps.componentId`)}).strict(),er=m.object({ids:w(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:m.record(m.string(),nn).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(),tr=m.object({ids:w(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:m.string().optional().describe(`schema.splitOps.name4`)}).strict(),nr=m.object({kind:m.enum(Me).describe("样式类别。八项是三家 `StyleType` 的并集:**PAINT / TEXT / EFFECT / GRID 三家都有**;`STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING` **只 MasterGo 能建**—— 在 Figma / 即时设计传这四类会被写前点名拒(不静默、不 fallthrough 建成别的类)。MG 上和另四类一样是「从取值节点抄」,所以间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值时前置检查就会拦下"),name:m.string().min(1).describe("样式名,建议用「分组/名称」两层(如 `色板/主色`)"),description:m.string().optional().describe(`样式说明,建后可在 jsd://styles 里回读`),fromNodeId:m.string().describe(`**取值来源节点**(必填):三平台唯一都成立的形状 —— MG 的原生入口就是「从这个图层抄」,Figma / jsDesign 由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进新样式。PAINT 类 fills 优先,节点只有描边时退到 strokes`)}).strict(),rr=m.object({ids:m.array(m.string().min(1)).min(1).describe(`要删的本地样式 id 列表(取自 jsd://styles 或 jsd_get_page 的 assets.styles);按 id 不按名 —— 同名样式可以并存,按名删等于猜`)}).strict(),ir=m.object({sourceId:m.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),ar={ids:w(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:m.string().describe(`schema.splitOps.sourceId`),swapToSource:m.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},or=m.object(ar).strict(),sr=m.object(ar).strict(),cr={fills:C.shape.fills,fillStyleId:C.shape.fillStyleId,blendMode:C.shape.blendMode},lr={...Fn.shape},ur={cornerRadius:In.shape.cornerRadius,topLeftRadius:In.shape.topLeftRadius,topRightRadius:In.shape.topRightRadius,bottomLeftRadius:In.shape.bottomLeftRadius,bottomRightRadius:In.shape.bottomRightRadius,cornerSmoothing:C.shape.cornerSmoothing},dr={...Ln.shape},fr={x:S.shape.x,y:S.shape.y,rotation:S.shape.rotation},pr={...Nn.shape,x:S.shape.x,y:S.shape.y},mr={...Rn.shape,constraints:C.shape.constraints},hr={effects:C.shape.effects,effectStyleId:C.shape.effectStyleId,clipsContent:C.shape.clipsContent,layoutGrids:C.shape.layoutGrids,arcData:C.shape.arcData},gr={opacity:S.shape.opacity,visible:S.shape.visible,locked:S.shape.locked},_r={name:m.string().describe(`schema.splitOps.name5`)},vr={...Pn.shape};function T(e){return m.object({...zn,...e}).strict()}var yr=T(cr),br=T(lr),xr=T(ur),Sr=T(dr),Cr=T(fr),wr=T(pr),Tr=T(mr),Er=T(hr),Dr=T(gr),Or=T(_r),kr=T(vr),Ar={set_fill:Object.keys(cr),set_stroke:Object.keys(lr),set_corner_radius:Object.keys(ur),set_text:Object.keys(dr),move:Object.keys(fr),resize:Object.keys(pr),set_layout:Object.keys(mr),set_effects:Object.keys(hr),set_visibility:Object.keys(gr),rename:Object.keys(_r),set_shape:Object.keys(vr)};function E(e){return m.object({...zn,props:m.object(e).strict()}).strict()}E(cr),E(lr),E(ur),E(dr),E(fr),E(pr),E(mr),E(hr),E(gr),E(_r),E(vr);function jr(e,t,n){let r=e.ctx.platform;return r==null?null:We(r,t,e.node.type)?Ue(r,t,n)?null:`value`:`type`}function Mr(e,t,n){let r=jr(e,t,n);if(r==null)return!0;let i=e.ctx.platform;if(i==null)return!0;let a=b[i];if(e.outcome.ignored.add(t),r===`type`)return e.outcome.warnings.push(`${t} 在 ${a} 的「${e.node.type}」上没有对应字段(该平台的这类节点不含这个属性的 mixin),本次已跳过:不是写失败,是这种节点上不存在该属性。要用它就换本平台支持该属性的节点类型;不去写的话结果里不会再回显它。`),!1;let o=Ge(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function Nr(e,t){return e[t]}function Pr(e,t,n){e[t]=n}function Fr(e,t,n){return n==null||!(t in e)?!1:(Pr(e,t,n),!0)}function Ir(e,t,n,r){return Lr(e,t,n,r)?Fr(t,n,r):!1}function Lr(e,t,n,r){return!(r==null||!je(n,t.type)||!Mr(e,n,r))}var Rr={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&&Vr(t),r){if(i==null)return;Ir(e,t,`layoutMode`,i);let r=n;Ir(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])Ir(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])Ir(e,t,n,r[n]);Hr(e);return}for(let r of Rr.keys)Ir(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&&je(r,t.type)&&jr(e,r,i)==null&&(r in t&&t[r]!==i&&Pr(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&&je(r,t.type)&&jr(e,r,a)==null&&(r in t&&Nr(t,r)!==a&&Pr(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||Nr(t,r)===a}))}for(let r of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let i=n[r];i!=null&&(e.create&&n.layoutMode==null||je(r,t.type)&&jr(e,r,i)==null&&(r in t&&Nr(t,r)!==i&&Pr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||Nr(t,r)===i})))}if(n.layoutMode==null||!je(`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 zr(e){try{let t=e.children;return Array.isArray(t)?t.map(e=>e.id):[]}catch{return[]}}var Br=new WeakMap;function Vr(e){let t=e;Br.set(e,{order:zr(e),width:typeof t.width==`number`?t.width:void 0,height:typeof t.height==`number`?t.height:void 0})}function Hr(e){let{node:t,src:n}=e,r=n.layoutMode===`HORIZONTAL`,i=[[`primaryAxisSizingMode`,r?n.width!=null:n.height!=null],[`counterAxisSizingMode`,r?n.height!=null:n.width!=null]];for(let[e,r]of i)r&&n[e]==null&&e in t&&Pr(t,e,`FIXED`)}Object.keys(Oe).filter(e=>e!==`componentProperties`);var Ur=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=>Ur.has(e)));function Wr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Ur].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var Gr={"zh-CN":qt,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.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)`,"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).
|
|
23
23
|
|
|
24
24
|
2. Then call jsd_ping — that wakes the background daemon (starting it if needed).
|
|
25
|
-
If it reports "plugin not connected", tell me to run the text-to-design plugin inside my design app.`,"panel.expand":`Expand`,"panel.collapse":`Collapse`,"panel.close":`Close`,"selection.title":`Selected nodes`,"selection.badge":`{count} nodes · {size} serialized`,"selection.copy":`Copy`,"selection.empty.title":`No nodes selected`,"selection.empty.hint":`Select nodes on the canvas and they show up here, ready to copy`,"capability.card.title":`Capabilities`,"capability.card.missing":`Capabilities unavailable (plugin not connected)`,"capability.card.badgeTitle":`Core capability count · platform-specific capabilities available · platform op count`,"capability.card.badge":`core {core} · platform {host}/{total} · op {ops}`,"capability.card.coreSection":`Core capabilities`,"capability.card.hostSection":`Platform differences`,"capability.card.opTitle":`{op}: supported on the current platform`,"capability.card.opTitleOff":`{op}: not supported on the current platform`,"capability.card.opsSection":`Platform-specific ops`,"capability.card.refresh":`Refresh`,"capability.card.noOps":`No platform-specific ops on this platform`,"log.trigger":`Log`,"log.trigger.title":`Log: MCP calls and connection events`,"log.trigger.unread":`Log, {count} new errors`,"log.trigger.unit":`errors`,"log.trigger.announce":`{count} new errors`,"log.drawer.title":`Log`,"log.drawer.count":`{shown} / {total}`,"log.drawer.clear":`Clear`,"log.drawer.close":`Close log`,"log.drawer.filter.all":`All`,"log.drawer.filter.info":`Info+`,"log.drawer.filter.warn":`Warn+`,"log.drawer.filter.error":`Error`,"log.drawer.empty":`No log yet. MCP calls and connection events are recorded here.`,"log.drawer.emptyFiltered":`Nothing at level "{filter}" — switch to "All" for the full record.`,"log.drawer.copy":`Copy`,"log.drawer.newCount":`↓ {count} new entries`,"bridge.log.superseded":`Another plugin panel took over the channel; auto-reconnect stopped (click "Reclaim" in the panel header to switch back)`,"bridge.log.confirmed":`Service confirmed the connection (version {version})`,"bridge.log.versionPush":`Latest npm versions received: plugin {ui}, service {mcp}`,"bridge.log.versionUnknown":`unknown`,"bridge.log.handshakeTimeout":`WS handshake timed out ({ms}ms), giving up on this connection: {port}`,"bridge.log.serverConnected":`MCP server connected, waiting for service confirmation: ws://localhost:{port}`,"bridge.log.confirmTimeout":`Service confirmation timed out, closing: {port}`,"bridge.log.closed":`Connection closed: {port}`,"bridge.log.stale":`Service confirmation expired (no heartbeat for {ms}ms), closing: {port}`,"bridge.log.wsFailed":`Failed to handle WS message: {message}`,"bridge.log.recvRequest":`Server request received: {method}`,"bridge.log.recvResponse":`Server response received (ignored): {id}`,"bridge.log.forwardTimeout":`Forwarding to plugin timed out: {method}`,"bridge.log.pluginTimeout":`Plugin response timed out`,"bridge.log.ignoreUnknown":`Ignoring unknown plugin message: {type}`,"bridge.log.codeFailed":`Failed to handle code message: {message}`,"bridge.log.sendFailed":`Failed to send response (server not connected): {id}`,"bridge.log.manualClose":`Disconnected manually`,"bridge.log.capabilityMissing":`Capability reply malformed (missing platform)`,"bridge.log.capabilityFailed":`Failed to fetch capabilities: {message}`,"bridge.log.pingOk":`Plugin ping succeeded: {data}`,"bridge.log.pingFailed":`Plugin ping failed: {message}`,"bridge.error.useBridge":`useBridge must be used inside <BridgeProvider>`,"schema.base.r":`Red channel, 0-1 (0=none, 1=full), e.g. 1 for pure red; values >1 are treated as 0-255 and auto-normalized`,"schema.base.g":`Green channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.b":`Blue channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1; >1 treated as 0-255 and auto-normalized`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`Transform matrix [[a,b,tx],[c,d,ty]]`,"schema.base.type":`Fill type: solid`,"schema.base.opacity":`Opacity 0-1, default 1`,"schema.base.visible":`Whether visible, default true`,"schema.base.blendMode":`Blend mode, default NORMAL`,"schema.base.blendMode2":`Solid fill (SOLID): {color:{r,g,b}}`,"schema.base.type2":`Fill type: linear gradient`,"schema.base.gradientStops":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform":`Linear gradient (GRADIENT_LINEAR): transitions along a straight line`,"schema.base.type3":`Fill type: radial gradient`,"schema.base.gradientStops2":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform2":`Radial gradient (GRADIENT_RADIAL): radiating outwards from the centre`,"schema.base.type4":`Fill type: angular gradient`,"schema.base.gradientStops3":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform3":`Angular gradient (GRADIENT_ANGULAR): transitions around the circumference`,"schema.base.type5":`Fill type: image fill`,"schema.base.imageHash":`Image asset hash (injected by jsd_fill_image etc.)`,"schema.base.scaleMode":`Image scale mode: FIT | FILL | CROP | TILE`,"schema.base.scaleMode2":`Image fill (IMAGE): references the image by imageHash`,"schema.base.type6":`Effect type: drop shadow (cast outside the node)`,"schema.base.color2":`Shadow color (with alpha)`,"schema.base.x":`Horizontal offset (px), positive = right`,"schema.base.y":`Vertical offset (px), positive = down`,"schema.base.y2":`Shadow offset vector (px)`,"schema.base.radius":`Blur radius (px), >=0`,"schema.base.spread":`Spread (px), positive expands and negative shrinks the shadow, default 0`,"schema.base.visible2":`Whether visible, default true`,"schema.base.blendMode3":`Blend mode, default NORMAL`,"schema.base.showShadowBehindNode":`Whether the shadow is drawn behind the node (otherwise under its content), default true`,"schema.base.showShadowBehindNode2":`Drop shadow (DROP_SHADOW): a shadow cast outside the node`,"schema.base.type7":`Effect type: inner shadow (cast inside the node)`,"schema.base.color3":`Shadow color (with alpha)`,"schema.base.x2":`Horizontal offset (px), positive = right`,"schema.base.y3":`Vertical offset (px), positive = down`,"schema.base.y4":`Shadow offset vector (px)`,"schema.base.radius2":`Blur radius (px), >=0`,"schema.base.spread2":`Spread (px), positive expands and negative shrinks, default 0`,"schema.base.visible3":`Whether visible, default true`,"schema.base.blendMode4":`Blend mode, default NORMAL`,"schema.base.blendMode5":`Inner shadow (INNER_SHADOW): a shadow cast inside the node`,"schema.base.type8":`Effect type: layer blur (blurs the whole node itself)`,"schema.base.radius3":`Blur radius (px), >=0`,"schema.base.visible4":`Whether visible, default true`,"schema.base.visible5":`Layer blur (LAYER_BLUR): blurs the node itself`,"schema.base.type9":`Effect type: background blur (blurs what is behind the node)`,"schema.base.radius4":`Blur radius (px), >=0`,"schema.base.visible6":`Whether visible, default true`,"schema.base.visible7":`Background blur (BACKGROUND_BLUR): blurs the content behind the node`,"schema.base.pattern":`Grid type: ROWS | COLUMNS | GRID`,"schema.base.alignment":`Alignment: MIN | MAX | CENTER | STRETCH`,"schema.base.sectionSize":`Section size (px)`,"schema.base.gutterSize":`Gutter size (px)`,"schema.base.offset":`Offset (px)`,"schema.base.windingRule":`Winding rule: NONZERO | EVENODD | NONE, default NONZERO`,"schema.base.value":`Line height value (px)`,"schema.base.unit":`Unit: PIXELS = fixed pixels`,"schema.base.value2":`Line height value (percentage)`,"schema.base.unit2":`Unit: PERCENT = percentage`,"schema.base.unit3":`Unit: AUTO = automatic line height`,"schema.base.unit4":`Automatic line height: {unit: "AUTO"}, no value needed`,"schema.base.unit5":`Unit: PIXELS = pixels | PERCENT = percentage`,"schema.batch.calls":`Step list, executed in array order`,"schema.batch.ok":`True when every step ran and succeeded (executed < total means it stopped halfway)`,"schema.batch.executed":`Number of steps that actually produced a result`,"schema.batch.total":`Total number of planned steps`,"schema.batch.error":`Failure reason (human-readable text)`,"schema.batch.error2":`Id of the step that failed`,"schema.executeOp.depth":`Serialization depth`,"schema.executeSchemas.type":`Child node type`,"schema.executeSchemas.x":`X relative to the parent (px)`,"schema.executeSchemas.y":`Y relative to the parent (px)`,"schema.executeSchemas.x2":`X relative to the parent (px)`,"schema.executeSchemas.y2":`Y relative to the parent (px)`,"schema.executeSchemas.width":`Width (px)`,"schema.executeSchemas.height":`Height (px)`,"schema.executeSchemas.rotation":`Rotation angle (deg)`,"schema.executeSchemas.opacity":`Opacity 0-1`,"schema.executeSchemas.strokes":`Stroke list (Paint array)`,"schema.executeSchemas.strokeWeight":`Stroke weight (px)`,"schema.executeSchemas.strokeTopWeight":`Top stroke weight (px)`,"schema.executeSchemas.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.executeSchemas.strokeLeftWeight":`Left stroke weight (px)`,"schema.executeSchemas.strokeRightWeight":`Right stroke weight (px)`,"schema.executeSchemas.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.executeSchemas.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.executeSchemas.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.executeSchemas.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow/blur, stackable)`,"schema.executeSchemas.vertical":`Constraint inside auto-layout`,"schema.executeSchemas.clipsContent":`Whether overflowing content is clipped`,"schema.executeSchemas.cornerSmoothing":`Corner smoothing 0-1`,"schema.executeSchemas.layoutGrids":`Layout grids (guides)`,"schema.executeSchemas.cornerRadius":`Corner radius (px), same on all four corners`,"schema.executeSchemas.topLeftRadius":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.executeSchemas.paddingTop":`Top padding (px)`,"schema.executeSchemas.paddingRight":`Right padding (px)`,"schema.executeSchemas.paddingBottom":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.layoutGrow":`Grow factor inside auto-layout`,"schema.executeSchemas.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.cornerRadius2":`Corner radius (px)`,"schema.executeSchemas.startingAngle":`Starting angle (radians)`,"schema.executeSchemas.endingAngle":`Ending angle (radians)`,"schema.executeSchemas.innerRadius":`Inner radius (0-1 ratio)`,"schema.executeSchemas.innerRadius2":`Arc path parameters, draws a ring`,"schema.executeSchemas.innerRadius3":`ELLIPSE = ellipse (use arcData to draw a ring)`,"schema.executeSchemas.type3":`LINE = line`,"schema.executeSchemas.pointCount":`Polygon corner count, e.g. 6 = hexagon`,"schema.executeSchemas.cornerRadius3":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius2":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius2":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius2":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius2":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON = polygon (use pointCount)`,"schema.executeSchemas.pointCount2":`Star point count, e.g. 5 = five-pointed star`,"schema.executeSchemas.innerRadius4":`Inner radius (0-1 ratio)`,"schema.executeSchemas.cornerRadius4":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius3":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius3":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius3":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius4":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius5":`STAR = star (with pointCount / innerRadius)`,"schema.executeSchemas.vectorPaths":`Vector path data`,"schema.executeSchemas.fontSize":`Font size (px), default 16`,"schema.executeSchemas.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.executeSchemas.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.executeSchemas.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`Line height: {value, unit}`,"schema.executeSchemas.letterSpacing":`Letter spacing: {value, unit}`,"schema.executeSchemas.letterSpacing2":`Letter spacing: {value, unit}, unit is PIXELS | PERCENT`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.paddingTop2":`Top padding (px)`,"schema.executeSchemas.paddingRight2":`Right padding (px)`,"schema.executeSchemas.paddingBottom2":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft2":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode2":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.path":`GROUP = group (implemented as a frame internally)`,"schema.executeSchemas.children2":`Child nodes to merge (at least 2)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION = boolean operation (merges child nodes)`,"schema.execute.name":`Name of the generated layer, default svg-design`,"schema.execute.html":`HTML fragment, inline styles supported`,"schema.execute.name2":`Name of the generated layer, default html-design`,"schema.execute.size":`Icon edge length in px, default 24`,"schema.execute.color":`Stroke color (hex), default #000000`,"schema.execute.strokeWidth":`Stroke width, default 2`,"schema.execute.name3":`Name of the generated layer, default icon-<icon name>`,"schema.inputs.ids":`Find by node id, highest priority`,"schema.inputs.name":`Fuzzy match by name (contains)`,"schema.inputs.recursive":`Whether to search recursively (default true)`,"schema.inputs.depth":`Serialization depth: 0 = self only, 1 = with direct children; default 1`,"schema.inputs.name2":`Group only: group name`,"schema.inputs.paddingTop":`Group only. Top padding (px)`,"schema.inputs.paddingRight":`Group only. Right padding (px)`,"schema.inputs.paddingBottom":`Group only. Bottom padding (px)`,"schema.inputs.paddingLeft":`Group only. Left padding (px)`,"schema.inputs.primaryAxisSizingMode":`Group only. Main axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisSizingMode":`Group only. Cross axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisAlignItems":`Group only. Cross axis alignment: MIN | MAX | CENTER`,"schema.inputs.key":`Team library component key (required only for import_component)`,"schema.inputs.componentId":`Target component (COMPONENT) node id`,"schema.inputs.format":`Export format, default PNG`,"schema.inputs.scale":`Scale factor (PNG/JPG), default 1`,"schema.inputs.savePath":`Absolute path to write, e.g. /tmp/icon.png`,"schema.inputs.includeDataUrl":`Whether to also return the base64 dataURL, default false`,"schema.inputs.ids2":`Node ids to fill with the image`,"schema.inputs.sourcePath":`Absolute path of the local image, e.g. /tmp/poster.png`,"schema.inputs.params":`Operation parameters; the shape depends on the op`,"schema.inputs.family":`Filter by family name (case-insensitive substring), e.g. "Source"`,"schema.inputs.offset":`Paging start index (families to skip), default 0`,"schema.inputs.limit":`Max families per page, default 50, max 500; a font library can hold ~1900 families and dumping all of them blows up the context`,"schema.platform.name":`op name, pass it verbatim when calling jsd_platform_op`,"schema.platform.description":`Includes the params shape`,"schema.results.capabilities":`Platform-difference capabilities`,"schema.results.families":`Available font families`,"schema.results.family":`Font family`,"schema.results.styles":`Styles available in this family, e.g. ["Regular","Medium","Bold"]`,"schema.results.count":`Number of font families in this page`,"schema.results.total":`Total families after filtering (independent of paging)`,"schema.results.offset":`Start index of this page`,"schema.results.truncated":`true means more pages exist; continue with offset`,"schema.sharedProps.width":`Width (px)`,"schema.sharedProps.height":`Height (px)`,"schema.sharedProps.rotation":`Rotation angle (deg, around the node top-left origin; x/y unchanged)`,"schema.sharedProps.opacity":`Opacity 0-1`,"schema.sharedProps.pointCount":`Polygon/star corner count (POLYGON / STAR only)`,"schema.sharedProps.innerRadius":`Inner radius (0-1 ratio)`,"schema.sharedProps.strokes":`Stroke list (Paint array)`,"schema.sharedProps.strokeWeight":`Stroke weight (px)`,"schema.sharedProps.strokeTopWeight":`Top stroke weight (px)`,"schema.sharedProps.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.sharedProps.strokeLeftWeight":`Left stroke weight (px)`,"schema.sharedProps.strokeRightWeight":`Right stroke weight (px)`,"schema.sharedProps.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.sharedProps.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.sharedProps.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.topLeftRadius":`Top-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.sharedProps.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.sharedProps.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.sharedProps.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.sharedProps.lineHeight":`Line height: {value, unit}`,"schema.sharedProps.letterSpacing":`Letter spacing: {value, unit}`,"schema.sharedProps.textStyleId":`Local text style id`,"schema.sharedProps.textTruncation":`Text truncation: DISABLED | ENDING (Figma only)`,"schema.sharedProps.maxLines":`Maximum number of lines, Figma only`,"schema.sharedProps.paddingTop":`Top padding (px)`,"schema.sharedProps.paddingRight":`Right padding (px)`,"schema.sharedProps.paddingBottom":`Bottom padding (px)`,"schema.sharedProps.paddingLeft":`Left padding (px)`,"schema.sharedProps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.sharedProps.layoutGrow":`Grow factor inside auto-layout`,"schema.sharedProps.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.sharedProps.fillStyleId":`Local fill style id`,"schema.sharedProps.effectStyleId":`Local effect style id`,"schema.sharedProps.effects":`Effect list (shadow/blur, stackable)`,"schema.sharedProps.vertical":`Constraint inside auto-layout`,"schema.sharedProps.clipsContent":`Whether overflowing content is clipped`,"schema.sharedProps.cornerSmoothing":`Corner smoothing 0-1`,"schema.sharedProps.layoutGrids":`Layout grids (guides)`,"schema.sharedProps.startingAngle":`Starting angle (radians)`,"schema.sharedProps.endingAngle":`Ending angle (radians)`,"schema.sharedProps.innerRadius2":`Inner radius (0-1 ratio)`,"schema.sharedProps.innerRadius3":`Arc path parameters, ELLIPSE nodes only`,"schema.splitOps.ids":`Target node id list; defaults to the current selection`,"schema.splitOps.matchName":`Filter precisely by name`,"schema.splitOps.ids2":`Node ids to delete; defaults to the current selection`,"schema.splitOps.matchName2":`Delete only nodes whose name matches exactly`,"schema.splitOps.name":`Group name`,"schema.splitOps.paddingTop":`Top padding (px)`,"schema.splitOps.paddingRight":`Right padding (px)`,"schema.splitOps.paddingBottom":`Bottom padding (px)`,"schema.splitOps.paddingLeft":`Left padding (px)`,"schema.splitOps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.splitOps.ids3":`Ids of broken nodes to clean up; defaults to all broken nodes on the current page`,"schema.splitOps.name2":`Component name`,"schema.splitOps.key":`Team library component key`,"schema.splitOps.name3":`Name of the imported node`,"schema.splitOps.componentId":`Target component (COMPONENT) node id`,"schema.splitOps.name4":`Variant set name`,"schema.splitOps.sourceId":`Source instance id, i.e. the snapshotId returned by an earlier copy_overrides`,"schema.splitOps.name5":`New node name`,"batch.title":`Batch orchestration`,"batch.followUp":`Review the canvas result after the orchestrated run`,"createComponent.title":`Create component`,"createComponent.description":`Create a COMPONENT and return the new id. Pass children to build it with content in one call (same fields as jsd_create_frame children), optionally with width/height; without children you get an empty shell to fill via jsd_reparent_nodes. The source nodes are never converted or modified — a component is always created fresh. Name variants as "prop=value, prop=value"; set variant properties with jsd_set_instance_properties`,"createComponent.description2":`Resize the component / add fill, corner radius, shadow`,"createInstance.title":`Create component instance`,"createInstance.description":`Set the variant properties of the instance`,"detachInstance.title":`Detach instance`,"detachInstance.description":`Edit the detached node freely`,"importComponent.title":`Import component from team library`,"importComponent.description":`Create an instance of the imported component`,"swapComponent.title":`Swap component`,"swapComponent.description":`Set variant properties after the swap`,"setInstanceProperties.title":`Set variant properties`,"setInstanceProperties.description":`Sync overrides across other instances`,"combineAsVariants.title":`Combine as variant set`,"copyOverrides.title":`Copy instance overrides snapshot`,"copyOverrides.description":`Apply the snapshot to target instances`,"applyOverrides.title":`Apply instance overrides snapshot`,"applyOverrides.description":`Keep syncing other instances`,"syncOverrides.title":`Sync instance overrides`,"syncOverrides.description":`Review the synced instances`,"createFrame.title":`Create frame container`,"createFrame.description":`Create a single FRAME node; input holds only FRAME fields: width/height size, layoutMode auto-layout (itemSpacing/padding*/main and cross axis sizing and alignment) plus visual fields such as fills and strokes. Only one root FRAME is created; use children only for small structures (a container plus its direct children, child x/y relative to the parent) — never pass a whole screen tree in one children call. Build layer by layer with jsd_batch, then reparent each layer into its parent with jsd_reparent_nodes. Set layoutMode=HORIZONTAL or VERTICAL before auto-layout fields (otherwise they are ignored). Without explicit fills the engine defaults to a white background; pass fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}] for a transparent container. Always pass a semantic name (e.g. "Sidebar", "KPI-OEE"); unnamed nodes fall back to the engine default name node. Use jsd_batch to create multiple roots or complex trees`,"createRectangle.title":`Create rectangle`,"createRectangle.description":`Create a single RECTANGLE node; input holds only rectangle fields: width/height, cornerRadius per corner and visual fields such as fills and strokes. Only one root rectangle; use children only for small structures (child x/y relative to the parent). Always pass a semantic name (e.g. "Card base", "Chart gridlines"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createText.title":`Create text`,"createText.description":`Create a single TEXT node; input holds only text fields: characters (required), fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing and fills/strokes. Only one root text node. Resolve fonts with jsd_list_fonts first: use fonts[].family verbatim and the full name from the same entry's styles (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings will name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content). Always pass a semantic name (e.g. "Chart title", "KPI value"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createEllipse.title":`Create ellipse`,"createEllipse.description":`Create a single ELLIPSE node: width/height, arcData ring parameters (draws a ring) and visual fields such as fills and strokes. Only one root ellipse. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createLine.title":`Create line`,"createLine.description":`Create a single LINE node: width/height and stroke fields. For short straight segments LINE + rotation is more stable. One axis may be 0: the engine resize check demands >= 0.01 so the plugin lifts the zero axis to 0.01 (visually a straight line, serialization still reads 0); jsd_resize_node accepts a zero axis too. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createPolygon.title":`Create polygon`,"createPolygon.description":`Create a single POLYGON node: pointCount is required (e.g. 6 = hexagon), plus cornerRadius and visual fields. Only one root polygon. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createStar.title":`Create star`,"createStar.description":`Create a single STAR node: pointCount corner count, innerRadius ratio and visual fields such as fills and strokes. Only one root star. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createVector.title":`Create vector`,"createVector.description":`Create a single VECTOR node: vectorPaths/vectorNetwork geometry with fills and strokes. Prefer jsd_create_icon or SVG import for icon-like shapes. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createGroup.title":`Create group`,"createGroup.description":`Create a single GROUP node wrapping the given children: group first, then lay out. Only one root group. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createBooleanOperation.title":`Create boolean operation node`,"createSvg.title":`Import SVG`,"createSvg.description":"Import an SVG into the canvas as editable layers (native createNodeFromSvg parsing; paths/gradients/strokes preserved). Pick one source: svg (inline string) or svgPath (path to a local .svg file, read by the background service). **Charts and data visualisations must use svgPath** (line, bar, pie/donut, scatter, radar, area, gauge, dashboard, Sankey, …): there is no built-in chart tool — write a script that computes the SVG, write it to a local file, then pass the path. Engine hard constraints (violations fail silently): the root element needs xmlns plus explicit width/height/viewBox; colours as hex only; no external images/fonts/scripts; approximate curves with C/Q, never the A command; canvas ≤2000×2000; split semantic layers into `<g id>` (one wrapper group is no grouping), with a single transform on the outer group only. Before you start, ReadMcpResource the recipe jsd://recipes/chart-by-code — it carries the zero-dependency example, the colour and type-scale conventions, and the post-import layer check plus visual acceptance checklist. Use jsd_batch to orchestrate multiple root nodes or complex trees","createIcon.title":`Insert built-in icon`,"htmlToDesign.title":`HTML to design nodes`,"htmlToDesign.description":`Convert an HTML fragment into canvas nodes. Default path is jsd_html_to_design (SVG fidelity, complex styles dropped); only use per-type create tools (jsd_create_frame etc.) when editable layers are required`,"manageNodes.title":`Node structure operations (aggregate)`,"manageNodes.followUp":`Set the container auto-layout after the structure change`,"manageComponents.title":`Component and instance operations (aggregate)`,"manageComponents.description":`Aggregate entrypoint dispatching by op: create_component / create_instance / detach_instance / import_component / combine_as_variants / swap_component / set_instance_properties / copy_overrides / apply_overrides / sync_overrides. Prefer the dedicated small tools for a single op`,"manageComponents.description2":`Set variant properties after the component/instance change`,"find.title":`Find nodes`,"find.description":`Set the matched nodes as the current selection for later edits/deletes`,"selectNodes.title":`Set canvas selection`,"selectNodes.description":`Move or resize the selected nodes`,"deleteNode.title":`Delete node`,"deleteNode.description":`Review the remaining nodes after deletion`,"cloneNode.title":`Clone node`,"cloneNode.description":`Move the copy to the target position`,"groupNodes.title":`Group nodes`,"groupNodes.description":`Set the auto-layout of the new group`,"ungroupNodes.title":`Ungroup nodes`,"ungroupNodes.description":`Adjust child positions after ungrouping`,"flattenNodes.title":`Flatten into vector`,"flattenNodes.description":`Set the fill of the flattened shape`,"outlineStroke.title":`Outline stroke`,"outlineStroke.description":`Adjust the stroke of the new outline`,"reparentNodes.title":`Move nodes under a parent`,"reparentNodes.description":`Fine-tune x/y under the new parent if needed (absolute position is preserved automatically)`,"repairNodes.title":`Repair broken nodes`,"repairNodes.description":`Review the page node state after repairing`,"platformOp.title":`Platform-specific operation`,"platformOp.description":`Run a platform-specific op (Figma: variables / local styles / component properties; MasterGo: variable read-write / component properties / set-level variant management). CRITICAL: never guess op names or parameters — read the platformOps list (each entry carries its parameter shape) and capabilities from jsd_ping first, then call by the listed names; an unsupported platform or a wrong op name returns an error listing the ops the current platform supports`,"platformOp.description2":`Review the effect of the platform op on the canvas`,"prompt.htmlToDesign.title":`HTML to design`,"prompt.htmlToDesign.description":`Convert an HTML fragment into canvas nodes, with fidelity trade-offs`,"prompt.iconGrid.title":`Icon grid`,"prompt.iconGrid.description":`Insert Lucide icons in bulk and lay them out in an auto-layout grid`,"prompt.scriptOps.title":`Scripted batch calls`,"prompt.chartByCode.title":`Charts / data visualization by code`,"prompt.chartByCode.description":`The primary path for charts and data visualization — line, bar, pie / donut, scatter, radar, area, gauge, dashboard or any other chart: write your own code to compute the geometry, save the SVG to a file, then import it via jsd_create_svg (dependency-free example plus engine-side hard constraints)`,"prompt.designStrategy.title":`Design strategy overview`,"prompt.textReplace.title":`Bulk text replacement strategy`,"prompt.variantSync.title":`Bulk sync styles across sibling instances`,"prompt.variableBinding.title":`Bind variables and apply in bulk`,"prompt.variantSet.title":`Build a variant set`,"prompt.componentProperty.title":`Define and set component properties`,"setFillColor.title":`Set fill`,"setFillColor.followUp":`Next set the stroke`,"setStroke.title":`Set stroke`,"setStroke.description":`Next set the fill`,"setCornerRadius.title":`Set corner radius`,"setCornerRadius.description":`Next set shadow/blur effects`,"setText.title":`Modify text`,"setText.followUp":`Give the text a semantic name`,"moveNode.title":`Move node`,"moveNode.description":`Next adjust the size`,"resizeNode.title":`Resize node`,"resizeNode.description":`Next set visibility/lock`,"setLayout.title":`Set auto-layout`,"setLayout.description":`Move child nodes into the container to finish the layout`,"setEffects.title":`Set effects and advanced properties`,"setEffects.description":`Next set visibility/lock`,"setVisibility.title":`Set visibility and lock`,"setVisibility.description":`Review the canvas selection after the change`,"renameNode.title":`Rename node`,"renameNode.description":`Next edit the text content/typography`,"setShape.title":`Set polygon/star shape`,"setShape.description":`Next set the fill`,"export.title":`Export nodes as images`,"export.description":`Export the given nodes to PNG files. Large base64 payloads are dropped from the result and written to disk instead; use jsd_export again with a smaller scale if you need inline data`,"export.description2":`Fill the exported image into a node`,"fillImage.title":`Fill node with a local image`,"fillImage.description":`Read a local image file and fill the given nodes with it (IMAGE fill)`,"fillImage.description2":`Review the image fill result`,"listFonts.title":`List available fonts`,"listFonts.description":`Set text with the listed fonts`,"resources.title":`Current canvas selection`,"resources.title2":`Available font list`,"resources.title3":`Local style list`,"resources.title4":`Current page overview: top-level nodes + reusable asset roster`,"resources.title5":`Node detail`,"resources.title6":`Platform state and capabilities`,"resources.title7":`Recipe index`,"resources.title8":`Recipe body`,"ping.followUp":`Read the current selection once the connection is confirmed; for creation tasks read the design-strategy prompt first`,"getSelection.title":`Read canvas selection`,"getSelection.description":`Read the current selection of the canvas, serialized with direct children; equivalent to jsd_get_selection depth=2`,"getSelection.description2":`Find nodes precisely inside the selection`,"getPage.title":`Current page overview: top-level nodes + reusable asset roster`,"getPage.description":"Two read-only sections for the **current page**. (1) nodes: geometry of the current page **first-level** nodes (id/name/type/width/height/x/y, not recursive); (2) assets: the reusable roster — summary gives counts for all four faces; components; variants (with dimension -> allowed values); styles (PAINT/TEXT/EFFECT/GRID, each with its type); variables. Every entry carries id and name. Scope: **styles and variables are document-level** (the engine enumeration APIs are document-level by nature); components/variants are platform-dependent — platforms that can read beyond the current page cover the whole document, those that cannot (jsDesign / MasterGo) **cover the current page only**, named in note. **This is step one of any design task: read it first, and reuse any component / variant value / style / variable that matches by name or purpose — never create a duplicate**; only build something new when the roster does not have it. A face whose capability the platform does not declare comes back as an empty array (jsDesign has no variables and cannot list styles); the reason is named in note — **an empty array does not mean the document has none**. `variants[].properties` is omitted entirely when the platform cannot read that field (never an empty object). Drill into assets by id with jsd_find. Also carries pages: each page name and its top-level node count. On dynamic-page platforms the first read loads the whole document and names that cost in note (idempotent — later calls do not reload). On platforms that cannot read beyond the current page (jsDesign / MasterGo) the roster and pages cover the current page only, also named in note — that does not mean the document has one page","getPage.followUp":`Read a specific node serialized by id; pass scope=document to search across pages`,"mcp.instructions":`Tools for operating the design canvas. One operation per jsd_* tool, no op dispatch; the aggregate entrypoints jsd_manage_nodes / jsd_manage_components are only for batch or mixed structure operations. Discipline:
|
|
25
|
+
If it reports "plugin not connected", tell me to run the text-to-design plugin inside my design app.`,"panel.expand":`Expand`,"panel.collapse":`Collapse`,"panel.close":`Close`,"selection.title":`Selected nodes`,"selection.badge":`{count} nodes · {size} serialized`,"selection.copy":`Copy`,"selection.empty.title":`No nodes selected`,"selection.empty.hint":`Select nodes on the canvas and they show up here, ready to copy`,"capability.card.title":`Capabilities`,"capability.card.missing":`Capabilities unavailable (plugin not connected)`,"capability.card.badgeTitle":`Core capability count · platform-specific capabilities available · platform op count`,"capability.card.badge":`core {core} · platform {host}/{total} · op {ops}`,"capability.card.coreSection":`Core capabilities`,"capability.card.hostSection":`Platform differences`,"capability.card.opTitle":`{op}: supported on the current platform`,"capability.card.opTitleOff":`{op}: not supported on the current platform`,"capability.card.opsSection":`Platform-specific ops`,"capability.card.refresh":`Refresh`,"capability.card.noOps":`No platform-specific ops on this platform`,"log.trigger":`Log`,"log.trigger.title":`Log: MCP calls and connection events`,"log.trigger.unread":`Log, {count} new errors`,"log.trigger.unit":`errors`,"log.trigger.announce":`{count} new errors`,"log.drawer.title":`Log`,"log.drawer.count":`{shown} / {total}`,"log.drawer.clear":`Clear`,"log.drawer.close":`Close log`,"log.drawer.filter.all":`All`,"log.drawer.filter.info":`Info+`,"log.drawer.filter.warn":`Warn+`,"log.drawer.filter.error":`Error`,"log.drawer.empty":`No log yet. MCP calls and connection events are recorded here.`,"log.drawer.emptyFiltered":`Nothing at level "{filter}" — switch to "All" for the full record.`,"log.drawer.copy":`Copy`,"log.drawer.newCount":`↓ {count} new entries`,"bridge.log.superseded":`Another plugin panel took over the channel; auto-reconnect stopped (click "Reclaim" in the panel header to switch back)`,"bridge.log.confirmed":`Service confirmed the connection (version {version})`,"bridge.log.versionPush":`Latest npm versions received: plugin {ui}, service {mcp}`,"bridge.log.versionUnknown":`unknown`,"bridge.log.handshakeTimeout":`WS handshake timed out ({ms}ms), giving up on this connection: {port}`,"bridge.log.serverConnected":`MCP server connected, waiting for service confirmation: ws://localhost:{port}`,"bridge.log.confirmTimeout":`Service confirmation timed out, closing: {port}`,"bridge.log.closed":`Connection closed: {port}`,"bridge.log.stale":`Service confirmation expired (no heartbeat for {ms}ms), closing: {port}`,"bridge.log.wsFailed":`Failed to handle WS message: {message}`,"bridge.log.recvRequest":`Server request received: {method}`,"bridge.log.recvResponse":`Server response received (ignored): {id}`,"bridge.log.forwardTimeout":`Forwarding to plugin timed out: {method}`,"bridge.log.pluginTimeout":`Plugin response timed out`,"bridge.log.ignoreUnknown":`Ignoring unknown plugin message: {type}`,"bridge.log.codeFailed":`Failed to handle code message: {message}`,"bridge.log.sendFailed":`Failed to send response (server not connected): {id}`,"bridge.log.manualClose":`Disconnected manually`,"bridge.log.capabilityMissing":`Capability reply malformed (missing platform)`,"bridge.log.capabilityFailed":`Failed to fetch capabilities: {message}`,"bridge.log.pingOk":`Plugin ping succeeded: {data}`,"bridge.log.pingFailed":`Plugin ping failed: {message}`,"bridge.error.useBridge":`useBridge must be used inside <BridgeProvider>`,"schema.base.r":`Red channel, 0-1 (0=none, 1=full), e.g. 1 for pure red; values >1 are treated as 0-255 and auto-normalized`,"schema.base.g":`Green channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.b":`Blue channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1; >1 treated as 0-255 and auto-normalized`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`Transform matrix [[a,b,tx],[c,d,ty]]`,"schema.base.type":`Fill type: solid`,"schema.base.opacity":`Opacity 0-1, default 1`,"schema.base.visible":`Whether visible, default true`,"schema.base.blendMode":`Blend mode, default NORMAL`,"schema.base.blendMode2":`Solid fill (SOLID): {color:{r,g,b}}`,"schema.base.type2":`Fill type: linear gradient`,"schema.base.gradientStops":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform":`Linear gradient (GRADIENT_LINEAR): transitions along a straight line`,"schema.base.type3":`Fill type: radial gradient`,"schema.base.gradientStops2":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform2":`Radial gradient (GRADIENT_RADIAL): radiating outwards from the centre`,"schema.base.type4":`Fill type: angular gradient`,"schema.base.gradientStops3":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform3":`Angular gradient (GRADIENT_ANGULAR): transitions around the circumference`,"schema.base.type5":`Fill type: image fill`,"schema.base.imageHash":`Image asset hash (injected by jsd_fill_image etc.)`,"schema.base.scaleMode":`Image scale mode: FIT | FILL | CROP | TILE`,"schema.base.scaleMode2":`Image fill (IMAGE): references the image by imageHash`,"schema.base.type6":`Effect type: drop shadow (cast outside the node)`,"schema.base.color2":`Shadow color (with alpha)`,"schema.base.x":`Horizontal offset (px), positive = right`,"schema.base.y":`Vertical offset (px), positive = down`,"schema.base.y2":`Shadow offset vector (px)`,"schema.base.radius":`Blur radius (px), >=0`,"schema.base.spread":`Spread (px), positive expands and negative shrinks the shadow, default 0`,"schema.base.visible2":`Whether visible, default true`,"schema.base.blendMode3":`Blend mode, default NORMAL`,"schema.base.showShadowBehindNode":`Whether the shadow is drawn behind the node (otherwise under its content), default true`,"schema.base.showShadowBehindNode2":`Drop shadow (DROP_SHADOW): a shadow cast outside the node`,"schema.base.type7":`Effect type: inner shadow (cast inside the node)`,"schema.base.color3":`Shadow color (with alpha)`,"schema.base.x2":`Horizontal offset (px), positive = right`,"schema.base.y3":`Vertical offset (px), positive = down`,"schema.base.y4":`Shadow offset vector (px)`,"schema.base.radius2":`Blur radius (px), >=0`,"schema.base.spread2":`Spread (px), positive expands and negative shrinks, default 0`,"schema.base.visible3":`Whether visible, default true`,"schema.base.blendMode4":`Blend mode, default NORMAL`,"schema.base.blendMode5":`Inner shadow (INNER_SHADOW): a shadow cast inside the node`,"schema.base.type8":`Effect type: layer blur (blurs the whole node itself)`,"schema.base.radius3":`Blur radius (px), >=0`,"schema.base.visible4":`Whether visible, default true`,"schema.base.visible5":`Layer blur (LAYER_BLUR): blurs the node itself`,"schema.base.type9":`Effect type: background blur (blurs what is behind the node)`,"schema.base.radius4":`Blur radius (px), >=0`,"schema.base.visible6":`Whether visible, default true`,"schema.base.visible7":`Background blur (BACKGROUND_BLUR): blurs the content behind the node`,"schema.base.pattern":`Grid type: ROWS | COLUMNS | GRID`,"schema.base.alignment":`Alignment: MIN | MAX | CENTER | STRETCH`,"schema.base.sectionSize":`Section size (px)`,"schema.base.gutterSize":`Gutter size (px)`,"schema.base.offset":`Offset (px)`,"schema.base.windingRule":`Winding rule: NONZERO | EVENODD | NONE, default NONZERO`,"schema.base.value":`Line height value (px)`,"schema.base.unit":`Unit: PIXELS = fixed pixels`,"schema.base.value2":`Line height value (percentage)`,"schema.base.unit2":`Unit: PERCENT = percentage`,"schema.base.unit3":`Unit: AUTO = automatic line height`,"schema.base.unit4":`Automatic line height: {unit: "AUTO"}, no value needed`,"schema.base.unit5":`Unit: PIXELS = pixels | PERCENT = percentage`,"schema.batch.calls":`Step list, executed in array order (mutually exclusive with callsFile)`,"schema.batch.callsFile":`Absolute path to a JSON file holding the step list (mutually exclusive with calls). Use it when the arguments are too large to fit in the context — the file holds {"calls":[…]}, or a bare array (equivalent), with the same shape as calls, and may also carry stopOnError / checkDrift. The file content is read and used as call arguments`,"schema.batch.ok":`True when every step ran and succeeded (executed < total means it stopped halfway)`,"schema.batch.executed":`Number of steps that actually produced a result`,"schema.batch.total":`Total number of planned steps`,"schema.batch.error":`Failure reason (human-readable text)`,"schema.batch.error2":`Id of the step that failed`,"schema.executeOp.depth":`Serialization depth`,"schema.executeSchemas.type":`Child node type`,"schema.executeSchemas.x":`X relative to the parent (px)`,"schema.executeSchemas.y":`Y relative to the parent (px)`,"schema.executeSchemas.x2":`X relative to the parent (px)`,"schema.executeSchemas.y2":`Y relative to the parent (px)`,"schema.executeSchemas.width":`Width (px)`,"schema.executeSchemas.height":`Height (px)`,"schema.executeSchemas.rotation":`Rotation angle (deg)`,"schema.executeSchemas.opacity":`Opacity 0-1`,"schema.executeSchemas.strokes":`Stroke list (Paint array)`,"schema.executeSchemas.strokeWeight":`Stroke weight (px)`,"schema.executeSchemas.strokeTopWeight":`Top stroke weight (px)`,"schema.executeSchemas.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.executeSchemas.strokeLeftWeight":`Left stroke weight (px)`,"schema.executeSchemas.strokeRightWeight":`Right stroke weight (px)`,"schema.executeSchemas.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.executeSchemas.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.executeSchemas.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.executeSchemas.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow/blur, stackable)`,"schema.executeSchemas.vertical":`Constraint inside auto-layout`,"schema.executeSchemas.clipsContent":`Whether overflowing content is clipped`,"schema.executeSchemas.cornerSmoothing":`Corner smoothing 0-1`,"schema.executeSchemas.layoutGrids":`Layout grids (guides)`,"schema.executeSchemas.cornerRadius":`Corner radius (px), same on all four corners`,"schema.executeSchemas.topLeftRadius":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.executeSchemas.paddingTop":`Top padding (px)`,"schema.executeSchemas.paddingRight":`Right padding (px)`,"schema.executeSchemas.paddingBottom":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.layoutGrow":`Grow factor inside auto-layout`,"schema.executeSchemas.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.cornerRadius2":`Corner radius (px)`,"schema.executeSchemas.startingAngle":`Starting angle (radians)`,"schema.executeSchemas.endingAngle":`Ending angle (radians)`,"schema.executeSchemas.innerRadius":`Inner radius (0-1 ratio)`,"schema.executeSchemas.innerRadius2":`Arc path parameters, draws a ring`,"schema.executeSchemas.innerRadius3":`ELLIPSE = ellipse (use arcData to draw a ring)`,"schema.executeSchemas.type3":`LINE = line`,"schema.executeSchemas.pointCount":`Polygon corner count, e.g. 6 = hexagon`,"schema.executeSchemas.cornerRadius3":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius2":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius2":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius2":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius2":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON = polygon (use pointCount)`,"schema.executeSchemas.pointCount2":`Star point count, e.g. 5 = five-pointed star`,"schema.executeSchemas.innerRadius4":`Inner radius (0-1 ratio)`,"schema.executeSchemas.cornerRadius4":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius3":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius3":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius3":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius4":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius5":`STAR = star (with pointCount / innerRadius)`,"schema.executeSchemas.vectorPaths":`Vector path data`,"schema.executeSchemas.fontSize":`Font size (px), default 16`,"schema.executeSchemas.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.executeSchemas.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.executeSchemas.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`Line height: {value, unit}`,"schema.executeSchemas.letterSpacing":`Letter spacing: {value, unit}`,"schema.executeSchemas.letterSpacing2":`Letter spacing: {value, unit}, unit is PIXELS | PERCENT`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.paddingTop2":`Top padding (px)`,"schema.executeSchemas.paddingRight2":`Right padding (px)`,"schema.executeSchemas.paddingBottom2":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft2":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode2":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.path":`GROUP = group (implemented as a frame internally)`,"schema.executeSchemas.children2":`Child nodes to merge (at least 2)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION = boolean operation (merges child nodes)`,"schema.execute.name":`Name of the generated layer, default svg-design`,"schema.execute.html":`HTML fragment, inline styles supported`,"schema.execute.name2":`Name of the generated layer, default html-design`,"schema.execute.size":`Icon edge length in px, default 24`,"schema.execute.color":`Stroke color (hex), default #000000`,"schema.execute.strokeWidth":`Stroke width, default 2`,"schema.execute.name3":`Name of the generated layer, default icon-<icon name>`,"schema.inputs.ids":`Find by node id, highest priority`,"schema.inputs.name":`Fuzzy match by name (contains)`,"schema.inputs.recursive":`Whether to search recursively (default true)`,"schema.inputs.depth":`Serialization depth: 0 = self only, 1 = with direct children; default 1`,"schema.inputs.name2":`Group only: group name`,"schema.inputs.paddingTop":`Group only. Top padding (px)`,"schema.inputs.paddingRight":`Group only. Right padding (px)`,"schema.inputs.paddingBottom":`Group only. Bottom padding (px)`,"schema.inputs.paddingLeft":`Group only. Left padding (px)`,"schema.inputs.primaryAxisSizingMode":`Group only. Main axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisSizingMode":`Group only. Cross axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisAlignItems":`Group only. Cross axis alignment: MIN | MAX | CENTER`,"schema.inputs.key":`Team library component key (required only for import_component)`,"schema.inputs.componentId":`Target component (COMPONENT) node id`,"schema.inputs.format":`Export format, default PNG`,"schema.inputs.scale":`Scale factor (PNG/JPG), default 1`,"schema.inputs.savePath":`Absolute path to write, e.g. /tmp/icon.png`,"schema.inputs.includeDataUrl":`Whether to also return the base64 dataURL, default false`,"schema.inputs.ids2":`Node ids to fill with the image`,"schema.inputs.sourcePath":`Absolute path of the local image, e.g. /tmp/poster.png`,"schema.inputs.params":`Operation parameters; the shape depends on the op`,"schema.inputs.family":`Filter by family name (case-insensitive substring), e.g. "Source"`,"schema.inputs.offset":`Paging start index (families to skip), default 0`,"schema.inputs.limit":`Max families per page, default 50, max 500; a font library can hold ~1900 families and dumping all of them blows up the context`,"schema.platform.name":`op name, pass it verbatim when calling jsd_platform_op`,"schema.platform.description":`Includes the params shape`,"schema.results.capabilities":`Platform-difference capabilities`,"schema.results.families":`Available font families`,"schema.results.family":`Font family`,"schema.results.styles":`Styles available in this family, e.g. ["Regular","Medium","Bold"]`,"schema.results.count":`Number of font families in this page`,"schema.results.total":`Total families after filtering (independent of paging)`,"schema.results.offset":`Start index of this page`,"schema.results.truncated":`true means more pages exist; continue with offset`,"schema.sharedProps.width":`Width (px)`,"schema.sharedProps.height":`Height (px)`,"schema.sharedProps.rotation":`Rotation angle (deg, around the node top-left origin; x/y unchanged)`,"schema.sharedProps.opacity":`Opacity 0-1`,"schema.sharedProps.pointCount":`Polygon/star corner count (POLYGON / STAR only)`,"schema.sharedProps.innerRadius":`Inner radius (0-1 ratio)`,"schema.sharedProps.strokes":`Stroke list (Paint array)`,"schema.sharedProps.strokeWeight":`Stroke weight (px)`,"schema.sharedProps.strokeTopWeight":`Top stroke weight (px)`,"schema.sharedProps.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.sharedProps.strokeLeftWeight":`Left stroke weight (px)`,"schema.sharedProps.strokeRightWeight":`Right stroke weight (px)`,"schema.sharedProps.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.sharedProps.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.sharedProps.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.topLeftRadius":`Top-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.sharedProps.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.sharedProps.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.sharedProps.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.sharedProps.lineHeight":`Line height: {value, unit}`,"schema.sharedProps.letterSpacing":`Letter spacing: {value, unit}`,"schema.sharedProps.textStyleId":`Local text style id`,"schema.sharedProps.textTruncation":`Text truncation: DISABLED | ENDING (Figma only)`,"schema.sharedProps.maxLines":`Maximum number of lines, Figma only`,"schema.sharedProps.paddingTop":`Top padding (px)`,"schema.sharedProps.paddingRight":`Right padding (px)`,"schema.sharedProps.paddingBottom":`Bottom padding (px)`,"schema.sharedProps.paddingLeft":`Left padding (px)`,"schema.sharedProps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.sharedProps.layoutGrow":`Grow factor inside auto-layout`,"schema.sharedProps.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.sharedProps.fillStyleId":`Local fill style id`,"schema.sharedProps.effectStyleId":`Local effect style id`,"schema.sharedProps.effects":`Effect list (shadow/blur, stackable)`,"schema.sharedProps.vertical":`Constraint inside auto-layout`,"schema.sharedProps.clipsContent":`Whether overflowing content is clipped`,"schema.sharedProps.cornerSmoothing":`Corner smoothing 0-1`,"schema.sharedProps.layoutGrids":`Layout grids (guides)`,"schema.sharedProps.startingAngle":`Starting angle (radians)`,"schema.sharedProps.endingAngle":`Ending angle (radians)`,"schema.sharedProps.innerRadius2":`Inner radius (0-1 ratio)`,"schema.sharedProps.innerRadius3":`Arc path parameters, ELLIPSE nodes only`,"schema.splitOps.ids":`Target node id list; defaults to the current selection`,"schema.splitOps.matchName":`Filter precisely by name`,"schema.splitOps.ids2":`Node ids to delete; defaults to the current selection`,"schema.splitOps.matchName2":`Delete only nodes whose name matches exactly`,"schema.splitOps.name":`Group name`,"schema.splitOps.paddingTop":`Top padding (px)`,"schema.splitOps.paddingRight":`Right padding (px)`,"schema.splitOps.paddingBottom":`Bottom padding (px)`,"schema.splitOps.paddingLeft":`Left padding (px)`,"schema.splitOps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.splitOps.ids3":`Ids of broken nodes to clean up; defaults to all broken nodes on the current page`,"schema.splitOps.name2":`Component name`,"schema.splitOps.key":`Team library component key`,"schema.splitOps.name3":`Name of the imported node`,"schema.splitOps.componentId":`Target component (COMPONENT) node id`,"schema.splitOps.name4":`Variant set name`,"schema.splitOps.sourceId":`Source instance id, i.e. the snapshotId returned by an earlier copy_overrides`,"schema.splitOps.name5":`New node name`,"batch.title":`Batch orchestration`,"batch.followUp":`Review the canvas result after the orchestrated run`,"createComponent.title":`Create component`,"createComponent.description":`Create a COMPONENT and return the new id. Pass children to build it with content in one call (same fields as jsd_create_frame children), optionally with width/height; without children you get an empty shell to fill via jsd_reparent_nodes. The source nodes are never converted or modified — a component is always created fresh. Name variants as "prop=value, prop=value"; set variant properties with jsd_set_instance_properties`,"createComponent.description2":`Resize the component / add fill, corner radius, shadow`,"createInstance.title":`Create component instance`,"createInstance.description":`Set the variant properties of the instance`,"detachInstance.title":`Detach instance`,"detachInstance.description":`Edit the detached node freely`,"importComponent.title":`Import component from team library`,"importComponent.description":`Create an instance of the imported component`,"swapComponent.title":`Swap component`,"swapComponent.description":`Set variant properties after the swap`,"setInstanceProperties.title":`Set variant properties`,"setInstanceProperties.description":`Sync overrides across other instances`,"combineAsVariants.title":`Combine as variant set`,"copyOverrides.title":`Copy instance overrides snapshot`,"copyOverrides.description":`Apply the snapshot to target instances`,"applyOverrides.title":`Apply instance overrides snapshot`,"applyOverrides.description":`Keep syncing other instances`,"syncOverrides.title":`Sync instance overrides`,"syncOverrides.description":`Review the synced instances`,"createFrame.title":`Create frame container`,"createFrame.description":`Create a single FRAME node; input holds only FRAME fields: width/height size, layoutMode auto-layout (itemSpacing/padding*/main and cross axis sizing and alignment) plus visual fields such as fills and strokes. Only one root FRAME is created; use children only for small structures (a container plus its direct children, child x/y relative to the parent) — never pass a whole screen tree in one children call. Build layer by layer with jsd_batch, then reparent each layer into its parent with jsd_reparent_nodes. Set layoutMode=HORIZONTAL or VERTICAL before auto-layout fields (otherwise they are ignored). Without explicit fills the engine defaults to a white background; pass fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}] for a transparent container. Always pass a semantic name (e.g. "Sidebar", "KPI-OEE"); unnamed nodes fall back to the engine default name node. Use jsd_batch to create multiple roots or complex trees`,"createRectangle.title":`Create rectangle`,"createRectangle.description":`Create a single RECTANGLE node; input holds only rectangle fields: width/height, cornerRadius per corner and visual fields such as fills and strokes. Only one root rectangle; use children only for small structures (child x/y relative to the parent). Always pass a semantic name (e.g. "Card base", "Chart gridlines"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createText.title":`Create text`,"createText.description":`Create a single TEXT node; input holds only text fields: characters (required), fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing and fills/strokes. Only one root text node. Resolve fonts with jsd_list_fonts first: use fonts[].family verbatim and the full name from the same entry's styles (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings will name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content). Always pass a semantic name (e.g. "Chart title", "KPI value"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createEllipse.title":`Create ellipse`,"createEllipse.description":`Create a single ELLIPSE node: width/height, arcData ring parameters (draws a ring) and visual fields such as fills and strokes. Only one root ellipse. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createLine.title":`Create line`,"createLine.description":`Create a single LINE node: width/height and stroke fields. For short straight segments LINE + rotation is more stable. One axis may be 0: the engine resize check demands >= 0.01 so the plugin lifts the zero axis to 0.01 (visually a straight line, serialization still reads 0); jsd_resize_node accepts a zero axis too. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createPolygon.title":`Create polygon`,"createPolygon.description":`Create a single POLYGON node: pointCount is required (e.g. 6 = hexagon), plus cornerRadius and visual fields. Only one root polygon. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createStar.title":`Create star`,"createStar.description":`Create a single STAR node: pointCount corner count, innerRadius ratio and visual fields such as fills and strokes. Only one root star. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createVector.title":`Create vector`,"createVector.description":`Create a single VECTOR node: vectorPaths/vectorNetwork geometry with fills and strokes. Prefer jsd_create_icon or SVG import for icon-like shapes. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createGroup.title":`Create group`,"createGroup.description":`Create a single GROUP node wrapping the given children: group first, then lay out. Only one root group. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createBooleanOperation.title":`Create boolean operation node`,"createSvg.title":`Import SVG`,"createSvg.description":"Import an SVG into the canvas as editable layers (native createNodeFromSvg parsing; paths/gradients/strokes preserved). Pick one source: svg (inline string) or svgPath (path to a local .svg file, read by the background service). **Charts and data visualisations must use svgPath** (line, bar, pie/donut, scatter, radar, area, gauge, dashboard, Sankey, …): there is no built-in chart tool — write a script that computes the SVG, write it to a local file, then pass the path. Engine hard constraints (violations fail silently): the root element needs xmlns plus explicit width/height/viewBox; colours as hex only; no external images/fonts/scripts; approximate curves with C/Q, never the A command; canvas ≤2000×2000; split semantic layers into `<g id>` (one wrapper group is no grouping), with a single transform on the outer group only. Before you start, ReadMcpResource the recipe jsd://recipes/chart-by-code — it carries the zero-dependency example, the colour and type-scale conventions, and the post-import layer check plus visual acceptance checklist. Use jsd_batch to orchestrate multiple root nodes or complex trees","createIcon.title":`Insert built-in icon`,"htmlToDesign.title":`HTML to design nodes`,"htmlToDesign.description":`Convert an HTML fragment into canvas nodes. Default path is jsd_html_to_design (SVG fidelity, complex styles dropped); only use per-type create tools (jsd_create_frame etc.) when editable layers are required`,"manageNodes.title":`Node structure operations (aggregate)`,"manageNodes.followUp":`Set the container auto-layout after the structure change`,"manageComponents.title":`Component and instance operations (aggregate)`,"manageComponents.description":`Aggregate entrypoint dispatching by op: create_component / create_instance / detach_instance / import_component / combine_as_variants / swap_component / set_instance_properties / copy_overrides / apply_overrides / sync_overrides. Prefer the dedicated small tools for a single op`,"manageComponents.description2":`Set variant properties after the component/instance change`,"find.title":`Find nodes`,"find.description":`Set the matched nodes as the current selection for later edits/deletes`,"selectNodes.title":`Set canvas selection`,"selectNodes.description":`Move or resize the selected nodes`,"deleteNode.title":`Delete node`,"deleteNode.description":`Review the remaining nodes after deletion`,"cloneNode.title":`Clone node`,"cloneNode.description":`Move the copy to the target position`,"groupNodes.title":`Group nodes`,"groupNodes.description":`Set the auto-layout of the new group`,"ungroupNodes.title":`Ungroup nodes`,"ungroupNodes.description":`Adjust child positions after ungrouping`,"flattenNodes.title":`Flatten into vector`,"flattenNodes.description":`Set the fill of the flattened shape`,"outlineStroke.title":`Outline stroke`,"outlineStroke.description":`Adjust the stroke of the new outline`,"reparentNodes.title":`Move nodes under a parent`,"reparentNodes.description":`Fine-tune x/y under the new parent if needed (absolute position is preserved automatically)`,"repairNodes.title":`Repair broken nodes`,"repairNodes.description":`Review the page node state after repairing`,"platformOp.title":`Platform-specific operation`,"platformOp.description":`Run a platform-specific op (Figma: variables / local styles / component properties; MasterGo: variable read-write / component properties / set-level variant management). CRITICAL: never guess op names or parameters — read the platformOps list (each entry carries its parameter shape) and capabilities from jsd_ping first, then call by the listed names; an unsupported platform or a wrong op name returns an error listing the ops the current platform supports`,"platformOp.description2":`Review the effect of the platform op on the canvas`,"prompt.htmlToDesign.title":`HTML to design`,"prompt.htmlToDesign.description":`Convert an HTML fragment into canvas nodes, with fidelity trade-offs`,"prompt.iconGrid.title":`Icon grid`,"prompt.iconGrid.description":`Insert Lucide icons in bulk and lay them out in an auto-layout grid`,"prompt.scriptOps.title":`Scripted batch calls`,"prompt.chartByCode.title":`Charts / data visualization by code`,"prompt.chartByCode.description":`The primary path for charts and data visualization — line, bar, pie / donut, scatter, radar, area, gauge, dashboard or any other chart: write your own code to compute the geometry, save the SVG to a file, then import it via jsd_create_svg (dependency-free example plus engine-side hard constraints)`,"prompt.designStrategy.title":`Design strategy overview`,"prompt.textReplace.title":`Bulk text replacement strategy`,"prompt.variantSync.title":`Bulk sync styles across sibling instances`,"prompt.variableBinding.title":`Bind variables and apply in bulk`,"prompt.variantSet.title":`Build a variant set`,"prompt.componentProperty.title":`Define and set component properties`,"setFillColor.title":`Set fill`,"setFillColor.followUp":`Next set the stroke`,"setStroke.title":`Set stroke`,"setStroke.description":`Next set the fill`,"setCornerRadius.title":`Set corner radius`,"setCornerRadius.description":`Next set shadow/blur effects`,"setText.title":`Modify text`,"setText.followUp":`Give the text a semantic name`,"moveNode.title":`Move node`,"moveNode.description":`Next adjust the size`,"resizeNode.title":`Resize node`,"resizeNode.description":`Next set visibility/lock`,"setLayout.title":`Set auto-layout`,"setLayout.description":`Move child nodes into the container to finish the layout`,"setEffects.title":`Set effects and advanced properties`,"setEffects.description":`Next set visibility/lock`,"setVisibility.title":`Set visibility and lock`,"setVisibility.description":`Review the canvas selection after the change`,"renameNode.title":`Rename node`,"renameNode.description":`Next edit the text content/typography`,"setShape.title":`Set polygon/star shape`,"setShape.description":`Next set the fill`,"export.title":`Export nodes as images`,"export.description":`Export the given nodes to PNG files. Large base64 payloads are dropped from the result and written to disk instead; use jsd_export again with a smaller scale if you need inline data`,"export.description2":`Fill the exported image into a node`,"fillImage.title":`Fill node with a local image`,"fillImage.description":`Read a local image file and fill the given nodes with it (IMAGE fill)`,"fillImage.description2":`Review the image fill result`,"listFonts.title":`List available fonts`,"listFonts.description":`Set text with the listed fonts`,"createStyle.title":`Create a local style`,"createStyle.description":"Creates one local style **from an existing node** and returns its id and name. Eight categories — the union of the three engines’ `StyleType`: PAINT / TEXT / EFFECT / GRID exist on **all three**; STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING are **MasterGo only** — the other two have no factory, so asking for them is rejected before the request, listing the categories that platform does support (never silently built as some other kind). Copying from a layer is the only shape all three platforms share: MasterGo natively does `createFillStyle({name, id: layerId})` and the engine takes the style from that layer; Figma / jsDesign expose no-arg factories, so this tool fills the new style from the node’s fills / effects / layoutGrids / text layout fields. For PAINT, fills win and strokes are the fallback (so a node with neither raises an error instead of silently creating an empty style). Mixed values (e.g. a text node using two fonts) raise an error telling you to unify the font with jsd_set_text first; the four new categories follow the same rule — SPACING / PADDING need an auto-layout container and CORNER_RADIUS needs a real corner, and when the value cannot be read the request is never sent. Bind the result by id: `jsd_set_fill_color` fillStyleId / `jsd_set_stroke` strokeStyleId / `jsd_set_text` textStyleId / `jsd_set_effects` effectStyleId — afterwards editing the style updates everywhere it is used, which is the correct way to keep a palette consistent on platforms without a variable surface. Read the catalog from `jsd://styles` (read-only resource)","createStyle.followUp":`Bind the new style id to nodes`,"deleteStyle.title":`Delete local styles`,"deleteStyle.description":'Deletes local styles by id (pass several ids at once), one at a time: a missing id lands in the result’s failed list with a reason and does not affect the others. Ids come from jsd://styles or assets.styles in jsd_get_page — **by id, not by name**, because same-named styles can coexist and deleting by name means guessing which one was meant. The counterpart of `jsd_create_style` (a feature is only safe to try when it can also be undone); variables are deleted with the platform op `figma_variables_remove` (Figma) / `mg_variables_remove` (MasterGo). ⚠ Nodes still referencing a deleted style keep a dangling `*StyleId` — the engine does not clean them up, so rebind them to another style first; this repo does not expose a "who uses this style" query (Figma has `getStyleConsumersAsync`, unwired)',"deleteStyle.followUp":`Re-read the style list to confirm`,"resources.title":`Current canvas selection`,"resources.title2":`Available font list`,"resources.title3":`Local style list`,"resources.title4":`Current page overview: top-level nodes + reusable asset roster`,"resources.title5":`Node detail`,"resources.title6":`Platform state and capabilities`,"resources.title7":`Recipe index`,"resources.title8":`Recipe body`,"ping.followUp":`Read the current selection once the connection is confirmed; for creation tasks read the design-strategy prompt first`,"getSelection.title":`Read canvas selection`,"getSelection.description":`Read the current selection of the canvas, serialized with direct children; equivalent to jsd_get_selection depth=2`,"getSelection.description2":`Find nodes precisely inside the selection`,"getPage.title":`Current page overview: top-level nodes + reusable asset roster`,"getPage.description":"Two read-only sections for the **current page**. (1) nodes: geometry of the current page **first-level** nodes (id/name/type/width/height/x/y, not recursive); (2) assets: the reusable roster — summary gives counts for all four faces; components; variants (with dimension -> allowed values); styles (PAINT/TEXT/EFFECT/GRID, each with its type); variables. Every entry carries id and name. Scope: **styles and variables are document-level** (the engine enumeration APIs are document-level by nature); components/variants are platform-dependent — platforms that can read beyond the current page cover the whole document, those that cannot (jsDesign / MasterGo) **cover the current page only**, named in note. **This is step one of any design task: read it first, and reuse any component / variant value / style / variable that matches by name or purpose — never create a duplicate**; only build something new when the roster does not have it. A face whose capability the platform does not declare comes back as an empty array (jsDesign has no variables and cannot list styles); the reason is named in note — **an empty array does not mean the document has none**. `variants[].properties` is omitted entirely when the platform cannot read that field (never an empty object). Drill into assets by id with jsd_find. Also carries pages: each page name and its top-level node count. On dynamic-page platforms the first read loads the whole document and names that cost in note (idempotent — later calls do not reload). On platforms that cannot read beyond the current page (jsDesign / MasterGo) the roster and pages cover the current page only, also named in note — that does not mean the document has one page","getPage.followUp":`Read a specific node serialized by id; pass scope=document to search across pages`,"mcp.instructions":`Tools for operating the design canvas. One operation per jsd_* tool, no op dispatch; the aggregate entrypoints jsd_manage_nodes / jsd_manage_components are only for batch or mixed structure operations. Discipline:
|
|
26
26
|
- **The first step of any design/creation task is reading the jsd_get_page roster** (assets.summary counts components / variants / styles / variables): reuse whatever matches — spread components with jsd_create_instance, switch to an existing variant value with jsd_set_instance_properties, and use the platform platformOps entry for styles and variables. Only build a new node when the roster genuinely lacks it (and name new assets "family/state" so the next run can reuse them).
|
|
27
27
|
- Create nodes with per-type tools: jsd_create_frame / jsd_create_rectangle / jsd_create_text etc., one node type each; use jsd_batch for multi-root or deeply nested trees. The root x/y comes from placement (default center overwrites the root x/y with the viewport centre; pass placement:{mode:"manual"} to lay out by coordinates, or mode:"absolute" with x/y). Build the hierarchy deep enough — never stop at one level: children is only for small structures (a container plus its direct children; child x/y is relative to the parent), never pass a whole screen tree in one children call. Every element must live inside a semantic container, never directly under the screen root: screen → semantic sections (sidebar / topbar / filter bar / KPI row / each card) → elements inside a card grouped by meaning. Always pass a semantic name (unnamed nodes fall back to the engine default name node). Then jsd_reparent_nodes to group (pass parentId explicitly; cross-parent moves preserve absolute position and recompute x/y under the new parent, and auto-layout containers take over the position). Set auto-layout (layoutMode/itemSpacing/padding* …) last with jsd_set_layout.
|
|
28
28
|
- Modify properties with the dedicated tools: fills jsd_set_fill_color, stroke jsd_set_stroke, radius jsd_set_cornerRadius, text jsd_set_text, position jsd_move_node, size jsd_resize_node (x/y too), layout jsd_set_layout, effects jsd_set_effects, visibility jsd_set_visibility, rename jsd_rename_node, shape jsd_set_shape.
|
|
@@ -34,46 +34,92 @@ 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; 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.
|
|
37
|
-
A placeholder that occupies a whole argument keeps its type (an array can be used directly as ids); embedded in a string it is expanded as JSON text. Placeholders are valid only inside the same call (the step table is destroyed when the call ends; referencing a previous batch aborts the whole batch). Duplicate ids, unknown tools or unresolvable references abort immediately; a failing step aborts by default (stopOnError=false, or per-step continueOnError=true, lets it finish).
|
|
37
|
+
A placeholder that occupies a whole argument keeps its type (an array can be used directly as ids); embedded in a string it is expanded as JSON text. Placeholders are valid only inside the same call (the step table is destroyed when the call ends; referencing a previous batch aborts the whole batch). 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]\`.
|
|
38
38
|
Echoes are trimmed: node objects keep id/name/type/x/y/width/height/z/parentId; vectorPaths and constraints are dropped entirely. Steps still over 20K chars after trimming degrade to an id list (echoTrimmed=true). Resolution is unaffected (the full data is used internally). Batches containing icons must be verified visually with one jsd_export — an echo is not proof.
|
|
39
|
-
Result 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_find -> nodes; jsd_get_selection -> selection; jsd_set_* -> updated; jsd_swap_component -> swapped; jsd_manage_nodes ops: select/remove/ungroup/repair -> id string arrays, clone/outline_stroke -> created[group/flatten -> created (single object), reparent -> moved[].
|
|
40
|
-
Structure drift review is on by default (checkDrift=false disables it): steps containing remove/reparent/group/ungroup/flatten/repair record sibling coordinates before the change and report any node that moved on its own. 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.`,"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.
|
|
41
|
-
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 content and typography (TEXT nodes only): characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, plus Figma truncation and max lines. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`}},Fr=/\{(\w+)\}/g;function Ir(e){let t=Pr[e]??Pr.en,n=Pr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Fr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Lr=/^zh([-_]|$)/i,Rr=/^en([-_]|$)/i;function zr(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Lr.test(t))return`zh-CN`;if(Rr.test(t))return`en`}}var Br={debug:0,info:1,warn:2,error:3},Vr={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},Hr=`@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`,Ur={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:null,evidence:[`${Hr}(全文无 variable 声明:grep -in variable 零命中)`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${Hr}:1093 setProperties 只收 string`,`${Hr}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me)`,evidence:[`${Hr}:899-900 VariantMixin.variantProperties(readonly)`,`${Hr}:1074-1079 ComponentSetNode 只有 clone / defaultVariant / variantGroupProperties`,`${Hr}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`]}},figma:{variables:{read:`boundVariables / figma_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename / remove(改变量值与生命周期,本仓未接)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(0040 起带 unbind)/ figma_variables_list`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${k}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`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}: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`],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(复合变量补子项)`],fallback:null,evidence:[`${A}:1522 readonly variables: VariableAPI`,`${A}:1098-1108 VariableAPI(Collection / Mode)`,`${A}:1176 getVariables() / :1874 Variable{id,name,…}`,`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释)`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${A}:3096 readonly componentProperties: Array<ComponentProperties>`,`${A}:3097 setProperties({ [propertyId: string]: string | boolean })`,`${A}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`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:Ur[e][t]}var Wr={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},Gr=`https://registry.npmjs.org`;function Kr(e){return`${Gr}/${e}/latest`}var qr=4e3,Jr=process.env.TEXT_TO_DESIGN_MCP_LOG??u(c(),`text-to-design-mcp.log`),Yr=Br,Xr=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,Zr=null;function Qr(e){Zr=e}function $r(e,n){if(Yr[e]>=Yr[Xr])try{t(Jr,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{Zr?.(e,n)}catch{}}function M(e){$r(`info`,e)}function N(e){$r(`debug`,e)}function P(e){$r(`warn`,e)}function F(e){$r(`error`,e)}var ei=xe,ti=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??ei,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 g(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new g(`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 g(`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 g(t.error.code,t.error.message):new g(`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 g(`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(ni(e.data,e.buffers))}};function ni(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 ri=`0.12.1`,ii=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),ai=`text-to-design-mcp-server`,L=ri,oi=Date.now(),si=15e3,ci=6e3,li=5e3,ui=6e4,di=3e5,fi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),pi=12e4,mi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),hi={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,gi=null;function _i(){return R}function vi(){let e=R?.platform;if(e==null)return{label:hi.label,runtime:hi.runtime};let t=S[e];return{label:`${t}客户端`,runtime:t}}function yi(e){R!=null&&(R=null,N(`平台状态已清空(${e})`))}function bi(e){return gi??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:li});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(`平台状态已缓存: ${S[R.platform]}(平台差异能力 ${R.capabilities.length} 项 / 特有操作 ${R.platformOps.length} 个)`)}catch(e){N(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{gi=null}})(),gi}function xi(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function Si(e){if(xi(e)!==!1)return null;let t=R?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>S[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${S[t]},已拒绝执行(未向插件发起请求)。`,e.platformNote==null?``:`${e.platformNote}`,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Ci(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var wi=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=h(),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(),ye),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===ee.OPEN}send(e){this.client&&this.client.readyState===ee.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===ee.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(be,`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} (${Ci(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===ee.OPEN&&(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==ee.OPEN)return;let n={type:`status`,state:t,version:ri};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)})}},Ti=200,Ei=class{transport=new wi;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;constructor(){this.pending=new ti((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 g(`not_connected`,`${vi().runtime} 插件未连接。请先在${vi().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=Ti&&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)}`)}}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],M(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};async function z(){try{let e=await fetch(`http://127.0.0.1:${I}/health`,{signal:AbortSignal.timeout(800)});if(!e.ok)return null;let t=await e.json();return t.name&&t.version?{name:t.name,version:t.version,...typeof t.startedAt==`number`?{startedAt:t.startedAt}:{}}:null}catch{return null}}var Di=!1;async function Oi(){if(Di)return;Di=!0;let e=process.argv[1];if(!e)return;let t;try{t=a(e).mtimeMs}catch{return}let n=await z();n?.startedAt==null||n.startedAt>=t||P(`常驻 daemon 跑在旧构建上(daemon 启动 ${new Date(n.startedAt).toISOString()} < 产物 ${new Date(t).toISOString()}),本次代码改动未生效。收掉它:curl -X POST http://127.0.0.1:${I}/shutdown,再重新拉起`)}async function ki(){let e=await z();if(e&&e.version!==L){M(`检测到旧版 daemon (${e.version} → ${L}),正在替换...`),await fetch(`http://127.0.0.1:${I}/shutdown`,{method:`POST`}).catch(()=>{});let t=Date.now()+ci;for(;Date.now()<t&&(await Ai(250),await z()!==null););return await z()===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 z()===null?{state:`none`}:{state:`starting`}}}function Ai(e){return new Promise(t=>setTimeout(t,e))}var ji=3,Mi=4,Ni=240,Pi=16,Fi=8;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ii(e,t){if(!e.startsWith(`#/`))return;let n={$defs:t};for(let t of e.slice(2).split(`/`)){let e=decodeURIComponent(t).replace(/~1/g,`/`).replace(/~0/g,`~`);if(!B(n))return;n=n[e]}return n}function Li(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 Ri(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>=Mi))break}return n}function zi(e,t,n){if(!B(e))return{};if(typeof e.$ref==`string`){if(t>Fi)return{};let r=Ii(e.$ref,n.defs);return r===void 0?{}:zi(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>Ni?`${t.slice(0,Ni)}…`:t)}let i=Li(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]=Ri(a.map(e=>zi(e,t,n))))}let a=t>=ji&&B(e.properties);if(B(e.items)&&(r.items=a?{}:zi(e.items,t+1,n)),B(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,Pi),o={};for(let r of a)o[r]=zi(e.properties[r],t+1,n);if(r.properties=o,t===0&&Array.isArray(e.required)){let t=e.required.filter(e=>typeof e==`string`&&e in o);t.length>0&&(r.required=t)}}return(r.type===`object`||B(r.properties)||B(e.items)&&r.type!==`array`)&&(r.additionalProperties=!0),r}function Bi(e){if(!B(e))return e;let t=zi(e,0,{defs:B(e.$defs)?e.$defs:{}});return B(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function Vi(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 Hi(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=Vi(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function Ui(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 Wi(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 Gi(e){let t=ce(e)[`~standard`],n=Hi(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=Wi(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${Ui(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function Ki(){let e=ue(process.execPath,[...process.execArgv,...process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});e.unref(),e.on(`error`,e=>{F(`拉起 daemon 失败: ${e.message}`)})}var qi=1500,Ji=2e4,Yi=6e4,Xi=6e5,Zi=5e5,Qi=5e3;function $i(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>Zi?[`合计 ${(t/1024).toFixed(0)} KB > ${Zi/1024} KB`]:[],...e.filter(e=>e.outputBytes>Qi).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function ea(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 n of e??[]){let e=m.string().describe(n.description??``);t[n.name]=n.required===!0?e:e.optional()}return m.object(t)}async function na(e){let t=e,n=!1,r=null,i=new ie({name:ai,version:L},{supportedProtocolVersions:[`2026-07-28`,...oe],...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||!ea(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?Bi(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:Gi(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:ce(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)}`)}}$i(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`&&P(`同步清单失败: ${String(t.reason).slice(0,120)}`)},m=()=>r||(r=(async()=>{let e=Date.now()+Ji,n=null;for(;Date.now()<e;){try{let e=await ki();if(e.state===`proxy`){t=e.client,h(t),M(`shim: 上游已恢复`),await p();return}e.state===`none`&&Ki()}catch(e){n=e}await Ai(qi)}throw n??Error(`上游重连超时(${Ji}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=le(async()=>(await p(),i)),te=L,ne=null,re=null,se=async()=>{let e=await z();e!=null&&e.version!==te&&(M(`上游版本变化(${te} → ${e.version}),全量重同步目录`),te=e.version,await p())},ue=()=>{n||(ne=setTimeout(()=>{n||se().finally(ue)},Yi),ne.unref())},de=()=>{n||(re=setTimeout(()=>{n||p().finally(de)},Xi),re.unref())};ue(),de(),M(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,ne&&clearTimeout(ne),re&&clearTimeout(re),await ee.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}function ra(e=process.env.TEXT_TO_DESIGN_LANG){return zr(e)??`zh-CN`}function ia(e=ra()){return{locale:e,t:Ir(e)}}function aa(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 oa(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=aa(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function sa(e,t){p.globalRegistry.add(e,{description:t})}function ca(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 la(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=aa(i);if(a!=null)for(let e of ca(a))r(e)};r(e)}function ua(e,t){return la(e,e=>{let n=oa(e);if(n==null)return;let r=t(n);r!==n&&sa(e,r)}),e}function da(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function fa(e){return e._def?.typeName}function pa(e,t){return e._def?.[t]}function ma(e,t){return e._def?.[t]}function V(e){switch(fa(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 ma(e,`value`);case`ZodEnum`:return ma(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=pa(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=pa(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=ma(e,`options`)??[],n=t.find(e=>fa(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 ha={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function ga(e,t,n){let r=ha[ve(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 _a(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...da(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:da(e).content,structuredContent:V(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...da(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var va=new Map;function ya(e){return va.get(e)}function ba(){return[...va.keys()].sort()}var xa=8,Sa=20;function Ca(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function wa(e,t,n){let r=Ca(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,xa).join(`, `)}]${o.length>xa?` 等 ${o.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${r.length<=Sa?`该工具接受: [${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=async(t,r,i)=>{try{let o=Si(e);if(o!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`),ga(new g(`platform_unsupported`,o),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 g(`invalid_args`,`参数校验失败(${e.name}): ${wa(e.inputSchema,t,r)}`)}t=n.data}let s={...r==null?{}:{signal:r},...e.timeout==null?{}:{timeout:e.timeout}},c=i?.skipHooks===!0?void 0:e.hook?.();if(c?.before!=null)try{await c.before(t)}catch(t){P(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let l;l=e.run?await e.run(t,n,r??new AbortController().signal):await n.request(e.method,e.payload?e.payload(t):t,s);let u=e.extraContent?e.extraContent(l,t):[],d=[];if(c?.after!=null)try{let e=await c.after(t,l)??[];for(let t of e)d.push(t),u.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;d.push(n),u.push({type:`text`,text:n})}let f=_a(l,e.outputSchema,u.length>0?u:void 0,a(e.followUp));return d.length>0?{...f,warnings:d}:f}catch(t){let n=t instanceof Error?t.message:String(t);return F(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`),ga(t,e.outputSchema,a(e.followUp))}};va.set(e.name,o);let{t:s}=r,c=i(e.name,{title:s(e.title),description:e.platformNote==null?s(e.description):`${s(e.description)}${s(e.platformNote)}`,...e.inputSchema?{inputSchema:ua(e.inputSchema,s)}:{},outputSchema:ua(e.outputSchema,s),annotations:e.annotations},async(...t)=>{let n=e.inputSchema!=null,r=t[0],i=t[1],a=n?r??{}:{},s=n?i:r,c=s?.mcpReq?.signal??s?.signal;return o(a,c)});return c.alwaysEnabled=e.alwaysEnabled??!1,c}}function Ta(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}}function Ea(e,t){let n=e.indexOf(`.`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);if(!t.has(r)){let n=[...t.keys()].join(`, `)||`无`;throw Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${n})`)}let a=t.get(r);if(i===``)return a;let o=Ta(a,i);if(!o.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${r} 的返回结构`);return o.value}var Da=/\{\{\s*([^{}]+?)\s*\}\}/g,Oa=/^\{\{\s*([^{}]+?)\s*\}\}$/,ka=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],Aa=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),ja=2e4;function Ma(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}function Na(e){if(Array.isArray(e))return e.map(Na);if(typeof e!=`object`||!e)return e;let t=e;if(typeof t.id==`string`&&typeof t.type==`string`&&typeof t.name==`string`){let e={};for(let n of ka)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))Aa.has(e)||(n[e]=Na(r));return n}function Pa(e,t){if(Array.isArray(e)){for(let n of e)Pa(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}Pa(r,t)}}function Fa(e){let t=Na(e),n=Ma(t);if(n<=ja)return{data:t,trimmed:n!==Ma(e)};let r=[];return Pa(t,r),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${n} 字符,已省略明细;需要细节请把该工具单独调用一次`,ids:[...new Set(r)]},trimmed:!0}}function Ia(e,t){if(typeof e==`string`){let n=Oa.exec(e.trim());return n==null?e.replace(Da,(e,n)=>{let r=Ea(n,t);return typeof r==`string`?r:JSON.stringify(r)}):Ea(n[1],t)}if(Array.isArray(e))return e.map(e=>Ia(e,t));if(typeof e==`object`&&e){let n={};for(let[r,i]of Object.entries(e))n[r]=Ia(i,t);return n}return e}function La(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:dt,outputSchema:ft,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:pi,run:async(e,t,n)=>{let{calls:r,stopOnError:i,checkDrift:a}=e,o=new Map,s=[],c=!1,l=a===!1,u=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.id==null||t.id.trim()===``?`step${e+1}`:t.id.trim(),d=e=>{s.push({id:a,tool:t.tool,ok:!1,error:e})};if(o.has(a)||s.some(e=>e.id===a)){d(`步骤 id "${a}" 重复`);break}let f=ya(t.tool);if(f==null){d(`未知工具 ${t.tool},可用: ${ba().join(`, `)}`);break}let p;try{p=Ia(t.args??{},o)}catch(e){d(e instanceof Error?e.message:String(e));break}let m=await f(p,n,{skipHooks:l});if(m.isError===!0){if(d((m.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),i!==!1&&t.continueOnError!==!0)break;continue}let h=Fa(m.structuredContent);h.trimmed&&(c=!0),o.set(a,m.structuredContent),m.warnings!=null&&u.push(...m.warnings),s.push({id:a,tool:t.tool,ok:!0,data:h.data})}let d=s.length===r.length,f=u;return{ok:d&&s.every(e=>e.ok),executed:s.length,total:r.length,results:s,...c?{echoTrimmed:!0}:{},...f.length>0?{warnings:f}:{}}}})(e,t,n)]}function Ra(e){return e==null?x:[e]}function U(e){return S[e]}function za(e,t){return j(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function Ba(e,t){let n=e=>{let t=e==null?null:j(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=t?`${U(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${U(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。替代路径:${za(e,`variants`)}。`,i=n(e);return i===``?r:`${r}${i}`}let r=x.filter(e=>j(e,`variants`)?.fallback!=null),i=x.filter(e=>!r.includes(e));return[`按能力位 ${Vr.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?za(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function Va(e){if(e==null)return Ra(null).map(e=>{let t=Je(e,`setProperties`),n=j(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${U(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=j(e,`components`),n=Je(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(能力位 ${Vr.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function Ha(e){if(e!=null){let t=j(e,`variables`);if(t==null)return`${U(e)}的变量面未登记。`;if(t.write.length>0)return`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。`}return`${U(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。`}let t=x.filter(e=>(j(e,`variables`)?.write.length??0)>0),n=x.filter(e=>(j(e,`variables`)?.write.length??0)===0&&(j(e,`variables`)?.nativeUnwired.length??0)>0),r=x.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=j(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${U(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function Ua(e){return e===`mastergo`?"- 绑定一次传 `nodeIds` 多个节点 + `property` + `value` + `variableId`(数组型属性另给 `index`),槽位取值见 `mg_variables_apply` 的描述,传错会在入参校验就点名;":e===`figma`?"- 绑定一次传 `nodeIds` 多个节点 + `boundProperty` + `variableId`,不要一个节点一次调用;":"- 绑定一次传多个 `nodeIds`,参数词汇以本平台变量面给的为准,不要一个节点一次调用;"}function Wa(e){return e===`mastergo`?["- ⚠ MG **没有**「图层属性 ↔ 变量」的反读接口:回读只能拿到该图层用到的集合与模式(见 `mg_list_variables`),它证明「集合挂上了」、证不了「挂在该属性上」;","- 所以绑数组属性(fills / effects / grids)**必须**自己给 `index`,并 jsd_export({ids:[节点id], scale=0.5}) 目视确认渲染真的变了 —— 这一条别省。"].join(`
|
|
39
|
+
Result 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[].
|
|
40
|
+
Structure drift review is on by default (checkDrift=false disables it): steps containing remove/reparent/group/ungroup/flatten/repair record sibling coordinates before the change and report any node that moved on its own. 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.
|
|
41
|
+
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 content and typography (TEXT nodes only): characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, plus Figma truncation and max lines. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`}},Kr=/\{(\w+)\}/g;function qr(e){let t=Gr[e]??Gr.en,n=Gr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Kr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Jr=/^zh([-_]|$)/i,Yr=/^en([-_]|$)/i;function Xr(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Jr.test(t))return`zh-CN`;if(Yr.test(t))return`en`}}var Zr={debug:0,info:1,warn:2,error:3},Qr={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},D=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,O=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,k=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,$r={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:[`${D}(全文无 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)",`${D}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${D}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${D}:1093 setProperties 只收 string`,`${D}: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)—— 没有变体集时别拿它当切状态的通道`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me)`,evidence:[`${D}:899-900 VariantMixin.variantProperties(readonly)`,`${D}:1074-1079 ComponentSetNode 只有 clone / defaultVariant / variantGroupProperties`,`${D}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${O}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${O}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${O}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${O}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${O}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:11127 readonly componentProperties`,`${O}:11123 setProperties(string | boolean | VariableAlias)`,`${O}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${O}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${O}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${O}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${O}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${O}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${O}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${k}:1522 readonly variables: VariableAPI`,`${k}:1098-1108 VariableAPI(Collection / Mode)`,`${k}:1176 getVariables() / :1874 Variable{id,name,…}`,`${k}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${k}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${k}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${k}:3096 readonly componentProperties: Array<ComponentProperties>`,`${k}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${k}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${k}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${k}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${k}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${k}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${k}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${k}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function A(e,t){return e==null?null:$r[e][t]}var ei={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},ti=`https://registry.npmjs.org`;function ni(e){return`${ti}/${e}/latest`}var ri=4e3,ii=process.env.TEXT_TO_DESIGN_MCP_LOG??d(c(),`text-to-design-mcp.log`),ai=Zr,oi=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,si=null;function ci(e){si=e}function li(e,n){if(ai[e]>=ai[oi])try{t(ii,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{si?.(e,n)}catch{}}function j(e){li(`info`,e)}function M(e){li(`debug`,e)}function N(e){li(`warn`,e)}function P(e){li(`error`,e)}var ui=we,di=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??ui,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 g(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new g(`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 g(`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 g(t.error.code,t.error.message):new g(`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 g(`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(fi(e.data,e.buffers))}};function fi(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 pi=`0.13.1`,mi=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),F=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),hi=`text-to-design-mcp-server`,I=pi,gi=Date.now(),_i=15e3,vi=6e3,yi=5e3,bi=6e4,xi=3e5,Si=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),Ci=12e4,wi=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),Ti=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),Ei={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},L=null,Di=null;function Oi(){return L}function ki(){let e=L?.platform;if(e==null)return{label:Ei.label,runtime:Ei.runtime};let t=b[e];return{label:`${t}客户端`,runtime:t}}function Ai(e){L!=null&&(L=null,M(`平台状态已清空(${e})`))}function ji(e){return Di??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:yi});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(`平台状态已缓存: ${b[L.platform]}(平台差异能力 ${L.capabilities.length} 项 / 特有操作 ${L.platformOps.length} 个)`)}catch(e){M(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{Di=null}})(),Di}function Mi(e){if(e.platforms==null)return!0;let t=L?.platform;return t==null?null:e.platforms.includes(t)}function Ni(e){if(Mi(e)!==!1)return null;let t=L?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>b[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${b[t]},已拒绝执行(未向插件发起请求)。`,e.platformNote==null?``:`${e.platformNote}`,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Pi(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Fi=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=te(),this.wss=new ne({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===h.OPEN}send(e){this.client&&this.client.readyState===h.OPEN?(this.client.send(e),M(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):N(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===h.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} (${Pi(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===h.OPEN&&(this.sendStatus(e,`ready`),M(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==h.OPEN)return;let n={type:`status`,state:t,version:pi};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)})}},Ii=200,Li=class{transport=new Fi;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;constructor(){this.pending=new di((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):(N(`请求被拒(插件未连接): ${e}`),Promise.reject(new g(`not_connected`,`${ki().runtime} 插件未连接。请先在${ki().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=Ii&&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)}`)}}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],j(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};async function R(){try{let e=await fetch(`http://127.0.0.1:${F}/health`,{signal:AbortSignal.timeout(800)});if(!e.ok)return null;let t=await e.json();return t.name&&t.version?{name:t.name,version:t.version,...typeof t.startedAt==`number`?{startedAt:t.startedAt}:{}}:null}catch{return null}}var Ri=!1;async function zi(){if(Ri)return;Ri=!0;let e=process.argv[1];if(!e)return;let t;try{t=a(e).mtimeMs}catch{return}let n=await R();n?.startedAt==null||n.startedAt>=t||N(`常驻 daemon 跑在旧构建上(daemon 启动 ${new Date(n.startedAt).toISOString()} < 产物 ${new Date(t).toISOString()}),本次代码改动未生效。收掉它:curl -X POST http://127.0.0.1:${F}/shutdown,再重新拉起`)}async function Bi(){let e=await R();if(e&&e.version!==I){j(`检测到旧版 daemon (${e.version} → ${I}),正在替换...`),await fetch(`http://127.0.0.1:${F}/shutdown`,{method:`POST`}).catch(()=>{});let t=Date.now()+vi;for(;Date.now()<t&&(await Vi(250),await R()!==null););return await R()===null?{state:`none`}:(j(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new re({name:`text-to-design-proxy`,version:I},{versionNegotiation:{mode:`auto`}});try{await t.connect(new ie(new URL(`http://127.0.0.1:${F}/mcp`)));let{tools:e}=await t.listTools();return e.length===0||!e.every(e=>e.name.startsWith(`jsd_`))?(await t.close(),{state:`foreign`}):{state:`proxy`,client:t}}catch{return await t.close().catch(()=>{}),await R()===null?{state:`none`}:{state:`starting`}}}function Vi(e){return new Promise(t=>setTimeout(t,e))}var Hi=3,Ui=4,Wi=240,Gi=16,Ki=8;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qi(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 Ji(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 Yi(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>=Ui))break}return n}function Xi(e,t,n){if(!z(e))return{};if(typeof e.$ref==`string`){if(t>Ki)return{};let r=qi(e.$ref,n.defs);return r===void 0?{}:Xi(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>Wi?`${t.slice(0,Wi)}…`:t)}let i=Ji(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]=Yi(a.map(e=>Xi(e,t,n))))}let a=t>=Hi&&z(e.properties);if(z(e.items)&&(r.items=a?{}:Xi(e.items,t+1,n)),z(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,Gi),o={};for(let r of a)o[r]=Xi(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 Zi(e){if(!z(e))return e;let t=Xi(e,0,{defs:z(e.$defs)?e.$defs:{}});return z(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function Qi(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 $i(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=Qi(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function ea(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 ta(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 na(e){let t=le(e)[`~standard`],n=$i(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=ta(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${ea(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function ra(e){let t=de(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 ia=1500,aa=2e4,oa=6e4,sa=6e5,ca=5e5,la=5e3;function ua(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>ca?[`合计 ${(t/1024).toFixed(0)} KB > ${ca/1024} KB`]:[],...e.filter(e=>e.outputBytes>la).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&N(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function da(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 fa(e){let t={};for(let n of e??[]){let e=m.string().describe(n.description??``);t[n.name]=n.required===!0?e:e.optional()}return m.object(t)}async function pa(e){let t=e,n=!1,r=null,i=new ae({name:hi,version:I},{supportedProtocolVersions:[`2026-07-28`,...se],...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||!da(r))throw r;return N(`shim: 上游请求失败,触发重连后重放`),await ee(),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?Zi(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:na(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:le(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)}`)}}ua(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:fa(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 oe(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)}`)},ee=()=>r||(r=(async()=>{let e=Date.now()+aa,n=null;for(;Date.now()<e;){try{let e=await Bi();if(e.state===`proxy`){t=e.client,m(t),j(`shim: 上游已恢复`),await p();return}e.state===`none`&&ra()}catch(e){n=e}await Vi(ia)}throw n??Error(`上游重连超时(${aa}ms)`)})().finally(()=>{r=null}),r),m=e=>{e.onclose=()=>{n||(N(`shim: 上游断开,自动重连`),ee().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(()=>{})})};m(t);let te=ue(async()=>(await p(),i)),h=I,ne=null,re=null,ie=async()=>{let e=await R();e!=null&&e.version!==h&&(j(`上游版本变化(${h} → ${e.version}),全量重同步目录`),h=e.version,await p())},ce=()=>{n||(ne=setTimeout(()=>{n||ie().finally(ce)},oa),ne.unref())},de=()=>{n||(re=setTimeout(()=>{n||p().finally(de)},sa),re.unref())};ce(),de(),j(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,ne&&clearTimeout(ne),re&&clearTimeout(re),await te.close().catch(e=>{N(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}function ma(e=process.env.TEXT_TO_DESIGN_LANG){return Xr(e)??`zh-CN`}function ha(e=ma()){return{locale:e,t:qr(e)}}function B(e){throw Error(e)}var ga=50;async function _a(e){let t=e.trim();t===``&&B(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),u(t)||B(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await _e(t).catch(e=>{B(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||B(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>wi&&B(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(wi/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await ge(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>ga&&B(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${ga} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=gt.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);B(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return j(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function va(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 ya(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=va(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function ba(e,t){ee.globalRegistry.add(e,{description:t})}function xa(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 Sa(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=va(i);if(a!=null)for(let e of xa(a))r(e)};r(e)}function Ca(e,t){return Sa(e,e=>{let n=ya(e);if(n==null)return;let r=t(n);r!==n&&ba(e,r)}),e}function wa(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function Ta(e){return e._def?.typeName}function Ea(e,t){return e._def?.[t]}function Da(e,t){return e._def?.[t]}function V(e){switch(Ta(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 Da(e,`value`);case`ZodEnum`:return Da(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=Ea(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=Ea(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=Da(e,`options`)??[],n=t.find(e=>Ta(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 Oa={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function ka(e,t,n){let r=Oa[xe(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 Aa(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...wa(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??[],...wa(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var ja=new Map;function Ma(e){return ja.get(e)}function Na(){return[...ja.keys()].sort()}var Pa=8,Fa=20;function Ia(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function La(e,t,n){let r=Ia(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,Pa).join(`, `)}]${o.length>Pa?` 等 ${o.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${r.length<=Fa?`该工具接受: [${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=async(t,r,i)=>{try{let o=Ni(e);if(o!=null)return P(`工具 ${e.name} 在当前平台不可用,已拦截`),ka(new g(`platform_unsupported`,o),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 g(`invalid_args`,`参数校验失败(${e.name}): ${La(e.inputSchema,t,r)}`)}t=n.data}let s={...r==null?{}:{signal:r},...e.timeout==null?{}:{timeout:e.timeout}},c=i?.skipHooks===!0?void 0:e.hook?.();if(c?.before!=null)try{await c.before(t)}catch(t){N(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let l;l=e.run?await e.run(t,n,r??new AbortController().signal):await n.request(e.method,e.payload?e.payload(t):t,s);let u=e.extraContent?e.extraContent(l,t):[],d=[];if(c?.after!=null)try{let e=await c.after(t,l)??[];for(let t of e)d.push(t),u.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;d.push(n),u.push({type:`text`,text:n})}let f=Aa(l,e.outputSchema,u.length>0?u:void 0,a(e.followUp));return d.length>0?{...f,warnings:d}:f}catch(t){let n=t instanceof Error?t.message:String(t);return P(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`),ka(t,e.outputSchema,a(e.followUp))}};ja.set(e.name,o);let{t:s}=r,c=i(e.name,{title:s(e.title),description:e.platformNote==null?s(e.description):`${s(e.description)}${s(e.platformNote)}`,...e.inputSchema?{inputSchema:Ca(e.inputSchema,s)}:{},outputSchema:Ca(e.outputSchema,s),annotations:e.annotations},async(...t)=>{let n=e.inputSchema!=null,r=t[0],i=t[1],a=n?r??{}:{},s=n?i:r,c=s?.mcpReq?.signal??s?.signal;return o(a,c)});return c.alwaysEnabled=e.alwaysEnabled??!1,c}}function Ra(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 za=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}};function Ba(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 za(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=Ra(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var Va=/^@(comp|var):([\s\S]+)$/;function Ha(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 Ua(e,t,n){let r=await n();return Ha(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var Wa=/\{\{\s*([^{}]+?)\s*\}\}/g,Ga=/^\{\{\s*([^{}]+?)\s*\}\}$/,Ka=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],qa=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),Ja=2e4;function Ya(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var Xa=[`x`,`y`,`width`,`height`,`parentId`];function Za(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:Xa.some(t=>e[t]!==void 0)}function Qa(e){if(Array.isArray(e))return e.map(Qa);if(typeof e!=`object`||!e)return e;let t=e;if(Za(t)){let e={};for(let n of Ka)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))qa.has(e)||(n[e]=Qa(r));return n}function $a(e,t){if(Array.isArray(e)){for(let n of e)$a(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}$a(r,t)}}function eo(e){let t=Qa(e),n=Ya(t);if(n<=Ja)return{data:t,trimmed:n!==Ya(e)};let r=[];return $a(t,r),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${n} 字符,已省略明细;需要细节请把该工具单独调用一次`,ids:[...new Set(r)]},trimmed:!0}}async function to(e,t,n,r){let i=async e=>{let i=Va.exec(e.trim());return i==null?Ba(e,t,r):Ua(i[1],i[2],n)};if(typeof e==`string`){let t=Ga.exec(e.trim());if(t!=null)return i(t[1]);let n=``,r=0;for(let t of e.matchAll(Wa)){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 to(a,t,n,r));return i}if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=await to(o,t,n,r);return i}return e}function no(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:_t,outputSchema:vt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:Ci,run:async(e,t,n)=>{let{calls:r,callsFile:i,stopOnError:a,checkDrift:o}=e,s=i==null||i.trim()===``?null:await _a(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,ee=u===!1,m=[],te,h=()=>(te??=(async()=>(await t.request(`get_page`,{},{...n==null?{}:{signal:n}}))?.assets??{})(),te),ne=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=>{ne.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=Ma(t.tool);if(a==null){i(`未知工具 ${t.tool},可用: ${Na().join(`, `)}`);break}let o;try{o=await to(t.args??{},d,h,ne)}catch(e){if(i(e instanceof Error?e.message:String(e)),e instanceof za&&(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=eo(s.structuredContent);u.trimmed&&(p=!0),d.set(r,s.structuredContent),s.warnings!=null&&m.push(...s.warnings),f.push({id:r,tool:t.tool,ok:!0,data:u.data})}let re=f.length===c.length,ie=m;return{ok:re&&f.every(e=>e.ok),executed:f.length,total:c.length,results:f,...p?{echoTrimmed:!0}:{},...ie.length>0?{warnings:ie}:{}}}})(e,t,n)]}function ro(e){return e==null?y:[e]}function U(e){return b[e]}function io(e,t){return A(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function ao(e,t){let n=e=>{let t=e==null?null:A(e,`variants`)?.setLevelOps;return t==null||t.length===0?``:`造新维度/新取值不用绕实例:本平台有集合级管理入口(${t.join(` / `)})—— 先 mg_list_variant_properties 看现状,再建维度/加成分/改取值,每个 op 都写完回读(各自的行为注意写在它的描述里,调用前读一眼);换绑(jsd_set_instance_properties)只负责切到**已有**成分。`};if(e!=null&&t!=null){let r=A(e,`variants`)?.read,i=r==null?``:`文档里**已有**的变体集不受影响:\`${r}\` 与组件集上的维度取值照常读得到,已有取值照常用 jsd_set_instance_properties 切 —— 缺的只是「用脚本造一个新的」;`,a=t?`${U(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${U(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。${i}替代路径:${io(e,`variants`)}。`,o=n(e);return o===``?a:`${a}${o}`}let r=y.filter(e=>A(e,`variants`)?.fallback!=null),i=y.filter(e=>!r.includes(e));return[`按能力位 ${Qr.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?io(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function oo(e){if(e==null)return ro(null).map(e=>{let t=Je(e,`setProperties`),n=A(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${U(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=A(e,`components`),n=Je(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(能力位 ${Qr.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function so(e){if(e!=null){let t=A(e,`variables`);if(t==null)return`${U(e)}的变量面未登记。`;if(t.write.length>0)return`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。替代路径:${io(e,`variables`)}`}return`${U(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。替代路径:${io(e,`variables`)}`}let t=y.filter(e=>(A(e,`variables`)?.write.length??0)>0),n=y.filter(e=>(A(e,`variables`)?.write.length??0)===0&&(A(e,`variables`)?.nativeUnwired.length??0)>0),r=y.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=A(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${U(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function co(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 lo(e){return e===`mastergo`?["- ⚠ MG **没有**「图层属性 ↔ 变量」的反读接口:回读只能拿到该图层用到的集合与模式(见 `mg_list_variables`),它证明「集合挂上了」、证不了「挂在该属性上」;","- 所以绑数组属性(fills / effects / grids)**必须**自己给 `index`,并 jsd_export({ids:[节点id], scale=0.5}) 目视确认渲染真的变了 —— 这一条别省。"].join(`
|
|
42
42
|
`):e===`figma`?[`- 回读节点上的绑定,比对里面的 variableId 与你要绑的是同一个 —— **回显成功不等于绑上了**;`,`- 涉及视觉的改动再 jsd_export({ids:[节点id], scale=0.5}) 导小图目检一次;`].join(`
|
|
43
|
-
`):`- 回读本平台提供的绑定读面,比对里面的 variableId 与你要绑的是同一个 —— **回显成功不等于绑上了**;`}function
|
|
43
|
+
`):`- 回读本平台提供的绑定读面,比对里面的 variableId 与你要绑的是同一个 —— **回显成功不等于绑上了**;`}function uo(e){return e===`mastergo`?["- MG 的节点上**没有**绑定字段可读:`mg_list_variables` 给出集合 / 模式 / 变量及它们的值,某图层用了哪些集合看 `getLayerVariableModes`;","- 变量 id 取自 `mg_list_variables` 或 `jsd_get_page` 的 `assets.variables`,**可直接回喂**写入口,不用改名、不用补名称。"].join(`
|
|
44
44
|
`):e===`figma`?[`- 读节点上的变量绑定(字段名见上一节):键是引擎的可绑定字段名,值的三态由引擎决定 —— 标量字段是单个别名;fills / strokes / effects / layoutGrids / textRangeFills 是别名数组;componentProperties 是按属性名索引的别名表。**键在 = 至少有一条绑定**(无绑定或平台不提供该字段时整个键省略)。`,"- 库存与模式走 `figma_variables_list`(集合 / 模式 / 各变量的值);读路径就是写侧的 `boundProperty` 词汇,值里的 id **可直接回喂**写入口,不用改名、不用补名称。",`- 引擎口径原样保留:有**独立圆角**的节点上,圆角绑定会表现为 topLeftRadius / topRightRadius / bottomLeftRadius / bottomRightRadius 四条(不归一成 cornerRadius)。`].join(`
|
|
45
45
|
`):[`- 以本平台变量面给出的读路径为准:**键在 = 至少有一条绑定**(平台不提供该字段时整个键省略)。`,`- 值里的 id **可直接回喂**写入口,不用改名、不用补名称。`].join(`
|
|
46
|
-
`)}function
|
|
47
|
-
`):e===`figma`?["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。","- 变体集:切到**已有**取值用 `jsd_set_instance_properties`(取值清单看 `assets.variants[].properties`)。","- 样式:平台 op `figma_style_apply_by_name` 按名应用,或直接写节点字段 `fillStyleId` / `strokeStyleId` / `textStyleId` / `effectStyleId
|
|
48
|
-
`):e===`jsdesign`?["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2
|
|
49
|
-
`):["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。","- 变体集:切到**已有**取值用 `jsd_set_instance_properties`(取值清单看 `assets.variants[].properties`)。","- 样式:节点上的 `*StyleId` 字段引用样式 id,或本平台提供的按名应用入口(清单见 `jsd://platform/state` 的 platformOps)。","- 变量:本平台的变量入口见 `jsd://platform/state` 的 platformOps(`assets.variables` 恒空即本平台没有变量面)。"].join(`
|
|
50
|
-
`)}function
|
|
51
|
-
|
|
52
|
-
`)
|
|
53
|
-
`).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}">${xo(e)}</text>`)});return}let l=eo(i.background??i[`background-color`],e.tag===`img`?Qa:void 0),u=ro(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)vo(n),bo(n,t,a,o)}function xo(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function So(e){let t=ge(e,{decodeEntities:!0}).children.filter(e=>he(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=$a(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=_o(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),yo(r,c,l)}var Co={"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`},wo=e(import.meta.url);function To(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Eo=JSON.parse(r(wo.resolve(`lucide-static/icon-nodes.json`),`utf8`)),Do=JSON.parse(r(wo.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Eo))q.set(e,{name:e,nodes:t,keywords:Do[e]??[]});q.size;var Oo=new Map;for(let[e,t]of Object.entries(Do))t.forEach((t,n)=>{let r=Oo.get(t)??[];r.push({name:e,idx:n}),Oo.set(t,r)});var ko=new _e([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Ao(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function jo(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Co[t];if(r){let e=q.get(r);if(e)return e}let i=To(t),a=ko.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Ao(i,To(e.item.name))>=3});if(a.length)return a[0].item;let o=Oo.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||To(e.name).length-To(t.name).length)[0];return q.get(e.name)??null}let s=ko.search(t,{limit:8}).filter(e=>Ao(i,To(e.item.name))>=2)[0];return s?s.item:null}function Mo(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=Co[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of Oo.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of ko.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function No(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(`
|
|
46
|
+
`)}function fo(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。⚠ 本平台只声明了 `styles`(**按 id 应用**),**没声明 `styleEnumeration`**(列出有哪些样式)—— 四个 `getLocal*Styles` 都在但永不返回(同步调用还会冻死插件线程,见 0043),故 `assets.styles` 与 `jsd://styles` **恒空**:别拿「清单里没有」当「文档里没有」,要复用已有样式就从**正用着它的节点**上读 id(`jsd_find` / `jsd_get_selection` 的 `*StyleId` 字段);确认没有才 `jsd_create_style` 从指定节点抄,并**把回包 id 记账**(这份平台列不出来,丢了找不回;建重复了用 `jsd_delete_style` 按 id 删)。","- 变量:`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(`
|
|
47
|
+
`):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(`
|
|
48
|
+
`):e===`jsdesign`?["- 组件:`jsd_create_instance` 用 `componentId` 铺实例;同类单元 ≥2 个时**先查清单**,别新建重复组件。⚠ 本平台把带 `/` 的组件名拆成「集合 / 成分」—— `assets.components[].name` 是**叶子名**(建 `组/主件` 后清单里叫 `主件`,集合名在 `assets.variants` 上),按名字取组件(`{{@comp:…}}`)时一律照清单里的原样写。","- 变体集:切到**已有**取值用 `jsd_set_instance_properties`(取值清单看 `assets.variants[].properties`)。","- 样式:节点字段 `fillStyleId` / `strokeStyleId` / `textStyleId` / `effectStyleId` 直接引用样式 id(清单见 `assets.styles` 或 `jsd://styles`);**清单里没有就建一条** —— `jsd_create_style` 从指定节点抄。","- 变量:本平台没有变量面(`assets.variables` 恒空),别去找变量入口;统一色板走上一条的样式路。"].join(`
|
|
49
|
+
`):["- 组件:`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(`
|
|
50
|
+
`)}function po(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`)。"]:[];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(`
|
|
51
|
+
`):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(`
|
|
52
|
+
`):e===`jsdesign`?["- **jsDesign:只有样式一层** —— typings 全文没有任何 variable 声明(`grep -in variable` 零命中),这是**平台没有这个面**,不是「本仓还没接」。⇒ 变量能做的「一个语义 token 随模式/主题变」在这里没有对应物:色板、间距、排版一律落**样式**;深浅两套主题只能建成两套样式族按名字批量重刷(`jsd_find` 定位 → `jsd_batch` 改写),或抽成两个组件族 —— 别去试变量 op(daemon 拦成 `platform_unsupported`,白跑一趟往返)。","- **组件属性只收字符串**:`setProperties` 的签名只有 `string`(布尔 / 换绑 / 文本属性的值形态一概不收)⇒ 状态差异不要押在组件属性上,走「族名 / 状态」命名的多主件;另:给**没有变体属性的实例**调 `jsd_set_instance_properties` 不是报错,是挂到 25s 转发超时(真机 2026-10-14)。","- ⚠ 契约的样式类别是三家 `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` 清)。已有的变体集照样能读、能切取值,缺的只是「用脚本新建一个」。",...r,...n].join(`
|
|
53
|
+
`):["- **三平台的连线方式不同,先探平台再选路**(`jsd_ping` 的 capabilities / `jsd://platform/state`):Figma 是「变量 → 样式 → 节点」三层链,三端都有入口(样式档的绑定靠 `figma_style_variables_list` 才看得见);MasterGo 把样式塌进变量(八项复合样式类型,且与样式共用一套 id 空间、类别词汇逐字重名);即时设计只有样式一层(typings 里没有任何变量声明)。照搬别家做法的典型症状:去找本平台没有的入口,或在另一份清单里找已经建好的那一条。",...t==null?["- 样式能不能列清单同样按能力位判(`styleEnumeration`):未声明的平台上 `assets.styles` 恒空 —— **别把「列不出来」当「文档里没有」**,已有样式的 id 从节点上的 `*StyleId` 读。"]:[],...n].join(`
|
|
54
|
+
`)}function mo(e){if(e==null){let e=y.filter(e=>A(e,`components`)?.read!=null),t=y.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(U).join(` / `)} 读得到;`,`${t.map(U).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return A(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function ho(e){return["排布有两条路,都可用:① **自动布局** —— `layoutMode=HORIZONTAL|VERTICAL` 配 ","`itemSpacing/padding*/primary|counterAxisSizingMode|primary|counterAxisAlignItems`","(节奏按上一条:归组摆好后用 jsd_set_layout);② **栅格参考线** —— `layoutGrids`(仅 "+Ae.layoutGrids.join(` / `)+`)。`,`两者互斥:引擎只在**非自动布局**的容器上收网格。`,ro(e).map(e=>Le.includes(e)?`${U(e)}:\`layoutGrids\` 实测不收(节点级网格不落盘)—— 别重试,要栅格请在设计器里手动加`:`${U(e)}:\`layoutGrids\` 可写,写后走双读回读校验,没生效会在结果 warnings 里点名`).join(`;`)].join(``)}function W(e,t){return{method:`component_op`,outputSchema:Cn,payload:t=>({op:e,...t}),...t}}function go(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Yn,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:Xn,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:Zn,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:Qn,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:$n,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 双向断言守):${oo(null)}`,inputSchema:er,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 节点,实例不能直接合成。${ao(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:tr,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:ir,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:or,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:sr,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 _o=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),vo={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},yo=`#f3f4f6`;function bo(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 xo(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:vo[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function So(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 Co(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 wo(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:xo(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:xo(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function To(e){return G(e[`font-size`])??16}function Eo(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function Do(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Oo(e){return(e.display??``).includes(`flex`)}function ko(e){return e[`flex-direction`]===`row`?`row`:`column`}function Ao(e){return G(e.gap)??G(e[`row-gap`])??0}function jo(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function Mo(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function No(e){return e.type===`text`?e.data:ve(e)?e.tagName===`br`?`
|
|
55
|
+
`:e.children.map(No).join(``):``}function Po(e){return e.replace(/\s+/g,` `).trim()}function Fo(e,t){let n=bo(e.attribs.style),r={tag:e.tagName,style:n,children:[],isText:!1,x:0,y:0,w:0,h:0};if(e.tagName===`img`)return r.w=K(n,`width`)??120,r.h=K(n,`height`)??120,r;for(let t of e.children){if(t.type===`text`){let e=Po(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:Io(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}ve(t)&&(_o.has(t.tagName)||t.tagName!==`br`&&r.children.push(Fo(t,!1)))}if(t&&r.children.length===0){let t=Po(e.children.map(No).join(``));t&&r.children.push({tag:`#text`,text:t,style:Io(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function Io(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 Lo(e,t){let n=e.style,r=Co(n),i=So(n),a=wo(n),o=Math.max(0,t-r.left-r.right-a.width*2);if(e.tag===`img`)return e.w=K(n,`width`)??120,e.h=K(n,`height`)??120,{width:e.w+i.left+i.right,height:e.h+i.top+i.bottom};let s=o,c=0;if(e.isText){let t=To(n),r=(e.text??``).split(`
|
|
56
|
+
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>Mo(e,t)),t)),e.h=r.length*Do(n,t),c=e.h}else{let t=Oo(n),i=ko(n),o=Ao(n),l=K(n,`width`),u=K(n,`height`);if(l!=null&&(s=Math.max(0,l-r.left-r.right-a.width*2)),t&&i===`row`){let t=0,n=0;for(let i of e.children){let e=Lo(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&jo(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=Lo(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&jo(i.style)!==`left`&&(i.w=s),t+=e.height,t+=o,n=Math.max(n,e.width)}c=t-(e.children.length?o:0),e.w=n}e.w=l??e.w,e.h=u??c,c=u??c}let l=r.left+r.right+a.width*2,u=r.top+r.bottom+a.width*2;return K(n,`width`)??(e.w+=l),K(n,`height`)==null&&!e.isText&&(e.h+=u),{width:e.w+i.left+i.right,height:e.h+i.top+i.bottom}}function Ro(e){let t=So(e.style);e.x+=t.left,e.y+=t.top}function zo(e,t,n){let r=[];return Bo(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 Bo(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=To(i),r=xo(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=Eo(i),u=jo(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=Do(i,n);(e.text??``).split(`
|
|
57
|
+
`).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}">${Vo(e)}</text>`)});return}let l=xo(i.background??i[`background-color`],e.tag===`img`?yo:void 0),u=wo(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)Ro(n),Bo(n,t,a,o)}function Vo(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Ho(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=Fo(n,!0),i=bo(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=Lo(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),zo(r,c,l)}var Uo={"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`},Wo=e(import.meta.url);function Go(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Ko=JSON.parse(r(Wo.resolve(`lucide-static/icon-nodes.json`),`utf8`)),qo=JSON.parse(r(Wo.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Ko))q.set(e,{name:e,nodes:t,keywords:qo[e]??[]});q.size;var Jo=new Map;for(let[e,t]of Object.entries(qo))t.forEach((t,n)=>{let r=Jo.get(t)??[];r.push({name:e,idx:n}),Jo.set(t,r)});var Yo=new be([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Xo(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Zo(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Uo[t];if(r){let e=q.get(r);if(e)return e}let i=Go(t),a=Yo.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Xo(i,Go(e.item.name))>=3});if(a.length)return a[0].item;let o=Jo.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||Go(e.name).length-Go(t.name).length)[0];return q.get(e.name)??null}let s=Yo.search(t,{limit:8}).filter(e=>Xo(i,Go(e.item.name))>=2)[0];return s?s.item:null}function Qo(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=Uo[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of Jo.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Yo.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function $o(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(`
|
|
54
58
|
`);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(`
|
|
55
|
-
`)}var Po={FRAME:wt,RECTANGLE:Tt,ELLIPSE:Et,LINE:Dt,POLYGON:Ot,STAR:kt,VECTOR:At,TEXT:jt,GROUP:Mt,BOOLEAN_OPERATION:Nt};function Fo(e){let t={...Po[e].shape,type:m.literal(e).optional()};return m.object({...t,placement:Ft.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:Fo(e),outputSchema:ln,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 Io(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:je}),followUp:Y})],a=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:It,outputSchema:ln,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:ui,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>mi)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${mi}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:o??`svg-design`},{signal:n,timeout:ui})},followUp:Y}),o=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Rt,outputSchema:ln,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=jo(r);if(!c){let e=Mo(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=No(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:Lt,outputSchema:ln,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=So(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 Lo=`(page)`,Ro=8,zo=200,Bo=5,Vo=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function Ho(e){let t=e.op;return typeof t==`string`&&Vo.has(t)}function Uo(e){return e.op===`reparent`}function Wo(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 Go(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function Ko(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 qo(e,t){let n=ya(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 Jo(e){let t=new Map;if(e===Lo){let e=await qo(`jsd_get_page`,{});if(e==null)return null;for(let n of Go(e.nodes).slice(0,zo)){let e=Ko(n);e!=null&&t.set(e.id,e)}return t}let n=await qo(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=Go(n.nodes)[0];if(r==null)return null;for(let e of Go(r.children).slice(0,zo)){let n=Ko(e);n!=null&&t.set(n.id,n)}return t}var Yo=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(e.op===void 0||Ho(e)){this.engaged=!0;try{let t=new Set;if(Wo(e,t),t.size===0)return;let n=await qo(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of Go(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}Uo(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(Lo);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=Ro){this.dead.add(e);continue}let t=await Jo(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 Jo(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,Bo).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>Bo?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===Lo?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},Xo=()=>new Yo;function Zo(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:en,outputSchema:mn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:Xo,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:tn,outputSchema:_n,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 Qo(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:Qt,outputSchema:pn,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:mn,payload:t=>({op:e,...t}),...Vo.has(e)?{tags:[`structural`],hook:Xo}:{},...t}}function $o(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:Mn,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:Nn,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:Pn,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:Fn,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:In,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:Ln,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:Rn,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:zn,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:Bn,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 es(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`],platformNote:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${qa(null)}${Va(null)}。变量面:${Ha(null)})`,method:`platform_op`,inputSchema:sn,outputSchema:pt,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function ts(e,t){return[e.registerPrompt(`html-to-design`,{title:t.t(`prompt.htmlToDesign.title`),description:t.t(`prompt.htmlToDesign.description`),argsSchema:m.object({html:m.string().describe(`要转换的 HTML 片段`),name:m.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:rs(String(e),t==null?void 0:String(t))}}]})),e.registerPrompt(`icon-grid`,{title:t.t(`prompt.iconGrid.title`),description:t.t(`prompt.iconGrid.description`),argsSchema:m.object({icons:m.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:m.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:m.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:is(String(e),Number(t)||24,Number(n)||16)}}]})),e.registerPrompt(`script-ops`,{title:t.t(`prompt.scriptOps.title`),description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:m.object({task:m.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:as(e==null?void 0:String(e))}}]})),e.registerPrompt(`design-strategy`,{title:t.t(`prompt.designStrategy.title`),description:`画布创作的通用纪律:先摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:m.object({screen:m.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:os(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`text-replace-strategy`,{title:t.t(`prompt.textReplace.title`),description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:m.object({rootId:m.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:ss(e==null?void 0:String(e))}}]})),e.registerPrompt(`variant-sync`,{title:t.t(`prompt.variantSync.title`),description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:m.object({sourceId:m.string().optional().describe(`源实例 id;留空取当前选中`),targetType:m.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:cs(e==null?void 0:String(e),t==null?void 0:String(t))}}]})),e.registerPrompt(`variable-binding`,{title:t.t(`prompt.variableBinding.title`),description:`变量绑定与批量套用:先看本平台有没有变量能力面,再读绑定、建变量、批量绑定;没有变量面的平台给替代路径`,argsSchema:m.object({target:m.string().optional().describe(`要绑定的节点或范围描述;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:ls(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`variant-set`,{title:t.t(`prompt.variantSet.title`),description:`变体集构建:按能力位 inPlaceVariants 分流(原位合并 / 多主件兜底),含命名与建后回读复核`,argsSchema:m.object({family:m.string().optional().describe(`组件族名,如 Nav;留空只返回做法与分流`)})},({family:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:us(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`component-property`,{title:t.t(`prompt.componentProperty.title`),description:`组件属性的定义与设值:定义走平台 op、设值走 jsd_set_instance_properties,并按当前平台给出能收的值形态`,argsSchema:m.object({target:m.string().optional().describe(`组件或实例 id;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:ds(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`chart-by-code`,{title:t.t(`prompt.chartByCode.title`),description:t.t(`prompt.chartByCode.description`),argsSchema:m.object({chart:m.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」「各地区销售额占比环形图」「日活趋势面积图」`),svgPath:m.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)})},({chart:e,svgPath:t})=>({messages:[{role:`user`,content:{type:`text`,text:ps(String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function Z(){return _i()?.platform??null}function ns(e){return _i()?.capabilities.includes(e)===!0}function rs(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 is(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 as(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
|
|
59
|
+
`)}var es={FRAME:At,RECTANGLE:jt,ELLIPSE:Mt,LINE:Nt,POLYGON:Pt,STAR:Ft,VECTOR:It,TEXT:Lt,GROUP:Rt,BOOLEAN_OPERATION:zt};function ts(e){let t={...es[e].shape,type:m.literal(e).optional()};return m.object({...t,placement:Vt.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:ts(e),outputSchema:hn,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 ns(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:Ze}),followUp:Y})],a=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:Ht,outputSchema:hn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:bi,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>Ti)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${Ti}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:o??`svg-design`},{signal:n,timeout:bi})},followUp:Y}),o=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Wt,outputSchema:hn,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=Zo(r);if(!c){let e=Qo(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=$o(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:Ut,outputSchema:hn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=Ho(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 rs=`(page)`,is=8,as=200,os=5,ss=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function cs(e){let t=e.op;return typeof t==`string`&&ss.has(t)}function ls(e){return e.op===`reparent`}function us(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 ds(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function fs(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 ps(e,t){let n=Ma(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 ms(e){let t=new Map;if(e===rs){let e=await ps(`jsd_get_page`,{});if(e==null)return null;for(let n of ds(e.nodes).slice(0,as)){let e=fs(n);e!=null&&t.set(e.id,e)}return t}let n=await ps(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=ds(n.nodes)[0];if(r==null)return null;for(let e of ds(r.children).slice(0,as)){let n=fs(e);n!=null&&t.set(n.id,n)}return t}var hs=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(e.op===void 0||cs(e)){this.engaged=!0;try{let t=new Set;if(us(e,t),t.size===0)return;let n=await ps(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of ds(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}ls(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(rs);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=is){this.dead.add(e);continue}let t=await ms(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 ms(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,os).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>os?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===rs?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},gs=()=>new hs;function _s(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:cn,outputSchema:bn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:gs,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:ln,outputSchema:Cn,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 vs(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:on,outputSchema:yn,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:bn,payload:t=>({op:e,...t}),...ss.has(e)?{tags:[`structural`],hook:gs}:{},...t}}function ys(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:Bn,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:Vn,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:Hn,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:Un,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:Wn,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:Gn,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:Kn,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:qn,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:Jn,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 bs(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`],platformNote:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${mo(null)}${oo(null)}。变量面:${so(null)})`,method:`platform_op`,inputSchema:mn,outputSchema:yt,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function xs(e,t){return[e.registerPrompt(`html-to-design`,{title:t.t(`prompt.htmlToDesign.title`),description:t.t(`prompt.htmlToDesign.description`),argsSchema:m.object({html:m.string().describe(`要转换的 HTML 片段`),name:m.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:ws(String(e),t==null?void 0:String(t))}}]})),e.registerPrompt(`icon-grid`,{title:t.t(`prompt.iconGrid.title`),description:t.t(`prompt.iconGrid.description`),argsSchema:m.object({icons:m.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:m.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:m.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:Ts(String(e),Number(t)||24,Number(n)||16)}}]})),e.registerPrompt(`script-ops`,{title:t.t(`prompt.scriptOps.title`),description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:m.object({task:m.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:Es(e==null?void 0:String(e))}}]})),e.registerPrompt(`design-strategy`,{title:t.t(`prompt.designStrategy.title`),description:`画布创作的通用纪律:先查可复用件(组件/变体/样式/变量怎么选、怎么复用)、再摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:m.object({screen:m.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ds(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`text-replace-strategy`,{title:t.t(`prompt.textReplace.title`),description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:m.object({rootId:m.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Os(e==null?void 0:String(e))}}]})),e.registerPrompt(`variant-sync`,{title:t.t(`prompt.variantSync.title`),description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:m.object({sourceId:m.string().optional().describe(`源实例 id;留空取当前选中`),targetType:m.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:ks(e==null?void 0:String(e),t==null?void 0:String(t))}}]})),e.registerPrompt(`variable-binding`,{title:t.t(`prompt.variableBinding.title`),description:`变量绑定与批量套用:先看本平台有没有变量能力面,再读绑定、建变量、批量绑定;没有变量面的平台给替代路径`,argsSchema:m.object({target:m.string().optional().describe(`要绑定的节点或范围描述;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:As(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`variant-set`,{title:t.t(`prompt.variantSet.title`),description:`变体集构建:按能力位 inPlaceVariants 分流(原位合并 / 多主件兜底),含命名与建后回读复核`,argsSchema:m.object({family:m.string().optional().describe(`组件族名,如 Nav;留空只返回做法与分流`)})},({family:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:js(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`component-property`,{title:t.t(`prompt.componentProperty.title`),description:`组件属性的定义与设值:定义走平台 op、设值走 jsd_set_instance_properties,并按当前平台给出能收的值形态`,argsSchema:m.object({target:m.string().optional().describe(`组件或实例 id;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ms(e==null?void 0:String(e),Z())}}]})),e.registerPrompt(`chart-by-code`,{title:t.t(`prompt.chartByCode.title`),description:t.t(`prompt.chartByCode.description`),argsSchema:m.object({chart:m.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」「各地区销售额占比环形图」「日活趋势面积图」`),svgPath:m.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)})},({chart:e,svgPath:t})=>({messages:[{role:`user`,content:{type:`text`,text:Ps(String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function Z(){return Oi()?.platform??null}function Ss(e,t){return e.split(`
|
|
60
|
+
`).map(e=>e===``?e:t+e).join(`
|
|
61
|
+
`)}function Cs(e){return Oi()?.capabilities.includes(e)===!0}function ws(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 Ts(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 Es(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
|
|
56
62
|
1) 多步流程一次成型:优先 jsd_batch 编排(create→reparent→update、find→批量修改、图标×N 等);宿主有代码执行工具时也可写一段脚本连续 await 多个 tools.jsd_*。
|
|
57
63
|
2) 中间值只在管道内流动:上游结果用双花括号占位符(步骤id.字段路径)注入下游参数(脚本内用变量传递);每步只提取后续需要的字段,不回传完整序列化结果。**占位符只在同一次调用的本批次内有效** —— 跨批次引用会报「占位符引用的步骤不存在或未成功」并中止整批,跨批次请硬编码上一步回显里的真实 id。
|
|
58
|
-
3) 收敛:最后只做一次 jsd_get_selection(depth=1)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
3) 收敛:最后只做一次 jsd_get_selection(depth=1) 总复核,不要每步都复核。
|
|
65
|
+
|
|
66
|
+
## 整页/整档批量改造(同一套纪律的更重场合)
|
|
67
|
+
|
|
68
|
+
适用:一次要改的节点上百、参数体自己都写不下(整页铺 token、整档换样式、批量套组件)。只改几个节点时直接单工具调用更省。
|
|
69
|
+
|
|
70
|
+
4) **先摸底,再动手**。jsd_get_page 读 assets(组件/变体/样式/变量)与顶层节点;再**按「块」**(每屏 / 每板)分别 jsd_find(depth 2~3)把要改的树读回来。整档一次读完会超回包上限、结果落盘 —— 落盘后用脚本做结构化分析(分组、去重、统计形态),不要把整棵树塞进上下文。
|
|
71
|
+
|
|
72
|
+
5) **定策略前先确认「现状形态」**。例:批量绑色前先确认目标节点是不是「单个 SOLID 填充」——有渐变或多色的节点,一次绑整组会把该节点上别的 paint 一起改掉。这一步跳过,失败会以「回显成功但渲染变了」的形式出现(见结果 warnings 一节)。
|
|
73
|
+
|
|
74
|
+
6) **id 的三种来源,优先级从高到低**:本批步骤结果 {{步骤id.字段路径}};文档已有资源 {{@comp:名称}} / {{@var:名称}}(读一次 jsd_get_page 的资源清单,同批共用);兜底才硬编码上一批回显里的真实 id。名字零命中/多命中一律点名中止 —— 那是设计,不是可以「取最近的一个」的警告。
|
|
75
|
+
|
|
76
|
+
7) **按块切批**,不要一次排到 50 步上限:每屏一段既换来回显清晰,也换到失败隔离(某屏失败不连坐其余)。
|
|
77
|
+
|
|
78
|
+
8) **回读复核要单独调一次 jsd_find**。batch 回显会把节点裁到 id/name/type/几何,在批内看回显复核会被裁剪骗到;要确认 boundVariables 或 *StyleId 是否真落上,只能单独读一次。
|
|
79
|
+
|
|
80
|
+
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 本仓内部模块 —— 那是内部传输契约,不是给调用方用的接口。
|
|
81
|
+
|
|
82
|
+
10) **点名类错误不要重试**:字段不可绑 / 名字不唯一 / 平台签名不收 / 引用的步骤不存在,都是策略问题,重试只会同样失败。只有连接类抖动才值得重试。`}function Ds(e,t){let n=e==null?`当前设计`:`「${e}」`,r=ao(t,t==null?null:Cs(Qr.variants)),i=fo(t),a=po(t,t==null?null:Oi()?.capabilities.includes(`styleEnumeration`)===!0),o=ho(t);return`# 画布创作纪律
|
|
83
|
+
|
|
84
|
+
0) **先查可复用件,再动手**(设计类任务的第一步,别跳)。\`jsd_get_page\`(等价资源 \`jsd://page\`)给的是**设计系统资源清单** —— 看 \`assets.summary\` 一眼判断这文档有没有现成的件,再按类取 id 复用;样式另有一份清单 \`jsd://styles\`(\`styleEnumeration\` 未声明的平台上它与 \`assets.styles\` 一样恒空,见下面「看不到」那条)。这一条里只有两件事:**选对件类** 与 **走对入口**。
|
|
85
|
+
- **先判「要复用的是什么」,再选件类** —— 件类拿错,后面的动作全白做:
|
|
86
|
+
- **整个结构**(按钮 / 卡片 / 列表项 / 图标底)→ **组件**。
|
|
87
|
+
- **同一结构的几种状态**(默认 / 悬停 / 禁用 / 尺寸)→ **变体**:先看 \`assets.variants[].properties\` 有没有现成取值,有就切过去,没有才造(**造不造得出先看下面「多状态」那条** —— 平台未声明 inPlaceVariants 时根本没有变体集这条路)。
|
|
88
|
+
- **一组固定视觉**(色 / 字号字重 / 阴影效果)→ **样式**。
|
|
89
|
+
- **一个语义 token**(主色 / 间距 / 圆角,且要随模式或主题变)→ **变量**;本平台没有变量面就退回上一条的样式。
|
|
90
|
+
- 复用入口(按当前平台):
|
|
91
|
+
${Ss(i,` `)}
|
|
92
|
+
- **它们之间怎么连(三平台的接法完全不同,别照搬别家)**:
|
|
93
|
+
${Ss(a,` `)}
|
|
94
|
+
- **命中就复用,禁止新建重复件**:同名/同用途的组件、已有的变体取值、已有的颜色/文字/效果样式、已有的变量,一律先用现成的;清单里确实没有才新建,并按「组件族/状态」命名 —— 命名是它下一次能被命中的唯一依据。反向也一样别做过头:只出现一次的结构不必提组件(提了也没有第二次可复用),一次性装饰不必建样式。
|
|
95
|
+
- **清单是空的,先分清两种「看不到」** —— 判错就会白建一堆重复件:① **本平台读不出来**:样式与变量是能力门控面,平台未声明时 \`assets.styles\` / \`assets.variables\` **恒空**,回包 note 会点名「恒空:本平台未声明对应能力,这一面清单读不出来(不等于文档里没有)」;组件/变体集则可能因某页枚举失败而不全,note 里点名的是具体页名。别拿「看不到」当「没有」 —— 先用 \`jsd_find\` 按名字/类型再确认一遍;名字寻址(\`{{@comp:…}}\` / \`{{@var:…}}\`)读的是同一份清单,同样会不命中。② **确实没有** → 按下面从零建。
|
|
96
|
+
- **从零建的落点顺序:先做样板 → 抄成件 → 再铺开**,别先铺十个同样的再回头提炼(那时每个都要改一遍):
|
|
97
|
+
- 第一个单元做出来就立刻定型:**视觉类** \`jsd_create_style\` 从该节点抄出 PAINT / TEXT / EFFECT / GRID,后续节点直接引用 \`*StyleId\`;**语义 token** 用本平台的建变量 op(名单见 platformOps),没有变量面的平台就落在样式上;**结构类**是否 \`jsd_create_component\` 提组件,按下一条的判据来 —— 不该抽的别抽。
|
|
98
|
+
- 抽不抽的一句话判据:**结构完全一致 + 差异能收敛到变体属性 / 文本属性** → 抽,其余同类一律 \`jsd_create_instance\` 铺;**差异落在子节点上、或状态要靠多主件扛** → 不抽(理由见下面「复用不是无条件」那三条)。多状态:能合成变体集就合成,不能就多主件按「族 / 状态」命名。
|
|
99
|
+
- **命名是它下一次能被命中的唯一依据**:按「族 / 状态」命名,不留「矩形 1」。
|
|
100
|
+
- **建完回读**:再取一次资源清单,确认它真的进了 \`assets\`(看 \`summary\` 计数或名字)—— 没出现等于没建,下一次调用照样命中不了。⚠ 例外:**未声明 \`styleEnumeration\` 的平台(即时设计)连样式都列不出来**,建完在清单里永远看不到 —— 那就把 \`jsd_create_style\` 回包的 id **记账**(节点上的 \`*StyleId\` 也读得到),别指望回读清单。
|
|
101
|
+
- **别拿 \`jsd_clone_node\` 当复用**:复制出来的是与主件脱钩的副本,改主件它不动。要「同结构多份」就铺实例。
|
|
102
|
+
- **「复用」不是无条件的 —— 这三类件不抽组件**,抽了比不抽更难改:
|
|
103
|
+
- **差异落在实例子节点上**的同类件(会话项的头像色 / 名字 / 预览 / 未读数、气泡的文案 / 宽度):实例子节点的样式覆盖**不保证渲染生效**,命中时引擎只回 warnings 让你去改主组件(见第 10 条)。内容各不相同的件抽成组件,等于把所有差异押在不保证生效的覆盖上 —— 主组件全继承不可能(内容各不相同),到处覆盖又不生效,抽完更难改。
|
|
104
|
+
- **状态变体在没声明 inPlaceVariants 的平台上**(即时设计,以 ping 能力位为准):变体集做不出来,只能退化成多主件按「族名 / 状态」命名(标签 / 选中、标签 / 默认)—— 而**多主件不省事**,改一处要改 N 个主件。只有视觉差异的状态,优先用样式或填充差异表达,别克隆出一整套多主件。也别指望 \`jsd_set_instance_properties\` 在没有变体集的实例上「切状态」—— 真机(即时设计 2026-10-14):给无变体属性的实例设属性**不报错,直接挂到 25s 转发超时**。另:合成失败**不是无副作用**,画布会留下畸形集合与布尔运算残骸,按名字 \`jsd_find\` 出来用 \`jsd_repair_nodes\` 清(\`jsd_delete_node\` 对它们报「没有要删除的节点」)。
|
|
105
|
+
- **往返预算压不住时**:组件化的顺序与「一次 batch 成型」**相反**(先建主件 → 铺实例 → 再逐个回写实例差异),且占位符 \`{{步骤id.字段路径}}\` **只在本批次内有效** —— 差异写在实例子节点上时,子节点 id 要等铺完才知道,必然跨批,跨批就得把真实 id 硬编码记账,往返数翻倍。**一次性 / 低复用预期的画面选少往返是正当的**,别为了纪律把简单画面做成三趟往返。
|
|
106
|
+
- **不抽组件,可维护性靠这三样补**(别裸奔):① **视觉统一走样式** —— 这是不组件化时唯一真能「改一处影响全部」的路(jsDesign 有样式面:\`jsd_create_style\` 从样板节点抄一条,其余节点引用 \`*StyleId\`;它**没有变量面**,色板与间距也落在样式上);② **语义化命名当查询键** —— 同类件要一起改时 \`jsd_find\` 按名字/类型一次拎出来,再 \`jsd_batch\` 改(命名乱了这招就废);③ **状态差异一律「族名 / 状态」命名**,将来整族可定位。
|
|
107
|
+
- **改动一处要影响全部 → 改源头**:改主组件 / 改样式 / 改变量,不要逐个改实例;要把一套覆盖从源实例复制到一批目标走 \`jsd_sync_overrides\`(配方 \`jsd://recipes/variant-sync\`)。
|
|
108
|
+
- 多状态组件怎么造:${r}
|
|
109
|
+
- 深入(总纲只给判据,细节在各自的配方):**造变体集** \`jsd://recipes/variant-set\`;**组件属性(布尔 / 文本 / 换绑)的定义与设值** \`jsd://recipes/component-property\`;**变量绑定与批量套用** \`jsd://recipes/variable-binding\`。
|
|
63
110
|
1) 再摸底:jsd_get_selection(depth=2) 看现状(名称/类型/尺寸/填充/子结构),已有节点用 jsd_find 精确定位,不要重复创建同名元素。
|
|
64
111
|
2) 结构分层,调用分批:**成品该多深就多深** —— 屏 → 语义分区 → 卡片 → 卡内图元,四层都要建出来,别只做到「屏 + 分区」就收手。受限的只是**单次调用的传参方式**:children 只用于「容器 + 其直属子节点」这类小结构,别在一次 create 里塞整棵树(易整批失败);分层分批用 jsd_batch 编排多个 per-type create 步骤,每批建完即用 jsd_reparent_nodes 归到父容器。
|
|
65
112
|
3) 命名语义化:用「登录页 / Logo 容器 / 邮箱输入 / 主按钮」这类说明用途的名字,不用「矩形 1」「Frame 2」;同一批元素命名风格保持一致。
|
|
66
|
-
3.5) 抽组件:**先回第 0 条的清单**——已有同族组件就直接 jsd_create_instance 铺开,别新建重复组件;要切状态先看 \`assets.variants[].properties\` 里有没有现成取值。清单里确实没有、且同类单元 ≥2 个且结构一致(按钮 / 输入框 / 列表项 / 图标底)时,才提 COMPONENT、再用 INSTANCE 铺开,别逐个复制;命名走「组件族/状态」。
|
|
67
113
|
4) 归组后再布局:**元素不许直挂屏根** —— 屏内每个语义分区(侧栏 / 顶栏 / 筛选条 / KPI 行 / 每张卡片)各自是一个容器,卡片内部的图元再按语义编组(GROUP:坐标轴 / 网格 / 数据系列 / 图例各一组)。一层不套、几十个元素平铺是后续最难改的形态,别走这个极端。做法:先建容器与元素,再用 jsd_reparent_nodes 逐层归入(**parentId 显式传目标容器 id**,别依赖「当前选中第一个」的缺省值;跨父级移动会保持节点绝对位置,不用手动摆回 x/y,移入 auto-layout 容器时位置交给布局);auto-layout(layoutMode/itemSpacing/padding*/primaryAxisAlignItems 等)最后用 jsd_set_layout 单独设,别在建节点时混着传。
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
114
|
+
5) ${o}
|
|
115
|
+
6) **绘图区用 SVG 还是原生图元,按「之后要改的是哪一类」分**(做法见 \`jsd://recipes/chart-by-code\`):**数值级**(换数据 / 改某根柱的高度 / 挪一个点)→ SVG,回源重算重导比在画布上挪一串节点便宜;\`vectorPaths.data\` **不回读**,画布上读不到也改不了坐标。**样式级**(改色 / 线宽 / 隐藏某个系列)→ 两边都行:SVG 按语义 \`<g id>\` 切层后在画布上就能点名改(实测 jsDesign 会落成同名子分组,渐变与 dash 保留;换平台先回读确认)。**结构级**(要排进 auto-layout 行列 / 要绑变量或样式 / 要做成组件复用 / 表格单元格 / 卡片骨架)→ 必须原生节点,**SVG 不吃布局**。**文案一律原生**(SVG 里的 \`<text>\` 字体字重由引擎解析,不保证)。三者常共存,一张卡的标准形态:卡片 FRAME + 标题/图例/数值/表格用原生节点,中间绘图区塞一个 SVG 子节点。
|
|
116
|
+
7) 间距与字号阶梯:主标题 > 正文标签 > 按钮文本 > 辅助说明;同级元素间距一致,用 itemSpacing 统一控制,不靠手调坐标凑。**长段落要换行**:TEXT 缺省按内容撑开(textAutoResize 缺省 WIDTH_AND_HEIGHT),只给 width 会被引擎改成 NONE 且高度不随内容重算 —— 要固定宽+自动换行传 width + textAutoResize:"HEIGHT",要固定框尺寸传 "NONE"。**字体取 jsd_list_fonts 的 fonts[] 成对值**:family 用 fonts[].family 原样(如 SourceHanSansCN_family),style 用同一项的全名(如 SourceHanSansCN-Bold,不是简称 "Bold")—— 写错会被静默忽略、退回默认字面,结果 warnings 会点名。
|
|
117
|
+
8) 视觉顺序:自上而下按阅读顺序排布,主操作按钮放在输入项之后,次要链接(忘记密码/注册)放最后。
|
|
118
|
+
9) 层序与遮挡:序列化里每个节点都带 \`z\`(= 父级 children 下标 = 绘制顺序,0 = 最底层,越大越靠上),判断谁压谁直接读 z。要调层序用 jsd_reparent_nodes + index(= 目标 z);auto-layout 容器同样支持,若引擎没落位会明确报错,那就改 itemSpacing / 对齐。别靠「新建一个节点压上去」改遮挡。
|
|
119
|
+
10) 样式落点:纯描边图形只传 strokes 就行(fills 会被自动置空,不会变灰块);批量刷色给 ids + recursive(recursive 只作用于后代,容器自己不会被套上方框,要给容器也上色才传 includeSelf=true);实例子节点(位于 INSTANCE 内)的样式覆盖不保证渲染生效 —— 命中时结果的 warnings 会直接给出主组件里对应子节点的 id,改主组件即所有实例继承,只要单实例不同就先 jsd_detach_instance。
|
|
120
|
+
11) 批量回显都做了摘要裁剪(jsd_batch 的节点只留 id/name/type/x/y):含图标/矢量克隆的批次要另配一次 jsd_export 目视验收,别拿回显当验收证据。
|
|
121
|
+
12) 出错回滚:ok=false 或「没找到 X 节点」→ jsd_find 复核 id 是否已失效(可能被连坐删除),必要时 jsd_repair_nodes 清理后重试。**结果 warnings 一律读** —— 它点名的都是「回显成功却没生效」:能力门控字段被忽略、字段回读不一致(fontName 字重被降级 / TEXT 的 width 被 auto-resize 吃掉)、根节点 x/y 被 placement 覆盖;含删除/移父的批次还会报同层几何漂移(引擎把没碰到的兄弟节点静默挪走),照 warnings 给的原值回填,别把它当样式问题排查。
|
|
122
|
+
13) 收敛复核:整批做完只做一次 jsd_get_selection(depth=1),或 jsd_export({ids:[要看的节点id], scale:0.5}) 导小图看效果(ids 为必填数组);**关键视觉改动靠导图目检,回显不等于生效**,不要每步都读一遍。
|
|
77
123
|
|
|
78
124
|
示例结构(登录页):
|
|
79
125
|
- 登录页(FRAME)
|
|
@@ -85,7 +131,7 @@ ${Ka(t)}
|
|
|
85
131
|
- 主按钮(FRAME + TEXT)
|
|
86
132
|
- 辅助链接(FRAME:忘记密码 TEXT + 注册 TEXT)
|
|
87
133
|
|
|
88
|
-
${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function
|
|
134
|
+
${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function Os(e){return`# 文本批量替换
|
|
89
135
|
|
|
90
136
|
## 1. 摸底与分块
|
|
91
137
|
- 对 ${e==null?`当前选中(先用 jsd_get_selection 拿到根 id)`:`节点 ${e}`} 先 jsd_get_selection 看结构,按语义把文本分成几块:表格按行或列、卡片按「同名字段一组」、表单按「标签 + 输入」一组、导航按菜单项一组。
|
|
@@ -103,10 +149,11 @@ ${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回
|
|
|
103
149
|
- 有问题先修当前块再继续下一块,不要把所有错误攒到最后。
|
|
104
150
|
|
|
105
151
|
## 5. 收尾
|
|
106
|
-
- 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function
|
|
152
|
+
- 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function ks(e,t){return`# 同类实例样式批量同步
|
|
107
153
|
|
|
108
154
|
## 适用场景
|
|
109
155
|
把一个实例的样式/文案套用到多个同类实例(卡片组、列表项、表单组……),避免逐个手改。
|
|
156
|
+
「要复用的东西该走组件 / 变体 / 样式 / 变量哪一类」是另一道题,判据在 \`jsd://recipes/design-strategy\` 第 0 条;本配方只管「同一批实例怎么统一」。
|
|
110
157
|
|
|
111
158
|
## 1. 取源实例属性
|
|
112
159
|
- 对 ${e==null?`当前选中(先 jsd_get_selection 确认)`:`节点 ${e}`} 用 jsd_get_selection(depth=2) 确认它是可复用的 INSTANCE,并记录源 id。
|
|
@@ -120,53 +167,59 @@ ${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回
|
|
|
120
167
|
- 引擎不支持时再退化为手工:jsd_set_fill_color / jsd_set_text 等 ids=[目标] 填字段 + jsd_set_instance_properties 设变体值。
|
|
121
168
|
|
|
122
169
|
## 4. 复核
|
|
123
|
-
- jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function
|
|
170
|
+
- jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function As(e,t){let n=e??`目标节点`,r=so(t),i=(A(t,`variables`)?.write??[]).length>0,a=i?`## 3. 批量绑定别逐个往返
|
|
124
171
|
- 建变量时**一次传完**变量列表(失败整体回滚),拿到 collectionId 与 variables[].id;
|
|
125
|
-
${
|
|
126
|
-
- 整条链(建变量 → 绑定 → 回读复核)合并进 jsd_batch
|
|
172
|
+
${co(t)}
|
|
173
|
+
- 整条链(建变量 → 绑定 → 回读复核)合并进 jsd_batch:本批新建的中间 id 用 {{步骤id.字段路径}} 占位符(不回传模型),**已存在的组件 / 变量按名字取**用 {{@comp:名称}} / {{@var:名称}} —— 它读一次 jsd_get_page 的资源清单,省掉「先查 id 再拼批」那一趟往返;名字不唯一或没命中都会点名中止。
|
|
174
|
+
- ⚠ 名字一律按 assets 里**原样**写,不要照搬创建时用的路径:即时设计会把带斜杠的组件名拆成「集合 / 成分」,assets.components[].name 存的是叶子名(真机 2026-10-14:建「探针/组件」之后清单里叫「组件」,而「探针」落在 assets.variants 的集合名上)—— 按创建时那个路径写会不命中,没命中时错误里会给出现有名字。
|
|
175
|
+
- ⚠ 可建 / 可绑的变量类型: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 的第三参收不了它们。
|
|
176
|
+
- ⚠ 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\`,两档别混。
|
|
127
177
|
|
|
128
178
|
## 4. 复核(写后必须回读)
|
|
129
|
-
${
|
|
179
|
+
${lo(t)}
|
|
130
180
|
- 结果的 warnings 一律读:绑定类字段被忽略时会在这里点名。`:`## 3. 本平台没有可用的变量入口,本节跳过
|
|
131
181
|
- 别去试变量 op(daemon 会拦成 platform_unsupported,白跑一趟往返)。
|
|
132
|
-
- 统一色板 /
|
|
182
|
+
- 统一色板 / 间距照第 1 节末尾的替代路径做(那半句就是从事实表 \`variables.fallback\` 投影出来的,不在这里重写);要批量复用样式走 variant-sync 配方(COMPONENT + jsd_sync_overrides)。
|
|
133
183
|
|
|
134
184
|
## 4. 复核
|
|
135
185
|
- 若文档里本来就有绑定(别的平台建的),回读时按字段名比对;本平台读不到绑定字段时,结果里不会出现该键,别把「没有该键」当成「绑定丢了」。`;return`# 变量绑定与批量套用(${n})
|
|
136
186
|
|
|
137
187
|
## 1. 本平台的变量面
|
|
138
188
|
- ${r}
|
|
189
|
+
- 先确认这道题**该由变量来答**:只要一组固定视觉就够(不随模式/主题变)时走样式更轻,判据见 \`jsd://recipes/design-strategy\` 第 0 条。
|
|
139
190
|
|
|
140
191
|
## 2. 摸清现状再动手
|
|
141
|
-
${i?
|
|
192
|
+
${i?uo(t):`- 本平台的读侧也不提供绑定字段,所以下面讲的字段形状只在有变量面的平台上成立 —— 看一眼知道有这回事即可,别在本平台找它。`}
|
|
142
193
|
|
|
143
|
-
${a}`}function
|
|
194
|
+
${a}`}function js(e,t){return`# ${e==null?`组件族`:`组件族「${e}」`}的变体集构建
|
|
144
195
|
|
|
145
196
|
## 1. 先分流(判据是能力位,不是平台名)
|
|
146
|
-
- ${
|
|
197
|
+
- ${ao(t,t==null?null:Cs(Qr.variants))}
|
|
147
198
|
|
|
148
199
|
## 2. 前置
|
|
200
|
+
- 先确认这道题**该由变体来答**:只是几处颜色/字号不同 → 样式;只是同一结构的几种状态 → 才是变体(判据见 \`jsd://recipes/design-strategy\` 第 0 条)。
|
|
149
201
|
- 只收 COMPONENT(**实例不能直接合成**)—— 每个状态各做成一个 COMPONENT,不足两个先 jsd_create_component。
|
|
150
202
|
- **集合已经存在、只是要加一个状态**:用集合级 op 直接加成分(有这组 op 的平台),别再另建组件去合并 —— 合并是「从零造集合」的动作。
|
|
151
203
|
- 每个主件先把**自己的**尺寸与布局做完再合并:成员自身没排好,合并后集合里就是一堆歪的。
|
|
152
204
|
|
|
153
205
|
## 3. 维度与取值怎么定
|
|
154
206
|
- 按第 1 节选定的路子走:**有**集合级管理入口的平台(名单见 jsd_ping 的 platformOps)直接建维度 / 改取值,**别**靠名字;**没有**的平台:变体属性由主件的**名字**承载,对不上就改名字后重新合并,别绕过名字硬塞属性值 —— 名字是引擎的入口,属性值是它的投影。
|
|
155
|
-
- 两条路子共同的验收:动完手立刻回读一次 —— 维度与**可选值**读组件集上的 \`variantGroupProperties\`(该平台没有这个字段时用平台提供的查看 op),单个节点的当前取值读 \`${
|
|
207
|
+
- 两条路子共同的验收:动完手立刻回读一次 —— 维度与**可选值**读组件集上的 \`variantGroupProperties\`(该平台没有这个字段时用平台提供的查看 op),单个节点的当前取值读 \`${A(t,`variants`)?.read??`variantProperties`}\`;确认引擎认的就是你要的那组再往下走。
|
|
156
208
|
|
|
157
209
|
## 4. 取用
|
|
158
210
|
- jsd_create_instance 按 COMPONENT 生成实例;切换状态用 jsd_set_instance_properties(变体属性传字符串,如 {"状态":"禁用"})。
|
|
159
211
|
|
|
160
212
|
## 5. 复核
|
|
161
213
|
- jsd_find 回读每个成员/实例的取值,确认属性与取值集合完整;
|
|
162
|
-
- jsd_export({ids:[集合id], scale:0.5}) 导小图确认成员排布与间距,回显不算验收。`}function
|
|
214
|
+
- jsd_export({ids:[集合id], scale:0.5}) 导小图确认成员排布与间距,回显不算验收。`}function Ms(e,t){let n=e??`目标组件/实例`,r=oo(t),i=Je(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(`
|
|
163
215
|
`);return`# 组件属性的定义与设值(${n})
|
|
164
216
|
|
|
165
217
|
## 1. 分清两件事(混起来是最常见的错)
|
|
218
|
+
- 属性是**组件 / 变体**这一层的事:整块结构复用走组件、状态差异走变体、纯视觉走样式 —— 三类件怎么选见 \`jsd://recipes/design-strategy\` 第 0 条。
|
|
166
219
|
- **定义**:在 COMPONENT / COMPONENT_SET 上建属性。入口是平台 op,名单先经 jsd_ping 的 platformOps 确认(不同平台各自一套,没有统一入口)。
|
|
167
220
|
- **设值**:在 INSTANCE 上给值,三平台同名入口 \`jsd_set_instance_properties\`(不在组件本体上设值)。
|
|
168
221
|
|
|
169
|
-
## 2. 本平台的事实${t==null?`(未探测到平台 —— 下面按平台分别列出)`:`(${
|
|
222
|
+
## 2. 本平台的事实${t==null?`(未探测到平台 —— 下面按平台分别列出)`:`(${b[t]})`}
|
|
170
223
|
- ${r}
|
|
171
224
|
|
|
172
225
|
## 3. 值怎么传
|
|
@@ -186,11 +239,11 @@ ${s}
|
|
|
186
239
|
- 回读 componentProperties / variantProperties 的 value 与期望比对 —— 写后回读才算验收;
|
|
187
240
|
- ⚠ **回读通过 ≠ 画面变了**:属性可能成对存在(\`摘要\`/\`摘要2\`、\`显示铃铛\`/\`显示铃铛2\`),只有**连着可见图层**的那一组会改画面 —— 写错那组时\`componentProperties\` 全部回读为新值、回包 \`ok=true\`,画布却纹丝不动(Figma 真机实测)。所以第 4 节要先读 \`componentPropertyReferences\` 认准连着可见层的是哪一组,写完再用 jsd_find **深度读节点的实际内容 / 可见性**复核,别只看 \`componentProperties\` 的回显;
|
|
188
241
|
- 实例子节点(INSTANCE 内)的样式覆盖不保证渲染生效:命中时结果 warnings 会给出主组件里对应子节点的 id,改主组件即全实例继承;
|
|
189
|
-
- warnings 一律读:被忽略的字段、回读不一致(fontName 字重降级等)都在那里点名。`}var
|
|
190
|
-
`);function
|
|
242
|
+
- warnings 一律读:被忽略的字段、回读不一致(fontName 字重降级等)都在那里点名。`}var Ns=[`// /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(`
|
|
243
|
+
`);function Ps(e,t){return`# 用代码画图表 / 数据可视化:算出 SVG → 落盘 → 导入画布
|
|
191
244
|
|
|
192
245
|
## 0. 前提:没有内置图表工具,这条路就是主路径
|
|
193
|
-
- **先判该不该用 SVG**:本配方适合「几何由数据算出来」的图(折线 / 面积 / 圆环 / 弧 / 热力条 / 带刻度坐标轴)—— 用矩形手拼这些要多几十倍节点还拼不准,换数据时回源重导也比在画布上挪一串节点便宜。**不适合**的三类:要排进 auto-layout 行列的、要绑变量/样式或要做成组件复用的、表格单元格与卡片骨架这类结构件 —— 这些必须原生节点(SVG **不吃布局**,\`vectorPaths.data\` 也不回读)。完整判据见 \`jsd://recipes/design-strategy\` 第
|
|
246
|
+
- **先判该不该用 SVG**:本配方适合「几何由数据算出来」的图(折线 / 面积 / 圆环 / 弧 / 热力条 / 带刻度坐标轴)—— 用矩形手拼这些要多几十倍节点还拼不准,换数据时回源重导也比在画布上挪一串节点便宜。**不适合**的三类:要排进 auto-layout 行列的、要绑变量/样式或要做成组件复用的、表格单元格与卡片骨架这类结构件 —— 这些必须原生节点(SVG **不吃布局**,\`vectorPaths.data\` 也不回读)。完整判据见 \`jsd://recipes/design-strategy\` 第 6 条。
|
|
194
247
|
- 图表一律这样画:**你自己写代码算几何、自己拼 SVG 字符串、落盘,再用 \`jsd_create_svg\` 导入**。本仓没有内置图表工具(别去找、也别试着调)。
|
|
195
248
|
- 前提是**你能执行本地命令**。做不到就改用原生图元(FRAME / RECTANGLE / TEXT / POLYGON)摆一张近似图,或换一个有 shell 的宿主。
|
|
196
249
|
- **不指定库**:用你最顺手的写法 —— 原生 \`Math\` 与数组方法手算坐标就够(见第 7 节的零依赖示例,它同时演示了第 5 节的分层);要用第三方包也行,唯一的判断标准是**它能不能在没有浏览器的环境里跑出字符串**。
|
|
@@ -249,7 +302,7 @@ ${s}
|
|
|
249
302
|
|
|
250
303
|
## 7. 最小可跑示例(零依赖:只用 \`Math\` 与数组;改 \`data\` 即可)
|
|
251
304
|
\`\`\`js
|
|
252
|
-
${
|
|
305
|
+
${Ns}
|
|
253
306
|
\`\`\`
|
|
254
307
|
|
|
255
308
|
## 8. 复核清单
|
|
@@ -258,22 +311,22 @@ ${fs}
|
|
|
258
311
|
- [ ] \`jsd_create_svg\` 结果里有 \`created.id\`(没有=没真导入);
|
|
259
312
|
- [ ] 导入后 \`jsd_find({ ids:[created.id], depth:2 })\` 看过层级:有子层就用,只有一层就按第 6 节另建要改的原生节点;
|
|
260
313
|
- [ ] \`jsd_export\` 出的图肉眼过一遍:轴、刻度、文字都在,没有元素跑到画布外;
|
|
261
|
-
- [ ] 文字要不要可编辑(见第 6 节)—— 要就把标题/图例另建原生节点,别全塞进 SVG 图层。`}function ms(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 hs=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Q(e){let t=br[e.method],n=e=>t.filter(t=>e[t]!==void 0&&De[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+hs,inputSchema:e.inputSchema,outputSchema:un,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)=>ms(e,n(t),r(t))}}var gs=Nr();function _s(e,t,n){return[Q({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:gs}),method:`set_fill`,inputSchema:lr,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:ur,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:dr,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:fr,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:pr,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:mr,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 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:hr,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:gr,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:_r,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:vr,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:yr,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 vs(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 ys(e,t,i){let a=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:nn,outputSchema:vn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:ui,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,r)=>{let{ids:i,format:a,scale:s,savePath:d,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(d&&(n(l(d),{recursive:!0}),o(d,r),a.path=d),f){if(r.byteLength>fi){let n=d??u(c(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${vs(i,t.format)}`);d||o(n,r),a.path=n,h.push(`${e}(实际 ${r.byteLength} 字节 > 上限 ${fi} 字节)已落盘:${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:on,outputSchema:un,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:ui,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:ui})}}),d=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:rn,outputSchema:yn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}});return[a(e,t,i),s(e,t,i),d(e,t,i)]}var bs=`jsd://recipes`,xs=`jsd://recipes/{id}`,Ss=[{id:`design-strategy`,uri:`jsd://recipes/design-strategy`,titleKey:`prompt.designStrategy.title`,whenToUse:`画布创作的通用纪律。**从零设计整页 / 界面之前先读这一条**:先摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、抽组件、归组后再布局、图形区走 SVG 还是原生图元的分流、间距与字号阶梯、层序与遮挡、出错回滚,附示例结构树`,render:()=>os(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:()=>ps(`<在此写明图表种类 + 数据 + 口径>`,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:()=>rs(`<在此粘贴完整 HTML 片段>`)},{id:`icon-grid`,uri:`jsd://recipes/icon-grid`,titleKey:`prompt.iconGrid.title`,whenToUse:`批量插入 Lucide 图标并排成 auto-layout 网格`,argsHint:`参数 icons(逗号分隔的图标名)、size(默认 24)、gap(默认 16)`,render:()=>is(`<图标名1,图标名2,…>`)},{id:`script-ops`,uri:`jsd://recipes/script-ops`,titleKey:`prompt.scriptOps.title`,whenToUse:`把多步画布操作合并成一次 jsd_batch 编排或一段宿主脚本。步骤多、往返多、上下文吃紧时读它(含占位符纪律与收敛复核)`,argsHint:`参数 task(要完成的任务,留空只返回脚本化调用纪律)`,render:()=>as(void 0)},{id:`text-replace-strategy`,uri:`jsd://recipes/text-replace-strategy`,titleKey:`prompt.textReplace.title`,whenToUse:`批量改文案:在一棵子树里定位并替换文本,含命中范围、命名与回显复核纪律`,argsHint:`参数 rootId(子树根节点 id,留空用当前选中)`,render:()=>ss(void 0)},{id:`variant-sync`,uri:`jsd://recipes/variant-sync`,titleKey:`prompt.variantSync.title`,whenToUse:`同类实例的样式批量同步。改一处要影响全部实例时走它 —— 改主组件而不是逐个改实例(含实例子节点覆盖不生效的处置)`,argsHint:`参数 sourceId(样板节点 id)、targetType(目标节点类型)`,render:()=>cs(void 0,void 0)},{id:`variable-binding`,uri:`jsd://recipes/variable-binding`,titleKey:`prompt.variableBinding.title`,whenToUse:`变量绑定与批量套用(按当前平台变量面分流)`,argsHint:`参数 target(目标节点 id,留空用当前选中)`,render:()=>ls(void 0,Z())},{id:`variant-set`,uri:`jsd://recipes/variant-set`,titleKey:`prompt.variantSet.title`,whenToUse:`变体集构建:把同族组件合成 COMPONENT_SET 并设变体属性(按平台能力位分流)`,argsHint:`参数 family(组件族名)`,render:()=>us(void 0,Z())},{id:`component-property`,uri:`jsd://recipes/component-property`,titleKey:`prompt.componentProperty.title`,whenToUse:`组件属性的定义与设值(值形态 / 写入口 / 读侧 / 替代路径四件套,按平台分流)`,argsHint:`参数 target(组件或实例 id,留空只返回做法与分流)`,render:()=>ds(void 0,Z())}];function Cs(e){return Ss.find(t=>t.id===e)}function ws(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,...Ss.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`。"].join(`
|
|
262
|
-
`)}function
|
|
263
|
-
Description=${
|
|
314
|
+
- [ ] 文字要不要可编辑(见第 6 节)—— 要就把标题/图例另建原生节点,别全塞进 SVG 图层。`}function Fs(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 Is=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Q(e){let t=Ar[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Ae[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+Is,inputSchema:e.inputSchema,outputSchema:gn,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)=>Fs(e,n(t),r(t))}}var Ls=Wr();function Rs(e,t,n){return[Q({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Ls}),method:`set_fill`,inputSchema:yr,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。`+Ls,method:`set_stroke`,inputSchema:br,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 无圆角。`+Ls,method:`set_corner_radius`,inputSchema:xr,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:Ls}),method:`set_text`,inputSchema:Sr,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:Cr,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:wr,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 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:Tr,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)。`+Ls,method:`set_effects`,inputSchema:Er,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:Dr,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:Or,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:kr,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 zs(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 Bs(e,t,i){let a=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:un,outputSchema:wn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:bi,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??{},ee=[],m=[];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>Si){let n=u??d(c(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${zs(i,t.format)}`);u||o(n,r),a.path=n,m.push(`${e}(实际 ${r.byteLength} 字节 > 上限 ${Si} 字节)已落盘:${n}`)}else a.dataUrl=`data:${i};base64,${r.toString(`base64`)}`}ee.push(a)}return{exports:ee,dataUrlOverflow:m}},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:pn,outputSchema:gn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:bi,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:bi})}}),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:dn,outputSchema:Tn,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:nr,outputSchema:jn,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:rr,outputSchema:Mn,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 Vs=`jsd://recipes`,Hs=`jsd://recipes/{id}`,Us=[{id:`design-strategy`,uri:`jsd://recipes/design-strategy`,titleKey:`prompt.designStrategy.title`,whenToUse:`画布创作的通用纪律。**从零设计整页 / 界面之前先读这一条**:先查可复用件(按「要复用的是什么」选件类 —— 结构走组件、状态走变体、固定视觉走样式、语义 token 走变量,含各平台复用入口与「命中就复用 / 改源头不逐个改实例」的纪律,以及**什么时候别抽组件**:差异落在实例子节点上、平台未声明 inPlaceVariants、往返预算压不住),再摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局、图形区走 SVG 还是原生图元的分流、间距与字号阶梯、层序与遮挡、出错回滚,附示例结构树`,render:()=>Ds(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:()=>Ps(`<在此写明图表种类 + 数据 + 口径>`,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:()=>ws(`<在此粘贴完整 HTML 片段>`)},{id:`icon-grid`,uri:`jsd://recipes/icon-grid`,titleKey:`prompt.iconGrid.title`,whenToUse:`批量插入 Lucide 图标并排成 auto-layout 网格`,argsHint:`参数 icons(逗号分隔的图标名)、size(默认 24)、gap(默认 16)`,render:()=>Ts(`<图标名1,图标名2,…>`)},{id:`script-ops`,uri:`jsd://recipes/script-ops`,titleKey:`prompt.scriptOps.title`,whenToUse:`把多步画布操作合并成一次 jsd_batch 编排或一段宿主脚本;步骤多、往返多、上下文吃紧时读它。也覆盖**整页/整档批量改造**(先摸底、确认现状形态、id 的三种来源、按块切批、清单装不下时用 callsFile 或 CLI exec、回读复核与点名类错误不重试)`,argsHint:`参数 task(要完成的任务,留空只返回脚本化调用纪律)`,render:()=>Es(void 0)},{id:`text-replace-strategy`,uri:`jsd://recipes/text-replace-strategy`,titleKey:`prompt.textReplace.title`,whenToUse:`批量改文案:在一棵子树里定位并替换文本,含命中范围、命名与回显复核纪律`,argsHint:`参数 rootId(子树根节点 id,留空用当前选中)`,render:()=>Os(void 0)},{id:`variant-sync`,uri:`jsd://recipes/variant-sync`,titleKey:`prompt.variantSync.title`,whenToUse:`同类实例的样式批量同步。改一处要影响全部实例时走它 —— 改主组件而不是逐个改实例(含实例子节点覆盖不生效的处置)`,argsHint:`参数 sourceId(样板节点 id)、targetType(目标节点类型)`,render:()=>ks(void 0,void 0)},{id:`variable-binding`,uri:`jsd://recipes/variable-binding`,titleKey:`prompt.variableBinding.title`,whenToUse:`变量绑定与批量套用(按当前平台变量面分流)`,argsHint:`参数 target(目标节点 id,留空用当前选中)`,render:()=>As(void 0,Z())},{id:`variant-set`,uri:`jsd://recipes/variant-set`,titleKey:`prompt.variantSet.title`,whenToUse:`变体集构建:把同族组件合成 COMPONENT_SET 并设变体属性(按平台能力位分流)`,argsHint:`参数 family(组件族名)`,render:()=>js(void 0,Z())},{id:`component-property`,uri:`jsd://recipes/component-property`,titleKey:`prompt.componentProperty.title`,whenToUse:`组件属性的定义与设值(值形态 / 写入口 / 读侧 / 替代路径四件套,按平台分流)`,argsHint:`参数 target(组件或实例 id,留空只返回做法与分流)`,render:()=>Ms(void 0,Z())}];function Ws(e){return Us.find(t=>t.id===e)}function Gs(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,...Us.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`。"].join(`
|
|
315
|
+
`)}function Ks(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function qs(e){let t=Us.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,Vs,{title:`resources.title7`,description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${t}`,mimeType:`text/markdown`},async()=>Ks(Vs,Gs())),e.registerResource(`recipe`,new oe(Hs,{list:void 0}),{title:`resources.title8`,description:`按 id 读取配方正文(markdown),如 ${Hs.replace(`{id}`,`chart-by-code`)}。可用 id:${t};索引与「何时用」见 ${Vs}`,mimeType:`text/markdown`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r,a=i==null?void 0:Ws(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${t})`);return Ks(e,a.render())})]}function Js(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function Ys(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()=>Js(`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()=>Js(`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()=>Js(`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()=>Js(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new oe(`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 Js(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()=>Js(`jsd://platform/state`,Oi()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}function Xs(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:Ei.label}),description:n.t(`ping.description`,{client:Ei.label}),outputSchema:_n,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},alwaysEnabled:!0,timeout:yi,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:yi});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:Gt,outputSchema:vn,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:fn,outputSchema:An,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 Zs=[Xs,ns,vs,ys,go,Rs,_s,Bs,no,bs,Ys,qs,(e,t,n)=>xs(e,n)];function Qs(e,t=ha()){let n=new ae({name:hi,version:I},{supportedProtocolVersions:[`2026-07-28`,...se],instructions:t.t(`mcp.instructions`),cacheHints:{"tools/list":{ttlMs:xi,cacheScope:`private`},"prompts/list":{ttlMs:xi,cacheScope:`private`},"resources/list":{ttlMs:xi,cacheScope:`private`},"resources/templates/list":{ttlMs:xi,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}});for(let r of Zs)r(n,e,t);return n}var $s=null;async function ec(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ri);try{let n=await fetch(ni(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 tc(){let e=Date.now();if($s!=null&&e-$s.at<18e5)return $s.latest;let[t,n]=await Promise.all([ec(ei.ui),ec(ei.mcp)]);return M(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),$s={at:e,latest:{ui:t,mcp:n}},$s.latest}async function nc(){let e=Date.now()+_i;do{let e=await Bi();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 Vi(250)}while(Date.now()<e);return await R()===null||(j(`已有 daemon 持有端口,本次启动跳过`),!1)}async function rc(e){if(!await nc()){await zi();return}await e.start(mi),j(`daemon: 插件 WS ws://localhost:${e.port}`);let t=null,n=ce(()=>t??=Qs(e),{legacy:`reject`}),r=he(n),i=pe(),a=me(),o=null,s=null,c=()=>{tc().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=c;let l=t=>{j(`daemon 退出: ${t}`),s!=null&&clearInterval(s),n.close().catch(e=>{M(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),o?.close(),process.exit(0)};await new Promise((e,t)=>{o=te((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?j(r):M(r)}),e.method===`GET`&&o===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:hi,version:I,pid:process.pid,startedAt:gi}));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(F,`127.0.0.1`,()=>e())}),j(`daemon: MCP HTTP http://127.0.0.1:${F}/mcp`),j(`daemon 就绪,常驻运行(更新时由版本自检自动替换)`),s=setInterval(c,Se),c(),process.on(`SIGINT`,()=>l(`SIGINT`))}async function ic(){await zi();let e=await Bi();if(e.state===`foreign`)P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1);else if(e.state===`proxy`){await pa(e.client);return}e.state===`none`?(j(`未发现 daemon,自动拉起...`),ra()):j(`daemon 正在启动,等待就绪...`);let t=Date.now()+_i;for(;Date.now()<t;){await Vi(250);let e=await Bi();if(e.state===`proxy`){await pa(e.client);return}e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}P(`daemon 启动超时(${_i/1e3}s),请检查残留进程后重试`),process.exit(1)}var $=`text-to-design-mcp`;function ac(e){return e.includes(` `)?`"${e}"`:e}function oc(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function sc(){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 cc(e,t){return[{kind:`write`,path:d(s(),`.config/systemd/user`,`${$}.service`),content:`[Unit]
|
|
316
|
+
Description=${hi} (design plugin bridge: WS ${mi} / MCP HTTP ${F})
|
|
264
317
|
Documentation=https://github.com/wzrove/text-to-design
|
|
265
318
|
After=network.target
|
|
266
319
|
|
|
267
320
|
[Service]
|
|
268
321
|
Type=simple
|
|
269
322
|
Environment=TEXT_TO_DESIGN_MCP_ROLE=daemon
|
|
270
|
-
ExecStart=${
|
|
323
|
+
ExecStart=${ac(e)} ${ac(t)} daemon
|
|
271
324
|
Restart=on-failure
|
|
272
325
|
RestartSec=2
|
|
273
326
|
|
|
274
327
|
[Install]
|
|
275
328
|
WantedBy=default.target
|
|
276
|
-
`},{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
|
|
329
|
+
`},{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 lc(e,t){let n=d(s(),`Library/LaunchAgents`,`com.${$}.plist`),r=d(s(),`Library/Logs`,`${$}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
277
330
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
278
331
|
<plist version="1.0">
|
|
279
332
|
<dict>
|
|
@@ -281,8 +334,8 @@ WantedBy=default.target
|
|
|
281
334
|
<string>com.${$}</string>
|
|
282
335
|
<key>ProgramArguments</key>
|
|
283
336
|
<array>
|
|
284
|
-
<string>${
|
|
285
|
-
<string>${
|
|
337
|
+
<string>${oc(e)}</string>
|
|
338
|
+
<string>${oc(t)}</string>
|
|
286
339
|
<string>daemon</string>
|
|
287
340
|
</array>
|
|
288
341
|
<key>EnvironmentVariables</key>
|
|
@@ -298,9 +351,12 @@ WantedBy=default.target
|
|
|
298
351
|
<false/>
|
|
299
352
|
</dict>
|
|
300
353
|
<key>StandardOutPath</key>
|
|
301
|
-
<string>${
|
|
354
|
+
<string>${oc(r)}</string>
|
|
302
355
|
<key>StandardErrorPath</key>
|
|
303
|
-
<string>${
|
|
356
|
+
<string>${oc(r)}</string>
|
|
304
357
|
</dict>
|
|
305
358
|
</plist>
|
|
306
|
-
`;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
|
|
359
|
+
`;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 uc(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,$,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${$}`}]}function dc(e,t){return process.platform===`linux`?cc(e,t):process.platform===`darwin`?lc(e,t):process.platform===`win32`?uc(e,t):[]}function fc(){if(process.platform===`linux`){let e=d(s(),`.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=d(s(),`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 pc(e,t){if(e.kind===`note`){j(`提示:${e.line}`);return}if(e.kind===`write`){if(t){j(`[dry-run] 写入 ${e.path}`),j(e.content.trimEnd());return}n(l(e.path),{recursive:!0}),o(e.path,e.content,`utf8`),j(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){j(`[dry-run] 删除 ${e.path}`);return}i(e.path,{force:!0}),j(`已删除 ${e.path}`);return}if(t){j(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let r=fe(e.cmd,e.args,{encoding:`utf8`});if(r.error){N(`执行失败(${e.cmd}):${r.error.code??r.error.message} —— 定义文件已就位,可手动启用`);return}if(r.status!==0){N(`${e.cmd} 退出码 ${r.status}: ${(r.stderr??``).trim().slice(0,200)}`);return}j(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function mc(e,t){e.length===0&&(P(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)pc(n,t)}function hc(e={}){let t=sc(),n,r;`problem`in t?(e.force||(P(t.problem),process.exit(1)),N(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=f(process.argv[1]??``)):(n=t.exe,r=t.script),j(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),mc(dc(n,r),e.dryRun===!0),e.dryRun||j(`完成。校验:curl -s http://127.0.0.1:${F}/health(应返回 ${hi} ${I})`)}function gc(e={}){j(`${e.dryRun?`[dry-run] `:``}注销自启`),mc(fc(),e.dryRun===!0)}async function _c(){let e=Date.now()+_i;for(;Date.now()<e;){let e=await Bi();if(e.state===`proxy`)return e.client;if(e.state===`foreign`)throw Error(`MCP 端口被**非本项目**的服务占用,exec 不会去猜它是什么。请先释放端口(见 daemon 启动日志里的排查提示)。`);e.state===`none`&&ra(process.argv.slice(1,2)),await Vi(250)}throw Error(`等待 daemon 就绪超时(${_i}ms)。若刚从旧版本升级,旧 daemon 可能还没释放端口,稍后重试即可。`)}function vc(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 yc(e,t){let n=await _a(e),r=n.stopOnError??!0;if(vc(n.path,n.calls,r,t.json===!0),t.dryRun===!0){process.stdout.write(`--dry-run:只校验了清单,未连接 daemon,未执行任何步骤。
|
|
360
|
+
`);return}let i=await _c();try{let e=await i.callTool({name:`jsd_batch`,arguments:{calls:n.calls,stopOnError:r,checkDrift:n.checkDrift}},{timeout:Ci+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(`
|
|
361
|
+
`);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 bc(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]
|
|
362
|
+
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await yc(t,n)}catch(e){P(e instanceof Error?e.message:String(e)),process.exitCode=1}}var xc=new Li;xc.onConnectionChange=e=>{if(j(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录不变)`),e){ji(xc);return}Ai(`插件断开`)},ci((e,t)=>xc.notifyLog(e,t));var Sc=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),Cc=process.argv.slice(2),wc=Cc.find(e=>e===`install-service`||e===`uninstall-service`),Tc=Cc[0]===`exec`&&!Sc;if(wc){ci((e,t)=>{(e===`error`||e===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${t}\n`)});let e={dryRun:Cc.includes(`--dry-run`),force:Cc.includes(`--force`)};wc===`install-service`?hc(e):gc(e)}else Tc?(ci((e,t)=>{process.stderr.write(`[text-to-design-mcp] ${t}\n`)}),bc(Cc.slice(1))):Sc?rc(xc).catch(e=>{xc.stop(),P(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):ic().catch(e=>{P(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
|